@dynamic-labs/iframe-setup 4.9.1 → 4.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.
- package/CHANGELOG.md +15 -0
- package/README.md +9 -12
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +2 -2
- package/src/lib/setupIframe/setupIframe.cjs +2 -7
- package/src/lib/setupIframe/setupIframe.js +2 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.9.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.1...v4.9.2) (2025-03-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **QNTM-2951:** update sdk styles ([#8214](https://github.com/dynamic-labs/dynamic-auth/issues/8214)) ([45cefa8](https://github.com/dynamic-labs/dynamic-auth/commit/45cefa82bdaad769c63ffeab4fb48f88ac855461))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* embedded widget race condition that would show both embedded and non-embedded widgets at the same time ([#8208](https://github.com/dynamic-labs/dynamic-auth/issues/8208)) ([031fb77](https://github.com/dynamic-labs/dynamic-auth/commit/031fb775c10daa383bf56ab7ba5fa4cf6ae9451c))
|
|
13
|
+
* **iframe-setup:** require the initial parent url when using an iframe ([#8268](https://github.com/dynamic-labs/dynamic-auth/issues/8268)) ([258e8a1](https://github.com/dynamic-labs/dynamic-auth/commit/258e8a128c31b8695518f9943bc74de9fce63196))
|
|
14
|
+
* improve WalletConnect experience ([#8201](https://github.com/dynamic-labs/dynamic-auth/issues/8201)) ([a09b16d](https://github.com/dynamic-labs/dynamic-auth/commit/a09b16de2ccd3cbba89f70a8ded4b7656f09f807)), closes [#8202](https://github.com/dynamic-labs/dynamic-auth/issues/8202) [#8207](https://github.com/dynamic-labs/dynamic-auth/issues/8207)
|
|
15
|
+
* prevent closing modal when mfa view is required ([#8156](https://github.com/dynamic-labs/dynamic-auth/issues/8156)) ([c34b245](https://github.com/dynamic-labs/dynamic-auth/commit/c34b24509e3f96046e72150b055d9c820f98706f))
|
|
16
|
+
|
|
2
17
|
### [4.9.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1) (2025-03-11)
|
|
3
18
|
|
|
4
19
|
|
package/README.md
CHANGED
|
@@ -16,11 +16,17 @@ This package provides the setupIframe method thats used to setup the iframe envi
|
|
|
16
16
|
|
|
17
17
|
### Step 1: Parent Page Setup
|
|
18
18
|
|
|
19
|
-
Configure the parent page that will contain the iframe
|
|
19
|
+
Configure the parent page that will contain the iframe.
|
|
20
|
+
|
|
21
|
+
To setup the iframe, you need to pass the parent URL to the iframe using the `initial-parent-url` query parameter
|
|
20
22
|
|
|
21
23
|
```tsx
|
|
22
24
|
const iframeURL = new URL('https://iframe.com');
|
|
23
25
|
|
|
26
|
+
if (typeof window !== 'undefined') {
|
|
27
|
+
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
const App = () => {
|
|
25
31
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
26
32
|
|
|
@@ -108,18 +114,11 @@ export const setupIframe = (
|
|
|
108
114
|
iframe: HTMLIFrameElement,
|
|
109
115
|
origin: string,
|
|
110
116
|
): VoidFunction => {
|
|
117
|
+
if (typeof window === 'undefined') return () => {};
|
|
118
|
+
|
|
111
119
|
const messageHandler = createMessageHandler<IFRAME_EVENTS>(window, origin);
|
|
112
120
|
const messageSender = createMessageSender<IFRAME_EVENTS>(iframe);
|
|
113
121
|
|
|
114
|
-
// Add initial parent url to iframe src
|
|
115
|
-
const applyInitialParentUrlToIframeSrc = () => {
|
|
116
|
-
const iframeURL = new URL(iframe.src);
|
|
117
|
-
|
|
118
|
-
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
119
|
-
|
|
120
|
-
iframe.src = iframeURL.toString();
|
|
121
|
-
};
|
|
122
|
-
|
|
123
122
|
// Add event listener to handle deeplink
|
|
124
123
|
const setupOpenUrlHandler = () =>
|
|
125
124
|
messageHandler('OPEN_URL', ({ url, target = 'self', features }) => {
|
|
@@ -170,8 +169,6 @@ export const setupIframe = (
|
|
|
170
169
|
};
|
|
171
170
|
};
|
|
172
171
|
|
|
173
|
-
applyInitialParentUrlToIframeSrc();
|
|
174
|
-
|
|
175
172
|
// Holds all the cleanup handlers
|
|
176
173
|
const cleanupHandlers: VoidFunction[] = [];
|
|
177
174
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/iframe-setup",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2",
|
|
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.9.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.9.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {}
|
|
24
24
|
}
|
|
@@ -20,14 +20,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
20
20
|
* @returns a function to teardown the iframe setup
|
|
21
21
|
*/
|
|
22
22
|
const setupIframe = (iframe, origin) => {
|
|
23
|
+
if (typeof window === 'undefined')
|
|
24
|
+
return () => { };
|
|
23
25
|
const messageHandler = createMessageHandler(window, origin);
|
|
24
26
|
const messageSender = createMessageSender(iframe);
|
|
25
|
-
// Add initial parent url to iframe src
|
|
26
|
-
const applyInitialParentUrlToIframeSrc = () => {
|
|
27
|
-
const iframeURL = new URL(iframe.src);
|
|
28
|
-
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
29
|
-
iframe.src = iframeURL.toString();
|
|
30
|
-
};
|
|
31
27
|
// Add event listener to handle deeplink
|
|
32
28
|
const setupOpenUrlHandler = () => messageHandler('OPEN_URL', ({ url, target = 'self', features }) => {
|
|
33
29
|
if (target === 'blank') {
|
|
@@ -68,7 +64,6 @@ const setupIframe = (iframe, origin) => {
|
|
|
68
64
|
window.removeEventListener('focus', onVisibilityOrFocus);
|
|
69
65
|
};
|
|
70
66
|
};
|
|
71
|
-
applyInitialParentUrlToIframeSrc();
|
|
72
67
|
// Holds all the cleanup handlers
|
|
73
68
|
const cleanupHandlers = [];
|
|
74
69
|
cleanupHandlers.push(setupUrlUpdateHandler());
|
|
@@ -16,14 +16,10 @@
|
|
|
16
16
|
* @returns a function to teardown the iframe setup
|
|
17
17
|
*/
|
|
18
18
|
const setupIframe = (iframe, origin) => {
|
|
19
|
+
if (typeof window === 'undefined')
|
|
20
|
+
return () => { };
|
|
19
21
|
const messageHandler = createMessageHandler(window, origin);
|
|
20
22
|
const messageSender = createMessageSender(iframe);
|
|
21
|
-
// Add initial parent url to iframe src
|
|
22
|
-
const applyInitialParentUrlToIframeSrc = () => {
|
|
23
|
-
const iframeURL = new URL(iframe.src);
|
|
24
|
-
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
25
|
-
iframe.src = iframeURL.toString();
|
|
26
|
-
};
|
|
27
23
|
// Add event listener to handle deeplink
|
|
28
24
|
const setupOpenUrlHandler = () => messageHandler('OPEN_URL', ({ url, target = 'self', features }) => {
|
|
29
25
|
if (target === 'blank') {
|
|
@@ -64,7 +60,6 @@ const setupIframe = (iframe, origin) => {
|
|
|
64
60
|
window.removeEventListener('focus', onVisibilityOrFocus);
|
|
65
61
|
};
|
|
66
62
|
};
|
|
67
|
-
applyInitialParentUrlToIframeSrc();
|
|
68
63
|
// Holds all the cleanup handlers
|
|
69
64
|
const cleanupHandlers = [];
|
|
70
65
|
cleanupHandlers.push(setupUrlUpdateHandler());
|