@atumlabs/mppx-atum-escrow 0.4.0 → 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 +25 -0
- package/LICENSE +201 -165
- package/NOTICE +2 -0
- package/README.md +116 -6
- package/THIRD-PARTY-NOTICES.txt +20 -33
- package/dist/{chunk-TPLD2L6B.js → chunk-5IQDNGVU.js} +79 -29
- package/dist/chunk-F3H73WI3.js +8358 -0
- package/dist/{chunk-KRSFEITH.js → chunk-NVPGDBFS.js} +10474 -2713
- package/dist/client.d.ts +187 -3
- package/dist/client.js +14 -6
- package/dist/index.d.ts +4 -3
- package/dist/index.js +15 -7
- package/dist/{internal-CJEu9yUF.d.ts → internal-DwRZPk7k.d.ts} +4 -44
- package/dist/server.d.ts +60 -22
- package/dist/server.js +4 -6
- package/package.json +8 -7
- package/dist/chunk-OEEC5P3E.js +0 -3658
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +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-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>>;
|
|
8
168
|
|
|
9
169
|
/**
|
|
10
170
|
* Result of an {@link ensureSourceApproval} call.
|
|
@@ -205,6 +365,30 @@ interface AtumEscrowClientConfig {
|
|
|
205
365
|
* used. Ignored for EVM/Tron.
|
|
206
366
|
*/
|
|
207
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>>;
|
|
208
392
|
}
|
|
209
393
|
/**
|
|
210
394
|
* Configure the payer side of the method.
|
|
@@ -266,4 +450,4 @@ declare function registerClient(config: AtumEscrowClientConfig): Method.Client<{
|
|
|
266
450
|
};
|
|
267
451
|
}, undefined>;
|
|
268
452
|
|
|
269
|
-
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
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
3
|
-
*
|
|
4
|
-
* Access and use are governed by the LICENSE file distributed with this package.
|
|
5
|
-
* Do not remove, alter, or obscure this notice.
|
|
2
|
+
* Copyright 2026 Atum Labs, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
4
|
*/
|
|
7
5
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
8
6
|
import {
|
|
7
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
8
|
+
AtumEscrowTrustError,
|
|
9
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
10
|
+
DEFAULT_PEG_GROUPS,
|
|
11
|
+
atumGatewayTrust,
|
|
9
12
|
import_payment_request_token_approval,
|
|
10
13
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NVPGDBFS.js";
|
|
12
15
|
import {
|
|
13
16
|
ChargeRequestSchema,
|
|
14
17
|
CredentialPayloadSchema,
|
|
@@ -16,17 +19,22 @@ import {
|
|
|
16
19
|
INTENT_ID_META_KEY,
|
|
17
20
|
METHOD_NAME,
|
|
18
21
|
atumEscrowChargeMethod
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-F3H73WI3.js";
|
|
20
23
|
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
21
24
|
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
22
25
|
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
23
26
|
export {
|
|
27
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
28
|
+
AtumEscrowTrustError,
|
|
24
29
|
ChargeRequestSchema,
|
|
25
30
|
CredentialPayloadSchema,
|
|
31
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
32
|
+
DEFAULT_PEG_GROUPS,
|
|
26
33
|
INTENT,
|
|
27
34
|
INTENT_ID_META_KEY,
|
|
28
35
|
METHOD_NAME,
|
|
29
36
|
atumEscrowChargeMethod,
|
|
37
|
+
atumGatewayTrust,
|
|
30
38
|
export_ensureSourceApproval as ensureSourceApproval,
|
|
31
39
|
export_isUnconfirmed as isUnconfirmed,
|
|
32
40
|
export_needsSourceApproval as needsSourceApproval,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +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-BbTnhw79.js';
|
|
5
6
|
import 'zod/mini';
|
|
6
7
|
import 'mppx';
|
|
7
8
|
import 'zod/v4/core';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
3
|
-
*
|
|
4
|
-
* Access and use are governed by the LICENSE file distributed with this package.
|
|
5
|
-
* Do not remove, alter, or obscure this notice.
|
|
2
|
+
* Copyright 2026 Atum Labs, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
4
|
*/
|
|
7
5
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
8
6
|
import {
|
|
7
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
8
|
+
AtumEscrowTrustError,
|
|
9
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
10
|
+
DEFAULT_PEG_GROUPS,
|
|
11
|
+
atumGatewayTrust,
|
|
9
12
|
import_payment_request_token_approval,
|
|
10
13
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NVPGDBFS.js";
|
|
12
15
|
import {
|
|
13
16
|
PaymentRejectedError,
|
|
14
17
|
SettlementFailedError,
|
|
@@ -21,7 +24,7 @@ import {
|
|
|
21
24
|
isSettlementPending,
|
|
22
25
|
registerServer,
|
|
23
26
|
validateCorridor
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5IQDNGVU.js";
|
|
25
28
|
import {
|
|
26
29
|
ChargeRequestSchema,
|
|
27
30
|
CredentialPayloadSchema,
|
|
@@ -29,13 +32,17 @@ import {
|
|
|
29
32
|
INTENT_ID_META_KEY,
|
|
30
33
|
METHOD_NAME,
|
|
31
34
|
atumEscrowChargeMethod
|
|
32
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-F3H73WI3.js";
|
|
33
36
|
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
34
37
|
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
35
38
|
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
36
39
|
export {
|
|
40
|
+
ATUM_DEFAULT_TRUST_GATEWAYS,
|
|
41
|
+
AtumEscrowTrustError,
|
|
37
42
|
ChargeRequestSchema,
|
|
38
43
|
CredentialPayloadSchema,
|
|
44
|
+
DEFAULT_MAX_MARKUP_BPS,
|
|
45
|
+
DEFAULT_PEG_GROUPS,
|
|
39
46
|
INTENT,
|
|
40
47
|
INTENT_ID_META_KEY,
|
|
41
48
|
METHOD_NAME,
|
|
@@ -43,6 +50,7 @@ export {
|
|
|
43
50
|
SettlementFailedError,
|
|
44
51
|
SettlementPendingError,
|
|
45
52
|
atumEscrowChargeMethod,
|
|
53
|
+
atumGatewayTrust,
|
|
46
54
|
buildChargeChallenge,
|
|
47
55
|
buildChargeRequest,
|
|
48
56
|
corridorFromDefaults,
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
+
import { B } from './sender-auth-verify-BbTnhw79.js';
|
|
1
2
|
import * as z from 'zod/mini';
|
|
2
3
|
import { PaymentRequest } from './generated/index.js';
|
|
3
4
|
import { Challenge, Credential } from 'mppx';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* A message that has been cryptographically signed to prove authorization. The signature proves you control the wallet that's sending funds.
|
|
7
|
-
*/
|
|
8
|
-
type SignedMessage = {
|
|
9
|
-
/**
|
|
10
|
-
* The data that was signed. Format depends on the blockchain:
|
|
11
|
-
* - EVM: Hex-encoded message hash (with 0x prefix)
|
|
12
|
-
* - Solana: Hex-encoded message hash (with 0x prefix)
|
|
13
|
-
* - Tron: Hex-encoded message hash (possibly without 0x prefix)
|
|
14
|
-
*/
|
|
15
|
-
message: string;
|
|
16
|
-
/**
|
|
17
|
-
* Optional: If 'message' contains a hash, this field contains the original data before it was hashed. Useful for verification and debugging.
|
|
18
|
-
*/
|
|
19
|
-
message_prehash?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The cryptographic signature proving you authorized this message. Hex-encoded with a 0x prefix on every supported chain. The signer's own public key is base58 on Solana, but the signature itself is not.
|
|
22
|
-
*/
|
|
23
|
-
signature: string;
|
|
24
|
-
/**
|
|
25
|
-
* Optional chain-specific payload containing additional signing context (e.g., delegate_signer for Solana). Preserved through the pipeline for downstream consumers.
|
|
26
|
-
*/
|
|
27
|
-
payload?: {
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
6
|
/**
|
|
33
7
|
* Chain defaults returned by the payment gateway /v1/defaults endpoint.
|
|
34
8
|
*/
|
|
@@ -40,22 +14,8 @@ interface ChainDefaults {
|
|
|
40
14
|
fulfillmentProxy: string;
|
|
41
15
|
permit2Contract?: string;
|
|
42
16
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* same fact in `svmSignatureDomainVersion` below.
|
|
46
|
-
*
|
|
47
|
-
* `4` and above select the CORE-2120 four-member witness
|
|
48
|
-
* (`depositRequestHash`, `destination`, `reserver`, `releaser`); `3` selects the two-member
|
|
49
|
-
* witness a not-yet-redeployed escrow pins. ABSENT means four — see the sender-auth package's
|
|
50
|
-
* `ChainDefaults.depositWitnessVersion` for why absence is the permissive default.
|
|
51
|
-
*
|
|
52
|
-
* Passed through to the sender_auth adapter verbatim; this type only has to carry it.
|
|
53
|
-
*/
|
|
54
|
-
depositWitnessVersion?: number;
|
|
55
|
-
/**
|
|
56
|
-
* V3 Solana escrow domain-separation fields, surfaced by payment-gw
|
|
57
|
-
* `/v1/defaults` for Solana source chains. Used to build the EscrowDomain that the
|
|
58
|
-
* 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.
|
|
59
19
|
*/
|
|
60
20
|
svmSignatureClusterId?: string;
|
|
61
21
|
svmSignatureDomainVersion?: number;
|
|
@@ -116,7 +76,7 @@ interface SenderSignature {
|
|
|
116
76
|
}
|
|
117
77
|
/** Signs a single sender_auth signed message for a payment request. */
|
|
118
78
|
interface SenderSigner {
|
|
119
|
-
sign(signedMessage:
|
|
79
|
+
sign(signedMessage: B): Promise<SenderSignature>;
|
|
120
80
|
}
|
|
121
81
|
/** Turnkey provider configuration (shared by the SDK and the CLI env loader). */
|
|
122
82
|
interface TurnkeyConfig {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
|
-
import { i as atumEscrowChargeMethod, j as ChainDefaults, d as ChargeRequest } from './internal-CJEu9yUF.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-CJEu9yUF.js';
|
|
3
|
-
import { Errors, Receipt, Method } from 'mppx';
|
|
4
1
|
import { PaymentRequest } from './generated/index.js';
|
|
5
2
|
export { PaymentRequest } from './generated/index.js';
|
|
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';
|
|
6
7
|
import 'zod/mini';
|
|
7
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
|
+
|
|
8
39
|
/**
|
|
9
40
|
* This file was automatically generated by json-schema-to-typescript.
|
|
10
41
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
@@ -239,8 +270,14 @@ interface AtumEscrowCorridor {
|
|
|
239
270
|
/** Accepted source options; selected per charge by `(network, asset)`. */
|
|
240
271
|
sources: AtumEscrowSource[];
|
|
241
272
|
}
|
|
242
|
-
/**
|
|
243
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Lifecycle state the gateway reports for a payment.
|
|
275
|
+
*
|
|
276
|
+
* `finalizing` means the payment is on chain but has not yet reached the confirmation depth its
|
|
277
|
+
* chain requires. It is NOT terminal: a payer must keep waiting on the same idempotency key, never
|
|
278
|
+
* start a second payment for it.
|
|
279
|
+
*/
|
|
280
|
+
type PaymentSettlementStatus = 'pending' | 'finalizing' | 'completed' | 'failed';
|
|
244
281
|
/** What a {@link PaymentSubmitter} resolves with. */
|
|
245
282
|
interface PaymentSubmitResult {
|
|
246
283
|
/** The gateway's payment id. Present whenever the payment was accepted. */
|
|
@@ -260,10 +297,8 @@ interface PaymentSubmitResult {
|
|
|
260
297
|
*
|
|
261
298
|
* Submit and return what the gateway said; do not poll for completion inside the submitter.
|
|
262
299
|
* A payment that outlives the gateway's synchronous window surfaces to the payer as
|
|
263
|
-
* {@link SettlementPendingError}, and the payer's retry of the same purchase
|
|
264
|
-
*
|
|
265
|
-
* instead holds the merchant's request open for the full settlement window and hides the pending
|
|
266
|
-
* 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.
|
|
267
302
|
*
|
|
268
303
|
* Throw {@link PaymentRejectedError} when the gateway refuses the request, so the refusal keeps
|
|
269
304
|
* its code. Any other throw is treated as an unknown outcome.
|
|
@@ -277,7 +312,15 @@ interface AtumEscrowServerConfig {
|
|
|
277
312
|
submitter: PaymentSubmitter;
|
|
278
313
|
/** Clock (epoch ms) used to validate deadline ordering and budgets. Defaults to `Date.now`. */
|
|
279
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;
|
|
280
322
|
}
|
|
323
|
+
|
|
281
324
|
/**
|
|
282
325
|
* The receipt returned once a payment settles, extending the MPP receipt with the Atum
|
|
283
326
|
* settlement details. `reference` carries the destination-chain transaction hash, and
|
|
@@ -331,10 +374,9 @@ declare function validateCorridor(corridor: AtumEscrowCorridor): void;
|
|
|
331
374
|
* signing time.
|
|
332
375
|
*
|
|
333
376
|
* Prefer {@link buildChargeChallenge}, which pairs these terms with the per-purchase identifier
|
|
334
|
-
* the payer requires. A challenge built from this function alone carries no such identifier and
|
|
335
|
-
* the payer's client refuses it
|
|
336
|
-
*
|
|
337
|
-
* 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.
|
|
338
380
|
*
|
|
339
381
|
* @param corridor - the corridor to serve.
|
|
340
382
|
* @param select - which configured source to fund from, by `(network, asset)`.
|
|
@@ -342,9 +384,8 @@ declare function validateCorridor(corridor: AtumEscrowCorridor): void;
|
|
|
342
384
|
* destination token. Set per charge so one registration serves any price.
|
|
343
385
|
* @param options.issuedAt - Solana-source only: the merchant's cluster-clock reading (epoch
|
|
344
386
|
* seconds) to stamp into `extra.issuedAt`, so the payer's client builds the deposit fully
|
|
345
|
-
* offline (no RPC). Omit to let the client stamp `issued_at`
|
|
346
|
-
*
|
|
347
|
-
* 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.
|
|
348
389
|
* Ignored for EVM/Tron sources.
|
|
349
390
|
* @throws if no source option matches `select`, or the corridor is invalid.
|
|
350
391
|
*/
|
|
@@ -357,11 +398,8 @@ declare function buildChargeRequest(corridor: AtumEscrowCorridor, select: {
|
|
|
357
398
|
/**
|
|
358
399
|
* A charge challenge's two halves, ready to hand to the framework.
|
|
359
400
|
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* challenge-id HMAC, but nesting the metadata inside the request would bury the purchase
|
|
363
|
-
* identifier in the terms blob where the payer does not look for it — so this type keeps them in
|
|
364
|
-
* 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.
|
|
365
403
|
*/
|
|
366
404
|
interface ChargeChallenge {
|
|
367
405
|
/** The method-specific charge request (the payment terms). */
|
|
@@ -440,4 +478,4 @@ declare function corridorFromDefaults(defaults: ChainDefaultsSource, params: {
|
|
|
440
478
|
fulfillmentDeadlineSeconds: number;
|
|
441
479
|
}): Promise<AtumEscrowCorridor>;
|
|
442
480
|
|
|
443
|
-
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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
3
|
-
*
|
|
4
|
-
* Access and use are governed by the LICENSE file distributed with this package.
|
|
5
|
-
* Do not remove, alter, or obscure this notice.
|
|
2
|
+
* Copyright 2026 Atum Labs, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
4
|
*/
|
|
7
5
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
8
6
|
import {
|
|
@@ -17,7 +15,7 @@ import {
|
|
|
17
15
|
isSettlementPending,
|
|
18
16
|
registerServer,
|
|
19
17
|
validateCorridor
|
|
20
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5IQDNGVU.js";
|
|
21
19
|
import {
|
|
22
20
|
ChargeRequestSchema,
|
|
23
21
|
CredentialPayloadSchema,
|
|
@@ -25,7 +23,7 @@ import {
|
|
|
25
23
|
INTENT_ID_META_KEY,
|
|
26
24
|
METHOD_NAME,
|
|
27
25
|
atumEscrowChargeMethod
|
|
28
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-F3H73WI3.js";
|
|
29
27
|
export {
|
|
30
28
|
ChargeRequestSchema,
|
|
31
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
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
|
-
"access": "
|
|
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"
|
|
@@ -51,10 +51,11 @@
|
|
|
51
51
|
"README.md",
|
|
52
52
|
"CHANGELOG.md",
|
|
53
53
|
"LICENSE",
|
|
54
|
+
"NOTICE",
|
|
54
55
|
"THIRD-PARTY-NOTICES.txt"
|
|
55
56
|
],
|
|
56
57
|
"scripts": {
|
|
57
|
-
"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)}\"",
|
|
58
59
|
"build:deps": "pnpm --filter \"@atum-labs/mppx-atum-escrow^...\" run build",
|
|
59
60
|
"build": "tsup && node scripts/stamp-entry-headers.mjs",
|
|
60
61
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"mppx": "^0.8.12",
|
|
93
94
|
"tsup": "^8.5.1",
|
|
94
95
|
"typescript": "^5.6.3",
|
|
95
|
-
"vitest": "^
|
|
96
|
+
"vitest": "^4.1.11",
|
|
96
97
|
"zod": "^4.4.3"
|
|
97
98
|
}
|
|
98
99
|
}
|