Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObeliskClient

The ObeliskClient is the main entrypoint for using the library.

Hierarchy

  • ObeliskClient

Implements

Index

Constructors

constructor

  • Create a new client. You need to call init() before using it!

    Parameters

    • optionsObjectOrUrl: ClientOptions | string
    • Optional eventObserver: Observer<ClientEvent>

      Optionally you can add an observer that listens to the ClientEvents from the very start.

    Returns ObeliskClient

Accessors

events

  • Returns hot observable that sends ClientEvents when they happen.

    inheritdoc

    Returns Observable<ClientEvent>

isAuthReady$

  • get isAuthReady$(): Observable<void>
  • Once this observable returns, the authentication procedure is over. This is usefull for any Auth checking (eg. Auth Guards)

    inheritdoc

    Returns Observable<void>

options

  • The client options used at contstruction time.

    inheritdoc

    Returns ClientOptions

tokens

  • A cache of all currently known and defined tokens.

    inheritdoc

    Returns Tokens

Methods

clearClientCredentials

  • clearClientCredentials(): void
  • Client credentials will be cleared from Session storage, if they were present

    Returns void

createLoginUrl

  • createLoginUrl(loginOptions?: undefined | { offline_access?: undefined | false | true; prompt?: "none" | "login"; redirectUri?: undefined | string }): string
  • inheritdoc

    Parameters

    • Optional loginOptions: undefined | { offline_access?: undefined | false | true; prompt?: "none" | "login"; redirectUri?: undefined | string }

    Returns string

createLogoutUrl

  • createLogoutUrl(redirectUri?: undefined | string): string
  • inheritdoc

    Parameters

    • Optional redirectUri: undefined | string

    Returns string

endpoint

  • Construct a regular Endpoint instance. This is an endpoint that does not return a Temporal Page..

    Parameters

    • uri: string

      The uri pointing to a valid - non-Temporal-Page-returning - Obelisk API endpoint.

    • Default value apiVersion: ApiVersion = "v1"

    Returns Endpoint

getNewRpt

  • getNewRpt(ticket?: undefined | string): Observable<Token>
  • Returns an observable to get a new RPT. Call this after init() if you want to have an RPT available immediatly

    Parameters

    • Optional ticket: undefined | string

      Optional ticket used for authMode 'uma'

    Returns Observable<Token>

graphQLEndpoint

init

  • init(): Observable<boolean>
  • Initializes the client with the Authorization server, logging in if logged in previously. Must be called before any authed calls can be made!

    Returns Observable<boolean>

    Observable boolean stating whether init performed a login with the hash url.

isLoggedIn

  • isLoggedIn(): boolean
  • Checks locally if logInfo is present in storage and not expired. Good condition for using in a Guard.

    Returns boolean

keepSessionAlive

  • keepSessionAlive(leeway?: number): Observable<boolean>
  • inheritdoc

    Parameters

    • Default value leeway: number = 3000

    Returns Observable<boolean>

login

  • login(loginOptions?: undefined | { offline_access?: undefined | false | true; prompt?: "none" | "login"; redirectUri?: undefined | string }): void
  • inheritdoc

    Parameters

    • Optional loginOptions: undefined | { offline_access?: undefined | false | true; prompt?: "none" | "login"; redirectUri?: undefined | string }

    Returns void

loginAsClient

  • loginAsClient(clientId: string, clientSecret: string): Observable<Token>
  • Login as client. This can be used to login as the client itself. It will immediatly request an RPT token and return that.

    Parameters

    • clientId: string
    • clientSecret: string

    Returns Observable<Token>

logout

  • logout(redirectUri?: undefined | string): void
  • Do logout, by changing the url with a client side redirect.

    Parameters

    • Optional redirectUri: undefined | string

      Optional redirectUri to return to after logout, defaults to current url;

    Returns void

rawEndpoint

  • Construct a regular Endpoint instance. This is a raw endpoint that does no checking on what datastructure is returend.

    Parameters

    • uri: string

      The uri pointing to a valid endpoint.

    • Default value apiVersion: ApiVersion = "v1"

    Returns Endpoint

refreshPatToken

  • refreshPatToken(): Observable<boolean>
  • Only for refreshing the PAT token. Only meant for some specific cases

    Returns Observable<boolean>

refreshRptToken

  • refreshRptToken(): Observable<boolean>
  • Only for refreshing the RPT token. Only meant for some specific cases

    Returns Observable<boolean>

rptHasRole

  • rptHasRole(role: string, targetClientId?: undefined | string): boolean
  • Checks the decoded RPT token for the presence of the given role string

    Parameters

    • role: string

      String of a role to check for in the RPT token

    • Optional targetClientId: undefined | string

      String of the targetClientId to check the roles for. Defaults to the Obelisk API id

    Returns boolean

streamEndpoint

  • Constructs a StreamEndpoint instance.

    Parameters

    • uri: string

      The uri pointing to a valid event stream (SSE) andpoint. (ends on /sse)

    • Default value apiVersion: ApiVersion = "v1"

    Returns StreamEndpoint

temporalPageEndpoint

  • Construct an TPageEndpoint instance that you can query to get data. This should be an endpoint that returns a Temporal Page.

    Parameters

    • uri: string

      The uri pointing to a valid - Temporal-Page-returning - Obelisk API endpoint.

    • Default value apiVersion: ApiVersion = "v1"

    Returns TPageEndpoint