@stridge/pay-sdk 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/cjs/_internal/coordinator.cjs +3898 -0
- package/dist/cjs/_internal/coordinator.cjs.map +1 -0
- package/dist/cjs/_internal/coordinator.d.cts +6263 -0
- package/dist/cjs/guards-CQWGp5eP.d.cts +3311 -0
- package/dist/cjs/guards-r1nnLHLD.cjs +3617 -0
- package/dist/cjs/guards-r1nnLHLD.cjs.map +1 -0
- package/dist/cjs/index.cjs +40 -0
- package/dist/cjs/index.d.cts +2 -0
- package/dist/esm/_internal/coordinator.d.ts +6263 -0
- package/dist/esm/_internal/coordinator.js +3677 -0
- package/dist/esm/_internal/coordinator.js.map +1 -0
- package/dist/esm/guards-CQWGp5eP.d.ts +3311 -0
- package/dist/esm/guards-CukG42GQ.js +2940 -0
- package/dist/esm/guards-CukG42GQ.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/package.json +54 -3
|
@@ -0,0 +1,3311 @@
|
|
|
1
|
+
//#region src/encoding/utf8.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a string as UTF-8 bytes. These are the exact bytes a signature covers and the relay forwards, so every
|
|
4
|
+
* signing and relay-body helper goes through here rather than through `btoa` or a Latin-1 shortcut.
|
|
5
|
+
*
|
|
6
|
+
* A lone surrogate becomes U+FFFD, as `TextEncoder` defines. `JSON.stringify` never produces one, so a body built
|
|
7
|
+
* with it round-trips exactly.
|
|
8
|
+
*/
|
|
9
|
+
declare function utf8ToBytes(text: string): Uint8Array<ArrayBuffer>;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes UTF-8 bytes into a string, refusing malformed input rather than replacing it.
|
|
12
|
+
*
|
|
13
|
+
* @throws {TypeError} when `bytes` is not well-formed UTF-8.
|
|
14
|
+
*/
|
|
15
|
+
declare function bytesToUtf8(bytes: Uint8Array): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/protocol/constants.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* The literal protocol tag every app↔hub message carries. Anything posted to the window without it is not ours.
|
|
20
|
+
*/
|
|
21
|
+
declare const PAY_PROTOCOL = "stridge-sua";
|
|
22
|
+
/**
|
|
23
|
+
* The protocol version this SDK speaks. A message with another version is rejected by the message guards.
|
|
24
|
+
*/
|
|
25
|
+
declare const SUA_PROTOCOL_VERSION = 1;
|
|
26
|
+
/**
|
|
27
|
+
* The longest correlation id the guards accept, in UTF-16 code units.
|
|
28
|
+
*/
|
|
29
|
+
declare const MAX_MESSAGE_ID_LENGTH = 128;
|
|
30
|
+
/**
|
|
31
|
+
* The longest message a sign request may carry, in **UTF-8 bytes** (a CJK character is 3, an emoji 4). It bounds what
|
|
32
|
+
* the hub renders and relays: the Coordinator caps a request body at 64 KiB, and the relay body carries the payload
|
|
33
|
+
* as hex (2 characters a byte) inside base64 (4 characters for 3). At this limit, with an EIP-191 prefix and the
|
|
34
|
+
* stamp, the relay request stays near 45 KB, well under the cap.
|
|
35
|
+
*/
|
|
36
|
+
declare const MAX_SIGN_MESSAGE_BYTES = 16384;
|
|
37
|
+
/**
|
|
38
|
+
* The longest `error.message` the guards accept.
|
|
39
|
+
*/
|
|
40
|
+
declare const MAX_ERROR_MESSAGE_LENGTH = 1024;
|
|
41
|
+
/**
|
|
42
|
+
* The longest label the Pay element guards accept, in UTF-16 code units. An empty label is valid; the renderer owns
|
|
43
|
+
* any accessibility fallback.
|
|
44
|
+
*/
|
|
45
|
+
declare const MAX_ELEMENT_LABEL_LENGTH = 1024;
|
|
46
|
+
/** The most wallets one link C `pay-source-funds` names. */
|
|
47
|
+
declare const MAX_PAY_SOURCE_FUNDS_WALLETS = 20;
|
|
48
|
+
/**
|
|
49
|
+
* The longest app origin the relay guards accept, in UTF-16 code units.
|
|
50
|
+
*/
|
|
51
|
+
declare const MAX_APP_ORIGIN_LENGTH = 2048;
|
|
52
|
+
/**
|
|
53
|
+
* The longest app page address (`element-page-url` and its forwards) the guards accept, in UTF-16 code units. A bound
|
|
54
|
+
* for validation, not a browser limit.
|
|
55
|
+
*/
|
|
56
|
+
declare const MAX_PAGE_URL_LENGTH = 8192;
|
|
57
|
+
/**
|
|
58
|
+
* The tallest block size a Pay element may report, in CSS pixels. A bound for validation, not a measured browser
|
|
59
|
+
* limit.
|
|
60
|
+
*/
|
|
61
|
+
declare const MAX_ELEMENT_BLOCK_SIZE = 16384;
|
|
62
|
+
/**
|
|
63
|
+
* The longest resize animation a Pay element may report, in milliseconds.
|
|
64
|
+
*/
|
|
65
|
+
declare const MAX_ELEMENT_RESIZE_DURATION_MS = 10000;
|
|
66
|
+
/**
|
|
67
|
+
* The geometry easing identifiers. `standard` means `cubic-bezier(0.4, 0, 0.2, 1)`; arbitrary CSS is never accepted.
|
|
68
|
+
*/
|
|
69
|
+
declare const SUA_ELEMENT_GEOMETRY_EASINGS: {
|
|
70
|
+
readonly standard: "standard";
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The largest magnitude of any menu rect coordinate or size, in CSS pixels. A bound for validation, not a measured
|
|
74
|
+
* browser limit.
|
|
75
|
+
*/
|
|
76
|
+
declare const MAX_MENU_RECT_VALUE = 1000000;
|
|
77
|
+
/**
|
|
78
|
+
* An app id: `app_` and a 26-character Crockford base32 ULID in **uppercase only**, whose first character is `0`–`7`
|
|
79
|
+
* (it carries 3 bits; anything above `7` overflows 128 bits). The Coordinator's `pkg/id/id.go` refuses a lowercase
|
|
80
|
+
* id and an overflowing one, and answers every call that carries one with `403 APP_SUSPENDED`.
|
|
81
|
+
*/
|
|
82
|
+
declare const APP_ID_PATTERN: RegExp;
|
|
83
|
+
/**
|
|
84
|
+
* A hub frame name, as `element-init`'s `hubFrame` and the Pay element URL's `hubFrame` hint carry it: an ASCII letter
|
|
85
|
+
* or digit, then ASCII letters, digits, `_` or `-`. The first character excludes the reserved underscore-prefixed
|
|
86
|
+
* browsing-context names such as `_top`. A reader checks the length bound, 1 to {@link MAX_MESSAGE_ID_LENGTH}
|
|
87
|
+
* characters, first, so a huge string never reaches the pattern.
|
|
88
|
+
*/
|
|
89
|
+
declare const HUB_FRAME_NAME_PATTERN: RegExp;
|
|
90
|
+
/**
|
|
91
|
+
* An EVM address: `0x` and 40 hex digits, any case.
|
|
92
|
+
*/
|
|
93
|
+
declare const EVM_ADDRESS_PATTERN: RegExp;
|
|
94
|
+
/**
|
|
95
|
+
* The `message` of the `internal` error a framed hub page answers a request with when the request belongs in the Sua
|
|
96
|
+
* window: the frame cannot reach the hub's first-party storage, so it can open no round and register no keypair. It
|
|
97
|
+
* is the one `error.message` the app reads: on it, the app sends its next request to the Pay window. The code stays
|
|
98
|
+
* `internal`, so an app that does not know the value reads it as an internal error. Never rename it: the app and the
|
|
99
|
+
* hub ship apart, and a renamed value silently stops the switch.
|
|
100
|
+
*/
|
|
101
|
+
declare const HUB_NEEDS_POPUP_MESSAGE = "needs-popup";
|
|
102
|
+
/**
|
|
103
|
+
* The wire type of the Fund request (app → hub): open Fund in the hub's Stridge Wallet dialog. Never rename it: the
|
|
104
|
+
* app and the hub ship apart, and a hub that does not know the value drops the request.
|
|
105
|
+
*/
|
|
106
|
+
declare const PAY_FUND_REQUEST_TYPE = "fund";
|
|
107
|
+
/**
|
|
108
|
+
* The screens a Fund request may start on, as its `start` carries them. `FundStartScreen` derives from this object.
|
|
109
|
+
*
|
|
110
|
+
* - `home` — the account home.
|
|
111
|
+
* - `fund` — the Fund surface. A missing `start` means this one.
|
|
112
|
+
*/
|
|
113
|
+
declare const PAY_FUND_START_SCREENS: {
|
|
114
|
+
readonly home: "home";
|
|
115
|
+
readonly fund: "fund";
|
|
116
|
+
};
|
|
117
|
+
/** Fund ownership notices shared by the app and hub across independently deployed versions. */
|
|
118
|
+
declare const PAY_FUND_MESSAGE_TYPES: {
|
|
119
|
+
readonly received: "fund-received";
|
|
120
|
+
readonly cancel: "fund-cancel";
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The query parameters of the hub page's URL: the app sets them on the configured hub URL when it builds the
|
|
124
|
+
* iframe's `src` and the Pay window's URL, and the hub page reads them. Never rename one: the app and the hub ship
|
|
125
|
+
* apart.
|
|
126
|
+
*
|
|
127
|
+
* - `theme` — the colour scheme the hub page paints before `init` arrives. Cosmetic only.
|
|
128
|
+
* - `surface` — {@link HUB_SURFACE_POPUP} marks the page as the Pay window.
|
|
129
|
+
* - `app`, `origin` — the app id and the app page's origin, which the Pay window uses only to pick where its `ready`
|
|
130
|
+
* goes, and only when its registry lists that origin for that app. Untrusted: `init` is checked as in a frame.
|
|
131
|
+
* - `hubFrame` — the name of the app's hub frame, a discovery hint for the Pay element. It authorizes no peer.
|
|
132
|
+
*
|
|
133
|
+
* A missing, repeated or conflicting hint never selects another app.
|
|
134
|
+
*/
|
|
135
|
+
declare const HUB_URL_PARAMS: {
|
|
136
|
+
readonly theme: "theme";
|
|
137
|
+
readonly surface: "surface";
|
|
138
|
+
readonly app: "app";
|
|
139
|
+
readonly origin: "origin";
|
|
140
|
+
readonly hubFrame: "hubFrame";
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The value of the `surface` query parameter (`HUB_URL_PARAMS.surface`) that marks the hub page as the Pay window.
|
|
144
|
+
*/
|
|
145
|
+
declare const HUB_SURFACE_POPUP = "popup";
|
|
146
|
+
/**
|
|
147
|
+
* The value of the `surface` query parameter (`HUB_URL_PARAMS.surface`) that marks the hub page as a Pay element.
|
|
148
|
+
*/
|
|
149
|
+
declare const HUB_SURFACE_ELEMENT = "element";
|
|
150
|
+
/**
|
|
151
|
+
* The fixed route of the Pay element on the hub origin.
|
|
152
|
+
*/
|
|
153
|
+
declare const PAY_ELEMENT_PATH = "/elements/pay";
|
|
154
|
+
/**
|
|
155
|
+
* The failure codes a Pay element adds to `HubErrorCode` on `failed`. `ElementFailureCode` derives from this object.
|
|
156
|
+
* No hub sends them, so `HubErrorCode` stays as it is.
|
|
157
|
+
*
|
|
158
|
+
* - `unavailable` — the hub never completed the handshake, or reloaded while the request was in flight.
|
|
159
|
+
* - `popup-blocked` — the browser refused to open the Pay window the Pay element opens from the user's click.
|
|
160
|
+
*/
|
|
161
|
+
declare const PAY_ELEMENT_FAILURE_CODES: {
|
|
162
|
+
readonly unavailable: "unavailable";
|
|
163
|
+
readonly popupBlocked: "popup-blocked";
|
|
164
|
+
};
|
|
165
|
+
/** Closed pay wire vocabulary and input bounds. */
|
|
166
|
+
declare const PAY_JOBS: readonly ["pay", "deposit"];
|
|
167
|
+
declare const PAY_CURRENCIES: readonly ["USD"];
|
|
168
|
+
/**
|
|
169
|
+
* The first steps a chosen-amount Deposit's Pay window may take: ask the `amount` (the default) or the `method`. Only
|
|
170
|
+
* `method` travels on the wire; a request without `firstStep` asks the amount first.
|
|
171
|
+
*/
|
|
172
|
+
declare const PAY_FIRST_STEPS: readonly ["amount", "method"];
|
|
173
|
+
declare const PAY_AMOUNT_PATTERN: RegExp;
|
|
174
|
+
declare const MAX_PAY_AMOUNT = "100000.00";
|
|
175
|
+
declare const MAX_PAY_ITEM_LENGTH = 64;
|
|
176
|
+
/**
|
|
177
|
+
* The longest payout address a pay request carries, in UTF-16 code units. The wire only bounds the string; the hub
|
|
178
|
+
* decides whether it is a usable address.
|
|
179
|
+
*/
|
|
180
|
+
declare const MAX_PAY_PAYOUT_ADDRESS_LENGTH = 128;
|
|
181
|
+
/**
|
|
182
|
+
* A checkout rule id a pay request may name as its `destination`: `ckr_`, then 1 to 60 ASCII letters or digits. The
|
|
183
|
+
* wire checks only the shape; whether the app has the rule is the Coordinator's answer.
|
|
184
|
+
*/
|
|
185
|
+
declare const PAY_DESTINATION_RULE_PATTERN: RegExp;
|
|
186
|
+
/**
|
|
187
|
+
* The asset of a pay request's destination address: a CAIP-19 id on an `eip155` chain (an asset namespace of 3 to 8
|
|
188
|
+
* lowercase letters, digits or hyphens, then a reference of 1 to 128 letters, digits, hyphens, dots or `%`). The wire
|
|
189
|
+
* checks only the shape; the hub decides whether the asset is listed and payable.
|
|
190
|
+
*/
|
|
191
|
+
declare const PAY_DESTINATION_ASSET_PATTERN: RegExp;
|
|
192
|
+
declare const PAY_MESSAGE_TYPES: {
|
|
193
|
+
readonly payRequest: "element-pay-request";
|
|
194
|
+
/**
|
|
195
|
+
* A Deposit whose amount the user chooses in the window, within the app's optional limits. It is its own type, not
|
|
196
|
+
* optional keys on `element-pay-request`, so an element from before it drops this message alone.
|
|
197
|
+
*/
|
|
198
|
+
readonly depositRequest: "element-deposit-request";
|
|
199
|
+
readonly payRequestAck: "element-pay-request-ack";
|
|
200
|
+
readonly paid: "element-paid";
|
|
201
|
+
readonly checkoutResult: "element-checkout-result";
|
|
202
|
+
readonly held: "element-held";
|
|
203
|
+
readonly unconfirmed: "element-unconfirmed";
|
|
204
|
+
};
|
|
205
|
+
declare const SUA_PAY_REQUEST_TYPE = "pay";
|
|
206
|
+
declare const PAY_ELEMENT_MESSAGE_TYPES: {
|
|
207
|
+
readonly payRequest: "element-pay-request";
|
|
208
|
+
readonly depositRequest: "element-deposit-request";
|
|
209
|
+
readonly payRequestAck: "element-pay-request-ack";
|
|
210
|
+
readonly init: "element-init";
|
|
211
|
+
readonly config: "element-config";
|
|
212
|
+
readonly focus: "focus";
|
|
213
|
+
readonly ready: "element-ready";
|
|
214
|
+
readonly accepted: "element-accepted";
|
|
215
|
+
readonly refused: "element-refused";
|
|
216
|
+
readonly configAck: "element-config-ack";
|
|
217
|
+
readonly resize: "resize";
|
|
218
|
+
readonly signed: "signed";
|
|
219
|
+
readonly failed: "failed";
|
|
220
|
+
readonly menuAnchor: "menu-anchor";
|
|
221
|
+
readonly menuEnded: "element-menu-ended";
|
|
222
|
+
readonly checkStatusCapability: "element-check-status-capability";
|
|
223
|
+
readonly checkStatusSettled: "element-check-status-settled";
|
|
224
|
+
readonly pageUrl: "element-page-url";
|
|
225
|
+
readonly geometryCapabilities: "element-geometry-capabilities";
|
|
226
|
+
readonly geometryTarget: "element-geometry-target";
|
|
227
|
+
readonly geometryComplete: "element-geometry-complete";
|
|
228
|
+
readonly geometryCancelled: "element-geometry-cancelled";
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Pay element → app notifications on link B. Only `checkStatusRequest` has a reply.
|
|
232
|
+
*
|
|
233
|
+
* - `connected` — a connected address the element observed over link C.
|
|
234
|
+
* - `viewShown` — the element's real view is on screen, in place of its placeholder.
|
|
235
|
+
* - `loadFailed` — the view the element shows is a load failure, with a {@link PAY_ELEMENT_LOAD_FAILURE_REASONS} value.
|
|
236
|
+
* - `checkStatusRequest` — request to check a spent attempt; the app answers with `element-check-status-settled`
|
|
237
|
+
* and the same envelope id and correlation payload when its check finishes, including failure.
|
|
238
|
+
*
|
|
239
|
+
* The element posts one of `viewShown` and `loadFailed` after the `resize` for the view it revealed, and again only
|
|
240
|
+
* when the view turns from one to the other. An app that predates them drops them as unknown types.
|
|
241
|
+
*/
|
|
242
|
+
declare const PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES: {
|
|
243
|
+
readonly paid: "element-paid";
|
|
244
|
+
readonly connected: "element-connected";
|
|
245
|
+
readonly viewShown: "element-view-shown";
|
|
246
|
+
readonly loadFailed: "element-load-failed";
|
|
247
|
+
readonly checkStatusRequest: "element-check-status-request";
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Why the view a Pay element shows is a load failure, as `element-load-failed` carries it.
|
|
251
|
+
* `PayElementLoadFailureReason` derives from this object.
|
|
252
|
+
*
|
|
253
|
+
* - `hub-frame` — link C, the element's link to the app's hub frame, failed for this document.
|
|
254
|
+
* - `internal` — the element failed to load for a reason of its own.
|
|
255
|
+
*/
|
|
256
|
+
declare const PAY_ELEMENT_LOAD_FAILURE_REASONS: {
|
|
257
|
+
readonly hubFrame: "hub-frame";
|
|
258
|
+
readonly internal: "internal";
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* The message types the app and its hub frame add to the existing app↔hub messages. `overlayHidden` is also reused
|
|
262
|
+
* from hub frame to initiating element on link C, with that operation's id.
|
|
263
|
+
*/
|
|
264
|
+
declare const PAY_HUB_FRAME_MESSAGE_TYPES: {
|
|
265
|
+
readonly diagnosticsSubscribe: "diagnostics-subscribe";
|
|
266
|
+
readonly diagnosticsUnsubscribe: "diagnostics-unsubscribe";
|
|
267
|
+
readonly diagnosticsStatus: "diagnostics-status";
|
|
268
|
+
readonly diagnosticsInspect: "diagnostics-inspect";
|
|
269
|
+
readonly diagnosticsDetails: "diagnostics-details";
|
|
270
|
+
readonly diagnosticsDisconnect: "diagnostics-disconnect";
|
|
271
|
+
readonly activity: "activity";
|
|
272
|
+
readonly showMenu: "show-menu";
|
|
273
|
+
readonly menuAccepted: "menu-accepted";
|
|
274
|
+
readonly menuRefused: "menu-refused";
|
|
275
|
+
readonly menuEnded: "menu-ended";
|
|
276
|
+
readonly overlayHidden: "overlay-hidden";
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* The handshake message types between a Pay element and the Pay window it opens. The Pay window sends `build`, its
|
|
280
|
+
* own build id, immediately before `accepted` with the same id, so the Pay element can trust a sign's release code only
|
|
281
|
+
* from a Pay window that runs its own build.
|
|
282
|
+
*/
|
|
283
|
+
declare const SUA_RELAY_MESSAGE_TYPES: {
|
|
284
|
+
readonly init: "relay-init";
|
|
285
|
+
readonly accepted: "relay-accepted";
|
|
286
|
+
readonly refused: "relay-refused";
|
|
287
|
+
readonly build: "relay-build";
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* The message types between a Pay element and its hub frame (link C), in both directions. The Pay element sends
|
|
291
|
+
* `probe`, `attach`, `confirm`, `detach`, `windowOpened`, `windowResult`, `windowError`, `windowEnded`,
|
|
292
|
+
* `windowState` and `pageUrl`; the hub frame sends the others. Link C also reuses the six ceremony requests, `state`, `transport`,
|
|
293
|
+
* `activity`, `result`, `error` and `overlay-hidden`, with their payloads unchanged.
|
|
294
|
+
*/
|
|
295
|
+
declare const SUA_LINK_C_MESSAGE_TYPES: {
|
|
296
|
+
readonly paySource: "pay-source";
|
|
297
|
+
/**
|
|
298
|
+
* The first wallet saved to the signed-in account, beside a `pay-source` that names the Stridge Wallet: the card
|
|
299
|
+
* shows it in the account's place when the balance does not cover the amount.
|
|
300
|
+
*/
|
|
301
|
+
readonly paySourceSaved: "pay-source-saved";
|
|
302
|
+
/**
|
|
303
|
+
* Says that the `pay-source` and `pay-source-saved` before it on the same stream are the hub frame's current pick,
|
|
304
|
+
* read from the session and the hub's own storage, as a Pay window reads it. A hub frame that only reports never
|
|
305
|
+
* sends it, so the card keeps its own record of the last pick.
|
|
306
|
+
*/
|
|
307
|
+
readonly paySourceCurrent: "pay-source-current";
|
|
308
|
+
/**
|
|
309
|
+
* The money of the wallets the card may show for the current `pay-source`: the picked wallet, or the wallets saved
|
|
310
|
+
* to the signed-in account beside a Stridge Wallet pick. The hub never knows the amount, so the card weighs it: a
|
|
311
|
+
* wallet that covers it stands in for a Stridge Wallet balance that does not. Display only.
|
|
312
|
+
*/
|
|
313
|
+
readonly paySourceFunds: "pay-source-funds";
|
|
314
|
+
readonly menuPayment: "menu-payment";
|
|
315
|
+
readonly payOwner: "pay-owner";
|
|
316
|
+
readonly payProgress: "pay-progress";
|
|
317
|
+
/**
|
|
318
|
+
* The hub's proof, sent right after a failed `pay-progress` that allows a retry, that this payment was never sent:
|
|
319
|
+
* `progressId` names that `pay-progress` envelope. Only then may the card say "No money moved".
|
|
320
|
+
*/
|
|
321
|
+
readonly payUnsent: "pay-unsent";
|
|
322
|
+
readonly checkoutResult: "checkout-result";
|
|
323
|
+
/**
|
|
324
|
+
* The wallet that paid a guest checkout in full, by its brand, so the card leads its paid row with that wallet's
|
|
325
|
+
* logo. Display only.
|
|
326
|
+
*/
|
|
327
|
+
readonly checkoutWallet: "checkout-wallet";
|
|
328
|
+
/**
|
|
329
|
+
* A guest checkout the hub holds in storage for a payment, sent before its Coordinator read answers: Pay on that
|
|
330
|
+
* payment reopens the checkout and starts no new one. `request` `null` says the hub holds it no longer.
|
|
331
|
+
*/
|
|
332
|
+
readonly checkoutHeld: "checkout-held";
|
|
333
|
+
readonly probe: "hub-probe";
|
|
334
|
+
readonly probeAck: "hub-probe-ack";
|
|
335
|
+
readonly attach: "attach";
|
|
336
|
+
readonly accepted: "attach-accepted";
|
|
337
|
+
readonly refused: "attach-refused";
|
|
338
|
+
readonly confirm: "attach-confirm";
|
|
339
|
+
readonly detach: "detach";
|
|
340
|
+
readonly balance: "balance";
|
|
341
|
+
readonly windowOpened: "window-opened";
|
|
342
|
+
readonly windowAccepted: "window-accepted";
|
|
343
|
+
readonly windowRefused: "window-refused";
|
|
344
|
+
readonly windowResult: "window-result";
|
|
345
|
+
readonly windowError: "window-error";
|
|
346
|
+
readonly windowEnded: "window-ended";
|
|
347
|
+
readonly windowCancel: "window-cancel";
|
|
348
|
+
readonly windowState: "window-state";
|
|
349
|
+
readonly pageUrl: "page-url";
|
|
350
|
+
/**
|
|
351
|
+
* The method the card's source row showed when the person pressed Pay, for the `pay` the element sends right after
|
|
352
|
+
* it: the Pay window opens that method and never decides another one itself.
|
|
353
|
+
*/
|
|
354
|
+
readonly payShown: "pay-shown";
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Why a Pay window that a Pay element opened ended, as `window-ended` reports it. `SuaWindowEndCause` derives from
|
|
358
|
+
* this object.
|
|
359
|
+
*
|
|
360
|
+
* - `settled` — the ceremony finished and the window closed.
|
|
361
|
+
* - `window-cancel` — "Cancel" on the hub frame's backdrop closed it.
|
|
362
|
+
* - `window-lost` — the user closed the window, or it was lost.
|
|
363
|
+
* - `teardown` — the provider or the Pay element went away.
|
|
364
|
+
*/
|
|
365
|
+
declare const SUA_WINDOW_END_CAUSES: {
|
|
366
|
+
readonly settled: "settled";
|
|
367
|
+
readonly windowCancel: "window-cancel";
|
|
368
|
+
readonly windowLost: "window-lost";
|
|
369
|
+
readonly teardown: "teardown";
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Why the hub frame asks a Pay element to close the Pay window it owns, as `window-cancel` and link E's
|
|
373
|
+
* `relay-close` carry it. `SuaWindowCancelCause` derives from this object; each value is also a
|
|
374
|
+
* {@link SUA_WINDOW_END_CAUSES} value.
|
|
375
|
+
*/
|
|
376
|
+
declare const SUA_WINDOW_CANCEL_CAUSES: {
|
|
377
|
+
readonly windowCancel: "window-cancel";
|
|
378
|
+
readonly teardown: "teardown";
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* The longest hub build id link C carries, in characters: ASCII letters, digits, `_` or `-`, starting with a letter or
|
|
382
|
+
* digit. The build-id source emits a UUID.
|
|
383
|
+
*/
|
|
384
|
+
declare const MAX_HUB_BUILD_ID_LENGTH = 128;
|
|
385
|
+
/**
|
|
386
|
+
* A hub build id, as link C's `attach-accepted` and `attach-confirm` and link E's `relay-build` carry it and the hub
|
|
387
|
+
* page's build marker emits it:
|
|
388
|
+
* an ASCII letter or digit, then ASCII letters, digits, `_` or `-`. A reader checks the length bound, 1 to
|
|
389
|
+
* {@link MAX_HUB_BUILD_ID_LENGTH} characters, first, so a huge string never reaches the pattern.
|
|
390
|
+
*/
|
|
391
|
+
declare const HUB_BUILD_ID_PATTERN: RegExp;
|
|
392
|
+
/**
|
|
393
|
+
* The longest link C balance amount, in characters: `2^256 - 1` base units as dollars with six decimals.
|
|
394
|
+
*/
|
|
395
|
+
declare const MAX_HUB_BALANCE_AMOUNT_LENGTH = 79;
|
|
396
|
+
/**
|
|
397
|
+
* The separator of a namespaced link C id, `<attachmentId>:<nonce>`. A 36-character attachment id, the separator and a
|
|
398
|
+
* nonce of at most 91 characters fit {@link MAX_MESSAGE_ID_LENGTH}. The guards check only the ordinary id; the link
|
|
399
|
+
* checks the namespace.
|
|
400
|
+
*/
|
|
401
|
+
declare const SUA_LINK_C_ID_SEPARATOR = ":";
|
|
402
|
+
/**
|
|
403
|
+
* The nonce prefixes of link C's ordered streams. A stream message's id is `<attachmentId>:<prefix><sequence>`, the
|
|
404
|
+
* sequence a canonical decimal from 1 that each stream counts on its own per attachment.
|
|
405
|
+
*/
|
|
406
|
+
declare const SUA_LINK_C_STREAM_PREFIXES: {
|
|
407
|
+
readonly state: "s_";
|
|
408
|
+
readonly transport: "t_";
|
|
409
|
+
readonly activity: "a_";
|
|
410
|
+
readonly balance: "b_";
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* The graceful-close and ordered-state message types a Pay element and the Pay window it opened add to link E.
|
|
414
|
+
*/
|
|
415
|
+
declare const SUA_RELAY_CONTROL_MESSAGE_TYPES: {
|
|
416
|
+
readonly close: "relay-close";
|
|
417
|
+
readonly closeAccepted: "relay-close-accepted";
|
|
418
|
+
readonly state: "relay-state";
|
|
419
|
+
/** The Pay window's `pay-progress` for the element that opened it, on the operation's own stream (R1-05). */
|
|
420
|
+
readonly payOwner: "relay-pay-owner";
|
|
421
|
+
readonly payProgress: "relay-pay-progress";
|
|
422
|
+
/** Link C's `pay-unsent`, naming the `relay-pay-progress` it proves by its sequence. */
|
|
423
|
+
readonly payUnsent: "relay-pay-unsent";
|
|
424
|
+
readonly checkoutResult: "relay-checkout-result";
|
|
425
|
+
/** Link C's `checkout-wallet`, on the operation's pay stream. */
|
|
426
|
+
readonly checkoutWallet: "relay-checkout-wallet";
|
|
427
|
+
/** The app page's address for the `pay` the element relays next: the element sends it right before. */
|
|
428
|
+
readonly pageUrl: "relay-page-url";
|
|
429
|
+
/**
|
|
430
|
+
* The source the Pay window picks for the person it serves, for the card of the element that opened it, on the
|
|
431
|
+
* operation's pay stream with `relay-pay-progress`.
|
|
432
|
+
*/
|
|
433
|
+
readonly paySource: "relay-pay-source";
|
|
434
|
+
/** The first saved wallet beside the Pay window's account pick, as link C's `pay-source-saved`, on the same stream. */
|
|
435
|
+
readonly paySourceSaved: "relay-pay-source-saved";
|
|
436
|
+
/** Link C's `pay-shown`, for the `pay` the element relays right after it. */
|
|
437
|
+
readonly payShown: "relay-pay-shown";
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* The message type an app-owned Pay window (the hub page at the root with `surface=popup`, opened by the app page)
|
|
441
|
+
* posts to the app's hub frame, both on the hub's origin. `state` carries the window's state, ordered per window
|
|
442
|
+
* document, so a hub frame that only reports keeps its display-only connected copy in step with a sign-in, a sign-out
|
|
443
|
+
* 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
|
|
444
|
+
* at the hub's origin, and the hub frame checks the sender's document before it reads the data.
|
|
445
|
+
*/
|
|
446
|
+
declare const SUA_APP_WINDOW_MESSAGE_TYPES: {
|
|
447
|
+
readonly state: "app-window-state";
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* The private account-email messages between Stridge-origin documents: one report per authenticated route a hub frame
|
|
451
|
+
* that only reports learns its state on, and the refresh request and reply of the app-owned route. Each report carries
|
|
452
|
+
* the account the sending Pay window shows (its identity, address and email) or `null` to clear it, beside the public
|
|
453
|
+
* state stream it refers to. They are new types, never new fields on `relay-state`, `window-state` or
|
|
454
|
+
* `app-window-state`, so a peer that predates them drops only them; they never reach an app page, an app hook or an app
|
|
455
|
+
* event.
|
|
456
|
+
*
|
|
457
|
+
* - `relay` — a Pay window → the Pay element or hub frame that opened it (link E), beside `relay-state`.
|
|
458
|
+
* - `window` — a Pay element → its confirmed hub frame attachment (link C), forwarding a `relay` report, beside
|
|
459
|
+
* `window-state`.
|
|
460
|
+
* - `appWindow` — an app-owned Pay window → the app page's hub frames, beside `app-window-state`.
|
|
461
|
+
* - `appWindowRefresh` — a hub frame → the app-owned Pay window whose state it shows: asks it to read its session again
|
|
462
|
+
* now (the frame's menu opened, or the frame gained focus). Never to the app page that opened the window.
|
|
463
|
+
* - `appWindowRefreshReply` — that Pay window → the asking hub frame only: the account after a session read that
|
|
464
|
+
* answered after the request, and that read's time.
|
|
465
|
+
*/
|
|
466
|
+
declare const SUA_ACCOUNT_EMAIL_MESSAGE_TYPES: {
|
|
467
|
+
readonly relay: "relay-account-email";
|
|
468
|
+
readonly window: "window-account-email";
|
|
469
|
+
readonly appWindow: "app-window-account-email";
|
|
470
|
+
readonly appWindowRefresh: "app-window-account-email-refresh";
|
|
471
|
+
readonly appWindowRefreshReply: "app-window-account-email-refresh-reply";
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* The longest identity id an account-email report carries, in characters. A defensive wire bound, not a format rule.
|
|
475
|
+
*/
|
|
476
|
+
declare const MAX_ACCOUNT_IDENTITY_LENGTH = 256;
|
|
477
|
+
/**
|
|
478
|
+
* The longest email an account-email report carries, in characters. A defensive wire bound: a well-formed email is no
|
|
479
|
+
* proof of ownership.
|
|
480
|
+
*/
|
|
481
|
+
declare const MAX_ACCOUNT_EMAIL_LENGTH = 320;
|
|
482
|
+
/**
|
|
483
|
+
* The longest time an account-email report may be shown, in milliseconds: a report's `validUntil` is at most this long
|
|
484
|
+
* after the sender's last authenticated session read and never after the session's known expiry (a sender with no
|
|
485
|
+
* fresh read reports `account: null`), and a receiver drops a report whose `validUntil` lies further ahead of its own
|
|
486
|
+
* clock.
|
|
487
|
+
*/
|
|
488
|
+
declare const MAX_ACCOUNT_EMAIL_LEASE_MS: number;
|
|
489
|
+
/**
|
|
490
|
+
* The longest keypair expiry the ordered state wrappers (`relay-state`, `window-state`, `app-window-state`) accept, in
|
|
491
|
+
* characters. The
|
|
492
|
+
* existing `state` keeps its own rule.
|
|
493
|
+
*/
|
|
494
|
+
declare const MAX_RELAY_STATE_EXPIRY_LENGTH = 64;
|
|
495
|
+
/**
|
|
496
|
+
* The lifetime message types an app and a Pay element add to links A and B: the per-config action eligibility check
|
|
497
|
+
* and the element-only reload request. The Pay element sends `actionCheck` and `reloadRequest`; the app answers.
|
|
498
|
+
*/
|
|
499
|
+
declare const PAY_ELEMENT_LIFETIME_MESSAGE_TYPES: {
|
|
500
|
+
readonly actionCheck: "element-action-check";
|
|
501
|
+
readonly actionEligibility: "element-action-eligibility";
|
|
502
|
+
readonly reloadRequest: "element-reload-request";
|
|
503
|
+
readonly reloadGrant: "element-reload-grant";
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Why a Pay element asks the app for its one reload. `SuaElementReloadReason` derives from this object.
|
|
507
|
+
*
|
|
508
|
+
* - `build-mismatch` — the hub frame runs another hub build than the Pay element.
|
|
509
|
+
*/
|
|
510
|
+
declare const SUA_ELEMENT_RELOAD_REASONS: {
|
|
511
|
+
readonly buildMismatch: "build-mismatch";
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* The cookie on the hub's origin that holds the session's `csrf_token`: the hub proxy writes it beside the session
|
|
515
|
+
* 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
|
|
516
|
+
* the server, and the hub page share one spelling. The `__Host-` prefix makes the browser refuse it unless it is
|
|
517
|
+
* `Secure`, `Path=/` and host-only, so no sibling subdomain can plant one.
|
|
518
|
+
*/
|
|
519
|
+
declare const HUB_CSRF_COOKIE_NAME = "__Host-sua_csrf";
|
|
520
|
+
/**
|
|
521
|
+
* The Coordinator's guest cookie for a page with unpartitioned cookie access: a top-level hub page, or a hub frame with
|
|
522
|
+
* storage access. `HttpOnly`; the hub proxy passes it both ways and hub script never reads it. A login takes this
|
|
523
|
+
* guest in and clears the cookie.
|
|
524
|
+
*/
|
|
525
|
+
declare const HUB_GUEST_COOKIE_NAME = "__Host-sua_gid";
|
|
526
|
+
/**
|
|
527
|
+
* The Coordinator's guest cookie for a partitioned hub frame (`Partitioned`, so one per top-level site). The hub opens
|
|
528
|
+
* no guest in such a frame; the proxy still passes the cookie both ways, so a guest the backend scopes there keeps
|
|
529
|
+
* working.
|
|
530
|
+
*/
|
|
531
|
+
declare const HUB_PARTITIONED_GUEST_COOKIE_NAME = "__Host-sua_pgid";
|
|
532
|
+
/**
|
|
533
|
+
* The request header that names the guest cookie a guest write uses (`unpartitioned` or `partitioned`). The guest open
|
|
534
|
+
* states it in its body instead.
|
|
535
|
+
*/
|
|
536
|
+
declare const GUEST_COOKIE_ACCESS_HEADER = "X-Stridge-Cookie-Access";
|
|
537
|
+
/**
|
|
538
|
+
* The request header a session call with `omitCredentials` sends, with the value {@link SESSION_HEADER_OMIT}. The
|
|
539
|
+
* hub proxy then drops the session cookie `__Host-sua_session` from what it forwards and keeps every other Coordinator
|
|
540
|
+
* cookie. It never forwards this header.
|
|
541
|
+
*/
|
|
542
|
+
declare const SESSION_HEADER = "X-Stridge-Session";
|
|
543
|
+
/**
|
|
544
|
+
* The value of {@link SESSION_HEADER} that tells the hub proxy to drop the session cookie.
|
|
545
|
+
*/
|
|
546
|
+
declare const SESSION_HEADER_OMIT = "omit";
|
|
547
|
+
/** One-use guest code on the accepted hub-to-window relay. */
|
|
548
|
+
declare const SUA_GUEST_HANDOFF_MESSAGE_TYPE = "relay-guest-handoff";
|
|
549
|
+
/** Private hub-frame continuation of an already pending Fund request. */
|
|
550
|
+
declare const SUA_FUND_WINDOW_MESSAGE_TYPE = "relay-fund-continuation";
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/protocol/types.d.ts
|
|
553
|
+
/**
|
|
554
|
+
* The versioned envelope of every message on the app↔hub channel (the iframe's `postMessage`, and later the
|
|
555
|
+
* popup fallback's). The channel itself, and its origin checks, live in pay-kit; this module holds only the shapes and the
|
|
556
|
+
* guards.
|
|
557
|
+
*
|
|
558
|
+
* Correlation: every request (`init`, `sign-in`, `sign`, `sign-out`, `disconnect`, `fund`) carries a
|
|
559
|
+
* fresh `id`, and the hub's `result` or `error` for it carries **the same `id`**. Fund's receipt and cancellation also
|
|
560
|
+
* use that id. Other notices (`appearance`, `ready`, `transport`, `state`, `overlay-open`, `overlay-close`) carry fresh
|
|
561
|
+
* ids of their own and get no reply.
|
|
562
|
+
*/
|
|
563
|
+
interface PayEnvelope<TType extends string, TPayload> {
|
|
564
|
+
/**
|
|
565
|
+
* Always `"stridge-sua"`.
|
|
566
|
+
*/
|
|
567
|
+
protocol: typeof PAY_PROTOCOL;
|
|
568
|
+
/**
|
|
569
|
+
* Always `1`.
|
|
570
|
+
*/
|
|
571
|
+
version: typeof SUA_PROTOCOL_VERSION;
|
|
572
|
+
/**
|
|
573
|
+
* The correlation id: a non-empty string of at most 128 characters, unique per request (a `crypto.randomUUID()`
|
|
574
|
+
* is the intended value).
|
|
575
|
+
*/
|
|
576
|
+
id: string;
|
|
577
|
+
/**
|
|
578
|
+
* The message type.
|
|
579
|
+
*/
|
|
580
|
+
type: TType;
|
|
581
|
+
/**
|
|
582
|
+
* The message's data. `{}` for a message that carries none.
|
|
583
|
+
*/
|
|
584
|
+
payload: TPayload;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* The payload of a message that carries no data: exactly `{}`.
|
|
588
|
+
*/
|
|
589
|
+
type EmptyPayload = Record<string, never>;
|
|
590
|
+
/**
|
|
591
|
+
* The hub's color scheme.
|
|
592
|
+
*/
|
|
593
|
+
type HubTheme = "dark" | "light";
|
|
594
|
+
/**
|
|
595
|
+
* The colour scheme the hub takes from `PayProvider`.
|
|
596
|
+
* Radius and token overrides would need a new protocol version.
|
|
597
|
+
*/
|
|
598
|
+
interface HubAppearance {
|
|
599
|
+
/**
|
|
600
|
+
* The color scheme.
|
|
601
|
+
*/
|
|
602
|
+
theme: HubTheme;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* The payload of `init`.
|
|
606
|
+
*/
|
|
607
|
+
interface InitPayload {
|
|
608
|
+
/**
|
|
609
|
+
* The consumer app's id (`app_` and a 26-character ULID).
|
|
610
|
+
*/
|
|
611
|
+
appId: string;
|
|
612
|
+
/**
|
|
613
|
+
* How the hub should look.
|
|
614
|
+
*/
|
|
615
|
+
appearance: HubAppearance;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The payload of `appearance`.
|
|
619
|
+
*/
|
|
620
|
+
interface AppearancePayload {
|
|
621
|
+
/**
|
|
622
|
+
* The new appearance, replacing the previous one whole.
|
|
623
|
+
*/
|
|
624
|
+
appearance: HubAppearance;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* The payload of `sign`.
|
|
628
|
+
*/
|
|
629
|
+
interface SignPayload {
|
|
630
|
+
/**
|
|
631
|
+
* The message to sign as the user sees it: a non-empty string of at most `MAX_SIGN_MESSAGE_BYTES` UTF-8 bytes.
|
|
632
|
+
* The hub shows it on the sign confirm screen and signs its bytes only after a click on the hub's own UI.
|
|
633
|
+
*/
|
|
634
|
+
message: string;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* The screen a Fund request starts on; see {@link PAY_FUND_START_SCREENS}.
|
|
638
|
+
*/
|
|
639
|
+
type FundStartScreen = (typeof PAY_FUND_START_SCREENS)[keyof typeof PAY_FUND_START_SCREENS];
|
|
640
|
+
/**
|
|
641
|
+
* The payload of `fund`: `{}` or exactly `start`. It carries no amount, owner, destination or method: the hub picks
|
|
642
|
+
* them all, so the app never supplies or learns money data.
|
|
643
|
+
*/
|
|
644
|
+
interface FundPayload {
|
|
645
|
+
/**
|
|
646
|
+
* The screen Fund starts on. Omitted means `fund`.
|
|
647
|
+
*/
|
|
648
|
+
start?: FundStartScreen;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* app → hub, request: the handshake, sent once after the hub's `ready`. The hub posts `transport`, answers `result`
|
|
652
|
+
* (`request: "init"`), and then sends a `state` snapshot whenever the state changes.
|
|
653
|
+
*/
|
|
654
|
+
type AppInitMessage = PayEnvelope<"init", InitPayload>;
|
|
655
|
+
/**
|
|
656
|
+
* app → hub: the consumer changed its appearance. No reply.
|
|
657
|
+
*/
|
|
658
|
+
type AppAppearanceMessage = PayEnvelope<"appearance", AppearancePayload>;
|
|
659
|
+
/**
|
|
660
|
+
* app → hub, request: open the sign-in ceremony. Answered by `result` (`request: "sign-in"`) with the session's
|
|
661
|
+
* address once the user signs in, or by `error`. When a session's user has not authorized this app, the hub offers
|
|
662
|
+
* that account ("Continue as"); until the user continues, the app gets what the email step sends (`overlay-open`, a
|
|
663
|
+
* `signed-out` state, and `cancelled` when the dialog closes). "Continue" answers with the address and no code, so the
|
|
664
|
+
* keypair may still need a renewal and the wallet may still be `pending`: the app's first `sign` then renews, or
|
|
665
|
+
* fails because the wallet cannot sign yet.
|
|
666
|
+
*/
|
|
667
|
+
type AppSignInMessage = PayEnvelope<"sign-in", EmptyPayload>;
|
|
668
|
+
/**
|
|
669
|
+
* app → hub, request: open the sign confirm screen for a message. Answered by `result` (`request: "sign"`) with the
|
|
670
|
+
* signature, or by `error`. With no session, the hub signs the user in first (or, for an app the session's user has
|
|
671
|
+
* not authorized, offers that account) and then shows the confirm, in one dialog from this one request.
|
|
672
|
+
*/
|
|
673
|
+
type AppSignMessage = PayEnvelope<"sign", SignPayload>;
|
|
674
|
+
/**
|
|
675
|
+
* app → hub, request: sign out. Answered by `result` (`request: "sign-out"`) or `error`.
|
|
676
|
+
*/
|
|
677
|
+
type AppSignOutMessage = PayEnvelope<"sign-out", EmptyPayload>;
|
|
678
|
+
/**
|
|
679
|
+
* app → hub, request: revoke this app's authorization for the session's identity, so the app sees `signed-out` while
|
|
680
|
+
* the session, its keypair and every other app stay as they are. Answered by `result` (`request: "disconnect"`), also
|
|
681
|
+
* when there was nothing to revoke. It needs no click in the hub and sends nothing to the Coordinator, which keeps no
|
|
682
|
+
* per-app record.
|
|
683
|
+
*/
|
|
684
|
+
type AppDisconnectMessage = PayEnvelope<"disconnect", EmptyPayload>;
|
|
685
|
+
/**
|
|
686
|
+
* app → hub, request: open Fund in the hub's Stridge Wallet dialog, on the screen `start` names (`fund` when omitted).
|
|
687
|
+
* The dialog and every amount, address and linked wallet in it stay in the hub. Answered by `result` (`request:
|
|
688
|
+
* "fund"`) once the user closes Fund, which is the normal end, not `cancelled`, whatever the user did inside it.
|
|
689
|
+
*
|
|
690
|
+
* It needs a session whose user authorized this app, the hub signs no one in and renews
|
|
691
|
+
* nothing for it, and it fails with the `error` set: `signed-out` (no session, or an app the user has not
|
|
692
|
+
* authorized, not told apart), `session-locked`, `app-suspended`, `wallet-closed`, `network`, `rate-limited`,
|
|
693
|
+
* `wallet-not-ready`, `internal`, `busy`, `not-initialized` and `cancelled`, under the session rules. A framed hub page
|
|
694
|
+
* that cannot reach its first-party storage answers `internal` with the message `HUB_NEEDS_POPUP_MESSAGE`, so the app
|
|
695
|
+
* opens the Pay window from the user's click. In the Pay window the request stays open while Fund shows, and the window
|
|
696
|
+
* closes itself only after the answer; a closed window ends the request in `result`, since it closes Fund.
|
|
697
|
+
*
|
|
698
|
+
* A hub that predates Fund drops this request, because its guard rejects the unknown type, and answers nothing: no
|
|
699
|
+
* `error`, no `overlay-open`. Without a bound, the request would stay in flight in the iframe until the hub page
|
|
700
|
+
* reloads, and in the Pay window until the user closes it. The app face bounds the wait: a request that gets neither
|
|
701
|
+
* an answer nor an exact-id `fund-received` within its limit ends with the app face's own `unavailable` and sends
|
|
702
|
+
* `fund-cancel` with that id. A current hub receipts before session work and retires an exact-id cancellation.
|
|
703
|
+
*/
|
|
704
|
+
type AppFundMessage = PayEnvelope<typeof PAY_FUND_REQUEST_TYPE, FundPayload>;
|
|
705
|
+
/** app → hub: retire only the Fund request with this same envelope id. No answer is required. */
|
|
706
|
+
type AppFundCancelMessage = PayEnvelope<typeof PAY_FUND_MESSAGE_TYPES.cancel, EmptyPayload>;
|
|
707
|
+
/**
|
|
708
|
+
* Every message the app sends the hub.
|
|
709
|
+
*/
|
|
710
|
+
type AppMessage = AppInitMessage | AppAppearanceMessage | AppSignInMessage | AppSignMessage | AppSignOutMessage | AppDisconnectMessage | AppFundMessage | AppFundCancelMessage;
|
|
711
|
+
/**
|
|
712
|
+
* The app → hub message types that are requests, and so get a `result` or `error` with the same `id`.
|
|
713
|
+
*/
|
|
714
|
+
type HubRequestType = "pay" | "init" | "sign-in" | "sign" | "sign-out" | "disconnect" | typeof PAY_FUND_REQUEST_TYPE;
|
|
715
|
+
/**
|
|
716
|
+
* What the app face shows, as the hub reports it.
|
|
717
|
+
*
|
|
718
|
+
* - `checking` — the start-up checks (guide §10) are running.
|
|
719
|
+
* - `signed-out` — no session.
|
|
720
|
+
* - `signed-in` — a session; `evmAddress` is present once the wallet has an address, which a `pending` wallet already
|
|
721
|
+
* has. Signing needs an active wallet: until then a sign fails because the wallet cannot sign yet.
|
|
722
|
+
* - `session-locked` — a live session whose `csrf_token` is lost: nothing can change until it expires.
|
|
723
|
+
* - `app-suspended` — the backend refuses this app id: a configuration error.
|
|
724
|
+
* - `wallet-closed` — the session's wallet is wound down.
|
|
725
|
+
* - `unavailable` — the start-up checks could not finish: no answer from the Coordinator, a rate limit, or a wallet
|
|
726
|
+
* still provisioning after the wait ran out. The hub offers a retry; the app face reads it as "try later". The app
|
|
727
|
+
* face also reports it on its own when the hub never completes the handshake.
|
|
728
|
+
*/
|
|
729
|
+
type HubStatus = "checking" | "signed-out" | "signed-in" | "session-locked" | "app-suspended" | "wallet-closed" | "unavailable";
|
|
730
|
+
/**
|
|
731
|
+
* The payload of `state`: a full snapshot, replacing the previous one.
|
|
732
|
+
*/
|
|
733
|
+
interface HubStateSnapshot {
|
|
734
|
+
/**
|
|
735
|
+
* The status.
|
|
736
|
+
*/
|
|
737
|
+
status: HubStatus;
|
|
738
|
+
/**
|
|
739
|
+
* The wallet's EVM address, checksummed as the Coordinator returned it. Only with `signed-in`, once the wallet has
|
|
740
|
+
* an address; the wallet may still be `pending`, and a sign fails until it is active.
|
|
741
|
+
*/
|
|
742
|
+
evmAddress?: string;
|
|
743
|
+
/**
|
|
744
|
+
* RFC 3339 instant the keypair stops signing. Only when a keypair is registered.
|
|
745
|
+
*/
|
|
746
|
+
keypairExpiresAt?: string;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Where the hub shows its ceremonies.
|
|
750
|
+
*
|
|
751
|
+
* - `overlay` — in the iframe the app framed, shown as a full-viewport overlay on the app's page.
|
|
752
|
+
* - `popup` — in a window on the hub's origin that the app opens from the user's click. The hub picks it from its own
|
|
753
|
+
* setting and from whether its framed page can reach the hub's first-party storage.
|
|
754
|
+
*/
|
|
755
|
+
type HubTransport = "overlay" | "popup";
|
|
756
|
+
/**
|
|
757
|
+
* The payload of `transport`.
|
|
758
|
+
*/
|
|
759
|
+
interface TransportPayload {
|
|
760
|
+
/**
|
|
761
|
+
* Where the hub shows its ceremonies.
|
|
762
|
+
*/
|
|
763
|
+
mode: HubTransport;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* The `result` payload for `init`.
|
|
767
|
+
*/
|
|
768
|
+
interface InitResult {
|
|
769
|
+
/**
|
|
770
|
+
* Discriminant: the request this answers.
|
|
771
|
+
*/
|
|
772
|
+
request: "init";
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* The `result` payload for `sign-in`.
|
|
776
|
+
*/
|
|
777
|
+
interface SignInResult {
|
|
778
|
+
/**
|
|
779
|
+
* Discriminant: the request this answers.
|
|
780
|
+
*/
|
|
781
|
+
request: "sign-in";
|
|
782
|
+
/**
|
|
783
|
+
* The signed-in wallet's EVM address.
|
|
784
|
+
*/
|
|
785
|
+
evmAddress: string;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* The `result` payload for `sign`: the EIP-191 personal-message signature, ready for any EVM verifier (viem's
|
|
789
|
+
* `verifyMessage`, `ecrecover`). The hub builds it only after it recovered the signer from Turnkey's `r`, `s` and `v`
|
|
790
|
+
* over the signed payload and matched it with the wallet's EVM address, so a signature that does not recover to the
|
|
791
|
+
* wallet never reaches the app.
|
|
792
|
+
*/
|
|
793
|
+
interface SignResult {
|
|
794
|
+
/**
|
|
795
|
+
* Discriminant: the request this answers.
|
|
796
|
+
*/
|
|
797
|
+
request: "sign";
|
|
798
|
+
/**
|
|
799
|
+
* `0x` followed by 130 lowercase hex characters: r (32 bytes) ‖ s (32 bytes, always the low-s form) ‖ v (one byte,
|
|
800
|
+
* `1b` or `1c`, that is 27 or 28). Byte-identical to viem's `signMessage` for the same key and message. Built with
|
|
801
|
+
* `toEvmSignature`.
|
|
802
|
+
*/
|
|
803
|
+
signature: string;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* The `result` payload for `sign-out`.
|
|
807
|
+
*/
|
|
808
|
+
interface SignOutResult {
|
|
809
|
+
/**
|
|
810
|
+
* Discriminant: the request this answers.
|
|
811
|
+
*/
|
|
812
|
+
request: "sign-out";
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* The `result` payload for `disconnect`.
|
|
816
|
+
*/
|
|
817
|
+
interface DisconnectResult {
|
|
818
|
+
/**
|
|
819
|
+
* Discriminant: the request this answers.
|
|
820
|
+
*/
|
|
821
|
+
request: "disconnect";
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* The `result` payload for `fund`: the user closed Fund. It carries no amount, address or linked wallet.
|
|
825
|
+
*/
|
|
826
|
+
interface FundResult {
|
|
827
|
+
/**
|
|
828
|
+
* Discriminant: the request this answers.
|
|
829
|
+
*/
|
|
830
|
+
request: typeof PAY_FUND_REQUEST_TYPE;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Every `result` payload; narrow on `request`.
|
|
834
|
+
*/
|
|
835
|
+
type HubResult = {
|
|
836
|
+
request: "pay";
|
|
837
|
+
} | InitResult | SignInResult | SignResult | SignOutResult | DisconnectResult | FundResult;
|
|
838
|
+
/**
|
|
839
|
+
* Why a request failed, as the app sees it.
|
|
840
|
+
*
|
|
841
|
+
* - `cancelled` — the user closed the dialog.
|
|
842
|
+
* - `busy` — another request is still in progress.
|
|
843
|
+
* - `not-initialized` — a request arrived before `init`.
|
|
844
|
+
* - `signed-out` — the request needs a session and there is none.
|
|
845
|
+
* - `refused` — the signature was refused: by the provider, or by the hub for a sign-in message meant for another site.
|
|
846
|
+
* - `outcome-unknown` — the signature's outcome is unknown; never retried automatically.
|
|
847
|
+
* - `cosignature-required` — the request waits for a second approval that nothing will give.
|
|
848
|
+
* - `session-locked` — the session's `csrf_token` is lost.
|
|
849
|
+
* - `app-suspended` — the backend refuses this app id.
|
|
850
|
+
* - `rate-limited` — too many requests; `retryAfterSeconds` says how long to wait when known.
|
|
851
|
+
* - `wallet-closed` — the wallet is wound down.
|
|
852
|
+
* - `wallet-not-ready` — the wallet is still provisioning after the wait ran out.
|
|
853
|
+
* - `network` — the hub could not reach the Coordinator.
|
|
854
|
+
* - `internal` — anything else.
|
|
855
|
+
*/
|
|
856
|
+
type HubErrorCode = "cancelled" | "busy" | "not-initialized" | "signed-out" | "refused" | "outcome-unknown" | "cosignature-required" | "session-locked" | "app-suspended" | "rate-limited" | "wallet-closed" | "wallet-not-ready" | "network" | "internal";
|
|
857
|
+
/**
|
|
858
|
+
* The payload of `error`.
|
|
859
|
+
*/
|
|
860
|
+
interface HubError {
|
|
861
|
+
/**
|
|
862
|
+
* The request this answers.
|
|
863
|
+
*/
|
|
864
|
+
request: HubRequestType;
|
|
865
|
+
/**
|
|
866
|
+
* Why it failed.
|
|
867
|
+
*/
|
|
868
|
+
code: HubErrorCode;
|
|
869
|
+
/**
|
|
870
|
+
* A developer-facing description, at most 1024 characters, possibly empty. Never shown to the user as is. One
|
|
871
|
+
* value is read by the app: `HUB_NEEDS_POPUP_MESSAGE` with the code `internal`, which a framed hub page answers
|
|
872
|
+
* when the request belongs in the Pay window, sends the app's next request there.
|
|
873
|
+
*/
|
|
874
|
+
message: string;
|
|
875
|
+
/**
|
|
876
|
+
* Whole seconds to wait, with `rate-limited`, when the Coordinator said.
|
|
877
|
+
*/
|
|
878
|
+
retryAfterSeconds?: number;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* hub → app: the hub's listener is attached. Sent once per page load of the hub; the app answers with `init`.
|
|
882
|
+
*/
|
|
883
|
+
type HubReadyMessage = PayEnvelope<"ready", EmptyPayload>;
|
|
884
|
+
/**
|
|
885
|
+
* hub → app: where the hub shows its ceremonies. Sent after a valid `init`, before its `result`, so the app knows the
|
|
886
|
+
* transport before its first request. No reply.
|
|
887
|
+
*
|
|
888
|
+
* Safe across versions: an app that predates this message drops it as an unknown type, and an app that never receives
|
|
889
|
+
* it (a hub that predates it) treats the transport as `overlay`.
|
|
890
|
+
*/
|
|
891
|
+
type HubTransportMessage = PayEnvelope<"transport", TransportPayload>;
|
|
892
|
+
/**
|
|
893
|
+
* hub → app: the state changed. The first one follows the `init` result.
|
|
894
|
+
*/
|
|
895
|
+
type HubStateMessage = PayEnvelope<"state", HubStateSnapshot>;
|
|
896
|
+
/**
|
|
897
|
+
* hub → app: a ceremony needs UI; the app shows the iframe as a full-viewport transparent overlay.
|
|
898
|
+
*/
|
|
899
|
+
type HubOverlayOpenMessage = PayEnvelope<"overlay-open", EmptyPayload>;
|
|
900
|
+
/**
|
|
901
|
+
* hub → app: the ceremony UI is gone; the app hides the iframe again at zero size.
|
|
902
|
+
*/
|
|
903
|
+
type HubOverlayCloseMessage = PayEnvelope<"overlay-close", EmptyPayload>;
|
|
904
|
+
/** hub → app: this hub accepted the Fund request with this same envelope id before session work. */
|
|
905
|
+
type HubFundReceivedMessage = PayEnvelope<typeof PAY_FUND_MESSAGE_TYPES.received, EmptyPayload>;
|
|
906
|
+
/**
|
|
907
|
+
* hub → app: a request succeeded. Its `id` is the request's.
|
|
908
|
+
*/
|
|
909
|
+
type HubResultMessage = PayEnvelope<"result", HubResult>;
|
|
910
|
+
/**
|
|
911
|
+
* hub → app: a request failed. Its `id` is the request's.
|
|
912
|
+
*/
|
|
913
|
+
type HubErrorMessage = PayEnvelope<"error", HubError>;
|
|
914
|
+
/**
|
|
915
|
+
* Every message the hub sends the app.
|
|
916
|
+
*/
|
|
917
|
+
type HubMessage = HubReadyMessage | HubTransportMessage | HubStateMessage | HubOverlayOpenMessage | HubOverlayCloseMessage | HubFundReceivedMessage | HubResultMessage | HubErrorMessage;
|
|
918
|
+
/**
|
|
919
|
+
* The copy of a card Pay element. Each label is a string of at most `MAX_ELEMENT_LABEL_LENGTH` characters, possibly
|
|
920
|
+
* empty; an omitted label resets its part to the default, or leaves an optional part out. The sign action's label is
|
|
921
|
+
* not here: it lives on the action alone.
|
|
922
|
+
*/
|
|
923
|
+
interface CardElementLabels {
|
|
924
|
+
/**
|
|
925
|
+
* The sign-in button's label.
|
|
926
|
+
*/
|
|
927
|
+
button?: string;
|
|
928
|
+
/**
|
|
929
|
+
* The copy shown when the sign action can no longer be used.
|
|
930
|
+
*/
|
|
931
|
+
actionExpired?: string;
|
|
932
|
+
/**
|
|
933
|
+
* The title shown after the user signed.
|
|
934
|
+
*/
|
|
935
|
+
done?: string;
|
|
936
|
+
/**
|
|
937
|
+
* The description under the done title.
|
|
938
|
+
*/
|
|
939
|
+
doneDescription?: string;
|
|
940
|
+
/**
|
|
941
|
+
* The label of the Balance part.
|
|
942
|
+
*/
|
|
943
|
+
balanceLabel?: string;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* The one sign action a card offers.
|
|
947
|
+
*/
|
|
948
|
+
interface ElementSignAction {
|
|
949
|
+
/**
|
|
950
|
+
* Identifies this sign attempt: a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters. One attempt
|
|
951
|
+
* carries one immutable message and produces at most one signature for the handle's lifetime; the `signed` or
|
|
952
|
+
* `failed` notice for it carries the same id.
|
|
953
|
+
*/
|
|
954
|
+
attemptId: string;
|
|
955
|
+
/**
|
|
956
|
+
* The message to sign as the user sees it: a non-empty string of at most `MAX_SIGN_MESSAGE_BYTES` UTF-8 bytes, as
|
|
957
|
+
* for `sign`. Never trimmed or normalized.
|
|
958
|
+
*/
|
|
959
|
+
message: string;
|
|
960
|
+
/**
|
|
961
|
+
* The action button's label, at most `MAX_ELEMENT_LABEL_LENGTH` characters, possibly empty.
|
|
962
|
+
*/
|
|
963
|
+
label: string;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* The config bundle of a card Pay element: its copy, its sign action and whether it shows the Balance part, applied
|
|
967
|
+
* together.
|
|
968
|
+
*/
|
|
969
|
+
interface CardElementConfig {
|
|
970
|
+
/**
|
|
971
|
+
* The bundle's revision: a safe integer from 1. A higher revision replaces the applied bundle whole.
|
|
972
|
+
*/
|
|
973
|
+
revision: number;
|
|
974
|
+
/**
|
|
975
|
+
* The card's copy.
|
|
976
|
+
*/
|
|
977
|
+
labels: CardElementLabels;
|
|
978
|
+
/**
|
|
979
|
+
* The sign action, or `null` while none is configured, which keeps signing disabled.
|
|
980
|
+
*/
|
|
981
|
+
action: ElementSignAction | null;
|
|
982
|
+
/**
|
|
983
|
+
* Whether the card shows its Balance part. It carries no balance value or source.
|
|
984
|
+
*/
|
|
985
|
+
showBalance: boolean;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* The payload of `element-init`: exactly these three keys. It carries no build id, origin, revision, balance or app
|
|
989
|
+
* name; the Pay element and the hub frame compare their build ids over their own link.
|
|
990
|
+
*/
|
|
991
|
+
interface ElementInitPayload {
|
|
992
|
+
/**
|
|
993
|
+
* The app's id (`app_` and a 26-character ULID). The Pay element binds it to the app its URL names.
|
|
994
|
+
*/
|
|
995
|
+
appId: string;
|
|
996
|
+
/**
|
|
997
|
+
* The name of the app's hub frame: 1 to `MAX_MESSAGE_ID_LENGTH` characters, an ASCII letter or digit, then ASCII
|
|
998
|
+
* letters, digits, `_` or `-`. So never a reserved name such as `_top`. The Pay element finds the hub frame by it;
|
|
999
|
+
* it is a routing hint and authorizes nothing.
|
|
1000
|
+
*/
|
|
1001
|
+
hubFrame: string;
|
|
1002
|
+
/**
|
|
1003
|
+
* How the Pay element should look.
|
|
1004
|
+
*/
|
|
1005
|
+
appearance: HubAppearance;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* app → Pay element, request: the handshake, sent after the Pay element's `element-ready`. Answered by
|
|
1009
|
+
* `element-accepted` or `element-refused` with the same `id`.
|
|
1010
|
+
*/
|
|
1011
|
+
type AppElementInitMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.init, ElementInitPayload>;
|
|
1012
|
+
/**
|
|
1013
|
+
* The payload of `element-config`: one full bundle for the Pay element.
|
|
1014
|
+
*/
|
|
1015
|
+
type ElementConfigPayload = CardElementConfig;
|
|
1016
|
+
/**
|
|
1017
|
+
* app → Pay element, request: apply this config bundle. Answered by `element-config-ack` with the same `id` once the
|
|
1018
|
+
* bundle is applied.
|
|
1019
|
+
*/
|
|
1020
|
+
type AppElementConfigMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.config, ElementConfigPayload>;
|
|
1021
|
+
/**
|
|
1022
|
+
* app → Pay element: focus the Pay element's primary control. No reply.
|
|
1023
|
+
*/
|
|
1024
|
+
type AppElementFocusMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.focus, EmptyPayload>;
|
|
1025
|
+
/** Completes the original menu-anchor, consuming its private focus callback. */
|
|
1026
|
+
type AppElementMenuEndedMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.menuEnded, {
|
|
1027
|
+
restoreFocus: boolean;
|
|
1028
|
+
}>;
|
|
1029
|
+
/** {@link AppElementMessage} as the hub decodes it: its pay and deposit requests may carry the legacy key. Internal. */
|
|
1030
|
+
type HubAppElementMessage = Exclude<AppElementMessage, AppElementPayRequestMessage | AppElementDepositRequestMessage> | HubAppElementPayRequestMessage | HubAppElementDepositRequestMessage;
|
|
1031
|
+
/** Every message the app sends a Pay element, including independent menu completion. */
|
|
1032
|
+
type AppElementMessage = AppElementPayRequestMessage | AppElementDepositRequestMessage | AppElementMenuEndedMessage | AppElementInitMessage | AppElementConfigMessage | AppElementFocusMessage | AppAppearanceMessage | AppElementActionEligibilityMessage | AppElementReloadGrantMessage | AppElementCheckStatusCapabilityMessage | AppElementCheckStatusSettledMessage | AppElementPageUrlMessage | ElementGeometryCapabilitiesMessage | AppElementGeometryCompleteMessage | AppElementGeometryCancelledMessage;
|
|
1033
|
+
/**
|
|
1034
|
+
* The requests of a ceremony: every `HubRequestType` except `init`, which has its own handshake answers.
|
|
1035
|
+
*/
|
|
1036
|
+
type CeremonyRequestType = Exclude<HubRequestType, "init">;
|
|
1037
|
+
/**
|
|
1038
|
+
* Why a ceremony that a Pay element ran failed: every `HubErrorCode`, and the two failures of the Pay element itself
|
|
1039
|
+
* in `PAY_ELEMENT_FAILURE_CODES`.
|
|
1040
|
+
*
|
|
1041
|
+
* - `unavailable` — the hub never completed the handshake, or reloaded while the request was in flight.
|
|
1042
|
+
* - `popup-blocked` — the browser refused to open the Pay window the Pay element opens from the user's click.
|
|
1043
|
+
*
|
|
1044
|
+
* The app face raises the same two codes when it owns the request. No hub sends them, so `HubErrorCode` stays as
|
|
1045
|
+
* it is.
|
|
1046
|
+
*/
|
|
1047
|
+
type ElementFailureCode = HubErrorCode | (typeof PAY_ELEMENT_FAILURE_CODES)[keyof typeof PAY_ELEMENT_FAILURE_CODES];
|
|
1048
|
+
/**
|
|
1049
|
+
* The payload of a handshake refusal: why the peer refused the handshake. It names no request.
|
|
1050
|
+
*/
|
|
1051
|
+
interface RefusalPayload {
|
|
1052
|
+
/**
|
|
1053
|
+
* Why the peer refused.
|
|
1054
|
+
*/
|
|
1055
|
+
code: HubErrorCode;
|
|
1056
|
+
/**
|
|
1057
|
+
* A developer-facing description, at most `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty. Never shown to
|
|
1058
|
+
* the user as is.
|
|
1059
|
+
*/
|
|
1060
|
+
message: string;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* The payload of `element-config-ack`.
|
|
1064
|
+
*/
|
|
1065
|
+
interface ElementConfigAckPayload {
|
|
1066
|
+
/**
|
|
1067
|
+
* The revision of the bundle the Pay element applied: a safe integer from 1.
|
|
1068
|
+
*/
|
|
1069
|
+
revision: number;
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* The payload of `resize`.
|
|
1073
|
+
*/
|
|
1074
|
+
interface ElementResizePayload {
|
|
1075
|
+
/**
|
|
1076
|
+
* The Pay element's content block size in CSS pixels: a finite number from 0 to `MAX_ELEMENT_BLOCK_SIZE`.
|
|
1077
|
+
* Fractions are valid.
|
|
1078
|
+
*/
|
|
1079
|
+
blockSize: number;
|
|
1080
|
+
/**
|
|
1081
|
+
* How long the app animates the frame to the new size, in whole milliseconds from 0 to
|
|
1082
|
+
* `MAX_ELEMENT_RESIZE_DURATION_MS`. `0` means immediately.
|
|
1083
|
+
*/
|
|
1084
|
+
durationMs: number;
|
|
1085
|
+
}
|
|
1086
|
+
/** The current accepted element document and handshake, echoed in every geometry outcome. */
|
|
1087
|
+
interface ElementGeometryLifetimePayload {
|
|
1088
|
+
/** The element document's lowercase canonical version-4 UUID. */
|
|
1089
|
+
documentId: string;
|
|
1090
|
+
/** The accepted element-init envelope id, bounded by MAX_MESSAGE_ID_LENGTH. */
|
|
1091
|
+
initId: string;
|
|
1092
|
+
}
|
|
1093
|
+
/** Both peers advertise support for geometry and routed overlay receipts in this lifetime. */
|
|
1094
|
+
interface ElementGeometryCapabilitiesPayload extends ElementGeometryLifetimePayload {
|
|
1095
|
+
/** `false` withdraws support and restores immediate intrinsic sizing. */
|
|
1096
|
+
supported: boolean;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* app ↔ element on A/B: an independent advertisement with a fresh envelope id. Start unsupported for every
|
|
1100
|
+
* document/init. Use geometry targets only after sending and receiving `supported: true` for the same lifetime.
|
|
1101
|
+
* The element advertises after acceptance and build-compatible hub attachment; the app pins that authenticated
|
|
1102
|
+
* document before echoing its lifetime. Support includes the app's overlay-hidden receipts on D and the element's
|
|
1103
|
+
* consumption of the hub's routed receipts on C.
|
|
1104
|
+
*/
|
|
1105
|
+
type ElementGeometryCapabilitiesMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.geometryCapabilities, ElementGeometryCapabilitiesPayload>;
|
|
1106
|
+
/** The fixed geometry easing vocabulary; receivers map the identifier to CSS locally. */
|
|
1107
|
+
type ElementGeometryEasing = (typeof SUA_ELEMENT_GEOMETRY_EASINGS)[keyof typeof SUA_ELEMENT_GEOMETRY_EASINGS];
|
|
1108
|
+
/** A target in CSS pixels, with the same size/duration bounds as resize and a constrained easing. */
|
|
1109
|
+
interface ElementGeometryTargetPayload extends ElementGeometryLifetimePayload, ElementResizePayload {
|
|
1110
|
+
/** `standard` maps to cubic-bezier(0.4, 0, 0.2, 1). */
|
|
1111
|
+
easing: ElementGeometryEasing;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* element → app on B: the envelope id is the fresh geometry operation id. Only the app sizes the frame.
|
|
1115
|
+
* The app answers once with complete or cancelled using the same id and document/init. Geometry operations are
|
|
1116
|
+
* independent of ceremony requests; a receiver still authenticates source, origin and the current lifetime.
|
|
1117
|
+
*/
|
|
1118
|
+
type ElementGeometryTargetMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.geometryTarget, ElementGeometryTargetPayload>;
|
|
1119
|
+
/** app → element on A: the requested geometry was applied; id echoes the target operation. */
|
|
1120
|
+
type AppElementGeometryCompleteMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.geometryComplete, ElementGeometryLifetimePayload>;
|
|
1121
|
+
/**
|
|
1122
|
+
* app → element on A: the target was retired before completion; id echoes the target operation. Width changes,
|
|
1123
|
+
* replacement, retry and teardown cancel pending work. Ignore late outcomes and reconcile a current outcome once.
|
|
1124
|
+
*/
|
|
1125
|
+
type AppElementGeometryCancelledMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.geometryCancelled, ElementGeometryLifetimePayload>;
|
|
1126
|
+
/**
|
|
1127
|
+
* The payload of `signed`: the signature for one captured sign attempt.
|
|
1128
|
+
*/
|
|
1129
|
+
interface ElementSignedPayload {
|
|
1130
|
+
/**
|
|
1131
|
+
* The signature, in the shape of `SignResult.signature`.
|
|
1132
|
+
*/
|
|
1133
|
+
signature: string;
|
|
1134
|
+
/**
|
|
1135
|
+
* The message that was signed: a non-empty string of at most `MAX_SIGN_MESSAGE_BYTES` UTF-8 bytes. It equals the
|
|
1136
|
+
* captured attempt's message; the app checks that at runtime.
|
|
1137
|
+
*/
|
|
1138
|
+
message: string;
|
|
1139
|
+
/**
|
|
1140
|
+
* The captured attempt's id, which may be older than the config the Pay element applies now.
|
|
1141
|
+
*/
|
|
1142
|
+
attemptId: string;
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* The `failed` payload for a sign attempt.
|
|
1146
|
+
*/
|
|
1147
|
+
interface ElementSignFailure {
|
|
1148
|
+
/**
|
|
1149
|
+
* Discriminant: the request that failed.
|
|
1150
|
+
*/
|
|
1151
|
+
request: "sign";
|
|
1152
|
+
/**
|
|
1153
|
+
* Why it failed.
|
|
1154
|
+
*/
|
|
1155
|
+
code: ElementFailureCode;
|
|
1156
|
+
/**
|
|
1157
|
+
* A developer-facing description, at most `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty. Never shown to
|
|
1158
|
+
* the user as is.
|
|
1159
|
+
*/
|
|
1160
|
+
message: string;
|
|
1161
|
+
/**
|
|
1162
|
+
* The captured attempt's id. Always present, so a cancel, a refusal, a blocked Pay window or an unknown outcome
|
|
1163
|
+
* each settles the right attempt.
|
|
1164
|
+
*/
|
|
1165
|
+
attemptId: string;
|
|
1166
|
+
/**
|
|
1167
|
+
* Whole seconds to wait, with `rate-limited`, when the Coordinator said.
|
|
1168
|
+
*/
|
|
1169
|
+
retryAfterSeconds?: number;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* The `failed` payload for a ceremony other than sign. It carries no attempt id.
|
|
1173
|
+
*/
|
|
1174
|
+
interface ElementCeremonyFailure {
|
|
1175
|
+
/**
|
|
1176
|
+
* Discriminant: the request that failed.
|
|
1177
|
+
*/
|
|
1178
|
+
request: Exclude<CeremonyRequestType, "sign">;
|
|
1179
|
+
/**
|
|
1180
|
+
* Why it failed.
|
|
1181
|
+
*/
|
|
1182
|
+
code: ElementFailureCode;
|
|
1183
|
+
/**
|
|
1184
|
+
* A developer-facing description, at most `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty. Never shown to
|
|
1185
|
+
* the user as is.
|
|
1186
|
+
*/
|
|
1187
|
+
message: string;
|
|
1188
|
+
/**
|
|
1189
|
+
* Whole seconds to wait, with `rate-limited`, when the Coordinator said.
|
|
1190
|
+
*/
|
|
1191
|
+
retryAfterSeconds?: number;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* The payload of `failed`; narrow on `request`. Only the sign branch carries an attempt id.
|
|
1195
|
+
*/
|
|
1196
|
+
type ElementFailedPayload = ElementSignFailure | ElementCeremonyFailure;
|
|
1197
|
+
/**
|
|
1198
|
+
* A rect in CSS pixels, as plain data (not a `DOMRect`). Every value is finite; `x` and `y` lie within
|
|
1199
|
+
* ±`MAX_MENU_RECT_VALUE`, and `width` and `height` from 0 to `MAX_MENU_RECT_VALUE`. Fractions are valid.
|
|
1200
|
+
*/
|
|
1201
|
+
interface PayMenuRect {
|
|
1202
|
+
/**
|
|
1203
|
+
* The left edge.
|
|
1204
|
+
*/
|
|
1205
|
+
x: number;
|
|
1206
|
+
/**
|
|
1207
|
+
* The top edge.
|
|
1208
|
+
*/
|
|
1209
|
+
y: number;
|
|
1210
|
+
/**
|
|
1211
|
+
* The width.
|
|
1212
|
+
*/
|
|
1213
|
+
width: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* The height.
|
|
1216
|
+
*/
|
|
1217
|
+
height: number;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* `menu-payment`: the order the card's next menu opens over (`paymentId`), and whether the card's owner hold for the
|
|
1221
|
+
* current person holds it (`held`), so the menu hides the address in that state only. Hiding is the only thing it can
|
|
1222
|
+
* do; it grants nothing.
|
|
1223
|
+
*/
|
|
1224
|
+
type ElementMenuPaymentMessage = PayEnvelope<"menu-payment", {
|
|
1225
|
+
paymentId: string | null;
|
|
1226
|
+
held: boolean;
|
|
1227
|
+
}>;
|
|
1228
|
+
/**
|
|
1229
|
+
* The payload of `menu-anchor`.
|
|
1230
|
+
*/
|
|
1231
|
+
interface ElementMenuAnchorPayload {
|
|
1232
|
+
/**
|
|
1233
|
+
* The control the menu anchors to, relative to the Pay element's viewport.
|
|
1234
|
+
*/
|
|
1235
|
+
rect: PayMenuRect;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Pay element → app: the Pay element's listener is attached. Sent once per page load of the Pay element; after a
|
|
1239
|
+
* reload, the app repeats the handshake. No reply.
|
|
1240
|
+
*/
|
|
1241
|
+
type ElementReadyMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.ready, EmptyPayload>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Pay element → app: the Pay element accepted the handshake. Its `id` is the handshake request's.
|
|
1244
|
+
*/
|
|
1245
|
+
type ElementAcceptedMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.accepted, EmptyPayload>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Pay element → app: the Pay element refused the handshake. Its `id` is the handshake request's.
|
|
1248
|
+
*/
|
|
1249
|
+
type ElementRefusedMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.refused, RefusalPayload>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Pay element → app: the Pay element applied a config bundle. Its `id` is the `element-config` request's, and the
|
|
1252
|
+
* Pay element posts it before it enables a click for that revision.
|
|
1253
|
+
*/
|
|
1254
|
+
type ElementConfigAckMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.configAck, ElementConfigAckPayload>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Pay element → app: the Pay element's content changed size; the app sizes the frame to it. No reply.
|
|
1257
|
+
*/
|
|
1258
|
+
type ElementResizeMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.resize, ElementResizePayload>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Pay element → app: the user signed a captured attempt. No reply. It carries no email, code, keypair or address of
|
|
1261
|
+
* another network.
|
|
1262
|
+
*/
|
|
1263
|
+
type ElementSignedMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.signed, ElementSignedPayload>;
|
|
1264
|
+
/**
|
|
1265
|
+
* Pay element → app: a ceremony the Pay element ran failed. No reply. It is not a `HubError`: it carries the
|
|
1266
|
+
* Pay element's own failures, and an attempt id on sign.
|
|
1267
|
+
*/
|
|
1268
|
+
type ElementFailedMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.failed, ElementFailedPayload>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Pay element → app: where the control a menu anchors to sits. The app converts the rect to its own viewport. It
|
|
1271
|
+
* authorizes nothing. No reply.
|
|
1272
|
+
*/
|
|
1273
|
+
type ElementMenuAnchorMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.menuAnchor, ElementMenuAnchorPayload>;
|
|
1274
|
+
/**
|
|
1275
|
+
* A connected address observed through the element's current authenticated link C state.
|
|
1276
|
+
*/
|
|
1277
|
+
interface ElementConnectedPayload {
|
|
1278
|
+
/** The element document's lowercase canonical version-4 UUID. Correlation, not authentication. */
|
|
1279
|
+
documentId: string;
|
|
1280
|
+
/** The accepted element-init envelope id, bounded by MAX_MESSAGE_ID_LENGTH. */
|
|
1281
|
+
initId: string;
|
|
1282
|
+
/** A safe integer from 1, increasing within the accepted init. */
|
|
1283
|
+
sequence: number;
|
|
1284
|
+
/** The observed address, matching EVM_ADDRESS_PATTERN. */
|
|
1285
|
+
evmAddress: string;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Pay element → app notification. The receiver authenticates the sender and checks its current init, pinned document
|
|
1289
|
+
* and increasing sequence before delivery. This notice does not prove a live signing session.
|
|
1290
|
+
*/
|
|
1291
|
+
type ElementConnectedMessage = PayEnvelope<typeof PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.connected, ElementConnectedPayload>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Pay element → app notification: the element's real view is on screen, in place of its placeholder. It follows the
|
|
1294
|
+
* `resize` for that view. No reply.
|
|
1295
|
+
*/
|
|
1296
|
+
type ElementViewShownMessage = PayEnvelope<typeof PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.viewShown, EmptyPayload>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Why the view a Pay element shows is a load failure: `hub-frame` or `internal`.
|
|
1299
|
+
*/
|
|
1300
|
+
type PayElementLoadFailureReason = (typeof PAY_ELEMENT_LOAD_FAILURE_REASONS)[keyof typeof PAY_ELEMENT_LOAD_FAILURE_REASONS];
|
|
1301
|
+
/**
|
|
1302
|
+
* The payload of `element-load-failed`.
|
|
1303
|
+
*/
|
|
1304
|
+
interface ElementLoadFailedPayload {
|
|
1305
|
+
/**
|
|
1306
|
+
* Why the view is a load failure.
|
|
1307
|
+
*/
|
|
1308
|
+
reason: PayElementLoadFailureReason;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Pay element → app notification: the view the element shows is a load failure. It follows the `resize` for that
|
|
1312
|
+
* view. It is not a `failed`: no ceremony ran. No reply.
|
|
1313
|
+
*/
|
|
1314
|
+
type ElementLoadFailedMessage = PayEnvelope<typeof PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.loadFailed, ElementLoadFailedPayload>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Every message a Pay element sends the app, including lifetime requests and `element-check-status-request`.
|
|
1317
|
+
*/
|
|
1318
|
+
type ElementMessage = ElementPayRequestAckMessage | ElementPaidMessage | ElementCheckoutResultMessage | ElementHeldMessage | ElementUnconfirmedMessage | ElementReadyMessage | ElementAcceptedMessage | ElementRefusedMessage | ElementConfigAckMessage | ElementResizeMessage | ElementSignedMessage | ElementFailedMessage | ElementMenuAnchorMessage | ElementConnectedMessage | ElementViewShownMessage | ElementLoadFailedMessage | ElementActionCheckMessage | ElementReloadRequestMessage | ElementCheckStatusRequestMessage | ElementGeometryCapabilitiesMessage | ElementGeometryTargetMessage;
|
|
1319
|
+
/**
|
|
1320
|
+
* The payload of `activity`.
|
|
1321
|
+
*/
|
|
1322
|
+
interface HubActivityPayload {
|
|
1323
|
+
/**
|
|
1324
|
+
* Whether the hub is busy across all its peers: a ceremony, or background work that cannot be cancelled (such as a
|
|
1325
|
+
* registration that goes on after the dialog closed), still prevents another request. It is `false` only when the
|
|
1326
|
+
* hub can take a request again. Not a counter, and it names no request.
|
|
1327
|
+
*/
|
|
1328
|
+
pending: boolean;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* The payload of `show-menu`.
|
|
1332
|
+
*/
|
|
1333
|
+
interface AppShowMenuPayload {
|
|
1334
|
+
/**
|
|
1335
|
+
* The control the menu anchors to, in the app's viewport: the app converts the Pay element's `menu-anchor` rect
|
|
1336
|
+
* before it sends it.
|
|
1337
|
+
*/
|
|
1338
|
+
anchor: PayMenuRect;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* The payload of `menu-refused`: why the hub did not show the menu. It names no request.
|
|
1342
|
+
*/
|
|
1343
|
+
interface MenuRefusalPayload {
|
|
1344
|
+
/**
|
|
1345
|
+
* Why the hub refused.
|
|
1346
|
+
*/
|
|
1347
|
+
code: HubErrorCode;
|
|
1348
|
+
/**
|
|
1349
|
+
* A developer-facing description, at most `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty. Never shown to
|
|
1350
|
+
* the user as is.
|
|
1351
|
+
*/
|
|
1352
|
+
message: string;
|
|
1353
|
+
/**
|
|
1354
|
+
* Whole seconds to wait, with `rate-limited`, when the Coordinator said.
|
|
1355
|
+
*/
|
|
1356
|
+
retryAfterSeconds?: number;
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* hub frame → app: whether the hub is busy. Sent when the state changes. No reply.
|
|
1360
|
+
*/
|
|
1361
|
+
type HubActivityMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.activity, HubActivityPayload>;
|
|
1362
|
+
/**
|
|
1363
|
+
* app → hub frame, request: show the account menu at this anchor. Answered by `menu-accepted` or `menu-refused` with
|
|
1364
|
+
* the same `id`; the app bounds a missing answer with its normal request timeout. It is not a `HubRequestType`, so no
|
|
1365
|
+
* `result` or `error` answers it. It authorizes no signing.
|
|
1366
|
+
*/
|
|
1367
|
+
type AppShowMenuMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.showMenu, AppShowMenuPayload>;
|
|
1368
|
+
/**
|
|
1369
|
+
* hub frame → app: the hub accepted `show-menu` and will show the menu. Its `id` is the `show-menu` request's. It is
|
|
1370
|
+
* not a ceremony result, and does not prove the browser showed the menu.
|
|
1371
|
+
*/
|
|
1372
|
+
type HubMenuAcceptedMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.menuAccepted, EmptyPayload>;
|
|
1373
|
+
/**
|
|
1374
|
+
* hub frame → app: the hub refused `show-menu`. Its `id` is the `show-menu` request's.
|
|
1375
|
+
*/
|
|
1376
|
+
type HubMenuRefusedMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.menuRefused, MenuRefusalPayload>;
|
|
1377
|
+
/**
|
|
1378
|
+
* Every message the app sends its hub frame: every `AppMessage`, and `show-menu`. `AppMessage` stays as it is.
|
|
1379
|
+
*/
|
|
1380
|
+
/** Exact session labels projected from the existing hub session machine. */
|
|
1381
|
+
type HubDiagnosticsSession = "checking" | "signedOut" | "provisioning" | "signedIn" | "keypairExpired" | "sessionLocked" | "appSuspended" | "walletClosed" | "unavailable" | "signingOut";
|
|
1382
|
+
/** Allowlisted observations only, with no controller context or account data. */
|
|
1383
|
+
interface HubDiagnosticsObservation {
|
|
1384
|
+
phase: "connected" | "reporting";
|
|
1385
|
+
hubStatus: HubStatus;
|
|
1386
|
+
session: HubDiagnosticsSession | null;
|
|
1387
|
+
storage: "unpartitioned" | "partitioned";
|
|
1388
|
+
source: "provider-frame";
|
|
1389
|
+
}
|
|
1390
|
+
/** Ordered status for one authenticated frame subscription. */
|
|
1391
|
+
type HubDiagnosticsStatusPayload = {
|
|
1392
|
+
subscriptionId: string;
|
|
1393
|
+
sequence: number;
|
|
1394
|
+
observedAt: number;
|
|
1395
|
+
} & ({
|
|
1396
|
+
state: "disabled";
|
|
1397
|
+
} | ({
|
|
1398
|
+
state: "ready";
|
|
1399
|
+
} & HubDiagnosticsObservation));
|
|
1400
|
+
/** Subscribe only after the ordinary frame init was accepted. The envelope id is the subscription id. */
|
|
1401
|
+
type AppDiagnosticsSubscribeMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsSubscribe, EmptyPayload>;
|
|
1402
|
+
/** Retire exactly the named subscription without affecting ceremonies. */
|
|
1403
|
+
type AppDiagnosticsUnsubscribeMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsUnsubscribe, {
|
|
1404
|
+
subscriptionId: string;
|
|
1405
|
+
}>;
|
|
1406
|
+
/** Dedicated frame status, never an init, ceremony or popup answer. */
|
|
1407
|
+
type HubDiagnosticsStatusMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsStatus, HubDiagnosticsStatusPayload>;
|
|
1408
|
+
/** Cached entity status, without raw values or errors. */
|
|
1409
|
+
type HubDiagnosticsEntityStatus = "idle" | "loading" | "ready" | "stale" | "error";
|
|
1410
|
+
/** Only public held-key facts, including a stale key still held in memory. */
|
|
1411
|
+
interface HubDiagnosticsHeldKey {
|
|
1412
|
+
status: HubDiagnosticsEntityStatus;
|
|
1413
|
+
publicKeyHex: string | null;
|
|
1414
|
+
registeredExpiresAt: string | null;
|
|
1415
|
+
}
|
|
1416
|
+
/** The last cached session read, never cookie authority or a new request. */
|
|
1417
|
+
interface HubDiagnosticsSessionRead {
|
|
1418
|
+
status: HubDiagnosticsEntityStatus;
|
|
1419
|
+
credentialExpiresAt: string | null;
|
|
1420
|
+
}
|
|
1421
|
+
/** Confirmation data for one hub-issued target. Identity remains hub-side. */
|
|
1422
|
+
interface HubDiagnosticsDisconnect {
|
|
1423
|
+
targetId: string;
|
|
1424
|
+
appName: string;
|
|
1425
|
+
evmAddress: string;
|
|
1426
|
+
}
|
|
1427
|
+
/** Unauthorized, reporting and partitioned recipients get no private observations. */
|
|
1428
|
+
type HubDiagnosticsDetailsObservation = {
|
|
1429
|
+
state: "withheld";
|
|
1430
|
+
} | {
|
|
1431
|
+
state: "available";
|
|
1432
|
+
provenance: "driver-memory";
|
|
1433
|
+
controllerProvenance: "controller-observation";
|
|
1434
|
+
heldKey: HubDiagnosticsHeldKey;
|
|
1435
|
+
sessionRead: HubDiagnosticsSessionRead;
|
|
1436
|
+
effectiveExpiresAt: string | null;
|
|
1437
|
+
rememberedEmailPresent: boolean;
|
|
1438
|
+
appAuthorized: true;
|
|
1439
|
+
busy: boolean;
|
|
1440
|
+
persistedKey: "not-inspected";
|
|
1441
|
+
cookieAuthority: "not-directly-observable";
|
|
1442
|
+
token: "not-inspected";
|
|
1443
|
+
disconnect: HubDiagnosticsDisconnect | null;
|
|
1444
|
+
};
|
|
1445
|
+
/** A separate ordered stream on the existing diagnostics subscription. */
|
|
1446
|
+
type HubDiagnosticsDetailsPayload = {
|
|
1447
|
+
subscriptionId: string;
|
|
1448
|
+
sequence: number;
|
|
1449
|
+
observedAt: number;
|
|
1450
|
+
schemaVersion: 1;
|
|
1451
|
+
} & HubDiagnosticsDetailsObservation;
|
|
1452
|
+
/** Opt in once after base diagnostics is ready. Old peers may ignore this control. */
|
|
1453
|
+
type AppDiagnosticsInspectMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsInspect, {
|
|
1454
|
+
subscriptionId: string;
|
|
1455
|
+
}>;
|
|
1456
|
+
/** Targeted existing disconnect, frame-only. Its answer still names request disconnect. */
|
|
1457
|
+
type AppDiagnosticsDisconnectMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsDisconnect, {
|
|
1458
|
+
subscriptionId: string;
|
|
1459
|
+
targetId: string;
|
|
1460
|
+
}>;
|
|
1461
|
+
type HubDiagnosticsDetailsMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.diagnosticsDetails, HubDiagnosticsDetailsPayload>;
|
|
1462
|
+
/**
|
|
1463
|
+
* app → hub frame on D: the app overlay owner has actually hidden the frame after its held overlay-close.
|
|
1464
|
+
* The envelope id echoes that close notice. The hub retains the close-id → initiating-operation mapping through
|
|
1465
|
+
* result settlement; the app need not know the element's ceremony id. No payload or reply.
|
|
1466
|
+
*/
|
|
1467
|
+
type AppOverlayHiddenMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.overlayHidden, EmptyPayload>;
|
|
1468
|
+
/**
|
|
1469
|
+
* hub frame → initiating element on C: the app acknowledged hiding this operation's overlay. The envelope id is
|
|
1470
|
+
* the original namespaced ceremony request id, resolved from the close receipt and current attachment. Deliver
|
|
1471
|
+
* once only to that attachment, even if its result already settled. Never infer completion from busy/state alone.
|
|
1472
|
+
*/
|
|
1473
|
+
type HubElementOverlayHiddenMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.overlayHidden, EmptyPayload>;
|
|
1474
|
+
type AppHubFrameMessage = AppMessage | AppShowMenuMessage | AppDiagnosticsSubscribeMessage | AppDiagnosticsUnsubscribeMessage | AppDiagnosticsInspectMessage | AppDiagnosticsDisconnectMessage | AppOverlayHiddenMessage;
|
|
1475
|
+
/**
|
|
1476
|
+
* Every message the hub frame sends the app: every `HubMessage`, `activity` and the two `show-menu` answers.
|
|
1477
|
+
* `HubMessage` stays as it is.
|
|
1478
|
+
*/
|
|
1479
|
+
/** Only Escape with an actually posted close may grant restoration. */
|
|
1480
|
+
type HubMenuEndedMessage = PayEnvelope<typeof PAY_HUB_FRAME_MESSAGE_TYPES.menuEnded, {
|
|
1481
|
+
restoreFocus: false;
|
|
1482
|
+
} | {
|
|
1483
|
+
restoreFocus: true;
|
|
1484
|
+
closeId: string;
|
|
1485
|
+
}>;
|
|
1486
|
+
type HubFrameAppMessage = HubDiagnosticsStatusMessage | HubDiagnosticsDetailsMessage | HubMessage | HubActivityMessage | HubMenuAcceptedMessage | HubMenuRefusedMessage | HubMenuEndedMessage;
|
|
1487
|
+
/**
|
|
1488
|
+
* The payload of `relay-init`.
|
|
1489
|
+
*/
|
|
1490
|
+
interface RelayInitPayload {
|
|
1491
|
+
/**
|
|
1492
|
+
* The app's id (`app_` and a 26-character ULID). The Pay window binds it to the app id it serves.
|
|
1493
|
+
*/
|
|
1494
|
+
appId: string;
|
|
1495
|
+
/**
|
|
1496
|
+
* The app page's origin, exactly as `URL.origin` spells it: `http:` or `https:`, with no path, trailing slash,
|
|
1497
|
+
* credentials, query or fragment, and at most `MAX_APP_ORIGIN_LENGTH` characters. The Pay window checks it against
|
|
1498
|
+
* the app's registry before it signs for it; its shape authorizes nothing.
|
|
1499
|
+
*/
|
|
1500
|
+
appOrigin: string;
|
|
1501
|
+
/**
|
|
1502
|
+
* How the Pay window should look.
|
|
1503
|
+
*/
|
|
1504
|
+
appearance: HubAppearance;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* The `result` payload of a ceremony request: every `HubResult` except the one for `init`.
|
|
1508
|
+
*/
|
|
1509
|
+
type CeremonyResult = Exclude<HubResult, InitResult>;
|
|
1510
|
+
/**
|
|
1511
|
+
* The `error` payload of a ceremony request: a `HubError` whose `request` is not `init`.
|
|
1512
|
+
*/
|
|
1513
|
+
interface CeremonyError extends HubError {
|
|
1514
|
+
/**
|
|
1515
|
+
* The request this answers.
|
|
1516
|
+
*/
|
|
1517
|
+
request: CeremonyRequestType;
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Pay element → Pay window, request: the handshake, sent once after the Pay window's `ready`. Answered by
|
|
1521
|
+
* `relay-accepted` or `relay-refused` with the same `id`.
|
|
1522
|
+
*/
|
|
1523
|
+
type ElementRelayInitMessage = PayEnvelope<typeof SUA_RELAY_MESSAGE_TYPES.init, RelayInitPayload>;
|
|
1524
|
+
/**
|
|
1525
|
+
* Pay window → Pay element: the Pay window accepted the handshake. Its `id` is the `relay-init` request's.
|
|
1526
|
+
*/
|
|
1527
|
+
type WindowRelayAcceptedMessage = PayEnvelope<typeof SUA_RELAY_MESSAGE_TYPES.accepted, EmptyPayload>;
|
|
1528
|
+
/**
|
|
1529
|
+
* The payload of `relay-build`: the Pay window's own hub build id, in the format link C's `attach-accepted` carries.
|
|
1530
|
+
*/
|
|
1531
|
+
interface WindowRelayBuildPayload {
|
|
1532
|
+
/**
|
|
1533
|
+
* 1 to `MAX_HUB_BUILD_ID_LENGTH` characters matching `HUB_BUILD_ID_PATTERN`.
|
|
1534
|
+
*/
|
|
1535
|
+
buildId: string;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Pay window → Pay element: the Pay window's build id, posted immediately before `relay-accepted` with the same `id`,
|
|
1539
|
+
* the `relay-init` request's. A Pay element releases a sign's attempt on the Pay window's answer only when this build
|
|
1540
|
+
* matches its own; a Pay window that sends none, or a different one, gets every failed sign spent.
|
|
1541
|
+
*/
|
|
1542
|
+
type WindowRelayBuildMessage = PayEnvelope<typeof SUA_RELAY_MESSAGE_TYPES.build, WindowRelayBuildPayload>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Pay window → Pay element: the Pay window refused the handshake. Its `id` is the `relay-init` request's.
|
|
1545
|
+
*/
|
|
1546
|
+
type WindowRelayRefusedMessage = PayEnvelope<typeof SUA_RELAY_MESSAGE_TYPES.refused, RefusalPayload>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Pay window → Pay element: a ceremony request succeeded. Its `id` is the request's.
|
|
1549
|
+
*/
|
|
1550
|
+
type WindowResultMessage = PayEnvelope<"result", CeremonyResult>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Pay window → Pay element: a ceremony request failed. Its `id` is the request's.
|
|
1553
|
+
*/
|
|
1554
|
+
type WindowErrorMessage = PayEnvelope<"error", CeremonyError>;
|
|
1555
|
+
/** The selected linked-wallet id stays on the hub origin; null resumes the chooser. */
|
|
1556
|
+
interface FundWindowContinuationPayload {
|
|
1557
|
+
relayId: string;
|
|
1558
|
+
requestId: string;
|
|
1559
|
+
walletId: string | null;
|
|
1560
|
+
}
|
|
1561
|
+
/** A Fund continuation is never accepted on the consumer app channel. */
|
|
1562
|
+
type FundWindowContinuationMessage = PayEnvelope<typeof SUA_FUND_WINDOW_MESSAGE_TYPE, FundWindowContinuationPayload>;
|
|
1563
|
+
/**
|
|
1564
|
+
* Every message a Pay element sends the Pay window it opened: `relay-init`, then the existing `appearance` and
|
|
1565
|
+
* ceremony requests, and the graceful `relay-close`. The ordinary `init` is not one of them.
|
|
1566
|
+
*/
|
|
1567
|
+
type ElementWindowMessage = HubPayRequestMessage | PayEnvelope<typeof SUA_GUEST_HANDOFF_MESSAGE_TYPE, {
|
|
1568
|
+
handoff: string;
|
|
1569
|
+
}> | FundWindowContinuationMessage | ElementRelayInitMessage | AppAppearanceMessage | AppSignInMessage | AppSignMessage | AppSignOutMessage | AppDisconnectMessage | AppFundMessage | ElementRelayCloseMessage | ElementRelayPageUrlMessage | ElementRelayPayShownMessage;
|
|
1570
|
+
/**
|
|
1571
|
+
* Every message the Pay window sends the Pay element that opened it: `relay-build`, the two `relay-init` answers, the existing
|
|
1572
|
+
* notices, a `result` or `error` for a ceremony request, the `relay-close-accepted` answer and the ordered
|
|
1573
|
+
* `relay-state`. No answer to `init`. The Pay element ignores the overlay notices on this path.
|
|
1574
|
+
*/
|
|
1575
|
+
type WindowElementMessage = WindowRelayCheckoutResultMessage | WindowRelayCheckoutWalletMessage | WindowRelayBuildMessage | WindowRelayAcceptedMessage | WindowRelayRefusedMessage | HubReadyMessage | HubTransportMessage | HubStateMessage | HubOverlayOpenMessage | HubOverlayCloseMessage | WindowResultMessage | WindowErrorMessage | WindowRelayCloseAcceptedMessage | WindowRelayStateMessage | WindowRelayPayOwnerMessage | WindowRelayPayProgressMessage | WindowRelayPayUnsentMessage | WindowRelayPaySourceMessage | WindowRelayPaySourceSavedMessage | HubElementCheckoutHeldMessage;
|
|
1576
|
+
/**
|
|
1577
|
+
* Why a Pay window that a Pay element opened ended: `settled`, `window-cancel`, `window-lost` or `teardown`.
|
|
1578
|
+
*/
|
|
1579
|
+
type SuaWindowEndCause = (typeof SUA_WINDOW_END_CAUSES)[keyof typeof SUA_WINDOW_END_CAUSES];
|
|
1580
|
+
/**
|
|
1581
|
+
* Why the hub frame asks a Pay element to close the Pay window it owns: `window-cancel` or `teardown`.
|
|
1582
|
+
*/
|
|
1583
|
+
type SuaWindowCancelCause = (typeof SUA_WINDOW_CANCEL_CAUSES)[keyof typeof SUA_WINDOW_CANCEL_CAUSES];
|
|
1584
|
+
/**
|
|
1585
|
+
* The balance a hub frame shows its Pay elements, structurally the app face's `SuaBalance`. Only the ready branch
|
|
1586
|
+
* carries an amount: canonical dollars with exactly six decimals (`0.000000` is zero, `0.000001` one base unit), at
|
|
1587
|
+
* most `MAX_HUB_BALANCE_AMOUNT_LENGTH` characters and at most `2^256 - 1` base units. The hub frame always sends
|
|
1588
|
+
* `currency: "USD"`; an omitted currency is accepted to keep the `SuaBalance` shape.
|
|
1589
|
+
*/
|
|
1590
|
+
type HubElementBalance = {
|
|
1591
|
+
status: "loading";
|
|
1592
|
+
} | {
|
|
1593
|
+
status: "unavailable";
|
|
1594
|
+
} | {
|
|
1595
|
+
status: "ready";
|
|
1596
|
+
amount: string;
|
|
1597
|
+
currency?: "USD";
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* The payload of `hub-probe`.
|
|
1601
|
+
*/
|
|
1602
|
+
type ElementHubProbePayload = EmptyPayload;
|
|
1603
|
+
/**
|
|
1604
|
+
* Pay element → hub frame, discovery: is this indexed frame the hub? The envelope `id` is a fresh challenge per probed
|
|
1605
|
+
* frame and discovery generation. Answered by `hub-probe-ack` with the same `id`. It claims no app origin and
|
|
1606
|
+
* authorizes nothing.
|
|
1607
|
+
*/
|
|
1608
|
+
type ElementHubProbeMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.probe, ElementHubProbePayload>;
|
|
1609
|
+
/**
|
|
1610
|
+
* hub frame → Pay element: the answer to `hub-probe`. Its `id` is the probe's challenge. It carries no state and
|
|
1611
|
+
* allocates no attachment.
|
|
1612
|
+
*/
|
|
1613
|
+
type HubElementProbeAckMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.probeAck, EmptyPayload>;
|
|
1614
|
+
/**
|
|
1615
|
+
* The payload of `attach`.
|
|
1616
|
+
*/
|
|
1617
|
+
type ElementAttachPayload = EmptyPayload;
|
|
1618
|
+
/**
|
|
1619
|
+
* Pay element → hub frame, request: attach to the hub frame selected by discovery. Answered by `attach-accepted` or
|
|
1620
|
+
* `attach-refused` with the same `id`. A repeat with the same `id` gets the same answer; a fresh `id` resets
|
|
1621
|
+
* the link.
|
|
1622
|
+
*/
|
|
1623
|
+
type ElementAttachMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.attach, ElementAttachPayload>;
|
|
1624
|
+
/**
|
|
1625
|
+
* The payload of `attach-accepted` and of `attach-confirm`.
|
|
1626
|
+
*/
|
|
1627
|
+
interface HubAttachAcceptedPayload {
|
|
1628
|
+
/**
|
|
1629
|
+
* The attachment's id: a lowercase canonical version-4 UUID the hub frame issues for one attachment. It correlates
|
|
1630
|
+
* and namespaces the link; it is never authority.
|
|
1631
|
+
*/
|
|
1632
|
+
attachmentId: string;
|
|
1633
|
+
/**
|
|
1634
|
+
* The hub frame's build id: 1 to `MAX_HUB_BUILD_ID_LENGTH` ASCII letters, digits, `_` or `-`, starting with a
|
|
1635
|
+
* letter or digit.
|
|
1636
|
+
*/
|
|
1637
|
+
buildId: string;
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* hub frame → Pay element: the hub frame accepted `attach`, provisionally. Its `id` is the `attach` request's. No
|
|
1641
|
+
* state flows and no ceremony is enabled until a matching `attach-confirm`.
|
|
1642
|
+
*/
|
|
1643
|
+
type HubAttachAcceptedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.accepted, HubAttachAcceptedPayload>;
|
|
1644
|
+
/**
|
|
1645
|
+
* hub frame → Pay element: the hub frame refused `attach`. Its `id` is the `attach` request's.
|
|
1646
|
+
*/
|
|
1647
|
+
type HubAttachRefusedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.refused, RefusalPayload>;
|
|
1648
|
+
/**
|
|
1649
|
+
* The payload of `attach-confirm`: the attachment it confirms and the Pay element's own build id, which must equal the
|
|
1650
|
+
* hub frame's.
|
|
1651
|
+
*/
|
|
1652
|
+
type ElementAttachConfirmPayload = HubAttachAcceptedPayload;
|
|
1653
|
+
/**
|
|
1654
|
+
* Pay element → hub frame: the Pay element compared its build id with the accepted one and confirms the attachment.
|
|
1655
|
+
* No reply; on a match the hub frame sends `transport`, `state`, `activity`, then `balance`.
|
|
1656
|
+
*/
|
|
1657
|
+
type ElementAttachConfirmMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.confirm, ElementAttachConfirmPayload>;
|
|
1658
|
+
/**
|
|
1659
|
+
* The payload of `detach`.
|
|
1660
|
+
*/
|
|
1661
|
+
interface ElementDetachPayload {
|
|
1662
|
+
/**
|
|
1663
|
+
* The attachment the Pay element leaves.
|
|
1664
|
+
*/
|
|
1665
|
+
attachmentId: string;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Pay element → hub frame: the Pay element leaves its attachment. No reply. Idempotent, and only a cooperative
|
|
1669
|
+
* shortcut: the hub frame also detects a lost Pay element on its own.
|
|
1670
|
+
*/
|
|
1671
|
+
type ElementDetachMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.detach, ElementDetachPayload>;
|
|
1672
|
+
/**
|
|
1673
|
+
* The payload of `balance`.
|
|
1674
|
+
*/
|
|
1675
|
+
interface HubElementBalancePayload {
|
|
1676
|
+
/**
|
|
1677
|
+
* The balance to show.
|
|
1678
|
+
*/
|
|
1679
|
+
balance: HubElementBalance;
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* hub frame → Pay element: the balance changed. No reply. Ordered by its own stream within the attachment.
|
|
1683
|
+
*/
|
|
1684
|
+
type HubElementBalanceMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.balance, HubElementBalancePayload>;
|
|
1685
|
+
/**
|
|
1686
|
+
* The payload of `window-opened`.
|
|
1687
|
+
*/
|
|
1688
|
+
interface ElementWindowOpenedPayload {
|
|
1689
|
+
/**
|
|
1690
|
+
* The id the Pay element gave the window before it opened it.
|
|
1691
|
+
*/
|
|
1692
|
+
windowId: string;
|
|
1693
|
+
/**
|
|
1694
|
+
* The envelope id of the ceremony request the Pay element will send the window over link E.
|
|
1695
|
+
*/
|
|
1696
|
+
requestId: string;
|
|
1697
|
+
/**
|
|
1698
|
+
* That ceremony request.
|
|
1699
|
+
*/
|
|
1700
|
+
request: CeremonyRequestType;
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Pay element → hub frame, request: the Pay element opened a Pay window for a ceremony and asks to own it. Answered by
|
|
1704
|
+
* `window-accepted` or `window-refused` with the same `id`.
|
|
1705
|
+
*/
|
|
1706
|
+
type ElementWindowOpenedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowOpened, ElementWindowOpenedPayload>;
|
|
1707
|
+
/**
|
|
1708
|
+
* The payload of `window-accepted`.
|
|
1709
|
+
*/
|
|
1710
|
+
interface HubElementWindowAcceptedPayload {
|
|
1711
|
+
/**
|
|
1712
|
+
* The window it accepts.
|
|
1713
|
+
*/
|
|
1714
|
+
windowId: string;
|
|
1715
|
+
/**
|
|
1716
|
+
* The operation id the hub frame issued for the window's ceremony.
|
|
1717
|
+
*/
|
|
1718
|
+
operationId: string;
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* hub frame → Pay element: the hub frame reserved the ceremony for this window. Its `id` is the `window-opened`
|
|
1722
|
+
* request's.
|
|
1723
|
+
*/
|
|
1724
|
+
type HubElementWindowAcceptedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowAccepted, HubElementWindowAcceptedPayload>;
|
|
1725
|
+
/**
|
|
1726
|
+
* The payload of `window-refused`.
|
|
1727
|
+
*/
|
|
1728
|
+
interface HubElementWindowRefusedPayload {
|
|
1729
|
+
/**
|
|
1730
|
+
* The window it refuses.
|
|
1731
|
+
*/
|
|
1732
|
+
windowId: string;
|
|
1733
|
+
/**
|
|
1734
|
+
* Why the hub frame refused.
|
|
1735
|
+
*/
|
|
1736
|
+
code: HubErrorCode;
|
|
1737
|
+
/**
|
|
1738
|
+
* A developer-facing description, at most `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty. Never shown to
|
|
1739
|
+
* the user as is.
|
|
1740
|
+
*/
|
|
1741
|
+
message: string;
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* hub frame → Pay element: the hub frame refused the window. Its `id` is the `window-opened` request's.
|
|
1745
|
+
*/
|
|
1746
|
+
type HubElementWindowRefusedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowRefused, HubElementWindowRefusedPayload>;
|
|
1747
|
+
/**
|
|
1748
|
+
* The payload of `window-result`.
|
|
1749
|
+
*/
|
|
1750
|
+
interface ElementWindowResultPayload {
|
|
1751
|
+
/**
|
|
1752
|
+
* The operation id from `window-accepted`.
|
|
1753
|
+
*/
|
|
1754
|
+
operationId: string;
|
|
1755
|
+
/**
|
|
1756
|
+
* The window's id.
|
|
1757
|
+
*/
|
|
1758
|
+
windowId: string;
|
|
1759
|
+
/**
|
|
1760
|
+
* The envelope id of the window's ceremony request.
|
|
1761
|
+
*/
|
|
1762
|
+
requestId: string;
|
|
1763
|
+
/**
|
|
1764
|
+
* The window's result, as the Pay element received and matched it over link E.
|
|
1765
|
+
*/
|
|
1766
|
+
result: CeremonyResult;
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Pay element → hub frame: the owned window answered its ceremony with a result. No reply. A report of the
|
|
1770
|
+
* operation's outcome, never a request to run anything; the window may stay open after it.
|
|
1771
|
+
*/
|
|
1772
|
+
type ElementWindowResultMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowResult, ElementWindowResultPayload>;
|
|
1773
|
+
/**
|
|
1774
|
+
* The payload of `window-error`.
|
|
1775
|
+
*/
|
|
1776
|
+
interface ElementWindowErrorPayload {
|
|
1777
|
+
/**
|
|
1778
|
+
* The operation id from `window-accepted`.
|
|
1779
|
+
*/
|
|
1780
|
+
operationId: string;
|
|
1781
|
+
/**
|
|
1782
|
+
* The window's id.
|
|
1783
|
+
*/
|
|
1784
|
+
windowId: string;
|
|
1785
|
+
/**
|
|
1786
|
+
* The envelope id of the window's ceremony request.
|
|
1787
|
+
*/
|
|
1788
|
+
requestId: string;
|
|
1789
|
+
/**
|
|
1790
|
+
* The window's error, as the Pay element received and matched it over link E.
|
|
1791
|
+
*/
|
|
1792
|
+
error: CeremonyError;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Pay element → hub frame: the owned window answered its ceremony with an error. No reply.
|
|
1796
|
+
*/
|
|
1797
|
+
type ElementWindowErrorMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowError, ElementWindowErrorPayload>;
|
|
1798
|
+
/**
|
|
1799
|
+
* The payload of `window-ended`.
|
|
1800
|
+
*/
|
|
1801
|
+
interface ElementWindowEndedPayload {
|
|
1802
|
+
/**
|
|
1803
|
+
* The operation id from `window-accepted`, or `null` for a window that ended before the Pay element received its
|
|
1804
|
+
* acceptance. `null` names only this window, never "whichever operation is current".
|
|
1805
|
+
*/
|
|
1806
|
+
operationId: string | null;
|
|
1807
|
+
/**
|
|
1808
|
+
* The window's id.
|
|
1809
|
+
*/
|
|
1810
|
+
windowId: string;
|
|
1811
|
+
/**
|
|
1812
|
+
* Why it ended.
|
|
1813
|
+
*/
|
|
1814
|
+
cause: SuaWindowEndCause;
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Pay element → hub frame: the owned window actually ended. No reply. Only this releases the hub frame's reservation.
|
|
1818
|
+
*/
|
|
1819
|
+
type ElementWindowEndedMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowEnded, ElementWindowEndedPayload>;
|
|
1820
|
+
/**
|
|
1821
|
+
* The payload of `window-cancel`.
|
|
1822
|
+
*/
|
|
1823
|
+
interface HubElementWindowCancelPayload {
|
|
1824
|
+
/**
|
|
1825
|
+
* The operation to cancel.
|
|
1826
|
+
*/
|
|
1827
|
+
operationId: string;
|
|
1828
|
+
/**
|
|
1829
|
+
* The window that runs it.
|
|
1830
|
+
*/
|
|
1831
|
+
windowId: string;
|
|
1832
|
+
/**
|
|
1833
|
+
* Why.
|
|
1834
|
+
*/
|
|
1835
|
+
cause: SuaWindowCancelCause;
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* hub frame → Pay element: close the owned window gracefully. No reply; the Pay element sends link E's `relay-close`,
|
|
1839
|
+
* and the reservation stays until `window-ended`.
|
|
1840
|
+
*/
|
|
1841
|
+
type HubElementWindowCancelMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowCancel, HubElementWindowCancelPayload>;
|
|
1842
|
+
/**
|
|
1843
|
+
* The payload of `window-state`.
|
|
1844
|
+
*/
|
|
1845
|
+
interface ElementWindowStatePayload {
|
|
1846
|
+
/**
|
|
1847
|
+
* The operation id from `window-accepted`.
|
|
1848
|
+
*/
|
|
1849
|
+
operationId: string;
|
|
1850
|
+
/**
|
|
1851
|
+
* The window's id.
|
|
1852
|
+
*/
|
|
1853
|
+
windowId: string;
|
|
1854
|
+
/**
|
|
1855
|
+
* The envelope id of the window's ceremony request.
|
|
1856
|
+
*/
|
|
1857
|
+
requestId: string;
|
|
1858
|
+
/**
|
|
1859
|
+
* The window's relay id, as its `relay-state` carried it.
|
|
1860
|
+
*/
|
|
1861
|
+
relayId: string;
|
|
1862
|
+
/**
|
|
1863
|
+
* The window's state sequence, as its `relay-state` carried it: a safe integer from 1.
|
|
1864
|
+
*/
|
|
1865
|
+
sequence: number;
|
|
1866
|
+
/**
|
|
1867
|
+
* The window's state, as its `relay-state` carried it. An included `keypairExpiresAt` is at most
|
|
1868
|
+
* `MAX_RELAY_STATE_EXPIRY_LENGTH` characters.
|
|
1869
|
+
*/
|
|
1870
|
+
state: HubStateSnapshot;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Pay element → hub frame: the owned window's ordered state, forwarded unchanged under the Pay element's window
|
|
1874
|
+
* operation. No reply. Display input for the hub frame's connected copy only.
|
|
1875
|
+
*/
|
|
1876
|
+
type ElementWindowStateMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.windowState, ElementWindowStatePayload>;
|
|
1877
|
+
/**
|
|
1878
|
+
* The payload of link C `page-url`.
|
|
1879
|
+
*/
|
|
1880
|
+
interface ElementPageUrlPayload {
|
|
1881
|
+
/**
|
|
1882
|
+
* The app page's address the element holds, as `element-page-url` carried it; `null` when it holds none.
|
|
1883
|
+
*/
|
|
1884
|
+
url: string | null;
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Pay element → hub frame (link C): the address of the app page the element sits on. The element sends it when that
|
|
1888
|
+
* changes, so the hub frame has it before the next `pay`. The hub frame keeps it in memory only when its origin is the
|
|
1889
|
+
* attachment's app origin, gives it to the attachment's `pay`, and never stores or logs it. Its id is an operation id
|
|
1890
|
+
* of the attachment. A hub frame that predates it drops it. No reply.
|
|
1891
|
+
*/
|
|
1892
|
+
type ElementPageUrlMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.pageUrl, ElementPageUrlPayload>;
|
|
1893
|
+
/**
|
|
1894
|
+
* The payload of link C `pay-shown`.
|
|
1895
|
+
*/
|
|
1896
|
+
interface ElementPayShownPayload {
|
|
1897
|
+
/** The `paymentId` of the `pay` the element sends right after it. */
|
|
1898
|
+
paymentId: string;
|
|
1899
|
+
/**
|
|
1900
|
+
* The method the card's source row showed at the click, by the card fields `pay-source` names it with: the Stridge
|
|
1901
|
+
* Wallet, a wallet, or `null` for a row that named none.
|
|
1902
|
+
*/
|
|
1903
|
+
shown: HubElementPaySourceRemembered | null;
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Pay element → hub frame (link C): the method the card showed when the person pressed Pay, sent right before that
|
|
1907
|
+
* `pay`. The hub frame gives it to that `pay` alone, when the payment ids match, and the Pay window opens that method,
|
|
1908
|
+
* never one it decides from its own reads. A hub frame that predates it drops it and decides as before. No reply.
|
|
1909
|
+
*/
|
|
1910
|
+
type ElementPayShownMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.payShown, ElementPayShownPayload>;
|
|
1911
|
+
/**
|
|
1912
|
+
* Every message a Pay element sends its hub frame (link C): the link C types and the six ceremony requests, payloads
|
|
1913
|
+
* unchanged. No `init`, `appearance`, `result` or `error`.
|
|
1914
|
+
*/
|
|
1915
|
+
type ElementHubMessage = HubPayRequestMessage | ElementHubProbeMessage | ElementAttachMessage | ElementAttachConfirmMessage | ElementDetachMessage | ElementWindowOpenedMessage | ElementWindowResultMessage | ElementWindowErrorMessage | ElementWindowEndedMessage | ElementWindowStateMessage | ElementPageUrlMessage | ElementPayShownMessage | AppSignInMessage | AppSignMessage | AppSignOutMessage | AppDisconnectMessage | AppFundMessage | ElementMenuPaymentMessage;
|
|
1916
|
+
/**
|
|
1917
|
+
* Every message a hub frame sends a Pay element (link C): the link C types, the existing `state`, `transport` and
|
|
1918
|
+
* `activity`, a `result` or `error` for a ceremony request, and correlated `overlay-hidden`. No `ready`,
|
|
1919
|
+
* `overlay-open`, `overlay-close` or answer to `init`.
|
|
1920
|
+
*/
|
|
1921
|
+
type HubElementMessage = HubElementCheckoutResultMessage | HubElementCheckoutWalletMessage | HubElementCheckoutHeldMessage | HubElementPaySourceMessage | HubElementPaySourceSavedMessage | HubElementPaySourceFundsMessage | HubElementPaySourceCurrentMessage | HubElementPayOwnerMessage | HubElementPayProgressMessage | HubElementPayUnsentMessage | HubElementOverlayHiddenMessage | HubElementProbeAckMessage | HubAttachAcceptedMessage | HubAttachRefusedMessage | HubElementBalanceMessage | HubElementWindowAcceptedMessage | HubElementWindowRefusedMessage | HubElementWindowCancelMessage | HubStateMessage | HubTransportMessage | HubActivityMessage | WindowResultMessage | WindowErrorMessage;
|
|
1922
|
+
/**
|
|
1923
|
+
* Why a Pay element closes its Pay window gracefully: the hub frame's cancel cause.
|
|
1924
|
+
*/
|
|
1925
|
+
type RelayCloseCause = SuaWindowCancelCause;
|
|
1926
|
+
/**
|
|
1927
|
+
* The payload of `relay-close`, and of its answer `relay-close-accepted`.
|
|
1928
|
+
*/
|
|
1929
|
+
interface ElementRelayClosePayload {
|
|
1930
|
+
/**
|
|
1931
|
+
* The envelope id of the first `relay-init` the window accepted for this Pay element document.
|
|
1932
|
+
*/
|
|
1933
|
+
relayId: string;
|
|
1934
|
+
/**
|
|
1935
|
+
* The envelope id of the ceremony request to close.
|
|
1936
|
+
*/
|
|
1937
|
+
requestId: string;
|
|
1938
|
+
/**
|
|
1939
|
+
* That ceremony request.
|
|
1940
|
+
*/
|
|
1941
|
+
request: CeremonyRequestType;
|
|
1942
|
+
/**
|
|
1943
|
+
* Why.
|
|
1944
|
+
*/
|
|
1945
|
+
cause: RelayCloseCause;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Pay element → Pay window: run the window's idempotent Close for this operation. Answered by `relay-close-accepted`
|
|
1949
|
+
* with the same `id`, or not at all when the close is stale or invalid. It never force-closes: the window closes only
|
|
1950
|
+
* when its own rules allow it.
|
|
1951
|
+
*/
|
|
1952
|
+
type ElementRelayCloseMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.close, ElementRelayClosePayload>;
|
|
1953
|
+
/**
|
|
1954
|
+
* The payload of `relay-page-url`.
|
|
1955
|
+
*/
|
|
1956
|
+
interface ElementRelayPageUrlPayload {
|
|
1957
|
+
/**
|
|
1958
|
+
* The envelope id of the `relay-init` the window accepted for this Pay element document.
|
|
1959
|
+
*/
|
|
1960
|
+
relayId: string;
|
|
1961
|
+
/**
|
|
1962
|
+
* The app page's full address, as `element-page-url` carries it.
|
|
1963
|
+
*/
|
|
1964
|
+
url: string;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Pay element → Pay window: the address of the app page whose `pay` the element relays right after it. The window
|
|
1968
|
+
* keeps it in memory for that payment alone, only when its origin is the relay's app origin, and never stores or logs
|
|
1969
|
+
* it. A Pay window that predates it drops it. No reply.
|
|
1970
|
+
*/
|
|
1971
|
+
type ElementRelayPageUrlMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.pageUrl, ElementRelayPageUrlPayload>;
|
|
1972
|
+
/**
|
|
1973
|
+
* The payload of `relay-pay-shown`: link C's `pay-shown`, with the relay id.
|
|
1974
|
+
*/
|
|
1975
|
+
interface ElementRelayPayShownPayload extends ElementPayShownPayload {
|
|
1976
|
+
/**
|
|
1977
|
+
* The envelope id of the `relay-init` the window accepted for this Pay element document.
|
|
1978
|
+
*/
|
|
1979
|
+
relayId: string;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Pay element → Pay window: the method the card showed for the `pay` the element relays right after it (link C's
|
|
1983
|
+
* `pay-shown`). A Pay window that predates it drops it. No reply.
|
|
1984
|
+
*/
|
|
1985
|
+
type ElementRelayPayShownMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.payShown, ElementRelayPayShownPayload>;
|
|
1986
|
+
/**
|
|
1987
|
+
* The payload of `relay-close-accepted`: the `relay-close` payload, echoed.
|
|
1988
|
+
*/
|
|
1989
|
+
type WindowRelayCloseAcceptedPayload = ElementRelayClosePayload;
|
|
1990
|
+
/**
|
|
1991
|
+
* Pay window → Pay element: the window's Close ran, or had already run, for this operation. Its `id` is the
|
|
1992
|
+
* `relay-close` request's. It does not prove the window ended, the ceremony was cancelled or the outcome.
|
|
1993
|
+
*/
|
|
1994
|
+
type WindowRelayCloseAcceptedMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.closeAccepted, WindowRelayCloseAcceptedPayload>;
|
|
1995
|
+
/**
|
|
1996
|
+
* The payload of `relay-state`.
|
|
1997
|
+
*/
|
|
1998
|
+
interface WindowRelayStatePayload {
|
|
1999
|
+
/**
|
|
2000
|
+
* The envelope id of the first `relay-init` the window accepted for this Pay element document.
|
|
2001
|
+
*/
|
|
2002
|
+
relayId: string;
|
|
2003
|
+
/**
|
|
2004
|
+
* The envelope id of the window's current ceremony request.
|
|
2005
|
+
*/
|
|
2006
|
+
requestId: string;
|
|
2007
|
+
/**
|
|
2008
|
+
* The position in this operation's state stream: a safe integer from 1, increasing.
|
|
2009
|
+
*/
|
|
2010
|
+
sequence: number;
|
|
2011
|
+
/**
|
|
2012
|
+
* The window's state. An included `keypairExpiresAt` is at most `MAX_RELAY_STATE_EXPIRY_LENGTH` characters.
|
|
2013
|
+
*/
|
|
2014
|
+
state: HubStateSnapshot;
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Pay window → Pay element: the window's state for its current operation, ordered by `sequence`. No reply.
|
|
2018
|
+
*/
|
|
2019
|
+
type WindowRelayStateMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.state, WindowRelayStatePayload>;
|
|
2020
|
+
/**
|
|
2021
|
+
* The payload of `app-window-state`.
|
|
2022
|
+
*/
|
|
2023
|
+
interface AppWindowStatePayload {
|
|
2024
|
+
/**
|
|
2025
|
+
* The app id of the window's accepted app connection.
|
|
2026
|
+
*/
|
|
2027
|
+
appId: string;
|
|
2028
|
+
/**
|
|
2029
|
+
* The verified origin of the window's accepted app connection.
|
|
2030
|
+
*/
|
|
2031
|
+
appOrigin: string;
|
|
2032
|
+
/**
|
|
2033
|
+
* The position in the window document's state stream: a safe integer from 1, increasing.
|
|
2034
|
+
*/
|
|
2035
|
+
sequence: number;
|
|
2036
|
+
/**
|
|
2037
|
+
* The window's state. An included `keypairExpiresAt` is at most `MAX_RELAY_STATE_EXPIRY_LENGTH` characters.
|
|
2038
|
+
*/
|
|
2039
|
+
state: HubStateSnapshot;
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* App-owned Pay window → the app's hub frame: the window's state, ordered by `sequence`. No reply.
|
|
2043
|
+
*/
|
|
2044
|
+
type AppWindowStateMessage = PayEnvelope<typeof SUA_APP_WINDOW_MESSAGE_TYPES.state, AppWindowStatePayload>;
|
|
2045
|
+
/**
|
|
2046
|
+
* The account an account-email report names: the account the sending Pay window shows, bound to the identity that
|
|
2047
|
+
* signed in with the email. Exactly these keys.
|
|
2048
|
+
*/
|
|
2049
|
+
interface AccountEmailReportAccount {
|
|
2050
|
+
/**
|
|
2051
|
+
* The account's identity (`idn_…`): 1 to `MAX_ACCOUNT_IDENTITY_LENGTH` characters with no control or format
|
|
2052
|
+
* character.
|
|
2053
|
+
*/
|
|
2054
|
+
identityId: string;
|
|
2055
|
+
/**
|
|
2056
|
+
* The account's EVM address, as the public state the report refers to shows it.
|
|
2057
|
+
*/
|
|
2058
|
+
evmAddress: string;
|
|
2059
|
+
/**
|
|
2060
|
+
* The email bound to the identity: 1 to `MAX_ACCOUNT_EMAIL_LENGTH` characters with no control or format character,
|
|
2061
|
+
* or `null` when the window knows the account but not its email.
|
|
2062
|
+
*/
|
|
2063
|
+
email: string | null;
|
|
2064
|
+
/**
|
|
2065
|
+
* Epoch milliseconds after which the report must not be shown: a safe integer, at most
|
|
2066
|
+
* `MAX_ACCOUNT_EMAIL_LEASE_MS` after the sender's last authenticated session read, and never after the session's
|
|
2067
|
+
* known expiry.
|
|
2068
|
+
*/
|
|
2069
|
+
validUntil: number;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* The payload of `relay-account-email`.
|
|
2073
|
+
*/
|
|
2074
|
+
interface RelayAccountEmailPayload {
|
|
2075
|
+
/**
|
|
2076
|
+
* As for `relay-state`.
|
|
2077
|
+
*/
|
|
2078
|
+
relayId: string;
|
|
2079
|
+
/**
|
|
2080
|
+
* As for `relay-state`.
|
|
2081
|
+
*/
|
|
2082
|
+
requestId: string;
|
|
2083
|
+
/**
|
|
2084
|
+
* The position in this operation's account-email stream: a safe integer from 1, increasing. Its own count, apart
|
|
2085
|
+
* from the `relay-state` stream.
|
|
2086
|
+
*/
|
|
2087
|
+
sequence: number;
|
|
2088
|
+
/**
|
|
2089
|
+
* The `sequence` of the `relay-state` this report describes, on the same operation.
|
|
2090
|
+
*/
|
|
2091
|
+
stateSequence: number;
|
|
2092
|
+
/**
|
|
2093
|
+
* The account the window shows, or `null`: clear any email shown for this stream.
|
|
2094
|
+
*/
|
|
2095
|
+
account: AccountEmailReportAccount | null;
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* Pay window → the Pay element or hub frame that opened it: the account email for its current operation, ordered by
|
|
2099
|
+
* `sequence`. Private to Stridge-origin documents. No reply.
|
|
2100
|
+
*/
|
|
2101
|
+
type RelayAccountEmailMessage = PayEnvelope<typeof SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.relay, RelayAccountEmailPayload>;
|
|
2102
|
+
/**
|
|
2103
|
+
* The payload of `window-account-email`: a `relay-account-email`, unchanged, under the window operation's ids.
|
|
2104
|
+
*/
|
|
2105
|
+
interface WindowAccountEmailPayload {
|
|
2106
|
+
/**
|
|
2107
|
+
* As for `window-state`.
|
|
2108
|
+
*/
|
|
2109
|
+
operationId: string;
|
|
2110
|
+
/**
|
|
2111
|
+
* As for `window-state`.
|
|
2112
|
+
*/
|
|
2113
|
+
windowId: string;
|
|
2114
|
+
/**
|
|
2115
|
+
* As for `window-state`.
|
|
2116
|
+
*/
|
|
2117
|
+
requestId: string;
|
|
2118
|
+
/**
|
|
2119
|
+
* As for `window-state`.
|
|
2120
|
+
*/
|
|
2121
|
+
relayId: string;
|
|
2122
|
+
/**
|
|
2123
|
+
* As the window's `relay-account-email` carried it.
|
|
2124
|
+
*/
|
|
2125
|
+
sequence: number;
|
|
2126
|
+
/**
|
|
2127
|
+
* As the window's `relay-account-email` carried it: the `window-state` sequence this report describes.
|
|
2128
|
+
*/
|
|
2129
|
+
stateSequence: number;
|
|
2130
|
+
/**
|
|
2131
|
+
* As the window's `relay-account-email` carried it.
|
|
2132
|
+
*/
|
|
2133
|
+
account: AccountEmailReportAccount | null;
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Pay element → its hub frame attachment: the account email of the Pay window it owns, ordered by `sequence`. Private
|
|
2137
|
+
* to Stridge-origin documents. No reply.
|
|
2138
|
+
*/
|
|
2139
|
+
type WindowAccountEmailMessage = PayEnvelope<typeof SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.window, WindowAccountEmailPayload>;
|
|
2140
|
+
/**
|
|
2141
|
+
* The payload of `app-window-account-email`.
|
|
2142
|
+
*/
|
|
2143
|
+
interface AppWindowAccountEmailPayload {
|
|
2144
|
+
/**
|
|
2145
|
+
* As for `app-window-state`.
|
|
2146
|
+
*/
|
|
2147
|
+
appId: string;
|
|
2148
|
+
/**
|
|
2149
|
+
* As for `app-window-state`.
|
|
2150
|
+
*/
|
|
2151
|
+
appOrigin: string;
|
|
2152
|
+
/**
|
|
2153
|
+
* The position in the window document's account-email stream: a safe integer from 1, increasing.
|
|
2154
|
+
*/
|
|
2155
|
+
sequence: number;
|
|
2156
|
+
/**
|
|
2157
|
+
* The `sequence` of the `app-window-state` this report describes, from the same window document.
|
|
2158
|
+
*/
|
|
2159
|
+
stateSequence: number;
|
|
2160
|
+
/**
|
|
2161
|
+
* The account the window shows, or `null`: clear any email shown for this window.
|
|
2162
|
+
*/
|
|
2163
|
+
account: AccountEmailReportAccount | null;
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* App-owned Pay window → the app page's hub frames: the account email, ordered by `sequence`. Private to
|
|
2167
|
+
* Stridge-origin documents. No reply.
|
|
2168
|
+
*/
|
|
2169
|
+
type AppWindowAccountEmailMessage = PayEnvelope<typeof SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindow, AppWindowAccountEmailPayload>;
|
|
2170
|
+
/**
|
|
2171
|
+
* The payload of `app-window-account-email-refresh`.
|
|
2172
|
+
*/
|
|
2173
|
+
interface AppWindowAccountEmailRefreshPayload {
|
|
2174
|
+
/**
|
|
2175
|
+
* As for `app-window-state`.
|
|
2176
|
+
*/
|
|
2177
|
+
appId: string;
|
|
2178
|
+
/**
|
|
2179
|
+
* As for `app-window-state`.
|
|
2180
|
+
*/
|
|
2181
|
+
appOrigin: string;
|
|
2182
|
+
/**
|
|
2183
|
+
* A new id for this request: the reply names it, and the frame takes a reply only for its one open request.
|
|
2184
|
+
*/
|
|
2185
|
+
refreshId: string;
|
|
2186
|
+
/**
|
|
2187
|
+
* The `sequence` of the window's `app-window-state` the frame shows now.
|
|
2188
|
+
*/
|
|
2189
|
+
stateSequence: number;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Hub frame → the app-owned Pay window whose state it shows: read the session again now and reply. Private to
|
|
2193
|
+
* Stridge-origin documents.
|
|
2194
|
+
*/
|
|
2195
|
+
type AppWindowAccountEmailRefreshMessage = PayEnvelope<typeof SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindowRefresh, AppWindowAccountEmailRefreshPayload>;
|
|
2196
|
+
/**
|
|
2197
|
+
* The payload of `app-window-account-email-refresh-reply`.
|
|
2198
|
+
*/
|
|
2199
|
+
interface AppWindowAccountEmailRefreshReplyPayload {
|
|
2200
|
+
/**
|
|
2201
|
+
* As the request carried it.
|
|
2202
|
+
*/
|
|
2203
|
+
appId: string;
|
|
2204
|
+
/**
|
|
2205
|
+
* As the request carried it.
|
|
2206
|
+
*/
|
|
2207
|
+
appOrigin: string;
|
|
2208
|
+
/**
|
|
2209
|
+
* The request's `refreshId`.
|
|
2210
|
+
*/
|
|
2211
|
+
refreshId: string;
|
|
2212
|
+
/**
|
|
2213
|
+
* The `sequence` of the window's `app-window-state` the account describes: the request's, since the window replies
|
|
2214
|
+
* only while its state has not moved.
|
|
2215
|
+
*/
|
|
2216
|
+
stateSequence: number;
|
|
2217
|
+
/**
|
|
2218
|
+
* Epoch milliseconds when the window's session read answered: a safe integer from 1, never before the request.
|
|
2219
|
+
*/
|
|
2220
|
+
checkedAt: number;
|
|
2221
|
+
/**
|
|
2222
|
+
* The account the window shows after that read, its `validUntil` at most `MAX_ACCOUNT_EMAIL_LEASE_MS` after
|
|
2223
|
+
* `checkedAt` and never after the session's known expiry; or `null`: show no email.
|
|
2224
|
+
*/
|
|
2225
|
+
account: AccountEmailReportAccount | null;
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* App-owned Pay window → the hub frame that asked: the answer to `app-window-account-email-refresh`. Private to
|
|
2229
|
+
* Stridge-origin documents. No reply.
|
|
2230
|
+
*/
|
|
2231
|
+
type AppWindowAccountEmailRefreshReplyMessage = PayEnvelope<typeof SUA_ACCOUNT_EMAIL_MESSAGE_TYPES.appWindowRefreshReply, AppWindowAccountEmailRefreshReplyPayload>;
|
|
2232
|
+
/**
|
|
2233
|
+
* Why a Pay element asks the app for its one reload: `build-mismatch`.
|
|
2234
|
+
*/
|
|
2235
|
+
type SuaElementReloadReason = (typeof SUA_ELEMENT_RELOAD_REASONS)[keyof typeof SUA_ELEMENT_RELOAD_REASONS];
|
|
2236
|
+
/**
|
|
2237
|
+
* The payload of `element-action-check`.
|
|
2238
|
+
*/
|
|
2239
|
+
interface ElementActionCheckPayload {
|
|
2240
|
+
/**
|
|
2241
|
+
* The Pay element document's id: a lowercase canonical version-4 UUID the element mints once per document.
|
|
2242
|
+
* Correlation, not authentication.
|
|
2243
|
+
*/
|
|
2244
|
+
documentId: string;
|
|
2245
|
+
/**
|
|
2246
|
+
* The envelope id of the accepted `element-init`.
|
|
2247
|
+
*/
|
|
2248
|
+
initId: string;
|
|
2249
|
+
/**
|
|
2250
|
+
* The envelope id of the applied `element-config`.
|
|
2251
|
+
*/
|
|
2252
|
+
configId: string;
|
|
2253
|
+
/**
|
|
2254
|
+
* That config's revision: a safe integer from 1.
|
|
2255
|
+
*/
|
|
2256
|
+
revision: number;
|
|
2257
|
+
/**
|
|
2258
|
+
* The config's sign action's attempt id.
|
|
2259
|
+
*/
|
|
2260
|
+
attemptId: string;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Pay element → app, request: may the card enable this exact sign action? Answered by `element-action-eligibility`
|
|
2264
|
+
* with the same `id`. A missing, false or stale answer keeps the action disabled.
|
|
2265
|
+
*/
|
|
2266
|
+
type ElementActionCheckMessage = PayEnvelope<typeof PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.actionCheck, ElementActionCheckPayload>;
|
|
2267
|
+
/**
|
|
2268
|
+
* The payload of `element-action-eligibility`: the check, echoed, and the answer.
|
|
2269
|
+
*/
|
|
2270
|
+
interface AppElementActionEligibilityPayload extends ElementActionCheckPayload {
|
|
2271
|
+
/**
|
|
2272
|
+
* Whether the attempt is still unused in the app's ledger. `true` is permission for this config only, not proof of
|
|
2273
|
+
* a signature.
|
|
2274
|
+
*/
|
|
2275
|
+
eligible: boolean;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* app → Pay element: the answer to `element-action-check`. Its `id` is the check's.
|
|
2279
|
+
*/
|
|
2280
|
+
type AppElementActionEligibilityMessage = PayEnvelope<typeof PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.actionEligibility, AppElementActionEligibilityPayload>;
|
|
2281
|
+
/**
|
|
2282
|
+
* The payload of `element-page-url`.
|
|
2283
|
+
*/
|
|
2284
|
+
interface AppElementPageUrlPayload {
|
|
2285
|
+
/**
|
|
2286
|
+
* The app page's full address (`location.href`): 1 to `MAX_PAGE_URL_LENGTH` characters, an `http:` or `https:` URL
|
|
2287
|
+
* spelled as `URL` writes it, with no credentials.
|
|
2288
|
+
*/
|
|
2289
|
+
url: string;
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* app → Pay element: the address of the page the app shows Pay on. The app sends it before each `element-pay-request`.
|
|
2293
|
+
* The hub takes it only when its origin is the element's verified app origin, keeps it in memory for that payment, and
|
|
2294
|
+
* never stores or logs it: a phone wallet that browses (Phantom) opens this page in its own browser. A Pay element that
|
|
2295
|
+
* predates it drops it as an unknown type, and without it the hub keeps its other phone routes. No reply.
|
|
2296
|
+
*/
|
|
2297
|
+
type AppElementPageUrlMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.pageUrl, AppElementPageUrlPayload>;
|
|
2298
|
+
/** The app's Check status support for one accepted element document and init. */
|
|
2299
|
+
interface AppElementCheckStatusCapabilityPayload {
|
|
2300
|
+
/** The pinned element document's lowercase canonical version-4 UUID. Correlation, not authentication. */
|
|
2301
|
+
documentId: string;
|
|
2302
|
+
/** The envelope id of the accepted `element-init`, bounded like a message id. */
|
|
2303
|
+
initId: string;
|
|
2304
|
+
/** Whether the app currently has a Check status callback. `false` withdraws support. */
|
|
2305
|
+
supported: boolean;
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* app → Pay element: advertise or withdraw Check status after the app pins the document from an authenticated
|
|
2309
|
+
* `element-action-check` or `element-connected`. No reply. A new document or init starts unsupported.
|
|
2310
|
+
*/
|
|
2311
|
+
type AppElementCheckStatusCapabilityMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.checkStatusCapability, AppElementCheckStatusCapabilityPayload>;
|
|
2312
|
+
/**
|
|
2313
|
+
* The exact current document, init, config and spent attempt to check. Uses the same field bounds as
|
|
2314
|
+
* `element-action-check`; the channel also verifies this attempt is spent in this card's lifetime.
|
|
2315
|
+
*/
|
|
2316
|
+
type ElementCheckStatusRequestPayload = ElementActionCheckPayload;
|
|
2317
|
+
/**
|
|
2318
|
+
* Pay element → app, request: check the app backend for a spent attempt. Despite living in the notification table,
|
|
2319
|
+
* it requires `element-check-status-settled` with the same envelope id and payload. It grants no signing permission.
|
|
2320
|
+
*/
|
|
2321
|
+
type ElementCheckStatusRequestMessage = PayEnvelope<typeof PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES.checkStatusRequest, ElementCheckStatusRequestPayload>;
|
|
2322
|
+
/** The Check status request's correlation fields, echoed unchanged; no payment result or retry permission. */
|
|
2323
|
+
type AppElementCheckStatusSettledPayload = ElementCheckStatusRequestPayload;
|
|
2324
|
+
/**
|
|
2325
|
+
* app → Pay element: the backend check finished, including a rejection or synchronous return. Its envelope id and
|
|
2326
|
+
* payload echo the request. A stale settlement is ignored. Settlement never releases a spent attempt: retry needs
|
|
2327
|
+
* an app backend check, a new attempt id and a fresh Pay click. `onFailed` remains terminal and once-only;
|
|
2328
|
+
* cosignature has no action.
|
|
2329
|
+
*/
|
|
2330
|
+
type AppElementCheckStatusSettledMessage = PayEnvelope<typeof PAY_ELEMENT_MESSAGE_TYPES.checkStatusSettled, AppElementCheckStatusSettledPayload>;
|
|
2331
|
+
/**
|
|
2332
|
+
* The payload of `element-reload-request`. It carries no build id, URL or address.
|
|
2333
|
+
*/
|
|
2334
|
+
interface ElementReloadRequestPayload {
|
|
2335
|
+
/**
|
|
2336
|
+
* The Pay element document's id.
|
|
2337
|
+
*/
|
|
2338
|
+
documentId: string;
|
|
2339
|
+
/**
|
|
2340
|
+
* The envelope id of the accepted `element-init`.
|
|
2341
|
+
*/
|
|
2342
|
+
initId: string;
|
|
2343
|
+
/**
|
|
2344
|
+
* Why.
|
|
2345
|
+
*/
|
|
2346
|
+
reason: SuaElementReloadReason;
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
2349
|
+
* Pay element → app, request: may the Pay element reload itself once? Answered by `element-reload-grant` with the
|
|
2350
|
+
* same `id`. The app owns the one-reload budget; only the Pay element navigates.
|
|
2351
|
+
*/
|
|
2352
|
+
type ElementReloadRequestMessage = PayEnvelope<typeof PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.reloadRequest, ElementReloadRequestPayload>;
|
|
2353
|
+
/**
|
|
2354
|
+
* The payload of `element-reload-grant`.
|
|
2355
|
+
*/
|
|
2356
|
+
interface AppElementReloadGrantPayload {
|
|
2357
|
+
/**
|
|
2358
|
+
* The Pay element document's id, echoed.
|
|
2359
|
+
*/
|
|
2360
|
+
documentId: string;
|
|
2361
|
+
/**
|
|
2362
|
+
* The envelope id of the accepted `element-init`, echoed.
|
|
2363
|
+
*/
|
|
2364
|
+
initId: string;
|
|
2365
|
+
/**
|
|
2366
|
+
* Whether the Pay element may reload. `false` once the budget is spent.
|
|
2367
|
+
*/
|
|
2368
|
+
granted: boolean;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* app → Pay element: the answer to `element-reload-request`. Its `id` is the request's.
|
|
2372
|
+
*/
|
|
2373
|
+
type AppElementReloadGrantMessage = PayEnvelope<typeof PAY_ELEMENT_LIFETIME_MESSAGE_TYPES.reloadGrant, AppElementReloadGrantPayload>;
|
|
2374
|
+
//#endregion
|
|
2375
|
+
//#region src/protocol/pay.d.ts
|
|
2376
|
+
type PayJob = (typeof PAY_JOBS)[number];
|
|
2377
|
+
type PayCurrency = (typeof PAY_CURRENCIES)[number];
|
|
2378
|
+
/** Which question a chosen-amount Deposit's Pay window asks first. Presentation only, never a payment term. */
|
|
2379
|
+
type PayFirstStep = (typeof PAY_FIRST_STEPS)[number];
|
|
2380
|
+
/** An app's checkout rule id, as {@link PAY_DESTINATION_RULE_PATTERN} ("ckr_01JD3V9QX8K2M4N6P8R0S2T4V6"). */
|
|
2381
|
+
type PayDestinationRuleId = `ckr_${string}`;
|
|
2382
|
+
/**
|
|
2383
|
+
* An address with the asset it is paid in: `0x` and 40 hexadecimal characters, not the zero address, and a CAIP-19
|
|
2384
|
+
* asset on an `eip155` chain ({@link PAY_DESTINATION_ASSET_PATTERN}). The asset names the chain, so an address never
|
|
2385
|
+
* travels without one.
|
|
2386
|
+
*/
|
|
2387
|
+
interface PayDestinationAddress {
|
|
2388
|
+
address: `0x${string}`;
|
|
2389
|
+
asset: `eip155:${string}`;
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* 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
|
|
2393
|
+
* the app's raw ask: the hub compares a saved or resumed payment against it exactly as sent, never against what it
|
|
2394
|
+
* resolves to now.
|
|
2395
|
+
*/
|
|
2396
|
+
type PayDestinationAsk = PayDestinationRuleId | PayDestinationAddress;
|
|
2397
|
+
/**
|
|
2398
|
+
* The payload of `element-pay-request`: these six keys, plus `destination` only when the app gives one. `item` is
|
|
2399
|
+
* `null` when the app sends none (never absent, so the exact-key guard stays simple).
|
|
2400
|
+
*/
|
|
2401
|
+
interface ElementPayRequestPayload {
|
|
2402
|
+
/**
|
|
2403
|
+
* A safe integer from 1. A higher revision replaces the applied request whole; an equal or lower one is acked and
|
|
2404
|
+
* ignored.
|
|
2405
|
+
*/
|
|
2406
|
+
revision: number;
|
|
2407
|
+
/**
|
|
2408
|
+
* The app's id for this one payment: 1 to `MAX_MESSAGE_ID_LENGTH` characters. The hub pays one `paymentId` at most
|
|
2409
|
+
* once per app and payment id in this browser's hub storage and names it in `element-paid`. Missing or partitioned
|
|
2410
|
+
* storage weakens that protection; this notice is still not proof. A new purchase is a new id; a retry after a rejection or a
|
|
2411
|
+
* failure keeps it. Changing `job`, `amount`, `currency` or `item` under a known `paymentId` is refused (TypeError on
|
|
2412
|
+
* the app face, dropped by the element).
|
|
2413
|
+
*/
|
|
2414
|
+
paymentId: string;
|
|
2415
|
+
/**
|
|
2416
|
+
* The job word.
|
|
2417
|
+
*/
|
|
2418
|
+
job: PayJob;
|
|
2419
|
+
/**
|
|
2420
|
+
* The amount the app must receive, as {@link PAY_AMOUNT_PATTERN}, greater than zero.
|
|
2421
|
+
*/
|
|
2422
|
+
amount: string;
|
|
2423
|
+
/**
|
|
2424
|
+
* The currency of `amount`.
|
|
2425
|
+
*/
|
|
2426
|
+
currency: PayCurrency;
|
|
2427
|
+
/**
|
|
2428
|
+
* The item line, 1 to {@link MAX_PAY_ITEM_LENGTH} code units, or `null`.
|
|
2429
|
+
*/
|
|
2430
|
+
item: string | null;
|
|
2431
|
+
/**
|
|
2432
|
+
* Where the app asks the money to go ({@link PayDestinationAsk}). Absent when the app gives none, so a request
|
|
2433
|
+
* without it keeps the six keys an older peer reads. It is not one of the payment's terms: a changed destination
|
|
2434
|
+
* under a known `paymentId` is a new revision, never a conflict.
|
|
2435
|
+
*/
|
|
2436
|
+
destination?: PayDestinationAsk;
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* A request's destination ask as the wire may carry it: `destination`, or the older `payoutAddress` (at most
|
|
2440
|
+
* {@link MAX_PAY_PAYOUT_ADDRESS_LENGTH} code units, unchecked) that apps sent before it, never both. The decoders still
|
|
2441
|
+
* accept the older key from older apps, and the hub still reads it on retained requests and old receipts. Internal:
|
|
2442
|
+
* the public request types name `destination` only.
|
|
2443
|
+
*
|
|
2444
|
+
* Why it stays: Ada and Kite sent it from #356 to #389, so retained payment records may still hold it; and the staging
|
|
2445
|
+
* production apps still run a kit that forwards a `payoutAddress` prop (removed in b028ff5df). Once every deployed app
|
|
2446
|
+
* build contains b028ff5df, remove only the app ingress (the element request keys and guards) and the hub's forwarding.
|
|
2447
|
+
* The shared terms keys stay: account receipt replay rebuilds terms from retained records and decodes them here, so
|
|
2448
|
+
* they go only with a migration of stored payment records that keeps their recorded destination ask.
|
|
2449
|
+
*/
|
|
2450
|
+
interface LegacyPayDestinationAsk {
|
|
2451
|
+
payoutAddress?: string;
|
|
2452
|
+
destination?: PayDestinationAsk;
|
|
2453
|
+
}
|
|
2454
|
+
/**
|
|
2455
|
+
* The payload of `element-deposit-request`: a Deposit whose amount the user chooses in the window. It has no `job`
|
|
2456
|
+
* (the type says Deposit) and no `amount`. `min` and `max` are the app's optional limits, as
|
|
2457
|
+
* {@link PAY_AMOUNT_PATTERN} within {@link MAX_PAY_AMOUNT}, with `min` at most `max`; each is absent when the app gives
|
|
2458
|
+
* none. The other keys read as on `element-pay-request`, and the element answers with `element-pay-request-ack`.
|
|
2459
|
+
*/
|
|
2460
|
+
interface ElementDepositRequestPayload {
|
|
2461
|
+
revision: number;
|
|
2462
|
+
paymentId: string;
|
|
2463
|
+
currency: PayCurrency;
|
|
2464
|
+
item: string | null;
|
|
2465
|
+
/** The least the user may deposit, for example "20.00". */
|
|
2466
|
+
min?: string;
|
|
2467
|
+
/** The most the user may deposit, for example "500". */
|
|
2468
|
+
max?: string;
|
|
2469
|
+
destination?: PayDestinationAsk;
|
|
2470
|
+
/**
|
|
2471
|
+
* `method` when the app asks the window to show the ways to pay before the amount. Absent for the default amount
|
|
2472
|
+
* first, so a request without it keeps the keys an older peer reads: an element that predates it drops the whole
|
|
2473
|
+
* request, so the hub deploys first. Not one of the payment's terms: a change is a new revision, never a conflict.
|
|
2474
|
+
*/
|
|
2475
|
+
firstStep?: Exclude<PayFirstStep, "amount">;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* The payload of `element-pay-request-ack`.
|
|
2479
|
+
*/
|
|
2480
|
+
interface ElementPayRequestAckPayload {
|
|
2481
|
+
/**
|
|
2482
|
+
* The revision the element now holds.
|
|
2483
|
+
*/
|
|
2484
|
+
revision: number;
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* The payload of `element-paid`. It reports what the hub saw; it is not proof of payment. The app reconciles with its
|
|
2488
|
+
* own backend or Gateway before it ships anything (the reference and the transaction hash let it look the payment up).
|
|
2489
|
+
* The same paymentId can be reported again after a reload; apps must handle it idempotently by paymentId.
|
|
2490
|
+
*/
|
|
2491
|
+
interface ElementPaidPayload {
|
|
2492
|
+
/**
|
|
2493
|
+
* The `paymentId` of the request this payment answered.
|
|
2494
|
+
*/
|
|
2495
|
+
paymentId: string;
|
|
2496
|
+
/**
|
|
2497
|
+
* The job word of that request.
|
|
2498
|
+
*/
|
|
2499
|
+
job: PayJob;
|
|
2500
|
+
/**
|
|
2501
|
+
* The amount and currency of that request.
|
|
2502
|
+
*/
|
|
2503
|
+
amount: string;
|
|
2504
|
+
currency: PayCurrency;
|
|
2505
|
+
/**
|
|
2506
|
+
* How the person paid. `account` is a real Stridge Wallet transfer to the app on Tempo. `transfer` is "Pay by QR
|
|
2507
|
+
* code": the person sent to a Gateway deposit address made for this one order, which settles to the app's payout.
|
|
2508
|
+
* An app face from before `transfer` drops only this message (its guard reads the method by exact value), so such an
|
|
2509
|
+
* app hears nothing for a QR payment and reconciles it through its own backend or Gateway.
|
|
2510
|
+
*/
|
|
2511
|
+
method: "wallet" | "cash" | "account" | "transfer";
|
|
2512
|
+
/**
|
|
2513
|
+
* The receipt reference the hub shows ("7Q2-K9F"): 1 to 32 characters of `[0-9A-Z-]`.
|
|
2514
|
+
*/
|
|
2515
|
+
reference: string;
|
|
2516
|
+
/**
|
|
2517
|
+
* The delivery transaction hash on the payout network, when Gateway reports one, else `null`.
|
|
2518
|
+
*/
|
|
2519
|
+
transactionHash: `0x${string}` | null;
|
|
2520
|
+
/** Actual delivery facts, distinct from the requested USD amount. */
|
|
2521
|
+
received: PayReceived;
|
|
2522
|
+
/** A completed route may still be short of the payment target. */
|
|
2523
|
+
outcome: "paid" | "short";
|
|
2524
|
+
}
|
|
2525
|
+
/** Actual output reported by the correlated settlement. */
|
|
2526
|
+
interface PayReceived {
|
|
2527
|
+
amountBaseUnits: string;
|
|
2528
|
+
assetSymbol: string;
|
|
2529
|
+
networkId: string;
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* The words of the request a payment record is bound to: its job, amount ("24.00"), currency and item line. A paid
|
|
2533
|
+
* `pay-progress` carries them, so the element pairs a stored receipt only with a request of the same terms.
|
|
2534
|
+
*/
|
|
2535
|
+
type PayTerms = Pick<ElementPayRequestPayload, "job" | "amount" | "currency" | "item">;
|
|
2536
|
+
/** A transaction is always paired with the network where it happened. */
|
|
2537
|
+
interface PayTransaction {
|
|
2538
|
+
hash: `0x${string}`;
|
|
2539
|
+
networkId: string;
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* app → Sua element.
|
|
2543
|
+
*/
|
|
2544
|
+
type AppElementPayRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.payRequest, ElementPayRequestPayload>;
|
|
2545
|
+
/**
|
|
2546
|
+
* app → Sua element.
|
|
2547
|
+
*/
|
|
2548
|
+
type AppElementDepositRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.depositRequest, ElementDepositRequestPayload>;
|
|
2549
|
+
/** `element-pay-request` as the hub decodes it: an older app may still send the legacy key. Internal. */
|
|
2550
|
+
type HubAppElementPayRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.payRequest, ElementPayRequestPayload & LegacyPayDestinationAsk>;
|
|
2551
|
+
/** `element-deposit-request` as the hub decodes it: an older app may still send the legacy key. Internal. */
|
|
2552
|
+
type HubAppElementDepositRequestMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.depositRequest, ElementDepositRequestPayload & LegacyPayDestinationAsk>;
|
|
2553
|
+
/**
|
|
2554
|
+
* Sua element → app.
|
|
2555
|
+
*/
|
|
2556
|
+
type ElementPayRequestAckMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.payRequestAck, ElementPayRequestAckPayload>;
|
|
2557
|
+
/**
|
|
2558
|
+
* Sua element → app notice.
|
|
2559
|
+
*/
|
|
2560
|
+
type ElementPaidMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.paid, ElementPaidPayload>;
|
|
2561
|
+
/** A support notice names the locked payment. It never authorizes fulfillment or a retry. */
|
|
2562
|
+
interface ElementPaymentNoticePayload {
|
|
2563
|
+
paymentId: string;
|
|
2564
|
+
reference: string;
|
|
2565
|
+
}
|
|
2566
|
+
type ElementHeldMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.held, ElementPaymentNoticePayload>;
|
|
2567
|
+
type ElementUnconfirmedMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.unconfirmed, ElementPaymentNoticePayload>;
|
|
2568
|
+
/** Compares validated decimal pay amounts without floating point arithmetic. */
|
|
2569
|
+
declare function comparePayAmounts(left: string, right: string): -1 | 0 | 1;
|
|
2570
|
+
/**
|
|
2571
|
+
* The money words of a request either message carries, without its revision: a fixed request names its `job` and
|
|
2572
|
+
* `amount`; a chosen-amount Deposit names neither, only its optional limits.
|
|
2573
|
+
*/
|
|
2574
|
+
type PayRequestTerms = Pick<ElementPayRequestPayload, "paymentId" | "job" | "amount" | "currency" | "item"> | Pick<ElementDepositRequestPayload, "paymentId" | "currency" | "item" | "min" | "max">;
|
|
2575
|
+
/** The request's job word: a chosen-amount Deposit request is always `deposit`. Pure. */
|
|
2576
|
+
declare function payJobOf(request: PayRequestTerms): PayJob;
|
|
2577
|
+
/**
|
|
2578
|
+
* Whether a payment of `amount` (a validated pay amount, "40.00") answers `request`: the same amount for a fixed
|
|
2579
|
+
* request; for a chosen-amount Deposit, any amount within its limits. Pure.
|
|
2580
|
+
*/
|
|
2581
|
+
declare function answersPayAmount(request: PayRequestTerms, amount: string): boolean;
|
|
2582
|
+
/**
|
|
2583
|
+
* Whether two requests ask the same money under the same `paymentId`: the same kind, job, currency, item, and the
|
|
2584
|
+
* same amount or the same limits (decimal-equal: "20" is "20.00"). The destination ask and the first step are not
|
|
2585
|
+
* terms ({@link samePayDestinationAsk} compares the ask). Pure.
|
|
2586
|
+
*/
|
|
2587
|
+
declare function samePayTerms(left: PayRequestTerms, right: PayRequestTerms): boolean;
|
|
2588
|
+
/**
|
|
2589
|
+
* Whether two requests ask for the same destination, exactly as the app sent it: the same `destination` (the same rule
|
|
2590
|
+
* id, or the same address and asset, byte for byte); absent equals absent. The app face's revision check uses it. Pure.
|
|
2591
|
+
*/
|
|
2592
|
+
declare function samePayDestinationAsk(left: {
|
|
2593
|
+
destination?: PayDestinationAsk;
|
|
2594
|
+
}, right: {
|
|
2595
|
+
destination?: PayDestinationAsk;
|
|
2596
|
+
}): boolean;
|
|
2597
|
+
/**
|
|
2598
|
+
* {@link samePayDestinationAsk} with the older key too: the same `destination` and the same raw `payoutAddress`,
|
|
2599
|
+
* absent equal to absent. The hub's ask identity uses it, so a saved or resumed payment compares against what the app
|
|
2600
|
+
* asked, never against a later resolution. Internal. Pure.
|
|
2601
|
+
*/
|
|
2602
|
+
declare function sameLegacyPayDestinationAsk(left: LegacyPayDestinationAsk, right: LegacyPayDestinationAsk): boolean;
|
|
2603
|
+
/** Exact-key pay request guard. Never throws. */
|
|
2604
|
+
declare function isElementPayRequestPayload(value: unknown): value is ElementPayRequestPayload;
|
|
2605
|
+
/** Exact-key chosen-amount Deposit request guard. Never throws. */
|
|
2606
|
+
declare function isElementDepositRequestPayload(value: unknown): value is ElementDepositRequestPayload;
|
|
2607
|
+
/** Exact-key acknowledgment guard. Never throws. */
|
|
2608
|
+
declare function isElementPayRequestAckPayload(value: unknown): value is ElementPayRequestAckPayload;
|
|
2609
|
+
/** Exact-key payment notice guard. Never throws. */
|
|
2610
|
+
declare function isElementPaidPayload(value: unknown): value is ElementPaidPayload;
|
|
2611
|
+
/** The four final states reported by a checkout, independently of its UI outcome. */
|
|
2612
|
+
type CheckoutFinalState = "completed" | "failed" | "canceled" | "expired";
|
|
2613
|
+
/** A Coordinator observation. The app must verify delivery independently before it fulfils the checkout. */
|
|
2614
|
+
interface ElementCheckoutResultPayload {
|
|
2615
|
+
paymentId: string;
|
|
2616
|
+
/**
|
|
2617
|
+
* The pay-in id, distinct from the envelope id: an opaque string, `srt_<uuid>` from Coordinator rc.38 on (a bare UUID
|
|
2618
|
+
* before). Never parse it.
|
|
2619
|
+
*/
|
|
2620
|
+
id: string;
|
|
2621
|
+
/**
|
|
2622
|
+
* The pay-in's final state. The Coordinator now calls it `status`; this message keeps the key `state`, because apps
|
|
2623
|
+
* read it and the app and the hub deploy apart.
|
|
2624
|
+
*/
|
|
2625
|
+
state: CheckoutFinalState;
|
|
2626
|
+
/** Approved amount in destination base units. */
|
|
2627
|
+
amount: string;
|
|
2628
|
+
/** Delivered amount in destination base units, possibly below amount. */
|
|
2629
|
+
delivered: string;
|
|
2630
|
+
/** Unique destination transactions only; empty is valid even on completed. */
|
|
2631
|
+
destinationTxs: readonly string[];
|
|
2632
|
+
}
|
|
2633
|
+
type ElementCheckoutResultMessage = PayEnvelope<typeof PAY_MESSAGE_TYPES.checkoutResult, ElementCheckoutResultPayload>;
|
|
2634
|
+
/** Internal request terms accompany the fixed app payload so a cached result cannot answer changed terms. */
|
|
2635
|
+
interface HubElementCheckoutResultPayload {
|
|
2636
|
+
result: ElementCheckoutResultPayload;
|
|
2637
|
+
request: PayTerms & LegacyPayDestinationAsk;
|
|
2638
|
+
/** The payee name the server gave the approved quote (`payee.name`), or `null` when it named none. */
|
|
2639
|
+
payee: string | null;
|
|
2640
|
+
}
|
|
2641
|
+
/**
|
|
2642
|
+
* The wallet that paid a guest checkout in full, as the card draws it: the brand its logo is looked up by. Display
|
|
2643
|
+
* only: never an identity or a money input.
|
|
2644
|
+
*/
|
|
2645
|
+
interface HubElementCheckoutWalletPayload {
|
|
2646
|
+
paymentId: string;
|
|
2647
|
+
/** The paying wallet's brand ("metamask"), as `pay-progress` names a direct payment's. */
|
|
2648
|
+
brand: string;
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2651
|
+
* A guest checkout the hub holds for `paymentId` with the terms its result carries, or `request` `null` once the hub
|
|
2652
|
+
* holds none: it expired, was released, or went.
|
|
2653
|
+
*/
|
|
2654
|
+
interface HubElementCheckoutHeldPayload {
|
|
2655
|
+
paymentId: string;
|
|
2656
|
+
request: HubElementCheckoutResultPayload["request"] | null;
|
|
2657
|
+
}
|
|
2658
|
+
/** Exact-key checkout guard. Never throws; ids are 1–128 code units, amounts at most 78 digits. */
|
|
2659
|
+
declare function isElementCheckoutResultPayload(value: unknown): value is ElementCheckoutResultPayload;
|
|
2660
|
+
/** Internal checkout result and its bound request terms. */
|
|
2661
|
+
type HubElementCheckoutResultMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.checkoutResult, HubElementCheckoutResultPayload>;
|
|
2662
|
+
/** The wallet that paid a guest checkout in full, beside its checkout result. */
|
|
2663
|
+
type HubElementCheckoutWalletMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.checkoutWallet, HubElementCheckoutWalletPayload>;
|
|
2664
|
+
/** A guest checkout the hub holds for a payment, or holds no longer. */
|
|
2665
|
+
type HubElementCheckoutHeldMessage = PayEnvelope<typeof SUA_LINK_C_MESSAGE_TYPES.checkoutHeld, HubElementCheckoutHeldPayload>;
|
|
2666
|
+
/**
|
|
2667
|
+
* The payload of `relay-pay-progress`: a Pay window's `pay-progress` for the element that opened it. A popup hub page
|
|
2668
|
+
* holds no link C attachment, so its payment reaches the card and the app's `element-paid` on this stream.
|
|
2669
|
+
*/
|
|
2670
|
+
interface WindowRelayPayProgressPayload {
|
|
2671
|
+
/** As for `relay-state`. */
|
|
2672
|
+
relayId: string;
|
|
2673
|
+
/** The envelope id of the window's current ceremony request. */
|
|
2674
|
+
requestId: string;
|
|
2675
|
+
/** The position in this operation's pay-progress stream: a safe integer from 1, increasing. */
|
|
2676
|
+
sequence: number;
|
|
2677
|
+
/** The payment's progress, as link C's `pay-progress` carries it. */
|
|
2678
|
+
progress: HubElementPayProgressPayload;
|
|
2679
|
+
}
|
|
2680
|
+
type WindowRelayPayProgressMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.payProgress, WindowRelayPayProgressPayload>;
|
|
2681
|
+
/**
|
|
2682
|
+
* The payload of `relay-pay-source`: the source a Pay window picks for the person it serves, as link C's `pay-source`
|
|
2683
|
+
* names it in `remembered`. A hub frame that cannot read the window's storage or session picks for a guest, so the
|
|
2684
|
+
* card of the element that opened the window shows this one instead, for the person the window last relayed.
|
|
2685
|
+
*/
|
|
2686
|
+
interface WindowRelayPaySourcePayload {
|
|
2687
|
+
/** As for `relay-state`. */
|
|
2688
|
+
relayId: string;
|
|
2689
|
+
/** The envelope id of the window's current ceremony request. */
|
|
2690
|
+
requestId: string;
|
|
2691
|
+
/** The position in this operation's pay stream, shared with `relay-pay-progress`: a safe integer from 1, increasing. */
|
|
2692
|
+
sequence: number;
|
|
2693
|
+
/** The picked source, as `pay-source` carries it; `null` when the window picks none. */
|
|
2694
|
+
remembered: HubElementPaySourceRemembered | null;
|
|
2695
|
+
}
|
|
2696
|
+
type WindowRelayPaySourceMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.paySource, WindowRelayPaySourcePayload>;
|
|
2697
|
+
/**
|
|
2698
|
+
* The payload of `relay-pay-source-saved`: the first wallet saved to the account the Pay window serves, as link C's
|
|
2699
|
+
* `pay-source-saved` carries it, for the card of the element that opened the window.
|
|
2700
|
+
*/
|
|
2701
|
+
interface WindowRelayPaySourceSavedPayload {
|
|
2702
|
+
/** As for `relay-state`. */
|
|
2703
|
+
relayId: string;
|
|
2704
|
+
/** The envelope id of the window's current ceremony request. */
|
|
2705
|
+
requestId: string;
|
|
2706
|
+
/** The position in this operation's pay stream, shared with `relay-pay-source`: a safe integer from 1, increasing. */
|
|
2707
|
+
sequence: number;
|
|
2708
|
+
/** The first saved wallet; `null` when the window picks no account or the account saved none. */
|
|
2709
|
+
saved: HubElementPaySavedWallet | null;
|
|
2710
|
+
}
|
|
2711
|
+
type WindowRelayPaySourceSavedMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.paySourceSaved, WindowRelayPaySourceSavedPayload>;
|
|
2712
|
+
/** Full pay request carried on both hub transports. */
|
|
2713
|
+
interface HubPayRequestPayload {
|
|
2714
|
+
paymentId: string;
|
|
2715
|
+
job: PayJob;
|
|
2716
|
+
/**
|
|
2717
|
+
* The amount the app asked for, or `null` for a Deposit whose amount the user chooses in the window
|
|
2718
|
+
* (`element-deposit-request`).
|
|
2719
|
+
*/
|
|
2720
|
+
amount: string | null;
|
|
2721
|
+
currency: "USD";
|
|
2722
|
+
item: string | null;
|
|
2723
|
+
/** A chosen-amount Deposit's least amount, when the app gave one. Absent whenever `amount` is set. */
|
|
2724
|
+
min?: string;
|
|
2725
|
+
/** A chosen-amount Deposit's most amount, when the app gave one. Absent whenever `amount` is set. */
|
|
2726
|
+
max?: string;
|
|
2727
|
+
/**
|
|
2728
|
+
* `method` when a chosen-amount Deposit asks the ways to pay before the amount, as `element-deposit-request`
|
|
2729
|
+
* carried it. Absent for the amount first and whenever `amount` is set.
|
|
2730
|
+
*/
|
|
2731
|
+
firstStep?: Exclude<PayFirstStep, "amount">;
|
|
2732
|
+
/**
|
|
2733
|
+
* Where the window opens: `pay` (the Pay button), `sources` (the card's source row: the "Pay with" list), or a
|
|
2734
|
+
* started payment's `progress` / `receipt`.
|
|
2735
|
+
*/
|
|
2736
|
+
entry: "pay" | "sources" | "progress" | "receipt";
|
|
2737
|
+
/**
|
|
2738
|
+
* The app's payout address, as `element-pay-request` carried it. Absent when the app gave none. The hub uses it
|
|
2739
|
+
* only for an app its app list marks as a test app, and only when it is a valid address.
|
|
2740
|
+
*
|
|
2741
|
+
* @deprecated Use `destination`. A request may not carry both.
|
|
2742
|
+
*/
|
|
2743
|
+
payoutAddress?: string;
|
|
2744
|
+
/** The app's destination ask, as `element-pay-request` carried it. Absent when the app gave none. */
|
|
2745
|
+
destination?: PayDestinationAsk;
|
|
2746
|
+
}
|
|
2747
|
+
type HubPayRequestMessage = PayEnvelope<"pay", HubPayRequestPayload>;
|
|
2748
|
+
/**
|
|
2749
|
+
* The source the card picks: a wallet (`last-used` for a guest, `saved` for a signed-in person) or, for a signed-in
|
|
2750
|
+
* person who has not paid with a saved wallet yet, the Stridge Wallet (`account`).
|
|
2751
|
+
*/
|
|
2752
|
+
type HubElementPaySourceRemembered = {
|
|
2753
|
+
kind: "last-used" | "saved";
|
|
2754
|
+
brand: string;
|
|
2755
|
+
name: string;
|
|
2756
|
+
addressTail: string;
|
|
2757
|
+
} | {
|
|
2758
|
+
kind: "account";
|
|
2759
|
+
};
|
|
2760
|
+
/** Card source facts supplied by the hub window. */
|
|
2761
|
+
interface HubElementPaySourcePayload {
|
|
2762
|
+
account: "on" | "off" | null;
|
|
2763
|
+
remembered: HubElementPaySourceRemembered | null;
|
|
2764
|
+
detected: readonly string[];
|
|
2765
|
+
/**
|
|
2766
|
+
* How the person may pay. `cash` is `direct` (Cash pays the app), `account` (Card or bank creates a Stridge Wallet
|
|
2767
|
+
* first) or `none` (no Cash).
|
|
2768
|
+
*/
|
|
2769
|
+
methods: {
|
|
2770
|
+
wallet: true;
|
|
2771
|
+
cash: "direct" | "account" | "none";
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* Hub-origin progress only; the consumer app face receives the existing element-paid notice. An open Pay window can
|
|
2776
|
+
* predate the element's build, so account receipts accept legacy terms without ask evidence. `transfer` is "Manual
|
|
2777
|
+
* deposit": `paying` once a deposit to the order's address is seen, then `paid`.
|
|
2778
|
+
*/
|
|
2779
|
+
type HubElementPayProgressPayload = {
|
|
2780
|
+
paymentId: string;
|
|
2781
|
+
phase: "paying";
|
|
2782
|
+
logo: "wallet" | "cash" | "account" | "transfer";
|
|
2783
|
+
brand: string | null;
|
|
2784
|
+
/** The wallet the payment left from ("MetaMask ••4e07"), or `null` when the hub has no label (Cash). */
|
|
2785
|
+
fromLabel: string | null;
|
|
2786
|
+
/**
|
|
2787
|
+
* When the payment started, in ms since the epoch, when the hub's record kept it. The card says "Taking longer
|
|
2788
|
+
* than usual" once the hub's long wait passed since then. Absent from an older hub.
|
|
2789
|
+
*/
|
|
2790
|
+
startedAt?: number;
|
|
2791
|
+
source: PayTransaction | null;
|
|
2792
|
+
delivery: PayTransaction | null;
|
|
2793
|
+
} | {
|
|
2794
|
+
paymentId: string;
|
|
2795
|
+
phase: "paid";
|
|
2796
|
+
logo: "wallet" | "cash" | "account" | "transfer";
|
|
2797
|
+
brand: string | null;
|
|
2798
|
+
reference: string;
|
|
2799
|
+
fromLabel: string;
|
|
2800
|
+
source: PayTransaction | null;
|
|
2801
|
+
delivery: PayTransaction | null;
|
|
2802
|
+
received: PayReceived;
|
|
2803
|
+
/**
|
|
2804
|
+
* `received` in token units with two fraction digits, rounded down ("23.90"), for the card's "Kite Studio got
|
|
2805
|
+
* 23.90 USDC". `null` when the hub no longer knows the token's decimals (a record kept before this field).
|
|
2806
|
+
*/
|
|
2807
|
+
receivedDisplay: string | null;
|
|
2808
|
+
/**
|
|
2809
|
+
* Required for an account receipt by the hub guard. The recorded destination, the record's raw ask (in
|
|
2810
|
+
* `request`) and the registry payout let the element reject a replay for another ask. Absent for wallet and
|
|
2811
|
+
* Cash receipts. A null payout means registry settings are unavailable, so the element reports no paid notice.
|
|
2812
|
+
*/
|
|
2813
|
+
binding?: {
|
|
2814
|
+
destination: {
|
|
2815
|
+
address: `0x${string}`;
|
|
2816
|
+
networkId: string;
|
|
2817
|
+
assetSymbol: "USDC" | "USDT";
|
|
2818
|
+
};
|
|
2819
|
+
payout: {
|
|
2820
|
+
address: `0x${string}` | null;
|
|
2821
|
+
networkId: string;
|
|
2822
|
+
assetSymbol: "USDC" | "USDT";
|
|
2823
|
+
} | null;
|
|
2824
|
+
testApp: boolean;
|
|
2825
|
+
};
|
|
2826
|
+
outcome: "paid" | "short";
|
|
2827
|
+
/**
|
|
2828
|
+
* The terms of the request this payment's record is bound to (R1-01). An account receipt adds the record's raw
|
|
2829
|
+
* destination ask (`payoutAddress` or `destination`, with `destination: null` when it sent none). Missing
|
|
2830
|
+
* evidence is a legacy receipt and requires the old effective-payout check.
|
|
2831
|
+
*/
|
|
2832
|
+
request: PayTerms & {
|
|
2833
|
+
payoutAddress?: string;
|
|
2834
|
+
destination?: PayDestinationAsk | null;
|
|
2835
|
+
};
|
|
2836
|
+
} | {
|
|
2837
|
+
paymentId: string;
|
|
2838
|
+
phase: "failed";
|
|
2839
|
+
retry: "allowed" | "support";
|
|
2840
|
+
/** Hub-only distinction. App peers receive separate held and unconfirmed message types. */
|
|
2841
|
+
reason?: "unconfirmed" | "held" | "reverted";
|
|
2842
|
+
reference: string;
|
|
2843
|
+
source: PayTransaction | null;
|
|
2844
|
+
delivery: PayTransaction | null;
|
|
2845
|
+
};
|
|
2846
|
+
type HubElementPaySourceMessage = PayEnvelope<"pay-source", HubElementPaySourcePayload>;
|
|
2847
|
+
/** A wallet saved to the signed-in account, by the fields the card draws: "MetaMask ••4e07". */
|
|
2848
|
+
interface HubElementPaySavedWallet {
|
|
2849
|
+
brand: string;
|
|
2850
|
+
name: string;
|
|
2851
|
+
addressTail: string;
|
|
2852
|
+
}
|
|
2853
|
+
/**
|
|
2854
|
+
* The payload of `pay-source-saved`: the first wallet saved to the signed-in account while `pay-source` names the
|
|
2855
|
+
* Stridge Wallet, else `null`. The hub never knows the amount, so the card weighs the balance and shows this wallet in
|
|
2856
|
+
* the account's place when the balance does not cover it.
|
|
2857
|
+
*/
|
|
2858
|
+
interface HubElementPaySourceSavedPayload {
|
|
2859
|
+
saved: HubElementPaySavedWallet | null;
|
|
2860
|
+
}
|
|
2861
|
+
type HubElementPaySourceSavedMessage = PayEnvelope<"pay-source-saved", HubElementPaySourceSavedPayload>;
|
|
2862
|
+
/**
|
|
2863
|
+
* A wallet the card may show, by the fields it draws, with its money: "MetaMask ••4e07", `cents` the dollars it holds
|
|
2864
|
+
* in the coins the pay path accepts. Display only: never an identity or a money input.
|
|
2865
|
+
*/
|
|
2866
|
+
interface HubElementPayFundedWallet {
|
|
2867
|
+
/** `saved` to the signed-in account, or `last-used` by this browser. */
|
|
2868
|
+
kind: "saved" | "last-used";
|
|
2869
|
+
brand: string;
|
|
2870
|
+
name: string;
|
|
2871
|
+
addressTail: string;
|
|
2872
|
+
/** Whole cents, rounded down: a safe integer from 0. */
|
|
2873
|
+
cents: number;
|
|
2874
|
+
/** The wallet this browser paid the app with last. */
|
|
2875
|
+
lastUsed: boolean;
|
|
2876
|
+
}
|
|
2877
|
+
/**
|
|
2878
|
+
* The payload of `pay-source-funds`: the money of the wallets the card may show for the current `pay-source`, as the hub
|
|
2879
|
+
* read it for each one's address; a wallet whose read failed is left out.
|
|
2880
|
+
*/
|
|
2881
|
+
interface HubElementPaySourceFundsPayload {
|
|
2882
|
+
wallets: readonly HubElementPayFundedWallet[];
|
|
2883
|
+
}
|
|
2884
|
+
type HubElementPaySourceFundsMessage = PayEnvelope<"pay-source-funds", HubElementPaySourceFundsPayload>;
|
|
2885
|
+
/**
|
|
2886
|
+
* `pay-source-current`: the `pay-source` and `pay-source-saved` before it on the same stream are the hub frame's current
|
|
2887
|
+
* pick, so the card replaces its own record of the last pick with them. No payload.
|
|
2888
|
+
*/
|
|
2889
|
+
type HubElementPaySourceCurrentMessage = PayEnvelope<"pay-source-current", EmptyPayload>;
|
|
2890
|
+
/** Derived eligibility shared only between hub-origin documents. No account identifier leaves this stream. */
|
|
2891
|
+
interface HubElementPayOwnerPayload {
|
|
2892
|
+
paymentId: string;
|
|
2893
|
+
held: "nothing-sent" | "may-sent" | null;
|
|
2894
|
+
}
|
|
2895
|
+
type HubElementPayOwnerMessage = PayEnvelope<"pay-owner", HubElementPayOwnerPayload>;
|
|
2896
|
+
type WindowRelayPayOwnerPayload = Omit<WindowRelayPayProgressPayload, "progress"> & {
|
|
2897
|
+
owner: HubElementPayOwnerPayload;
|
|
2898
|
+
};
|
|
2899
|
+
type WindowRelayPayOwnerMessage = PayEnvelope<"relay-pay-owner", WindowRelayPayOwnerPayload>;
|
|
2900
|
+
type HubElementPayProgressMessage = PayEnvelope<"pay-progress", HubElementPayProgressPayload>;
|
|
2901
|
+
/** `pay-unsent`: the failed `pay-progress` envelope `progressId` names belongs to a payment that was never sent. */
|
|
2902
|
+
interface HubElementPayUnsentPayload {
|
|
2903
|
+
paymentId: string;
|
|
2904
|
+
progressId: string;
|
|
2905
|
+
}
|
|
2906
|
+
type HubElementPayUnsentMessage = PayEnvelope<"pay-unsent", HubElementPayUnsentPayload>;
|
|
2907
|
+
/** `relay-pay-unsent`: as `pay-unsent`, naming the `relay-pay-progress` it proves by its `sequence`. */
|
|
2908
|
+
type WindowRelayPayUnsentPayload = Omit<WindowRelayPayProgressPayload, "progress"> & {
|
|
2909
|
+
paymentId: string;
|
|
2910
|
+
progressSequence: number;
|
|
2911
|
+
};
|
|
2912
|
+
type WindowRelayPayUnsentMessage = PayEnvelope<"relay-pay-unsent", WindowRelayPayUnsentPayload>;
|
|
2913
|
+
/** Checkout results share the relay pay stream and its operation correlation. */
|
|
2914
|
+
interface WindowRelayCheckoutResultPayload {
|
|
2915
|
+
relayId: string;
|
|
2916
|
+
requestId: string;
|
|
2917
|
+
sequence: number;
|
|
2918
|
+
checkout: HubElementCheckoutResultPayload;
|
|
2919
|
+
}
|
|
2920
|
+
type WindowRelayCheckoutResultMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutResult, WindowRelayCheckoutResultPayload>;
|
|
2921
|
+
/** The paying wallet of a checkout, on the relay pay stream as its result is. */
|
|
2922
|
+
interface WindowRelayCheckoutWalletPayload {
|
|
2923
|
+
relayId: string;
|
|
2924
|
+
requestId: string;
|
|
2925
|
+
sequence: number;
|
|
2926
|
+
wallet: HubElementCheckoutWalletPayload;
|
|
2927
|
+
}
|
|
2928
|
+
type WindowRelayCheckoutWalletMessage = PayEnvelope<typeof SUA_RELAY_CONTROL_MESSAGE_TYPES.checkoutWallet, WindowRelayCheckoutWalletPayload>;
|
|
2929
|
+
//#endregion
|
|
2930
|
+
//#region src/protocol/codec.d.ts
|
|
2931
|
+
type SuaMessage = AppMessage | HubMessage | HubAppElementMessage | ElementMessage | AppHubFrameMessage | HubFrameAppMessage | ElementWindowMessage | WindowElementMessage | ElementHubMessage | HubElementMessage | AppWindowStateMessage | RelayAccountEmailMessage | WindowAccountEmailMessage | AppWindowAccountEmailMessage | AppWindowAccountEmailRefreshMessage | AppWindowAccountEmailRefreshReplyMessage;
|
|
2932
|
+
/**
|
|
2933
|
+
* The messages that carry a payment's raw destination ask, legacy key included: the app's pay and deposit requests as
|
|
2934
|
+
* the hub decodes them, the element's pay request to the hub, and the progress and checkout records the hub binds to
|
|
2935
|
+
* it. The internal entry types them with the legacy key; the published SDK types them without it.
|
|
2936
|
+
*/
|
|
2937
|
+
type HubAskMessage = HubAppElementPayRequestMessage | HubAppElementDepositRequestMessage | HubPayRequestMessage | HubElementPayProgressMessage | HubElementCheckoutResultMessage | HubElementCheckoutHeldMessage | WindowRelayPayProgressMessage | WindowRelayCheckoutResultMessage;
|
|
2938
|
+
/** `T` without the legacy key, on an object that declares it; `null` passes through, other keys keep their types. */
|
|
2939
|
+
type DropAsk<T> = T extends object ? Omit<T, "payoutAddress"> : T;
|
|
2940
|
+
/** A payload whose `request` declares the legacy key, in each phase that has one; other phases stay as they are. */
|
|
2941
|
+
type DropRequestAsk<P> = P extends {
|
|
2942
|
+
request: unknown;
|
|
2943
|
+
} ? Omit<P, "request"> & {
|
|
2944
|
+
request: DropAsk<P["request"]>;
|
|
2945
|
+
} : P;
|
|
2946
|
+
/** {@link HubAskMessage} without the legacy key: removed only on the objects that declare it. */
|
|
2947
|
+
type PublicAskMessage = AppElementPayRequestMessage | AppElementDepositRequestMessage | PayEnvelope<HubPayRequestMessage["type"], DropAsk<HubPayRequestPayload>> | PayEnvelope<HubElementPayProgressMessage["type"], DropRequestAsk<HubElementPayProgressPayload>> | PayEnvelope<HubElementCheckoutResultMessage["type"], DropRequestAsk<HubElementCheckoutResultPayload>> | PayEnvelope<HubElementCheckoutHeldMessage["type"], DropRequestAsk<HubElementCheckoutHeldPayload>> | PayEnvelope<WindowRelayPayProgressMessage["type"], Omit<WindowRelayPayProgressPayload, "progress"> & {
|
|
2948
|
+
progress: DropRequestAsk<HubElementPayProgressPayload>;
|
|
2949
|
+
}> | PayEnvelope<WindowRelayCheckoutResultMessage["type"], Omit<WindowRelayCheckoutResultPayload, "checkout"> & {
|
|
2950
|
+
checkout: DropRequestAsk<HubElementCheckoutResultPayload>;
|
|
2951
|
+
}>;
|
|
2952
|
+
/** The messages the published SDK types: every message, with the legacy key taken out of the ones that carry it. */
|
|
2953
|
+
type PayPublicMessage = Exclude<SuaMessage, HubAskMessage> | PublicAskMessage;
|
|
2954
|
+
type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
2955
|
+
declare const decodedMessage: unique symbol;
|
|
2956
|
+
/** Only decoders produce this proof; the brand adds no wire field. */
|
|
2957
|
+
type DecodedMessage<T extends PayPublicMessage = PayPublicMessage> = DeepReadonly<T> & {
|
|
2958
|
+
readonly [decodedMessage]: true;
|
|
2959
|
+
};
|
|
2960
|
+
/** {@link DecodedMessage} over every message, the legacy key included; the internal entry names it `DecodedMessage`. */
|
|
2961
|
+
type HubDecodedMessage<T extends SuaMessage = SuaMessage> = DeepReadonly<T> & {
|
|
2962
|
+
readonly [decodedMessage]: true;
|
|
2963
|
+
};
|
|
2964
|
+
type ForbidErrorFields = { [K in Exclude<keyof HubError, "request">]?: never; };
|
|
2965
|
+
type EnvelopePayload<T extends SuaMessage> = T extends {
|
|
2966
|
+
type: "result";
|
|
2967
|
+
} ? T["payload"] & ForbidErrorFields : T["payload"];
|
|
2968
|
+
type PayEnvelopeArgs<T extends SuaMessage = SuaMessage> = T extends SuaMessage ? [id: string, type: T["type"], payload: EnvelopePayload<T>] : never;
|
|
2969
|
+
declare function createPayEnvelope<const TArgs extends PayEnvelopeArgs<PayPublicMessage>>(...[id, type, payload]: TArgs): Extract<PayPublicMessage, {
|
|
2970
|
+
type: TArgs[1];
|
|
2971
|
+
}>;
|
|
2972
|
+
/** {@link createPayEnvelope} over every message, the legacy key included; the internal entry names it `createPayEnvelope`. */
|
|
2973
|
+
declare function createHubSuaEnvelope<const TArgs extends PayEnvelopeArgs>(...[id, type, payload]: TArgs): Extract<SuaMessage, {
|
|
2974
|
+
type: TArgs[1];
|
|
2975
|
+
}>;
|
|
2976
|
+
//#endregion
|
|
2977
|
+
//#region src/protocol/guards.d.ts
|
|
2978
|
+
/**
|
|
2979
|
+
* Reports whether `value` is a message to sign: a non-empty string whose UTF-8 encoding is at most
|
|
2980
|
+
* `MAX_SIGN_MESSAGE_BYTES` bytes. Its UTF-16 length is checked first, so a huge string is never encoded.
|
|
2981
|
+
*/
|
|
2982
|
+
declare function isSignText(value: unknown): value is string;
|
|
2983
|
+
/**
|
|
2984
|
+
* Reports whether `value` is a hub frame name: a string of 1 to `MAX_MESSAGE_ID_LENGTH` characters matching
|
|
2985
|
+
* {@link HUB_FRAME_NAME_PATTERN}. The length is checked first, so a huge string never reaches the regex.
|
|
2986
|
+
*/
|
|
2987
|
+
declare function isHubFrameName(value: unknown): value is string;
|
|
2988
|
+
/**
|
|
2989
|
+
* Reports whether `value` is a hub build id: 1 to `MAX_HUB_BUILD_ID_LENGTH` characters matching
|
|
2990
|
+
* {@link HUB_BUILD_ID_PATTERN}. The length is checked first, so a huge string never reaches the regex.
|
|
2991
|
+
*/
|
|
2992
|
+
declare function isHubBuildId(value: unknown): value is string;
|
|
2993
|
+
/**
|
|
2994
|
+
* Reports whether `value` is shaped like an envelope of this protocol, whatever its version, type or payload: a plain
|
|
2995
|
+
* object (prototype `Object.prototype` or `null`) with `protocol === "stridge-sua"`, a positive integer `version`, a
|
|
2996
|
+
* non-empty string `id` of at most `MAX_MESSAGE_ID_LENGTH` characters, a non-empty string `type`, and a plain-object
|
|
2997
|
+
* `payload`. Extra keys are allowed here.
|
|
2998
|
+
*
|
|
2999
|
+
* The channel uses it to drop foreign `postMessage` traffic cheaply and to tell "ours, but another version" (log it)
|
|
3000
|
+
* from noise. It does not check the sender's origin; the channel does.
|
|
3001
|
+
*/
|
|
3002
|
+
declare function isSuaEnvelope(value: unknown): value is PayEnvelope<string, unknown>;
|
|
3003
|
+
/**
|
|
3004
|
+
* Reports whether `value` is a well-formed app → hub message ({@link AppMessage}), and rejects every other shape.
|
|
3005
|
+
*
|
|
3006
|
+
* Envelope: exactly the keys `protocol`, `version`, `id`, `type`, `payload`; `protocol === PAY_PROTOCOL`; `version
|
|
3007
|
+
* === SUA_PROTOCOL_VERSION`; `id` a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters; `payload` a plain
|
|
3008
|
+
* object. Then, by `type` (any other type is rejected):
|
|
3009
|
+
*
|
|
3010
|
+
* - `init` — payload keys exactly `appId` and `appearance`; `appId` matches `APP_ID_PATTERN`; `appearance` is a valid
|
|
3011
|
+
* appearance.
|
|
3012
|
+
* - `appearance` — payload key exactly `appearance`, a valid appearance.
|
|
3013
|
+
* - `sign-in`, `sign-out`, `disconnect` — payload is `{}` (no keys).
|
|
3014
|
+
* - `fund` — payload is `{}` or exactly `start`, one of `PAY_FUND_START_SCREENS`.
|
|
3015
|
+
* - `fund-cancel` — payload is `{}`; the hub matches its envelope id to the pending Fund request.
|
|
3016
|
+
* - `sign` — payload key exactly `message`: a non-empty string whose UTF-8 encoding is at most
|
|
3017
|
+
* `MAX_SIGN_MESSAGE_BYTES` bytes (its UTF-16 length is checked first, so a huge string is never encoded).
|
|
3018
|
+
*
|
|
3019
|
+
* An appearance carries `theme` `"dark"` or `"light"`. The decoder also accepts and discards a legacy `accent` key.
|
|
3020
|
+
*
|
|
3021
|
+
* Throughout, "plain object" means a non-null, non-array object whose prototype is `Object.prototype` or `null`; "exact
|
|
3022
|
+
* keys" means no key outside the listed ones; an optional key whose value is `undefined` counts as absent. Never
|
|
3023
|
+
* throws.
|
|
3024
|
+
*/
|
|
3025
|
+
declare function isAppMessage(value: unknown): value is AppMessage;
|
|
3026
|
+
declare function decodeAppMessage(value: unknown): HubDecodedMessage<AppMessage> | undefined;
|
|
3027
|
+
/**
|
|
3028
|
+
* Reports whether `value` is a well-formed hub → app message ({@link HubMessage}), and rejects every other shape.
|
|
3029
|
+
*
|
|
3030
|
+
* Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):
|
|
3031
|
+
*
|
|
3032
|
+
* - `ready`, `overlay-open`, `overlay-close`, `fund-received` — payload is `{}`. The app matches the Fund receipt's id.
|
|
3033
|
+
* - `transport` — payload key exactly `mode`: `"overlay"` or `"popup"`.
|
|
3034
|
+
* - `state` — payload keys within `status`, `evmAddress`, `keypairExpiresAt`; `status` is a `HubStatus`;
|
|
3035
|
+
* `evmAddress`, when present, matches `EVM_ADDRESS_PATTERN`; `keypairExpiresAt`, when present, is a string that
|
|
3036
|
+
* `Date.parse` reads as a finite number.
|
|
3037
|
+
* - `result` — payload keyed by `request`: `init`, `sign-out`, `disconnect` and `fund` have no other
|
|
3038
|
+
* key;
|
|
3039
|
+
* `sign-in` has exactly `evmAddress` (matching `EVM_ADDRESS_PATTERN`); `sign` has exactly `signature`: `0x`, 128
|
|
3040
|
+
* lowercase hex digits, then `1b` or `1c` (132 characters). Any other `request` is rejected.
|
|
3041
|
+
* - `error` — payload keys within `request`, `code`, `message`, `retryAfterSeconds`; `request` is a `HubRequestType`;
|
|
3042
|
+
* `code` is a `HubErrorCode`; `message` is a string of at most `MAX_ERROR_MESSAGE_LENGTH` characters (it may be
|
|
3043
|
+
* empty); `retryAfterSeconds`, when present, is a non-negative safe integer.
|
|
3044
|
+
*
|
|
3045
|
+
* The same plain-object, exact-key and `undefined`-as-absent rules apply. Never throws.
|
|
3046
|
+
*/
|
|
3047
|
+
declare function isHubMessage(value: unknown): value is HubMessage;
|
|
3048
|
+
declare function decodeHubMessage(value: unknown): DecodedMessage<HubMessage> | undefined;
|
|
3049
|
+
/**
|
|
3050
|
+
* Reports whether `value` is a well-formed app → Pay element message ({@link AppElementMessage}), and rejects every
|
|
3051
|
+
* other shape, including the app → hub `init` and ceremony requests.
|
|
3052
|
+
*
|
|
3053
|
+
* Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):
|
|
3054
|
+
*
|
|
3055
|
+
* - `element-init` — payload keys exactly `appId` (matching `APP_ID_PATTERN`), `hubFrame` (1 to
|
|
3056
|
+
* `MAX_MESSAGE_ID_LENGTH` characters: an ASCII letter or digit, then ASCII letters, digits, `_` or `-`) and
|
|
3057
|
+
* `appearance` (a valid appearance, as for {@link isAppMessage}). All three are required; any
|
|
3058
|
+
* other key, a build id included, is rejected.
|
|
3059
|
+
* - `element-config` — one full bundle with exactly `revision`, `labels`, `action` and `showBalance`; `labels` has
|
|
3060
|
+
* at most `button`, `actionExpired`, `done`, `doneDescription`, `balanceLabel`; `action` is `null` or exactly
|
|
3061
|
+
* `attemptId` (a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters), `message` (as for `sign`) and
|
|
3062
|
+
* `label`; `showBalance` is a boolean.
|
|
3063
|
+
*
|
|
3064
|
+
* `revision` is a safe integer from 1. Every label, the action's included, is a string of at most
|
|
3065
|
+
* `MAX_ELEMENT_LABEL_LENGTH` characters and may be empty.
|
|
3066
|
+
* - `focus` — payload is `{}`.
|
|
3067
|
+
* - `appearance` — as for {@link isAppMessage}.
|
|
3068
|
+
* - `element-action-eligibility` — payload keys exactly `documentId` (a lowercase canonical version-4 UUID),
|
|
3069
|
+
* `initId`, `configId` and `attemptId` (each a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters),
|
|
3070
|
+
* `revision` (a safe integer from 1) and `eligible` (a boolean).
|
|
3071
|
+
* - `element-reload-grant` — payload keys exactly `documentId` and `initId`, as above, and `granted` (a boolean). No
|
|
3072
|
+
* URL, build id or counter.
|
|
3073
|
+
* - `element-check-status-capability` — payload keys exactly `documentId` and `initId`, as above, and `supported`
|
|
3074
|
+
* (a boolean). The receiver matches the accepted document and init.
|
|
3075
|
+
* - `element-check-status-settled` — exactly the five correlation fields of `element-action-eligibility` without
|
|
3076
|
+
* `eligible`. The receiver matches the pending Check status request's envelope id and all payload fields.
|
|
3077
|
+
*
|
|
3078
|
+
* The same plain-object, exact-key and `undefined`-as-absent rules apply. A legacy `kind` key is rejected, even when
|
|
3079
|
+
* its value is `undefined`. It checks shape only: the channel checks the sender and origin, binds `element-init`'s
|
|
3080
|
+
* app id to the served app and its hub frame to any URL hint, and matches each lifetime answer to its pending
|
|
3081
|
+
* request. Never throws.
|
|
3082
|
+
*/
|
|
3083
|
+
declare function isAppElementMessage(value: unknown): value is AppElementMessage;
|
|
3084
|
+
declare function decodeAppElementMessage(value: unknown): HubDecodedMessage<HubAppElementMessage> | undefined;
|
|
3085
|
+
/**
|
|
3086
|
+
* Reports whether `value` is a well-formed Pay element → app message ({@link ElementMessage}), and rejects every other
|
|
3087
|
+
* shape, including every app → hub, hub → app and app → Pay element message.
|
|
3088
|
+
*
|
|
3089
|
+
* Envelope: the same rules as {@link isAppMessage}. Then, by `type` (any other type is rejected):
|
|
3090
|
+
*
|
|
3091
|
+
* - `element-ready`, `element-accepted` — payload is `{}`.
|
|
3092
|
+
* - `element-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most
|
|
3093
|
+
* `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty). No `request` key.
|
|
3094
|
+
* - `element-config-ack` — payload key exactly `revision`, a safe integer from 1.
|
|
3095
|
+
* - `resize` — payload keys exactly `blockSize`, a finite number from 0 to `MAX_ELEMENT_BLOCK_SIZE`, and `durationMs`,
|
|
3096
|
+
* a safe integer from 0 to `MAX_ELEMENT_RESIZE_DURATION_MS`. Both are required.
|
|
3097
|
+
* - `signed` — payload keys exactly `signature` (as for a sign `result`), `message` (as for `sign`) and `attemptId` (a
|
|
3098
|
+
* non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters).
|
|
3099
|
+
* - `failed` — payload keyed by `request`, with `code` an `ElementFailureCode`, `message` as for `element-refused`,
|
|
3100
|
+
* and an optional `retryAfterSeconds`, a non-negative safe integer. `sign` also requires `attemptId`, as for
|
|
3101
|
+
* `signed`; `sign-in`, `sign-out`, `disconnect` and `fund` must not hold the `attemptId` key. Any other
|
|
3102
|
+
* `request`, `init` included, is rejected.
|
|
3103
|
+
* - `menu-anchor` — payload key exactly `rect`: exactly `x`, `y`, `width`, `height`, each a finite number; `x` and `y`
|
|
3104
|
+
* within ±`MAX_MENU_RECT_VALUE`, `width` and `height` from 0 to `MAX_MENU_RECT_VALUE`. Fractions are valid.
|
|
3105
|
+
* - `element-action-check` — payload keys exactly `documentId` (a lowercase canonical version-4 UUID), `initId`,
|
|
3106
|
+
* `configId` and `attemptId` (each a non-empty string of at most `MAX_MESSAGE_ID_LENGTH` characters) and `revision`
|
|
3107
|
+
* (a safe integer from 1).
|
|
3108
|
+
* - `element-reload-request` — payload keys exactly `documentId` and `initId`, as above, and `reason`
|
|
3109
|
+
* (`build-mismatch`). No build id or URL.
|
|
3110
|
+
* - `element-connected` — payload keys exactly `documentId` and `initId`, as above, `sequence` (a safe integer from 1)
|
|
3111
|
+
* and `evmAddress` (matching `EVM_ADDRESS_PATTERN`). The receiver checks the current init, pinned document and
|
|
3112
|
+
* increasing sequence; this guard checks only their shape.
|
|
3113
|
+
* - `element-view-shown` — payload is `{}`.
|
|
3114
|
+
* - `element-load-failed` — payload key exactly `reason` (`hub-frame` or `internal`).
|
|
3115
|
+
* - `element-check-status-request` — exactly the five correlation fields of `element-action-check`. Requires a
|
|
3116
|
+
* settlement response despite its notification-table entry. The receiver checks the current config and spent
|
|
3117
|
+
* attempt before invoking the app's callback; shape validation alone does not prove either.
|
|
3118
|
+
*
|
|
3119
|
+
* The same plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel checks the
|
|
3120
|
+
* sender, correlates answers by `id`, and matches a `signed` or `failed` notice to its captured attempt. Never throws.
|
|
3121
|
+
*/
|
|
3122
|
+
declare function isElementMessage(value: unknown): value is ElementMessage;
|
|
3123
|
+
declare function decodeElementMessage(value: unknown): DecodedMessage<ElementMessage> | undefined;
|
|
3124
|
+
/**
|
|
3125
|
+
* Reports whether `value` is a well-formed app → hub frame message ({@link AppHubFrameMessage}), and rejects every
|
|
3126
|
+
* other shape. It accepts every message {@link isAppMessage} accepts, by the same rules, and adds:
|
|
3127
|
+
*
|
|
3128
|
+
* - `show-menu` — payload key exactly `anchor`: a rect as for `menu-anchor`, in the app's viewport.
|
|
3129
|
+
*
|
|
3130
|
+
* The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel
|
|
3131
|
+
* checks the sender. Never throws.
|
|
3132
|
+
*/
|
|
3133
|
+
declare function isAppHubFrameMessage(value: unknown): value is AppHubFrameMessage;
|
|
3134
|
+
declare function decodeAppHubFrameMessage(value: unknown): HubDecodedMessage<AppHubFrameMessage> | undefined;
|
|
3135
|
+
/**
|
|
3136
|
+
* Reports whether `value` is a well-formed hub frame → app message ({@link HubFrameAppMessage}), and rejects every
|
|
3137
|
+
* other shape. It accepts every message {@link isHubMessage} accepts, by the same rules, and adds:
|
|
3138
|
+
*
|
|
3139
|
+
* - `activity` — payload key exactly `pending`, a boolean.
|
|
3140
|
+
* - `menu-accepted` — payload is `{}`.
|
|
3141
|
+
* - `menu-refused` — payload keys `code` (a `HubErrorCode`), `message` (a string of at most
|
|
3142
|
+
* `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty) and an optional `retryAfterSeconds`, a non-negative safe
|
|
3143
|
+
* integer. No `request` key.
|
|
3144
|
+
*
|
|
3145
|
+
* `show-menu` is not a `HubRequestType`, so a `result` or `error` for it is rejected. The same envelope, plain-object,
|
|
3146
|
+
* exact-key and `undefined`-as-absent rules apply. It checks shape only: the channel checks the sender and correlates
|
|
3147
|
+
* the menu answers by `id`. Never throws.
|
|
3148
|
+
*/
|
|
3149
|
+
declare function isHubFrameAppMessage(value: unknown): value is HubFrameAppMessage;
|
|
3150
|
+
declare function decodeHubFrameAppMessage(value: unknown): DecodedMessage<HubFrameAppMessage> | undefined;
|
|
3151
|
+
/**
|
|
3152
|
+
* Reports whether `value` is a well-formed Pay element → Pay window message ({@link ElementWindowMessage}), and
|
|
3153
|
+
* rejects every other shape, the ordinary `init` included. By `type`:
|
|
3154
|
+
*
|
|
3155
|
+
* - `relay-init` — payload keys exactly `appId` (matching `APP_ID_PATTERN`), `appOrigin` and `appearance` (a valid
|
|
3156
|
+
* appearance). `appOrigin` is a string of 1 to `MAX_APP_ORIGIN_LENGTH` characters that `URL` reads as an `http:` or
|
|
3157
|
+
* `https:` URL whose `origin` is the string itself: no path, trailing slash, credentials, query, fragment, default
|
|
3158
|
+
* port or other spelling of the same origin.
|
|
3159
|
+
* - `appearance`, `sign-in`, `sign`, `sign-out`, `disconnect`, `fund` — as for {@link isAppMessage}.
|
|
3160
|
+
* - `relay-close` — payload keys exactly `relayId` and `requestId` (each a non-empty string of at most
|
|
3161
|
+
* `MAX_MESSAGE_ID_LENGTH` characters), `request` (a ceremony request, never `init`) and `cause` (`window-cancel` or
|
|
3162
|
+
* `teardown`).
|
|
3163
|
+
*
|
|
3164
|
+
* The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the Sua
|
|
3165
|
+
* window checks the sender, binds `appId` to the app it serves, checks `appOrigin` against the app's registry and
|
|
3166
|
+
* matches a `relay-close` to its current operation. Never throws.
|
|
3167
|
+
*/
|
|
3168
|
+
declare function isElementWindowMessage(value: unknown): value is ElementWindowMessage;
|
|
3169
|
+
declare function decodeElementWindowMessage(value: unknown): HubDecodedMessage<ElementWindowMessage> | undefined;
|
|
3170
|
+
/**
|
|
3171
|
+
* Reports whether `value` is a well-formed Pay window → Pay element message ({@link WindowElementMessage}), and
|
|
3172
|
+
* rejects every other shape. By `type`:
|
|
3173
|
+
*
|
|
3174
|
+
* - `relay-build` — payload key exactly `buildId` (1 to `MAX_HUB_BUILD_ID_LENGTH` ASCII letters, digits, `_` or `-`,
|
|
3175
|
+
* starting with a letter or digit), as for `attach-accepted`.
|
|
3176
|
+
* - `relay-accepted` — payload is `{}`.
|
|
3177
|
+
* - `relay-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most
|
|
3178
|
+
* `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty). No `request` key.
|
|
3179
|
+
* - `ready`, `transport`, `state`, `overlay-open`, `overlay-close` — as for {@link isHubMessage}.
|
|
3180
|
+
* - `result`, `error` — as for {@link isHubMessage}, but `request` is `sign-in`, `sign`, `sign-out`, `disconnect`,
|
|
3181
|
+
* `fund`. An answer to `init` is rejected: `relay-init` has its own answers.
|
|
3182
|
+
* - `relay-close-accepted` — the `relay-close` payload rules of {@link isElementWindowMessage}.
|
|
3183
|
+
* - `relay-state` — payload keys exactly `relayId` and `requestId` (as for `relay-close`), `sequence` (a safe integer
|
|
3184
|
+
* from 1) and `state` (as for `state`, with a `keypairExpiresAt` of at most `MAX_RELAY_STATE_EXPIRY_LENGTH`
|
|
3185
|
+
* characters, its length checked before it is parsed).
|
|
3186
|
+
* - `relay-pay-progress` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and
|
|
3187
|
+
* `progress` (a link C `pay-progress` payload).
|
|
3188
|
+
* - `relay-pay-source` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and
|
|
3189
|
+
* `remembered` (`null`, or a link C `pay-source` `remembered`).
|
|
3190
|
+
* - `relay-pay-source-saved` — payload keys exactly `relayId`, `requestId`, `sequence` (as for `relay-state`) and
|
|
3191
|
+
* `saved` (`null`, or a link C `pay-source-saved` `saved`).
|
|
3192
|
+
* - `checkout-held` — the link C payload: the Pay window's own stored checkout for the `pay` it admitted.
|
|
3193
|
+
*
|
|
3194
|
+
* The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape only: the Sua
|
|
3195
|
+
* element checks the sender and correlates each answer and state with its relay and operation. Never throws.
|
|
3196
|
+
*/
|
|
3197
|
+
declare function isWindowElementMessage(value: unknown): value is WindowElementMessage;
|
|
3198
|
+
declare function decodeWindowElementMessage(value: unknown): HubDecodedMessage<WindowElementMessage> | undefined;
|
|
3199
|
+
/**
|
|
3200
|
+
* Reports whether `value` is a well-formed Pay element → hub frame message ({@link ElementHubMessage}, link C), and
|
|
3201
|
+
* rejects every other shape. By `type`:
|
|
3202
|
+
*
|
|
3203
|
+
* - `hub-probe`, `attach` — payload is exactly `{}`; a legacy `kind` key is rejected, even when its value is `undefined`.
|
|
3204
|
+
* - `attach-confirm` — payload keys exactly `attachmentId` (a lowercase canonical version-4 UUID) and `buildId` (1 to
|
|
3205
|
+
* `MAX_HUB_BUILD_ID_LENGTH` ASCII letters, digits, `_` or `-`, starting with a letter or digit).
|
|
3206
|
+
* - `detach` — payload key exactly `attachmentId`, as above.
|
|
3207
|
+
* - `window-opened` — payload keys exactly `windowId` and `requestId` (each a non-empty string of at most
|
|
3208
|
+
* `MAX_MESSAGE_ID_LENGTH` characters) and `request` (a ceremony request, never `init`).
|
|
3209
|
+
* - `window-result` — payload keys exactly `operationId`, `windowId`, `requestId` (ids as above) and `result` (a
|
|
3210
|
+
* ceremony `result` payload, as for {@link isWindowElementMessage}).
|
|
3211
|
+
* - `window-error` — the same ids and `error` (a ceremony `error` payload, as for {@link isWindowElementMessage}).
|
|
3212
|
+
* - `window-ended` — payload keys exactly `operationId` (an id, or `null`), `windowId` and `cause` (`settled`,
|
|
3213
|
+
* `window-cancel`, `window-lost` or `teardown`).
|
|
3214
|
+
* - `window-state` — payload keys exactly `operationId`, `windowId`, `requestId`, `relayId` (ids), `sequence` (a safe
|
|
3215
|
+
* integer from 1) and `state` (as for {@link isWindowElementMessage}'s `relay-state`).
|
|
3216
|
+
* - `sign-in`, `sign`, `sign-out`, `disconnect`, `fund` — as for {@link isAppMessage}.
|
|
3217
|
+
*
|
|
3218
|
+
* `init`, `appearance`, `result` and `error` are rejected. The same envelope, plain-object, exact-key and
|
|
3219
|
+
* `undefined`-as-absent rules apply. It checks shape only, and only the ordinary envelope id: the hub frame checks the
|
|
3220
|
+
* sender's document and relationship, the attachment's namespace and stream order, and matches every message to its
|
|
3221
|
+
* pending table. Never throws.
|
|
3222
|
+
*/
|
|
3223
|
+
declare function isElementHubMessage(value: unknown): value is ElementHubMessage;
|
|
3224
|
+
declare function decodeElementHubMessage(value: unknown): HubDecodedMessage<ElementHubMessage> | undefined;
|
|
3225
|
+
/**
|
|
3226
|
+
* Reports whether `value` is a well-formed hub frame → Pay element message ({@link HubElementMessage}, link C), and
|
|
3227
|
+
* rejects every other shape. By `type`:
|
|
3228
|
+
*
|
|
3229
|
+
* - `hub-probe-ack`, `pay-source-current` — payload is `{}`.
|
|
3230
|
+
* - `attach-accepted` — the `attach-confirm` payload rules of {@link isElementHubMessage}.
|
|
3231
|
+
* - `attach-refused` — payload keys exactly `code` (a `HubErrorCode`) and `message` (a string of at most
|
|
3232
|
+
* `MAX_ERROR_MESSAGE_LENGTH` characters, possibly empty).
|
|
3233
|
+
* - `balance` — payload key exactly `balance`: `{status: "loading"}` or `{status: "unavailable"}` with no other key,
|
|
3234
|
+
* or `{status: "ready", amount, currency?}` where `amount` is canonical dollars with exactly six decimals (no leading
|
|
3235
|
+
* zero, sign, grouping or exponent), at most `MAX_HUB_BALANCE_AMOUNT_LENGTH` characters and at most `2^256 - 1`
|
|
3236
|
+
* base units, and `currency`, when present, is `USD`.
|
|
3237
|
+
* - `window-accepted` — payload keys exactly `windowId` and `operationId`, each a non-empty string of at most
|
|
3238
|
+
* `MAX_MESSAGE_ID_LENGTH` characters.
|
|
3239
|
+
* - `window-refused` — payload keys exactly `windowId` (an id), `code` and `message` (as for `attach-refused`).
|
|
3240
|
+
* - `window-cancel` — payload keys exactly `operationId`, `windowId` (ids) and `cause` (`window-cancel` or
|
|
3241
|
+
* `teardown`).
|
|
3242
|
+
* - `state`, `transport` — as for {@link isHubMessage}.
|
|
3243
|
+
* - `activity` — as for {@link isHubFrameAppMessage}.
|
|
3244
|
+
* - `result`, `error` — as for {@link isWindowElementMessage}: never an answer to `init`.
|
|
3245
|
+
*
|
|
3246
|
+
* `overlay-hidden` requires an empty payload; its id names the initiating ceremony. `ready`, `overlay-open` and
|
|
3247
|
+
* `overlay-close` are rejected. The same envelope, plain-object, exact-key and `undefined`-as-absent
|
|
3248
|
+
* rules apply. It checks shape only, and only the ordinary envelope id: the Pay element checks the sender's document
|
|
3249
|
+
* and relationship, the attachment's namespace and stream order, and matches every answer to its pending request.
|
|
3250
|
+
* Never throws.
|
|
3251
|
+
*/
|
|
3252
|
+
declare function isHubElementMessage(value: unknown): value is HubElementMessage;
|
|
3253
|
+
declare function decodeHubElementMessage(value: unknown): HubDecodedMessage<HubElementMessage> | undefined;
|
|
3254
|
+
/**
|
|
3255
|
+
* Reports whether `value` is a well-formed app-owned Pay window → hub frame message ({@link AppWindowStateMessage}),
|
|
3256
|
+
* and rejects every other shape: `app-window-state` with payload keys exactly `appId` (matching `APP_ID_PATTERN`),
|
|
3257
|
+
* `appOrigin` (1 to `MAX_APP_ORIGIN_LENGTH` characters that `URL` reads as an `http:` or `https:` origin, spelled as
|
|
3258
|
+
* that origin), `sequence` (a safe integer from 1) and `state` (as for {@link isWindowElementMessage}'s
|
|
3259
|
+
* `relay-state`). The same envelope, plain-object, exact-key and `undefined`-as-absent rules apply. It checks shape
|
|
3260
|
+
* only: the hub frame checks the sender's document and relationship, the app connection and the order. Never throws.
|
|
3261
|
+
*/
|
|
3262
|
+
declare function isAppWindowHubMessage(value: unknown): value is AppWindowStateMessage;
|
|
3263
|
+
declare function decodeAppWindowHubMessage(value: unknown): HubDecodedMessage<AppWindowStateMessage> | undefined;
|
|
3264
|
+
/**
|
|
3265
|
+
* Decodes a Pay window → opener `relay-account-email` ({@link RelayAccountEmailMessage}) into a frozen snapshot, or
|
|
3266
|
+
* `undefined` for every other shape: payload keys exactly `relayId` and `requestId` (ids), `sequence` and
|
|
3267
|
+
* `stateSequence` (safe integers from 1), and `account`. `account` is `null`, or exactly `identityId` (1 to
|
|
3268
|
+
* `MAX_ACCOUNT_IDENTITY_LENGTH` characters), `evmAddress` (matching `EVM_ADDRESS_PATTERN`), `email` (`null`, or 1 to
|
|
3269
|
+
* `MAX_ACCOUNT_EMAIL_LENGTH` characters) and `validUntil` (a safe integer from 1); the identity and the email hold no
|
|
3270
|
+
* control, format, line-separator or paragraph-separator character. The same envelope, plain-object, exact-key and
|
|
3271
|
+
* `undefined`-as-absent rules as every other guard apply. It checks shape only: the receiver checks the sender's
|
|
3272
|
+
* document, the operation, the state it refers to and the lease. No other guard accepts it. Never throws, and never
|
|
3273
|
+
* reports what it rejected.
|
|
3274
|
+
*/
|
|
3275
|
+
declare function decodeRelayAccountEmailMessage(value: unknown): HubDecodedMessage<RelayAccountEmailMessage> | undefined;
|
|
3276
|
+
/**
|
|
3277
|
+
* Decodes a Pay element → hub frame `window-account-email` ({@link WindowAccountEmailMessage}) into a frozen snapshot,
|
|
3278
|
+
* or `undefined` for every other shape: payload keys exactly `operationId`, `windowId`, `requestId`, `relayId` (ids),
|
|
3279
|
+
* `sequence`, `stateSequence` and `account`, each as for {@link decodeRelayAccountEmailMessage}. It checks shape only,
|
|
3280
|
+
* and only the ordinary envelope id. No other guard accepts it. Never throws.
|
|
3281
|
+
*/
|
|
3282
|
+
declare function decodeWindowAccountEmailMessage(value: unknown): HubDecodedMessage<WindowAccountEmailMessage> | undefined;
|
|
3283
|
+
/**
|
|
3284
|
+
* Decodes an app-owned Pay window → hub frame `app-window-account-email` ({@link AppWindowAccountEmailMessage}) into a
|
|
3285
|
+
* frozen snapshot, or `undefined` for every other shape: payload keys exactly `appId` and `appOrigin` (as for
|
|
3286
|
+
* {@link isAppWindowHubMessage}), `sequence`, `stateSequence` and `account` (as for
|
|
3287
|
+
* {@link decodeRelayAccountEmailMessage}). It checks shape only. No other guard accepts it. Never throws.
|
|
3288
|
+
*/
|
|
3289
|
+
declare function decodeAppWindowAccountEmailMessage(value: unknown): HubDecodedMessage<AppWindowAccountEmailMessage> | undefined;
|
|
3290
|
+
/**
|
|
3291
|
+
* Decodes a hub frame → app-owned Pay window `app-window-account-email-refresh`
|
|
3292
|
+
* ({@link AppWindowAccountEmailRefreshMessage}) into a frozen snapshot, or `undefined` for every other shape: payload
|
|
3293
|
+
* keys exactly `appId` and `appOrigin` (as for {@link isAppWindowHubMessage}), `refreshId` (an id) and `stateSequence`
|
|
3294
|
+
* (a safe integer from 1). The same envelope, plain-object, exact-key and `undefined`-as-absent rules as every other
|
|
3295
|
+
* guard apply. It checks shape only: the Pay window checks that the sender is a hub frame of its app page and that the
|
|
3296
|
+
* state is its current one. No other guard accepts it. Never throws, and never reports what it rejected.
|
|
3297
|
+
*/
|
|
3298
|
+
declare function decodeAppWindowAccountEmailRefreshMessage(value: unknown): HubDecodedMessage<AppWindowAccountEmailRefreshMessage> | undefined;
|
|
3299
|
+
/**
|
|
3300
|
+
* Decodes an app-owned Pay window → hub frame `app-window-account-email-refresh-reply`
|
|
3301
|
+
* ({@link AppWindowAccountEmailRefreshReplyMessage}) into a frozen snapshot, or `undefined` for every other shape:
|
|
3302
|
+
* payload keys exactly `appId`, `appOrigin`, `refreshId` and `stateSequence` (as for
|
|
3303
|
+
* {@link decodeAppWindowAccountEmailRefreshMessage}), `checkedAt` (a safe integer from 1) and `account` (as for
|
|
3304
|
+
* {@link decodeRelayAccountEmailMessage}). It checks shape only: the frame checks the sender's document, its open
|
|
3305
|
+
* request, the state, the check time and the lease. No other guard accepts it. Never throws.
|
|
3306
|
+
*/
|
|
3307
|
+
declare function decodeAppWindowAccountEmailRefreshReplyMessage(value: unknown): HubDecodedMessage<AppWindowAccountEmailRefreshReplyMessage> | undefined;
|
|
3308
|
+
declare function isAppearance(value: unknown): value is HubAppearance;
|
|
3309
|
+
//#endregion
|
|
3310
|
+
export { HubAppElementDepositRequestMessage as $, EVM_ADDRESS_PATTERN as $a, HubError as $i, CeremonyError as $n, SUA_FUND_WINDOW_MESSAGE_TYPE as $o, ElementResizeMessage as $r, isElementDepositRequestPayload as $t, isSignText as A, RelayInitPayload as Aa, HubDiagnosticsDetailsMessage as Ai, AppElementReloadGrantPayload as An, PAY_CURRENCIES as Ao, ElementHubProbeMessage as Ar, PayFirstStep as At, AppElementPayRequestMessage as B, WindowAccountEmailPayload as Ba, HubDiagnosticsStatusPayload as Bi, AppSignMessage as Bn, PAY_FUND_MESSAGE_TYPES as Bo, ElementPayShownMessage as Br, WindowRelayPayOwnerMessage as Bt, isElementMessage as C, PayElementLoadFailureReason as Ca, HubActivityMessage as Ci, AppElementGeometryCompleteMessage as Cn, MAX_PAY_AMOUNT as Co, ElementGeometryCapabilitiesMessage as Cr, HubPayRequestMessage as Ct, isHubFrameAppMessage as D, RelayAccountEmailMessage as Da, HubAttachAcceptedMessage as Di, AppElementPageUrlMessage as Dn, MAX_RELAY_STATE_EXPIRY_LENGTH as Do, ElementGeometryTargetMessage as Dr, PayDestinationAddress as Dt, isHubElementMessage as E, RefusalPayload as Ea, HubAppearance as Ei, AppElementMessage as En, MAX_PAY_SOURCE_FUNDS_WALLETS as Eo, ElementGeometryLifetimePayload as Er, PayCurrency as Et, PayEnvelopeArgs as F, SuaElementReloadReason as Fa, HubDiagnosticsHeldKey as Fi, AppMessage as Fn, PAY_ELEMENT_LOAD_FAILURE_REASONS as Fo, ElementMenuAnchorMessage as Fr, PayTransaction as Ft, ElementHeldMessage as G, WindowRelayBuildPayload as Ga, HubElementOverlayHiddenMessage as Gi, AppWindowAccountEmailRefreshPayload as Gn, PAY_MESSAGE_TYPES as Go, ElementRelayClosePayload as Gr, WindowRelayPaySourcePayload as Gt, ElementCheckoutResultMessage as H, WindowErrorMessage as Ha, HubElementBalanceMessage as Hi, AppWindowAccountEmailMessage as Hn, PAY_FUND_START_SCREENS as Ho, ElementReadyMessage as Hr, WindowRelayPayProgressMessage as Ht, SuaMessage as I, SuaWindowCancelCause as Ia, HubDiagnosticsObservation as Ii, AppOverlayHiddenMessage as In, PAY_ELEMENT_MESSAGE_TYPES as Io, ElementMenuAnchorPayload as Ir, WindowRelayCheckoutResultMessage as It, ElementPayRequestAckMessage as J, WindowRelayRefusedMessage as Ja, HubElementWindowAcceptedPayload as Ji, AppWindowStateMessage as Jn, SESSION_HEADER_OMIT as Jo, ElementRelayPageUrlPayload as Jr, WindowRelayPayUnsentMessage as Jt, ElementPaidMessage as K, WindowRelayCloseAcceptedMessage as Ka, HubElementProbeAckMessage as Ki, AppWindowAccountEmailRefreshReplyMessage as Kn, PAY_PROTOCOL as Ko, ElementRelayInitMessage as Kr, WindowRelayPaySourceSavedMessage as Kt, createHubSuaEnvelope as L, SuaWindowEndCause as La, HubDiagnosticsSession as Li, AppShowMenuMessage as Ln, PAY_ELEMENT_NOTIFICATION_MESSAGE_TYPES as Lo, ElementMessage as Lr, WindowRelayCheckoutResultPayload as Lt, isWindowElementMessage as M, SignOutResult as Ma, HubDiagnosticsDetailsPayload as Mi, AppFundMessage as Mn, PAY_DESTINATION_RULE_PATTERN as Mo, ElementInitPayload as Mr, PayReceived as Mt, DecodedMessage as N, SignPayload as Na, HubDiagnosticsDisconnect as Ni, AppHubFrameMessage as Nn, PAY_ELEMENT_FAILURE_CODES as No, ElementLoadFailedMessage as Nr, PayRequestTerms as Nt, isHubFrameName as O, RelayAccountEmailPayload as Oa, HubAttachAcceptedPayload as Oi, AppElementPageUrlPayload as On, MAX_SIGN_MESSAGE_BYTES as Oo, ElementGeometryTargetPayload as Or, PayDestinationAsk as Ot, HubDecodedMessage as P, SignResult as Pa, HubDiagnosticsEntityStatus as Pi, AppInitMessage as Pn, PAY_ELEMENT_LIFETIME_MESSAGE_TYPES as Po, ElementLoadFailedPayload as Pr, PayTerms as Pt, ElementUnconfirmedMessage as Q, APP_ID_PATTERN as Qa, HubElementWindowRefusedPayload as Qi, CardElementLabels as Qn, SUA_ELEMENT_RELOAD_REASONS as Qo, ElementReloadRequestPayload as Qr, isElementCheckoutResultPayload as Qt, createPayEnvelope as R, TransportPayload as Ra, HubDiagnosticsSessionRead as Ri, AppShowMenuPayload as Rn, PAY_ELEMENT_PATH as Ro, ElementPageUrlMessage as Rr, WindowRelayCheckoutWalletMessage as Rt, isElementHubMessage as S, MenuRefusalPayload as Sa, FundWindowContinuationPayload as Si, AppElementGeometryCancelledMessage as Sn, MAX_PAGE_URL_LENGTH as So, ElementFailureCode as Sr, HubElementPayUnsentPayload as St, isHubBuildId as T, PayMenuRect as Ta, HubAppElementMessage as Ti, AppElementMenuEndedMessage as Tn, MAX_PAY_PAYOUT_ADDRESS_LENGTH as To, ElementGeometryEasing as Tr, LegacyPayDestinationAsk as Tt, ElementCheckoutResultPayload as U, WindowRelayAcceptedMessage as Ua, HubElementBalancePayload as Ui, AppWindowAccountEmailPayload as Un, PAY_HUB_FRAME_MESSAGE_TYPES as Uo, ElementRefusedMessage as Ur, WindowRelayPayProgressPayload as Ut, CheckoutFinalState as V, WindowElementMessage as Va, HubElementBalance as Vi, AppSignOutMessage as Vn, PAY_FUND_REQUEST_TYPE as Vo, ElementPayShownPayload as Vr, WindowRelayPayOwnerPayload as Vt, ElementDepositRequestPayload as W, WindowRelayBuildMessage as Wa, HubElementMessage as Wi, AppWindowAccountEmailRefreshMessage as Wn, PAY_JOBS as Wo, ElementRelayCloseMessage as Wr, WindowRelayPaySourceMessage as Wt, ElementPayRequestPayload as X, WindowRelayStatePayload as Xa, HubElementWindowCancelPayload as Xi, AppearancePayload as Xn, SUA_APP_WINDOW_MESSAGE_TYPES as Xo, ElementRelayPayShownPayload as Xr, answersPayAmount as Xt, ElementPayRequestAckPayload as Y, WindowRelayStateMessage as Ya, HubElementWindowCancelMessage as Yi, AppWindowStatePayload as Yn, SUA_ACCOUNT_EMAIL_MESSAGE_TYPES as Yo, ElementRelayPayShownMessage as Yr, WindowRelayPayUnsentPayload as Yt, ElementPaymentNoticePayload as Z, WindowResultMessage as Za, HubElementWindowRefusedMessage as Zi, CardElementConfig as Zn, SUA_ELEMENT_GEOMETRY_EASINGS as Zo, ElementReloadRequestMessage as Zr, comparePayAmounts as Zt, isAppElementMessage as _, HubTheme as _a, EmptyPayload as _i, AppElementCheckStatusCapabilityPayload as _n, MAX_ERROR_MESSAGE_LENGTH as _o, ElementConnectedPayload as _r, HubElementPaySourcePayload as _t, decodeAppWindowAccountEmailRefreshMessage as a, HubMenuEndedMessage as aa, ElementViewShownMessage as ai, samePayDestinationAsk as an, HUB_NEEDS_POPUP_MESSAGE as ao, ElementActionCheckPayload as ar, SUA_PROTOCOL_VERSION as as, HubElementCheckoutWalletMessage as at, isAppWindowHubMessage as b, InitPayload as ba, FundStartScreen as bi, AppElementConfigMessage as bn, MAX_MENU_RECT_VALUE as bo, ElementFailedMessage as br, HubElementPaySourceSavedPayload as bt, decodeElementHubMessage as c, HubOverlayCloseMessage as ca, ElementWindowErrorMessage as ci, AppAppearanceMessage as cn, HUB_SURFACE_POPUP as co, ElementAttachMessage as cr, SUA_WINDOW_CANCEL_CAUSES as cs, HubElementPayOwnerMessage as ct, decodeHubElementMessage as d, HubRequestType as da, ElementWindowOpenedMessage as di, AppDiagnosticsSubscribeMessage as dn, MAX_ACCOUNT_EMAIL_LENGTH as do, ElementCheckStatusRequestMessage as dr, utf8ToBytes as ds, HubElementPayProgressPayload as dt, HubErrorCode as ea, ElementResizePayload as ei, isElementPaidPayload as en, GUEST_COOKIE_ACCESS_HEADER as eo, CeremonyRequestType as er, SUA_GUEST_HANDOFF_MESSAGE_TYPE as es, HubAppElementPayRequestMessage as et, decodeHubFrameAppMessage as f, HubResult as fa, ElementWindowOpenedPayload as fi, AppDiagnosticsUnsubscribeMessage as fn, MAX_ACCOUNT_IDENTITY_LENGTH as fo, ElementCheckStatusRequestPayload as fr, HubElementPaySavedWallet as ft, decodeWindowElementMessage as g, HubStatus as ga, ElementWindowStatePayload as gi, AppElementCheckStatusCapabilityMessage as gn, MAX_ELEMENT_RESIZE_DURATION_MS as go, ElementConnectedMessage as gr, HubElementPaySourceMessage as gt, decodeWindowAccountEmailMessage as h, HubStateSnapshot as ha, ElementWindowStateMessage as hi, AppElementActionEligibilityPayload as hn, MAX_ELEMENT_LABEL_LENGTH as ho, ElementConfigPayload as hr, HubElementPaySourceFundsPayload as ht, decodeAppWindowAccountEmailMessage as i, HubMenuAcceptedMessage as ia, ElementSignedPayload as ii, sameLegacyPayDestinationAsk as in, HUB_GUEST_COOKIE_NAME as io, ElementActionCheckMessage as ir, SUA_PAY_REQUEST_TYPE as is, HubElementCheckoutResultPayload as it, isSuaEnvelope as j, SignInResult as ja, HubDiagnosticsDetailsObservation as ji, AppFundCancelMessage as jn, PAY_DESTINATION_ASSET_PATTERN as jo, ElementHubProbePayload as jr, PayJob as jt, isHubMessage as k, RelayCloseCause as ka, HubAttachRefusedMessage as ki, AppElementReloadGrantMessage as kn, PAY_AMOUNT_PATTERN as ko, ElementHubMessage as kr, PayDestinationRuleId as kt, decodeElementMessage as l, HubOverlayOpenMessage as la, ElementWindowErrorPayload as li, AppDiagnosticsDisconnectMessage as ln, HUB_URL_PARAMS as lo, ElementAttachPayload as lr, SUA_WINDOW_END_CAUSES as ls, HubElementPayOwnerPayload as lt, decodeRelayAccountEmailMessage as m, HubStateMessage as ma, ElementWindowResultPayload as mi, AppElementActionEligibilityMessage as mn, MAX_ELEMENT_BLOCK_SIZE as mo, ElementConfigAckPayload as mr, HubElementPaySourceFundsMessage as mt, decodeAppHubFrameMessage as n, HubFrameAppMessage as na, ElementSignFailure as ni, isElementPayRequestPayload as nn, HUB_CSRF_COOKIE_NAME as no, DisconnectResult as nr, SUA_LINK_C_MESSAGE_TYPES as ns, HubElementCheckoutHeldPayload as nt, decodeAppWindowAccountEmailRefreshReplyMessage as o, HubMenuRefusedMessage as oa, ElementWindowEndedMessage as oi, samePayTerms as on, HUB_PARTITIONED_GUEST_COOKIE_NAME as oo, ElementAttachConfirmMessage as or, SUA_RELAY_CONTROL_MESSAGE_TYPES as os, HubElementCheckoutWalletPayload as ot, decodeHubMessage as p, HubResultMessage as pa, ElementWindowResultMessage as pi, AppDisconnectMessage as pn, MAX_APP_ORIGIN_LENGTH as po, ElementConfigAckMessage as pr, HubElementPaySourceCurrentMessage as pt, ElementPaidPayload as q, WindowRelayCloseAcceptedPayload as qa, HubElementWindowAcceptedMessage as qi, AppWindowAccountEmailRefreshReplyPayload as qn, SESSION_HEADER as qo, ElementRelayPageUrlMessage as qr, WindowRelayPaySourceSavedPayload as qt, decodeAppMessage as r, HubFundReceivedMessage as ra, ElementSignedMessage as ri, payJobOf as rn, HUB_FRAME_NAME_PATTERN as ro, ElementAcceptedMessage as rr, SUA_LINK_C_STREAM_PREFIXES as rs, HubElementCheckoutResultMessage as rt, decodeAppWindowHubMessage as s, HubMessage as sa, ElementWindowEndedPayload as si, AccountEmailReportAccount as sn, HUB_SURFACE_ELEMENT as so, ElementAttachConfirmPayload as sr, SUA_RELAY_MESSAGE_TYPES as ss, HubElementPayFundedWallet as st, decodeAppElementMessage as t, HubErrorMessage as ta, ElementSignAction as ti, isElementPayRequestAckPayload as tn, HUB_BUILD_ID_PATTERN as to, CeremonyResult as tr, SUA_LINK_C_ID_SEPARATOR as ts, HubElementCheckoutHeldMessage as tt, decodeElementWindowMessage as u, HubReadyMessage as ua, ElementWindowMessage as ui, AppDiagnosticsInspectMessage as un, MAX_ACCOUNT_EMAIL_LEASE_MS as uo, ElementCeremonyFailure as ur, bytesToUtf8 as us, HubElementPayProgressMessage as ut, isAppHubFrameMessage as v, HubTransport as va, FundPayload as vi, AppElementCheckStatusSettledMessage as vn, MAX_HUB_BALANCE_AMOUNT_LENGTH as vo, ElementDetachMessage as vr, HubElementPaySourceRemembered as vt, isElementWindowMessage as w, PayEnvelope as wa, HubActivityPayload as wi, AppElementInitMessage as wn, MAX_PAY_ITEM_LENGTH as wo, ElementGeometryCapabilitiesPayload as wr, HubPayRequestPayload as wt, isAppearance as x, InitResult as xa, FundWindowContinuationMessage as xi, AppElementFocusMessage as xn, MAX_MESSAGE_ID_LENGTH as xo, ElementFailedPayload as xr, HubElementPayUnsentMessage as xt, isAppMessage as y, HubTransportMessage as ya, FundResult as yi, AppElementCheckStatusSettledPayload as yn, MAX_HUB_BUILD_ID_LENGTH as yo, ElementDetachPayload as yr, HubElementPaySourceSavedMessage as yt, AppElementDepositRequestMessage as z, WindowAccountEmailMessage as za, HubDiagnosticsStatusMessage as zi, AppSignInMessage as zn, PAY_FIRST_STEPS as zo, ElementPageUrlPayload as zr, WindowRelayCheckoutWalletPayload as zt };
|
|
3311
|
+
//# sourceMappingURL=guards-CQWGp5eP.d.ts.map
|