@sixb/server 0.1.19 → 0.1.20

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.
Files changed (48) hide show
  1. package/README.md +13 -22
  2. package/dist/auth/browser-origin.d.ts +4 -26
  3. package/dist/auth/browser-origin.d.ts.map +1 -1
  4. package/dist/auth/experience.d.ts +0 -3
  5. package/dist/auth/experience.d.ts.map +1 -1
  6. package/dist/auth/guard.d.ts +1 -1
  7. package/dist/auth/guard.d.ts.map +1 -1
  8. package/dist/auth/public-routes.d.ts +0 -5
  9. package/dist/auth/public-routes.d.ts.map +1 -1
  10. package/dist/auth/responses.d.ts +0 -2
  11. package/dist/auth/responses.d.ts.map +1 -1
  12. package/dist/auth/session-cookies.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +68 -297
  16. package/dist/index.js.map +14 -15
  17. package/dist/routes/action-runs.d.ts +0 -2
  18. package/dist/routes/action-runs.d.ts.map +1 -1
  19. package/dist/routes/agents.d.ts +0 -2
  20. package/dist/routes/agents.d.ts.map +1 -1
  21. package/dist/routes/auth.d.ts +8 -17
  22. package/dist/routes/auth.d.ts.map +1 -1
  23. package/dist/routes/objects.d.ts +0 -2
  24. package/dist/routes/objects.d.ts.map +1 -1
  25. package/dist/routes/workflows.d.ts +0 -4
  26. package/dist/routes/workflows.d.ts.map +1 -1
  27. package/dist/schemas/auth.d.ts +28 -63
  28. package/dist/schemas/auth.d.ts.map +1 -1
  29. package/dist/schemas/files.d.ts +0 -3
  30. package/dist/schemas/files.d.ts.map +1 -1
  31. package/dist/server.d.ts +1 -2
  32. package/dist/server.d.ts.map +1 -1
  33. package/package.json +6 -6
  34. package/src/auth/browser-origin.ts +30 -240
  35. package/src/auth/experience.ts +1 -4
  36. package/src/auth/guard.ts +4 -32
  37. package/src/auth/public-routes.ts +1 -10
  38. package/src/auth/responses.ts +0 -5
  39. package/src/auth/session-cookies.ts +1 -3
  40. package/src/auth/shared-access.ts +1 -1
  41. package/src/index.ts +1 -1
  42. package/src/routes/auth.ts +32 -111
  43. package/src/schemas/auth.ts +2 -15
  44. package/src/schemas/files.ts +0 -6
  45. package/src/server.ts +2 -15
  46. package/dist/auth/application-access.d.ts +0 -4
  47. package/dist/auth/application-access.d.ts.map +0 -1
  48. package/src/auth/application-access.ts +0 -15
package/dist/index.js CHANGED
@@ -10,46 +10,16 @@ import { websocket as elysiaWebSocket } from "elysia/ws";
10
10
  import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
11
11
 
12
12
  // src/auth/browser-origin.ts
