@inflowpayai/x402-buyer 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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/_foundation-bridge.ts","../src/signer.ts","../src/inflow-client.ts","../src/decode-evm-key.ts","../src/decode-solana-key.ts"],"names":["EXTENSION_REGISTRY"],"mappings":";;;;;;;;AAQO,IAAM,uBAAA,GAAN,cAAsC,KAAA,CAAM;AAAA;AAAA,EAExC,UAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,WAAA,CAAY,YAAoB,MAAA,EAA2B;AACzD,IAAA,KAAA,CAAM,CAAA,SAAA,EAAY,UAAU,CAAA,eAAA,EAAkB,MAAM,CAAA,gBAAA,CAAkB,CAAA;AACtE,IAAA,IAAA,CAAK,IAAA,GAAO,yBAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF;AAOO,IAAM,0BAAA,GAAN,cAAyC,KAAA,CAAM;AAAA;AAAA,EAE3C,UAAA;AAAA,EAET,YAAY,UAAA,EAAoB;AAC9B,IAAA,KAAA,CAAM,CAAA,SAAA,EAAY,UAAU,CAAA,oBAAA,CAAsB,CAAA;AAClD,IAAA,IAAA,CAAK,IAAA,GAAO,4BAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AACF;AAMO,IAAM,wBAAA,GAAN,cAAuC,KAAA,CAAM;AAAA;AAAA,EAEzC,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,WAAA,CAAY,YAAoB,SAAA,EAAmB;AACjD,IAAA,KAAA,CAAM,YAAY,UAAU,CAAA,mBAAA,EAAsB,MAAA,CAAO,SAAS,CAAC,CAAA,EAAA,CAAI,CAAA;AACvE,IAAA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,OAAO,OAAA,KAAY,QAAA,IAAY,CAAC,MAAA,CAAO,SAAA,CAAU,OAAO,CAAA,IAAK,OAAA,GAAU,CAAA,IAAK,OAAA,GAAU,GAAA,EAAK;AAC7F,MAAA,MAAM,IAAI,yBAAA,CAA0B,CAAA,4BAAA,EAA+B,CAAA,CAAE,QAAA,EAAU,CAAA,4BAAA,CAA8B,CAAA;AAAA,IAC/G;AACA,IAAA,KAAA,CAAM,CAAC,CAAA,GAAI,OAAA;AAAA,EACb;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,aAAa,OAAA,EAA6B;AACjD,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,IAAA,CAAK,OAAO,OAAO,CAAA;AAAA,EAC/B,SAAS,GAAA,EAAK;AACZ,IAAA,MAAM,IAAI,yBAAA,CAA0B,CAAA,sBAAA,EAAyB,GAAA,YAAe,KAAA,GAAQ,IAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA,CAAE,CAAA;AAAA,EACjH;AACA,EAAA,IAAI,OAAA,CAAQ,WAAW,eAAA,EAAiB;AACtC,IAAA,MAAM,IAAI,yBAAA;AAAA,MACR,CAAA,kBAAA,EAAqB,QAAQ,MAAA,CAAO,QAAA,EAAU,CAAA,iBAAA,EAAoB,eAAA,CAAgB,UAAU,CAAA;AAAA,KAC9F;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type { TransactionStatus } from './types.js';\n\n/**\n * Thrown by `awaitPayload` when the server moves the approval out of `'INITIATED'` without producing an\n * `encodedPayload` — the server has decided not to sign (insufficient funds, user-rejected, internal error, etc.). The\n * terminal `status` string is surfaced verbatim so callers can branch on it without the SDK having to enumerate every\n * server-side failure state.\n */\nexport class X402ApprovalFailedError extends Error {\n /** The approval id the server returned from `POST /v1/transactions/x402`. */\n readonly approvalId: string;\n /** Terminal status reported by the server. */\n readonly status: TransactionStatus;\n\n /**\n * @param approvalId - Server-issued approval id.\n * @param status - Terminal status string from the polling response.\n */\n constructor(approvalId: string, status: TransactionStatus) {\n super(`Approval ${approvalId} terminated as ${status} with no payload`);\n this.name = 'X402ApprovalFailedError';\n this.approvalId = approvalId;\n this.status = status;\n }\n}\n\n/**\n * Thrown by `awaitPayload` when `cancel()` is called on the same `PreparedPayment`. The cancel is fire-and-forget\n * against the server; the SDK exits the polling loop immediately and never returns the partially-fetched state to the\n * caller.\n */\nexport class X402ApprovalCancelledError extends Error {\n /** The approval id the server returned from `POST /v1/transactions/x402`. */\n readonly approvalId: string;\n\n constructor(approvalId: string) {\n super(`Approval ${approvalId} cancelled by caller`);\n this.name = 'X402ApprovalCancelledError';\n this.approvalId = approvalId;\n }\n}\n\n/**\n * Thrown by `awaitPayload` when wall-clock exceeds `timeoutMs` or the caller's `signal` aborts before the server has\n * signed.\n */\nexport class X402ApprovalTimeoutError extends Error {\n /** The approval id the server returned from `POST /v1/transactions/x402`. */\n readonly approvalId: string;\n /** Effective timeout in milliseconds. */\n readonly timeoutMs: number;\n\n /**\n * @param approvalId - Server-issued approval id.\n * @param timeoutMs - The configured timeout that elapsed.\n */\n constructor(approvalId: string, timeoutMs: number) {\n super(`Approval ${approvalId} not signed within ${String(timeoutMs)}ms`);\n this.name = 'X402ApprovalTimeoutError';\n this.approvalId = approvalId;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Thrown by `prepare()` / `sign()` when `SignOptions.paymentId` does not satisfy the `payment-identifier` extension's\n * format rules (16–128 chars, `^[a-zA-Z0-9_-]+$`). Surfaced client-side before any server round trip.\n */\nexport class X402PaymentIdFormatError extends Error {\n /** The offending input. */\n readonly input: string;\n\n /** @param input - The {@link SignOptions.paymentId} value that failed validation. */\n constructor(input: string) {\n // JSON.stringify wraps in double quotes and escapes embedded quotes / backslashes / control chars, so an input\n // like `foo\"bar` produces an unambiguous, copy-pasteable message instead of `Invalid paymentId \"foo\"bar\";...`.\n super(`Invalid paymentId ${JSON.stringify(input)}; must be 16-128 chars matching ^[a-zA-Z0-9_-]+$`);\n this.name = 'X402PaymentIdFormatError';\n this.input = input;\n }\n}\n\n/**\n * Thrown by {@link InflowClient.prepareInflowPayment} when the caller asks the two-phase flow for a requirement the\n * InFlow signer cannot sign. The two-phase flow only exists for InFlow-signed requirements; foundation-signed schemes\n * have no equivalent.\n */\nexport class X402AdapterRoutingError extends Error {\n /** Scheme of the requirement the adapter could not route. */\n readonly scheme: string;\n /** Network of the requirement the adapter could not route. */\n readonly network: string;\n\n /**\n * @param scheme - Scheme of the offending requirement.\n * @param network - Network of the offending requirement.\n */\n constructor(scheme: string, network: string) {\n super(\n `InflowClient cannot route requirement (scheme: \"${scheme}\", network: \"${network}\"): ` +\n `not in the InFlow buyer capability cache and no two-phase flow exists for foundation-signed schemes`,\n );\n this.name = 'X402AdapterRoutingError';\n this.scheme = scheme;\n this.network = network;\n }\n}\n\n/**\n * Thrown by `parseEvmPrivateKey` when the input cannot be normalized to a 32-byte secp256k1 secret. The accepted input\n * forms are `0x`-prefixed hex, bare hex, and InFlow's Java `Hex.encodeHexString(BigInteger.toByteArray())` seed\n * (including the 33-byte sign-byte and sub-32-byte leading-zero-stripped shapes).\n *\n * The raw input is intentionally **not** preserved on the error: a decoding failure can be the user pasting a real key\n * in the wrong encoding (e.g. a Solana base58 secret into the EVM decoder), so the offending value is treated as\n * potential cryptographic material. Use {@link X402InvalidEvmKeyError.reason} for diagnostics; never log the input.\n */\nexport class X402InvalidEvmKeyError extends Error {\n /** Why the input failed validation. Never contains key bytes. */\n readonly reason: string;\n\n /**\n * @param reason - Short explanation appended to the error message. Must not contain the raw input — produce a length\n * / shape description instead (e.g. `'expected 32 bytes, got 31'`).\n */\n constructor(reason: string) {\n super(`Invalid EVM private key: ${reason}`);\n this.name = 'X402InvalidEvmKeyError';\n this.reason = reason;\n }\n}\n\n/**\n * Thrown by `decodeSolanaSecret` when the input cannot be decoded to a 64-byte Ed25519 secret key. Accepted input forms\n * are a base58 string (matches InFlow's `SolanaClient.Account.getSeed()` and Phantom's export) or a JSON byte array\n * (matches `solana-keygen`'s output file).\n *\n * The raw input is intentionally **not** preserved on the error: a decoding failure can be the user pasting a real key\n * in the wrong encoding (e.g. a base58 secret with one character mistyped), so the offending value is treated as\n * potential cryptographic material. Use {@link X402InvalidSolanaKeyError.reason} for diagnostics; never log the input.\n */\nexport class X402InvalidSolanaKeyError extends Error {\n /** Why the input failed validation. Never contains key bytes. */\n readonly reason: string;\n\n /**\n * @param reason - Short explanation appended to the error message. Must not contain the raw input — produce a length\n * / shape description instead (e.g. `'expected 64 bytes, got 32'`).\n */\n constructor(reason: string) {\n super(\n `Invalid Solana private key: ${reason}. ` +\n 'Expected a 64-byte Ed25519 secret key, supplied either as a base58 string ' +\n '(matches InFlow SolanaClient.Account.getSeed()) or a JSON byte array ' +\n '(matches solana-keygen).',\n );\n this.name = 'X402InvalidSolanaKeyError';\n this.reason = reason;\n }\n}\n","import type {\n PaymentPayload as FoundationPaymentPayload,\n PaymentRequirements as FoundationPaymentRequirements,\n} from '@x402/core/types';\nimport type { InflowPaymentPayload, PaymentRequirements } from '@inflowpayai/x402';\n\n/**\n * Single, documented type boundary between InFlow's widened wire types and the foundation's narrower ones. Concentrated\n * here so additions to the foundation shape upstream surface in one place rather than at scattered cast sites.\n *\n * Type asymmetry (runtime-equivalent in both directions; the casts encode that):\n *\n * - **InFlow → foundation is the lossy direction.** InFlow's `PaymentRequirements.extra` is optional; the foundation's is\n * required. InFlow's `PaymentRequirements.network` is the wider `string`; the foundation's is the CAIP-2 template\n * literal `${string}:${string}`. Going InFlow → foundation requires `as unknown as` because TS can't see that an\n * absent `extra` is the empty record at runtime, or that an InFlow `network: string` is always CAIP-2 shaped in\n * practice.\n * - **Foundation → InFlow is the safe direction** and the implicit assignment compiles without a cast: foundation's\n * required `extra` is assignable to InFlow's optional one, and `${string}:${string}` is assignable to `string`.\n * `fromFoundationRequirements` exists only so the call site at `inflow-client.ts:createPaymentPayload` reads\n * symmetrically against the InFlow → foundation direction.\n *\n * Per AGENTS.md §Conventions: `as unknown as` lives at documented type boundaries; this module is the documented\n * boundary for the buyer side.\n *\n * @internal\n */\n\n/** Foundation `PaymentRequirements[]` → InFlow `readonly PaymentRequirements[]`. Safe direction; no cast needed. */\nexport function fromFoundationRequirements(\n r: readonly FoundationPaymentRequirements[],\n): readonly PaymentRequirements[] {\n return r;\n}\n\n/** InFlow `PaymentPayload` → foundation `PaymentPayload`. Lossy direction; safe under V2 wire shape. */\nexport function toFoundationPayload(p: InflowPaymentPayload): FoundationPaymentPayload {\n return p as unknown as FoundationPaymentPayload;\n}\n","import { InflowHttpClient } from '@inflowpayai/x402';\nimport type {\n InflowPaymentPayload,\n PaymentRequirements,\n PaymentScheme,\n X402BuyerSupportedResponse,\n} from '@inflowpayai/x402';\nimport { EXTENSION_REGISTRY, validatePaymentId } from '@inflowpayai/x402/extensions';\n\nimport {\n X402ApprovalCancelledError,\n X402ApprovalFailedError,\n X402ApprovalTimeoutError,\n X402PaymentIdFormatError,\n} from './errors.js';\nimport type {\n ApprovalStatus,\n EncodedPayment,\n InflowSigner,\n PreparedPayment,\n SignerOptions,\n SignOptions,\n SigningContext,\n TransactionStatus,\n X402PayloadResponse,\n X402TransactionResponse,\n} from './types.js';\n\nconst SUPPORTED_PATH = '/v1/transactions/x402-supported';\nconst TRANSACTIONS_PATH = '/v1/transactions/x402';\nconst APPROVAL_CANCEL_PATH = (id: string): string => `/v1/approvals/${id}/cancel`;\nconst TRANSACTION_X402_PATH = (id: string): string => `/v1/transactions/${id}/x402`;\n\nconst CACHE_TTL_MS = 60 * 60 * 1000;\nconst DEFAULT_POLL_INTERVAL_MS = 5000;\nconst DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;\nconst DEFAULT_PREFER: readonly PaymentScheme[] = ['balance', 'exact'];\nconst APPROVAL_APPROVED: ApprovalStatus = 'APPROVED';\n\n/**\n * Async factory for {@link InflowSigner}. Primes the buyer-supported cache before resolving so `supports()` is honestly\n * synchronous. Implementation detail of {@link createInflowClient}; not re-exported from the package barrel.\n *\n * @internal\n */\nexport async function createInflowSigner(options: SignerOptions): Promise<InflowSigner> {\n const http = new InflowHttpClient(options);\n const prefer = options.prefer ?? DEFAULT_PREFER;\n const extensionsHandled: ReadonlySet<string> = new Set(EXTENSION_REGISTRY.keys());\n\n interface CacheEntry<T> {\n value: T | undefined;\n expiresAt: number;\n inFlight: Promise<T> | undefined;\n }\n const supportedCache: CacheEntry<X402BuyerSupportedResponse> = {\n value: undefined,\n expiresAt: 0,\n inFlight: undefined,\n };\n\n async function fetchSupported(): Promise<X402BuyerSupportedResponse> {\n const fresh = await http.get<X402BuyerSupportedResponse>(SUPPORTED_PATH);\n supportedCache.value = fresh;\n supportedCache.expiresAt = Date.now() + CACHE_TTL_MS;\n return fresh;\n }\n\n function getSupported(): Promise<X402BuyerSupportedResponse> {\n if (supportedCache.value !== undefined && Date.now() < supportedCache.expiresAt) {\n return Promise.resolve(supportedCache.value);\n }\n if (supportedCache.inFlight !== undefined) return supportedCache.inFlight;\n const inFlight = fetchSupported().finally(() => {\n supportedCache.inFlight = undefined;\n });\n supportedCache.inFlight = inFlight;\n return inFlight;\n }\n\n /**\n * Reissues the fetch and atomically swaps in the new value on success. The previously cached value remains live until\n * the refresh resolves, so a transient failure does not flip `supports()` to false.\n */\n function refreshSupported(): Promise<X402BuyerSupportedResponse> {\n if (supportedCache.inFlight !== undefined) return supportedCache.inFlight;\n const inFlight = fetchSupported().finally(() => {\n supportedCache.inFlight = undefined;\n });\n supportedCache.inFlight = inFlight;\n return inFlight;\n }\n\n function supports(requirement: PaymentRequirements): boolean {\n const cached = supportedCache.value;\n if (cached === undefined) return false;\n return cached.kinds.some((k) => k.scheme === requirement.scheme && k.network === requirement.network);\n }\n\n async function prepare(\n requirement: PaymentRequirements,\n context: SigningContext,\n callOptions?: SignOptions,\n ): Promise<PreparedPayment> {\n const merged = { ...options.signDefaults, ...callOptions };\n if (merged.paymentId !== undefined && !validatePaymentId(merged.paymentId)) {\n throw new X402PaymentIdFormatError(merged.paymentId);\n }\n const body = {\n accept: requirement,\n resource: context.resource,\n x402Version: context.x402Version,\n ...(merged.paymentId !== undefined ? { remotePaymentId: merged.paymentId } : {}),\n };\n // Retries disabled: `POST /v1/transactions/x402` is idempotent only when\n // the caller supplies a `remotePaymentId` (server-side `putIfAbsent`).\n // Without that, a transparent 5xx retry would create a second Approval\n // and Transaction while the first one ages out at the 15-min expiry.\n // The buyer signer's polling loop is itself the retry mechanism for the\n // approval-window patience; transport-level retry here would be unsafe.\n const created = await http.post<X402TransactionResponse>(TRANSACTIONS_PATH, body, {\n retries: 0,\n ...(merged.signal !== undefined ? { signal: merged.signal } : {}),\n });\n return makePreparedPayment(http, created, merged);\n }\n\n async function sign(\n requirement: PaymentRequirements,\n context: SigningContext,\n callOptions?: SignOptions,\n ): Promise<EncodedPayment> {\n const prepared = await prepare(requirement, context, callOptions);\n try {\n return await prepared.awaitPayload(callOptions);\n } catch (err) {\n // Fire-and-forget cancel; never let it mask the original error.\n void prepared.cancel();\n throw err;\n }\n }\n\n // Prime the supported cache before returning so `supports()` is honest.\n await fetchSupported();\n\n const signer: InflowSigner = {\n prefer,\n extensionsHandled,\n supports,\n sign,\n prepare,\n ready: () => Promise.resolve(),\n getSupported,\n refreshSupported,\n };\n return signer;\n}\n\n/**\n * Construct the {@link PreparedPayment} returned by `prepare()`. The `awaitPayload` polling loop is created lazily on\n * first call; concurrent callers share the same in-flight promise.\n */\nfunction makePreparedPayment(\n http: InflowHttpClient,\n created: X402TransactionResponse,\n preparedOptions: SignOptions,\n): PreparedPayment {\n let awaitInFlight: Promise<EncodedPayment> | undefined;\n let cancelled = false;\n // Signal fired by `cancel()` to break the polling loop immediately.\n const cancelController = new AbortController();\n\n function buildEncodedPayment(encodedPayload: string, paymentPayload: InflowPaymentPayload): EncodedPayment {\n return { encodedPayload, paymentPayload, transactionId: created.transactionId };\n }\n\n async function pollOnce(signal?: AbortSignal): Promise<X402PayloadResponse> {\n return http.get<X402PayloadResponse>(TRANSACTION_X402_PATH(created.transactionId), {\n retries: 0,\n ...(signal !== undefined ? { signal } : {}),\n });\n }\n\n async function awaitPayload(callOptions?: SignOptions): Promise<EncodedPayment> {\n if (cancelled) {\n throw new X402ApprovalCancelledError(created.approvalId);\n }\n if (awaitInFlight !== undefined) return awaitInFlight;\n const merged: SignOptions = { ...preparedOptions, ...callOptions };\n const pollIntervalMs = merged.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = merged.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const callerSignal = merged.signal;\n // The poll loop honours an abort from either the caller or `cancel()`.\n const signal = composeSignals(callerSignal, cancelController.signal);\n const promise = runPollLoop({\n pollOnce,\n buildEncodedPayment,\n approvalId: created.approvalId,\n pollIntervalMs,\n timeoutMs,\n signal,\n // Short-circuit for the synchronous-approval path: when the server\n // signed during `POST /v1/transactions/x402` (approvalStatus = APPROVED),\n // the very first GET should already have the payload; the loop is\n // still robust to a missed first poll.\n createdApprovalStatus: created.approvalStatus,\n }).catch((err: unknown) => {\n if (cancelled) {\n throw new X402ApprovalCancelledError(created.approvalId);\n }\n throw err;\n });\n awaitInFlight = promise;\n promise.catch(() => {\n // Reset in-flight on rejection so a retry re-enters the loop instead\n // of replaying the same rejection.\n awaitInFlight = undefined;\n });\n return promise;\n }\n\n async function statusFn(): Promise<TransactionStatus> {\n const payload = await pollOnce();\n return payload.status;\n }\n\n async function cancel(): Promise<void> {\n // Client-side cancel: flip the flag and abort the poll loop *before*\n // touching the network. Any in-flight `awaitPayload()` rejects with\n // `X402ApprovalCancelledError` immediately. The server cancel is\n // fire-and-forget — errors never surface to the caller.\n cancelled = true;\n cancelController.abort();\n try {\n await http.post(APPROVAL_CANCEL_PATH(created.approvalId), undefined, { retries: 0 });\n } catch {\n // swallow\n }\n }\n\n return {\n transactionId: created.transactionId,\n approvalId: created.approvalId,\n awaitPayload,\n status: statusFn,\n cancel,\n };\n}\n\n/**\n * Single `AbortSignal` fired when any of the inputs aborts. Uses native `AbortSignal.any` on Node 20.3+; falls back to\n * a manual fan-in otherwise.\n */\nfunction composeSignals(...signals: (AbortSignal | undefined)[]): AbortSignal {\n const live = signals.filter((s): s is AbortSignal => s !== undefined);\n // Fast path for the single-signal case so the caller observes that signal's `.reason` unchanged. Avoids the\n // `live[0]!` non-null assertion AGENTS.md §Conventions prohibits — under `noUncheckedIndexedAccess`, indexed\n // access on the filtered array still types as `AbortSignal | undefined`.\n const [first, ...rest] = live;\n if (first !== undefined && rest.length === 0) return first;\n // Prefer native `AbortSignal.any` (Node 20.3+); fall back to a manual fan-in. The single-level cast lets the\n // feature detect typecheck without reaching for `as unknown as`.\n const anyFn = (AbortSignal as { any?: (s: AbortSignal[]) => AbortSignal }).any;\n if (typeof anyFn === 'function') return anyFn(live);\n // Manual fan-in. When any input aborts, fire the controller and remove the listeners we added to the siblings —\n // otherwise the siblings hold references to a closure that's no longer useful, and a long-lived composed signal\n // would accumulate dead listeners on long-lived parents.\n const controller = new AbortController();\n const cleanups: Array<() => void> = [];\n const fire = (reason: unknown): void => {\n controller.abort(reason);\n for (const c of cleanups) c();\n };\n for (const s of live) {\n if (s.aborted) {\n fire(s.reason);\n return controller.signal;\n }\n const handler = (): void => fire(s.reason);\n s.addEventListener('abort', handler, { once: true });\n cleanups.push(() => s.removeEventListener('abort', handler));\n }\n return controller.signal;\n}\n\n/**\n * Poll loop core. Inspects `encodedPayload` presence first, then status: payload present → signed; status in\n * {@link TERMINAL_FAILURE_STATUSES} → failed; everything else → pending (including non-terminal statuses racing the\n * server's `encodedPayload` write). 5xx and network errors during a single poll are swallowed; the loop is itself the\n * retry mechanism.\n */\nasync function runPollLoop(input: {\n pollOnce: (signal?: AbortSignal) => Promise<X402PayloadResponse>;\n buildEncodedPayment: (encodedPayload: string, paymentPayload: InflowPaymentPayload) => EncodedPayment;\n approvalId: string;\n pollIntervalMs: number;\n timeoutMs: number;\n signal?: AbortSignal;\n createdApprovalStatus: ApprovalStatus;\n}): Promise<EncodedPayment> {\n const { pollOnce, buildEncodedPayment, approvalId, pollIntervalMs, timeoutMs, signal } = input;\n const startedAt = Date.now();\n const deadline = startedAt + timeoutMs;\n const isAborted = (): boolean => signal !== undefined && signal.aborted;\n\n if (isAborted()) {\n throw new X402ApprovalTimeoutError(approvalId, timeoutMs);\n }\n\n // Synchronous-approval path: skip the first sleep.\n let firstPoll = input.createdApprovalStatus === APPROVAL_APPROVED;\n\n while (Date.now() < deadline) {\n if (isAborted()) {\n throw new X402ApprovalTimeoutError(approvalId, timeoutMs);\n }\n let response: X402PayloadResponse | undefined;\n try {\n // Thread the caller signal so an in-flight GET aborts immediately on\n // caller cancel instead of running out the HTTP client's 30s default.\n response = await pollOnce(signal);\n } catch (err) {\n // If the abort fired, propagate as timeout/abort error instead of\n // silently sleeping and re-polling.\n if (signal !== undefined && signal.aborted) {\n throw new X402ApprovalTimeoutError(approvalId, timeoutMs);\n }\n void err;\n // 5xx / network error → swallow; sleep and retry.\n response = undefined;\n }\n if (response !== undefined) {\n const settled = evaluatePoll(response);\n if (settled === 'pending') {\n // Still INITIATED, or transitioned to a non-terminal/success state\n // whose `encodedPayload` write hasn't landed yet. Sleep and retry.\n } else if (settled === 'failed') {\n throw new X402ApprovalFailedError(approvalId, response.status);\n } else {\n // settled === 'signed' → response.encodedPayload && paymentPayload present.\n return buildEncodedPayment(response.encodedPayload as string, response.paymentPayload as InflowPaymentPayload);\n }\n }\n if (firstPoll) {\n firstPoll = false;\n continue;\n }\n await sleep(pollIntervalMs, signal);\n }\n throw new X402ApprovalTimeoutError(approvalId, timeoutMs);\n}\n\n/**\n * Terminal failure statuses produced by the InFlow `TransactionStatus` enum (see `inflow-server`\n * `datastore/local/TransactionStatus.java`). On any of these the poll loop rejects with `X402ApprovalFailedError`\n * without waiting for a payload — the payment will never settle.\n *\n * Any other status (`PENDING`, `PROCESSING`, success states racing the `encodedPayload` write) is treated as `pending`\n * so transient gaps between status flip and payload write don't poison the buyer.\n */\nconst TERMINAL_FAILURE_STATUSES: ReadonlySet<string> = new Set([\n 'DECLINED',\n 'EXPIRED',\n 'GENERAL_ERROR',\n 'INSUFFICIENT_FUNDS',\n]);\n\nfunction evaluatePoll(response: X402PayloadResponse): 'pending' | 'signed' | 'failed' {\n if (response.encodedPayload != null && response.paymentPayload != null) {\n return 'signed';\n }\n if (TERMINAL_FAILURE_STATUSES.has(response.status)) {\n return 'failed';\n }\n return 'pending';\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve) => {\n const timer = setTimeout(resolve, ms);\n if (signal !== undefined) {\n const onAbort = (): void => {\n clearTimeout(timer);\n resolve();\n };\n if (signal.aborted) {\n clearTimeout(timer);\n resolve();\n } else {\n signal.addEventListener('abort', onAbort, { once: true });\n }\n }\n });\n}\n","import { x402Client } from '@x402/core/client';\nimport type {\n AfterPaymentCreationHook,\n BeforePaymentCreationHook,\n ClientExtension,\n OnPaymentCreationFailureHook,\n OnPaymentResponseHook,\n PaymentPolicy,\n} from '@x402/core/client';\nimport type { Network, PaymentPayload, PaymentRequired, SchemeNetworkClient } from '@x402/core/types';\n\nimport type { InflowPaymentPayload, PaymentRequirements, PaymentScheme } from '@inflowpayai/x402';\nimport { EXTENSION_REGISTRY, getExtension, setExtension, type SignContext } from '@inflowpayai/x402/extensions';\n\nimport { X402AdapterRoutingError } from './errors.js';\nimport { fromFoundationRequirements, toFoundationPayload } from './_foundation-bridge.js';\nimport { createInflowSigner } from './signer.js';\nimport type { InflowSigner, PreparedPayment, SignerOptions, SignOptions, SigningContext } from './types.js';\n\n/**\n * Subclass of `@x402/core`'s `x402Client` that adds the InFlow MPC signing branch and the two-phase\n * {@link InflowClient.prepareInflowPayment} flow. Construct via {@link createInflowClient}.\n */\nexport class InflowClient extends x402Client {\n /**\n * The InFlow-signed branch of the routing decision. Kept private — callers compose by passing the {@link InflowClient}\n * to `x402HTTPClient` (and to `registerExactEvmScheme` / `registerExactSvmScheme` for foundation-signed networks).\n */\n private readonly inflowSigner: InflowSigner;\n /**\n * Ordered scheme preference used when picking among multiple InFlow-acceptable requirements. Sourced from the InFlow\n * signer at construction so the buyer's intent (`prefer: ['balance', 'exact']` by default) survives across the\n * override.\n */\n private readonly preferOrder: readonly PaymentScheme[];\n\n /**\n * Construct via {@link createInflowClient}. The factory primes the buyer capability cache before resolving, so the\n * routing decision in {@link InflowClient.createPaymentPayload} is synchronous against in-memory data. The constructor\n * is exported only so the class is referenceable for `instanceof` checks, generic constraints, and return types.\n *\n * @param inflowSigner - Primed InFlow signer carrying the buyer capability cache, MPC signing flow, and prefer order.\n * @internal\n */\n constructor(inflowSigner: InflowSigner) {\n super();\n this.inflowSigner = inflowSigner;\n this.preferOrder = inflowSigner.prefer;\n }\n\n /**\n * Routing override. InFlow signs when the buyer capability cache covers a requirement (preferred-scheme order);\n * otherwise the foundation signs and any registered extension handlers are folded into `payload.extensions`. A\n * `required: true` extension whose handler returns `null` throws.\n */\n override async createPaymentPayload(paymentRequired: PaymentRequired): Promise<PaymentPayload> {\n // All foundation/InFlow type translation goes through ./_foundation-bridge.ts; see that file for the rationale on\n // why these casts are safe under the V2 wire shape.\n const inflowMatch = this.pickInflowMatch(fromFoundationRequirements(paymentRequired.accepts));\n if (inflowMatch !== null) {\n const context: SigningContext = {\n resource: paymentRequired.resource,\n x402Version: paymentRequired.x402Version,\n ...(paymentRequired.extensions !== undefined ? { extensions: paymentRequired.extensions } : {}),\n };\n const result = await this.inflowSigner.sign(inflowMatch, context);\n return toFoundationPayload(result.paymentPayload);\n }\n const payload = await super.createPaymentPayload(paymentRequired);\n // Foundation PaymentPayload is structurally assignable to InflowPaymentPayload (foundation `payload: Record<string,\n // unknown>` is the catch-all branch of `InflowPaymentPayloadData`; foundation `network: ${string}:${string}` is\n // assignable to InFlow's wider `network: string`). No cast needed here.\n const folded = foldInflowExtensions(payload, paymentRequired);\n return toFoundationPayload(folded);\n }\n\n /**\n * Two-phase signing flow for callers that want to surface pending- approval UI before the protected request is\n * replayed. Forwarded to the InFlow signer's `prepare()`; returns a {@link PreparedPayment} the caller can\n * `awaitPayload()` or `cancel()` independently.\n *\n * Has no foundation equivalent — `x402Client.createPaymentPayload` is one-shot. The handle is InFlow-specific and\n * only applies to requirements InFlow can sign.\n *\n * @param requirement - The chosen `PaymentRequirements` (re-exported from `@inflowpayai/x402`) — must match an entry\n * in the InFlow buyer capability cache.\n * @param context - Seller-side {@link SigningContext}.\n * @param options - Per-call {@link SignOptions}.\n * @returns A {@link PreparedPayment} handle.\n * @throws {@link X402AdapterRoutingError} When the requirement is not in the InFlow buyer capability cache\n * (foundation-signed requirements have no two-phase flow).\n */\n async prepareInflowPayment(\n requirement: PaymentRequirements,\n context: SigningContext,\n options?: SignOptions,\n ): Promise<PreparedPayment> {\n if (!this.inflowSigner.supports(requirement)) {\n throw new X402AdapterRoutingError(requirement.scheme, requirement.network);\n }\n return this.inflowSigner.prepare(requirement, context, options);\n }\n\n // The eight overrides below preserve foundation `x402Client` behavior\n // verbatim and only narrow the return type to `this` so chaining\n // stays in the {@link InflowClient} subclass.\n\n override register(network: Network, schemeNetworkClient: SchemeNetworkClient): this {\n super.register(network, schemeNetworkClient);\n return this;\n }\n\n override registerV1(network: string, schemeNetworkClient: SchemeNetworkClient): this {\n super.registerV1(network, schemeNetworkClient);\n return this;\n }\n\n override registerPolicy(policy: PaymentPolicy): this {\n super.registerPolicy(policy);\n return this;\n }\n\n override registerExtension(extension: ClientExtension): this {\n super.registerExtension(extension);\n return this;\n }\n\n override onBeforePaymentCreation(hook: BeforePaymentCreationHook): this {\n super.onBeforePaymentCreation(hook);\n return this;\n }\n\n override onAfterPaymentCreation(hook: AfterPaymentCreationHook): this {\n super.onAfterPaymentCreation(hook);\n return this;\n }\n\n override onPaymentCreationFailure(hook: OnPaymentCreationFailureHook): this {\n super.onPaymentCreationFailure(hook);\n return this;\n }\n\n override onPaymentResponse(hook: OnPaymentResponseHook): this {\n super.onPaymentResponse(hook);\n return this;\n }\n\n /**\n * Pick the buyer's preferred `accepts[]` entry the InFlow signer can handle. Walks {@link InflowClient.preferOrder}\n * and returns the first entry whose `(scheme, network)` is in the InFlow capability cache; returns `null` when no\n * entry matches (the foundation branch takes over).\n */\n private pickInflowMatch(accepts: readonly PaymentRequirements[]): PaymentRequirements | null {\n for (const scheme of this.preferOrder) {\n const match = accepts.find((r) => r.scheme === scheme && this.inflowSigner.supports(r));\n if (match !== undefined) return match;\n }\n return null;\n }\n}\n\n/**\n * Async factory for {@link InflowClient}. Constructs the InFlow signer (which primes the buyer-supported cache) and\n * attaches it to a fresh `InflowClient` instance.\n *\n * Foundation-managed scheme registrations (`registerExactEvmScheme(client, …)`, `registerExactSvmScheme(client, …)`)\n * are applied to the returned instance by the caller after this factory resolves.\n *\n * @param options - {@link SignerOptions}.\n * @returns A primed {@link InflowClient} ready for `x402HTTPClient` and any further foundation scheme registrations.\n */\nexport async function createInflowClient(options: SignerOptions): Promise<InflowClient> {\n const inflowSigner = await createInflowSigner(options);\n return new InflowClient(inflowSigner);\n}\n\n/**\n * Run every handler in `EXTENSION_REGISTRY` against the seller's `paymentRequired.extensions`. For each declared\n * extension whose handler returns a non-`null` payload entry, fold the entry into `paymentPayload.extensions`. Required\n * declarations whose handler returns `null` throw.\n *\n * The foundation `x402Client` does not know about `EXTENSION_REGISTRY`, so this fold-up runs only on the\n * foundation-signed branch of the routing decision. The InFlow-signed branch is unaffected — the InFlow server already\n * handled extensions when constructing the server-side payload.\n */\nfunction foldInflowExtensions(\n paymentPayload: InflowPaymentPayload,\n paymentRequired: PaymentRequired,\n): InflowPaymentPayload {\n const declared = paymentRequired.extensions;\n if (declared === undefined) return paymentPayload;\n\n const signContext: SignContext = {};\n let extensions: Record<string, unknown> | undefined = paymentPayload.extensions;\n for (const handler of EXTENSION_REGISTRY.values()) {\n const declaration = getExtension(declared, handler);\n if (declaration === undefined) continue;\n const entry = handler.buildPayloadEntry(declaration, signContext);\n if (entry !== null) {\n extensions = setExtension(extensions, handler, entry);\n continue;\n }\n const required =\n declaration !== null &&\n typeof declaration === 'object' &&\n 'required' in declaration &&\n declaration.required === true;\n if (required) {\n throw new Error(\n `InflowClient: extension \"${handler.name}\" is declared as required but no payload entry was produced`,\n );\n }\n }\n if (extensions === undefined) return paymentPayload;\n return { ...paymentPayload, extensions };\n}\n","import { X402InvalidEvmKeyError } from './errors.js';\n\nconst HEX_RE = /^[0-9a-f]+$/;\n\n/**\n * Normalize a secp256k1 secret to viem's `0x`-prefixed 32-byte hex form. Accepts `0x`-prefixed hex, bare hex, or an\n * InFlow Java seed (`BigInteger.toByteArray()` output — two's-complement, so 33 bytes with a leading sign byte for\n * high-bit-set secrets, or short when leading zero bytes were dropped). Both edges renormalize to 32 bytes.\n *\n * @example\n *\n * ```ts\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { parseEvmPrivateKey } from '@inflowpayai/x402-buyer';\n *\n * const account = privateKeyToAccount(parseEvmPrivateKey(process.env.EVM_PRIVATE_KEY!));\n * ```\n *\n * @throws {@link X402InvalidEvmKeyError} On non-hex input or a payload that doesn't reduce to exactly 32 bytes.\n */\nexport function parseEvmPrivateKey(value: string): `0x${string}` {\n let hex = value.trim().toLowerCase();\n if (hex.startsWith('0x')) hex = hex.slice(2);\n if (hex === '' || !HEX_RE.test(hex)) {\n throw new X402InvalidEvmKeyError('expected hex characters (0x-prefixed or bare)');\n }\n // Strip the Java BigInteger sign byte: a 33-byte two's-complement\n // encoding of a positive secp256k1 secret whose top byte is >= 0x80.\n if (hex.length === 66 && hex.startsWith('00')) {\n hex = hex.slice(2);\n }\n // Left-pad short keys whose leading zero bytes were dropped by\n // `BigInteger.toByteArray()`.\n if (hex.length < 64) hex = hex.padStart(64, '0');\n if (hex.length !== 64) {\n throw new X402InvalidEvmKeyError(`expected 32 bytes after normalization; got ${(hex.length / 2).toString()}`);\n }\n return `0x${hex}`;\n}\n","import bs58 from 'bs58';\n\nimport { X402InvalidSolanaKeyError } from './errors.js';\n\nconst EXPECTED_LENGTH = 64;\n\n/**\n * Decode a Solana secret into the 64-byte Ed25519 form expected by `@solana/kit`'s `createKeyPairSignerFromBytes`.\n * Auto-detects between a JSON byte array (`[...]`, as written by `solana-keygen`) and base58 (as emitted by InFlow's\n * `SolanaClient.Account.getSeed()` and by Phantom's exported secret).\n *\n * @example\n *\n * ```ts\n * import { createKeyPairSignerFromBytes } from '@solana/kit';\n * import { decodeSolanaSecret } from '@inflowpayai/x402-buyer';\n *\n * const bytes = decodeSolanaSecret(process.env.SOLANA_PRIVATE_KEY!);\n * const signer = await createKeyPairSignerFromBytes(bytes);\n * ```\n *\n * @throws {@link X402InvalidSolanaKeyError} On empty input, unparseable payloads, or anything that doesn't decode to\n * exactly 64 bytes.\n */\nexport function decodeSolanaSecret(value: string): Uint8Array {\n const trimmed = value.trim();\n if (trimmed === '') {\n throw new X402InvalidSolanaKeyError('input is empty');\n }\n if (trimmed.startsWith('[')) {\n return decodeJsonByteArray(trimmed);\n }\n return decodeBase58(trimmed);\n}\n\nfunction decodeJsonByteArray(trimmed: string): Uint8Array {\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch (err) {\n throw new X402InvalidSolanaKeyError(`JSON parse failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!Array.isArray(parsed)) {\n throw new X402InvalidSolanaKeyError('JSON value is not an array');\n }\n if (parsed.length !== EXPECTED_LENGTH) {\n throw new X402InvalidSolanaKeyError(\n `JSON array length is ${parsed.length.toString()}, expected ${EXPECTED_LENGTH.toString()}`,\n );\n }\n const bytes = new Uint8Array(EXPECTED_LENGTH);\n for (let i = 0; i < EXPECTED_LENGTH; i += 1) {\n const element: unknown = parsed[i];\n if (typeof element !== 'number' || !Number.isInteger(element) || element < 0 || element > 255) {\n throw new X402InvalidSolanaKeyError(`JSON array element at index ${i.toString()} is not an integer in 0..255`);\n }\n bytes[i] = element;\n }\n return bytes;\n}\n\nfunction decodeBase58(trimmed: string): Uint8Array {\n let decoded: Uint8Array;\n try {\n decoded = bs58.decode(trimmed);\n } catch (err) {\n throw new X402InvalidSolanaKeyError(`base58 decode failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (decoded.length !== EXPECTED_LENGTH) {\n throw new X402InvalidSolanaKeyError(\n `base58 decoded to ${decoded.length.toString()} bytes, expected ${EXPECTED_LENGTH.toString()}`,\n );\n }\n return decoded;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@inflowpayai/x402-buyer",
3
+ "version": "0.5.0",
4
+ "description": "InFlow x402 SDK: buyer-side InflowClient (x402Client subclass) for InFlow MPC signing alongside foundation @x402/evm and @x402/svm scheme registrations.",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "node": {
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ },
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22.13.0"
28
+ },
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "bs58": "^6.0.0",
32
+ "@inflowpayai/x402": "^0.5.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@x402/core": "^2.12.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@x402/core": {
39
+ "optional": false
40
+ }
41
+ },
42
+ "devDependencies": {
43
+ "@vitest/coverage-v8": "^2.1.0",
44
+ "@x402/core": "^2.12.0",
45
+ "fast-check": "^3.22.0",
46
+ "msw": "^2.4.0"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "provenance": true
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/inflowpayai/inflow-node.git",
55
+ "directory": "packages/x402-buyer"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/inflowpayai/inflow-node/issues"
59
+ },
60
+ "homepage": "https://github.com/inflowpayai/inflow-node/tree/main/packages/x402-buyer#readme",
61
+ "keywords": [
62
+ "x402",
63
+ "payments",
64
+ "inflow",
65
+ "@inflowpayai",
66
+ "buyer",
67
+ "signer"
68
+ ],
69
+ "scripts": {
70
+ "build": "tsup",
71
+ "dev": "tsup --watch",
72
+ "test": "vitest run --coverage",
73
+ "test:watch": "vitest",
74
+ "lint": "eslint src test --max-warnings 0",
75
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
76
+ "clean": "rm -rf dist .turbo"
77
+ }
78
+ }