create-agent 0.0.6 → 0.0.8
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.
- package/README.md +113 -2
- package/bin/create-agent.js +59 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,113 @@
|
|
|
1
|
-
# create-agent
|
|
2
|
-
|
|
1
|
+
# create-agent 🤖
|
|
2
|
+
|
|
3
|
+
A command-line tool to generate Agent keypairs with various encodings.
|
|
4
|
+
|
|
5
|
+
## Installation 📦
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g create-agent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or simply run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm create agent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage 🚀
|
|
18
|
+
|
|
19
|
+
Simply run:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
create-agent
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The tool will generate a new Agent keypair and display it in various formats.
|
|
26
|
+
|
|
27
|
+
## Output Fields 🔑
|
|
28
|
+
|
|
29
|
+
The tool generates a JSON object containing:
|
|
30
|
+
|
|
31
|
+
### Private Key Formats
|
|
32
|
+
|
|
33
|
+
#### `privkey`
|
|
34
|
+
|
|
35
|
+
- 32-byte private key in hexadecimal format
|
|
36
|
+
- The private key of the Agent
|
|
37
|
+
- Used to sign Nostr events
|
|
38
|
+
- Example:
|
|
39
|
+
```
|
|
40
|
+
"7f7168866801e2003bfc6507f881783e23587d35ece7b1f1981891b9c9c26c55"
|
|
41
|
+
```
|
|
42
|
+
- ⚠️ **Keep this secret!**
|
|
43
|
+
|
|
44
|
+
#### `nsec`
|
|
45
|
+
|
|
46
|
+
- Bech32-encoded private key (starts with `nsec`)
|
|
47
|
+
- Human-friendly format
|
|
48
|
+
- Example:
|
|
49
|
+
```
|
|
50
|
+
"nsec1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3vk8rx"
|
|
51
|
+
```
|
|
52
|
+
- ⚠️ **Keep this secret!**
|
|
53
|
+
|
|
54
|
+
### Public Key Formats
|
|
55
|
+
|
|
56
|
+
#### `pubkey`
|
|
57
|
+
|
|
58
|
+
- 32-byte public key in hexadecimal format
|
|
59
|
+
- Derived from private key using Schnorr signatures
|
|
60
|
+
- Your identity in the Nostr network
|
|
61
|
+
- Example:
|
|
62
|
+
```
|
|
63
|
+
"06444f34c6c5f973d74b3c78214fd0bf694f0cf459651b2ffe651fa08ba00bf4"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### `npub`
|
|
67
|
+
|
|
68
|
+
- Bech32-encoded public key (starts with `npub`)
|
|
69
|
+
- Human-friendly format for sharing
|
|
70
|
+
- Example:
|
|
71
|
+
```
|
|
72
|
+
"npub1sg6plzptd64u62a878hep2kev88swjh3tw00gjsfl8f237lmu63q0uf63m"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Example Output 📝
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"privkey": "7f7168866801e2003bfc6507f881783e23587d35ece7b1f1981891b9c9c26c55",
|
|
80
|
+
"pubkey": "06444f34c6c5f973d74b3c78214fd0bf694f0cf459651b2ffe651fa08ba00bf4",
|
|
81
|
+
"nsec": "nsec1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3vk8rx",
|
|
82
|
+
"npub": "npub1sg6plzptd64u62a878hep2kev88swjh3tw00gjsfl8f237lmu63q0uf63m"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Security Notice 🔒
|
|
87
|
+
|
|
88
|
+
**Never share your private key!** Anyone with access to your private key (`privkey` or `nsec`) can:
|
|
89
|
+
|
|
90
|
+
- ✍️ Post messages as you
|
|
91
|
+
- 👤 Update your profile
|
|
92
|
+
- 👥 Follow/unfollow other users
|
|
93
|
+
- 📨 Send encrypted messages in your name
|
|
94
|
+
|
|
95
|
+
## About Nostr 📡
|
|
96
|
+
|
|
97
|
+
Nostr (Notes and Other Stuff Transmitted by Relays) is a decentralized social networking protocol. Each user is identified by a public key, and all actions are signed using their corresponding private key.
|
|
98
|
+
|
|
99
|
+
## Development 🛠️
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git clone https://github.com/melvincarvalho/create-agent.git
|
|
103
|
+
cd create-agent
|
|
104
|
+
npm install
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## License 📄
|
|
108
|
+
|
|
109
|
+
MIT
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
Made with ❤️ for the [Agentic Alliance](https://agenticalliance.com/) community
|
package/bin/create-agent.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// NOSTR KEY GENERATION
|
|
5
|
+
// =============================================================================
|
|
4
6
|
import { generateSecretKey, getPublicKey } from 'nostr-tools/pure';
|
|
5
7
|
import { nip19 } from 'nostr-tools';
|
|
6
8
|
|
|
7
9
|
// Generate cryptographically secure private key (32 bytes)
|
|
8
10
|
const privkey = generateSecretKey();
|
|
9
|
-
|
|
10
|
-
// Convert Uint8Array to hex string
|
|
11
11
|
const privkeyHex = Array.from(privkey)
|
|
12
12
|
.map(b => b.toString(16).padStart(2, '0'))
|
|
13
13
|
.join('');
|
|
@@ -15,21 +15,62 @@ const privkeyHex = Array.from(privkey)
|
|
|
15
15
|
// Derive public key using Schnorr signatures (32 bytes, hex encoded)
|
|
16
16
|
const pubkey = getPublicKey(privkey);
|
|
17
17
|
|
|
18
|
-
// Encode
|
|
18
|
+
// Encode keys in Nostr formats
|
|
19
19
|
const nsec = nip19.nsecEncode(privkey);
|
|
20
|
-
|
|
21
|
-
// Encode the public key as npub
|
|
22
20
|
const npub = nip19.npubEncode(pubkey);
|
|
23
21
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// DID DOCUMENT CREATION
|
|
24
|
+
// =============================================================================
|
|
25
|
+
const didDocument = {
|
|
26
|
+
"@context": [
|
|
27
|
+
"https://www.w3.org/ns/did/v1",
|
|
28
|
+
"https://w3id.org/nostr/context"
|
|
29
|
+
],
|
|
30
|
+
"id": `did:nostr:${pubkey}`,
|
|
31
|
+
"verificationMethod": [
|
|
32
|
+
{
|
|
33
|
+
"id": `did:nostr:${pubkey}#key1`,
|
|
34
|
+
"controller": `did:nostr:${pubkey}`,
|
|
35
|
+
"type": "SchnorrVerification2025"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"authentication": [
|
|
39
|
+
"#key1"
|
|
40
|
+
],
|
|
41
|
+
"assertionMethod": [
|
|
42
|
+
"#key1"
|
|
43
|
+
],
|
|
44
|
+
"service": [] // Empty services array
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// =============================================================================
|
|
48
|
+
// CONSOLE OUTPUT
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// First output the initial warning message to stderr
|
|
51
|
+
process.stderr.write('\x1b[36m🤖 Creating new Nostr agent identity...\x1b[0m\n');
|
|
52
|
+
process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|
|
53
|
+
process.stderr.write('\x1b[33m⚠️ IMPORTANT: Keep your private key (nsec/privkey) secret!\x1b[0m\n');
|
|
54
|
+
process.stderr.write('\x1b[33m Never share it with anyone or input it on websites.\x1b[0m\n');
|
|
55
|
+
process.stderr.write('\n');
|
|
56
|
+
|
|
57
|
+
// Then output the Nostr identity information to stderr
|
|
58
|
+
process.stderr.write('\n\x1b[32m📋 Your Nostr Identity:\x1b[0m\n');
|
|
59
|
+
process.stderr.write('\x1b[32m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|
|
60
|
+
process.stderr.write(`\x1b[0mPublic Key (hex) : \x1b[33m${pubkey}\x1b[0m\n`);
|
|
61
|
+
process.stderr.write(`\x1b[0mNostr Public Key : \x1b[33m${npub}\x1b[0m\n`);
|
|
62
|
+
process.stderr.write(`\x1b[0mPrivate Key (hex): \x1b[31m${privkeyHex}\x1b[0m\n`);
|
|
63
|
+
process.stderr.write(`\x1b[0mNostr Secret Key : \x1b[31m${nsec}\x1b[0m\n`);
|
|
64
|
+
process.stderr.write('\n');
|
|
65
|
+
process.stderr.write('\x1b[36m🔍 Usage:\x1b[0m\n');
|
|
66
|
+
process.stderr.write('\x1b[0m- Use your npub to identify yourself to others\x1b[0m\n');
|
|
67
|
+
process.stderr.write('\x1b[0m- Add relays to the services array for discovery\x1b[0m\n');
|
|
68
|
+
process.stderr.write('\x1b[0m- Use nsec to sign into Nostr clients (handle with extreme care!)\x1b[0m\n');
|
|
69
|
+
process.stderr.write('\n');
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Then output the DID document to stdout with a clear header in the output
|
|
73
|
+
process.stderr.write('\x1b[36m📄 DID Nostr Document:\x1b[0m\n');
|
|
74
|
+
process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|
|
75
|
+
console.log(JSON.stringify(didDocument, null, 2));
|
|
76
|
+
process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|