@valiron/sdk 0.12.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 +18 -5
- package/dist/clients.d.ts +28 -64
- package/dist/clients.js +39 -176
- package/dist/identity.d.ts +5 -69
- package/dist/identity.js +6 -108
- package/dist/index.d.ts +64 -117
- package/dist/index.js +69 -131
- package/dist/middleware.d.ts +54 -24
- package/dist/middleware.js +307 -44
- package/dist/operatorSdk.d.ts +13 -2
- package/dist/operatorSdk.js +2 -2
- package/dist/types.d.ts +63 -89
- package/docs/API-REFERENCE.md +496 -190
- package/docs/DASHBOARD.md +253 -0
- package/docs/ERRORS.md +43 -0
- package/docs/IDENTITY.md +71 -0
- package/docs/QUICKSTART.md +50 -60
- package/docs/README.md +1 -1
- package/docs/SANDBOX.md +53 -16
- package/docs/SDK-REFERENCE.md +309 -174
- package/docs/TRUST-MODEL.md +2 -27
- package/docs/llms.txt +63 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile,
|
|
1
|
+
import { ValironConfig, CallOptions, AgentProfile, AgentSnapshotSummary, WalletProfile, WalletResolution, SandboxResult, KeyAgentSandboxResult, GateResult, GateOptions, RouteDecision, KeyAgentProfile, KeyAgentChallenge, WorldIdStatus, WorldIdAgentProfile, ProxyRequest, ProxyResponse } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Valiron SDK – Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
4
4
|
*
|
|
@@ -166,6 +166,24 @@ export declare class ValironSDK {
|
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
168
|
triggerSandboxTest(agentId: string, options?: CallOptions): Promise<SandboxResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Trigger sandbox testing for a key-based (web2) agent.
|
|
171
|
+
*
|
|
172
|
+
* Key agents have no on-chain endpoints, so this uses sandbox_relay mode.
|
|
173
|
+
* The result is written to Redis so subsequent `getKeyAgentProfile()` calls
|
|
174
|
+
* return a real score.
|
|
175
|
+
*
|
|
176
|
+
* @param agentAddress - The key agent's Ethereum address
|
|
177
|
+
* @returns Sandbox test results including score and tier
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const result = await valiron.triggerKeyAgentSandbox('0xabc...');
|
|
182
|
+
* console.log(result.valironScore); // 82
|
|
183
|
+
* console.log(result.tier); // 'A'
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
triggerKeyAgentSandbox(agentAddress: string): Promise<KeyAgentSandboxResult>;
|
|
169
187
|
/**
|
|
170
188
|
* Trust gate — checks an agent by combining on-chain reputation with
|
|
171
189
|
* sandbox behavioral tests and returns a single allow/deny decision.
|
|
@@ -196,49 +214,75 @@ export declare class ValironSDK {
|
|
|
196
214
|
* ```
|
|
197
215
|
*/
|
|
198
216
|
gate(agentId: string, options?: GateOptions): Promise<GateResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Proxy an API call through Valiron's trust gateway.
|
|
219
|
+
*
|
|
220
|
+
* Linear flow: Agent → Valiron → API Seller
|
|
221
|
+
*
|
|
222
|
+
* Valiron evaluates the agent inline and either forwards the request to
|
|
223
|
+
* the real API or blocks with 403. The agent never touches the API
|
|
224
|
+
* seller directly.
|
|
225
|
+
*
|
|
226
|
+
* @param agentId - On-chain agent ID (ERC-8004 token ID or Solana pubkey)
|
|
227
|
+
* @param request - Target URL, method, headers, and body to forward
|
|
228
|
+
* @param options - Optional chain override
|
|
229
|
+
* @returns Proxied API response wrapped with Valiron metadata
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const result = await valiron.proxy('25459', {
|
|
234
|
+
* target: 'https://api-seller.example.com/data',
|
|
235
|
+
* method: 'GET',
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* if (result._valiron.allow) {
|
|
239
|
+
* console.log(result.response); // Real API data
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
proxy<T = unknown>(agentId: string, request: ProxyRequest, options?: CallOptions): Promise<ProxyResponse<T>>;
|
|
199
244
|
/**
|
|
200
245
|
* Get a challenge nonce for a key-based agent to prove identity.
|
|
201
246
|
*
|
|
202
247
|
* The agent must sign this challenge with its private key and
|
|
203
248
|
* return the signature via `verifyKeyAgent()`.
|
|
204
249
|
*
|
|
205
|
-
* @param
|
|
250
|
+
* @param agentAddress - Ethereum address of the agent
|
|
206
251
|
* @returns Challenge nonce and expiry
|
|
207
252
|
*
|
|
208
253
|
* @example
|
|
209
254
|
* ```typescript
|
|
210
|
-
* const { challenge } = await valiron.getKeyAgentChallenge('
|
|
211
|
-
* const
|
|
212
|
-
* const profile = await valiron.verifyKeyAgent(
|
|
255
|
+
* const { challenge } = await valiron.getKeyAgentChallenge('0x1234...abcd');
|
|
256
|
+
* const signature = await account.signMessage({ message: challenge });
|
|
257
|
+
* const profile = await valiron.verifyKeyAgent({ challenge, signature, agentAddress });
|
|
213
258
|
* ```
|
|
214
259
|
*/
|
|
215
|
-
getKeyAgentChallenge(
|
|
260
|
+
getKeyAgentChallenge(agentAddress: string): Promise<KeyAgentChallenge>;
|
|
216
261
|
/**
|
|
217
|
-
* Verify a key-based agent's identity via challenge-response.
|
|
262
|
+
* Verify a key-based agent's identity via EIP-191 challenge-response.
|
|
218
263
|
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
264
|
+
* The server recovers the signer's address from the signature and verifies
|
|
265
|
+
* it matches the claimed agentAddress. On success, returns the agent's
|
|
266
|
+
* trust profile.
|
|
221
267
|
*
|
|
222
|
-
* @param params - Challenge response with signature and
|
|
268
|
+
* @param params - Challenge response with EIP-191 signature and address
|
|
223
269
|
* @returns Agent trust profile (behavioral score + Icebreaker context if available)
|
|
224
270
|
*/
|
|
225
271
|
verifyKeyAgent(params: {
|
|
226
272
|
challenge: string;
|
|
227
273
|
signature: string;
|
|
228
|
-
|
|
229
|
-
agentKeyHash: string;
|
|
230
|
-
ethereumAddress?: string;
|
|
274
|
+
agentAddress: string;
|
|
231
275
|
}): Promise<KeyAgentProfile>;
|
|
232
276
|
/**
|
|
233
|
-
* Get trust profile for a key-based agent by its
|
|
277
|
+
* Get trust profile for a key-based agent by its Ethereum address.
|
|
234
278
|
*
|
|
235
279
|
* Returns behavioral score and any Icebreaker ownership context.
|
|
236
280
|
* The agent must have been verified via challenge-response at least once.
|
|
237
281
|
*
|
|
238
|
-
* @param
|
|
282
|
+
* @param agentAddress - Ethereum address (keccak256-derived from secp256k1 public key)
|
|
239
283
|
* @returns Agent trust profile
|
|
240
284
|
*/
|
|
241
|
-
getKeyAgentProfile(
|
|
285
|
+
getKeyAgentProfile(agentAddress: string): Promise<KeyAgentProfile>;
|
|
242
286
|
/**
|
|
243
287
|
* Verify a World ID proof linking a human to an agent.
|
|
244
288
|
*
|
|
@@ -248,7 +292,7 @@ export declare class ValironSDK {
|
|
|
248
292
|
*
|
|
249
293
|
* @param agentId - The ERC-8004 agent ID
|
|
250
294
|
* @param proof - World ID proof payload from IDKit
|
|
251
|
-
* @param options - Optional overrides (e.g. `{ chain: '
|
|
295
|
+
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
252
296
|
* @returns Verification result with updated World ID status
|
|
253
297
|
*
|
|
254
298
|
* @example
|
|
@@ -300,7 +344,7 @@ export declare class ValironSDK {
|
|
|
300
344
|
* while Icebreaker provides background enrichment (LinkedIn, GitHub, etc.).
|
|
301
345
|
*
|
|
302
346
|
* @param agentId - The ERC-8004 agent ID
|
|
303
|
-
* @param options - Optional overrides (e.g. `{ chain: '
|
|
347
|
+
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
304
348
|
* @returns Combined human trust profile
|
|
305
349
|
*
|
|
306
350
|
* @example
|
|
@@ -312,103 +356,6 @@ export declare class ValironSDK {
|
|
|
312
356
|
* ```
|
|
313
357
|
*/
|
|
314
358
|
getWorldIdProfile(agentId: string, options?: CallOptions): Promise<WorldIdAgentProfile>;
|
|
315
|
-
/**
|
|
316
|
-
* Preflight gate check for a Solana payment channel.
|
|
317
|
-
*
|
|
318
|
-
* Checks the agent's trust score and returns the escrow address,
|
|
319
|
-
* credit line, and tier policy. Call this before opening a channel.
|
|
320
|
-
*
|
|
321
|
-
* @param agentId - The agent ID (ERC-8004 or Solana)
|
|
322
|
-
* @param walletAddress - The agent's Solana wallet address
|
|
323
|
-
* @returns Preflight result with escrow address and credit line
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* ```typescript
|
|
327
|
-
* const preflight = await valiron.channelPreflight('25459', 'So1ana...');
|
|
328
|
-
* console.log(preflight.escrowAddress); // deposit USDC here
|
|
329
|
-
* console.log(preflight.creditLineReadable); // '$50.00'
|
|
330
|
-
* console.log(preflight.tier); // 'AA'
|
|
331
|
-
* ```
|
|
332
|
-
*/
|
|
333
|
-
channelPreflight(agentId: string, walletAddress: string): Promise<ChannelPreflightResponse>;
|
|
334
|
-
/**
|
|
335
|
-
* Open a payment channel after depositing USDC to the escrow.
|
|
336
|
-
*
|
|
337
|
-
* Verifies the deposit transaction on-chain and opens a credit line
|
|
338
|
-
* based on the agent's trust tier.
|
|
339
|
-
*
|
|
340
|
-
* @param agentId - The agent ID
|
|
341
|
-
* @param walletAddress - The agent's Solana wallet address
|
|
342
|
-
* @param depositSignature - The Solana transaction signature of the USDC deposit
|
|
343
|
-
* @returns Channel session with ID, credit line, and expiry
|
|
344
|
-
*
|
|
345
|
-
* @example
|
|
346
|
-
* ```typescript
|
|
347
|
-
* const channel = await valiron.channelOpen('25459', 'So1ana...', '5eykt...');
|
|
348
|
-
* console.log(channel.sessionId); // 'ch_abc123'
|
|
349
|
-
* console.log(channel.creditLineReadable); // '$50.00'
|
|
350
|
-
* console.log(channel.expiresAt); // ISO timestamp
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
channelOpen(agentId: string, walletAddress: string, depositSignature: string): Promise<ChannelOpenResponse>;
|
|
354
|
-
/**
|
|
355
|
-
* Consume credit from an open payment channel.
|
|
356
|
-
*
|
|
357
|
-
* Records a charge against the channel's credit line. The session ID
|
|
358
|
-
* is used as the authorization token.
|
|
359
|
-
*
|
|
360
|
-
* @param sessionId - The channel session ID from `channelOpen()`
|
|
361
|
-
* @param cost - Amount to charge in USDC (e.g. 0.5 for $0.50)
|
|
362
|
-
* @param description - Optional description of the charge
|
|
363
|
-
* @returns Usage record with remaining balance
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```typescript
|
|
367
|
-
* const usage = await valiron.channelConsume('ch_abc123', 0.5, 'GPT-4 call');
|
|
368
|
-
* console.log(usage.session.remainingReadable); // '$49.50'
|
|
369
|
-
* console.log(usage.session.requestCount); // 1
|
|
370
|
-
* ```
|
|
371
|
-
*/
|
|
372
|
-
channelConsume(sessionId: string, cost: number, description?: string): Promise<ChannelConsumeResponse>;
|
|
373
|
-
/**
|
|
374
|
-
* Get the current status of a payment channel.
|
|
375
|
-
*
|
|
376
|
-
* @param sessionId - The channel session ID
|
|
377
|
-
* @returns Channel status with balance, request count, and expiry
|
|
378
|
-
*
|
|
379
|
-
* @example
|
|
380
|
-
* ```typescript
|
|
381
|
-
* const status = await valiron.channelStatus('ch_abc123');
|
|
382
|
-
* console.log(status.remainingReadable); // '$49.50'
|
|
383
|
-
* console.log(status.active); // true
|
|
384
|
-
* console.log(status.settled); // false
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
channelStatus(sessionId: string): Promise<ChannelStatusResponse>;
|
|
388
|
-
/**
|
|
389
|
-
* Settle and close a payment channel.
|
|
390
|
-
*
|
|
391
|
-
* Closes the channel, calculates unused credit, and refunds
|
|
392
|
-
* unspent USDC back to the agent's wallet on Solana.
|
|
393
|
-
*
|
|
394
|
-
* @param sessionId - The channel session ID
|
|
395
|
-
* @returns Settlement result with refund details
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```typescript
|
|
399
|
-
* const settlement = await valiron.channelSettle('ch_abc123');
|
|
400
|
-
* console.log(settlement.totalConsumedReadable); // '$0.50'
|
|
401
|
-
* console.log(settlement.refundReadable); // '$49.50'
|
|
402
|
-
* console.log(settlement.refundSignature); // Solana TX sig
|
|
403
|
-
* ```
|
|
404
|
-
*/
|
|
405
|
-
channelSettle(sessionId: string): Promise<ChannelSettlementResponse>;
|
|
406
|
-
/**
|
|
407
|
-
* Check payment channel service health.
|
|
408
|
-
*
|
|
409
|
-
* @returns Health status and escrow address
|
|
410
|
-
*/
|
|
411
|
-
channelHealth(): Promise<ChannelHealthResponse>;
|
|
412
359
|
/**
|
|
413
360
|
* Flush any pending telemetry events and release resources.
|
|
414
361
|
*
|
|
@@ -433,7 +380,7 @@ export * from "./types";
|
|
|
433
380
|
export { ValironClient } from "./clients";
|
|
434
381
|
export { createValironGate, valironFastifyPlugin, createValironNextMiddleware, valironGateCheck, } from "./middleware";
|
|
435
382
|
export type { ValironGateConfig, ValironFastifyConfig, ValironNextConfig, ValironGateCheckResult, } from "./middleware";
|
|
436
|
-
export {
|
|
437
|
-
export type {
|
|
383
|
+
export { isValidAddress, generateChallenge, } from "./identity";
|
|
384
|
+
export type { ChallengeResponse, } from "./identity";
|
|
438
385
|
export { ValironOperator } from "./operatorSdk";
|
|
439
386
|
export type { ValironOperatorConfig, PaywallConfig } from "./operatorSdk";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ValironOperator = exports.
|
|
17
|
+
exports.ValironOperator = exports.generateChallenge = exports.isValidAddress = exports.valironGateCheck = exports.createValironNextMiddleware = exports.valironFastifyPlugin = exports.createValironGate = exports.ValironClient = exports.ValironSDK = void 0;
|
|
18
18
|
const clients_1 = require("./clients");
|
|
19
19
|
/**
|
|
20
20
|
* Valiron SDK – Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
@@ -197,6 +197,26 @@ class ValironSDK {
|
|
|
197
197
|
async triggerSandboxTest(agentId, options) {
|
|
198
198
|
return this.client.triggerSandboxTest(agentId, options);
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Trigger sandbox testing for a key-based (web2) agent.
|
|
202
|
+
*
|
|
203
|
+
* Key agents have no on-chain endpoints, so this uses sandbox_relay mode.
|
|
204
|
+
* The result is written to Redis so subsequent `getKeyAgentProfile()` calls
|
|
205
|
+
* return a real score.
|
|
206
|
+
*
|
|
207
|
+
* @param agentAddress - The key agent's Ethereum address
|
|
208
|
+
* @returns Sandbox test results including score and tier
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const result = await valiron.triggerKeyAgentSandbox('0xabc...');
|
|
213
|
+
* console.log(result.valironScore); // 82
|
|
214
|
+
* console.log(result.tier); // 'A'
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
async triggerKeyAgentSandbox(agentAddress) {
|
|
218
|
+
return this.client.triggerKeyAgentSandbox(agentAddress);
|
|
219
|
+
}
|
|
200
220
|
/**
|
|
201
221
|
* Trust gate — checks an agent by combining on-chain reputation with
|
|
202
222
|
* sandbox behavioral tests and returns a single allow/deny decision.
|
|
@@ -229,6 +249,36 @@ class ValironSDK {
|
|
|
229
249
|
async gate(agentId, options) {
|
|
230
250
|
return this.client.gate(agentId, options);
|
|
231
251
|
}
|
|
252
|
+
// ─── Proxy Gateway ──────────────────────────────────────────────────────
|
|
253
|
+
/**
|
|
254
|
+
* Proxy an API call through Valiron's trust gateway.
|
|
255
|
+
*
|
|
256
|
+
* Linear flow: Agent → Valiron → API Seller
|
|
257
|
+
*
|
|
258
|
+
* Valiron evaluates the agent inline and either forwards the request to
|
|
259
|
+
* the real API or blocks with 403. The agent never touches the API
|
|
260
|
+
* seller directly.
|
|
261
|
+
*
|
|
262
|
+
* @param agentId - On-chain agent ID (ERC-8004 token ID or Solana pubkey)
|
|
263
|
+
* @param request - Target URL, method, headers, and body to forward
|
|
264
|
+
* @param options - Optional chain override
|
|
265
|
+
* @returns Proxied API response wrapped with Valiron metadata
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const result = await valiron.proxy('25459', {
|
|
270
|
+
* target: 'https://api-seller.example.com/data',
|
|
271
|
+
* method: 'GET',
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* if (result._valiron.allow) {
|
|
275
|
+
* console.log(result.response); // Real API data
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
async proxy(agentId, request, options) {
|
|
280
|
+
return this.client.proxy(agentId, request, options);
|
|
281
|
+
}
|
|
232
282
|
// ─── Key-Based Agent Identity (Web2 Agents) ─────────────────────────────
|
|
233
283
|
/**
|
|
234
284
|
* Get a challenge nonce for a key-based agent to prove identity.
|
|
@@ -236,42 +286,43 @@ class ValironSDK {
|
|
|
236
286
|
* The agent must sign this challenge with its private key and
|
|
237
287
|
* return the signature via `verifyKeyAgent()`.
|
|
238
288
|
*
|
|
239
|
-
* @param
|
|
289
|
+
* @param agentAddress - Ethereum address of the agent
|
|
240
290
|
* @returns Challenge nonce and expiry
|
|
241
291
|
*
|
|
242
292
|
* @example
|
|
243
293
|
* ```typescript
|
|
244
|
-
* const { challenge } = await valiron.getKeyAgentChallenge('
|
|
245
|
-
* const
|
|
246
|
-
* const profile = await valiron.verifyKeyAgent(
|
|
294
|
+
* const { challenge } = await valiron.getKeyAgentChallenge('0x1234...abcd');
|
|
295
|
+
* const signature = await account.signMessage({ message: challenge });
|
|
296
|
+
* const profile = await valiron.verifyKeyAgent({ challenge, signature, agentAddress });
|
|
247
297
|
* ```
|
|
248
298
|
*/
|
|
249
|
-
async getKeyAgentChallenge(
|
|
250
|
-
return this.client.getKeyAgentChallenge(
|
|
299
|
+
async getKeyAgentChallenge(agentAddress) {
|
|
300
|
+
return this.client.getKeyAgentChallenge(agentAddress);
|
|
251
301
|
}
|
|
252
302
|
/**
|
|
253
|
-
* Verify a key-based agent's identity via challenge-response.
|
|
303
|
+
* Verify a key-based agent's identity via EIP-191 challenge-response.
|
|
254
304
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
305
|
+
* The server recovers the signer's address from the signature and verifies
|
|
306
|
+
* it matches the claimed agentAddress. On success, returns the agent's
|
|
307
|
+
* trust profile.
|
|
257
308
|
*
|
|
258
|
-
* @param params - Challenge response with signature and
|
|
309
|
+
* @param params - Challenge response with EIP-191 signature and address
|
|
259
310
|
* @returns Agent trust profile (behavioral score + Icebreaker context if available)
|
|
260
311
|
*/
|
|
261
312
|
async verifyKeyAgent(params) {
|
|
262
313
|
return this.client.verifyKeyAgent(params);
|
|
263
314
|
}
|
|
264
315
|
/**
|
|
265
|
-
* Get trust profile for a key-based agent by its
|
|
316
|
+
* Get trust profile for a key-based agent by its Ethereum address.
|
|
266
317
|
*
|
|
267
318
|
* Returns behavioral score and any Icebreaker ownership context.
|
|
268
319
|
* The agent must have been verified via challenge-response at least once.
|
|
269
320
|
*
|
|
270
|
-
* @param
|
|
321
|
+
* @param agentAddress - Ethereum address (keccak256-derived from secp256k1 public key)
|
|
271
322
|
* @returns Agent trust profile
|
|
272
323
|
*/
|
|
273
|
-
async getKeyAgentProfile(
|
|
274
|
-
return this.client.getKeyAgentProfile(
|
|
324
|
+
async getKeyAgentProfile(agentAddress) {
|
|
325
|
+
return this.client.getKeyAgentProfile(agentAddress);
|
|
275
326
|
}
|
|
276
327
|
// ─── World ID (Proof-of-Personhood) ─────────────────────────────────
|
|
277
328
|
/**
|
|
@@ -283,7 +334,7 @@ class ValironSDK {
|
|
|
283
334
|
*
|
|
284
335
|
* @param agentId - The ERC-8004 agent ID
|
|
285
336
|
* @param proof - World ID proof payload from IDKit
|
|
286
|
-
* @param options - Optional overrides (e.g. `{ chain: '
|
|
337
|
+
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
287
338
|
* @returns Verification result with updated World ID status
|
|
288
339
|
*
|
|
289
340
|
* @example
|
|
@@ -325,7 +376,7 @@ class ValironSDK {
|
|
|
325
376
|
* while Icebreaker provides background enrichment (LinkedIn, GitHub, etc.).
|
|
326
377
|
*
|
|
327
378
|
* @param agentId - The ERC-8004 agent ID
|
|
328
|
-
* @param options - Optional overrides (e.g. `{ chain: '
|
|
379
|
+
* @param options - Optional overrides (e.g. `{ chain: 'base' }`)
|
|
329
380
|
* @returns Combined human trust profile
|
|
330
381
|
*
|
|
331
382
|
* @example
|
|
@@ -339,116 +390,6 @@ class ValironSDK {
|
|
|
339
390
|
async getWorldIdProfile(agentId, options) {
|
|
340
391
|
return this.client.getWorldIdProfile(agentId, options);
|
|
341
392
|
}
|
|
342
|
-
// ─── Payment Channels (Solana) ─────────────────────────────────────────
|
|
343
|
-
/**
|
|
344
|
-
* Preflight gate check for a Solana payment channel.
|
|
345
|
-
*
|
|
346
|
-
* Checks the agent's trust score and returns the escrow address,
|
|
347
|
-
* credit line, and tier policy. Call this before opening a channel.
|
|
348
|
-
*
|
|
349
|
-
* @param agentId - The agent ID (ERC-8004 or Solana)
|
|
350
|
-
* @param walletAddress - The agent's Solana wallet address
|
|
351
|
-
* @returns Preflight result with escrow address and credit line
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
* ```typescript
|
|
355
|
-
* const preflight = await valiron.channelPreflight('25459', 'So1ana...');
|
|
356
|
-
* console.log(preflight.escrowAddress); // deposit USDC here
|
|
357
|
-
* console.log(preflight.creditLineReadable); // '$50.00'
|
|
358
|
-
* console.log(preflight.tier); // 'AA'
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
async channelPreflight(agentId, walletAddress) {
|
|
362
|
-
return this.client.channelPreflight(agentId, walletAddress);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Open a payment channel after depositing USDC to the escrow.
|
|
366
|
-
*
|
|
367
|
-
* Verifies the deposit transaction on-chain and opens a credit line
|
|
368
|
-
* based on the agent's trust tier.
|
|
369
|
-
*
|
|
370
|
-
* @param agentId - The agent ID
|
|
371
|
-
* @param walletAddress - The agent's Solana wallet address
|
|
372
|
-
* @param depositSignature - The Solana transaction signature of the USDC deposit
|
|
373
|
-
* @returns Channel session with ID, credit line, and expiry
|
|
374
|
-
*
|
|
375
|
-
* @example
|
|
376
|
-
* ```typescript
|
|
377
|
-
* const channel = await valiron.channelOpen('25459', 'So1ana...', '5eykt...');
|
|
378
|
-
* console.log(channel.sessionId); // 'ch_abc123'
|
|
379
|
-
* console.log(channel.creditLineReadable); // '$50.00'
|
|
380
|
-
* console.log(channel.expiresAt); // ISO timestamp
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
async channelOpen(agentId, walletAddress, depositSignature) {
|
|
384
|
-
return this.client.channelOpen(agentId, walletAddress, depositSignature);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Consume credit from an open payment channel.
|
|
388
|
-
*
|
|
389
|
-
* Records a charge against the channel's credit line. The session ID
|
|
390
|
-
* is used as the authorization token.
|
|
391
|
-
*
|
|
392
|
-
* @param sessionId - The channel session ID from `channelOpen()`
|
|
393
|
-
* @param cost - Amount to charge in USDC (e.g. 0.5 for $0.50)
|
|
394
|
-
* @param description - Optional description of the charge
|
|
395
|
-
* @returns Usage record with remaining balance
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```typescript
|
|
399
|
-
* const usage = await valiron.channelConsume('ch_abc123', 0.5, 'GPT-4 call');
|
|
400
|
-
* console.log(usage.session.remainingReadable); // '$49.50'
|
|
401
|
-
* console.log(usage.session.requestCount); // 1
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
async channelConsume(sessionId, cost, description) {
|
|
405
|
-
return this.client.channelConsume(sessionId, cost, description);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Get the current status of a payment channel.
|
|
409
|
-
*
|
|
410
|
-
* @param sessionId - The channel session ID
|
|
411
|
-
* @returns Channel status with balance, request count, and expiry
|
|
412
|
-
*
|
|
413
|
-
* @example
|
|
414
|
-
* ```typescript
|
|
415
|
-
* const status = await valiron.channelStatus('ch_abc123');
|
|
416
|
-
* console.log(status.remainingReadable); // '$49.50'
|
|
417
|
-
* console.log(status.active); // true
|
|
418
|
-
* console.log(status.settled); // false
|
|
419
|
-
* ```
|
|
420
|
-
*/
|
|
421
|
-
async channelStatus(sessionId) {
|
|
422
|
-
return this.client.channelStatus(sessionId);
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Settle and close a payment channel.
|
|
426
|
-
*
|
|
427
|
-
* Closes the channel, calculates unused credit, and refunds
|
|
428
|
-
* unspent USDC back to the agent's wallet on Solana.
|
|
429
|
-
*
|
|
430
|
-
* @param sessionId - The channel session ID
|
|
431
|
-
* @returns Settlement result with refund details
|
|
432
|
-
*
|
|
433
|
-
* @example
|
|
434
|
-
* ```typescript
|
|
435
|
-
* const settlement = await valiron.channelSettle('ch_abc123');
|
|
436
|
-
* console.log(settlement.totalConsumedReadable); // '$0.50'
|
|
437
|
-
* console.log(settlement.refundReadable); // '$49.50'
|
|
438
|
-
* console.log(settlement.refundSignature); // Solana TX sig
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
async channelSettle(sessionId) {
|
|
442
|
-
return this.client.channelSettle(sessionId);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Check payment channel service health.
|
|
446
|
-
*
|
|
447
|
-
* @returns Health status and escrow address
|
|
448
|
-
*/
|
|
449
|
-
async channelHealth() {
|
|
450
|
-
return this.client.channelHealth();
|
|
451
|
-
}
|
|
452
393
|
/**
|
|
453
394
|
* Flush any pending telemetry events and release resources.
|
|
454
395
|
*
|
|
@@ -482,10 +423,7 @@ Object.defineProperty(exports, "valironFastifyPlugin", { enumerable: true, get:
|
|
|
482
423
|
Object.defineProperty(exports, "createValironNextMiddleware", { enumerable: true, get: function () { return middleware_1.createValironNextMiddleware; } });
|
|
483
424
|
Object.defineProperty(exports, "valironGateCheck", { enumerable: true, get: function () { return middleware_1.valironGateCheck; } });
|
|
484
425
|
var identity_1 = require("./identity");
|
|
485
|
-
Object.defineProperty(exports, "
|
|
486
|
-
Object.defineProperty(exports, "deriveKeyHash", { enumerable: true, get: function () { return identity_1.deriveKeyHash; } });
|
|
426
|
+
Object.defineProperty(exports, "isValidAddress", { enumerable: true, get: function () { return identity_1.isValidAddress; } });
|
|
487
427
|
Object.defineProperty(exports, "generateChallenge", { enumerable: true, get: function () { return identity_1.generateChallenge; } });
|
|
488
|
-
Object.defineProperty(exports, "signChallenge", { enumerable: true, get: function () { return identity_1.signChallenge; } });
|
|
489
|
-
Object.defineProperty(exports, "verifyChallenge", { enumerable: true, get: function () { return identity_1.verifyChallenge; } });
|
|
490
428
|
var operatorSdk_1 = require("./operatorSdk");
|
|
491
429
|
Object.defineProperty(exports, "ValironOperator", { enumerable: true, get: function () { return operatorSdk_1.ValironOperator; } });
|