@otplib/plugin-base32-scure 13.2.0 → 13.3.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.
Files changed (2) hide show
  1. package/README.md +13 -32
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -20,11 +20,8 @@ This plugin provides Base32 encoding and decoding using `@scure/base`, a cryptog
20
20
 
21
21
  ```typescript
22
22
  import { generateSecret, generate } from "otplib";
23
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
24
- import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
25
-
26
- const base32 = new ScureBase32Plugin();
27
- const crypto = new NodeCryptoPlugin();
23
+ import { base32 } from "@otplib/plugin-base32-scure";
24
+ import { crypto } from "@otplib/plugin-crypto-node";
28
25
 
29
26
  // Generate a secret
30
27
  const secret = generateSecret({ crypto, base32 });
@@ -40,9 +37,7 @@ const token = await generate({
40
37
  ### Encoding and Decoding
41
38
 
42
39
  ```typescript
43
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
44
-
45
- const base32 = new ScureBase32Plugin();
40
+ import { base32 } from "@otplib/plugin-base32-scure";
46
41
 
47
42
  // Encode binary data to Base32
48
43
  const data = new Uint8Array([1, 2, 3, 4, 5]);
@@ -57,9 +52,7 @@ const decoded = base32.decode("AEBAGBAF");
57
52
  ### With Custom Options
58
53
 
59
54
  ```typescript
60
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
61
-
62
- const base32 = new ScureBase32Plugin();
55
+ import { base32 } from "@otplib/plugin-base32-scure";
63
56
 
64
57
  // Encode without padding
65
58
  const encoded = base32.encode(data, { padding: false });
@@ -96,11 +89,8 @@ Works in all environments:
96
89
 
97
90
  ```typescript
98
91
  import { generateSecret, generate } from "otplib";
99
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
100
- import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
101
-
102
- const base32 = new ScureBase32Plugin();
103
- const crypto = new NodeCryptoPlugin();
92
+ import { base32 } from "@otplib/plugin-base32-scure";
93
+ import { crypto } from "@otplib/plugin-crypto-node";
104
94
 
105
95
  const secret = generateSecret({ crypto, base32 });
106
96
  console.log(secret); // Base32-encoded secret
@@ -113,11 +103,8 @@ console.log(token); // 6-digit token
113
103
 
114
104
  ```typescript
115
105
  import { generateSecret, generate } from "otplib";
116
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
117
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
118
-
119
- const base32 = new ScureBase32Plugin();
120
- const crypto = new WebCryptoPlugin();
106
+ import { base32 } from "@otplib/plugin-base32-scure";
107
+ import { crypto } from "@otplib/plugin-crypto-web";
121
108
 
122
109
  const secret = await generateSecret({ crypto, base32 });
123
110
  const token = await generate({ secret, crypto, base32 });
@@ -126,11 +113,8 @@ const token = await generate({ secret, crypto, base32 });
126
113
  ### Manual Secret Generation
127
114
 
128
115
  ```typescript
129
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
130
- import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
131
-
132
- const base32 = new ScureBase32Plugin();
133
- const crypto = new NodeCryptoPlugin();
116
+ import { base32 } from "@otplib/plugin-base32-scure";
117
+ import { crypto } from "@otplib/plugin-crypto-node";
134
118
 
135
119
  // Generate random secret
136
120
  const secretBytes = crypto.randomBytes(20);
@@ -142,14 +126,11 @@ console.log(secret); // Base32 secret for TOTP
142
126
  ### Edge Runtime (Cloudflare Worker)
143
127
 
144
128
  ```typescript
145
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
146
- import { WebCryptoPlugin } from "@otplib/plugin-crypto-web";
129
+ import { base32 } from "@otplib/plugin-base32-scure";
130
+ import { crypto } from "@otplib/plugin-crypto-web";
147
131
 
148
132
  export default {
149
133
  async fetch(request) {
150
- const base32 = new ScureBase32Plugin();
151
- const crypto = new WebCryptoPlugin();
152
-
153
134
  // Generate secret
154
135
  const secretBytes = await crypto.randomBytes(20);
155
136
  const secret = base32.encode(secretBytes, { padding: false });
@@ -216,4 +197,4 @@ Full documentation available at [otplib.yeojz.dev](https://otplib.yeojz.dev):
216
197
 
217
198
  ## License
218
199
 
219
- [MIT](./LICENSE) © 2026 Gerald Yeo
200
+ [MIT](./LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otplib/plugin-base32-scure",
3
- "version": "13.2.0",
3
+ "version": "13.3.0",
4
4
  "description": "Base32 plugin for otplib using @scure/base",
5
5
  "license": "MIT",
6
6
  "author": "Gerald Yeo <support@yeojz.dev>",
@@ -43,10 +43,10 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@scure/base": "^2.0.0",
46
- "@otplib/core": "13.2.0"
46
+ "@otplib/core": "13.3.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "^25.0.10",
49
+ "@types/node": "^25.2.3",
50
50
  "tsup": "^8.5.1",
51
51
  "typescript": "^5.9.3",
52
52
  "vitest": "^4.0.18"