@seams/wallet 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +3 -3
  2. package/dist/.build-inputs.sha256 +1 -1
  3. package/dist/esm/core/signingEngine/flows/signNear/shared/signatureOnlySigning.js +4 -9
  4. package/dist/esm/core/signingEngine/flows/signNear/signDelegate.js +10 -2
  5. package/dist/esm/core/signingEngine/flows/signNear/signNep413.js +6 -1
  6. package/dist/esm/sdk/{host-c1__wJwz.js → host-CWE1mHHY.js} +1 -1
  7. package/dist/esm/sdk/{runtime-auth-BKFyLISf.js → runtime-auth-DiEJDFkJ.js} +1 -1
  8. package/dist/{public/sdk/runtime-device-link-ENxdEXQW.js → esm/sdk/runtime-device-link-5u31t1H0.js} +1 -1
  9. package/dist/{public/sdk/runtime-ecdsa-tempo-DhGEb9U7.js → esm/sdk/runtime-ecdsa-tempo-C3CRzwph.js} +1 -1
  10. package/dist/esm/sdk/{runtime-email-otp-dgsP7XZi.js → runtime-email-otp-DHlirACG.js} +1 -1
  11. package/dist/esm/sdk/{runtime-export-D2RCm5Gk.js → runtime-export-CFy4-Ebn.js} +1 -1
  12. package/dist/esm/sdk/{runtime-near-Bf-9MFBQ.js → runtime-near-BxYOozPP.js} +1 -1
  13. package/dist/esm/sdk/{runtime-preferences-LQ8SPE7o.js → runtime-preferences-C1Exkn4E.js} +1 -1
  14. package/dist/esm/sdk/{runtime-recovery-BuEzJzuZ.js → runtime-recovery-DSbvI1DT.js} +1 -1
  15. package/dist/esm/sdk/{shared-8ffIBYw2.js → shared-6SvVPZD0.js} +1 -1
  16. package/dist/esm/sdk/{signNear-BhTkDm2-.js → signNear-C6ljzB87.js} +1 -1
  17. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  18. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  19. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  20. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  21. package/dist/public/headers.manifest.json +1 -1
  22. package/dist/public/sdk/{host-c1__wJwz.js → host-CWE1mHHY.js} +1 -1
  23. package/dist/public/sdk/{runtime-auth-BKFyLISf.js → runtime-auth-DiEJDFkJ.js} +1 -1
  24. package/dist/{esm/sdk/runtime-device-link-ENxdEXQW.js → public/sdk/runtime-device-link-5u31t1H0.js} +1 -1
  25. package/dist/{esm/sdk/runtime-ecdsa-tempo-DhGEb9U7.js → public/sdk/runtime-ecdsa-tempo-C3CRzwph.js} +1 -1
  26. package/dist/public/sdk/{runtime-email-otp-dgsP7XZi.js → runtime-email-otp-DHlirACG.js} +1 -1
  27. package/dist/public/sdk/{runtime-export-D2RCm5Gk.js → runtime-export-CFy4-Ebn.js} +1 -1
  28. package/dist/public/sdk/{runtime-near-Bf-9MFBQ.js → runtime-near-BxYOozPP.js} +1 -1
  29. package/dist/public/sdk/{runtime-preferences-LQ8SPE7o.js → runtime-preferences-C1Exkn4E.js} +1 -1
  30. package/dist/public/sdk/{runtime-recovery-BuEzJzuZ.js → runtime-recovery-DSbvI1DT.js} +1 -1
  31. package/dist/public/sdk/{shared-8ffIBYw2.js → shared-6SvVPZD0.js} +1 -1
  32. package/dist/public/sdk/{signNear-BhTkDm2-.js → signNear-C6ljzB87.js} +1 -1
  33. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  34. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  35. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  36. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  37. package/dist/public/sdk/workers/shamir3pass_runtime_bg.wasm +0 -0
  38. package/dist/public/wallet-assets.manifest.json +26 -26
  39. package/dist/public/wallet-service/index.html +4 -4
  40. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signatureOnlySigning.d.ts +2 -2
  41. package/dist/workers/shamir3pass_runtime_bg.wasm +0 -0
  42. package/package.json +1 -1
