authhero 5.17.0 → 5.17.1

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 (41) hide show
  1. package/dist/authhero.cjs +4 -4
  2. package/dist/authhero.d.ts +192 -192
  3. package/dist/authhero.mjs +48 -48
  4. package/dist/stats.html +1 -1
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/authentication-flows/passwordless.d.ts +3 -3
  7. package/dist/types/emails/defaults/Layout.d.ts +1 -1
  8. package/dist/types/emails/defaults/PrimaryButton.d.ts +1 -1
  9. package/dist/types/emails/defaults/ResetEmail.d.ts +1 -1
  10. package/dist/types/emails/defaults/ResetEmailByCode.d.ts +1 -1
  11. package/dist/types/emails/defaults/UserInvitation.d.ts +1 -1
  12. package/dist/types/emails/defaults/VerifyEmail.d.ts +1 -1
  13. package/dist/types/emails/defaults/VerifyEmailByCode.d.ts +1 -1
  14. package/dist/types/emails/defaults/WelcomeEmail.d.ts +1 -1
  15. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  16. package/dist/types/index.d.ts +191 -191
  17. package/dist/types/routes/auth-api/index.d.ts +20 -20
  18. package/dist/types/routes/auth-api/passwordless.d.ts +12 -12
  19. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  20. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  21. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  22. package/dist/types/routes/management-api/actions.d.ts +1 -1
  23. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  24. package/dist/types/routes/management-api/clients.d.ts +7 -7
  25. package/dist/types/routes/management-api/connections.d.ts +1 -1
  26. package/dist/types/routes/management-api/email-templates.d.ts +14 -14
  27. package/dist/types/routes/management-api/forms.d.ts +119 -119
  28. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  29. package/dist/types/routes/management-api/index.d.ts +165 -165
  30. package/dist/types/routes/management-api/logs.d.ts +3 -3
  31. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  32. package/dist/types/routes/management-api/organizations.d.ts +1 -1
  33. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  34. package/dist/types/routes/management-api/users.d.ts +2 -2
  35. package/dist/types/routes/universal-login/common.d.ts +2 -2
  36. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  37. package/dist/types/routes/universal-login/u2-index.d.ts +6 -6
  38. package/dist/types/routes/universal-login/u2-routes.d.ts +6 -6
  39. package/dist/types/types/Hooks.d.ts +1 -1
  40. package/dist/types/types/IdToken.d.ts +1 -1
  41. package/package.json +5 -5
