@signedby/sdk 0.1.0 → 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/README.md +43 -68
- 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,101 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SIGNEDBYME TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Self-signing digital signatures with zero-knowledge proofs.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @signedby/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @signedby/sdk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Quick Start
|
|
12
14
|
|
|
13
|
-
### For Agents - Authenticate to Enterprises
|
|
14
|
-
|
|
15
15
|
```typescript
|
|
16
|
-
import { SignedByClient } from '@signedby/sdk';
|
|
17
|
-
|
|
18
|
-
// Load delegation from your human owner
|
|
19
|
-
const client = await SignedByClient.fromDelegation('./delegation.json');
|
|
20
|
-
|
|
21
|
-
console.log(`Your npub: ${client.npub}`);
|
|
22
|
-
console.log(`Authorized for: ${JSON.stringify(client.scopes)}`);
|
|
16
|
+
import { SignedByAgent, SignedByClient } from '@signedby/sdk';
|
|
23
17
|
|
|
24
|
-
//
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
nonce: 'random_nonce_here'
|
|
18
|
+
// Initialize agent
|
|
19
|
+
const agent = await SignedByAgent.init({
|
|
20
|
+
storagePath: './agent_data'
|
|
28
21
|
});
|
|
29
22
|
|
|
30
|
-
//
|
|
31
|
-
console.log(`ID Token: ${token.idToken}`);
|
|
32
|
-
console.log(`Subject: ${token.sub}`);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### For Agent Setup - Initialize Identity
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { SignedByAgent } from '@signedby/sdk';
|
|
39
|
-
|
|
40
|
-
// Initialize agent (creates DID if first run)
|
|
41
|
-
const agent = await SignedByAgent.init('./agent_data');
|
|
42
|
-
|
|
43
|
-
console.log(`Agent npub: ${agent.npub}`);
|
|
44
|
-
|
|
45
|
-
// Configure email mapping for enterprises
|
|
23
|
+
// Set email mapping for enterprises
|
|
46
24
|
agent.setEmailMapping({
|
|
47
|
-
'
|
|
48
|
-
'acme.com': 'you@gmail.com'
|
|
25
|
+
'example.com': 'user@example.com'
|
|
49
26
|
});
|
|
50
27
|
|
|
51
|
-
// Connect to
|
|
52
|
-
await agent.
|
|
28
|
+
// Connect to SIGNEDBYME relays
|
|
29
|
+
await agent.connectRelays();
|
|
53
30
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log(`
|
|
31
|
+
// Watch for authorization requests
|
|
32
|
+
for await (const authRequest of agent.watchForAuthorizations()) {
|
|
33
|
+
console.log(`Authorization from ${authRequest.enterprise}`);
|
|
57
34
|
}
|
|
35
|
+
|
|
36
|
+
// Authenticate
|
|
37
|
+
const client = new SignedByClient('https://api.signedbyme.com');
|
|
38
|
+
const token = await client.authenticate({
|
|
39
|
+
clientId: 'example',
|
|
40
|
+
proof: await agent.generateProof()
|
|
41
|
+
});
|
|
42
|
+
console.log(`Authenticated: ${token.sub}`);
|
|
58
43
|
```
|
|
59
44
|
|
|
60
|
-
##
|
|
45
|
+
## Features
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
DelegationRevokedError,
|
|
67
|
-
DelegationExpiredError,
|
|
68
|
-
ScopeDeniedError,
|
|
69
|
-
} from '@signedby/sdk';
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const token = await client.login({ clientId: 'acme-corp', nonce });
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (error instanceof DelegationRevokedError) {
|
|
75
|
-
console.log('Delegation was revoked. Contact your human owner.');
|
|
76
|
-
} else if (error instanceof DelegationExpiredError) {
|
|
77
|
-
console.log('Delegation expired. Request renewal from your human owner.');
|
|
78
|
-
} else if (error instanceof ScopeDeniedError) {
|
|
79
|
-
console.log('Not authorized for this enterprise.');
|
|
80
|
-
} else if (error instanceof SignedByError) {
|
|
81
|
-
console.log(`Authentication failed: ${error.message}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
47
|
+
- **Agent Management**: DID generation, secure storage
|
|
48
|
+
- **Groth16 ZK Proofs**: Native Rust core via napi-rs
|
|
49
|
+
- **NOSTR Integration**: Automatic relay management
|
|
50
|
+
- **OIDC Compatible**: Standard JWT id_tokens
|
|
85
51
|
|
|
86
52
|
## Requirements
|
|
87
53
|
|
|
88
54
|
- Node.js 18+
|
|
89
|
-
-
|
|
55
|
+
- Platform-specific native bindings (included)
|
|
56
|
+
|
|
57
|
+
## Supported Platforms
|
|
58
|
+
|
|
59
|
+
- Linux x64 (glibc)
|
|
60
|
+
- Linux ARM64 (glibc)
|
|
61
|
+
- macOS x64 (Intel)
|
|
62
|
+
- macOS ARM64 (Apple Silicon)
|
|
63
|
+
- Windows x64
|
|
90
64
|
|
|
91
65
|
## Documentation
|
|
92
66
|
|
|
93
|
-
|
|
94
|
-
- [API Reference](https://signedbyme.com/docs/api-reference.html)
|
|
95
|
-
- [Understanding Delegation](https://signedbyme.com/docs/delegation.html)
|
|
67
|
+
Full documentation: [https://docs.signedbyme.com](https://docs.signedbyme.com)
|
|
96
68
|
|
|
97
69
|
## License
|
|
98
70
|
|
|
99
|
-
SignedByMe Source-Available License
|
|
71
|
+
SSAL-1.0 (SignedByMe Source-Available License)
|
|
72
|
+
|
|
73
|
+
## Links
|
|
100
74
|
|
|
101
|
-
|
|
75
|
+
- [GitHub](https://github.com/SIGNEDBYME-APP/SIGNEDBYME)
|
|
76
|
+
- [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": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
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",
|