@sixb/server 0.1.7 → 0.1.9
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 +1454 -658
- package/dist/index.js.map +25 -20
- 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/files.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +3 -3
- 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 +7 -7
- package/dist/routes/ws/agents.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/schemas/agents.d.ts +22 -30
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +332 -24
- package/dist/schemas/ai-accounting.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +40 -40
- package/dist/schemas/common.d.ts +6 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/datasets.d.ts +28 -22
- package/dist/schemas/datasets.d.ts.map +1 -1
- package/dist/schemas/logs.d.ts +24 -24
- 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 +20 -20
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/package.json +7 -7
- 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/agents.ts +1 -1
- package/src/routes/files.ts +2 -6
- package/src/routes/share-grants.ts +238 -0
- package/src/routes/shared-access.ts +165 -0
- package/src/routes/ws/agents.ts +5 -3
- package/src/routes/ws/events.ts +1 -1
- package/src/schemas/agents.ts +1 -4
- package/src/schemas/ai-accounting.ts +3 -0
- package/src/schemas/common.ts +2 -0
- 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) {
|
|
@@ -1109,6 +1417,8 @@ function sixbFailureSchema(codes) {
|
|
|
1109
1417
|
retryable: z.boolean(),
|
|
1110
1418
|
at: z.string().datetime(),
|
|
1111
1419
|
details: JsonValueSchema.optional(),
|
|
1420
|
+
httpStatus: z.number().int().min(100).max(599).optional(),
|
|
1421
|
+
redacted: z.literal(true).optional(),
|
|
1112
1422
|
truncated: z.literal(true).optional()
|
|
1113
1423
|
});
|
|
1114
1424
|
}
|
|
@@ -1735,7 +2045,7 @@ function serializeAction(action) {
|
|
|
1735
2045
|
id: action.id,
|
|
1736
2046
|
name: action.id,
|
|
1737
2047
|
description: action.description,
|
|
1738
|
-
...action.binding.kind === "object" ? { objectTypeId: action.binding.
|
|
2048
|
+
...action.binding.kind === "object" ? { objectTypeId: action.binding.objectTypeId } : {},
|
|
1739
2049
|
params: Object.entries(action.params).map(([id, config]) => ({
|
|
1740
2050
|
id,
|
|
1741
2051
|
name: id,
|
|
@@ -1745,12 +2055,7 @@ function serializeAction(action) {
|
|
|
1745
2055
|
description: config.description,
|
|
1746
2056
|
semanticType: config.semanticType
|
|
1747
2057
|
})),
|
|
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
|
-
}
|
|
2058
|
+
phases: action.phases
|
|
1754
2059
|
});
|
|
1755
2060
|
}
|
|
1756
2061
|
function serializeActionDetail(action, host) {
|
|
@@ -1836,7 +2141,7 @@ import {
|
|
|
1836
2141
|
resolveAgentExecutionAuthorization,
|
|
1837
2142
|
resolveInheritedAgentExecutionAuthorization
|
|
1838
2143
|
} from "@sixb/core/internal/agents";
|
|
1839
|
-
import { normalizeRoutePath as
|
|
2144
|
+
import { normalizeRoutePath as normalizeRoutePath3, pathSegmentsFor } from "@sixb/core/internal/http";
|
|
1840
2145
|
|
|
1841
2146
|
// src/routes/files.ts
|
|
1842
2147
|
import {
|
|
@@ -1845,11 +2150,8 @@ import {
|
|
|
1845
2150
|
SYSTEM_PRINCIPAL
|
|
1846
2151
|
} from "@sixb/core";
|
|
1847
2152
|
import { computeBlobDigest, supportsDirectUpload } from "@sixb/core/blob-storage/server";
|
|
1848
|
-
import {
|
|
1849
|
-
|
|
1850
|
-
createUploadExpiresAt,
|
|
1851
|
-
FileUploadSessionError as FileUploadSessionError2
|
|
1852
|
-
} from "@sixb/core/storage";
|
|
2153
|
+
import { createFileUploadId, createUploadExpiresAt } from "@sixb/core/internal/storage";
|
|
2154
|
+
import { FileUploadSessionError as FileUploadSessionError2 } from "@sixb/core/storage";
|
|
1853
2155
|
var DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES = DEFAULT_SIMPLE_FILE_UPLOAD_BYTES + 1024 * 1024;
|
|
1854
2156
|
function registerFileRoutes(app, host) {
|
|
1855
2157
|
const uploadSessions = host.storage.fileUploadSessions ?? new InMemoryFileUploadSessions;
|
|
@@ -2450,13 +2752,13 @@ function toGatewayRunState(storedRun, workflowRun) {
|
|
|
2450
2752
|
};
|
|
2451
2753
|
}
|
|
2452
2754
|
if (storedRun?.kind === "conversation") {
|
|
2453
|
-
const
|
|
2755
|
+
const common = {
|
|
2454
2756
|
run: storedRun,
|
|
2455
2757
|
runId: storedRun.id,
|
|
2456
2758
|
agentExecution: { kind: "conversation", runId: storedRun.id },
|
|
2457
2759
|
agentRun: storedRun
|
|
2458
2760
|
};
|
|
2459
|
-
return { ...
|
|
2761
|
+
return { ...common, authority: "inherited" };
|
|
2460
2762
|
}
|
|
2461
2763
|
if (!workflowRun)
|
|
2462
2764
|
return null;
|
|
@@ -2469,19 +2771,19 @@ function toGatewayRunState(storedRun, workflowRun) {
|
|
|
2469
2771
|
}
|
|
2470
2772
|
async function resolveGatewayRunAuthorization(input) {
|
|
2471
2773
|
if (input.runState.authority === "inherited") {
|
|
2472
|
-
const
|
|
2774
|
+
const resolved = await resolveInheritedAgentExecutionAuthorization({
|
|
2473
2775
|
auth: input.auth,
|
|
2474
2776
|
projectId: input.host.id,
|
|
2475
2777
|
authorizationRef: input.execution.authorizationRef,
|
|
2476
2778
|
security: input.host.definitions.security
|
|
2477
2779
|
});
|
|
2478
|
-
const
|
|
2780
|
+
const authorization = inheritedRequestAuthorization(resolved, input.execution.authorizationRef);
|
|
2479
2781
|
assertAgentExecutionRecord({
|
|
2480
2782
|
execution: input.execution,
|
|
2481
2783
|
runId: input.runState.runId,
|
|
2482
|
-
authorization
|
|
2784
|
+
authorization
|
|
2483
2785
|
});
|
|
2484
|
-
return
|
|
2786
|
+
return authorization;
|
|
2485
2787
|
}
|
|
2486
2788
|
const resolved = await resolveAgentExecutionAuthorization({
|
|
2487
2789
|
auth: input.auth,
|
|
@@ -2513,7 +2815,7 @@ function gatewayUpstreamPath(pathname) {
|
|
|
2513
2815
|
const prefixLength = pathSegmentsFor(AGENT_API_GATEWAY_PREFIX2).length;
|
|
2514
2816
|
const segments = pathSegmentsFor(pathname);
|
|
2515
2817
|
const upstreamSegments = segments.slice(prefixLength + 2);
|
|
2516
|
-
return
|
|
2818
|
+
return normalizeRoutePath3(`/${upstreamSegments.join("/")}`);
|
|
2517
2819
|
}
|
|
2518
2820
|
function forwardedRequestHeaders(source) {
|
|
2519
2821
|
const headers = new Headers;
|
|
@@ -2558,7 +2860,7 @@ async function readRequestBody(request, maxBytes) {
|
|
|
2558
2860
|
return concatChunks(chunks, total);
|
|
2559
2861
|
}
|
|
2560
2862
|
function isSimpleFileUpload(method, pathname) {
|
|
2561
|
-
return method === "POST" &&
|
|
2863
|
+
return method === "POST" && normalizeRoutePath3(pathname) === "/api/files";
|
|
2562
2864
|
}
|
|
2563
2865
|
function matchesWorkflowRunStart(pathname) {
|
|
2564
2866
|
const segments = pathSegmentsFor(pathname);
|
|
@@ -2583,8 +2885,8 @@ class PayloadTooLargeError extends Error {
|
|
|
2583
2885
|
|
|
2584
2886
|
// src/routes/agents.ts
|
|
2585
2887
|
import { AgentRequestError } from "@sixb/core";
|
|
2586
|
-
import { agentRunStreamId } from "@sixb/core/agents/streams";
|
|
2587
2888
|
import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/internal/agents";
|
|
2889
|
+
import { agentRunStreamId } from "@sixb/core/internal/agents/streams";
|
|
2588
2890
|
import {
|
|
2589
2891
|
AgentStorageError
|
|
2590
2892
|
} from "@sixb/core/storage";
|
|
@@ -2818,6 +3120,9 @@ var AiModelCallUsageRecordSchema = z8.object({
|
|
|
2818
3120
|
var AiModelCallAccountingItemSchema = z8.object({
|
|
2819
3121
|
usage: AiModelCallUsageRecordSchema,
|
|
2820
3122
|
attribution: z8.discriminatedUnion("kind", [
|
|
3123
|
+
z8.object({ kind: z8.literal("request"), requestId: z8.string() }),
|
|
3124
|
+
z8.object({ kind: z8.literal("action"), actionId: z8.string(), actionRunId: z8.string() }),
|
|
3125
|
+
z8.object({ kind: z8.literal("workflow"), workflowId: z8.string(), workflowRunId: z8.string() }),
|
|
2821
3126
|
z8.object({
|
|
2822
3127
|
kind: z8.literal("agent"),
|
|
2823
3128
|
agentRunId: z8.string(),
|
|
@@ -4247,7 +4552,7 @@ function registerAiAccountingRoutes(app, host) {
|
|
|
4247
4552
|
import { getConnectorConnectionCallbackProcess } from "@sixb/core/internal/connector-connections";
|
|
4248
4553
|
|
|
4249
4554
|
// src/auth/connector-callback-cookie.ts
|
|
4250
|
-
import { getCookie as
|
|
4555
|
+
import { getCookie as getCookie3 } from "@sixb/core/internal/auth";
|
|
4251
4556
|
import { createSixbError } from "@sixb/core/internal/errors";
|
|
4252
4557
|
var CALLBACK_PATH = "/auth/connectors/callback";
|
|
4253
4558
|
var COOKIE_PREFIX = "sixb_connector_callback_";
|
|
@@ -4264,7 +4569,7 @@ function createConnectorCallbackCookie(input) {
|
|
|
4264
4569
|
}
|
|
4265
4570
|
function readConnectorCallbackCookie(request, state) {
|
|
4266
4571
|
const name = connectorCallbackCookieName(attemptIdFromState(state));
|
|
4267
|
-
return { name, value:
|
|
4572
|
+
return { name, value: getCookie3(request, name) };
|
|
4268
4573
|
}
|
|
4269
4574
|
function clearConnectorCallbackCookie(request, name) {
|
|
4270
4575
|
return serializeConnectorCallbackCookie({
|
|
@@ -4954,6 +5259,7 @@ var DatasetDefinitionSchema = z13.object({
|
|
|
4954
5259
|
id: z13.string(),
|
|
4955
5260
|
description: z13.string().optional(),
|
|
4956
5261
|
primaryKey: z13.union([z13.string(), z13.array(z13.string()).min(2)]).optional(),
|
|
5262
|
+
sequenceBy: z13.string().optional(),
|
|
4957
5263
|
partitionBy: z13.array(z13.string()).optional(),
|
|
4958
5264
|
schema: DatasetSchema
|
|
4959
5265
|
});
|
|
@@ -4962,7 +5268,7 @@ var DatasetVersionRefSchema = z13.object({
|
|
|
4962
5268
|
versionId: z13.string()
|
|
4963
5269
|
});
|
|
4964
5270
|
var DatasetProducerSchema = z13.object({
|
|
4965
|
-
kind: z13.enum(["sync", "pipeline"]),
|
|
5271
|
+
kind: z13.enum(["sync", "pipeline", "ingest"]),
|
|
4966
5272
|
id: z13.string().optional(),
|
|
4967
5273
|
runId: z13.string().optional()
|
|
4968
5274
|
});
|
|
@@ -8085,45 +8391,466 @@ function registerRuleRoutes(app, host) {
|
|
|
8085
8391
|
});
|
|
8086
8392
|
}
|
|
8087
8393
|
|
|
8088
|
-
// src/
|
|
8394
|
+
// src/routes/share-grants.ts
|
|
8395
|
+
import {
|
|
8396
|
+
AuthorizationError as AuthorizationError4,
|
|
8397
|
+
ShareError
|
|
8398
|
+
} from "@sixb/core";
|
|
8399
|
+
import { ObjectNotFoundError as ObjectNotFoundError2 } from "@sixb/core/storage";
|
|
8400
|
+
|
|
8401
|
+
// src/schemas/share-grants.ts
|
|
8089
8402
|
import { z as z24 } from "zod";
|
|
8090
|
-
var
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8403
|
+
var StoredIdentifierSchema = z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8404
|
+
message: "stored identifier must not be blank or contain NUL bytes"
|
|
8405
|
+
});
|
|
8406
|
+
var Rfc3339DateSchema2 = z24.string().datetime({ offset: true });
|
|
8407
|
+
var DestinationPathSchema = z24.string().min(1).max(4096);
|
|
8408
|
+
var QueryBooleanSchema = z24.preprocess((value) => {
|
|
8409
|
+
if (value === "true" || value === true)
|
|
8410
|
+
return true;
|
|
8411
|
+
if (value === "false" || value === false)
|
|
8412
|
+
return false;
|
|
8413
|
+
return value;
|
|
8414
|
+
}, z24.boolean());
|
|
8415
|
+
var ShareGrantListLimitSchema = z24.preprocess(parseUnsignedQueryInteger, z24.number().int().min(1).max(200));
|
|
8416
|
+
var ShareGrantListOffsetSchema = z24.preprocess(parseUnsignedQueryInteger, z24.number().int().min(0).max(Number.MAX_SAFE_INTEGER));
|
|
8417
|
+
function parseUnsignedQueryInteger(value) {
|
|
8418
|
+
if (typeof value !== "string" || !/^\d+$/.test(value))
|
|
8419
|
+
return value;
|
|
8420
|
+
const parsed = Number(value);
|
|
8421
|
+
return Number.isSafeInteger(parsed) ? parsed : value;
|
|
8422
|
+
}
|
|
8423
|
+
var ShareGrantTargetSchema = z24.object({
|
|
8424
|
+
objectTypeId: StoredIdentifierSchema,
|
|
8425
|
+
primaryId: StoredIdentifierSchema
|
|
8426
|
+
});
|
|
8427
|
+
var ShareGrantTargetInputSchema = z24.object({
|
|
8428
|
+
objectTypeId: StoredIdentifierSchema,
|
|
8429
|
+
primaryId: z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8430
|
+
message: "primaryId must not be blank or contain NUL bytes"
|
|
8431
|
+
})
|
|
8432
|
+
});
|
|
8433
|
+
var AuthorizablePrincipalSchema = z24.object({
|
|
8434
|
+
type: z24.enum(["user", "serviceAccount"]),
|
|
8435
|
+
id: StoredIdentifierSchema
|
|
8436
|
+
});
|
|
8437
|
+
var PrincipalSchema = z24.object({
|
|
8438
|
+
type: z24.enum(["user", "serviceAccount", "system"]),
|
|
8439
|
+
id: StoredIdentifierSchema
|
|
8440
|
+
});
|
|
8441
|
+
var SharedAccessGrantSchema = z24.object({
|
|
8442
|
+
id: StoredIdentifierSchema,
|
|
8443
|
+
definitionId: StoredIdentifierSchema,
|
|
8444
|
+
target: ShareGrantTargetSchema,
|
|
8445
|
+
issuedBy: AuthorizablePrincipalSchema,
|
|
8446
|
+
destinationPath: DestinationPathSchema,
|
|
8447
|
+
createdAt: Rfc3339DateSchema2,
|
|
8448
|
+
expiresAt: Rfc3339DateSchema2,
|
|
8449
|
+
revokedAt: Rfc3339DateSchema2.optional(),
|
|
8450
|
+
revokedBy: PrincipalSchema.optional()
|
|
8451
|
+
});
|
|
8452
|
+
var IssueSharedAccessGrantBodySchema = z24.object({
|
|
8453
|
+
definitionId: StoredIdentifierSchema,
|
|
8454
|
+
target: ShareGrantTargetInputSchema,
|
|
8455
|
+
destinationPath: DestinationPathSchema,
|
|
8456
|
+
expiresAt: Rfc3339DateSchema2
|
|
8457
|
+
});
|
|
8458
|
+
var IssueSharedAccessGrantResponseSchema = z24.object({
|
|
8459
|
+
grant: SharedAccessGrantSchema,
|
|
8460
|
+
url: z24.string().startsWith("/shared/")
|
|
8461
|
+
});
|
|
8462
|
+
var ListSharedAccessGrantsQuerySchema = z24.object({
|
|
8463
|
+
definitionId: StoredIdentifierSchema,
|
|
8464
|
+
primaryId: z24.string().min(1).refine(isStoredIdentifier2, {
|
|
8465
|
+
message: "primaryId must not be blank or contain NUL bytes"
|
|
8466
|
+
}).optional(),
|
|
8467
|
+
includeRevoked: QueryBooleanSchema.optional(),
|
|
8468
|
+
includeExpired: QueryBooleanSchema.optional(),
|
|
8469
|
+
limit: ShareGrantListLimitSchema.optional(),
|
|
8470
|
+
offset: ShareGrantListOffsetSchema.optional()
|
|
8471
|
+
});
|
|
8472
|
+
var ListSharedAccessGrantsResponseSchema = z24.object({
|
|
8473
|
+
grants: z24.array(SharedAccessGrantSchema),
|
|
8474
|
+
hasMore: z24.boolean(),
|
|
8475
|
+
total: z24.number().int().nonnegative()
|
|
8476
|
+
});
|
|
8477
|
+
var SharedAccessGrantIdParamsSchema = z24.object({
|
|
8478
|
+
grantId: StoredIdentifierSchema
|
|
8479
|
+
});
|
|
8480
|
+
var RevokeSharedAccessGrantResponseSchema = z24.object({
|
|
8481
|
+
grant: SharedAccessGrantSchema
|
|
8482
|
+
});
|
|
8483
|
+
function isStoredIdentifier2(value) {
|
|
8484
|
+
return value.trim().length > 0 && !value.includes("\x00");
|
|
8485
|
+
}
|
|
8486
|
+
|
|
8487
|
+
// src/routes/share-grants.ts
|
|
8488
|
+
var INTERNAL_ERROR = "[SixbServer] Shared-access operation failed.";
|
|
8489
|
+
var STORAGE_UNAVAILABLE_ERROR = "[SixbServer] Shared-access grant storage is not configured on this runtime.";
|
|
8490
|
+
function registerShareGrantRoutes(app, _host) {
|
|
8491
|
+
return app.post("/api/share-grants", async (context) => {
|
|
8492
|
+
const { body, set } = context;
|
|
8493
|
+
setNoStore(set);
|
|
8494
|
+
try {
|
|
8495
|
+
const invitation = await requireRequestSixb(context).shares.issueById({
|
|
8496
|
+
definitionId: body.definitionId,
|
|
8497
|
+
target: body.target,
|
|
8498
|
+
destinationPath: body.destinationPath,
|
|
8499
|
+
expiresAt: new Date(body.expiresAt)
|
|
8500
|
+
});
|
|
8501
|
+
const grant = serializeSharedAccessGrant(invitation.grant);
|
|
8502
|
+
set.status = 201;
|
|
8503
|
+
return IssueSharedAccessGrantResponseSchema.parse({
|
|
8504
|
+
grant,
|
|
8505
|
+
url: sharedAccessUrl(grant.id, grant.destinationPath, invitation.secret)
|
|
8506
|
+
});
|
|
8507
|
+
} catch (error) {
|
|
8508
|
+
return handleShareGrantRouteError(error, set);
|
|
8509
|
+
}
|
|
8510
|
+
}, {
|
|
8511
|
+
body: IssueSharedAccessGrantBodySchema,
|
|
8512
|
+
response: {
|
|
8513
|
+
201: IssueSharedAccessGrantResponseSchema,
|
|
8514
|
+
400: ErrorResponseSchema,
|
|
8515
|
+
401: ErrorResponseSchema,
|
|
8516
|
+
403: ErrorResponseSchema,
|
|
8517
|
+
404: ErrorResponseSchema,
|
|
8518
|
+
500: ErrorResponseSchema,
|
|
8519
|
+
501: ErrorResponseSchema
|
|
8520
|
+
},
|
|
8521
|
+
error: sharedAccessValidationError("Invalid shared-access grant request."),
|
|
8522
|
+
detail: {
|
|
8523
|
+
summary: "Issue a shared-access grant",
|
|
8524
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8525
|
+
operationId: "issueSharedAccessGrant",
|
|
8526
|
+
security: bearerSecurityRequirement("issueSharedAccessGrant")
|
|
8527
|
+
}
|
|
8528
|
+
}).get("/api/share-grants", async (context) => {
|
|
8529
|
+
const { query, set } = context;
|
|
8530
|
+
setNoStore(set);
|
|
8531
|
+
try {
|
|
8532
|
+
const result = await requireRequestSixb(context).shares.listById({
|
|
8533
|
+
definitionId: query.definitionId,
|
|
8534
|
+
primaryId: query.primaryId,
|
|
8535
|
+
includeRevoked: query.includeRevoked,
|
|
8536
|
+
includeExpired: query.includeExpired,
|
|
8537
|
+
limit: query.limit,
|
|
8538
|
+
offset: query.offset
|
|
8539
|
+
});
|
|
8540
|
+
return ListSharedAccessGrantsResponseSchema.parse({
|
|
8541
|
+
grants: result.grants.map(serializeSharedAccessGrant),
|
|
8542
|
+
total: result.total,
|
|
8543
|
+
hasMore: result.hasMore
|
|
8544
|
+
});
|
|
8545
|
+
} catch (error) {
|
|
8546
|
+
return handleShareGrantRouteError(error, set);
|
|
8547
|
+
}
|
|
8548
|
+
}, {
|
|
8549
|
+
query: ListSharedAccessGrantsQuerySchema,
|
|
8550
|
+
response: {
|
|
8551
|
+
200: ListSharedAccessGrantsResponseSchema,
|
|
8552
|
+
400: ErrorResponseSchema,
|
|
8553
|
+
401: ErrorResponseSchema,
|
|
8554
|
+
403: ErrorResponseSchema,
|
|
8555
|
+
404: ErrorResponseSchema,
|
|
8556
|
+
500: ErrorResponseSchema,
|
|
8557
|
+
501: ErrorResponseSchema
|
|
8558
|
+
},
|
|
8559
|
+
error: sharedAccessValidationError("Invalid shared-access grant query."),
|
|
8560
|
+
detail: {
|
|
8561
|
+
summary: "List shared-access grants",
|
|
8562
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8563
|
+
operationId: "listSharedAccessGrants",
|
|
8564
|
+
security: bearerSecurityRequirement("listSharedAccessGrants")
|
|
8565
|
+
}
|
|
8566
|
+
}).delete("/api/share-grants/:grantId", async (context) => {
|
|
8567
|
+
const { params, set } = context;
|
|
8568
|
+
setNoStore(set);
|
|
8569
|
+
try {
|
|
8570
|
+
const grant = await requireRequestSixb(context).shares.revoke(params.grantId);
|
|
8571
|
+
if (!grant) {
|
|
8572
|
+
set.status = 404;
|
|
8573
|
+
return { error: "[SixbServer] Shared-access grant not found." };
|
|
8574
|
+
}
|
|
8575
|
+
return RevokeSharedAccessGrantResponseSchema.parse({
|
|
8576
|
+
grant: serializeSharedAccessGrant(grant)
|
|
8577
|
+
});
|
|
8578
|
+
} catch (error) {
|
|
8579
|
+
return handleShareGrantRouteError(error, set);
|
|
8580
|
+
}
|
|
8581
|
+
}, {
|
|
8582
|
+
params: SharedAccessGrantIdParamsSchema,
|
|
8583
|
+
response: {
|
|
8584
|
+
200: RevokeSharedAccessGrantResponseSchema,
|
|
8585
|
+
400: ErrorResponseSchema,
|
|
8586
|
+
401: ErrorResponseSchema,
|
|
8587
|
+
403: ErrorResponseSchema,
|
|
8588
|
+
404: ErrorResponseSchema,
|
|
8589
|
+
500: ErrorResponseSchema,
|
|
8590
|
+
501: ErrorResponseSchema
|
|
8591
|
+
},
|
|
8592
|
+
error: sharedAccessValidationError("Invalid shared-access grant id."),
|
|
8593
|
+
detail: {
|
|
8594
|
+
summary: "Revoke a shared-access grant",
|
|
8595
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8596
|
+
operationId: "revokeSharedAccessGrant",
|
|
8597
|
+
security: bearerSecurityRequirement("revokeSharedAccessGrant")
|
|
8598
|
+
}
|
|
8599
|
+
});
|
|
8600
|
+
}
|
|
8601
|
+
function serializeSharedAccessGrant(grant) {
|
|
8602
|
+
return SharedAccessGrantSchema.parse({
|
|
8603
|
+
id: grant.id,
|
|
8604
|
+
definitionId: grant.definitionId,
|
|
8605
|
+
target: grant.target,
|
|
8606
|
+
issuedBy: grant.issuedBy,
|
|
8607
|
+
destinationPath: grant.destinationPath,
|
|
8608
|
+
createdAt: grant.createdAt.toISOString(),
|
|
8609
|
+
expiresAt: grant.expiresAt.toISOString(),
|
|
8610
|
+
...grant.revokedAt === undefined ? {} : { revokedAt: grant.revokedAt.toISOString() },
|
|
8611
|
+
...grant.revokedBy === undefined ? {} : { revokedBy: grant.revokedBy }
|
|
8612
|
+
});
|
|
8613
|
+
}
|
|
8614
|
+
function sharedAccessUrl(grantId, destinationPath, secret) {
|
|
8615
|
+
return `/shared/${encodeURIComponent(grantId)}${destinationPath}#${encodeURIComponent(secret)}`;
|
|
8616
|
+
}
|
|
8617
|
+
function handleShareGrantRouteError(error, set) {
|
|
8618
|
+
if (error instanceof ShareError) {
|
|
8619
|
+
set.status = shareErrorStatus(error);
|
|
8620
|
+
if (error.reason === "storage_failure")
|
|
8621
|
+
return { error: INTERNAL_ERROR };
|
|
8622
|
+
if (error.reason === "storage_unavailable")
|
|
8623
|
+
return { error: STORAGE_UNAVAILABLE_ERROR };
|
|
8624
|
+
if (error.reason === "unauthenticated")
|
|
8625
|
+
return { error: "Authentication required." };
|
|
8626
|
+
return { error: error.message };
|
|
8627
|
+
}
|
|
8628
|
+
if (error instanceof AuthorizationError4) {
|
|
8629
|
+
set.status = 403;
|
|
8630
|
+
return { error: error.message };
|
|
8631
|
+
}
|
|
8632
|
+
if (error instanceof ObjectNotFoundError2) {
|
|
8633
|
+
set.status = 404;
|
|
8634
|
+
return { error: error.message };
|
|
8635
|
+
}
|
|
8636
|
+
set.status = 500;
|
|
8637
|
+
return { error: INTERNAL_ERROR };
|
|
8638
|
+
}
|
|
8639
|
+
function shareErrorStatus(error) {
|
|
8640
|
+
switch (error.reason) {
|
|
8641
|
+
case "invalid_input":
|
|
8642
|
+
return 400;
|
|
8643
|
+
case "not_found":
|
|
8644
|
+
return 404;
|
|
8645
|
+
case "unauthenticated":
|
|
8646
|
+
return 401;
|
|
8647
|
+
case "storage_unavailable":
|
|
8648
|
+
return 501;
|
|
8649
|
+
case "storage_failure":
|
|
8650
|
+
return 500;
|
|
8651
|
+
}
|
|
8652
|
+
}
|
|
8653
|
+
function sharedAccessValidationError(message) {
|
|
8654
|
+
return ({
|
|
8655
|
+
code,
|
|
8656
|
+
set
|
|
8657
|
+
}) => {
|
|
8658
|
+
if (code !== "VALIDATION")
|
|
8659
|
+
return;
|
|
8660
|
+
setNoStore(set);
|
|
8661
|
+
set.status = 400;
|
|
8662
|
+
return { error: message };
|
|
8663
|
+
};
|
|
8664
|
+
}
|
|
8665
|
+
function setNoStore(set) {
|
|
8666
|
+
if (set.headers instanceof Headers) {
|
|
8667
|
+
set.headers.set("cache-control", "no-store");
|
|
8668
|
+
return;
|
|
8669
|
+
}
|
|
8670
|
+
if (!set.headers || typeof set.headers !== "object" || Array.isArray(set.headers)) {
|
|
8671
|
+
set.headers = {};
|
|
8672
|
+
}
|
|
8673
|
+
set.headers["cache-control"] = "no-store";
|
|
8674
|
+
}
|
|
8675
|
+
|
|
8676
|
+
// src/schemas/shared-access.ts
|
|
8677
|
+
import { z as z25 } from "zod";
|
|
8678
|
+
var StoredIdentifierSchema2 = z25.string().min(1).max(128).refine((value) => value.trim() === value && !value.includes("\x00"), {
|
|
8679
|
+
message: "stored identifier must not be blank or contain NUL bytes"
|
|
8680
|
+
});
|
|
8681
|
+
var Rfc3339DateSchema3 = z25.string().datetime({ offset: true });
|
|
8682
|
+
var SharedAccessGrantParamsSchema = z25.object({
|
|
8683
|
+
grantId: StoredIdentifierSchema2
|
|
8684
|
+
});
|
|
8685
|
+
var ExchangeSharedAccessBodySchema = z25.object({
|
|
8686
|
+
secret: z25.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
8687
|
+
});
|
|
8688
|
+
var SharedAccessSessionResponseSchema = z25.object({
|
|
8689
|
+
grantId: StoredIdentifierSchema2,
|
|
8690
|
+
destinationPath: z25.string().min(1).max(4096),
|
|
8691
|
+
expiresAt: Rfc3339DateSchema3,
|
|
8692
|
+
absoluteExpiresAt: Rfc3339DateSchema3,
|
|
8693
|
+
csrfToken: z25.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
8694
|
+
});
|
|
8695
|
+
var SharedAccessSignOutResponseSchema = z25.object({
|
|
8696
|
+
signedOut: z25.literal(true)
|
|
8697
|
+
});
|
|
8698
|
+
|
|
8699
|
+
// src/routes/shared-access.ts
|
|
8700
|
+
function registerSharedAccessRoutes(app, boundary) {
|
|
8701
|
+
return app.post("/api/shared-access/:grantId/exchange", async ({ body, params, request }) => {
|
|
8702
|
+
try {
|
|
8703
|
+
const resolved = await boundary.exchange(request, params.grantId, body.secret);
|
|
8704
|
+
if (!resolved)
|
|
8705
|
+
return sharedAccessUnauthenticatedResponse();
|
|
8706
|
+
return sharedSessionResponse(resolved.context, resolved.cookies);
|
|
8707
|
+
} catch {
|
|
8708
|
+
return sharedAccessUnavailableResponse();
|
|
8709
|
+
}
|
|
8710
|
+
}, {
|
|
8711
|
+
params: SharedAccessGrantParamsSchema,
|
|
8712
|
+
body: ExchangeSharedAccessBodySchema,
|
|
8713
|
+
response: {
|
|
8714
|
+
200: SharedAccessSessionResponseSchema,
|
|
8715
|
+
401: ErrorResponseSchema,
|
|
8716
|
+
503: ErrorResponseSchema
|
|
8717
|
+
},
|
|
8718
|
+
error: sharedAccessRouteError,
|
|
8719
|
+
detail: {
|
|
8720
|
+
summary: "Exchange a shared link for a short-lived session",
|
|
8721
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8722
|
+
operationId: "exchangeSharedAccess",
|
|
8723
|
+
security: []
|
|
8724
|
+
}
|
|
8725
|
+
}).get("/api/shared-access/:grantId/session", async ({ params, request }) => {
|
|
8726
|
+
try {
|
|
8727
|
+
const resolved = await boundary.resolveSession(request, params.grantId);
|
|
8728
|
+
if (!resolved) {
|
|
8729
|
+
return withSetCookies(sharedAccessUnauthenticatedResponse(), boundary.clearCookieHeaders(request, params.grantId));
|
|
8730
|
+
}
|
|
8731
|
+
return sharedSessionResponse(resolved.context, resolved.cookies);
|
|
8732
|
+
} catch {
|
|
8733
|
+
return sharedAccessUnavailableResponse();
|
|
8734
|
+
}
|
|
8735
|
+
}, {
|
|
8736
|
+
params: SharedAccessGrantParamsSchema,
|
|
8737
|
+
response: {
|
|
8738
|
+
200: SharedAccessSessionResponseSchema,
|
|
8739
|
+
401: ErrorResponseSchema,
|
|
8740
|
+
503: ErrorResponseSchema
|
|
8741
|
+
},
|
|
8742
|
+
error: sharedAccessRouteError,
|
|
8743
|
+
detail: {
|
|
8744
|
+
summary: "Get the current shared-access session",
|
|
8745
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8746
|
+
operationId: "getSharedAccessSession",
|
|
8747
|
+
security: []
|
|
8748
|
+
}
|
|
8749
|
+
}).post("/api/shared-access/:grantId/sign-out", async ({ params, request }) => {
|
|
8750
|
+
try {
|
|
8751
|
+
const result = await boundary.signOut(request, params.grantId);
|
|
8752
|
+
if (result.kind === "csrf")
|
|
8753
|
+
return sharedAccessForbiddenResponse();
|
|
8754
|
+
if (result.kind === "invalid") {
|
|
8755
|
+
return withSetCookies(sharedAccessUnauthenticatedResponse(), result.setCookies);
|
|
8756
|
+
}
|
|
8757
|
+
const response = new Response(JSON.stringify({ signedOut: true }), {
|
|
8758
|
+
status: 200,
|
|
8759
|
+
headers: sharedAccessSecurityHeaders()
|
|
8760
|
+
});
|
|
8761
|
+
return withSetCookies(response, result.setCookies);
|
|
8762
|
+
} catch {
|
|
8763
|
+
return sharedAccessUnavailableResponse();
|
|
8764
|
+
}
|
|
8765
|
+
}, {
|
|
8766
|
+
params: SharedAccessGrantParamsSchema,
|
|
8767
|
+
response: {
|
|
8768
|
+
200: SharedAccessSignOutResponseSchema,
|
|
8769
|
+
401: ErrorResponseSchema,
|
|
8770
|
+
403: ErrorResponseSchema,
|
|
8771
|
+
503: ErrorResponseSchema
|
|
8772
|
+
},
|
|
8773
|
+
error: sharedAccessRouteError,
|
|
8774
|
+
detail: {
|
|
8775
|
+
summary: "Sign out a shared-access session",
|
|
8776
|
+
tags: [OPENAPI_TAGS.sharedAccess.name],
|
|
8777
|
+
operationId: "signOutSharedAccess",
|
|
8778
|
+
security: SIXB_CSRF_SECURITY_REQUIREMENT
|
|
8779
|
+
}
|
|
8780
|
+
});
|
|
8781
|
+
}
|
|
8782
|
+
function sharedSessionResponse(context, cookies) {
|
|
8783
|
+
const headers = sharedAccessSecurityHeaders();
|
|
8784
|
+
headers.set(CSRF_TOKEN_RESPONSE_HEADER_NAME, cookies.csrfToken);
|
|
8785
|
+
for (const cookie of cookies.setCookies)
|
|
8786
|
+
headers.append("set-cookie", cookie);
|
|
8787
|
+
return new Response(JSON.stringify({
|
|
8788
|
+
grantId: context.grantId,
|
|
8789
|
+
destinationPath: context.destinationPath,
|
|
8790
|
+
expiresAt: context.expiresAt.toISOString(),
|
|
8791
|
+
absoluteExpiresAt: context.absoluteExpiresAt.toISOString(),
|
|
8792
|
+
csrfToken: cookies.csrfToken
|
|
8793
|
+
}), { status: 200, headers });
|
|
8794
|
+
}
|
|
8795
|
+
function withSetCookies(response, setCookies) {
|
|
8796
|
+
for (const cookie of setCookies)
|
|
8797
|
+
response.headers.append("set-cookie", cookie);
|
|
8798
|
+
return response;
|
|
8799
|
+
}
|
|
8800
|
+
function sharedAccessRouteError(context) {
|
|
8801
|
+
if (context.code === "PARSE" || isRequestValidationError(context)) {
|
|
8802
|
+
return sharedAccessUnauthenticatedResponse();
|
|
8803
|
+
}
|
|
8804
|
+
return sharedAccessUnavailableResponse();
|
|
8805
|
+
}
|
|
8806
|
+
function isRequestValidationError(context) {
|
|
8807
|
+
if (context.code !== "VALIDATION" || !isRecord(context.error))
|
|
8808
|
+
return false;
|
|
8809
|
+
return ["body", "params", "query", "headers", "cookie"].includes(String(context.error.type));
|
|
8810
|
+
}
|
|
8811
|
+
function isRecord(value) {
|
|
8812
|
+
return typeof value === "object" && value !== null;
|
|
8813
|
+
}
|
|
8814
|
+
|
|
8815
|
+
// src/schemas/status.ts
|
|
8816
|
+
import { z as z26 } from "zod";
|
|
8817
|
+
var HealthResponseSchema = z26.object({ status: z26.literal("ok") });
|
|
8818
|
+
var StorageReadinessSchema = z26.object({
|
|
8819
|
+
reachable: z26.boolean(),
|
|
8820
|
+
schemaValid: z26.boolean()
|
|
8094
8821
|
});
|
|
8095
|
-
var ReadinessResponseSchema =
|
|
8096
|
-
status:
|
|
8822
|
+
var ReadinessResponseSchema = z26.object({
|
|
8823
|
+
status: z26.enum(["ready", "unready"]),
|
|
8097
8824
|
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:
|
|
8825
|
+
reason: z26.string().optional()
|
|
8826
|
+
});
|
|
8827
|
+
var MaintenanceSummarySchema = z26.object({
|
|
8828
|
+
running: z26.boolean(),
|
|
8829
|
+
intervalMs: z26.number().int().positive(),
|
|
8830
|
+
lastStartedAt: z26.string().nullable(),
|
|
8831
|
+
lastCompletedAt: z26.string().nullable(),
|
|
8832
|
+
lastDurationMs: z26.number().nonnegative().nullable(),
|
|
8833
|
+
consecutiveFailures: z26.number().int().nonnegative(),
|
|
8834
|
+
lastError: z26.string().nullable(),
|
|
8835
|
+
outbox: z26.object({
|
|
8836
|
+
pendingCount: z26.number().int().nonnegative(),
|
|
8837
|
+
oldestPendingAt: z26.string().nullable(),
|
|
8838
|
+
retryingCount: z26.number().int().nonnegative(),
|
|
8839
|
+
maxAttempts: z26.number().int().nonnegative()
|
|
8113
8840
|
}).nullable(),
|
|
8114
|
-
terminalSources:
|
|
8115
|
-
count:
|
|
8116
|
-
oldestTerminalAt:
|
|
8841
|
+
terminalSources: z26.object({
|
|
8842
|
+
count: z26.number().int().nonnegative(),
|
|
8843
|
+
oldestTerminalAt: z26.string().nullable()
|
|
8117
8844
|
}).nullable(),
|
|
8118
|
-
cleanup:
|
|
8119
|
-
publishedOutboxRowsDeleted:
|
|
8120
|
-
terminalSourceRowsDeleted:
|
|
8121
|
-
terminalSourceMaterializationsDeleted:
|
|
8845
|
+
cleanup: z26.object({
|
|
8846
|
+
publishedOutboxRowsDeleted: z26.number().int().nonnegative(),
|
|
8847
|
+
terminalSourceRowsDeleted: z26.number().int().nonnegative(),
|
|
8848
|
+
terminalSourceMaterializationsDeleted: z26.number().int().nonnegative()
|
|
8122
8849
|
}).nullable()
|
|
8123
8850
|
});
|
|
8124
|
-
var StatusResponseSchema =
|
|
8125
|
-
status:
|
|
8126
|
-
objectTypes:
|
|
8851
|
+
var StatusResponseSchema = z26.object({
|
|
8852
|
+
status: z26.enum(["ok", "degraded"]),
|
|
8853
|
+
objectTypes: z26.number().int().nonnegative(),
|
|
8127
8854
|
maintenance: MaintenanceSummarySchema
|
|
8128
8855
|
});
|
|
8129
8856
|
|
|
@@ -8169,74 +8896,74 @@ function registerStatusRoutes(app, host) {
|
|
|
8169
8896
|
import {
|
|
8170
8897
|
SYNC_RUN_FAILURE_CODES
|
|
8171
8898
|
} from "@sixb/core/storage";
|
|
8172
|
-
import { z as
|
|
8899
|
+
import { z as z27 } from "zod";
|
|
8173
8900
|
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:
|
|
8901
|
+
var SyncParamsSchema = z27.object({
|
|
8902
|
+
syncId: z27.string().min(1)
|
|
8903
|
+
});
|
|
8904
|
+
var SyncRunStatusSchema = z27.enum(["queued", "running", "succeeded", "failed", "cancelled"]);
|
|
8905
|
+
var SyncModeSchema = z27.enum(["snapshot", "append", "merge"]);
|
|
8906
|
+
var SyncRunsQuerySchema = z27.object({
|
|
8907
|
+
syncId: z27.string().optional(),
|
|
8908
|
+
datasetId: z27.string().optional(),
|
|
8182
8909
|
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:
|
|
8910
|
+
startedAfter: z27.string().optional(),
|
|
8911
|
+
startedBefore: z27.string().optional(),
|
|
8912
|
+
limit: z27.string().optional(),
|
|
8913
|
+
offset: z27.string().optional(),
|
|
8914
|
+
order: z27.enum(["asc", "desc"]).optional()
|
|
8915
|
+
});
|
|
8916
|
+
var RequestSyncRunBodySchema = z27.object({
|
|
8917
|
+
expectedLatestVersionId: z27.string().optional(),
|
|
8918
|
+
commitMessage: z27.string().optional()
|
|
8919
|
+
});
|
|
8920
|
+
var SyncTriggerSchema = z27.object({
|
|
8921
|
+
type: z27.literal("schedule"),
|
|
8922
|
+
scheduleId: z27.string()
|
|
8923
|
+
});
|
|
8924
|
+
var SyncRunSchema = z27.object({
|
|
8925
|
+
id: z27.string(),
|
|
8926
|
+
projectId: z27.string(),
|
|
8927
|
+
syncId: z27.string(),
|
|
8928
|
+
datasetId: z27.string(),
|
|
8202
8929
|
mode: SyncModeSchema,
|
|
8203
8930
|
status: SyncRunStatusSchema,
|
|
8204
|
-
queuedAt:
|
|
8205
|
-
startedAt:
|
|
8206
|
-
finishedAt:
|
|
8207
|
-
rowsRead:
|
|
8208
|
-
output:
|
|
8209
|
-
datasetId:
|
|
8210
|
-
versionId:
|
|
8931
|
+
queuedAt: z27.string(),
|
|
8932
|
+
startedAt: z27.string().optional(),
|
|
8933
|
+
finishedAt: z27.string().optional(),
|
|
8934
|
+
rowsRead: z27.number().optional(),
|
|
8935
|
+
output: z27.object({
|
|
8936
|
+
datasetId: z27.string(),
|
|
8937
|
+
versionId: z27.string()
|
|
8211
8938
|
}).optional(),
|
|
8212
|
-
expectedLatestVersionId:
|
|
8213
|
-
commitMessage:
|
|
8939
|
+
expectedLatestVersionId: z27.string().optional(),
|
|
8940
|
+
commitMessage: z27.string().optional(),
|
|
8214
8941
|
error: SyncRunFailureSchema.optional()
|
|
8215
8942
|
});
|
|
8216
|
-
var SyncSchema =
|
|
8217
|
-
id:
|
|
8943
|
+
var SyncSchema = z27.object({
|
|
8944
|
+
id: z27.string(),
|
|
8218
8945
|
mode: SyncModeSchema,
|
|
8219
|
-
connector:
|
|
8220
|
-
id:
|
|
8221
|
-
type:
|
|
8946
|
+
connector: z27.object({
|
|
8947
|
+
id: z27.string(),
|
|
8948
|
+
type: z27.string()
|
|
8222
8949
|
}),
|
|
8223
|
-
target:
|
|
8224
|
-
kind:
|
|
8950
|
+
target: z27.object({
|
|
8951
|
+
kind: z27.literal("dataset"),
|
|
8225
8952
|
dataset: DatasetDefinitionSchema
|
|
8226
8953
|
}),
|
|
8227
|
-
triggers:
|
|
8954
|
+
triggers: z27.array(SyncTriggerSchema),
|
|
8228
8955
|
latestRun: SyncRunSchema.nullable()
|
|
8229
8956
|
});
|
|
8230
|
-
var SyncRunListResponseSchema =
|
|
8231
|
-
runs:
|
|
8232
|
-
hasMore:
|
|
8233
|
-
total:
|
|
8957
|
+
var SyncRunListResponseSchema = z27.object({
|
|
8958
|
+
runs: z27.array(SyncRunSchema),
|
|
8959
|
+
hasMore: z27.boolean(),
|
|
8960
|
+
total: z27.number()
|
|
8234
8961
|
});
|
|
8235
|
-
var RequestSyncRunResponseSchema =
|
|
8236
|
-
runId:
|
|
8237
|
-
jobId:
|
|
8238
|
-
syncId:
|
|
8239
|
-
queuedAt:
|
|
8962
|
+
var RequestSyncRunResponseSchema = z27.object({
|
|
8963
|
+
runId: z27.string(),
|
|
8964
|
+
jobId: z27.string(),
|
|
8965
|
+
syncId: z27.string(),
|
|
8966
|
+
queuedAt: z27.string()
|
|
8240
8967
|
});
|
|
8241
8968
|
|
|
8242
8969
|
// src/routes/syncs.ts
|
|
@@ -8390,52 +9117,52 @@ function registerSyncRoutes(app, host) {
|
|
|
8390
9117
|
}
|
|
8391
9118
|
|
|
8392
9119
|
// 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:
|
|
9120
|
+
import { z as z28 } from "zod";
|
|
9121
|
+
var TelemetryParamsSchema = z28.object({
|
|
9122
|
+
objectTypeId: z28.string().min(1),
|
|
9123
|
+
objectId: z28.string().min(1),
|
|
9124
|
+
propertyId: z28.string().min(1)
|
|
9125
|
+
});
|
|
9126
|
+
var TelemetryHistoryQuerySchema = z28.object({
|
|
9127
|
+
from: z28.string().optional(),
|
|
9128
|
+
to: z28.string().optional(),
|
|
9129
|
+
limit: z28.string().optional(),
|
|
9130
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
9131
|
+
});
|
|
9132
|
+
var BulkTelemetryHistorySeriesInputSchema = z28.object({
|
|
9133
|
+
objectTypeId: z28.string().min(1),
|
|
9134
|
+
objectId: z28.string().min(1),
|
|
9135
|
+
propertyId: z28.string().min(1)
|
|
8409
9136
|
}).strict();
|
|
8410
|
-
var BulkTelemetryHistoryBodySchema =
|
|
8411
|
-
series:
|
|
8412
|
-
from:
|
|
8413
|
-
to:
|
|
8414
|
-
limitPerSeries:
|
|
8415
|
-
order:
|
|
9137
|
+
var BulkTelemetryHistoryBodySchema = z28.object({
|
|
9138
|
+
series: z28.array(BulkTelemetryHistorySeriesInputSchema).min(1),
|
|
9139
|
+
from: z28.string().optional(),
|
|
9140
|
+
to: z28.string().optional(),
|
|
9141
|
+
limitPerSeries: z28.number().int().nonnegative().optional(),
|
|
9142
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
8416
9143
|
}).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:
|
|
9144
|
+
var AppendTelemetryBodySchema = z28.object({
|
|
9145
|
+
value: z28.unknown(),
|
|
9146
|
+
unit: z28.string().optional(),
|
|
9147
|
+
at: z28.string().optional()
|
|
9148
|
+
});
|
|
9149
|
+
var TelemetryPointSchema = z28.object({
|
|
9150
|
+
projectId: z28.string(),
|
|
9151
|
+
objectTypeId: z28.string(),
|
|
9152
|
+
objectId: z28.string(),
|
|
9153
|
+
propertyId: z28.string(),
|
|
9154
|
+
value: z28.unknown(),
|
|
9155
|
+
unit: z28.string().optional(),
|
|
9156
|
+
at: z28.string()
|
|
9157
|
+
});
|
|
9158
|
+
var BulkTelemetryHistorySeriesSchema = z28.object({
|
|
9159
|
+
objectTypeId: z28.string(),
|
|
9160
|
+
objectId: z28.string(),
|
|
9161
|
+
propertyId: z28.string(),
|
|
9162
|
+
points: z28.array(TelemetryPointSchema)
|
|
9163
|
+
});
|
|
9164
|
+
var BulkTelemetryHistoryResponseSchema = z28.object({
|
|
9165
|
+
series: z28.array(BulkTelemetryHistorySeriesSchema)
|
|
8439
9166
|
});
|
|
8440
9167
|
|
|
8441
9168
|
// src/routes/telemetry.ts
|
|
@@ -8593,40 +9320,40 @@ function registerTelemetryRoutes(app, _host) {
|
|
|
8593
9320
|
|
|
8594
9321
|
// src/schemas/webhook-runs.ts
|
|
8595
9322
|
import { WEBHOOK_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
8596
|
-
import { z as
|
|
9323
|
+
import { z as z29 } from "zod";
|
|
8597
9324
|
var WebhookRunFailureSchema = sixbFailureSchema(WEBHOOK_RUN_FAILURE_CODES);
|
|
8598
|
-
var WebhookRunStatusSchema =
|
|
8599
|
-
var WebhookRunsQuerySchema =
|
|
8600
|
-
connectorId:
|
|
8601
|
-
webhookId:
|
|
9325
|
+
var WebhookRunStatusSchema = z29.enum(["running", "succeeded", "failed"]);
|
|
9326
|
+
var WebhookRunsQuerySchema = z29.object({
|
|
9327
|
+
connectorId: z29.string().optional(),
|
|
9328
|
+
webhookId: z29.string().optional(),
|
|
8602
9329
|
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:
|
|
9330
|
+
idempotencyKey: z29.string().optional(),
|
|
9331
|
+
startedAfter: z29.string().optional(),
|
|
9332
|
+
startedBefore: z29.string().optional(),
|
|
9333
|
+
limit: z29.string().optional(),
|
|
9334
|
+
offset: z29.string().optional(),
|
|
9335
|
+
order: z29.enum(["asc", "desc"]).optional()
|
|
9336
|
+
});
|
|
9337
|
+
var WebhookRunSchema = z29.object({
|
|
9338
|
+
id: z29.string(),
|
|
9339
|
+
projectId: z29.string(),
|
|
9340
|
+
executionId: z29.string(),
|
|
9341
|
+
connectorId: z29.string(),
|
|
9342
|
+
webhookId: z29.string(),
|
|
8616
9343
|
status: WebhookRunStatusSchema,
|
|
8617
|
-
method:
|
|
8618
|
-
route:
|
|
8619
|
-
startedAt:
|
|
8620
|
-
finishedAt:
|
|
8621
|
-
requestBodyBytes:
|
|
8622
|
-
responseStatus:
|
|
8623
|
-
idempotencyKey:
|
|
9344
|
+
method: z29.string(),
|
|
9345
|
+
route: z29.string(),
|
|
9346
|
+
startedAt: z29.string(),
|
|
9347
|
+
finishedAt: z29.string().optional(),
|
|
9348
|
+
requestBodyBytes: z29.number(),
|
|
9349
|
+
responseStatus: z29.number().optional(),
|
|
9350
|
+
idempotencyKey: z29.string().optional(),
|
|
8624
9351
|
error: WebhookRunFailureSchema.optional()
|
|
8625
9352
|
});
|
|
8626
|
-
var WebhookRunListResponseSchema =
|
|
8627
|
-
runs:
|
|
8628
|
-
hasMore:
|
|
8629
|
-
total:
|
|
9353
|
+
var WebhookRunListResponseSchema = z29.object({
|
|
9354
|
+
runs: z29.array(WebhookRunSchema),
|
|
9355
|
+
hasMore: z29.boolean(),
|
|
9356
|
+
total: z29.number()
|
|
8630
9357
|
});
|
|
8631
9358
|
|
|
8632
9359
|
// src/routes/webhook-runs.ts
|
|
@@ -8701,25 +9428,25 @@ import {
|
|
|
8701
9428
|
snapshotWorkflowInterventionResponse
|
|
8702
9429
|
} from "@sixb/core/internal/workflows";
|
|
8703
9430
|
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
|
|
9431
|
+
import { z as z31 } from "zod";
|
|
8705
9432
|
|
|
8706
9433
|
// src/schemas/workflows.ts
|
|
8707
9434
|
import {
|
|
8708
9435
|
WORKFLOW_RUN_FAILURE_CODES
|
|
8709
9436
|
} from "@sixb/core/storage";
|
|
8710
|
-
import { z as
|
|
8711
|
-
var WorkflowIOSnapshotSchema =
|
|
9437
|
+
import { z as z30 } from "zod";
|
|
9438
|
+
var WorkflowIOSnapshotSchema = z30.record(JsonValueSchema);
|
|
8712
9439
|
var WorkflowRunFailureSchema = sixbFailureSchema(WORKFLOW_RUN_FAILURE_CODES);
|
|
8713
|
-
var WorkflowParamsSchema =
|
|
8714
|
-
workflowId:
|
|
9440
|
+
var WorkflowParamsSchema = z30.object({
|
|
9441
|
+
workflowId: z30.string().min(1)
|
|
8715
9442
|
});
|
|
8716
|
-
var WorkflowRunParamsSchema =
|
|
8717
|
-
runId:
|
|
9443
|
+
var WorkflowRunParamsSchema = z30.object({
|
|
9444
|
+
runId: z30.string().min(1)
|
|
8718
9445
|
});
|
|
8719
|
-
var WorkflowInterventionParamsSchema =
|
|
8720
|
-
interventionId:
|
|
9446
|
+
var WorkflowInterventionParamsSchema = z30.object({
|
|
9447
|
+
interventionId: z30.string().min(1)
|
|
8721
9448
|
});
|
|
8722
|
-
var WorkflowRunStatusSchema =
|
|
9449
|
+
var WorkflowRunStatusSchema = z30.enum([
|
|
8723
9450
|
"queued",
|
|
8724
9451
|
"running",
|
|
8725
9452
|
"waiting",
|
|
@@ -8727,90 +9454,90 @@ var WorkflowRunStatusSchema = z28.enum([
|
|
|
8727
9454
|
"failed",
|
|
8728
9455
|
"cancelled"
|
|
8729
9456
|
]);
|
|
8730
|
-
var WorkflowInterventionStatusSchema =
|
|
9457
|
+
var WorkflowInterventionStatusSchema = z30.enum([
|
|
8731
9458
|
"pending",
|
|
8732
9459
|
"submitted",
|
|
8733
9460
|
"cancelled",
|
|
8734
9461
|
"expired"
|
|
8735
9462
|
]);
|
|
8736
|
-
var WorkflowRunsQuerySchema =
|
|
8737
|
-
workflowId:
|
|
9463
|
+
var WorkflowRunsQuerySchema = z30.object({
|
|
9464
|
+
workflowId: z30.string().optional(),
|
|
8738
9465
|
status: WorkflowRunStatusSchema.optional(),
|
|
8739
|
-
startedAfter:
|
|
8740
|
-
startedBefore:
|
|
8741
|
-
limit:
|
|
8742
|
-
offset:
|
|
8743
|
-
order:
|
|
9466
|
+
startedAfter: z30.string().optional(),
|
|
9467
|
+
startedBefore: z30.string().optional(),
|
|
9468
|
+
limit: z30.string().optional(),
|
|
9469
|
+
offset: z30.string().optional(),
|
|
9470
|
+
order: z30.enum(["asc", "desc"]).optional()
|
|
8744
9471
|
});
|
|
8745
|
-
var WorkflowInterventionsQuerySchema =
|
|
8746
|
-
workflowId:
|
|
8747
|
-
workflowRunId:
|
|
8748
|
-
nodeRunId:
|
|
8749
|
-
nodeId:
|
|
8750
|
-
nodeKey:
|
|
8751
|
-
interventionId:
|
|
9472
|
+
var WorkflowInterventionsQuerySchema = z30.object({
|
|
9473
|
+
workflowId: z30.string().optional(),
|
|
9474
|
+
workflowRunId: z30.string().optional(),
|
|
9475
|
+
nodeRunId: z30.string().optional(),
|
|
9476
|
+
nodeId: z30.string().optional(),
|
|
9477
|
+
nodeKey: z30.string().optional(),
|
|
9478
|
+
interventionId: z30.string().optional(),
|
|
8752
9479
|
status: WorkflowInterventionStatusSchema.optional(),
|
|
8753
|
-
requestedAfter:
|
|
8754
|
-
requestedBefore:
|
|
8755
|
-
limit:
|
|
8756
|
-
offset:
|
|
8757
|
-
order:
|
|
9480
|
+
requestedAfter: z30.string().optional(),
|
|
9481
|
+
requestedBefore: z30.string().optional(),
|
|
9482
|
+
limit: z30.string().optional(),
|
|
9483
|
+
offset: z30.string().optional(),
|
|
9484
|
+
order: z30.enum(["asc", "desc"]).optional()
|
|
8758
9485
|
});
|
|
8759
|
-
var RequestWorkflowRunBodySchema =
|
|
9486
|
+
var RequestWorkflowRunBodySchema = z30.object({
|
|
8760
9487
|
input: WorkflowIOSnapshotSchema.optional()
|
|
8761
9488
|
}).default({});
|
|
8762
|
-
var WorkflowInterventionActorSchema =
|
|
8763
|
-
principalType:
|
|
8764
|
-
principalId:
|
|
9489
|
+
var WorkflowInterventionActorSchema = z30.object({
|
|
9490
|
+
principalType: z30.enum(["user", "serviceAccount", "system"]),
|
|
9491
|
+
principalId: z30.string().min(1)
|
|
8765
9492
|
});
|
|
8766
|
-
var CancelWorkflowRunBodySchema =
|
|
8767
|
-
var SubmitWorkflowInterventionBodySchema =
|
|
9493
|
+
var CancelWorkflowRunBodySchema = z30.object({}).default({});
|
|
9494
|
+
var SubmitWorkflowInterventionBodySchema = z30.object({
|
|
8768
9495
|
response: WorkflowIOSnapshotSchema
|
|
8769
9496
|
});
|
|
8770
|
-
var CancelWorkflowInterventionBodySchema =
|
|
8771
|
-
var WorkflowTriggerSchema =
|
|
8772
|
-
type:
|
|
8773
|
-
scheduleId:
|
|
9497
|
+
var CancelWorkflowInterventionBodySchema = z30.object({}).default({});
|
|
9498
|
+
var WorkflowTriggerSchema = z30.object({
|
|
9499
|
+
type: z30.literal("schedule"),
|
|
9500
|
+
scheduleId: z30.string()
|
|
8774
9501
|
});
|
|
8775
|
-
var WorkflowNodeSchema =
|
|
8776
|
-
|
|
8777
|
-
type:
|
|
8778
|
-
id:
|
|
8779
|
-
key:
|
|
9502
|
+
var WorkflowNodeSchema = z30.union([
|
|
9503
|
+
z30.object({
|
|
9504
|
+
type: z30.literal("step"),
|
|
9505
|
+
id: z30.string(),
|
|
9506
|
+
key: z30.string(),
|
|
8780
9507
|
input: WorkflowIOSnapshotSchema,
|
|
8781
9508
|
output: WorkflowIOSnapshotSchema
|
|
8782
9509
|
}),
|
|
8783
|
-
|
|
8784
|
-
type:
|
|
8785
|
-
id:
|
|
8786
|
-
key:
|
|
8787
|
-
objectTypeId:
|
|
9510
|
+
z30.object({
|
|
9511
|
+
type: z30.literal("action"),
|
|
9512
|
+
id: z30.string(),
|
|
9513
|
+
key: z30.string(),
|
|
9514
|
+
objectTypeId: z30.string().optional(),
|
|
8788
9515
|
params: WorkflowIOSnapshotSchema
|
|
8789
9516
|
}),
|
|
8790
|
-
|
|
8791
|
-
type:
|
|
8792
|
-
id:
|
|
8793
|
-
key:
|
|
9517
|
+
z30.object({
|
|
9518
|
+
type: z30.literal("intervention"),
|
|
9519
|
+
id: z30.string(),
|
|
9520
|
+
key: z30.string(),
|
|
8794
9521
|
input: WorkflowIOSnapshotSchema,
|
|
8795
9522
|
response: WorkflowIOSnapshotSchema,
|
|
8796
|
-
description:
|
|
9523
|
+
description: z30.string().optional()
|
|
8797
9524
|
}),
|
|
8798
|
-
|
|
8799
|
-
type:
|
|
8800
|
-
id:
|
|
8801
|
-
key:
|
|
9525
|
+
z30.object({
|
|
9526
|
+
type: z30.literal("agent"),
|
|
9527
|
+
id: z30.string(),
|
|
9528
|
+
key: z30.string(),
|
|
8802
9529
|
input: WorkflowIOSnapshotSchema,
|
|
8803
9530
|
output: WorkflowIOSnapshotSchema
|
|
8804
9531
|
})
|
|
8805
9532
|
]);
|
|
8806
|
-
var WorkflowRunSummarySchema =
|
|
8807
|
-
id:
|
|
8808
|
-
projectId:
|
|
8809
|
-
workflowId:
|
|
9533
|
+
var WorkflowRunSummarySchema = z30.object({
|
|
9534
|
+
id: z30.string(),
|
|
9535
|
+
projectId: z30.string(),
|
|
9536
|
+
workflowId: z30.string(),
|
|
8810
9537
|
status: WorkflowRunStatusSchema,
|
|
8811
|
-
queuedAt:
|
|
8812
|
-
startedAt:
|
|
8813
|
-
finishedAt:
|
|
9538
|
+
queuedAt: z30.string().optional(),
|
|
9539
|
+
startedAt: z30.string(),
|
|
9540
|
+
finishedAt: z30.string().optional(),
|
|
8814
9541
|
error: WorkflowRunFailureSchema.optional(),
|
|
8815
9542
|
requestedBy: WorkflowInterventionActorSchema
|
|
8816
9543
|
});
|
|
@@ -8818,110 +9545,110 @@ var WorkflowRunDetailSchema = WorkflowRunSummarySchema.extend({
|
|
|
8818
9545
|
input: WorkflowIOSnapshotSchema,
|
|
8819
9546
|
output: WorkflowIOSnapshotSchema.optional()
|
|
8820
9547
|
});
|
|
8821
|
-
var WorkflowAgentNodeExecutionSummarySchema =
|
|
8822
|
-
status:
|
|
8823
|
-
attempt:
|
|
8824
|
-
modelId:
|
|
8825
|
-
finishReason:
|
|
9548
|
+
var WorkflowAgentNodeExecutionSummarySchema = z30.object({
|
|
9549
|
+
status: z30.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
|
|
9550
|
+
attempt: z30.number().int().nonnegative(),
|
|
9551
|
+
modelId: z30.string().optional(),
|
|
9552
|
+
finishReason: z30.string().optional(),
|
|
8826
9553
|
usage: AiUsageSummarySchema.optional(),
|
|
8827
9554
|
cost: AiCostSummarySchema.optional(),
|
|
8828
|
-
startedAt:
|
|
8829
|
-
completedAt:
|
|
9555
|
+
startedAt: z30.string().optional(),
|
|
9556
|
+
completedAt: z30.string().optional()
|
|
8830
9557
|
});
|
|
8831
|
-
var WorkflowAgentFailurePhaseSchema =
|
|
9558
|
+
var WorkflowAgentFailurePhaseSchema = z30.enum(["agent-loop", "structured-finalizer"]);
|
|
8832
9559
|
var WorkflowAgentNodeExecutionSchema = WorkflowAgentNodeExecutionSummarySchema.extend({
|
|
8833
|
-
nodeRunId:
|
|
8834
|
-
prompt:
|
|
8835
|
-
trace:
|
|
8836
|
-
diagnostics:
|
|
9560
|
+
nodeRunId: z30.string(),
|
|
9561
|
+
prompt: z30.string(),
|
|
9562
|
+
trace: z30.array(AgentMessagePartSchema).optional(),
|
|
9563
|
+
diagnostics: z30.array(JsonValueSchema).optional(),
|
|
8837
9564
|
failurePhase: WorkflowAgentFailurePhaseSchema.optional(),
|
|
8838
9565
|
error: AgentRunFailureSchema.optional(),
|
|
8839
|
-
createdAt:
|
|
9566
|
+
createdAt: z30.string()
|
|
8840
9567
|
});
|
|
8841
|
-
var WorkflowNodeRunSchema =
|
|
8842
|
-
id:
|
|
8843
|
-
projectId:
|
|
8844
|
-
workflowRunId:
|
|
8845
|
-
workflowId:
|
|
8846
|
-
nodeIndex:
|
|
8847
|
-
nodeType:
|
|
8848
|
-
nodeId:
|
|
8849
|
-
nodeKey:
|
|
8850
|
-
status:
|
|
9568
|
+
var WorkflowNodeRunSchema = z30.object({
|
|
9569
|
+
id: z30.string(),
|
|
9570
|
+
projectId: z30.string(),
|
|
9571
|
+
workflowRunId: z30.string(),
|
|
9572
|
+
workflowId: z30.string(),
|
|
9573
|
+
nodeIndex: z30.number(),
|
|
9574
|
+
nodeType: z30.enum(["step", "action", "intervention", "agent"]),
|
|
9575
|
+
nodeId: z30.string(),
|
|
9576
|
+
nodeKey: z30.string(),
|
|
9577
|
+
status: z30.enum(["running", "waiting", "succeeded", "failed", "cancelled"]),
|
|
8851
9578
|
input: WorkflowIOSnapshotSchema,
|
|
8852
|
-
startedAt:
|
|
8853
|
-
finishedAt:
|
|
9579
|
+
startedAt: z30.string(),
|
|
9580
|
+
finishedAt: z30.string().optional(),
|
|
8854
9581
|
output: WorkflowIOSnapshotSchema.optional(),
|
|
8855
9582
|
error: WorkflowRunFailureSchema.optional(),
|
|
8856
9583
|
agentExecution: WorkflowAgentNodeExecutionSummarySchema.optional()
|
|
8857
9584
|
});
|
|
8858
|
-
var WorkflowInterventionSchema =
|
|
8859
|
-
id:
|
|
8860
|
-
projectId:
|
|
8861
|
-
workflowId:
|
|
8862
|
-
workflowRunId:
|
|
8863
|
-
nodeRunId:
|
|
8864
|
-
nodeIndex:
|
|
8865
|
-
nodeId:
|
|
8866
|
-
nodeKey:
|
|
8867
|
-
interventionId:
|
|
9585
|
+
var WorkflowInterventionSchema = z30.object({
|
|
9586
|
+
id: z30.string(),
|
|
9587
|
+
projectId: z30.string(),
|
|
9588
|
+
workflowId: z30.string(),
|
|
9589
|
+
workflowRunId: z30.string(),
|
|
9590
|
+
nodeRunId: z30.string(),
|
|
9591
|
+
nodeIndex: z30.number(),
|
|
9592
|
+
nodeId: z30.string(),
|
|
9593
|
+
nodeKey: z30.string(),
|
|
9594
|
+
interventionId: z30.string(),
|
|
8868
9595
|
input: WorkflowIOSnapshotSchema,
|
|
8869
9596
|
defaultResponse: WorkflowIOSnapshotSchema,
|
|
8870
9597
|
status: WorkflowInterventionStatusSchema,
|
|
8871
|
-
requestedAt:
|
|
8872
|
-
expiresAt:
|
|
8873
|
-
submittedAt:
|
|
9598
|
+
requestedAt: z30.string(),
|
|
9599
|
+
expiresAt: z30.string().optional(),
|
|
9600
|
+
submittedAt: z30.string().optional(),
|
|
8874
9601
|
submittedBy: WorkflowInterventionActorSchema.optional(),
|
|
8875
9602
|
response: WorkflowIOSnapshotSchema.optional(),
|
|
8876
|
-
cancelledAt:
|
|
9603
|
+
cancelledAt: z30.string().optional(),
|
|
8877
9604
|
cancelledBy: WorkflowInterventionActorSchema.optional(),
|
|
8878
|
-
expiredAt:
|
|
9605
|
+
expiredAt: z30.string().optional()
|
|
8879
9606
|
});
|
|
8880
|
-
var WorkflowSchema =
|
|
8881
|
-
id:
|
|
9607
|
+
var WorkflowSchema = z30.object({
|
|
9608
|
+
id: z30.string(),
|
|
8882
9609
|
input: WorkflowIOSnapshotSchema,
|
|
8883
|
-
triggers:
|
|
8884
|
-
nodes:
|
|
9610
|
+
triggers: z30.array(WorkflowTriggerSchema),
|
|
9611
|
+
nodes: z30.array(WorkflowNodeSchema),
|
|
8885
9612
|
latestRun: WorkflowRunSummarySchema.nullable()
|
|
8886
9613
|
});
|
|
8887
|
-
var WorkflowRunListResponseSchema =
|
|
8888
|
-
runs:
|
|
8889
|
-
hasMore:
|
|
8890
|
-
total:
|
|
9614
|
+
var WorkflowRunListResponseSchema = z30.object({
|
|
9615
|
+
runs: z30.array(WorkflowRunSummarySchema),
|
|
9616
|
+
hasMore: z30.boolean(),
|
|
9617
|
+
total: z30.number()
|
|
8891
9618
|
});
|
|
8892
|
-
var WorkflowRunDetailResponseSchema =
|
|
9619
|
+
var WorkflowRunDetailResponseSchema = z30.object({
|
|
8893
9620
|
run: WorkflowRunDetailSchema,
|
|
8894
|
-
nodes:
|
|
9621
|
+
nodes: z30.array(WorkflowNodeRunSchema)
|
|
8895
9622
|
});
|
|
8896
9623
|
var CancelWorkflowRunResponseSchema = WorkflowRunDetailResponseSchema;
|
|
8897
|
-
var WorkflowInterventionListResponseSchema =
|
|
8898
|
-
interventions:
|
|
8899
|
-
hasMore:
|
|
8900
|
-
total:
|
|
9624
|
+
var WorkflowInterventionListResponseSchema = z30.object({
|
|
9625
|
+
interventions: z30.array(WorkflowInterventionSchema),
|
|
9626
|
+
hasMore: z30.boolean(),
|
|
9627
|
+
total: z30.number()
|
|
8901
9628
|
});
|
|
8902
|
-
var SubmitWorkflowInterventionResponseSchema =
|
|
9629
|
+
var SubmitWorkflowInterventionResponseSchema = z30.object({
|
|
8903
9630
|
intervention: WorkflowInterventionSchema,
|
|
8904
|
-
jobId:
|
|
9631
|
+
jobId: z30.string()
|
|
8905
9632
|
});
|
|
8906
|
-
var CancelWorkflowInterventionResponseSchema =
|
|
9633
|
+
var CancelWorkflowInterventionResponseSchema = z30.object({
|
|
8907
9634
|
intervention: WorkflowInterventionSchema
|
|
8908
9635
|
});
|
|
8909
|
-
var RequestWorkflowRunResponseSchema =
|
|
8910
|
-
runId:
|
|
8911
|
-
jobId:
|
|
8912
|
-
workflowId:
|
|
8913
|
-
queuedAt:
|
|
9636
|
+
var RequestWorkflowRunResponseSchema = z30.object({
|
|
9637
|
+
runId: z30.string(),
|
|
9638
|
+
jobId: z30.string(),
|
|
9639
|
+
workflowId: z30.string(),
|
|
9640
|
+
queuedAt: z30.string()
|
|
8914
9641
|
});
|
|
8915
9642
|
|
|
8916
9643
|
// src/routes/workflows.ts
|
|
8917
9644
|
var WorkflowRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
8918
|
-
path:
|
|
9645
|
+
path: z31.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow run file content paths must start with /input/ or /output/")
|
|
8919
9646
|
});
|
|
8920
9647
|
var WorkflowNodeFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
8921
|
-
path:
|
|
9648
|
+
path: z31.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow node file content paths must start with /input/ or /output/")
|
|
8922
9649
|
});
|
|
8923
9650
|
var WorkflowNodeFileContentParamsSchema = WorkflowRunParamsSchema.extend({
|
|
8924
|
-
nodeKey:
|
|
9651
|
+
nodeKey: z31.string().min(1)
|
|
8925
9652
|
});
|
|
8926
9653
|
function serializeWorkflowRunSummary(run) {
|
|
8927
9654
|
return {
|
|
@@ -8991,12 +9718,12 @@ function serializeWorkflowAgentExecution(execution) {
|
|
|
8991
9718
|
}
|
|
8992
9719
|
function workflowAgentFailurePhase(execution) {
|
|
8993
9720
|
const details = execution.error?.details;
|
|
8994
|
-
if (!
|
|
9721
|
+
if (!isRecord2(details))
|
|
8995
9722
|
return;
|
|
8996
9723
|
const phase = details.failurePhase;
|
|
8997
9724
|
return phase === "agent-loop" || phase === "structured-finalizer" ? phase : undefined;
|
|
8998
9725
|
}
|
|
8999
|
-
function
|
|
9726
|
+
function isRecord2(value) {
|
|
9000
9727
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9001
9728
|
}
|
|
9002
9729
|
function principalForExecution(sixb) {
|
|
@@ -9508,13 +10235,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
9508
10235
|
if (!tx.workflowInterventions || !tx.workflowRuns) {
|
|
9509
10236
|
throw new Error("[SixbServer] Workflow storage disappeared during cancellation.");
|
|
9510
10237
|
}
|
|
9511
|
-
const
|
|
10238
|
+
const cancelled = await tx.workflowInterventions.cancel({
|
|
9512
10239
|
projectId: host.id,
|
|
9513
10240
|
id: intervention.id,
|
|
9514
10241
|
cancelledAt,
|
|
9515
10242
|
cancelledBy: serializePrincipal(principalForExecution(sixb))
|
|
9516
10243
|
});
|
|
9517
|
-
const
|
|
10244
|
+
const cancelledNode = await tx.workflowRuns.nodes.finish({
|
|
9518
10245
|
projectId: host.id,
|
|
9519
10246
|
id: intervention.nodeRunId,
|
|
9520
10247
|
status: "cancelled",
|
|
@@ -9527,7 +10254,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
9527
10254
|
nodeRunId: intervention.nodeRunId
|
|
9528
10255
|
})
|
|
9529
10256
|
});
|
|
9530
|
-
const
|
|
10257
|
+
const cancelledRun = await tx.workflowRuns.finish({
|
|
9531
10258
|
projectId: host.id,
|
|
9532
10259
|
id: intervention.workflowRunId,
|
|
9533
10260
|
status: "cancelled",
|
|
@@ -9539,7 +10266,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
9539
10266
|
runId: intervention.workflowRunId
|
|
9540
10267
|
})
|
|
9541
10268
|
});
|
|
9542
|
-
return { cancelled
|
|
10269
|
+
return { cancelled, cancelledNode, cancelledRun };
|
|
9543
10270
|
});
|
|
9544
10271
|
await emitWorkflowInterventionCancelled({
|
|
9545
10272
|
host,
|
|
@@ -9715,13 +10442,13 @@ function registerWorkflowRoutes(app, host) {
|
|
|
9715
10442
|
return { error: "Workflow not found" };
|
|
9716
10443
|
}
|
|
9717
10444
|
if (existing.status === "cancelled") {
|
|
9718
|
-
const
|
|
9719
|
-
if (!
|
|
10445
|
+
const nodes = await sixb.workflows.runs.listNodes(existing.id, { order: "asc" });
|
|
10446
|
+
if (!nodes) {
|
|
9720
10447
|
throw new Error(`[SixbServer] Authorized workflow run '${existing.id}' lost its execution view.`);
|
|
9721
10448
|
}
|
|
9722
10449
|
return CancelWorkflowRunResponseSchema.parse({
|
|
9723
10450
|
run: serializeWorkflowRunDetail(existing),
|
|
9724
|
-
nodes:
|
|
10451
|
+
nodes: nodes.nodes.map(serializeWorkflowNodeRun)
|
|
9725
10452
|
});
|
|
9726
10453
|
}
|
|
9727
10454
|
if (existing.status === "succeeded" || existing.status === "failed") {
|
|
@@ -9955,6 +10682,8 @@ function registerHttpRoutes(app, host, options) {
|
|
|
9955
10682
|
registerPipelineRoutes(app, host);
|
|
9956
10683
|
registerWorkflowRoutes(app, host);
|
|
9957
10684
|
registerRuleRoutes(app, host);
|
|
10685
|
+
registerShareGrantRoutes(app, host);
|
|
10686
|
+
registerSharedAccessRoutes(app, options.sharedAccess);
|
|
9958
10687
|
registerOntologyRoutes(app, host);
|
|
9959
10688
|
registerObjectRoutes(app, host);
|
|
9960
10689
|
registerActionRoutes(app, host);
|
|
@@ -9972,7 +10701,7 @@ function registerHttpRoutes(app, host, options) {
|
|
|
9972
10701
|
}
|
|
9973
10702
|
|
|
9974
10703
|
// src/routes/auth.ts
|
|
9975
|
-
import { createHash as
|
|
10704
|
+
import { createHash as createHash3, randomBytes, randomUUID, timingSafeEqual } from "crypto";
|
|
9976
10705
|
import {
|
|
9977
10706
|
AuthRuntimeError,
|
|
9978
10707
|
clearCsrfCookieHeader,
|
|
@@ -9981,12 +10710,12 @@ import {
|
|
|
9981
10710
|
createCsrfCookieHeader as createCsrfCookieHeader2,
|
|
9982
10711
|
createSessionCookieHeader as createSessionCookieHeader2,
|
|
9983
10712
|
createSessionCredential,
|
|
9984
|
-
generateCsrfToken as
|
|
9985
|
-
getCookie as
|
|
10713
|
+
generateCsrfToken as generateCsrfToken3,
|
|
10714
|
+
getCookie as getCookie4,
|
|
9986
10715
|
isMagicLinkAuthStrategy,
|
|
9987
10716
|
isOidcAuthStrategy,
|
|
9988
10717
|
shouldUseSecureCookies,
|
|
9989
|
-
verifyDoubleSubmitCsrf as
|
|
10718
|
+
verifyDoubleSubmitCsrf as verifyDoubleSubmitCsrf3
|
|
9990
10719
|
} from "@sixb/core/internal/auth";
|
|
9991
10720
|
import {
|
|
9992
10721
|
AuthStorageError
|
|
@@ -10124,301 +10853,301 @@ function notFoundResponse() {
|
|
|
10124
10853
|
}
|
|
10125
10854
|
|
|
10126
10855
|
// 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:
|
|
10856
|
+
import { z as z32 } from "zod";
|
|
10857
|
+
var AuthInvitationStatusSchema = z32.enum(["pending", "accepted", "revoked"]);
|
|
10858
|
+
var AuthGroupOptionSchema = z32.object({
|
|
10859
|
+
id: z32.string(),
|
|
10860
|
+
label: z32.string().optional(),
|
|
10861
|
+
description: z32.string().optional()
|
|
10862
|
+
});
|
|
10863
|
+
var AuthInvitationSchema = z32.object({
|
|
10864
|
+
id: z32.string(),
|
|
10865
|
+
email: z32.string(),
|
|
10866
|
+
groupIds: z32.array(z32.string()),
|
|
10138
10867
|
status: AuthInvitationStatusSchema,
|
|
10139
|
-
createdAt:
|
|
10140
|
-
updatedAt:
|
|
10141
|
-
expiresAt:
|
|
10142
|
-
acceptedAt:
|
|
10143
|
-
revokedAt:
|
|
10144
|
-
});
|
|
10145
|
-
var AuthInvitationDeliverySchema =
|
|
10146
|
-
status:
|
|
10147
|
-
link:
|
|
10148
|
-
url:
|
|
10149
|
-
expiresAt:
|
|
10868
|
+
createdAt: z32.string(),
|
|
10869
|
+
updatedAt: z32.string(),
|
|
10870
|
+
expiresAt: z32.string(),
|
|
10871
|
+
acceptedAt: z32.string().optional(),
|
|
10872
|
+
revokedAt: z32.string().optional()
|
|
10873
|
+
});
|
|
10874
|
+
var AuthInvitationDeliverySchema = z32.object({
|
|
10875
|
+
status: z32.enum(["sent", "skipped", "rate_limited", "not_supported"]),
|
|
10876
|
+
link: z32.object({
|
|
10877
|
+
url: z32.string().url(),
|
|
10878
|
+
expiresAt: z32.string().optional()
|
|
10150
10879
|
}).optional()
|
|
10151
10880
|
});
|
|
10152
10881
|
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:
|
|
10882
|
+
var AuthAccessTokenKindSchema = z32.enum(["personal", "serviceAccount"]);
|
|
10883
|
+
var AuthAccessTokenSubjectTypeSchema = z32.enum(["user", "serviceAccount"]);
|
|
10884
|
+
var AuthAccessTokenStatusSchema = z32.enum(["active", "expired", "revoked"]);
|
|
10885
|
+
var AuthServiceAccountStatusSchema = z32.enum(["active", "suspended"]);
|
|
10886
|
+
var AuthUserStatusSchema = z32.enum(["active", "suspended"]);
|
|
10887
|
+
var AuthAccessTokenSchema = z32.object({
|
|
10888
|
+
id: z32.string(),
|
|
10889
|
+
name: z32.string(),
|
|
10161
10890
|
kind: AuthAccessTokenKindSchema,
|
|
10162
10891
|
status: AuthAccessTokenStatusSchema,
|
|
10163
10892
|
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:
|
|
10893
|
+
subjectId: z32.string(),
|
|
10894
|
+
subjectLabel: z32.string().optional(),
|
|
10895
|
+
groupIds: z32.array(z32.string()).optional(),
|
|
10896
|
+
createdAt: z32.string(),
|
|
10897
|
+
expiresAt: z32.string(),
|
|
10898
|
+
revokedAt: z32.string().optional(),
|
|
10899
|
+
lastUsedAt: z32.string().optional(),
|
|
10900
|
+
lastUsedUserAgent: z32.string().optional(),
|
|
10901
|
+
lastUsedIpAddress: z32.string().optional()
|
|
10902
|
+
});
|
|
10903
|
+
var AuthServiceAccountSchema = z32.object({
|
|
10904
|
+
id: z32.string(),
|
|
10905
|
+
name: z32.string(),
|
|
10906
|
+
description: z32.string().optional(),
|
|
10178
10907
|
status: AuthServiceAccountStatusSchema,
|
|
10179
|
-
groupIds:
|
|
10180
|
-
createdAt:
|
|
10181
|
-
updatedAt:
|
|
10182
|
-
});
|
|
10183
|
-
var AuthMemberUserSchema =
|
|
10184
|
-
id:
|
|
10185
|
-
email:
|
|
10186
|
-
displayName:
|
|
10187
|
-
avatarUrl:
|
|
10908
|
+
groupIds: z32.array(z32.string()),
|
|
10909
|
+
createdAt: z32.string(),
|
|
10910
|
+
updatedAt: z32.string()
|
|
10911
|
+
});
|
|
10912
|
+
var AuthMemberUserSchema = z32.object({
|
|
10913
|
+
id: z32.string(),
|
|
10914
|
+
email: z32.string(),
|
|
10915
|
+
displayName: z32.string().optional(),
|
|
10916
|
+
avatarUrl: z32.string().optional(),
|
|
10188
10917
|
status: AuthUserStatusSchema,
|
|
10189
|
-
createdAt:
|
|
10190
|
-
updatedAt:
|
|
10918
|
+
createdAt: z32.string(),
|
|
10919
|
+
updatedAt: z32.string()
|
|
10191
10920
|
});
|
|
10192
|
-
var AuthManagedMemberSchema =
|
|
10921
|
+
var AuthManagedMemberSchema = z32.object({
|
|
10193
10922
|
user: AuthMemberUserSchema,
|
|
10194
|
-
groupIds:
|
|
10923
|
+
groupIds: z32.array(z32.string())
|
|
10195
10924
|
});
|
|
10196
|
-
var AuthMemberCapabilitiesSchema =
|
|
10197
|
-
assignGroups:
|
|
10198
|
-
suspend:
|
|
10199
|
-
reactivate:
|
|
10925
|
+
var AuthMemberCapabilitiesSchema = z32.object({
|
|
10926
|
+
assignGroups: z32.boolean(),
|
|
10927
|
+
suspend: z32.boolean(),
|
|
10928
|
+
reactivate: z32.boolean()
|
|
10200
10929
|
});
|
|
10201
10930
|
var AuthMemberSchema = AuthManagedMemberSchema.extend({
|
|
10202
10931
|
capabilities: AuthMemberCapabilitiesSchema
|
|
10203
10932
|
});
|
|
10204
|
-
var GetAuthAccessManagementOptionsResponseSchema =
|
|
10205
|
-
groups:
|
|
10933
|
+
var GetAuthAccessManagementOptionsResponseSchema = z32.object({
|
|
10934
|
+
groups: z32.array(AuthGroupOptionSchema)
|
|
10206
10935
|
});
|
|
10207
|
-
var ListAuthAccessTokensResponseSchema =
|
|
10208
|
-
accessTokens:
|
|
10936
|
+
var ListAuthAccessTokensResponseSchema = z32.object({
|
|
10937
|
+
accessTokens: z32.array(AuthAccessTokenSchema)
|
|
10209
10938
|
});
|
|
10210
|
-
var CreateAuthPersonalAccessTokenBodySchema =
|
|
10211
|
-
name:
|
|
10212
|
-
expiresAt:
|
|
10213
|
-
groupIds:
|
|
10939
|
+
var CreateAuthPersonalAccessTokenBodySchema = z32.object({
|
|
10940
|
+
name: z32.string().trim().min(1),
|
|
10941
|
+
expiresAt: z32.string().min(1),
|
|
10942
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10214
10943
|
});
|
|
10215
|
-
var CreateAuthPersonalAccessTokenResponseSchema =
|
|
10944
|
+
var CreateAuthPersonalAccessTokenResponseSchema = z32.object({
|
|
10216
10945
|
accessToken: AuthAccessTokenSchema,
|
|
10217
|
-
tokenValue:
|
|
10946
|
+
tokenValue: z32.string()
|
|
10218
10947
|
});
|
|
10219
|
-
var RevokeAuthAccessTokenParamsSchema =
|
|
10220
|
-
tokenId:
|
|
10948
|
+
var RevokeAuthAccessTokenParamsSchema = z32.object({
|
|
10949
|
+
tokenId: z32.string().min(1)
|
|
10221
10950
|
});
|
|
10222
|
-
var RevokeAuthAccessTokenResponseSchema =
|
|
10951
|
+
var RevokeAuthAccessTokenResponseSchema = z32.object({
|
|
10223
10952
|
accessToken: AuthAccessTokenSchema
|
|
10224
10953
|
});
|
|
10225
|
-
var ListAuthServiceAccountsResponseSchema =
|
|
10226
|
-
serviceAccounts:
|
|
10954
|
+
var ListAuthServiceAccountsResponseSchema = z32.object({
|
|
10955
|
+
serviceAccounts: z32.array(AuthServiceAccountSchema)
|
|
10227
10956
|
});
|
|
10228
|
-
var CreateAuthServiceAccountBodySchema =
|
|
10229
|
-
id:
|
|
10230
|
-
name:
|
|
10231
|
-
description:
|
|
10232
|
-
groupIds:
|
|
10957
|
+
var CreateAuthServiceAccountBodySchema = z32.object({
|
|
10958
|
+
id: z32.string().trim().min(1).optional(),
|
|
10959
|
+
name: z32.string().trim().min(1),
|
|
10960
|
+
description: z32.string().trim().optional(),
|
|
10961
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10233
10962
|
});
|
|
10234
|
-
var CreateAuthServiceAccountResponseSchema =
|
|
10963
|
+
var CreateAuthServiceAccountResponseSchema = z32.object({
|
|
10235
10964
|
serviceAccount: AuthServiceAccountSchema
|
|
10236
10965
|
});
|
|
10237
|
-
var AuthServiceAccountParamsSchema =
|
|
10238
|
-
serviceAccountId:
|
|
10966
|
+
var AuthServiceAccountParamsSchema = z32.object({
|
|
10967
|
+
serviceAccountId: z32.string().min(1)
|
|
10239
10968
|
});
|
|
10240
|
-
var DisableAuthServiceAccountResponseSchema =
|
|
10969
|
+
var DisableAuthServiceAccountResponseSchema = z32.object({
|
|
10241
10970
|
serviceAccount: AuthServiceAccountSchema
|
|
10242
10971
|
});
|
|
10243
|
-
var ListAuthServiceAccountAccessTokensResponseSchema =
|
|
10244
|
-
accessTokens:
|
|
10972
|
+
var ListAuthServiceAccountAccessTokensResponseSchema = z32.object({
|
|
10973
|
+
accessTokens: z32.array(AuthAccessTokenSchema)
|
|
10245
10974
|
});
|
|
10246
|
-
var CreateAuthServiceAccountAccessTokenBodySchema =
|
|
10247
|
-
name:
|
|
10248
|
-
expiresAt:
|
|
10249
|
-
groupIds:
|
|
10975
|
+
var CreateAuthServiceAccountAccessTokenBodySchema = z32.object({
|
|
10976
|
+
name: z32.string().trim().min(1),
|
|
10977
|
+
expiresAt: z32.string().min(1),
|
|
10978
|
+
groupIds: z32.array(z32.string().min(1)).optional()
|
|
10250
10979
|
});
|
|
10251
|
-
var CreateAuthServiceAccountAccessTokenResponseSchema =
|
|
10980
|
+
var CreateAuthServiceAccountAccessTokenResponseSchema = z32.object({
|
|
10252
10981
|
accessToken: AuthAccessTokenSchema,
|
|
10253
|
-
tokenValue:
|
|
10982
|
+
tokenValue: z32.string()
|
|
10254
10983
|
});
|
|
10255
10984
|
var RevokeAuthServiceAccountAccessTokenParamsSchema = AuthServiceAccountParamsSchema.extend({
|
|
10256
|
-
tokenId:
|
|
10985
|
+
tokenId: z32.string().min(1)
|
|
10257
10986
|
});
|
|
10258
|
-
var RevokeAuthServiceAccountAccessTokenResponseSchema =
|
|
10987
|
+
var RevokeAuthServiceAccountAccessTokenResponseSchema = z32.object({
|
|
10259
10988
|
accessToken: AuthAccessTokenSchema
|
|
10260
10989
|
});
|
|
10261
|
-
var AuthCreateInvitationCapabilitySchema =
|
|
10262
|
-
|
|
10263
|
-
state:
|
|
10990
|
+
var AuthCreateInvitationCapabilitySchema = z32.union([
|
|
10991
|
+
z32.object({
|
|
10992
|
+
state: z32.literal("enabled")
|
|
10264
10993
|
}),
|
|
10265
|
-
|
|
10266
|
-
state:
|
|
10267
|
-
reason:
|
|
10994
|
+
z32.object({
|
|
10995
|
+
state: z32.literal("disabled"),
|
|
10996
|
+
reason: z32.enum(["missing_membership_policy", "invitation_delivery_not_supported"])
|
|
10268
10997
|
})
|
|
10269
10998
|
]);
|
|
10270
|
-
var AuthInvitationDestinationSchema =
|
|
10271
|
-
id:
|
|
10272
|
-
label:
|
|
10273
|
-
});
|
|
10274
|
-
var GetAuthInvitationOptionsResponseSchema =
|
|
10275
|
-
groups:
|
|
10276
|
-
destinations:
|
|
10277
|
-
defaultDestinationId:
|
|
10278
|
-
canInviteWithoutGroups:
|
|
10279
|
-
capabilities:
|
|
10999
|
+
var AuthInvitationDestinationSchema = z32.object({
|
|
11000
|
+
id: z32.enum(["atlas", "app"]),
|
|
11001
|
+
label: z32.string()
|
|
11002
|
+
});
|
|
11003
|
+
var GetAuthInvitationOptionsResponseSchema = z32.object({
|
|
11004
|
+
groups: z32.array(AuthInvitationGroupOptionSchema),
|
|
11005
|
+
destinations: z32.array(AuthInvitationDestinationSchema),
|
|
11006
|
+
defaultDestinationId: z32.enum(["atlas", "app"]).optional(),
|
|
11007
|
+
canInviteWithoutGroups: z32.boolean(),
|
|
11008
|
+
capabilities: z32.object({
|
|
10280
11009
|
createInvitation: AuthCreateInvitationCapabilitySchema
|
|
10281
11010
|
})
|
|
10282
11011
|
});
|
|
10283
|
-
var GetAuthMembershipOptionsResponseSchema =
|
|
10284
|
-
groups:
|
|
10285
|
-
capabilities:
|
|
10286
|
-
invite:
|
|
10287
|
-
assignGroups:
|
|
10288
|
-
suspend:
|
|
11012
|
+
var GetAuthMembershipOptionsResponseSchema = z32.object({
|
|
11013
|
+
groups: z32.array(AuthGroupOptionSchema),
|
|
11014
|
+
capabilities: z32.object({
|
|
11015
|
+
invite: z32.boolean(),
|
|
11016
|
+
assignGroups: z32.boolean(),
|
|
11017
|
+
suspend: z32.boolean()
|
|
10289
11018
|
})
|
|
10290
11019
|
});
|
|
10291
|
-
var ListAuthMembersQuerySchema =
|
|
10292
|
-
limit:
|
|
10293
|
-
offset:
|
|
10294
|
-
order:
|
|
11020
|
+
var ListAuthMembersQuerySchema = z32.object({
|
|
11021
|
+
limit: z32.string().optional(),
|
|
11022
|
+
offset: z32.string().optional(),
|
|
11023
|
+
order: z32.enum(["asc", "desc"]).optional()
|
|
10295
11024
|
});
|
|
10296
|
-
var ListAuthMembersResponseSchema =
|
|
10297
|
-
members:
|
|
10298
|
-
hasMore:
|
|
10299
|
-
total:
|
|
11025
|
+
var ListAuthMembersResponseSchema = z32.object({
|
|
11026
|
+
members: z32.array(AuthMemberSchema),
|
|
11027
|
+
hasMore: z32.boolean(),
|
|
11028
|
+
total: z32.number()
|
|
10300
11029
|
});
|
|
10301
|
-
var AuthMemberParamsSchema =
|
|
10302
|
-
userId:
|
|
11030
|
+
var AuthMemberParamsSchema = z32.object({
|
|
11031
|
+
userId: z32.string().min(1)
|
|
10303
11032
|
});
|
|
10304
|
-
var UpdateAuthMemberGroupsBodySchema =
|
|
10305
|
-
groupIds:
|
|
11033
|
+
var UpdateAuthMemberGroupsBodySchema = z32.object({
|
|
11034
|
+
groupIds: z32.array(z32.string().min(1))
|
|
10306
11035
|
});
|
|
10307
|
-
var UpdateAuthMemberGroupsResponseSchema =
|
|
11036
|
+
var UpdateAuthMemberGroupsResponseSchema = z32.object({
|
|
10308
11037
|
member: AuthManagedMemberSchema
|
|
10309
11038
|
});
|
|
10310
|
-
var SuspendAuthMemberResponseSchema =
|
|
11039
|
+
var SuspendAuthMemberResponseSchema = z32.object({
|
|
10311
11040
|
member: AuthManagedMemberSchema
|
|
10312
11041
|
});
|
|
10313
|
-
var ReactivateAuthMemberResponseSchema =
|
|
11042
|
+
var ReactivateAuthMemberResponseSchema = z32.object({
|
|
10314
11043
|
member: AuthManagedMemberSchema
|
|
10315
11044
|
});
|
|
10316
|
-
var CreateAuthInvitationBodySchema =
|
|
10317
|
-
email:
|
|
10318
|
-
groupIds:
|
|
10319
|
-
destinationId:
|
|
10320
|
-
expiresAt:
|
|
10321
|
-
returnTo:
|
|
10322
|
-
revealLink:
|
|
11045
|
+
var CreateAuthInvitationBodySchema = z32.object({
|
|
11046
|
+
email: z32.string().min(1),
|
|
11047
|
+
groupIds: z32.array(z32.string().min(1)).optional(),
|
|
11048
|
+
destinationId: z32.enum(["atlas", "app"]).optional(),
|
|
11049
|
+
expiresAt: z32.string().optional(),
|
|
11050
|
+
returnTo: z32.string().optional(),
|
|
11051
|
+
revealLink: z32.boolean().optional()
|
|
10323
11052
|
});
|
|
10324
|
-
var CreateAuthInvitationResponseSchema =
|
|
11053
|
+
var CreateAuthInvitationResponseSchema = z32.object({
|
|
10325
11054
|
invitation: AuthInvitationSchema,
|
|
10326
11055
|
delivery: AuthInvitationDeliverySchema
|
|
10327
11056
|
});
|
|
10328
|
-
var ListAuthInvitationsQuerySchema =
|
|
10329
|
-
email:
|
|
11057
|
+
var ListAuthInvitationsQuerySchema = z32.object({
|
|
11058
|
+
email: z32.string().optional(),
|
|
10330
11059
|
status: AuthInvitationStatusSchema.optional(),
|
|
10331
|
-
limit:
|
|
10332
|
-
offset:
|
|
10333
|
-
order:
|
|
11060
|
+
limit: z32.string().optional(),
|
|
11061
|
+
offset: z32.string().optional(),
|
|
11062
|
+
order: z32.enum(["asc", "desc"]).optional()
|
|
10334
11063
|
});
|
|
10335
|
-
var ListAuthInvitationsResponseSchema =
|
|
10336
|
-
invitations:
|
|
10337
|
-
hasMore:
|
|
10338
|
-
total:
|
|
11064
|
+
var ListAuthInvitationsResponseSchema = z32.object({
|
|
11065
|
+
invitations: z32.array(AuthInvitationSchema),
|
|
11066
|
+
hasMore: z32.boolean(),
|
|
11067
|
+
total: z32.number()
|
|
10339
11068
|
});
|
|
10340
|
-
var RevokeAuthInvitationParamsSchema =
|
|
10341
|
-
invitationId:
|
|
11069
|
+
var RevokeAuthInvitationParamsSchema = z32.object({
|
|
11070
|
+
invitationId: z32.string().min(1)
|
|
10342
11071
|
});
|
|
10343
|
-
var RevokeAuthInvitationResponseSchema =
|
|
11072
|
+
var RevokeAuthInvitationResponseSchema = z32.object({
|
|
10344
11073
|
invitation: AuthInvitationSchema
|
|
10345
11074
|
});
|
|
10346
|
-
var AuthSessionResponseSchema =
|
|
10347
|
-
|
|
10348
|
-
authenticated:
|
|
11075
|
+
var AuthSessionResponseSchema = z32.union([
|
|
11076
|
+
z32.object({
|
|
11077
|
+
authenticated: z32.literal(false)
|
|
10349
11078
|
}),
|
|
10350
|
-
|
|
10351
|
-
authenticated:
|
|
10352
|
-
csrfToken:
|
|
10353
|
-
applicationAccess:
|
|
10354
|
-
allowed:
|
|
10355
|
-
audience:
|
|
11079
|
+
z32.object({
|
|
11080
|
+
authenticated: z32.literal(true),
|
|
11081
|
+
csrfToken: z32.string(),
|
|
11082
|
+
applicationAccess: z32.object({
|
|
11083
|
+
allowed: z32.boolean(),
|
|
11084
|
+
audience: z32.enum(["atlas", "app"])
|
|
10356
11085
|
}),
|
|
10357
|
-
user:
|
|
10358
|
-
id:
|
|
10359
|
-
email:
|
|
10360
|
-
displayName:
|
|
10361
|
-
avatarUrl:
|
|
10362
|
-
groupIds:
|
|
11086
|
+
user: z32.object({
|
|
11087
|
+
id: z32.string(),
|
|
11088
|
+
email: z32.string(),
|
|
11089
|
+
displayName: z32.string().optional(),
|
|
11090
|
+
avatarUrl: z32.string().optional(),
|
|
11091
|
+
groupIds: z32.array(z32.string())
|
|
10363
11092
|
}),
|
|
10364
|
-
session:
|
|
10365
|
-
id:
|
|
10366
|
-
expiresAt:
|
|
11093
|
+
session: z32.object({
|
|
11094
|
+
id: z32.string(),
|
|
11095
|
+
expiresAt: z32.string()
|
|
10367
11096
|
})
|
|
10368
11097
|
})
|
|
10369
11098
|
]);
|
|
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
|
-
|
|
11099
|
+
var AuthSignOutResponseSchema = z32.object({
|
|
11100
|
+
success: z32.boolean()
|
|
11101
|
+
});
|
|
11102
|
+
var CreateDeviceAuthorizationBodySchema = z32.object({
|
|
11103
|
+
clientName: z32.string().trim().min(1).max(100),
|
|
11104
|
+
tokenName: z32.string().trim().min(1).max(100),
|
|
11105
|
+
expiresIn: z32.literal("90d").optional()
|
|
11106
|
+
});
|
|
11107
|
+
var CreateDeviceAuthorizationResponseSchema = z32.object({
|
|
11108
|
+
deviceCode: z32.string(),
|
|
11109
|
+
userCode: z32.string(),
|
|
11110
|
+
verificationUri: z32.string(),
|
|
11111
|
+
verificationUriComplete: z32.string(),
|
|
11112
|
+
expiresAt: z32.string(),
|
|
11113
|
+
interval: z32.number()
|
|
11114
|
+
});
|
|
11115
|
+
var ExchangeDeviceAuthorizationBodySchema = z32.object({
|
|
11116
|
+
deviceCode: z32.string().min(1)
|
|
11117
|
+
});
|
|
11118
|
+
var ExchangeDeviceAuthorizationResponseSchema = z32.union([
|
|
11119
|
+
z32.object({ status: z32.literal("pending") }),
|
|
11120
|
+
z32.object({ status: z32.literal("denied") }),
|
|
11121
|
+
z32.object({ status: z32.literal("expired") }),
|
|
11122
|
+
z32.object({ status: z32.literal("approved"), accessToken: z32.string() })
|
|
10394
11123
|
]);
|
|
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:
|
|
11124
|
+
var DeviceAuthorizationDecisionBodySchema = z32.object({
|
|
11125
|
+
userCode: z32.string().trim().min(1),
|
|
11126
|
+
decision: z32.enum(["approve", "deny"]),
|
|
11127
|
+
csrfToken: z32.string().min(1)
|
|
11128
|
+
});
|
|
11129
|
+
var AuthSessionSummarySchema = z32.object({
|
|
11130
|
+
id: z32.string(),
|
|
11131
|
+
audience: z32.enum(["atlas", "app"]),
|
|
11132
|
+
current: z32.boolean(),
|
|
11133
|
+
createdAt: z32.string(),
|
|
11134
|
+
expiresAt: z32.string(),
|
|
11135
|
+
lastSeenAt: z32.string().optional(),
|
|
11136
|
+
userAgent: z32.string().optional(),
|
|
11137
|
+
ipAddress: z32.string().optional()
|
|
11138
|
+
});
|
|
11139
|
+
var ListAuthSessionsResponseSchema = z32.object({
|
|
11140
|
+
sessions: z32.array(AuthSessionSummarySchema)
|
|
11141
|
+
});
|
|
11142
|
+
var RevokeAuthSessionParamsSchema = z32.object({
|
|
11143
|
+
sessionId: z32.string().min(1)
|
|
11144
|
+
});
|
|
11145
|
+
var RevokeAuthSessionResponseSchema = z32.object({
|
|
11146
|
+
success: z32.boolean()
|
|
11147
|
+
});
|
|
11148
|
+
var SignOutAllResponseSchema = z32.object({
|
|
11149
|
+
success: z32.boolean(),
|
|
11150
|
+
revokedCount: z32.number()
|
|
10422
11151
|
});
|
|
10423
11152
|
|
|
10424
11153
|
// src/routes/auth.ts
|
|
@@ -10584,7 +11313,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10584
11313
|
}
|
|
10585
11314
|
const csrfHeaders = new Headers(request.headers);
|
|
10586
11315
|
csrfHeaders.set("x-sixb-csrf", parsed.csrfToken);
|
|
10587
|
-
if (!
|
|
11316
|
+
if (!verifyDoubleSubmitCsrf3(new Request(request.url, { method: "POST", headers: csrfHeaders }), {
|
|
10588
11317
|
cookieName: host.auth.getCookieOptions(authOptions).csrfCookieName
|
|
10589
11318
|
})) {
|
|
10590
11319
|
return authPageResponse("<h1>Invalid authorization request</h1>", 403);
|
|
@@ -10679,7 +11408,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10679
11408
|
const authOptions = resolveAuthOptions(options, request);
|
|
10680
11409
|
const session = await host.auth.getSession(request, authOptions);
|
|
10681
11410
|
const cookieOptions = host.auth.getCookieOptions(authOptions);
|
|
10682
|
-
if (session.authenticated && !
|
|
11411
|
+
if (session.authenticated && !verifyDoubleSubmitCsrf3(request, {
|
|
10683
11412
|
cookieName: cookieOptions.csrfCookieName
|
|
10684
11413
|
})) {
|
|
10685
11414
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
@@ -10750,7 +11479,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10750
11479
|
if (!session.authenticated) {
|
|
10751
11480
|
return jsonResponse2({ error: "Authentication required" }, 401);
|
|
10752
11481
|
}
|
|
10753
|
-
if (!
|
|
11482
|
+
if (!verifyDoubleSubmitCsrf3(request, { cookieName: cookieOptions.csrfCookieName })) {
|
|
10754
11483
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
10755
11484
|
}
|
|
10756
11485
|
const { sessionId } = RevokeAuthSessionParamsSchema.parse(params);
|
|
@@ -10788,7 +11517,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10788
11517
|
if (!session.authenticated) {
|
|
10789
11518
|
return jsonResponse2({ error: "Authentication required" }, 401);
|
|
10790
11519
|
}
|
|
10791
|
-
if (!
|
|
11520
|
+
if (!verifyDoubleSubmitCsrf3(request, { cookieName: cookieOptions.csrfCookieName })) {
|
|
10792
11521
|
return jsonResponse2({ error: "CSRF verification failed" }, 403);
|
|
10793
11522
|
}
|
|
10794
11523
|
const revoked = await requireAuthStorage(host).sessions.revokeActiveForUser({
|
|
@@ -11416,7 +12145,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
11416
12145
|
requesterHash: pending.hash
|
|
11417
12146
|
});
|
|
11418
12147
|
const response = await magicLinkRequestedResponse(options, authRedirect);
|
|
11419
|
-
const existingPending =
|
|
12148
|
+
const existingPending = getCookie4(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
11420
12149
|
response.headers.append("set-cookie", magicLinkPendingCookieHeader({
|
|
11421
12150
|
request,
|
|
11422
12151
|
host,
|
|
@@ -11497,7 +12226,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
11497
12226
|
}
|
|
11498
12227
|
}
|
|
11499
12228
|
const requesterHash = url.searchParams.get("requester")?.trim();
|
|
11500
|
-
const pendingSecret =
|
|
12229
|
+
const pendingSecret = getCookie4(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
11501
12230
|
if (requesterHash && pendingSecret && matchesMagicLinkRequester(pendingSecret, requesterHash)) {
|
|
11502
12231
|
return completeMagicLinkCallback({
|
|
11503
12232
|
host,
|
|
@@ -11587,7 +12316,7 @@ var DEVICE_ACCESS_TOKEN_TTL_MS = 90 * 24 * 60 * 60 * 1000;
|
|
|
11587
12316
|
var DEVICE_AUTHORIZATION_POLL_INTERVAL_SECONDS = 2;
|
|
11588
12317
|
var DEVICE_USER_CODE_ALPHABET = "BCDFGHJKLMNPQRSTVWXYZ23456789";
|
|
11589
12318
|
function hashDeviceCode(deviceCode) {
|
|
11590
|
-
return
|
|
12319
|
+
return createHash3("sha256").update(deviceCode).digest("base64url");
|
|
11591
12320
|
}
|
|
11592
12321
|
function parseDeviceAuthorizationId(deviceCode) {
|
|
11593
12322
|
const separator = deviceCode.indexOf(".");
|
|
@@ -11617,7 +12346,7 @@ function createMagicLinkPendingCredential() {
|
|
|
11617
12346
|
return { secret, hash: hashMagicLinkPendingSecret(secret) };
|
|
11618
12347
|
}
|
|
11619
12348
|
function hashMagicLinkPendingSecret(secret) {
|
|
11620
|
-
return
|
|
12349
|
+
return createHash3("sha256").update(secret).digest("base64url");
|
|
11621
12350
|
}
|
|
11622
12351
|
function matchesMagicLinkRequester(pendingSecret, requesterHash) {
|
|
11623
12352
|
const expected = Buffer.from(hashMagicLinkPendingSecret(pendingSecret));
|
|
@@ -11698,7 +12427,7 @@ function sessionCallbackCompletionResponse(input) {
|
|
|
11698
12427
|
}));
|
|
11699
12428
|
headers.append("set-cookie", createCsrfCookieHeader2({
|
|
11700
12429
|
request: input.request,
|
|
11701
|
-
value:
|
|
12430
|
+
value: generateCsrfToken3(),
|
|
11702
12431
|
expiresAt: input.expiresAt,
|
|
11703
12432
|
options: cookieOptions
|
|
11704
12433
|
}));
|
|
@@ -11758,11 +12487,11 @@ function resolveInvitationDeliveryContext(options, request, input) {
|
|
|
11758
12487
|
}
|
|
11759
12488
|
}
|
|
11760
12489
|
function resolveSessionCsrfToken(input) {
|
|
11761
|
-
const existing =
|
|
12490
|
+
const existing = getCookie4(input.request, input.cookieOptions.csrfCookieName);
|
|
11762
12491
|
if (existing) {
|
|
11763
12492
|
return { token: existing };
|
|
11764
12493
|
}
|
|
11765
|
-
const token =
|
|
12494
|
+
const token = generateCsrfToken3();
|
|
11766
12495
|
return {
|
|
11767
12496
|
token,
|
|
11768
12497
|
setCookie: createCsrfCookieHeader2({
|
|
@@ -12242,7 +12971,7 @@ function jsonResponse2(body, status, headersInit) {
|
|
|
12242
12971
|
}
|
|
12243
12972
|
|
|
12244
12973
|
// src/routes/webhooks.ts
|
|
12245
|
-
import { createHash as
|
|
12974
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
12246
12975
|
import { reportRunFailure } from "@sixb/core/internal/error-reporting";
|
|
12247
12976
|
import { captureSixbFailure, createSixbError as createSixbError5, toSixbFailure as toSixbFailure2 } from "@sixb/core/internal/errors";
|
|
12248
12977
|
import { bindDurablePrimitiveExecution } from "@sixb/core/internal/primitive-execution";
|
|
@@ -12351,7 +13080,7 @@ async function admitPreparedWebhook(options, runId, prepared) {
|
|
|
12351
13080
|
method: options.request.method.toUpperCase(),
|
|
12352
13081
|
route: options.registered.route,
|
|
12353
13082
|
requestBodyBytes: prepared.rawBody.byteLength,
|
|
12354
|
-
requestBodySha256:
|
|
13083
|
+
requestBodySha256: createHash4("sha256").update(prepared.rawBody).digest("hex"),
|
|
12355
13084
|
idempotencyKey: prepared.idempotencyKey
|
|
12356
13085
|
});
|
|
12357
13086
|
} catch (error) {
|
|
@@ -12385,7 +13114,7 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
12385
13114
|
client: createClientResolver(execution.sixb, connector)
|
|
12386
13115
|
});
|
|
12387
13116
|
} catch (error) {
|
|
12388
|
-
const
|
|
13117
|
+
const failed = createWebhookRunFailure({
|
|
12389
13118
|
registered,
|
|
12390
13119
|
runId,
|
|
12391
13120
|
idempotencyKey: prepared.idempotencyKey,
|
|
@@ -12393,13 +13122,13 @@ async function executeWebhookHandler(options, prepared, admission, logger) {
|
|
|
12393
13122
|
message: "Webhook handler failed",
|
|
12394
13123
|
cause: error
|
|
12395
13124
|
});
|
|
12396
|
-
reportFailure(
|
|
13125
|
+
reportFailure(failed.error, failed.failure);
|
|
12397
13126
|
try {
|
|
12398
13127
|
await finishWebhookRun(host, {
|
|
12399
13128
|
runId,
|
|
12400
13129
|
status: "failed",
|
|
12401
13130
|
responseStatus: 500,
|
|
12402
|
-
failure:
|
|
13131
|
+
failure: failed.failure
|
|
12403
13132
|
});
|
|
12404
13133
|
} catch (_finalizationError) {}
|
|
12405
13134
|
set.status = 500;
|
|
@@ -12531,13 +13260,15 @@ function isWebhookResponse(value) {
|
|
|
12531
13260
|
// src/routes/ws/agents.ts
|
|
12532
13261
|
import {
|
|
12533
13262
|
AGENT_ACTIVITY_STREAM_ID,
|
|
12534
|
-
agentActivityStreamDefinition,
|
|
12535
|
-
agentRunStreamDefinition,
|
|
12536
|
-
agentRunStreamId as agentRunStreamId2,
|
|
12537
13263
|
isAgentRunActivityEvent
|
|
12538
13264
|
} from "@sixb/core/agents/streams";
|
|
12539
13265
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
12540
|
-
import {
|
|
13266
|
+
import {
|
|
13267
|
+
agentActivityStreamDefinition,
|
|
13268
|
+
agentRunStreamDefinition,
|
|
13269
|
+
agentRunStreamId as agentRunStreamId2
|
|
13270
|
+
} from "@sixb/core/internal/agents/streams";
|
|
13271
|
+
import { z as z33 } from "zod";
|
|
12541
13272
|
|
|
12542
13273
|
// src/utils/ws.ts
|
|
12543
13274
|
function safeSend(target, payload) {
|
|
@@ -12585,25 +13316,25 @@ async function decodeWsMessage(message) {
|
|
|
12585
13316
|
}
|
|
12586
13317
|
|
|
12587
13318
|
// src/routes/ws/agents.ts
|
|
12588
|
-
var SubscribeSchema =
|
|
12589
|
-
type:
|
|
12590
|
-
runId:
|
|
12591
|
-
afterCursor:
|
|
13319
|
+
var SubscribeSchema = z33.object({
|
|
13320
|
+
type: z33.literal("subscribe"),
|
|
13321
|
+
runId: z33.string().min(1),
|
|
13322
|
+
afterCursor: z33.string().min(1).optional()
|
|
12592
13323
|
});
|
|
12593
|
-
var SubscribeActivitySchema =
|
|
12594
|
-
type:
|
|
13324
|
+
var SubscribeActivitySchema = z33.object({
|
|
13325
|
+
type: z33.literal("subscribe.activity")
|
|
12595
13326
|
});
|
|
12596
|
-
var ReplaySchema =
|
|
12597
|
-
type:
|
|
12598
|
-
runId:
|
|
12599
|
-
afterCursor:
|
|
12600
|
-
limit:
|
|
13327
|
+
var ReplaySchema = z33.object({
|
|
13328
|
+
type: z33.literal("replay"),
|
|
13329
|
+
runId: z33.string().min(1),
|
|
13330
|
+
afterCursor: z33.string().min(1).optional(),
|
|
13331
|
+
limit: z33.number().int().positive().max(500).optional()
|
|
12601
13332
|
});
|
|
12602
|
-
var UnsubscribeSchema =
|
|
12603
|
-
type:
|
|
12604
|
-
runId:
|
|
13333
|
+
var UnsubscribeSchema = z33.object({
|
|
13334
|
+
type: z33.literal("unsubscribe"),
|
|
13335
|
+
runId: z33.string().min(1).optional()
|
|
12605
13336
|
});
|
|
12606
|
-
var AgentStreamMessageSchema =
|
|
13337
|
+
var AgentStreamMessageSchema = z33.union([
|
|
12607
13338
|
SubscribeSchema,
|
|
12608
13339
|
SubscribeActivitySchema,
|
|
12609
13340
|
ReplaySchema,
|
|
@@ -12899,23 +13630,23 @@ function errorMessage(error) {
|
|
|
12899
13630
|
}
|
|
12900
13631
|
|
|
12901
13632
|
// src/routes/ws/events.ts
|
|
12902
|
-
import { scopeKeysForEvent } from "@sixb/core/
|
|
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 =
|
|
13633
|
+
import { scopeKeysForEvent } from "@sixb/core/internal/event-scope";
|
|
13634
|
+
import { z as z34 } from "zod";
|
|
13635
|
+
var SubscribeSchema2 = z34.object({
|
|
13636
|
+
type: z34.literal("subscribe"),
|
|
13637
|
+
topic: z34.enum(EVENT_TOPICS).optional(),
|
|
13638
|
+
types: z34.array(z34.enum(EVENT_TYPES)).optional(),
|
|
13639
|
+
objectTypeId: z34.string().optional(),
|
|
13640
|
+
primaryId: z34.string().optional(),
|
|
13641
|
+
actionId: z34.string().optional(),
|
|
13642
|
+
runId: z34.string().optional(),
|
|
13643
|
+
afterCursor: z34.string().optional(),
|
|
13644
|
+
limit: z34.number().int().positive().max(500).optional()
|
|
13645
|
+
});
|
|
13646
|
+
var UnsubscribeSchema2 = z34.object({
|
|
13647
|
+
type: z34.literal("unsubscribe")
|
|
13648
|
+
});
|
|
13649
|
+
var SubscriptionMessageSchema = z34.union([SubscribeSchema2, UnsubscribeSchema2]);
|
|
12919
13650
|
function parseSubscriptionMessage(payload) {
|
|
12920
13651
|
if (!payload || typeof payload !== "object") {
|
|
12921
13652
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -13105,7 +13836,7 @@ function eventMatchesScope(event, filter) {
|
|
|
13105
13836
|
}
|
|
13106
13837
|
|
|
13107
13838
|
// src/routes/ws/logs.ts
|
|
13108
|
-
import { z as
|
|
13839
|
+
import { z as z35 } from "zod";
|
|
13109
13840
|
|
|
13110
13841
|
// src/routes/ws/log-subscription-hub.ts
|
|
13111
13842
|
import { BrokerCursorExpiredError as BrokerCursorExpiredError2 } from "@sixb/core/broker";
|
|
@@ -13355,13 +14086,13 @@ class LogSubscriptionHub {
|
|
|
13355
14086
|
this.scheduleFlush(state);
|
|
13356
14087
|
}
|
|
13357
14088
|
waitForQueueProgress(state) {
|
|
13358
|
-
return new Promise((
|
|
14089
|
+
return new Promise((resolve) => state.queueProgressWaiters.add(resolve));
|
|
13359
14090
|
}
|
|
13360
14091
|
notifyQueueProgress(state) {
|
|
13361
14092
|
const waiters = [...state.queueProgressWaiters];
|
|
13362
14093
|
state.queueProgressWaiters.clear();
|
|
13363
|
-
for (const
|
|
13364
|
-
|
|
14094
|
+
for (const resolve of waiters)
|
|
14095
|
+
resolve();
|
|
13365
14096
|
}
|
|
13366
14097
|
send(state, payload) {
|
|
13367
14098
|
if (state.closed)
|
|
@@ -13418,26 +14149,26 @@ function socketBufferedAmount(ws) {
|
|
|
13418
14149
|
}
|
|
13419
14150
|
|
|
13420
14151
|
// src/routes/ws/logs.ts
|
|
13421
|
-
var SubscribeSchema3 =
|
|
13422
|
-
type:
|
|
13423
|
-
kinds:
|
|
13424
|
-
levels:
|
|
13425
|
-
run:
|
|
13426
|
-
kind:
|
|
14152
|
+
var SubscribeSchema3 = z35.object({
|
|
14153
|
+
type: z35.literal("subscribe"),
|
|
14154
|
+
kinds: z35.array(z35.enum(SIXB_RUN_KINDS)).min(1).optional(),
|
|
14155
|
+
levels: z35.array(z35.enum(LOG_LEVELS)).min(1).optional(),
|
|
14156
|
+
run: z35.object({
|
|
14157
|
+
kind: z35.enum(SIXB_RUN_KINDS),
|
|
13427
14158
|
id: LogRunIdSchema
|
|
13428
14159
|
}).optional(),
|
|
13429
|
-
afterCursor:
|
|
14160
|
+
afterCursor: z35.string().optional()
|
|
13430
14161
|
}).superRefine((value, context) => {
|
|
13431
14162
|
if (value.run && value.kinds && !value.kinds.includes(value.run.kind)) {
|
|
13432
14163
|
context.addIssue({
|
|
13433
|
-
code:
|
|
14164
|
+
code: z35.ZodIssueCode.custom,
|
|
13434
14165
|
path: ["run"],
|
|
13435
14166
|
message: "run.kind must be included in kinds"
|
|
13436
14167
|
});
|
|
13437
14168
|
}
|
|
13438
14169
|
});
|
|
13439
|
-
var UnsubscribeSchema3 =
|
|
13440
|
-
var SubscriptionMessageSchema2 =
|
|
14170
|
+
var UnsubscribeSchema3 = z35.object({ type: z35.literal("unsubscribe") });
|
|
14171
|
+
var SubscriptionMessageSchema2 = z35.union([SubscribeSchema3, UnsubscribeSchema3]);
|
|
13441
14172
|
function parseLogSubscriptionMessage(payload) {
|
|
13442
14173
|
if (!payload || typeof payload !== "object") {
|
|
13443
14174
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -13539,6 +14270,7 @@ class SixbServer {
|
|
|
13539
14270
|
authContextResolver;
|
|
13540
14271
|
authRedirectContextResolver;
|
|
13541
14272
|
authExperience;
|
|
14273
|
+
sharedAccessOptions;
|
|
13542
14274
|
app = null;
|
|
13543
14275
|
bunServer = null;
|
|
13544
14276
|
maintenance = null;
|
|
@@ -13551,6 +14283,7 @@ class SixbServer {
|
|
|
13551
14283
|
this.authContextResolver = createApiBrowserAuthContextResolver(this.apiBrowserPolicy);
|
|
13552
14284
|
this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(this.apiBrowserPolicy);
|
|
13553
14285
|
this.authExperience = options.authExperience;
|
|
14286
|
+
this.sharedAccessOptions = options.sharedAccess ?? {};
|
|
13554
14287
|
}
|
|
13555
14288
|
getHost() {
|
|
13556
14289
|
return this.hostRuntime;
|
|
@@ -13579,6 +14312,9 @@ class SixbServer {
|
|
|
13579
14312
|
getAuthExperience() {
|
|
13580
14313
|
return this.authExperience;
|
|
13581
14314
|
}
|
|
14315
|
+
getSharedAccessOptions() {
|
|
14316
|
+
return this.sharedAccessOptions;
|
|
14317
|
+
}
|
|
13582
14318
|
async start() {
|
|
13583
14319
|
if (this.app !== null || this.bunServer !== null || this.maintenance !== null) {
|
|
13584
14320
|
throw new Error("[SixbServer] Server is already running.");
|
|
@@ -13625,6 +14361,8 @@ function createSixbApi(server) {
|
|
|
13625
14361
|
host,
|
|
13626
14362
|
resolveAuthContext: (request) => server.resolveAuthContext(request)
|
|
13627
14363
|
});
|
|
14364
|
+
const sharedAccess = new SharedAccessBoundary(host, server.getSharedAccessOptions());
|
|
14365
|
+
const preparedSharedAccess = new WeakMap;
|
|
13628
14366
|
guard.assertCanServeHttp({ production: true });
|
|
13629
14367
|
const apiBrowserPolicy = server.getApiBrowserPolicy();
|
|
13630
14368
|
const app = new Elysia;
|
|
@@ -13641,18 +14379,55 @@ function createSixbApi(server) {
|
|
|
13641
14379
|
allowedHeaders: [
|
|
13642
14380
|
"authorization",
|
|
13643
14381
|
"content-type",
|
|
13644
|
-
|
|
13645
|
-
SESSION_ACTIVITY_HEADER_NAME
|
|
14382
|
+
CSRF_HEADER_NAME3,
|
|
14383
|
+
SESSION_ACTIVITY_HEADER_NAME,
|
|
14384
|
+
SHARED_ACCESS_GRANT_HEADER_NAME
|
|
13646
14385
|
],
|
|
13647
14386
|
exposeHeaders: [CSRF_TOKEN_RESPONSE_HEADER_NAME],
|
|
13648
14387
|
maxAge: 600
|
|
13649
14388
|
}));
|
|
14389
|
+
app.onRequest(async ({ request, set }) => {
|
|
14390
|
+
const shared = await sharedAccess.resolveRequest(request);
|
|
14391
|
+
preparedSharedAccess.set(request, shared);
|
|
14392
|
+
if (shared.kind === "allow") {
|
|
14393
|
+
setResponseHeader2(set, "cache-control", "no-store");
|
|
14394
|
+
}
|
|
14395
|
+
return shared.kind === "deny" ? shared.response : undefined;
|
|
14396
|
+
});
|
|
13650
14397
|
app.derive(async ({ request }) => {
|
|
14398
|
+
const shared = preparedSharedAccess.get(request) ?? await sharedAccess.resolveRequest(request);
|
|
14399
|
+
preparedSharedAccess.delete(request);
|
|
14400
|
+
if (shared.kind === "deny") {
|
|
14401
|
+
return {
|
|
14402
|
+
auth: { kind: "deny", response: shared.response },
|
|
14403
|
+
sharedAccessCookies: null,
|
|
14404
|
+
sixb: null
|
|
14405
|
+
};
|
|
14406
|
+
}
|
|
14407
|
+
if (shared.kind === "allow") {
|
|
14408
|
+
return {
|
|
14409
|
+
auth: { kind: "allow", session: null },
|
|
14410
|
+
sharedAccessCookies: shared.cookies,
|
|
14411
|
+
sixb: bindRequestExecution(host, {
|
|
14412
|
+
request,
|
|
14413
|
+
authorization: {
|
|
14414
|
+
type: "delegated",
|
|
14415
|
+
access: shared.context.access,
|
|
14416
|
+
delegation: {
|
|
14417
|
+
kind: "share",
|
|
14418
|
+
grantId: shared.context.grantId,
|
|
14419
|
+
sessionId: shared.context.sessionId
|
|
14420
|
+
}
|
|
14421
|
+
}
|
|
14422
|
+
})
|
|
14423
|
+
};
|
|
14424
|
+
}
|
|
13651
14425
|
const internalAuthState = consumeInternalRequestAuthState(request);
|
|
13652
14426
|
if (internalAuthState) {
|
|
13653
14427
|
const { authorization, ...agentState } = internalAuthState;
|
|
13654
14428
|
return {
|
|
13655
14429
|
auth: { kind: "allow", session: null },
|
|
14430
|
+
sharedAccessCookies: null,
|
|
13656
14431
|
...agentState,
|
|
13657
14432
|
sixb: bindRequestExecution(host, {
|
|
13658
14433
|
request,
|
|
@@ -13664,6 +14439,7 @@ function createSixbApi(server) {
|
|
|
13664
14439
|
if (auth.kind === "deny" || !auth.session?.authenticated) {
|
|
13665
14440
|
return {
|
|
13666
14441
|
auth,
|
|
14442
|
+
sharedAccessCookies: null,
|
|
13667
14443
|
sixb: auth.kind === "allow" && !guard.isAuthEnabled() ? bindRequestExecution(host, {
|
|
13668
14444
|
request,
|
|
13669
14445
|
authorization: { type: "disabled" }
|
|
@@ -13674,12 +14450,30 @@ function createSixbApi(server) {
|
|
|
13674
14450
|
const credential = auth.session.credentialSource === "session" ? { type: "session", id: auth.session.session.id } : { type: "accessToken", id: auth.session.accessToken.id };
|
|
13675
14451
|
return {
|
|
13676
14452
|
auth,
|
|
14453
|
+
sharedAccessCookies: null,
|
|
13677
14454
|
sixb: bindRequestExecution(host, {
|
|
13678
14455
|
request,
|
|
13679
14456
|
authorization: { type: "principal", context: authz, credential }
|
|
13680
14457
|
})
|
|
13681
14458
|
};
|
|
13682
|
-
}).onBeforeHandle(({ auth }) => auth.kind === "deny" ? auth.response : undefined).mapResponse(({ auth, request, set }) => {
|
|
14459
|
+
}).onBeforeHandle(({ auth }) => auth.kind === "deny" ? auth.response : undefined).mapResponse(({ auth, request, responseValue, set, sharedAccessCookies }) => {
|
|
14460
|
+
if (sharedAccessCookies) {
|
|
14461
|
+
if (sharedAccessCookies.setCookies.length > 0) {
|
|
14462
|
+
appendSetCookieHeaders(set, sharedAccessCookies.setCookies);
|
|
14463
|
+
}
|
|
14464
|
+
setResponseHeader2(set, CSRF_TOKEN_RESPONSE_HEADER_NAME, sharedAccessCookies.csrfToken);
|
|
14465
|
+
setResponseHeader2(set, "cache-control", "no-store");
|
|
14466
|
+
if (responseValue instanceof Response) {
|
|
14467
|
+
const headers = new Headers(responseValue.headers);
|
|
14468
|
+
headers.set("cache-control", "no-store");
|
|
14469
|
+
return new Response(responseValue.body, {
|
|
14470
|
+
status: responseValue.status,
|
|
14471
|
+
statusText: responseValue.statusText,
|
|
14472
|
+
headers
|
|
14473
|
+
});
|
|
14474
|
+
}
|
|
14475
|
+
return;
|
|
14476
|
+
}
|
|
13683
14477
|
if (!auth || auth.kind !== "allow" || auth.session?.credentialSource !== "session" || auth.session.sessionRenewed !== true) {
|
|
13684
14478
|
return;
|
|
13685
14479
|
}
|
|
@@ -13706,7 +14500,8 @@ function createSixbApi(server) {
|
|
|
13706
14500
|
components: {
|
|
13707
14501
|
securitySchemes: {
|
|
13708
14502
|
[SIXB_CSRF_SECURITY_SCHEME_ID]: SIXB_CSRF_SECURITY_SCHEME,
|
|
13709
|
-
[SIXB_BEARER_SECURITY_SCHEME_ID]: SIXB_BEARER_SECURITY_SCHEME
|
|
14503
|
+
[SIXB_BEARER_SECURITY_SCHEME_ID]: SIXB_BEARER_SECURITY_SCHEME,
|
|
14504
|
+
[SIXB_SHARED_GRANT_SECURITY_SCHEME_ID]: SIXB_SHARED_GRANT_SECURITY_SCHEME
|
|
13710
14505
|
},
|
|
13711
14506
|
schemas: ObjectQueryOpenApiSchemas
|
|
13712
14507
|
},
|
|
@@ -13732,6 +14527,7 @@ function createSixbApi(server) {
|
|
|
13732
14527
|
resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
|
|
13733
14528
|
});
|
|
13734
14529
|
registerHttpRoutes(app, host, {
|
|
14530
|
+
sharedAccess,
|
|
13735
14531
|
connectorConnections: {
|
|
13736
14532
|
resolveReturnTo: (request, returnTo) => {
|
|
13737
14533
|
const authContext = server.resolveAuthContext(request);
|
|
@@ -13816,8 +14612,8 @@ function attachBunServer(app, bunServer) {
|
|
|
13816
14612
|
app.server = bunServer;
|
|
13817
14613
|
}
|
|
13818
14614
|
export {
|
|
13819
|
-
|
|
13820
|
-
|
|
14615
|
+
SixbServer,
|
|
14616
|
+
createSixbServer
|
|
13821
14617
|
};
|
|
13822
14618
|
|
|
13823
|
-
//# debugId=
|
|
14619
|
+
//# debugId=9579A35BED5BF80264756E2164756E21
|