@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.
Files changed (66) hide show
  1. package/README.md +6 -6
  2. package/THIRD_PARTY_NOTICES.md +1 -127
  3. package/dist/.build-inputs.sha256 +1 -1
  4. package/dist/esm/sdk/{host-Csu5L7VF.js → host-DltV2Oan.js} +1 -1
  5. package/dist/esm/sdk/registration-Coh0_Nva.js +1 -0
  6. package/dist/esm/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
  7. package/dist/{public/sdk/runtime-auth-BMT_gIKI.js → esm/sdk/runtime-auth-CP6P681o.js} +1 -1
  8. package/dist/{public/sdk/runtime-device-link-DQe0aqRi.js → esm/sdk/runtime-device-link-CGDZQK-D.js} +1 -1
  9. package/dist/esm/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BiJYKWK4.js} +1 -1
  10. package/dist/esm/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-B0XCNDRb.js} +1 -1
  11. package/dist/esm/sdk/{runtime-export-BiyLbdCe.js → runtime-export-CXxv6KIx.js} +1 -1
  12. package/dist/esm/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CuyS57wu.js} +1 -1
  13. package/dist/esm/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-B2WBUZO7.js} +1 -1
  14. package/dist/esm/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-KwVdSe94.js} +1 -1
  15. package/dist/esm/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-Iy1vecX0.js} +1 -1
  16. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  17. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  18. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  19. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  20. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
  21. package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client_bg.wasm +0 -0
  22. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.d.ts +212 -233
  23. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.js +675 -694
  24. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client_bg.wasm +0 -0
  25. package/dist/public/headers.manifest.json +1 -1
  26. package/dist/public/sdk/{host-Csu5L7VF.js → host-DltV2Oan.js} +1 -1
  27. package/dist/public/sdk/registration-Coh0_Nva.js +1 -0
  28. package/dist/public/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
  29. package/dist/{esm/sdk/runtime-auth-BMT_gIKI.js → public/sdk/runtime-auth-CP6P681o.js} +1 -1
  30. package/dist/{esm/sdk/runtime-device-link-DQe0aqRi.js → public/sdk/runtime-device-link-CGDZQK-D.js} +1 -1
  31. package/dist/public/sdk/{runtime-ecdsa-tempo-DKkeMMpm.js → runtime-ecdsa-tempo-BiJYKWK4.js} +1 -1
  32. package/dist/public/sdk/{runtime-email-otp-CzTe7r9I.js → runtime-email-otp-B0XCNDRb.js} +1 -1
  33. package/dist/public/sdk/{runtime-export-BiyLbdCe.js → runtime-export-CXxv6KIx.js} +1 -1
  34. package/dist/public/sdk/{runtime-near-Kk0n1FSf.js → runtime-near-CuyS57wu.js} +1 -1
  35. package/dist/public/sdk/{runtime-preferences-B-A3hddU.js → runtime-preferences-B2WBUZO7.js} +1 -1
  36. package/dist/public/sdk/{runtime-recovery-C9p1TU1w.js → runtime-recovery-KwVdSe94.js} +1 -1
  37. package/dist/public/sdk/{runtimeContext-ChuvOC0h.js → runtimeContext-Iy1vecX0.js} +1 -1
  38. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  39. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  40. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  41. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  42. package/dist/public/sdk/workers/device-linking-key.worker.js +454 -947
  43. package/dist/public/sdk/workers/email-otp.worker.js +588 -820
  44. package/dist/public/sdk/workers/evm_crypto_bg.wasm +0 -0
  45. package/dist/public/sdk/workers/passkey-mpc-export.worker.js +572 -804
  46. package/dist/public/sdk/workers/router_ab_ecdsa_client_bg.wasm +0 -0
  47. package/dist/public/sdk/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
  48. package/dist/public/sdk/workers/tempo_signer_bg.wasm +0 -0
  49. package/dist/public/sdk/workers/wallet-custody-ceremony.worker.js +524 -971
  50. package/dist/public/sdk/workers/wallet_custody_ceremony_bg.wasm +0 -0
  51. package/dist/public/sdk/workers/wasm_signer_worker_bg.wasm +0 -0
  52. package/dist/public/wallet-assets.manifest.json +26 -26
  53. package/dist/public/wallet-service/index.html +4 -4
  54. package/dist/workers/device-linking-key.worker.js +454 -947
  55. package/dist/workers/email-otp.worker.js +588 -820
  56. package/dist/workers/evm_crypto_bg.wasm +0 -0
  57. package/dist/workers/passkey-mpc-export.worker.js +572 -804
  58. package/dist/workers/router_ab_ecdsa_client_bg.wasm +0 -0
  59. package/dist/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
  60. package/dist/workers/tempo_signer_bg.wasm +0 -0
  61. package/dist/workers/wallet-custody-ceremony.worker.js +524 -971
  62. package/dist/workers/wallet_custody_ceremony_bg.wasm +0 -0
  63. package/dist/workers/wasm_signer_worker_bg.wasm +0 -0
  64. package/package.json +17 -17
  65. package/dist/esm/sdk/registration-C7w_51wE.js +0 -1
  66. package/dist/public/sdk/registration-C7w_51wE.js +0 -1
