Options
All
  • Public
  • Public/Protected
  • All
Menu

CrossidClient performs OAuth2 authorization code flow using the PKCE extension. A typical application will only need a sigle instance of this client. In more advanced cases, such as a single SPA app that requires interaction with multiple oauth2 clients, a client instance should be created per OAuth client id.

const opts = {
...
}
const crossid = new CrossidClient(opts)

Hierarchy

  • Client

Index

Constructors

constructor

Methods

createLogoutRedirectURL

  • createLogoutRedirectURL(opts?: LogoutOpts): Promise<string>
  • Creates a redirect URL that can be used to start an logout flow.

    This method is useful when you want control over the actual redirection, if you want browser to be redirected, call logoutWithRedirect instead.

    const url = createLogoutRedirectURL()
    window.location.assign(url)
    

    Parameters

    • opts: LogoutOpts = {}

      custom options that affects the logout flow.

    Returns Promise<string>

    a URL where the browser should be redirected to in order to logout.

createRedirectURL

  • Creates a redirect URL that can be used to start an authorization code request.

    This method is useful when you want control over the actual redirection, if you want browser to be redirected, call loginWithRedirect instead.

    const url = createRedirectURL()
    window.location.assign(url)
    

    Parameters

    • opts: AuthorizationOpts = {}

      custom options that affects the authorization code process.

    Returns Promise<string>

    a URL where the browser should be redirected to in order to login.

createSignupUrl

getAccessToken

  • Returns an access token.

    Parameters

    • opts: GetAccessTokenOpts = {}

      options to get an access token for a more specific authentication.

    Returns Promise<string>

    a promise which resolves to an access token string.

getUser

  • Returns an authenticated User.

    Type parameters

    Parameters

    • opts: GetUserOpts = {}

      options to get a user for a more specific authentication.

    Returns Promise<E>

    a promise which resolves to a User or undefined if no authenticated user found.

handleLogoutRedirectCallback

  • handleLogoutRedirectCallback(url?: URL): Promise<LogoutCompleteResponse>
  • Call this method in order to complete logout flow. this method should be called after the End-User sucessfully logs out.

    note that this method only works if the logout was performed for a specific client.

    Parameters

    • url: URL = ...

      the URL returned from the logout endpoint, defaults to window.location.href

    Returns Promise<LogoutCompleteResponse>

handleRedirectCallback

  • handleRedirectCallback(url?: URL): Promise<LoginCompleteResponse>
  • Call this method in order to complete authentication flow. this method should be called after the End-User sucessfully signs-in.

    Parameters

    • url: URL = ...

      the URL returned from the authorization code endpoint, defaults to window.location.href

    Returns Promise<LoginCompleteResponse>

introspectAccessToken

  • introspectAccessToken returns the decoded claims of the access token. handful for protecting spa routes by claims such 'scp'

    note: this method does not actually perform idp introspection nor checks the validity of the token.

    Parameters

    Returns Promise<JWTClaims>

loginWithRedirect

logoutWithRedirect

signupWithRedirect