{"id":23639063,"url":"https://github.com/humanjavaenterprises/nostr-nsec-seedphrase","last_synced_at":"2025-08-31T14:32:13.825Z","repository":{"id":266750434,"uuid":"899202823","full_name":"HumanjavaEnterprises/nostr-nsec-seedphrase","owner":"HumanjavaEnterprises","description":"The nostr-nsec-seedphrase repository offers a TypeScript library that converts Nostr nsec keys into mnemonic seed phrases, enhancing the readability and management of keys within Nostr applications. This approach mirrors Bitcoin's use of seed phrases, emphasizing the importance of secure storage and careful handling of these keys.","archived":false,"fork":false,"pushed_at":"2024-12-16T02:09:03.000Z","size":300,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-16T03:19:10.248Z","etag":null,"topics":["bitcoin","cryptography","decentralized-protocols","digital-signatures","key-management","mnemonic-seed-phrases","nostr","public-key-infrastructure","security"],"latest_commit_sha":null,"homepage":"","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/HumanjavaEnterprises.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2024-12-05T20:09:17.000Z","updated_at":"2024-12-16T02:09:07.000Z","dependencies_parsed_at":"2024-12-05T23:24:56.694Z","dependency_job_id":"3407594a-d37c-459f-ad62-4211e3b502a0","html_url":"https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase","commit_stats":null,"previous_names":["humanjavaenterprises/nostr-nsec-seedphrase"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanjavaEnterprises%2Fnostr-nsec-seedphrase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanjavaEnterprises%2Fnostr-nsec-seedphrase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanjavaEnterprises%2Fnostr-nsec-seedphrase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanjavaEnterprises%2Fnostr-nsec-seedphrase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HumanjavaEnterprises","download_url":"https://codeload.github.com/HumanjavaEnterprises/nostr-nsec-seedphrase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231600666,"owners_count":18398551,"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":["bitcoin","cryptography","decentralized-protocols","digital-signatures","key-management","mnemonic-seed-phrases","nostr","public-key-infrastructure","security"],"created_at":"2024-12-28T08:11:50.180Z","updated_at":"2025-08-31T14:32:13.820Z","avatar_url":"https://github.com/HumanjavaEnterprises.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nostr-nsec-seedphrase\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm version](https://img.shields.io/npm/v/nostr-nsec-seedphrase.svg)](https://www.npmjs.com/package/nostr-nsec-seedphrase)\n[![npm downloads](https://img.shields.io/npm/dm/nostr-nsec-seedphrase.svg)](https://www.npmjs.com/package/nostr-nsec-seedphrase)\n[![License](https://img.shields.io/npm/l/nostr-nsec-seedphrase.svg)](https://github.com/humanjavaenterprises/nostr-nsec-seedphrase/blob/main/LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)\n[![Test Status](https://img.shields.io/github/actions/workflow/status/humanjavaenterprises/nostr-nsec-seedphrase/test.yml?branch=main\u0026label=tests)](https://github.com/humanjavaenterprises/nostr-nsec-seedphrase/actions)\n[![Code Style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)\n\n\u003c/div\u003e\n\nA focused TypeScript library for Nostr key management and seedphrase functionality, with seamless integration with nostr-crypto-utils. This package specializes in converting between nsec keys and seed phrases, managing delegations, and handling various key formats.\n\n## Core Features\n\n- 🌱 **Seedphrase Management**\n  - Generate and validate BIP39 seed phrases\n  - Convert between seed phrases and Nostr keys\n  - Secure entropy generation\n  - Multiple language support\n\n- 🔑 **Key Operations**\n  - Convert between formats (hex, nsec, npub)\n  - Validate key pairs\n  - Generate new key pairs\n  - Public key derivation\n\n- 📝 **Delegation Support (NIP-26)**\n  - Create delegation tokens\n  - Time-based conditions\n  - Event kind filtering\n  - Token validation and verification\n  - Expiry management\n\n- 🔄 **Format Conversions**\n  - Hex ↔ nsec\n  - Hex ↔ npub\n  - Seed phrase ↔ key pair\n  - Comprehensive validation\n\n## NIPs Support Status\n\n🟢 Fully implemented 🟡 Partially implemented 🔴 Not implemented\n\n| NIP | Status | Description |\n|-----|--------|-------------|\n| 01 | 🟢 | Basic protocol flow \u0026 event signing |\n| 06 | 🟢 | Basic key derivation from seed phrase |\n| 19 | 🟢 | bech32-encoded entities |\n| 26 | 🟢 | Delegated event signing |\n\n## Installation\n\n```bash\nnpm install nostr-nsec-seedphrase\n```\n\n## Quick Start\n\n### Generate a New Key Pair with Seed Phrase\n\n```typescript\nimport { generateKeyPairWithSeed } from 'nostr-nsec-seedphrase';\n\nconst keyPair = generateKeyPairWithSeed();\nconsole.log({\n  seedPhrase: keyPair.seedPhrase,\n  nsec: keyPair.nsec,\n  npub: keyPair.npub\n});\n```\n\n### Convert Seed Phrase to Key Pair\n\n```typescript\nimport { seedPhraseToKeyPair } from 'nostr-nsec-seedphrase';\n\nconst keyPair = await seedPhraseToKeyPair('your twelve word seed phrase here');\nconsole.log({\n  privateKey: keyPair.privateKey, // hex format\n  publicKey: keyPair.publicKey,   // hex format\n  nsec: keyPair.nsec,            // bech32 format\n  npub: keyPair.npub             // bech32 format\n});\n```\n\n### Create and Verify Delegations\n\n```typescript\nimport { createDelegation, verifyDelegation } from 'nostr-nsec-seedphrase';\n\n// Create a delegation token\nconst delegation = await createDelegation(\n  delegateePublicKey,\n  {\n    kinds: [1, 2], // allowed event kinds\n    since: Math.floor(Date.now() / 1000),\n    until: Math.floor(Date.now() / 1000) + 86400 // 24 hours\n  },\n  delegatorPrivateKey\n);\n\n// Verify a delegation\nconst isValid = await verifyDelegation(\n  delegation,\n  Math.floor(Date.now() / 1000), // current timestamp\n  1 // event kind to verify\n);\n```\n\n## Key Features in Detail\n\n### 1. Seedphrase Management\n\nThe library provides comprehensive seedphrase functionality:\n\n```typescript\nimport { \n  generateSeedPhrase,\n  validateSeedPhrase,\n  seedPhraseToKeyPair\n} from 'nostr-nsec-seedphrase';\n\n// Generate a new seed phrase\nconst seedPhrase = generateSeedPhrase();\n\n// Validate an existing seed phrase\nconst isValid = validateSeedPhrase(seedPhrase);\n\n// Convert seed phrase to key pair\nconst keyPair = await seedPhraseToKeyPair(seedPhrase);\n```\n\n### 2. Key Format Conversions\n\nEasy conversion between different key formats:\n\n```typescript\nimport {\n  hexToNsec,\n  hexToNpub,\n  nsecToHex,\n  npubToHex\n} from 'nostr-nsec-seedphrase';\n\n// Convert hex to bech32 formats\nconst nsec = hexToNsec(privateKeyHex);\nconst npub = hexToNpub(publicKeyHex);\n\n// Convert bech32 to hex formats\nconst privateKeyHex = nsecToHex(nsec);\nconst publicKeyHex = npubToHex(npub);\n```\n\n### 3. Delegation Management\n\nComprehensive NIP-26 delegation support:\n\n```typescript\nimport {\n  createDelegation,\n  verifyDelegation,\n  isDelegationValid,\n  getDelegationExpiry\n} from 'nostr-nsec-seedphrase';\n\n// Create a delegation with conditions\nconst delegation = await createDelegation(delegatee, {\n  kinds: [1], // only text notes\n  since: Math.floor(Date.now() / 1000),\n  until: Math.floor(Date.now() / 1000) + 86400\n}, delegatorPrivateKey);\n\n// Check delegation validity\nconst isValid = await isDelegationValid(delegation);\n\n// Get delegation expiry\nconst expiry = getDelegationExpiry(delegation);\n```\n\n## Module Support\n\nThis package supports both ESM and CommonJS usage:\n\n### ESM (recommended)\n```typescript\nimport { generateKeyPairWithSeed } from 'nostr-nsec-seedphrase';\n```\n\n### CommonJS\n```javascript\nconst { generateKeyPairWithSeed } = require('nostr-nsec-seedphrase');\n```\n\n### Webpack Usage\nThe package is fully compatible with webpack for client-side applications. Add to your webpack config:\n\n```javascript\nmodule.exports = {\n  resolve: {\n    fallback: {\n      \"crypto\": require.resolve(\"crypto-browserify\"),\n      \"stream\": require.resolve(\"stream-browserify\"),\n      \"buffer\": require.resolve(\"buffer/\")\n    }\n  }\n};\n```\n\n## Documentation\n\nThe library includes comprehensive TypeScript types and JSDoc documentation. You can:\n\n1. View the documentation in your IDE through TypeScript and JSDoc annotations\n2. Generate HTML documentation using:\n   ```bash\n   npm run docs\n   ```\n3. View the generated documentation locally:\n   ```bash\n   npm run docs:serve\n   ```\n4. Access the generated documentation in the `docs` directory\n\n### Key Format Utilities\n\n```typescript\nimport { nip19 } from 'nostr-nsec-seedphrase';\n\n// Encode/decode public keys\nconst npub = nip19.npubEncode(hexPublicKey);\nconst hexPubkey = nip19.npubDecode(npub);\n\n// Encode/decode private keys\nconst nsec = nip19.nsecEncode(hexPrivateKey);\nconst hexPrivkey = nip19.nsecDecode(nsec);\n\n// Encode/decode event IDs\nconst note = nip19.noteEncode(eventId);\nconst hexEventId = nip19.noteDecode(note);\n```\n\n## Integration with nostr-crypto-utils\n\nThis package is designed to work seamlessly with nostr-crypto-utils:\n\n- Uses compatible key formats and types\n- Leverages nostr-crypto-utils for cryptographic operations\n- Maintains consistent error handling and validation\n\n## Security Considerations\n\n- Never share or expose private keys or seed phrases\n- Always validate input seed phrases and keys\n- Use secure entropy sources for key generation\n- Implement proper key storage practices\n- Regularly rotate delegation tokens\n- Set appropriate expiry times for delegations\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## License\n\nMIT License - see the [LICENSE](LICENSE) file for details.\n\n## Version 0.6.5\n- Fixed TypeScript errors related to unknown type assignments across multiple files.\n- Improved error handling by converting error objects to strings before logging.\n- Updated logger imports to use default imports where necessary.\n- Ensured consistent logging practices throughout the codebase.\n- Added a checklist for future reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanjavaenterprises%2Fnostr-nsec-seedphrase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanjavaenterprises%2Fnostr-nsec-seedphrase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanjavaenterprises%2Fnostr-nsec-seedphrase/lists"}