@sixb/server 0.1.7 → 0.1.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/dist/auth/access-token-boundary.d.ts +3 -0
- package/dist/auth/access-token-boundary.d.ts.map +1 -1
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/auth/shared-access.d.ts +66 -0
- package/dist/auth/shared-access.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1419 -627
- package/dist/index.js.map +19 -14
- package/dist/openapi/security.d.ts +15 -1
- package/dist/openapi/security.d.ts.map +1 -1
- package/dist/openapi/tags.d.ts +6 -2
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts +2 -0
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/actions.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +5 -5
- package/dist/routes/auth.d.ts +9 -9
- package/dist/routes/connector-connection-runs.d.ts +8 -8
- package/dist/routes/connector-connections.d.ts +4 -4
- package/dist/routes/datasets.d.ts +5 -3
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +1 -1
- package/dist/routes/pipelines.d.ts +4 -0
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/share-grants.d.ts +264 -0
- package/dist/routes/share-grants.d.ts.map +1 -0
- package/dist/routes/shared-access.d.ts +155 -0
- package/dist/routes/shared-access.d.ts.map +1 -0
- package/dist/routes/syncs.d.ts +2 -0
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +1 -1
- package/dist/schemas/agents.d.ts +22 -30
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +40 -40
- package/dist/schemas/datasets.d.ts +28 -22
- package/dist/schemas/datasets.d.ts.map +1 -1
- package/dist/schemas/logs.d.ts +6 -6
- package/dist/schemas/pipelines.d.ts +36 -0
- package/dist/schemas/pipelines.d.ts.map +1 -1
- package/dist/schemas/share-grants.d.ts +518 -0
- package/dist/schemas/share-grants.d.ts.map +1 -0
- package/dist/schemas/shared-access.d.ts +42 -0
- package/dist/schemas/shared-access.d.ts.map +1 -0
- package/dist/schemas/syncs.d.ts +7 -0
- package/dist/schemas/syncs.d.ts.map +1 -1
- package/dist/schemas/workflows.d.ts +4 -4
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/auth/access-token-boundary.ts +17 -2
- package/src/auth/public-routes.ts +5 -0
- package/src/auth/shared-access.ts +376 -0
- package/src/index.ts +1 -0
- package/src/openapi/security.ts +20 -1
- package/src/openapi/tags.ts +4 -0
- package/src/registerRoutes.ts +6 -0
- package/src/routes/actions.ts +5 -10
- package/src/routes/agent-api-gateway.ts +1 -1
- package/src/routes/share-grants.ts +238 -0
- package/src/routes/shared-access.ts +165 -0
- package/src/schemas/agents.ts +1 -4
- package/src/schemas/datasets.ts +2 -1
- package/src/schemas/share-grants.ts +109 -0
- package/src/schemas/shared-access.ts +31 -0
- package/src/server.ts +91 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// src/server.ts
|
|
3
3
|
import { cors } from "@elysiajs/cors";
|
|
4
4
|
import { openapi } from "@elysiajs/openapi";
|
|
5
|
-
import { CSRF_HEADER_NAME as
|
|
5
|
+
import { CSRF_HEADER_NAME as CSRF_HEADER_NAME3 } from "@sixb/core/internal/auth";
|
|
6
6
|
import { bindRequestExecution } from "@sixb/core/internal/request-execution";
|
|
7
7
|
import { Elysia } from "elysia";
|
|
8
8
|
import { websocket as elysiaWebSocket } from "elysia/ws";
|
|
@@ -209,17 +209,308 @@ var CSRF_TOKEN_RESPONSE_HEADER_NAME = "x-sixb-csrf-token";
|
|
|
209
209
|
|
|
210
210
|
// src/auth/guard.ts
|
|
211
211
|
import {
|
|
212
|
-
verifyDoubleSubmitCsrf
|
|
212
|
+
verifyDoubleSubmitCsrf as verifyDoubleSubmitCsrf2
|
|
213
213
|
} from "@sixb/core/internal/auth";
|
|
214
214
|
|
|
215
215
|
// src/auth/access-token-boundary.ts
|
|
216
|
-
import { isCsrfExemptMethod } from "@sixb/core/internal/auth";
|
|
216
|
+
import { isCsrfExemptMethod as isCsrfExemptMethod2 } from "@sixb/core/internal/auth";
|
|
217
|
+
import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
|
|
218
|
+
|
|
219
|
+
// src/openapi/security.ts
|
|
220
|
+
import { CSRF_HEADER_NAME as CSRF_HEADER_NAME2 } from "@sixb/core/internal/auth";
|
|
221
|
+
|
|
222
|
+
// src/auth/shared-access.ts
|
|
223
|
+
import { createHash } from "crypto";
|
|
224
|
+
import {
|
|
225
|
+
CSRF_HEADER_NAME,
|
|
226
|
+
generateCsrfToken,
|
|
227
|
+
getCookie,
|
|
228
|
+
isCsrfExemptMethod,
|
|
229
|
+
verifyDoubleSubmitCsrf
|
|
230
|
+
} from "@sixb/core/internal/auth";
|
|
217
231
|
import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
|
|
232
|
+
import { SharedSessionProtocol } from "@sixb/core/internal/shares";
|
|
233
|
+
|
|
234
|
+
// src/auth/session-activity.ts
|
|
235
|
+
var SESSION_ACTIVITY_HEADER_NAME = "x-sixb-session-activity";
|
|
236
|
+
var SESSION_ACTIVITY_HEADER_VALUE = "1";
|
|
237
|
+
function hasForegroundSessionActivity(request) {
|
|
238
|
+
return request.headers.get(SESSION_ACTIVITY_HEADER_NAME) === SESSION_ACTIVITY_HEADER_VALUE;
|
|
239
|
+
}
|
|
240
|
+
function isSessionTerminationRequest(request) {
|
|
241
|
+
if (request.method.toUpperCase() !== "POST") {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
const pathname = new URL(request.url).pathname;
|
|
245
|
+
return pathname === "/api/auth/sign-out" || pathname === "/api/auth/sign-out-all" || /^\/api\/auth\/sessions\/[^/]+\/revoke$/.test(pathname);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/auth/shared-access.ts
|
|
249
|
+
var SHARED_ACCESS_GRANT_HEADER_NAME = "x-sixb-share-grant";
|
|
250
|
+
var SHARED_SESSION_COOKIE_PREFIX = "sixb_share_session_";
|
|
251
|
+
var SHARED_CSRF_COOKIE_PREFIX = "sixb_share_csrf_";
|
|
252
|
+
var SHARED_COOKIE_PATH = "/api";
|
|
253
|
+
var STORED_IDENTIFIER_MAX_LENGTH = 128;
|
|
254
|
+
var SHARED_SESSION_ROUTES = SIXB_API_ROUTES.filter((route) => route.sharedSession);
|
|
255
|
+
|
|
256
|
+
class SharedAccessBoundary {
|
|
257
|
+
host;
|
|
258
|
+
options;
|
|
259
|
+
protocol;
|
|
260
|
+
constructor(host, options = {}) {
|
|
261
|
+
this.host = host;
|
|
262
|
+
this.options = options;
|
|
263
|
+
}
|
|
264
|
+
preflightResponse(request) {
|
|
265
|
+
if (isSharedAccessPublicRoute(request))
|
|
266
|
+
return;
|
|
267
|
+
const selectedGrantId = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
|
|
268
|
+
if (selectedGrantId === null)
|
|
269
|
+
return;
|
|
270
|
+
if (request.headers.has("authorization") || !isSharedSessionRoute(request)) {
|
|
271
|
+
return sharedAccessForbiddenResponse();
|
|
272
|
+
}
|
|
273
|
+
if (!isStoredIdentifier(selectedGrantId))
|
|
274
|
+
return sharedAccessUnauthenticatedResponse();
|
|
275
|
+
}
|
|
276
|
+
async resolveRequest(request) {
|
|
277
|
+
if (isSharedAccessPublicRoute(request))
|
|
278
|
+
return { kind: "absent" };
|
|
279
|
+
const selectedGrantId = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
|
|
280
|
+
if (selectedGrantId === null)
|
|
281
|
+
return { kind: "absent" };
|
|
282
|
+
const preflight = this.preflightResponse(request);
|
|
283
|
+
if (preflight)
|
|
284
|
+
return { kind: "deny", response: preflight };
|
|
285
|
+
let resolved;
|
|
286
|
+
try {
|
|
287
|
+
resolved = await this.resolveSession(request, selectedGrantId);
|
|
288
|
+
} catch {
|
|
289
|
+
return { kind: "deny", response: sharedAccessUnavailableResponse() };
|
|
290
|
+
}
|
|
291
|
+
if (!resolved) {
|
|
292
|
+
return { kind: "deny", response: sharedAccessUnauthenticatedResponse() };
|
|
293
|
+
}
|
|
294
|
+
if (!isCsrfExemptMethod(request.method) && !verifyDoubleSubmitCsrf(request, {
|
|
295
|
+
cookieName: sharedCookieNames(selectedGrantId).csrf,
|
|
296
|
+
headerName: CSRF_HEADER_NAME
|
|
297
|
+
})) {
|
|
298
|
+
return { kind: "deny", response: sharedAccessForbiddenResponse() };
|
|
299
|
+
}
|
|
300
|
+
return { kind: "allow", ...resolved };
|
|
301
|
+
}
|
|
302
|
+
async exchange(request, grantId, secret) {
|
|
303
|
+
if (!isStoredIdentifier(grantId))
|
|
304
|
+
return null;
|
|
305
|
+
const protocol = this.getProtocol();
|
|
306
|
+
const credential = await protocol.exchange(grantId, secret);
|
|
307
|
+
if (!credential)
|
|
308
|
+
return null;
|
|
309
|
+
const csrfToken = generateCsrfToken();
|
|
310
|
+
return {
|
|
311
|
+
context: credential.context,
|
|
312
|
+
cookies: this.createCookieHeaders({
|
|
313
|
+
request,
|
|
314
|
+
grantId,
|
|
315
|
+
sessionValue: credential.cookieValue,
|
|
316
|
+
csrfToken,
|
|
317
|
+
expiresAt: credential.context.expiresAt
|
|
318
|
+
})
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async resolveSession(request, grantId) {
|
|
322
|
+
if (!isStoredIdentifier(grantId))
|
|
323
|
+
return null;
|
|
324
|
+
const protocol = this.getProtocol();
|
|
325
|
+
const names = sharedCookieNames(grantId);
|
|
326
|
+
const sessionValue = getCookie(request, names.session);
|
|
327
|
+
const foreground = hasForegroundSessionActivity(request);
|
|
328
|
+
const context = await protocol.resolve(grantId, sessionValue, {
|
|
329
|
+
activity: foreground ? "foreground" : "background"
|
|
330
|
+
});
|
|
331
|
+
if (!context || !sessionValue)
|
|
332
|
+
return null;
|
|
333
|
+
const existingCsrfToken = getCookie(request, names.csrf);
|
|
334
|
+
const csrfToken = existingCsrfToken ?? generateCsrfToken();
|
|
335
|
+
return {
|
|
336
|
+
context,
|
|
337
|
+
cookies: foreground ? this.createCookieHeaders({
|
|
338
|
+
request,
|
|
339
|
+
grantId,
|
|
340
|
+
sessionValue,
|
|
341
|
+
csrfToken,
|
|
342
|
+
expiresAt: context.expiresAt
|
|
343
|
+
}) : {
|
|
344
|
+
csrfToken,
|
|
345
|
+
setCookies: existingCsrfToken === undefined ? [
|
|
346
|
+
serializeSharedCookie({
|
|
347
|
+
request,
|
|
348
|
+
name: names.csrf,
|
|
349
|
+
value: csrfToken,
|
|
350
|
+
expiresAt: context.expiresAt,
|
|
351
|
+
maxAge: cookieMaxAge(context.expiresAt)
|
|
352
|
+
})
|
|
353
|
+
] : []
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
async signOut(request, grantId) {
|
|
358
|
+
if (!isStoredIdentifier(grantId)) {
|
|
359
|
+
return { kind: "invalid", setCookies: [] };
|
|
360
|
+
}
|
|
361
|
+
const clearCookies = this.clearCookieHeaders(request, grantId);
|
|
362
|
+
const resolved = await this.resolveSession(request, grantId);
|
|
363
|
+
if (!resolved)
|
|
364
|
+
return { kind: "invalid", setCookies: clearCookies };
|
|
365
|
+
if (!verifyDoubleSubmitCsrf(request, {
|
|
366
|
+
cookieName: sharedCookieNames(grantId).csrf,
|
|
367
|
+
headerName: CSRF_HEADER_NAME
|
|
368
|
+
})) {
|
|
369
|
+
return { kind: "csrf" };
|
|
370
|
+
}
|
|
371
|
+
const protocol = this.getProtocol();
|
|
372
|
+
await protocol.revoke(resolved.context);
|
|
373
|
+
return { kind: "signedOut", setCookies: clearCookies };
|
|
374
|
+
}
|
|
375
|
+
clearCookieHeaders(request, grantId) {
|
|
376
|
+
if (!isStoredIdentifier(grantId))
|
|
377
|
+
return [];
|
|
378
|
+
const names = sharedCookieNames(grantId);
|
|
379
|
+
return [
|
|
380
|
+
serializeSharedCookie({
|
|
381
|
+
request,
|
|
382
|
+
name: names.session,
|
|
383
|
+
value: "",
|
|
384
|
+
expiresAt: new Date(0),
|
|
385
|
+
maxAge: 0,
|
|
386
|
+
httpOnly: true
|
|
387
|
+
}),
|
|
388
|
+
serializeSharedCookie({
|
|
389
|
+
request,
|
|
390
|
+
name: names.csrf,
|
|
391
|
+
value: "",
|
|
392
|
+
expiresAt: new Date(0),
|
|
393
|
+
maxAge: 0
|
|
394
|
+
})
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
createCookieHeaders(input) {
|
|
398
|
+
const names = sharedCookieNames(input.grantId);
|
|
399
|
+
const maxAge = cookieMaxAge(input.expiresAt);
|
|
400
|
+
return {
|
|
401
|
+
csrfToken: input.csrfToken,
|
|
402
|
+
setCookies: [
|
|
403
|
+
serializeSharedCookie({
|
|
404
|
+
request: input.request,
|
|
405
|
+
name: names.session,
|
|
406
|
+
value: input.sessionValue,
|
|
407
|
+
expiresAt: input.expiresAt,
|
|
408
|
+
maxAge,
|
|
409
|
+
httpOnly: true
|
|
410
|
+
}),
|
|
411
|
+
serializeSharedCookie({
|
|
412
|
+
request: input.request,
|
|
413
|
+
name: names.csrf,
|
|
414
|
+
value: input.csrfToken,
|
|
415
|
+
expiresAt: input.expiresAt,
|
|
416
|
+
maxAge
|
|
417
|
+
})
|
|
418
|
+
]
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
getProtocol() {
|
|
422
|
+
if (this.protocol)
|
|
423
|
+
return this.protocol;
|
|
424
|
+
if (!this.host.storage.shareGrants || !this.host.storage.shareSessions) {
|
|
425
|
+
throw new Error("[SixbServer] Shared-access session storage is not configured.");
|
|
426
|
+
}
|
|
427
|
+
this.protocol = new SharedSessionProtocol({
|
|
428
|
+
host: this.host,
|
|
429
|
+
...this.options.inactivityTtlMs === undefined ? {} : { inactivityTtlMs: this.options.inactivityTtlMs }
|
|
430
|
+
});
|
|
431
|
+
return this.protocol;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function isSharedAccessPublicRoute(request) {
|
|
435
|
+
return isSharedAccessPublicPath(new URL(request.url).pathname, request.method);
|
|
436
|
+
}
|
|
437
|
+
function isSharedAccessPublicPath(pathname, requestMethod) {
|
|
438
|
+
const method = requestMethod.toUpperCase();
|
|
439
|
+
const normalizedPathname = normalizeRoutePath(pathname);
|
|
440
|
+
const suffix = method === "POST" && normalizedPathname.endsWith("/exchange") ? "exchange" : method === "GET" && normalizedPathname.endsWith("/session") ? "session" : method === "POST" && normalizedPathname.endsWith("/sign-out") ? "sign-out" : null;
|
|
441
|
+
if (!suffix)
|
|
442
|
+
return false;
|
|
443
|
+
return matchesPathPattern(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
|
|
444
|
+
}
|
|
445
|
+
function isSharedSessionRoute(request) {
|
|
446
|
+
const method = request.method.toUpperCase();
|
|
447
|
+
const pathname = normalizeRoutePath(new URL(request.url).pathname);
|
|
448
|
+
return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern(pathname, route.path));
|
|
449
|
+
}
|
|
450
|
+
function sharedAccessUnauthenticatedResponse() {
|
|
451
|
+
return sharedBoundaryJsonResponse({ error: "Shared access session is invalid" }, 401);
|
|
452
|
+
}
|
|
453
|
+
function sharedAccessForbiddenResponse() {
|
|
454
|
+
return sharedBoundaryJsonResponse({ error: "Shared access is not allowed for this request" }, 403);
|
|
455
|
+
}
|
|
456
|
+
function sharedAccessUnavailableResponse() {
|
|
457
|
+
return sharedBoundaryJsonResponse({ error: "Shared access is unavailable" }, 503);
|
|
458
|
+
}
|
|
459
|
+
function sharedBoundaryJsonResponse(body, status) {
|
|
460
|
+
return new Response(JSON.stringify(body), {
|
|
461
|
+
status,
|
|
462
|
+
headers: sharedAccessSecurityHeaders()
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function sharedAccessSecurityHeaders() {
|
|
466
|
+
return new Headers({
|
|
467
|
+
"cache-control": "no-store",
|
|
468
|
+
"content-security-policy": "default-src 'none'; frame-ancestors 'none'",
|
|
469
|
+
"content-type": "application/json; charset=utf-8",
|
|
470
|
+
"referrer-policy": "no-referrer",
|
|
471
|
+
"x-content-type-options": "nosniff",
|
|
472
|
+
"x-robots-tag": "noindex, nofollow"
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function sharedCookieNames(grantId) {
|
|
476
|
+
const digest = createHash("sha256").update(grantId).digest("hex");
|
|
477
|
+
return {
|
|
478
|
+
session: `${SHARED_SESSION_COOKIE_PREFIX}${digest}`,
|
|
479
|
+
csrf: `${SHARED_CSRF_COOKIE_PREFIX}${digest}`
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function serializeSharedCookie(input) {
|
|
483
|
+
const parts = [
|
|
484
|
+
`${input.name}=${input.value}`,
|
|
485
|
+
`Path=${SHARED_COOKIE_PATH}`,
|
|
486
|
+
"SameSite=Strict",
|
|
487
|
+
`Max-Age=${Math.trunc(input.maxAge)}`,
|
|
488
|
+
`Expires=${input.expiresAt.toUTCString()}`
|
|
489
|
+
];
|
|
490
|
+
if (input.httpOnly)
|
|
491
|
+
parts.push("HttpOnly");
|
|
492
|
+
if (shouldUseSecureSharedCookie(input.request))
|
|
493
|
+
parts.push("Secure");
|
|
494
|
+
return parts.join("; ");
|
|
495
|
+
}
|
|
496
|
+
function cookieMaxAge(expiresAt) {
|
|
497
|
+
return Math.max(0, Math.floor((expiresAt.getTime() - Date.now()) / 1000));
|
|
498
|
+
}
|
|
499
|
+
function shouldUseSecureSharedCookie(request) {
|
|
500
|
+
const url = new URL(request.url);
|
|
501
|
+
if (url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "::1") {
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
return url.protocol === "https:" || true;
|
|
505
|
+
}
|
|
506
|
+
function isStoredIdentifier(value) {
|
|
507
|
+
return value.length > 0 && value.length <= STORED_IDENTIFIER_MAX_LENGTH && value.trim() === value && !value.includes("\x00");
|
|
508
|
+
}
|
|
218
509
|
|
|
219
510
|
// src/openapi/security.ts
|
|
220
|
-
import { CSRF_HEADER_NAME } from "@sixb/core/internal/auth";
|
|
221
511
|
var SIXB_CSRF_SECURITY_SCHEME_ID = "sixbCsrf";
|
|
222
512
|
var SIXB_BEARER_SECURITY_SCHEME_ID = "sixbBearer";
|
|
513
|
+
var SIXB_SHARED_GRANT_SECURITY_SCHEME_ID = "sixbSharedGrant";
|
|
223
514
|
var SIXB_CSRF_SECURITY_REQUIREMENT = [
|
|
224
515
|
{
|
|
225
516
|
[SIXB_CSRF_SECURITY_SCHEME_ID]: []
|
|
@@ -234,11 +525,18 @@ var SIXB_CSRF_OR_BEARER_SECURITY_REQUIREMENT = [
|
|
|
234
525
|
...SIXB_CSRF_SECURITY_REQUIREMENT,
|
|
235
526
|
...SIXB_BEARER_SECURITY_REQUIREMENT
|
|
236
527
|
];
|
|
528
|
+
var SIXB_SHARED_READ_SECURITY_REQUIREMENT = {
|
|
529
|
+
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: []
|
|
530
|
+
};
|
|
531
|
+
var SIXB_SHARED_MUTATION_SECURITY_REQUIREMENT = {
|
|
532
|
+
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: [],
|
|
533
|
+
[SIXB_CSRF_SECURITY_SCHEME_ID]: []
|
|
534
|
+
};
|
|
237
535
|
var SIXB_CSRF_SECURITY_SCHEME = {
|
|
238
536
|
type: "apiKey",
|
|
239
537
|
in: "header",
|
|
240
|
-
name:
|
|
241
|
-
description: "Required for authenticated mutating requests. Use the csrfToken returned by
|
|
538
|
+
name: CSRF_HEADER_NAME2,
|
|
539
|
+
description: "Required for cookie-authenticated mutating requests. Use the csrfToken returned by the corresponding session endpoint."
|
|
242
540
|
};
|
|
243
541
|
var SIXB_BEARER_SECURITY_SCHEME = {
|
|
244
542
|
type: "http",
|
|
@@ -246,21 +544,38 @@ var SIXB_BEARER_SECURITY_SCHEME = {
|
|
|
246
544
|
bearerFormat: "Sixb access token",
|
|
247
545
|
description: "Use a Sixb personal access token or service-account token. Bearer tokens are accepted only on routes that explicitly document this scheme."
|
|
248
546
|
};
|
|
547
|
+
var SIXB_SHARED_GRANT_SECURITY_SCHEME = {
|
|
548
|
+
type: "apiKey",
|
|
549
|
+
in: "header",
|
|
550
|
+
name: SHARED_ACCESS_GRANT_HEADER_NAME,
|
|
551
|
+
description: "Selects the shared grant whose grant-specific HttpOnly session cookie must authenticate the request."
|
|
552
|
+
};
|
|
249
553
|
|
|
250
554
|
// src/auth/access-token-boundary.ts
|
|
251
|
-
var ACCESS_TOKEN_ROUTES =
|
|
555
|
+
var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES2.filter((route) => route.accessToken).map((route) => ({
|
|
556
|
+
operationId: route.operationId,
|
|
557
|
+
method: route.method,
|
|
558
|
+
path: route.path,
|
|
559
|
+
sharedSession: route.sharedSession ?? false
|
|
560
|
+
}));
|
|
252
561
|
function bearerSecurityRequirement(operationId) {
|
|
253
562
|
const route = ACCESS_TOKEN_ROUTES.find((candidate) => candidate.operationId === operationId);
|
|
254
563
|
if (!route) {
|
|
255
564
|
throw new Error(`[SixbServer] '${operationId}' is not a registered bearer route. Add it to ACCESS_TOKEN_ROUTES.`);
|
|
256
565
|
}
|
|
257
|
-
|
|
566
|
+
const standard = isCsrfExemptMethod2(route.method) ? SIXB_BEARER_SECURITY_REQUIREMENT : SIXB_CSRF_OR_BEARER_SECURITY_REQUIREMENT;
|
|
567
|
+
if (!route.sharedSession)
|
|
568
|
+
return standard;
|
|
569
|
+
return [
|
|
570
|
+
...standard,
|
|
571
|
+
isCsrfExemptMethod2(route.method) ? SIXB_SHARED_READ_SECURITY_REQUIREMENT : SIXB_SHARED_MUTATION_SECURITY_REQUIREMENT
|
|
572
|
+
];
|
|
258
573
|
}
|
|
259
574
|
function isAccessTokenRoute(request) {
|
|
260
575
|
const url = new URL(request.url);
|
|
261
576
|
const method = request.method.toUpperCase();
|
|
262
|
-
const pathname =
|
|
263
|
-
return ACCESS_TOKEN_ROUTES.some((route) => route.method === method &&
|
|
577
|
+
const pathname = normalizeRoutePath2(url.pathname);
|
|
578
|
+
return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
|
|
264
579
|
}
|
|
265
580
|
function shouldVerifyCsrfForAuthSource(route, source) {
|
|
266
581
|
return route.csrfProtected && source === "session";
|
|
@@ -275,7 +590,7 @@ function sessionCanAccessApplication(host, session, audience) {
|
|
|
275
590
|
|
|
276
591
|
// src/auth/public-routes.ts
|
|
277
592
|
import { AGENT_API_GATEWAY_PREFIX } from "@sixb/core/internal/agents";
|
|
278
|
-
import { isCsrfExemptMethod as
|
|
593
|
+
import { isCsrfExemptMethod as isCsrfExemptMethod3 } from "@sixb/core/internal/auth";
|
|
279
594
|
var CONNECTOR_OAUTH_CALLBACK_PATH = "/auth/connectors/callback";
|
|
280
595
|
function classifyRoute(request) {
|
|
281
596
|
const url = new URL(request.url);
|
|
@@ -287,21 +602,24 @@ function classifyRoute(request) {
|
|
|
287
602
|
return { kind: "websocket", csrfProtected: false };
|
|
288
603
|
}
|
|
289
604
|
if (pathname.startsWith("/api/")) {
|
|
290
|
-
return { kind: "api", csrfProtected: !
|
|
605
|
+
return { kind: "api", csrfProtected: !isCsrfExemptMethod3(request.method) };
|
|
291
606
|
}
|
|
292
607
|
if (pathname === "/auth/device") {
|
|
293
|
-
return { kind: "html", csrfProtected: !
|
|
608
|
+
return { kind: "html", csrfProtected: !isCsrfExemptMethod3(request.method) };
|
|
294
609
|
}
|
|
295
610
|
if (pathname === "/docs" || pathname.startsWith("/docs/")) {
|
|
296
|
-
return { kind: "html", csrfProtected: !
|
|
611
|
+
return { kind: "html", csrfProtected: !isCsrfExemptMethod3(request.method) };
|
|
297
612
|
}
|
|
298
|
-
return { kind: "api", csrfProtected: !
|
|
613
|
+
return { kind: "api", csrfProtected: !isCsrfExemptMethod3(request.method) };
|
|
299
614
|
}
|
|
300
615
|
function isPublicRoute(pathname, method) {
|
|
301
616
|
const normalizedMethod = method.toUpperCase();
|
|
302
617
|
if (normalizedMethod === "OPTIONS") {
|
|
303
618
|
return true;
|
|
304
619
|
}
|
|
620
|
+
if (isSharedAccessPublicPath(pathname, method)) {
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
305
623
|
if ((pathname === "/favicon.svg" || pathname === "/favicon.ico") && normalizedMethod === "GET") {
|
|
306
624
|
return true;
|
|
307
625
|
}
|
|
@@ -400,20 +718,6 @@ function jsonResponse(body, status = 200, headers) {
|
|
|
400
718
|
});
|
|
401
719
|
}
|
|
402
720
|
|
|
403
|
-
// src/auth/session-activity.ts
|
|
404
|
-
var SESSION_ACTIVITY_HEADER_NAME = "x-sixb-session-activity";
|
|
405
|
-
var SESSION_ACTIVITY_HEADER_VALUE = "1";
|
|
406
|
-
function hasForegroundSessionActivity(request) {
|
|
407
|
-
return request.headers.get(SESSION_ACTIVITY_HEADER_NAME) === SESSION_ACTIVITY_HEADER_VALUE;
|
|
408
|
-
}
|
|
409
|
-
function isSessionTerminationRequest(request) {
|
|
410
|
-
if (request.method.toUpperCase() !== "POST") {
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
const pathname = new URL(request.url).pathname;
|
|
414
|
-
return pathname === "/api/auth/sign-out" || pathname === "/api/auth/sign-out-all" || /^\/api\/auth\/sessions\/[^/]+\/revoke$/.test(pathname);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
721
|
// src/auth/guard.ts
|
|
418
722
|
class ServerAuthGuard {
|
|
419
723
|
host;
|
|
@@ -507,7 +811,7 @@ class ServerAuthGuard {
|
|
|
507
811
|
return this.host.auth.getCookieOptions({ audience }).csrfCookieName;
|
|
508
812
|
}
|
|
509
813
|
verifyCsrf(request, _session) {
|
|
510
|
-
return
|
|
814
|
+
return verifyDoubleSubmitCsrf2(request, {
|
|
511
815
|
cookieName: this.getCsrfCookieName(request)
|
|
512
816
|
});
|
|
513
817
|
}
|
|
@@ -555,18 +859,18 @@ function requireRequestSixb(context) {
|
|
|
555
859
|
import {
|
|
556
860
|
createCsrfCookieHeader,
|
|
557
861
|
createSessionCookieHeader,
|
|
558
|
-
generateCsrfToken,
|
|
559
|
-
getCookie
|
|
862
|
+
generateCsrfToken as generateCsrfToken2,
|
|
863
|
+
getCookie as getCookie2
|
|
560
864
|
} from "@sixb/core/internal/auth";
|
|
561
865
|
function createSessionRenewalCookieHeaders(input) {
|
|
562
866
|
const cookieOptions = input.host.auth.getCookieOptions({
|
|
563
867
|
audience: input.session.session.audience
|
|
564
868
|
});
|
|
565
|
-
const sessionValue =
|
|
869
|
+
const sessionValue = getCookie2(input.request, cookieOptions.sessionCookieName);
|
|
566
870
|
if (!sessionValue) {
|
|
567
871
|
return null;
|
|
568
872
|
}
|
|
569
|
-
const csrfToken = input.csrfToken ??
|
|
873
|
+
const csrfToken = input.csrfToken ?? getCookie2(input.request, cookieOptions.csrfCookieName) ?? generateCsrfToken2();
|
|
570
874
|
return {
|
|
571
875
|
csrfToken,
|
|
572
876
|
headers: [
|
|
@@ -747,6 +1051,10 @@ var OPENAPI_TAGS = {
|
|
|
747
1051
|
authServiceAccounts: {
|
|
748
1052
|
name: "Auth Service Accounts",
|
|
749
1053
|
description: "Service accounts and service-account access tokens"
|
|
1054
|
+
},
|
|
1055
|
+
sharedAccess: {
|
|
1056
|
+
name: "Shared Access",
|
|
1057
|
+
description: "Scoped shared-access grant lifecycle"
|
|
750
1058
|
}
|
|
751
1059
|
};
|
|
752
1060
|
var OPENAPI_TAG_METADATA = Object.values(OPENAPI_TAGS).map(({ name, description }) => ({
|
|
@@ -758,7 +1066,7 @@ var OPENAPI_TAG_METADATA = Object.values(OPENAPI_TAGS).map(({ name, description
|
|
|
758
1066
|
import { z as z5 } from "zod";
|
|
759
1067
|
|
|
760
1068
|
// src/files/content.ts
|
|
761
|
-
import { createHash } from "crypto";
|
|
1069
|
+
import { createHash as createHash2 } from "crypto";
|
|
762
1070
|
import { isFileRef } from "@sixb/core";
|
|
763
1071
|
import { BlobStorageError, supportsRangeRead } from "@sixb/core/blob-storage/server";
|
|
764
1072
|
import { ZodError } from "zod";
|
|
@@ -992,7 +1300,7 @@ function fileContentHeaders(fileRef, stat, requestedDisposition, canReadRange) {
|
|
|
992
1300
|
mediaType,
|
|
993
1301
|
headers.get("content-disposition")
|
|
994
1302
|
]);
|
|
995
|
-
headers.set("etag", `"sha256:${
|
|
1303
|
+
headers.set("etag", `"sha256:${createHash2("sha256").update(representation).digest("hex")}"`);
|
|
996
1304
|
headers.set("x-content-type-options", "nosniff");
|
|
997
1305
|
headers.set("cache-control", "private, no-cache");
|
|
998
1306
|
if (canReadRange) {
|
|
@@ -1735,7 +2043,7 @@ function serializeAction(action) {
|
|
|
1735
2043
|
id: action.id,
|
|
1736
2044
|
name: action.id,
|
|
1737
2045
|
description: action.description,
|
|
1738
|
-
...action.binding.kind === "object" ? { objectTypeId: action.binding.
|
|
2046
|
+
...action.binding.kind === "object" ? { objectTypeId: action.binding.objectTypeId } : {},
|
|
1739
2047
|
params: Object.entries(action.params).map(([id, config]) => ({
|
|
1740
2048
|
id,
|
|
1741
2049
|
name: id,
|
|
@@ -1745,12 +2053,7 @@ function serializeAction(action) {
|
|
|
1745
2053
|
description: config.description,
|
|
1746
2054
|
semanticType: config.semanticType
|
|
1747
2055
|
})),
|
|
1748
|
-
phases:
|
|
1749
|
-
validate: action.phases.validate.length > 0,
|
|
1750
|
-
writeback: action.phases.writeback !== undefined,
|
|
1751
|
-
edits: action.phases.edits !== undefined,
|
|
1752
|
-
effects: action.phases.effects !== undefined
|
|
1753
|
-
}
|
|
2056
|
+
phases: action.phases
|
|
1754
2057
|
});
|
|
1755
2058
|
}
|
|
1756
2059
|
function serializeActionDetail(action, host) {
|
|
@@ -1836,7 +2139,7 @@ import {
|
|
|
1836
2139
|
resolveAgentExecutionAuthorization,
|
|
1837
2140
|
resolveInheritedAgentExecutionAuthorization
|
|
1838
2141
|
} from "@sixb/core/internal/agents";
|
|
1839
|
-
import { normalizeRoutePath as
|
|
2142
|
+
import { normalizeRoutePath as normalizeRoutePath3, pathSegmentsFor } from "@sixb/core/internal/http";
|
|
1840
2143
|
|
|
1841
2144
|
// src/routes/files.ts
|
|
1842
2145
|
import {
|
|
@@ -2513,7 +2816,7 @@ function gatewayUpstreamPath(pathname) {
|
|
|
2513
2816
|
const prefixLength = pathSegmentsFor(AGENT_API_GATEWAY_PREFIX2).length;
|
|
2514
2817
|
const segments = pathSegmentsFor(pathname);
|
|
2515
2818
|
const upstreamSegments = segments.slice(prefixLength + 2);
|
|
2516
|
-
return
|
|
2819
|
+
return normalizeRoutePath3(`/${upstreamSegments.join("/")}`);
|
|
2517
2820
|
}
|
|
2518
2821
|
function forwardedRequestHeaders(source) {
|
|
2519
2822
|
const headers = new Headers;
|
|
@@ -2558,7 +2861,7 @@ async function readRequestBody(request, maxBytes) {
|
|
|
2558
2861
|
return concatChunks(chunks, total);
|
|
2559
2862
|
}
|
|
2560
2863
|
function isSimpleFileUpload(method, pathname) {
|
|
2561
|
-
return method === "POST" &&
|
|
2864
|
+
return method === "POST" && normalizeRoutePath3(pathname) === "/api/files";
|
|
2562
2865
|
}
|
|
2563
2866
|
function matchesWorkflowRunStart(pathname) {
|
|
2564
2867
|
const segments = pathSegmentsFor(pathname);
|
|
@@ -4247,7 +4550,7 @@ function registerAiAccountingRoutes(app, host) {
|
|
|
4247
4550
|
import { getConnectorConnectionCallbackProcess } from "@sixb/core/internal/connector-connections";
|
|
4248
4551
|
|
|
4249
4552
|
// src/auth/connector-callback-cookie.ts
|
|
4250
|
-
import { getCookie as
|
|
4553
|
+
import { getCookie as getCookie3 } from "@sixb/core/internal/auth";
|
|
4251
4554
|
import { createSixbError } from "@sixb/core/internal/errors";
|
|
4252
4555
|
var CALLBACK_PATH = "/auth/connectors/callback";
|
|
4253
4556
|
var COOKIE_PREFIX = "sixb_connector_callback_";
|
|
@@ -4264,7 +4567,7 @@ function createConnectorCallbackCookie(input) {
|
|
|
4264
4567
|
}
|
|
4265
4568
|
function readConnectorCallbackCookie(request, state) {
|
|
4266
4569
|
const name = connectorCallbackCookieName(attemptIdFromState(state));
|
|
4267
|
-
return { name, value:
|
|
4570
|
+
return { name, value: getCookie3(request, name) };
|
|
4268
4571
|
}
|
|
4269
4572
|
function clearConnectorCallbackCookie(request, name) {
|
|
4270
4573
|
return serializeConnectorCallbackCookie({
|
|
@@ -4954,6 +5257,7 @@ var DatasetDefinitionSchema = z13.object({
|
|
|
4954
5257
|
id: z13.string(),
|
|
4955
5258
|
description: z13.string().optional(),
|
|
4956
5259
|
primaryKey: z13.union([z13.string(), z13.array(z13.string()).min(2)]).optional(),
|
|
5260
|
+
sequenceBy: z13.string().optional(),
|
|
4957
5261
|
partitionBy: z13.array(z13.string()).optional(),
|
|
4958
5262
|
schema: DatasetSchema
|
|
4959
5263
|
});
|
|
@@ -4962,7 +5266,7 @@ var DatasetVersionRefSchema = z13.object({
|
|
|
4962
5266
|
versionId: z13.string()
|
|
4963
5267
|
});
|
|
4964
5268
|
var DatasetProducerSchema = z13.object({
|
|
4965
|
-
kind: z13.enum(["sync", "pipeline"]),
|
|
5269
|
+
kind: z13.enum(["sync", "pipeline", "ingest"]),
|
|
4966
5270
|
id: z13.string().optional(),
|
|
4967
5271
|
runId: z13.string().optional()
|
|
4968
5272
|
});
|
|
@@ -8085,45 +8389,466 @@ function registerRuleRoutes(app, host) {
|
|
|
8085
8389
|
});
|
|
8086
8390
|
}
|
|
8087
8391
|
|
|
8088
|
-
// src/
|
|
8392
|
+
// src/routes/share-grants.ts
|
|
8393
|
+
import {
|
|
8394
|
+
AuthorizationError as AuthorizationError4,
|
|
8395
|
+
ShareError
|
|
8396
|
+
} from "@sixb/core";
|
|
8397
|
+
import { ObjectNotFoundError as ObjectNotFoundError2 } from "@sixb/core/storage";
|
|
8398
|
+
|
|
8399
|
+
// src/schemas/share-grants.ts
|
|
8089
8400
|
import { z as z24 } from "zod";
|
|
8090
|
-
var
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8401
|
+
var StoredIdentifierSchema = z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8402
|
+
message: "stored identifier must not be blank or contain NUL bytes"
|
|
8403
|
+
});
|
|
8404
|
+
var Rfc3339DateSchema2 = z24.string().datetime({ offset: true });
|
|
8405
|
+
var DestinationPathSchema = z24.string().min(1).max(4096);
|
|
8406
|
+
var QueryBooleanSchema = z24.preprocess((value) => {
|
|
8407
|
+
if (value === "true" || value === true)
|
|
8408
|
+
return true;
|
|
8409
|
+
if (value === "false" || value === false)
|
|
8410
|
+
return false;
|
|
8411
|
+
return value;
|
|
8412
|
+
}, z24.boolean());
|
|
8413
|
+
var ShareGrantListLimitSchema = z24.preprocess(parseUnsignedQueryInteger, z24.number().int().min(1).max(200));
|
|
8414
|
+
var ShareGrantListOffsetSchema = z24.preprocess(parseUnsignedQueryInteger, z24.number().int().min(0).max(Number.MAX_SAFE_INTEGER));
|
|
8415
|
+
function parseUnsignedQueryInteger(value) {
|
|
8416
|
+
if (typeof value !== "string" || !/^\d+$/.test(value))
|
|
8417
|
+
return value;
|
|
8418
|
+
const parsed = Number(value);
|
|
8419
|
+
return Number.isSafeInteger(parsed) ? parsed : value;
|
|
8420
|
+
}
|
|
8421
|
+
var ShareGrantTargetSchema = z24.object({
|
|
8422
|
+
objectTypeId: StoredIdentifierSchema,
|
|
8423
|
+
primaryId: StoredIdentifierSchema
|
|
8424
|
+
});
|
|
8425
|
+
var ShareGrantTargetInputSchema = z24.object({
|
|
8426
|
+
objectTypeId: StoredIdentifierSchema,
|
|
8427
|
+
primaryId: z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8428
|
+
message: "primaryId must not be blank or contain NUL bytes"
|
|
8429
|
+
})
|
|
8430
|
+
});
|
|
8431
|
+
var AuthorizablePrincipalSchema = z24.object({
|
|
8432
|
+
type: z24.enum(["user", "serviceAccount"]),
|
|
8433
|
+
id: StoredIdentifierSchema
|
|
8434
|
+
});
|
|
8435
|
+
var PrincipalSchema = z24.object({
|
|
8436
|
+
type: z24.enum(["user", "serviceAccount", "system"]),
|
|
8437
|
+
id: StoredIdentifierSchema
|
|
8438
|
+
});
|
|
8439
|
+
var SharedAccessGrantSchema = z24.object({
|
|
8440
|
+
id: StoredIdentifierSchema,
|
|
8441
|
+
definitionId: StoredIdentifierSchema,
|
|
8442
|
+
target: ShareGrantTargetSchema,
|
|
8443
|
+
issuedBy: AuthorizablePrincipalSchema,
|
|
8444
|
+
destinationPath: DestinationPathSchema,
|
|
8445
|
+
createdAt: Rfc3339DateSchema2,
|
|
8446
|
+
expiresAt: Rfc3339DateSchema2,
|
|
8447
|
+
revokedAt: Rfc3339DateSchema2.optional(),
|
|
8448
|
+
revokedBy: PrincipalSchema.optional()
|
|
8449
|
+
});
|
|
8450
|
+
var IssueSharedAccessGrantBodySchema = z24.object({
|
|
8451
|
+
definitionId: StoredIdentifierSchema,
|
|
8452
|
+
target: ShareGrantTargetInputSchema,
|
|
8453
|
+
destinationPath: DestinationPathSchema,
|
|
8454
|
+
expiresAt: Rfc3339DateSchema2
|
|
8455
|
+
});
|
|
8456
|
+
var IssueSharedAccessGrantResponseSchema = z24.object({
|
|
8457
|
+
grant: SharedAccessGrantSchema,
|
|
8458
|
+
url: z24.string().startsWith("/shared/")
|
|
8459
|
+
});
|
|
8460
|
+
var ListSharedAccessGrantsQuerySchema = z24.object({
|
|
8461
|
+
definitionId: StoredIdentifierSchema,
|
|
8462
|
+
primaryId: z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8463
|
+
message: "primaryId must not be blank or contain NUL bytes"
|
|
8464
|
+
}).optional(),
|
|
8465
|
+
includeRevoked: QueryBooleanSchema.optional(),
|
|
8466
|
+
includeExpired: QueryBooleanSchema.optional(),
|
|
8467
|
+
limit: ShareGrantListLimitSchema.optional(),
|
|
8468
|
+
offset: ShareGrantListOffsetSchema.optional()
|
|
8469
|
+
});
|
|
8470
|
+
var ListSharedAccessGrantsResponseSchema = z24.object({
|
|
8471
|
+
grants: z24.array(SharedAccessGrantSchema),
|
|
8472
|
+
hasMore: z24.boolean(),
|
|
8473
|
+
total: z24.number().int().nonnegative()
|
|
8474
|
+
});
|
|
8475
|
+
var SharedAccessGrantIdParamsSchema = z24.object({
|
|
8476
|
+
grantId: StoredIdentifierSchema
|
|
8477
|
+
});
|
|
8478
|
+
var RevokeSharedAccessGrantResponseSchema = z24.object({
|
|
8479
|
+
grant: SharedAccessGrantSchema
|
|
8480
|
+
});
|
|
8481
|
+
function isStoredIdentifier2(value) {
|
|
8482
|
+
return value.trim().length > 0 && !value.includes("\x00");
|
|
8483
|
+
}
|
|
8484
|
+
|
|
8485
|
+
// src/routes/share-grants.ts
|
|
8486
|
+
var INTERNAL_ERROR = "[SixbServer] Shared-access operation failed.";
|
|
8487
|
+
var STORAGE_UNAVAILABLE_ERROR = "[SixbServer] Shared-access grant storage is not configured on this runtime.";
|
|
8488
|
+
function registerShareGrantRoutes(app, _host) {
|
|
8489
|
+
return app.post("/api/share-grants", async (context) => {
|
|
8490
|
+
const { body, set } = context;
|
|
8491
|
+
setNoStore(set);
|
|
8492
|
+
try {
|
|
8493
|
+
const invitation = await requireRequestSixb(context).shares.issueById({
|
|
8494
|
+
definitionId: body.definitionId,
|
|
8495
|
+
target: body.target,
|
|
8496
|
+
destinationPath: body.destinationPath,
|
|
8497
|
+
expiresAt: new Date(body.expiresAt)
|
|
8498
|
+
});
|
|
8499
|
+
const grant = serializeSharedAccessGrant(invitation.grant);
|
|
8500
|
+
set.status = 201;
|
|
8501
|
+
return IssueSharedAccessGrantResponseSchema.parse({
|
|
8502
|
+
grant,
|
|
8503
|
+
url: sharedAccessUrl(grant.id, grant.destinationPath, invitation.secret)
|
|
8504
|
+
});
|
|
8505
|
+
} catch (error) {
|
|
8506
|
+
return handleShareGrantRouteError(error, set);
|
|
8507
|
+
}
|
|
8508
|
+
}, {
|
|
8509
|
+
body: IssueSharedAccessGrantBodySchema,
|
|
8510
|
+
response: {
|
|
8511
|
+
201: IssueSharedAccessGrantResponseSchema,
|
|
8512
|
+
400: ErrorResponseSchema,
|
|
8513
|
+
401: ErrorResponseSchema,
|
|
8514
|
+
403: ErrorResponseSchema,
|
|
8515
|
+
404: ErrorResponseSchema,
|
|
8516
|
+
500: ErrorResponseSchema,
|
|
8517
|
+
501: ErrorResponseSchema
|
|
8518
|
+
},
|
|
8519
|
+
error: sharedAccessValidationError("Invalid shared-access grant request."),
|
|
8520
|
+
detail: {
|
|
8521
|
+
summary: "Issue a shared-access grant",
|
|
8522
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8523
|
+
operationId: "issueSharedAccessGrant",
|
|
8524
|
+
security: bearerSecurityRequirement("issueSharedAccessGrant")
|
|
8525
|
+
}
|
|
8526
|
+
}).get("/api/share-grants", async (context) => {
|
|
8527
|
+
const { query, set } = context;
|
|
8528
|
+
setNoStore(set);
|
|
8529
|
+
try {
|
|
8530
|
+
const result = await requireRequestSixb(context).shares.listById({
|
|
8531
|
+
definitionId: query.definitionId,
|
|
8532
|
+
primaryId: query.primaryId,
|
|
8533
|
+
includeRevoked: query.includeRevoked,
|
|
8534
|
+
includeExpired: query.includeExpired,
|
|
8535
|
+
limit: query.limit,
|
|
8536
|
+
offset: query.offset
|
|
8537
|
+
});
|
|
8538
|
+
return ListSharedAccessGrantsResponseSchema.parse({
|
|
8539
|
+
grants: result.grants.map(serializeSharedAccessGrant),
|
|
8540
|
+
total: result.total,
|
|
8541
|
+
hasMore: result.hasMore
|
|
8542
|
+
});
|
|
8543
|
+
} catch (error) {
|
|
8544
|
+
return handleShareGrantRouteError(error, set);
|
|
8545
|
+
}
|
|
8546
|
+
}, {
|
|
8547
|
+
query: ListSharedAccessGrantsQuerySchema,
|
|
8548
|
+
response: {
|
|
8549
|
+
200: ListSharedAccessGrantsResponseSchema,
|
|
8550
|
+
400: ErrorResponseSchema,
|
|
8551
|
+
401: ErrorResponseSchema,
|
|
8552
|
+
403: ErrorResponseSchema,
|
|
8553
|
+
404: ErrorResponseSchema,
|
|
8554
|
+
500: ErrorResponseSchema,
|
|
8555
|
+
501: ErrorResponseSchema
|
|
8556
|
+
},
|
|
8557
|
+
error: sharedAccessValidationError("Invalid shared-access grant query."),
|
|
8558
|
+
detail: {
|
|
8559
|
+
summary: "List shared-access grants",
|
|
8560
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8561
|
+
operationId: "listSharedAccessGrants",
|
|
8562
|
+
security: bearerSecurityRequirement("listSharedAccessGrants")
|
|
8563
|
+
}
|
|
8564
|
+
}).delete("/api/share-grants/:grantId", async (context) => {
|
|
8565
|
+
const { params, set } = context;
|
|
8566
|
+
setNoStore(set);
|
|
8567
|
+
try {
|
|
8568
|
+
const grant = await requireRequestSixb(context).shares.revoke(params.grantId);
|
|
8569
|
+
if (!grant) {
|
|
8570
|
+
set.status = 404;
|
|
8571
|
+
return { error: "[SixbServer] Shared-access grant not found." };
|
|
8572
|
+
}
|
|
8573
|
+
return RevokeSharedAccessGrantResponseSchema.parse({
|
|
8574
|
+
grant: serializeSharedAccessGrant(grant)
|
|
8575
|
+
});
|
|
8576
|
+
} catch (error) {
|
|
8577
|
+
return handleShareGrantRouteError(error, set);
|
|
8578
|
+
}
|
|
8579
|
+
}, {
|
|
8580
|
+
params: SharedAccessGrantIdParamsSchema,
|
|
8581
|
+
response: {
|
|
8582
|
+
200: RevokeSharedAccessGrantResponseSchema,
|
|
8583
|
+
400: ErrorResponseSchema,
|
|
8584
|
+
401: ErrorResponseSchema,
|
|
8585
|
+
403: ErrorResponseSchema,
|
|
8586
|
+
404: ErrorResponseSchema,
|
|
8587
|
+
500: ErrorResponseSchema,
|
|
8588
|
+
501: ErrorResponseSchema
|
|
8589
|
+
},
|
|
8590
|
+
error: sharedAccessValidationError("Invalid shared-access grant id."),
|
|
8591
|
+
detail: {
|
|
8592
|
+
summary: "Revoke a shared-access grant",
|
|
8593
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8594
|
+
operationId: "revokeSharedAccessGrant",
|
|
8595
|
+
security: bearerSecurityRequirement("revokeSharedAccessGrant")
|
|
8596
|
+
}
|
|
8597
|
+
});
|
|
8598
|
+
}
|
|
8599
|
+
function serializeSharedAccessGrant(grant) {
|
|
8600
|
+
return SharedAccessGrantSchema.parse({
|
|
8601
|
+
id: grant.id,
|
|
8602
|
+
definitionId: grant.definitionId,
|
|
8603
|
+
target: grant.target,
|
|
8604
|
+
issuedBy: grant.issuedBy,
|
|
8605
|
+
destinationPath: grant.destinationPath,
|
|
8606
|
+
createdAt: grant.createdAt.toISOString(),
|
|
8607
|
+
expiresAt: grant.expiresAt.toISOString(),
|
|
8608
|
+
...grant.revokedAt === undefined ? {} : { revokedAt: grant.revokedAt.toISOString() },
|
|
8609
|
+
...grant.revokedBy === undefined ? {} : { revokedBy: grant.revokedBy }
|
|
8610
|
+
});
|
|
8611
|
+
}
|
|
8612
|
+
function sharedAccessUrl(grantId, destinationPath, secret) {
|
|
8613
|
+
return `/shared/${encodeURIComponent(grantId)}${destinationPath}#${encodeURIComponent(secret)}`;
|
|
8614
|
+
}
|
|
8615
|
+
function handleShareGrantRouteError(error, set) {
|
|
8616
|
+
if (error instanceof ShareError) {
|
|
8617
|
+
set.status = shareErrorStatus(error);
|
|
8618
|
+
if (error.reason === "storage_failure")
|
|
8619
|
+
return { error: INTERNAL_ERROR };
|
|
8620
|
+
if (error.reason === "storage_unavailable")
|
|
8621
|
+
return { error: STORAGE_UNAVAILABLE_ERROR };
|
|
8622
|
+
if (error.reason === "unauthenticated")
|
|
8623
|
+
return { error: "Authentication required." };
|
|
8624
|
+
return { error: error.message };
|
|
8625
|
+
}
|
|
8626
|
+
if (error instanceof AuthorizationError4) {
|
|
8627
|
+
set.status = 403;
|
|
8628
|
+
return { error: error.message };
|
|
8629
|
+
}
|
|
8630
|
+
if (error instanceof ObjectNotFoundError2) {
|
|
8631
|
+
set.status = 404;
|
|
8632
|
+
return { error: error.message };
|
|
8633
|
+
}
|
|
8634
|
+
set.status = 500;
|
|
8635
|
+
return { error: INTERNAL_ERROR };
|
|
8636
|
+
}
|
|
8637
|
+
function shareErrorStatus(error) {
|
|
8638
|
+
switch (error.reason) {
|
|
8639
|
+
case "invalid_input":
|
|
8640
|
+
return 400;
|
|
8641
|
+
case "not_found":
|
|
8642
|
+
return 404;
|
|
8643
|
+
case "unauthenticated":
|
|
8644
|
+
return 401;
|
|
8645
|
+
case "storage_unavailable":
|
|
8646
|
+
return 501;
|
|
8647
|
+
case "storage_failure":
|
|
8648
|
+
return 500;
|
|
8649
|
+
}
|
|
8650
|
+
}
|
|
8651
|
+
function sharedAccessValidationError(message) {
|
|
8652
|
+
return ({
|
|
8653
|
+
code,
|
|
8654
|
+
set
|
|
8655
|
+
}) => {
|
|
8656
|
+
if (code !== "VALIDATION")
|
|
8657
|
+
return;
|
|
8658
|
+
setNoStore(set);
|
|
8659
|
+
set.status = 400;
|
|
8660
|
+
return { error: message };
|
|
8661
|
+
};
|
|
8662
|
+
}
|
|
8663
|
+
function setNoStore(set) {
|
|
8664
|
+
if (set.headers instanceof Headers) {
|
|
8665
|
+
set.headers.set("cache-control", "no-store");
|
|
8666
|
+
return;
|
|
8667
|
+
}
|
|
8668
|
+
if (!set.headers || typeof set.headers !== "object" || Array.isArray(set.headers)) {
|
|
8669
|
+
set.headers = {};
|
|
8670
|
+
}
|
|
8671
|
+
set.headers["cache-control"] = "no-store";
|
|
8672
|
+
}
|
|
8673
|
+
|
|
8674
|
+
// src/schemas/shared-access.ts
|
|
8675
|
+
import { z as z25 } from "zod";
|
|
8676
|
+
var StoredIdentifierSchema2 = z25.string().min(1).max(128).refine((value) => value.trim() === value && !value.includes("\x00"), {
|
|
8677
|
+
message: "stored identifier must not be blank or contain NUL bytes"
|
|
8678
|
+
});
|
|
8679
|
+
var Rfc3339DateSchema3 = z25.string().datetime({ offset: true });
|
|
8680
|
+
var SharedAccessGrantParamsSchema = z25.object({
|
|
8681
|
+
grantId: StoredIdentifierSchema2
|
|
8682
|
+
});
|
|
8683
|
+
var ExchangeSharedAccessBodySchema = z25.object({
|
|
8684
|
+
secret: z25.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
8685
|
+
});
|
|
8686
|
+
var SharedAccessSessionResponseSchema = z25.object({
|
|
8687
|
+
grantId: StoredIdentifierSchema2,
|
|
8688
|
+
destinationPath: z25.string().min(1).max(4096),
|
|
8689
|
+
expiresAt: Rfc3339DateSchema3,
|
|
8690
|
+
absoluteExpiresAt: Rfc3339DateSchema3,
|
|
8691
|
+
csrfToken: z25.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
8692
|
+
});
|
|
8693
|
+
var SharedAccessSignOutResponseSchema = z25.object({
|
|
8694
|
+
signedOut: z25.literal(true)
|
|
8695
|
+
});
|
|
8696
|
+
|
|
8697
|
+
// src/routes/shared-access.ts
|
|
8698
|
+
function registerSharedAccessRoutes(app, boundary) {
|
|
8699
|
+
return app.post("/api/shared-access/:grantId/exchange", async ({ body, params, request }) => {
|
|
8700
|
+
try {
|
|
8701
|
+
const resolved = await boundary.exchange(request, params.grantId, body.secret);
|
|
8702
|
+
if (!resolved)
|
|
8703
|
+
return sharedAccessUnauthenticatedResponse();
|
|
8704
|
+
return sharedSessionResponse(resolved.context, resolved.cookies);
|
|
8705
|
+
} catch {
|
|
8706
|
+
return sharedAccessUnavailableResponse();
|
|
8707
|
+
}
|
|
8708
|
+
}, {
|
|
8709
|
+
params: SharedAccessGrantParamsSchema,
|
|
8710
|
+
body: ExchangeSharedAccessBodySchema,
|
|
8711
|
+
response: {
|
|
8712
|
+
200: SharedAccessSessionResponseSchema,
|
|
8713
|
+
401: ErrorResponseSchema,
|
|
8714
|
+
503: ErrorResponseSchema
|
|
8715
|
+
},
|
|
8716
|
+
error: sharedAccessRouteError,
|
|
8717
|
+
detail: {
|
|
8718
|
+
summary: "Exchange a shared link for a short-lived session",
|
|
8719
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8720
|
+
operationId: "exchangeSharedAccess",
|
|
8721
|
+
security: []
|
|
8722
|
+
}
|
|
8723
|
+
}).get("/api/shared-access/:grantId/session", async ({ params, request }) => {
|
|
8724
|
+
try {
|
|
8725
|
+
const resolved = await boundary.resolveSession(request, params.grantId);
|
|
8726
|
+
if (!resolved) {
|
|
8727
|
+
return withSetCookies(sharedAccessUnauthenticatedResponse(), boundary.clearCookieHeaders(request, params.grantId));
|
|
8728
|
+
}
|
|
8729
|
+
return sharedSessionResponse(resolved.context, resolved.cookies);
|
|
8730
|
+
} catch {
|
|
8731
|
+
return sharedAccessUnavailableResponse();
|
|
8732
|
+
}
|
|
8733
|
+
}, {
|
|
8734
|
+
params: SharedAccessGrantParamsSchema,
|
|
8735
|
+
response: {
|
|
8736
|
+
200: SharedAccessSessionResponseSchema,
|
|
8737
|
+
401: ErrorResponseSchema,
|
|
8738
|
+
503: ErrorResponseSchema
|
|
8739
|
+
},
|
|
8740
|
+
error: sharedAccessRouteError,
|
|
8741
|
+
detail: {
|
|
8742
|
+
summary: "Get the current shared-access session",
|
|
8743
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8744
|
+
operationId: "getSharedAccessSession",
|
|
8745
|
+
security: []
|
|
8746
|
+
}
|
|
8747
|
+
}).post("/api/shared-access/:grantId/sign-out", async ({ params, request }) => {
|
|
8748
|
+
try {
|
|
8749
|
+
const result = await boundary.signOut(request, params.grantId);
|
|
8750
|
+
if (result.kind === "csrf")
|
|
8751
|
+
return sharedAccessForbiddenResponse();
|
|
8752
|
+
if (result.kind === "invalid") {
|
|
8753
|
+
return withSetCookies(sharedAccessUnauthenticatedResponse(), result.setCookies);
|
|
8754
|
+
}
|
|
8755
|
+
const response = new Response(JSON.stringify({ signedOut: true }), {
|
|
8756
|
+
status: 200,
|
|
8757
|
+
headers: sharedAccessSecurityHeaders()
|
|
8758
|
+
});
|
|
8759
|
+
return withSetCookies(response, result.setCookies);
|
|
8760
|
+
} catch {
|
|
8761
|
+
return sharedAccessUnavailableResponse();
|
|
8762
|
+
}
|
|
8763
|
+
}, {
|
|
8764
|
+
params: SharedAccessGrantParamsSchema,
|
|
8765
|
+
response: {
|
|
8766
|
+
200: SharedAccessSignOutResponseSchema,
|
|
8767
|
+
401: ErrorResponseSchema,
|
|
8768
|
+
403: ErrorResponseSchema,
|
|
8769
|
+
503: ErrorResponseSchema
|
|
8770
|
+
},
|
|
8771
|
+
error: sharedAccessRouteError,
|
|
8772
|
+
detail: {
|
|
8773
|
+
summary: "Sign out a shared-access session",
|
|
8774
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8775
|
+
operationId: "signOutSharedAccess",
|
|
8776
|
+
security: SIXB_CSRF_SECURITY_REQUIREMENT
|
|
8777
|
+
}
|
|
8778
|
+
});
|
|
8779
|
+
}
|
|
8780
|
+
function sharedSessionResponse(context, cookies) {
|
|
8781
|
+
const headers = sharedAccessSecurityHeaders();
|
|
8782
|
+
headers.set(CSRF_TOKEN_RESPONSE_HEADER_NAME, cookies.csrfToken);
|
|
8783
|
+
for (const cookie of cookies.setCookies)
|
|
8784
|
+
headers.append("set-cookie", cookie);
|
|
8785
|
+
return new Response(JSON.stringify({
|
|
8786
|
+
grantId: context.grantId,
|
|
8787
|
+
destinationPath: context.destinationPath,
|
|
8788
|
+
expiresAt: context.expiresAt.toISOString(),
|
|
8789
|
+
absoluteExpiresAt: context.absoluteExpiresAt.toISOString(),
|
|
8790
|
+
csrfToken: cookies.csrfToken
|
|
8791
|
+
}), { status: 200, headers });
|
|
8792
|
+
}
|
|
8793
|
+
function withSetCookies(response, setCookies) {
|
|
8794
|
+
for (const cookie of setCookies)
|
|
8795
|
+
response.headers.append("set-cookie", cookie);
|
|
8796
|
+
return response;
|
|
8797
|
+
}
|
|
8798
|
+
function sharedAccessRouteError(context) {
|
|
8799
|
+
if (context.code === "PARSE" || isRequestValidationError(context)) {
|
|
8800
|
+
return sharedAccessUnauthenticatedResponse();
|
|
8801
|
+
}
|
|
8802
|
+
return sharedAccessUnavailableResponse();
|
|
8803
|
+
}
|
|
8804
|
+
function isRequestValidationError(context) {
|
|
8805
|
+
if (context.code !== "VALIDATION" || !isRecord(context.error))
|
|
8806
|
+
return false;
|
|
8807
|
+
return ["body", "params", "query", "headers", "cookie"].includes(String(context.error.type));
|
|
8808
|
+
}
|
|
8809
|
+
function isRecord(value) {
|
|
8810
|
+
return typeof value === "object" && value !== null;
|
|
8811
|
+
}
|
|
8812
|
+
|
|
8813
|
+
// src/schemas/status.ts
|
|
8814
|
+
import { z as z26 } from "zod";
|
|
8815
|
+
var HealthResponseSchema = z26.object({ status: z26.literal("ok") });
|
|
8816
|
+
var StorageReadinessSchema = z26.object({
|
|
8817
|
+
reachable: z26.boolean(),
|
|
8818
|
+
schemaValid: z26.boolean()
|
|
8094
8819
|
});
|
|
8095
|
-
var ReadinessResponseSchema =
|
|
8096
|
-
status:
|
|
8820
|
+
var ReadinessResponseSchema = z26.object({
|
|
8821
|
+
status: z26.enum(["ready", "unready"]),
|
|
8097
8822
|
storage: StorageReadinessSchema,
|
|
8098
|
-
reason:
|
|
8099
|
-
});
|
|
8100
|
-
var MaintenanceSummarySchema =
|
|
8101
|
-
running:
|
|
8102
|
-
intervalMs:
|
|
8103
|
-
lastStartedAt:
|
|
8104
|
-
lastCompletedAt:
|
|
8105
|
-
lastDurationMs:
|
|
8106
|
-
consecutiveFailures:
|
|
8107
|
-
lastError:
|
|
8108
|
-
outbox:
|
|
8109
|
-
pendingCount:
|
|
8110
|
-
oldestPendingAt:
|
|
8111
|
-
retryingCount:
|
|
8112
|
-
maxAttempts:
|
|
8823
|
+
reason: z26.string().optional()
|
|
8824
|
+
});
|
|
8825
|
+
var MaintenanceSummarySchema = z26.object({
|
|
8826
|
+
running: z26.boolean(),
|
|
8827
|
+
intervalMs: z26.number().int().positive(),
|
|
8828
|
+
lastStartedAt: z26.string().nullable(),
|
|
8829
|
+
lastCompletedAt: z26.string().nullable(),
|
|
8830
|
+
lastDurationMs: z26.number().nonnegative().nullable(),
|
|
8831
|
+
consecutiveFailures: z26.number().int().nonnegative(),
|
|
8832
|
+
lastError: z26.string().nullable(),
|
|
8833
|
+
outbox: z26.object({
|
|
8834
|
+
pendingCount: z26.number().int().nonnegative(),
|
|
8835
|
+
oldestPendingAt: z26.string().nullable(),
|
|
8836
|
+
retryingCount: z26.number().int().nonnegative(),
|
|
8837
|
+
maxAttempts: z26.number().int().nonnegative()
|
|
8113
8838
|
}).nullable(),
|
|
8114
|
-
terminalSources:
|
|
8115
|
-
count:
|
|
8116
|
-
oldestTerminalAt:
|
|
8839
|
+
terminalSources: z26.object({
|
|
8840
|
+
count: z26.number().int().nonnegative(),
|
|
8841
|
+
oldestTerminalAt: z26.string().nullable()
|
|
8117
8842
|
}).nullable(),
|
|
8118
|
-
cleanup:
|
|
8119
|
-
publishedOutboxRowsDeleted:
|
|
8120
|
-
terminalSourceRowsDeleted:
|
|
8121
|
-
terminalSourceMaterializationsDeleted:
|
|
8843
|
+
cleanup: z26.object({
|
|
8844
|
+
publishedOutboxRowsDeleted: z26.number().int().nonnegative(),
|
|
8845
|
+
terminalSourceRowsDeleted: z26.number().int().nonnegative(),
|
|
8846
|
+
terminalSourceMaterializationsDeleted: z26.number().int().nonnegative()
|
|
8122
8847
|
}).nullable()
|
|
8123
8848
|
});
|
|
8124
|
-
var StatusResponseSchema =
|
|
8125
|
-
status:
|
|
8126
|
-
objectTypes:
|
|
8849
|
+
var StatusResponseSchema = z26.object({
|
|
8850
|
+
status: z26.enum(["ok", "degraded"]),
|
|
8851
|
+
objectTypes: z26.number().int().nonnegative(),
|
|
8127
8852
|
maintenance: MaintenanceSummarySchema
|
|
8128
8853
|
});
|
|
8129
8854
|
|
|
@@ -8169,74 +8894,74 @@ function registerStatusRoutes(app, host) {
|
|
|
8169
8894
|
import {
|
|
8170
8895
|
SYNC_RUN_FAILURE_CODES
|
|
8171
8896
|
} from "@sixb/core/storage";
|
|
8172
|
-
import { z as
|
|
8897
|
+
import { z as z27 } from "zod";
|
|
8173
8898
|
var SyncRunFailureSchema = sixbFailureSchema(SYNC_RUN_FAILURE_CODES);
|
|
8174
|
-
var SyncParamsSchema =
|
|
8175
|
-
syncId:
|
|
8176
|
-
});
|
|
8177
|
-
var SyncRunStatusSchema =
|
|
8178
|
-
var SyncModeSchema =
|
|
8179
|
-
var SyncRunsQuerySchema =
|
|
8180
|
-
syncId:
|
|
8181
|
-
datasetId:
|
|
8899
|
+
var SyncParamsSchema = z27.object({
|
|
8900
|
+
syncId: z27.string().min(1)
|
|
8901
|
+
});
|
|
8902
|
+
var SyncRunStatusSchema = z27.enum(["queued", "running", "succeeded", "failed", "cancelled"]);
|
|
8903
|
+
var SyncModeSchema = z27.enum(["snapshot", "append", "merge"]);
|
|
8904
|
+
var SyncRunsQuerySchema = z27.object({
|
|
8905
|
+
syncId: z27.string().optional(),
|
|
8906
|
+
datasetId: z27.string().optional(),
|
|
8182
8907
|
status: SyncRunStatusSchema.optional(),
|
|
8183
|
-
startedAfter:
|
|
8184
|
-
startedBefore:
|
|
8185
|
-
limit:
|
|
8186
|
-
offset:
|
|
8187
|
-
order:
|
|
8188
|
-
});
|
|
8189
|
-
var RequestSyncRunBodySchema =
|
|
8190
|
-
expectedLatestVersionId:
|
|
8191
|
-
commitMessage:
|
|
8192
|
-
});
|
|
8193
|
-
var SyncTriggerSchema =
|
|
8194
|
-
type:
|
|
8195
|
-
scheduleId:
|
|
8196
|
-
});
|
|
8197
|
-
var SyncRunSchema =
|
|
8198
|
-
id:
|
|
8199
|
-
projectId:
|
|
8200
|
-
syncId:
|
|
8201
|
-
datasetId:
|
|
8908
|
+
startedAfter: z27.string().optional(),
|
|
8909
|
+
startedBefore: z27.string().optional(),
|
|
8910
|
+
limit: z27.string().optional(),
|
|
8911
|
+
offset: z27.string().optional(),
|
|
8912
|
+
order: z27.enum(["asc", "desc"]).optional()
|
|
8913
|
+
});
|
|
8914
|
+
var RequestSyncRunBodySchema = z27.object({
|
|
8915
|
+
expectedLatestVersionId: z27.string().optional(),
|
|
8916
|
+
commitMessage: z27.string().optional()
|
|
8917
|
+
});
|
|
8918
|
+
var SyncTriggerSchema = z27.object({
|
|
8919
|
+
type: z27.literal("schedule"),
|
|
8920
|
+
scheduleId: z27.string()
|
|
8921
|
+
});
|
|
8922
|
+
var SyncRunSchema = z27.object({
|
|
8923
|
+
id: z27.string(),
|
|
8924
|
+
projectId: z27.string(),
|
|
8925
|
+
syncId: z27.string(),
|
|
8926
|
+
datasetId: z27.string(),
|
|
8202
8927
|
mode: SyncModeSchema,
|
|
8203
8928
|
status: SyncRunStatusSchema,
|
|
8204
|
-
queuedAt:
|
|
8205
|
-
startedAt:
|
|
8206
|
-
finishedAt:
|
|
8207
|
-
rowsRead:
|
|
8208
|
-
output:
|
|
8209
|
-
datasetId:
|
|
8210
|
-
versionId:
|
|
8929
|
+
queuedAt: z27.string(),
|
|
8930
|
+
startedAt: z27.string().optional(),
|
|
8931
|
+
finishedAt: z27.string().optional(),
|
|
8932
|
+
rowsRead: z27.number().optional(),
|
|
8933
|
+
output: z27.object({
|
|
8934
|
+
datasetId: z27.string(),
|
|
8935
|
+
versionId: z27.string()
|
|
8211
8936
|
}).optional(),
|
|
8212
|
-
expectedLatestVersionId:
|
|
8213
|
-
commitMessage:
|
|
8937
|
+
expectedLatestVersionId: z27.string().optional(),
|
|
8938
|
+
commitMessage: z27.string().optional(),
|
|
8214
8939
|
error: SyncRunFailureSchema.optional()
|
|
8215
8940
|
});
|
|
8216
|
-
var SyncSchema =
|
|
8217
|
-
id:
|
|
8941
|
+
var SyncSchema = z27.object({
|
|
8942
|
+
id: z27.string(),
|
|
8218
8943
|
mode: SyncModeSchema,
|
|
8219
|
-
connector:
|
|
8220
|
-
id:
|
|
8221
|
-
type:
|
|
8944
|
+
connector: z27.object({
|
|
8945
|
+
id: z27.string(),
|
|
8946
|
+
type: z27.string()
|
|
8222
8947
|
}),
|
|
8223
|
-
target:
|
|
8224
|
-
kind:
|
|
8948
|
+
target: z27.object({
|
|
8949
|
+
kind: z27.literal("dataset"),
|
|
8225
8950
|
dataset: DatasetDefinitionSchema
|
|
8226
8951
|
}),
|
|
8227
|
-
triggers:
|
|
8952
|
+
triggers: z27.array(SyncTriggerSchema),
|
|
8228
8953
|
latestRun: SyncRunSchema.nullable()
|
|
8229
8954
|
});
|
|
8230
|
-
var SyncRunListResponseSchema =
|
|
8231
|
-
runs:
|
|
8232
|
-
hasMore:
|
|
8233
|
-
total:
|
|
8955
|
+
var SyncRunListResponseSchema = z27.object({
|
|
8956
|
+
runs: z27.array(SyncRunSchema),
|
|
8957
|
+
hasMore: z27.boolean(),
|
|
8958
|
+
total: z27.number()
|
|
8234
8959
|
});
|
|
8235
|
-
var RequestSyncRunResponseSchema =
|
|
8236
|
-
runId:
|
|
8237
|
-
jobId:
|
|
8238
|
-
syncId:
|
|
8239
|
-
queuedAt:
|
|
8960
|
+
var RequestSyncRunResponseSchema = z27.object({
|
|
8961
|
+
runId: z27.string(),
|
|
8962
|
+
jobId: z27.string(),
|
|
8963
|
+
syncId: z27.string(),
|
|
8964
|
+
queuedAt: z27.string()
|
|
8240
8965
|
});
|
|
8241
8966
|
|
|
8242
8967
|
// src/routes/syncs.ts
|
|
@@ -8390,52 +9115,52 @@ function registerSyncRoutes(app, host) {
|
|
|
8390
9115
|
}
|
|
8391
9116
|
|
|
8392
9117
|
// src/schemas/telemetry.ts
|
|
8393
|
-
import { z as
|
|
8394
|
-
var TelemetryParamsSchema =
|
|
8395
|
-
objectTypeId:
|
|
8396
|
-
objectId:
|
|
8397
|
-
propertyId:
|
|
8398
|
-
});
|
|
8399
|
-
var TelemetryHistoryQuerySchema =
|
|
8400
|
-
from:
|
|
8401
|
-
to:
|
|
8402
|
-
limit:
|
|
8403
|
-
order:
|
|
8404
|
-
});
|
|
8405
|
-
var BulkTelemetryHistorySeriesInputSchema =
|
|
8406
|
-
objectTypeId:
|
|
8407
|
-
objectId:
|
|
8408
|
-
propertyId:
|
|
9118
|
+
import { z as z28 } from "zod";
|
|
9119
|
+
var TelemetryParamsSchema = z28.object({
|
|
9120
|
+
objectTypeId: z28.string().min(1),
|
|
9121
|
+
objectId: z28.string().min(1),
|
|
9122
|
+
propertyId: z28.string().min(1)
|
|
9123
|
+
});
|
|
9124
|
+
var TelemetryHistoryQuerySchema = z28.object({
|
|
9125
|
+
from: z28.string().optional(),
|
|
9126
|
+
to: z28.string().optional(),
|
|
9127
|
+
limit: z28.string().optional(),
|
|
9128
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
9129
|
+
});
|
|
9130
|
+
var BulkTelemetryHistorySeriesInputSchema = z28.object({
|
|
9131
|
+
objectTypeId: z28.string().min(1),
|
|
9132
|
+
objectId: z28.string().min(1),
|
|
9133
|
+
propertyId: z28.string().min(1)
|
|
8409
9134
|
}).strict();
|
|
8410
|
-
var BulkTelemetryHistoryBodySchema =
|
|
8411
|
-
series:
|
|
8412
|
-
from:
|
|
8413
|
-
to:
|
|
8414
|
-
limitPerSeries:
|
|
8415
|
-
order:
|
|
9135
|
+
var BulkTelemetryHistoryBodySchema = z28.object({
|
|
9136
|
+
series: z28.array(BulkTelemetryHistorySeriesInputSchema).min(1),
|
|
9137
|
+
from: z28.string().optional(),
|
|
9138
|
+
to: z28.string().optional(),
|
|
9139
|
+
limitPerSeries: z28.number().int().nonnegative().optional(),
|
|
9140
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
8416
9141
|
}).strict();
|
|
8417
|
-
var AppendTelemetryBodySchema =
|
|
8418
|
-
value:
|
|
8419
|
-
unit:
|
|
8420
|
-
at:
|
|
8421
|
-
});
|
|
8422
|
-
var TelemetryPointSchema =
|
|
8423
|
-
projectId:
|
|
8424
|
-
objectTypeId:
|
|
8425
|
-
objectId:
|
|
8426
|
-
propertyId:
|
|
8427
|
-
value:
|
|
8428
|
-
unit:
|
|
8429
|
-
at:
|
|
8430
|
-
});
|
|
8431
|
-
var BulkTelemetryHistorySeriesSchema =
|
|
8432
|
-
objectTypeId:
|
|
8433
|
-
objectId:
|
|
8434
|
-
propertyId:
|
|
8435
|
-
points:
|
|
8436
|
-
});
|
|
8437
|
-
var BulkTelemetryHistoryResponseSchema =
|
|
8438
|
-
series:
|
|
9142
|
+
var AppendTelemetryBodySchema = z28.object({
|
|
9143
|
+
value: z28.unknown(),
|
|
9144
|
+
unit: z28.string().optional(),
|
|
9145
|
+
at: z28.string().optional()
|
|
9146
|
+
});
|
|
9147
|
+
var TelemetryPointSchema = z28.object({
|
|
9148
|
+
projectId: z28.string(),
|
|
9149
|
+
objectTypeId: z28.string(),
|
|
9150
|
+
objectId: z28.string(),
|
|
9151
|
+
propertyId: z28.string(),
|
|
9152
|
+
value: z28.unknown(),
|
|
9153
|
+
unit: z28.string().optional(),
|
|
9154
|
+
at: z28.string()
|
|
9155
|
+
});
|
|
9156
|
+
var BulkTelemetryHistorySeriesSchema = z28.object({
|
|
9157
|
+
objectTypeId: z28.string(),
|
|
9158
|
+
objectId: z28.string(),
|
|
9159
|
+
propertyId: z28.string(),
|
|
9160
|
+
points: z28.array(TelemetryPointSchema)
|
|
9161
|
+
});
|
|
9162
|
+
var BulkTelemetryHistoryResponseSchema = z28.object({
|
|
9163
|
+
series: z28.array(BulkTelemetryHistorySeriesSchema)
|
|
8439
9164
|
});
|
|
8440
9165
|
|
|
8441
9166
|
// src/routes/telemetry.ts
|
|
@@ -8593,40 +9318,40 @@ function registerTelemetryRoutes(app, _host) {
|
|
|
8593
9318
|
|
|
8594
9319
|
// src/schemas/webhook-runs.ts
|
|
8595
9320
|
import { WEBHOOK_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
8596
|
-
import { z as
|
|
9321
|
+
import { z as z29 } from "zod";
|
|
8597
9322
|
var WebhookRunFailureSchema = sixbFailureSchema(WEBHOOK_RUN_FAILURE_CODES);
|
|
8598
|
-
var WebhookRunStatusSchema =
|
|
8599
|
-
var WebhookRunsQuerySchema =
|
|
8600
|
-
connectorId:
|
|
8601
|
-
webhookId:
|
|
9323
|
+
var WebhookRunStatusSchema = z29.enum(["running", "succeeded", "failed"]);
|
|
9324
|
+
var WebhookRunsQuerySchema = z29.object({
|
|
9325
|
+
connectorId: z29.string().optional(),
|
|
9326
|
+
webhookId: z29.string().optional(),
|
|
8602
9327
|
status: WebhookRunStatusSchema.optional(),
|
|
8603
|
-
idempotencyKey:
|
|
8604
|
-
startedAfter:
|
|
8605
|
-
startedBefore:
|
|
8606
|
-
limit:
|
|
8607
|
-
offset:
|
|
8608
|
-
order:
|
|
8609
|
-
});
|
|
8610
|
-
var WebhookRunSchema =
|
|
8611
|
-
id:
|
|
8612
|
-
projectId:
|
|
8613
|
-
executionId:
|
|
8614
|
-
connectorId:
|
|
8615
|
-
webhookId:
|
|
9328
|
+
idempotencyKey: z29.string().optional(),
|
|
9329
|
+
startedAfter: z29.string().optional(),
|
|
9330
|
+
startedBefore: z29.string().optional(),
|
|
9331
|
+
limit: z29.string().optional(),
|
|
9332
|
+
offset: z29.string().optional(),
|
|
9333
|
+
order: z29.enum(["asc", "desc"]).optional()
|
|
9334
|
+
});
|
|
9335
|
+
var WebhookRunSchema = z29.object({
|
|
9336
|
+
id: z29.string(),
|
|
9337
|
+
projectId: z29.string(),
|
|
9338
|
+
executionId: z29.string(),
|
|
9339
|
+
connectorId: z29.string(),
|
|
9340
|
+
webhookId: z29.string(),
|
|
8616
9341
|
status: WebhookRunStatusSchema,
|
|
8617
|
-
method:
|
|
8618
|
-
route:
|
|
8619
|
-
startedAt:
|
|
8620
|
-
finishedAt:
|
|
8621
|
-
requestBodyBytes:
|
|
8622
|
-
responseStatus:
|
|
8623
|
-
idempotencyKey:
|
|
9342
|
+
method: z29.string(),
|
|
9343
|
+
route: z29.string(),
|
|
9344
|
+
startedAt: z29.string(),
|
|
9345
|
+
finishedAt: z29.string().optional(),
|
|
9346
|
+
requestBodyBytes: z29.number(),
|
|
9347
|
+
responseStatus: z29.number().optional(),
|
|
9348
|
+
idempotencyKey: z29.string().optional(),
|
|
8624
9349
|
error: WebhookRunFailureSchema.optional()
|
|
8625
9350
|
});
|
|
8626
|
-
var WebhookRunListResponseSchema =
|
|
8627
|
-
runs:
|
|
8628
|
-
hasMore:
|
|
8629
|
-
total:
|
|
9351
|
+
var WebhookRunListResponseSchema = z29.object({
|
|
9352
|
+
runs: z29.array(WebhookRunSchema),
|
|
9353
|
+
hasMore: z29.boolean(),
|
|
9354
|
+
total: z29.number()
|
|
8630
9355
|
});
|
|
8631
9356
|
|
|
8632
9357
|
// src/routes/webhook-runs.ts
|
|
@@ -8701,25 +9426,25 @@ import {
|
|
|
8701
9426
|
snapshotWorkflowInterventionResponse
|
|
8702
9427
|
} from "@sixb/core/internal/workflows";
|
|
8703
9428
|
import { AGENT_RUN_FAILURE_CODES as AGENT_RUN_FAILURE_CODES2, WORKFLOW_RUN_FAILURE_CODES as WORKFLOW_RUN_FAILURE_CODES2 } from "@sixb/core/storage";
|
|
8704
|
-
import { z as
|
|
9429
|
+
import { z as z31 } from "zod";
|
|
8705
9430
|
|
|
8706
9431
|
// src/schemas/workflows.ts
|
|
8707
9432
|
import {
|
|
8708
9433
|
WORKFLOW_RUN_FAILURE_CODES
|
|
8709
9434
|
} from "@sixb/core/storage";
|
|
8710
|
-
import { z as
|
|
8711
|
-
var WorkflowIOSnapshotSchema =
|
|
9435
|
+
import { z as z30 } from "zod";
|
|
9436
|
+
var WorkflowIOSnapshotSchema = z30.record(JsonValueSchema);
|
|
8712
9437
|
var WorkflowRunFailureSchema = sixbFailureSchema(WORKFLOW_RUN_FAILURE_CODES);
|
|
8713
|
-
var WorkflowParamsSchema =
|
|
8714
|
-
workflowId:
|
|
9438
|
+
var WorkflowParamsSchema = z30.object({
|
|
9439
|
+
workflowId: z30.string().min(1)
|
|
8715
9440
|
});
|
|
8716
|
-
var WorkflowRunParamsSchema =
|
|
8717
|
-
runId:
|
|
9441
|
+
var WorkflowRunParamsSchema = z30.object({
|
|
9442
|
+
runId: z30.string().min(1)
|
|
8718
9443
|
});
|
|
8719
|
-
var WorkflowInterventionParamsSchema =
|
|
8720
|
-
interventionId:
|
|
9444
|
+
var WorkflowInterventionParamsSchema = z30.object({
|
|
9445
|
+
interventionId: z30.string().min(1)
|
|
8721
9446
|
});
|
|
8722
|
-
var WorkflowRunStatusSchema =
|
|
9447
|
+
var WorkflowRunStatusSchema = z30.enum([
|
|
8723
9448
|
"queued",
|
|
8724
9449
|
"running",
|
|
8725
9450
|
"waiting",
|
|
@@ -8727,90 +9452,90 @@ var WorkflowRunStatusSchema = z28.enum([
|
|
|
8727
9452
|
"failed",
|
|
8728
9453
|
"cancelled"
|
|
8729
9454
|
]);
|
|
8730
|
-
var WorkflowInterventionStatusSchema =
|
|
9455
|
+
var WorkflowInterventionStatusSchema = z30.enum([
|
|
8731
9456
|
"pending",
|
|
8732
9457
|
"submitted",
|
|
8733
9458
|
"cancelled",
|
|
8734
9459
|
"expired"
|
|
8735
9460
|
]);
|
|
8736
|
-
var WorkflowRunsQuerySchema =
|
|
8737
|
-
workflowId:
|
|
9461
|
+
var WorkflowRunsQuerySchema = z30.object({
|
|
9462
|
+
workflowId: z30.string().optional(),
|
|
8738
9463
|
status: WorkflowRunStatusSchema.optional(),
|
|
8739
|
-
startedAfter:
|
|
8740
|
-
startedBefore:
|
|
8741
|
-
limit:
|
|
8742
|
-
offset:
|
|
8743
|
-
order:
|
|
9464
|
+
startedAfter: z30.string().optional(),
|
|
9465
|
+
startedBefore: z30.string().optional(),
|
|
9466
|
+
limit: z30.string().optional(),
|
|
9467
|
+
offset: z30.string().optional(),
|
|
9468
|
+
order: z30.enum(["asc", "desc"]).optional()
|
|
8744
9469
|
});
|
|
8745
|
-
var WorkflowInterventionsQuerySchema =
|
|
8746
|
-
workflowId:
|
|
8747
|
-
workflowRunId:
|
|
8748
|
-
nodeRunId:
|
|
8749
|
-
nodeId:
|
|
8750
|
-
nodeKey:
|
|
8751
|
-
interventionId:
|
|
9470
|
+
var WorkflowInterventionsQuerySchema = z30.object({
|
|
9471
|
+
workflowId: z30.string().optional(),
|
|
9472
|
+
workflowRunId: z30.string().optional(),
|
|
9473
|
+
nodeRunId: z30.string().optional(),
|
|
9474
|
+
nodeId: z30.string().optional(),
|
|
9475
|
+
nodeKey: z30.string().optional(),
|
|
9476
|
+
interventionId: z30.string().optional(),
|
|
8752
9477
|
status: WorkflowInterventionStatusSchema.optional(),
|
|
8753
|
-
requestedAfter:
|
|
8754
|
-
requestedBefore:
|
|
8755
|
-
limit:
|
|
8756
|
-
offset:
|
|
8757
|
-
order:
|
|
9478
|
+
requestedAfter: z30.string().optional(),
|
|
9479
|
+
requestedBefore: z30.string().optional(),
|
|
9480
|
+
limit: z30.string().optional(),
|
|
9481
|
+
offset: z30.string().optional(),
|
|
9482
|
+
order: z30.enum(["asc", "desc"]).optional()
|
|
8758
9483
|
});
|
|
8759
|
-
var RequestWorkflowRunBodySchema =
|
|
9484
|
+
var RequestWorkflowRunBodySchema = z30.object({
|
|
8760
9485
|
input: WorkflowIOSnapshotSchema.optional()
|
|
8761
9486
|
}).default({});
|
|
8762
|
-
var WorkflowInterventionActorSchema =
|
|
8763
|
-
principalType:
|
|
8764
|
-
principalId:
|
|
9487
|
+
var WorkflowInterventionActorSchema = z30.object({
|
|
9488
|
+
principalType: z30.enum(["user", "serviceAccount", "system"]),
|
|
9489
|
+
principalId: z30.string().min(1)
|
|
8765
9490
|
});
|
|
8766
|
-
var CancelWorkflowRunBodySchema =
|
|
8767
|
-
var SubmitWorkflowInterventionBodySchema =
|
|
9491
|
+
var CancelWorkflowRunBodySchema = z30.object({}).default({});
|
|
9492
|
+
var SubmitWorkflowInterventionBodySchema = z30.object({
|
|
8768
9493
|
response: WorkflowIOSnapshotSchema
|
|
8769
9494
|
});
|
|
8770
|
-
var CancelWorkflowInterventionBodySchema =
|
|
8771
|
-
var WorkflowTriggerSchema =
|
|
8772
|
-
type:
|
|
8773
|
-
scheduleId:
|
|
9495
|
+
var CancelWorkflowInterventionBodySchema = z30.object({}).default({});
|
|
9496
|
+
var WorkflowTriggerSchema = z30.object({
|
|
9497
|
+
type: z30.literal("schedule"),
|
|
9498
|
+
scheduleId: z30.string()
|
|
8774
9499
|
});
|
|
8775
|
-
var WorkflowNodeSchema =
|
|
8776
|
-
|
|
8777
|
-
type:
|
|
8778
|
-
id:
|
|
8779
|
-
key:
|
|
9500
|
+
var WorkflowNodeSchema = z30.union([
|
|
9501
|
+
z30.object({
|
|
9502
|
+
type: z30.literal("step"),
|
|
9503
|
+
id: z30.string(),
|
|
9504
|
+
key: z30.string(),
|
|
8780
9505
|
input: WorkflowIOSnapshotSchema,
|
|
8781
9506
|
output: WorkflowIOSnapshotSchema
|
|
8782
9507
|
}),
|
|
8783
|
-
|
|
8784
|
-
type:
|
|
8785
|
-
id:
|
|
8786
|
-
key:
|
|
8787
|
-
objectTypeId:
|
|
9508
|
+
z30.object({
|
|
9509
|
+
type: z30.literal("action"),
|
|
9510
|
+
id: z30.string(),
|
|
9511
|
+
key: z30.string(),
|
|
9512
|
+
objectTypeId: z30.string().optional(),
|
|
8788
9513
|
params: WorkflowIOSnapshotSchema
|
|
8789
9514
|
}),
|
|
8790
|
-
|
|
8791
|
-
type:
|
|
8792
|
-
id:
|
|
8793
|
-
key:
|
|
9515
|
+
z30.object({
|
|
9516
|
+
type: z30.literal("intervention"),
|
|
9517
|
+
id: z30.string(),
|
|
9518
|
+
key: z30.string(),
|
|
8794
9519
|
input: WorkflowIOSnapshotSchema,
|
|
8795
9520
|
response: WorkflowIOSnapshotSchema,
|
|
8796
|
-
description:
|
|
9521
|
+
description: z30.string().optional()
|
|
8797
9522
|
}),
|
|
8798
|
-
|
|
8799
|
-
type:
|
|
8800
|
-
id:
|
|
8801
|
-
key:
|
|
9523
|
+
z30.object({
|
|
9524
|
+
type: z30.literal("agent"),
|
|
9525
|
+
id: z30.string(),
|
|
9526
|
+
key: z30.string(),
|
|
8802
9527
|
input: WorkflowIOSnapshotSchema,
|
|
8803
9528
|
output: WorkflowIOSnapshotSchema
|
|
8804
9529
|
})
|
|
8805
9530
|
]);
|
|
8806
|
-
var WorkflowRunSummarySchema =
|
|
8807
|
-
id:
|
|
8808
|
-
projectId:
|
|
8809
|
-
workflowId:
|
|
9531
|
+
var WorkflowRunSummarySchema = z30.object({
|
|
9532
|
+
id: z30.string(),
|
|
9533
|
+
projectId: z30.string(),
|
|
9534
|
+
workflowId: z30.string(),
|
|
8810
9535
|
status: WorkflowRunStatusSchema,
|
|
8811
|
-
queuedAt:
|
|
8812
|
-
startedAt:
|
|
8813
|
-
finishedAt:
|
|
9536
|
+
queuedAt: z30.string().optional(),
|
|
9537
|
+
startedAt: z30.string(),
|
|
9538
|
+
finishedAt: z30.string().optional(),
|
|
8814
9539
|
error: WorkflowRunFailureSchema.optional(),
|
|
8815
9540
|
requestedBy: WorkflowInterventionActorSchema
|
|
8816
9541
|
});
|
|
@@ -8818,110 +9543,110 @@ var WorkflowRunDetailSchema = WorkflowRunSummarySchema.extend({
|
|
|
8818
9543
|
input: WorkflowIOSnapshotSchema,
|
|
8819
9544
|
output: WorkflowIOSnapshotSchema.optional()
|
|
8820
9545
|
});
|
|
8821
|
-
var WorkflowAgentNodeExecutionSummarySchema =
|
|
8822
|
-
status:
|
|
8823
|
-
attempt:
|
|
8824
|
-
modelId:
|
|
8825
|
-
finishReason:
|
|
9546
|
+
var WorkflowAgentNodeExecutionSummarySchema = z30.object({
|
|
9547
|
+
status: z30.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
|
|
9548
|
+
attempt: z30.number().int().nonnegative(),
|
|
9549
|
+
modelId: z30.string().optional(),
|
|
9550
|
+
finishReason: z30.string().optional(),
|
|
8826
9551
|
usage: AiUsageSummarySchema.optional(),
|
|
8827
9552
|
cost: AiCostSummarySchema.optional(),
|
|
8828
|
-
startedAt:
|
|
8829
|
-
completedAt:
|
|
9553
|
+
startedAt: z30.string().optional(),
|
|
9554
|
+
completedAt: z30.string().optional()
|
|
8830
9555
|
});
|
|
8831
|
-
var WorkflowAgentFailurePhaseSchema =
|
|
9556
|
+
var WorkflowAgentFailurePhaseSchema = z30.enum(["agent-loop", "structured-finalizer"]);
|
|
8832
9557
|
var WorkflowAgentNodeExecutionSchema = WorkflowAgentNodeExecutionSummarySchema.extend({
|
|
8833
|
-
nodeRunId:
|
|
8834
|
-
prompt:
|
|
8835
|
-
trace:
|
|
8836
|
-
diagnostics:
|
|
9558
|
+
nodeRunId: z30.string(),
|
|
9559
|
+
prompt: z30.string(),
|
|
9560
|
+
trace: z30.array(AgentMessagePartSchema).optional(),
|
|
9561
|
+
diagnostics: z30.array(JsonValueSchema).optional(),
|
|
8837
9562
|
failurePhase: WorkflowAgentFailurePhaseSchema.optional(),
|
|
8838
9563
|
error: AgentRunFailureSchema.optional(),
|
|
8839
|
-
createdAt:
|
|
9564
|
+
createdAt: z30.string()
|
|
8840
9565
|
});
|
|
8841
|
-
var WorkflowNodeRunSchema =
|
|
8842
|
-
id:
|
|
8843
|
-
projectId:
|
|
8844
|
-
workflowRunId:
|
|
8845
|
-
workflowId:
|
|
8846
|
-
nodeIndex:
|
|
8847
|
-
nodeType:
|
|
8848
|
-
nodeId:
|
|
8849
|
-
nodeKey:
|
|
8850
|
-
status:
|
|
9566
|
+
var WorkflowNodeRunSchema = z30.object({
|
|
9567
|
+
id: z30.string(),
|
|
9568
|
+
projectId: z30.string(),
|
|
9569
|
+
workflowRunId: z30.string(),
|
|
9570
|
+
workflowId: z30.string(),
|
|
9571
|
+
nodeIndex: z30.number(),
|
|
9572
|
+
nodeType: z30.enum(["step", "action", "intervention", "agent"]),
|
|
9573
|
+
nodeId: z30.string(),
|
|
9574
|
+
nodeKey: z30.string(),
|
|
9575
|
+
status: z30.enum(["running", "waiting", "succeeded", "failed", "cancelled"]),
|
|
8851
9576
|
input: WorkflowIOSnapshotSchema,
|
|
8852
|
-
startedAt:
|
|
8853
|
-
finishedAt:
|
|
9577
|
+
startedAt: z30.string(),
|
|
9578
|
+
finishedAt: z30.string().optional(),
|
|
8854
9579
|
output: WorkflowIOSnapshotSchema.optional(),
|
|
8855
9580
|
error: WorkflowRunFailureSchema.optional(),
|
|
8856
9581
|
agentExecution: WorkflowAgentNodeExecutionSummarySchema.optional()
|
|
8857
9582
|
});
|
|
8858
|
-
var WorkflowInterventionSchema =
|
|
8859
|
-
id:
|
|
8860
|
-
projectId:
|
|
8861
|
-
workflowId:
|
|
8862
|
-
workflowRunId:
|
|
8863
|
-
nodeRunId:
|
|
8864
|
-
nodeIndex:
|
|
8865
|
-
nodeId:
|
|
8866
|
-
nodeKey:
|
|
8867
|
-
interventionId:
|
|
9583
|
+
var WorkflowInterventionSchema = z30.object({
|
|
9584
|
+
id: z30.string(),
|
|
9585
|
+
projectId: z30.string(),
|
|
9586
|
+
workflowId: z30.string(),
|
|
9587
|
+
workflowRunId: z30.string(),
|
|
9588
|
+
nodeRunId: z30.string(),
|
|
9589
|
+
nodeIndex: z30.number(),
|
|
9590
|
+
nodeId: z30.string(),
|
|
9591
|
+
nodeKey: z30.string(),
|
|
9592
|
+
interventionId: z30.string(),
|
|
8868
9593
|
input: WorkflowIOSnapshotSchema,
|
|
8869
9594
|
defaultResponse: WorkflowIOSnapshotSchema,
|
|
8870
9595
|
status: WorkflowInterventionStatusSchema,
|
|
8871
|
-
requestedAt:
|
|
8872
|
-
expiresAt:
|
|
8873
|
-
submittedAt:
|
|
9596
|
+
requestedAt: z30.string(),
|
|
9597
|
+
expiresAt: z30.string().optional(),
|
|
9598
|
+
submittedAt: z30.string().optional(),
|
|
8874
9599
|
submittedBy: WorkflowInterventionActorSchema.optional(),
|
|
8875
9600
|
response: WorkflowIOSnapshotSchema.optional(),
|
|
8876
|
-
cancelledAt:
|
|
9601
|
+
cancelledAt: z30.string().optional(),
|
|
8877
9602
|
cancelledBy: WorkflowInterventionActorSchema.optional(),
|
|
8878
|
-
expiredAt:
|
|
9603
|
+
expiredAt: z30.string().optional()
|
|
8879
9604
|
});
|
|
8880
|
-
var WorkflowSchema =
|
|
8881
|
-
id:
|
|
9605
|
+
var WorkflowSchema = z30.object({
|
|
9606
|
+
id: z30.string(),
|
|
8882
9607
|
input: WorkflowIOSnapshotSchema,
|
|
8883
|
-
triggers:
|
|
8884
|
-
nodes:
|
|
9608
|
+
triggers: z30.array(WorkflowTriggerSchema),
|
|
9609
|
+
nodes: z30.array(WorkflowNodeSchema),
|
|
8885
9610
|
latestRun: WorkflowRunSummarySchema.nullable()
|
|
8886
9611
|
});
|
|
8887
|
-
var WorkflowRunListResponseSchema =
|
|
8888
|
-
runs:
|
|
8889
|
-
hasMore:
|
|
8890
|
-
total:
|
|
9612
|
+
var WorkflowRunListResponseSchema = z30.object({
|
|
9613
|
+
runs: z30.array(WorkflowRunSummarySchema),
|
|
9614
|
+
hasMore: z30.boolean(),
|
|
9615
|
+
total: z30.number()
|
|
8891
9616
|
});
|
|
8892
|
-
var WorkflowRunDetailResponseSchema =
|
|
9617
|
+
var WorkflowRunDetailResponseSchema = z30.object({
|
|
8893
9618
|
run: WorkflowRunDetailSchema,
|
|
8894
|
-
nodes:
|
|
9619
|
+
nodes: z30.array(WorkflowNodeRunSchema)
|
|
8895
9620
|
});
|
|
8896
9621
|
var CancelWorkflowRunResponseSchema = WorkflowRunDetailResponseSchema;
|
|
8897
|
-
var WorkflowInterventionListResponseSchema =
|
|
8898
|
-
interventions:
|
|
8899
|
-
hasMore:
|
|
8900
|
-
total:
|
|
9622
|
+
var WorkflowInterventionListResponseSchema = z30.object({
|
|
9623
|
+
interventions: z30.array(WorkflowInterventionSchema),
|
|
9624
|
+
hasMore: z30.boolean(),
|
|
9625
|
+
total: z30.number()
|
|
8901
9626
|
});
|
|
8902
|
-
var SubmitWorkflowInterventionResponseSchema =
|
|
9627
|
+
var SubmitWorkflowInterventionResponseSchema = z30.object({
|
|
8903
9628
|
intervention: WorkflowInterventionSchema,
|
|
8904
|
-
jobId:
|
|
9629
|
+
jobId: z30.string()
|
|
8905
9630
|
});
|
|
8906
|
-
var CancelWorkflowInterventionResponseSchema =
|
|
9631
|
+
var CancelWorkflowInterventionResponseSchema = z30.object({
|
|
8907
9632
|
intervention: WorkflowInterventionSchema
|
|
8908
9633
|
});
|
|
8909
|
-
var RequestWorkflowRunResponseSchema =
|
|
8910
|
-
runId:
|
|
8911
|
-
jobId:
|
|
8912
|
-
workflowId:
|
|
8913
|
-
queuedAt:
|
|
9634
|
+
var RequestWorkflowRunResponseSchema = z30.object({
|
|
9635
|
+
runId: z30.string(),
|
|
9636
|
+
jobId: z30.string(),
|
|
9637
|
+
workflowId: z30.string(),
|
|
9638
|
+
queuedAt: z30.string()
|
|
8914
9639
|
});
|
|
8915
9640
|
|
|
8916
9641
|
// src/routes/workflows.ts
|
|
8917
9642
|
var WorkflowRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
8918
|
-
path:
|
|
9643
|
+
path: z31.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow run file content paths must start with /input/ or /output/")
|
|
8919
9644
|
});
|
|
8920
9645
|
var WorkflowNodeFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
8921
|
-
path:
|
|
9646
|
+
path: z31.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow node file content paths must start with /input/ or /output/")
|
|
8922
9647
|
});
|
|
8923
9648
|
var WorkflowNodeFileContentParamsSchema = WorkflowRunParamsSchema.extend({
|
|
8924
|
-
nodeKey:
|
|
9649
|
+
nodeKey: z31.string().min(1)
|
|
8925
9650
|
});
|
|
8926
9651
|
function serializeWorkflowRunSummary(run) {
|
|
8927
9652
|
return {
|
|
@@ -8991,12 +9716,12 @@ function serializeWorkflowAgentExecution(execution) {
|
|
|
8991
9716
|
}
|
|
8992
9717
|
function workflowAgentFailurePhase(execution) {
|
|
8993
9718
|
const details = execution.error?.details;
|
|
8994
|
-
if (!
|
|
9719
|
+
if (!isRecord2(details))
|
|
8995
9720
|
return;
|
|
8996
9721
|
const phase = details.failurePhase;
|
|
8997
9722
|
return phase === "agent-loop" || phase === "structured-finalizer" ? phase : undefined;
|
|
8998
9723
|
}
|
|
8999
|
-
function
|
|
9724
|
+
function isRecord2(value) {
|
|
9000
9725
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9001
9726
|
}
|
|
9002
9727
|
function principalForExecution(sixb) {
|
|
@@ -9955,6 +10680,8 @@ function registerHttpRoutes(app, host, options) {
|
|
|
9955
10680
|
registerPipelineRoutes(app, host);
|
|
9956
10681
|
registerWorkflowRoutes(app, host);
|
|
9957
10682
|
registerRuleRoutes(app, host);
|
|
10683
|
+
registerShareGrantRoutes(app, host);
|
|
10684
|
+
registerSharedAccessRoutes(app, options.sharedAccess);
|
|
9958
10685
|
registerOntologyRoutes(app, host);
|
|
9959
10686
|
registerObjectRoutes(app, host);
|
|
9960
10687
|
registerActionRoutes(app, host);
|
|
@@ -9972,7 +10699,7 @@ function registerHttpRoutes(app, host, options) {
|
|
|
9972
10699
|
}
|
|
9973
10700
|
|
|
9974
10701
|
// src/routes/auth.ts
|
|
9975
|
-
import { createHash as
|
|
10702
|
+
import { createHash as createHash3, randomBytes, randomUUID, timingSafeEqual } from "crypto";
|
|
9976
10703
|
import {
|
|
9977
10704
|
AuthRuntimeError,
|
|
9978
10705
|
clearCsrfCookieHeader,
|
|
@@ -9981,12 +10708,12 @@ import {
|
|
|
9981
10708
|
createCsrfCookieHeader as createCsrfCookieHeader2,
|
|
9982
10709
|
createSessionCookieHeader as createSessionCookieHeader2,
|
|
9983
10710
|
createSessionCredential,
|
|
9984
|
-
generateCsrfToken as
|
|
9985
|
-
getCookie as
|
|
10711
|
+
generateCsrfToken as generateCsrfToken3,
|
|
10712
|
+
getCookie as getCookie4,
|
|
9986
10713
|
isMagicLinkAuthStrategy,
|
|
9987
10714
|
isOidcAuthStrategy,
|
|
9988
10715
|
shouldUseSecureCookies,
|
|
9989
|
-
verifyDoubleSubmitCsrf as
|
|
10716
|
+
verifyDoubleSubmitCsrf as verifyDoubleSubmitCsrf3
|
|
9990
10717
|
} from "@sixb/core/internal/auth";
|
|
9991
10718
|
import {
|
|
9992
10719
|
AuthStorageError
|
|
@@ -10124,301 +10851,301 @@ function notFoundResponse() {
|
|
|
10124
10851
|
}
|
|
10125
10852
|
|
|
10126
10853
|
// src/schemas/auth.ts
|
|
10127
|
-
import { z as
|
|
10128
|
-
var AuthInvitationStatusSchema =
|
|
10129
|
-
var AuthGroupOptionSchema =
|
|
10130
|
-
id:
|
|
10131
|
-
label:
|
|
10132
|
-
description:
|
|
10133
|
-
});
|
|
10134
|
-
var AuthInvitationSchema =
|
|
10135
|
-
id:
|
|
10136
|
-
email:
|
|
10137
|
-
groupIds:
|
|
10854
|
+
import { z as z32 } from "zod";
|
|
10855
|
+
var AuthInvitationStatusSchema = z32.enum(["pending", "accepted", "revoked"]);
|
|
10856
|
+
var AuthGroupOptionSchema = z32.object({
|
|
10857
|
+
id: z32.string(),
|
|
10858
|
+
label: z32.string().optional(),
|
|
10859
|
+
description: z32.string().optional()
|
|
10860
|
+
});
|
|
10861
|
+
var AuthInvitationSchema = z32.object({
|
|
10862
|
+
id: z32.string(),
|
|
10863
|
+
email: z32.string(),
|
|
10864
|
+
groupIds: z32.array(z32.string()),
|
|
10138
10865
|
status: AuthInvitationStatusSchema,
|
|
10139
|
-
createdAt:
|
|
10140
|
-
updatedAt:
|
|
10141
|
-
expiresAt:
|
|
10142
|
-
acceptedAt:
|
|
10143
|
-
revokedAt:
|
|
10144
|
-
});
|
|
10145
|
-
var AuthInvitationDeliverySchema =
|
|
10146
|
-
status:
|
|
10147
|
-
link:
|
|
10148
|
-
url:
|
|
10149
|
-
expiresAt:
|
|
10866
|
+
createdAt: z32.string(),
|
|
10867
|
+
updatedAt: z32.string(),
|
|
10868
|
+
expiresAt: z32.string(),
|
|
10869
|
+
acceptedAt: z32.string().optional(),
|
|
10870
|
+
revokedAt: z32.string().optional()
|
|
10871
|
+
});
|
|
10872
|
+
var AuthInvitationDeliverySchema = z32.object({
|
|
10873
|
+
status: z32.enum(["sent", "skipped", "rate_limited", "not_supported"]),
|
|
10874
|
+
link: z32.object({
|
|
10875
|
+
url: z32.string().url(),
|
|
10876
|
+
expiresAt: z32.string().optional()
|
|
10150
10877
|
}).optional()
|
|
10151
10878
|
});
|
|
10152
10879
|
var AuthInvitationGroupOptionSchema = AuthGroupOptionSchema;
|
|
10153
|
-
var AuthAccessTokenKindSchema =
|
|
10154
|
-
var AuthAccessTokenSubjectTypeSchema =
|
|
10155
|
-
var AuthAccessTokenStatusSchema =
|
|
10156
|
-
var AuthServiceAccountStatusSchema =
|
|
10157
|
-
var AuthUserStatusSchema =
|
|
10158
|
-
var AuthAccessTokenSchema =
|
|
10159
|
-
id:
|
|
10160
|
-
name:
|
|
10880
|
+
var AuthAccessTokenKindSchema = z32.enum(["personal", "serviceAccount"]);
|
|
10881
|
+
var AuthAccessTokenSubjectTypeSchema = z32.enum(["user", "serviceAccount"]);
|
|
10882
|
+
var AuthAccessTokenStatusSchema = z32.enum(["active", "expired", "revoked"]);
|
|
10883
|
+
var AuthServiceAccountStatusSchema = z32.enum(["active", "suspended"]);
|
|
10884
|
+
var AuthUserStatusSchema = z32.enum(["active", "suspended"]);
|
|
10885
|
+
var AuthAccessTokenSchema = z32.object({
|
|
10886
|
+
id: z32.string(),
|
|
10887
|
+
name: z32.string(),
|
|
10161
10888
|
kind: AuthAccessTokenKindSchema,
|
|
10162
10889
|
status: AuthAccessTokenStatusSchema,
|
|
10163
10890
|
subjectType: AuthAccessTokenSubjectTypeSchema,
|
|
10164
|
-
subjectId:
|
|
10165
|
-
subjectLabel:
|
|
10166
|
-
groupIds:
|
|
10167
|
-
createdAt:
|
|
10168
|
-
expiresAt:
|
|
10169
|
-
revokedAt:
|
|
10170
|
-
lastUsedAt:
|
|
10171
|
-
lastUsedUserAgent:
|
|
10172
|
-
lastUsedIpAddress:
|
|
10173
|
-
});
|
|
10174
|
-
var AuthServiceAccountSchema =
|
|
10175
|
-
id:
|
|
10176
|
-
name:
|
|
10177
|
-
description:
|
|
10891
|
+
subjectId: z32.string(),
|
|
10892
|
+
subjectLabel: z32.string().optional(),
|
|
10893
|
+
groupIds: z32.array(z32.string()).optional(),
|
|
10894
|
+
createdAt: z32.string(),
|
|
10895
|
+
expiresAt: z32.string(),
|
|
10896
|
+
revokedAt: z32.string().optional(),
|
|
10897
|
+
lastUsedAt: z32.string().optional(),
|
|
10898
|
+
lastUsedUserAgent: z32.string().optional(),
|
|
10899
|
+
lastUsedIpAddress: z32.string().optional()
|
|
10900
|
+
});
|
|
10901
|
+
var AuthServiceAccountSchema = z32.object({
|
|
10902
|
+
id: z32.string(),
|
|
10903
|
+
name: z32.string(),
|
|
10904
|
+
description: z32.string().optional(),
|
|
10178
10905
|
status: AuthServiceAccountStatusSchema,
|
|
10179
|
-
groupIds:
|
|
10180
|
-
createdAt:
|
|
10181
|
-
updatedAt:
|
|
10182
|
-
});
|
|
10183
|
-
var AuthMemberUserSchema =
|
|
10184
|
-
id:
|
|
10185
|
-
email:
|
|
10186
|
-
displayName:
|
|
10187
|
-
avatarUrl:
|
|
10906
|
+
groupIds: z32.array(z32.string()),
|
|
10907
|
+
createdAt: z32.string(),
|
|
10908
|
+
updatedAt: z32.string()
|
|
10909
|
+
});
|
|
10910
|
+
var AuthMemberUserSchema = z32.object({
|
|
10911
|
+
id: z32.string(),
|
|
10912
|
+
email: z32.string(),
|
|
10913
|
+
displayName: z32.string().optional(),
|
|
10914
|
+
avatarUrl: z32.string().optional(),
|
|
10188
10915
|
status: AuthUserStatusSchema,
|
|
10189
|
-
createdAt:
|
|
10190
|
-
updatedAt:
|
|
10916
|
+
createdAt: z32.string(),
|
|
10917
|
+
updatedAt: z32.string()
|
|
10191
10918
|
});
|
|
10192
|
-
var AuthManagedMemberSchema =
|
|
10919
|
+
var AuthManagedMemberSchema = z32.object({
|
|
10193
10920
|
user: AuthMemberUserSchema,
|
|
10194
|
-
groupIds:
|
|
10921
|
+
groupIds: z32.array(z32.string())
|
|
10195
10922
|
});
|
|
10196
|
-
var AuthMemberCapabilitiesSchema =
|
|
10197
|
-
assignGroups:
|
|
10198
|
-
suspend:
|
|
10199
|
-
reactivate:
|
|
10923
|
+
var AuthMemberCapabilitiesSchema = z32.object({
|
|
10924
|
+
assignGroups: z32.boolean(),
|
|
10925
|
+
suspend: z32.boolean(),
|
|
10926
|
+
reactivate: z32.boolean()
|
|
10200
10927
|
});
|
|
10201
10928
|
var AuthMemberSchema = AuthManagedMemberSchema.extend({
|
|
10202
10929
|
capabilities: AuthMemberCapabilitiesSchema
|
|
10203
10930
|
});
|
|
10204
|
-
var GetAuthAccessManagementOptionsResponseSchema =
|
|
10205
|
-
groups:
|
|
10931
|
+
var GetAuthAccessManagementOptionsResponseSchema = z32.object({
|
|
10932
|
+
groups: z32.array(AuthGroupOptionSchema)
|
|
10206
10933
|
});
|
|
10207
|
-
var ListAuthAccessTokensResponseSchema =
|
|
10208
|
-
accessTokens:
|
|
10934
|
+
var ListAuthAccessTokensResponseSchema = z32.object({
|
|
10935
|
+
accessTokens: z32.array(AuthAccessTokenSchema)
|
|
10209
10936
|
});
|
|
10210
|
-
var CreateAuthPersonalAccessTokenBodySchema =
|
|
10211
|
-
name:
|
|
10212
|
-
expiresAt:
|
|
10213
|
-
groupIds:
|
|
10937
|
+
var CreateAuthPersonalAccessTokenBodySchema = z32.object({
|
|
10938
|
+
name: z32.string().trim().min(1),
|
|
10939
|
+
expiresAt: z32.string().min(1),
|
|
10940
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10214
10941
|
});
|
|
10215
|
-
var CreateAuthPersonalAccessTokenResponseSchema =
|
|
10942
|
+
var CreateAuthPersonalAccessTokenResponseSchema = z32.object({
|
|
10216
10943
|
accessToken: AuthAccessTokenSchema,
|
|
10217
|
-
tokenValue:
|
|
10944
|
+
tokenValue: z32.string()
|
|
10218
10945
|
});
|
|
10219
|
-
var RevokeAuthAccessTokenParamsSchema =
|
|
10220
|
-
tokenId:
|
|
10946
|
+
var RevokeAuthAccessTokenParamsSchema = z32.object({
|
|
10947
|
+
tokenId: z32.string().min(1)
|
|
10221
10948
|
});
|
|
10222
|
-
var RevokeAuthAccessTokenResponseSchema =
|
|
10949
|
+
var RevokeAuthAccessTokenResponseSchema = z32.object({
|
|
10223
10950
|
accessToken: AuthAccessTokenSchema
|
|
10224
10951
|
});
|
|
10225
|
-
var ListAuthServiceAccountsResponseSchema =
|
|
10226
|
-
serviceAccounts:
|
|
10952
|
+
var ListAuthServiceAccountsResponseSchema = z32.object({
|
|
10953
|
+
serviceAccounts: z32.array(AuthServiceAccountSchema)
|
|
10227
10954
|
});
|
|
10228
|
-
var CreateAuthServiceAccountBodySchema =
|
|
10229
|
-
id:
|
|
10230
|
-
name:
|
|
10231
|
-
description:
|
|
10232
|
-
groupIds:
|
|
10955
|
+
var CreateAuthServiceAccountBodySchema = z32.object({
|
|
10956
|
+
id: z32.string().trim().min(1).optional(),
|
|
10957
|
+
name: z32.string().trim().min(1),
|
|
10958
|
+
description: z32.string().trim().optional(),
|
|
10959
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10233
10960
|
});
|
|
10234
|
-
var CreateAuthServiceAccountResponseSchema =
|
|
10961
|
+
var CreateAuthServiceAccountResponseSchema = z32.object({
|
|
10235
10962
|
serviceAccount: AuthServiceAccountSchema
|
|
10236
10963
|
});
|
|
10237
|
-
var AuthServiceAccountParamsSchema =
|
|
10238
|
-
serviceAccountId:
|
|
10964
|
+
var AuthServiceAccountParamsSchema = z32.object({
|
|
10965
|
+
serviceAccountId: z32.string().min(1)
|
|
10239
10966
|
});
|
|
10240
|
-
var DisableAuthServiceAccountResponseSchema =
|
|
10967
|
+
var DisableAuthServiceAccountResponseSchema = z32.object({
|
|
10241
10968
|
serviceAccount: AuthServiceAccountSchema
|
|
10242
10969
|
});
|
|
10243
|
-
var ListAuthServiceAccountAccessTokensResponseSchema =
|
|
10244
|
-
accessTokens:
|
|
10970
|
+
var ListAuthServiceAccountAccessTokensResponseSchema = z32.object({
|
|
10971
|
+
accessTokens: z32.array(AuthAccessTokenSchema)
|
|
10245
10972
|
});
|
|
10246
|
-
var CreateAuthServiceAccountAccessTokenBodySchema =
|
|
10247
|
-
name:
|
|
10248
|
-
expiresAt:
|
|
10249
|
-
groupIds:
|
|
10973
|
+
var CreateAuthServiceAccountAccessTokenBodySchema = z32.object({
|
|
10974
|
+
name: z32.string().trim().min(1),
|
|
10975
|
+
expiresAt: z32.string().min(1),
|
|
10976
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10250
10977
|
});
|
|
10251
|
-
var CreateAuthServiceAccountAccessTokenResponseSchema =
|
|
10978
|
+
var CreateAuthServiceAccountAccessTokenResponseSchema = z32.object({
|
|
10252
10979
|
accessToken: AuthAccessTokenSchema,
|
|
10253
|
-
tokenValue:
|
|
10980
|
+
tokenValue: z32.string()
|
|
10254
10981
|
});
|
|
10255
10982
|
var RevokeAuthServiceAccountAccessTokenParamsSchema = AuthServiceAccountParamsSchema.extend({
|
|
10256
|
-
tokenId:
|
|
10983
|
+
tokenId: z32.string().min(1)
|
|
10257
10984
|
});
|
|
10258
|
-
var RevokeAuthServiceAccountAccessTokenResponseSchema =
|
|
10985
|
+
var RevokeAuthServiceAccountAccessTokenResponseSchema = z32.object({
|
|
10259
10986
|
accessToken: AuthAccessTokenSchema
|
|
10260
10987
|
});
|
|
10261
|
-
var AuthCreateInvitationCapabilitySchema =
|
|
10262
|
-
|
|
10263
|
-
state:
|
|
10988
|
+
var AuthCreateInvitationCapabilitySchema = z32.union([
|
|
10989
|
+
z32.object({
|
|
10990
|
+
state: z32.literal("enabled")
|
|
10264
10991
|
}),
|
|
10265
|
-
|
|
10266
|
-
state:
|
|
10267
|
-
reason:
|
|
10992
|
+
z32.object({
|
|
10993
|
+
state: z32.literal("disabled"),
|
|
10994
|
+
reason: z32.enum(["missing_membership_policy", "invitation_delivery_not_supported"])
|
|
10268
10995
|
})
|
|
10269
10996
|
]);
|
|
10270
|
-
var AuthInvitationDestinationSchema =
|
|
10271
|
-
id:
|
|
10272
|
-
label:
|
|
10273
|
-
});
|
|
10274
|
-
var GetAuthInvitationOptionsResponseSchema =
|
|
10275
|
-
groups:
|
|
10276
|
-
destinations:
|
|
10277
|
-
defaultDestinationId:
|
|
10278
|
-
canInviteWithoutGroups:
|
|
10279
|
-
capabilities:
|
|
10997
|
+
var AuthInvitationDestinationSchema = z32.object({
|
|
10998
|
+
id: z32.enum(["atlas", "app"]),
|
|
10999
|
+
label: z32.string()
|
|
11000
|
+
});
|
|
11001
|
+
var GetAuthInvitationOptionsResponseSchema = z32.object({
|
|
11002
|
+
groups: z32.array(AuthInvitationGroupOptionSchema),
|
|
11003
|
+
destinations: z32.array(AuthInvitationDestinationSchema),
|
|
11004
|
+
defaultDestinationId: z32.enum(["atlas", "app"]).optional(),
|
|
11005
|
+
canInviteWithoutGroups: z32.boolean(),
|
|
11006
|
+
capabilities: z32.object({
|
|
10280
11007
|
createInvitation: AuthCreateInvitationCapabilitySchema
|
|
10281
11008
|
})
|
|
10282
11009
|
});
|
|
10283
|
-
var GetAuthMembershipOptionsResponseSchema =
|
|
10284
|
-
groups:
|
|
10285
|
-
capabilities:
|
|
10286
|
-
invite:
|
|
10287
|
-
assignGroups:
|
|
10288
|
-
suspend:
|
|
11010
|
+
var GetAuthMembershipOptionsResponseSchema = z32.object({
|
|
11011
|
+
groups: z32.array(AuthGroupOptionSchema),
|
|
11012
|
+
capabilities: z32.object({
|
|
11013
|
+
invite: z32.boolean(),
|
|
11014
|
+
assignGroups: z32.boolean(),
|
|
11015
|
+
suspend: z32.boolean()
|
|
10289
11016
|
})
|
|
10290
11017
|
});
|
|
10291
|
-
var ListAuthMembersQuerySchema =
|
|
10292
|
-
limit:
|
|
10293
|
-
offset:
|
|
10294
|
-
order:
|
|
11018
|
+
var ListAuthMembersQuerySchema = z32.object({
|
|
11019
|
+
limit: z32.string().optional(),
|
|
11020
|
+
offset: z32.string().optional(),
|
|
11021
|
+
order: z32.enum(["asc", "desc"]).optional()
|
|
10295
11022
|
});
|
|
10296
|
-
var ListAuthMembersResponseSchema =
|
|
10297
|
-
members:
|
|
10298
|
-
hasMore:
|
|
10299
|
-
total:
|
|
11023
|
+
var ListAuthMembersResponseSchema = z32.object({
|
|
11024
|
+
members: z32.array(AuthMemberSchema),
|
|
11025
|
+
hasMore: z32.boolean(),
|
|
11026
|
+
total: z32.number()
|
|
10300
11027
|
});
|
|
10301
|
-
var AuthMemberParamsSchema =
|
|
10302
|
-
userId:
|
|
11028
|
+
var AuthMemberParamsSchema = z32.object({
|
|
11029
|
+
userId: z32.string().min(1)
|
|
10303
11030
|
});
|
|
10304
|
-
var UpdateAuthMemberGroupsBodySchema =
|
|
10305
|
-
groupIds:
|
|
11031
|
+
var UpdateAuthMemberGroupsBodySchema = z32.object({
|
|
11032
|
+
groupIds: z32.array(z32.string().min(1))
|
|
10306
11033
|
});
|
|
10307
|
-
var UpdateAuthMemberGroupsResponseSchema =
|
|
11034
|
+
var UpdateAuthMemberGroupsResponseSchema = z32.object({
|
|
10308
11035
|
member: AuthManagedMemberSchema
|
|
10309
11036
|
});
|
|
10310
|
-
var SuspendAuthMemberResponseSchema =
|
|
11037
|
+
var SuspendAuthMemberResponseSchema = z32.object({
|
|
10311
11038
|
member: AuthManagedMemberSchema
|
|
10312
11039
|
});
|
|
10313
|
-
var ReactivateAuthMemberResponseSchema =
|
|
11040
|
+
var ReactivateAuthMemberResponseSchema = z32.object({
|
|
10314
11041
|
member: AuthManagedMemberSchema
|
|
10315
11042
|
});
|
|
10316
|
-
var CreateAuthInvitationBodySchema =
|
|
10317
|
-
email:
|
|
10318
|
-
groupIds:
|
|
10319
|
-
destinationId:
|
|
10320
|
-
expiresAt:
|
|
10321
|
-
returnTo:
|
|
10322
|
-
revealLink:
|
|
11043
|
+
var CreateAuthInvitationBodySchema = z32.object({
|
|
11044
|
+
email: z32.string().min(1),
|
|
11045
|
+
groupIds: z32.array(z32.string().min(1)).optional(),
|
|
11046
|
+
destinationId: z32.enum(["atlas", "app"]).optional(),
|
|
11047
|
+
expiresAt: z32.string().optional(),
|
|
11048
|
+
returnTo: z32.string().optional(),
|
|
11049
|
+
revealLink: z32.boolean().optional()
|
|
10323
11050
|
});
|
|
10324
|
-
var CreateAuthInvitationResponseSchema =
|
|
11051
|
+
var CreateAuthInvitationResponseSchema = z32.object({
|
|
10325
11052
|
invitation: AuthInvitationSchema,
|
|
10326
11053
|
delivery: AuthInvitationDeliverySchema
|
|
10327
11054
|
});
|
|
10328
|
-
var ListAuthInvitationsQuerySchema =
|
|
10329
|
-
email:
|
|
11055
|
+
var ListAuthInvitationsQuerySchema = z32.object({
|
|
11056
|
+
email: z32.string().optional(),
|
|
10330
11057
|
status: AuthInvitationStatusSchema.optional(),
|
|
10331
|
-
limit:
|
|
10332
|
-
offset:
|
|
10333
|
-
order:
|
|
11058
|
+
limit: z32.string().optional(),
|
|
11059
|
+
offset: z32.string().optional(),
|
|
11060
|
+
order: z32.enum(["asc", "desc"]).optional()
|
|
10334
11061
|
});
|
|
10335
|
-
var ListAuthInvitationsResponseSchema =
|
|
10336
|
-
invitations:
|
|
10337
|
-
hasMore:
|
|
10338
|
-
total:
|
|
11062
|
+
var ListAuthInvitationsResponseSchema = z32.object({
|
|
11063
|
+
invitations: z32.array(AuthInvitationSchema),
|
|
11064
|
+
hasMore: z32.boolean(),
|
|
11065
|
+
total: z32.number()
|
|
10339
11066
|
});
|
|
10340
|
-
var RevokeAuthInvitationParamsSchema =
|
|
10341
|
-
invitationId:
|
|
11067
|
+
var RevokeAuthInvitationParamsSchema = z32.object({
|
|
11068
|
+
invitationId: z32.string().min(1)
|
|
10342
11069
|
});
|
|
10343
|
-
var RevokeAuthInvitationResponseSchema =
|
|
11070
|
+
var RevokeAuthInvitationResponseSchema = z32.object({
|
|
10344
11071
|
invitation: AuthInvitationSchema
|
|
10345
11072
|
});
|
|
10346
|
-
var AuthSessionResponseSchema =
|
|
10347
|
-
|
|
10348
|
-
authenticated:
|
|
11073
|
+
var AuthSessionResponseSchema = z32.union([
|
|
11074
|
+
z32.object({
|
|
11075
|
+
authenticated: z32.literal(false)
|
|
10349
11076
|
}),
|
|
10350
|
-
|
|
10351
|
-
authenticated:
|
|
10352
|
-
csrfToken:
|
|
10353
|
-
applicationAccess:
|
|
10354
|
-
allowed:
|
|
10355
|
-
audience:
|
|
11077
|
+
z32.object({
|
|
11078
|
+
authenticated: z32.literal(true),
|
|
11079
|
+
csrfToken: z32.string(),
|
|
11080
|
+
applicationAccess: z32.object({
|
|
11081
|
+
allowed: z32.boolean(),
|
|
11082
|
+
audience: z32.enum(["atlas", "app"])
|
|
10356
11083
|
}),
|
|
10357
|
-
user:
|
|
10358
|
-
id:
|
|
10359
|
-
email:
|
|
10360
|
-
displayName:
|
|
10361
|
-
avatarUrl:
|
|
10362
|
-
groupIds:
|
|
11084
|
+
user: z32.object({
|
|
11085
|
+
id: z32.string(),
|
|
11086
|
+
email: z32.string(),
|
|
11087
|
+
displayName: z32.string().optional(),
|
|
11088
|
+
avatarUrl: z32.string().optional(),
|
|
11089
|
+
groupIds: z32.array(z32.string())
|
|
10363
11090
|
}),
|
|
10364
|
-
session:
|
|
10365
|
-
id:
|
|
10366
|
-
expiresAt:
|
|
11091
|
+
session: z32.object({
|
|
11092
|
+
id: z32.string(),
|
|
11093
|
+
expiresAt: z32.string()
|
|
10367
11094
|
})
|
|
10368
11095
|
})
|
|
10369
11096
|
]);
|
|
10370
|
-
var AuthSignOutResponseSchema =
|
|
10371
|
-
success:
|
|
10372
|
-
});
|
|
10373
|
-
var CreateDeviceAuthorizationBodySchema =
|
|
10374
|
-
clientName:
|
|
10375
|
-
tokenName:
|
|
10376
|
-
expiresIn:
|
|
10377
|
-
});
|
|
10378
|
-
var CreateDeviceAuthorizationResponseSchema =
|
|
10379
|
-
deviceCode:
|
|
10380
|
-
userCode:
|
|
10381
|
-
verificationUri:
|
|
10382
|
-
verificationUriComplete:
|
|
10383
|
-
expiresAt:
|
|
10384
|
-
interval:
|
|
10385
|
-
});
|
|
10386
|
-
var ExchangeDeviceAuthorizationBodySchema =
|
|
10387
|
-
deviceCode:
|
|
10388
|
-
});
|
|
10389
|
-
var ExchangeDeviceAuthorizationResponseSchema =
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
11097
|
+
var AuthSignOutResponseSchema = z32.object({
|
|
11098
|
+
success: z32.boolean()
|
|
11099
|
+
});
|
|
11100
|
+
var CreateDeviceAuthorizationBodySchema = z32.object({
|
|
11101
|
+
clientName: z32.string().trim().min(1).max(100),
|
|
11102
|
+
tokenName: z32.string().trim().min(1).max(100),
|
|
11103
|
+
expiresIn: z32.literal("90d").optional()
|
|
11104
|
+
});
|
|
11105
|
+
var CreateDeviceAuthorizationResponseSchema = z32.object({
|
|
11106
|
+
deviceCode: z32.string(),
|
|
11107
|
+
userCode: z32.string(),
|
|
11108
|
+
verificationUri: z32.string(),
|
|
11109
|
+
verificationUriComplete: z32.string(),
|
|
11110
|
+
expiresAt: z32.string(),
|
|
11111
|
+
interval: z32.number()
|
|
11112
|
+
});
|
|
11113
|
+
var ExchangeDeviceAuthorizationBodySchema = z32.object({
|
|
11114
|
+
deviceCode: z32.string().min(1)
|
|
11115
|
+
});
|
|
11116
|
+
var ExchangeDeviceAuthorizationResponseSchema = z32.union([
|
|
11117
|
+
z32.object({ status: z32.literal("pending") }),
|
|
11118
|
+
z32.object({ status: z32.literal("denied") }),
|
|
11119
|
+
z32.object({ status: z32.literal("expired") }),
|
|
11120
|
+
z32.object({ status: z32.literal("approved"), accessToken: z32.string() })
|
|
10394
11121
|
]);
|
|
10395
|
-
var DeviceAuthorizationDecisionBodySchema =
|
|
10396
|
-
userCode:
|
|
10397
|
-
decision:
|
|
10398
|
-
csrfToken:
|
|
10399
|
-
});
|
|
10400
|
-
var AuthSessionSummarySchema =
|
|
10401
|
-
id:
|
|
10402
|
-
audience:
|
|
10403
|
-
current:
|
|
10404
|
-
createdAt:
|
|
10405
|
-
expiresAt:
|
|
10406
|
-
lastSeenAt:
|
|
10407
|
-
userAgent:
|
|
10408
|
-
ipAddress:
|
|
10409
|
-
});
|
|
10410
|
-
var ListAuthSessionsResponseSchema =
|
|
10411
|
-
sessions:
|
|
10412
|
-
});
|
|
10413
|
-
var RevokeAuthSessionParamsSchema =
|
|
10414
|
-
sessionId:
|
|
10415
|
-
});
|
|
10416
|
-
var RevokeAuthSessionResponseSchema =
|
|
10417
|
-
success:
|
|
10418
|
-
});
|
|
10419
|
-
var SignOutAllResponseSchema =
|
|
10420
|
-
success:
|
|
10421
|
-
revokedCount:
|
|
11122
|
+
var DeviceAuthorizationDecisionBodySchema = z32.object({
|
|
11123
|
+
userCode: z32.string().trim().min(1),
|
|
11124
|
+
decision: z32.enum(["approve", "deny"]),
|
|
11125
|
+
csrfToken: z32.string().min(1)
|
|
11126
|
+
});
|
|
11127
|
+
var AuthSessionSummarySchema = z32.object({
|
|
11128
|
+
id: z32.string(),
|
|
11129
|
+
audience: z32.enum(["atlas", "app"]),
|
|
11130
|
+
current: z32.boolean(),
|
|
11131
|
+
createdAt: z32.string(),
|
|
11132
|
+
expiresAt: z32.string(),
|
|
11133
|
+
lastSeenAt: z32.string().optional(),
|
|
11134
|
+
userAgent: z32.string().optional(),
|
|
11135
|
+
ipAddress: z32.string().optional()
|
|
11136
|
+
});
|
|
11137
|
+
var ListAuthSessionsResponseSchema = z32.object({
|
|
11138
|
+
sessions: z32.array(AuthSessionSummarySchema)
|
|
11139
|
+
});
|
|
11140
|
+
var RevokeAuthSessionParamsSchema = z32.object({
|
|
11141
|
+
sessionId: z32.string().min(1)
|
|
11142
|
+
});
|
|
11143
|
+
var RevokeAuthSessionResponseSchema = z32.object({
|
|
11144
|
+
success: z32.boolean()
|
|
11145
|
+
});
|
|
11146
|
+
var SignOutAllResponseSchema = z32.object({
|
|
11147
|
+
success: z32.boolean(),
|
|
11148
|
+
revokedCount: z32.number()
|
|
10422
11149
|
});
|
|
10423
11150
|
|
|
10424
11151
|
// src/routes/auth.ts
|
|
@@ -10584,7 +11311,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10584
11311
|
}
|
|
10585
11312
|
const csrfHeaders = new Headers(request.headers);
|
|
10586
11313
|
csrfHeaders.set("x-sixb-csrf", parsed.csrfToken);
|
|
10587
|
-
if (!
|
|
11314
|
+
if (!verifyDoubleSubmitCsrf3(new Request(request.url, { method: "POST", headers: csrfHeaders }), {
|
|
10588
11315
|
cookieName: host.auth.getCookieOptions(authOptions).csrfCookieName
|
|
10589
11316
|
})) {
|
|
10590
11317
|
return authPageResponse("<h1>Invalid authorization request</h1>", 403);
|
|
@@ -10679,7 +11406,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10679
11406
|
const authOptions = resolveAuthOptions(options, request);
|
|
10680
11407
|
const session = await host.auth.getSession(request, authOptions);
|
|
10681
11408
|
const cookieOptions = host.auth.getCookieOptions(authOptions);
|
|
10682
|
-
if (session.authenticated && !
|
|
11409
|
+
if (session.authenticated && !verifyDoubleSubmitCsrf3(request, {
|
|
10683
11410
|
cookieName: cookieOptions.csrfCookieName
|
|
10684
11411
|
})) {
|
|
10685
11412
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
@@ -10750,7 +11477,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10750
11477
|
if (!session.authenticated) {
|
|
10751
11478
|
return jsonResponse2({ error: "Authentication required" }, 401);
|
|
10752
11479
|
}
|
|
10753
|
-
if (!
|
|
11480
|
+
if (!verifyDoubleSubmitCsrf3(request, { cookieName: cookieOptions.csrfCookieName })) {
|
|
10754
11481
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
10755
11482
|
}
|
|
10756
11483
|
const { sessionId } = RevokeAuthSessionParamsSchema.parse(params);
|
|
@@ -10788,7 +11515,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10788
11515
|
if (!session.authenticated) {
|
|
10789
11516
|
return jsonResponse2({ error: "Authentication required" }, 401);
|
|
10790
11517
|
}
|
|
10791
|
-
if (!
|
|
11518
|
+
if (!verifyDoubleSubmitCsrf3(request, { cookieName: cookieOptions.csrfCookieName })) {
|
|
10792
11519
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
10793
11520
|
}
|
|
10794
11521
|
const revoked = await requireAuthStorage(host).sessions.revokeActiveForUser({
|
|
@@ -11416,7 +12143,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
11416
12143
|
requesterHash: pending.hash
|
|
11417
12144
|
});
|
|
11418
12145
|
const response = await magicLinkRequestedResponse(options, authRedirect);
|
|
11419
|
-
const existingPending =
|
|
12146
|
+
const existingPending = getCookie4(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
11420
12147
|
response.headers.append("set-cookie", magicLinkPendingCookieHeader({
|
|
11421
12148
|
request,
|
|
11422
12149
|
host,
|
|
@@ -11497,7 +12224,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
11497
12224
|
}
|
|
11498
12225
|
}
|
|
11499
12226
|
const requesterHash = url.searchParams.get("requester")?.trim();
|
|
11500
|
-
const pendingSecret =
|
|
12227
|
+
const pendingSecret = getCookie4(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
11501
12228
|
if (requesterHash && pendingSecret && matchesMagicLinkRequester(pendingSecret, requesterHash)) {
|
|
11502
12229
|
return completeMagicLinkCallback({
|
|
11503
12230
|
host,
|
|
@@ -11587,7 +12314,7 @@ var DEVICE_ACCESS_TOKEN_TTL_MS = 90 * 24 * 60 * 60 * 1000;
|
|
|
11587
12314
|
var DEVICE_AUTHORIZATION_POLL_INTERVAL_SECONDS = 2;
|
|
11588
12315
|
var DEVICE_USER_CODE_ALPHABET = "BCDFGHJKLMNPQRSTVWXYZ23456789";
|
|
11589
12316
|
function hashDeviceCode(deviceCode) {
|
|
11590
|
-
return
|
|
12317
|
+
return createHash3("sha256").update(deviceCode).digest("base64url");
|
|
11591
12318
|
}
|
|
11592
12319
|
function parseDeviceAuthorizationId(deviceCode) {
|
|
11593
12320
|
const separator = deviceCode.indexOf(".");
|
|
@@ -11617,7 +12344,7 @@ function createMagicLinkPendingCredential() {
|
|
|
11617
12344
|
return { secret, hash: hashMagicLinkPendingSecret(secret) };
|
|
11618
12345
|
}
|
|
11619
12346
|
function hashMagicLinkPendingSecret(secret) {
|
|
11620
|
-
return
|
|
12347
|
+
return createHash3("sha256").update(secret).digest("base64url");
|
|
11621
12348
|
}
|
|
11622
12349
|
function matchesMagicLinkRequester(pendingSecret, requesterHash) {
|
|
11623
12350
|
const expected = Buffer.from(hashMagicLinkPendingSecret(pendingSecret));
|
|
@@ -11698,7 +12425,7 @@ function sessionCallbackCompletionResponse(input) {
|
|
|
11698
12425
|
}));
|
|
11699
12426
|
headers.append("set-cookie", createCsrfCookieHeader2({
|
|
11700
12427
|
request: input.request,
|
|
11701
|
-
value:
|
|
12428
|
+
value: generateCsrfToken3(),
|
|
11702
12429
|
expiresAt: input.expiresAt,
|
|
11703
12430
|
options: cookieOptions
|
|
11704
12431
|
}));
|
|
@@ -11758,11 +12485,11 @@ function resolveInvitationDeliveryContext(options, request, input) {
|
|
|
11758
12485
|
}
|
|
11759
12486
|
}
|
|
11760
12487
|
function resolveSessionCsrfToken(input) {
|
|
11761
|
-
const existing =
|
|
12488
|
+
const existing = getCookie4(input.request, input.cookieOptions.csrfCookieName);
|
|
11762
12489
|
if (existing) {
|
|
11763
12490
|
return { token: existing };
|
|
11764
12491
|
}
|
|
11765
|
-
const token =
|
|
12492
|
+
const token = generateCsrfToken3();
|
|
11766
12493
|
return {
|
|
11767
12494
|
token,
|
|
11768
12495
|
setCookie: createCsrfCookieHeader2({
|
|
@@ -12242,7 +12969,7 @@ function jsonResponse2(body, status, headersInit) {
|
|
|
12242
12969
|
}
|
|
12243
12970
|
|
|
12244
12971
|
// src/routes/webhooks.ts
|
|
12245
|
-
import { createHash as
|
|
12972
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
12246
12973
|
import { reportRunFailure } from "@sixb/core/internal/error-reporting";
|
|
12247
12974
|
import { captureSixbFailure, createSixbError as createSixbError5, toSixbFailure as toSixbFailure2 } from "@sixb/core/internal/errors";
|
|
12248
12975
|
import { bindDurablePrimitiveExecution } from "@sixb/core/internal/primitive-execution";
|
|
@@ -12351,7 +13078,7 @@ async function admitPreparedWebhook(options, runId, prepared) {
|
|
|
12351
13078
|
method: options.request.method.toUpperCase(),
|
|
12352
13079
|
route: options.registered.route,
|
|
12353
13080
|
requestBodyBytes: prepared.rawBody.byteLength,
|
|
12354
|
-
requestBodySha256:
|
|
13081
|
+
requestBodySha256: createHash4("sha256").update(prepared.rawBody).digest("hex"),
|
|
12355
13082
|
idempotencyKey: prepared.idempotencyKey
|
|
12356
13083
|
});
|
|
12357
13084
|
} catch (error) {
|
|
@@ -12537,7 +13264,7 @@ import {
|
|
|
12537
13264
|
isAgentRunActivityEvent
|
|
12538
13265
|
} from "@sixb/core/agents/streams";
|
|
12539
13266
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
12540
|
-
import { z as
|
|
13267
|
+
import { z as z33 } from "zod";
|
|
12541
13268
|
|
|
12542
13269
|
// src/utils/ws.ts
|
|
12543
13270
|
function safeSend(target, payload) {
|
|
@@ -12585,25 +13312,25 @@ async function decodeWsMessage(message) {
|
|
|
12585
13312
|
}
|
|
12586
13313
|
|
|
12587
13314
|
// src/routes/ws/agents.ts
|
|
12588
|
-
var SubscribeSchema =
|
|
12589
|
-
type:
|
|
12590
|
-
runId:
|
|
12591
|
-
afterCursor:
|
|
13315
|
+
var SubscribeSchema = z33.object({
|
|
13316
|
+
type: z33.literal("subscribe"),
|
|
13317
|
+
runId: z33.string().min(1),
|
|
13318
|
+
afterCursor: z33.string().min(1).optional()
|
|
12592
13319
|
});
|
|
12593
|
-
var SubscribeActivitySchema =
|
|
12594
|
-
type:
|
|
13320
|
+
var SubscribeActivitySchema = z33.object({
|
|
13321
|
+
type: z33.literal("subscribe.activity")
|
|
12595
13322
|
});
|
|
12596
|
-
var ReplaySchema =
|
|
12597
|
-
type:
|
|
12598
|
-
runId:
|
|
12599
|
-
afterCursor:
|
|
12600
|
-
limit:
|
|
13323
|
+
var ReplaySchema = z33.object({
|
|
13324
|
+
type: z33.literal("replay"),
|
|
13325
|
+
runId: z33.string().min(1),
|
|
13326
|
+
afterCursor: z33.string().min(1).optional(),
|
|
13327
|
+
limit: z33.number().int().positive().max(500).optional()
|
|
12601
13328
|
});
|
|
12602
|
-
var UnsubscribeSchema =
|
|
12603
|
-
type:
|
|
12604
|
-
runId:
|
|
13329
|
+
var UnsubscribeSchema = z33.object({
|
|
13330
|
+
type: z33.literal("unsubscribe"),
|
|
13331
|
+
runId: z33.string().min(1).optional()
|
|
12605
13332
|
});
|
|
12606
|
-
var AgentStreamMessageSchema =
|
|
13333
|
+
var AgentStreamMessageSchema = z33.union([
|
|
12607
13334
|
SubscribeSchema,
|
|
12608
13335
|
SubscribeActivitySchema,
|
|
12609
13336
|
ReplaySchema,
|
|
@@ -12900,22 +13627,22 @@ function errorMessage(error) {
|
|
|
12900
13627
|
|
|
12901
13628
|
// src/routes/ws/events.ts
|
|
12902
13629
|
import { scopeKeysForEvent } from "@sixb/core/events/scope";
|
|
12903
|
-
import { z as
|
|
12904
|
-
var SubscribeSchema2 =
|
|
12905
|
-
type:
|
|
12906
|
-
topic:
|
|
12907
|
-
types:
|
|
12908
|
-
objectTypeId:
|
|
12909
|
-
primaryId:
|
|
12910
|
-
actionId:
|
|
12911
|
-
runId:
|
|
12912
|
-
afterCursor:
|
|
12913
|
-
limit:
|
|
12914
|
-
});
|
|
12915
|
-
var UnsubscribeSchema2 =
|
|
12916
|
-
type:
|
|
12917
|
-
});
|
|
12918
|
-
var SubscriptionMessageSchema =
|
|
13630
|
+
import { z as z34 } from "zod";
|
|
13631
|
+
var SubscribeSchema2 = z34.object({
|
|
13632
|
+
type: z34.literal("subscribe"),
|
|
13633
|
+
topic: z34.enum(EVENT_TOPICS).optional(),
|
|
13634
|
+
types: z34.array(z34.enum(EVENT_TYPES)).optional(),
|
|
13635
|
+
objectTypeId: z34.string().optional(),
|
|
13636
|
+
primaryId: z34.string().optional(),
|
|
13637
|
+
actionId: z34.string().optional(),
|
|
13638
|
+
runId: z34.string().optional(),
|
|
13639
|
+
afterCursor: z34.string().optional(),
|
|
13640
|
+
limit: z34.number().int().positive().max(500).optional()
|
|
13641
|
+
});
|
|
13642
|
+
var UnsubscribeSchema2 = z34.object({
|
|
13643
|
+
type: z34.literal("unsubscribe")
|
|
13644
|
+
});
|
|
13645
|
+
var SubscriptionMessageSchema = z34.union([SubscribeSchema2, UnsubscribeSchema2]);
|
|
12919
13646
|
function parseSubscriptionMessage(payload) {
|
|
12920
13647
|
if (!payload || typeof payload !== "object") {
|
|
12921
13648
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -13105,7 +13832,7 @@ function eventMatchesScope(event, filter) {
|
|
|
13105
13832
|
}
|
|
13106
13833
|
|
|
13107
13834
|
// src/routes/ws/logs.ts
|
|
13108
|
-
import { z as
|
|
13835
|
+
import { z as z35 } from "zod";
|
|
13109
13836
|
|
|
13110
13837
|
// src/routes/ws/log-subscription-hub.ts
|
|
13111
13838
|
import { BrokerCursorExpiredError as BrokerCursorExpiredError2 } from "@sixb/core/broker";
|
|
@@ -13418,26 +14145,26 @@ function socketBufferedAmount(ws) {
|
|
|
13418
14145
|
}
|
|
13419
14146
|
|
|
13420
14147
|
// src/routes/ws/logs.ts
|
|
13421
|
-
var SubscribeSchema3 =
|
|
13422
|
-
type:
|
|
13423
|
-
kinds:
|
|
13424
|
-
levels:
|
|
13425
|
-
run:
|
|
13426
|
-
kind:
|
|
14148
|
+
var SubscribeSchema3 = z35.object({
|
|
14149
|
+
type: z35.literal("subscribe"),
|
|
14150
|
+
kinds: z35.array(z35.enum(SIXB_RUN_KINDS)).min(1).optional(),
|
|
14151
|
+
levels: z35.array(z35.enum(LOG_LEVELS)).min(1).optional(),
|
|
14152
|
+
run: z35.object({
|
|
14153
|
+
kind: z35.enum(SIXB_RUN_KINDS),
|
|
13427
14154
|
id: LogRunIdSchema
|
|
13428
14155
|
}).optional(),
|
|
13429
|
-
afterCursor:
|
|
14156
|
+
afterCursor: z35.string().optional()
|
|
13430
14157
|
}).superRefine((value, context) => {
|
|
13431
14158
|
if (value.run && value.kinds && !value.kinds.includes(value.run.kind)) {
|
|
13432
14159
|
context.addIssue({
|
|
13433
|
-
code:
|
|
14160
|
+
code: z35.ZodIssueCode.custom,
|
|
13434
14161
|
path: ["run"],
|
|
13435
14162
|
message: "run.kind must be included in kinds"
|
|
13436
14163
|
});
|
|
13437
14164
|
}
|
|
13438
14165
|
});
|
|
13439
|
-
var UnsubscribeSchema3 =
|
|
13440
|
-
var SubscriptionMessageSchema2 =
|
|
14166
|
+
var UnsubscribeSchema3 = z35.object({ type: z35.literal("unsubscribe") });
|
|
14167
|
+
var SubscriptionMessageSchema2 = z35.union([SubscribeSchema3, UnsubscribeSchema3]);
|
|
13441
14168
|
function parseLogSubscriptionMessage(payload) {
|
|
13442
14169
|
if (!payload || typeof payload !== "object") {
|
|
13443
14170
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -13539,6 +14266,7 @@ class SixbServer {
|
|
|
13539
14266
|
authContextResolver;
|
|
13540
14267
|
authRedirectContextResolver;
|
|
13541
14268
|
authExperience;
|
|
14269
|
+
sharedAccessOptions;
|
|
13542
14270
|
app = null;
|
|
13543
14271
|
bunServer = null;
|
|
13544
14272
|
maintenance = null;
|
|
@@ -13551,6 +14279,7 @@ class SixbServer {
|
|
|
13551
14279
|
this.authContextResolver = createApiBrowserAuthContextResolver(this.apiBrowserPolicy);
|
|
13552
14280
|
this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(this.apiBrowserPolicy);
|
|
13553
14281
|
this.authExperience = options.authExperience;
|
|
14282
|
+
this.sharedAccessOptions = options.sharedAccess ?? {};
|
|
13554
14283
|
}
|
|
13555
14284
|
getHost() {
|
|
13556
14285
|
return this.hostRuntime;
|
|
@@ -13579,6 +14308,9 @@ class SixbServer {
|
|
|
13579
14308
|
getAuthExperience() {
|
|
13580
14309
|
return this.authExperience;
|
|
13581
14310
|
}
|
|
14311
|
+
getSharedAccessOptions() {
|
|
14312
|
+
return this.sharedAccessOptions;
|
|
14313
|
+
}
|
|
13582
14314
|
async start() {
|
|
13583
14315
|
if (this.app !== null || this.bunServer !== null || this.maintenance !== null) {
|
|
13584
14316
|
throw new Error("[SixbServer] Server is already running.");
|
|
@@ -13625,6 +14357,8 @@ function createSixbApi(server) {
|
|
|
13625
14357
|
host,
|
|
13626
14358
|
resolveAuthContext: (request) => server.resolveAuthContext(request)
|
|
13627
14359
|
});
|
|
14360
|
+
const sharedAccess = new SharedAccessBoundary(host, server.getSharedAccessOptions());
|
|
14361
|
+
const preparedSharedAccess = new WeakMap;
|
|
13628
14362
|
guard.assertCanServeHttp({ production: true });
|
|
13629
14363
|
const apiBrowserPolicy = server.getApiBrowserPolicy();
|
|
13630
14364
|
const app = new Elysia;
|
|
@@ -13641,18 +14375,55 @@ function createSixbApi(server) {
|
|
|
13641
14375
|
allowedHeaders: [
|
|
13642
14376
|
"authorization",
|
|
13643
14377
|
"content-type",
|
|
13644
|
-
|
|
13645
|
-
SESSION_ACTIVITY_HEADER_NAME
|
|
14378
|
+
CSRF_HEADER_NAME3,
|
|
14379
|
+
SESSION_ACTIVITY_HEADER_NAME,
|
|
14380
|
+
SHARED_ACCESS_GRANT_HEADER_NAME
|
|
13646
14381
|
],
|
|
13647
14382
|
exposeHeaders: [CSRF_TOKEN_RESPONSE_HEADER_NAME],
|
|
13648
14383
|
maxAge: 600
|
|
13649
14384
|
}));
|
|
14385
|
+
app.onRequest(async ({ request, set }) => {
|
|
14386
|
+
const shared = await sharedAccess.resolveRequest(request);
|
|
14387
|
+
preparedSharedAccess.set(request, shared);
|
|
14388
|
+
if (shared.kind === "allow") {
|
|
14389
|
+
setResponseHeader2(set, "cache-control", "no-store");
|
|
14390
|
+
}
|
|
14391
|
+
return shared.kind === "deny" ? shared.response : undefined;
|
|
14392
|
+
});
|
|
13650
14393
|
app.derive(async ({ request }) => {
|
|
14394
|
+
const shared = preparedSharedAccess.get(request) ?? await sharedAccess.resolveRequest(request);
|
|
14395
|
+
preparedSharedAccess.delete(request);
|
|
14396
|
+
if (shared.kind === "deny") {
|
|
14397
|
+
return {
|
|
14398
|
+
auth: { kind: "deny", response: shared.response },
|
|
14399
|
+
sharedAccessCookies: null,
|
|
14400
|
+
sixb: null
|
|
14401
|
+
};
|
|
14402
|
+
}
|
|
14403
|
+
if (shared.kind === "allow") {
|
|
14404
|
+
return {
|
|
14405
|
+
auth: { kind: "allow", session: null },
|
|
14406
|
+
sharedAccessCookies: shared.cookies,
|
|
14407
|
+
sixb: bindRequestExecution(host, {
|
|
14408
|
+
request,
|
|
14409
|
+
authorization: {
|
|
14410
|
+
type: "delegated",
|
|
14411
|
+
access: shared.context.access,
|
|
14412
|
+
delegation: {
|
|
14413
|
+
kind: "share",
|
|
14414
|
+
grantId: shared.context.grantId,
|
|
14415
|
+
sessionId: shared.context.sessionId
|
|
14416
|
+
}
|
|
14417
|
+
}
|
|
14418
|
+
})
|
|
14419
|
+
};
|
|
14420
|
+
}
|
|
13651
14421
|
const internalAuthState = consumeInternalRequestAuthState(request);
|
|
13652
14422
|
if (internalAuthState) {
|
|
13653
14423
|
const { authorization, ...agentState } = internalAuthState;
|
|
13654
14424
|
return {
|
|
13655
14425
|
auth: { kind: "allow", session: null },
|
|
14426
|
+
sharedAccessCookies: null,
|
|
13656
14427
|
...agentState,
|
|
13657
14428
|
sixb: bindRequestExecution(host, {
|
|
13658
14429
|
request,
|
|
@@ -13664,6 +14435,7 @@ function createSixbApi(server) {
|
|
|
13664
14435
|
if (auth.kind === "deny" || !auth.session?.authenticated) {
|
|
13665
14436
|
return {
|
|
13666
14437
|
auth,
|
|
14438
|
+
sharedAccessCookies: null,
|
|
13667
14439
|
sixb: auth.kind === "allow" && !guard.isAuthEnabled() ? bindRequestExecution(host, {
|
|
13668
14440
|
request,
|
|
13669
14441
|
authorization: { type: "disabled" }
|
|
@@ -13674,12 +14446,30 @@ function createSixbApi(server) {
|
|
|
13674
14446
|
const credential = auth.session.credentialSource === "session" ? { type: "session", id: auth.session.session.id } : { type: "accessToken", id: auth.session.accessToken.id };
|
|
13675
14447
|
return {
|
|
13676
14448
|
auth,
|
|
14449
|
+
sharedAccessCookies: null,
|
|
13677
14450
|
sixb: bindRequestExecution(host, {
|
|
13678
14451
|
request,
|
|
13679
14452
|
authorization: { type: "principal", context: authz, credential }
|
|
13680
14453
|
})
|
|
13681
14454
|
};
|
|
13682
|
-
}).onBeforeHandle(({ auth }) => auth.kind === "deny" ? auth.response : undefined).mapResponse(({ auth, request, set }) => {
|
|
14455
|
+
}).onBeforeHandle(({ auth }) => auth.kind === "deny" ? auth.response : undefined).mapResponse(({ auth, request, responseValue, set, sharedAccessCookies }) => {
|
|
14456
|
+
if (sharedAccessCookies) {
|
|
14457
|
+
if (sharedAccessCookies.setCookies.length > 0) {
|
|
14458
|
+
appendSetCookieHeaders(set, sharedAccessCookies.setCookies);
|
|
14459
|
+
}
|
|
14460
|
+
setResponseHeader2(set, CSRF_TOKEN_RESPONSE_HEADER_NAME, sharedAccessCookies.csrfToken);
|
|
14461
|
+
setResponseHeader2(set, "cache-control", "no-store");
|
|
14462
|
+
if (responseValue instanceof Response) {
|
|
14463
|
+
const headers = new Headers(responseValue.headers);
|
|
14464
|
+
headers.set("cache-control", "no-store");
|
|
14465
|
+
return new Response(responseValue.body, {
|
|
14466
|
+
status: responseValue.status,
|
|
14467
|
+
statusText: responseValue.statusText,
|
|
14468
|
+
headers
|
|
14469
|
+
});
|
|
14470
|
+
}
|
|
14471
|
+
return;
|
|
14472
|
+
}
|
|
13683
14473
|
if (!auth || auth.kind !== "allow" || auth.session?.credentialSource !== "session" || auth.session.sessionRenewed !== true) {
|
|
13684
14474
|
return;
|
|
13685
14475
|
}
|
|
@@ -13706,7 +14496,8 @@ function createSixbApi(server) {
|
|
|
13706
14496
|
components: {
|
|
13707
14497
|
securitySchemes: {
|
|
13708
14498
|
[SIXB_CSRF_SECURITY_SCHEME_ID]: SIXB_CSRF_SECURITY_SCHEME,
|
|
13709
|
-
[SIXB_BEARER_SECURITY_SCHEME_ID]: SIXB_BEARER_SECURITY_SCHEME
|
|
14499
|
+
[SIXB_BEARER_SECURITY_SCHEME_ID]: SIXB_BEARER_SECURITY_SCHEME,
|
|
14500
|
+
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: SIXB_SHARED_GRANT_SECURITY_SCHEME
|
|
13710
14501
|
},
|
|
13711
14502
|
schemas: ObjectQueryOpenApiSchemas
|
|
13712
14503
|
},
|
|
@@ -13732,6 +14523,7 @@ function createSixbApi(server) {
|
|
|
13732
14523
|
resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
|
|
13733
14524
|
});
|
|
13734
14525
|
registerHttpRoutes(app, host, {
|
|
14526
|
+
sharedAccess,
|
|
13735
14527
|
connectorConnections: {
|
|
13736
14528
|
resolveReturnTo: (request, returnTo) => {
|
|
13737
14529
|
const authContext = server.resolveAuthContext(request);
|
|
@@ -13820,4 +14612,4 @@ export {
|
|
|
13820
14612
|
SixbServer
|
|
13821
14613
|
};
|
|
13822
14614
|
|
|
13823
|
-
//# debugId=
|
|
14615
|
+
//# debugId=35CC7331BF77216F64756E2164756E21
|