@onlyworlds/sdk 4.78.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 CHANGED
@@ -5,6 +5,13 @@ 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
+
8
15
  ## [4.78.0] - 2026-10-26
9
16
 
10
17
  ### Added
package/dist/index.d.ts CHANGED
@@ -4301,9 +4301,16 @@ declare class OwV2Client {
4301
4301
  * returned: from then on it answers 401 `key_revoked`. The owner revokes any of the world's keys,
4302
4302
  * a member only their own; any other id is a 404 (`err.isNotFound`). Revoking a revoked key
4303
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. Account token only.
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.
4305
4309
  */
4306
- revokeWorldKey(worldId: string, keyId: string): Promise<void>;
4310
+ revokeWorldKey(worldId: string, keyId: string, opts?: {
4311
+ signal?: AbortSignal;
4312
+ keepalive?: boolean;
4313
+ }): Promise<void>;
4307
4314
  /**
4308
4315
  * Start Sign in with OnlyWorlds from a tool's page: mint `state` and a PKCE verifier, keep them
4309
4316
  * under `clientId` in `storage` (sessionStorage by default; in Node pass one), and send the
@@ -4393,6 +4400,10 @@ declare class OwV2Client {
4393
4400
  * the body is read. With it given, a 304 Not Modified returns null instead of throwing.
4394
4401
  */
4395
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;
4396
4407
  }): Promise<T>;
4397
4408
  }
4398
4409
  /**
package/dist/index.js CHANGED
@@ -1732,13 +1732,21 @@ var OwV2Client = class {
1732
1732
  * returned: from then on it answers 401 `key_revoked`. The owner revokes any of the world's keys,
1733
1733
  * a member only their own; any other id is a 404 (`err.isNotFound`). Revoking a revoked key
1734
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. Account token only.
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.
1736
1740
  */
1737
- async revokeWorldKey(worldId, keyId) {
1741
+ async revokeWorldKey(worldId, keyId, opts = {}) {
1742
+ only("revokeWorldKey", opts, ["signal", "keepalive"]);
1738
1743
  if (this.keyKind !== "account") {
1739
1744
  throw new TypeError("revokeWorldKey needs an account token (ow_a_)");
1740
1745
  }
1741
- await this.request("DELETE", `/account/worlds/${encodeURIComponent(worldId)}/keys/${encodeURIComponent(keyId)}`);
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);
1742
1750
  }
1743
1751
  // -- Sign in with OnlyWorlds (OAuth 2.1 code + PKCE, keel PR 154) ---------
1744
1752
  /**
@@ -1854,11 +1862,14 @@ var OwV2Client = class {
1854
1862
  if (opts.elementWrite) headers["X-OW-Client"] = this.clientName;
1855
1863
  let res;
1856
1864
  try {
1857
- res = await this.fetchImpl(url, {
1865
+ const init = {
1858
1866
  method,
1859
1867
  headers,
1860
1868
  body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
1861
- });
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);
1862
1873
  } catch (cause) {
1863
1874
  throw new OwNetworkError(`OnlyWorlds request failed: ${method} ${path}`, cause);
1864
1875
  }
@@ -2054,7 +2065,9 @@ var REQUEST_OPTION_KEYS = [
2054
2065
  "proposable",
2055
2066
  "ifMatch",
2056
2067
  "ifNoneMatch",
2057
- "onEtag"
2068
+ "onEtag",
2069
+ "signal",
2070
+ "keepalive"
2058
2071
  ];
2059
2072
  function only(method, obj, keys, hint = "") {
2060
2073
  const k = unknownKey(obj, keys);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.78.0",
3
+ "version": "4.79.0",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {