@dubsdotapp/expo 0.2.48 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,6 +1,35 @@
1
1
  import nacl from 'tweetnacl';
2
2
  import bs58 from 'bs58';
3
3
 
4
+ // tweetnacl checks self.crypto.getRandomValues at import time.
5
+ // In some React Native environments this isn't set up yet.
6
+ // Ensure PRNG is configured before any crypto operations.
7
+ try {
8
+ nacl.randomBytes(1);
9
+ } catch {
10
+ // Try globalThis.crypto (available in Hermes / RN 0.76+)
11
+ const g = typeof globalThis !== 'undefined' ? globalThis : (typeof self !== 'undefined' ? self : undefined);
12
+ if (g?.crypto?.getRandomValues) {
13
+ nacl.setPRNG((x: Uint8Array, n: number) => {
14
+ const v = new Uint8Array(n);
15
+ g.crypto.getRandomValues(v);
16
+ for (let i = 0; i < n; i++) x[i] = v[i];
17
+ });
18
+ } else {
19
+ // Try expo-crypto as fallback
20
+ try {
21
+ const { getRandomValues } = require('expo-crypto');
22
+ nacl.setPRNG((x: Uint8Array, n: number) => {
23
+ const v = new Uint8Array(n);
24
+ getRandomValues(v);
25
+ for (let i = 0; i < n; i++) x[i] = v[i];
26
+ });
27
+ } catch {
28
+ // PRNG will throw when used — unavoidable without a crypto source
29
+ }
30
+ }
31
+ }
32
+
4
33
  export interface KeyPair {
5
34
  publicKey: Uint8Array;
6
35
  secretKey: Uint8Array;