@atumlabs/mppx-atum-escrow 0.4.1 → 0.5.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/CHANGELOG.md +16 -2
- package/README.md +113 -4
- package/dist/{chunk-EWIOTGMO.js → chunk-5IQDNGVU.js} +78 -28
- package/dist/chunk-F3H73WI3.js +8358 -0
- package/dist/{chunk-IGTT7XSG.js → chunk-NVPGDBFS.js} +6671 -1261
- package/dist/client.d.ts +187 -4
- package/dist/client.js +12 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -3
- package/dist/{internal-BZBJJfaL.d.ts → internal-DwRZPk7k.d.ts} +4 -18
- package/dist/server.d.ts +52 -22
- package/dist/server.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-LAWFMGYD.js +0 -3707
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,170 @@
|
|
|
1
1
|
import * as zod_v4_core from 'zod/v4/core';
|
|
2
2
|
import * as z from 'zod/mini';
|
|
3
|
-
import { S as SenderSigner, h as SenderSignerOptions, k as SolanaClusterUnixTimeReader } from './internal-
|
|
4
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, i as atumEscrowChargeMethod } from './internal-
|
|
3
|
+
import { S as SenderSigner, h as SenderSignerOptions, k as SolanaClusterUnixTimeReader } from './internal-DwRZPk7k.js';
|
|
4
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, i as atumEscrowChargeMethod } from './internal-DwRZPk7k.js';
|
|
5
5
|
import { Method } from 'mppx';
|
|
6
6
|
import { Signer } from 'ethers';
|
|
7
7
|
export { PaymentRequest } from './generated/index.js';
|
|
8
|
-
import './sender-auth-verify-
|
|
8
|
+
import './sender-auth-verify-BbTnhw79.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The payer's trust source for atum-escrow corridors.
|
|
12
|
+
*
|
|
13
|
+
* An MPP challenge names the escrow, the fulfillment proxy, the reserver and the releaser the
|
|
14
|
+
* payer is about to sign into its deposit authorization. The merchant writes those values, but the
|
|
15
|
+
* reserver decides who is paid and how much of the cap, and the releaser decides when the escrow
|
|
16
|
+
* opens, so they are the payer's trust points to choose. The client therefore checks each one
|
|
17
|
+
* against a source the payer controls before signing anything; the challenge is a claim, not an
|
|
18
|
+
* authority.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A token a trust source vouches for on one chain. `decimals` is what lets the client compare a
|
|
22
|
+
* source-token cap with a destination-token price.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
interface TrustedToken {
|
|
27
|
+
symbol: string;
|
|
28
|
+
address: string;
|
|
29
|
+
decimals: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The addresses a trust source vouches for on one chain.
|
|
33
|
+
*
|
|
34
|
+
* The keys match the corridor defaults the signing library takes, so a trusted set can be compared
|
|
35
|
+
* field by field with what a challenge asks the payer to sign.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
interface TrustedRoles {
|
|
40
|
+
/** The source escrow contract: the Permit2 spender a deposit authorizes. */
|
|
41
|
+
escrowContract: string;
|
|
42
|
+
/** The account that signs reserve witnesses (the challenge's `reserver`). */
|
|
43
|
+
quoteSelector: string;
|
|
44
|
+
/** The account that signs release and refund witnesses (the challenge's `releaser`). */
|
|
45
|
+
fulfillmentVerifierAccount: string;
|
|
46
|
+
/** The fulfillment proxy, compared on the chain the payment is delivered on. */
|
|
47
|
+
fulfillmentProxy: string;
|
|
48
|
+
/** The tokens payable on this chain; a payment in any other token is refused. */
|
|
49
|
+
tokens: ReadonlyArray<TrustedToken>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Answers which addresses the payer trusts on a chain, given its CAIP-2 id.
|
|
53
|
+
*
|
|
54
|
+
* Rejects with {@link AtumEscrowTrustError} `CHAIN_NOT_TRUSTED` when it vouches for nothing on the
|
|
55
|
+
* chain, and `TRUST_SOURCE_UNAVAILABLE` when it cannot find out. Any other rejection is reported by
|
|
56
|
+
* the client as `TRUST_SOURCE_UNAVAILABLE`.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
type TrustResolver = (network: string) => Promise<TrustedRoles>;
|
|
61
|
+
/**
|
|
62
|
+
* Why a payment was refused before signing.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
type AtumEscrowTrustErrorCode = 'UNTRUSTED_ESCROW' | 'UNTRUSTED_RESERVER' | 'UNTRUSTED_RELEASER' | 'UNTRUSTED_FULFILLMENT_PROXY' | 'UNTRUSTED_ASSET' | 'ASSETS_NOT_COMPARABLE' | 'MARKUP_EXCEEDED' | 'CHAIN_NOT_TRUSTED' | 'TRUST_SOURCE_UNAVAILABLE';
|
|
67
|
+
/**
|
|
68
|
+
* A payment the client refused to sign because its corridor is not one the payer trusts.
|
|
69
|
+
*
|
|
70
|
+
* `code` is the stable thing to branch on. For the `UNTRUSTED_*` codes and `MARKUP_EXCEEDED`,
|
|
71
|
+
* `field` names the challenge member that failed and `actual` the value the challenge asked for;
|
|
72
|
+
* `expected`, when set, is the trusted value or, for `MARKUP_EXCEEDED`, the largest amount
|
|
73
|
+
* allowed. Values are reported as written.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
declare class AtumEscrowTrustError extends Error {
|
|
78
|
+
readonly code: AtumEscrowTrustErrorCode;
|
|
79
|
+
readonly network: string;
|
|
80
|
+
readonly field?: string;
|
|
81
|
+
readonly expected?: string;
|
|
82
|
+
readonly actual?: string;
|
|
83
|
+
constructor(init: {
|
|
84
|
+
code: AtumEscrowTrustErrorCode;
|
|
85
|
+
network: string;
|
|
86
|
+
message: string;
|
|
87
|
+
field?: string;
|
|
88
|
+
expected?: string;
|
|
89
|
+
actual?: string;
|
|
90
|
+
cause?: unknown;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The payment gateways the client asks when the payer supplies no trust source: Atum's production
|
|
95
|
+
* mainnet and production testnet deployments. Their chain ids never overlap, so at most one serves
|
|
96
|
+
* a given chain.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
declare const ATUM_DEFAULT_TRUST_GATEWAYS: readonly string[];
|
|
101
|
+
/**
|
|
102
|
+
* Options for {@link atumGatewayTrust}.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
interface AtumGatewayTrustOptions {
|
|
107
|
+
/**
|
|
108
|
+
* Gateway base URLs to ask. Defaults to {@link ATUM_DEFAULT_TRUST_GATEWAYS}.
|
|
109
|
+
*
|
|
110
|
+
* Each chain must be served by at most one gateway in the list: the first trusted answer is
|
|
111
|
+
* used, so two gateways vouching for different roles on one chain would make the outcome depend
|
|
112
|
+
* on which answers first.
|
|
113
|
+
*
|
|
114
|
+
* Trailing slashes are removed; an entry with nothing left after that (`''`, `'/'`) is refused
|
|
115
|
+
* when the resolver is built. An empty list trusts no chain.
|
|
116
|
+
*/
|
|
117
|
+
gateways?: readonly string[];
|
|
118
|
+
/** The `fetch` to use. Defaults to the global one, read at call time. */
|
|
119
|
+
fetch?: typeof fetch;
|
|
120
|
+
/** Clock for cache expiry, in epoch milliseconds. Defaults to `Date.now`. */
|
|
121
|
+
now?: () => number;
|
|
122
|
+
/** How long a trusted answer is reused, in milliseconds. Defaults to 300000. */
|
|
123
|
+
ttlMs?: number;
|
|
124
|
+
/** How long one gateway may take to answer, in milliseconds. Defaults to 5000. */
|
|
125
|
+
timeoutMs?: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A trust source backed by payment gateways' `GET /v1/defaults`.
|
|
129
|
+
*
|
|
130
|
+
* Every gateway is asked. The first well-formed answer for the chain is trusted. Only when every
|
|
131
|
+
* gateway answers 404 is the chain reported as not trusted: a gateway that failed might have been
|
|
132
|
+
* the one serving it, so any failure without a usable answer is reported as unavailable instead.
|
|
133
|
+
* Trusted answers are cached per chain, and concurrent lookups for a chain share one round of
|
|
134
|
+
* requests; failures are never cached, so recovery needs no wait.
|
|
135
|
+
*
|
|
136
|
+
* @throws `Error` when a configured gateway is empty once its trailing slashes are removed.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
declare function atumGatewayTrust(options?: AtumGatewayTrustOptions): TrustResolver;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The payer's bound on the spend cap.
|
|
144
|
+
*
|
|
145
|
+
* The cap (`source.amount`) is the most the escrow may ever pull from the payer. An honest auction
|
|
146
|
+
* charges less, but a thin auction, a compromised quote selector or a bug can charge up to the cap,
|
|
147
|
+
* so the payer refuses a cap further above the price than it allows. The price is
|
|
148
|
+
* `fulfillmentAmount`, in the destination token; the cap is in the source token, so both are
|
|
149
|
+
* compared in one unit, and only between tokens the payer treats as the same money.
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The markup over `fulfillmentAmount`, in basis points, the client accepts when the payer sets
|
|
154
|
+
* none: room above the 3% the merchant SDK documents, while bounding the payer's extra exposure.
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
declare const DEFAULT_MAX_MARKUP_BPS = 500;
|
|
159
|
+
/**
|
|
160
|
+
* Tokens the client treats as interchangeable 1:1 when the payer sets none: the US-dollar
|
|
161
|
+
* stablecoins on the network's allowlists. The allowlist records only symbol, address and
|
|
162
|
+
* decimals, so this list is the peg assumption itself. A token outside every group is comparable
|
|
163
|
+
* only with itself.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
declare const DEFAULT_PEG_GROUPS: ReadonlyArray<ReadonlyArray<string>>;
|
|
9
168
|
|
|
10
169
|
/**
|
|
11
170
|
* Result of an {@link ensureSourceApproval} call.
|
|
@@ -206,6 +365,30 @@ interface AtumEscrowClientConfig {
|
|
|
206
365
|
* used. Ignored for EVM/Tron.
|
|
207
366
|
*/
|
|
208
367
|
solanaClockReader?: SolanaClusterUnixTimeReader;
|
|
368
|
+
/**
|
|
369
|
+
* Where the payer learns which escrow, fulfillment proxy, reserver and releaser it trusts on a
|
|
370
|
+
* chain. Every challenge is checked against it before anything is signed, and a challenge naming
|
|
371
|
+
* any other address is refused.
|
|
372
|
+
*
|
|
373
|
+
* @remarks
|
|
374
|
+
* Optional. Without it, the client asks Atum's production gateways (see
|
|
375
|
+
* {@link atumGatewayTrust} and {@link ATUM_DEFAULT_TRUST_GATEWAYS}). Pass your own resolver to
|
|
376
|
+
* trust another deployment — staging, a local devnet (which reuses mainnet chain ids), or another
|
|
377
|
+
* operator — or a fixed set of addresses. The check itself cannot be turned off.
|
|
378
|
+
*/
|
|
379
|
+
trust?: TrustResolver;
|
|
380
|
+
/**
|
|
381
|
+
* The most the cap (`source.amount`) may exceed `fulfillmentAmount`, in basis points, after both
|
|
382
|
+
* are put in one unit. A larger cap is refused before signing. Defaults to
|
|
383
|
+
* {@link DEFAULT_MAX_MARKUP_BPS}.
|
|
384
|
+
*/
|
|
385
|
+
maxMarkupBps?: number;
|
|
386
|
+
/**
|
|
387
|
+
* Groups of token symbols the payer treats as the same money, so a cap in one can be priced
|
|
388
|
+
* against a fulfillment in another. Replaces {@link DEFAULT_PEG_GROUPS}; a token outside every
|
|
389
|
+
* group is comparable only with itself.
|
|
390
|
+
*/
|
|
391
|
+
pegGroups?: ReadonlyArray<ReadonlyArray<string>>;
|
|
209
392
|
}
|
|
210
393
|
/**
|
|
211
394
|
* Configure the payer side of the method.
|
|
@@ -267,4 +450,4 @@ declare function registerClient(config: AtumEscrowClientConfig): Method.Client<{
|
|
|
267
450
|
};
|
|
268
451
|
}, undefined>;
|
|
269
452
|
|
|
270
|
-
export { type ApprovalParams, type AtumEscrowClientConfig, type ConfirmationOptions, type EnsureApprovalResult, SenderSigner, SenderSignerOptions, type TronWebLike, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient };
|
|
453
|
+
export { ATUM_DEFAULT_TRUST_GATEWAYS, type ApprovalParams, type AtumEscrowClientConfig, AtumEscrowTrustError, type AtumEscrowTrustErrorCode, type AtumGatewayTrustOptions, type ConfirmationOptions, DEFAULT_MAX_MARKUP_BPS, DEFAULT_PEG_GROUPS, type EnsureApprovalResult, SenderSigner, SenderSignerOptions, type TronWebLike, type TrustResolver, type TrustedRoles, type TrustedToken, atumGatewayTrust, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient };
|
package/dist/client.js
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
6
6
|
import {
|
|
7
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
8
|
+
AtumEscrowTrustError,
|
|
9
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
10
|
+
DEFAULT_PEG_GROUPS,
|
|
11
|
+
atumGatewayTrust,
|
|
7
12
|
import_payment_request_token_approval,
|
|
8
13
|
registerClient
|
|
9
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NVPGDBFS.js";
|
|
10
15
|
import {
|
|
11
16
|
ChargeRequestSchema,
|
|
12
17
|
CredentialPayloadSchema,
|
|
@@ -14,17 +19,22 @@ import {
|
|
|
14
19
|
INTENT_ID_META_KEY,
|
|
15
20
|
METHOD_NAME,
|
|
16
21
|
atumEscrowChargeMethod
|
|
17
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-F3H73WI3.js";
|
|
18
23
|
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
19
24
|
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
20
25
|
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
21
26
|
export {
|
|
27
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
28
|
+
AtumEscrowTrustError,
|
|
22
29
|
ChargeRequestSchema,
|
|
23
30
|
CredentialPayloadSchema,
|
|
31
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
32
|
+
DEFAULT_PEG_GROUPS,
|
|
24
33
|
INTENT,
|
|
25
34
|
INTENT_ID_META_KEY,
|
|
26
35
|
METHOD_NAME,
|
|
27
36
|
atumEscrowChargeMethod,
|
|
37
|
+
atumGatewayTrust,
|
|
28
38
|
export_ensureSourceApproval as ensureSourceApproval,
|
|
29
39
|
export_isUnconfirmed as isUnconfirmed,
|
|
30
40
|
export_needsSourceApproval as needsSourceApproval,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowExtra, c as AtumEscrowRequest, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, S as SenderSigner, h as SenderSignerOptions, i as atumEscrowChargeMethod } from './internal-
|
|
2
|
-
export { ApprovalParams, AtumEscrowClientConfig, ConfirmationOptions, EnsureApprovalResult, TronWebLike, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient } from './client.js';
|
|
3
|
-
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServer, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, ChargeChallenge, FulfillmentConfirmation, PaymentRejectedError, PaymentSettlementStatus, PaymentSubmitResult, PaymentSubmitter, SettlementErrorDetails, SettlementFailedError, SettlementPendingError, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor } from './server.js';
|
|
1
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowExtra, c as AtumEscrowRequest, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, S as SenderSigner, h as SenderSignerOptions, i as atumEscrowChargeMethod } from './internal-DwRZPk7k.js';
|
|
2
|
+
export { ATUM_DEFAULT_TRUST_GATEWAYS, ApprovalParams, AtumEscrowClientConfig, AtumEscrowTrustError, AtumEscrowTrustErrorCode, AtumGatewayTrustOptions, ConfirmationOptions, DEFAULT_MAX_MARKUP_BPS, DEFAULT_PEG_GROUPS, EnsureApprovalResult, TronWebLike, TrustResolver, TrustedRoles, TrustedToken, atumGatewayTrust, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient } from './client.js';
|
|
3
|
+
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServer, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, ChargeChallenge, CommitmentOutcome, CommitmentResult, FulfillmentConfirmation, PaymentRejectedError, PaymentSettlementStatus, PaymentSubmitResult, PaymentSubmitter, SettlementErrorDetails, SettlementFailedError, SettlementPendingError, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor } from './server.js';
|
|
4
4
|
export { PaymentRequest } from './generated/index.js';
|
|
5
|
-
import './sender-auth-verify-
|
|
5
|
+
import './sender-auth-verify-BbTnhw79.js';
|
|
6
6
|
import 'zod/mini';
|
|
7
7
|
import 'mppx';
|
|
8
8
|
import 'zod/v4/core';
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
6
6
|
import {
|
|
7
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
8
|
+
AtumEscrowTrustError,
|
|
9
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
10
|
+
DEFAULT_PEG_GROUPS,
|
|
11
|
+
atumGatewayTrust,
|
|
7
12
|
import_payment_request_token_approval,
|
|
8
13
|
registerClient
|
|
9
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NVPGDBFS.js";
|
|
10
15
|
import {
|
|
11
16
|
PaymentRejectedError,
|
|
12
17
|
SettlementFailedError,
|
|
@@ -19,7 +24,7 @@ import {
|
|
|
19
24
|
isSettlementPending,
|
|
20
25
|
registerServer,
|
|
21
26
|
validateCorridor
|
|
22
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5IQDNGVU.js";
|
|
23
28
|
import {
|
|
24
29
|
ChargeRequestSchema,
|
|
25
30
|
CredentialPayloadSchema,
|
|
@@ -27,13 +32,17 @@ import {
|
|
|
27
32
|
INTENT_ID_META_KEY,
|
|
28
33
|
METHOD_NAME,
|
|
29
34
|
atumEscrowChargeMethod
|
|
30
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-F3H73WI3.js";
|
|
31
36
|
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
32
37
|
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
33
38
|
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
34
39
|
export {
|
|
40
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
41
|
+
AtumEscrowTrustError,
|
|
35
42
|
ChargeRequestSchema,
|
|
36
43
|
CredentialPayloadSchema,
|
|
44
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
45
|
+
DEFAULT_PEG_GROUPS,
|
|
37
46
|
INTENT,
|
|
38
47
|
INTENT_ID_META_KEY,
|
|
39
48
|
METHOD_NAME,
|
|
@@ -41,6 +50,7 @@ export {
|
|
|
41
50
|
SettlementFailedError,
|
|
42
51
|
SettlementPendingError,
|
|
43
52
|
atumEscrowChargeMethod,
|
|
53
|
+
atumGatewayTrust,
|
|
44
54
|
buildChargeChallenge,
|
|
45
55
|
buildChargeRequest,
|
|
46
56
|
corridorFromDefaults,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B } from './sender-auth-verify-BbTnhw79.js';
|
|
2
2
|
import * as z from 'zod/mini';
|
|
3
3
|
import { PaymentRequest } from './generated/index.js';
|
|
4
4
|
import { Challenge, Credential } from 'mppx';
|
|
@@ -14,22 +14,8 @@ interface ChainDefaults {
|
|
|
14
14
|
fulfillmentProxy: string;
|
|
15
15
|
permit2Contract?: string;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* same fact in `svmSignatureDomainVersion` below.
|
|
20
|
-
*
|
|
21
|
-
* `4` and above select the four-member witness
|
|
22
|
-
* (`depositRequestHash`, `destination`, `reserver`, `releaser`); `3` selects the two-member
|
|
23
|
-
* witness a not-yet-redeployed escrow pins. ABSENT means four — see the sender-auth package's
|
|
24
|
-
* `ChainDefaults.depositWitnessVersion` for why absence is the permissive default.
|
|
25
|
-
*
|
|
26
|
-
* Passed through to the sender_auth adapter verbatim; this type only has to carry it.
|
|
27
|
-
*/
|
|
28
|
-
depositWitnessVersion?: number;
|
|
29
|
-
/**
|
|
30
|
-
* V3 Solana escrow domain-separation fields, surfaced by payment-gw
|
|
31
|
-
* `/v1/defaults` for Solana source chains. Used to build the EscrowDomain that the
|
|
32
|
-
* V3 deposit hash binds to. Absent for EVM/Tron.
|
|
17
|
+
* Solana escrow domain-separation fields, used to build the EscrowDomain the deposit hash
|
|
18
|
+
* binds to. Absent for EVM/Tron.
|
|
33
19
|
*/
|
|
34
20
|
svmSignatureClusterId?: string;
|
|
35
21
|
svmSignatureDomainVersion?: number;
|
|
@@ -90,7 +76,7 @@ interface SenderSignature {
|
|
|
90
76
|
}
|
|
91
77
|
/** Signs a single sender_auth signed message for a payment request. */
|
|
92
78
|
interface SenderSigner {
|
|
93
|
-
sign(signedMessage:
|
|
79
|
+
sign(signedMessage: B): Promise<SenderSignature>;
|
|
94
80
|
}
|
|
95
81
|
/** Turnkey provider configuration (shared by the SDK and the CLI env loader). */
|
|
96
82
|
interface TurnkeyConfig {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import { i as atumEscrowChargeMethod, j as ChainDefaults, d as ChargeRequest } from './internal-BZBJJfaL.js';
|
|
2
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME } from './internal-BZBJJfaL.js';
|
|
3
|
-
import { Errors, Receipt, Method } from 'mppx';
|
|
4
1
|
import { PaymentRequest } from './generated/index.js';
|
|
5
2
|
export { PaymentRequest } from './generated/index.js';
|
|
6
|
-
import './
|
|
3
|
+
import { i as atumEscrowChargeMethod, j as ChainDefaults, d as ChargeRequest } from './internal-DwRZPk7k.js';
|
|
4
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME } from './internal-DwRZPk7k.js';
|
|
5
|
+
import { Errors, Receipt, Method } from 'mppx';
|
|
6
|
+
import './sender-auth-verify-BbTnhw79.js';
|
|
7
7
|
import 'zod/mini';
|
|
8
8
|
|
|
9
|
+
/** Verdict of a destination-commitment check. Only `verified` admits a payment. */
|
|
10
|
+
type CommitmentOutcome = 'verified'
|
|
11
|
+
/** The source chain is unsupported, or message_scheme cannot authorise a payment from it. */
|
|
12
|
+
| 'scheme_mismatch'
|
|
13
|
+
/** The signed deposit commits no destination or no request hash. */
|
|
14
|
+
| 'commitment_absent'
|
|
15
|
+
/** message_prehash is unreadable, ambiguous, or not the document behind the signed digest. */
|
|
16
|
+
| 'prehash_mismatch'
|
|
17
|
+
/** The deposit is not signed by, or not made out to, the payment's source account. */
|
|
18
|
+
| 'signer_mismatch'
|
|
19
|
+
/** The signed destination is not the payment's destination. */
|
|
20
|
+
| 'destination_mismatch'
|
|
21
|
+
/** The signed depositRequestHash is not keccak256 of the payment's request_id. */
|
|
22
|
+
| 'request_hash_mismatch'
|
|
23
|
+
/** The payment request document is unreadable or ambiguous. */
|
|
24
|
+
| 'request_malformed'
|
|
25
|
+
/** The verifier did not supply what the check needs. */
|
|
26
|
+
| 'verifier_misconfigured';
|
|
27
|
+
/** The outcome of a check plus the values it compared, for admissions and refusals alike. */
|
|
28
|
+
interface CommitmentResult {
|
|
29
|
+
outcome: CommitmentOutcome;
|
|
30
|
+
detail: string;
|
|
31
|
+
namespace: string;
|
|
32
|
+
scheme: string;
|
|
33
|
+
signedDestination: string;
|
|
34
|
+
expectedDestination: string;
|
|
35
|
+
signedDepositRequestHash: string;
|
|
36
|
+
expectedDepositRequestHash: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
/**
|
|
10
40
|
* This file was automatically generated by json-schema-to-typescript.
|
|
11
41
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
@@ -246,7 +276,6 @@ interface AtumEscrowCorridor {
|
|
|
246
276
|
* `finalizing` means the payment is on chain but has not yet reached the confirmation depth its
|
|
247
277
|
* chain requires. It is NOT terminal: a payer must keep waiting on the same idempotency key, never
|
|
248
278
|
* start a second payment for it.
|
|
249
|
-
*
|
|
250
279
|
*/
|
|
251
280
|
type PaymentSettlementStatus = 'pending' | 'finalizing' | 'completed' | 'failed';
|
|
252
281
|
/** What a {@link PaymentSubmitter} resolves with. */
|
|
@@ -268,10 +297,8 @@ interface PaymentSubmitResult {
|
|
|
268
297
|
*
|
|
269
298
|
* Submit and return what the gateway said; do not poll for completion inside the submitter.
|
|
270
299
|
* A payment that outlives the gateway's synchronous window surfaces to the payer as
|
|
271
|
-
* {@link SettlementPendingError}, and the payer's retry of the same purchase
|
|
272
|
-
*
|
|
273
|
-
* instead holds the merchant's request open for the full settlement window and hides the pending
|
|
274
|
-
* state that makes the retry safe.
|
|
300
|
+
* {@link SettlementPendingError}, and the payer's retry of the same purchase resolves to the same
|
|
301
|
+
* payment and collects the result.
|
|
275
302
|
*
|
|
276
303
|
* Throw {@link PaymentRejectedError} when the gateway refuses the request, so the refusal keeps
|
|
277
304
|
* its code. Any other throw is treated as an unknown outcome.
|
|
@@ -285,7 +312,15 @@ interface AtumEscrowServerConfig {
|
|
|
285
312
|
submitter: PaymentSubmitter;
|
|
286
313
|
/** Clock (epoch ms) used to validate deadline ordering and budgets. Defaults to `Date.now`. */
|
|
287
314
|
now?: () => number;
|
|
315
|
+
/**
|
|
316
|
+
* Called with the result of every payee check, admissions and refusals alike, so you can count
|
|
317
|
+
* payments by `logFields.sender_auth_result` and log each refusal with all of `logFields`. A
|
|
318
|
+
* refused payment still throws; an exception from this callback on an admission refuses the
|
|
319
|
+
* payment with a fixed message.
|
|
320
|
+
*/
|
|
321
|
+
onCommitmentResult?: (result: CommitmentResult, logFields: Record<string, string>) => void;
|
|
288
322
|
}
|
|
323
|
+
|
|
289
324
|
/**
|
|
290
325
|
* The receipt returned once a payment settles, extending the MPP receipt with the Atum
|
|
291
326
|
* settlement details. `reference` carries the destination-chain transaction hash, and
|
|
@@ -339,10 +374,9 @@ declare function validateCorridor(corridor: AtumEscrowCorridor): void;
|
|
|
339
374
|
* signing time.
|
|
340
375
|
*
|
|
341
376
|
* Prefer {@link buildChargeChallenge}, which pairs these terms with the per-purchase identifier
|
|
342
|
-
* the payer requires. A challenge built from this function alone carries no such identifier and
|
|
343
|
-
* the payer's client refuses it
|
|
344
|
-
*
|
|
345
|
-
* payment. Reach for it directly only when supplying the per-purchase metadata by hand.
|
|
377
|
+
* the payer requires. A challenge built from this function alone carries no such identifier, and
|
|
378
|
+
* the payer's client refuses it at signing time. Use it directly only when supplying the
|
|
379
|
+
* per-purchase metadata yourself.
|
|
346
380
|
*
|
|
347
381
|
* @param corridor - the corridor to serve.
|
|
348
382
|
* @param select - which configured source to fund from, by `(network, asset)`.
|
|
@@ -350,9 +384,8 @@ declare function validateCorridor(corridor: AtumEscrowCorridor): void;
|
|
|
350
384
|
* destination token. Set per charge so one registration serves any price.
|
|
351
385
|
* @param options.issuedAt - Solana-source only: the merchant's cluster-clock reading (epoch
|
|
352
386
|
* seconds) to stamp into `extra.issuedAt`, so the payer's client builds the deposit fully
|
|
353
|
-
* offline (no RPC). Omit to let the client stamp `issued_at`
|
|
354
|
-
*
|
|
355
|
-
* earlier (at 402-build time), so only set it when the client genuinely cannot read a clock.
|
|
387
|
+
* offline (no RPC). Omit to let the client stamp `issued_at` at signing time, which keeps the
|
|
388
|
+
* full replay window; a merchant-stamped value starts the window at 402-build time.
|
|
356
389
|
* Ignored for EVM/Tron sources.
|
|
357
390
|
* @throws if no source option matches `select`, or the corridor is invalid.
|
|
358
391
|
*/
|
|
@@ -365,11 +398,8 @@ declare function buildChargeRequest(corridor: AtumEscrowCorridor, select: {
|
|
|
365
398
|
/**
|
|
366
399
|
* A charge challenge's two halves, ready to hand to the framework.
|
|
367
400
|
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* challenge-id HMAC, but nesting the metadata inside the request would bury the purchase
|
|
371
|
-
* identifier in the terms blob where the payer does not look for it — so this type keeps them in
|
|
372
|
-
* the shape the framework expects.
|
|
401
|
+
* `request` is the method-specific payment terms and `meta` is challenge metadata, matching the
|
|
402
|
+
* framework's shape. Both are covered by the challenge-id HMAC.
|
|
373
403
|
*/
|
|
374
404
|
interface ChargeChallenge {
|
|
375
405
|
/** The method-specific charge request (the payment terms). */
|
|
@@ -448,4 +478,4 @@ declare function corridorFromDefaults(defaults: ChainDefaultsSource, params: {
|
|
|
448
478
|
fulfillmentDeadlineSeconds: number;
|
|
449
479
|
}): Promise<AtumEscrowCorridor>;
|
|
450
480
|
|
|
451
|
-
export { type AtumEscrowCorridor, type AtumEscrowReceipt, type AtumEscrowServer, type AtumEscrowServerConfig, type AtumEscrowSource, type ChainDefaultsSource, type ChargeChallenge, ChargeRequest, type FulfillmentConfirmation, PaymentRejectedError, type PaymentSettlementStatus, type PaymentSubmitResult, type PaymentSubmitter, type SettlementErrorDetails, SettlementFailedError, SettlementPendingError, atumEscrowChargeMethod, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor };
|
|
481
|
+
export { type AtumEscrowCorridor, type AtumEscrowReceipt, type AtumEscrowServer, type AtumEscrowServerConfig, type AtumEscrowSource, type ChainDefaultsSource, type ChargeChallenge, ChargeRequest, type CommitmentOutcome, type CommitmentResult, type FulfillmentConfirmation, PaymentRejectedError, type PaymentSettlementStatus, type PaymentSubmitResult, type PaymentSubmitter, type SettlementErrorDetails, SettlementFailedError, SettlementPendingError, atumEscrowChargeMethod, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor };
|
package/dist/server.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
isSettlementPending,
|
|
16
16
|
registerServer,
|
|
17
17
|
validateCorridor
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5IQDNGVU.js";
|
|
19
19
|
import {
|
|
20
20
|
ChargeRequestSchema,
|
|
21
21
|
CredentialPayloadSchema,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
INTENT_ID_META_KEY,
|
|
24
24
|
METHOD_NAME,
|
|
25
25
|
atumEscrowChargeMethod
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-F3H73WI3.js";
|
|
27
27
|
export {
|
|
28
28
|
ChargeRequestSchema,
|
|
29
29
|
CredentialPayloadSchema,
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atumlabs/mppx-atum-escrow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Atum cross-chain escrow payment method for the Machine Payments Protocol (MPP).",
|
|
5
5
|
"author": "Atum Labs, Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://github.com/Atum-Labs/protocol/tree/main/mppx-atum-escrow#readme",
|
|
10
|
+
"homepage": "https://github.com/Atum-Labs/protocol/tree/main/schemas/apis/payment-gateway/v1/bindings/mppx-atum-escrow#readme",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/Atum-Labs/protocol.git",
|
|
14
|
-
"directory": "mppx-atum-escrow"
|
|
14
|
+
"directory": "schemas/apis/payment-gateway/v1/bindings/mppx-atum-escrow"
|
|
15
15
|
},
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/Atum-Labs/protocol/issues"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"THIRD-PARTY-NOTICES.txt"
|
|
56
56
|
],
|
|
57
57
|
"scripts": {
|
|
58
|
-
"prebuild:deps": "node -e \"if(!require('fs').existsSync('
|
|
58
|
+
"prebuild:deps": "node -e \"if(!require('fs').existsSync('../../../../../../pnpm-workspace.yaml')){console.error('protocol workspace not found at ../../../../../../pnpm-workspace.yaml. Is this checked out inside the protocol monorepo?');process.exit(1)}\"",
|
|
59
59
|
"build:deps": "pnpm --filter \"@atum-labs/mppx-atum-escrow^...\" run build",
|
|
60
60
|
"build": "tsup && node scripts/stamp-entry-headers.mjs",
|
|
61
61
|
"lint": "eslint . --max-warnings 0",
|