@seams/wallet 0.12.0 → 0.13.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.
Files changed (55) hide show
  1. package/README.md +3 -3
  2. package/dist/.build-inputs.sha256 +1 -1
  3. package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.js +160 -140
  4. package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/linkDeviceBadge.js +90 -0
  5. package/dist/esm/core/config/defaultConfigs.js +1 -1
  6. package/dist/esm/sdk/{host-CHQwi-Nm.js → host-BAeJh9rB.js} +1 -1
  7. package/dist/{public/sdk/presignaturePool-CLHu7HaU.js → esm/sdk/presignaturePool-Bkk6bLFB.js} +1 -1
  8. package/dist/esm/sdk/routerAbNormalSigning-B35zb-P-.js +1 -0
  9. package/dist/esm/sdk/runtime-auth-D7VqiZeg.js +1 -0
  10. package/dist/esm/sdk/{runtime-device-link-DXjabXJb.js → runtime-device-link-BKc_MD5V.js} +1 -1
  11. package/dist/esm/sdk/{runtime-ecdsa-tempo-DlKMIbyP.js → runtime-ecdsa-tempo-DC51NDrh.js} +1 -1
  12. package/dist/esm/sdk/{runtime-email-otp-BBPghU2G.js → runtime-email-otp-C-wopKFf.js} +1 -1
  13. package/dist/esm/sdk/{runtime-export-pw-xJL8o.js → runtime-export-BtGy8BKi.js} +1 -1
  14. package/dist/esm/sdk/{runtime-near-B-vYxGjl.js → runtime-near-nq8pgRAl.js} +1 -1
  15. package/dist/esm/sdk/{runtime-preferences-D-hY0RfC.js → runtime-preferences-778ZfMmT.js} +1 -1
  16. package/dist/esm/sdk/{runtime-recovery-Vg1ND2nl.js → runtime-recovery-B-JsRiN0.js} +1 -1
  17. package/dist/esm/sdk/{secp256k1-C-AETUpI.js → secp256k1-CYQS0rj-.js} +1 -1
  18. package/dist/esm/sdk/{shared-6bpRPbcM.js → shared-B6BCLs8L.js} +1 -1
  19. package/dist/esm/sdk/{signEvmFamily-M0trbeZe.js → signEvmFamily-ttVfV0qm.js} +1 -1
  20. package/dist/{public/sdk/signNear-DGUQZ44s.js → esm/sdk/signNear-bcWIHxEY.js} +1 -1
  21. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  22. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  23. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  24. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  25. package/dist/esm/sdk/wallet-ui.css +1 -1
  26. package/dist/public/headers.manifest.json +1 -1
  27. package/dist/public/sdk/{host-CHQwi-Nm.js → host-BAeJh9rB.js} +1 -1
  28. package/dist/{esm/sdk/presignaturePool-CLHu7HaU.js → public/sdk/presignaturePool-Bkk6bLFB.js} +1 -1
  29. package/dist/public/sdk/routerAbNormalSigning-B35zb-P-.js +1 -0
  30. package/dist/public/sdk/runtime-auth-D7VqiZeg.js +1 -0
  31. package/dist/public/sdk/{runtime-device-link-DXjabXJb.js → runtime-device-link-BKc_MD5V.js} +1 -1
  32. package/dist/public/sdk/{runtime-ecdsa-tempo-DlKMIbyP.js → runtime-ecdsa-tempo-DC51NDrh.js} +1 -1
  33. package/dist/public/sdk/{runtime-email-otp-BBPghU2G.js → runtime-email-otp-C-wopKFf.js} +1 -1
  34. package/dist/public/sdk/{runtime-export-pw-xJL8o.js → runtime-export-BtGy8BKi.js} +1 -1
  35. package/dist/public/sdk/{runtime-near-B-vYxGjl.js → runtime-near-nq8pgRAl.js} +1 -1
  36. package/dist/public/sdk/{runtime-preferences-D-hY0RfC.js → runtime-preferences-778ZfMmT.js} +1 -1
  37. package/dist/public/sdk/{runtime-recovery-Vg1ND2nl.js → runtime-recovery-B-JsRiN0.js} +1 -1
  38. package/dist/public/sdk/{secp256k1-C-AETUpI.js → secp256k1-CYQS0rj-.js} +1 -1
  39. package/dist/public/sdk/{shared-6bpRPbcM.js → shared-B6BCLs8L.js} +1 -1
  40. package/dist/public/sdk/{signEvmFamily-M0trbeZe.js → signEvmFamily-ttVfV0qm.js} +1 -1
  41. package/dist/{esm/sdk/signNear-DGUQZ44s.js → public/sdk/signNear-bcWIHxEY.js} +1 -1
  42. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  43. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  44. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  45. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  46. package/dist/public/sdk/wallet-ui.css +1 -1
  47. package/dist/public/wallet-assets.manifest.json +34 -34
  48. package/dist/public/wallet-service/index.html +4 -4
  49. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.d.ts +21 -3
  50. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/linkDeviceBadge.d.ts +18 -0
  51. package/package.json +1 -1
  52. package/dist/esm/sdk/routerAbNormalSigning-DVKFBYgV.js +0 -1
  53. package/dist/esm/sdk/runtime-auth-DtpRz88X.js +0 -1
  54. package/dist/public/sdk/routerAbNormalSigning-DVKFBYgV.js +0 -1
  55. 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.12.0** provides browser wallet lifecycle, NEAR and EVM-family
