• Refresh token handler

    Parameters

    • refreshTokenService: RefreshTokenService

      injected service use to handle the refresh token related operations

      • refreshAccessToken
    • configuration: {
          authSecrets: AuthSecrets;
          authType: AuthType;
          authenticateRefreshToken: AuthenticationRefreshTokenFunction;
          cookieConfig: false | CookieConfig;
          tokenExpireTime: {
              accessToken: string | number;
          };
      }

      injected configuration use to handle the configuration related operations

    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query]. Note:

      • body.findgerprint defaulted to ''

    Returns Promise<adapter.AdapterHandlerResponse>

    200 Status OK

    {
    data: {
    accessToken: string
    },
    status: 200
    }

    Description

    This handler will rotate token and generate a new access token by applying the following steps in sequence:

    1. Get token verification from request info

    2. Authenticate refresh token from context

    3. Generate a new refresh token (refreshTokenService.generateRefreshToken)

    4. Delete old refresh token (refreshTokenService.deleteRefreshToken)

    5. Refresh access token (refreshTokenService.refreshAccessToken)

    6. If authType is cookie, set cookie maxAge to 0

    7. Return access token

    Throws

    400 NBError Bad Request

    • Cannot find refreshToken from request
    • Refresh token is invalid
    • cookies is undefined in request
    • Invalid params

    Throws

    403 NBError Forbidden

    • refresh token not found

Generated using TypeDoc