Skip to content

Commit

Permalink
Merge pull request #4 from Hampfh/main
Browse files Browse the repository at this point in the history
fix: Allow async getRefreshToken
  • Loading branch information
pyncz authored Dec 28, 2023
2 parents 8a046c2 + 3decc8a commit 472c92f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const refreshTokenLink = <TRouter extends AnyRouter = AnyRouter>(opts: Re
onUnauthorized?.()

// Try to get a new jwt pair if the refresh token is stored
const refreshToken = getRefreshToken()
const refreshToken = await getRefreshToken()

if (refreshToken) {
refreshState.promise = (async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/models/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface RefreshTokenLinkOptions {
* Get locally stored refresh token
* @returns Refresh token string or undefined
*/
getRefreshToken: () => string | undefined
getRefreshToken: () => Promise<string | undefined> | string | undefined

/**
* Fetch a new JWT pair by refresh token from your API
Expand Down

0 comments on commit 472c92f

Please sign in to comment.