@sixb/server 0.1.24 → 0.1.26
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/public-routes.d.ts.map +1 -1
- package/dist/auth/run-token.d.ts +28 -0
- package/dist/auth/run-token.d.ts.map +1 -0
- package/dist/auth/scope.d.ts +11 -13
- package/dist/auth/scope.d.ts.map +1 -1
- package/dist/index.js +3500 -2989
- package/dist/index.js.map +30 -28
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/agent-approval-gate.d.ts +7 -4
- package/dist/routes/agent-approval-gate.d.ts.map +1 -1
- package/dist/routes/agent-approvals.d.ts +4 -1
- package/dist/routes/agent-approvals.d.ts.map +1 -1
- package/dist/routes/agent-computers.d.ts +134 -0
- package/dist/routes/agent-computers.d.ts.map +1 -0
- package/dist/routes/agent-runners.d.ts +74 -0
- package/dist/routes/agent-runners.d.ts.map +1 -0
- package/dist/routes/agents.d.ts +28 -0
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/artifacts.d.ts +5 -28
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/auth.d.ts +1 -1
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/datasets.d.ts.map +1 -1
- package/dist/routes/observed-agent-threads.d.ts +3 -0
- package/dist/routes/observed-agent-threads.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts.map +1 -1
- package/dist/routes/projections.d.ts +2 -0
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/shared-access.d.ts +2 -2
- package/dist/routes/syncs.d.ts +34 -34
- package/dist/routes/syncs.d.ts.map +1 -1
- package/dist/routes/users.d.ts +1 -0
- package/dist/routes/users.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +4 -4
- package/dist/schemas/agents.d.ts +79 -1
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/auth.d.ts +2 -2
- package/dist/schemas/projections.d.ts +14 -0
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/shared-access.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +24 -24
- package/dist/schemas/users.d.ts +8 -0
- package/dist/schemas/users.d.ts.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/auth/public-routes.ts +0 -6
- package/src/auth/run-token.ts +327 -0
- package/src/auth/scope.ts +16 -37
- package/src/registerRoutes.ts +4 -2
- package/src/routes/agent-approval-gate.ts +40 -14
- package/src/routes/agent-approvals.ts +1 -1
- package/src/routes/agent-computers.ts +126 -0
- package/src/routes/agent-runners.ts +181 -0
- package/src/routes/agents.ts +7 -2
- package/src/routes/artifacts.ts +55 -11
- package/src/routes/auth.ts +391 -37
- package/src/routes/datasets.ts +5 -0
- package/src/routes/pipelines.ts +5 -0
- package/src/routes/syncs.ts +4 -0
- package/src/routes/users.ts +15 -2
- package/src/schemas/agents.ts +16 -1
- package/src/schemas/artifacts.ts +1 -1
- package/src/schemas/projections.ts +2 -0
- package/src/schemas/users.ts +6 -0
- package/src/server.ts +35 -13
- package/dist/routes/agent-api-gateway.d.ts +0 -4
- package/dist/routes/agent-api-gateway.d.ts.map +0 -1
- package/src/routes/agent-api-gateway.ts +0 -404
package/src/routes/auth.ts
CHANGED
|
@@ -306,18 +306,20 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
306
306
|
async ({ request }) => {
|
|
307
307
|
const rawUserCode = new URL(request.url).searchParams.get("user_code")
|
|
308
308
|
if (!rawUserCode) {
|
|
309
|
-
return
|
|
309
|
+
return devicePageResponse(
|
|
310
310
|
[
|
|
311
|
+
deviceTileEmblem("monitor"),
|
|
311
312
|
"<h1>Authorize a device</h1>",
|
|
313
|
+
"<p>Enter the code shown on the device you're signing in.</p>",
|
|
312
314
|
'<form method="get" action="/auth/device">',
|
|
313
|
-
'<input name="user_code" autocomplete="one-time-code" placeholder="BCDF-HJKM" aria-label="Device code" required autofocus>',
|
|
315
|
+
'<input class="code-input" name="user_code" type="text" autocomplete="one-time-code" autocapitalize="characters" spellcheck="false" placeholder="BCDF-HJKM" aria-label="Device code" required autofocus>',
|
|
314
316
|
'<button type="submit">Continue</button>',
|
|
315
317
|
"</form>",
|
|
316
318
|
].join("")
|
|
317
319
|
)
|
|
318
320
|
}
|
|
319
321
|
const userCode = normalizeDeviceUserCode(rawUserCode)
|
|
320
|
-
if (!userCode) return
|
|
322
|
+
if (!userCode) return invalidDeviceAuthorizationResponse()
|
|
321
323
|
const authorization = await requireAuthStorage(host).deviceAuthorizations.getByUserCode({
|
|
322
324
|
projectId: host.id,
|
|
323
325
|
userCode,
|
|
@@ -328,7 +330,7 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
328
330
|
authorization.status !== "pending" ||
|
|
329
331
|
authorization.expiresAt <= now
|
|
330
332
|
) {
|
|
331
|
-
return
|
|
333
|
+
return expiredDeviceAuthorizationResponse()
|
|
332
334
|
}
|
|
333
335
|
const session = await host.auth.getSession(request)
|
|
334
336
|
if (!session.authenticated) return authPageResponse("<h1>Authentication required</h1>", 401)
|
|
@@ -338,24 +340,29 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
338
340
|
cookieOptions,
|
|
339
341
|
expiresAt: session.session.expiresAt,
|
|
340
342
|
})
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
const
|
|
343
|
+
const groupLabels = new Map(
|
|
344
|
+
host.definitions.security.listGroups().map((group) => [group.id, group.label ?? group.id])
|
|
345
|
+
)
|
|
346
|
+
const groups = session.groupIds.map((id) => groupLabels.get(id) ?? id).join(", ") || "None"
|
|
347
|
+
const response = devicePageResponse(
|
|
345
348
|
[
|
|
349
|
+
deviceLinkEmblem("waiting", accountInitials(session.user)),
|
|
346
350
|
"<h1>Authorize this device?</h1>",
|
|
347
351
|
`<p><strong>${escapeHtml(authorization.clientName)}</strong> is requesting to sign in as you.</p>`,
|
|
348
|
-
|
|
352
|
+
deviceUserCodeHtml(authorization.userCode),
|
|
349
353
|
// Whoever starts a request names it, so the code is what ties it to the user's device.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
'<p class="hint">Authorize it only if you started this sign-in, and the device asking shows this same code.</p>',
|
|
355
|
+
'<dl class="details">',
|
|
356
|
+
`<div><dt>Account</dt><dd title="${escapeHtml(session.user.email)}">${escapeHtml(session.user.email)}</dd></div>`,
|
|
357
|
+
`<div><dt>Groups</dt><dd title="${escapeHtml(groups)}">${escapeHtml(groups)}</dd></div>`,
|
|
358
|
+
"</dl>",
|
|
359
|
+
'<form class="actions" method="post" action="/auth/device">',
|
|
354
360
|
`<input type="hidden" name="userCode" value="${escapeHtml(userCode)}">`,
|
|
355
361
|
`<input type="hidden" name="csrfToken" value="${escapeHtml(csrf.token)}">`,
|
|
362
|
+
'<button class="secondary" name="decision" value="deny" type="submit">Deny</button>',
|
|
356
363
|
'<button name="decision" value="approve" type="submit">Authorize</button>',
|
|
357
|
-
'<button name="decision" value="deny" type="submit">Deny</button>',
|
|
358
364
|
"</form>",
|
|
365
|
+
'<p class="footnote">It stays signed in until you sign it out or it goes unused for a while.</p>',
|
|
359
366
|
].join("")
|
|
360
367
|
)
|
|
361
368
|
if (csrf.setCookie) response.headers.append("set-cookie", csrf.setCookie)
|
|
@@ -372,14 +379,21 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
372
379
|
if (!session.authenticated) return authPageResponse("<h1>Authentication required</h1>", 401)
|
|
373
380
|
const csrfCookieName = host.auth.getCookieOptions().csrfCookieName
|
|
374
381
|
if (!verifyCsrfToken(request, { cookieName: csrfCookieName, token: parsed.csrfToken })) {
|
|
375
|
-
return
|
|
382
|
+
return devicePageResponse(
|
|
383
|
+
[
|
|
384
|
+
deviceTileEmblem("alert"),
|
|
385
|
+
"<h1>Invalid authorization request</h1>",
|
|
386
|
+
"<p>Reload the approval page and try again.</p>",
|
|
387
|
+
].join(""),
|
|
388
|
+
{ status: 403 }
|
|
389
|
+
)
|
|
376
390
|
}
|
|
377
391
|
const storage = requireAuthStorage(host)
|
|
378
392
|
const authorization = await storage.deviceAuthorizations.getByUserCode({
|
|
379
393
|
projectId: host.id,
|
|
380
394
|
userCode: parsed.userCode,
|
|
381
395
|
})
|
|
382
|
-
if (!authorization) return
|
|
396
|
+
if (!authorization) return invalidDeviceAuthorizationResponse()
|
|
383
397
|
const decidedAt = new Date()
|
|
384
398
|
try {
|
|
385
399
|
if (parsed.decision === "approve") {
|
|
@@ -400,14 +414,26 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
400
414
|
} catch (error) {
|
|
401
415
|
// The authorization expired or was decided after this page rendered.
|
|
402
416
|
if (error instanceof AuthStorageError && error.code === "invalid_device_authorization") {
|
|
403
|
-
return
|
|
417
|
+
return expiredDeviceAuthorizationResponse()
|
|
404
418
|
}
|
|
405
419
|
throw error
|
|
406
420
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
421
|
+
const client = `<strong>${escapeHtml(authorization.clientName)}</strong>`
|
|
422
|
+
return devicePageResponse(
|
|
423
|
+
(parsed.decision === "approve"
|
|
424
|
+
? [
|
|
425
|
+
deviceLinkEmblem("approved", accountInitials(session.user)),
|
|
426
|
+
"<h1>Device authorized</h1>",
|
|
427
|
+
`<p>${client} is signed in as you.</p>`,
|
|
428
|
+
'<p class="footnote">You can close this window.<br>Sign it out anytime from Settings › Personal.</p>',
|
|
429
|
+
]
|
|
430
|
+
: [
|
|
431
|
+
deviceLinkEmblem("denied", accountInitials(session.user)),
|
|
432
|
+
"<h1>Authorization denied</h1>",
|
|
433
|
+
`<p>${client} was not signed in.</p>`,
|
|
434
|
+
'<p class="footnote">You can close this window.</p>',
|
|
435
|
+
]
|
|
436
|
+
).join("")
|
|
411
437
|
)
|
|
412
438
|
},
|
|
413
439
|
{
|
|
@@ -501,14 +527,15 @@ export function registerAuthRoutes(app: Elysia, host: SixbHostView, options: Aut
|
|
|
501
527
|
// A URL that still names a code belongs to an authorization this browser no longer holds.
|
|
502
528
|
// Stop here rather than start another: a page left open must not keep minting requests.
|
|
503
529
|
if (authorization || url.searchParams.has("user_code")) {
|
|
504
|
-
const response =
|
|
530
|
+
const response = devicePageResponse(
|
|
505
531
|
[
|
|
506
|
-
authorization?.status === "denied"
|
|
507
|
-
? "<h1>Sign-in was denied</h1>"
|
|
508
|
-
: "<h1>This sign-in request has expired</h1>",
|
|
509
|
-
|
|
532
|
+
...(authorization?.status === "denied"
|
|
533
|
+
? [deviceLinkEmblem("denied", null), "<h1>Sign-in was denied</h1>"]
|
|
534
|
+
: [deviceTileEmblem("clock"), "<h1>This sign-in request has expired</h1>"]),
|
|
535
|
+
"<p>Start again to get a new code.</p>",
|
|
536
|
+
`<a class="button" href="${escapeHtml(deviceSignInPath(url, null))}">Try again</a>`,
|
|
510
537
|
].join(""),
|
|
511
|
-
400
|
|
538
|
+
{ status: 400, title: "Sign in" }
|
|
512
539
|
)
|
|
513
540
|
response.headers.append("set-cookie", clearCookie)
|
|
514
541
|
return response
|
|
@@ -1865,19 +1892,34 @@ function deviceVerificationUrl(
|
|
|
1865
1892
|
// Reloads itself instead of polling from a script, so the page stays script-free like the other
|
|
1866
1893
|
// auth pages; the reload that follows the approval is the request that signs the browser in.
|
|
1867
1894
|
function deviceSignInPendingResponse(userCode: string, verificationUrl: string): Response {
|
|
1895
|
+
return devicePageResponse(
|
|
1896
|
+
[
|
|
1897
|
+
deviceLinkEmblem("waiting", null),
|
|
1898
|
+
"<h1>Continue in your browser</h1>",
|
|
1899
|
+
"<p>Approve this sign-in from a browser where you are signed in. This page continues on its own.</p>",
|
|
1900
|
+
deviceUserCodeHtml(userCode),
|
|
1901
|
+
`<a class="button secondary" href="${escapeHtml(verificationUrl)}" target="_blank" rel="noopener">Open the approval page</a>`,
|
|
1902
|
+
'<p class="status">Waiting for approval</p>',
|
|
1903
|
+
].join(""),
|
|
1904
|
+
{
|
|
1905
|
+
title: "Sign in",
|
|
1906
|
+
head: `<meta http-equiv="refresh" content="${DEVICE_AUTHORIZATION_POLL_INTERVAL_SECONDS}">`,
|
|
1907
|
+
}
|
|
1908
|
+
)
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
function devicePageResponse(
|
|
1912
|
+
body: string,
|
|
1913
|
+
options: { readonly status?: number; readonly title?: string; readonly head?: string } = {}
|
|
1914
|
+
): Response {
|
|
1868
1915
|
return new Response(
|
|
1869
1916
|
authPageDocument(
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
`<p>Code: <strong>${escapeHtml(userCode)}</strong></p>`,
|
|
1874
|
-
`<p><a href="${escapeHtml(verificationUrl)}" target="_blank" rel="noopener">Open the approval page</a></p>`,
|
|
1875
|
-
].join(""),
|
|
1876
|
-
"Sign in",
|
|
1877
|
-
`<meta http-equiv="refresh" content="${DEVICE_AUTHORIZATION_POLL_INTERVAL_SECONDS}">`
|
|
1917
|
+
`<div class="device">${body}</div>`,
|
|
1918
|
+
options.title ?? "Authorize device",
|
|
1919
|
+
`${DEVICE_PAGE_STYLE}${options.head ?? ""}`
|
|
1878
1920
|
),
|
|
1879
1921
|
{
|
|
1880
|
-
status: 200,
|
|
1922
|
+
status: options.status ?? 200,
|
|
1881
1923
|
headers: {
|
|
1882
1924
|
"content-type": "text/html; charset=utf-8",
|
|
1883
1925
|
"cache-control": "no-store",
|
|
@@ -1886,6 +1928,84 @@ function deviceSignInPendingResponse(userCode: string, verificationUrl: string):
|
|
|
1886
1928
|
)
|
|
1887
1929
|
}
|
|
1888
1930
|
|
|
1931
|
+
function expiredDeviceAuthorizationResponse(): Response {
|
|
1932
|
+
return devicePageResponse(
|
|
1933
|
+
[
|
|
1934
|
+
deviceTileEmblem("clock"),
|
|
1935
|
+
"<h1>This authorization has expired</h1>",
|
|
1936
|
+
"<p>Start the sign-in again on your device to get a new code.</p>",
|
|
1937
|
+
].join(""),
|
|
1938
|
+
{ status: 400 }
|
|
1939
|
+
)
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
function invalidDeviceAuthorizationResponse(): Response {
|
|
1943
|
+
return devicePageResponse(
|
|
1944
|
+
[
|
|
1945
|
+
deviceTileEmblem("alert"),
|
|
1946
|
+
"<h1>Invalid authorization</h1>",
|
|
1947
|
+
"<p>Check the code shown on your device and enter it again.</p>",
|
|
1948
|
+
'<a class="button" href="/auth/device">Enter the code</a>',
|
|
1949
|
+
].join(""),
|
|
1950
|
+
{ status: 400 }
|
|
1951
|
+
)
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
// Lucide's outlines, drawn inline so the pages keep loading nothing.
|
|
1955
|
+
const DEVICE_ICONS = {
|
|
1956
|
+
monitor:
|
|
1957
|
+
'<rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>',
|
|
1958
|
+
user: '<circle cx="12" cy="8" r="4"/><path d="M20 21a8 8 0 0 0-16 0"/>',
|
|
1959
|
+
check: '<path d="M20 6 9 17l-5-5"/>',
|
|
1960
|
+
cross: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
1961
|
+
clock: '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',
|
|
1962
|
+
alert: '<circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/>',
|
|
1963
|
+
} as const
|
|
1964
|
+
|
|
1965
|
+
function deviceIcon(name: keyof typeof DEVICE_ICONS): string {
|
|
1966
|
+
return `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${DEVICE_ICONS[name]}</svg>`
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/** The device, the state of its link, and the account: initials, or a person when signed out. */
|
|
1970
|
+
function deviceLinkEmblem(
|
|
1971
|
+
state: "waiting" | "approved" | "denied",
|
|
1972
|
+
initials: string | null
|
|
1973
|
+
): string {
|
|
1974
|
+
const badge =
|
|
1975
|
+
state === "waiting"
|
|
1976
|
+
? ""
|
|
1977
|
+
: `<span class="badge">${deviceIcon(state === "approved" ? "check" : "cross")}</span>`
|
|
1978
|
+
return [
|
|
1979
|
+
`<div class="emblem emblem-${state}" aria-hidden="true">`,
|
|
1980
|
+
`<span class="tile">${deviceIcon("monitor")}</span>`,
|
|
1981
|
+
`<span class="link">${badge}</span>`,
|
|
1982
|
+
`<span class="tile tile-account">${initials ? escapeHtml(initials) : deviceIcon("user")}</span>`,
|
|
1983
|
+
"</div>",
|
|
1984
|
+
].join("")
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
function deviceTileEmblem(icon: keyof typeof DEVICE_ICONS): string {
|
|
1988
|
+
return `<div class="emblem" aria-hidden="true"><span class="tile">${deviceIcon(icon)}</span></div>`
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
/** One cell per character, so the code reads the same at a glance on both screens. */
|
|
1992
|
+
function deviceUserCodeHtml(userCode: string): string {
|
|
1993
|
+
const cells = [...userCode].map((character) =>
|
|
1994
|
+
character === "-" ? '<span class="code-dash"></span>' : `<span>${escapeHtml(character)}</span>`
|
|
1995
|
+
)
|
|
1996
|
+
return [
|
|
1997
|
+
`<p class="sr-only">Code: ${escapeHtml(userCode)}</p>`,
|
|
1998
|
+
`<div class="code" aria-hidden="true">${cells.join("")}</div>`,
|
|
1999
|
+
].join("")
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
function accountInitials(user: UserRecord): string {
|
|
2003
|
+
const words = (user.displayName?.trim() || user.email).split(/\s+/)
|
|
2004
|
+
const first = words[0] ?? ""
|
|
2005
|
+
const last = words.length > 1 ? (words.at(-1) ?? "") : ""
|
|
2006
|
+
return `${[...first][0] ?? ""}${[...last][0] ?? ""}`.toUpperCase()
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1889
2009
|
// The pending cookie carries the preimage of the `requester` hash embedded in
|
|
1890
2010
|
// the emailed callback URL. Only the browser that requested the link holds it,
|
|
1891
2011
|
// so GET /auth/callback can distinguish that browser (sign in immediately) from
|
|
@@ -2269,7 +2389,9 @@ const AUTH_PAGE_STYLE = `<style>
|
|
|
2269
2389
|
--primary: #0a0a0a;
|
|
2270
2390
|
--primary-foreground: #ffffff;
|
|
2271
2391
|
--border: #e2e2e2;
|
|
2392
|
+
--muted: #f4f4f4;
|
|
2272
2393
|
--muted-foreground: #5f5f5f;
|
|
2394
|
+
--success: #16a34a;
|
|
2273
2395
|
--ring: #0a0a0a;
|
|
2274
2396
|
--radius: 0.5rem;
|
|
2275
2397
|
}
|
|
@@ -2281,7 +2403,9 @@ const AUTH_PAGE_STYLE = `<style>
|
|
|
2281
2403
|
--primary: #f4f4f4;
|
|
2282
2404
|
--primary-foreground: #0a0a0a;
|
|
2283
2405
|
--border: #262626;
|
|
2406
|
+
--muted: #1c1c1c;
|
|
2284
2407
|
--muted-foreground: #8a8a8a;
|
|
2408
|
+
--success: #22c55e;
|
|
2285
2409
|
--ring: #f4f4f4;
|
|
2286
2410
|
}
|
|
2287
2411
|
}
|
|
@@ -2381,6 +2505,236 @@ button:disabled { cursor: default; }
|
|
|
2381
2505
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
2382
2506
|
</style>`
|
|
2383
2507
|
|
|
2508
|
+
// The device sign-in pages, centered on one picture: the device, the account, and the state of the
|
|
2509
|
+
// link between them. Their animations stay on the 2-second cycle of the waiting page's reload, so
|
|
2510
|
+
// each reload picks them up where the last one left off.
|
|
2511
|
+
const DEVICE_PAGE_STYLE = `<style>
|
|
2512
|
+
.device {
|
|
2513
|
+
--line: color-mix(in srgb, var(--muted-foreground) 55%, transparent);
|
|
2514
|
+
text-align: center;
|
|
2515
|
+
}
|
|
2516
|
+
.device h1 { margin-top: 1.5rem; }
|
|
2517
|
+
.device h1,
|
|
2518
|
+
.device p { text-wrap: balance; }
|
|
2519
|
+
.device p strong { overflow-wrap: anywhere; }
|
|
2520
|
+
.sr-only {
|
|
2521
|
+
position: absolute;
|
|
2522
|
+
width: 1px;
|
|
2523
|
+
height: 1px;
|
|
2524
|
+
margin: -1px;
|
|
2525
|
+
overflow: hidden;
|
|
2526
|
+
clip: rect(0, 0, 0, 0);
|
|
2527
|
+
white-space: nowrap;
|
|
2528
|
+
}
|
|
2529
|
+
.emblem {
|
|
2530
|
+
display: flex;
|
|
2531
|
+
align-items: center;
|
|
2532
|
+
justify-content: center;
|
|
2533
|
+
}
|
|
2534
|
+
.tile {
|
|
2535
|
+
display: grid;
|
|
2536
|
+
flex: none;
|
|
2537
|
+
place-items: center;
|
|
2538
|
+
width: 3rem;
|
|
2539
|
+
height: 3rem;
|
|
2540
|
+
color: var(--foreground);
|
|
2541
|
+
background: var(--card);
|
|
2542
|
+
border: 1px solid var(--border);
|
|
2543
|
+
border-radius: 0.875rem;
|
|
2544
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 16px -8px rgb(0 0 0 / 0.14);
|
|
2545
|
+
}
|
|
2546
|
+
.tile svg { width: 1.375rem; height: 1.375rem; }
|
|
2547
|
+
.tile-account {
|
|
2548
|
+
color: var(--primary-foreground);
|
|
2549
|
+
background: var(--primary);
|
|
2550
|
+
border-color: var(--primary);
|
|
2551
|
+
font-size: 0.9375rem;
|
|
2552
|
+
font-weight: 600;
|
|
2553
|
+
letter-spacing: 0.02em;
|
|
2554
|
+
}
|
|
2555
|
+
.link {
|
|
2556
|
+
position: relative;
|
|
2557
|
+
width: 4rem;
|
|
2558
|
+
height: 1px;
|
|
2559
|
+
margin: 0 0.5rem;
|
|
2560
|
+
background: linear-gradient(to right, var(--line) 50%, transparent 0) 50% 0 / 6px 1px repeat-x;
|
|
2561
|
+
}
|
|
2562
|
+
.emblem-waiting .link::after {
|
|
2563
|
+
content: "";
|
|
2564
|
+
position: absolute;
|
|
2565
|
+
top: 50%;
|
|
2566
|
+
left: 0;
|
|
2567
|
+
width: 5px;
|
|
2568
|
+
height: 5px;
|
|
2569
|
+
margin: -2.5px 0 0 -2.5px;
|
|
2570
|
+
background: var(--foreground);
|
|
2571
|
+
border-radius: 50%;
|
|
2572
|
+
animation: travel 2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
|
|
2573
|
+
}
|
|
2574
|
+
.emblem-approved .link { background: var(--success); }
|
|
2575
|
+
.badge {
|
|
2576
|
+
position: absolute;
|
|
2577
|
+
top: 50%;
|
|
2578
|
+
left: 50%;
|
|
2579
|
+
display: grid;
|
|
2580
|
+
place-items: center;
|
|
2581
|
+
width: 1.5rem;
|
|
2582
|
+
height: 1.5rem;
|
|
2583
|
+
margin: -0.75rem 0 0 -0.75rem;
|
|
2584
|
+
border-radius: 50%;
|
|
2585
|
+
box-shadow: 0 0 0 4px var(--background);
|
|
2586
|
+
animation: pop 0.5s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
2587
|
+
}
|
|
2588
|
+
.badge svg { width: 0.875rem; height: 0.875rem; stroke-width: 3; }
|
|
2589
|
+
.badge path {
|
|
2590
|
+
stroke-dasharray: 24;
|
|
2591
|
+
stroke-dashoffset: 24;
|
|
2592
|
+
animation: draw 0.35s 0.4s ease-out forwards;
|
|
2593
|
+
}
|
|
2594
|
+
.emblem-approved .badge { color: #ffffff; background: var(--success); }
|
|
2595
|
+
.emblem-denied .badge {
|
|
2596
|
+
color: var(--muted-foreground);
|
|
2597
|
+
background: var(--muted);
|
|
2598
|
+
box-shadow: 0 0 0 4px var(--background), inset 0 0 0 1px var(--border);
|
|
2599
|
+
}
|
|
2600
|
+
.code {
|
|
2601
|
+
display: grid;
|
|
2602
|
+
grid-template-columns: repeat(4, 1fr) 0.75rem repeat(4, 1fr);
|
|
2603
|
+
gap: 0.25rem;
|
|
2604
|
+
margin-top: 1.5rem;
|
|
2605
|
+
}
|
|
2606
|
+
.code span {
|
|
2607
|
+
display: grid;
|
|
2608
|
+
place-items: center;
|
|
2609
|
+
height: 2.75rem;
|
|
2610
|
+
font-family: "SF Mono", "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
|
|
2611
|
+
font-size: 1.125rem;
|
|
2612
|
+
font-weight: 500;
|
|
2613
|
+
background: var(--card);
|
|
2614
|
+
border: 1px solid var(--border);
|
|
2615
|
+
border-radius: calc(var(--radius) - 2px);
|
|
2616
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
|
|
2617
|
+
}
|
|
2618
|
+
.code .code-dash {
|
|
2619
|
+
align-self: center;
|
|
2620
|
+
height: 2px;
|
|
2621
|
+
background: var(--border);
|
|
2622
|
+
border: 0;
|
|
2623
|
+
border-radius: 1px;
|
|
2624
|
+
box-shadow: none;
|
|
2625
|
+
}
|
|
2626
|
+
.hint { margin-top: 0.875rem; font-size: 0.8125rem; }
|
|
2627
|
+
.details {
|
|
2628
|
+
margin: 1.5rem 0 0;
|
|
2629
|
+
padding: 0 0.875rem;
|
|
2630
|
+
text-align: left;
|
|
2631
|
+
font-size: 0.8125rem;
|
|
2632
|
+
background: var(--card);
|
|
2633
|
+
border: 1px solid var(--border);
|
|
2634
|
+
border-radius: var(--radius);
|
|
2635
|
+
}
|
|
2636
|
+
.details div {
|
|
2637
|
+
display: flex;
|
|
2638
|
+
justify-content: space-between;
|
|
2639
|
+
gap: 1rem;
|
|
2640
|
+
padding: 0.625rem 0;
|
|
2641
|
+
}
|
|
2642
|
+
.details div + div { border-top: 1px solid var(--border); }
|
|
2643
|
+
.details dt { flex: none; color: var(--muted-foreground); }
|
|
2644
|
+
.details dd {
|
|
2645
|
+
min-width: 0;
|
|
2646
|
+
margin: 0;
|
|
2647
|
+
overflow: hidden;
|
|
2648
|
+
font-weight: 500;
|
|
2649
|
+
text-overflow: ellipsis;
|
|
2650
|
+
white-space: nowrap;
|
|
2651
|
+
}
|
|
2652
|
+
.device form { margin-top: 1.5rem; }
|
|
2653
|
+
.device input.code-input {
|
|
2654
|
+
height: 3rem;
|
|
2655
|
+
font-family: "SF Mono", "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
|
|
2656
|
+
font-size: 1.25rem;
|
|
2657
|
+
font-weight: 500;
|
|
2658
|
+
text-align: center;
|
|
2659
|
+
/* Letter spacing trails the last character; the indent balances it. */
|
|
2660
|
+
text-indent: 0.2em;
|
|
2661
|
+
letter-spacing: 0.2em;
|
|
2662
|
+
text-transform: uppercase;
|
|
2663
|
+
}
|
|
2664
|
+
.device input.code-input::placeholder {
|
|
2665
|
+
color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
|
|
2666
|
+
}
|
|
2667
|
+
.actions {
|
|
2668
|
+
display: grid;
|
|
2669
|
+
grid-template-columns: 1fr 1fr;
|
|
2670
|
+
gap: 0.5rem;
|
|
2671
|
+
}
|
|
2672
|
+
.actions button { margin-top: 0; }
|
|
2673
|
+
.button {
|
|
2674
|
+
display: flex;
|
|
2675
|
+
align-items: center;
|
|
2676
|
+
justify-content: center;
|
|
2677
|
+
height: 2.5rem;
|
|
2678
|
+
margin-top: 1.5rem;
|
|
2679
|
+
font-size: 0.875rem;
|
|
2680
|
+
font-weight: 500;
|
|
2681
|
+
color: var(--primary-foreground);
|
|
2682
|
+
text-decoration: none;
|
|
2683
|
+
background: var(--primary);
|
|
2684
|
+
border-radius: calc(var(--radius) - 2px);
|
|
2685
|
+
}
|
|
2686
|
+
.button:hover { opacity: 0.9; }
|
|
2687
|
+
.button:focus-visible {
|
|
2688
|
+
outline: 2px solid var(--ring);
|
|
2689
|
+
outline-offset: 2px;
|
|
2690
|
+
}
|
|
2691
|
+
.device button,
|
|
2692
|
+
.button { transition: opacity 0.15s, background-color 0.15s, transform 0.1s; }
|
|
2693
|
+
.device button:active,
|
|
2694
|
+
.button:active { transform: scale(0.98); }
|
|
2695
|
+
.secondary {
|
|
2696
|
+
color: var(--foreground);
|
|
2697
|
+
background: var(--card);
|
|
2698
|
+
border: 1px solid var(--border);
|
|
2699
|
+
}
|
|
2700
|
+
.secondary:hover:not(:disabled) { opacity: 1; background: var(--muted); }
|
|
2701
|
+
.footnote { margin-top: 1.25rem; font-size: 0.75rem; }
|
|
2702
|
+
.status {
|
|
2703
|
+
display: flex;
|
|
2704
|
+
align-items: center;
|
|
2705
|
+
justify-content: center;
|
|
2706
|
+
gap: 0.5rem;
|
|
2707
|
+
margin-top: 1.25rem;
|
|
2708
|
+
font-size: 0.8125rem;
|
|
2709
|
+
}
|
|
2710
|
+
.status::before {
|
|
2711
|
+
content: "";
|
|
2712
|
+
width: 0.375rem;
|
|
2713
|
+
height: 0.375rem;
|
|
2714
|
+
background: currentColor;
|
|
2715
|
+
border-radius: 50%;
|
|
2716
|
+
animation: pulse 2s ease-in-out infinite;
|
|
2717
|
+
}
|
|
2718
|
+
@keyframes travel {
|
|
2719
|
+
0% { opacity: 0; transform: translateX(0); }
|
|
2720
|
+
20%, 80% { opacity: 1; }
|
|
2721
|
+
100% { opacity: 0; transform: translateX(4rem); }
|
|
2722
|
+
}
|
|
2723
|
+
@keyframes pop {
|
|
2724
|
+
from { opacity: 0; transform: scale(0.4); }
|
|
2725
|
+
to { opacity: 1; transform: scale(1); }
|
|
2726
|
+
}
|
|
2727
|
+
@keyframes draw { to { stroke-dashoffset: 0; } }
|
|
2728
|
+
@keyframes pulse { 50% { opacity: 0.3; } }
|
|
2729
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2730
|
+
.emblem-waiting .link::after { display: none; }
|
|
2731
|
+
.badge,
|
|
2732
|
+
.badge path,
|
|
2733
|
+
.status::before { animation: none; }
|
|
2734
|
+
.badge path { stroke-dashoffset: 0; }
|
|
2735
|
+
}
|
|
2736
|
+
</style>`
|
|
2737
|
+
|
|
2384
2738
|
function authPageDocument(body: string, title = "Sign in", head = ""): string {
|
|
2385
2739
|
return [
|
|
2386
2740
|
"<!doctype html>",
|
|
@@ -2389,8 +2743,8 @@ function authPageDocument(body: string, title = "Sign in", head = ""): string {
|
|
|
2389
2743
|
'<meta charset="utf-8">',
|
|
2390
2744
|
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
2391
2745
|
`<title>${escapeHtml(title)}</title>`,
|
|
2392
|
-
head,
|
|
2393
2746
|
AUTH_PAGE_STYLE,
|
|
2747
|
+
head,
|
|
2394
2748
|
"</head>",
|
|
2395
2749
|
"<body>",
|
|
2396
2750
|
'<main class="shell">',
|
package/src/routes/datasets.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
DatasetVersion,
|
|
7
7
|
} from "@sixb/core/lake-storage"
|
|
8
8
|
import type { Elysia } from "elysia"
|
|
9
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
9
10
|
import { requireRequestSixb } from "../auth/scope"
|
|
10
11
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
11
12
|
import { codedErrorResponseSchema, ErrorResponseSchema } from "../schemas/common"
|
|
@@ -213,6 +214,7 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
213
214
|
summary: "List registered datasets",
|
|
214
215
|
tags: [OPENAPI_TAGS.datasets.name],
|
|
215
216
|
operationId: "listDatasets",
|
|
217
|
+
security: accessTokenSecurityRequirement("listDatasets"),
|
|
216
218
|
},
|
|
217
219
|
}
|
|
218
220
|
)
|
|
@@ -241,6 +243,7 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
241
243
|
summary: "Get dataset metadata",
|
|
242
244
|
tags: [OPENAPI_TAGS.datasets.name],
|
|
243
245
|
operationId: "getDataset",
|
|
246
|
+
security: accessTokenSecurityRequirement("getDataset"),
|
|
244
247
|
},
|
|
245
248
|
}
|
|
246
249
|
)
|
|
@@ -275,6 +278,7 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
275
278
|
summary: "List dataset versions",
|
|
276
279
|
tags: [OPENAPI_TAGS.datasetVersions.name],
|
|
277
280
|
operationId: "listDatasetVersions",
|
|
281
|
+
security: accessTokenSecurityRequirement("listDatasetVersions"),
|
|
278
282
|
},
|
|
279
283
|
}
|
|
280
284
|
)
|
|
@@ -366,6 +370,7 @@ export function registerDatasetRoutes(app: Elysia, host: SixbHostView) {
|
|
|
366
370
|
summary: "Preview dataset rows",
|
|
367
371
|
tags: [OPENAPI_TAGS.datasetRows.name],
|
|
368
372
|
operationId: "listDatasetRows",
|
|
373
|
+
security: accessTokenSecurityRequirement("listDatasetRows"),
|
|
369
374
|
},
|
|
370
375
|
}
|
|
371
376
|
)
|
package/src/routes/pipelines.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PipelineDefinition, PipelineStepExecutor, SixbHostView } from "@sixb/core"
|
|
2
2
|
import type { PipelineRunRecord, PipelineStepRunRecord } from "@sixb/core/storage"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
4
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
5
6
|
import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
6
7
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -143,6 +144,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
143
144
|
summary: "List registered pipelines",
|
|
144
145
|
tags: [OPENAPI_TAGS.pipelines.name],
|
|
145
146
|
operationId: "listPipelines",
|
|
147
|
+
security: accessTokenSecurityRequirement("listPipelines"),
|
|
146
148
|
},
|
|
147
149
|
}
|
|
148
150
|
)
|
|
@@ -166,6 +168,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
166
168
|
summary: "Get pipeline metadata",
|
|
167
169
|
tags: [OPENAPI_TAGS.pipelines.name],
|
|
168
170
|
operationId: "getPipeline",
|
|
171
|
+
security: accessTokenSecurityRequirement("getPipeline"),
|
|
169
172
|
},
|
|
170
173
|
}
|
|
171
174
|
)
|
|
@@ -211,6 +214,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
211
214
|
summary: "List pipeline run history",
|
|
212
215
|
tags: [OPENAPI_TAGS.pipelineRuns.name],
|
|
213
216
|
operationId: "listPipelineRuns",
|
|
217
|
+
security: accessTokenSecurityRequirement("listPipelineRuns"),
|
|
214
218
|
},
|
|
215
219
|
}
|
|
216
220
|
)
|
|
@@ -257,6 +261,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
|
|
|
257
261
|
summary: "Get pipeline run detail",
|
|
258
262
|
tags: [OPENAPI_TAGS.pipelineRuns.name],
|
|
259
263
|
operationId: "getPipelineRun",
|
|
264
|
+
security: accessTokenSecurityRequirement("getPipelineRun"),
|
|
260
265
|
},
|
|
261
266
|
}
|
|
262
267
|
)
|
package/src/routes/syncs.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SixbHostView, SyncDefinition } from "@sixb/core"
|
|
2
2
|
import type { SyncRunRecord } from "@sixb/core/storage"
|
|
3
3
|
import type { Elysia } from "elysia"
|
|
4
|
+
import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
|
|
4
5
|
import { requireRequestSixb } from "../auth/scope"
|
|
5
6
|
import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
|
|
6
7
|
import { OPENAPI_TAGS } from "../openapi/tags"
|
|
@@ -105,6 +106,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
105
106
|
summary: "List registered syncs",
|
|
106
107
|
tags: [OPENAPI_TAGS.syncs.name],
|
|
107
108
|
operationId: "listSyncs",
|
|
109
|
+
security: accessTokenSecurityRequirement("listSyncs"),
|
|
108
110
|
},
|
|
109
111
|
}
|
|
110
112
|
)
|
|
@@ -128,6 +130,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
128
130
|
summary: "Get sync metadata",
|
|
129
131
|
tags: [OPENAPI_TAGS.syncs.name],
|
|
130
132
|
operationId: "getSync",
|
|
133
|
+
security: accessTokenSecurityRequirement("getSync"),
|
|
131
134
|
},
|
|
132
135
|
}
|
|
133
136
|
)
|
|
@@ -174,6 +177,7 @@ export function registerSyncRoutes(app: Elysia, host: SixbHostView) {
|
|
|
174
177
|
summary: "List sync run history",
|
|
175
178
|
tags: [OPENAPI_TAGS.syncRuns.name],
|
|
176
179
|
operationId: "listSyncRuns",
|
|
180
|
+
security: accessTokenSecurityRequirement("listSyncRuns"),
|
|
177
181
|
},
|
|
178
182
|
}
|
|
179
183
|
)
|
package/src/routes/users.ts
CHANGED
|
@@ -17,8 +17,21 @@ export function registerUserRoutes(app: Elysia, _host: SixbHostView) {
|
|
|
17
17
|
const sixb = requireRequestSixb(context)
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const { email, ...input } = ListUsersQuerySchema.parse(query)
|
|
21
|
+
if (email === undefined) {
|
|
22
|
+
const page = await sixb.users.list(input)
|
|
23
|
+
return { users: [...page.users], hasMore: page.hasMore, total: page.total }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// `users.get({ email })` over HTTP: a query parameter, so an email never goes in a path.
|
|
27
|
+
if (Object.values(input).some((value) => value !== undefined)) {
|
|
28
|
+
set.status = 400
|
|
29
|
+
return {
|
|
30
|
+
error: "[SixbServer] email finds one member and takes no other option.",
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const profile = await sixb.users.get({ email })
|
|
34
|
+
return { users: profile ? [profile] : [], hasMore: false, total: profile ? 1 : 0 }
|
|
22
35
|
} catch (error) {
|
|
23
36
|
return handleRouteError(error, set)
|
|
24
37
|
}
|