@otplib/plugin-crypto-web 13.3.0 → 13.4.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 +9 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ yarn add @otplib/plugin-crypto-web
|
|
|
14
14
|
|
|
15
15
|
This plugin provides HMAC and random byte generation using the Web Crypto API. It supports all hash algorithms available in modern browsers:
|
|
16
16
|
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
17
|
+
- `sha1`
|
|
18
|
+
- `sha256`
|
|
19
|
+
- `sha512`
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
@@ -61,10 +61,10 @@ The Web Crypto API only supports asynchronous operations:
|
|
|
61
61
|
import { crypto } from "@otplib/plugin-crypto-web";
|
|
62
62
|
|
|
63
63
|
// Async HMAC (required by Web Crypto API)
|
|
64
|
-
const digest = await crypto.hmac("
|
|
64
|
+
const digest = await crypto.hmac("sha1", key, data);
|
|
65
65
|
|
|
66
|
-
//
|
|
67
|
-
const bytes =
|
|
66
|
+
// Synchronous random bytes
|
|
67
|
+
const bytes = crypto.randomBytes(20); // synchronous
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
## Edge Runtime Support
|
|
@@ -94,9 +94,9 @@ Use this plugin when:
|
|
|
94
94
|
|
|
95
95
|
## Performance
|
|
96
96
|
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
- Uses OS-level
|
|
97
|
+
- HMAC operations are asynchronous (returns `Promise`)
|
|
98
|
+
- `randomBytes` is synchronous (uses `crypto.getRandomValues`)
|
|
99
|
+
- Uses native browser crypto implementations backed by OS-level primitives
|
|
100
100
|
|
|
101
101
|
## Limitations
|
|
102
102
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otplib/plugin-crypto-web",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.4.0",
|
|
4
4
|
"description": "Web Crypto API adapter for otplib",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gerald Yeo <support@yeojz.dev>",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"LICENSE"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@otplib/core": "13.
|
|
47
|
+
"@otplib/core": "13.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsup": "^8.5.1",
|