@dynamic-labs/react-native-extension 4.77.2 → 4.78.1

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.
Files changed (3) hide show
  1. package/index.cjs +24 -5
  2. package/index.js +24 -5
  3. package/package.json +6 -6
package/index.cjs CHANGED
@@ -34,7 +34,7 @@ function _interopNamespace(e) {
34
34
  return Object.freeze(n);
35
35
  }
36
36
 
37
- var version = "4.77.2";
37
+ var version = "4.78.1";
38
38
 
39
39
  function _extends() {
40
40
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -289,6 +289,19 @@ const assignStartTimeToUrl = url => {
289
289
  };
290
290
 
291
291
  const waasOrigins = ['https://app.dynamic-preprod.xyz', 'https://app.dynamicauth.com'];
292
+ const isNonProductionBuild = () => process.env['NODE_ENV'] !== 'production';
293
+ const isAllowedWaasOrigin = origin => {
294
+ if (waasOrigins.includes(origin)) {
295
+ return true;
296
+ }
297
+ // Dev-only fallback: allow localhost so mobile-demo can load the iframe
298
+ // against a local redcoast stack. Never allowed in production bundles to
299
+ // prevent a malicious app on the device from impersonating the iframe.
300
+ if (isNonProductionBuild() && /^http:\/\/localhost:\d+$/.test(origin)) {
301
+ return true;
302
+ }
303
+ return false;
304
+ };
292
305
  const turnkeyOrigins = ['https://recovery.turnkey.com', 'https://export.turnkey.com'];
293
306
  const WebView = ({
294
307
  webviewUrl: initialWebViewUrl,
@@ -401,15 +414,21 @@ const WebView = ({
401
414
  const requestUrl = getUrl(request.url);
402
415
  // Invalid URL, never navigate to it
403
416
  if (!requestUrl) return false;
404
- // Same origin as the webview, allow navigation
417
+ // Sub-frame (iframe) requests are controlled by the trusted web app
418
+ // content — allow them through without restriction. On iOS,
419
+ // onShouldStartLoadWithRequest fires for iframe navigations too,
420
+ // unlike Android, which is why third-party iframes (e.g. Banxa
421
+ // checkout) would otherwise be blocked only on iOS.
422
+ if (!request.isTopFrame) return true;
423
+ // Same origin as the webview, allow top-level navigation
405
424
  if (webViewUrl.origin === requestUrl.origin) {
406
425
  return true;
407
426
  }
408
- // Allow WAAS iframe to load
409
- if (requestUrl.pathname.startsWith('/waas-v1') && waasOrigins.includes(requestUrl.origin)) {
427
+ // Allow WAAS top-level navigation
428
+ if (requestUrl.pathname.startsWith('/waas-v1') && isAllowedWaasOrigin(requestUrl.origin)) {
410
429
  return true;
411
430
  }
412
- // Allow TurnkeyV1 iframe to load
431
+ // Allow TurnkeyV1 top-level navigation
413
432
  if (turnkeyOrigins.includes(requestUrl.origin)) {
414
433
  return true;
415
434
  }
package/index.js CHANGED
@@ -12,7 +12,7 @@ import { getItemAsync, deleteItemAsync, setItemAsync } from 'expo-secure-store';
12
12
  import { createPasskey, PasskeyStamper } from '@turnkey/react-native-passkey-stamper';
13
13
  import { requireNativeModule } from 'expo-modules-core';
14
14
 
15
- var version = "4.77.2";
15
+ var version = "4.78.1";
16
16
 
17
17
  function _extends() {
18
18
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -267,6 +267,19 @@ const assignStartTimeToUrl = url => {
267
267
  };
268
268
 
269
269
  const waasOrigins = ['https://app.dynamic-preprod.xyz', 'https://app.dynamicauth.com'];
270
+ const isNonProductionBuild = () => process.env['NODE_ENV'] !== 'production';
271
+ const isAllowedWaasOrigin = origin => {
272
+ if (waasOrigins.includes(origin)) {
273
+ return true;
274
+ }
275
+ // Dev-only fallback: allow localhost so mobile-demo can load the iframe
276
+ // against a local redcoast stack. Never allowed in production bundles to
277
+ // prevent a malicious app on the device from impersonating the iframe.
278
+ if (isNonProductionBuild() && /^http:\/\/localhost:\d+$/.test(origin)) {
279
+ return true;
280
+ }
281
+ return false;
282
+ };
270
283
  const turnkeyOrigins = ['https://recovery.turnkey.com', 'https://export.turnkey.com'];
271
284
  const WebView = ({
272
285
  webviewUrl: initialWebViewUrl,
@@ -379,15 +392,21 @@ const WebView = ({
379
392
  const requestUrl = getUrl(request.url);
380
393
  // Invalid URL, never navigate to it
381
394
  if (!requestUrl) return false;
382
- // Same origin as the webview, allow navigation
395
+ // Sub-frame (iframe) requests are controlled by the trusted web app
396
+ // content — allow them through without restriction. On iOS,
397
+ // onShouldStartLoadWithRequest fires for iframe navigations too,
398
+ // unlike Android, which is why third-party iframes (e.g. Banxa
399
+ // checkout) would otherwise be blocked only on iOS.
400
+ if (!request.isTopFrame) return true;
401
+ // Same origin as the webview, allow top-level navigation
383
402
  if (webViewUrl.origin === requestUrl.origin) {
384
403
  return true;
385
404
  }
386
- // Allow WAAS iframe to load
387
- if (requestUrl.pathname.startsWith('/waas-v1') && waasOrigins.includes(requestUrl.origin)) {
405
+ // Allow WAAS top-level navigation
406
+ if (requestUrl.pathname.startsWith('/waas-v1') && isAllowedWaasOrigin(requestUrl.origin)) {
388
407
  return true;
389
408
  }
390
- // Allow TurnkeyV1 iframe to load
409
+ // Allow TurnkeyV1 top-level navigation
391
410
  if (turnkeyOrigins.includes(requestUrl.origin)) {
392
411
  return true;
393
412
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/react-native-extension",
3
- "version": "4.77.2",
3
+ "version": "4.78.1",
4
4
  "main": "./index.cjs",
5
5
  "module": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -18,11 +18,11 @@
18
18
  "@turnkey/react-native-passkey-stamper": "1.2.7",
19
19
  "@react-native-documents/picker": "^11.0.0",
20
20
  "react-native-fs": ">=2.20.0",
21
- "@dynamic-labs/assert-package-version": "4.77.2",
22
- "@dynamic-labs/client": "4.77.2",
23
- "@dynamic-labs/logger": "4.77.2",
24
- "@dynamic-labs/message-transport": "4.77.2",
25
- "@dynamic-labs/webview-messages": "4.77.2"
21
+ "@dynamic-labs/assert-package-version": "4.78.1",
22
+ "@dynamic-labs/client": "4.78.1",
23
+ "@dynamic-labs/logger": "4.78.1",
24
+ "@dynamic-labs/message-transport": "4.78.1",
25
+ "@dynamic-labs/webview-messages": "4.78.1"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=18.0.0 <20.0.0",