@paysentry/sandbox 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.
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mock-acp.d.ts +80 -0
- package/dist/mock-acp.d.ts.map +1 -0
- package/dist/mock-acp.js +136 -0
- package/dist/mock-acp.js.map +1 -0
- package/dist/mock-ap2.d.ts +88 -0
- package/dist/mock-ap2.d.ts.map +1 -0
- package/dist/mock-ap2.js +200 -0
- package/dist/mock-ap2.js.map +1 -0
- package/dist/mock-x402.d.ts +55 -0
- package/dist/mock-x402.d.ts.map +1 -0
- package/dist/mock-x402.js +118 -0
- package/dist/mock-x402.js.map +1 -0
- package/dist/scenarios.d.ts +40 -0
- package/dist/scenarios.d.ts.map +1 -0
- package/dist/scenarios.js +180 -0
- package/dist/scenarios.js.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { MockX402 } from './mock-x402.js';
|
|
2
|
+
export type { MockX402Config } from './mock-x402.js';
|
|
3
|
+
export { MockACP } from './mock-acp.js';
|
|
4
|
+
export type { MockACPConfig, MockPaymentMethod } from './mock-acp.js';
|
|
5
|
+
export { MockAP2 } from './mock-ap2.js';
|
|
6
|
+
export type { MockAP2Config, PaymentMandate } from './mock-ap2.js';
|
|
7
|
+
export { SCENARIO_BASIC_PAYMENT, SCENARIO_OVERSPEND, SCENARIO_APPROVAL_REQUIRED, SCENARIO_BLOCKED_RECIPIENT, SCENARIO_MULTI_PROTOCOL, SCENARIO_DISPUTE, SCENARIO_RATE_SPIKE, SCENARIO_TIMEOUT, SCENARIO_MULTI_AGENT, ALL_SCENARIOS, } from './scenarios.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,GACd,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// @paysentry/sandbox — Public API
|
|
3
|
+
// Mock multi-protocol payment environment for testing AI agent payments
|
|
4
|
+
// =============================================================================
|
|
5
|
+
export { MockX402 } from './mock-x402.js';
|
|
6
|
+
export { MockACP } from './mock-acp.js';
|
|
7
|
+
export { MockAP2 } from './mock-ap2.js';
|
|
8
|
+
export { SCENARIO_BASIC_PAYMENT, SCENARIO_OVERSPEND, SCENARIO_APPROVAL_REQUIRED, SCENARIO_BLOCKED_RECIPIENT, SCENARIO_MULTI_PROTOCOL, SCENARIO_DISPUTE, SCENARIO_RATE_SPIKE, SCENARIO_TIMEOUT, SCENARIO_MULTI_AGENT, ALL_SCENARIOS, } from './scenarios.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,kCAAkC;AAClC,wEAAwE;AACxE,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,GACd,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AgentTransaction, MockPaymentResult, Logger } from '@paysentry/core';
|
|
2
|
+
/** Configuration for the mock ACP endpoint */
|
|
3
|
+
export interface MockACPConfig {
|
|
4
|
+
/** Simulated processing latency in milliseconds (default: 200) */
|
|
5
|
+
readonly latencyMs?: number;
|
|
6
|
+
/** Simulated failure rate, 0.0 to 1.0 (default: 0) */
|
|
7
|
+
readonly failureRate?: number;
|
|
8
|
+
/** Simulated settlement time in milliseconds (default: 2000) */
|
|
9
|
+
readonly settlementMs?: number;
|
|
10
|
+
/** Merchants that will always decline (for testing) */
|
|
11
|
+
readonly declinedMerchants?: readonly string[];
|
|
12
|
+
/** Optional logger */
|
|
13
|
+
readonly logger?: Logger;
|
|
14
|
+
}
|
|
15
|
+
/** Payment method in the mock ACP system */
|
|
16
|
+
export interface MockPaymentMethod {
|
|
17
|
+
/** Method identifier */
|
|
18
|
+
readonly id: string;
|
|
19
|
+
/** Type of payment method */
|
|
20
|
+
readonly type: 'card' | 'bank_transfer' | 'wallet';
|
|
21
|
+
/** Whether this method is active */
|
|
22
|
+
readonly active: boolean;
|
|
23
|
+
/** Available balance (for wallet type) */
|
|
24
|
+
readonly balance?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* MockACP simulates the Agent Commerce Protocol, which handles
|
|
28
|
+
* traditional payment flows (similar to Stripe) for agent-to-merchant
|
|
29
|
+
* transactions.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const acp = new MockACP({
|
|
34
|
+
* declinedMerchants: ['merchant:blacklisted-shop'],
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* acp.addPaymentMethod({
|
|
38
|
+
* id: 'pm_default',
|
|
39
|
+
* type: 'wallet',
|
|
40
|
+
* active: true,
|
|
41
|
+
* balance: 1000,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const result = await acp.processPayment(transaction);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class MockACP {
|
|
48
|
+
private readonly config;
|
|
49
|
+
private readonly declinedMerchants;
|
|
50
|
+
private readonly paymentMethods;
|
|
51
|
+
/** Track all processed payments */
|
|
52
|
+
readonly processedPayments: MockPaymentResult[];
|
|
53
|
+
/** Transaction history */
|
|
54
|
+
readonly transactionLog: Array<{
|
|
55
|
+
readonly txId: string;
|
|
56
|
+
readonly amount: number;
|
|
57
|
+
readonly currency: string;
|
|
58
|
+
readonly merchant: string;
|
|
59
|
+
readonly timestamp: string;
|
|
60
|
+
}>;
|
|
61
|
+
constructor(config?: MockACPConfig);
|
|
62
|
+
/**
|
|
63
|
+
* Add a payment method to the mock ACP.
|
|
64
|
+
*/
|
|
65
|
+
addPaymentMethod(method: MockPaymentMethod): void;
|
|
66
|
+
/**
|
|
67
|
+
* Process a payment through the mock ACP.
|
|
68
|
+
*/
|
|
69
|
+
processPayment(tx: AgentTransaction): Promise<MockPaymentResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Get all payment methods.
|
|
72
|
+
*/
|
|
73
|
+
getPaymentMethods(): MockPaymentMethod[];
|
|
74
|
+
/**
|
|
75
|
+
* Reset the mock to initial state.
|
|
76
|
+
*/
|
|
77
|
+
reset(): void;
|
|
78
|
+
private sleep;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=mock-acp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC,CAAM;gBAEI,MAAM,CAAC,EAAE,aAAa;IAUlC;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAIjD;;OAEG;IACG,cAAc,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4EtE;;OAEG;IACH,iBAAiB,IAAI,iBAAiB,EAAE;IAIxC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/mock-acp.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// MockACP — Simulated Agent Commerce Protocol / Stripe endpoint
|
|
3
|
+
// Mimics traditional payment processing (card, subscription, one-time)
|
|
4
|
+
// =============================================================================
|
|
5
|
+
import { generateId } from '@paysentry/core';
|
|
6
|
+
/**
|
|
7
|
+
* MockACP simulates the Agent Commerce Protocol, which handles
|
|
8
|
+
* traditional payment flows (similar to Stripe) for agent-to-merchant
|
|
9
|
+
* transactions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const acp = new MockACP({
|
|
14
|
+
* declinedMerchants: ['merchant:blacklisted-shop'],
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* acp.addPaymentMethod({
|
|
18
|
+
* id: 'pm_default',
|
|
19
|
+
* type: 'wallet',
|
|
20
|
+
* active: true,
|
|
21
|
+
* balance: 1000,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const result = await acp.processPayment(transaction);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class MockACP {
|
|
28
|
+
config;
|
|
29
|
+
declinedMerchants;
|
|
30
|
+
paymentMethods = new Map();
|
|
31
|
+
/** Track all processed payments */
|
|
32
|
+
processedPayments = [];
|
|
33
|
+
/** Transaction history */
|
|
34
|
+
transactionLog = [];
|
|
35
|
+
constructor(config) {
|
|
36
|
+
this.config = {
|
|
37
|
+
latencyMs: config?.latencyMs ?? 200,
|
|
38
|
+
failureRate: config?.failureRate ?? 0,
|
|
39
|
+
settlementMs: config?.settlementMs ?? 2000,
|
|
40
|
+
...config,
|
|
41
|
+
};
|
|
42
|
+
this.declinedMerchants = new Set(config?.declinedMerchants ?? []);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Add a payment method to the mock ACP.
|
|
46
|
+
*/
|
|
47
|
+
addPaymentMethod(method) {
|
|
48
|
+
this.paymentMethods.set(method.id, method);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Process a payment through the mock ACP.
|
|
52
|
+
*/
|
|
53
|
+
async processPayment(tx) {
|
|
54
|
+
await this.sleep(this.config.latencyMs);
|
|
55
|
+
// Check for declined merchants
|
|
56
|
+
if (this.declinedMerchants.has(tx.recipient)) {
|
|
57
|
+
const result = {
|
|
58
|
+
success: false,
|
|
59
|
+
txId: '',
|
|
60
|
+
error: `Merchant "${tx.recipient}" has been declined`,
|
|
61
|
+
};
|
|
62
|
+
this.processedPayments.push(result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
// Validate we have at least one active payment method
|
|
66
|
+
const activeMethods = [...this.paymentMethods.values()].filter((m) => m.active);
|
|
67
|
+
if (activeMethods.length === 0) {
|
|
68
|
+
const result = {
|
|
69
|
+
success: false,
|
|
70
|
+
txId: '',
|
|
71
|
+
error: 'No active payment methods available',
|
|
72
|
+
};
|
|
73
|
+
this.processedPayments.push(result);
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
// Check wallet balance if applicable
|
|
77
|
+
const walletMethod = activeMethods.find((m) => m.type === 'wallet');
|
|
78
|
+
if (walletMethod && walletMethod.balance !== undefined && walletMethod.balance < tx.amount) {
|
|
79
|
+
const result = {
|
|
80
|
+
success: false,
|
|
81
|
+
txId: '',
|
|
82
|
+
error: `Insufficient wallet balance: $${walletMethod.balance} < $${tx.amount}`,
|
|
83
|
+
};
|
|
84
|
+
this.processedPayments.push(result);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
// Simulate random failures
|
|
88
|
+
if (Math.random() < this.config.failureRate) {
|
|
89
|
+
const result = {
|
|
90
|
+
success: false,
|
|
91
|
+
txId: '',
|
|
92
|
+
error: 'Simulated ACP processing error: payment declined',
|
|
93
|
+
};
|
|
94
|
+
this.processedPayments.push(result);
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
// Success
|
|
98
|
+
const txId = generateId('acp');
|
|
99
|
+
this.transactionLog.push({
|
|
100
|
+
txId,
|
|
101
|
+
amount: tx.amount,
|
|
102
|
+
currency: tx.currency,
|
|
103
|
+
merchant: tx.recipient,
|
|
104
|
+
timestamp: new Date().toISOString(),
|
|
105
|
+
});
|
|
106
|
+
const result = {
|
|
107
|
+
success: true,
|
|
108
|
+
txId,
|
|
109
|
+
settlementMs: this.config.settlementMs,
|
|
110
|
+
};
|
|
111
|
+
this.processedPayments.push(result);
|
|
112
|
+
this.config.logger?.info(`[MockACP] Payment processed: ${txId}`, {
|
|
113
|
+
amount: tx.amount,
|
|
114
|
+
merchant: tx.recipient,
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get all payment methods.
|
|
120
|
+
*/
|
|
121
|
+
getPaymentMethods() {
|
|
122
|
+
return [...this.paymentMethods.values()];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Reset the mock to initial state.
|
|
126
|
+
*/
|
|
127
|
+
reset() {
|
|
128
|
+
this.processedPayments.length = 0;
|
|
129
|
+
this.transactionLog.length = 0;
|
|
130
|
+
this.paymentMethods.clear();
|
|
131
|
+
}
|
|
132
|
+
sleep(ms) {
|
|
133
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=mock-acp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-acp.js","sourceRoot":"","sources":["../src/mock-acp.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,gEAAgE;AAChE,uEAAuE;AACvE,gFAAgF;AAOhF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmC7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,OAAO;IACD,MAAM,CAA8F;IACpG,iBAAiB,CAAc;IAC/B,cAAc,GAAmC,IAAI,GAAG,EAAE,CAAC;IAE5E,mCAAmC;IAC1B,iBAAiB,GAAwB,EAAE,CAAC;IAErD,0BAA0B;IACjB,cAAc,GAMlB,EAAE,CAAC;IAER,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,GAAG;YACnC,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,CAAC;YACrC,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,IAAI;YAC1C,GAAG,MAAM;SACV,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,MAAyB;QACxC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,EAAoB;QACvC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAExC,+BAA+B;QAC/B,IAAI,IAAI,CAAC,iBAAi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,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AgentTransaction, AgentId, MockPaymentResult, Logger } from '@paysentry/core';
|
|
2
|
+
/** A payment mandate between two agents */
|
|
3
|
+
export interface PaymentMandate {
|
|
4
|
+
/** Unique mandate identifier */
|
|
5
|
+
readonly id: string;
|
|
6
|
+
/** Agent granting the mandate (payer) */
|
|
7
|
+
readonly grantor: AgentId;
|
|
8
|
+
/** Agent receiving payments (payee) */
|
|
9
|
+
readonly grantee: AgentId;
|
|
10
|
+
/** Maximum amount per transaction */
|
|
11
|
+
readonly maxPerTransaction: number;
|
|
12
|
+
/** Maximum cumulative amount */
|
|
13
|
+
readonly maxCumulative: number;
|
|
14
|
+
/** Currency */
|
|
15
|
+
readonly currency: string;
|
|
16
|
+
/** ISO 8601 expiration date */
|
|
17
|
+
readonly expiresAt: string;
|
|
18
|
+
/** Whether the mandate is active */
|
|
19
|
+
active: boolean;
|
|
20
|
+
/** Amount already spent under this mandate */
|
|
21
|
+
spent: number;
|
|
22
|
+
}
|
|
23
|
+
/** Configuration for the mock AP2 issuer */
|
|
24
|
+
export interface MockAP2Config {
|
|
25
|
+
/** Simulated latency in milliseconds (default: 150) */
|
|
26
|
+
readonly latencyMs?: number;
|
|
27
|
+
/** Simulated failure rate, 0.0 to 1.0 (default: 0) */
|
|
28
|
+
readonly failureRate?: number;
|
|
29
|
+
/** Optional logger */
|
|
30
|
+
readonly logger?: Logger;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* MockAP2 simulates the Agent-to-Agent Payment Protocol, which enables
|
|
34
|
+
* agents to issue payment mandates to other agents. A mandate grants
|
|
35
|
+
* permission to pull funds up to specified limits.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const ap2 = new MockAP2();
|
|
40
|
+
*
|
|
41
|
+
* // Create a mandate: agent-1 authorizes agent-2 to spend up to $100
|
|
42
|
+
* const mandate = ap2.createMandate({
|
|
43
|
+
* grantor: 'agent-1' as AgentId,
|
|
44
|
+
* grantee: 'agent-2' as AgentId,
|
|
45
|
+
* maxPerTransaction: 10,
|
|
46
|
+
* maxCumulative: 100,
|
|
47
|
+
* currency: 'USDC',
|
|
48
|
+
* expiresAt: new Date(Date.now() + 86400000).toISOString(),
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Process a payment under the mandate
|
|
52
|
+
* const result = await ap2.processPayment(transaction, mandate.id);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class MockAP2 {
|
|
56
|
+
private readonly config;
|
|
57
|
+
private readonly mandates;
|
|
58
|
+
/** Track all processed payments */
|
|
59
|
+
readonly processedPayments: MockPaymentResult[];
|
|
60
|
+
constructor(config?: MockAP2Config);
|
|
61
|
+
/**
|
|
62
|
+
* Create a new payment mandate.
|
|
63
|
+
*/
|
|
64
|
+
createMandate(input: Omit<PaymentMandate, 'id' | 'active' | 'spent'>): PaymentMandate;
|
|
65
|
+
/**
|
|
66
|
+
* Process a payment under a specific mandate.
|
|
67
|
+
*/
|
|
68
|
+
processPayment(tx: AgentTransaction, mandateId?: string): Promise<MockPaymentResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Revoke a mandate.
|
|
71
|
+
*/
|
|
72
|
+
revokeMandate(mandateId: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Get a mandate by ID.
|
|
75
|
+
*/
|
|
76
|
+
getMandate(mandateId: string): PaymentMandate | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Get all mandates for a given grantor or grantee.
|
|
79
|
+
*/
|
|
80
|
+
getMandates(agentId: AgentId, role: 'grantor' | 'grantee'): PaymentMandate[];
|
|
81
|
+
/**
|
|
82
|
+
* Reset the mock to initial state.
|
|
83
|
+
*/
|
|
84
|
+
reset(): void;
|
|
85
|
+
private findMandate;
|
|
86
|
+
private sleep;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=mock-ap2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-ap2.d.ts","sourceRoot":"","sources":["../src/mock-ap2.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,MAAM,EACP,MAAM,iBAAiB,CAAC;AAGzB,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,qCAAqC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAEnC,gCAAgC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,eAAe;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAEhB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,sBAAsB;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6E;IACpG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IAEnE,mCAAmC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,CAAM;gBAEzC,MAAM,CAAC,EAAE,aAAa;IAQlC;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG,cAAc;IAmBrF;;OAEG;IACG,cAAc,CAClB,EAAE,EAAE,gBAAgB,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IA4G7B;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IASzC;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIzD;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,cAAc,EAAE;IAM5E;;OAEG;IACH,KAAK,IAAI,IAAI;IASb,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/mock-ap2.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// MockAP2 — Simulated Agent-to-Agent Payment Protocol (AP2) mandate issuer
|
|
3
|
+
// Handles recurring payment mandates between AI agents
|
|
4
|
+
// =============================================================================
|
|
5
|
+
import { generateId } from '@paysentry/core';
|
|
6
|
+
/**
|
|
7
|
+
* MockAP2 simulates the Agent-to-Agent Payment Protocol, which enables
|
|
8
|
+
* agents to issue payment mandates to other agents. A mandate grants
|
|
9
|
+
* permission to pull funds up to specified limits.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const ap2 = new MockAP2();
|
|
14
|
+
*
|
|
15
|
+
* // Create a mandate: agent-1 authorizes agent-2 to spend up to $100
|
|
16
|
+
* const mandate = ap2.createMandate({
|
|
17
|
+
* grantor: 'agent-1' as AgentId,
|
|
18
|
+
* grantee: 'agent-2' as AgentId,
|
|
19
|
+
* maxPerTransaction: 10,
|
|
20
|
+
* maxCumulative: 100,
|
|
21
|
+
* currency: 'USDC',
|
|
22
|
+
* expiresAt: new Date(Date.now() + 86400000).toISOString(),
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Process a payment under the mandate
|
|
26
|
+
* const result = await ap2.processPayment(transaction, mandate.id);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class MockAP2 {
|
|
30
|
+
config;
|
|
31
|
+
mandates = new Map();
|
|
32
|
+
/** Track all processed payments */
|
|
33
|
+
processedPayments = [];
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.config = {
|
|
36
|
+
latencyMs: config?.latencyMs ?? 150,
|
|
37
|
+
failureRate: config?.failureRate ?? 0,
|
|
38
|
+
...config,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a new payment mandate.
|
|
43
|
+
*/
|
|
44
|
+
createMandate(input) {
|
|
45
|
+
const mandate = {
|
|
46
|
+
...input,
|
|
47
|
+
id: generateId('mdt'),
|
|
48
|
+
active: true,
|
|
49
|
+
spent: 0,
|
|
50
|
+
};
|
|
51
|
+
this.mandates.set(mandate.id, mandate);
|
|
52
|
+
this.config.logger?.info(`[MockAP2] Created mandate ${mandate.id}`, {
|
|
53
|
+
grantor: mandate.grantor,
|
|
54
|
+
grantee: mandate.grantee,
|
|
55
|
+
maxCumulative: mandate.maxCumulative,
|
|
56
|
+
});
|
|
57
|
+
return mandate;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Process a payment under a specific mandate.
|
|
61
|
+
*/
|
|
62
|
+
async processPayment(tx, mandateId) {
|
|
63
|
+
await this.sleep(this.config.latencyMs);
|
|
64
|
+
// Find applicable mandate
|
|
65
|
+
const mandate = mandateId
|
|
66
|
+
? this.mandates.get(mandateId)
|
|
67
|
+
: this.findMandate(tx);
|
|
68
|
+
if (!mandate) {
|
|
69
|
+
const result = {
|
|
70
|
+
success: false,
|
|
71
|
+
txId: '',
|
|
72
|
+
error: mandateId
|
|
73
|
+
? `Mandate ${mandateId} not found`
|
|
74
|
+
: `No active mandate found for ${tx.agentId} -> ${tx.recipient}`,
|
|
75
|
+
};
|
|
76
|
+
this.processedPayments.push(result);
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
// Validate mandate is active
|
|
80
|
+
if (!mandate.active) {
|
|
81
|
+
const result = {
|
|
82
|
+
success: false,
|
|
83
|
+
txId: '',
|
|
84
|
+
error: `Mandate ${mandate.id} is no longer active`,
|
|
85
|
+
};
|
|
86
|
+
this.processedPayments.push(result);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
// Check expiration
|
|
90
|
+
if (new Date(mandate.expiresAt) < new Date()) {
|
|
91
|
+
mandate.active = false;
|
|
92
|
+
const result = {
|
|
93
|
+
success: false,
|
|
94
|
+
txId: '',
|
|
95
|
+
error: `Mandate ${mandate.id} has expired`,
|
|
96
|
+
};
|
|
97
|
+
this.processedPayments.push(result);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
// Check currency match
|
|
101
|
+
if (mandate.currency !== tx.currency) {
|
|
102
|
+
const result = {
|
|
103
|
+
success: false,
|
|
104
|
+
txId: '',
|
|
105
|
+
error: `Currency mismatch: mandate is ${mandate.currency}, transaction is ${tx.currency}`,
|
|
106
|
+
};
|
|
107
|
+
this.processedPayments.push(result);
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
// Check per-transaction limit
|
|
111
|
+
if (tx.amount > mandate.maxPerTransaction) {
|
|
112
|
+
const result = {
|
|
113
|
+
success: false,
|
|
114
|
+
txId: '',
|
|
115
|
+
error: `Amount $${tx.amount} exceeds mandate per-transaction limit of $${mandate.maxPerTransaction}`,
|
|
116
|
+
};
|
|
117
|
+
this.processedPayments.push(result);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
// Check cumulative limit
|
|
121
|
+
if (mandate.spent + tx.amount > mandate.maxCumulative) {
|
|
122
|
+
const result = {
|
|
123
|
+
success: false,
|
|
124
|
+
txId: '',
|
|
125
|
+
error: `Cumulative spend would reach $${mandate.spent + tx.amount}, exceeding mandate limit of $${mandate.maxCumulative}`,
|
|
126
|
+
};
|
|
127
|
+
this.processedPayments.push(result);
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
// Simulate random failures
|
|
131
|
+
if (Math.random() < this.config.failureRate) {
|
|
132
|
+
const result = {
|
|
133
|
+
success: false,
|
|
134
|
+
txId: '',
|
|
135
|
+
error: 'Simulated AP2 network error',
|
|
136
|
+
};
|
|
137
|
+
this.processedPayments.push(result);
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
// Success — update mandate spend tracking
|
|
141
|
+
mandate.spent += tx.amount;
|
|
142
|
+
const txId = generateId('ap2');
|
|
143
|
+
const result = {
|
|
144
|
+
success: true,
|
|
145
|
+
txId,
|
|
146
|
+
settlementMs: 500,
|
|
147
|
+
};
|
|
148
|
+
this.processedPayments.push(result);
|
|
149
|
+
this.config.logger?.info(`[MockAP2] Payment processed under mandate ${mandate.id}: ${txId}`, {
|
|
150
|
+
amount: tx.amount,
|
|
151
|
+
mandateSpent: mandate.spent,
|
|
152
|
+
mandateRemaining: mandate.maxCumulative - mandate.spent,
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Revoke a mandate.
|
|
158
|
+
*/
|
|
159
|
+
revokeMandate(mandateId) {
|
|
160
|
+
const mandate = this.mandates.get(mandateId);
|
|
161
|
+
if (!mandate)
|
|
162
|
+
return false;
|
|
163
|
+
mandate.active = false;
|
|
164
|
+
this.config.logger?.info(`[MockAP2] Revoked mandate ${mandateId}`);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get a mandate by ID.
|
|
169
|
+
*/
|
|
170
|
+
getMandate(mandateId) {
|
|
171
|
+
return this.mandates.get(mandateId);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get all mandates for a given grantor or grantee.
|
|
175
|
+
*/
|
|
176
|
+
getMandates(agentId, role) {
|
|
177
|
+
return [...this.mandates.values()].filter((m) => role === 'grantor' ? m.grantor === agentId : m.grantee === agentId);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Reset the mock to initial state.
|
|
181
|
+
*/
|
|
182
|
+
reset() {
|
|
183
|
+
this.mandates.clear();
|
|
184
|
+
this.processedPayments.length = 0;
|
|
185
|
+
}
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
// Private
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
findMandate(tx) {
|
|
190
|
+
// Find an active mandate where the tx agent is the grantee
|
|
191
|
+
// and the tx recipient matches the grantor
|
|
192
|
+
return [...this.mandates.values()].find((m) => m.active &&
|
|
193
|
+
m.grantee === tx.agentId &&
|
|
194
|
+
new Date(m.expiresAt) > new Date());
|
|
195
|
+
}
|
|
196
|
+
sleep(ms) {
|
|
197
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=mock-ap2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-ap2.js","sourceRoot":"","sources":["../src/mock-ap2.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,uDAAuD;AACvD,gFAAgF;AAQhF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA4C7C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,OAAO;IACD,MAAM,CAA6E;I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KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,8EAA8E;IAC9E,UAAU;IACV,8EAA8E;IAEtE,WAAW,CAAC,EAAoB;QACtC,2DAA2D;QAC3D,2CAA2C;QAC3C,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,OAAO;YACxB,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,CACrC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentTransaction, MockPaymentResult, Logger } from '@paysentry/core';
|
|
2
|
+
/** Configuration for the mock x402 facilitator */
|
|
3
|
+
export interface MockX402Config {
|
|
4
|
+
/** Simulated network latency in milliseconds (default: 100) */
|
|
5
|
+
readonly latencyMs?: number;
|
|
6
|
+
/** Simulated failure rate, 0.0 to 1.0 (default: 0) */
|
|
7
|
+
readonly failureRate?: number;
|
|
8
|
+
/** Simulated settlement time in milliseconds (default: 1000) */
|
|
9
|
+
readonly settlementMs?: number;
|
|
10
|
+
/** Maximum amount allowed per transaction (default: Infinity) */
|
|
11
|
+
readonly maxAmount?: number;
|
|
12
|
+
/** Supported currencies (default: ['USDC', 'ETH']) */
|
|
13
|
+
readonly supportedCurrencies?: readonly string[];
|
|
14
|
+
/** Optional logger */
|
|
15
|
+
readonly logger?: Logger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MockX402 simulates the x402 payment protocol (HTTP 402 Payment Required).
|
|
19
|
+
* In production, x402 enables pay-per-request access to HTTP resources.
|
|
20
|
+
* This mock provides deterministic or configurable behavior for testing.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const x402 = new MockX402({ latencyMs: 50, failureRate: 0.1 });
|
|
25
|
+
*
|
|
26
|
+
* const result = await x402.processPayment(transaction);
|
|
27
|
+
* if (result.success) {
|
|
28
|
+
* console.log(`Payment processed: ${result.txId}`);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class MockX402 {
|
|
33
|
+
private readonly config;
|
|
34
|
+
private readonly supportedCurrencies;
|
|
35
|
+
/** Track all processed payments for assertion in tests */
|
|
36
|
+
readonly processedPayments: MockPaymentResult[];
|
|
37
|
+
/** Running balance of the mock facilitator */
|
|
38
|
+
private balance;
|
|
39
|
+
constructor(config?: MockX402Config);
|
|
40
|
+
/**
|
|
41
|
+
* Process a payment through the mock x402 facilitator.
|
|
42
|
+
* Simulates network latency, validation, and settlement.
|
|
43
|
+
*/
|
|
44
|
+
processPayment(tx: AgentTransaction): Promise<MockPaymentResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the running balance of processed payments.
|
|
47
|
+
*/
|
|
48
|
+
getBalance(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Reset the mock to initial state.
|
|
51
|
+
*/
|
|
52
|
+
reset(): void;
|
|
53
|
+
private sleep;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=mock-x402.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-x402.d.ts","sourceRoot":"","sources":["../src/mock-x402.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACP,MAAM,iBAAiB,CAAC;AAGzB,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,gEAAgE;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,sDAAsD;IACtD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjD,sBAAsB;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8G;IACrI,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAc;IAElD,0DAA0D;IAC1D,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,CAAM;IAErD,8CAA8C;IAC9C,OAAO,CAAC,OAAO,CAAa;gBAEhB,MAAM,CAAC,EAAE,cAAc;IAWnC;;;OAGG;IACG,cAAc,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqEtE;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// MockX402 — Simulated x402 (HTTP 402 Payment Required) facilitator
|
|
3
|
+
// Mimics the behavior of a real x402 payment facilitator for testing
|
|
4
|
+
// =============================================================================
|
|
5
|
+
import { generateId } from '@paysentry/core';
|
|
6
|
+
/**
|
|
7
|
+
* MockX402 simulates the x402 payment protocol (HTTP 402 Payment Required).
|
|
8
|
+
* In production, x402 enables pay-per-request access to HTTP resources.
|
|
9
|
+
* This mock provides deterministic or configurable behavior for testing.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const x402 = new MockX402({ latencyMs: 50, failureRate: 0.1 });
|
|
14
|
+
*
|
|
15
|
+
* const result = await x402.processPayment(transaction);
|
|
16
|
+
* if (result.success) {
|
|
17
|
+
* console.log(`Payment processed: ${result.txId}`);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class MockX402 {
|
|
22
|
+
config;
|
|
23
|
+
supportedCurrencies;
|
|
24
|
+
/** Track all processed payments for assertion in tests */
|
|
25
|
+
processedPayments = [];
|
|
26
|
+
/** Running balance of the mock facilitator */
|
|
27
|
+
balance = 0;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = {
|
|
30
|
+
latencyMs: config?.latencyMs ?? 100,
|
|
31
|
+
failureRate: config?.failureRate ?? 0,
|
|
32
|
+
settlementMs: config?.settlementMs ?? 1000,
|
|
33
|
+
maxAmount: config?.maxAmount ?? Infinity,
|
|
34
|
+
...config,
|
|
35
|
+
};
|
|
36
|
+
this.supportedCurrencies = new Set(config?.supportedCurrencies ?? ['USDC', 'ETH']);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Process a payment through the mock x402 facilitator.
|
|
40
|
+
* Simulates network latency, validation, and settlement.
|
|
41
|
+
*/
|
|
42
|
+
async processPayment(tx) {
|
|
43
|
+
// Simulate network latency
|
|
44
|
+
await this.sleep(this.config.latencyMs);
|
|
45
|
+
// Validate currency
|
|
46
|
+
if (!this.supportedCurrencies.has(tx.currency)) {
|
|
47
|
+
const result = {
|
|
48
|
+
success: false,
|
|
49
|
+
txId: '',
|
|
50
|
+
error: `Unsupported currency: ${tx.currency}. Supported: ${[...this.supportedCurrencies].join(', ')}`,
|
|
51
|
+
};
|
|
52
|
+
this.processedPayments.push(result);
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
// Validate amount
|
|
56
|
+
if (tx.amount > this.config.maxAmount) {
|
|
57
|
+
const result = {
|
|
58
|
+
success: false,
|
|
59
|
+
txId: '',
|
|
60
|
+
error: `Amount $${tx.amount} exceeds maximum of $${this.config.maxAmount}`,
|
|
61
|
+
};
|
|
62
|
+
this.processedPayments.push(result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
// Validate recipient looks like a URL (x402 targets HTTP endpoints)
|
|
66
|
+
if (!tx.recipient.startsWith('http://') && !tx.recipient.startsWith('https://')) {
|
|
67
|
+
const result = {
|
|
68
|
+
success: false,
|
|
69
|
+
txId: '',
|
|
70
|
+
error: `x402 requires an HTTP URL recipient. Got: ${tx.recipient}`,
|
|
71
|
+
};
|
|
72
|
+
this.processedPayments.push(result);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
// Simulate random failures
|
|
76
|
+
if (Math.random() < this.config.failureRate) {
|
|
77
|
+
const result = {
|
|
78
|
+
success: false,
|
|
79
|
+
txId: '',
|
|
80
|
+
error: 'Simulated x402 facilitator error: transaction failed',
|
|
81
|
+
};
|
|
82
|
+
this.processedPayments.push(result);
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
// Success
|
|
86
|
+
const txId = generateId('x402');
|
|
87
|
+
this.balance += tx.amount;
|
|
88
|
+
const result = {
|
|
89
|
+
success: true,
|
|
90
|
+
txId,
|
|
91
|
+
settlementMs: this.config.settlementMs,
|
|
92
|
+
};
|
|
93
|
+
this.processedPayments.push(result);
|
|
94
|
+
this.config.logger?.info(`[MockX402] Payment processed: ${txId}`, {
|
|
95
|
+
amount: tx.amount,
|
|
96
|
+
currency: tx.currency,
|
|
97
|
+
recipient: tx.recipient,
|
|
98
|
+
});
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the running balance of processed payments.
|
|
103
|
+
*/
|
|
104
|
+
getBalance() {
|
|
105
|
+
return this.balance;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Reset the mock to initial state.
|
|
109
|
+
*/
|
|
110
|
+
reset() {
|
|
111
|
+
this.processedPayments.length = 0;
|
|
112
|
+
this.balance = 0;
|
|
113
|
+
}
|
|
114
|
+
sleep(ms) {
|
|
115
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=mock-x402.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-x402.js","sourceRoot":"","sources":["../src/mock-x402.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oEAAoE;AACpE,qEAAqE;AACrE,gFAAgF;AAOhF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAuB7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,QAAQ;IACF,MAAM,CAA8G;IACpH,mBAAmB,CAAc;IAElD,0DAA0D;IACjD,iBAAiB,GAAwB,EAAE,CAAC;IAErD,8CAA8C;IACtC,OAAO,GAAW,CAAC,CAAC;IAE5B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,GAAG;YACnC,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,CAAC;YACrC,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,IAAI;YAC1C,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,QAAQ;YACxC,GAAG,MAAM;SACV,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,mBAAmB,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,EAAoB;QACvC,2BAA2B;QAC3B,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAExC,oBAAoB;QACpB,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,E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AAI,EAAE,EAAE;gBACR,KAAK,EAAE,sDAAsD;aAC9D,CAAC;YACF,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,UAAU;QACV,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,MAAM,CAAC;QAE1B,MAAM,MAAM,GAAsB;YAChC,OAAO,EAAE,IAAI;YACb,IAAI;YACJ,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;SACvC,CAAC;QAEF,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,iCAAiC,IAAI,EAAE,EAAE;YAChE,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,SAAS,EAAE,EAAE,CAAC,SAAS;SACxB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TestScenario } from '@paysentry/core';
|
|
2
|
+
/**
|
|
3
|
+
* Basic happy path: A single successful payment.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SCENARIO_BASIC_PAYMENT: TestScenario;
|
|
6
|
+
/**
|
|
7
|
+
* Budget overspend: Agent tries to exceed its daily budget.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SCENARIO_OVERSPEND: TestScenario;
|
|
10
|
+
/**
|
|
11
|
+
* Large transaction requiring approval.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SCENARIO_APPROVAL_REQUIRED: TestScenario;
|
|
14
|
+
/**
|
|
15
|
+
* Blocked recipient: Agent tries to pay a blacklisted service.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SCENARIO_BLOCKED_RECIPIENT: TestScenario;
|
|
18
|
+
/**
|
|
19
|
+
* Multi-protocol: Agent uses different protocols for different services.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SCENARIO_MULTI_PROTOCOL: TestScenario;
|
|
22
|
+
/**
|
|
23
|
+
* Dispute flow: Payment succeeds, then a dispute is filed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SCENARIO_DISPUTE: TestScenario;
|
|
26
|
+
/**
|
|
27
|
+
* Rate spike: Rapid succession of payments triggers rate limiting.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SCENARIO_RATE_SPIKE: TestScenario;
|
|
30
|
+
/**
|
|
31
|
+
* Timeout scenario: Payment to a slow endpoint that times out.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SCENARIO_TIMEOUT: TestScenario;
|
|
34
|
+
/**
|
|
35
|
+
* Multi-agent: Multiple agents making concurrent payments.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SCENARIO_MULTI_AGENT: TestScenario;
|
|
38
|
+
/** All built-in scenarios */
|
|
39
|
+
export declare const ALL_SCENARIOS: readonly TestScenario[];
|
|
40
|
+
//# sourceMappingURL=scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.d.ts","sourceRoot":"","sources":["../src/scenarios.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIV,YAAY,EACb,MAAM,iBAAiB,CAAC;AAgCzB;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAWpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAUhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,YAWxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,YAWxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,YAwBrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAY9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAUjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAY9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,YASlC,CAAC;AAEF,6BAA6B;AAC7B,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAUhD,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Pre-built Test Scenarios
|
|
3
|
+
// Ready-to-use scenarios for testing common agent payment patterns
|
|
4
|
+
// =============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Create a transaction template for use in test scenarios.
|
|
7
|
+
* This is a helper to reduce boilerplate in scenario definitions.
|
|
8
|
+
*/
|
|
9
|
+
function tx(overrides) {
|
|
10
|
+
return {
|
|
11
|
+
agentId: (overrides.agentId ?? 'test-agent'),
|
|
12
|
+
recipient: overrides.recipient ?? 'https://api.example.com/resource',
|
|
13
|
+
amount: overrides.amount ?? 1.0,
|
|
14
|
+
currency: overrides.currency ?? 'USDC',
|
|
15
|
+
purpose: overrides.purpose ?? 'Test payment',
|
|
16
|
+
protocol: overrides.protocol ?? 'x402',
|
|
17
|
+
service: overrides.service,
|
|
18
|
+
metadata: Object.freeze(overrides.metadata ?? {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Scenarios
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* Basic happy path: A single successful payment.
|
|
26
|
+
*/
|
|
27
|
+
export const SCENARIO_BASIC_PAYMENT = {
|
|
28
|
+
name: 'Basic Payment',
|
|
29
|
+
description: 'A single agent makes a simple x402 payment that should succeed.',
|
|
30
|
+
transactions: [
|
|
31
|
+
tx({
|
|
32
|
+
amount: 0.05,
|
|
33
|
+
purpose: 'Basic API call',
|
|
34
|
+
recipient: 'https://api.openai.com/v1/chat',
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
expectedOutcomes: ['completed'],
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Budget overspend: Agent tries to exceed its daily budget.
|
|
41
|
+
*/
|
|
42
|
+
export const SCENARIO_OVERSPEND = {
|
|
43
|
+
name: 'Budget Overspend',
|
|
44
|
+
description: 'Agent makes multiple payments that cumulatively exceed the daily budget. The last transaction should be rejected.',
|
|
45
|
+
transactions: [
|
|
46
|
+
tx({ amount: 30, purpose: 'First batch of API calls' }),
|
|
47
|
+
tx({ amount: 30, purpose: 'Second batch of API calls' }),
|
|
48
|
+
tx({ amount: 30, purpose: 'Third batch of API calls' }),
|
|
49
|
+
tx({ amount: 30, purpose: 'This should be rejected (exceeds $100 daily)' }),
|
|
50
|
+
],
|
|
51
|
+
expectedOutcomes: ['completed', 'completed', 'completed', 'rejected'],
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Large transaction requiring approval.
|
|
55
|
+
*/
|
|
56
|
+
export const SCENARIO_APPROVAL_REQUIRED = {
|
|
57
|
+
name: 'Approval Required',
|
|
58
|
+
description: 'Agent attempts a payment above the auto-approve threshold. The transaction should require human approval.',
|
|
59
|
+
transactions: [
|
|
60
|
+
tx({
|
|
61
|
+
amount: 500,
|
|
62
|
+
purpose: 'Expensive model training run',
|
|
63
|
+
recipient: 'https://compute.provider.com/train',
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
expectedOutcomes: ['approved'],
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Blocked recipient: Agent tries to pay a blacklisted service.
|
|
70
|
+
*/
|
|
71
|
+
export const SCENARIO_BLOCKED_RECIPIENT = {
|
|
72
|
+
name: 'Blocked Recipient',
|
|
73
|
+
description: 'Agent attempts to pay a recipient that is on the blocklist. Should be denied.',
|
|
74
|
+
transactions: [
|
|
75
|
+
tx({
|
|
76
|
+
recipient: 'https://malicious-service.com/api',
|
|
77
|
+
amount: 1.0,
|
|
78
|
+
purpose: 'Attempting to pay blocked recipient',
|
|
79
|
+
}),
|
|
80
|
+
],
|
|
81
|
+
expectedOutcomes: ['rejected'],
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Multi-protocol: Agent uses different protocols for different services.
|
|
85
|
+
*/
|
|
86
|
+
export const SCENARIO_MULTI_PROTOCOL = {
|
|
87
|
+
name: 'Multi-Protocol',
|
|
88
|
+
description: 'Agent makes payments across x402, ACP, and AP2 protocols. All should succeed.',
|
|
89
|
+
transactions: [
|
|
90
|
+
tx({
|
|
91
|
+
protocol: 'x402',
|
|
92
|
+
recipient: 'https://api.service-a.com/v1/data',
|
|
93
|
+
amount: 0.10,
|
|
94
|
+
purpose: 'x402 API payment',
|
|
95
|
+
}),
|
|
96
|
+
tx({
|
|
97
|
+
protocol: 'acp',
|
|
98
|
+
recipient: 'merchant:coffee-shop',
|
|
99
|
+
amount: 5.50,
|
|
100
|
+
purpose: 'ACP merchant payment',
|
|
101
|
+
}),
|
|
102
|
+
tx({
|
|
103
|
+
protocol: 'ap2',
|
|
104
|
+
recipient: 'agent://research-agent',
|
|
105
|
+
amount: 2.00,
|
|
106
|
+
purpose: 'AP2 agent-to-agent payment',
|
|
107
|
+
}),
|
|
108
|
+
],
|
|
109
|
+
expectedOutcomes: ['completed', 'completed', 'completed'],
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Dispute flow: Payment succeeds, then a dispute is filed.
|
|
113
|
+
*/
|
|
114
|
+
export const SCENARIO_DISPUTE = {
|
|
115
|
+
name: 'Dispute Flow',
|
|
116
|
+
description: 'Agent makes a payment, but the service does not deliver. A dispute should be filed.',
|
|
117
|
+
transactions: [
|
|
118
|
+
tx({
|
|
119
|
+
amount: 25.0,
|
|
120
|
+
purpose: 'Purchase premium dataset',
|
|
121
|
+
recipient: 'https://data-provider.com/datasets/premium',
|
|
122
|
+
metadata: { expectedDelivery: 'immediate', category: 'data' },
|
|
123
|
+
}),
|
|
124
|
+
],
|
|
125
|
+
expectedOutcomes: ['disputed'],
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Rate spike: Rapid succession of payments triggers rate limiting.
|
|
129
|
+
*/
|
|
130
|
+
export const SCENARIO_RATE_SPIKE = {
|
|
131
|
+
name: 'Rate Spike',
|
|
132
|
+
description: 'Agent fires 10 rapid payments in succession. Should trigger rate spike alerts.',
|
|
133
|
+
transactions: Array.from({ length: 10 }, (_, i) => tx({
|
|
134
|
+
amount: 0.01,
|
|
135
|
+
purpose: `Rapid payment ${i + 1}`,
|
|
136
|
+
})),
|
|
137
|
+
expectedOutcomes: Array.from({ length: 10 }, () => 'completed'),
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Timeout scenario: Payment to a slow endpoint that times out.
|
|
141
|
+
*/
|
|
142
|
+
export const SCENARIO_TIMEOUT = {
|
|
143
|
+
name: 'Timeout',
|
|
144
|
+
description: 'Agent pays a service that takes too long to respond. Should fail with timeout.',
|
|
145
|
+
transactions: [
|
|
146
|
+
tx({
|
|
147
|
+
amount: 1.0,
|
|
148
|
+
purpose: 'Payment to slow service',
|
|
149
|
+
recipient: 'https://slow-service.example.com/api',
|
|
150
|
+
metadata: { timeout: 5000 },
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
expectedOutcomes: ['failed'],
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Multi-agent: Multiple agents making concurrent payments.
|
|
157
|
+
*/
|
|
158
|
+
export const SCENARIO_MULTI_AGENT = {
|
|
159
|
+
name: 'Multi-Agent',
|
|
160
|
+
description: 'Three different agents each make a payment. All should succeed independently.',
|
|
161
|
+
transactions: [
|
|
162
|
+
tx({ agentId: 'agent-alpha', amount: 10, purpose: 'Agent Alpha payment' }),
|
|
163
|
+
tx({ agentId: 'agent-beta', amount: 20, purpose: 'Agent Beta payment' }),
|
|
164
|
+
tx({ agentId: 'agent-gamma', amount: 30, purpose: 'Agent Gamma payment' }),
|
|
165
|
+
],
|
|
166
|
+
expectedOutcomes: ['completed', 'completed', 'completed'],
|
|
167
|
+
};
|
|
168
|
+
/** All built-in scenarios */
|
|
169
|
+
export const ALL_SCENARIOS = [
|
|
170
|
+
SCENARIO_BASIC_PAYMENT,
|
|
171
|
+
SCENARIO_OVERSPEND,
|
|
172
|
+
SCENARIO_APPROVAL_REQUIRED,
|
|
173
|
+
SCENARIO_BLOCKED_RECIPIENT,
|
|
174
|
+
SCENARIO_MULTI_PROTOCOL,
|
|
175
|
+
SCENARIO_DISPUTE,
|
|
176
|
+
SCENARIO_RATE_SPIKE,
|
|
177
|
+
SCENARIO_TIMEOUT,
|
|
178
|
+
SCENARIO_MULTI_AGENT,
|
|
179
|
+
];
|
|
180
|
+
//# sourceMappingURL=scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../src/scenarios.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2BAA2B;AAC3B,mEAAmE;AACnE,gFAAgF;AAShF;;;GAGG;AACH,SAAS,EAAE,CAAC,SASX;IACC,OAAO;QACL,OAAO,EAAE,CAAC,SAAS,CAAC,OAAO,IAAI,YAAY,CAAY;QACvD,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,kCAAkC;QACpE,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,GAAG;QAC/B,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI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MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;QACxE,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;KAC3E;IACD,gBAAgB,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC;CAC1D,CAAC;AAEF,6BAA6B;AAC7B,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD,sBAAsB;IACtB,kBAAkB;IAClB,0BAA0B;IAC1B,0BAA0B;IAC1B,uBAAuB;IACvB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;CACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paysentry/sandbox",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mock multi-protocol payment environment for testing AI agent payments",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"clean": "tsc --build --clean"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@paysentry/core": "1.0.0"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"files": ["dist"],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/paysentry/paysentry",
|
|
26
|
+
"directory": "packages/sandbox"
|
|
27
|
+
}
|
|
28
|
+
}
|