create-agent 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
 
3
3
  // Use nostr-tools to generate secure keypair
4
4
  import { generateSecretKey, getPublicKey } from 'nostr-tools/pure';
5
+ import { nip19 } from 'nostr-tools';
5
6
 
6
7
  // Generate cryptographically secure private key (32 bytes)
7
8
  const privkey = generateSecretKey();
@@ -14,13 +15,21 @@ const privkeyHex = Array.from(privkey)
14
15
  // Derive public key using Schnorr signatures (32 bytes, hex encoded)
15
16
  const pubkey = getPublicKey(privkey);
16
17
 
18
+ // Encode the private key as nsec
19
+ const nsec = nip19.nsecEncode(privkey);
20
+
21
+ // Encode the public key as npub
22
+ const npub = nip19.npubEncode(pubkey);
23
+
17
24
  // Cool console message
18
25
  console.error('\x1b[36m%s\x1b[0m', '🤖 Creating new agent...');
19
26
  console.error('\x1b[33m%s\x1b[0m', '⚠️ Keep your private key secret!');
20
27
  console.error('');
21
28
 
22
- // Output JSON with both keys
29
+ // Output JSON with both keys, nsec and npub
23
30
  console.log(JSON.stringify({
24
31
  privkey: privkeyHex,
25
- pubkey: pubkey
32
+ pubkey: pubkey,
33
+ nsec: nsec,
34
+ npub: npub
26
35
  }, null, 2));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-agent",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "description": "create an agent",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -28,4 +28,4 @@
28
28
  "dependencies": {
29
29
  "nostr-tools": "^2.10.4"
30
30
  }
31
- }
31
+ }