@t2000/cli 10.20.2 → 10.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LKSOKYLR.js → chunk-5MAY6SK7.js} +2 -6
- package/dist/{chunk-LKSOKYLR.js.map → chunk-5MAY6SK7.js.map} +1 -1
- package/dist/{chunk-SUSL7H4U.js → chunk-D3DUYZYR.js} +1 -20
- package/dist/{chunk-SUSL7H4U.js.map → chunk-D3DUYZYR.js.map} +1 -1
- package/dist/{chunk-XE63VG7O.js → chunk-JEIOQF6Q.js} +3 -3
- package/dist/{chunk-WHUYPKGH.js → chunk-R6QER65C.js} +3 -3
- package/dist/{chunk-3YV35WUN.js → chunk-SKQLFHJJ.js} +5 -5
- package/dist/{chunk-3ZUWXUSN.js → chunk-ZXXZGTWS.js} +71 -2
- package/dist/chunk-ZXXZGTWS.js.map +1 -0
- package/dist/{dist-2UQ2QGGD.js → dist-36BJD54E.js} +4 -5
- package/dist/{dist-2UQ2QGGD.js.map → dist-36BJD54E.js.map} +1 -1
- package/dist/{dist-3WU6OGLY.js → dist-MQVAPHMQ.js} +6 -7
- package/dist/{esm-B2D3HRCK.js → esm-4JYJHL2T.js} +2 -2
- package/dist/{grpc-5M6HXT6N.js → grpc-SHHHADW4.js} +4 -4
- package/dist/index.js +12314 -499
- package/dist/index.js.map +1 -1
- package/dist/{src-JJQKDNTF.js → src-4VRJNQ2G.js} +3 -5
- package/dist/{src-JJQKDNTF.js.map → src-4VRJNQ2G.js.map} +1 -1
- package/package.json +3 -3
- package/dist/_esm-K6TT5GJK.js +0 -3660
- package/dist/_esm-K6TT5GJK.js.map +0 -1
- package/dist/ccip-RH5RVHLF.js +0 -18
- package/dist/chunk-3ZUWXUSN.js.map +0 -1
- package/dist/chunk-4MFEND6E.js +0 -154
- package/dist/chunk-4MFEND6E.js.map +0 -1
- package/dist/chunk-5T7HEJY2.js +0 -620
- package/dist/chunk-5T7HEJY2.js.map +0 -1
- package/dist/chunk-65QFRTNV.js +0 -1918
- package/dist/chunk-65QFRTNV.js.map +0 -1
- package/dist/chunk-CPGDCKGM.js +0 -13603
- package/dist/chunk-CPGDCKGM.js.map +0 -1
- package/dist/chunk-HTE5A24I.js +0 -78
- package/dist/chunk-HTE5A24I.js.map +0 -1
- package/dist/chunk-OCLKPYUU.js +0 -2
- package/dist/chunk-PDKJSPAS.js +0 -243
- package/dist/chunk-PDKJSPAS.js.map +0 -1
- package/dist/chunk-QO46HIYL.js +0 -12
- package/dist/chunk-QO46HIYL.js.map +0 -1
- package/dist/chunk-R5V4MKT2.js +0 -968
- package/dist/chunk-R5V4MKT2.js.map +0 -1
- package/dist/chunk-RHWZZCW3.js +0 -265
- package/dist/chunk-RHWZZCW3.js.map +0 -1
- package/dist/chunk-RI6QL63V.js +0 -17061
- package/dist/chunk-RI6QL63V.js.map +0 -1
- package/dist/chunk-YDDF6B4R.js +0 -5206
- package/dist/chunk-YDDF6B4R.js.map +0 -1
- package/dist/client-JLZR2FS5.js +0 -16020
- package/dist/client-JLZR2FS5.js.map +0 -1
- package/dist/client-UP24NK7G.js +0 -150
- package/dist/client-UP24NK7G.js.map +0 -1
- package/dist/dist-3WU6OGLY.js.map +0 -1
- package/dist/dist-LRMCAOJQ.js +0 -37
- package/dist/dist-LRMCAOJQ.js.map +0 -1
- package/dist/dist-PB7J4ZXK.js +0 -440
- package/dist/dist-PB7J4ZXK.js.map +0 -1
- package/dist/grpc-5M6HXT6N.js.map +0 -1
- package/dist/secp256k1-L7272WAL.js +0 -20
- package/dist/secp256k1-L7272WAL.js.map +0 -1
- /package/dist/{chunk-XE63VG7O.js.map → chunk-JEIOQF6Q.js.map} +0 -0
- /package/dist/{chunk-WHUYPKGH.js.map → chunk-R6QER65C.js.map} +0 -0
- /package/dist/{chunk-3YV35WUN.js.map → chunk-SKQLFHJJ.js.map} +0 -0
- /package/dist/{ccip-RH5RVHLF.js.map → dist-MQVAPHMQ.js.map} +0 -0
- /package/dist/{esm-B2D3HRCK.js.map → esm-4JYJHL2T.js.map} +0 -0
- /package/dist/{chunk-OCLKPYUU.js.map → grpc-SHHHADW4.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../x402/src/constants.ts","../../x402/src/store.ts","../../x402/src/utils.ts","../../x402/src/x402.ts"],"sourcesContent":["// Payment-asset constants for the x402 dialect. USDC is the settlement\n// stable on both networks; anything richer (decimals lookups, symbol\n// resolution) belongs to the SDK's token registry, not here.\n\nexport interface Currency {\n type: string;\n decimals: number;\n}\n\nexport const SUI_USDC_TYPE =\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';\n\nexport const SUI_USDC_TESTNET_TYPE =\n '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC';\n\nexport const USDC = {\n type: SUI_USDC_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n\nexport const USDC_TESTNET = {\n type: SUI_USDC_TESTNET_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n","// Digest replay store + settlement report — hoisted OFF the suimpp server\n// module (SPEC_T2_X402_MONOREPO §3a lock 2) so this package never touches\n// the mppx pay loop. Settle-once enforcement: every settled digest is\n// recorded, and a digest that has been seen settles nothing twice.\n\nexport interface DigestStore {\n has(digest: string): Promise<boolean>;\n set(digest: string): Promise<void>;\n}\n\n/** What a successful settlement reports to the host (ops / activity hooks). */\nexport interface PaymentReport {\n digest: string;\n sender?: string;\n recipient: string;\n amount: string;\n currency: string;\n network: string;\n}\n\nconst DEFAULT_TTL_MS = 86_400_000; // 24 hours\nconst EVICTION_INTERVAL_MS = 3_600_000; // 1 hour\n\n/** Dev/test store — per-process, TTL-evicted. Production sellers supply a\n * durable DigestStore (Redis, Postgres); replay windows must survive\n * restarts. */\nexport class InMemoryDigestStore implements DigestStore {\n private store = new Map<string, number>();\n private readonly ttlMs: number;\n\n constructor(ttlMs = DEFAULT_TTL_MS) {\n this.ttlMs = ttlMs;\n if (typeof globalThis.setInterval === 'function') {\n const timer = setInterval(() => this.evict(), EVICTION_INTERVAL_MS);\n if (typeof timer === 'object' && 'unref' in timer) timer.unref();\n }\n }\n\n async has(digest: string): Promise<boolean> {\n const expiresAt = this.store.get(digest);\n if (expiresAt === undefined) return false;\n if (Date.now() > expiresAt) {\n this.store.delete(digest);\n return false;\n }\n return true;\n }\n\n async set(digest: string): Promise<void> {\n this.store.set(digest, Date.now() + this.ttlMs);\n }\n\n private evict(): void {\n const now = Date.now();\n for (const [digest, expiresAt] of this.store.entries()) {\n if (now > expiresAt) this.store.delete(digest);\n }\n }\n}\n","/**\n * Parse a string amount to raw bigint units without floating-point math.\n * \"0.01\" with 6 decimals → 10000n\n */\nexport function parseAmountToRaw(amount: string, decimals: number): bigint {\n const [whole = '0', frac = ''] = amount.split('.');\n const paddedFrac = frac.padEnd(decimals, '0').slice(0, decimals);\n return BigInt(whole + paddedFrac);\n}\n\n/**\n * Retry an async function with linear backoff.\n * Throws the last error if all attempts fail.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n {\n attempts = 5,\n baseDelayMs = 1000,\n }: { attempts?: number; baseDelayMs?: number } = {},\n): Promise<T> {\n let lastError: unknown;\n for (let i = 0; i < attempts; i++) {\n try {\n return await fn();\n } catch (err) {\n lastError = err;\n if (i < attempts - 1) {\n await new Promise((r) => setTimeout(r, baseDelayMs * (i + 1)));\n }\n }\n }\n throw lastError;\n}\n","import type { ClientWithCoreApi } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport { Transaction } from '@mysten/sui/transactions';\nimport {\n fromBase64,\n normalizeSuiAddress,\n toBase64,\n toHex,\n} from '@mysten/sui/utils';\nimport type { Currency } from './constants.js';\nimport type { DigestStore, PaymentReport } from './store.js';\nimport { parseAmountToRaw, withRetry } from './utils.js';\n\n// ---------------------------------------------------------------------------\n// x402 dialect for the suimpp rail — scheme `exact` on network `sui:*`.\n//\n// Canonical design doc: t2000-internal `spec/active/SUIMPP_X402_SCHEME.md`\n// (v0.3, APPROVED). The settlement rail is identical to the legacy digest\n// dialect — a gasless stablecoin transfer (`0x2::balance::send_funds`,\n// gasPrice = 0, no gas payment, protocol-level gasless). The ONLY change is\n// choreography: the client SIGNS but does not submit; the server (gateway /\n// facilitator) submits at serve time. This makes no-charge-on-failure\n// structural and clients sign-only.\n//\n// Replay binding (on-chain): the stateless address-balance form requires\n// `ValidDuring { minEpoch, maxEpoch, chain, nonce }` expiration — we derive\n// the nonce from the challenge id, which cryptographically binds the signed\n// payment to the specific 402 challenge and guarantees two same-amount\n// payments in the same epoch produce distinct digests. The nonce carries\n// UNIQUENESS, not secrecy (challenge ids are already unguessable HMAC\n// outputs); replay safety = challenge-once + digest-once + the 1-epoch\n// window, enforced server-side.\n// ---------------------------------------------------------------------------\n\nexport const X402_SCHEME = 'exact' as const;\nexport const X402_VERSION = 1 as const;\n/** Request header carrying the signed payment (x402 standard). */\nexport const X402_PAYMENT_HEADER = 'X-PAYMENT';\n/** Response header carrying the settlement result (x402 standard). */\nexport const X402_PAYMENT_RESPONSE_HEADER = 'X-PAYMENT-RESPONSE';\n\n/** The Sui framework package — the ONLY package a payment PTB may call. */\nconst FRAMEWORK_PACKAGE = normalizeSuiAddress('0x2');\n/** `module::function` pairs that move funds to the recipient. */\nconst SEND_FUNDS_FNS = new Set(['balance::send_funds', 'coin::send_funds']);\n/** Every `module::function` permitted in a payment PTB (the gasless trio). */\nconst ALLOWED_FNS = new Set([\n ...SEND_FUNDS_FNS,\n 'balance::redeem_funds',\n 'coin::redeem_funds',\n 'balance::withdrawal_split',\n 'coin::into_balance',\n]);\n\nexport type X402Network =\n `sui:${'mainnet' | 'testnet' | 'devnet' | 'localnet'}`;\n\nexport interface X402Requirements {\n scheme: typeof X402_SCHEME;\n network: X402Network;\n /** Full Sui coin type of the payment asset. */\n asset: string;\n /** Atomic units (e.g. USDC 6dp) as a decimal string. */\n maxAmountRequired: string;\n payTo: string;\n resource: string;\n maxTimeoutSeconds: number;\n extra: {\n suimpp: {\n /** The mppx challenge id this payment must bind to (single-use). */\n challengeId: string;\n /** u32 derived from challengeId — goes into ValidDuring.nonce. */\n nonce: number;\n /** Chain identifier string for ValidDuring (genesis digest). */\n chain: string;\n minEpoch: string;\n maxEpoch: string;\n };\n };\n}\n\n// ---------------------------------------------------------------------------\n// Escrow intent — the job-class extension (SPEC_A2A_ESCROW slice 2).\n//\n// Instant calls are settle-then-serve and need no escrow. Async deliverable\n// work (reports, builds, SLA jobs) commits funds BEFORE delivery starts, so\n// a job-class endpoint's 402 advertises escrow TERMS instead of a payment\n// challenge: the buyer creates+funds a shared `a2a_escrow::escrow::Job`\n// object on Sui (funds live in the object — no facilitator custody), then\n// presents the Job object id as the X-PAYMENT credential. The seller\n// verifies the object ON-CHAIN (funded, pays me, covers the price) before\n// starting work — chain-verified, so it works for every signer including\n// zkLogin. Settlement (deliver/release/reject/refund) happens on the object,\n// not through this rail.\n//\n// Semantics: an accepts[] entry carrying `extra.escrow` is JOB-CLASS — the\n// seller MUST refuse an instant signed-transfer X-PAYMENT against it, and\n// clients MUST NOT pay it instantly (route through the escrow flow, e.g.\n// `t2 job create`).\n//\n// This package carries only the surface t2000 consumes: the terms types +\n// the two discriminators (isX402EscrowRequirements for client routing,\n// isX402EscrowHeader for the seller-side refusal). The escrow-credential\n// BUILDER helpers (createX402EscrowRequirements, encode/parse of the\n// Job-object X-PAYMENT payload) had zero consumers here and stay published\n// in @suimpp/mpp.\n// ---------------------------------------------------------------------------\n\nexport interface X402EscrowTerms {\n /** Time the seller commits to deliver within, in ms from job creation. */\n deliverWithinMs: number;\n /** Buyer's accept/reject window after delivery, in ms. Lapse = release. */\n reviewWindowMs: number;\n /** Buyer's share in basis points if they reject (0–10000). Fixed at job\n * creation — neither side can move the goalposts later. */\n rejectSplitBps: number;\n /** The escrow Move package the seller verifies jobs against\n * (`a2a_escrow::escrow` on the advertised network). */\n packageId?: string;\n /** Optional pointer (URL or short note) describing the expected job-spec\n * format the buyer should hash into the job's `spec_hash`. */\n specSchema?: string;\n}\n\n/** A job-class `accepts[]` entry. Same base fields as the instant entry\n * (`maxAmountRequired` = the job price) but NO settlement challenge —\n * `extra.escrow` replaces `extra.suimpp`. */\nexport interface X402EscrowRequirements {\n scheme: typeof X402_SCHEME;\n network: X402Network;\n asset: string;\n /** The job price in atomic units (decimal string). */\n maxAmountRequired: string;\n /** The seller wallet the Job must pay (and the claimed Agent ID wallet). */\n payTo: string;\n resource: string;\n maxTimeoutSeconds: number;\n extra: { escrow: X402EscrowTerms };\n}\n\n/** Discriminate a job-class entry inside a mixed accepts[] array. */\nexport function isX402EscrowRequirements(\n entry: unknown,\n): entry is X402EscrowRequirements {\n return Boolean(\n entry &&\n typeof entry === 'object' &&\n typeof (entry as X402EscrowRequirements).extra?.escrow\n ?.deliverWithinMs === 'number',\n );\n}\n\n/** Discriminate escrow vs instant X-PAYMENT credentials without throwing —\n * sellers serving both classes route on this before parsing. */\nexport function isX402EscrowHeader(headerValue: string): boolean {\n try {\n const parsed = JSON.parse(\n new TextDecoder().decode(fromBase64(headerValue)),\n );\n return typeof parsed?.payload?.jobId === 'string';\n } catch {\n return false;\n }\n}\n\nexport interface X402PaymentPayload {\n x402Version: typeof X402_VERSION;\n scheme: typeof X402_SCHEME;\n network: X402Network;\n payload: {\n senderAddress: string;\n /** base64 BCS TransactionData — fully signed-ready bytes. */\n txBytes: string;\n /** Sender signature over txBytes (Ed25519 / secp / zkLogin). */\n senderSignature: string;\n challengeId: string;\n };\n}\n\nexport interface X402SettleResponse {\n success: boolean;\n network: X402Network;\n /** Settled transaction digest. */\n transaction: string;\n payer: string;\n}\n\n/**\n * Derive the ValidDuring nonce (u32) from a challenge id. FNV-1a 32-bit —\n * dependency-free and browser-safe. The nonce provides per-challenge\n * UNIQUENESS (distinct digests for otherwise-identical payments); it is not\n * a secret and carries no security on its own.\n */\nexport function challengeNonce(challengeId: string): number {\n let hash = 0x811c9dc5;\n for (let i = 0; i < challengeId.length; i++) {\n hash ^= challengeId.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n return hash >>> 0;\n}\n\nexport function x402Network(\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n): X402Network {\n return `sui:${network}`;\n}\n\n// ---------------------------------------------------------------------------\n// Server half — build the `accepts[]` entry for a 402 response\n// ---------------------------------------------------------------------------\n\nexport interface CreateRequirementsOptions {\n challengeId: string;\n /** Human-units amount string from the challenge (e.g. \"0.02\"). */\n amount: string;\n currency: Currency;\n recipient: string;\n resource: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n /** Chain identifier string (genesis digest) for ValidDuring. */\n chain: string;\n /** Current epoch — requirements are valid for [epoch, epoch + 1]. */\n currentEpoch: bigint | number | string;\n maxTimeoutSeconds?: number;\n}\n\nexport function createX402Requirements(\n options: CreateRequirementsOptions,\n): X402Requirements {\n const amountRaw = parseAmountToRaw(options.amount, options.currency.decimals);\n const minEpoch = BigInt(options.currentEpoch);\n return {\n scheme: X402_SCHEME,\n network: x402Network(options.network),\n asset: options.currency.type,\n maxAmountRequired: amountRaw.toString(),\n payTo: options.recipient,\n resource: options.resource,\n maxTimeoutSeconds: options.maxTimeoutSeconds ?? 60,\n extra: {\n suimpp: {\n challengeId: options.challengeId,\n nonce: challengeNonce(options.challengeId),\n chain: options.chain,\n minEpoch: minEpoch.toString(),\n maxEpoch: (minEpoch + 1n).toString(),\n },\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Client half — build + sign the payment WITHOUT submitting\n// ---------------------------------------------------------------------------\n\nexport interface BuildSignedPaymentOptions {\n requirements: X402Requirements;\n signer: Signer;\n /**\n * Optional client for build-time resolution. The canonical stateless\n * shape (address-balance withdrawal → redeem_funds → send_funds) has no\n * object inputs, so the build is offline when omitted.\n */\n client?: ClientWithCoreApi;\n}\n\n/**\n * Build the canonical stateless payment transaction, sign it, and return the\n * `X-PAYMENT` header value + parsed payload. Never submits — settlement is\n * the server's job (`settleX402Payment`).\n */\nexport async function buildX402SignedPayment(\n options: BuildSignedPaymentOptions,\n): Promise<{ header: string; payment: X402PaymentPayload }> {\n const { requirements, signer } = options;\n const { suimpp } = requirements.extra;\n const sender = signer.toSuiAddress();\n const amountRaw = BigInt(requirements.maxAmountRequired);\n\n const tx = new Transaction();\n tx.setSender(sender);\n\n const [balance] = tx.moveCall({\n target: '0x2::balance::redeem_funds',\n typeArguments: [requirements.asset],\n arguments: [tx.withdrawal({ amount: amountRaw, type: requirements.asset })],\n });\n tx.moveCall({\n target: '0x2::balance::send_funds',\n typeArguments: [requirements.asset],\n arguments: [balance, tx.pure.address(requirements.payTo)],\n });\n\n // Gasless stablecoin transfer: empty gas payment + zero price/budget.\n tx.setGasPrice(0);\n tx.setGasBudget(0);\n tx.setGasPayment([]);\n tx.setExpiration({\n ValidDuring: {\n minEpoch: suimpp.minEpoch,\n maxEpoch: suimpp.maxEpoch,\n minTimestamp: null,\n maxTimestamp: null,\n chain: suimpp.chain,\n nonce: suimpp.nonce,\n },\n });\n\n const bytes = options.client\n ? await tx.build({ client: options.client })\n : await tx.build();\n const { signature } = await signer.signTransaction(bytes);\n\n const payment: X402PaymentPayload = {\n x402Version: X402_VERSION,\n scheme: X402_SCHEME,\n network: requirements.network,\n payload: {\n senderAddress: sender,\n txBytes: toBase64(bytes),\n senderSignature: signature,\n challengeId: suimpp.challengeId,\n },\n };\n return { header: encodeX402Header(payment), payment };\n}\n\nexport function encodeX402Header(payment: X402PaymentPayload): string {\n return toBase64(new TextEncoder().encode(JSON.stringify(payment)));\n}\n\nexport function parseX402Header(headerValue: string): X402PaymentPayload {\n let parsed: X402PaymentPayload;\n try {\n parsed = JSON.parse(new TextDecoder().decode(fromBase64(headerValue)));\n } catch {\n throw new Error('[suimpp/x402] X-PAYMENT header is not base64 JSON');\n }\n if (parsed.scheme !== X402_SCHEME) {\n throw new Error(`[suimpp/x402] Unsupported scheme: ${parsed.scheme}`);\n }\n const p = parsed.payload;\n if (\n !p?.txBytes ||\n !p?.senderSignature ||\n !p?.challengeId ||\n !p?.senderAddress\n ) {\n throw new Error('[suimpp/x402] X-PAYMENT payload missing required fields');\n }\n return parsed;\n}\n\n// ---------------------------------------------------------------------------\n// Server half — verify (pre-settle, structural) + settle (submit + confirm)\n// ---------------------------------------------------------------------------\n\nexport interface VerifyX402Options {\n payment: X402PaymentPayload;\n /** The terms this payment must match (from the original challenge). */\n expected: {\n challengeId: string;\n amount: string;\n currency: Currency;\n recipient: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n };\n}\n\n/**\n * Structural pre-settle verification: the signed bytes must be the canonical\n * gasless payment for OUR terms before we relay them. Catches wrong-terms /\n * relay-abuse payloads without an RPC call.\n *\n * SCOPE (Phase 1): this is a STRUCTURAL check — it does NOT verify\n * `senderSignature`. Signature authority is the chain at `settleX402Payment`\n * (a bad signature fails `executeTransaction`, and under settle-then-serve\n * the upstream is never called), plus the post-settle balance-change check.\n * A standalone Phase-3 public `/verify` endpoint adds an explicit async\n * signature check (needs a client for zkLogin) on top of this.\n */\nexport function verifyX402Payment(options: VerifyX402Options): {\n txBytes: Uint8Array;\n nonce: number;\n} {\n const { payment, expected } = options;\n\n if (payment.network !== x402Network(expected.network)) {\n throw new Error(`[suimpp/x402] Network mismatch: ${payment.network}`);\n }\n if (payment.payload.challengeId !== expected.challengeId) {\n throw new Error('[suimpp/x402] Payment is bound to a different challenge');\n }\n\n const txBytes = fromBase64(payment.payload.txBytes);\n const tx = Transaction.from(txBytes);\n const data = tx.getData();\n\n if (\n !data.sender ||\n normalizeSuiAddress(data.sender) !==\n normalizeSuiAddress(payment.payload.senderAddress)\n ) {\n throw new Error('[suimpp/x402] Transaction sender mismatch');\n }\n\n // Gasless shape: zero price, no gas payment objects.\n const gas = data.gasData;\n if (BigInt(gas.price ?? 1) !== 0n || (gas.payment?.length ?? 0) > 0) {\n throw new Error('[suimpp/x402] Transaction is not a gasless transfer');\n }\n\n // ValidDuring nonce = the on-chain challenge binding.\n const expiration = data.expiration;\n const validDuring =\n expiration && 'ValidDuring' in expiration ? expiration.ValidDuring : null;\n if (!validDuring) {\n throw new Error(\n '[suimpp/x402] Transaction must use ValidDuring expiration',\n );\n }\n const expectedNonce = challengeNonce(expected.challengeId);\n if (Number(validDuring.nonce) !== expectedNonce) {\n throw new Error(\n '[suimpp/x402] ValidDuring nonce does not bind to the challenge',\n );\n }\n\n // Command allowlist: only the gasless transfer trio on the FRAMEWORK\n // package (0x2) may appear, and at least one send_funds must pay the\n // expected recipient. The package check is load-bearing — a malicious\n // `0xEVIL::balance::send_funds` must NOT pass as `0x2::balance::send_funds`.\n const normalizedRecipient = normalizeSuiAddress(expected.recipient);\n let paysRecipient = false;\n for (const command of data.commands) {\n if (!('MoveCall' in command) || !command.MoveCall) {\n throw new Error('[suimpp/x402] Only MoveCall commands are permitted');\n }\n const call = command.MoveCall;\n const fn = `${call.module}::${call.function}`;\n if (normalizeSuiAddress(call.package) !== FRAMEWORK_PACKAGE) {\n throw new Error(\n `[suimpp/x402] Non-framework package call: ${call.package}::${fn}`,\n );\n }\n if (!ALLOWED_FNS.has(fn)) {\n throw new Error(`[suimpp/x402] Disallowed Move call: 0x2::${fn}`);\n }\n if (SEND_FUNDS_FNS.has(fn)) {\n const recipientArg = call.arguments[call.arguments.length - 1];\n if (\n recipientArg &&\n typeof recipientArg === 'object' &&\n 'Input' in recipientArg\n ) {\n const input = data.inputs[recipientArg.Input as number];\n if (input && 'Pure' in input && input.Pure?.bytes) {\n const addr = `0x${toHex(fromBase64(input.Pure.bytes))}`;\n if (normalizeSuiAddress(addr) === normalizedRecipient) {\n paysRecipient = true;\n }\n }\n }\n }\n }\n if (!paysRecipient) {\n throw new Error(\n '[suimpp/x402] Transaction does not pay the expected recipient',\n );\n }\n\n return { txBytes, nonce: expectedNonce };\n}\n\nexport interface SettleX402Options {\n payment: X402PaymentPayload;\n client: ClientWithCoreApi;\n /** Digest replay store — shared with the legacy dialect. */\n store: DigestStore;\n expected: VerifyX402Options['expected'];\n onPayment?: (report: PaymentReport) => void;\n}\n\n/**\n * Settle-then-serve: verify structurally, submit the client-signed bytes,\n * confirm the on-chain balance change, record the digest. Throws (and the\n * host returns 402) without serving if anything fails — and because the\n * host only calls the upstream AFTER this resolves, a failed upstream can\n * void/refund before any service value is lost.\n */\nexport async function settleX402Payment(\n options: SettleX402Options,\n): Promise<X402SettleResponse> {\n const { payment, client, store, expected } = options;\n const { txBytes } = verifyX402Payment({ payment, expected });\n\n const result = await withRetry(\n () =>\n client.core.executeTransaction({\n transaction: txBytes,\n signatures: [payment.payload.senderSignature],\n include: { balanceChanges: true, transaction: true },\n }),\n { attempts: 3, baseDelayMs: 500 },\n );\n\n const resolved = result.Transaction ?? result.FailedTransaction;\n if (!resolved?.status.success) {\n throw new Error(\n `[suimpp/x402] Settlement failed on-chain: ${\n resolved?.status.error?.message ?? 'unknown'\n }`,\n );\n }\n\n const digest = resolved.digest;\n if (await store.has(digest)) {\n throw new Error(`[suimpp/x402] Digest already used: ${digest}`);\n }\n\n // Post-settle enforcement (same checks as the legacy dialect).\n const normalizedRecipient = normalizeSuiAddress(expected.recipient);\n const paid = resolved.balanceChanges.find(\n (bc) =>\n bc.coinType === expected.currency.type &&\n normalizeSuiAddress(bc.address) === normalizedRecipient &&\n BigInt(bc.amount) > 0n,\n );\n const requestedRaw = parseAmountToRaw(\n expected.amount,\n expected.currency.decimals,\n );\n if (!paid || BigInt(paid.amount) < requestedRaw) {\n throw new Error('[suimpp/x402] Settled amount does not satisfy the terms');\n }\n\n await store.set(digest);\n\n const report: PaymentReport = {\n digest,\n sender: payment.payload.senderAddress,\n recipient: expected.recipient,\n amount: expected.amount,\n currency: expected.currency.type,\n network: expected.network,\n };\n if (options.onPayment) {\n try {\n options.onPayment(report);\n } catch {}\n }\n\n return {\n success: true,\n network: payment.network,\n transaction: digest,\n payer: payment.payload.senderAddress,\n };\n}\n\nexport function encodeX402Response(response: X402SettleResponse): string {\n return toBase64(new TextEncoder().encode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,QAAI;AACF,cAAQ,UAAU,MAAM;IAC1B,QAAQ;IAAC;EACX;AAEA,SAAO;IACL,SAAS;IACT,SAAS,QAAQ;IACjB,aAAa;IACb,OAAO,QAAQ,QAAQ;EAAA;AAE3B;AAEO,SAAS,mBAAmB,UAAsC;AACvE,SAAO,SAAS,IAAI,YAAA,EAAc,OAAO,KAAK,UAAU,QAAQ,CAAC,CAAC;AACpE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../x402/src/constants.ts","../../x402/src/store.ts","../../x402/src/utils.ts","../../x402/src/x402.ts"],"sourcesContent":["// Payment-asset constants for the x402 dialect. USDC is the settlement\n// stable on both networks; anything richer (decimals lookups, symbol\n// resolution) belongs to the SDK's token registry, not here.\n\nexport interface Currency {\n type: string;\n decimals: number;\n}\n\nexport const SUI_USDC_TYPE =\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';\n\nexport const SUI_USDC_TESTNET_TYPE =\n '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC';\n\nexport const USDC = {\n type: SUI_USDC_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n\nexport const USDC_TESTNET = {\n type: SUI_USDC_TESTNET_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n","// Digest replay store + settlement report — hoisted OFF the suimpp server\n// module (SPEC_T2_X402_MONOREPO §3a lock 2) so this package never touches\n// the mppx pay loop. Settle-once enforcement: every settled digest is\n// recorded, and a digest that has been seen settles nothing twice.\n\nexport interface DigestStore {\n has(digest: string): Promise<boolean>;\n set(digest: string): Promise<void>;\n}\n\n/** What a successful settlement reports to the host (ops / activity hooks). */\nexport interface PaymentReport {\n digest: string;\n sender?: string;\n recipient: string;\n amount: string;\n currency: string;\n network: string;\n}\n\nconst DEFAULT_TTL_MS = 86_400_000; // 24 hours\nconst EVICTION_INTERVAL_MS = 3_600_000; // 1 hour\n\n/** Dev/test store — per-process, TTL-evicted. Production sellers supply a\n * durable DigestStore (Redis, Postgres); replay windows must survive\n * restarts. */\nexport class InMemoryDigestStore implements DigestStore {\n private store = new Map<string, number>();\n private readonly ttlMs: number;\n\n constructor(ttlMs = DEFAULT_TTL_MS) {\n this.ttlMs = ttlMs;\n if (typeof globalThis.setInterval === 'function') {\n const timer = setInterval(() => this.evict(), EVICTION_INTERVAL_MS);\n if (typeof timer === 'object' && 'unref' in timer) timer.unref();\n }\n }\n\n async has(digest: string): Promise<boolean> {\n const expiresAt = this.store.get(digest);\n if (expiresAt === undefined) return false;\n if (Date.now() > expiresAt) {\n this.store.delete(digest);\n return false;\n }\n return true;\n }\n\n async set(digest: string): Promise<void> {\n this.store.set(digest, Date.now() + this.ttlMs);\n }\n\n private evict(): void {\n const now = Date.now();\n for (const [digest, expiresAt] of this.store.entries()) {\n if (now > expiresAt) this.store.delete(digest);\n }\n }\n}\n","/**\n * Parse a string amount to raw bigint units without floating-point math.\n * \"0.01\" with 6 decimals → 10000n\n */\nexport function parseAmountToRaw(amount: string, decimals: number): bigint {\n const [whole = '0', frac = ''] = amount.split('.');\n const paddedFrac = frac.padEnd(decimals, '0').slice(0, decimals);\n return BigInt(whole + paddedFrac);\n}\n\n/**\n * Retry an async function with linear backoff.\n * Throws the last error if all attempts fail.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n {\n attempts = 5,\n baseDelayMs = 1000,\n }: { attempts?: number; baseDelayMs?: number } = {},\n): Promise<T> {\n let lastError: unknown;\n for (let i = 0; i < attempts; i++) {\n try {\n return await fn();\n } catch (err) {\n lastError = err;\n if (i < attempts - 1) {\n await new Promise((r) => setTimeout(r, baseDelayMs * (i + 1)));\n }\n }\n }\n throw lastError;\n}\n","import type { ClientWithCoreApi } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport { Transaction } from '@mysten/sui/transactions';\nimport {\n fromBase64,\n normalizeSuiAddress,\n toBase64,\n toHex,\n} from '@mysten/sui/utils';\nimport type { Currency } from './constants.js';\nimport type { DigestStore, PaymentReport } from './store.js';\nimport { parseAmountToRaw, withRetry } from './utils.js';\n\n// ---------------------------------------------------------------------------\n// x402 dialect for the suimpp rail — scheme `exact` on network `sui:*`.\n//\n// Canonical design doc: t2000-internal `spec/active/SUIMPP_X402_SCHEME.md`\n// (v0.3, APPROVED). The settlement rail is identical to the legacy digest\n// dialect — a gasless stablecoin transfer (`0x2::balance::send_funds`,\n// gasPrice = 0, no gas payment, protocol-level gasless). The ONLY change is\n// choreography: the client SIGNS but does not submit; the server (gateway /\n// facilitator) submits at serve time. This makes no-charge-on-failure\n// structural and clients sign-only.\n//\n// Replay binding (on-chain): the stateless address-balance form requires\n// `ValidDuring { minEpoch, maxEpoch, chain, nonce }` expiration — we derive\n// the nonce from the challenge id, which cryptographically binds the signed\n// payment to the specific 402 challenge and guarantees two same-amount\n// payments in the same epoch produce distinct digests. The nonce carries\n// UNIQUENESS, not secrecy (challenge ids are already unguessable HMAC\n// outputs); replay safety = challenge-once + digest-once + the 1-epoch\n// window, enforced server-side.\n// ---------------------------------------------------------------------------\n\nexport const X402_SCHEME = 'exact' as const;\nexport const X402_VERSION = 1 as const;\n/** Request header carrying the signed payment (x402 standard). */\nexport const X402_PAYMENT_HEADER = 'X-PAYMENT';\n/** Response header carrying the settlement result (x402 standard). */\nexport const X402_PAYMENT_RESPONSE_HEADER = 'X-PAYMENT-RESPONSE';\n\n/** The Sui framework package — the ONLY package a payment PTB may call. */\nconst FRAMEWORK_PACKAGE = normalizeSuiAddress('0x2');\n/** `module::function` pairs that move funds to the recipient. */\nconst SEND_FUNDS_FNS = new Set(['balance::send_funds', 'coin::send_funds']);\n/** Every `module::function` permitted in a payment PTB (the gasless trio). */\nconst ALLOWED_FNS = new Set([\n ...SEND_FUNDS_FNS,\n 'balance::redeem_funds',\n 'coin::redeem_funds',\n 'balance::withdrawal_split',\n 'coin::into_balance',\n]);\n\nexport type X402Network =\n `sui:${'mainnet' | 'testnet' | 'devnet' | 'localnet'}`;\n\nexport interface X402Requirements {\n scheme: typeof X402_SCHEME;\n network: X402Network;\n /** Full Sui coin type of the payment asset. */\n asset: string;\n /** Atomic units (e.g. USDC 6dp) as a decimal string. */\n maxAmountRequired: string;\n payTo: string;\n resource: string;\n maxTimeoutSeconds: number;\n extra: {\n suimpp: {\n /** The mppx challenge id this payment must bind to (single-use). */\n challengeId: string;\n /** u32 derived from challengeId — goes into ValidDuring.nonce. */\n nonce: number;\n /** Chain identifier string for ValidDuring (genesis digest). */\n chain: string;\n minEpoch: string;\n maxEpoch: string;\n };\n };\n}\n\n// ---------------------------------------------------------------------------\n// Escrow intent — the job-class extension (SPEC_A2A_ESCROW slice 2).\n//\n// Instant calls are settle-then-serve and need no escrow. Async deliverable\n// work (reports, builds, SLA jobs) commits funds BEFORE delivery starts, so\n// a job-class endpoint's 402 advertises escrow TERMS instead of a payment\n// challenge: the buyer creates+funds a shared `a2a_escrow::escrow::Job`\n// object on Sui (funds live in the object — no facilitator custody), then\n// presents the Job object id as the X-PAYMENT credential. The seller\n// verifies the object ON-CHAIN (funded, pays me, covers the price) before\n// starting work — chain-verified, so it works for every signer including\n// zkLogin. Settlement (deliver/release/reject/refund) happens on the object,\n// not through this rail.\n//\n// Semantics: an accepts[] entry carrying `extra.escrow` is JOB-CLASS — the\n// seller MUST refuse an instant signed-transfer X-PAYMENT against it, and\n// clients MUST NOT pay it instantly (route through the escrow flow, e.g.\n// `t2 job create`).\n//\n// This package carries only the surface t2000 consumes: the terms types +\n// the two discriminators (isX402EscrowRequirements for client routing,\n// isX402EscrowHeader for the seller-side refusal). The escrow-credential\n// BUILDER helpers (createX402EscrowRequirements, encode/parse of the\n// Job-object X-PAYMENT payload) had zero consumers here and stay published\n// in @suimpp/mpp.\n// ---------------------------------------------------------------------------\n\nexport interface X402EscrowTerms {\n /** Time the seller commits to deliver within, in ms from job creation. */\n deliverWithinMs: number;\n /** Buyer's accept/reject window after delivery, in ms. Lapse = release. */\n reviewWindowMs: number;\n /** Buyer's share in basis points if they reject (0–10000). Fixed at job\n * creation — neither side can move the goalposts later. */\n rejectSplitBps: number;\n /** The escrow Move package the seller verifies jobs against\n * (`a2a_escrow::escrow` on the advertised network). */\n packageId?: string;\n /** Optional pointer (URL or short note) describing the expected job-spec\n * format the buyer should hash into the job's `spec_hash`. */\n specSchema?: string;\n}\n\n/** A job-class `accepts[]` entry. Same base fields as the instant entry\n * (`maxAmountRequired` = the job price) but NO settlement challenge —\n * `extra.escrow` replaces `extra.suimpp`. */\nexport interface X402EscrowRequirements {\n scheme: typeof X402_SCHEME;\n network: X402Network;\n asset: string;\n /** The job price in atomic units (decimal string). */\n maxAmountRequired: string;\n /** The seller wallet the Job must pay (and the claimed Agent ID wallet). */\n payTo: string;\n resource: string;\n maxTimeoutSeconds: number;\n extra: { escrow: X402EscrowTerms };\n}\n\n/** Discriminate a job-class entry inside a mixed accepts[] array. */\nexport function isX402EscrowRequirements(\n entry: unknown,\n): entry is X402EscrowRequirements {\n return Boolean(\n entry &&\n typeof entry === 'object' &&\n typeof (entry as X402EscrowRequirements).extra?.escrow\n ?.deliverWithinMs === 'number',\n );\n}\n\n/** Discriminate escrow vs instant X-PAYMENT credentials without throwing —\n * sellers serving both classes route on this before parsing. */\nexport function isX402EscrowHeader(headerValue: string): boolean {\n try {\n const parsed = JSON.parse(\n new TextDecoder().decode(fromBase64(headerValue)),\n );\n return typeof parsed?.payload?.jobId === 'string';\n } catch {\n return false;\n }\n}\n\nexport interface X402PaymentPayload {\n x402Version: typeof X402_VERSION;\n scheme: typeof X402_SCHEME;\n network: X402Network;\n payload: {\n senderAddress: string;\n /** base64 BCS TransactionData — fully signed-ready bytes. */\n txBytes: string;\n /** Sender signature over txBytes (Ed25519 / secp / zkLogin). */\n senderSignature: string;\n challengeId: string;\n };\n}\n\nexport interface X402SettleResponse {\n success: boolean;\n network: X402Network;\n /** Settled transaction digest. */\n transaction: string;\n payer: string;\n}\n\n/**\n * Derive the ValidDuring nonce (u32) from a challenge id. FNV-1a 32-bit —\n * dependency-free and browser-safe. The nonce provides per-challenge\n * UNIQUENESS (distinct digests for otherwise-identical payments); it is not\n * a secret and carries no security on its own.\n */\nexport function challengeNonce(challengeId: string): number {\n let hash = 0x811c9dc5;\n for (let i = 0; i < challengeId.length; i++) {\n hash ^= challengeId.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n return hash >>> 0;\n}\n\nexport function x402Network(\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n): X402Network {\n return `sui:${network}`;\n}\n\n// ---------------------------------------------------------------------------\n// Server half — build the `accepts[]` entry for a 402 response\n// ---------------------------------------------------------------------------\n\nexport interface CreateRequirementsOptions {\n challengeId: string;\n /** Human-units amount string from the challenge (e.g. \"0.02\"). */\n amount: string;\n currency: Currency;\n recipient: string;\n resource: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n /** Chain identifier string (genesis digest) for ValidDuring. */\n chain: string;\n /** Current epoch — requirements are valid for [epoch, epoch + 1]. */\n currentEpoch: bigint | number | string;\n maxTimeoutSeconds?: number;\n}\n\nexport function createX402Requirements(\n options: CreateRequirementsOptions,\n): X402Requirements {\n const amountRaw = parseAmountToRaw(options.amount, options.currency.decimals);\n const minEpoch = BigInt(options.currentEpoch);\n return {\n scheme: X402_SCHEME,\n network: x402Network(options.network),\n asset: options.currency.type,\n maxAmountRequired: amountRaw.toString(),\n payTo: options.recipient,\n resource: options.resource,\n maxTimeoutSeconds: options.maxTimeoutSeconds ?? 60,\n extra: {\n suimpp: {\n challengeId: options.challengeId,\n nonce: challengeNonce(options.challengeId),\n chain: options.chain,\n minEpoch: minEpoch.toString(),\n maxEpoch: (minEpoch + 1n).toString(),\n },\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Client half — build + sign the payment WITHOUT submitting\n// ---------------------------------------------------------------------------\n\nexport interface BuildSignedPaymentOptions {\n requirements: X402Requirements;\n signer: Signer;\n /**\n * Optional client for build-time resolution. The canonical stateless\n * shape (address-balance withdrawal → redeem_funds → send_funds) has no\n * object inputs, so the build is offline when omitted.\n */\n client?: ClientWithCoreApi;\n}\n\n/**\n * Build the canonical stateless payment transaction, sign it, and return the\n * `X-PAYMENT` header value + parsed payload. Never submits — settlement is\n * the server's job (`settleX402Payment`).\n */\nexport async function buildX402SignedPayment(\n options: BuildSignedPaymentOptions,\n): Promise<{ header: string; payment: X402PaymentPayload }> {\n const { requirements, signer } = options;\n const { suimpp } = requirements.extra;\n const sender = signer.toSuiAddress();\n const amountRaw = BigInt(requirements.maxAmountRequired);\n\n const tx = new Transaction();\n tx.setSender(sender);\n\n const [balance] = tx.moveCall({\n target: '0x2::balance::redeem_funds',\n typeArguments: [requirements.asset],\n arguments: [tx.withdrawal({ amount: amountRaw, type: requirements.asset })],\n });\n tx.moveCall({\n target: '0x2::balance::send_funds',\n typeArguments: [requirements.asset],\n arguments: [balance, tx.pure.address(requirements.payTo)],\n });\n\n // Gasless stablecoin transfer: empty gas payment + zero price/budget.\n tx.setGasPrice(0);\n tx.setGasBudget(0);\n tx.setGasPayment([]);\n tx.setExpiration({\n ValidDuring: {\n minEpoch: suimpp.minEpoch,\n maxEpoch: suimpp.maxEpoch,\n minTimestamp: null,\n maxTimestamp: null,\n chain: suimpp.chain,\n nonce: suimpp.nonce,\n },\n });\n\n const bytes = options.client\n ? await tx.build({ client: options.client })\n : await tx.build();\n const { signature } = await signer.signTransaction(bytes);\n\n const payment: X402PaymentPayload = {\n x402Version: X402_VERSION,\n scheme: X402_SCHEME,\n network: requirements.network,\n payload: {\n senderAddress: sender,\n txBytes: toBase64(bytes),\n senderSignature: signature,\n challengeId: suimpp.challengeId,\n },\n };\n return { header: encodeX402Header(payment), payment };\n}\n\nexport function encodeX402Header(payment: X402PaymentPayload): string {\n return toBase64(new TextEncoder().encode(JSON.stringify(payment)));\n}\n\nexport function parseX402Header(headerValue: string): X402PaymentPayload {\n let parsed: X402PaymentPayload;\n try {\n parsed = JSON.parse(new TextDecoder().decode(fromBase64(headerValue)));\n } catch {\n throw new Error('[suimpp/x402] X-PAYMENT header is not base64 JSON');\n }\n if (parsed.scheme !== X402_SCHEME) {\n throw new Error(`[suimpp/x402] Unsupported scheme: ${parsed.scheme}`);\n }\n const p = parsed.payload;\n if (\n !p?.txBytes ||\n !p?.senderSignature ||\n !p?.challengeId ||\n !p?.senderAddress\n ) {\n throw new Error('[suimpp/x402] X-PAYMENT payload missing required fields');\n }\n return parsed;\n}\n\n// ---------------------------------------------------------------------------\n// Server half — verify (pre-settle, structural) + settle (submit + confirm)\n// ---------------------------------------------------------------------------\n\nexport interface VerifyX402Options {\n payment: X402PaymentPayload;\n /** The terms this payment must match (from the original challenge). */\n expected: {\n challengeId: string;\n amount: string;\n currency: Currency;\n recipient: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n };\n}\n\n/**\n * Structural pre-settle verification: the signed bytes must be the canonical\n * gasless payment for OUR terms before we relay them. Catches wrong-terms /\n * relay-abuse payloads without an RPC call.\n *\n * SCOPE (Phase 1): this is a STRUCTURAL check — it does NOT verify\n * `senderSignature`. Signature authority is the chain at `settleX402Payment`\n * (a bad signature fails `executeTransaction`, and under settle-then-serve\n * the upstream is never called), plus the post-settle balance-change check.\n * A standalone Phase-3 public `/verify` endpoint adds an explicit async\n * signature check (needs a client for zkLogin) on top of this.\n */\nexport function verifyX402Payment(options: VerifyX402Options): {\n txBytes: Uint8Array;\n nonce: number;\n} {\n const { payment, expected } = options;\n\n if (payment.network !== x402Network(expected.network)) {\n throw new Error(`[suimpp/x402] Network mismatch: ${payment.network}`);\n }\n if (payment.payload.challengeId !== expected.challengeId) {\n throw new Error('[suimpp/x402] Payment is bound to a different challenge');\n }\n\n const txBytes = fromBase64(payment.payload.txBytes);\n const tx = Transaction.from(txBytes);\n const data = tx.getData();\n\n if (\n !data.sender ||\n normalizeSuiAddress(data.sender) !==\n normalizeSuiAddress(payment.payload.senderAddress)\n ) {\n throw new Error('[suimpp/x402] Transaction sender mismatch');\n }\n\n // Gasless shape: zero price, no gas payment objects.\n const gas = data.gasData;\n if (BigInt(gas.price ?? 1) !== 0n || (gas.payment?.length ?? 0) > 0) {\n throw new Error('[suimpp/x402] Transaction is not a gasless transfer');\n }\n\n // ValidDuring nonce = the on-chain challenge binding.\n const expiration = data.expiration;\n const validDuring =\n expiration && 'ValidDuring' in expiration ? expiration.ValidDuring : null;\n if (!validDuring) {\n throw new Error(\n '[suimpp/x402] Transaction must use ValidDuring expiration',\n );\n }\n const expectedNonce = challengeNonce(expected.challengeId);\n if (Number(validDuring.nonce) !== expectedNonce) {\n throw new Error(\n '[suimpp/x402] ValidDuring nonce does not bind to the challenge',\n );\n }\n\n // Command allowlist: only the gasless transfer trio on the FRAMEWORK\n // package (0x2) may appear, and at least one send_funds must pay the\n // expected recipient. The package check is load-bearing — a malicious\n // `0xEVIL::balance::send_funds` must NOT pass as `0x2::balance::send_funds`.\n const normalizedRecipient = normalizeSuiAddress(expected.recipient);\n let paysRecipient = false;\n for (const command of data.commands) {\n if (!('MoveCall' in command) || !command.MoveCall) {\n throw new Error('[suimpp/x402] Only MoveCall commands are permitted');\n }\n const call = command.MoveCall;\n const fn = `${call.module}::${call.function}`;\n if (normalizeSuiAddress(call.package) !== FRAMEWORK_PACKAGE) {\n throw new Error(\n `[suimpp/x402] Non-framework package call: ${call.package}::${fn}`,\n );\n }\n if (!ALLOWED_FNS.has(fn)) {\n throw new Error(`[suimpp/x402] Disallowed Move call: 0x2::${fn}`);\n }\n if (SEND_FUNDS_FNS.has(fn)) {\n const recipientArg = call.arguments[call.arguments.length - 1];\n if (\n recipientArg &&\n typeof recipientArg === 'object' &&\n 'Input' in recipientArg\n ) {\n const input = data.inputs[recipientArg.Input as number];\n if (input && 'Pure' in input && input.Pure?.bytes) {\n const addr = `0x${toHex(fromBase64(input.Pure.bytes))}`;\n if (normalizeSuiAddress(addr) === normalizedRecipient) {\n paysRecipient = true;\n }\n }\n }\n }\n }\n if (!paysRecipient) {\n throw new Error(\n '[suimpp/x402] Transaction does not pay the expected recipient',\n );\n }\n\n return { txBytes, nonce: expectedNonce };\n}\n\nexport interface SettleX402Options {\n payment: X402PaymentPayload;\n client: ClientWithCoreApi;\n /** Digest replay store — shared with the legacy dialect. */\n store: DigestStore;\n expected: VerifyX402Options['expected'];\n onPayment?: (report: PaymentReport) => void;\n}\n\n/**\n * Settle-then-serve: verify structurally, submit the client-signed bytes,\n * confirm the on-chain balance change, record the digest. Throws (and the\n * host returns 402) without serving if anything fails — and because the\n * host only calls the upstream AFTER this resolves, a failed upstream can\n * void/refund before any service value is lost.\n */\nexport async function settleX402Payment(\n options: SettleX402Options,\n): Promise<X402SettleResponse> {\n const { payment, client, store, expected } = options;\n const { txBytes } = verifyX402Payment({ payment, expected });\n\n const result = await withRetry(\n () =>\n client.core.executeTransaction({\n transaction: txBytes,\n signatures: [payment.payload.senderSignature],\n include: { balanceChanges: true, transaction: true },\n }),\n { attempts: 3, baseDelayMs: 500 },\n );\n\n const resolved = result.Transaction ?? result.FailedTransaction;\n if (!resolved?.status.success) {\n throw new Error(\n `[suimpp/x402] Settlement failed on-chain: ${\n resolved?.status.error?.message ?? 'unknown'\n }`,\n );\n }\n\n const digest = resolved.digest;\n if (await store.has(digest)) {\n throw new Error(`[suimpp/x402] Digest already used: ${digest}`);\n }\n\n // Post-settle enforcement (same checks as the legacy dialect).\n const normalizedRecipient = normalizeSuiAddress(expected.recipient);\n const paid = resolved.balanceChanges.find(\n (bc) =>\n bc.coinType === expected.currency.type &&\n normalizeSuiAddress(bc.address) === normalizedRecipient &&\n BigInt(bc.amount) > 0n,\n );\n const requestedRaw = parseAmountToRaw(\n expected.amount,\n expected.currency.decimals,\n );\n if (!paid || BigInt(paid.amount) < requestedRaw) {\n throw new Error('[suimpp/x402] Settled amount does not satisfy the terms');\n }\n\n await store.set(digest);\n\n const report: PaymentReport = {\n digest,\n sender: payment.payload.senderAddress,\n recipient: expected.recipient,\n amount: expected.amount,\n currency: expected.currency.type,\n network: expected.network,\n };\n if (options.onPayment) {\n try {\n options.onPayment(report);\n } catch {}\n }\n\n return {\n success: true,\n network: payment.network,\n transaction: digest,\n payer: payment.payload.senderAddress,\n };\n}\n\nexport function encodeX402Response(response: X402SettleResponse): string {\n return toBase64(new TextEncoder().encode(JSON.stringify(response)));\n}\n"],"mappings":";;;;;;;;;;;;;;AASO,IAAM,gBACX;AAEK,IAAM,wBACX;AAEK,IAAM,OAAO;EAClB,MAAM;EACN,UAAU;AACZ;AAEO,IAAM,eAAe;EAC1B,MAAM;EACN,UAAU;AACZ;ACHA,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAKtB,IAAM,sBAAN,MAAiD;EAC9C,QAAA,oBAAY,IAAA;EACH;EAEjB,YAAY,QAAQ,gBAAgB;AAClC,SAAK,QAAQ;AACb,QAAI,OAAO,WAAW,gBAAgB,YAAY;AAChD,YAAM,QAAQ,YAAY,MAAM,KAAK,MAAA,GAAS,oBAAoB;AAClE,UAAI,OAAO,UAAU,YAAY,WAAW,MAAA,OAAa,MAAA;IAC3D;EACF;EAEA,MAAM,IAAI,QAAkC;AAC1C,UAAM,YAAY,KAAK,MAAM,IAAI,MAAM;AACvC,QAAI,cAAc,OAAW,QAAO;AACpC,QAAI,KAAK,IAAA,IAAQ,WAAW;AAC1B,WAAK,MAAM,OAAO,MAAM;AACxB,aAAO;IACT;AACA,WAAO;EACT;EAEA,MAAM,IAAI,QAA+B;AACvC,SAAK,MAAM,IAAI,QAAQ,KAAK,IAAA,IAAQ,KAAK,KAAK;EAChD;EAEQ,QAAc;AACpB,UAAM,MAAM,KAAK,IAAA;AACjB,eAAW,CAAC,QAAQ,SAAS,KAAK,KAAK,MAAM,QAAA,GAAW;AACtD,UAAI,MAAM,UAAW,MAAK,MAAM,OAAO,MAAM;IAC/C;EACF;AACF;ACtDO,SAAS,iBAAiB,QAAgB,UAA0B;AACzE,QAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,IAAI,OAAO,MAAM,GAAG;AACjD,QAAM,aAAa,KAAK,OAAO,UAAU,GA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,QAAQ,QAAQ,QAAQ;IACxB,WAAW,SAAS;IACpB,QAAQ,SAAS;IACjB,UAAU,SAAS,SAAS;IAC5B,SAAS,SAAS;EAAA;AAEpB,MAAI,QAAQ,WAAW;AACrB,QAAI;AACF,cAAQ,UAAU,MAAM;IAC1B,QAAQ;IAAC;EACX;AAEA,SAAO;IACL,SAAS;IACT,SAAS,QAAQ;IACjB,aAAa;IACb,OAAO,QAAQ,QAAQ;EAAA;AAE3B;AAEO,SAAS,mBAAmB,UAAsC;AACvE,SAAO,SAAS,IAAI,YAAA,EAAc,OAAO,KAAK,UAAU,QAAQ,CAAC,CAAC;AACpE;","names":[]}
|
|
@@ -171,12 +171,11 @@ import {
|
|
|
171
171
|
processEndpoint,
|
|
172
172
|
processFlattenRoutes,
|
|
173
173
|
restituteMsafeFastRouterSwapParams
|
|
174
|
-
} from "./chunk-
|
|
175
|
-
import "./chunk-
|
|
176
|
-
import "./chunk-
|
|
177
|
-
import "./chunk-
|
|
178
|
-
import "./chunk-
|
|
179
|
-
import "./chunk-SUSL7H4U.js";
|
|
174
|
+
} from "./chunk-SKQLFHJJ.js";
|
|
175
|
+
import "./chunk-R6QER65C.js";
|
|
176
|
+
import "./chunk-JEIOQF6Q.js";
|
|
177
|
+
import "./chunk-5MAY6SK7.js";
|
|
178
|
+
import "./chunk-D3DUYZYR.js";
|
|
180
179
|
import "./chunk-BLLELIG6.js";
|
|
181
180
|
export {
|
|
182
181
|
AFSUI,
|
|
@@ -351,4 +350,4 @@ export {
|
|
|
351
350
|
processFlattenRoutes,
|
|
352
351
|
restituteMsafeFastRouterSwapParams
|
|
353
352
|
};
|
|
354
|
-
//# sourceMappingURL=dist-
|
|
353
|
+
//# sourceMappingURL=dist-MQVAPHMQ.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
randomBytes,
|
|
15
15
|
toBase64,
|
|
16
16
|
toHex
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-D3DUYZYR.js";
|
|
18
18
|
import {
|
|
19
19
|
__commonJS,
|
|
20
20
|
__toESM
|
|
@@ -1081,4 +1081,4 @@ export {
|
|
|
1081
1081
|
jwtToAddress2 as jwtToAddress,
|
|
1082
1082
|
poseidonHash
|
|
1083
1083
|
};
|
|
1084
|
-
//# sourceMappingURL=esm-
|
|
1084
|
+
//# sourceMappingURL=esm-4JYJHL2T.js.map
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
SuiGrpcClient,
|
|
6
6
|
isSuiGrpcClient,
|
|
7
7
|
types_exports
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-R6QER65C.js";
|
|
9
|
+
import "./chunk-5MAY6SK7.js";
|
|
10
|
+
import "./chunk-D3DUYZYR.js";
|
|
11
11
|
import "./chunk-BLLELIG6.js";
|
|
12
12
|
export {
|
|
13
13
|
GrpcCoreClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
SuiGrpcClient,
|
|
17
17
|
isSuiGrpcClient
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=grpc-
|
|
19
|
+
//# sourceMappingURL=grpc-SHHHADW4.js.map
|