@t2000/cli 0.22.26 → 0.23.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.
Files changed (34) hide show
  1. package/README.md +11 -97
  2. package/dist/{ccip-JEEJV65M.js → ccip-XP27NGI7.js} +3 -3
  3. package/dist/{chunk-A5X4KG7U.js → chunk-3I6VJOM6.js} +210 -970
  4. package/dist/chunk-3I6VJOM6.js.map +1 -0
  5. package/dist/chunk-4N76GQCL.js +35382 -0
  6. package/dist/chunk-4N76GQCL.js.map +1 -0
  7. package/dist/{chunk-XOAZJ42V.js → chunk-DWOZSUBE.js} +588 -584
  8. package/dist/{chunk-XOAZJ42V.js.map → chunk-DWOZSUBE.js.map} +1 -1
  9. package/dist/chunk-EI3GHTKX.js +968 -0
  10. package/dist/chunk-EI3GHTKX.js.map +1 -0
  11. package/dist/{chunk-EEPD7SHV.js → chunk-TYYJRUQI.js} +15755 -15918
  12. package/dist/chunk-TYYJRUQI.js.map +1 -0
  13. package/dist/client-5KJQTN5X.js +84 -0
  14. package/dist/client-5KJQTN5X.js.map +1 -0
  15. package/dist/{client-R3NRAXMD.js → client-IXUBQ3HM.js} +334 -638
  16. package/dist/client-IXUBQ3HM.js.map +1 -0
  17. package/dist/{dist-NBWIWHHS.js → dist-E7HUP73Q.js} +5 -29
  18. package/dist/{dist-KJM2NT74.js → dist-W4Q4YXD7.js} +4200 -603
  19. package/dist/dist-W4Q4YXD7.js.map +1 -0
  20. package/dist/index.js +29 -1016
  21. package/dist/index.js.map +1 -1
  22. package/package.json +4 -5
  23. package/dist/chunk-3WKGZRWT.js +0 -77733
  24. package/dist/chunk-3WKGZRWT.js.map +0 -1
  25. package/dist/chunk-77SWBATH.js +0 -204
  26. package/dist/chunk-77SWBATH.js.map +0 -1
  27. package/dist/chunk-A5X4KG7U.js.map +0 -1
  28. package/dist/chunk-EEPD7SHV.js.map +0 -1
  29. package/dist/client-CK5OR2TP.js +0 -746
  30. package/dist/client-CK5OR2TP.js.map +0 -1
  31. package/dist/client-R3NRAXMD.js.map +0 -1
  32. package/dist/dist-KJM2NT74.js.map +0 -1
  33. /package/dist/{ccip-JEEJV65M.js.map → ccip-XP27NGI7.js.map} +0 -0
  34. /package/dist/{dist-NBWIWHHS.js.map → dist-E7HUP73Q.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_c4e524ef2c460fde6664b2d190f6f806/node_modules/mppx/src/PaymentRequest.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_c4e524ef2c460fde6664b2d190f6f806/node_modules/mppx/src/zod.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_c4e524ef2c460fde6664b2d190f6f806/node_modules/mppx/src/Challenge.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_c4e524ef2c460fde6664b2d190f6f806/node_modules/mppx/src/Credential.ts","../../../node_modules/.pnpm/mppx@0.4.9_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_c4e524ef2c460fde6664b2d190f6f806/node_modules/mppx/src/Method.ts","../../mpp-sui/src/method.ts","../../mpp-sui/src/utils.ts","../../mpp-sui/src/client.ts"],"sourcesContent":["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, 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 } 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","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 { Method, z } from 'mppx';\n\nexport const suiCharge = Method.from({\n intent: 'charge',\n name: 'sui',\n schema: {\n credential: {\n payload: z.object({\n digest: z.string(),\n }),\n },\n request: z.object({\n amount: z.string(),\n currency: z.string(),\n recipient: z.string(),\n }),\n },\n});\n","import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';\n\nexport const SUI_USDC_TYPE =\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';\n\n/**\n * Fetch ALL coins of a given type, handling Sui pagination (max 50 per page).\n */\nexport interface CoinInfo {\n coinObjectId: string;\n balance: string;\n}\n\nexport async function fetchCoins(\n client: SuiJsonRpcClient,\n owner: string,\n coinType: string,\n): Promise<CoinInfo[]> {\n const coins: CoinInfo[] = [];\n let cursor: string | null | undefined;\n let hasNext = true;\n while (hasNext) {\n const page = await client.getCoins({ owner, coinType, cursor: cursor ?? undefined });\n coins.push(...page.data.map((c) => ({ coinObjectId: c.coinObjectId, balance: c.balance })));\n cursor = page.nextCursor;\n hasNext = page.hasNextPage;\n }\n return coins;\n}\n\n/**\n * Parse a string amount to raw bigint units without floating-point math.\n * \"0.01\" with 6 decimals → 10000n\n */\nexport function parseAmountToRaw(amount: string, decimals: number): bigint {\n const [whole = '0', frac = ''] = amount.split('.');\n const paddedFrac = frac.padEnd(decimals, '0').slice(0, decimals);\n return BigInt(whole + paddedFrac);\n}\n","import { Method, Credential } from 'mppx';\nimport type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { suiCharge } from './method.js';\nimport { fetchCoins, parseAmountToRaw } from './utils.js';\n\nexport { suiCharge } from './method.js';\nexport { SUI_USDC_TYPE } from './utils.js';\n\nexport interface TransactionSigner {\n getAddress(): string;\n signTransaction(txBytes: Uint8Array): Promise<{ signature: string }>;\n}\n\nexport interface SuiChargeOptions {\n client: SuiJsonRpcClient;\n signer: TransactionSigner;\n /** Override transaction execution (e.g. to route through a gas manager). */\n execute?: (tx: Transaction) => Promise<{ digest: string; effects: unknown }>;\n}\n\nexport function sui(options: SuiChargeOptions) {\n const address = options.signer.getAddress();\n\n return Method.toClient(suiCharge, {\n async createCredential({ challenge }) {\n const { amount, currency, recipient } = challenge.request;\n const amountRaw = parseAmountToRaw(amount, 6);\n\n const coins = await fetchCoins(options.client, address, currency);\n if (coins.length === 0) {\n throw new Error(\n `No ${currency.split('::').pop()} balance to pay with`,\n );\n }\n\n const totalBalance = coins.reduce(\n (sum, c) => sum + BigInt(c.balance),\n 0n,\n );\n if (totalBalance < amountRaw) {\n const available = Number(totalBalance) / 1e6;\n const requested = Number(amountRaw) / 1e6;\n throw new Error(\n `Not enough USDC to pay $${requested.toFixed(2)} (available: $${available.toFixed(2)})`,\n );\n }\n\n const tx = new Transaction();\n tx.setSender(address);\n\n const primaryCoin = tx.object(coins[0].coinObjectId);\n if (coins.length > 1) {\n tx.mergeCoins(\n primaryCoin,\n coins.slice(1).map((c) => tx.object(c.coinObjectId)),\n );\n }\n\n const [payment] = tx.splitCoins(primaryCoin, [amountRaw]);\n tx.transferObjects([payment], recipient);\n\n let result;\n try {\n if (options.execute) {\n result = await options.execute(tx);\n } else {\n tx.setSender(address);\n const built = await tx.build({ client: options.client });\n const { signature } = await options.signer.signTransaction(built);\n result = await options.client.executeTransactionBlock({\n transactionBlock: built,\n signature,\n options: { showEffects: true },\n });\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`Payment transaction failed: ${msg}`);\n }\n\n return Credential.serialize({\n challenge,\n payload: { digest: result.digest },\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCM,SAAU,YAAY,SAAe;AACzC,QAAMA,QAAO,eAAO,SAAS,OAAO;AACpC,SAAO,KAAK,MAAMA,KAAI;AACxB;AAiEM,SAAU,UAAU,SAAgB;AACxC,QAAMC,QAAO,aAAK,aAAa,OAAO;AACtC,SAAO,eAAO,WAAWA,OAAM,EAAE,KAAK,OAAO,KAAK,KAAI,CAAE;AAC1D;;;AC3GA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKM,SAAU,SAAM;AACpB,SAAO,iBAAE,OAAM,EAAG,MAAM,iBAAE,MAAM,iBAAiB,gBAAgB,CAAC;AACpE;AAGM,SAAU,WAAQ;AACtB,SAAO,iBAC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MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,cAAM,IAAI,MAAM,+BAA+B,GAAG,EAAE;MACtD;AAEA,aAAO,mBAAW,UAAU;QAC1B;QACA,SAAS,EAAE,QAAQ,OAAO,OAAA;MAAO,CAClC;IACH;EAAA,CACD;AACH;","names":["json","json","deserialize","serialize","deserialize","json","serialize","from","amount","address","Method","signature"]}