Skip to content

Class: PrivateClient ​

Ties the three seams together: build a request, send it, update the session.

Constructors ​

Constructor ​

ts
new PrivateClient(options?): PrivateClient;

Parameters ​

ParameterType
options?PrivateClientOptions

Returns ​

PrivateClient

Accessors ​

session ​

Get Signature ​

ts
get session(): SessionData;
Returns ​

SessionData

Methods ​

patchAuth() ​

ts
patchAuth(auth): void;

Merges fields into the session auth (e.g. the user id after login).

Parameters ​

ParameterType
authPartial<AuthState>

Returns ​

void


patchSession() ​

ts
patchSession(patch): void;

Merges top-level fields into the session (e.g. the USDID identity).

Parameters ​

ParameterType
patchPartial<SessionData>

Returns ​

void


persist() ​

ts
persist(): Promise<void>;

Saves the current session to the store, when there is one.

Returns ​

Promise<void>


request() ​

ts
request(input): Promise<PrivateResponseJson>;

Sends a request and parses it, throwing a typed error on failure. If the session expired and an onSessionExpired hook is set, it re-authenticates and repeats the request once. A login_required rejection means the request was not applied, so repeating a mutation is safe.

Parameters ​

ParameterType
inputPrivateRequestOptions

Returns ​

Promise<PrivateResponseJson>


send() ​

ts
send(input): Promise<HttpResponse>;

Sends a request and returns the raw response. Updates and persists the session.

Parameters ​

ParameterType
inputPrivateRequestOptions

Returns ​

Promise<HttpResponse>


fromStore() ​

ts
static fromStore(store, options?): Promise<PrivateClient>;

A client started from the session a store holds, or from a fresh one.

Parameters ​

ParameterType
storeSessionStore
options?{ transport?: HttpTransport; }
options.transport?HttpTransport

Returns ​

Promise<PrivateClient>

MIT License. Not affiliated with, endorsed or sponsored by Meta or Instagram.