authhero 0.211.1 → 0.213.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.
package/dist/authhero.mjs CHANGED
@@ -1510,7 +1510,7 @@ const ew = o.object({
1510
1510
  nameIdentifierProbes: o.array(o.string()).optional(),
1511
1511
  authnContextClassRef: o.string().optional(),
1512
1512
  mappings: o.record(o.string()).optional()
1513
- }), mu = o.object({
1513
+ }), tw = o.object({
1514
1514
  id: o.string(),
1515
1515
  name: o.string(),
1516
1516
  callbacks: o.array(o.string()).default([]).optional().openapi({
@@ -1541,11 +1541,11 @@ const ew = o.object({
1541
1541
  description: "Prevents users from signing up using the hosted login page. This is not available in auth0"
1542
1542
  }),
1543
1543
  client_metadata: o.record(o.string().length(255)).optional()
1544
- }), vi = o.object({
1544
+ }), gG = o.object({
1545
1545
  created_at: o.string().transform((t) => t === null ? "" : t),
1546
1546
  updated_at: o.string().transform((t) => t === null ? "" : t),
1547
- ...mu.shape
1548
- }), tw = o.object({
1547
+ ...tw.shape
1548
+ }), mu = o.object({
1549
1549
  client_id: o.string().openapi({
1550
1550
  description: "ID of this client."
1551
1551
  }),
@@ -1712,10 +1712,10 @@ const ew = o.object({
1712
1712
  description: "Specifies how long, in seconds, a Pushed Authorization Request URI remains valid"
1713
1713
  }),
1714
1714
  token_quota: o.record(o.any()).default({}).optional()
1715
- }), gG = o.object({
1715
+ }), vi = o.object({
1716
1716
  created_at: o.string(),
1717
1717
  updated_at: o.string(),
1718
- ...tw.shape
1718
+ ...mu.shape
1719
1719
  }), io = o.object({
1720
1720
  x: o.number(),
1721
1721
  y: o.number()
@@ -1981,7 +1981,10 @@ const _a = o.object({
1981
1981
  o.object({
1982
1982
  ...vi.shape,
1983
1983
  tenant: xs,
1984
- connections: o.array(Sn)
1984
+ connections: o.array(Sn),
1985
+ // Legacy fields for backward compatibility - these are now stored in client_metadata
1986
+ disable_sign_ups: o.boolean(),
1987
+ email_validation: o.string()
1985
1988
  });
1986
1989
  const mw = o.enum([
1987
1990
  "password_reset",
@@ -4694,7 +4697,7 @@ let av = (t) => crypto.getRandomValues(new Uint8Array(t)), cv = (t, e, n) => {
4694
4697
  if (a += t[l[u] & r] || "", a.length === s) return a;
4695
4698
  }
4696
4699
  };
4697
- }, lv = (t, e = 21) => cv(t, e, av), Ve = (t = 21) => {
4700
+ }, lv = (t, e = 21) => cv(t, e, av), He = (t = 21) => {
4698
4701
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
4699
4702
  for (; t--; )
4700
4703
  e += ov[n[t] & 63];
@@ -4725,7 +4728,7 @@ function dv(t) {
4725
4728
  }), r) : t.users.create(e, n);
4726
4729
  };
4727
4730
  }
4728
- function He(t, e) {
4731
+ function Ve(t, e) {
4729
4732
  return {
4730
4733
  type: e.type,
4731
4734
  description: e.description || "",
@@ -6206,7 +6209,7 @@ async function Kb(t, e, n, r, i) {
6206
6209
  });
6207
6210
  if (!(($ = e.addons) != null && $.samlp))
6208
6211
  throw new E(400, {
6209
- message: `SAML Addon is not enabled for client ${e.id}`
6212
+ message: `SAML Addon is not enabled for client ${e.client_id}`
6210
6213
  });
6211
6214
  const { recipient: l, audience: u } = e.addons.samlp, d = n.state || "";
6212
6215
  if (!l || !d || !r || !n.state)
@@ -6234,7 +6237,7 @@ async function Kb(t, e, n, r, i) {
6234
6237
  );
6235
6238
  }
6236
6239
  async function Gb(t, e) {
6237
- const n = e.notBefore || (/* @__PURE__ */ new Date()).toISOString(), r = e.notAfter || new Date(new Date(n).getTime() + 10 * 60 * 1e3).toISOString(), i = e.issueInstant || n, s = e.sessionNotOnOrAfter || r, a = e.responseId || `_${Ve()}`, l = e.assertionId || `_${Ve()}`, u = [
6240
+ const n = e.notBefore || (/* @__PURE__ */ new Date()).toISOString(), r = e.notAfter || new Date(new Date(n).getTime() + 10 * 60 * 1e3).toISOString(), i = e.issueInstant || n, s = e.sessionNotOnOrAfter || r, a = e.responseId || `_${He()}`, l = e.assertionId || `_${He()}`, u = [
6238
6241
  {
6239
6242
  "samlp:Response": [
6240
6243
  {
@@ -6662,7 +6665,7 @@ async function mc(t, e) {
6662
6665
  async function Zm(t, e) {
6663
6666
  return {
6664
6667
  code: (await t.env.data.codes.create(e.client.tenant.id, {
6665
- code_id: Ve(),
6668
+ code_id: He(),
6666
6669
  user_id: e.user.user_id,
6667
6670
  code_type: "authorization_code",
6668
6671
  login_id: e.login_id,
@@ -6689,9 +6692,9 @@ async function Qm(t, e) {
6689
6692
  return await t.env.data.refreshTokens.create(
6690
6693
  n.tenant.id,
6691
6694
  {
6692
- id: Ve(),
6695
+ id: He(),
6693
6696
  session_id: s,
6694
- client_id: n.id,
6697
+ client_id: n.client_id,
6695
6698
  idle_expires_at: new Date(
6696
6699
  Date.now() + hc * 1e3
6697
6700
  ).toISOString(),
@@ -6717,7 +6720,7 @@ async function Qm(t, e) {
6717
6720
  }
6718
6721
  async function e_(t, { user: e, client: n, loginSession: r }) {
6719
6722
  const i = await t.env.data.sessions.create(n.tenant.id, {
6720
- id: Ve(),
6723
+ id: He(),
6721
6724
  user_id: e.user_id,
6722
6725
  login_session_id: r.id,
6723
6726
  idle_expires_at: new Date(
@@ -6732,7 +6735,7 @@ async function e_(t, { user: e, client: n, loginSession: r }) {
6732
6735
  initial_asn: "",
6733
6736
  last_asn: ""
6734
6737
  },
6735
- clients: [n.id]
6738
+ clients: [n.client_id]
6736
6739
  });
6737
6740
  return await t.env.data.loginSessions.update(n.tenant.id, r.id, {
6738
6741
  session_id: i.id
@@ -6742,7 +6745,7 @@ async function In(t, e) {
6742
6745
  var A, I;
6743
6746
  const { authParams: n, client: r, ticketAuth: i } = e;
6744
6747
  let { user: s } = e;
6745
- const a = n.response_type || cn.CODE, l = n.response_mode || Hn.QUERY, u = He(t, {
6748
+ const a = n.response_type || cn.CODE, l = n.response_mode || Hn.QUERY, u = Ve(t, {
6746
6749
  type: qe.SUCCESS_LOGIN,
6747
6750
  description: `Successful login for ${s.user_id}`,
6748
6751
  userId: s.user_id
@@ -6759,8 +6762,8 @@ async function In(t, e) {
6759
6762
  throw new E(500, {
6760
6763
  message: "Login session not found for ticket auth."
6761
6764
  });
6762
- const O = _v(), D = Ve(12), x = await t.env.data.codes.create(r.tenant.id, {
6763
- code_id: Ve(),
6765
+ const O = _v(), D = He(12), x = await t.env.data.codes.create(r.tenant.id, {
6766
+ code_id: He(),
6764
6767
  code_type: "ticket",
6765
6768
  login_id: e.loginSession.id,
6766
6769
  expires_at: new Date(Date.now() + xv).toISOString(),
@@ -6782,8 +6785,8 @@ async function In(t, e) {
6782
6785
  r.tenant.id,
6783
6786
  p
6784
6787
  );
6785
- O && !O.clients.includes(r.id) && await t.env.data.sessions.update(r.tenant.id, p, {
6786
- clients: [...O.clients, r.id]
6788
+ O && !O.clients.includes(r.client_id) && await t.env.data.sessions.update(r.tenant.id, p, {
6789
+ clients: [...O.clients, r.client_id]
6787
6790
  });
6788
6791
  } else if (!p) {
6789
6792
  if (!e.loginSession)
@@ -6933,16 +6936,32 @@ async function Yb(t, e, n) {
6933
6936
  const r = await t.env.data.tenants.get(e);
6934
6937
  if (!r)
6935
6938
  throw new Error(`Tenant not found: ${e}`);
6936
- return mc(t, {
6937
- client: {
6938
- id: t.env.ISSUER,
6939
- tenant: r,
6940
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
6941
- updated_at: (/* @__PURE__ */ new Date()).toISOString(),
6942
- name: t.env.ISSUER,
6943
- disable_sign_ups: !1,
6944
- connections: []
6939
+ const i = {
6940
+ client_id: t.env.ISSUER,
6941
+ tenant: r,
6942
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
6943
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
6944
+ name: t.env.ISSUER,
6945
+ global: !1,
6946
+ is_first_party: !1,
6947
+ oidc_conformant: !1,
6948
+ sso: !1,
6949
+ sso_disabled: !1,
6950
+ cross_origin_authentication: !1,
6951
+ custom_login_page_on: !1,
6952
+ require_pushed_authorization_requests: !1,
6953
+ require_proof_of_possession: !1,
6954
+ client_metadata: {
6955
+ disable_sign_ups: "false",
6956
+ email_validation: "disabled"
6945
6957
  },
6958
+ // Legacy fields extracted from metadata
6959
+ disable_sign_ups: !1,
6960
+ email_validation: "disabled",
6961
+ connections: []
6962
+ };
6963
+ return mc(t, {
6964
+ client: i,
6946
6965
  authParams: {
6947
6966
  client_id: t.env.ISSUER,
6948
6967
  response_type: cn.TOKEN,
@@ -6961,7 +6980,7 @@ async function t_(t, e, n) {
6961
6980
  },
6962
6981
  body: JSON.stringify(n)
6963
6982
  })).ok) {
6964
- const a = He(t, {
6983
+ const a = Ve(t, {
6965
6984
  type: qe.FAILED_HOOK,
6966
6985
  description: `Failed to invoke hook ${i.hook_id}`
6967
6986
  });
@@ -7070,7 +7089,7 @@ function n3(t, e) {
7070
7089
  }
7071
7090
  );
7072
7091
  } catch {
7073
- const p = He(t, {
7092
+ const p = Ve(t, {
7074
7093
  type: qe.FAILED_SIGNUP,
7075
7094
  description: "Pre user registration hook failed"
7076
7095
  });
@@ -7090,7 +7109,7 @@ function n3(t, e) {
7090
7109
  }
7091
7110
  );
7092
7111
  } catch {
7093
- const p = He(t, {
7112
+ const p = Ve(t, {
7094
7113
  type: qe.FAILED_SIGNUP,
7095
7114
  description: "Post user registration hook failed"
7096
7115
  });
@@ -7133,7 +7152,7 @@ function r3(t, e) {
7133
7152
  } catch (u) {
7134
7153
  if (u instanceof E)
7135
7154
  throw u;
7136
- const d = He(t, {
7155
+ const d = Ve(t, {
7137
7156
  type: qe.FAILED_HOOK,
7138
7157
  description: "Pre user update hook failed"
7139
7158
  });
@@ -7142,7 +7161,7 @@ function r3(t, e) {
7142
7161
  });
7143
7162
  }
7144
7163
  if (await e.users.update(n, r, i), i.email) {
7145
- const u = He(t, {
7164
+ const u = Ve(t, {
7146
7165
  type: qe.SUCCESS_CHANGE_EMAIL,
7147
7166
  description: `Email updated to ${i.email}`,
7148
7167
  userId: r
@@ -7161,7 +7180,7 @@ async function i3(t, e, n, r) {
7161
7180
  tenant_id: e.tenant.id,
7162
7181
  email: r
7163
7182
  })) {
7164
- const u = He(t, {
7183
+ const u = Ve(t, {
7165
7184
  type: qe.FAILED_SIGNUP,
7166
7185
  description: "Public signup is disabled"
7167
7186
  });
@@ -7241,7 +7260,7 @@ async function s3(t, e, n, r, i, s) {
7241
7260
  })
7242
7261
  });
7243
7262
  } catch {
7244
- const h = He(t, {
7263
+ const h = Ve(t, {
7245
7264
  type: qe.FAILED_HOOK,
7246
7265
  description: `Failed to invoke post-user-login webhook: ${d.url}`
7247
7266
  });
@@ -7585,7 +7604,7 @@ const xh = Qt.extend({
7585
7604
  last_login: (/* @__PURE__ */ new Date()).toISOString()
7586
7605
  });
7587
7606
  t.set("user_id", h.user_id);
7588
- const g = He(t, {
7607
+ const g = Ve(t, {
7589
7608
  type: qe.SUCCESS_API_OPERATION,
7590
7609
  description: "User created"
7591
7610
  });
@@ -17053,7 +17072,7 @@ async function Kd(t) {
17053
17072
  hash: "SHA-256",
17054
17073
  publicExponent: new Uint8Array([1, 0, 1]),
17055
17074
  modulusLength: 2048
17056
- }, n = await crypto.subtle.generateKey(e, !0, ["sign", "verify"]), r = Ve(), i = Eu(new TextEncoder().encode(r)), s = await r$.createSelfSigned({
17075
+ }, n = await crypto.subtle.generateKey(e, !0, ["sign", "verify"]), r = He(), i = Eu(new TextEncoder().encode(r)), s = await r$.createSelfSigned({
17057
17076
  serialNumber: i,
17058
17077
  name: t.name,
17059
17078
  notBefore: /* @__PURE__ */ new Date(),
@@ -17289,10 +17308,7 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17289
17308
  200: {
17290
17309
  content: {
17291
17310
  "application/json": {
17292
- schema: o.union([
17293
- l$,
17294
- o.array(vi)
17295
- ])
17311
+ schema: o.union([l$, o.array(vi)])
17296
17312
  }
17297
17313
  },
17298
17314
  description: "List of clients"
@@ -17300,13 +17316,13 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17300
17316
  }
17301
17317
  }),
17302
17318
  async (t) => {
17303
- const { "tenant-id": e } = t.req.valid("header"), { page: n, per_page: r, include_totals: i, sort: s, q: a } = t.req.valid("query"), u = (await t.env.data.applications.list(e, {
17319
+ const { "tenant-id": e } = t.req.valid("header"), { page: n, per_page: r, include_totals: i, sort: s, q: a } = t.req.valid("query"), u = (await t.env.data.clients.list(e, {
17304
17320
  page: n,
17305
17321
  per_page: r,
17306
17322
  include_totals: i,
17307
17323
  sort: bt(s),
17308
17324
  q: a
17309
- })).applications;
17325
+ })).clients;
17310
17326
  return i ? t.json({
17311
17327
  clients: u,
17312
17328
  start: 0,
@@ -17339,19 +17355,15 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17339
17355
  schema: vi
17340
17356
  }
17341
17357
  },
17342
- description: "An application"
17358
+ description: "A client"
17343
17359
  }
17344
17360
  }
17345
17361
  }),
17346
17362
  async (t) => {
17347
- const { "tenant-id": e } = t.req.valid("header"), { id: n } = t.req.valid("param"), i = (await t.env.data.applications.list(e, {
17348
- page: 1,
17349
- per_page: 0,
17350
- include_totals: !1
17351
- })).applications.find((s) => s.id === n);
17352
- if (!i)
17363
+ const { "tenant-id": e } = t.req.valid("header"), { id: n } = t.req.valid("param"), r = await t.env.data.clients.get(e, n);
17364
+ if (!r)
17353
17365
  throw new E(404);
17354
- return t.json(i);
17366
+ return t.json(r);
17355
17367
  }
17356
17368
  ).openapi(
17357
17369
  U({
@@ -17379,8 +17391,8 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17379
17391
  }),
17380
17392
  async (t) => {
17381
17393
  const { "tenant-id": e } = t.req.valid("header"), { id: n } = t.req.valid("param");
17382
- if (!await t.env.data.applications.remove(e, n))
17383
- throw new E(404, { message: "Application not found" });
17394
+ if (!await t.env.data.clients.remove(e, n))
17395
+ throw new E(404, { message: "Client not found" });
17384
17396
  return t.text("OK");
17385
17397
  }
17386
17398
  ).openapi(
@@ -17415,16 +17427,16 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17415
17427
  schema: vi
17416
17428
  }
17417
17429
  },
17418
- description: "The update application"
17430
+ description: "The updated client"
17419
17431
  }
17420
17432
  }
17421
17433
  }),
17422
17434
  async (t) => {
17423
17435
  const { "tenant-id": e } = t.req.valid("header"), { id: n } = t.req.valid("param"), i = t.req.valid("json");
17424
- await t.env.data.applications.update(e, n, i);
17425
- const s = await t.env.data.applications.get(e, n);
17436
+ await t.env.data.clients.update(e, n, i);
17437
+ const s = await t.env.data.clients.get(e, n);
17426
17438
  if (!s)
17427
- throw new E(404, { message: "Application not found" });
17439
+ throw new E(404, { message: "Client not found" });
17428
17440
  return t.json(s);
17429
17441
  }
17430
17442
  ).openapi(
@@ -17456,19 +17468,15 @@ const o$ = 1e3 * 60 * 60 * 24, a$ = new $e().openapi(
17456
17468
  schema: o.object(vi.shape)
17457
17469
  }
17458
17470
  },
17459
- description: "An application"
17471
+ description: "A client"
17460
17472
  }
17461
17473
  }
17462
17474
  }),
17463
17475
  async (t) => {
17464
17476
  const { "tenant-id": e } = t.req.valid("header"), n = t.req.valid("json"), r = {
17465
17477
  ...n,
17466
- id: n.id || Ve(),
17467
- client_secret: n.client_secret || Ve()
17468
- }, i = await t.env.data.applications.create(
17469
- e,
17470
- r
17471
- );
17478
+ client_secret: n.client_secret || He()
17479
+ }, i = await t.env.data.clients.create(e, r);
17472
17480
  return t.json(i, { status: 201 });
17473
17481
  }
17474
17482
  );
@@ -20355,7 +20363,7 @@ const Z$ = Qt.extend({
20355
20363
  async (t) => {
20356
20364
  const { "tenant-id": e } = t.req.valid("header"), n = t.req.valid("json"), r = {
20357
20365
  ...n,
20358
- id: n.id || Ve()
20366
+ id: n.id || He()
20359
20367
  }, i = await t.env.data.organizations.create(
20360
20368
  e,
20361
20369
  r
@@ -21541,7 +21549,7 @@ async function Rx(t, e) {
21541
21549
  n.kid,
21542
21550
  r,
21543
21551
  i
21544
- ), a = Ve(), l = await s.createAuthorizationURL(
21552
+ ), a = He(), l = await s.createAuthorizationURL(
21545
21553
  a,
21546
21554
  ((d = n.scope) == null ? void 0 : d.split(" ")) || ["name", "email"]
21547
21555
  );
@@ -21585,7 +21593,7 @@ async function Bx(t, e) {
21585
21593
  n.client_id,
21586
21594
  n.client_secret,
21587
21595
  r
21588
- ), s = Ve();
21596
+ ), s = He();
21589
21597
  return {
21590
21598
  redirectUrl: i.createAuthorizationURL(
21591
21599
  s,
@@ -21633,7 +21641,7 @@ async function Ux(t, e) {
21633
21641
  n.client_id,
21634
21642
  n.client_secret,
21635
21643
  r
21636
- ), s = Ve(), a = bx();
21644
+ ), s = He(), a = bx();
21637
21645
  return {
21638
21646
  redirectUrl: i.createAuthorizationURL(
21639
21647
  s,
@@ -21680,7 +21688,7 @@ async function zx(t, e) {
21680
21688
  n.client_id,
21681
21689
  n.client_secret,
21682
21690
  `${ut(t.env)}callback`
21683
- ), i = Ve(), s = r.createAuthorizationURL(
21691
+ ), i = He(), s = r.createAuthorizationURL(
21684
21692
  "https://api.vipps.no/access-management-1.0/access/oauth2/auth",
21685
21693
  i,
21686
21694
  ((a = n.scope) == null ? void 0 : a.split(" ")) || [
@@ -21809,8 +21817,8 @@ async function og(t, e, n, r) {
21809
21817
  throw new E(400, { message: "State not found" });
21810
21818
  const i = e.connections.find((u) => u.name === n);
21811
21819
  if (!i) {
21812
- t.set("client_id", e.id);
21813
- const u = He(t, {
21820
+ t.set("client_id", e.client_id);
21821
+ const u = Ve(t, {
21814
21822
  type: qe.FAILED_LOGIN,
21815
21823
  description: "Connection not found"
21816
21824
  });
@@ -21827,7 +21835,7 @@ async function og(t, e, n, r) {
21827
21835
  Date.now() + Ur * 1e3
21828
21836
  ).toISOString(),
21829
21837
  authParams: r,
21830
- csrf_token: Ve(),
21838
+ csrf_token: He(),
21831
21839
  ip: u,
21832
21840
  useragent: d,
21833
21841
  auth0Client: Zn(p)
@@ -21882,19 +21890,19 @@ async function ag(t, { code: e, state: n }) {
21882
21890
  r,
21883
21891
  s.authParams.client_id
21884
21892
  );
21885
- t.set("client_id", a.id), t.set("tenant_id", a.tenant.id);
21893
+ t.set("client_id", a.client_id), t.set("tenant_id", a.tenant.id);
21886
21894
  const l = a.connections.find(
21887
21895
  (I) => I.id === i.connection_id
21888
21896
  );
21889
21897
  if (!l) {
21890
- const I = He(t, {
21898
+ const I = Ve(t, {
21891
21899
  type: qe.FAILED_LOGIN,
21892
21900
  description: "Connection not found"
21893
21901
  });
21894
21902
  throw await r.data.logs.create(a.tenant.id, I), new E(403, { message: "Connection not found" });
21895
21903
  }
21896
21904
  if (t.set("connection", l.name), !s.authParams.redirect_uri) {
21897
- const I = He(t, {
21905
+ const I = Ve(t, {
21898
21906
  type: qe.FAILED_LOGIN,
21899
21907
  description: "Redirect URI not defined"
21900
21908
  });
@@ -21944,7 +21952,7 @@ async function cg(t, e, n, r, i, s) {
21944
21952
  const { redirect_uri: u } = l.authParams;
21945
21953
  if (!u)
21946
21954
  throw new E(400, { message: "Redirect uri not found" });
21947
- const d = He(t, {
21955
+ const d = Ve(t, {
21948
21956
  type: qe.FAILED_LOGIN,
21949
21957
  description: `Failed connection login: ${i} ${n}, ${r}`
21950
21958
  });
@@ -22218,7 +22226,7 @@ const Wx = new $e().openapi(
22218
22226
  }
22219
22227
  }
22220
22228
  }
22221
- const l = He(t, {
22229
+ const l = Ve(t, {
22222
22230
  type: qe.SUCCESS_LOGOUT,
22223
22231
  description: "User successfully logged out"
22224
22232
  });
@@ -22422,7 +22430,7 @@ async function Yx(t, e) {
22422
22430
  if (n.client_secret && !oa(n.client_secret, e.client_secret))
22423
22431
  throw new E(403, { message: "Invalid client credentials" });
22424
22432
  const r = {
22425
- client_id: n.id,
22433
+ client_id: n.client_id,
22426
22434
  scope: e.scope,
22427
22435
  audience: e.audience
22428
22436
  };
@@ -22506,7 +22514,7 @@ async function Qx(t, e) {
22506
22514
  response_mode: Hn.WEB_MESSAGE,
22507
22515
  // Pass through other relevant authParams from the loginSession or original request if necessary
22508
22516
  // For authorization_code grant, these are usually fixed or derived, not directly from params
22509
- client_id: n.id,
22517
+ client_id: n.client_id,
22510
22518
  // ensure client_id is from the validated client
22511
22519
  scope: i.authParams.scope,
22512
22520
  // scope from original authorization request
@@ -22571,7 +22579,7 @@ async function t5(t, e) {
22571
22579
  refresh_token: r.id,
22572
22580
  session_id: r.session_id,
22573
22581
  authParams: {
22574
- client_id: n.id,
22582
+ client_id: n.client_id,
22575
22583
  audience: s == null ? void 0 : s.audience,
22576
22584
  scope: s == null ? void 0 : s.scopes,
22577
22585
  response_mode: Hn.WEB_MESSAGE
@@ -24683,7 +24691,7 @@ async function wl(t, { to: e, code: n }) {
24683
24691
  code: n,
24684
24692
  from: r.name
24685
24693
  });
24686
- const l = He(t, {
24694
+ const l = Ve(t, {
24687
24695
  type: qe.CODE_LINK_SENT,
24688
24696
  description: e
24689
24697
  });
@@ -24739,7 +24747,7 @@ async function kf(t, { to: e, code: n, authParams: r }) {
24739
24747
  throw new E(400, {
24740
24748
  message: "Only email and SMS connections are supported for magic links"
24741
24749
  });
24742
- const u = He(t, {
24750
+ const u = Ve(t, {
24743
24751
  type: qe.CODE_LINK_SENT,
24744
24752
  description: e
24745
24753
  });
@@ -24846,7 +24854,7 @@ const mE = new $e().openapi(
24846
24854
  throw new E(400, {
24847
24855
  message: "Client not found"
24848
24856
  });
24849
- if (t.set("client_id", i.id), t.set("tenant_id", i.tenant.id), !Sf(n))
24857
+ if (t.set("client_id", i.client_id), t.set("tenant_id", i.tenant.id), !Sf(n))
24850
24858
  throw new E(400, {
24851
24859
  message: "Password does not meet the requirements"
24852
24860
  });
@@ -24872,7 +24880,7 @@ const mE = new $e().openapi(
24872
24880
  password: l,
24873
24881
  algorithm: "bcrypt"
24874
24882
  }), await Nf(t, a);
24875
- const u = He(t, {
24883
+ const u = Ve(t, {
24876
24884
  type: qe.SUCCESS_SIGNUP,
24877
24885
  description: "Successful signup"
24878
24886
  });
@@ -24914,7 +24922,7 @@ const mE = new $e().openapi(
24914
24922
  throw new E(400, {
24915
24923
  message: "Client not found"
24916
24924
  });
24917
- if (t.set("client_id", r.id), t.set("tenant_id", r.tenant.id), !await Gi({
24925
+ if (t.set("client_id", r.client_id), t.set("tenant_id", r.tenant.id), !await Gi({
24918
24926
  userAdapter: t.env.data.users,
24919
24927
  tenant_id: r.tenant.id,
24920
24928
  username: e,
@@ -24933,7 +24941,7 @@ const mE = new $e().openapi(
24933
24941
  Date.now() + Ur * 1e3
24934
24942
  ).toISOString(),
24935
24943
  authParams: s,
24936
- csrf_token: Ve(),
24944
+ csrf_token: He(),
24937
24945
  ip: t.get("ip"),
24938
24946
  useragent: t.get("useragent"),
24939
24947
  auth0Client: Zn(t.get("auth0_client"))
@@ -24997,13 +25005,13 @@ const _E = new $e().openapi(
24997
25005
  throw new E(400, {
24998
25006
  message: "Client not found"
24999
25007
  });
25000
- t.set("client_id", l.id), t.set("tenant_id", l.tenant.id);
25008
+ t.set("client_id", l.client_id), t.set("tenant_id", l.tenant.id);
25001
25009
  const u = a === "email" ? e.email : e.phone_number, d = t.get("ip"), p = t.get("useragent"), h = t.get("auth0_client"), g = Zn(h), $ = await n.data.loginSessions.create(
25002
25010
  l.tenant.id,
25003
25011
  {
25004
25012
  authParams: { ...s, client_id: r, username: u },
25005
25013
  expires_at: new Date(Date.now() + ea).toISOString(),
25006
- csrf_token: Ve(),
25014
+ csrf_token: He(),
25007
25015
  ip: d,
25008
25016
  useragent: p,
25009
25017
  auth0Client: g
@@ -25088,7 +25096,7 @@ const _E = new $e().openapi(
25088
25096
  response_type: d,
25089
25097
  nonce: p
25090
25098
  } = t.req.valid("query"), h = await ss(e, n);
25091
- t.set("client_id", h.id), t.set("tenant_id", h.tenant.id), t.set("connection", "email");
25099
+ t.set("client_id", h.client_id), t.set("tenant_id", h.tenant.id), t.set("connection", "email");
25092
25100
  const g = {
25093
25101
  client_id: n,
25094
25102
  redirect_uri: s,
@@ -25123,7 +25131,7 @@ const _E = new $e().openapi(
25123
25131
  username: r
25124
25132
  },
25125
25133
  expires_at: new Date(Date.now() + ea).toISOString(),
25126
- csrf_token: Ve(),
25134
+ csrf_token: He(),
25127
25135
  ip: A,
25128
25136
  useragent: I,
25129
25137
  auth0Client: D
@@ -25156,7 +25164,7 @@ async function E1(t, e, n, r) {
25156
25164
  provider: "auth2"
25157
25165
  });
25158
25166
  if (!a) {
25159
- const $ = He(t, {
25167
+ const $ = Ve(t, {
25160
25168
  type: qe.FAILED_LOGIN_INCORRECT_PASSWORD,
25161
25169
  description: "Invalid user"
25162
25170
  });
@@ -25174,7 +25182,7 @@ async function E1(t, e, n, r) {
25174
25182
  t.set("connection", a.connection), t.set("user_id", l.user_id);
25175
25183
  const u = await i.passwords.get(e.tenant.id, a.user_id);
25176
25184
  if (!(u && await so.compare(n.password, u.password))) {
25177
- const $ = He(t, {
25185
+ const $ = Ve(t, {
25178
25186
  type: qe.FAILED_LOGIN_INCORRECT_PASSWORD,
25179
25187
  description: "Invalid password"
25180
25188
  });
@@ -25191,7 +25199,7 @@ async function E1(t, e, n, r) {
25191
25199
  })).logs.filter(
25192
25200
  ($) => $.type === qe.FAILED_LOGIN_INCORRECT_PASSWORD && new Date($.date) > new Date(Date.now() - 1e3 * 60 * 5)
25193
25201
  ).length >= 3) {
25194
- const $ = He(t, {
25202
+ const $ = Ve(t, {
25195
25203
  // TODO: change to BLOCKED_ACCOUNT_EMAIL
25196
25204
  type: qe.FAILED_LOGIN,
25197
25205
  description: "Too many failed login attempts"
@@ -25203,7 +25211,7 @@ async function E1(t, e, n, r) {
25203
25211
  }
25204
25212
  if (!a.email_verified && e.email_validation === "enforced") {
25205
25213
  await Nf(t, a);
25206
- const $ = He(t, {
25214
+ const $ = Ve(t, {
25207
25215
  type: qe.FAILED_LOGIN,
25208
25216
  description: "Email not verified"
25209
25217
  });
@@ -25212,7 +25220,7 @@ async function E1(t, e, n, r) {
25212
25220
  code: "EMAIL_NOT_VERIFIED"
25213
25221
  });
25214
25222
  }
25215
- const g = He(t, {
25223
+ const g = Ve(t, {
25216
25224
  type: qe.SUCCESS_LOGIN,
25217
25225
  description: "Successful login",
25218
25226
  strategy_type: "Username-Password-Authentication",
@@ -25260,10 +25268,10 @@ async function yE(t, e, n, r) {
25260
25268
  Date.now() + Ev
25261
25269
  ).toISOString(),
25262
25270
  authParams: {
25263
- client_id: e.id,
25271
+ client_id: e.client_id,
25264
25272
  username: n
25265
25273
  },
25266
- csrf_token: Ve(),
25274
+ csrf_token: He(),
25267
25275
  ip: a,
25268
25276
  useragent: l,
25269
25277
  auth0Client: d
@@ -25347,7 +25355,7 @@ const wE = new $e().openapi(
25347
25355
  client_id: n,
25348
25356
  username: s
25349
25357
  },
25350
- csrf_token: Ve(),
25358
+ csrf_token: He(),
25351
25359
  ip: a,
25352
25360
  useragent: l,
25353
25361
  auth0Client: Zn(u)
@@ -25411,7 +25419,7 @@ async function vE({
25411
25419
  Date.now() + Ur * 1e3
25412
25420
  ).toISOString(),
25413
25421
  authParams: r,
25414
- csrf_token: Ve(),
25422
+ csrf_token: He(),
25415
25423
  authorization_url: a.toString(),
25416
25424
  ip: l,
25417
25425
  useragent: d,
@@ -25519,7 +25527,7 @@ async function xE({
25519
25527
  }) {
25520
25528
  const { env: h } = t, g = new URL(r), $ = `${g.protocol}//${g.host}`;
25521
25529
  async function A(K = "Login required") {
25522
- const W = He(t, {
25530
+ const W = Ve(t, {
25523
25531
  type: qe.FAILED_SILENT_AUTH,
25524
25532
  description: K
25525
25533
  });
@@ -25544,7 +25552,7 @@ async function xE({
25544
25552
  const D = {
25545
25553
  client: e,
25546
25554
  authParams: {
25547
- client_id: e.id,
25555
+ client_id: e.client_id,
25548
25556
  audience: u,
25549
25557
  code_challenge_method: a,
25550
25558
  code_challenge: l,
@@ -25574,7 +25582,7 @@ async function xE({
25574
25582
  Date.now() + hc * 1e3
25575
25583
  ).toISOString() : void 0
25576
25584
  });
25577
- const z = He(t, {
25585
+ const z = Ve(t, {
25578
25586
  type: qe.SUCCESS_SILENT_AUTH,
25579
25587
  description: "Successful silent authentication"
25580
25588
  });
@@ -25696,7 +25704,7 @@ const AE = ["email", "sms", "Username-Password-Authentication"], EE = new $e().o
25696
25704
  } = t.req.valid("query");
25697
25705
  t.set("log", "authorize");
25698
25706
  const M = await ss(e, n);
25699
- t.set("client_id", M.id), t.set("tenant_id", M.tenant.id);
25707
+ t.set("client_id", M.client_id), t.set("tenant_id", M.tenant.id);
25700
25708
  const K = {
25701
25709
  redirect_uri: i.split("#")[0],
25702
25710
  // Remove fragment if present
@@ -25822,7 +25830,7 @@ const AE = ["email", "sms", "Username-Password-Authentication"], EE = new $e().o
25822
25830
  const { env: e } = t, { client_id: n, redirect_url: r, login_hint: i, screen_hint: s } = t.req.valid("query");
25823
25831
  t.set("log", "account");
25824
25832
  const a = await ss(e, n);
25825
- t.set("client_id", a.id), t.set("tenant_id", a.tenant.id);
25833
+ t.set("client_id", a.client_id), t.set("tenant_id", a.tenant.id);
25826
25834
  const l = {
25827
25835
  redirect_uri: r || t.req.url,
25828
25836
  client_id: n,
@@ -25853,7 +25861,7 @@ const AE = ["email", "sms", "Username-Password-Authentication"], EE = new $e().o
25853
25861
  Date.now() + Ur * 1e3
25854
25862
  ).toISOString(),
25855
25863
  authParams: l,
25856
- csrf_token: Ve(),
25864
+ csrf_token: He(),
25857
25865
  authorization_url: g.toString(),
25858
25866
  ip: $,
25859
25867
  useragent: I,
@@ -26326,7 +26334,7 @@ async function ze(t, e, n = !1) {
26326
26334
  r,
26327
26335
  i.authParams.client_id
26328
26336
  );
26329
- t.set("client_id", s.id), t.set("tenant_id", s.tenant.id);
26337
+ t.set("client_id", s.client_id), t.set("tenant_id", s.tenant.id);
26330
26338
  const a = await r.data.tenants.get(s.tenant.id);
26331
26339
  if (a) {
26332
26340
  if (i.session_id && !n) {
@@ -26936,7 +26944,7 @@ const YE = (t, e) => {
26936
26944
  t,
26937
26945
  n
26938
26946
  );
26939
- t.set("client_id", i.id);
26947
+ t.set("client_id", i.client_id);
26940
26948
  const u = t.get("countryCode"), { normalized: d, connectionType: p } = yl(
26941
26949
  r.username,
26942
26950
  u
@@ -26966,7 +26974,7 @@ const YE = (t, e) => {
26966
26974
  try {
26967
26975
  await i3(t, i, t.env.data, d);
26968
26976
  } catch {
26969
- const O = He(t, {
26977
+ const O = Ve(t, {
26970
26978
  type: qe.FAILED_SIGNUP,
26971
26979
  description: "Public signup is disabled"
26972
26980
  });
@@ -27844,9 +27852,9 @@ const eo = (t) => {
27844
27852
  message: B.t("username_not_found_error") || "Username not found in session."
27845
27853
  });
27846
27854
  try {
27847
- t.set("client_id", s.id);
27855
+ t.set("client_id", s.client_id);
27848
27856
  const u = await xf(t, {
27849
- client_id: s.id,
27857
+ client_id: s.client_id,
27850
27858
  authParams: a.authParams,
27851
27859
  username: a.authParams.username,
27852
27860
  otp: n
@@ -29040,7 +29048,7 @@ const su = (t) => {
29040
29048
  className: "bg-gray-200/40 p-2 rounded-md hover:bg-gray-200/75",
29041
29049
  title: B.t("edit"),
29042
29050
  "aria-label": B.t("edit"),
29043
- href: l ? `/u/account/change-email?state=${encodeURIComponent(l)}` : `/u/account/change-email?client_id=${encodeURIComponent(i.id)}`,
29051
+ href: l ? `/u/account/change-email?state=${encodeURIComponent(l)}` : `/u/account/change-email?client_id=${encodeURIComponent(i.client_id)}`,
29044
29052
  children: /* @__PURE__ */ _(M8, {})
29045
29053
  }
29046
29054
  )
@@ -29166,7 +29174,7 @@ const su = (t) => {
29166
29174
  let u, d;
29167
29175
  try {
29168
29176
  if (r.action === "update_email" && r.email) {
29169
- const h = Ve();
29177
+ const h = He();
29170
29178
  await e.data.codes.create(a.tenant.id, {
29171
29179
  code_id: h,
29172
29180
  login_id: "",
@@ -29405,7 +29413,7 @@ const su = (t) => {
29405
29413
  }
29406
29414
  )
29407
29415
  );
29408
- const d = er(), p = Ve();
29416
+ const d = er(), p = He();
29409
29417
  return await e.data.codes.create(a.tenant.id, {
29410
29418
  code_id: p,
29411
29419
  login_id: "",
@@ -29465,7 +29473,7 @@ const su = (t) => {
29465
29473
  tt,
29466
29474
  {
29467
29475
  Component: "a",
29468
- href: l || (a ? `/u/account?state=${encodeURIComponent(a)}` : `/u/account?client_id=${encodeURIComponent(r.id)}`),
29476
+ href: l || (a ? `/u/account?state=${encodeURIComponent(a)}` : `/u/account?client_id=${encodeURIComponent(r.client_id)}`),
29469
29477
  className: "sm:mt-4 !text-base",
29470
29478
  children: [
29471
29479
  /* @__PURE__ */ _("span", { children: B.t("continue") }),
@@ -29534,7 +29542,7 @@ const su = (t) => {
29534
29542
  "a",
29535
29543
  {
29536
29544
  className: "block text-primary hover:text-primaryHover text-center",
29537
- href: a ? `/u/account?state=${encodeURIComponent(a)}` : `/u/account?client_id=${encodeURIComponent(r.id)}`,
29545
+ href: a ? `/u/account?state=${encodeURIComponent(a)}` : `/u/account?client_id=${encodeURIComponent(r.client_id)}`,
29538
29546
  children: B.t("go_back")
29539
29547
  }
29540
29548
  )
@@ -38555,7 +38563,7 @@ const kS = new $e().openapi(
38555
38563
  const i = r.map(
38556
38564
  (d) => new al(d.cert).toString("base64")
38557
38565
  ), s = t.env.ISSUER, a = SS({
38558
- entityId: ((u = (l = n.addons) == null ? void 0 : l.samlp) == null ? void 0 : u.audience) || n.id,
38566
+ entityId: ((u = (l = n.addons) == null ? void 0 : l.samlp) == null ? void 0 : u.audience) || n.client_id,
38559
38567
  certificates: i,
38560
38568
  assertionConsumerServiceUrl: `${s}samlp/${e}`,
38561
38569
  singleLogoutServiceUrl: `${s}samlp/${e}/logout`
@@ -38602,11 +38610,11 @@ const kS = new $e().openapi(
38602
38610
  throw new E(404, {
38603
38611
  message: "Client not found"
38604
38612
  });
38605
- t.set("client_id", i.id), t.set("tenant_id", i.tenant.id);
38613
+ t.set("client_id", i.client_id), t.set("tenant_id", i.tenant.id);
38606
38614
  const s = await ES(n), a = s["samlp:AuthnRequest"]["saml:Issuer"]["#text"], l = await t.env.data.loginSessions.create(
38607
38615
  t.var.tenant_id,
38608
38616
  {
38609
- csrf_token: Ve(),
38617
+ csrf_token: He(),
38610
38618
  authParams: {
38611
38619
  client_id: e,
38612
38620
  state: JSON.stringify({
@@ -40146,8 +40154,8 @@ export {
40146
40154
  N8 as UnverifiedEmailPage,
40147
40155
  OX as UserNotFoundPage,
40148
40156
  n8 as VippsLogo,
40149
- mu as applicationInsertSchema,
40150
- vi as applicationSchema,
40157
+ tw as applicationInsertSchema,
40158
+ gG as applicationSchema,
40151
40159
  mG as auth0FlowInsertSchema,
40152
40160
  gw as auth0FlowSchema,
40153
40161
  Un as auth0UserResponseSchema,
@@ -40156,8 +40164,8 @@ export {
40156
40164
  Tw as bordersSchema,
40157
40165
  oh as brandingSchema,
40158
40166
  rw as buttonComponentSchema,
40159
- tw as clientInsertSchema,
40160
- gG as clientSchema,
40167
+ mu as clientInsertSchema,
40168
+ vi as clientSchema,
40161
40169
  _w as codeInsertSchema,
40162
40170
  _G as codeSchema,
40163
40171
  mw as codeTypeSchema,