@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.mjs
CHANGED
|
@@ -731,6 +731,28 @@ import bs582 from "bs58";
|
|
|
731
731
|
// src/wallet/phantom-deeplink/crypto.ts
|
|
732
732
|
import nacl from "tweetnacl";
|
|
733
733
|
import bs58 from "bs58";
|
|
734
|
+
try {
|
|
735
|
+
nacl.randomBytes(1);
|
|
736
|
+
} catch {
|
|
737
|
+
const g = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : void 0;
|
|
738
|
+
if (g?.crypto?.getRandomValues) {
|
|
739
|
+
nacl.setPRNG((x, n) => {
|
|
740
|
+
const v = new Uint8Array(n);
|
|
741
|
+
g.crypto.getRandomValues(v);
|
|
742
|
+
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
743
|
+
});
|
|
744
|
+
} else {
|
|
745
|
+
try {
|
|
746
|
+
const { getRandomValues } = __require("expo-crypto");
|
|
747
|
+
nacl.setPRNG((x, n) => {
|
|
748
|
+
const v = new Uint8Array(n);
|
|
749
|
+
getRandomValues(v);
|
|
750
|
+
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
751
|
+
});
|
|
752
|
+
} catch {
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
734
756
|
function generateKeyPair() {
|
|
735
757
|
const kp = nacl.box.keyPair();
|
|
736
758
|
return { publicKey: kp.publicKey, secretKey: kp.secretKey };
|
|
@@ -1317,32 +1339,6 @@ var styles = StyleSheet.create({
|
|
|
1317
1339
|
// src/managed-wallet.tsx
|
|
1318
1340
|
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
1319
1341
|
var TAG3 = "[Dubs:ManagedWallet]";
|
|
1320
|
-
function getDefaultRedirectUri() {
|
|
1321
|
-
if (Platform.OS !== "ios") return void 0;
|
|
1322
|
-
try {
|
|
1323
|
-
const expoLinking = __require("expo-linking");
|
|
1324
|
-
if (expoLinking.createURL) {
|
|
1325
|
-
const uri = expoLinking.createURL("phantom-callback");
|
|
1326
|
-
console.log(TAG3, "Auto-detected redirect URI via expo-linking:", uri);
|
|
1327
|
-
return uri;
|
|
1328
|
-
}
|
|
1329
|
-
} catch (e) {
|
|
1330
|
-
console.log(TAG3, "expo-linking createURL failed:", e instanceof Error ? e.message : e);
|
|
1331
|
-
}
|
|
1332
|
-
try {
|
|
1333
|
-
const Constants = __require("expo-constants").default;
|
|
1334
|
-
const scheme = Constants.expoConfig?.scheme;
|
|
1335
|
-
if (scheme) {
|
|
1336
|
-
const uri = `${scheme}://phantom-callback`;
|
|
1337
|
-
console.log(TAG3, "Auto-detected redirect URI via expo-constants:", uri);
|
|
1338
|
-
return uri;
|
|
1339
|
-
}
|
|
1340
|
-
} catch (e) {
|
|
1341
|
-
console.log(TAG3, "expo-constants fallback failed:", e instanceof Error ? e.message : e);
|
|
1342
|
-
}
|
|
1343
|
-
console.log(TAG3, "Could not auto-detect redirect URI on iOS \u2014 pass redirectUri to DubsProvider");
|
|
1344
|
-
return void 0;
|
|
1345
|
-
}
|
|
1346
1342
|
var phantomSingleton = null;
|
|
1347
1343
|
function getOrCreatePhantomAdapter(config) {
|
|
1348
1344
|
if (!phantomSingleton) {
|
|
@@ -1389,20 +1385,14 @@ function ManagedWalletProvider({
|
|
|
1389
1385
|
const [connecting, setConnecting] = useState(false);
|
|
1390
1386
|
const [isReady, setIsReady] = useState(false);
|
|
1391
1387
|
const [error, setError] = useState(null);
|
|
1392
|
-
const usePhantom = Platform.OS === "ios";
|
|
1393
|
-
|
|
1394
|
-
console.log(TAG3, `Platform: ${Platform.OS}, redirectUri: ${resolvedRedirectUri ?? "none"} (explicit: ${!!redirectUri}), usePhantom: ${usePhantom}`);
|
|
1388
|
+
const usePhantom = Platform.OS === "ios" && !!redirectUri;
|
|
1389
|
+
console.log(TAG3, `Platform: ${Platform.OS}, redirectUri: ${redirectUri ? "provided" : "not set"}, usePhantom: ${usePhantom}`);
|
|
1395
1390
|
const adapterRef = useRef(null);
|
|
1396
1391
|
const transactRef = useRef(null);
|
|
1397
1392
|
if (!adapterRef.current) {
|
|
1398
1393
|
if (usePhantom) {
|
|
1399
|
-
if (!resolvedRedirectUri) {
|
|
1400
|
-
throw new Error(
|
|
1401
|
-
'@dubsdotapp/expo: Could not auto-detect redirect URI on iOS. Either set a "scheme" in your app.json or pass redirectUri to <DubsProvider>.'
|
|
1402
|
-
);
|
|
1403
|
-
}
|
|
1404
1394
|
adapterRef.current = getOrCreatePhantomAdapter({
|
|
1405
|
-
redirectUri
|
|
1395
|
+
redirectUri,
|
|
1406
1396
|
appUrl,
|
|
1407
1397
|
cluster,
|
|
1408
1398
|
storage
|