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
new REST(options?): REST;Defined in: packages/rest/src/rest.ts:109
Parameters
| Parameter | Type |
|---|---|
options? | RESTOptions |
Returns
REST
Properties
authenticated
authenticated: boolean = false;Defined in: packages/rest/src/rest.ts:87
baseURL
readonly baseURL: string;Defined in: packages/rest/src/rest.ts:89
cid
cid: string = '';Defined in: packages/rest/src/rest.ts:86
maxPowRetries
readonly maxPowRetries: number;Defined in: packages/rest/src/rest.ts:92
onResponse?
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
| Parameter | Type |
|---|---|
response | APISuccessResponse |
Returns
void
password
protected password: string = '';Defined in: packages/rest/src/rest.ts:100
proofOfWork?
proofOfWork?: ProofOfWorkSolver;Defined in: packages/rest/src/rest.ts:91
See RESTOptions.proofOfWork. Settable after construction.
sauce
sauce: string = '';Defined in: packages/rest/src/rest.ts:85
username
protected username: string = '';Defined in: packages/rest/src/rest.ts:99
Methods
collection()
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 Parameter | Default type |
|---|---|
T extends object | Record<string, any> |
Parameters
| Parameter | Type |
|---|---|
url | string |
options? | RequestOptions |
Returns
Promise<APICollection<T>>
cookies()
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()
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
| Parameter | Type |
|---|---|
url | string |
options? | RequestOptions |
Returns
Promise<Response>
login()
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
| Parameter | Type |
|---|---|
username | string |
password | string |
options? | Record<string, any> |
Returns
Promise<void>
logout()
logout(): Promise<void>;Defined in: packages/rest/src/rest.ts:188
Returns
Promise<void>
request()
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 Parameter | Default type |
|---|---|
T extends object | Record<string, any> |
Parameters
| Parameter | Type |
|---|---|
url | string |
options? | RequestOptions |
Returns
Promise<APISuccessResponse<T>>
resource()
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 Parameter | Default type |
|---|---|
T extends object | Record<string, any> |
Parameters
| Parameter | Type |
|---|---|
url | string |
options? | RequestOptions |
Returns
Promise<APIResource<T>>
resources()
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 Parameter | Default type |
|---|---|
T extends object | Record<string, any> |
Parameters
| Parameter | Type |
|---|---|
url | string |
options? | RequestOptions |
Returns
Promise<APIResource<T>[]>
solveChallenges()
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>