@authhero/kysely-adapter 10.126.0 → 10.126.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.
@@ -2,10 +2,10 @@ var $e = Object.defineProperty;
2
2
  var Ee = (e, t, a) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var K = (e, t, a) => Ee(e, typeof t != "symbol" ? t + "" : t, a);
4
4
  import { customAlphabet as Ie, nanoid as E } from "nanoid";
5
- import { parseUserId as ze, flowSchema as B, codeSchema as Pe, loginSessionSchema as De, LoginSessionState as le, promptSettingSchema as Ae, formSchema as q, resourceServerSchema as je } from "@authhero/adapter-interfaces";
5
+ import { parseUserId as ze, flowSchema as B, codeSchema as Pe, loginSessionSchema as De, LoginSessionState as le, promptSettingSchema as Ae, formSchema as q, resourceServerSchema as Fe } from "@authhero/adapter-interfaces";
6
6
  import "@hono/zod-openapi";
7
7
  import { sql as h, Migrator as de } from "kysely";
8
- const Fe = 17, Re = {
8
+ const je = 17, Re = {
9
9
  organization: "org_",
10
10
  connection: "con_",
11
11
  action: "act_",
@@ -16,30 +16,30 @@ const Fe = 17, Re = {
16
16
  guardian_factor: "gfa_",
17
17
  invite: "inv_"
18
18
  };
19
- function j(e) {
20
- const n = Ie("0123456789abcdefghijklmnopqrstuvwxyz", Fe)();
19
+ function F(e) {
20
+ const n = Ie("0123456789abcdefghijklmnopqrstuvwxyz", je)();
21
21
  return `${Re[e]}${n}`;
22
22
  }
23
23
  function Je() {
24
- return j("organization");
24
+ return F("organization");
25
25
  }
26
26
  function Me() {
27
- return j("connection");
27
+ return F("connection");
28
28
  }
29
29
  function Le() {
30
- return j("action");
30
+ return F("action");
31
31
  }
32
32
  function Ke() {
33
- return j("hook");
33
+ return F("hook");
34
34
  }
35
35
  function qe() {
36
- return j("resource_server");
36
+ return F("resource_server");
37
37
  }
38
38
  function Ue() {
39
- return j("hook_code");
39
+ return F("hook_code");
40
40
  }
41
41
  function Be() {
42
- return j("invite");
42
+ return F("invite");
43
43
  }
44
44
  function Qe(e) {
45
45
  return async (t, a) => {
@@ -87,7 +87,7 @@ function ue(e) {
87
87
  function D(e, t = (/* @__PURE__ */ new Date(0)).toISOString()) {
88
88
  return ue(e) ?? t;
89
89
  }
90
- function x(e) {
90
+ function T(e) {
91
91
  if (!e || e === "")
92
92
  return null;
93
93
  const t = new Date(e);
@@ -211,7 +211,7 @@ function k(e, t, a, n) {
211
211
  t = t.where(
212
212
  (g) => g.or(
213
213
  f.map(
214
- (y) => y === "user_id" ? g(p(y), "=", c) : g(p(y), "like", `%${c}%`)
214
+ (w) => w === "user_id" ? g(p(w), "=", c) : g(p(w), "like", `%${c}%`)
215
215
  )
216
216
  )
217
217
  );
@@ -240,9 +240,9 @@ function He(e) {
240
240
  updated_at_ts: p,
241
241
  deployed_at_ts: f,
242
242
  secrets: g,
243
- dependencies: y,
244
- supported_triggers: T,
245
- tenant_id: v,
243
+ dependencies: w,
244
+ supported_triggers: v,
245
+ tenant_id: C,
246
246
  ...N
247
247
  } = m, I = z({ created_at_ts: _, updated_at_ts: p }, [
248
248
  "created_at_ts",
@@ -257,10 +257,10 @@ function He(e) {
257
257
  deployed_at: f ? new Date(Number(f)).toISOString() : void 0,
258
258
  secrets: Y(g),
259
259
  dependencies: Y(
260
- y
260
+ w
261
261
  ),
262
262
  supported_triggers: Y(
263
- T
263
+ v
264
264
  )
265
265
  };
266
266
  });
@@ -377,22 +377,22 @@ function Xe(e) {
377
377
  };
378
378
  };
379
379
  }
380
- function w(e) {
380
+ function y(e) {
381
381
  if (e == null || typeof e != "object")
382
382
  return e;
383
383
  if (Array.isArray(e))
384
384
  return e.map(
385
385
  (a) => (
386
386
  // Only recurse into objects; leave primitives untouched
387
- a !== null && typeof a == "object" ? w(a) : a
387
+ a !== null && typeof a == "object" ? y(a) : a
388
388
  )
389
389
  );
390
390
  const t = { ...e };
391
391
  for (const a in t) {
392
392
  const n = t[a];
393
393
  n === null ? delete t[a] : n !== null && typeof n == "object" && (Array.isArray(n) ? t[a] = n.map(
394
- (o) => o !== null && typeof o == "object" ? w(o) : o
395
- ) : t[a] = w(n));
394
+ (o) => o !== null && typeof o == "object" ? y(o) : o
395
+ ) : t[a] = y(n));
396
396
  }
397
397
  return t;
398
398
  }
@@ -449,7 +449,7 @@ function et(e) {
449
449
  ...o.map((u) => U(u))
450
450
  ]
451
451
  };
452
- return w(i);
452
+ return y(i);
453
453
  };
454
454
  }
455
455
  function tt(e) {
@@ -462,9 +462,9 @@ function tt(e) {
462
462
  }
463
463
  const c = await u.offset(n * o).limit(o).selectAll().execute(), l = c.map((f) => f.user_id), m = l.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", l).orderBy("created_at", "asc").execute() : [], _ = c.map((f) => {
464
464
  const g = m.filter(
465
- (y) => y.linked_to === f.user_id
465
+ (w) => w.linked_to === f.user_id
466
466
  );
467
- return w({
467
+ return y({
468
468
  ...f,
469
469
  email_verified: f.email_verified === 1,
470
470
  phone_verified: f.phone_verified !== null ? f.phone_verified === 1 : void 0,
@@ -474,7 +474,7 @@ function tt(e) {
474
474
  address: f.address ? JSON.parse(f.address) : void 0,
475
475
  identities: [
476
476
  U(f, !0),
477
- ...g.map((y) => U(y))
477
+ ...g.map((w) => U(w))
478
478
  ]
479
479
  });
480
480
  });
@@ -606,7 +606,7 @@ function it(e) {
606
606
  ...n,
607
607
  actions: A(n.actions, [])
608
608
  };
609
- return B.parse(w(o));
609
+ return B.parse(y(o));
610
610
  };
611
611
  }
612
612
  function ct(e) {
@@ -619,7 +619,7 @@ function ct(e) {
619
619
  ...m,
620
620
  actions: A(m.actions, [])
621
621
  };
622
- return B.parse(w(_));
622
+ return B.parse(y(_));
623
623
  });
624
624
  if (!r)
625
625
  return {
@@ -689,7 +689,7 @@ function pe(e) {
689
689
  };
690
690
  return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(
691
691
  e.sandbox_versions_available
692
- )), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), w(t);
692
+ )), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), y(t);
693
693
  }