package/dist/authhero.mjs CHANGED
@@ -5076,7 +5076,7 @@ var $o = (e, t) => {
5076
5076
  }, ls = (e, t, n, r) => {
5077
5077
  let i = cs(t, n, r);
5078
5078
  e.header("Set-Cookie", i, { append: !0 });
5079
- }, us = "mpv55hkq", ds = /* @__PURE__ */ p({
5079
+ }, us = "mpxp0lcu", ds = /* @__PURE__ */ p({
5080
5080
  common: () => fs,
5081
5081
  consent: () => ps,
5082
5082
  default: () => xs,
@@ -23400,18 +23400,16 @@ var sO = {
23400
23400
  grant_types: ["authorization_code", "refresh_token"]
23401
23401
  },
23402
23402
  regular_web: {
23403
- token_endpoint_auth_method: "client_secret_basic",
23403
+ token_endpoint_auth_method: "client_secret_post",
23404
23404
  grant_types: ["authorization_code", "refresh_token"]
23405
23405
  },
23406
23406
  non_interactive: {
23407
- token_endpoint_auth_method: "client_secret_basic",
23407
+ token_endpoint_auth_method: "client_secret_post",
23408
23408
  grant_types: ["client_credentials"]
23409
23409
  }
23410
23410
  };
23411
23411
  function cO(e, t) {
23412
- let n = t.app_type;
23413
- if (typeof n != "string") return e;
23414
- let r = sO[n];
23412
+ let n = t.app_type, r = sO[typeof n == "string" ? n : "regular_web"];
23415
23413
  return r ? {
23416
23414
  ...e,
23417
23415
  token_endpoint_auth_method: "token_endpoint_auth_method" in t ? e.token_endpoint_auth_method : r.token_endpoint_auth_method,
@@ -30035,23 +30033,23 @@ function mP(e, t, n) {
30035
30033
  };
30036
30034
  }
30037
30035
  async function hP(e, t) {
30038
- let { authParams: n, user: r, client: i, session_id: a, organization: o, permissions: s, impersonatingUser: c } = t, l = t.auth_time;
30039
- if (l === void 0 && a && e.var.tenant_id) {
30036
+ let { authParams: n, user: r, client: i, session_id: a, organization: o, permissions: s, impersonatingUser: c, grantType: l } = t, u = t.auth_time;
30037
+ if (u === void 0 && a && e.var.tenant_id) {
30040
30038
  let t = await e.env.data.sessions.get(e.var.tenant_id, a);
30041
- t?.authenticated_at && (l = Math.floor(new Date(t.authenticated_at).getTime() / 1e3));
30039
+ t?.authenticated_at && (u = Math.floor(new Date(t.authenticated_at).getTime() / 1e3));
30042
30040
  }
30043
- let u = e.var.tenant_id, d = (await AD(e.env.data.keys, u ?? "", u ? e.env.signingKeyMode : "control-plane", { purpose: "sign" }))[0];
30044
- if (!d?.pkcs7 || !d.cert) throw new B(500, { message: "No signing key available" });
30045
- let f = Ok(d.pkcs7), p = await Lk(d.cert), m = um(e.env, e.var.custom_domain), h = n.audience ?? i.tenant.default_audience ?? `${m}userinfo`, g = n.claims?.userinfo ? Object.keys(n.claims.userinfo) : void 0, v = {
30046
- aud: h,
30041
+ let d = e.var.tenant_id, f = (await AD(e.env.data.keys, d ?? "", d ? e.env.signingKeyMode : "control-plane", { purpose: "sign" }))[0];
30042
+ if (!f?.pkcs7 || !f.cert) throw new B(500, { message: "No signing key available" });
30043
+ let p = Ok(f.pkcs7), m = await Lk(f.cert), h = um(e.env, e.var.custom_domain), g = n.audience ?? i.tenant.default_audience ?? `${h}userinfo`, v = n.claims?.userinfo ? Object.keys(n.claims.userinfo) : void 0, y = {
30044
+ aud: g,
30047
30045
  scope: n.scope || "",
30048
30046
  sub: r?.user_id || n.client_id,
30049
- iss: m,
30047
+ iss: h,
30050
30048
  tenant_id: e.var.tenant_id,
30051
30049
  sid: a,
30052
30050
  act: c ? { sub: c.user_id } : void 0,
30053
30051
  org_id: o ? o.id : void 0,
30054
- requested_userinfo_claims: g,
30052
+ requested_userinfo_claims: v,
30055
30053
  org_name: o && i.tenant.allow_organization_name_in_authentication_api ? o.name.toLowerCase() : void 0,
30056
30054
  permissions: s,
30057
30055
  ...t.customClaims
@@ -30059,26 +30057,26 @@ async function hP(e, t) {
30059
30057
  if (t.customClaims) {
30060
30058
  for (let e of pP) if (e in t.customClaims) throw Error(`Cannot overwrite reserved claim '${e}'`);
30061
30059
  }
30062
- let y = n.scope?.split(" ") || [], b = y.includes("openid"), x = (n.response_type ?? "").trim() === on.ID_TOKEN, S = i.auth0_conformant !== !1 || x, C = r && b ? {
30060
+ let b = n.scope?.split(" ") || [], x = b.includes("openid"), S = (n.response_type ?? "").trim() === on.ID_TOKEN, C = i.auth0_conformant !== !1 || S, w = r && x ? {
30063
30061
  aud: n.client_id,
30064
30062
  sub: r.user_id,
30065
- iss: m,
30063
+ iss: h,
30066
30064
  sid: a,
30067
30065
  nonce: n.nonce,
30068
- ...l === void 0 ? {} : { auth_time: l },
30066
+ ...u === void 0 ? {} : { auth_time: u },
30069
30067
  ...n.acr_values ? { acr: n.acr_values.split(" ")[0] } : {},
30070
- ...S ? Fj(r, y) : {},
30068
+ ...C ? Fj(r, b) : {},
30071
30069
  ...n.claims?.id_token ? Ij(r, Object.keys(n.claims.id_token)) : {},
30072
- ...x && n.claims?.userinfo ? Ij(r, Object.keys(n.claims.userinfo)) : {},
30070
+ ...S && n.claims?.userinfo ? Ij(r, Object.keys(n.claims.userinfo)) : {},
30073
30071
  act: c ? { sub: c.user_id } : void 0,
30074
30072
  org_id: o?.id,
30075
30073
  org_name: o?.name.toLowerCase()
30076
- } : void 0, w = bj({
30074
+ } : void 0, T = bj({
30077
30075
  loginSession: t.loginSession,
30078
30076
  authConnection: t.authConnection,
30079
30077
  ctxConnection: e.var.connection,
30080
30078
  user: r
30081
- }), T = await xj(e, e.var.tenant_id, w, r);
30079
+ }), ee = await xj(e, e.var.tenant_id, T, r);
30082
30080
  e.env.hooks?.onExecuteCredentialsExchange && await e.env.hooks.onExecuteCredentialsExchange({
30083
30081
  ctx: e,
30084
30082
  client: i,
@@ -30090,29 +30088,30 @@ async function hP(e, t) {
30090
30088
  url: e.req.url
30091
30089
  },
30092
30090
  scope: n.scope || "",
30093
- grant_type: "",
30094
- connection: T || (w ? {
30095
- id: w,
30096
- name: w,
30091
+ grant_type: l ?? "",
30092
+ organization: o,
30093
+ connection: ee || (T ? {
30094
+ id: T,
30095
+ name: T,
30097
30096
  strategy: r?.provider || "auth0"
30098
30097
  } : void 0)
30099
- }, mP(e, v, C));
30098
+ }, mP(e, y, w));
30100
30099
  {
30101
30100
  let { hooks: t } = await e.env.data.hooks.list(e.var.tenant_id, {
30102
30101
  q: "trigger_id:credentials-exchange",
30103
30102
  page: 0,
30104
30103
  per_page: 100,
30105
30104
  include_totals: !1
30106
- }), a = t.filter((e) => e.enabled && ZA(e)), o = mP(e, v, C);
30105
+ }), a = t.filter((e) => e.enabled && ZA(e)), s = mP(e, y, w);
30107
30106
  if (r) {
30108
30107
  for (let t of a) if (ZA(t)) try {
30109
- await $A(e, t.template_id, r, o);
30108
+ await $A(e, t.template_id, r, s);
30110
30109
  } catch (e) {
30111
30110
  if (e instanceof _) throw e;
30112
30111
  console.warn(`[credentials-exchange] Failed to execute template hook: ${t.template_id}`, e);
30113
30112
  }
30114
30113
  }
30115
- let s = mP(e, v, C), c = await zA(e, t, {
30114
+ let c = mP(e, y, w), u = await zA(e, t, {
30116
30115
  ctx: e,
30117
30116
  client: i,
30118
30117
  user: r,
@@ -30123,31 +30122,32 @@ async function hP(e, t) {
30123
30122
  url: e.req?.url || ""
30124
30123
  },
30125
30124
  scope: n.scope || "",
30126
- grant_type: "",
30127
- connection: T || (w ? {
30128
- id: w,
30129
- name: w,
30125
+ grant_type: l ?? "",
30126
+ organization: o,
30127
+ connection: ee || (T ? {
30128
+ id: T,
30129
+ name: T,
30130
30130
  strategy: r?.provider || "auth0"
30131
30131
  } : void 0)
30132
- }, s);
30133
- c && e.set("action_execution_id", c);
30132
+ }, c);
30133
+ u && e.set("action_execution_id", u);
30134
30134
  }
30135
- let ee = c ? 3600 : t.token_lifetime ?? 86400, E = {
30135
+ let E = c ? 3600 : t.token_lifetime ?? 86400, te = {
30136
30136
  includeIssuedTimestamp: !0,
30137
- expiresIn: new ap(ee, "s"),
30138
- headers: { kid: d.kid }
30139
- }, te = await op(p, f, v, E);
30140
- if (C) {
30137
+ expiresIn: new ap(E, "s"),
30138
+ headers: { kid: f.kid }
30139
+ }, ne = await op(m, p, y, te);
30140
+ if (w) {
30141
30141
  let e = (n.response_type ?? "").split(" ");
30142
- t.code && e.includes("code") && (C.c_hash = await zk(t.code, p)), e.includes("id_token") && e.includes("token") && (C.at_hash = await zk(te, p));
30142
+ t.code && e.includes("code") && (w.c_hash = await zk(t.code, m)), e.includes("id_token") && e.includes("token") && (w.at_hash = await zk(ne, m));
30143
30143
  }
30144
- let ne = C ? await op(p, f, C, E) : void 0;
30144
+ let D = w ? await op(m, p, w, te) : void 0;
30145
30145
  return {
30146
- access_token: te,
30146
+ access_token: ne,
30147
30147
  refresh_token: t.refresh_token,
30148
- id_token: ne,
30148
+ id_token: D,
30149
30149
  token_type: "Bearer",
30150
- expires_in: ee
30150
+ expires_in: E
30151
30151
  };
30152
30152
  }
30153
30153
  async function gP(e, t) {
@@ -69166,7 +69166,7 @@ var Une = {
69166
69166
  password: o,
69167
69167
  username: l.authParams.username
69168
69168
  });
69169
- if ("success" in d) return { redirect: `/u2/login/identifier?state=${encodeURIComponent(i)}&message=password_reset_success` };
69169
+ if ("success" in d) return { redirect: `${e.routePrefix}/login/identifier?state=${encodeURIComponent(i)}&message=password_reset_success` };
69170
69170
  let f = d.error === "code_expired" ? c.codeExpired() : d.error;
69171
69171
  return {
69172
69172
  error: f,
@@ -69366,7 +69366,7 @@ var Wne = {
69366
69366
  password: s,
69367
69367
  username: l.authParams.username
69368
69368
  });
69369
- if ("success" in u) return { redirect: `/u2/login/identifier?state=${encodeURIComponent(i)}&message=password_reset_success` };
69369
+ if ("success" in u) return { redirect: `${e.routePrefix}/login/identifier?state=${encodeURIComponent(i)}&message=password_reset_success` };
69370
69370
  let d = u.error === "code_expired" ? a.invalidCode() : u.error;
69371
69371
  return {
69372
69372
  error: d,