@provenonce/sdk 0.6.0 → 0.8.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 +5 -5
- package/dist/index.d.mts +80 -5
- package/dist/index.d.ts +80 -5
- package/dist/index.js +344 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +344 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ import { register } from '@provenonce/sdk';
|
|
|
17
17
|
|
|
18
18
|
// Root registration (one-time)
|
|
19
19
|
const creds = await register('my-agent-v1', {
|
|
20
|
-
registryUrl: 'https://provenonce.
|
|
20
|
+
registryUrl: 'https://provenonce.io',
|
|
21
21
|
registrationSecret: process.env.REGISTRATION_SECRET, // required in production
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ console.log(creds.secret); // save — shown only once
|
|
|
27
27
|
|
|
28
28
|
// Child registration (requires parent credentials)
|
|
29
29
|
const child = await register('worker-1', {
|
|
30
|
-
registryUrl: 'https://provenonce.
|
|
30
|
+
registryUrl: 'https://provenonce.io',
|
|
31
31
|
parentHash: creds.hash,
|
|
32
32
|
parentApiKey: creds.api_key,
|
|
33
33
|
});
|
|
@@ -40,7 +40,7 @@ import { BeatAgent } from '@provenonce/sdk';
|
|
|
40
40
|
|
|
41
41
|
const agent = new BeatAgent({
|
|
42
42
|
apiKey: 'pvn_...',
|
|
43
|
-
registryUrl: 'https://provenonce.
|
|
43
|
+
registryUrl: 'https://provenonce.io',
|
|
44
44
|
verbose: true,
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -109,7 +109,7 @@ Python examples use the REST API directly — no Python SDK needed. See [`exampl
|
|
|
109
109
|
|
|
110
110
|
## Links
|
|
111
111
|
|
|
112
|
-
- [Live prototype](https://provenonce.
|
|
112
|
+
- [Live prototype](https://provenonce.io)
|
|
113
113
|
- [npm package](https://www.npmjs.com/package/@provenonce/sdk)
|
|
114
|
-
- [API docs](https://provenonce.
|
|
114
|
+
- [API docs](https://provenonce.io/docs)
|
|
115
115
|
- [GitHub](https://github.com/jarekpiot/provenonce)
|
package/dist/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const agent = new BeatAgent({
|
|
14
14
|
* apiKey: 'pvn_...',
|
|
15
|
-
* registryUrl: 'https://provenonce.
|
|
15
|
+
* registryUrl: 'https://provenonce.io',
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
18
18
|
* await agent.init(); // Birth in Beat time
|
|
@@ -65,6 +65,28 @@ interface AgentStatus {
|
|
|
65
65
|
};
|
|
66
66
|
difficulty?: number;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Generate an Ed25519 keypair for agent wallet identity.
|
|
70
|
+
* Returns hex-encoded raw keys (32 bytes each).
|
|
71
|
+
* Uses Node.js built-in crypto — zero external dependencies.
|
|
72
|
+
*/
|
|
73
|
+
declare function generateWalletKeypair(): {
|
|
74
|
+
publicKey: string;
|
|
75
|
+
secretKey: string;
|
|
76
|
+
};
|
|
77
|
+
/** Wallet info returned from root registration */
|
|
78
|
+
interface WalletInfo {
|
|
79
|
+
/** Hex-encoded 32-byte Ed25519 public key (Solana self-custody only, empty otherwise) */
|
|
80
|
+
public_key: string;
|
|
81
|
+
/** Hex-encoded 32-byte Ed25519 secret seed — SAVE THIS for future fee signing (Solana self-custody only) */
|
|
82
|
+
secret_key: string;
|
|
83
|
+
/** Solana-compatible base58 address (Solana wallets only) */
|
|
84
|
+
solana_address?: string;
|
|
85
|
+
/** The wallet address (base58 for Solana, 0x for Ethereum) */
|
|
86
|
+
address: string;
|
|
87
|
+
/** Wallet chain: 'solana' or 'ethereum' */
|
|
88
|
+
chain: string;
|
|
89
|
+
}
|
|
68
90
|
/** Result from registering an agent */
|
|
69
91
|
interface RegistrationResult {
|
|
70
92
|
hash: string;
|
|
@@ -74,21 +96,56 @@ interface RegistrationResult {
|
|
|
74
96
|
parent: string | null;
|
|
75
97
|
depth: number;
|
|
76
98
|
name: string;
|
|
99
|
+
metadata?: Record<string, unknown> | null;
|
|
77
100
|
signature: string;
|
|
78
101
|
explorer_url?: string;
|
|
102
|
+
/** Wallet chain: 'solana', 'ethereum', or null (no wallet) */
|
|
103
|
+
wallet_chain?: string | null;
|
|
79
104
|
beat?: {
|
|
80
105
|
genesis_hash: string;
|
|
81
106
|
difficulty: number;
|
|
82
107
|
status: string;
|
|
83
108
|
};
|
|
109
|
+
/** Wallet info — only present for root agents with wallets */
|
|
110
|
+
wallet?: WalletInfo;
|
|
84
111
|
}
|
|
85
112
|
/**
|
|
86
113
|
* Register a new agent on the Provenonce registry.
|
|
87
114
|
*
|
|
88
|
-
*
|
|
89
|
-
* const creds = await register('my-
|
|
115
|
+
* No wallet (default, single-phase):
|
|
116
|
+
* const creds = await register('my-agent', { registryUrl: '...' });
|
|
117
|
+
*
|
|
118
|
+
* Solana self-custody wallet (Model A, two-phase):
|
|
119
|
+
* const creds = await register('my-org', {
|
|
120
|
+
* registryUrl: '...',
|
|
121
|
+
* walletModel: 'self-custody',
|
|
122
|
+
* });
|
|
123
|
+
* // creds.wallet.secret_key = hex secret (SAVE THIS)
|
|
124
|
+
* // creds.wallet.address = base58 Solana address
|
|
125
|
+
*
|
|
126
|
+
* Solana with existing key:
|
|
127
|
+
* const creds = await register('my-org', {
|
|
128
|
+
* registryUrl: '...',
|
|
129
|
+
* walletSecretKey: '<hex-encoded-32-byte-seed>',
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* Ethereum bring-your-own (two-phase):
|
|
133
|
+
* const creds = await register('my-org', {
|
|
134
|
+
* registryUrl: '...',
|
|
135
|
+
* walletChain: 'ethereum',
|
|
136
|
+
* walletAddress: '0x...',
|
|
137
|
+
* walletSignFn: (msg) => wallet.signMessage(msg),
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* Solana operator (Model B, two-phase):
|
|
141
|
+
* const creds = await register('my-org', {
|
|
142
|
+
* registryUrl: '...',
|
|
143
|
+
* walletModel: 'operator',
|
|
144
|
+
* operatorWalletAddress: '<base58>',
|
|
145
|
+
* operatorSignFn: (msg) => signWithWallet(msg),
|
|
146
|
+
* });
|
|
90
147
|
*
|
|
91
|
-
* Child
|
|
148
|
+
* Child agent (no wallet):
|
|
92
149
|
* const creds = await register('worker-1', {
|
|
93
150
|
* registryUrl: '...',
|
|
94
151
|
* parentHash: parentCreds.hash,
|
|
@@ -100,6 +157,22 @@ declare function register(name: string, options?: {
|
|
|
100
157
|
parentHash?: string;
|
|
101
158
|
parentApiKey?: string;
|
|
102
159
|
registrationSecret?: string;
|
|
160
|
+
/** Hex-encoded 32-byte Ed25519 secret seed (bring-your-own Solana key) */
|
|
161
|
+
walletSecretKey?: string;
|
|
162
|
+
/** Wallet model: 'self-custody' (Model A) or 'operator' (Model B). Must be set explicitly to opt in. */
|
|
163
|
+
walletModel?: 'self-custody' | 'operator';
|
|
164
|
+
/** Wallet chain: 'solana' (default when wallet is used) or 'ethereum' (D-63) */
|
|
165
|
+
walletChain?: 'solana' | 'ethereum';
|
|
166
|
+
/** Wallet address for Ethereum bring-your-own (0x + 40 hex chars) */
|
|
167
|
+
walletAddress?: string;
|
|
168
|
+
/** Async function to sign a message with an Ethereum wallet (EIP-191 personal_sign). Returns 0x-prefixed 65-byte hex sig. */
|
|
169
|
+
walletSignFn?: (message: string) => Promise<string>;
|
|
170
|
+
/** Operator's Solana wallet address (base58). Required when walletModel='operator'. */
|
|
171
|
+
operatorWalletAddress?: string;
|
|
172
|
+
/** Function to sign a message with the operator's Solana wallet. Required when walletModel='operator'. */
|
|
173
|
+
operatorSignFn?: (message: string) => Promise<string>;
|
|
174
|
+
/** Optional agent metadata (arbitrary JSON object, max 4KB). Returned in /verify and /status. */
|
|
175
|
+
metadata?: Record<string, unknown>;
|
|
103
176
|
}): Promise<RegistrationResult>;
|
|
104
177
|
interface BeatAgentConfig {
|
|
105
178
|
/** API key from registration (pvn_...) */
|
|
@@ -150,6 +223,8 @@ declare class BeatAgent {
|
|
|
150
223
|
* through a specific window of computational time.
|
|
151
224
|
*/
|
|
152
225
|
pulse(count?: number): Beat[];
|
|
226
|
+
/** Internal beat computation — no status check. Used by both pulse() and resync(). */
|
|
227
|
+
private computeBeats;
|
|
153
228
|
/**
|
|
154
229
|
* Submit a Beat proof to the registry.
|
|
155
230
|
*
|
|
@@ -220,4 +295,4 @@ declare function computeBeatsLite(startHash: string, startIndex: number, count:
|
|
|
220
295
|
elapsed: number;
|
|
221
296
|
};
|
|
222
297
|
|
|
223
|
-
export { type AgentStatus, type Beat, BeatAgent, type BeatAgentConfig, type CheckinResult, type RegistrationResult, type SpawnResult, computeBeat, computeBeatsLite, register };
|
|
298
|
+
export { type AgentStatus, type Beat, BeatAgent, type BeatAgentConfig, type CheckinResult, type RegistrationResult, type SpawnResult, type WalletInfo, computeBeat, computeBeatsLite, generateWalletKeypair, register };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const agent = new BeatAgent({
|
|
14
14
|
* apiKey: 'pvn_...',
|
|
15
|
-
* registryUrl: 'https://provenonce.
|
|
15
|
+
* registryUrl: 'https://provenonce.io',
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
18
18
|
* await agent.init(); // Birth in Beat time
|
|
@@ -65,6 +65,28 @@ interface AgentStatus {
|
|
|
65
65
|
};
|
|
66
66
|
difficulty?: number;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Generate an Ed25519 keypair for agent wallet identity.
|
|
70
|
+
* Returns hex-encoded raw keys (32 bytes each).
|
|
71
|
+
* Uses Node.js built-in crypto — zero external dependencies.
|
|
72
|
+
*/
|
|
73
|
+
declare function generateWalletKeypair(): {
|
|
74
|
+
publicKey: string;
|
|
75
|
+
secretKey: string;
|
|
76
|
+
};
|
|
77
|
+
/** Wallet info returned from root registration */
|
|
78
|
+
interface WalletInfo {
|
|
79
|
+
/** Hex-encoded 32-byte Ed25519 public key (Solana self-custody only, empty otherwise) */
|
|
80
|
+
public_key: string;
|
|
81
|
+
/** Hex-encoded 32-byte Ed25519 secret seed — SAVE THIS for future fee signing (Solana self-custody only) */
|
|
82
|
+
secret_key: string;
|
|
83
|
+
/** Solana-compatible base58 address (Solana wallets only) */
|
|
84
|
+
solana_address?: string;
|
|
85
|
+
/** The wallet address (base58 for Solana, 0x for Ethereum) */
|
|
86
|
+
address: string;
|
|
87
|
+
/** Wallet chain: 'solana' or 'ethereum' */
|
|
88
|
+
chain: string;
|
|
89
|
+
}
|
|
68
90
|
/** Result from registering an agent */
|
|
69
91
|
interface RegistrationResult {
|
|
70
92
|
hash: string;
|
|
@@ -74,21 +96,56 @@ interface RegistrationResult {
|
|
|
74
96
|
parent: string | null;
|
|
75
97
|
depth: number;
|
|
76
98
|
name: string;
|
|
99
|
+
metadata?: Record<string, unknown> | null;
|
|
77
100
|
signature: string;
|
|
78
101
|
explorer_url?: string;
|
|
102
|
+
/** Wallet chain: 'solana', 'ethereum', or null (no wallet) */
|
|
103
|
+
wallet_chain?: string | null;
|
|
79
104
|
beat?: {
|
|
80
105
|
genesis_hash: string;
|
|
81
106
|
difficulty: number;
|
|
82
107
|
status: string;
|
|
83
108
|
};
|
|
109
|
+
/** Wallet info — only present for root agents with wallets */
|
|
110
|
+
wallet?: WalletInfo;
|
|
84
111
|
}
|
|
85
112
|
/**
|
|
86
113
|
* Register a new agent on the Provenonce registry.
|
|
87
114
|
*
|
|
88
|
-
*
|
|
89
|
-
* const creds = await register('my-
|
|
115
|
+
* No wallet (default, single-phase):
|
|
116
|
+
* const creds = await register('my-agent', { registryUrl: '...' });
|
|
117
|
+
*
|
|
118
|
+
* Solana self-custody wallet (Model A, two-phase):
|
|
119
|
+
* const creds = await register('my-org', {
|
|
120
|
+
* registryUrl: '...',
|
|
121
|
+
* walletModel: 'self-custody',
|
|
122
|
+
* });
|
|
123
|
+
* // creds.wallet.secret_key = hex secret (SAVE THIS)
|
|
124
|
+
* // creds.wallet.address = base58 Solana address
|
|
125
|
+
*
|
|
126
|
+
* Solana with existing key:
|
|
127
|
+
* const creds = await register('my-org', {
|
|
128
|
+
* registryUrl: '...',
|
|
129
|
+
* walletSecretKey: '<hex-encoded-32-byte-seed>',
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* Ethereum bring-your-own (two-phase):
|
|
133
|
+
* const creds = await register('my-org', {
|
|
134
|
+
* registryUrl: '...',
|
|
135
|
+
* walletChain: 'ethereum',
|
|
136
|
+
* walletAddress: '0x...',
|
|
137
|
+
* walletSignFn: (msg) => wallet.signMessage(msg),
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* Solana operator (Model B, two-phase):
|
|
141
|
+
* const creds = await register('my-org', {
|
|
142
|
+
* registryUrl: '...',
|
|
143
|
+
* walletModel: 'operator',
|
|
144
|
+
* operatorWalletAddress: '<base58>',
|
|
145
|
+
* operatorSignFn: (msg) => signWithWallet(msg),
|
|
146
|
+
* });
|
|
90
147
|
*
|
|
91
|
-
* Child
|
|
148
|
+
* Child agent (no wallet):
|
|
92
149
|
* const creds = await register('worker-1', {
|
|
93
150
|
* registryUrl: '...',
|
|
94
151
|
* parentHash: parentCreds.hash,
|
|
@@ -100,6 +157,22 @@ declare function register(name: string, options?: {
|
|
|
100
157
|
parentHash?: string;
|
|
101
158
|
parentApiKey?: string;
|
|
102
159
|
registrationSecret?: string;
|
|
160
|
+
/** Hex-encoded 32-byte Ed25519 secret seed (bring-your-own Solana key) */
|
|
161
|
+
walletSecretKey?: string;
|
|
162
|
+
/** Wallet model: 'self-custody' (Model A) or 'operator' (Model B). Must be set explicitly to opt in. */
|
|
163
|
+
walletModel?: 'self-custody' | 'operator';
|
|
164
|
+
/** Wallet chain: 'solana' (default when wallet is used) or 'ethereum' (D-63) */
|
|
165
|
+
walletChain?: 'solana' | 'ethereum';
|
|
166
|
+
/** Wallet address for Ethereum bring-your-own (0x + 40 hex chars) */
|
|
167
|
+
walletAddress?: string;
|
|
168
|
+
/** Async function to sign a message with an Ethereum wallet (EIP-191 personal_sign). Returns 0x-prefixed 65-byte hex sig. */
|
|
169
|
+
walletSignFn?: (message: string) => Promise<string>;
|
|
170
|
+
/** Operator's Solana wallet address (base58). Required when walletModel='operator'. */
|
|
171
|
+
operatorWalletAddress?: string;
|
|
172
|
+
/** Function to sign a message with the operator's Solana wallet. Required when walletModel='operator'. */
|
|
173
|
+
operatorSignFn?: (message: string) => Promise<string>;
|
|
174
|
+
/** Optional agent metadata (arbitrary JSON object, max 4KB). Returned in /verify and /status. */
|
|
175
|
+
metadata?: Record<string, unknown>;
|
|
103
176
|
}): Promise<RegistrationResult>;
|
|
104
177
|
interface BeatAgentConfig {
|
|
105
178
|
/** API key from registration (pvn_...) */
|
|
@@ -150,6 +223,8 @@ declare class BeatAgent {
|
|
|
150
223
|
* through a specific window of computational time.
|
|
151
224
|
*/
|
|
152
225
|
pulse(count?: number): Beat[];
|
|
226
|
+
/** Internal beat computation — no status check. Used by both pulse() and resync(). */
|
|
227
|
+
private computeBeats;
|
|
153
228
|
/**
|
|
154
229
|
* Submit a Beat proof to the registry.
|
|
155
230
|
*
|
|
@@ -220,4 +295,4 @@ declare function computeBeatsLite(startHash: string, startIndex: number, count:
|
|
|
220
295
|
elapsed: number;
|
|
221
296
|
};
|
|
222
297
|
|
|
223
|
-
export { type AgentStatus, type Beat, BeatAgent, type BeatAgentConfig, type CheckinResult, type RegistrationResult, type SpawnResult, computeBeat, computeBeatsLite, register };
|
|
298
|
+
export { type AgentStatus, type Beat, BeatAgent, type BeatAgentConfig, type CheckinResult, type RegistrationResult, type SpawnResult, type WalletInfo, computeBeat, computeBeatsLite, generateWalletKeypair, register };
|