694
694
  function fe(e) {
695
695
  const t = { ...e };
@@ -963,10 +963,10 @@ function bt(e) {
963
963
  updated_at_ts: n,
964
964
  authenticated_at_ts: n,
965
965
  last_interaction_at_ts: n,
966
- expires_at_ts: x(s),
967
- idle_expires_at_ts: x(i),
968
- used_at_ts: x(u),
969
- revoked_at_ts: x(d),
966
+ expires_at_ts: T(s),
967
+ idle_expires_at_ts: T(i),
968
+ used_at_ts: T(u),
969
+ revoked_at_ts: T(d),
970
970
  device: JSON.stringify(c),
971
971
  clients: JSON.stringify(l)
972
972
  }).execute(), r;
@@ -982,9 +982,9 @@ function Ot(e) {
982
982
  device: n.device ? JSON.stringify(n.device) : void 0,
983
983
  clients: n.clients ? JSON.stringify(n.clients) : void 0
984
984
  };
985
- return n.expires_at !== void 0 && (o.expires_at_ts = x(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = x(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = x(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = x(
985
+ return n.expires_at !== void 0 && (o.expires_at_ts = T(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = T(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = T(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = T(
986
986
  n.last_interaction_at
987
- )), n.used_at !== void 0 && (o.used_at_ts = x(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = x(n.revoked_at)), n.user_id !== void 0 && (o.user_id = n.user_id), n.login_session_id !== void 0 && (o.login_session_id = n.login_session_id), !!(await e.updateTable("sessions").set(o).where("tenant_id", "=", t).where("sessions.id", "=", a).execute()).length;
987
+ )), n.used_at !== void 0 && (o.used_at_ts = T(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = T(n.revoked_at)), n.user_id !== void 0 && (o.user_id = n.user_id), n.login_session_id !== void 0 && (o.login_session_id = n.login_session_id), !!(await e.updateTable("sessions").set(o).where("tenant_id", "=", t).where("sessions.id", "=", a).execute()).length;
988
988
  };
989
989
  }
990
990
  function kt(e) {
@@ -1002,23 +1002,23 @@ function kt(e) {
1002
1002
  const {
1003
1003
  tenant_id: f,
1004
1004
  device: g,
1005
- clients: y,
1006
- created_at_ts: T,
1007
- updated_at_ts: v,
1005
+ clients: w,
1006
+ created_at_ts: v,
1007
+ updated_at_ts: C,
1008
1008
  expires_at_ts: N,
1009
1009
  idle_expires_at_ts: I,
1010
- authenticated_at_ts: C,
1010
+ authenticated_at_ts: x,
1011
1011
  last_interaction_at_ts: P,
1012
1012
  used_at_ts: ee,
1013
1013
  revoked_at_ts: Se,
1014
1014
  ...Oe
1015
1015
  } = p, ke = z(
1016
1016
  {
1017
- created_at_ts: T,
1018
- updated_at_ts: v,
1017
+ created_at_ts: v,
1018
+ updated_at_ts: C,
1019
1019
  expires_at_ts: N,
1020
1020
  idle_expires_at_ts: I,
1021
- authenticated_at_ts: C,
1021
+ authenticated_at_ts: x,
1022
1022
  last_interaction_at_ts: P,
1023
1023
  used_at_ts: ee,
1024
1024
  revoked_at_ts: Se
@@ -1035,7 +1035,7 @@ function kt(e) {
1035
1035
  ...Oe,
1036
1036
  ...ke,
1037
1037
  device: JSON.parse(g),
1038
- clients: JSON.parse(y)
1038
+ clients: JSON.parse(w)
1039
1039
  };
1040
1040
  });
1041
1041
  if (!r)
@@ -1126,7 +1126,7 @@ function At(e) {
1126
1126
  s && (i = k(e, i, s, ["code", "login_id"]));
1127
1127
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1128
1128
  const { tenant_id: _, ...p } = m;
1129
- return Pe.parse(w(p));
1129
+ return Pe.parse(y(p));
1130
1130
  });
1131
1131
  if (!r)
1132
1132
  return {
@@ -1144,7 +1144,7 @@ function At(e) {
1144
1144
  };
1145
1145
  };
1146
1146
  }
1147
- function jt(e) {
1147
+ function Ft(e) {
1148
1148
  return async (t, a) => {
1149
1149
  const n = {
1150
1150
  ...a,
@@ -1156,7 +1156,7 @@ function jt(e) {
1156
1156
  }).execute(), n;
1157
1157
  };
1158
1158
  }
1159
- function Ft(e) {
1159
+ function jt(e) {
1160
1160
  return async (t, a) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1161
1161
  }
1162
1162
  function Rt(e) {
@@ -1164,7 +1164,7 @@ function Rt(e) {
1164
1164
  let o = e.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", n);
1165
1165
  t.length && (o = o.where("codes.tenant_id", "=", t));
1166
1166
  const r = await o.selectAll().executeTakeFirst();
1167
- return r ? w(r) : null;
1167
+ return r ? y(r) : null;
1168
1168
  };
1169
1169
  }
1170
1170
  function Jt(e) {
@@ -1175,9 +1175,9 @@ function Mt(e) {
1175
1175
  }
1176
1176
  function Lt(e) {
1177
1177
  return {
1178
- create: jt(e),
1178
+ create: Ft(e),
1179
1179
  list: At(e),
1180
- remove: Ft(e),
1180
+ remove: jt(e),
1181
1181
  used: Jt(e),
1182
1182
  consume: Mt(e),
1183
1183
  get: Rt(e)
@@ -1203,7 +1203,7 @@ function Kt(e) {
1203
1203
  }
1204
1204
  function X(e) {
1205
1205
  const { is_system: t, ...a } = e;
1206
- return w({
1206
+ return y({
1207
1207
  ...a,
1208
1208
  is_system: t ? !0 : void 0,
1209
1209
  options: JSON.parse(e.options)
@@ -1335,7 +1335,7 @@ function Gt(e) {
1335
1335
  if (!n)
1336
1336
  return null;
1337
1337
  const { tenant_id: o, ...r } = n;
1338
- return w({
1338
+ return y({
1339
1339
  ...r,
1340
1340
  // Convert integer fields back to booleans
1341
1341
  global: !!n.global,
@@ -1379,7 +1379,7 @@ function Gt(e) {
1379
1379
  function Vt(e) {
1380
1380
  return async (t) => {
1381
1381
  const a = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
1382
- return a ? w({
1382
+ return a ? y({
1383
1383
  ...a,
1384
1384
  // Convert integer fields back to booleans
1385
1385
  global: !!a.global,
@@ -1646,7 +1646,7 @@ function ca(e) {
1646
1646
  created_at: n,
1647
1647
  updated_at: n
1648
1648
  };
1649
- return await e.insertInto("client_grants").values(u).execute(), w({
1649
+ return await e.insertInto("client_grants").values(u).execute(), y({
1650
1650
  id: o,
1651
1651
  tenant_id: t,
1652
1652
  ...i,
@@ -1679,7 +1679,7 @@ function la(e) {
1679
1679
  created_at: n.created_at,
1680
1680
  updated_at: n.updated_at
1681
1681
  };
1682
- return w(o);
1682
+ return y(o);
1683
1683
  };
1684
1684
  }
1685
1685
  function da(e) {
@@ -1687,14 +1687,14 @@ function da(e) {
1687
1687
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1688
1688
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1689
1689
  if (s) {
1690
- const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, y = g ? g[3] : "", T = /^(>=|>|<=|<)/.test(y || "");
1691
- if (g && !T && y) {
1692
- const v = !!g[1], N = g[2], { ref: I } = e.dynamic, C = I(`client_grants.${N}`);
1690
+ const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, w = g ? g[3] : "", v = /^(>=|>|<=|<)/.test(w || "");
1691
+ if (g && !v && w) {
1692
+ const C = !!g[1], N = g[2], { ref: I } = e.dynamic, x = I(`client_grants.${N}`);
1693
1693
  if (N === "allow_any_organization") {
1694
- const P = y === "true" ? 1 : 0;
1695
- v ? u = u.where(C, "!=", P) : u = u.where(C, "=", P);
1694
+ const P = w === "true" ? 1 : 0;
1695
+ C ? u = u.where(x, "!=", P) : u = u.where(x, "=", P);
1696
1696
  } else
1697
- v ? u = u.where(C, "!=", y) : u = u.where(C, "=", y);
1697
+ C ? u = u.where(x, "!=", w) : u = u.where(x, "=", w);
1698
1698
  } else
1699
1699
  u = k(e, u, _, []);
1700
1700
  }
@@ -1720,7 +1720,7 @@ function da(e) {
1720
1720
  created_at: _.created_at,
1721
1721
  updated_at: _.updated_at
1722
1722
  };
1723
- return w(p);
1723
+ return y(p);
1724
1724
  });
1725
1725
  if (!r)
1726
1726
  return {
@@ -1920,7 +1920,7 @@ function ba(e) {
1920
1920
  font_url: d,
1921
1921
  ...c
1922
1922
  } = a;
1923
- return w({
1923
+ return y({
1924
1924
  ...c,
1925
1925
  colors: {
1926
1926
  primary: o,
@@ -1937,7 +1937,7 @@ function ba(e) {
1937
1937
  }
1938
1938
  function Sa(e) {
1939
1939
  return async (t, a) => {
1940
- var s, i, u, d, c, l, m, _, p, f, g, y, T, v, N, I, C, P;
1940
+ var s, i, u, d, c, l, m, _, p, f, g, w, v, C, N, I, x, P;
1941
1941
  const { colors: n, font: o, ...r } = a;
1942
1942
  try {
1943
1943
  await e.insertInto("branding").values({
@@ -1955,9 +1955,9 @@ function Sa(e) {
1955
1955
  ...r,
1956
1956
  colors_primary: n == null ? void 0 : n.primary,
1957
1957
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1958
- colors_page_background_start: (T = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : T.start,
1959
- colors_page_background_end: (N = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : N.end,
1960
- colors_page_background_angle_dev: (C = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : C.angle_deg,
1958
+ colors_page_background_start: (v = (w = a.colors) == null ? void 0 : w.page_background) == null ? void 0 : v.start,
1959
+ colors_page_background_end: (N = (C = a.colors) == null ? void 0 : C.page_background) == null ? void 0 : N.end,
1960
+ colors_page_background_angle_dev: (x = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : x.angle_deg,
1961
1961
  font_url: (P = a.font) == null ? void 0 : P.url
1962
1962
  }).where("tenant_id", "=", t).execute();
1963
1963
  }
@@ -2023,15 +2023,15 @@ function za(e) {
2023
2023
  enabled: p,
2024
2024
  synchronous: f,
2025
2025
  created_at_ts: g,
2026
- updated_at_ts: y,
2027
- ...T
2028
- } = m, v = z({ created_at_ts: g, updated_at_ts: y }, [
2026
+ updated_at_ts: w,
2027
+ ...v
2028
+ } = m, C = z({ created_at_ts: g, updated_at_ts: w }, [
2029
2029
  "created_at_ts",
2030
2030
  "updated_at_ts"
2031
2031
  ]);
2032
- return w({
2033
- ...T,
2032
+ return y({
2034
2033
  ...v,
2034
+ ...C,
2035
2035
  enabled: !!p,
2036
2036
  synchronous: !!f
2037
2037
  });
@@ -2066,7 +2066,7 @@ function Pa(e) {
2066
2066
  "created_at_ts",
2067
2067
  "updated_at_ts"
2068
2068
  ]);
2069
- return w({
2069
+ return y({
2070
2070
  ...i,
2071
2071
  ...u,
2072
2072
  enabled: !!i.enabled,
@@ -2098,7 +2098,7 @@ function Aa(e) {
2098
2098
  };
2099
2099
  };
2100
2100
  }
2101
- function ja(e) {
2101
+ function Fa(e) {
2102
2102
  return async (t, a, n) => {
2103
2103
  const { hook_id: o, ...r } = n, s = {
2104
2104
  ...r,
@@ -2109,12 +2109,12 @@ function ja(e) {
2109
2109
  return await e.updateTable("hooks").set(s).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", t).execute(), !0;
2110
2110
  };
2111
2111
  }
2112
- function Fa(e) {
2112
+ function ja(e) {
2113
2113
  return {
2114
2114
  create: Aa(e),
2115
2115
  get: Pa(e),
2116
2116
  list: za(e),
2117
- update: ja(e),
2117
+ update: Fa(e),
2118
2118
  remove: Da(e)
2119
2119
  };
2120
2120
  }
@@ -2212,7 +2212,7 @@ function Ba(e) {
2212
2212
  fonts_subtitle_bold: !!n.fonts_subtitle_bold,
2213
2213
  fonts_title_bold: !!n.fonts_title_bold
2214
2214
  };
2215
- return w(
2215
+ return y(
2216
2216
  _e(o, [
2217
2217
  "widget",
2218
2218
  "colors",
@@ -2250,7 +2250,7 @@ function Ha(e) {
2250
2250
  );
2251
2251
  return De.parse(
2252
2252
  _e(
2253
- w({
2253
+ y({
2254
2254
  ...i,
2255
2255
  ...u,
2256
2256
  state: n.state || le.PENDING,
@@ -2311,7 +2311,7 @@ function Za(e) {
2311
2311
  updated_at_ts: Date.now(),
2312
2312
  // Only update expires_at_ts if a new expires_at was provided
2313
2313
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2314
- ...s !== void 0 ? { expires_at_ts: x(s) } : {}
2314
+ ...s !== void 0 ? { expires_at_ts: T(s) } : {}
2315
2315
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2316
2316
  };
2317
2317
  }
@@ -2329,7 +2329,7 @@ function tn(e) {
2329
2329
  function an(e) {
2330
2330
  return async (t) => {
2331
2331
  const [a] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
2332
- return w({
2332
+ return y({
2333
2333
  identifier_first: !!(a != null && a.identifier_first),
2334
2334
  password_first: !!(a != null && a.password_first),
2335
2335
  webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
@@ -2338,7 +2338,7 @@ function an(e) {
2338
2338
  };
2339
2339
  }
2340
2340
  function oe(e) {
2341
- return w({
2341
+ return y({
2342
2342
  ...e,
2343
2343
  webauthn_platform_first_factor: e.webauthn_platform_first_factor ? !!e.webauthn_platform_first_factor : void 0,
2344
2344
  identifier_first: e.identifier_first ? !!e.identifier_first : void 0,
@@ -2377,7 +2377,7 @@ function rn(e) {
2377
2377
  enabled: s,
2378
2378
  ...i
2379
2379
  } = a;
2380
- return w({
2380
+ return y({
2381
2381
  ...i,
2382
2382
  credentials: JSON.parse(o),
2383
2383
  settings: JSON.parse(r),
@@ -2467,18 +2467,26 @@ function _n(e) {
2467
2467
  resource_servers: d,
2468
2468
  rotating: c,
2469
2469
  ...l
2470
- } = a, m = Date.now();
2471
- return await e.insertInto("refresh_tokens").values({
2472
- ...l,
2473
- tenant_id: t,
2474
- rotating: c ? 1 : 0,
2475
- device: JSON.stringify(u),
2476
- resource_servers: JSON.stringify(d),
2477
- created_at_ts: m,
2478
- expires_at_ts: x(r),
2479
- idle_expires_at_ts: s ? x(s) : null,
2480
- last_exchanged_at_ts: i ? x(i) : null
2481
- }).execute(), { ...a, ...o };
2470
+ } = a, m = Date.now(), _ = T(r), p = s ? T(s) : null, f = Math.max(
2471
+ _ ?? 0,
2472
+ p ?? 0
2473
+ );
2474
+ return await e.transaction().execute(async (g) => {
2475
+ await g.insertInto("refresh_tokens").values({
2476
+ ...l,
2477
+ tenant_id: t,
2478
+ rotating: c ? 1 : 0,
2479
+ device: JSON.stringify(u),
2480
+ resource_servers: JSON.stringify(d),
2481
+ created_at_ts: m,
2482
+ expires_at_ts: _,
2483
+ idle_expires_at_ts: p,
2484
+ last_exchanged_at_ts: i ? T(i) : null
2485
+ }).execute(), f > 0 && a.login_id && await g.updateTable("login_sessions").set({
2486
+ expires_at_ts: f,
2487
+ updated_at_ts: m
2488
+ }).where("tenant_id", "=", t).where("id", "=", a.login_id).where("expires_at_ts", "<", f).execute();
2489
+ }), { ...a, ...o };
2482
2490
  };
2483
2491
  }
2484
2492
  function mn(e) {
@@ -2502,11 +2510,27 @@ function hn(e) {
2502
2510
  rotating: c !== void 0 ? c ? 1 : 0 : void 0,
2503
2511
  // Convert date fields to bigint format
2504
2512
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2505
- expires_at_ts: r !== void 0 ? x(r) : void 0,
2506
- idle_expires_at_ts: s !== void 0 ? x(s) : void 0,
2507
- last_exchanged_at_ts: i !== void 0 ? x(i) : void 0
2513
+ expires_at_ts: r !== void 0 ? T(r) : void 0,
2514
+ idle_expires_at_ts: s !== void 0 ? T(s) : void 0,
2515
+ last_exchanged_at_ts: i !== void 0 ? T(i) : void 0
2508
2516
  };
2509
- return !!(await e.updateTable("refresh_tokens").set(m).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length;
2517
+ return e.transaction().execute(async (_) => {
2518
+ const f = !!(await _.updateTable("refresh_tokens").set(m).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length, g = m.expires_at_ts !== void 0 || m.idle_expires_at_ts !== void 0;
2519
+ if (f && g) {
2520
+ const w = await _.selectFrom("refresh_tokens").select(["login_id", "expires_at_ts", "idle_expires_at_ts"]).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).executeTakeFirst();
2521
+ if (w != null && w.login_id) {
2522
+ const v = Math.max(
2523
+ w.expires_at_ts ?? 0,
2524
+ w.idle_expires_at_ts ?? 0
2525
+ );
2526
+ v > 0 && await _.updateTable("login_sessions").set({
2527
+ expires_at_ts: v,
2528
+ updated_at_ts: Date.now()
2529
+ }).where("tenant_id", "=", t).where("id", "=", w.login_id).where("expires_at_ts", "<", v).execute();
2530
+ }
2531
+ }
2532
+ return f;
2533
+ });
2510
2534
  };
2511
2535
  }
2512
2536
  function pn(e) {
@@ -2524,16 +2548,16 @@ function pn(e) {
2524
2548
  const {
2525
2549
  tenant_id: f,
2526
2550
  created_at_ts: g,
2527
- expires_at_ts: y,
2528
- idle_expires_at_ts: T,
2529
- last_exchanged_at_ts: v,
2551
+ expires_at_ts: w,
2552
+ idle_expires_at_ts: v,
2553
+ last_exchanged_at_ts: C,
2530
2554
  ...N
2531
2555
  } = p, I = z(
2532
2556
  {
2533
2557
  created_at_ts: g,
2534
- expires_at_ts: y,
2535
- idle_expires_at_ts: T,
2536
- last_exchanged_at_ts: v
2558
+ expires_at_ts: w,
2559
+ idle_expires_at_ts: v,
2560
+ last_exchanged_at_ts: C
2537
2561
  },
2538
2562
  ["created_at_ts"],
2539
2563
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
@@ -2672,7 +2696,7 @@ function vn(e) {
2672
2696
  _.ending = JSON.parse(_.ending);
2673
2697
  } catch {
2674
2698
  }
2675
- return q.parse(w(_));
2699
+ return q.parse(y(_));
2676
2700
  });
2677
2701
  if (!r)
2678
2702
  return {
@@ -2716,7 +2740,7 @@ function xn(e) {
2716
2740
  o.ending = JSON.parse(o.ending);
2717
2741
  } catch {
2718
2742
  }
2719
- return q.parse(w(o));
2743
+ return q.parse(y(o));
2720
2744
  };
2721
2745
  }
2722
2746
  function Tn(e) {
@@ -2746,7 +2770,7 @@ function bn(e) {
2746
2770
  ...a,
2747
2771
  created_at: n,
2748
2772
  updated_at: n
2749
- }, r = je.parse(o), {
2773
+ }, r = Fe.parse(o), {
2750
2774
  verificationKey: s,
2751
2775
  scopes: i,
2752
2776
  options: u,
@@ -2768,7 +2792,7 @@ function bn(e) {
2768
2792
  created_at: n,
2769
2793
  updated_at: n
2770
2794
  };
2771
- return await e.insertInto("resource_servers").values(p).execute(), w(r);
2795
+ return await e.insertInto("resource_servers").values(p).execute(), y(r);
2772
2796
  };
2773
2797
  }
2774
2798
  function Sn(e) {
@@ -2784,7 +2808,7 @@ function Sn(e) {
2784
2808
  is_system: c,
2785
2809
  metadata: l,
2786
2810
  ...m
2787
- } = o, _ = w({
2811
+ } = o, _ = y({
2788
2812
  ...m,
2789
2813
  scopes: s ? JSON.parse(s) : [],
2790
2814
  options: i ? JSON.parse(i) : {},
@@ -2803,10 +2827,10 @@ function On(e) {
2803
2827
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2804
2828
  let i = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
2805
2829
  if (s) {
2806
- const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", y = /^(>=|>|<=|<)/.test(g || "");
2807
- if (f && !y) {
2808
- const T = !!f[1], v = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2809
- i = T ? i.where(v, "not like", `%${g}%`) : i.where(v, "like", `%${g}%`);
2830
+ const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", w = /^(>=|>|<=|<)/.test(g || "");
2831
+ if (f && !w) {
2832
+ const v = !!f[1], C = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2833
+ i = v ? i.where(C, "not like", `%${g}%`) : i.where(C, "like", `%${g}%`);
2810
2834
  } else
2811
2835
  i = k(e, i, m, [
2812
2836
  "resource_servers.name",
@@ -2818,23 +2842,23 @@ function On(e) {
2818
2842
  verification_key: p,
2819
2843
  scopes: f,
2820
2844
  options: g,
2821
- skip_consent_for_verifiable_first_party_clients: y,
2822
- allow_offline_access: T,
2823
- is_system: v,
2845
+ skip_consent_for_verifiable_first_party_clients: w,
2846
+ allow_offline_access: v,
2847
+ is_system: C,
2824
2848
  metadata: N,
2825
2849
  ...I
2826
- } = _, C = w({
2850
+ } = _, x = y({
2827
2851
  ...I,
2828
2852
  scopes: f ? JSON.parse(f) : [],
2829
2853
  options: g ? JSON.parse(g) : {},
2830
- skip_consent_for_verifiable_first_party_clients: !!y,
2831
- allow_offline_access: !!T,
2832
- is_system: v ? !0 : void 0,
2854
+ skip_consent_for_verifiable_first_party_clients: !!w,
2855
+ allow_offline_access: !!v,
2856
+ is_system: C ? !0 : void 0,
2833
2857
  metadata: N ? JSON.parse(N) : void 0,
2834
2858
  // Convert verification_key back to verificationKey for API
2835
2859
  verificationKey: p
2836
2860
  });
2837
- return C.token_lifetime ?? (C.token_lifetime = 86400), C.token_lifetime_for_web ?? (C.token_lifetime_for_web = 7200), C;
2861
+ return x.token_lifetime ?? (x.token_lifetime = 86400), x.token_lifetime_for_web ?? (x.token_lifetime_for_web = 7200), x;
2838
2862
  });
2839
2863
  if (!r)
2840
2864
  return {
@@ -2970,7 +2994,7 @@ function An(e) {
2970
2994
  return Number(n.numDeletedRows) > 0;
2971
2995
  };
2972
2996
  }
2973
- function jn(e) {
2997
+ function Fn(e) {
2974
2998
  return {
2975
2999
  create: In(e),
2976
3000
  get: zn(e),
@@ -2979,7 +3003,7 @@ function jn(e) {
2979
3003
  remove: An(e)
2980
3004
  };
2981
3005
  }
2982
- function Fn(e) {
3006
+ function jn(e) {
2983
3007
  return async (t, a, n) => {
2984
3008
  if (n.length === 0) return !0;
2985
3009
  const o = (/* @__PURE__ */ new Date()).toISOString();
@@ -3064,7 +3088,7 @@ function Jn(e) {
3064
3088
  }
3065
3089
  function Mn(e) {
3066
3090
  return {
3067
- assign: Fn(e),
3091
+ assign: jn(e),
3068
3092
  remove: Rn(e),
3069
3093
  list: Jn(e)
3070
3094
  };
@@ -3243,7 +3267,7 @@ function Vn(e) {
3243
3267
  function Xn(e) {
3244
3268
  return async (t, a) => {
3245
3269
  let n = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
3246
- return n || (n = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", a).executeTakeFirst()), n ? w({
3270
+ return n || (n = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", a).executeTakeFirst()), n ? y({
3247
3271
  ...n,
3248
3272
  branding: n.branding ? JSON.parse(n.branding) : {},
3249
3273
  metadata: n.metadata ? JSON.parse(n.metadata) : {},
@@ -3288,7 +3312,7 @@ function Zn(e) {
3288
3312
  s = Number((l == null ? void 0 : l.count) || 0);
3289
3313
  }
3290
3314
  const i = r.map(
3291
- (c) => w({
3315
+ (c) => y({
3292
3316
  ...c,
3293
3317
  branding: c.branding ? JSON.parse(c.branding) : {},
3294
3318
  metadata: c.metadata ? JSON.parse(c.metadata) : {},
@@ -3531,7 +3555,7 @@ function _o(e) {
3531
3555
  user_metadata: {},
3532
3556
  roles: []
3533
3557
  });
3534
- return w({
3558
+ return y({
3535
3559
  ...o,
3536
3560
  send_invitation_email: n.send_invitation_email === 1
3537
3561
  });
@@ -3552,7 +3576,7 @@ function mo(e) {
3552
3576
  user_metadata: {},
3553
3577
  roles: []
3554
3578
  });
3555
- return w({
3579
+ return y({
3556
3580
  ...i,
3557
3581
  send_invitation_email: s.send_invitation_email === 1
3558
3582
  });
@@ -3955,7 +3979,7 @@ function Ao(e) {
3955
3979
  return Number(a.numDeletedRows);
3956
3980
  };
3957
3981
  }
3958
- function jo(e) {
3982
+ function Fo(e) {
3959
3983
  return {
3960
3984
  create: So(e),
3961
3985
  getByIds: Oo(e),
@@ -3978,7 +4002,7 @@ class ve {
3978
4002
  return this.migrations;
3979
4003
  }
3980
4004
  }
3981
- async function Fo(e) {
4005
+ async function jo(e) {
3982
4006
  await e.schema.createTable("tenants").addColumn("id", "varchar(255)", (t) => t.primaryKey()).addColumn("name", "varchar(255)").addColumn("audience", "varchar(255)").addColumn("sender_email", "varchar(255)").addColumn("sender_name", "varchar(255)").addColumn("language", "varchar(255)").addColumn("logo", "varchar(255)").addColumn("primary_color", "varchar(255)").addColumn("secondary_color", "varchar(255)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("updated_at", "varchar(255)", (t) => t.notNull()).execute(), await e.schema.createTable("users").addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn(
3983
4007
  "tenant_id",
3984
4008
  "varchar(255)",
@@ -4056,7 +4080,7 @@ async function Ro(e) {
4056
4080
  const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4057
4081
  __proto__: null,
4058
4082
  down: Ro,
4059
- up: Fo
4083
+ up: jo
4060
4084
  }, Symbol.toStringTag, { value: "Module" }));
4061
4085
  async function Mo(e) {
4062
4086
  await e.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
@@ -4283,19 +4307,19 @@ async function Dr(e) {
4283
4307
  }
4284
4308
  async function Ar(e) {
4285
4309
  }
4286
- const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4310
+ const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4287
4311
  __proto__: null,
4288
4312
  down: Ar,
4289
4313
  up: Dr
4290
4314
  }, Symbol.toStringTag, { value: "Module" }));
4291
- async function Fr(e) {
4315
+ async function jr(e) {
4292
4316
  }
4293
4317
  async function Rr(e) {
4294
4318
  }
4295
4319
  const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4296
4320
  __proto__: null,
4297
4321
  down: Rr,
4298
- up: Fr
4322
+ up: jr
4299
4323
  }, Symbol.toStringTag, { value: "Module" }));
4300
4324
  async function Mr(e) {
4301
4325
  await e.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
@@ -4480,19 +4504,19 @@ async function Ds(e) {
4480
4504
  async function As(e) {
4481
4505
  await e.schema.dropTable("authentication_codes").execute();
4482
4506
  }
4483
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4507
+ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4484
4508
  __proto__: null,
4485
4509
  down: As,
4486
4510
  up: Ds
4487
4511
  }, Symbol.toStringTag, { value: "Module" }));
4488
- async function Fs(e) {
4512
+ async function js(e) {
4489
4513
  }
4490
4514
  async function Rs(e) {
4491
4515
  }
4492
4516
  const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4493
4517
  __proto__: null,
4494
4518
  down: Rs,
4495
- up: Fs
4519
+ up: js
4496
4520
  }, Symbol.toStringTag, { value: "Module" }));
4497
4521
  async function Ms(e) {
4498
4522
  await e.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
@@ -4727,12 +4751,12 @@ async function Ai(e) {
4727
4751
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4728
4752
  ).addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4729
4753
  }
4730
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4754
+ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4731
4755
  __proto__: null,
4732
4756
  down: Ai,
4733
4757
  up: Di
4734
4758
  }, Symbol.toStringTag, { value: "Module" }));
4735
- async function Fi(e) {
4759
+ async function ji(e) {
4736
4760
  await e.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
4737
4761
  }
4738
4762
  async function Ri(e) {
@@ -4741,7 +4765,7 @@ async function Ri(e) {
4741
4765
  const Ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4742
4766
  __proto__: null,
4743
4767
  down: Ri,
4744
- up: Fi
4768
+ up: ji
4745
4769
  }, Symbol.toStringTag, { value: "Module" }));
4746
4770
  async function Mi(e) {
4747
4771
  }
@@ -4986,12 +5010,12 @@ async function Dc(e) {
4986
5010
  async function Ac(e) {
4987
5011
  await e.schema.dropTable("sessions_2").execute(), await e.schema.dropTable("refresh_tokens_2").execute();
4988
5012
  }
4989
- const jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5013
+ const Fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4990
5014
  __proto__: null,
4991
5015
  down: Ac,
4992
5016
  up: Dc
4993
5017
  }, Symbol.toStringTag, { value: "Module" }));
4994
- async function Fc(e) {
5018
+ async function jc(e) {
4995
5019
  await e.schema.createTable("custom_domains").addColumn(
4996
5020
  "custom_domain_id",
4997
5021
  "varchar(21)",
@@ -5012,7 +5036,7 @@ async function Rc(e) {
5012
5036
  const Jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5013
5037
  __proto__: null,
5014
5038
  down: Rc,
5015
- up: Fc
5039
+ up: jc
5016
5040
  }, Symbol.toStringTag, { value: "Module" }));
5017
5041
  async function Mc(e) {
5018
5042
  }
@@ -5302,12 +5326,12 @@ async function Dl(e) {
5302
5326
  async function Al(e) {
5303
5327
  await e.schema.dropTable("roles").execute(), await e.schema.dropTable("resource_servers").execute();
5304
5328
  }
5305
- const jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5329
+ const Fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5306
5330
  __proto__: null,
5307
5331
  down: Al,
5308
5332
  up: Dl
5309
5333
  }, Symbol.toStringTag, { value: "Module" }));
5310
- async function Fl(e) {
5334
+ async function jl(e) {
5311
5335
  await e.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("role_id", "varchar(21)", (t) => t.notNull()).addColumn(
5312
5336
  "resource_server_identifier",
5313
5337
  "varchar(191)",
@@ -5334,7 +5358,7 @@ async function Rl(e) {
5334
5358
  const Jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5335
5359
  __proto__: null,
5336
5360
  down: Rl,
5337
- up: Fl
5361
+ up: jl
5338
5362
  }, Symbol.toStringTag, { value: "Module" }));
5339
5363
  async function Ml(e) {
5340
5364
  await e.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("user_id", "varchar(191)", (t) => t.notNull()).addColumn("role_id", "varchar(21)", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
@@ -5891,12 +5915,12 @@ const Dd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5891
5915
  async function Ad(e) {
5892
5916
  await e.schema.createTable("invites").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("organization_id", "varchar(21)", (t) => t.notNull()).addColumn("inviter", "text", (t) => t.notNull()).addColumn("invitee", "text", (t) => t.notNull()).addColumn("client_id", "varchar(191)", (t) => t.notNull()).addColumn("connection_id", "varchar(21)").addColumn("invitation_url", "text", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)", (t) => t.notNull()).addColumn("app_metadata", "text").addColumn("user_metadata", "text").addColumn("roles", "text").addColumn("ticket_id", "varchar(191)").addColumn("ttl_sec", "integer").addColumn("send_invitation_email", "integer").execute(), await e.schema.createIndex("idx_invites_tenant_id").on("invites").column("tenant_id").execute(), await e.schema.createIndex("idx_invites_organization_id").on("invites").column("organization_id").execute(), await e.schema.createIndex("idx_invites_expires_at").on("invites").column("expires_at").execute(), await e.schema.createIndex("idx_invites_tenant_created").on("invites").columns(["tenant_id", "created_at"]).execute();
5893
5917
  }
5894
- async function jd(e) {
5918
+ async function Fd(e) {
5895
5919
  await e.schema.dropTable("invites").execute();
5896
5920
  }
5897
- const Fd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5921
+ const jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5898
5922
  __proto__: null,
5899
- down: jd,
5923
+ down: Fd,
5900
5924
  up: Ad
5901
5925
  }, Symbol.toStringTag, { value: "Module" }));
5902
5926
  async function Rd(e) {
@@ -6192,7 +6216,7 @@ async function pu(e) {
6192
6216
  const t = await hu(e);
6193
6217
  await b(e, "refresh_tokens", "created_at_ts", "bigint"), await b(e, "refresh_tokens", "expires_at_ts", "bigint"), await b(e, "refresh_tokens", "idle_expires_at_ts", "bigint"), await b(e, "refresh_tokens", "last_exchanged_at_ts", "bigint"), await b(e, "sessions", "created_at_ts", "bigint"), await b(e, "sessions", "updated_at_ts", "bigint"), await b(e, "sessions", "expires_at_ts", "bigint"), await b(e, "sessions", "idle_expires_at_ts", "bigint"), await b(e, "sessions", "authenticated_at_ts", "bigint"), await b(e, "sessions", "last_interaction_at_ts", "bigint"), await b(e, "sessions", "used_at_ts", "bigint"), await b(e, "sessions", "revoked_at_ts", "bigint"), await b(e, "login_sessions", "created_at_ts", "bigint"), await b(e, "login_sessions", "updated_at_ts", "bigint"), await b(e, "login_sessions", "expires_at_ts", "bigint"), t === "mysql" && (await e.schema.alterTable("refresh_tokens").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("expires_at", "varchar(35)").execute()), await e.schema.createIndex("idx_sessions_user_id").on("sessions").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_user_id").on("refresh_tokens").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.createIndex("idx_refresh_tokens_expires_at_ts").on("refresh_tokens").column("expires_at_ts").execute(), await e.schema.createIndex("idx_sessions_expires_at_ts").on("sessions").column("expires_at_ts").execute(), await e.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
6194
6218
  }
6195
- async function F(e, t, a) {
6219
+ async function j(e, t, a) {
6196
6220
  try {
6197
6221
  await e.schema.dropIndex(t).on(a).execute();
6198
6222
  } catch (n) {
@@ -6211,7 +6235,7 @@ async function S(e, t, a) {
6211
6235
  }
6212
6236
  }
6213
6237
  async function fu(e) {
6214
- await F(e, "idx_sessions_user_id", "sessions"), await F(e, "idx_refresh_tokens_user_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_session_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_expires_at_ts", "refresh_tokens"), await F(e, "idx_sessions_expires_at_ts", "sessions"), await F(e, "idx_login_sessions_expires_at_ts", "login_sessions"), await S(e, "refresh_tokens", "created_at_ts"), await S(e, "refresh_tokens", "expires_at_ts"), await S(e, "refresh_tokens", "idle_expires_at_ts"), await S(e, "refresh_tokens", "last_exchanged_at_ts"), await S(e, "sessions", "created_at_ts"), await S(e, "sessions", "updated_at_ts"), await S(e, "sessions", "expires_at_ts"), await S(e, "sessions", "idle_expires_at_ts"), await S(e, "sessions", "authenticated_at_ts"), await S(e, "sessions", "last_interaction_at_ts"), await S(e, "sessions", "used_at_ts"), await S(e, "sessions", "revoked_at_ts"), await S(e, "login_sessions", "created_at_ts"), await S(e, "login_sessions", "updated_at_ts"), await S(e, "login_sessions", "expires_at_ts");
6238
+ await j(e, "idx_sessions_user_id", "sessions"), await j(e, "idx_refresh_tokens_user_id", "refresh_tokens"), await j(e, "idx_refresh_tokens_session_id", "refresh_tokens"), await j(e, "idx_refresh_tokens_expires_at_ts", "refresh_tokens"), await j(e, "idx_sessions_expires_at_ts", "sessions"), await j(e, "idx_login_sessions_expires_at_ts", "login_sessions"), await S(e, "refresh_tokens", "created_at_ts"), await S(e, "refresh_tokens", "expires_at_ts"), await S(e, "refresh_tokens", "idle_expires_at_ts"), await S(e, "refresh_tokens", "last_exchanged_at_ts"), await S(e, "sessions", "created_at_ts"), await S(e, "sessions", "updated_at_ts"), await S(e, "sessions", "expires_at_ts"), await S(e, "sessions", "idle_expires_at_ts"), await S(e, "sessions", "authenticated_at_ts"), await S(e, "sessions", "last_interaction_at_ts"), await S(e, "sessions", "used_at_ts"), await S(e, "sessions", "revoked_at_ts"), await S(e, "login_sessions", "created_at_ts"), await S(e, "login_sessions", "updated_at_ts"), await S(e, "login_sessions", "expires_at_ts");
6215
6239
  }
6216
6240
  const gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6217
6241
  __proto__: null,
@@ -6342,20 +6366,20 @@ const Au = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6342
6366
  down: Du,
6343
6367
  up: Pu
6344
6368
  }, Symbol.toStringTag, { value: "Module" }));
6345
- async function ju(e) {
6369
+ async function Fu(e) {
6346
6370
  await e.schema.createTable("universal_login_templates").addColumn(
6347
6371
  "tenant_id",
6348
6372
  "varchar(191)",
6349
6373
  (t) => t.primaryKey().references("tenants.id").onDelete("cascade")
6350
6374
  ).addColumn("body", "text", (t) => t.notNull()).addColumn("updated_at_ts", "integer", (t) => t.notNull()).addColumn("created_at_ts", "integer", (t) => t.notNull()).execute();
6351
6375
  }
6352
- async function Fu(e) {
6376
+ async function ju(e) {
6353
6377
  await e.schema.dropTable("universal_login_templates").execute();
6354
6378
  }
6355
6379
  const Ru = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6356
6380
  __proto__: null,
6357
- down: Fu,
6358
- up: ju
6381
+ down: ju,
6382
+ up: Fu
6359
6383
  }, Symbol.toStringTag, { value: "Module" }));
6360
6384
  async function Ju(e) {
6361
6385
  await e.schema.createTable("custom_text").addColumn(
@@ -6708,12 +6732,12 @@ async function D_(e) {
6708
6732
  async function A_(e) {
6709
6733
  await e.schema.dropTable("actions").execute();
6710
6734
  }
6711
- const j_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6735
+ const F_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6712
6736
  __proto__: null,
6713
6737
  down: A_,
6714
6738
  up: D_
6715
6739
  }, Symbol.toStringTag, { value: "Module" }));
6716
- async function F_(e) {
6740
+ async function j_(e) {
6717
6741
  await e.schema.alterTable("outbox_events").addColumn("dead_lettered_at", "varchar(35)").execute(), await e.schema.alterTable("outbox_events").addColumn("final_error", "text").execute();
6718
6742
  }
6719
6743
  async function R_(e) {
@@ -6722,7 +6746,7 @@ async function R_(e) {
6722
6746
  const J_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6723
6747
  __proto__: null,
6724
6748
  down: R_,
6725
- up: F_
6749
+ up: j_
6726
6750
  }, Symbol.toStringTag, { value: "Module" }));
6727
6751
  async function M_(e) {
6728
6752
  await e.schema.alterTable("users").addColumn("registration_completed_at", "varchar(35)").execute(), await e.updateTable("users").set({
@@ -6765,7 +6789,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6765
6789
  n15_userEmailIndex: Or,
6766
6790
  n16_userLocale: Er,
6767
6791
  n17_signingKeys: Pr,
6768
- n18_logsFields: jr,
6792
+ n18_logsFields: Fr,
6769
6793
  n19_connectionsUserinfo: Jr,
6770
6794
  n20_missingFields: Kr,
6771
6795
  n21_sessionDeletedAt: Br,
@@ -6783,7 +6807,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6783
6807
  n33_vendorIdInUniversalLoginSession: Os,
6784
6808
  n34_auth0ClientInUniversalLoginSession: Es,
6785
6809
  n35_increaseUniversalSessionStateLength: Ps,
6786
- n36_authenticationCodes: js,
6810
+ n36_authenticationCodes: Fs,
6787
6811
  n37_disableSignUps: Js,
6788
6812
  n38_otpIpAddress: Ks,
6789
6813
  n39_increaseUserAgentLength: Bs,
@@ -6801,7 +6825,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6801
6825
  n51_connectionid: Oi,
6802
6826
  n52_cert: Ei,
6803
6827
  n53_codes_primary_key: Pi,
6804
- n54_cleanup_tables: ji,
6828
+ n54_cleanup_tables: Fi,
6805
6829
  n55_logs_index: Ji,
6806
6830
  n56_application_fields: Ki,
6807
6831
  n57_prompt_settings: Bi,
@@ -6819,7 +6843,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6819
6843
  n70_refresh_tokens: Oc,
6820
6844
  n71_session_new_fields: Ec,
6821
6845
  n72_session_primary_key: Pc,
6822
- n73_drop_sessions: jc,
6846
+ n73_drop_sessions: Fc,
6823
6847
  n74_custom_domains: Jc,
6824
6848
  n75_organizations: Kc,
6825
6849
  n76_authorization_url_length: Bc,
@@ -6837,7 +6861,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6837
6861
  n88_add_redirect_uri_to_codes: Ol,
6838
6862
  n89_add_nonce_and_state_to_codes: El,
6839
6863
  n90_themes: Pl,
6840
- n91_resource_servers_rules_permissions: jl,
6864
+ n91_resource_servers_rules_permissions: Fl,
6841
6865
  n92_role_permissions: Jl,
6842
6866
  n93_add_permissions_to_roles: Kl,
6843
6867
  n94_keys_connection_and_extend_columns: Bl,
@@ -6854,7 +6878,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6854
6878
  o006_remove_redundant_user_organizations_tenant_index: kd,
6855
6879
  o007_tenant_settings: Id,
6856
6880
  o008_merge_tenant_settings_into_tenants: Dd,
6857
- o009_create_invites_table: Fd,
6881
+ o009_create_invites_table: jd,
6858
6882
  o010_add_log_id_to_logs: Md,
6859
6883
  o011_add_location_info_to_logs: qd,
6860
6884
  o012_add_password_history: Qd,
@@ -6889,7 +6913,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6889
6913
  o041_add_outbox_claim_columns: O_,
6890
6914
  o042_add_outbox_claim_index: E_,
6891
6915
  o043_add_code_hooks: P_,
6892
- o044_create_actions: j_,
6916
+ o044_create_actions: F_,
6893
6917
  o045_outbox_dead_letter: J_,
6894
6918
  o046_user_registration_completed_at: K_,
6895
6919
  o047_outbox_dead_lettered_tenant_index: B_
@@ -6932,7 +6956,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6932
6956
  flows: ut(e),
6933
6957
  forms: Nn(e),
6934
6958
  hookCode: Ka(e),
6935
- hooks: Fa(e),
6959
+ hooks: ja(e),
6936
6960
  invites: fo(e),
6937
6961
  keys: ga(e),
6938
6962
  loginSessions: tn(e),
@@ -6945,7 +6969,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6945
6969
  rolePermissions: Mn(e),
6946
6970
  userPermissions: Bn(e),
6947
6971
  userRoles: Gn(e),
6948
- roles: jn(e),
6972
+ roles: Fn(e),
6949
6973
  sessions: $t(e),
6950
6974
  sessionCleanup: wn(e),
6951
6975
  tenants: wt(e),
@@ -6956,7 +6980,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6956
6980
  organizations: ao(e),
6957
6981
  userOrganizations: lo(e),
6958
6982
  stats: wo(e),
6959
- outbox: jo(e),
6983
+ outbox: Fo(e),
6960
6984
  async transaction(n) {
6961
6985
  return t.useTransactions === !1 ? n(a) : e.transaction().execute(async (o) => {
6962
6986
  const r = Q_(o, {