Skip to content

Documentation / @imvu/rest / REST

Class: REST ​

Defined in: packages/rest/src/rest.ts:84

Low-level IMVU REST client: cookie-based auth, HTTP transport, and raw (un-modeled) resource fetching. @imvu/client builds the resource/manager layer on top; consumers that just want fast, raw typed JSON (e.g. a renderer that doesn't want class instances) can use this directly.

Built on the standard fetch, so it carries no HTTP-library dependency.

Constructors ​

Constructor ​

ts
new REST(options?): REST;

Defined in: packages/rest/src/rest.ts:109

Parameters ​

ParameterType
options?RESTOptions

Returns ​

REST

Properties ​

authenticated ​

ts
authenticated: boolean = false;

Defined in: packages/rest/src/rest.ts:87


baseURL ​

ts
readonly baseURL: string;

Defined in: packages/rest/src/rest.ts:89


cid ​

ts
cid: string = '';

Defined in: packages/rest/src/rest.ts:86


maxPowRetries ​

ts
readonly maxPowRetries: number;

Defined in: packages/rest/src/rest.ts:92


onResponse? ​

ts
onResponse?: (response) => void;

Defined in: packages/rest/src/rest.ts:97

Called with every successful API response, including all the documents it embeds (denormalized). @imvu/client uses it to keep its cache current.

Parameters ​

ParameterType
responseAPISuccessResponse

Returns ​

void


password ​

ts
protected password: string = '';

Defined in: packages/rest/src/rest.ts:100


proofOfWork? ​

ts
proofOfWork?: ProofOfWorkSolver;

Defined in: packages/rest/src/rest.ts:91

See RESTOptions.proofOfWork. Settable after construction.


sauce ​

ts
sauce: string = '';

Defined in: packages/rest/src/rest.ts:85


username ​

ts
protected username: string = '';

Defined in: packages/rest/src/rest.ts:99

Methods ​

collection() ​

ts
collection<T>(url, options?): Promise<APICollection<T>>;

Defined in: packages/rest/src/rest.ts:372

Fetch one bounded page from a node-group or edge-group document.

Type Parameters ​

Type ParameterDefault type
T extends objectRecord<string, any>

Parameters ​

ParameterType
urlstring
options?RequestOptions

Returns ​

Promise<APICollection<T>>


cookies() ​

ts
cookies(): Promise<CookieJar>;

Defined in: packages/rest/src/rest.ts:124

The session's cookie jar, loaded from storage on first use.

Returns ​

Promise<CookieJar>


fetch() ​

ts
fetch(url, options?): Promise<Response>;

Defined in: packages/rest/src/rest.ts:199

Send a request through the session and return the raw Response, whatever its status. Resolves url against the base URL, sends and records cookies, adds the auth headers to writes, and follows redirects (capturing cookies set along the way).

Parameters ​

ParameterType
urlstring
options?RequestOptions

Returns ​

Promise<Response>


login() ​

ts
login(
   username, 
   password, 
   options?
): Promise<void>;

Defined in: packages/rest/src/rest.ts:136

Authenticate. Reuses an existing _imvu_avnm session cookie when present (skipping the login POST) and establishes the "sauce" auth token that must accompany every non-GET request. If the reused session turns out to be stale (a matching _imvu_avnm cookie but an expired session), it falls back to a full login POST and retries once.

Parameters ​

ParameterType
usernamestring
passwordstring
options?Record<string, any>

Returns ​

Promise<void>


logout() ​

ts
logout(): Promise<void>;

Defined in: packages/rest/src/rest.ts:188

Returns ​

Promise<void>


request() ​

ts
request<T>(url, options?): Promise<APISuccessResponse<T>>;

Defined in: packages/rest/src/rest.ts:251

Send a request and return the API's success envelope; API failures throw IMVUAPIError.

Type Parameters ​

Type ParameterDefault type
T extends objectRecord<string, any>

Parameters ​

ParameterType
urlstring
options?RequestOptions

Returns ​

Promise<APISuccessResponse<T>>


resource() ​

ts
resource<T>(url, options?): Promise<APIResource<T>>;

Defined in: packages/rest/src/rest.ts:350

Fetch a single resource and return its normalized envelope with raw data. Handles the search shape (/user?username=…) and derives an opaque string ID without mutating the payload.

Type Parameters ​

Type ParameterDefault type
T extends objectRecord<string, any>

Parameters ​

ParameterType
urlstring
options?RequestOptions

Returns ​

Promise<APIResource<T>>


resources() ​

ts
resources<T>(url, options?): Promise<APIResource<T>[]>;

Defined in: packages/rest/src/rest.ts:411

Fetch a collection and return the raw (un-modeled) API nodes.

Type Parameters ​

Type ParameterDefault type
T extends objectRecord<string, any>

Parameters ​

ParameterType
urlstring
options?RequestOptions

Returns ​

Promise<APIResource<T>[]>


solveChallenges() ​

ts
solveChallenges(): Promise<number>;

Defined in: packages/rest/src/rest.ts:279

Solve every outstanding proof-of-work challenge for this session, the way the web client does: list /pow, read each challenge's nonce, solve it with proofOfWork, and POST {solution} back. Concurrent calls share one run. Resolves to the number of challenges handled. Called automatically when a request fails with VERIFY-001.

Returns ​

Promise<number>

Released under the MIT License.