toolcraft 0.0.342 → 0.0.344

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.70",
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.344",
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.344",
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.70",
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.344",
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.344",
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.70",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -24,13 +24,19 @@ const verifier = createJwksTokenVerifier({
24
24
 
25
25
  ## Public API
26
26
 
27
+ `OAuthError.is(value)` recognizes native token/challenge failures across separately
28
+ bundled package copies while preserving the SDK diagnostic fields. Error names
29
+ alone do not establish either native error type.
30
+
27
31
  - `createDefaultOAuthClientProvider(options)`: default MCP OAuth client provider with dynamic or static client registration.
28
32
  - `createOAuthClientProvider(options)`: lower-level provider constructor.
29
33
  - `createAuthStoreSessionStore(options)`: persisted OAuth session store backed by `auth-store`.
30
34
  - `createLoopbackAuthorizationSession(options)`: local callback server for browser authorization.
35
+ - `OAuthAuthorizationError`: a callback denial with its original `error`, `errorDescription` and message for host observers. Use `OAuthAuthorizationError.is(value)` to recognize errors across separately bundled package copies.
31
36
  - `generateCodeVerifier()` and `generateCodeChallenge(...)`: PKCE helpers.
32
37
  - `normalizeStoredOAuthClient(value)`: normalize a saved client identity, full registration and ownership marker.
33
38
  - `normalizeOAuthScope(value)`: validate scope syntax and normalize its case-sensitive set.
39
+ - `waitForOAuthOperation(promise, signal?)`: settle the caller on cancellation while continuing to observe host completion.
34
40
  - `canonicalizeResourceIndicator(value)`: resource indicator canonicalization.
35
41
  - `createJwksTokenVerifier(options)`: JWKS-backed access-token verifier for MCP servers.
36
42
  - `OAuthError`: OAuth HTTP error type with status, retryability and known-outcome fields.
@@ -98,7 +104,8 @@ Native provider calls capture request option handles before host work. Unauthori
98
104
  handling also owns complete discovery metadata, presented grant values, rejected
99
105
  request headers and the selected challenge error before reading persistence.
100
106
  A browser callback cannot redirect a later code exchange by changing caller
101
- metadata. Explicit authentication owns metadata when lazy discovery returns;
107
+ metadata. Metadata loaded from a host session store is copied before clock or
108
+ fetch callbacks, retaining the original refresh endpoint and persisted extensions. Explicit authentication owns metadata when lazy discovery returns;
102
109
  the selected discovery method retains its original receiver and live host state.
103
110
 
104
111
  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))
@@ -20,6 +20,14 @@ export interface LoopbackAuthorizationSession {
20
20
  waitForCode(authorizationUrl: string): Promise<string>;
21
21
  close(): void;
22
22
  }
23
+ /** Authorization callback denial, retaining the provider diagnostic for host observers. */
24
+ export declare class OAuthAuthorizationError extends Error {
25
+ readonly error: string;
26
+ readonly errorDescription: string;
27
+ /** Recognize errors from separately bundled copies of this package. */
28
+ static is(value: unknown): value is OAuthAuthorizationError;
29
+ constructor(error: string, errorDescription: string);
30
+ }
23
31
  export declare function createLoopbackAuthorizationSession(options?: LoopbackAuthorizationOptions): Promise<LoopbackAuthorizationSession>;
24
32
  export declare function loopbackTarget(options: LoopbackAuthorizationOptions): {
25
33
  port: number;
@@ -1,5 +1,22 @@
1
1
  import http from "node:http";
2
2
  import { parseAuthorizationState } from "./authorization-state.js";
3
+ const authorizationErrorBrand = Symbol.for("poe-platform.mcp-oauth.OAuthAuthorizationError");
4
+ /** Authorization callback denial, retaining the provider diagnostic for host observers. */
5
+ export class OAuthAuthorizationError extends Error {
6
+ error;
7
+ errorDescription;
8
+ /** Recognize errors from separately bundled copies of this package. */
9
+ static is(value) {
10
+ return value instanceof Error && Object.getOwnPropertyDescriptor(value, authorizationErrorBrand)?.value === true;
11
+ }
12
+ constructor(error, errorDescription) {
13
+ super(`OAuth authorization failed: ${error} — ${errorDescription}`);
14
+ this.error = error;
15
+ this.errorDescription = errorDescription;
16
+ this.name = "OAuthAuthorizationError";
17
+ Object.defineProperty(this, authorizationErrorBrand, { value: true });
18
+ }
19
+ }
3
20
  export async function createLoopbackAuthorizationSession(options = {}) {
4
21
  options.signal?.throwIfAborted();
5
22
  const timeoutMs = options.timeoutMs ?? 120_000;
@@ -144,7 +161,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
144
161
  try {
145
162
  validateAuthorizationCallbackBinding(callbackParameters, expectedAuthorization);
146
163
  if (callbackParameters.error !== null)
147
- throw createAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
164
+ throw new OAuthAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
148
165
  const code = validateAuthorizationCallbackParameters(callbackParameters, expectedAuthorization);
149
166
  res.writeHead(200, { "Content-Type": "text/html" });
150
167
  res.end(buildSuccessPage(options.landingPage));
@@ -167,7 +184,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
167
184
  throw new Error("OAuth callback missing authorization code");
168
185
  validateAuthorizationCallbackBinding(callbackParameters, expectedAuthorization);
169
186
  if (callbackParameters.error !== null)
170
- throw createAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
187
+ throw new OAuthAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
171
188
  const code = validateAuthorizationCallbackParameters(callbackParameters, expectedAuthorization);
172
189
  settle(() => resolve(code));
173
190
  }).catch(error => settle(() => reject(error)));
@@ -244,9 +261,6 @@ function validateAuthorizationCallbackBinding(callback, expected) {
244
261
  throw new Error("OAuth callback issuer mismatch");
245
262
  }
246
263
  }
