@seams/wallet 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/THIRD_PARTY_NOTICES.md +5 -2
  2. package/dist/.build-inputs.sha256 +1 -1
  3. package/dist/esm/externalNear/actions.js +26 -0
  4. package/dist/esm/externalNear/boundary.js +53 -0
  5. package/dist/esm/externalNear/controller.js +187 -0
  6. package/dist/esm/externalNear/hot.js +40 -0
  7. package/dist/esm/externalNear/index.js +3 -0
  8. package/dist/esm/externalNear/intear.js +109 -0
  9. package/dist/esm/externalNear/intearPopup.js +83 -0
  10. package/dist/esm/externalNear/meteor.js +121 -0
  11. package/dist/esm/externalNear/meteorRequest.js +117 -0
  12. package/dist/esm/externalNear/types.js +17 -0
  13. package/dist/esm/externalNear/wallets.js +33 -0
  14. package/dist/esm/node_modules/borsh/lib/esm/buffer.js +67 -0
  15. package/dist/esm/node_modules/borsh/lib/esm/deserialize.js +94 -0
  16. package/dist/esm/node_modules/borsh/lib/esm/index.js +13 -0
  17. package/dist/esm/node_modules/borsh/lib/esm/serialize.js +127 -0
  18. package/dist/esm/node_modules/borsh/lib/esm/types.js +19 -0
  19. package/dist/esm/node_modules/borsh/lib/esm/utils.js +104 -0
  20. package/dist/esm/plugins/plugin-utils.js +2 -5
  21. package/dist/esm/react/externalNear.css +90 -0
  22. package/dist/esm/react/externalNear.js +104 -0
  23. package/dist/esm/sdk/host-C5KYWEcs.js +1 -0
  24. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  25. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  26. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  27. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  28. package/dist/esm/sdk/wallet-ui.css +1 -1
  29. package/dist/public/headers.manifest.json +1 -1
  30. package/dist/public/sdk/host-C5KYWEcs.js +1 -0
  31. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  32. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  33. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  34. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  35. package/dist/public/sdk/wallet-ui.css +1 -1
  36. package/dist/public/wallet-assets.manifest.json +4 -5
  37. package/dist/public/wallet-service/index.html +4 -4
  38. package/dist/types/wallet/src/externalNear/actions.d.ts +20 -0
  39. package/dist/types/wallet/src/externalNear/boundary.d.ts +7 -0
  40. package/dist/types/wallet/src/externalNear/controller.d.ts +23 -0
  41. package/dist/types/wallet/src/externalNear/hot.d.ts +13 -0
  42. package/dist/types/wallet/src/externalNear/index.d.ts +4 -0
  43. package/dist/types/wallet/src/externalNear/intear.d.ts +12 -0
  44. package/dist/types/wallet/src/externalNear/intearPopup.d.ts +25 -0
  45. package/dist/types/wallet/src/externalNear/meteor.d.ts +16 -0
  46. package/dist/types/wallet/src/externalNear/meteorRequest.d.ts +29 -0
  47. package/dist/types/wallet/src/externalNear/types.d.ts +67 -0
  48. package/dist/types/wallet/src/externalNear/wallets.d.ts +4 -0
  49. package/dist/types/wallet/src/plugins/plugin-utils.d.ts +1 -1
  50. package/dist/types/wallet/src/react/externalNear.d.ts +26 -0
  51. package/package.json +18 -1
  52. package/dist/esm/plugins/SeamsWeb/walletIframe/sanitization.js +0 -18
  53. package/dist/esm/sdk/host-DoftJdVQ.js +0 -1
  54. package/dist/public/sdk/host-DoftJdVQ.js +0 -1
