bcrypt-ts 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -12
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
[](https://github.com/Mister-Hope/bcrypt-ts/actions/workflows/test.yml)
|
|
8
8
|
[](https://deepscan.io/dashboard#view=project&tid=15982&pid=28024&bid=898932) [](https://codecov.io/gh/Mister-Hope/bcrypt-ts)
|
|
9
9
|
|
|
10
|
-
Optimized bcrypt in
|
|
10
|
+
Optimized bcrypt in TypeScript with zero dependencies. Compatible to the C++ [bcrypt](https://npmjs.org/package/bcrypt) binding on Node.js and also working in the browser.
|
|
11
11
|
|
|
12
|
-
## Why bcrypt-ts instead of
|
|
12
|
+
## Why bcrypt-ts instead of bcrypt.js
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
14
|
+
- bcrypt-ts is fully written in TypeScript
|
|
15
|
+
- bcrypt-ts provides dual ESM/cjs mode for both Node.js and browser environments
|
|
16
16
|
- Minified output
|
|
17
17
|
- Tree shakable
|
|
18
18
|
|
|
@@ -22,7 +22,7 @@ Besides incorporating a salt to protect against rainbow table attacks, bcrypt is
|
|
|
22
22
|
iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with
|
|
23
23
|
increasing computation power. ([see](http://en.wikipedia.org/wiki/Bcrypt))
|
|
24
24
|
|
|
25
|
-
While bcrypt-ts is compatible
|
|
25
|
+
While bcrypt-ts is compatible with the C++ bcrypt binding, it is built in pure JavaScript and thus slower ([about 30%](https://github.com/dcodeIO/bcrypt.js/wiki/Benchmark)), effectively reducing the number of iterations that can be processed in an equal time span.
|
|
26
26
|
|
|
27
27
|
The maximum input length is 72 bytes (note that UTF-8 encoded characters use up to 4 bytes) and the length of generated
|
|
28
28
|
hashes is 60 characters. Note that maximum input length is not implicitly checked by the library for compatibility with
|
|
@@ -61,10 +61,8 @@ In the browser, bcrypt.js relies on [Web Crypto API](http://www.w3.org/TR/WebCry
|
|
|
61
61
|
### How to choose between them
|
|
62
62
|
|
|
63
63
|
- If you are using this package in pure Node.js environment, then you will probably use the node bundle.
|
|
64
|
-
|
|
65
|
-
- If you
|
|
66
|
-
|
|
67
|
-
- If you meet any issues that a incorrect bundle is used, you can use `bcrypt-ts/node` and `bcrypt-ts/browser` to force the correct bundle.
|
|
64
|
+
- If you are using bundler like webpack or Vite, then you will probably use the browser bundle.
|
|
65
|
+
- If you meet any issues where an incorrect bundle is used, you can import from `bcrypt-ts/node` and `bcrypt-ts/browser` to manually select the bundle.
|
|
68
66
|
|
|
69
67
|
### Usage - Sync
|
|
70
68
|
|
|
@@ -118,8 +116,8 @@ import { compare } from "bcrypt-ts";
|
|
|
118
116
|
// Load hash from your password DB
|
|
119
117
|
const hash = "xxxxxx";
|
|
120
118
|
|
|
121
|
-
await
|
|
122
|
-
await
|
|
119
|
+
await compare("B4c0//", hash); // true
|
|
120
|
+
await compare("not_bacon", hash); // false
|
|
123
121
|
```
|
|
124
122
|
|
|
125
123
|
Auto-gen a salt and hash:
|
|
@@ -127,7 +125,7 @@ Auto-gen a salt and hash:
|
|
|
127
125
|
```ts
|
|
128
126
|
import { hash } from "bcrypt-ts";
|
|
129
127
|
|
|
130
|
-
const result = await
|
|
128
|
+
const result = await hash("B4c0//", 10);
|
|
131
129
|
// Store hash in your password DB
|
|
132
130
|
```
|
|
133
131
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bcrypt-ts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "bcrypt written in typescript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bcrypt",
|
|
@@ -60,26 +60,26 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@codecov/rollup-plugin": "1.9.0",
|
|
63
|
-
"@commitlint/cli": "19.
|
|
64
|
-
"@commitlint/config-conventional": "19.
|
|
63
|
+
"@commitlint/cli": "19.8.0",
|
|
64
|
+
"@commitlint/config-conventional": "19.8.0",
|
|
65
65
|
"@rollup/plugin-alias": "5.1.1",
|
|
66
66
|
"@rollup/plugin-replace": "6.0.2",
|
|
67
|
-
"@types/node": "22.
|
|
68
|
-
"@vitest/coverage-istanbul": "3.
|
|
69
|
-
"eslint": "9.
|
|
70
|
-
"eslint-config-mister-hope": "0.
|
|
67
|
+
"@types/node": "22.15.3",
|
|
68
|
+
"@vitest/coverage-istanbul": "3.1.2",
|
|
69
|
+
"eslint": "9.25.1",
|
|
70
|
+
"eslint-config-mister-hope": "0.9.1",
|
|
71
71
|
"husky": "9.1.7",
|
|
72
72
|
"nano-staged": "0.8.0",
|
|
73
|
-
"prettier": "3.5.
|
|
73
|
+
"prettier": "3.5.3",
|
|
74
74
|
"rimraf": "6.0.1",
|
|
75
|
-
"rollup": "4.
|
|
76
|
-
"rollup-plugin-dts": "6.
|
|
77
|
-
"rollup-plugin-esbuild": "6.2.
|
|
78
|
-
"typescript": "5.
|
|
79
|
-
"vitest": "3.
|
|
75
|
+
"rollup": "4.40.1",
|
|
76
|
+
"rollup-plugin-dts": "6.2.1",
|
|
77
|
+
"rollup-plugin-esbuild": "6.2.1",
|
|
78
|
+
"typescript": "5.8.3",
|
|
79
|
+
"vitest": "3.1.2"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
|
-
"node": ">=
|
|
82
|
+
"node": ">=20"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"bench": "vitest bench",
|