@t2000/cli 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ccip-S3INYIGB.js → ccip-JEEJV65M.js} +3 -3
- package/dist/chunk-77SWBATH.js +204 -0
- package/dist/chunk-77SWBATH.js.map +1 -0
- package/dist/{chunk-7KWZUAT7.js → chunk-A5X4KG7U.js} +970 -210
- package/dist/chunk-A5X4KG7U.js.map +1 -0
- package/dist/{chunk-XLHETABG.js → chunk-KC2WRBJB.js} +1876 -2018
- package/dist/chunk-KC2WRBJB.js.map +1 -0
- package/dist/chunk-W7ACGWI5.js +879 -0
- package/dist/chunk-W7ACGWI5.js.map +1 -0
- package/dist/{client-BG6M6WUI.js → client-QWWT5U25.js} +211 -209
- package/dist/client-QWWT5U25.js.map +1 -0
- package/dist/{client-UCPLLOGQ.js → client-WUGFY2SS.js} +5 -5
- package/dist/{client-UCPLLOGQ.js.map → client-WUGFY2SS.js.map} +1 -1
- package/dist/{dist-6Z4OX6F4.js → dist-PMIMNN2H.js} +1475 -809
- package/dist/{dist-6Z4OX6F4.js.map → dist-PMIMNN2H.js.map} +1 -1
- package/dist/dist-YCBO7GXC.js +1305 -0
- package/dist/dist-YCBO7GXC.js.map +1 -0
- package/dist/index.js +4 -4
- package/package.json +3 -3
- package/dist/chunk-7KWZUAT7.js.map +0 -1
- package/dist/chunk-PR2QAGO2.js +0 -968
- package/dist/chunk-PR2QAGO2.js.map +0 -1
- package/dist/chunk-SDO3BBBC.js +0 -154
- package/dist/chunk-SDO3BBBC.js.map +0 -1
- package/dist/chunk-XLHETABG.js.map +0 -1
- package/dist/client-BG6M6WUI.js.map +0 -1
- package/dist/dist-NX2SBBWO.js +0 -34
- package/dist/dist-NX2SBBWO.js.map +0 -1
- /package/dist/{ccip-S3INYIGB.js.map → ccip-JEEJV65M.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/BodyDigest.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/internal/constantTimeEqual.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Challenge.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/PaymentRequest.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/zod.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Credential.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Errors.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Expires.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Mcp.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Method.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Receipt.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.4.3__express@5.2.1_hono@4.12.9_openap_a5bd8709643e33148686c341f103678d/node_modules/mppx/src/Store.ts"],"sourcesContent":["import { Base64, Bytes, Hash } from 'ox'\n\nimport { constantTimeEqual } from './internal/constantTimeEqual.js'\n\n/**\n * A body digest string in the format \"algorithm=base64hash\".\n *\n * @example\n * ```ts\n * import { BodyDigest } from 'mppx'\n *\n * const digest: BodyDigest.BodyDigest = 'sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE'\n * ```\n */\nexport type BodyDigest = `sha-256=${string}`\n\n/**\n * Computes a SHA-256 digest of the given body.\n *\n * @param body - The body to digest (string or object).\n * @returns A digest string in the format \"sha-256=base64hash\".\n *\n * @example\n * ```ts\n * import { BodyDigest } from 'mppx'\n *\n * const digest = BodyDigest.compute({ amount: '1000' })\n * // => 'sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE'\n * ```\n */\nexport function compute(body: Record<string, unknown> | string): BodyDigest {\n const str = typeof body === 'object' ? JSON.stringify(body) : body\n const bytes = Bytes.fromString(str)\n const hash = Hash.sha256(bytes, { as: 'Bytes' })\n const base64 = Base64.fromBytes(hash)\n return `sha-256=${base64}`\n}\n\n/**\n * Verifies that a digest matches the given body.\n *\n * @param digest - The digest to verify.\n * @param body - The body to verify against.\n * @returns True if the digest matches, false otherwise.\n *\n * @example\n * ```ts\n * import { BodyDigest } from 'mppx'\n *\n * const isValid = BodyDigest.verify(digest, '{\"amount\":\"1000\"}')\n * ```\n */\nexport function verify(digest: BodyDigest, body: Record<string, unknown> | string): boolean {\n return constantTimeEqual(compute(body), digest)\n}\n","import { Hash, Hex } from 'ox'\n\n/** Constant-time string comparison to prevent timing attacks. */\nexport function constantTimeEqual(a: string, b: string): boolean {\n const hashA = Hash.sha256(Hex.fromString(a))\n const hashB = Hash.sha256(Hex.fromString(b))\n let result = 0\n for (let i = 0; i < hashA.length; i++) result |= hashA.charCodeAt(i) ^ hashB.charCodeAt(i)\n return result === 0\n}\n","import { Base64, Bytes, Hash } from 'ox'\n\nimport { constantTimeEqual } from './internal/constantTimeEqual.js'\nimport type { OneOf } from './internal/types.js'\nimport type * as Method from './Method.js'\nimport * as PaymentRequest from './PaymentRequest.js'\nimport * as z from './zod.js'\n\n/**\n * Schema for a payment challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const challenge = Challenge.Schema.parse(data)\n * ```\n */\nexport const Schema = z.object({\n /** Optional human-readable description of the payment. */\n description: z.optional(z.string()),\n /** Optional digest of the request body (format: \"sha-256=base64hash\"). */\n digest: z.optional(z.string().check(z.regex(/^sha-256=/, 'Invalid digest format'))),\n /** Optional expiration timestamp (ISO 8601). */\n expires: z.optional(z.datetime()),\n /** Unique challenge identifier (HMAC-bound). */\n id: z.string(),\n /** Intent type (e.g., \"charge\", \"session\"). */\n intent: z.string(),\n /** Payment method (e.g., \"tempo\", \"stripe\"). */\n method: z.string(),\n /** Optional server-defined correlation data. Flat string-to-string map; clients MUST NOT modify. */\n opaque: z.optional(z.record(z.string(), z.string())),\n /** Server realm (e.g., hostname). */\n realm: z.string(),\n /** Method-specific request data. */\n request: z.record(z.string(), z.unknown()),\n})\n\n/**\n * A parsed payment challenge from a `WWW-Authenticate` header.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const challenge: Challenge.Challenge = {\n * id: 'abc123',\n * realm: 'api.example.com',\n * method: 'tempo',\n * intent: 'charge',\n * request: { amount: '1000000', currency: '0x...', recipient: '0x...' },\n * }\n * ```\n */\nexport type Challenge<\n request = Record<string, unknown>,\n intent extends string = string,\n method extends string = string,\n> = Omit<z.infer<typeof Schema>, 'intent' | 'method' | 'request'> & {\n intent: intent\n method: method\n request: request\n}\n\n/**\n * Extracts a union of challenge types from an array of methods.\n */\nexport type FromMethods<methods extends readonly Method.Method[]> = {\n [method in keyof methods]: Challenge<\n z.output<methods[method]['schema']['request']>,\n methods[method]['intent'],\n methods[method]['name']\n >\n}[number]\n\n/**\n * Creates a challenge from the given parameters.\n *\n * If `secretKey` option is provided, the challenge ID is computed as HMAC-SHA256\n * over the challenge parameters (realm|method|intent|request|expires|digest),\n * cryptographically binding the ID to its contents.\n *\n * @param parameters - Challenge parameters.\n * @param options - Optional settings including secretKey for HMAC-bound ID.\n * @returns A challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * // With HMAC-bound ID (recommended for servers)\n * const challenge = Challenge.from(\n * {\n * realm: 'api.example.com',\n * method: 'tempo',\n * intent: 'charge',\n * request: { amount: '1000000', currency: '0x...', recipient: '0x...' },\n * },\n * { secretKey: 'my-secret' },\n * )\n *\n * // With explicit ID\n * const challenge = Challenge.from({\n * id: 'abc123',\n * realm: 'api.example.com',\n * method: 'tempo',\n * intent: 'charge',\n * request: { amount: '1000000', currency: '0x...', recipient: '0x...' },\n * })\n * ```\n */\nexport function from<\n const parameters extends from.Parameters,\n const methods extends readonly Method.Method[] | undefined = undefined,\n>(parameters: parameters, options?: from.Options<methods>): from.ReturnType<parameters, methods> {\n void options\n const {\n description,\n digest,\n meta,\n method: methodName,\n intent,\n realm,\n request,\n secretKey,\n } = parameters\n\n const expires = parameters.expires as string\n const id = secretKey\n ? computeId({ ...parameters, expires, ...(meta && { opaque: meta }) }, { secretKey })\n : (parameters as { id: string }).id\n\n return Schema.parse({\n id,\n realm,\n method: methodName,\n intent,\n request,\n ...(description && { description }),\n ...(digest && { digest }),\n ...(expires && { expires }),\n ...(meta && { opaque: meta }),\n }) as from.ReturnType<parameters, methods>\n}\n\nexport declare namespace from {\n type Options<methods extends readonly Method.Method[] | undefined = undefined> = {\n methods?: methods\n }\n\n type Parameters = OneOf<\n | {\n /** Explicit challenge ID. */\n id: string\n }\n | {\n /** Secret key for HMAC-bound challenge ID. */\n secretKey: string\n }\n > & {\n /** Optional human-readable description of the payment. */\n description?: string | undefined\n /** Optional digest of the request body. */\n digest?: string | undefined\n /** Optional expiration timestamp (ISO 8601). */\n expires?: string | undefined\n /** Intent type (e.g., \"charge\", \"session\"). */\n intent: string\n /** Optional server-defined correlation data (serialized as `opaque` on the challenge). Flat string-to-string map; clients MUST NOT modify. */\n meta?: Record<string, string> | undefined\n /** Payment method (e.g., \"tempo\", \"stripe\"). */\n method: string\n /** Server realm (e.g., hostname). */\n realm: string\n /** Method-specific request data. */\n request: PaymentRequest.Request\n }\n\n type ReturnType<\n parameters extends Parameters,\n methods extends readonly Method.Method[] | undefined = undefined,\n > = methods extends readonly Method.Method[]\n ? FromMethods<methods>\n : Challenge<parameters['request']>\n}\n\n/**\n * Creates a validated challenge from a method intent.\n *\n * If `secretKey` option is provided, the challenge ID is computed as HMAC-SHA256\n * over the challenge parameters, cryptographically binding the ID to its contents.\n *\n * @param intent - The method intent to validate against.\n * @param parameters - Challenge parameters (realm, request, optional expires/digest, and id if no secretKey).\n * @param options - Optional settings including secretKey for HMAC-bound ID.\n * @returns A validated challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n * import { Methods } from 'mppx/tempo'\n *\n * // With HMAC-bound ID (recommended for servers)\n * const challenge = Challenge.fromMethod(\n * Methods.charge,\n * {\n * realm: 'api.example.com',\n * expires: '2025-01-06T12:00:00Z',\n * request: {\n * amount: '1000000',\n * currency: '0x20c0000000000000000000000000000000000001',\n * recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',\n * },\n * },\n * { secretKey: 'my-secret' },\n * )\n * ```\n */\nexport function fromMethod<const method extends Method.Method>(\n method: method,\n parameters: fromMethod.Parameters<method>,\n): fromMethod.ReturnType<method> {\n const { name: methodName, intent } = method\n const { description, digest, expires, id, meta, realm, secretKey } = parameters\n\n const request = PaymentRequest.fromMethod(method, parameters.request)\n\n return from({\n ...(id ? { id } : { secretKey }),\n realm,\n method: methodName,\n intent: intent,\n request,\n description,\n digest,\n expires,\n meta,\n } as from.Parameters) as fromMethod.ReturnType<method>\n}\n\nexport declare namespace fromMethod {\n type Parameters<method extends Method.Method> = OneOf<\n | {\n /** Explicit challenge ID. */\n id: string\n }\n | {\n /** Secret key for HMAC-bound challenge ID. */\n secretKey: string\n }\n > & {\n /** Optional human-readable description of the payment. */\n description?: string | undefined\n /** Optional digest of the request body. */\n digest?: string | undefined\n /** Optional expiration timestamp (ISO 8601). */\n expires?: string | undefined\n /** Optional server-defined correlation data (serialized as `opaque` on the challenge). Flat string-to-string map; clients MUST NOT modify. */\n meta?: Record<string, string> | undefined\n /** Server realm (e.g., hostname). */\n realm: string\n /** Method-specific request data. */\n request: z.input<method['schema']['request']>\n }\n\n type ReturnType<method extends Method.Method> = Challenge<z.output<method['schema']['request']>>\n}\n\n/**\n * Serializes a challenge to the WWW-Authenticate header format.\n *\n * @param challenge - The challenge to serialize.\n * @returns A string suitable for the WWW-Authenticate header value.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const header = Challenge.serialize(challenge)\n * // => 'Payment id=\"abc123\", realm=\"api.example.com\", method=\"tempo\", intent=\"charge\", request=\"eyJhbW91bnQiOi...\"'\n * ```\n */\nexport function serialize(challenge: Challenge): string {\n const parts = [\n `id=\"${challenge.id}\"`,\n `realm=\"${challenge.realm}\"`,\n `method=\"${challenge.method}\"`,\n `intent=\"${challenge.intent}\"`,\n `request=\"${PaymentRequest.serialize(challenge.request)}\"`,\n ]\n\n if (challenge.description !== undefined) parts.push(`description=\"${challenge.description}\"`)\n if (challenge.digest !== undefined) parts.push(`digest=\"${challenge.digest}\"`)\n if (challenge.expires !== undefined) parts.push(`expires=\"${challenge.expires}\"`)\n if (challenge.opaque !== undefined)\n parts.push(`opaque=\"${PaymentRequest.serialize(challenge.opaque)}\"`)\n\n return `Payment ${parts.join(', ')}`\n}\n\n/**\n * Deserializes a WWW-Authenticate header value to a challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const challenge = Challenge.deserialize(header)\n *\n * // With methods for type narrowing\n * const challenge = Challenge.deserialize(header, { methods })\n * ```\n *\n * @param header - The WWW-Authenticate header value.\n * @param options - Optional settings to narrow the challenge type.\n * @returns The deserialized challenge.\n */\nexport function deserialize<const methods extends readonly Method.Method[] | undefined = undefined>(\n value: string,\n options?: from.Options<methods>,\n): from.ReturnType<from.Parameters, methods> {\n const params = extractPaymentAuthParams(value)\n if (!params) throw new Error('Missing Payment scheme.')\n\n const result = parseAuthParams(params)\n\n const { request, opaque, ...rest } = result\n if (!request) throw new Error('Missing request parameter.')\n if (rest.method && !/^[a-z][a-z0-9:_-]*$/.test(rest.method))\n throw new Error(`Invalid method: \"${rest.method}\". Must be lowercase per spec.`)\n\n return from(\n {\n ...rest,\n request: PaymentRequest.deserialize(request),\n ...(opaque && { meta: PaymentRequest.deserialize(opaque) as Record<string, string> }),\n } as from.Parameters,\n options,\n )\n}\n\n/** @internal Extracts the `Payment` scheme from a WWW-Authenticate value that may contain multiple schemes. */\nfunction extractPaymentAuthParams(header: string): string | null {\n const token = 'Payment'\n let inQuotes = false\n let escaped = false\n\n for (let i = 0; i < header.length; i++) {\n const char = header[i]\n\n if (inQuotes) {\n if (escaped) escaped = false\n else if (char === '\\\\') escaped = true\n else if (char === '\"') inQuotes = false\n continue\n }\n\n if (char === '\"') {\n inQuotes = true\n continue\n }\n\n if (!startsWithSchemeToken(header, i, token)) continue\n\n const prefix = header.slice(0, i)\n if (prefix.trim() && !prefix.trimEnd().endsWith(',')) continue\n\n let paramsStart = i + token.length\n while (paramsStart < header.length && /\\s/.test(header[paramsStart] ?? '')) paramsStart++\n return header.slice(paramsStart)\n }\n\n return null\n}\n\n/** @internal Parses auth-params with support for escaped quoted-string values. */\nfunction parseAuthParams(input: string): Record<string, string> {\n const result: Record<string, string> = {}\n let i = 0\n\n while (i < input.length) {\n while (i < input.length && /[\\s,]/.test(input[i] ?? '')) i++\n if (i >= input.length) break\n\n const keyStart = i\n while (i < input.length && /[A-Za-z0-9_-]/.test(input[i] ?? '')) i++\n const key = input.slice(keyStart, i)\n if (!key) throw new Error('Malformed auth-param.')\n\n while (i < input.length && /\\s/.test(input[i] ?? '')) i++\n\n // If there is no '=' after a token, this is likely another auth scheme.\n if (input[i] !== '=') break\n i++\n\n while (i < input.length && /\\s/.test(input[i] ?? '')) i++\n\n const [value, nextIndex] = readAuthParamValue(input, i)\n i = nextIndex\n\n if (key in result) throw new Error(`Duplicate parameter: ${key}`)\n result[key] = value\n }\n\n return result\n}\n\n/** @internal */\nfunction readAuthParamValue(input: string, start: number): [value: string, nextIndex: number] {\n if (input[start] === '\"') return readQuotedAuthParamValue(input, start + 1)\n\n let i = start\n while (i < input.length && input[i] !== ',') i++\n return [input.slice(start, i).trim(), i]\n}\n\n/** @internal */\nfunction readQuotedAuthParamValue(\n input: string,\n start: number,\n): [value: string, nextIndex: number] {\n let i = start\n let value = ''\n let escaped = false\n\n while (i < input.length) {\n const char = input[i]!\n i++\n\n if (escaped) {\n value += char\n escaped = false\n continue\n }\n\n if (char === '\\\\') {\n escaped = true\n continue\n }\n\n if (char === '\"') return [value, i]\n value += char\n }\n\n throw new Error('Unterminated quoted-string.')\n}\n\n/** @internal */\nfunction startsWithSchemeToken(value: string, index: number, token: string): boolean {\n if (!value.slice(index).toLowerCase().startsWith(token.toLowerCase())) return false\n const next = value[index + token.length]\n return Boolean(next && /\\s/.test(next))\n}\n\n/**\n * Extracts the challenge from a Headers object.\n *\n * @param headers - The HTTP headers.\n * @param options - Optional settings to narrow the challenge type.\n * @returns The deserialized challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const challenge = Challenge.fromHeaders(response.headers)\n *\n * // With methods for type narrowing\n * const challenge = Challenge.fromHeaders(response.headers, { methods })\n * ```\n */\nexport function fromHeaders<const methods extends readonly Method.Method[] | undefined = undefined>(\n headers: Headers,\n options?: from.Options<methods>,\n): from.ReturnType<from.Parameters, methods> {\n const header = headers.get('WWW-Authenticate')\n if (!header) throw new Error('Missing WWW-Authenticate header.')\n return deserialize(header, options)\n}\n\n/**\n * Extracts the challenge from a Response's WWW-Authenticate header.\n *\n * @param response - The HTTP response (must be 402 status).\n * @param options - Optional settings to narrow the challenge type.\n * @returns The deserialized challenge.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const response = await fetch('/resource')\n * if (response.status === 402)\n * const challenge = Challenge.fromResponse(response)\n *\n * // With methods for type narrowing\n * const challenge = Challenge.fromResponse(response, { methods })\n * ```\n */\nexport function fromResponse<\n const methods extends readonly Method.Method[] | undefined = undefined,\n>(response: Response, options?: from.Options<methods>): from.ReturnType<from.Parameters, methods> {\n if (response.status !== 402) throw new Error('Response status is not 402.')\n return fromHeaders(response.headers, options)\n}\n\n/**\n * Extracts all Payment challenges from a Response with potentially merged\n * `WWW-Authenticate` headers (multiple challenges in a single header value).\n *\n * @param response - The HTTP response (must be 402 status).\n * @param options - Optional settings to narrow the challenge type.\n * @returns An array of deserialized challenges.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const response = await fetch('/resource')\n * if (response.status === 402) {\n * const challenges = Challenge.fromResponseList(response)\n * // challenges[0] => tempo/charge, challenges[1] => stripe/charge\n * }\n * ```\n */\nexport function fromResponseList<\n const methods extends readonly Method.Method[] | undefined = undefined,\n>(\n response: Response,\n options?: from.Options<methods>,\n): from.ReturnType<from.Parameters, methods>[] {\n if (response.status !== 402) throw new Error('Response status is not 402.')\n return fromHeadersList(response.headers, options)\n}\n\n/**\n * Extracts all Payment challenges from a Headers object with potentially\n * merged `WWW-Authenticate` values.\n *\n * @param headers - The HTTP headers.\n * @param options - Optional settings to narrow the challenge type.\n * @returns An array of deserialized challenges.\n */\nexport function fromHeadersList<\n const methods extends readonly Method.Method[] | undefined = undefined,\n>(headers: Headers, options?: from.Options<methods>): from.ReturnType<from.Parameters, methods>[] {\n const header = headers.get('WWW-Authenticate')\n if (!header) throw new Error('Missing WWW-Authenticate header.')\n return deserializeList(header, options)\n}\n\n/**\n * Deserializes a `WWW-Authenticate` header value that may contain multiple\n * Payment challenges (comma-separated per RFC 9110 §11.6.1).\n *\n * @param value - The raw WWW-Authenticate header value.\n * @param options - Optional settings to narrow the challenge type.\n * @returns An array of deserialized challenges.\n */\nexport function deserializeList<\n const methods extends readonly Method.Method[] | undefined = undefined,\n>(value: string, options?: from.Options<methods>): from.ReturnType<from.Parameters, methods>[] {\n // Find the start index of each `Payment ` scheme prefix.\n const starts: number[] = []\n for (const match of value.matchAll(/Payment\\s+/gi)) {\n starts.push(match.index!)\n }\n if (starts.length === 0) throw new Error('No Payment schemes found.')\n\n // Slice each scheme from its `Payment ` prefix up to the next scheme boundary,\n // trimming any trailing comma/whitespace between schemes.\n return starts.map((start, i) => {\n const end = i + 1 < starts.length ? starts[i + 1]! : value.length\n const chunk = value.slice(start, end).replace(/,\\s*$/, '')\n return deserialize(chunk, options)\n })\n}\n\n/**\n * Verifies that a challenge ID matches the expected HMAC for the given parameters.\n *\n * @param challenge - The challenge to verify.\n * @param options - Options including the secret key.\n * @returns True if the challenge ID is valid, false otherwise.\n *\n * @example\n * ```ts\n * import { Challenge } from 'mppx'\n *\n * const isValid = Challenge.verify(challenge, { secretKey: 'my-secret' })\n * ```\n */\nexport function verify(challenge: Challenge, options: verify.Options): boolean {\n const expectedId = computeId(challenge, options)\n return constantTimeEqual(challenge.id, expectedId)\n}\n\nexport declare namespace verify {\n type Options = {\n /** Secret key for HMAC-bound challenge ID verification. */\n secretKey: string\n }\n}\n\n/** Alias for `challenge.opaque`. Extracts server-defined correlation data from a challenge. */\nexport function meta(challenge: Challenge): Record<string, string> | undefined {\n return challenge.opaque\n}\n\n/** @internal Computes HMAC-SHA256 challenge ID from parameters. */\nfunction computeId(challenge: Omit<Challenge, 'id'>, options: { secretKey: string }): string {\n // Each field occupies a fixed positional slot joined by '|'. Optional fields\n // use an empty string when absent so the slot count is stable — this avoids\n // ambiguity between e.g. (expires set, no digest) vs (no expires, digest set)\n // and means adding a new optional field changes all HMACs exactly once.\n const input = [\n challenge.realm,\n challenge.method,\n challenge.intent,\n PaymentRequest.serialize(challenge.request),\n challenge.expires ?? '',\n challenge.digest ?? '',\n challenge.opaque ? PaymentRequest.serialize(challenge.opaque) : '',\n ].join('|')\n\n const key = Bytes.fromString(options.secretKey)\n const data = Bytes.fromString(input)\n const mac = Hash.hmac256(key, data, { as: 'Bytes' })\n return Base64.fromBytes(mac, { url: true, pad: false })\n}\n","import { Base64, Json } from 'ox'\n\nimport type { Compute } from './internal/types.js'\nimport type * as Method from './Method.js'\nimport type * as z from './zod.js'\n\n/**\n * Intent-specific payment parameters.\n *\n * @example\n * ```ts\n * import { Request } from 'mppx'\n *\n * const request: Request.Request = {\n * amount: '1000000',\n * currency: '0x20c0000000000000000000000000000000000001',\n * recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',\n * }\n * ```\n */\nexport type Request<request extends Record<string, unknown> = Record<string, unknown>> =\n Compute<request>\n\n/**\n * Deserializes a base64url string to a request.\n *\n * @param encoded - The base64url-encoded string.\n * @returns The deserialized request.\n *\n * @example\n * ```ts\n * import { Request } from 'mppx'\n *\n * const request = Request.deserialize(serialized)\n * ```\n */\nexport function deserialize(encoded: string): Request {\n const json = Base64.toString(encoded)\n return JSON.parse(json)\n}\n\n/**\n * Creates a request from the given parameters.\n *\n * @param request - Request parameters.\n * @returns A request.\n *\n * @example\n * ```ts\n * import { Request } from 'mppx'\n *\n * const request = Request.from({\n * amount: '1000000',\n * currency: '0x20c0000000000000000000000000000000000001',\n * recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',\n * })\n * ```\n */\nexport function from<const request extends Request>(request: request): request {\n return request\n}\n\n/**\n * Creates a validated request from a method intent.\n *\n * @param method - The method to validate against.\n * @param request - Request parameters.\n * @returns A validated request.\n *\n * @example\n * ```ts\n * import { Request } from 'mppx'\n * import { Methods } from 'mppx/tempo'\n *\n * const request = Request.fromMethod(Methods.charge, {\n * amount: '1000000',\n * currency: '0x20c0000000000000000000000000000000000001',\n * recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',\n * expires: '2025-01-06T12:00:00Z',\n * chainId: 42431,\n * })\n * ```\n */\nexport function fromMethod<const method extends Method.Method>(\n method: method,\n request: z.input<method['schema']['request']>,\n): Request<z.output<method['schema']['request']>> {\n return method.schema.request.parse(request) as Request<z.output<method['schema']['request']>>\n}\n\n/**\n * Serializes a request to a base64url string.\n *\n * @param request - The request to serialize.\n * @returns A base64url-encoded string (no padding).\n *\n * @example\n * ```ts\n * import { Request } from 'mppx'\n *\n * const serialized = Request.serialize(request)\n * // => \"eyJhbW91bnQiOiIxMDAwMDAwIiwiY3VycmVuY3kiOiIweC4uLiJ9\"\n * ```\n */\nexport function serialize(request: Request): string {\n const json = Json.canonicalize(request)\n return Base64.fromString(json, { pad: false, url: true })\n}\n","import { type ZodMiniOptional, type ZodMiniType, z } from 'zod/mini'\n\nexport * from 'zod/mini'\n\n/** Numeric string amount (e.g., \"1\", \"1.5\", \"1000000\"). */\nexport function amount() {\n return z.string().check(z.regex(/^\\d+(\\.\\d+)?$/, 'Invalid amount'))\n}\n\n/** ISO 8601 datetime string (e.g., \"2025-01-06T12:00:00Z\"). */\nexport function datetime() {\n return z\n .string()\n .check(\n z.regex(\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/,\n 'Invalid ISO 8601 datetime',\n ),\n )\n}\n\n/** Hex-encoded address string (0x-prefixed, 40 hex chars). */\nexport function address() {\n return z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/, 'Invalid address'))\n}\n\n/** Hex-encoded hash string (0x-prefixed, 64 hex chars). */\nexport function hash() {\n return z.string().check(z.regex(/^0x[0-9a-fA-F]{64}$/, 'Invalid hash'))\n}\n\n/** Billing period: \"day\", \"week\", \"month\", \"year\", or seconds as string. */\nexport function period() {\n return z.string().check(z.regex(/^(day|week|month|year|\\d+)$/, 'Invalid period'))\n}\n\n/** Hex-encoded signature string (0x-prefixed). */\nexport function signature() {\n return z.string().check(z.regex(/^0x[0-9a-fA-F]+$/, 'Invalid signature'))\n}\n\n/** Checks if a schema is optional and returns the inner type if so. */\nexport function unwrapOptional<schema extends ZodMiniType>(schema: schema): ZodMiniType {\n if (schema._zod.def.type === 'optional')\n return (schema as unknown as ZodMiniOptional)._zod.def.innerType as ZodMiniType\n return schema\n}\n","import { Base64 } from 'ox'\n\nimport * as Challenge from './Challenge.js'\nimport * as PaymentRequest from './PaymentRequest.js'\n\n/**\n * A payment credential containing the challenge and payment proof.\n */\nexport type Credential<\n payload = unknown,\n challenge extends Challenge.Challenge = Challenge.Challenge,\n> = {\n /** The challenge from the 402 response. */\n challenge: challenge\n /** Method-specific payment proof. */\n payload: payload\n /** Optional payer identifier as a DID (e.g., \"did:pkh:eip155:1:0x...\"). */\n source?: string\n}\n\n/**\n * Deserializes an Authorization header value to a credential.\n *\n * @param header - The Authorization header value.\n * @returns The deserialized credential.\n *\n * @example\n * ```ts\n * import { Credential } from 'mppx'\n *\n * const credential = Credential.deserialize(header)\n * ```\n */\nexport function deserialize<payload = unknown>(value: string): Credential<payload> {\n const prefixMatch = value.match(/^Payment\\s+(.+)$/i)\n if (!prefixMatch?.[1]) throw new Error('Missing Payment scheme.')\n try {\n const json = Base64.toString(prefixMatch[1])\n const parsed = JSON.parse(json) as {\n challenge: Omit<Challenge.Challenge, 'request'> & { request: string }\n payload: payload\n source?: string\n }\n const challenge = Challenge.Schema.parse({\n ...parsed.challenge,\n request: PaymentRequest.deserialize(parsed.challenge.request),\n })\n return {\n challenge,\n payload: parsed.payload,\n ...(parsed.source && { source: parsed.source }),\n } as Credential<payload>\n } catch {\n throw new Error('Invalid base64url or JSON.')\n }\n}\n\n/**\n * Creates a credential from the given parameters.\n *\n * @param parameters - Credential parameters with a Challenge object.\n * @returns A credential.\n *\n * @example\n * ```ts\n * import { Credential, Challenge } from 'mppx'\n *\n * const credential = Credential.from({\n * challenge,\n * payload: { signature: '0x...' },\n * })\n * ```\n */\nexport function from<const parameters extends from.Parameters>(\n parameters: parameters,\n): Credential<parameters['payload'], parameters['challenge']> {\n const { challenge, payload, source } = parameters\n return {\n challenge,\n payload,\n ...(source && { source }),\n } as Credential<parameters['payload'], parameters['challenge']>\n}\n\nexport declare namespace from {\n type Parameters = {\n /** The challenge from the 402 response. */\n challenge: Challenge.Challenge\n /** Method-specific payment proof. */\n payload: unknown\n /** Optional payer identifier as a DID (e.g., \"did:pkh:eip155:1:0x...\"). */\n source?: string\n }\n}\n\n/**\n * Extracts the credential from a Request's Authorization header.\n *\n * @param request - The HTTP request.\n * @returns The deserialized credential.\n *\n * @example\n * ```ts\n * import { Credential } from 'mppx'\n *\n * const credential = Credential.fromRequest(request)\n * ```\n */\nexport function fromRequest<payload = unknown>(request: Request): Credential<payload> {\n const header = request.headers.get('Authorization')\n if (!header) throw new Error('Missing Authorization header.')\n const payment = extractPaymentScheme(header)\n if (!payment) throw new Error('Missing Payment scheme.')\n return deserialize<payload>(payment)\n}\n\n/**\n * Serializes a credential to the Authorization header format.\n *\n * @param credential - The credential to serialize.\n * @returns A string suitable for the Authorization header value.\n *\n * @example\n * ```ts\n * import { Credential } from 'mppx'\n *\n * const header = Credential.serialize(credential)\n * // => 'Payment eyJjaGFsbGVuZ2UiOnsi...'\n * ```\n */\nexport function serialize(credential: Credential): string {\n const wire = {\n challenge: {\n ...credential.challenge,\n request: PaymentRequest.serialize(credential.challenge.request),\n },\n payload: credential.payload,\n ...(credential.source && { source: credential.source }),\n }\n const json = JSON.stringify(wire)\n const encoded = Base64.fromString(json, { pad: false, url: true })\n return `Payment ${encoded}`\n}\n\n/**\n * Extracts the `Payment` scheme from an Authorization header value\n * that may contain multiple schemes (comma-separated per RFC 9110).\n *\n * @param header - The raw Authorization header value.\n * @returns The `Payment ...` scheme string, or `null` if not found.\n */\nexport function extractPaymentScheme(header: string): string | null {\n const schemes = header.split(',').map((s) => s.trim())\n return schemes.find((s) => /^Payment\\s+/i.test(s)) ?? null\n}\n","/**\n * Base class for all payment-related errors.\n */\nexport abstract class PaymentError extends Error {\n /** RFC 9457 Problem Details type URI. */\n abstract readonly type: string\n\n /** Human-readable summary for RFC 9457 Problem Details. */\n abstract readonly title: string\n\n /** HTTP status code. */\n readonly status: number = 402\n\n /** Converts the error to RFC 9457 Problem Details format. */\n toProblemDetails(challengeId?: string): PaymentError.ProblemDetails {\n return {\n type: this.type,\n title: this.title,\n status: this.status,\n detail: this.message,\n ...(challengeId && { challengeId }),\n }\n }\n}\n\nexport declare namespace PaymentError {\n type ProblemDetails = {\n /** RFC 9457 Problem Details type URI. */\n type: string\n /** Human-readable summary. */\n title: string\n /** HTTP status code. */\n status: number\n /** Human-readable explanation. */\n detail: string\n /** Associated challenge ID, if applicable. */\n challengeId?: string\n }\n}\n\n/**\n * Credential is malformed (invalid base64url, bad JSON structure).\n */\nexport class MalformedCredentialError extends PaymentError {\n override readonly name = 'MalformedCredentialError'\n readonly title = 'Malformed Credential'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/malformed-credential'\n\n constructor(options: MalformedCredentialError.Options = {}) {\n const { reason } = options\n super(reason ? `Credential is malformed: ${reason}.` : 'Credential is malformed.')\n }\n}\n\nexport declare namespace MalformedCredentialError {\n type Options = {\n /** Reason the credential is malformed (e.g., \"invalid base64url\", \"invalid JSON\"). */\n reason?: string\n }\n}\n\n/**\n * Challenge ID is unknown, expired, or already used.\n */\nexport class InvalidChallengeError extends PaymentError {\n override readonly name = 'InvalidChallengeError'\n readonly title = 'Invalid Challenge'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/invalid-challenge'\n\n constructor(options: InvalidChallengeError.Options = {}) {\n const { id, reason } = options\n const idPart = id ? ` \"${id}\"` : ''\n const reasonPart = reason ? `: ${reason}` : ''\n super(`Challenge${idPart} is invalid${reasonPart}.`)\n }\n}\n\nexport declare namespace InvalidChallengeError {\n type Options = {\n /** The invalid challenge ID. */\n id?: string\n /** Reason the challenge is invalid (e.g., \"expired\", \"already used\", \"unknown\"). */\n reason?: string\n }\n}\n\n/**\n * Payment proof is invalid or verification failed.\n */\nexport class VerificationFailedError extends PaymentError {\n override readonly name = 'VerificationFailedError'\n readonly title = 'Verification Failed'\n readonly type = 'https://paymentauth.org/problems/verification-failed'\n\n constructor(options: VerificationFailedError.Options = {}) {\n const { reason } = options\n super(reason ? `Payment verification failed: ${reason}.` : 'Payment verification failed.')\n }\n}\n\nexport declare namespace VerificationFailedError {\n type Options = {\n /** Reason verification failed (e.g., \"invalid signature\", \"insufficient amount\"). */\n reason?: string\n }\n}\n\n/**\n * Payment requires additional action (e.g., 3DS authentication).\n */\nexport class PaymentActionRequiredError extends PaymentError {\n override readonly name = 'PaymentActionRequiredError'\n readonly title = 'Payment Action Required'\n readonly type = 'https://paymentauth.org/problems/payment-action-required'\n\n constructor(options: PaymentActionRequiredError.Options = {}) {\n const { reason } = options\n super(reason ? `Payment requires action: ${reason}.` : 'Payment requires action.')\n }\n}\n\nexport declare namespace PaymentActionRequiredError {\n type Options = {\n /** Reason action is required (e.g., \"requires_action\"). */\n reason?: string\n }\n}\n\n/**\n * Payment has expired.\n */\nexport class PaymentExpiredError extends PaymentError {\n override readonly name = 'PaymentExpiredError'\n readonly title = 'Payment Expired'\n readonly type = 'https://paymentauth.org/problems/payment-expired'\n\n constructor(options: PaymentExpiredError.Options = {}) {\n const { expires } = options\n super(expires ? `Payment expired at ${expires}.` : 'Payment has expired.')\n }\n}\n\nexport declare namespace PaymentExpiredError {\n type Options = {\n /** ISO 8601 expiration timestamp. */\n expires?: string\n }\n}\n\n/**\n * No credential was provided but payment is required.\n */\nexport class PaymentRequiredError extends PaymentError {\n override readonly name = 'PaymentRequiredError'\n readonly title = 'Payment Required'\n readonly type = 'https://paymentauth.org/problems/payment-required'\n\n constructor(options: PaymentRequiredError.Options = {}) {\n const { description } = options\n const parts = ['Payment is required']\n if (description) parts.push(`(${description})`)\n super(`${parts.join(' ')}.`)\n }\n}\n\nexport declare namespace PaymentRequiredError {\n type Options = {\n /** Human-readable description of the payment. */\n description?: string | undefined\n }\n}\n\n/**\n * Credential payload does not match the expected schema.\n */\nexport class InvalidPayloadError extends PaymentError {\n override readonly name = 'InvalidPayloadError'\n readonly title = 'Invalid Payload'\n readonly type = 'https://paymentauth.org/problems/invalid-payload'\n\n constructor(options: InvalidPayloadError.Options = {}) {\n const { reason } = options\n super(reason ? `Credential payload is invalid: ${reason}.` : 'Credential payload is invalid.')\n }\n}\n\nexport declare namespace InvalidPayloadError {\n type Options = {\n /** Reason the payload is invalid (e.g., \"missing signature field\"). */\n reason?: string\n }\n}\n\n/**\n * Request is malformed or contains invalid parameters.\n */\nexport class BadRequestError extends PaymentError {\n override readonly name = 'BadRequestError'\n readonly title = 'Bad Request'\n override readonly status = 400\n readonly type = 'https://paymentauth.org/problems/bad-request'\n\n constructor(options: BadRequestError.Options = {}) {\n const { reason } = options\n super(reason ? `Bad request: ${reason}.` : 'Bad request.')\n }\n}\n\nexport declare namespace BadRequestError {\n type Options = {\n /** Reason the request is invalid. */\n reason?: string\n }\n}\n\n/**\n * Payment amount is insufficient (too low).\n */\nexport class PaymentInsufficientError extends PaymentError {\n override readonly name = 'PaymentInsufficientError'\n readonly title = 'Payment Insufficient'\n readonly type = 'https://paymentauth.org/problems/payment-insufficient'\n\n constructor(options: PaymentInsufficientError.Options = {}) {\n const { reason } = options\n super(reason ? `Payment insufficient: ${reason}.` : 'Payment amount is insufficient.')\n }\n}\n\nexport declare namespace PaymentInsufficientError {\n type Options = {\n /** Reason the payment is insufficient (e.g., \"expected 1000, received 500\"). */\n reason?: string\n }\n}\n\n/**\n * Payment method is not supported by the server.\n */\nexport class PaymentMethodUnsupportedError extends PaymentError {\n override readonly name = 'PaymentMethodUnsupportedError'\n readonly title = 'Method Unsupported'\n override readonly status = 400\n readonly type = 'https://paymentauth.org/problems/method-unsupported'\n\n constructor(options: PaymentMethodUnsupportedError.Options = {}) {\n const { method } = options\n super(\n method ? `Payment method \"${method}\" is not supported.` : 'Payment method is not supported.',\n )\n }\n}\n\nexport declare namespace PaymentMethodUnsupportedError {\n type Options = {\n /** The unsupported method identifier. */\n method?: string\n }\n}\n\n/**\n * Insufficient balance in the payment channel.\n */\nexport class InsufficientBalanceError extends PaymentError {\n override readonly name = 'InsufficientBalanceError'\n readonly title = 'Insufficient Balance'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/session/insufficient-balance'\n\n constructor(options: InsufficientBalanceError.Options = {}) {\n const { reason } = options\n super(reason ? `Insufficient balance: ${reason}.` : 'Insufficient balance.')\n }\n}\n\nexport declare namespace InsufficientBalanceError {\n type Options = {\n /** Reason for insufficient balance. */\n reason?: string\n }\n}\n\n/**\n * Voucher or close request signature is invalid.\n */\nexport class InvalidSignatureError extends PaymentError {\n override readonly name = 'InvalidSignatureError'\n readonly title = 'Invalid Signature'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/session/invalid-signature'\n\n constructor(options: InvalidSignatureError.Options = {}) {\n const { reason } = options\n super(reason ? `Invalid signature: ${reason}.` : 'Invalid signature.')\n }\n}\n\nexport declare namespace InvalidSignatureError {\n type Options = {\n reason?: string\n }\n}\n\n/**\n * Recovered signer is not authorized for this channel.\n */\nexport class SignerMismatchError extends PaymentError {\n override readonly name = 'SignerMismatchError'\n readonly title = 'Signer Mismatch'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/session/signer-mismatch'\n\n constructor(options: SignerMismatchError.Options = {}) {\n const { reason } = options\n super(reason ? `Signer mismatch: ${reason}.` : 'Signer is not authorized for this channel.')\n }\n}\n\nexport declare namespace SignerMismatchError {\n type Options = {\n reason?: string\n }\n}\n\n/**\n * Voucher cumulative amount exceeds the channel deposit.\n */\nexport class AmountExceedsDepositError extends PaymentError {\n override readonly name = 'AmountExceedsDepositError'\n readonly title = 'Amount Exceeds Deposit'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/session/amount-exceeds-deposit'\n\n constructor(options: AmountExceedsDepositError.Options = {}) {\n const { reason } = options\n super(reason ? `Amount exceeds deposit: ${reason}.` : 'Voucher amount exceeds channel deposit.')\n }\n}\n\nexport declare namespace AmountExceedsDepositError {\n type Options = {\n reason?: string\n }\n}\n\n/**\n * Voucher amount increase is below the minimum delta.\n */\nexport class DeltaTooSmallError extends PaymentError {\n override readonly name = 'DeltaTooSmallError'\n readonly title = 'Delta Too Small'\n override readonly status = 402\n readonly type = 'https://paymentauth.org/problems/session/delta-too-small'\n\n constructor(options: DeltaTooSmallError.Options = {}) {\n const { reason } = options\n super(reason ? `Delta too small: ${reason}.` : 'Amount increase below minimum voucher delta.')\n }\n}\n\nexport declare namespace DeltaTooSmallError {\n type Options = {\n reason?: string\n }\n}\n\n/**\n * No channel with this ID exists.\n */\nexport class ChannelNotFoundError extends PaymentError {\n override readonly name = 'ChannelNotFoundError'\n readonly title = 'Channel Not Found'\n override readonly status = 410\n readonly type = 'https://paymentauth.org/problems/session/channel-not-found'\n\n constructor(options: ChannelNotFoundError.Options = {}) {\n const { reason } = options\n super(reason ? `Channel not found: ${reason}.` : 'No channel with this ID exists.')\n }\n}\n\nexport declare namespace ChannelNotFoundError {\n type Options = {\n reason?: string\n }\n}\n\n/**\n * Channel is closed or finalized.\n */\nexport class ChannelClosedError extends PaymentError {\n override readonly name = 'ChannelClosedError'\n readonly title = 'Channel Closed'\n override readonly status = 410\n readonly type = 'https://paymentauth.org/problems/session/channel-finalized'\n\n constructor(options: ChannelClosedError.Options = {}) {\n const { reason } = options\n super(reason ? `Channel closed: ${reason}.` : 'Channel is closed.')\n }\n}\n\nexport declare namespace ChannelClosedError {\n type Options = {\n /** Reason the channel is closed. */\n reason?: string\n }\n}\n","/** Returns an ISO 8601 datetime string `n` days from now. */\nexport function days(n: number) {\n return new Date(Date.now() + n * 24 * 60 * 60 * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` hours from now. */\nexport function hours(n: number) {\n return new Date(Date.now() + n * 60 * 60 * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` minutes from now. */\nexport function minutes(n: number) {\n return new Date(Date.now() + n * 60 * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` months (30 days) from now. */\nexport function months(n: number) {\n return new Date(Date.now() + n * 30 * 24 * 60 * 60 * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` seconds from now. */\nexport function seconds(n: number) {\n return new Date(Date.now() + n * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` weeks from now. */\nexport function weeks(n: number) {\n return new Date(Date.now() + n * 7 * 24 * 60 * 60 * 1000).toISOString()\n}\n\n/** Returns an ISO 8601 datetime string `n` years (365 days) from now. */\nexport function years(n: number) {\n return new Date(Date.now() + n * 365 * 24 * 60 * 60 * 1000).toISOString()\n}\n","import type * as Challenge from './Challenge.js'\nimport type * as Credential from './Credential.js'\nimport type * as Errors from './Errors.js'\nimport type { OneOf } from './internal/types.js'\nimport type * as core_Receipt from './Receipt.js'\n\n/** MCP JSON-RPC error code for payment required. */\nexport const paymentRequiredCode = -32042\n\n/** MCP JSON-RPC error code for payment verification failed. */\nexport const paymentVerificationFailedCode = -32043\n\n/** MCP metadata key for credentials. */\nexport const credentialMetaKey = 'org.paymentauth/credential'\n\n/** MCP metadata key for receipts. */\nexport const receiptMetaKey = 'org.paymentauth/receipt'\n\n/**\n * MCP request with payment metadata support.\n */\nexport type Request = {\n method: string\n params?: {\n _meta?:\n | {\n [credentialMetaKey]?: Credential.Credential\n [key: string]: unknown\n }\n | undefined\n [key: string]: unknown\n }\n}\n\n/**\n * Full JSON-RPC request (used internally by transports).\n */\nexport type JsonRpcRequest = Request & {\n jsonrpc?: '2.0' | undefined\n id?: number | string | undefined\n}\n\n/**\n * MCP result with optional receipt metadata.\n */\nexport type Result = {\n _meta?: {\n [receiptMetaKey]?: Receipt\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\n/**\n * MCP error object for payment required responses.\n */\nexport type ErrorObject = {\n code: number\n message: string\n data?: {\n httpStatus: number\n challenges: Challenge.Challenge[]\n /** RFC 9457 Problem Details for rich error context. */\n problem?: Errors.PaymentError.ProblemDetails\n }\n}\n\n/**\n * Full JSON-RPC response (used internally by transports).\n */\nexport type Response = {\n jsonrpc?: '2.0' | undefined\n id?: number | string | undefined\n} & OneOf<{ result: Result } | { error: ErrorObject }>\n\n/**\n * MCP receipt structure (extends Receipt with MCP-specific fields).\n */\nexport type Receipt = core_Receipt.Receipt & {\n challengeId: string\n}\n","import type * as Challenge from './Challenge.js'\nimport type * as Credential from './Credential.js'\nimport type { ExactPartial, LooseOmit, MaybePromise } from './internal/types.js'\nimport type * as Receipt from './Receipt.js'\nimport type * as Transport from './server/Transport.js'\nimport type * as z from './zod.js'\n\n/**\n * A payment method.\n */\nexport type Method = {\n name: string\n intent: string\n schema: {\n credential: {\n payload: z.ZodMiniType\n }\n request: z.ZodMiniType<Record<string, unknown>>\n }\n}\n\n/**\n * Creates a payment method.\n *\n * @example\n * ```ts\n * import { z } from 'zod/mini'\n * import { Method } from 'mppx'\n *\n * const tempoCharge = Method.from({\n * name: 'tempo',\n * intent: 'charge',\n * schema: {\n * credential: {\n * payload: z.object({\n * signature: z.string(),\n * type: z.literal('transaction'),\n * }),\n * },\n * request: z.object({\n * amount: z.string(),\n * currency: z.string(),\n * recipient: z.string(),\n * }),\n * },\n * })\n * ```\n */\nexport function from<const method extends Method>(method: method): method {\n return method\n}\n\n/**\n * A client-side configured method with credential creation logic.\n */\nexport type Client<\n method extends Method = Method,\n context extends z.ZodMiniType | undefined = z.ZodMiniType | undefined,\n> = method & {\n context?: context\n createCredential: CreateCredentialFn<\n method,\n context extends z.ZodMiniType ? z.output<context> : Record<never, never>\n >\n}\nexport type AnyClient = Client<any, any>\n\n/**\n * A server-side configured method with verification logic.\n */\nexport type Server<\n method extends Method = Method,\n defaults extends ExactPartial<z.input<method['schema']['request']>> = {},\n transportOverride = undefined,\n> = method & {\n defaults?: defaults | undefined\n request?: RequestFn<method> | undefined\n respond?: RespondFn<method> | undefined\n transport?: transportOverride | undefined\n verify: VerifyFn<method>\n}\nexport type AnyServer = Server<any, any, any>\n\n/** Credential creation function for a single method. */\nexport type CreateCredentialFn<method extends Method, context = unknown> = (\n parameters: {\n challenge: Challenge.Challenge<\n z.output<method['schema']['request']>,\n method['intent'],\n method['name']\n >\n } & ([keyof context] extends [never] ? unknown : { context: context }),\n) => Promise<string>\n\n/** Request transform function for a single method. */\nexport type RequestFn<method extends Method> = (options: {\n credential?: Credential.Credential | null | undefined\n request: z.input<method['schema']['request']>\n}) => MaybePromise<z.input<method['schema']['request']>>\n\n/** Verification function for a single method. */\nexport type VerifyFn<method extends Method> = (parameters: {\n credential: Credential.Credential<\n z.output<method['schema']['credential']['payload']>,\n Challenge.Challenge<z.output<method['schema']['request']>, method['intent'], method['name']>\n >\n request: z.input<method['schema']['request']>\n}) => Promise<Receipt.Receipt>\n\n/**\n * Optional respond function for a server-side method.\n *\n * Called after `verify` succeeds. If it returns a `Response`, the library\n * treats the request as fully handled (e.g. channel open/close) and\n * `withReceipt()` will short-circuit — returning the management response\n * with the receipt header attached without invoking any user-supplied\n * response or generator. If it returns `undefined`, the server handler\n * is expected to serve content via `withReceipt(response)`.\n *\n * **HTTP-only.** The `input` parameter is a `Request` object; MCP transports\n * do not invoke this hook.\n */\nexport type RespondFn<method extends Method> = (parameters: {\n credential: Credential.Credential<\n z.output<method['schema']['credential']['payload']>,\n Challenge.Challenge<z.output<method['schema']['request']>, method['intent'], method['name']>\n >\n input: globalThis.Request\n receipt: Receipt.Receipt\n request: z.input<method['schema']['request']>\n}) => MaybePromise<globalThis.Response | undefined>\n\n/** Partial request type for defaults. */\nexport type RequestDefaults<method extends Method> = ExactPartial<\n z.input<method['schema']['request']>\n>\n\n/** Makes fields optional if they exist in defaults. */\nexport type WithDefaults<request, defaults> = [keyof defaults] extends [never]\n ? request\n : LooseOmit<request, keyof defaults & string> &\n ExactPartial<Pick<request, keyof defaults & keyof request>>\n\n/**\n * Extends a method with client-side credential creation logic.\n *\n * @example\n * ```ts\n * import { Method } from 'mppx'\n * import { Methods } from 'mppx/tempo'\n *\n * const tempoCharge = Method.toClient(Methods.charge, {\n * async createCredential({ challenge }) {\n * return Credential.serialize({ challenge, payload: { ... } })\n * },\n * })\n * ```\n */\nexport function toClient<\n const method extends Method,\n const context extends z.ZodMiniType | undefined = undefined,\n>(method: method, options: toClient.Options<method, context>): Client<method, context> {\n const { context, createCredential } = options\n return {\n ...method,\n context,\n createCredential,\n } as Client<method, context>\n}\n\nexport declare namespace toClient {\n type Options<method extends Method, context extends z.ZodMiniType | undefined = undefined> = {\n context?: context\n createCredential: CreateCredentialFn<\n method,\n context extends z.ZodMiniType ? z.output<context> : Record<never, never>\n >\n }\n}\n\n/**\n * Extends a method with server-side verification logic.\n *\n * @example\n * ```ts\n * import { Method } from 'mppx'\n * import { Methods } from 'mppx/tempo'\n *\n * const tempoCharge = Method.toServer(Methods.charge, {\n * async verify({ credential }) {\n * // verification logic\n * return { status: 'success', ... }\n * },\n * })\n * ```\n */\nexport function toServer<\n const method extends Method,\n const defaults extends RequestDefaults<method> = {},\n const transportOverride extends Transport.AnyTransport | undefined = undefined,\n>(\n method: method,\n options: toServer.Options<method, defaults, transportOverride>,\n): Server<method, defaults, transportOverride> {\n const { defaults, request, respond, transport, verify } = options\n return {\n ...method,\n defaults,\n request,\n respond,\n transport,\n verify,\n } as Server<method, defaults, transportOverride>\n}\n\nexport declare namespace toServer {\n type Options<\n method extends Method,\n defaults extends RequestDefaults<method> = {},\n transportOverride extends Transport.AnyTransport | undefined = undefined,\n > = {\n defaults?: defaults | undefined\n request?: RequestFn<method> | undefined\n respond?: RespondFn<method> | undefined\n transport?: transportOverride | undefined\n verify: VerifyFn<method>\n }\n}\n","import { Base64 } from 'ox'\n\nimport * as z from './zod.js'\n\n/**\n * Schema for a payment receipt.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const receipt = Receipt.Schema.parse(data)\n * ```\n */\nexport const Schema = z.object({\n /** Payment method used (e.g., \"tempo\", \"stripe\"). */\n method: z.string(),\n /** Method-specific reference (e.g., transaction hash). */\n reference: z.string(),\n /** Optional external reference ID echoed from the credential payload. */\n externalId: z.optional(z.string()),\n /** Payment status. Always \"success\" — failures use 402 + Problem Details. */\n status: z.literal('success'),\n /** RFC 3339 settlement timestamp. */\n timestamp: z.datetime(),\n})\n\n/**\n * Payment receipt returned after verification.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const receipt: Receipt.Receipt = {\n * method: 'tempo',\n * status: 'success',\n * timestamp: new Date().toISOString(),\n * reference: '0x...',\n * }\n * ```\n */\nexport type Receipt = z.infer<typeof Schema>\n\n/**\n * Deserializes a Payment-Receipt header value to a receipt.\n *\n * @param encoded - The base64url-encoded header value.\n * @returns The deserialized receipt.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const receipt = Receipt.deserialize(encoded)\n * ```\n */\nexport function deserialize(encoded: string): Receipt {\n const json = Base64.toString(encoded)\n return from(JSON.parse(json))\n}\n\n/**\n * Creates a receipt from the given parameters.\n *\n * @param parameters - Receipt parameters.\n * @returns A receipt.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const receipt = Receipt.from({\n * method: 'tempo',\n * status: 'success',\n * timestamp: new Date().toISOString(),\n * reference: '0x...',\n * })\n * ```\n */\nexport function from(parameters: from.Parameters): Receipt {\n return Schema.parse(parameters)\n}\n\nexport declare namespace from {\n type Parameters = z.input<typeof Schema>\n}\n\n/**\n * Serializes a receipt to the Payment-Receipt header format.\n *\n * @param receipt - The receipt to serialize.\n * @returns A base64url-encoded string suitable for the Payment-Receipt header value.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const header = Receipt.serialize(receipt)\n * // => \"eyJzdGF0dXMiOiJzdWNjZXNzIiwidGltZXN0YW1wIjoi...\"\n * ```\n */\nexport function serialize(receipt: Receipt): string {\n const json = JSON.stringify(receipt)\n return Base64.fromString(json, { pad: false, url: true })\n}\n\n/**\n * Extracts the receipt from a Response's Payment-Receipt header.\n *\n * @param response - The HTTP response.\n * @returns The deserialized receipt.\n *\n * @example\n * ```ts\n * import { Receipt } from 'mppx'\n *\n * const response = await fetch('/resource', {\n * headers: { Authorization: Credential.serialize(credential) },\n * })\n * if (response.ok) {\n * const receipt = Receipt.fromResponse(response)\n * }\n * ```\n */\nexport function fromResponse(response: Response): Receipt {\n const header = response.headers.get('Payment-Receipt')\n if (!header) throw new Error('Missing Payment-Receipt header.')\n return deserialize(header)\n}\n","/**\n * Async key-value store interface.\n *\n * Modeled after Cloudflare KV's API (`get`/`put`/`delete`).\n * Implementations handle serialization internally.\n */\nimport { Json } from 'ox'\n\nexport type StoreItemMap = Record<string, unknown>\n\nexport type Store<itemMap extends StoreItemMap = StoreItemMap> = {\n get: <key extends keyof itemMap & string>(key: key) => Promise<itemMap[key] | null>\n put: <key extends keyof itemMap & string>(key: key, value: itemMap[key]) => Promise<void>\n delete: <key extends keyof itemMap & string>(key: key) => Promise<void>\n}\n\n/** Creates a {@link Store} from an existing implementation. */\nexport function from<store extends Store>(store: store): store {\n return store\n}\n\n/** Wraps a Cloudflare KV namespace. */\nexport function cloudflare(kv: cloudflare.Parameters): Store {\n return from({\n async get(key) {\n const raw = await kv.get(key)\n if (raw == null) return null as any\n return Json.parse(raw as string)\n },\n async put(key, value) {\n await kv.put(key, Json.stringify(value))\n },\n async delete(key) {\n await kv.delete(key)\n },\n })\n}\n\nexport declare namespace cloudflare {\n export type Parameters = {\n get: (key: string) => Promise<unknown>\n put: (key: string, value: string) => Promise<void>\n delete: (key: string) => Promise<void>\n }\n}\n\n/** In-memory store backed by a `Map`. JSON-roundtrips values to match production behavior. */\nexport function memory(): Store {\n const store = new Map<string, string>()\n return from({\n async get(key) {\n const raw = store.get(key)\n if (raw === undefined) return null as any\n return Json.parse(raw)\n },\n async put(key, value) {\n store.set(key, Json.stringify(value))\n },\n async delete(key) {\n store.delete(key)\n },\n })\n}\n\n/** Wraps a standard Redis client (ioredis, node-redis, Valkey). */\nexport function redis(client: redis.Parameters): Store {\n return from({\n async get(key) {\n const raw = await client.get(key)\n if (raw == null) return null as any\n return Json.parse(raw)\n },\n async put(key, value) {\n await client.set(key, Json.stringify(value))\n },\n async delete(key) {\n await client.del(key)\n },\n })\n}\n\nexport declare namespace redis {\n export type Parameters = {\n get: (key: string) => Promise<string | null>\n set: (key: string, value: string) => Promise<unknown>\n del: (key: string) => Promise<unknown>\n }\n}\n\n/** Wraps an Upstash Redis instance (e.g. Vercel KV). */\nexport function upstash(redis: upstash.Parameters): Store {\n return from({\n async get(key) {\n return (await redis.get(key)) as any\n },\n async put(key, value) {\n await redis.set(key, value)\n },\n async delete(key) {\n await redis.del(key)\n },\n })\n}\n\nexport declare namespace upstash {\n export type Parameters = {\n get: (key: string) => Promise<unknown>\n set: (key: string, value: unknown) => Promise<unknown>\n del: (key: string) => Promise<unknown>\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACGM,SAAU,kBAAkB,GAAW,GAAS;AACpD,QAAM,QAAQ,aAAK,OAAO,YAAI,WAAW,CAAC,CAAC;AAC3C,QAAM,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,IAAI,KAAK,OAAK;AAClB,YAAM,OAAO,IAAI,KAAK,aAAK,UAAU,KAAK,CAAC;IAC7C;IACA,MAAM,OAAO,KAAG;AACd,YAAM,OAAO,IAAI,GAAG;IACtB;GACD;AACH;AAWM,SAAU,QAAQC,QAAyB;AAC/C,SAAOD,MAAK;IACV,MAAM,IAAI,KAAG;AACX,aAAQ,MAAMC,OAAM,IAAI,GAAG;IAC7B;IACA,MAAM,IAAI,KAAK,OAAK;AAClB,YAAMA,OAAM,IAAI,KAAK,KAAK;IAC5B;IACA,MAAM,OAAO,KAAG;AACd,YAAMA,OAAM,IAAI,GAAG;IACrB;GACD;AACH;","names":["hash","base64","deserialize","from","fromMethod","meta","serialize","verify","json","from","meta","fromMethod","serialize","deserialize","verify","mac","deserialize","from","serialize","deserialize","json","from","serialize","from","verify","Schema","deserialize","from","fromResponse","serialize","Schema","deserialize","json","from","serialize","fromResponse","from","from","redis"]}
|
package/dist/index.js
CHANGED
|
@@ -35712,8 +35712,8 @@ function parseChallengeAmount(challenge) {
|
|
|
35712
35712
|
}
|
|
35713
35713
|
async function payWithMpp(args) {
|
|
35714
35714
|
const { signer, client, options } = args;
|
|
35715
|
-
const { Mppx } = await import("./client-
|
|
35716
|
-
const { sui, USDC } = await import("./client-
|
|
35715
|
+
const { Mppx } = await import("./client-QWWT5U25.js");
|
|
35716
|
+
const { sui, USDC } = await import("./client-WUGFY2SS.js");
|
|
35717
35717
|
const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-RHG6ARHV.js");
|
|
35718
35718
|
const signerAddress = signer.getAddress();
|
|
35719
35719
|
let paymentDigest;
|
|
@@ -44931,7 +44931,7 @@ async function runEstimate(url, opts) {
|
|
|
44931
44931
|
}
|
|
44932
44932
|
return;
|
|
44933
44933
|
}
|
|
44934
|
-
const { Challenge } = await import("./dist-
|
|
44934
|
+
const { Challenge } = await import("./dist-YCBO7GXC.js");
|
|
44935
44935
|
let challenge;
|
|
44936
44936
|
try {
|
|
44937
44937
|
challenge = Challenge.fromResponse(response);
|
|
@@ -45347,7 +45347,7 @@ function registerMcpStart(parent) {
|
|
|
45347
45347
|
parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
45348
45348
|
let mod2;
|
|
45349
45349
|
try {
|
|
45350
|
-
mod2 = await import("./dist-
|
|
45350
|
+
mod2 = await import("./dist-PMIMNN2H.js");
|
|
45351
45351
|
} catch {
|
|
45352
45352
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
45353
45353
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2000/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Agent Wallet for AI agents on Sui — gasless USDC + USDsui sends, Cetus swap, MPP paid API access, MCP integration, scriptable from any shell.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "^5",
|
|
46
46
|
"typescript-eslint": "^8.58.0",
|
|
47
47
|
"vitest": "^3",
|
|
48
|
-
"@t2000/mcp": "4.
|
|
49
|
-
"@t2000/sdk": "4.
|
|
48
|
+
"@t2000/mcp": "4.4.0",
|
|
49
|
+
"@t2000/sdk": "4.4.0"
|
|
50
50
|
},
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|