247
- function createAuthorizationError(error, description) {
248
- return new Error(`OAuth authorization failed: ${error} — ${description}`);
249
- }
250
264
  function escapeHtml(text) {
251
265
  return text
252
266
  .replaceAll("&", "&amp;")
@@ -5,6 +5,8 @@ interface OAuthErrorShape {
5
5
  error_uri?: string;
6
6
  }
7
7
  export declare class OAuthError extends Error {
8
+ /** Recognize errors from separately bundled copies of this package. */
9
+ static is(value: unknown): value is OAuthError;
8
10
  readonly error: string;
9
11
  readonly errorDescription: string | undefined;
10
12
  readonly errorUri: string | undefined;
@@ -4,7 +4,12 @@ import { readBoundedResponseText } from "../http-response.js";
4
4
  import { fetchMcpResponse } from "../http-fetch.js";
5
5
  import { normalizeOAuthScope } from "./scope.js";
6
6
  const MAX_JS_DATE_MS = 8_640_000_000_000_000;
7
+ const oauthErrorBrand = Symbol.for("poe-platform.mcp-oauth.OAuthError");
7
8
  export class OAuthError extends Error {
9
+ /** Recognize errors from separately bundled copies of this package. */
10
+ static is(value) {
11
+ return value instanceof Error && Object.getOwnPropertyDescriptor(value, oauthErrorBrand)?.value === true;
12
+ }
8
13
  error;
9
14
  errorDescription;
10
15
  errorUri;
@@ -20,6 +25,7 @@ export class OAuthError extends Error {
20
25
  const uri = Object.hasOwn(shape, "error_uri") ? shape.error_uri : undefined;
21
26
  super(description ?? (outcomeKnown ? shape.error : `OAuth HTTP response did not contain a valid error (HTTP ${status})`));
22
27
  this.name = "OAuthError";
28
+ Object.defineProperty(this, oauthErrorBrand, { value: true });
23
29
  this.error = shape.error;
24
30
  this.errorDescription = description;
25
31
  this.errorUri = uri;
@@ -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";
@@ -6,7 +7,7 @@ export { createResourceBoundOAuthStores } from "./client/resource-bound-store.js
6
7
  export type { ResourceBoundOAuthStores } from "./client/resource-bound-store.js";
7
8
  export { parseOAuthClientRegistration, normalizeStoredOAuthClient } from "./client/client-registration.js";
8
9
  export { createDefaultOAuthClientProvider, createOAuthClientProvider, } from "./client/default-oauth-client-provider.js";
9
- export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, } from "./client/loopback-authorization.js";
10
+ export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, OAuthAuthorizationError, } from "./client/loopback-authorization.js";
10
11
  export { generateCodeChallenge, generateCodeVerifier, } from "./client/pkce.js";
11
12
  export { OAuthError, } from "./client/token-endpoint.js";
12
13
  export { canonicalizeResourceIndicator, } from "./resource-indicator.js";
@@ -1,10 +1,11 @@
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";
5
6
  export { parseOAuthClientRegistration, normalizeStoredOAuthClient } from "./client/client-registration.js";
6
7
  export { createDefaultOAuthClientProvider, createOAuthClientProvider, } from "./client/default-oauth-client-provider.js";
7
- export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, } from "./client/loopback-authorization.js";
8
+ export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, OAuthAuthorizationError, } from "./client/loopback-authorization.js";
8
9
  export { generateCodeChallenge, generateCodeVerifier, } from "./client/pkce.js";
