@otplib/plugin-crypto-web 13.1.1 → 13.2.1

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.
Files changed (2) hide show
  1. package/README.md +7 -16
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -24,11 +24,8 @@ This plugin provides HMAC and random byte generation using the Web Crypto API. I
24
24
 
25
25
  ```typescript
26
26
  import { generateSecret, generate } from "otplib";
27
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
28
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
29
-
30
- const crypto = new WebCryptoPlugin();
31
- const base32 = new ScureBase32Plugin();
27
+ import { crypto } from "@otplib/plugin-crypto-web";
28
+ import { base32 } from "@otplib/plugin-base32-scure";
32
29
 
33
30
  // Generate a secret
34
31
  const secret = await generateSecret({ crypto, base32 });
@@ -45,14 +42,11 @@ const token = await generate({
45
42
 
46
43
  ```typescript
47
44
  import { generate } from "otplib";
48
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
49
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
50
-
51
- const crypto = new WebCryptoPlugin();
52
- const base32 = new ScureBase32Plugin();
45
+ import { crypto } from "@otplib/plugin-crypto-web";
46
+ import { base32 } from "@otplib/plugin-base32-scure";
53
47
 
54
48
  const token = await generate({
55
- secret: "JBSWY3DPEHPK3PXP",
49
+ secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
56
50
  algorithm: "sha256",
57
51
  crypto,
58
52
  base32,
@@ -64,9 +58,7 @@ const token = await generate({
64
58
  The Web Crypto API only supports asynchronous operations:
65
59
 
66
60
  ```typescript
67
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
68
-
69
- const crypto = new WebCryptoPlugin();
61
+ import { crypto } from "@otplib/plugin-crypto-web";
70
62
 
71
63
  // Async HMAC (required by Web Crypto API)
72
64
  const digest = await crypto.hmac("SHA-1", key, data);
@@ -81,11 +73,10 @@ Should also work in runtimes which implements Web Crypto API:
81
73
 
82
74
  ```typescript
83
75
  // Cloudflare Worker example
84
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
76
+ import { crypto } from "@otplib/plugin-crypto-web";
85
77
 
86
78
  export default {
87
79
  async fetch(request) {
88
- const crypto = new WebCryptoPlugin();
89
80
  // Use crypto for OTP operations
90
81
  },
91
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otplib/plugin-crypto-web",
3
- "version": "13.1.1",
3
+ "version": "13.2.1",
4
4
  "description": "Web Crypto API adapter for otplib",
5
5
  "license": "MIT",
6
6
  "author": "Gerald Yeo <support@yeojz.dev>",
@@ -44,12 +44,12 @@
44
44
  "LICENSE"
45
45
  ],
46
46
  "dependencies": {
47
- "@otplib/core": "13.1.1"
47
+ "@otplib/core": "13.2.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.0.1",
51
51
  "typescript": "^5.3.3",
52
- "vitest": "^4.0.16"
52
+ "vitest": "^4.0.18"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"