@absolutejs/auth 0.30.0-beta.4 → 0.30.0-beta.5

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.d.ts CHANGED
@@ -13454,6 +13454,7 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
13454
13454
  scope?: string | undefined;
13455
13455
  claims?: string | undefined;
13456
13456
  nonce?: string | undefined;
13457
+ request?: string | undefined;
13457
13458
  redirect_uri?: string | undefined;
13458
13459
  acr_values?: string | undefined;
13459
13460
  code_challenge?: string | undefined;
@@ -15120,7 +15121,9 @@ export { generateSigningKey, jwkThumbprint, signJwt, toPublicJwk, verifyJwt } fr
15120
15121
  export type { SigningKey } from './oidc/keys';
15121
15122
  export { extractDpopNonceClaim, mintDpopNonce, verifyDpopNonce, verifyDpopProof } from './oidc/dpop';
15122
15123
  export type { DpopResult } from './oidc/dpop';
15123
- export { CLIENT_ASSERTION_TYPE, verifyClientAssertion } from './oidc/clientAuth';
15124
+ export { CLIENT_ASSERTION_TYPE, verifyClientAssertion, verifyJwtSignedByClient } from './oidc/clientAuth';
15125
+ export { parseSignedRequestObject } from './oidc/jar';
15126
+ export type { JarParseResult } from './oidc/jar';
15124
15127
  export { createInMemoryAuthorizationCodeStore, createInMemoryClientAssertionJtiStore, createInMemoryClientRegistrationTokenStore, createInMemoryDeviceAuthorizationStore, createInMemoryInitialAccessTokenStore, createInMemoryLogoutDeliveryStore, createInMemoryOAuthClientStore, createInMemoryOidcRefreshTokenStore, createInMemoryPushedAuthorizationRequestStore } from './oidc/inMemoryStores';
15125
15128
  export { consumePushedRequest, pushAuthorizationRequest, DEFAULT_PAR_TTL_MS, REQUEST_URI_PREFIX } from './oidc/par';
15126
15129
  export { fetchUserInfo, readUserInfoBearer, userInfoChallengeHeader } from './oidc/userinfo';
package/dist/index.js CHANGED
@@ -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) => ({
@@ -23169,6 +23242,7 @@ export {
23169
23242
  verifyRecaptcha,
23170
23243
  verifyPkce,
23171
23244
  verifyPassword,
23245
+ verifyJwtSignedByClient,
23172
23246
  verifyJwt,
23173
23247
  verifyIdTokenHint,
23174
23248
  verifyHcaptcha,
@@ -23238,6 +23312,7 @@ export {
23238
23312
  pkceProviderOptions,
23239
23313
  passwordlessTokensTable,
23240
23314
  passwordlessRoutes,
23315
+ parseSignedRequestObject,
23241
23316
  parseSchema,
23242
23317
  organizationsTable,
23243
23318
  organizationRoutes,
@@ -23515,5 +23590,5 @@ export {
23515
23590
  AuthIdentityConflictError
23516
23591
  };
23517
23592
 
23518
- //# debugId=2099933871462CB064756E2164756E21
23593
+ //# debugId=36AE5503DAE3C8E864756E2164756E21
23519
23594
  //# sourceMappingURL=index.js.map