@bankofai/x402-evm 1.0.0-beta.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/README.md +172 -0
- package/dist/cjs/auth-capture/client/index.d.ts +44 -0
- package/dist/cjs/auth-capture/client/index.js +298 -0
- package/dist/cjs/auth-capture/client/index.js.map +1 -0
- package/dist/cjs/batch-settlement/client/file-storage.d.ts +47 -0
- package/dist/cjs/batch-settlement/client/file-storage.js +116 -0
- package/dist/cjs/batch-settlement/client/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/client/index.d.ts +111 -0
- package/dist/cjs/batch-settlement/client/index.js +1565 -0
- package/dist/cjs/batch-settlement/client/index.js.map +1 -0
- package/dist/cjs/batch-settlement/facilitator/index.d.ts +72 -0
- package/dist/cjs/batch-settlement/facilitator/index.js +2102 -0
- package/dist/cjs/batch-settlement/facilitator/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/file-storage.d.ts +53 -0
- package/dist/cjs/batch-settlement/server/file-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/server/index.d.ts +491 -0
- package/dist/cjs/batch-settlement/server/index.js +1978 -0
- package/dist/cjs/batch-settlement/server/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/redis-storage.d.ts +87 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js.map +1 -0
- package/dist/cjs/client/agent-wallet.d.ts +69 -0
- package/dist/cjs/client/agent-wallet.js +84 -0
- package/dist/cjs/client/agent-wallet.js.map +1 -0
- package/dist/cjs/exact/client/index.d.ts +63 -0
- package/dist/cjs/exact/client/index.js +739 -0
- package/dist/cjs/exact/client/index.js.map +1 -0
- package/dist/cjs/exact/facilitator/index.d.ts +141 -0
- package/dist/cjs/exact/facilitator/index.js +1989 -0
- package/dist/cjs/exact/facilitator/index.js.map +1 -0
- package/dist/cjs/exact/server/index.d.ts +118 -0
- package/dist/cjs/exact/server/index.js +326 -0
- package/dist/cjs/exact/server/index.js.map +1 -0
- package/dist/cjs/exact/v1/client/index.d.ts +38 -0
- package/dist/cjs/exact/v1/client/index.js +193 -0
- package/dist/cjs/exact/v1/client/index.js.map +1 -0
- package/dist/cjs/exact/v1/facilitator/index.d.ts +84 -0
- package/dist/cjs/exact/v1/facilitator/index.js +739 -0
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
- package/dist/cjs/facilitator/agent-wallet.d.ts +109 -0
- package/dist/cjs/facilitator/agent-wallet.js +105 -0
- package/dist/cjs/facilitator/agent-wallet.js.map +1 -0
- package/dist/cjs/index.d.ts +338 -0
- package/dist/cjs/index.js +2860 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/permit2-DK5A8alk.d.ts +729 -0
- package/dist/cjs/permit2-DhJRUcgY.d.ts +729 -0
- package/dist/cjs/rpc-DULZzRne.d.ts +13 -0
- package/dist/cjs/scheme-7ehldYoO.d.ts +307 -0
- package/dist/cjs/scheme-BjBJzHF7.d.ts +307 -0
- package/dist/cjs/scheme-DWgpkDgz.d.ts +47 -0
- package/dist/cjs/signer-BFelv8DL.d.ts +170 -0
- package/dist/cjs/storage-6W5MO46W.d.ts +50 -0
- package/dist/cjs/storage-CHNote8s.d.ts +81 -0
- package/dist/cjs/storage-DjCv5IPh.d.ts +81 -0
- package/dist/cjs/types-CKd3Xoi1.d.ts +180 -0
- package/dist/cjs/types-DIt9uAUy.d.ts +180 -0
- package/dist/cjs/upto/client/index.d.ts +34 -0
- package/dist/cjs/upto/client/index.js +509 -0
- package/dist/cjs/upto/client/index.js.map +1 -0
- package/dist/cjs/upto/facilitator/index.d.ts +54 -0
- package/dist/cjs/upto/facilitator/index.js +1313 -0
- package/dist/cjs/upto/facilitator/index.js.map +1 -0
- package/dist/cjs/upto/server/index.d.ts +69 -0
- package/dist/cjs/upto/server/index.js +296 -0
- package/dist/cjs/upto/server/index.js.map +1 -0
- package/dist/cjs/v1/index.d.ts +40 -0
- package/dist/cjs/v1/index.js +199 -0
- package/dist/cjs/v1/index.js.map +1 -0
- package/dist/esm/auth-capture/client/index.d.mts +44 -0
- package/dist/esm/auth-capture/client/index.mjs +8 -0
- package/dist/esm/auth-capture/client/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/client/file-storage.d.mts +47 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs +63 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/client/index.d.mts +111 -0
- package/dist/esm/batch-settlement/client/index.mjs +58 -0
- package/dist/esm/batch-settlement/client/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/facilitator/index.d.mts +72 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs +1252 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/file-storage.d.mts +53 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs +128 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/index.d.mts +491 -0
- package/dist/esm/batch-settlement/server/index.mjs +1640 -0
- package/dist/esm/batch-settlement/server/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/redis-storage.d.mts +87 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs +156 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs.map +1 -0
- package/dist/esm/chunk-2EUQTNJO.mjs +38 -0
- package/dist/esm/chunk-2EUQTNJO.mjs.map +1 -0
- package/dist/esm/chunk-3WZF6722.mjs +36 -0
- package/dist/esm/chunk-3WZF6722.mjs.map +1 -0
- package/dist/esm/chunk-E4Z7PNXC.mjs +275 -0
- package/dist/esm/chunk-E4Z7PNXC.mjs.map +1 -0
- package/dist/esm/chunk-GQVMVP4N.mjs +911 -0
- package/dist/esm/chunk-GQVMVP4N.mjs.map +1 -0
- package/dist/esm/chunk-H2EYJIZL.mjs +489 -0
- package/dist/esm/chunk-H2EYJIZL.mjs.map +1 -0
- package/dist/esm/chunk-H3KPLYGI.mjs +152 -0
- package/dist/esm/chunk-H3KPLYGI.mjs.map +1 -0
- package/dist/esm/chunk-HYABYUBD.mjs +432 -0
- package/dist/esm/chunk-HYABYUBD.mjs.map +1 -0
- package/dist/esm/chunk-I2DVUHM5.mjs +123 -0
- package/dist/esm/chunk-I2DVUHM5.mjs.map +1 -0
- package/dist/esm/chunk-JK7SLLF7.mjs +34 -0
- package/dist/esm/chunk-JK7SLLF7.mjs.map +1 -0
- package/dist/esm/chunk-JNT7C46S.mjs +352 -0
- package/dist/esm/chunk-JNT7C46S.mjs.map +1 -0
- package/dist/esm/chunk-MACPBXCT.mjs +415 -0
- package/dist/esm/chunk-MACPBXCT.mjs.map +1 -0
- package/dist/esm/chunk-P3QOX3QZ.mjs +113 -0
- package/dist/esm/chunk-P3QOX3QZ.mjs.map +1 -0
- package/dist/esm/chunk-QVATVA3J.mjs +47 -0
- package/dist/esm/chunk-QVATVA3J.mjs.map +1 -0
- package/dist/esm/chunk-SHJFA25H.mjs +159 -0
- package/dist/esm/chunk-SHJFA25H.mjs.map +1 -0
- package/dist/esm/chunk-TW7Z65AO.mjs +34 -0
- package/dist/esm/chunk-TW7Z65AO.mjs.map +1 -0
- package/dist/esm/chunk-U4HCGTLU.mjs +35 -0
- package/dist/esm/chunk-U4HCGTLU.mjs.map +1 -0
- package/dist/esm/chunk-VS3RYAYE.mjs +80 -0
- package/dist/esm/chunk-VS3RYAYE.mjs.map +1 -0
- package/dist/esm/chunk-W6ON4LG2.mjs +39 -0
- package/dist/esm/chunk-W6ON4LG2.mjs.map +1 -0
- package/dist/esm/chunk-XG2JLZVJ.mjs +627 -0
- package/dist/esm/chunk-XG2JLZVJ.mjs.map +1 -0
- package/dist/esm/chunk-ZCJRY5LQ.mjs +162 -0
- package/dist/esm/chunk-ZCJRY5LQ.mjs.map +1 -0
- package/dist/esm/client/agent-wallet.d.mts +69 -0
- package/dist/esm/client/agent-wallet.mjs +36 -0
- package/dist/esm/client/agent-wallet.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +63 -0
- package/dist/esm/exact/client/index.mjs +25 -0
- package/dist/esm/exact/client/index.mjs.map +1 -0
- package/dist/esm/exact/facilitator/index.d.mts +141 -0
- package/dist/esm/exact/facilitator/index.mjs +694 -0
- package/dist/esm/exact/facilitator/index.mjs.map +1 -0
- package/dist/esm/exact/server/index.d.mts +118 -0
- package/dist/esm/exact/server/index.mjs +153 -0
- package/dist/esm/exact/server/index.mjs.map +1 -0
- package/dist/esm/exact/v1/client/index.d.mts +38 -0
- package/dist/esm/exact/v1/client/index.mjs +12 -0
- package/dist/esm/exact/v1/client/index.mjs.map +1 -0
- package/dist/esm/exact/v1/facilitator/index.d.mts +84 -0
- package/dist/esm/exact/v1/facilitator/index.mjs +12 -0
- package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
- package/dist/esm/facilitator/agent-wallet.d.mts +109 -0
- package/dist/esm/facilitator/agent-wallet.mjs +74 -0
- package/dist/esm/facilitator/agent-wallet.mjs.map +1 -0
- package/dist/esm/index.d.mts +338 -0
- package/dist/esm/index.mjs +144 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/permit2-DhJRUcgY.d.mts +729 -0
- package/dist/esm/rpc-DULZzRne.d.mts +13 -0
- package/dist/esm/scheme-CkNhpXrG.d.mts +307 -0
- package/dist/esm/scheme-D8ZbykGV.d.mts +47 -0
- package/dist/esm/signer-BFelv8DL.d.mts +170 -0
- package/dist/esm/storage-6W5MO46W.d.mts +50 -0
- package/dist/esm/storage-BEzTEiUr.d.mts +81 -0
- package/dist/esm/types-DIt9uAUy.d.mts +180 -0
- package/dist/esm/upto/client/index.d.mts +34 -0
- package/dist/esm/upto/client/index.mjs +22 -0
- package/dist/esm/upto/client/index.mjs.map +1 -0
- package/dist/esm/upto/facilitator/index.d.mts +54 -0
- package/dist/esm/upto/facilitator/index.mjs +507 -0
- package/dist/esm/upto/facilitator/index.mjs.map +1 -0
- package/dist/esm/upto/server/index.d.mts +69 -0
- package/dist/esm/upto/server/index.mjs +124 -0
- package/dist/esm/upto/server/index.mjs.map +1 -0
- package/dist/esm/v1/index.d.mts +40 -0
- package/dist/esm/v1/index.mjs +18 -0
- package/dist/esm/v1/index.mjs.map +1 -0
- package/package.json +250 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTH_CAPTURE_ESCROW_ADDRESS,
|
|
3
|
+
AUTH_CAPTURE_SCHEME,
|
|
4
|
+
AuthCaptureEvmScheme,
|
|
5
|
+
EIP3009_TOKEN_COLLECTOR_ADDRESS,
|
|
6
|
+
PERMIT2_TOKEN_COLLECTOR_ADDRESS
|
|
7
|
+
} from "./chunk-E4Z7PNXC.mjs";
|
|
8
|
+
import {
|
|
9
|
+
toClientEvmSigner,
|
|
10
|
+
toFacilitatorEvmSigner
|
|
11
|
+
} from "./chunk-3WZF6722.mjs";
|
|
12
|
+
import {
|
|
13
|
+
BatchSettlementEvmScheme
|
|
14
|
+
} from "./chunk-GQVMVP4N.mjs";
|
|
15
|
+
import "./chunk-W6ON4LG2.mjs";
|
|
16
|
+
import {
|
|
17
|
+
BATCH_SETTLEMENT_ADDRESS,
|
|
18
|
+
BATCH_SETTLEMENT_DOMAIN,
|
|
19
|
+
BATCH_SETTLEMENT_SCHEME,
|
|
20
|
+
ERC3009_DEPOSIT_COLLECTOR_ADDRESS,
|
|
21
|
+
claimBatchTypes,
|
|
22
|
+
refundTypes,
|
|
23
|
+
voucherTypes
|
|
24
|
+
} from "./chunk-HYABYUBD.mjs";
|
|
25
|
+
import {
|
|
26
|
+
ExactEvmScheme
|
|
27
|
+
} from "./chunk-ZCJRY5LQ.mjs";
|
|
28
|
+
import {
|
|
29
|
+
DEFAULT_STABLECOINS,
|
|
30
|
+
getDefaultAsset
|
|
31
|
+
} from "./chunk-H3KPLYGI.mjs";
|
|
32
|
+
import {
|
|
33
|
+
isEIP3009Payload,
|
|
34
|
+
isPermit2Payload,
|
|
35
|
+
isUptoPermit2Payload
|
|
36
|
+
} from "./chunk-JK7SLLF7.mjs";
|
|
37
|
+
import {
|
|
38
|
+
isBatchSettlementClaimPayload,
|
|
39
|
+
isBatchSettlementDepositPayload,
|
|
40
|
+
isBatchSettlementEnrichedRefundPayload,
|
|
41
|
+
isBatchSettlementRefundPayload,
|
|
42
|
+
isBatchSettlementSettlePayload,
|
|
43
|
+
isBatchSettlementVoucherPayload
|
|
44
|
+
} from "./chunk-U4HCGTLU.mjs";
|
|
45
|
+
import "./chunk-XG2JLZVJ.mjs";
|
|
46
|
+
import {
|
|
47
|
+
UptoEvmScheme
|
|
48
|
+
} from "./chunk-I2DVUHM5.mjs";
|
|
49
|
+
import {
|
|
50
|
+
createPermit2ApprovalTx,
|
|
51
|
+
getPermit2AllowanceReadParams
|
|
52
|
+
} from "./chunk-QVATVA3J.mjs";
|
|
53
|
+
import "./chunk-H2EYJIZL.mjs";
|
|
54
|
+
import "./chunk-P3QOX3QZ.mjs";
|
|
55
|
+
import {
|
|
56
|
+
BUILDER_CODE_KEY,
|
|
57
|
+
appendDataSuffix,
|
|
58
|
+
resolveDataSuffix
|
|
59
|
+
} from "./chunk-JNT7C46S.mjs";
|
|
60
|
+
import {
|
|
61
|
+
PERMIT2_ADDRESS,
|
|
62
|
+
authorizationTypes,
|
|
63
|
+
eip3009ABI,
|
|
64
|
+
erc20AllowanceAbi,
|
|
65
|
+
permit2WitnessTypes,
|
|
66
|
+
uptoPermit2WitnessTypes,
|
|
67
|
+
x402ExactPermit2ProxyABI,
|
|
68
|
+
x402ExactPermit2ProxyAddress,
|
|
69
|
+
x402UptoPermit2ProxyABI,
|
|
70
|
+
x402UptoPermit2ProxyAddress
|
|
71
|
+
} from "./chunk-MACPBXCT.mjs";
|
|
72
|
+
import "./chunk-VS3RYAYE.mjs";
|
|
73
|
+
import "./chunk-TW7Z65AO.mjs";
|
|
74
|
+
|
|
75
|
+
// src/auth-capture/types.ts
|
|
76
|
+
function isAuthCaptureExtra(value) {
|
|
77
|
+
if (typeof value !== "object" || value === null) return false;
|
|
78
|
+
const v = value;
|
|
79
|
+
return typeof v.captureAuthorizer === "string" && typeof v.captureDeadline === "number" && typeof v.refundDeadline === "number" && typeof v.feeRecipient === "string" && typeof v.minFeeBps === "number" && typeof v.maxFeeBps === "number" && typeof v.name === "string" && typeof v.version === "string";
|
|
80
|
+
}
|
|
81
|
+
function isEip3009Payload(value) {
|
|
82
|
+
if (typeof value !== "object" || value === null) return false;
|
|
83
|
+
const v = value;
|
|
84
|
+
return "authorization" in v && typeof v.authorization === "object" && v.authorization !== null && typeof v.signature === "string" && typeof v.salt === "string";
|
|
85
|
+
}
|
|
86
|
+
function isPermit2Payload2(value) {
|
|
87
|
+
if (typeof value !== "object" || value === null) return false;
|
|
88
|
+
const v = value;
|
|
89
|
+
if (typeof v.signature !== "string" || typeof v.salt !== "string") return false;
|
|
90
|
+
if (typeof v.permit2Authorization !== "object" || v.permit2Authorization === null) return false;
|
|
91
|
+
const a = v.permit2Authorization;
|
|
92
|
+
return typeof a.from === "string" && typeof a.spender === "string" && typeof a.nonce === "string" && typeof a.deadline === "string" && typeof a.permitted === "object" && a.permitted !== null;
|
|
93
|
+
}
|
|
94
|
+
function isAuthCapturePayload(value) {
|
|
95
|
+
return isEip3009Payload(value) || isPermit2Payload2(value);
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
AUTH_CAPTURE_ESCROW_ADDRESS,
|
|
99
|
+
AUTH_CAPTURE_SCHEME,
|
|
100
|
+
AuthCaptureEvmScheme,
|
|
101
|
+
BATCH_SETTLEMENT_ADDRESS,
|
|
102
|
+
BATCH_SETTLEMENT_DOMAIN,
|
|
103
|
+
BATCH_SETTLEMENT_SCHEME,
|
|
104
|
+
BUILDER_CODE_KEY,
|
|
105
|
+
BatchSettlementEvmScheme,
|
|
106
|
+
DEFAULT_STABLECOINS,
|
|
107
|
+
EIP3009_TOKEN_COLLECTOR_ADDRESS,
|
|
108
|
+
ERC3009_DEPOSIT_COLLECTOR_ADDRESS,
|
|
109
|
+
ExactEvmScheme,
|
|
110
|
+
PERMIT2_ADDRESS,
|
|
111
|
+
PERMIT2_TOKEN_COLLECTOR_ADDRESS,
|
|
112
|
+
UptoEvmScheme,
|
|
113
|
+
appendDataSuffix,
|
|
114
|
+
authorizationTypes,
|
|
115
|
+
claimBatchTypes,
|
|
116
|
+
createPermit2ApprovalTx,
|
|
117
|
+
eip3009ABI,
|
|
118
|
+
erc20AllowanceAbi,
|
|
119
|
+
getDefaultAsset,
|
|
120
|
+
getPermit2AllowanceReadParams,
|
|
121
|
+
isAuthCaptureExtra,
|
|
122
|
+
isAuthCapturePayload,
|
|
123
|
+
isBatchSettlementClaimPayload,
|
|
124
|
+
isBatchSettlementDepositPayload,
|
|
125
|
+
isBatchSettlementEnrichedRefundPayload,
|
|
126
|
+
isBatchSettlementRefundPayload,
|
|
127
|
+
isBatchSettlementSettlePayload,
|
|
128
|
+
isBatchSettlementVoucherPayload,
|
|
129
|
+
isEIP3009Payload,
|
|
130
|
+
isPermit2Payload,
|
|
131
|
+
isUptoPermit2Payload,
|
|
132
|
+
permit2WitnessTypes,
|
|
133
|
+
refundTypes,
|
|
134
|
+
resolveDataSuffix,
|
|
135
|
+
toClientEvmSigner,
|
|
136
|
+
toFacilitatorEvmSigner,
|
|
137
|
+
uptoPermit2WitnessTypes,
|
|
138
|
+
voucherTypes,
|
|
139
|
+
x402ExactPermit2ProxyABI,
|
|
140
|
+
x402ExactPermit2ProxyAddress,
|
|
141
|
+
x402UptoPermit2ProxyABI,
|
|
142
|
+
x402UptoPermit2ProxyAddress
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth-capture/types.ts"],"sourcesContent":["/**\n * auth-capture wire-format types.\n *\n * Spec-level field names (captureAuthorizer, captureDeadline, refundDeadline,\n * feeRecipient) live here at the extra/wire layer. The on-chain PaymentInfo\n * struct keeps the canonical Solidity field names (operator, authorizationExpiry,\n * refundExpiry, feeReceiver) so the EIP-712 typehash stays byte-identical with\n * the AuthCaptureEscrow contract.\n *\n * Salt is NOT in extra. It is generated client-side per signing call and rides\n * on the payload alongside the signature.\n */\n\nimport type { AssetTransferMethod } from \"../types\";\n\n// AuthCaptureExtra — fields in PaymentRequirements.extra.\n//\n// Fee-policy fields (minFeeBps, maxFeeBps, feeRecipient) are all required.\n// No implicit defaults: a merchant who wants no minimum fee writes\n// `minFeeBps: 0` explicitly. This forces fee policy to be a conscious choice\n// on the wire and avoids \"did they mean 0 or did they forget?\" ambiguity.\nexport interface AuthCaptureExtra {\n // Required\n // The only address allowed to call authorize/capture/void/refund/charge on\n // AuthCaptureEscrow (each of those is gated by onlySender(paymentInfo.operator))\n // — i.e., it must be msg.sender of the \"Authorize\" call. In x402's\n // facilitator-submits flow that means either the facilitator's EOA, or any\n // smart contract that ultimately calls escrow (arbiter with dispute logic,\n // multisig, etc.). Independent of assetTransferMethod — applies to both\n // EIP-3009 and Permit2.\n captureAuthorizer: `0x${string}`; // formerly `operator` in commerce-payments\n captureDeadline: number; // absolute Unix seconds; capture must occur before this\n refundDeadline: number; // absolute Unix seconds; refunds allowed until this\n feeRecipient: `0x${string}`; // address that receives the fee portion (renamed from feeReceiver)\n minFeeBps: number; // floor on the captureAuthorizer's fee; 0 = no minimum\n maxFeeBps: number; // cap on the captureAuthorizer's fee\n name: string; // EIP-712 token-domain name (e.g., \"USDC\")\n version: string; // EIP-712 token-domain version (e.g., \"2\")\n // Optional\n autoCapture?: boolean; // default: false. true → facilitator calls charge(), false → authorize()\n assetTransferMethod?: AssetTransferMethod; // default: 'eip3009'\n}\n\n/**\n * Type guard for AuthCaptureExtra. Checks the structural shape an auth-capture\n * scheme requires inside `PaymentRequirements.extra`: every spec-mandated\n * required field present with the right primitive type.\n *\n * @param value - Candidate object from `requirements.extra`.\n * @returns True if `value` has every required AuthCaptureExtra field.\n */\nexport function isAuthCaptureExtra(value: unknown): value is AuthCaptureExtra {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n return (\n typeof v.captureAuthorizer === \"string\" &&\n typeof v.captureDeadline === \"number\" &&\n typeof v.refundDeadline === \"number\" &&\n typeof v.feeRecipient === \"string\" &&\n typeof v.minFeeBps === \"number\" &&\n typeof v.maxFeeBps === \"number\" &&\n typeof v.name === \"string\" &&\n typeof v.version === \"string\"\n );\n}\n\n// EIP-3009 payload — ReceiveWithAuthorization to the canonical EIP-3009 token collector.\nexport interface Eip3009Payload {\n authorization: {\n from: `0x${string}`;\n to: `0x${string}`; // EIP3009_TOKEN_COLLECTOR_ADDRESS\n value: string;\n validAfter: string;\n validBefore: string; // = preApprovalExpiry\n nonce: `0x${string}`; // = payer-agnostic PaymentInfo hash\n };\n signature: `0x${string}`;\n salt: `0x${string}`; // bytes32, fresh per request, used to reconstruct PaymentInfo\n}\n\n/**\n * Type guard for an EIP-3009-shaped auth-capture payload. Checks for an\n * `authorization` object plus the required `signature` and `salt` fields;\n * field-level validation happens later in `verify()`.\n *\n * @param value - Candidate payment payload from the wire.\n * @returns True if `value` has the EIP-3009 envelope shape.\n */\nexport function isEip3009Payload(value: unknown): value is Eip3009Payload {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n return (\n \"authorization\" in v &&\n typeof v.authorization === \"object\" &&\n v.authorization !== null &&\n typeof v.signature === \"string\" &&\n typeof v.salt === \"string\"\n );\n}\n\n// Permit2 payload — PermitTransferFrom to the canonical Permit2 token collector.\nexport interface Permit2Payload {\n permit2Authorization: {\n from: `0x${string}`;\n permitted: {\n token: `0x${string}`;\n amount: string;\n };\n spender: `0x${string}`; // PERMIT2_TOKEN_COLLECTOR_ADDRESS\n nonce: string; // uint256 string, = uint256(payer-agnostic PaymentInfo hash)\n deadline: string; // = preApprovalExpiry\n };\n signature: `0x${string}`;\n salt: `0x${string}`; // bytes32, fresh per request, used to reconstruct PaymentInfo\n}\n\n/**\n * Type guard for a Permit2-shaped auth-capture payload. Checks for the\n * `permit2Authorization` envelope (with `from`, `spender`, `nonce`,\n * `deadline`, `permitted`) plus the required `signature` and `salt` fields.\n *\n * @param value - Candidate payment payload from the wire.\n * @returns True if `value` has the Permit2 envelope shape.\n */\nexport function isPermit2Payload(value: unknown): value is Permit2Payload {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n if (typeof v.signature !== \"string\" || typeof v.salt !== \"string\") return false;\n if (typeof v.permit2Authorization !== \"object\" || v.permit2Authorization === null) return false;\n const a = v.permit2Authorization as Record<string, unknown>;\n return (\n typeof a.from === \"string\" &&\n typeof a.spender === \"string\" &&\n typeof a.nonce === \"string\" &&\n typeof a.deadline === \"string\" &&\n typeof a.permitted === \"object\" &&\n a.permitted !== null\n );\n}\n\n// Discriminated union of all auth-capture payload shapes.\nexport type AuthCapturePayload = Eip3009Payload | Permit2Payload;\n\n/**\n * Type guard for any auth-capture payload. Returns true if `value` matches\n * either the EIP-3009 envelope or the Permit2 envelope.\n *\n * @param value - Candidate payment payload from the wire.\n * @returns True if `value` is a valid auth-capture envelope of either shape.\n */\nexport function isAuthCapturePayload(value: unknown): value is AuthCapturePayload {\n return isEip3009Payload(value) || isPermit2Payload(value);\n}\n\n/**\n * On-chain PaymentInfo struct (canonical Solidity names — DO NOT RENAME).\n * Reconstructed by the facilitator from extra + payload.salt + payer + receiver/asset/amount.\n */\nexport interface PaymentInfoStruct {\n operator: `0x${string}`; // = extra.captureAuthorizer\n payer: `0x${string}`;\n receiver: `0x${string}`; // = requirements.payTo\n token: `0x${string}`; // = requirements.asset\n maxAmount: string; // = requirements.amount\n preApprovalExpiry: number;\n authorizationExpiry: number; // = extra.captureDeadline\n refundExpiry: number; // = extra.refundDeadline\n minFeeBps: number;\n maxFeeBps: number;\n feeReceiver: `0x${string}`; // = extra.feeRecipient\n salt: `0x${string}`; // = payload.salt\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAAS,mBAAmB,OAA2C;AAC5E,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,IAAI;AACV,SACE,OAAO,EAAE,sBAAsB,YAC/B,OAAO,EAAE,oBAAoB,YAC7B,OAAO,EAAE,mBAAmB,YAC5B,OAAO,EAAE,iBAAiB,YAC1B,OAAO,EAAE,cAAc,YACvB,OAAO,EAAE,cAAc,YACvB,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,YAAY;AAEzB;AAwBO,SAAS,iBAAiB,OAAyC;AACxE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,IAAI;AACV,SACE,mBAAmB,KACnB,OAAO,EAAE,kBAAkB,YAC3B,EAAE,kBAAkB,QACpB,OAAO,EAAE,cAAc,YACvB,OAAO,EAAE,SAAS;AAEtB;AA0BO,SAASA,kBAAiB,OAAyC;AACxE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,cAAc,YAAY,OAAO,EAAE,SAAS,SAAU,QAAO;AAC1E,MAAI,OAAO,EAAE,yBAAyB,YAAY,EAAE,yBAAyB,KAAM,QAAO;AAC1F,QAAM,IAAI,EAAE;AACZ,SACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,YAAY,YACrB,OAAO,EAAE,UAAU,YACnB,OAAO,EAAE,aAAa,YACtB,OAAO,EAAE,cAAc,YACvB,EAAE,cAAc;AAEpB;AAYO,SAAS,qBAAqB,OAA6C;AAChF,SAAO,iBAAiB,KAAK,KAAKA,kBAAiB,KAAK;AAC1D;","names":["isPermit2Payload"]}
|