@carecard/jwt-read 3.0.10 → 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 +3 -3
- package/lib/jwtLib.js +2 -2
- package/package.json +1 -1
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
|
-
|
|
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
|
|
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
|
|
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?.
|
|
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?.
|
|
15
|
+
return visitorObj?.payload?.sub;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function doesJwtUserHasRole(req, userRole) {
|