@seams/wallet 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.js +160 -140
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/linkDeviceBadge.js +90 -0
- package/dist/esm/sdk/{host-CHQwi-Nm.js → host-GawN20iA.js} +1 -1
- package/dist/esm/sdk/runtime-auth-TZw6JD8N.js +1 -0
- package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/esm/sdk/wallet-ui.css +1 -1
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/{host-CHQwi-Nm.js → host-GawN20iA.js} +1 -1
- package/dist/public/sdk/runtime-auth-TZw6JD8N.js +1 -0
- package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/sdk/wallet-ui.css +1 -1
- package/dist/public/wallet-assets.manifest.json +6 -6
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.d.ts +21 -3
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/linkDeviceBadge.d.ts +18 -0
- package/package.json +1 -1
- package/dist/esm/sdk/runtime-auth-DtpRz88X.js +0 -1
- package/dist/public/sdk/runtime-auth-DtpRz88X.js +0 -1
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Seams Wallet SDK
|
|
2
2
|
|
|
3
|
-
`@seams/wallet` **0.
|
|
3
|
+
`@seams/wallet` **0.13.0** provides browser wallet lifecycle, NEAR and EVM-family
|
|
4
4
|
threshold signing, React components, and hosted wallet runtime assets.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
pnpm add @seams/wallet@0.
|
|
9
|
+
pnpm add @seams/wallet@0.13.0
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
React integrations support React 18 and 19. Import the provider and UI from
|
|
13
13
|
`@seams/wallet/react` and its stylesheet from `@seams/wallet/react/styles`.
|
|
14
14
|
Keep the application package, wallet-origin assets, and
|
|
15
|
-
`@seams/wallet-server@0.
|
|
15
|
+
`@seams/wallet-server@0.13.0` on the matching release.
|
|
16
16
|
|
|
17
17
|
## Next release migration (unreleased)
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
264938a73999cf6e6b1da2cf1272943fb8258e8c3a5fee0fce16e21e0a64d0f3
|
|
@@ -7,6 +7,7 @@ import { PadlockIcon } from "../../../../../core/signingEngine/uiConfirm/ui/prea
|
|
|
7
7
|
import { blinkMenuItem } from "../../../../../utils/menuItemBlink.js";
|
|
8
8
|
import { accountDropdownIcon, backIcon, chevronIcon, fingerprintIcon, googleIcon, linkDeviceIcon, linkFailedIcon, mailIcon, recoveryIcon, rerollIcon } from "./icons.js";
|
|
9
9
|
import { AuthMenuFooter } from "./AuthMenuFooter.js";
|
|
10
|
+
import { linkDeviceDotRing, linkDeviceEmailOtpPresentation } from "./linkDeviceBadge.js";
|
|
10
11
|
import { Component, Fragment } from "preact";
|
|
11
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
|
|
12
13
|
//#region src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.tsx
|
|
@@ -33,7 +34,21 @@ function recoveryInputCharacters(code) {
|
|
|
33
34
|
}
|
|
34
35
|
return characters;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
const RECOVERY_CODE_SEPARATOR = /[\s\-\u2010-\u2015\u2212]/;
|
|
38
|
+
/** Characters the input dropped because no recovery code contains them, such as U. */
|
|
39
|
+
function rejectedRecoveryCharacters(input) {
|
|
40
|
+
const rejected = /* @__PURE__ */ new Set();
|
|
41
|
+
for (const character of input.toUpperCase()) {
|
|
42
|
+
if (RECOVERY_CODE_SEPARATOR.test(character)) continue;
|
|
43
|
+
if (recoveryInputCharacters(character)) continue;
|
|
44
|
+
rejected.add(character);
|
|
45
|
+
}
|
|
46
|
+
return Array.from(rejected).slice(0, 3);
|
|
47
|
+
}
|
|
48
|
+
function renderRecoveryCodeGroups(code, selection, arrival) {
|
|
49
|
+
const caret = selection && selection.start === selection.end ? selection.start : null;
|
|
50
|
+
const lastIndex = 31;
|
|
51
|
+
const focusIndex = selection === null ? null : Math.min(selection.start, lastIndex);
|
|
37
52
|
const groups = [];
|
|
38
53
|
for (let start = 0; start < 32; start += 4) {
|
|
39
54
|
const end = start + 4;
|
|
@@ -43,19 +58,42 @@ function renderRecoveryCodeGroups(code, caret) {
|
|
|
43
58
|
const classes = ["seams-otp-slot"];
|
|
44
59
|
if (character) classes.push("is-filled");
|
|
45
60
|
if (index === caret) classes.push("is-caret");
|
|
61
|
+
if (caret === 32 && index === lastIndex) classes.push("is-caret-after");
|
|
62
|
+
if (selection && index >= selection.start && index < selection.end) classes.push("is-selected");
|
|
63
|
+
if (arrival && index >= arrival.start && index < arrival.end) classes.push("is-new");
|
|
46
64
|
slots.push(/* @__PURE__ */ jsx("span", {
|
|
47
65
|
class: classes.join(" "),
|
|
66
|
+
"data-recovery-slot": index,
|
|
48
67
|
children: character
|
|
49
68
|
}, index));
|
|
50
69
|
}
|
|
51
|
-
const
|
|
70
|
+
const groupClasses = ["seams-recovery-code-group"];
|
|
71
|
+
if (focusIndex !== null && focusIndex >= start && focusIndex < end) groupClasses.push("is-active");
|
|
72
|
+
if (code.length >= end) groupClasses.push("is-complete");
|
|
52
73
|
groups.push(/* @__PURE__ */ jsx("div", {
|
|
53
|
-
class:
|
|
74
|
+
class: groupClasses.join(" "),
|
|
54
75
|
children: slots
|
|
55
76
|
}, start));
|
|
56
77
|
}
|
|
57
78
|
return groups;
|
|
58
79
|
}
|
|
80
|
+
function recoveryCaretAtPoint(root, clientX, clientY, codeLength) {
|
|
81
|
+
let nearest = null;
|
|
82
|
+
for (const slot of root.querySelectorAll("[data-recovery-slot]")) {
|
|
83
|
+
const index = Number(slot.dataset.recoverySlot);
|
|
84
|
+
const box = slot.getBoundingClientRect();
|
|
85
|
+
const dx = clientX < box.left ? box.left - clientX : Math.max(0, clientX - box.right);
|
|
86
|
+
const dy = clientY < box.top ? box.top - clientY : Math.max(0, clientY - box.bottom);
|
|
87
|
+
const distance = dx * dx + dy * dy;
|
|
88
|
+
if (nearest === null || distance < nearest.distance) nearest = {
|
|
89
|
+
index,
|
|
90
|
+
distance,
|
|
91
|
+
after: clientX > box.left + box.width / 2
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (nearest === null) return null;
|
|
95
|
+
return Math.min(nearest.after ? nearest.index + 1 : nearest.index, codeLength);
|
|
96
|
+
}
|
|
59
97
|
function renderOtpCodeDigit(digit) {
|
|
60
98
|
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx("span", {
|
|
61
99
|
class: `seams-otp-slot ${digit.trim() ? "is-filled" : ""}`,
|
|
@@ -102,90 +140,6 @@ function menuNotice(viewModel) {
|
|
|
102
140
|
if (viewModel.kind === "google_otp_login" || viewModel.kind === "google_registration") return viewModel.error || null;
|
|
103
141
|
return viewModel.kind === "passkey" && viewModel.status.kind === "recoverable" && viewModel.status.reason === "error" ? viewModel.status.message : null;
|
|
104
142
|
}
|
|
105
|
-
const LINK_DEVICE_DOT_COUNT = 12;
|
|
106
|
-
function linkDeviceDotRing(phase, glyph) {
|
|
107
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsxs("div", {
|
|
108
|
-
class: `seams-link-device-dot-ring is-${phase}`,
|
|
109
|
-
"aria-hidden": "true",
|
|
110
|
-
children: [
|
|
111
|
-
Array.from({ length: LINK_DEVICE_DOT_COUNT }, (_, index) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx("span", { "data-dot-index": index }) })),
|
|
112
|
-
glyph ? /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx("div", {
|
|
113
|
-
class: "seams-link-device-dot-ring-glyph",
|
|
114
|
-
children: glyph
|
|
115
|
-
}) }) : null,
|
|
116
|
-
/* @__PURE__ */ jsx("svg", {
|
|
117
|
-
class: "seams-link-device-dot-ring-check",
|
|
118
|
-
viewBox: "0 0 52 52",
|
|
119
|
-
fill: "none",
|
|
120
|
-
stroke: "currentColor",
|
|
121
|
-
"stroke-width": "2.5",
|
|
122
|
-
"stroke-linecap": "round",
|
|
123
|
-
"stroke-linejoin": "round",
|
|
124
|
-
children: /* @__PURE__ */ jsx("path", { d: "m18.5 27 5 5 10-11" })
|
|
125
|
-
})
|
|
126
|
-
]
|
|
127
|
-
}) });
|
|
128
|
-
}
|
|
129
|
-
function linkDeviceEmailOtpPresentation(activation) {
|
|
130
|
-
switch (activation.kind) {
|
|
131
|
-
case "sending": return {
|
|
132
|
-
ring: "waiting",
|
|
133
|
-
heading: "Sending your code",
|
|
134
|
-
status: "Emailing a 6-digit code",
|
|
135
|
-
pending: true,
|
|
136
|
-
tone: "neutral"
|
|
137
|
-
};
|
|
138
|
-
case "resending": return {
|
|
139
|
-
ring: "waiting",
|
|
140
|
-
heading: "Sending a new code",
|
|
141
|
-
status: "Emailing a fresh 6-digit code",
|
|
142
|
-
pending: true,
|
|
143
|
-
tone: "neutral"
|
|
144
|
-
};
|
|
145
|
-
case "submitting": return {
|
|
146
|
-
ring: "waiting",
|
|
147
|
-
heading: "Checking your code",
|
|
148
|
-
status: "Verifying the code you entered",
|
|
149
|
-
pending: true,
|
|
150
|
-
tone: "neutral"
|
|
151
|
-
};
|
|
152
|
-
case "code_input": return {
|
|
153
|
-
ring: "idle",
|
|
154
|
-
heading: "Verify your email",
|
|
155
|
-
status: "Enter the 6-digit code we just sent.",
|
|
156
|
-
pending: false,
|
|
157
|
-
tone: "neutral"
|
|
158
|
-
};
|
|
159
|
-
case "incorrect": return {
|
|
160
|
-
ring: "idle",
|
|
161
|
-
heading: "Verify your email",
|
|
162
|
-
status: activation.message,
|
|
163
|
-
pending: false,
|
|
164
|
-
tone: "error"
|
|
165
|
-
};
|
|
166
|
-
case "expired": return {
|
|
167
|
-
ring: "idle",
|
|
168
|
-
heading: "That code expired",
|
|
169
|
-
status: activation.message,
|
|
170
|
-
pending: false,
|
|
171
|
-
tone: "error"
|
|
172
|
-
};
|
|
173
|
-
case "unavailable": return {
|
|
174
|
-
ring: "idle",
|
|
175
|
-
heading: "Email code unavailable",
|
|
176
|
-
status: activation.message,
|
|
177
|
-
pending: false,
|
|
178
|
-
tone: "error"
|
|
179
|
-
};
|
|
180
|
-
case "completed": return {
|
|
181
|
-
ring: "approved",
|
|
182
|
-
heading: "Email verified",
|
|
183
|
-
status: "Finishing linking this device",
|
|
184
|
-
pending: true,
|
|
185
|
-
tone: "neutral"
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
143
|
function selectedLoginAccount(viewModel) {
|
|
190
144
|
return resolveAuthMenuLoginAccount(viewModel.accountOptions, viewModel.selectedAccount).selectedAccount;
|
|
191
145
|
}
|
|
@@ -219,8 +173,13 @@ var AuthMenuSurface = class extends Component {
|
|
|
219
173
|
super(..._args);
|
|
220
174
|
this.state = {
|
|
221
175
|
accountMenu: "closed",
|
|
222
|
-
|
|
176
|
+
recoverySelection: null,
|
|
177
|
+
recoveryRejection: null
|
|
223
178
|
};
|
|
179
|
+
this.recoveryDrawnCode = "";
|
|
180
|
+
this.recoveryArrival = null;
|
|
181
|
+
this.recoveryArrivalTimer = null;
|
|
182
|
+
this.recoveryRejectionTimer = null;
|
|
224
183
|
this.accountMenuExitTimer = null;
|
|
225
184
|
this.accountMenuChoice = null;
|
|
226
185
|
this.previouslyFocusedElement = null;
|
|
@@ -396,23 +355,42 @@ var AuthMenuSurface = class extends Component {
|
|
|
396
355
|
if (this.viewModel.kind !== "recovery") return;
|
|
397
356
|
const input = event.currentTarget;
|
|
398
357
|
const raw = input.value;
|
|
358
|
+
const rejected = rejectedRecoveryCharacters(raw);
|
|
359
|
+
if (rejected.length > 0) this.showRecoveryRejection(rejected);
|
|
399
360
|
const caret = recoveryInputCharacters(raw.slice(0, input.selectionStart ?? raw.length)).length;
|
|
400
361
|
const code = recoveryInputCharacters(raw).slice(0, 32);
|
|
401
362
|
if (input.value !== code) {
|
|
402
363
|
input.value = code;
|
|
403
364
|
input.setSelectionRange(Math.min(caret, code.length), Math.min(caret, code.length));
|
|
404
365
|
}
|
|
405
|
-
this.
|
|
366
|
+
this.syncRecoverySelection(input);
|
|
406
367
|
this.emitIntent({
|
|
407
368
|
kind: "recovery_code_changed",
|
|
408
369
|
recoveryCode: code
|
|
409
370
|
});
|
|
410
371
|
};
|
|
411
|
-
this.
|
|
412
|
-
if (event.currentTarget instanceof HTMLInputElement) this.
|
|
372
|
+
this.onRecoverySelectionMove = (event) => {
|
|
373
|
+
if (event.currentTarget instanceof HTMLInputElement) this.syncRecoverySelection(event.currentTarget);
|
|
374
|
+
};
|
|
375
|
+
this.onRecoveryCodeClick = (event) => {
|
|
376
|
+
const input = event.currentTarget;
|
|
377
|
+
if (!(input instanceof HTMLInputElement)) return;
|
|
378
|
+
if (input.selectionStart === input.selectionEnd) {
|
|
379
|
+
const caret = recoveryCaretAtPoint(this.props.element, event.clientX, event.clientY, input.value.length);
|
|
380
|
+
if (caret !== null) input.setSelectionRange(caret, caret);
|
|
381
|
+
}
|
|
382
|
+
this.syncRecoverySelection(input);
|
|
383
|
+
};
|
|
384
|
+
this.clearRecoveryRejection = () => {
|
|
385
|
+
this.recoveryRejectionTimer = null;
|
|
386
|
+
this.setState({ recoveryRejection: null });
|
|
387
|
+
};
|
|
388
|
+
this.endRecoveryArrival = () => {
|
|
389
|
+
this.recoveryArrivalTimer = null;
|
|
390
|
+
this.recoveryArrival = null;
|
|
413
391
|
};
|
|
414
392
|
this.onRecoveryCodeBlur = () => {
|
|
415
|
-
this.setState({
|
|
393
|
+
this.setState({ recoverySelection: null });
|
|
416
394
|
};
|
|
417
395
|
this.onRecoverySubmit = (event) => {
|
|
418
396
|
event.preventDefault();
|
|
@@ -524,6 +502,8 @@ var AuthMenuSurface = class extends Component {
|
|
|
524
502
|
if (this.contentHeightFrame !== null) cancelAnimationFrame(this.contentHeightFrame);
|
|
525
503
|
this.contentHeightFrame = null;
|
|
526
504
|
this.endAccountMenuExit();
|
|
505
|
+
if (this.recoveryArrivalTimer !== null) clearTimeout(this.recoveryArrivalTimer);
|
|
506
|
+
if (this.recoveryRejectionTimer !== null) clearTimeout(this.recoveryRejectionTimer);
|
|
527
507
|
window.removeEventListener("resize", this.queueContentHeightSync);
|
|
528
508
|
document.removeEventListener("pointerdown", this.onDocumentPointerDown);
|
|
529
509
|
document.removeEventListener("keydown", this.onKeyDown, true);
|
|
@@ -593,10 +573,40 @@ var AuthMenuSurface = class extends Component {
|
|
|
593
573
|
focusableElements() {
|
|
594
574
|
return Array.from(this.props.element.querySelectorAll("button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])"));
|
|
595
575
|
}
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
576
|
+
showRecoveryRejection(characters) {
|
|
577
|
+
const parity = this.state.recoveryRejection?.parity === 0 ? 1 : 0;
|
|
578
|
+
this.setState({ recoveryRejection: {
|
|
579
|
+
characters,
|
|
580
|
+
parity
|
|
581
|
+
} });
|
|
582
|
+
if (this.recoveryRejectionTimer !== null) clearTimeout(this.recoveryRejectionTimer);
|
|
583
|
+
this.recoveryRejectionTimer = setTimeout(this.clearRecoveryRejection, 2e3);
|
|
584
|
+
}
|
|
585
|
+
recoveryCodeArrival(code) {
|
|
586
|
+
const drawn = this.recoveryDrawnCode;
|
|
587
|
+
if (code === drawn) return this.recoveryArrival;
|
|
588
|
+
this.recoveryDrawnCode = code;
|
|
589
|
+
let start = 0;
|
|
590
|
+
while (start < drawn.length && drawn[start] === code[start]) start += 1;
|
|
591
|
+
const end = start + code.length - drawn.length;
|
|
592
|
+
this.recoveryArrival = code.length > drawn.length ? {
|
|
593
|
+
start,
|
|
594
|
+
end
|
|
595
|
+
} : null;
|
|
596
|
+
if (this.recoveryArrivalTimer !== null) clearTimeout(this.recoveryArrivalTimer);
|
|
597
|
+
this.recoveryArrivalTimer = setTimeout(this.endRecoveryArrival, 600);
|
|
598
|
+
return this.recoveryArrival;
|
|
599
|
+
}
|
|
600
|
+
syncRecoverySelection(input) {
|
|
601
|
+
const length = input.value.length;
|
|
602
|
+
const start = Math.min(input.selectionStart ?? length, length);
|
|
603
|
+
const end = Math.min(Math.max(input.selectionEnd ?? start, start), length);
|
|
604
|
+
const current = this.state.recoverySelection;
|
|
605
|
+
if (current?.start === start && current.end === end) return;
|
|
606
|
+
this.setState({ recoverySelection: {
|
|
607
|
+
start,
|
|
608
|
+
end
|
|
609
|
+
} });
|
|
600
610
|
}
|
|
601
611
|
emitIntent(intent) {
|
|
602
612
|
this.props.onIntent(intent);
|
|
@@ -898,7 +908,8 @@ var AuthMenuSurface = class extends Component {
|
|
|
898
908
|
renderRecovery(viewModel) {
|
|
899
909
|
if (viewModel.stage === "enter_code") {
|
|
900
910
|
const code = recoveryInputCharacters(viewModel.recoveryCode).slice(0, 32);
|
|
901
|
-
const
|
|
911
|
+
const arrival = this.recoveryCodeArrival(code);
|
|
912
|
+
const rejection = this.state.recoveryRejection;
|
|
902
913
|
const statusMessage = viewModel.status.kind === "recoverable" ? viewModel.status.message : "";
|
|
903
914
|
const feedbackMessage = viewModel.recoveryCodeError ?? statusMessage;
|
|
904
915
|
const feedbackIsError = feedbackMessage.length > 0;
|
|
@@ -917,54 +928,63 @@ var AuthMenuSurface = class extends Component {
|
|
|
917
928
|
onSubmit: this.onRecoverySubmit,
|
|
918
929
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
919
930
|
class: "seams-recovery-field",
|
|
920
|
-
children: [
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
931
|
+
children: [
|
|
932
|
+
/* @__PURE__ */ jsxs("div", {
|
|
933
|
+
class: "seams-recovery-field-header",
|
|
934
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
935
|
+
class: "seams-field-label",
|
|
936
|
+
for: "seams-recovery-code",
|
|
937
|
+
children: "Recovery code"
|
|
938
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
939
|
+
id: "seams-recovery-code-count",
|
|
940
|
+
class: "seams-recovery-code-count",
|
|
941
|
+
children: [
|
|
942
|
+
code.length,
|
|
943
|
+
"/",
|
|
944
|
+
32
|
|
945
|
+
]
|
|
946
|
+
})]
|
|
947
|
+
}),
|
|
948
|
+
/* @__PURE__ */ jsxs("div", {
|
|
949
|
+
class: `seams-otp-code-field seams-recovery-code-field ${rejection ? `is-rejecting-${rejection.parity}` : ""}`,
|
|
950
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
951
|
+
id: "seams-recovery-code",
|
|
952
|
+
class: "seams-otp-input",
|
|
953
|
+
"data-recovery-code": true,
|
|
954
|
+
name: "recoveryCode",
|
|
955
|
+
type: "text",
|
|
956
|
+
inputmode: "text",
|
|
957
|
+
autocomplete: "off",
|
|
958
|
+
autocapitalize: "characters",
|
|
959
|
+
autocorrect: "off",
|
|
960
|
+
spellcheck: false,
|
|
961
|
+
"aria-invalid": viewModel.recoveryCodeError ? "true" : "false",
|
|
962
|
+
"aria-describedby": viewModel.recoveryCodeError ? "seams-recovery-code-feedback seams-recovery-code-count seams-recovery-code-hint" : "seams-recovery-code-count seams-recovery-code-hint",
|
|
963
|
+
value: code,
|
|
964
|
+
onInput: this.onRecoveryCodeInput,
|
|
965
|
+
onFocus: this.onRecoverySelectionMove,
|
|
966
|
+
onKeyUp: this.onRecoverySelectionMove,
|
|
967
|
+
onSelect: this.onRecoverySelectionMove,
|
|
968
|
+
onClick: this.onRecoveryCodeClick,
|
|
969
|
+
onBlur: this.onRecoveryCodeBlur
|
|
970
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
971
|
+
class: `seams-otp-slots seams-recovery-code-slots ${arrival && arrival.end - arrival.start > 1 ? "is-sweeping" : ""}`,
|
|
972
|
+
"aria-hidden": "true",
|
|
973
|
+
children: renderRecoveryCodeGroups(code, this.state.recoverySelection, arrival)
|
|
974
|
+
})]
|
|
975
|
+
}),
|
|
976
|
+
/* @__PURE__ */ jsx("p", {
|
|
977
|
+
id: "seams-recovery-code-hint",
|
|
978
|
+
class: `seams-recovery-code-hint ${rejection ? "is-error" : ""}`,
|
|
979
|
+
"aria-live": "polite",
|
|
980
|
+
children: rejection ? `Recovery codes don’t use ${rejection.characters.join(", ")}.` : "You can paste the whole code."
|
|
981
|
+
})
|
|
982
|
+
]
|
|
962
983
|
}), /* @__PURE__ */ jsx("button", {
|
|
963
984
|
class: "seams-auth-method-btn seams-auth-method-btn-primary",
|
|
964
985
|
type: "submit",
|
|
965
986
|
"data-auth-menu-primary": true,
|
|
966
987
|
"data-recovery-continue": true,
|
|
967
|
-
disabled: !complete,
|
|
968
988
|
children: "Continue"
|
|
969
989
|
})]
|
|
970
990
|
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
//#region src/SeamsWeb/walletIframe/host/ui/auth-menu/linkDeviceBadge.tsx
|
|
3
|
+
const LINK_DEVICE_DOT_COUNT = 12;
|
|
4
|
+
function linkDeviceDotRing(phase, glyph) {
|
|
5
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
6
|
+
class: `seams-link-device-dot-ring is-${phase}`,
|
|
7
|
+
"aria-hidden": "true",
|
|
8
|
+
children: [
|
|
9
|
+
Array.from({ length: LINK_DEVICE_DOT_COUNT }, (_, index) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("span", { "data-dot-index": index }) })),
|
|
10
|
+
glyph ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
|
|
11
|
+
class: "seams-link-device-dot-ring-glyph",
|
|
12
|
+
children: glyph
|
|
13
|
+
}) }) : null,
|
|
14
|
+
/* @__PURE__ */ jsx("svg", {
|
|
15
|
+
class: "seams-link-device-dot-ring-check",
|
|
16
|
+
viewBox: "0 0 52 52",
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
"stroke-width": "2.5",
|
|
20
|
+
"stroke-linecap": "round",
|
|
21
|
+
"stroke-linejoin": "round",
|
|
22
|
+
children: /* @__PURE__ */ jsx("path", { d: "m18.5 27 5 5 10-11" })
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
}) });
|
|
26
|
+
}
|
|
27
|
+
function linkDeviceEmailOtpPresentation(activation) {
|
|
28
|
+
switch (activation.kind) {
|
|
29
|
+
case "sending": return {
|
|
30
|
+
ring: "waiting",
|
|
31
|
+
heading: "Sending your code",
|
|
32
|
+
status: "Emailing a 6-digit code",
|
|
33
|
+
pending: true,
|
|
34
|
+
tone: "neutral"
|
|
35
|
+
};
|
|
36
|
+
case "resending": return {
|
|
37
|
+
ring: "waiting",
|
|
38
|
+
heading: "Sending a new code",
|
|
39
|
+
status: "Emailing a fresh 6-digit code",
|
|
40
|
+
pending: true,
|
|
41
|
+
tone: "neutral"
|
|
42
|
+
};
|
|
43
|
+
case "submitting": return {
|
|
44
|
+
ring: "waiting",
|
|
45
|
+
heading: "Checking your code",
|
|
46
|
+
status: "Verifying the code you entered",
|
|
47
|
+
pending: true,
|
|
48
|
+
tone: "neutral"
|
|
49
|
+
};
|
|
50
|
+
case "code_input": return {
|
|
51
|
+
ring: "idle",
|
|
52
|
+
heading: "Verify your email",
|
|
53
|
+
status: "Enter the 6-digit code we just sent.",
|
|
54
|
+
pending: false,
|
|
55
|
+
tone: "neutral"
|
|
56
|
+
};
|
|
57
|
+
case "incorrect": return {
|
|
58
|
+
ring: "idle",
|
|
59
|
+
heading: "Verify your email",
|
|
60
|
+
status: activation.message,
|
|
61
|
+
pending: false,
|
|
62
|
+
tone: "error"
|
|
63
|
+
};
|
|
64
|
+
case "expired": return {
|
|
65
|
+
ring: "idle",
|
|
66
|
+
heading: "That code expired",
|
|
67
|
+
status: activation.message,
|
|
68
|
+
pending: false,
|
|
69
|
+
tone: "error"
|
|
70
|
+
};
|
|
71
|
+
case "unavailable": return {
|
|
72
|
+
ring: "idle",
|
|
73
|
+
heading: "Email code unavailable",
|
|
74
|
+
status: activation.message,
|
|
75
|
+
pending: false,
|
|
76
|
+
tone: "error"
|
|
77
|
+
};
|
|
78
|
+
case "completed": return {
|
|
79
|
+
ring: "approved",
|
|
80
|
+
heading: "Email verified",
|
|
81
|
+
status: "Finishing linking this device",
|
|
82
|
+
pending: true,
|
|
83
|
+
tone: "neutral"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { linkDeviceDotRing, linkDeviceEmailOtpPresentation };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=linkDeviceBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t}from"./chains-C_X_fNuS.js";import{n}from"./walletRegistrationSetupPrewarm-B9kpnrbK.js";import{_ as r,c as i,f as a,g as o,h as s,l as c,m as l,n as u,o as d,t as f,v as p}from"./messages-DgJlG9NU.js";import{a as m,c as h,i as g,l as _,n as v,o as y,s as b,t as x,u as S}from"./transactionReviewAdmission-CIvR4W5_.js";import{t as C}from"./events-1dzC4Ocx.js";import{t as w}from"./walletIframeIdentity-Cz82I_Uh.js";import{t as T}from"./errors-DIWY1KR9.js";function E(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function D(){E(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),O(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&l(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;a()||s(r)}function O(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const k={};let A=null,j=null;function M(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),A):(k[e.kind]??=P(e.kind),k[e.kind])}async function N(){A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),j??=Promise.all([A,import(`./mountRecoveryCodeBackupSurface-D1G-iCPI.js`)]).then(()=>void 0),await j}function P(e){switch(e){case`auth`:return import(`./runtime-auth-DtpRz88X.js`);case`near`:return import(`./runtime-near-B-vYxGjl.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DlKMIbyP.js`);case`email_otp`:return import(`./runtime-email-otp-BBPghU2G.js`);case`recovery`:return import(`./runtime-recovery-Vg1ND2nl.js`);case`export`:return import(`./runtime-export-pw-xJL8o.js`);case`device_link`:return import(`./runtime-device-link-DXjabXJb.js`);case`preferences`:return import(`./runtime-preferences-D-hY0RfC.js`)}return F(e)}function F(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function I(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function L(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function R(e){try{return w(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function z(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(c(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(d(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(i(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return I(e)}function B(e){return e.kind!==`boot`}let V=!1;const H=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function U(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function W(t){return!e(t)||!U(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!U(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function G(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function K(e){try{e.close()}catch{}}function q(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:u,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${u}, received ${t??`missing`}`,details:n}})}catch{}return K(e),!0}function J(e,t){return!t||t.has(e.kind)}function Y(e,t,n,r){e.executionGeneration===t&&n(r)}function X(e,t,n,r){return e.executionGeneration!==t||n(r)}function Z(e={}){if(V)return;V=!0,D(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&N().catch(()=>void 0);let i=new Set,a=new Set,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},l=e=>{e&&i.add(e)},d=e=>!!e&&(i.has(e)||g(e)?.cancelled===!0),f=e=>{e&&i.delete(e)},w=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},E=e=>!e||!d(e)?!1:g(e)?.cancelled?!0:(w(e),f(e),!0),O=()=>{for(let e of H){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(C.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},k=async i=>{let u=i.data;if(!u||!t(u))return;let C=u.requestId,D=s.executionGeneration,k=Y.bind(null,s,D,c),A=null;try{if(`transactionReview`in u){if(u.type!==`PM_SIGN_AND_SEND_TX`&&u.type!==`PM_SIGN_TEMPO`)throw new m(`review_invalid_input`,`Review is unsupported for this request`);let e=h(u.transactionReview);if(e.requestId!==C)throw new m(`review_invalid_input`,`Review request identity mismatch`);let t=u.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new m(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);A=new x(e,u.type===`PM_SIGN_TEMPO`&&u.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>k({type:`TRANSACTION_REVIEW_STATE`,requestId:C,payload:e}),e=>k({type:`ERROR`,requestId:C,payload:{code:e instanceof m?e.code:`cancelled`,message:e.message}}))}(u.type===`PM_LOCK`||u.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&v(new m(`review_identity_changed`,`The wallet session changed`));let t=z(u);if(!B(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:C});return;case`PM_SET_CONFIG`:{let e=o(s.configuration,r(t.request.payload)),i=p(s.configuration.kind===`configured`?s.configuration.config:null)!==p(e.config);if(s.configuration=e,i){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of a)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});a.clear()}s.onConfigurationChanged?.(),i&&(v(new m(`review_identity_changed`,`Wallet execution configuration changed`)),O()),c({type:`PONG`,requestId:C});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=b(t.request.payload);e&&g(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=h(r),i=g(t.requestId);if(t.requestId===e&&i&&_(t,i.metadata)){let e=new m(S(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{y(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:C});return}let i=e?g(e):void 0;if(i){i.cancel(new m(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:C});return}l(e),O(),e&&w(e),c({type:`PONG`,requestId:C});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!J(t,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:C,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}C&&a.add(C);let i=await M(t);if(D!==s.executionGeneration)return;await i.handleWalletHostRuntimeRequest({transactionReview:A,state:s,executionGeneration:D,req:t.request,post:Y.bind(null,s,D,c),isCancelled:X.bind(null,s,D,d),respondIfCancelled:X.bind(null,s,D,E)})}catch(e){if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`||A?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-Cz48v4oy.js`);if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=T(e),i=t.resolveWalletBoundaryErrorCode({requestType:u.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:u.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(u.type);c({type:`ERROR`,requestId:C,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(u.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{C&&(a.delete(C),f(C)),A?.finish()}};window.addEventListener(`message`,e=>{let t=W(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!G(e.origin)){K(n);return}if(!q(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(s.parentOrigin=e.origin),s.port=n;try{s.port.onmessage=k,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:u}})}}})}try{Z()}catch(e){console.error(`[WalletHost] init failed`,e)}export{Z as t};
|
|
1
|
+
import{C as e,S as t}from"./chains-C_X_fNuS.js";import{n}from"./walletRegistrationSetupPrewarm-B9kpnrbK.js";import{_ as r,c as i,f as a,g as o,h as s,l as c,m as l,n as u,o as d,t as f,v as p}from"./messages-DgJlG9NU.js";import{a as m,c as h,i as g,l as _,n as v,o as y,s as b,t as x,u as S}from"./transactionReviewAdmission-CIvR4W5_.js";import{t as C}from"./events-1dzC4Ocx.js";import{t as w}from"./walletIframeIdentity-Cz82I_Uh.js";import{t as T}from"./errors-DIWY1KR9.js";function E(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function D(){E(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),O(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&l(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;a()||s(r)}function O(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const k={};let A=null,j=null;function M(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),A):(k[e.kind]??=P(e.kind),k[e.kind])}async function N(){A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),j??=Promise.all([A,import(`./mountRecoveryCodeBackupSurface-D1G-iCPI.js`)]).then(()=>void 0),await j}function P(e){switch(e){case`auth`:return import(`./runtime-auth-TZw6JD8N.js`);case`near`:return import(`./runtime-near-B-vYxGjl.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DlKMIbyP.js`);case`email_otp`:return import(`./runtime-email-otp-BBPghU2G.js`);case`recovery`:return import(`./runtime-recovery-Vg1ND2nl.js`);case`export`:return import(`./runtime-export-pw-xJL8o.js`);case`device_link`:return import(`./runtime-device-link-DXjabXJb.js`);case`preferences`:return import(`./runtime-preferences-D-hY0RfC.js`)}return F(e)}function F(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function I(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function L(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function R(e){try{return w(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function z(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(c(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(d(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(i(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return I(e)}function B(e){return e.kind!==`boot`}let V=!1;const H=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function U(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function W(t){return!e(t)||!U(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!U(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function G(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function K(e){try{e.close()}catch{}}function q(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:u,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${u}, received ${t??`missing`}`,details:n}})}catch{}return K(e),!0}function J(e,t){return!t||t.has(e.kind)}function Y(e,t,n,r){e.executionGeneration===t&&n(r)}function X(e,t,n,r){return e.executionGeneration!==t||n(r)}function Z(e={}){if(V)return;V=!0,D(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&N().catch(()=>void 0);let i=new Set,a=new Set,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},l=e=>{e&&i.add(e)},d=e=>!!e&&(i.has(e)||g(e)?.cancelled===!0),f=e=>{e&&i.delete(e)},w=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},E=e=>!e||!d(e)?!1:g(e)?.cancelled?!0:(w(e),f(e),!0),O=()=>{for(let e of H){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(C.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},k=async i=>{let u=i.data;if(!u||!t(u))return;let C=u.requestId,D=s.executionGeneration,k=Y.bind(null,s,D,c),A=null;try{if(`transactionReview`in u){if(u.type!==`PM_SIGN_AND_SEND_TX`&&u.type!==`PM_SIGN_TEMPO`)throw new m(`review_invalid_input`,`Review is unsupported for this request`);let e=h(u.transactionReview);if(e.requestId!==C)throw new m(`review_invalid_input`,`Review request identity mismatch`);let t=u.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new m(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);A=new x(e,u.type===`PM_SIGN_TEMPO`&&u.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>k({type:`TRANSACTION_REVIEW_STATE`,requestId:C,payload:e}),e=>k({type:`ERROR`,requestId:C,payload:{code:e instanceof m?e.code:`cancelled`,message:e.message}}))}(u.type===`PM_LOCK`||u.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&v(new m(`review_identity_changed`,`The wallet session changed`));let t=z(u);if(!B(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:C});return;case`PM_SET_CONFIG`:{let e=o(s.configuration,r(t.request.payload)),i=p(s.configuration.kind===`configured`?s.configuration.config:null)!==p(e.config);if(s.configuration=e,i){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of a)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});a.clear()}s.onConfigurationChanged?.(),i&&(v(new m(`review_identity_changed`,`Wallet execution configuration changed`)),O()),c({type:`PONG`,requestId:C});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=b(t.request.payload);e&&g(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=h(r),i=g(t.requestId);if(t.requestId===e&&i&&_(t,i.metadata)){let e=new m(S(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{y(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:C});return}let i=e?g(e):void 0;if(i){i.cancel(new m(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:C});return}l(e),O(),e&&w(e),c({type:`PONG`,requestId:C});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!J(t,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:C,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}C&&a.add(C);let i=await M(t);if(D!==s.executionGeneration)return;await i.handleWalletHostRuntimeRequest({transactionReview:A,state:s,executionGeneration:D,req:t.request,post:Y.bind(null,s,D,c),isCancelled:X.bind(null,s,D,d),respondIfCancelled:X.bind(null,s,D,E)})}catch(e){if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`||A?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-Cz48v4oy.js`);if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=T(e),i=t.resolveWalletBoundaryErrorCode({requestType:u.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:u.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(u.type);c({type:`ERROR`,requestId:C,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(u.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{C&&(a.delete(C),f(C)),A?.finish()}};window.addEventListener(`message`,e=>{let t=W(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!G(e.origin)){K(n);return}if(!q(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(s.parentOrigin=e.origin),s.port=n;try{s.port.onmessage=k,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:u}})}}})}try{Z()}catch(e){console.error(`[WalletHost] init failed`,e)}export{Z as t};
|