@atumlabs/mppx-atum-escrow 0.1.1 → 0.3.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 +50 -0
- package/README.md +212 -47
- package/dist/chunk-4YD6566T.js +371 -0
- package/dist/chunk-Z3AUNEU5.js +2645 -0
- package/dist/{chunk-2MWWLU75.js → chunk-ZFA5SSUP.js} +1691 -1653
- package/dist/client.d.ts +21 -16
- package/dist/client.js +4 -2
- package/dist/index.d.ts +19 -18
- package/dist/index.js +19 -3
- package/dist/internal-9tB7y-A7.d.ts +365 -0
- package/dist/server.d.ts +234 -17
- package/dist/server.js +18 -2
- package/package.json +7 -4
- package/dist/chunk-L62WG2VU.js +0 -131
- package/dist/chunk-W6D2D767.js +0 -1410
- package/dist/internal-CjcEyEsm.d.ts +0 -842
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as zod_v4_core from 'zod/v4/core';
|
|
2
2
|
import * as z from 'zod/mini';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
|
-
import { S as SenderSigner,
|
|
5
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, c as ChargeRequest, d as ChargeRequestSchema, e as CredentialPayloadSchema, I as INTENT,
|
|
4
|
+
import { S as SenderSigner, g as SenderSignerOptions, i as SolanaClusterUnixTimeReader } from './internal-9tB7y-A7.js';
|
|
5
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, c as ChargeRequest, d as ChargeRequestSchema, e as CredentialPayloadSchema, I as INTENT, f as INTENT_ID_META_KEY, M as METHOD_NAME, h as atumEscrowChargeMethod } from './internal-9tB7y-A7.js';
|
|
6
6
|
import { Method } from 'mppx';
|
|
7
|
+
export { PaymentRequest } from './generated/index.js';
|
|
7
8
|
|
|
8
9
|
/** Configuration for the payer side of the method. */
|
|
9
10
|
interface AtumEscrowClientConfig {
|
|
@@ -22,8 +23,10 @@ interface AtumEscrowClientConfig {
|
|
|
22
23
|
/** Clock (epoch ms) used to derive absolute deadlines from the challenge budgets. Defaults to `Date.now`. */
|
|
23
24
|
now?: () => number;
|
|
24
25
|
/**
|
|
25
|
-
* Solana-only
|
|
26
|
-
*
|
|
26
|
+
* Solana-only: supplies the `issued_at` a Solana deposit is stamped with, keeping the
|
|
27
|
+
* build fully offline. Used only when the challenge does not carry a merchant-stamped
|
|
28
|
+
* `extra.issuedAt` (which takes precedence); if neither is present, the client clock is
|
|
29
|
+
* used. Ignored for EVM/Tron.
|
|
27
30
|
*/
|
|
28
31
|
solanaClockReader?: SolanaClusterUnixTimeReader;
|
|
29
32
|
}
|
|
@@ -35,16 +38,18 @@ interface AtumEscrowClientConfig {
|
|
|
35
38
|
* built through the payment-gateway client's request builder, so the same call handles
|
|
36
39
|
* EVM, Tron, and Solana sources.
|
|
37
40
|
*
|
|
38
|
-
* Idempotency:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
41
|
+
* Idempotency: the `request_id` is derived from the challenge's per-intent identifier (see
|
|
42
|
+
* {@link INTENT_ID_META_KEY}) via the shared sender_auth SDK, and `preparePaymentRequest` then
|
|
43
|
+
* derives the deposit nonce from that `request_id` on every chain. So rebuilding the credential
|
|
44
|
+
* for the same purchase reproduces the same payment identity, and the gateway de-duplicates the
|
|
45
|
+
* retry onto the original payment instead of charging twice. On EVM/Tron the reused Permit2
|
|
46
|
+
* nonce is a second, on-chain backstop (the duplicate deposit reverts); on Solana the replay
|
|
47
|
+
* nonce only guards a ~128s window, so there the gateway's `request_id` dedup is the durable
|
|
48
|
+
* protection.
|
|
49
|
+
*
|
|
50
|
+
* A challenge that carries no such identifier cannot be paid safely, so this client refuses it
|
|
51
|
+
* rather than falling back to something per-attempt. See
|
|
52
|
+
* {@link ../server!buildChargeChallenge | buildChargeChallenge} for the merchant side.
|
|
48
53
|
*
|
|
49
54
|
* @param config - the payer's signer, source account, and options.
|
|
50
55
|
*/
|
|
@@ -62,7 +67,7 @@ declare function registerClient(config: AtumEscrowClientConfig): Method.Client<{
|
|
|
62
67
|
destination: z.ZodMiniObject<{
|
|
63
68
|
network: z.ZodMiniString<string>;
|
|
64
69
|
asset: z.ZodMiniString<string>;
|
|
65
|
-
|
|
70
|
+
address: z.ZodMiniString<string>;
|
|
66
71
|
}, zod_v4_core.$strip>;
|
|
67
72
|
fulfillmentAmount: z.ZodMiniString<string>;
|
|
68
73
|
escrow: z.ZodMiniString<string>;
|
|
@@ -72,9 +77,9 @@ declare function registerClient(config: AtumEscrowClientConfig): Method.Client<{
|
|
|
72
77
|
fulfillmentVerifierEndpoint: z.ZodMiniString<string>;
|
|
73
78
|
quoteDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
74
79
|
fulfillmentDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
75
|
-
permit2: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
76
80
|
svmSignatureClusterId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
77
81
|
svmSignatureDomainVersion: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
82
|
+
issuedAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
78
83
|
}, zod_v4_core.$strip>;
|
|
79
84
|
}, zod_v4_core.$strip>;
|
|
80
85
|
readonly credential: {
|
package/dist/client.js
CHANGED
|
@@ -8,18 +8,20 @@ import { createRequire as __atumCreateRequire } from 'module'; const require = _
|
|
|
8
8
|
import {
|
|
9
9
|
ensureSourceApproval,
|
|
10
10
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ZFA5SSUP.js";
|
|
12
12
|
import {
|
|
13
13
|
ChargeRequestSchema,
|
|
14
14
|
CredentialPayloadSchema,
|
|
15
15
|
INTENT,
|
|
16
|
+
INTENT_ID_META_KEY,
|
|
16
17
|
METHOD_NAME,
|
|
17
18
|
atumEscrowChargeMethod
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-Z3AUNEU5.js";
|
|
19
20
|
export {
|
|
20
21
|
ChargeRequestSchema,
|
|
21
22
|
CredentialPayloadSchema,
|
|
22
23
|
INTENT,
|
|
24
|
+
INTENT_ID_META_KEY,
|
|
23
25
|
METHOD_NAME,
|
|
24
26
|
atumEscrowChargeMethod,
|
|
25
27
|
ensureSourceApproval,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowRequest, C as ChargeCredentialPayload, c as ChargeRequest, d as ChargeRequestSchema, e as CredentialPayloadSchema, I as INTENT,
|
|
1
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowRequest, C as ChargeCredentialPayload, c as ChargeRequest, d as ChargeRequestSchema, e as CredentialPayloadSchema, I as INTENT, f as INTENT_ID_META_KEY, M as METHOD_NAME, S as SenderSigner, g as SenderSignerOptions, h as atumEscrowChargeMethod } from './internal-9tB7y-A7.js';
|
|
2
2
|
export { AtumEscrowClientConfig, EnsureApprovalResult, ensureSourceApproval, registerClient } from './client.js';
|
|
3
|
-
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, FulfillmentConfirmation, PaymentSubmitter, buildChargeRequest, corridorFromDefaults, registerServer, validateCorridor } from './server.js';
|
|
3
|
+
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, ChargeChallenge, FulfillmentConfirmation, PaymentRejectedError, PaymentSettlementStatus, PaymentSubmitResult, PaymentSubmitter, SettlementErrorDetails, SettlementFailedError, SettlementPendingError, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor } from './server.js';
|
|
4
|
+
export { PaymentRequest } from './generated/index.js';
|
|
4
5
|
import 'zod/mini';
|
|
5
6
|
import 'mppx';
|
|
6
7
|
import 'zod/v4/core';
|
|
@@ -12,11 +13,11 @@ import 'ethers';
|
|
|
12
13
|
* and run json-schema-to-typescript to regenerate this file.
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
|
-
* The `extra.atum` object carried inside an atum-escrow x402 PaymentRequirements entry (accepts[]): the merchant's receive-side plus the contract/role addresses and deadline budgets. Scheme-specific data the standard x402 `extra` bag treats as opaque, so it is owned here and shared by all role mechanisms. Addresses are chain-general: an EVM `0x`-
|
|
16
|
+
* The `extra.atum` object carried inside an atum-escrow x402 PaymentRequirements entry (accepts[]): the merchant's receive-side plus the contract/role addresses and deadline budgets. Scheme-specific data the standard x402 `extra` bag treats as opaque, so it is owned here and shared by all role mechanisms. Addresses are chain-general: an EVM `0x`-hex address (20 bytes) or a base58-encoded address (Solana/Tron), per the field's CAIP-2 chain.
|
|
16
17
|
*/
|
|
17
18
|
interface AtumEscrowExtra {
|
|
18
19
|
/**
|
|
19
|
-
* Where the merchant receives (CAIP-2 chain, token,
|
|
20
|
+
* Where the merchant receives (CAIP-2 chain, token, address).
|
|
20
21
|
*/
|
|
21
22
|
destination: {
|
|
22
23
|
/**
|
|
@@ -24,36 +25,36 @@ interface AtumEscrowExtra {
|
|
|
24
25
|
*/
|
|
25
26
|
network: string;
|
|
26
27
|
/**
|
|
27
|
-
* Destination token address (EVM hex or base58).
|
|
28
|
+
* Destination token contract address (EVM hex or base58, per the destination chain).
|
|
28
29
|
*/
|
|
29
30
|
asset: string;
|
|
30
31
|
/**
|
|
31
|
-
* Merchant receive
|
|
32
|
+
* Merchant receive address (EVM hex or base58, per the destination chain).
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
address: string;
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
37
|
* Exact amount the merchant receives, in atomic token units.
|
|
37
38
|
*/
|
|
38
39
|
fulfillmentAmount: string;
|
|
39
40
|
/**
|
|
40
|
-
* Source-chain escrow contract (the x402 payTo).
|
|
41
|
+
* Source-chain escrow contract (the x402 payTo); EVM hex or base58, per the source chain.
|
|
41
42
|
*/
|
|
42
43
|
escrow: string;
|
|
43
44
|
/**
|
|
44
|
-
* Destination-chain fulfillment proxy contract.
|
|
45
|
+
* Destination-chain fulfillment proxy contract (EVM hex or base58, per the destination chain).
|
|
45
46
|
*/
|
|
46
47
|
fulfillmentProxy: string;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Atum reserver role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
49
50
|
*/
|
|
50
51
|
reserver: string;
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
+
* Atum releaser role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
53
54
|
*/
|
|
54
55
|
releaser: string;
|
|
55
56
|
/**
|
|
56
|
-
* Source-chain fulfillment-verifier endpoint the payment request carries. The verifier account and the
|
|
57
|
+
* Source-chain fulfillment-verifier endpoint the payment request carries. The verifier account and the quote_selector are the releaser and reserver respectively (the network derives the deposit witness roles from them), so only the endpoint is not otherwise present in this object.
|
|
57
58
|
*/
|
|
58
59
|
fulfillmentVerifierEndpoint: string;
|
|
59
60
|
/**
|
|
@@ -65,17 +66,17 @@ interface AtumEscrowExtra {
|
|
|
65
66
|
*/
|
|
66
67
|
fulfillmentDeadlineSeconds: number;
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
-
*/
|
|
70
|
-
permit2?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Solana-only: cluster identifier used to domain-separate the deposit authorization. Present only when the source chain is Solana; omitted for EVM/Tron.
|
|
69
|
+
* Solana source only: cluster name used to build the 32-byte cluster_id in the V3 escrow signature domain. Optional; the facilitator requires it for a Solana source.
|
|
73
70
|
*/
|
|
74
71
|
svmSignatureClusterId?: string;
|
|
75
72
|
/**
|
|
76
|
-
* Solana
|
|
73
|
+
* Solana source only: escrow signature-domain version (V3 domain separation). Optional; required for a Solana source.
|
|
77
74
|
*/
|
|
78
75
|
svmSignatureDomainVersion?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Solana source only: merchant-stamped issue time in epoch seconds. The merchant reads the cluster clock so the client makes no RPC and the 402 stays self-contained. Optional; required for a Solana source.
|
|
78
|
+
*/
|
|
79
|
+
issuedAt?: string;
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export type { AtumEscrowExtra };
|
package/dist/index.js
CHANGED
|
@@ -8,29 +8,45 @@ import { createRequire as __atumCreateRequire } from 'module'; const require = _
|
|
|
8
8
|
import {
|
|
9
9
|
ensureSourceApproval,
|
|
10
10
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ZFA5SSUP.js";
|
|
12
12
|
import {
|
|
13
|
+
PaymentRejectedError,
|
|
14
|
+
SettlementFailedError,
|
|
15
|
+
SettlementPendingError,
|
|
16
|
+
buildChargeChallenge,
|
|
13
17
|
buildChargeRequest,
|
|
14
18
|
corridorFromDefaults,
|
|
19
|
+
isPaymentRejected,
|
|
20
|
+
isSettlementFailed,
|
|
21
|
+
isSettlementPending,
|
|
15
22
|
registerServer,
|
|
16
23
|
validateCorridor
|
|
17
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-4YD6566T.js";
|
|
18
25
|
import {
|
|
19
26
|
ChargeRequestSchema,
|
|
20
27
|
CredentialPayloadSchema,
|
|
21
28
|
INTENT,
|
|
29
|
+
INTENT_ID_META_KEY,
|
|
22
30
|
METHOD_NAME,
|
|
23
31
|
atumEscrowChargeMethod
|
|
24
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-Z3AUNEU5.js";
|
|
25
33
|
export {
|
|
26
34
|
ChargeRequestSchema,
|
|
27
35
|
CredentialPayloadSchema,
|
|
28
36
|
INTENT,
|
|
37
|
+
INTENT_ID_META_KEY,
|
|
29
38
|
METHOD_NAME,
|
|
39
|
+
PaymentRejectedError,
|
|
40
|
+
SettlementFailedError,
|
|
41
|
+
SettlementPendingError,
|
|
30
42
|
atumEscrowChargeMethod,
|
|
43
|
+
buildChargeChallenge,
|
|
31
44
|
buildChargeRequest,
|
|
32
45
|
corridorFromDefaults,
|
|
33
46
|
ensureSourceApproval,
|
|
47
|
+
isPaymentRejected,
|
|
48
|
+
isSettlementFailed,
|
|
49
|
+
isSettlementPending,
|
|
34
50
|
registerClient,
|
|
35
51
|
registerServer,
|
|
36
52
|
validateCorridor
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
import { PaymentRequest } from './generated/index.js';
|
|
3
|
+
import { Challenge, Credential } from 'mppx';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A message that has been cryptographically signed to prove authorization.
|
|
7
|
+
* The signature proves you control the wallet that's sending funds.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
type SignedMessage = {
|
|
11
|
+
/**
|
|
12
|
+
* The data that was signed. Format depends on the blockchain:
|
|
13
|
+
* - EVM: Hex-encoded message hash (with 0x prefix)
|
|
14
|
+
* - Solana: Base64 encoded message
|
|
15
|
+
* - Tron: Hex-encoded message hash (possibly without 0x prefix)
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
message: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional: If 'message' contains a hash, this field contains the original data
|
|
21
|
+
* before it was hashed. Useful for verification and debugging.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
message_prehash?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The cryptographic signature proving you authorized this message.
|
|
27
|
+
* Format varies by blockchain (hex for EVM/Tron, base58 for Solana).
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
signature: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Chain defaults returned by the payment gateway /defaults endpoint.
|
|
35
|
+
*/
|
|
36
|
+
interface ChainDefaults {
|
|
37
|
+
escrowContract: string;
|
|
38
|
+
quoteSelector: string;
|
|
39
|
+
fulfillmentVerifierAccount: string;
|
|
40
|
+
fulfillmentVerifierEndpoint: string;
|
|
41
|
+
fulfillmentProxy: string;
|
|
42
|
+
permit2Contract?: string;
|
|
43
|
+
/**
|
|
44
|
+
* V3 Solana escrow domain-separation fields, surfaced by payment-gw
|
|
45
|
+
* `/defaults` for Solana source chains. Used to build the EscrowDomain that the
|
|
46
|
+
* V3 deposit hash binds to. Absent for EVM/Tron.
|
|
47
|
+
*/
|
|
48
|
+
svmSignatureClusterId?: string;
|
|
49
|
+
svmSignatureDomainVersion?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface Logger {
|
|
53
|
+
debug(obj: unknown, msg?: string): void;
|
|
54
|
+
info(obj: unknown, msg?: string): void;
|
|
55
|
+
warn(obj: unknown, msg?: string): void;
|
|
56
|
+
error(obj: unknown, msg?: string): void;
|
|
57
|
+
child(bindings: Record<string, unknown>): Logger;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface Counter {
|
|
61
|
+
add(value: number, attributes?: Record<string, unknown>): void;
|
|
62
|
+
}
|
|
63
|
+
interface Histogram {
|
|
64
|
+
record(value: number, attributes?: Record<string, unknown>): void;
|
|
65
|
+
}
|
|
66
|
+
interface InstrumentOptions {
|
|
67
|
+
description?: string;
|
|
68
|
+
unit?: string;
|
|
69
|
+
}
|
|
70
|
+
interface Meter {
|
|
71
|
+
createCounter(name: string, options?: InstrumentOptions): Counter;
|
|
72
|
+
createHistogram(name: string, options?: InstrumentOptions): Histogram;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the `issued_at` timestamp for a Solana deposit authorization from the
|
|
77
|
+
* cluster's on-chain clock instead of the local wall clock.
|
|
78
|
+
*
|
|
79
|
+
* The escrow validates `now_sec >= issued_at` against Solana's `Clock` sysvar
|
|
80
|
+
* (crates/replay/src/check.rs). That on-chain clock is global consensus and only
|
|
81
|
+
* moves forward, so a value read at build time is a safe lower bound at
|
|
82
|
+
* settlement, which removes the `Escrow_FutureTransaction` failure that a raw
|
|
83
|
+
* `Date.now()` (client wall clock, possibly ahead of the lagging cluster clock)
|
|
84
|
+
* can trigger.
|
|
85
|
+
*
|
|
86
|
+
* The read is best-effort: on any failure, timeout, or unresolved RPC it falls
|
|
87
|
+
* back to `Date.now()` minus a skew buffer, so a flaky public endpoint degrades
|
|
88
|
+
* to the previous behavior rather than blocking the payment.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/** Reads the cluster's on-chain unix timestamp (seconds) from an RPC endpoint. */
|
|
92
|
+
type SolanaClusterUnixTimeReader = (rpcUrl: string, timeoutMs: number) => Promise<bigint>;
|
|
93
|
+
|
|
94
|
+
/** Result of signing a sender_auth message. */
|
|
95
|
+
interface SenderSignature {
|
|
96
|
+
/** 0x-prefixed signature hex (65-byte secp256k1 for EVM/Tron, 64-byte ed25519 for Solana). */
|
|
97
|
+
signature: string;
|
|
98
|
+
/**
|
|
99
|
+
* base58 signer public key for non-recoverable schemes (Solana), attached to
|
|
100
|
+
* the signed message's payload.delegate_signer. Absent for EVM/Tron, whose
|
|
101
|
+
* secp256k1 signatures are recoverable.
|
|
102
|
+
*/
|
|
103
|
+
delegateSigner?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Signs a single sender_auth signed message for a payment request. */
|
|
106
|
+
interface SenderSigner {
|
|
107
|
+
sign(signedMessage: SignedMessage): Promise<SenderSignature>;
|
|
108
|
+
}
|
|
109
|
+
/** Turnkey provider configuration (shared by the SDK and the CLI env loader). */
|
|
110
|
+
interface TurnkeyConfig {
|
|
111
|
+
organizationId: string;
|
|
112
|
+
walletId: string;
|
|
113
|
+
apiPublicKey: string;
|
|
114
|
+
apiPrivateKey: string;
|
|
115
|
+
/**
|
|
116
|
+
* Chain-native address the signer is expected to resolve to. Verified against
|
|
117
|
+
* the address Turnkey returns at initialize(); a mismatch fails fast rather
|
|
118
|
+
* than signing as the wrong depositor.
|
|
119
|
+
*/
|
|
120
|
+
pinnedAddress?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional observability threaded to the Turnkey network path (default noop).
|
|
123
|
+
* SDK consumers can wire their own logger and meter; the CLI leaves them unset.
|
|
124
|
+
*/
|
|
125
|
+
logger?: Logger;
|
|
126
|
+
meter?: Meter;
|
|
127
|
+
}
|
|
128
|
+
/** Options selecting a sender-signing provider. Defaults to the private-key provider. */
|
|
129
|
+
type SenderSignerOptions = {
|
|
130
|
+
provider?: 'raw';
|
|
131
|
+
privateKey: string;
|
|
132
|
+
pinnedAddress?: string;
|
|
133
|
+
} | ({
|
|
134
|
+
provider: 'turnkey';
|
|
135
|
+
} & TurnkeyConfig);
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
139
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
140
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* The MPP `charge` challenge request — the method-specific `request` blob inside an mppx Challenge. It carries the source option the payer funds from plus the destination/corridor block (the reused `extra`). MPP has no x402 `accepts[]` envelope, so the source option that x402 carried at the `accepts[]` top level rides here alongside `extra`. One source option per challenge; a 402 may advertise several challenges to offer several source options.
|
|
144
|
+
*/
|
|
145
|
+
interface AtumEscrowRequest {
|
|
146
|
+
/**
|
|
147
|
+
* The source chain/token/cap the payer funds from.
|
|
148
|
+
*/
|
|
149
|
+
source: {
|
|
150
|
+
/**
|
|
151
|
+
* CAIP-2 source chain id (e.g. eip155:8453).
|
|
152
|
+
*/
|
|
153
|
+
network: string;
|
|
154
|
+
/**
|
|
155
|
+
* Source token address (EVM hex or base58, per the source chain).
|
|
156
|
+
*/
|
|
157
|
+
asset: string;
|
|
158
|
+
/**
|
|
159
|
+
* Source spend cap (fulfillmentAmount + markup), in atomic token units — the authoritative `max_source_amount` the payer signs.
|
|
160
|
+
*/
|
|
161
|
+
amount: string;
|
|
162
|
+
};
|
|
163
|
+
extra: AtumEscrowExtra;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The `extra.atum` object carried inside an atum-escrow x402 PaymentRequirements entry (accepts[]): the merchant's receive-side plus the contract/role addresses and deadline budgets. Scheme-specific data the standard x402 `extra` bag treats as opaque, so it is owned here and shared by all role mechanisms. Addresses are chain-general: an EVM `0x`-hex address (20 bytes) or a base58-encoded address (Solana/Tron), per the field's CAIP-2 chain.
|
|
167
|
+
*/
|
|
168
|
+
interface AtumEscrowExtra {
|
|
169
|
+
/**
|
|
170
|
+
* Where the merchant receives (CAIP-2 chain, token, address).
|
|
171
|
+
*/
|
|
172
|
+
destination: {
|
|
173
|
+
/**
|
|
174
|
+
* CAIP-2 destination chain id (e.g. eip155:42161).
|
|
175
|
+
*/
|
|
176
|
+
network: string;
|
|
177
|
+
/**
|
|
178
|
+
* Destination token contract address (EVM hex or base58, per the destination chain).
|
|
179
|
+
*/
|
|
180
|
+
asset: string;
|
|
181
|
+
/**
|
|
182
|
+
* Merchant receive address (EVM hex or base58, per the destination chain).
|
|
183
|
+
*/
|
|
184
|
+
address: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Exact amount the merchant receives, in atomic token units.
|
|
188
|
+
*/
|
|
189
|
+
fulfillmentAmount: string;
|
|
190
|
+
/**
|
|
191
|
+
* Source-chain escrow contract (the x402 payTo); EVM hex or base58, per the source chain.
|
|
192
|
+
*/
|
|
193
|
+
escrow: string;
|
|
194
|
+
/**
|
|
195
|
+
* Destination-chain fulfillment proxy contract (EVM hex or base58, per the destination chain).
|
|
196
|
+
*/
|
|
197
|
+
fulfillmentProxy: string;
|
|
198
|
+
/**
|
|
199
|
+
* Atum reserver role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
200
|
+
*/
|
|
201
|
+
reserver: string;
|
|
202
|
+
/**
|
|
203
|
+
* Atum releaser role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
204
|
+
*/
|
|
205
|
+
releaser: string;
|
|
206
|
+
/**
|
|
207
|
+
* Source-chain fulfillment-verifier endpoint the payment request carries. The verifier account and the quote_selector are the releaser and reserver respectively (the network derives the deposit witness roles from them), so only the endpoint is not otherwise present in this object.
|
|
208
|
+
*/
|
|
209
|
+
fulfillmentVerifierEndpoint: string;
|
|
210
|
+
/**
|
|
211
|
+
* Recommended quote-deadline budget in seconds, relative to signing time.
|
|
212
|
+
*/
|
|
213
|
+
quoteDeadlineSeconds: number;
|
|
214
|
+
/**
|
|
215
|
+
* Recommended fulfillment-deadline budget in seconds, relative to signing time.
|
|
216
|
+
*/
|
|
217
|
+
fulfillmentDeadlineSeconds: number;
|
|
218
|
+
/**
|
|
219
|
+
* Solana source only: cluster name used to build the 32-byte cluster_id in the V3 escrow signature domain. Optional; the facilitator requires it for a Solana source.
|
|
220
|
+
*/
|
|
221
|
+
svmSignatureClusterId?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Solana source only: escrow signature-domain version (V3 domain separation). Optional; required for a Solana source.
|
|
224
|
+
*/
|
|
225
|
+
svmSignatureDomainVersion?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Solana source only: merchant-stamped issue time in epoch seconds. The merchant reads the cluster clock so the client makes no RPC and the 402 stays self-contained. Optional; required for a Solana source.
|
|
228
|
+
*/
|
|
229
|
+
issuedAt?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Shared internals for the Atum escrow MPP method: the wire schemas, the method
|
|
234
|
+
* definition, the shared types, and the pure chain/address helpers used by both
|
|
235
|
+
* the payer ({@link ./client}) and merchant ({@link ./server}) sides.
|
|
236
|
+
*
|
|
237
|
+
* This module is not a public entry point — consumers import from the package
|
|
238
|
+
* root, `/client`, or `/server`. The helpers here are exported only so the
|
|
239
|
+
* client and server modules can share them.
|
|
240
|
+
*
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
/** The method name advertised in MPP challenges and credentials. */
|
|
245
|
+
declare const METHOD_NAME = "atum-escrow";
|
|
246
|
+
/** The MPP intent this method implements. */
|
|
247
|
+
declare const INTENT = "charge";
|
|
248
|
+
/**
|
|
249
|
+
* Challenge-metadata key carrying the merchant's per-intent payment identifier.
|
|
250
|
+
*
|
|
251
|
+
* The payer derives the payment's `request_id` from this value, and the gateway
|
|
252
|
+
* de-duplicates on that `request_id`. So the key's lifetime defines what counts as "the same
|
|
253
|
+
* payment": one value per thing being bought, reused on every retry of that purchase, never
|
|
254
|
+
* shared between two purchases.
|
|
255
|
+
*
|
|
256
|
+
* It rides in challenge metadata rather than in the charge request because it identifies the
|
|
257
|
+
* purchase, not its terms — two sequential orders for the same item have identical terms and
|
|
258
|
+
* must still be two payments. Metadata is covered by the challenge-id HMAC, so a payer cannot
|
|
259
|
+
* substitute another intent's identifier to have a second purchase resolve onto an
|
|
260
|
+
* already-settled payment.
|
|
261
|
+
*
|
|
262
|
+
* Prefixed to keep it distinct from a merchant's own metadata and from the framework's
|
|
263
|
+
* reserved keys.
|
|
264
|
+
*/
|
|
265
|
+
declare const INTENT_ID_META_KEY = "atumIntentId";
|
|
266
|
+
/**
|
|
267
|
+
* Schema for the `charge` challenge request — the method-specific data a merchant
|
|
268
|
+
* publishes in an MPP `402` challenge. It describes what the merchant receives and the
|
|
269
|
+
* source option the payer may fund from, so the payer can build the payment offline.
|
|
270
|
+
*/
|
|
271
|
+
declare const ChargeRequestSchema: z.ZodMiniObject<{
|
|
272
|
+
source: z.ZodMiniObject<{
|
|
273
|
+
network: z.ZodMiniString<string>;
|
|
274
|
+
asset: z.ZodMiniString<string>;
|
|
275
|
+
amount: z.ZodMiniString<string>;
|
|
276
|
+
}, z.core.$strip>;
|
|
277
|
+
extra: z.ZodMiniObject<{
|
|
278
|
+
destination: z.ZodMiniObject<{
|
|
279
|
+
network: z.ZodMiniString<string>;
|
|
280
|
+
asset: z.ZodMiniString<string>;
|
|
281
|
+
address: z.ZodMiniString<string>;
|
|
282
|
+
}, z.core.$strip>;
|
|
283
|
+
fulfillmentAmount: z.ZodMiniString<string>;
|
|
284
|
+
escrow: z.ZodMiniString<string>;
|
|
285
|
+
fulfillmentProxy: z.ZodMiniString<string>;
|
|
286
|
+
reserver: z.ZodMiniString<string>;
|
|
287
|
+
releaser: z.ZodMiniString<string>;
|
|
288
|
+
fulfillmentVerifierEndpoint: z.ZodMiniString<string>;
|
|
289
|
+
quoteDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
290
|
+
fulfillmentDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
291
|
+
svmSignatureClusterId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
292
|
+
svmSignatureDomainVersion: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
293
|
+
issuedAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
294
|
+
}, z.core.$strip>;
|
|
295
|
+
}, z.core.$strip>;
|
|
296
|
+
/**
|
|
297
|
+
* Schema for the `charge` credential payload — the signed payment the payer returns in
|
|
298
|
+
* the MPP credential. It carries the Atum payment request; the request's signatures and
|
|
299
|
+
* terms are verified in full during server verification and by the Atum Payment Gateway,
|
|
300
|
+
* so this envelope validates only that the request is present.
|
|
301
|
+
*/
|
|
302
|
+
declare const CredentialPayloadSchema: z.ZodMiniObject<{
|
|
303
|
+
paymentRequest: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
/**
|
|
306
|
+
* The `charge` challenge request — the canonical `AtumEscrowRequest` shape (source option
|
|
307
|
+
* + the destination/corridor `extra`). The runtime schema above is verified against this
|
|
308
|
+
* type at compile time (below), so the validator and the canonical schema cannot drift.
|
|
309
|
+
*/
|
|
310
|
+
type ChargeRequest = AtumEscrowRequest;
|
|
311
|
+
/** The `charge` credential payload, carrying the signed Atum payment request. */
|
|
312
|
+
interface ChargeCredentialPayload {
|
|
313
|
+
/** The signed Atum payment request: source/destination, amounts, and authorizations. */
|
|
314
|
+
paymentRequest: PaymentRequest;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The MPP challenge for this method. Uses the schema's inferred type for the request
|
|
318
|
+
* (equal to {@link ChargeRequest} by the compile-time guard above, and compatible with
|
|
319
|
+
* the framework's `Record<string, unknown>` request constraint).
|
|
320
|
+
*/
|
|
321
|
+
type AtumEscrowChallenge = Challenge.Challenge<z.infer<typeof ChargeRequestSchema>, "charge", "atum-escrow">;
|
|
322
|
+
/** The MPP credential for this method. */
|
|
323
|
+
type AtumEscrowCredential = Credential.Credential<ChargeCredentialPayload, AtumEscrowChallenge>;
|
|
324
|
+
/**
|
|
325
|
+
* The base `atum-escrow` charge method. Extend it with `registerClient` on the payer side
|
|
326
|
+
* and `registerServer` on the merchant side.
|
|
327
|
+
*/
|
|
328
|
+
declare const atumEscrowChargeMethod: {
|
|
329
|
+
readonly name: "atum-escrow";
|
|
330
|
+
readonly intent: "charge";
|
|
331
|
+
readonly schema: {
|
|
332
|
+
readonly request: z.ZodMiniObject<{
|
|
333
|
+
source: z.ZodMiniObject<{
|
|
334
|
+
network: z.ZodMiniString<string>;
|
|
335
|
+
asset: z.ZodMiniString<string>;
|
|
336
|
+
amount: z.ZodMiniString<string>;
|
|
337
|
+
}, z.core.$strip>;
|
|
338
|
+
extra: z.ZodMiniObject<{
|
|
339
|
+
destination: z.ZodMiniObject<{
|
|
340
|
+
network: z.ZodMiniString<string>;
|
|
341
|
+
asset: z.ZodMiniString<string>;
|
|
342
|
+
address: z.ZodMiniString<string>;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
fulfillmentAmount: z.ZodMiniString<string>;
|
|
345
|
+
escrow: z.ZodMiniString<string>;
|
|
346
|
+
fulfillmentProxy: z.ZodMiniString<string>;
|
|
347
|
+
reserver: z.ZodMiniString<string>;
|
|
348
|
+
releaser: z.ZodMiniString<string>;
|
|
349
|
+
fulfillmentVerifierEndpoint: z.ZodMiniString<string>;
|
|
350
|
+
quoteDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
351
|
+
fulfillmentDeadlineSeconds: z.ZodMiniNumber<number>;
|
|
352
|
+
svmSignatureClusterId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
353
|
+
svmSignatureDomainVersion: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
354
|
+
issuedAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
355
|
+
}, z.core.$strip>;
|
|
356
|
+
}, z.core.$strip>;
|
|
357
|
+
readonly credential: {
|
|
358
|
+
readonly payload: z.ZodMiniObject<{
|
|
359
|
+
paymentRequest: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
360
|
+
}, z.core.$strip>;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export { type AtumEscrowChallenge as A, type ChargeCredentialPayload as C, INTENT as I, METHOD_NAME as M, type SenderSigner as S, type AtumEscrowCredential as a, type AtumEscrowRequest as b, type ChargeRequest as c, ChargeRequestSchema as d, CredentialPayloadSchema as e, INTENT_ID_META_KEY as f, type SenderSignerOptions as g, atumEscrowChargeMethod as h, type SolanaClusterUnixTimeReader as i, type ChainDefaults as j };
|