Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 8ce24e6

Browse files
authored
Merge pull request #251 from Zilliqa/fix/replace-node-sodium
change node-sodium to sodium-native
2 parents a9433a2 + 57d647c commit 8ce24e6

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ want to use it for.
2929
| [`@zilliqa-js/util`](./packages/zilliqa-js-util) | Miscellaneous functions that take care of serialisation/deserialisation and validation. | none |
3030
| [`@zilliqa-js/viewblock`](https://github.com/Ashlar/zilliqa-js-viewblock) | Library interfacing with ViewBlock's APIs | `@zilliqa-js/crypto` |
3131

32+
33+
## Pre-Requisite (Windows Users)
34+
35+
`zilliqa-js` uses [`scrypt`](https://www.npmjs.com/package/scrypt) library which depends on `node-gyp` in order to compile the binaries from source on Windows.
36+
`node-gyp` on Windows requires users to install additional Visual Studio Build tools.
37+
38+
To install the required Visual Studio Build tools:
39+
40+
```shell
41+
npm install --global --production windows-build-tools # from an elevated PowerShell or CMD.exe as Administrator
42+
43+
npm config set msvs_version 2015 # 2015 is more compatible; though 2017 may work too
44+
```
45+
46+
Refer to https://github.com/nodejs/node-gyp#installation for more information about `node-gyp` installation on Windows.
47+
48+
3249
## Installation
3350

3451
It is recommended that developers install the JavaScript client by making use

packages/zilliqa-js-crypto/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"pbkdf2": "^3.0.16",
3838
"randombytes": "^2.0.6",
3939
"scryptsy": "^2.1.0",
40-
"sodium": "^3.0.2",
40+
"sodium-native": "^3.2.0",
4141
"uuid": "^3.3.2"
4242
}
4343
}

packages/zilliqa-js-crypto/src/random.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export const randomBytes = (bytes: number) => {
3535
randBz = window.crypto.getRandomValues(new Uint8Array(bytes));
3636
} else if (typeof require !== 'undefined') {
3737
const b = Buffer.allocUnsafe(bytes);
38-
require('sodium').api.randombytes_buf(b, bytes);
38+
const sodium = require('sodium-native');
39+
sodium.randombytes_buf(b);
3940
randBz = new Uint8Array(
4041
b.buffer,
4142
b.byteOffset,

yarn.lock

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5832,7 +5832,7 @@ [email protected]:
58325832
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
58335833
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
58345834

5835-
ini@^1.3.2, ini@^1.3.4, ini@~1.3.0:
5835+
ini@^1.3.2, ini@^1.3.4, ini@^1.3.5, ini@~1.3.0:
58365836
version "1.3.5"
58375837
resolved "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
58385838
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
@@ -7817,11 +7817,6 @@ nice-try@^1.0.4:
78177817
resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
78187818
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
78197819

7820-
node-addon-api@*:
7821-
version "3.0.1"
7822-
resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.1.tgz#990544a2607ec3f538443df4858f8c40089b7783"
7823-
integrity sha512-YUpjl57P55u2yUaKX5Bgy4t5s6SCNYMg+62XNg+k41aYbBL1NgWrZfcgljR5MxDxHDjzl0qHDNtH6SkW4DXNCA==
7824-
78257820
node-fetch-npm@^2.0.2:
78267821
version "2.0.2"
78277822
resolved "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz#7258c9046182dca345b4208eda918daf33697ff7"
@@ -7841,6 +7836,11 @@ node-fetch@^2.3.0, node-fetch@^2.5.0:
78417836
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
78427837
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
78437838

7839+
node-gyp-build@^4.2.0:
7840+
version "4.2.3"
7841+
resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739"
7842+
integrity sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==
7843+
78447844
node-gyp@^5.0.2:
78457845
version "5.0.5"
78467846
resolved "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.5.tgz#f6cf1da246eb8c42b097d7cd4d6c3ce23a4163af"
@@ -9856,12 +9856,13 @@ socks@~2.3.2:
98569856
ip "^1.1.5"
98579857
smart-buffer "4.0.2"
98589858

9859-
sodium@^3.0.2:
9860-
version "3.0.2"
9861-
resolved "https://registry.npmjs.org/sodium/-/sodium-3.0.2.tgz#4dbd7eb4a21c92ca7e7f684756cd733fee78112e"
9862-
integrity sha512-IsTwTJeoNBU97km3XkrbCGC/n/9aUQejgD3QPr2YY2gtbSPru3TI6nhCqgoez9Mv88frF9oVZS/jrXFbd6WXyA==
9859+
sodium-native@^3.2.0:
9860+
version "3.2.0"
9861+
resolved "https://registry.npmjs.org/sodium-native/-/sodium-native-3.2.0.tgz#68a9469b96edadffef320cbce51294ad5f72a37f"
9862+
integrity sha512-8aq/vQSegLwsRch8Sb/Bpf9aAqlNe5dp0+NVhb9UjHv42zDZ0D5zX3wBRUbXK9Ejum9uZE6DUgT4vVLlUFRBWg==
98639863
dependencies:
9864-
node-addon-api "*"
9864+
ini "^1.3.5"
9865+
node-gyp-build "^4.2.0"
98659866

98669867
sort-keys@^2.0.0:
98679868
version "2.0.0"

0 commit comments

Comments
 (0)