client.connect() for headless and
Identity API integrations — it handles authentication only, with no
payment-method setup or KYC steps. When the customer finishes, the SDK
decrypts the returned credentials and primes the client so that subsequent SDK
calls are authenticated automatically.
Call
client.getConnection()
first. The connection check primes the client with the token the Auth frame
needs. If you call setupAuth() without a prior connection check that
resolved with status: "connectionRequired", it returns a
configurationError.Setup auth
The promise returned by
client.setupAuth() resolves after the customer
completes the auth flow (or an error ends it). Track flow progress — including
the moment the UI is ready to show — through onEvent, not by awaiting the
promise.Parameters
| Field | Type | Required | Description |
|---|---|---|---|
container | HTMLElement | ✅ | A DOM element to render the Auth frame into. |
onEvent | (event: AuthEvent) => void | Callback invoked for auth flow events. See AuthEvent. |
AuthEvent
onEvent receives events as the auth flow progresses. Use event.kind to
decide how to handle each event.
| kind | Payload | When you receive it |
|---|---|---|
"ready" | — | The auth UI is rendered and ready to be shown. |
"complete" | Connection | The customer authenticated. status is "active", or "termsAcceptanceRequired" when a Terms of Use attestation is still outstanding. |
"error" | AuthEventError | The flow encountered an error. |
AuthEventError
The error event payload comes from the underlying auth frame. It is
discriminated by code.
| Field | Type | Required | Description |
|---|---|---|---|
code | "validationError" | "generic" | ✅ | The error category. |
errors | { code: string; message: string }[] | Field-level errors. Present when code is "validationError". | |
message | string | Developer-friendly details. May be present when code is "generic". |
Result
client.setupAuth() returns a Result<AuthFrame, SetupAuthError>.
Result envelope
Result<AuthFrame, SetupAuthError>
| Field | Type | Required | Description |
|---|---|---|---|
ok | boolean | ✅ | Whether the operation succeeded. |
value | AuthFrame | Present when ok is true. | |
error | SetupAuthError | Present when ok is false. |
AuthFrame
| Field | Type | Required | Description |
|---|---|---|---|
dispose | () => void | ✅ | Unmounts the frame. After you call this, no further events are dispatched to your onEvent callback. |
SetupAuthError
| Field | Type | Required | Description |
|---|---|---|---|
kind | "configurationError" | "genericError" | ✅ | The error category. "configurationError" means the client has no token from a prior connection check. |
message | string | ✅ | Developer-friendly details. |
TS Definitions
TS Definitions
types.ts