@dynamic-labs-wallet/browser-wallet-client 1.0.32 → 1.0.34

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/index.cjs CHANGED
@@ -446,6 +446,76 @@ const createIframeWaasSDKContainer = ()=>{
446
446
  };
447
447
  };
448
448
 
449
+ /**
450
+ * Resolve the wallet iframe domain from the API base URL: the
451
+ * environment-mapped Dynamic domain, or `baseApiUrl` itself in cookie auth
452
+ * mode (customer custom domains). Single source of truth shared by the
453
+ * IframeManager constructor and the public preconnect helper.
454
+ */ const resolveIframeDomain = ({ baseApiUrl, authMode })=>{
455
+ if (authMode === core.AuthMode.COOKIE) {
456
+ return baseApiUrl;
457
+ }
458
+ var _IFRAME_DOMAIN_MAP_getEnvironmentFromUrl;
459
+ return (_IFRAME_DOMAIN_MAP_getEnvironmentFromUrl = core.IFRAME_DOMAIN_MAP[core.getEnvironmentFromUrl(baseApiUrl)]) != null ? _IFRAME_DOMAIN_MAP_getEnvironmentFromUrl : null;
460
+ };
461
+
462
+ /**
463
+ * Warm the browser's connection to the iframe origin (DNS + TCP + TLS) by
464
+ * injecting `<link rel="preconnect">` (plus a `<link rel="dns-prefetch">`
465
+ * fallback) into the host document head, so a later iframe document fetch
466
+ * starts on a hot connection instead of paying connection-setup RTT inside
467
+ * the iframe load timeout window.
468
+ *
469
+ * Re-warms on every call: browsers drop unused preconnected sockets after
470
+ * ~10s and never re-process a link already in the DOM, so the links are
471
+ * replaced rather than skipped. No-op outside the DOM (React Native / SSR).
472
+ * The preconnect deliberately omits `crossorigin`: the iframe navigation and
473
+ * its same-origin subresources are credentialed fetches, which reuse the
474
+ * non-CORS connection a plain preconnect opens.
475
+ */ const preconnectIframeOrigin = (iframeUrl)=>{
476
+ var _document_getElementById, _document_getElementById1;
477
+ if (typeof document === 'undefined' || !document.head) return;
478
+ let origin;
479
+ try {
480
+ origin = new URL(iframeUrl).origin;
481
+ } catch (e) {
482
+ return;
483
+ }
484
+ const preconnectId = `dynamic-waas-preconnect-${origin}`;
485
+ const dnsPrefetchId = `dynamic-waas-dns-prefetch-${origin}`;
486
+ (_document_getElementById = document.getElementById(preconnectId)) == null ? void 0 : _document_getElementById.remove();
487
+ (_document_getElementById1 = document.getElementById(dnsPrefetchId)) == null ? void 0 : _document_getElementById1.remove();
488
+ const preconnect = document.createElement('link');
489
+ preconnect.id = preconnectId;
490
+ preconnect.rel = 'preconnect';
491
+ preconnect.href = origin;
492
+ document.head.appendChild(preconnect);
493
+ const dnsPrefetch = document.createElement('link');
494
+ dnsPrefetch.id = dnsPrefetchId;
495
+ dnsPrefetch.rel = 'dns-prefetch';
496
+ dnsPrefetch.href = origin;
497
+ document.head.appendChild(dnsPrefetch);
498
+ };
499
+ /**
500
+ * Public warmup entry point for host SDKs. Resolves the wallet iframe domain
501
+ * from the same inputs the wallet client constructor uses and preconnects to
502
+ * it.
503
+ *
504
+ * Call this when an embedded-wallet auth flow STARTS (email submitted, OTP
505
+ * verification begins) — not at wallet client construction, which happens
506
+ * milliseconds before the iframe mounts and leaves the warmup no runway.
507
+ * Safe to call repeatedly; each call re-warms the connection, which matters
508
+ * because an unused preconnect goes cold after ~10s.
509
+ */ const preconnectWaasIframe = ({ baseApiUrl, authMode = core.AuthMode.HEADER })=>{
510
+ const iframeDomain = resolveIframeDomain({
511
+ baseApiUrl,
512
+ authMode
513
+ });
514
+ if (iframeDomain) {
515
+ preconnectIframeOrigin(iframeDomain);
516
+ }
517
+ };
518
+
449
519
  const FRAME_ANCESTORS_QUERY_PARAM = 'frameAncestors';
