tiny-http-mcp-server 0.1.44 → 0.1.45

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.44",
21
+ "version": "0.1.45",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -33,7 +33,7 @@ const verifier = createJwksTokenVerifier({
33
33
  - `normalizeOAuthScope(value)`: validate scope syntax and normalize its case-sensitive set.
34
34
  - `canonicalizeResourceIndicator(value)`: resource indicator canonicalization.
35
35
  - `createJwksTokenVerifier(options)`: JWKS-backed access-token verifier for MCP servers.
36
- - `OAuthError`: token endpoint error type.
36
+ - `OAuthError`: OAuth HTTP error type with status, retryability and known-outcome fields.
37
37
 
38
38
  ## Configuration
39
39
 
@@ -244,3 +244,10 @@ cannot disable this policy.
244
244
 
245
245
  This package exposes no direct environment variables. When `authStore` is used,
246
246
  `auth-store` honors its own backend environment variables.
247
+
248
+ Malformed OAuth HTTP errors retain their numeric HTTP status without echoing
249
+ response bodies. Raw/incomplete client-error responses (including registration
250
+ HTTP 403) are nonretryable `invalid_response` errors; authorization fails without
251
+ waiting for consent that never started. Raw server errors remain transient.
252
+ `outcomeKnown: false` still withholds an uncertain rotating refresh family: a
253
+ nonretryable HTTP status alone does not prove a refresh token was unconsumed.
@@ -16,13 +16,15 @@ export class OAuthError extends Error {
16
16
  /** True only when a complete OAuth error response establishes rejection. */
17
17
  outcomeKnown;
18
18
  constructor(shape, status, outcomeKnown = true) {
19
- super(shape.error_description ?? shape.error);
19
+ const description = Object.hasOwn(shape, "error_description") ? shape.error_description : undefined;
20
+ const uri = Object.hasOwn(shape, "error_uri") ? shape.error_uri : undefined;
21
+ super(description ?? (outcomeKnown ? shape.error : `OAuth HTTP response did not contain a valid error (HTTP ${status})`));
20
22
  this.name = "OAuthError";
21
23
  this.error = shape.error;
22
- this.errorDescription = shape.error_description;
23
- this.errorUri = shape.error_uri;
24
- this.error_description = shape.error_description;
25
- this.error_uri = shape.error_uri;
24
+ this.errorDescription = description;
25
+ this.errorUri = uri;
26
+ this.error_description = description;
27
+ this.error_uri = uri;
26
28
  this.status = status;
27
29
  this.retryable = isRetryableOAuthError(this);
28
30
  this.terminal = !this.retryable;
@@ -164,7 +166,9 @@ export async function readOAuthJsonObjectResponse(response, signal) {
164
166
  const record = payload;
165
167
  if (!response.ok) {
166
168
  const error = getOwnEntry(record, "error");
167
- throw new OAuthError(readOAuthError(record, fallbackError.error), response.status, typeof error === "string" && error.trim().length > 0);
169
+ if (typeof error !== "string" || error.trim() === "")
170
+ throw fallbackError;
171
+ throw new OAuthError(readOAuthError(record), response.status);
168
172
  }
169
173
  return record;
170
174
  }
@@ -182,7 +186,7 @@ function getOwnEntry(record, key) {
182
186
  return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;
183
187
  }
184
188
  function createFallbackOAuthError(status) {
185
- const error = status === 503 ? "temporarily_unavailable" : "server_error";
189
+ const error = status === 503 ? "temporarily_unavailable" : status >= 500 ? "server_error" : "invalid_response";
186
190
  return new OAuthError({ error }, status, false);
187
191
  }
188
192
  function normalizeBearerTokenType(value) {
@@ -5014,13 +5014,15 @@ var OAuthError = class extends Error {
5014
5014
  /** True only when a complete OAuth error response establishes rejection. */
5015
5015
  outcomeKnown;
5016
5016
  constructor(shape, status, outcomeKnown = true) {
5017
- super(shape.error_description ?? shape.error);
5017
+ const description = Object.hasOwn(shape, "error_description") ? shape.error_description : void 0;
5018
+ const uri = Object.hasOwn(shape, "error_uri") ? shape.error_uri : void 0;
5019
+ super(description ?? (outcomeKnown ? shape.error : `OAuth HTTP response did not contain a valid error (HTTP ${status})`));
5018
5020
  this.name = "OAuthError";
5019
5021
  this.error = shape.error;
5020
- this.errorDescription = shape.error_description;
5021
- this.errorUri = shape.error_uri;
5022
- this.error_description = shape.error_description;
5023
- this.error_uri = shape.error_uri;
5022
+ this.errorDescription = description;
5023
+ this.errorUri = uri;
5024
+ this.error_description = description;
5025
+ this.error_uri = uri;
5024
5026
  this.status = status;
5025
5027
  this.retryable = isRetryableOAuthError(this);
5026
5028
  this.terminal = !this.retryable;
@@ -5149,7 +5151,9 @@ async function readOAuthJsonObjectResponse(response, signal) {
5149
5151
  const record2 = payload;
5150
5152
  if (!response.ok) {
5151
5153
  const error = getOwnEntry5(record2, "error");
5152
- throw new OAuthError(readOAuthError(record2, fallbackError.error), response.status, typeof error === "string" && error.trim().length > 0);
5154
+ if (typeof error !== "string" || error.trim() === "")
5155
+ throw fallbackError;
5156
+ throw new OAuthError(readOAuthError(record2), response.status);
5153
5157
  }
5154
5158
  return record2;
5155
5159
  }
@@ -5167,7 +5171,7 @@ function getOwnEntry5(record2, key2) {
5167
5171
  return Object.prototype.hasOwnProperty.call(record2, key2) ? record2[key2] : void 0;
5168
5172
  }
5169
5173
  function createFallbackOAuthError(status) {
5170
- const error = status === 503 ? "temporarily_unavailable" : "server_error";
5174
+ const error = status === 503 ? "temporarily_unavailable" : status >= 500 ? "server_error" : "invalid_response";
5171
5175
  return new OAuthError({ error }, status, false);
5172
5176
  }
5173
5177
  function normalizeBearerTokenType(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",