@dubsdotapp/expo 0.2.50 → 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 +31 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- 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);
|