@@ -0,0 +1,90 @@
1
+ .seams-near-picker {
2
+ color: var(--seams-wallet-picker-text, #f5f5f5);
3
+ background: var(--seams-wallet-picker-background, #202020);
4
+ padding: clamp(20px, 4vw, 40px);
5
+ border-radius: 28px;
6
+ width: 100%;
7
+ box-sizing: border-box;
8
+ }
9
+ .seams-near-picker h2 {
10
+ font-size: clamp(22px, 4vw, 32px);
11
+ font-weight: 500;
12
+ margin: 0;
13
+ }
14
+ .seams-near-network {
15
+ opacity: 0.7;
16
+ }
17
+ .seams-near-wallets {
18
+ display: grid;
19
+ grid-template-columns: repeat(2, minmax(0, 1fr));
20
+ gap: 12px;
21
+ }
22
+ .seams-near-wallets button {
23
+ display: flex;
24
+ flex-direction: column;
25
+ align-items: flex-start;
26
+ gap: 12px;
27
+ color: inherit;
28
+ background: var(--seams-wallet-picker-card, #262626);
29
+ border: 1px solid var(--seams-wallet-picker-border, #383838);
30
+ border-radius: 24px;
31
+ padding: 24px;
32
+ text-align: left;
33
+ font: inherit;
34
+ cursor: pointer;
35
+ min-width: 0;
36
+ }
37
+ .seams-near-wallets strong {
38
+ font-size: 20px;
39
+ font-weight: 500;
40
+ overflow-wrap: anywhere;
41
+ }
42
+ .seams-near-wallets small {
43
+ font-size: 12px;
44
+ opacity: 0.7;
45
+ overflow-wrap: anywhere;
46
+ }
47
+ .seams-near-icon {
48
+ display: grid;
49
+ place-items: center;
50
+ width: 48px;
51
+ height: 48px;
52
+ border-radius: 50%;
53
+ background: #181818;
54
+ font-size: 24px;
55
+ }
56
+ .seams-near-meteor {
57
+ background: #fff;
58
+ color: #4824e9;
59
+ font-weight: 700;
60
+ }
61
+ .seams-near-intear {
62
+ background: #fff;
63
+ color: #1685ff;
64
+ font-weight: 700;
65
+ }
66
+ .seams-near-wallets button:hover:enabled {
67
+ background: var(--seams-wallet-picker-hover, #303030);
68
+ }
69
+ .seams-near-picker button:focus-visible {
70
+ outline: 3px solid #8faaff;
71
+ outline-offset: 3px;
72
+ }
73
+ .seams-near-picker button:disabled {
74
+ opacity: 0.45;
75
+ cursor: default;
76
+ }
77
+ .seams-near-disconnect {
78
+ margin-top: 20px;
79
+ padding: 10px 16px;
80
+ font: inherit;
81
+ color: inherit;
82
+ background: transparent;
83
+ border: 1px solid #666;
84
+ border-radius: 10px;
85
+ }
86
+ @media (max-width: 380px) {
87
+ .seams-near-wallets {
88
+ grid-template-columns: 1fr;
89
+ }
90
+ }
@@ -0,0 +1,104 @@
1
+ import { nearWalletName } from "../externalNear/wallets.js";
2
+ import { Component, useSyncExternalStore } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import "./externalNear.css";
5
+ //#region src/react/externalNear.tsx
6
+ function useExternalNear(controller) {
7
+ return useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
8
+ }
9
+ var ExternalNearWalletPicker = class extends Component {
10
+ state = {
11
+ snapshot: this.props.controller.getSnapshot(),
12
+ message: ""
13
+ };
14
+ unsubscribe = null;
15
+ componentDidMount() {
16
+ this.unsubscribe = this.props.controller.subscribe(this.updateSnapshot);
17
+ }
18
+ componentWillUnmount() {
19
+ this.unsubscribe?.();
20
+ this.props.controller.disconnect();
21
+ }
22
+ updateSnapshot = () => {
23
+ this.setState({ snapshot: this.props.controller.getSnapshot() });
24
+ };
25
+ connect = async (wallet) => {
26
+ const result = await this.props.controller.connect(wallet);
27
+ this.setState({ message: result.ok ? `Connected to ${nearWalletName(wallet)}.` : result.message });
28
+ };
29
+ disconnect = () => {
30
+ this.props.controller.disconnect();
31
+ this.setState({ message: "Disconnected from Seams. Manage site permissions in your wallet." });
32
+ };
33
+ render() {
34
+ const { connection, busy, wallets } = this.state.snapshot;
35
+ const choices = [];
36
+ for (const wallet of wallets) choices.push(/* @__PURE__ */ jsx(NearWalletButton, {
37
+ wallet,
38
+ network: this.props.controller.network,
39
+ busy,
40
+ onConnect: this.connect
41
+ }, wallet));
42
+ return /* @__PURE__ */ jsxs("section", {
43
+ "aria-label": "Choose your NEAR wallet",
44
+ className: "seams-near-picker",
45
+ children: [
46
+ /* @__PURE__ */ jsx("h2", { children: "Choose your NEAR wallet" }),
47
+ /* @__PURE__ */ jsxs("p", {
48
+ className: "seams-near-network",
49
+ children: ["NEAR ", this.props.controller.network]
50
+ }),
51
+ /* @__PURE__ */ jsx("div", {
52
+ className: "seams-near-wallets",
53
+ children: choices
54
+ }),
55
+ wallets.length === 0 && /* @__PURE__ */ jsx("p", { children: "No NEAR wallets are enabled." }),
56
+ connection.kind === "connected" && /* @__PURE__ */ jsxs("p", { children: [
57
+ nearWalletName(connection.wallet),
58
+ " · ",
59
+ connection.accountId
60
+ ] }),
61
+ /* @__PURE__ */ jsx("button", {
62
+ className: "seams-near-disconnect",
63
+ type: "button",
64
+ disabled: connection.kind === "disconnected",
65
+ onClick: this.disconnect,
66
+ children: "Disconnect"
67
+ }),
68
+ /* @__PURE__ */ jsx("p", {
69
+ role: "status",
70
+ children: busy ? "Complete the request in your wallet." : this.state.message
71
+ })
72
+ ]
73
+ });
74
+ }
75
+ };
76
+ const walletIcons = {
77
+ meteor: "M",
78
+ hot: "🔥",
79
+ intear: "I"
80
+ };
81
+ function NearWalletButton({ wallet, network, busy, onConnect }) {
82
+ const unavailable = wallet === "hot" && network !== "mainnet";
83
+ let description = "Browser extension";
84
+ if (wallet === "intear") description = "Opens wallet.intear.tech";
85
+ if (unavailable) description = "Mainnet only";
86
+ return /* @__PURE__ */ jsxs("button", {
87
+ type: "button",
88
+ disabled: busy || unavailable,
89
+ onClick: onConnect.bind(null, wallet),
90
+ children: [
91
+ /* @__PURE__ */ jsx("span", {
92
+ className: `seams-near-icon seams-near-${wallet}`,
93
+ "aria-hidden": "true",
94
+ children: walletIcons[wallet]
95
+ }),
96
+ /* @__PURE__ */ jsx("strong", { children: nearWalletName(wallet) }),
97
+ /* @__PURE__ */ jsx("small", { children: description })
98
+ ]
99
+ });
100
+ }
101
+ //#endregion
102
+ export { ExternalNearWalletPicker, useExternalNear };
103
+
104
+ //# sourceMappingURL=externalNear.js.map
@@ -0,0 +1 @@
1
+ import{C as e,S as t}from"./chains-CPmd4s9f.js";import{n}from"./walletRegistrationSetupPrewarm-CQow9u8m.js";import{t as r}from"./walletDbName-BVZhb4xF.js";import{_ as i,b as a,c as o,d as s,g as c,i as l,m as u,n as d,r as f,t as p,u as m,v as ee,y as te}from"./sessionObservationRevision-abErAhd6.js";import{a as h,c as g,i as _,l as ne,n as v,o as re,s as y,t as b,u as ie}from"./transactionReviewAdmission-CNNho8IG.js";import{t as x}from"./events-1dzC4Ocx.js";import{t as S}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as C}from"./errors-CI1xdN0d.js";import{t as w}from"./signer-worker-Bh_5foqX.js";function T(){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 E(){T(),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.`)),ae(),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&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;u()||i(r)}function ae(){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 D={};let O=null,k=null;function oe(e){return e.request.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?e.request.payload?.authorization?.kind===`email_otp`?A(e.kind):(O??=import(`./runtime-recovery-codes-CuqYWqK7.js`),O):A(e.kind)}function se(){A(`auth`).catch(ce)}function ce(){}function A(e){let t=D[e];if(t)return t;let n=N(e);return D[e]=n,n.catch(j.bind(null,e,n)),n}function j(e,t){D[e]===t&&delete D[e]}async function M(){O??=import(`./runtime-recovery-codes-CuqYWqK7.js`),k??=Promise.all([O,import(`./mountRecoveryCodeBackupSurface-D3QFgMGE.js`)]).then(()=>void 0),await k}function N(e){switch(e){case`auth`:return import(`./runtime-auth-C0V-5znH.js`);case`near`:return import(`./runtime-near-DRrdWzmr.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-CDSZ3pxS.js`);case`email_otp`:return import(`./runtime-email-otp-DXuxFOjL.js`);case`recovery`:return import(`./runtime-recovery-DlJlaZlf.js`);case`export`:return import(`./runtime-export-Ba12ChDI.js`);case`device_link`:return import(`./runtime-device-link-B1jpHQSF.js`);case`preferences`:return import(`./runtime-preferences-BWyhRaBA.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){switch(e.type){case`PM_GET_RECENT_UNLOCKS`:case`PM_GET_CONFIRMATION_CONFIG`:return!0;case`PM_GET_EXACT_WALLET_SESSION_STATE`:{let t=e.request.payload;if(!t||typeof t!=`object`)return!1;let n=Reflect.get(t,`authenticationRead`),r=Reflect.get(t,`wallet`);return(n===`restore`||n===`current`)&&!!r&&typeof r==`object`&&Reflect.get(r,`kind`)===`current`}default:return!1}}function I(e){switch(e.type){case`PM_GET_EXACT_WALLET_SESSION_STATE`:return{revision:p(),walletId:null,state:{kind:`wallet_locked`},session:d()};case`PM_GET_RECENT_UNLOCKS`:return{walletIds:[],accountIds:[],accounts:[],lastUsedAccount:null};case`PM_GET_CONFIRMATION_CONFIG`:return{walletId:null,confirmationConfig:w,revision:0}}}let L=null;function R(){return L??=B().finally(z),L}function z(){L=null}async function B(){try{return typeof indexedDB>`u`||typeof indexedDB.databases!=`function`?!1:(await indexedDB.databases()).some(V)?await H():!0}catch{return!1}}function V(e){return e.name===r}function H(){return new Promise(e=>{let t=indexedDB.open(r);t.onupgradeneeded=()=>t.transaction?.abort(),t.onerror=()=>e(!1),t.onsuccess=()=>{let n=t.result;n.onversionchange=()=>n.close(),U(n).then(t=>{n.close(),e(t===0)},()=>{n.close(),e(!1)})}})}function U(e){let t=Array.from(e.objectStoreNames);return t.length===0?Promise.resolve(0):new Promise((n,r)=>{let i=e.transaction(t,`readonly`),a=0;for(let e of t){let t=i.objectStore(e).count();t.onsuccess=()=>{a+=t.result}}i.oncomplete=()=>n(a),i.onerror=()=>r(i.error),i.onabort=()=>r(i.error)})}function W(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function G(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function K(e){try{return S(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function le(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_PREPARE_WALLET_RUNTIME`: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=K(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:G(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=K(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:G(o(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=K(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:G(m(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 W(e)}function ue(e){return e.kind!==`boot`}let q=!1;const de=[{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 J(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function fe(t){return!e(t)||!J(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!J(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function pe(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 Y(e){try{e.close()}catch{}}function me(e,t){if(t===`16.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return Y(e),!0}function X(e,t){return!t||t.has(e)}function Z(e,t,n,r){e.executionGeneration===t&&n(r)}function Q(e,t,n,r){return e.executionGeneration!==t||n(r)}function $(e={}){if(q)return;q=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o=!1,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},u=e=>{e&&r.add(e)},d=e=>!!e&&(r.has(e)||_(e)?.cancelled===!0),f=e=>{e&&r.delete(e)},p=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},m=e=>!e||!d(e)?!1:_(e)?.cancelled?!0:(p(e),f(e),!0),S=()=>{for(let e of de){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(x.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},w=async r=>{let l=r.data;if(!l||!t(l))return;let x=l.requestId,w=s.executionGeneration,T=Z.bind(null,s,w,c),E=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new h(`review_invalid_input`,`Review is unsupported for this request`);let e=g(l.transactionReview);if(e.requestId!==x)throw new h(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new h(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);E=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>T({type:`TRANSACTION_REVIEW_STATE`,requestId:x,payload:e}),e=>T({type:`ERROR`,requestId:x,payload:{code:e instanceof h?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&v(new h(`review_identity_changed`,`The wallet session changed`));let t=le(l);if(!ue(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:x});return;case`PM_PREPARE_WALLET_RUNTIME`:X(`auth`,e.supportedRuntimeRouteKinds)&&se(),c({type:`PONG`,requestId:x});return;case`PM_SET_CONFIG`:{let e=ee(s.configuration,te(t.request.payload)),r=a(s.configuration.kind===`configured`?s.configuration.config:null)!==a(e.config);if(s.configuration=e,r){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of i)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}s.onConfigurationChanged?.(),r&&(v(new h(`review_identity_changed`,`Wallet execution configuration changed`)),S()),c({type:`PONG`,requestId:x});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&_(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=g(r),i=_(t.requestId);if(t.requestId===e&&i&&ne(t,i.metadata)){let e=new h(ie(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{re(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:x});return}let i=e?_(e):void 0;if(i){i.cancel(new h(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:x});return}u(e),S(),e&&p(e),c({type:`PONG`,requestId:x});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-CpDMkSPm.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-CpDMkSPm.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!X(t.kind,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:x,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}if(x&&i.add(x),!o&&F(t)&&await R()&&!o){if(w!==s.executionGeneration||m(x))return;T({type:`PM_RESULT`,requestId:x,payload:{ok:!0,result:I(t)}});return}o=!0;let r=await oe(t);if(w!==s.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:E,state:s,executionGeneration:w,req:t.request,post:Z.bind(null,s,w,c),isCancelled:Q.bind(null,s,w,d),respondIfCancelled:Q.bind(null,s,w,m)})}catch(e){if(w!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`||E?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-CqHi6ji6.js`);if(w!==s.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=C(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(l.type);c({type:`ERROR`,requestId:x,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{x&&(i.delete(x),f(x)),E?.finish()}};window.addEventListener(`message`,e=>{let t=fe(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!pe(e.origin)){Y(n);return}if(!me(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=w,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:l}})}}})}try{$()}catch(e){console.error(`[WalletHost] init failed`,e)}export{$ as t};
@@ -1 +1 @@
1
- import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-DoftJdVQ.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`ecdsa`,`email_otp`,`export`,`recovery`,`preferences`])});
1
+ import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-C5KYWEcs.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`ecdsa`,`email_otp`,`export`,`recovery`,`preferences`])});
@@ -1 +1 @@
1
- import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-DoftJdVQ.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e();
1
+ import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-C5KYWEcs.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e();
@@ -1 +1 @@
1
- import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-DoftJdVQ.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`near`,`export`,`device_link`,`recovery`,`preferences`])});
1
+ import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-C5KYWEcs.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`near`,`export`,`device_link`,`recovery`,`preferences`])});
@@ -1 +1 @@
1
- import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-DoftJdVQ.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";export{e as initWalletIFrame};
1
+ import"./activeWalletSession-BtEHhe99.js";import"./walletDbName-BVZhb4xF.js";import"./signingSessionSeal-DqbjG8c8.js";import{t as e}from"./host-C5KYWEcs.js";import"./capabilityKinds-CqHVzVsJ.js";import"./errors-CI1xdN0d.js";export{e as initWalletIFrame};