@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @dubsdotapp/expo
2
2
 
3
- React Native SDK for the [Dubs](https://dubs.fun) betting platform. Pure TypeScript — no native code.
3
+ React Native SDK for the [Dubs](https://dubs.fun) betting platform.
4
4
 
5
5
  ## Install
6
6
 
@@ -14,6 +14,19 @@ For the built-in Mobile Wallet Adapter (optional):
14
14
  npx expo install @solana-mobile/mobile-wallet-adapter-protocol-web3js
15
15
  ```
16
16
 
17
+ ### Custom Dev Builds
18
+
19
+ The SDK includes `expo-crypto` as a dependency to provide `crypto.getRandomValues` for Solana transaction signing, wallet encryption, and other cryptographic operations. This works automatically in Expo Go and EAS builds.
20
+
21
+ If your app uses a **custom dev build** (has `ios/` or `android/` directories), you need to rebuild after installing so the native `ExpoCrypto` module is linked:
22
+
23
+ ```bash
24
+ npx expo prebuild --clean
25
+ npx expo run:ios # or npx expo run:android
26
+ ```
27
+
28
+ This is standard Expo behavior for any package with native code — you only need to do this once after installing the SDK.
29
+
17
30
  ## Quick Start
18
31
 
19
32
  ### 1. Set up the provider
package/dist/index.js CHANGED
@@ -77,6 +77,20 @@ __export(index_exports, {
77
77
  });
78
78
  module.exports = __toCommonJS(index_exports);
79
79
 
80
+ // src/polyfill.ts
81
+ var import_expo_crypto = require("expo-crypto");
82
+ if (typeof global !== "undefined") {
83
+ if (typeof global.crypto !== "object") {
84
+ global.crypto = {};
85
+ }
86
+ if (typeof global.crypto.getRandomValues !== "function") {
87
+ global.crypto.getRandomValues = import_expo_crypto.getRandomValues;
88
+ }
89
+ }
90
+ if (typeof self === "undefined" && typeof globalThis !== "undefined") {
91
+ globalThis.self = globalThis;
92
+ }
93
+
80
94
  // src/constants.ts
81
95
  var DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
82
96
  var DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
@@ -800,48 +814,10 @@ var MwaWalletAdapter = class {
800
814
  var import_web32 = require("@solana/web3.js");
801
815
  var import_bs582 = __toESM(require("bs58"));
802
816
 
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
-
810
817
  // src/wallet/phantom-deeplink/crypto.ts
811
818
  var import_tweetnacl = __toESM(require("tweetnacl"));
812
819
  var import_bs58 = __toESM(require("bs58"));
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;
823
- if (g?.crypto?.getRandomValues) {
824
- import_tweetnacl.default.setPRNG((x, n) => {
825
- const v = new Uint8Array(n);
826
- g.crypto.getRandomValues(v);
827
- for (let i = 0; i < n; i++) x[i] = v[i];
828
- });
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 {
840
- }
841
- console.error("[Dubs] No PRNG available \u2014 crypto operations will fail. Install expo-crypto or use Hermes.");
842
- }
843
820
  function generateKeyPair() {
844
- ensurePRNG();
845
821
  const kp = import_tweetnacl.default.box.keyPair();
846
822
  return { publicKey: kp.publicKey, secretKey: kp.secretKey };
847
823
  }
@@ -849,7 +825,6 @@ function deriveSharedSecret(ourSecretKey, theirPublicKey) {
849
825
  return import_tweetnacl.default.box.before(theirPublicKey, ourSecretKey);
850
826
  }
851
827
  function encryptPayload(payload, sharedSecret) {
852
- ensurePRNG();
853
828
  const nonce = import_tweetnacl.default.randomBytes(24);
854
829
  const message = new TextEncoder().encode(JSON.stringify(payload));
855
830
  const encrypted = import_tweetnacl.default.box.after(message, nonce, sharedSecret);