The main entry point for the OFCP App JS SDK

Constructors

  • The main entry point for the OFCP App JS SDK. This class should only be instantiated after the user has consented to the terms, conditions, and privacy policy!

    Parameters

    • tokenFN: (() => Promise<string>)

      A function that returns the customer token as a string inside a promise

        • (): Promise<string>
        • Returns Promise<string>

    • config: OfcpConfig = ...

      Advanced configuration for the SDK, rarely needed

    Returns TecsafeApi

    An error if the configuration is invalid

Methods

  • Adds an event listener to the SDK

    Parameters

    • event: ON_LOGIN_REQUEST

      The event to listen for, see EventType

    • listener: ((...args: any[]) => void)

      The listener to call when the event is triggered.

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns void

  • Closes the AppWidget full screen mode

    Parameters

    • destroy: boolean = false

      If true, the widget will be destroyed instead of hidden

    Returns void

  • Destroys all widgets, and resets the SDK to its initial state

    Returns Promise<void>

  • Get the browser ID, a random string that is stored in localStorage. This is NOT used for tracking, but to identify the browser if the user mistakenly shares the URL with OFCP data in it.

    Returns string

  • Gets all event listeners

    Returns {
        [key: string]: ((...args: any[]) => void)[];
    }

    An object with the event names as keys, and the listeners as values

    • [key: string]: ((...args: any[]) => void)[]
  • Gets the full screen data. It is not recommended to use this method directly.

    Returns any

    The full screen data

  • Gets the token, refreshing it if necessary. Utilizes a cache to prevent multiple requests, and only refreshes the token if it is expired (or refresh is true).

    Parameters

    • refresh: boolean = false

    Returns Promise<string>

    The token as a string inside a promise

  • Gets the timestamp (in milliseconds) when the token will expire

    Returns number

    The timestamp when the token will expire

  • Opens the AppWidget in full screen mode on the provided url

    Parameters

    • url: string

      The url to open in full screen

    Returns void

    An error if the url is not in the allowedOrigins list

    AppWidget

  • Refreshes the token and sends it to all widgets

    Parameters

    • Optionaltoken: string

      If provided, the token to use instead of fetching a new one with the tokenFN

    Returns Promise<void>

  • Removes an event listener from the SDK

    Parameters

    • event: ON_LOGIN_REQUEST

      The event to remove the listener from

    • listener: ((...args: any[]) => void)

      The listener to remove

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns void

  • Sends a message to all widgets

    Parameters

    • message: Message

      The message to send

    Returns void

  • Sets the full screen data. It is not recommended to use this method directly.

    Parameters

    • data: any

      The full screen data

    Returns void