@absolutejs/auth 0.30.0-beta.4 → 0.30.0-beta.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.
package/dist/index.js CHANGED
@@ -2520,7 +2520,7 @@ var createOAuth2Client = async (providerName, config) => {
2520
2520
  };
2521
2521
 
2522
2522
  // src/index.ts
2523
- import { Elysia as Elysia35 } from "elysia";
2523
+ import { Elysia as Elysia36 } from "elysia";
2524
2524
 
2525
2525
  // src/apikeys/routes.ts
2526
2526
  import { Elysia, t } from "elysia";
@@ -4623,6 +4623,12 @@ var verifyAgainstAny = async (assertion, candidates) => {
4623
4623
  }
4624
4624
  return;
4625
4625
  };
4626
+ var verifyJwtSignedByClientImpl = async (client, jwt) => {
4627
+ const candidates = await resolveClientJwks(client);
4628
+ if (candidates === undefined || candidates.length === 0)
4629
+ return;
4630
+ return verifyAgainstAny(jwt, candidates);
4631
+ };
4626
4632
  var verifyClientAssertion = async ({
4627
4633
  assertion,
4628
4634
  expectedAudience,
@@ -4677,6 +4683,10 @@ var verifyClientAssertion = async ({
4677
4683
  }
4678
4684
  return client;
4679
4685
  };
4686
+ var verifyJwtSignedByClient = ({
4687
+ jwt,
4688
+ client
4689
+ }) => verifyJwtSignedByClientImpl(client, jwt);
4680
4690
 
4681
4691
  // src/oidc/dpop.ts
4682
4692
  var DEFAULT_MAX_AGE_MS = 60000;
@@ -4893,6 +4903,40 @@ var fanOutBackchannelLogout = async ({
4893
4903
  return reachable.map(({ client }) => client.clientId);
4894
4904
  };
4895
4905
 
4906
+ // src/oidc/jar.ts
4907
+ var MS_PER_SECOND2 = 1000;
4908
+ var numberClaim = (value) => typeof value === "number" ? value : undefined;
4909
+ var stringClaim = (value) => typeof value === "string" ? value : undefined;
4910
+ var arrayClaim = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : undefined;
4911
+ var parseSignedRequestObject = async ({
4912
+ client,
4913
+ expectedIssuer,
4914
+ jwt,
4915
+ now = Date.now()
4916
+ }) => {
4917
+ const verified = await verifyJwtSignedByClient({ client, jwt });
4918
+ if (verified === undefined) {
4919
+ return { error: "invalid_request_object", ok: false };
4920
+ }
4921
+ const { payload } = verified;
4922
+ const { aud } = payload;
4923
+ const iss = stringClaim(payload.iss);
4924
+ const exp = numberClaim(payload.exp);
4925
+ if (iss !== client.clientId) {
4926
+ return { error: "invalid_request_object", ok: false };
4927
+ }
4928
+ const audMatches = typeof aud === "string" && aud === expectedIssuer || (arrayClaim(aud)?.includes(expectedIssuer) ?? false);
4929
+ if (!audMatches) {
4930
+ return { error: "invalid_request_object", ok: false };
4931
+ }
4932
+ if (exp !== undefined && exp * MS_PER_SECOND2 <= now) {
4933
+ return { error: "invalid_request_object", ok: false };
4934
+ }
4935
+ const envelope = new Set(["aud", "exp", "iat", "iss", "jti", "nbf"]);
4936
+ const params = Object.fromEntries(Object.entries(payload).filter((entry) => typeof entry[1] === "string" && !envelope.has(entry[0])));
4937
+ return { ok: true, params };
4938
+ };
4939
+
4896
4940
  // src/oidc/par.ts
4897
4941
  var REQUEST_URI_BYTES = 32;
4898
4942
  var DEFAULT_PAR_TTL_SECONDS = 90;
@@ -5467,6 +5511,9 @@ var oidcProviderRoutes = (config) => {
5467
5511
  introspection_endpoint: `${issuer}${introspectRoute}`,
5468
5512
  issuer,
5469
5513
  jwks_uri: `${issuer}${jwksRoute}`,
5514
+ request_object_signing_alg_values_supported: ["ES256"],
5515
+ request_parameter_supported: true,
5516
+ require_signed_request_object_supported: true,
5470
5517
  response_types_supported: ["code"],
5471
5518
  revocation_endpoint: `${issuer}${revokeRoute}`,
5472
5519
  subject_types_supported: ["public"],
@@ -5549,6 +5596,22 @@ var oidcProviderRoutes = (config) => {
5549
5596
  } else if (query.request_uri !== undefined && query.request_uri.startsWith(REQUEST_URI_PREFIX)) {
5550
5597
  return jsonResponse({ error: "invalid_request_uri" }, HTTP_BAD_REQUEST2);
5551
5598
  }
5599
+ const initialClientId = effectiveQuery.client_id;
5600
+ const initialClient = initialClientId === undefined ? undefined : await clientStore.findClient(initialClientId);
5601
+ if (effectiveQuery.request !== undefined && initialClient !== undefined) {
5602
+ const parsed = await parseSignedRequestObject({
5603
+ client: initialClient,
5604
+ expectedIssuer: issuer,
5605
+ jwt: effectiveQuery.request
5606
+ });
5607
+ if (!parsed.ok) {
5608
+ return jsonResponse({ error: parsed.error }, HTTP_BAD_REQUEST2);
5609
+ }
5610
+ effectiveQuery = {
5611
+ ...parsed.params,
5612
+ client_id: initialClientId
5613
+ };
5614
+ }
5552
5615
  const {
5553
5616
  client_id: clientId,
5554
5617
  code_challenge: codeChallenge,
@@ -5559,8 +5622,8 @@ var oidcProviderRoutes = (config) => {
5559
5622
  scope,
5560
5623
  state
5561
5624
  } = effectiveQuery;
5562
- const client = clientId === undefined ? undefined : await clientStore.findClient(clientId);
5563
- if (client === undefined || redirectUri === undefined || !client.redirectUris.includes(redirectUri)) {
5625
+ const client = initialClient;
5626
+ if (client === undefined || clientId !== client.clientId || redirectUri === undefined || !client.redirectUris.includes(redirectUri)) {
5564
5627
  return jsonResponse({ error: "invalid_client" }, HTTP_BAD_REQUEST2);
5565
5628
  }
5566
5629
  const errorRedirect = (error) => {
@@ -5572,6 +5635,9 @@ var oidcProviderRoutes = (config) => {
5572
5635
  if (client.requirePushedAuthorizationRequests === true && query.request_uri === undefined) {
5573
5636
  return errorRedirect("invalid_request");
5574
5637
  }
5638
+ if (client.requireSignedRequestObject === true && query.request === undefined && query.request_uri === undefined) {
5639
+ return errorRedirect("invalid_request_object");
5640
+ }
5575
5641
  if (responseType !== "code") {
5576
5642
  return errorRedirect("unsupported_response_type");
5577
5643
  }
@@ -5652,6 +5718,7 @@ var oidcProviderRoutes = (config) => {
5652
5718
  nonce: t12.Optional(t12.String()),
5653
5719
  prompt: t12.Optional(t12.String()),
5654
5720
  redirect_uri: t12.Optional(t12.String()),
5721
+ request: t12.Optional(t12.String()),
5655
5722
  request_uri: t12.Optional(t12.String()),
5656
5723
  response_type: t12.Optional(t12.String()),
5657
5724
  scope: t12.Optional(t12.String()),
@@ -21415,6 +21482,8 @@ var oauthClientsTable = pgTable("auth_oauth_clients", {
21415
21482
  name: varchar("name", { length: ID_LENGTH7 }).notNull(),
21416
21483
  post_logout_redirect_uris: text("post_logout_redirect_uris").array(),
21417
21484
  redirect_uris: text("redirect_uris").array().notNull(),
21485
+ require_pushed_authorization_requests: boolean("require_pushed_authorization_requests"),
21486
+ require_signed_request_object: boolean("require_signed_request_object"),
21418
21487
  scopes: text("scopes").array().notNull()
21419
21488
  });
21420
21489
  var oauthCodesTable = pgTable("auth_oauth_codes", {
@@ -21487,6 +21556,8 @@ var toClient2 = (row) => ({
21487
21556
  name: row.name,
21488
21557
  postLogoutRedirectUris: row.post_logout_redirect_uris ?? undefined,
21489
21558
  redirectUris: row.redirect_uris,
21559
+ requirePushedAuthorizationRequests: row.require_pushed_authorization_requests ?? undefined,
21560
+ requireSignedRequestObject: row.require_signed_request_object ?? undefined,
21490
21561
  scopes: row.scopes
21491
21562
  });
21492
21563
  var toLogoutDelivery = (row) => ({
@@ -21686,6 +21757,8 @@ var toClientValues2 = (client) => ({
21686
21757
  name: client.name,
21687
21758
  post_logout_redirect_uris: client.postLogoutRedirectUris ?? null,
21688
21759
  redirect_uris: client.redirectUris,
21760
+ require_pushed_authorization_requests: client.requirePushedAuthorizationRequests ?? null,
21761
+ require_signed_request_object: client.requireSignedRequestObject ?? null,
21689
21762
  scopes: client.scopes
21690
21763
  });
21691
21764
  var createPostgresOAuthClientStore = (db) => ({
@@ -22317,6 +22390,220 @@ var createPostgresWarrantStore = (db) => ({
22317
22390
  }).onConflictDoNothing({ target: warrantsTable.id });
22318
22391
  }
22319
22392
  });
22393
+ // src/sso/samlIdpRoutes.ts
22394
+ import { Elysia as Elysia35, t as t31 } from "elysia";
22395
+ var HTTP_BAD_REQUEST3 = 400;
22396
+ var HTTP_UNAUTHORIZED3 = 401;
22397
+ var HTTP_FOUND2 = 302;
22398
+ var HTTP_OK3 = 200;
22399
+ var xmlResponse = (body) => new Response(body, {
22400
+ headers: { "content-type": "application/samlmetadata+xml" },
22401
+ status: HTTP_OK3
22402
+ });
22403
+ var htmlResponse = (body) => new Response(body, {
22404
+ headers: { "content-type": "text/html; charset=utf-8" },
22405
+ status: HTTP_OK3
22406
+ });
22407
+ var redirectTo2 = (url) => new Response(null, { headers: { location: url }, status: HTTP_FOUND2 });
22408
+ var errorJson = (status, error) => new Response(JSON.stringify({ error }), {
22409
+ headers: { "content-type": "application/json" },
22410
+ status
22411
+ });
22412
+ var samlIdpRoutes = ({
22413
+ authSessionStore,
22414
+ getNameId,
22415
+ getSamlAttributes,
22416
+ idpAdapter,
22417
+ idpEntityId,
22418
+ loginUrl,
22419
+ samlServiceProviderStore,
22420
+ ssoRoute = DEFAULT_SSO_ROUTE
22421
+ }) => {
22422
+ const ssoIdpRoute = `${ssoRoute}/saml/idp/sso`;
22423
+ const idpInitiateRoute = `${ssoRoute}/saml/idp/sso/initiate`;
22424
+ const idpMetadataRoute = `${ssoRoute}/saml/idp/metadata`;
22425
+ const ssoUrlFor = (requestUrl) => `${new URL(requestUrl).origin}${ssoIdpRoute}`;
22426
+ const renderResponse = async ({
22427
+ acsUrl,
22428
+ inResponseTo,
22429
+ relayState,
22430
+ serviceProviderEntityId,
22431
+ user
22432
+ }) => {
22433
+ const samlResponse = await idpAdapter.createSamlResponse({
22434
+ acsUrl,
22435
+ attributes: getSamlAttributes?.(user),
22436
+ audience: serviceProviderEntityId,
22437
+ idpEntityId,
22438
+ inResponseTo,
22439
+ nameId: getNameId(user),
22440
+ sessionIndex: crypto.randomUUID()
22441
+ });
22442
+ const html2 = idpAdapter.buildAutoPostForm({
22443
+ acsUrl,
22444
+ relayState,
22445
+ samlResponse
22446
+ });
22447
+ return htmlResponse(html2);
22448
+ };
22449
+ const handleSpInitiated = async ({
22450
+ binding,
22451
+ body,
22452
+ inMemorySession,
22453
+ request,
22454
+ userSessionIdValue
22455
+ }) => {
22456
+ if (body.SAMLRequest === undefined) {
22457
+ return errorJson(HTTP_BAD_REQUEST3, "missing_saml_request");
22458
+ }
22459
+ let firstPass;
22460
+ try {
22461
+ firstPass = await idpAdapter.parseAuthnRequest({
22462
+ binding,
22463
+ samlRequest: body.SAMLRequest
22464
+ });
22465
+ } catch {
22466
+ return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
22467
+ }
22468
+ const serviceProvider = await samlServiceProviderStore.findServiceProvider(firstPass.issuer);
22469
+ if (serviceProvider === undefined) {
22470
+ return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
22471
+ }
22472
+ let parsed;
22473
+ try {
22474
+ parsed = await idpAdapter.parseAuthnRequest({
22475
+ binding,
22476
+ samlRequest: body.SAMLRequest,
22477
+ serviceProvider,
22478
+ signature: body.Signature,
22479
+ signatureAlgorithm: body.SigAlg,
22480
+ signedQueryString: binding === "Redirect" ? new URL(request.url).search.slice(1) : undefined
22481
+ });
22482
+ } catch {
22483
+ return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
22484
+ }
22485
+ const userSession = await loadSessionFromSource({
22486
+ authSessionStore,
22487
+ session: inMemorySession,
22488
+ userSessionId: userSessionIdValue
22489
+ });
22490
+ if (userSession === undefined || parsed.forceAuthn === true) {
22491
+ if (loginUrl === undefined) {
22492
+ return errorJson(HTTP_UNAUTHORIZED3, "login_required");
22493
+ }
22494
+ return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
22495
+ }
22496
+ return renderResponse({
22497
+ acsUrl: parsed.acsUrl ?? serviceProvider.acsUrl,
22498
+ inResponseTo: parsed.id,
22499
+ relayState: parsed.relayState ?? body.RelayState,
22500
+ serviceProviderEntityId: serviceProvider.entityId,
22501
+ user: userSession.user
22502
+ });
22503
+ };
22504
+ return new Elysia35().use(sessionStore()).post(ssoIdpRoute, async ({
22505
+ body,
22506
+ cookie: { user_session_id },
22507
+ request,
22508
+ store
22509
+ }) => handleSpInitiated({
22510
+ binding: "POST",
22511
+ body,
22512
+ inMemorySession: store.session,
22513
+ request,
22514
+ userSessionIdValue: user_session_id.value
22515
+ }), {
22516
+ body: t31.Object({
22517
+ RelayState: t31.Optional(t31.String()),
22518
+ SAMLRequest: t31.Optional(t31.String())
22519
+ }),
22520
+ cookie: t31.Cookie({
22521
+ user_session_id: t31.Optional(userSessionIdTypebox)
22522
+ })
22523
+ }).get(ssoIdpRoute, async ({
22524
+ cookie: { user_session_id },
22525
+ query,
22526
+ request,
22527
+ store
22528
+ }) => handleSpInitiated({
22529
+ binding: "Redirect",
22530
+ body: query,
22531
+ inMemorySession: store.session,
22532
+ request,
22533
+ userSessionIdValue: user_session_id.value
22534
+ }), {
22535
+ cookie: t31.Cookie({
22536
+ user_session_id: t31.Optional(userSessionIdTypebox)
22537
+ }),
22538
+ query: t31.Object({
22539
+ RelayState: t31.Optional(t31.String()),
22540
+ SAMLRequest: t31.Optional(t31.String()),
22541
+ SigAlg: t31.Optional(t31.String()),
22542
+ Signature: t31.Optional(t31.String())
22543
+ })
22544
+ }).get(idpInitiateRoute, async ({
22545
+ cookie: { user_session_id },
22546
+ query: { sp: serviceProviderEntityId, RelayState: relayState },
22547
+ request,
22548
+ store
22549
+ }) => {
22550
+ if (serviceProviderEntityId === undefined) {
22551
+ return errorJson(HTTP_BAD_REQUEST3, "missing_sp");
22552
+ }
22553
+ const serviceProvider = await samlServiceProviderStore.findServiceProvider(serviceProviderEntityId);
22554
+ if (serviceProvider === undefined) {
22555
+ return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
22556
+ }
22557
+ const userSession = authSessionStore === undefined ? await loadSessionFromSource({
22558
+ session: store.session,
22559
+ userSessionId: user_session_id.value
22560
+ }) : await loadSessionFromSource({
22561
+ authSessionStore,
22562
+ session: store.session,
22563
+ userSessionId: user_session_id.value
22564
+ });
22565
+ if (userSession === undefined) {
22566
+ if (loginUrl === undefined) {
22567
+ return errorJson(HTTP_UNAUTHORIZED3, "login_required");
22568
+ }
22569
+ return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
22570
+ }
22571
+ return renderResponse({
22572
+ acsUrl: serviceProvider.acsUrl,
22573
+ relayState,
22574
+ serviceProviderEntityId: serviceProvider.entityId,
22575
+ user: userSession.user
22576
+ });
22577
+ }, {
22578
+ cookie: t31.Cookie({
22579
+ user_session_id: t31.Optional(userSessionIdTypebox)
22580
+ }),
22581
+ query: t31.Object({
22582
+ RelayState: t31.Optional(t31.String()),
22583
+ sp: t31.Optional(t31.String())
22584
+ })
22585
+ }).get(idpMetadataRoute, async ({ request }) => xmlResponse(await idpAdapter.getIdpMetadata({
22586
+ entityId: idpEntityId,
22587
+ ssoUrl: ssoUrlFor(request.url)
22588
+ })));
22589
+ };
22590
+ // src/sso/inMemorySamlServiceProviderStore.ts
22591
+ var createInMemorySamlServiceProviderStore = () => {
22592
+ const providers2 = new Map;
22593
+ return {
22594
+ deleteServiceProvider: async (entityId) => {
22595
+ providers2.delete(entityId);
22596
+ },
22597
+ findServiceProvider: async (entityId) => {
22598
+ const found = providers2.get(entityId);
22599
+ return found ? { ...found } : undefined;
22600
+ },
22601
+ listServiceProviders: async () => Array.from(providers2.values()).map((serviceProvider) => ({ ...serviceProvider })),
22602
+ saveServiceProvider: async (serviceProvider) => {
22603
+ providers2.set(serviceProvider.entityId, { ...serviceProvider });
22604
+ }
22605
+ };
22606
+ };
22320
22607
  // src/sso/inMemorySsoConnectionStore.ts
22321
22608
  var cloneConnection = (value) => value.type === "oidc" ? {
22322
22609
  ...value,
@@ -22342,16 +22629,63 @@ var createInMemorySsoConnectionStore = () => {
22342
22629
  }
22343
22630
  };
22344
22631
  };
22345
- // src/sso/postgresSsoConnectionStore.ts
22632
+ // src/sso/postgresSamlServiceProviderStore.ts
22346
22633
  var ID_LENGTH10 = 255;
22634
+ var URL_LENGTH2 = 2048;
22635
+ var samlServiceProvidersTable = pgTable("auth_saml_service_providers", {
22636
+ acs_url: varchar("acs_url", { length: URL_LENGTH2 }).notNull(),
22637
+ created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22638
+ entity_id: varchar("entity_id", { length: URL_LENGTH2 }).primaryKey(),
22639
+ name_id_format: varchar("name_id_format", { length: ID_LENGTH10 }),
22640
+ signing_cert: text("signing_cert"),
22641
+ updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
22642
+ });
22643
+ var toServiceProvider = (row) => ({
22644
+ acsUrl: row.acs_url,
22645
+ createdAt: row.created_at_ms,
22646
+ entityId: row.entity_id,
22647
+ nameIdFormat: row.name_id_format ?? undefined,
22648
+ signingCert: row.signing_cert ?? undefined,
22649
+ updatedAt: row.updated_at_ms
22650
+ });
22651
+ var toValues2 = (serviceProvider) => ({
22652
+ acs_url: serviceProvider.acsUrl,
22653
+ created_at_ms: serviceProvider.createdAt,
22654
+ entity_id: serviceProvider.entityId,
22655
+ name_id_format: serviceProvider.nameIdFormat ?? null,
22656
+ signing_cert: serviceProvider.signingCert ?? null,
22657
+ updated_at_ms: serviceProvider.updatedAt
22658
+ });
22659
+ var createNeonSamlServiceProviderStore = (databaseUrl) => createPostgresSamlServiceProviderStore(createNeonDatabase(databaseUrl));
22660
+ var createPostgresSamlServiceProviderStore = (db) => ({
22661
+ deleteServiceProvider: async (entityId) => {
22662
+ await db.delete(samlServiceProvidersTable).where(eq(samlServiceProvidersTable.entity_id, entityId));
22663
+ },
22664
+ findServiceProvider: async (entityId) => {
22665
+ const [row] = await db.select().from(samlServiceProvidersTable).where(eq(samlServiceProvidersTable.entity_id, entityId)).limit(1);
22666
+ return row === undefined ? undefined : toServiceProvider(row);
22667
+ },
22668
+ listServiceProviders: async () => {
22669
+ const rows = await db.select().from(samlServiceProvidersTable);
22670
+ return rows.map(toServiceProvider);
22671
+ },
22672
+ saveServiceProvider: async (serviceProvider) => {
22673
+ await db.insert(samlServiceProvidersTable).values(toValues2(serviceProvider)).onConflictDoUpdate({
22674
+ set: toValues2(serviceProvider),
22675
+ target: samlServiceProvidersTable.entity_id
22676
+ });
22677
+ }
22678
+ });
22679
+ // src/sso/postgresSsoConnectionStore.ts
22680
+ var ID_LENGTH11 = 255;
22347
22681
  var TYPE_LENGTH2 = 16;
22348
22682
  var ssoConnectionsTable = pgTable("auth_sso_connections", {
22349
22683
  config: jsonb("config").$type().notNull(),
22350
- connection_id: varchar("connection_id", { length: ID_LENGTH10 }).primaryKey(),
22684
+ connection_id: varchar("connection_id", { length: ID_LENGTH11 }).primaryKey(),
22351
22685
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22352
22686
  enabled: boolean("enabled").notNull().default(true),
22353
22687
  organization_id: varchar("organization_id", {
22354
- length: ID_LENGTH10
22688
+ length: ID_LENGTH11
22355
22689
  }).notNull(),
22356
22690
  type: varchar("type", { length: TYPE_LENGTH2 }).$type().notNull(),
22357
22691
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
@@ -22418,7 +22752,7 @@ var toConnection = (row) => {
22418
22752
  };
22419
22753
  return connection;
22420
22754
  };
22421
- var toValues2 = (connection) => ({
22755
+ var toValues3 = (connection) => ({
22422
22756
  config: connection.config,
22423
22757
  connection_id: connection.connectionId,
22424
22758
  created_at_ms: connection.createdAt,
@@ -22448,7 +22782,7 @@ var createPostgresSsoConnectionStore = (db) => ({
22448
22782
  });
22449
22783
  },
22450
22784
  saveConnection: async (connection) => {
22451
- const values = toValues2(connection);
22785
+ const values = toValues3(connection);
22452
22786
  await db.insert(ssoConnectionsTable).values(values).onConflictDoUpdate({
22453
22787
  set: values,
22454
22788
  target: ssoConnectionsTable.connection_id
@@ -22477,18 +22811,18 @@ var createInMemoryWebAuthnCredentialStore = () => {
22477
22811
  };
22478
22812
  };
22479
22813
  // src/webauthn/postgresWebAuthnCredentialStore.ts
22480
- var ID_LENGTH11 = 255;
22814
+ var ID_LENGTH12 = 255;
22481
22815
  var DEVICE_TYPE_LENGTH = 32;
22482
22816
  var webauthnCredentialsTable = pgTable("auth_webauthn_credentials", {
22483
22817
  backed_up: boolean("backed_up"),
22484
22818
  counter: bigint("counter", { mode: "number" }).notNull().default(0),
22485
22819
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22486
- credential_id: varchar("credential_id", { length: ID_LENGTH11 }).primaryKey(),
22820
+ credential_id: varchar("credential_id", { length: ID_LENGTH12 }).primaryKey(),
22487
22821
  device_type: varchar("device_type", { length: DEVICE_TYPE_LENGTH }),
22488
22822
  last_used_at_ms: bigint("last_used_at_ms", { mode: "number" }),
22489
22823
  public_key: text("public_key").notNull(),
22490
22824
  transports: jsonb("transports").$type(),
22491
- user_id: varchar("user_id", { length: ID_LENGTH11 }).notNull()
22825
+ user_id: varchar("user_id", { length: ID_LENGTH12 }).notNull()
22492
22826
  });
22493
22827
  var toCredential = (row) => ({
22494
22828
  backedUp: row.backed_up ?? undefined,
@@ -22501,7 +22835,7 @@ var toCredential = (row) => ({
22501
22835
  transports: row.transports ?? undefined,
22502
22836
  userId: row.user_id
22503
22837
  });
22504
- var toValues3 = (credential) => ({
22838
+ var toValues4 = (credential) => ({
22505
22839
  backed_up: credential.backedUp ?? null,
22506
22840
  counter: credential.counter,
22507
22841
  created_at_ms: credential.createdAt,
@@ -22526,7 +22860,7 @@ var createPostgresWebAuthnCredentialStore = (db) => ({
22526
22860
  await db.delete(webauthnCredentialsTable).where(eq(webauthnCredentialsTable.credential_id, credentialId));
22527
22861
  },
22528
22862
  saveCredential: async (credential) => {
22529
- const values = toValues3(credential);
22863
+ const values = toValues4(credential);
22530
22864
  await db.insert(webauthnCredentialsTable).values(values).onConflictDoUpdate({
22531
22865
  set: values,
22532
22866
  target: webauthnCredentialsTable.credential_id
@@ -22581,41 +22915,41 @@ var createInMemoryOrganizationStore = () => {
22581
22915
  };
22582
22916
  };
22583
22917
  // src/organizations/postgresOrganizationStore.ts
22584
- var ID_LENGTH12 = 255;
22918
+ var ID_LENGTH13 = 255;
22585
22919
  var NAME_LENGTH = 255;
22586
22920
  var STATE_LENGTH = 16;
22587
22921
  var organizationInvitationsTable = pgTable("auth_organization_invitations", {
22588
22922
  accepted_at_ms: bigint("accepted_at_ms", { mode: "number" }),
22589
22923
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22590
- email: varchar("email", { length: ID_LENGTH12 }).notNull(),
22924
+ email: varchar("email", { length: ID_LENGTH13 }).notNull(),
22591
22925
  expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
22592
22926
  invitation_id: varchar("invitation_id", {
22593
- length: ID_LENGTH12
22927
+ length: ID_LENGTH13
22594
22928
  }).primaryKey(),
22595
- inviter_user_id: varchar("inviter_user_id", { length: ID_LENGTH12 }),
22929
+ inviter_user_id: varchar("inviter_user_id", { length: ID_LENGTH13 }),
22596
22930
  organization_id: varchar("organization_id", {
22597
- length: ID_LENGTH12
22931
+ length: ID_LENGTH13
22598
22932
  }).notNull(),
22599
22933
  roles: jsonb("roles").$type().notNull().default([]),
22600
22934
  state: varchar("state", { length: STATE_LENGTH }).$type().notNull().default("pending"),
22601
- token_hash: varchar("token_hash", { length: ID_LENGTH12 }).notNull().unique()
22935
+ token_hash: varchar("token_hash", { length: ID_LENGTH13 }).notNull().unique()
22602
22936
  });
22603
22937
  var organizationMembershipsTable = pgTable("auth_organization_memberships", {
22604
22938
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22605
22939
  organization_id: varchar("organization_id", {
22606
- length: ID_LENGTH12
22940
+ length: ID_LENGTH13
22607
22941
  }).notNull(),
22608
22942
  roles: jsonb("roles").$type().notNull().default([]),
22609
22943
  status: varchar("status", { length: STATE_LENGTH }).$type().notNull().default("active"),
22610
22944
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
22611
- user_id: varchar("user_id", { length: ID_LENGTH12 }).notNull()
22945
+ user_id: varchar("user_id", { length: ID_LENGTH13 }).notNull()
22612
22946
  }, (table) => [primaryKey({ columns: [table.organization_id, table.user_id] })]);
22613
22947
  var organizationsTable = pgTable("auth_organizations", {
22614
22948
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22615
22949
  metadata: jsonb("metadata").$type(),
22616
22950
  name: varchar("name", { length: NAME_LENGTH }).notNull(),
22617
22951
  organization_id: varchar("organization_id", {
22618
- length: ID_LENGTH12
22952
+ length: ID_LENGTH13
22619
22953
  }).primaryKey(),
22620
22954
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
22621
22955
  });
@@ -22789,12 +23123,12 @@ var createInMemoryRoleStore = () => {
22789
23123
  };
22790
23124
  };
22791
23125
  // src/roles/postgresRoleStore.ts
22792
- var ID_LENGTH13 = 255;
23126
+ var ID_LENGTH14 = 255;
22793
23127
  var SLUG_LENGTH = 128;
22794
23128
  var GLOBAL_SCOPE = "";
22795
23129
  var rolesTable = pgTable("auth_roles", {
22796
23130
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22797
- organization_id: varchar("organization_id", { length: ID_LENGTH13 }).notNull().default(GLOBAL_SCOPE),
23131
+ organization_id: varchar("organization_id", { length: ID_LENGTH14 }).notNull().default(GLOBAL_SCOPE),
22798
23132
  permissions: jsonb("permissions").$type().notNull().default([]),
22799
23133
  slug: varchar("slug", { length: SLUG_LENGTH }).notNull(),
22800
23134
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
@@ -22849,11 +23183,11 @@ var createInMemoryPasswordlessTokenStore = () => {
22849
23183
  };
22850
23184
  };
22851
23185
  // src/passwordless/postgresPasswordlessTokenStore.ts
22852
- var ID_LENGTH14 = 255;
23186
+ var ID_LENGTH15 = 255;
22853
23187
  var passwordlessTokensTable = pgTable("auth_passwordless_tokens", {
22854
- email: varchar("email", { length: ID_LENGTH14 }).notNull(),
23188
+ email: varchar("email", { length: ID_LENGTH15 }).notNull(),
22855
23189
  expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
22856
- token_hash: varchar("token_hash", { length: ID_LENGTH14 }).primaryKey()
23190
+ token_hash: varchar("token_hash", { length: ID_LENGTH15 }).primaryKey()
22857
23191
  });
22858
23192
  var toToken3 = (row) => ({
22859
23193
  email: row.email,
@@ -22893,14 +23227,14 @@ var createInMemoryWebhookDeliveryStore = () => {
22893
23227
  };
22894
23228
  };
22895
23229
  // src/webhooks/postgresStore.ts
22896
- var ID_LENGTH15 = 255;
22897
- var URL_LENGTH2 = 2048;
23230
+ var ID_LENGTH16 = 255;
23231
+ var URL_LENGTH3 = 2048;
22898
23232
  var DEFAULT_LIST_LIMIT4 = 100;
22899
23233
  var webhookDeliveriesTable = pgTable("auth_webhook_deliveries", {
22900
23234
  attempts: bigint("attempts", { mode: "number" }).notNull(),
22901
23235
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22902
- endpoint_url: varchar("endpoint_url", { length: URL_LENGTH2 }).notNull(),
22903
- envelope_id: varchar("envelope_id", { length: ID_LENGTH15 }).primaryKey(),
23236
+ endpoint_url: varchar("endpoint_url", { length: URL_LENGTH3 }).notNull(),
23237
+ envelope_id: varchar("envelope_id", { length: ID_LENGTH16 }).primaryKey(),
22904
23238
  envelope_json: jsonb("envelope_json").$type().notNull(),
22905
23239
  last_error: text("last_error"),
22906
23240
  last_status: bigint("last_status", { mode: "number" })
@@ -22955,19 +23289,19 @@ var createInMemorySetupSessionStore = () => {
22955
23289
  };
22956
23290
  };
22957
23291
  // src/portal/postgresSetupSessionStore.ts
22958
- var ID_LENGTH16 = 255;
23292
+ var ID_LENGTH17 = 255;
22959
23293
  var setupSessionsTable = pgTable("auth_setup_sessions", {
22960
23294
  capabilities: jsonb("capabilities").$type().notNull().default([]),
22961
23295
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
22962
- created_by: varchar("created_by", { length: ID_LENGTH16 }),
23296
+ created_by: varchar("created_by", { length: ID_LENGTH17 }),
22963
23297
  expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
22964
23298
  organization_id: varchar("organization_id", {
22965
- length: ID_LENGTH16
23299
+ length: ID_LENGTH17
22966
23300
  }).notNull(),
22967
23301
  setup_session_id: varchar("setup_session_id", {
22968
- length: ID_LENGTH16
23302
+ length: ID_LENGTH17
22969
23303
  }).primaryKey(),
22970
- token_hash: varchar("token_hash", { length: ID_LENGTH16 }).notNull().unique()
23304
+ token_hash: varchar("token_hash", { length: ID_LENGTH17 }).notNull().unique()
22971
23305
  });
22972
23306
  var toSession = (row) => ({
22973
23307
  capabilities: row.capabilities,
@@ -23073,7 +23407,7 @@ var auth = async ({
23073
23407
  const auditedOnCallbackSuccess = auditEmit ? composeCallbackAudit(onCallbackSuccess, auditEmit) : onCallbackSuccess;
23074
23408
  const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
23075
23409
  const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
23076
- return new Elysia35().use(sessionCleanup({
23410
+ return new Elysia36().use(sessionCleanup({
23077
23411
  authSessionStore,
23078
23412
  cleanupIntervalMs,
23079
23413
  maxSessions,
@@ -23119,42 +23453,42 @@ var auth = async ({
23119
23453
  ...auditedCredentials,
23120
23454
  authSessionStore,
23121
23455
  lockoutGuard
23122
- }) : new Elysia35).use(auditedMfa ? mfaRoutes({ ...auditedMfa, authSessionStore }) : new Elysia35).use(passwordless ? passwordlessRoutes({
23456
+ }) : new Elysia36).use(auditedMfa ? mfaRoutes({ ...auditedMfa, authSessionStore }) : new Elysia36).use(passwordless ? passwordlessRoutes({
23123
23457
  ...passwordless,
23124
23458
  authSessionStore,
23125
23459
  emit: auditEmit
23126
- }) : new Elysia35).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia35).use(sso ? oidcSsoRoutes({ ...sso, authSessionStore }) : new Elysia35).use(sso && sso.samlAdapter ? samlSsoRoutes({
23460
+ }) : new Elysia36).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia36).use(sso ? oidcSsoRoutes({ ...sso, authSessionStore }) : new Elysia36).use(sso && sso.samlAdapter ? samlSsoRoutes({
23127
23461
  ...sso,
23128
23462
  authSessionStore,
23129
23463
  samlAdapter: sso.samlAdapter
23130
- }) : new Elysia35).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
23464
+ }) : new Elysia36).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
23131
23465
  getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
23132
23466
  ssoConnectionStore: sso.ssoConnectionStore,
23133
23467
  ssoRoute: sso.ssoRoute
23134
- }) : new Elysia35).use(scim ? scimRoutes(scim) : new Elysia35).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia35).use(oidc ? oidcProviderRoutes({ ...oidc, authSessionStore }) : new Elysia35).use(organizations ? organizationRoutes({
23468
+ }) : new Elysia36).use(scim ? scimRoutes(scim) : new Elysia36).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia36).use(oidc ? oidcProviderRoutes({ ...oidc, authSessionStore }) : new Elysia36).use(organizations ? organizationRoutes({
23135
23469
  ...organizations,
23136
23470
  authSessionStore,
23137
23471
  emit: auditEmit
23138
- }) : new Elysia35).use(roles ? roleRoutes({
23472
+ }) : new Elysia36).use(roles ? roleRoutes({
23139
23473
  ...roles,
23140
23474
  authSessionStore,
23141
23475
  emit: auditEmit
23142
- }) : new Elysia35).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia35).use(webauthn ? webauthnRoutes({
23476
+ }) : new Elysia36).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia36).use(webauthn ? webauthnRoutes({
23143
23477
  ...webauthn,
23144
23478
  authSessionStore,
23145
23479
  emit: auditEmit
23146
- }) : new Elysia35).use(compliance ? complianceRoutes({
23480
+ }) : new Elysia36).use(compliance ? complianceRoutes({
23147
23481
  ...compliance,
23148
23482
  authSessionStore,
23149
23483
  emit: auditEmit
23150
- }) : new Elysia35).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
23484
+ }) : new Elysia36).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
23151
23485
  ...authorization,
23152
23486
  authSessionStore,
23153
23487
  emit: auditEmit
23154
- }) : new Elysia35).use(htmx ? createAuthHtmxRoutes({
23488
+ }) : new Elysia36).use(htmx ? createAuthHtmxRoutes({
23155
23489
  ...htmx,
23156
23490
  authSessionStore
23157
- }) : new Elysia35);
23491
+ }) : new Elysia36);
23158
23492
  };
23159
23493
  export {
23160
23494
  writeWarrant,
@@ -23169,6 +23503,7 @@ export {
23169
23503
  verifyRecaptcha,
23170
23504
  verifyPkce,
23171
23505
  verifyPassword,
23506
+ verifyJwtSignedByClient,
23172
23507
  verifyJwt,
23173
23508
  verifyIdTokenHint,
23174
23509
  verifyHcaptcha,
@@ -23205,6 +23540,8 @@ export {
23205
23540
  scimTokensTable,
23206
23541
  scimRoutes,
23207
23542
  samlSsoRoutes,
23543
+ samlServiceProvidersTable,
23544
+ samlIdpRoutes,
23208
23545
  rotateVaultKey,
23209
23546
  rotateMfaEncryptionKey,
23210
23547
  rolesTable,
@@ -23238,6 +23575,7 @@ export {
23238
23575
  pkceProviderOptions,
23239
23576
  passwordlessTokensTable,
23240
23577
  passwordlessRoutes,
23578
+ parseSignedRequestObject,
23241
23579
  parseSchema,
23242
23580
  organizationsTable,
23243
23581
  organizationRoutes,
@@ -23359,6 +23697,7 @@ export {
23359
23697
  createPostgresSsoConnectionStore,
23360
23698
  createPostgresSetupSessionStore,
23361
23699
  createPostgresScimTokenStore,
23700
+ createPostgresSamlServiceProviderStore,
23362
23701
  createPostgresRoleStore,
23363
23702
  createPostgresPushedAuthorizationRequestStore,
23364
23703
  createPostgresPasswordlessTokenStore,
@@ -23389,6 +23728,7 @@ export {
23389
23728
  createNeonSsoConnectionStore,
23390
23729
  createNeonSetupSessionStore,
23391
23730
  createNeonScimTokenStore,
23731
+ createNeonSamlServiceProviderStore,
23392
23732
  createNeonRoleStore,
23393
23733
  createNeonPushedAuthorizationRequestStore,
23394
23734
  createNeonPasswordlessTokenStore,
@@ -23425,6 +23765,7 @@ export {
23425
23765
  createInMemorySsoConnectionStore,
23426
23766
  createInMemorySetupSessionStore,
23427
23767
  createInMemoryScimTokenStore,
23768
+ createInMemorySamlServiceProviderStore,
23428
23769
  createInMemoryRoleStore,
23429
23770
  createInMemoryPushedAuthorizationRequestStore,
23430
23771
  createInMemoryPasswordlessTokenStore,
@@ -23515,5 +23856,5 @@ export {
23515
23856
  AuthIdentityConflictError
23516
23857
  };
23517
23858
 
23518
- //# debugId=2099933871462CB064756E2164756E21
23859
+ //# debugId=B31AA1D09BAE440964756E2164756E21
23519
23860
  //# sourceMappingURL=index.js.map