@onlyworlds/sdk 4.28.0 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/index.d.ts +108 -17
- package/dist/index.js +43 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.30.0] — 2026-10-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **A friend with only a link** (keel #353, D111):
|
|
12
|
+
- `redeemJoin(code, { name?, agentName? })`: redeems a join code that needs no account, at `POST /join`,
|
|
13
|
+
sending no credential whatever key the client holds. The answer's `kind` tells the two apart:
|
|
14
|
+
`OwPlayerJoined` (a read key, `ow_r_`, no PIN, and the Character the player reads as) or
|
|
15
|
+
`OwAgentJoined` (a seat's write key, secret and `.env` lines). Shown once; the code is spent, so a
|
|
16
|
+
lost answer means a new link. Every bad code is one 404.
|
|
17
|
+
- `createWorldLink(worldId, { reader: 'player', character? })`: a player link, guest only; `character`
|
|
18
|
+
is a Character's id or `new` (the default). `OwWorldLink.character` names it on the list.
|
|
19
|
+
- `player` joins the `kind` of `OwMe` and `OwMember`.
|
|
20
|
+
- **A client with no key**: `apiKey` is optional. `new OwV2Client()` (or an empty key) has `keyKind: 'none'`
|
|
21
|
+
and can call `health`, `previewJoin` and `redeemJoin`, which is what a friend with only a link has; any
|
|
22
|
+
other call is a TypeError before anything is sent. Until now a key was required even for the routes
|
|
23
|
+
that send none.
|
|
24
|
+
|
|
25
|
+
## [4.29.0] — 2026-10-16
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- `rekeySeat(worldId, seatId)` (keel #355 piece 3, D108): a new key and secret for a seat whose AI lost
|
|
29
|
+
its own, by its sponsor or the world's owner. The old key and secret stop at once; the answer has
|
|
30
|
+
`createSeat`'s shape (`OwSeatCreated`: `key`, `pin`, `env`), shown once. No Idempotency-Key, by keel's
|
|
31
|
+
rule: if the answer is lost too, ask for another.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- `createSeat`'s doc names `rekeySeat` as the way back from a lost answer.
|
|
35
|
+
- `OwApiError.param`'s doc: `API-Pin` on a 401 PIN refusal (keel #357, D107), not only a 422/400's field.
|
|
36
|
+
|
|
8
37
|
## [4.28.0] — 2026-10-16
|
|
9
38
|
|
|
10
39
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -2171,7 +2171,8 @@ interface OwMe {
|
|
|
2171
2171
|
name: string;
|
|
2172
2172
|
};
|
|
2173
2173
|
scope: 'read' | 'write';
|
|
2174
|
-
|
|
2174
|
+
/** `player`: a friend with no account, reading as a guest (keel #353). */
|
|
2175
|
+
kind: 'owner' | 'person' | 'agent' | 'player';
|
|
2175
2176
|
role: 'owner' | OwMemberRole;
|
|
2176
2177
|
/** The membership id (what `created_by` holds for what this key creates), or null for the owner. */
|
|
2177
2178
|
membership: string | null;
|
|
@@ -2185,7 +2186,7 @@ interface OwMe {
|
|
|
2185
2186
|
interface OwMember {
|
|
2186
2187
|
/** The membership id (what `created_by` holds), or null for the owner. */
|
|
2187
2188
|
id: string | null;
|
|
2188
|
-
kind: 'owner' | 'person' | 'agent';
|
|
2189
|
+
kind: 'owner' | 'person' | 'agent' | 'player';
|
|
2189
2190
|
role: 'owner' | OwMemberRole;
|
|
2190
2191
|
/** The Character that is this member, or null. */
|
|
2191
2192
|
character: string | null;
|
|
@@ -2209,8 +2210,8 @@ interface OwAllowance {
|
|
|
2209
2210
|
}
|
|
2210
2211
|
/** POST /join/preview: what a join code holds, read without using it (keel #212). */
|
|
2211
2212
|
interface OwJoinPreview {
|
|
2212
|
-
/** `person`: an invite link, accepted with acceptJoin. `agent`: redeemed by an AI agent at POST /join. */
|
|
2213
|
-
reader: 'person' | 'agent' | (string & {});
|
|
2213
|
+
/** `person`: an invite link, accepted with acceptJoin. `agent`: redeemed by an AI agent at POST /join. `player`: a friend with no account redeems it with redeemJoin for a read key (keel #353). */
|
|
2214
|
+
reader: 'person' | 'agent' | 'player' | (string & {});
|
|
2214
2215
|
world: {
|
|
2215
2216
|
name: string;
|
|
2216
2217
|
description: string | null;
|
|
@@ -2230,14 +2231,14 @@ interface OwJoinPreview {
|
|
|
2230
2231
|
interface OwWorldLink {
|
|
2231
2232
|
/** The link's id: revokeWorldLink takes it. */
|
|
2232
2233
|
id: string;
|
|
2233
|
-
/** `person`: accepted signed in, with acceptJoin. `agent`: redeemed by an AI agent at POST /join. */
|
|
2234
|
-
reader: 'person' | 'agent';
|
|
2234
|
+
/** `person`: accepted signed in, with acceptJoin. `agent`: redeemed by an AI agent at POST /join. `player`: redeemed with no account at POST /join, for a read key. */
|
|
2235
|
+
reader: 'person' | 'agent' | 'player';
|
|
2235
2236
|
role: OwMemberRole;
|
|
2236
2237
|
/** The name the owner gave an agent link on the website, or empty. */
|
|
2237
2238
|
label: string;
|
|
2238
2239
|
/** The name the link is signed with, or empty (the invite line then reads "Someone"). */
|
|
2239
2240
|
inviter_name: string;
|
|
2240
|
-
/** Whether redeeming gives the agent a Character of its own. Always false on a person link. */
|
|
2241
|
+
/** Whether redeeming gives the agent a Character of its own. Always false on a person link, always true on a player link. */
|
|
2241
2242
|
with_character: boolean;
|
|
2242
2243
|
/** The code's last four characters, to tell links apart. */
|
|
2243
2244
|
last4: string;
|
|
@@ -2248,6 +2249,11 @@ interface OwWorldLink {
|
|
|
2248
2249
|
/** 0 or 1: a link works once. */
|
|
2249
2250
|
uses: number;
|
|
2250
2251
|
status: 'pending' | 'used' | 'revoked' | 'expired';
|
|
2252
|
+
/** A player link only: the Character the player reads as; null while a link for a fresh Character is unused. `name` is null if that Character was deleted (the redeem then makes a fresh one). */
|
|
2253
|
+
character?: {
|
|
2254
|
+
id: string;
|
|
2255
|
+
name: string | null;
|
|
2256
|
+
} | null;
|
|
2251
2257
|
[k: string]: unknown;
|
|
2252
2258
|
}
|
|
2253
2259
|
/** POST /account/worlds/{id}/links: the new link, with its code. The code is in this answer only: keel keeps a hash. */
|
|
@@ -2259,6 +2265,58 @@ interface OwCreatedWorldLink extends OwWorldLink {
|
|
|
2259
2265
|
/** The one line to send: who invites, to which world, and the link. */
|
|
2260
2266
|
line: string;
|
|
2261
2267
|
}
|
|
2268
|
+
/** POST /join, an agent's code: its seat, write key and secret, shown once (keel #212; `kind` since #353). */
|
|
2269
|
+
interface OwAgentJoined {
|
|
2270
|
+
kind: 'agent';
|
|
2271
|
+
world: {
|
|
2272
|
+
id: string;
|
|
2273
|
+
name: string;
|
|
2274
|
+
description: string;
|
|
2275
|
+
[k: string]: unknown;
|
|
2276
|
+
};
|
|
2277
|
+
seat: {
|
|
2278
|
+
id: string;
|
|
2279
|
+
role: OwMemberRole;
|
|
2280
|
+
agent_name: string;
|
|
2281
|
+
[k: string]: unknown;
|
|
2282
|
+
};
|
|
2283
|
+
with_character: boolean;
|
|
2284
|
+
character: {
|
|
2285
|
+
id: string;
|
|
2286
|
+
name: string;
|
|
2287
|
+
} | null;
|
|
2288
|
+
/** The seat's write key (`API-Key`). */
|
|
2289
|
+
key: string;
|
|
2290
|
+
/** The seat's secret, sent as `API-Pin`. */
|
|
2291
|
+
pin: string;
|
|
2292
|
+
base_url: string;
|
|
2293
|
+
/** The lines of a `.env` file for the agent. */
|
|
2294
|
+
env: string;
|
|
2295
|
+
next: string[];
|
|
2296
|
+
members: Array<Record<string, unknown>>;
|
|
2297
|
+
[k: string]: unknown;
|
|
2298
|
+
}
|
|
2299
|
+
/** POST /join, a player's code: a read key for a friend with no account, reading as a guest (keel #353). Shown once. */
|
|
2300
|
+
interface OwPlayerJoined {
|
|
2301
|
+
kind: 'player';
|
|
2302
|
+
/** A read key (`ow_r_`): no PIN, a player reads only. */
|
|
2303
|
+
key: string;
|
|
2304
|
+
world: {
|
|
2305
|
+
id: string;
|
|
2306
|
+
name: string;
|
|
2307
|
+
description: string;
|
|
2308
|
+
[k: string]: unknown;
|
|
2309
|
+
};
|
|
2310
|
+
/** The Character the player reads as. */
|
|
2311
|
+
character: {
|
|
2312
|
+
id: string;
|
|
2313
|
+
name: string;
|
|
2314
|
+
};
|
|
2315
|
+
role: 'guest';
|
|
2316
|
+
[k: string]: unknown;
|
|
2317
|
+
}
|
|
2318
|
+
/** POST /join's answer: tell the two apart by `kind`. */
|
|
2319
|
+
type OwJoined = OwAgentJoined | OwPlayerJoined;
|
|
2262
2320
|
/** One live agent seat, as GET /account/worlds/{id}/seats lists it (keel #355, D106). No key or secret. */
|
|
2263
2321
|
interface OwSeat {
|
|
2264
2322
|
/** The seat's membership id: removeSeat takes it, and GET /members names the seat by it. */
|
|
@@ -2357,8 +2415,12 @@ interface ListParams {
|
|
|
2357
2415
|
filter?: Record<string, string | number | boolean>;
|
|
2358
2416
|
}
|
|
2359
2417
|
interface OwClientConfig {
|
|
2360
|
-
/**
|
|
2361
|
-
|
|
2418
|
+
/**
|
|
2419
|
+
* The key: an ow_w_ (write) or ow_r_ (read) world key, an ow_a_ account token (sent as a Bearer token, for the account routes), or a 10-digit legacy key.
|
|
2420
|
+
* Leave it out for a client that holds none, such as a friend with only a link (since 4.30.0): it can call health,
|
|
2421
|
+
* previewJoin and redeemJoin, and any other call is a TypeError before anything is sent.
|
|
2422
|
+
*/
|
|
2423
|
+
apiKey?: string;
|
|
2362
2424
|
/**
|
|
2363
2425
|
* The PIN, needed for writes when the world has one, and for legacy-key reads of private worlds.
|
|
2364
2426
|
* Prefixed keys read without a PIN. A string, not a number: '0123' !== 123.
|
|
@@ -2412,7 +2474,7 @@ declare class OwApiError extends Error {
|
|
|
2412
2474
|
readonly code: string | null;
|
|
2413
2475
|
/** Error family from the envelope, e.g. 'invalid_request', 'not_found'. */
|
|
2414
2476
|
readonly type: string | null;
|
|
2415
|
-
/** Offending field/param named by the envelope (422/400), else null. */
|
|
2477
|
+
/** Offending field/param named by the envelope (a 422/400's field; `API-Pin` on a 401 PIN refusal, keel #357), else null. */
|
|
2416
2478
|
readonly param: string | null;
|
|
2417
2479
|
/** Documentation link from the envelope -- show it to users/logs verbatim. */
|
|
2418
2480
|
readonly docUrl: string | null;
|
|
@@ -2533,7 +2595,9 @@ type OwKeyKind =
|
|
|
2533
2595
|
/** ow_a_ -- account Bearer token for /account/* routes; can mint world keys. */
|
|
2534
2596
|
| 'account'
|
|
2535
2597
|
/** Grandfathered 10-digit key. Needs PIN to read private worlds. */
|
|
2536
|
-
| 'legacy' | 'unknown'
|
|
2598
|
+
| 'legacy' | 'unknown'
|
|
2599
|
+
/** No key: a client for the routes that send none (health, previewJoin, redeemJoin), as a friend with only a link has. */
|
|
2600
|
+
| 'none';
|
|
2537
2601
|
/** Demo range 0000000000-0000000009: read-only aliases, safe as live read gates. */
|
|
2538
2602
|
declare function isDemoKey(key: string): boolean;
|
|
2539
2603
|
declare function detectKeyKind(key: string): OwKeyKind;
|
|
@@ -2568,7 +2632,7 @@ declare class OwV2Client {
|
|
|
2568
2632
|
private readonly apiPin;
|
|
2569
2633
|
private readonly fetchImpl;
|
|
2570
2634
|
private readonly agent;
|
|
2571
|
-
constructor(config
|
|
2635
|
+
constructor(config?: OwClientConfig);
|
|
2572
2636
|
/** GET /health -- unauthenticated liveness pulse. */
|
|
2573
2637
|
health(): Promise<unknown>;
|
|
2574
2638
|
/**
|
|
@@ -2769,6 +2833,21 @@ declare class OwV2Client {
|
|
|
2769
2833
|
* 404 `not_found` (`err.isNotFound`). `code` is the part of the link after `#`.
|
|
2770
2834
|
*/
|
|
2771
2835
|
previewJoin(code: string): Promise<OwJoinPreview>;
|
|
2836
|
+
/**
|
|
2837
|
+
* POST /join -- redeem a join code that needs no account: a player's (a friend reading as
|
|
2838
|
+
* a guest, keel #353) or an AI agent's. Sends no credential, whatever key this client holds.
|
|
2839
|
+
* 201 with `kind` telling the two answers apart: `player` gives a read key (`ow_r_`, no PIN)
|
|
2840
|
+
* and the Character it reads as; `agent` gives a seat's write key, secret and `.env` lines.
|
|
2841
|
+
* Both are shown once, and the code is spent: a lost answer cannot be replayed (the owner
|
|
2842
|
+
* sees the row never used, and makes a new link). `name` (a player's, optional: the
|
|
2843
|
+
* Character's name or "Player" when left out) and `agentName` (an agent's, required for an
|
|
2844
|
+
* agent code). Every bad code is the same 404 `not_found`; a person's code is redeemed with
|
|
2845
|
+
* acceptJoin instead.
|
|
2846
|
+
*/
|
|
2847
|
+
redeemJoin(code: string, opts?: {
|
|
2848
|
+
name?: string;
|
|
2849
|
+
agentName?: string;
|
|
2850
|
+
}): Promise<OwJoined>;
|
|
2772
2851
|
/**
|
|
2773
2852
|
* POST /account/join -- accept an invite link's code as the account this client's
|
|
2774
2853
|
* `ow_a_` token belongs to: 201 with the new membership. Refusals: 404 `not_found`
|
|
@@ -2781,17 +2860,21 @@ declare class OwV2Client {
|
|
|
2781
2860
|
/**
|
|
2782
2861
|
* POST /account/worlds/{worldId}/links -- a new invite link for a world this client's
|
|
2783
2862
|
* `ow_a_` token owns (keel C1): `reader` is required (`person`, accepted with acceptJoin;
|
|
2784
|
-
* `agent`, redeemed at POST /join
|
|
2785
|
-
*
|
|
2863
|
+
* `agent`, redeemed at POST /join; `player`, a friend with no account, redeemed with
|
|
2864
|
+
* redeemJoin for a read key, keel #353); `role` defaults to contributor (a player link is
|
|
2865
|
+
* guest, and refuses any other), `days` (1, 7 or 30) to 7; `withCharacter` (agent links
|
|
2866
|
+
* only) to true; `character` (player links only) a Character's id or `new` (the default):
|
|
2867
|
+
* whoever opens the link first reads as it, until removed. 201 with the code, shown in this
|
|
2786
2868
|
* answer only. Owner only: anyone else, and a world that doesn't exist, gets 404
|
|
2787
2869
|
* `not_found` (`err.isNotFound`). A world key is a TypeError before anything is sent.
|
|
2788
2870
|
*/
|
|
2789
2871
|
createWorldLink(worldId: string, opts: {
|
|
2790
|
-
reader: 'person' | 'agent';
|
|
2872
|
+
reader: 'person' | 'agent' | 'player';
|
|
2791
2873
|
role?: OwMemberRole;
|
|
2792
2874
|
days?: 1 | 7 | 30;
|
|
2793
2875
|
inviterName?: string;
|
|
2794
2876
|
withCharacter?: boolean;
|
|
2877
|
+
character?: string;
|
|
2795
2878
|
}): Promise<OwCreatedWorldLink>;
|
|
2796
2879
|
/**
|
|
2797
2880
|
* GET /account/worlds/{worldId}/links -- the world's invite links, without their codes:
|
|
@@ -2815,7 +2898,7 @@ declare class OwV2Client {
|
|
|
2815
2898
|
* `mine` (members only: it plays the Character you play). 201 with `key`, `pin` and the
|
|
2816
2899
|
* `.env` lines in `env`, shown in this answer only. Sends no Idempotency-Key, by keel's rule:
|
|
2817
2900
|
* a replay would have to keep the key. If the answer is lost, listSeats shows the seat without
|
|
2818
|
-
* its key:
|
|
2901
|
+
* its key: rekeySeat gives it a new one (or removeSeat and make another). Needs the client's `ow_a_` token.
|
|
2819
2902
|
*/
|
|
2820
2903
|
createSeat(worldId: string, opts: {
|
|
2821
2904
|
name: string;
|
|
@@ -2827,6 +2910,14 @@ declare class OwV2Client {
|
|
|
2827
2910
|
* as the world's owner, every seat. No keys or secrets. Needs the client's `ow_a_` token.
|
|
2828
2911
|
*/
|
|
2829
2912
|
listSeats(worldId: string): Promise<OwSeat[]>;
|
|
2913
|
+
/**
|
|
2914
|
+
* POST /account/worlds/{worldId}/seats/{seatId}/key -- a new key and secret for a seat whose AI
|
|
2915
|
+
* lost its own: its sponsor or the world's owner may. The old key and secret stop at once;
|
|
2916
|
+
* nothing else about the seat changes. 201 with the same shape as createSeat (`key`, `pin`,
|
|
2917
|
+
* `env`), shown in this answer only. No Idempotency-Key, by keel's rule: if this answer is lost
|
|
2918
|
+
* too, ask for another new key. Needs the client's `ow_a_` token.
|
|
2919
|
+
*/
|
|
2920
|
+
rekeySeat(worldId: string, seatId: string): Promise<OwSeatCreated>;
|
|
2830
2921
|
/**
|
|
2831
2922
|
* DELETE /account/worlds/{worldId}/seats/{seatId} -- remove an agent seat: its sponsor or the
|
|
2832
2923
|
* world's owner may. Its key and secret stop at once; a Character it made that nobody touched
|
|
@@ -3834,4 +3925,4 @@ declare class TokenResource {
|
|
|
3834
3925
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
3835
3926
|
}
|
|
3836
3927
|
|
|
3837
|
-
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_SCHEMA, type FieldInfo, type FieldType, GameTier, type ListParams, ONLYWORLDS_VERSION, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreatedWorldLink, type OwElement, type OwElementBase, type OwErrorBody, type OwJoinPreview, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, OwPreconditionFailedError, type OwPreparedPhoto, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwSeat, type OwSeatCreated, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, type OwUploadedImage, OwV2Client, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWriteDoor, PHOTO_MAX_BYTES, PHOTO_TYPES, type ParseError, type ParseOptions, type ParseResult, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, elementColor, eraForStep, errorFromResponse, familyOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, isAgentDoor, isDemoKey, isLeapYear, isParseError, kindCanWrite, lookupWorld, monthStartSteps, parseDate, parseErrorEnvelope, pinExpectation, planPhoto, preparePhoto, readCalendarConfig, readCalendarValue, readWorldFile, renderElement, resolveCalendarLens, resolveEraDomains, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
|
3928
|
+
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_SCHEMA, type FieldInfo, type FieldType, GameTier, type ListParams, ONLYWORLDS_VERSION, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreatedWorldLink, type OwElement, type OwElementBase, type OwErrorBody, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwSeat, type OwSeatCreated, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, type OwUploadedImage, OwV2Client, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWriteDoor, PHOTO_MAX_BYTES, PHOTO_TYPES, type ParseError, type ParseOptions, type ParseResult, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, elementColor, eraForStep, errorFromResponse, familyOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, isAgentDoor, isDemoKey, isLeapYear, isParseError, kindCanWrite, lookupWorld, monthStartSteps, parseDate, parseErrorEnvelope, pinExpectation, planPhoto, preparePhoto, readCalendarConfig, readCalendarValue, readWorldFile, renderElement, resolveCalendarLens, resolveEraDomains, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -249,11 +249,10 @@ var DEFAULT_BASE_URL = "https://www.onlyworlds.com/api/v2";
|
|
|
249
249
|
var DEFAULT_PAGE_SIZE = 100;
|
|
250
250
|
var DEFAULT_CHANGES_PAGE_SIZE = 100;
|
|
251
251
|
var OwV2Client = class {
|
|
252
|
-
constructor(config) {
|
|
253
|
-
|
|
254
|
-
this.apiKey = config.apiKey;
|
|
252
|
+
constructor(config = {}) {
|
|
253
|
+
this.apiKey = config.apiKey ?? "";
|
|
255
254
|
this.apiPin = config.apiPin || void 0;
|
|
256
|
-
this.keyKind = detectKeyKind(config.apiKey);
|
|
255
|
+
this.keyKind = config.apiKey ? detectKeyKind(config.apiKey) : "none";
|
|
257
256
|
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
258
257
|
this.pageSize = config.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
259
258
|
this.changesPageSize = config.changesPageSize ?? DEFAULT_CHANGES_PAGE_SIZE;
|
|
@@ -569,6 +568,23 @@ var OwV2Client = class {
|
|
|
569
568
|
async previewJoin(code) {
|
|
570
569
|
return this.request("POST", "/join/preview", { auth: false, body: { code } });
|
|
571
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* POST /join -- redeem a join code that needs no account: a player's (a friend reading as
|
|
573
|
+
* a guest, keel #353) or an AI agent's. Sends no credential, whatever key this client holds.
|
|
574
|
+
* 201 with `kind` telling the two answers apart: `player` gives a read key (`ow_r_`, no PIN)
|
|
575
|
+
* and the Character it reads as; `agent` gives a seat's write key, secret and `.env` lines.
|
|
576
|
+
* Both are shown once, and the code is spent: a lost answer cannot be replayed (the owner
|
|
577
|
+
* sees the row never used, and makes a new link). `name` (a player's, optional: the
|
|
578
|
+
* Character's name or "Player" when left out) and `agentName` (an agent's, required for an
|
|
579
|
+
* agent code). Every bad code is the same 404 `not_found`; a person's code is redeemed with
|
|
580
|
+
* acceptJoin instead.
|
|
581
|
+
*/
|
|
582
|
+
async redeemJoin(code, opts = {}) {
|
|
583
|
+
const body = { code };
|
|
584
|
+
if (opts.name !== void 0) body.name = opts.name;
|
|
585
|
+
if (opts.agentName !== void 0) body.agent_name = opts.agentName;
|
|
586
|
+
return this.request("POST", "/join", { auth: false, body });
|
|
587
|
+
}
|
|
572
588
|
/**
|
|
573
589
|
* POST /account/join -- accept an invite link's code as the account this client's
|
|
574
590
|
* `ow_a_` token belongs to: 201 with the new membership. Refusals: 404 `not_found`
|
|
@@ -586,8 +602,11 @@ var OwV2Client = class {
|
|
|
586
602
|
/**
|
|
587
603
|
* POST /account/worlds/{worldId}/links -- a new invite link for a world this client's
|
|
588
604
|
* `ow_a_` token owns (keel C1): `reader` is required (`person`, accepted with acceptJoin;
|
|
589
|
-
* `agent`, redeemed at POST /join
|
|
590
|
-
*
|
|
605
|
+
* `agent`, redeemed at POST /join; `player`, a friend with no account, redeemed with
|
|
606
|
+
* redeemJoin for a read key, keel #353); `role` defaults to contributor (a player link is
|
|
607
|
+
* guest, and refuses any other), `days` (1, 7 or 30) to 7; `withCharacter` (agent links
|
|
608
|
+
* only) to true; `character` (player links only) a Character's id or `new` (the default):
|
|
609
|
+
* whoever opens the link first reads as it, until removed. 201 with the code, shown in this
|
|
591
610
|
* answer only. Owner only: anyone else, and a world that doesn't exist, gets 404
|
|
592
611
|
* `not_found` (`err.isNotFound`). A world key is a TypeError before anything is sent.
|
|
593
612
|
*/
|
|
@@ -600,6 +619,7 @@ var OwV2Client = class {
|
|
|
600
619
|
if (opts.days !== void 0) body.days = opts.days;
|
|
601
620
|
if (opts.inviterName !== void 0) body.inviter_name = opts.inviterName;
|
|
602
621
|
if (opts.withCharacter !== void 0) body.with_character = opts.withCharacter;
|
|
622
|
+
if (opts.character !== void 0) body.character = opts.character;
|
|
603
623
|
return this.request("POST", `/account/worlds/${encodeURIComponent(worldId)}/links`, { body });
|
|
604
624
|
}
|
|
605
625
|
/**
|
|
@@ -636,7 +656,7 @@ var OwV2Client = class {
|
|
|
636
656
|
* `mine` (members only: it plays the Character you play). 201 with `key`, `pin` and the
|
|
637
657
|
* `.env` lines in `env`, shown in this answer only. Sends no Idempotency-Key, by keel's rule:
|
|
638
658
|
* a replay would have to keep the key. If the answer is lost, listSeats shows the seat without
|
|
639
|
-
* its key:
|
|
659
|
+
* its key: rekeySeat gives it a new one (or removeSeat and make another). Needs the client's `ow_a_` token.
|
|
640
660
|
*/
|
|
641
661
|
async createSeat(worldId, opts) {
|
|
642
662
|
if (this.keyKind !== "account") {
|
|
@@ -658,6 +678,19 @@ var OwV2Client = class {
|
|
|
658
678
|
const page = await this.request("GET", `/account/worlds/${encodeURIComponent(worldId)}/seats`);
|
|
659
679
|
return page.data;
|
|
660
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* POST /account/worlds/{worldId}/seats/{seatId}/key -- a new key and secret for a seat whose AI
|
|
683
|
+
* lost its own: its sponsor or the world's owner may. The old key and secret stop at once;
|
|
684
|
+
* nothing else about the seat changes. 201 with the same shape as createSeat (`key`, `pin`,
|
|
685
|
+
* `env`), shown in this answer only. No Idempotency-Key, by keel's rule: if this answer is lost
|
|
686
|
+
* too, ask for another new key. Needs the client's `ow_a_` token.
|
|
687
|
+
*/
|
|
688
|
+
async rekeySeat(worldId, seatId) {
|
|
689
|
+
if (this.keyKind !== "account") {
|
|
690
|
+
throw new TypeError("rekeySeat needs an account token (ow_a_)");
|
|
691
|
+
}
|
|
692
|
+
return this.request("POST", `/account/worlds/${encodeURIComponent(worldId)}/seats/${encodeURIComponent(seatId)}/key`);
|
|
693
|
+
}
|
|
661
694
|
/**
|
|
662
695
|
* DELETE /account/worlds/{worldId}/seats/{seatId} -- remove an agent seat: its sponsor or the
|
|
663
696
|
* world's owner may. Its key and secret stop at once; a Character it made that nobody touched
|
|
@@ -730,6 +763,9 @@ var OwV2Client = class {
|
|
|
730
763
|
if (opts.ifMatch !== void 0 && !(Number.isInteger(opts.ifMatch) && opts.ifMatch >= 0)) {
|
|
731
764
|
throw new TypeError(`ifMatch must be a whole number (an element's change_seq), got ${String(opts.ifMatch)}`);
|
|
732
765
|
}
|
|
766
|
+
if (opts.auth !== false && this.keyKind === "none") {
|
|
767
|
+
throw new TypeError(`${method} ${path} needs a key, and this client holds none: without one, only health, previewJoin and redeemJoin work`);
|
|
768
|
+
}
|
|
733
769
|
const url = `${this.baseUrl}${path}${opts.query ? `?${opts.query}` : ""}`;
|
|
734
770
|
const headers = {};
|
|
735
771
|
if (opts.auth !== false) {
|