450
520
  /**
451
521
  * Builds the iframe message transport with the recovery + block decorators.
@@ -1284,10 +1354,15 @@ class IframeManager {
1284
1354
  var _internalOptions_createWaasSDKContainer;
1285
1355
  this.createWaasSDKContainer = (_internalOptions_createWaasSDKContainer = internalOptions == null ? void 0 : internalOptions.createWaasSDKContainer) != null ? _internalOptions_createWaasSDKContainer : createIframeWaasSDKContainer;
1286
1356
  this.onUnauthorized = internalOptions == null ? void 0 : internalOptions.onUnauthorized;
1287
- const environment = core.getEnvironmentFromUrl(baseApiUrl);
1288
- this.iframeDomain = core.IFRAME_DOMAIN_MAP[environment];
1289
- if (this.authMode === core.AuthMode.COOKIE) {
1290
- this.iframeDomain = this.baseApiUrl;
1357
+ this.iframeDomain = resolveIframeDomain({
1358
+ baseApiUrl,
1359
+ authMode: this.authMode
1360
+ });
1361
+ // Fallback warmup: only saves connection setup when the host constructs
1362
+ // the client ahead of use. Hosts should call `preconnectWaasIframe` at
1363
+ // auth-flow start for real runway. No-op on React Native.
1364
+ if (this.iframeDomain) {
1365
+ preconnectIframeOrigin(this.iframeDomain);
1291
1366
  }
1292
1367
  // Generate unique instanceId when client is created
1293
1368
  this.instanceId = crypto.randomUUID();
@@ -1805,3 +1880,4 @@ Object.defineProperty(exports, "WalletOperation", {
1805
1880
  });
1806
1881
  exports.DynamicWalletClient = DynamicWalletClient;
1807
1882
  exports.createIframeWaasSDKContainer = createIframeWaasSDKContainer;
1883
+ exports.preconnectWaasIframe = preconnectWaasIframe;
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthMode, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP, WalletOperation } from '@dynamic-labs-wallet/core';
1
+ import { AuthMode, IFRAME_DOMAIN_MAP, getEnvironmentFromUrl, WalletOperation } from '@dynamic-labs-wallet/core';
2
2
  export { AuthMode, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, ThresholdSignatureScheme, WalletOperation } from '@dynamic-labs-wallet/core';
3
3
  import { createRequestChannel, parseMessageTransportData, applyDefaultMessageOrigin, createMessageTransport, applyRecoveryManager, makeWaitForUnblock } from '@dynamic-labs/message-transport';
4
4
  import { Logger } from '@dynamic-labs/logger';
@@ -445,6 +445,76 @@ const createIframeWaasSDKContainer = ()=>{
445
445
  };
446
446
  };
447
447
 
448
+ /**
449
+ * Resolve the wallet iframe domain from the API base URL: the
450
+ * environment-mapped Dynamic domain, or `baseApiUrl` itself in cookie auth
451
+ * mode (customer custom domains). Single source of truth shared by the
452
+ * IframeManager constructor and the public preconnect helper.
453
+ */ const resolveIframeDomain = ({ baseApiUrl, authMode })=>{
454
+ if (authMode === AuthMode.COOKIE) {
455
+ return baseApiUrl;
456
+ }
457
+ var _IFRAME_DOMAIN_MAP_getEnvironmentFromUrl;
458
+ return (_IFRAME_DOMAIN_MAP_getEnvironmentFromUrl = IFRAME_DOMAIN_MAP[getEnvironmentFromUrl(baseApiUrl)]) != null ? _IFRAME_DOMAIN_MAP_getEnvironmentFromUrl : null;
459
+ };
460
+
461
+ /**
462
+ * Warm the browser's connection to the iframe origin (DNS + TCP + TLS) by
463
+ * injecting `<link rel="preconnect">` (plus a `<link rel="dns-prefetch">`
464
+ * fallback) into the host document head, so a later iframe document fetch
465
+ * starts on a hot connection instead of paying connection-setup RTT inside
466
+ * the iframe load timeout window.
467
+ *
468
+ * Re-warms on every call: browsers drop unused preconnected sockets after
469
+ * ~10s and never re-process a link already in the DOM, so the links are
470
+ * replaced rather than skipped. No-op outside the DOM (React Native / SSR).
471
+ * The preconnect deliberately omits `crossorigin`: the iframe navigation and
472
+ * its same-origin subresources are credentialed fetches, which reuse the
473
+ * non-CORS connection a plain preconnect opens.
474
+ */ const preconnectIframeOrigin = (iframeUrl)=>{
475
+ var _document_getElementById, _document_getElementById1;
476
+ if (typeof document === 'undefined' || !document.head) return;
477
+ let origin;
478
+ try {
479
+ origin = new URL(iframeUrl).origin;
480
+ } catch (e) {
481
+ return;
482
+ }
483
+ const preconnectId = `dynamic-waas-preconnect-${origin}`;
484
+ const dnsPrefetchId = `dynamic-waas-dns-prefetch-${origin}`;
485
+ (_document_getElementById = document.getElementById(preconnectId)) == null ? void 0 : _document_getElementById.remove();
486
+ (_document_getElementById1 = document.getElementById(dnsPrefetchId)) == null ? void 0 : _document_getElementById1.remove();
487
+ const preconnect = document.createElement('link');
488
+ preconnect.id = preconnectId;
489
+ preconnect.rel = 'preconnect';
490
+ preconnect.href = origin;
491
+ document.head.appendChild(preconnect);
492
+ const dnsPrefetch = document.createElement('link');
493
+ dnsPrefetch.id = dnsPrefetchId;
494
+ dnsPrefetch.rel = 'dns-prefetch';
495
+ dnsPrefetch.href = origin;
496
+ document.head.appendChild(dnsPrefetch);
497
+ };
498
+ /**
499
+ * Public warmup entry point for host SDKs. Resolves the wallet iframe domain
500
+ * from the same inputs the wallet client constructor uses and preconnects to
501
+ * it.
502
+ *
503
+ * Call this when an embedded-wallet auth flow STARTS (email submitted, OTP
504
+ * verification begins) — not at wallet client construction, which happens
505
+ * milliseconds before the iframe mounts and leaves the warmup no runway.
506
+ * Safe to call repeatedly; each call re-warms the connection, which matters
507
+ * because an unused preconnect goes cold after ~10s.
508
+ */ const preconnectWaasIframe = ({ baseApiUrl, authMode = AuthMode.HEADER })=>{
509
+ const iframeDomain = resolveIframeDomain({
510
+ baseApiUrl,
511
+ authMode
512
+ });
513
+ if (iframeDomain) {
514
+ preconnectIframeOrigin(iframeDomain);
515
+ }
516
+ };
517
+
448
518
  const FRAME_ANCESTORS_QUERY_PARAM = 'frameAncestors';
