@moonpay/platform-sdk-react-native 1.16.0 → 1.17.0

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/dist/index.js CHANGED
@@ -462,7 +462,13 @@ import { useEffect, useRef } from "react";
462
462
  import { View } from "react-native";
463
463
  import WebView from "react-native-webview";
464
464
  import { jsx } from "react/jsx-runtime";
465
- function MoonPayFrame({ transport, hidden, style }) {
465
+ var DEFAULT_ORIGIN_WHITELIST = ["https://*", "http://*", "about:srcdoc"];
466
+ function MoonPayFrame({
467
+ transport,
468
+ hidden,
469
+ style,
470
+ webViewProps
471
+ }) {
466
472
  const webViewRef = useRef(null);
467
473
  useEffect(() => {
468
474
  transport.attachWebView(webViewRef);
@@ -478,13 +484,15 @@ function MoonPayFrame({ transport, hidden, style }) {
478
484
  return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(
479
485
  WebView,
480
486
  {
481
- ref: webViewRef,
482
- source: { uri: url },
483
- onMessage: handleMessage,
487
+ originWhitelist: DEFAULT_ORIGIN_WHITELIST,
484
488
  allowsInlineMediaPlayback: true,
485
489
  javaScriptEnabled: true,
486
490
  domStorageEnabled: true,
487
- style: { flex: 1 }
491
+ style: { flex: 1 },
492
+ ...webViewProps,
493
+ ref: webViewRef,
494
+ source: { uri: url },
495
+ onMessage: handleMessage
488
496
  }
489
497
  ) });
490
498
  }
@@ -494,7 +502,8 @@ import {
494
502
  applyThemeParam,
495
503
  buildFrameUrl,
496
504
  createFrameOrchestrator,
497
- generateKeyPair
505
+ generateKeyPair,
506
+ isSecureRandomAvailable
498
507
  } from "@moonpay/platform-sdk-core";
499
508
 
500
509
  // src/webview-transport.ts
@@ -557,6 +566,7 @@ var WebViewTransport = class {
557
566
  };
558
567
 
559
568
  // src/frame-engine.ts
569
+ var CRYPTO_UNAVAILABLE_MESSAGE = "MoonPay SDK: crypto.getRandomValues is unavailable. React Native (Hermes) has no Web Crypto. Install and register a Web Crypto getRandomValues polyfill on the global before using the SDK \u2014 Expo: expo-crypto; bare React Native: react-native-get-random-values. See https://dev.moonpay.com/platform/sdk-reference/react-native/overview.";
560
570
  var FrameSessionDisposedError = class extends Error {
561
571
  constructor() {
562
572
  super("Frame session disposed");
@@ -566,7 +576,11 @@ var FrameSessionDisposedError = class extends Error {
566
576
  function createFrameSession(spec, ctx, props, overrides = {}) {
567
577
  const generated = `${spec.channelPrefix}-${Date.now()}`;
568
578
  const channelId = spec.resolveChannelId ? spec.resolveChannelId(props, generated) : generated;
569
- const keyPair = spec.needsKeyPair ? generateKeyPair() : void 0;
579
+ let keyPair;
580
+ if (spec.needsKeyPair) {
581
+ if (!isSecureRandomAvailable()) throw new Error(CRYPTO_UNAVAILABLE_MESSAGE);
582
+ keyPair = generateKeyPair();
583
+ }
570
584
  const builtUrl = spec.buildUrl ? spec.buildUrl(ctx, props, channelId, keyPair?.publicKey) : buildFrameUrl(
571
585
  spec.path,
572
586
  { ...spec.buildParams?.(ctx, props, keyPair?.publicKey), channelId },
@@ -1316,7 +1330,8 @@ function MoonPayFrameView({
1316
1330
  props,
1317
1331
  style,
1318
1332
  defaultStyle,
1319
- onEvent
1333
+ onEvent,
1334
+ webViewProps
1320
1335
  }) {
1321
1336
  const { sessionToken, core, frameBaseUrl, theme } = useMoonPayContext();
1322
1337
  const [transport, setTransport] = useState3(null);
@@ -1384,15 +1399,15 @@ function MoonPayFrameView({
1384
1399
  applyReactiveProps(spec, reactiveKeys, propsRef.current, appliedRef.current, handle);
1385
1400
  }, [liveKey]);
1386
1401
  if (spec.hidden) {
1387
- return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true }) : null;
1402
+ return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true, webViewProps }) : null;
1388
1403
  }
1389
1404
  const resolvedStyle = { ...defaultStyle, ...style };
1390
- return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport }) : null });
1405
+ return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, webViewProps }) : null });
1391
1406
  }
1392
1407
 
1393
1408
  // src/components/add-card.tsx
1394
1409
  import { jsx as jsx5 } from "react/jsx-runtime";
