@dws-std/jwt 1.3.0 → 1.4.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/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="https://cdn.jsdelivr.net/gh/Dominus-Web-Service/std@main/packages/jwt/logo-jwt.png" alt="DWS JWT logo" width="200" />
3
+ </p>
4
+
1
5
  # 🔐 DWS JWT
2
6
 
3
7
  Signing and verifying JWTs shouldn't require boilerplate.
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 _textEncoder = new TextEncoder;
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(_textEncoder.encode(secret));
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, _textEncoder.encode(secret), {
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.0",
3
+ "version": "1.4.1",
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.2.1",
44
+ "@dws-std/error": "^2.3.1",
45
45
  "jose": "^6.2.3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/bun": "^1.3.14",
49
- "oxfmt": "0.54.0",
50
- "oxlint": "1.69.0",
49
+ "oxfmt": "0.56.0",
50
+ "oxlint": "1.71.0",
51
51
  "oxlint-tsgolint": "0.23.0",
52
52
  "typescript": "^6.0.3"
53
53
  },
54
54
  "peerDependencies": {
55
- "@dws-std/error": "^2.2.1"
55
+ "@dws-std/error": "^2.3.1"
56
56
  }
57
57
  }