tiny-http-mcp-server 0.1.43 → 0.1.44

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.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.43",
21
+ "version": "0.1.44",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -29,6 +29,8 @@ const verifier = createJwksTokenVerifier({
29
29
  - `createAuthStoreSessionStore(options)`: persisted OAuth session store backed by `auth-store`.
30
30
  - `createLoopbackAuthorizationSession(options)`: local callback server for browser authorization.
31
31
  - `generateCodeVerifier()` and `generateCodeChallenge(...)`: PKCE helpers.
32
+ - `normalizeStoredOAuthClient(value)`: normalize a saved client identity, full registration and ownership marker.
33
+ - `normalizeOAuthScope(value)`: validate scope syntax and normalize its case-sensitive set.
32
34
  - `canonicalizeResourceIndicator(value)`: resource indicator canonicalization.
33
35
  - `createJwksTokenVerifier(options)`: JWKS-backed access-token verifier for MCP servers.
34
36
  - `OAuthError`: token endpoint error type.
@@ -1,8 +1,45 @@
1
1
  export async function fetchMcpResponse(fetchImplementation, input, init = {}) {
2
- const response = await fetchImplementation(input, { ...init, redirect: "error" });
3
- if (response.redirected || response.type === "opaqueredirect") {
4
- void response.body?.cancel().catch(() => undefined);
5
- throw new Error("MCP HTTP redirects are not allowed");
6
- }
7
- return response;
2
+ const signal = init.signal;
3
+ signal?.throwIfAborted();
4
+ return new Promise((resolve, reject) => {
5
+ let settled = false;
6
+ const finish = (error, response) => {
7
+ if (settled)
8
+ return;
9
+ settled = true;
10
+ signal?.removeEventListener("abort", abort);
11
+ if (response === undefined)
12
+ reject(error);
13
+ else
14
+ resolve(response);
15
+ };
16
+ const abort = () => finish(signal?.reason);
17
+ signal?.addEventListener("abort", abort, { once: true });
18
+ if (signal?.aborted) {
19
+ abort();
20
+ return;
21
+ }
22
+ let pending;
23
+ try {
24
+ pending = fetchImplementation(input, { ...init, redirect: "error" });
25
+ }
26
+ catch (error) {
27
+ finish(error);
28
+ return;
29
+ }
30
+ void pending.then(response => {
31
+ if (settled || signal?.aborted) {
32
+ void response.body?.cancel().catch(() => undefined);
33
+ if (!settled)
34
+ abort();
35
+ return;
36
+ }
37
+ if (response.redirected || response.type === "opaqueredirect") {
38
+ void response.body?.cancel().catch(() => undefined);
39
+ finish(new Error("MCP HTTP redirects are not allowed"));
40
+ }
41
+ else
42
+ finish(undefined, response);
43
+ }, error => finish(error));
44
+ });
8
45
  }
@@ -1,9 +1,10 @@
1
+ export { normalizeOAuthScope } from "./client/scope.js";
1
2
  export { parseOAuthTokenGrant } from "./client/token-grant.js";
2
3
  export type { OAuthTokenGrantImportOptions } 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 type { ResourceBoundOAuthStores } from "./client/resource-bound-store.js";
6
- export { parseOAuthClientRegistration } from "./client/client-registration.js";
7
+ export { parseOAuthClientRegistration, normalizeStoredOAuthClient } from "./client/client-registration.js";
7
8
  export { createDefaultOAuthClientProvider, createOAuthClientProvider, } from "./client/default-oauth-client-provider.js";
8
9
  export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, } from "./client/loopback-authorization.js";
9
10
  export { generateCodeChallenge, generateCodeVerifier, } from "./client/pkce.js";
@@ -1,7 +1,8 @@
1
+ export { normalizeOAuthScope } from "./client/scope.js";
1
2
  export { parseOAuthTokenGrant } from "./client/token-grant.js";
2
3
  export { createAuthStoreSessionStore, } from "./client/auth-store-session-store.js";
3
4
  export { createResourceBoundOAuthStores } from "./client/resource-bound-store.js";
4
- export { parseOAuthClientRegistration } from "./client/client-registration.js";
5
+ export { parseOAuthClientRegistration, normalizeStoredOAuthClient } from "./client/client-registration.js";
5
6
  export { createDefaultOAuthClientProvider, createOAuthClientProvider, } from "./client/default-oauth-client-provider.js";
6
7
  export { buildSuccessPage, createLoopbackAuthorizationSession, extractCodeFromInput, } from "./client/loopback-authorization.js";
7
8
  export { generateCodeChallenge, generateCodeVerifier, } from "./client/pkce.js";
@@ -3395,6 +3395,16 @@ var SubscriptionManager = class {
3395
3395
  }
3396
3396
  };
