otplib 13.2.1 → 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.
@@ -1,4 +1,4 @@
1
- import { CryptoPlugin, Base32Plugin, OTPGuardrails, HashAlgorithm, Digits } from '@otplib/core';
1
+ import { CryptoPlugin, Base32Plugin, OTPGuardrails, HashAlgorithm, Digits, OTPHooks } from '@otplib/core';
2
2
 
3
3
  /**
4
4
  * Type definitions for otplib package
@@ -80,6 +80,12 @@ type OTPGenerateOptions = {
80
80
  * Used by HOTP strategy (required)
81
81
  */
82
82
  counter?: number;
83
+ /**
84
+ * Hooks for customizing token encoding and validation.
85
+ * Allows non-standard OTP variants (e.g., Steam Guard) to replace
86
+ * the default numeric encoding with custom schemes.
87
+ */
88
+ hooks?: OTPHooks;
83
89
  };
84
90
  /**
85
91
  * Options for OTP verification
@@ -104,6 +110,13 @@ type OTPVerifyOptions = OTPGenerateOptions & {
104
110
  * - Tuple [past, future]: explicit window control
105
111
  */
106
112
  counterTolerance?: number | [number, number];
113
+ /**
114
+ * Minimum allowed TOTP time step for replay protection (optional)
115
+ *
116
+ * Rejects tokens with timeStep <= afterTimeStep.
117
+ * Only used by TOTP strategy.
118
+ */
119
+ afterTimeStep?: number;
107
120
  };
108
121
 
109
- export type { OTPAuthOptions as O, OTPGenerateOptions as a, OTPVerifyOptions as b, OTPStrategy as c };
122
+ export type { OTPAuthOptions as O, OTPGenerateOptions as a, OTPStrategy as b, OTPVerifyOptions as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otplib",
3
- "version": "13.2.1",
3
+ "version": "13.3.0",
4
4
  "description": "TypeScript-first library for TOTP and HOTP with multi-runtime and plugin support",
5
5
  "license": "MIT",
6
6
  "author": "Gerald Yeo <support@yeojz.dev>",
@@ -41,6 +41,26 @@
41
41
  "types": "./dist/index.d.cts",
42
42
  "default": "./dist/index.cjs"
43
43
  }
44
+ },
45
+ "./functional": {
46
+ "import": {
47
+ "types": "./dist/functional.d.ts",
48
+ "default": "./dist/functional.js"
49
+ },
50
+ "require": {
51
+ "types": "./dist/functional.d.cts",
52
+ "default": "./dist/functional.cjs"
53
+ }
54
+ },
55
+ "./class": {
56
+ "import": {
57
+ "types": "./dist/class.d.ts",
58
+ "default": "./dist/class.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/class.d.cts",
62
+ "default": "./dist/class.cjs"
63
+ }
44
64
  }
45
65
  },
46
66
  "files": [
@@ -49,18 +69,17 @@
49
69
  "LICENSE"
50
70
  ],
51
71
  "dependencies": {
52
- "@otplib/core": "13.2.1",
53
- "@otplib/uri": "13.2.1",
54
- "@otplib/hotp": "13.2.1",
55
- "@otplib/totp": "13.2.1",
56
- "@otplib/plugin-crypto-noble": "13.2.1",
57
- "@otplib/plugin-base32-scure": "13.2.1"
72
+ "@otplib/uri": "13.3.0",
73
+ "@otplib/hotp": "13.3.0",
74
+ "@otplib/totp": "13.3.0",
75
+ "@otplib/plugin-crypto-noble": "13.3.0",
76
+ "@otplib/plugin-base32-scure": "13.3.0",
77
+ "@otplib/core": "13.3.0"
58
78
  },
59
79
  "devDependencies": {
60
- "tsup": "^8.0.1",
61
- "typescript": "^5.3.3",
80
+ "tsup": "^8.5.1",
81
+ "typescript": "^5.9.3",
62
82
  "vitest": "^4.0.18",
63
- "@otplib/plugin-crypto-noble": "13.2.1",
64
83
  "@repo/testing": "13.0.1"
65
84
  },
66
85
  "publishConfig": {