9
10
  export { OAuthError, } from "./client/token-endpoint.js";
10
11
  export { canonicalizeResourceIndicator, } from "./resource-indicator.js";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.65",
3
+ "version": "0.1.70",
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);
@@ -3498,6 +3516,22 @@ function getOwnEntry(record2, key2) {
3498
3516
  }
3499
3517
 
3500
3518
  // ../mcp-oauth/dist/client/loopback-authorization.js
3519
+ var authorizationErrorBrand = /* @__PURE__ */ Symbol.for("poe-platform.mcp-oauth.OAuthAuthorizationError");
3520
+ var OAuthAuthorizationError = class extends Error {
3521
+ error;
3522
+ errorDescription;
3523
+ /** Recognize errors from separately bundled copies of this package. */
3524
+ static is(value) {
3525
+ return value instanceof Error && Object.getOwnPropertyDescriptor(value, authorizationErrorBrand)?.value === true;
3526
+ }
3527
+ constructor(error, errorDescription) {
3528
+ super(`OAuth authorization failed: ${error} \u2014 ${errorDescription}`);
3529
+ this.error = error;
3530
+ this.errorDescription = errorDescription;
3531
+ this.name = "OAuthAuthorizationError";
3532
+ Object.defineProperty(this, authorizationErrorBrand, { value: true });
3533
+ }
3534
+ };
3501
3535
  async function createLoopbackAuthorizationSession(options = {}) {
3502
3536
  options.signal?.throwIfAborted();
3503
3537
  const timeoutMs = options.timeoutMs ?? 12e4;
@@ -3645,7 +3679,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
3645
3679
  try {
3646
3680
  validateAuthorizationCallbackBinding(callbackParameters, expectedAuthorization);
3647
3681
  if (callbackParameters.error !== null)
3648
- throw createAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
3682
+ throw new OAuthAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
3649
3683
  const code = validateAuthorizationCallbackParameters(callbackParameters, expectedAuthorization);
3650
3684
  res.writeHead(200, { "Content-Type": "text/html" });
3651
3685
  res.end(buildSuccessPage(options.landingPage));
@@ -3667,7 +3701,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
3667
3701
  throw new Error("OAuth callback missing authorization code");
3668
3702
  validateAuthorizationCallbackBinding(callbackParameters, expectedAuthorization);
3669
3703
  if (callbackParameters.error !== null)
3670
- throw createAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
3704
+ throw new OAuthAuthorizationError(callbackParameters.error, callbackParameters.errorDescription ?? callbackParameters.error);
3671
3705
  const code = validateAuthorizationCallbackParameters(callbackParameters, expectedAuthorization);
3672
3706
  settle(() => resolve(code));
3673
3707
  }).catch((error) => settle(() => reject(error)));
@@ -3736,9 +3770,6 @@ function validateAuthorizationCallbackBinding(callback, expected) {
3736
3770
  throw new Error("OAuth callback issuer mismatch");
3737
3771
  }
3738
3772
  }
3739
- function createAuthorizationError(error, description) {
3740
- return new Error(`OAuth authorization failed: ${error} \u2014 ${description}`);
3741
- }
3742
3773
  function escapeHtml(text) {
3743
3774
  return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
3744
3775
  }
