diff --git a/jest.ts b/jest.ts index b0f76f53..e03585d3 100644 --- a/jest.ts +++ b/jest.ts @@ -108,6 +108,14 @@ jest.mock(`expo-image-picker`, () => { }; }); +jest.mock(`expo-crypto`, () => { + const uuid = jest.requireActual(`uuid`); + + return { + randomUUID: () => uuid.v4(), + }; +}); + jest.mock(`expo-file-system`, () => { const uuid = jest.requireActual(`uuid`); const fs = jest.requireActual(`fs`); diff --git a/package-lock.json b/package-lock.json index ae5d320d..7a401cf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,18 +12,17 @@ "events": "3.3.0", "expo": "^48.0.0", "expo-constants": "^14.2.1", + "expo-crypto": "^12.2.1", "expo-file-system": "^15.2.2", "expo-image-picker": "^14.1.1", "expo-intent-launcher": "^10.5.2", "expo-media-library": "^15.2.2", "expo-permissions": "^14.1.1", - "expo-random": "^13.1.1", "expo-secure-store": "^12.1.1", "expo-standard-web-crypto": "^1.4.3", "filter-validate-email": "1.1.3", "react-native-gesture-handler": "^2.9.0", - "react-native-safe-area-context": "^4.5.0", - "uuid": "^8.3.2" + "react-native-safe-area-context": "^4.5.0" }, "devDependencies": { "@types/jest": "27.4.0", @@ -45,7 +44,8 @@ "react": "17.0.2", "react-native": "0.66.4", "react-test-renderer": "17.0.2", - "typescript": "4.5.5" + "typescript": "4.5.5", + "uuid": "^9.0.0" }, "engines": { "node": ">=16.11.1" @@ -2158,6 +2158,14 @@ "safe-json-stringify": "~1" } }, + "node_modules/@expo/bunyan/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@expo/cli": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@expo/cli/-/cli-0.6.0.tgz", @@ -3871,6 +3879,14 @@ "node": ">=12" } }, + "node_modules/@expo/rudder-sdk-node/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@expo/sdk-runtime-versions": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@expo/sdk-runtime-versions/-/sdk-runtime-versions-1.0.0.tgz", @@ -8714,6 +8730,17 @@ "node": ">=8.0" } }, + "node_modules/expo-crypto": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-12.2.1.tgz", + "integrity": "sha512-NfKsREzj55xCm0v9OKuNw3DU1r6i6VNTYrQcYSZfGOp7o+tvZsJRyr+NyrUg5YVH93TUkothCtsPahdYA4r1Wg==", + "dependencies": { + "base64-js": "^1.3.0" + }, + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-file-system": { "version": "15.2.2", "resolved": "https://registry.npmjs.org/expo-file-system/-/expo-file-system-15.2.2.tgz", @@ -8922,6 +8949,8 @@ "version": "13.1.1", "resolved": "https://registry.npmjs.org/expo-random/-/expo-random-13.1.1.tgz", "integrity": "sha512-+KkhGp7xW45GvMRzlcSOzvDwzTgyXo6C84GaG4GI43rOdECBQ2lGUJ12st39OtfZm1lORNskpi66DjnuJ73g9w==", + "optional": true, + "peer": true, "dependencies": { "base64-js": "^1.3.0" }, @@ -17743,9 +17772,10 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, "bin": { "uuid": "dist/bin/uuid" } @@ -19566,6 +19596,13 @@ "mv": "~2", "safe-json-stringify": "~1", "uuid": "^8.0.0" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } } }, "@expo/cli": { @@ -20921,6 +20958,13 @@ "node-fetch": "^2.6.1", "remove-trailing-slash": "^0.1.0", "uuid": "^8.3.2" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } } }, "@expo/sdk-runtime-versions": { @@ -24953,6 +24997,14 @@ } } }, + "expo-crypto": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-12.2.1.tgz", + "integrity": "sha512-NfKsREzj55xCm0v9OKuNw3DU1r6i6VNTYrQcYSZfGOp7o+tvZsJRyr+NyrUg5YVH93TUkothCtsPahdYA4r1Wg==", + "requires": { + "base64-js": "^1.3.0" + } + }, "expo-file-system": { "version": "15.2.2", "resolved": "https://registry.npmjs.org/expo-file-system/-/expo-file-system-15.2.2.tgz", @@ -25104,6 +25156,8 @@ "version": "13.1.1", "resolved": "https://registry.npmjs.org/expo-random/-/expo-random-13.1.1.tgz", "integrity": "sha512-+KkhGp7xW45GvMRzlcSOzvDwzTgyXo6C84GaG4GI43rOdECBQ2lGUJ12st39OtfZm1lORNskpi66DjnuJ73g9w==", + "optional": true, + "peer": true, "requires": { "base64-js": "^1.3.0" } @@ -31672,9 +31726,10 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true }, "v8-compile-cache": { "version": "2.3.0", diff --git a/package.json b/package.json index 5266eec3..25943320 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "react": "17.0.2", "react-native": "0.66.4", "react-test-renderer": "17.0.2", - "typescript": "4.5.5" + "typescript": "4.5.5", + "uuid": "^9.0.0" }, "peerDependencies": { "react": "*", @@ -59,17 +60,16 @@ "events": "3.3.0", "expo": "^48.0.0", "expo-constants": "^14.2.1", + "expo-crypto": "^12.2.1", "expo-file-system": "^15.2.2", "expo-image-picker": "^14.1.1", "expo-intent-launcher": "^10.5.2", "expo-media-library": "^15.2.2", "expo-permissions": "^14.1.1", - "expo-random": "^13.1.1", "expo-secure-store": "^12.1.1", "expo-standard-web-crypto": "^1.4.3", "filter-validate-email": "1.1.3", "react-native-gesture-handler": "^2.9.0", - "react-native-safe-area-context": "^4.5.0", - "uuid": "^8.3.2" + "react-native-safe-area-context": "^4.5.0" } } diff --git a/react-native/components/createStackRoutingComponent/readme.md b/react-native/components/createStackRoutingComponent/readme.md index 789d8c56..921e221a 100644 --- a/react-native/components/createStackRoutingComponent/readme.md +++ b/react-native/components/createStackRoutingComponent/readme.md @@ -6,7 +6,7 @@ all items in the stack are continuously rendered). ## Usage ```tsx -import * as uuid from "uuid"; +import * as Crypto from "expo-crypto"; import React from "react"; import { Button, SafeAreaView, Text } from "react-native"; import { @@ -237,10 +237,10 @@ export default () => { { - setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeAKey`, parameters: null } ]); + setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeAKey`, parameters: null } ]); }} pushB={(value) => { - setRouteState([ ...routeState, { uuid: uuid.v4(), key: `routeBKey`, parameters: { value } } ]); + setRouteState([ ...routeState, { uuid: Crypto.randomUUID(), key: `routeBKey`, parameters: { value } } ]); }} pop={() => { setRouteState(routeState.slice(0, routeState.length - 1)); diff --git a/react-native/services/FileStore/index.tsx b/react-native/services/FileStore/index.tsx index 28805ffd..3f8cecd4 100644 --- a/react-native/services/FileStore/index.tsx +++ b/react-native/services/FileStore/index.tsx @@ -1,4 +1,4 @@ -import * as uuid from "uuid"; +import * as Crypto from "expo-crypto"; import * as FileSystem from "expo-file-system"; import type { FileStoreInterface } from "../../types/FileStoreInterface"; @@ -99,7 +99,7 @@ export class FileStore implements FileStoreInterface { try { this.operationsInProgress++; - const output = uuid.v4(); + const output = Crypto.randomUUID(); await FileSystem.moveAsync({ from: fileUri,