@lovable.dev/mcp-js 0.5.0
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/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/authorize-DpTEIFvs.d.ts +9 -0
- package/dist/chunk-6DXGZZA4.js +6 -0
- package/dist/chunk-DDF63QWG.js +80 -0
- package/dist/chunk-GLG5RZGE.js +66 -0
- package/dist/chunk-MA5H6PSF.js +46 -0
- package/dist/chunk-QA3FWDUV.js +40 -0
- package/dist/chunk-VD6CS7Y6.js +144 -0
- package/dist/chunk-XEDRJFAR.js +371 -0
- package/dist/index.cjs +271 -0
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +172 -0
- package/dist/protocols/mcp/index.cjs +505 -0
- package/dist/protocols/mcp/index.d.cts +14 -0
- package/dist/protocols/mcp/index.d.ts +14 -0
- package/dist/protocols/mcp/index.js +10 -0
- package/dist/protocols/oauth-metadata.cjs +390 -0
- package/dist/protocols/oauth-metadata.d.cts +8 -0
- package/dist/protocols/oauth-metadata.d.ts +8 -0
- package/dist/protocols/oauth-metadata.js +9 -0
- package/dist/protocols/rest/index.cjs +599 -0
- package/dist/protocols/rest/index.d.cts +11 -0
- package/dist/protocols/rest/index.d.ts +11 -0
- package/dist/protocols/rest/index.js +12 -0
- package/dist/stacks/tanstack/index.cjs +743 -0
- package/dist/stacks/tanstack/index.d.cts +38 -0
- package/dist/stacks/tanstack/index.d.ts +38 -0
- package/dist/stacks/tanstack/index.js +38 -0
- package/dist/stacks/tanstack/vite.cjs +291 -0
- package/dist/stacks/tanstack/vite.d.cts +64 -0
- package/dist/stacks/tanstack/vite.d.ts +64 -0
- package/dist/stacks/tanstack/vite.js +263 -0
- package/dist/types-zMlr1mOK.d.ts +270 -0
- package/package.json +101 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/protocols/oauth-metadata.ts
|
|
21
|
+
var oauth_metadata_exports = {};
|
|
22
|
+
__export(oauth_metadata_exports, {
|
|
23
|
+
createOAuthProtectedResourceMetadataHandler: () => createOAuthProtectedResourceMetadataHandler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(oauth_metadata_exports);
|
|
26
|
+
|
|
27
|
+
// src/core/http.ts
|
|
28
|
+
var JSON_HEADERS = { "Content-Type": "application/json" };
|
|
29
|
+
function headResponse(response) {
|
|
30
|
+
return new Response(null, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
31
|
+
}
|
|
32
|
+
function methodNotAllowed(allow) {
|
|
33
|
+
return new Response(JSON.stringify({ error: "method not allowed" }), {
|
|
34
|
+
status: 405,
|
|
35
|
+
headers: { ...JSON_HEADERS, Allow: allow }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/core/promise.ts
|
|
40
|
+
function cachedPromise(load) {
|
|
41
|
+
let settled = false;
|
|
42
|
+
let value;
|
|
43
|
+
return async () => {
|
|
44
|
+
if (settled)
|
|
45
|
+
return value;
|
|
46
|
+
const loaded = await load();
|
|
47
|
+
settled = true;
|
|
48
|
+
value = loaded;
|
|
49
|
+
return loaded;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/core/url.ts
|
|
54
|
+
function trimTrailingSlash(value) {
|
|
55
|
+
return value.replace(/\/+$/, "");
|
|
56
|
+
}
|
|
57
|
+
function isLocalHTTPHost(hostname) {
|
|
58
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
59
|
+
}
|
|
60
|
+
function urlSafetyProblem(url) {
|
|
61
|
+
const isAllowedHTTP = url.protocol === "http:" && isLocalHTTPHost(url.hostname);
|
|
62
|
+
if (url.protocol !== "https:" && !isAllowedHTTP) {
|
|
63
|
+
return "must use https://, except localhost development URLs";
|
|
64
|
+
}
|
|
65
|
+
if (url.username || url.password) {
|
|
66
|
+
return "must not include credentials";
|
|
67
|
+
}
|
|
68
|
+
if (url.search || url.hash) {
|
|
69
|
+
return "must not include query or fragment";
|
|
70
|
+
}
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/core/validation.ts
|
|
75
|
+
function parseSafeUrl(subject, raw, ErrorClass = Error) {
|
|
76
|
+
let url;
|
|
77
|
+
try {
|
|
78
|
+
url = new URL(raw);
|
|
79
|
+
} catch {
|
|
80
|
+
throw new ErrorClass(`${subject} must be an absolute URL`);
|
|
81
|
+
}
|
|
82
|
+
const problem = urlSafetyProblem(url);
|
|
83
|
+
if (problem) {
|
|
84
|
+
throw new ErrorClass(`${subject} ${problem}`);
|
|
85
|
+
}
|
|
86
|
+
return url;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/auth/discovery.ts
|
|
90
|
+
var OAuthConfigurationError = class extends Error {
|
|
91
|
+
constructor(message) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.name = "OAuthConfigurationError";
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var METADATA_FETCH_TIMEOUT_MS = 5e3;
|
|
97
|
+
function issuerPath(url) {
|
|
98
|
+
const path = trimTrailingSlash(url.pathname);
|
|
99
|
+
return path === "" ? void 0 : path;
|
|
100
|
+
}
|
|
101
|
+
function pathInsertedOAuthMetadataUrls(url, path) {
|
|
102
|
+
return [
|
|
103
|
+
`${url.origin}/.well-known/oauth-authorization-server${path}`,
|
|
104
|
+
`${url.origin}/.well-known/openid-configuration${path}`
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
function oauthMetadataUrlsForIssuer(issuer) {
|
|
108
|
+
const normalizedIssuer = trimTrailingSlash(issuer);
|
|
109
|
+
const url = new URL(normalizedIssuer);
|
|
110
|
+
const path = issuerPath(url);
|
|
111
|
+
if (!path) {
|
|
112
|
+
return [
|
|
113
|
+
`${normalizedIssuer}/.well-known/oauth-authorization-server`,
|
|
114
|
+
`${normalizedIssuer}/.well-known/openid-configuration`
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
return [...pathInsertedOAuthMetadataUrls(url, path), `${normalizedIssuer}/.well-known/openid-configuration`];
|
|
118
|
+
}
|
|
119
|
+
async function fetchFirstValidOAuthServerMetadata(metadataUrls, expectedIssuer) {
|
|
120
|
+
const errors = [];
|
|
121
|
+
for (const url of metadataUrls) {
|
|
122
|
+
try {
|
|
123
|
+
return await fetchOAuthServerMetadata(url, expectedIssuer);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
errors.push(`${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`failed to discover OAuth server metadata (${errors.join("; ")})`);
|
|
129
|
+
}
|
|
130
|
+
async function fetchOAuthServerMetadata(url, expectedIssuer) {
|
|
131
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(METADATA_FETCH_TIMEOUT_MS), redirect: "error" });
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
throw new Error(String(response.status));
|
|
134
|
+
}
|
|
135
|
+
const json = await response.json();
|
|
136
|
+
if (typeof json.issuer !== "string") {
|
|
137
|
+
throw new Error("missing issuer");
|
|
138
|
+
}
|
|
139
|
+
parseSafeUrl("discovered issuer", json.issuer);
|
|
140
|
+
if (trimTrailingSlash(json.issuer) !== expectedIssuer) {
|
|
141
|
+
throw new Error("issuer mismatch");
|
|
142
|
+
}
|
|
143
|
+
if (typeof json.jwks_uri !== "string") {
|
|
144
|
+
throw new Error("missing jwks_uri");
|
|
145
|
+
}
|
|
146
|
+
parseSafeUrl("discovered jwks_uri", json.jwks_uri);
|
|
147
|
+
return { issuer: json.issuer, jwks_uri: json.jwks_uri };
|
|
148
|
+
}
|
|
149
|
+
async function fetchIssuerOAuthServerMetadata(issuer) {
|
|
150
|
+
try {
|
|
151
|
+
return await fetchFirstValidOAuthServerMetadata(oauthMetadataUrlsForIssuer(issuer), issuer);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
throw new OAuthConfigurationError(
|
|
154
|
+
`OAuth issuer discovery failed: ${err instanceof Error ? err.message : String(err)}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function createOAuthDiscoveryResolver(auth) {
|
|
159
|
+
const configuredIssuer = trimTrailingSlash(auth.issuer);
|
|
160
|
+
const oauthServerMetadata = cachedPromise(() => fetchIssuerOAuthServerMetadata(configuredIssuer));
|
|
161
|
+
return {
|
|
162
|
+
resolveIssuer: async () => configuredIssuer,
|
|
163
|
+
resolveJwksUri: async () => auth.jwksUri ?? (await oauthServerMetadata()).jwks_uri
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/auth/resource.ts
|
|
168
|
+
function resolveProtectedResource(auth, request, options) {
|
|
169
|
+
if (auth.resource)
|
|
170
|
+
return trimTrailingSlash(auth.resource);
|
|
171
|
+
const path = resolveResourcePath(options.resourcePath, request);
|
|
172
|
+
const resourceURL = new URL(path, request.url);
|
|
173
|
+
resourceURL.search = "";
|
|
174
|
+
resourceURL.hash = "";
|
|
175
|
+
return trimTrailingSlash(resourceURL.toString());
|
|
176
|
+
}
|
|
177
|
+
function assertResourcePathShape(resourcePath) {
|
|
178
|
+
if (!resourcePath.startsWith("/") || resourcePath.startsWith("//") || resourcePath.includes("\\") || /(^|\/)\.\.(\/|$)/.test(resourcePath)) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
`@lovable.dev/mcp-js: resourcePath must be an absolute path beginning with "/" without ".." segments or backslashes (got ${JSON.stringify(resourcePath)})`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function resolveResourcePath(resourcePath, request) {
|
|
185
|
+
if (resourcePath === void 0)
|
|
186
|
+
return new URL(request.url).pathname;
|
|
187
|
+
assertResourcePathShape(resourcePath);
|
|
188
|
+
return resourcePath;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/auth/verifier.ts
|
|
192
|
+
var import_jose = require("jose");
|
|
193
|
+
|
|
194
|
+
// src/auth/claims.ts
|
|
195
|
+
function readString(value) {
|
|
196
|
+
return typeof value === "string" ? value : void 0;
|
|
197
|
+
}
|
|
198
|
+
function splitScopes(value) {
|
|
199
|
+
if (typeof value === "string")
|
|
200
|
+
return value.split(/\s+/).filter(Boolean);
|
|
201
|
+
if (Array.isArray(value))
|
|
202
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
function stringClaim(claims, name) {
|
|
206
|
+
return readString(claims[name]);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/auth/verifier.ts
|
|
210
|
+
var DEFAULT_JWT_ALGORITHMS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "EdDSA"];
|
|
211
|
+
var DEFAULT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
212
|
+
var OAuthTokenError = class extends Error {
|
|
213
|
+
constructor(status, oauthError, message) {
|
|
214
|
+
super(message);
|
|
215
|
+
this.status = status;
|
|
216
|
+
this.oauthError = oauthError;
|
|
217
|
+
this.name = "OAuthTokenError";
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
function resolveAcceptedAudiences(auth, resource) {
|
|
221
|
+
return auth.acceptedAudiences ?? [resource];
|
|
222
|
+
}
|
|
223
|
+
function isJwksFetchFailure(err) {
|
|
224
|
+
if (err instanceof import_jose.errors.JWKSTimeout || err instanceof import_jose.errors.JWKSInvalid)
|
|
225
|
+
return true;
|
|
226
|
+
if (!(err instanceof import_jose.errors.JOSEError))
|
|
227
|
+
return err instanceof Error;
|
|
228
|
+
return err.code === "ERR_JOSE_GENERIC";
|
|
229
|
+
}
|
|
230
|
+
async function verifyJwtClaims(token, keySet, issuer, audience, auth) {
|
|
231
|
+
try {
|
|
232
|
+
const { payload } = await (0, import_jose.jwtVerify)(token, keySet, {
|
|
233
|
+
// `issuer` is trimmed of any trailing slash; accept both forms so a token whose
|
|
234
|
+
// `iss` carries the slash the AS publishes still verifies.
|
|
235
|
+
issuer: [issuer, `${issuer}/`],
|
|
236
|
+
audience: [...audience],
|
|
237
|
+
algorithms: auth.algorithms ? [...auth.algorithms] : DEFAULT_JWT_ALGORITHMS,
|
|
238
|
+
requiredClaims: ["sub", "exp"],
|
|
239
|
+
clockTolerance: auth.clockToleranceSeconds ?? DEFAULT_CLOCK_TOLERANCE_SECONDS
|
|
240
|
+
});
|
|
241
|
+
return payload;
|
|
242
|
+
} catch (err) {
|
|
243
|
+
if (isJwksFetchFailure(err)) {
|
|
244
|
+
throw new OAuthConfigurationError(`JWKS fetch failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
245
|
+
}
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function assertNonEmptySubject(claims) {
|
|
250
|
+
const sub = claims["sub"];
|
|
251
|
+
if (typeof sub !== "string" || sub.trim() === "") {
|
|
252
|
+
throw new OAuthTokenError(401, "invalid_token", "token subject claim must be a non-empty string");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function assertOAuthClientClaim(auth, clientId) {
|
|
256
|
+
if (auth.requireOAuthClientClaim !== false && !clientId) {
|
|
257
|
+
throw new OAuthTokenError(401, "invalid_token", "OAuth client claim is required");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function makeBearer(token) {
|
|
261
|
+
return Object.defineProperty({}, "token", { value: token, enumerable: false });
|
|
262
|
+
}
|
|
263
|
+
function buildMcpAuthContext(args) {
|
|
264
|
+
const { claims } = args;
|
|
265
|
+
return {
|
|
266
|
+
type: "oauth",
|
|
267
|
+
principal: {
|
|
268
|
+
claims,
|
|
269
|
+
issuer: args.issuer,
|
|
270
|
+
resource: args.resource,
|
|
271
|
+
acceptedAudiences: args.acceptedAudiences,
|
|
272
|
+
scopes: splitScopes(claims.scope),
|
|
273
|
+
sub: stringClaim(claims, "sub"),
|
|
274
|
+
email: stringClaim(claims, "email"),
|
|
275
|
+
clientId: stringClaim(claims, "client_id") ?? stringClaim(claims, "azp")
|
|
276
|
+
},
|
|
277
|
+
bearer: makeBearer(args.token)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function createOAuthTokenVerifier(auth, discovery) {
|
|
281
|
+
const loadRemoteJwksKeySet = cachedPromise(
|
|
282
|
+
() => discovery.resolveJwksUri().then((jwksURI) => (0, import_jose.createRemoteJWKSet)(new URL(jwksURI)))
|
|
283
|
+
);
|
|
284
|
+
return async (token, request, options) => {
|
|
285
|
+
const resource = resolveProtectedResource(auth, request, options);
|
|
286
|
+
const issuer = await discovery.resolveIssuer();
|
|
287
|
+
const acceptedAudiences = resolveAcceptedAudiences(auth, resource);
|
|
288
|
+
const claims = await verifyJwtClaims(token, await loadRemoteJwksKeySet(), issuer, acceptedAudiences, auth);
|
|
289
|
+
assertNonEmptySubject(claims);
|
|
290
|
+
const context = buildMcpAuthContext({ token, claims, issuer, resource, acceptedAudiences });
|
|
291
|
+
assertOAuthClientClaim(auth, context.principal.clientId);
|
|
292
|
+
return context;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/auth/authorize.ts
|
|
297
|
+
function oauthConfigurationErrorResponse() {
|
|
298
|
+
return new Response(JSON.stringify({ error: "oauth configuration error" }), {
|
|
299
|
+
status: 500,
|
|
300
|
+
headers: { ...JSON_HEADERS, "Cache-Control": "no-store" }
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function getOAuthRuntime(mcp, options = {}) {
|
|
304
|
+
if (options.resourcePath !== void 0)
|
|
305
|
+
assertResourcePathShape(options.resourcePath);
|
|
306
|
+
const stableOptions = { resourcePath: options.resourcePath };
|
|
307
|
+
const auth = mcp.auth?.type === "oauth" ? mcp.auth : void 0;
|
|
308
|
+
if (!auth)
|
|
309
|
+
return { kind: "unconfigured", options: stableOptions };
|
|
310
|
+
const discovery = createOAuthDiscoveryResolver(auth);
|
|
311
|
+
return {
|
|
312
|
+
kind: "configured",
|
|
313
|
+
auth,
|
|
314
|
+
discovery,
|
|
315
|
+
verify: createOAuthTokenVerifier(auth, discovery),
|
|
316
|
+
options: stableOptions
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/protocols/oauth-metadata.ts
|
|
321
|
+
var CORS_ORIGIN = { "Access-Control-Allow-Origin": "*" };
|
|
322
|
+
function withCors(response) {
|
|
323
|
+
response.headers.set("Access-Control-Allow-Origin", "*");
|
|
324
|
+
return response;
|
|
325
|
+
}
|
|
326
|
+
function notFound() {
|
|
327
|
+
return new Response(JSON.stringify({ error: "not found" }), {
|
|
328
|
+
status: 404,
|
|
329
|
+
// `no-store` so a 404 (OAuth unconfigured) isn't heuristically cached and
|
|
330
|
+
// then served past a later deploy that enables OAuth and starts returning 200.
|
|
331
|
+
headers: { ...JSON_HEADERS, ...CORS_ORIGIN, "Cache-Control": "no-store" }
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
async function buildProtectedResourceMetadata(mcp, auth, request, options, discovery) {
|
|
335
|
+
const issuer = await discovery.resolveIssuer();
|
|
336
|
+
const body = {
|
|
337
|
+
resource: resolveProtectedResource(auth, request, options),
|
|
338
|
+
authorization_servers: [issuer],
|
|
339
|
+
bearer_methods_supported: ["header"],
|
|
340
|
+
resource_name: auth.resourceName ?? mcp.title,
|
|
341
|
+
resource_documentation: auth.resourceDocumentation
|
|
342
|
+
};
|
|
343
|
+
if (auth.requiredScopes && auth.requiredScopes.length > 0)
|
|
344
|
+
body.scopes_supported = auth.requiredScopes;
|
|
345
|
+
return body;
|
|
346
|
+
}
|
|
347
|
+
function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
348
|
+
const runtime = getOAuthRuntime(mcp, options);
|
|
349
|
+
if (runtime.kind === "configured" && runtime.auth.protectedResourceMetadataUrl === void 0 && runtime.auth.resource === void 0 && runtime.options.resourcePath === void 0) {
|
|
350
|
+
throw new Error(
|
|
351
|
+
`@lovable.dev/mcp-js: auth.resource or a resourcePath is required so the protected-resource metadata doesn't advertise the well-known URL as the resource`
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
return async (request) => {
|
|
355
|
+
if (runtime.kind !== "configured" || runtime.auth.protectedResourceMetadataUrl !== void 0)
|
|
356
|
+
return notFound();
|
|
357
|
+
if (request.method === "OPTIONS") {
|
|
358
|
+
return new Response(null, {
|
|
359
|
+
status: 204,
|
|
360
|
+
headers: { ...CORS_ORIGIN, "Access-Control-Allow-Methods": "GET, HEAD, OPTIONS" }
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
364
|
+
return withCors(methodNotAllowed("GET, HEAD, OPTIONS"));
|
|
365
|
+
const headers = {
|
|
366
|
+
...JSON_HEADERS,
|
|
367
|
+
...CORS_ORIGIN,
|
|
368
|
+
"Cache-Control": "public, max-age=300",
|
|
369
|
+
Vary: "Host"
|
|
370
|
+
};
|
|
371
|
+
try {
|
|
372
|
+
const metadata = await buildProtectedResourceMetadata(
|
|
373
|
+
mcp,
|
|
374
|
+
runtime.auth,
|
|
375
|
+
request,
|
|
376
|
+
runtime.options,
|
|
377
|
+
runtime.discovery
|
|
378
|
+
);
|
|
379
|
+
const response = Response.json(metadata, { headers });
|
|
380
|
+
return request.method === "HEAD" ? headResponse(response) : response;
|
|
381
|
+
} catch {
|
|
382
|
+
const response = withCors(oauthConfigurationErrorResponse());
|
|
383
|
+
return request.method === "HEAD" ? headResponse(response) : response;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
388
|
+
0 && (module.exports = {
|
|
389
|
+
createOAuthProtectedResourceMetadataHandler
|
|
390
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { M as McpRuntimeOptions } from '../authorize-DpTEIFvs.js';
|
|
2
|
+
import { d as McpDefinition } from '../types-zMlr1mOK.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
type OAuthProtectedResourceMetadataHandler = (request: Request) => Promise<Response>;
|
|
6
|
+
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
7
|
+
|
|
8
|
+
export { type OAuthProtectedResourceMetadataHandler, createOAuthProtectedResourceMetadataHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { M as McpRuntimeOptions } from '../authorize-DpTEIFvs.js';
|
|
2
|
+
import { d as McpDefinition } from '../types-zMlr1mOK.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
type OAuthProtectedResourceMetadataHandler = (request: Request) => Promise<Response>;
|
|
6
|
+
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
7
|
+
|
|
8
|
+
export { type OAuthProtectedResourceMetadataHandler, createOAuthProtectedResourceMetadataHandler };
|