@@ -5020,7 +5051,12 @@ async function readBoundedResponseText(response, maxBytes, readers, signal) {
5020
5051
 
5021
5052
  // ../mcp-oauth/dist/client/token-endpoint.js
5022
5053
  var MAX_JS_DATE_MS2 = 864e13;
5054
+ var oauthErrorBrand = /* @__PURE__ */ Symbol.for("poe-platform.mcp-oauth.OAuthError");
5023
5055
  var OAuthError = class extends Error {
5056
+ /** Recognize errors from separately bundled copies of this package. */
5057
+ static is(value) {
5058
+ return value instanceof Error && Object.getOwnPropertyDescriptor(value, oauthErrorBrand)?.value === true;
5059
+ }
5024
5060
  error;
5025
5061
  errorDescription;
5026
5062
  errorUri;
@@ -5036,6 +5072,7 @@ var OAuthError = class extends Error {
5036
5072
  const uri = Object.hasOwn(shape, "error_uri") ? shape.error_uri : void 0;
5037
5073
  super(description ?? (outcomeKnown ? shape.error : `OAuth HTTP response did not contain a valid error (HTTP ${status})`));
5038
5074
  this.name = "OAuthError";
5075
+ Object.defineProperty(this, oauthErrorBrand, { value: true });
5039
5076
  this.error = shape.error;
5040
5077
  this.errorDescription = description;
5041
5078
  this.errorUri = uri;
@@ -5204,24 +5241,6 @@ function normalizeBearerTokenType(value) {
5204
5241
  return value.toLowerCase() === "bearer" ? "Bearer" : null;
5205
5242
  }
5206
5243
 
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
5244
  // ../mcp-oauth/dist/client/session-transaction.js
5226
5245
  var queues = /* @__PURE__ */ new WeakMap();
5227
5246
  async function withOAuthSessionTransaction(store, resource, operation, options = {}) {
@@ -5837,12 +5856,13 @@ function normalizeLoadedSession(session) {
5837
5856
  if (session === null) {
5838
5857
  return null;
5839
5858
  }
5859
+ const discovery = structuredClone(session.discovery);
5840
5860
  const refreshState = getOwnEntry6(session, "refreshState");
5841
5861
  if (refreshState !== void 0 && (refreshState !== "pending" || getOwnEntry6(session, "tokens") !== void 0))
5842
5862
  throw new Error("Stored OAuth refresh state is invalid");
5843
5863
  const client = normalizeStoredOAuthClient(getOwnEntry6(session, "client"));
5844
5864
  if (client === null) {
5845
- return { ...session, client: { clientId: "" }, tokens: void 0 };
5865
+ return { ...session, discovery, client: { clientId: "" }, tokens: void 0 };
5846
5866
  }
5847
5867
  const tokens = normalizeStoredTokens(getOwnEntry6(session, "tokens"));
5848
5868
  if (tokens !== void 0) {
@@ -5852,7 +5872,7 @@ function normalizeLoadedSession(session) {
5852
5872
  throw new Error("Stored OAuth access token is not a valid HTTP header value");
5853
5873
  }
5854
5874
  }
5855
- return { ...session, client, tokens };
5875
+ return { ...session, discovery, client, tokens };
5856
5876
  }
5857
5877
  function normalizeImportedTokens(value, now) {
5858
5878
  if (!isObjectRecord3(value))
@@ -6423,6 +6443,20 @@ function validateCachedDiscovery(value, resource) {
6423
6443
  authorizationServerMetadata
6424
6444
  });
6425
6445
  }
6446
+ async function waitForCache(operation, signal) {
6447
+ if (signal === void 0) return operation;
6448
+ let abort;
6449
+ try {
6450
+ return await new Promise((resolve, reject) => {
6451
+ abort = () => reject(signal.reason);
6452
+ signal.addEventListener("abort", abort, { once: true });
6453
+ Promise.resolve(operation).then(resolve, reject);
6454
+ if (signal.aborted) abort();
6455
+ });
6456
+ } finally {
6457
+ signal.removeEventListener("abort", abort);
6458
+ }
6459
+ }
6426
6460
  var OAuthMetadataDiscovery = class {
6427
6461
  fetchImpl;
6428
6462
  cache;
@@ -6459,7 +6493,7 @@ var OAuthMetadataDiscovery = class {
6459
6493
  if (memoryCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6460
6494
  return structuredClone(memoryCachedResult);
6461
6495
  }
6462
- const sharedCachedResult = await this.cache?.get(cacheKey);
6496
+ const sharedCachedResult = resourceMetadataUrl === void 0 ? await waitForCache(this.cache?.get(cacheKey), signal) : void 0;
6463
6497
  signal?.throwIfAborted();
6464
6498
  if (sharedCachedResult !== null && sharedCachedResult !== void 0 && resourceMetadataUrl === void 0) {
6465
6499
  try {
@@ -6467,7 +6501,7 @@ var OAuthMetadataDiscovery = class {
6467
6501
  this.memoryCache.set(cacheKey, structuredClone(result));
6468
6502
  return result;
6469
6503
  } catch {
6470
- await this.cache?.delete?.(cacheKey);
6504
+ await waitForCache(this.cache?.delete?.(cacheKey), signal);
6471
6505
  }
6472
6506
  }
6473
6507
  const { location: resourceMetadataLocation, metadata: resourceMetadata } = await this.discoverProtectedResource(cacheKey, resourceMetadataUrl, signal);
@@ -6490,7 +6524,7 @@ var OAuthMetadataDiscovery = class {
6490
6524
  authorizationServerMetadata
6491
6525
  };
6492
6526
  this.memoryCache.set(cacheKey, structuredClone(result));
6493
- await this.cache?.set(cacheKey, structuredClone(result));
6527
+ await waitForCache(this.cache?.set(cacheKey, structuredClone(result)), signal);
6494
6528
  return result;
6495
6529
  } catch (error) {
6496
6530
  signal?.throwIfAborted();
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.342",
11
+ "version": "0.0.344",
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.344",
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.344",
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.344",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",