@se-studio/contentful-cms 3.15.7 → 3.16.3
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/CHANGELOG.md +30 -0
- package/HOSTED.md +18 -0
- package/dist/commands/host-pack-publish.d.ts +23 -0
- package/dist/commands/host-pack-publish.d.ts.map +1 -0
- package/dist/commands/host-pack-publish.js +84 -0
- package/dist/commands/host-pack-publish.js.map +1 -0
- package/dist/commands/host.d.ts.map +1 -1
- package/dist/commands/host.js +2 -0
- package/dist/commands/host.js.map +1 -1
- package/dist/config/hosted.d.ts +14 -0
- package/dist/config/hosted.d.ts.map +1 -1
- package/dist/config/hosted.js +54 -0
- package/dist/config/hosted.js.map +1 -1
- package/dist/contentful/cma-user-agent.d.ts +1 -1
- package/dist/editor-pack/generate.d.ts +2 -0
- package/dist/editor-pack/generate.d.ts.map +1 -1
- package/dist/editor-pack/generate.js +1 -0
- package/dist/editor-pack/generate.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/hosted/index.d.ts +4 -2
- package/dist/hosted/index.d.ts.map +1 -1
- package/dist/hosted/index.js +4 -2
- package/dist/hosted/index.js.map +1 -1
- package/dist/hosted/next/context.d.ts +6 -1
- package/dist/hosted/next/context.d.ts.map +1 -1
- package/dist/hosted/next/context.js +18 -2
- package/dist/hosted/next/context.js.map +1 -1
- package/dist/hosted/next/editor-pack-path.d.ts +4 -0
- package/dist/hosted/next/editor-pack-path.d.ts.map +1 -1
- package/dist/hosted/next/editor-pack-path.js +16 -0
- package/dist/hosted/next/editor-pack-path.js.map +1 -1
- package/dist/hosted/next/page-styles.d.ts +0 -1
- package/dist/hosted/next/page-styles.d.ts.map +1 -1
- package/dist/hosted/next/page-styles.js +0 -10
- package/dist/hosted/next/page-styles.js.map +1 -1
- package/dist/hosted/next/pages/CmsEditPage.js +2 -1
- package/dist/hosted/next/pages/CmsEditPage.js.map +1 -1
- package/dist/hosted/next/pages/CustomerPlaybooksPage.d.ts.map +1 -1
- package/dist/hosted/next/pages/CustomerPlaybooksPage.js +2 -1
- package/dist/hosted/next/pages/CustomerPlaybooksPage.js.map +1 -1
- package/dist/hosted/next/pages/HomePage.js +2 -1
- package/dist/hosted/next/pages/HomePage.js.map +1 -1
- package/dist/hosted/next/request-origin.d.ts +3 -0
- package/dist/hosted/next/request-origin.d.ts.map +1 -0
- package/dist/hosted/next/request-origin.js +12 -0
- package/dist/hosted/next/request-origin.js.map +1 -0
- package/dist/hosted/next/routes/connect.js +1 -1
- package/dist/hosted/next/routes/connect.js.map +1 -1
- package/dist/hosted/next/routes/customer-index.d.ts.map +1 -1
- package/dist/hosted/next/routes/customer-index.js +21 -4
- package/dist/hosted/next/routes/customer-index.js.map +1 -1
- package/dist/hosted/next/routes/customer-resource.d.ts +1 -1
- package/dist/hosted/next/routes/customer-resource.d.ts.map +1 -1
- package/dist/hosted/next/routes/customer-resource.js +13 -3
- package/dist/hosted/next/routes/customer-resource.js.map +1 -1
- package/dist/hosted/next/routes/health.d.ts.map +1 -1
- package/dist/hosted/next/routes/health.js +77 -15
- package/dist/hosted/next/routes/health.js.map +1 -1
- package/dist/hosted/next/routes/link-contentful.js +1 -1
- package/dist/hosted/next/routes/link-contentful.js.map +1 -1
- package/dist/hosted/next/routes/mcp.d.ts +6 -1
- package/dist/hosted/next/routes/mcp.d.ts.map +1 -1
- package/dist/hosted/next/routes/mcp.js +50 -22
- package/dist/hosted/next/routes/mcp.js.map +1 -1
- package/dist/hosted/next/routes/oauth-authorization-server.d.ts +1 -1
- package/dist/hosted/next/routes/oauth-authorization-server.d.ts.map +1 -1
- package/dist/hosted/next/routes/oauth-authorization-server.js +2 -2
- package/dist/hosted/next/routes/oauth-authorization-server.js.map +1 -1
- package/dist/hosted/next/routes/oauth-authorize.js +1 -1
- package/dist/hosted/next/routes/oauth-authorize.js.map +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource-path.d.ts +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource-path.d.ts.map +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource-path.js +2 -2
- package/dist/hosted/next/routes/oauth-protected-resource-path.js.map +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource.d.ts +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource.d.ts.map +1 -1
- package/dist/hosted/next/routes/oauth-protected-resource.js +2 -2
- package/dist/hosted/next/routes/oauth-protected-resource.js.map +1 -1
- package/dist/hosted/next/routes/oauth-register.js +1 -1
- package/dist/hosted/next/routes/oauth-register.js.map +1 -1
- package/dist/hosted/next/routes/oauth-token.js +1 -1
- package/dist/hosted/next/routes/oauth-token.js.map +1 -1
- package/dist/hosted/oauth/auth.d.ts +1 -1
- package/dist/hosted/oauth/auth.d.ts.map +1 -1
- package/dist/hosted/oauth/auth.js +3 -3
- package/dist/hosted/oauth/auth.js.map +1 -1
- package/dist/hosted/oauth/config.d.ts +14 -4
- package/dist/hosted/oauth/config.d.ts.map +1 -1
- package/dist/hosted/oauth/config.js +44 -8
- package/dist/hosted/oauth/config.js.map +1 -1
- package/dist/hosted/oauth/handlers.d.ts +5 -3
- package/dist/hosted/oauth/handlers.d.ts.map +1 -1
- package/dist/hosted/oauth/handlers.js +15 -10
- package/dist/hosted/oauth/handlers.js.map +1 -1
- package/dist/hosted/pack-fetch.d.ts +35 -0
- package/dist/hosted/pack-fetch.d.ts.map +1 -0
- package/dist/hosted/pack-fetch.js +188 -0
- package/dist/hosted/pack-fetch.js.map +1 -0
- package/dist/hosted/tenant-registry.d.ts +68 -0
- package/dist/hosted/tenant-registry.d.ts.map +1 -0
- package/dist/hosted/tenant-registry.js +167 -0
- package/dist/hosted/tenant-registry.js.map +1 -0
- package/package.json +2 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { isMultiTenantHostedMode, loadHostedDeploymentForRequest, loadHostedDeploymentFromEnv, } from '../../../config/hosted.js';
|
|
3
4
|
import { MediaPipelineJobStore } from '../../../media-pipeline/job-store.js';
|
|
4
5
|
import { isAllowedExtraRoot } from '../../../publish/classify.js';
|
|
5
6
|
import { redisPlanStore } from '../../../publish/store.js';
|
|
6
7
|
import { StagedUploadStore } from '../../../staged-upload/store.js';
|
|
7
|
-
import { buildHostedConfig, handleHostedMcpRequest, isMcpUnauthorizedError, isTransientContentfulFailure, isUnusableContentfulCacheReason,
|
|
8
|
+
import { buildHostedConfig, handleHostedMcpRequest, isMcpUnauthorizedError, isTransientContentfulFailure, isUnusableContentfulCacheReason, oauthLogAuthFailure, oauthLogMcpHandlerError, patValidationFailureReason, RedisIndexCacheStore, RedisSessionStore, resolveContentfulTokenFromRequest, resolveEditorPackForTenant, resolvePatForDeployment, runWithContentfulRequestStats, unauthorizedMcpResponse, } from '../../index.js';
|
|
8
9
|
import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
9
10
|
import { createOAuthHandlerContext } from '../context.js';
|
|
10
11
|
import { getHostedEditorPackPath } from '../editor-pack-path.js';
|
|
11
12
|
import { createRedisClient } from '../redis.js';
|
|
12
13
|
const redisClient = createRedisClient();
|
|
13
|
-
const
|
|
14
|
+
const localEditorPackPath = getHostedEditorPackPath();
|
|
14
15
|
function readExtraRootContentTypes(packPath) {
|
|
15
16
|
try {
|
|
16
17
|
const raw = readFileSync(path.join(packPath, 'publish.json'), 'utf8');
|
|
@@ -23,8 +24,16 @@ function readExtraRootContentTypes(packPath) {
|
|
|
23
24
|
return [];
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Streamable HTTP clients may open a long-lived GET SSE stream. This host is
|
|
29
|
+
* stateless and never writes to it, so GET held Fluid memory until the 300s
|
|
30
|
+
* timeout (#267). Refuse GET; clients fall back to POST/JSON.
|
|
31
|
+
*/
|
|
32
|
+
export async function GET(_request) {
|
|
33
|
+
return withCors(new Response(null, {
|
|
34
|
+
status: 405,
|
|
35
|
+
headers: { Allow: 'POST' },
|
|
36
|
+
}));
|
|
28
37
|
}
|
|
29
38
|
export async function POST(request) {
|
|
30
39
|
return handleMcp(request);
|
|
@@ -39,12 +48,34 @@ async function handleMcp(request) {
|
|
|
39
48
|
const response = await runWithContentfulRequestStats(() => handleMcpInner(request));
|
|
40
49
|
return withCors(response);
|
|
41
50
|
}
|
|
51
|
+
async function resolveDeployment(request) {
|
|
52
|
+
if (isMultiTenantHostedMode()) {
|
|
53
|
+
const resolved = loadHostedDeploymentForRequest(request);
|
|
54
|
+
if (!resolved.tenant) {
|
|
55
|
+
throw new Error('Multi-tenant mode resolved no tenant.');
|
|
56
|
+
}
|
|
57
|
+
const pack = await resolveEditorPackForTenant(resolved.tenant);
|
|
58
|
+
return {
|
|
59
|
+
deployment: resolved.deployment,
|
|
60
|
+
displayName: resolved.tenant.displayName,
|
|
61
|
+
editorPackPath: pack.packPath,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
deployment: loadHostedDeploymentFromEnv(),
|
|
66
|
+
displayName: process.env['CMS_EDIT_DISPLAY_NAME'],
|
|
67
|
+
editorPackPath: localEditorPackPath,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
42
70
|
async function handleMcpInner(request) {
|
|
43
|
-
const oauthCtx = createOAuthHandlerContext();
|
|
71
|
+
const oauthCtx = createOAuthHandlerContext(request);
|
|
44
72
|
let user;
|
|
45
73
|
let mcpSub;
|
|
74
|
+
let deployment;
|
|
75
|
+
let editorPackPath;
|
|
76
|
+
let displayName;
|
|
46
77
|
try {
|
|
47
|
-
|
|
78
|
+
({ deployment, editorPackPath, displayName } = await resolveDeployment(request));
|
|
48
79
|
const { sub, contentfulToken } = await resolveContentfulTokenFromRequest(request, oauthCtx.store, deployment.spaceId);
|
|
49
80
|
mcpSub = sub;
|
|
50
81
|
try {
|
|
@@ -60,7 +91,7 @@ async function handleMcpInner(request) {
|
|
|
60
91
|
projectKey: deployment.projectKey,
|
|
61
92
|
message,
|
|
62
93
|
});
|
|
63
|
-
return unauthorizedMcpResponse('invalid_contentful_token');
|
|
94
|
+
return unauthorizedMcpResponse('invalid_contentful_token', request);
|
|
64
95
|
}
|
|
65
96
|
if (isTransientContentfulFailure(reason)) {
|
|
66
97
|
oauthLogAuthFailure('mcp', reason, {
|
|
@@ -77,15 +108,18 @@ async function handleMcpInner(request) {
|
|
|
77
108
|
catch (err) {
|
|
78
109
|
let deploymentMeta = {};
|
|
79
110
|
try {
|
|
80
|
-
const
|
|
81
|
-
deploymentMeta = {
|
|
111
|
+
const resolved = await resolveDeployment(request);
|
|
112
|
+
deploymentMeta = {
|
|
113
|
+
spaceId: resolved.deployment.spaceId,
|
|
114
|
+
projectKey: resolved.deployment.projectKey,
|
|
115
|
+
};
|
|
82
116
|
}
|
|
83
117
|
catch {
|
|
84
|
-
// env not configured — still log auth failure without deployment context
|
|
118
|
+
// env/registry not configured — still log auth failure without deployment context
|
|
85
119
|
}
|
|
86
120
|
if (isMcpUnauthorizedError(err)) {
|
|
87
121
|
oauthLogAuthFailure('mcp', err.reason, deploymentMeta);
|
|
88
|
-
return unauthorizedMcpResponse(err.reason);
|
|
122
|
+
return unauthorizedMcpResponse(err.reason, request);
|
|
89
123
|
}
|
|
90
124
|
const message = err instanceof Error ? err.message : String(err);
|
|
91
125
|
oauthLogAuthFailure('mcp', patValidationFailureReason(message), {
|
|
@@ -95,7 +129,6 @@ async function handleMcpInner(request) {
|
|
|
95
129
|
return Response.json({ error: message }, { status: 401 });
|
|
96
130
|
}
|
|
97
131
|
try {
|
|
98
|
-
const deployment = loadHostedDeploymentFromEnv();
|
|
99
132
|
const runtimeContext = {
|
|
100
133
|
config: buildHostedConfig(deployment, user.token),
|
|
101
134
|
sessionStore: new RedisSessionStore(redisClient),
|
|
@@ -116,7 +149,7 @@ async function handleMcpInner(request) {
|
|
|
116
149
|
resolveContext: async () => runtimeContext,
|
|
117
150
|
getMcpInfo: () => ({
|
|
118
151
|
projectKey: deployment.projectKey,
|
|
119
|
-
displayName
|
|
152
|
+
displayName,
|
|
120
153
|
spaceId: deployment.spaceId,
|
|
121
154
|
}),
|
|
122
155
|
editorPackPath,
|
|
@@ -124,15 +157,10 @@ async function handleMcpInner(request) {
|
|
|
124
157
|
}
|
|
125
158
|
catch (err) {
|
|
126
159
|
const message = err instanceof Error ? err.message : String(err);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
// env not configured — still log handler failure without deployment context
|
|
134
|
-
}
|
|
135
|
-
oauthLogMcpHandlerError(message, deploymentMeta);
|
|
160
|
+
oauthLogMcpHandlerError(message, {
|
|
161
|
+
spaceId: deployment.spaceId,
|
|
162
|
+
projectKey: deployment.projectKey,
|
|
163
|
+
});
|
|
136
164
|
return Response.json({ error: message }, { status: 500 });
|
|
137
165
|
}
|
|
138
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,+BAA+B,EAC/B,
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI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sB,CAAC,OAAO,EAAE;YAC3C,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc;YAC1C,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;gBACjB,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,WAAW;gBACX,OAAO,EAAE,UAAU,CAAC,OAAO;aAC5B,CAAC;YACF,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,uBAAuB,CAAC,OAAO,EAAE;YAC/B,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,UAAU,EAAE,UAAU,CAAC,UAAU;SAClC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authorization-server.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorization-server.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"oauth-authorization-server.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorization-server.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE7D;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAEjD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { handleOAuthAuthorizationServerMetadataGet } from '../../index.js';
|
|
2
2
|
import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
3
|
-
export async function GET() {
|
|
4
|
-
return withCors(handleOAuthAuthorizationServerMetadataGet());
|
|
3
|
+
export async function GET(request) {
|
|
4
|
+
return withCors(handleOAuthAuthorizationServerMetadataGet(request));
|
|
5
5
|
}
|
|
6
6
|
export async function OPTIONS() {
|
|
7
7
|
return corsPreflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authorization-server.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorization-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"oauth-authorization-server.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorization-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAgB;IACxC,OAAO,QAAQ,CAAC,yCAAyC,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handleOAuthAuthorizeGet } from '../../index.js';
|
|
2
2
|
import { createOAuthHandlerContext } from '../context.js';
|
|
3
3
|
export async function GET(request) {
|
|
4
|
-
return handleOAuthAuthorizeGet(request, createOAuthHandlerContext());
|
|
4
|
+
return handleOAuthAuthorizeGet(request, createOAuthHandlerContext(request));
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=oauth-authorize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authorize.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAgB;IACxC,OAAO,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"oauth-authorize.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAgB;IACxC,OAAO,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -5,7 +5,7 @@ type PathParams = {
|
|
|
5
5
|
* RFC 9728 path-aware metadata:
|
|
6
6
|
* `/.well-known/oauth-protected-resource/api/mcp`
|
|
7
7
|
*/
|
|
8
|
-
export declare function GET(
|
|
8
|
+
export declare function GET(request: Request, context: {
|
|
9
9
|
params: Promise<PathParams>;
|
|
10
10
|
}): Promise<Response>;
|
|
11
11
|
export declare function OPTIONS(): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-protected-resource-path.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource-path.ts"],"names":[],"mappings":"AAMA,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,wBAAsB,GAAG,CACvB,
|
|
1
|
+
{"version":3,"file":"oauth-protected-resource-path.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource-path.ts"],"names":[],"mappings":"AAMA,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,wBAAsB,GAAG,CACvB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,GACvC,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAEjD"}
|
|
@@ -4,12 +4,12 @@ import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
|
4
4
|
* RFC 9728 path-aware metadata:
|
|
5
5
|
* `/.well-known/oauth-protected-resource/api/mcp`
|
|
6
6
|
*/
|
|
7
|
-
export async function GET(
|
|
7
|
+
export async function GET(request, context) {
|
|
8
8
|
const { path } = await context.params;
|
|
9
9
|
if (!isMcpProtectedResourcePath(path)) {
|
|
10
10
|
return withCors(new Response('Not found', { status: 404 }));
|
|
11
11
|
}
|
|
12
|
-
return withCors(handleOAuthProtectedResourceMetadataGet());
|
|
12
|
+
return withCors(handleOAuthProtectedResourceMetadataGet(request));
|
|
13
13
|
}
|
|
14
14
|
export async function OPTIONS() {
|
|
15
15
|
return corsPreflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-protected-resource-path.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource-path.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI9D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,
|
|
1
|
+
{"version":3,"file":"oauth-protected-resource-path.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource-path.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI9D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,OAAgB,EAChB,OAAwC;IAExC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;IACtC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,QAAQ,CAAC,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,QAAQ,CAAC,uCAAuC,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-protected-resource.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"oauth-protected-resource.d.ts","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource.ts"],"names":[],"mappings":"AAGA,wBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE7D;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAEjD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { handleOAuthProtectedResourceMetadataGet } from '../../index.js';
|
|
2
2
|
import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
3
|
-
export async function GET() {
|
|
4
|
-
return withCors(handleOAuthProtectedResourceMetadataGet());
|
|
3
|
+
export async function GET(request) {
|
|
4
|
+
return withCors(handleOAuthProtectedResourceMetadataGet(request));
|
|
5
5
|
}
|
|
6
6
|
export async function OPTIONS() {
|
|
7
7
|
return corsPreflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-protected-resource.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"oauth-protected-resource.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-protected-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAgB;IACxC,OAAO,QAAQ,CAAC,uCAAuC,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { handleOAuthRegisterPost } from '../../index.js';
|
|
|
2
2
|
import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
3
3
|
import { createOAuthHandlerContext } from '../context.js';
|
|
4
4
|
export async function POST(request) {
|
|
5
|
-
return withCors(await handleOAuthRegisterPost(request, createOAuthHandlerContext()));
|
|
5
|
+
return withCors(await handleOAuthRegisterPost(request, createOAuthHandlerContext(request)));
|
|
6
6
|
}
|
|
7
7
|
export async function OPTIONS() {
|
|
8
8
|
return corsPreflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-register.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAgB;IACzC,OAAO,QAAQ,CAAC,MAAM,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"oauth-register.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAgB;IACzC,OAAO,QAAQ,CAAC,MAAM,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { handleOAuthTokenPost } from '../../index.js';
|
|
|
2
2
|
import { corsPreflight, withCors } from '../../oauth/cors.js';
|
|
3
3
|
import { createOAuthHandlerContext } from '../context.js';
|
|
4
4
|
export async function POST(request) {
|
|
5
|
-
return withCors(await handleOAuthTokenPost(request, createOAuthHandlerContext()));
|
|
5
|
+
return withCors(await handleOAuthTokenPost(request, createOAuthHandlerContext(request)));
|
|
6
6
|
}
|
|
7
7
|
export async function OPTIONS() {
|
|
8
8
|
return corsPreflight();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-token.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAgB;IACzC,OAAO,QAAQ,CAAC,MAAM,oBAAoB,CAAC,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"oauth-token.js","sourceRoot":"","sources":["../../../../src/hosted/next/routes/oauth-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAgB;IACzC,OAAO,QAAQ,CAAC,MAAM,oBAAoB,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -5,7 +5,7 @@ export declare class McpUnauthorizedError extends Error {
|
|
|
5
5
|
constructor(reason: McpAuthFailureReason);
|
|
6
6
|
}
|
|
7
7
|
export declare function isMcpUnauthorizedError(error: unknown): error is McpUnauthorizedError;
|
|
8
|
-
export declare function unauthorizedMcpResponse(reason?: McpAuthFailureReason): Response;
|
|
8
|
+
export declare function unauthorizedMcpResponse(reason?: McpAuthFailureReason, request?: Request): Response;
|
|
9
9
|
export declare function resolveContentfulTokenFromRequest(request: Request, store: OAuthStore,
|
|
10
10
|
/** Host Contentful space — same isolation as session keys (deployment.spaceId). */
|
|
11
11
|
spaceId?: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,iBAAiB,GACjB,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,YAAY,MAAM,EAAE,oBAAoB,EAIvC;CACF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF;AAQD,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,iBAAiB,GACjB,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,YAAY,MAAM,EAAE,oBAAoB,EAIvC;CACF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF;AAQD,wBAAgB,uBAAuB,CACrC,MAAM,GAAE,oBAAuC,EAC/C,OAAO,CAAC,EAAE,OAAO,GAChB,QAAQ,CAaV;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,UAAU;AACjB,mFAAmF;AACnF,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBnD"}
|
|
@@ -17,8 +17,8 @@ const INVALID_TOKEN_DESCRIPTIONS = {
|
|
|
17
17
|
missing_contentful_token: 'Contentful session expired. Reconnect and sign in with Contentful.',
|
|
18
18
|
invalid_contentful_token: 'Contentful session expired. Reconnect and sign in with Contentful.',
|
|
19
19
|
};
|
|
20
|
-
export function unauthorizedMcpResponse(reason = 'missing_bearer') {
|
|
21
|
-
const metadataUrl = getProtectedResourceMetadataUrl();
|
|
20
|
+
export function unauthorizedMcpResponse(reason = 'missing_bearer', request) {
|
|
21
|
+
const metadataUrl = getProtectedResourceMetadataUrl(request);
|
|
22
22
|
const description = INVALID_TOKEN_DESCRIPTIONS[reason];
|
|
23
23
|
const www = description
|
|
24
24
|
? `Bearer error="invalid_token", error_description="${description}", resource_metadata="${metadataUrl}"`
|
|
@@ -40,7 +40,7 @@ spaceId) {
|
|
|
40
40
|
}
|
|
41
41
|
let sub;
|
|
42
42
|
try {
|
|
43
|
-
({ sub } = await verifyMcpAccessToken(bearer, getMcpResourceUrl()));
|
|
43
|
+
({ sub } = await verifyMcpAccessToken(bearer, getMcpResourceUrl(request)));
|
|
44
44
|
}
|
|
45
45
|
catch {
|
|
46
46
|
throw new McpUnauthorizedError('invalid_mcp_jwt');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/hosted/oauth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAShD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,MAAM,CAAuB;IAEtC,YAAY,MAA4B;QACtC,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CAA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AAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,EAAE;QACrE,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,kBAAkB,EAAE,GAAG;SACxB;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAgB,EAChB,KAAiB;AACjB,mFAAmF;AACnF,OAAgB;IAEhB,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public origin from `CMS_EDIT_PUBLIC_ORIGIN` (single-tenant / env fallback).
|
|
3
|
+
* Prefer {@link resolvePublicOrigin} when a Request is available.
|
|
4
|
+
*/
|
|
1
5
|
export declare function getPublicOrigin(): string;
|
|
2
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Per-request public origin for OAuth, MCP resource URL, and staged upload.
|
|
8
|
+
* Multi-tenant: registry `publicOrigin` for the request Host (or override).
|
|
9
|
+
* Single-tenant: `CMS_EDIT_PUBLIC_ORIGIN`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolvePublicOrigin(request?: Request): string;
|
|
12
|
+
export declare function getMcpResourceUrl(request?: Request): string;
|
|
3
13
|
/** RFC 9728 path suffix for the MCP resource (`/.well-known/oauth-protected-resource/api/mcp`). */
|
|
4
14
|
export declare function isMcpProtectedResourcePath(segments: readonly string[]): boolean;
|
|
5
15
|
export declare function getContentfulOAuthClientId(): string;
|
|
6
|
-
export declare function getContentfulOAuthRedirectUri(): string;
|
|
7
|
-
export declare function getContentfulAuthorizeUrl(authRequestId: string): string;
|
|
8
|
-
export declare function getProtectedResourceMetadataUrl(): string;
|
|
16
|
+
export declare function getContentfulOAuthRedirectUri(request?: Request): string;
|
|
17
|
+
export declare function getContentfulAuthorizeUrl(authRequestId: string, requestOrOrigin?: Request | string): string;
|
|
18
|
+
export declare function getProtectedResourceMetadataUrl(request?: Request): string;
|
|
9
19
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/config.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAuB7D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAE3D;AAED,mGAAmG;AACnG,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE/E;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD;AAED,wBAAgB,6BAA6B,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAEvE;AAED,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GACjC,MAAM,CAaR;AAED,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAEzE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isMultiTenantHostedMode, loadTenantRegistryFromEnv, resolveRequestHostname, } from '../tenant-registry.js';
|
|
1
2
|
function requireEnv(name) {
|
|
2
3
|
const value = process.env[name]?.trim();
|
|
3
4
|
if (!value) {
|
|
@@ -5,11 +6,43 @@ function requireEnv(name) {
|
|
|
5
6
|
}
|
|
6
7
|
return value;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Public origin from `CMS_EDIT_PUBLIC_ORIGIN` (single-tenant / env fallback).
|
|
11
|
+
* Prefer {@link resolvePublicOrigin} when a Request is available.
|
|
12
|
+
*/
|
|
8
13
|
export function getPublicOrigin() {
|
|
9
14
|
return requireEnv('CMS_EDIT_PUBLIC_ORIGIN').replace(/\/$/, '');
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Per-request public origin for OAuth, MCP resource URL, and staged upload.
|
|
18
|
+
* Multi-tenant: registry `publicOrigin` for the request Host (or override).
|
|
19
|
+
* Single-tenant: `CMS_EDIT_PUBLIC_ORIGIN`.
|
|
20
|
+
*/
|
|
21
|
+
export function resolvePublicOrigin(request) {
|
|
22
|
+
if (!request || !isMultiTenantHostedMode()) {
|
|
23
|
+
return getPublicOrigin();
|
|
24
|
+
}
|
|
25
|
+
const registry = loadTenantRegistryFromEnv();
|
|
26
|
+
const hostname = resolveRequestHostname(request);
|
|
27
|
+
if (registry && hostname) {
|
|
28
|
+
const tenant = registry.tenants.find((t) => t.hostname === hostname);
|
|
29
|
+
if (tenant) {
|
|
30
|
+
return tenant.publicOrigin;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const url = new URL(request.url);
|
|
35
|
+
if (hostname) {
|
|
36
|
+
return `${url.protocol}//${hostname}`.replace(/\/$/, '');
|
|
37
|
+
}
|
|
38
|
+
return url.origin.replace(/\/$/, '');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return getPublicOrigin();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function getMcpResourceUrl(request) {
|
|
45
|
+
return `${resolvePublicOrigin(request)}/api/mcp`;
|
|
13
46
|
}
|
|
14
47
|
/** RFC 9728 path suffix for the MCP resource (`/.well-known/oauth-protected-resource/api/mcp`). */
|
|
15
48
|
export function isMcpProtectedResourcePath(segments) {
|
|
@@ -18,20 +51,23 @@ export function isMcpProtectedResourcePath(segments) {
|
|
|
18
51
|
export function getContentfulOAuthClientId() {
|
|
19
52
|
return requireEnv('CONTENTFUL_OAUTH_CLIENT_ID');
|
|
20
53
|
}
|
|
21
|
-
export function getContentfulOAuthRedirectUri() {
|
|
22
|
-
return `${
|
|
54
|
+
export function getContentfulOAuthRedirectUri(request) {
|
|
55
|
+
return `${resolvePublicOrigin(request)}/oauth/contentful-callback`;
|
|
23
56
|
}
|
|
24
|
-
export function getContentfulAuthorizeUrl(authRequestId) {
|
|
57
|
+
export function getContentfulAuthorizeUrl(authRequestId, requestOrOrigin) {
|
|
58
|
+
const redirectUri = typeof requestOrOrigin === 'string'
|
|
59
|
+
? `${requestOrOrigin.replace(/\/$/, '')}/oauth/contentful-callback`
|
|
60
|
+
: getContentfulOAuthRedirectUri(requestOrOrigin);
|
|
25
61
|
const params = new URLSearchParams({
|
|
26
62
|
response_type: 'token',
|
|
27
63
|
client_id: getContentfulOAuthClientId(),
|
|
28
|
-
redirect_uri:
|
|
64
|
+
redirect_uri: redirectUri,
|
|
29
65
|
scope: 'content_management_manage',
|
|
30
66
|
state: authRequestId,
|
|
31
67
|
});
|
|
32
68
|
return `https://be.contentful.com/oauth/authorize?${params.toString()}`;
|
|
33
69
|
}
|
|
34
|
-
export function getProtectedResourceMetadataUrl() {
|
|
35
|
-
return `${
|
|
70
|
+
export function getProtectedResourceMetadataUrl(request) {
|
|
71
|
+
return `${resolvePublicOrigin(request)}/.well-known/oauth-protected-resource`;
|
|
36
72
|
}
|
|
37
73
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/hosted/oauth/config.ts"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/hosted/oauth/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;A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AC,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,4BAA4B,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,OAAiB;IAC7D,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,4BAA4B,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,aAAqB,EACrB,eAAkC;IAElC,MAAM,WAAW,GACf,OAAO,eAAe,KAAK,QAAQ;QACjC,CAAC,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,4BAA4B;QACnE,CAAC,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,0BAA0B,EAAE;QACvC,YAAY,EAAE,WAAW;QACzB,KAAK,EAAE,2BAA2B;QAClC,KAAK,EAAE,aAAa;KACrB,CAAC,CAAC;IACH,OAAO,6CAA6C,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,OAAiB;IAC/D,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,uCAAuC,CAAC;AAChF,CAAC"}
|
|
@@ -3,15 +3,17 @@ import { type OAuthStore } from './store.js';
|
|
|
3
3
|
export interface OAuthHandlerContext {
|
|
4
4
|
store: OAuthStore;
|
|
5
5
|
deployment: HostedDeploymentConfig;
|
|
6
|
+
/** Request-scoped public origin (Host / registry in multi-tenant mode). */
|
|
7
|
+
publicOrigin: string;
|
|
6
8
|
displayName?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare function handleOAuthAuthorizeGet(request: Request, ctx: OAuthHandlerContext): Promise<Response>;
|
|
9
11
|
export declare function handleOAuthRegisterPost(request: Request, ctx: OAuthHandlerContext): Promise<Response>;
|
|
10
12
|
export declare function handleOAuthTokenPost(request: Request, ctx: OAuthHandlerContext): Promise<Response>;
|
|
11
13
|
export declare function handleLinkContentfulPost(request: Request, ctx: OAuthHandlerContext): Promise<Response>;
|
|
12
|
-
export declare function handleOAuthAuthorizationServerMetadataGet(): Response;
|
|
13
|
-
export declare function handleOAuthProtectedResourceMetadataGet(): Response;
|
|
14
|
-
export declare function handleOAuthHealthCheck(): Promise<{
|
|
14
|
+
export declare function handleOAuthAuthorizationServerMetadataGet(request?: Request): Response;
|
|
15
|
+
export declare function handleOAuthProtectedResourceMetadataGet(request?: Request): Response;
|
|
16
|
+
export declare function handleOAuthHealthCheck(request?: Request): Promise<{
|
|
15
17
|
ok: boolean;
|
|
16
18
|
detail: string;
|
|
17
19
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAmB/F,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAmDD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CA0EnB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CA4BnB;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CAgGnB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EA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2,7 +2,7 @@ import { validatePatForDeployment } from '../../config/hosted.js';
|
|
|
2
2
|
import { flushTelemetry, recordOAuthTelemetryFailure, recordOAuthTelemetrySuccess, } from '../../telemetry/index.js';
|
|
3
3
|
import { CIMD_CLIENT_TTL_SECONDS, fetchClientIdMetadata, isCimdClientId, metadataAllowsRedirect, } from './cimd.js';
|
|
4
4
|
import { completeAuthorizationCodeGrant, issueAuthorizationRedirect } from './complete.js';
|
|
5
|
-
import { getContentfulAuthorizeUrl,
|
|
5
|
+
import { getContentfulAuthorizeUrl, getPublicOrigin, resolvePublicOrigin } from './config.js';
|
|
6
6
|
import { oauthLogAuthFailure, oauthLogVerbose, patValidationFailureReason } from './log.js';
|
|
7
7
|
import { noteOauthRedirect } from './redirect-hosts.js';
|
|
8
8
|
import { normalizeLoopbackRedirectUri, redirectUriMatchesRegistered } from './redirect-uri.js';
|
|
@@ -102,7 +102,7 @@ export async function handleOAuthAuthorizeGet(request, ctx) {
|
|
|
102
102
|
resource,
|
|
103
103
|
scope: granted.scope,
|
|
104
104
|
});
|
|
105
|
-
const contentfulAuthorizeUrl = getContentfulAuthorizeUrl(authRequestId);
|
|
105
|
+
const contentfulAuthorizeUrl = getContentfulAuthorizeUrl(authRequestId, ctx.publicOrigin);
|
|
106
106
|
return Response.redirect(contentfulAuthorizeUrl, 302);
|
|
107
107
|
}
|
|
108
108
|
export async function handleOAuthRegisterPost(request, ctx) {
|
|
@@ -248,7 +248,7 @@ export async function handleLinkContentfulPost(request, ctx) {
|
|
|
248
248
|
spaceId: ctx.deployment.spaceId,
|
|
249
249
|
projectKey: ctx.deployment.projectKey,
|
|
250
250
|
});
|
|
251
|
-
const origin =
|
|
251
|
+
const origin = ctx.publicOrigin;
|
|
252
252
|
const resumeUrl = new URL(`${origin}/oauth/authorize`);
|
|
253
253
|
resumeUrl.searchParams.set('resume', authRequestId);
|
|
254
254
|
resumeUrl.searchParams.set('sub', user.userId);
|
|
@@ -267,8 +267,8 @@ export async function handleLinkContentfulPost(request, ctx) {
|
|
|
267
267
|
return Response.json({ error: message }, { status: 401 });
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
export function handleOAuthAuthorizationServerMetadataGet() {
|
|
271
|
-
const origin =
|
|
270
|
+
export function handleOAuthAuthorizationServerMetadataGet(request) {
|
|
271
|
+
const origin = resolvePublicOrigin(request);
|
|
272
272
|
return Response.json({
|
|
273
273
|
issuer: origin,
|
|
274
274
|
authorization_endpoint: `${origin}/oauth/authorize`,
|
|
@@ -282,18 +282,23 @@ export function handleOAuthAuthorizationServerMetadataGet() {
|
|
|
282
282
|
client_id_metadata_document_supported: true,
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
|
-
export function handleOAuthProtectedResourceMetadataGet() {
|
|
286
|
-
const origin =
|
|
285
|
+
export function handleOAuthProtectedResourceMetadataGet(request) {
|
|
286
|
+
const origin = resolvePublicOrigin(request);
|
|
287
287
|
return Response.json({
|
|
288
|
-
resource:
|
|
288
|
+
resource: `${origin}/api/mcp`,
|
|
289
289
|
authorization_servers: [origin],
|
|
290
290
|
scopes_supported: [...CMS_EDIT_OAUTH_SCOPES],
|
|
291
291
|
bearer_methods_supported: ['header'],
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
|
-
export async function handleOAuthHealthCheck() {
|
|
294
|
+
export async function handleOAuthHealthCheck(request) {
|
|
295
295
|
try {
|
|
296
|
-
|
|
296
|
+
if (request) {
|
|
297
|
+
resolvePublicOrigin(request);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
getPublicOrigin();
|
|
301
|
+
}
|
|
297
302
|
if (!process.env['MCP_OAUTH_JWT_SECRET']?.trim()) {
|
|
298
303
|
return { ok: false, detail: 'Missing MCP_OAUTH_JWT_SECRET' };
|
|
299
304
|
}
|