@signedby/sdk 0.1.0 → 1.0.1
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 +86 -67
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,92 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SIGNEDBYME TypeScript SDK
|
|
2
2
|
|
|
3
|
-
Human-
|
|
3
|
+
Human-Controlled Identity for Autonomous Agents
|
|
4
|
+
|
|
5
|
+
## What is SIGNEDBYME?
|
|
6
|
+
|
|
7
|
+
SIGNEDBYME is the identity layer for autonomous agents. Agents prove membership in enterprise-authorized groups using Groth16 zero-knowledge proofs — without revealing which agent they are. The enterprise gets a boolean: authorized. No identity revealed.
|
|
8
|
+
|
|
9
|
+
This SDK enables agents to generate cryptographic identity, produce zero-knowledge proofs, and authenticate to enterprises via NOSTR and OIDC.
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
8
14
|
npm install @signedby/sdk
|
|
15
|
+
# or
|
|
16
|
+
yarn add @signedby/sdk
|
|
9
17
|
```
|
|
10
18
|
|
|
11
19
|
## Quick Start
|
|
12
20
|
|
|
13
|
-
### For Agents - Authenticate to Enterprises
|
|
14
|
-
|
|
15
21
|
```typescript
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.log(`Authorized for: ${JSON.stringify(client.scopes)}`);
|
|
22
|
+
import {
|
|
23
|
+
AgentIdentity,
|
|
24
|
+
EncryptedFileStorage,
|
|
25
|
+
MembershipProver,
|
|
26
|
+
NostrClient
|
|
27
|
+
} from '@signedby/sdk';
|
|
23
28
|
|
|
24
|
-
//
|
|
25
|
-
const
|
|
26
|
-
clientId: 'acme-corp',
|
|
27
|
-
nonce: 'random_nonce_here'
|
|
28
|
-
});
|
|
29
|
+
// Initialize secure storage
|
|
30
|
+
const storage = new EncryptedFileStorage('./agent_data');
|
|
29
31
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
32
|
+
// Create agent identity (one-time setup)
|
|
33
|
+
const identity = new AgentIdentity(storage);
|
|
34
|
+
const state = await identity.initialize();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { SignedByAgent } from '@signedby/sdk';
|
|
36
|
+
console.log(`Agent npub: ${state.agentNpub}`);
|
|
37
|
+
console.log(`Leaf commitment: ${state.leafCommitment}`);
|
|
39
38
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
39
|
+
// Generate Groth16 proof for authentication
|
|
40
|
+
const prover = MembershipProver.fromCircuitsDir('./circuits');
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
const leafSecret = identity.getLeafSecret();
|
|
43
|
+
const witness = await loadWitness(storage, 'acme');
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
'amazon.com': 'you@gmail.com',
|
|
48
|
-
'acme.com': 'you@gmail.com'
|
|
49
|
-
});
|
|
45
|
+
const proof = await prover.generateProof(leafSecret, witness);
|
|
46
|
+
console.log(`Proof generated in ${proof.proofTimeMs}ms`);
|
|
50
47
|
|
|
51
|
-
//
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
for await (const event of agent.watchForAuthorizations()) {
|
|
55
|
-
console.log(`New authorization from: ${event.enterprise}`);
|
|
56
|
-
console.log(`Scopes: ${event.scopes}`);
|
|
57
|
-
}
|
|
48
|
+
// Publish proof to NOSTR
|
|
49
|
+
const client = await NostrClient.connect(identity);
|
|
50
|
+
await client.publishProofEvent(proofData);
|
|
58
51
|
```
|
|
59
52
|
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- **DID Generation**: secp256k1 keypair in secure storage (OS keyring, Keychain, DPAPI), never extractable
|
|
56
|
+
- **Groth16 ZK Proofs**: BN254 curve, ~101K constraints, <3s on ARM64 via native Rust core (napi-rs)
|
|
57
|
+
- **Bitcoin-Backed**: Identity fused with Lightning payment at creation via NWC (NIP-47)
|
|
58
|
+
- **NOSTR Integration**: Publish kinds 28101 (proof), 28102 (delegation ack), 28103 (revocation ack); poll for kinds 28200/28250/28251; NIP-42 relay authentication; decentralized audit trail on public relays
|
|
59
|
+
- **Witness Caching**: Merkle path cached locally, auto-refresh when root rotates out of 30-root window
|
|
60
|
+
|
|
61
|
+
## Modules
|
|
62
|
+
|
|
63
|
+
| Export | Purpose |
|
|
64
|
+
|--------|---------|
|
|
65
|
+
| `AgentIdentity` | DID generation, leaf_secret derivation |
|
|
66
|
+
| `EncryptedFileStorage` | Encrypted storage with OS keyring (ChaCha20-Poly1305) |
|
|
67
|
+
| `MembershipProver` | Groth16 proof generation via native Rust |
|
|
68
|
+
| `NostrClient` | NOSTR relay client with NIP-42 auth |
|
|
69
|
+
| `EnrollmentBootstrap` | Three-gate genesis flow |
|
|
70
|
+
| `DelegationValidator` | Delegation validation (kind 28250/28251) |
|
|
71
|
+
| `NwcWallet` | NWC wallet integration (NIP-47) |
|
|
72
|
+
|
|
73
|
+
## SDK Lifecycle
|
|
74
|
+
|
|
75
|
+
### One-Time Initialization
|
|
76
|
+
1. Generate DID in secure storage
|
|
77
|
+
2. Derive leaf_secret (5 BN254 field elements)
|
|
78
|
+
3. Compute leaf_commitment = Poseidon2(leaf_secret)
|
|
79
|
+
4. Load Groth16 proving key (~88MB)
|
|
80
|
+
5. Initialize NWC wallet for Lightning
|
|
81
|
+
|
|
82
|
+
### Enrollment per Enterprise
|
|
83
|
+
Three-gate genesis flow — runs once per enterprise:
|
|
84
|
+
- **Gate 1**: Email + token verification via kind 28202
|
|
85
|
+
- **Gate 2**: Human signs kind 28250 delegation
|
|
86
|
+
- **Gate 3**: Leaf appended to Merkle tree
|
|
87
|
+
|
|
88
|
+
### Authentication
|
|
89
|
+
1. Generate Groth16 proof from leaf_secret + cached witness
|
|
90
|
+
2. Publish kind 28101 to NOSTR
|
|
91
|
+
3. Enterprise validates and calls API
|
|
92
|
+
4. Agent receives OIDC id_token
|
|
85
93
|
|
|
86
94
|
## Requirements
|
|
87
95
|
|
|
88
96
|
- Node.js 18+
|
|
89
|
-
-
|
|
97
|
+
- Native libraries bundled for supported platforms
|
|
98
|
+
|
|
99
|
+
## Supported Platforms
|
|
100
|
+
|
|
101
|
+
- Linux x64 (glibc)
|
|
102
|
+
- Linux ARM64 (glibc)
|
|
103
|
+
- macOS x64 (Intel)
|
|
104
|
+
- macOS ARM64 (Apple Silicon)
|
|
105
|
+
- Windows x64
|
|
90
106
|
|
|
91
107
|
## Documentation
|
|
92
108
|
|
|
@@ -96,6 +112,9 @@ try {
|
|
|
96
112
|
|
|
97
113
|
## License
|
|
98
114
|
|
|
99
|
-
|
|
115
|
+
SSAL-1.0 (SIGNEDBYME Source-Available License)
|
|
116
|
+
|
|
117
|
+
## Links
|
|
100
118
|
|
|
101
|
-
|
|
119
|
+
- [GitHub](https://github.com/SIGNEDBYME-APP/SIGNEDBYME)
|
|
120
|
+
- [Website](https://signedbyme.com)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type definitions for
|
|
2
|
+
* Type definitions for SIGNEDBYME SDK.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* OIDC token returned from successful authentication.
|
|
@@ -48,7 +48,7 @@ interface AuthorizationEvent {
|
|
|
48
48
|
interface LoginOptions {
|
|
49
49
|
/** NOSTR relay URL (default: wss://relay.privacy-lion.com) */
|
|
50
50
|
relayUrl?: string;
|
|
51
|
-
/**
|
|
51
|
+
/** SIGNEDBYME API URL (default: https://api.beta.privacy-lion.com) */
|
|
52
52
|
apiUrl?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ interface LoginOptions {
|
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Client for authenticating to enterprises using
|
|
60
|
+
* Client for authenticating to enterprises using SIGNEDBYME.
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
@@ -171,10 +171,10 @@ declare class SignedByAgent {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
174
|
+
* SIGNEDBYME SDK Errors.
|
|
175
175
|
*/
|
|
176
176
|
/**
|
|
177
|
-
* Base error class for all
|
|
177
|
+
* Base error class for all SIGNEDBYME errors.
|
|
178
178
|
*/
|
|
179
179
|
declare class SignedByError extends Error {
|
|
180
180
|
constructor(message: string);
|
|
@@ -231,7 +231,7 @@ declare class RelayConnectionError extends SignedByError {
|
|
|
231
231
|
constructor(message?: string);
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
|
-
* Raised when the
|
|
234
|
+
* Raised when the SIGNEDBYME API returns an error.
|
|
235
235
|
*/
|
|
236
236
|
declare class ApiError extends SignedByError {
|
|
237
237
|
readonly errorCode?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type definitions for
|
|
2
|
+
* Type definitions for SIGNEDBYME SDK.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* OIDC token returned from successful authentication.
|
|
@@ -48,7 +48,7 @@ interface AuthorizationEvent {
|
|
|
48
48
|
interface LoginOptions {
|
|
49
49
|
/** NOSTR relay URL (default: wss://relay.privacy-lion.com) */
|
|
50
50
|
relayUrl?: string;
|
|
51
|
-
/**
|
|
51
|
+
/** SIGNEDBYME API URL (default: https://api.beta.privacy-lion.com) */
|
|
52
52
|
apiUrl?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ interface LoginOptions {
|
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Client for authenticating to enterprises using
|
|
60
|
+
* Client for authenticating to enterprises using SIGNEDBYME.
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
@@ -171,10 +171,10 @@ declare class SignedByAgent {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
174
|
+
* SIGNEDBYME SDK Errors.
|
|
175
175
|
*/
|
|
176
176
|
/**
|
|
177
|
-
* Base error class for all
|
|
177
|
+
* Base error class for all SIGNEDBYME errors.
|
|
178
178
|
*/
|
|
179
179
|
declare class SignedByError extends Error {
|
|
180
180
|
constructor(message: string);
|
|
@@ -231,7 +231,7 @@ declare class RelayConnectionError extends SignedByError {
|
|
|
231
231
|
constructor(message?: string);
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
|
-
* Raised when the
|
|
234
|
+
* Raised when the SIGNEDBYME API returns an error.
|
|
235
235
|
*/
|
|
236
236
|
declare class ApiError extends SignedByError {
|
|
237
237
|
readonly errorCode?: string;
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ var require_native = __commonJS({
|
|
|
46
46
|
const packageName = platformMap[platformName]?.[archName];
|
|
47
47
|
if (!packageName) {
|
|
48
48
|
throw new Error(
|
|
49
|
-
`Unsupported platform: ${platformName}-${archName}.
|
|
49
|
+
`Unsupported platform: ${platformName}-${archName}. SIGNEDBYME SDK supports: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ var require_native = __commonJS({
|
|
|
35
35
|
const packageName = platformMap[platformName]?.[archName];
|
|
36
36
|
if (!packageName) {
|
|
37
37
|
throw new Error(
|
|
38
|
-
`Unsupported platform: ${platformName}-${archName}.
|
|
38
|
+
`Unsupported platform: ${platformName}-${archName}. SIGNEDBYME SDK supports: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64`
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signedby/sdk",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SIGNEDBYME SDK - Human-Controlled Identity for Autonomous Agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -34,32 +34,32 @@
|
|
|
34
34
|
"oidc",
|
|
35
35
|
"did"
|
|
36
36
|
],
|
|
37
|
-
"author": "
|
|
37
|
+
"author": "SIGNEDBYME <contact@signedbyme.com>",
|
|
38
38
|
"license": "SSAL-1.0",
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/
|
|
41
|
+
"url": "https://github.com/SIGNEDBYME-APP/SIGNEDBYME.git",
|
|
42
42
|
"directory": "sdk/typescript"
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://signedbyme.com",
|
|
45
45
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/
|
|
46
|
+
"url": "https://github.com/SIGNEDBYME-APP/SIGNEDBYME/issues"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
54
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
55
|
+
"eslint": "^9.0.0",
|
|
56
|
+
"tsup": "^8.2.0",
|
|
57
|
+
"typescript": "^5.5.0",
|
|
58
|
+
"vitest": "^2.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@noble/curves": "^1.
|
|
62
|
-
"@noble/hashes": "^1.
|
|
61
|
+
"@noble/curves": "^1.6.0",
|
|
62
|
+
"@noble/hashes": "^1.5.0"
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|
|
65
65
|
"@signedby/core-linux-x64-gnu": "0.1.0",
|