File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
const jwt = require ( "jsonwebtoken" ) ;
2
2
3
- // Constants .
3
+ // JWT constants .
4
4
const JWT_PUBLIC_KEY = process . env . JWT_PUBLIC_KEY ;
5
+ const JWT_RS256_ALGORITHM = "RS256" ;
6
+
7
+ // General constants.
8
+ const STRING_TYPE = "string" ;
5
9
6
10
exports . handler = async ( event ) => {
7
11
// Gets event header.
8
12
const header =
9
- typeof event . header === "string" ? JSON . parse ( event . header ) : event . header ;
13
+ typeof event . header === STRING_TYPE
14
+ ? JSON . parse ( event . header )
15
+ : event . header ;
10
16
11
17
// Needs to be authorized by a given token.
12
18
const token = header . token ;
@@ -15,7 +21,7 @@ exports.handler = async (event) => {
15
21
const jwtSettings = {
16
22
publicKey : JWT_PUBLIC_KEY ,
17
23
options : {
18
- algorithms : [ "RS256" ] ,
24
+ algorithms : [ JWT_RS256_ALGORITHM ] ,
19
25
} ,
20
26
} ;
21
27
You can’t perform that action at this time.
0 commit comments