Skip to content

Commit

Permalink
fix(runtime): swap out expo-random for expo-crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Oct 30, 2024
1 parent 0b4d86b commit 594b5f6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"expo-asset": "~11.0.0",
"expo-barcode-scanner": "~14.0.1",
"expo-constants": "~17.0.2",
"expo-crypto": "~14.0.1",
"expo-file-system": "~18.0.0",
"expo-font": "~13.0.0",
"expo-keep-awake": "~14.0.1",
"expo-linking": "~7.0.2",
"expo-random": "~14.0.1",
"expo-router": "~4.0.0-preview.8",
"expo-splash-screen": "~0.28.5",
"expo-status-bar": "~2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/NativeModules/getDeviceIdAsync.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Random from 'expo-random';
import { getRandomBytesAsync } from 'expo-crypto';

export default async function getDeviceIdAsync() {
const value = await AsyncStorage.getItem('SnackDeviceId');
if (value) return value;
const byteArray = await Random.getRandomBytesAsync(16);
const byteArray = await getRandomBytesAsync(16);
const hexString = [...new Uint8Array(byteArray.buffer)]
.map((x) => x.toString(16).padStart(2, '0'))
.join('');
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/NativeModules/getDeviceIdAsync.web.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Random from 'expo-random';
import { getRandomBytesAsync } from 'expo-crypto';

let fallbackStore: string | null = null;

Expand Down Expand Up @@ -26,7 +26,7 @@ export default async function getDeviceIdAsync() {
return value;
}

const byteArray = await Random.getRandomBytesAsync(16);
const byteArray = await getRandomBytesAsync(16);
const hexString = [...new Uint8Array(byteArray.buffer)]
.map((x) => x.toString(16).padStart(2, '0'))
.join('');
Expand Down
14 changes: 7 additions & 7 deletions runtime/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4245,6 +4245,13 @@ expo-constants@~17.0.0, expo-constants@~17.0.2:
"@expo/config" "~10.0.0"
"@expo/env" "~0.4.0"

expo-crypto@~14.0.1:
version "14.0.1"
resolved "https://registry.yarnpkg.com/expo-crypto/-/expo-crypto-14.0.1.tgz#2aabfebf202f8390db9060c033a18ad8eabe8cd9"
integrity sha512-/gGpD9UAz8fgZtU08cwwqeQElkFmMy2Hc8lLa9laSjD3YN0XM07zDJyJ+CC1VhQ63G8WpUnq1IHSmaPbbLp+oQ==
dependencies:
base64-js "^1.3.0"

expo-eas-client@~0.13.0:
version "0.13.1"
resolved "https://registry.yarnpkg.com/expo-eas-client/-/expo-eas-client-0.13.1.tgz#ebca627f3f58a54906394eb3f5d22f41a1822618"
Expand Down Expand Up @@ -4314,13 +4321,6 @@ [email protected]:
dependencies:
invariant "^2.2.4"

expo-random@~14.0.1:
version "14.0.1"
resolved "https://registry.yarnpkg.com/expo-random/-/expo-random-14.0.1.tgz#aedc6a3b6ff86c74a85989d77d20e0f1762ed669"
integrity sha512-gX2mtR9o+WelX21YizXUCD/y+a4ZL+RDthDmFkHxaYbdzjSYTn8u/igoje/l3WEO+/RYspmqUFa8w/ckNbt6Vg==
dependencies:
base64-js "^1.3.0"

expo-router@~4.0.0-preview.8:
version "4.0.0-preview.8"
resolved "https://registry.yarnpkg.com/expo-router/-/expo-router-4.0.0-preview.8.tgz#7522dce48acda5b6e66dd2c15682280a1751fb3c"
Expand Down

0 comments on commit 594b5f6

Please sign in to comment.