@onlyworlds/sdk 4.77.0 → 4.79.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 +13 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +29 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.79.0] - 2026-10-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`revokeWorldKey(worldId, keyId, { signal, keepalive })`**: both go to `fetch` as given. With `keepalive: true` a browser finishes the revoke after the tab that sent it closes, so a page can revoke its key on Sign out and close at once; a `signal` (for example `AbortSignal.timeout(5000)`) puts a time limit on it, and an abort rejects with an `OwNetworkError` whose `cause2` is the abort. A dead account token is a 401 (`err.isAuthError`), and then the key was not revoked. An unknown option is a TypeError before anything is sent.
|
|
13
|
+
- **`request()` takes `signal` and `keepalive`**, passed to `fetch` as given and sent only when given.
|
|
14
|
+
|
|
15
|
+
## [4.78.0] - 2026-10-26
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`revokeWorldKey(worldId, keyId)`**: revoke a world key by the `id` `mintWorldKey` returned (`DELETE /account/worlds/{id}/keys/{key_id}`, account token only). The key then answers 401 `key_revoked`. The owner revokes any of the world's keys, a member only their own; any other id is a 404. Revoking a revoked key answers the same 204, so a tool that mints a key when a person signs in can revoke it when they sign out without tracking whether it already did.
|
|
20
|
+
|
|
8
21
|
## [4.77.0] - 2026-10-26
|
|
9
22
|
|
|
10
23
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -4296,6 +4296,21 @@ declare class OwV2Client {
|
|
|
4296
4296
|
scope?: 'read' | 'write';
|
|
4297
4297
|
name?: string;
|
|
4298
4298
|
}): Promise<OwMintedKey>;
|
|
4299
|
+
/**
|
|
4300
|
+
* DELETE /account/worlds/{worldId}/keys/{keyId} -- revoke a world key, by the `id` mintWorldKey
|
|
4301
|
+
* returned: from then on it answers 401 `key_revoked`. The owner revokes any of the world's keys,
|
|
4302
|
+
* a member only their own; any other id is a 404 (`err.isNotFound`). Revoking a revoked key
|
|
4303
|
+
* changes nothing and answers the same 204, so a tool that signs out can revoke its key without
|
|
4304
|
+
* knowing whether it already did. An account token already revoked or expired is a 401
|
|
4305
|
+
* (`err.isAuthError`): the key was not revoked and still reads. `signal` (an AbortSignal, e.g.
|
|
4306
|
+
* `AbortSignal.timeout(5000)`) and `keepalive` go to fetch as given: with `keepalive: true` a
|
|
4307
|
+
* browser finishes the revoke after the tab that sent it closes; an abort rejects with an
|
|
4308
|
+
* OwNetworkError whose `cause2` is the abort. Account token only.
|
|
4309
|
+
*/
|
|
4310
|
+
revokeWorldKey(worldId: string, keyId: string, opts?: {
|
|
4311
|
+
signal?: AbortSignal;
|
|
4312
|
+
keepalive?: boolean;
|
|
4313
|
+
}): Promise<void>;
|
|
4299
4314
|
/**
|
|
4300
4315
|
* Start Sign in with OnlyWorlds from a tool's page: mint `state` and a PKCE verifier, keep them
|
|
4301
4316
|
* under `clientId` in `storage` (sessionStorage by default; in Node pass one), and send the
|
|
@@ -4385,6 +4400,10 @@ declare class OwV2Client {
|
|
|
4385
4400
|
* the body is read. With it given, a 304 Not Modified returns null instead of throwing.
|
|
4386
4401
|
*/
|
|
4387
4402
|
onEtag?: (etag: string | null, status: number) => void;
|
|
4403
|
+
/** Passed to fetch as given: aborting it rejects with an OwNetworkError whose `cause2` is the abort. */
|
|
4404
|
+
signal?: AbortSignal;
|
|
4405
|
+
/** Passed to fetch as given: a browser finishes the request after the page closes. */
|
|
4406
|
+
keepalive?: boolean;
|
|
4388
4407
|
}): Promise<T>;
|
|
4389
4408
|
}
|
|
4390
4409
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1727,6 +1727,27 @@ var OwV2Client = class {
|
|
|
1727
1727
|
if (opts.name !== void 0) body.name = opts.name;
|
|
1728
1728
|
return this.request("POST", `/account/worlds/${encodeURIComponent(worldId)}/keys`, { write: true, body });
|
|
1729
1729
|
}
|
|
1730
|
+
/**
|
|
1731
|
+
* DELETE /account/worlds/{worldId}/keys/{keyId} -- revoke a world key, by the `id` mintWorldKey
|
|
1732
|
+
* returned: from then on it answers 401 `key_revoked`. The owner revokes any of the world's keys,
|
|
1733
|
+
* a member only their own; any other id is a 404 (`err.isNotFound`). Revoking a revoked key
|
|
1734
|
+
* changes nothing and answers the same 204, so a tool that signs out can revoke its key without
|
|
1735
|
+
* knowing whether it already did. An account token already revoked or expired is a 401
|
|
1736
|
+
* (`err.isAuthError`): the key was not revoked and still reads. `signal` (an AbortSignal, e.g.
|
|
1737
|
+
* `AbortSignal.timeout(5000)`) and `keepalive` go to fetch as given: with `keepalive: true` a
|
|
1738
|
+
* browser finishes the revoke after the tab that sent it closes; an abort rejects with an
|
|
1739
|
+
* OwNetworkError whose `cause2` is the abort. Account token only.
|
|
1740
|
+
*/
|
|
1741
|
+
async revokeWorldKey(worldId, keyId, opts = {}) {
|
|
1742
|
+
only("revokeWorldKey", opts, ["signal", "keepalive"]);
|
|
1743
|
+
if (this.keyKind !== "account") {
|
|
1744
|
+
throw new TypeError("revokeWorldKey needs an account token (ow_a_)");
|
|
1745
|
+
}
|
|
1746
|
+
const send = {};
|
|
1747
|
+
if (opts.signal !== void 0) send.signal = opts.signal;
|
|
1748
|
+
if (opts.keepalive !== void 0) send.keepalive = opts.keepalive;
|
|
1749
|
+
await this.request("DELETE", `/account/worlds/${encodeURIComponent(worldId)}/keys/${encodeURIComponent(keyId)}`, send);
|
|
1750
|
+
}
|
|
1730
1751
|
// -- Sign in with OnlyWorlds (OAuth 2.1 code + PKCE, keel PR 154) ---------
|
|
1731
1752
|
/**
|
|
1732
1753
|
* Start Sign in with OnlyWorlds from a tool's page: mint `state` and a PKCE verifier, keep them
|
|
@@ -1841,11 +1862,14 @@ var OwV2Client = class {
|
|
|
1841
1862
|
if (opts.elementWrite) headers["X-OW-Client"] = this.clientName;
|
|
1842
1863
|
let res;
|
|
1843
1864
|
try {
|
|
1844
|
-
|
|
1865
|
+
const init = {
|
|
1845
1866
|
method,
|
|
1846
1867
|
headers,
|
|
1847
1868
|
body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
1848
|
-
}
|
|
1869
|
+
};
|
|
1870
|
+
if (opts.signal !== void 0) init.signal = opts.signal;
|
|
1871
|
+
if (opts.keepalive !== void 0) init.keepalive = opts.keepalive;
|
|
1872
|
+
res = await this.fetchImpl(url, init);
|
|
1849
1873
|
} catch (cause) {
|
|
1850
1874
|
throw new OwNetworkError(`OnlyWorlds request failed: ${method} ${path}`, cause);
|
|
1851
1875
|
}
|
|
@@ -2041,7 +2065,9 @@ var REQUEST_OPTION_KEYS = [
|
|
|
2041
2065
|
"proposable",
|
|
2042
2066
|
"ifMatch",
|
|
2043
2067
|
"ifNoneMatch",
|
|
2044
|
-
"onEtag"
|
|
2068
|
+
"onEtag",
|
|
2069
|
+
"signal",
|
|
2070
|
+
"keepalive"
|
|
2045
2071
|
];
|
|
2046
2072
|
function only(method, obj, keys, hint = "") {
|
|
2047
2073
|
const k = unknownKey(obj, keys);
|