From 6f476a3ac198d902ec13e6b7e3779590ef14c9bb Mon Sep 17 00:00:00 2001 From: shreerang6921 <68148922+shreerang6921@users.noreply.github.com> Date: Fri, 9 Feb 2024 11:53:58 +0530 Subject: [PATCH] Use library to have secure random source in react native environment (#5) * Add library to provide secure random source to ethers * Add semicolon * Keep imports together * Add comment for react-native-get-random-values --------- Co-authored-by: Adw8 --- package.json | 1 + utils.ts | 3 +++ yarn.lock | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/package.json b/package.json index 30d333c..c3b816c 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "ethers": "5", "react": "18.2.0", "react-native": "0.73.3", + "react-native-get-random-values": "^1.10.0", "react-native-keychain": "^8.1.2" }, "devDependencies": { diff --git a/utils.ts b/utils.ts index 5f153a6..79f318d 100644 --- a/utils.ts +++ b/utils.ts @@ -1,3 +1,6 @@ +/* Importing this library provides react native with a secure random source. +For more information, "visit https://docs.ethers.org/v5/cookbook/react-native/#cookbook-reactnative-security" */ +import 'react-native-get-random-values'; import '@ethersproject/shims'; import { Wallet, utils } from 'ethers'; diff --git a/yarn.lock b/yarn.lock index f644093..c7c5529 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3725,6 +3725,11 @@ expect@^29.7.0: jest-message-util "^29.7.0" jest-util "^29.7.0" +fast-base64-decode@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz#b434a0dd7d92b12b43f26819300d2dafb83ee418" + integrity sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q== + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -5919,6 +5924,13 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-native-get-random-values@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/react-native-get-random-values/-/react-native-get-random-values-1.10.0.tgz#c2c5f12a4ef8b1175145347b4a4b9f9a40d9ffc8" + integrity sha512-gZ1zbXhbb8+Jy9qYTV8c4Nf45/VB4g1jmXuavY5rPfUn7x3ok9Vl3FTl0dnE92Z4FFtfbUNNwtSfcmomdtWg+A== + dependencies: + fast-base64-decode "^1.0.0" + react-native-keychain@^8.1.2: version "8.1.2" resolved "https://registry.yarnpkg.com/react-native-keychain/-/react-native-keychain-8.1.2.tgz#34291ae472878e5124d081211af5ede7d810e64f"