@aotter/mantle-cloudflare 0.1.0-alpha.6 → 0.1.0-alpha.8
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/README.md +15 -8
- package/dist/auth/conventionalAuth.d.ts +3 -0
- package/dist/auth/conventionalAuth.d.ts.map +1 -1
- package/dist/auth/conventionalAuth.js +23 -6
- package/dist/auth/conventionalAuth.js.map +1 -1
- package/dist/auth/createAuth.d.ts +32 -13
- package/dist/auth/createAuth.d.ts.map +1 -1
- package/dist/auth/createAuth.js +182 -154
- package/dist/auth/createAuth.js.map +1 -1
- package/dist/bindings/AssetsAssetServer.d.ts +4 -4
- package/dist/bindings/AssetsAssetServer.d.ts.map +1 -1
- package/dist/bindings/AssetsAssetServer.js +2 -2
- package/dist/bindings/D1DatabaseDriver.d.ts +3 -4
- package/dist/bindings/D1DatabaseDriver.d.ts.map +1 -1
- package/dist/bindings/D1DatabaseDriver.js +4 -91
- package/dist/bindings/D1DatabaseDriver.js.map +1 -1
- package/dist/bindings/WorkersQueueHookDispatcher.d.ts +2 -2
- package/dist/bindings/WorkersQueueHookDispatcher.d.ts.map +1 -1
- package/dist/bindings/WorkersQueueHookDispatcher.js +1 -1
- package/dist/bindings/WorkersQueueHookDispatcher.js.map +1 -1
- package/dist/bindings/conventionalBindings.d.ts +2 -3
- package/dist/bindings/conventionalBindings.d.ts.map +1 -1
- package/dist/bindings/conventionalBindings.js +1 -3
- package/dist/bindings/conventionalBindings.js.map +1 -1
- package/dist/handlers/turnstile.d.ts +1 -1
- package/dist/handlers/turnstile.d.ts.map +1 -1
- package/dist/handlers/turnstile.js +3 -1
- package/dist/handlers/turnstile.js.map +1 -1
- package/dist/mount/bootRuntimeOnce.d.ts +15 -8
- package/dist/mount/bootRuntimeOnce.d.ts.map +1 -1
- package/dist/mount/bootRuntimeOnce.js +36 -21
- package/dist/mount/bootRuntimeOnce.js.map +1 -1
- package/dist/mount/cmsConfig.d.ts +17 -9
- package/dist/mount/cmsConfig.d.ts.map +1 -1
- package/dist/mount/index.d.ts +4 -4
- package/dist/mount/index.d.ts.map +1 -1
- package/dist/mount/index.js +3 -3
- package/dist/mount/index.js.map +1 -1
- package/dist/mount/mountAdmin.d.ts +6 -0
- package/dist/mount/mountAdmin.d.ts.map +1 -0
- package/dist/mount/mountAdmin.js +16 -0
- package/dist/mount/mountAdmin.js.map +1 -0
- package/dist/mount/mountMcp.d.ts +7 -10
- package/dist/mount/mountMcp.d.ts.map +1 -1
- package/dist/mount/mountMcp.js +57 -49
- package/dist/mount/mountMcp.js.map +1 -1
- package/dist/mount/mountPublicRoutes.d.ts +4 -4
- package/dist/mount/mountPublicRoutes.d.ts.map +1 -1
- package/dist/mount/mountPublicRoutes.js +31 -24
- package/dist/mount/mountPublicRoutes.js.map +1 -1
- package/dist/mount/mountRuntimeEndpoints.d.ts +7 -0
- package/dist/mount/mountRuntimeEndpoints.d.ts.map +1 -0
- package/dist/mount/mountRuntimeEndpoints.js +49 -0
- package/dist/mount/mountRuntimeEndpoints.js.map +1 -0
- package/dist/mount/resolveCaller.d.ts.map +1 -1
- package/dist/mount/resolveCaller.js +0 -33
- package/dist/mount/resolveCaller.js.map +1 -1
- package/dist/oauth/cachePolicy.d.ts.map +1 -1
- package/dist/oauth/cachePolicy.js +2 -4
- package/dist/oauth/cachePolicy.js.map +1 -1
- package/dist/oauth/consentHtml.d.ts +2 -2
- package/dist/oauth/consentHtml.d.ts.map +1 -1
- package/dist/oauth/consentHtml.js +5 -5
- package/dist/oauth/consentHtml.js.map +1 -1
- package/dist/oauth/index.d.ts +0 -2
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +0 -2
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/mountOAuth.d.ts +2 -16
- package/dist/oauth/mountOAuth.d.ts.map +1 -1
- package/dist/oauth/mountOAuth.js +24 -99
- package/dist/oauth/mountOAuth.js.map +1 -1
- package/dist/worker/createMantleWorker.d.ts +12 -13
- package/dist/worker/createMantleWorker.d.ts.map +1 -1
- package/dist/worker/createMantleWorker.js +31 -24
- package/dist/worker/createMantleWorker.js.map +1 -1
- package/package.json +12 -11
- package/dist/mount/mountServerEndpoints.d.ts +0 -9
- package/dist/mount/mountServerEndpoints.d.ts.map +0 -1
- package/dist/mount/mountServerEndpoints.js +0 -1625
- package/dist/mount/mountServerEndpoints.js.map +0 -1
- package/dist/mount/runMantleUseCase.d.ts +0 -3
- package/dist/mount/runMantleUseCase.d.ts.map +0 -1
- package/dist/mount/runMantleUseCase.js +0 -41
- package/dist/mount/runMantleUseCase.js.map +0 -1
- package/dist/oauth/oauthConstants.d.ts +0 -15
- package/dist/oauth/oauthConstants.d.ts.map +0 -1
- package/dist/oauth/oauthConstants.js +0 -15
- package/dist/oauth/oauthConstants.js.map +0 -1
- package/dist/oauth/oauthSingleton.d.ts +0 -33
- package/dist/oauth/oauthSingleton.d.ts.map +0 -1
- package/dist/oauth/oauthSingleton.js +0 -39
- package/dist/oauth/oauthSingleton.js.map +0 -1
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
manifests: config.manifests,
|
|
5
|
-
handlers: config.handlers,
|
|
6
|
-
templates: config.templates,
|
|
7
|
-
siteDefaults: config.siteDefaults,
|
|
8
|
-
reservedHttpPathPrefixes: [config.auth.basePath],
|
|
9
|
-
publicPathResolver: config.publicPathResolver,
|
|
10
|
-
mediaAllowSvg: config.mediaAllowSvg,
|
|
11
|
-
db: config.bindings.db,
|
|
12
|
-
assets: config.bindings.assets,
|
|
13
|
-
mediaStorage: config.bindings.mediaStorage,
|
|
14
|
-
deferredHookDispatcher: config.bindings.deferredHookDispatcher,
|
|
15
|
-
onPublicChange: config.onPublicChange,
|
|
16
|
-
});
|
|
1
|
+
import { SqliteMantleStorageAdapter, bootMantleRuntime, } from "@aotter/mantle-runtime";
|
|
2
|
+
import { createMantleWeb } from "@aotter/mantle-web";
|
|
3
|
+
export function createMantleRuntimeRef(config) {
|
|
17
4
|
let booted = null;
|
|
5
|
+
let web = null;
|
|
6
|
+
const storage = new SqliteMantleStorageAdapter(config.bindings.db, config.siteDefaults);
|
|
18
7
|
return {
|
|
19
|
-
|
|
8
|
+
plan: config.plan,
|
|
20
9
|
auth: config.auth,
|
|
10
|
+
adminAssets: config.bindings.adminAssets,
|
|
21
11
|
credentialResolver: config.credentialResolver,
|
|
22
12
|
jwtBearer: config.jwtBearer,
|
|
13
|
+
web(runtime) {
|
|
14
|
+
return web ??= createMantleWeb(runtime, {
|
|
15
|
+
templates: config.templates,
|
|
16
|
+
paths: config.publicPathResolver,
|
|
17
|
+
mediaAssets: runtime.media ?? undefined,
|
|
18
|
+
});
|
|
19
|
+
},
|
|
23
20
|
get() {
|
|
24
21
|
if (booted)
|
|
25
22
|
return booted;
|
|
26
|
-
booted = bootWithD1Retry(
|
|
23
|
+
booted = bootWithD1Retry(async () => {
|
|
24
|
+
const runtime = await bootMantleRuntime({
|
|
25
|
+
plan: config.plan,
|
|
26
|
+
storage,
|
|
27
|
+
handlers: config.handlers,
|
|
28
|
+
deployment: {
|
|
29
|
+
reservedHttpPathPrefixes: config.reservedHttpPathPrefixes,
|
|
30
|
+
},
|
|
31
|
+
ports: {
|
|
32
|
+
deferredHookDispatcher: config.bindings.deferredHookDispatcher,
|
|
33
|
+
mediaStorage: config.bindings.mediaStorage,
|
|
34
|
+
mediaAllowSvg: config.mediaAllowSvg,
|
|
35
|
+
onPublishingContentChange: config.onPublicChange,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (!runtime.siteConfig || !runtime.updateSiteSettings) {
|
|
39
|
+
throw new Error("Cloudflare SQLite storage did not prepare site configuration.");
|
|
40
|
+
}
|
|
41
|
+
return runtime;
|
|
42
|
+
})
|
|
27
43
|
.catch((err) => {
|
|
28
44
|
booted = null;
|
|
29
45
|
console.error("[mantle] runtime boot failed", errorDetails(err));
|
|
@@ -39,11 +55,10 @@ const RETRYABLE_D1_ERRORS = [
|
|
|
39
55
|
"storage caused object to be reset",
|
|
40
56
|
"reset because its code was updated",
|
|
41
57
|
];
|
|
42
|
-
async function bootWithD1Retry(
|
|
58
|
+
async function bootWithD1Retry(create) {
|
|
43
59
|
for (let attempt = 1;; attempt += 1) {
|
|
44
60
|
try {
|
|
45
|
-
await
|
|
46
|
-
return runtime;
|
|
61
|
+
return await create();
|
|
47
62
|
}
|
|
48
63
|
catch (error) {
|
|
49
64
|
if (attempt >= MAX_BOOT_ATTEMPTS || !isRetryableD1Error(error))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootRuntimeOnce.js","sourceRoot":"","sources":["../../src/mount/bootRuntimeOnce.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"bootRuntimeOnce.js","sourceRoot":"","sources":["../../src/mount/bootRuntimeOnce.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAIlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AA2BrE,MAAM,UAAU,sBAAsB,CAAC,MAA8B;IACnE,IAAI,MAAM,GAA4C,IAAI,CAAC;IAC3D,IAAI,GAAG,GAAqB,IAAI,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,0BAA0B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IACxF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW;QACxC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,GAAG,CAAC,OAAO;YACT,OAAO,GAAG,KAAK,eAAe,CAAC,OAAO,EAAE;gBACtC,SAAS,EAAE,MAAM,CAAC,S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AAE,CAAC;IACxD,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,YAAY,KAAK;QACxC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO;QACrB,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS;YACzB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import type { AnyHandler,
|
|
2
|
-
import type {
|
|
1
|
+
import type { AnyHandler, DatabaseDriver, DeferredHookDispatcher, MediaStorage, RuntimePlan } from "@aotter/mantle-runtime";
|
|
2
|
+
import type { AdminAssetServer } from "@aotter/mantle-admin";
|
|
3
|
+
import type { PublicPathResolver, TemplateRegistry } from "@aotter/mantle-web";
|
|
4
|
+
import type { SiteDefaults } from "@aotter/mantle-spec";
|
|
3
5
|
import type { Auth } from "../auth/createAuth.js";
|
|
4
6
|
import type { ConsumerCredentialResolver } from "./resolveCaller.js";
|
|
5
7
|
/**
|
|
6
8
|
* Consumer-supplied config for the Cloudflare adapter mounts. `auth`
|
|
7
9
|
* (Better Auth) gates `/admin/api/*` + MCP bearers. `bindings` carries
|
|
8
|
-
*
|
|
10
|
+
* runtime and selected capability adapters.
|
|
9
11
|
*/
|
|
10
|
-
export interface
|
|
11
|
-
readonly
|
|
12
|
+
export interface MantleCloudflareConfig {
|
|
13
|
+
readonly plan: RuntimePlan;
|
|
12
14
|
readonly handlers?: Readonly<Record<string, AnyHandler>>;
|
|
13
15
|
readonly templates?: TemplateRegistry;
|
|
14
16
|
readonly siteDefaults?: SiteDefaults;
|
|
15
17
|
readonly publicPathResolver?: PublicPathResolver;
|
|
16
|
-
|
|
18
|
+
/** Routes owned by the capabilities this composition actually mounts. */
|
|
19
|
+
readonly reservedHttpPathPrefixes?: readonly string[];
|
|
20
|
+
readonly bindings: {
|
|
21
|
+
readonly db: DatabaseDriver;
|
|
22
|
+
} & {
|
|
23
|
+
/** Optional Admin SPA assets. Omitting this mounts no Admin surface. */
|
|
24
|
+
readonly adminAssets?: AdminAssetServer;
|
|
17
25
|
/** Optional media storage adapter. When set, media MCP tools and
|
|
18
26
|
* `/admin/api/media/*` endpoints are registered. Forwarded to the
|
|
19
27
|
* runtime as `mediaStorage`. */
|
|
20
|
-
readonly mediaStorage?:
|
|
28
|
+
readonly mediaStorage?: MediaStorage;
|
|
21
29
|
/** Optional at-least-once dispatcher. When set, `after_*`
|
|
22
30
|
* lifecycle hooks enqueue after the entry write; a rejected send
|
|
23
31
|
* falls back to best-effort `ctx.waitUntil`/inline execution. The
|
|
24
32
|
* Cloudflare adapter expects a
|
|
25
33
|
* `WorkersQueueHookDispatcher` bound to the `mantle-internal` queue
|
|
26
34
|
* here. */
|
|
27
|
-
readonly deferredHookDispatcher?:
|
|
35
|
+
readonly deferredHookDispatcher?: DeferredHookDispatcher;
|
|
28
36
|
};
|
|
29
37
|
/** Pass-through to runtime: SVG opt-in flag (default false). */
|
|
30
38
|
readonly mediaAllowSvg?: boolean;
|
|
@@ -38,6 +46,6 @@ export interface CmsConfig {
|
|
|
38
46
|
readonly audience: string;
|
|
39
47
|
readonly scopes?: readonly string[];
|
|
40
48
|
};
|
|
41
|
-
readonly onPublicChange?:
|
|
49
|
+
readonly onPublicChange?: () => Promise<void>;
|
|
42
50
|
}
|
|
43
51
|
//# sourceMappingURL=cmsConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmsConfig.d.ts","sourceRoot":"","sources":["../../src/mount/cmsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"cmsConfig.d.ts","sourceRoot":"","sources":["../../src/mount/cmsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACjD,yEAAyE;IACzE,QAAQ,CAAC,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;KAAE,GAAG;QACnD,wEAAwE;QACxE,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;QACxC;;yCAEiC;QACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;QACrC;;;;;oBAKY;QACZ,QAAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;KAC1D,CAAC;IACF,gEAAgE;IAChE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;yBAEqB;IACrB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,0BAA0B,CAAC;IACzD,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACrC,CAAC;IACF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C"}
|
package/dist/mount/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { mountRuntimeEndpoints } from "./mountRuntimeEndpoints.js";
|
|
2
|
+
export { mountAdmin } from "./mountAdmin.js";
|
|
3
3
|
export { resolveCaller, type CallerResolution, type ConsumerCredentialResolution, type ConsumerCredentialResolver, type ResolveCallerOptions, } from "./resolveCaller.js";
|
|
4
|
-
export { type
|
|
4
|
+
export { type CloudflareMantleRuntime, type MantleRuntimeRef, createMantleRuntimeRef, } from "./bootRuntimeOnce.js";
|
|
5
5
|
export { createMcpApiHandler, type CreateMcpApiHandlerOptions, } from "./mountMcp.js";
|
|
6
6
|
export { mountPublicRoutes, type CollectionRouteConfig, type MountPublicRoutesOptions, type PublicContentContext, type PublicRouteContext, type SlugOverride, } from "./mountPublicRoutes.js";
|
|
7
|
-
export type {
|
|
7
|
+
export type { MantleCloudflareConfig } from "./cmsConfig.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/mount/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { mountRuntimeEndpoints } from "./mountRuntimeEndpoints.js";
|
|
2
|
+
export { mountAdmin } from "./mountAdmin.js";
|
|
3
3
|
export { resolveCaller, } from "./resolveCaller.js";
|
|
4
|
-
export {
|
|
4
|
+
export { createMantleRuntimeRef, } from "./bootRuntimeOnce.js";
|
|
5
5
|
export { createMcpApiHandler, } from "./mountMcp.js";
|
|
6
6
|
export { mountPublicRoutes, } from "./mountPublicRoutes.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/mount/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,GAKd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,GAMlB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Env, Hono } from "hono";
|
|
2
|
+
import { type AdminAssetServer } from "@aotter/mantle-admin";
|
|
3
|
+
import type { MantleRuntimeRef } from "./bootRuntimeOnce.js";
|
|
4
|
+
/** Bind Cloudflare request context to the portable Admin mount. */
|
|
5
|
+
export declare function mountAdmin<E extends Env>(app: Hono<E>, ref: MantleRuntimeRef, assets: AdminAssetServer): void;
|
|
6
|
+
//# sourceMappingURL=mountAdmin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mountAdmin.d.ts","sourceRoot":"","sources":["../../src/mount/mountAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,CAAC,SAAS,GAAG,EACtC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EACZ,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,gBAAgB,GACvB,IAAI,CAWN"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mountMantleAdmin, } from "@aotter/mantle-admin";
|
|
2
|
+
import { readWaitUntil } from "./mountRuntimeEndpoints.js";
|
|
3
|
+
/** Bind Cloudflare request context to the portable Admin mount. */
|
|
4
|
+
export function mountAdmin(app, ref, assets) {
|
|
5
|
+
mountMantleAdmin(app, {
|
|
6
|
+
get: () => ref.get(),
|
|
7
|
+
plan: ref.plan,
|
|
8
|
+
auth: ref.auth,
|
|
9
|
+
assets,
|
|
10
|
+
requestContext: (context) => ({
|
|
11
|
+
env: context.env ?? {},
|
|
12
|
+
waitUntil: readWaitUntil(context),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mountAdmin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mountAdmin.js","sourceRoot":"","sources":["../../src/mount/mountAdmin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,mEAAmE;AACnE,MAAM,UAAU,UAAU,CACxB,GAAY,EACZ,GAAqB,EACrB,MAAwB;IAExB,gBAAgB,CAAC,GAAG,EAAE;QACpB,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE;QACpB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,MAAM;QACN,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC5B,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE;YACtB,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC;SAClC,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
package/dist/mount/mountMcp.d.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MantleRuntimeRef } from "./bootRuntimeOnce.js";
|
|
2
2
|
export interface CreateMcpApiHandlerOptions {
|
|
3
|
-
readonly ref:
|
|
3
|
+
readonly ref: MantleRuntimeRef;
|
|
4
4
|
readonly surface: "staff" | "public";
|
|
5
|
+
/** Canonical RFC 8707/9728 protected resource bound into access-token aud. */
|
|
6
|
+
readonly resource: string;
|
|
5
7
|
/** OAuth scopes required to enter this MCP resource. Defaults to
|
|
6
8
|
* the existing compatibility scope `mcp`. Target-specific scopes
|
|
7
9
|
* remain manifest predicates enforced on tools/call. */
|
|
8
10
|
readonly requiredScopes?: readonly string[];
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
|
-
* Build a Cloudflare Worker `ExportedHandler` that serves one MCP
|
|
12
|
-
* resource
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* The OAuthProvider lib verifies the bearer token and sets its
|
|
16
|
-
* token-specific identity and scopes on `ctx.props` BEFORE calling
|
|
17
|
-
* this handler. We re-read the caller's mutable staff role from D1
|
|
18
|
-
* on every invocation.
|
|
13
|
+
* Build a Cloudflare Worker `ExportedHandler` that serves one MCP path.
|
|
14
|
+
* Better Auth issues resource-bound JWTs; this adapter verifies the token then
|
|
15
|
+
* re-reads the caller's mutable staff role from D1 on every invocation.
|
|
19
16
|
*
|
|
20
17
|
* Note: OAuth scope distinction (`mcp:read` vs `mcp:staff`) used to
|
|
21
18
|
* differentiate surfaces here. Removed because claude.ai's MCP client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountMcp.d.ts","sourceRoot":"","sources":["../../src/mount/mountMcp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mountMcp.d.ts","sourceRoot":"","sources":["../../src/mount/mountMcp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IACrC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;6DAEyD;IACzD,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,OAAO,EAAE,0BAA0B,GAClC,eAAe,CAAC,GAAG,CAAC,CAwHtB"}
|
package/dist/mount/mountMcp.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { McpJsonRpcDispatcher } from "@aotter/mantle-runtime";
|
|
2
|
+
import { DPOP_SIGNING_ALGORITHMS } from "better-auth/oauth2";
|
|
2
3
|
import { contextForVerifiedUser } from "./resolveCaller.js";
|
|
3
4
|
import { rejectCrossOriginMutation } from "../auth/rejectCrossOriginMutation.js";
|
|
4
5
|
/**
|
|
5
|
-
* Build a Cloudflare Worker `ExportedHandler` that serves one MCP
|
|
6
|
-
* resource
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* The OAuthProvider lib verifies the bearer token and sets its
|
|
10
|
-
* token-specific identity and scopes on `ctx.props` BEFORE calling
|
|
11
|
-
* this handler. We re-read the caller's mutable staff role from D1
|
|
12
|
-
* on every invocation.
|
|
6
|
+
* Build a Cloudflare Worker `ExportedHandler` that serves one MCP path.
|
|
7
|
+
* Better Auth issues resource-bound JWTs; this adapter verifies the token then
|
|
8
|
+
* re-reads the caller's mutable staff role from D1 on every invocation.
|
|
13
9
|
*
|
|
14
10
|
* Note: OAuth scope distinction (`mcp:read` vs `mcp:staff`) used to
|
|
15
11
|
* differentiate surfaces here. Removed because claude.ai's MCP client
|
|
@@ -18,7 +14,7 @@ import { rejectCrossOriginMutation } from "../auth/rejectCrossOriginMutation.js"
|
|
|
18
14
|
* driven.
|
|
19
15
|
*/
|
|
20
16
|
export function createMcpApiHandler(options) {
|
|
21
|
-
const { ref, surface } = options;
|
|
17
|
+
const { ref, surface, resource } = options;
|
|
22
18
|
const requiredScopes = options.requiredScopes ?? ["mcp"];
|
|
23
19
|
// Key the cached dispatcher to the runtime identity. Without this,
|
|
24
20
|
// if `ref.get()` rejects + resets and the next call returns a new
|
|
@@ -31,22 +27,25 @@ export function createMcpApiHandler(options) {
|
|
|
31
27
|
const rejected = rejectCrossOriginMutation(request);
|
|
32
28
|
if (rejected)
|
|
33
29
|
return rejected;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
40
|
-
|
|
30
|
+
const verified = await ref.auth.verifyOAuthAccessToken(request, {
|
|
31
|
+
audience: resource,
|
|
32
|
+
scopes: requiredScopes,
|
|
33
|
+
});
|
|
34
|
+
if (!verified.ok)
|
|
35
|
+
return oauthDenied(resource, requiredScopes, verified);
|
|
36
|
+
const grantedScopes = verified.scopes;
|
|
41
37
|
const waitUntil = typeof ctx.waitUntil === "function" ? ctx.waitUntil.bind(ctx) : undefined;
|
|
42
|
-
const handlerContext = await contextForVerifiedUser(
|
|
38
|
+
const handlerContext = await contextForVerifiedUser(verified.userId, {
|
|
43
39
|
credential: "oauth",
|
|
44
|
-
credentialId:
|
|
45
|
-
clientId:
|
|
40
|
+
credentialId: verified.credentialId,
|
|
41
|
+
clientId: verified.clientId,
|
|
46
42
|
scopes: grantedScopes,
|
|
47
43
|
}, ref.auth, { env, ...(waitUntil ? { waitUntil } : {}) });
|
|
48
44
|
if (surface === "staff" && !handlerContext.staff) {
|
|
49
|
-
return
|
|
45
|
+
return oauthDenied(resource, requiredScopes, {
|
|
46
|
+
status: 403,
|
|
47
|
+
reason: "insufficient-scope",
|
|
48
|
+
});
|
|
50
49
|
}
|
|
51
50
|
const runtime = await ref.get();
|
|
52
51
|
// Media tools require BOTH a storage adapter AND a declared
|
|
@@ -86,8 +85,18 @@ export function createMcpApiHandler(options) {
|
|
|
86
85
|
unpublish: runtime.unpublish,
|
|
87
86
|
archive: runtime.archive,
|
|
88
87
|
deleteEntry: runtime.deleteEntry,
|
|
89
|
-
executeView:
|
|
90
|
-
|
|
88
|
+
executeView: {
|
|
89
|
+
execute: (request) => runtime.executeView({
|
|
90
|
+
...request,
|
|
91
|
+
view: request.view.metadata.name,
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
invokeProcedure: {
|
|
95
|
+
execute: (request) => runtime.invokeProcedure({
|
|
96
|
+
...request,
|
|
97
|
+
procedure: request.procedure.metadata.name,
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
91
100
|
media: mediaEnabled && runtime.media
|
|
92
101
|
? {
|
|
93
102
|
createUpload: runtime.media.createUpload,
|
|
@@ -95,14 +104,16 @@ export function createMcpApiHandler(options) {
|
|
|
95
104
|
purposes: mediaPurposes,
|
|
96
105
|
}
|
|
97
106
|
: undefined,
|
|
98
|
-
}, [...runtime.
|
|
107
|
+
}, [...runtime.schemas.values()], {
|
|
99
108
|
surface,
|
|
100
109
|
// A View belongs on surface S iff its declared surface
|
|
101
110
|
// (default "public") matches — mirrors how procedures are
|
|
102
111
|
// gated (#438). Without this, `surface: "staff"` Views leaked
|
|
103
112
|
// into the public `/mcp` tools/list + tools/call.
|
|
104
|
-
views:
|
|
105
|
-
|
|
113
|
+
views: Object.values(ref.plan.views)
|
|
114
|
+
.map(({ manifest }) => manifest)
|
|
115
|
+
.filter((view) => view.spec.surface === surface),
|
|
116
|
+
procedures: collectMcpProcedures(ref.plan, surface),
|
|
106
117
|
serverInfo,
|
|
107
118
|
});
|
|
108
119
|
cached = { configKey, dispatcher };
|
|
@@ -112,29 +123,26 @@ export function createMcpApiHandler(options) {
|
|
|
112
123
|
},
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
|
-
function
|
|
116
|
-
if (!value || typeof value !== "object")
|
|
117
|
-
return null;
|
|
118
|
-
const props = value;
|
|
119
|
-
if (typeof props["userId"] !== "string" ||
|
|
120
|
-
props["userId"].length === 0 ||
|
|
121
|
-
typeof props["clientId"] !== "string" ||
|
|
122
|
-
props["clientId"].length === 0 ||
|
|
123
|
-
!Array.isArray(props["scopes"]) ||
|
|
124
|
-
!props["scopes"].every((scope) => typeof scope === "string"))
|
|
125
|
-
return null;
|
|
126
|
-
return {
|
|
127
|
-
userId: props["userId"],
|
|
128
|
-
clientId: props["clientId"],
|
|
129
|
-
scopes: props["scopes"],
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function forbidden(requiredScopes) {
|
|
126
|
+
function oauthDenied(resource, requiredScopes, denied) {
|
|
133
127
|
const scope = requiredScopes.join(" ");
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
const resourceUrl = new URL(resource);
|
|
129
|
+
const resourcePath = resourceUrl.pathname.replace(/\/$/u, "");
|
|
130
|
+
const metadata = new URL(`/.well-known/oauth-protected-resource${resourcePath}`, resourceUrl.origin).href;
|
|
131
|
+
const error = denied.status === 403 ? "insufficient_scope" : "invalid_token";
|
|
132
|
+
const challenge = denied.reason === "invalid-dpop-proof"
|
|
133
|
+
? `DPoP error="invalid_dpop_proof", algs="${DPOP_SIGNING_ALGORITHMS.join(" ")}"`
|
|
134
|
+
: `Bearer realm="mcp", error="${error}", scope="${scope}", resource_metadata="${metadata}"`;
|
|
135
|
+
return Response.json({
|
|
136
|
+
jsonrpc: "2.0",
|
|
137
|
+
error: {
|
|
138
|
+
code: -32000,
|
|
139
|
+
message: denied.status === 403 ? "insufficient scope" : "unauthorized",
|
|
140
|
+
},
|
|
141
|
+
id: null,
|
|
142
|
+
}, {
|
|
143
|
+
status: denied.status,
|
|
136
144
|
headers: {
|
|
137
|
-
"www-authenticate":
|
|
145
|
+
"www-authenticate": challenge,
|
|
138
146
|
"access-control-expose-headers": "WWW-Authenticate",
|
|
139
147
|
},
|
|
140
148
|
});
|
|
@@ -147,14 +155,14 @@ function forbidden(requiredScopes) {
|
|
|
147
155
|
* are silently dropped here — boot validation already rejects those
|
|
148
156
|
* with TRIGGER_TARGET_PROCEDURE_UNKNOWN before we get this far.
|
|
149
157
|
*/
|
|
150
|
-
function collectMcpProcedures(
|
|
158
|
+
function collectMcpProcedures(plan, surface) {
|
|
151
159
|
const out = [];
|
|
152
|
-
for (const t of triggers) {
|
|
160
|
+
for (const { manifest: t } of Object.values(plan.triggers)) {
|
|
153
161
|
if (t.spec.source.kind !== "mcp")
|
|
154
162
|
continue;
|
|
155
163
|
if (t.spec.source.surface !== surface)
|
|
156
164
|
continue;
|
|
157
|
-
const p =
|
|
165
|
+
const p = plan.procedures[t.spec.target.procedure]?.manifest;
|
|
158
166
|
if (p)
|
|
159
167
|
out.push(p);
|
|
160
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountMcp.js","sourceRoot":"","sources":["../../src/mount/mountMcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"mountMcp.js","sourceRoot":"","sources":["../../src/mount/mountMcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAajF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAmC;IAEnC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,CAAC;IACzD,mEAAmE;IACnE,kEAAkE;IAClE,8DAA8D;IAC9D,kEAAkE;IAClE,qDAAqD;IACrD,MAAM,eAAe,GAAG,I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from "hono";
|
|
2
2
|
import type { SiteConfig } from "@aotter/mantle-spec";
|
|
3
|
-
import { type
|
|
4
|
-
import type {
|
|
3
|
+
import { type SeoMeta } from "@aotter/mantle-web";
|
|
4
|
+
import type { CloudflareMantleRuntime, MantleRuntimeRef } from "./bootRuntimeOnce.js";
|
|
5
5
|
/**
|
|
6
6
|
* `mountPublicRoutes` — mounts the SDK-managed public surface on the
|
|
7
7
|
* consumer's Hono app. Replaces ~140 lines of route-stitching every
|
|
@@ -48,7 +48,7 @@ export interface CollectionRouteConfig {
|
|
|
48
48
|
readonly homeSlug?: string;
|
|
49
49
|
}
|
|
50
50
|
export interface PublicContentContext {
|
|
51
|
-
readonly runtime:
|
|
51
|
+
readonly runtime: CloudflareMantleRuntime;
|
|
52
52
|
readonly site: SiteConfig;
|
|
53
53
|
readonly locale: string;
|
|
54
54
|
}
|
|
@@ -77,5 +77,5 @@ export interface MountPublicRoutesOptions {
|
|
|
77
77
|
/** Live-dev flag — disables public caching for entry / list HTML. */
|
|
78
78
|
readonly liveDev?: boolean;
|
|
79
79
|
}
|
|
80
|
-
export declare function mountPublicRoutes(app: Hono, ref:
|
|
80
|
+
export declare function mountPublicRoutes(app: Hono, ref: MantleRuntimeRef, options: MountPublicRoutesOptions): void;
|
|
81
81
|
//# sourceMappingURL=mountPublicRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountPublicRoutes.d.ts","sourceRoot":"","sources":["../../src/mount/mountPublicRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAS,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"mountPublicRoutes.d.ts","sourceRoot":"","sources":["../../src/mount/mountPublicRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAA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