@sixb/server 0.1.1 → 0.1.2
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 +3 -3
- package/dist/auth/application-access.d.ts +2 -2
- package/dist/auth/application-access.d.ts.map +1 -1
- package/dist/auth/connector-callback-cookie.d.ts +12 -0
- package/dist/auth/connector-callback-cookie.d.ts.map +1 -0
- package/dist/auth/guard.d.ts +3 -3
- package/dist/auth/guard.d.ts.map +1 -1
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/scope.d.ts +13 -27
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/auth/session-cookies.d.ts +2 -2
- package/dist/auth/session-cookies.d.ts.map +1 -1
- package/dist/connectors/http.d.ts +16 -0
- package/dist/connectors/http.d.ts.map +1 -0
- package/dist/index.js +3293 -2704
- package/dist/index.js.map +55 -50
- package/dist/openapi/tags.d.ts +11 -3
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts +6 -2
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/action-runs.d.ts +21 -31
- package/dist/routes/action-runs.d.ts.map +1 -1
- package/dist/routes/actions.d.ts +9 -8
- package/dist/routes/actions.d.ts.map +1 -1
- package/dist/routes/agent-api-gateway.d.ts +2 -2
- package/dist/routes/agent-api-gateway.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +130 -131
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +84 -84
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connector-connection-runs.d.ts +794 -0
- package/dist/routes/connector-connection-runs.d.ts.map +1 -0
- package/dist/routes/connector-connections.d.ts +219 -0
- package/dist/routes/connector-connections.d.ts.map +1 -0
- package/dist/routes/connectors.d.ts +10 -4
- package/dist/routes/connectors.d.ts.map +1 -1
- package/dist/routes/datasets.d.ts +8 -4
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/events.d.ts +8 -8
- package/dist/routes/events.d.ts.map +1 -1
- package/dist/routes/files.d.ts +11 -10
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/links.d.ts +2 -2
- package/dist/routes/links.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +5 -5
- package/dist/routes/logs.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +34 -34
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/ontology.d.ts +50 -50
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +24 -34
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/project.d.ts +2 -2
- package/dist/routes/project.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +131 -83
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/rules.d.ts +6 -6
- package/dist/routes/rules.d.ts.map +1 -1
- package/dist/routes/status.d.ts +2 -2
- package/dist/routes/status.d.ts.map +1 -1
- package/dist/routes/syncs.d.ts +20 -25
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/telemetry.d.ts +2 -2
- package/dist/routes/telemetry.d.ts.map +1 -1
- package/dist/routes/webhook-runs.d.ts +9 -9
- package/dist/routes/webhook-runs.d.ts.map +1 -1
- package/dist/routes/webhooks.d.ts +2 -2
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +74 -48
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/agents.d.ts +11 -5
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/events.d.ts +8 -8
- package/dist/routes/ws/events.d.ts.map +1 -1
- package/dist/routes/ws/log-subscription-hub.d.ts +6 -3
- package/dist/routes/ws/log-subscription-hub.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/routes/ws/logs.d.ts.map +1 -1
- package/dist/schemas/actions.d.ts +97 -202
- package/dist/schemas/actions.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +442 -439
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-usage.d.ts +34 -0
- package/dist/schemas/ai-usage.d.ts.map +1 -0
- package/dist/schemas/auth.d.ts +142 -142
- package/dist/schemas/common.d.ts +37 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +713 -2
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/datasets.d.ts +2 -2
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +34 -34
- package/dist/schemas/logs.d.ts +22 -22
- package/dist/schemas/objects.d.ts +10 -10
- package/dist/schemas/ontology.d.ts +118 -118
- package/dist/schemas/pipelines.d.ts +95 -190
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +918 -563
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/rules.d.ts +6 -6
- package/dist/schemas/status.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +65 -108
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/webhook-runs.d.ts +41 -41
- package/dist/schemas/webhook-runs.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +516 -183
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +6 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/utils/http.d.ts +2 -0
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/ws.d.ts +4 -3
- package/dist/utils/ws.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/auth/access-token-boundary.ts +4 -4
- package/src/auth/application-access.ts +8 -9
- package/src/auth/connector-callback-cookie.ts +95 -0
- package/src/auth/guard.ts +11 -11
- package/src/auth/public-routes.ts +13 -0
- package/src/auth/scope.ts +26 -36
- package/src/auth/session-cookies.ts +3 -3
- package/src/connectors/http.ts +110 -0
- package/src/openapi/tags.ts +9 -1
- package/src/registerRoutes.ts +34 -23
- package/src/routes/action-runs.ts +39 -39
- package/src/routes/actions.ts +7 -13
- package/src/routes/agent-api-gateway.ts +41 -38
- package/src/routes/agents.ts +89 -200
- package/src/routes/auth.ts +87 -91
- package/src/routes/connector-connection-runs.ts +346 -0
- package/src/routes/connector-connections.ts +135 -0
- package/src/routes/connectors.ts +24 -12
- package/src/routes/datasets.ts +55 -54
- package/src/routes/events.ts +5 -5
- package/src/routes/files.ts +22 -30
- package/src/routes/links.ts +31 -35
- package/src/routes/logs.ts +6 -11
- package/src/routes/objects.ts +51 -114
- package/src/routes/ontology.ts +27 -38
- package/src/routes/pipelines.ts +28 -62
- package/src/routes/project.ts +3 -3
- package/src/routes/projections.ts +26 -38
- package/src/routes/rules.ts +11 -25
- package/src/routes/status.ts +5 -5
- package/src/routes/syncs.ts +19 -45
- package/src/routes/telemetry.ts +18 -29
- package/src/routes/webhook-runs.ts +5 -5
- package/src/routes/webhooks.ts +259 -341
- package/src/routes/workflows.ts +226 -248
- package/src/routes/ws/agents.ts +196 -66
- package/src/routes/ws/events.ts +11 -10
- package/src/routes/ws/log-subscription-hub.ts +6 -12
- package/src/routes/ws/logs.ts +13 -5
- package/src/schemas/actions.ts +58 -25
- package/src/schemas/agents.ts +19 -14
- package/src/schemas/ai-usage.ts +16 -0
- package/src/schemas/common.ts +24 -0
- package/src/schemas/connectors.ts +164 -0
- package/src/schemas/pipelines.ts +23 -15
- package/src/schemas/projections.ts +17 -3
- package/src/schemas/syncs.ts +13 -8
- package/src/schemas/webhook-runs.ts +10 -5
- package/src/schemas/workflows.ts +16 -6
- package/src/server.ts +65 -26
- package/src/utils/http.ts +34 -6
- package/src/utils/ws.ts +10 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAA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1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SixbHostView } from "@sixb/core";
|
|
2
2
|
import { Elysia } from "elysia";
|
|
3
3
|
import { type AuthInvitationDestinationOptions, type AuthInvitationRedirectContext, type AuthInvitationRedirectInput, type RequestAuthContext, type ResolveAuthRedirectContext, type ResolvedSixbApiBrowserPolicy, type SixbApiBrowserPolicy } from "./auth/browser-origin";
|
|
4
4
|
export interface SixbServerOptions {
|
|
5
|
-
|
|
5
|
+
host: SixbHostView;
|
|
6
6
|
port?: number;
|
|
7
|
-
|
|
7
|
+
hostname?: string;
|
|
8
8
|
quiet?: boolean;
|
|
9
9
|
browser: SixbApiBrowserPolicy;
|
|
10
10
|
}
|
|
11
11
|
export declare function createSixbServer(options: SixbServerOptions): SixbServer;
|
|
12
12
|
export declare class SixbServer {
|
|
13
|
-
private readonly
|
|
13
|
+
private readonly hostRuntime;
|
|
14
14
|
private readonly port;
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly hostname;
|
|
16
16
|
private readonly quiet;
|
|
17
17
|
private readonly apiBrowserPolicy;
|
|
18
18
|
private readonly authContextResolver;
|
|
@@ -21,7 +21,7 @@ export declare class SixbServer {
|
|
|
21
21
|
private bunServer;
|
|
22
22
|
private maintenance;
|
|
23
23
|
constructor(options: SixbServerOptions);
|
|
24
|
-
|
|
24
|
+
getHost(): SixbHostView;
|
|
25
25
|
getPort(): number;
|
|
26
26
|
resolveAuthContext(request: Request): RequestAuthContext;
|
|
27
27
|
resolveAuthRedirectContext(request: Parameters<ResolveAuthRedirectContext>[0], input: Parameters<ResolveAuthRedirectContext>[1]): ReturnType<ResolveAuthRedirectContext>;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":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AK,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,GAC/C,UAAU,CAAC,0BAA0B,CAAC;IAIzC,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAIlD,+BAA+B,CAAC,QAAQ,EAAE,OAAO,GAAG,gCAAgC;IAIpF,gCAAgC,CAC9B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,2BAA2B,GACjC,6BAA6B;IAIhC,mBAAmB,IAAI,4BAA4B;IAI7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAe5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgK/C;AAiED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
package/dist/utils/http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SixbErrorCode } from "@sixb/core";
|
|
1
2
|
export declare function toIsoString(value: Date): string;
|
|
2
3
|
export declare function parseDate(value: string | undefined): Date | undefined;
|
|
3
4
|
export declare function parseOptionalInt(value: string | undefined): number | undefined;
|
|
@@ -19,5 +20,6 @@ export declare function handleRouteError(error: unknown, set: {
|
|
|
19
20
|
status?: number | string;
|
|
20
21
|
}): {
|
|
21
22
|
error: string;
|
|
23
|
+
code?: SixbErrorCode;
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/utils/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAA;AA2BnB,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAWrE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACjC,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAGnB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAChC;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,aAAa,CAAA;CACrB,CAsCA"}
|
package/dist/utils/ws.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OntologySource } from "@sixb/core";
|
|
2
|
+
import type { Sixb } from "@sixb/core/internal/request-execution";
|
|
2
3
|
export declare function safeSend(target: {
|
|
3
4
|
send: (message: string) => void;
|
|
4
5
|
}, payload: unknown): void;
|
|
5
6
|
/** Stable per-connection key for a subscription-state WeakMap (the raw socket when Elysia wraps it). */
|
|
6
7
|
export declare function wsStateKey(ws: object): object;
|
|
7
|
-
/** The
|
|
8
|
-
export declare function
|
|
8
|
+
/** The execution SDK attached once when the WebSocket request crosses the auth boundary. */
|
|
9
|
+
export declare function wsRequestSixb(ws: object): Sixb<readonly OntologySource[]> | null;
|
|
9
10
|
export declare function decodeWsMessage(message: unknown): Promise<unknown>;
|
|
10
11
|
//# sourceMappingURL=ws.d.ts.map
|
package/dist/utils/ws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/utils/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/utils/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAA;AAEjE,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAM5F;AAED,wGAAwG;AACxG,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS,cAAc,EAAE,CAAC,GAAG,IAAI,CAOhF;AAUD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA4BxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "HTTP and WebSocket API server for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"zod-to-json-schema": "^3.24.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@sixb/core": "0.1.
|
|
40
|
+
"@sixb/core": "0.1.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@sixb/auth-magic-link": "0.1.1",
|
|
44
44
|
"@sixb/auth-oidc": "0.1.1",
|
|
45
|
-
"@sixb/core": "0.1.
|
|
46
|
-
"@sixb/sqlite": "0.1.
|
|
45
|
+
"@sixb/core": "0.1.2",
|
|
46
|
+
"@sixb/sqlite": "0.1.2",
|
|
47
47
|
"@types/bun": "latest",
|
|
48
48
|
"typescript": "^5.7.0"
|
|
49
49
|
},
|
|
@@ -21,9 +21,9 @@ export interface AccessTokenRoute {
|
|
|
21
21
|
// `agentApi` projection of the same table, which the table's load-time invariant keeps a strict
|
|
22
22
|
// subset of this one.
|
|
23
23
|
//
|
|
24
|
-
// Bearer tokens should only reach routes that
|
|
25
|
-
//
|
|
26
|
-
//
|
|
24
|
+
// Bearer tokens should only reach routes that enforce execution-bound authority. Admin, browser,
|
|
25
|
+
// webhook, and WebSocket routes stay session-only because bearer access is intentionally absent
|
|
26
|
+
// from SIXB_API_ROUTES.
|
|
27
27
|
export const ACCESS_TOKEN_ROUTES: readonly AccessTokenRoute[] = SIXB_API_ROUTES.filter(
|
|
28
28
|
(route) => route.accessToken
|
|
29
29
|
).map((route) => ({ operationId: route.operationId, method: route.method, path: route.path }))
|
|
@@ -63,6 +63,6 @@ export function shouldVerifyCsrfForAuthSource(
|
|
|
63
63
|
source: AuthCredentialSource
|
|
64
64
|
): boolean {
|
|
65
65
|
// CSRF protects ambient browser cookies. Bearer tokens are explicit request
|
|
66
|
-
// credentials, so they skip CSRF while still requiring
|
|
66
|
+
// credentials, so they skip CSRF while still requiring execution-bound authorization.
|
|
67
67
|
return route.csrfProtected && source === "session"
|
|
68
68
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AuthSessionAudience,
|
|
3
|
-
canAccessApplication,
|
|
4
|
-
type OntologySource,
|
|
5
|
-
type Sixb,
|
|
6
|
-
} from "@sixb/core"
|
|
1
|
+
import { type AuthSessionAudience, canAccessApplication, type SixbHostView } from "@sixb/core"
|
|
7
2
|
import type { AuthenticatedRequestAuthSession } from "@sixb/core/internal/auth"
|
|
8
3
|
|
|
9
4
|
export function sessionCanAccessApplication(
|
|
10
|
-
|
|
5
|
+
host: SixbHostView,
|
|
11
6
|
session: AuthenticatedRequestAuthSession,
|
|
12
7
|
audience: AuthSessionAudience
|
|
13
8
|
): boolean {
|
|
14
|
-
const authorization =
|
|
15
|
-
return canAccessApplication(
|
|
9
|
+
const authorization = host.auth.contextFromSession(session)
|
|
10
|
+
return canAccessApplication(
|
|
11
|
+
authorization,
|
|
12
|
+
host.definitions.security.listResolvedRoles(),
|
|
13
|
+
audience
|
|
14
|
+
)
|
|
16
15
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { getCookie } from "@sixb/core/internal/auth"
|
|
2
|
+
import { createSixbError } from "@sixb/core/internal/errors"
|
|
3
|
+
|
|
4
|
+
const CALLBACK_PATH = "/auth/connectors/callback"
|
|
5
|
+
const COOKIE_PREFIX = "sixb_connector_callback_"
|
|
6
|
+
const ATTEMPT_ID_PATTERN =
|
|
7
|
+
/^cat_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
|
8
|
+
|
|
9
|
+
export function createConnectorCallbackCookie(input: {
|
|
10
|
+
readonly request: Request
|
|
11
|
+
readonly attemptId: string
|
|
12
|
+
readonly secret: string
|
|
13
|
+
readonly expiresAt: Date
|
|
14
|
+
}): string {
|
|
15
|
+
const expiresAt = validDate(input.expiresAt)
|
|
16
|
+
return serializeConnectorCallbackCookie({
|
|
17
|
+
request: input.request,
|
|
18
|
+
name: connectorCallbackCookieName(input.attemptId),
|
|
19
|
+
value: input.secret,
|
|
20
|
+
maxAge: Math.max(0, Math.floor((expiresAt.getTime() - Date.now()) / 1000)),
|
|
21
|
+
expiresAt,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function readConnectorCallbackCookie(
|
|
26
|
+
request: Request,
|
|
27
|
+
state: string
|
|
28
|
+
): { readonly name: string; readonly value: string | undefined } {
|
|
29
|
+
const name = connectorCallbackCookieName(attemptIdFromState(state))
|
|
30
|
+
return { name, value: getCookie(request, name) }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function clearConnectorCallbackCookie(request: Request, name: string): string {
|
|
34
|
+
return serializeConnectorCallbackCookie({
|
|
35
|
+
request,
|
|
36
|
+
name,
|
|
37
|
+
value: "",
|
|
38
|
+
maxAge: 0,
|
|
39
|
+
expiresAt: new Date(0),
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function attemptIdFromState(state: string): string {
|
|
44
|
+
const separator = state.indexOf(".")
|
|
45
|
+
if (separator <= 0 || separator === state.length - 1) {
|
|
46
|
+
throw createSixbError(
|
|
47
|
+
"connector.authorization_invalid",
|
|
48
|
+
"[SixbServer] Connector OAuth state is invalid."
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
return state.slice(0, separator)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function connectorCallbackCookieName(attemptId: string): string {
|
|
55
|
+
if (!ATTEMPT_ID_PATTERN.test(attemptId)) {
|
|
56
|
+
throw createSixbError(
|
|
57
|
+
"connector.authorization_invalid",
|
|
58
|
+
"[SixbServer] Connector OAuth attempt id is invalid."
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
return `${COOKIE_PREFIX}${attemptId}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function serializeConnectorCallbackCookie(input: {
|
|
65
|
+
readonly request: Request
|
|
66
|
+
readonly name: string
|
|
67
|
+
readonly value: string
|
|
68
|
+
readonly maxAge: number
|
|
69
|
+
readonly expiresAt: Date
|
|
70
|
+
}): string {
|
|
71
|
+
const parts = [
|
|
72
|
+
`${input.name}=${input.value}`,
|
|
73
|
+
`Path=${CALLBACK_PATH}`,
|
|
74
|
+
"HttpOnly",
|
|
75
|
+
"SameSite=Lax",
|
|
76
|
+
`Max-Age=${Math.trunc(input.maxAge)}`,
|
|
77
|
+
`Expires=${input.expiresAt.toUTCString()}`,
|
|
78
|
+
]
|
|
79
|
+
if (shouldUseSecureCookie(input.request)) parts.push("Secure")
|
|
80
|
+
return parts.join("; ")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function shouldUseSecureCookie(request: Request): boolean {
|
|
84
|
+
return new URL(request.url).protocol === "https:" || process.env.NODE_ENV === "production"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function validDate(value: Date): Date {
|
|
88
|
+
if (Number.isNaN(value.getTime())) {
|
|
89
|
+
throw createSixbError(
|
|
90
|
+
"internal.unexpected",
|
|
91
|
+
"[SixbServer] Connector callback cookie expiration is invalid."
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
return new Date(value)
|
|
95
|
+
}
|
package/src/auth/guard.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SixbHostView } from "@sixb/core"
|
|
2
2
|
import {
|
|
3
3
|
type AuthenticatedRequestAuthSession,
|
|
4
4
|
verifyDoubleSubmitCsrf,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { hasForegroundSessionActivity, isSessionTerminationRequest } from "./session-activity"
|
|
18
18
|
|
|
19
19
|
export interface ServerAuthGuardOptions {
|
|
20
|
-
readonly
|
|
20
|
+
readonly host: SixbHostView
|
|
21
21
|
readonly resolveAuthContext: ResolveRequestAuthContext
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -33,20 +33,20 @@ export type ServerAuthGuardDecision =
|
|
|
33
33
|
| { readonly kind: "allow"; readonly session: AuthenticatedRequestAuthSession | null }
|
|
34
34
|
|
|
35
35
|
export class ServerAuthGuard {
|
|
36
|
-
private readonly
|
|
36
|
+
private readonly host: SixbHostView
|
|
37
37
|
private readonly resolveAuthContext: ResolveRequestAuthContext
|
|
38
38
|
|
|
39
39
|
constructor(options: ServerAuthGuardOptions) {
|
|
40
|
-
this.
|
|
40
|
+
this.host = options.host
|
|
41
41
|
this.resolveAuthContext = options.resolveAuthContext
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
isAuthEnabled(): boolean {
|
|
45
|
-
return this.
|
|
45
|
+
return this.host.auth.isEnabled()
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
assertCanServeHttp(params: { readonly production: boolean }): void {
|
|
49
|
-
this.
|
|
49
|
+
this.host.auth.assertCanServeHttp(params)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
async resolve(request: Request): Promise<ServerAuthGuardDecision> {
|
|
@@ -64,7 +64,7 @@ export class ServerAuthGuard {
|
|
|
64
64
|
return { kind: "deny", response: authContext }
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
let session = await this.
|
|
67
|
+
let session = await this.host.auth.getSession(request, {
|
|
68
68
|
audience: authContext.audience,
|
|
69
69
|
credentialSource: "any",
|
|
70
70
|
})
|
|
@@ -86,7 +86,7 @@ export class ServerAuthGuard {
|
|
|
86
86
|
return { kind: "deny", response: jsonAuthRequiredResponse() }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
if (!sessionCanAccessApplication(this.
|
|
89
|
+
if (!sessionCanAccessApplication(this.host, session, authContext.audience)) {
|
|
90
90
|
return {
|
|
91
91
|
kind: "deny",
|
|
92
92
|
response: jsonForbiddenResponse("Application access is not allowed"),
|
|
@@ -113,7 +113,7 @@ export class ServerAuthGuard {
|
|
|
113
113
|
!isSessionTerminationRequest(request) &&
|
|
114
114
|
hasForegroundSessionActivity(request)
|
|
115
115
|
) {
|
|
116
|
-
const activeSession = await this.
|
|
116
|
+
const activeSession = await this.host.auth.getSession(request, {
|
|
117
117
|
audience: authContext.audience,
|
|
118
118
|
credentialSource: "session",
|
|
119
119
|
sessionActivity: "foreground",
|
|
@@ -130,7 +130,7 @@ export class ServerAuthGuard {
|
|
|
130
130
|
}
|
|
131
131
|
return { kind: "deny", response: jsonAuthRequiredResponse() }
|
|
132
132
|
}
|
|
133
|
-
if (!sessionCanAccessApplication(this.
|
|
133
|
+
if (!sessionCanAccessApplication(this.host, activeSession, authContext.audience)) {
|
|
134
134
|
return {
|
|
135
135
|
kind: "deny",
|
|
136
136
|
response: jsonForbiddenResponse("Application access is not allowed"),
|
|
@@ -144,7 +144,7 @@ export class ServerAuthGuard {
|
|
|
144
144
|
|
|
145
145
|
getCsrfCookieName(request: Request): string {
|
|
146
146
|
const audience = this.resolveAuthContext(request).audience
|
|
147
|
-
return this.
|
|
147
|
+
return this.host.auth.getCookieOptions({ audience }).csrfCookieName
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
verifyCsrf(request: Request, _session: AuthenticatedRequestAuthSession): boolean {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AGENT_API_GATEWAY_PREFIX } from "@sixb/core/internal/agents"
|
|
2
2
|
import { isCsrfExemptMethod } from "@sixb/core/internal/auth"
|
|
3
3
|
|
|
4
|
+
const CONNECTOR_OAUTH_CALLBACK_PATH = "/auth/connectors/callback"
|
|
5
|
+
|
|
4
6
|
export type RouteAccessKind = "public" | "api" | "html" | "websocket"
|
|
5
7
|
|
|
6
8
|
export interface RouteAccess {
|
|
@@ -83,5 +85,16 @@ export function isPublicRoute(pathname: string, method: string): boolean {
|
|
|
83
85
|
return true
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
// The callback proves one-use OAuth state plus a dedicated HttpOnly browser binding. PKCE then
|
|
89
|
+
// binds the code exchange to the attempt created by the authorized initiating request. Elysia
|
|
90
|
+
// routes both trailing-slash variants; some providers require the slash in the registered URI.
|
|
91
|
+
if (
|
|
92
|
+
(pathname === CONNECTOR_OAUTH_CALLBACK_PATH ||
|
|
93
|
+
pathname === `${CONNECTOR_OAUTH_CALLBACK_PATH}/`) &&
|
|
94
|
+
normalizedMethod === "GET"
|
|
95
|
+
) {
|
|
96
|
+
return true
|
|
97
|
+
}
|
|
98
|
+
|
|
86
99
|
return false
|
|
87
100
|
}
|
package/src/auth/scope.ts
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OntologySource } from "@sixb/core"
|
|
2
|
+
import type { RequestExecutionAuthorization, Sixb } from "@sixb/core/internal/request-execution"
|
|
2
3
|
import type { AgentRunRecord } from "@sixb/core/storage"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Per-request authorization state attached by the server's auth derive.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* requests
|
|
9
|
-
* behavior for surfaces that are not grant-enforced yet.
|
|
10
|
-
*
|
|
11
|
-
* SECURITY — privileged is the silent default. The core runtime treats a
|
|
12
|
-
* missing authorization context as fully privileged (workers, syncs, tests
|
|
13
|
-
* need that). A scoped principal therefore gains no protection unless the route
|
|
14
|
-
* actively routes through `scoped`. Concretely:
|
|
15
|
-
*
|
|
16
|
-
* - A grant-enforced handler MUST use `scoped` (falling back to the raw
|
|
17
|
-
* `sixb` only when `scoped` is null). That now covers writes as well as
|
|
18
|
-
* reads: object, link, and telemetry writes enforce `edit:object` and
|
|
19
|
-
* `append:telemetry`. Using the raw `sixb` on a path an authenticated
|
|
20
|
-
* principal can reach is a silent god-mode bypass — it will not fail to
|
|
21
|
-
* compile or to run.
|
|
22
|
-
* - Surfaces with no grant family yet (auth admin, raw storage) stay
|
|
23
|
-
* authenticated-only by design and use the raw `sixb` deliberately, not by
|
|
24
|
-
* omission. Add such a route consciously, and lock it down when its grant
|
|
25
|
-
* family lands.
|
|
26
|
-
*
|
|
27
|
-
* This implicit default is a known V1 trade-off (kept for runtime ergonomics);
|
|
28
|
-
* if it proves error-prone, make privileged access explicit at this boundary.
|
|
8
|
+
* Protected domain routes require `sixb`. It is present for authenticated and auth-disabled
|
|
9
|
+
* requests, and absent only for public routes that do not execute protected domain operations.
|
|
29
10
|
*/
|
|
30
11
|
export interface RequestAuthState {
|
|
31
|
-
readonly
|
|
32
|
-
readonly scoped: ScopedSixb<readonly OntologySource[]> | null
|
|
12
|
+
readonly sixb: Sixb<readonly OntologySource[]> | null
|
|
33
13
|
/** Present for requests proxied through the run-scoped agent API gateway. */
|
|
34
14
|
readonly agentRun?: AgentRunRecord
|
|
35
15
|
/** Identifies which kind of active agent execution owns a gateway request. */
|
|
@@ -38,16 +18,24 @@ export interface RequestAuthState {
|
|
|
38
18
|
| { readonly kind: "workflow"; readonly nodeRunId: string }
|
|
39
19
|
}
|
|
40
20
|
|
|
41
|
-
|
|
21
|
+
export interface InternalRequestAuthState {
|
|
22
|
+
readonly authorization: RequestExecutionAuthorization
|
|
23
|
+
readonly agentRun?: AgentRunRecord
|
|
24
|
+
readonly agentExecution?: RequestAuthState["agentExecution"]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const internalRequestAuthState = new WeakMap<Request, InternalRequestAuthState>()
|
|
42
28
|
|
|
43
29
|
export function registerInternalRequestAuthState(
|
|
44
30
|
request: Request,
|
|
45
|
-
authState:
|
|
31
|
+
authState: InternalRequestAuthState
|
|
46
32
|
): void {
|
|
47
33
|
internalRequestAuthState.set(request, authState)
|
|
48
34
|
}
|
|
49
35
|
|
|
50
|
-
export function consumeInternalRequestAuthState(
|
|
36
|
+
export function consumeInternalRequestAuthState(
|
|
37
|
+
request: Request
|
|
38
|
+
): InternalRequestAuthState | undefined {
|
|
51
39
|
const authState = internalRequestAuthState.get(request)
|
|
52
40
|
if (authState) {
|
|
53
41
|
internalRequestAuthState.delete(request)
|
|
@@ -63,16 +51,18 @@ export function consumeInternalRequestAuthState(request: Request): RequestAuthSt
|
|
|
63
51
|
* point until route registration carries the derived context type.
|
|
64
52
|
*/
|
|
65
53
|
export function requestAuthState(context: unknown): RequestAuthState {
|
|
66
|
-
const {
|
|
67
|
-
authz = null,
|
|
68
|
-
scoped = null,
|
|
69
|
-
agentRun,
|
|
70
|
-
agentExecution,
|
|
71
|
-
} = context as Partial<RequestAuthState>
|
|
54
|
+
const { sixb = null, agentRun, agentExecution } = context as Partial<RequestAuthState>
|
|
72
55
|
return {
|
|
73
|
-
|
|
74
|
-
scoped,
|
|
56
|
+
sixb,
|
|
75
57
|
...(agentRun === undefined ? {} : { agentRun }),
|
|
76
58
|
...(agentExecution === undefined ? {} : { agentExecution }),
|
|
77
59
|
}
|
|
78
60
|
}
|
|
61
|
+
|
|
62
|
+
export function requireRequestSixb(context: unknown): Sixb<readonly OntologySource[]> {
|
|
63
|
+
const sixb = requestAuthState(context).sixb
|
|
64
|
+
if (!sixb) {
|
|
65
|
+
throw new Error("[SixbServer] Execution scope is not available for this route.")
|
|
66
|
+
}
|
|
67
|
+
return sixb
|
|
68
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SixbHostView } from "@sixb/core"
|
|
2
2
|
import {
|
|
3
3
|
type AuthenticatedAuthSession,
|
|
4
4
|
createCsrfCookieHeader,
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
} from "@sixb/core/internal/auth"
|
|
9
9
|
|
|
10
10
|
export function createSessionRenewalCookieHeaders(input: {
|
|
11
|
-
readonly
|
|
11
|
+
readonly host: SixbHostView
|
|
12
12
|
readonly request: Request
|
|
13
13
|
readonly session: AuthenticatedAuthSession
|
|
14
14
|
readonly csrfToken?: string
|
|
15
15
|
}): { readonly csrfToken: string; readonly headers: readonly [string, string] } | null {
|
|
16
|
-
const cookieOptions = input.
|
|
16
|
+
const cookieOptions = input.host.auth.getCookieOptions({
|
|
17
17
|
audience: input.session.session.audience,
|
|
18
18
|
})
|
|
19
19
|
const sessionValue = getCookie(input.request, cookieOptions.sessionCookieName)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { SixbHostView } from "@sixb/core"
|
|
2
|
+
import type {
|
|
3
|
+
ConnectorConnectionRunView,
|
|
4
|
+
ConnectorConnectionsRuntime,
|
|
5
|
+
ConnectorConnectionView,
|
|
6
|
+
} from "@sixb/core/internal/connector-connections"
|
|
7
|
+
import {
|
|
8
|
+
getConnectorConnectionsRuntime,
|
|
9
|
+
isOAuthConnectorDefinition,
|
|
10
|
+
} from "@sixb/core/internal/connector-connections"
|
|
11
|
+
import { createSixbError } from "@sixb/core/internal/errors"
|
|
12
|
+
import type { z } from "zod"
|
|
13
|
+
import {
|
|
14
|
+
CONNECTOR_HTTP_ERROR_CODES,
|
|
15
|
+
type ConnectorConnectionRunSchema,
|
|
16
|
+
type ConnectorConnectionSchema,
|
|
17
|
+
type ConnectorHttpErrorCode,
|
|
18
|
+
} from "../schemas/connectors"
|
|
19
|
+
import { handleRouteError, toIsoString } from "../utils/http"
|
|
20
|
+
|
|
21
|
+
export function connectorRouteRuntime(
|
|
22
|
+
host: SixbHostView,
|
|
23
|
+
owner: object,
|
|
24
|
+
connectorId: string
|
|
25
|
+
): ConnectorConnectionsRuntime {
|
|
26
|
+
const definition = host.definitions.connectors.getById(connectorId)
|
|
27
|
+
if (!definition) {
|
|
28
|
+
throw createSixbError("connector.not_found", "[Sixb] Connector was not found.")
|
|
29
|
+
}
|
|
30
|
+
if (!isOAuthConnectorDefinition(definition)) {
|
|
31
|
+
throw createSixbError(
|
|
32
|
+
"connector.configuration_invalid",
|
|
33
|
+
`[Sixb] Connector '${connectorId}' does not use OAuth authentication.`
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
return getConnectorConnectionsRuntime(owner)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function serializeConnectorConnection(
|
|
40
|
+
connection: ConnectorConnectionView
|
|
41
|
+
): z.infer<typeof ConnectorConnectionSchema> {
|
|
42
|
+
return {
|
|
43
|
+
id: connection.id,
|
|
44
|
+
connectorId: connection.connectorId,
|
|
45
|
+
owner: connection.owner,
|
|
46
|
+
slot: connection.slot,
|
|
47
|
+
account: connection.account,
|
|
48
|
+
status: connection.status,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function serializeConnectorConnectionRun(
|
|
53
|
+
run: ConnectorConnectionRunView
|
|
54
|
+
): z.infer<typeof ConnectorConnectionRunSchema> {
|
|
55
|
+
const base = {
|
|
56
|
+
id: run.id,
|
|
57
|
+
connectorId: run.connectorId,
|
|
58
|
+
kind: run.kind,
|
|
59
|
+
owner: run.owner,
|
|
60
|
+
slot: run.slot,
|
|
61
|
+
createdAt: toIsoString(run.createdAt),
|
|
62
|
+
updatedAt: toIsoString(run.updatedAt),
|
|
63
|
+
}
|
|
64
|
+
if (run.status === "running") return { ...base, status: "running" }
|
|
65
|
+
if (run.status === "waiting" && run.waitingFor === "provider_authorization") {
|
|
66
|
+
return {
|
|
67
|
+
...base,
|
|
68
|
+
status: "waiting",
|
|
69
|
+
waitingFor: "provider_authorization",
|
|
70
|
+
expiresAt: toIsoString(run.expiresAt),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (run.status === "waiting") {
|
|
74
|
+
return {
|
|
75
|
+
...base,
|
|
76
|
+
status: "waiting",
|
|
77
|
+
waitingFor: "account_selection",
|
|
78
|
+
accounts: [...run.accounts],
|
|
79
|
+
expiresAt: toIsoString(run.expiresAt),
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (run.status === "succeeded") {
|
|
83
|
+
return {
|
|
84
|
+
...base,
|
|
85
|
+
status: "succeeded",
|
|
86
|
+
connections: run.connections.map(serializeConnectorConnection),
|
|
87
|
+
finishedAt: toIsoString(run.finishedAt),
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (run.status === "failed") {
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
status: "failed",
|
|
94
|
+
error: run.error,
|
|
95
|
+
finishedAt: toIsoString(run.finishedAt),
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { ...base, status: run.status, finishedAt: toIsoString(run.finishedAt) }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function handleConnectorRouteError(
|
|
102
|
+
error: unknown,
|
|
103
|
+
set: { status?: number | string }
|
|
104
|
+
): { error: string } | { error: string; code: ConnectorHttpErrorCode } {
|
|
105
|
+
const response = handleRouteError(error, set)
|
|
106
|
+
if (response.code && (CONNECTOR_HTTP_ERROR_CODES as readonly string[]).includes(response.code)) {
|
|
107
|
+
return { error: response.error, code: response.code as ConnectorHttpErrorCode }
|
|
108
|
+
}
|
|
109
|
+
return { error: response.error }
|
|
110
|
+
}
|
package/src/openapi/tags.ts
CHANGED
|
@@ -13,7 +13,15 @@ export const OPENAPI_TAGS = {
|
|
|
13
13
|
},
|
|
14
14
|
connectors: {
|
|
15
15
|
name: "Connectors",
|
|
16
|
-
description: "Connector metadata
|
|
16
|
+
description: "Connector metadata",
|
|
17
|
+
},
|
|
18
|
+
connectorConnections: {
|
|
19
|
+
name: "Connector Connections",
|
|
20
|
+
description: "Connected external accounts",
|
|
21
|
+
},
|
|
22
|
+
connectorConnectionRuns: {
|
|
23
|
+
name: "Connector Connection Runs",
|
|
24
|
+
description: "Interactive OAuth connection runs",
|
|
17
25
|
},
|
|
18
26
|
webhooks: {
|
|
19
27
|
name: "Webhooks",
|