@fluojs/jwt 1.0.0-beta.3 → 1.0.0-beta.4
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/README.ko.md +2 -0
- package/README.md +2 -0
- package/dist/signing/verifier.d.ts.map +1 -1
- package/dist/signing/verifier.js +16 -1
- package/package.json +4 -4
package/README.ko.md
CHANGED
|
@@ -162,6 +162,8 @@ JWT 서명과 검증에는 `algorithms`에 지원되는 알고리즘이 하나
|
|
|
162
162
|
|
|
163
163
|
액세스 토큰 TTL도 양의 유한 숫자여야 합니다. `accessTokenTtlSeconds`를 생략하면 `DefaultJwtSigner`는 문서화된 기본값인 `3600`초를 사용합니다. 소수 초는 JWT NumericDate `exp` 클레임에 그대로 보존됩니다. `0`, 음수 또는 유한하지 않은 값이 제공되면 토큰을 발행하기 전에 `JwtConfigurationError`로 실패합니다.
|
|
164
164
|
|
|
165
|
+
검증은 잘못된 시간 정책에 대해 fail closed로 동작합니다. 검증에 참여하는 `exp`, `nbf`, `iat` 클레임은 유한한 JWT NumericDate 숫자여야 하며, `clockSkewSeconds`도 음수가 아닌 유한 숫자여야 합니다. 유한하지 않은 값은 expiration, not-before, age check를 늘리는 대신 거부됩니다.
|
|
166
|
+
|
|
165
167
|
## 공개 API 개요
|
|
166
168
|
|
|
167
169
|
### 주요 클래스
|
package/README.md
CHANGED
|
@@ -162,6 +162,8 @@ JWT signing and verification require at least one supported algorithm in `algori
|
|
|
162
162
|
|
|
163
163
|
Access-token TTL must also be a positive finite number. When `accessTokenTtlSeconds` is omitted, `DefaultJwtSigner` uses the documented `3600` second default. Fractional seconds are preserved in the JWT NumericDate `exp` claim; when the option is provided as `0`, a negative number, or a non-finite value, signing fails with `JwtConfigurationError` before a token is issued.
|
|
164
164
|
|
|
165
|
+
Verification fails closed on malformed time policy. `exp`, `nbf`, and `iat` claims that participate in verification must be finite JWT NumericDate numbers, and `clockSkewSeconds` must be a non-negative finite number. Non-finite values are rejected instead of extending expiration, not-before, or age checks.
|
|
166
|
+
|
|
165
167
|
## Public API Overview
|
|
166
168
|
|
|
167
169
|
### Core Classes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../../src/signing/verifier.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAA0B,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAG1G;;GAEG;AACH,eAAO,MAAM,WAAW,eAAiC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAI3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAOjE,CAAC;
|
|
1
|
+
{"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../../src/signing/verifier.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAA0B,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAG1G;;GAEG;AACH,eAAO,MAAM,WAAW,eAAiC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAI3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAOjE,CAAC;AAmDF,KAAK,gCAAgC,GAAG,IAAI,CAC1C,kBAAkB,EAClB,YAAY,GAAG,UAAU,GAAG,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CACpF,CAAC;AA+LF;;GAEG;AACH,qBACa,kBAAkB;IAMjB,OAAO,CAAC,QAAQ,CAAC,OAAO;IALpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqB;IACxD,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAqB;IAC/D,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAiC;gBAE/C,OAAO,EAAE,kBAAkB;IAalD,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7D;;;;;;;;;;OAUG;IACG,8BAA8B,CAClC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,OAAO,CAAC,gCAAgC,CAAC,GACnD,OAAO,CAAC,YAAY,CAAC;IAqBlB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ9D,OAAO,CAAC,gCAAgC;YAsB1B,WAAW;IA+BzB,OAAO,CAAC,kBAAkB;YAUZ,oBAAoB;YAgBpB,wBAAwB;YAsBxB,8BAA8B;YAsB9B,kBAAkB;IAWhC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,oBAAoB;IA2B5B,OAAO,CAAC,yBAAyB;YAiBnB,oBAAoB;CAOnC"}
|
package/dist/signing/verifier.js
CHANGED
|
@@ -57,6 +57,19 @@ function isAllowedAlgorithm(alg, allowed) {
|
|
|
57
57
|
function isFiniteNumericDate(value) {
|
|
58
58
|
return typeof value === 'number' && Number.isFinite(value);
|
|
59
59
|
}
|
|
60
|
+
function assertFiniteNumericDateClaim(payload, claim) {
|
|
61
|
+
const value = payload[claim];
|
|
62
|
+
if (value !== undefined && !isFiniteNumericDate(value)) {
|
|
63
|
+
throw new JwtInvalidTokenError(`JWT ${claim} claim must be a finite numeric date.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function resolveClockSkewSeconds(clockSkewSeconds) {
|
|
67
|
+
const clockSkew = clockSkewSeconds ?? 0;
|
|
68
|
+
if (!Number.isFinite(clockSkew) || clockSkew < 0) {
|
|
69
|
+
throw new JwtConfigurationError('JWT clockSkewSeconds must be a non-negative finite number.');
|
|
70
|
+
}
|
|
71
|
+
return clockSkew;
|
|
72
|
+
}
|
|
60
73
|
function createKeyResolutionState(keys) {
|
|
61
74
|
const state = {
|
|
62
75
|
hmacKeyCount: 0,
|
|
@@ -306,10 +319,12 @@ class DefaultJwtVerifier {
|
|
|
306
319
|
}
|
|
307
320
|
validateTokenClaims(payload, options) {
|
|
308
321
|
const now = Math.floor(Date.now() / 1000);
|
|
309
|
-
const clockSkew = options.clockSkewSeconds
|
|
322
|
+
const clockSkew = resolveClockSkewSeconds(options.clockSkewSeconds);
|
|
310
323
|
if (options.requireExp !== false && typeof payload.exp !== 'number') {
|
|
311
324
|
throw new JwtInvalidTokenError('JWT is missing a required expiration claim.');
|
|
312
325
|
}
|
|
326
|
+
assertFiniteNumericDateClaim(payload, 'exp');
|
|
327
|
+
assertFiniteNumericDateClaim(payload, 'nbf');
|
|
313
328
|
this.validateMaxAgeClaims(payload, options.maxAge, clockSkew, now);
|
|
314
329
|
if (typeof payload.exp === 'number' && payload.exp + clockSkew < now) {
|
|
315
330
|
throw new JwtExpiredTokenError();
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"signing",
|
|
10
10
|
"verification"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.4",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@fluojs/core": "^1.0.0-beta.
|
|
40
|
-
"@fluojs/di": "^1.0.0-beta.
|
|
41
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
39
|
+
"@fluojs/core": "^1.0.0-beta.5",
|
|
40
|
+
"@fluojs/di": "^1.0.0-beta.7",
|
|
41
|
+
"@fluojs/runtime": "^1.0.0-beta.12"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"vitest": "^3.2.4"
|