@dws-std/jwt 1.3.0 → 1.4.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/dist/index.js +3 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var JWT_ERROR_KEYS = {
|
|
|
9
9
|
JWT_EXPIRED: "jwt.token-expired",
|
|
10
10
|
JWT_UNAUTHORIZED: "jwt.unauthorized"
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var textEncoder = new TextEncoder;
|
|
13
13
|
var signJWT = (secret, payload, expirationSeconds = 60 * 15) => {
|
|
14
14
|
if (secret.length < 32)
|
|
15
15
|
throw new Exception("Secret key must be at least 32 characters long", {
|
|
@@ -33,7 +33,7 @@ var signJWT = (secret, payload, expirationSeconds = 60 * 15) => {
|
|
|
33
33
|
...payload
|
|
34
34
|
};
|
|
35
35
|
try {
|
|
36
|
-
return new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(
|
|
36
|
+
return new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(textEncoder.encode(secret));
|
|
37
37
|
} catch (error) {
|
|
38
38
|
throw new Exception("Failed to sign JWT", {
|
|
39
39
|
key: JWT_ERROR_KEYS.JWT_SIGN_ERROR,
|
|
@@ -43,7 +43,7 @@ var signJWT = (secret, payload, expirationSeconds = 60 * 15) => {
|
|
|
43
43
|
};
|
|
44
44
|
var verifyJWT = async (token, secret, options) => {
|
|
45
45
|
try {
|
|
46
|
-
return await jwtVerify(token,
|
|
46
|
+
return await jwtVerify(token, textEncoder.encode(secret), {
|
|
47
47
|
algorithms: ["HS256"],
|
|
48
48
|
...options?.issuer && { issuer: options.issuer },
|
|
49
49
|
...options?.audience && { audience: options.audience }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dws-std/jwt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "JWT utilities and helpers for secure token management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"test": "bun test --pass-with-no-tests --coverage"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@dws-std/error": "^2.
|
|
44
|
+
"@dws-std/error": "^2.3.0",
|
|
45
45
|
"jose": "^6.2.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/bun": "^1.3.14",
|
|
49
|
-
"oxfmt": "0.
|
|
50
|
-
"oxlint": "1.
|
|
49
|
+
"oxfmt": "0.55.0",
|
|
50
|
+
"oxlint": "1.70.0",
|
|
51
51
|
"oxlint-tsgolint": "0.23.0",
|
|
52
52
|
"typescript": "^6.0.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@dws-std/error": "^2.
|
|
55
|
+
"@dws-std/error": "^2.3.0"
|
|
56
56
|
}
|
|
57
57
|
}
|