@voidly/session 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1348 @@
1
+ // @voidly/session — GENERATED by scripts/build-types.mjs. Do not edit.
2
+ //
3
+ // The transitive closure of what src/index.ts exports, flattened into one
4
+ // module. Server declarations are absent because nothing here reaches them.
5
+
6
+ export declare function acceptHire(input: {
7
+ grantHash: string;
8
+ providerDid: string;
9
+ sign: Signer;
10
+ nowMs: number;
11
+ ttlMs?: number;
12
+ entropy?: SessionEntropy;
13
+ }): Promise<{
14
+ ok: true;
15
+ acceptance: TaskAcceptanceEnvelope;
16
+ signature_base64: string;
17
+ } | {
18
+ ok: false;
19
+ reason: string;
20
+ }>;
21
+ type AccountSpellingRefuseDetail = "grant_payer_account_not_canonical" | "grant_payee_account_not_canonical";
22
+ export type AssembleAuthorizationRefusal = HireRefuseDetail | SignRefusal | "grant_hash_mismatch" | "authorization_asset_not_frozen_usdc" | "valid_after_not_safe_integer" | "authorization_entry_point_mismatch";
23
+ export declare function assembleSignedReceiveAuthorization(input: AssembleSignedTransferAuthorizationInput): Promise<AssembleSignedReceiveAuthorizationResult>;
24
+ export type AssembleSignedReceiveAuthorizationResult = {
25
+ ok: true;
26
+ signed: SignedReceiveAuthorization;
27
+ grantHash: string;
28
+ } | {
29
+ ok: false;
30
+ reason: AssembleAuthorizationRefusal;
31
+ detail: string;
32
+ };
33
+ export declare function assembleSignedTransferAuthorization(input: AssembleSignedTransferAuthorizationInput): Promise<AssembleSignedTransferAuthorizationResult>;
34
+ export interface AssembleSignedTransferAuthorizationInput {
35
+ readonly authorization: unknown;
36
+ readonly grant: TaskGrantEnvelope;
37
+ readonly nowMs: number;
38
+ readonly expectedGrantHash?: string;
39
+ }
40
+ export type AssembleSignedTransferAuthorizationResult = {
41
+ ok: true;
42
+ signed: SignedTransferAuthorization;
43
+ grantHash: string;
44
+ } | {
45
+ ok: false;
46
+ reason: AssembleAuthorizationRefusal;
47
+ detail: string;
48
+ };
49
+ export declare function authenticateHireAcceptance(input: {
50
+ readonly raw: unknown;
51
+ readonly grant: TaskGrantEnvelope;
52
+ readonly grantHash: string;
53
+ readonly nowMs: number;
54
+ }): Promise<AuthenticateHireAcceptanceResult>;
55
+ export type AuthenticateHireAcceptanceResult = {
56
+ ok: true;
57
+ accepted: SessionHireAccepted;
58
+ } | {
59
+ ok: false;
60
+ reason: HireRefuseDetail | "grant_hash_mismatch";
61
+ };
62
+ export declare const AUTHORIZATION_ENTRY_POINTS: readonly AuthorizationEntryPoint[];
63
+ export declare const AUTHORIZATION_KEYS: readonly [
64
+ "scheme",
65
+ "entry_point",
66
+ "chain",
67
+ "asset",
68
+ "from",
69
+ "to",
70
+ "value",
71
+ "valid_after",
72
+ "valid_before",
73
+ "nonce",
74
+ "signature"
75
+ ];
76
+ export declare const AUTHORIZATION_USED_TOPIC0 = "0x98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a5";
77
+ export declare function authorizationEntryPoint(authorization: {
78
+ readonly entry_point?: AuthorizationEntryPoint;
79
+ }): AuthorizationEntryPoint | "unstated";
80
+ export type AuthorizationEntryPoint = "transfer_with_authorization" | "receive_with_authorization";
81
+ export declare function authorizationValidBeforeFor(grant: TaskGrantEnvelope): string | null;
82
+ export declare function bindAuthorizationToGrant(authorization: PaymentAuthorization, grant: TaskGrantEnvelope, grantHash: string): Promise<HireRefuseDetail | null>;
83
+ export type BroadcastTx = (request: TransactionRequest) => Promise<string> | string;
84
+ export interface BuildAuthorizationInput {
85
+ chain: string;
86
+ from: string;
87
+ to: string;
88
+ value: string;
89
+ validAfter: number;
90
+ validBefore: number;
91
+ grantHash: string;
92
+ }
93
+ export type BuildCalldataResult = {
94
+ ok: true;
95
+ request: TransactionRequest;
96
+ } | {
97
+ ok: false;
98
+ reason: CalldataRefusal;
99
+ detail: string;
100
+ };
101
+ export declare function buildHire(input: {
102
+ hirer: {
103
+ did: string;
104
+ signingPublicKeyBase64: string;
105
+ sign: Signer;
106
+ };
107
+ provider: VerifiedProvider;
108
+ service: {
109
+ ref: string;
110
+ };
111
+ task: {
112
+ brief: string;
113
+ };
114
+ price: {
115
+ chain: string;
116
+ asset: string;
117
+ payerAccount: string;
118
+ payeeAccount: string;
119
+ minAmount: string;
120
+ maxAmount: string;
121
+ };
122
+ ttl: {
123
+ offerMs: number;
124
+ grantMs: number;
125
+ };
126
+ nowMs: number;
127
+ entropy?: SessionEntropy;
128
+ }): Promise<BuildHireResult>;
129
+ export declare function buildHireMessage(wire: HireWire, authorization: PaymentAuthorization, sign: Signer): Promise<Validated<SessionHireMessage, HireRefuseDetail>>;
130
+ export type BuildHireResult = {
131
+ ok: true;
132
+ wire: HireWire;
133
+ keep: HireKeep;
134
+ } | {
135
+ ok: false;
136
+ reason: RedeemRejectReason | AccountSpellingRefuseDetail | ProviderTermsRejectReason;
137
+ };
138
+ export type BuildReceiveAuthorizationResult = {
139
+ ok: true;
140
+ typedData: ReceiveAuthorizationTypedData;
141
+ } | {
142
+ ok: false;
143
+ reason: TransferAuthorizationRefusal;
144
+ };
145
+ export declare function buildReceiveAuthorizationTypedData(input: BuildAuthorizationInput): Promise<BuildReceiveAuthorizationResult>;
146
+ export declare function buildReceivePaymentAuthorization(input: {
147
+ grant: TaskGrantEnvelope;
148
+ grantHash: string;
149
+ nowMs: number;
150
+ sign: SignReceiveTypedData;
151
+ }): Promise<BuildReceivePaymentResult>;
152
+ export type BuildReceivePaymentResult = {
153
+ ok: true;
154
+ authorization: PaymentAuthorization;
155
+ signed: SignedReceiveAuthorization;
156
+ grantHash: string;
157
+ } | {
158
+ ok: false;
159
+ reason: HirePaymentRefusal;
160
+ detail: string;
161
+ };
162
+ export declare function buildReceiveWithAuthorizationCalldata(signed: SignedReceiveAuthorization): BuildCalldataResult;
163
+ export declare function buildRecoveryRequest(input: {
164
+ grantHash: string;
165
+ requesterDid: string;
166
+ actionNonce: string;
167
+ nowMs: number;
168
+ ttlMs: number;
169
+ sign: Signer;
170
+ }): Promise<{
171
+ ok: true;
172
+ request: TaskRecoveryRequest;
173
+ signature_base64: string;
174
+ } | {
175
+ ok: false;
176
+ reason: SessionResultRejectReason;
177
+ }>;
178
+ export declare function buildRedemptionProofHeader(input: {
179
+ providerDid: string;
180
+ grantHash: string;
181
+ sign: Signer;
182
+ nowMs: number;
183
+ entropy?: SessionEntropy;
184
+ }): Promise<{
185
+ name: string;
186
+ value: string;
187
+ }>;
188
+ export declare function buildSettlementHint(input: {
189
+ grantHash: string;
190
+ providerDid: string;
191
+ evidence: unknown;
192
+ nowMs: number;
193
+ }): Promise<SettlementHintEnvelope>;
194
+ export type BuildTransferAuthorizationResult = {
195
+ ok: true;
196
+ typedData: TransferAuthorizationTypedData;
197
+ } | {
198
+ ok: false;
199
+ reason: TransferAuthorizationRefusal;
200
+ };
201
+ export declare function buildTransferAuthorizationTypedData(input: BuildAuthorizationInput): Promise<BuildTransferAuthorizationResult>;
202
+ export declare function buildTransferPaymentAuthorization(input: {
203
+ grant: TaskGrantEnvelope;
204
+ grantHash: string;
205
+ nowMs: number;
206
+ sign: SignTypedData;
207
+ }): Promise<BuildTransferPaymentResult>;
208
+ export type BuildTransferPaymentResult = {
209
+ ok: true;
210
+ authorization: PaymentAuthorization;
211
+ signed: SignedTransferAuthorization;
212
+ grantHash: string;
213
+ } | {
214
+ ok: false;
215
+ reason: HirePaymentRefusal;
216
+ detail: string;
217
+ };
218
+ export declare function buildTransferWithAuthorizationCalldata(signed: SignedTransferAuthorization): BuildCalldataResult;
219
+ export declare function buildX402PaymentPayload(signed: SignedTransferAuthorization, matched: {
220
+ readonly x402Version: number;
221
+ readonly network: string;
222
+ }): X402PaymentPayload;
223
+ export declare function buildX402PaymentRequirements(signed: SignedTransferAuthorization, matched: {
224
+ readonly x402Version: number;
225
+ readonly network: string;
226
+ }): Record<string, unknown>;
227
+ export declare function caip2Of(caip10OrCaip19: string): string | null;
228
+ export type CalldataRefusal = "unsupported_chain" | "malformed_authorization" | "malformed_signature";
229
+ export declare function canonicalBytes(value: unknown): Uint8Array;
230
+ export declare function canonicalize(value: unknown): string;
231
+ declare const CAPSULE_ALG = "x25519-xsalsa20-poly1305+xsalsa20-poly1305";
232
+ export declare const CAPSULE_NONCE_LENGTH = 24;
233
+ export declare function checkSingleAuthorizationRelay(request: TransactionRequest, context?: SingleAuthorizationRelayContext): SingleAuthorizationCheck;
234
+ export declare function compareDecimalStrings(a: string, b: string): number | null;
235
+ type CostRefusal = "estimate_unavailable" | "gas_price_unavailable" | "balance_unavailable" | "relayer_cannot_pay_gas";
236
+ export declare function createFacilitatorSubmitter(input: FacilitatorSubmitterInput): PaymentSubmitter;
237
+ export declare function createPayeeRelayBroadcaster(input: PayeeRelayBroadcasterInput): (request: TransactionRequest) => Promise<string>;
238
+ export declare function createReadOnlyEvmRpc(input: ReadOnlyEvmRpcInput): ReadOnlyEvmRpc;
239
+ export declare function createSelfSubmitter(input: SelfSubmitterInput): PaymentSubmitter;
240
+ export declare function decideFromSupported(args: {
241
+ readonly body: unknown;
242
+ readonly chain: string;
243
+ readonly url: string;
244
+ readonly httpStatus: number | null;
245
+ }): FacilitatorPreflightResult;
246
+ export declare function decodeRevertReason(data: unknown): string | null;
247
+ export declare function deriveDidFromSigningKey(signingPublicKey: Uint8Array): string;
248
+ export declare function destroySessionKey(key: SessionKey): void;
249
+ export type DiscoveryTransportReason = "manifest_unreachable" | "manifest_not_json";
250
+ export declare function encodeSessionProviderProof(envelope: SessionProviderProofEnvelope, signatureBase64: string): string;
251
+ export declare function envelopeHash(env: object): Promise<string>;
252
+ export declare function estimateRelayCost(input: {
253
+ readonly rpc: ReadOnlyEvmRpc;
254
+ readonly request: TransactionRequest;
255
+ readonly from: string;
256
+ readonly gasLimitMarginPercent: number;
257
+ }): Promise<RelayCostResult>;
258
+ export declare const EVM_USDC_EIP712_DOMAINS: ReadonlyMap<string, EvmUsdcDomain>;
259
+ export interface EvmUsdcDomain {
260
+ readonly name: string;
261
+ readonly version: string;
262
+ readonly chainId: number;
263
+ readonly verifyingContract: string;
264
+ readonly domainSeparator: string;
265
+ }
266
+ export declare function exportSessionKeyBytes(key: SessionKey): Uint8Array | null;
267
+ export declare const FACILITATOR_PREFLIGHT_SCHEMA = "voidly.pay.facilitator-preflight/v1";
268
+ export interface FacilitatorPreflightInput {
269
+ readonly baseUrl: string;
270
+ readonly chain?: string;
271
+ readonly fetchImpl: FetchLike;
272
+ readonly signal?: AbortSignal;
273
+ }
274
+ export interface FacilitatorPreflightResult {
275
+ readonly schema: typeof FACILITATOR_PREFLIGHT_SCHEMA;
276
+ readonly verdict: PreflightVerdict;
277
+ readonly reason: PreflightReason;
278
+ readonly detail: string;
279
+ readonly chain: string;
280
+ readonly frozenAsset: string | null;
281
+ readonly url: string;
282
+ readonly httpStatus: number | null;
283
+ readonly matched: MatchedKind | null;
284
+ readonly observations: readonly PreflightObservation[];
285
+ readonly undetermined: readonly PreflightUndetermined[];
286
+ }
287
+ export interface FacilitatorSubmitterInput {
288
+ readonly preflight: FacilitatorPreflightResult;
289
+ readonly fetchImpl: FetchLike;
290
+ readonly signal?: AbortSignal;
291
+ readonly allowUnadvertisedTransferMethod?: boolean;
292
+ }
293
+ export type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
294
+ export declare function fetchVerifiedProvider(input: FetchVerifiedProviderInput): Promise<FetchVerifiedProviderResult>;
295
+ export interface FetchVerifiedProviderInput {
296
+ readonly manifestUrl: string;
297
+ readonly expectedProviderDid: string;
298
+ readonly fetchImpl: FetchLike;
299
+ readonly signal?: AbortSignal;
300
+ }
301
+ export type FetchVerifiedProviderResult = {
302
+ readonly ok: true;
303
+ readonly provider: VerifiedProvider;
304
+ } | {
305
+ readonly ok: false;
306
+ readonly reason: VerifiedProviderRejectReason | DiscoveryTransportReason;
307
+ readonly detail: string;
308
+ };
309
+ export declare const FORBIDDEN_RPC_METHODS: readonly string[];
310
+ export declare function frameBucketSize(totalBytes: number): number;
311
+ export declare function hashArtifact(artifact: object): Promise<string>;
312
+ export interface HireKeep {
313
+ sessionKey: SessionKey;
314
+ grant_hash: string;
315
+ offer_hash: string;
316
+ brief_commitment: string;
317
+ }
318
+ export type HirePaymentRefusal = SignRefusal | HireRefuseDetail | "grant_hash_mismatch";
319
+ export type HireRefuseDetail = RedeemRejectReason | "hire_not_object" | "hire_schema_mismatch" | "hire_unexpected_field" | "hire_invalid_offer_signature_encoding" | "hire_invalid_grant_signature_encoding" | "hire_invalid_authorization_signature_encoding" | "authorization_signature_forged" | "authorization_not_object" | "authorization_unexpected_field" | "authorization_scheme_unsupported" | "authorization_entry_point_unsupported" | "authorization_entry_point_unstated" | "authorization_entry_point_not_accepted" | "provider_entry_points_unconfigured" | "stored_hire_bundle_mismatch" | "stored_hire_unreadable" | "ledger_read_failed" | "authorization_invalid_chain" | "authorization_invalid_asset" | "authorization_invalid_from" | "authorization_invalid_to" | "authorization_invalid_value" | "authorization_invalid_valid_after" | "authorization_invalid_valid_before" | "authorization_invalid_nonce" | "authorization_invalid_signature" | "authorization_chain_mismatch" | "authorization_asset_mismatch" | "authorization_payer_mismatch" | "authorization_payee_mismatch" | AccountSpellingRefuseDetail | "authorization_below_floor" | "authorization_over_ceiling" | "authorization_binding_mismatch" | "authorization_expiry_mismatch" | "authorization_valid_after_too_late" | "hirer_key_unresolved" | "hirer_key_not_the_registered_one" | "offer_signature_forged" | "grant_signature_forged" | "provider_did_not_ours" | "provider_signing_key_not_ours" | "provider_enc_key_not_ours" | "payee_account_not_ours" | "grant_already_expired" | "grant_window_too_short" | "price_under_provider_floor" | "provider_policy_refused" | "provider_not_accepting" | "ledger_write_failed";
320
+ type HireRefuseReason = "hire_malformed" | "identity_unresolved" | "hirer_key_mismatch" | "invalid_hirer_signature" | "artifact_binding_broken" | "not_the_named_provider" | "authorization_invalid" | "authorization_entry_point_refused" | "grant_already_committed" | "price_below_floor" | "window_too_short" | "brief_rejected" | "service_unavailable" | "ledger_unavailable";
321
+ export interface HireTerms {
322
+ readonly serviceRef: string;
323
+ readonly chain: string;
324
+ readonly asset: string;
325
+ readonly payerAccount: string;
326
+ readonly payeeAccount: string;
327
+ readonly minAmount: string;
328
+ readonly maxAmount: string;
329
+ readonly grantExpiresAtMs: number;
330
+ readonly offerExpiresAtMs: number;
331
+ }
332
+ export type HireWire = {
333
+ offer: SessionOfferEnvelope;
334
+ offer_signature_base64: string;
335
+ grant: TaskGrantEnvelope;
336
+ grant_signature_base64: string;
337
+ capsule: TaskCapsule;
338
+ };
339
+ export declare function importSessionKey(bytes: Uint8Array): SessionKey;
340
+ declare const INSPECT_CUSTOM: unique symbol;
341
+ export declare function isAllZero(bytes: Uint8Array): boolean;
342
+ export declare function isCaip10(s: string): boolean;
343
+ export declare function isCaip19(s: string): boolean;
344
+ export declare function isCaip2(s: string): boolean;
345
+ export declare function isPositiveDecimalString(s: string): boolean;
346
+ export declare function isSessionParty(value: unknown): value is SessionParty;
347
+ export declare function isVerifiedProvider(value: unknown): value is VerifiedProvider;
348
+ export declare const KNOWN_ASSET_TRANSFER_METHODS: readonly [
349
+ "eip3009",
350
+ "permit2",
351
+ "erc7710"
352
+ ];
353
+ export type ManifestRejectReason = "manifest_not_object" | "manifest_schema_mismatch" | "manifest_unexpected_field" | "manifest_field_malformed" | "manifest_signature_missing" | "manifest_signature_malformed" | "manifest_signature_invalid" | "manifest_did_not_derived" | "manifest_did_not_pinned";
354
+ export interface MatchedKind {
355
+ readonly x402Version: number;
356
+ readonly scheme: string;
357
+ readonly network: string;
358
+ readonly resolvedChain: string;
359
+ readonly assetTransferMethod: string | null;
360
+ }
361
+ export declare const MAX_BRIEF_LENGTH: number;
362
+ export declare const MAX_CLOCK_SKEW_MS: number;
363
+ export declare const MAX_GRANT_TTL_MS: number;
364
+ export declare const MAX_OFFER_TTL_MS: number;
365
+ export declare const MAX_RESULT_LENGTH: number;
366
+ export declare const MAX_SERVICE_REF_LENGTH = 128;
367
+ export declare const MIN_GRANT_TTL_MS: number;
368
+ export declare const MIN_NONCE_LENGTH = 16;
369
+ export declare function openBrief(input: {
370
+ wire: HireWire;
371
+ attestation: unknown;
372
+ attestationSignatureBase64: string;
373
+ attestorSigningPublicKey: Uint8Array;
374
+ hirerSigningPublicKey: Uint8Array;
375
+ providerDid: string;
376
+ recipientEncSecretKey: Uint8Array;
377
+ nowMs: number;
378
+ }): Promise<ProviderOpenResult>;
379
+ export declare function openDeliveredResult(input: {
380
+ readonly receipt: unknown;
381
+ readonly signatureBase64: string;
382
+ readonly resultCapsule: unknown;
383
+ readonly grant: TaskGrantEnvelope;
384
+ readonly grantHash: string;
385
+ readonly sessionKey: SessionKey;
386
+ readonly nowMs: number;
387
+ }): Promise<OpenDeliveredResultOutcome>;
388
+ export type OpenDeliveredResultOutcome = {
389
+ kind: "opened";
390
+ result: string;
391
+ receipt: TaskDeliveryReceipt;
392
+ } | {
393
+ kind: "unopenable";
394
+ receipt: TaskDeliveryReceipt;
395
+ } | {
396
+ kind: "unverifiable";
397
+ reason: OpenDeliveredResultRefusal;
398
+ };
399
+ export type OpenDeliveredResultRefusal = "grant_hash_mismatch" | SessionResultRejectReason | "delivery_grant_mismatch";
400
+ export interface PayeeRelayBroadcasterInput {
401
+ readonly rpc: ReadOnlyEvmRpc;
402
+ readonly relayerAddress: string;
403
+ readonly send: SendRelayTransaction;
404
+ readonly gasLimitMarginPercent: number;
405
+ }
406
+ export declare function payForGrant(options: PayForGrantOptions): Promise<PayForGrantResult>;
407
+ export interface PayForGrantOptions {
408
+ readonly grant: TaskGrantEnvelope;
409
+ readonly grantHash: string;
410
+ readonly nowMs: number;
411
+ readonly signer: SignTypedData;
412
+ readonly facilitator?: {
413
+ readonly baseUrl: string;
414
+ readonly fetchImpl: FetchLike;
415
+ };
416
+ readonly broadcast?: BroadcastTx;
417
+ readonly allowUnadvertisedTransferMethod?: boolean;
418
+ readonly signal?: AbortSignal;
419
+ }
420
+ export type PayForGrantRefusal = HirePaymentRefusal | SubmitRefusal | "facilitator_permit2" | "facilitator_unusable" | "facilitator_unknown";
421
+ export type PayForGrantResult = {
422
+ ok: true;
423
+ transactionHash: string;
424
+ authorization: PaymentAuthorization;
425
+ signed: SignedTransferAuthorization;
426
+ preflight: FacilitatorPreflightResult | null;
427
+ } | {
428
+ ok: false;
429
+ reason: PayForGrantRefusal;
430
+ detail: string;
431
+ unsigned: boolean;
432
+ preflight: FacilitatorPreflightResult | null;
433
+ };
434
+ export declare const PAYMENT_AUTHORIZATION_SCHEME = "eip3009";
435
+ export type PaymentAuthorization = {
436
+ scheme: typeof PAYMENT_AUTHORIZATION_SCHEME;
437
+ entry_point?: AuthorizationEntryPoint;
438
+ chain: string;
439
+ asset: string;
440
+ from: string;
441
+ to: string;
442
+ value: string;
443
+ valid_after: string;
444
+ valid_before: string;
445
+ nonce: string;
446
+ signature: string;
447
+ };
448
+ export interface PaymentSubmitter {
449
+ readonly kind: "facilitator" | "self";
450
+ submit(signed: SignedTransferAuthorization): Promise<SubmitResult>;
451
+ }
452
+ export declare function postDeliver(ep: SessionEndpoint, input: {
453
+ wire: HireWire;
454
+ receipt: TaskDeliveryReceipt;
455
+ receiptSignatureBase64: string;
456
+ resultCapsule: TaskResultCapsule;
457
+ }): Promise<SessionResponse>;
458
+ export declare function postReattest(ep: SessionEndpoint, input: {
459
+ wire: HireWire;
460
+ proofHeader: {
461
+ name: string;
462
+ value: string;
463
+ };
464
+ }): Promise<SessionResponse>;
465
+ export declare function postRecover(ep: SessionEndpoint, input: {
466
+ wire: HireWire;
467
+ request: TaskRecoveryRequest;
468
+ requestSignatureBase64: string;
469
+ }): Promise<SessionResponse<RecoverResponseBody>>;
470
+ export declare function postRedeem(ep: SessionEndpoint, input: {
471
+ wire: HireWire;
472
+ acceptance: TaskAcceptanceEnvelope;
473
+ acceptanceSignatureBase64: string;
474
+ evidence: unknown;
475
+ proofHeader: {
476
+ name: string;
477
+ value: string;
478
+ };
479
+ }): Promise<SessionResponse<RedeemResponseBody>>;
480
+ export declare const PREFLIGHT_DEFAULT_CHAIN = "eip155:8453";
481
+ export declare function preflightAdmitsPayment(preflight: FacilitatorPreflightResult, allowUnadvertisedTransferMethod: boolean): boolean;
482
+ export declare function preflightFacilitator(input: FacilitatorPreflightInput): Promise<FacilitatorPreflightResult>;
483
+ export interface PreflightObservation {
484
+ readonly code: PreflightObservationCode;
485
+ readonly detail: string;
486
+ }
487
+ type PreflightObservationCode = "matched_via_v1_alias" | "v1_exact_is_eip3009_by_spec" | "batch_scheme_advertised" | "other_schemes_on_chain" | "supported_response_not_v2_conformant" | "redirected" | "minimum_payment_advertised";
488
+ export type PreflightReason = "eip3009_exact_advertised" | "transfer_method_permit2" | "transfer_method_not_eip3009" | "no_exact_on_chain" | "chain_not_offered" | "asset_not_frozen_usdc" | "transfer_method_not_advertised" | "transfer_method_unrecognised" | "asset_advertisement_unreadable" | "unreachable" | "http_status" | "response_not_json" | "response_malformed" | "response_too_large" | "url_not_https" | "chain_not_supported_by_rail";
489
+ export interface PreflightUndetermined {
490
+ readonly code: PreflightUndeterminedCode;
491
+ readonly detail: string;
492
+ }
493
+ type PreflightUndeterminedCode = "batching_not_advertised" | "nonce_control_is_client_side" | "per_transaction_shape_is_on_chain" | "transfer_method_not_advertised";
494
+ export type PreflightVerdict = "usable" | "unusable" | "unknown";
495
+ export declare function privateHire(input: PrivateHireInput): Promise<PrivateHireResult>;
496
+ interface PrivateHireInput {
497
+ hirer: {
498
+ did: string;
499
+ signingPublicKeyBase64: string;
500
+ sign: Signer;
501
+ };
502
+ provider: VerifiedProvider;
503
+ service: {
504
+ ref: string;
505
+ };
506
+ task: {
507
+ brief: string;
508
+ };
509
+ price: {
510
+ chain: string;
511
+ asset: string;
512
+ payerAccount: string;
513
+ payeeAccount: string;
514
+ minAmount: string;
515
+ maxAmount: string;
516
+ };
517
+ ttl: {
518
+ offerMs: number;
519
+ grantMs: number;
520
+ };
521
+ nowMs: number;
522
+ entropy: {
523
+ offerNonce: string;
524
+ grantNonce: string;
525
+ sessionKey: Uint8Array;
526
+ ephemeralSecretKey: Uint8Array;
527
+ briefSalt: Uint8Array;
528
+ bodyNonce: Uint8Array;
529
+ wrapNonce: Uint8Array;
530
+ };
531
+ }
532
+ type PrivateHireResult = {
533
+ ok: true;
534
+ wire: HireWire;
535
+ keep: HireKeep;
536
+ } | {
537
+ ok: false;
538
+ reason: RedeemRejectReason | ProviderTermsRejectReason | AccountSpellingRefuseDetail;
539
+ };
540
+ export declare const PROVIDER_MANIFEST_KEYS: readonly [
541
+ "schema",
542
+ "provider_did",
543
+ "signing_public_key_base64",
544
+ "encryption_public_key_base64",
545
+ "attestor_public_key_base64",
546
+ "accept_url",
547
+ "hire_message_schema",
548
+ "worker_base_url",
549
+ "grant_ttl_ms",
550
+ "acceptance_ttl_ms",
551
+ "services",
552
+ "payment_buys",
553
+ "notes",
554
+ "signature_base64"
555
+ ];
556
+ export declare const PROVIDER_MANIFEST_PATH = "/.well-known/voidly-session-provider.json";
557
+ export declare const PROVIDER_MANIFEST_SCHEMA = "voidly.session.provider.manifest/v1";
558
+ export interface ProviderManifest {
559
+ readonly schema: typeof PROVIDER_MANIFEST_SCHEMA;
560
+ readonly provider_did: string;
561
+ readonly signing_public_key_base64: string;
562
+ readonly encryption_public_key_base64: string;
563
+ readonly attestor_public_key_base64: string;
564
+ readonly accept_url: string;
565
+ readonly hire_message_schema: typeof SESSION_HIRE_SCHEMA;
566
+ readonly worker_base_url: string;
567
+ readonly grant_ttl_ms: {
568
+ readonly min: number;
569
+ readonly max: number;
570
+ };
571
+ readonly acceptance_ttl_ms: number;
572
+ readonly services: ReadonlyArray<{
573
+ readonly ref: string;
574
+ readonly description: string;
575
+ readonly price: {
576
+ readonly chain: string;
577
+ readonly asset: string;
578
+ readonly payee_account: string;
579
+ readonly min_amount: string;
580
+ readonly max_amount: string;
581
+ };
582
+ }>;
583
+ readonly payment_buys: "an attempt, not an outcome";
584
+ readonly notes: readonly string[];
585
+ readonly signature_base64: string;
586
+ }
587
+ export type ProviderOpenRefusal = "open_clock_implausible" | "attestation_not_object" | "attestation_schema_mismatch" | "attestation_unexpected_field" | "attestation_invalid_grant_hash" | "attestation_invalid_capsule_hash" | "attestation_invalid_offer_hash" | "attestation_invalid_hirer_did" | "attestation_invalid_provider_did" | "attestation_invalid_evidence_id" | "attestation_invalid_settled_chain" | "attestation_invalid_settled_asset" | "attestation_invalid_settled_amount" | "attestation_invalid_timestamp" | "attestation_not_yet_valid" | "attestation_expired" | "attestation_outlives_grant" | "attestor_key_invalid" | "attestation_invalid_signature" | "grant_unreadable" | "hirer_key_invalid" | "hirer_key_not_derivable" | "invalid_grant_signature" | "attestation_grant_mismatch" | "attestation_capsule_mismatch" | "attestation_offer_mismatch" | "attestation_hirer_mismatch" | "attestation_provider_mismatch" | "attestation_settlement_mismatch" | "attestation_below_agreed_price" | "provider_did_mismatch" | "capsule_unreadable" | "capsule_binding_mismatch" | "recipient_binding_mismatch";
588
+ export type ProviderOpenResult = {
589
+ kind: "opened";
590
+ brief: string;
591
+ sessionKey: SessionKey;
592
+ } | {
593
+ kind: "refused";
594
+ reason: ProviderOpenRefusal;
595
+ } | {
596
+ kind: "unopenable";
597
+ };
598
+ export type ProviderTermsRejectReason = "provider_not_verified" | "provider_service_not_offered" | "provider_price_chain_not_offered" | "provider_price_asset_not_offered" | "provider_payee_not_manifested" | "provider_price_below_manifest_floor" | "provider_price_above_manifest_ceiling" | "provider_grant_ttl_below_manifest_floor" | "provider_grant_ttl_above_manifest_ceiling";
599
+ export declare const READ_ONLY_RPC_METHODS: readonly string[];
600
+ export interface ReadOnlyEvmRpc {
601
+ readonly url: string;
602
+ request(method: string, params: readonly unknown[]): Promise<RpcResult>;
603
+ }
604
+ export interface ReadOnlyEvmRpcInput {
605
+ readonly url: string;
606
+ readonly fetchImpl: FetchLike;
607
+ readonly signal?: AbortSignal;
608
+ }
609
+ export declare const RECEIVE_WITH_AUTHORIZATION_SELECTOR = "0xef55bec6";
610
+ export declare const RECEIVE_WITH_AUTHORIZATION_TYPEHASH = "0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8";
611
+ export interface ReceiveAuthorizationTypedData {
612
+ readonly domain: {
613
+ readonly name: string;
614
+ readonly version: string;
615
+ readonly chainId: number;
616
+ readonly verifyingContract: string;
617
+ };
618
+ readonly types: {
619
+ readonly EIP712Domain: ReadonlyArray<{
620
+ readonly name: string;
621
+ readonly type: string;
622
+ }>;
623
+ readonly ReceiveWithAuthorization: ReadonlyArray<{
624
+ readonly name: string;
625
+ readonly type: string;
626
+ }>;
627
+ };
628
+ readonly primaryType: "ReceiveWithAuthorization";
629
+ readonly message: {
630
+ readonly from: string;
631
+ readonly to: string;
632
+ readonly value: string;
633
+ readonly validAfter: string;
634
+ readonly validBefore: string;
635
+ readonly nonce: string;
636
+ };
637
+ }
638
+ type ReceivedHireRefuseDetail = HireRefuseDetail | UnknownHireRefuseDetail;
639
+ export interface RecoverResponseBody {
640
+ schema: string;
641
+ outcome: {
642
+ kind: "answered";
643
+ grant_hash: string;
644
+ state: {
645
+ kind: string;
646
+ };
647
+ answer: {
648
+ receipt: unknown;
649
+ receipt_signature_base64: string;
650
+ result_capsule: unknown;
651
+ } | null;
652
+ } | {
653
+ kind: "paid_no_session";
654
+ grant_hash: string;
655
+ evidence_id: string;
656
+ } | {
657
+ kind: "no_payment_recorded";
658
+ grant_hash: string;
659
+ } | {
660
+ kind: "rejected";
661
+ reason: string;
662
+ };
663
+ }
664
+ export declare function recoverResult(input: {
665
+ readonly endpoint: SessionEndpoint;
666
+ readonly wire: HireWire;
667
+ readonly grantHash: string;
668
+ readonly sessionKey: SessionKey;
669
+ readonly sign: Signer;
670
+ readonly nowMs: number;
671
+ readonly ttlMs?: number;
672
+ readonly entropy?: SessionEntropy;
673
+ }): Promise<RecoverResultOutcome>;
674
+ export type RecoverResultOutcome = {
675
+ kind: "opened";
676
+ result: string;
677
+ receipt: TaskDeliveryReceipt;
678
+ } | {
679
+ kind: "unopenable";
680
+ receipt: TaskDeliveryReceipt;
681
+ } | {
682
+ kind: "unverifiable";
683
+ reason: OpenDeliveredResultRefusal | "answer_malformed";
684
+ } | {
685
+ kind: "no_result";
686
+ status: number;
687
+ outcome: string;
688
+ state: string;
689
+ evidence_id?: string;
690
+ } | {
691
+ kind: "undelivered";
692
+ detail: string;
693
+ } | {
694
+ kind: "unrecognized";
695
+ status: number;
696
+ detail: string;
697
+ } | {
698
+ kind: "unbuildable";
699
+ reason: RecoverResultRefusal;
700
+ };
701
+ export type RecoverResultRefusal = "grant_hash_mismatch" | "hirer_did_unusable" | SessionResultRejectReason;
702
+ export type RedeemRejectReason = "clock_implausible" | "offer_not_object" | "offer_schema_mismatch" | "offer_unexpected_field" | "offer_invalid_hirer_did" | "offer_invalid_hirer_pubkey" | "offer_invalid_provider_did" | "offer_self_hire_not_allowed" | "offer_invalid_service_ref" | "offer_invalid_price_chain" | "offer_invalid_price_asset" | "offer_invalid_price_payer_account" | "offer_invalid_price_payee_account" | "offer_price_chain_mismatch" | "offer_invalid_price_amount" | "offer_invalid_price_min_amount" | "offer_price_band_inverted" | "offer_invalid_nonce" | "offer_invalid_timestamp" | "offer_ttl_too_long" | "offer_not_yet_valid" | "offer_expired" | "grant_not_object" | "grant_schema_mismatch" | "grant_unexpected_field" | "grant_invalid_hirer_did" | "grant_invalid_provider_did" | "grant_self_hire_not_allowed" | "grant_invalid_provider_signing_pubkey" | "grant_invalid_provider_enc_pubkey" | "grant_invalid_offer_hash" | "grant_invalid_capsule_hash" | "grant_invalid_brief_commitment" | "grant_invalid_price_chain" | "grant_invalid_price_asset" | "grant_invalid_price_payer_account" | "grant_invalid_price_payee_account" | "grant_price_chain_mismatch" | "grant_invalid_price_amount" | "grant_invalid_price_min_amount" | "grant_price_band_inverted" | "grant_invalid_nonce" | "grant_invalid_timestamp" | "grant_ttl_too_long" | "grant_not_yet_valid" | "capsule_not_object" | "capsule_schema_mismatch" | "capsule_unexpected_field" | "capsule_invalid_alg" | "capsule_invalid_offer_hash" | "capsule_invalid_recipient_pubkey" | "capsule_invalid_ephemeral_pubkey" | "capsule_invalid_wrapped_key" | "capsule_invalid_wrap_nonce" | "capsule_invalid_body_nonce" | "capsule_invalid_body" | "capsule_body_too_large" | "acceptance_not_object" | "acceptance_schema_mismatch" | "acceptance_unexpected_field" | "acceptance_invalid_grant_hash" | "acceptance_invalid_redeemer_did" | "acceptance_invalid_nonce" | "acceptance_invalid_timestamp" | "acceptance_window_too_long" | "acceptance_not_yet_valid" | "acceptance_expired" | "store_not_serialized" | "hirer_did_mismatch" | "provider_did_mismatch" | "provider_key_mismatch" | "hirer_key_mismatch" | "invalid_offer_signature" | "invalid_grant_signature" | "invalid_acceptance_signature" | "grant_offer_mismatch" | "grant_capsule_mismatch" | "capsule_offer_mismatch" | "recipient_binding_mismatch" | "grant_price_mismatch" | "grant_provider_mismatch" | "grant_hirer_mismatch" | "grant_outlives_offer" | "acceptance_grant_mismatch" | "acceptance_redeemer_mismatch" | "invalid_session_key_length" | "invalid_session_key_all_zero" | "invalid_ephemeral_secret_length" | "invalid_brief_salt_length" | "invalid_brief_salt_all_zero" | "invalid_ephemeral_secret_all_zero" | "invalid_body_nonce_length" | "invalid_body_nonce_all_zero" | "invalid_wrap_nonce_length" | "invalid_wrap_nonce_all_zero" | "capsule_frame_failed" | "invalid_recipient_enc_pubkey" | "brief_too_long" | "invalid_ttl" | "grant_ttl_below_settlement_depth" | "signer_failed" | "journal_record_malformed" | "settlement_adapter_unknown" | "settlement_adapter_misregistered" | "settlement_indeterminate" | "settlement_unattributable" | "settlement_rejected" | "settlement_superseded" | "settlement_cancelled" | "settlement_chain_mismatch" | "settlement_asset_mismatch" | "settlement_invalid_amount" | "settlement_over_ceiling" | "settlement_below_floor" | "settlement_invalid_evidence_id" | "settlement_invalid_payer_account" | "settlement_invalid_payee_account" | "settlement_payer_mismatch" | "settlement_payee_mismatch" | "settlement_binding_mismatch" | "settlement_evidence_reused";
703
+ export interface RedeemResponseBody {
704
+ schema: string;
705
+ outcome: {
706
+ kind: "redeemed";
707
+ grant_hash: string;
708
+ offer_hash: string;
709
+ provider_did: string;
710
+ price: {
711
+ chain: string;
712
+ asset: string;
713
+ min_amount: string;
714
+ max_amount: string;
715
+ };
716
+ settled_amount: string | null;
717
+ expires_at_ms: number | null;
718
+ recoverable_until_ms: number | null;
719
+ brief_readable_here: false;
720
+ attestation: RedemptionAttestation | null;
721
+ attestation_signature_base64: string | null;
722
+ attestation_unavailable: string | null;
723
+ } | {
724
+ kind: "replayed";
725
+ grant_hash: string;
726
+ first_redeemed_at_ms: number;
727
+ first_evidence_id: string;
728
+ } | {
729
+ kind: "expired";
730
+ grant_hash: string;
731
+ expires_at_ms: number;
732
+ now_ms: number;
733
+ } | {
734
+ kind: "rejected";
735
+ reason: string;
736
+ };
737
+ }
738
+ export declare const REDEMPTION_ATTESTATION_SCHEMA = "voidly-session-redemption-attestation/v1";
739
+ export type RedemptionAttestation = {
740
+ schema: typeof REDEMPTION_ATTESTATION_SCHEMA;
741
+ grant_hash: string;
742
+ capsule_hash: string;
743
+ offer_hash: string;
744
+ hirer_did: string;
745
+ provider_did: string;
746
+ evidence_id: string;
747
+ settled_chain: string;
748
+ settled_asset: string;
749
+ settled_amount: string;
750
+ redeemed_at: string;
751
+ expires_at: string;
752
+ };
753
+ export interface RelayCost {
754
+ readonly gas: bigint;
755
+ readonly gasLimit: bigint;
756
+ readonly gasPriceWei: bigint;
757
+ readonly maxCostWei: bigint;
758
+ readonly relayerBalanceWei: bigint;
759
+ }
760
+ export type RelayCostResult = {
761
+ readonly ok: true;
762
+ readonly cost: RelayCost;
763
+ } | {
764
+ readonly ok: false;
765
+ readonly reason: CostRefusal;
766
+ readonly detail: string;
767
+ };
768
+ export declare class RelayRefusal extends Error {
769
+ readonly reason: RelayRefusalReason;
770
+ constructor(reason: RelayRefusalReason, detail: string);
771
+ }
772
+ export type RelayRefusalReason = "batched_relay_refused" | "chain_id_mismatch" | "chain_id_unavailable" | "chain_time_unavailable" | "relay_window_too_short" | "relayer_address_malformed" | "simulation_reverted" | "simulation_unavailable" | CostRefusal | "send_threw" | "send_returned_no_hash";
773
+ export declare const REQUIRED_ASSET_TRANSFER_METHOD: "eip3009";
774
+ export declare function resolveSettlementTransaction(input: ResolveSettlementTransactionInput): Promise<SettlementLookupResult>;
775
+ export interface ResolveSettlementTransactionInput {
776
+ readonly rpc: ReadOnlyEvmRpc;
777
+ readonly chainId: number;
778
+ readonly authorizer: string;
779
+ readonly bindingReference: string;
780
+ readonly fromBlock: bigint;
781
+ }
782
+ declare const RESULT_CAPSULE_ALG = "xsalsa20-poly1305";
783
+ export declare function revertDataFromRpcError(detail: string): string | null;
784
+ export declare function reviewHire(input: {
785
+ wire: HireWire;
786
+ expectedProviderDid: string;
787
+ hirerSigningPublicKey: Uint8Array;
788
+ nowMs: number;
789
+ }): Promise<ReviewHireResult>;
790
+ export type ReviewHireRefusal = "offer_unreadable" | "grant_unreadable" | "capsule_unreadable" | "hirer_key_invalid" | "hirer_key_not_derivable" | "invalid_offer_signature" | "invalid_grant_signature" | "grant_offer_mismatch" | "grant_capsule_mismatch" | "capsule_offer_mismatch" | "recipient_binding_mismatch" | "grant_price_mismatch" | "grant_provider_mismatch" | "grant_hirer_mismatch" | "grant_outlives_offer" | "provider_did_mismatch";
791
+ export type ReviewHireResult = {
792
+ ok: true;
793
+ offer: SessionOfferEnvelope;
794
+ grant: TaskGrantEnvelope;
795
+ capsule: TaskCapsule;
796
+ grantHash: string;
797
+ capsuleHash: string;
798
+ offerHash: string;
799
+ terms: HireTerms;
800
+ } | {
801
+ ok: false;
802
+ reason: ReviewHireRefusal;
803
+ };
804
+ export type RpcRefusal = "rpc_method_not_read_only" | "rpc_url_not_https" | "rpc_unreachable" | "rpc_response_unreadable" | "rpc_error" | "rpc_result_malformed";
805
+ export type RpcResult = {
806
+ readonly ok: true;
807
+ readonly result: unknown;
808
+ } | {
809
+ readonly ok: false;
810
+ readonly reason: RpcRefusal;
811
+ readonly detail: string;
812
+ };
813
+ export declare function sealCapsule(input: {
814
+ brief: string;
815
+ offerHash: string;
816
+ recipientEncPublicKey: Uint8Array;
817
+ sessionKeyBytes: Uint8Array;
818
+ ephemeralSecretKey: Uint8Array;
819
+ briefSalt: Uint8Array;
820
+ bodyNonce: Uint8Array;
821
+ wrapNonce: Uint8Array;
822
+ }): Promise<{
823
+ capsule: TaskCapsule;
824
+ sessionKey: SessionKey;
825
+ briefCommitment: string;
826
+ }>;
827
+ export declare function sealTaskResult(input: {
828
+ result: string;
829
+ grantHash: string;
830
+ sessionKey: SessionKey;
831
+ briefCapsule: TaskCapsule;
832
+ entropy?: SessionEntropy;
833
+ }): Promise<{
834
+ capsule: TaskResultCapsule;
835
+ resultCommitment: string;
836
+ resultCapsuleHash: string;
837
+ }>;
838
+ export interface SelfSubmitterInput {
839
+ readonly broadcast: BroadcastTx;
840
+ }
841
+ export type SendRelayTransaction = (transaction: {
842
+ readonly from: string;
843
+ readonly to: string;
844
+ readonly data: string;
845
+ readonly value: "0x0";
846
+ readonly chainId: number;
847
+ readonly gasLimit: bigint;
848
+ readonly gasPriceWei: bigint;
849
+ }) => Promise<string> | string;
850
+ declare const SESSION_HIRE_ACCEPTED_SCHEMA = "voidly-session-hire-accepted/v1";
851
+ declare const SESSION_HIRE_REFUSED_SCHEMA = "voidly-session-hire-refused/v1";
852
+ declare const SESSION_HIRE_SCHEMA = "voidly-session-hire/v1";
853
+ declare const SESSION_OFFER_SCHEMA = "voidly-session-offer/v1";
854
+ export declare const SESSION_PATHS: Readonly<{
855
+ readonly redeem: "/v1/pay/session/redeem";
856
+ readonly deliver: "/v1/pay/session/deliver";
857
+ readonly recover: "/v1/pay/session/recover";
858
+ readonly reattest: "/v1/pay/session/reattest";
859
+ }>;
860
+ export declare const SESSION_PROVIDER_PROOF_HEADER = "x-voidly-session-provider-proof";
861
+ export declare const SESSION_PROVIDER_PROOF_MAX_WINDOW_MS: number;
862
+ export declare const SESSION_PROVIDER_PROOF_SCHEMA = "voidly-session-provider-redemption/v1";
863
+ export declare const SESSION_RAIL_BLOCK_TIME_MS = 2000;
864
+ export declare const SESSION_RAIL_MIN_CONFIRMATIONS = 12;
865
+ declare const SESSION_REATTEST_PROOF_SCHEMA = "voidly-session-provider-reattestation/v1";
866
+ export declare class SessionCryptoUnavailableError extends Error {
867
+ readonly code = "session_crypto_unavailable";
868
+ constructor(message: string);
869
+ }
870
+ export interface SessionEndpoint {
871
+ baseUrl: string;
872
+ fetch?: typeof fetch;
873
+ timeoutMs?: number | null;
874
+ }
875
+ export interface SessionEntropy {
876
+ random(n: number): Uint8Array;
877
+ nonce(): string;
878
+ }
879
+ export type SessionHireAccepted = {
880
+ schema: typeof SESSION_HIRE_ACCEPTED_SCHEMA;
881
+ grant_hash: string;
882
+ acceptance: TaskAcceptanceEnvelope;
883
+ acceptance_signature_base64: string;
884
+ };
885
+ export type SessionHireMessage = {
886
+ schema: typeof SESSION_HIRE_SCHEMA;
887
+ offer: SessionOfferEnvelope;
888
+ offer_signature_base64: string;
889
+ grant: TaskGrantEnvelope;
890
+ grant_signature_base64: string;
891
+ capsule: TaskCapsule;
892
+ authorization: PaymentAuthorization;
893
+ authorization_signature_base64: string;
894
+ };
895
+ export type SessionHireRefused = {
896
+ schema: typeof SESSION_HIRE_REFUSED_SCHEMA;
897
+ reason: HireRefuseReason;
898
+ detail: ReceivedHireRefuseDetail;
899
+ };
900
+ export type SessionKey = SessionKeyHandle;
901
+ declare class SessionKeyHandle {
902
+ #private;
903
+ toJSON(): string;
904
+ toString(): string;
905
+ [INSPECT_CUSTOM](): string;
906
+ get isSessionKey(): boolean;
907
+ }
908
+ export type SessionOfferEnvelope = {
909
+ schema: typeof SESSION_OFFER_SCHEMA;
910
+ hirer_did: string;
911
+ hirer_signing_pubkey_base64: string;
912
+ provider_did: string;
913
+ service_ref: string;
914
+ price_chain: string;
915
+ price_asset: string;
916
+ price_payer_account: string;
917
+ price_payee_account: string;
918
+ price_min_amount: string;
919
+ price_max_amount: string;
920
+ nonce: string;
921
+ issued_at: string;
922
+ expires_at: string;
923
+ };
924
+ interface SessionParty {
925
+ readonly did: string;
926
+ readonly signingPublicKey: Uint8Array;
927
+ }
928
+ export declare function sessionProviderProofEnvelope(input: SessionProviderProofFields): SessionProviderProofEnvelope;
929
+ export interface SessionProviderProofEnvelope {
930
+ schema: SessionProviderProofSchema;
931
+ provider_did: string;
932
+ grant_hash: string;
933
+ action_nonce: string;
934
+ issued_at: string;
935
+ expires_at: string;
936
+ }
937
+ interface SessionProviderProofFields {
938
+ providerDid: string;
939
+ grantHash: string;
940
+ actionNonce: string;
941
+ nowMs: number;
942
+ ttlMs?: number;
943
+ }
944
+ type SessionProviderProofSchema = typeof SESSION_PROVIDER_PROOF_SCHEMA | typeof SESSION_REATTEST_PROOF_SCHEMA;
945
+ export interface SessionResponse<T = unknown> {
946
+ status: number;
947
+ body: T;
948
+ }
949
+ export type SessionResultRejectReason = "result_capsule_not_object" | "result_capsule_schema_mismatch" | "result_capsule_unexpected_field" | "result_capsule_invalid_alg" | "result_capsule_invalid_grant_hash" | "result_capsule_invalid_body_nonce" | "result_capsule_invalid_body" | "result_body_too_large" | "result_capsule_grant_mismatch" | "result_capsule_not_sealed_frame" | "delivery_not_object" | "delivery_schema_mismatch" | "delivery_unexpected_field" | "delivery_invalid_grant_hash" | "delivery_invalid_offer_hash" | "delivery_invalid_provider_did" | "delivery_invalid_result_capsule_hash" | "delivery_invalid_result_commitment" | "delivery_invalid_timestamp" | "delivery_window_too_long" | "delivery_not_yet_valid" | "invalid_delivery_signature" | "delivery_grant_mismatch" | "delivery_offer_mismatch" | "delivery_provider_mismatch" | "delivery_capsule_hash_mismatch" | "recovery_not_object" | "recovery_schema_mismatch" | "recovery_unexpected_field" | "recovery_invalid_grant_hash" | "recovery_invalid_requester_did" | "recovery_invalid_nonce" | "recovery_invalid_timestamp" | "recovery_window_too_long" | "recovery_not_yet_valid" | "recovery_expired" | "invalid_recovery_signature" | "recovery_grant_mismatch" | "recovery_requester_not_a_party" | "record_malformed";
950
+ export declare class SessionTransportError extends Error {
951
+ readonly code = "session_transport_error";
952
+ readonly status: number;
953
+ readonly body: string;
954
+ constructor(message: string, status: number, body: string);
955
+ }
956
+ export declare class SessionUsageError extends Error {
957
+ readonly code = "session_usage_error";
958
+ constructor(message: string);
959
+ }
960
+ export declare const SETTLEMENT_BINDING_DOMAIN = "voidly-session-settlement-binding/v1|";
961
+ declare const SETTLEMENT_HINT_SCHEMA: "voidly.session.settlement-hint/v1";
962
+ export declare function settlementBindingReference(grantHash: string): Promise<string>;
963
+ export interface SettlementHintEnvelope {
964
+ readonly schema: typeof SETTLEMENT_HINT_SCHEMA;
965
+ readonly grant_hash: string;
966
+ readonly provider_did: string;
967
+ readonly evidence_hash: string;
968
+ readonly issued_at: string;
969
+ }
970
+ export type SettlementLookupResult = {
971
+ readonly kind: "found";
972
+ readonly transactionHash: string;
973
+ readonly blockNumber: bigint;
974
+ } | {
975
+ readonly kind: "not_consumed";
976
+ } | {
977
+ readonly kind: "impossible";
978
+ readonly detail: string;
979
+ } | {
980
+ readonly kind: "unavailable";
981
+ readonly detail: string;
982
+ };
983
+ export declare function settlementNonce(grantHash: string): Promise<`0x${string}`>;
984
+ export declare function settleUrlFor(baseUrl: string): string | null;
985
+ export declare function sha256Hex(bytes: Uint8Array): Promise<string>;
986
+ export declare function signCanonical(env: object, sign: Signer): Promise<string | null>;
987
+ export declare function signDelivery(input: {
988
+ grantHash: string;
989
+ offerHash: string;
990
+ providerDid: string;
991
+ resultCapsuleHash: string;
992
+ resultCommitment: string;
993
+ recoverableUntilMs: number;
994
+ nowMs: number;
995
+ sign: Signer;
996
+ }): Promise<{
997
+ ok: true;
998
+ receipt: TaskDeliveryReceipt;
999
+ signature_base64: string;
1000
+ } | {
1001
+ ok: false;
1002
+ reason: SessionResultRejectReason;
1003
+ }>;
1004
+ export interface SignedReceiveAuthorization {
1005
+ readonly typedData: ReceiveAuthorizationTypedData;
1006
+ readonly signature: string;
1007
+ readonly v: number;
1008
+ readonly r: string;
1009
+ readonly s: string;
1010
+ readonly chain: string;
1011
+ readonly grantHash: string;
1012
+ }
1013
+ export interface SignedTransferAuthorization {
1014
+ readonly typedData: TransferAuthorizationTypedData;
1015
+ readonly signature: string;
1016
+ readonly v: number;
1017
+ readonly r: string;
1018
+ readonly s: string;
1019
+ readonly chain: string;
1020
+ readonly grantHash: string;
1021
+ }
1022
+ export type Signer = (bytes: Uint8Array) => Uint8Array | Promise<Uint8Array>;
1023
+ export declare function signHireAuthorization(input: {
1024
+ readonly grant: TaskGrantEnvelope;
1025
+ readonly grantHash: string;
1026
+ readonly authorization: PaymentAuthorization;
1027
+ readonly sign: Signer;
1028
+ }): Promise<SignHireAuthorizationResult>;
1029
+ export type SignHireAuthorizationResult = {
1030
+ ok: true;
1031
+ authorizationSignatureBase64: string;
1032
+ } | {
1033
+ ok: false;
1034
+ reason: HirePaymentRefusal | "signer_failed";
1035
+ detail: string;
1036
+ };
1037
+ export declare function signReceiveAuthorization(input: SignReceiveAuthorizationInput, signer: SignReceiveTypedData): Promise<SignReceiveAuthorizationResult>;
1038
+ export type SignReceiveAuthorizationInput = SignTransferAuthorizationInput;
1039
+ export type SignReceiveAuthorizationResult = {
1040
+ ok: true;
1041
+ signed: SignedReceiveAuthorization;
1042
+ } | {
1043
+ ok: false;
1044
+ reason: SignRefusal;
1045
+ detail: string;
1046
+ };
1047
+ export type SignReceiveTypedData = (typedData: ReceiveAuthorizationTypedData) => Promise<string> | string;
1048
+ export type SignRefusal = TransferAuthorizationRefusal | "authorization_expired" | "authorization_not_yet_valid" | "invalid_now_ms" | "signer_threw" | "signature_not_65_bytes" | "signature_recovery_id_invalid";
1049
+ export declare function signTransferAuthorization(input: SignTransferAuthorizationInput, signer: SignTypedData): Promise<SignTransferAuthorizationResult>;
1050
+ export interface SignTransferAuthorizationInput {
1051
+ chain: string;
1052
+ from: string;
1053
+ to: string;
1054
+ value: string;
1055
+ validAfter: number;
1056
+ validBefore: number;
1057
+ grantHash: string;
1058
+ nowMs: number;
1059
+ }
1060
+ export type SignTransferAuthorizationResult = {
1061
+ ok: true;
1062
+ signed: SignedTransferAuthorization;
1063
+ } | {
1064
+ ok: false;
1065
+ reason: SignRefusal;
1066
+ detail: string;
1067
+ };
1068
+ export type SignTypedData = (typedData: TransferAuthorizationTypedData) => Promise<string> | string;
1069
+ export declare function simulateTransaction(input: {
1070
+ readonly rpc: ReadOnlyEvmRpc;
1071
+ readonly request: TransactionRequest;
1072
+ readonly from: string;
1073
+ }): Promise<SimulationOutcome>;
1074
+ export type SimulationOutcome = {
1075
+ readonly kind: "would_succeed";
1076
+ readonly returned: string;
1077
+ } | {
1078
+ readonly kind: "would_revert";
1079
+ readonly reason: string | null;
1080
+ readonly raw: string;
1081
+ } | {
1082
+ readonly kind: "unavailable";
1083
+ readonly detail: string;
1084
+ };
1085
+ export type SingleAuthorizationCheck = {
1086
+ readonly ok: true;
1087
+ } | {
1088
+ readonly ok: false;
1089
+ readonly detail: string;
1090
+ };
1091
+ export interface SingleAuthorizationRelayContext {
1092
+ readonly relayerAddress?: string;
1093
+ }
1094
+ export declare function submitHire(input: {
1095
+ readonly url: string;
1096
+ readonly wire: HireWire;
1097
+ readonly grantHash: string;
1098
+ readonly authorization: PaymentAuthorization;
1099
+ readonly sign: Signer;
1100
+ readonly nowMs: number;
1101
+ readonly fetchImpl: FetchLike;
1102
+ readonly signal?: AbortSignal;
1103
+ }): Promise<SubmitHireResult>;
1104
+ export type SubmitHireResult = {
1105
+ kind: "accepted";
1106
+ accepted: SessionHireAccepted;
1107
+ } | {
1108
+ kind: "refused";
1109
+ refused: SessionHireRefused;
1110
+ retryable: boolean;
1111
+ steersPayment: boolean;
1112
+ } | {
1113
+ kind: "undelivered";
1114
+ detail: string;
1115
+ } | {
1116
+ kind: "unverifiable";
1117
+ detail: HireRefuseDetail | "response_malformed";
1118
+ } | {
1119
+ kind: "unbuildable";
1120
+ reason: HireRefuseDetail | "grant_hash_mismatch";
1121
+ };
1122
+ export type SubmitRefusal = "facilitator_not_usable" | "chain_mismatch" | "facilitator_refused" | "facilitator_response_unreadable" | "unreachable" | "broadcast_failed";
1123
+ export type SubmitResult = {
1124
+ ok: true;
1125
+ transactionHash: string;
1126
+ } | {
1127
+ ok: false;
1128
+ reason: SubmitRefusal;
1129
+ detail: string;
1130
+ };
1131
+ export declare function submitSettlementHint(input: {
1132
+ readonly url: string;
1133
+ readonly grant: TaskGrantEnvelope;
1134
+ readonly grantHash: string;
1135
+ readonly evidence: unknown;
1136
+ readonly sign: Signer;
1137
+ readonly nowMs: number;
1138
+ readonly fetchImpl: FetchLike;
1139
+ readonly signal?: AbortSignal;
1140
+ }): Promise<SubmitSettlementHintResult>;
1141
+ export type SubmitSettlementHintRefusal = "grant_hash_mismatch" | "provider_did_unusable" | "evidence_unusable" | "signature_failed";
1142
+ export type SubmitSettlementHintResult = {
1143
+ kind: "acknowledged";
1144
+ status: number;
1145
+ hint: SettlementHintEnvelope;
1146
+ } | {
1147
+ kind: "refused";
1148
+ status: number;
1149
+ reason: string;
1150
+ } | {
1151
+ kind: "undelivered";
1152
+ detail: string;
1153
+ } | {
1154
+ kind: "unrecognized";
1155
+ status: number;
1156
+ detail: string;
1157
+ } | {
1158
+ kind: "unbuildable";
1159
+ reason: SubmitSettlementHintRefusal;
1160
+ };
1161
+ export declare function supportedUrlFor(baseUrl: string): string | null;
1162
+ declare const TASK_ACCEPTANCE_SCHEMA = "voidly-task-acceptance/v1";
1163
+ declare const TASK_CAPSULE_SCHEMA = "voidly-task-capsule/v1";
1164
+ declare const TASK_DELIVERY_SCHEMA = "voidly-task-delivery/v1";
1165
+ declare const TASK_GRANT_SCHEMA = "voidly-task-grant/v1";
1166
+ declare const TASK_RECOVERY_SCHEMA = "voidly-task-recovery/v1";
1167
+ declare const TASK_RESULT_CAPSULE_SCHEMA = "voidly-task-result-capsule/v1";
1168
+ export type TaskAcceptanceEnvelope = {
1169
+ schema: typeof TASK_ACCEPTANCE_SCHEMA;
1170
+ grant_hash: string;
1171
+ redeemer_did: string;
1172
+ action_nonce: string;
1173
+ issued_at: string;
1174
+ expires_at: string;
1175
+ };
1176
+ export type TaskCapsule = {
1177
+ schema: typeof TASK_CAPSULE_SCHEMA;
1178
+ alg: typeof CAPSULE_ALG;
1179
+ offer_hash: string;
1180
+ recipient_enc_pubkey_base64: string;
1181
+ ephemeral_pubkey_base64: string;
1182
+ wrapped_session_key_base64: string;
1183
+ wrap_nonce_base64: string;
1184
+ body_nonce_base64: string;
1185
+ body_base64: string;
1186
+ };
1187
+ export type TaskDeliveryReceipt = {
1188
+ schema: typeof TASK_DELIVERY_SCHEMA;
1189
+ grant_hash: string;
1190
+ offer_hash: string;
1191
+ provider_did: string;
1192
+ result_capsule_hash: string;
1193
+ result_commitment: string;
1194
+ issued_at: string;
1195
+ recoverable_until: string;
1196
+ };
1197
+ export type TaskGrantEnvelope = {
1198
+ schema: typeof TASK_GRANT_SCHEMA;
1199
+ hirer_did: string;
1200
+ provider_did: string;
1201
+ provider_signing_pubkey_base64: string;
1202
+ provider_enc_pubkey_base64: string;
1203
+ offer_hash: string;
1204
+ capsule_hash: string;
1205
+ brief_commitment: string;
1206
+ price_chain: string;
1207
+ price_asset: string;
1208
+ price_payer_account: string;
1209
+ price_payee_account: string;
1210
+ price_min_amount: string;
1211
+ price_max_amount: string;
1212
+ nonce: string;
1213
+ issued_at: string;
1214
+ expires_at: string;
1215
+ };
1216
+ export type TaskRecoveryRequest = {
1217
+ schema: typeof TASK_RECOVERY_SCHEMA;
1218
+ grant_hash: string;
1219
+ requester_did: string;
1220
+ action_nonce: string;
1221
+ issued_at: string;
1222
+ expires_at: string;
1223
+ };
1224
+ export type TaskResultCapsule = {
1225
+ schema: typeof TASK_RESULT_CAPSULE_SCHEMA;
1226
+ alg: typeof RESULT_CAPSULE_ALG;
1227
+ grant_hash: string;
1228
+ body_nonce_base64: string;
1229
+ body_base64: string;
1230
+ };
1231
+ export declare function timestampMs(value: unknown): number | null;
1232
+ export interface TransactionRequest {
1233
+ readonly to: string;
1234
+ readonly data: string;
1235
+ readonly value: "0x0";
1236
+ readonly chainId: number;
1237
+ }
1238
+ export declare const TRANSFER_WITH_AUTHORIZATION_SELECTOR = "0xe3ee160e";
1239
+ export declare const TRANSFER_WITH_AUTHORIZATION_TYPEHASH = "0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267";
1240
+ export type TransferAuthorizationRefusal = "unsupported_chain" | "invalid_from" | "invalid_to" | "invalid_value" | "invalid_validity_window" | "validity_looks_like_milliseconds" | "invalid_grant_hash";
1241
+ export interface TransferAuthorizationTypedData {
1242
+ readonly domain: {
1243
+ readonly name: string;
1244
+ readonly version: string;
1245
+ readonly chainId: number;
1246
+ readonly verifyingContract: string;
1247
+ };
1248
+ readonly types: {
1249
+ readonly EIP712Domain: ReadonlyArray<{
1250
+ readonly name: string;
1251
+ readonly type: string;
1252
+ }>;
1253
+ readonly TransferWithAuthorization: ReadonlyArray<{
1254
+ readonly name: string;
1255
+ readonly type: string;
1256
+ }>;
1257
+ };
1258
+ readonly primaryType: "TransferWithAuthorization";
1259
+ readonly message: {
1260
+ readonly from: string;
1261
+ readonly to: string;
1262
+ readonly value: string;
1263
+ readonly validAfter: string;
1264
+ readonly validBefore: string;
1265
+ readonly nonce: string;
1266
+ };
1267
+ }
1268
+ type UnknownHireRefuseDetail = string & {};
1269
+ export declare function unsealBody(capsule: TaskCapsule, sessionKey: SessionKey): Promise<UnsealResult>;
1270
+ type UnsealResult = {
1271
+ kind: "opened";
1272
+ bytes: Uint8Array;
1273
+ payload: Uint8Array;
1274
+ } | {
1275
+ kind: "unopenable";
1276
+ };
1277
+ export declare function validateAcceptance(raw: unknown, nowMs: number): Validated<TaskAcceptanceEnvelope>;
1278
+ export declare function validateAuthorizationShape(raw: unknown): Validated<PaymentAuthorization, HireRefuseDetail>;
1279
+ export declare function validateCapsuleShape(raw: unknown): Validated<TaskCapsule>;
1280
+ export type Validated<T, R = RedeemRejectReason> = {
1281
+ ok: true;
1282
+ env: T;
1283
+ } | {
1284
+ ok: false;
1285
+ reason: R;
1286
+ };
1287
+ export declare function validateGrant(raw: unknown, nowMs: number): Validated<TaskGrantEnvelope>;
1288
+ export declare function validateOffer(raw: unknown, nowMs: number): Validated<SessionOfferEnvelope>;
1289
+ export declare function validateRecoveryRequest(raw: unknown, nowMs: number): Validated<TaskRecoveryRequest, SessionResultRejectReason>;
1290
+ export declare function validateRedemptionAttestation(raw: unknown, nowMs: number): Validated<RedemptionAttestation, ProviderOpenRefusal>;
1291
+ export declare function validateResultCapsuleShape(raw: unknown): Validated<TaskResultCapsule, SessionResultRejectReason>;
1292
+ export declare function validateX402SessionEvidence(raw: unknown): X402SessionEvidence | null;
1293
+ declare const VERIFIED_PROVIDER: unique symbol;
1294
+ export interface VerifiedProvider {
1295
+ readonly [VERIFIED_PROVIDER]: true;
1296
+ readonly manifest: ProviderManifest;
1297
+ }
1298
+ export type VerifiedProviderRejectReason = ManifestRejectReason | "manifest_pin_not_a_did" | "manifest_service_ref_duplicated";
1299
+ export type VerifiedProviderVerdict = {
1300
+ readonly ok: true;
1301
+ readonly provider: VerifiedProvider;
1302
+ } | {
1303
+ readonly ok: false;
1304
+ readonly reason: VerifiedProviderRejectReason;
1305
+ };
1306
+ export declare function verifyDeliveryReceipt(input: {
1307
+ receipt: unknown;
1308
+ signatureBase64: string;
1309
+ grant: TaskGrantEnvelope;
1310
+ grantHash: string;
1311
+ nowMs: number;
1312
+ }): VerifyDeliveryResult;
1313
+ export type VerifyDeliveryResult = {
1314
+ ok: true;
1315
+ receipt: TaskDeliveryReceipt;
1316
+ } | {
1317
+ ok: false;
1318
+ reason: SessionResultRejectReason | "delivery_grant_mismatch";
1319
+ };
1320
+ export declare function verifyDetached(env: object, signatureBase64: string, publicKey: Uint8Array): boolean;
1321
+ export declare function verifyProvider(raw: unknown, expectedProviderDid: string): VerifiedProviderVerdict;
1322
+ export declare function webCryptoEntropy(): SessionEntropy;
1323
+ export declare const X402_SESSION_EVIDENCE_SCHEMA = "voidly.session.settlement.x402/v1";
1324
+ export declare const X402_SESSION_USDC_BY_CHAIN: ReadonlyMap<string, string>;
1325
+ export declare const X402_V1_NETWORK_ALIASES: ReadonlyMap<string, string>;
1326
+ export interface X402PaymentPayload {
1327
+ readonly x402Version: number;
1328
+ readonly scheme: "exact";
1329
+ readonly network: string;
1330
+ readonly payload: {
1331
+ readonly signature: string;
1332
+ readonly authorization: {
1333
+ readonly from: string;
1334
+ readonly to: string;
1335
+ readonly value: string;
1336
+ readonly validAfter: string;
1337
+ readonly validBefore: string;
1338
+ readonly nonce: string;
1339
+ };
1340
+ };
1341
+ }
1342
+ export declare function x402SessionAccountCaip10(chain: string, address: string): string | null;
1343
+ export declare function x402SessionAssetCaip19(chain: string): string | null;
1344
+ export declare function x402SessionEvidence(transactionHash: string): X402SessionEvidence;
1345
+ export interface X402SessionEvidence {
1346
+ readonly schema: typeof X402_SESSION_EVIDENCE_SCHEMA;
1347
+ readonly transaction_hash: string;
1348
+ }