@dubsdotapp/expo 0.2.51 → 0.2.53
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/README.md +14 -1
- package/dist/index.js +14 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +3 -0
- package/src/polyfill.ts +23 -0
- package/src/wallet/phantom-deeplink/crypto.ts +0 -45
- package/src/wallet/phantom-deeplink/ensure-self.ts +0 -9
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
+
// src/polyfill.ts
|
|
9
|
+
import { getRandomValues } from "expo-crypto";
|
|
10
|
+
if (typeof global !== "undefined") {
|
|
11
|
+
if (typeof global.crypto !== "object") {
|
|
12
|
+
global.crypto = {};
|
|
13
|
+
}
|
|
14
|
+
if (typeof global.crypto.getRandomValues !== "function") {
|
|
15
|
+
global.crypto.getRandomValues = getRandomValues;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (typeof self === "undefined" && typeof globalThis !== "undefined") {
|
|
19
|
+
globalThis.self = globalThis;
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
// src/constants.ts
|
|
9
23
|
var DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
|
|
10
24
|
var DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
|
|
@@ -728,48 +742,10 @@ var MwaWalletAdapter = class {
|
|
|
728
742
|
import { PublicKey as PublicKey2, Transaction as Transaction2 } from "@solana/web3.js";
|
|
729
743
|
import bs582 from "bs58";
|
|
730
744
|
|
|
731
|
-
// src/wallet/phantom-deeplink/ensure-self.ts
|
|
732
|
-
if (typeof self === "undefined") {
|
|
733
|
-
if (typeof globalThis !== "undefined") {
|
|
734
|
-
globalThis.self = globalThis;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
745
|
// src/wallet/phantom-deeplink/crypto.ts
|
|
739
746
|
import nacl from "tweetnacl";
|
|
740
747
|
import bs58 from "bs58";
|
|
741
|
-
var prngChecked = false;
|
|
742
|
-
function ensurePRNG() {
|
|
743
|
-
if (prngChecked) return;
|
|
744
|
-
prngChecked = true;
|
|
745
|
-
try {
|
|
746
|
-
nacl.randomBytes(1);
|
|
747
|
-
return;
|
|
748
|
-
} catch {
|
|
749
|
-
}
|
|
750
|
-
const g = typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
751
|
-
if (g?.crypto?.getRandomValues) {
|
|
752
|
-
nacl.setPRNG((x, n) => {
|
|
753
|
-
const v = new Uint8Array(n);
|
|
754
|
-
g.crypto.getRandomValues(v);
|
|
755
|
-
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
756
|
-
});
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
try {
|
|
760
|
-
const { getRandomValues } = __require("expo-crypto");
|
|
761
|
-
nacl.setPRNG((x, n) => {
|
|
762
|
-
const v = new Uint8Array(n);
|
|
763
|
-
getRandomValues(v);
|
|
764
|
-
for (let i = 0; i < n; i++) x[i] = v[i];
|
|
765
|
-
});
|
|
766
|
-
return;
|
|
767
|
-
} catch {
|
|
768
|
-
}
|
|
769
|
-
console.error("[Dubs] No PRNG available \u2014 crypto operations will fail. Install expo-crypto or use Hermes.");
|
|
770
|
-
}
|
|
771
748
|
function generateKeyPair() {
|
|
772
|
-
ensurePRNG();
|
|
773
749
|
const kp = nacl.box.keyPair();
|
|
774
750
|
return { publicKey: kp.publicKey, secretKey: kp.secretKey };
|
|
775
751
|
}
|
|
@@ -777,7 +753,6 @@ function deriveSharedSecret(ourSecretKey, theirPublicKey) {
|
|
|
777
753
|
return nacl.box.before(theirPublicKey, ourSecretKey);
|
|
778
754
|
}
|
|
779
755
|
function encryptPayload(payload, sharedSecret) {
|
|
780
|
-
ensurePRNG();
|
|
781
756
|
const nonce = nacl.randomBytes(24);
|
|
782
757
|
const message = new TextEncoder().encode(JSON.stringify(payload));
|
|
783
758
|
const encrypted = nacl.box.after(message, nonce, sharedSecret);
|