@absolutejs/auth 0.55.5 → 0.55.6

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 (53) hide show
  1. package/README.md +6 -1
  2. package/dist/agents/context.d.ts +8 -8
  3. package/dist/agents/index.js +36 -6
  4. package/dist/agents/index.js.map +6 -5
  5. package/dist/agents/routes.d.ts +134 -27
  6. package/dist/apikeys/routes.d.ts +2 -2
  7. package/dist/authContext.d.ts +193 -0
  8. package/dist/authorization/protectPermission.d.ts +4 -4
  9. package/dist/compliance/routes.d.ts +2 -2
  10. package/dist/credentials/login.d.ts +6 -6
  11. package/dist/credentials/register.d.ts +2 -2
  12. package/dist/credentials/routes.d.ts +6 -6
  13. package/dist/htmx/configuredRoutes.d.ts +542 -0
  14. package/dist/htmx/routes.d.ts +4 -4
  15. package/dist/index.d.ts +3399 -8
  16. package/dist/index.js +658 -508
  17. package/dist/index.js.map +15 -12
  18. package/dist/mfa/challenge.d.ts +2 -2
  19. package/dist/mfa/management.d.ts +2 -2
  20. package/dist/mfa/routes.d.ts +4 -4
  21. package/dist/mfa/sms.d.ts +4 -4
  22. package/dist/mfa/totp.d.ts +2 -2
  23. package/dist/oidc/routes.d.ts +14 -14
  24. package/dist/organizations/routes.d.ts +4 -3
  25. package/dist/passwordless/routes.d.ts +7 -6
  26. package/dist/pluginIdentity.d.ts +2 -0
  27. package/dist/portal/routes.d.ts +3 -3
  28. package/dist/roles/routes.d.ts +4 -3
  29. package/dist/routes/callback.d.ts +2 -2
  30. package/dist/routes/profile.d.ts +2 -2
  31. package/dist/routes/protectRoute.d.ts +6 -6
  32. package/dist/routes/refresh.d.ts +3 -3
  33. package/dist/routes/revoke.d.ts +3 -3
  34. package/dist/routes/sessions.d.ts +5 -5
  35. package/dist/routes/signout.d.ts +3 -3
  36. package/dist/routes/stepUp.d.ts +4 -4
  37. package/dist/routes/userStatus.d.ts +2 -2
  38. package/dist/server.d.ts +6 -6
  39. package/dist/server.js +657 -508
  40. package/dist/server.js.map +16 -13
  41. package/dist/session/access.d.ts +3 -3
  42. package/dist/session/cleanup.d.ts +3 -3
  43. package/dist/session/state.d.ts +3 -3
  44. package/dist/session/types.d.ts +1 -0
  45. package/dist/sso/discoveryRoute.d.ts +1 -1
  46. package/dist/sso/oidcRoutes.d.ts +4 -4
  47. package/dist/sso/samlIdpRoutes.d.ts +3 -3
  48. package/dist/sso/samlRoutes.d.ts +7 -6
  49. package/dist/webauthn/routes.d.ts +2 -2
  50. package/package.json +1 -1
  51. package/dist/authInstance.d.ts +0 -7
  52. package/dist/serverConfig.d.ts +0 -10
  53. package/dist/session/internalData.d.ts +0 -34
package/dist/index.js CHANGED
@@ -2824,7 +2824,7 @@ var createCustomOAuth2Client = (providerConfig, credentials) => buildOAuth2Clien
2824
2824
  var createOAuth2Client = (providerName, config) => buildOAuth2Client(providers[providerName], config);
2825
2825
 
2826
2826
  // src/index.ts
2827
- import { Elysia as Elysia42 } from "elysia";
2827
+ import { Elysia as Elysia45 } from "elysia";
2828
2828
 
2829
2829
  // src/apikeys/routes.ts
2830
2830
  import { Elysia, t } from "elysia";
@@ -3044,6 +3044,24 @@ var apiKeysRoutes = ({
3044
3044
  });
3045
3045
  };
3046
3046
 
3047
+ // src/agents/routes.ts
3048
+ import { Elysia as Elysia3 } from "elysia";
3049
+
3050
+ // src/pluginIdentity.ts
3051
+ var dependencyIds = new WeakMap;
3052
+ var nextDependencyId = 1;
3053
+ var pluginDependencySeed = (dependency) => {
3054
+ if (dependency === undefined)
3055
+ return "default";
3056
+ const existing = dependencyIds.get(dependency);
3057
+ if (existing !== undefined)
3058
+ return existing;
3059
+ const identity = nextDependencyId;
3060
+ nextDependencyId += 1;
3061
+ dependencyIds.set(dependency, identity);
3062
+ return identity;
3063
+ };
3064
+
3047
3065
  // src/agents/config.ts
3048
3066
  var DEFAULT_AGENT_RESOURCE_METADATA_ROUTE = "/.well-known/oauth-protected-resource";
3049
3067
  var agentProtectedResourceMetadata = (config) => ({
@@ -3155,14 +3173,19 @@ var failureResponse = (config, failure, requiredScopes) => new Response(JSON.str
3155
3173
  },
3156
3174
  status: failure.code === "Forbidden" ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED2
3157
3175
  });
3158
- var agentAuthContextPlugin = (config) => new Elysia2().derive(({ request }) => ({
3176
+ var agentAuthContextPlugin = (config) => new Elysia2({
3177
+ name: "@absolutejs/auth/agent-context",
3178
+ seed: pluginDependencySeed(config)
3179
+ }).derive(({ request }) => ({
3159
3180
  protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
3160
3181
  if (config === undefined) {
3161
3182
  const failure = {
3162
3183
  code: "Unauthorized",
3163
3184
  message: "Agent is not authenticated"
3164
3185
  };
3165
- return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: HTTP_UNAUTHORIZED2 });
3186
+ return await handleAuthFail?.(failure) ?? new Response(failure.message, {
3187
+ status: HTTP_UNAUTHORIZED2
3188
+ });
3166
3189
  }
3167
3190
  const principal = await resolveAgentPrincipal(request, config);
3168
3191
  if (principal === undefined) {
@@ -3181,7 +3204,7 @@ var agentAuthContextPlugin = (config) => new Elysia2().derive(({ request }) => (
3181
3204
  }
3182
3205
  return handleAuth(principal);
3183
3206
  }
3184
- }));
3207
+ })).as("global");
3185
3208
 
3186
3209
  // src/agents/registration.ts
3187
3210
  init_constants();
@@ -3915,8 +3938,15 @@ var parseRegistrationInput = (value) => {
3915
3938
  return input;
3916
3939
  };
3917
3940
  var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
