Skip to content

Commit

Permalink
feat(core): add refreshTokenAt method
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroAS51 authored and pi0 committed Mar 15, 2020
1 parent 1c6d5ad commit 75374e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/core/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export default class Auth {
return this._token.getStatus()
}

refreshTokenAt () {
return this._token.refreshAt()
}

// ---------------------------------------------------------------
// Refresh token helpers
// ---------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions lib/core/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export class Token {
getStatus () {
return new TokenStatus(this.get(), this._getExpiration)
}

refreshAt () {
return (this._getExpiration() - Date.now()) * 0.75
}
}

export class RefreshToken {
Expand Down

0 comments on commit 75374e1

Please sign in to comment.