13
- import {
14
- applications,
15
- DEFAULT_AUTH_SESSION_AUDIENCE,
16
- isValidAuthSessionAudience,
17
- resolveAuthSessionAudience
18
- } from "@sixb/core";
19
- import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
20
- var fileNavigationRoutes = SIXB_API_ROUTES.filter((route) => (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content"));
21
-
22
13
  class BrowserOriginError extends Error {
23
14
  name = "BrowserOriginError";
24
15
  }
25
16
  function resolveApiBrowserPolicy(policy) {
26
- const apiOriginAudience = resolveAuthSessionAudience(policy.apiOriginAudience ?? DEFAULT_AUTH_SESSION_AUDIENCE);
27
- const origins = new Map;
28
- const audienceOrigins = new Map;
29
- for (const entry of policy.allowedOrigins) {
30
- const origin = normalizeHttpOrigin(entry.origin, "browser origin");
31
- const audience = resolveAuthSessionAudience(entry.audience);
32
- const existingAudienceOrigin = audienceOrigins.get(audience);
33
- if (existingAudienceOrigin && existingAudienceOrigin !== origin) {
34
- throw new Error(`[SixbServer] Auth audience '${audience}' is mapped to multiple browser origins.`);
35
- }
36
- audienceOrigins.set(audience, origin);
37
- const existing = origins.get(origin);
38
- if (existing) {
39
- if (existing.audience !== audience) {
40
- throw new Error(`[SixbServer] Browser origin '${origin}' is mapped to multiple auth audiences.`);
41
- }
42
- continue;
43
- }
44
- origins.set(origin, { origin, audience });
45
- }
46
- if (origins.size === 0) {
47
- throw new Error("[SixbServer] API browser policy requires at least one allowed origin.");
48
- }
17
+ const allowedOrigins = [
18
+ ...new Set(policy.allowedOrigins.map((origin) => normalizeHttpOrigin(origin, "browser origin")))
19
+ ];
49
20
  return {
50
21
  publicOrigin: policy.publicOrigin ? normalizeHttpOrigin(policy.publicOrigin, "API public origin") : undefined,
51
- apiOriginAudience,
52
- allowedOrigins: [...origins.values()]
22
+ allowedOrigins
53
23
  };
54
24
  }
55
25
  function createApiBrowserAuthContextResolver(policy) {
@@ -60,118 +30,38 @@ function createApiBrowserAuthRedirectContextResolver(policy) {
60
30
  }
61
31
  function resolveApiBrowserAuthContext(policy, request) {
62
32
  const origin = normalizeRequestOrigin(request);
63
- const fileAudience = resolveFileNavigationAudience(policy, request);
64
33
  if (!origin) {
65
- return { audience: fileAudience ?? policy.apiOriginAudience, absoluteReturnTo: true };
34
+ return { absoluteReturnTo: true };
66
35
  }
67
- const allowed = findAllowedBrowserOrigin(policy, origin);
68
- if (allowed) {
69
- assertFileAudienceMatchesOrigin(fileAudience, allowed.audience);
70
- return {
71
- audience: allowed.audience,
72
- browserOrigin: allowed.origin,
73
- absoluteReturnTo: true
74
- };
75
- }
76
- if (isSameOriginApiRequest(policy, origin, request)) {
77
- assertFileAudienceMatchesOrigin(fileAudience, policy.apiOriginAudience);
78
- return { audience: policy.apiOriginAudience, browserOrigin: origin, absoluteReturnTo: true };
36
+ if (isAllowedOrigin(policy, request, origin)) {
37
+ return { browserOrigin: origin, absoluteReturnTo: true };
79
38
  }
80
39
  throw new BrowserOriginError(`[SixbServer] Browser origin '${origin}' is not allowed.`);
81
40
  }
82
- function resolveFileNavigationAudience(policy, request) {
83
- const url = new URL(request.url);
84
- if (!fileNavigationRoutes.some((route) => route.method === request.method && matchesPathPattern(normalizeRoutePath(url.pathname), route.path))) {
85
- return;
86
- }
87
- const values = url.searchParams.getAll("audience");
88
- if (values.length === 0)
89
- return;
90
- const audience = values[0];
91
- if (values.length !== 1 || !audience || !isValidAuthSessionAudience(audience) || audience !== policy.apiOriginAudience && !policy.allowedOrigins.some((entry) => entry.audience === audience)) {
92
- throw new BrowserOriginError("[SixbServer] File navigation audience is not allowed.");
93
- }
94
- return audience;
95
- }
96
- function assertFileAudienceMatchesOrigin(audience, originAudience) {
97
- if (audience !== undefined && audience !== originAudience) {
98
- throw new BrowserOriginError("[SixbServer] File navigation audience conflicts with Origin.");
99
- }
100
- }
101
41
  function isAllowedApiBrowserOrigin(policy, request) {
102
42
  const origin = normalizeRequestOrigin(request);
103
- if (!origin) {
104
- return false;
105
- }
106
- return findAllowedBrowserOrigin(policy, origin) !== null || isSameOriginApiRequest(policy, origin, request);
43
+ return origin !== null && isAllowedOrigin(policy, request, origin);
107
44
  }
108
45
  function resolveApiBrowserAuthRedirectContext(policy, request, input) {
109
- const audience = resolveRequiredAuthAudience(input.audience);
110
- const returnTo = resolveApiBrowserReturnTo(policy, request, input, audience);
111
46
  return {
112
- audience,
113
- returnTo,
47
+ returnTo: resolveApiBrowserReturnTo(policy, request, input),
114
48
  requestOrigin: resolveApiBrowserPublicOrigin(policy, request)
115
49
  };
116
50
  }
117
- function getApiBrowserInvitationDestinationOptions(policy) {
118
- const destinations = policy.allowedOrigins.map((entry) => ({
119
- id: entry.audience,
120
- label: applications[entry.audience].label
121
- }));
122
- const defaultDestinationId = destinations.some((destination) => destination.id === "app") ? applications.app.id : destinations.some((destination) => destination.id === "atlas") ? applications.atlas.id : undefined;
123
- return {
124
- destinations,
125
- ...defaultDestinationId ? { defaultDestinationId } : {}
126
- };
127
- }
128
51
  function resolveApiBrowserInvitationRedirectContext(policy, request, input) {
129
52
  const authContext = resolveApiBrowserAuthContext(policy, request);
130
- if (!input.destinationId) {
131
- return resolveApiBrowserAuthRedirectContext(policy, request, {
132
- audience: authContext.audience,
133
- fallbackReturnToOrigin: authContext.browserOrigin,
134
- returnTo: input.returnTo
135
- });
136
- }
137
- const destination = policy.allowedOrigins.find((entry) => entry.audience === input.destinationId);
138
- if (!destination) {
139
- throw new BrowserOriginError("[SixbServer] Invitation destination is not allowed.");
140
- }
141
- assertInvitationReturnToOrigin(input.returnTo, destination.origin);
142
53
  return resolveApiBrowserAuthRedirectContext(policy, request, {
143
- audience: destination.audience,
144
- fallbackReturnToOrigin: destination.origin,
54
+ fallbackReturnToOrigin: authContext.browserOrigin ?? policy.allowedOrigins[0],
145
55
  returnTo: input.returnTo
146
56
  });
147
57
  }
148
58
  function resolveApiBrowserPublicOrigin(policy, request) {
149
59
  return policy.publicOrigin ?? new URL(request.url).origin;
150
60
  }
151
- function findAllowedBrowserOrigin(policy, origin) {
152
- return policy.allowedOrigins.find((entry) => entry.origin === origin) ?? null;
153
- }
154
- function isSameOriginApiRequest(policy, origin, request) {
155
- const apiOrigin = resolveApiBrowserPublicOrigin(policy, request);
156
- return origin === apiOrigin;
157
- }
158
- function assertInvitationReturnToOrigin(returnTo, destinationOrigin) {
159
- if (!returnTo?.trim())
160
- return;
161
- try {
162
- if (new URL(returnTo).origin === destinationOrigin)
163
- return;
164
- } catch {}
165
- throw new BrowserOriginError("[SixbServer] Invitation return target is not allowed.");
166
- }
167
- function resolveRequiredAuthAudience(value) {
168
- const audience = value?.trim();
169
- if (!audience || !isValidAuthSessionAudience(audience)) {
170
- throw new BrowserOriginError("[SixbServer] Auth audience is invalid or missing.");
171
- }
172
- return audience;
61
+ function isAllowedOrigin(policy, request, origin) {
62
+ return policy.allowedOrigins.includes(origin) || origin === resolveApiBrowserPublicOrigin(policy, request);
173
63
  }
174
- function resolveApiBrowserReturnTo(policy, request, input, audience) {
64
+ function resolveApiBrowserReturnTo(policy, request, input) {
175
65
  const rawReturnTo = input.returnTo?.trim();
176
66
  const value = rawReturnTo || (input.fallbackReturnToOrigin ? new URL("/", normalizeHttpOrigin(input.fallbackReturnToOrigin, "fallback return origin")).href : "");
177
67
  if (!value) {
@@ -183,25 +73,11 @@ function resolveApiBrowserReturnTo(policy, request, input, audience) {
183
73
  } catch {
184
74
  throw new BrowserOriginError("[SixbServer] Auth return target must be an absolute URL.");
185
75
  }
186
- if (url.protocol !== "http:" && url.protocol !== "https:" || url.username || url.password) {
187
- throw new BrowserOriginError("[SixbServer] Auth return target is not allowed.");
188
- }
189
- const returnAudience = resolveReturnToAudience(policy, request, url.origin);
190
- if (returnAudience !== audience) {
76
+ if (url.protocol !== "http:" && url.protocol !== "https:" || url.username || url.password || !isAllowedOrigin(policy, request, url.origin)) {
191
77
  throw new BrowserOriginError("[SixbServer] Auth return target is not allowed.");
192
78
  }
193
79
  return url.toString();
194
80
  }
195
- function resolveReturnToAudience(policy, request, origin) {
196
- const allowed = findAllowedBrowserOrigin(policy, origin);
197
- if (allowed) {
198
- return allowed.audience;
199
- }
200
- if (origin === resolveApiBrowserPublicOrigin(policy, request)) {
201
- return policy.apiOriginAudience;
202
- }
203
- return null;
204
- }
205
81
  function normalizeRequestOrigin(request) {
206
82
  const origin = request.headers.get("origin");
207
83
  if (!origin) {
@@ -286,7 +162,7 @@ import {
286
162
 
287
163
  // src/auth/access-token-boundary.ts
288
164
  import { isCsrfExemptMethod as isCsrfExemptMethod2 } from "@sixb/core/internal/auth";
289
- import { matchesPathPattern as matchesPathPattern3, normalizeRoutePath as normalizeRoutePath3, SIXB_API_ROUTES as SIXB_API_ROUTES3 } from "@sixb/core/internal/http";
165
+ import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
290
166
 
291
167
  // src/openapi/security.ts
292
168
  import { CSRF_HEADER_NAME } from "@sixb/core/internal/auth";
@@ -299,7 +175,7 @@ import {
299
175
  isCsrfExemptMethod,
300
176
  verifyDoubleSubmitCsrf
301
177
  } from "@sixb/core/internal/auth";
302
- import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
178
+ import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
303
179
  import { SharedSessionProtocol } from "@sixb/core/internal/shares";
304
180
 
305
181
  // src/auth/session-activity.ts
@@ -323,7 +199,7 @@ var SHARED_SESSION_COOKIE_PREFIX = "sixb_share_session_";
323
199
  var SHARED_CSRF_COOKIE_PREFIX = "sixb_share_csrf_";
324
200
  var SHARED_COOKIE_PATH = "/api";
325
201
  var STORED_IDENTIFIER_MAX_LENGTH = 128;
326
- var SHARED_SESSION_ROUTES = SIXB_API_ROUTES2.filter((route) => route.sharedSession);
202
+ var SHARED_SESSION_ROUTES = SIXB_API_ROUTES.filter((route) => route.sharedSession);
327
203
  var SHARED_FILE_CONTENT_ROUTES = SHARED_SESSION_ROUTES.filter((route) => (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content"));
328
204
 
329
205
  class SharedAccessBoundary {
@@ -511,18 +387,18 @@ function isSharedAccessPublicRoute(request) {
511
387
  }
512
388
  function isSharedAccessPublicPath(pathname, requestMethod) {
513
389
  const method = requestMethod.toUpperCase();
514
- const normalizedPathname = normalizeRoutePath2(pathname);
390
+ const normalizedPathname = normalizeRoutePath(pathname);
515
391
  const suffix = method === "POST" && normalizedPathname.endsWith("/exchange") ? "exchange" : method === "GET" && normalizedPathname.endsWith("/session") ? "session" : method === "POST" && normalizedPathname.endsWith("/sign-out") ? "sign-out" : null;
516
392
  if (!suffix)
517
393
  return false;
518
- return matchesPathPattern2(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
394
+ return matchesPathPattern(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
519
395
  }
520
396
  function selectSharedAccessGrant(request) {
521
397
  const header = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
522
398
  const url = new URL(request.url);
523
399
  const method = request.method.toUpperCase();
524
- const pathname = normalizeRoutePath2(url.pathname);
525
- const queryValues = SHARED_FILE_CONTENT_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path)) ? url.searchParams.getAll(SHARED_ACCESS_GRANT_QUERY_PARAM) : [];
400
+ const pathname = normalizeRoutePath(url.pathname);
401
+ const queryValues = SHARED_FILE_CONTENT_ROUTES.some((route) => route.method === method && matchesPathPattern(pathname, route.path)) ? url.searchParams.getAll(SHARED_ACCESS_GRANT_QUERY_PARAM) : [];
526
402
  const [query, ...extra] = queryValues;
527
403
  if (query === undefined) {
528
404
  return header === null ? { kind: "absent" } : { kind: "selected", grantId: header };
@@ -533,8 +409,8 @@ function selectSharedAccessGrant(request) {
533
409
  }
534
410
  function isSharedSessionRoute(request) {
535
411
  const method = request.method.toUpperCase();
536
- const pathname = normalizeRoutePath2(new URL(request.url).pathname);
537
- return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
412
+ const pathname = normalizeRoutePath(new URL(request.url).pathname);
413
+ return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern(pathname, route.path));
538
414
  }
539
415
  function sharedAccessUnauthenticatedResponse() {
540
416
  return sharedBoundaryJsonResponse({ error: "Shared access session is invalid" }, 401);
@@ -643,7 +519,7 @@ var SIXB_SHARED_GRANT_SECURITY_SCHEME = {
643
519
  };
644
520
 
645
521
  // src/auth/access-token-boundary.ts
646
- var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES3.filter((route) => route.accessToken).map((route) => ({
522
+ var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES2.filter((route) => route.accessToken).map((route) => ({
647
523
  operationId: route.operationId,
648
524
  method: route.method,
649
525
  path: route.path,
@@ -665,8 +541,8 @@ function accessTokenSecurityRequirement(operationId) {
665
541
  function isAccessTokenRoute(request) {
666
542
  const url = new URL(request.url);
667
543
  const method = request.method.toUpperCase();
668
- const pathname = normalizeRoutePath3(url.pathname);
669
- return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern3(pathname, route.path));
544
+ const pathname = normalizeRoutePath2(url.pathname);
545
+ return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
670
546
  }
671
547
  function credentialTransport(caller) {
672
548
  return caller.credentialSource === "session" && !caller.session.bearer ? "cookie" : "bearer";
@@ -675,13 +551,6 @@ function shouldVerifyCsrf(route, transport) {
675
551
  return route.csrfProtected && transport === "cookie";
676
552
  }
677
553
 
678
- // src/auth/application-access.ts
679
- import { canAccessApplication } from "@sixb/core";
680
- function sessionCanAccessApplication(host, session, audience) {
681
- const authorization = host.auth.contextFromSession(session);
682
- return canAccessApplication(authorization, host.definitions.security.listResolvedRoles(), audience);
683
- }
684
-
685
554
  // src/auth/public-routes.ts
686
555
  import { AGENT_API_GATEWAY_PREFIX } from "@sixb/core/internal/agents";
687
556
  import { isCsrfExemptMethod as isCsrfExemptMethod3 } from "@sixb/core/internal/auth";
@@ -699,10 +568,7 @@ function classifyRoute(request) {
699
568
  if (pathname.startsWith("/api/")) {
700
569
  return { kind: "api", csrfProtected: !isCsrfExemptMethod3(request.method) };
701
570
  }
702
- if (pathname === "/auth/device") {
703
- return { kind: "html", csrfProtected: !isCsrfExemptMethod3(request.method), account: true };
704
- }
705
- if (pathname === "/docs" || pathname.startsWith("/docs/")) {
571
+ if (pathname === "/auth/device" || pathname === "/docs" || pathname.startsWith("/docs/")) {
706
572
  return { kind: "html", csrfProtected: !isCsrfExemptMethod3(request.method) };
707
573
  }
708
574
  return { kind: "api", csrfProtected: !isCsrfExemptMethod3(request.method) };
@@ -791,9 +657,6 @@ function htmlAuthRedirectResponse(request, options = {}) {
791
657
  const requestUrl = new URL(request.url);
792
658
  const rawReturnTo = options.absoluteReturnTo ? new URL(returnToForRequest(request), requestUrl.origin).toString() : returnToForRequest(request);
793
659
  const params = new URLSearchParams({ returnTo: rawReturnTo });
794
- if (options.absoluteReturnTo && options.audience) {
795
- params.set("audience", options.audience);
796
- }
797
660
  return new Response(null, {
798
661
  status: 302,
799
662
  headers: {
@@ -842,17 +705,13 @@ class ServerAuthGuard {
842
705
  if (authContext instanceof Response) {
843
706
  return { kind: "deny", response: authContext };
844
707
  }
845
- let session = await this.host.auth.getSession(request, {
846
- audience: authContext.audience,
847
- credentialSource: "any"
848
- });
708
+ let session = await this.host.auth.getSession(request, { credentialSource: "any" });
849
709
  if (!session.authenticated) {
850
710
  if (route.kind === "html") {
851
711
  return {
852
712
  kind: "deny",
853
713
  response: htmlAuthRedirectResponse(request, {
854
- absoluteReturnTo: authContext.absoluteReturnTo ?? false,
855
- audience: authContext.audience
714
+ absoluteReturnTo: authContext.absoluteReturnTo ?? false
856
715
  })
857
716
  };
858
717
  }
@@ -861,13 +720,6 @@ class ServerAuthGuard {
861
720
  }
862
721
  return { kind: "deny", response: jsonAuthRequiredResponse() };
863
722
  }
864
- const deniedApplication = (caller) => !route.account && credentialTransport(caller) === "cookie" && !sessionCanAccessApplication(this.host, caller, authContext.audience);
865
- if (deniedApplication(session)) {
866
- return {
867
- kind: "deny",
868
- response: jsonForbiddenResponse("Application access is not allowed")
869
- };
870
- }
871
723
  if (session.credentialSource === "accessToken" && !isAccessTokenRoute(request)) {
872
724
  return {
873
725
  kind: "deny",
@@ -879,7 +731,6 @@ class ServerAuthGuard {
879
731
  }
880
732
  if (session.credentialSource === "session" && credentialTransport(session) === "cookie" && route.kind !== "websocket" && !isSessionTerminationRequest(request) && hasForegroundSessionActivity(request)) {
881
733
  const activeSession = await this.host.auth.getSession(request, {
882
- audience: authContext.audience,
883
734
  credentialSource: "session",
884
735
  sessionActivity: "foreground"
885
736
  });
@@ -888,30 +739,22 @@ class ServerAuthGuard {
888
739
  return {
889
740
  kind: "deny",
890
741
  response: htmlAuthRedirectResponse(request, {
891
- absoluteReturnTo: authContext.absoluteReturnTo ?? false,
892
- audience: authContext.audience
742
+ absoluteReturnTo: authContext.absoluteReturnTo ?? false
893
743
  })
894
744
  };
895
745
  }
896
746
  return { kind: "deny", response: jsonAuthRequiredResponse() };
897
747
  }
898
- if (deniedApplication(activeSession)) {
899
- return {
900
- kind: "deny",
901
- response: jsonForbiddenResponse("Application access is not allowed")
902
- };
903
- }
904
748
  session = activeSession;
905
749
  }
906
750
  return { kind: "allow", session };
907
751
  }
908
- getCsrfCookieName(request) {
909
- const audience = this.resolveAuthContext(request).audience;
910
- return this.host.auth.getCookieOptions({ audience }).csrfCookieName;
752
+ getCsrfCookieName() {
753
+ return this.host.auth.getCookieOptions().csrfCookieName;
911
754
  }
912
755
  verifyCsrf(request, _session) {
913
756
  return verifyDoubleSubmitCsrf2(request, {
914
- cookieName: this.getCsrfCookieName(request)
757
+ cookieName: this.getCsrfCookieName()
915
758
  });
916
759
  }
917
760
  tryResolveAuthContext(request) {
@@ -966,9 +809,7 @@ import {
966
809
  getCookie as getCookie2
967
810
  } from "@sixb/core/internal/auth";
968
811
  function createSessionRenewalCookieHeaders(input) {
969
- const cookieOptions = input.host.auth.getCookieOptions({
970
- audience: input.session.session.audience
971
- });
812
+ const cookieOptions = input.host.auth.getCookieOptions();
972
813
  const sessionValue = getCookie2(input.request, cookieOptions.sessionCookieName);
973
814
  if (!sessionValue) {
974
815
  return null;
@@ -2028,7 +1869,6 @@ var CompleteFileUploadBodySchema = z4.object({
2028
1869
  parts: z4.array(FileUploadPartSchema).optional()
2029
1870
  });
2030
1871
  var FileContentQuerySchema = z4.object({
2031
- audience: z4.enum(["atlas", "app"]).optional().describe("Session audience for file navigation without Origin; must match Origin when present"),
2032
1872
  path: z4.string().min(1),
2033
1873
  disposition: z4.enum(["inline", "attachment"]).optional(),
2034
1874
  v: z4.string().optional().describe("Client cache key; the route still resolves the current file")
@@ -2263,7 +2103,7 @@ import {
2263
2103
  resolveAgentExecutionAuthorization,
2264
2104
  resolveInheritedAgentExecutionAuthorization
2265
2105
  } from "@sixb/core/internal/agents";
2266
- import { normalizeRoutePath as normalizeRoutePath4, pathSegmentsFor } from "@sixb/core/internal/http";
2106
+ import { normalizeRoutePath as normalizeRoutePath3, pathSegmentsFor } from "@sixb/core/internal/http";
2267
2107
 
2268
2108
  // src/routes/files.ts
2269
2109
  import {
@@ -2924,7 +2764,7 @@ function gatewayUpstreamPath(pathname) {
2924
2764
  const prefixLength = pathSegmentsFor(AGENT_API_GATEWAY_PREFIX2).length;
2925
2765
  const segments = pathSegmentsFor(pathname);
2926
2766
  const upstreamSegments = segments.slice(prefixLength + 2);
2927
- return normalizeRoutePath4(`/${upstreamSegments.join("/")}`);
2767
+ return normalizeRoutePath3(`/${upstreamSegments.join("/")}`);
2928
2768
  }
2929
2769
  function forwardedRequestHeaders(source) {
2930
2770
  const headers = new Headers;
@@ -2959,7 +2799,7 @@ async function readGatewayRequestBody(request, upstreamPath) {
2959
2799
  return readRequestBodyWithLimit(request, MAX_AGENT_API_BODY_BYTES, "Agent API gateway request body exceeds 1MB.");
2960
2800
  }
2961
2801
  function isSimpleFileUpload(method, pathname) {
2962
- return method === "POST" && normalizeRoutePath4(pathname) === "/api/files";
2802
+ return method === "POST" && normalizeRoutePath3(pathname) === "/api/files";
2963
2803
  }
2964
2804
  function matchesWorkflowRunStart(pathname) {
2965
2805
  const segments = pathSegmentsFor(pathname);
@@ -11062,9 +10902,6 @@ function registerHttpRoutes(app, host, options) {
11062
10902
 
11063
10903
  // src/routes/auth.ts
11064
10904
  import { createHash as createHash3, randomBytes, randomUUID, timingSafeEqual } from "crypto";
11065
- import {
11066
- DEFAULT_AUTH_SESSION_AUDIENCE as DEFAULT_AUTH_SESSION_AUDIENCE2
11067
- } from "@sixb/core";
11068
10905
  import {
11069
10906
  AuthRuntimeError,
11070
10907
  clearCsrfCookieHeader,
@@ -11092,7 +10929,7 @@ import { resolve } from "path";
11092
10929
  var AUTH_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__";
11093
10930
  var AUTH_ASSET_PREFIX = "/auth/assets/";
11094
10931
  async function customAuthExperienceResponse(options, input) {
11095
- if (!options || input.audience !== (options.audience ?? "app")) {
10932
+ if (!options) {
11096
10933
  return null;
11097
10934
  }
11098
10935
  const template = Bun.file(resolve(options.outdir, "index.html"));
@@ -11407,14 +11244,8 @@ var AuthCreateInvitationCapabilitySchema = z32.union([
11407
11244
  reason: z32.enum(["missing_membership_policy", "invitation_delivery_not_supported"])
11408
11245
  })
11409
11246
  ]);
11410
- var AuthInvitationDestinationSchema = z32.object({
11411
- id: z32.enum(["atlas", "app"]),
11412
- label: z32.string()
11413
- });
11414
11247
  var GetAuthInvitationOptionsResponseSchema = z32.object({
11415
11248
  groups: z32.array(AuthInvitationGroupOptionSchema),
11416
- destinations: z32.array(AuthInvitationDestinationSchema),
11417
- defaultDestinationId: z32.enum(["atlas", "app"]).optional(),
11418
11249
  canInviteWithoutGroups: z32.boolean(),
11419
11250
  capabilities: z32.object({
11420
11251
  createInvitation: AuthCreateInvitationCapabilitySchema
@@ -11422,10 +11253,12 @@ var GetAuthInvitationOptionsResponseSchema = z32.object({
11422
11253
  });
11423
11254
  var GetAuthMembershipOptionsResponseSchema = z32.object({
11424
11255
  groups: z32.array(AuthGroupOptionSchema),
11256
+ serviceAccountGroups: z32.array(AuthGroupOptionSchema),
11425
11257
  capabilities: z32.object({
11426
11258
  invite: z32.boolean(),
11427
11259
  assignGroups: z32.boolean(),
11428
- suspend: z32.boolean()
11260
+ suspend: z32.boolean(),
11261
+ serviceAccounts: z32.boolean()
11429
11262
  })
11430
11263
  });
11431
11264
  var ListAuthMembersQuerySchema = z32.object({
@@ -11456,7 +11289,6 @@ var ReactivateAuthMemberResponseSchema = z32.object({
11456
11289
  var CreateAuthInvitationBodySchema = z32.object({
11457
11290
  email: z32.string().min(1),
11458
11291
  groupIds: z32.array(z32.string().min(1)).optional(),
11459
- destinationId: z32.enum(["atlas", "app"]).optional(),
11460
11292
  expiresAt: z32.string().optional(),
11461
11293
  returnTo: z32.string().optional(),
11462
11294
  revealLink: z32.boolean().optional()
@@ -11491,10 +11323,6 @@ var AuthSessionResponseSchema = z32.union([
11491
11323
  z32.object({
11492
11324
  authenticated: z32.literal(true),
11493
11325
  csrfToken: z32.string().optional(),
11494
- applicationAccess: z32.object({
11495
- allowed: z32.boolean(),
11496
- audience: z32.enum(["atlas", "app"])
11497
- }),
11498
11326
  user: z32.object({
11499
11327
  id: z32.string(),
11500
11328
  email: z32.string(),
@@ -11546,7 +11374,6 @@ var DeviceAuthorizationDecisionBodySchema = z32.object({
11546
11374
  });
11547
11375
  var AuthSessionSummarySchema = z32.object({
11548
11376
  id: z32.string(),
11549
- audience: z32.enum(["atlas", "app"]).optional(),
11550
11377
  current: z32.boolean(),
11551
11378
  createdAt: z32.string(),
11552
11379
  expiresAt: z32.string(),
@@ -11708,11 +11535,10 @@ function registerAuthRoutes(app, host, options) {
11708
11535
  if (!authorization || authorization.status !== "pending" || authorization.expiresAt <= now) {
11709
11536
  return authPageResponse("<h1>This authorization has expired</h1>", 400);
11710
11537
  }
11711
- const authOptions = resolveAuthOptions(options, request);
11712
- const session = await host.auth.getSession(request, authOptions);
11538
+ const session = await host.auth.getSession(request);
11713
11539
  if (!session.authenticated)
11714
11540
  return authPageResponse("<h1>Authentication required</h1>", 401);
11715
- const cookieOptions = host.auth.getCookieOptions(authOptions);
11541
+ const cookieOptions = host.auth.getCookieOptions();
11716
11542
  const csrf = resolveSessionCsrfToken({
11717
11543
  request,
11718
11544
  cookieOptions,
@@ -11737,11 +11563,10 @@ function registerAuthRoutes(app, host, options) {
11737
11563
  return response;
11738
11564
  }, { detail: { hide: true } }).post("/auth/device", async ({ body, request }) => {
11739
11565
  const parsed = DeviceAuthorizationDecisionBodySchema.parse(body);
11740
- const authOptions = resolveAuthOptions(options, request);
11741
- const session = await host.auth.getSession(request, authOptions);
11566
+ const session = await host.auth.getSession(request);
11742
11567
  if (!session.authenticated)
11743
11568
  return authPageResponse("<h1>Authentication required</h1>", 401);
11744
- const csrfCookieName = host.auth.getCookieOptions(authOptions).csrfCookieName;
11569
+ const csrfCookieName = host.auth.getCookieOptions().csrfCookieName;
11745
11570
  if (!verifyCsrfToken(request, { cookieName: csrfCookieName, token: parsed.csrfToken })) {
11746
11571
  return authPageResponse("<h1>Invalid authorization request</h1>", 403);
11747
11572
  }
@@ -11785,22 +11610,18 @@ function registerAuthRoutes(app, host, options) {
11785
11610
  parse: "urlencoded",
11786
11611
  detail: { hide: true }
11787
11612
  }).get("/api/auth/session", async ({ request }) => {
11788
- const authOptions = resolveAuthOptions(options, request);
11789
- const caller = await host.auth.getSession(request, {
11790
- ...authOptions,
11791
- credentialSource: "any"
11792
- });
11613
+ const caller = await host.auth.getSession(request, { credentialSource: "any" });
11793
11614
  if (!caller.authenticated || caller.credentialSource !== "session") {
11794
11615
  return signedOutSessionResponse(host);
11795
11616
  }
11796
11617
  if (caller.session.bearer) {
11797
- return jsonResponse2(authSessionBody(host, caller, DEFAULT_AUTH_SESSION_AUDIENCE2), 200);
11618
+ return jsonResponse2(authSessionBody(caller), 200);
11798
11619
  }
11799
- const session = hasForegroundSessionActivity(request) && sessionCanAccessApplication(host, caller, authOptions.audience) ? await host.auth.getSession(request, { ...authOptions, sessionActivity: "foreground" }) : caller;
11620
+ const session = hasForegroundSessionActivity(request) ? await host.auth.getSession(request, { sessionActivity: "foreground" }) : caller;
11800
11621
  if (!session.authenticated) {
11801
11622
  return signedOutSessionResponse(host);
11802
11623
  }
11803
- const cookieOptions = host.auth.getCookieOptions(authOptions);
11624
+ const cookieOptions = host.auth.getCookieOptions();
11804
11625
  const csrf = resolveSessionCsrfToken({
11805
11626
  request,
11806
11627
  cookieOptions,
@@ -11812,7 +11633,7 @@ function registerAuthRoutes(app, host, options) {
11812
11633
  session,
11813
11634
  csrfToken: csrf.token
11814
11635
  }) : null;
11815
- return authSessionJsonResponse({ ...authSessionBody(host, session, authOptions.audience), csrfToken: csrf.token }, renewal?.headers ?? (csrf.setCookie ? [csrf.setCookie] : []));
11636
+ return authSessionJsonResponse({ ...authSessionBody(session), csrfToken: csrf.token }, renewal?.headers ?? (csrf.setCookie ? [csrf.setCookie] : []));
11816
11637
  }, {
11817
11638
  response: { 200: AuthSessionResponseSchema },
11818
11639
  detail: {
@@ -11822,13 +11643,9 @@ function registerAuthRoutes(app, host, options) {
11822
11643
  security: SIXB_OPTIONAL_SESSION_SECURITY_REQUIREMENT
11823
11644
  }
11824
11645
  }).post("/api/auth/sign-out", async ({ request }) => {
11825
- const authOptions = resolveAuthOptions(options, request);
11826
- const result = await host.auth.getSession(request, {
11827
- ...authOptions,
11828
- credentialSource: "any"
11829
- });
11646
+ const result = await host.auth.getSession(request, { credentialSource: "any" });
11830
11647
  const session = result.authenticated && result.credentialSource === "session" ? result : null;
11831
- const cookieOptions = host.auth.getCookieOptions(authOptions);
11648
+ const cookieOptions = host.auth.getCookieOptions();
11832
11649
  if (session && !session.session.bearer && !verifyDoubleSubmitCsrf3(request, {
11833
11650
  cookieName: cookieOptions.csrfCookieName
11834
11651
  })) {
@@ -11858,7 +11675,6 @@ function registerAuthRoutes(app, host, options) {
11858
11675
  return jsonResponse2({
11859
11676
  sessions: sessions.map((entry) => ({
11860
11677
  id: entry.id,
11861
- audience: entry.bearer ? undefined : entry.audience,
11862
11678
  current: entry.id === session.session.id,
11863
11679
  createdAt: toIsoString(entry.createdAt),
11864
11680
  expiresAt: toIsoString(entry.expiresAt),
@@ -11890,7 +11706,7 @@ function registerAuthRoutes(app, host, options) {
11890
11706
  if (sessionId !== session.session.id) {
11891
11707
  return jsonResponse2({ success: true }, 200);
11892
11708
  }
11893
- const cookieOptions = host.auth.getCookieOptions(resolveAuthOptions(options, request));
11709
+ const cookieOptions = host.auth.getCookieOptions();
11894
11710
  return signedOutResponse(request, cookieOptions, { success: true });
11895
11711
  }, {
11896
11712
  params: RevokeAuthSessionParamsSchema,
@@ -11912,7 +11728,7 @@ function registerAuthRoutes(app, host, options) {
11912
11728
  return session;
11913
11729
  }
11914
11730
  const revokedCount = await host.auth.revokeAllSessions(session);
11915
- const cookieOptions = host.auth.getCookieOptions(resolveAuthOptions(options, request));
11731
+ const cookieOptions = host.auth.getCookieOptions();
11916
11732
  return signedOutResponse(request, cookieOptions, { success: true, revokedCount });
11917
11733
  }, {
11918
11734
  response: {
@@ -12212,7 +12028,6 @@ function registerAuthRoutes(app, host, options) {
12212
12028
  const caller = requireUserCaller(context);
12213
12029
  const parsed = CreateAuthInvitationBodySchema.parse(body);
12214
12030
  const deliveryContext = resolveInvitationDeliveryContext(options, request, {
12215
- destinationId: parsed.destinationId,
12216
12031
  returnTo: parsed.returnTo
12217
12032
  });
12218
12033
  if (deliveryContext instanceof Response) {
@@ -12251,10 +12066,7 @@ function registerAuthRoutes(app, host, options) {
12251
12066
  }).get("/api/auth/invitation-options", async ({ request, ...context }) => {
12252
12067
  try {
12253
12068
  const caller = requireUserCaller(context);
12254
- return jsonResponse2({
12255
- ...await host.auth.getInvitationOptions(caller),
12256
- ...options.getInvitationDestinationOptions(request)
12257
- }, 200);
12069
+ return jsonResponse2(await host.auth.getInvitationOptions(caller), 200);
12258
12070
  } catch (error) {
12259
12071
  return authRouteErrorResponse(error);
12260
12072
  }
@@ -12461,7 +12273,6 @@ function registerAuthRoutes(app, host, options) {
12461
12273
  }).post("/auth/sign-in", async ({ body, request }) => {
12462
12274
  const strategy = host.auth.getStrategy();
12463
12275
  const authRedirect = resolveAuthRedirectContext(options, request, {
12464
- audience: body.audience,
12465
12276
  returnTo: body.returnTo
12466
12277
  });
12467
12278
  if (authRedirect instanceof Response) {
@@ -12474,7 +12285,6 @@ function registerAuthRoutes(app, host, options) {
12474
12285
  projectId: host.id,
12475
12286
  authStorage,
12476
12287
  email: body.email ?? "",
12477
- audience: authRedirect.audience,
12478
12288
  returnTo: authRedirect.returnTo,
12479
12289
  requestOrigin: authRedirect.requestOrigin,
12480
12290
  requesterHash: pending.hash
@@ -12494,7 +12304,6 @@ function registerAuthRoutes(app, host, options) {
12494
12304
  const result = await strategy.startOidcSignIn({
12495
12305
  projectId: host.id,
12496
12306
  authStorage,
12497
- audience: authRedirect.audience,
12498
12307
  returnTo: authRedirect.returnTo,
12499
12308
  requestOrigin: authRedirect.requestOrigin
12500
12309
  });
@@ -12503,7 +12312,6 @@ function registerAuthRoutes(app, host, options) {
12503
12312
  return strategyNotImplementedResponse("Sign-in is not implemented yet.");
12504
12313
  }, {
12505
12314
  body: t.Object({
12506
- audience: t.Optional(t.String()),
12507
12315
  email: t.Optional(t.String()),
12508
12316
  returnTo: t.Optional(t.String())
12509
12317
  }),
@@ -12513,7 +12321,6 @@ function registerAuthRoutes(app, host, options) {
12513
12321
  const strategy = host.auth.getStrategy();
12514
12322
  const url = new URL(request.url);
12515
12323
  const authRedirect = resolveAuthRedirectContext(options, request, {
12516
- audience: url.searchParams.get("audience"),
12517
12324
  returnTo: url.searchParams.get("returnTo")
12518
12325
  });
12519
12326
  if (authRedirect instanceof Response) {
@@ -12526,7 +12333,6 @@ function registerAuthRoutes(app, host, options) {
12526
12333
  const result = await strategy.startOidcSignIn({
12527
12334
  projectId: host.id,
12528
12335
  authStorage: requireAuthStorage(host),
12529
- audience: authRedirect.audience,
12530
12336
  returnTo: authRedirect.returnTo,
12531
12337
  requestOrigin: authRedirect.requestOrigin
12532
12338
  });
@@ -12539,7 +12345,7 @@ function registerAuthRoutes(app, host, options) {
12539
12345
  const url = new URL(request.url);
12540
12346
  const magicLinkId = url.searchParams.get("magicLinkId")?.trim();
12541
12347
  const token = url.searchParams.get("token")?.trim();
12542
- const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, url.searchParams.get("audience"));
12348
+ const authRedirectHint = resolveAuthExperienceRedirectHint(options, request);
12543
12349
  if (!magicLinkId || !token) {
12544
12350
  return await invalidMagicLinkResponse(options, authRedirectHint);
12545
12351
  }
@@ -12592,7 +12398,6 @@ function registerAuthRoutes(app, host, options) {
12592
12398
  if (!state || !matchesOidcStateCookie(request, state)) {
12593
12399
  throw new Error("[SixbServer] OIDC callback reached a browser that did not start this sign-in.");
12594
12400
  }
12595
- const authOptions = resolveAuthOptions(options, request);
12596
12401
  const result = await strategy.completeOidcSignIn({
12597
12402
  projectId: host.id,
12598
12403
  authStorage: requireAuthStorage(host),
@@ -12600,7 +12405,6 @@ function registerAuthRoutes(app, host, options) {
12600
12405
  requestOrigin: options.resolveAuthRequestOrigin(request),
12601
12406
  session: {
12602
12407
  id: sessionCredential.sessionId,
12603
- audience: authOptions.audience,
12604
12408
  tokenHash: sessionCredential.tokenHash,
12605
12409
  createdAt: now,
12606
12410
  ...host.auth.createSessionDeadlines(now),
@@ -12612,7 +12416,6 @@ function registerAuthRoutes(app, host, options) {
12612
12416
  request,
12613
12417
  apiOrigin: options.resolveAuthRequestOrigin(request),
12614
12418
  sessionCredential,
12615
- audience: result.session.audience,
12616
12419
  expiresAt: result.session.expiresAt,
12617
12420
  returnTo: result.returnTo
12618
12421
  });
@@ -12639,7 +12442,7 @@ function registerAuthRoutes(app, host, options) {
12639
12442
  }
12640
12443
  const magicLinkId = body.magicLinkId?.trim();
12641
12444
  const token = body.token?.trim();
12642
- const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, body.audience);
12445
+ const authRedirectHint = resolveAuthExperienceRedirectHint(options, request);
12643
12446
  if (!magicLinkId || !token) {
12644
12447
  return await invalidMagicLinkResponse(options, authRedirectHint);
12645
12448
  }
@@ -12655,8 +12458,7 @@ function registerAuthRoutes(app, host, options) {
12655
12458
  }, {
12656
12459
  body: t.Object({
12657
12460
  magicLinkId: t.Optional(t.String()),
12658
- token: t.Optional(t.String()),
12659
- audience: t.Optional(t.String())
12461
+ token: t.Optional(t.String())
12660
12462
  }),
12661
12463
  parse: "urlencoded",
12662
12464
  detail: { hide: true }
@@ -12718,7 +12520,6 @@ function callbackCookieHeader(params) {
12718
12520
  return parts.join("; ");
12719
12521
  }
12720
12522
  async function completeMagicLinkCallback(input) {
12721
- const authOptions = resolveAuthOptions(input.options, input.request);
12722
12523
  const now = new Date;
12723
12524
  const sessionCredential = createSessionCredential();
12724
12525
  const device = resolveSessionDevice(input.request);
@@ -12730,7 +12531,6 @@ async function completeMagicLinkCallback(input) {
12730
12531
  token: input.token,
12731
12532
  session: {
12732
12533
  id: sessionCredential.sessionId,
12733
- audience: authOptions.audience,
12734
12534
  tokenHash: sessionCredential.tokenHash,
12735
12535
  createdAt: now,
12736
12536
  ...input.host.auth.createSessionDeadlines(now),
@@ -12742,7 +12542,6 @@ async function completeMagicLinkCallback(input) {
12742
12542
  request: input.request,
12743
12543
  apiOrigin: input.options.resolveAuthRequestOrigin(input.request),
12744
12544
  sessionCredential,
12745
- audience: result.session.audience,
12746
12545
  expiresAt: result.session.expiresAt,
12747
12546
  returnTo: result.returnTo
12748
12547
  });
@@ -12796,7 +12595,7 @@ function resolveSessionDevice(request) {
12796
12595
  };
12797
12596
  }
12798
12597
  function sessionCallbackCompletionResponse(input) {
12799
- const cookieOptions = input.host.auth.getCookieOptions({ audience: input.audience });
12598
+ const cookieOptions = input.host.auth.getCookieOptions();
12800
12599
  const headers = new Headers({
12801
12600
  "cache-control": "no-store"
12802
12601
  });
@@ -12844,9 +12643,6 @@ function authCallbackCompletionDocumentResponse(returnTo, headers) {
12844
12643
  headers
12845
12644
  });
12846
12645
  }
12847
- function resolveAuthOptions(options, request) {
12848
- return options.resolveAuthContext(request);
12849
- }
12850
12646
  function resolveAuthRedirectContext(options, request, input) {
12851
12647
  try {
12852
12648
  return options.resolveAuthRedirectContext(request, input);
@@ -12862,7 +12658,7 @@ function resolveInvitationDeliveryContext(options, request, input) {
12862
12658
  return options.resolveInvitationRedirectContext(request, input);
12863
12659
  } catch (error) {
12864
12660
  if (error instanceof BrowserOriginError) {
12865
- return jsonResponse2({ error: "Invitation destination is not allowed" }, 400);
12661
+ return jsonResponse2({ error: "Invitation return target is not allowed" }, 400);
12866
12662
  }
12867
12663
  throw error;
12868
12664
  }
@@ -12883,10 +12679,9 @@ function resolveSessionCsrfToken(input) {
12883
12679
  })
12884
12680
  };
12885
12681
  }
12886
- function authSessionBody(host, session, audience) {
12682
+ function authSessionBody(session) {
12887
12683
  return {
12888
12684
  authenticated: true,
12889
- applicationAccess: { allowed: sessionCanAccessApplication(host, session, audience), audience },
12890
12685
  user: {
12891
12686
  id: session.user.id,
12892
12687
  email: session.user.email,
@@ -13076,20 +12871,18 @@ function authPageResponse(body, status = 200) {
13076
12871
  }
13077
12872
  async function signInFormResponse(options, context) {
13078
12873
  return await customAuthExperienceResponse(options.authExperience, {
13079
- audience: context.audience,
13080
12874
  state: { kind: "signIn" },
13081
12875
  signInUrl: authExperienceSignInUrl(context),
13082
12876
  submission: {
13083
12877
  kind: "requestMagicLink",
13084
12878
  action: "/auth/sign-in",
13085
- fields: { audience: context.audience, returnTo: context.returnTo }
12879
+ fields: { returnTo: context.returnTo }
13086
12880
  },
13087
12881
  referrerPolicy: "same-origin"
13088
12882
  }) ?? authPageResponse([
13089
12883
  "<h1>Sign in</h1>",
13090
12884
  "<p>We'll email you a sign-in link.</p>",
13091
12885
  '<form method="post" action="/auth/sign-in">',
13092
- `<input type="hidden" name="audience" value="${escapeHtml(context.audience)}">`,
13093
12886
  `<input type="hidden" name="returnTo" value="${escapeHtml(context.returnTo)}">`,
13094
12887
  '<input name="email" type="email" autocomplete="email" placeholder="you@example.com" aria-label="Email address" required autofocus>',
13095
12888
  '<button type="submit">Send sign-in link</button>',
@@ -13098,7 +12891,6 @@ async function signInFormResponse(options, context) {
13098
12891
  }
13099
12892
  async function magicLinkRequestedResponse(options, context) {
13100
12893
  return await customAuthExperienceResponse(options.authExperience, {
13101
- audience: context.audience,
13102
12894
  state: { kind: "checkEmail" },
13103
12895
  signInUrl: authExperienceSignInUrl(context)
13104
12896
  }) ?? htmlMessageResponse("If this email can sign in, we sent a link. Check your inbox to continue.", 200, "Check your email");
@@ -13106,7 +12898,6 @@ async function magicLinkRequestedResponse(options, context) {
13106
12898
  async function invalidMagicLinkResponse(options, context) {
13107
12899
  if (context) {
13108
12900
  const custom = await customAuthExperienceResponse(options.authExperience, {
13109
- audience: context.audience,
13110
12901
  state: { kind: "invalidLink" },
13111
12902
  signInUrl: authExperienceSignInUrl(context),
13112
12903
  status: 400
@@ -13119,7 +12910,6 @@ async function invalidMagicLinkResponse(options, context) {
13119
12910
  async function authExperienceErrorResponse(options, context) {
13120
12911
  if (context) {
13121
12912
  const custom = await customAuthExperienceResponse(options.authExperience, {
13122
- audience: context.audience,
13123
12913
  state: { kind: "error" },
13124
12914
  signInUrl: authExperienceSignInUrl(context),
13125
12915
  status: 500
@@ -13130,20 +12920,16 @@ async function authExperienceErrorResponse(options, context) {
13130
12920
  return await invalidMagicLinkResponse(options, undefined);
13131
12921
  }
13132
12922
  function authExperienceSignInUrl(context) {
13133
- const params = new URLSearchParams({ audience: context.audience, returnTo: context.returnTo });
12923
+ const params = new URLSearchParams({ returnTo: context.returnTo });
13134
12924
  return `/auth/sign-in?${params.toString()}`;
13135
12925
  }
13136
- function resolveAuthExperienceRedirectHint(options, request, audience) {
13137
- if (audience !== "app" && audience !== "atlas") {
13138
- return;
13139
- }
13140
- const context = resolveInvitationDeliveryContext(options, request, { destinationId: audience });
12926
+ function resolveAuthExperienceRedirectHint(options, request) {
12927
+ const context = resolveInvitationDeliveryContext(options, request, {});
13141
12928
  return context instanceof Response ? undefined : context;
13142
12929
  }
13143
12930
  async function magicLinkConfirmResponse(options, input) {
13144
12931
  if (input.authRedirect) {
13145
12932
  const custom = await customAuthExperienceResponse(options.authExperience, {
13146
- audience: input.authRedirect.audience,
13147
12933
  state: { kind: "confirm", ...input.email ? { email: input.email } : {} },
13148
12934
  signInUrl: authExperienceSignInUrl(input.authRedirect),
13149
12935
  submission: {
@@ -13151,8 +12937,7 @@ async function magicLinkConfirmResponse(options, input) {
13151
12937
  action: "/auth/callback",
13152
12938
  fields: {
13153
12939
  magicLinkId: input.magicLinkId,
13154
- token: input.token,
13155
- audience: input.authRedirect.audience
12940
+ token: input.token
13156
12941
  }
13157
12942
  },
13158
12943
  referrerPolicy: "same-origin",
@@ -13167,9 +12952,6 @@ async function magicLinkConfirmResponse(options, input) {
13167
12952
  '<form method="post" action="/auth/callback" id="confirm">',
13168
12953
  `<input type="hidden" name="magicLinkId" value="${escapeHtml(input.magicLinkId)}">`,
13169
12954
  `<input type="hidden" name="token" value="${escapeHtml(input.token)}">`,
13170
- ...input.authRedirect ? [
13171
- `<input type="hidden" name="audience" value="${escapeHtml(input.authRedirect.audience)}">`
13172
- ] : [],
13173
12955
  '<button type="submit" id="confirm-button">Continue</button>',
13174
12956
  "</form>",
13175
12957
  "<script>",
@@ -14734,9 +14516,6 @@ class SixbServer {
14734
14516
  resolveAuthRequestOrigin(request) {
14735
14517
  return resolveApiBrowserPublicOrigin(this.apiBrowserPolicy, request);
14736
14518
  }
14737
- getInvitationDestinationOptions(_request) {
14738
- return getApiBrowserInvitationDestinationOptions(this.apiBrowserPolicy);
14739
- }
14740
14519
  resolveInvitationRedirectContext(request, input) {
14741
14520
  return resolveApiBrowserInvitationRedirectContext(this.apiBrowserPolicy, request, input);
14742
14521
  }
@@ -14964,9 +14743,7 @@ function createSixbApi(server) {
14964
14743
  }));
14965
14744
  const authExperience = server.getAuthExperience();
14966
14745
  registerAuthRoutes(app, host, {
14967
- resolveAuthContext: (request) => server.resolveAuthContext(request),
14968
14746
  resolveAuthRedirectContext: (request, input) => server.resolveAuthRedirectContext(request, input),
14969
- getInvitationDestinationOptions: (request) => server.getInvitationDestinationOptions(request),
14970
14747
  resolveAuthRequestOrigin: (request) => server.resolveAuthRequestOrigin(request),
14971
14748
  authExperience: authExperience && { ...authExperience, locale: host.locale },
14972
14749
  resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
@@ -14974,13 +14751,7 @@ function createSixbApi(server) {
14974
14751
  registerHttpRoutes(app, host, {
14975
14752
  sharedAccess,
14976
14753
  connectorConnections: {
14977
- resolveReturnTo: (request, returnTo) => {
14978
- const authContext = server.resolveAuthContext(request);
14979
- return server.resolveAuthRedirectContext(request, {
14980
- audience: authContext.audience,
14981
- returnTo
14982
- }).returnTo;
14983
- },
14754
+ resolveReturnTo: (request, returnTo) => server.resolveAuthRedirectContext(request, { returnTo }).returnTo,
14984
14755
  resolveCallbackUrl: (request) => new URL("/auth/connectors/callback", server.resolveAuthRequestOrigin(request)).toString()
14985
14756
  }
14986
14757
  });
@@ -15071,4 +14842,4 @@ export {
15071
14842
  createSixbServer
15072
14843
  };
15073
14844
 
15074
- //# debugId=AA8B124AF8294E7E64756E2164756E21
14845
+ //# debugId=891AB76315522D8A64756E2164756E21