3918
- var agentAuthPlugin = (config) => {
3919
- const plugin = agentAuthContextPlugin(config);
3941
+ var agentAuthPlugin = (config) => new Elysia3({
3942
+ name: "@absolutejs/auth/agent",
3943
+ seed: pluginDependencySeed(config)
3944
+ }).use(agentAuthContextPlugin(config)).use(agentAuthRoutes(config)).as("global");
3945
+ var agentAuthRoutes = (config) => {
3946
+ const plugin = new Elysia3({
3947
+ name: "@absolutejs/auth/agent-routes",
3948
+ seed: pluginDependencySeed(config)
3949
+ });
3920
3950
  if (config === undefined)
3921
3951
  return plugin.as("global");
3922
3952
  if (config.agentRegistration === undefined) {
@@ -4109,8 +4139,11 @@ var composeSignOutAudit = (onSignOut, emit) => async (context) => {
4109
4139
  return onSignOut?.(context);
4110
4140
  };
4111
4141
 
4142
+ // src/authContext.ts
4143
+ import { Elysia as Elysia8 } from "elysia";
4144
+
4112
4145
  // src/authorization/protectPermission.ts
4113
- import { Elysia as Elysia4, t as t3 } from "elysia";
4146
+ import { Elysia as Elysia5, t as t3 } from "elysia";
4114
4147
 
4115
4148
  // src/session/access.ts
4116
4149
  var collectSessionEntries = (session) => Object.entries(session).filter((entry) => isUserSessionId(entry[0]));
@@ -4224,11 +4257,11 @@ var loadSessionFromSource = async ({
4224
4257
  };
4225
4258
 
4226
4259
  // src/session/state.ts
4227
- import { Elysia as Elysia3 } from "elysia";
4260
+ import { Elysia as Elysia4 } from "elysia";
4228
4261
  var sessionStore = () => {
4229
4262
  const initialSession = {};
4230
4263
  const initialUnregisteredSession = {};
4231
- return new Elysia3({ name: "sessionStore" }).state({
4264
+ return new Elysia4({ name: "sessionStore" }).state({
4232
4265
  session: initialSession,
4233
4266
  unregisteredSession: initialUnregisteredSession
4234
4267
  });
@@ -4250,7 +4283,10 @@ var protectPermissionPlugin = ({
4250
4283
  authSessionStore,
4251
4284
  emit,
4252
4285
  hasPermission
4253
- }) => new Elysia4().use(sessionStore()).guard({ cookie: t3.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
4286
+ }) => new Elysia5({
4287
+ name: "@absolutejs/auth/permission",
4288
+ seed: pluginDependencySeed(hasPermission)
4289
+ }).use(sessionStore()).guard({ cookie: t3.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
4254
4290
  protectPermission: (check, handleAuth, handleAuthFail) => getStatusFromSource({
4255
4291
  authSessionStore,
4256
4292
  session,
@@ -4286,8 +4322,80 @@ var protectPermissionPlugin = ({
4286
4322
  })
4287
4323
  })).as("global");
4288
4324
 
4325
+ // src/routes/protectRoute.ts
4326
+ import { Elysia as Elysia6, t as t4 } from "elysia";
4327
+ var protectRoutePlugin = ({
4328
+ authSessionStore
4329
+ } = {}) => new Elysia6({
4330
+ name: "@absolutejs/auth/protect-route",
4331
+ seed: pluginDependencySeed(authSessionStore)
4332
+ }).use(sessionStore()).guard({ cookie: t4.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
4333
+ protectRoute: (handleAuth, handleAuthFail) => getStatusFromSource({
4334
+ authSessionStore,
4335
+ session,
4336
+ user_session_id
4337
+ }).then(async ({ user, error }) => {
4338
+ if (error) {
4339
+ return handleAuthFail?.(error) ?? status(error.code, error.message);
4340
+ }
4341
+ if (!user) {
4342
+ return handleAuthFail?.({
4343
+ code: "Unauthorized",
4344
+ message: "User is not authenticated"
4345
+ }) ?? status("Unauthorized", "User is not authenticated");
4346
+ }
4347
+ return handleAuth(user);
4348
+ })
4349
+ })).as("global");
4350
+
4351
+ // src/routes/stepUp.ts
4352
+ import { Elysia as Elysia7, t as t5 } from "elysia";
4353
+ var stepUpPlugin = ({
4354
+ authSessionStore
4355
+ } = {}) => new Elysia7({
4356
+ name: "@absolutejs/auth/step-up",
4357
+ seed: pluginDependencySeed(authSessionStore)
4358
+ }).use(sessionStore()).guard({ cookie: t5.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
4359
+ requireRecentAuth: (maxAgeMs, handleAuth, handleAuthFail) => loadSessionFromSource({
4360
+ authSessionStore,
4361
+ session,
4362
+ userSessionId: user_session_id.value
4363
+ }).then((userSession) => {
4364
+ const authenticatedAt = userSession?.authenticatedAt;
4365
+ const isRecent = authenticatedAt !== undefined && Date.now() - authenticatedAt <= maxAgeMs;
4366
+ if (!userSession || !isRecent) {
4367
+ return handleAuthFail?.({
4368
+ code: "Unauthorized",
4369
+ message: "Recent authentication required"
4370
+ }) ?? status("Unauthorized", "Recent authentication required");
4371
+ }
4372
+ return handleAuth(userSession.user);
4373
+ })
4374
+ })).as("global");
4375
+
4376
+ // src/authContext.ts
4377
+ var createAuthContext = ({
4378
+ agentAuth,
4379
+ authSessionStore,
4380
+ authorization,
4381
+ emit,
4382
+ seedSource
4383
+ }) => new Elysia8({
4384
+ name: "@absolutejs/auth/context",
4385
+ seed: pluginDependencySeed(seedSource)
4386
+ }).use([
4387
+ protectRoutePlugin({ authSessionStore }),
4388
+ stepUpPlugin({ authSessionStore }),
4389
+ authorization ? protectPermissionPlugin({
4390
+ ...authorization,
4391
+ authSessionStore,
4392
+ emit
4393
+ }) : new Elysia8,
4394
+ agentAuthContextPlugin(agentAuth)
4395
+ ]);
4396
+
4289
4397
  // src/compliance/routes.ts
4290
- import { Elysia as Elysia5, t as t4 } from "elysia";
4398
+ import { Elysia as Elysia9, t as t6 } from "elysia";
4291
4399
 
4292
4400
  // src/utils.ts
4293
4401
  init_constants();
@@ -4618,7 +4726,7 @@ var complianceRoutes = ({
4618
4726
  emit,
4619
4727
  exportUserData,
4620
4728
  getUserId
4621
- }) => new Elysia5().use(sessionStore()).get(`${complianceRoute}/export`, async ({
4729
+ }) => new Elysia9().use(sessionStore()).get(`${complianceRoute}/export`, async ({
4622
4730
  cookie: { user_session_id },
4623
4731
  status,
4624
4732
  store: { session }
@@ -4638,7 +4746,7 @@ var complianceRoutes = ({
4638
4746
  userId: getUserId?.(current.user)
4639
4747
  });
4640
4748
  return status("OK", data);
4641
- }, { cookie: t4.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(complianceRoute, async ({
4749
+ }, { cookie: t6.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(complianceRoute, async ({
4642
4750
  cookie: { user_session_id },
4643
4751
  status,
4644
4752
  store: { session }
@@ -4671,14 +4779,14 @@ var complianceRoutes = ({
4671
4779
  userId
4672
4780
  });
4673
4781
  return status("OK", { deleted: true });
4674
- }, { cookie: t4.Cookie({ user_session_id: userSessionIdTypebox }) });
4782
+ }, { cookie: t6.Cookie({ user_session_id: userSessionIdTypebox }) });
4675
4783
 
4676
4784
  // src/credentials/routes.ts
4677
- import { Elysia as Elysia10 } from "elysia";
4785
+ import { Elysia as Elysia14 } from "elysia";
4678
4786
 
4679
4787
  // src/credentials/emailVerification.ts
4680
4788
  init_crypto();
4681
- import { Elysia as Elysia6, t as t5 } from "elysia";
4789
+ import { Elysia as Elysia10, t as t7 } from "elysia";
4682
4790
 
4683
4791
  // src/credentials/config.ts
4684
4792
  init_constants();
@@ -4693,7 +4801,7 @@ var credentialsEmailVerification = ({
4693
4801
  onSendEmail,
4694
4802
  verificationTokenDurationMs = DEFAULT_VERIFICATION_TOKEN_TTL_MS,
4695
4803
  verifyEmailRoute = "/auth/verify-email"
4696
- }) => new Elysia6().post(verifyEmailRoute, async ({ body: { token }, status }) => {
4804
+ }) => new Elysia10().post(verifyEmailRoute, async ({ body: { token }, status }) => {
4697
4805
  const consumed = await credentialStore.consumeVerificationToken(await hashToken(token));
4698
4806
  if (!consumed) {
4699
4807
  return status("Bad Request", "Invalid or expired verification token");
@@ -4701,7 +4809,7 @@ var credentialsEmailVerification = ({
4701
4809
  await credentialStore.setEmailVerified(consumed.email);
4702
4810
  await onEmailVerified?.({ email: consumed.email });
4703
4811
  return status("OK", { status: "email_verified" });
4704
- }, { body: t5.Object({ token: t5.String() }) }).post(`${verifyEmailRoute}/request`, async ({ body: { email }, status }) => {
4812
+ }, { body: t7.Object({ token: t7.String() }) }).post(`${verifyEmailRoute}/request`, async ({ body: { email }, status }) => {
4705
4813
  const normalizedEmail = email.trim().toLowerCase();
4706
4814
  const credential = await credentialStore.getCredentialByEmail(normalizedEmail);
4707
4815
  if (credential && !credential.emailVerified) {
@@ -4720,12 +4828,12 @@ var credentialsEmailVerification = ({
4720
4828
  });
4721
4829
  }
4722
4830
  return status("OK", { status: "verification_requested" });
4723
- }, { body: t5.Object({ email: t5.String() }) });
4831
+ }, { body: t7.Object({ email: t7.String() }) });
4724
4832
 
4725
4833
  // src/credentials/login.ts
4726
4834
  init_constants();
4727
4835
  init_crypto();
4728
- import { Elysia as Elysia7, t as t6 } from "elysia";
4836
+ import { Elysia as Elysia11, t as t8 } from "elysia";
4729
4837
 
4730
4838
  // src/credentials/import.ts
4731
4839
  init_crypto();
@@ -4923,7 +5031,7 @@ var credentialsLogin = ({
4923
5031
  rehashOnLogin = false,
4924
5032
  requireEmailVerification = false,
4925
5033
  sessionDurationMs = DEFAULT_CREDENTIAL_SESSION_TTL_MS
4926
- }) => new Elysia7().use(sessionStore()).post(loginRoute, async ({
5034
+ }) => new Elysia11().use(sessionStore()).post(loginRoute, async ({
4927
5035
  body: { email, password },
4928
5036
  cookie: { user_session_id },
4929
5037
  request,
@@ -5006,13 +5114,13 @@ var credentialsLogin = ({
5006
5114
  status: "authenticated"
5007
5115
  });
5008
5116
  }), {
5009
- body: t6.Object({ email: t6.String(), password: t6.String() }),
5010
- cookie: t6.Cookie({ user_session_id: userSessionIdTypebox })
5117
+ body: t8.Object({ email: t8.String(), password: t8.String() }),
5118
+ cookie: t8.Cookie({ user_session_id: userSessionIdTypebox })
5011
5119
  });
5012
5120
 
5013
5121
  // src/credentials/passwordReset.ts
5014
5122
  init_crypto();
5015
- import { Elysia as Elysia8, t as t7 } from "elysia";
5123
+ import { Elysia as Elysia12, t as t9 } from "elysia";
5016
5124
  var credentialsPasswordReset = ({
5017
5125
  credentialStore,
5018
5126
  onPasswordReset,
@@ -5020,7 +5128,7 @@ var credentialsPasswordReset = ({
5020
5128
  passwordPolicy,
5021
5129
  resetPasswordRoute = "/auth/reset-password",
5022
5130
  resetTokenDurationMs = DEFAULT_RESET_TOKEN_TTL_MS
5023
- }) => new Elysia8().post(`${resetPasswordRoute}/request`, async ({ body: { email }, status }) => {
5131
+ }) => new Elysia12().post(`${resetPasswordRoute}/request`, async ({ body: { email }, status }) => {
5024
5132
  const normalizedEmail = email.trim().toLowerCase();
5025
5133
  const credential = await credentialStore.getCredentialByEmail(normalizedEmail);
5026
5134
  if (credential && credential.status === "active") {
@@ -5039,7 +5147,7 @@ var credentialsPasswordReset = ({
5039
5147
  });
5040
5148
  }
5041
5149
  return status("OK", { status: "reset_requested" });
5042
- }, { body: t7.Object({ email: t7.String() }) }).post(resetPasswordRoute, async ({ body: { password, token }, status }) => {
5150
+ }, { body: t9.Object({ email: t9.String() }) }).post(resetPasswordRoute, async ({ body: { password, token }, status }) => {
5043
5151
  const consumed = await credentialStore.consumeResetToken(await hashToken(token));
5044
5152
  if (!consumed) {
5045
5153
  return status("Bad Request", "Invalid or expired reset token");
@@ -5066,12 +5174,12 @@ var credentialsPasswordReset = ({
5066
5174
  await onPasswordReset?.({ email: consumed.email });
5067
5175
  return status("OK", { status: "password_reset" });
5068
5176
  }, {
5069
- body: t7.Object({ password: t7.String(), token: t7.String() })
5177
+ body: t9.Object({ password: t9.String(), token: t9.String() })
5070
5178
  });
5071
5179
 
5072
5180
  // src/credentials/register.ts
5073
5181
  init_crypto();
5074
- import { Elysia as Elysia9, t as t8 } from "elysia";
5182
+ import { Elysia as Elysia13, t as t10 } from "elysia";
5075
5183
  var credentialsRegister = ({
5076
5184
  authSessionStore,
5077
5185
  cookieSecure,
@@ -5085,7 +5193,7 @@ var credentialsRegister = ({
5085
5193
  requireEmailVerification = false,
5086
5194
  sessionDurationMs = DEFAULT_CREDENTIAL_SESSION_TTL_MS,
5087
5195
  verificationTokenDurationMs = DEFAULT_VERIFICATION_TOKEN_TTL_MS
5088
- }) => new Elysia9().use(sessionStore()).post(registerRoute, async ({
5196
+ }) => new Elysia13().use(sessionStore()).post(registerRoute, async ({
5089
5197
  body: { email, password, ...extraFields },
5090
5198
  cookie: { user_session_id },
5091
5199
  status,
@@ -5158,38 +5266,18 @@ var credentialsRegister = ({
5158
5266
  });
5159
5267
  return status("Created", { status: "authenticated" });
5160
5268
  }), {
5161
- body: t8.Object({ email: t8.String(), password: t8.String() }, { additionalProperties: true }),
5162
- cookie: t8.Cookie({ user_session_id: userSessionIdTypebox })
5269
+ body: t10.Object({ email: t10.String(), password: t10.String() }, { additionalProperties: true }),
5270
+ cookie: t10.Cookie({ user_session_id: userSessionIdTypebox })
5163
5271
  });
5164
5272
 
5165
5273
  // src/credentials/routes.ts
5166
- var credentialRoutes = (config) => new Elysia10().use(credentialsRegister(config)).use(credentialsEmailVerification(config)).use(credentialsLogin(config)).use(credentialsPasswordReset(config));
5274
+ var credentialRoutes = (config) => new Elysia14().use(credentialsRegister(config)).use(credentialsEmailVerification(config)).use(credentialsLogin(config)).use(credentialsPasswordReset(config));
5167
5275
 
5168
- // src/htmx/routes.ts
5169
- import { Elysia as Elysia12 } from "elysia";
5276
+ // src/htmx/configuredRoutes.ts
5277
+ import { Elysia as Elysia16 } from "elysia";
5170
5278
 
5171
- // src/routes/protectRoute.ts
5172
- import { Elysia as Elysia11, t as t9 } from "elysia";
5173
- var protectRoutePlugin = ({
5174
- authSessionStore
5175
- } = {}) => new Elysia11().use(sessionStore()).guard({ cookie: t9.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
5176
- protectRoute: (handleAuth, handleAuthFail) => getStatusFromSource({
5177
- authSessionStore,
5178
- session,
5179
- user_session_id
5180
- }).then(async ({ user, error }) => {
5181
- if (error) {
5182
- return handleAuthFail?.(error) ?? status(error.code, error.message);
5183
- }
5184
- if (!user) {
5185
- return handleAuthFail?.({
5186
- code: "Unauthorized",
5187
- message: "User is not authenticated"
5188
- }) ?? status("Unauthorized", "User is not authenticated");
5189
- }
5190
- return handleAuth(user);
5191
- })
5192
- })).as("global");
5279
+ // src/htmx/routes.ts
5280
+ import { Elysia as Elysia15 } from "elysia";
5193
5281
 
5194
5282
  // src/htmx/renderers.ts
5195
5283
  var escapeHtml2 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
@@ -5281,7 +5369,7 @@ var signInPrompt = `<section class="auth-content"><h1 class="page-heading">Not a
5281
5369
  var createAuthHtmxRoutes = (config) => {
5282
5370
  const renderers = resolveAuthHtmxRenderers(config);
5283
5371
  const authorizationHref = config.authorizationHref ?? ((provider) => `/oauth2/${provider}/authorization`);
5284
- return new Elysia12().use(protectRoutePlugin({
5372
+ return new Elysia15().use(protectRoutePlugin({
5285
5373
  authSessionStore: config.authSessionStore
5286
5374
  })).get("/htmx/login", () => html(renderers.providerLogin("Sign in with", true))).get("/htmx/link", () => html(renderers.providerLogin("Link", false))).get("/htmx/connector-links", () => html(renderers.connectorLinks())).get("/htmx/auth-menu", ({ protectRoute }) => protectRoute((user) => html(renderers.authMenu(user)), () => html(renderers.authMenu(null)))).get("/htmx/me", ({ protectRoute }) => protectRoute((user) => html(renderers.protected(user)), () => html(signInPrompt))).get("/htmx/account", ({ protectRoute }) => protectRoute((user) => html(renderers.account(user)), () => html(signInPrompt))).get("/htmx/identities", ({ protectRoute, query }) => protectRoute(async (user) => {
5287
5375
  const search = typeof query.query === "string" ? query.query : "";
@@ -5352,6 +5440,39 @@ var createAuthHtmxRoutes = (config) => {
5352
5440
  });
5353
5441
  };
5354
5442
 
5443
+ // src/htmx/configuredRoutes.ts
5444
+ var isNullableString = (value) => value === undefined || value === null || typeof value === "string";
5445
+ var isAuthHtmxUser = (value) => {
5446
+ if (typeof value !== "object" || value === null)
5447
+ return false;
5448
+ return typeof Reflect.get(value, "sub") === "string" && isNullableString(Reflect.get(value, "email")) && isNullableString(Reflect.get(value, "first_name")) && isNullableString(Reflect.get(value, "last_name")) && isNullableString(Reflect.get(value, "primary_auth_identity_id"));
5449
+ };
5450
+ var htmxSessionSource = (store) => {
5451
+ if (store === undefined)
5452
+ return;
5453
+ return {
5454
+ getSession: async (id) => {
5455
+ const session = await store.getSession(id);
5456
+ if (session === undefined || !isAuthHtmxUser(session.user)) {
5457
+ return;
5458
+ }
5459
+ const result = {
5460
+ ...session,
5461
+ user: session.user
5462
+ };
5463
+ return result;
5464
+ },
5465
+ removeSession: (id) => store.removeSession(id)
5466
+ };
5467
+ };
5468
+ var createConfiguredAuthHtmxRoutes = ({
5469
+ authSessionStore,
5470
+ config
5471
+ }) => config === undefined ? new Elysia16 : createAuthHtmxRoutes({
5472
+ ...config,
5473
+ authSessionStore: htmxSessionSource(authSessionStore)
5474
+ });
5475
+
5355
5476
  // src/lockout/config.ts
5356
5477
  init_constants();
5357
5478
  var DEFAULT_MAX_ATTEMPTS = 5;
@@ -5387,11 +5508,11 @@ var isMfaEnrolled = (enrollment) => enrollment !== undefined && (enrollment.totp
5387
5508
  var createMfaGate = ({ getUserId, mfaStore }) => async (user) => isMfaEnrolled(await mfaStore.getEnrollment(getUserId(user)));
5388
5509
 
5389
5510
  // src/mfa/routes.ts
5390
- import { Elysia as Elysia17 } from "elysia";
5511
+ import { Elysia as Elysia21 } from "elysia";
5391
5512
 
5392
5513
  // src/mfa/challenge.ts
5393
5514
  init_crypto();
5394
- import { Elysia as Elysia14, t as t11 } from "elysia";
5515
+ import { Elysia as Elysia18, t as t12 } from "elysia";
5395
5516
 
5396
5517
  // src/mfa/backupCodes.ts
5397
5518
  init_crypto();
@@ -5427,7 +5548,7 @@ var encryptTotpSecret = (secret, encryptionKey) => encryptionKey ? encryptSecret
5427
5548
 
5428
5549
  // src/mfa/sms.ts
5429
5550
  init_crypto();
5430
- import { Elysia as Elysia13, t as t10 } from "elysia";
5551
+ import { Elysia as Elysia17, t as t11 } from "elysia";
5431
5552
  var DECIMAL_RADIX2 = 10;
5432
5553
  var MASK_VISIBLE_DIGITS = 4;
5433
5554
  var E164_PATTERN = /^\+[1-9]\d{7,14}$/u;
@@ -5480,7 +5601,7 @@ var mfaSmsRoutes = ({
5480
5601
  smsMaxAttempts = DEFAULT_SMS_MAX_ATTEMPTS,
5481
5602
  smsSetupRoute = "/auth/mfa/sms/setup",
5482
5603
  smsVerifyRoute = "/auth/mfa/sms/verify"
5483
- }) => new Elysia13().use(sessionStore()).post(smsSetupRoute, async ({
5604
+ }) => new Elysia17().use(sessionStore()).post(smsSetupRoute, async ({
5484
5605
  body: { phone },
5485
5606
  cookie: { user_session_id },
5486
5607
  status,
@@ -5520,8 +5641,8 @@ var mfaSmsRoutes = ({
5520
5641
  await onSendSmsCode({ code, expiresAt, phone });
5521
5642
  return status("OK", { phone: maskPhone(phone) });
5522
5643
  }, {
5523
- body: t10.Object({ phone: t10.String() }),
5524
- cookie: t10.Cookie({ user_session_id: userSessionIdTypebox })
5644
+ body: t11.Object({ phone: t11.String() }),
5645
+ cookie: t11.Cookie({ user_session_id: userSessionIdTypebox })
5525
5646
  }).post(smsVerifyRoute, async ({
5526
5647
  body: { code },
5527
5648
  cookie: { user_session_id },
@@ -5567,8 +5688,8 @@ var mfaSmsRoutes = ({
5567
5688
  await onMfaEnrolled?.({ userId });
5568
5689
  return status("OK", { status: "enrolled" });
5569
5690
  }, {
5570
- body: t10.Object({ code: t10.String() }),
5571
- cookie: t10.Cookie({ user_session_id: userSessionIdTypebox })
5691
+ body: t11.Object({ code: t11.String() }),
5692
+ cookie: t11.Cookie({ user_session_id: userSessionIdTypebox })
5572
5693
  });
5573
5694
 
5574
5695
  // src/mfa/challenge.ts
@@ -5588,7 +5709,7 @@ var mfaChallenge = ({
5588
5709
  smsCodeTtlMs = DEFAULT_SMS_CODE_TTL_MS,
5589
5710
  smsMaxAttempts = DEFAULT_SMS_MAX_ATTEMPTS,
5590
5711
  totpMaxAttempts = DEFAULT_TOTP_MAX_ATTEMPTS
5591
- }) => new Elysia14().use(sessionStore()).post(challengeRoute, async ({
5712
+ }) => new Elysia18().use(sessionStore()).post(challengeRoute, async ({
5592
5713
  body: { action, code, factor },
5593
5714
  cookie: { user_session_id },
5594
5715
  status,
@@ -5719,16 +5840,16 @@ var mfaChallenge = ({
5719
5840
  });
5720
5841
  return promote();
5721
5842
  }), {
5722
- body: t11.Object({
5723
- action: t11.Optional(t11.Union([t11.Literal("send"), t11.Literal("verify")])),
5724
- code: t11.Optional(t11.String()),
5725
- factor: t11.Optional(t11.Literal("sms"))
5843
+ body: t12.Object({
5844
+ action: t12.Optional(t12.Union([t12.Literal("send"), t12.Literal("verify")])),
5845
+ code: t12.Optional(t12.String()),
5846
+ factor: t12.Optional(t12.Literal("sms"))
5726
5847
  }),
5727
- cookie: t11.Cookie({ user_session_id: userSessionIdTypebox })
5848
+ cookie: t12.Cookie({ user_session_id: userSessionIdTypebox })
5728
5849
  });
5729
5850
 
5730
5851
  // src/mfa/management.ts
5731
- import { Elysia as Elysia15, t as t12 } from "elysia";
5852
+ import { Elysia as Elysia19, t as t13 } from "elysia";
5732
5853
  var maskPhone2 = (phone) => {
5733
5854
  if (!phone)
5734
5855
  return null;
@@ -5741,7 +5862,7 @@ var mfaManagementRoutes = ({
5741
5862
  getUserId,
5742
5863
  managementRoute = "/auth/mfa",
5743
5864
  mfaStore
5744
- }) => new Elysia15().use(sessionStore()).get(managementRoute, async ({
5865
+ }) => new Elysia19().use(sessionStore()).get(managementRoute, async ({
5745
5866
  cookie: { user_session_id },
5746
5867
  status,
5747
5868
  store: { session }
@@ -5765,7 +5886,7 @@ var mfaManagementRoutes = ({
5765
5886
  totp: { enabled: enrollment?.totpVerified ?? false }
5766
5887
  };
5767
5888
  return status("OK", response);
5768
- }, { cookie: t12.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(managementRoute, async ({
5889
+ }, { cookie: t13.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(managementRoute, async ({
5769
5890
  cookie: { user_session_id },
5770
5891
  status,
5771
5892
  store: { session }
@@ -5780,11 +5901,11 @@ var mfaManagementRoutes = ({
5780
5901
  }
5781
5902
  await mfaStore.removeEnrollment(getUserId(userSession.user));
5782
5903
  return status("OK", { status: "disabled" });
5783
- }, { cookie: t12.Cookie({ user_session_id: userSessionIdTypebox }) });
5904
+ }, { cookie: t13.Cookie({ user_session_id: userSessionIdTypebox }) });
5784
5905
 
5785
5906
  // src/mfa/totp.ts
5786
5907
  init_crypto();
5787
- import { Elysia as Elysia16, t as t13 } from "elysia";
5908
+ import { Elysia as Elysia20, t as t14 } from "elysia";
5788
5909
  var mfaTotpRoutes = ({
5789
5910
  authSessionStore,
5790
5911
  backupCodeCount = DEFAULT_BACKUP_CODE_COUNT,
@@ -5795,7 +5916,7 @@ var mfaTotpRoutes = ({
5795
5916
  onMfaEnrolled,
5796
5917
  totpSetupRoute = "/auth/mfa/totp/setup",
5797
5918
  totpVerifyRoute = "/auth/mfa/totp/verify"
5798
- }) => new Elysia16().use(sessionStore()).post(totpSetupRoute, async ({
5919
+ }) => new Elysia20().use(sessionStore()).post(totpSetupRoute, async ({
5799
5920
  cookie: { user_session_id },
5800
5921
  status,
5801
5922
  store: { session }
@@ -5833,7 +5954,7 @@ var mfaTotpRoutes = ({
5833
5954
  secret
5834
5955
  })
5835
5956
  });
5836
- }, { cookie: t13.Cookie({ user_session_id: userSessionIdTypebox }) }).post(totpVerifyRoute, async ({
5957
+ }, { cookie: t14.Cookie({ user_session_id: userSessionIdTypebox }) }).post(totpVerifyRoute, async ({
5837
5958
  body: { code },
5838
5959
  cookie: { user_session_id },
5839
5960
  status,
@@ -5867,17 +5988,17 @@ var mfaTotpRoutes = ({
5867
5988
  await onMfaEnrolled?.({ userId });
5868
5989
  return status("OK", { backupCodes: codes });
5869
5990
  }, {
5870
- body: t13.Object({ code: t13.String() }),
5871
- cookie: t13.Cookie({ user_session_id: userSessionIdTypebox })
5991
+ body: t14.Object({ code: t14.String() }),
5992
+ cookie: t14.Cookie({ user_session_id: userSessionIdTypebox })
5872
5993
  });
5873
5994
 
5874
5995
  // src/mfa/routes.ts
5875
- var mfaRoutes = (config) => new Elysia17().use(mfaManagementRoutes(config)).use(mfaTotpRoutes(config)).use(mfaSmsRoutes(config)).use(mfaChallenge(config));
5996
+ var mfaRoutes = (config) => new Elysia21().use(mfaManagementRoutes(config)).use(mfaTotpRoutes(config)).use(mfaSmsRoutes(config)).use(mfaChallenge(config));
5876
5997
 
5877
5998
  // src/oidc/routes.ts
5878
5999
  init_constants();
5879
6000
  init_crypto();
5880
- import { Elysia as Elysia18, t as t14 } from "elysia";
6001
+ import { Elysia as Elysia22, t as t15 } from "elysia";
5881
6002
 
5882
6003
  // src/oidc/config.ts
5883
6004
  init_constants();
@@ -7916,7 +8037,7 @@ var oidcProviderRoutes = (config) => {
7916
8037
  url.searchParams.set("state", query.state);
7917
8038
  return redirectTo(url.toString());
7918
8039
  };
7919
- return new Elysia18().use(sessionStore()).get(authorizeRoute, async ({
8040
+ return new Elysia22().use(sessionStore()).get(authorizeRoute, async ({
7920
8041
  cookie: { user_session_id },
7921
8042
  query,
7922
8043
  request,
@@ -8071,26 +8192,26 @@ var oidcProviderRoutes = (config) => {
8071
8192
  params.state = state;
8072
8193
  return respondToClient(redirectUri, responseMode, params);
8073
8194
  }, {
8074
- cookie: t14.Cookie({
8075
- user_session_id: t14.Optional(userSessionIdTypebox)
8195
+ cookie: t15.Cookie({
8196
+ user_session_id: t15.Optional(userSessionIdTypebox)
8076
8197
  }),
8077
- query: t14.Object({
8078
- acr_values: t14.Optional(t14.String()),
8079
- claims: t14.Optional(t14.String()),
8080
- client_id: t14.Optional(t14.String()),
8081
- code_challenge: t14.Optional(t14.String()),
8082
- code_challenge_method: t14.Optional(t14.String()),
8083
- id_token_hint: t14.Optional(t14.String()),
8084
- max_age: t14.Optional(t14.String()),
8085
- nonce: t14.Optional(t14.String()),
8086
- prompt: t14.Optional(t14.String()),
8087
- redirect_uri: t14.Optional(t14.String()),
8088
- request: t14.Optional(t14.String()),
8089
- request_uri: t14.Optional(t14.String()),
8090
- response_mode: t14.Optional(t14.String()),
8091
- response_type: t14.Optional(t14.String()),
8092
- scope: t14.Optional(t14.String()),
8093
- state: t14.Optional(t14.String())
8198
+ query: t15.Object({
8199
+ acr_values: t15.Optional(t15.String()),
8200
+ claims: t15.Optional(t15.String()),
8201
+ client_id: t15.Optional(t15.String()),
8202
+ code_challenge: t15.Optional(t15.String()),
8203
+ code_challenge_method: t15.Optional(t15.String()),
8204
+ id_token_hint: t15.Optional(t15.String()),
8205
+ max_age: t15.Optional(t15.String()),
8206
+ nonce: t15.Optional(t15.String()),
8207
+ prompt: t15.Optional(t15.String()),
8208
+ redirect_uri: t15.Optional(t15.String()),
8209
+ request: t15.Optional(t15.String()),
8210
+ request_uri: t15.Optional(t15.String()),
8211
+ response_mode: t15.Optional(t15.String()),
8212
+ response_type: t15.Optional(t15.String()),
8213
+ scope: t15.Optional(t15.String()),
8214
+ state: t15.Optional(t15.String())
8094
8215
  })
8095
8216
  }).post(tokenRoute, async ({ body, headers, request }) => {
8096
8217
  if (body.grant_type === PRE_AUTHORIZED_CODE_GRANT && config.vciConfig !== undefined) {
@@ -8157,26 +8278,26 @@ var oidcProviderRoutes = (config) => {
8157
8278
  }
8158
8279
  return oauthError2(HTTP_BAD_REQUEST3, "unsupported_grant_type");
8159
8280
  }, {
8160
- body: t14.Object({
8161
- assertion: t14.Optional(t14.String()),
8162
- audience: t14.Optional(t14.String()),
8163
- auth_req_id: t14.Optional(t14.String()),
8164
- claim_token: t14.Optional(t14.String()),
8165
- client_assertion: t14.Optional(t14.String()),
8166
- client_assertion_type: t14.Optional(t14.String()),
8167
- client_id: t14.Optional(t14.String()),
8168
- client_secret: t14.Optional(t14.String()),
8169
- code: t14.Optional(t14.String()),
8170
- code_verifier: t14.Optional(t14.String()),
8171
- device_code: t14.Optional(t14.String()),
8172
- grant_type: t14.Optional(t14.String()),
8173
- "pre-authorized_code": t14.Optional(t14.String()),
8174
- redirect_uri: t14.Optional(t14.String()),
8175
- refresh_token: t14.Optional(t14.String()),
8176
- resource: t14.Optional(t14.String()),
8177
- scope: t14.Optional(t14.String()),
8178
- subject_token: t14.Optional(t14.String()),
8179
- subject_token_type: t14.Optional(t14.String())
8281
+ body: t15.Object({
8282
+ assertion: t15.Optional(t15.String()),
8283
+ audience: t15.Optional(t15.String()),
8284
+ auth_req_id: t15.Optional(t15.String()),
8285
+ claim_token: t15.Optional(t15.String()),
8286
+ client_assertion: t15.Optional(t15.String()),
8287
+ client_assertion_type: t15.Optional(t15.String()),
8288
+ client_id: t15.Optional(t15.String()),
8289
+ client_secret: t15.Optional(t15.String()),
8290
+ code: t15.Optional(t15.String()),
8291
+ code_verifier: t15.Optional(t15.String()),
8292
+ device_code: t15.Optional(t15.String()),
8293
+ grant_type: t15.Optional(t15.String()),
8294
+ "pre-authorized_code": t15.Optional(t15.String()),
8295
+ redirect_uri: t15.Optional(t15.String()),
8296
+ refresh_token: t15.Optional(t15.String()),
8297
+ resource: t15.Optional(t15.String()),
8298
+ scope: t15.Optional(t15.String()),
8299
+ subject_token: t15.Optional(t15.String()),
8300
+ subject_token_type: t15.Optional(t15.String())
8180
8301
  })
8181
8302
  }).post(parRoute, async ({ body, headers, request }) => {
8182
8303
  if (config.pushedAuthorizationRequestStore === undefined) {
@@ -8206,25 +8327,25 @@ var oidcProviderRoutes = (config) => {
8206
8327
  });
8207
8328
  return jsonResponse(result.body, result.ok ? HTTP_OK3 : result.status);
8208
8329
  }, {
8209
- body: t14.Object({
8210
- acr_values: t14.Optional(t14.String()),
8211
- audience: t14.Optional(t14.String()),
8212
- claims: t14.Optional(t14.String()),
8213
- client_assertion: t14.Optional(t14.String()),
8214
- client_assertion_type: t14.Optional(t14.String()),
8215
- client_id: t14.Optional(t14.String()),
8216
- client_secret: t14.Optional(t14.String()),
8217
- code_challenge: t14.Optional(t14.String()),
8218
- code_challenge_method: t14.Optional(t14.String()),
8219
- nonce: t14.Optional(t14.String()),
8220
- redirect_uri: t14.Optional(t14.String()),
8221
- resource: t14.Optional(t14.String()),
8222
- response_type: t14.Optional(t14.String()),
8223
- scope: t14.Optional(t14.String()),
8224
- state: t14.Optional(t14.String())
8330
+ body: t15.Object({
8331
+ acr_values: t15.Optional(t15.String()),
8332
+ audience: t15.Optional(t15.String()),
8333
+ claims: t15.Optional(t15.String()),
8334
+ client_assertion: t15.Optional(t15.String()),
8335
+ client_assertion_type: t15.Optional(t15.String()),
8336
+ client_id: t15.Optional(t15.String()),
8337
+ client_secret: t15.Optional(t15.String()),
8338
+ code_challenge: t15.Optional(t15.String()),
8339
+ code_challenge_method: t15.Optional(t15.String()),
8340
+ nonce: t15.Optional(t15.String()),
8341
+ redirect_uri: t15.Optional(t15.String()),
8342
+ resource: t15.Optional(t15.String()),
8343
+ response_type: t15.Optional(t15.String()),
8344
+ scope: t15.Optional(t15.String()),
8345
+ state: t15.Optional(t15.String())
8225
8346
  }),
8226
- headers: t14.Object({
8227
- authorization: t14.Optional(t14.String())
8347
+ headers: t15.Object({
8348
+ authorization: t15.Optional(t15.String())
8228
8349
  })
8229
8350
  }).post(introspectRoute, async ({ body, headers }) => {
8230
8351
  const basic = readBasicAuth2(headers.authorization);
@@ -8245,14 +8366,14 @@ var oidcProviderRoutes = (config) => {
8245
8366
  });
8246
8367
  return jsonResponse(result, HTTP_OK3);
8247
8368
  }, {
8248
- body: t14.Object({
8249
- client_id: t14.Optional(t14.String()),
8250
- client_secret: t14.Optional(t14.String()),
8251
- token: t14.String(),
8252
- token_type_hint: t14.Optional(t14.String())
8369
+ body: t15.Object({
8370
+ client_id: t15.Optional(t15.String()),
8371
+ client_secret: t15.Optional(t15.String()),
8372
+ token: t15.String(),
8373
+ token_type_hint: t15.Optional(t15.String())
8253
8374
  }),
8254
- headers: t14.Object({
8255
- authorization: t14.Optional(t14.String())
8375
+ headers: t15.Object({
8376
+ authorization: t15.Optional(t15.String())
8256
8377
  })
8257
8378
  }).post(revokeRoute, async ({ body, headers }) => {
8258
8379
  const basic = readBasicAuth2(headers.authorization);
@@ -8270,14 +8391,14 @@ var oidcProviderRoutes = (config) => {
8270
8391
  }
8271
8392
  return new Response(null, { status: HTTP_OK3 });
8272
8393
  }, {
8273
- body: t14.Object({
8274
- client_id: t14.Optional(t14.String()),
8275
- client_secret: t14.Optional(t14.String()),
8276
- token: t14.String(),
8277
- token_type_hint: t14.Optional(t14.String())
8394
+ body: t15.Object({
8395
+ client_id: t15.Optional(t15.String()),
8396
+ client_secret: t15.Optional(t15.String()),
8397
+ token: t15.String(),
8398
+ token_type_hint: t15.Optional(t15.String())
8278
8399
  }),
8279
- headers: t14.Object({
8280
- authorization: t14.Optional(t14.String())
8400
+ headers: t15.Object({
8401
+ authorization: t15.Optional(t15.String())
8281
8402
  })
8282
8403
  }).post(backchannelAuthorizationRoute, async ({ body, headers }) => {
8283
8404
  if (config.backchannelAuthStore === undefined) {
@@ -8313,15 +8434,15 @@ var oidcProviderRoutes = (config) => {
8313
8434
  interval: result.interval
8314
8435
  }, HTTP_OK3);
8315
8436
  }, {
8316
- body: t14.Object({
8317
- binding_message: t14.Optional(t14.String()),
8318
- client_id: t14.Optional(t14.String()),
8319
- client_secret: t14.Optional(t14.String()),
8320
- login_hint: t14.Optional(t14.String()),
8321
- scope: t14.Optional(t14.String())
8437
+ body: t15.Object({
8438
+ binding_message: t15.Optional(t15.String()),
8439
+ client_id: t15.Optional(t15.String()),
8440
+ client_secret: t15.Optional(t15.String()),
8441
+ login_hint: t15.Optional(t15.String()),
8442
+ scope: t15.Optional(t15.String())
8322
8443
  }),
8323
- headers: t14.Object({
8324
- authorization: t14.Optional(t14.String())
8444
+ headers: t15.Object({
8445
+ authorization: t15.Optional(t15.String())
8325
8446
  })
8326
8447
  }).post(deviceAuthorizationRoute, async ({ body, headers }) => {
8327
8448
  if (config.deviceAuthorizationStore === undefined) {
@@ -8346,13 +8467,13 @@ var oidcProviderRoutes = (config) => {
8346
8467
  });
8347
8468
  return jsonResponse(response, HTTP_OK3);
8348
8469
  }, {
8349
- body: t14.Object({
8350
- client_id: t14.Optional(t14.String()),
8351
- client_secret: t14.Optional(t14.String()),
8352
- scope: t14.Optional(t14.String())
8470
+ body: t15.Object({
8471
+ client_id: t15.Optional(t15.String()),
8472
+ client_secret: t15.Optional(t15.String()),
8473
+ scope: t15.Optional(t15.String())
8353
8474
  }),
8354
- headers: t14.Object({
8355
- authorization: t14.Optional(t14.String())
8475
+ headers: t15.Object({
8476
+ authorization: t15.Optional(t15.String())
8356
8477
  })
8357
8478
  }).post(deviceApproveRoute, async ({ body, cookie: { user_session_id }, store }) => {
8358
8479
  if (config.deviceAuthorizationStore === undefined) {
@@ -8378,40 +8499,40 @@ var oidcProviderRoutes = (config) => {
8378
8499
  return oauthError2(HTTP_BAD_REQUEST3, result.error);
8379
8500
  return jsonResponse({ ok: true }, HTTP_OK3);
8380
8501
  }, {
8381
- body: t14.Object({
8382
- action: t14.Optional(t14.Union([t14.Literal("approve"), t14.Literal("deny")])),
8383
- user_code: t14.String()
8502
+ body: t15.Object({
8503
+ action: t15.Optional(t15.Union([t15.Literal("approve"), t15.Literal("deny")])),
8504
+ user_code: t15.String()
8384
8505
  }),
8385
- cookie: t14.Cookie({
8386
- user_session_id: t14.Optional(userSessionIdTypebox)
8506
+ cookie: t15.Cookie({
8507
+ user_session_id: t15.Optional(userSessionIdTypebox)
8387
8508
  })
8388
8509
  }).get(endSessionRoute, async ({ cookie: { user_session_id }, query, store }) => handleEndSession({
8389
8510
  cookie: user_session_id,
8390
8511
  inMemorySession: store.session,
8391
8512
  query
8392
8513
  }), {
8393
- cookie: t14.Cookie({
8394
- user_session_id: t14.Optional(userSessionIdTypebox)
8514
+ cookie: t15.Cookie({
8515
+ user_session_id: t15.Optional(userSessionIdTypebox)
8395
8516
  }),
8396
- query: t14.Object({
8397
- client_id: t14.Optional(t14.String()),
8398
- id_token_hint: t14.Optional(t14.String()),
8399
- post_logout_redirect_uri: t14.Optional(t14.String()),
8400
- state: t14.Optional(t14.String())
8517
+ query: t15.Object({
8518
+ client_id: t15.Optional(t15.String()),
8519
+ id_token_hint: t15.Optional(t15.String()),
8520
+ post_logout_redirect_uri: t15.Optional(t15.String()),
8521
+ state: t15.Optional(t15.String())
8401
8522
  })
8402
8523
  }).post(endSessionRoute, async ({ body, cookie: { user_session_id }, store }) => handleEndSession({
8403
8524
  cookie: user_session_id,
8404
8525
  inMemorySession: store.session,
8405
8526
  query: body
8406
8527
  }), {
8407
- body: t14.Object({
8408
- client_id: t14.Optional(t14.String()),
8409
- id_token_hint: t14.Optional(t14.String()),
8410
- post_logout_redirect_uri: t14.Optional(t14.String()),
8411
- state: t14.Optional(t14.String())
8528
+ body: t15.Object({
8529
+ client_id: t15.Optional(t15.String()),
8530
+ id_token_hint: t15.Optional(t15.String()),
8531
+ post_logout_redirect_uri: t15.Optional(t15.String()),
8532
+ state: t15.Optional(t15.String())
8412
8533
  }),
8413
- cookie: t14.Cookie({
8414
- user_session_id: t14.Optional(userSessionIdTypebox)
8534
+ cookie: t15.Cookie({
8535
+ user_session_id: t15.Optional(userSessionIdTypebox)
8415
8536
  })
8416
8537
  }).post(registrationRoute, async ({ body, headers }) => {
8417
8538
  if (config.clientRegistrationTokenStore === undefined) {
@@ -8430,18 +8551,18 @@ var oidcProviderRoutes = (config) => {
8430
8551
  });
8431
8552
  return jsonResponse(result.body, result.ok ? HTTP_OK3 : result.status);
8432
8553
  }, {
8433
- body: t14.Object({
8434
- backchannel_logout_uri: t14.Optional(t14.String()),
8435
- client_name: t14.Optional(t14.String()),
8436
- grant_types: t14.Optional(t14.Array(t14.String())),
8437
- jwks: t14.Optional(t14.Any()),
8438
- jwks_uri: t14.Optional(t14.String()),
8439
- post_logout_redirect_uris: t14.Optional(t14.Array(t14.String())),
8440
- redirect_uris: t14.Optional(t14.Array(t14.String())),
8441
- scope: t14.Optional(t14.String())
8554
+ body: t15.Object({
8555
+ backchannel_logout_uri: t15.Optional(t15.String()),
8556
+ client_name: t15.Optional(t15.String()),
8557
+ grant_types: t15.Optional(t15.Array(t15.String())),
8558
+ jwks: t15.Optional(t15.Any()),
8559
+ jwks_uri: t15.Optional(t15.String()),
8560
+ post_logout_redirect_uris: t15.Optional(t15.Array(t15.String())),
8561
+ redirect_uris: t15.Optional(t15.Array(t15.String())),
8562
+ scope: t15.Optional(t15.String())
8442
8563
  }),
8443
- headers: t14.Object({
8444
- authorization: t14.Optional(t14.String())
8564
+ headers: t15.Object({
8565
+ authorization: t15.Optional(t15.String())
8445
8566
  })
8446
8567
  }).get(`${registrationRoute}/:clientId`, async ({ headers, params: { clientId } }) => {
8447
8568
  if (config.clientRegistrationTokenStore === undefined) {
@@ -8455,10 +8576,10 @@ var oidcProviderRoutes = (config) => {
8455
8576
  });
8456
8577
  return jsonResponse(result.body, result.status);
8457
8578
  }, {
8458
- headers: t14.Object({
8459
- authorization: t14.Optional(t14.String())
8579
+ headers: t15.Object({
8580
+ authorization: t15.Optional(t15.String())
8460
8581
  }),
8461
- params: t14.Object({ clientId: t14.String() })
8582
+ params: t15.Object({ clientId: t15.String() })
8462
8583
  }).put(`${registrationRoute}/:clientId`, async ({ body, headers, params: { clientId } }) => {
8463
8584
  if (config.clientRegistrationTokenStore === undefined) {
8464
8585
  return jsonResponse({ error: "unsupported_response_type" }, HTTP_NOT_IMPLEMENTED);
@@ -8473,20 +8594,20 @@ var oidcProviderRoutes = (config) => {
8473
8594
  });
8474
8595
  return jsonResponse(result.body, result.status);
8475
8596
  }, {
8476
- body: t14.Object({
8477
- backchannel_logout_uri: t14.Optional(t14.String()),
8478
- client_name: t14.Optional(t14.String()),
8479
- grant_types: t14.Optional(t14.Array(t14.String())),
8480
- jwks: t14.Optional(t14.Any()),
8481
- jwks_uri: t14.Optional(t14.String()),
8482
- post_logout_redirect_uris: t14.Optional(t14.Array(t14.String())),
8483
- redirect_uris: t14.Optional(t14.Array(t14.String())),
8484
- scope: t14.Optional(t14.String())
8597
+ body: t15.Object({
8598
+ backchannel_logout_uri: t15.Optional(t15.String()),
8599
+ client_name: t15.Optional(t15.String()),
8600
+ grant_types: t15.Optional(t15.Array(t15.String())),
8601
+ jwks: t15.Optional(t15.Any()),
8602
+ jwks_uri: t15.Optional(t15.String()),
8603
+ post_logout_redirect_uris: t15.Optional(t15.Array(t15.String())),
8604
+ redirect_uris: t15.Optional(t15.Array(t15.String())),
8605
+ scope: t15.Optional(t15.String())
8485
8606
  }),
8486
- headers: t14.Object({
8487
- authorization: t14.Optional(t14.String())
8607
+ headers: t15.Object({
8608
+ authorization: t15.Optional(t15.String())
8488
8609
  }),
8489
- params: t14.Object({ clientId: t14.String() })
8610
+ params: t15.Object({ clientId: t15.String() })
8490
8611
  }).delete(`${registrationRoute}/:clientId`, async ({ headers, params: { clientId } }) => {
8491
8612
  if (config.clientRegistrationTokenStore === undefined) {
8492
8613
  return jsonResponse({ error: "unsupported_response_type" }, HTTP_NOT_IMPLEMENTED);
@@ -8502,10 +8623,10 @@ var oidcProviderRoutes = (config) => {
8502
8623
  }
8503
8624
  return jsonResponse(result.body, result.status);
8504
8625
  }, {
8505
- headers: t14.Object({
8506
- authorization: t14.Optional(t14.String())
8626
+ headers: t15.Object({
8627
+ authorization: t15.Optional(t15.String())
8507
8628
  }),
8508
- params: t14.Object({ clientId: t14.String() })
8629
+ params: t15.Object({ clientId: t15.String() })
8509
8630
  }).get(userinfoRoute, async ({ headers }) => {
8510
8631
  const token = readUserInfoBearer(headers.authorization);
8511
8632
  const result = await fetchUserInfo({ config, token });
@@ -8520,8 +8641,8 @@ var oidcProviderRoutes = (config) => {
8520
8641
  }
8521
8642
  return jsonResponse(result.body, HTTP_OK3);
8522
8643
  }, {
8523
- headers: t14.Object({
8524
- authorization: t14.Optional(t14.String())
8644
+ headers: t15.Object({
8645
+ authorization: t15.Optional(t15.String())
8525
8646
  })
8526
8647
  }).post(userinfoRoute, async ({ headers, body }) => {
8527
8648
  const token = readUserInfoBearer(headers.authorization) ?? body.access_token;
@@ -8537,17 +8658,17 @@ var oidcProviderRoutes = (config) => {
8537
8658
  }
8538
8659
  return jsonResponse(result.body, HTTP_OK3);
8539
8660
  }, {
8540
- body: t14.Object({
8541
- access_token: t14.Optional(t14.String())
8661
+ body: t15.Object({
8662
+ access_token: t15.Optional(t15.String())
8542
8663
  }),
8543
- headers: t14.Object({
8544
- authorization: t14.Optional(t14.String())
8664
+ headers: t15.Object({
8665
+ authorization: t15.Optional(t15.String())
8545
8666
  })
8546
8667
  }).get(jwksRoute, () => ({ keys: [toPublicJwk(signingKey)] })).get("/.well-known/openid-configuration", () => discovery).get("/.well-known/oauth-authorization-server", () => discovery);
8547
8668
  };
8548
8669
 
8549
8670
  // src/organizations/routes.ts
8550
- import { Elysia as Elysia19, t as t15 } from "elysia";
8671
+ import { Elysia as Elysia23, t as t16 } from "elysia";
8551
8672
 
8552
8673
  // src/organizations/config.ts
8553
8674
  init_constants();
@@ -8663,7 +8784,7 @@ var organizationRoutes = ({
8663
8784
  organizationStore,
8664
8785
  ownerRoles
8665
8786
  }) => {
8666
- const cookie = t15.Cookie({ user_session_id: userSessionIdTypebox });
8787
+ const cookie = t16.Cookie({ user_session_id: userSessionIdTypebox });
8667
8788
  const requireUser = async (userSessionId, session) => {
8668
8789
  const current = await loadSessionFromSource({
8669
8790
  authSessionStore,
@@ -8679,7 +8800,7 @@ var organizationRoutes = ({
8679
8800
  }
8680
8801
  return membership?.status === "active";
8681
8802
  };
8682
- return new Elysia19().use(sessionStore()).get(organizationsRoute, async ({
8803
+ return new Elysia23().use(sessionStore()).get(organizationsRoute, async ({
8683
8804
  cookie: { user_session_id },
8684
8805
  status,
8685
8806
  store: { session }
@@ -8726,9 +8847,9 @@ var organizationRoutes = ({
8726
8847
  });
8727
8848
  return status("OK", { organization });
8728
8849
  }, {
8729
- body: t15.Object({
8730
- metadata: t15.Optional(t15.Record(t15.String(), t15.Unknown())),
8731
- name: t15.String()
8850
+ body: t16.Object({
8851
+ metadata: t16.Optional(t16.Record(t16.String(), t16.Unknown())),
8852
+ name: t16.String()
8732
8853
  }),
8733
8854
  cookie
8734
8855
  }).post(`${organizationsRoute}/:organizationId/invitations`, async ({
@@ -8772,12 +8893,12 @@ var organizationRoutes = ({
8772
8893
  token
8773
8894
  });
8774
8895
  }, {
8775
- body: t15.Object({
8776
- email: t15.String(),
8777
- roles: t15.Optional(t15.Array(t15.String()))
8896
+ body: t16.Object({
8897
+ email: t16.String(),
8898
+ roles: t16.Optional(t16.Array(t16.String()))
8778
8899
  }),
8779
8900
  cookie,
8780
- params: t15.Object({ organizationId: t15.String() })
8901
+ params: t16.Object({ organizationId: t16.String() })
8781
8902
  }).get(`${organizationsRoute}/:organizationId/invitations`, async ({
8782
8903
  cookie: { user_session_id },
8783
8904
  params: { organizationId },
@@ -8801,7 +8922,7 @@ var organizationRoutes = ({
8801
8922
  state: invitation.state
8802
8923
  }))
8803
8924
  });
8804
- }, { cookie, params: t15.Object({ organizationId: t15.String() }) }).delete(`${organizationsRoute}/:organizationId/invitations/:invitationId`, async ({
8925
+ }, { cookie, params: t16.Object({ organizationId: t16.String() }) }).delete(`${organizationsRoute}/:organizationId/invitations/:invitationId`, async ({
8805
8926
  cookie: { user_session_id },
8806
8927
  params: { invitationId, organizationId },
8807
8928
  status,
@@ -8825,9 +8946,9 @@ var organizationRoutes = ({
8825
8946
  return status("OK", { revoked: invitationId });
8826
8947
  }, {
8827
8948
  cookie,
8828
- params: t15.Object({
8829
- invitationId: t15.String(),
8830
- organizationId: t15.String()
8949
+ params: t16.Object({
8950
+ invitationId: t16.String(),
8951
+ organizationId: t16.String()
8831
8952
  })
8832
8953
  }).post(`${organizationsRoute}/invitations/accept`, async ({
8833
8954
  body: { token },
@@ -8862,7 +8983,7 @@ var organizationRoutes = ({
8862
8983
  organizationId: membership.organizationId,
8863
8984
  roles: membership.roles
8864
8985
  });
8865
- }, { body: t15.Object({ token: t15.String() }), cookie }).get(`${organizationsRoute}/:organizationId/members`, async ({
8986
+ }, { body: t16.Object({ token: t16.String() }), cookie }).get(`${organizationsRoute}/:organizationId/members`, async ({
8866
8987
  cookie: { user_session_id },
8867
8988
  params: { organizationId },
8868
8989
  status,
@@ -8878,7 +8999,7 @@ var organizationRoutes = ({
8878
8999
  }
8879
9000
  const members = await organizationStore.listMembershipsByOrganization(organizationId);
8880
9001
  return status("OK", { members });
8881
- }, { cookie, params: t15.Object({ organizationId: t15.String() }) }).delete(`${organizationsRoute}/:organizationId/members/:userId`, async ({
9002
+ }, { cookie, params: t16.Object({ organizationId: t16.String() }) }).delete(`${organizationsRoute}/:organizationId/members/:userId`, async ({
8882
9003
  cookie: { user_session_id },
8883
9004
  params: { organizationId, userId },
8884
9005
  status,
@@ -8902,16 +9023,16 @@ var organizationRoutes = ({
8902
9023
  return status("OK", { removed: userId });
8903
9024
  }, {
8904
9025
  cookie,
8905
- params: t15.Object({
8906
- organizationId: t15.String(),
8907
- userId: t15.String()
9026
+ params: t16.Object({
9027
+ organizationId: t16.String(),
9028
+ userId: t16.String()
8908
9029
  })
8909
9030
  });
8910
9031
  };
8911
9032
 
8912
9033
  // src/passwordless/routes.ts
8913
9034
  init_crypto();
8914
- import { Elysia as Elysia20, t as t16 } from "elysia";
9035
+ import { Elysia as Elysia24, t as t17 } from "elysia";
8915
9036
 
8916
9037
  // src/passwordless/config.ts
8917
9038
  init_constants();
@@ -8947,8 +9068,8 @@ var passwordlessRoutes = ({
8947
9068
  passwordlessTokenStore,
8948
9069
  sessionDurationMs = DEFAULT_PASSWORDLESS_SESSION_TTL_MS
8949
9070
  }) => {
8950
- const cookie = t16.Cookie({
8951
- user_session_id: t16.Optional(userSessionIdTypebox)
9071
+ const cookie = t17.Cookie({
9072
+ user_session_id: t17.Optional(userSessionIdTypebox)
8952
9073
  });
8953
9074
  const completeLogin = async (email, userSessionCookie, session) => {
8954
9075
  const existing = await getUserByEmail(email);
@@ -8972,7 +9093,7 @@ var passwordlessRoutes = ({
8972
9093
  await onPasswordlessLogin?.({ user, userSessionId });
8973
9094
  return userSessionId;
8974
9095
  };
8975
- const magicLink = onSendMagicLink ? new Elysia20().use(sessionStore()).post(`${passwordlessRoute}/magic-link`, async ({ body: { email }, status }) => {
9096
+ const magicLink = onSendMagicLink ? new Elysia24().use(sessionStore()).post(`${passwordlessRoute}/magic-link`, async ({ body: { email }, status }) => {
8976
9097
  const normalizedEmail = email.trim().toLowerCase();
8977
9098
  const token = generateSecureToken();
8978
9099
  const expiresAt = Date.now() + magicLinkTokenDurationMs;
@@ -8987,7 +9108,7 @@ var passwordlessRoutes = ({
8987
9108
  token
8988
9109
  });
8989
9110
  return status("OK", { status: "magic_link_sent" });
8990
- }, { body: t16.Object({ email: t16.String() }) }).post(`${passwordlessRoute}/magic-link/verify`, async ({
9111
+ }, { body: t17.Object({ email: t17.String() }) }).post(`${passwordlessRoute}/magic-link/verify`, async ({
8991
9112
  body: { token },
8992
9113
  cookie: { user_session_id },
8993
9114
  status,
@@ -9002,8 +9123,8 @@ var passwordlessRoutes = ({
9002
9123
  return status("Unauthorized", "No account for this email");
9003
9124
  }
9004
9125
  return status("OK", { status: "authenticated" });
9005
- }, { body: t16.Object({ token: t16.String() }), cookie }) : new Elysia20;
9006
- const otp = onSendOtp ? new Elysia20().use(sessionStore()).post(`${passwordlessRoute}/otp`, async ({ body: { email }, status }) => {
9126
+ }, { body: t17.Object({ token: t17.String() }), cookie }) : new Elysia24;
9127
+ const otp = onSendOtp ? new Elysia24().use(sessionStore()).post(`${passwordlessRoute}/otp`, async ({ body: { email }, status }) => {
9007
9128
  const normalizedEmail = email.trim().toLowerCase();
9008
9129
  const code = generateOtpCode(otpLength);
9009
9130
  const expiresAt = Date.now() + otpDurationMs;
@@ -9018,7 +9139,7 @@ var passwordlessRoutes = ({
9018
9139
  expiresAt
9019
9140
  });
9020
9141
  return status("OK", { status: "otp_sent" });
9021
- }, { body: t16.Object({ email: t16.String() }) }).post(`${passwordlessRoute}/otp/verify`, async ({
9142
+ }, { body: t17.Object({ email: t17.String() }) }).post(`${passwordlessRoute}/otp/verify`, async ({
9022
9143
  body: { code, email },
9023
9144
  cookie: { user_session_id },
9024
9145
  status,
@@ -9035,17 +9156,17 @@ var passwordlessRoutes = ({
9035
9156
  }
9036
9157
  return status("OK", { status: "authenticated" });
9037
9158
  }, {
9038
- body: t16.Object({
9039
- code: t16.String(),
9040
- email: t16.String()
9159
+ body: t17.Object({
9160
+ code: t17.String(),
9161
+ email: t17.String()
9041
9162
  }),
9042
9163
  cookie
9043
- }) : new Elysia20;
9044
- return new Elysia20().use(magicLink).use(otp);
9164
+ }) : new Elysia24;
9165
+ return new Elysia24().use(magicLink).use(otp);
9045
9166
  };
9046
9167
 
9047
9168
  // src/portal/routes.ts
9048
- import { Elysia as Elysia21, t as t17 } from "elysia";
9169
+ import { Elysia as Elysia25, t as t18 } from "elysia";
9049
9170
 
9050
9171
  // src/scim/config.ts
9051
9172
  init_crypto();
@@ -9140,7 +9261,7 @@ var portalRoutes = ({
9140
9261
  }) => {
9141
9262
  const loadSession = (authorization) => resolveSetupSession({ authorization, setupSessionStore });
9142
9263
  const oidcRedirectUri = (origin, organizationId) => `${origin}${ssoRoute}/oidc/${organizationId}/callback`;
9143
- return new Elysia21().get(`${portalRoute}/session`, async ({ headers, request, status }) => {
9264
+ return new Elysia25().get(`${portalRoute}/session`, async ({ headers, request, status }) => {
9144
9265
  const session = await loadSession(headers.authorization);
9145
9266
  if (!session) {
9146
9267
  return status("Unauthorized", "Invalid or expired setup link");
@@ -9203,11 +9324,11 @@ var portalRoutes = ({
9203
9324
  });
9204
9325
  return status("OK", { configured: true, type: "saml" });
9205
9326
  }, {
9206
- body: t17.Object({
9207
- idpEntityId: t17.String(),
9208
- idpSloUrl: t17.Optional(t17.String()),
9209
- idpSsoUrl: t17.String(),
9210
- idpX509Cert: t17.String()
9327
+ body: t18.Object({
9328
+ idpEntityId: t18.String(),
9329
+ idpSloUrl: t18.Optional(t18.String()),
9330
+ idpSsoUrl: t18.String(),
9331
+ idpX509Cert: t18.String()
9211
9332
  })
9212
9333
  }).put(`${portalRoute}/connection/oidc`, async ({ body, headers, request, status }) => {
9213
9334
  const session = await loadSession(headers.authorization);
@@ -9251,12 +9372,12 @@ var portalRoutes = ({
9251
9372
  });
9252
9373
  return status("OK", { configured: true, type: "oidc" });
9253
9374
  }, {
9254
- body: t17.Object({
9255
- clientId: t17.String(),
9256
- clientSecret: t17.String(),
9257
- issuer: t17.String(),
9258
- redirectUri: t17.Optional(t17.String()),
9259
- scopes: t17.Optional(t17.Array(t17.String()))
9375
+ body: t18.Object({
9376
+ clientId: t18.String(),
9377
+ clientSecret: t18.String(),
9378
+ issuer: t18.String(),
9379
+ redirectUri: t18.Optional(t18.String()),
9380
+ scopes: t18.Optional(t18.Array(t18.String()))
9260
9381
  })
9261
9382
  }).post(`${portalRoute}/scim/token`, async ({ headers, request, status }) => {
9262
9383
  const session = await loadSession(headers.authorization);
@@ -9287,7 +9408,7 @@ var portalRoutes = ({
9287
9408
  };
9288
9409
 
9289
9410
  // src/roles/routes.ts
9290
- import { Elysia as Elysia22, t as t18 } from "elysia";
9411
+ import { Elysia as Elysia26, t as t19 } from "elysia";
9291
9412
 
9292
9413
  // src/roles/config.ts
9293
9414
  var DEFAULT_ROLES_ROUTE = "/auth/roles";
@@ -9322,7 +9443,7 @@ var roleRoutes = ({
9322
9443
  roleStore,
9323
9444
  rolesRoute = DEFAULT_ROLES_ROUTE
9324
9445
  }) => {
9325
- const cookie = t18.Cookie({ user_session_id: userSessionIdTypebox });
9446
+ const cookie = t19.Cookie({ user_session_id: userSessionIdTypebox });
9326
9447
  const requireUser = async (userSessionId, session) => {
9327
9448
  const current = await loadSessionFromSource({
9328
9449
  authSessionStore,
@@ -9338,7 +9459,7 @@ var roleRoutes = ({
9338
9459
  }
9339
9460
  return membership?.status === "active";
9340
9461
  };
9341
- return new Elysia22().use(sessionStore()).get(`${rolesRoute}/:organizationId`, async ({
9462
+ return new Elysia26().use(sessionStore()).get(`${rolesRoute}/:organizationId`, async ({
9342
9463
  cookie: { user_session_id },
9343
9464
  params: { organizationId },
9344
9465
  status,
@@ -9356,7 +9477,7 @@ var roleRoutes = ({
9356
9477
  roleStore.listRoles()
9357
9478
  ]);
9358
9479
  return status("OK", { roles: [...scoped, ...global] });
9359
- }, { cookie, params: t18.Object({ organizationId: t18.String() }) }).put(`${rolesRoute}/:organizationId/members/:userId`, async ({
9480
+ }, { cookie, params: t19.Object({ organizationId: t19.String() }) }).put(`${rolesRoute}/:organizationId/members/:userId`, async ({
9360
9481
  body: { roles },
9361
9482
  cookie: { user_session_id },
9362
9483
  params: { organizationId, userId },
@@ -9389,11 +9510,11 @@ var roleRoutes = ({
9389
9510
  await onRolesAssigned?.({ organizationId, roles, userId });
9390
9511
  return status("OK", { roles: updated.roles });
9391
9512
  }, {
9392
- body: t18.Object({ roles: t18.Array(t18.String()) }),
9513
+ body: t19.Object({ roles: t19.Array(t19.String()) }),
9393
9514
  cookie,
9394
- params: t18.Object({
9395
- organizationId: t18.String(),
9396
- userId: t18.String()
9515
+ params: t19.Object({
9516
+ organizationId: t19.String(),
9517
+ userId: t19.String()
9397
9518
  })
9398
9519
  });
9399
9520
  };
@@ -9561,7 +9682,7 @@ var resolveProviderClientConfiguration = ({
9561
9682
 
9562
9683
  // src/routes/authorize.ts
9563
9684
  init_constants();
9564
- import { Elysia as Elysia23, t as t19 } from "elysia";
9685
+ import { Elysia as Elysia27, t as t20 } from "elysia";
9565
9686
  var parseReferer = (headerReferer) => {
9566
9687
  if (!headerReferer)
9567
9688
  return "/";
@@ -9583,7 +9704,7 @@ var authorize = ({
9583
9704
  onAuthorizeError
9584
9705
  }) => {
9585
9706
  const secure = resolveCookieSecure(cookieSecure);
9586
- return new Elysia23().get(authorizeRoute, async ({
9707
+ return new Elysia27().get(authorizeRoute, async ({
9587
9708
  status,
9588
9709
  redirect,
9589
9710
  cookie: {
@@ -9700,15 +9821,15 @@ var authorize = ({
9700
9821
  return status("Internal Server Error", "Failed to create authorization URL");
9701
9822
  }
9702
9823
  }, {
9703
- cookie: t19.Cookie({
9824
+ cookie: t20.Cookie({
9704
9825
  auth_client: authClientOption,
9705
9826
  auth_intent: authIntentOption,
9706
- auth_provider: t19.Optional(authProviderOption)
9827
+ auth_provider: t20.Optional(authProviderOption)
9707
9828
  }),
9708
- params: t19.Object({
9829
+ params: t20.Object({
9709
9830
  provider: authProviderOption
9710
9831
  }),
9711
- query: t19.Object({
9832
+ query: t20.Object({
9712
9833
  client: authClientOption,
9713
9834
  intent: authIntentOption
9714
9835
  })
@@ -9716,7 +9837,7 @@ var authorize = ({
9716
9837
  };
9717
9838
 
9718
9839
  // src/routes/callback.ts
9719
- import { Elysia as Elysia24, t as t20 } from "elysia";
9840
+ import { Elysia as Elysia28, t as t21 } from "elysia";
9720
9841
 
9721
9842
  // src/errors.ts
9722
9843
  class AuthIdentityConflictError extends Error {
@@ -9739,7 +9860,7 @@ var callback = ({
9739
9860
  onLinkIdentityConflict,
9740
9861
  onLinkConnector,
9741
9862
  onCallbackError
9742
- }) => new Elysia24().use(sessionStore()).get(callbackRoute, async ({
9863
+ }) => new Elysia28().use(sessionStore()).get(callbackRoute, async ({
9743
9864
  status,
9744
9865
  redirect,
9745
9866
  store: { session, unregisteredSession },
@@ -9874,25 +9995,25 @@ var callback = ({
9874
9995
  }
9875
9996
  return redirect(originUrl);
9876
9997
  }), {
9877
- cookie: t20.Cookie({
9998
+ cookie: t21.Cookie({
9878
9999
  auth_client: authClientOption,
9879
10000
  auth_intent: authIntentOption,
9880
- auth_provider: t20.Optional(authProviderOption),
9881
- code_verifier: t20.Optional(t20.String()),
9882
- origin_url: t20.Optional(t20.String()),
9883
- state: t20.Optional(t20.String()),
9884
- user_session_id: t20.Optional(userSessionIdTypebox)
10001
+ auth_provider: t21.Optional(authProviderOption),
10002
+ code_verifier: t21.Optional(t21.String()),
10003
+ origin_url: t21.Optional(t21.String()),
10004
+ state: t21.Optional(t21.String()),
10005
+ user_session_id: t21.Optional(userSessionIdTypebox)
9885
10006
  })
9886
10007
  });
9887
10008
 
9888
10009
  // src/routes/profile.ts
9889
- import { Elysia as Elysia25, t as t21 } from "elysia";
10010
+ import { Elysia as Elysia29, t as t22 } from "elysia";
9890
10011
  var profile = ({
9891
10012
  clientProviders,
9892
10013
  profileRoute = "/oauth2/profile",
9893
10014
  onProfileSuccess,
9894
10015
  onProfileError
9895
- }) => new Elysia25().use(sessionStore()).get(profileRoute, async ({
10016
+ }) => new Elysia29().use(sessionStore()).get(profileRoute, async ({
9896
10017
  status,
9897
10018
  store: { session },
9898
10019
  cookie: { user_session_id, auth_provider, auth_client }
@@ -9942,7 +10063,7 @@ var profile = ({
9942
10063
  return err instanceof Error ? status("Internal Server Error", `${err.message} - ${err.stack ?? ""}`) : status("Internal Server Error", `Failed to validate authorization code: Unknown status: ${err}`);
9943
10064
  }
9944
10065
  }, {
9945
- cookie: t21.Cookie({
10066
+ cookie: t22.Cookie({
9946
10067
  auth_client: authClientOption,
9947
10068
  auth_provider: authProviderOption,
9948
10069
  user_session_id: userSessionIdTypebox
@@ -9951,7 +10072,7 @@ var profile = ({
9951
10072
 
9952
10073
  // src/routes/refresh.ts
9953
10074
  init_constants();
9954
- import { Elysia as Elysia26, t as t22 } from "elysia";
10075
+ import { Elysia as Elysia30, t as t23 } from "elysia";
9955
10076
  var refresh = ({
9956
10077
  authSessionStore,
9957
10078
  clientProviders,
@@ -9959,7 +10080,7 @@ var refresh = ({
9959
10080
  onRefreshSuccess,
9960
10081
  onRefreshError,
9961
10082
  sessionDurationMs = MILLISECONDS_IN_A_DAY
9962
- }) => new Elysia26().use(sessionStore()).post(refreshRoute, async ({
10083
+ }) => new Elysia30().use(sessionStore()).post(refreshRoute, async ({
9963
10084
  status,
9964
10085
  store: { session },
9965
10086
  cookie: { user_session_id, auth_provider, auth_client }
@@ -10028,7 +10149,7 @@ var refresh = ({
10028
10149
  return status("Internal Server Error", "Failed to refresh token");
10029
10150
  }
10030
10151
  }, {
10031
- cookie: t22.Cookie({
10152
+ cookie: t23.Cookie({
10032
10153
  auth_client: authClientOption,
10033
10154
  auth_provider: authProviderOption,
10034
10155
  user_session_id: userSessionIdTypebox
@@ -10036,14 +10157,14 @@ var refresh = ({
10036
10157
  });
10037
10158
 
10038
10159
  // src/routes/revoke.ts
10039
- import { Elysia as Elysia27, t as t23 } from "elysia";
10160
+ import { Elysia as Elysia31, t as t24 } from "elysia";
10040
10161
  var revoke = ({
10041
10162
  authSessionStore,
10042
10163
  clientProviders,
10043
10164
  revokeRoute = "/oauth2/revocation",
10044
10165
  onRevocationSuccess,
10045
10166
  onRevocationError
10046
- }) => new Elysia27().use(sessionStore()).post(revokeRoute, async ({
10167
+ }) => new Elysia31().use(sessionStore()).post(revokeRoute, async ({
10047
10168
  status,
10048
10169
  store: { session },
10049
10170
  cookie: { user_session_id, auth_provider, auth_client }
@@ -10108,7 +10229,7 @@ var revoke = ({
10108
10229
  return status("Internal Server Error", "Failed to revoke token");
10109
10230
  }
10110
10231
  }, {
10111
- cookie: t23.Cookie({
10232
+ cookie: t24.Cookie({
10112
10233
  auth_client: authClientOption,
10113
10234
  auth_provider: authProviderOption,
10114
10235
  user_session_id: userSessionIdTypebox
@@ -10116,12 +10237,12 @@ var revoke = ({
10116
10237
  });
10117
10238
 
10118
10239
  // src/routes/sessions.ts
10119
- import { Elysia as Elysia28, t as t24 } from "elysia";
10240
+ import { Elysia as Elysia32, t as t25 } from "elysia";
10120
10241
  var sessionRoutes = ({
10121
10242
  authSessionStore,
10122
10243
  getUserId,
10123
10244
  sessionsRoute = "/auth/sessions"
10124
- }) => new Elysia28().use(sessionStore()).get(sessionsRoute, async ({
10245
+ }) => new Elysia32().use(sessionStore()).get(sessionsRoute, async ({
10125
10246
  cookie: { user_session_id },
10126
10247
  status,
10127
10248
  store: { session }
@@ -10149,7 +10270,7 @@ var sessionRoutes = ({
10149
10270
  id: entry.id
10150
10271
  }));
10151
10272
  return status("OK", { sessions: list });
10152
- }, { cookie: t24.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(`${sessionsRoute}/:id`, async ({
10273
+ }, { cookie: t25.Cookie({ user_session_id: userSessionIdTypebox }) }).delete(`${sessionsRoute}/:id`, async ({
10153
10274
  cookie: { user_session_id },
10154
10275
  params: { id },
10155
10276
  status,
@@ -10176,34 +10297,12 @@ var sessionRoutes = ({
10176
10297
  await authSessionStore.removeSession(id);
10177
10298
  return status("OK", { revoked: id });
10178
10299
  }, {
10179
- cookie: t24.Cookie({ user_session_id: userSessionIdTypebox }),
10180
- params: t24.Object({ id: t24.String() })
10300
+ cookie: t25.Cookie({ user_session_id: userSessionIdTypebox }),
10301
+ params: t25.Object({ id: t25.String() })
10181
10302
  });
10182
10303
 
10183
- // src/routes/stepUp.ts
10184
- import { Elysia as Elysia29, t as t25 } from "elysia";
10185
- var stepUpPlugin = ({
10186
- authSessionStore
10187
- } = {}) => new Elysia29().use(sessionStore()).guard({ cookie: t25.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
10188
- requireRecentAuth: (maxAgeMs, handleAuth, handleAuthFail) => loadSessionFromSource({
10189
- authSessionStore,
10190
- session,
10191
- userSessionId: user_session_id.value
10192
- }).then((userSession) => {
10193
- const authenticatedAt = userSession?.authenticatedAt;
10194
- const isRecent = authenticatedAt !== undefined && Date.now() - authenticatedAt <= maxAgeMs;
10195
- if (!userSession || !isRecent) {
10196
- return handleAuthFail?.({
10197
- code: "Unauthorized",
10198
- message: "Recent authentication required"
10199
- }) ?? status("Unauthorized", "Recent authentication required");
10200
- }
10201
- return handleAuth(userSession.user);
10202
- })
10203
- })).as("global");
10204
-
10205
10304
  // src/routes/signout.ts
10206
- import { Elysia as Elysia30, t as t26 } from "elysia";
10305
+ import { Elysia as Elysia33, t as t26 } from "elysia";
10207
10306
  var sessionForSignOut = ({
10208
10307
  authSessionStore,
10209
10308
  currentSession,
@@ -10233,7 +10332,7 @@ var signout = ({
10233
10332
  authSessionStore,
10234
10333
  signoutRoute = "/oauth2/signout",
10235
10334
  onSignOut
10236
- }) => new Elysia30().use(sessionStore()).delete(signoutRoute, async ({
10335
+ }) => new Elysia33().use(sessionStore()).delete(signoutRoute, async ({
10237
10336
  status,
10238
10337
  store: { session },
10239
10338
  cookie: { user_session_id, auth_provider }
@@ -10280,12 +10379,12 @@ var signout = ({
10280
10379
  });
10281
10380
 
10282
10381
  // src/routes/userStatus.ts
10283
- import { Elysia as Elysia31, t as t27 } from "elysia";
10382
+ import { Elysia as Elysia34, t as t27 } from "elysia";
10284
10383
  var userStatus = ({
10285
10384
  authSessionStore,
10286
10385
  statusRoute = "/oauth2/status",
10287
10386
  onStatus
10288
- }) => new Elysia31().use(sessionStore()).get(statusRoute, async ({ status, cookie: { user_session_id }, store: { session } }) => {
10387
+ }) => new Elysia34().use(sessionStore()).get(statusRoute, async ({ status, cookie: { user_session_id }, store: { session } }) => {
10289
10388
  const { user, impersonator, error } = await getStatusFromSource({
10290
10389
  authSessionStore,
10291
10390
  session,
@@ -10303,7 +10402,7 @@ var userStatus = ({
10303
10402
  }, { cookie: t27.Cookie({ user_session_id: userSessionIdTypebox }) });
10304
10403
 
10305
10404
  // src/scim/routes.ts
10306
- import { Elysia as Elysia32, t as t28 } from "elysia";
10405
+ import { Elysia as Elysia35, t as t28 } from "elysia";
10307
10406
 
10308
10407
  // src/scim/serialize.ts
10309
10408
  var USER_SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User";
@@ -10776,7 +10875,7 @@ var scimRoutes = ({
10776
10875
  const resourceTypesLocation = (requestUrl) => `${new URL(requestUrl).origin}${scimRoute}/ResourceTypes`;
10777
10876
  const usersEndpoint = `${scimRoute}/Users`;
10778
10877
  const groupsEndpoint = `${scimRoute}/Groups`;
10779
- return new Elysia32().onParse(({ request }, contentType) => contentType === SCIM_CONTENT_TYPE2 ? request.json() : undefined).get(spcRoute, async ({ headers, request }) => {
10878
+ return new Elysia35().onParse(({ request }, contentType) => contentType === SCIM_CONTENT_TYPE2 ? request.json() : undefined).get(spcRoute, async ({ headers, request }) => {
10780
10879
  const organizationId = await resolveScimOrganization(scimTokenStore, headers.authorization);
10781
10880
  if (organizationId === undefined)
10782
10881
  return unauthorized();
@@ -10968,7 +11067,7 @@ var scimRoutes = ({
10968
11067
 
10969
11068
  // src/session/cleanup.ts
10970
11069
  init_constants();
10971
- import { Elysia as Elysia33 } from "elysia";
11070
+ import { Elysia as Elysia36 } from "elysia";
10972
11071
  var sessionCleanup = ({
10973
11072
  authSessionStore,
10974
11073
  cleanupIntervalMs = MILLISECONDS_IN_AN_HOUR,
@@ -10976,7 +11075,7 @@ var sessionCleanup = ({
10976
11075
  onSessionCleanup
10977
11076
  }) => {
10978
11077
  let intervalId = null;
10979
- return new Elysia33({ name: "sessionCleanup" }).use(sessionStore()).onStart(({ store: { session, unregisteredSession } }) => {
11078
+ return new Elysia36({ name: "sessionCleanup" }).use(sessionStore()).onStart(({ store: { session, unregisteredSession } }) => {
10980
11079
  intervalId = setInterval(async () => {
10981
11080
  await performCleanup({
10982
11081
  authSessionStore,
@@ -11204,7 +11303,7 @@ var performCleanup = async ({
11204
11303
  };
11205
11304
 
11206
11305
  // src/sso/discoveryRoute.ts
11207
- import { Elysia as Elysia34, t as t29 } from "elysia";
11306
+ import { Elysia as Elysia37, t as t29 } from "elysia";
11208
11307
  var emailDomain = (email) => {
11209
11308
  const atIndex = email.lastIndexOf("@");
11210
11309
  if (atIndex === -1)
@@ -11217,7 +11316,7 @@ var ssoDiscoveryRoute = ({
11217
11316
  ssoRoute = DEFAULT_SSO_ROUTE
11218
11317
  }) => {
11219
11318
  const discoveryRoute = `${ssoRoute}/authorize`;
11220
- return new Elysia34().get(discoveryRoute, async ({ query: { email }, redirect, status }) => {
11319
+ return new Elysia37().get(discoveryRoute, async ({ query: { email }, redirect, status }) => {
11221
11320
  if (!isNonEmptyString(email)) {
11222
11321
  return status("Bad Request", 'An "email" query parameter is required');
11223
11322
  }
@@ -11239,7 +11338,7 @@ var ssoDiscoveryRoute = ({
11239
11338
 
11240
11339
  // src/sso/oidcRoutes.ts
11241
11340
  init_constants();
11242
- import { Elysia as Elysia35, t as t30 } from "elysia";
11341
+ import { Elysia as Elysia38, t as t30 } from "elysia";
11243
11342
  var makeSsoCookieOptions = (secure) => ({
11244
11343
  httpOnly: true,
11245
11344
  maxAge: COOKIE_DURATION,
@@ -11278,7 +11377,7 @@ var oidcSsoRoutes = ({
11278
11377
  const ssoCookieOptions = makeSsoCookieOptions(resolveCookieSecure(cookieSecure));
11279
11378
  const authorizeRoute = `${ssoRoute}/oidc/:organizationId/authorize`;
11280
11379
  const callbackRoute = `${ssoRoute}/oidc/:organizationId/callback`;
11281
- return new Elysia35().use(sessionStore()).get(authorizeRoute, async ({
11380
+ return new Elysia38().use(sessionStore()).get(authorizeRoute, async ({
11282
11381
  cookie: {
11283
11382
  sso_nonce,
11284
11383
  sso_organization,
@@ -11404,7 +11503,7 @@ var oidcSsoRoutes = ({
11404
11503
  };
11405
11504
 
11406
11505
  // src/sso/samlRoutes.ts
11407
- import { Elysia as Elysia36, t as t31 } from "elysia";
11506
+ import { Elysia as Elysia39, t as t31 } from "elysia";
11408
11507
  var toLocalPath = (value) => {
11409
11508
  if (value === undefined || value.length === 0)
11410
11509
  return "/";
@@ -11454,7 +11553,7 @@ var samlSsoRoutes = ({
11454
11553
  const target = authSessionStore ? compatibilityLayer.session : inMemorySession;
11455
11554
  return target[userSessionId]?.samlLogout;
11456
11555
  };
11457
- return new Elysia36().use(sessionStore()).get(authorizeRoute, async ({
11556
+ return new Elysia39().use(sessionStore()).get(authorizeRoute, async ({
11458
11557
  headers,
11459
11558
  params: { organizationId },
11460
11559
  redirect,
@@ -11676,7 +11775,7 @@ var samlSsoRoutes = ({
11676
11775
 
11677
11776
  // src/webauthn/routes.ts
11678
11777
  init_constants();
11679
- import { Elysia as Elysia37, t as t32 } from "elysia";
11778
+ import { Elysia as Elysia40, t as t32 } from "elysia";
11680
11779
 
11681
11780
  // src/webauthn/config.ts
11682
11781
  init_constants();
@@ -11718,7 +11817,7 @@ var webauthnRoutes = ({
11718
11817
  secure,
11719
11818
  value: challenge
11720
11819
  });
11721
- return new Elysia37().use(sessionStore()).post(`${webauthnRoute}/register/options`, async ({
11820
+ return new Elysia40().use(sessionStore()).post(`${webauthnRoute}/register/options`, async ({
11722
11821
  cookie: { user_session_id, webauthn_challenge },
11723
11822
  status,
11724
11823
  store: { session }
@@ -25052,7 +25151,7 @@ var createInMemoryCredentialOfferStore = () => {
25052
25151
  };
25053
25152
  };
25054
25153
  // src/oidc/vciRoutes.ts
25055
- import { Elysia as Elysia38, t as t33 } from "elysia";
25154
+ import { Elysia as Elysia41, t as t33 } from "elysia";
25056
25155
  var HTTP_OK4 = 200;
25057
25156
  var HTTP_BAD_REQUEST4 = 400;
25058
25157
  var HTTP_UNAUTHORIZED5 = 401;
@@ -25077,7 +25176,7 @@ var vciRoutes = ({
25077
25176
  const credentialRoute = `${vciRoute}/credential`;
25078
25177
  const nonceRoute = `${vciRoute}/nonce`;
25079
25178
  const vciSigningKey = vciConfig.signingKey ?? signingKey;
25080
- return new Elysia38().get("/.well-known/openid-credential-issuer", () => Response.json(buildIssuerMetadata({
25179
+ return new Elysia41().get("/.well-known/openid-credential-issuer", () => Response.json(buildIssuerMetadata({
25081
25180
  config: vciConfig,
25082
25181
  issuer: issuerUrl,
25083
25182
  vciRoute
@@ -25226,7 +25325,7 @@ var verifyStatusListJwt = async ({
25226
25325
  };
25227
25326
  };
25228
25327
  // src/vc/statusListRoutes.ts
25229
- import { Elysia as Elysia39, t as t34 } from "elysia";
25328
+ import { Elysia as Elysia42, t as t34 } from "elysia";
25230
25329
  var HTTP_OK5 = 200;
25231
25330
  var HTTP_NOT_FOUND = 404;
25232
25331
  var DEFAULT_STATUS_ROUTE = "/vc/status";
@@ -25238,7 +25337,7 @@ var statusListRoutes = ({
25238
25337
  ttlSeconds
25239
25338
  }) => {
25240
25339
  const listRoute = `${statusRoute}/:listId`;
25241
- return new Elysia39().get(listRoute, async ({ params: { listId } }) => {
25340
+ return new Elysia42().get(listRoute, async ({ params: { listId } }) => {
25242
25341
  const bits = await getStatusList(listId);
25243
25342
  if (bits === undefined) {
25244
25343
  return new Response("Not found", { status: HTTP_NOT_FOUND });
@@ -25459,7 +25558,7 @@ var createInMemoryPresentationRequestStore = () => {
25459
25558
  };
25460
25559
  };
25461
25560
  // src/vc/vpRoutes.ts
25462
- import { Elysia as Elysia40, t as t35 } from "elysia";
25561
+ import { Elysia as Elysia43, t as t35 } from "elysia";
25463
25562
  var HTTP_OK6 = 200;
25464
25563
  var HTTP_BAD_REQUEST5 = 400;
25465
25564
  var HTTP_NOT_FOUND2 = 404;
@@ -25478,7 +25577,7 @@ var vpRoutes = ({
25478
25577
  const authorizeRoute = `${vpRoute}/authorize`;
25479
25578
  const requestRoute = `${vpRoute}/request/:id`;
25480
25579
  const responseRoute = `${vpRoute}/response`;
25481
- return new Elysia40().post(authorizeRoute, async ({ body }) => {
25580
+ return new Elysia43().post(authorizeRoute, async ({ body }) => {
25482
25581
  const input = {
25483
25582
  clientId: body.client_id ?? defaultClientId,
25484
25583
  requestedClaims: body.requested_claims,
@@ -28653,7 +28752,7 @@ var blockMigrations = {
28653
28752
  webhooks: initMigration("webhooks", [webhookDeliveriesTable])
28654
28753
  };
28655
28754
  // src/sso/samlIdpRoutes.ts
28656
- import { Elysia as Elysia41, t as t36 } from "elysia";
28755
+ import { Elysia as Elysia44, t as t36 } from "elysia";
28657
28756
  var HTTP_BAD_REQUEST6 = 400;
28658
28757
  var HTTP_UNAUTHORIZED6 = 401;
28659
28758
  var HTTP_FOUND2 = 302;
@@ -28763,7 +28862,7 @@ var samlIdpRoutes = ({
28763
28862
  user: userSession.user
28764
28863
  });
28765
28864
  };
28766
- return new Elysia41().use(sessionStore()).post(ssoIdpRoute, async ({ body, cookie: { user_session_id }, request, store }) => handleSpInitiated({
28865
+ return new Elysia44().use(sessionStore()).post(ssoIdpRoute, async ({ body, cookie: { user_session_id }, request, store }) => handleSpInitiated({
28767
28866
  binding: "POST",
28768
28867
  body,
28769
28868
  inMemorySession: store.session,
@@ -29060,59 +29159,67 @@ var createInMemorySetupSessionStore = () => {
29060
29159
  };
29061
29160
 
29062
29161
  // src/index.ts
29063
- var auth = async ({
29064
- providersConfiguration,
29065
- authorizeRoute,
29066
- cookieSecure,
29067
- callbackRoute,
29068
- profileRoute,
29069
- signoutRoute,
29070
- statusRoute,
29071
- refreshRoute,
29072
- revokeRoute,
29073
- cleanupIntervalMs,
29074
- maxSessions,
29075
- sessionDurationMs,
29076
- authSessionStore,
29077
- audit,
29078
- credentials,
29079
- customProviders,
29080
- mfa,
29081
- passwordless,
29082
- lockout,
29083
- sessions,
29084
- sso,
29085
- scim,
29086
- apikeys,
29087
- agentAuth,
29088
- oidc,
29089
- organizations,
29090
- roles,
29091
- portal,
29092
- authorization,
29093
- compliance,
29094
- webauthn,
29095
- webhooks,
29096
- htmx,
29097
- tracing,
29098
- resolveAuthIntent,
29099
- onAuthorizeSuccess,
29100
- onAuthorizeError,
29101
- onProfileSuccess,
29102
- onProfileError,
29103
- onCallbackSuccess,
29104
- onLinkIdentity,
29105
- onLinkIdentityConflict,
29106
- onLinkConnector,
29107
- onCallbackError,
29108
- onStatus,
29109
- onRefreshSuccess,
29110
- onRefreshError,
29111
- onSignOut,
29112
- onRevocationSuccess,
29113
- onRevocationError,
29114
- onSessionCleanup
29115
- }) => {
29162
+ var validatePositiveOptions = (prefix, options) => {
29163
+ for (const [name2, value] of Object.entries(options)) {
29164
+ if (value !== undefined && (!Number.isFinite(value) || value <= 0)) {
29165
+ throw new Error(`${prefix}.${name2} must be positive`);
29166
+ }
29167
+ }
29168
+ };
29169
+ var buildAuthApplications = async (configuration) => {
29170
+ const {
29171
+ providersConfiguration,
29172
+ authorizeRoute,
29173
+ cookieSecure,
29174
+ callbackRoute,
29175
+ profileRoute,
29176
+ signoutRoute,
29177
+ statusRoute,
29178
+ refreshRoute,
29179
+ revokeRoute,
29180
+ cleanupIntervalMs,
29181
+ maxSessions,
29182
+ sessionDurationMs,
29183
+ authSessionStore,
29184
+ audit,
29185
+ credentials,
29186
+ customProviders,
29187
+ mfa,
29188
+ passwordless,
29189
+ lockout,
29190
+ sessions,
29191
+ sso,
29192
+ scim,
29193
+ apikeys,
29194
+ agentAuth,
29195
+ oidc,
29196
+ organizations,
29197
+ roles,
29198
+ portal,
29199
+ authorization,
29200
+ compliance,
29201
+ webauthn,
29202
+ webhooks,
29203
+ htmx,
29204
+ tracing,
29205
+ resolveAuthIntent,
29206
+ onAuthorizeSuccess,
29207
+ onAuthorizeError,
29208
+ onProfileSuccess,
29209
+ onProfileError,
29210
+ onCallbackSuccess,
29211
+ onLinkIdentity,
29212
+ onLinkIdentityConflict,
29213
+ onLinkConnector,
29214
+ onCallbackError,
29215
+ onStatus,
29216
+ onRefreshSuccess,
29217
+ onRefreshError,
29218
+ onSignOut,
29219
+ onRevocationSuccess,
29220
+ onRevocationError,
29221
+ onSessionCleanup
29222
+ } = configuration;
29116
29223
  if (agentAuth?.agentRegistration !== undefined) {
29117
29224
  if (oidc === undefined) {
29118
29225
  throw new Error("agentAuth.agentRegistration requires the OIDC provider");
@@ -29131,7 +29238,7 @@ var auth = async ({
29131
29238
  if (registration2.allowAnonymous === true && registration2.revokeAccessTokens === undefined) {
29132
29239
  throw new Error("Anonymous agent registration requires revokeAccessTokens");
29133
29240
  }
29134
- for (const [name2, value] of Object.entries({
29241
+ validatePositiveOptions("agentAuth.agentRegistration", {
29135
29242
  assertionTtlMs: registration2.assertionTtlMs,
29136
29243
  attemptTtlMs: registration2.attemptTtlMs,
29137
29244
  claimTtlMs: registration2.claimTtlMs,
@@ -29139,11 +29246,7 @@ var auth = async ({
29139
29246
  maxCodeAttempts: registration2.maxCodeAttempts,
29140
29247
  pollIntervalSeconds: registration2.pollIntervalSeconds,
29141
29248
  tokenTtlMs: registration2.tokenTtlMs
29142
- })) {
29143
- if (value !== undefined && (!Number.isFinite(value) || value <= 0)) {
29144
- throw new Error(`agentAuth.agentRegistration.${name2} must be positive`);
29145
- }
29146
- }
29249
+ });
29147
29250
  }
29148
29251
  if (tracing !== undefined)
29149
29252
  await initTracing(tracing);
@@ -29246,107 +29349,152 @@ var auth = async ({
29246
29349
  const auditedOnCallbackSuccess = auditEmit ? composeCallbackAudit(onCallbackSuccess, auditEmit) : onCallbackSuccess;
29247
29350
  const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
29248
29351
  const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
29249
- const composedAuth = new Elysia42().use(sessionCleanup({
29250
- authSessionStore,
29251
- cleanupIntervalMs,
29252
- maxSessions,
29253
- onSessionCleanup
29254
- })).use(signout({
29255
- authSessionStore,
29256
- onSignOut: auditedOnSignOut,
29257
- signoutRoute
29258
- })).use(revoke({
29259
- authSessionStore,
29260
- clientProviders,
29261
- onRevocationError,
29262
- onRevocationSuccess: auditedOnRevocationSuccess,
29263
- revokeRoute
29264
- })).use(userStatus({ authSessionStore, onStatus, statusRoute })).use(refresh({
29265
- authSessionStore,
29266
- clientProviders,
29267
- onRefreshError,
29268
- onRefreshSuccess,
29269
- refreshRoute,
29270
- sessionDurationMs
29271
- })).use(authorize({
29272
- authorizeRoute,
29273
- clientProviders,
29274
- cookieSecure: resolvedCookieSecure,
29275
- onAuthorizeError,
29276
- onAuthorizeSuccess
29277
- })).use(callback({
29278
- authSessionStore,
29279
- callbackRoute,
29280
- clientProviders,
29281
- onCallbackError,
29282
- onCallbackSuccess: auditedOnCallbackSuccess,
29283
- onLinkConnector,
29284
- onLinkIdentity,
29285
- onLinkIdentityConflict,
29286
- resolveAuthIntent
29287
- })).use(profile({
29288
- clientProviders,
29289
- onProfileError,
29290
- onProfileSuccess,
29291
- profileRoute
29292
- })).use(auditedCredentials ? credentialRoutes({
29293
- ...auditedCredentials,
29294
- authSessionStore,
29295
- cookieSecure: resolvedCookieSecure,
29296
- lockoutGuard
29297
- }) : new Elysia42).use(auditedMfa ? mfaRoutes({
29298
- ...auditedMfa,
29299
- authSessionStore,
29300
- cookieSecure: resolvedCookieSecure
29301
- }) : new Elysia42).use(passwordless ? passwordlessRoutes({
29302
- ...passwordless,
29303
- authSessionStore,
29304
- cookieSecure: resolvedCookieSecure,
29305
- emit: auditEmit
29306
- }) : new Elysia42).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia42).use(sso ? oidcSsoRoutes({
29307
- ...sso,
29308
- authSessionStore,
29309
- cookieSecure: resolvedCookieSecure
29310
- }) : new Elysia42).use(sso && sso.samlAdapter ? samlSsoRoutes({
29311
- ...sso,
29312
- authSessionStore,
29313
- cookieSecure: resolvedCookieSecure,
29314
- samlAdapter: sso.samlAdapter
29315
- }) : new Elysia42).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
29316
- getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
29317
- ssoConnectionStore: sso.ssoConnectionStore,
29318
- ssoRoute: sso.ssoRoute
29319
- }) : new Elysia42).use(scim ? scimRoutes(scim) : new Elysia42).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia42).use(oidcConfig ? oidcProviderRoutes({
29320
- ...oidcConfig,
29321
- authSessionStore
29322
- }) : new Elysia42).use(organizations ? organizationRoutes({
29323
- ...organizations,
29324
- authSessionStore,
29325
- emit: auditEmit
29326
- }) : new Elysia42).use(roles ? roleRoutes({
29327
- ...roles,
29328
- authSessionStore,
29329
- emit: auditEmit
29330
- }) : new Elysia42).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia42).use(webauthn ? webauthnRoutes({
29331
- ...webauthn,
29332
- authSessionStore,
29333
- cookieSecure: resolvedCookieSecure,
29334
- emit: auditEmit
29335
- }) : new Elysia42).use(compliance ? complianceRoutes({
29336
- ...compliance,
29337
- authSessionStore,
29338
- emit: auditEmit
29339
- }) : new Elysia42).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
29340
- ...authorization,
29352
+ const pluginSeed = pluginDependencySeed(configuration);
29353
+ const coreRoutes = new Elysia45({
29354
+ name: "@absolutejs/auth/core-routes",
29355
+ seed: pluginSeed
29356
+ }).use([
29357
+ sessionCleanup({
29358
+ authSessionStore,
29359
+ cleanupIntervalMs,
29360
+ maxSessions,
29361
+ onSessionCleanup
29362
+ }),
29363
+ signout({
29364
+ authSessionStore,
29365
+ onSignOut: auditedOnSignOut,
29366
+ signoutRoute
29367
+ }),
29368
+ revoke({
29369
+ authSessionStore,
29370
+ clientProviders,
29371
+ onRevocationError,
29372
+ onRevocationSuccess: auditedOnRevocationSuccess,
29373
+ revokeRoute
29374
+ }),
29375
+ userStatus({ authSessionStore, onStatus, statusRoute }),
29376
+ refresh({
29377
+ authSessionStore,
29378
+ clientProviders,
29379
+ onRefreshError,
29380
+ onRefreshSuccess,
29381
+ refreshRoute,
29382
+ sessionDurationMs
29383
+ }),
29384
+ authorize({
29385
+ authorizeRoute,
29386
+ clientProviders,
29387
+ cookieSecure: resolvedCookieSecure,
29388
+ onAuthorizeError,
29389
+ onAuthorizeSuccess
29390
+ }),
29391
+ callback({
29392
+ authSessionStore,
29393
+ callbackRoute,
29394
+ clientProviders,
29395
+ onCallbackError,
29396
+ onCallbackSuccess: auditedOnCallbackSuccess,
29397
+ onLinkConnector,
29398
+ onLinkIdentity,
29399
+ onLinkIdentityConflict,
29400
+ resolveAuthIntent
29401
+ }),
29402
+ profile({
29403
+ clientProviders,
29404
+ onProfileError,
29405
+ onProfileSuccess,
29406
+ profileRoute
29407
+ })
29408
+ ]);
29409
+ const featureRoutes = new Elysia45({
29410
+ name: "@absolutejs/auth/feature-routes",
29411
+ seed: pluginSeed
29412
+ }).use([
29413
+ auditedCredentials ? credentialRoutes({
29414
+ ...auditedCredentials,
29415
+ authSessionStore,
29416
+ cookieSecure: resolvedCookieSecure,
29417
+ lockoutGuard
29418
+ }) : new Elysia45,
29419
+ auditedMfa ? mfaRoutes({
29420
+ ...auditedMfa,
29421
+ authSessionStore,
29422
+ cookieSecure: resolvedCookieSecure
29423
+ }) : new Elysia45,
29424
+ passwordless ? passwordlessRoutes({
29425
+ ...passwordless,
29426
+ authSessionStore,
29427
+ cookieSecure: resolvedCookieSecure,
29428
+ emit: auditEmit
29429
+ }) : new Elysia45,
29430
+ sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia45,
29431
+ sso ? oidcSsoRoutes({
29432
+ ...sso,
29433
+ authSessionStore,
29434
+ cookieSecure: resolvedCookieSecure
29435
+ }) : new Elysia45,
29436
+ sso && sso.samlAdapter ? samlSsoRoutes({
29437
+ ...sso,
29438
+ authSessionStore,
29439
+ cookieSecure: resolvedCookieSecure,
29440
+ samlAdapter: sso.samlAdapter
29441
+ }) : new Elysia45,
29442
+ sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
29443
+ getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
29444
+ ssoConnectionStore: sso.ssoConnectionStore,
29445
+ ssoRoute: sso.ssoRoute
29446
+ }) : new Elysia45,
29447
+ scim ? scimRoutes(scim) : new Elysia45,
29448
+ apikeys ? apiKeysRoutes(apikeys) : new Elysia45,
29449
+ oidcConfig ? oidcProviderRoutes({
29450
+ ...oidcConfig,
29451
+ authSessionStore
29452
+ }) : new Elysia45,
29453
+ organizations ? organizationRoutes({
29454
+ ...organizations,
29455
+ authSessionStore,
29456
+ emit: auditEmit
29457
+ }) : new Elysia45,
29458
+ roles ? roleRoutes({
29459
+ ...roles,
29460
+ authSessionStore,
29461
+ emit: auditEmit
29462
+ }) : new Elysia45,
29463
+ portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia45,
29464
+ webauthn ? webauthnRoutes({
29465
+ ...webauthn,
29466
+ authSessionStore,
29467
+ cookieSecure: resolvedCookieSecure,
29468
+ emit: auditEmit
29469
+ }) : new Elysia45,
29470
+ compliance ? complianceRoutes({
29471
+ ...compliance,
29472
+ authSessionStore,
29473
+ emit: auditEmit
29474
+ }) : new Elysia45,
29475
+ createConfiguredAuthHtmxRoutes({ authSessionStore, config: htmx }),
29476
+ agentAuthRoutes(resolvedAgentAuth)
29477
+ ]);
29478
+ const authContext = createAuthContext({
29479
+ agentAuth: resolvedAgentAuth,
29480
+ authorization,
29341
29481
  authSessionStore,
29342
- emit: auditEmit
29343
- }) : new Elysia42).use(htmx ? createAuthHtmxRoutes({
29344
- ...htmx,
29345
- authSessionStore
29346
- }) : new Elysia42);
29347
- const authWithAgent = composedAuth.use(agentAuthPlugin(resolvedAgentAuth));
29348
- return authWithAgent;
29482
+ emit: auditEmit,
29483
+ seedSource: configuration
29484
+ });
29485
+ return { authContext, coreRoutes, featureRoutes };
29486
+ };
29487
+ var auth = async (configuration) => {
29488
+ const { authContext, coreRoutes, featureRoutes } = await buildAuthApplications(configuration);
29489
+ const application = new Elysia45({
29490
+ name: "@absolutejs/auth",
29491
+ seed: pluginDependencySeed(configuration)
29492
+ });
29493
+ application.use(coreRoutes);
29494
+ application.use(featureRoutes);
29495
+ return application.use(authContext);
29349
29496
  };
29497
+ var createAuthApplications = async (configuration) => buildAuthApplications(configuration);
29350
29498
  export {
29351
29499
  writeWarrant,
29352
29500
  withSpan,
@@ -29730,6 +29878,8 @@ export {
29730
29878
  createCredentialOffer,
29731
29879
  createClientIdMetadataResolver,
29732
29880
  createAuthHtmxRoutes,
29881
+ createAuthContext,
29882
+ createAuthApplications,
29733
29883
  createAuditRedactor,
29734
29884
  createAuditEmitter,
29735
29885
  createApiKey,
@@ -29829,5 +29979,5 @@ export {
29829
29979
  AGENT_CLAIM_GRANT_TYPE
29830
29980
  };
29831
29981
 
29832
- //# debugId=394E6CA4C2DE944764756E2164756E21
29982
+ //# debugId=C32E620BB25CD5D564756E2164756E21
29833
29983
  //# sourceMappingURL=index.js.map