@onlyworlds/sdk 4.104.1 → 4.104.2

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.104.2] - 2026-10-29
9
+
10
+ ### Fixed
11
+
12
+ - **`completeSignIn` keeps a sign-in pending when a return carries another state.** It cleared the pending record before checking the state, so any page that opened a native app's custom scheme (`obsidian://onlyworlds-signin?state=anything`) could cancel a sign-in in flight. Now a return whose state does not match leaves the record as it is, and the real return still signs in. Once a return carries the sign-in's own state, the record is cleared whatever follows: a refusal, a cancel on the consent page, or the wrong page.
13
+ - **`OwMember.sponsor_member`**, which the server now serves on agent rows of `members()`: who answers for the AI, as a membership id on the same list, `owner`, or null (a seat made from a link for an email address, or a sponsor with no live membership). Person and player rows carry none.
14
+
8
15
  ## [4.104.1] - 2026-10-29
9
16
 
10
17
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -2723,6 +2723,13 @@ interface OwMember {
2723
2723
  lenses: string[];
2724
2724
  /** Where `lenses` comes from: `chosen` (the row's own list, empty for none) or `titles` (it chose none, and its Character's Titles bring these). */
2725
2725
  lenses_from: 'chosen' | 'titles';
2726
+ /**
2727
+ * Agent rows only: who answers for this AI, as the roster names them: the sponsor's membership id
2728
+ * (the `id` of their row here), `owner` when the world's owner answers for it, or null for a seat
2729
+ * made from a link for an email address and for a sponsor with no live membership here. Every
2730
+ * reader reads it; person and player rows carry no `sponsor_member`.
2731
+ */
2732
+ sponsor_member?: string | null;
2726
2733
  /**
2727
2734
  * Served only, never written: present only when `lenses` was served with a lens left out, one this
2728
2735
  * key cannot see; then it names `lenses`. Saving the list you were shown keeps that lens where it stands.
@@ -3853,8 +3860,8 @@ declare function pinExpectation(kind: OwKeyKind): 'never' | 'optional' | 'requir
3853
3860
  * callback page: it checks `state` and that the page is the registered return address, takes the
3854
3861
  * code out of the address bar, trades it at `POST /api/v2/auth/token` with no credential, and
3855
3862
  * returns the token with the account and the `resume` the tool parked before the redirect. The
3856
- * SDK keeps nothing: the record is cleared on success and on refusal, and the token is the tool's
3857
- * to store.
3863
+ * SDK keeps nothing: the record is cleared once a return carries its state (success or refusal; a
3864
+ * return with another state leaves it pending), and the token is the tool's to store.
3858
3865
  */
3859
3866
  /** Where the pending sign-in's record lives between the two pages: string in, string out. */
3860
3867
  interface OwSignInStorage {
@@ -4728,7 +4735,8 @@ declare class OwV2Client {
4728
4735
  * `code` and `state` out of the address bar (only when `url` is not given: a native app passes
4729
4736
  * the address its loopback server or scheme handler received), trade
4730
4737
  * the code once at `POST /auth/token` with the PKCE verifier and no credential, and return the
4731
- * `ow_a_` token with the account and `resume`. The record is cleared on success and on refusal;
4738
+ * `ow_a_` token with the account and `resume`. The record is cleared once a return carries its
4739
+ * state, on success and on refusal; a return with another state leaves the sign-in pending;
4732
4740
  * the SDK keeps no token: the tool does. Refusals are `OwSignInError`: `state_mismatch` (no
4733
4741
  * pending sign-in, a different state, or the wrong page; nothing sent), `invalid_grant` (keel's
4734
4742
  * 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`.
package/dist/index.js CHANGED
@@ -608,7 +608,6 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
608
608
  }
609
609
  const key = RECORD_PREFIX + clientId;
610
610
  const raw = storage.get(key);
611
- storage.remove(key);
612
611
  let record = null;
613
612
  try {
614
613
  record = raw ? JSON.parse(raw) : null;
@@ -616,9 +615,14 @@ async function completeSignIn(baseUrl, fetchImpl, opts) {
616
615
  record = null;
617
616
  }
618
617
  if (!record || typeof record.state !== "string" || typeof record.verifier !== "string" || typeof record.redirectUri !== "string") {
618
+ storage.remove(key);
619
619
  throw new OwSignInError("state_mismatch", "No sign-in is pending for this tool here: start again from the sign-in button.");
620
620
  }
621
- if (!code || !state || state !== record.state) {
621
+ if (state !== record.state) {
622
+ throw new OwSignInError("state_mismatch", "This page was not reached from the sign-in that was started here: start again.");
623
+ }
624
+ storage.remove(key);
625
+ if (!code) {
622
626
  throw new OwSignInError("state_mismatch", "This page was not reached from the sign-in that was started here: start again.");
623
627
  }
624
628
  if (!samePage(here, record.redirectUri)) {
@@ -1940,7 +1944,8 @@ var OwV2Client = class {
1940
1944
  * `code` and `state` out of the address bar (only when `url` is not given: a native app passes
1941
1945
  * the address its loopback server or scheme handler received), trade
1942
1946
  * the code once at `POST /auth/token` with the PKCE verifier and no credential, and return the
1943
- * `ow_a_` token with the account and `resume`. The record is cleared on success and on refusal;
1947
+ * `ow_a_` token with the account and `resume`. The record is cleared once a return carries its
1948
+ * state, on success and on refusal; a return with another state leaves the sign-in pending;
1944
1949
  * the SDK keeps no token: the tool does. Refusals are `OwSignInError`: `state_mismatch` (no
1945
1950
  * pending sign-in, a different state, or the wrong page; nothing sent), `invalid_grant` (keel's
1946
1951
  * 400: used, expired, or another client's code), `rate_limited`, `offline`, `failed`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.104.1",
3
+ "version": "4.104.2",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {