@haven_ai/sdk 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -16
- package/dist/index.cjs +864 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -5
- package/dist/index.d.ts +148 -5
- package/dist/index.js +860 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -48,7 +48,7 @@ interface PaymentIntent {
|
|
|
48
48
|
/** Data needed to sign the payment */
|
|
49
49
|
signData: SignData;
|
|
50
50
|
}
|
|
51
|
-
type PaymentStatus = 'pending_signature' | 'submitted' | 'confirmed' | 'expired' | 'failed';
|
|
51
|
+
type PaymentStatus = 'pending_signature' | 'submitted' | 'confirmed' | 'pending_approval' | 'approved' | 'proposed' | 'executed' | 'rejected' | 'expired' | 'failed';
|
|
52
52
|
interface PaymentResult {
|
|
53
53
|
/** Unique payment ID */
|
|
54
54
|
paymentId: string;
|
|
@@ -113,6 +113,109 @@ interface X402Receipt {
|
|
|
113
113
|
merchantTo?: string | null;
|
|
114
114
|
payer?: string;
|
|
115
115
|
chainId?: number;
|
|
116
|
+
haven?: {
|
|
117
|
+
paymentId: string;
|
|
118
|
+
fundingTxHash: string;
|
|
119
|
+
fundingExplorerUrl: string;
|
|
120
|
+
};
|
|
121
|
+
merchant?: {
|
|
122
|
+
payTo: string | null;
|
|
123
|
+
settlementTxHash?: string | null;
|
|
124
|
+
settlementExplorerUrl?: string | null;
|
|
125
|
+
};
|
|
126
|
+
x402?: {
|
|
127
|
+
amount: string;
|
|
128
|
+
token: string;
|
|
129
|
+
network: string;
|
|
130
|
+
asset: string;
|
|
131
|
+
resource: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
interface X402AuthorizationOptions {
|
|
135
|
+
/** Stable caller-supplied key for this user intent. Prevents duplicate approvals across fresh 402 quotes. */
|
|
136
|
+
idempotencyKey?: string;
|
|
137
|
+
}
|
|
138
|
+
interface ResumeAuthorizedX402Input extends X402AuthorizationOptions {
|
|
139
|
+
/** Payment or approval request ID returned by authorizeX402 / haven.fetch. */
|
|
140
|
+
paymentId: string;
|
|
141
|
+
/** Original or freshly parsed x402 requirements for the merchant retry. */
|
|
142
|
+
paymentRequired: X402PaymentRequired;
|
|
143
|
+
}
|
|
144
|
+
interface ResumeX402PaymentInput extends X402AuthorizationOptions {
|
|
145
|
+
/** Payment or approval request ID returned by authorizeX402 / haven.fetch. */
|
|
146
|
+
paymentId: string;
|
|
147
|
+
/** Original paid URL. If paymentRequired is omitted, Haven will call it once to re-read the 402 challenge. */
|
|
148
|
+
url: string;
|
|
149
|
+
/** Original fetch options. Reused for the 402 probe and final merchant retry. */
|
|
150
|
+
init?: RequestInit;
|
|
151
|
+
/** Original or freshly parsed x402 requirements. Supplying this avoids an extra merchant 402 probe. */
|
|
152
|
+
paymentRequired?: X402PaymentRequired;
|
|
153
|
+
}
|
|
154
|
+
type MachinePaymentRail = 'x402' | 'mpp_demo' | 'mpp_crypto' | 'stripe_deposit' | 'spt';
|
|
155
|
+
interface MachinePaymentChallenge {
|
|
156
|
+
rail: MachinePaymentRail;
|
|
157
|
+
version: string;
|
|
158
|
+
challengeId: string;
|
|
159
|
+
resource: string;
|
|
160
|
+
description: string;
|
|
161
|
+
network: {
|
|
162
|
+
chainId: number;
|
|
163
|
+
name: 'base';
|
|
164
|
+
};
|
|
165
|
+
asset: {
|
|
166
|
+
symbol: 'USDC';
|
|
167
|
+
address: string;
|
|
168
|
+
decimals: 6;
|
|
169
|
+
};
|
|
170
|
+
amount: {
|
|
171
|
+
display: string;
|
|
172
|
+
atomic: string;
|
|
173
|
+
};
|
|
174
|
+
recipient: string;
|
|
175
|
+
expiresAt: string;
|
|
176
|
+
metadata?: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
interface MachinePaymentReceipt {
|
|
179
|
+
success: boolean;
|
|
180
|
+
rail: MachinePaymentRail;
|
|
181
|
+
paymentId: string;
|
|
182
|
+
challengeId: string;
|
|
183
|
+
txHash: string;
|
|
184
|
+
token: string;
|
|
185
|
+
amount: string;
|
|
186
|
+
to: string;
|
|
187
|
+
resourceUrl: string;
|
|
188
|
+
explorerUrl: string;
|
|
189
|
+
payer?: string;
|
|
190
|
+
chainId?: number;
|
|
191
|
+
proofHeader: string;
|
|
192
|
+
}
|
|
193
|
+
type PaymentStateKind = 'payment_intent' | 'approval_request';
|
|
194
|
+
type PaymentPhase = 'agent_signature_required' | 'payment_submitted' | 'payment_confirmed' | 'user_approval_required' | 'user_execution_required' | 'waiting_for_additional_approvals' | 'funding_sent' | 'rejected' | 'expired' | 'failed';
|
|
195
|
+
type PaymentNextAction = 'sign_and_submit_payment' | 'check_status_later' | 'none' | 'wait_for_user_approval' | 'wait_for_user_to_complete_payment' | 'retry_original_x402_request' | 'stop_and_tell_user' | 'request_again_if_user_still_wants_it';
|
|
196
|
+
interface PaymentStatusResult {
|
|
197
|
+
paymentId: string;
|
|
198
|
+
kind: PaymentStateKind;
|
|
199
|
+
rail: string;
|
|
200
|
+
status: PaymentStatus | string;
|
|
201
|
+
phase: PaymentPhase;
|
|
202
|
+
nextAction: PaymentNextAction;
|
|
203
|
+
amount: string;
|
|
204
|
+
token: string;
|
|
205
|
+
resourceUrl: string | null;
|
|
206
|
+
merchantAddress: string | null;
|
|
207
|
+
txHash: string | null;
|
|
208
|
+
expiresAt: string;
|
|
209
|
+
chainId: number;
|
|
210
|
+
message: string;
|
|
211
|
+
}
|
|
212
|
+
interface PendingApproval extends PaymentStatusResult {
|
|
213
|
+
kind: 'approval_request';
|
|
214
|
+
status: 'pending_approval' | 'pending' | string;
|
|
215
|
+
phase: 'user_approval_required';
|
|
216
|
+
nextAction: 'wait_for_user_approval';
|
|
217
|
+
requested?: string;
|
|
218
|
+
remaining?: string | null;
|
|
116
219
|
}
|
|
117
220
|
declare class HavenError extends Error {
|
|
118
221
|
readonly code: string;
|
|
@@ -122,7 +225,14 @@ declare class HavenError extends Error {
|
|
|
122
225
|
}
|
|
123
226
|
declare class HavenApiError extends HavenError {
|
|
124
227
|
readonly body?: unknown | undefined;
|
|
125
|
-
constructor(message: string, statusCode: number, body?: unknown | undefined);
|
|
228
|
+
constructor(message: string, statusCode: number, body?: unknown | undefined, paymentId?: string);
|
|
229
|
+
}
|
|
230
|
+
declare class HavenPaymentStateError extends HavenApiError {
|
|
231
|
+
readonly state: PaymentStatusResult;
|
|
232
|
+
constructor(message: string, statusCode: number, state: PaymentStatusResult, body?: unknown);
|
|
233
|
+
get status(): string;
|
|
234
|
+
get phase(): PaymentPhase;
|
|
235
|
+
get nextAction(): PaymentNextAction;
|
|
126
236
|
}
|
|
127
237
|
declare class HavenSigningError extends HavenError {
|
|
128
238
|
constructor(message: string);
|
|
@@ -141,6 +251,7 @@ declare class HavenClient {
|
|
|
141
251
|
private readonly pollingInterval;
|
|
142
252
|
private readonly inFlightX402;
|
|
143
253
|
private readonly x402ReceiptCache;
|
|
254
|
+
private readonly inFlightMachinePayments;
|
|
144
255
|
/** Delegate address derived from the private key (if provided) */
|
|
145
256
|
readonly delegateAddress: string | undefined;
|
|
146
257
|
constructor(config: HavenClientConfig);
|
|
@@ -179,6 +290,13 @@ declare class HavenClient {
|
|
|
179
290
|
* Get the current status of a payment.
|
|
180
291
|
*/
|
|
181
292
|
getPayment(paymentId: string): Promise<PaymentResult>;
|
|
293
|
+
/**
|
|
294
|
+
* Get agent-actionable status for a payment intent or approval request.
|
|
295
|
+
*
|
|
296
|
+
* Use this for IDs returned by agent tools and machine-payment/x402 flows.
|
|
297
|
+
* `getPayment()` remains available for payment-intent-only integrations.
|
|
298
|
+
*/
|
|
299
|
+
getPaymentStatus(paymentId: string): Promise<PaymentStatusResult>;
|
|
182
300
|
/**
|
|
183
301
|
* Poll until a payment reaches a terminal status (confirmed, failed, expired).
|
|
184
302
|
*/
|
|
@@ -192,8 +310,10 @@ declare class HavenClient {
|
|
|
192
310
|
*
|
|
193
311
|
* Requires `delegateKey` to be set in the client config.
|
|
194
312
|
*/
|
|
195
|
-
authorizeX402(paymentRequired: X402PaymentRequired): Promise<X402Receipt>;
|
|
313
|
+
authorizeX402(paymentRequired: X402PaymentRequired, options?: X402AuthorizationOptions): Promise<X402Receipt>;
|
|
196
314
|
private authorizeStandardX402;
|
|
315
|
+
resumeAuthorizedX402(input: ResumeAuthorizedX402Input): Promise<X402Receipt>;
|
|
316
|
+
resumeX402Payment(input: ResumeX402PaymentInput): Promise<Response>;
|
|
197
317
|
/**
|
|
198
318
|
* Fetch wrapper that automatically handles HTTP 402 responses.
|
|
199
319
|
*
|
|
@@ -207,9 +327,23 @@ declare class HavenClient {
|
|
|
207
327
|
*
|
|
208
328
|
* Requires `delegateKey` to be set in the client config.
|
|
209
329
|
*/
|
|
210
|
-
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
330
|
+
fetch(url: string, init?: RequestInit, options?: X402AuthorizationOptions): Promise<Response>;
|
|
331
|
+
private retryX402Request;
|
|
332
|
+
authorizeMachinePayment(challenge: MachinePaymentChallenge): Promise<MachinePaymentReceipt>;
|
|
333
|
+
private authorizeMppDemoPayment;
|
|
334
|
+
private fetchWithMachinePayment;
|
|
335
|
+
private assertCanResumeX402;
|
|
336
|
+
private mapX402ReceiptFromAuthorization;
|
|
337
|
+
private mapX402ReceiptFromStatus;
|
|
338
|
+
private buildX402Receipt;
|
|
211
339
|
private createStandardX402Header;
|
|
212
340
|
private cacheX402Receipt;
|
|
341
|
+
private mapMachinePaymentReceipt;
|
|
342
|
+
private recordMerchantRetryRejected;
|
|
343
|
+
private reportMachinePaymentEvidence;
|
|
344
|
+
private throwIfNonSignableAuthorizationState;
|
|
345
|
+
private throwPaymentStateError;
|
|
346
|
+
private paymentStateFromRaw;
|
|
213
347
|
private x402PayerAddress;
|
|
214
348
|
private withX402Wallet;
|
|
215
349
|
/**
|
|
@@ -225,10 +359,14 @@ declare class HavenClient {
|
|
|
225
359
|
* ```
|
|
226
360
|
*/
|
|
227
361
|
executeTool(toolName: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
362
|
+
private toolX402PaymentRequired;
|
|
363
|
+
private x402ToolReceipt;
|
|
364
|
+
private toolError;
|
|
228
365
|
private post;
|
|
229
366
|
private get;
|
|
230
367
|
private request;
|
|
231
368
|
private mapPaymentResult;
|
|
369
|
+
private mapPaymentStatusResult;
|
|
232
370
|
}
|
|
233
371
|
|
|
234
372
|
/**
|
|
@@ -353,4 +491,9 @@ declare function encodePaymentProof(receipt: {
|
|
|
353
491
|
chainId?: number;
|
|
354
492
|
}): string;
|
|
355
493
|
|
|
356
|
-
|
|
494
|
+
declare function parseMachinePaymentChallenge(response: Response): MachinePaymentChallenge;
|
|
495
|
+
declare function parseMachinePaymentChallengeResponse(response: Response): Promise<MachinePaymentChallenge>;
|
|
496
|
+
declare function buildMachinePaymentIdempotencyKey(challenge: MachinePaymentChallenge): string;
|
|
497
|
+
declare function encodeMachinePaymentProof(receipt: Omit<MachinePaymentReceipt, 'proofHeader'>): string;
|
|
498
|
+
|
|
499
|
+
export { type ClaudeTool, HavenApiError, HavenClient, type HavenClientConfig, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type OpenAITool, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentRequest, type PaymentResult, type PaymentStatus, type PaymentStatusResult, type PendingApproval, type ResumeAuthorizedX402Input, type ResumeX402PaymentInput, type SignData, type X402AuthorizationOptions, type X402PaymentOption, type X402PaymentRequired, type X402Receipt, addressFromKey, buildMachinePaymentIdempotencyKey, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, signHash, verifySignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ interface PaymentIntent {
|
|
|
48
48
|
/** Data needed to sign the payment */
|
|
49
49
|
signData: SignData;
|
|
50
50
|
}
|
|
51
|
-
type PaymentStatus = 'pending_signature' | 'submitted' | 'confirmed' | 'expired' | 'failed';
|
|
51
|
+
type PaymentStatus = 'pending_signature' | 'submitted' | 'confirmed' | 'pending_approval' | 'approved' | 'proposed' | 'executed' | 'rejected' | 'expired' | 'failed';
|
|
52
52
|
interface PaymentResult {
|
|
53
53
|
/** Unique payment ID */
|
|
54
54
|
paymentId: string;
|
|
@@ -113,6 +113,109 @@ interface X402Receipt {
|
|
|
113
113
|
merchantTo?: string | null;
|
|
114
114
|
payer?: string;
|
|
115
115
|
chainId?: number;
|
|
116
|
+
haven?: {
|
|
117
|
+
paymentId: string;
|
|
118
|
+
fundingTxHash: string;
|
|
119
|
+
fundingExplorerUrl: string;
|
|
120
|
+
};
|
|
121
|
+
merchant?: {
|
|
122
|
+
payTo: string | null;
|
|
123
|
+
settlementTxHash?: string | null;
|
|
124
|
+
settlementExplorerUrl?: string | null;
|
|
125
|
+
};
|
|
126
|
+
x402?: {
|
|
127
|
+
amount: string;
|
|
128
|
+
token: string;
|
|
129
|
+
network: string;
|
|
130
|
+
asset: string;
|
|
131
|
+
resource: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
interface X402AuthorizationOptions {
|
|
135
|
+
/** Stable caller-supplied key for this user intent. Prevents duplicate approvals across fresh 402 quotes. */
|
|
136
|
+
idempotencyKey?: string;
|
|
137
|
+
}
|
|
138
|
+
interface ResumeAuthorizedX402Input extends X402AuthorizationOptions {
|
|
139
|
+
/** Payment or approval request ID returned by authorizeX402 / haven.fetch. */
|
|
140
|
+
paymentId: string;
|
|
141
|
+
/** Original or freshly parsed x402 requirements for the merchant retry. */
|
|
142
|
+
paymentRequired: X402PaymentRequired;
|
|
143
|
+
}
|
|
144
|
+
interface ResumeX402PaymentInput extends X402AuthorizationOptions {
|
|
145
|
+
/** Payment or approval request ID returned by authorizeX402 / haven.fetch. */
|
|
146
|
+
paymentId: string;
|
|
147
|
+
/** Original paid URL. If paymentRequired is omitted, Haven will call it once to re-read the 402 challenge. */
|
|
148
|
+
url: string;
|
|
149
|
+
/** Original fetch options. Reused for the 402 probe and final merchant retry. */
|
|
150
|
+
init?: RequestInit;
|
|
151
|
+
/** Original or freshly parsed x402 requirements. Supplying this avoids an extra merchant 402 probe. */
|
|
152
|
+
paymentRequired?: X402PaymentRequired;
|
|
153
|
+
}
|
|
154
|
+
type MachinePaymentRail = 'x402' | 'mpp_demo' | 'mpp_crypto' | 'stripe_deposit' | 'spt';
|
|
155
|
+
interface MachinePaymentChallenge {
|
|
156
|
+
rail: MachinePaymentRail;
|
|
157
|
+
version: string;
|
|
158
|
+
challengeId: string;
|
|
159
|
+
resource: string;
|
|
160
|
+
description: string;
|
|
161
|
+
network: {
|
|
162
|
+
chainId: number;
|
|
163
|
+
name: 'base';
|
|
164
|
+
};
|
|
165
|
+
asset: {
|
|
166
|
+
symbol: 'USDC';
|
|
167
|
+
address: string;
|
|
168
|
+
decimals: 6;
|
|
169
|
+
};
|
|
170
|
+
amount: {
|
|
171
|
+
display: string;
|
|
172
|
+
atomic: string;
|
|
173
|
+
};
|
|
174
|
+
recipient: string;
|
|
175
|
+
expiresAt: string;
|
|
176
|
+
metadata?: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
interface MachinePaymentReceipt {
|
|
179
|
+
success: boolean;
|
|
180
|
+
rail: MachinePaymentRail;
|
|
181
|
+
paymentId: string;
|
|
182
|
+
challengeId: string;
|
|
183
|
+
txHash: string;
|
|
184
|
+
token: string;
|
|
185
|
+
amount: string;
|
|
186
|
+
to: string;
|
|
187
|
+
resourceUrl: string;
|
|
188
|
+
explorerUrl: string;
|
|
189
|
+
payer?: string;
|
|
190
|
+
chainId?: number;
|
|
191
|
+
proofHeader: string;
|
|
192
|
+
}
|
|
193
|
+
type PaymentStateKind = 'payment_intent' | 'approval_request';
|
|
194
|
+
type PaymentPhase = 'agent_signature_required' | 'payment_submitted' | 'payment_confirmed' | 'user_approval_required' | 'user_execution_required' | 'waiting_for_additional_approvals' | 'funding_sent' | 'rejected' | 'expired' | 'failed';
|
|
195
|
+
type PaymentNextAction = 'sign_and_submit_payment' | 'check_status_later' | 'none' | 'wait_for_user_approval' | 'wait_for_user_to_complete_payment' | 'retry_original_x402_request' | 'stop_and_tell_user' | 'request_again_if_user_still_wants_it';
|
|
196
|
+
interface PaymentStatusResult {
|
|
197
|
+
paymentId: string;
|
|
198
|
+
kind: PaymentStateKind;
|
|
199
|
+
rail: string;
|
|
200
|
+
status: PaymentStatus | string;
|
|
201
|
+
phase: PaymentPhase;
|
|
202
|
+
nextAction: PaymentNextAction;
|
|
203
|
+
amount: string;
|
|
204
|
+
token: string;
|
|
205
|
+
resourceUrl: string | null;
|
|
206
|
+
merchantAddress: string | null;
|
|
207
|
+
txHash: string | null;
|
|
208
|
+
expiresAt: string;
|
|
209
|
+
chainId: number;
|
|
210
|
+
message: string;
|
|
211
|
+
}
|
|
212
|
+
interface PendingApproval extends PaymentStatusResult {
|
|
213
|
+
kind: 'approval_request';
|
|
214
|
+
status: 'pending_approval' | 'pending' | string;
|
|
215
|
+
phase: 'user_approval_required';
|
|
216
|
+
nextAction: 'wait_for_user_approval';
|
|
217
|
+
requested?: string;
|
|
218
|
+
remaining?: string | null;
|
|
116
219
|
}
|
|
117
220
|
declare class HavenError extends Error {
|
|
118
221
|
readonly code: string;
|
|
@@ -122,7 +225,14 @@ declare class HavenError extends Error {
|
|
|
122
225
|
}
|
|
123
226
|
declare class HavenApiError extends HavenError {
|
|
124
227
|
readonly body?: unknown | undefined;
|
|
125
|
-
constructor(message: string, statusCode: number, body?: unknown | undefined);
|
|
228
|
+
constructor(message: string, statusCode: number, body?: unknown | undefined, paymentId?: string);
|
|
229
|
+
}
|
|
230
|
+
declare class HavenPaymentStateError extends HavenApiError {
|
|
231
|
+
readonly state: PaymentStatusResult;
|
|
232
|
+
constructor(message: string, statusCode: number, state: PaymentStatusResult, body?: unknown);
|
|
233
|
+
get status(): string;
|
|
234
|
+
get phase(): PaymentPhase;
|
|
235
|
+
get nextAction(): PaymentNextAction;
|
|
126
236
|
}
|
|
127
237
|
declare class HavenSigningError extends HavenError {
|
|
128
238
|
constructor(message: string);
|
|
@@ -141,6 +251,7 @@ declare class HavenClient {
|
|
|
141
251
|
private readonly pollingInterval;
|
|
142
252
|
private readonly inFlightX402;
|
|
143
253
|
private readonly x402ReceiptCache;
|
|
254
|
+
private readonly inFlightMachinePayments;
|
|
144
255
|
/** Delegate address derived from the private key (if provided) */
|
|
145
256
|
readonly delegateAddress: string | undefined;
|
|
146
257
|
constructor(config: HavenClientConfig);
|
|
@@ -179,6 +290,13 @@ declare class HavenClient {
|
|
|
179
290
|
* Get the current status of a payment.
|
|
180
291
|
*/
|
|
181
292
|
getPayment(paymentId: string): Promise<PaymentResult>;
|
|
293
|
+
/**
|
|
294
|
+
* Get agent-actionable status for a payment intent or approval request.
|
|
295
|
+
*
|
|
296
|
+
* Use this for IDs returned by agent tools and machine-payment/x402 flows.
|
|
297
|
+
* `getPayment()` remains available for payment-intent-only integrations.
|
|
298
|
+
*/
|
|
299
|
+
getPaymentStatus(paymentId: string): Promise<PaymentStatusResult>;
|
|
182
300
|
/**
|
|
183
301
|
* Poll until a payment reaches a terminal status (confirmed, failed, expired).
|
|
184
302
|
*/
|
|
@@ -192,8 +310,10 @@ declare class HavenClient {
|
|
|
192
310
|
*
|
|
193
311
|
* Requires `delegateKey` to be set in the client config.
|
|
194
312
|
*/
|
|
195
|
-
authorizeX402(paymentRequired: X402PaymentRequired): Promise<X402Receipt>;
|
|
313
|
+
authorizeX402(paymentRequired: X402PaymentRequired, options?: X402AuthorizationOptions): Promise<X402Receipt>;
|
|
196
314
|
private authorizeStandardX402;
|
|
315
|
+
resumeAuthorizedX402(input: ResumeAuthorizedX402Input): Promise<X402Receipt>;
|
|
316
|
+
resumeX402Payment(input: ResumeX402PaymentInput): Promise<Response>;
|
|
197
317
|
/**
|
|
198
318
|
* Fetch wrapper that automatically handles HTTP 402 responses.
|
|
199
319
|
*
|
|
@@ -207,9 +327,23 @@ declare class HavenClient {
|
|
|
207
327
|
*
|
|
208
328
|
* Requires `delegateKey` to be set in the client config.
|
|
209
329
|
*/
|
|
210
|
-
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
330
|
+
fetch(url: string, init?: RequestInit, options?: X402AuthorizationOptions): Promise<Response>;
|
|
331
|
+
private retryX402Request;
|
|
332
|
+
authorizeMachinePayment(challenge: MachinePaymentChallenge): Promise<MachinePaymentReceipt>;
|
|
333
|
+
private authorizeMppDemoPayment;
|
|
334
|
+
private fetchWithMachinePayment;
|
|
335
|
+
private assertCanResumeX402;
|
|
336
|
+
private mapX402ReceiptFromAuthorization;
|
|
337
|
+
private mapX402ReceiptFromStatus;
|
|
338
|
+
private buildX402Receipt;
|
|
211
339
|
private createStandardX402Header;
|
|
212
340
|
private cacheX402Receipt;
|
|
341
|
+
private mapMachinePaymentReceipt;
|
|
342
|
+
private recordMerchantRetryRejected;
|
|
343
|
+
private reportMachinePaymentEvidence;
|
|
344
|
+
private throwIfNonSignableAuthorizationState;
|
|
345
|
+
private throwPaymentStateError;
|
|
346
|
+
private paymentStateFromRaw;
|
|
213
347
|
private x402PayerAddress;
|
|
214
348
|
private withX402Wallet;
|
|
215
349
|
/**
|
|
@@ -225,10 +359,14 @@ declare class HavenClient {
|
|
|
225
359
|
* ```
|
|
226
360
|
*/
|
|
227
361
|
executeTool(toolName: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
362
|
+
private toolX402PaymentRequired;
|
|
363
|
+
private x402ToolReceipt;
|
|
364
|
+
private toolError;
|
|
228
365
|
private post;
|
|
229
366
|
private get;
|
|
230
367
|
private request;
|
|
231
368
|
private mapPaymentResult;
|
|
369
|
+
private mapPaymentStatusResult;
|
|
232
370
|
}
|
|
233
371
|
|
|
234
372
|
/**
|
|
@@ -353,4 +491,9 @@ declare function encodePaymentProof(receipt: {
|
|
|
353
491
|
chainId?: number;
|
|
354
492
|
}): string;
|
|
355
493
|
|
|
356
|
-
|
|
494
|
+
declare function parseMachinePaymentChallenge(response: Response): MachinePaymentChallenge;
|
|
495
|
+
declare function parseMachinePaymentChallengeResponse(response: Response): Promise<MachinePaymentChallenge>;
|
|
496
|
+
declare function buildMachinePaymentIdempotencyKey(challenge: MachinePaymentChallenge): string;
|
|
497
|
+
declare function encodeMachinePaymentProof(receipt: Omit<MachinePaymentReceipt, 'proofHeader'>): string;
|
|
498
|
+
|
|
499
|
+
export { type ClaudeTool, HavenApiError, HavenClient, type HavenClientConfig, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type OpenAITool, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentRequest, type PaymentResult, type PaymentStatus, type PaymentStatusResult, type PendingApproval, type ResumeAuthorizedX402Input, type ResumeX402PaymentInput, type SignData, type X402AuthorizationOptions, type X402PaymentOption, type X402PaymentRequired, type X402Receipt, addressFromKey, buildMachinePaymentIdempotencyKey, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, signHash, verifySignature };
|