Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
* demo: use type `NuxtConfig` in `nuxt.config.ts`

* feat: improve types

* feat(schemes): set constructor types

* refactor: rename contract `PartialOptions` to `SchemePartialOptions`

* feat(providers): add contracts `ProviderOptions` and `ProviderPartialOptions`

* feat(sanctum provider): improve types

* chore: fix lint

* refactor(sanctum provider): reorder extends

* fix(provider): fix type `ProviderPartialOptions`

* fix(schemes): `property` and `data` of `refreshToken` should accept `false`

* fix(schemes): fix types of `scope` and `endpoints`

* feat(jwt provider): improve types

* feat(passport provider): improve types

* refactor(sanctum provider): use `typeof strategy` for `DEFAULTS` type

* feat(github provider): improve types

* feat(facebook provider): improve types

* feat(google provider): improve types

* feat(auth0 provider): improve types

* feat(module): improve types

* chore(eslint): use recommended typescript rules

* feat(schemes): improve types

* feat(schemes): use `protected` and `private` modifiers

* fix(schemes): return type of logout should be `Promise<void> | void`

* fix(oauth2 scheme): return type of logout should be `void`

* feat(providers): improve types

* feat(inc): improve types

* feat(inc): use `private` modifiers

* fix(types): add plugins option to type `ModuleOptions`

* feat(types): improve option types of `ModuleOptions`

* feat(module): improve types

* fix(oauth2 scheme): use `+ ''` instead of `toString()`

* test: fix method names

* fix(token, refresh token): use type `string | boolean`

* feat(utils): improve types

* fix(types): add `ignoreExceptions` option to type `ModuleOptions`

* fix(scheme): fix type `Scheme`

* fix(scheme): fix type `RefreshableScheme`

* fix(refresh scheme): fix type of `setUserToken` params

* fix(core): fix property `tokenName` in `requestWith`

* fix(local scheme): fix return type of `mounted`

* fix(utils): fix types

* fix(inc): fix types

* feat(core): improve types

* chore(tsconfig): enable `resolveJsonModule`

* chore(eslint): fix extends order

* chore(dev-deps): add `vue` and `@types/lodash.get`

* chore(dev-deps): add @types/cookie-parser, @types/express-jwt, and @types/jsonwebtoken

* demo: improve types

* demo: update tsconfig

* chore: update tsconfig

* chore(scripts): use `import` instead of `require`

* fix(schemes): fix return type of `mounted`

* fix(utils): fix type of `encodeQuery`

* fix(local scheme): fix type of `login` endpoint in `LocalSchemeOptions`

* fix(providers): add `clientSecret` to type `ProviderOptions`

* feat(utils): improve types of provider utilities

* demo: update tsconfig

* demo: use `nuxt/components`

* demo: fix auth options

* demo(api): fix export default

* fix(module): set default value of `ignoreExceptions` to `false`

* test: improve types

* test: update tsconfig

* chore(jest): use `tsconfig` instead of `tsConfig`

The option `tsConfig` is deprecated and will be removed in ts-jest 27, use `tsconfig` instead.

* chore(jest): ignore fixture

* demo: convert api and store files back to js

* chore(eslint): ignore test/fixture

* fix: add `_` prefix to private methods

* refactor(providers): move contracts to index.ts

* refactor(schemes): move contracts to index.ts

* refactor(schemes): export scheme options directly in scheme file

* feat: export scheme and provider types at top level

* chore(tsconfig): set `baseUrl`

* chore(dev-deps): use `latest` version

* refactor: simplify types, update structure and use named exports

* refactor: type leftovers

* refactor: simplify and apply prettier rules

* refactor: update module and demo

* chore: show error trace in demo

* feat: throw better errors for invalid strategy

* fix typo in template

* update demo

* chore: fix lint errors

* fix custom scheme imports

* test: use @nuxt/test-utils

* feat(pkg): use siroc

* fix: resolve rescursive types

* update top level index.d

* fix getProp

* update ci

* remove dependency on nanoid and jwt-decode named exports

* fix demo types

* revert demo to custom vps because of sticky sessions

Co-authored-by: Pooya Parsa <>
3 contributors

Users who have contributed to this file

@JoaoPedroAS51 @pi0 @bramburn
import type { RefreshableScheme, HTTPResponse } from '../types'
import type { Auth } from '../core'
export class RefreshController {
public $auth: Auth
private _refreshPromise: Promise<HTTPResponse | void> = null
constructor(public scheme: RefreshableScheme) {
this.$auth = scheme.$auth
// Multiple requests will be queued until the first has completed token refresh.
handleRefresh(): Promise<HTTPResponse | void> {
// Another request has started refreshing the token, wait for it to complete
if (this._refreshPromise) {
return this._refreshPromise
return this._doRefresh()
// Returns a promise which is resolved when refresh is completed
// Call this function when you intercept a request with an expired token.
private _doRefresh(): Promise<HTTPResponse | void> {
this._refreshPromise = new Promise((resolve, reject) => {
.then((response) => {
this._refreshPromise = null
.catch((error) => {
this._refreshPromise = null
return this._refreshPromise