@dynamic-labs/iframe-setup 4.9.2-preview.0 → 4.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/CHANGELOG.md +28 -1
- package/README.md +41 -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,5 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
### [4.9.
|
|
2
|
+
### [4.9.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.2...v4.9.3) (2025-03-14)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* allow adding extra text to ToS and PP footer using custom css ([#8290](https://github.com/dynamic-labs/dynamic-auth/issues/8290)) ([0f6eb26](https://github.com/dynamic-labs/dynamic-auth/commit/0f6eb2666ea93a32360710ba5ac14eac53e07e2d))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* log out if there is a mismatch in user and wallet state ([#8300](https://github.com/dynamic-labs/dynamic-auth/issues/8300)) ([82ec2ad](https://github.com/dynamic-labs/dynamic-auth/commit/82ec2add1682a576d00dfe13aa1b9cccecf96688))
|
|
13
|
+
* sol sponsored tx for v3 ([#8288](https://github.com/dynamic-labs/dynamic-auth/issues/8288)) ([c466fba](https://github.com/dynamic-labs/dynamic-auth/commit/c466fba417d39641631e29104ec9c156dfdf7647))
|
|
14
|
+
* v3 existing wallet could not log in again ([#8282](https://github.com/dynamic-labs/dynamic-auth/issues/8282)) ([c2d68ad](https://github.com/dynamic-labs/dynamic-auth/commit/c2d68adf575fcce371e438076184ef590f346c9f))
|
|
15
|
+
|
|
16
|
+
### [4.9.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.1...v4.9.2) (2025-03-12)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* **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))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* 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))
|
|
27
|
+
* **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))
|
|
28
|
+
* 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)
|
|
29
|
+
* 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))
|
|
3
30
|
|
|
4
31
|
### [4.9.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1) (2025-03-11)
|
|
5
32
|
|
package/README.md
CHANGED
|
@@ -16,11 +16,19 @@ 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
|
|
24
|
+
import { setupIframe } from '@dynamic-labs/iframe-setup';
|
|
25
|
+
|
|
22
26
|
const iframeURL = new URL('https://iframe.com');
|
|
23
27
|
|
|
28
|
+
if (typeof window !== 'undefined') {
|
|
29
|
+
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
const App = () => {
|
|
25
33
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
26
34
|
|
|
@@ -108,18 +116,11 @@ export const setupIframe = (
|
|
|
108
116
|
iframe: HTMLIFrameElement,
|
|
109
117
|
origin: string,
|
|
110
118
|
): VoidFunction => {
|
|
119
|
+
if (typeof window === 'undefined') return () => {};
|
|
120
|
+
|
|
111
121
|
const messageHandler = createMessageHandler<IFRAME_EVENTS>(window, origin);
|
|
112
122
|
const messageSender = createMessageSender<IFRAME_EVENTS>(iframe);
|
|
113
123
|
|
|
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
124
|
// Add event listener to handle deeplink
|
|
124
125
|
const setupOpenUrlHandler = () =>
|
|
125
126
|
messageHandler('OPEN_URL', ({ url, target = 'self', features }) => {
|
|
@@ -170,8 +171,6 @@ export const setupIframe = (
|
|
|
170
171
|
};
|
|
171
172
|
};
|
|
172
173
|
|
|
173
|
-
applyInitialParentUrlToIframeSrc();
|
|
174
|
-
|
|
175
174
|
// Holds all the cleanup handlers
|
|
176
175
|
const cleanupHandlers: VoidFunction[] = [];
|
|
177
176
|
|
|
@@ -226,3 +225,33 @@ const createMessageSender =
|
|
|
226
225
|
};
|
|
227
226
|
|
|
228
227
|
```
|
|
228
|
+
|
|
229
|
+
Now you can import and use the `setupIframe` function in your iframe application:
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { setupIframe } from './iframe-setup';
|
|
233
|
+
|
|
234
|
+
const iframeURL = new URL('https://iframe.com');
|
|
235
|
+
|
|
236
|
+
if (typeof window !== 'undefined') {
|
|
237
|
+
iframeURL.searchParams.set('initial-parent-url', window.location.href);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const App = () => {
|
|
241
|
+
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
242
|
+
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
const cleanUp = setupIframe(iframeRef.current!, iframeURL.origin);
|
|
245
|
+
|
|
246
|
+
return () => {
|
|
247
|
+
cleanUp();
|
|
248
|
+
};
|
|
249
|
+
}, []);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<div>
|
|
253
|
+
<iframe ref={iframeRef} src={iframeURL.toString()} />
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
```
|
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.3",
|
|
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.3"
|
|
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());
|