{"id":17134711,"url":"https://github.com/robojones/token-server","last_synced_at":"2026-03-10T02:33:10.912Z","repository":{"id":57377718,"uuid":"133087664","full_name":"robojones/token-server","owner":"robojones","description":"TLS encrypted communication in Node.js","archived":false,"fork":false,"pushed_at":"2018-09-05T15:34:36.000Z","size":94,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T01:45:15.781Z","etag":null,"topics":["buffer","client","connection","encrypted","npm","server","ssl","tls"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/token-server","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robojones.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-11T20:53:25.000Z","updated_at":"2019-09-16T08:48:23.000Z","dependencies_parsed_at":"2022-09-19T03:30:29.843Z","dependency_job_id":null,"html_url":"https://github.com/robojones/token-server","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/robojones/token-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Ftoken-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Ftoken-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Ftoken-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Ftoken-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robojones","download_url":"https://codeload.github.com/robojones/token-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robojones%2Ftoken-server/sbom","scorecard":{"id":781081,"data":{"date":"2025-08-11","repo":{"name":"github.com/robojones/token-server","commit":"5ee6377e1daa4aa449fe08acad4ec819f42f2dda"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T04:56:17.673Z","repository_id":57377718,"created_at":"2025-08-23T04:56:17.674Z","updated_at":"2025-08-23T04:56:17.674Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30322645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buffer","client","connection","encrypted","npm","server","ssl","tls"],"created_at":"2024-10-14T19:45:33.851Z","updated_at":"2026-03-10T02:33:10.879Z","avatar_url":"https://github.com/robojones.png","language":"TypeScript","readme":"# token-server\n\nTLS encrypted communication\n\n[![CircleCI](https://circleci.com/gh/robojones/token-server.svg?style=svg)](https://circleci.com/gh/robojones/token-server)\n\n[![Test Coverage](https://api.codeclimate.com/v1/badges/f74e4d181314dd0d1e31/test_coverage)](https://codeclimate.com/github/robojones/token-server/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f74e4d181314dd0d1e31/maintainability)](https://codeclimate.com/github/robojones/token-server/maintainability)\n\nThis module simplifies SSL encrypted communication.\nIt allows you to send messages (called tokens) from a client to a server and back.\n\n## Example\n\nThis example shows how a client and a server can be connected using self-signed certificates.\n\nFor some help on how to generate self-signed certificates [see this comment](https://github.com/nodejs/help/issues/253#issuecomment-242425636).\n\n```javascript\nconst { TokenServer, TokenClient } = require('token-server')\n\n/* ### Server ### */\n\nconst server = new TokenServer({\n\thost: 'localhost',\n\tport: 8090,\n\n\tkey: fs.readFileSync('certs/server/server.key'),\n\tcert: fs.readFileSync('certs/server/server.crt'),\n\tca: fs.readFileSync('certs/ca/ca.crt'),\n\trequestCert: true, // ask for a client cert\n})\n\n// Listen for tokens from the client.\nserver.on('token', (token, connection) =\u003e {\n\tconsole.log('The client says:', token.toString())\n\n\tconst token = Buffer.from('I am happy to see you!')\n\tconnection.send(token)\n})\n\n/* ### Client ### */\n\nconst client = new TokenClient({\n\thost: 'localhost',\n\tport: 8090,\n\n\tkey: fs.readFileSync('certs/client/client.key'),\n\tcert: fs.readFileSync('certs/client/client.crt'),\n\tca: fs.readFileSync('certs/ca/ca.crt'),\n})\n\nclient.on('token', (token, connection) =\u003e {\n\tconsole.log('The server responds', token.toString())\n})\n\nconst token = Buffer.from('Hello!')\nclient.send(token)\n```\n\n## API\n\n### Table of Contents\n\n- [TokenClient](#tokenclient)\n\t- [constructor](#tokenclient-constructor)\n\t- [Event: \"close\"](#tokenclient-close)\n\t- [Event: \"connect\"](#tokenclient-connect)\n\t- [Event: \"error\"](#tokenclient-error)\n\t- [Event: \"token\"](#tokenclient-token)\n\t- [close()](#tokenclientclose)\n\t- [connect()](#tokenclientconnect)\n\t- [send()](#tokenclientsend)\n- [TokenServer](#tokenserver)\n\t- [constructor](#tokenserver-constructor)\n\t- [Event: \"close\"](#tokenserver-close)\n\t- [Event: \"connect\"](#tokenserver-connect)\n\t- [Event: \"error\"](#tokenserver-error)\n\t- [Event: \"token\"](#tokenserver-token)\n\t- [close()](#tokenserverclose)\n\t- [connect()](#tokenserverconnect)\n- [Connection](#connection)\n\t- [constructor](#connection-constructor)\n\t- [Event: \"token\"](#connection-token)\n\t- [isDead](#connectionisdead)\n\t- [close()](#connectionclose)\n\t- [send()](#connectionsend)\n\n### TokenClient\n\nThis class represents a client that can connect to a server.\n\n#### TokenClient constructor\n\n```typescript\nconst client = new Client(options)\n```\n\n- **options**\n\t- port `\u003cnumber\u003e` The port that the client should connect to.\n\t- host `\u003cstring\u003e` The hostname of the server.\n\t- key `\u003cstring|Buffer\u003e` The private key of the client.\n\t- cert `\u003cstring|Buffer\u003e` The SSL certificate of the client.\n\t- ca `\u003cstring|Buffer\u003e` The authority certificate (used for self signed certificates)\n\t- All other options accepted by [tls.connect()](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)\n\n#### TokenClient: \"close\"\n\nThis event is emitted when the client connection gets closed.\n\n```typescript\nclient.on('close', (hadError) =\u003e {\n\t// ...your code...\n})\n```\n\n- hadError `\u003cboolean\u003e` Is `true` if the client connection was closed by an error (e.g. if the server did not respond).\n\n#### TokenClient: \"connect\"\n\nThis event is emitted when the client is successfully connected to the server.\n\n```typescript\nclient.on('connect', () =\u003e {\n\t// ...your code...\n})\n```\n\n#### TokenClient: \"error\"\n\nThis event is emitted when a connection error occured. It is always followed by a [\"close\" event](#tokenclient-close).\n\n```typescript\nclient.on('error', (error) =\u003e {\n\t// ...your code...\n})\n```\n\n- error `\u003cError\u003e` The error that was emitted by the underlying TLS socket.\n\n#### TokenClient: \"token\"\n\nThis event is emitted when the server sends a token in reponse to a token that was sent by this client.\n\n```typescript\nclient.on('token', (token, connection) =\u003e {\n\t// ...your code...\n})\n```\n\n- token `\u003cBuffer\u003e` The token that was received.\n- connection `\u003cConnection\u003e` [see here](#connection) The connection that sent the token.\n\n#### TokenClient#close()\n\nThis method is used to disconnect the client from the server.\n\n```typescript\nclient.close()\n```\n\nThis method returns `true` if the connection was ended.\nIf the client was already disconnected, the method returns `false`.\n\n#### TokenClient#connect()\n\nThis method is used to reconnect the client to the server if the connection was closed.\n\n```typescript\nclient.connect(delay)\n```\n\n- delay `\u003cnumber\u003e` _(optional)_ Time in milliseconds to wait before a new connection to the server is created.\n\nReturns `true` if a new connection will be created. If the client is already connected, then `false` will be returned.\n\n#### TokenClient#send()\n\nThis method allows you to send a token to the server.\nPlease note that the server has no `send()` method.\nIt can only respond if it receives a token of the client.\n\n```typescript\nclient.send(token)\n```\n\n- token `\u003cBuffer\u003e` The token that should be sent to the server.\n\n### TokenServer\n\nThis class represents a server that accepts SSL encrypted connections.\n\n#### TokenServer constructor\n\n```typescript\nconst server = new TokenServer(options)\n```\n\n- **options**\n\t- port `\u003cnumber\u003e` The port that the server should listen to.\n\t- host `\u003cstring\u003e` The hostname to listen to.\n\t- key `\u003cstring|Buffer\u003e` The private key of the server.\n\t- cert `\u003cstring|Buffer\u003e` The SSL certificate of the server.\n\t- ca `\u003cstring|Buffer\u003e` The authority certificate (used for self signed certificates)\n\t- All other options accepted by [tls.createServer()](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) and [server.listen](https://nodejs.org/api/net.html#net_server_listen_options_callback).\n\n#### TokenServer: \"close\"\n\nThis event is emitted when the server gets closed.\n\n```typescript\nserver.on('close', (hadError) =\u003e {\n\t// ...your code...\n})\n```\n\n- hadError `\u003cboolean\u003e` Is `true` if the server was closed by an error (e.g. if the port was already in use).\n\n#### TokenServer: \"connect\"\n\nThis event is emitted when the server is successfully listening to the specified port.\n\n```typescript\nserver.on('connect', () =\u003e {\n\t// ...your code...\n})\n```\n\n#### TokenServer: \"error\"\n\nThis event is emitted when a server error occured. It is always followed by a [\"close\" event](#tokenserver-close).\n\n```typescript\nserver.on('error', (error) =\u003e {\n\t// ...your code...\n})\n```\n\n- error `\u003cError\u003e` The error that was emitted by the underlying TLS server.\n\n#### TokenServer: \"token\"\n\nThis event is emitted when the server receives a token from a client.\nThe server send a token back to the client by calling `connection.send(token)`.\n\n```typescript\nserver.on('token', (token, connection) =\u003e {\n\t// ...your code...\n})\n```\n\n- token `\u003cBuffer\u003e` The token that was received.\n- connection `\u003cConnection\u003e` [see here](#connection) The connection that sent the token.\n\n#### TokenServer#close()\n\nThis method is used to disconnect the server.\nThe server will wait for all connections to close before it stops listening to its port.\n\n```typescript\nserver.close()\n```\n\nThis method returns `true` if the server was closed.\nIf the server was already closed, the method returns `false`.\n\n#### TokenServer#connect()\n\nThis method is used to reconnect the server to its port.\nYou can use this method if the port was used before und you want to retry to listen to the port.\n\n```typescript\nconst result = client.connect(delay)\n```\n\n- delay `\u003cnumber\u003e` _(optional)_ Time in milliseconds to wait before the server tries to listen to the port.\n\nReturns `true` if a new connection will be created. If the server is already connected, then `false` will be returned.\n\n### Connection\n\nThis class is a wrapper for a stream or socket.\nIt parses all the data that goes through the stream and emits a `\"token\"` event when a token gets sent.\nThe class can be used on both sides of a duplex stream to send and receive tokens.\n\n#### Connection constructor\n\n```typescript\nconst connection = new Connection(socket)\n```\n\n- socket `\u003cnet.Socket\u003e` [see here](https://nodejs.org/api/net.html#net_class_net_socket) A connection that can be created e.g. with [net.connect](https://nodejs.org/api/net.html#net_net_connect).\n\n#### Connection: \"token\"\n\nThis event is emitted when a token arrives at the underlying socket.\n\n```typescript\nconnection.on('token', (token) =\u003e {\n\t// ...your code...\n})\n```\n\n- token `\u003cBuffer\u003e` The token that was received.\n\n#### Connection#isDead\n\nIs a boolean that is `true` if the underlying socket is writable and `false` if it is not.\n\n```typescript\nconst status = connection.isDead\n```\n\n#### Connection#close()\n\nThis method is used to disconnect from the server.\n\n```typescript\nconst result = connection.close()\n```\n\nThis method returns `true` if the connection was ended.\nIf the client was already disconnected, the method returns `false`.\n\n#### Connection#send()\n\nThis method allows you to send a token through the connection.\n\n```typescript\nconst success = client.send(token)\n```\n\nThe method returns `true` if the message was written to the underlying socket. It returns `false` if the connection is dead.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobojones%2Ftoken-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobojones%2Ftoken-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobojones%2Ftoken-server/lists"}