@seams/wallet 0.9.0 → 0.9.2

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 (60) hide show
  1. package/README.md +3 -3
  2. package/dist/.build-inputs.sha256 +1 -1
  3. package/dist/esm/core/signingEngine/chains/evm/bytes.js +15 -1
  4. package/dist/esm/core/signingEngine/flows/signEvmFamily/signingFlow.js +1 -1
  5. package/dist/esm/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.js +84 -38
  6. package/dist/esm/core/signingEngine/flows/signNear/signTransactions.js +49 -2
  7. package/dist/esm/core/signingEngine/uiConfirm/ui/confirm-surface-resize.js +173 -2
  8. package/dist/esm/core/signingEngine/uiConfirm/ui/surface-resize-events.js +6 -1
  9. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/abi/abiDecode.js +315 -0
  10. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/abi/enrichDisplayModelWithAbi.js +77 -0
  11. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/formatters.js +10 -1
  12. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/fallback.js +52 -0
  13. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/types.js +62 -0
  14. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/tree.js +249 -0
  15. package/dist/esm/sdk/{host-B1CdRGoI.js → host-c1__wJwz.js} +1 -1
  16. package/dist/esm/sdk/{runtime-auth-tgfe70hU.js → runtime-auth-BKFyLISf.js} +1 -1
  17. package/dist/{public/sdk/runtime-device-link-BUxuQupR.js → esm/sdk/runtime-device-link-ENxdEXQW.js} +1 -1
  18. package/dist/{public/sdk/runtime-ecdsa-tempo-DOBk_EtI.js → esm/sdk/runtime-ecdsa-tempo-DhGEb9U7.js} +1 -1
  19. package/dist/esm/sdk/{runtime-email-otp-CsAJKvYC.js → runtime-email-otp-dgsP7XZi.js} +1 -1
  20. package/dist/esm/sdk/{runtime-export-7REbcnBl.js → runtime-export-D2RCm5Gk.js} +1 -1
  21. package/dist/esm/sdk/{runtime-near-BA0DQf6H.js → runtime-near-Bf-9MFBQ.js} +1 -1
  22. package/dist/esm/sdk/{runtime-preferences-cRViPE8a.js → runtime-preferences-LQ8SPE7o.js} +1 -1
  23. package/dist/esm/sdk/{runtime-recovery-RRc8Yz1y.js → runtime-recovery-BuEzJzuZ.js} +1 -1
  24. package/dist/esm/sdk/shared-8ffIBYw2.js +6 -0
  25. package/dist/esm/sdk/signNear-BhTkDm2-.js +1 -0
  26. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  27. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  28. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  29. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  30. package/dist/esm/utils/intentDigest.js +59 -1
  31. package/dist/public/headers.manifest.json +1 -1
  32. package/dist/public/sdk/{host-B1CdRGoI.js → host-c1__wJwz.js} +1 -1
  33. package/dist/public/sdk/{runtime-auth-tgfe70hU.js → runtime-auth-BKFyLISf.js} +1 -1
  34. package/dist/{esm/sdk/runtime-device-link-BUxuQupR.js → public/sdk/runtime-device-link-ENxdEXQW.js} +1 -1
  35. package/dist/{esm/sdk/runtime-ecdsa-tempo-DOBk_EtI.js → public/sdk/runtime-ecdsa-tempo-DhGEb9U7.js} +1 -1
  36. package/dist/public/sdk/{runtime-email-otp-CsAJKvYC.js → runtime-email-otp-dgsP7XZi.js} +1 -1
  37. package/dist/public/sdk/{runtime-export-7REbcnBl.js → runtime-export-D2RCm5Gk.js} +1 -1
  38. package/dist/public/sdk/{runtime-near-BA0DQf6H.js → runtime-near-Bf-9MFBQ.js} +1 -1
  39. package/dist/public/sdk/{runtime-preferences-cRViPE8a.js → runtime-preferences-LQ8SPE7o.js} +1 -1
  40. package/dist/public/sdk/{runtime-recovery-RRc8Yz1y.js → runtime-recovery-BuEzJzuZ.js} +1 -1
  41. package/dist/public/sdk/shared-8ffIBYw2.js +6 -0
  42. package/dist/public/sdk/signNear-BhTkDm2-.js +1 -0
  43. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  44. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  45. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  46. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  47. package/dist/public/wallet-assets.manifest.json +26 -26
  48. package/dist/public/wallet-service/index.html +4 -4
  49. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.d.ts +16 -4
  50. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signatureOnlySigning.d.ts +3 -3
  51. package/dist/types/wallet/src/core/signingEngine/nonce/nearTransactionReadiness.d.ts +3 -0
  52. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/confirmOperation.d.ts +3 -1
  53. package/dist/types/wallet/src/core/signingEngine/uiConfirm/handlers/flows/signing.d.ts +2 -0
  54. package/dist/types/wallet/src/core/signingEngine/uiConfirm/handlers/handlePromptFromWorker.d.ts +2 -0
  55. package/dist/types/wallet/src/core/signingEngine/uiConfirm/uiConfirm.types.d.ts +3 -0
  56. package/package.json +1 -1
  57. package/dist/esm/sdk/shared-DdfxBUGY.js +0 -6
  58. package/dist/esm/sdk/signNear-CO5bx24Z.js +0 -1
  59. package/dist/public/sdk/shared-DdfxBUGY.js +0 -6
  60. package/dist/public/sdk/signNear-CO5bx24Z.js +0 -1
