• Check token handler

    Parameters

    • onetimeTokenService: OnetimeTokenService

      injected service use to handle the onetime token related operations

      • isValidOnetimeToken
      • invalidateToken
    • authSecrets: AuthSecrets

      authenticate secrets

    • authenticate: AuthenticationFunction

      custom authentication function

    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

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

      • body.fingerprint defaulted to empty string
      • body.target defaulted to undefined

    Returns Promise<CheckTokeHandlerResponse>

    200 Status OK

    // If token type is access
    {
    data: {
    userId: string;
    },
    status: number;
    }

    // If token type is onetime
    {
    data: object;
    status: number;
    }

    Description

    This handler will create check token by applying the following steps in sequence:

    1. Get token, fingerprint, target from request body

    2. Get ip and host from request info

    3. Check token (crypto.checkJWT)

    4. Check token type (access or onetime)

    5. If token type is access, check passes security checks and then return userId

    6. If token type is onetime, check request token

    6.1. If request token is undefined, throw NBError

    6.2. If request token is not app access token, throw NBError

    6.3. If request token is app access token, check token is valid (onetimeTokenService.isValidOnetimeToken)

    6.3.1. If token is valid, invalidate token (onetimeTokenService.invalidateToken) and return token data

    6.3.2. If token is invalid, throw NBError

    Throws

    400 NBError Bad Request

    • invalid token
    • you don't have permission to check the token

    Throws

    403 NBError Forbidden

    • you don't have permission to check the token

Generated using TypeDoc