@carecard/jwt-read 3.0.7 → 3.0.11

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/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { Request, Response, NextFunction } from 'express';
8
8
  * Basic structure of a JWT payload as used in this package.
9
9
  */
10
10
  export interface JwtPayload {
11
- client_id?: string;
11
+ sub?: string;
12
12
  exp?: number;
13
13
  iat?: number;
14
14
  roles?: string[];
@@ -76,12 +76,12 @@ export function verifyWebTokenNoThrow(publicKey: string, headerName: string): (r
76
76
  export function verifyVisitorNoThrow(publicKey: string): (req: AuthenticatedRequest, res: Response, next: NextFunction) => void;
77
77
 
78
78
  /**
79
- * Returns the client_id from the extracted JWT in req.jwt.
79
+ * Returns the sub from the extracted JWT in req.jwt.
80
80
  */
81
81
  export function jwtClientId(req?: any): string | undefined;
82
82
 
83
83
  /**
84
- * Returns the client_id from the extracted visitor token in req.visitor.
84
+ * Returns the sub from the extracted visitor token in req.visitor.
85
85
  */
86
86
  export function visitorClientId(req?: any): string | undefined;
87
87
 
package/lib/jwtLib.js CHANGED
@@ -7,12 +7,12 @@ const {
7
7
 
8
8
  function jwtClientId(req) {
9
9
  const jwtObj = req?.jwt || this;
10
- return jwtObj?.payload?.client_id;
10
+ return jwtObj?.payload?.sub;
11
11
  }
12
12
 
13
13
  function visitorClientId(req) {
14
14
  const visitorObj = req?.visitor || this;
15
- return visitorObj?.payload?.client_id;
15
+ return visitorObj?.payload?.sub;
16
16
  }
17
17
 
18
18
  function doesJwtUserHasRole(req, userRole) {
@@ -188,7 +188,6 @@ function verifyJwtAndRole(role, publicKey, customErrorFunction) {
188
188
  _isLoginRequired(isRoleExist, customErrorFunction);
189
189
  next();
190
190
  } catch (err) {
191
- console.error('verifyJwtAndRole error:', err);
192
191
  next(err);
193
192
  }
194
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/jwt-read",
3
- "version": "3.0.7",
3
+ "version": "3.0.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/CareCard-ca/pkg-jwt-read.git"
@@ -28,8 +28,8 @@
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "dependencies": {
31
- "@carecard/auth-util": "3.0.6",
32
- "@carecard/common-util": "3.0.7",
33
- "@carecard/validate": "3.0.7"
31
+ "@carecard/auth-util": "3.0.10",
32
+ "@carecard/common-util": "3.0.10",
33
+ "@carecard/validate": "3.0.10"
34
34
  }
35
35
  }