Skip to main content

TicketlayerLive

@ticketlayer/live


@ticketlayer/live / index / TicketlayerLive

Class: TicketlayerLive

Defined in: createLiveClient.ts:89

@ticketlayer/live - the buyer-facing client for the Ticketlayer Live surface.

The client surface (sales operations + session/queue) is GENERATED from the backstage sales-surface projection + the live-api spec (see client.ts). The only hand-written part is createLiveClient (browser/native ergonomics).

Runs in the browser and React Native (publishable key + X-Live-Session header

  • pluggable token storage). Web builds may additionally bundle @ticketlayer/elements; native apps use the headless client + webview checkout.

Accessors

hasSession

Get Signature

get hasSession(): boolean;

Defined in: createLiveClient.ts:347

True once a session has been created/resumed (i.e. a mutation has happened).

Returns

boolean


session

Get Signature

get session(): Readonly<SessionState>;

Defined in: createLiveClient.ts:342

Returns

Readonly<SessionState>

Constructors

Constructor

new TicketlayerLive(client: LiveClient, opts: {
baseUrl: string;
domain?: string;
publishableKey?: string;
sessionMode: "cookie" | "token";
}): TicketlayerLive;

Defined in: createLiveClient.ts:141

Parameters

ParameterType
clientLiveClient
opts{ baseUrl: string; domain?: string; publishableKey?: string; sessionMode: "cookie" | "token"; }
opts.baseUrlstring
opts.domain?string
opts.publishableKey?string
opts.sessionMode"cookie" | "token"

Returns

TicketlayerLive

Methods

emit()

emit(event: LiveEvent, payload?: unknown): void;

Defined in: createLiveClient.ts:338

Push an event onto the shared bus. Used by Elements/host to raise UI intents (e.g. ui:checkout-requested) that the host app acts on - the SDK relays but does not render UI itself.

Parameters

ParameterType
eventLiveEvent
payload?unknown

Returns

void


ensureSession()

ensureSession(): Promise<void>;

Defined in: createLiveClient.ts:357

Create the Live session on demand and hydrate state - idempotent and single-flight. Called lazily before the first mutation (cart/login); NOT on page load, so browsing never creates a session. Channel is identified by the publishable key (embed) or the storefront domain (hosted).

Returns

Promise<void>


getSessionToken()

getSessionToken(): Promise<string | null>;

Defined in: createLiveClient.ts:432

The current session token (token mode), for handing off to an embed iframe.

Returns

Promise<string | null>


off()

off(event: LiveEvent, handler: (payload?: unknown) => void): void;

Defined in: createLiveClient.ts:330

Parameters

ParameterType
eventLiveEvent
handler(payload?: unknown) => void

Returns

void


on()

on(event: LiveEvent, handler: (payload?: unknown) => void): () => void;

Defined in: createLiveClient.ts:327

Subscribe to a state event or UI intent; returns an unsubscribe fn.

Parameters

ParameterType
eventLiveEvent
handler(payload?: unknown) => void

Returns

() => void


refreshSession()

refreshSession(): Promise<void>;

Defined in: createLiveClient.ts:437

Re-read session state (customer, auth, cart) from the live-api session.

Returns

Promise<void>


resume()

resume(token: string): Promise<void>;

Defined in: createLiveClient.ts:425

Resume an EXISTING session by token instead of bootstrapping a new one. Used by the embedded checkout iframe: the third-party page hands off its session token so the iframe sees the same cart/channel (token transport).

Parameters

ParameterType
tokenstring

Returns

Promise<void>


resumeIfExists()

resumeIfExists(): Promise<boolean>;

Defined in: createLiveClient.ts:408

Rehydrate an ALREADY-EXISTING session (hosted/cookie transport) without creating one. On a page load/refresh the client is lazily session-less, but a returning visitor may still hold the live_session cookie with a cart server-side. This probes GET /session (a cheap read - it 401s when no session exists, and never writes one): on success it binds this client to that session and pulls the cart back in; on 401 it stays session-less so browsing still creates no session. Marking _sessionStarted on success is load-bearing - otherwise the next mutation's ensureSession() would POST a fresh session and orphan the existing cart.

Returns

Promise<boolean>

true if an existing session was resumed.


start()

start(opts?: {
domain?: string;
}): Promise<void>;

Defined in: createLiveClient.ts:390

Parameters

ParameterType
opts{ domain?: string; }
opts.domain?string

Returns

Promise<void>

Deprecated

Use ensureSession(); kept for back-compat.

Properties

auth

