@catamorphic/fastify-plugin 0.0.0-stage → 0.1.0-alpha.31
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.txt +202 -0
- package/NOTICE.txt +32 -0
- package/README.md +143 -2
- package/dist/app-presentation-tools.d.ts +4 -0
- package/dist/app-presentation-tools.d.ts.map +1 -0
- package/dist/app.d.ts +27 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/chunk-baagvvm3.js +164 -0
- package/dist/chunk-baagvvm3.js.map +10 -0
- package/dist/http-identity.d.ts +52 -0
- package/dist/http-identity.d.ts.map +1 -0
- package/dist/hung-up.d.ts +7 -0
- package/dist/hung-up.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10884 -0
- package/dist/index.js.map +56 -0
- package/dist/mcp-shared.d.ts +117 -0
- package/dist/mcp-shared.d.ts.map +1 -0
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +13 -0
- package/dist/mcp.js.map +9 -0
- package/dist/plugin.d.ts +113 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/project-capabilities.d.ts +25 -0
- package/dist/project-capabilities.d.ts.map +1 -0
- package/dist/project-mcp-program.d.ts +15 -0
- package/dist/project-mcp-program.d.ts.map +1 -0
- package/dist/project-mcp-surface.d.ts +16 -0
- package/dist/project-mcp-surface.d.ts.map +1 -0
- package/dist/request-logging.d.ts +18 -0
- package/dist/request-logging.d.ts.map +1 -0
- package/dist/routes/agent-capabilities.d.ts +4 -0
- package/dist/routes/agent-capabilities.d.ts.map +1 -0
- package/dist/routes/agent.d.ts +4 -0
- package/dist/routes/agent.d.ts.map +1 -0
- package/dist/routes/apps-mcp.d.ts +4 -0
- package/dist/routes/apps-mcp.d.ts.map +1 -0
- package/dist/routes/apps.d.ts +12 -0
- package/dist/routes/apps.d.ts.map +1 -0
- package/dist/routes/client-runners.d.ts +11 -0
- package/dist/routes/client-runners.d.ts.map +1 -0
- package/dist/routes/code-hosts.d.ts +11 -0
- package/dist/routes/code-hosts.d.ts.map +1 -0
- package/dist/routes/connection-mcp.d.ts +10 -0
- package/dist/routes/connection-mcp.d.ts.map +1 -0
- package/dist/routes/connections.d.ts +4 -0
- package/dist/routes/connections.d.ts.map +1 -0
- package/dist/routes/documents.d.ts +11 -0
- package/dist/routes/documents.d.ts.map +1 -0
- package/dist/routes/environments.d.ts +4 -0
- package/dist/routes/environments.d.ts.map +1 -0
- package/dist/routes/git-gateway.d.ts +21 -0
- package/dist/routes/git-gateway.d.ts.map +1 -0
- package/dist/routes/http-gateway.d.ts +13 -0
- package/dist/routes/http-gateway.d.ts.map +1 -0
- package/dist/routes/me.d.ts +12 -0
- package/dist/routes/me.d.ts.map +1 -0
- package/dist/routes/memberships.d.ts +12 -0
- package/dist/routes/memberships.d.ts.map +1 -0
- package/dist/routes/model-gateway.d.ts +12 -0
- package/dist/routes/model-gateway.d.ts.map +1 -0
- package/dist/routes/notifications.d.ts +4 -0
- package/dist/routes/notifications.d.ts.map +1 -0
- package/dist/routes/parse.d.ts +5 -0
- package/dist/routes/parse.d.ts.map +1 -0
- package/dist/routes/personal-environment.d.ts +13 -0
- package/dist/routes/personal-environment.d.ts.map +1 -0
- package/dist/routes/plugins.d.ts +4 -0
- package/dist/routes/plugins.d.ts.map +1 -0
- package/dist/routes/project-mcp.d.ts +25 -0
- package/dist/routes/project-mcp.d.ts.map +1 -0
- package/dist/routes/projects.d.ts +4 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/publications.d.ts +15 -0
- package/dist/routes/publications.d.ts.map +1 -0
- package/dist/routes/run-errors.d.ts +8 -0
- package/dist/routes/run-errors.d.ts.map +1 -0
- package/dist/routes/runs.d.ts +4 -0
- package/dist/routes/runs.d.ts.map +1 -0
- package/dist/routes/session-artifacts.d.ts +27 -0
- package/dist/routes/session-artifacts.d.ts.map +1 -0
- package/dist/routes/session-mailboxes.d.ts +4 -0
- package/dist/routes/session-mailboxes.d.ts.map +1 -0
- package/dist/routes/session-previews.d.ts +40 -0
- package/dist/routes/session-previews.d.ts.map +1 -0
- package/dist/routes/session-terminals.d.ts +15 -0
- package/dist/routes/session-terminals.d.ts.map +1 -0
- package/dist/routes/triggers.d.ts +20 -0
- package/dist/routes/triggers.d.ts.map +1 -0
- package/dist/routes/watchers.d.ts +4 -0
- package/dist/routes/watchers.d.ts.map +1 -0
- package/dist/routes/webhooks.d.ts +11 -0
- package/dist/routes/webhooks.d.ts.map +1 -0
- package/dist/routes/workflow-enablements.d.ts +4 -0
- package/dist/routes/workflow-enablements.d.ts.map +1 -0
- package/dist/routes/workflows.d.ts +4 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/schemas.d.ts +17776 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/session-artifact-tools.d.ts +5 -0
- package/dist/session-artifact-tools.d.ts.map +1 -0
- package/dist/session-event-stream.d.ts +45 -0
- package/dist/session-event-stream.d.ts.map +1 -0
- package/dist/spa.d.ts +24 -0
- package/dist/spa.d.ts.map +1 -0
- package/dist/telemetry.d.ts +4 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/package.json +73 -4
- package/src/app-presentation-tools.ts +46 -0
- package/src/app.ts +115 -0
- package/src/http-identity.ts +145 -0
- package/src/hung-up.ts +13 -0
- package/src/index.ts +25 -0
- package/src/mcp-shared.ts +331 -0
- package/src/mcp.ts +10 -0
- package/src/plugin.ts +332 -0
- package/src/project-capabilities.ts +153 -0
- package/src/project-mcp-program.ts +607 -0
- package/src/project-mcp-surface.ts +881 -0
- package/src/request-logging.ts +47 -0
- package/src/routes/agent-capabilities.ts +109 -0
- package/src/routes/agent.ts +1566 -0
- package/src/routes/apps-mcp.ts +303 -0
- package/src/routes/apps.ts +692 -0
- package/src/routes/client-runners.ts +251 -0
- package/src/routes/code-hosts.ts +247 -0
- package/src/routes/connection-mcp.ts +135 -0
- package/src/routes/connections.ts +494 -0
- package/src/routes/documents.ts +538 -0
- package/src/routes/environments.ts +72 -0
- package/src/routes/git-gateway.ts +106 -0
- package/src/routes/http-gateway.ts +141 -0
- package/src/routes/me.ts +122 -0
- package/src/routes/memberships.ts +173 -0
- package/src/routes/model-gateway.ts +134 -0
- package/src/routes/notifications.ts +101 -0
- package/src/routes/parse.ts +32 -0
- package/src/routes/personal-environment.ts +146 -0
- package/src/routes/plugins.ts +341 -0
- package/src/routes/project-mcp.ts +394 -0
- package/src/routes/projects.ts +708 -0
- package/src/routes/publications.ts +222 -0
- package/src/routes/run-errors.ts +86 -0
- package/src/routes/runs.ts +253 -0
- package/src/routes/session-artifacts.ts +293 -0
- package/src/routes/session-mailboxes.ts +80 -0
- package/src/routes/session-previews.ts +224 -0
- package/src/routes/session-terminals.ts +209 -0
- package/src/routes/triggers.ts +241 -0
- package/src/routes/watchers.ts +94 -0
- package/src/routes/webhooks.ts +171 -0
- package/src/routes/workflow-enablements.ts +331 -0
- package/src/routes/workflows.ts +323 -0
- package/src/schemas.ts +2735 -0
- package/src/session-artifact-tools.ts +170 -0
- package/src/session-event-stream.ts +122 -0
- package/src/spa.ts +135 -0
- package/src/telemetry.ts +93 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Identity } from "@catamorphic/core";
|
|
2
|
+
import type { FastifyRequest } from "fastify";
|
|
3
|
+
/**
|
|
4
|
+
* The one identity mechanism of the HTTP surface. The host supplies a
|
|
5
|
+
* resolver when it registers the plugin; it runs on every request (including
|
|
6
|
+
* iframe navigations to served app documents, which carry the host's own
|
|
7
|
+
* session cookie) and returns the caller's {@link Identity} — root for the
|
|
8
|
+
* host itself, scoped for a member — or `null` for "not authenticated" (401).
|
|
9
|
+
*
|
|
10
|
+
* There is no default: catamorphic is embed-only and never guesses who is
|
|
11
|
+
* calling. Hosts that terminate auth elsewhere (a proxy, a sidecar behind
|
|
12
|
+
* the host's gateway) pass {@link identityFromHeaders}; everyone else writes
|
|
13
|
+
* the few lines that turn their verified session into an identity.
|
|
14
|
+
*/
|
|
15
|
+
export type IdentityResolver = (request: FastifyRequest) => Identity | null | Promise<Identity | null>;
|
|
16
|
+
/**
|
|
17
|
+
* A stock resolver reading `X-Catamorphic-Tenant-Id` and `X-External-User-Id`.
|
|
18
|
+
* Only for hosts whose auth layer sits *in front of* the plugin and sets these
|
|
19
|
+
* headers itself from a verified session (a proxy route, a gateway); never
|
|
20
|
+
* expose a plugin using this resolver directly to browsers, since anyone
|
|
21
|
+
* could then claim any identity. Both headers are required and yield full
|
|
22
|
+
* identities — a header-terminated host that wants scoped viewers wraps this
|
|
23
|
+
* in its own resolver.
|
|
24
|
+
*/
|
|
25
|
+
export declare function identityFromHeaders(): IdentityResolver;
|
|
26
|
+
/**
|
|
27
|
+
* A stock resolver for hosts whose members arrive with a bearer token the
|
|
28
|
+
* host itself issued — the desktop's remote projects, a member's own agent
|
|
29
|
+
* on the project MCP endpoint, a connect link (ADR 0055). `verify` is the
|
|
30
|
+
* host's: it turns the token into who is calling (and, typically, hands
|
|
31
|
+
* that to `core.memberships.identityFor` or `resolveRoles`), or `null` for
|
|
32
|
+
* an unknown/expired token. A missing or malformed header is `null` too —
|
|
33
|
+
* 401, never a guess. Revocation is instant by construction: every request
|
|
34
|
+
* re-verifies.
|
|
35
|
+
*/
|
|
36
|
+
export declare function identityFromBearer(verify: (token: string, request: FastifyRequest) => Identity | null | Promise<Identity | null>): IdentityResolver;
|
|
37
|
+
/** Stores the resolved identity on the request (plugin-internal). */
|
|
38
|
+
export declare function attachIdentity(request: FastifyRequest, identity: Identity): void;
|
|
39
|
+
/** The attached identity, or null on a public route with no session. */
|
|
40
|
+
export declare function optionalIdentity(request: FastifyRequest): Identity | null;
|
|
41
|
+
/**
|
|
42
|
+
* The identity the plugin's resolver attached to this request. Routes call
|
|
43
|
+
* this; it never reads headers itself.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveIdentity(request: FastifyRequest): Identity;
|
|
46
|
+
export declare function getExternalUserId(request: FastifyRequest): string;
|
|
47
|
+
export declare function getTenantId(request: FastifyRequest): string;
|
|
48
|
+
/** A malformed identity claim from the host (400), distinct from 401. */
|
|
49
|
+
export declare class HttpIdentityError extends Error {
|
|
50
|
+
constructor(message: string);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=http-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-identity.d.ts","sourceRoot":"","sources":["../src/http-identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,cAAc,KACpB,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAQhD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAKtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,CACN,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,KACpB,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAC9C,gBAAgB,CASlB;AAQD,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,QAWzE;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAEzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,QAAQ,CAQjE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAajE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAa3D;AAED,yEAAyE;AACzE,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FastifyReply } from "fastify";
|
|
2
|
+
/**
|
|
3
|
+
* Aborts when the caller hangs up before the answer is sent, so a long
|
|
4
|
+
* poll or wait nobody is listening to any more ends.
|
|
5
|
+
*/
|
|
6
|
+
export declare function hungUp(reply: FastifyReply): AbortSignal;
|
|
7
|
+
//# sourceMappingURL=hung-up.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hung-up.d.ts","sourceRoot":"","sources":["../src/hung-up.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAMvD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { AppConfig } from "./app.js";
|
|
2
|
+
export { createApp } from "./app.js";
|
|
3
|
+
export { HttpIdentityError, type IdentityResolver, identityFromBearer, identityFromHeaders, } from "./http-identity.js";
|
|
4
|
+
export type { CatamorphicPluginOptions, ProjectMcpHost, ProjectMcpHostTool, RouteContext, } from "./plugin.js";
|
|
5
|
+
export { catamorphicPlugin } from "./plugin.js";
|
|
6
|
+
export { projectToolCapabilities } from "./project-capabilities.js";
|
|
7
|
+
export { apiErrorResponse, apiNotFoundResponse, errorLogFields, requestLogFields, } from "./request-logging.js";
|
|
8
|
+
export { PREVIEW_REFUSAL_HEADER } from "./routes/session-previews.js";
|
|
9
|
+
export { pwaManifestWithLaunch, serveSpaDist } from "./spa.js";
|
|
10
|
+
export { instrumentHttpServer } from "./telemetry.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|