tiny-http-mcp-server 0.1.65 → 0.1.67
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/dist/composition.json +1 -1
- package/node_modules/mcp-oauth/README.md +2 -1
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +3 -2
- package/node_modules/tiny-mcp-client/README.md +1 -1
- package/node_modules/tiny-mcp-client/dist/index.js +20 -5
- package/package.json +1 -1
package/dist/composition.json
CHANGED
|
@@ -98,7 +98,8 @@ Native provider calls capture request option handles before host work. Unauthori
|
|
|
98
98
|
handling also owns complete discovery metadata, presented grant values, rejected
|
|
99
99
|
request headers and the selected challenge error before reading persistence.
|
|
100
100
|
A browser callback cannot redirect a later code exchange by changing caller
|
|
101
|
-
metadata.
|
|
101
|
+
metadata. Metadata loaded from a host session store is copied before clock or
|
|
102
|
+
fetch callbacks, retaining the original refresh endpoint and persisted extensions. Explicit authentication owns metadata when lazy discovery returns;
|
|
102
103
|
the selected discovery method retains its original receiver and live host state.
|
|
103
104
|
|
|
104
105
|
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))
|
|
@@ -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
|
|
|
@@ -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();
|