@kadanza/extension-sdk
    Preparing search index...

    Class ExtensionSDK

    Default IExtensionSDK implementation. Prefer createExtensionSDK.

    Implements

    Index
    • Calls the Kadanza Platform API with the current connection credentials.

      Requests go to getApiUrl + endpoint. Authorization and tenant headers are managed by the SDK and cannot be overridden.

      Type Parameters

      • T

        Expected JSON response body.

      Parameters

      • endpoint: string

        Root-relative API path.

      • options: RequestInit = {}

        Standard fetch options.

      Returns Promise<T>

      When not connected, handshake did not include authToken and extensionDetails (apiUrl or baseUrl, tenantDomain), the endpoint is invalid, the request fails, or the response is not successful JSON.

    • Establishes the parent connection and waits for HANDSHAKE_ACK.

      Safe to call repeatedly (e.g. from a React useEffect with deps):

      • Already connected: returns the cached handshake and re-applies authTokenAutoRefresh / authTokenBufferMs without another init. timeoutMs is ignored after connect.
      • Handshake in progress: returns the same in-flight promise. Options from the first connecting call apply until the handshake completes.

      Opt-in proactive refresh can be enabled with authTokenAutoRefresh: true (optional authTokenBufferMs).

      Pass routingType: "client-hash" for HashRouter SPAs so the parent can soft-navigate without reloading the iframe. Default is "server".

      Handshake completes when the parent sends HANDSHAKE_ACK. Context fields (authToken, extensionDetails, designTokens, pageSettings) are optional — omitted values are null. Use them only when the current host surface provides them (e.g. spaceId / pageId on Experience Pages, designTokens when a tenant is in context).

      Parameters

      • options: ConnectOptions = {}

        Handshake timeout, routing type, and optional auth-token auto-refresh.

      Returns Promise<HandshakePayload>

      When tenantUrl is missing or invalid.

      When not embedded in a parent frame, destroyed, or the handshake times out.

    • Tears down listeners, proactive refresh timers, and cached state. Rejects any in-flight requests. The instance cannot be reused after destroy. When created via createExtensionSDK, clears the singleton so a later create call can return a fresh instance.

      Returns void

    • Platform API base URL the parent uses for its own API calls.

      Returns handshake extensionDetails.apiUrl as sent. When the host omits it, falls back to deriving api.{hostname} from extensionDetails.baseUrl. null until connected, or when neither field is usable.

      Returns string | null