@dubsdotapp/expo 0.2.48 → 0.2.50

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
@@ -803,6 +803,28 @@ var import_bs582 = __toESM(require("bs58"));
803
803
  // src/wallet/phantom-deeplink/crypto.ts
804
804
  var import_tweetnacl = __toESM(require("tweetnacl"));
805
805
  var import_bs58 = __toESM(require("bs58"));
806
+ try {
807
+ import_tweetnacl.default.randomBytes(1);
808
+ } catch {
809
+ const g = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : void 0;
810
+ if (g?.crypto?.getRandomValues) {
811
+ import_tweetnacl.default.setPRNG((x, n) => {
812
+ const v = new Uint8Array(n);
813
+ g.crypto.getRandomValues(v);
814
+ for (let i = 0; i < n; i++) x[i] = v[i];
815
+ });
816
+ } else {
817
+ try {
818
+ const { getRandomValues } = require("expo-crypto");
819
+ import_tweetnacl.default.setPRNG((x, n) => {
820
+ const v = new Uint8Array(n);
821
+ getRandomValues(v);
822
+ for (let i = 0; i < n; i++) x[i] = v[i];
823
+ });
824
+ } catch {
825
+ }
826
+ }
827
+ }
806
828
  function generateKeyPair() {
807
829
  const kp = import_tweetnacl.default.box.keyPair();
808
830
  return { publicKey: kp.publicKey, secretKey: kp.secretKey };
@@ -1382,6 +1404,29 @@ var styles = import_react_native3.StyleSheet.create({
1382
1404
  // src/managed-wallet.tsx
1383
1405
  var import_jsx_runtime2 = require("react/jsx-runtime");
1384
1406
  var TAG3 = "[Dubs:ManagedWallet]";
1407
+ function getDefaultRedirectUri() {
1408
+ if (import_react_native4.Platform.OS !== "ios") return void 0;
1409
+ try {
1410
+ const expoLinking = require("expo-linking");
1411
+ if (expoLinking.createURL) {
1412
+ const uri = expoLinking.createURL("phantom-callback");
1413
+ console.log(TAG3, "Auto-detected redirect URI via expo-linking:", uri);
1414
+ return uri;
1415
+ }
1416
+ } catch {
1417
+ }
1418
+ try {
1419
+ const Constants = require("expo-constants").default;
1420
+ const scheme = Constants.expoConfig?.scheme;
1421
+ if (scheme) {
1422
+ const uri = `${scheme}://phantom-callback`;
1423
+ console.log(TAG3, "Auto-detected redirect URI via expo-constants:", uri);
1424
+ return uri;
1425
+ }
1426
+ } catch {
1427
+ }
1428
+ return void 0;
1429
+ }
1385
1430
  var phantomSingleton = null;
1386
1431
  function getOrCreatePhantomAdapter(config) {
1387
1432
  if (!phantomSingleton) {
@@ -1428,14 +1473,15 @@ function ManagedWalletProvider({
1428
1473
  const [connecting, setConnecting] = (0, import_react2.useState)(false);
1429
1474
  const [isReady, setIsReady] = (0, import_react2.useState)(false);
1430
1475
  const [error, setError] = (0, import_react2.useState)(null);
1431
- const usePhantom = import_react_native4.Platform.OS === "ios" && !!redirectUri;
1432
- console.log(TAG3, `Platform: ${import_react_native4.Platform.OS}, redirectUri: ${redirectUri ? "provided" : "not set"}, usePhantom: ${usePhantom}`);
1476
+ const resolvedRedirectUri = redirectUri || getDefaultRedirectUri();
1477
+ const usePhantom = import_react_native4.Platform.OS === "ios" && !!resolvedRedirectUri;
1478
+ console.log(TAG3, `Platform: ${import_react_native4.Platform.OS}, redirectUri: ${resolvedRedirectUri ?? "none"} (explicit: ${!!redirectUri}), usePhantom: ${usePhantom}`);
1433
1479
  const adapterRef = (0, import_react2.useRef)(null);
1434
1480
  const transactRef = (0, import_react2.useRef)(null);
1435
1481
  if (!adapterRef.current) {
1436
1482
  if (usePhantom) {
1437
1483
  adapterRef.current = getOrCreatePhantomAdapter({
1438
- redirectUri,
1484
+ redirectUri: resolvedRedirectUri,
1439
1485
  appUrl,
1440
1486
  cluster,
1441
1487
  storage