{"id":17133396,"url":"https://github.com/chronark/prefixed-id","last_synced_at":"2025-10-11T20:06:47.556Z","repository":{"id":105802119,"uuid":"576669535","full_name":"chronark/prefixed-id","owner":"chronark","description":"Generate prefixed ids just like stripe: sk_helloworld","archived":false,"fork":false,"pushed_at":"2022-12-10T15:59:53.000Z","size":37,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T23:03:07.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chronark.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-10T15:42:48.000Z","updated_at":"2023-11-08T11:49:54.000Z","dependencies_parsed_at":"2023-06-14T02:00:59.343Z","dependency_job_id":null,"html_url":"https://github.com/chronark/prefixed-id","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Fprefixed-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Fprefixed-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Fprefixed-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronark%2Fprefixed-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chronark","download_url":"https://codeload.github.com/chronark/prefixed-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234671010,"owners_count":18869278,"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":[],"created_at":"2024-10-14T19:42:05.109Z","updated_at":"2025-09-29T22:31:00.478Z","avatar_url":"https://github.com/chronark.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1 align=\"center\"\u003e@chronark/prefixed-id\u003c/h1\u003e\n    \u003ch5\u003epre_JUbF9zRGz9hrFXUyNJLXcowD9GsqCD\u003c/h5\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\nA minimal library to generate Stripe inspired predixed ids for your application.\nPrefixed ids look like this: `pre_JUbF9zRGz9hrFXUyNJLXcowD9GsqCD`. They can be very useful if you\nhave different entities and want to quickly identify them.\n\nGenerated ids rely on the provided crypto implementation. If you use either `window.crypto` or \n`crypto` from \"node:crypto\", the ids will be cryptographically secure.\n\n\nWorks in\n- Nodejs\n- Cloudflare Workers\n- Vercel Edge\n\n\n## Install\n\n```\nnpm i @chronark/prefixed-id\n```\n\n## Usage\n\n### Nodejs\n\n```ts\n\nimport nodeCrypto from \"node:crypto\"\n\nconst idGenerator = new IdGenerator({\n    prefixes: {\n        \"user\": \"u\",\n    },\n    crypto: nodeCrypto\n})\n\nconsole.log(idGenerator.id(\"user\"))\n// u_PtbBA7NGcYYDpae6ULWujk\n```\n\n### WebCrypto\n\n- Cloudflare Workers\n- Vercel Edge\n\n```ts\nconst idGenerator = new IdGenerator({\n    prefixes: {\n        \"user\": \"u\",\n    },\n    crypto: crypto // will be globally defined\n})\n\nconsole.log(idGenerator.id(\"user\"))\n// u_PtbBA7NGcYYDpae6ULWujk\n```\n\n## Options \n\nYou may pass these options to the constructor to customize the id generation.\n\n```ts\n{\n\t/**\n\t *\n\t * @default \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"\n\t */\n\talphabet?: string;\n\n\t/**\n\t * Either window.crypto or crypto from node\n\t *\n\t * @default window?.crypto\n\t */\n\tcrypto?: Crypto;\n\n\t/**\n\t * Byte size of the generated id\n\t */\n\tsize?: number;\n};\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronark%2Fprefixed-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchronark%2Fprefixed-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronark%2Fprefixed-id/lists"}