Skip to content

Commit

Permalink
refactor!: remove node:crypto-based CSPRNG implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
LiosK committed Jun 21, 2023
1 parent ad3c873 commit 44d9e7b
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Removed

- CommonJS entry point
- `node:crypto`-based CSPRNG implementation; now falls back on `Math.random()`
in Node v14 or older where Web Crypto API is not yet available
- Non-ESM browser test runner

## v2.5.0 - 2023-06-21
Expand Down
4 changes: 0 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,6 @@ let getRandomValues = (buffer) => {
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
getRandomValues = (buffer) => crypto.getRandomValues(buffer);
}
/** @internal */
export const _setRandom = (rand) => {
getRandomValues = rand;
};
/**
* Wraps `crypto.getRandomValues()` and compatibles to enable buffering; this
* uses a small buffer by default to avoid unbearable throughput decline in some
Expand Down
1 change: 0 additions & 1 deletion dist/node.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions dist/node.js

This file was deleted.

12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@
"type": "module",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"node": "./dist/node.js",
"default": "./dist/index.js"
},
"exports": "./dist/index.js",
"files": [
"CHANGELOG.md",
"dist"
],
"sideEffects": [
"./dist/node.js"
],
"browser": {
"crypto": false
},
"sideEffects": false,
"scripts": {
"build": "tsc",
"doc": "typedoc ./src/index.ts --gitRevision \"v$npm_package_version\"",
Expand Down
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,6 @@ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
getRandomValues = (buffer) => crypto.getRandomValues(buffer);
}

/** @internal */
export const _setRandom = (
rand: <T extends Uint8Array | Uint16Array | Uint32Array>(buffer: T) => T
) => {
getRandomValues = rand;
};

/**
* Wraps `crypto.getRandomValues()` and compatibles to enable buffering; this
* uses a small buffer by default to avoid unbearable throughput decline in some
Expand Down
10 changes: 0 additions & 10 deletions src/node.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/node_crypto.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"typeRoots": [],
"declaration": true,
"outDir": "./dist/",
"stripInternal": true,
"isolatedModules": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down

0 comments on commit 44d9e7b

Please sign in to comment.