@dws-std/jwt 1.0.1 → 1.1.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.
- package/dist/index.d.ts +1 -2
- package/dist/index.js +7 -8
- package/dist/jwt.d.ts +9 -2
- package/package.json +7 -7
- package/dist/constant/jwt-error-keys.d.ts +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { JWT_ERROR_KEYS } from './
|
|
2
|
-
export { signJWT, verifyJWT, type VerifyOptions } from './jwt';
|
|
1
|
+
export { JWT_ERROR_KEYS, signJWT, verifyJWT, type VerifyOptions } from './jwt';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/constant/jwt-error-keys.ts
|
|
3
|
-
var JWT_ERROR_KEYS = {
|
|
4
|
-
JWT_SECRET_TOO_WEAK: "jwt.secret_too_weak",
|
|
5
|
-
JWT_EXPIRATION_PASSED: "jwt.expiration_passed",
|
|
6
|
-
JWT_SIGN_ERROR: "jwt.sign_error",
|
|
7
|
-
JWT_EXPIRED: "jwt.token_expired",
|
|
8
|
-
JWT_UNAUTHORIZED: "jwt.unauthorized"
|
|
9
|
-
};
|
|
10
2
|
// src/jwt.ts
|
|
11
3
|
import { parseHumanTimeToSeconds } from "@dws-std/common";
|
|
12
4
|
import { Exception } from "@dws-std/error";
|
|
13
5
|
import { SignJWT, errors, jwtVerify } from "jose";
|
|
6
|
+
var JWT_ERROR_KEYS = {
|
|
7
|
+
JWT_SECRET_TOO_WEAK: "jwt.secret-too-weak",
|
|
8
|
+
JWT_EXPIRATION_PASSED: "jwt.expiration-passed",
|
|
9
|
+
JWT_SIGN_ERROR: "jwt.sign-error",
|
|
10
|
+
JWT_EXPIRED: "jwt.token-expired",
|
|
11
|
+
JWT_UNAUTHORIZED: "jwt.unauthorized"
|
|
12
|
+
};
|
|
14
13
|
var _textEncoder = new TextEncoder;
|
|
15
14
|
var signJWT = (secret, payload, expiration = 60 * 15) => {
|
|
16
15
|
if (secret.length < 32)
|
package/dist/jwt.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type JWTPayload, type JWTVerifyResult } from 'jose';
|
|
2
|
+
export declare const JWT_ERROR_KEYS: {
|
|
3
|
+
readonly JWT_SECRET_TOO_WEAK: "jwt.secret-too-weak";
|
|
4
|
+
readonly JWT_EXPIRATION_PASSED: "jwt.expiration-passed";
|
|
5
|
+
readonly JWT_SIGN_ERROR: "jwt.sign-error";
|
|
6
|
+
readonly JWT_EXPIRED: "jwt.token-expired";
|
|
7
|
+
readonly JWT_UNAUTHORIZED: "jwt.unauthorized";
|
|
8
|
+
};
|
|
2
9
|
export interface VerifyOptions {
|
|
3
10
|
issuer?: string;
|
|
4
11
|
audience?: string | string[];
|
|
@@ -10,7 +17,7 @@ export interface VerifyOptions {
|
|
|
10
17
|
* @param payload - The JWT payload claims
|
|
11
18
|
* @param expiration - Token expiration as seconds offset, Date, or human-readable string (default: 15 minutes)
|
|
12
19
|
*
|
|
13
|
-
* @throws ({@link Exception})
|
|
20
|
+
* @throws ({@link Exception}) - If secret is too short, expiration is in the past, or signing fails
|
|
14
21
|
*
|
|
15
22
|
* @returns A Promise resolving to the signed JWT string
|
|
16
23
|
*/
|
|
@@ -22,7 +29,7 @@ export declare const signJWT: (secret: string, payload: JWTPayload, expiration?:
|
|
|
22
29
|
* @param secret - The secret key used for HS256 verification
|
|
23
30
|
* @param options - Optional verification options for issuer/audience validation
|
|
24
31
|
*
|
|
25
|
-
* @throws ({@link Exception})
|
|
32
|
+
* @throws ({@link Exception}) - 401 if token is expired, invalid signature, malformed, or claim validation fails
|
|
26
33
|
*
|
|
27
34
|
* @returns The verification result with payload and protected header
|
|
28
35
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dws-std/jwt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "JWT utilities and helpers for secure token management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "https://github.com/Dominus-Web-Service/std",
|
|
21
|
-
"directory": "packages/
|
|
21
|
+
"directory": "packages/jwt"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist"
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"test": "bun test --pass-with-no-tests --coverage"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@dws-std/common": "^1.0
|
|
45
|
-
"@dws-std/error": "^2.
|
|
44
|
+
"@dws-std/common": "^1.1.0",
|
|
45
|
+
"@dws-std/error": "^2.2.0",
|
|
46
46
|
"jose": "^6.2.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/bun": "^1.3.
|
|
49
|
+
"@types/bun": "^1.3.12",
|
|
50
50
|
"oxfmt": "0.44.0",
|
|
51
51
|
"oxlint": "1.59.0",
|
|
52
52
|
"oxlint-tsgolint": "0.20.0",
|
|
53
53
|
"typescript": "^6.0.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@dws-std/common": "^1.0
|
|
57
|
-
"@dws-std/error": "^2.
|
|
56
|
+
"@dws-std/common": "^1.1.0",
|
|
57
|
+
"@dws-std/error": "^2.2.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const JWT_ERROR_KEYS: {
|
|
2
|
-
readonly JWT_SECRET_TOO_WEAK: "jwt.secret_too_weak";
|
|
3
|
-
readonly JWT_EXPIRATION_PASSED: "jwt.expiration_passed";
|
|
4
|
-
readonly JWT_SIGN_ERROR: "jwt.sign_error";
|
|
5
|
-
readonly JWT_EXPIRED: "jwt.token_expired";
|
|
6
|
-
readonly JWT_UNAUTHORIZED: "jwt.unauthorized";
|
|
7
|
-
};
|