authhero 0.194.0 → 0.195.0

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.
@@ -11513,9 +11513,9 @@ export declare const openIDConfigurationSchema: z.ZodObject<{
11513
11513
  token_endpoint_auth_signing_alg_values_supported: string[];
11514
11514
  }>;
11515
11515
  export interface ListParams {
11516
- page: number;
11517
- per_page: number;
11518
- include_totals: boolean;
11516
+ page?: number;
11517
+ per_page?: number;
11518
+ include_totals?: boolean;
11519
11519
  q?: string;
11520
11520
  sort?: {
11521
11521
  sort_by: string;
@@ -12252,11 +12252,18 @@ export declare const signingKeySchema: z.ZodObject<{
12252
12252
  current_until: z.ZodOptional<z.ZodString>;
12253
12253
  revoked: z.ZodOptional<z.ZodBoolean>;
12254
12254
  revoked_at: z.ZodOptional<z.ZodString>;
12255
+ connection: z.ZodOptional<z.ZodString>;
12256
+ type: z.ZodEnum<[
12257
+ "jwt_signing",
12258
+ "saml_encryption"
12259
+ ]>;
12255
12260
  }, "strip", z.ZodTypeAny, {
12261
+ type: "jwt_signing" | "saml_encryption";
12256
12262
  kid: string;
12257
12263
  cert: string;
12258
12264
  fingerprint: string;
12259
12265
  thumbprint: string;
12266
+ connection?: string | undefined;
12260
12267
  revoked_at?: string | undefined;
12261
12268
  pkcs7?: string | undefined;
12262
12269
  current?: boolean | undefined;
@@ -12266,10 +12273,12 @@ export declare const signingKeySchema: z.ZodObject<{
12266
12273
  current_until?: string | undefined;
12267
12274
  revoked?: boolean | undefined;
12268
12275
  }, {
12276
+ type: "jwt_signing" | "saml_encryption";
12269
12277
  kid: string;
12270
12278
  cert: string;
12271
12279
  fingerprint: string;
12272
12280
  thumbprint: string;
12281
+ connection?: string | undefined;
12273
12282
  revoked_at?: string | undefined;
12274
12283
  pkcs7?: string | undefined;
12275
12284
  current?: boolean | undefined;
@@ -14623,9 +14632,12 @@ export interface CustomDomainsAdapter {
14623
14632
  remove: (tenant_id: string, id: string) => Promise<boolean>;
14624
14633
  update: (tenant_id: string, id: string, custom_domain: Partial<CustomDomain>) => Promise<boolean>;
14625
14634
  }
14635
+ export interface ListKeysResponse extends Totals {
14636
+ signingKeys: SigningKey[];
14637
+ }
14626
14638
  export interface KeysAdapter {
14627
14639
  create: (key: SigningKey) => Promise<void>;
14628
- list: () => Promise<SigningKey[]>;
14640
+ list: (params?: ListParams) => Promise<ListKeysResponse>;
14629
14641
  update: (kid: string, key: Partial<Omit<SigningKey, "kid">>) => Promise<boolean>;
14630
14642
  }
14631
14643
  export interface BrandingAdapter {
@@ -14706,12 +14718,8 @@ export interface UserPermissionsAdapter {
14706
14718
  remove(tenant_id: string, user_id: string, permissions: Pick<UserPermissionInsert, "resource_server_identifier" | "permission_name">[]): Promise<boolean>;
14707
14719
  list(tenant_id: string, user_id: string, params?: ListParams): Promise<UserPermissionWithDetailsList>;
14708
14720
  }
14709
- export interface ListRolesResponse {
14721
+ export interface ListRolesResponse extends Totals {
14710
14722
  roles: Role[];
14711
- totals?: Totals;
14712
- start: number;
14713
- limit: number;
14714
- length: number;
14715
14723
  }
14716
14724
  export interface RolesAdapter {
14717
14725
  create(tenantId: string, role: RoleInsert): Promise<Role>;
@@ -17964,10 +17972,12 @@ export declare function init(config: AuthHeroConfig): {
17964
17972
  };
17965
17973
  };
17966
17974
  output: {
17975
+ type: "jwt_signing" | "saml_encryption";
17967
17976
  kid: string;
17968
17977
  cert: string;
17969
17978
  fingerprint: string;
17970
17979
  thumbprint: string;
17980
+ connection?: string | undefined | undefined;
17971
17981
  revoked_at?: string | undefined | undefined;
17972
17982
  pkcs7?: string | undefined | undefined;
17973
17983
  current?: boolean | undefined | undefined;
@@ -17994,10 +18004,12 @@ export declare function init(config: AuthHeroConfig): {
17994
18004
  };
17995
18005
  };
17996
18006
  output: {
18007
+ type: "jwt_signing" | "saml_encryption";
17997
18008
  kid: string;
17998
18009
  cert: string;
17999
18010
  fingerprint: string;
18000
18011
  thumbprint: string;
18012
+ connection?: string | undefined | undefined;
18001
18013
  revoked_at?: string | undefined | undefined;
18002
18014
  pkcs7?: string | undefined | undefined;
18003
18015
  current?: boolean | undefined | undefined;
package/dist/authhero.mjs CHANGED
@@ -2363,7 +2363,13 @@ const ow = o.enum([
2363
2363
  description: "The date and time when the current key was rotated"
2364
2364
  }),
2365
2365
  revoked: o.boolean().optional().openapi({ description: "True if the key is revoked" }),
2366
- revoked_at: o.string().optional().openapi({ description: "The date and time when the key was revoked" })
2366
+ revoked_at: o.string().optional().openapi({ description: "The date and time when the key was revoked" }),
2367
+ connection: o.string().optional().openapi({
2368
+ description: "The connection identifier associated with the key"
2369
+ }),
2370
+ type: o.enum(["jwt_signing", "saml_encryption"]).openapi({
2371
+ description: "The type of the signing key"
2372
+ })
2367
2373
  });
2368
2374
  var hs = /* @__PURE__ */ ((t) => (t.RefreshToken = "refresh_token", t.AuthorizationCode = "authorization_code", t.ClientCredential = "client_credentials", t.Passwordless = "passwordless", t.Password = "password", t.OTP = "http://auth0.com/oauth/grant-type/passwordless/otp", t))(hs || {});
2369
2375
  const bm = o.object({
@@ -5933,7 +5939,7 @@ function Ib(t, e, n) {
5933
5939
  });
5934
5940
  }
5935
5941
  async function Tb(t, e, n, r, i) {
5936
- var g, A, m;
5942
+ var A, m, $;
5937
5943
  if (!n.redirect_uri)
5938
5944
  throw new O(400, {
5939
5945
  message: "Missing redirect_uri in authParams"
@@ -5942,38 +5948,40 @@ async function Tb(t, e, n, r, i) {
5942
5948
  throw new O(400, {
5943
5949
  message: "Missing email in user"
5944
5950
  });
5945
- const [s] = await t.env.data.keys.list();
5946
- if (!s)
5951
+ const { signingKeys: s } = await t.env.data.keys.list({
5952
+ q: "type:jwt_signing"
5953
+ }), [a] = s;
5954
+ if (!a)
5947
5955
  throw new O(500, {
5948
5956
  message: "No signing key found"
5949
5957
  });
5950
- if (!((g = e.addons) != null && g.samlp))
5958
+ if (!((A = e.addons) != null && A.samlp))
5951
5959
  throw new O(400, {
5952
5960
  message: `SAML Addon is not enabled for client ${e.id}`
5953
5961
  });
5954
- const { recipient: a, audience: l } = e.addons.samlp, u = n.state || "";
5955
- if (!a || !u || !r || !n.state)
5962
+ const { recipient: l, audience: u } = e.addons.samlp, d = n.state || "";
5963
+ if (!l || !d || !r || !n.state)
5956
5964
  throw new O(400, {
5957
5965
  message: "Missing recipient or inResponseTo"
5958
5966
  });
5959
- const d = JSON.parse(n.state), p = new URL(n.redirect_uri), h = await Ob(t, {
5967
+ const p = JSON.parse(n.state), h = new URL(n.redirect_uri), g = await Ob(t, {
5960
5968
  issuer: t.env.ISSUER,
5961
- audience: l || n.client_id,
5962
- destination: p.toString(),
5963
- inResponseTo: d.requestId,
5964
- userId: ((m = (A = r.app_metadata) == null ? void 0 : A.vimeo) == null ? void 0 : m.user_id) || r.user_id,
5969
+ audience: u || n.client_id,
5970
+ destination: h.toString(),
5971
+ inResponseTo: p.requestId,
5972
+ userId: (($ = (m = r.app_metadata) == null ? void 0 : m.vimeo) == null ? void 0 : $.user_id) || r.user_id,
5965
5973
  email: r.email,
5966
5974
  sessionIndex: i,
5967
5975
  signature: {
5968
- privateKeyPem: s.pkcs7,
5969
- cert: s.cert,
5970
- kid: s.kid
5976
+ privateKeyPem: a.pkcs7,
5977
+ cert: a.cert,
5978
+ kid: a.kid
5971
5979
  }
5972
5980
  });
5973
5981
  return Ib(
5974
- p.toString(),
5975
- h,
5976
- d.relayState
5982
+ h.toString(),
5983
+ g,
5984
+ p.relayState
5977
5985
  );
5978
5986
  }
5979
5987
  async function Ob(t, e) {
@@ -6313,7 +6321,9 @@ function _u(t, e) {
6313
6321
  const ch = ["sub", "iss", "aud", "exp", "nbf", "iat", "jti"];
6314
6322
  async function dc(t, e) {
6315
6323
  var k, S;
6316
- const { authParams: n, user: r, client: i, session_id: s } = e, l = (await t.env.data.keys.list()).filter(
6324
+ const { authParams: n, user: r, client: i, session_id: s } = e, { signingKeys: a } = await t.env.data.keys.list({
6325
+ q: "type:jwt_signing"
6326
+ }), l = a.filter(
6317
6327
  (b) => !b.revoked_at || new Date(b.revoked_at) > /* @__PURE__ */ new Date()
6318
6328
  ), u = l[l.length - 1];
6319
6329
  if (!(u != null && u.pkcs7))
@@ -16848,7 +16858,8 @@ async function Pd(t) {
16848
16858
  cert: l,
16849
16859
  thumbprint: d,
16850
16860
  fingerprint: u,
16851
- pkcs7: p
16861
+ pkcs7: p,
16862
+ type: "jwt_signing"
16852
16863
  };
16853
16864
  }
16854
16865
  function U4(t, e) {
@@ -16893,7 +16904,9 @@ const q4 = 1e3 * 60 * 60 * 24, V4 = new Ae().openapi(
16893
16904
  }
16894
16905
  }),
16895
16906
  async (t) => {
16896
- const n = (await t.env.data.keys.list()).filter((r) => "cert" in r).map((r) => r);
16907
+ const { signingKeys: e } = await t.env.data.keys.list({
16908
+ q: "type:jwt_signing"
16909
+ }), n = e.filter((r) => "cert" in r).map((r) => r);
16897
16910
  return t.json(n);
16898
16911
  }
16899
16912
  ).openapi(
@@ -16926,7 +16939,9 @@ const q4 = 1e3 * 60 * 60 * 24, V4 = new Ae().openapi(
16926
16939
  }
16927
16940
  }),
16928
16941
  async (t) => {
16929
- const { kid: e } = t.req.valid("param"), r = (await t.env.data.keys.list()).find((i) => i.kid === e);
16942
+ const { kid: e } = t.req.valid("param"), { signingKeys: n } = await t.env.data.keys.list({
16943
+ q: "type:jwt_signing"
16944
+ }), r = n.find((i) => i.kid === e);
16930
16945
  if (!r)
16931
16946
  throw new O(404, { message: "Key not found" });
16932
16947
  return t.json(r);
@@ -16953,7 +16968,9 @@ const q4 = 1e3 * 60 * 60 * 24, V4 = new Ae().openapi(
16953
16968
  }
16954
16969
  }),
16955
16970
  async (t) => {
16956
- const e = await t.env.data.keys.list();
16971
+ const { signingKeys: e } = await t.env.data.keys.list({
16972
+ q: "type:jwt_signing"
16973
+ });
16957
16974
  for await (const r of e)
16958
16975
  await t.env.data.keys.update(r.kid, {
16959
16976
  revoked_at: new Date(Date.now() + q4).toISOString()
@@ -16961,7 +16978,7 @@ const q4 = 1e3 * 60 * 60 * 24, V4 = new Ae().openapi(
16961
16978
  const n = await Pd({
16962
16979
  name: `CN=${t.env.ORGANIZATION_NAME}`
16963
16980
  });
16964
- return await t.env.data.keys.create(n), t.text("OK", { status: 201 });
16981
+ return await t.env.data.keys.create({ ...n, type: "jwt_signing" }), t.text("OK", { status: 201 });
16965
16982
  }
16966
16983
  ).openapi(
16967
16984
  V({
@@ -16996,7 +17013,7 @@ const q4 = 1e3 * 60 * 60 * 24, V4 = new Ae().openapi(
16996
17013
  const r = await Pd({
16997
17014
  name: `CN=${t.env.ORGANIZATION_NAME}`
16998
17015
  });
16999
- return await t.env.data.keys.create(r), t.text("OK");
17016
+ return await t.env.data.keys.create({ ...r, type: "jwt_signing" }), t.text("OK");
17000
17017
  }
17001
17018
  ), H4 = new Ae().openapi(
17002
17019
  V({
@@ -18296,7 +18313,9 @@ var gx = async (t, e, n = "HS256") => {
18296
18313
  return e.forEach((i) => i({ phase: yx.Stringify, buffer: n, context: r })), n[0];
18297
18314
  }, vx = V2.verify, bx = V2.decode;
18298
18315
  async function Ld(t) {
18299
- const e = await t.keys.list();
18316
+ const { signingKeys: e } = await t.keys.list({
18317
+ q: "type:jwt_signing"
18318
+ });
18300
18319
  return await Promise.all(
18301
18320
  e.map(async (r) => {
18302
18321
  const s = await new nl(r.cert).publicKey.export(), a = await crypto.subtle.exportKey("jwk", s);
@@ -18950,7 +18969,10 @@ function Tx(t) {
18950
18969
  }
18951
18970
  const ol = async (t, e) => {
18952
18971
  var l, u, d, p;
18953
- const n = (l = t.req.query("auth0Client")) == null ? void 0 : l.slice(0, 255), r = (u = t.req.header("x-real-ip")) == null ? void 0 : u.slice(0, 45), i = (d = t.req.header("user-agent")) == null ? void 0 : d.slice(0, 512), s = (p = t.req.header("cf-ipcountry")) == null ? void 0 : p.slice(0, 2), a = n ? Tx(n) : void 0;
18972
+ const n = (l = t.req.query("auth0Client")) == null ? void 0 : l.slice(0, 255), r = (
18973
+ // If the request is proxied, use x-forwarded-for, otherwise use cf-connecting-ip or x-real-ip
18974
+ (u = t.req.header("x-forwarded-host") && t.req.header("x-forwarded-for") ? t.req.header("x-forwarded-for") : t.req.header("cf-connecting-ip") || t.req.header("x-real-ip")) == null ? void 0 : u.slice(0, 45)
18975
+ ), i = (d = t.req.header("user-agent")) == null ? void 0 : d.slice(0, 512), s = (p = t.req.header("cf-ipcountry")) == null ? void 0 : p.slice(0, 2), a = n ? Tx(n) : void 0;
18954
18976
  a && t.set("auth0_client", a), r && t.set("ip", r), i && t.set("useragent", i), s && t.set("countryCode", s), await e();
18955
18977
  }, Dr = class Dr {
18956
18978
  constructor() {
@@ -36839,8 +36861,10 @@ const YE = new Ae().openapi(
36839
36861
  throw new O(404, {
36840
36862
  message: "Client not found"
36841
36863
  });
36842
- const r = await t.env.data.keys.list();
36843
- if (!r.length)
36864
+ const { signingKeys: r } = await t.env.data.keys.list({
36865
+ q: "type:jwt_signing"
36866
+ });
36867
+ if (r.length === 0)
36844
36868
  throw new O(500, {
36845
36869
  message: "No signing key found"
36846
36870
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authhero",
3
- "version": "0.194.0",
3
+ "version": "0.195.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -36,7 +36,7 @@
36
36
  "vite": "^5.4.11",
37
37
  "vite-plugin-dts": "^4.3.0",
38
38
  "vitest": "^2.1.5",
39
- "@authhero/kysely-adapter": "^10.36.0"
39
+ "@authhero/kysely-adapter": "^10.37.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "@peculiar/x509": "^1.12.3",
@@ -50,7 +50,7 @@
50
50
  "nanoid": "^5.0.8",
51
51
  "oslo": "^1.2.1",
52
52
  "xml-crypto": "^6.1.2",
53
- "@authhero/adapter-interfaces": "^0.82.0"
53
+ "@authhero/adapter-interfaces": "^0.83.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@hono/zod-openapi": "^0.19.2",