@depup/otplib 13.3.0-depup.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/LICENSE +21 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/class.cjs +2 -0
- package/dist/class.cjs.map +1 -0
- package/dist/class.d.cts +293 -0
- package/dist/class.d.ts +293 -0
- package/dist/class.js +2 -0
- package/dist/class.js.map +1 -0
- package/dist/functional.cjs +2 -0
- package/dist/functional.cjs.map +1 -0
- package/dist/functional.d.cts +234 -0
- package/dist/functional.d.ts +234 -0
- package/dist/functional.js +2 -0
- package/dist/functional.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/types-BBT_82HF.d.cts +122 -0
- package/dist/types-BBT_82HF.d.ts +122 -0
- package/package.json +108 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { CryptoPlugin, Base32Plugin, OTPGuardrails, HashAlgorithm, Digits, OTPHooks } from '@otplib/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for otplib package
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* OTP Strategy Type
|
|
9
|
+
*/
|
|
10
|
+
type OTPStrategy = "totp" | "hotp";
|
|
11
|
+
/**
|
|
12
|
+
* Options with plugin overrides
|
|
13
|
+
*/
|
|
14
|
+
type OTPAuthOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Crypto plugin to use (default: NobleCryptoPlugin)
|
|
17
|
+
*/
|
|
18
|
+
readonly crypto?: CryptoPlugin;
|
|
19
|
+
/**
|
|
20
|
+
* Base32 plugin to use (default: ScureBase32Plugin)
|
|
21
|
+
*/
|
|
22
|
+
readonly base32?: Base32Plugin;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Common options for OTP generation
|
|
26
|
+
*
|
|
27
|
+
* These options apply to both TOTP and HOTP strategies.
|
|
28
|
+
*/
|
|
29
|
+
type OTPGenerateOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* Base32-encoded secret key
|
|
32
|
+
*
|
|
33
|
+
* **Note**: By default, strings are assumed to be Base32 encoded.
|
|
34
|
+
* If you have a raw string/passphrase, you must convert it to Uint8Array first.
|
|
35
|
+
*/
|
|
36
|
+
secret: string | Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* OTP strategy to use (default: 'totp')
|
|
39
|
+
* - 'totp': Time-based OTP
|
|
40
|
+
* - 'hotp': HMAC-based OTP
|
|
41
|
+
*/
|
|
42
|
+
strategy?: OTPStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Crypto plugin to use (default: NobleCryptoPlugin)
|
|
45
|
+
*/
|
|
46
|
+
crypto?: CryptoPlugin;
|
|
47
|
+
/**
|
|
48
|
+
* Base32 plugin to use (default: ScureBase32Plugin)
|
|
49
|
+
*/
|
|
50
|
+
base32?: Base32Plugin;
|
|
51
|
+
/**
|
|
52
|
+
* Validation guardrails
|
|
53
|
+
*/
|
|
54
|
+
guardrails?: OTPGuardrails;
|
|
55
|
+
/**
|
|
56
|
+
* Hash algorithm (default: 'sha1')
|
|
57
|
+
*/
|
|
58
|
+
algorithm?: HashAlgorithm;
|
|
59
|
+
/**
|
|
60
|
+
* Number of digits (default: 6)
|
|
61
|
+
*/
|
|
62
|
+
digits?: Digits;
|
|
63
|
+
/**
|
|
64
|
+
* Time step in seconds (default: 30)
|
|
65
|
+
* Used by TOTP strategy
|
|
66
|
+
*/
|
|
67
|
+
period?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Current Unix epoch timestamp in seconds (default: now)
|
|
70
|
+
* Used by TOTP strategy
|
|
71
|
+
*/
|
|
72
|
+
epoch?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Initial Unix time to start counting time steps (default: 0)
|
|
75
|
+
* Used by TOTP strategy
|
|
76
|
+
*/
|
|
77
|
+
t0?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Counter value
|
|
80
|
+
* Used by HOTP strategy (required)
|
|
81
|
+
*/
|
|
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;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Options for OTP verification
|
|
92
|
+
*
|
|
93
|
+
* Extends OTPFunctionalOptions with token and tolerance parameters.
|
|
94
|
+
*/
|
|
95
|
+
type OTPVerifyOptions = OTPGenerateOptions & {
|
|
96
|
+
/**
|
|
97
|
+
* OTP code to verify
|
|
98
|
+
*/
|
|
99
|
+
token: string;
|
|
100
|
+
/**
|
|
101
|
+
* Time tolerance in seconds for TOTP verification (default: 0)
|
|
102
|
+
* - Number: symmetric tolerance (same for past and future)
|
|
103
|
+
* - Tuple [past, future]: asymmetric tolerance
|
|
104
|
+
* Use [5, 0] for RFC-compliant past-only verification.
|
|
105
|
+
*/
|
|
106
|
+
epochTolerance?: number | [number, number];
|
|
107
|
+
/**
|
|
108
|
+
* Counter tolerance for HOTP verification (default: 0)
|
|
109
|
+
* - Number: creates look-ahead only tolerance [0, n]
|
|
110
|
+
* - Tuple [past, future]: explicit window control
|
|
111
|
+
*/
|
|
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;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type { OTPAuthOptions as O, OTPGenerateOptions as a, OTPStrategy as b, OTPVerifyOptions as c };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { CryptoPlugin, Base32Plugin, OTPGuardrails, HashAlgorithm, Digits, OTPHooks } from '@otplib/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for otplib package
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* OTP Strategy Type
|
|
9
|
+
*/
|
|
10
|
+
type OTPStrategy = "totp" | "hotp";
|
|
11
|
+
/**
|
|
12
|
+
* Options with plugin overrides
|
|
13
|
+
*/
|
|
14
|
+
type OTPAuthOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Crypto plugin to use (default: NobleCryptoPlugin)
|
|
17
|
+
*/
|
|
18
|
+
readonly crypto?: CryptoPlugin;
|
|
19
|
+
/**
|
|
20
|
+
* Base32 plugin to use (default: ScureBase32Plugin)
|
|
21
|
+
*/
|
|
22
|
+
readonly base32?: Base32Plugin;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Common options for OTP generation
|
|
26
|
+
*
|
|
27
|
+
* These options apply to both TOTP and HOTP strategies.
|
|
28
|
+
*/
|
|
29
|
+
type OTPGenerateOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* Base32-encoded secret key
|
|
32
|
+
*
|
|
33
|
+
* **Note**: By default, strings are assumed to be Base32 encoded.
|
|
34
|
+
* If you have a raw string/passphrase, you must convert it to Uint8Array first.
|
|
35
|
+
*/
|
|
36
|
+
secret: string | Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* OTP strategy to use (default: 'totp')
|
|
39
|
+
* - 'totp': Time-based OTP
|
|
40
|
+
* - 'hotp': HMAC-based OTP
|
|
41
|
+
*/
|
|
42
|
+
strategy?: OTPStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Crypto plugin to use (default: NobleCryptoPlugin)
|
|
45
|
+
*/
|
|
46
|
+
crypto?: CryptoPlugin;
|
|
47
|
+
/**
|
|
48
|
+
* Base32 plugin to use (default: ScureBase32Plugin)
|
|
49
|
+
*/
|
|
50
|
+
base32?: Base32Plugin;
|
|
51
|
+
/**
|
|
52
|
+
* Validation guardrails
|
|
53
|
+
*/
|
|
54
|
+
guardrails?: OTPGuardrails;
|
|
55
|
+
/**
|
|
56
|
+
* Hash algorithm (default: 'sha1')
|
|
57
|
+
*/
|
|
58
|
+
algorithm?: HashAlgorithm;
|
|
59
|
+
/**
|
|
60
|
+
* Number of digits (default: 6)
|
|
61
|
+
*/
|
|
62
|
+
digits?: Digits;
|
|
63
|
+
/**
|
|
64
|
+
* Time step in seconds (default: 30)
|
|
65
|
+
* Used by TOTP strategy
|
|
66
|
+
*/
|
|
67
|
+
period?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Current Unix epoch timestamp in seconds (default: now)
|
|
70
|
+
* Used by TOTP strategy
|
|
71
|
+
*/
|
|
72
|
+
epoch?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Initial Unix time to start counting time steps (default: 0)
|
|
75
|
+
* Used by TOTP strategy
|
|
76
|
+
*/
|
|
77
|
+
t0?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Counter value
|
|
80
|
+
* Used by HOTP strategy (required)
|
|
81
|
+
*/
|
|
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;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Options for OTP verification
|
|
92
|
+
*
|
|
93
|
+
* Extends OTPFunctionalOptions with token and tolerance parameters.
|
|
94
|
+
*/
|
|
95
|
+
type OTPVerifyOptions = OTPGenerateOptions & {
|
|
96
|
+
/**
|
|
97
|
+
* OTP code to verify
|
|
98
|
+
*/
|
|
99
|
+
token: string;
|
|
100
|
+
/**
|
|
101
|
+
* Time tolerance in seconds for TOTP verification (default: 0)
|
|
102
|
+
* - Number: symmetric tolerance (same for past and future)
|
|
103
|
+
* - Tuple [past, future]: asymmetric tolerance
|
|
104
|
+
* Use [5, 0] for RFC-compliant past-only verification.
|
|
105
|
+
*/
|
|
106
|
+
epochTolerance?: number | [number, number];
|
|
107
|
+
/**
|
|
108
|
+
* Counter tolerance for HOTP verification (default: 0)
|
|
109
|
+
* - Number: creates look-ahead only tolerance [0, n]
|
|
110
|
+
* - Tuple [past, future]: explicit window control
|
|
111
|
+
*/
|
|
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;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type { OTPAuthOptions as O, OTPGenerateOptions as a, OTPStrategy as b, OTPVerifyOptions as c };
|
package/package.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/otplib",
|
|
3
|
+
"version": "13.3.0-depup.0",
|
|
4
|
+
"description": "TypeScript-first library for TOTP and HOTP with multi-runtime and plugin support (with updated dependencies)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Gerald Yeo <support@yeojz.dev>",
|
|
7
|
+
"homepage": "https://otplib.yeojz.dev",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/yeojz/otplib.git",
|
|
11
|
+
"directory": "packages/otplib"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/yeojz/otplib/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"otplib",
|
|
18
|
+
"depup",
|
|
19
|
+
"updated-dependencies",
|
|
20
|
+
"security",
|
|
21
|
+
"latest",
|
|
22
|
+
"patched",
|
|
23
|
+
"otp",
|
|
24
|
+
"hotp",
|
|
25
|
+
"totp",
|
|
26
|
+
"rfc4226",
|
|
27
|
+
"rfc6238",
|
|
28
|
+
"2fa",
|
|
29
|
+
"mfa",
|
|
30
|
+
"authenticator",
|
|
31
|
+
"google-authenticator",
|
|
32
|
+
"one-time-password"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"type": "module",
|
|
36
|
+
"main": "./dist/index.cjs",
|
|
37
|
+
"module": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"default": "./dist/index.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/index.d.cts",
|
|
47
|
+
"default": "./dist/index.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./functional": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/functional.d.ts",
|
|
53
|
+
"default": "./dist/functional.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/functional.d.cts",
|
|
57
|
+
"default": "./dist/functional.cjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./class": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/class.d.ts",
|
|
63
|
+
"default": "./dist/class.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/class.d.cts",
|
|
67
|
+
"default": "./dist/class.cjs"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist",
|
|
73
|
+
"README.md",
|
|
74
|
+
"LICENSE",
|
|
75
|
+
"changes.json"
|
|
76
|
+
],
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@otplib/uri": "13.3.0",
|
|
79
|
+
"@otplib/hotp": "13.3.0",
|
|
80
|
+
"@otplib/totp": "13.3.0",
|
|
81
|
+
"@otplib/plugin-crypto-noble": "13.3.0",
|
|
82
|
+
"@otplib/plugin-base32-scure": "13.3.0",
|
|
83
|
+
"@otplib/core": "13.3.0"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"tsup": "^8.5.1",
|
|
87
|
+
"typescript": "^5.9.3",
|
|
88
|
+
"vitest": "^4.0.18",
|
|
89
|
+
"@repo/testing": "13.0.1"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"dev": "tsup --watch",
|
|
94
|
+
"test": "vitest",
|
|
95
|
+
"test:ci": "vitest run --coverage",
|
|
96
|
+
"typecheck": "tsc --noEmit",
|
|
97
|
+
"lint": "eslint src/",
|
|
98
|
+
"clean": "rm -rf dist .tsbuildinfo"
|
|
99
|
+
},
|
|
100
|
+
"depup": {
|
|
101
|
+
"changes": {},
|
|
102
|
+
"depsUpdated": 0,
|
|
103
|
+
"originalPackage": "otplib",
|
|
104
|
+
"originalVersion": "13.3.0",
|
|
105
|
+
"processedAt": "2026-03-19T03:03:40.527Z",
|
|
106
|
+
"smokeTest": "failed"
|
|
107
|
+
}
|
|
108
|
+
}
|