@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
@@ -1,57 +1,20 @@
1
- import {
2
- type AuthSessionAudience,
3
- applications,
4
- DEFAULT_AUTH_SESSION_AUDIENCE,
5
- isValidAuthSessionAudience,
6
- resolveAuthSessionAudience,
7
- } from "@sixb/core"
8
- import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http"
9
-
10
- const fileNavigationRoutes = SIXB_API_ROUTES.filter(
11
- (route) =>
12
- (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content")
13
- )
14
-
15
- export interface SixbBrowserOrigin {
16
- readonly origin: string
17
- readonly audience: AuthSessionAudience
18
- }
19
-
20
1
  export interface SixbApiBrowserPolicy {
21
2
  readonly publicOrigin?: string
22
- readonly allowedOrigins: readonly SixbBrowserOrigin[]
23
- readonly apiOriginAudience?: AuthSessionAudience
24
- }
25
-
26
- export interface ResolvedSixbBrowserOrigin {
27
- readonly origin: string
28
- readonly audience: AuthSessionAudience
3
+ /** The browser origins that may call the API with a session: the project's app. */
4
+ readonly allowedOrigins: readonly string[]
29
5
  }
30
6
 
31
7
  export interface ResolvedSixbApiBrowserPolicy {
32
8
  readonly publicOrigin?: string
33
- readonly apiOriginAudience: AuthSessionAudience
34
- readonly allowedOrigins: readonly ResolvedSixbBrowserOrigin[]
9
+ readonly allowedOrigins: readonly string[]
35
10
  }
36
11
 
37
12
  export interface RequestAuthContext {
38
- readonly audience: AuthSessionAudience
39
13
  readonly browserOrigin?: string
40
14
  readonly absoluteReturnTo?: boolean
41
15
  }
42
16
 
43
- export interface AuthInvitationDestination {
44
- readonly id: AuthSessionAudience
45
- readonly label: string
46
- }
47
-
48
- export interface AuthInvitationDestinationOptions {
49
- readonly destinations: readonly AuthInvitationDestination[]
50
- readonly defaultDestinationId?: AuthSessionAudience
51
- }
52
-
53
17
  export interface AuthInvitationRedirectInput {
54
- readonly destinationId?: AuthSessionAudience
55
18
  readonly returnTo?: string
56
19
  }
57
20
 
@@ -60,13 +23,11 @@ export type AuthInvitationRedirectContext = AuthRedirectContext
60
23
  export type ResolveRequestAuthContext = (request: Request) => RequestAuthContext
61
24
 
62
25
  export interface AuthRedirectInput {
63
- readonly audience?: string | null
64
26
  readonly returnTo?: string | null
65
27
  readonly fallbackReturnToOrigin?: string
66
28
  }
67
29
 
68
30
  export interface AuthRedirectContext {
69
- readonly audience: AuthSessionAudience
70
31
  readonly returnTo: string
71
32
  readonly requestOrigin: string
72
33
  }
@@ -83,46 +44,18 @@ export class BrowserOriginError extends Error {
83
44
  export function resolveApiBrowserPolicy(
84
45
  policy: SixbApiBrowserPolicy
85
46
  ): ResolvedSixbApiBrowserPolicy {
86
- const apiOriginAudience = resolveAuthSessionAudience(
87
- policy.apiOriginAudience ?? DEFAULT_AUTH_SESSION_AUDIENCE
88
- )
89
- const origins = new Map<string, ResolvedSixbBrowserOrigin>()
90
- const audienceOrigins = new Map<AuthSessionAudience, string>()
91
-
92
- for (const entry of policy.allowedOrigins) {
93
- const origin = normalizeHttpOrigin(entry.origin, "browser origin")
94
- const audience = resolveAuthSessionAudience(entry.audience)
95
- const existingAudienceOrigin = audienceOrigins.get(audience)
96
- if (existingAudienceOrigin && existingAudienceOrigin !== origin) {
97
- throw new Error(
98
- `[SixbServer] Auth audience '${audience}' is mapped to multiple browser origins.`
99
- )
100
- }
101
- audienceOrigins.set(audience, origin)
102
-
103
- const existing = origins.get(origin)
104
- if (existing) {
105
- if (existing.audience !== audience) {
106
- throw new Error(
107
- `[SixbServer] Browser origin '${origin}' is mapped to multiple auth audiences.`
108
- )
109
- }
110
- continue
111
- }
112
-
113
- origins.set(origin, { origin, audience })
114
- }
115
-
116
- if (origins.size === 0) {
117
- throw new Error("[SixbServer] API browser policy requires at least one allowed origin.")
118
- }
47
+ const allowedOrigins = [
48
+ ...new Set(
49
+ policy.allowedOrigins.map((origin) => normalizeHttpOrigin(origin, "browser origin"))
50
+ ),
51
+ ]
119
52
 
53
+ // Empty is an API serving no browser app: only its own origin is admitted.
120
54
  return {
121
55
  publicOrigin: policy.publicOrigin
122
56
  ? normalizeHttpOrigin(policy.publicOrigin, "API public origin")
123
57
  : undefined,
124
- apiOriginAudience,
125
- allowedOrigins: [...origins.values()],
58
+ allowedOrigins,
126
59
  }
127
60
  }
128
61
 
@@ -143,82 +76,23 @@ export function resolveApiBrowserAuthContext(
143
76
  request: Request
144
77
  ): RequestAuthContext {
145
78
  const origin = normalizeRequestOrigin(request)
146
- const fileAudience = resolveFileNavigationAudience(policy, request)
147
79
  if (!origin) {
148
- return { audience: fileAudience ?? policy.apiOriginAudience, absoluteReturnTo: true }
80
+ return { absoluteReturnTo: true }
149
81
  }
150
82
 
151
- const allowed = findAllowedBrowserOrigin(policy, origin)
152
- if (allowed) {
153
- assertFileAudienceMatchesOrigin(fileAudience, allowed.audience)
154
- return {
155
- audience: allowed.audience,
156
- browserOrigin: allowed.origin,
157
- absoluteReturnTo: true,
158
- }
159
- }
160
-
161
- if (isSameOriginApiRequest(policy, origin, request)) {
162
- assertFileAudienceMatchesOrigin(fileAudience, policy.apiOriginAudience)
163
- return { audience: policy.apiOriginAudience, browserOrigin: origin, absoluteReturnTo: true }
83
+ if (isAllowedOrigin(policy, request, origin)) {
84
+ return { browserOrigin: origin, absoluteReturnTo: true }
164
85
  }
165
86
 
166
87
  throw new BrowserOriginError(`[SixbServer] Browser origin '${origin}' is not allowed.`)
167
88
  }
168
89
 
169
- // A URL audience selects credentials, never grants authority. Only file GET/HEAD
170
- // routes accept it; Origin remains authoritative whenever the browser sends one.
171
- function resolveFileNavigationAudience(
172
- policy: ResolvedSixbApiBrowserPolicy,
173
- request: Request
174
- ): AuthSessionAudience | undefined {
175
- const url = new URL(request.url)
176
- if (
177
- !fileNavigationRoutes.some(
178
- (route) =>
179
- route.method === request.method &&
180
- matchesPathPattern(normalizeRoutePath(url.pathname), route.path)
181
- )
182
- ) {
183
- return undefined
184
- }
185
- const values = url.searchParams.getAll("audience")
186
- if (values.length === 0) return undefined
187
- const audience = values[0]
188
- if (
189
- values.length !== 1 ||
190
- !audience ||
191
- !isValidAuthSessionAudience(audience) ||
192
- (audience !== policy.apiOriginAudience &&
193
- !policy.allowedOrigins.some((entry) => entry.audience === audience))
194
- ) {
195
- throw new BrowserOriginError("[SixbServer] File navigation audience is not allowed.")
196
- }
197
- return audience
198
- }
199
-
200
- function assertFileAudienceMatchesOrigin(
201
- audience: AuthSessionAudience | undefined,
202
- originAudience: AuthSessionAudience
203
- ): void {
204
- if (audience !== undefined && audience !== originAudience) {
205
- throw new BrowserOriginError("[SixbServer] File navigation audience conflicts with Origin.")
206
- }
207
- }
208
-
209
90
  export function isAllowedApiBrowserOrigin(
210
91
  policy: ResolvedSixbApiBrowserPolicy,
211
92
  request: Request
212
93
  ): boolean {
213
94
  const origin = normalizeRequestOrigin(request)
214
- if (!origin) {
215
- return false
216
- }
217
-
218
- return (
219
- findAllowedBrowserOrigin(policy, origin) !== null ||
220
- isSameOriginApiRequest(policy, origin, request)
221
- )
95
+ return origin !== null && isAllowedOrigin(policy, request, origin)
222
96
  }
223
97
 
224
98
  export function resolveApiBrowserAuthRedirectContext(
@@ -226,58 +100,21 @@ export function resolveApiBrowserAuthRedirectContext(
226
100
  request: Request,
227
101
  input: AuthRedirectInput
228
102
  ): AuthRedirectContext {
229
- const audience = resolveRequiredAuthAudience(input.audience)
230
- const returnTo = resolveApiBrowserReturnTo(policy, request, input, audience)
231
-
232
103
  return {
233
- audience,
234
- returnTo,
104
+ returnTo: resolveApiBrowserReturnTo(policy, request, input),
235
105
  requestOrigin: resolveApiBrowserPublicOrigin(policy, request),
236
106
  }
237
107
  }
238
108
 
239
- export function getApiBrowserInvitationDestinationOptions(
240
- policy: ResolvedSixbApiBrowserPolicy
241
- ): AuthInvitationDestinationOptions {
242
- const destinations = policy.allowedOrigins.map((entry) => ({
243
- id: entry.audience,
244
- label: applications[entry.audience].label,
245
- }))
246
- const defaultDestinationId = destinations.some((destination) => destination.id === "app")
247
- ? applications.app.id
248
- : destinations.some((destination) => destination.id === "atlas")
249
- ? applications.atlas.id
250
- : undefined
251
-
252
- return {
253
- destinations,
254
- ...(defaultDestinationId ? { defaultDestinationId } : {}),
255
- }
256
- }
257
-
109
+ /** An invitation lands where the inviter works, or on the app when the request has no Origin. */
258
110
  export function resolveApiBrowserInvitationRedirectContext(
259
111
  policy: ResolvedSixbApiBrowserPolicy,
260
112
  request: Request,
261
113
  input: AuthInvitationRedirectInput
262
114
  ): AuthInvitationRedirectContext {
263
115
  const authContext = resolveApiBrowserAuthContext(policy, request)
264
- if (!input.destinationId) {
265
- return resolveApiBrowserAuthRedirectContext(policy, request, {
266
- audience: authContext.audience,
267
- fallbackReturnToOrigin: authContext.browserOrigin,
268
- returnTo: input.returnTo,
269
- })
270
- }
271
-
272
- const destination = policy.allowedOrigins.find((entry) => entry.audience === input.destinationId)
273
- if (!destination) {
274
- throw new BrowserOriginError("[SixbServer] Invitation destination is not allowed.")
275
- }
276
- assertInvitationReturnToOrigin(input.returnTo, destination.origin)
277
-
278
116
  return resolveApiBrowserAuthRedirectContext(policy, request, {
279
- audience: destination.audience,
280
- fallbackReturnToOrigin: destination.origin,
117
+ fallbackReturnToOrigin: authContext.browserOrigin ?? policy.allowedOrigins[0],
281
118
  returnTo: input.returnTo,
282
119
  })
283
120
  }
@@ -289,51 +126,21 @@ export function resolveApiBrowserPublicOrigin(
289
126
  return policy.publicOrigin ?? new URL(request.url).origin
290
127
  }
291
128
 
292
- function findAllowedBrowserOrigin(
129
+ function isAllowedOrigin(
293
130
  policy: ResolvedSixbApiBrowserPolicy,
131
+ request: Request,
294
132
  origin: string
295
- ): ResolvedSixbBrowserOrigin | null {
296
- return policy.allowedOrigins.find((entry) => entry.origin === origin) ?? null
297
- }
298
-
299
- function isSameOriginApiRequest(
300
- policy: ResolvedSixbApiBrowserPolicy,
301
- origin: string,
302
- request: Request
303
133
  ): boolean {
304
- const apiOrigin = resolveApiBrowserPublicOrigin(policy, request)
305
- return origin === apiOrigin
306
- }
307
-
308
- function assertInvitationReturnToOrigin(
309
- returnTo: string | undefined,
310
- destinationOrigin: string
311
- ): void {
312
- if (!returnTo?.trim()) return
313
-
314
- try {
315
- if (new URL(returnTo).origin === destinationOrigin) return
316
- } catch {
317
- // Fall through to the same public validation error as an origin mismatch.
318
- }
319
-
320
- throw new BrowserOriginError("[SixbServer] Invitation return target is not allowed.")
321
- }
322
-
323
- function resolveRequiredAuthAudience(value: string | null | undefined): AuthSessionAudience {
324
- const audience = value?.trim()
325
- if (!audience || !isValidAuthSessionAudience(audience)) {
326
- throw new BrowserOriginError("[SixbServer] Auth audience is invalid or missing.")
327
- }
328
-
329
- return audience
134
+ return (
135
+ policy.allowedOrigins.includes(origin) ||
136
+ origin === resolveApiBrowserPublicOrigin(policy, request)
137
+ )
330
138
  }
331
139
 
332
140
  function resolveApiBrowserReturnTo(
333
141
  policy: ResolvedSixbApiBrowserPolicy,
334
142
  request: Request,
335
- input: AuthRedirectInput,
336
- audience: AuthSessionAudience
143
+ input: AuthRedirectInput
337
144
  ): string {
338
145
  const rawReturnTo = input.returnTo?.trim()
339
146
  const value =
@@ -354,35 +161,18 @@ function resolveApiBrowserReturnTo(
354
161
  throw new BrowserOriginError("[SixbServer] Auth return target must be an absolute URL.")
355
162
  }
356
163
 
357
- if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password) {
358
- throw new BrowserOriginError("[SixbServer] Auth return target is not allowed.")
359
- }
360
-
361
- const returnAudience = resolveReturnToAudience(policy, request, url.origin)
362
- if (returnAudience !== audience) {
164
+ if (
165
+ (url.protocol !== "http:" && url.protocol !== "https:") ||
166
+ url.username ||
167
+ url.password ||
168
+ !isAllowedOrigin(policy, request, url.origin)
169
+ ) {
363
170
  throw new BrowserOriginError("[SixbServer] Auth return target is not allowed.")
364
171
  }
365
172
 
366
173
  return url.toString()
367
174
  }
368
175
 
369
- function resolveReturnToAudience(
370
- policy: ResolvedSixbApiBrowserPolicy,
371
- request: Request,
372
- origin: string
373
- ): AuthSessionAudience | null {
374
- const allowed = findAllowedBrowserOrigin(policy, origin)
375
- if (allowed) {
376
- return allowed.audience
377
- }
378
-
379
- if (origin === resolveApiBrowserPublicOrigin(policy, request)) {
380
- return policy.apiOriginAudience
381
- }
382
-
383
- return null
384
- }
385
-
386
176
  function normalizeRequestOrigin(request: Request): string | null {
387
177
  const origin = request.headers.get("origin")
388
178
  if (!origin) {
@@ -1,12 +1,10 @@
1
1
  import { resolve } from "node:path"
2
- import type { AuthSessionAudience } from "@sixb/core"
3
2
 
4
3
  const AUTH_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__"
5
4
  const AUTH_ASSET_PREFIX = "/auth/assets/"
6
5
 
7
6
  export interface SixbAuthExperienceOptions {
8
7
  readonly outdir: string
9
- readonly audience?: AuthSessionAudience
10
8
  }
11
9
 
12
10
  /** The configured experience with the project's language, which its pages declare. */
@@ -30,7 +28,6 @@ export interface AuthExperienceSubmission {
30
28
  export async function customAuthExperienceResponse(
31
29
  options: ProjectAuthExperience | undefined,
32
30
  input: {
33
- readonly audience: AuthSessionAudience
34
31
  readonly state: AuthExperiencePageState
35
32
  readonly signInUrl: string
36
33
  readonly submission?: AuthExperienceSubmission
@@ -39,7 +36,7 @@ export async function customAuthExperienceResponse(
39
36
  readonly formActionOrigins?: readonly string[]
40
37
  }
41
38
  ): Promise<Response | null> {
42
- if (!options || input.audience !== (options.audience ?? "app")) {
39
+ if (!options) {
43
40
  return null
44
41
  }
45
42
 
package/src/auth/guard.ts CHANGED
@@ -4,7 +4,6 @@ import {
4
4
  verifyDoubleSubmitCsrf,
5
5
  } from "@sixb/core/internal/auth"
6
6
  import { credentialTransport, isAccessTokenRoute, shouldVerifyCsrf } from "./access-token-boundary"
7
- import { sessionCanAccessApplication } from "./application-access"
8
7
  import { BrowserOriginError, type ResolveRequestAuthContext } from "./browser-origin"
9
8
  import { classifyRoute } from "./public-routes"
10
9
  import {
@@ -64,17 +63,13 @@ export class ServerAuthGuard {
64
63
  return { kind: "deny", response: authContext }
65
64
  }
66
65
 
67
- let session = await this.host.auth.getSession(request, {
68
- audience: authContext.audience,
69
- credentialSource: "any",
70
- })
66
+ let session = await this.host.auth.getSession(request, { credentialSource: "any" })
71
67
  if (!session.authenticated) {
72
68
  if (route.kind === "html") {
73
69
  return {
74
70
  kind: "deny",
75
71
  response: htmlAuthRedirectResponse(request, {
76
72
  absoluteReturnTo: authContext.absoluteReturnTo ?? false,
77
- audience: authContext.audience,
78
73
  }),
79
74
  }
80
75
  }
@@ -86,20 +81,6 @@ export class ServerAuthGuard {
86
81
  return { kind: "deny", response: jsonAuthRequiredResponse() }
87
82
  }
88
83
 
89
- // Application access gates the web app a browser session belongs to. A native client's session
90
- // and an access token belong to no web app: grants alone decide what they may do. Account pages
91
- // serve every signed-in user.
92
- const deniedApplication = (caller: AuthenticatedRequestAuthSession) =>
93
- !route.account &&
94
- credentialTransport(caller) === "cookie" &&
95
- !sessionCanAccessApplication(this.host, caller, authContext.audience)
96
- if (deniedApplication(session)) {
97
- return {
98
- kind: "deny",
99
- response: jsonForbiddenResponse("Application access is not allowed"),
100
- }
101
- }
102
-
103
84
  if (session.credentialSource === "accessToken" && !isAccessTokenRoute(request)) {
104
85
  return {
105
86
  kind: "deny",
@@ -123,7 +104,6 @@ export class ServerAuthGuard {
123
104
  hasForegroundSessionActivity(request)
124
105
  ) {
125
106
  const activeSession = await this.host.auth.getSession(request, {
126
- audience: authContext.audience,
127
107
  credentialSource: "session",
128
108
  sessionActivity: "foreground",
129
109
  })
@@ -133,32 +113,24 @@ export class ServerAuthGuard {
133
113
  kind: "deny",
134
114
  response: htmlAuthRedirectResponse(request, {
135
115
  absoluteReturnTo: authContext.absoluteReturnTo ?? false,
136
- audience: authContext.audience,
137
116
  }),
138
117
  }
139
118
  }
140
119
  return { kind: "deny", response: jsonAuthRequiredResponse() }
141
120
  }
142
- if (deniedApplication(activeSession)) {
143
- return {
144
- kind: "deny",
145
- response: jsonForbiddenResponse("Application access is not allowed"),
146
- }
147
- }
148
121
  session = activeSession
149
122
  }
150
123
 
151
124
  return { kind: "allow", session }
152
125
  }
153
126
 
154
- getCsrfCookieName(request: Request): string {
155
- const audience = this.resolveAuthContext(request).audience
156
- return this.host.auth.getCookieOptions({ audience }).csrfCookieName
127
+ getCsrfCookieName(): string {
128
+ return this.host.auth.getCookieOptions().csrfCookieName
157
129
  }
158
130
 
159
131
  verifyCsrf(request: Request, _session: AuthenticatedRequestAuthSession): boolean {
160
132
  return verifyDoubleSubmitCsrf(request, {
161
- cookieName: this.getCsrfCookieName(request),
133
+ cookieName: this.getCsrfCookieName(),
162
134
  })
163
135
  }
164
136
 
@@ -10,11 +10,6 @@ export type RouteAccessKind = "public" | "api" | "html" | "websocket"
10
10
  export interface RouteAccess {
11
11
  readonly kind: RouteAccessKind
12
12
  readonly csrfProtected: boolean
13
- /**
14
- * An instance account page every signed-in user needs, whichever web app they may open: approving
15
- * a CLI login. Application access does not gate it.
16
- */
17
- readonly account?: true
18
13
  }
19
14
 
20
15
  export function classifyRoute(request: Request): RouteAccess {
@@ -33,11 +28,7 @@ export function classifyRoute(request: Request): RouteAccess {
33
28
  return { kind: "api", csrfProtected: !isCsrfExemptMethod(request.method) }
34
29
  }
35
30
 
36
- if (pathname === "/auth/device") {
37
- return { kind: "html", csrfProtected: !isCsrfExemptMethod(request.method), account: true }
38
- }
39
-
40
- if (pathname === "/docs" || pathname.startsWith("/docs/")) {
31
+ if (pathname === "/auth/device" || pathname === "/docs" || pathname.startsWith("/docs/")) {
41
32
  return { kind: "html", csrfProtected: !isCsrfExemptMethod(request.method) }
42
33
  }
43
34
 
@@ -1,4 +1,3 @@
1
- import type { AuthSessionAudience } from "@sixb/core"
2
1
  import { returnToForRequest } from "./return-to"
3
2
 
4
3
  export function jsonAuthRequiredResponse(): Response {
@@ -17,7 +16,6 @@ export function htmlAuthRedirectResponse(
17
16
  request: Request,
18
17
  options: {
19
18
  readonly absoluteReturnTo?: boolean
20
- readonly audience?: AuthSessionAudience
21
19
  } = {}
22
20
  ): Response {
23
21
  const requestUrl = new URL(request.url)
@@ -25,9 +23,6 @@ export function htmlAuthRedirectResponse(
25
23
  ? new URL(returnToForRequest(request), requestUrl.origin).toString()
26
24
  : returnToForRequest(request)
27
25
  const params = new URLSearchParams({ returnTo: rawReturnTo })
28
- if (options.absoluteReturnTo && options.audience) {
29
- params.set("audience", options.audience)
30
- }
31
26
 
32
27
  return new Response(null, {
33
28
  status: 302,
@@ -13,9 +13,7 @@ export function createSessionRenewalCookieHeaders(input: {
13
13
  readonly session: AuthenticatedAuthSession
14
14
  readonly csrfToken?: string
15
15
  }): { readonly csrfToken: string; readonly headers: readonly [string, string] } | null {
16
- const cookieOptions = input.host.auth.getCookieOptions({
17
- audience: input.session.session.audience,
18
- })
16
+ const cookieOptions = input.host.auth.getCookieOptions()
19
17
  const sessionValue = getCookie(input.request, cookieOptions.sessionCookieName)
20
18
  if (!sessionValue) {
21
19
  return null
@@ -299,7 +299,7 @@ export function isSharedAccessPublicPath(pathname: string, requestMethod: string
299
299
  /**
300
300
  * The header selects the grant. File GET/HEAD routes also accept the selector in the query, because
301
301
  * `<img>`, `<video>`, and download links cannot send headers. Either way it only names which
302
- * grant cookie to read; the HttpOnly cookie remains the credential, as with a file `audience`.
302
+ * grant cookie to read; the HttpOnly cookie remains the credential.
303
303
  */
304
304
  function selectSharedAccessGrant(request: Request): SharedAccessGrantSelection {
305
305
  const header = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME)
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { SixbApiBrowserPolicy, SixbBrowserOrigin } from "./auth/browser-origin"
1
+ export type { SixbApiBrowserPolicy } from "./auth/browser-origin"
2
2
  export type { SixbAuthExperienceOptions } from "./auth/experience"
3
3
  export type { SixbSharedAccessOptions } from "./auth/shared-access"
4
4
  export { createSixbServer, SixbServer, type SixbServerOptions } from "./server"