teapot-coding-agent 0.36.1 → 0.36.3

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.
@@ -202,6 +202,32 @@ export class ServerAuth {
202
202
  throw new Error("no PKCE verifier — the authorization flow did not start here");
203
203
  return v;
204
204
  }
205
+ /**
206
+ * The SDK's discovery cache — the reason Notion's exchange never completed.
207
+ *
208
+ * The OAuth flow is split across TWO transport instances: the one that hits the 401 and
209
+ * redirects the browser, and the one built after the callback arrives. The SDK's own contract
210
+ * says this state "MUST persist with the same durability as `codeVerifier` (survives the
211
+ * redirect round-trip)", because the issuer recorded at redirect time is what the authorization
212
+ * response's `iss` is validated against (RFC 9207) when the code is redeemed.
213
+ *
214
+ * MEASURED on this machine's real store after a BROWSER-COMPLETED Notion authorization:
215
+ * `codeVerifier` present, `clientInformation.redirect_uris` a real ephemeral port
216
+ * (`http://127.0.0.1:37209/callback`), and no `accessToken` — the redeeming instance had
217
+ * re-discovered a different issuer binding, so the exchange never produced tokens. Both earlier
218
+ * fixes (persist the verifier, re-register on a redirect mismatch) were necessary and neither was
219
+ * sufficient.
220
+ */
221
+ discoveryState() {
222
+ return this.store.discoveryState;
223
+ }
224
+ async saveDiscoveryState(state) {
225
+ if (!state || typeof state !== "object")
226
+ return;
227
+ this.store.discoveryState = state;
228
+ // same durability as the verifier: the instance that redeems the code is not this one
229
+ await this.persist(this.server, this.store);
230
+ }
205
231
  // ---- teapot-facing ----
206
232
  /** the url the browser must open, once `redirectToAuthorization` has been called */
207
233
  pendingUrl() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.36.1",
3
+ "version": "0.36.3",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",