@otplib/hotp 13.2.0 → 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 +10 -9
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -14,11 +14,8 @@ yarn add @otplib/hotp
14
14
 
15
15
  ```typescript
16
16
  import { generate, verify } from "@otplib/hotp";
17
- import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
18
- import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
19
-
20
- const crypto = new NodeCryptoPlugin();
21
- const base32 = new ScureBase32Plugin();
17
+ import { crypto } from "@otplib/plugin-crypto-node";
18
+ import { base32 } from "@otplib/plugin-base32-scure";
22
19
 
23
20
  // Generate an HOTP token for counter 0
24
21
  const token = await generate({
@@ -50,12 +47,14 @@ Generate an HOTP code for a specific counter:
50
47
 
51
48
  ```typescript
52
49
  import { generate } from '@otplib/hotp';
50
+ import { crypto } from '@otplib/plugin-crypto-node';
51
+ import { base32 } from '@otplib/plugin-base32-scure';
53
52
 
54
53
  const token = await generate({
55
54
  secret: new Uint8Array([...]), // Required: secret as bytes
56
55
  counter: 0, // Required: counter value
57
- crypto: new NodeCryptoPlugin(), // Required: crypto plugin
58
- base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
56
+ crypto, // Required: crypto plugin
57
+ base32, // Optional: base32 plugin (for decoding)
59
58
  algorithm: 'sha1', // Optional: 'sha1' | 'sha256' | 'sha512'
60
59
  digits: 6, // Optional: 6 | 7 | 8
61
60
  });
@@ -67,13 +66,15 @@ Verify an HOTP code:
67
66
 
68
67
  ```typescript
69
68
  import { verify } from '@otplib/hotp';
69
+ import { crypto } from '@otplib/plugin-crypto-node';
70
+ import { base32 } from '@otplib/plugin-base32-scure';
70
71
 
71
72
  const result = await verify({
72
73
  secret: new Uint8Array([...]), // Required: secret as bytes
73
74
  token: '123456', // Required: token to verify
74
75
  counter: 0, // Required: expected counter
75
- crypto: new NodeCryptoPlugin(), // Required: crypto plugin
76
- base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
76
+ crypto, // Required: crypto plugin
77
+ base32, // Optional: base32 plugin (for decoding)
77
78
  algorithm: 'sha1', // Optional: hash algorithm
78
79
  digits: 6, // Optional: expected digits
79
80
  counterTolerance: 5, // Optional: look-ahead tolerance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otplib/hotp",
3
- "version": "13.2.0",
3
+ "version": "13.2.1",
4
4
  "description": "RFC 4226 HOTP implementation for otplib",
5
5
  "license": "MIT",
6
6
  "author": "Gerald Yeo <support@yeojz.dev>",
@@ -45,16 +45,16 @@
45
45
  "LICENSE"
46
46
  ],
47
47
  "dependencies": {
48
- "@otplib/core": "13.2.0",
49
- "@otplib/uri": "13.2.0"
48
+ "@otplib/core": "13.2.1",
49
+ "@otplib/uri": "13.2.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "tsup": "^8.0.1",
53
53
  "typescript": "^5.3.3",
54
54
  "vitest": "^4.0.18",
55
- "@repo/testing": "13.0.1",
56
- "@otplib/plugin-base32-scure": "13.2.0",
57
- "@otplib/plugin-crypto-node": "13.2.0"
55
+ "@otplib/plugin-base32-scure": "13.2.1",
56
+ "@otplib/plugin-crypto-node": "13.2.1",
57
+ "@repo/testing": "13.0.1"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"