449
519
  /**
450
520
  * Builds the iframe message transport with the recovery + block decorators.
@@ -1283,10 +1353,15 @@ class IframeManager {
1283
1353
  var _internalOptions_createWaasSDKContainer;
1284
1354
  this.createWaasSDKContainer = (_internalOptions_createWaasSDKContainer = internalOptions == null ? void 0 : internalOptions.createWaasSDKContainer) != null ? _internalOptions_createWaasSDKContainer : createIframeWaasSDKContainer;
1285
1355
  this.onUnauthorized = internalOptions == null ? void 0 : internalOptions.onUnauthorized;
1286
- const environment = getEnvironmentFromUrl(baseApiUrl);
1287
- this.iframeDomain = IFRAME_DOMAIN_MAP[environment];
1288
- if (this.authMode === AuthMode.COOKIE) {
1289
- this.iframeDomain = this.baseApiUrl;
1356
+ this.iframeDomain = resolveIframeDomain({
1357
+ baseApiUrl,
1358
+ authMode: this.authMode
1359
+ });
1360
+ // Fallback warmup: only saves connection setup when the host constructs
1361
+ // the client ahead of use. Hosts should call `preconnectWaasIframe` at
1362
+ // auth-flow start for real runway. No-op on React Native.
1363
+ if (this.iframeDomain) {
1364
+ preconnectIframeOrigin(this.iframeDomain);
1290
1365
  }
1291
1366
  // Generate unique instanceId when client is created
1292
1367
  this.instanceId = crypto.randomUUID();
@@ -1782,4 +1857,4 @@ class DynamicWalletClient extends IframeManager {
1782
1857
  }
1783
1858
  }
1784
1859
 
1785
- export { DynamicWalletClient, createIframeWaasSDKContainer };
1860
+ export { DynamicWalletClient, createIframeWaasSDKContainer, preconnectWaasIframe };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/browser-wallet-client",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/core": "1.0.32",
7
+ "@dynamic-labs-wallet/core": "1.0.34",
8
8
  "@dynamic-labs/logger": "^4.45.2",
9
9
  "@dynamic-labs/message-transport": "^4.45.2"
10
10
  },
@@ -1 +1 @@
1
- {"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../../src/client/iframeManager/IframeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,KAAK,sBAAsB,EAK3B,KAAK,qBAAqB,EAG1B,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAOL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAqC9E,qBAAa,aAAa;IACxB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,wCAAU;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,aAAa,EAAE,MAAM,CAAC;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allet iframe domain from the API base URL: the
4
+ * environment-mapped Dynamic domain, or `baseApiUrl` itself in cookie auth
5
+ * mode (customer custom domains). Single source of truth shared by the
6
+ * IframeManager constructor and the public preconnect helper.
7
+ */
8
+ export declare const resolveIframeDomain: ({ baseApiUrl, authMode, }: {
9
+ baseApiUrl: string;
10
+ authMode: AuthMode;
11
+ }) => string | null;
12
+ //# sourceMappingURL=resolveIframeDomain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveIframeDomain.d.ts","sourceRoot":"","sources":["../../../src/client/iframeManager/resolveIframeDomain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA4C,MAAM,2BAA2B,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,8BAG7B;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,KAAG,MAAM,GAAG,IAKZ,CAAC"}
package/src/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, ThresholdSignatureSc
2
2
  export type { BitcoinAddressType, BitcoinConfig, BitcoinNetwork, CreateWaasSDKContainer, GetWalletResponse, WaasSDKContainer, WalletRecoveryState, } from '@dynamic-labs-wallet/core';
