import { getClaims } from './getClaims' ; import { Jwt } from './Jwt' ; const expirationKey = 'exp' ; export function getExpiration ( jwt ) { const claims = getClaims ( jwt ) ; if ( expirationKey in claims && typeof claims [ expirationKey ] === 'number' ) { const seconds = claims [ expirationKey ] as number ; const milliseconds = seconds * 1000 ; return new Date ( milliseconds ) ; } return new Date ( Date . now ( ) - 1 ) ; }