@@ -1 +1 @@
1
- import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-c1__wJwz.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`ecdsa`,`email_otp`,`export`,`recovery`,`preferences`])});
1
+ import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-CWE1mHHY.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`ecdsa`,`email_otp`,`export`,`recovery`,`preferences`])});
@@ -1 +1 @@
1
- import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-c1__wJwz.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e();
1
+ import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-CWE1mHHY.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e();
@@ -1 +1 @@
1
- import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-c1__wJwz.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`near`,`export`,`device_link`,`recovery`,`preferences`])});
1
+ import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-CWE1mHHY.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`near`,`export`,`device_link`,`recovery`,`preferences`])});
@@ -1 +1 @@
1
- import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-c1__wJwz.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";export{e as initWalletIFrame};
1
+ import"./primitives-CAcl7ON7.js";import"./sessionPolicy-J-RrlPZQ.js";import"./signingSessionSeal-CDLUmAFY.js";import{t as e}from"./host-CWE1mHHY.js";import"./activeWalletSession-DiZcKjB_.js";import"./capabilityKinds-CKQ4Uqnv.js";import"./errors-BZO3LF6G.js";export{e as initWalletIFrame};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "packageName": "@seams/wallet",
4
- "packageVersion": "0.9.2",
4
+ "packageVersion": "0.9.3",
5
5
  "assetRoot": "dist/public",
6
6
  "routeClasses": [
7
7
  {
@@ -1 +1 @@
1
- import{C as e,S as t}from"./chains-CiYQT1K4.js";import{_ as n,c as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,t as d,v as f}from"./messages-vxz27Way.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y,t as b,u as x}from"./transactionReviewAdmission-C-a3ctCJ.js";import{t as S}from"./events-DsQJQ0Cl.js";import{t as C}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as w}from"./errors-BZO3LF6G.js";function T(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function E(){T(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),D(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;i()||o(r)}function D(){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 O={};let k=null,A=null;function j(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),k):(O[e.kind]??=N(e.kind),O[e.kind])}async function M(){k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),A??=Promise.all([k,import(`./mountRecoveryCodeBackupSurface-B1qhFF6G.js`)]).then(()=>void 0),await A}function N(e){switch(e){case`auth`:return import(`./runtime-auth-BKFyLISf.js`);case`near`:return import(`./runtime-near-Bf-9MFBQ.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DhGEb9U7.js`);case`email_otp`:return import(`./runtime-email-otp-dgsP7XZi.js`);case`recovery`:return import(`./runtime-recovery-BuEzJzuZ.js`);case`export`:return import(`./runtime-export-D2RCm5Gk.js`);case`device_link`:return import(`./runtime-device-link-ENxdEXQW.js`);case`preferences`:return import(`./runtime-preferences-LQ8SPE7o.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(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 G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){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(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(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}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};
1
+ import{C as e,S as t}from"./chains-CiYQT1K4.js";import{_ as n,c as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,t as d,v as f}from"./messages-vxz27Way.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y,t as b,u as x}from"./transactionReviewAdmission-C-a3ctCJ.js";import{t as S}from"./events-DsQJQ0Cl.js";import{t as C}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as w}from"./errors-BZO3LF6G.js";function T(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function E(){T(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),D(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;i()||o(r)}function D(){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 O={};let k=null,A=null;function j(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),k):(O[e.kind]??=N(e.kind),O[e.kind])}async function M(){k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),A??=Promise.all([k,import(`./mountRecoveryCodeBackupSurface-B1qhFF6G.js`)]).then(()=>void 0),await A}function N(e){switch(e){case`auth`:return import(`./runtime-auth-DiEJDFkJ.js`);case`near`:return import(`./runtime-near-BxYOozPP.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-C3CRzwph.js`);case`email_otp`:return import(`./runtime-email-otp-DHlirACG.js`);case`recovery`:return import(`./runtime-recovery-DSbvI1DT.js`);case`export`:return import(`./runtime-export-CFy4-Ebn.js`);case`device_link`:return import(`./runtime-device-link-5u31t1H0.js`);case`preferences`:return import(`./runtime-preferences-C1Exkn4E.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(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 G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){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(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(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}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};