diff --git a/src/lhisp-oauth-client.t.ts b/src/lhisp-oauth-client.t.ts index 08e67ff..1e71b4d 100644 --- a/src/lhisp-oauth-client.t.ts +++ b/src/lhisp-oauth-client.t.ts @@ -30,7 +30,8 @@ export interface AccessToken { token_type: string; access_token: string; expires_in: number; - created_at: number; + scope?: string; + created_at?: number; } export enum GrantType { diff --git a/src/lhisp-oauth-client.ts b/src/lhisp-oauth-client.ts index 033d8e2..66e393c 100644 --- a/src/lhisp-oauth-client.ts +++ b/src/lhisp-oauth-client.ts @@ -70,8 +70,8 @@ export default class LhispOauthClient { isTokenValid(token: AccessToken){ if(!token) return false; - const now = Date.now() - const timeDiff = (now - token.created_at) / 1000; + if(!token.created_at) return false; + const timeDiff = (Date.now() - token.created_at) / 1000; return timeDiff < token.expires_in - 10; }