toolcraft 0.0.342 → 0.0.343

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/composition.json CHANGED
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.65",
101
+ "version": "0.1.68",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.342",
116
+ "version": "0.0.343",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.342",
126
+ "version": "0.0.343",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.65",
101
+ "version": "0.1.68",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.342",
116
+ "version": "0.0.343",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.342",
126
+ "version": "0.0.343",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.65",
21
+ "version": "0.1.68",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -31,6 +31,7 @@ const verifier = createJwksTokenVerifier({
31
31
  - `generateCodeVerifier()` and `generateCodeChallenge(...)`: PKCE helpers.
32
32
  - `normalizeStoredOAuthClient(value)`: normalize a saved client identity, full registration and ownership marker.
33
33
  - `normalizeOAuthScope(value)`: validate scope syntax and normalize its case-sensitive set.
34
+ - `waitForOAuthOperation(promise, signal?)`: settle the caller on cancellation while continuing to observe host completion.
34
35
  - `canonicalizeResourceIndicator(value)`: resource indicator canonicalization.
35
36
  - `createJwksTokenVerifier(options)`: JWKS-backed access-token verifier for MCP servers.
36
37
  - `OAuthError`: OAuth HTTP error type with status, retryability and known-outcome fields.
@@ -98,7 +99,8 @@ Native provider calls capture request option handles before host work. Unauthori
98
99
  handling also owns complete discovery metadata, presented grant values, rejected
99
100
  request headers and the selected challenge error before reading persistence.
100
101
  A browser callback cannot redirect a later code exchange by changing caller
101
- metadata. Explicit authentication owns metadata when lazy discovery returns;
102
+ metadata. Metadata loaded from a host session store is copied before clock or
103
+ fetch callbacks, retaining the original refresh endpoint and persisted extensions. Explicit authentication owns metadata when lazy discovery returns;
102
104
  the selected discovery method retains its original receiver and live host state.
103
105
 
104
106
  Provider request inputs accept an optional `signal`. It reaches callback waits,
@@ -593,12 +593,13 @@ function normalizeLoadedSession(session) {
593
593
  if (session === null) {
594
594
  return null;
595
595
  }
596
+ const discovery = structuredClone(session.discovery);
596
597
  const refreshState = getOwnEntry(session, "refreshState");
597
598
  if (refreshState !== undefined && (refreshState !== "pending" || getOwnEntry(session, "tokens") !== undefined))
598
599
  throw new Error("Stored OAuth refresh state is invalid");
599
600
  const client = normalizeStoredOAuthClient(getOwnEntry(session, "client"));
600
601
  if (client === null) {
601
- return { ...session, client: { clientId: "" }, tokens: undefined };
602
+ return { ...session, discovery, client: { clientId: "" }, tokens: undefined };
602
603
  }
603
604
  const tokens = normalizeStoredTokens(getOwnEntry(session, "tokens"));
604
605
  if (tokens !== undefined) {
@@ -609,7 +610,7 @@ function normalizeLoadedSession(session) {
609
610
  throw new Error("Stored OAuth access token is not a valid HTTP header value");
610
611
  }
611
612
  }
612
- return { ...session, client, tokens };
613
+ return { ...session, discovery, client, tokens };
613
614
  }
614
615
  function normalizeImportedTokens(value, now) {
615
616
  if (!isObjectRecord(value))
@@ -1,4 +1,5 @@
1
1
  export { normalizeOAuthScope } from "./client/scope.js";
2
+ export { waitForOAuthOperation } from "./client/cancellable-operation.js";
2
3
  export { parseOAuthTokenGrant } from "./client/token-grant.js";
3
4
  export type { OAuthTokenGrantImportOptions } from "./client/token-grant.js";
4
5
  export { createAuthStoreSessionStore, } from "./client/auth-store-session-store.js";
@@ -1,4 +1,5 @@
1
1
  export { normalizeOAuthScope } from "./client/scope.js";
2
+ export { waitForOAuthOperation } from "./client/cancellable-operation.js";
2
3
  export { parseOAuthTokenGrant } from "./client/token-grant.js";
3
4
  export { createAuthStoreSessionStore, } from "./client/auth-store-session-store.js";
4
5
  export { createResourceBoundOAuthStores } from "./client/resource-bound-store.js";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.65",
3
+ "version": "0.1.68",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -101,7 +101,7 @@ const transport = new HttpTransport({
101
101
  });
102
102
  ```
103
103
 
104
- You can also call `discoverOAuthMetadata(resourceUrl, options)` directly, or instantiate `OAuthMetadataDiscovery` with a custom `fetch` implementation and shared cache. Lookup options accept `signal`; cancellation stops metadata fetches and body reads without trying another discovery candidate.
104
+ You can also call `discoverOAuthMetadata(resourceUrl, options)` directly, or instantiate `OAuthMetadataDiscovery` with a custom `fetch` implementation and shared cache. An explicit `resourceMetadataUrl` requires fresh network discovery without reading either cache; validated results still populate both caches. Lookup options accept `signal`; cancellation stops metadata fetches and body reads without trying another discovery candidate. It also settles while shared-cache reads, writes or eviction wait. Host cache work may finish afterward; its late rejection remains observed, and canceled discovery does not start another candidate.
105
105
 
106
106
  OAuth provider inputs receive the originating request's `signal`, covering header authorization and unauthorized handling. Modern request cancellation stops its OAuth work while leaving other requests usable; transport disposal cancels all pending OAuth operations. The default provider propagates this signal to callback, registration and token work. Custom providers must observe it for their own operations.
107
107
 
@@ -3405,6 +3405,24 @@ function normalizeOAuthScope(scope) {
3405
3405
  return normalized || void 0;
3406
3406
  }
3407
3407
 
3408
+ // ../mcp-oauth/dist/client/cancellable-operation.js
3409
+ async function waitForOAuthOperation(operation, signal) {
3410
+ if (signal === void 0)
3411
+ return operation;
3412
+ let abort;
3413
+ try {
3414
+ return await new Promise((resolve, reject) => {
3415
+ abort = () => reject(signal.reason);
3416
+ signal.addEventListener("abort", abort, { once: true });
3417
+ operation.then(resolve, reject);
3418
+ if (signal.aborted)
3419
+ abort();
3420
+ });
3421
+ } finally {
3422
+ signal.removeEventListener("abort", abort);
3423
+ }
3424
+ }
3425
+
3408
3426
  // ../mcp-oauth/dist/client/bounded-json.js
3409
3427
  function copyBoundedOAuthJson(value, message) {
3410
3428
  const invalid = () => new Error(message);
@@ -5204,24 +5222,6 @@ function normalizeBearerTokenType(value) {
5204
5222
  return value.toLowerCase() === "bearer" ? "Bearer" : null;
5205
5223
  }
5206
5224
 
5207
- // ../mcp-oauth/dist/client/cancellable-operation.js
5208
- async function waitForOAuthOperation(operation, signal) {
5209
- if (signal === void 0)
5210
- return operation;
5211
- let abort;
5212
- try {
5213
- return await new Promise((resolve, reject) => {
5214
- abort = () => reject(signal.reason);
5215
- signal.addEventListener("abort", abort, { once: true });
5216
- operation.then(resolve, reject);
5217
- if (signal.aborted)
5218
- abort();
5219
- });
5220
- } finally {
5221
- signal.removeEventListener("abort", abort);
5222
- }
5223
- }
5224
-
5225
5225
  // ../mcp-oauth/dist/client/session-transaction.js
5226
5226
  var queues = /* @__PURE__ */ new WeakMap();
5227
5227
  async function withOAuthSessionTransaction(store, resource, operation, options = {}) {
@@ -5837,12 +5837,13 @@ function normalizeLoadedSession(session) {
5837
5837
  if (session === null) {
5838
5838
  return null;
5839
5839
  }
5840
+ const discovery = structuredClone(session.discovery);
5840
5841
  const refreshState = getOwnEntry6(session, "refreshState");
5841
5842
  if (refreshState !== void 0 && (refreshState !== "pending" || getOwnEntry6(session, "tokens") !== void 0))
5842
5843
  throw new Error("Stored OAuth refresh state is invalid");
5843
5844
  const client = normalizeStoredOAuthClient(getOwnEntry6(session, "client"));
5844
5845
  if (client === null) {
5845
- return { ...session, client: { clientId: "" }, tokens: void 0 };
5846
+ return { ...session, discovery, client: { clientId: "" }, tokens: void 0 };
5846
5847
  }
5847
5848
  const tokens = normalizeStoredTokens(getOwnEntry6(session, "tokens"));
5848
5849
  if (tokens !== void 0) {
@@ -5852,7 +5853,7 @@ function normalizeLoadedSession(session) {
5852
5853
  throw new Error("Stored OAuth access token is not a valid HTTP header value");
5853
5854
  }
5854
5855
  }
5855
- return { ...session, client, tokens };
5856
+ return { ...session, discovery, client, tokens };
5856
5857
  }
5857
5858
  function normalizeImportedTokens(value, now) {
5858
5859
  if (!isObjectRecord3(value))
@@ -6423,6 +6424,20 @@ function validateCachedDiscovery(value, resource) {
6423
6424
  authorizationServerMetadata
6424
6425
  });
6425
6426
  }
6427
+ async function waitForCache(operation, signal) {
6428
+ if (signal === void 0) return operation;
6429
+ let abort;
6430
+ try {
6431
+ return await new Promise((resolve, reject) => {
6432
+ abort = () => reject(signal.reason);
6433
+ signal.addEventListener("abort", abort, { once: true });
6434
+ Promise.resolve(operation).then(resolve, reject);
6435
+ if (signal.aborted) abort();
6436
+ });
6437
+ } finally {
6438
+ signal.removeEventListener("abort", abort);
6439
+ }
6440
+ }
6426
6441
  var OAuthMetadataDiscovery = class {
6427
6442
  fetchImpl;
6428
6443
  cache;
@@ -6459,7 +6474,7 @@ var OAuthMetadataDiscovery = class {
6459
6474
  if (memoryCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6460
6475
  return structuredClone(memoryCachedResult);
6461
6476
  }
6462
- const sharedCachedResult = await this.cache?.get(cacheKey);
6477
+ const sharedCachedResult = resourceMetadataUrl === void 0 ? await waitForCache(this.cache?.get(cacheKey), signal) : void 0;
6463
6478
  signal?.throwIfAborted();
6464
6479
  if (sharedCachedResult !== null && sharedCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6465
6480
  try {
@@ -6467,7 +6482,7 @@ var OAuthMetadataDiscovery = class {
6467
6482
  this.memoryCache.set(cacheKey, structuredClone(result));
6468
6483
  return result;
6469
6484
  } catch {
6470
- await this.cache?.delete?.(cacheKey);
6485
+ await waitForCache(this.cache?.delete?.(cacheKey), signal);
6471
6486
  }
6472
6487
  }
6473
6488
  const { location: resourceMetadataLocation, metadata: resourceMetadata } = await this.discoverProtectedResource(cacheKey, resourceMetadataUrl, signal);
@@ -6490,7 +6505,7 @@ var OAuthMetadataDiscovery = class {
6490
6505
  authorizationServerMetadata
6491
6506
  };
6492
6507
  this.memoryCache.set(cacheKey, structuredClone(result));
6493
- await this.cache?.set(cacheKey, structuredClone(result));
6508
+ await waitForCache(this.cache?.set(cacheKey, structuredClone(result)), signal);
6494
6509
  return result;
6495
6510
  } catch (error) {
6496
6511
  signal?.throwIfAborted();
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.342",
11
+ "version": "0.0.343",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.342",
3
+ "version": "0.0.343",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.342",
3
+ "version": "0.0.343",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.342",
161
+ "toolcraft-schema": "0.0.343",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",