@@ -1 +1 @@
1
- import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import{_ as e,v as t}from"./ownerNearOperation-DCxxHcwX.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{W as n,_ as r,h as i,m as a}from"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import{c as o}from"./sdkSentEvents-BFwv3mBw.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as s}from"./runtimeContext-ChuvOC0h.js";import{n as c,r as l,t as u}from"./shared-CkHhXgFB.js";function d(e,t,n,r){return n?(e.get(n)?.reject(Error(`A newer Email OTP method selection is required`)),new Promise((i,a)=>{let o=setTimeout(()=>f(e,n,Error(`Email OTP method selection timed out`)),9e5);e.set(n,{choices:r,resolve:e=>{clearTimeout(o),i(e)},reject:e=>{clearTimeout(o),a(e instanceof Error?e:Error(String(e)))}}),t.postProgress(n,{event:`wallet_device_link_email_otp_base_factor_selection_required_v1`,choices:r})})):Promise.reject(Error(`Device-link request id is required`))}function f(e,t,n){if(!t)return;let r=e.get(t);r&&(e.delete(t),r.reject(n))}function p(e,t){let n=e.get(t.scanRequestId);if(!n)throw Error(`Email OTP method selection is unavailable`);switch(t.action.kind){case`cancel`:e.delete(t.scanRequestId),n.reject(Error(`Device linking was cancelled`));return;case`select`:{let r=t.action.baseWalletAuthMethodId;if(!n.choices.some(e=>e.baseWalletAuthMethodId===r))throw Error(`The selected Email OTP method is unavailable for this linked device`);e.delete(t.scanRequestId),n.resolve(r);return}default:throw t.action,Error(`Unsupported Email OTP method selection action`)}}function m(e){switch(e.activation.kind){case`linked_device_target_passkey_activation_v1`:return{event:`wallet_device_link_target_factor_activation_v1`,activationId:e.activationId,activation:{kind:e.activation.kind}};case`linked_device_target_email_otp_activation_v1`:return{event:`wallet_device_link_target_factor_activation_v1`,activationId:e.activationId,activation:{kind:e.activation.kind,state:e.activation.state}};default:throw e.activation,Error(`Unsupported linked-device target-factor activation`)}}async function h(e){switch(e.action.kind){case`create_passkey`:if(e.active.activation.kind!==`linked_device_target_passkey_activation_v1`)throw Error(`linked-device Passkey activation is unavailable`);await e.active.activation.createPasskey();return;case`send_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.sendCode();return;case`resend_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.resendCode();return;case`submit_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.submitCode(e.action.otpCode);return;default:throw e.action,Error(`Unsupported linked-device target-factor action`)}}function g(e,t,n,r,i){e.current={activationId:r,activation:i},t.postProgress(n,m(e.current))}function _(e,t,n,r){t.postProgress(n,r);let i=o(r);(i.kind===`active`||i.kind===`failed`||i.kind===`invalid_active`||i.kind===`cancelled`)&&(e.current=null)}function v(o){let s={current:null},m=new Map;return{PM_START_DEVICE2_LINKING_FLOW:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_START_DEVICE2_LINKING_FLOW requires a payload`);let{ui:r,cameraId:i,options:a}=n,l;if(n.targetFactor.kind===`email_otp`){if(typeof n.targetEmail!=`string`)throw Error(`PM_START_DEVICE2_LINKING_FLOW requires targetEmail for Email OTP`);l={targetFactor:n.targetFactor,targetEmail:n.targetEmail}}else l={targetFactor:n.targetFactor};if(o.respondIfCancelled(e.requestId))return;let u=String(e.requestId||``).trim();if(!u)throw Error(`Device-link target-factor activation id is required`);let d=await t.devices.startLinking({...l,...r?{ui:r}:{},...i?{cameraId:i}:{},options:{...a||{},onEvent:_.bind(null,s,o,e.requestId),onTargetFactorRequired:g.bind(null,s,o,e.requestId,u)}});o.respondIfCancelled(e.requestId)||c(o,e.requestId,d)},PM_DEVICE_LINK_TARGET_FACTOR_ACTION:async e=>{let n=t(e.payload);if(!n)throw Error(`PM_DEVICE_LINK_TARGET_FACTOR_ACTION payload is invalid`);let r=s.current;if(!r||r.activationId!==n.activationId)throw Error(`linked-device target-factor activation is unavailable`);await h({active:r,action:n.action}),u(o,e.requestId)},PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION:async t=>{let n=e(t.payload);if(!n)throw Error(`Email OTP method selection payload is invalid`);p(m,n),u(o,t.requestId)},PM_CANCEL_DEVICE_LINKING:async e=>{let t=o.getWalletRuntime();if(!o.respondIfCancelled(e.requestId)){await t.devices.cancelLinking(),s.current=null;for(let e of[...m.keys()])f(m,e,Error(`Device linking was cancelled`));o.respondIfCancelled(e.requestId)||u(o,e.requestId)}},PM_SCAN_AND_LINK_DEVICE:async e=>{let t=o.getWalletRuntime(),{qrData:r,options:i}=e.payload;if(!o.respondIfCancelled(e.requestId))try{let a=await t.devices.approveLinking(n(r),{...l(o,e.requestId,i||{}),onEmailOtpBaseFactorRequired:t=>d(m,o,e.requestId,t)});if(o.respondIfCancelled(e.requestId))return;c(o,e.requestId,a)}finally{f(m,e.requestId,Error(`Device-link request ended before Email OTP method selection completed`))}},PM_HAS_PASSKEY:async e=>{let t=o.getWalletRuntime(),{walletId:n}=e.payload,r=await t.auth.hasPasskey(n);c(o,e.requestId,r)},PM_LIST_LINKED_DEVICES:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_LIST_LINKED_DEVICES requires a payload`);let r=a({kind:`linked_device_list_request_v1`,walletId:n.walletId,limit:n.limit,cursor:n.cursor}),s=await t.devices.list({walletId:String(r.walletId),limit:r.limit,cursor:r.cursor});c(o,e.requestId,i(s))},PM_REVOKE_LINKED_DEVICE:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_REVOKE_LINKED_DEVICE requires a payload`);if(o.respondIfCancelled(e.requestId))return;let i=await t.devices.remove({walletId:n.walletId,walletAuthMethodId:n.walletAuthMethodId});o.respondIfCancelled(e.requestId)||c(o,e.requestId,r(i))}}}async function y(e){await s(e,v)}export{y as handleWalletHostRuntimeRequest};
1
+ import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import{_ as e,v as t}from"./ownerNearOperation-DCxxHcwX.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{W as n,_ as r,h as i,m as a}from"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import{c as o}from"./sdkSentEvents-BFwv3mBw.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as s}from"./runtimeContext-Iy1vecX0.js";import{n as c,r as l,t as u}from"./shared-CkHhXgFB.js";function d(e,t,n,r){return n?(e.get(n)?.reject(Error(`A newer Email OTP method selection is required`)),new Promise((i,a)=>{let o=setTimeout(()=>f(e,n,Error(`Email OTP method selection timed out`)),9e5);e.set(n,{choices:r,resolve:e=>{clearTimeout(o),i(e)},reject:e=>{clearTimeout(o),a(e instanceof Error?e:Error(String(e)))}}),t.postProgress(n,{event:`wallet_device_link_email_otp_base_factor_selection_required_v1`,choices:r})})):Promise.reject(Error(`Device-link request id is required`))}function f(e,t,n){if(!t)return;let r=e.get(t);r&&(e.delete(t),r.reject(n))}function p(e,t){let n=e.get(t.scanRequestId);if(!n)throw Error(`Email OTP method selection is unavailable`);switch(t.action.kind){case`cancel`:e.delete(t.scanRequestId),n.reject(Error(`Device linking was cancelled`));return;case`select`:{let r=t.action.baseWalletAuthMethodId;if(!n.choices.some(e=>e.baseWalletAuthMethodId===r))throw Error(`The selected Email OTP method is unavailable for this linked device`);e.delete(t.scanRequestId),n.resolve(r);return}default:throw t.action,Error(`Unsupported Email OTP method selection action`)}}function m(e){switch(e.activation.kind){case`linked_device_target_passkey_activation_v1`:return{event:`wallet_device_link_target_factor_activation_v1`,activationId:e.activationId,activation:{kind:e.activation.kind}};case`linked_device_target_email_otp_activation_v1`:return{event:`wallet_device_link_target_factor_activation_v1`,activationId:e.activationId,activation:{kind:e.activation.kind,state:e.activation.state}};default:throw e.activation,Error(`Unsupported linked-device target-factor activation`)}}async function h(e){switch(e.action.kind){case`create_passkey`:if(e.active.activation.kind!==`linked_device_target_passkey_activation_v1`)throw Error(`linked-device Passkey activation is unavailable`);await e.active.activation.createPasskey();return;case`send_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.sendCode();return;case`resend_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.resendCode();return;case`submit_email_otp`:if(e.active.activation.kind!==`linked_device_target_email_otp_activation_v1`)throw Error(`linked-device Email OTP activation is unavailable`);await e.active.activation.submitCode(e.action.otpCode);return;default:throw e.action,Error(`Unsupported linked-device target-factor action`)}}function g(e,t,n,r,i){e.current={activationId:r,activation:i},t.postProgress(n,m(e.current))}function _(e,t,n,r){t.postProgress(n,r);let i=o(r);(i.kind===`active`||i.kind===`failed`||i.kind===`invalid_active`||i.kind===`cancelled`)&&(e.current=null)}function v(o){let s={current:null},m=new Map;return{PM_START_DEVICE2_LINKING_FLOW:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_START_DEVICE2_LINKING_FLOW requires a payload`);let{ui:r,cameraId:i,options:a}=n,l;if(n.targetFactor.kind===`email_otp`){if(typeof n.targetEmail!=`string`)throw Error(`PM_START_DEVICE2_LINKING_FLOW requires targetEmail for Email OTP`);l={targetFactor:n.targetFactor,targetEmail:n.targetEmail}}else l={targetFactor:n.targetFactor};if(o.respondIfCancelled(e.requestId))return;let u=String(e.requestId||``).trim();if(!u)throw Error(`Device-link target-factor activation id is required`);let d=await t.devices.startLinking({...l,...r?{ui:r}:{},...i?{cameraId:i}:{},options:{...a||{},onEvent:_.bind(null,s,o,e.requestId),onTargetFactorRequired:g.bind(null,s,o,e.requestId,u)}});o.respondIfCancelled(e.requestId)||c(o,e.requestId,d)},PM_DEVICE_LINK_TARGET_FACTOR_ACTION:async e=>{let n=t(e.payload);if(!n)throw Error(`PM_DEVICE_LINK_TARGET_FACTOR_ACTION payload is invalid`);let r=s.current;if(!r||r.activationId!==n.activationId)throw Error(`linked-device target-factor activation is unavailable`);await h({active:r,action:n.action}),u(o,e.requestId)},PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION:async t=>{let n=e(t.payload);if(!n)throw Error(`Email OTP method selection payload is invalid`);p(m,n),u(o,t.requestId)},PM_CANCEL_DEVICE_LINKING:async e=>{let t=o.getWalletRuntime();if(!o.respondIfCancelled(e.requestId)){await t.devices.cancelLinking(),s.current=null;for(let e of[...m.keys()])f(m,e,Error(`Device linking was cancelled`));o.respondIfCancelled(e.requestId)||u(o,e.requestId)}},PM_SCAN_AND_LINK_DEVICE:async e=>{let t=o.getWalletRuntime(),{qrData:r,options:i}=e.payload;if(!o.respondIfCancelled(e.requestId))try{let a=await t.devices.approveLinking(n(r),{...l(o,e.requestId,i||{}),onEmailOtpBaseFactorRequired:t=>d(m,o,e.requestId,t)});if(o.respondIfCancelled(e.requestId))return;c(o,e.requestId,a)}finally{f(m,e.requestId,Error(`Device-link request ended before Email OTP method selection completed`))}},PM_HAS_PASSKEY:async e=>{let t=o.getWalletRuntime(),{walletId:n}=e.payload,r=await t.auth.hasPasskey(n);c(o,e.requestId,r)},PM_LIST_LINKED_DEVICES:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_LIST_LINKED_DEVICES requires a payload`);let r=a({kind:`linked_device_list_request_v1`,walletId:n.walletId,limit:n.limit,cursor:n.cursor}),s=await t.devices.list({walletId:String(r.walletId),limit:r.limit,cursor:r.cursor});c(o,e.requestId,i(s))},PM_REVOKE_LINKED_DEVICE:async e=>{let t=o.getWalletRuntime(),n=e.payload;if(!n)throw Error(`PM_REVOKE_LINKED_DEVICE requires a payload`);if(o.respondIfCancelled(e.requestId))return;let i=await t.devices.remove({walletId:n.walletId,walletAuthMethodId:n.walletAuthMethodId});o.respondIfCancelled(e.requestId)||c(o,e.requestId,r(i))}}}async function y(e){await s(e,v)}export{y as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as e,t}from"./runtimeContext-ChuvOC0h.js";import{n,t as r}from"./shared-CkHhXgFB.js";function i(e){return{PM_SIGN_TEMPO:async r=>{let i=e.getWalletRuntime(),{walletSession:a,request:o,chainTarget:s,options:c}=r.payload;if(e.respondIfCancelled(r.requestId))return;let l={confirmationConfig:c?.confirmationConfig,shouldAbort:()=>e.isCancelled(r.requestId),onEvent:t=>{e.postProgress(r.requestId,t)}},u;switch(r.payload.operationKind){case`tempo_transaction`:if(o.chain!==`tempo`)throw Error(`[wallet-iframe] Tempo operation requires a Tempo request`);if(s.kind!==`tempo`)throw Error(`[wallet-iframe] Tempo request requires a Tempo target`);u=await i.tempo.signTransaction({walletSession:a,request:o,chainTarget:s,options:l});break;case`evm_transaction`:if(o.chain!==`evm`)throw Error(`[wallet-iframe] EVM operation requires an EVM request`);if(s.kind!==`evm`)throw Error(`[wallet-iframe] EVM request requires an EVM target`);u=await i.evm.signTransaction({walletSession:a,request:o,chainTarget:s,options:l});break;case`tempo_fee_token_preference`:{if(o.chain!==`evm`||s.kind!==`tempo`)throw Error(`[wallet-iframe] Tempo fee-token operation requires an EVM request and Tempo target`);let e=t({request:o,chainTarget:s});u=await i.signTempoFeeTokenPreferenceInternal({walletSession:a,request:e,chainTarget:s,confirmationConfigOverride:l.confirmationConfig,shouldAbort:l.shouldAbort,onEvent:l.onEvent});break}default:throw Error(`[wallet-iframe] unsupported EVM-family signing operation`)}e.respondIfCancelled(r.requestId)||n(e,r.requestId,u)},PM_REPORT_TEMPO_BROADCAST_ACCEPTED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,txHash:o}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportBroadcastAccepted({walletSession:i,signedResult:a,txHash:o,options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_BROADCAST_REJECTED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,error:o}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportBroadcastRejected({walletSession:i,signedResult:a,...o?{error:o}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_FINALIZED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,txHash:o,receiptStatus:s}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportFinalized({walletSession:i,signedResult:a,...o?{txHash:o}:{},...s?{receiptStatus:s}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_DROPPED_OR_REPLACED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,reason:o,txHash:s}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportDroppedOrReplaced({walletSession:i,signedResult:a,reason:o,...s?{txHash:s}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_RECONCILE_TEMPO_NONCE_LANE:async t=>{let r=e.getWalletRuntime(),{walletSession:i,signedResult:a}=t.payload;if(e.respondIfCancelled(t.requestId))return;let o=await r.tempo.advanced.reconcileNonceLane({walletSession:i,signedResult:a,options:{onEvent:n=>e.postProgress(t.requestId,n)}});e.respondIfCancelled(t.requestId)||n(e,t.requestId,o)}}}async function a(t){await e(t,i)}export{a as handleWalletHostRuntimeRequest};
1
+ import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as e,t}from"./runtimeContext-Iy1vecX0.js";import{n,t as r}from"./shared-CkHhXgFB.js";function i(e){return{PM_SIGN_TEMPO:async r=>{let i=e.getWalletRuntime(),{walletSession:a,request:o,chainTarget:s,options:c}=r.payload;if(e.respondIfCancelled(r.requestId))return;let l={confirmationConfig:c?.confirmationConfig,shouldAbort:()=>e.isCancelled(r.requestId),onEvent:t=>{e.postProgress(r.requestId,t)}},u;switch(r.payload.operationKind){case`tempo_transaction`:if(o.chain!==`tempo`)throw Error(`[wallet-iframe] Tempo operation requires a Tempo request`);if(s.kind!==`tempo`)throw Error(`[wallet-iframe] Tempo request requires a Tempo target`);u=await i.tempo.signTransaction({walletSession:a,request:o,chainTarget:s,options:l});break;case`evm_transaction`:if(o.chain!==`evm`)throw Error(`[wallet-iframe] EVM operation requires an EVM request`);if(s.kind!==`evm`)throw Error(`[wallet-iframe] EVM request requires an EVM target`);u=await i.evm.signTransaction({walletSession:a,request:o,chainTarget:s,options:l});break;case`tempo_fee_token_preference`:{if(o.chain!==`evm`||s.kind!==`tempo`)throw Error(`[wallet-iframe] Tempo fee-token operation requires an EVM request and Tempo target`);let e=t({request:o,chainTarget:s});u=await i.signTempoFeeTokenPreferenceInternal({walletSession:a,request:e,chainTarget:s,confirmationConfigOverride:l.confirmationConfig,shouldAbort:l.shouldAbort,onEvent:l.onEvent});break}default:throw Error(`[wallet-iframe] unsupported EVM-family signing operation`)}e.respondIfCancelled(r.requestId)||n(e,r.requestId,u)},PM_REPORT_TEMPO_BROADCAST_ACCEPTED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,txHash:o}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportBroadcastAccepted({walletSession:i,signedResult:a,txHash:o,options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_BROADCAST_REJECTED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,error:o}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportBroadcastRejected({walletSession:i,signedResult:a,...o?{error:o}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_FINALIZED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,txHash:o,receiptStatus:s}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportFinalized({walletSession:i,signedResult:a,...o?{txHash:o}:{},...s?{receiptStatus:s}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_REPORT_TEMPO_DROPPED_OR_REPLACED:async t=>{let n=e.getWalletRuntime(),{walletSession:i,signedResult:a,reason:o,txHash:s}=t.payload;e.respondIfCancelled(t.requestId)||(await n.tempo.advanced.reportDroppedOrReplaced({walletSession:i,signedResult:a,reason:o,...s?{txHash:s}:{},options:{onEvent:n=>e.postProgress(t.requestId,n)}}),!e.respondIfCancelled(t.requestId)&&r(e,t.requestId))},PM_RECONCILE_TEMPO_NONCE_LANE:async t=>{let r=e.getWalletRuntime(),{walletSession:i,signedResult:a}=t.payload;if(e.respondIfCancelled(t.requestId))return;let o=await r.tempo.advanced.reconcileNonceLane({walletSession:i,signedResult:a,options:{onEvent:n=>e.postProgress(t.requestId,n)}});e.respondIfCancelled(t.requestId)||n(e,t.requestId,o)}}}async function a(t){await e(t,i)}export{a as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import{r as e}from"./secureRandomId-8LSc91aN.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{c as t,handleWalletHostRuntimeRequestWithHandlers as n}from"./runtimeContext-ChuvOC0h.js";import{n as r,r as i}from"./shared-CkHhXgFB.js";import{t as a}from"./recoveryAuthorization-CQsjb8Tm.js";function o(e){let t=s(e);if(t.method===`email`)return{method:`email`,walletId:c(t,`walletId`),email:c(t,`email`)};if(t.method!==`google`)throw Error(`Email code method is invalid`);let n=s(t.target);if(n.kind!==`wallet`&&n.kind!==`discoverable`)throw Error(`Email code wallet target is invalid`);return{method:`google`,idToken:c(t,`idToken`),target:n.kind===`wallet`?{kind:`wallet`,walletId:c(n,`walletId`)}:{kind:`discoverable`}}}function s(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function c(e,t){let n=typeof e[t]==`string`?e[t].trim():``;if(!n)throw Error(`Missing ${t}`);return n}function l(e,t){return(typeof e[t]==`string`?e[t].trim():``)||void 0}function u(e){let t=s(e);if(Object.prototype.hasOwnProperty.call(t,`walletSessionToken`))throw Error(`wallet iframe requests must not carry walletSessionToken`)}function d(e){let t=s(e),n=[`challengeId`,`challenge_id`,`otpCode`,`otp_code`,`otpDelivery`,`otp_delivery`,`delivery`,`resend`].find(e=>Object.prototype.hasOwnProperty.call(t,e));if(n)throw Error(`Google Email OTP registration message must not include ${n}`)}const f=new Map;function p(){return e(`google-email-otp`,16,`Google Email OTP wallet auth flow handles`)}function m(e){let t=p();return f.set(t,{flow:e,expiresAtMs:e.expiresAtMs}),e.mode===`register`?{kind:e.kind,state:`registration_ready`,flowHandleId:t,flowId:e.flowId,requestedMode:e.requestedMode,mode:`register`,walletId:e.walletId,emailHint:e.emailHint,prompt:e.prompt,expiresAtMs:e.expiresAtMs}:{kind:e.kind,state:`challenge_sent`,flowHandleId:t,flowId:e.flowId,requestedMode:e.requestedMode,mode:`login`,walletId:e.walletId,emailHint:e.emailHint,prompt:e.prompt,delivery:e.delivery,expiresAtMs:e.expiresAtMs}}function h(e){return e.ok?{ok:!0,value:m(e.value)}:e}function g(e){return e.ok?{ok:!0,value:m(e.value)}:e}function _(e){return e.ok?{ok:!0,value:{walletId:e.value.walletId,mode:`register`,session:e.value.session,registration:e.value.registration}}:e}function v(e){return c(s(e),`flowHandleId`)}function y(e,t){let n=c(t,`flowId`),r=c(t,`walletId`),i=c(t,`mode`);if(e.flowId!==n)throw Error(`Google Email OTP wallet auth flow handle does not match flow id`);if(String(e.walletId)!==r)throw Error(`Google Email OTP wallet auth flow handle does not match wallet`);if(e.mode!==i)throw Error(`Google Email OTP wallet auth flow handle does not match mode`)}function b(e){let t=s(e),n=v(t),r=f.get(n);if(!r)throw Error(`Google Email OTP wallet auth flow handle is not active`);if(Date.now()>r.expiresAtMs)throw f.delete(n),r.flow.cancel().catch(()=>void 0),Error(`Google Email OTP wallet auth flow handle expired`);return y(r.flow,t),r.flow}function x(e){let t=v(s(e)),n=b(e);return f.delete(t),n}function S(e){let t=s(e),n=c(t,`operation`);if(n!==`credentials_list`&&n!==`credential_label`&&n!==`recovery_rotate`&&n!==`recovery_read`&&n!==`recovery_status`&&n!==`recovery_backup_acknowledge`)throw Error(`Wallet custody Email OTP challenge operation is invalid`);let r=s(t.payload);if(Object.keys(r).length===0&&t.payload===void 0)throw Error(`Wallet custody Email OTP challenge payload is required`);return{walletId:c(t,`walletId`),providerSubjectId:c(t,`providerSubjectId`),operation:n,payload:r,...l(t,`requestOrigin`)?{requestOrigin:l(t,`requestOrigin`)}:{}}}function C(e){let t=s(e);if(Object.keys(t).sort().join(`,`)!==`authorization,walletId`)throw Error(`Wallet recovery rotation request has unexpected fields`);let n=s(t.authorization);if(Object.keys(n).length!==1)throw Error(`Wallet recovery rotation authorization has unexpected fields`);if(n.kind===`existing_passkey`)return{walletId:c(t,`walletId`),authorization:{kind:`existing_passkey`}};if(n.kind===`email_otp`)return{walletId:c(t,`walletId`),authorization:{kind:`email_otp`}};throw Error(`Wallet recovery rotation authorization is invalid`)}function w(e){let t=s(e.diagnostics);Reflect.set(globalThis,`__SEAMS_EMAIL_OTP_UNLOCK_DIAGNOSTICS`,t.emailOtpUnlockTimings===!0),Reflect.set(globalThis,`__SEAMS_REGISTRATION_BENCHMARK_DIAGNOSTICS`,t.registrationBenchmarkTimings===!0),delete e.diagnostics}function T(e){return{PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION:async n=>{let i=await t(n.payload,n.payload.relayUrl);r(e,n.requestId,{kind:`redeemed_hosted_wallet_seams_session`,expiresAtMs:i.expiresAtMs})},PM_REQUEST_EMAIL_OTP_CHALLENGE:async t=>{let n=e.getWalletRuntime();u(t.payload);let a=o(t.payload),s=await n.auth.requestEmailCode(i(e,t.requestId,a));r(e,t.requestId,h(s))},PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH:async t=>{let n=e.getWalletRuntime(),a=s(t.payload);w(a),a.mode===`register`&&d(a);let o=i(e,t.requestId,a),c=await n.auth.startGoogleSignIn(o);r(e,t.requestId,h(c))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND:async t=>{let n=b(t.payload);if(n.mode!==`login`)throw Error(`Google Email OTP wallet auth resend requires a login flow`);let i=await n.resend();i.ok&&x(t.payload),r(e,t.requestId,h(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID:async t=>{let n=b(t.payload);if(n.mode!==`register`)throw Error(`Google Email OTP wallet auth reroll requires a registration flow`);d(t.payload);let i=await n.rerollWalletId();i.ok&&x(t.payload),r(e,t.requestId,g(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT:async t=>{let n=b(t.payload);if(n.mode!==`login`)throw Error(`Google Email OTP wallet auth submit requires a login flow`);let i=s(t.payload),a=await n.submit({otpCode:c(i,`otpCode`)});a.ok&&x(t.payload),r(e,t.requestId,a)},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION:async t=>{let n=b(t.payload);if(n.mode!==`register`)throw Error(`Google Email OTP wallet auth completion requires a registration flow`);d(t.payload);let i=await n.completeRegistration();i.ok&&x(t.payload),r(e,t.requestId,_(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL:async t=>{await b(t.payload).cancel(),x(t.payload),r(e,t.requestId,void 0)},PM_GET_WALLET_RECOVERY_CODE_STATUS:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.getCodeStatus(a(t.payload));r(e,t.requestId,n)},PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.requestWalletCustodyEmailOtpChallenge(S(t.payload));r(e,t.requestId,n)},PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.confirmBackup(a(t.payload));r(e,t.requestId,n)},PM_ROTATE_WALLET_RECOVERY_CODES:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.rotateCodes(C(t.payload));r(e,t.requestId,n)}}}async function E(e){await n(e,T)}export{E as handleWalletHostRuntimeRequest};
1
+ import{r as e}from"./secureRandomId-8LSc91aN.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{c as t,handleWalletHostRuntimeRequestWithHandlers as n}from"./runtimeContext-Iy1vecX0.js";import{n as r,r as i}from"./shared-CkHhXgFB.js";import{t as a}from"./recoveryAuthorization-CQsjb8Tm.js";function o(e){let t=s(e);if(t.method===`email`)return{method:`email`,walletId:c(t,`walletId`),email:c(t,`email`)};if(t.method!==`google`)throw Error(`Email code method is invalid`);let n=s(t.target);if(n.kind!==`wallet`&&n.kind!==`discoverable`)throw Error(`Email code wallet target is invalid`);return{method:`google`,idToken:c(t,`idToken`),target:n.kind===`wallet`?{kind:`wallet`,walletId:c(n,`walletId`)}:{kind:`discoverable`}}}function s(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function c(e,t){let n=typeof e[t]==`string`?e[t].trim():``;if(!n)throw Error(`Missing ${t}`);return n}function l(e,t){return(typeof e[t]==`string`?e[t].trim():``)||void 0}function u(e){let t=s(e);if(Object.prototype.hasOwnProperty.call(t,`walletSessionToken`))throw Error(`wallet iframe requests must not carry walletSessionToken`)}function d(e){let t=s(e),n=[`challengeId`,`challenge_id`,`otpCode`,`otp_code`,`otpDelivery`,`otp_delivery`,`delivery`,`resend`].find(e=>Object.prototype.hasOwnProperty.call(t,e));if(n)throw Error(`Google Email OTP registration message must not include ${n}`)}const f=new Map;function p(){return e(`google-email-otp`,16,`Google Email OTP wallet auth flow handles`)}function m(e){let t=p();return f.set(t,{flow:e,expiresAtMs:e.expiresAtMs}),e.mode===`register`?{kind:e.kind,state:`registration_ready`,flowHandleId:t,flowId:e.flowId,requestedMode:e.requestedMode,mode:`register`,walletId:e.walletId,emailHint:e.emailHint,prompt:e.prompt,expiresAtMs:e.expiresAtMs}:{kind:e.kind,state:`challenge_sent`,flowHandleId:t,flowId:e.flowId,requestedMode:e.requestedMode,mode:`login`,walletId:e.walletId,emailHint:e.emailHint,prompt:e.prompt,delivery:e.delivery,expiresAtMs:e.expiresAtMs}}function h(e){return e.ok?{ok:!0,value:m(e.value)}:e}function g(e){return e.ok?{ok:!0,value:m(e.value)}:e}function _(e){return e.ok?{ok:!0,value:{walletId:e.value.walletId,mode:`register`,session:e.value.session,registration:e.value.registration}}:e}function v(e){return c(s(e),`flowHandleId`)}function y(e,t){let n=c(t,`flowId`),r=c(t,`walletId`),i=c(t,`mode`);if(e.flowId!==n)throw Error(`Google Email OTP wallet auth flow handle does not match flow id`);if(String(e.walletId)!==r)throw Error(`Google Email OTP wallet auth flow handle does not match wallet`);if(e.mode!==i)throw Error(`Google Email OTP wallet auth flow handle does not match mode`)}function b(e){let t=s(e),n=v(t),r=f.get(n);if(!r)throw Error(`Google Email OTP wallet auth flow handle is not active`);if(Date.now()>r.expiresAtMs)throw f.delete(n),r.flow.cancel().catch(()=>void 0),Error(`Google Email OTP wallet auth flow handle expired`);return y(r.flow,t),r.flow}function x(e){let t=v(s(e)),n=b(e);return f.delete(t),n}function S(e){let t=s(e),n=c(t,`operation`);if(n!==`credentials_list`&&n!==`credential_label`&&n!==`recovery_rotate`&&n!==`recovery_read`&&n!==`recovery_status`&&n!==`recovery_backup_acknowledge`)throw Error(`Wallet custody Email OTP challenge operation is invalid`);let r=s(t.payload);if(Object.keys(r).length===0&&t.payload===void 0)throw Error(`Wallet custody Email OTP challenge payload is required`);return{walletId:c(t,`walletId`),providerSubjectId:c(t,`providerSubjectId`),operation:n,payload:r,...l(t,`requestOrigin`)?{requestOrigin:l(t,`requestOrigin`)}:{}}}function C(e){let t=s(e);if(Object.keys(t).sort().join(`,`)!==`authorization,walletId`)throw Error(`Wallet recovery rotation request has unexpected fields`);let n=s(t.authorization);if(Object.keys(n).length!==1)throw Error(`Wallet recovery rotation authorization has unexpected fields`);if(n.kind===`existing_passkey`)return{walletId:c(t,`walletId`),authorization:{kind:`existing_passkey`}};if(n.kind===`email_otp`)return{walletId:c(t,`walletId`),authorization:{kind:`email_otp`}};throw Error(`Wallet recovery rotation authorization is invalid`)}function w(e){let t=s(e.diagnostics);Reflect.set(globalThis,`__SEAMS_EMAIL_OTP_UNLOCK_DIAGNOSTICS`,t.emailOtpUnlockTimings===!0),Reflect.set(globalThis,`__SEAMS_REGISTRATION_BENCHMARK_DIAGNOSTICS`,t.registrationBenchmarkTimings===!0),delete e.diagnostics}function T(e){return{PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION:async n=>{let i=await t(n.payload,n.payload.relayUrl);r(e,n.requestId,{kind:`redeemed_hosted_wallet_seams_session`,expiresAtMs:i.expiresAtMs})},PM_REQUEST_EMAIL_OTP_CHALLENGE:async t=>{let n=e.getWalletRuntime();u(t.payload);let a=o(t.payload),s=await n.auth.requestEmailCode(i(e,t.requestId,a));r(e,t.requestId,h(s))},PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH:async t=>{let n=e.getWalletRuntime(),a=s(t.payload);w(a),a.mode===`register`&&d(a);let o=i(e,t.requestId,a),c=await n.auth.startGoogleSignIn(o);r(e,t.requestId,h(c))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND:async t=>{let n=b(t.payload);if(n.mode!==`login`)throw Error(`Google Email OTP wallet auth resend requires a login flow`);let i=await n.resend();i.ok&&x(t.payload),r(e,t.requestId,h(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID:async t=>{let n=b(t.payload);if(n.mode!==`register`)throw Error(`Google Email OTP wallet auth reroll requires a registration flow`);d(t.payload);let i=await n.rerollWalletId();i.ok&&x(t.payload),r(e,t.requestId,g(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT:async t=>{let n=b(t.payload);if(n.mode!==`login`)throw Error(`Google Email OTP wallet auth submit requires a login flow`);let i=s(t.payload),a=await n.submit({otpCode:c(i,`otpCode`)});a.ok&&x(t.payload),r(e,t.requestId,a)},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION:async t=>{let n=b(t.payload);if(n.mode!==`register`)throw Error(`Google Email OTP wallet auth completion requires a registration flow`);d(t.payload);let i=await n.completeRegistration();i.ok&&x(t.payload),r(e,t.requestId,_(i))},PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL:async t=>{await b(t.payload).cancel(),x(t.payload),r(e,t.requestId,void 0)},PM_GET_WALLET_RECOVERY_CODE_STATUS:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.getCodeStatus(a(t.payload));r(e,t.requestId,n)},PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.requestWalletCustodyEmailOtpChallenge(S(t.payload));r(e,t.requestId,n)},PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.confirmBackup(a(t.payload));r(e,t.requestId,n)},PM_ROTATE_WALLET_RECOVERY_CODES:async t=>{u(t.payload);let n=await e.getWalletRuntime().recovery.rotateCodes(C(t.payload));r(e,t.requestId,n)}}}async function E(e){await n(e,T)}export{E as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import{g as e}from"./domainIds-t1lp25yU.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import{r as t}from"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{s as n}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import{N as r,P as i}from"./nearEd25519YaoSigningPreparation-Cz2Gb95g.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as a}from"./runtimeContext-ChuvOC0h.js";import{n as o,t as s}from"./shared-CkHhXgFB.js";function c(t){switch(t.kind){case`ecdsa`:{let e=r(t.laneIdentity);if(String(e.signer.walletId)!==String(t.walletSession.walletId))throw Error(`[WalletIframe] key export lane wallet does not match wallet session`);if(!n(e.signer.chainTarget,t.chainTarget))throw Error(`[WalletIframe] key export lane chain target does not match request target`);return{kind:`ecdsa`,chainTarget:t.chainTarget,walletSession:t.walletSession,laneIdentity:e,options:t.options}}case`ed25519`:{let n=i(t.laneIdentity),r=e(t.materialActivation);if(!r.ok)throw Error(r.error.message);let a=n.signer;if(String(a.account.wallet.walletId)!==String(t.walletSession.walletId))throw Error(`[WalletIframe] Ed25519 export lane wallet does not match wallet session`);if(String(a.account.nearAccountId)!==String(t.nearAccount.accountId))throw Error(`[WalletIframe] Ed25519 export lane does not match the NEAR account`);return{kind:`ed25519`,nearAccount:t.nearAccount,walletSession:t.walletSession,laneIdentity:n,materialActivation:r.value,options:t.options}}}}function l(e){return{PM_RESOLVE_EXACT_KEY_EXPORT_LANE:async t=>{let n=await e.getWalletRuntime().keys.resolveExactKeyExportLane(t.payload);o(e,t.requestId,n)},PM_EXPORT_KEYPAIR_UI:async n=>{let r=e.getWalletRuntime(),i=n.payload;if(!e.respondIfCancelled(n.requestId)){try{let t=c(i);await r.keys.exportKeypairWithUI(t.kind===`ecdsa`?{kind:`ecdsa`,chainTarget:t.chainTarget,walletSession:t.walletSession,laneIdentity:t.laneIdentity,options:{...t.options,onEvent:t=>e.postProgress(n.requestId,t)}}:{kind:`ed25519`,nearAccount:t.nearAccount,walletSession:t.walletSession,laneIdentity:t.laneIdentity,materialActivation:t.materialActivation,options:{...t.options,onEvent:t=>e.postProgress(n.requestId,t)}})}catch(r){if(t(r)){if(e.respondIfCancelled(n.requestId))return;s(e,n.requestId);return}throw r}e.respondIfCancelled(n.requestId)||s(e,n.requestId)}}}}async function u(e){await a(e,l)}export{u as handleWalletHostRuntimeRequest};
1
+ import{g as e}from"./domainIds-t1lp25yU.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import{r as t}from"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{s as n}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import{N as r,P as i}from"./nearEd25519YaoSigningPreparation-Cz2Gb95g.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as a}from"./runtimeContext-Iy1vecX0.js";import{n as o,t as s}from"./shared-CkHhXgFB.js";function c(t){switch(t.kind){case`ecdsa`:{let e=r(t.laneIdentity);if(String(e.signer.walletId)!==String(t.walletSession.walletId))throw Error(`[WalletIframe] key export lane wallet does not match wallet session`);if(!n(e.signer.chainTarget,t.chainTarget))throw Error(`[WalletIframe] key export lane chain target does not match request target`);return{kind:`ecdsa`,chainTarget:t.chainTarget,walletSession:t.walletSession,laneIdentity:e,options:t.options}}case`ed25519`:{let n=i(t.laneIdentity),r=e(t.materialActivation);if(!r.ok)throw Error(r.error.message);let a=n.signer;if(String(a.account.wallet.walletId)!==String(t.walletSession.walletId))throw Error(`[WalletIframe] Ed25519 export lane wallet does not match wallet session`);if(String(a.account.nearAccountId)!==String(t.nearAccount.accountId))throw Error(`[WalletIframe] Ed25519 export lane does not match the NEAR account`);return{kind:`ed25519`,nearAccount:t.nearAccount,walletSession:t.walletSession,laneIdentity:n,materialActivation:r.value,options:t.options}}}}function l(e){return{PM_RESOLVE_EXACT_KEY_EXPORT_LANE:async t=>{let n=await e.getWalletRuntime().keys.resolveExactKeyExportLane(t.payload);o(e,t.requestId,n)},PM_EXPORT_KEYPAIR_UI:async n=>{let r=e.getWalletRuntime(),i=n.payload;if(!e.respondIfCancelled(n.requestId)){try{let t=c(i);await r.keys.exportKeypairWithUI(t.kind===`ecdsa`?{kind:`ecdsa`,chainTarget:t.chainTarget,walletSession:t.walletSession,laneIdentity:t.laneIdentity,options:{...t.options,onEvent:t=>e.postProgress(n.requestId,t)}}:{kind:`ed25519`,nearAccount:t.nearAccount,walletSession:t.walletSession,laneIdentity:t.laneIdentity,materialActivation:t.materialActivation,options:{...t.options,onEvent:t=>e.postProgress(n.requestId,t)}})}catch(r){if(t(r)){if(e.respondIfCancelled(n.requestId))return;s(e,n.requestId);return}throw r}e.respondIfCancelled(n.requestId)||s(e,n.requestId)}}}}async function u(e){await a(e,l)}export{u as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import{_ as e,b as t,u as n}from"./digests-BIaE0DMd.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{c as r,n as i}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import{u as a}from"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as o}from"./runtimeContext-ChuvOC0h.js";import{i as s,n as c,r as l}from"./shared-CkHhXgFB.js";function u(e){let t=r(e);return{walletId:t,walletSessionUserId:String(t)}}function d(r){if(r&&e(r))try{let e=n(r),i=r.nonceLease,o=r.serverDispatch;return a.fromPlain({transaction:r.transaction,signature:r.signature,borsh_bytes:e,transactionHash:t(Reflect.get(r,`transactionHash`),`transactionHash`),...i?{nonceLease:i}:{},...o?{serverDispatch:o}:{}})}catch{return r}return r}function f(e){throw Error(`Unsupported registration auth method: ${String(e)}`)}function p(e){switch(e.kind){case`passkey`:return{kind:`passkey`,rpId:e.rpId,...e.authenticatorOptions===void 0?{}:{authenticatorOptions:e.authenticatorOptions}};case`email_otp`:switch(e.proofKind){case`otp_challenge`:return{kind:`email_otp`,proofKind:`otp_challenge`,email:e.email,providerSubject:e.providerSubject,otpCode:e.otpCode,...e.challengeId===void 0?{}:{challengeId:e.challengeId}};case`google_sso_registration`:return{kind:`email_otp`,proofKind:`google_sso_registration`,email:e.email,providerSubject:e.providerSubject,googleEmailOtpRegistrationAttemptId:e.googleEmailOtpRegistrationAttemptId,googleEmailOtpRegistrationOfferId:e.googleEmailOtpRegistrationOfferId,googleEmailOtpRegistrationCandidateId:e.googleEmailOtpRegistrationCandidateId};default:return f(e)}default:return f(e)}}function m(e){return{PM_OWNER_NEAR_TRANSACTION:h.bind(null,e),PM_REGISTER_WALLET:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=s(e,t.requestId,r.options||{}),a=await n.registerWalletCommand({completion:r.completion,authMethod:p(r.authMethod),wallet:r.wallet,signerSelection:r.signerSelection,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||(a.success&&a.kind!==`wallet_owner_registered`&&await e.publishCurrentSession(),!e.respondIfCancelled(t.requestId)&&c(e,t.requestId,a))},PM_ADD_WALLET_SIGNER:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addSigner({walletId:r.walletId,rpId:r.rpId,signerSelection:r.signerSelection,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_ADD_PASSKEY:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addPasskey({walletId:r.walletId,rpId:r.rpId,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_GET_AUTH_METHOD_AVAILABILITY:async t=>{if(!t.payload)throw Error(`Authentication method request is missing.`);let n=await e.getWalletRuntime().registration.getAuthMethodAvailability(t.payload);e.respondIfCancelled(t.requestId)||c(e,t.requestId,n)},PM_SET_AUTH_METHOD_ENABLED:async t=>{if(!t.payload)throw Error(`Authentication method request is missing.`);let n=await e.getWalletRuntime().registration.setAuthMethodEnabled(t.payload);await e.publishCurrentSession(),e.respondIfCancelled(t.requestId)||c(e,t.requestId,n)},PM_ACTIVATE_AUTH_METHOD:async t=>{let n=e.getWalletRuntime();if(e.respondIfCancelled(t.requestId))return;let r=t.payload;if(!r)throw Error(`Authentication method activation requires a wallet ID.`);let i=await n.registration.activateAuthMethod({walletId:r.walletId,method:r.method});e.respondIfCancelled(t.requestId)||c(e,t.requestId,i)},PM_ADD_EMAIL_OTP:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addEmail({walletId:r.walletId,emailAddress:r.emailAddress,options:i});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_REVOKE_AUTH_METHOD:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=await n.registration.removeAuthMethod({walletId:r.walletId,walletAuthMethodId:r.walletAuthMethodId});e.respondIfCancelled(t.requestId)||c(e,t.requestId,i)},PM_GET_NEAR_PROVISIONING_STATE:async t=>{let n=e.getWalletRuntime(),i=r(t.payload?.walletId),a=await n.registration.getNearAccountState({walletId:i});c(e,t.requestId,a)},PM_SIGN_TX_WITH_ACTIONS:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,transaction:o,options:s}=t.payload,d=await n.near.signTransaction({walletSession:u(r),nearAccount:i(a),transaction:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)},PM_SIGN_AND_SEND_TX:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,transaction:o,options:s}=t.payload,d=await n.near.signAndSendTransaction({walletSession:u(r),nearAccount:i(a),receiverId:o.receiverId,actions:o.actions,options:{...l(e,t.requestId,s||{})}});c(e,t.requestId,d)},PM_SEND_TRANSACTION:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,signedTransaction:o,options:s}=t.payload||{},f=await n.near.sendTransaction({walletSession:u(r),nearAccount:i(a),signedTransaction:d(o),options:{...l(e,t.requestId,s||{})}});c(e,t.requestId,f)},PM_SIGN_DELEGATE_ACTION:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,delegate:o,options:s}=t.payload,d=await n.near.signDelegateAction({walletSession:u(r),nearAccount:i(a),delegate:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)},PM_SIGN_NEP413:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,params:o,options:s}=t.payload,d=await n.near.signMessage({walletSession:u(r),nearAccount:i(a),params:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)}}}async function h(e,t){let n=await e.getWalletRuntime().runOwnerNearOperation(t.payload,g.bind(null,e,t.requestId),e.postProgress.bind(e,t.requestId),_.bind(null,e,t));c(e,t.requestId,n)}function g(e,t){if(e.isCancelled(t))throw new DOMException(`The owner operation was cancelled.`,`AbortError`)}function _(e,t){e.postProgress(t.requestId,{event:`owner_near_submitting`,operationId:t.payload.recovery.operationId})}async function v(e){await o(e,m)}export{v as handleWalletHostRuntimeRequest};
1
+ import{_ as e,b as t,u as n}from"./digests-BIaE0DMd.js";import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{c as r,n as i}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import{u as a}from"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as o}from"./runtimeContext-Iy1vecX0.js";import{i as s,n as c,r as l}from"./shared-CkHhXgFB.js";function u(e){let t=r(e);return{walletId:t,walletSessionUserId:String(t)}}function d(r){if(r&&e(r))try{let e=n(r),i=r.nonceLease,o=r.serverDispatch;return a.fromPlain({transaction:r.transaction,signature:r.signature,borsh_bytes:e,transactionHash:t(Reflect.get(r,`transactionHash`),`transactionHash`),...i?{nonceLease:i}:{},...o?{serverDispatch:o}:{}})}catch{return r}return r}function f(e){throw Error(`Unsupported registration auth method: ${String(e)}`)}function p(e){switch(e.kind){case`passkey`:return{kind:`passkey`,rpId:e.rpId,...e.authenticatorOptions===void 0?{}:{authenticatorOptions:e.authenticatorOptions}};case`email_otp`:switch(e.proofKind){case`otp_challenge`:return{kind:`email_otp`,proofKind:`otp_challenge`,email:e.email,providerSubject:e.providerSubject,otpCode:e.otpCode,...e.challengeId===void 0?{}:{challengeId:e.challengeId}};case`google_sso_registration`:return{kind:`email_otp`,proofKind:`google_sso_registration`,email:e.email,providerSubject:e.providerSubject,googleEmailOtpRegistrationAttemptId:e.googleEmailOtpRegistrationAttemptId,googleEmailOtpRegistrationOfferId:e.googleEmailOtpRegistrationOfferId,googleEmailOtpRegistrationCandidateId:e.googleEmailOtpRegistrationCandidateId};default:return f(e)}default:return f(e)}}function m(e){return{PM_OWNER_NEAR_TRANSACTION:h.bind(null,e),PM_REGISTER_WALLET:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=s(e,t.requestId,r.options||{}),a=await n.registerWalletCommand({completion:r.completion,authMethod:p(r.authMethod),wallet:r.wallet,signerSelection:r.signerSelection,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||(a.success&&a.kind!==`wallet_owner_registered`&&await e.publishCurrentSession(),!e.respondIfCancelled(t.requestId)&&c(e,t.requestId,a))},PM_ADD_WALLET_SIGNER:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addSigner({walletId:r.walletId,rpId:r.rpId,signerSelection:r.signerSelection,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_ADD_PASSKEY:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addPasskey({walletId:r.walletId,rpId:r.rpId,options:{...i,...r.confirmationConfig?{confirmationConfig:r.confirmationConfig}:{}}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_GET_AUTH_METHOD_AVAILABILITY:async t=>{if(!t.payload)throw Error(`Authentication method request is missing.`);let n=await e.getWalletRuntime().registration.getAuthMethodAvailability(t.payload);e.respondIfCancelled(t.requestId)||c(e,t.requestId,n)},PM_SET_AUTH_METHOD_ENABLED:async t=>{if(!t.payload)throw Error(`Authentication method request is missing.`);let n=await e.getWalletRuntime().registration.setAuthMethodEnabled(t.payload);await e.publishCurrentSession(),e.respondIfCancelled(t.requestId)||c(e,t.requestId,n)},PM_ACTIVATE_AUTH_METHOD:async t=>{let n=e.getWalletRuntime();if(e.respondIfCancelled(t.requestId))return;let r=t.payload;if(!r)throw Error(`Authentication method activation requires a wallet ID.`);let i=await n.registration.activateAuthMethod({walletId:r.walletId,method:r.method});e.respondIfCancelled(t.requestId)||c(e,t.requestId,i)},PM_ADD_EMAIL_OTP:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=l(e,t.requestId,r.options||{}),a=await n.registration.addEmail({walletId:r.walletId,emailAddress:r.emailAddress,options:i});e.respondIfCancelled(t.requestId)||c(e,t.requestId,a)},PM_REVOKE_AUTH_METHOD:async t=>{let n=e.getWalletRuntime(),r=t.payload;if(e.respondIfCancelled(t.requestId))return;let i=await n.registration.removeAuthMethod({walletId:r.walletId,walletAuthMethodId:r.walletAuthMethodId});e.respondIfCancelled(t.requestId)||c(e,t.requestId,i)},PM_GET_NEAR_PROVISIONING_STATE:async t=>{let n=e.getWalletRuntime(),i=r(t.payload?.walletId),a=await n.registration.getNearAccountState({walletId:i});c(e,t.requestId,a)},PM_SIGN_TX_WITH_ACTIONS:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,transaction:o,options:s}=t.payload,d=await n.near.signTransaction({walletSession:u(r),nearAccount:i(a),transaction:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)},PM_SIGN_AND_SEND_TX:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,transaction:o,options:s}=t.payload,d=await n.near.signAndSendTransaction({walletSession:u(r),nearAccount:i(a),receiverId:o.receiverId,actions:o.actions,options:{...l(e,t.requestId,s||{})}});c(e,t.requestId,d)},PM_SEND_TRANSACTION:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,signedTransaction:o,options:s}=t.payload||{},f=await n.near.sendTransaction({walletSession:u(r),nearAccount:i(a),signedTransaction:d(o),options:{...l(e,t.requestId,s||{})}});c(e,t.requestId,f)},PM_SIGN_DELEGATE_ACTION:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,delegate:o,options:s}=t.payload,d=await n.near.signDelegateAction({walletSession:u(r),nearAccount:i(a),delegate:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)},PM_SIGN_NEP413:async t=>{let n=e.getWalletRuntime(),{walletId:r,nearAccountId:a,params:o,options:s}=t.payload,d=await n.near.signMessage({walletSession:u(r),nearAccount:i(a),params:o,options:{...l(e,t.requestId,s||{})}});e.respondIfCancelled(t.requestId)||c(e,t.requestId,d)}}}async function h(e,t){let n=await e.getWalletRuntime().runOwnerNearOperation(t.payload,g.bind(null,e,t.requestId),e.postProgress.bind(e,t.requestId),_.bind(null,e,t));c(e,t.requestId,n)}function g(e,t){if(e.isCancelled(t))throw new DOMException(`The owner operation was cancelled.`,`AbortError`)}function _(e,t){e.postProgress(t.requestId,{event:`owner_near_submitting`,operationId:t.payload.recovery.operationId})}async function v(e){await o(e,m)}export{v as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{c as e}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as t}from"./runtimeContext-ChuvOC0h.js";import{n}from"./shared-CkHhXgFB.js";function r(t){return{PM_SET_CONFIRM_BEHAVIOR:async r=>{let i=t.getWalletRuntime(),{behavior:a,walletId:o}=r.payload;o&&i.preferences.setCurrentWallet(e(o)),await i.preferences.setConfirmationBehavior(a),n(t,r.requestId,t.readPreferences())},PM_SET_CONFIRMATION_CONFIG:async r=>{let i=t.getWalletRuntime(),{walletId:a}=r.payload||{};a&&i.preferences.setCurrentWallet(e(a)),await i.preferences.setConfirmationConfig(r.payload?.config||{}),n(t,r.requestId,t.readPreferences())},PM_GET_CONFIRMATION_CONFIG:async e=>{let r=t.readPreferences();n(t,e.requestId,r)}}}async function i(e){await t(e,r)}export{i as handleWalletHostRuntimeRequest};
1
+ import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import{c as e}from"./ecdsaChainTarget-BoRVQtjQ.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as t}from"./runtimeContext-Iy1vecX0.js";import{n}from"./shared-CkHhXgFB.js";function r(t){return{PM_SET_CONFIRM_BEHAVIOR:async r=>{let i=t.getWalletRuntime(),{behavior:a,walletId:o}=r.payload;o&&i.preferences.setCurrentWallet(e(o)),await i.preferences.setConfirmationBehavior(a),n(t,r.requestId,t.readPreferences())},PM_SET_CONFIRMATION_CONFIG:async r=>{let i=t.getWalletRuntime(),{walletId:a}=r.payload||{};a&&i.preferences.setCurrentWallet(e(a)),await i.preferences.setConfirmationConfig(r.payload?.config||{}),n(t,r.requestId,t.readPreferences())},PM_GET_CONFIRMATION_CONFIG:async e=>{let r=t.readPreferences();n(t,e.requestId,r)}}}async function i(e){await t(e,r)}export{i as handleWalletHostRuntimeRequest};
@@ -1 +1 @@
1
- import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as e}from"./runtimeContext-ChuvOC0h.js";import{n as t,r as n}from"./shared-CkHhXgFB.js";function r(e){return{PM_SYNC_ACCOUNT_FLOW:async r=>{let i=e.getWalletRuntime(),{walletId:a}=r.payload||{};if(e.respondIfCancelled(r.requestId))return;let o=await i.recovery.syncAccount({...a?{walletId:a}:{},options:{...n(e,r.requestId,{})}});e.respondIfCancelled(r.requestId)||t(e,r.requestId,o)}}}async function i(t){await e(t,r)}export{i as handleWalletHostRuntimeRequest};
1
+ import"./walletDbName-B6-CV_Rq.js";import"./activeWalletSession-HAOgRKzn.js";import"./signingSessionSeal-BFOBKj-J.js";import"./capabilityKinds-Cafn86Y1.js";import"./errors-BJBDbwHk.js";import"./signerDomain-D-EUTlLK.js";import"./accountIds-DGWFzEnw.js";import"./csp-stylesheet-5LU6VGKK.js";import"./registrationIntent-Cb3tggIM.js";import"./presignatures-B9KnQyfE.js";import"./device-linking-BL2aDEUF.js";import"./walletAuthority-CU9nO0Ze.js";import"./digestEncoding-Rx8Vjy4J.js";import"./walletAuthMethodRecord--fvGr8r1.js";import"./signerSlot-BlijMq8C.js";import"./indexedDB-BqsYXybq.js";import"./keccak-DGHI1G6t.js";import"./registrationSignerPlan-CeMidFme.js";import"./walletCapabilityBindings-mPx-6_r-.js";import"./emailOtpEcdsaDerivationIdentity-DJmMyqL-.js";import"./authorization-D_NueqAv.js";import"./wallet-recovery-Bfm-oUoP.js";import"./signNear-DyFk--I3.js";import"./appearance-token-vars-CzlRDVQ7.js";import{handleWalletHostRuntimeRequestWithHandlers as e}from"./runtimeContext-Iy1vecX0.js";import{n as t,r as n}from"./shared-CkHhXgFB.js";function r(e){return{PM_SYNC_ACCOUNT_FLOW:async r=>{let i=e.getWalletRuntime(),{walletId:a}=r.payload||{};if(e.respondIfCancelled(r.requestId))return;let o=await i.recovery.syncAccount({...a?{walletId:a}:{},options:{...n(e,r.requestId,{})}});e.respondIfCancelled(r.requestId)||t(e,r.requestId,o)}}}async function i(t){await e(t,r)}export{i as handleWalletHostRuntimeRequest};