create-agent 0.0.16 → 0.0.18
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/.claude/settings.local.json +18 -0
- package/README.md +1 -1
- package/bin/create-agent.js +9 -8
- package/index.js +1 -1
- package/package.json +2 -2
- package/test/index.test.js +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebFetch(domain:did-nostr.com)",
|
|
5
|
+
"WebFetch(domain:nostrcg.github.io)",
|
|
6
|
+
"Bash(npm test *)",
|
|
7
|
+
"Bash(gh repo *)",
|
|
8
|
+
"Bash(gh issue *)",
|
|
9
|
+
"Bash(git push *)",
|
|
10
|
+
"Bash(gh pr create --base gh-pages --title 'Update DID document to latest did:nostr spec \\(DID → CID context\\)' --body ' *)",
|
|
11
|
+
"Bash(gh pr *)",
|
|
12
|
+
"Bash(gh api *)",
|
|
13
|
+
"Bash(git checkout *)",
|
|
14
|
+
"Bash(git pull *)",
|
|
15
|
+
"Bash(npm install *)"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ The tool outputs a spec-compliant DID document to `stdout`:
|
|
|
46
46
|
```json
|
|
47
47
|
{
|
|
48
48
|
"@context": [
|
|
49
|
-
"https://
|
|
49
|
+
"https://www.w3.org/ns/cid/v1",
|
|
50
50
|
"https://w3id.org/nostr/context"
|
|
51
51
|
],
|
|
52
52
|
"id": "did:nostr:dd82687ee5a352c6d6de337bce53f150ca1567f3861475c74e7da62695931d23",
|
package/bin/create-agent.js
CHANGED
|
@@ -14,11 +14,13 @@ function isGitRepo() {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Check if
|
|
18
|
-
function
|
|
17
|
+
// Check if agent identity already exists in THIS repo (not inherited from parent)
|
|
18
|
+
function hasIdentity() {
|
|
19
19
|
try {
|
|
20
|
-
const result = execSync('git config nostr.privkey', { encoding: 'utf8' }).trim()
|
|
21
|
-
|
|
20
|
+
const result = execSync('git config --local nostr.privkey', { encoding: 'utf8' }).trim()
|
|
21
|
+
const hasLocalPrivkey = result.length > 0
|
|
22
|
+
const hasDIDFile = fs.existsSync('agent.did.json')
|
|
23
|
+
return hasLocalPrivkey && hasDIDFile
|
|
22
24
|
} catch {
|
|
23
25
|
return false
|
|
24
26
|
}
|
|
@@ -26,12 +28,11 @@ function hasPrivkey() {
|
|
|
26
28
|
|
|
27
29
|
// Main
|
|
28
30
|
if (!isGitRepo()) {
|
|
29
|
-
console.error('\x1b[
|
|
30
|
-
|
|
31
|
-
process.exit(1)
|
|
31
|
+
console.error('\x1b[36mInitializing git repository...\x1b[0m')
|
|
32
|
+
execSync('git init', { stdio: 'inherit' })
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
if (
|
|
35
|
+
if (hasIdentity()) {
|
|
35
36
|
console.error('\x1b[33mAgent identity already exists.\x1b[0m')
|
|
36
37
|
console.error('Privkey found in: git config nostr.privkey')
|
|
37
38
|
console.error('To regenerate, first run: git config --unset nostr.privkey')
|
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export function generateAgent() {
|
|
|
25
25
|
// Create DID document per https://nostrcg.github.io/did-nostr/
|
|
26
26
|
const did = {
|
|
27
27
|
"@context": [
|
|
28
|
-
"https://
|
|
28
|
+
"https://www.w3.org/ns/cid/v1",
|
|
29
29
|
"https://w3id.org/nostr/context"
|
|
30
30
|
],
|
|
31
31
|
"id": `did:nostr:${pubkey}`,
|
package/package.json
CHANGED
package/test/index.test.js
CHANGED
|
@@ -43,12 +43,12 @@ describe('generateAgent', () => {
|
|
|
43
43
|
const { did, pubkey } = generateAgent()
|
|
44
44
|
|
|
45
45
|
assert.deepStrictEqual(did['@context'], [
|
|
46
|
-
'https://www.w3.org/ns/
|
|
46
|
+
'https://www.w3.org/ns/cid/v1',
|
|
47
47
|
'https://w3id.org/nostr/context'
|
|
48
48
|
])
|
|
49
49
|
assert.strictEqual(did.id, `did:nostr:${pubkey}`)
|
|
50
50
|
assert.ok(Array.isArray(did.verificationMethod))
|
|
51
|
-
assert.strictEqual(did.verificationMethod[0].type, '
|
|
51
|
+
assert.strictEqual(did.verificationMethod[0].type, 'Multikey')
|
|
52
52
|
assert.deepStrictEqual(did.authentication, ['#key1'])
|
|
53
53
|
assert.deepStrictEqual(did.assertionMethod, ['#key1'])
|
|
54
54
|
assert.deepStrictEqual(did.service, [])
|