readonly auth: {
authenticated: boolean;
customer: unknown;
exchange: (proof:
| string
| {
assertion?: string;
code?: string;
type: string;
}) => Promise<unknown>;
logout: () => Promise<void>;
requestMagicLink: (contact: {
email?: string;
phone?: string;
}) => Promise<unknown>;
};

Defined in: createLiveClient.ts:121

authenticated

readonly authenticated: boolean;

customer

readonly customer: unknown;

exchange

exchange: (proof: 
| string
| {
assertion?: string;
code?: string;
type: string;
}) => Promise<unknown>;
Parameters
ParameterType
proof| string | { assertion?: string; code?: string; type: string; }
Returns

Promise<unknown>

logout

logout: () => Promise<void>;
Returns

Promise<void>

requestMagicLink: (contact: {
email?: string;
phone?: string;
}) => Promise<unknown>;
Parameters
ParameterType
contact{ email?: string; phone?: string; }
contact.email?string
contact.phone?string
Returns

Promise<unknown>


cart

readonly cart: {
add: (item: CartItemInput) => Promise<unknown>;
checkout: (opts?: {
customerNotes?: string;
}) => Promise<unknown>;
current: unknown;
ensure: () => Promise<string>;
id: string | null;
refresh: () => Promise<unknown>;
remove: (itemId: string) => Promise<unknown>;
};

Defined in: createLiveClient.ts:112

add

add: (item: CartItemInput) => Promise<unknown>;
Parameters
ParameterType
itemCartItemInput
Returns

Promise<unknown>

checkout

checkout: (opts?: {
customerNotes?: string;
}) => Promise<unknown>;
Parameters
ParameterType
opts?{ customerNotes?: string; }
opts.customerNotes?string
Returns

Promise<unknown>

current

readonly current: unknown;

ensure

ensure: () => Promise<string>;
Returns

Promise<string>

id

readonly id: string | null;

refresh

refresh: () => Promise<unknown>;
Returns

Promise<unknown>

remove

remove: (itemId: string) => Promise<unknown>;
Parameters
ParameterType
itemIdstring
Returns

Promise<unknown>


client

readonly client: LiveClient;

Defined in: createLiveClient.ts:91

The underlying generated client (escape hatch for un-wrapped calls).


events

readonly events: {
get: (eventId: string) => Promise<unknown>;
list: () => Promise<unknown>;
};

Defined in: createLiveClient.ts:110

get

get: (eventId: string) => Promise<unknown>;
Parameters
ParameterType
eventIdstring
Returns

Promise<unknown>

list

list: () => Promise<unknown>;
Returns

Promise<unknown>


orders

readonly orders: {
get: (orderId: string) => Promise<unknown>;
mine: () => Promise<unknown>;
ticketPdf: (orderId: string, passId: string) => Promise<Blob>;
};

Defined in: createLiveClient.ts:128

get

get: (orderId: string) => Promise<unknown>;
Parameters
ParameterType
orderIdstring
Returns

Promise<unknown>

mine

mine: () => Promise<unknown>;
Returns

Promise<unknown>

ticketPdf

ticketPdf: (orderId: string, passId: string) => Promise<Blob>;
Parameters
ParameterType
orderIdstring
passIdstring
Returns

Promise<Blob>


payments

readonly payments: {
begin: (orderId: string, opts?: {
paymentType?: string;
returnUrl?: string;
}) => Promise<unknown>;
};

Defined in: createLiveClient.ts:133

begin

begin: (orderId: string, opts?: {
paymentType?: string;
returnUrl?: string;
}) => Promise<unknown>;
Parameters
ParameterType
orderIdstring
opts?{ paymentType?: string; returnUrl?: string; }
opts.paymentType?string
opts.returnUrl?string
Returns

Promise<unknown>


presale

readonly presale: {
redeem: (code: string) => Promise<PresaleRedemption>;
};

Defined in: createLiveClient.ts:136

redeem

redeem: (code: string) => Promise<PresaleRedemption>;
Parameters
ParameterType
codestring
Returns

Promise<PresaleRedemption>


queue

readonly queue: {
join: () => Promise<unknown>;
status: () => Promise<unknown>;
};

Defined in: createLiveClient.ts:139

join

join: () => Promise<unknown>;
Returns

Promise<unknown>

status

status: () => Promise<unknown>;
Returns

Promise<unknown>


theme

readonly theme: {
apply: () => Promise<unknown>;
get: () => Promise<unknown>;
};

Defined in: createLiveClient.ts:111

apply

apply: () => Promise<unknown>;
Returns

Promise<unknown>

get

get: () => Promise<unknown>;
Returns

Promise<unknown>