@seams/wallet 0.30.0 → 0.33.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 +7 -7
- package/THIRD_PARTY_NOTICES.md +1 -127
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuFooter.js +38 -10
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.js +23 -67
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/RecoveryOptions.js +60 -0
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/mountAuthMenuSurface.js +6 -0
- package/dist/esm/SeamsWeb/walletIframe/shared/authMenuPresentation.js +28 -0
- package/dist/esm/SeamsWeb/walletIframe/shared/messages.js +21 -10
- package/dist/esm/SeamsWeb/walletIframe/shared/walletAlternatives.js +4 -14
- package/dist/esm/core/ui/walletIcon.js +11 -3
- package/dist/esm/externalNear/controller.js +3 -2
- package/dist/esm/externalNear/meteor.js +1 -1
- package/dist/esm/externalNear/meteorRequest.js +8 -2
- package/dist/esm/react/components/HostedSeamsAuthMenu/shell.js +17 -1
- package/dist/esm/sdk/{host-Csu5L7VF.js → host-BsVFOugh.js} +1 -1
- package/dist/esm/sdk/ownerNearOperation-BsIdSH0C.js +1 -0
- 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/esm/sdk/runtime-auth-CJCU2yJi.js +1 -0
- package/dist/esm/sdk/{runtime-device-link-DQe0aqRi.js → runtime-device-link-C0oXLSnz.js} +1 -1
- package/dist/esm/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BC8u9NuI.js} +1 -1
- package/dist/esm/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-Cl4iu0z7.js} +1 -1
- package/dist/esm/sdk/{runtime-export-BiyLbdCe.js → runtime-export-BdhfErGJ.js} +1 -1
- package/dist/esm/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CT2ALBct.js} +1 -1
- package/dist/esm/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-fN2G9tct.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-n-TGLkwz.js} +1 -1
- package/dist/esm/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-DI28d8Qu.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/sdk/wallet-service.css +2 -0
- package/dist/esm/sdk/wallet-ui.css +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-BsVFOugh.js} +1 -1
- package/dist/public/sdk/ownerNearOperation-BsIdSH0C.js +1 -0
- 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/public/sdk/runtime-auth-CJCU2yJi.js +1 -0
- package/dist/public/sdk/{runtime-device-link-DQe0aqRi.js → runtime-device-link-C0oXLSnz.js} +1 -1
- package/dist/public/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BC8u9NuI.js} +1 -1
- package/dist/public/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-Cl4iu0z7.js} +1 -1
- package/dist/public/sdk/{runtime-export-BiyLbdCe.js → runtime-export-BdhfErGJ.js} +1 -1
- package/dist/public/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CT2ALBct.js} +1 -1
- package/dist/public/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-fN2G9tct.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-n-TGLkwz.js} +1 -1
- package/dist/public/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-DI28d8Qu.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/wallet-service.css +2 -0
- package/dist/public/sdk/wallet-ui.css +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 +29 -29
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuFooter.d.ts +4 -0
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.d.ts +3 -1
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/RecoveryOptions.d.ts +11 -0
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/mountAuthMenuSurface.d.ts +3 -0
- package/dist/types/wallet/src/SeamsWeb/walletIframe/shared/authMenuPresentation.d.ts +13 -0
- package/dist/types/wallet/src/SeamsWeb/walletIframe/shared/messages.d.ts +7 -1
- package/dist/types/wallet/src/core/ui/walletIcon.d.ts +1 -0
- package/dist/types/wallet/src/externalNear/meteorRequest.d.ts +3 -0
- package/dist/types/wallet/src/index.d.ts +1 -1
- package/dist/types/wallet/src/react/components/HostedSeamsAuthMenu/public.d.ts +1 -1
- package/dist/types/wallet/src/react/components/HostedSeamsAuthMenu/types.d.ts +6 -2
- package/dist/types/wallet/src/react/index.d.ts +1 -1
- 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/ownerNearOperation-DCxxHcwX.js +0 -1
- package/dist/esm/sdk/registration-C7w_51wE.js +0 -1
- package/dist/esm/sdk/runtime-auth-BMT_gIKI.js +0 -1
- package/dist/public/sdk/ownerNearOperation-DCxxHcwX.js +0 -1
- package/dist/public/sdk/registration-C7w_51wE.js +0 -1
- package/dist/public/sdk/runtime-auth-BMT_gIKI.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-BsIdSH0C.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-CJCU2yJi.js`);case`near`:return import(`./runtime-near-CT2ALBct.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-BC8u9NuI.js`);case`email_otp`:return import(`./runtime-email-otp-Cl4iu0z7.js`);case`recovery`:return import(`./runtime-recovery-n-TGLkwz.js`);case`export`:return import(`./runtime-export-BdhfErGJ.js`);case`device_link`:return import(`./runtime-device-link-C0oXLSnz.js`);case`preferences`:return import(`./runtime-preferences-fN2G9tct.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===`21.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-DI28d8Qu.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,k as t}from"./domainIds-t1lp25yU.js";import{S as n,b as r,g as i,x as a}from"./digests-BIaE0DMd.js";import{N as o,r as s}from"./activeWalletSession-HAOgRKzn.js";import{t as c}from"./walletIframeIdentity-Cz82I_Uh.js";import{r as l}from"./canonicalPrimitives-DKeS3M40.js";import{o as u}from"./errors-BJBDbwHk.js";import{s as d}from"./nearRpcResults-CeHdqaS4.js";import{n as f}from"./ed25519OperationFingerprint-Dev4P6Og.js";import{r as p}from"./types-D2Zk1W7I.js";import{t as m}from"./accountIds-DGWFzEnw.js";import{t as h}from"./actions-7SvZZut1.js";const g=`__SEAMS_WALLET_SDK_BASE__`,_=`SEAMS_WALLET_SDK_BASE_CHANGED`,v=`__SEAMS_WALLET_ASSET_VERSION__`;function y(){if(typeof window>`u`)return;let e=window[g];return typeof e==`string`&&e.length>0?e:void 0}function ee(e){if(typeof window>`u`)return;let t=window;t[g]=e,window.dispatchEvent(new CustomEvent(_,{detail:e}))}function te(){if(typeof window>`u`)return;let e=window[v];return typeof e==`string`&&e.length>0?e:void 0}function ne(e){if(typeof window>`u`)return;let t=e.trim();t&&(window[v]=t)}function re(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(_,t,{passive:!0}),()=>window.removeEventListener(_,t)}function b(e){let t=ie(e);if(t!==null)return t;if(typeof e!=`string`||e.length>131072)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function ie(e){return typeof e!=`string`||e.length>131072||!/^data:image\/(?:png|webp|jpeg|svg\+xml)[;,]/i.test(e)?null:e}function ae(e){if(e===void 0)return`collapsible`;switch(e){case`collapsible`:return`collapsible`;case`expanded`:return`expanded`;case`hidden`:return`hidden`;default:return null}}function oe(e){if(e===void 0)return{kind:`seams`};if(!i(e))return null;if(e.kind===`seams`&&Object.keys(e).length===1)return{kind:`seams`};if(e.kind!==`custom`||Object.keys(e).length!==3||typeof e.name!=`string`||!e.name.trim()||e.name.length>512)return null;let t=b(e.logo);return t?{kind:`custom`,logo:t,name:e.name.trim()}:null}function x(){return{primary:[],secondary:[]}}function S(e){return typeof e==`string`&&e.trim().length>0&&e.length<=512}function se(e){if(e===null)return{ok:!0,value:null};let t=b(e);return t===null?{ok:!1}:{ok:!0,value:t}}function C(e,t){if(!Array.isArray(e)||e.length>32)return null;let n=[];for(let r of e){if(!i(r)||!S(r.id)||!S(r.label)||typeof r.description!=`string`||r.description.length>512||t.has(r.id))return null;let e=se(r.icon);if(!e.ok)return null;t.add(r.id),n.push({id:r.id,label:r.label,description:r.description,icon:e.value})}return n}function ce(e){if(!i(e))return null;let t=new Set,n=C(e.primary,t),r=C(e.secondary,t);return n&&r?{primary:n,secondary:r}:null}function le(e){if(!i(e)||!i(e.result))return null;let t=k(e.authMenuSessionId),n;try{n=c(e.requestId)}catch{return null}if(!t||!S(e.connectionRequestId))return null;let r;switch(e.result.kind){case`connected`:case`cancelled`:if(e.result.message!==void 0)return null;r={kind:e.result.kind};break;case`failed`:if(!S(e.result.message))return null;r={kind:`failed`,message:e.result.message};break;default:return null}return{authMenuSessionId:t,requestId:n,connectionRequestId:e.connectionRequestId,result:r}}const w={login:{title:`Welcome back`,subtitle:``,passkeyCta:`Unlock with passkey`},register:{title:`Create a wallet`,subtitle:``,passkeyNameLabel:`Wallet name`,passkeyCta:`Create wallet with passkey`},common:{closeLabel:`Close`}};function T(e,t){return typeof e==`string`&&e.trim()||null}function E(e,t){let n=T(e,t);return n===null?null:n}function D(e){try{return c(e)}catch{return null}}function O(e,t){let n=new Set(t);return Object.keys(e).every(e=>n.has(e))}function k(e){return E(e,`authMenuSessionId`)}function A(e){return E(e,`externalAuthRequestId`)}function j(e){return i(e)?e:null}function M(e,t=new Set,n=!1){if(e===void 0)return n;if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>M(e,t,n));let r=j(e);return r!==null&&Object.values(r).every(e=>M(e,t,n))}function N(e,t){return T(e,`copy`)??t}function P(e,t){let n=j(e);return{title:N(n?.title,t.title),subtitle:N(n?.subtitle,t.subtitle),passkeyCta:N(n?.passkeyCta,t.passkeyCta)}}function F(e){let t=j(e),n=j(t?.register);return{login:P(t?.login,w.login),register:{...P(t?.register,w.register),passkeyNameLabel:N(n?.passkeyNameLabel,w.register.passkeyNameLabel)},common:{closeLabel:N(j(t?.common)?.closeLabel,w.common.closeLabel)}}}function I(e){return e===`google`?e:null}function L(e){return e===`login`||e===`register`?e:null}function R(e){return e===`implicit_wallet`||e===`sponsored_named_near_account`?e:null}function z(e){return e===`close_button`||e===`component_unmounted`||e===`connection_closed`?e:null}function B(e,t){if(e===void 0)return!0;let n=j(e);return n!==null&&O(n,t)}function V(e){let t=j(e);return!t||!O(t,[`login`,`register`,`common`])?!1:B(t.login,[`title`,`subtitle`,`passkeyCta`])&&B(t.register,[`title`,`subtitle`,`passkeyCta`,`passkeyNameLabel`])&&B(t.common,[`closeLabel`])}function H(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){let e=I(n);if(!e)return null;t.push(e)}return t}function U(e){let n=j(e);if(!n||!M(n,new Set,!0)||n.kind!==`hosted_auth_menu_open_v1`||!O(n,[`kind`,`authMenuSessionId`,`initialMode`,`initialHeightCssPx`,`loginTarget`,`registrationAccountInput`,`showRegistrationInput`,`showProgress`,`copy`,`enabledExternalProviders`,`walletAlternatives`,`recoveryOptions`,`footerBrand`])||!V(n.copy))return null;let r=k(n.authMenuSessionId),i=L(n.initialMode),a=n.initialHeightCssPx;if(a!==void 0&&(typeof a!=`number`||!Number.isFinite(a)||a<=0))return null;let o=j(n.loginTarget),s=o?.kind===`wallet`||o?.kind===`wallet_sync`?t(o.walletId):null,c=o?.kind===`discoverable`&&O(o,[`kind`])?{kind:`discoverable`}:o?.kind===`wallet`&&O(o,[`kind`,`walletId`])&&s?.ok?{kind:`wallet`,walletId:s.value}:o?.kind===`wallet_sync`&&O(o,[`kind`,`walletId`])&&s?.ok?{kind:`wallet_sync`,walletId:s.value}:null,l=R(n.registrationAccountInput),u=H(n.enabledExternalProviders),d=ae(n.recoveryOptions),f=oe(n.footerBrand),p=n.walletAlternatives===void 0?x():ce(n.walletAlternatives);return!r||!i||!c||!l||typeof n.showRegistrationInput!=`boolean`||typeof n.showProgress!=`boolean`||!u||!p||!d||!f||!M(n.copy,new Set,!0)?null:{kind:`hosted_auth_menu_open_v1`,authMenuSessionId:r,initialMode:i,initialHeightCssPx:a,loginTarget:c,registrationAccountInput:l,showRegistrationInput:n.showRegistrationInput,showProgress:n.showProgress,copy:F(n.copy),enabledExternalProviders:u,walletAlternatives:p,recoveryOptions:d,footerBrand:f}}function W(e){let t=j(e);if(!t||!M(t)||t.kind!==`hosted_auth_menu_error_v1`||!O(t,[`kind`,`authMenuSessionId`,`mode`,`message`]))return null;let n=k(t.authMenuSessionId),r=L(t.mode),i=T(t.message,`message`);return n&&r&&i?{kind:t.kind,authMenuSessionId:n,mode:r,message:i}:null}function ue(e){let t=j(e);if(!t||!M(t))return null;switch(t.kind){case`google_id_token`:{if(!O(t,[`kind`,`idToken`]))return null;let e=T(t.idToken,`idToken`);return e?{kind:t.kind,idToken:e}:null}case`cancelled`:return O(t,[`kind`,`reason`])&&t.reason===`user_cancelled`?{kind:t.kind,reason:t.reason}:null;case`failed`:{if(!O(t,[`kind`,`code`,`message`]))return null;let e=t.code===`provider_unavailable`||t.code===`provider_error`||t.code===`invalid_evidence`?t.code:null,n=T(t.message,`message`);return e&&n?{kind:t.kind,code:e,message:n}:null}default:return null}}function de(e){let t=j(e);if(!t||!M(t)||t.kind!==`hosted_auth_menu_external_auth_resolution_v1`||!O(t,[`kind`,`authMenuSessionId`,`externalAuthRequestId`,`requestId`,`evidence`]))return null;let n=k(t.authMenuSessionId),r=A(t.externalAuthRequestId),i=D(t.requestId),a=ue(t.evidence);return!n||!r||!i||!a?null:{kind:t.kind,authMenuSessionId:n,externalAuthRequestId:r,requestId:i,evidence:a}}function fe(e){let t=j(e);if(!t||!M(t)||t.kind!==`hosted_auth_menu_cancel_v1`||!O(t,[`kind`,`authMenuSessionId`,`requestId`,`reason`]))return null;let n=k(t.authMenuSessionId),r=D(t.requestId),i=z(t.reason);return n&&r&&i?{kind:t.kind,authMenuSessionId:n,requestId:r,reason:i}:null}const pe=`21.0.0`,me=`WALLET_IFRAME_PROTOCOL_VERSION_MISMATCH`,G=[`home`,`exchangeCode`,`nonce`,`appOrigin`,`walletOrigin`,`relayUrl`];function K(e,t){if(typeof e!=`string`||e.length===0||e.length>512||e.trim()!==e||/[\s\u0000-\u001f\u007f]/.test(e))throw Error(`${t} must be a compact opaque identifier`);return e}function q(e,t){if(typeof e!=`string`||e.length===0||e.trim()!==e)throw Error(`${t} must be a canonical HTTP origin`);let n;try{n=new URL(e)}catch{throw Error(`${t} must be a canonical HTTP origin`)}if(n.protocol!==`https:`&&n.protocol!==`http:`||n.origin!==e||n.pathname!==`/`||n.search!==``||n.hash!==``)throw Error(`${t} must be a canonical HTTP origin`);return n.origin}function he(e){if(!i(e))throw Error(`hosted-wallet redemption payload must be an exact object`);if(Object.keys(e).length!==G.length)throw Error(`hosted-wallet redemption payload fields are invalid`);for(let t of G)if(!Object.hasOwn(e,t))throw Error(`hosted-wallet redemption payload fields are invalid`);return{home:s(e.home),exchangeCode:K(e.exchangeCode,`exchangeCode`),nonce:K(e.nonce,`nonce`),appOrigin:q(e.appOrigin,`appOrigin`),walletOrigin:q(e.walletOrigin,`walletOrigin`),relayUrl:K(e.relayUrl,`relayUrl`)}}function ge(t){if(!i(t)||!O(t,[`scanRequestId`,`action`])||typeof t.scanRequestId!=`string`||t.scanRequestId.length===0||!i(t.action))return null;let n=t.action;if(n.kind===`cancel`)return O(n,[`kind`])?{scanRequestId:t.scanRequestId,action:{kind:n.kind}}:null;if(n.kind!==`select`||!O(n,[`kind`,`baseWalletAuthMethodId`]))return null;let r=e(n.baseWalletAuthMethodId);return r.ok?{scanRequestId:t.scanRequestId,action:{kind:n.kind,baseWalletAuthMethodId:r.value}}:null}function _e(e){if(!i(e)||!O(e,[`activationId`,`action`])||typeof e.activationId!=`string`||e.activationId.length===0||!i(e.action))return null;let t=e.action;switch(t.kind){case`create_passkey`:case`send_email_otp`:case`resend_email_otp`:return O(t,[`kind`])?{activationId:e.activationId,action:{kind:t.kind}}:null;case`submit_email_otp`:return O(t,[`kind`,`otpCode`])&&typeof t.otpCode==`string`&&/^\d{6}$/.test(t.otpCode)?{activationId:e.activationId,action:{kind:t.kind,otpCode:t.otpCode}}:null;default:return null}}function ve(e){let t=n(e,`NEAR transaction result`);if(t.success===!0){let e=r(t.transactionId,`transactionId`),n=d(t.result);if(e!==n.transaction.hash)throw Error(`NEAR transaction result contains different transaction hashes`);return typeof n.status==`object`&&`Failure`in n.status?J(e,Error(`NEAR transaction execution failed`)):{success:!0,transactionId:e,result:n}}if(t.success!==!1)throw Error(`Invalid NEAR transaction result`);let i=a(t.error,`NEAR transaction error`);switch(t.kind){case`not_submitted`:return{success:!1,kind:`not_submitted`,error:i};case`submission_unknown`:return{success:!1,kind:`submission_unknown`,error:i};case`unresolved`:return{success:!1,kind:`unresolved`,transactionId:r(t.transactionId,`transactionId`),error:i};default:throw Error(`Invalid NEAR transaction failure`)}}function ye(e,t){return{success:!1,kind:t,error:u(e)||`NEAR transaction failed`}}function J(e,t){return{success:!1,kind:`unresolved`,transactionId:e,error:u(t)}}function be(){return{appIdentity:{kind:`anonymous`},authentication:{kind:`signed_out`},capabilityProjection:{kind:`not_requested`},nonceDiagnostics:null}}let Y=0;function xe(){return Y+=1,Y}const Se=`/wallet/external-auth`;function Ce(e){let t=n(e,`external identity`),i=t.provider,a=r(t.issuer,`issuer`),o=r(t.subject,`subject`);switch(i){case`google`:if(a!==`https://accounts.google.com`)throw Error(`Invalid Google issuer`);return{provider:i,issuer:a,subject:o};case`application`:return{provider:i,issuer:a,subject:o};default:throw Error(`Invalid external identity provider`)}}function we(e){let i=n(e,`external owner challenge`),a=t(i.walletId);if(!a.ok)throw Error(`Invalid owner challenge wallet`);let s=a.value,c=r(i.attemptId,`attemptId`),u=Ce(i.identity),d=l(i.challengeB64u),f=o(i.expiresAtMs,`owner challenge expiry`);switch(i.kind){case`associate`:return{kind:`associate`,walletId:s,attemptId:c,identity:u,challengeB64u:d,expiresAtMs:f};case`unlink`:return{kind:`unlink`,walletId:s,attemptId:c,identity:u,challengeB64u:d,expiresAtMs:f,associationId:r(i.associationId,`associationId`)};default:throw Error(`Invalid owner challenge purpose`)}}function Te(e){let t=n(e,`external auth command`);if(t.action===`prepare`||t.action===`prepare_association`)return{action:t.action,walletId:r(t.walletId,`walletId`)};if(t.action===`unlink`)return{action:`unlink`,walletId:r(t.walletId,`walletId`),associationId:r(t.associationId,`associationId`)};if(t.action!==`authenticate`&&t.action!==`associate`)throw Error(`Invalid external authentication command`);let i=n(t.input,`authentication input`),a=r(i.walletId,`walletId`);if(i.method===`google`)return{action:t.action,input:{method:`google`,walletId:a,idToken:r(i.idToken,`idToken`)}};if(i.method===`handoff`)return{action:t.action,input:{method:`handoff`,walletId:a,attemptId:r(i.attemptId,`attemptId`),code:r(i.code,`code`)}};throw Error(`Unsupported external authentication method`)}function X(e){let i=n(e,`external authentication`),a=t(i.walletId);if(!a.ok||i.kind!==`external_authenticated`||i.provider!==`google`&&i.provider!==`application`||i.permission!==`wallet_settings_read`||`authMethod`in i)throw Error(`External authentication is invalid`);return{kind:`external_authenticated`,walletId:a.value,sessionId:r(i.sessionId,`sessionId`),associationId:r(i.associationId,`associationId`),environmentId:r(i.environmentId,`environmentId`),provider:i.provider,permission:`wallet_settings_read`,expiresAtMs:o(i.expiresAtMs,`expiresAtMs`)}}function Z(e){return{ok:!1,code:e,message:`Wallet authentication could not be completed.`}}function Q(e){let t=n(e,`external authentication failure`);switch(t.code){case`invalid_request`:case`invalid_credential`:case`access_denied`:case`expired`:case`superseded`:case`unavailable`:case`rate_limited`:case`cancelled`:return Z(t.code);default:return Z(`unavailable`)}}function Ee(e){let t=n(e,`external settings`);if(!Array.isArray(t.accounts)||!Array.isArray(t.methods)||!Array.isArray(t.devices))throw Error(`Invalid wallet settings`);return{authentication:X(t.authentication),accounts:t.accounts.map(De),methods:t.methods.map(Oe),devices:t.devices.map(ke)}}function De(e){let t=n(e,`account`);if(t.family!==`ed25519`&&t.family!==`ecdsa`)throw Error(`Invalid account family`);return{family:t.family,address:r(t.address,`address`),publicKey:r(t.publicKey,`publicKey`)}}function Oe(e){let t=n(e,`method`);if(t.kind!==`passkey`&&t.kind!==`email_otp`&&t.kind!==`voiceid`)throw Error(`Invalid method`);return{id:r(t.id,`id`),kind:t.kind}}function ke(e){return{id:r(n(e,`device`).id,`id`)}}function $(e){let i=n(e,`owner operation recovery`),a=r(i.operationId,`operationId`);if(!/^owner-near:[A-Za-z0-9_-]{32,64}$/.test(a))throw Error(`Invalid owner operation ID.`);let o=t(i.walletId);if(!o.ok)throw Error(`Invalid owner operation wallet.`);return{operationId:p.signingOperation(a),walletId:o.value,nearAccountId:m(r(i.nearAccountId,`nearAccountId`))}}function Ae(e){let t=n(e,`owner operation command`),r=X(t.authentication),i=$(t.recovery);if(i.walletId!==String(r.walletId))throw Error(`Owner operation wallet mismatch.`);switch(t.action){case`recover`:return{action:`recover`,authentication:r,recovery:i};case`approve`:{let e=n(t.transaction,`transaction`),a=f({nearAccountId:i.nearAccountId,receiverId:e.receiverId,actions:e.actions},`transaction`);if(a.nearAccountId!==String(i.nearAccountId))throw Error(`Owner operation account mismatch.`);let o=t.expiresAtMs;if(typeof o!=`number`||!Number.isSafeInteger(o)||o<=0)throw Error(`Invalid owner operation expiry.`);return{action:`approve`,authentication:r,recovery:i,expiresAtMs:o,transaction:{receiverId:a.receiverId,actions:a.actions.map(Me)}}}default:throw Error(`Invalid owner operation action.`)}}function je(e){let t=n(e,`owner operation outcome`);switch(t.kind){case`completed`:{let e=ve(t.result);if(!e.success)throw Error(`A completed owner operation requires a successful transaction.`);return{kind:`completed`,result:e}}case`reverted`:return{kind:`reverted`,transactionId:r(t.transactionId,`transactionId`),error:r(t.error,`error`)};case`cancelled`:return{kind:`cancelled`};case`expired`:return{kind:`expired`};case`failed`:return{kind:`failed`,error:r(t.error,`error`)};case`unknown`:return{kind:`unknown`,recovery:$(t.recovery)};default:throw Error(`Invalid owner operation outcome.`)}}function Me(e){switch(e.action_type){case`CreateAccount`:return{action_type:h.CreateAccount};case`DeployContract`:return{action_type:h.DeployContract,code:[...e.code]};case`FunctionCall`:return{action_type:h.FunctionCall,method_name:e.method_name,args:e.args,gas:e.gas,deposit:e.deposit};case`Transfer`:return{action_type:h.Transfer,deposit:e.deposit};case`Stake`:return{action_type:h.Stake,stake:e.stake,public_key:e.public_key};case`AddKey`:return{action_type:h.AddKey,public_key:e.public_key,access_key:e.access_key};case`DeleteKey`:return{action_type:h.DeleteKey,public_key:e.public_key};case`DeleteAccount`:return{action_type:h.DeleteAccount,beneficiary_id:e.beneficiary_id};case`DeployGlobalContract`:return{action_type:h.DeployGlobalContract,code:[...e.code],deploy_mode:e.deploy_mode};case`UseGlobalContract`:return e.account_id===void 0?{action_type:h.UseGlobalContract,code_hash:e.code_hash}:{action_type:h.UseGlobalContract,account_id:e.account_id};case`SignedDelegate`:throw Error(`Use the delegate API for delegated actions.`);default:throw Error(`Unsupported owner transaction action.`)}}export{ee as A,he as C,y as D,te as E,re as O,U as S,le as T,ge as _,Z as a,W as b,we as c,be as d,ye as f,A as g,pe as h,Se as i,ne as k,Ee as l,me as m,je as n,Te as o,J as p,$ as r,Q as s,Ae as t,xe as u,_e as v,x as w,de as x,fe as y};
|