8 examples of 'jwt expiration time format' in JavaScript

Every line of 'jwt expiration time format' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
33function getTokenExpiredDate(token) {
34 return jwtHelper.getTokenExpirationDate(token);
35}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

148public getTokenExpirationDate(token:string) {
149 var decoded: any;
150 decoded = this.decodeToken(token);
151
152 if(typeof decoded.exp === "undefined") {
153 return null;
154 }
155
156 var date = new Date(0); // The 0 here is the key, which sets the date to the epoch
157 date.setUTCSeconds(decoded.exp);
158
159 return date;
160}
26isExpired(offsetSeconds: number = 0): boolean {
27 const decoded = this.payload;
28 if (!decoded.hasOwnProperty('exp')) return null;
29
30 const date = new Date(0);
31 date.setUTCSeconds(decoded.exp);
32
33 return !(date.valueOf() > (new Date().valueOf() + (offsetSeconds * 1000)));
34}
143public get tokenExpirationTime(): number | undefined {
144 return this.internalConfiguration.tokenExpirationTime;
145}
16export default function tokenExpiration(when) {
17 // We pass when through the Date constructor for backwards compatibility;
18 // `when` used to be a number.
19 return new Date((new Date(when)).getTime() + tokenLifetimeMs);
20}
29get activationTokenExpiry() {
30 return this.userData.activationTokenExpiry;
31}
63getTokenExpDate(): Date {
64 const decoded = this.getPayload();
65 if (!decoded.hasOwnProperty('exp')) {
66 return null;
67 }
68
69 const date = new Date(0);
70 date.setUTCSeconds(decoded.exp);
71
72 return date;
73}
135getExpiryDate() {
136 return JSON.stringify(new Date(this.expiresAt));
137}

Related snippets