validate() {

		// Split into header and payload
		const parts = this.jwt.split(".");
		if(parts.length !== 3) { return false; }

		// Check if the token is still valid
		const header = JSON.parse(JWT.base64ToString(parts[0]));
		const payload = JSON.parse(JWT.base64ToString(parts[1]));

		// If it's not a JWT OR if it's not encoded as HS256, not valid
		if(header.typ !== "JWT" || header.alg !== "HS256") { return false; }


		const now = Math.floor(Date.now() / 1000) + 5;
		
		// If the token is not valid yet, return false
		if(now < payload.nbf) { return false; }

		// If we're before the issued at date, return false
		if(now < payload.iat) { return false; }

		// If the token has expired, return false
		if(now > payload.exp) { return false; }

		// Return that it's valid
		return true;

	}
/**
	 * Validates the token
	 * 
	 * @returns true if the JWT is valid
	 */
Validates the token

@returns true if the JWT is valid
Validates the token @returns true if the JWT is valid
validate() {
		const parts = this.jwt.split(".");
		if(parts.length !== 3) { return false; }
		const header = JSON.parse(JWT.base64ToString(parts[0]));
		const payload = JSON.parse(JWT.base64ToString(parts[1]));
		if(header.typ !== "JWT" || header.alg !== "HS256") { return false; }
		const now = Math.floor(Date.now() / 1000) + 5;
		if(now < payload.nbf) { return false; }
		if(now < payload.iat) { return false; }
		if(now > payload.exp) { return false; }
		return true;
	}
validate ( ) { const parts = this . jwt . split ( "." ) ; if ( parts . length !== 3 ) { return false ; } const header = JSON . parse ( JWT . base64ToString ( parts [ 0 ] ) ) ; const payload = JSON . parse ( JWT . base64ToString ( parts [ 1 ] ) ) ; if ( header . typ !== "JWT" || header . alg !== "HS256" ) { return false ; } const now = Math . floor ( Date . now ( ) / 1000 ) + 5 ; if ( now < payload . nbf ) { return false ; } if ( now < payload . iat ) { return false ; } if ( now > payload . exp ) { return false ; } return true ; }
Validates the token
Validates the token
// Split into header and payload // Check if the token is still valid // If it's not a JWT OR if it's not encoded as HS256, not valid // If the token is not valid yet, return false // If we're before the issued at date, return false // If the token has expired, return false // Return that it's valid