Repository navigation
Expand file tree
/
Copy pathtypes.d.ts
More file actions
1793 lines (1618 loc) · 56.5 KB
/
Copy pathtypes.d.ts
File metadata and controls
1793 lines (1618 loc) · 56.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module '@proofable/sdk' {
export interface Eip1193Provider {
request(args: { method: string; params?: unknown[] | Record<string, unknown> }): Promise<unknown>;
}
export type WalletLike = Eip1193Provider | { address?: string } | { getAddress?: () => Promise<string> } | { signMessage?: (message: string) => Promise<string> };
export class ProofableClient {
constructor(config?: ProofableClientConfig);
verifyFromApp(params: VerifyFromAppParams): Promise<VerificationResult>;
verify(params: VerifyParams): Promise<VerificationResult>;
getProof(qHash: string): Promise<StatusResult>;
getPrivateProof(qHash: string, wallet?: WalletLike | GatePrivateAuth): Promise<StatusResult>;
isHealthy(): Promise<boolean>;
getVerifiers(): Promise<string[]>;
getVerifierCatalog(): Promise<VerifierCatalog>;
createWalletLinkData(params: {
primaryWalletAddress: string;
secondaryWalletAddress: string;
wallet?: WalletLike;
chain?: string;
signedTimestamp?: number;
relationshipType?: 'primary' | 'personal' | 'org' | 'affiliate' | 'agent' | 'linked';
label?: string;
}): Promise<WalletLinkData>;
pollProofStatus(qHash: string, options?: PollOptions): Promise<StatusResult>;
revokeOwnProof(qHash: string, wallet?: { address: string }): Promise<boolean>;
getProofsByWallet(walletAddress: string, options?: GetProofsOptions): Promise<ProofsResult>;
getPrivateProofsByWallet(walletAddress: string, options?: GetProofsOptions, wallet?: WalletLike): Promise<ProofsResult>;
gateCheck(params: GateCheckApiParams): Promise<GateCheckApiResponse>;
/**
* Talk to a hosted agent: one chat turn run as the agent, under the delegation you signed for it.
* With `agentWallet`, someone else's public agent runs in your own profile, with nothing of its owner's in the conversation.
*/
agentChat(params: AgentChatParams): Promise<AgentChatFinal>;
/** Who this client is signed in as; `authenticated` is false with no credential. */
me(): Promise<ProofableMe>;
/**
* Let your app sponsor usage: your users' checks and their chats with your agents are billed to
* your organization within a daily credit cap. One signed record on your account.
*/
sponsorApp(params: SponsorAppParams): Promise<SponsorAppResult>;
/** Your credits and spend: the balance, recent events, and spend by line and by UTC day. */
getUsage(options?: UsageOptions): Promise<UsageResult | null>;
createGatePrivateAuth(params: {
address: string;
wallet?: WalletLike;
chain?: string;
signatureMethod?: string;
}): Promise<GatePrivateAuth>;
checkGate(params: CheckGateParams): Promise<CheckGateResult>;
/** Public gate snapshot (requirements, charge, schedule , never the secret reward value). */
getGate(gateId: string): Promise<PublicGateSnapshot>;
/** Post-verify reward delivery for hosted gate checkout (session or wallet-bound). */
fulfillGate(params: FulfillGateParams): Promise<GateFulfillmentResponse>;
}
export type PrivacyLevel = 'public' | 'private';
export interface ProofableClientConfig {
apiUrl?: string;
/**
* The credential sent as a Bearer token: a profile access key on a server, or a person's
* access token from `ProofableSignIn`. Not required for VerifyGate or gateCheck.
*/
apiKey?: string;
/** Public app attribution id (non-secret). */
appId?: string;
/** Advanced server/app sponsor wallet. Published gate checkout resolves billing from gateId. */
billingWallet?: string;
sponsorOrgWallet?: string;
orgWallet?: string;
/** Site origin for sponsor grants and server verifyFromApp (sets Origin on Node). */
appOrigin?: string;
/**
* Optional. Not required for published gate checkout.
* Server auth for unsigned verify uses appId + Origin (appOrigin), not this field.
*/
appLinkQHash?: string;
paymentSignature?: string;
extraHeaders?: Record<string, string>;
timeout?: number;
/** Canonical EVM identity chain for DID/signing defaults (Base mainnet 8453). NOT the anchoring rail. */
identityChainId?: number;
enableLogging?: boolean;
}
export interface FetchSponsorGrantParams {
apiUrl?: string;
appId: string;
orgWallet: string;
verifierIds?: string[];
targetChains?: number[];
origin?: string;
/** What the app sponsors: its users' checks (the default) or their chats with the owner's agents. */
scope?: 'sponsored-verification' | 'agent-chat';
expiresInSeconds?: number;
}
export interface FetchSponsorGrantResult {
sponsorGrant: string;
exp?: number;
orgWallet: string;
appId: string;
maxCredits?: number;
}
export function fetchSponsorGrant(params: FetchSponsorGrantParams): Promise<FetchSponsorGrantResult>;
export interface SponsorAppParams {
/** Your app's id: letters, digits, ".", "_", ":" or "-". */
appId: string;
/** The https origin your app calls from. */
origin: string;
/** The most credits the app may spend in a UTC day. */
creditsPerDay: number;
/** What the app sponsors; both by default. */
scopes?: Array<'sponsored-verification' | 'agent-chat'>;
}
export interface SponsorAppResult {
qHash: string;
appId: string;
origin: string;
creditsPerDay: number;
scopes: string[];
}
/** The signed-in profile, as `client.me()` returns it. */
export interface ProofableMe {
authenticated: boolean;
address?: string;
primaryAccount?: string;
handle?: string;
profileSummary?: Record<string, unknown>;
[key: string]: unknown;
}
export interface ProofableSignInOptions {
/** Where Proofable sends the person back: an https URL on your site. */
redirectUri: string;
/** The client id `register()` gave you. Omit it and `start()` registers once per instance. */
clientId?: string;
scope?: string;
issuer?: string;
resource?: string;
fetchImpl?: typeof fetch;
}
export interface ProofableSignInStart {
/** Send the person here. */
url: string;
state: string;
/** Keep it until the person is back, then pass it to `finish()`. */
verifier: string;
clientId: string;
}
export interface ProofableTokens {
accessToken: string;
refreshToken: string | null;
tokenType: string;
expiresIn: number | null;
expiresAt: number | null;
scope: string;
}
/**
* Sign your app's users in with Proofable: the same sign-in every MCP host uses, for your
* own web app. Then act as the person with `new ProofableClient({ apiKey: tokens.accessToken })`.
*/
export class ProofableSignIn {
constructor(options: ProofableSignInOptions);
redirectUri: string;
clientId: string | null;
/** Register your callback once and keep the client id. */
register(): Promise<string>;
/** Where to send the person, with the values to keep until they are back. */
start(options?: { state?: string }): Promise<ProofableSignInStart>;
/** Exchange the callback's code for the person's tokens. */
finish(input: { code: string; verifier: string; state?: string; expectedState?: string; iss?: string }): Promise<ProofableTokens>;
/** New tokens from a refresh token; the old one is spent. */
refresh(refreshToken: string): Promise<ProofableTokens>;
}
export const PROOFABLE_SIGN_IN_ISSUER: string;
export const PROOFABLE_SIGN_IN_RESOURCE: string;
export const PROOFABLE_SIGN_IN_SCOPE: string;
export interface VerificationOptions {
privacyLevel?: PrivacyLevel;
enableIpfs?: boolean;
storeOriginalContent?: boolean;
targetChains?: number[];
/** Anchor the receipt on the hub registry chain. Defaults to false (receipts persist offchain). */
publishToHub?: boolean;
publicDisplay?: boolean;
meta?: Record<string, any>;
verifierOptions?: Record<string, any>;
}
export interface VerifierCatalogMetadataEntry {
category?: string;
description?: string;
accessLevel?: 'public' | 'pro' | 'custom' | 'admin' | string;
flowType?: 'instant' | 'interactive' | 'external_lookup' | string;
expiryType?: 'permanent' | 'point_in_time' | 'expiring' | string;
allowsDelegatedSubject?: boolean;
compatibleWith?: string[];
conflictsWith?: string[];
supportsDirectApi?: boolean;
supportsHostedVerify?: boolean;
dataSchema?: Record<string, any>;
requiredFields?: string[];
optionalFields?: string[];
}
export interface VerifierCatalog {
data: string[];
metadata: Record<string, VerifierCatalogMetadataEntry>;
meta?: Record<string, any>;
}
export interface VerifyFromAppParams {
user: {
walletAddress?: string;
address?: string;
identity?: string;
};
verifier?: VerifierId;
content?: string | Record<string, any>;
data?: VerificationData;
options?: VerifyOptions;
}
export interface VerifyParams {
verifier?: VerifierId;
content?: string;
data?: VerificationData;
options?: VerifyOptions;
verifierIds?: VerifierId[];
walletAddress?: string;
signature?: string;
signedTimestamp?: number;
chainId?: number;
chain?: string;
signatureMethod?: string;
delegationQHash?: string;
wallet?: WalletLike;
}
export interface ProofResult {
qHash: string;
status: string;
walletAddress?: string;
proofUrl?: string;
crossChain?: boolean;
}
export interface VerificationResult {
qHash: string;
status: VerificationStatus;
success: boolean;
data?: VerificationData;
}
export interface StatusResult {
qHash?: string;
proofUrl?: string | null;
success: boolean;
status: VerificationStatus;
data: {
qHash?: string;
status: string;
walletAddress: string;
verifierIds?: string[];
targetChains?: number[];
verifiedVerifiers?: Array<{
verifierId: string;
verified: boolean;
data: any;
status: string;
zkInfo?: {
zkStatus: string;
};
}>;
crosschain?: {
status: string;
hubTxHash?: string;
initiated?: number;
completed?: number;
totalChains?: number;
finalized?: number;
relayResults?: Record<string, {
success: boolean;
transactionHash?: string;
completedAt?: number;
chainId: number;
status: string;
gasUsed?: string;
blockNumber?: string;
voucherId?: string;
}>;
createdVouchers?: string[];
};
hubTransaction?: {
txHash: string;
timestamp: number;
chainId: number;
status: string;
};
ipfs?: {
cid: string;
gateway: string;
createdAt: number;
size: number;
};
options?: {
enableIpfs?: boolean;
disclosePortableProof?: boolean;
publicDisplay?: boolean;
storeOriginalContent?: boolean;
verifierOptions?: object;
privacyLevel?: 'private' | 'public';
meta?: object;
};
meta?: {
privacyLevel: 'private' | 'public';
publiclyAccessible: boolean;
};
createdAt?: number;
completedAt?: number;
lastUpdated?: number;
portableProof?: Record<string, unknown>;
};
}
export interface PollOptions {
interval?: number;
timeout?: number;
onProgress?: (status: any) => void;
}
export interface ValidationResult {
valid: boolean;
error?: string;
missing?: string[];
warnings?: string[];
}
export type CoreVerifierId =
| 'ownership-basic'
| 'ownership-social' // Hosted OAuth social ownership
| 'ownership-pseudonym' // Pseudonymous identity verification
| 'ownership-org-oauth' // Hosted OAuth organization ownership
| 'nft-ownership'
| 'token-holding'
| 'ownership-dns-txt'
| 'wallet-link'
| 'contract-ownership'
| 'wallet-risk' // Wallet risk assessment
| 'proof-of-human' // Hosted ZK personhood verification
| 'agent-identity'
| 'agent-delegation'
| 'ai-content-moderation'
| string; // Allow custom verifier IDs
export type VerifierId = CoreVerifierId;
export type VerificationStatus =
| 'processing_verifiers'
| 'processing_zk_proofs'
| 'verified'
| 'verified_no_verifiers'
| 'verified_crosschain_initiated'
| 'verified_crosschain_propagating'
| 'verified_crosschain_propagated'
| 'partially_verified'
| 'verified_propagation_failed'
| 'rejected'
| 'rejected_verifier_failure'
| 'rejected_zk_initiation_failure'
| 'error_processing_exception'
| 'error_initialization'
| 'error_storage_unavailable'
| 'error_storage_query'
| 'not_found';
export function constructVerificationMessage(params: {
walletAddress: string;
signedTimestamp: number;
data: any;
verifierIds: VerifierId[];
chainId?: number;
chain?: string;
}): string;
export const PORTABLE_PROOF_SIGNER_HEADER: string;
export function canonicalizePortableProofJson(value: unknown): string;
export function computePortableProofQHash(envelope: Record<string, any>): string;
export function verifyPortableProofEnvelope(
envelope: Record<string, any>,
options?: { provider?: unknown; now?: number; maxAgeMs?: number; maxFutureMs?: number }
): Promise<{
valid: boolean;
qHashValid: boolean;
didValid?: boolean;
signatureValid: boolean;
requiresChainState?: boolean;
computedQHash?: string;
signer?: string | null;
fresh?: boolean;
ageMs?: number;
errors: string[];
}>;
export function validateWalletAddress(address: string): boolean;
export function validateUniversalAddress(address: string, chain?: string): boolean;
export function validateTimestamp(timestamp: number, maxAgeMs?: number): boolean;
export function validateQHash(qHash: string): boolean;
export function normalizeAddress(address: string): string;
export function resolveDID(
params: {
walletAddress?: string;
chainId?: number;
chain?: string;
},
options?: {
endpoint?: string;
apiUrl?: string;
credentials?: 'omit' | 'same-origin' | 'include';
headers?: Record<string, string>;
}
): Promise<{
did: string;
data: unknown;
raw: unknown;
}>;
export function standardizeVerificationRequest(
params: Record<string, any>,
options?: {
endpoint?: string;
apiUrl?: string;
credentials?: 'omit' | 'same-origin' | 'include';
headers?: Record<string, string>;
}
): Promise<any>;
export function resolveZkPassportConfig(overrides?: Record<string, any>): {
provider: string;
scope: string;
checkSanctions: boolean;
requireFaceMatch: boolean;
faceMatchMode: string;
[key: string]: any;
};
export function toHexUtf8(message: string): string;
export function signMessage(params: {
provider?: any;
message: string;
walletAddress?: string;
chain?: string;
}): Promise<string>;
export function validateVerifierPayload(verifierId: string, data: any): ValidationResult;
export function buildVerificationRequest(params: {
verifierIds: string[];
data: any;
walletAddress: string;
chainId?: number;
chain?: string;
options?: any;
signedTimestamp?: number;
}): { message: string; request: { verifierIds: string[]; data: any; walletAddress: string; signedTimestamp: number; chainId?: number; chain?: string; options?: any } };
export function isTerminalStatus(status: VerificationStatus): boolean;
export function isSuccessStatus(status: VerificationStatus): boolean;
export function isFailureStatus(status: VerificationStatus): boolean;
export function formatVerificationStatus(status: VerificationStatus): {
label: string;
description: string;
color: string;
category: string;
};
export class StatusPoller {
constructor(client: ProofableClient, qHash: string, options?: { interval?: number; maxAttempts?: number; exponentialBackoff?: boolean; maxInterval?: number });
poll(): Promise<StatusResult>;
}
export function formatTimestamp(timestamp: number): string;
export function isSupportedChain(chainId: number): boolean;
export function delay(ms: number): Promise<void>;
export function withRetry<T>(fn: () => Promise<T>, options?: {
maxAttempts?: number;
baseDelay?: number;
maxDelay?: number;
backoffFactor?: number;
}): Promise<T>;
export function toAgentDelegationMaxSpend(
humanAmount: string | number,
decimals: number
): string;
export const DEFAULT_HOSTED_VERIFY_URL: string;
export function getHostedCheckoutUrl(opts?: {
gateId?: string;
returnUrl?: string;
verifiers?: string[];
preset?: string;
mode?: string;
intent?: string;
origin?: string;
oauthProvider?: string;
/** Advanced sponsor-grant attribution. Omit when gateId is present. */
appId?: string;
/** Advanced sponsor wallet. Omit when gateId is present. */
billingWallet?: string;
baseUrl?: string;
}): string;
export function getHostedAgentCreateUrl(opts: {
agentId: string;
agentWallet: string;
controllerWallet?: string;
/** Existing agent-identity receipt. When set, Hosted Verify requests delegation only. */
identityQHash?: string;
returnUrl?: string;
agentLabel?: string;
agentType?: 'ai' | 'bot' | 'service' | 'automation' | 'agent' | string;
expiresAt?: number;
maxSpend?: string;
allowedPaymentTypes?: string[];
allowedActions?: string[];
deniedActions?: string[];
runtimePolicy?: {
allowedProviders?: string[];
allowedModelClasses?: string[];
requiresHumanApproval?: boolean;
secretsExposedToReceipt?: boolean;
};
approvalPolicy?: {
humanApprovalRequiredForNewClaims?: boolean;
preApprovedContentOnly?: boolean;
};
baseUrl?: string;
}): string;
export type ProofablePublicGateCharge = {
enabled: boolean;
scheme: string;
label: string;
amountUsd: number;
/** Payment methods offered to visitors: 'usdc' and/or 'stripe' (card). */
methods: Array<'usdc' | 'stripe' | string>;
/** True when the owner can receive card payouts (Stripe Connect ready). */
cardPayoutReady?: boolean;
appliesTo: string;
/** 'verifyThenCharge' (default) or 'chargeThenVerify'. */
executionOrder?: string;
recipient?: string;
};
/** One gate requirement row on the wire (protocol shape used by published gates). */
export interface GateMatchRowWire {
path: string;
op?: 'eq' | 'gte' | 'lte' | string;
value: string;
}
export interface GateRequirementWire {
verifierId: string;
match?: GateMatchRowWire[];
optional?: boolean;
minCount?: number;
maxAgeMs?: number;
}
/** Public snapshot returned by GET /api/v1/profile/gates/{gateId} , never includes the secret reward value. */
export interface PublicGateSnapshot {
schemaVersion: number;
gateId: string;
name?: string;
status?: string;
version?: number;
requirements: GateRequirementWire[];
policy?: {
visibility?: string;
gateFreshnessHours?: number;
};
monetization?: {
charge?: ProofablePublicGateCharge | null;
};
checkout?: {
mode?: string;
flowPlan?: {
batches?: number;
hasInteractive?: boolean;
hasBackground?: boolean;
};
description?: string;
successReturnUrl?: string;
};
marketplaceTemplate?: {
templateId: string;
label?: string;
tags?: string[];
};
schedule?: {
startsAt?: string;
endsAt?: string;
};
artifact?: {
type: string;
label?: string;
};
/** What the buyer fills in for an AI service listing. Send the values as `serviceParameters` on fulfill. */
serviceInputs?: Array<{ name: string; label: string; required: boolean }>;
}
export interface FulfillGateParams {
gateId: string;
/** Verified proof id for this checkout. */
qHash: string;
/** Required when no session cookie binds the wallet. */
walletAddress?: string;
/** Stripe checkout session id for paid gates (card rail). */
paymentCheckoutSessionId?: string;
/** USDC payment transaction hash for paid gates (wallet rail). */
paymentTxHash?: string;
/** Buyer-approved listing access. Required when the gate snapshot includes requestedAccess. */
accessGrant?: {
resources?: Array<{ kind: string; id: string }>;
connectionQHash?: string;
connectedAccountId?: string;
toolkitSlug?: string;
};
/** The buyer's values for an AI service listing's `serviceInputs`, each up to 512 characters. */
serviceParameters?: Array<{ name: string; value: string }>;
}
export interface GateFulfillmentResult {
delivery: 'access_granted' | 'redirect' | 'download' | 'reveal' | string;
type?: string;
value?: string;
label?: string;
message?: string;
}
export interface GateFulfillmentResponse {
success: boolean;
data?: {
gateId: string;
qHash: string;
fulfillment: GateFulfillmentResult;
successReturnUrl?: string;
/** The run an AI service order started. Its answer appears on the receipt (`meta.marketplace.serviceJob.result`) when it finishes. */
serviceJob?: {
jobId: string;
qHash?: string | null;
status?: string | null;
proofUrl?: string | null;
};
};
error?: any;
}
export const PROOFABLE_CONSTANTS: {
IDENTITY_CHAIN_ID: number;
/** Optional on-chain anchoring rail (Base Sepolia today; no mainnet hub). */
HUB_CHAIN_ID: number;
TESTNET_CHAINS: number[];
API_BASE_URL: string;
API_VERSION: string;
SIGNATURE_MAX_AGE_MS: number;
REQUEST_TIMEOUT_MS: number;
DEFAULT_VERIFIERS: VerifierId[];
};
export class SDKError extends Error {
code: string;
details: any;
}
export class ApiError extends SDKError {
statusCode: number;
response: any;
}
export class ValidationError extends SDKError {
field?: string;
value?: any;
}
export class NetworkError extends SDKError {
originalError?: Error;
}
export class ConfigurationError extends SDKError {
configKey?: string;
}
export class VerificationError extends SDKError {
verifierId?: string;
}
export class AuthenticationError extends SDKError {}
export interface GetProofsOptions {
limit?: number;
offset?: number;
cursor?: string;
chain?: string;
signatureMethod?: string;
q?: string;
qHash?: string;
verifierId?: string;
verifierIds?: string;
tags?: string;
tagPrefix?: string;
tagContains?: string;
tagPrefixesAll?: string;
status?: string;
appId?: string;
chainCoverage?: 'hub-only' | 'cross-chain';
privacyLevel?: 'public' | 'private';
includeHistory?: boolean;
includeFacets?: string;
visibility?: 'public';
isPublicRead?: boolean;
}
export interface ProofsResult {
success: boolean;
proofs: any[];
totalCount: number | null;
hasMore: boolean;
nextOffset?: number | null;
/** Keyset continuation when the API returns cursor paging (preferred over deep offsets). */
nextCursor?: string | null;
facets?: {
tags?: string[];
truncated?: boolean;
} | null;
}
export interface GateRequirement {
verifierId: CoreVerifierId;
maxAgeMs?: number;
optional?: boolean;
minCount?: number;
/**
* Either the protocol wire shape (array of { path, op, value } rows , what
* published gates store) or a flat { path: value } map for client-side checks.
*/
match?: GateMatchRowWire[] | Record<string, any>;
}
export interface CheckGateParams {
walletAddress: string;
requirements: GateRequirement[];
proofs?: any[];
}
export interface CheckGateResult {
satisfied: boolean;
missing: GateRequirement[];
existing: Record<string, any>;
allProofs: any[];
}
export interface AgentChatMessage {
role: 'user' | 'assistant';
content: string;
}
export interface AgentChatParams {
/** The conversation; the last message is from the user. */
messages: AgentChatMessage[];
/** Run as this agent; omit to run as yourself. */
agentId?: string;
/**
* The agent's account: when two of your agents share an agentId, or to talk to someone
* else's public agent, which then runs in your own profile, with nothing of its owner's in the conversation.
*/
agentWallet?: string;
/** Context from your app, passed to the agent as data. */
systemPrompt?: string;
/** 'default' (the default) or 'advanced'; with `provider`, that provider's model id. */
model?: string;
/** Run on your own model key instead of hosted inference. */
provider?: string;
providerSecretProofQHash?: string;
responseMode?: 'agent' | 'plan';
turnId?: string;
/** Every streamed event as it arrives: turn.start, answer.delta, tool.start, tool.result, final, … */
onEvent?: (type: string, data: Record<string, unknown>) => void;
signal?: AbortSignal;
}
/** A record the agent read; anyone can open it at proofable.me/proof/<qHash>. */
export interface AgentChatCitation {
qHash: string;
title: string | null;
facet: string | null;
visibility: 'public' | 'private' | null;
}
/** The turn's `final` event. */
export interface AgentChatFinal {
turnId: string;
outcome: 'succeeded' | 'failed' | 'blocked' | 'canceled' | 'incomplete';
answer: string;
citations: AgentChatCitation[];
agent?: { agentId: string; agentWallet: string; identityQHash: string | null; delegationQHash: string | null };
credits?: { spent: number };
usage: Record<string, number> | null;
model: string | null;
provider: string | null;
toolActivity: Array<Record<string, unknown>> | null;
error?: { code: string; message: string; retryable: boolean };
[key: string]: unknown;
}
export interface UsageOptions {
/** First UTC day of the period, YYYY-MM-DD. */
from?: string;
/** Last UTC day of the period, YYYY-MM-DD. */
to?: string;
appId?: string;
limit?: number;
}
export interface UsageResult {
orgWallet: string;
profileId: string | null;
credits: { remaining?: number; allowance?: number; [key: string]: unknown } | null;
usage: {
limit: number;
from?: string;
to?: string;
events: Array<Record<string, unknown>>;
summary: {
count: number;
requiredCredits: number;
debitedCredits: number;
byMode: Record<string, number>;
byStatus: Record<string, number>;
debitedByDay: Record<string, number>;
};
};
}
export interface GateCheckApiParams {
address?: string;
/** Subject account. Bare address, CAIP-10, or did:pkh. New integrations use `{ accountId }`. */
subject?: { accountId: string; chain?: string } | { address: string; chain?: string } | string;
/** Inline Gate Policy. Mutually exclusive with `gateId`. Uses POST /proofs/check. */
gate?: GateRequirement[];
/** Optional published listing handle retained for checkout compatibility. */
gateId?: string;
verifierIds?: string[] | string;
requireAll?: boolean;
minCount?: number;
sinceDays?: number;
since?: number;
limit?: number;
includePrivate?: boolean;
includeQHashes?: boolean;
wallet?: WalletLike;
chain?: string;
signatureMethod?: string;
privateAuth?: GatePrivateAuth;
referenceType?: string;
referenceId?: string;
tag?: string;
tags?: string[] | string;
contentType?: string;
content?: string;
contentHash?: string;
contractAddress?: string;
tokenId?: string;
chainId?: number;
domain?: string;
minBalance?: string;
provider?: string;
handle?: string;
namespace?: string;
ownerAddress?: string;
riskLevel?: string;
sanctioned?: boolean;
poisoned?: boolean;
primaryWalletAddress?: string;
secondaryWalletAddress?: string;
verificationMethod?: string;
/** Personhood ID for proof-of-human sybil resistance matching (0x-prefixed 64-hex-char SHA-256 digest) */
neusPersonhoodId?: string;
}
export interface GatePrivateAuth {
walletAddress: string;
signature: string;
signedTimestamp: number;
chain?: string;
signatureMethod?: string;
}
export interface GateCheckApiResponse {
success: boolean;
satisfied: boolean;
policyHash: string | null;
gateId: string | null;
subject: string;
requirements: GateRequirement[] | null;
missing: string[];
proofs: string[];
existing: Record<string, any>;
expiresAt: string | number | null;
data?: {
eligible: boolean;
matchedCount?: number;
matchedQHashes?: string[];
matchedTags?: string[];
projections?: Array<Record<string, any>> | null;
criteria?: Record<string, any>;
/**
* Per-requirement evaluation returned for inline policies and persisted listings.
* `allRequiredSatisfied === true` is the ONLY readiness signal for gate
* checkout; `eligible`/`matchedCount` alone are not sufficient.
*/
gate?: {
gateId: string | null;
policyHash?: string;
allRequiredSatisfied: boolean;
satisfiedVerifierIds: string[];
missingVerifierIds: string[];
/** verifierId to one or more qHashes for checkout reuse (requires includeQHashes=true). */
reusedVerifierProofs?: Record<string, string | string[]>;
/** Per-requirement rows (requires includeQHashes=true). */
rows?: Array<{
verifierId: string;
satisfied: boolean;
qHashes?: string[];
}>;
};
};
error?: any;
}
export interface ApiResponse<T = any> {