1395
- function MoonPayAddCard({ onEvent, style }) {
1410
+ function MoonPayAddCard({ onEvent, style, webViewProps }) {
1396
1411
  return /* @__PURE__ */ jsx5(
1397
1412
  MoonPayFrameView,
1398
1413
  {
@@ -1400,7 +1415,8 @@ function MoonPayAddCard({ onEvent, style }) {
1400
1415
  props: {},
1401
1416
  style,
1402
1417
  defaultStyle: { flex: 1 },
1403
- onEvent
1418
+ onEvent,
1419
+ webViewProps
1404
1420
  }
1405
1421
  );
1406
1422
  }
@@ -1411,7 +1427,8 @@ function MoonPayApplePayButton({
1411
1427
  quote,
1412
1428
  externalTransactionId,
1413
1429
  onEvent,
1414
- style
1430
+ style,
1431
+ webViewProps
1415
1432
  }) {
1416
1433
  return /* @__PURE__ */ jsx6(
1417
1434
  MoonPayFrameView,
@@ -1420,14 +1437,15 @@ function MoonPayApplePayButton({
1420
1437
  props: { quote, externalTransactionId },
1421
1438
  style,
1422
1439
  defaultStyle: { height: 48 },
1423
- onEvent
1440
+ onEvent,
1441
+ webViewProps
1424
1442
  }
1425
1443
  );
1426
1444
  }
1427
1445
 
1428
1446
  // src/components/auth.tsx
1429
1447
  import { jsx as jsx7 } from "react/jsx-runtime";
1430
- function MoonPayAuth({ onEvent, style }) {
1448
+ function MoonPayAuth({ onEvent, style, webViewProps }) {
1431
1449
  return /* @__PURE__ */ jsx7(
1432
1450
  MoonPayFrameView,
1433
1451
  {
@@ -1435,7 +1453,8 @@ function MoonPayAuth({ onEvent, style }) {
1435
1453
  props: {},
1436
1454
  style,
1437
1455
  defaultStyle: { flex: 1 },
1438
- onEvent
1456
+ onEvent,
1457
+ webViewProps
1439
1458
  }
1440
1459
  );
1441
1460
  }
@@ -1446,7 +1465,8 @@ function MoonPayBuyButton({
1446
1465
  quote,
1447
1466
  externalTransactionId,
1448
1467
  onEvent,
1449
- style
1468
+ style,
1469
+ webViewProps
1450
1470
  }) {
1451
1471
  return /* @__PURE__ */ jsx8(
1452
1472
  MoonPayFrameView,
@@ -1455,7 +1475,8 @@ function MoonPayBuyButton({
1455
1475
  props: { quote, externalTransactionId },
1456
1476
  style,
1457
1477
  defaultStyle: { height: 48 },
1458
- onEvent
1478
+ onEvent,
1479
+ webViewProps
1459
1480
  }
1460
1481
  );
1461
1482
  }
@@ -1465,7 +1486,8 @@ import { jsx as jsx9 } from "react/jsx-runtime";
1465
1486
  function MoonPayBuyFrame({
1466
1487
  quote,
1467
1488
  externalTransactionId,
1468
- onEvent
1489
+ onEvent,
1490
+ webViewProps
1469
1491
  }) {
1470
1492
  return /* @__PURE__ */ jsx9(
1471
1493
  MoonPayFrameView,
@@ -1473,14 +1495,20 @@ function MoonPayBuyFrame({
1473
1495
  spec: buySpec,
1474
1496
  props: { quote, externalTransactionId },
1475
1497
  defaultStyle: {},
1476
- onEvent
1498
+ onEvent,
1499
+ webViewProps
1477
1500
  }
1478
1501
  );
1479
1502
  }
1480
1503
 
1481
1504
  // src/components/challenge.tsx
1482
1505
  import { jsx as jsx10 } from "react/jsx-runtime";
1483
- function MoonPayChallenge({ url, onEvent, style }) {
1506
+ function MoonPayChallenge({
1507
+ url,
1508
+ onEvent,
1509
+ style,
1510
+ webViewProps
1511
+ }) {
1484
1512
  return /* @__PURE__ */ jsx10(
1485
1513
  MoonPayFrameView,
1486
1514
  {
@@ -1488,14 +1516,20 @@ function MoonPayChallenge({ url, onEvent, style }) {
1488
1516
  props: { url },
1489
1517
  style,
1490
1518
  defaultStyle: { flex: 1 },
1491
- onEvent
1519
+ onEvent,
1520
+ webViewProps
1492
1521
  }
1493
1522
  );
1494
1523
  }
1495
1524
 
1496
1525
  // src/components/connect.tsx
1497
1526
  import { jsx as jsx11 } from "react/jsx-runtime";
1498
- function MoonPayConnect({ theme, onEvent, style }) {
1527
+ function MoonPayConnect({
1528
+ theme,
1529
+ onEvent,
1530
+ style,
1531
+ webViewProps
1532
+ }) {
1499
1533
  return /* @__PURE__ */ jsx11(
1500
1534
  MoonPayFrameView,
1501
1535
  {
@@ -1503,7 +1537,8 @@ function MoonPayConnect({ theme, onEvent, style }) {
1503
1537
  props: { theme },
1504
1538
  style,
1505
1539
  defaultStyle: { flex: 1 },
1506
- onEvent
1540
+ onEvent,
1541
+ webViewProps
1507
1542
  }
1508
1543
  );
1509
1544
  }
@@ -1512,7 +1547,8 @@ function MoonPayConnect({ theme, onEvent, style }) {
1512
1547
  import { jsx as jsx12 } from "react/jsx-runtime";
1513
1548
  function MoonPayConnectionCheck({
1514
1549
  skipKyc,
1515
- onEvent
1550
+ onEvent,
1551
+ webViewProps
1516
1552
  }) {
1517
1553
  return /* @__PURE__ */ jsx12(
1518
1554
  MoonPayFrameView,
@@ -1520,20 +1556,37 @@ function MoonPayConnectionCheck({
1520
1556
  spec: connectionCheckSpec,
1521
1557
  props: { skipKyc },
1522
1558
  defaultStyle: {},
1523
- onEvent
1559
+ onEvent,
1560
+ webViewProps
1524
1561
  }
1525
1562
  );
1526
1563
  }
1527
1564
 
1528
1565
  // src/components/connection-reset.tsx
1529
1566
  import { jsx as jsx13 } from "react/jsx-runtime";
1530
- function MoonPayConnectionReset({ onEvent }) {
1531
- return /* @__PURE__ */ jsx13(MoonPayFrameView, { spec: connectionResetSpec, props: {}, defaultStyle: {}, onEvent });
1567
+ function MoonPayConnectionReset({
1568
+ onEvent,
1569
+ webViewProps
1570
+ }) {
1571
+ return /* @__PURE__ */ jsx13(
1572
+ MoonPayFrameView,
1573
+ {
1574
+ spec: connectionResetSpec,
1575
+ props: {},
1576
+ defaultStyle: {},
1577
+ onEvent,
1578
+ webViewProps
1579
+ }
1580
+ );
1532
1581
  }
1533
1582
 
1534
1583
  // src/components/customer-export.tsx
1535
1584
  import { jsx as jsx14 } from "react/jsx-runtime";
1536
- function MoonPayCustomerExport({ onEvent, style }) {
1585
+ function MoonPayCustomerExport({
1586
+ onEvent,
1587
+ style,
1588
+ webViewProps
1589
+ }) {
1537
1590
  return /* @__PURE__ */ jsx14(
1538
1591
  MoonPayFrameView,
1539
1592
  {
@@ -1541,7 +1594,8 @@ function MoonPayCustomerExport({ onEvent, style }) {
1541
1594
  props: {},
1542
1595
  style,
1543
1596
  defaultStyle: { flex: 1 },
1544
- onEvent
1597
+ onEvent,
1598
+ webViewProps
1545
1599
  }
1546
1600
  );
1547
1601
  }
@@ -1552,7 +1606,8 @@ function MoonPayGooglePayButton({
1552
1606
  quote,
1553
1607
  externalTransactionId,
1554
1608
  onEvent,
1555
- style
1609
+ style,
1610
+ webViewProps
1556
1611
  }) {
1557
1612
  return /* @__PURE__ */ jsx15(
1558
1613
  MoonPayFrameView,
@@ -1561,7 +1616,8 @@ function MoonPayGooglePayButton({
1561
1616
  props: { quote, externalTransactionId },
1562
1617
  style,
1563
1618
  defaultStyle: { height: 48 },
1564
- onEvent
1619
+ onEvent,
1620
+ webViewProps
1565
1621
  }
1566
1622
  );
1567
1623
  }
@@ -1572,7 +1628,8 @@ function MoonPayWidget({
1572
1628
  quote,
1573
1629
  externalTransactionId,
1574
1630
  onEvent,
1575
- style
1631
+ style,
1632
+ webViewProps
1576
1633
  }) {
1577
1634
  return /* @__PURE__ */ jsx16(
1578
1635
  MoonPayFrameView,
@@ -1581,7 +1638,8 @@ function MoonPayWidget({
1581
1638
  props: { quote, externalTransactionId },
1582
1639
  style,
1583
1640
  defaultStyle: { flex: 1 },
1584
- onEvent
1641
+ onEvent,
1642
+ webViewProps
1585
1643
  }
1586
1644
  );
1587
1645
  }