@dynamic-labs/iframe-setup 4.91.2 → 4.91.4

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/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
1
 
2
+ ### [4.91.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.3...v4.91.4) (2026-07-01)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * conditionally use /op/ route for AA transactions based on block explorer support ([#11628](https://github.com/dynamic-labs/dynamic-auth/issues/11628)) ([95822dc](https://github.com/dynamic-labs/dynamic-auth/commit/95822dc0edbcd739afe870f0b3881555fdb17eb6))
8
+ * require error codes in all SDK error classes ([#11761](https://github.com/dynamic-labs/dynamic-auth/issues/11761)) ([5744811](https://github.com/dynamic-labs/dynamic-auth/commit/5744811efdd1e415aaf51eec5b3300b323ec1347))
9
+
10
+ ### [4.91.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.2...v4.91.3) (2026-06-30)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **bitcoin:** detect late-registering wallet-standard wallets (DYNT-1210) ([#11747](https://github.com/dynamic-labs/dynamic-auth/issues/11747)) ([17809f6](https://github.com/dynamic-labs/dynamic-auth/commit/17809f6e811fe101367cc31a2d899a8d0b0d107e))
16
+ * fetch onramp providers lazily instead of eagerly on mount ([#11767](https://github.com/dynamic-labs/dynamic-auth/issues/11767)) ([3ee6708](https://github.com/dynamic-labs/dynamic-auth/commit/3ee67087142ae1942f865e0ab37b7108700b3327))
17
+ * **iframe-setup:** sync parent URL to iframe on pushState/replaceState ([#11751](https://github.com/dynamic-labs/dynamic-auth/issues/11751)) ([c8be3af](https://github.com/dynamic-labs/dynamic-auth/commit/c8be3afc301f77b349f23398bed940ce40f93b73))
18
+ * **nonce:** fetch nonce on demand when missing before wallet verification ([#11753](https://github.com/dynamic-labs/dynamic-auth/issues/11753)) ([4f01a21](https://github.com/dynamic-labs/dynamic-auth/commit/4f01a21b6081c852f32868c8a5e04d70aaf280a2)), closes [#1](https://github.com/dynamic-labs/dynamic-auth/issues/1)
19
+ * **react-native-extension:** arm loading timer before setUrl to cover pre-onLoadStart gap ([#11764](https://github.com/dynamic-labs/dynamic-auth/issues/11764)) ([31f2015](https://github.com/dynamic-labs/dynamic-auth/commit/31f20151a4b59279f9c133b723e50de771b06436))
20
+ * **webview-controller:** unwrap ZeroDev smart wallet for native gasless ([#11758](https://github.com/dynamic-labs/dynamic-auth/issues/11758)) ([989714e](https://github.com/dynamic-labs/dynamic-auth/commit/989714e414556868c8e0c54401aac1ed7354331b))
21
+
2
22
  ### [4.91.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.1...v4.91.2) (2026-06-26)
3
23
 
4
24
 
package/README.md CHANGED
@@ -161,16 +161,25 @@ export const setupIframe = (
161
161
 
162
162
  // Watch for url changes and update Dynamic SDK in iframe
163
163
  const setupUrlUpdateHandler = (): VoidFunction => {
164
- const onPopState = () => {
165
- const url = window.location.href;
166
-
167
- messageSender('UPDATE_PARENT_URL', { url });
164
+ const notifyUrlChange = () => {
165
+ try {
166
+ messageSender('UPDATE_PARENT_URL', { url: window.location.href });
167
+ } catch {
168
+ // Never let a notification failure surface to the host application
169
+ // (e.g. an SPA router calling history.pushState)
170
+ }
168
171
  };
169
172
 
170
- window.addEventListener('popstate', onPopState);
173
+ patchHistoryOnce();
174
+
175
+ // popstate fires on browser back/forward navigation; the custom event
176
+ // fires on programmatic pushState/replaceState (which never emit popstate)
177
+ window.addEventListener('popstate', notifyUrlChange);
178
+ window.addEventListener(URL_CHANGE_EVENT, notifyUrlChange);
171
179
 
172
180
  return () => {
173
- window.removeEventListener('popstate', onPopState);
181
+ window.removeEventListener('popstate', notifyUrlChange);
182
+ window.removeEventListener(URL_CHANGE_EVENT, notifyUrlChange);
174
183
  };
175
184
  };
176
185
 
@@ -211,6 +220,44 @@ export const setupIframe = (
211
220
 
212
221
  // Utils
213
222
 
223
+ /**
224
+ * Custom event dispatched when the parent URL changes via the History API.
225
+ * Used instead of re-patching history per setupIframe call so that multiple
226
+ * instances can observe changes without clobbering each other's patches.
227
+ */
228
+ const URL_CHANGE_EVENT = 'dynamic-labs:url-change';
229
+
230
+ const HISTORY_PATCHED_FLAG = '__dynamicLabsHistoryPatched';
231
+
232
+ /**
233
+ * Patch history.pushState/replaceState to emit URL_CHANGE_EVENT.
234
+ *
235
+ * popstate does not fire for programmatic navigation, so we patch the History
236
+ * API to broadcast a custom event instead. The patch is installed only once,
237
+ * retains no references, and is intentionally never restored — it merely
238
+ * dispatches an event, which keeps it safe to leave in place and composable
239
+ * across multiple setupIframe instances.
240
+ */
241
+ const patchHistoryOnce = (): void => {
242
+ const history = window.history as History & Record<string, unknown>;
243
+
244
+ if (history[HISTORY_PATCHED_FLAG]) return;
245
+ history[HISTORY_PATCHED_FLAG] = true;
246
+
247
+ const originalPushState = history.pushState.bind(history);
248
+ const originalReplaceState = history.replaceState.bind(history);
249
+
250
+ history.pushState = (...args: Parameters<History['pushState']>) => {
251
+ originalPushState(...args);
252
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
253
+ };
254
+
255
+ history.replaceState = (...args: Parameters<History['replaceState']>) => {
256
+ originalReplaceState(...args);
257
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
258
+ };
259
+ };
260
+
214
261
  /**
215
262
  * Create a message handler for the iframe
216
263
  */
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.91.2";
6
+ var version = "4.91.4";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.91.2";
2
+ var version = "4.91.4";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/iframe-setup",
3
- "version": "4.91.2",
3
+ "version": "4.91.4",
4
4
  "description": "Collection of utilities to use the Dynamic SDK in an iframe",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/assert-package-version": "4.91.2"
21
+ "@dynamic-labs/assert-package-version": "4.91.4"
22
22
  },
23
23
  "peerDependencies": {}
24
24
  }
@@ -35,13 +35,23 @@ const setupIframe = (iframe, origin) => {
35
35
  });
36
36
  // Watch for url changes and update Dynamic SDK in iframe
37
37
  const setupUrlUpdateHandler = () => {
38
- const onPopState = () => {
39
- const url = window.location.href;
40
- messageSender('UPDATE_PARENT_URL', { url });
38
+ const notifyUrlChange = () => {
39
+ try {
40
+ messageSender('UPDATE_PARENT_URL', { url: window.location.href });
41
+ }
42
+ catch (_a) {
43
+ // Never let a notification failure surface to the host application
44
+ // (e.g. an SPA router calling history.pushState)
45
+ }
41
46
  };
42
- window.addEventListener('popstate', onPopState);
47
+ patchHistoryOnce();
48
+ // popstate fires on browser back/forward navigation; the custom event
49
+ // fires on programmatic pushState/replaceState (which never emit popstate)
50
+ window.addEventListener('popstate', notifyUrlChange);
51
+ window.addEventListener(URL_CHANGE_EVENT, notifyUrlChange);
43
52
  return () => {
44
- window.removeEventListener('popstate', onPopState);
53
+ window.removeEventListener('popstate', notifyUrlChange);
54
+ window.removeEventListener(URL_CHANGE_EVENT, notifyUrlChange);
45
55
  };
46
56
  };
47
57
  /**
@@ -72,6 +82,38 @@ const setupIframe = (iframe, origin) => {
72
82
  return () => cleanupHandlers.forEach((offHandler) => offHandler());
73
83
  };
74
84
  // Utils
85
+ /**
86
+ * Custom event dispatched when the parent URL changes via the History API.
87
+ * Used instead of re-patching history per setupIframe call so that multiple
88
+ * instances can observe changes without clobbering each other's patches.
89
+ */
90
+ const URL_CHANGE_EVENT = 'dynamic-labs:url-change';
91
+ const HISTORY_PATCHED_FLAG = '__dynamicLabsHistoryPatched';
92
+ /**
93
+ * Patch history.pushState/replaceState to emit URL_CHANGE_EVENT.
94
+ *
95
+ * popstate does not fire for programmatic navigation, so we patch the History
96
+ * API to broadcast a custom event instead. The patch is installed only once,
97
+ * retains no references, and is intentionally never restored — it merely
98
+ * dispatches an event, which keeps it safe to leave in place and composable
99
+ * across multiple setupIframe instances.
100
+ */
101
+ const patchHistoryOnce = () => {
102
+ const history = window.history;
103
+ if (history[HISTORY_PATCHED_FLAG])
104
+ return;
105
+ history[HISTORY_PATCHED_FLAG] = true;
106
+ const originalPushState = history.pushState.bind(history);
107
+ const originalReplaceState = history.replaceState.bind(history);
108
+ history.pushState = (...args) => {
109
+ originalPushState(...args);
110
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
111
+ };
112
+ history.replaceState = (...args) => {
113
+ originalReplaceState(...args);
114
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
115
+ };
116
+ };
75
117
  /**
76
118
  * Create a message handler for the iframe
77
119
  */
@@ -31,13 +31,23 @@ const setupIframe = (iframe, origin) => {
31
31
  });
32
32
  // Watch for url changes and update Dynamic SDK in iframe
33
33
  const setupUrlUpdateHandler = () => {
34
- const onPopState = () => {
35
- const url = window.location.href;
36
- messageSender('UPDATE_PARENT_URL', { url });
34
+ const notifyUrlChange = () => {
35
+ try {
36
+ messageSender('UPDATE_PARENT_URL', { url: window.location.href });
37
+ }
38
+ catch (_a) {
39
+ // Never let a notification failure surface to the host application
40
+ // (e.g. an SPA router calling history.pushState)
41
+ }
37
42
  };
38
- window.addEventListener('popstate', onPopState);
43
+ patchHistoryOnce();
44
+ // popstate fires on browser back/forward navigation; the custom event
45
+ // fires on programmatic pushState/replaceState (which never emit popstate)
46
+ window.addEventListener('popstate', notifyUrlChange);
47
+ window.addEventListener(URL_CHANGE_EVENT, notifyUrlChange);
39
48
  return () => {
40
- window.removeEventListener('popstate', onPopState);
49
+ window.removeEventListener('popstate', notifyUrlChange);
50
+ window.removeEventListener(URL_CHANGE_EVENT, notifyUrlChange);
41
51
  };
42
52
  };
43
53
  /**
@@ -68,6 +78,38 @@ const setupIframe = (iframe, origin) => {
68
78
  return () => cleanupHandlers.forEach((offHandler) => offHandler());
69
79
  };
70
80
  // Utils
81
+ /**
82
+ * Custom event dispatched when the parent URL changes via the History API.
83
+ * Used instead of re-patching history per setupIframe call so that multiple
84
+ * instances can observe changes without clobbering each other's patches.
85
+ */
86
+ const URL_CHANGE_EVENT = 'dynamic-labs:url-change';
87
+ const HISTORY_PATCHED_FLAG = '__dynamicLabsHistoryPatched';
88
+ /**
89
+ * Patch history.pushState/replaceState to emit URL_CHANGE_EVENT.
90
+ *
91
+ * popstate does not fire for programmatic navigation, so we patch the History
92
+ * API to broadcast a custom event instead. The patch is installed only once,
93
+ * retains no references, and is intentionally never restored — it merely
94
+ * dispatches an event, which keeps it safe to leave in place and composable
95
+ * across multiple setupIframe instances.
96
+ */
97
+ const patchHistoryOnce = () => {
98
+ const history = window.history;
99
+ if (history[HISTORY_PATCHED_FLAG])
100
+ return;
101
+ history[HISTORY_PATCHED_FLAG] = true;
102
+ const originalPushState = history.pushState.bind(history);
103
+ const originalReplaceState = history.replaceState.bind(history);
104
+ history.pushState = (...args) => {
105
+ originalPushState(...args);
106
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
107
+ };
108
+ history.replaceState = (...args) => {
109
+ originalReplaceState(...args);
110
+ window.dispatchEvent(new Event(URL_CHANGE_EVENT));
111
+ };
112
+ };
71
113
  /**
72
114
  * Create a message handler for the iframe
73
115
  */