3
3
  export * from './client/index.js';
4
4
  export { createIframeWaasSDKContainer } from './services/createIframeWaasSDKContainer.js';
5
+ export { preconnectWaasIframe } from './services/preconnectIframeOrigin.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { AuthMode } from '@dynamic-labs-wallet/core';
2
+ /**
3
+ * Warm the browser's connection to the iframe origin (DNS + TCP + TLS) by
4
+ * injecting `<link rel="preconnect">` (plus a `<link rel="dns-prefetch">`
5
+ * fallback) into the host document head, so a later iframe document fetch
6
+ * starts on a hot connection instead of paying connection-setup RTT inside
7
+ * the iframe load timeout window.
8
+ *
9
+ * Re-warms on every call: browsers drop unused preconnected sockets after
10
+ * ~10s and never re-process a link already in the DOM, so the links are
11
+ * replaced rather than skipped. No-op outside the DOM (React Native / SSR).
12
+ * The preconnect deliberately omits `crossorigin`: the iframe navigation and
13
+ * its same-origin subresources are credentialed fetches, which reuse the
14
+ * non-CORS connection a plain preconnect opens.
15
+ */
16
+ export declare const preconnectIframeOrigin: (iframeUrl: string) => void;
17
+ /**
18
+ * Public warmup entry point for host SDKs. Resolves the wallet iframe domain
19
+ * from the same inputs the wallet client constructor uses and preconnects to
20
+ * it.
21
+ *
22
+ * Call this when an embedded-wallet auth flow STARTS (email submitted, OTP
23
+ * verification begins) — not at wallet client construction, which happens
24
+ * milliseconds before the iframe mounts and leaves the warmup no runway.
25
+ * Safe to call repeatedly; each call re-warms the connection, which matters
26
+ * because an unused preconnect goes cold after ~10s.
27
+ */
28
+ export declare const preconnectWaasIframe: ({ baseApiUrl, authMode, }: {
29
+ baseApiUrl: string;
30
+ authMode?: AuthMode;
31
+ }) => void;
32
+ //# sourceMappingURL=preconnectIframeOrigin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preconnectIframeOrigin.d.ts","sourceRoot":"","sources":["../../src/services/preconnectIframeOrigin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,cAAe,MAAM,KAAG,IA0B1D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,8BAG9B;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,KAAG,IAKH,CAAC"}