@seams/wallet 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/core/signingEngine/flows/signNear/shared/signatureOnlySigning.js +4 -9
- package/dist/esm/core/signingEngine/flows/signNear/signDelegate.js +10 -2
- package/dist/esm/core/signingEngine/flows/signNear/signNep413.js +6 -1
- package/dist/esm/core/signingEngine/uiConfirm/ui/confirm-surface-resize.js +173 -2
- package/dist/esm/core/signingEngine/uiConfirm/ui/surface-resize-events.js +6 -1
- package/dist/esm/sdk/{host-c1__wJwz.js → host-CWE1mHHY.js} +1 -1
- package/dist/esm/sdk/{runtime-auth-BKFyLISf.js → runtime-auth-DiEJDFkJ.js} +1 -1
- package/dist/{public/sdk/runtime-device-link-ENxdEXQW.js → esm/sdk/runtime-device-link-5u31t1H0.js} +1 -1
- package/dist/{public/sdk/runtime-ecdsa-tempo-DhGEb9U7.js → esm/sdk/runtime-ecdsa-tempo-C3CRzwph.js} +1 -1
- package/dist/esm/sdk/{runtime-email-otp-dgsP7XZi.js → runtime-email-otp-DHlirACG.js} +1 -1
- package/dist/esm/sdk/{runtime-export-D2RCm5Gk.js → runtime-export-CFy4-Ebn.js} +1 -1
- package/dist/esm/sdk/{runtime-near-Bf-9MFBQ.js → runtime-near-BxYOozPP.js} +1 -1
- package/dist/esm/sdk/{runtime-preferences-LQ8SPE7o.js → runtime-preferences-C1Exkn4E.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-BuEzJzuZ.js → runtime-recovery-DSbvI1DT.js} +1 -1
- package/dist/esm/sdk/{shared-8ffIBYw2.js → shared-6SvVPZD0.js} +1 -1
- package/dist/esm/sdk/{signNear-BhTkDm2-.js → signNear-C6ljzB87.js} +1 -1
- package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/{host-c1__wJwz.js → host-CWE1mHHY.js} +1 -1
- package/dist/public/sdk/{runtime-auth-BKFyLISf.js → runtime-auth-DiEJDFkJ.js} +1 -1
- package/dist/{esm/sdk/runtime-device-link-ENxdEXQW.js → public/sdk/runtime-device-link-5u31t1H0.js} +1 -1
- package/dist/{esm/sdk/runtime-ecdsa-tempo-DhGEb9U7.js → public/sdk/runtime-ecdsa-tempo-C3CRzwph.js} +1 -1
- package/dist/public/sdk/{runtime-email-otp-dgsP7XZi.js → runtime-email-otp-DHlirACG.js} +1 -1
- package/dist/public/sdk/{runtime-export-D2RCm5Gk.js → runtime-export-CFy4-Ebn.js} +1 -1
- package/dist/public/sdk/{runtime-near-Bf-9MFBQ.js → runtime-near-BxYOozPP.js} +1 -1
- package/dist/public/sdk/{runtime-preferences-LQ8SPE7o.js → runtime-preferences-C1Exkn4E.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-BuEzJzuZ.js → runtime-recovery-DSbvI1DT.js} +1 -1
- package/dist/public/sdk/{shared-8ffIBYw2.js → shared-6SvVPZD0.js} +1 -1
- package/dist/public/sdk/{signNear-BhTkDm2-.js → signNear-C6ljzB87.js} +1 -1
- package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/sdk/workers/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/public/wallet-assets.manifest.json +26 -26
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signatureOnlySigning.d.ts +2 -2
- package/dist/workers/shamir3pass_runtime_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Seams Wallet SDK
|
|
2
2
|
|
|
3
|
-
`@seams/wallet` **0.9.
|
|
3
|
+
`@seams/wallet` **0.9.3** provides browser wallet lifecycle, NEAR and EVM-family
|
|
4
4
|
threshold signing, React components, and hosted wallet runtime assets.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
pnpm add @seams/wallet@0.9.
|
|
9
|
+
pnpm add @seams/wallet@0.9.3
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
React integrations support React 18 and 19. Import the provider and UI from
|
|
13
13
|
`@seams/wallet/react` and its stylesheet from `@seams/wallet/react/styles`.
|
|
14
14
|
Keep the application package, wallet-origin assets, and
|
|
15
|
-
`@seams/wallet-server@0.9.
|
|
15
|
+
`@seams/wallet-server@0.9.3` on the matching release.
|
|
16
16
|
|
|
17
17
|
## Next release migration (unreleased)
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
baaacacbc40c756149e9350116e31155bb6db1caa8e113422fb146f612c325b8
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SigningSessionIds, SigningSessionPlanKind } from "../../../session/operationState/types.js";
|
|
2
2
|
import { nearEd25519SignerBindingFromBoundaryFields } from "../../../session/identity/exactSigningLaneIdentity.js";
|
|
3
|
-
import { computeUiIntentDigestFromNep413 } from "../../../../../utils/intentDigest.js";
|
|
4
3
|
import { parseSigningOperationFingerprintDigest } from "../../../../../shared-ts/src/authorization/operationFingerprint.js";
|
|
5
4
|
import { SigningOperationCommandKind, runSigningOperationCommand } from "../../shared/signingStateMachine.js";
|
|
6
5
|
import { buildSigningConfirmationAuthParams } from "../../../stepUpConfirmation/confirmOperation.js";
|
|
@@ -241,14 +240,14 @@ function authorizeNearSignatureOnlyOperation(operation, stepUp, confirmation) {
|
|
|
241
240
|
};
|
|
242
241
|
}
|
|
243
242
|
/**
|
|
244
|
-
* Sends the server prepare of a warm-session
|
|
243
|
+
* Sends the server prepare of a warm-session signature while the
|
|
245
244
|
* confirmation dialog is open. The request is bound to the digest the dialog
|
|
246
245
|
* shows and to the signing digest. A confirmation that returns another digest,
|
|
247
246
|
* a declined confirmation or a step-up leaves the prepare to expire with its
|
|
248
247
|
* lease; the quota use it claimed stays spent.
|
|
249
248
|
*/
|
|
250
|
-
async function startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCoordinator) {
|
|
251
|
-
if (stepUp.preparedStepUp.kind !== "warm_session"
|
|
249
|
+
async function startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCoordinator, displayDigest) {
|
|
250
|
+
if (stepUp.preparedStepUp.kind !== "warm_session") return null;
|
|
252
251
|
const resolved = await resolveConfirmedNearEd25519YaoCapability({
|
|
253
252
|
preparation: operation.preparation,
|
|
254
253
|
executor: operation.executor
|
|
@@ -267,11 +266,7 @@ async function startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCo
|
|
|
267
266
|
nearAccountId: operation.nearAccountId,
|
|
268
267
|
operationId: operation.signingOperation.operationId,
|
|
269
268
|
operationFingerprint: operation.signingOperation.operationFingerprint,
|
|
270
|
-
displayDigest
|
|
271
|
-
nearAccountId: operation.nearAccountId,
|
|
272
|
-
recipient: operation.intent.recipient,
|
|
273
|
-
message: operation.intent.message
|
|
274
|
-
}),
|
|
269
|
+
displayDigest,
|
|
275
270
|
signingDigestB64u: await operation.computeSigningDigestB64u(),
|
|
276
271
|
intent: operation.intent
|
|
277
272
|
});
|
|
@@ -6,7 +6,9 @@ import { ensureEd25519Prefix } from "../../../../shared-ts/src/utils/near.js";
|
|
|
6
6
|
import { toAccountId } from "../../../types/accountIds.js";
|
|
7
7
|
import { SigningEventPhase, createSigningFlowEvent } from "../../../types/sdkSentEvents.js";
|
|
8
8
|
import { SigningOperationIntent, SigningSessionIds } from "../../session/operationState/types.js";
|
|
9
|
+
import { computeUiIntentDigestFromTxs, orderActionForDigest } from "../../../../utils/intentDigest.js";
|
|
9
10
|
import { isWarmSessionSigningAuthPlan } from "../../stepUpConfirmation/types.js";
|
|
11
|
+
import { emitEd25519SigningTiming } from "../../session/operationState/trace.js";
|
|
10
12
|
import { SigningOperationCommandKind, runSigningOperationCommand } from "../shared/signingStateMachine.js";
|
|
11
13
|
import { resolveNearSigningMaterials } from "./shared/signingMaterials.js";
|
|
12
14
|
import { buildNearDelegateSigningPayloads } from "../../chains/near/payloads.js";
|
|
@@ -14,7 +16,7 @@ import { parseThresholdEd25519NearAction, thresholdEd25519DelegateActionOperatio
|
|
|
14
16
|
import { computeThresholdEd25519DelegateSigningDigestWasm } from "../../chains/near/nearSignerWasm.js";
|
|
15
17
|
import { finalizeThresholdEd25519DelegateSignatureResult } from "./shared/ed25519YaoNormalSigning.js";
|
|
16
18
|
import { toPublicKeyString } from "../../workerManager/validation.js";
|
|
17
|
-
import { authorizeNearSignatureOnlyOperation, confirmNearSignatureOnlyOperation, prepareNearSignatureOnlyStepUp, resolveNearSignatureOnlySigningMaterial, resolveNearSignatureOnlySigningPlans, runNearSignatureOnlySignCommand, signNearSignatureOnlyOperation } from "./shared/signatureOnlySigning.js";
|
|
19
|
+
import { authorizeNearSignatureOnlyOperation, confirmNearSignatureOnlyOperation, prepareNearSignatureOnlyStepUp, resolveNearSignatureOnlySigningMaterial, resolveNearSignatureOnlySigningPlans, runNearSignatureOnlySignCommand, signNearSignatureOnlyOperation, startNearSignatureOnlyPrepare } from "./shared/signatureOnlySigning.js";
|
|
18
20
|
//#region src/core/signingEngine/flows/signNear/signDelegate.ts
|
|
19
21
|
function emitNearSigningEvent(onEvent, accountId, event) {
|
|
20
22
|
try {
|
|
@@ -137,6 +139,11 @@ async function runNearDelegateActionSigning({ ctx, commandSubject, nearAccount,
|
|
|
137
139
|
remainingUses: confirmationAuthPayload.signingAuthPlan.remainingUses
|
|
138
140
|
}
|
|
139
141
|
});
|
|
142
|
+
const startedPrepare = await startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCoordinator, await computeUiIntentDigestFromTxs([{
|
|
143
|
+
receiverId: delegateSigningPayloads.confirmationDelegate.receiverId,
|
|
144
|
+
actions: delegateSigningPayloads.confirmationDelegate.actions.map(orderActionForDigest)
|
|
145
|
+
}]));
|
|
146
|
+
const confirmationStartedAt = performance.now();
|
|
140
147
|
emitNearSigningEvent(onEvent, nearAccountId, {
|
|
141
148
|
phase: SigningEventPhase.STEP_05_CONFIRMATION_DISPLAYED,
|
|
142
149
|
status: "waiting_for_user",
|
|
@@ -160,6 +167,7 @@ async function runNearDelegateActionSigning({ ctx, commandSubject, nearAccount,
|
|
|
160
167
|
rpcCall: resolvedRpcCall
|
|
161
168
|
}
|
|
162
169
|
});
|
|
170
|
+
emitEd25519SigningTiming(String(operationId), "confirmation", confirmationStartedAt);
|
|
163
171
|
emitNearSigningEvent(onEvent, nearAccountId, {
|
|
164
172
|
phase: SigningEventPhase.STEP_05_CONFIRMATION_APPROVED,
|
|
165
173
|
status: "succeeded",
|
|
@@ -183,7 +191,7 @@ async function runNearDelegateActionSigning({ ctx, commandSubject, nearAccount,
|
|
|
183
191
|
overlay: "none"
|
|
184
192
|
}
|
|
185
193
|
});
|
|
186
|
-
const material = await resolveNearSignatureOnlySigningMaterial(operation, authorization);
|
|
194
|
+
const material = await resolveNearSignatureOnlySigningMaterial(operation, authorization, startedPrepare);
|
|
187
195
|
emitNearSigningEvent(onEvent, nearAccountId, {
|
|
188
196
|
phase: SigningEventPhase.STEP_07_AUTHENTICATION_COMPLETE,
|
|
189
197
|
status: "succeeded",
|
|
@@ -4,6 +4,7 @@ import { resolveNearNetwork } from "../../../config/chains.js";
|
|
|
4
4
|
import { normalizeThresholdEd25519ParticipantIds } from "../../../../shared-ts/src/threshold/participants.js";
|
|
5
5
|
import { PASSKEY_MANAGER_DEFAULT_CONFIGS } from "../../../config/defaultConfigs.js";
|
|
6
6
|
import { SigningOperationIntent, SigningSessionIds } from "../../session/operationState/types.js";
|
|
7
|
+
import { computeUiIntentDigestFromNep413 } from "../../../../utils/intentDigest.js";
|
|
7
8
|
import { emitEd25519SigningTiming } from "../../session/operationState/trace.js";
|
|
8
9
|
import { SigningOperationCommandKind, runSigningOperationCommand } from "../shared/signingStateMachine.js";
|
|
9
10
|
import { resolveNearSigningMaterials } from "./shared/signingMaterials.js";
|
|
@@ -83,7 +84,11 @@ async function signNep413Message({ ctx, commandSubject, nearAccount, signingSess
|
|
|
83
84
|
passkeyEd25519OperationStepUp,
|
|
84
85
|
emailOtpEd25519StepUp
|
|
85
86
|
});
|
|
86
|
-
const startedPrepare = await startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCoordinator
|
|
87
|
+
const startedPrepare = await startNearSignatureOnlyPrepare(operation, stepUp, signingSessionCoordinator, await computeUiIntentDigestFromNep413({
|
|
88
|
+
nearAccountId,
|
|
89
|
+
recipient: payload.recipient,
|
|
90
|
+
message: payload.message
|
|
91
|
+
}));
|
|
87
92
|
emitEd25519SigningTiming(String(operationId), "pre_confirmation", preConfirmationStartedAt);
|
|
88
93
|
const confirmationStartedAt = performance.now();
|
|
89
94
|
const confirmation = await confirmNearSignatureOnlyOperation(operation, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
|
|
1
|
+
import { addSurfaceResizeBeginListener, dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
|
|
2
2
|
//#region src/core/signingEngine/uiConfirm/ui/confirm-surface-resize.ts
|
|
3
3
|
/**
|
|
4
4
|
* Host-driven height changes for wallet-iframe confirmations.
|
|
@@ -25,6 +25,10 @@ import { dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
|
|
|
25
25
|
*
|
|
26
26
|
* The module owns the rules for iframe-hosted confirmation reflow.
|
|
27
27
|
*/
|
|
28
|
+
const CONFIRM_SURFACE_MODE_ATTR = "data-seams-confirm-surface";
|
|
29
|
+
const CONFIRM_SURFACE_MODE_WALLET_IFRAME = "wallet-iframe";
|
|
30
|
+
/** Marks the confirmer host while its height is held at a motion's target. */
|
|
31
|
+
const CONFIRM_SURFACE_PINNED_CLASS = "seams-confirm-surface-pinned";
|
|
28
32
|
/**
|
|
29
33
|
* Marks the document root for the same span. It is a second class rather than
|
|
30
34
|
* the one above because the host rule must match any element that hosts a
|
|
@@ -37,6 +41,24 @@ const CONFIRM_SURFACE_PINNED_ROOT_CLASS = "seams-confirm-surface-pinned-root";
|
|
|
37
41
|
const CONFIRM_SURFACE_HEIGHT_DRIVEN_CLASS = "seams-surface-height-driven";
|
|
38
42
|
/** The CSS variable the class above reads. Components own the write (CSP). */
|
|
39
43
|
const CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR = "--seams-surface-height-driven-target";
|
|
44
|
+
/** Frames the box may sit still, after it has moved, before its motion counts as over. */
|
|
45
|
+
const SETTLED_FRAMES_AFTER_MOTION = 8;
|
|
46
|
+
/** Frames to wait for the parent to react at all before giving up on it. */
|
|
47
|
+
const SETTLED_FRAMES_WITHOUT_MOTION = 20;
|
|
48
|
+
/**
|
|
49
|
+
* The parent writes the destination box and forces a layout BEFORE it starts
|
|
50
|
+
* its ease, and a cross-origin iframe can receive that destination size for one
|
|
51
|
+
* frame before the animation snaps it back to the origin. Landing on that
|
|
52
|
+
* frame finishes the interior instantly and leaves the box to ease on its
|
|
53
|
+
* own — the exact jank this module exists to remove. A box that jumps straight
|
|
54
|
+
* to the target therefore has to stay there this many frames before the
|
|
55
|
+
* content lands on it; a box that eased through intermediate sizes lands at
|
|
56
|
+
* once. The parent pins the iframe to the origin for that read
|
|
57
|
+
* (`overlay-styles.ts pinDialogIframe`), so this is the second of two guards.
|
|
58
|
+
*/
|
|
59
|
+
const LANDING_CONFIRM_FRAMES = 3;
|
|
60
|
+
/** The parent rounds the measured size; allow that much slack when asking whether the box hugs the host. */
|
|
61
|
+
const HUG_TOLERANCE_CSS_PX = 1;
|
|
40
62
|
/** A host that claims a motion and never lands it must not leave content clamped. */
|
|
41
63
|
const ANNOUNCE_SAFETY_MS = 1500;
|
|
42
64
|
/** Height changes below this are not worth a motion, and round to nothing. */
|
|
@@ -169,7 +191,156 @@ function announceClampedSurfaceResize(args) {
|
|
|
169
191
|
if (!claimed) element.classList.remove(...addedClasses);
|
|
170
192
|
return claimed;
|
|
171
193
|
}
|
|
194
|
+
let diagnosticHost = null;
|
|
195
|
+
const surfaceMotionDiagnostics = {
|
|
196
|
+
blipFrames: 0,
|
|
197
|
+
trace(durationMs = 2e3) {
|
|
198
|
+
return new Promise((resolve) => {
|
|
199
|
+
const lines = [];
|
|
200
|
+
const startedAt = performance.now();
|
|
201
|
+
const tick = () => {
|
|
202
|
+
const host = diagnosticHost;
|
|
203
|
+
const pinned = host?.classList.contains(CONFIRM_SURFACE_PINNED_CLASS) ? "*" : "";
|
|
204
|
+
lines.push(`${Math.round(performance.now() - startedAt)}: box=${document.documentElement.clientHeight} content=${host ? Math.round(host.getBoundingClientRect().height) : "-"}${pinned}`);
|
|
205
|
+
if (performance.now() - startedAt < durationMs) requestAnimationFrame(tick);
|
|
206
|
+
else resolve(lines);
|
|
207
|
+
};
|
|
208
|
+
requestAnimationFrame(tick);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
function publishDiagnostics(element) {
|
|
213
|
+
diagnosticHost = element;
|
|
214
|
+
try {
|
|
215
|
+
window.__seamsSurfaceMotion = surfaceMotionDiagnostics;
|
|
216
|
+
} catch {}
|
|
217
|
+
}
|
|
218
|
+
function defaultViewportHeightCssPx() {
|
|
219
|
+
const height = document.documentElement?.clientHeight ?? 0;
|
|
220
|
+
return height > 0 ? height : window.innerHeight;
|
|
221
|
+
}
|
|
222
|
+
function clamp(value, min, max) {
|
|
223
|
+
return Math.min(Math.max(value, min), max);
|
|
224
|
+
}
|
|
225
|
+
function isWalletIframeConfirmSurface(element) {
|
|
226
|
+
return element.getAttribute(CONFIRM_SURFACE_MODE_ATTR) === CONFIRM_SURFACE_MODE_WALLET_IFRAME;
|
|
227
|
+
}
|
|
228
|
+
function createHostHeightPin(element) {
|
|
229
|
+
if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return null;
|
|
230
|
+
let sheet = null;
|
|
231
|
+
const release = () => {
|
|
232
|
+
element.classList.remove(CONFIRM_SURFACE_PINNED_CLASS);
|
|
233
|
+
document.documentElement.classList.remove(CONFIRM_SURFACE_PINNED_ROOT_CLASS);
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
set(px) {
|
|
237
|
+
try {
|
|
238
|
+
if (!sheet) sheet = new CSSStyleSheet();
|
|
239
|
+
sheet.replaceSync(`.${CONFIRM_SURFACE_PINNED_CLASS}{height:${Math.max(0, Math.round(px))}px}.${CONFIRM_SURFACE_PINNED_ROOT_CLASS}{overflow:hidden}`);
|
|
240
|
+
if (!document.adoptedStyleSheets.includes(sheet)) document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
element.classList.add(CONFIRM_SURFACE_PINNED_CLASS);
|
|
245
|
+
document.documentElement.classList.add(CONFIRM_SURFACE_PINNED_ROOT_CLASS);
|
|
246
|
+
return true;
|
|
247
|
+
},
|
|
248
|
+
release,
|
|
249
|
+
dispose() {
|
|
250
|
+
release();
|
|
251
|
+
if (!sheet) return;
|
|
252
|
+
const retired = sheet;
|
|
253
|
+
sheet = null;
|
|
254
|
+
try {
|
|
255
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== retired);
|
|
256
|
+
} catch {}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function attachConfirmSurfaceResizeChoreographer(element, options = {}) {
|
|
261
|
+
const readViewportHeightCssPx = options.viewportHeightCssPx ?? defaultViewportHeightCssPx;
|
|
262
|
+
const pin = createHostHeightPin(element);
|
|
263
|
+
publishDiagnostics(element);
|
|
264
|
+
let active = null;
|
|
265
|
+
const settle = () => {
|
|
266
|
+
const current = active;
|
|
267
|
+
if (!current) return;
|
|
268
|
+
active = null;
|
|
269
|
+
if (current.frame !== null) cancelAnimationFrame(current.frame);
|
|
270
|
+
current.driver.setProgress(1);
|
|
271
|
+
current.driver.finish();
|
|
272
|
+
pin?.release();
|
|
273
|
+
};
|
|
274
|
+
const step = () => {
|
|
275
|
+
const current = active;
|
|
276
|
+
if (!current) return;
|
|
277
|
+
current.frame = null;
|
|
278
|
+
const viewportPx = readViewportHeightCssPx();
|
|
279
|
+
if (viewportPx !== current.lastViewportPx) {
|
|
280
|
+
current.lastViewportPx = viewportPx;
|
|
281
|
+
current.framesSinceChange = 0;
|
|
282
|
+
current.moved = true;
|
|
283
|
+
} else current.framesSinceChange += 1;
|
|
284
|
+
const progress = clamp((viewportPx - current.originHostPx) / current.deltaCssPx, 0, 1);
|
|
285
|
+
if (progress >= 1) {
|
|
286
|
+
current.framesAtTarget += 1;
|
|
287
|
+
if (current.sawIntermediate || current.framesAtTarget >= LANDING_CONFIRM_FRAMES) {
|
|
288
|
+
settle();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
current.frame = requestAnimationFrame(step);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (current.framesAtTarget > 0) surfaceMotionDiagnostics.blipFrames += 1;
|
|
295
|
+
current.framesAtTarget = 0;
|
|
296
|
+
if (progress > 0) current.sawIntermediate = true;
|
|
297
|
+
current.driver.setProgress(progress);
|
|
298
|
+
const settledFrames = current.moved ? SETTLED_FRAMES_AFTER_MOTION : SETTLED_FRAMES_WITHOUT_MOTION;
|
|
299
|
+
if (current.framesSinceChange >= settledFrames) {
|
|
300
|
+
settle();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
current.frame = requestAnimationFrame(step);
|
|
304
|
+
};
|
|
305
|
+
const onSurfaceResizeBegin = (event) => {
|
|
306
|
+
const detail = event.detail;
|
|
307
|
+
if (!pin || !detail || !isWalletIframeConfirmSurface(element)) return;
|
|
308
|
+
const deltaCssPx = detail.deltaCssPx;
|
|
309
|
+
if (!Number.isFinite(deltaCssPx) || Math.abs(deltaCssPx) < MIN_ANNOUNCED_DELTA_CSS_PX) return;
|
|
310
|
+
settle();
|
|
311
|
+
const viewportPx = readViewportHeightCssPx();
|
|
312
|
+
const hostPx = element.getBoundingClientRect().height;
|
|
313
|
+
if (!(viewportPx > 0) || !(hostPx > 0) || Math.abs(viewportPx - hostPx) > HUG_TOLERANCE_CSS_PX) return;
|
|
314
|
+
const originHostPx = Math.round(hostPx);
|
|
315
|
+
const targetHostPx = originHostPx + deltaCssPx;
|
|
316
|
+
if (!(targetHostPx > 0)) return;
|
|
317
|
+
if (!pin.set(targetHostPx)) return;
|
|
318
|
+
const driver = detail.claim();
|
|
319
|
+
if (!driver) {
|
|
320
|
+
pin.release();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
active = {
|
|
324
|
+
driver,
|
|
325
|
+
originHostPx,
|
|
326
|
+
deltaCssPx,
|
|
327
|
+
lastViewportPx: viewportPx,
|
|
328
|
+
framesSinceChange: 0,
|
|
329
|
+
moved: false,
|
|
330
|
+
sawIntermediate: false,
|
|
331
|
+
framesAtTarget: 0,
|
|
332
|
+
frame: null
|
|
333
|
+
};
|
|
334
|
+
active.frame = requestAnimationFrame(step);
|
|
335
|
+
};
|
|
336
|
+
const removeListener = addSurfaceResizeBeginListener(element, onSurfaceResizeBegin);
|
|
337
|
+
return { dispose() {
|
|
338
|
+
removeListener();
|
|
339
|
+
settle();
|
|
340
|
+
pin?.dispose();
|
|
341
|
+
} };
|
|
342
|
+
}
|
|
172
343
|
//#endregion
|
|
173
|
-
export { CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR, announceClampedSurfaceResize, createSurfaceHeightReflow };
|
|
344
|
+
export { CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR, CONFIRM_SURFACE_MODE_ATTR, announceClampedSurfaceResize, announceSurfaceResize, attachConfirmSurfaceResizeChoreographer, createSurfaceHeightReflow };
|
|
174
345
|
|
|
175
346
|
//# sourceMappingURL=confirm-surface-resize.js.map
|
|
@@ -7,7 +7,12 @@ function dispatchSurfaceResizeBegin(target, detail) {
|
|
|
7
7
|
detail
|
|
8
8
|
}));
|
|
9
9
|
}
|
|
10
|
+
function addSurfaceResizeBeginListener(target, listener, options) {
|
|
11
|
+
const handler = listener;
|
|
12
|
+
target.addEventListener(SURFACE_RESIZE_BEGIN_EVENT, handler, options);
|
|
13
|
+
return () => target.removeEventListener(SURFACE_RESIZE_BEGIN_EVENT, handler, options);
|
|
14
|
+
}
|
|
10
15
|
//#endregion
|
|
11
|
-
export { dispatchSurfaceResizeBegin };
|
|
16
|
+
export { addSurfaceResizeBeginListener, dispatchSurfaceResizeBegin };
|
|
12
17
|
|
|
13
18
|
//# sourceMappingURL=surface-resize-events.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-BKFyLISf.js`);case`near`:return import(`./runtime-near-Bf-9MFBQ.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DhGEb9U7.js`);case`email_otp`:return import(`./runtime-email-otp-dgsP7XZi.js`);case`recovery`:return import(`./runtime-recovery-BuEzJzuZ.js`);case`export`:return import(`./runtime-export-D2RCm5Gk.js`);case`device_link`:return import(`./runtime-device-link-ENxdEXQW.js`);case`preferences`:return import(`./runtime-preferences-LQ8SPE7o.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};
|
|
1
|
+
import{C as e,S as t}from"./chains-CiYQT1K4.js";import{_ as n,c as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,t as d,v as f}from"./messages-vxz27Way.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y,t as b,u as x}from"./transactionReviewAdmission-C-a3ctCJ.js";import{t as S}from"./events-DsQJQ0Cl.js";import{t as C}from"./walletIframeIdentity-DJ0KOBHg.js";import{t as w}from"./errors-BZO3LF6G.js";function T(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function E(){T(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),D(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&c(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;i()||o(r)}function D(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const O={};let k=null,A=null;function j(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),k):(O[e.kind]??=N(e.kind),O[e.kind])}async function M(){k??=import(`./runtime-recovery-codes-BZMiAR_5.js`),A??=Promise.all([k,import(`./mountRecoveryCodeBackupSurface-B1qhFF6G.js`)]).then(()=>void 0),await A}function N(e){switch(e){case`auth`:return import(`./runtime-auth-DiEJDFkJ.js`);case`near`:return import(`./runtime-near-BxYOozPP.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-C3CRzwph.js`);case`email_otp`:return import(`./runtime-email-otp-DHlirACG.js`);case`recovery`:return import(`./runtime-recovery-DSbvI1DT.js`);case`export`:return import(`./runtime-export-CFy4-Ebn.js`);case`device_link`:return import(`./runtime-device-link-5u31t1H0.js`);case`preferences`:return import(`./runtime-preferences-C1Exkn4E.js`)}return P(e)}function P(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function F(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function I(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function L(e){try{return C(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function R(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(s(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(u(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=L(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:I(r(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return F(e)}function z(e){return e.kind!==`boot`}let B=!1;const V=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function H(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function U(t){return!e(t)||!H(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!H(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function W(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function G(e){try{e.close()}catch{}}function K(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:l,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:d,message:`Wallet iframe protocol version mismatch: expected ${l}, received ${t??`missing`}`,details:n}})}catch{}return G(e),!0}function q(e,t){return!t||t.has(e.kind)}function J(e,t,n,r){e.executionGeneration===t&&n(r)}function Y(e,t,n,r){return e.executionGeneration!==t||n(r)}function X(e={}){if(B)return;B=!0,E(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&M().catch(()=>void 0);let r=new Set,i=new Set,o={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},s=e=>{try{o.port?.postMessage(e)}catch{}},c=e=>{e&&r.add(e)},u=e=>!!e&&(r.has(e)||h(e)?.cancelled===!0),d=e=>{e&&r.delete(e)},C=e=>{e&&s({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},T=e=>!e||!u(e)?!1:h(e)?.cancelled?!0:(C(e),d(e),!0),D=()=>{for(let e of V){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(S.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},O=async r=>{let l=r.data;if(!l||!t(l))return;let S=l.requestId,E=o.executionGeneration,O=J.bind(null,o,E,s),k=null;try{if(`transactionReview`in l){if(l.type!==`PM_SIGN_AND_SEND_TX`&&l.type!==`PM_SIGN_TEMPO`)throw new p(`review_invalid_input`,`Review is unsupported for this request`);let e=m(l.transactionReview);if(e.requestId!==S)throw new p(`review_invalid_input`,`Review request identity mismatch`);let t=l.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new p(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);k=new b(e,l.type===`PM_SIGN_TEMPO`&&l.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>O({type:`TRANSACTION_REVIEW_STATE`,requestId:S,payload:e}),e=>O({type:`ERROR`,requestId:S,payload:{code:e instanceof p?e.code:`cancelled`,message:e.message}}))}(l.type===`PM_LOCK`||l.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&_(new p(`review_identity_changed`,`The wallet session changed`));let t=R(l);if(!z(t))switch(t.type){case`PING`:s({type:`PONG`,requestId:S});return;case`PM_SET_CONFIG`:{let e=a(o.configuration,n(t.request.payload)),r=f(o.configuration.kind===`configured`?o.configuration.config:null)!==f(e.config);if(o.configuration=e,r){o.executionGeneration+=1;for(let e of i)s({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});i.clear()}o.onConfigurationChanged?.(),r&&(_(new p(`review_identity_changed`,`Wallet execution configuration changed`)),D()),s({type:`PONG`,requestId:S});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=y(t.request.payload);e&&h(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=m(r),i=h(t.requestId);if(t.requestId===e&&i&&g(t,i.metadata)){let e=new p(x(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{v(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}s({type:`PONG`,requestId:S});return}let i=e?h(e):void 0;if(i){i.cancel(new p(`cancelled`,`Request cancelled`)),s({type:`PONG`,requestId:S});return}c(e),D(),e&&C(e),s({type:`PONG`,requestId:S});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-D40ih2j-.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!q(t,e.supportedRuntimeRouteKinds)){s({type:`ERROR`,requestId:S,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}S&&i.add(S);let r=await j(t);if(E!==o.executionGeneration)return;await r.handleWalletHostRuntimeRequest({transactionReview:k,state:o,executionGeneration:E,req:t.request,post:J.bind(null,o,E,s),isCancelled:Y.bind(null,o,E,u),respondIfCancelled:Y.bind(null,o,E,T)})}catch(e){if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`||k?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-DEHsPxNm.js`);if(E!==o.executionGeneration&&l.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=w(e),i=t.resolveWalletBoundaryErrorCode({requestType:l.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:l.type,rawCode:n,code:i,message:r}),c=t.resolveWalletBoundarySignerKind(l.type);s({type:`ERROR`,requestId:S,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(l.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&c?{signerKind:c}:{}}})}finally{S&&(i.delete(S),d(S)),k?.finish()}};window.addEventListener(`message`,e=>{let t=U(e.data),n=e.ports[0];if(!(!t||!n||o.port)){if(e.source!==window.parent||!W(e.origin)){G(n);return}if(!K(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(o.parentOrigin=e.origin),o.port=n;try{o.port.onmessage=O,o.port.start?.()}catch{}s({type:`READY`,payload:{protocolVersion:l}})}}})}try{X()}catch(e){console.error(`[WalletHost] init failed`,e)}export{X as t};
|