nervepay 1.0.0
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/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/README.md +532 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -0
- package/dist/setup.d.ts +9 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +391 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/gateway.d.ts +96 -0
- package/dist/tools/gateway.d.ts.map +1 -0
- package/dist/tools/gateway.js +99 -0
- package/dist/tools/gateway.js.map +1 -0
- package/dist/tools/identity.d.ts +85 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +42 -0
- package/dist/tools/identity.js.map +1 -0
- package/dist/tools/orchestration.d.ts +111 -0
- package/dist/tools/orchestration.d.ts.map +1 -0
- package/dist/tools/orchestration.js +83 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/vault.d.ts +39 -0
- package/dist/tools/vault.d.ts.map +1 -0
- package/dist/tools/vault.js +57 -0
- package/dist/tools/vault.js.map +1 -0
- package/dist/utils/client.d.ts +42 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +100 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/crypto.d.ts +28 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +108 -0
- package/dist/utils/crypto.js.map +1 -0
- package/openclaw.plugin.json +63 -0
- package/package.json +59 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ed25519 cryptographic utilities for NervePay authentication
|
|
3
|
+
*/
|
|
4
|
+
import * as ed25519 from '@noble/ed25519';
|
|
5
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
6
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
7
|
+
// Base58 alphabet (Bitcoin-style, no 0/O/I/l)
|
|
8
|
+
const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9
|
+
/**
|
|
10
|
+
* Decode Base58 string to bytes
|
|
11
|
+
*/
|
|
12
|
+
export function decodeBase58(str) {
|
|
13
|
+
const bytes = [];
|
|
14
|
+
for (const char of str) {
|
|
15
|
+
const index = BASE58_ALPHABET.indexOf(char);
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
throw new Error(`Invalid base58 character: ${char}`);
|
|
18
|
+
}
|
|
19
|
+
let carry = index;
|
|
20
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
21
|
+
carry += bytes[i] * 58;
|
|
22
|
+
bytes[i] = carry & 0xff;
|
|
23
|
+
carry >>= 8;
|
|
24
|
+
}
|
|
25
|
+
while (carry > 0) {
|
|
26
|
+
bytes.push(carry & 0xff);
|
|
27
|
+
carry >>= 8;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Handle leading '1's (represent leading zeros)
|
|
31
|
+
for (const char of str) {
|
|
32
|
+
if (char !== '1')
|
|
33
|
+
break;
|
|
34
|
+
bytes.push(0);
|
|
35
|
+
}
|
|
36
|
+
return new Uint8Array(bytes.reverse());
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Encode bytes to Base58
|
|
40
|
+
*/
|
|
41
|
+
export function encodeBase58(bytes) {
|
|
42
|
+
const digits = [0];
|
|
43
|
+
for (const byte of bytes) {
|
|
44
|
+
let carry = byte;
|
|
45
|
+
for (let i = 0; i < digits.length; i++) {
|
|
46
|
+
carry += digits[i] << 8;
|
|
47
|
+
digits[i] = carry % 58;
|
|
48
|
+
carry = Math.floor(carry / 58);
|
|
49
|
+
}
|
|
50
|
+
while (carry > 0) {
|
|
51
|
+
digits.push(carry % 58);
|
|
52
|
+
carry = Math.floor(carry / 58);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Handle leading zeros
|
|
56
|
+
for (const byte of bytes) {
|
|
57
|
+
if (byte !== 0)
|
|
58
|
+
break;
|
|
59
|
+
digits.push(0);
|
|
60
|
+
}
|
|
61
|
+
return digits.reverse().map(d => BASE58_ALPHABET[d]).join('');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sign a payload with Ed25519 private key
|
|
65
|
+
*/
|
|
66
|
+
export async function signPayload(privateKeyBase58, payload) {
|
|
67
|
+
// Remove 'ed25519:' prefix if present
|
|
68
|
+
const keyStr = privateKeyBase58.replace(/^ed25519:/, '');
|
|
69
|
+
// Decode base58 private key (64 bytes: 32-byte seed + 32-byte public key)
|
|
70
|
+
const privateKeyBytes = decodeBase58(keyStr);
|
|
71
|
+
// Extract the 32-byte seed (first 32 bytes)
|
|
72
|
+
const seed = privateKeyBytes.slice(0, 32);
|
|
73
|
+
// Sign the JSON payload
|
|
74
|
+
const message = JSON.stringify(payload);
|
|
75
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
76
|
+
const signature = await ed25519.sign(messageBytes, seed);
|
|
77
|
+
// Return base64-encoded signature
|
|
78
|
+
return Buffer.from(signature).toString('base64');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Verify an Ed25519 signature
|
|
82
|
+
*/
|
|
83
|
+
export async function verifySignature(publicKeyBase58, payload, signatureBase64) {
|
|
84
|
+
try {
|
|
85
|
+
const publicKeyBytes = decodeBase58(publicKeyBase58);
|
|
86
|
+
const message = JSON.stringify(payload);
|
|
87
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
88
|
+
const signature = Buffer.from(signatureBase64, 'base64');
|
|
89
|
+
return await ed25519.verify(signature, messageBytes, publicKeyBytes);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generate SHA-256 hash of string
|
|
97
|
+
*/
|
|
98
|
+
export function sha256Hash(data) {
|
|
99
|
+
const bytes = new TextEncoder().encode(data);
|
|
100
|
+
return bytesToHex(sha256(bytes));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Generate random UUID v4
|
|
104
|
+
*/
|
|
105
|
+
export function randomUUID() {
|
|
106
|
+
return crypto.randomUUID();
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,8CAA8C;AAC9C,MAAM,eAAe,GAAG,4DAA4D,CAAC;AAErF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;YACxB,KAAK,KAAK,CAAC,CAAC;QACd,CAAC;QAED,OAAO,KAAK,GAAG,CAAC,EAAE,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,K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AAY,EAAE,cAAc,CAAC,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "nervepay",
|
|
3
|
+
"name": "nervepay",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Self-sovereign identity layer for AI agents. W3C DIDs, Ed25519 auth, vault, and multi-agent orchestration.",
|
|
6
|
+
"author": "NervePay <hello@nervepay.xyz>",
|
|
7
|
+
"homepage": "https://nervepay.xyz",
|
|
8
|
+
"repository": "https://github.com/nervepay/nervepay-plugin",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"configSchema": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"additionalProperties": false,
|
|
13
|
+
"properties": {
|
|
14
|
+
"apiUrl": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "NervePay API URL",
|
|
17
|
+
"default": "https://api.nervepay.xyz"
|
|
18
|
+
},
|
|
19
|
+
"agentDid": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Agent DID (did:nervepay:agent:xxx)",
|
|
22
|
+
"pattern": "^did:nervepay:agent:[A-Za-z0-9]{22}$"
|
|
23
|
+
},
|
|
24
|
+
"privateKey": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Ed25519 private key for signing requests"
|
|
27
|
+
},
|
|
28
|
+
"gatewayUrl": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "OpenClaw gateway URL (for pairing)"
|
|
31
|
+
},
|
|
32
|
+
"enableOrchestration": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "Enable multi-agent orchestration features",
|
|
35
|
+
"default": false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": []
|
|
39
|
+
},
|
|
40
|
+
"uiHints": {
|
|
41
|
+
"apiUrl": {
|
|
42
|
+
"label": "API URL",
|
|
43
|
+
"placeholder": "https://api.nervepay.xyz"
|
|
44
|
+
},
|
|
45
|
+
"agentDid": {
|
|
46
|
+
"label": "Agent DID",
|
|
47
|
+
"placeholder": "did:nervepay:agent:..."
|
|
48
|
+
},
|
|
49
|
+
"privateKey": {
|
|
50
|
+
"label": "Private Key",
|
|
51
|
+
"placeholder": "ed25519:...",
|
|
52
|
+
"sensitive": true
|
|
53
|
+
},
|
|
54
|
+
"gatewayUrl": {
|
|
55
|
+
"label": "Gateway URL",
|
|
56
|
+
"placeholder": "https://your-gateway:18789"
|
|
57
|
+
},
|
|
58
|
+
"enableOrchestration": {
|
|
59
|
+
"label": "Enable Orchestration",
|
|
60
|
+
"description": "Allows spawning sub-agents and managing tasks"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nervepay",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "NervePay plugin for OpenClaw - Self-sovereign identity, vault, and orchestration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"openclaw": {
|
|
9
|
+
"extensions": [
|
|
10
|
+
"dist/index.js"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"test": "vitest",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"openclaw",
|
|
21
|
+
"openclaw-plugin",
|
|
22
|
+
"nervepay",
|
|
23
|
+
"identity",
|
|
24
|
+
"did",
|
|
25
|
+
"ed25519",
|
|
26
|
+
"vault",
|
|
27
|
+
"orchestration",
|
|
28
|
+
"ai-agents"
|
|
29
|
+
],
|
|
30
|
+
"author": "NervePay <hello@nervepay.xyz>",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"homepage": "https://nervepay.xyz",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/nervepay/nervepay-plugin"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@noble/ed25519": "^2.1.0",
|
|
39
|
+
"@noble/hashes": "^1.5.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"openclaw": ">=1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.0.0",
|
|
46
|
+
"typescript": "^5.6.0",
|
|
47
|
+
"vitest": "^2.0.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=22.0.0"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"dist",
|
|
54
|
+
"openclaw.plugin.json",
|
|
55
|
+
"README.md",
|
|
56
|
+
"LICENSE",
|
|
57
|
+
"CHANGELOG.md"
|
|
58
|
+
]
|
|
59
|
+
}
|