@dubsdotapp/expo 0.2.49 → 0.2.51
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 +58 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/managed-wallet.tsx +28 -4
- package/src/wallet/phantom-deeplink/crypto.ts +36 -20
- package/src/wallet/phantom-deeplink/ensure-self.ts +9 -0
package/dist/index.js
CHANGED
|
@@ -800,32 +800,48 @@ var MwaWalletAdapter = class {
|
|
|
800
800
|
var import_web32 = require("@solana/web3.js");
|
|
801
801
|
var import_bs582 = __toESM(require("bs58"));
|
|
802
802
|
|
|
803
|
+
// src/wallet/phantom-deeplink/ensure-self.ts
|
|
804
|
+
if (typeof self === "undefined") {
|
|
805
|
+
if (typeof globalThis !== "undefined") {
|
|
806
|
+
globalThis.self = globalThis;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
803
810
|
// src/wallet/phantom-deeplink/crypto.ts
|
|
804
811
|
var import_tweetnacl = __toESM(require("tweetnacl"));
|
|
805
812
|
var import_bs58 = __toESM(require("bs58"));
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
813
|
+
var prngChecked = false;
|
|
814
|
+
function ensurePRNG() {
|
|
815
|
+
if (prngChecked) return;
|
|
816
|
+
prngChecked = true;
|
|
817
|
+
try {
|
|
818
|
+
import_tweetnacl.default.randomBytes(1);
|
|
819
|
+
return;
|
|
820
|
+
} catch {
|
|
821
|
+
}
|
|
822
|
+
const g = typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
810
823
|
if (g?.crypto?.getRandomValues) {
|
|
811
824
|
import_tweetnacl.default.setPRNG((x, n) => {
|
|
812
825
|
const v = new Uint8Array(n);
|
|
813
826
|
g.crypto.getRandomValues(v);
|
|
814
827
|
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
815
828
|
});
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
try {
|
|
832
|
+
const { getRandomValues } = require("expo-crypto");
|
|
833
|
+
import_tweetnacl.default.setPRNG((x, n) => {
|
|
834
|
+
const v = new Uint8Array(n);
|
|
835
|
+
getRandomValues(v);
|
|
836
|
+
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
837
|
+
});
|
|
838
|
+
return;
|
|
839
|
+
} catch {
|
|
826
840
|
}
|
|
841
|
+
console.error("[Dubs] No PRNG available \u2014 crypto operations will fail. Install expo-crypto or use Hermes.");
|
|
827
842
|
}
|
|
828
843
|
function generateKeyPair() {
|
|
844
|
+
ensurePRNG();
|
|
829
845
|
const kp = import_tweetnacl.default.box.keyPair();
|
|
830
846
|
return { publicKey: kp.publicKey, secretKey: kp.secretKey };
|
|
831
847
|
}
|
|
@@ -833,6 +849,7 @@ function deriveSharedSecret(ourSecretKey, theirPublicKey) {
|
|
|
833
849
|
return import_tweetnacl.default.box.before(theirPublicKey, ourSecretKey);
|
|
834
850
|
}
|
|
835
851
|
function encryptPayload(payload, sharedSecret) {
|
|
852
|
+
ensurePRNG();
|
|
836
853
|
const nonce = import_tweetnacl.default.randomBytes(24);
|
|
837
854
|
const message = new TextEncoder().encode(JSON.stringify(payload));
|
|
838
855
|
const encrypted = import_tweetnacl.default.box.after(message, nonce, sharedSecret);
|
|
@@ -1404,6 +1421,29 @@ var styles = import_react_native3.StyleSheet.create({
|
|
|
1404
1421
|
// src/managed-wallet.tsx
|
|
1405
1422
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1406
1423
|
var TAG3 = "[Dubs:ManagedWallet]";
|
|
1424
|
+
function getDefaultRedirectUri() {
|
|
1425
|
+
if (import_react_native4.Platform.OS !== "ios") return void 0;
|
|
1426
|
+
try {
|
|
1427
|
+
const expoLinking = require("expo-linking");
|
|
1428
|
+
if (expoLinking.createURL) {
|
|
1429
|
+
const uri = expoLinking.createURL("phantom-callback");
|
|
1430
|
+
console.log(TAG3, "Auto-detected redirect URI via expo-linking:", uri);
|
|
1431
|
+
return uri;
|
|
1432
|
+
}
|
|
1433
|
+
} catch {
|
|
1434
|
+
}
|
|
1435
|
+
try {
|
|
1436
|
+
const Constants = require("expo-constants").default;
|
|
1437
|
+
const scheme = Constants.expoConfig?.scheme;
|
|
1438
|
+
if (scheme) {
|
|
1439
|
+
const uri = `${scheme}://phantom-callback`;
|
|
1440
|
+
console.log(TAG3, "Auto-detected redirect URI via expo-constants:", uri);
|
|
1441
|
+
return uri;
|
|
1442
|
+
}
|
|
1443
|
+
} catch {
|
|
1444
|
+
}
|
|
1445
|
+
return void 0;
|
|
1446
|
+
}
|
|
1407
1447
|
var phantomSingleton = null;
|
|
1408
1448
|
function getOrCreatePhantomAdapter(config) {
|
|
1409
1449
|
if (!phantomSingleton) {
|
|
@@ -1450,14 +1490,15 @@ function ManagedWalletProvider({
|
|
|
1450
1490
|
const [connecting, setConnecting] = (0, import_react2.useState)(false);
|
|
1451
1491
|
const [isReady, setIsReady] = (0, import_react2.useState)(false);
|
|
1452
1492
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1493
|
+
const resolvedRedirectUri = redirectUri || getDefaultRedirectUri();
|
|
1494
|
+
const usePhantom = import_react_native4.Platform.OS === "ios" && !!resolvedRedirectUri;
|
|
1495
|
+
console.log(TAG3, `Platform: ${import_react_native4.Platform.OS}, redirectUri: ${resolvedRedirectUri ?? "none"} (explicit: ${!!redirectUri}), usePhantom: ${usePhantom}`);
|
|
1455
1496
|
const adapterRef = (0, import_react2.useRef)(null);
|
|
1456
1497
|
const transactRef = (0, import_react2.useRef)(null);
|
|
1457
1498
|
if (!adapterRef.current) {
|
|
1458
1499
|
if (usePhantom) {
|
|
1459
1500
|
adapterRef.current = getOrCreatePhantomAdapter({
|
|
1460
|
-
redirectUri,
|
|
1501
|
+
redirectUri: resolvedRedirectUri,
|
|
1461
1502
|
appUrl,
|
|
1462
1503
|
cluster,
|
|
1463
1504
|
storage
|