3
+ `@seams/wallet` **0.13.1** 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.12.0
9
+ pnpm add @seams/wallet@0.13.1
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.12.0` on the matching release.
15
+ `@seams/wallet-server@0.13.1` on the matching release.
16
16
 
17
17
  ## Next release migration (unreleased)
18
18
 
@@ -1 +1 @@
1
- cac337f5d60ac07e7f5ca7219b430e7f4a2cf19050cd38956b352906687b6759
1
+ d55abaddea2337462727d3d8dcc55bdc61ab16087d349e2ad48feffaac2c4f43
@@ -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
- function renderRecoveryCodeGroups(code, caret) {
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 active = caret !== null && caret >= start && caret < end;
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: `seams-recovery-code-group ${active ? "is-active" : ""}`,
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
- recoveryCaret: null
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.syncRecoveryCaret(input);
366
+ this.syncRecoverySelection(input);
406
367
  this.emitIntent({
407
368
  kind: "recovery_code_changed",
408
369
  recoveryCode: code
409
370
  });
410
371
  };
411
- this.onRecoveryCaretMove = (event) => {
412
- if (event.currentTarget instanceof HTMLInputElement) this.syncRecoveryCaret(event.currentTarget);
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({ recoveryCaret: null });
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
- syncRecoveryCaret(input) {
597
- const caret = Math.min(input.selectionStart ?? input.value.length, 31);
598
- const recoveryCaret = input.value.length < 32 ? caret : null;
599
- if (recoveryCaret !== this.state.recoveryCaret) this.setState({ recoveryCaret });
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 complete = code.length === 32;
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: [/* @__PURE__ */ jsxs("div", {
921
- class: "seams-recovery-field-header",
922
- children: [/* @__PURE__ */ jsx("label", {
923
- class: "seams-field-label",
924
- for: "seams-recovery-code",
925
- children: "Recovery code"
926
- }), /* @__PURE__ */ jsxs("span", {
927
- id: "seams-recovery-code-count",
928
- class: "seams-recovery-code-count",
929
- children: [
930
- code.length,
931
- "/",
932
- 32
933
- ]
934
- })]
935
- }), /* @__PURE__ */ jsxs("div", {
936
- class: "seams-otp-code-field seams-recovery-code-field",
937
- children: [/* @__PURE__ */ jsx("input", {
938
- id: "seams-recovery-code",
939
- class: "seams-otp-input",
940
- "data-recovery-code": true,
941
- name: "recoveryCode",
942
- type: "text",
943
- inputmode: "text",
944
- autocomplete: "off",
945
- autocapitalize: "characters",
946
- autocorrect: "off",
947
- spellcheck: false,
948
- "aria-invalid": viewModel.recoveryCodeError ? "true" : "false",
949
- "aria-describedby": viewModel.recoveryCodeError ? "seams-recovery-code-feedback seams-recovery-code-count" : "seams-recovery-code-count",
950
- value: code,
951
- onInput: this.onRecoveryCodeInput,
952
- onFocus: this.onRecoveryCaretMove,
953
- onKeyUp: this.onRecoveryCaretMove,
954
- onClick: this.onRecoveryCaretMove,
955
- onBlur: this.onRecoveryCodeBlur
956
- }), /* @__PURE__ */ jsx("div", {
957
- class: "seams-otp-slots seams-recovery-code-slots",
958
- "aria-hidden": "true",
959
- children: renderRecoveryCodeGroups(code, this.state.recoveryCaret)
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
@@ -25,7 +25,7 @@ const PASSKEY_MANAGER_DEFAULT_CONFIGS = {
25
25
  },
26
26
  {
27
27
  network: "arc-testnet",
28
- rpcUrl: "https://rpc.testnet.arc.network",
28
+ rpcUrl: "https://rpc.testnet.arc.io",
29
29
  explorerUrl: "https://testnet.arcscan.app",
30
30
  chainId: 5042002
31
31
  },
@@ -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-D7VqiZeg.js`);case`near`:return import(`./runtime-near-nq8pgRAl.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DC51NDrh.js`);case`email_otp`:return import(`./runtime-email-otp-C-wopKFf.js`);case`recovery`:return import(`./runtime-recovery-B-JsRiN0.js`);case`export`:return import(`./runtime-export-BtGy8BKi.js`);case`device_link`:return import(`./runtime-device-link-BKc_MD5V.js`);case`preferences`:return import(`./runtime-preferences-778ZfMmT.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};