@seams/wallet 0.30.0 → 0.31.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 +6 -6
- package/THIRD_PARTY_NOTICES.md +1 -127
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/sdk/{host-Csu5L7VF.js → host-DltV2Oan.js} +1 -1
- package/dist/esm/sdk/registration-Coh0_Nva.js +1 -0
- package/dist/esm/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/{public/sdk/runtime-auth-BMT_gIKI.js → esm/sdk/runtime-auth-CP6P681o.js} +1 -1
- package/dist/{public/sdk/runtime-device-link-DQe0aqRi.js → esm/sdk/runtime-device-link-CGDZQK-D.js} +1 -1
- package/dist/esm/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BiJYKWK4.js} +1 -1
- package/dist/esm/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-B0XCNDRb.js} +1 -1
- package/dist/esm/sdk/{runtime-export-BiyLbdCe.js → runtime-export-CXxv6KIx.js} +1 -1
- package/dist/esm/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CuyS57wu.js} +1 -1
- package/dist/esm/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-B2WBUZO7.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-KwVdSe94.js} +1 -1
- package/dist/esm/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-Iy1vecX0.js} +1 -1
- 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/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.d.ts +212 -233
- package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.js +675 -694
- package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/{host-Csu5L7VF.js → host-DltV2Oan.js} +1 -1
- package/dist/public/sdk/registration-Coh0_Nva.js +1 -0
- package/dist/public/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/{esm/sdk/runtime-auth-BMT_gIKI.js → public/sdk/runtime-auth-CP6P681o.js} +1 -1
- package/dist/{esm/sdk/runtime-device-link-DQe0aqRi.js → public/sdk/runtime-device-link-CGDZQK-D.js} +1 -1
- package/dist/public/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BiJYKWK4.js} +1 -1
- package/dist/public/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-B0XCNDRb.js} +1 -1
- package/dist/public/sdk/{runtime-export-BiyLbdCe.js → runtime-export-CXxv6KIx.js} +1 -1
- package/dist/public/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CuyS57wu.js} +1 -1
- package/dist/public/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-B2WBUZO7.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-KwVdSe94.js} +1 -1
- package/dist/public/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-Iy1vecX0.js} +1 -1
- 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/workers/device-linking-key.worker.js +454 -947
- package/dist/public/sdk/workers/email-otp.worker.js +588 -820
- package/dist/public/sdk/workers/evm_crypto_bg.wasm +0 -0
- package/dist/public/sdk/workers/passkey-mpc-export.worker.js +572 -804
- package/dist/public/sdk/workers/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/public/sdk/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/public/sdk/workers/tempo_signer_bg.wasm +0 -0
- package/dist/public/sdk/workers/wallet-custody-ceremony.worker.js +524 -971
- package/dist/public/sdk/workers/wallet_custody_ceremony_bg.wasm +0 -0
- package/dist/public/sdk/workers/wasm_signer_worker_bg.wasm +0 -0
- package/dist/public/wallet-assets.manifest.json +26 -26
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/workers/device-linking-key.worker.js +454 -947
- package/dist/workers/email-otp.worker.js +588 -820
- package/dist/workers/evm_crypto_bg.wasm +0 -0
- package/dist/workers/passkey-mpc-export.worker.js +572 -804
- package/dist/workers/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/workers/tempo_signer_bg.wasm +0 -0
- package/dist/workers/wallet-custody-ceremony.worker.js +524 -971
- package/dist/workers/wallet_custody_ceremony_bg.wasm +0 -0
- package/dist/workers/wasm_signer_worker_bg.wasm +0 -0
- package/package.json +17 -17
- package/dist/esm/sdk/registration-C7w_51wE.js +0 -1
- package/dist/public/sdk/registration-C7w_51wE.js +0 -1
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t}from"./digests-BIaE0DMd.js";import{n}from"./walletRegistrationSetupPrewarm-CEvGKQSg.js";import{t as r}from"./walletDbName-B6-CV_Rq.js";import{n as i,r as a,t as o}from"./configuration-BAad7ngq.js";import{a as ee,i as s,n as te,o as ne,r as re,t as c}from"./transactionReview-CGIlI835.js";import{t as l}from"./events-D6l0_ugy.js";import{i as u,n as d,t as ie}from"./transactionReviewAdmission-Cf_qUZJt.js";import{A as f,D as p,S as m,T as h,d as g,f as _,h as v,k as y,m as b,o as x,t as S,u as C,x as w,y as T}from"./ownerNearOperation-DCxxHcwX.js";import{t as E}from"./walletIframeIdentity-Cz82I_Uh.js";import{t as ae}from"./errors-BJBDbwHk.js";import{s as D}from"./ed25519OperationFingerprint-Dev4P6Og.js";function O(){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 k(){O(),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.`)),A(),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&&y(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;p()||f(r)}function A(){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 j={};let M=null,N=null;function oe(e){return e.request.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?e.request.payload?.authorization?.kind===`email_otp`?P(e.kind):(M??=import(`./runtime-recovery-codes-CFOWDVd9.js`),M):P(e.kind)}function se(){P(`auth`).catch(ce)}function ce(){}function P(e){let t=j[e];if(t)return t;let n=I(e);return j[e]=n,n.catch(le.bind(null,e,n)),n}function le(e,t){j[e]===t&&delete j[e]}async function F(){M??=import(`./runtime-recovery-codes-CFOWDVd9.js`),N??=Promise.all([M,import(`./mountRecoveryCodeBackupSurface-CMtByh-L.js`)]).then(()=>void 0),await N}function I(e){switch(e){case`auth`:return import(`./runtime-auth-BMT_gIKI.js`);case`near`:return import(`./runtime-near-Kk0n1FSf.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DKkeMMpm.js`);case`email_otp`:return import(`./runtime-email-otp-CzTe7r9I.js`);case`recovery`:return import(`./runtime-recovery-C9p1TU1w.js`);case`export`:return import(`./runtime-export-BiyLbdCe.js`);case`device_link`:return import(`./runtime-device-link-DQe0aqRi.js`);case`preferences`:return import(`./runtime-preferences-B-A3hddU.js`)}return L(e)}function L(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function R(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 z(e){switch(e.type){case`PM_GET_EXACT_WALLET_SESSION_STATE`:return{revision:C(),walletId:null,state:{kind:`wallet_locked`},session:g()};case`PM_GET_RECENT_UNLOCKS`:return{walletIds:[],accountIds:[],accounts:[],lastUsedAccount:null};case`PM_GET_CONFIRMATION_CONFIG`:return{walletId:null,confirmationConfig:D,revision:0}}}let B=null;function V(){return B??=U().finally(H),B}function H(){B=null}async function U(){try{return typeof indexedDB>`u`||typeof indexedDB.databases!=`function`?!1:(await indexedDB.databases()).some(ue)?await de():!0}catch{return!1}}function ue(e){return e.name===r}function de(){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(),fe(n).then(t=>{n.close(),e(t===0)},()=>{n.close(),e(!1)})}})}function fe(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 pe(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function W(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function G(e){try{return E(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function me(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_OWNER_NEAR_TRANSACTION`:return{kind:`near`,type:e.type,request:{type:e.type,requestId:E(e.requestId),payload:S(e.payload)}};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ACTIVATE_AUTH_METHOD`:case`PM_GET_AUTH_METHOD_AVAILABILITY`:case`PM_SET_AUTH_METHOD_ENABLED`: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=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(m(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(T(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_WALLET_CONNECTION`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(h(e.payload),`wallet connection resolution`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(w(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_EXTERNAL_OWNER_AUTH`:{let t=x(e.payload);if(t.action!==`associate`&&t.action!==`unlink`)throw Error(`Owner request is invalid`);return{kind:`auth`,type:e.type,request:{type:e.type,requestId:E(e.requestId),payload:t,options:e.options}}}case`PM_UNLOCK`:case`PM_UNLOCK_AUTH_METHOD`:case`PM_EXTERNAL_AUTH`: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 pe(e)}function he(e){return e.kind!==`boot`}let K=!1;const ge=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-auth-method-activation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function q(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function _e(t){return!e(t)||!q(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!q(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function ve(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 J(e){try{e.close()}catch{}}function Y(e,t){if(t===`20.0.0`)return!1;let n={expectedProtocolVersion:v,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:b,message:`Wallet iframe protocol version mismatch: expected ${v}, received ${t??`missing`}`,details:n}})}catch{}return J(e),!0}function X(e,t){return!t||t.has(e)}function Z(e,t,n,r){e.executionGeneration===t&&n(r)}function ye(e,t,n,r){if(t===`PM_SIGN_AND_SEND_TX`){e({type:`PM_RESULT`,requestId:n,payload:{ok:!0,result:_(r,`not_submitted`)}});return}e({type:`ERROR`,requestId:n,payload:{code:r instanceof c?r.code:`cancelled`,message:r.message}})}function Q(e,t,n,r){return e.executionGeneration!==t||n(r)}function $(e={}){if(K)return;K=!0,k(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&F().catch(()=>void 0);let r=new Set,f=new Set,p=new Set,m=!1,h={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},g=e=>{try{h.port?.postMessage(e)}catch{}},y=e=>{e&&r.add(e)},b=e=>!!e&&(r.has(e)||u(e)?.cancelled===!0),x=e=>{e&&r.delete(e)},S=e=>{e&&g({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},C=e=>!e||!b(e)?!1:u(e)?.cancelled?!0:(S(e),x(e),!0),w=()=>{for(let e of ge){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(l.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},T=async r=>{let l=r.data;if(!l||!t(l))return;let v=l.requestId,T=typeof v==`string`&&l.type!==`PM_CANCEL`;if(T){if(p.has(v)){g({type:`ERROR`,requestId:v,payload:{code:`request_in_progress`,message:`Request identity is already active`}});return}p.add(v)}let E=h.executionGeneration,D=Z.bind(null,h,E,g),O=null,k=`admission`;try{let t=l.type.startsWith(`PM_SIGN_`)?await(await import(`./runtimeContext-ChuvOC0h.js`)).walletAuthMethodReviewPolicy(h,l):{kind:`disabled`};if(h.executionGeneration!==E||b(v))return;if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new c(`review_invalid_input`,`Review is unsupported for this request`);let e=s(l.transactionReview);if(e.requestId!==v)throw new c(`review_invalid_input`,`Review request identity mismatch`);let n=l.payload?.options?.confirmationConfig;if(n?.uiMode!==`modal`||n.behavior!==`requireClick`)throw new c(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);O=new ie(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>D({type:`TRANSACTION_REVIEW_STATE`,requestId:v,payload:e}),ye.bind(null,D,l.type,v),t)}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&d(new c(`review_identity_changed`,`The wallet session changed`));let r=me(l);if(!he(r))switch(r.type){case`PING`:g({type:`PONG`,requestId:v});return;case`PM_PREPARE_WALLET_RUNTIME`:X(`auth`,e.supportedRuntimeRouteKinds)&&se(),g({type:`PONG`,requestId:v});return;case`PM_SET_CONFIG`:{let e=o(h.configuration,i(r.request.payload)),t=a(h.configuration.kind===`configured`?h.configuration.config:null)!==a(e.config);if(h.configuration=e,t){h.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of f)g({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});f.clear()}h.onConfigurationChanged?.(),t&&(d(new c(`review_identity_changed`,`Wallet execution configuration changed`)),w()),g({type:`PONG`,requestId:v});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=re(r.request.payload);e&&u(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=r.request.payload?.requestId,t=r.request.payload,n=t&&typeof t==`object`?Reflect.get(t,`transactionReview`):void 0;if(n!==void 0){let r=s(n),i=u(r.requestId);if(r.requestId===e&&i&&ee(r,i.metadata)){let e=new c(ne(t&&typeof t==`object`?Reflect.get(t,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{te(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}g({type:`PONG`,requestId:v});return}let i=e?u(e):void 0;if(i){i.cancel(new c(`cancelled`,`Request cancelled`)),g({type:`PONG`,requestId:v});return}y(e),(await import(`./deviceLinkApproval-C4T8XAmi.js`).then(e=>e.i)).cancelDeviceLinkApproval(typeof e==`string`?{kind:`request`,requestId:e}:{kind:`all`}),w(),e&&S(e),g({type:`PONG`,requestId:v});return}case`PM_SET_TRANSACTION_VIEW`:{let e=r.request.payload,t=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,n=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof t==`string`&&(n===`toast`||n===`closed`)&&(await import(`./transaction-activity-BXSxMp1E.js`).then(e=>e.o)).setTransactionActivityView(t,n);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=r.request.payload,t=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof t==`string`&&(await import(`./transaction-activity-BXSxMp1E.js`).then(e=>e.o)).transactionBroadcastStarted(t);return}}if(!X(r.kind,e.supportedRuntimeRouteKinds)){g({type:`ERROR`,requestId:v,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${r.type}`}});return}if(v&&f.add(v),!m&&R(r)&&await V()&&!m){if(E!==h.executionGeneration||C(v))return;D({type:`PM_RESULT`,requestId:v,payload:{ok:!0,result:z(r)}});return}m=!0;let p=await oe(r);if(E!==h.executionGeneration)return;k=`runtime`,await p.handleWalletHostRuntimeRequest({transactionReview:O,state:h,executionGeneration:E,req:r.request,post:Z.bind(null,h,E,g),isCancelled:Q.bind(null,h,E,b),respondIfCancelled:Q.bind(null,h,E,C)})}catch(e){if(E!==h.executionGeneration&&l.type!==`PM_SET_CONFIG`||O?.cancelled)return;if(k===`admission`&&(l.type===`PM_SIGN_AND_SEND_TX`||l.type===`PM_SEND_TRANSACTION`)){D({type:`PM_RESULT`,requestId:v,payload:{ok:!0,result:_(e,`not_submitted`)}});return}let t=await import(`./canonicalSignerErrorCode-CX5PBpkt.js`);if(E!==h.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=ae(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);g({type:`ERROR`,requestId:v,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{T&&(p.delete(v),f.delete(v),x(v)),O?.finish()}};window.addEventListener(`message`,e=>{let t=_e(e.data),n=e.ports[0];if(!(!t||!n||h.port)){if(e.source!==window.parent||!ve(e.origin)){J(n);return}if(!Y(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(h.parentOrigin=e.origin),h.port=n;try{h.port.onmessage=T,h.port.start?.()}catch{}g({type:`READY`,payload:{protocolVersion:v}})}}})}try{$()}catch(e){console.error(`[WalletHost] init failed`,e)}export{$ as t};
|
|
1
|
+
import{g as e,h as t}from"./digests-BIaE0DMd.js";import{n}from"./walletRegistrationSetupPrewarm-CEvGKQSg.js";import{t as r}from"./walletDbName-B6-CV_Rq.js";import{n as i,r as a,t as o}from"./configuration-BAad7ngq.js";import{a as ee,i as s,n as te,o as ne,r as re,t as c}from"./transactionReview-CGIlI835.js";import{t as l}from"./events-D6l0_ugy.js";import{i as u,n as d,t as ie}from"./transactionReviewAdmission-Cf_qUZJt.js";import{A as f,D as p,S as m,T as h,d as g,f as _,h as v,k as y,m as b,o as x,t as S,u as C,x as w,y as T}from"./ownerNearOperation-DCxxHcwX.js";import{t as E}from"./walletIframeIdentity-Cz82I_Uh.js";import{t as ae}from"./errors-BJBDbwHk.js";import{s as D}from"./ed25519OperationFingerprint-Dev4P6Og.js";function O(){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 k(){O(),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.`)),A(),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&&y(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;p()||f(r)}function A(){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 j={};let M=null,N=null;function oe(e){return e.request.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?e.request.payload?.authorization?.kind===`email_otp`?P(e.kind):(M??=import(`./runtime-recovery-codes-CFOWDVd9.js`),M):P(e.kind)}function se(){P(`auth`).catch(ce)}function ce(){}function P(e){let t=j[e];if(t)return t;let n=I(e);return j[e]=n,n.catch(le.bind(null,e,n)),n}function le(e,t){j[e]===t&&delete j[e]}async function F(){M??=import(`./runtime-recovery-codes-CFOWDVd9.js`),N??=Promise.all([M,import(`./mountRecoveryCodeBackupSurface-CMtByh-L.js`)]).then(()=>void 0),await N}function I(e){switch(e){case`auth`:return import(`./runtime-auth-CP6P681o.js`);case`near`:return import(`./runtime-near-CuyS57wu.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-BiJYKWK4.js`);case`email_otp`:return import(`./runtime-email-otp-B0XCNDRb.js`);case`recovery`:return import(`./runtime-recovery-KwVdSe94.js`);case`export`:return import(`./runtime-export-CXxv6KIx.js`);case`device_link`:return import(`./runtime-device-link-CGDZQK-D.js`);case`preferences`:return import(`./runtime-preferences-B2WBUZO7.js`)}return L(e)}function L(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function R(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 z(e){switch(e.type){case`PM_GET_EXACT_WALLET_SESSION_STATE`:return{revision:C(),walletId:null,state:{kind:`wallet_locked`},session:g()};case`PM_GET_RECENT_UNLOCKS`:return{walletIds:[],accountIds:[],accounts:[],lastUsedAccount:null};case`PM_GET_CONFIRMATION_CONFIG`:return{walletId:null,confirmationConfig:D,revision:0}}}let B=null;function V(){return B??=U().finally(H),B}function H(){B=null}async function U(){try{return typeof indexedDB>`u`||typeof indexedDB.databases!=`function`?!1:(await indexedDB.databases()).some(ue)?await de():!0}catch{return!1}}function ue(e){return e.name===r}function de(){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(),fe(n).then(t=>{n.close(),e(t===0)},()=>{n.close(),e(!1)})}})}function fe(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 pe(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function W(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function G(e){try{return E(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function me(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_OWNER_NEAR_TRANSACTION`:return{kind:`near`,type:e.type,request:{type:e.type,requestId:E(e.requestId),payload:S(e.payload)}};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ACTIVATE_AUTH_METHOD`:case`PM_GET_AUTH_METHOD_AVAILABILITY`:case`PM_SET_AUTH_METHOD_ENABLED`: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=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(m(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(T(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_WALLET_CONNECTION`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(h(e.payload),`wallet connection resolution`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=G(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:W(w(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_EXTERNAL_OWNER_AUTH`:{let t=x(e.payload);if(t.action!==`associate`&&t.action!==`unlink`)throw Error(`Owner request is invalid`);return{kind:`auth`,type:e.type,request:{type:e.type,requestId:E(e.requestId),payload:t,options:e.options}}}case`PM_UNLOCK`:case`PM_UNLOCK_AUTH_METHOD`:case`PM_EXTERNAL_AUTH`: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 pe(e)}function he(e){return e.kind!==`boot`}let K=!1;const ge=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-auth-method-activation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function q(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function _e(t){return!e(t)||!q(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!q(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function ve(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 J(e){try{e.close()}catch{}}function Y(e,t){if(t===`20.0.0`)return!1;let n={expectedProtocolVersion:v,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:b,message:`Wallet iframe protocol version mismatch: expected ${v}, received ${t??`missing`}`,details:n}})}catch{}return J(e),!0}function X(e,t){return!t||t.has(e)}function Z(e,t,n,r){e.executionGeneration===t&&n(r)}function ye(e,t,n,r){if(t===`PM_SIGN_AND_SEND_TX`){e({type:`PM_RESULT`,requestId:n,payload:{ok:!0,result:_(r,`not_submitted`)}});return}e({type:`ERROR`,requestId:n,payload:{code:r instanceof c?r.code:`cancelled`,message:r.message}})}function Q(e,t,n,r){return e.executionGeneration!==t||n(r)}function $(e={}){if(K)return;K=!0,k(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&F().catch(()=>void 0);let r=new Set,f=new Set,p=new Set,m=!1,h={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},g=e=>{try{h.port?.postMessage(e)}catch{}},y=e=>{e&&r.add(e)},b=e=>!!e&&(r.has(e)||u(e)?.cancelled===!0),x=e=>{e&&r.delete(e)},S=e=>{e&&g({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},C=e=>!e||!b(e)?!1:u(e)?.cancelled?!0:(S(e),x(e),!0),w=()=>{for(let e of ge){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(l.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},T=async r=>{let l=r.data;if(!l||!t(l))return;let v=l.requestId,T=typeof v==`string`&&l.type!==`PM_CANCEL`;if(T){if(p.has(v)){g({type:`ERROR`,requestId:v,payload:{code:`request_in_progress`,message:`Request identity is already active`}});return}p.add(v)}let E=h.executionGeneration,D=Z.bind(null,h,E,g),O=null,k=`admission`;try{let t=l.type.startsWith(`PM_SIGN_`)?await(await import(`./runtimeContext-Iy1vecX0.js`)).walletAuthMethodReviewPolicy(h,l):{kind:`disabled`};if(h.executionGeneration!==E||b(v))return;if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new c(`review_invalid_input`,`Review is unsupported for this request`);let e=s(l.transactionReview);if(e.requestId!==v)throw new c(`review_invalid_input`,`Review request identity mismatch`);let n=l.payload?.options?.confirmationConfig;if(n?.uiMode!==`modal`||n.behavior!==`requireClick`)throw new c(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);O=new ie(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>D({type:`TRANSACTION_REVIEW_STATE`,requestId:v,payload:e}),ye.bind(null,D,l.type,v),t)}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&d(new c(`review_identity_changed`,`The wallet session changed`));let r=me(l);if(!he(r))switch(r.type){case`PING`:g({type:`PONG`,requestId:v});return;case`PM_PREPARE_WALLET_RUNTIME`:X(`auth`,e.supportedRuntimeRouteKinds)&&se(),g({type:`PONG`,requestId:v});return;case`PM_SET_CONFIG`:{let e=o(h.configuration,i(r.request.payload)),t=a(h.configuration.kind===`configured`?h.configuration.config:null)!==a(e.config);if(h.configuration=e,t){h.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of f)g({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});f.clear()}h.onConfigurationChanged?.(),t&&(d(new c(`review_identity_changed`,`Wallet execution configuration changed`)),w()),g({type:`PONG`,requestId:v});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=re(r.request.payload);e&&u(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=r.request.payload?.requestId,t=r.request.payload,n=t&&typeof t==`object`?Reflect.get(t,`transactionReview`):void 0;if(n!==void 0){let r=s(n),i=u(r.requestId);if(r.requestId===e&&i&&ee(r,i.metadata)){let e=new c(ne(t&&typeof t==`object`?Reflect.get(t,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{te(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}g({type:`PONG`,requestId:v});return}let i=e?u(e):void 0;if(i){i.cancel(new c(`cancelled`,`Request cancelled`)),g({type:`PONG`,requestId:v});return}y(e),(await import(`./deviceLinkApproval-C4T8XAmi.js`).then(e=>e.i)).cancelDeviceLinkApproval(typeof e==`string`?{kind:`request`,requestId:e}:{kind:`all`}),w(),e&&S(e),g({type:`PONG`,requestId:v});return}case`PM_SET_TRANSACTION_VIEW`:{let e=r.request.payload,t=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,n=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof t==`string`&&(n===`toast`||n===`closed`)&&(await import(`./transaction-activity-BXSxMp1E.js`).then(e=>e.o)).setTransactionActivityView(t,n);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=r.request.payload,t=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof t==`string`&&(await import(`./transaction-activity-BXSxMp1E.js`).then(e=>e.o)).transactionBroadcastStarted(t);return}}if(!X(r.kind,e.supportedRuntimeRouteKinds)){g({type:`ERROR`,requestId:v,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${r.type}`}});return}if(v&&f.add(v),!m&&R(r)&&await V()&&!m){if(E!==h.executionGeneration||C(v))return;D({type:`PM_RESULT`,requestId:v,payload:{ok:!0,result:z(r)}});return}m=!0;let p=await oe(r);if(E!==h.executionGeneration)return;k=`runtime`,await p.handleWalletHostRuntimeRequest({transactionReview:O,state:h,executionGeneration:E,req:r.request,post:Z.bind(null,h,E,g),isCancelled:Q.bind(null,h,E,b),respondIfCancelled:Q.bind(null,h,E,C)})}catch(e){if(E!==h.executionGeneration&&l.type!==`PM_SET_CONFIG`||O?.cancelled)return;if(k===`admission`&&(l.type===`PM_SIGN_AND_SEND_TX`||l.type===`PM_SEND_TRANSACTION`)){D({type:`PM_RESULT`,requestId:v,payload:{ok:!0,result:_(e,`not_submitted`)}});return}let t=await import(`./canonicalSignerErrorCode-CX5PBpkt.js`);if(E!==h.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=ae(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);g({type:`ERROR`,requestId:v,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{T&&(p.delete(v),f.delete(v),x(v)),O?.finish()}};window.addEventListener(`message`,e=>{let t=_e(e.data),n=e.ports[0];if(!(!t||!n||h.port)){if(e.source!==window.parent||!ve(e.origin)){J(n);return}if(!Y(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(h.parentOrigin=e.origin),h.port=n;try{h.port.onmessage=T,h.port.start?.()}catch{}g({type:`READY`,payload:{protocolVersion:v}})}}})}try{$()}catch(e){console.error(`[WalletHost] init failed`,e)}export{$ as t};
|