@bind-protocol/sdk 0.9.0 → 0.11.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/dist/{adapter-qe9f1ll3.d.cts → adapter-BCmJtPVz.d.cts} +23 -9
- package/dist/{adapter-J6D9MZJV.d.ts → adapter-DEuMXI-G.d.ts} +23 -9
- package/dist/adapters/dimo/index.cjs +61 -10
- package/dist/adapters/dimo/index.cjs.map +1 -1
- package/dist/adapters/dimo/index.d.cts +32 -5
- package/dist/adapters/dimo/index.d.ts +32 -5
- package/dist/adapters/dimo/index.js +61 -11
- package/dist/adapters/dimo/index.js.map +1 -1
- package/dist/adapters/index.cjs +50 -12
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +5 -5
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/index.js +50 -12
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/zktls/index.cjs +57 -2
- package/dist/adapters/zktls/index.cjs.map +1 -1
- package/dist/adapters/zktls/index.d.cts +18 -112
- package/dist/adapters/zktls/index.d.ts +18 -112
- package/dist/adapters/zktls/index.js +57 -3
- package/dist/adapters/zktls/index.js.map +1 -1
- package/dist/{client-CfYXpFLk.d.cts → client-D8RRkS5D.d.ts} +2 -2
- package/dist/{client-CpJ87Xe0.d.ts → client-Dwp_OgM8.d.cts} +2 -2
- package/dist/coinbase-D-ngYKTf.d.cts +116 -0
- package/dist/coinbase-tRHE5pGm.d.ts +116 -0
- package/dist/core/index.cjs +24 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +24 -2
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +411 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -6
- package/dist/index.d.ts +56 -6
- package/dist/index.js +406 -13
- package/dist/index.js.map +1 -1
- package/dist/types-BmMuzYu5.d.ts +64 -0
- package/dist/{types-D7Q7ymPa.d.ts → types-BmwJILOi.d.ts} +1 -1
- package/dist/types-CZN2fVZM.d.cts +64 -0
- package/dist/{types-ywkMNwun.d.cts → types-DLLfJJdQ.d.cts} +1 -1
- package/dist/{types-BcPssdQk.d.cts → types-YCc5fSja.d.cts} +1 -1
- package/dist/{types-BcPssdQk.d.ts → types-YCc5fSja.d.ts} +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { B as BindClient } from './client-Dwp_OgM8.cjs';
|
|
2
|
+
import { D as DataAdapter } from './types-DLLfJJdQ.cjs';
|
|
3
|
+
import { e as ZkTlsAttestation, Z as ZkTlsExtractor, P as ProveJobInputs } from './types-YCc5fSja.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* zkTLS Adapter Types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for zkTLS adapters
|
|
11
|
+
*/
|
|
12
|
+
interface ZkTlsAdapterConfig {
|
|
13
|
+
/** Bind Protocol API key */
|
|
14
|
+
apiKey: string;
|
|
15
|
+
/** API base URL (optional) */
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Query parameters for fetching attestation
|
|
20
|
+
*/
|
|
21
|
+
interface ZkTlsQuery {
|
|
22
|
+
/** Existing attestation ID to use */
|
|
23
|
+
attestationId?: string;
|
|
24
|
+
/** Or create new session with callback URL */
|
|
25
|
+
callbackUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Attestation data returned by adapter
|
|
29
|
+
*/
|
|
30
|
+
interface ZkTlsAttestationData {
|
|
31
|
+
attestation: ZkTlsAttestation;
|
|
32
|
+
extractor: ZkTlsExtractor;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Coinbase-specific claim structure
|
|
36
|
+
*/
|
|
37
|
+
interface CoinbaseKycClaims {
|
|
38
|
+
kyc_verified: boolean;
|
|
39
|
+
kyc_level?: number;
|
|
40
|
+
country_code?: string;
|
|
41
|
+
account_created_at?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Base zkTLS Adapter
|
|
46
|
+
*
|
|
47
|
+
* Provides common functionality for zkTLS-based data sources.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
declare abstract class ZkTlsAdapter implements DataAdapter<ZkTlsAdapterConfig, ZkTlsQuery, ZkTlsAttestationData> {
|
|
51
|
+
abstract readonly id: string;
|
|
52
|
+
abstract readonly name: string;
|
|
53
|
+
abstract readonly description: string;
|
|
54
|
+
abstract readonly extractorId: string;
|
|
55
|
+
protected abstract readonly supportedCircuits: string[];
|
|
56
|
+
protected readonly client: BindClient;
|
|
57
|
+
constructor(config: ZkTlsAdapterConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Fetch attestation data - either from existing attestation or by creating session
|
|
60
|
+
*/
|
|
61
|
+
fetchData(query: ZkTlsQuery): Promise<ZkTlsAttestationData>;
|
|
62
|
+
/**
|
|
63
|
+
* Transform attestation to circuit inputs
|
|
64
|
+
*/
|
|
65
|
+
abstract toCircuitInputs(data: ZkTlsAttestationData, circuitId: string): ProveJobInputs;
|
|
66
|
+
/**
|
|
67
|
+
* Get supported circuits
|
|
68
|
+
*/
|
|
69
|
+
getSupportedCircuits(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Create a zkTLS session and return the auth URL
|
|
72
|
+
* Client should redirect user to this URL
|
|
73
|
+
*/
|
|
74
|
+
createSession(callbackUrl: string): Promise<{
|
|
75
|
+
sessionId: string;
|
|
76
|
+
authUrl: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Wait for session completion and return attestation
|
|
80
|
+
*/
|
|
81
|
+
waitForSession(sessionId: string, options?: {
|
|
82
|
+
intervalMs?: number;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
}): Promise<ZkTlsAttestationData>;
|
|
85
|
+
protected fetchExistingAttestation(attestationId: string): Promise<ZkTlsAttestationData>;
|
|
86
|
+
protected initiateSession(callbackUrl: string): Promise<ZkTlsAttestationData>;
|
|
87
|
+
protected validateCircuit(circuitId: string): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Coinbase KYC Adapter
|
|
92
|
+
*
|
|
93
|
+
* Fetches KYC attestation data from Coinbase via zkTLS
|
|
94
|
+
* and transforms it for identity verification circuits.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
declare class CoinbaseAdapter extends ZkTlsAdapter {
|
|
98
|
+
readonly id = "coinbase-kyc";
|
|
99
|
+
readonly name = "Coinbase KYC";
|
|
100
|
+
readonly description = "Fetches KYC verification status from Coinbase via zkTLS attestation";
|
|
101
|
+
readonly extractorId = "coinbase";
|
|
102
|
+
protected readonly supportedCircuits: string[];
|
|
103
|
+
constructor(config: ZkTlsAdapterConfig);
|
|
104
|
+
/**
|
|
105
|
+
* Transform Coinbase attestation to circuit inputs
|
|
106
|
+
*/
|
|
107
|
+
toCircuitInputs(data: ZkTlsAttestationData, circuitId: string): ProveJobInputs;
|
|
108
|
+
private toKycInputs;
|
|
109
|
+
private toCoinbaseInputs;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Factory function to create a Coinbase adapter
|
|
113
|
+
*/
|
|
114
|
+
declare function createCoinbaseAdapter(config: ZkTlsAdapterConfig): CoinbaseAdapter;
|
|
115
|
+
|
|
116
|
+
export { CoinbaseAdapter as C, ZkTlsAdapter as Z, type ZkTlsAdapterConfig as a, type ZkTlsQuery as b, createCoinbaseAdapter as c, type ZkTlsAttestationData as d, type CoinbaseKycClaims as e };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { B as BindClient } from './client-D8RRkS5D.js';
|
|
2
|
+
import { D as DataAdapter } from './types-BmwJILOi.js';
|
|
3
|
+
import { e as ZkTlsAttestation, Z as ZkTlsExtractor, P as ProveJobInputs } from './types-YCc5fSja.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* zkTLS Adapter Types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for zkTLS adapters
|
|
11
|
+
*/
|
|
12
|
+
interface ZkTlsAdapterConfig {
|
|
13
|
+
/** Bind Protocol API key */
|
|
14
|
+
apiKey: string;
|
|
15
|
+
/** API base URL (optional) */
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Query parameters for fetching attestation
|
|
20
|
+
*/
|
|
21
|
+
interface ZkTlsQuery {
|
|
22
|
+
/** Existing attestation ID to use */
|
|
23
|
+
attestationId?: string;
|
|
24
|
+
/** Or create new session with callback URL */
|
|
25
|
+
callbackUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Attestation data returned by adapter
|
|
29
|
+
*/
|
|
30
|
+
interface ZkTlsAttestationData {
|
|
31
|
+
attestation: ZkTlsAttestation;
|
|
32
|
+
extractor: ZkTlsExtractor;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Coinbase-specific claim structure
|
|
36
|
+
*/
|
|
37
|
+
interface CoinbaseKycClaims {
|
|
38
|
+
kyc_verified: boolean;
|
|
39
|
+
kyc_level?: number;
|
|
40
|
+
country_code?: string;
|
|
41
|
+
account_created_at?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Base zkTLS Adapter
|
|
46
|
+
*
|
|
47
|
+
* Provides common functionality for zkTLS-based data sources.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
declare abstract class ZkTlsAdapter implements DataAdapter<ZkTlsAdapterConfig, ZkTlsQuery, ZkTlsAttestationData> {
|
|
51
|
+
abstract readonly id: string;
|
|
52
|
+
abstract readonly name: string;
|
|
53
|
+
abstract readonly description: string;
|
|
54
|
+
abstract readonly extractorId: string;
|
|
55
|
+
protected abstract readonly supportedCircuits: string[];
|
|
56
|
+
protected readonly client: BindClient;
|
|
57
|
+
constructor(config: ZkTlsAdapterConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Fetch attestation data - either from existing attestation or by creating session
|
|
60
|
+
*/
|
|
61
|
+
fetchData(query: ZkTlsQuery): Promise<ZkTlsAttestationData>;
|
|
62
|
+
/**
|
|
63
|
+
* Transform attestation to circuit inputs
|
|
64
|
+
*/
|
|
65
|
+
abstract toCircuitInputs(data: ZkTlsAttestationData, circuitId: string): ProveJobInputs;
|
|
66
|
+
/**
|
|
67
|
+
* Get supported circuits
|
|
68
|
+
*/
|
|
69
|
+
getSupportedCircuits(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Create a zkTLS session and return the auth URL
|
|
72
|
+
* Client should redirect user to this URL
|
|
73
|
+
*/
|
|
74
|
+
createSession(callbackUrl: string): Promise<{
|
|
75
|
+
sessionId: string;
|
|
76
|
+
authUrl: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Wait for session completion and return attestation
|
|
80
|
+
*/
|
|
81
|
+
waitForSession(sessionId: string, options?: {
|
|
82
|
+
intervalMs?: number;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
}): Promise<ZkTlsAttestationData>;
|
|
85
|
+
protected fetchExistingAttestation(attestationId: string): Promise<ZkTlsAttestationData>;
|
|
86
|
+
protected initiateSession(callbackUrl: string): Promise<ZkTlsAttestationData>;
|
|
87
|
+
protected validateCircuit(circuitId: string): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Coinbase KYC Adapter
|
|
92
|
+
*
|
|
93
|
+
* Fetches KYC attestation data from Coinbase via zkTLS
|
|
94
|
+
* and transforms it for identity verification circuits.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
declare class CoinbaseAdapter extends ZkTlsAdapter {
|
|
98
|
+
readonly id = "coinbase-kyc";
|
|
99
|
+
readonly name = "Coinbase KYC";
|
|
100
|
+
readonly description = "Fetches KYC verification status from Coinbase via zkTLS attestation";
|
|
101
|
+
readonly extractorId = "coinbase";
|
|
102
|
+
protected readonly supportedCircuits: string[];
|
|
103
|
+
constructor(config: ZkTlsAdapterConfig);
|
|
104
|
+
/**
|
|
105
|
+
* Transform Coinbase attestation to circuit inputs
|
|
106
|
+
*/
|
|
107
|
+
toCircuitInputs(data: ZkTlsAttestationData, circuitId: string): ProveJobInputs;
|
|
108
|
+
private toKycInputs;
|
|
109
|
+
private toCoinbaseInputs;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Factory function to create a Coinbase adapter
|
|
113
|
+
*/
|
|
114
|
+
declare function createCoinbaseAdapter(config: ZkTlsAdapterConfig): CoinbaseAdapter;
|
|
115
|
+
|
|
116
|
+
export { CoinbaseAdapter as C, ZkTlsAdapter as Z, type ZkTlsAdapterConfig as a, type ZkTlsQuery as b, createCoinbaseAdapter as c, type ZkTlsAttestationData as d, type CoinbaseKycClaims as e };
|
package/dist/core/index.cjs
CHANGED
|
@@ -432,18 +432,40 @@ var BindClient = class {
|
|
|
432
432
|
* @returns The verification result
|
|
433
433
|
* @throws {ApiError} If the API request fails
|
|
434
434
|
*/
|
|
435
|
-
async verifyUploadedProof(proofBuffer, vkBuffer) {
|
|
435
|
+
async verifyUploadedProof(proofBuffer, vkBuffer, options) {
|
|
436
|
+
const intervalMs = options?.intervalMs ?? 1e3;
|
|
437
|
+
const timeoutMs = options?.timeoutMs ?? 12e4;
|
|
436
438
|
const proofBytes = proofBuffer instanceof Uint8Array ? proofBuffer : new Uint8Array(proofBuffer);
|
|
437
439
|
const vkBytes = vkBuffer instanceof Uint8Array ? vkBuffer : new Uint8Array(vkBuffer);
|
|
438
440
|
const proofBase64 = typeof Buffer !== "undefined" ? Buffer.from(proofBytes).toString("base64") : btoa(String.fromCharCode(...proofBytes));
|
|
439
441
|
const vkBase64 = typeof Buffer !== "undefined" ? Buffer.from(vkBytes).toString("base64") : btoa(String.fromCharCode(...vkBytes));
|
|
440
|
-
|
|
442
|
+
const queueResult = await this.fetchJson("/api/verify/upload", {
|
|
441
443
|
method: "POST",
|
|
442
444
|
body: JSON.stringify({
|
|
443
445
|
proof: proofBase64,
|
|
444
446
|
vk: vkBase64
|
|
445
447
|
})
|
|
446
448
|
});
|
|
449
|
+
const jobId = queueResult.jobId;
|
|
450
|
+
const startTime = Date.now();
|
|
451
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
452
|
+
const statusResult = await this.getVerifyJobStatus(jobId);
|
|
453
|
+
if (statusResult.status === "completed" || statusResult.status === "failed") {
|
|
454
|
+
return {
|
|
455
|
+
isValid: statusResult.isValid ?? false,
|
|
456
|
+
error: statusResult.error,
|
|
457
|
+
verificationTimeMs: statusResult.verificationTimeMs ?? 0,
|
|
458
|
+
creditsCharged: statusResult.creditsCharged ?? queueResult.creditsCharged,
|
|
459
|
+
verificationResultId: statusResult.verificationResultId ?? jobId,
|
|
460
|
+
publicInputs: statusResult.publicInputs
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
await this.sleep(intervalMs);
|
|
464
|
+
}
|
|
465
|
+
throw new TimeoutError(
|
|
466
|
+
`Verification timed out after ${timeoutMs}ms. Job ID: ${jobId}`,
|
|
467
|
+
timeoutMs
|
|
468
|
+
);
|
|
447
469
|
}
|
|
448
470
|
/**
|
|
449
471
|
* Get verification history for the authenticated organization
|
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts"],"names":[],"mappings":";;;AAIO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA,EACnC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,WAAA;AAAA,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mBAAA,EAAoB;AAAA,IAChC;AAEA,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,GAAO,KAAA,CAAM,OAAO,EAAC,CAAE,CAAA;AACnD,MAAA,MAAM,IAAI,QAAA;AAAA,QACR,KAAK,KAAA,IAAS,CAAA,KAAA,EAAQ,SAAS,MAAM,CAAA,EAAA,EAAK,SAAS,UAAU,CAAA,CAAA;AAAA,QAC7D,QAAA,CAAS,MAAA;AAAA,QACT;AAAA,OACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,MAAc,SAAA,CAAa,IAAA,EAAc,IAAA,EAAgC;AACvE,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,KAAA,CAAM,MAAM,IAAI,CAAA;AAC5C,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AAEjC,IAAA,IAAI,IAAA,CAAK,YAAY,KAAA,EAAO;AAC1B,MAAA,MAAM,IAAI,QAAA,CAAS,IAAA,CAAK,SAAS,gBAAA,EAAkB,QAAA,CAAS,QAAQ,IAAI,CAAA;AAAA,IAC1E;AAEA,IAAA,OAAQ,KAAK,IAAA,IAAQ,IAAA;AAAA,EACvB;AAAA,EAEQ,MAAM,EAAA,EAA2B;AACvC,IAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AAAA,EACzD;AACF","file":"index.cjs","sourcesContent":["/**\n * Custom error classes for the Bind Protocol SDK\n */\n\nexport class BindError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'BindError';\n }\n}\n\nexport class ApiError extends BindError {\n constructor(\n message: string,\n public readonly status: number,\n public readonly response?: unknown\n ) {\n super(message, 'API_ERROR', { status, response });\n this.name = 'ApiError';\n }\n}\n\nexport class AuthenticationError extends BindError {\n constructor(message = 'Authentication failed') {\n super(message, 'AUTH_ERROR');\n this.name = 'AuthenticationError';\n }\n}\n\nexport class TimeoutError extends BindError {\n constructor(message: string, public readonly timeoutMs: number) {\n super(message, 'TIMEOUT_ERROR', { timeoutMs });\n this.name = 'TimeoutError';\n }\n}\n\nexport class InsufficientCreditsError extends BindError {\n constructor(\n public readonly required: number,\n public readonly available: number\n ) {\n super(\n `Insufficient credits: need ${required}, have ${available}`,\n 'INSUFFICIENT_CREDITS',\n { required, available }\n );\n this.name = 'InsufficientCreditsError';\n }\n}\n\n/**\n * Thrown when a zkTLS session expires before completion\n */\nexport class ZkTlsSessionExpiredError extends BindError {\n constructor(public readonly sessionId: string) {\n super(`zkTLS session expired: ${sessionId}`, 'ZKTLS_SESSION_EXPIRED', { sessionId });\n this.name = 'ZkTlsSessionExpiredError';\n }\n}\n\n/**\n * Thrown when a zkTLS session fails\n */\nexport class ZkTlsSessionFailedError extends BindError {\n constructor(\n public readonly sessionId: string,\n public readonly sessionError: string\n ) {\n super(`zkTLS session failed: ${sessionError}`, 'ZKTLS_SESSION_FAILED', { sessionId, sessionError });\n this.name = 'ZkTlsSessionFailedError';\n }\n}\n\n/**\n * Thrown when an extractor is not found or disabled\n */\nexport class ZkTlsExtractorError extends BindError {\n constructor(\n public readonly extractorId: string,\n message: string\n ) {\n super(message, 'ZKTLS_EXTRACTOR_ERROR', { extractorId });\n this.name = 'ZkTlsExtractorError';\n }\n}\n","/**\n * BindClient - Main client for interacting with the Bind Protocol API\n */\nimport type { PublicPolicySpec } from '@bind-protocol/policy-spec';\nimport {\n ApiError,\n AuthenticationError,\n InsufficientCreditsError,\n TimeoutError,\n ZkTlsSessionExpiredError,\n ZkTlsSessionFailedError,\n} from './errors';\nimport type {\n BindClientOptions,\n ProveJobInputs,\n ListProveJobsOptions,\n ProveJob,\n ProveJobSummary,\n SubmitProveJobResult,\n VerificationMode,\n ZkTlsExtractor,\n ZkTlsAttestation,\n ZkTlsSession,\n Circuit,\n ActivateCircuitResult,\n ShareProofRequest,\n SharedProof,\n ListSharedProofsOptions,\n RevokeSharedProofResult,\n VerificationResult,\n VerificationHistoryEntry,\n GetVerificationHistoryOptions,\n Pagination,\n PollOptions,\n VerifyJobStatus,\n} from './types';\n\nconst DEFAULT_BASE_URL = 'https://api.bindprotocol.com';\nconst DEFAULT_POLL_INTERVAL_MS = 2000;\nconst DEFAULT_TIMEOUT_MS = 300000; // 5 minutes\n\n/**\n * Derive a circuit ID from policy ID and version\n * This matches the server's auto-generation logic.\n * Format: {policyId}.v{version} with version dots replaced by underscores\n *\n * @example\n * deriveCircuitId(\"bind.demo.credit-score\", \"0.1.0\")\n * // Returns: \"bind.demo.credit-score.v0_1_0\"\n */\nexport function deriveCircuitId(policyId: string, version: string): string {\n const sanitizedVersion = version.replace(/\\./g, '_');\n return `${policyId}.v${sanitizedVersion}`;\n}\n\nexport class BindClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n\n constructor(options: BindClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || process.env.BIND_API_URL || DEFAULT_BASE_URL;\n this.headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n };\n }\n\n // ==========================================================================\n // Prove Job Methods\n // ==========================================================================\n\n /**\n * Submit a prove job for async processing\n * @param circuitId - The circuit identifier (e.g., \"bind.mobility.riskband.v1\")\n * @param inputs - Circuit inputs as key-value pairs (all values must be strings)\n * @param options - Optional configuration including verificationMode\n * @returns The submitted job details\n * @throws {ApiError} If the API request fails\n * @throws {InsufficientCreditsError} If there aren't enough credits\n */\n async submitProveJob(\n circuitId: string,\n inputs: ProveJobInputs,\n options?: {\n /**\n * How to verify the proof:\n * - 'zkverify': Submit to zkVerify blockchain (default if zkVerify is enabled)\n * - 'self_verify': Store in S3, client downloads and verifies locally\n */\n verificationMode?: VerificationMode;\n }\n ): Promise<SubmitProveJobResult> {\n try {\n return await this.fetchJson<SubmitProveJobResult>('/api/prove', {\n method: 'POST',\n body: JSON.stringify({\n circuitId,\n inputs,\n verificationMode: options?.verificationMode,\n }),\n });\n } catch (err) {\n if (err instanceof ApiError && err.response) {\n const body = err.response as Record<string, unknown>;\n if (body.requiredCredits !== undefined && body.availableCredits !== undefined) {\n throw new InsufficientCreditsError(\n body.requiredCredits as number,\n body.availableCredits as number\n );\n }\n }\n throw err;\n }\n }\n\n /**\n * Get the status and results of a prove job\n * @param jobId - The unique job identifier\n * @returns The job details including status and outputs\n * @throws {ApiError} If the API request fails\n */\n async getProveJob(jobId: string): Promise<ProveJob> {\n return this.fetchJson<ProveJob>(`/api/prove/${encodeURIComponent(jobId)}`);\n }\n\n /**\n * List prove jobs for the authenticated organization\n * @param options - Optional filters for status, limit, and offset\n * @returns Paginated list of prove jobs\n * @throws {ApiError} If the API request fails\n */\n async listProveJobs(options: ListProveJobsOptions = {}): Promise<{ jobs: ProveJobSummary[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.status) params.set('status', options.status);\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n\n const queryString = params.toString();\n const path = queryString ? `/api/prove?${queryString}` : '/api/prove';\n\n return this.fetchJson<{ jobs: ProveJobSummary[]; pagination: Pagination }>(path);\n }\n\n /**\n * Poll for prove job completion\n * @param jobId - The unique job identifier\n * @param options - Polling options\n * @returns The completed or failed job\n * @throws {TimeoutError} If the job doesn't complete within the timeout\n * @throws {ApiError} If the API request fails\n */\n async waitForProveJob(\n jobId: string,\n options: PollOptions & { onProgress?: (job: ProveJob) => void } = {}\n ): Promise<ProveJob> {\n const intervalMs = options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeoutMs) {\n const job = await this.getProveJob(jobId);\n\n if (options.onProgress) {\n options.onProgress(job);\n }\n\n if (job.status === 'completed' || job.status === 'failed') {\n return job;\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Timeout waiting for prove job ${jobId} after ${timeoutMs}ms`,\n timeoutMs\n );\n }\n\n // ==========================================================================\n // Policy Methods (Public, no authentication required)\n // ==========================================================================\n\n /**\n * List all available public policies\n * @returns Array of public policy specifications\n * @throws {ApiError} If the API request fails\n */\n async listPolicies(): Promise<PublicPolicySpec[]> {\n return this.fetchJson<PublicPolicySpec[]>('/api/policies');\n }\n\n /**\n * Get a specific policy by ID\n * @param policyId - The unique policy identifier\n * @returns The public policy specification, or null if not found\n * @throws {ApiError} If the API request fails (except 404)\n */\n async getPolicy(policyId: string): Promise<PublicPolicySpec | null> {\n try {\n return await this.fetchJson<PublicPolicySpec>(\n `/api/policies/${encodeURIComponent(policyId)}`\n );\n } catch (err) {\n if (err instanceof ApiError && err.status === 404) {\n return null;\n }\n throw err;\n }\n }\n\n // ==========================================================================\n // zkTLS Methods\n // ==========================================================================\n\n /**\n * List available zkTLS extractors (data sources)\n * @returns Array of available extractors\n * @throws {ApiError} If the API request fails\n */\n async listExtractors(): Promise<ZkTlsExtractor[]> {\n return this.fetchJson<ZkTlsExtractor[]>('/api/zktls/extractors');\n }\n\n /**\n * List zkTLS attestations for the authenticated organization\n * @returns Array of attestations\n * @throws {ApiError} If the API request fails\n */\n async listAttestations(): Promise<ZkTlsAttestation[]> {\n return this.fetchJson<ZkTlsAttestation[]>('/api/zktls/attestations');\n }\n\n /**\n * Get a specific attestation by ID\n * @param attestationId - The attestation UUID\n * @returns The attestation details\n * @throws {ApiError} If the API request fails\n */\n async getAttestation(attestationId: string): Promise<ZkTlsAttestation> {\n return this.fetchJson<ZkTlsAttestation>(`/api/zktls/attestations/${encodeURIComponent(attestationId)}`);\n }\n\n /**\n * Create a new zkTLS session for data attestation\n * @param extractorId - The extractor to use (e.g., \"coinbase\")\n * @param callbackUrl - URL to redirect to after authentication\n * @returns Session ID and auth URL to redirect user to\n * @throws {ApiError} If the API request fails\n */\n async createZkTlsSession(\n extractorId: string,\n callbackUrl: string\n ): Promise<{ sessionId: string; authUrl: string }> {\n return this.fetchJson<{ sessionId: string; authUrl: string }>('/api/zktls/sessions', {\n method: 'POST',\n body: JSON.stringify({ extractor: extractorId, callbackUrl }),\n });\n }\n\n /**\n * Get the status of a zkTLS session\n * @param sessionId - The session UUID\n * @returns Session status and attestation if completed\n * @throws {ApiError} If the API request fails\n */\n async getZkTlsSession(sessionId: string): Promise<ZkTlsSession> {\n return this.fetchJson<ZkTlsSession>(`/api/zktls/sessions/${encodeURIComponent(sessionId)}`);\n }\n\n /**\n * Wait for a zkTLS session to complete\n * @param sessionId - The session UUID\n * @param options - Polling options\n * @returns The completed session with attestation\n * @throws {ZkTlsSessionExpiredError} If session expires\n * @throws {ZkTlsSessionFailedError} If session fails\n * @throws {TimeoutError} If timeout is reached\n * @throws {ApiError} If the API request fails\n */\n async waitForZkTlsSession(\n sessionId: string,\n options: PollOptions & { onProgress?: (session: ZkTlsSession) => void } = {}\n ): Promise<ZkTlsSession> {\n const intervalMs = options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeoutMs) {\n const session = await this.getZkTlsSession(sessionId);\n\n if (options.onProgress) {\n options.onProgress(session);\n }\n\n if (session.status === 'completed') {\n return session;\n }\n\n if (session.status === 'failed') {\n throw new ZkTlsSessionFailedError(sessionId, session.error || 'Unknown error');\n }\n\n if (session.status === 'expired') {\n throw new ZkTlsSessionExpiredError(sessionId);\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Timeout waiting for zkTLS session ${sessionId} after ${timeoutMs}ms`,\n timeoutMs\n );\n }\n\n // ==========================================================================\n // Circuit Methods\n // ==========================================================================\n\n /**\n * List available circuits\n * @param options - Optional filters\n * @returns Array of circuits\n * @throws {ApiError} If the API request fails\n */\n async listCircuits(options: { status?: 'active' | 'all'; policyId?: string } = {}): Promise<Circuit[]> {\n const params = new URLSearchParams();\n if (options.status) params.set('status', options.status);\n if (options.policyId) params.set('policyId', options.policyId);\n\n const queryString = params.toString();\n const path = queryString ? `/api/circuits?${queryString}` : '/api/circuits';\n\n return this.fetchJson<Circuit[]>(path);\n }\n\n /**\n * Get a specific circuit by ID\n * @param circuitId - The circuit identifier\n * @returns The circuit details\n * @throws {ApiError} If the API request fails\n */\n async getCircuit(circuitId: string): Promise<Circuit> {\n return this.fetchJson<Circuit>(`/api/circuits/${encodeURIComponent(circuitId)}`);\n }\n\n /**\n * Activate a circuit (requires validation to have passed)\n * @param circuitId - The circuit identifier to activate\n * @returns The activation result\n * @throws {ApiError} If the API request fails\n */\n async activateCircuit(circuitId: string): Promise<ActivateCircuitResult> {\n return this.fetchJson<ActivateCircuitResult>(`/api/circuits/${encodeURIComponent(circuitId)}/activate`, {\n method: 'POST',\n });\n }\n\n // ==========================================================================\n // Shared Proof Methods\n // ==========================================================================\n\n /**\n * Share a completed proof with a verifier organization\n * @param request - Share proof request with proveJobId and verifierOrgId\n * @returns The created shared proof\n * @throws {ApiError} If the API request fails\n */\n async shareProof(request: ShareProofRequest): Promise<SharedProof> {\n return this.fetchJson<SharedProof>('/api/shared-proofs', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * List shared proofs (outgoing or incoming)\n * @param options - Filter by direction, pagination, and inclusion options\n * @returns Paginated list of shared proofs\n * @throws {ApiError} If the API request fails\n */\n async listSharedProofs(options: ListSharedProofsOptions = {}): Promise<{ shares: SharedProof[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.direction) params.set('direction', options.direction);\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n if (options.includeExpired) params.set('includeExpired', 'true');\n if (options.includeRevoked) params.set('includeRevoked', 'true');\n\n const queryString = params.toString();\n const path = queryString ? `/api/shared-proofs?${queryString}` : '/api/shared-proofs';\n\n return this.fetchJson<{ shares: SharedProof[]; pagination: Pagination }>(path);\n }\n\n /**\n * Get a specific shared proof by ID\n * @param sharedProofId - The shared proof ID\n * @returns The shared proof details\n * @throws {ApiError} If the API request fails\n */\n async getSharedProof(sharedProofId: string): Promise<SharedProof> {\n return this.fetchJson<SharedProof>(`/api/shared-proofs/${encodeURIComponent(sharedProofId)}`);\n }\n\n /**\n * Revoke a shared proof. Only the sharing organization can revoke.\n * @param sharedProofId - The shared proof ID to revoke\n * @returns The revocation result\n * @throws {ApiError} If the API request fails\n */\n async revokeSharedProof(sharedProofId: string): Promise<RevokeSharedProofResult> {\n return this.fetchJson<RevokeSharedProofResult>(`/api/shared-proofs/${encodeURIComponent(sharedProofId)}`, {\n method: 'DELETE',\n });\n }\n\n // ==========================================================================\n // Verification Methods\n // ==========================================================================\n\n /**\n * Verify a shared proof\n *\n * This method queues a verification job and polls until completion.\n * Verification is performed asynchronously by the prover worker.\n *\n * @param sharedProofId - The shared proof ID to verify\n * @param options - Optional polling configuration\n * @returns The verification result\n * @throws {ApiError} If the API request fails\n * @throws {TimeoutError} If verification doesn't complete within the timeout\n */\n async verifySharedProof(\n sharedProofId: string,\n options?: PollOptions\n ): Promise<VerificationResult> {\n const intervalMs = options?.intervalMs ?? 1000;\n const timeoutMs = options?.timeoutMs ?? 120000; // 2 minutes default\n\n // Queue the verification job\n const queueResult = await this.fetchJson<{\n jobId: string;\n status: VerifyJobStatus;\n creditsCharged: number;\n message?: string;\n }>(`/api/verify/shared/${encodeURIComponent(sharedProofId)}`, {\n method: 'POST',\n });\n\n const jobId = queueResult.jobId;\n const startTime = Date.now();\n\n // Poll until completion or timeout\n while (Date.now() - startTime < timeoutMs) {\n const statusResult = await this.getVerifyJobStatus(jobId);\n\n if (statusResult.status === 'completed' || statusResult.status === 'failed') {\n return {\n isValid: statusResult.isValid ?? false,\n error: statusResult.error,\n verificationTimeMs: statusResult.verificationTimeMs ?? 0,\n creditsCharged: statusResult.creditsCharged ?? queueResult.creditsCharged,\n verificationResultId: statusResult.verificationResultId ?? jobId,\n publicInputs: statusResult.publicInputs,\n };\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Verification timed out after ${timeoutMs}ms. Job ID: ${jobId}`,\n timeoutMs\n );\n }\n\n /**\n * Get the status of a verification job\n * @param jobId - The verification job ID\n * @returns The job status data\n * @throws {ApiError} If the API request fails\n */\n async getVerifyJobStatus(jobId: string): Promise<{\n status: VerifyJobStatus;\n isValid?: boolean;\n error?: string;\n verificationTimeMs?: number;\n creditsCharged: number;\n verificationResultId?: string;\n publicInputs?: string[];\n publicInputsMatch?: boolean;\n }> {\n return this.fetchJson(`/api/verify/jobs/${encodeURIComponent(jobId)}`);\n }\n\n /**\n * Verify an uploaded proof\n * @param proofBuffer - The proof binary as ArrayBuffer, Uint8Array, or Buffer\n * @param vkBuffer - The verification key binary as ArrayBuffer, Uint8Array, or Buffer\n * @returns The verification result\n * @throws {ApiError} If the API request fails\n */\n async verifyUploadedProof(\n proofBuffer: ArrayBuffer | Uint8Array,\n vkBuffer: ArrayBuffer | Uint8Array\n ): Promise<VerificationResult> {\n // Convert to Uint8Array if needed\n const proofBytes = proofBuffer instanceof Uint8Array\n ? proofBuffer\n : new Uint8Array(proofBuffer);\n const vkBytes = vkBuffer instanceof Uint8Array\n ? vkBuffer\n : new Uint8Array(vkBuffer);\n\n // Convert to base64\n const proofBase64 = typeof Buffer !== 'undefined'\n ? Buffer.from(proofBytes).toString('base64')\n : btoa(String.fromCharCode(...proofBytes));\n const vkBase64 = typeof Buffer !== 'undefined'\n ? Buffer.from(vkBytes).toString('base64')\n : btoa(String.fromCharCode(...vkBytes));\n\n return this.fetchJson<VerificationResult>('/api/verify/upload', {\n method: 'POST',\n body: JSON.stringify({\n proof: proofBase64,\n vk: vkBase64,\n }),\n });\n }\n\n /**\n * Get verification history for the authenticated organization\n * @param options - Pagination options\n * @returns Paginated list of verification results\n * @throws {ApiError} If the API request fails\n */\n async getVerificationHistory(options: GetVerificationHistoryOptions = {}): Promise<{ results: VerificationHistoryEntry[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n\n const queryString = params.toString();\n const path = queryString ? `/api/verify/history?${queryString}` : '/api/verify/history';\n\n return this.fetchJson<{ results: VerificationHistoryEntry[]; pagination: Pagination }>(path);\n }\n\n // ==========================================================================\n // Private Helpers\n // ==========================================================================\n\n private async fetch(path: string, init?: RequestInit): Promise<Response> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n ...init,\n headers: {\n ...this.headers,\n ...init?.headers,\n },\n });\n\n if (response.status === 401) {\n throw new AuthenticationError();\n }\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({}));\n throw new ApiError(\n body.error || `HTTP ${response.status}: ${response.statusText}`,\n response.status,\n body\n );\n }\n\n return response;\n }\n\n private async fetchJson<T>(path: string, init?: RequestInit): Promise<T> {\n const response = await this.fetch(path, init);\n const json = await response.json();\n\n if (json.success === false) {\n throw new ApiError(json.error || 'Request failed', response.status, json);\n }\n\n return (json.data ?? json) as T;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts"],"names":[],"mappings":";;;AAIO,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA,EACnC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,WAAA;AAAA,EACd;AACF;AAEO,IAAM,QAAA,GAAN,cAAuB,SAAA,CAAU;AAAA,EACtC,WAAA,CACE,OAAA,EACgB,MAAA,EACA,QAAA,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OACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,MAAc,SAAA,CAAa,IAAA,EAAc,IAAA,EAAgC;AACvE,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,KAAA,CAAM,MAAM,IAAI,CAAA;AAC5C,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AAEjC,IAAA,IAAI,IAAA,CAAK,YAAY,KAAA,EAAO;AAC1B,MAAA,MAAM,IAAI,QAAA,CAAS,IAAA,CAAK,SAAS,gBAAA,EAAkB,QAAA,CAAS,QAAQ,IAAI,CAAA;AAAA,IAC1E;AAEA,IAAA,OAAQ,KAAK,IAAA,IAAQ,IAAA;AAAA,EACvB;AAAA,EAEQ,MAAM,EAAA,EAA2B;AACvC,IAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AAAA,EACzD;AACF","file":"index.cjs","sourcesContent":["/**\n * Custom error classes for the Bind Protocol SDK\n */\n\nexport class BindError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'BindError';\n }\n}\n\nexport class ApiError extends BindError {\n constructor(\n message: string,\n public readonly status: number,\n public readonly response?: unknown\n ) {\n super(message, 'API_ERROR', { status, response });\n this.name = 'ApiError';\n }\n}\n\nexport class AuthenticationError extends BindError {\n constructor(message = 'Authentication failed') {\n super(message, 'AUTH_ERROR');\n this.name = 'AuthenticationError';\n }\n}\n\nexport class TimeoutError extends BindError {\n constructor(message: string, public readonly timeoutMs: number) {\n super(message, 'TIMEOUT_ERROR', { timeoutMs });\n this.name = 'TimeoutError';\n }\n}\n\nexport class InsufficientCreditsError extends BindError {\n constructor(\n public readonly required: number,\n public readonly available: number\n ) {\n super(\n `Insufficient credits: need ${required}, have ${available}`,\n 'INSUFFICIENT_CREDITS',\n { required, available }\n );\n this.name = 'InsufficientCreditsError';\n }\n}\n\n/**\n * Thrown when a zkTLS session expires before completion\n */\nexport class ZkTlsSessionExpiredError extends BindError {\n constructor(public readonly sessionId: string) {\n super(`zkTLS session expired: ${sessionId}`, 'ZKTLS_SESSION_EXPIRED', { sessionId });\n this.name = 'ZkTlsSessionExpiredError';\n }\n}\n\n/**\n * Thrown when a zkTLS session fails\n */\nexport class ZkTlsSessionFailedError extends BindError {\n constructor(\n public readonly sessionId: string,\n public readonly sessionError: string\n ) {\n super(`zkTLS session failed: ${sessionError}`, 'ZKTLS_SESSION_FAILED', { sessionId, sessionError });\n this.name = 'ZkTlsSessionFailedError';\n }\n}\n\n/**\n * Thrown when an extractor is not found or disabled\n */\nexport class ZkTlsExtractorError extends BindError {\n constructor(\n public readonly extractorId: string,\n message: string\n ) {\n super(message, 'ZKTLS_EXTRACTOR_ERROR', { extractorId });\n this.name = 'ZkTlsExtractorError';\n }\n}\n","/**\n * BindClient - Main client for interacting with the Bind Protocol API\n */\nimport type { PublicPolicySpec } from '@bind-protocol/policy-spec';\nimport {\n ApiError,\n AuthenticationError,\n InsufficientCreditsError,\n TimeoutError,\n ZkTlsSessionExpiredError,\n ZkTlsSessionFailedError,\n} from './errors';\nimport type {\n BindClientOptions,\n ProveJobInputs,\n ListProveJobsOptions,\n ProveJob,\n ProveJobSummary,\n SubmitProveJobResult,\n VerificationMode,\n ZkTlsExtractor,\n ZkTlsAttestation,\n ZkTlsSession,\n Circuit,\n ActivateCircuitResult,\n ShareProofRequest,\n SharedProof,\n ListSharedProofsOptions,\n RevokeSharedProofResult,\n VerificationResult,\n VerificationHistoryEntry,\n GetVerificationHistoryOptions,\n Pagination,\n PollOptions,\n VerifyJobStatus,\n} from './types';\n\nconst DEFAULT_BASE_URL = 'https://api.bindprotocol.com';\nconst DEFAULT_POLL_INTERVAL_MS = 2000;\nconst DEFAULT_TIMEOUT_MS = 300000; // 5 minutes\n\n/**\n * Derive a circuit ID from policy ID and version\n * This matches the server's auto-generation logic.\n * Format: {policyId}.v{version} with version dots replaced by underscores\n *\n * @example\n * deriveCircuitId(\"bind.demo.credit-score\", \"0.1.0\")\n * // Returns: \"bind.demo.credit-score.v0_1_0\"\n */\nexport function deriveCircuitId(policyId: string, version: string): string {\n const sanitizedVersion = version.replace(/\\./g, '_');\n return `${policyId}.v${sanitizedVersion}`;\n}\n\nexport class BindClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n\n constructor(options: BindClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || process.env.BIND_API_URL || DEFAULT_BASE_URL;\n this.headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n };\n }\n\n // ==========================================================================\n // Prove Job Methods\n // ==========================================================================\n\n /**\n * Submit a prove job for async processing\n * @param circuitId - The circuit identifier (e.g., \"bind.mobility.riskband.v1\")\n * @param inputs - Circuit inputs as key-value pairs (all values must be strings)\n * @param options - Optional configuration including verificationMode\n * @returns The submitted job details\n * @throws {ApiError} If the API request fails\n * @throws {InsufficientCreditsError} If there aren't enough credits\n */\n async submitProveJob(\n circuitId: string,\n inputs: ProveJobInputs,\n options?: {\n /**\n * How to verify the proof:\n * - 'zkverify': Submit to zkVerify blockchain (default if zkVerify is enabled)\n * - 'self_verify': Store in S3, client downloads and verifies locally\n */\n verificationMode?: VerificationMode;\n }\n ): Promise<SubmitProveJobResult> {\n try {\n return await this.fetchJson<SubmitProveJobResult>('/api/prove', {\n method: 'POST',\n body: JSON.stringify({\n circuitId,\n inputs,\n verificationMode: options?.verificationMode,\n }),\n });\n } catch (err) {\n if (err instanceof ApiError && err.response) {\n const body = err.response as Record<string, unknown>;\n if (body.requiredCredits !== undefined && body.availableCredits !== undefined) {\n throw new InsufficientCreditsError(\n body.requiredCredits as number,\n body.availableCredits as number\n );\n }\n }\n throw err;\n }\n }\n\n /**\n * Get the status and results of a prove job\n * @param jobId - The unique job identifier\n * @returns The job details including status and outputs\n * @throws {ApiError} If the API request fails\n */\n async getProveJob(jobId: string): Promise<ProveJob> {\n return this.fetchJson<ProveJob>(`/api/prove/${encodeURIComponent(jobId)}`);\n }\n\n /**\n * List prove jobs for the authenticated organization\n * @param options - Optional filters for status, limit, and offset\n * @returns Paginated list of prove jobs\n * @throws {ApiError} If the API request fails\n */\n async listProveJobs(options: ListProveJobsOptions = {}): Promise<{ jobs: ProveJobSummary[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.status) params.set('status', options.status);\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n\n const queryString = params.toString();\n const path = queryString ? `/api/prove?${queryString}` : '/api/prove';\n\n return this.fetchJson<{ jobs: ProveJobSummary[]; pagination: Pagination }>(path);\n }\n\n /**\n * Poll for prove job completion\n * @param jobId - The unique job identifier\n * @param options - Polling options\n * @returns The completed or failed job\n * @throws {TimeoutError} If the job doesn't complete within the timeout\n * @throws {ApiError} If the API request fails\n */\n async waitForProveJob(\n jobId: string,\n options: PollOptions & { onProgress?: (job: ProveJob) => void } = {}\n ): Promise<ProveJob> {\n const intervalMs = options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeoutMs) {\n const job = await this.getProveJob(jobId);\n\n if (options.onProgress) {\n options.onProgress(job);\n }\n\n if (job.status === 'completed' || job.status === 'failed') {\n return job;\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Timeout waiting for prove job ${jobId} after ${timeoutMs}ms`,\n timeoutMs\n );\n }\n\n // ==========================================================================\n // Policy Methods (Public, no authentication required)\n // ==========================================================================\n\n /**\n * List all available public policies\n * @returns Array of public policy specifications\n * @throws {ApiError} If the API request fails\n */\n async listPolicies(): Promise<PublicPolicySpec[]> {\n return this.fetchJson<PublicPolicySpec[]>('/api/policies');\n }\n\n /**\n * Get a specific policy by ID\n * @param policyId - The unique policy identifier\n * @returns The public policy specification, or null if not found\n * @throws {ApiError} If the API request fails (except 404)\n */\n async getPolicy(policyId: string): Promise<PublicPolicySpec | null> {\n try {\n return await this.fetchJson<PublicPolicySpec>(\n `/api/policies/${encodeURIComponent(policyId)}`\n );\n } catch (err) {\n if (err instanceof ApiError && err.status === 404) {\n return null;\n }\n throw err;\n }\n }\n\n // ==========================================================================\n // zkTLS Methods\n // ==========================================================================\n\n /**\n * List available zkTLS extractors (data sources)\n * @returns Array of available extractors\n * @throws {ApiError} If the API request fails\n */\n async listExtractors(): Promise<ZkTlsExtractor[]> {\n return this.fetchJson<ZkTlsExtractor[]>('/api/zktls/extractors');\n }\n\n /**\n * List zkTLS attestations for the authenticated organization\n * @returns Array of attestations\n * @throws {ApiError} If the API request fails\n */\n async listAttestations(): Promise<ZkTlsAttestation[]> {\n return this.fetchJson<ZkTlsAttestation[]>('/api/zktls/attestations');\n }\n\n /**\n * Get a specific attestation by ID\n * @param attestationId - The attestation UUID\n * @returns The attestation details\n * @throws {ApiError} If the API request fails\n */\n async getAttestation(attestationId: string): Promise<ZkTlsAttestation> {\n return this.fetchJson<ZkTlsAttestation>(`/api/zktls/attestations/${encodeURIComponent(attestationId)}`);\n }\n\n /**\n * Create a new zkTLS session for data attestation\n * @param extractorId - The extractor to use (e.g., \"coinbase\")\n * @param callbackUrl - URL to redirect to after authentication\n * @returns Session ID and auth URL to redirect user to\n * @throws {ApiError} If the API request fails\n */\n async createZkTlsSession(\n extractorId: string,\n callbackUrl: string\n ): Promise<{ sessionId: string; authUrl: string }> {\n return this.fetchJson<{ sessionId: string; authUrl: string }>('/api/zktls/sessions', {\n method: 'POST',\n body: JSON.stringify({ extractor: extractorId, callbackUrl }),\n });\n }\n\n /**\n * Get the status of a zkTLS session\n * @param sessionId - The session UUID\n * @returns Session status and attestation if completed\n * @throws {ApiError} If the API request fails\n */\n async getZkTlsSession(sessionId: string): Promise<ZkTlsSession> {\n return this.fetchJson<ZkTlsSession>(`/api/zktls/sessions/${encodeURIComponent(sessionId)}`);\n }\n\n /**\n * Wait for a zkTLS session to complete\n * @param sessionId - The session UUID\n * @param options - Polling options\n * @returns The completed session with attestation\n * @throws {ZkTlsSessionExpiredError} If session expires\n * @throws {ZkTlsSessionFailedError} If session fails\n * @throws {TimeoutError} If timeout is reached\n * @throws {ApiError} If the API request fails\n */\n async waitForZkTlsSession(\n sessionId: string,\n options: PollOptions & { onProgress?: (session: ZkTlsSession) => void } = {}\n ): Promise<ZkTlsSession> {\n const intervalMs = options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeoutMs) {\n const session = await this.getZkTlsSession(sessionId);\n\n if (options.onProgress) {\n options.onProgress(session);\n }\n\n if (session.status === 'completed') {\n return session;\n }\n\n if (session.status === 'failed') {\n throw new ZkTlsSessionFailedError(sessionId, session.error || 'Unknown error');\n }\n\n if (session.status === 'expired') {\n throw new ZkTlsSessionExpiredError(sessionId);\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Timeout waiting for zkTLS session ${sessionId} after ${timeoutMs}ms`,\n timeoutMs\n );\n }\n\n // ==========================================================================\n // Circuit Methods\n // ==========================================================================\n\n /**\n * List available circuits\n * @param options - Optional filters\n * @returns Array of circuits\n * @throws {ApiError} If the API request fails\n */\n async listCircuits(options: { status?: 'active' | 'all'; policyId?: string } = {}): Promise<Circuit[]> {\n const params = new URLSearchParams();\n if (options.status) params.set('status', options.status);\n if (options.policyId) params.set('policyId', options.policyId);\n\n const queryString = params.toString();\n const path = queryString ? `/api/circuits?${queryString}` : '/api/circuits';\n\n return this.fetchJson<Circuit[]>(path);\n }\n\n /**\n * Get a specific circuit by ID\n * @param circuitId - The circuit identifier\n * @returns The circuit details\n * @throws {ApiError} If the API request fails\n */\n async getCircuit(circuitId: string): Promise<Circuit> {\n return this.fetchJson<Circuit>(`/api/circuits/${encodeURIComponent(circuitId)}`);\n }\n\n /**\n * Activate a circuit (requires validation to have passed)\n * @param circuitId - The circuit identifier to activate\n * @returns The activation result\n * @throws {ApiError} If the API request fails\n */\n async activateCircuit(circuitId: string): Promise<ActivateCircuitResult> {\n return this.fetchJson<ActivateCircuitResult>(`/api/circuits/${encodeURIComponent(circuitId)}/activate`, {\n method: 'POST',\n });\n }\n\n // ==========================================================================\n // Shared Proof Methods\n // ==========================================================================\n\n /**\n * Share a completed proof with a verifier organization\n * @param request - Share proof request with proveJobId and verifierOrgId\n * @returns The created shared proof\n * @throws {ApiError} If the API request fails\n */\n async shareProof(request: ShareProofRequest): Promise<SharedProof> {\n return this.fetchJson<SharedProof>('/api/shared-proofs', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * List shared proofs (outgoing or incoming)\n * @param options - Filter by direction, pagination, and inclusion options\n * @returns Paginated list of shared proofs\n * @throws {ApiError} If the API request fails\n */\n async listSharedProofs(options: ListSharedProofsOptions = {}): Promise<{ shares: SharedProof[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.direction) params.set('direction', options.direction);\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n if (options.includeExpired) params.set('includeExpired', 'true');\n if (options.includeRevoked) params.set('includeRevoked', 'true');\n\n const queryString = params.toString();\n const path = queryString ? `/api/shared-proofs?${queryString}` : '/api/shared-proofs';\n\n return this.fetchJson<{ shares: SharedProof[]; pagination: Pagination }>(path);\n }\n\n /**\n * Get a specific shared proof by ID\n * @param sharedProofId - The shared proof ID\n * @returns The shared proof details\n * @throws {ApiError} If the API request fails\n */\n async getSharedProof(sharedProofId: string): Promise<SharedProof> {\n return this.fetchJson<SharedProof>(`/api/shared-proofs/${encodeURIComponent(sharedProofId)}`);\n }\n\n /**\n * Revoke a shared proof. Only the sharing organization can revoke.\n * @param sharedProofId - The shared proof ID to revoke\n * @returns The revocation result\n * @throws {ApiError} If the API request fails\n */\n async revokeSharedProof(sharedProofId: string): Promise<RevokeSharedProofResult> {\n return this.fetchJson<RevokeSharedProofResult>(`/api/shared-proofs/${encodeURIComponent(sharedProofId)}`, {\n method: 'DELETE',\n });\n }\n\n // ==========================================================================\n // Verification Methods\n // ==========================================================================\n\n /**\n * Verify a shared proof\n *\n * This method queues a verification job and polls until completion.\n * Verification is performed asynchronously by the prover worker.\n *\n * @param sharedProofId - The shared proof ID to verify\n * @param options - Optional polling configuration\n * @returns The verification result\n * @throws {ApiError} If the API request fails\n * @throws {TimeoutError} If verification doesn't complete within the timeout\n */\n async verifySharedProof(\n sharedProofId: string,\n options?: PollOptions\n ): Promise<VerificationResult> {\n const intervalMs = options?.intervalMs ?? 1000;\n const timeoutMs = options?.timeoutMs ?? 120000; // 2 minutes default\n\n // Queue the verification job\n const queueResult = await this.fetchJson<{\n jobId: string;\n status: VerifyJobStatus;\n creditsCharged: number;\n message?: string;\n }>(`/api/verify/shared/${encodeURIComponent(sharedProofId)}`, {\n method: 'POST',\n });\n\n const jobId = queueResult.jobId;\n const startTime = Date.now();\n\n // Poll until completion or timeout\n while (Date.now() - startTime < timeoutMs) {\n const statusResult = await this.getVerifyJobStatus(jobId);\n\n if (statusResult.status === 'completed' || statusResult.status === 'failed') {\n return {\n isValid: statusResult.isValid ?? false,\n error: statusResult.error,\n verificationTimeMs: statusResult.verificationTimeMs ?? 0,\n creditsCharged: statusResult.creditsCharged ?? queueResult.creditsCharged,\n verificationResultId: statusResult.verificationResultId ?? jobId,\n publicInputs: statusResult.publicInputs,\n };\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Verification timed out after ${timeoutMs}ms. Job ID: ${jobId}`,\n timeoutMs\n );\n }\n\n /**\n * Get the status of a verification job\n * @param jobId - The verification job ID\n * @returns The job status data\n * @throws {ApiError} If the API request fails\n */\n async getVerifyJobStatus(jobId: string): Promise<{\n status: VerifyJobStatus;\n isValid?: boolean;\n error?: string;\n verificationTimeMs?: number;\n creditsCharged: number;\n verificationResultId?: string;\n publicInputs?: string[];\n publicInputsMatch?: boolean;\n }> {\n return this.fetchJson(`/api/verify/jobs/${encodeURIComponent(jobId)}`);\n }\n\n /**\n * Verify an uploaded proof\n * @param proofBuffer - The proof binary as ArrayBuffer, Uint8Array, or Buffer\n * @param vkBuffer - The verification key binary as ArrayBuffer, Uint8Array, or Buffer\n * @returns The verification result\n * @throws {ApiError} If the API request fails\n */\n async verifyUploadedProof(\n proofBuffer: ArrayBuffer | Uint8Array,\n vkBuffer: ArrayBuffer | Uint8Array,\n options?: PollOptions\n ): Promise<VerificationResult> {\n const intervalMs = options?.intervalMs ?? 1000;\n const timeoutMs = options?.timeoutMs ?? 120000; // 2 minutes default\n\n // Convert to Uint8Array if needed\n const proofBytes = proofBuffer instanceof Uint8Array\n ? proofBuffer\n : new Uint8Array(proofBuffer);\n const vkBytes = vkBuffer instanceof Uint8Array\n ? vkBuffer\n : new Uint8Array(vkBuffer);\n\n // Convert to base64\n const proofBase64 = typeof Buffer !== 'undefined'\n ? Buffer.from(proofBytes).toString('base64')\n : btoa(String.fromCharCode(...proofBytes));\n const vkBase64 = typeof Buffer !== 'undefined'\n ? Buffer.from(vkBytes).toString('base64')\n : btoa(String.fromCharCode(...vkBytes));\n\n // Queue the verification job\n const queueResult = await this.fetchJson<{\n jobId: string;\n status: VerifyJobStatus;\n creditsCharged: number;\n message?: string;\n }>('/api/verify/upload', {\n method: 'POST',\n body: JSON.stringify({\n proof: proofBase64,\n vk: vkBase64,\n }),\n });\n\n const jobId = queueResult.jobId;\n const startTime = Date.now();\n\n // Poll until completion or timeout\n while (Date.now() - startTime < timeoutMs) {\n const statusResult = await this.getVerifyJobStatus(jobId);\n\n if (statusResult.status === 'completed' || statusResult.status === 'failed') {\n return {\n isValid: statusResult.isValid ?? false,\n error: statusResult.error,\n verificationTimeMs: statusResult.verificationTimeMs ?? 0,\n creditsCharged: statusResult.creditsCharged ?? queueResult.creditsCharged,\n verificationResultId: statusResult.verificationResultId ?? jobId,\n publicInputs: statusResult.publicInputs,\n };\n }\n\n await this.sleep(intervalMs);\n }\n\n throw new TimeoutError(\n `Verification timed out after ${timeoutMs}ms. Job ID: ${jobId}`,\n timeoutMs\n );\n }\n\n /**\n * Get verification history for the authenticated organization\n * @param options - Pagination options\n * @returns Paginated list of verification results\n * @throws {ApiError} If the API request fails\n */\n async getVerificationHistory(options: GetVerificationHistoryOptions = {}): Promise<{ results: VerificationHistoryEntry[]; pagination: Pagination }> {\n const params = new URLSearchParams();\n if (options.limit !== undefined) params.set('limit', options.limit.toString());\n if (options.offset !== undefined) params.set('offset', options.offset.toString());\n\n const queryString = params.toString();\n const path = queryString ? `/api/verify/history?${queryString}` : '/api/verify/history';\n\n return this.fetchJson<{ results: VerificationHistoryEntry[]; pagination: Pagination }>(path);\n }\n\n // ==========================================================================\n // Private Helpers\n // ==========================================================================\n\n private async fetch(path: string, init?: RequestInit): Promise<Response> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n ...init,\n headers: {\n ...this.headers,\n ...init?.headers,\n },\n });\n\n if (response.status === 401) {\n throw new AuthenticationError();\n }\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({}));\n throw new ApiError(\n body.error || `HTTP ${response.status}: ${response.statusText}`,\n response.status,\n body\n );\n }\n\n return response;\n }\n\n private async fetchJson<T>(path: string, init?: RequestInit): Promise<T> {\n const response = await this.fetch(path, init);\n const json = await response.json();\n\n if (json.success === false) {\n throw new ApiError(json.error || 'Request failed', response.status, json);\n }\n\n return (json.data ?? json) as T;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n"]}
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { B as BindClient, d as deriveCircuitId } from '../client-
|
|
2
|
-
export { A as ActivateCircuitResult, B as BindClientOptions,
|
|
1
|
+
export { B as BindClient, d as deriveCircuitId } from '../client-Dwp_OgM8.cjs';
|
|
2
|
+
export { A as ActivateCircuitResult, B as BindClientOptions, r as BindCredential, C as Circuit, p as CircuitStatus, q as CircuitValidationStatus, G as GetVerificationHistoryOptions, L as ListProveJobsOptions, i as ListSharedProofsOptions, c as Pagination, d as PollOptions, o as ProofDownloadUrls, a as ProveJob, P as ProveJobInputs, n as ProveJobOutputs, m as ProveJobStatus, b as ProveJobSummary, R as RevokeSharedProofResult, g as ShareProofRequest, h as SharedProof, S as SubmitProveJobResult, l as VerificationHistoryEntry, V as VerificationMode, j as VerificationResult, k as VerifyJobStatus, e as ZkTlsAttestation, Z as ZkTlsExtractor, f as ZkTlsSession, s as ZkTlsSessionStatus, t as ZkTlsWitness } from '../types-YCc5fSja.cjs';
|
|
3
3
|
export { DisclosureSpec, OutputClaimSpec, PolicyId, PolicyMetadata, PublicPolicySpec, SubjectSpec, ValiditySpec } from '@bind-protocol/policy-spec';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { B as BindClient, d as deriveCircuitId } from '../client-
|
|
2
|
-
export { A as ActivateCircuitResult, B as BindClientOptions,
|
|
1
|
+
export { B as BindClient, d as deriveCircuitId } from '../client-D8RRkS5D.js';
|
|
2
|
+
export { A as ActivateCircuitResult, B as BindClientOptions, r as BindCredential, C as Circuit, p as CircuitStatus, q as CircuitValidationStatus, G as GetVerificationHistoryOptions, L as ListProveJobsOptions, i as ListSharedProofsOptions, c as Pagination, d as PollOptions, o as ProofDownloadUrls, a as ProveJob, P as ProveJobInputs, n as ProveJobOutputs, m as ProveJobStatus, b as ProveJobSummary, R as RevokeSharedProofResult, g as ShareProofRequest, h as SharedProof, S as SubmitProveJobResult, l as VerificationHistoryEntry, V as VerificationMode, j as VerificationResult, k as VerifyJobStatus, e as ZkTlsAttestation, Z as ZkTlsExtractor, f as ZkTlsSession, s as ZkTlsSessionStatus, t as ZkTlsWitness } from '../types-YCc5fSja.js';
|
|
3
3
|
export { DisclosureSpec, OutputClaimSpec, PolicyId, PolicyMetadata, PublicPolicySpec, SubjectSpec, ValiditySpec } from '@bind-protocol/policy-spec';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/core/index.js
CHANGED
|
@@ -430,18 +430,40 @@ var BindClient = class {
|
|
|
430
430
|
* @returns The verification result
|
|
431
431
|
* @throws {ApiError} If the API request fails
|
|
432
432
|
*/
|
|
433
|
-
async verifyUploadedProof(proofBuffer, vkBuffer) {
|
|
433
|
+
async verifyUploadedProof(proofBuffer, vkBuffer, options) {
|
|
434
|
+
const intervalMs = options?.intervalMs ?? 1e3;
|
|
435
|
+
const timeoutMs = options?.timeoutMs ?? 12e4;
|
|
434
436
|
const proofBytes = proofBuffer instanceof Uint8Array ? proofBuffer : new Uint8Array(proofBuffer);
|
|
435
437
|
const vkBytes = vkBuffer instanceof Uint8Array ? vkBuffer : new Uint8Array(vkBuffer);
|
|
436
438
|
const proofBase64 = typeof Buffer !== "undefined" ? Buffer.from(proofBytes).toString("base64") : btoa(String.fromCharCode(...proofBytes));
|
|
437
439
|
const vkBase64 = typeof Buffer !== "undefined" ? Buffer.from(vkBytes).toString("base64") : btoa(String.fromCharCode(...vkBytes));
|
|
438
|
-
|
|
440
|
+
const queueResult = await this.fetchJson("/api/verify/upload", {
|
|
439
441
|
method: "POST",
|
|
440
442
|
body: JSON.stringify({
|
|
441
443
|
proof: proofBase64,
|
|
442
444
|
vk: vkBase64
|
|
443
445
|
})
|
|
444
446
|
});
|
|
447
|
+
const jobId = queueResult.jobId;
|
|
448
|
+
const startTime = Date.now();
|
|
449
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
450
|
+
const statusResult = await this.getVerifyJobStatus(jobId);
|
|
451
|
+
if (statusResult.status === "completed" || statusResult.status === "failed") {
|
|
452
|
+
return {
|
|
453
|
+
isValid: statusResult.isValid ?? false,
|
|
454
|
+
error: statusResult.error,
|
|
455
|
+
verificationTimeMs: statusResult.verificationTimeMs ?? 0,
|
|
456
|
+
creditsCharged: statusResult.creditsCharged ?? queueResult.creditsCharged,
|
|
457
|
+
verificationResultId: statusResult.verificationResultId ?? jobId,
|
|
458
|
+
publicInputs: statusResult.publicInputs
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
await this.sleep(intervalMs);
|
|
462
|
+
}
|
|
463
|
+
throw new TimeoutError(
|
|
464
|
+
`Verification timed out after ${timeoutMs}ms. Job ID: ${jobId}`,
|
|
465
|
+
timeoutMs
|
|
466
|
+
);
|
|
445
467
|
}
|
|
446
468
|
/**
|
|
447
469
|
* Get verification history for the authenticated organization
|