-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (43 loc) · 1.53 KB
/
index.js
File metadata and controls
49 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const jwt = require('jsonwebtoken');
const jwtPassword = 'secret';
/**
* Generates a JWT for a given username and password.
*
* @param {string} username - The username to be included in the JWT payload.
* Must be a valid email address.
* @param {string} password - The password to be included in the JWT payload.
* Should meet the defined length requirement (e.g., 6 characters).
* @returns {string|null} A JWT string if the username and password are valid.
* Returns null if the username is not a valid email or
* the password does not meet the length requirement.
*/
function signJwt(username, password) {
// Your code here
}
/**
* Verifies a JWT using a secret key.
*
* @param {string} token - The JWT string to verify.
* @returns {boolean} Returns true if the token is valid and verified using the secret key.
* Returns false if the token is invalid, expired, or not verified
* using the secret key.
*/
function verifyJwt(token) {
// Your code here
}
/**
* Decodes a JWT to reveal its payload without verifying its authenticity.
*
* @param {string} token - The JWT string to decode.
* @returns {object|false} The decoded payload of the JWT if the token is a valid JWT format.
* Returns false if the token is not a valid JWT format.
*/
function decodeJwt(token) {
// Your code here
}
module.exports = {
signJwt,
verifyJwt,
decodeJwt,
jwtPassword,
};