@sixb/server 0.1.9 → 0.1.11
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 +19 -0
- package/dist/auth/browser-origin.d.ts.map +1 -1
- package/dist/connectors/http.d.ts.map +1 -1
- package/dist/index.js +97 -30
- package/dist/index.js.map +13 -13
- package/dist/models/display.d.ts +2 -2
- package/dist/models/display.d.ts.map +1 -1
- package/dist/routes/action-runs.d.ts +2 -0
- package/dist/routes/action-runs.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +2 -0
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +2 -2
- package/dist/routes/connector-connection-runs.d.ts +138 -4
- package/dist/routes/connector-connection-runs.d.ts.map +1 -1
- package/dist/routes/files.d.ts +3 -1
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/objects.d.ts +2 -0
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +24 -0
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +4 -0
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +6 -6
- package/dist/schemas/connectors.d.ts +0 -3
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/files.d.ts +17 -8
- package/dist/schemas/files.d.ts.map +1 -1
- package/dist/schemas/objects.d.ts +5 -1
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/projections.d.ts +243 -0
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/auth/browser-origin.ts +50 -1
- package/src/connectors/http.ts +0 -1
- package/src/models/display.ts +3 -2
- package/src/routes/connector-connection-runs.ts +48 -3
- package/src/routes/files.ts +2 -1
- package/src/routes/webhooks.ts +15 -3
- package/src/schemas/connectors.ts +0 -1
- package/src/schemas/files.ts +8 -1
- package/src/schemas/objects.ts +12 -6
- package/src/schemas/projections.ts +1 -0
- package/src/server.ts +2 -0
package/README.md
CHANGED
|
@@ -37,8 +37,27 @@ Each configured audience identifies the browser application for exactly one orig
|
|
|
37
37
|
origins are shown as invitation destinations and participate in `can.access(applications.atlas)` or
|
|
38
38
|
`can.access(applications.app)` authorization.
|
|
39
39
|
|
|
40
|
+
File-content `GET`/`HEAD` routes accept `?audience=app` or `?audience=atlas` for
|
|
41
|
+
browser navigations that omit `Origin`. Use `objectFileContentUrl({ ..., audience: "app" })`
|
|
42
|
+
in a separate app. The audience must be configured in `allowedOrigins` or be the
|
|
43
|
+
`apiOriginAudience`; an explicit `Origin` must match it. The server authenticates only
|
|
44
|
+
the selected audience and still checks application and resource access. Omitting the
|
|
45
|
+
selector preserves the API audience default (`atlas`). This selector applies only to
|
|
46
|
+
file-content reads, including object, action/workflow run, and agent message files.
|
|
47
|
+
It does not change authentication for other routes. API cookies must reach the request;
|
|
48
|
+
with Sixb's `SameSite=Strict` cookies, use same-site app/API origins for embedding.
|
|
49
|
+
|
|
40
50
|
## API Routes
|
|
41
51
|
|
|
52
|
+
### Connector OAuth callbacks
|
|
53
|
+
|
|
54
|
+
`GET /auth/connectors/callback` disables Bun's socket idle timeout while preserving provider-operation
|
|
55
|
+
deadlines. Reverse proxies must also allow enough time for provider processing.
|
|
56
|
+
|
|
57
|
+
Organization selection has no time limit. The initiating user can resume pending runs through
|
|
58
|
+
`GET /api/connectors/:connectorId/connection-runs`, with current connector-management permission.
|
|
59
|
+
See [OAuth connection flows](../../docs/connectors/authentication.md#connect-an-oauth-account-from-an-app).
|
|
60
|
+
|
|
42
61
|
### REST Endpoints
|
|
43
62
|
|
|
44
63
|
| Method | Path | Description |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-origin.d.ts","sourceRoot":"","sources":["../../src/auth/browser-origin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAKzB,MAAM,YAAY,CA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ClD,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,iBAAiB,GACvB,mBAAmB,CASrB;AAED,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,4BAA4B,GACnC,gCAAgC,CAelC;AAED,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,2BAA2B,GACjC,6BAA6B,CAqB/B;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,OAAO,GACf,MAAM,CAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/connectors/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,2CAA2C,CAAA;AAMlD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAA;AAG9B,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,2BAA2B,CAY7B;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,uBAAuB,GAClC,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAS3C;AAED,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,0BAA0B,GAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/connectors/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,2CAA2C,CAAA;AAMlD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAA;AAG9B,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,2BAA2B,CAY7B;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,uBAAuB,GAClC,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAS3C;AAED,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,0BAA0B,GAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CA4C9C;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAChC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAMrE"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
isValidAuthSessionAudience,
|
|
16
16
|
resolveAuthSessionAudience
|
|
17
17
|
} from "@sixb/core";
|
|
18
|
+
import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
|
|
19
|
+
var fileNavigationRoutes = SIXB_API_ROUTES.filter((route) => (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content"));
|
|
18
20
|
|
|
19
21
|
class BrowserOriginError extends Error {
|
|
20
22
|
name = "BrowserOriginError";
|
|
@@ -57,11 +59,13 @@ function createApiBrowserAuthRedirectContextResolver(policy) {
|
|
|
57
59
|
}
|
|
58
60
|
function resolveApiBrowserAuthContext(policy, request) {
|
|
59
61
|
const origin = normalizeRequestOrigin(request);
|
|
62
|
+
const fileAudience = resolveFileNavigationAudience(policy, request);
|
|
60
63
|
if (!origin) {
|
|
61
|
-
return { audience: policy.apiOriginAudience, absoluteReturnTo: true };
|
|
64
|
+
return { audience: fileAudience ?? policy.apiOriginAudience, absoluteReturnTo: true };
|
|
62
65
|
}
|
|
63
66
|
const allowed = findAllowedBrowserOrigin(policy, origin);
|
|
64
67
|
if (allowed) {
|
|
68
|
+
assertFileAudienceMatchesOrigin(fileAudience, allowed.audience);
|
|
65
69
|
return {
|
|
66
70
|
audience: allowed.audience,
|
|
67
71
|
browserOrigin: allowed.origin,
|
|
@@ -69,10 +73,30 @@ function resolveApiBrowserAuthContext(policy, request) {
|
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
if (isSameOriginApiRequest(policy, origin, request)) {
|
|
76
|
+
assertFileAudienceMatchesOrigin(fileAudience, policy.apiOriginAudience);
|
|
72
77
|
return { audience: policy.apiOriginAudience, browserOrigin: origin, absoluteReturnTo: true };
|
|
73
78
|
}
|
|
74
79
|
throw new BrowserOriginError(`[SixbServer] Browser origin '${origin}' is not allowed.`);
|
|
75
80
|
}
|
|
81
|
+
function resolveFileNavigationAudience(policy, request) {
|
|
82
|
+
const url = new URL(request.url);
|
|
83
|
+
if (!fileNavigationRoutes.some((route) => route.method === request.method && matchesPathPattern(normalizeRoutePath(url.pathname), route.path))) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const values = url.searchParams.getAll("audience");
|
|
87
|
+
if (values.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const audience = values[0];
|
|
90
|
+
if (values.length !== 1 || !audience || !isValidAuthSessionAudience(audience) || audience !== policy.apiOriginAudience && !policy.allowedOrigins.some((entry) => entry.audience === audience)) {
|
|
91
|
+
throw new BrowserOriginError("[SixbServer] File navigation audience is not allowed.");
|
|
92
|
+
}
|
|
93
|
+
return audience;
|
|
94
|
+
}
|
|
95
|
+
function assertFileAudienceMatchesOrigin(audience, originAudience) {
|
|
96
|
+
if (audience !== undefined && audience !== originAudience) {
|
|
97
|
+
throw new BrowserOriginError("[SixbServer] File navigation audience conflicts with Origin.");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
76
100
|
function isAllowedApiBrowserOrigin(policy, request) {
|
|
77
101
|
const origin = normalizeRequestOrigin(request);
|
|
78
102
|
if (!origin) {
|
|
@@ -214,7 +238,7 @@ import {
|
|
|
214
238
|
|
|
215
239
|
// src/auth/access-token-boundary.ts
|
|
216
240
|
import { isCsrfExemptMethod as isCsrfExemptMethod2 } from "@sixb/core/internal/auth";
|
|
217
|
-
import { matchesPathPattern as
|
|
241
|
+
import { matchesPathPattern as matchesPathPattern3, normalizeRoutePath as normalizeRoutePath3, SIXB_API_ROUTES as SIXB_API_ROUTES3 } from "@sixb/core/internal/http";
|
|
218
242
|
|
|
219
243
|
// src/openapi/security.ts
|
|
220
244
|
import { CSRF_HEADER_NAME as CSRF_HEADER_NAME2 } from "@sixb/core/internal/auth";
|
|
@@ -228,7 +252,7 @@ import {
|
|
|
228
252
|
isCsrfExemptMethod,
|
|
229
253
|
verifyDoubleSubmitCsrf
|
|
230
254
|
} from "@sixb/core/internal/auth";
|
|
231
|
-
import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
|
|
255
|
+
import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
|
|
232
256
|
import { SharedSessionProtocol } from "@sixb/core/internal/shares";
|
|
233
257
|
|
|
234
258
|
// src/auth/session-activity.ts
|
|
@@ -251,7 +275,7 @@ var SHARED_SESSION_COOKIE_PREFIX = "sixb_share_session_";
|
|
|
251
275
|
var SHARED_CSRF_COOKIE_PREFIX = "sixb_share_csrf_";
|
|
252
276
|
var SHARED_COOKIE_PATH = "/api";
|
|
253
277
|
var STORED_IDENTIFIER_MAX_LENGTH = 128;
|
|
254
|
-
var SHARED_SESSION_ROUTES =
|
|
278
|
+
var SHARED_SESSION_ROUTES = SIXB_API_ROUTES2.filter((route) => route.sharedSession);
|
|
255
279
|
|
|
256
280
|
class SharedAccessBoundary {
|
|
257
281
|
host;
|
|
@@ -436,16 +460,16 @@ function isSharedAccessPublicRoute(request) {
|
|
|
436
460
|
}
|
|
437
461
|
function isSharedAccessPublicPath(pathname, requestMethod) {
|
|
438
462
|
const method = requestMethod.toUpperCase();
|
|
439
|
-
const normalizedPathname =
|
|
463
|
+
const normalizedPathname = normalizeRoutePath2(pathname);
|
|
440
464
|
const suffix = method === "POST" && normalizedPathname.endsWith("/exchange") ? "exchange" : method === "GET" && normalizedPathname.endsWith("/session") ? "session" : method === "POST" && normalizedPathname.endsWith("/sign-out") ? "sign-out" : null;
|
|
441
465
|
if (!suffix)
|
|
442
466
|
return false;
|
|
443
|
-
return
|
|
467
|
+
return matchesPathPattern2(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
|
|
444
468
|
}
|
|
445
469
|
function isSharedSessionRoute(request) {
|
|
446
470
|
const method = request.method.toUpperCase();
|
|
447
|
-
const pathname =
|
|
448
|
-
return SHARED_SESSION_ROUTES.some((route) => route.method === method &&
|
|
471
|
+
const pathname = normalizeRoutePath2(new URL(request.url).pathname);
|
|
472
|
+
return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
|
|
449
473
|
}
|
|
450
474
|
function sharedAccessUnauthenticatedResponse() {
|
|
451
475
|
return sharedBoundaryJsonResponse({ error: "Shared access session is invalid" }, 401);
|
|
@@ -552,7 +576,7 @@ var SIXB_SHARED_GRANT_SECURITY_SCHEME = {
|
|
|
552
576
|
};
|
|
553
577
|
|
|
554
578
|
// src/auth/access-token-boundary.ts
|
|
555
|
-
var ACCESS_TOKEN_ROUTES =
|
|
579
|
+
var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES3.filter((route) => route.accessToken).map((route) => ({
|
|
556
580
|
operationId: route.operationId,
|
|
557
581
|
method: route.method,
|
|
558
582
|
path: route.path,
|
|
@@ -574,8 +598,8 @@ function bearerSecurityRequirement(operationId) {
|
|
|
574
598
|
function isAccessTokenRoute(request) {
|
|
575
599
|
const url = new URL(request.url);
|
|
576
600
|
const method = request.method.toUpperCase();
|
|
577
|
-
const pathname =
|
|
578
|
-
return ACCESS_TOKEN_ROUTES.some((route) => route.method === method &&
|
|
601
|
+
const pathname = normalizeRoutePath3(url.pathname);
|
|
602
|
+
return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern3(pathname, route.path));
|
|
579
603
|
}
|
|
580
604
|
function shouldVerifyCsrfForAuthSource(route, source) {
|
|
581
605
|
return route.csrfProtected && source === "session";
|
|
@@ -1683,6 +1707,7 @@ var DirectPutFileUploadSchema = z4.object({
|
|
|
1683
1707
|
});
|
|
1684
1708
|
var MultipartFileUploadSchema = z4.object({
|
|
1685
1709
|
strategy: z4.literal("multipart"),
|
|
1710
|
+
partReceipt: z4.enum(["etag", "none"]),
|
|
1686
1711
|
uploadId: z4.string(),
|
|
1687
1712
|
partSizeBytes: z4.number().int().positive(),
|
|
1688
1713
|
expiresAt: z4.string()
|
|
@@ -1701,7 +1726,7 @@ var SignedFileUploadPartSchema = z4.object({
|
|
|
1701
1726
|
});
|
|
1702
1727
|
var FileUploadPartSchema = z4.object({
|
|
1703
1728
|
partNumber: z4.number().int().positive(),
|
|
1704
|
-
etag: z4.string()
|
|
1729
|
+
etag: z4.string().min(1).optional()
|
|
1705
1730
|
});
|
|
1706
1731
|
var CompleteFileUploadBodySchema = z4.object({
|
|
1707
1732
|
sizeBytes: z4.number().int().nonnegative().optional(),
|
|
@@ -1709,6 +1734,7 @@ var CompleteFileUploadBodySchema = z4.object({
|
|
|
1709
1734
|
parts: z4.array(FileUploadPartSchema).optional()
|
|
1710
1735
|
});
|
|
1711
1736
|
var FileContentQuerySchema = z4.object({
|
|
1737
|
+
audience: z4.enum(["atlas", "app"]).optional().describe("Session audience for file navigation without Origin; must match Origin when present"),
|
|
1712
1738
|
path: z4.string().min(1),
|
|
1713
1739
|
disposition: z4.enum(["inline", "attachment"]).optional(),
|
|
1714
1740
|
v: z4.string().optional().describe("Client cache key; the route still resolves the current file")
|
|
@@ -2141,7 +2167,7 @@ import {
|
|
|
2141
2167
|
resolveAgentExecutionAuthorization,
|
|
2142
2168
|
resolveInheritedAgentExecutionAuthorization
|
|
2143
2169
|
} from "@sixb/core/internal/agents";
|
|
2144
|
-
import { normalizeRoutePath as
|
|
2170
|
+
import { normalizeRoutePath as normalizeRoutePath4, pathSegmentsFor } from "@sixb/core/internal/http";
|
|
2145
2171
|
|
|
2146
2172
|
// src/routes/files.ts
|
|
2147
2173
|
import {
|
|
@@ -2497,6 +2523,7 @@ function fileUploadResponse(session) {
|
|
|
2497
2523
|
strategy: "multipart",
|
|
2498
2524
|
uploadId: session.id,
|
|
2499
2525
|
partSizeBytes: session.providerUpload.partSizeBytes,
|
|
2526
|
+
partReceipt: session.providerUpload.partReceipt ?? "etag",
|
|
2500
2527
|
expiresAt: session.providerUpload.expiresAt.toISOString()
|
|
2501
2528
|
};
|
|
2502
2529
|
}
|
|
@@ -2815,7 +2842,7 @@ function gatewayUpstreamPath(pathname) {
|
|
|
2815
2842
|
const prefixLength = pathSegmentsFor(AGENT_API_GATEWAY_PREFIX2).length;
|
|
2816
2843
|
const segments = pathSegmentsFor(pathname);
|
|
2817
2844
|
const upstreamSegments = segments.slice(prefixLength + 2);
|
|
2818
|
-
return
|
|
2845
|
+
return normalizeRoutePath4(`/${upstreamSegments.join("/")}`);
|
|
2819
2846
|
}
|
|
2820
2847
|
function forwardedRequestHeaders(source) {
|
|
2821
2848
|
const headers = new Headers;
|
|
@@ -2860,7 +2887,7 @@ async function readRequestBody(request, maxBytes) {
|
|
|
2860
2887
|
return concatChunks(chunks, total);
|
|
2861
2888
|
}
|
|
2862
2889
|
function isSimpleFileUpload(method, pathname) {
|
|
2863
|
-
return method === "POST" &&
|
|
2890
|
+
return method === "POST" && normalizeRoutePath4(pathname) === "/api/files";
|
|
2864
2891
|
}
|
|
2865
2892
|
function matchesWorkflowRunStart(pathname) {
|
|
2866
2893
|
const segments = pathSegmentsFor(pathname);
|
|
@@ -4728,8 +4755,7 @@ var ConnectorConnectionRunSchema = z12.union([
|
|
|
4728
4755
|
ConnectorConnectionRunBaseSchema.extend({
|
|
4729
4756
|
status: z12.literal("waiting"),
|
|
4730
4757
|
waitingFor: z12.literal("account_selection"),
|
|
4731
|
-
accounts: z12.array(ConnectorAccountSchema)
|
|
4732
|
-
expiresAt: z12.string().datetime()
|
|
4758
|
+
accounts: z12.array(ConnectorAccountSchema)
|
|
4733
4759
|
}),
|
|
4734
4760
|
ConnectorConnectionRunBaseSchema.extend({
|
|
4735
4761
|
status: z12.literal("succeeded"),
|
|
@@ -4827,8 +4853,7 @@ function serializeConnectorConnectionRun(run) {
|
|
|
4827
4853
|
...base,
|
|
4828
4854
|
status: "waiting",
|
|
4829
4855
|
waitingFor: "account_selection",
|
|
4830
|
-
accounts: [...run.accounts]
|
|
4831
|
-
expiresAt: toIsoString(run.expiresAt)
|
|
4856
|
+
accounts: [...run.accounts]
|
|
4832
4857
|
};
|
|
4833
4858
|
}
|
|
4834
4859
|
if (run.status === "succeeded") {
|
|
@@ -4859,7 +4884,29 @@ function handleConnectorRouteError(error, set) {
|
|
|
4859
4884
|
|
|
4860
4885
|
// src/routes/connector-connection-runs.ts
|
|
4861
4886
|
function registerConnectorConnectionRunRoutes(app, host, options) {
|
|
4862
|
-
return app.
|
|
4887
|
+
return app.get("/api/connectors/:connectorId/connection-runs", async (context) => {
|
|
4888
|
+
const { params, set } = context;
|
|
4889
|
+
try {
|
|
4890
|
+
const runtime = connectorRouteRuntime(host, requireRequestSixb(context), params.connectorId);
|
|
4891
|
+
return (await runtime.listPendingConnectionRuns(params.connectorId)).map(serializeConnectorConnectionRun);
|
|
4892
|
+
} catch (error) {
|
|
4893
|
+
return handleConnectorRouteError(error, set);
|
|
4894
|
+
}
|
|
4895
|
+
}, {
|
|
4896
|
+
params: ConnectorConnectionParamsSchema.pick({ connectorId: true }),
|
|
4897
|
+
response: {
|
|
4898
|
+
200: ConnectorConnectionRunSchema.array(),
|
|
4899
|
+
400: ConnectorBadRequestResponseSchema,
|
|
4900
|
+
403: ErrorResponseSchema,
|
|
4901
|
+
404: ConnectorNotFoundResponseSchema,
|
|
4902
|
+
500: ConnectorInternalErrorResponseSchema
|
|
4903
|
+
},
|
|
4904
|
+
detail: {
|
|
4905
|
+
summary: "List the initiating user's pending connector connection runs",
|
|
4906
|
+
tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
|
|
4907
|
+
operationId: "listPendingConnectorConnectionRuns"
|
|
4908
|
+
}
|
|
4909
|
+
}).post("/api/connectors/:connectorId/connection-runs", async (context) => {
|
|
4863
4910
|
const { params, body, request, set } = context;
|
|
4864
4911
|
try {
|
|
4865
4912
|
const runtime = connectorRouteRuntime(host, requireRequestSixb(context), params.connectorId);
|
|
@@ -5037,16 +5084,22 @@ function registerConnectorConnectionRunRoutes(app, host, options) {
|
|
|
5037
5084
|
operationId: "reauthorizeConnectorConnection",
|
|
5038
5085
|
security: SIXB_CSRF_SECURITY_REQUIREMENT
|
|
5039
5086
|
}
|
|
5040
|
-
}).get("/auth/connectors/callback", async ({
|
|
5087
|
+
}).get("/auth/connectors/callback", async ({ request, set, server }) => {
|
|
5088
|
+
server?.timeout(request, 0);
|
|
5041
5089
|
let callbackCookie;
|
|
5042
5090
|
try {
|
|
5043
|
-
const
|
|
5091
|
+
const parameters = new URL(request.url).searchParams;
|
|
5092
|
+
const callbackParameters = Object.fromEntries([...new Set(parameters.keys())].map((name) => {
|
|
5093
|
+
const values = parameters.getAll(name);
|
|
5094
|
+
return [name, values.length === 1 ? values[0] : values];
|
|
5095
|
+
}));
|
|
5096
|
+
const parsed = ConnectorOAuthCallbackQuerySchema.parse(callbackParameters);
|
|
5044
5097
|
callbackCookie = readConnectorCallbackCookie(request, parsed.state);
|
|
5045
5098
|
const result = await getConnectorConnectionCallbackProcess(host).completeConnectionRun({
|
|
5046
5099
|
state: parsed.state,
|
|
5047
5100
|
redirectUri: options.resolveCallbackUrl(request),
|
|
5048
5101
|
callbackBinding: callbackCookie.value ?? "",
|
|
5049
|
-
...parsed.code === undefined ? { error: parsed.error } : { code: parsed.code }
|
|
5102
|
+
...parsed.code === undefined ? { error: parsed.error } : { code: parsed.code, callbackParameters }
|
|
5050
5103
|
});
|
|
5051
5104
|
return connectorCallbackRedirect(result.returnTo, result.connectorId, result.runId, clearConnectorCallbackCookie(request, callbackCookie.name));
|
|
5052
5105
|
} catch (error) {
|
|
@@ -6014,6 +6067,7 @@ async function languageModelDisplay(entry) {
|
|
|
6014
6067
|
}
|
|
6015
6068
|
const gateway = entry.provider === "vercel-ai-gateway";
|
|
6016
6069
|
const publisherId = gateway ? entry.modelId.split("/")[0] : entry.provider;
|
|
6070
|
+
const via = definition.via ?? (gateway ? "AI Gateway" : undefined);
|
|
6017
6071
|
const capabilities = definition.capabilities;
|
|
6018
6072
|
const media = capabilities.inputMediaTypes;
|
|
6019
6073
|
const input = ["text"];
|
|
@@ -6029,8 +6083,8 @@ async function languageModelDisplay(entry) {
|
|
|
6029
6083
|
return {
|
|
6030
6084
|
name: definition.name ?? entry.modelId,
|
|
6031
6085
|
...definition.description === undefined ? {} : { description: definition.description },
|
|
6032
|
-
publisher: { id: publisherId, name: publisherName(publisherId) },
|
|
6033
|
-
...
|
|
6086
|
+
publisher: definition.publisher ?? { id: publisherId, name: publisherName(publisherId) },
|
|
6087
|
+
...via === undefined ? {} : { via },
|
|
6034
6088
|
capabilities: {
|
|
6035
6089
|
input,
|
|
6036
6090
|
output: ["text"],
|
|
@@ -6337,7 +6391,10 @@ var ObjectListResponseSchema = z18.object({
|
|
|
6337
6391
|
total: z18.number()
|
|
6338
6392
|
});
|
|
6339
6393
|
var anyJsonValueSchema = {};
|
|
6340
|
-
var stringArraySchema = {
|
|
6394
|
+
var stringArraySchema = {
|
|
6395
|
+
type: "array",
|
|
6396
|
+
items: { type: "string", minLength: 1 }
|
|
6397
|
+
};
|
|
6341
6398
|
var objectQueryRef = { $ref: "#/components/schemas/ObjectQuery" };
|
|
6342
6399
|
var objectQueryPredicateRef = { $ref: "#/components/schemas/ObjectQueryPredicate" };
|
|
6343
6400
|
var objectQuerySortFieldRef = { $ref: "#/components/schemas/ObjectQuerySortField" };
|
|
@@ -7952,7 +8009,8 @@ var ProjectionRunBaseSchema = z22.object({
|
|
|
7952
8009
|
attempt: z22.number(),
|
|
7953
8010
|
progress: z22.object({
|
|
7954
8011
|
sourceRowsRead: z22.number(),
|
|
7955
|
-
sourceRowsSkipped: z22.number()
|
|
8012
|
+
sourceRowsSkipped: z22.number(),
|
|
8013
|
+
sourceChangesRead: z22.number().optional()
|
|
7956
8014
|
}),
|
|
7957
8015
|
queuedAt: z22.string(),
|
|
7958
8016
|
startedAt: z22.string().optional(),
|
|
@@ -12975,7 +13033,11 @@ import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
|
12975
13033
|
import { reportRunFailure } from "@sixb/core/internal/error-reporting";
|
|
12976
13034
|
import { captureSixbFailure, createSixbError as createSixbError5, toSixbFailure as toSixbFailure2 } from "@sixb/core/internal/errors";
|
|
12977
13035
|
import { bindDurablePrimitiveExecution } from "@sixb/core/internal/primitive-execution";
|
|
12978
|
-
import {
|
|
13036
|
+
import {
|
|
13037
|
+
admitWebhookRun,
|
|
13038
|
+
createWebhookConnections,
|
|
13039
|
+
isStaticConnectorDefinition
|
|
13040
|
+
} from "@sixb/core/internal/webhooks";
|
|
12979
13041
|
import { WEBHOOK_RUN_FAILURE_CODES as WEBHOOK_RUN_FAILURE_CODES2, WebhookRunError } from "@sixb/core/storage";
|
|
12980
13042
|
var DEFAULT_WEBHOOK_BODY_LIMIT_BYTES = 1024 * 1024;
|
|
12981
13043
|
function registerWebhookRoutes(app, host) {
|
|
@@ -13111,7 +13173,8 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
13111
13173
|
rawBody: prepared.rawBody,
|
|
13112
13174
|
body: prepared.body,
|
|
13113
13175
|
logger,
|
|
13114
|
-
client: createClientResolver(execution.sixb, connector)
|
|
13176
|
+
client: createClientResolver(execution.sixb, connector),
|
|
13177
|
+
connections: createWebhookConnections(execution.sixb.connector, connector)
|
|
13115
13178
|
});
|
|
13116
13179
|
} catch (error) {
|
|
13117
13180
|
const failed = createWebhookRunFailure({
|
|
@@ -13224,6 +13287,9 @@ function parseWebhookBody(webhook, rawBody) {
|
|
|
13224
13287
|
function createClientResolver(sixb, connector) {
|
|
13225
13288
|
let clientPromise = null;
|
|
13226
13289
|
return () => {
|
|
13290
|
+
if (!isStaticConnectorDefinition(connector)) {
|
|
13291
|
+
throw createSixbError5("connector.configuration_invalid", "[SixbServer] OAuth webhook clients require connections.forAccount(accountId), then target.client().");
|
|
13292
|
+
}
|
|
13227
13293
|
clientPromise ??= sixb.connector(connector);
|
|
13228
13294
|
return clientPromise;
|
|
13229
13295
|
};
|
|
@@ -14491,6 +14557,7 @@ function createSixbApi(server) {
|
|
|
14491
14557
|
app.use(openapi({
|
|
14492
14558
|
path: "/docs",
|
|
14493
14559
|
provider: "swagger-ui",
|
|
14560
|
+
openapiVersion: "3.0.3",
|
|
14494
14561
|
documentation: {
|
|
14495
14562
|
info: {
|
|
14496
14563
|
title: "Sixb API",
|
|
@@ -14616,4 +14683,4 @@ export {
|
|
|
14616
14683
|
createSixbServer
|
|
14617
14684
|
};
|
|
14618
14685
|
|
|
14619
|
-
//# debugId=
|
|
14686
|
+
//# debugId=6D4551964DA2E95864756E2164756E21
|