{"id":28445063,"url":"https://github.com/wechaty/token","last_synced_at":"2025-07-17T16:33:12.532Z","repository":{"id":57397580,"uuid":"391824214","full_name":"wechaty/token","owner":"wechaty","description":"Wechaty Token-Based Authentication Manager","archived":false,"fork":false,"pushed_at":"2022-01-19T08:07:36.000Z","size":145,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T20:39:09.355Z","etag":null,"topics":["cli","grpc","token","wechaty"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/wechaty-token","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechaty.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":"2021-08-02T05:20:47.000Z","updated_at":"2022-05-16T15:52:13.000Z","dependencies_parsed_at":"2022-08-31T14:21:13.953Z","dependency_job_id":null,"html_url":"https://github.com/wechaty/token","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wechaty/token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Ftoken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Ftoken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Ftoken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Ftoken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechaty","download_url":"https://codeload.github.com/wechaty/token/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Ftoken/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265629946,"owners_count":23801494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli","grpc","token","wechaty"],"created_at":"2025-06-06T10:11:12.646Z","updated_at":"2025-07-17T16:33:12.524Z","avatar_url":"https://github.com/wechaty.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wechaty-token\n\n[![NPM](https://github.com/wechaty/token/actions/workflows/npm.yml/badge.svg)](https://github.com/wechaty/token/actions/workflows/npm.yml)\n[![NPM Version](https://badge.fury.io/js/wechaty-token.svg)](https://badge.fury.io/js/wechaty-token)\n[![npm (tag)](https://img.shields.io/npm/v/wechaty-token/next.svg)](https://www.npmjs.com/package/wechaty-token?activeTab=versions)\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)\n\n![wechaty token](docs/images/wechaty-token.png)\n\nWechaty Token Based Authentication Manager\n\n## Install\n\n```sh\nnpm install -g wechaty-token\n```\n\n## CLI Usage\n\n```sh\n$ wechaty-token --help\n\nwechaty-token \u003csubcommand\u003e\n\u003e Wechaty utility for discovering and generating tokens\n\nwhere \u003csubcommand\u003e can be one of:\n\n- generate - Generate a new Wechaty Token\n- discover - Wechaty TOKEN Service Discovery\n\nFor more help, try running `wechaty-token \u003csubcommand\u003e --help`\n```\n\n### Wechaty Token Discovery\n\n```sh\n$ wechaty-token discover --help\n\nwechaty-token discover\n\u003e Wechaty TOKEN Service Discovery\n\nARGUMENTS:\n  \u003cstr\u003e - Wechaty Puppet Service TOKEN\n\nFLAGS:\n  --help, -h - show help\n```\n\nExample:\n\n```sh\n# Discover a valid token (in-service)\n$ wechaty-token discover puppet_IN-SERVICE-TOKEN\n{\n  \"host\": \"1.2.3.4\",\n  \"port\": 5678\n}\n$ echo $?\n0\n\n# Discover a unvalid token (out-of-service)\n$ wechaty-token discover puppet_OUT-OF-SERVICE-TOKEN\nNotFound\n$ echo $?\n1\n```\n\n### Generate Wechaty Token\n\n```sh\n$ wechaty-token generate --help\n\nwechaty-token generate\n\u003e Generate a new Wechaty Token\n\nOPTIONS:\n  --type, -t \u003cstr\u003e - The type of the Wechaty Puppet Service [optional]\n\nFLAGS:\n  --help, -h - show help\n```\n\nExample:\n\n```sh\n# Generate a UUID token (`uuid` will be the default type)\n$ wechaty-token generate\nuuid_1fab726b-e3d3-40ce-8b7b-d3bd8c9fd280\n\n# Generate token with type `foo`\n$ wechaty-token generate --type foo\nfoo_1fab726b-e3d3-40ce-8b7b-d3bd8c9fd280\n```\n\n## gRPC Resolver Usage\n\nWe now can use `wechaty:///${TOKEN}` as gRPC address for Wechaty Service Token Discovery.\n\nThe `WechatyResolver` is for resolve the above address and help gRPC to connect to the right host and port.\n\n```ts\nimport { WechatyResolver } from 'wechaty-token'\nWechatyResolver.setup()\n// That's it! You can use `wechaty:///${TOKEN}` as gRPC address now!\n// const routeguide = grpc.loadPackageDefinition(packageDefinition).routeguide;\n// client = new routeguide.RouteGuide('wechaty:///${TOKEN}',\n//                                     grpc.credentials.createInsecure());\n// See: https://grpc.io/docs/languages/node/basics/\n```\n\nSee:\n\n- [gRPC Name Resolution](https://github.com/grpc/grpc/blob/master/doc/naming.md)\n- [Wechaty Puppet Service Code](https://github.com/wechaty/wechaty-puppet-service/blob/3a0285432e6916720c40604c61bcea6be5f63ab5/src/client/puppet-service.ts#L284-L285)\n\n## History\n\n### master v1.0 (Nov 28, 2021)\n\n1. ES Module support\n1. TypeScript 4.5\n1. Wechaty Token Discovery output `JSON.stringify` format\n\n### v0.5 (Sep 8, 2021)\n\n1. Wechaty Token format standard released: `SNI_UUID`\n    1. `SNI` will be used as Server Indicator Name (SNI) when we are using TLS\n    1. `UUID` is a standard UUID format (v4)\n1. add `wechatyToken.sni` support.\n\n### v0.4 (Aug 15, 2021)\n\n1. Use `cockatiel` to implement `RetryPolicy`\n1. Use `nock` to implement HTTP unit testing\n1. Implemented [#1](https://github.com/wechaty/token/issues/1)\n\n### v0.2 master (Aug 2, 2021)\n\n1. `wechaty-token` CLI released\n1. gRPC Resolver for Wechaty: Enabled `xds` like schema `wechaty:///uuid_TOKEN` for gRPC client\n\n### v0.0.1 (Aug 1, 2021)\n\nInited\n\n## Author\n\n[Huan LI](https://github.com/huan) ([李卓桓](http://linkedin.com/in/zixia)), Google Developer Expert (Machine Learning), zixia@zixia.net\n\n[![Profile of Huan LI (李卓桓) on StackOverflow](https://stackexchange.com/users/flair/265499.png)](https://stackexchange.com/users/265499)\n\n## Copyright \u0026 License\n\n- Code \u0026 Docs © 2018-now Huan LI \\\u003czixia@zixia.net\\\u003e\n- Code released under the Apache-2.0 License\n- Docs released under Creative Commons\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Ftoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechaty%2Ftoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Ftoken/lists"}