@stridge/pay-sdk 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_internal/coordinator.cjs +16 -8
- package/dist/cjs/_internal/coordinator.cjs.map +1 -1
- package/dist/cjs/_internal/coordinator.d.cts +12 -9
- package/dist/cjs/{guards-CYx283Oo.d.cts → guards-CQWGp5eP.d.cts} +12 -2
- package/dist/cjs/{guards-VkTvdL1L.cjs → guards-r1nnLHLD.cjs} +23 -1
- package/dist/cjs/guards-r1nnLHLD.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/_internal/coordinator.d.ts +12 -9
- package/dist/esm/_internal/coordinator.js +15 -9
- package/dist/esm/_internal/coordinator.js.map +1 -1
- package/dist/esm/{guards-CYx283Oo.d.ts → guards-CQWGp5eP.d.ts} +12 -2
- package/dist/esm/{guards-Cb0lVKgT.js → guards-CukG42GQ.js} +12 -2
- package/dist/esm/guards-CukG42GQ.js.map +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/guards-VkTvdL1L.cjs.map +0 -1
- package/dist/esm/guards-Cb0lVKgT.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards-CukG42GQ.js","names":["EMPTY_KEYS"],"sources":["../../src/encoding/utf8.ts","../../src/protocol/constants.ts","../../src/protocol/codec.ts","../../src/protocol/shape.ts","../../src/protocol/pay.ts","../../src/protocol/guards.ts"],"sourcesContent":["/**\n * Encodes a string as UTF-8 bytes. These are the exact bytes a signature covers and the relay forwards, so every\n * signing and relay-body helper goes through here rather than through `btoa` or a Latin-1 shortcut.\n *\n * A lone surrogate becomes U+FFFD, as `TextEncoder` defines. `JSON.stringify` never produces one, so a body built\n * with it round-trips exactly.\n */\nexport function utf8ToBytes(text: string): Uint8Array<ArrayBuffer> {\n return new TextEncoder().encode(text);\n}\n\n/**\n * Decodes UTF-8 bytes into a string, refusing malformed input rather than replacing it.\n *\n * @throws {TypeError} when `bytes` is not well-formed UTF-8.\n */\nexport function bytesToUtf8(bytes: Uint8Array): string {\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n}\n","/**\n * The literal protocol tag every app↔hub message carries. Anything posted to the window without it is not ours.\n */\nexport const PAY_PROTOCOL = \"stridge-sua\";\n\n/**\n * The protocol version this SDK speaks. A message with another version is rejected by the message guards.\n */\nexport const SUA_PROTOCOL_VERSION = 1;\n\n/**\n * The longest correlation id the guards accept, in UTF-16 code units.\n */\nexport const MAX_MESSAGE_ID_LENGTH = 128;\n\n/**\n * The longest message a sign request may carry, in **UTF-8 bytes** (a CJK character is 3, an emoji 4). It bounds what\n * the hub renders and relays: the Coordinator caps a request body at 64 KiB, and the relay body carries the payload\n * as hex (2 characters a byte) inside base64 (4 characters for 3). At this limit, with an EIP-191 prefix and the\n * stamp, the relay request stays near 45 KB, well under the cap.\n */\nexport const MAX_SIGN_MESSAGE_BYTES = 16384;\n\n/**\n * The longest `error.message` the guards accept.\n */\nexport const MAX_ERROR_MESSAGE_LENGTH = 1024;\n\n/**\n * The longest label the Pay element guards accept, in UTF-16 code units. An empty label is valid; the renderer owns\n * any accessibility fallback.\n */\nexport const MAX_ELEMENT_LABEL_LENGTH = 1024;\n\n/** The most wallets one link C `pay-source-funds` names. */\nexport const MAX_PAY_SOURCE_FUNDS_WALLETS = 20;\n\n/**\n * The longest app origin the relay guards accept, in UTF-16 code units.\n */\nexport const MAX_APP_ORIGIN_LENGTH = 2048;\n\n/**\n * The longest app page address (`element-page-url` and its forwards) the guards accept, in UTF-16 code units. A bound\n * for validation, not a browser limit.\n */\nexport const MAX_PAGE_URL_LENGTH = 8192;\n\n/**\n * The tallest block size a Pay element may report, in CSS pixels. A bound for validation, not a measured browser\n * limit.\n */\nexport const MAX_ELEMENT_BLOCK_SIZE = 16384;\n\n/**\n * The longest resize animation a Pay element may report, in milliseconds.\n */\nexport const MAX_ELEMENT_RESIZE_DURATION_MS = 10000;\n\n/**\n * The geometry easing identifiers. `standard` means `cubic-bezier(0.4, 0, 0.2, 1)`; arbitrary CSS is never accepted.\n */\nexport const SUA_ELEMENT_GEOMETRY_EASINGS = {\n standard: \"standard\",\n} as const;\n\n/**\n * The largest magnitude of any menu rect coordinate or size, in CSS pixels. A bound for validation, not a measured\n * browser limit.\n */\nexport const MAX_MENU_RECT_VALUE = 1000000;\n\n/**\n * An app id: `app_` and a 26-character Crockford base32 ULID in **uppercase only**, whose first character is `0`–`7`\n * (it carries 3 bits; anything above `7` overflows 128 bits). The Coordinator's `pkg/id/id.go` refuses a lowercase\n * id and an overflowing one, and answers every call that carries one with `403 APP_SUSPENDED`.\n */\nexport const APP_ID_PATTERN = /^app_[0-7][0-9A-HJKMNP-TV-Z]{25}$/;\n\n/**\n * A hub frame name, as `element-init`'s `hubFrame` and the Pay element URL's `hubFrame` hint carry it: an ASCII letter\n * or digit, then ASCII letters, digits, `_` or `-`. The first character excludes the reserved underscore-prefixed\n * browsing-context names such as `_top`. A reader checks the length bound, 1 to {@link MAX_MESSAGE_ID_LENGTH}\n * characters, first, so a huge string never reaches the pattern.\n */\nexport const HUB_FRAME_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;\n\n/**\n * An EVM address: `0x` and 40 hex digits, any case.\n */\nexport const EVM_ADDRESS_PATTERN = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The `message` of the `internal` error a framed hub page answers a request with when the request belongs in the Sua\n * window: the frame cannot reach the hub's first-party storage, so it can open no round and register no keypair. It\n * is the one `error.message` the app reads: on it, the app sends its next request to the Pay window. The code stays\n * `internal`, so an app that does not know the value reads it as an internal error. Never rename it: the app and the\n * hub ship apart, and a renamed value silently stops the switch.\n */\nexport const HUB_NEEDS_POPUP_MESSAGE = \"needs-popup\";\n\n/**\n * The wire type of the Fund request (app → hub): open Fund in the hub's Stridge Wallet dialog. Never rename it: the\n * app and the hub ship apart, and a hub that does not know the value drops the request.\n */\nexport const PAY_FUND_REQUEST_TYPE = \"fund\";\n\n/**\n * The screens a Fund request may start on, as its `start` carries them. `FundStartScreen` derives from this object.\n *\n * - `home` — the account home.\n * - `fund` — the Fund surface. A missing `start` means this one.\n */\nexport const PAY_FUND_START_SCREENS = {\n home: \"home\",\n fund: \"fund\",\n} as const;\n\n/** Fund ownership notices shared by the app and hub across independently deployed versions. */\nexport const PAY_FUND_MESSAGE_TYPES = {\n received: \"fund-received\",\n cancel: \"fund-cancel\",\n} as const;\n\n/**\n * The query parameters of the hub page's URL: the app sets them on the configured hub URL when it builds the\n * iframe's `src` and the Pay window's URL, and the hub page reads them. Never rename one: the app and the hub ship\n * apart.\n *\n * - `theme` — the colour scheme the hub page paints before `init` arrives. Cosmetic only.\n * - `surface` — {@link HUB_SURFACE_POPUP} marks the page as the Pay window.\n * - `app`, `origin` — the app id and the app page's origin, which the Pay window uses only to pick where its `ready`\n * goes, and only when its registry lists that origin for that app. Untrusted: `init` is checked as in a frame.\n * - `hubFrame` — the name of the app's hub frame, a discovery hint for the Pay element. It authorizes no peer.\n *\n * A missing, repeated or conflicting hint never selects another app.\n */\nexport const HUB_URL_PARAMS = {\n theme: \"theme\",\n surface: \"surface\",\n app: \"app\",\n origin: \"origin\",\n hubFrame: \"hubFrame\",\n} as const;\n\n/**\n * The value of the `surface` query parameter (`HUB_URL_PARAMS.surface`) that marks the hub page as the Pay window.\n */\nexport const HUB_SURFACE_POPUP = \"popup\";\n\n/**\n * The value of the `surface` query parameter (`HUB_URL_PARAMS.surface`) that marks the hub page as a Pay element.\n */\nexport const HUB_SURFACE_ELEMENT = \"element\";\n\n/**\n * The fixed route of the Pay element on the hub origin.\n */\nexport const PAY_ELEMENT_PATH = \"/elements/pay\";\n\n/**\n * The failure codes a Pay element adds to `HubErrorCode` on `failed`. `ElementFailureCode` derives from this object.\n * No hub sends them, so `HubErrorCode` stays as it is.\n *\n * - `unavailable` — the hub never completed the handshake, or reloaded while the request was in flight.\n * - `popup-blocked` — the browser refused to open the Pay window the Pay element opens from the user's click.\n */\nexport const PAY_ELEMENT_FAILURE_CODES = {\n unavailable: \"unavailable\",\n popupBlocked: \"popup-blocked\",\n} as const;\n\n/** Closed pay wire vocabulary and input bounds. */\nexport const PAY_JOBS = [\"pay\", \"deposit\"] as const;\nexport const PAY_CURRENCIES = [\"USD\"] as const;\n/**\n * The first steps a chosen-amount Deposit's Pay window may take: ask the `amount` (the default) or the `method`. Only\n * `method` travels on the wire; a request without `firstStep` asks the amount first.\n */\nexport const PAY_FIRST_STEPS = [\"amount\", \"method\"] as const;\nexport const PAY_AMOUNT_PATTERN = /^(?:0|[1-9]\\d{0,8})(?:\\.\\d{1,2})?$/;\nexport const MAX_PAY_AMOUNT = \"100000.00\";\nexport const MAX_PAY_ITEM_LENGTH = 64;\n/**\n * The longest payout address a pay request carries, in UTF-16 code units. The wire only bounds the string; the hub\n * decides whether it is a usable address.\n */\nexport const MAX_PAY_PAYOUT_ADDRESS_LENGTH = 128;\n/**\n * A checkout rule id a pay request may name as its `destination`: `ckr_`, then 1 to 60 ASCII letters or digits. The\n * wire checks only the shape; whether the app has the rule is the Coordinator's answer.\n */\nexport const PAY_DESTINATION_RULE_PATTERN = /^ckr_[0-9A-Za-z]{1,60}$/;\n/**\n * The asset of a pay request's destination address: a CAIP-19 id on an `eip155` chain (an asset namespace of 3 to 8\n * lowercase letters, digits or hyphens, then a reference of 1 to 128 letters, digits, hyphens, dots or `%`). The wire\n * checks only the shape; the hub decides whether the asset is listed and payable.\n */\nexport const PAY_DESTINATION_ASSET_PATTERN = /^eip155:[1-9][0-9]{0,31}\\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/;\nexport const PAY_MESSAGE_TYPES = {\n payRequest: \"element-pay-request\",\n /**\n * A Deposit whose amount the user chooses in the window, within the app's optional limits. It is its own type, not\n * optional keys on `element-pay-request`, so an element from before it drops this message alone.\n */\n depositRequest: \"element-deposit-request\",\n payRequestAck: \"element-pay-request-ack\",\n paid: \"element-paid\",\n checkoutResult: \"element-checkout-result\",\n held: \"element-held\",\n unconfirmed: \"element-unconfirmed\",\n} as const;\nexport const SUA_PAY_REQUEST_TYPE = \"pay\";\n\nexport const PAY_ELEMENT_MESSAGE_TYPES = {\n payRequest: PAY_MESSAGE_TYPES.payRequest,\n depositRequest: PAY_MESSAGE_TYPES.depositRequest,\n payRequestAck: PAY_MESSAGE_TYPES.payRequestAck,\n init: \"element-init\",\n config: \"element-config\",\n focus: \"focus\",\n ready: \"element-ready\",\n accepted: \"element-accepted\",\n refused: \"element-refused\",\n configAck: \"element-config-ack\",\n resize: \"resize\",\n signed: \"signed\",\n failed: \"failed\",\n menuAnchor: \"menu-anchor\",\n menuEnded: \"element-menu-ended\",\n checkStatusCapability: \"element-check-status-capability\",\n checkStatusSettled: \"element-check-status-settled\",\n\n pageUrl: \"element-page-url\",\n geometryCapabilities: \"element-geometry-capabilities\",\n geometryTarget: \"element-geometry-target\",\n geometryComplete: \"element-geometry-complete\",\n geometryCancelled: \"element-geometry-cancelled\",\n} as const;\n\n/**\n * Pay element → app notifications on link B. Only `checkStatusRequest` has a reply.\n *\n * - `connected` — a connected address the element observed over link C.\n * - `viewShown` — the element's real view is on screen, in place of its placeholder.\n * - `loadFailed` — the view the element shows is a load failure, with a {@link PAY_ELEMENT_LOAD_FAILURE_REASONS} value.\n * - `checkStatusRequest` — request to check a spent attempt; the app answers with `element-check-status-settled`\n * and the same envelope id and correlation payload when its check finishes, including failure.\n *\n * The element posts one of `viewShown` and `loadFailed` after the `resize` for the view it revealed, and again only\n * when the view turns from one to the other. An app that predates them drops them as unknown types.\n */\nexport const PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES = {\n paid: PAY_MESSAGE_TYPES.paid,\n\n connected: \"element-connected\",\n viewShown: \"element-view-shown\",\n loadFailed: \"element-load-failed\",\n checkStatusRequest: \"element-check-status-request\",\n} as const;\n\n/**\n * Why the view a Pay element shows is a load failure, as `element-load-failed` carries it.\n * `PayElementLoadFailureReason` derives from this object.\n *\n * - `hub-frame` — link C, the element's link to the app's hub frame, failed for this document.\n * - `internal` — the element failed to load for a reason of its own.\n */\nexport const PAY_ELEMENT_LOAD_FAILURE_REASONS = {\n hubFrame: \"hub-frame\",\n internal: \"internal\",\n} as const;\n\n/**\n * The message types the app and its hub frame add to the existing app↔hub messages. `overlayHidden` is also reused\n * from hub frame to initiating element on link C, with that operation's id.\n */\nexport const PAY_HUB_FRAME_MESSAGE_TYPES = {\n diagnosticsSubscribe: \"diagnostics-subscribe\",\n diagnosticsUnsubscribe: \"diagnostics-unsubscribe\",\n diagnosticsStatus: \"diagnostics-status\",\n diagnosticsInspect: \"diagnostics-inspect\",\n diagnosticsDetails: \"diagnostics-details\",\n diagnosticsDisconnect: \"diagnostics-disconnect\",\n activity: \"activity\",\n showMenu: \"show-menu\",\n menuAccepted: \"menu-accepted\",\n menuRefused: \"menu-refused\",\n menuEnded: \"menu-ended\",\n overlayHidden: \"overlay-hidden\",\n} as const;\n\n/**\n * The handshake message types between a Pay element and the Pay window it opens. The Pay window sends `build`, its\n * own build id, immediately before `accepted` with the same id, so the Pay element can trust a sign's release code only\n * from a Pay window that runs its own build.\n */\nexport const SUA_RELAY_MESSAGE_TYPES = {\n init: \"relay-init\",\n accepted: \"relay-accepted\",\n refused: \"relay-refused\",\n build: \"relay-build\",\n} as const;\n\n/**\n * The message types between a Pay element and its hub frame (link C), in both directions. The Pay element sends\n * `probe`, `attach`, `confirm`, `detach`, `windowOpened`, `windowResult`, `windowError`, `windowEnded`,\n * `windowState` and `pageUrl`; the hub frame sends the others. Link C also reuses the six ceremony requests, `state`, `transport`,\n * `activity`, `result`, `error` and `overlay-hidden`, with their payloads unchanged.\n */\nexport const SUA_LINK_C_MESSAGE_TYPES = {\n paySource: \"pay-source\",\n /**\n * The first wallet saved to the signed-in account, beside a `pay-source` that names the Stridge Wallet: the card\n * shows it in the account's place when the balance does not cover the amount.\n */\n paySourceSaved: \"pay-source-saved\",\n /**\n * Says that the `pay-source` and `pay-source-saved` before it on the same stream are the hub frame's current pick,\n * read from the session and the hub's own storage, as a Pay window reads it. A hub frame that only reports never\n * sends it, so the card keeps its own record of the last pick.\n */\n paySourceCurrent: \"pay-source-current\",\n /**\n * The money of the wallets the card may show for the current `pay-source`: the picked wallet, or the wallets saved\n * to the signed-in account beside a Stridge Wallet pick. The hub never knows the amount, so the card weighs it: a\n * wallet that covers it stands in for a Stridge Wallet balance that does not. Display only.\n */\n paySourceFunds: \"pay-source-funds\",\n menuPayment: \"menu-payment\",\n payOwner: \"pay-owner\",\n payProgress: \"pay-progress\",\n /**\n * The hub's proof, sent right after a failed `pay-progress` that allows a retry, that this payment was never sent:\n * `progressId` names that `pay-progress` envelope. Only then may the card say \"No money moved\".\n */\n payUnsent: \"pay-unsent\",\n checkoutResult: \"checkout-result\",\n /**\n * The wallet that paid a guest checkout in full, by its brand, so the card leads its paid row with that wallet's\n * logo. Display only.\n */\n checkoutWallet: \"checkout-wallet\",\n /**\n * A guest checkout the hub holds in storage for a payment, sent before its Coordinator read answers: Pay on that\n * payment reopens the checkout and starts no new one. `request` `null` says the hub holds it no longer.\n */\n checkoutHeld: \"checkout-held\",\n probe: \"hub-probe\",\n probeAck: \"hub-probe-ack\",\n attach: \"attach\",\n accepted: \"attach-accepted\",\n refused: \"attach-refused\",\n confirm: \"attach-confirm\",\n detach: \"detach\",\n balance: \"balance\",\n windowOpened: \"window-opened\",\n windowAccepted: \"window-accepted\",\n windowRefused: \"window-refused\",\n windowResult: \"window-result\",\n windowError: \"window-error\",\n windowEnded: \"window-ended\",\n windowCancel: \"window-cancel\",\n windowState: \"window-state\",\n\n pageUrl: \"page-url\",\n /**\n * The method the card's source row showed when the person pressed Pay, for the `pay` the element sends right after\n * it: the Pay window opens that method and never decides another one itself.\n */\n payShown: \"pay-shown\",\n} as const;\n\n/**\n * Why a Pay window that a Pay element opened ended, as `window-ended` reports it. `SuaWindowEndCause` derives from\n * this object.\n *\n * - `settled` — the ceremony finished and the window closed.\n * - `window-cancel` — \"Cancel\" on the hub frame's backdrop closed it.\n * - `window-lost` — the user closed the window, or it was lost.\n * - `teardown` — the provider or the Pay element went away.\n */\nexport const SUA_WINDOW_END_CAUSES = {\n settled: \"settled\",\n windowCancel: \"window-cancel\",\n windowLost: \"window-lost\",\n teardown: \"teardown\",\n} as const;\n\n/**\n * Why the hub frame asks a Pay element to close the Pay window it owns, as `window-cancel` and link E's\n * `relay-close` carry it. `SuaWindowCancelCause` derives from this object; each value is also a\n * {@link SUA_WINDOW_END_CAUSES} value.\n */\nexport const SUA_WINDOW_CANCEL_CAUSES = {\n windowCancel: \"window-cancel\",\n teardown: \"teardown\",\n} as const;\n\n/**\n * The longest hub build id link C carries, in characters: ASCII letters, digits, `_` or `-`, starting with a letter or\n * digit. The build-id source emits a UUID.\n */\nexport const MAX_HUB_BUILD_ID_LENGTH = 128;\n\n/**\n * A hub build id, as link C's `attach-accepted` and `attach-confirm` and link E's `relay-build` carry it and the hub\n * page's build marker emits it:\n * an ASCII letter or digit, then ASCII letters, digits, `_` or `-`. A reader checks the length bound, 1 to\n * {@link MAX_HUB_BUILD_ID_LENGTH} characters, first, so a huge string never reaches the pattern.\n */\nexport const HUB_BUILD_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;\n\n/**\n * The longest link C balance amount, in characters: `2^256 - 1` base units as dollars with six decimals.\n */\nexport const MAX_HUB_BALANCE_AMOUNT_LENGTH = 79;\n\n/**\n * The separator of a namespaced link C id, `<attachmentId>:<nonce>`. A 36-character attachment id, the separator and a\n * nonce of at most 91 characters fit {@link MAX_MESSAGE_ID_LENGTH}. The guards check only the ordinary id; the link\n * checks the namespace.\n */\nexport const SUA_LINK_C_ID_SEPARATOR = \":\";\n\n/**\n * The nonce prefixes of link C's ordered streams. A stream message's id is `<attachmentId>:<prefix><sequence>`, the\n * sequence a canonical decimal from 1 that each stream counts on its own per attachment.\n */\nexport const SUA_LINK_C_STREAM_PREFIXES = {\n state: \"s_\",\n transport: \"t_\",\n activity: \"a_\",\n balance: \"b_\",\n} as const;\n\n/**\n * The graceful-close and ordered-state message types a Pay element and the Pay window it opened add to link E.\n */\nexport const SUA_RELAY_CONTROL_MESSAGE_TYPES = {\n close: \"relay-close\",\n closeAccepted: \"relay-close-accepted\",\n state: \"relay-state\",\n /** The Pay window's `pay-progress` for the element that opened it, on the operation's own stream (R1-05). */\n payOwner: \"relay-pay-owner\",\n payProgress: \"relay-pay-progress\",\n /** Link C's `pay-unsent`, naming the `relay-pay-progress` it proves by its sequence. */\n payUnsent: \"relay-pay-unsent\",\n checkoutResult: \"relay-checkout-result\",\n /** Link C's `checkout-wallet`, on the operation's pay stream. */\n checkoutWallet: \"relay-checkout-wallet\",\n\n /** The app page's address for the `pay` the element relays next: the element sends it right before. */\n pageUrl: \"relay-page-url\",\n /**\n * The source the Pay window picks for the person it serves, for the card of the element that opened it, on the\n * operation's pay stream with `relay-pay-progress`.\n */\n paySource: \"relay-pay-source\",\n /** The first saved wallet beside the Pay window's account pick, as link C's `pay-source-saved`, on the same stream. */\n paySourceSaved: \"relay-pay-source-saved\",\n /** Link C's `pay-shown`, for the `pay` the element relays right after it. */\n payShown: \"relay-pay-shown\",\n} as const;\n\n/**\n * The message type an app-owned Pay window (the hub page at the root with `surface=popup`, opened by the app page)\n * posts to the app's hub frame, both on the hub's origin. `state` carries the window's state, ordered per window\n * document, so a hub frame that only reports keeps its display-only connected copy in step with a sign-in, a sign-out\n * or a switch of account the app's own Pay window ran. The app page never sends it: only a hub-origin document can post\n * at the hub's origin, and the hub frame checks the sender's document before it reads the data.\n */\nexport const SUA_APP_WINDOW_MESSAGE_TYPES = {\n state: \"app-window-state\",\n} as const;\n\n/**\n * The private account-email messages between Stridge-origin documents: one report per authenticated route a hub frame\n * that only reports learns its state on, and the refresh request and reply of the app-owned route. Each report carries\n * the account the sending Pay window shows (its identity, address and email) or `null` to clear it, beside the public\n * state stream it refers to. They are new types, never new fields on `relay-state`, `window-state` or\n * `app-window-state`, so a peer that predates them drops only them; they never reach an app page, an app hook or an app\n * event.\n *\n * - `relay` — a Pay window → the Pay element or hub frame that opened it (link E), beside `relay-state`.\n * - `window` — a Pay element → its confirmed hub frame attachment (link C), forwarding a `relay` report, beside\n * `window-state`.\n * - `appWindow` — an app-owned Pay window → the app page's hub frames, beside `app-window-state`.\n * - `appWindowRefresh` — a hub frame → the app-owned Pay window whose state it shows: asks it to read its session again\n * now (the frame's menu opened, or the frame gained focus). Never to the app page that opened the window.\n * - `appWindowRefreshReply` — that Pay window → the asking hub frame only: the account after a session read that\n * answered after the request, and that read's time.\n */\nexport const SUA_ACCOUNT_EMAIL_MESSAGE_TYPES = {\n relay: \"relay-account-email\",\n window: \"window-account-email\",\n appWindow: \"app-window-account-email\",\n appWindowRefresh: \"app-window-account-email-refresh\",\n appWindowRefreshReply: \"app-window-account-email-refresh-reply\",\n} as const;\n\n/**\n * The longest identity id an account-email report carries, in characters. A defensive wire bound, not a format rule.\n */\nexport const MAX_ACCOUNT_IDENTITY_LENGTH = 256;\n\n/**\n * The longest email an account-email report carries, in characters. A defensive wire bound: a well-formed email is no\n * proof of ownership.\n */\nexport const MAX_ACCOUNT_EMAIL_LENGTH = 320;\n\n/**\n * The longest time an account-email report may be shown, in milliseconds: a report's `validUntil` is at most this long\n * after the sender's last authenticated session read and never after the session's known expiry (a sender with no\n * fresh read reports `account: null`), and a receiver drops a report whose `validUntil` lies further ahead of its own\n * clock.\n */\nexport const MAX_ACCOUNT_EMAIL_LEASE_MS = 5 * 60_000;\n\n/**\n * The longest keypair expiry the ordered state wrappers (`relay-state`, `window-state`, `app-window-state`) accept, in\n * characters. The\n * existing `state` keeps its own rule.\n */\nexport const MAX_RELAY_STATE_EXPIRY_LENGTH = 64;\n\n/**\n * The lifetime message types an app and a Pay element add to links A and B: the per-config action eligibility check\n * and the element-only reload request. The Pay element sends `actionCheck` and `reloadRequest`; the app answers.\n */\nexport const PAY_ELEMENT_LIFETIME_MESSAGE_TYPES = {\n actionCheck: \"element-action-check\",\n actionEligibility: \"element-action-eligibility\",\n reloadRequest: \"element-reload-request\",\n reloadGrant: \"element-reload-grant\",\n} as const;\n\n/**\n * Why a Pay element asks the app for its one reload. `SuaElementReloadReason` derives from this object.\n *\n * - `build-mismatch` — the hub frame runs another hub build than the Pay element.\n */\nexport const SUA_ELEMENT_RELOAD_REASONS = {\n buildMismatch: \"build-mismatch\",\n} as const;\n\n/**\n * The cookie on the hub's origin that holds the session's `csrf_token`: the hub proxy writes it beside the session\n * cookie, and the hub page reads it. It is not part of the app↔hub channel; it lives here so the proxy, which runs on\n * the server, and the hub page share one spelling. The `__Host-` prefix makes the browser refuse it unless it is\n * `Secure`, `Path=/` and host-only, so no sibling subdomain can plant one.\n */\nexport const HUB_CSRF_COOKIE_NAME = \"__Host-sua_csrf\";\n\n/**\n * The Coordinator's guest cookie for a page with unpartitioned cookie access: a top-level hub page, or a hub frame with\n * storage access. `HttpOnly`; the hub proxy passes it both ways and hub script never reads it. A login takes this\n * guest in and clears the cookie.\n */\nexport const HUB_GUEST_COOKIE_NAME = \"__Host-sua_gid\";\n\n/**\n * The Coordinator's guest cookie for a partitioned hub frame (`Partitioned`, so one per top-level site). The hub opens\n * no guest in such a frame; the proxy still passes the cookie both ways, so a guest the backend scopes there keeps\n * working.\n */\nexport const HUB_PARTITIONED_GUEST_COOKIE_NAME = \"__Host-sua_pgid\";\n\n/**\n * The request header that names the guest cookie a guest write uses (`unpartitioned` or `partitioned`). The guest open\n * states it in its body instead.\n */\nexport const GUEST_COOKIE_ACCESS_HEADER = \"X-Stridge-Cookie-Access\";\n\n/**\n * The request header a session call with `omitCredentials` sends, with the value {@link SESSION_HEADER_OMIT}. The\n * hub proxy then drops the session cookie `__Host-sua_session` from what it forwards and keeps every other Coordinator\n * cookie. It never forwards this header.\n */\nexport const SESSION_HEADER = \"X-Stridge-Session\";\n\n/**\n * The value of {@link SESSION_HEADER} that tells the hub proxy to drop the session cookie.\n */\nexport const SESSION_HEADER_OMIT = \"omit\";\n\n/** One-use guest code on the accepted hub-to-window relay. */\nexport const SUA_GUEST_HANDOFF_MESSAGE_TYPE = \"relay-guest-handoff\";\n\n/** Private hub-frame continuation of an already pending Fund request. */\nexport const SUA_FUND_WINDOW_MESSAGE_TYPE = \"relay-fund-continuation\";\n","import { PAY_PROTOCOL, SUA_PROTOCOL_VERSION } from \"./constants\";\n\nimport type {\n AppElementDepositRequestMessage,\n AppElementPayRequestMessage,\n HubAppElementDepositRequestMessage,\n HubAppElementPayRequestMessage,\n HubElementCheckoutHeldMessage,\n HubElementCheckoutHeldPayload,\n HubElementCheckoutResultMessage,\n HubElementCheckoutResultPayload,\n HubElementPayProgressMessage,\n HubElementPayProgressPayload,\n HubPayRequestMessage,\n HubPayRequestPayload,\n WindowRelayCheckoutResultMessage,\n WindowRelayCheckoutResultPayload,\n WindowRelayPayProgressMessage,\n WindowRelayPayProgressPayload,\n} from \"./pay\";\nimport type {\n AppHubFrameMessage,\n AppMessage,\n AppWindowAccountEmailMessage,\n AppWindowAccountEmailRefreshMessage,\n AppWindowAccountEmailRefreshReplyMessage,\n AppWindowStateMessage,\n ElementHubMessage,\n ElementMessage,\n ElementWindowMessage,\n HubElementMessage,\n HubError,\n HubAppElementMessage,\n HubFrameAppMessage,\n HubMessage,\n RelayAccountEmailMessage,\n WindowAccountEmailMessage,\n PayEnvelope,\n WindowElementMessage,\n} from \"./types\";\n\nexport type SuaMessage =\n | AppMessage\n | HubMessage\n | HubAppElementMessage\n | ElementMessage\n | AppHubFrameMessage\n | HubFrameAppMessage\n | ElementWindowMessage\n | WindowElementMessage\n | ElementHubMessage\n | HubElementMessage\n | AppWindowStateMessage\n | RelayAccountEmailMessage\n | WindowAccountEmailMessage\n | AppWindowAccountEmailMessage\n | AppWindowAccountEmailRefreshMessage\n | AppWindowAccountEmailRefreshReplyMessage;\n\n/**\n * The messages that carry a payment's raw destination ask, legacy key included: the app's pay and deposit requests as\n * the hub decodes them, the element's pay request to the hub, and the progress and checkout records the hub binds to\n * it. The internal entry types them with the legacy key; the published SDK types them without it.\n */\ntype HubAskMessage =\n | HubAppElementPayRequestMessage\n | HubAppElementDepositRequestMessage\n | HubPayRequestMessage\n | HubElementPayProgressMessage\n | HubElementCheckoutResultMessage\n | HubElementCheckoutHeldMessage\n | WindowRelayPayProgressMessage\n | WindowRelayCheckoutResultMessage;\n\n/** `T` without the legacy key, on an object that declares it; `null` passes through, other keys keep their types. */\ntype DropAsk<T> = T extends object ? Omit<T, \"payoutAddress\"> : T;\n/** A payload whose `request` declares the legacy key, in each phase that has one; other phases stay as they are. */\ntype DropRequestAsk<P> = P extends { request: unknown } ? Omit<P, \"request\"> & { request: DropAsk<P[\"request\"]> } : P;\n\n/** {@link HubAskMessage} without the legacy key: removed only on the objects that declare it. */\ntype PublicAskMessage =\n | AppElementPayRequestMessage\n | AppElementDepositRequestMessage\n | PayEnvelope<HubPayRequestMessage[\"type\"], DropAsk<HubPayRequestPayload>>\n | PayEnvelope<HubElementPayProgressMessage[\"type\"], DropRequestAsk<HubElementPayProgressPayload>>\n | PayEnvelope<HubElementCheckoutResultMessage[\"type\"], DropRequestAsk<HubElementCheckoutResultPayload>>\n | PayEnvelope<HubElementCheckoutHeldMessage[\"type\"], DropRequestAsk<HubElementCheckoutHeldPayload>>\n | PayEnvelope<\n WindowRelayPayProgressMessage[\"type\"],\n Omit<WindowRelayPayProgressPayload, \"progress\"> & { progress: DropRequestAsk<HubElementPayProgressPayload> }\n >\n | PayEnvelope<\n WindowRelayCheckoutResultMessage[\"type\"],\n Omit<WindowRelayCheckoutResultPayload, \"checkout\"> & { checkout: DropRequestAsk<HubElementCheckoutResultPayload> }\n >;\n\n/** The messages the published SDK types: every message, with the legacy key taken out of the ones that carry it. */\nexport type PayPublicMessage = Exclude<SuaMessage, HubAskMessage> | PublicAskMessage;\n\ntype DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;\ndeclare const decodedMessage: unique symbol;\n\n/** Only decoders produce this proof; the brand adds no wire field. */\nexport type DecodedMessage<T extends PayPublicMessage = PayPublicMessage> = DeepReadonly<T> & {\n readonly [decodedMessage]: true;\n};\n/** {@link DecodedMessage} over every message, the legacy key included; the internal entry names it `DecodedMessage`. */\nexport type HubDecodedMessage<T extends SuaMessage = SuaMessage> = DeepReadonly<T> & {\n readonly [decodedMessage]: true;\n};\n\ntype ForbidErrorFields = { [K in Exclude<keyof HubError, \"request\">]?: never };\n\ntype EnvelopePayload<T extends SuaMessage> = T extends { type: \"result\" } ? T[\"payload\"] & ForbidErrorFields : T[\"payload\"];\n\nexport type PayEnvelopeArgs<T extends SuaMessage = SuaMessage> = T extends SuaMessage\n ? [id: string, type: T[\"type\"], payload: EnvelopePayload<T>]\n : never;\n\nexport function createPayEnvelope<const TArgs extends PayEnvelopeArgs<PayPublicMessage>>(\n ...[id, type, payload]: TArgs\n): Extract<PayPublicMessage, { type: TArgs[1] }> {\n return { protocol: PAY_PROTOCOL, version: SUA_PROTOCOL_VERSION, id, type, payload } as Extract<\n PayPublicMessage,\n { type: TArgs[1] }\n >;\n}\n/** {@link createPayEnvelope} over every message, the legacy key included; the internal entry names it `createPayEnvelope`. */\nexport function createHubSuaEnvelope<const TArgs extends PayEnvelopeArgs>(\n ...[id, type, payload]: TArgs\n): Extract<SuaMessage, { type: TArgs[1] }> {\n return { protocol: PAY_PROTOCOL, version: SUA_PROTOCOL_VERSION, id, type, payload } as Extract<\n SuaMessage,\n { type: TArgs[1] }\n >;\n}\n","/**\n * Shape checks shared by the message guards. Not part of the public API: `index.ts` does not re-export them.\n *\n * Every reader here touches each property of the input at most once and copies what it read into a fresh\n * null-prototype record, so a getter or a Proxy cannot answer one value to the check and another to the caller of the\n * check.\n */\n\n/**\n * A snapshot of an object's own enumerable string-keyed properties, on a null prototype.\n */\nexport type Fields = Record<string, unknown>;\n\n/**\n * Reports whether `value` is a plain object: non-null, not an array, with a prototype of `Object.prototype` or `null`.\n * Rejects functions, `Date`, `Map`, class instances and every other exotic object.\n */\nexport function isPlainObject(value: unknown): value is Fields {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const prototype: unknown = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Reads `value` as a plain object whose own enumerable string keys all belong to `allowed`, and returns a snapshot of\n * its values (an absent key reads as `undefined`). Returns `undefined` when `value` is not a plain object or holds a\n * key outside `allowed`. Symbol keys are ignored, as `Object.keys` ignores them.\n */\nexport function readExactFields(value: unknown, allowed: ReadonlySet<string>): Fields | undefined {\n if (!isPlainObject(value)) {\n return undefined;\n }\n const keys = Object.keys(value);\n if (keys.length > allowed.size) {\n return undefined;\n }\n const fields: Fields = Object.create(null) as Fields;\n for (const key of keys) {\n if (!allowed.has(key)) {\n return undefined;\n }\n fields[key] = value[key];\n }\n return fields;\n}\n\n/**\n * Reads the listed keys of a plain object, allowing any other key, and returns a snapshot of their values. Returns\n * `undefined` when `value` is not a plain object.\n */\nexport function readSomeFields(value: unknown, wanted: readonly string[]): Fields | undefined {\n if (!isPlainObject(value)) {\n return undefined;\n }\n const fields: Fields = Object.create(null) as Fields;\n for (const key of wanted) {\n fields[key] = Object.prototype.hasOwnProperty.call(value, key) ? value[key] : undefined;\n }\n return fields;\n}\n\n/**\n * Reports whether every key of a snapshot belongs to `allowed`. A snapshot from {@link readExactFields} holds exactly\n * the keys the input held, so this narrows an earlier, wider read without touching the input again.\n */\nexport function hasOnlyKeys(fields: Fields | undefined, allowed: ReadonlySet<string>): fields is Fields {\n return fields !== undefined && Object.keys(fields).every((key) => allowed.has(key));\n}\n\n/**\n * Reports whether `value` is a string of `minLength` to `maxLength` UTF-16 code units, inclusive.\n */\nexport function isStringOfLength(value: unknown, minLength: number, maxLength: number): value is string {\n return typeof value === \"string\" && value.length >= minLength && value.length <= maxLength;\n}\n\n/**\n * Reports whether `value` is a string of exactly `length` UTF-16 code units that matches `pattern`. The length is\n * checked first, so a huge string never reaches the regex.\n */\nexport function matchesOfLength(value: unknown, length: number, pattern: RegExp): value is string {\n return typeof value === \"string\" && value.length === length && pattern.test(value);\n}\n\n/**\n * Builds the set of a string union's members from a record keyed by every member, so the compiler flags a member\n * added to the union and missing here.\n */\nexport function memberSet<TMember extends string>(members: Record<TMember, true>): ReadonlySet<string> {\n return new Set(Object.keys(members));\n}\n\nexport type FieldReader = typeof readExactFields;\n\nconst REFUSED = Symbol(\"refused\");\n\nexport function createSnapshotReader() {\n const snapshots = new Map<unknown, Fields | typeof REFUSED>();\n const read: FieldReader = (value, allowed) => {\n const previous = snapshots.get(value);\n if (previous !== undefined) return previous !== REFUSED && hasOnlyKeys(previous, allowed) ? previous : undefined;\n const fields = readExactFields(value, allowed);\n snapshots.set(value, fields ?? REFUSED);\n return fields;\n };\n function freeze(root: Fields): Fields {\n for (const fields of snapshots.values()) {\n if (fields === REFUSED) continue;\n for (const key of Object.keys(fields)) {\n const value = fields[key];\n if (typeof value !== \"object\" || value === null) continue;\n const captured = snapshots.get(value);\n if (captured === undefined || captured === REFUSED) throw new TypeError(\"Unvalidated protocol record\");\n fields[key] = captured;\n }\n Object.freeze(fields);\n }\n return root;\n }\n return { read, freeze };\n}\n","import { SUA_LINK_C_MESSAGE_TYPES, MAX_PAY_SOURCE_FUNDS_WALLETS } from \"./constants\";\nimport { SUA_RELAY_CONTROL_MESSAGE_TYPES } from \"./constants\";\n\nimport type { EmptyPayload, PayEnvelope } from \"./types\";\n\n/**\n * The job words an app may pick. The hub owns every sentence built on them (\"Pay $24.00\", \"Deposited $20.00 to\n * Kite Studio\"). Closed set: a new word is a new SDK release, never free text.\n */\nexport {\n PAY_JOBS,\n PAY_CURRENCIES,\n PAY_FIRST_STEPS,\n PAY_AMOUNT_PATTERN,\n MAX_PAY_AMOUNT,\n MAX_PAY_ITEM_LENGTH,\n MAX_PAY_PAYOUT_ADDRESS_LENGTH,\n PAY_DESTINATION_RULE_PATTERN,\n PAY_DESTINATION_ASSET_PATTERN,\n PAY_MESSAGE_TYPES,\n} from \"./constants\";\nimport {\n PAY_JOBS,\n PAY_CURRENCIES,\n PAY_FIRST_STEPS,\n PAY_AMOUNT_PATTERN,\n MAX_PAY_AMOUNT,\n MAX_PAY_ITEM_LENGTH,\n MAX_PAY_PAYOUT_ADDRESS_LENGTH,\n PAY_DESTINATION_RULE_PATTERN,\n PAY_DESTINATION_ASSET_PATTERN,\n PAY_MESSAGE_TYPES,\n MAX_MESSAGE_ID_LENGTH,\n EVM_ADDRESS_PATTERN,\n} from \"./constants\";\nimport { createSnapshotReader, hasOnlyKeys, isStringOfLength, matchesOfLength, type FieldReader, type Fields } from \"./shape\";\nexport type PayJob = (typeof PAY_JOBS)[number];\nexport type PayCurrency = (typeof PAY_CURRENCIES)[number];\n/** Which question a chosen-amount Deposit's Pay window asks first. Presentation only, never a payment term. */\nexport type PayFirstStep = (typeof PAY_FIRST_STEPS)[number];\n\n/** An app's checkout rule id, as {@link PAY_DESTINATION_RULE_PATTERN} (\"ckr_01JD3V9QX8K2M4N6P8R0S2T4V6\"). */\nexport type PayDestinationRuleId = `ckr_${string}`;\n\n/**\n * An address with the asset it is paid in: `0x` and 40 hexadecimal characters, not the zero address, and a CAIP-19\n * asset on an `eip155` chain ({@link PAY_DESTINATION_ASSET_PATTERN}). The asset names the chain, so an address never\n * travels without one.\n */\nexport interface PayDestinationAddress {\n address: `0x${string}`;\n asset: `eip155:${string}`;\n}\n\n/**\n * Where a pay request asks the money to go: one of the app's checkout rules by id, or an address with its asset. It is\n * the app's raw ask: the hub compares a saved or resumed payment against it exactly as sent, never against what it\n * resolves to now.\n */\nexport type PayDestinationAsk = PayDestinationRuleId | PayDestinationAddress;\n\n/**\n * The payload of `element-pay-request`: these six keys, plus `destination` only when the app gives one. `item` is\n * `null` when the app sends none (never absent, so the exact-key guard stays simple).\n */\nexport interface ElementPayRequestPayload {\n /**\n * A safe integer from 1. A higher revision replaces the applied request whole; an equal or lower one is acked and\n * ignored.\n */\n revision: number;\n\n /**\n * The app's id for this one payment: 1 to `MAX_MESSAGE_ID_LENGTH` characters. The hub pays one `paymentId` at most\n * once per app and payment id in this browser's hub storage and names it in `element-paid`. Missing or partitioned\n * storage weakens that protection; this notice is still not proof. A new purchase is a new id; a retry after a rejection or a\n * failure keeps it. Changing `job`, `amount`, `currency` or `item` under a known `paymentId` is refused (TypeError on\n * the app face, dropped by the element).\n */\n paymentId: string;\n\n /**\n * The job word.\n */\n job: PayJob;\n\n /**\n * The amount the app must receive, as {@link PAY_AMOUNT_PATTERN}, greater than zero.\n */\n amount: string;\n\n /**\n * The currency of `amount`.\n */\n currency: PayCurrency;\n\n /**\n * The item line, 1 to {@link MAX_PAY_ITEM_LENGTH} code units, or `null`.\n */\n item: string | null;\n\n /**\n * Where the app asks the money to go ({@link PayDestinationAsk}). Absent when the app gives none, so a request\n * without it keeps the six keys an older peer reads. It is not one of the payment's terms: a changed destination\n * under a known `paymentId` is a new revision, never a conflict.\n */\n destination?: PayDestinationAsk;\n}\n\n/**\n * A request's destination ask as the wire may carry it: `destination`, or the older `payoutAddress` (at most\n * {@link MAX_PAY_PAYOUT_ADDRESS_LENGTH} code units, unchecked) that apps sent before it, never both. The decoders still\n * accept the older key from older apps, and the hub still reads it on retained requests and old receipts. Internal:\n * the public request types name `destination` only.\n *\n * Why it stays: Ada and Kite sent it from #356 to #389, so retained payment records may still hold it; and the staging\n * production apps still run a kit that forwards a `payoutAddress` prop (removed in b028ff5df). Once every deployed app\n * build contains b028ff5df, remove only the app ingress (the element request keys and guards) and the hub's forwarding.\n * The shared terms keys stay: account receipt replay rebuilds terms from retained records and decodes them here, so\n * they go only with a migration of stored payment records that keeps their recorded destination ask.\n */\nexport interface LegacyPayDestinationAsk {\n payoutAddress?: string;\n destination?: PayDestinationAsk;\n}\n\n/**\n * The payload of `element-deposit-request`: a Deposit whose amount the user chooses in the window. It has no `job`\n * (the type says Deposit) and no `amount`. `min` and `max` are the app's optional limits, as\n * {@link PAY_AMOUNT_PATTERN} within {@link MAX_PAY_AMOUNT}, with `min` at most `max`; each is absent when the app gives\n * none. The other keys read as on `element-pay-request`, and the element answers with `element-pay-request-ack`.\n */\nexport interface ElementDepositRequestPayload {\n revision: number;\n paymentId: string;\n currency: PayCurrency;\n item: string | null;\n /** The least the user may deposit, for example \"20.00\". */\n min?: string;\n /** The most the user may deposit, for example \"500\". */\n max?: string;\n destination?: PayDestinationAsk;\n /**\n * `method` when the app asks the window to show the ways to pay before the amount. Absent for the default amount\n * first, so a request without it keeps the keys an older peer reads: an element that predates it drops the whole\n * request, so the hub deploys first. Not one of the payment's terms: a change is a new revision, never a conflict.\n */\n firstStep?: Exclude<PayFirstStep, \"amount\">;\n}\n\n/**\n * The payload of `element-pay-request-ack`.\n */\nexport interface ElementPayRequestAckPayload {\n /**\n * The revision the element now holds.\n */\n revision: number;\n}\n\n/**\n * The payload of `element-paid`. It reports what the hub saw; it is not proof of payment. The app reconciles with its\n * own backend or Gateway before it ships anything (the reference and the transaction hash let it look the payment up).\n * The same paymentId can be reported again after a reload; apps must handle it idempotently by paymentId.\n */\nexport interface ElementPaidPayload {\n /**\n * The `paymentId` of the request this payment answered.\n */\n paymentId: string;\n\n /**\n * The job word of that request.\n */\n job: PayJob;\n\n /**\n * The amount and currency of that request.\n */\n amount: string;\n currency: PayCurrency;\n\n /**\n * How the person paid. `account` is a real Stridge Wallet transfer to the app on Tempo. `transfer` is \"Pay by QR\n * code\": the person sent to a Gateway deposit address made for this one order, which settles to the app's payout.\n * An app face from before `transfer` drops only this message (its guard reads the method by exact value), so such an\n * app hears nothing for a QR payment and reconciles it through its own backend or Gateway.\n */\n method: \"wallet\" | \"cash\" | \"account\" | \"transfer\";\n\n /**\n * The receipt reference the hub shows (\"7Q2-K9F\"): 1 to 32 characters of `[0-9A-Z-]`.\n */\n reference: string;\n\n /**\n * The delivery transaction hash on the payout network, when Gateway reports one, else `null`.\n */\n transactionHash: `0x${string}` | null;\n /** Actual delivery facts, distinct from the requested USD amount. */\n received: PayReceived;\n /** A completed route may still be short of the payment target. */\n outcome: \"paid\" | \"short\";\n}\n\n/** Actual output reported by the correlated settlement. */\nexport interface PayReceived {\n amountBaseUnits: string;\n assetSymbol: string;\n networkId: string;\n}\n/**\n * The words of the request a payment record is bound to: its job, amount (\"24.00\"), currency and item line. A paid\n * `pay-progress` carries them, so the element pairs a stored receipt only with a request of the same terms.\n */\nexport type PayTerms = Pick<ElementPayRequestPayload, \"job\" | \"amount\" | \"currency\" | \"item\">;\n/** A transaction is always paired with the network where it happened. */\nexport interface PayTransaction {\n hash: `0x${string}`;\n networkId: string;\n}\n\n/**\n * app → Sua element.\n */\nexport type AppElementPayRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.payRequest, ElementPayRequestPayload>;\n\n/**\n * app → Sua element.\n */\nexport type AppElementDepositRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.depositRequest, ElementDepositRequestPayload>;\n\n/** `element-pay-request` as the hub decodes it: an older app may still send the legacy key. Internal. */\nexport type HubAppElementPayRequestMessage = PayEnvelope<\n typeof PAY_MESSAGE_TYPES.payRequest,\n ElementPayRequestPayload & LegacyPayDestinationAsk\n>;\n\n/** `element-deposit-request` as the hub decodes it: an older app may still send the legacy key. Internal. */\nexport type HubAppElementDepositRequestMessage = PayEnvelope<\n typeof PAY_MESSAGE_TYPES.depositRequest,\n ElementDepositRequestPayload & LegacyPayDestinationAsk\n>;\n\n/**\n * Sua element → app.\n */\nexport type ElementPayRequestAckMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.payRequestAck, ElementPayRequestAckPayload>;\n\n/**\n * Sua element → app notice.\n */\nexport type ElementPaidMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.paid, ElementPaidPayload>;\n\n/** A support notice names the locked payment. It never authorizes fulfillment or a retry. */\nexport interface ElementPaymentNoticePayload {\n paymentId: string;\n reference: string;\n}\nexport type ElementHeldMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.held, ElementPaymentNoticePayload>;\nexport type ElementUnconfirmedMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.unconfirmed, ElementPaymentNoticePayload>;\n\nconst NOTICE_KEYS = new Set([\"paymentId\", \"reference\"]);\n/** Exact-key and snapshot-reader validation, shared by the two separate notice types. */\nexport function checkPaymentNotice(read: FieldReader, value: unknown): boolean {\n const fields = read(value, NOTICE_KEYS);\n return fields !== undefined && Object.keys(fields).length === 2 && text(fields.paymentId) && reference(fields.reference);\n}\n\n/**\n * The request keys that ask where the money goes, spread into every request and terms key set below. A new destination\n * key goes here once: a set that misses it makes the exact-key guard drop the whole message.\n */\nconst PAY_DESTINATION_KEYS = [\"payoutAddress\", \"destination\"] as const;\nconst DESTINATION_ADDRESS_KEYS = new Set([\"address\", \"asset\"]);\nconst REQUEST_KEYS = new Set([\"revision\", \"paymentId\", \"job\", \"amount\", \"currency\", \"item\", ...PAY_DESTINATION_KEYS]);\nconst DEPOSIT_REQUEST_KEYS = new Set([\n \"revision\",\n \"paymentId\",\n \"currency\",\n \"item\",\n \"min\",\n \"max\",\n ...PAY_DESTINATION_KEYS,\n \"firstStep\",\n]);\nconst HUB_REQUEST_KEYS = new Set([\n \"paymentId\",\n \"job\",\n \"amount\",\n \"currency\",\n \"item\",\n \"entry\",\n ...PAY_DESTINATION_KEYS,\n \"min\",\n \"max\",\n \"firstStep\",\n]);\nconst HUB_ENTRIES: ReadonlySet<unknown> = new Set<HubPayRequestPayload[\"entry\"]>([\"pay\", \"sources\", \"progress\", \"receipt\"]);\nconst ACK_KEYS = new Set([\"revision\"]);\nconst PAID_KEYS = new Set([\n \"paymentId\",\n \"job\",\n \"amount\",\n \"currency\",\n \"method\",\n \"reference\",\n \"transactionHash\",\n \"received\",\n \"outcome\",\n]);\nconst SOURCE_KEYS = new Set([\"account\", \"remembered\", \"detected\", \"methods\"]);\nconst METHODS_KEYS = new Set([\"wallet\", \"cash\"]);\nconst RECEIVED_KEYS = new Set([\"amountBaseUnits\", \"assetSymbol\", \"networkId\"]);\nconst TRANSACTION_KEYS = new Set([\"hash\", \"networkId\"]);\n/**\n * C0 and C1 control characters and the bidirectional override and isolate marks: an item name holding one could hide\n * or reorder what a person reads in the window. The match is on control characters on purpose.\n */\n// oxlint-disable-next-line no-control-regex -- the control range is the point of this check\nconst UNSAFE_ITEM_CHARACTERS = /[\\u0000-\\u001f\\u007f-\\u009f\\u202a-\\u202e\\u2066-\\u2069]/;\nconst REMEMBERED_KEYS = new Set([\"kind\", \"brand\", \"name\", \"addressTail\"]);\nconst SAVED_WALLET_KEYS = new Set([\"brand\", \"name\", \"addressTail\"]);\nconst PROGRESS_KEYS = new Set([\n \"reason\",\n \"paymentId\",\n \"phase\",\n \"logo\",\n \"brand\",\n \"reference\",\n \"fromLabel\",\n \"startedAt\",\n \"source\",\n \"delivery\",\n \"retry\",\n \"received\",\n \"receivedDisplay\",\n \"binding\",\n \"outcome\",\n \"request\",\n]);\nconst TERMS_KEYS = new Set([\"job\", \"amount\", \"currency\", \"item\"]);\nconst ANY_PROGRESS_KEYS = PROGRESS_KEYS;\n/** A token amount with exactly two fraction digits, as the hub formats it for the card (\"23.90\"). */\nconst DISPLAY_AMOUNT_PATTERN = /^(?:0|[1-9][0-9]{0,29})\\.[0-9]{2}$/;\nconst text = (value: unknown): value is string => isStringOfLength(value, 1, MAX_MESSAGE_ID_LENGTH);\n/** When a payment started: whole milliseconds since the epoch, from 0. */\nconst startedAt = (value: unknown): boolean => typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\nconst revision = (value: unknown): boolean => Number.isSafeInteger(value) && typeof value === \"number\" && value >= 1;\nconst reference = (value: unknown): boolean => typeof value === \"string\" && value.length <= 32 && /^[0-9A-Z-]+$/.test(value);\nconst hash = (value: unknown): boolean => value === null || (typeof value === \"string\" && /^0x[0-9a-fA-F]{64}$/.test(value));\nfunction cents(amount: string): bigint {\n const [whole = \"0\", fraction = \"\"] = amount.split(\".\");\n return BigInt(whole) * 100n + BigInt(fraction.padEnd(2, \"0\"));\n}\n/** Compares validated decimal pay amounts without floating point arithmetic. */\nexport function comparePayAmounts(left: string, right: string): -1 | 0 | 1 {\n const a = cents(left),\n b = cents(right);\n return a < b ? -1 : a > b ? 1 : 0;\n}\n/** A pay amount: {@link PAY_AMOUNT_PATTERN}, greater than zero, within {@link MAX_PAY_AMOUNT}. */\nfunction payAmount(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length <= 12 &&\n PAY_AMOUNT_PATTERN.test(value) &&\n comparePayAmounts(value, \"0\") > 0 &&\n comparePayAmounts(value, MAX_PAY_AMOUNT) <= 0\n );\n}\nfunction requestFields(fields: Fields): boolean {\n return payAmount(fields.amount) && termFields(fields);\n}\n/** Every request field but the amount. */\nfunction termFields(fields: Fields): boolean {\n return (\n text(fields.paymentId) &&\n (fields.job === \"pay\" || fields.job === \"deposit\") &&\n fields.currency === \"USD\" &&\n (fields.item === null ||\n (isStringOfLength(fields.item, 1, MAX_PAY_ITEM_LENGTH) && !UNSAFE_ITEM_CHARACTERS.test(fields.item))) &&\n (fields.payoutAddress === undefined || isStringOfLength(fields.payoutAddress, 0, MAX_PAY_PAYOUT_ADDRESS_LENGTH))\n );\n}\n/**\n * A request's `destination`: absent, a checkout rule id, or exactly an address and an `eip155` asset. A request that\n * also carries `payoutAddress` fails: the two asks never travel together. The address object is read through `read`,\n * so the decoded payload holds a detached, frozen copy.\n */\nfunction destinationField(read: FieldReader, fields: Fields): boolean {\n const { destination } = fields;\n if (destination === undefined) return true;\n if (fields.payoutAddress !== undefined) return false;\n if (typeof destination === \"string\")\n return isStringOfLength(destination, 5, 64) && PAY_DESTINATION_RULE_PATTERN.test(destination);\n const ask = read(destination, DESTINATION_ADDRESS_KEYS);\n return (\n ask !== undefined &&\n matchesOfLength(ask.address, 42, EVM_ADDRESS_PATTERN) &&\n !/^0x0{40}$/.test(ask.address) &&\n isStringOfLength(ask.asset, 1, 180) &&\n PAY_DESTINATION_ASSET_PATTERN.test(ask.asset)\n );\n}\n/** A chosen-amount Deposit's first step: absent (the amount first) or `method`, the one value the wire carries. */\nfunction firstStepField(fields: Fields): boolean {\n return fields.firstStep === undefined || fields.firstStep === \"method\";\n}\n/** A chosen-amount Deposit's limits: each absent or a pay amount, and `min` at most `max`. */\nfunction limitFields(fields: Fields): boolean {\n const { min, max } = fields;\n return (\n (min === undefined || payAmount(min)) &&\n (max === undefined || payAmount(max)) &&\n (min === undefined || max === undefined || comparePayAmounts(min as string, max as string) <= 0)\n );\n}\n/**\n * Shares the enclosing decoder's one-read snapshots. The hub's `pay` carries either an `amount` (a fixed request) or\n * `amount: null` with optional `min` and `max` (a chosen-amount Deposit).\n */\nexport function checkPayRequest(read: FieldReader, value: unknown, hub = false): boolean {\n const fields = read(value, hub ? HUB_REQUEST_KEYS : REQUEST_KEYS);\n if (fields === undefined || !destinationField(read, fields)) return false;\n if (!hub) return requestFields(fields) && revision(fields.revision);\n const terms =\n fields.amount === null\n ? fields.job === \"deposit\" && termFields(fields) && limitFields(fields) && firstStepField(fields)\n : requestFields(fields) && fields.min === undefined && fields.max === undefined && fields.firstStep === undefined;\n return terms && HUB_ENTRIES.has(fields.entry);\n}\n/**\n * The money words of a request either message carries, without its revision: a fixed request names its `job` and\n * `amount`; a chosen-amount Deposit names neither, only its optional limits.\n */\nexport type PayRequestTerms =\n | Pick<ElementPayRequestPayload, \"paymentId\" | \"job\" | \"amount\" | \"currency\" | \"item\">\n | Pick<ElementDepositRequestPayload, \"paymentId\" | \"currency\" | \"item\" | \"min\" | \"max\">;\n\n/** The request's job word: a chosen-amount Deposit request is always `deposit`. Pure. */\nexport function payJobOf(request: PayRequestTerms): PayJob {\n return \"job\" in request ? request.job : \"deposit\";\n}\n\n/**\n * Whether a payment of `amount` (a validated pay amount, \"40.00\") answers `request`: the same amount for a fixed\n * request; for a chosen-amount Deposit, any amount within its limits. Pure.\n */\nexport function answersPayAmount(request: PayRequestTerms, amount: string): boolean {\n if (\"amount\" in request) return comparePayAmounts(request.amount, amount) === 0;\n return (\n (request.min === undefined || comparePayAmounts(request.min, amount) <= 0) &&\n (request.max === undefined || comparePayAmounts(amount, request.max) <= 0)\n );\n}\n\n/**\n * Whether two requests ask the same money under the same `paymentId`: the same kind, job, currency, item, and the\n * same amount or the same limits (decimal-equal: \"20\" is \"20.00\"). The destination ask and the first step are not\n * terms ({@link samePayDestinationAsk} compares the ask). Pure.\n */\nexport function samePayTerms(left: PayRequestTerms, right: PayRequestTerms): boolean {\n if (left.paymentId !== right.paymentId || left.currency !== right.currency || left.item !== right.item) return false;\n if (\"amount\" in left)\n return \"amount\" in right && left.job === right.job && comparePayAmounts(left.amount, right.amount) === 0;\n return !(\"amount\" in right) && sameLimit(left.min, right.min) && sameLimit(left.max, right.max);\n}\n/**\n * Whether two requests ask for the same destination, exactly as the app sent it: the same `destination` (the same rule\n * id, or the same address and asset, byte for byte); absent equals absent. The app face's revision check uses it. Pure.\n */\nexport function samePayDestinationAsk(\n left: { destination?: PayDestinationAsk },\n right: { destination?: PayDestinationAsk },\n): boolean {\n return sameLegacyPayDestinationAsk(left, right);\n}\n/**\n * {@link samePayDestinationAsk} with the older key too: the same `destination` and the same raw `payoutAddress`,\n * absent equal to absent. The hub's ask identity uses it, so a saved or resumed payment compares against what the app\n * asked, never against a later resolution. Internal. Pure.\n */\nexport function sameLegacyPayDestinationAsk(left: LegacyPayDestinationAsk, right: LegacyPayDestinationAsk): boolean {\n if (left.payoutAddress !== right.payoutAddress) return false;\n const a = left.destination,\n b = right.destination;\n if (a === undefined || b === undefined || typeof a === \"string\" || typeof b === \"string\") return a === b;\n return a.address === b.address && a.asset === b.asset;\n}\nfunction sameLimit(left: string | undefined, right: string | undefined): boolean {\n return left === undefined || right === undefined ? left === right : comparePayAmounts(left, right) === 0;\n}\n/** Shares the enclosing decoder's one-read snapshots. */\nexport function checkDepositRequest(read: FieldReader, value: unknown): boolean {\n const fields = read(value, DEPOSIT_REQUEST_KEYS);\n return (\n fields !== undefined &&\n destinationField(read, fields) &&\n termFields({ ...fields, job: \"deposit\" }) &&\n limitFields(fields) &&\n firstStepField(fields) &&\n revision(fields.revision)\n );\n}\nexport function checkPayAck(read: FieldReader, value: unknown): boolean {\n const fields = read(value, ACK_KEYS);\n return fields !== undefined && revision(fields.revision);\n}\nexport function checkPaid(read: FieldReader, value: unknown): boolean {\n const fields = read(value, PAID_KEYS);\n return fields !== undefined && paidFields(read, fields);\n}\n\nfunction paidFields(read: FieldReader, fields: Fields): boolean {\n return (\n requestFields({ ...fields, item: null }) &&\n (fields.method === \"wallet\" || fields.method === \"cash\" || fields.method === \"account\" || fields.method === \"transfer\") &&\n reference(fields.reference) &&\n hash(fields.transactionHash) &&\n checkReceived(read, fields.received) &&\n (fields.outcome === \"paid\" || fields.outcome === \"short\")\n );\n}\nfunction networkId(value: unknown): boolean {\n return typeof value === \"string\" && value.length <= 20 && /^[1-9][0-9]*$/.test(value);\n}\nfunction checkReceived(read: FieldReader, value: unknown): boolean {\n const f = read(value, RECEIVED_KEYS);\n return (\n f !== undefined &&\n typeof f.amountBaseUnits === \"string\" &&\n f.amountBaseUnits.length <= 78 &&\n /^(?:0|[1-9][0-9]*)$/.test(f.amountBaseUnits) &&\n BigInt(f.amountBaseUnits) < 2n ** 256n &&\n typeof f.assetSymbol === \"string\" &&\n /^[A-Z0-9]{1,16}$/.test(f.assetSymbol) &&\n networkId(f.networkId)\n );\n}\nfunction checkTransaction(read: FieldReader, value: unknown): boolean {\n if (value === null) return true;\n const f = read(value, TRANSACTION_KEYS);\n return f !== undefined && f.hash !== null && hash(f.hash) && networkId(f.networkId);\n}\n/** Exact-key pay request guard. Never throws. */\nexport function isElementPayRequestPayload(value: unknown): value is ElementPayRequestPayload {\n try {\n return checkPayRequest(createSnapshotReader().read, value);\n } catch {\n return false;\n }\n}\n/** Exact-key chosen-amount Deposit request guard. Never throws. */\nexport function isElementDepositRequestPayload(value: unknown): value is ElementDepositRequestPayload {\n try {\n return checkDepositRequest(createSnapshotReader().read, value);\n } catch {\n return false;\n }\n}\n/** Exact-key acknowledgment guard. Never throws. */\nexport function isElementPayRequestAckPayload(value: unknown): value is ElementPayRequestAckPayload {\n try {\n return checkPayAck(createSnapshotReader().read, value);\n } catch {\n return false;\n }\n}\n/** Exact-key payment notice guard. Never throws. */\nexport function isElementPaidPayload(value: unknown): value is ElementPaidPayload {\n try {\n return checkPaid(createSnapshotReader().read, value);\n } catch {\n return false;\n }\n}\n/** Copies source arrays because the generic record snapshot reader accepts records only. */\nexport function readPaySource(read: FieldReader, value: unknown) {\n const f = read(value, SOURCE_KEYS);\n if (!f || !(f.account === null || f.account === \"on\" || f.account === \"off\")) return undefined;\n const detected = f.detected;\n if (!Array.isArray(detected) || detected.length > 100) return undefined;\n const brands: string[] = [];\n for (const brand of detected) {\n if (!text(brand)) return undefined;\n brands.push(brand);\n }\n const methods = read(f.methods, METHODS_KEYS);\n if (\n methods === undefined ||\n methods.wallet !== true ||\n !(methods.cash === \"direct\" || methods.cash === \"none\" || methods.cash === \"account\")\n )\n return undefined;\n f.methods = Object.freeze(methods);\n const remembered = readPaySourceRemembered(read, f.remembered);\n if (remembered === undefined) return undefined;\n f.remembered = remembered;\n f.detected = Object.freeze(brands);\n return Object.freeze(f);\n}\n/** A `pay-source` `remembered`: `null`, the Stridge Wallet, or a wallet's card fields. `undefined` when it is none. */\nexport function readPaySourceRemembered(read: FieldReader, value: unknown) {\n if (value === null) return null;\n const r = read(value, REMEMBERED_KEYS);\n if (!r) return undefined;\n const account = r.kind === \"account\" && Object.keys(r).length === 1;\n const wallet = (r.kind === \"last-used\" || r.kind === \"saved\") && text(r.brand) && text(r.name) && text(r.addressTail);\n return account || wallet ? Object.freeze(r) : undefined;\n}\nconst FUNDS_WALLET_KEYS = new Set([\"kind\", \"brand\", \"name\", \"addressTail\", \"cents\", \"lastUsed\"]);\n/**\n * Reads a `pay-source-funds` payload: exactly `wallets`, an array of at most {@link MAX_PAY_SOURCE_FUNDS_WALLETS}\n * wallets, each with exactly a `kind` (`saved` or `last-used`), the card fields, `cents` (a safe integer from 0) and a\n * boolean `lastUsed`. `undefined` when any part breaks its rule.\n */\nexport function readPaySourceFunds(read: FieldReader, value: unknown): Fields | undefined {\n const f = read(value, PAY_SOURCE_FUNDS_KEYS);\n if (!f || !Array.isArray(f.wallets) || f.wallets.length > MAX_PAY_SOURCE_FUNDS_WALLETS) return undefined;\n const wallets: Fields[] = [];\n for (const each of f.wallets as unknown[]) {\n const w = read(each, FUNDS_WALLET_KEYS);\n if (\n !w ||\n Object.keys(w).length !== FUNDS_WALLET_KEYS.size ||\n (w.kind !== \"saved\" && w.kind !== \"last-used\") ||\n !text(w.brand) ||\n !text(w.name) ||\n !text(w.addressTail) ||\n !Number.isSafeInteger(w.cents) ||\n (w.cents as number) < 0 ||\n typeof w.lastUsed !== \"boolean\"\n )\n return undefined;\n wallets.push(Object.freeze(w));\n }\n f.wallets = Object.freeze(wallets);\n return Object.freeze(f);\n}\nconst PAY_SOURCE_FUNDS_KEYS = new Set([\"wallets\"]);\n/** A `pay-source-saved` `saved`: `null`, or a saved wallet's card fields. `undefined` when it is none. */\nexport function readPaySavedWallet(read: FieldReader, value: unknown) {\n if (value === null) return null;\n const w = read(value, SAVED_WALLET_KEYS);\n return w && text(w.brand) && text(w.name) && text(w.addressTail) ? w : undefined;\n}\nfunction checkTerms(read: FieldReader, value: unknown): boolean {\n const f = read(value, TERMS_KEYS);\n return f !== undefined && requestFields({ ...f, paymentId: \"terms\" });\n}\n/** Account terms accept explicit no-ask evidence (`null`) and legacy terms with no evidence. */\nfunction checkAccountTerms(read: FieldReader, value: unknown): boolean {\n const f = read(value, CHECKOUT_TERMS_KEYS);\n if (f === undefined || !requestFields({ ...f, paymentId: \"terms\" })) return false;\n return f.destination === null ? f.payoutAddress === undefined : destinationField(read, f);\n}\nconst ACCOUNT_BINDING_KEYS = new Set([\"destination\", \"payout\", \"testApp\"]);\nconst PAYOUT_KEYS = new Set([\"address\", \"networkId\", \"assetSymbol\"]);\n\n/** Account receipt bindings stay inside the hub build and never enter the public element-paid notice. */\nfunction checkAccountBinding(read: FieldReader, value: unknown): boolean {\n const binding = read(value, ACCOUNT_BINDING_KEYS);\n if (binding === undefined || Object.keys(binding).length !== 3 || typeof binding.testApp !== \"boolean\") return false;\n const validPayout = (value: unknown, allowsPayer: boolean): boolean => {\n const payout = read(value, PAYOUT_KEYS);\n return (\n payout !== undefined &&\n Object.keys(payout).length === 3 &&\n ((allowsPayer && payout.address === null) ||\n (typeof payout.address === \"string\" &&\n EVM_ADDRESS_PATTERN.test(payout.address) &&\n !/^0x0{40}$/.test(payout.address))) &&\n typeof payout.networkId === \"string\" &&\n /^[1-9][0-9]*$/.test(payout.networkId) &&\n (payout.assetSymbol === \"USDC\" || payout.assetSymbol === \"USDT\")\n );\n };\n return validPayout(binding.destination, false) && (binding.payout === null || validPayout(binding.payout, true));\n}\n\nexport function checkPayProgress(read: FieldReader, value: unknown): boolean {\n const f = read(value, ANY_PROGRESS_KEYS);\n if (\n !f ||\n !hasOnlyKeys(f, PROGRESS_KEYS) ||\n !text(f.paymentId) ||\n !checkTransaction(read, f.source) ||\n !checkTransaction(read, f.delivery)\n )\n return false;\n const count = Object.keys(f).length;\n if (f.phase === \"failed\")\n return (\n (count === 6 ||\n (count === 7 &&\n f.retry === \"support\" &&\n (f.reason === \"unconfirmed\" || f.reason === \"held\" || f.reason === \"reverted\"))) &&\n (f.retry === \"allowed\" || f.retry === \"support\") &&\n reference(f.reference)\n );\n if (\n !(f.logo === \"wallet\" || f.logo === \"cash\" || f.logo === \"account\" || f.logo === \"transfer\") ||\n !(f.brand === null || text(f.brand))\n )\n return false;\n if (f.phase === \"paying\")\n return (\n (count === 7 || (count === 8 && \"startedAt\" in f && startedAt(f.startedAt))) &&\n (f.fromLabel === null || text(f.fromLabel))\n );\n return (\n f.phase === \"paid\" &&\n (f.logo === \"account\"\n ? count === 13 && checkAccountBinding(read, f.binding) && checkAccountTerms(read, f.request)\n : count === 12 && checkTerms(read, f.request)) &&\n reference(f.reference) &&\n text(f.fromLabel) &&\n checkReceived(read, f.received) &&\n (f.receivedDisplay === null ||\n (typeof f.receivedDisplay === \"string\" && DISPLAY_AMOUNT_PATTERN.test(f.receivedDisplay))) &&\n (f.outcome === \"paid\" || f.outcome === \"short\")\n );\n}\n\n/** The four final states reported by a checkout, independently of its UI outcome. */\nexport type CheckoutFinalState = \"completed\" | \"failed\" | \"canceled\" | \"expired\";\n/** A Coordinator observation. The app must verify delivery independently before it fulfils the checkout. */\nexport interface ElementCheckoutResultPayload {\n paymentId: string;\n /**\n * The pay-in id, distinct from the envelope id: an opaque string, `srt_<uuid>` from Coordinator rc.38 on (a bare UUID\n * before). Never parse it.\n */\n id: string;\n /**\n * The pay-in's final state. The Coordinator now calls it `status`; this message keeps the key `state`, because apps\n * read it and the app and the hub deploy apart.\n */\n state: CheckoutFinalState;\n /** Approved amount in destination base units. */\n amount: string;\n /** Delivered amount in destination base units, possibly below amount. */\n delivered: string;\n /** Unique destination transactions only; empty is valid even on completed. */\n destinationTxs: readonly string[];\n}\nexport type ElementCheckoutResultMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.checkoutResult, ElementCheckoutResultPayload>;\n/** Internal request terms accompany the fixed app payload so a cached result cannot answer changed terms. */\nexport interface HubElementCheckoutResultPayload {\n result: ElementCheckoutResultPayload;\n request: PayTerms & LegacyPayDestinationAsk;\n /** The payee name the server gave the approved quote (`payee.name`), or `null` when it named none. */\n payee: string | null;\n}\nconst CHECKOUT_KEYS = new Set([\"paymentId\", \"id\", \"state\", \"amount\", \"delivered\", \"destinationTxs\"]);\nconst CHECKOUT_NOTICE_KEYS = new Set([\"result\", \"request\", \"payee\"]);\n/** The longest payee name a checkout notice carries. */\nconst MAX_PAYEE_LENGTH = 512;\nconst CHECKOUT_TERMS_KEYS = new Set([...TERMS_KEYS, ...PAY_DESTINATION_KEYS]);\nconst BASE_UNITS = /^(?:0|[1-9][0-9]{0,77})$/;\n/** Reads each untrusted field once and detaches the bounded destination transaction array. */\nexport function readCheckoutResult(read: FieldReader, value: unknown): Fields | undefined {\n const f = read(value, CHECKOUT_KEYS);\n if (\n !f ||\n Object.keys(f).length !== 6 ||\n !text(f.paymentId) ||\n !text(f.id) ||\n !(f.state === \"completed\" || f.state === \"failed\" || f.state === \"canceled\" || f.state === \"expired\") ||\n typeof f.amount !== \"string\" ||\n !BASE_UNITS.test(f.amount) ||\n f.amount === \"0\" ||\n typeof f.delivered !== \"string\" ||\n !BASE_UNITS.test(f.delivered)\n )\n return undefined;\n const source = f.destinationTxs;\n if (!Array.isArray(source)) return undefined;\n const length = source.length;\n if (!Number.isSafeInteger(length) || length < 0 || length > 32) return undefined;\n const txs: string[] = [];\n for (let index = 0; index < length; index += 1) {\n const tx: unknown = source[index];\n if (!isStringOfLength(tx, 1, 128) || txs.includes(tx)) return undefined;\n txs.push(tx);\n }\n f.destinationTxs = Object.freeze(txs);\n return Object.freeze(f);\n}\n/** Reads the internal checkout notice without adding fields to the public result. */\nexport function readHubCheckoutResult(read: FieldReader, value: unknown): Fields | undefined {\n const f = read(value, CHECKOUT_NOTICE_KEYS);\n if (!f || Object.keys(f).length !== 3) return undefined;\n if (f.payee !== null && !isStringOfLength(f.payee, 1, MAX_PAYEE_LENGTH)) return undefined;\n const result = readCheckoutResult(read, f.result);\n const request = read(f.request, CHECKOUT_TERMS_KEYS);\n if (!result || !request || !destinationField(read, request) || !requestFields({ ...request, paymentId: result.paymentId }))\n return undefined;\n f.result = result;\n f.request = Object.freeze(request);\n return Object.freeze(f);\n}\n/**\n * The wallet that paid a guest checkout in full, as the card draws it: the brand its logo is looked up by. Display\n * only: never an identity or a money input.\n */\nexport interface HubElementCheckoutWalletPayload {\n paymentId: string;\n /** The paying wallet's brand (\"metamask\"), as `pay-progress` names a direct payment's. */\n brand: string;\n}\nconst CHECKOUT_WALLET_KEYS = new Set([\"paymentId\", \"brand\"]);\n/** The longest wallet brand a checkout wallet notice carries. */\nconst MAX_CHECKOUT_BRAND_LENGTH = 64;\n/** Reads a checkout wallet notice: exactly `paymentId` and `brand`, each a non-empty bounded string. */\nexport function readCheckoutWallet(read: FieldReader, value: unknown): Fields | undefined {\n const f = read(value, CHECKOUT_WALLET_KEYS);\n if (!f || Object.keys(f).length !== 2 || !text(f.paymentId) || !isStringOfLength(f.brand, 1, MAX_CHECKOUT_BRAND_LENGTH))\n return undefined;\n return Object.freeze(f);\n}\n/**\n * A guest checkout the hub holds for `paymentId` with the terms its result carries, or `request` `null` once the hub\n * holds none: it expired, was released, or went.\n */\nexport interface HubElementCheckoutHeldPayload {\n paymentId: string;\n request: HubElementCheckoutResultPayload[\"request\"] | null;\n}\nconst CHECKOUT_HELD_KEYS = new Set([\"paymentId\", \"request\"]);\n/** Checks a checkout hold: exactly `paymentId` and `request`, the checkout result's terms or `null`. */\nfunction checkCheckoutHeld(read: FieldReader, value: unknown): boolean {\n const f = read(value, CHECKOUT_HELD_KEYS);\n if (!f || Object.keys(f).length !== 2 || !text(f.paymentId)) return false;\n if (f.request === null) return true;\n const request = read(f.request, CHECKOUT_TERMS_KEYS);\n return request !== undefined && destinationField(read, request) && requestFields({ ...request, paymentId: f.paymentId });\n}\n/** Exact-key checkout guard. Never throws; ids are 1–128 code units, amounts at most 78 digits. */\nexport function isElementCheckoutResultPayload(value: unknown): value is ElementCheckoutResultPayload {\n try {\n return readCheckoutResult(createSnapshotReader().read, value) !== undefined;\n } catch {\n return false;\n }\n}\n\n/** Internal checkout result and its bound request terms. */\nexport type HubElementCheckoutResultMessage = PayEnvelope<\n typeof SUA_LINK_C_MESSAGE_TYPES.checkoutResult,\n HubElementCheckoutResultPayload\n>;\n\n/** The wallet that paid a guest checkout in full, beside its checkout result. */\nexport type HubElementCheckoutWalletMessage = PayEnvelope<\n typeof SUA_LINK_C_MESSAGE_TYPES.checkoutWallet,\n HubElementCheckoutWalletPayload\n>;\n\n/** A guest checkout the hub holds for a payment, or holds no longer. */\nexport type HubElementCheckoutHeldMessage = PayEnvelope<\n typeof SUA_LINK_C_MESSAGE_TYPES.checkoutHeld,\n HubElementCheckoutHeldPayload\n>;\n\n/**\n * The payload of `relay-pay-progress`: a Pay window's `pay-progress` for the element that opened it. A popup hub page\n * holds no link C attachment, so its payment reaches the card and the app's `element-paid` on this stream.\n */\nexport interface WindowRelayPayProgressPayload {\n /** As for `relay-state`. */\n relayId: string;\n /** The envelope id of the window's current ceremony request. */\n requestId: string;\n /** The position in this operation's pay-progress stream: a safe integer from 1, increasing. */\n sequence: number;\n /** The payment's progress, as link C's `pay-progress` carries it. */\n progress: HubElementPayProgressPayload;\n}\n\nexport type WindowRelayPayProgressMessage = PayEnvelope<\n typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.payProgress,\n WindowRelayPayProgressPayload\n>;\n\n/**\n * The payload of `relay-pay-source`: the source a Pay window picks for the person it serves, as link C's `pay-source`\n * names it in `remembered`. A hub frame that cannot read the window's storage or session picks for a guest, so the\n * card of the element that opened the window shows this one instead, for the person the window last relayed.\n */\nexport interface WindowRelayPaySourcePayload {\n /** As for `relay-state`. */\n relayId: string;\n /** The envelope id of the window's current ceremony request. */\n requestId: string;\n /** The position in this operation's pay stream, shared with `relay-pay-progress`: a safe integer from 1, increasing. */\n sequence: number;\n /** The picked source, as `pay-source` carries it; `null` when the window picks none. */\n remembered: HubElementPaySourceRemembered | null;\n}\n\nexport type WindowRelayPaySourceMessage = PayEnvelope<\n typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.paySource,\n WindowRelayPaySourcePayload\n>;\n\n/**\n * The payload of `relay-pay-source-saved`: the first wallet saved to the account the Pay window serves, as link C's\n * `pay-source-saved` carries it, for the card of the element that opened the window.\n */\nexport interface WindowRelayPaySourceSavedPayload {\n /** As for `relay-state`. */\n relayId: string;\n /** The envelope id of the window's current ceremony request. */\n requestId: string;\n /** The position in this operation's pay stream, shared with `relay-pay-source`: a safe integer from 1, increasing. */\n sequence: number;\n /** The first saved wallet; `null` when the window picks no account or the account saved none. */\n saved: HubElementPaySavedWallet | null;\n}\n\nexport type WindowRelayPaySourceSavedMessage = PayEnvelope<\n typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.paySourceSaved,\n WindowRelayPaySourceSavedPayload\n>;\n\n/** Full pay request carried on both hub transports. */\nexport interface HubPayRequestPayload {\n paymentId: string;\n job: PayJob;\n /**\n * The amount the app asked for, or `null` for a Deposit whose amount the user chooses in the window\n * (`element-deposit-request`).\n */\n amount: string | null;\n currency: \"USD\";\n item: string | null;\n /** A chosen-amount Deposit's least amount, when the app gave one. Absent whenever `amount` is set. */\n min?: string;\n /** A chosen-amount Deposit's most amount, when the app gave one. Absent whenever `amount` is set. */\n max?: string;\n /**\n * `method` when a chosen-amount Deposit asks the ways to pay before the amount, as `element-deposit-request`\n * carried it. Absent for the amount first and whenever `amount` is set.\n */\n firstStep?: Exclude<PayFirstStep, \"amount\">;\n /**\n * Where the window opens: `pay` (the Pay button), `sources` (the card's source row: the \"Pay with\" list), or a\n * started payment's `progress` / `receipt`.\n */\n entry: \"pay\" | \"sources\" | \"progress\" | \"receipt\";\n /**\n * The app's payout address, as `element-pay-request` carried it. Absent when the app gave none. The hub uses it\n * only for an app its app list marks as a test app, and only when it is a valid address.\n *\n * @deprecated Use `destination`. A request may not carry both.\n */\n payoutAddress?: string;\n /** The app's destination ask, as `element-pay-request` carried it. Absent when the app gave none. */\n destination?: PayDestinationAsk;\n}\nexport type HubPayRequestMessage = PayEnvelope<\"pay\", HubPayRequestPayload>;\n/**\n * The source the card picks: a wallet (`last-used` for a guest, `saved` for a signed-in person) or, for a signed-in\n * person who has not paid with a saved wallet yet, the Stridge Wallet (`account`).\n */\nexport type HubElementPaySourceRemembered =\n | { kind: \"last-used\" | \"saved\"; brand: string; name: string; addressTail: string }\n | { kind: \"account\" };\n\n/** Card source facts supplied by the hub window. */\nexport interface HubElementPaySourcePayload {\n account: \"on\" | \"off\" | null;\n remembered: HubElementPaySourceRemembered | null;\n detected: readonly string[];\n /**\n * How the person may pay. `cash` is `direct` (Cash pays the app), `account` (Card or bank creates a Stridge Wallet\n * first) or `none` (no Cash).\n */\n methods: { wallet: true; cash: \"direct\" | \"account\" | \"none\" };\n}\n/**\n * Hub-origin progress only; the consumer app face receives the existing element-paid notice. An open Pay window can\n * predate the element's build, so account receipts accept legacy terms without ask evidence. `transfer` is \"Manual\n * deposit\": `paying` once a deposit to the order's address is seen, then `paid`.\n */\nexport type HubElementPayProgressPayload =\n | {\n paymentId: string;\n phase: \"paying\";\n logo: \"wallet\" | \"cash\" | \"account\" | \"transfer\";\n brand: string | null;\n /** The wallet the payment left from (\"MetaMask ••4e07\"), or `null` when the hub has no label (Cash). */\n fromLabel: string | null;\n /**\n * When the payment started, in ms since the epoch, when the hub's record kept it. The card says \"Taking longer\n * than usual\" once the hub's long wait passed since then. Absent from an older hub.\n */\n startedAt?: number;\n source: PayTransaction | null;\n delivery: PayTransaction | null;\n }\n | {\n paymentId: string;\n phase: \"paid\";\n logo: \"wallet\" | \"cash\" | \"account\" | \"transfer\";\n brand: string | null;\n reference: string;\n fromLabel: string;\n source: PayTransaction | null;\n delivery: PayTransaction | null;\n received: PayReceived;\n /**\n * `received` in token units with two fraction digits, rounded down (\"23.90\"), for the card's \"Kite Studio got\n * 23.90 USDC\". `null` when the hub no longer knows the token's decimals (a record kept before this field).\n */\n receivedDisplay: string | null;\n /**\n * Required for an account receipt by the hub guard. The recorded destination, the record's raw ask (in\n * `request`) and the registry payout let the element reject a replay for another ask. Absent for wallet and\n * Cash receipts. A null payout means registry settings are unavailable, so the element reports no paid notice.\n */\n binding?: {\n destination: { address: `0x${string}`; networkId: string; assetSymbol: \"USDC\" | \"USDT\" };\n payout: { address: `0x${string}` | null; networkId: string; assetSymbol: \"USDC\" | \"USDT\" } | null;\n testApp: boolean;\n };\n outcome: \"paid\" | \"short\";\n /**\n * The terms of the request this payment's record is bound to (R1-01). An account receipt adds the record's raw\n * destination ask (`payoutAddress` or `destination`, with `destination: null` when it sent none). Missing\n * evidence is a legacy receipt and requires the old effective-payout check.\n */\n request: PayTerms & { payoutAddress?: string; destination?: PayDestinationAsk | null };\n }\n | {\n paymentId: string;\n phase: \"failed\";\n retry: \"allowed\" | \"support\";\n /** Hub-only distinction. App peers receive separate held and unconfirmed message types. */\n reason?: \"unconfirmed\" | \"held\" | \"reverted\";\n reference: string;\n source: PayTransaction | null;\n delivery: PayTransaction | null;\n };\nexport type HubElementPaySourceMessage = PayEnvelope<\"pay-source\", HubElementPaySourcePayload>;\n\n/** A wallet saved to the signed-in account, by the fields the card draws: \"MetaMask ••4e07\". */\nexport interface HubElementPaySavedWallet {\n brand: string;\n name: string;\n addressTail: string;\n}\n\n/**\n * The payload of `pay-source-saved`: the first wallet saved to the signed-in account while `pay-source` names the\n * Stridge Wallet, else `null`. The hub never knows the amount, so the card weighs the balance and shows this wallet in\n * the account's place when the balance does not cover it.\n */\nexport interface HubElementPaySourceSavedPayload {\n saved: HubElementPaySavedWallet | null;\n}\nexport type HubElementPaySourceSavedMessage = PayEnvelope<\"pay-source-saved\", HubElementPaySourceSavedPayload>;\n\n/**\n * A wallet the card may show, by the fields it draws, with its money: \"MetaMask ••4e07\", `cents` the dollars it holds\n * in the coins the pay path accepts. Display only: never an identity or a money input.\n */\nexport interface HubElementPayFundedWallet {\n /** `saved` to the signed-in account, or `last-used` by this browser. */\n kind: \"saved\" | \"last-used\";\n brand: string;\n name: string;\n addressTail: string;\n /** Whole cents, rounded down: a safe integer from 0. */\n cents: number;\n /** The wallet this browser paid the app with last. */\n lastUsed: boolean;\n}\n\n/**\n * The payload of `pay-source-funds`: the money of the wallets the card may show for the current `pay-source`, as the hub\n * read it for each one's address; a wallet whose read failed is left out.\n */\nexport interface HubElementPaySourceFundsPayload {\n wallets: readonly HubElementPayFundedWallet[];\n}\nexport type HubElementPaySourceFundsMessage = PayEnvelope<\"pay-source-funds\", HubElementPaySourceFundsPayload>;\n/**\n * `pay-source-current`: the `pay-source` and `pay-source-saved` before it on the same stream are the hub frame's current\n * pick, so the card replaces its own record of the last pick with them. No payload.\n */\nexport type HubElementPaySourceCurrentMessage = PayEnvelope<\"pay-source-current\", EmptyPayload>;\n/** Derived eligibility shared only between hub-origin documents. No account identifier leaves this stream. */\nexport interface HubElementPayOwnerPayload {\n paymentId: string;\n held: \"nothing-sent\" | \"may-sent\" | null;\n}\nexport type HubElementPayOwnerMessage = PayEnvelope<\"pay-owner\", HubElementPayOwnerPayload>;\nexport type WindowRelayPayOwnerPayload = Omit<WindowRelayPayProgressPayload, \"progress\"> & { owner: HubElementPayOwnerPayload };\nexport type WindowRelayPayOwnerMessage = PayEnvelope<\"relay-pay-owner\", WindowRelayPayOwnerPayload>;\n\nexport type HubElementPayProgressMessage = PayEnvelope<\"pay-progress\", HubElementPayProgressPayload>;\n\n/** `pay-unsent`: the failed `pay-progress` envelope `progressId` names belongs to a payment that was never sent. */\nexport interface HubElementPayUnsentPayload {\n paymentId: string;\n progressId: string;\n}\nexport type HubElementPayUnsentMessage = PayEnvelope<\"pay-unsent\", HubElementPayUnsentPayload>;\n/** `relay-pay-unsent`: as `pay-unsent`, naming the `relay-pay-progress` it proves by its `sequence`. */\nexport type WindowRelayPayUnsentPayload = Omit<WindowRelayPayProgressPayload, \"progress\"> & {\n paymentId: string;\n progressSequence: number;\n};\nexport type WindowRelayPayUnsentMessage = PayEnvelope<\"relay-pay-unsent\", WindowRelayPayUnsentPayload>;\n\n/** Checkout results share the relay pay stream and its operation correlation. */\nexport interface WindowRelayCheckoutResultPayload {\n relayId: string;\n requestId: string;\n sequence: number;\n checkout: HubElementCheckoutResultPayload;\n}\nexport type WindowRelayCheckoutResultMessage = PayEnvelope<\n typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutResult,\n WindowRelayCheckoutResultPayload\n>;\n\n/** The paying wallet of a checkout, on the relay pay stream as its result is. */\nexport interface WindowRelayCheckoutWalletPayload {\n relayId: string;\n requestId: string;\n sequence: number;\n wallet: HubElementCheckoutWalletPayload;\n}\nexport type WindowRelayCheckoutWalletMessage = PayEnvelope<\n typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutWallet,\n WindowRelayCheckoutWalletPayload\n>;\n\nexport function checkAppPayPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_MESSAGE_TYPES.payRequest:\n return checkPayRequest(read, payload);\n case PAY_MESSAGE_TYPES.depositRequest:\n return checkDepositRequest(read, payload);\n default:\n return false;\n }\n}\n\nexport function checkElementPayPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_MESSAGE_TYPES.payRequestAck:\n return checkPayAck(read, payload);\n case PAY_MESSAGE_TYPES.checkoutResult:\n return readCheckoutResult(read, payload) !== undefined;\n case PAY_MESSAGE_TYPES.paid:\n return checkPaid(read, payload);\n case PAY_MESSAGE_TYPES.held:\n case PAY_MESSAGE_TYPES.unconfirmed:\n return checkPaymentNotice(read, payload);\n default:\n return false;\n }\n}\n\nexport function checkHubPayPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case SUA_LINK_C_MESSAGE_TYPES.checkoutResult:\n return readHubCheckoutResult(read, payload) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.checkoutWallet:\n return readCheckoutWallet(read, payload) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.checkoutHeld:\n return checkCheckoutHeld(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.payOwner:\n return checkPayOwner(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.payProgress:\n return checkPayProgress(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.payUnsent: {\n const fields = read(payload, PAY_UNSENT_KEYS);\n return fields !== undefined && text(fields.paymentId) && text(fields.progressId);\n }\n case SUA_LINK_C_MESSAGE_TYPES.paySourceSaved: {\n const fields = read(payload, PAY_SOURCE_SAVED_KEYS);\n return fields !== undefined && readPaySavedWallet(read, fields.saved) !== undefined;\n }\n case SUA_LINK_C_MESSAGE_TYPES.paySourceCurrent:\n return read(payload, EMPTY_KEYS) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.paySourceFunds:\n return readPaySourceFunds(read, payload) !== undefined;\n default:\n return false;\n }\n}\n\nfunction checkPayOwner(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, new Set([\"paymentId\", \"held\"]));\n return (\n fields !== undefined &&\n text(fields.paymentId) &&\n (fields.held === null || fields.held === \"nothing-sent\" || fields.held === \"may-sent\")\n );\n}\n\nconst PAY_SOURCE_SAVED_KEYS = new Set([\"saved\"]);\nconst PAY_UNSENT_KEYS = new Set([\"paymentId\", \"progressId\"]);\nconst EMPTY_KEYS = new Set<string>();\n\n/**\n * A relayed checkout notice (`relayId`, `requestId`, `sequence` and the hub's checkout notice), read once and detached,\n * or `undefined` when any part breaks its rule. The validator and the decoder share it.\n */\nexport function readRelayCheckoutResult(\n read: FieldReader,\n value: unknown,\n isMessageId: (value: unknown) => boolean,\n isRevision: (value: unknown) => boolean,\n): Fields | undefined {\n const fields = read(value, RELAY_CHECKOUT_KEYS);\n if (!fields || !isMessageId(fields.relayId) || !isMessageId(fields.requestId) || !isRevision(fields.sequence))\n return undefined;\n const checkout = readHubCheckoutResult(read, fields.checkout);\n if (!checkout) return undefined;\n fields.checkout = checkout;\n return Object.freeze(fields);\n}\n\nexport function checkRelayPayPayload(\n read: FieldReader,\n type: string,\n payload: unknown,\n isMessageId: (value: unknown) => boolean,\n isRevision: (value: unknown) => boolean,\n): boolean {\n switch (type) {\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutResult:\n return readRelayCheckoutResult(read, payload, isMessageId, isRevision) !== undefined;\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutWallet: {\n const fields = read(payload, RELAY_CHECKOUT_WALLET_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n readCheckoutWallet(read, fields.wallet) !== undefined\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payOwner: {\n const fields = read(payload, new Set([\"relayId\", \"requestId\", \"sequence\", \"owner\"]));\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n checkPayOwner(read, fields.owner)\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payProgress: {\n const fields = read(payload, RELAY_PAY_PROGRESS_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n checkPayProgress(read, fields.progress)\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payUnsent: {\n const fields = read(payload, RELAY_PAY_UNSENT_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n text(fields.paymentId) &&\n isRevision(fields.progressSequence)\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.paySource: {\n const fields = read(payload, RELAY_PAY_SOURCE_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n readPaySourceRemembered(read, fields.remembered) !== undefined\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.paySourceSaved: {\n const fields = read(payload, RELAY_PAY_SOURCE_SAVED_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n readPaySavedWallet(read, fields.saved) !== undefined\n );\n }\n default:\n return false;\n }\n}\n\nconst RELAY_PAY_PROGRESS_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"progress\"]);\n\nconst RELAY_PAY_UNSENT_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"paymentId\", \"progressSequence\"]);\n\nconst RELAY_PAY_SOURCE_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"remembered\"]);\n\nconst RELAY_PAY_SOURCE_SAVED_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"saved\"]);\n\nconst RELAY_CHECKOUT_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"checkout\"]);\n\nconst RELAY_CHECKOUT_WALLET_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"wallet\"]);\n","import { utf8ToBytes } from \"#/encoding/utf8\";\n\nimport { PAY_MESSAGE_TYPES, SUA_PAY_REQUEST_TYPE } from \"./constants\";\nimport {\n APP_ID_PATTERN,\n EVM_ADDRESS_PATTERN,\n HUB_BUILD_ID_PATTERN,\n HUB_FRAME_NAME_PATTERN,\n MAX_ACCOUNT_EMAIL_LENGTH,\n MAX_ACCOUNT_IDENTITY_LENGTH,\n MAX_APP_ORIGIN_LENGTH,\n MAX_PAGE_URL_LENGTH,\n MAX_ELEMENT_BLOCK_SIZE,\n MAX_ELEMENT_LABEL_LENGTH,\n MAX_ELEMENT_RESIZE_DURATION_MS,\n MAX_ERROR_MESSAGE_LENGTH,\n MAX_HUB_BALANCE_AMOUNT_LENGTH,\n MAX_HUB_BUILD_ID_LENGTH,\n MAX_MENU_RECT_VALUE,\n MAX_MESSAGE_ID_LENGTH,\n MAX_RELAY_STATE_EXPIRY_LENGTH,\n MAX_SIGN_MESSAGE_BYTES,\n SUA_ACCOUNT_EMAIL_MESSAGE_TYPES,\n SUA_APP_WINDOW_MESSAGE_TYPES,\n PAY_ELEMENT_FAILURE_CODES,\n SUA_ELEMENT_GEOMETRY_EASINGS,\n PAY_ELEMENT_LIFETIME_MESSAGE_TYPES,\n PAY_ELEMENT_LOAD_FAILURE_REASONS,\n PAY_ELEMENT_MESSAGE_TYPES,\n PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES,\n SUA_ELEMENT_RELOAD_REASONS,\n PAY_FUND_REQUEST_TYPE,\n PAY_FUND_MESSAGE_TYPES,\n PAY_FUND_START_SCREENS,\n PAY_HUB_FRAME_MESSAGE_TYPES,\n SUA_LINK_C_MESSAGE_TYPES,\n PAY_PROTOCOL,\n SUA_PROTOCOL_VERSION,\n SUA_RELAY_CONTROL_MESSAGE_TYPES,\n SUA_RELAY_MESSAGE_TYPES,\n SUA_GUEST_HANDOFF_MESSAGE_TYPE,\n SUA_FUND_WINDOW_MESSAGE_TYPE,\n SUA_WINDOW_CANCEL_CAUSES,\n SUA_WINDOW_END_CAUSES,\n} from \"./constants\";\nimport {\n checkRelayPayPayload,\n readRelayCheckoutResult,\n checkAppPayPayload,\n checkElementPayPayload,\n checkHubPayPayload,\n checkPayRequest,\n readCheckoutResult,\n readHubCheckoutResult,\n readPaySourceFunds,\n readPaySource,\n readPaySourceRemembered,\n} from \"./pay\";\nimport {\n type Fields,\n isPlainObject,\n isStringOfLength,\n matchesOfLength,\n memberSet,\n hasOnlyKeys,\n createSnapshotReader,\n type FieldReader,\n readSomeFields,\n} from \"./shape\";\n\nimport type { DecodedMessage as PublicDecodedMessage, HubDecodedMessage as DecodedMessage, SuaMessage } from \"./codec\";\nimport type {\n AppElementMessage,\n AppWindowAccountEmailMessage,\n HubAppElementMessage,\n AppWindowAccountEmailRefreshMessage,\n AppWindowAccountEmailRefreshReplyMessage,\n AppWindowStateMessage,\n RelayAccountEmailMessage,\n WindowAccountEmailMessage,\n AppHubFrameMessage,\n AppMessage,\n CeremonyRequestType,\n ElementFailureCode,\n ElementHubMessage,\n ElementMessage,\n ElementWindowMessage,\n HubElementMessage,\n HubErrorCode,\n HubFrameAppMessage,\n HubDiagnosticsSession,\n HubMessage,\n HubAppearance,\n HubRequestType,\n HubStatus,\n HubTransport,\n PayElementLoadFailureReason,\n SuaElementReloadReason,\n PayEnvelope,\n SuaWindowCancelCause,\n SuaWindowEndCause,\n WindowElementMessage,\n} from \"./types\";\n\n/**\n * The length of every string `APP_ID_PATTERN` matches: `app_` and 26 ULID characters.\n */\nconst APP_ID_LENGTH = 30;\n\n/**\n * The length of every string `EVM_ADDRESS_PATTERN` matches: `0x` and 40 hex digits.\n */\nconst EVM_ADDRESS_LENGTH = 42;\n\n/**\n * The length of an EVM signature: `0x` and 65 bytes as hex.\n */\nconst EVM_SIGNATURE_LENGTH = 132;\n\n/**\n * An EVM signature as the hub returns it: `0x`, r and s as 128 lowercase hex digits, then v as `1b` or `1c`. Applied\n * after an exact length check.\n */\nconst EVM_SIGNATURE_PATTERN = /^0x[0-9a-f]{128}(?:1b|1c)$/;\n\n/**\n * The length of a canonical UUID: 32 hex digits and 4 dashes.\n */\nconst UUID_LENGTH = 36;\n\n/**\n * A lowercase canonical version-4 UUID: version nibble `4`, variant nibble `8`, `9`, `a` or `b`. Applied after an exact\n * length check. Link C's attachment id and link A/B's document id use it.\n */\nconst UUID_V4_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\n\n/**\n * A link C balance amount: canonical unsigned whole dollars (no leading zero, no sign, grouping or exponent) and\n * exactly six decimals. Applied after the `MAX_HUB_BALANCE_AMOUNT_LENGTH` check.\n */\nconst BALANCE_AMOUNT_PATTERN = /^(?:0|[1-9][0-9]*)\\.[0-9]{6}$/;\n\n/**\n * The most base units a link C balance amount may stand for: `2^256 - 1`.\n */\nconst MAX_BALANCE_BASE_UNITS = 2n ** 256n - 1n;\n\n/**\n * The one currency a ready link C balance may name.\n */\nconst BALANCE_CURRENCY = \"USD\";\n\n/**\n * The allowed keys of each object shape, for the exact-key checks.\n */\nconst EMPTY_KEYS: ReadonlySet<string> = new Set();\nconst ENVELOPE_KEYS = new Set([\"protocol\", \"version\", \"id\", \"type\", \"payload\"]);\nconst ENVELOPE_KEY_LIST = [...ENVELOPE_KEYS];\nconst INIT_KEYS = new Set([\"appId\", \"appearance\"]);\nconst APPEARANCE_PAYLOAD_KEYS = new Set([\"appearance\"]);\nconst APPEARANCE_KEYS = new Set([\"theme\"]);\nconst WIRE_APPEARANCE_KEYS = new Set([...APPEARANCE_KEYS, \"accent\"]);\nconst SIGN_KEYS = new Set([\"message\"]);\nconst FUND_KEYS = new Set([\"start\"]);\nconst FUND_START_SCREENS: ReadonlySet<string> = new Set(Object.values(PAY_FUND_START_SCREENS));\nconst TRANSPORT_KEYS = new Set([\"mode\"]);\nconst STATE_KEYS = new Set([\"status\", \"evmAddress\", \"keypairExpiresAt\"]);\nconst REQUEST_ONLY_KEYS = new Set([\"request\"]);\nconst SIGN_IN_RESULT_KEYS = new Set([\"request\", \"evmAddress\"]);\nconst SIGN_RESULT_KEYS = new Set([\"request\", \"signature\"]);\nconst RESULT_KEYS = new Set([...SIGN_IN_RESULT_KEYS, ...SIGN_RESULT_KEYS]);\nconst ERROR_KEYS = new Set([\"request\", \"code\", \"message\", \"retryAfterSeconds\"]);\nconst CARD_CONFIG_KEYS = new Set([\"revision\", \"labels\", \"action\", \"showBalance\"]);\nconst CARD_LABEL_KEYS = new Set([\"button\", \"actionExpired\", \"done\", \"doneDescription\", \"balanceLabel\"]);\nconst SIGN_ACTION_KEYS = new Set([\"attemptId\", \"message\", \"label\"]);\nconst REFUSAL_KEYS = new Set([\"code\", \"message\"]);\nconst CONFIG_ACK_KEYS = new Set([\"revision\"]);\nconst RESIZE_KEYS = new Set([\"blockSize\", \"durationMs\"]);\nconst GEOMETRY_LIFETIME_KEYS = new Set([\"documentId\", \"initId\"]);\nconst GEOMETRY_CAPABILITIES_KEYS = new Set([...GEOMETRY_LIFETIME_KEYS, \"supported\"]);\nconst GEOMETRY_TARGET_KEYS = new Set([...GEOMETRY_LIFETIME_KEYS, ...RESIZE_KEYS, \"easing\"]);\nconst GEOMETRY_EASINGS: ReadonlySet<string> = new Set(Object.values(SUA_ELEMENT_GEOMETRY_EASINGS));\nconst SIGNED_KEYS = new Set([\"signature\", \"message\", \"attemptId\"]);\nconst CEREMONY_FAILURE_KEYS = new Set([\"request\", \"code\", \"message\", \"retryAfterSeconds\"]);\nconst SIGN_FAILURE_KEYS = new Set([...CEREMONY_FAILURE_KEYS, \"attemptId\"]);\nconst FAILED_KEYS = SIGN_FAILURE_KEYS;\nconst MENU_ANCHOR_KEYS = new Set([\"rect\"]);\nconst MENU_RECT_KEYS = new Set([\"x\", \"y\", \"width\", \"height\"]);\nconst ACTIVITY_KEYS = new Set([\"pending\"]);\nconst SHOW_MENU_KEYS = new Set([\"anchor\"]);\nconst MENU_ENDED_KEYS = new Set([\"restoreFocus\", \"closeId\"]);\nconst ELEMENT_MENU_ENDED_KEYS = new Set([\"restoreFocus\"]);\nconst MENU_REFUSAL_KEYS = new Set([...REFUSAL_KEYS, \"retryAfterSeconds\"]);\nconst GUEST_HANDOFF_KEYS = new Set([\"handoff\"]);\nconst FUND_WINDOW_KEYS = new Set([\"relayId\", \"requestId\", \"walletId\"]);\nconst RELAY_INIT_KEYS = new Set([\"appId\", \"appOrigin\", \"appearance\"]);\nconst ELEMENT_INIT_KEYS = new Set([\"appId\", \"hubFrame\", \"appearance\"]);\nconst ATTACHMENT_KEYS = new Set([\"attachmentId\", \"buildId\"]);\nconst RELAY_BUILD_KEYS = new Set([\"buildId\"]);\nconst DETACH_KEYS = new Set([\"attachmentId\"]);\nconst BALANCE_PAYLOAD_KEYS = new Set([\"balance\"]);\nconst BALANCE_KEYS = new Set([\"status\", \"amount\", \"currency\"]);\nconst BALANCE_STATUS_ONLY_KEYS = new Set([\"status\"]);\nconst WINDOW_OPENED_KEYS = new Set([\"windowId\", \"requestId\", \"request\"]);\nconst WINDOW_ACCEPTED_KEYS = new Set([\"windowId\", \"operationId\"]);\nconst WINDOW_REFUSED_KEYS = new Set([\"windowId\", \"code\", \"message\"]);\nconst WINDOW_RESULT_KEYS = new Set([\"operationId\", \"windowId\", \"requestId\", \"result\"]);\nconst WINDOW_ERROR_KEYS = new Set([\"operationId\", \"windowId\", \"requestId\", \"error\"]);\nconst WINDOW_ENDED_KEYS = new Set([\"operationId\", \"windowId\", \"cause\"]);\nconst WINDOW_CANCEL_KEYS = WINDOW_ENDED_KEYS;\nconst WINDOW_STATE_KEYS = new Set([\"operationId\", \"windowId\", \"requestId\", \"relayId\", \"sequence\", \"state\"]);\nconst RELAY_CLOSE_KEYS = new Set([\"relayId\", \"requestId\", \"request\", \"cause\"]);\nconst PAGE_URL_KEYS = new Set([\"url\"]);\nconst RELAY_PAGE_URL_KEYS = new Set([\"relayId\", \"url\"]);\nconst PAY_SHOWN_KEYS = new Set([\"paymentId\", \"shown\"]);\nconst RELAY_PAY_SHOWN_KEYS = new Set([\"relayId\", \"paymentId\", \"shown\"]);\nconst RELAY_STATE_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"state\"]);\n\nconst APP_WINDOW_STATE_KEYS = new Set([\"appId\", \"appOrigin\", \"sequence\", \"state\"]);\nconst ACCOUNT_EMAIL_ACCOUNT_KEYS = new Set([\"identityId\", \"evmAddress\", \"email\", \"validUntil\"]);\nconst RELAY_ACCOUNT_EMAIL_KEYS = new Set([\"relayId\", \"requestId\", \"sequence\", \"stateSequence\", \"account\"]);\nconst WINDOW_ACCOUNT_EMAIL_KEYS = new Set([\n \"operationId\",\n \"windowId\",\n \"requestId\",\n \"relayId\",\n \"sequence\",\n \"stateSequence\",\n \"account\",\n]);\nconst APP_WINDOW_ACCOUNT_EMAIL_KEYS = new Set([\"appId\", \"appOrigin\", \"sequence\", \"stateSequence\", \"account\"]);\nconst APP_WINDOW_ACCOUNT_EMAIL_REFRESH_KEYS = new Set([\"appId\", \"appOrigin\", \"refreshId\", \"stateSequence\"]);\nconst APP_WINDOW_ACCOUNT_EMAIL_REFRESH_REPLY_KEYS = new Set([\n \"appId\",\n \"appOrigin\",\n \"refreshId\",\n \"stateSequence\",\n \"checkedAt\",\n \"account\",\n]);\nconst ACTION_CHECK_KEYS = new Set([\"documentId\", \"initId\", \"configId\", \"revision\", \"attemptId\"]);\nconst ACTION_ELIGIBILITY_KEYS = new Set([...ACTION_CHECK_KEYS, \"eligible\"]);\nconst RELOAD_REQUEST_KEYS = new Set([\"documentId\", \"initId\", \"reason\"]);\nconst RELOAD_GRANT_KEYS = new Set([\"documentId\", \"initId\", \"granted\"]);\nconst ELEMENT_CONNECTED_KEYS = new Set([\"documentId\", \"initId\", \"sequence\", \"evmAddress\"]);\nconst ELEMENT_LOAD_FAILED_KEYS = new Set([\"reason\"]);\nconst CHECK_STATUS_CAPABILITY_KEYS = new Set([\"documentId\", \"initId\", \"supported\"]);\n\n/**\n * The runtime members of the protocol's string unions, each checked for exhaustiveness against its type.\n */\nconst HUB_STATUSES = memberSet<HubStatus>({\n checking: true,\n \"signed-out\": true,\n \"signed-in\": true,\n \"session-locked\": true,\n \"app-suspended\": true,\n \"wallet-closed\": true,\n unavailable: true,\n});\n\nconst DIAGNOSTICS_SESSIONS = memberSet<HubDiagnosticsSession>({\n checking: true,\n signedOut: true,\n provisioning: true,\n signedIn: true,\n keypairExpired: true,\n sessionLocked: true,\n appSuspended: true,\n walletClosed: true,\n unavailable: true,\n signingOut: true,\n});\nconst DIAGNOSTICS_SUBSCRIPTION_KEYS = new Set([\"subscriptionId\"]);\nconst DIAGNOSTICS_DISABLED_KEYS = new Set([\"subscriptionId\", \"sequence\", \"observedAt\", \"state\"]);\nconst DIAGNOSTICS_READY_KEYS = new Set([...DIAGNOSTICS_DISABLED_KEYS, \"phase\", \"hubStatus\", \"session\", \"storage\", \"source\"]);\n\n/** Exact bounded metadata. Reporting and partitioned frames never claim a shared session. */\nfunction isDiagnosticsStatus(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, DIAGNOSTICS_READY_KEYS);\n if (\n fields === undefined ||\n !isMessageId(fields.subscriptionId) ||\n typeof fields.sequence !== \"number\" ||\n !Number.isSafeInteger(fields.sequence) ||\n fields.sequence < 0 ||\n typeof fields.observedAt !== \"number\" ||\n !Number.isFinite(fields.observedAt) ||\n fields.observedAt < 0\n )\n return false;\n if (fields.state === \"disabled\") return hasOnlyKeys(fields, DIAGNOSTICS_DISABLED_KEYS);\n return (\n fields.state === \"ready\" &&\n (fields.phase === \"connected\" || fields.phase === \"reporting\") &&\n isMember(fields.hubStatus, HUB_STATUSES) &&\n (fields.session === null || isMember(fields.session, DIAGNOSTICS_SESSIONS)) &&\n (fields.storage === \"unpartitioned\" || fields.storage === \"partitioned\") &&\n fields.source === \"provider-frame\" &&\n (!(fields.phase === \"reporting\" || fields.storage === \"partitioned\") || fields.session === null)\n );\n}\n\nconst DIAGNOSTICS_TARGET_KEYS = new Set([\"subscriptionId\", \"targetId\"]);\nconst DETAILS_WITHHELD_KEYS = new Set([\"subscriptionId\", \"sequence\", \"observedAt\", \"schemaVersion\", \"state\"]);\nconst DETAILS_AVAILABLE_KEYS = new Set([\n ...DETAILS_WITHHELD_KEYS,\n \"provenance\",\n \"controllerProvenance\",\n \"heldKey\",\n \"sessionRead\",\n \"effectiveExpiresAt\",\n \"rememberedEmailPresent\",\n \"appAuthorized\",\n \"busy\",\n \"persistedKey\",\n \"cookieAuthority\",\n \"token\",\n \"disconnect\",\n]);\nconst DETAILS_KEY_KEYS = new Set([\"status\", \"publicKeyHex\", \"registeredExpiresAt\"]);\nconst DETAILS_SESSION_KEYS = new Set([\"status\", \"credentialExpiresAt\"]);\nconst DETAILS_DISCONNECT_KEYS = new Set([\"targetId\", \"appName\", \"evmAddress\"]);\nconst DETAILS_ENTITY_STATUSES = new Set([\"idle\", \"loading\", \"ready\", \"stale\", \"error\"]);\n\nfunction isDiagnosticsExpiry(value: unknown): boolean {\n return (\n value === null ||\n (typeof value === \"string\" &&\n value.length <= 64 &&\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/.test(value) &&\n Number.isFinite(Date.parse(value)))\n );\n}\n\nfunction isDiagnosticsDetails(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, DETAILS_AVAILABLE_KEYS);\n if (\n fields === undefined ||\n !isMessageId(fields.subscriptionId) ||\n fields.schemaVersion !== 1 ||\n typeof fields.sequence !== \"number\" ||\n !Number.isSafeInteger(fields.sequence) ||\n fields.sequence < 0 ||\n typeof fields.observedAt !== \"number\" ||\n !Number.isFinite(fields.observedAt) ||\n fields.observedAt < 0\n )\n return false;\n if (fields.state === \"withheld\") return hasOnlyKeys(fields, DETAILS_WITHHELD_KEYS);\n const key = read(fields.heldKey, DETAILS_KEY_KEYS);\n const session = read(fields.sessionRead, DETAILS_SESSION_KEYS);\n if (\n fields.state !== \"available\" ||\n fields.provenance !== \"driver-memory\" ||\n fields.controllerProvenance !== \"controller-observation\" ||\n key === undefined ||\n session === undefined ||\n typeof key.status !== \"string\" ||\n !DETAILS_ENTITY_STATUSES.has(key.status) ||\n typeof session.status !== \"string\" ||\n !DETAILS_ENTITY_STATUSES.has(session.status) ||\n !(key.publicKeyHex === null || (typeof key.publicKeyHex === \"string\" && /^0[23][0-9a-f]{64}$/.test(key.publicKeyHex))) ||\n !isDiagnosticsExpiry(key.registeredExpiresAt) ||\n !isDiagnosticsExpiry(session.credentialExpiresAt) ||\n !isDiagnosticsExpiry(fields.effectiveExpiresAt) ||\n typeof fields.rememberedEmailPresent !== \"boolean\" ||\n fields.appAuthorized !== true ||\n typeof fields.busy !== \"boolean\" ||\n fields.persistedKey !== \"not-inspected\" ||\n fields.cookieAuthority !== \"not-directly-observable\" ||\n fields.token !== \"not-inspected\"\n )\n return false;\n if (key.status !== \"ready\" && key.status !== \"stale\" && (key.publicKeyHex !== null || key.registeredExpiresAt !== null))\n return false;\n if (session.status !== \"ready\" && session.status !== \"stale\" && session.credentialExpiresAt !== null) return false;\n if (fields.disconnect === null) return true;\n const target = read(fields.disconnect, DETAILS_DISCONNECT_KEYS);\n return (\n target !== undefined &&\n !fields.busy &&\n isMessageId(target.targetId) &&\n typeof target.appName === \"string\" &&\n target.appName.length > 0 &&\n target.appName.length <= 256 &&\n isEvmAddress(target.evmAddress)\n );\n}\n\nconst HUB_TRANSPORTS = memberSet<HubTransport>({\n overlay: true,\n popup: true,\n});\n\nconst HUB_REQUEST_TYPES = memberSet<HubRequestType>({\n init: true,\n \"sign-in\": true,\n sign: true,\n \"sign-out\": true,\n disconnect: true,\n [PAY_FUND_REQUEST_TYPE]: true,\n [SUA_PAY_REQUEST_TYPE]: true,\n});\n\n/**\n * Every `HubErrorCode`, as a record for {@link memberSet}, so `ElementFailureCode` extends it without a second list.\n */\nconst HUB_ERROR_CODE_MEMBERS: Record<HubErrorCode, true> = {\n cancelled: true,\n busy: true,\n \"not-initialized\": true,\n \"signed-out\": true,\n refused: true,\n \"outcome-unknown\": true,\n \"cosignature-required\": true,\n \"session-locked\": true,\n \"app-suspended\": true,\n \"rate-limited\": true,\n \"wallet-closed\": true,\n \"wallet-not-ready\": true,\n network: true,\n internal: true,\n};\n\nconst HUB_ERROR_CODES = memberSet<HubErrorCode>(HUB_ERROR_CODE_MEMBERS);\n\nconst ELEMENT_FAILURE_CODES = memberSet<ElementFailureCode>({\n ...HUB_ERROR_CODE_MEMBERS,\n [PAY_ELEMENT_FAILURE_CODES.unavailable]: true,\n [PAY_ELEMENT_FAILURE_CODES.popupBlocked]: true,\n});\n\n/**\n * The ceremony requests: every `HubRequestType` except `init`. A Pay window answers only these to a Pay element.\n */\nconst CEREMONY_REQUESTS = memberSet<CeremonyRequestType>({\n \"sign-in\": true,\n sign: true,\n \"sign-out\": true,\n disconnect: true,\n [PAY_FUND_REQUEST_TYPE]: true,\n [SUA_PAY_REQUEST_TYPE]: true,\n});\n\n/**\n * Why a Pay window ended, as `window-ended` carries it.\n */\nconst WINDOW_END_CAUSES = memberSet<SuaWindowEndCause>({\n [SUA_WINDOW_END_CAUSES.settled]: true,\n [SUA_WINDOW_END_CAUSES.windowCancel]: true,\n [SUA_WINDOW_END_CAUSES.windowLost]: true,\n [SUA_WINDOW_END_CAUSES.teardown]: true,\n});\n\n/**\n * Why the hub frame cancels a Pay window, as `window-cancel` and `relay-close` carry it.\n */\nconst WINDOW_CANCEL_CAUSES = memberSet<SuaWindowCancelCause>({\n [SUA_WINDOW_CANCEL_CAUSES.windowCancel]: true,\n [SUA_WINDOW_CANCEL_CAUSES.teardown]: true,\n});\n\n/**\n * Why a Pay element asks for its reload.\n */\nconst ELEMENT_RELOAD_REASONS = memberSet<SuaElementReloadReason>({\n [SUA_ELEMENT_RELOAD_REASONS.buildMismatch]: true,\n});\n\n/**\n * Why a Pay element's view is a load failure, as `element-load-failed` carries it.\n */\nconst ELEMENT_LOAD_FAILURE_REASONS = memberSet<PayElementLoadFailureReason>({\n [PAY_ELEMENT_LOAD_FAILURE_REASONS.hubFrame]: true,\n [PAY_ELEMENT_LOAD_FAILURE_REASONS.internal]: true,\n});\n\n/**\n * The ceremony requests whose `failed` carries no attempt id.\n */\nconst NON_SIGN_CEREMONY_REQUESTS = memberSet<Exclude<CeremonyRequestType, \"sign\">>({\n \"sign-in\": true,\n \"sign-out\": true,\n disconnect: true,\n [PAY_FUND_REQUEST_TYPE]: true,\n [SUA_PAY_REQUEST_TYPE]: true,\n});\n\n/**\n * Reports whether `value` is a correlation id: a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters.\n */\nfunction isMessageId(value: unknown): value is string {\n return isStringOfLength(value, 1, MAX_MESSAGE_ID_LENGTH);\n}\n\n/**\n * Reports whether `value` is one of `members`.\n */\nfunction isMember(value: unknown, members: ReadonlySet<string>): value is string {\n return typeof value === \"string\" && members.has(value);\n}\n\n/**\n * Reports whether `value` is an app id matching `APP_ID_PATTERN`.\n */\nfunction isAppId(value: unknown): value is string {\n return matchesOfLength(value, APP_ID_LENGTH, APP_ID_PATTERN);\n}\n\n/**\n * Reports whether `value` is an app origin: a string of 1 to `MAX_APP_ORIGIN_LENGTH` characters that `URL` reads as\n * an `http:` or `https:` URL whose `origin` is the string itself. So no path, trailing slash, credentials, query,\n * fragment, default port, opaque origin or other spelling of the same origin. Its length is checked first, so a huge\n * string is never parsed.\n */\nfunction isAppOrigin(value: unknown): value is string {\n if (!isStringOfLength(value, 1, MAX_APP_ORIGIN_LENGTH)) {\n return false;\n }\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n return (url.protocol === \"http:\" || url.protocol === \"https:\") && url.origin === value;\n}\n\n/** A `pay-shown` payment id and method: a message id, and `null` or a `pay-source` `remembered`. */\nfunction isPayShown(read: FieldReader, fields: Fields): boolean {\n return isMessageId(fields.paymentId) && readPaySourceRemembered(read, fields.shown) !== undefined;\n}\n\n/**\n * Reports whether `value` is an app page address: a string of 1 to `MAX_PAGE_URL_LENGTH` characters that `URL` reads\n * as an `http:` or `https:` URL whose `href` is the string itself (so the spelling `location.href` gives), with no\n * user name or password. Its length is checked first, so a huge string is never parsed.\n */\nfunction isPageUrl(value: unknown): value is string {\n if (!isStringOfLength(value, 1, MAX_PAGE_URL_LENGTH)) {\n return false;\n }\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n return (\n (url.protocol === \"http:\" || url.protocol === \"https:\") &&\n url.href === value &&\n url.username === \"\" &&\n url.password === \"\"\n );\n}\n\n/**\n * Reports whether `value` is an EVM address matching `EVM_ADDRESS_PATTERN`.\n */\nfunction isEvmAddress(value: unknown): value is string {\n return matchesOfLength(value, EVM_ADDRESS_LENGTH, EVM_ADDRESS_PATTERN);\n}\n\n/** Reads the theme and discards the legacy accent from the decoded snapshot. */\nfunction hasWireAppearance(read: FieldReader, value: unknown): boolean {\n const fields = read(value, WIRE_APPEARANCE_KEYS);\n if (fields === undefined || !hasAppearanceTheme(fields)) return false;\n delete fields.accent;\n return true;\n}\n\nfunction hasAppearanceTheme(fields: Fields | undefined): boolean {\n return fields?.theme === \"dark\" || fields?.theme === \"light\";\n}\n\n/**\n * Checks an `appearance` payload: exactly `appearance`, a valid appearance.\n */\nfunction isAppearancePayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, APPEARANCE_PAYLOAD_KEYS);\n return fields !== undefined && hasWireAppearance(read, fields.appearance);\n}\n\n/**\n * Reports whether `value` is a message to sign: a non-empty string whose UTF-8 encoding is at most\n * `MAX_SIGN_MESSAGE_BYTES` bytes. Its UTF-16 length is checked first, so a huge string is never encoded.\n */\nexport function isSignText(value: unknown): value is string {\n return isStringOfLength(value, 1, MAX_SIGN_MESSAGE_BYTES) && utf8ToBytes(value).length <= MAX_SIGN_MESSAGE_BYTES;\n}\n\n/**\n * Reads a strict envelope: exactly the envelope keys, this protocol and version, a valid id and a plain-object\n * payload. Returns the snapshot, or `undefined` when any rule fails.\n */\nfunction readStrictEnvelope(read: FieldReader, value: unknown): Fields | undefined {\n const fields = read(value, ENVELOPE_KEYS);\n if (fields === undefined) {\n return undefined;\n }\n if (fields.protocol !== PAY_PROTOCOL || fields.version !== SUA_PROTOCOL_VERSION) {\n return undefined;\n }\n if (!isMessageId(fields.id) || typeof fields.type !== \"string\" || !isPlainObject(fields.payload)) {\n return undefined;\n }\n return fields;\n}\n\n/**\n * Checks an app → hub payload against its type's rules.\n */\nfunction isAppPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case \"init\": {\n const fields = read(payload, INIT_KEYS);\n return fields !== undefined && isAppId(fields.appId) && hasWireAppearance(read, fields.appearance);\n }\n case \"appearance\":\n return isAppearancePayload(read, payload);\n case \"sign-in\":\n case \"sign-out\":\n case \"disconnect\":\n case PAY_FUND_MESSAGE_TYPES.cancel:\n return read(payload, EMPTY_KEYS) !== undefined;\n case \"sign\": {\n const fields = read(payload, SIGN_KEYS);\n return fields !== undefined && isSignText(fields.message);\n }\n case PAY_FUND_REQUEST_TYPE: {\n const fields = read(payload, FUND_KEYS);\n return fields !== undefined && (fields.start === undefined || isMember(fields.start, FUND_START_SCREENS));\n }\n default:\n return false;\n }\n}\n\n/**\n * Checks a `transport` payload: exactly `mode`, a `HubTransport`.\n */\nfunction isTransportPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, TRANSPORT_KEYS);\n return fields !== undefined && isMember(fields.mode, HUB_TRANSPORTS);\n}\n\n/**\n * Checks a state snapshot: a `HubStatus`, and an optional EVM address and keypair expiry. An expiry is a string of 1 to\n * `maxExpiryLength` characters, its length checked before `Date.parse` reads it as a finite number. The existing\n * `state` passes no bound; the ordered state wrappers pass `MAX_RELAY_STATE_EXPIRY_LENGTH`.\n */\nfunction isStateSnapshot(read: FieldReader, value: unknown, maxExpiryLength: number = Number.POSITIVE_INFINITY): boolean {\n const fields = read(value, STATE_KEYS);\n if (fields === undefined || !isMember(fields.status, HUB_STATUSES)) {\n return false;\n }\n if (fields.evmAddress !== undefined && !isEvmAddress(fields.evmAddress)) {\n return false;\n }\n const expiresAt = fields.keypairExpiresAt;\n return expiresAt === undefined || (isStringOfLength(expiresAt, 1, maxExpiryLength) && Number.isFinite(Date.parse(expiresAt)));\n}\n\n/**\n * Checks a `state` payload: a `HubStatus`, and an optional EVM address and keypair expiry, with no bound on the\n * expiry's length.\n */\nfunction isStatePayload(read: FieldReader, payload: unknown): boolean {\n return isStateSnapshot(read, payload);\n}\n\n/**\n * Reports whether `value` is an EVM signature matching `EVM_SIGNATURE_PATTERN`.\n */\nfunction isEvmSignature(value: unknown): boolean {\n return matchesOfLength(value, EVM_SIGNATURE_LENGTH, EVM_SIGNATURE_PATTERN);\n}\n\n/**\n * Checks a `result` payload, keyed by the `request` it answers, which must be one of `requests`.\n */\nfunction isResultPayload(read: FieldReader, payload: unknown, requests: ReadonlySet<string> = HUB_REQUEST_TYPES): boolean {\n const fields = read(payload, RESULT_KEYS);\n if (!isMember(fields?.request, requests)) {\n return false;\n }\n switch (fields?.request) {\n case \"init\":\n case \"sign-out\":\n case \"disconnect\":\n case PAY_FUND_REQUEST_TYPE:\n case SUA_PAY_REQUEST_TYPE:\n return hasOnlyKeys(fields, REQUEST_ONLY_KEYS);\n case \"sign-in\":\n return hasOnlyKeys(fields, SIGN_IN_RESULT_KEYS) && isEvmAddress(fields.evmAddress);\n case \"sign\":\n return hasOnlyKeys(fields, SIGN_RESULT_KEYS) && isEvmSignature(fields.signature);\n default:\n return false;\n }\n}\n\n/**\n * Reports whether `value` is a developer-facing error description: a string of at most `MAX_ERROR_MESSAGE_LENGTH`\n * characters, possibly empty.\n */\nfunction isErrorDetail(value: unknown): value is string {\n return isStringOfLength(value, 0, MAX_ERROR_MESSAGE_LENGTH);\n}\n\n/**\n * Reports whether `value` is an optional wait: absent (`undefined`), or a non-negative safe integer of seconds.\n */\nfunction isOptionalRetryAfterSeconds(value: unknown): boolean {\n return value === undefined || (Number.isSafeInteger(value) && (value as number) >= 0);\n}\n\n/**\n * Checks an `error` payload: a request type of `requests`, an error code, a bounded message and an optional wait.\n */\nfunction isErrorPayload(read: FieldReader, payload: unknown, requests: ReadonlySet<string> = HUB_REQUEST_TYPES): boolean {\n const fields = read(payload, ERROR_KEYS);\n if (fields === undefined) {\n return false;\n }\n if (!isMember(fields.request, requests) || !isMember(fields.code, HUB_ERROR_CODES)) {\n return false;\n }\n return isErrorDetail(fields.message) && isOptionalRetryAfterSeconds(fields.retryAfterSeconds);\n}\n\n/**\n * Checks a hub → app payload against its type's rules.\n */\nfunction isHubPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case \"ready\":\n case \"overlay-open\":\n case \"overlay-close\":\n case PAY_FUND_MESSAGE_TYPES.received:\n return read(payload, EMPTY_KEYS) !== undefined;\n case \"transport\":\n return isTransportPayload(read, payload);\n case \"state\":\n return isStatePayload(read, payload);\n case \"result\":\n return isResultPayload(read, payload);\n case \"error\":\n return isErrorPayload(read, payload);\n default:\n return false;\n }\n}\n\n/**\n * Reports whether `value` is a config bundle's revision: a safe integer from 1.\n */\nfunction isRevision(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 1;\n}\n\n/**\n * Reports whether `value` is a label set: a plain object whose keys all belong to `allowed`, each absent, `undefined`\n * or a string of at most `MAX_ELEMENT_LABEL_LENGTH` characters.\n */\nfunction isLabels(read: FieldReader, value: unknown, allowed: ReadonlySet<string>): boolean {\n const fields = read(value, allowed);\n return (\n fields !== undefined &&\n Object.values(fields).every((label) => label === undefined || isStringOfLength(label, 0, MAX_ELEMENT_LABEL_LENGTH))\n );\n}\n\n/**\n * Reports whether `value` is a card's sign action: exactly an attempt id, a message to sign and a label.\n */\nfunction isSignAction(read: FieldReader, value: unknown): boolean {\n const fields = read(value, SIGN_ACTION_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.attemptId) &&\n isSignText(fields.message) &&\n isStringOfLength(fields.label, 0, MAX_ELEMENT_LABEL_LENGTH)\n );\n}\n\n/**\n * Checks an `element-config` payload against the exact bundle keys and field rules.\n */\nfunction isElementConfigPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, CARD_CONFIG_KEYS);\n return (\n fields !== undefined &&\n isRevision(fields.revision) &&\n isLabels(read, fields.labels, CARD_LABEL_KEYS) &&\n (fields.action === null || isSignAction(read, fields.action)) &&\n typeof fields.showBalance === \"boolean\"\n );\n}\n\n/**\n * Reports whether `value` is a hub frame name: a string of 1 to `MAX_MESSAGE_ID_LENGTH` characters matching\n * {@link HUB_FRAME_NAME_PATTERN}. The length is checked first, so a huge string never reaches the regex.\n */\nexport function isHubFrameName(value: unknown): value is string {\n return isStringOfLength(value, 1, MAX_MESSAGE_ID_LENGTH) && HUB_FRAME_NAME_PATTERN.test(value);\n}\n\n/**\n * Checks an `element-init` payload: exactly an app id, a hub frame name and a valid appearance.\n */\nfunction isElementInitPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, ELEMENT_INIT_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isHubFrameName(fields.hubFrame) &&\n hasWireAppearance(read, fields.appearance)\n );\n}\n\n/**\n * Checks an app → Pay element payload against its type's rules.\n */\nfunction isAppElementPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_MESSAGE_TYPES.payRequest:\n case PAY_MESSAGE_TYPES.depositRequest:\n return checkAppPayPayload(read, type, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.geometryCapabilities:\n return isGeometryCapabilitiesPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.geometryComplete:\n case PAY_ELEMENT_MESSAGE_TYPES.geometryCancelled:\n return hasGeometryLifetime(read(payload, GEOMETRY_LIFETIME_KEYS));\n case PAY_ELEMENT_MESSAGE_TYPES.menuEnded: {\n const fields = read(payload, ELEMENT_MENU_ENDED_KEYS);\n return fields !== undefined && typeof fields.restoreFocus === \"boolean\";\n }\n case PAY_ELEMENT_MESSAGE_TYPES.init:\n return isElementInitPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.config:\n return isElementConfigPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.focus:\n return read(payload, EMPTY_KEYS) !== undefined;\n case \"appearance\":\n return isAppearancePayload(read, payload);\n case PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.actionEligibility:\n return isActionEligibilityPayload(read, payload);\n case PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.reloadGrant:\n return isReloadGrantPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.checkStatusCapability: {\n const fields = read(payload, CHECK_STATUS_CAPABILITY_KEYS);\n return (\n fields !== undefined &&\n isUuid(fields.documentId) &&\n isMessageId(fields.initId) &&\n typeof fields.supported === \"boolean\"\n );\n }\n case PAY_ELEMENT_MESSAGE_TYPES.checkStatusSettled:\n return isActionCheckPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.pageUrl: {\n const fields = read(payload, PAGE_URL_KEYS);\n return fields !== undefined && isPageUrl(fields.url);\n }\n default:\n return false;\n }\n}\n\n/**\n * Reports whether `value` is a finite number from `min` to `max`, inclusive. Fractions are valid.\n */\nfunction isFiniteWithin(value: unknown, min: number, max: number): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= min && value <= max;\n}\n\n/**\n * Checks a handshake refusal payload: exactly a `HubErrorCode` and a bounded message. It names no request.\n */\nfunction isRefusalPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, REFUSAL_KEYS);\n return fields !== undefined && isMember(fields.code, HUB_ERROR_CODES) && isErrorDetail(fields.message);\n}\n\n/**\n * Checks a `resize` payload: a finite block size from 0 to `MAX_ELEMENT_BLOCK_SIZE`, and a whole duration from 0 to\n * `MAX_ELEMENT_RESIZE_DURATION_MS`. Both are required.\n */\nfunction isResizePayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, RESIZE_KEYS);\n if (fields === undefined || !isFiniteWithin(fields.blockSize, 0, MAX_ELEMENT_BLOCK_SIZE)) {\n return false;\n }\n const durationMs = fields.durationMs;\n return Number.isSafeInteger(durationMs) && isFiniteWithin(durationMs, 0, MAX_ELEMENT_RESIZE_DURATION_MS);\n}\n\n/** Checks the document and accepted-init correlation after one exact-key read. */\nfunction hasGeometryLifetime(fields: Fields | undefined): fields is Fields {\n return fields !== undefined && isUuid(fields.documentId) && isMessageId(fields.initId);\n}\n\n/** Checks the bidirectional geometry advertisement without changing either handshake. */\nfunction isGeometryCapabilitiesPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, GEOMETRY_CAPABILITIES_KEYS);\n return hasGeometryLifetime(fields) && typeof fields.supported === \"boolean\";\n}\n\n/** Checks a target's lifetime, bounded geometry and fixed easing vocabulary in one payload read. */\nfunction isGeometryTargetPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, GEOMETRY_TARGET_KEYS);\n return (\n hasGeometryLifetime(fields) &&\n isFiniteWithin(fields.blockSize, 0, MAX_ELEMENT_BLOCK_SIZE) &&\n Number.isSafeInteger(fields.durationMs) &&\n isFiniteWithin(fields.durationMs, 0, MAX_ELEMENT_RESIZE_DURATION_MS) &&\n isMember(fields.easing, GEOMETRY_EASINGS)\n );\n}\n\n/**\n * Checks a `signed` payload: exactly a signature, the signed message and the attempt id.\n */\nfunction isSignedPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, SIGNED_KEYS);\n return (\n fields !== undefined && isEvmSignature(fields.signature) && isSignText(fields.message) && isMessageId(fields.attemptId)\n );\n}\n\n/**\n * Checks a `failed` payload, keyed by the `request` that failed. The payload is read once over the sign branch's\n * keys; a sign failure needs an attempt id, and every other ceremony's failure must not hold the key at all.\n */\nfunction isFailedPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, FAILED_KEYS);\n if (fields === undefined || !isMember(fields.code, ELEMENT_FAILURE_CODES)) {\n return false;\n }\n if (!isErrorDetail(fields.message) || !isOptionalRetryAfterSeconds(fields.retryAfterSeconds)) {\n return false;\n }\n if (fields.request === \"sign\") {\n return isMessageId(fields.attemptId);\n }\n return isMember(fields.request, NON_SIGN_CEREMONY_REQUESTS) && hasOnlyKeys(fields, CEREMONY_FAILURE_KEYS);\n}\n\n/**\n * Reports whether `value` is a menu rect: exactly `x`, `y`, `width` and `height`, each finite; `x` and `y` within\n * ±`MAX_MENU_RECT_VALUE`, `width` and `height` from 0 to `MAX_MENU_RECT_VALUE`.\n */\nfunction isMenuRect(read: FieldReader, value: unknown): boolean {\n const fields = read(value, MENU_RECT_KEYS);\n return (\n fields !== undefined &&\n isFiniteWithin(fields.x, -MAX_MENU_RECT_VALUE, MAX_MENU_RECT_VALUE) &&\n isFiniteWithin(fields.y, -MAX_MENU_RECT_VALUE, MAX_MENU_RECT_VALUE) &&\n isFiniteWithin(fields.width, 0, MAX_MENU_RECT_VALUE) &&\n isFiniteWithin(fields.height, 0, MAX_MENU_RECT_VALUE)\n );\n}\n\n/**\n * Checks a Pay element → app payload against its type's rules.\n */\nfunction isElementPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_MESSAGE_TYPES.payRequestAck:\n case PAY_MESSAGE_TYPES.checkoutResult:\n case PAY_MESSAGE_TYPES.paid:\n case PAY_MESSAGE_TYPES.held:\n case PAY_MESSAGE_TYPES.unconfirmed:\n return checkElementPayPayload(read, type, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.geometryCapabilities:\n return isGeometryCapabilitiesPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.geometryTarget:\n return isGeometryTargetPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.ready:\n case PAY_ELEMENT_MESSAGE_TYPES.accepted:\n return read(payload, EMPTY_KEYS) !== undefined;\n case PAY_ELEMENT_MESSAGE_TYPES.refused:\n return isRefusalPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.configAck: {\n const fields = read(payload, CONFIG_ACK_KEYS);\n return fields !== undefined && isRevision(fields.revision);\n }\n case PAY_ELEMENT_MESSAGE_TYPES.resize:\n return isResizePayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.signed:\n return isSignedPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.failed:\n return isFailedPayload(read, payload);\n case PAY_ELEMENT_MESSAGE_TYPES.menuAnchor: {\n const fields = read(payload, MENU_ANCHOR_KEYS);\n return fields !== undefined && isMenuRect(read, fields.rect);\n }\n case PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.actionCheck:\n case PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.checkStatusRequest:\n return isActionCheckPayload(read, payload);\n case PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.reloadRequest:\n return isReloadRequestPayload(read, payload);\n case PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.connected: {\n const fields = read(payload, ELEMENT_CONNECTED_KEYS);\n return (\n fields !== undefined &&\n isUuid(fields.documentId) &&\n isMessageId(fields.initId) &&\n isRevision(fields.sequence) &&\n isEvmAddress(fields.evmAddress)\n );\n }\n case PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.viewShown:\n return read(payload, EMPTY_KEYS) !== undefined;\n case PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.loadFailed: {\n const fields = read(payload, ELEMENT_LOAD_FAILED_KEYS);\n return fields !== undefined && isMember(fields.reason, ELEMENT_LOAD_FAILURE_REASONS);\n }\n default:\n return false;\n }\n}\n\n/**\n * Checks an app → hub frame payload: `show-menu`, or any app → hub payload.\n */\nfunction isAppHubFramePayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_HUB_FRAME_MESSAGE_TYPES.overlayHidden:\n return read(payload, EMPTY_KEYS) !== undefined;\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsSubscribe:\n return read(payload, EMPTY_KEYS) !== undefined;\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsInspect:\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsUnsubscribe: {\n const fields = read(payload, DIAGNOSTICS_SUBSCRIPTION_KEYS);\n return fields !== undefined && isMessageId(fields.subscriptionId);\n }\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsDisconnect: {\n const fields = read(payload, DIAGNOSTICS_TARGET_KEYS);\n return fields !== undefined && isMessageId(fields.subscriptionId) && isMessageId(fields.targetId);\n }\n case PAY_HUB_FRAME_MESSAGE_TYPES.showMenu: {\n const fields = read(payload, SHOW_MENU_KEYS);\n return fields !== undefined && isMenuRect(read, fields.anchor);\n }\n default:\n return isAppPayload(read, type, payload);\n }\n}\n\n/**\n * Checks a `menu-refused` payload: exactly a `HubErrorCode` and a bounded message, and an optional wait. It names no\n * request.\n */\nfunction isMenuRefusalPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, MENU_REFUSAL_KEYS);\n return (\n fields !== undefined &&\n isMember(fields.code, HUB_ERROR_CODES) &&\n isErrorDetail(fields.message) &&\n isOptionalRetryAfterSeconds(fields.retryAfterSeconds)\n );\n}\n\n/**\n * Checks an `activity` payload: exactly `pending`, a boolean.\n */\nfunction isActivityPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, ACTIVITY_KEYS);\n return fields !== undefined && typeof fields.pending === \"boolean\";\n}\n\n/**\n * Checks a hub frame → app payload: `activity`, the two `show-menu` answers, or any hub → app payload.\n */\nfunction isHubFrameAppPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsDetails:\n return isDiagnosticsDetails(read, payload);\n case PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsStatus:\n return isDiagnosticsStatus(read, payload);\n case PAY_HUB_FRAME_MESSAGE_TYPES.activity:\n return isActivityPayload(read, payload);\n case PAY_HUB_FRAME_MESSAGE_TYPES.menuEnded: {\n const fields = read(payload, MENU_ENDED_KEYS);\n return (\n fields !== undefined &&\n (fields.restoreFocus === true\n ? isMessageId(fields.closeId)\n : fields.restoreFocus === false && hasOnlyKeys(fields, ELEMENT_MENU_ENDED_KEYS))\n );\n }\n case PAY_HUB_FRAME_MESSAGE_TYPES.menuAccepted:\n return read(payload, EMPTY_KEYS) !== undefined;\n case PAY_HUB_FRAME_MESSAGE_TYPES.menuRefused:\n return isMenuRefusalPayload(read, payload);\n default:\n return isHubPayload(read, type, payload);\n }\n}\n\n/**\n * Checks a Pay element → Pay window payload: `relay-init`, or an app → hub payload other than `init`.\n */\nfunction isElementWindowPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case SUA_PAY_REQUEST_TYPE:\n return checkPayRequest(read, payload, true);\n case SUA_GUEST_HANDOFF_MESSAGE_TYPE: {\n const fields = read(payload, GUEST_HANDOFF_KEYS);\n return fields !== undefined && typeof fields.handoff === \"string\" && fields.handoff.length > 0;\n }\n case SUA_FUND_WINDOW_MESSAGE_TYPE: {\n const fields = read(payload, FUND_WINDOW_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n (fields.walletId === null || isMessageId(fields.walletId))\n );\n }\n case SUA_RELAY_MESSAGE_TYPES.init: {\n const fields = read(payload, RELAY_INIT_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isAppOrigin(fields.appOrigin) &&\n hasWireAppearance(read, fields.appearance)\n );\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.close:\n return isRelayClosePayload(read, payload);\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.pageUrl: {\n const fields = read(payload, RELAY_PAGE_URL_KEYS);\n return fields !== undefined && isMessageId(fields.relayId) && isPageUrl(fields.url);\n }\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payShown: {\n const fields = read(payload, RELAY_PAY_SHOWN_KEYS);\n return fields !== undefined && isMessageId(fields.relayId) && isPayShown(read, fields);\n }\n case \"init\":\n return false;\n default:\n return isAppPayload(read, type, payload);\n }\n}\n\n/**\n * Checks a Pay window → Pay element payload: `relay-build`, the two `relay-init` answers, a `result` or `error` for a ceremony\n * request, or any other hub → app payload.\n */\nfunction isWindowElementPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case SUA_RELAY_MESSAGE_TYPES.build: {\n const fields = read(payload, RELAY_BUILD_KEYS);\n return fields !== undefined && isHubBuildId(fields.buildId);\n }\n case SUA_RELAY_MESSAGE_TYPES.accepted:\n return read(payload, EMPTY_KEYS) !== undefined;\n case SUA_RELAY_MESSAGE_TYPES.refused:\n return isRefusalPayload(read, payload);\n case \"result\":\n return isResultPayload(read, payload, CEREMONY_REQUESTS);\n case \"error\":\n return isErrorPayload(read, payload, CEREMONY_REQUESTS);\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.closeAccepted:\n return isRelayClosePayload(read, payload);\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.state:\n return isRelayStatePayload(read, payload);\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutResult:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutWallet:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payOwner:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payProgress:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.payUnsent:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.paySource:\n case SUA_RELAY_CONTROL_MESSAGE_TYPES.paySourceSaved:\n return checkRelayPayPayload(read, type, payload, isMessageId, isRevision);\n case SUA_LINK_C_MESSAGE_TYPES.checkoutHeld:\n return checkHubPayPayload(read, type, payload);\n default:\n return isHubPayload(read, type, payload);\n }\n}\n\n/**\n * Reports whether `value` is a lowercase canonical version-4 UUID.\n */\nfunction isUuid(value: unknown): value is string {\n return matchesOfLength(value, UUID_LENGTH, UUID_V4_PATTERN);\n}\n\n/**\n * Reports whether `value` is a hub build id: 1 to `MAX_HUB_BUILD_ID_LENGTH` characters matching\n * {@link HUB_BUILD_ID_PATTERN}. The length is checked first, so a huge string never reaches the regex.\n */\nexport function isHubBuildId(value: unknown): value is string {\n return isStringOfLength(value, 1, MAX_HUB_BUILD_ID_LENGTH) && HUB_BUILD_ID_PATTERN.test(value);\n}\n\n/**\n * Reports whether `value` is a link C balance amount: at most `MAX_HUB_BALANCE_AMOUNT_LENGTH` characters matching\n * {@link BALANCE_AMOUNT_PATTERN}, whose base units (the digits without the point) are at most `2^256 - 1`. The length\n * and the pattern are checked before the integer conversion.\n */\nfunction isBalanceAmount(value: unknown): value is string {\n if (!isStringOfLength(value, 1, MAX_HUB_BALANCE_AMOUNT_LENGTH) || !BALANCE_AMOUNT_PATTERN.test(value)) {\n return false;\n }\n return BigInt(value.replace(\".\", \"\")) <= MAX_BALANCE_BASE_UNITS;\n}\n\n/**\n * Reports whether `value` is a link C balance: `loading` or `unavailable` with no other key, or `ready` with an amount\n * and an optional `USD` currency.\n */\nfunction isElementBalance(read: FieldReader, value: unknown): boolean {\n const fields = read(value, BALANCE_KEYS);\n switch (fields?.status) {\n case \"loading\":\n case \"unavailable\":\n return hasOnlyKeys(fields, BALANCE_STATUS_ONLY_KEYS);\n case \"ready\":\n return isBalanceAmount(fields.amount) && (fields.currency === undefined || fields.currency === BALANCE_CURRENCY);\n default:\n return false;\n }\n}\n\n/**\n * Checks an `attach-accepted` or `attach-confirm` payload: exactly an attachment id and a hub build id.\n */\nfunction isAttachmentPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, ATTACHMENT_KEYS);\n return fields !== undefined && isUuid(fields.attachmentId) && isHubBuildId(fields.buildId);\n}\n\n/**\n * Checks a `window-result` payload: exactly the window operation's three ids and a ceremony result.\n */\nfunction isWindowResultPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, WINDOW_RESULT_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.operationId) &&\n isMessageId(fields.windowId) &&\n isMessageId(fields.requestId) &&\n isResultPayload(read, fields.result, CEREMONY_REQUESTS)\n );\n}\n\n/**\n * Checks a `window-error` payload: exactly the window operation's three ids and a ceremony error.\n */\nfunction isWindowErrorPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, WINDOW_ERROR_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.operationId) &&\n isMessageId(fields.windowId) &&\n isMessageId(fields.requestId) &&\n isErrorPayload(read, fields.error, CEREMONY_REQUESTS)\n );\n}\n\n/**\n * Checks a `window-ended` payload: an operation id or `null`, a window id and a window end cause.\n */\nfunction isWindowEndedPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, WINDOW_ENDED_KEYS);\n return (\n fields !== undefined &&\n (fields.operationId === null || isMessageId(fields.operationId)) &&\n isMessageId(fields.windowId) &&\n isMember(fields.cause, WINDOW_END_CAUSES)\n );\n}\n\n/**\n * Checks a `window-state` payload: the window operation's three ids, the relay id, a sequence (a safe integer from 1)\n * and a state whose expiry is at most `MAX_RELAY_STATE_EXPIRY_LENGTH` characters.\n */\nfunction isWindowStatePayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, WINDOW_STATE_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.operationId) &&\n isMessageId(fields.windowId) &&\n isMessageId(fields.requestId) &&\n isMessageId(fields.relayId) &&\n isRevision(fields.sequence) &&\n isStateSnapshot(read, fields.state, MAX_RELAY_STATE_EXPIRY_LENGTH)\n );\n}\n\n/**\n * Checks a Pay element → hub frame payload: a link C request or report, or one of the six ceremony requests.\n */\nfunction isElementHubPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case SUA_LINK_C_MESSAGE_TYPES.menuPayment: {\n const fields = read(payload, new Set([\"paymentId\", \"held\"]));\n return (\n fields !== undefined &&\n typeof fields.held === \"boolean\" &&\n (fields.paymentId === null ||\n (typeof fields.paymentId === \"string\" &&\n fields.paymentId.length > 0 &&\n fields.paymentId.length <= MAX_MESSAGE_ID_LENGTH))\n );\n }\n case SUA_PAY_REQUEST_TYPE:\n return checkPayRequest(read, payload, true);\n case SUA_LINK_C_MESSAGE_TYPES.probe:\n case SUA_LINK_C_MESSAGE_TYPES.attach:\n return read(payload, EMPTY_KEYS) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.confirm:\n return isAttachmentPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.detach: {\n const fields = read(payload, DETACH_KEYS);\n return fields !== undefined && isUuid(fields.attachmentId);\n }\n case SUA_LINK_C_MESSAGE_TYPES.windowOpened: {\n const fields = read(payload, WINDOW_OPENED_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.windowId) &&\n isMessageId(fields.requestId) &&\n isMember(fields.request, CEREMONY_REQUESTS)\n );\n }\n case SUA_LINK_C_MESSAGE_TYPES.windowResult:\n return isWindowResultPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.windowError:\n return isWindowErrorPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.windowEnded:\n return isWindowEndedPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.windowState:\n return isWindowStatePayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.pageUrl: {\n const fields = read(payload, PAGE_URL_KEYS);\n return fields !== undefined && (fields.url === null || isPageUrl(fields.url));\n }\n case SUA_LINK_C_MESSAGE_TYPES.payShown: {\n const fields = read(payload, PAY_SHOWN_KEYS);\n return fields !== undefined && isPayShown(read, fields);\n }\n case \"sign-in\":\n case \"sign\":\n case \"sign-out\":\n case \"disconnect\":\n case PAY_FUND_REQUEST_TYPE:\n return isAppPayload(read, type, payload);\n default:\n return false;\n }\n}\n\n/**\n * Checks a hub frame → Pay element payload: a link C answer or notice, or the reused `state`, `transport`,\n * `activity`, or a `result` or `error` for a ceremony request.\n */\nfunction isHubElementPayload(read: FieldReader, type: string, payload: unknown): boolean {\n switch (type) {\n case SUA_LINK_C_MESSAGE_TYPES.checkoutResult:\n case SUA_LINK_C_MESSAGE_TYPES.checkoutWallet:\n case SUA_LINK_C_MESSAGE_TYPES.checkoutHeld:\n case SUA_LINK_C_MESSAGE_TYPES.payOwner:\n case SUA_LINK_C_MESSAGE_TYPES.payProgress:\n case SUA_LINK_C_MESSAGE_TYPES.payUnsent:\n case SUA_LINK_C_MESSAGE_TYPES.paySourceSaved:\n case SUA_LINK_C_MESSAGE_TYPES.paySourceCurrent:\n case SUA_LINK_C_MESSAGE_TYPES.paySourceFunds:\n return checkHubPayPayload(read, type, payload);\n case PAY_HUB_FRAME_MESSAGE_TYPES.overlayHidden:\n return read(payload, EMPTY_KEYS) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.probeAck:\n return read(payload, EMPTY_KEYS) !== undefined;\n case SUA_LINK_C_MESSAGE_TYPES.accepted:\n return isAttachmentPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.refused:\n return isRefusalPayload(read, payload);\n case SUA_LINK_C_MESSAGE_TYPES.balance: {\n const fields = read(payload, BALANCE_PAYLOAD_KEYS);\n return fields !== undefined && isElementBalance(read, fields.balance);\n }\n case SUA_LINK_C_MESSAGE_TYPES.windowAccepted: {\n const fields = read(payload, WINDOW_ACCEPTED_KEYS);\n return fields !== undefined && isMessageId(fields.windowId) && isMessageId(fields.operationId);\n }\n case SUA_LINK_C_MESSAGE_TYPES.windowRefused: {\n const fields = read(payload, WINDOW_REFUSED_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.windowId) &&\n isMember(fields.code, HUB_ERROR_CODES) &&\n isErrorDetail(fields.message)\n );\n }\n case SUA_LINK_C_MESSAGE_TYPES.windowCancel: {\n const fields = read(payload, WINDOW_CANCEL_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.operationId) &&\n isMessageId(fields.windowId) &&\n isMember(fields.cause, WINDOW_CANCEL_CAUSES)\n );\n }\n case \"state\":\n return isStatePayload(read, payload);\n case \"transport\":\n return isTransportPayload(read, payload);\n case PAY_HUB_FRAME_MESSAGE_TYPES.activity:\n return isActivityPayload(read, payload);\n case \"result\":\n return isResultPayload(read, payload, CEREMONY_REQUESTS);\n case \"error\":\n return isErrorPayload(read, payload, CEREMONY_REQUESTS);\n default:\n return false;\n }\n}\n\n/**\n * Checks a `relay-close` or `relay-close-accepted` payload: exactly the relay id, the request id, a ceremony request\n * and a cancel cause.\n */\nfunction isRelayClosePayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, RELAY_CLOSE_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isMember(fields.request, CEREMONY_REQUESTS) &&\n isMember(fields.cause, WINDOW_CANCEL_CAUSES)\n );\n}\n\n/**\n * Checks a `relay-state` payload: exactly the relay id, the request id, a sequence (a safe integer from 1) and a state\n * whose expiry is at most `MAX_RELAY_STATE_EXPIRY_LENGTH` characters.\n */\nfunction isRelayStatePayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, RELAY_STATE_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n isStateSnapshot(read, fields.state, MAX_RELAY_STATE_EXPIRY_LENGTH)\n );\n}\n\n/**\n * Reports whether a snapshot holds the fields every action check names: a document id, an init id, a config id, a\n * revision and an attempt id.\n */\nfunction hasActionCheckFields(fields: Fields): boolean {\n return (\n isUuid(fields.documentId) &&\n isMessageId(fields.initId) &&\n isMessageId(fields.configId) &&\n isRevision(fields.revision) &&\n isMessageId(fields.attemptId)\n );\n}\n\n/**\n * Checks an `element-action-check` payload: exactly the five correlation fields.\n */\nfunction isActionCheckPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, ACTION_CHECK_KEYS);\n return fields !== undefined && hasActionCheckFields(fields);\n}\n\n/**\n * Checks an `element-action-eligibility` payload: exactly the five correlation fields and a boolean `eligible`.\n */\nfunction isActionEligibilityPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, ACTION_ELIGIBILITY_KEYS);\n return fields !== undefined && hasActionCheckFields(fields) && typeof fields.eligible === \"boolean\";\n}\n\n/**\n * Checks an `element-reload-request` payload: exactly a document id, an init id and a reload reason.\n */\nfunction isReloadRequestPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, RELOAD_REQUEST_KEYS);\n return (\n fields !== undefined &&\n isUuid(fields.documentId) &&\n isMessageId(fields.initId) &&\n isMember(fields.reason, ELEMENT_RELOAD_REASONS)\n );\n}\n\n/**\n * Checks an `element-reload-grant` payload: exactly a document id, an init id and a boolean `granted`.\n */\nfunction isReloadGrantPayload(read: FieldReader, payload: unknown): boolean {\n const fields = read(payload, RELOAD_GRANT_KEYS);\n return fields !== undefined && isUuid(fields.documentId) && isMessageId(fields.initId) && typeof fields.granted === \"boolean\";\n}\n\n/**\n * Reports whether `value` is shaped like an envelope of this protocol, whatever its version, type or payload: a plain\n * object (prototype `Object.prototype` or `null`) with `protocol === \"stridge-sua\"`, a positive integer `version`, a\n * non-empty string `id` of at most `MAX_MESSAGE_ID_LENGTH` characters, a non-empty string `type`, and a plain-object\n * `payload`. Extra keys are allowed here.\n *\n * The channel uses it to drop foreign `postMessage` traffic cheaply and to tell \"ours, but another version\" (log it)\n * from noise. It does not check the sender's origin; the channel does.\n */\nexport function isSuaEnvelope(value: unknown): value is PayEnvelope<string, unknown> {\n try {\n const fields = readSomeFields(value, ENVELOPE_KEY_LIST);\n if (fields === undefined || fields.protocol !== PAY_PROTOCOL) {\n return false;\n }\n const version = fields.version;\n if (!Number.isSafeInteger(version) || (version as number) < 1) {\n return false;\n }\n return (\n isMessageId(fields.id) && typeof fields.type === \"string\" && fields.type.length > 0 && isPlainObject(fields.payload)\n );\n } catch {\n return false;\n }\n}\n\n/**\n * Reports whether `value` is a well-formed app → hub message ({@link AppMessage}), and rejects every other shape.\n *\n * Envelope: exactly the keys `protocol`, `version`, `id`, `type`, `payload`; `protocol === PAY_PROTOCOL`; `version\n * === SUA_PROTOCOL_VERSION`; `id` a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters; `payload` a plain\n * object. Then, by `type` (any other type is rejected):\n *\n * - `init` — payload keys exactly `appId` and `appearance`; `appId` matches `APP_ID_PATTERN`; `appearance` is a valid\n * appearance.\n * - `appearance` — payload key exactly `appearance`, a valid appearance.\n * - `sign-in`, `sign-out`, `disconnect` — payload is `{}` (no keys).\n * - `fund` — payload is `{}` or exactly `start`, one of `PAY_FUND_START_SCREENS`.\n * - `fund-cancel` — payload is `{}`; the hub matches its envelope id to the pending Fund request.\n * - `sign` — payload key exactly `message`: a non-empty string whose UTF-8 encoding is at most\n * `MAX_SIGN_MESSAGE_BYTES` bytes (its UTF-16 length is checked first, so a huge string is never encoded).\n *\n * An appearance carries `theme` `\"dark\"` or `\"light\"`. The decoder also accepts and discards a legacy `accent` key.\n *\n * Throughout, \"plain object\" means a non-null, non-array object whose prototype is `Object.prototype` or `null`; \"exact\n * keys\" means no key outside the listed ones; an optional key whose value is `undefined` counts as absent. Never\n * throws.\n */\nexport function isAppMessage(value: unknown): value is AppMessage {\n return decodeAppMessage(value) !== undefined;\n}\n\nexport function decodeAppMessage(value: unknown): DecodedMessage<AppMessage> | undefined {\n return decodeMessage<AppMessage>(value, isAppPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed hub → app message ({@link HubMessage}), and rejects every other shape.\n *\n * Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):\n *\n * - `ready`, `overlay-open`, `overlay-close`, `fund-received` — payload is `{}`. The app matches the Fund receipt's id.\n * - `transport` — payload key exactly `mode`: `\"overlay\"` or `\"popup\"`.\n * - `state` — payload keys within `status`, `evmAddress`, `keypairExpiresAt`; `status` is a `HubStatus`;\n * `evmAddress`, when present, matches `EVM_ADDRESS_PATTERN`; `keypairExpiresAt`, when present, is a string that\n * `Date.parse` reads as a finite number.\n * - `result` — payload keyed by `request`: `init`, `sign-out`, `disconnect` and `fund` have no other\n * key;\n * `sign-in` has exactly `evmAddress` (matching `EVM_ADDRESS_PATTERN`); `sign` has exactly `signature`: `0x`, 128\n * lowercase hex digits, then `1b` or `1c` (132 characters). Any other `request` is rejected.\n * - `error` — payload keys within `request`, `code`, `message`, `retryAfterSeconds`; `request` is a `HubRequestType`;\n * `code` is a `HubErrorCode`; `message` is a string of at most `MAX_ERROR_MESSAGE_LENGTH` characters (it may be\n * empty); `retryAfterSeconds`, when present, is a non-negative safe integer.\n *\n * The same plain-object, exact-key and `undefined`-as-absent rules apply. Never throws.\n */\nexport function isHubMessage(value: unknown): value is HubMessage {\n return decodeHubMessage(value) !== undefined;\n}\n\nexport function decodeHubMessage(value: unknown): PublicDecodedMessage<HubMessage> | undefined {\n return decodeMessage<HubMessage>(value, isHubPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed app → Pay element message ({@link AppElementMessage}), and rejects every\n * other shape, including the app → hub `init` and ceremony requests.\n *\n * Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):\n *\n * - `element-init` — payload keys exactly `appId` (matching `APP_ID_PATTERN`), `hubFrame` (1 to\n * `MAX_MESSAGE_ID_LENGTH` characters: an ASCII letter or digit, then ASCII letters, digits, `_` or `-`) and\n * `appearance` (a valid appearance, as for {@link isAppMessage}). All three are required; any\n * other key, a build id included, is rejected.\n * - `element-config` — one full bundle with exactly `revision`, `labels`, `action` and `showBalance`; `labels` has\n * at most `button`, `actionExpired`, `done`, `doneDescription`, `balanceLabel`; `action` is `null` or exactly\n * `attemptId` (a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters), `message` (as for `sign`) and\n * `label`; `showBalance` is a boolean.\n *\n * `revision` is a safe integer from 1. Every label, the action's included, is a string of at most\n * `MAX_ELEMENT_LABEL_LENGTH` characters and may be empty.\n * - `focus` — payload is `{}`.\n * - `appearance` — as for {@link isAppMessage}.\n * - `element-action-eligibility` — payload keys exactly `documentId` (a lowercase canonical version-4 UUID),\n * `initId`, `configId` and `attemptId` (each a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters),\n * `revision` (a safe integer from 1) and `eligible` (a boolean).\n * - `element-reload-grant` — payload keys exactly `documentId` and `initId`, as above, and `granted` (a boolean). No\n * URL, build id or counter.\n * - `element-check-status-capability` — payload keys exactly `documentId` and `initId`, as above, and `supported`\n * (a boolean). The receiver matches the accepted document and init.\n * - `element-check-status-settled` — exactly the five correlation fields of `element-action-eligibility` without\n * `eligible`. The receiver matches the pending Check status request's envelope id and all payload fields.\n *\n * The same plain-object, exact-key and `undefined`-as-absent rules apply. A legacy `kind` key is rejected, even when\n * its value is `undefined`. It checks shape only: the channel checks the sender and origin, binds `element-init`'s\n * app id to the served app and its hub frame to any URL hint, and matches each lifetime answer to its pending\n * request. Never throws.\n */\nexport function isAppElementMessage(value: unknown): value is AppElementMessage {\n return decodeAppElementMessage(value) !== undefined;\n}\n\nexport function decodeAppElementMessage(value: unknown): DecodedMessage<HubAppElementMessage> | undefined {\n return decodeMessage<HubAppElementMessage>(value, isAppElementPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed Pay element → app message ({@link ElementMessage}), and rejects every other\n * shape, including every app → hub, hub → app and app → Pay element message.\n *\n * Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):\n *\n * - `element-ready`, `element-accepted` — payload is `{}`.\n * - `element-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most\n * `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty). No `request` key.\n * - `element-config-ack` — payload key exactly `revision`, a safe integer from 1.\n * - `resize` — payload keys exactly `blockSize`, a finite number from 0 to `MAX_ELEMENT_BLOCK_SIZE`, and `durationMs`,\n * a safe integer from 0 to `MAX_ELEMENT_RESIZE_DURATION_MS`. Both are required.\n * - `signed` — payload keys exactly `signature` (as for a sign `result`), `message` (as for `sign`) and `attemptId` (a\n * non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters).\n * - `failed` — payload keyed by `request`, with `code` an `ElementFailureCode`, `message` as for `element-refused`,\n * and an optional `retryAfterSeconds`, a non-negative safe integer. `sign` also requires `attemptId`, as for\n * `signed`; `sign-in`, `sign-out`, `disconnect` and `fund` must not hold the `attemptId` key. Any other\n * `request`, `init` included, is rejected.\n * - `menu-anchor` — payload key exactly `rect`: exactly `x`, `y`, `width`, `height`, each a finite number; `x` and `y`\n * within ±`MAX_MENU_RECT_VALUE`, `width` and `height` from 0 to `MAX_MENU_RECT_VALUE`. Fractions are valid.\n * - `element-action-check` — payload keys exactly `documentId` (a lowercase canonical version-4 UUID), `initId`,\n * `configId` and `attemptId` (each a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters) and `revision`\n * (a safe integer from 1).\n * - `element-reload-request` — payload keys exactly `documentId` and `initId`, as above, and `reason`\n * (`build-mismatch`). No build id or URL.\n * - `element-connected` — payload keys exactly `documentId` and `initId`, as above, `sequence` (a safe integer from 1)\n * and `evmAddress` (matching `EVM_ADDRESS_PATTERN`). The receiver checks the current init, pinned document and\n * increasing sequence; this guard checks only their shape.\n * - `element-view-shown` — payload is `{}`.\n * - `element-load-failed` — payload key exactly `reason` (`hub-frame` or `internal`).\n * - `element-check-status-request` — exactly the five correlation fields of `element-action-check`. Requires a\n * settlement response despite its notification-table entry. The receiver checks the current config and spent\n * attempt before invoking the app's callback; shape validation alone does not prove either.\n *\n * The same plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel checks the\n * sender, correlates answers by `id`, and matches a `signed` or `failed` notice to its captured attempt. Never throws.\n */\nexport function isElementMessage(value: unknown): value is ElementMessage {\n return decodeElementMessage(value) !== undefined;\n}\n\nexport function decodeElementMessage(value: unknown): PublicDecodedMessage<ElementMessage> | undefined {\n return decodeMessage<ElementMessage>(value, isElementPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed app → hub frame message ({@link AppHubFrameMessage}), and rejects every\n * other shape. It accepts every message {@link isAppMessage} accepts, by the same rules, and adds:\n *\n * - `show-menu` — payload key exactly `anchor`: a rect as for `menu-anchor`, in the app's viewport.\n *\n * The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel\n * checks the sender. Never throws.\n */\nexport function isAppHubFrameMessage(value: unknown): value is AppHubFrameMessage {\n return decodeAppHubFrameMessage(value) !== undefined;\n}\n\nexport function decodeAppHubFrameMessage(value: unknown): DecodedMessage<AppHubFrameMessage> | undefined {\n return decodeMessage<AppHubFrameMessage>(value, isAppHubFramePayload);\n}\n\n/**\n * Reports whether `value` is a well-formed hub frame → app message ({@link HubFrameAppMessage}), and rejects every\n * other shape. It accepts every message {@link isHubMessage} accepts, by the same rules, and adds:\n *\n * - `activity` — payload key exactly `pending`, a boolean.\n * - `menu-accepted` — payload is `{}`.\n * - `menu-refused` — payload keys `code` (a `HubErrorCode`), `message` (a string of at most\n * `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty) and an optional `retryAfterSeconds`, a non-negative safe\n * integer. No `request` key.\n *\n * `show-menu` is not a `HubRequestType`, so a `result` or `error` for it is rejected. The same envelope, plain-object,\n * exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel checks the sender and correlates\n * the menu answers by `id`. Never throws.\n */\nexport function isHubFrameAppMessage(value: unknown): value is HubFrameAppMessage {\n return decodeHubFrameAppMessage(value) !== undefined;\n}\n\nexport function decodeHubFrameAppMessage(value: unknown): PublicDecodedMessage<HubFrameAppMessage> | undefined {\n return decodeMessage<HubFrameAppMessage>(value, isHubFrameAppPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed Pay element → Pay window message ({@link ElementWindowMessage}), and\n * rejects every other shape, the ordinary `init` included. By `type`:\n *\n * - `relay-init` — payload keys exactly `appId` (matching `APP_ID_PATTERN`), `appOrigin` and `appearance` (a valid\n * appearance). `appOrigin` is a string of 1 to `MAX_APP_ORIGIN_LENGTH` characters that `URL` reads as an `http:` or\n * `https:` URL whose `origin` is the string itself: no path, trailing slash, credentials, query, fragment, default\n * port or other spelling of the same origin.\n * - `appearance`, `sign-in`, `sign`, `sign-out`, `disconnect`, `fund` — as for {@link isAppMessage}.\n * - `relay-close` — payload keys exactly `relayId` and `requestId` (each a non-empty string of at most\n * `MAX_MESSAGE_ID_LENGTH` characters), `request` (a ceremony request, never `init`) and `cause` (`window-cancel` or\n * `teardown`).\n *\n * The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the Sua\n * window checks the sender, binds `appId` to the app it serves, checks `appOrigin` against the app's registry and\n * matches a `relay-close` to its current operation. Never throws.\n */\nexport function isElementWindowMessage(value: unknown): value is ElementWindowMessage {\n return decodeElementWindowMessage(value) !== undefined;\n}\n\nexport function decodeElementWindowMessage(value: unknown): DecodedMessage<ElementWindowMessage> | undefined {\n return decodeMessage<ElementWindowMessage>(value, isElementWindowPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed Pay window → Pay element message ({@link WindowElementMessage}), and\n * rejects every other shape. By `type`:\n *\n * - `relay-build` — payload key exactly `buildId` (1 to `MAX_HUB_BUILD_ID_LENGTH` ASCII letters, digits, `_` or `-`,\n * starting with a letter or digit), as for `attach-accepted`.\n * - `relay-accepted` — payload is `{}`.\n * - `relay-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most\n * `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty). No `request` key.\n * - `ready`, `transport`, `state`, `overlay-open`, `overlay-close` — as for {@link isHubMessage}.\n * - `result`, `error` — as for {@link isHubMessage}, but `request` is `sign-in`, `sign`, `sign-out`, `disconnect`,\n * `fund`. An answer to `init` is rejected: `relay-init` has its own answers.\n * - `relay-close-accepted` — the `relay-close` payload rules of {@link isElementWindowMessage}.\n * - `relay-state` — payload keys exactly `relayId` and `requestId` (as for `relay-close`), `sequence` (a safe integer\n * from 1) and `state` (as for `state`, with a `keypairExpiresAt` of at most `MAX_RELAY_STATE_EXPIRY_LENGTH`\n * characters, its length checked before it is parsed).\n * - `relay-pay-progress` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and\n * `progress` (a link C `pay-progress` payload).\n * - `relay-pay-source` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and\n * `remembered` (`null`, or a link C `pay-source` `remembered`).\n * - `relay-pay-source-saved` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and\n * `saved` (`null`, or a link C `pay-source-saved` `saved`).\n * - `checkout-held` — the link C payload: the Pay window's own stored checkout for the `pay` it admitted.\n *\n * The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the Sua\n * element checks the sender and correlates each answer and state with its relay and operation. Never throws.\n */\nexport function isWindowElementMessage(value: unknown): value is WindowElementMessage {\n return decodeWindowElementMessage(value) !== undefined;\n}\n\nexport function decodeWindowElementMessage(value: unknown): DecodedMessage<WindowElementMessage> | undefined {\n return decodeMessage<WindowElementMessage>(value, isWindowElementPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed Pay element → hub frame message ({@link ElementHubMessage}, link C), and\n * rejects every other shape. By `type`:\n *\n * - `hub-probe`, `attach` — payload is exactly `{}`; a legacy `kind` key is rejected, even when its value is `undefined`.\n * - `attach-confirm` — payload keys exactly `attachmentId` (a lowercase canonical version-4 UUID) and `buildId` (1 to\n * `MAX_HUB_BUILD_ID_LENGTH` ASCII letters, digits, `_` or `-`, starting with a letter or digit).\n * - `detach` — payload key exactly `attachmentId`, as above.\n * - `window-opened` — payload keys exactly `windowId` and `requestId` (each a non-empty string of at most\n * `MAX_MESSAGE_ID_LENGTH` characters) and `request` (a ceremony request, never `init`).\n * - `window-result` — payload keys exactly `operationId`, `windowId`, `requestId` (ids as above) and `result` (a\n * ceremony `result` payload, as for {@link isWindowElementMessage}).\n * - `window-error` — the same ids and `error` (a ceremony `error` payload, as for {@link isWindowElementMessage}).\n * - `window-ended` — payload keys exactly `operationId` (an id, or `null`), `windowId` and `cause` (`settled`,\n * `window-cancel`, `window-lost` or `teardown`).\n * - `window-state` — payload keys exactly `operationId`, `windowId`, `requestId`, `relayId` (ids), `sequence` (a safe\n * integer from 1) and `state` (as for {@link isWindowElementMessage}'s `relay-state`).\n * - `sign-in`, `sign`, `sign-out`, `disconnect`, `fund` — as for {@link isAppMessage}.\n *\n * `init`, `appearance`, `result` and `error` are rejected. The same envelope, plain-object, exact-key and\n * `undefined`-as-absent rules apply. It checks shape only, and only the ordinary envelope id: the hub frame checks the\n * sender's document and relationship, the attachment's namespace and stream order, and matches every message to its\n * pending table. Never throws.\n */\nexport function isElementHubMessage(value: unknown): value is ElementHubMessage {\n return decodeElementHubMessage(value) !== undefined;\n}\n\nexport function decodeElementHubMessage(value: unknown): DecodedMessage<ElementHubMessage> | undefined {\n return decodeMessage<ElementHubMessage>(value, isElementHubPayload);\n}\n\n/**\n * Reports whether `value` is a well-formed hub frame → Pay element message ({@link HubElementMessage}, link C), and\n * rejects every other shape. By `type`:\n *\n * - `hub-probe-ack`, `pay-source-current` — payload is `{}`.\n * - `attach-accepted` — the `attach-confirm` payload rules of {@link isElementHubMessage}.\n * - `attach-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most\n * `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty).\n * - `balance` — payload key exactly `balance`: `{status: \"loading\"}` or `{status: \"unavailable\"}` with no other key,\n * or `{status: \"ready\", amount, currency?}` where `amount` is canonical dollars with exactly six decimals (no leading\n * zero, sign, grouping or exponent), at most `MAX_HUB_BALANCE_AMOUNT_LENGTH` characters and at most `2^256 - 1`\n * base units, and `currency`, when present, is `USD`.\n * - `window-accepted` — payload keys exactly `windowId` and `operationId`, each a non-empty string of at most\n * `MAX_MESSAGE_ID_LENGTH` characters.\n * - `window-refused` — payload keys exactly `windowId` (an id), `code` and `message` (as for `attach-refused`).\n * - `window-cancel` — payload keys exactly `operationId`, `windowId` (ids) and `cause` (`window-cancel` or\n * `teardown`).\n * - `state`, `transport` — as for {@link isHubMessage}.\n * - `activity` — as for {@link isHubFrameAppMessage}.\n * - `result`, `error` — as for {@link isWindowElementMessage}: never an answer to `init`.\n *\n * `overlay-hidden` requires an empty payload; its id names the initiating ceremony. `ready`, `overlay-open` and\n * `overlay-close` are rejected. The same envelope, plain-object, exact-key and `undefined`-as-absent\n * rules apply. It checks shape only, and only the ordinary envelope id: the Pay element checks the sender's document\n * and relationship, the attachment's namespace and stream order, and matches every answer to its pending request.\n * Never throws.\n */\nexport function isHubElementMessage(value: unknown): value is HubElementMessage {\n return decodeHubElementMessage(value) !== undefined;\n}\n\nexport function decodeHubElementMessage(value: unknown): DecodedMessage<HubElementMessage> | undefined {\n return decodeMessage<HubElementMessage>(value, isHubElementPayload);\n}\n\n/**\n * Checks an app-owned Pay window → hub frame payload by `type`: only `app-window-state`, whose payload keys are\n * exactly `appId` (matching `APP_ID_PATTERN`), `appOrigin` (as for `relay-init`), `sequence` (a safe integer from 1)\n * and `state` (as for `relay-state`).\n */\nfunction isAppWindowHubPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_APP_WINDOW_MESSAGE_TYPES.state) {\n return false;\n }\n const fields = read(payload, APP_WINDOW_STATE_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isAppOrigin(fields.appOrigin) &&\n isRevision(fields.sequence) &&\n isStateSnapshot(read, fields.state, MAX_RELAY_STATE_EXPIRY_LENGTH)\n );\n}\n\n/**\n * Reports whether `value` is a well-formed app-owned Pay window → hub frame message ({@link AppWindowStateMessage}),\n * and rejects every other shape: `app-window-state` with payload keys exactly `appId` (matching `APP_ID_PATTERN`),\n * `appOrigin` (1 to `MAX_APP_ORIGIN_LENGTH` characters that `URL` reads as an `http:` or `https:` origin, spelled as\n * that origin), `sequence` (a safe integer from 1) and `state` (as for {@link isWindowElementMessage}'s\n * `relay-state`). The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape\n * only: the hub frame checks the sender's document and relationship, the app connection and the order. Never throws.\n */\nexport function isAppWindowHubMessage(value: unknown): value is AppWindowStateMessage {\n return decodeAppWindowHubMessage(value) !== undefined;\n}\n\nexport function decodeAppWindowHubMessage(value: unknown): DecodedMessage<AppWindowStateMessage> | undefined {\n return decodeMessage<AppWindowStateMessage>(value, isAppWindowHubPayload);\n}\n\n/**\n * A control, format, line-separator or paragraph-separator character: none may appear in an account-email report's\n * identity or email, so the text the hub shows reads as it was typed and holds no hidden or reordering mark.\n */\nconst UNSAFE_TEXT_PATTERN = /[\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}]/u;\n\n/**\n * Reports whether `value` is a string of 1 to `maxLength` characters with no control or format character. Its length\n * is checked first, so a huge string never reaches the pattern.\n */\nfunction isSafeText(value: unknown, maxLength: number): value is string {\n return isStringOfLength(value, 1, maxLength) && !UNSAFE_TEXT_PATTERN.test(value);\n}\n\n/**\n * Checks an account-email report's `account`: `null`, or exactly `identityId` (safe text of at most\n * `MAX_ACCOUNT_IDENTITY_LENGTH` characters), `evmAddress` (matching `EVM_ADDRESS_PATTERN`), `email` (`null`, or safe\n * text of at most `MAX_ACCOUNT_EMAIL_LENGTH` characters) and `validUntil` (a safe integer from 1).\n */\nfunction isAccountEmailAccount(read: FieldReader, value: unknown): boolean {\n if (value === null) {\n return true;\n }\n const fields = read(value, ACCOUNT_EMAIL_ACCOUNT_KEYS);\n return (\n fields !== undefined &&\n isSafeText(fields.identityId, MAX_ACCOUNT_IDENTITY_LENGTH) &&\n isEvmAddress(fields.evmAddress) &&\n (fields.email === null || isSafeText(fields.email, MAX_ACCOUNT_EMAIL_LENGTH)) &&\n isRevision(fields.validUntil)\n );\n}\n\n/**\n * Checks a `relay-account-email` payload: exactly `relayId`, `requestId` (ids), `sequence`, `stateSequence` (safe\n * integers from 1) and `account`.\n */\nfunction isRelayAccountEmailPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.relay) {\n return false;\n }\n const fields = read(payload, RELAY_ACCOUNT_EMAIL_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.relayId) &&\n isMessageId(fields.requestId) &&\n isRevision(fields.sequence) &&\n isRevision(fields.stateSequence) &&\n isAccountEmailAccount(read, fields.account)\n );\n}\n\n/**\n * Checks a `window-account-email` payload: exactly `operationId`, `windowId`, `requestId`, `relayId` (ids),\n * `sequence`, `stateSequence` (safe integers from 1) and `account`.\n */\nfunction isWindowAccountEmailPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.window) {\n return false;\n }\n const fields = read(payload, WINDOW_ACCOUNT_EMAIL_KEYS);\n return (\n fields !== undefined &&\n isMessageId(fields.operationId) &&\n isMessageId(fields.windowId) &&\n isMessageId(fields.requestId) &&\n isMessageId(fields.relayId) &&\n isRevision(fields.sequence) &&\n isRevision(fields.stateSequence) &&\n isAccountEmailAccount(read, fields.account)\n );\n}\n\n/**\n * Checks an `app-window-account-email` payload: exactly `appId`, `appOrigin` (as for `app-window-state`), `sequence`,\n * `stateSequence` (safe integers from 1) and `account`.\n */\nfunction isAppWindowAccountEmailPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindow) {\n return false;\n }\n const fields = read(payload, APP_WINDOW_ACCOUNT_EMAIL_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isAppOrigin(fields.appOrigin) &&\n isRevision(fields.sequence) &&\n isRevision(fields.stateSequence) &&\n isAccountEmailAccount(read, fields.account)\n );\n}\n\n/**\n * Checks an `app-window-account-email-refresh` payload: exactly `appId`, `appOrigin` (as for `app-window-state`),\n * `refreshId` (an id) and `stateSequence` (a safe integer from 1).\n */\nfunction isAppWindowAccountEmailRefreshPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindowRefresh) {\n return false;\n }\n const fields = read(payload, APP_WINDOW_ACCOUNT_EMAIL_REFRESH_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isAppOrigin(fields.appOrigin) &&\n isMessageId(fields.refreshId) &&\n isRevision(fields.stateSequence)\n );\n}\n\n/**\n * Checks an `app-window-account-email-refresh-reply` payload: exactly `appId`, `appOrigin`, `refreshId` and\n * `stateSequence` (as for the request), `checkedAt` (a safe integer from 1) and `account`.\n */\nfunction isAppWindowAccountEmailRefreshReplyPayload(read: FieldReader, type: string, payload: unknown): boolean {\n if (type !== SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindowRefreshReply) {\n return false;\n }\n const fields = read(payload, APP_WINDOW_ACCOUNT_EMAIL_REFRESH_REPLY_KEYS);\n return (\n fields !== undefined &&\n isAppId(fields.appId) &&\n isAppOrigin(fields.appOrigin) &&\n isMessageId(fields.refreshId) &&\n isRevision(fields.stateSequence) &&\n isRevision(fields.checkedAt) &&\n isAccountEmailAccount(read, fields.account)\n );\n}\n\n/**\n * Decodes a Pay window → opener `relay-account-email` ({@link RelayAccountEmailMessage}) into a frozen snapshot, or\n * `undefined` for every other shape: payload keys exactly `relayId` and `requestId` (ids), `sequence` and\n * `stateSequence` (safe integers from 1), and `account`. `account` is `null`, or exactly `identityId` (1 to\n * `MAX_ACCOUNT_IDENTITY_LENGTH` characters), `evmAddress` (matching `EVM_ADDRESS_PATTERN`), `email` (`null`, or 1 to\n * `MAX_ACCOUNT_EMAIL_LENGTH` characters) and `validUntil` (a safe integer from 1); the identity and the email hold no\n * control, format, line-separator or paragraph-separator character. The same envelope, plain-object, exact-key and\n * `undefined`-as-absent rules as every other guard apply. It checks shape only: the receiver checks the sender's\n * document, the operation, the state it refers to and the lease. No other guard accepts it. Never throws, and never\n * reports what it rejected.\n */\nexport function decodeRelayAccountEmailMessage(value: unknown): DecodedMessage<RelayAccountEmailMessage> | undefined {\n return decodeMessage<RelayAccountEmailMessage>(value, isRelayAccountEmailPayload);\n}\n\n/**\n * Decodes a Pay element → hub frame `window-account-email` ({@link WindowAccountEmailMessage}) into a frozen snapshot,\n * or `undefined` for every other shape: payload keys exactly `operationId`, `windowId`, `requestId`, `relayId` (ids),\n * `sequence`, `stateSequence` and `account`, each as for {@link decodeRelayAccountEmailMessage}. It checks shape only,\n * and only the ordinary envelope id. No other guard accepts it. Never throws.\n */\nexport function decodeWindowAccountEmailMessage(value: unknown): DecodedMessage<WindowAccountEmailMessage> | undefined {\n return decodeMessage<WindowAccountEmailMessage>(value, isWindowAccountEmailPayload);\n}\n\n/**\n * Decodes an app-owned Pay window → hub frame `app-window-account-email` ({@link AppWindowAccountEmailMessage}) into a\n * frozen snapshot, or `undefined` for every other shape: payload keys exactly `appId` and `appOrigin` (as for\n * {@link isAppWindowHubMessage}), `sequence`, `stateSequence` and `account` (as for\n * {@link decodeRelayAccountEmailMessage}). It checks shape only. No other guard accepts it. Never throws.\n */\nexport function decodeAppWindowAccountEmailMessage(value: unknown): DecodedMessage<AppWindowAccountEmailMessage> | undefined {\n return decodeMessage<AppWindowAccountEmailMessage>(value, isAppWindowAccountEmailPayload);\n}\n\n/**\n * Decodes a hub frame → app-owned Pay window `app-window-account-email-refresh`\n * ({@link AppWindowAccountEmailRefreshMessage}) into a frozen snapshot, or `undefined` for every other shape: payload\n * keys exactly `appId` and `appOrigin` (as for {@link isAppWindowHubMessage}), `refreshId` (an id) and `stateSequence`\n * (a safe integer from 1). The same envelope, plain-object, exact-key and `undefined`-as-absent rules as every other\n * guard apply. It checks shape only: the Pay window checks that the sender is a hub frame of its app page and that the\n * state is its current one. No other guard accepts it. Never throws, and never reports what it rejected.\n */\nexport function decodeAppWindowAccountEmailRefreshMessage(\n value: unknown,\n): DecodedMessage<AppWindowAccountEmailRefreshMessage> | undefined {\n return decodeMessage<AppWindowAccountEmailRefreshMessage>(value, isAppWindowAccountEmailRefreshPayload);\n}\n\n/**\n * Decodes an app-owned Pay window → hub frame `app-window-account-email-refresh-reply`\n * ({@link AppWindowAccountEmailRefreshReplyMessage}) into a frozen snapshot, or `undefined` for every other shape:\n * payload keys exactly `appId`, `appOrigin`, `refreshId` and `stateSequence` (as for\n * {@link decodeAppWindowAccountEmailRefreshMessage}), `checkedAt` (a safe integer from 1) and `account` (as for\n * {@link decodeRelayAccountEmailMessage}). It checks shape only: the frame checks the sender's document, its open\n * request, the state, the check time and the lease. No other guard accepts it. Never throws.\n */\nexport function decodeAppWindowAccountEmailRefreshReplyMessage(\n value: unknown,\n): DecodedMessage<AppWindowAccountEmailRefreshReplyMessage> | undefined {\n return decodeMessage<AppWindowAccountEmailRefreshReplyMessage>(value, isAppWindowAccountEmailRefreshReplyPayload);\n}\n\nfunction decodeMessage<T extends SuaMessage>(\n value: unknown,\n validate: (read: FieldReader, type: string, payload: unknown) => boolean,\n): DecodedMessage<T> | undefined {\n try {\n const { read, freeze } = createSnapshotReader();\n const envelope = readStrictEnvelope(read, value);\n if (envelope !== undefined && validate === isHubElementPayload && envelope.type === SUA_LINK_C_MESSAGE_TYPES.paySource) {\n const source = readPaySource(read, envelope.payload);\n if (source === undefined) return undefined;\n envelope.payload = source;\n return Object.freeze(envelope) as DecodedMessage<T>;\n }\n if (envelope !== undefined) {\n let payload: Fields | undefined;\n if (validate === isElementPayload && envelope.type === PAY_MESSAGE_TYPES.checkoutResult)\n payload = readCheckoutResult(read, envelope.payload);\n else if (validate === isHubElementPayload && envelope.type === SUA_LINK_C_MESSAGE_TYPES.checkoutResult)\n payload = readHubCheckoutResult(read, envelope.payload);\n else if (validate === isHubElementPayload && envelope.type === SUA_LINK_C_MESSAGE_TYPES.paySourceFunds)\n payload = readPaySourceFunds(read, envelope.payload);\n else if (validate === isWindowElementPayload && envelope.type === SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutResult) {\n payload = readRelayCheckoutResult(read, envelope.payload, isMessageId, isRevision);\n if (payload === undefined) return undefined;\n }\n if (payload !== undefined) {\n envelope.payload = payload;\n return Object.freeze(envelope) as DecodedMessage<T>;\n }\n }\n if (envelope === undefined || !validate(read, envelope.type as string, envelope.payload)) return undefined;\n return freeze(envelope) as DecodedMessage<T>;\n } catch {\n return undefined;\n }\n}\n\nexport function isAppearance(value: unknown): value is HubAppearance {\n try {\n return hasAppearanceT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