@xrpl-wallet-kit/browser 0.1.8 → 0.1.10
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/dist/xrpl-wallet-kit.iife.js +52 -10
- package/dist/xrpl-wallet-kit.iife.min.js +45 -45
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @xrpl-wallet-kit/browser v0.1.
|
|
1
|
+
/*! @xrpl-wallet-kit/browser v0.1.10 | MIT | https://github.com/XRPDomains/xrpl-wallet-kit */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __typeError = (msg) => {
|
|
4
4
|
throw TypeError(msg);
|
|
@@ -2431,6 +2431,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2431
2431
|
const SESSION_KEY = "session";
|
|
2432
2432
|
const WALLET_STORAGE_VERSION = 1;
|
|
2433
2433
|
const RECOVER_SESSION_RETRY_DELAYS_MS = [0, 700, 1600, 3e3];
|
|
2434
|
+
const DEFAULT_AUTO_RECONNECT_RESTORE_TIMEOUT_MS = 3e3;
|
|
2435
|
+
const DEFAULT_PENDING_RETURN_RECOVERY_TIMEOUT_MS = 1e4;
|
|
2434
2436
|
const DEFAULT_ACCOUNT_STATUS_TIMEOUT_MS = 2500;
|
|
2435
2437
|
const DEFAULT_AUTHENTICATE_EXPIRES_IN_SECONDS = 3600;
|
|
2436
2438
|
const DEFAULT_TX_CONFIRMATION_ATTEMPTS = 6;
|
|
@@ -2543,9 +2545,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2543
2545
|
}
|
|
2544
2546
|
try {
|
|
2545
2547
|
if (adapter.restoreSession) {
|
|
2546
|
-
const
|
|
2548
|
+
const restoredResult = await this.withTimeout(adapter.restoreSession(session), DEFAULT_AUTO_RECONNECT_RESTORE_TIMEOUT_MS);
|
|
2549
|
+
if (restoredResult.timedOut) {
|
|
2550
|
+
await this.clearStoredSessionAsStale(session, "restore_timeout");
|
|
2551
|
+
return null;
|
|
2552
|
+
}
|
|
2553
|
+
const restored = restoredResult.value;
|
|
2547
2554
|
if (!(restored == null ? void 0 : restored.session)) {
|
|
2548
|
-
this.
|
|
2555
|
+
await this.clearStoredSessionAsStale(session, "restore_unavailable");
|
|
2549
2556
|
return null;
|
|
2550
2557
|
}
|
|
2551
2558
|
const enrichedSession2 = await this.enrichSession(this.withWalletMetadata(restored.session, adapter));
|
|
@@ -2555,8 +2562,19 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2555
2562
|
this.emit("connected", { adapterId: enrichedSession2.adapterId, account: enrichedSession2.account, session: enrichedSession2 });
|
|
2556
2563
|
return enrichedSession2;
|
|
2557
2564
|
}
|
|
2558
|
-
if (adapter.isAvailable
|
|
2559
|
-
|
|
2565
|
+
if (adapter.isAvailable) {
|
|
2566
|
+
const availability = await this.withTimeout(Promise.resolve(adapter.isAvailable()), DEFAULT_AUTO_RECONNECT_RESTORE_TIMEOUT_MS);
|
|
2567
|
+
if (availability.timedOut) {
|
|
2568
|
+
await this.clearStoredSessionAsStale(session, "availability_timeout");
|
|
2569
|
+
return null;
|
|
2570
|
+
}
|
|
2571
|
+
if (!availability.value) {
|
|
2572
|
+
await this.clearStoredSessionAsStale(session, "adapter_unavailable");
|
|
2573
|
+
return null;
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
if (session.expiresAt && session.expiresAt <= Date.now()) {
|
|
2577
|
+
await this.clearStoredSessionAsStale(session, "session_expired");
|
|
2560
2578
|
return null;
|
|
2561
2579
|
}
|
|
2562
2580
|
const enrichedSession = await this.enrichSession(this.withWalletMetadata(session, adapter));
|
|
@@ -2590,16 +2608,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2590
2608
|
return null;
|
|
2591
2609
|
const announcedAdapters = /* @__PURE__ */ new Set();
|
|
2592
2610
|
const recoveryRetryDelaysMs = this.config.recoveryRetryDelaysMs ?? RECOVER_SESSION_RETRY_DELAYS_MS;
|
|
2611
|
+
const recoveryDeadline = Date.now() + DEFAULT_PENDING_RETURN_RECOVERY_TIMEOUT_MS;
|
|
2612
|
+
let timedOut = false;
|
|
2593
2613
|
for (const delayMs of recoveryRetryDelaysMs) {
|
|
2614
|
+
const remainingBeforeDelay = recoveryDeadline - Date.now();
|
|
2615
|
+
if (remainingBeforeDelay <= 0) {
|
|
2616
|
+
timedOut = true;
|
|
2617
|
+
break;
|
|
2618
|
+
}
|
|
2594
2619
|
if (delayMs > 0)
|
|
2595
|
-
await this.delay(delayMs);
|
|
2620
|
+
await this.delay(Math.min(delayMs, remainingBeforeDelay));
|
|
2596
2621
|
for (const adapter of recoverableAdapters) {
|
|
2622
|
+
const remaining = recoveryDeadline - Date.now();
|
|
2623
|
+
if (remaining <= 0) {
|
|
2624
|
+
timedOut = true;
|
|
2625
|
+
break;
|
|
2626
|
+
}
|
|
2597
2627
|
try {
|
|
2598
2628
|
if (!announcedAdapters.has(adapter.metadata.id)) {
|
|
2599
2629
|
announcedAdapters.add(adapter.metadata.id);
|
|
2600
2630
|
this.emit("connecting", { adapterId: adapter.metadata.id, recovering: true });
|
|
2601
2631
|
}
|
|
2602
|
-
const
|
|
2632
|
+
const recovery = await this.withTimeout((_a2 = adapter.recoverSession) == null ? void 0 : _a2.call(adapter, { network, walletId: adapter.metadata.id }), remaining);
|
|
2633
|
+
if (recovery.timedOut) {
|
|
2634
|
+
timedOut = true;
|
|
2635
|
+
this.logger.warn(`Session recovery timed out for ${adapter.metadata.id}`);
|
|
2636
|
+
break;
|
|
2637
|
+
}
|
|
2638
|
+
const recovered = recovery.value;
|
|
2603
2639
|
if (!(recovered == null ? void 0 : recovered.session))
|
|
2604
2640
|
continue;
|
|
2605
2641
|
const enrichedSession = await this.enrichSession(this.withWalletMetadata(recovered.session, adapter));
|
|
@@ -2613,14 +2649,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2613
2649
|
this.logger.warn(`Session recovery failed for ${adapter.metadata.id}`, error);
|
|
2614
2650
|
}
|
|
2615
2651
|
}
|
|
2652
|
+
if (timedOut)
|
|
2653
|
+
break;
|
|
2616
2654
|
}
|
|
2617
2655
|
recoverableAdapters.forEach((adapter) => {
|
|
2618
2656
|
var _a3;
|
|
2619
|
-
this.emit("session_stale", { adapterId: adapter.metadata.id, reason: "recover_unavailable", attempts: recoveryRetryDelaysMs.length });
|
|
2657
|
+
this.emit("session_stale", { adapterId: adapter.metadata.id, reason: timedOut ? "recover_timeout" : "recover_unavailable", attempts: recoveryRetryDelaysMs.length });
|
|
2620
2658
|
void ((_a3 = adapter.cancelPendingConnection) == null ? void 0 : _a3.call(adapter));
|
|
2621
2659
|
});
|
|
2622
2660
|
return null;
|
|
2623
2661
|
}
|
|
2662
|
+
async clearStoredSessionAsStale(session, reason) {
|
|
2663
|
+
await this.storage.removeItem(SESSION_KEY);
|
|
2664
|
+
this.emit("session_stale", { adapterId: session.adapterId, account: session.account, session, reason });
|
|
2665
|
+
}
|
|
2624
2666
|
delay(ms2) {
|
|
2625
2667
|
return new Promise((resolve) => setTimeout(resolve, ms2));
|
|
2626
2668
|
}
|
|
@@ -20587,7 +20629,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20587
20629
|
this.bindChrome();
|
|
20588
20630
|
}
|
|
20589
20631
|
renderQrLoading() {
|
|
20590
|
-
return `<span class="xwk-qr-loading xwk-qr-loading-skeleton" role="status" aria-live="polite"><span class="xwk-skeleton
|
|
20632
|
+
return `<span class="xwk-qr-loading xwk-qr-loading-skeleton" role="status" aria-live="polite"><span class="xwk-skeleton-qr xwk-qr-skeleton" aria-hidden="true"></span><span class="xwk-sr-only">${this.escapeHtml(this.messages().generatingQr)}</span></span>`;
|
|
20591
20633
|
}
|
|
20592
20634
|
renderQrCopyButtonContent() {
|
|
20593
20635
|
const messages = this.messages();
|
|
@@ -20667,7 +20709,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20667
20709
|
}
|
|
20668
20710
|
renderMobileSheetOverrides(theme) {
|
|
20669
20711
|
const inlineOverrides = `.xwk-inline{background:transparent!important;display:block!important;inset:auto!important;opacity:1!important;overflow:visible!important;padding:0!important;place-items:initial!important;position:relative!important;z-index:auto!important}.xwk-inline .xwk-modal{border:1px solid ${theme.border}!important;border-radius:${theme.radius}!important;box-shadow:none!important;max-height:none!important;max-width:none!important;opacity:1!important;transform:none!important;transition:none!important;width:100%!important}.xwk-inline .xwk-body{max-height:none!important}.xwk-inline .xwk-header-spacer{display:block;height:44px;width:44px}.xwk-inline[data-xwk-state="closing"] .xwk-modal{opacity:1!important;transform:none!important}`;
|
|
20670
|
-
const skeletonOverrides = `.xwk-skeleton{animation:xwk-qr-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;display:inline-block}.xwk-skeleton-circle{border-radius:999px}.xwk-skeleton-line{height:14px;border-radius:4px}.xwk-skeleton-pill{border-radius:999px}.xwk-skeleton-card,.xwk-skeleton-button{border-radius:${theme.walletRadius}}.xwk-skeleton-row{align-items:center;display:flex;gap:12px;width:100%}.xwk-qr-loading-skeleton{display:grid;height:100%;place-items:
|
|
20712
|
+
const skeletonOverrides = `.xwk-skeleton{animation:xwk-qr-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;display:inline-block}.xwk-skeleton-circle{border-radius:999px}.xwk-skeleton-line{height:14px;border-radius:4px}.xwk-skeleton-pill{border-radius:999px}.xwk-skeleton-card,.xwk-skeleton-button{border-radius:${theme.walletRadius}}.xwk-skeleton-row{align-items:center;display:flex;gap:12px;width:100%}.xwk-qr-loading-skeleton{display:grid;height:100%;place-items:stretch;width:100%}.xwk-qr-skeleton{border-radius:10px;box-sizing:border-box;display:block;height:100%;overflow:hidden;position:relative;width:100%}.xwk-qr-skeleton:before{background-image:radial-gradient(circle,${theme.muted} 0 2px,transparent 2.8px);background-size:14px 14px;content:"";inset:0;opacity:.22;position:absolute}.xwk-qr-skeleton:after{animation:xwk-qr-shimmer 1.35s ease-in-out infinite;background:linear-gradient(90deg,transparent 0%,${theme.surfaceHover} 42%,rgba(255,255,255,.34) 50%,${theme.surfaceHover} 58%,transparent 100%);content:"";inset:0;opacity:.52;position:absolute;transform:translateX(-115%);will-change:transform}.xwk-wallet-badge-loading{color:transparent;min-width:72px;visibility:visible}.xwk-wallet-badge-loading:before{display:none}@keyframes xwk-qr-skeleton-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}@keyframes xwk-qr-shimmer{0%{transform:translateX(-115%)}100%{transform:translateX(115%)}}@media(prefers-reduced-motion:reduce){.xwk-skeleton,.xwk-qr-skeleton,.xwk-qr-skeleton:after{animation:none!important}.xwk-skeleton,.xwk-qr-skeleton{background:${theme.surfaceHover}!important}.xwk-qr-skeleton:after{display:none!important}}`;
|
|
20671
20713
|
return `${skeletonOverrides}.xwk-modal:focus{outline:none}.xwk-sr-only{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}.xwk-error-text,.xwk-connect-status.xwk-error-text,.xwk-qr-loading.xwk-error-text{color:${theme.error}!important}.xwk-close,.xwk-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;appearance:none;background:transparent!important;border:0!important;box-shadow:none!important;margin:0;outline:none!important}.xwk-close:focus-visible,.xwk-back:focus-visible{outline:2px solid ${theme.accent}!important;outline-offset:0}@media(max-width:640px){.xwk-overlay{padding:max(12px,env(safe-area-inset-top)) 0 0!important;place-items:end center!important}.xwk-modal{align-self:end!important;border-bottom:0!important;border-bottom-left-radius:0!important;border-bottom-right-radius:0!important;border-left:0!important;border-right:0!important;border-top-left-radius:${theme.radius}!important;border-top-right-radius:${theme.radius}!important;height:auto!important;max-height:calc(100dvh - env(safe-area-inset-top))!important;max-width:none!important;width:100vw!important}.xwk-header{border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius}}.xwk-body{padding-bottom:max(6px,calc(6px + env(safe-area-inset-bottom)))!important}.xwk-overlay[data-xwk-view="list"] .xwk-body{padding-bottom:max(2px,calc(2px + env(safe-area-inset-bottom)))!important}.xwk-network-row{margin:-4px 0 8px!important}.xwk-overlay[data-xwk-view="list"] .xwk-footer{padding-top:6px!important}}${inlineOverrides}`;
|
|
20672
20714
|
}
|
|
20673
20715
|
renderWalletList(layout) {
|