@@ -0,0 +1,249 @@
1
+ import { isString } from "../../../../../shared-ts/src/utils/validation.js";
2
+ import { formatArgs, formatCodeSize, shortenPubkey } from "./formatters.js";
3
+ import { renderFallbackDisplayOperation } from "./renderers/fallback.js";
4
+ //#region src/core/signingEngine/uiConfirm/ui/transaction-display/tree.ts
5
+ function toChainLabel(chain) {
6
+ switch (chain) {
7
+ case "near": return "NEAR";
8
+ case "evm": return "EVM";
9
+ case "tempo": return "Tempo";
10
+ default: return "Unknown";
11
+ }
12
+ }
13
+ function buildWarningNodes(warnings) {
14
+ if (!Array.isArray(warnings) || warnings.length === 0) return [];
15
+ return [{
16
+ id: "warnings-root",
17
+ label: "Warnings",
18
+ type: "folder",
19
+ open: true,
20
+ children: warnings.map((warning, warningIndex) => ({
21
+ id: `warning-${warningIndex}`,
22
+ label: `[${String(warning.severity || "warning").toUpperCase()}] ${String(warning.message || "")}`,
23
+ type: "file",
24
+ open: false
25
+ }))
26
+ }];
27
+ }
28
+ function renderOperationNode(operation, depth, path) {
29
+ return renderFallbackDisplayOperation({
30
+ operation,
31
+ depth,
32
+ path,
33
+ renderChild: (childOperation, childDepth, childPath) => renderOperationNode(childOperation, childDepth, childPath)
34
+ });
35
+ }
36
+ function hideFolderChevrons(node) {
37
+ const children = Array.isArray(node.children) ? node.children.map((child) => hideFolderChevrons(child)) : void 0;
38
+ if (node.type !== "folder") return children ? {
39
+ ...node,
40
+ children
41
+ } : node;
42
+ return {
43
+ ...node,
44
+ hideChevron: true,
45
+ children
46
+ };
47
+ }
48
+ function attachChainToNode(node, chain) {
49
+ const children = Array.isArray(node.children) ? node.children.map((child) => attachChainToNode(child, chain)) : void 0;
50
+ return {
51
+ ...node,
52
+ chain,
53
+ ...children ? { children } : {}
54
+ };
55
+ }
56
+ function buildDisplayTreeFromModel(model) {
57
+ const hideModelFolderChevrons = model.chain === "evm" || model.chain === "tempo";
58
+ const operationNodes = (Array.isArray(model.operations) ? model.operations : []).map((operation, operationIndex) => renderOperationNode(operation, 0, String(operationIndex))).map((node) => attachChainToNode(node, model.chain)).map((node) => hideModelFolderChevrons ? hideFolderChevrons(node) : node);
59
+ const rootChildren = [...buildWarningNodes(model.warnings).map((node) => attachChainToNode(node, model.chain)).map((node) => hideModelFolderChevrons ? hideFolderChevrons(node) : node), ...operationNodes];
60
+ if (rootChildren.length === 0) rootChildren.push({
61
+ id: "no-operations",
62
+ label: "No operations",
63
+ type: "file",
64
+ open: false
65
+ });
66
+ const chainLabel = toChainLabel(model.chain);
67
+ return {
68
+ id: "display-root",
69
+ label: String(model.title || "").trim() || `${chainLabel} Transaction`,
70
+ type: "folder",
71
+ open: true,
72
+ children: rootChildren
73
+ };
74
+ }
75
+ function buildActionNode(action, idx) {
76
+ let actionNodes;
77
+ switch (action.type) {
78
+ case "FunctionCall":
79
+ actionNodes = [{
80
+ id: `a${idx}-args`,
81
+ label: "using args:",
82
+ type: "file",
83
+ open: false,
84
+ hideChevron: true,
85
+ hideLabel: true,
86
+ content: formatArgs(action.args)
87
+ }];
88
+ break;
89
+ case "Transfer":
90
+ actionNodes = [];
91
+ break;
92
+ case "CreateAccount":
93
+ actionNodes = [];
94
+ break;
95
+ case "DeployContract": {
96
+ const codeSize = formatCodeSize(action.code);
97
+ actionNodes = [{
98
+ id: `a${idx}-code-size`,
99
+ label: `WASM contract code size: ${codeSize}`,
100
+ type: "file",
101
+ open: false
102
+ }];
103
+ break;
104
+ }
105
+ case "DeployGlobalContract": {
106
+ const code = action.code;
107
+ const deployMode = action.deployMode;
108
+ const codeSize = formatCodeSize(code);
109
+ actionNodes = [{
110
+ id: `a${idx}-deploy-mode`,
111
+ label: `mode: ${String(deployMode || "")}`,
112
+ type: "file",
113
+ open: false
114
+ }, {
115
+ id: `a${idx}-code-size`,
116
+ label: `WASM global contract code size: ${codeSize}`,
117
+ type: "file",
118
+ open: false
119
+ }];
120
+ break;
121
+ }
122
+ case "UseGlobalContract": {
123
+ const accountId = action.accountId;
124
+ const codeHash = action.codeHash;
125
+ let label;
126
+ if (accountId) label = `by account: ${String(accountId)}`;
127
+ else if (codeHash) label = `by hash: ${shortenPubkey(String(codeHash), {
128
+ prefix: 10,
129
+ suffix: 6
130
+ })}`;
131
+ else label = "by global contract identifier";
132
+ actionNodes = [{
133
+ id: `a${idx}-identifier`,
134
+ label,
135
+ type: "file",
136
+ open: false
137
+ }];
138
+ break;
139
+ }
140
+ case "Stake":
141
+ actionNodes = [{
142
+ id: `a${idx}-publicKey`,
143
+ label: `validator: ${shortenPubkey(action.publicKey)}`,
144
+ type: "file",
145
+ open: true,
146
+ copyValue: action.publicKey
147
+ }];
148
+ break;
149
+ case "AddKey": {
150
+ const ak = action.accessKey;
151
+ let permissions = "";
152
+ try {
153
+ permissions = (isString(ak) ? JSON.parse(ak) : ak).permission === "FullAccess" ? "Full Access" : "Function Call";
154
+ } catch {
155
+ permissions = "Unknown";
156
+ }
157
+ actionNodes = [{
158
+ id: `a${idx}-publicKey`,
159
+ label: `key: ${shortenPubkey(action.publicKey)}`,
160
+ open: false,
161
+ type: "file",
162
+ copyValue: action.publicKey
163
+ }, {
164
+ id: `a${idx}-permissions`,
165
+ label: `permissions: ${permissions}`,
166
+ open: false,
167
+ type: "file"
168
+ }];
169
+ break;
170
+ }
171
+ case "DeleteKey":
172
+ actionNodes = [{
173
+ id: `a${idx}-publicKey`,
174
+ label: `key: ${shortenPubkey(action.publicKey)}`,
175
+ open: false,
176
+ type: "file",
177
+ copyValue: action.publicKey
178
+ }];
179
+ break;
180
+ case "DeleteAccount":
181
+ actionNodes = [{
182
+ id: `a${idx}-beneficiaryId`,
183
+ label: `sending balance to: ${action.beneficiaryId}`,
184
+ open: false,
185
+ type: "file"
186
+ }];
187
+ break;
188
+ default: {
189
+ let raw = "";
190
+ try {
191
+ raw = JSON.stringify(action, null, 2);
192
+ } catch {
193
+ raw = String(action);
194
+ }
195
+ actionNodes = [{
196
+ id: `a${idx}-action`,
197
+ label: `Action: ${action.type || "Unknown"}`,
198
+ open: false,
199
+ type: "file"
200
+ }, {
201
+ id: `a${idx}-raw`,
202
+ label: "Raw Data",
203
+ type: "file",
204
+ open: false,
205
+ content: raw
206
+ }];
207
+ break;
208
+ }
209
+ }
210
+ return {
211
+ id: `action-${idx}`,
212
+ label: "",
213
+ type: "folder",
214
+ open: false,
215
+ hideChevron: true,
216
+ action,
217
+ actionIndex: idx,
218
+ children: actionNodes
219
+ };
220
+ }
221
+ function buildTransactionNode(tx, tIdx, totalTransactions) {
222
+ const actionFolders = tx.actions.map((action, idx) => buildActionNode(action, idx));
223
+ return {
224
+ id: `tx-${tIdx}`,
225
+ label: "",
226
+ type: "folder",
227
+ open: true,
228
+ hideChevron: true,
229
+ transaction: tx,
230
+ transactionIndex: tIdx,
231
+ totalTransactions,
232
+ children: [...actionFolders]
233
+ };
234
+ }
235
+ function buildDisplayTreeFromTxPayloads(txSigningRequests) {
236
+ const totalTransactions = txSigningRequests.length;
237
+ const txFolders = txSigningRequests.map((tx, tIdx) => buildTransactionNode(tx, tIdx, totalTransactions));
238
+ return {
239
+ id: "txs-root",
240
+ label: totalTransactions > 1 ? "Transactions" : "Transaction",
241
+ type: "folder",
242
+ open: true,
243
+ children: txFolders
244
+ };
245
+ }
246
+ //#endregion
247
+ export { buildDisplayTreeFromModel, buildDisplayTreeFromTxPayloads };
248
+
249
+ //# sourceMappingURL=tree.js.map
@@ -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-tgfe70hU.js`);case`near`:return import(`./runtime-near-BA0DQf6H.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DOBk_EtI.js`);case`email_otp`:return import(`./runtime-email-otp-CsAJKvYC.js`);case`recovery`:return import(`./runtime-recovery-RRc8Yz1y.js`);case`export`:return import(`./runtime-export-7REbcnBl.js`);case`device_link`:return import(`./runtime-device-link-BUxuQupR.js`);case`preferences`:return import(`./runtime-preferences-cRViPE8a.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-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};