@useagentpay/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 +149 -0
- package/dist/index.cjs +2590 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -12
- package/dist/index.d.ts +163 -12
- package/dist/index.js +2561 -153
- package/dist/index.js.map +1 -1
- package/package.json +37 -18
- package/LICENSE +0 -21
- package/dist/cli.cjs +0 -2758
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2728
- package/dist/cli.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Stagehand } from '@browserbasehq/stagehand';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
|
|
1
4
|
interface BillingCredentials {
|
|
2
5
|
card: {
|
|
3
6
|
number: string;
|
|
@@ -82,15 +85,27 @@ interface ProposeOptions {
|
|
|
82
85
|
url: string;
|
|
83
86
|
}
|
|
84
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Abstraction over how a Stagehand browser instance is created.
|
|
90
|
+
* Implement this interface to plug in a custom browser backend
|
|
91
|
+
* (e.g. Browserbase, cloud Playwright, etc.).
|
|
92
|
+
*/
|
|
93
|
+
interface BrowserProvider {
|
|
94
|
+
createStagehand(modelApiKey?: string): Stagehand;
|
|
95
|
+
close(): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
interface CheckoutResult {
|
|
86
99
|
success: boolean;
|
|
87
100
|
confirmationId?: string;
|
|
88
101
|
error?: string;
|
|
89
102
|
}
|
|
90
103
|
interface ExecutorConfig {
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
/** Custom browser provider. Defaults to LocalBrowserProvider (local Chromium). */
|
|
105
|
+
provider?: BrowserProvider;
|
|
106
|
+
/** LLM API key for Stagehand's AI-driven navigation (e.g. ANTHROPIC_API_KEY). */
|
|
93
107
|
modelApiKey?: string;
|
|
108
|
+
proxyUrl?: string;
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
declare class NotSetupError extends Error {
|
|
@@ -182,6 +197,19 @@ declare class BudgetManager {
|
|
|
182
197
|
initWallet(budget: number, limitPerTx?: number): void;
|
|
183
198
|
}
|
|
184
199
|
|
|
200
|
+
interface AgentPayConfig {
|
|
201
|
+
/** When true, approval links are tunneled via Cloudflare for mobile access */
|
|
202
|
+
mobileMode: boolean;
|
|
203
|
+
/** Shell command to send notification. {{url}} is replaced with the approval URL. */
|
|
204
|
+
notifyCommand?: string;
|
|
205
|
+
/** Webhook URL to POST approval payload to */
|
|
206
|
+
notifyWebhook?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare function loadConfig(home?: string): AgentPayConfig;
|
|
210
|
+
declare function saveConfig(config: AgentPayConfig, home?: string): void;
|
|
211
|
+
declare function setMobileMode(enabled: boolean, home?: string): AgentPayConfig;
|
|
212
|
+
|
|
185
213
|
declare class TransactionManager {
|
|
186
214
|
private txPath;
|
|
187
215
|
constructor(txPath?: string);
|
|
@@ -220,8 +248,11 @@ interface DiscoverResult {
|
|
|
220
248
|
productName: string;
|
|
221
249
|
}
|
|
222
250
|
declare class PurchaseExecutor {
|
|
223
|
-
private
|
|
251
|
+
private provider;
|
|
252
|
+
private modelApiKey?;
|
|
224
253
|
private stagehand;
|
|
254
|
+
private proxyUrl;
|
|
255
|
+
private originalBaseUrl;
|
|
225
256
|
constructor(config?: ExecutorConfig);
|
|
226
257
|
private createStagehand;
|
|
227
258
|
/**
|
|
@@ -263,6 +294,121 @@ declare const PLACEHOLDER_MAP: {
|
|
|
263
294
|
declare function getPlaceholderVariables(): Record<string, string>;
|
|
264
295
|
declare function credentialsToSwapMap(creds: BillingCredentials): Record<string, string>;
|
|
265
296
|
|
|
297
|
+
interface ApprovalResult {
|
|
298
|
+
action: 'approved' | 'rejected';
|
|
299
|
+
passphrase?: string;
|
|
300
|
+
reason?: string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Launch an ephemeral HTTP server on localhost, open a browser page
|
|
304
|
+
* where the human can approve or deny the transaction.
|
|
305
|
+
* On approve: server-side signing is performed, passphrase returned in result.
|
|
306
|
+
* On deny: transaction is rejected.
|
|
307
|
+
*/
|
|
308
|
+
declare function requestBrowserApproval(tx: Transaction, tm: TransactionManager, audit: AuditLogger, home?: string): Promise<ApprovalResult>;
|
|
309
|
+
|
|
310
|
+
interface NotifyOptions {
|
|
311
|
+
/** Shell command to run. `{{url}}` is replaced with the approval URL. */
|
|
312
|
+
command?: string;
|
|
313
|
+
/** Webhook URL to POST `{ url, txId, merchant, amount }` to. */
|
|
314
|
+
webhookUrl?: string;
|
|
315
|
+
}
|
|
316
|
+
interface NotifyPayload {
|
|
317
|
+
url: string;
|
|
318
|
+
txId: string;
|
|
319
|
+
merchant: string;
|
|
320
|
+
amount: number;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Send a notification about a pending mobile approval.
|
|
324
|
+
*
|
|
325
|
+
* Supports two delivery methods (both can be used simultaneously):
|
|
326
|
+
* - `command`: Shell command with `{{url}}` placeholder (e.g. send via iMessage, Telegram, etc.)
|
|
327
|
+
* - `webhookUrl`: HTTP POST endpoint that receives JSON payload
|
|
328
|
+
*
|
|
329
|
+
* Returns an array of results (one per delivery method attempted).
|
|
330
|
+
*/
|
|
331
|
+
declare function sendNotification(payload: NotifyPayload, options: NotifyOptions): Promise<{
|
|
332
|
+
method: string;
|
|
333
|
+
success: boolean;
|
|
334
|
+
error?: string;
|
|
335
|
+
}[]>;
|
|
336
|
+
|
|
337
|
+
interface MobileApprovalOptions {
|
|
338
|
+
/** Notification delivery options */
|
|
339
|
+
notify: NotifyOptions;
|
|
340
|
+
/** AgentPay home directory */
|
|
341
|
+
home?: string;
|
|
342
|
+
}
|
|
343
|
+
interface MobileApprovalResult extends ApprovalResult {
|
|
344
|
+
/** Public URL that was sent to the user */
|
|
345
|
+
approvalUrl: string;
|
|
346
|
+
/** Notification delivery results */
|
|
347
|
+
notifyResults: {
|
|
348
|
+
method: string;
|
|
349
|
+
success: boolean;
|
|
350
|
+
error?: string;
|
|
351
|
+
}[];
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Request approval via a publicly accessible URL.
|
|
355
|
+
*
|
|
356
|
+
* Flow:
|
|
357
|
+
* 1. Start the local approval server (no browser opened)
|
|
358
|
+
* 2. Open a tunnel to expose it publicly
|
|
359
|
+
* 3. Send the tunnel URL to the user via configured notification method
|
|
360
|
+
* 4. Wait for the user to approve/reject (same as browser flow)
|
|
361
|
+
* 5. Clean up tunnel when done
|
|
362
|
+
*/
|
|
363
|
+
declare function requestMobileApproval(tx: Transaction, tm: TransactionManager, audit: AuditLogger, options: MobileApprovalOptions): Promise<MobileApprovalResult>;
|
|
364
|
+
|
|
365
|
+
interface TunnelHandle {
|
|
366
|
+
url: string;
|
|
367
|
+
close: () => void;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Expose a local port via a public HTTPS tunnel using Cloudflare Quick Tunnels.
|
|
371
|
+
*
|
|
372
|
+
* Requires `cloudflared` to be installed on the system. No Cloudflare account
|
|
373
|
+
* needed — quick tunnels generate a random `*.trycloudflare.com` URL.
|
|
374
|
+
*
|
|
375
|
+
* The tunnel process is spawned as a child process and killed when `close()` is called.
|
|
376
|
+
*/
|
|
377
|
+
declare function openTunnel(port: number): Promise<TunnelHandle>;
|
|
378
|
+
|
|
379
|
+
interface SetupResult {
|
|
380
|
+
completed: boolean;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Launch an ephemeral HTTP server on localhost, open a browser page
|
|
384
|
+
* where the human fills in credentials, passphrase, and budget.
|
|
385
|
+
* All sensitive data stays in the browser->server HTTP request on localhost.
|
|
386
|
+
* Never touches stdout/terminal.
|
|
387
|
+
*/
|
|
388
|
+
declare function requestBrowserSetup(home?: string): Promise<SetupResult>;
|
|
389
|
+
|
|
390
|
+
declare function startServer(port: number): Promise<ReturnType<typeof createServer>>;
|
|
391
|
+
|
|
392
|
+
declare function openBrowser(url: string): void;
|
|
393
|
+
|
|
394
|
+
interface PassphraseContext {
|
|
395
|
+
action: 'buy' | 'approve';
|
|
396
|
+
merchant?: string;
|
|
397
|
+
amount?: number;
|
|
398
|
+
description?: string;
|
|
399
|
+
txId?: string;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare function promptInput(question: string): Promise<string>;
|
|
403
|
+
declare function promptPassphrase(prompt?: string): Promise<string>;
|
|
404
|
+
declare function promptConfirm(question: string): Promise<boolean>;
|
|
405
|
+
/**
|
|
406
|
+
* Collect passphrase safely: uses terminal prompt when stdin is a TTY,
|
|
407
|
+
* otherwise opens a browser page so the human can enter it directly
|
|
408
|
+
* (keeping the passphrase out of the agent's context).
|
|
409
|
+
*/
|
|
410
|
+
declare function promptPassphraseSafe(context?: PassphraseContext): Promise<string>;
|
|
411
|
+
|
|
266
412
|
interface AgentPayOptions {
|
|
267
413
|
home?: string;
|
|
268
414
|
passphrase?: string;
|
|
@@ -289,13 +435,11 @@ declare class AgentPay {
|
|
|
289
435
|
limitPerTx: number;
|
|
290
436
|
remaining: number;
|
|
291
437
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
qrDataUrl: string;
|
|
298
|
-
}>;
|
|
438
|
+
};
|
|
439
|
+
get config(): {
|
|
440
|
+
get: () => AgentPayConfig;
|
|
441
|
+
setMobileMode: (enabled: boolean) => AgentPayConfig;
|
|
442
|
+
save: (config: AgentPayConfig) => void;
|
|
299
443
|
};
|
|
300
444
|
get transactions(): {
|
|
301
445
|
propose: (options: ProposeOptions) => Transaction;
|
|
@@ -307,6 +451,12 @@ declare class AgentPay {
|
|
|
307
451
|
status: "approved" | "rejected";
|
|
308
452
|
reason?: string;
|
|
309
453
|
}>;
|
|
454
|
+
requestApproval: (txId: string) => Promise<{
|
|
455
|
+
action: "approved" | "rejected";
|
|
456
|
+
passphrase?: string;
|
|
457
|
+
reason?: string;
|
|
458
|
+
}>;
|
|
459
|
+
requestMobileApproval: (txId: string, notify: NotifyOptions) => Promise<MobileApprovalResult>;
|
|
310
460
|
execute: (txId: string) => Promise<Receipt>;
|
|
311
461
|
getReceipt: (txId: string) => Receipt | undefined;
|
|
312
462
|
};
|
|
@@ -320,9 +470,10 @@ declare class AgentPay {
|
|
|
320
470
|
pending: Transaction[];
|
|
321
471
|
recent: Transaction[];
|
|
322
472
|
isSetup: boolean;
|
|
473
|
+
mobileMode: boolean;
|
|
323
474
|
};
|
|
324
475
|
}
|
|
325
476
|
|
|
326
|
-
declare const VERSION
|
|
477
|
+
declare const VERSION: string;
|
|
327
478
|
|
|
328
|
-
export { AgentPay, type AgentPayOptions, AlreadyExecutedError, AuditLogger, type BillingCredentials, BudgetManager, CheckoutFailedError, type CheckoutResult, DecryptError, type EncryptedVault, ExceedsTxLimitError, type ExecutorConfig, InsufficientBalanceError, InvalidMandateError, type KeyPair, NotApprovedError, NotSetupError, PLACEHOLDER_MAP, type ProposeOptions, PurchaseExecutor, type PurchaseMandate, type Receipt, TimeoutError, type Transaction, type TransactionDetails, TransactionManager, type TransactionStatus, VERSION, type Wallet, createMandate, credentialsToSwapMap, decrypt, encrypt, formatCurrency, formatStatus, formatTable, formatTimestamp, generateKeyPair, generateTxId, getAuditPath, getCredentialsPath, getHomePath, getKeysPath, getPlaceholderVariables, getTransactionsPath, getWalletPath, loadPrivateKey, loadPublicKey, loadVault, saveKeyPair, saveVault, verifyMandate, waitForApproval };
|
|
479
|
+
export { AgentPay, type AgentPayConfig, type AgentPayOptions, AlreadyExecutedError, type ApprovalResult, AuditLogger, type BillingCredentials, type BrowserProvider, BudgetManager, CheckoutFailedError, type CheckoutResult, DecryptError, type EncryptedVault, ExceedsTxLimitError, type ExecutorConfig, InsufficientBalanceError, InvalidMandateError, type KeyPair, type MobileApprovalOptions, type MobileApprovalResult, NotApprovedError, NotSetupError, type NotifyOptions, type NotifyPayload, PLACEHOLDER_MAP, type ProposeOptions, PurchaseExecutor, type PurchaseMandate, type Receipt, type SetupResult, TimeoutError, type Transaction, type TransactionDetails, TransactionManager, type TransactionStatus, type TunnelHandle, VERSION, type Wallet, createMandate, credentialsToSwapMap, decrypt, encrypt, formatCurrency, formatStatus, formatTable, formatTimestamp, generateKeyPair, generateTxId, getAuditPath, getCredentialsPath, getHomePath, getKeysPath, getPlaceholderVariables, getTransactionsPath, getWalletPath, loadConfig, loadPrivateKey, loadPublicKey, loadVault, openBrowser, openTunnel, promptConfirm, promptInput, promptPassphrase, promptPassphraseSafe, requestBrowserApproval, requestBrowserSetup, requestMobileApproval, saveConfig, saveKeyPair, saveVault, sendNotification, setMobileMode, startServer as startDashboardServer, verifyMandate, waitForApproval };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Stagehand } from '@browserbasehq/stagehand';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
|
|
1
4
|
interface BillingCredentials {
|
|
2
5
|
card: {
|
|
3
6
|
number: string;
|
|
@@ -82,15 +85,27 @@ interface ProposeOptions {
|
|
|
82
85
|
url: string;
|
|
83
86
|
}
|
|
84
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Abstraction over how a Stagehand browser instance is created.
|
|
90
|
+
* Implement this interface to plug in a custom browser backend
|
|
91
|
+
* (e.g. Browserbase, cloud Playwright, etc.).
|
|
92
|
+
*/
|
|
93
|
+
interface BrowserProvider {
|
|
94
|
+
createStagehand(modelApiKey?: string): Stagehand;
|
|
95
|
+
close(): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
interface CheckoutResult {
|
|
86
99
|
success: boolean;
|
|
87
100
|
confirmationId?: string;
|
|
88
101
|
error?: string;
|
|
89
102
|
}
|
|
90
103
|
interface ExecutorConfig {
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
/** Custom browser provider. Defaults to LocalBrowserProvider (local Chromium). */
|
|
105
|
+
provider?: BrowserProvider;
|
|
106
|
+
/** LLM API key for Stagehand's AI-driven navigation (e.g. ANTHROPIC_API_KEY). */
|
|
93
107
|
modelApiKey?: string;
|
|
108
|
+
proxyUrl?: string;
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
declare class NotSetupError extends Error {
|
|
@@ -182,6 +197,19 @@ declare class BudgetManager {
|
|
|
182
197
|
initWallet(budget: number, limitPerTx?: number): void;
|
|
183
198
|
}
|
|
184
199
|
|
|
200
|
+
interface AgentPayConfig {
|
|
201
|
+
/** When true, approval links are tunneled via Cloudflare for mobile access */
|
|
202
|
+
mobileMode: boolean;
|
|
203
|
+
/** Shell command to send notification. {{url}} is replaced with the approval URL. */
|
|
204
|
+
notifyCommand?: string;
|
|
205
|
+
/** Webhook URL to POST approval payload to */
|
|
206
|
+
notifyWebhook?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare function loadConfig(home?: string): AgentPayConfig;
|
|
210
|
+
declare function saveConfig(config: AgentPayConfig, home?: string): void;
|
|
211
|
+
declare function setMobileMode(enabled: boolean, home?: string): AgentPayConfig;
|
|
212
|
+
|
|
185
213
|
declare class TransactionManager {
|
|
186
214
|
private txPath;
|
|
187
215
|
constructor(txPath?: string);
|
|
@@ -220,8 +248,11 @@ interface DiscoverResult {
|
|
|
220
248
|
productName: string;
|
|
221
249
|
}
|
|
222
250
|
declare class PurchaseExecutor {
|
|
223
|
-
private
|
|
251
|
+
private provider;
|
|
252
|
+
private modelApiKey?;
|
|
224
253
|
private stagehand;
|
|
254
|
+
private proxyUrl;
|
|
255
|
+
private originalBaseUrl;
|
|
225
256
|
constructor(config?: ExecutorConfig);
|
|
226
257
|
private createStagehand;
|
|
227
258
|
/**
|
|
@@ -263,6 +294,121 @@ declare const PLACEHOLDER_MAP: {
|
|
|
263
294
|
declare function getPlaceholderVariables(): Record<string, string>;
|
|
264
295
|
declare function credentialsToSwapMap(creds: BillingCredentials): Record<string, string>;
|
|
265
296
|
|
|
297
|
+
interface ApprovalResult {
|
|
298
|
+
action: 'approved' | 'rejected';
|
|
299
|
+
passphrase?: string;
|
|
300
|
+
reason?: string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Launch an ephemeral HTTP server on localhost, open a browser page
|
|
304
|
+
* where the human can approve or deny the transaction.
|
|
305
|
+
* On approve: server-side signing is performed, passphrase returned in result.
|
|
306
|
+
* On deny: transaction is rejected.
|
|
307
|
+
*/
|
|
308
|
+
declare function requestBrowserApproval(tx: Transaction, tm: TransactionManager, audit: AuditLogger, home?: string): Promise<ApprovalResult>;
|
|
309
|
+
|
|
310
|
+
interface NotifyOptions {
|
|
311
|
+
/** Shell command to run. `{{url}}` is replaced with the approval URL. */
|
|
312
|
+
command?: string;
|
|
313
|
+
/** Webhook URL to POST `{ url, txId, merchant, amount }` to. */
|
|
314
|
+
webhookUrl?: string;
|
|
315
|
+
}
|
|
316
|
+
interface NotifyPayload {
|
|
317
|
+
url: string;
|
|
318
|
+
txId: string;
|
|
319
|
+
merchant: string;
|
|
320
|
+
amount: number;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Send a notification about a pending mobile approval.
|
|
324
|
+
*
|
|
325
|
+
* Supports two delivery methods (both can be used simultaneously):
|
|
326
|
+
* - `command`: Shell command with `{{url}}` placeholder (e.g. send via iMessage, Telegram, etc.)
|
|
327
|
+
* - `webhookUrl`: HTTP POST endpoint that receives JSON payload
|
|
328
|
+
*
|
|
329
|
+
* Returns an array of results (one per delivery method attempted).
|
|
330
|
+
*/
|
|
331
|
+
declare function sendNotification(payload: NotifyPayload, options: NotifyOptions): Promise<{
|
|
332
|
+
method: string;
|
|
333
|
+
success: boolean;
|
|
334
|
+
error?: string;
|
|
335
|
+
}[]>;
|
|
336
|
+
|
|
337
|
+
interface MobileApprovalOptions {
|
|
338
|
+
/** Notification delivery options */
|
|
339
|
+
notify: NotifyOptions;
|
|
340
|
+
/** AgentPay home directory */
|
|
341
|
+
home?: string;
|
|
342
|
+
}
|
|
343
|
+
interface MobileApprovalResult extends ApprovalResult {
|
|
344
|
+
/** Public URL that was sent to the user */
|
|
345
|
+
approvalUrl: string;
|
|
346
|
+
/** Notification delivery results */
|
|
347
|
+
notifyResults: {
|
|
348
|
+
method: string;
|
|
349
|
+
success: boolean;
|
|
350
|
+
error?: string;
|
|
351
|
+
}[];
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Request approval via a publicly accessible URL.
|
|
355
|
+
*
|
|
356
|
+
* Flow:
|
|
357
|
+
* 1. Start the local approval server (no browser opened)
|
|
358
|
+
* 2. Open a tunnel to expose it publicly
|
|
359
|
+
* 3. Send the tunnel URL to the user via configured notification method
|
|
360
|
+
* 4. Wait for the user to approve/reject (same as browser flow)
|
|
361
|
+
* 5. Clean up tunnel when done
|
|
362
|
+
*/
|
|
363
|
+
declare function requestMobileApproval(tx: Transaction, tm: TransactionManager, audit: AuditLogger, options: MobileApprovalOptions): Promise<MobileApprovalResult>;
|
|
364
|
+
|
|
365
|
+
interface TunnelHandle {
|
|
366
|
+
url: string;
|
|
367
|
+
close: () => void;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Expose a local port via a public HTTPS tunnel using Cloudflare Quick Tunnels.
|
|
371
|
+
*
|
|
372
|
+
* Requires `cloudflared` to be installed on the system. No Cloudflare account
|
|
373
|
+
* needed — quick tunnels generate a random `*.trycloudflare.com` URL.
|
|
374
|
+
*
|
|
375
|
+
* The tunnel process is spawned as a child process and killed when `close()` is called.
|
|
376
|
+
*/
|
|
377
|
+
declare function openTunnel(port: number): Promise<TunnelHandle>;
|
|
378
|
+
|
|
379
|
+
interface SetupResult {
|
|
380
|
+
completed: boolean;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Launch an ephemeral HTTP server on localhost, open a browser page
|
|
384
|
+
* where the human fills in credentials, passphrase, and budget.
|
|
385
|
+
* All sensitive data stays in the browser->server HTTP request on localhost.
|
|
386
|
+
* Never touches stdout/terminal.
|
|
387
|
+
*/
|
|
388
|
+
declare function requestBrowserSetup(home?: string): Promise<SetupResult>;
|
|
389
|
+
|
|
390
|
+
declare function startServer(port: number): Promise<ReturnType<typeof createServer>>;
|
|
391
|
+
|
|
392
|
+
declare function openBrowser(url: string): void;
|
|
393
|
+
|
|
394
|
+
interface PassphraseContext {
|
|
395
|
+
action: 'buy' | 'approve';
|
|
396
|
+
merchant?: string;
|
|
397
|
+
amount?: number;
|
|
398
|
+
description?: string;
|
|
399
|
+
txId?: string;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare function promptInput(question: string): Promise<string>;
|
|
403
|
+
declare function promptPassphrase(prompt?: string): Promise<string>;
|
|
404
|
+
declare function promptConfirm(question: string): Promise<boolean>;
|
|
405
|
+
/**
|
|
406
|
+
* Collect passphrase safely: uses terminal prompt when stdin is a TTY,
|
|
407
|
+
* otherwise opens a browser page so the human can enter it directly
|
|
408
|
+
* (keeping the passphrase out of the agent's context).
|
|
409
|
+
*/
|
|
410
|
+
declare function promptPassphraseSafe(context?: PassphraseContext): Promise<string>;
|
|
411
|
+
|
|
266
412
|
interface AgentPayOptions {
|
|
267
413
|
home?: string;
|
|
268
414
|
passphrase?: string;
|
|
@@ -289,13 +435,11 @@ declare class AgentPay {
|
|
|
289
435
|
limitPerTx: number;
|
|
290
436
|
remaining: number;
|
|
291
437
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
qrDataUrl: string;
|
|
298
|
-
}>;
|
|
438
|
+
};
|
|
439
|
+
get config(): {
|
|
440
|
+
get: () => AgentPayConfig;
|
|
441
|
+
setMobileMode: (enabled: boolean) => AgentPayConfig;
|
|
442
|
+
save: (config: AgentPayConfig) => void;
|
|
299
443
|
};
|
|
300
444
|
get transactions(): {
|
|
301
445
|
propose: (options: ProposeOptions) => Transaction;
|
|
@@ -307,6 +451,12 @@ declare class AgentPay {
|
|
|
307
451
|
status: "approved" | "rejected";
|
|
308
452
|
reason?: string;
|
|
309
453
|
}>;
|
|
454
|
+
requestApproval: (txId: string) => Promise<{
|
|
455
|
+
action: "approved" | "rejected";
|
|
456
|
+
passphrase?: string;
|
|
457
|
+
reason?: string;
|
|
458
|
+
}>;
|
|
459
|
+
requestMobileApproval: (txId: string, notify: NotifyOptions) => Promise<MobileApprovalResult>;
|
|
310
460
|
execute: (txId: string) => Promise<Receipt>;
|
|
311
461
|
getReceipt: (txId: string) => Receipt | undefined;
|
|
312
462
|
};
|
|
@@ -320,9 +470,10 @@ declare class AgentPay {
|
|
|
320
470
|
pending: Transaction[];
|
|
321
471
|
recent: Transaction[];
|
|
322
472
|
isSetup: boolean;
|
|
473
|
+
mobileMode: boolean;
|
|
323
474
|
};
|
|
324
475
|
}
|
|
325
476
|
|
|
326
|
-
declare const VERSION
|
|
477
|
+
declare const VERSION: string;
|
|
327
478
|
|
|
328
|
-
export { AgentPay, type AgentPayOptions, AlreadyExecutedError, AuditLogger, type BillingCredentials, BudgetManager, CheckoutFailedError, type CheckoutResult, DecryptError, type EncryptedVault, ExceedsTxLimitError, type ExecutorConfig, InsufficientBalanceError, InvalidMandateError, type KeyPair, NotApprovedError, NotSetupError, PLACEHOLDER_MAP, type ProposeOptions, PurchaseExecutor, type PurchaseMandate, type Receipt, TimeoutError, type Transaction, type TransactionDetails, TransactionManager, type TransactionStatus, VERSION, type Wallet, createMandate, credentialsToSwapMap, decrypt, encrypt, formatCurrency, formatStatus, formatTable, formatTimestamp, generateKeyPair, generateTxId, getAuditPath, getCredentialsPath, getHomePath, getKeysPath, getPlaceholderVariables, getTransactionsPath, getWalletPath, loadPrivateKey, loadPublicKey, loadVault, saveKeyPair, saveVault, verifyMandate, waitForApproval };
|
|
479
|
+
export { AgentPay, type AgentPayConfig, type AgentPayOptions, AlreadyExecutedError, type ApprovalResult, AuditLogger, type BillingCredentials, type BrowserProvider, BudgetManager, CheckoutFailedError, type CheckoutResult, DecryptError, type EncryptedVault, ExceedsTxLimitError, type ExecutorConfig, InsufficientBalanceError, InvalidMandateError, type KeyPair, type MobileApprovalOptions, type MobileApprovalResult, NotApprovedError, NotSetupError, type NotifyOptions, type NotifyPayload, PLACEHOLDER_MAP, type ProposeOptions, PurchaseExecutor, type PurchaseMandate, type Receipt, type SetupResult, TimeoutError, type Transaction, type TransactionDetails, TransactionManager, type TransactionStatus, type TunnelHandle, VERSION, type Wallet, createMandate, credentialsToSwapMap, decrypt, encrypt, formatCurrency, formatStatus, formatTable, formatTimestamp, generateKeyPair, generateTxId, getAuditPath, getCredentialsPath, getHomePath, getKeysPath, getPlaceholderVariables, getTransactionsPath, getWalletPath, loadConfig, loadPrivateKey, loadPublicKey, loadVault, openBrowser, openTunnel, promptConfirm, promptInput, promptPassphrase, promptPassphraseSafe, requestBrowserApproval, requestBrowserSetup, requestMobileApproval, saveConfig, saveKeyPair, saveVault, sendNotification, setMobileMode, startServer as startDashboardServer, verifyMandate, waitForApproval };
|