Interface AuthAPI

Authentication API methods Generally you won't need to call these methods directly - RevClient instances use them internally to maintain an authentication session.

The exception is the AuthAPI.buildOAuth2Authentication and AuthAPI.loginOAuth2 methods, which can be used when building an OAuth2 authentication flow.

interface AuthAPI {
    buildOAuthAuthenticationQuery: (
        config: Config,
        oauthSecret: string,
        state?: string,
    ) => Promise<
        {
            apiKey: string;
            redirect_uri: string;
            response_type: string;
            signature: string;
            state: string;
            verifier: string;
        },
    >;
    parseOAuthRedirectResponse: (
        url: string | Record<string, string> | URLSearchParams | URL,
    ) => RedirectResponse;
    get logoutToken(): (apiKey: string) => Promise<void>;
    get logoutUser(): (userId: string) => Promise<void>;
    buildOAuth2Authentication(
        config: ServerConfig,
        state?: string,
        verifier?: string,
    ): Promise<AuthenticationData>;
    buildOAuthAuthenticationURL(
        config: Config,
        oauthSecret: string,
        state?: string,
    ): Promise<string>;
    extendSession(): Promise<ExtendResponse>;
    extendSessionOAuth(
        config: Config,
        refreshToken: string,
    ): Promise<OAuth.LoginResponse>;
    extendSessionToken(apiKey: string): Promise<ExtendResponse>;
    extendSessionUser(userId: string): Promise<ExtendResponse>;
    loginGuestRegistration(
        webcastId: string,
        jwtToken: string,
        options?: RequestOptions,
    ): Promise<GuestRegistrationResposne>;
    loginJWT(
        jwtToken: string,
        options?: RequestOptions,
    ): Promise<JWTLoginResponse>;
    loginOAuth(config: Config, authCode: string): Promise<OAuth.LoginResponse>;
    loginOAuth2(
        config: Config,
        code: string,
        codeVerifier: string,
        options?: RequestOptions,
    ): Promise<AuthTokenResponse>;
    loginToken(
        apiKey: string,
        secret: string,
        options?: RequestOptions,
    ): Promise<Auth.LoginResponse>;
    loginUser(
        username: string,
        password: string,
        options?: RequestOptions,
    ): Promise<UserLoginResponse>;
    logoffToken(apiKey: string): Promise<void>;
    logoffUser(userId: string): Promise<void>;
    verifySession(): Promise<void>;
}

Hierarchy

  • API
    • AuthAPI

Properties

buildOAuthAuthenticationQuery: (
    config: Config,
    oauthSecret: string,
    state?: string,
) => Promise<
    {
        apiKey: string;
        redirect_uri: string;
        response_type: string;
        signature: string;
        state: string;
        verifier: string;
    },
> = buildLegacyOAuthQuery

Type declaration

    • (
          config: Config,
          oauthSecret: string,
          state?: string,
      ): Promise<
          {
              apiKey: string;
              redirect_uri: string;
              response_type: string;
              signature: string;
              state: string;
              verifier: string;
          },
      >
    • Constructs the query parameters for the Rev /oauth/authorization endpoint

      Parameters

      • config: Config

        OAuth signing settings, retrieved from Rev Admin -> Security -> API Keys page, along with revUrl

      • oauthSecret: string
      • state: string = '1'

        optional state to pass back to redirectUri once complete

      Returns Promise<
          {
              apiKey: string;
              redirect_uri: string;
              response_type: string;
              signature: string;
              state: string;
              verifier: string;
          },
      >

      A valid oauth flow endpoint + query

parseOAuthRedirectResponse: (
    url: string | Record<string, string> | URLSearchParams | URL,
) => RedirectResponse = parseLegacyOAuthRedirectResponse

Type declaration

    • (url: string | Record<string, string> | URLSearchParams | URL): RedirectResponse
    • Parse the query parameters returned to the redirectUri from Rev

      Parameters

      • url: string | Record<string, string> | URLSearchParams | URL

        The URL with query parameters, or object with the query parrameters

      Returns RedirectResponse

Accessors

  • get logoutToken(): (apiKey: string) => Promise<void>
  • Returns (apiKey: string) => Promise<void>

    • use logoffToken - put here because it's a common misspelling
  • get logoutUser(): (userId: string) => Promise<void>
  • Returns (userId: string) => Promise<void>

    • use logoffUser - put here because it's a common misspelling

Methods

  • generate the Authorization URL for the OAuth2 flow as well as the codeVerifier for the subsequent Access Token request. You must store the codeVerifier somehow (i.e. serverside database matched to user's state/cookies/session, or on browser SessionStorage) to be able to complete the OAuth2 login flow.

    Parameters

    • config: ServerConfig

      OAuth signing settings, retrieved from Rev Admin -> Security -> API Keys page

    • state: string = '1'

      optional state to pass back to redirectUri once complete

    • Optionalverifier: string

      the code_verifier to use when generating the code challenge. Can be any string 43-128 characters in length, just these characters: [A-Za-z0-9._~-]. If not provided then code will automatically generate a suitable value

    Returns Promise<AuthenticationData>

    A valid oauth flow URL + the code_verifier to save for later verification

  • Parameters

    • config: Config

      OAuth signing settings, retrieved from Rev Admin -> Security -> API Keys page

    • oauthSecret: string

      Secret from Rev Admin -> Security. This is a DIFFERENT value from the User Secret used for API login. Do not expose client-side!

    • state: string = '1'

      optional state to pass back to redirectUri once complete

    Returns Promise<string>

    A valid oauth flow URL

  • Parameters

    • apiKey: string

    Returns Promise<void>

  • Parameters

    • userId: string

    Returns Promise<void>

  • Returns Promise<void>