@onlyworlds/sdk 4.133.2 → 4.134.1
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 +15 -0
- package/dist/index.d.ts +58 -3
- package/dist/index.js +48 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.134.1] - 2026-11-08
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `OwWorldKeyRow` and `OwWorldKeyMember` are exported. 4.134.0 named them in `madeWorldKey`'s signature and in its notes, but left them out of the package's export list, so `import { type OwWorldKeyRow }` failed to compile. A test now reads each built entry's type declarations against its export list.
|
|
13
|
+
- `mintWorldKey`'s comment now says to mint again with a new idempotency key after a lost answer. The same key sent again makes a second key, and `madeWorldKey` keeps naming the first, so the second could never be found. Words only.
|
|
14
|
+
|
|
15
|
+
## [4.134.0] - 2026-11-08
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `madeWorldKey(worldId, idempotencyKey, { signal })`: the key a `mintWorldKey` call sent with that idempotency key made, as its row without the key itself (`OwWorldKeyRow`: id, name, last four, scope, last used, revoked, kept, and `member` on a member-bound key), or null when it made none. A revoked key still answers, with `revoked: true`. Null too from a server before the lookup, which answers that address 405.
|
|
20
|
+
- `mintWorldKey` takes `idempotencyKey`, sent as the Idempotency-Key header, and `signal`. The mint is never replayed (a stored answer would keep the key), so a second mint with the same key makes a second key. The server remembers the idempotency key on the row instead. When an answer is lost: keep the idempotency key on the device before the send, ask `madeWorldKey` after a network error or a timeout, revoke the id it names, and mint again. A 4xx made no key, and "none made" is worth believing only a couple of minutes after the send. An `idempotencyKey` that is not a non-empty string is a TypeError before anything is sent.
|
|
21
|
+
- `OwWorldKeyMember`, the membership a member-bound key is bound to; `OwMintedKey.member` is typed with it (it was a plain record).
|
|
22
|
+
|
|
8
23
|
## [4.133.2] - 2026-11-08
|
|
9
24
|
|
|
10
25
|
### Changed
|
package/dist/index.d.ts
CHANGED
|
@@ -3575,10 +3575,40 @@ interface OwMintedKey {
|
|
|
3575
3575
|
last_used_at: string | null;
|
|
3576
3576
|
revoked: boolean;
|
|
3577
3577
|
key: string;
|
|
3578
|
-
member?:
|
|
3578
|
+
member?: OwWorldKeyMember;
|
|
3579
3579
|
/** True when minted with `keep: true`: no revoke of the token that minted it takes it (a sign-out keeps it). */
|
|
3580
3580
|
kept?: boolean;
|
|
3581
3581
|
}
|
|
3582
|
+
/**
|
|
3583
|
+
* The membership a member-bound world key is bound to. A person's carries `username`; an agent
|
|
3584
|
+
* seat's `agent_name` (its username null); a player seat's `kind` and `name` (its username null).
|
|
3585
|
+
*/
|
|
3586
|
+
interface OwWorldKeyMember {
|
|
3587
|
+
id: string;
|
|
3588
|
+
username?: string | null;
|
|
3589
|
+
agent_name?: string;
|
|
3590
|
+
kind?: string;
|
|
3591
|
+
name?: string;
|
|
3592
|
+
}
|
|
3593
|
+
/**
|
|
3594
|
+
* A world key's row as GET /account/worlds/{id}/keys/made answers it (madeWorldKey): the key a
|
|
3595
|
+
* mint sent with that Idempotency-Key made, without the key itself. A revoked key still answers,
|
|
3596
|
+
* with `revoked: true`.
|
|
3597
|
+
*/
|
|
3598
|
+
interface OwWorldKeyRow {
|
|
3599
|
+
id: string;
|
|
3600
|
+
/** The key's label, an empty string when it has none. */
|
|
3601
|
+
name: string;
|
|
3602
|
+
/** The key's last four characters; the key itself is shown once, at the mint. */
|
|
3603
|
+
last4: string;
|
|
3604
|
+
scope: 'READ' | 'WRITE';
|
|
3605
|
+
last_used_at: string | null;
|
|
3606
|
+
revoked: boolean;
|
|
3607
|
+
/** True when the key is kept across a sign-out (`keep` at the mint). */
|
|
3608
|
+
kept: boolean;
|
|
3609
|
+
/** On a member-bound key only: the membership it is bound to. An owner key has none. */
|
|
3610
|
+
member?: OwWorldKeyMember;
|
|
3611
|
+
}
|
|
3582
3612
|
/** An account token as GET /account/tokens lists it: by name and last four, never the token itself. */
|
|
3583
3613
|
interface OwAccountToken {
|
|
3584
3614
|
/** The token's id: revokeAccountToken takes it, and a sign-in answers it as `tokenId`. */
|
|
@@ -5130,18 +5160,43 @@ declare class OwV2Client {
|
|
|
5130
5160
|
* name). The full key comes back
|
|
5131
5161
|
* once in `key`. The owner mints a world key; a member mints their own member key, 409
|
|
5132
5162
|
* `pin_required` (`err.isPinRequired`) for a write key while the account has no PIN. Account
|
|
5133
|
-
* token only
|
|
5163
|
+
* token only. `keep: true` keeps the key across a sign-out: revoking the token
|
|
5134
5164
|
* that minted it leaves it live (a tool that stores a key on the device passes it), while
|
|
5135
5165
|
* disconnecting the tool, or a replayed sign-in code, still takes it; the answer says `kept`.
|
|
5136
5166
|
* Without it, revoking a token a tool got through Sign in with OnlyWorlds revokes the keys it minted,
|
|
5137
5167
|
* unless the person holds another live token of the same tool; a token made by hand or by a password
|
|
5138
5168
|
* sign-in (signInWithPassword), or one of a tool that asks each time, never takes its keys.
|
|
5169
|
+
*
|
|
5170
|
+
* `idempotencyKey` is sent as the Idempotency-Key header. The mint is never replayed (a stored
|
|
5171
|
+
* answer would keep the key): a second mint with the same key makes a second key. The server
|
|
5172
|
+
* remembers the key on the row instead, so when an answer is lost, madeWorldKey finds the key this
|
|
5173
|
+
* call made, and the tool revokes it by its id and mints again. `signal` (an AbortSignal) goes to
|
|
5174
|
+
* fetch as given; an abort rejects with an OwNetworkError.
|
|
5175
|
+
*
|
|
5176
|
+
* When the answer may be lost: keep the idempotency key on the device before the send. A 4xx made
|
|
5177
|
+
* no key. After a network error or a timeout, ask madeWorldKey, revoke the id it names, and mint
|
|
5178
|
+
* again with a new idempotency key: the same one sent again makes a key the lookup cannot find,
|
|
5179
|
+
* since it keeps naming the first. Believe its "none made" only a couple of minutes after the send,
|
|
5180
|
+
* since an abort stops the wait, not the server's work.
|
|
5139
5181
|
*/
|
|
5140
5182
|
mintWorldKey(worldId: string, opts?: {
|
|
5141
5183
|
scope?: 'read' | 'write';
|
|
5142
5184
|
name?: string | null;
|
|
5143
5185
|
keep?: boolean;
|
|
5186
|
+
idempotencyKey?: string;
|
|
5187
|
+
signal?: AbortSignal;
|
|
5144
5188
|
}): Promise<OwMintedKey>;
|
|
5189
|
+
/**
|
|
5190
|
+
* GET /account/worlds/{worldId}/keys/made?key= -- the key a mintWorldKey call sent with this
|
|
5191
|
+
* `idempotencyKey` made, as a row without the key itself (`OwWorldKeyRow`), or null when it made
|
|
5192
|
+
* none. A revoked key still answers, with `revoked: true`. The owner finds the keys they minted; a
|
|
5193
|
+
* member only the keys bound to their seat; anything else is null (the server's one 404). Null also
|
|
5194
|
+
* for a server from before the lookup, which answers this address 405. `signal` goes to fetch as
|
|
5195
|
+
* given. Account token only.
|
|
5196
|
+
*/
|
|
5197
|
+
madeWorldKey(worldId: string, idempotencyKey: string, opts?: {
|
|
5198
|
+
signal?: AbortSignal;
|
|
5199
|
+
}): Promise<OwWorldKeyRow | null>;
|
|
5145
5200
|
/**
|
|
5146
5201
|
* DELETE /account/worlds/{worldId}/keys/{keyId} -- revoke a world key, by the `id` mintWorldKey
|
|
5147
5202
|
* returned: from then on it answers 401 `key_revoked`. The owner revokes any of the world's keys,
|
|
@@ -7177,4 +7232,4 @@ declare class TokenResource {
|
|
|
7177
7232
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
7178
7233
|
}
|
|
7179
7234
|
|
|
7180
|
-
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountToken, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDoor, type OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, strandOf, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
|
7235
|
+
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountToken, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDoor, type OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldKeyMember, type OwWorldKeyRow, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, strandOf, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -1939,18 +1939,33 @@ var OwV2Client = class {
|
|
|
1939
1939
|
* name). The full key comes back
|
|
1940
1940
|
* once in `key`. The owner mints a world key; a member mints their own member key, 409
|
|
1941
1941
|
* `pin_required` (`err.isPinRequired`) for a write key while the account has no PIN. Account
|
|
1942
|
-
* token only
|
|
1942
|
+
* token only. `keep: true` keeps the key across a sign-out: revoking the token
|
|
1943
1943
|
* that minted it leaves it live (a tool that stores a key on the device passes it), while
|
|
1944
1944
|
* disconnecting the tool, or a replayed sign-in code, still takes it; the answer says `kept`.
|
|
1945
1945
|
* Without it, revoking a token a tool got through Sign in with OnlyWorlds revokes the keys it minted,
|
|
1946
1946
|
* unless the person holds another live token of the same tool; a token made by hand or by a password
|
|
1947
1947
|
* sign-in (signInWithPassword), or one of a tool that asks each time, never takes its keys.
|
|
1948
|
+
*
|
|
1949
|
+
* `idempotencyKey` is sent as the Idempotency-Key header. The mint is never replayed (a stored
|
|
1950
|
+
* answer would keep the key): a second mint with the same key makes a second key. The server
|
|
1951
|
+
* remembers the key on the row instead, so when an answer is lost, madeWorldKey finds the key this
|
|
1952
|
+
* call made, and the tool revokes it by its id and mints again. `signal` (an AbortSignal) goes to
|
|
1953
|
+
* fetch as given; an abort rejects with an OwNetworkError.
|
|
1954
|
+
*
|
|
1955
|
+
* When the answer may be lost: keep the idempotency key on the device before the send. A 4xx made
|
|
1956
|
+
* no key. After a network error or a timeout, ask madeWorldKey, revoke the id it names, and mint
|
|
1957
|
+
* again with a new idempotency key: the same one sent again makes a key the lookup cannot find,
|
|
1958
|
+
* since it keeps naming the first. Believe its "none made" only a couple of minutes after the send,
|
|
1959
|
+
* since an abort stops the wait, not the server's work.
|
|
1948
1960
|
*/
|
|
1949
1961
|
async mintWorldKey(worldId, opts = {}) {
|
|
1950
|
-
only("mintWorldKey", opts, ["scope", "name", "keep"]);
|
|
1962
|
+
only("mintWorldKey", opts, ["scope", "name", "keep", "idempotencyKey", "signal"]);
|
|
1951
1963
|
if (opts.keep !== void 0 && typeof opts.keep !== "boolean") {
|
|
1952
1964
|
throw new TypeError(`mintWorldKey: keep is true or false, got ${JSON.stringify(opts.keep)}. Nothing was sent.`);
|
|
1953
1965
|
}
|
|
1966
|
+
if (opts.idempotencyKey !== void 0 && (typeof opts.idempotencyKey !== "string" || opts.idempotencyKey === "")) {
|
|
1967
|
+
throw new TypeError(`mintWorldKey: idempotencyKey is a non-empty string, got ${JSON.stringify(opts.idempotencyKey)}. Nothing was sent.`);
|
|
1968
|
+
}
|
|
1954
1969
|
if (this.keyKind !== "account") {
|
|
1955
1970
|
throw new TypeError("mintWorldKey needs an account token (ow_a_)");
|
|
1956
1971
|
}
|
|
@@ -1958,7 +1973,37 @@ var OwV2Client = class {
|
|
|
1958
1973
|
if (opts.scope !== void 0) body.scope = opts.scope;
|
|
1959
1974
|
if (opts.name !== void 0) body.name = opts.name;
|
|
1960
1975
|
if (opts.keep !== void 0) body.keep = opts.keep;
|
|
1961
|
-
return this.request("POST", `/account/worlds/${seg("worldId", worldId)}/keys`, {
|
|
1976
|
+
return this.request("POST", `/account/worlds/${seg("worldId", worldId)}/keys`, {
|
|
1977
|
+
body,
|
|
1978
|
+
...opts.idempotencyKey !== void 0 ? { idempotencyKey: opts.idempotencyKey } : {},
|
|
1979
|
+
...withSignal(opts.signal)
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* GET /account/worlds/{worldId}/keys/made?key= -- the key a mintWorldKey call sent with this
|
|
1984
|
+
* `idempotencyKey` made, as a row without the key itself (`OwWorldKeyRow`), or null when it made
|
|
1985
|
+
* none. A revoked key still answers, with `revoked: true`. The owner finds the keys they minted; a
|
|
1986
|
+
* member only the keys bound to their seat; anything else is null (the server's one 404). Null also
|
|
1987
|
+
* for a server from before the lookup, which answers this address 405. `signal` goes to fetch as
|
|
1988
|
+
* given. Account token only.
|
|
1989
|
+
*/
|
|
1990
|
+
async madeWorldKey(worldId, idempotencyKey, opts = {}) {
|
|
1991
|
+
only("madeWorldKey", opts, ["signal"]);
|
|
1992
|
+
if (typeof idempotencyKey !== "string" || idempotencyKey === "") {
|
|
1993
|
+
throw new TypeError(`madeWorldKey: the idempotency key is a non-empty string, got ${JSON.stringify(idempotencyKey)}. Nothing was sent.`);
|
|
1994
|
+
}
|
|
1995
|
+
if (this.keyKind !== "account") {
|
|
1996
|
+
throw new TypeError("madeWorldKey needs an account token (ow_a_)");
|
|
1997
|
+
}
|
|
1998
|
+
try {
|
|
1999
|
+
return await this.request("GET", `/account/worlds/${seg("worldId", worldId)}/keys/made`, {
|
|
2000
|
+
query: `key=${encodeURIComponent(idempotencyKey)}`,
|
|
2001
|
+
...withSignal(opts.signal)
|
|
2002
|
+
});
|
|
2003
|
+
} catch (err) {
|
|
2004
|
+
if (err instanceof OwApiError && (err.status === 404 || err.status === 405)) return null;
|
|
2005
|
+
throw err;
|
|
2006
|
+
}
|
|
1962
2007
|
}
|
|
1963
2008
|
/**
|
|
1964
2009
|
* DELETE /account/worlds/{worldId}/keys/{keyId} -- revoke a world key, by the `id` mintWorldKey
|