3397
3397
 
3398
+ // ../mcp-oauth/dist/client/scope.js
3399
+ function normalizeOAuthScope(scope) {
3400
+ if (scope === void 0)
3401
+ return void 0;
3402
+ if (typeof scope !== "string" || [...scope].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) > 126 || char === '"' || char === "\\"))
3403
+ throw new Error("Invalid OAuth scope syntax");
3404
+ const normalized = [...new Set(scope.split(" ").filter(Boolean))].sort().join(" ");
3405
+ return normalized || void 0;
3406
+ }
3407
+
3398
3408
  // ../mcp-oauth/dist/client/bounded-json.js
3399
3409
  function copyBoundedOAuthJson(value, message) {
3400
3410
  const invalid = () => new Error(message);
@@ -3441,16 +3451,6 @@ function copyBoundedOAuthJson(value, message) {
3441
3451
  return result;
3442
3452
  }
3443
3453
 
3444
- // ../mcp-oauth/dist/client/scope.js
3445
- function normalizeOAuthScope(scope) {
3446
- if (scope === void 0)
3447
- return void 0;
3448
- if (typeof scope !== "string" || [...scope].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) > 126 || char === '"' || char === "\\"))
3449
- throw new Error("Invalid OAuth scope syntax");
3450
- const normalized = [...new Set(scope.split(" ").filter(Boolean))].sort().join(" ");
3451
- return normalized || void 0;
3452
- }
3453
-
3454
3454
  // ../mcp-oauth/dist/client/loopback-authorization.js
3455
3455
  import http from "node:http";
3456
3456
 
@@ -4898,12 +4898,47 @@ import { isIP } from "node:net";
4898
4898
 
4899
4899
  // ../mcp-oauth/dist/http-fetch.js
4900
4900
  async function fetchMcpResponse(fetchImplementation, input, init = {}) {
4901
- const response = await fetchImplementation(input, { ...init, redirect: "error" });
4902
- if (response.redirected || response.type === "opaqueredirect") {
4903
- void response.body?.cancel().catch(() => void 0);
4904
- throw new Error("MCP HTTP redirects are not allowed");
4905
- }
4906
- return response;
4901
+ const signal = init.signal;
4902
+ signal?.throwIfAborted();
4903
+ return new Promise((resolve, reject) => {
4904
+ let settled = false;
4905
+ const finish = (error, response) => {
4906
+ if (settled)
4907
+ return;
4908
+ settled = true;
4909
+ signal?.removeEventListener("abort", abort);
4910
+ if (response === void 0)
4911
+ reject(error);
4912
+ else
4913
+ resolve(response);
4914
+ };
4915
+ const abort = () => finish(signal?.reason);
4916
+ signal?.addEventListener("abort", abort, { once: true });
4917
+ if (signal?.aborted) {
4918
+ abort();
4919
+ return;
4920
+ }
4921
+ let pending;
4922
+ try {
4923
+ pending = fetchImplementation(input, { ...init, redirect: "error" });
4924
+ } catch (error) {
4925
+ finish(error);
4926
+ return;
4927
+ }
4928
+ void pending.then((response) => {
4929
+ if (settled || signal?.aborted) {
4930
+ void response.body?.cancel().catch(() => void 0);
4931
+ if (!settled)
4932
+ abort();
4933
+ return;
4934
+ }
4935
+ if (response.redirected || response.type === "opaqueredirect") {
4936
+ void response.body?.cancel().catch(() => void 0);
4937
+ finish(new Error("MCP HTTP redirects are not allowed"));
4938
+ } else
4939
+ finish(void 0, response);
4940
+ }, (error) => finish(error));
4941
+ });
4907
4942
  }
4908
4943
 
4909
4944
  // ../mcp-oauth/dist/client/default-oauth-client-provider.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",