@dubsdotapp/expo 0.2.47 → 0.2.49
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 +25 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/managed-wallet.tsx +5 -49
- package/src/wallet/phantom-deeplink/crypto.ts +29 -0
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,32 +1404,6 @@ 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]";
|
|
1385
|
-
function getDefaultRedirectUri() {
|
|
1386
|
-
if (import_react_native4.Platform.OS !== "ios") return void 0;
|
|
1387
|
-
try {
|
|
1388
|
-
const expoLinking = require("expo-linking");
|
|
1389
|
-
if (expoLinking.createURL) {
|
|
1390
|
-
const uri = expoLinking.createURL("phantom-callback");
|
|
1391
|
-
console.log(TAG3, "Auto-detected redirect URI via expo-linking:", uri);
|
|
1392
|
-
return uri;
|
|
1393
|
-
}
|
|
1394
|
-
} catch (e) {
|
|
1395
|
-
console.log(TAG3, "expo-linking createURL failed:", e instanceof Error ? e.message : e);
|
|
1396
|
-
}
|
|
1397
|
-
try {
|
|
1398
|
-
const Constants = require("expo-constants").default;
|
|
1399
|
-
const scheme = Constants.expoConfig?.scheme;
|
|
1400
|
-
if (scheme) {
|
|
1401
|
-
const uri = `${scheme}://phantom-callback`;
|
|
1402
|
-
console.log(TAG3, "Auto-detected redirect URI via expo-constants:", uri);
|
|
1403
|
-
return uri;
|
|
1404
|
-
}
|
|
1405
|
-
} catch (e) {
|
|
1406
|
-
console.log(TAG3, "expo-constants fallback failed:", e instanceof Error ? e.message : e);
|
|
1407
|
-
}
|
|
1408
|
-
console.log(TAG3, "Could not auto-detect redirect URI on iOS \u2014 pass redirectUri to DubsProvider");
|
|
1409
|
-
return void 0;
|
|
1410
|
-
}
|
|
1411
1407
|
var phantomSingleton = null;
|
|
1412
1408
|
function getOrCreatePhantomAdapter(config) {
|
|
1413
1409
|
if (!phantomSingleton) {
|
|
@@ -1454,20 +1450,14 @@ function ManagedWalletProvider({
|
|
|
1454
1450
|
const [connecting, setConnecting] = (0, import_react2.useState)(false);
|
|
1455
1451
|
const [isReady, setIsReady] = (0, import_react2.useState)(false);
|
|
1456
1452
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
1457
|
-
const usePhantom = import_react_native4.Platform.OS === "ios";
|
|
1458
|
-
|
|
1459
|
-
console.log(TAG3, `Platform: ${import_react_native4.Platform.OS}, redirectUri: ${resolvedRedirectUri ?? "none"} (explicit: ${!!redirectUri}), usePhantom: ${usePhantom}`);
|
|
1453
|
+
const usePhantom = import_react_native4.Platform.OS === "ios" && !!redirectUri;
|
|
1454
|
+
console.log(TAG3, `Platform: ${import_react_native4.Platform.OS}, redirectUri: ${redirectUri ? "provided" : "not set"}, usePhantom: ${usePhantom}`);
|
|
1460
1455
|
const adapterRef = (0, import_react2.useRef)(null);
|
|
1461
1456
|
const transactRef = (0, import_react2.useRef)(null);
|
|
1462
1457
|
if (!adapterRef.current) {
|
|
1463
1458
|
if (usePhantom) {
|
|
1464
|
-
if (!resolvedRedirectUri) {
|
|
1465
|
-
throw new Error(
|
|
1466
|
-
'@dubsdotapp/expo: Could not auto-detect redirect URI on iOS. Either set a "scheme" in your app.json or pass redirectUri to <DubsProvider>.'
|
|
1467
|
-
);
|
|
1468
|
-
}
|
|
1469
1459
|
adapterRef.current = getOrCreatePhantomAdapter({
|
|
1470
|
-
redirectUri
|
|
1460
|
+
redirectUri,
|
|
1471
1461
|
appUrl,
|
|
1472
1462
|
cluster,
|
|
1473
1463
|
storage
|