@authhero/kysely-adapter 10.125.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
  });
@@ -285,7 +285,11 @@ function We(e) {
285
285
  const o = {
286
286
  updated_at_ts: Date.now()
287
287
  };
288
- return n.name !== void 0 && (o.name = n.name), n.code !== void 0 && (o.code = n.code), n.runtime !== void 0 && (o.runtime = n.runtime), n.secrets !== void 0 && (o.secrets = JSON.stringify(n.secrets)), n.dependencies !== void 0 && (o.dependencies = JSON.stringify(n.dependencies)), n.supported_triggers !== void 0 && (o.supported_triggers = JSON.stringify(n.supported_triggers)), n.status !== void 0 && (o.status = n.status), n.deployed_at !== void 0 && (o.deployed_at_ts = new Date(n.deployed_at).getTime()), (await e.updateTable("actions").set(o).where("actions.id", "=", a).where("actions.tenant_id", "=", t).executeTakeFirst()).numUpdatedRows > 0;
288
+ if (n.name !== void 0 && (o.name = n.name), n.code !== void 0 && (o.code = n.code), n.runtime !== void 0 && (o.runtime = n.runtime), n.secrets !== void 0 && (o.secrets = JSON.stringify(n.secrets)), n.dependencies !== void 0 && (o.dependencies = JSON.stringify(n.dependencies)), n.supported_triggers !== void 0 && (o.supported_triggers = JSON.stringify(n.supported_triggers)), n.status !== void 0 && (o.status = n.status), n.deployed_at !== void 0) {
289
+ const s = new Date(n.deployed_at).getTime();
290
+ Number.isFinite(s) && (o.deployed_at_ts = s);
291
+ }
292
+ return (await e.updateTable("actions").set(o).where("actions.id", "=", a).where("actions.tenant_id", "=", t).executeTakeFirst()).numUpdatedRows > 0;
289
293
  };
290
294
  }
291
295
  function Ge(e) {
@@ -373,22 +377,22 @@ function Xe(e) {
373
377
  };
374
378
  };
375
379
  }
376
- function w(e) {
380
+ function y(e) {
377
381
  if (e == null || typeof e != "object")
378
382
  return e;
379
383
  if (Array.isArray(e))
380
384
  return e.map(
381
385
  (a) => (
382
386
  // Only recurse into objects; leave primitives untouched
383
- a !== null && typeof a == "object" ? w(a) : a
387
+ a !== null && typeof a == "object" ? y(a) : a
384
388
  )
385
389
  );
386
390
  const t = { ...e };
387
391
  for (const a in t) {
388
392
  const n = t[a];
389
393
  n === null ? delete t[a] : n !== null && typeof n == "object" && (Array.isArray(n) ? t[a] = n.map(
390
- (o) => o !== null && typeof o == "object" ? w(o) : o
391
- ) : t[a] = w(n));
394
+ (o) => o !== null && typeof o == "object" ? y(o) : o
395
+ ) : t[a] = y(n));
392
396
  }
393
397
  return t;
394
398
  }
@@ -445,7 +449,7 @@ function et(e) {
445
449
  ...o.map((u) => U(u))
446
450
  ]
447
451
  };
448
- return w(i);
452
+ return y(i);
449
453
  };
450
454
  }
451
455
  function tt(e) {
@@ -458,9 +462,9 @@ function tt(e) {
458
462
  }
459
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) => {
460
464
  const g = m.filter(
461
- (y) => y.linked_to === f.user_id
465
+ (w) => w.linked_to === f.user_id
462
466
  );
463
- return w({
467
+ return y({
464
468
  ...f,
465
469
  email_verified: f.email_verified === 1,
466
470
  phone_verified: f.phone_verified !== null ? f.phone_verified === 1 : void 0,
@@ -470,7 +474,7 @@ function tt(e) {
470
474
  address: f.address ? JSON.parse(f.address) : void 0,
471
475
  identities: [
472
476
  U(f, !0),
473
- ...g.map((y) => U(y))
477
+ ...g.map((w) => U(w))
474
478
  ]
475
479
  });
476
480
  });
@@ -602,7 +606,7 @@ function it(e) {
602
606
  ...n,
603
607
  actions: A(n.actions, [])
604
608
  };
605
- return B.parse(w(o));
609
+ return B.parse(y(o));
606
610
  };
607
611
  }
608
612
  function ct(e) {
@@ -615,7 +619,7 @@ function ct(e) {
615
619
  ...m,
616
620
  actions: A(m.actions, [])
617
621
  };
618
- return B.parse(w(_));
622
+ return B.parse(y(_));
619
623
  });
620
624
  if (!r)
621
625
  return {
@@ -685,7 +689,7 @@ function pe(e) {
685
689
  };
686
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(
687
691
  e.sandbox_versions_available
688
- )), 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);
689
693
  }
690
694
  function fe(e) {
691
695
  const t = { ...e };
@@ -959,10 +963,10 @@ function bt(e) {
959
963
  updated_at_ts: n,
960
964
  authenticated_at_ts: n,
961
965
  last_interaction_at_ts: n,
962
- expires_at_ts: x(s),
963
- idle_expires_at_ts: x(i),
964
- used_at_ts: x(u),
965
- 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),
966
970
  device: JSON.stringify(c),
967
971
  clients: JSON.stringify(l)
968
972
  }).execute(), r;
@@ -978,9 +982,9 @@ function Ot(e) {
978
982
  device: n.device ? JSON.stringify(n.device) : void 0,
979
983
  clients: n.clients ? JSON.stringify(n.clients) : void 0
980
984
  };
981
- 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(
982
986
  n.last_interaction_at
983
- )), 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;
984
988
  };
985
989
  }
986
990
  function kt(e) {
@@ -998,23 +1002,23 @@ function kt(e) {
998
1002
  const {
999
1003
  tenant_id: f,
1000
1004
  device: g,
1001
- clients: y,
1002
- created_at_ts: T,
1003
- updated_at_ts: v,
1005
+ clients: w,
1006
+ created_at_ts: v,
1007
+ updated_at_ts: C,
1004
1008
  expires_at_ts: N,
1005
1009
  idle_expires_at_ts: I,
1006
- authenticated_at_ts: C,
1010
+ authenticated_at_ts: x,
1007
1011
  last_interaction_at_ts: P,
1008
1012
  used_at_ts: ee,
1009
1013
  revoked_at_ts: Se,
1010
1014
  ...Oe
1011
1015
  } = p, ke = z(
1012
1016
  {
1013
- created_at_ts: T,
1014
- updated_at_ts: v,
1017
+ created_at_ts: v,
1018
+ updated_at_ts: C,
1015
1019
  expires_at_ts: N,
1016
1020
  idle_expires_at_ts: I,
1017
- authenticated_at_ts: C,
1021
+ authenticated_at_ts: x,
1018
1022
  last_interaction_at_ts: P,
1019
1023
  used_at_ts: ee,
1020
1024
  revoked_at_ts: Se
@@ -1031,7 +1035,7 @@ function kt(e) {
1031
1035
  ...Oe,
1032
1036
  ...ke,
1033
1037
  device: JSON.parse(g),
1034
- clients: JSON.parse(y)
1038
+ clients: JSON.parse(w)
1035
1039
  };
1036
1040
  });
1037
1041
  if (!r)
@@ -1122,7 +1126,7 @@ function At(e) {
1122
1126
  s && (i = k(e, i, s, ["code", "login_id"]));
1123
1127
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1124
1128
  const { tenant_id: _, ...p } = m;
1125
- return Pe.parse(w(p));
1129
+ return Pe.parse(y(p));
1126
1130
  });
1127
1131
  if (!r)
1128
1132
  return {
@@ -1140,7 +1144,7 @@ function At(e) {
1140
1144
  };
1141
1145
  };
1142
1146
  }
1143
- function jt(e) {
1147
+ function Ft(e) {
1144
1148
  return async (t, a) => {
1145
1149
  const n = {
1146
1150
  ...a,
@@ -1152,7 +1156,7 @@ function jt(e) {
1152
1156
  }).execute(), n;
1153
1157
  };
1154
1158
  }
1155
- function Ft(e) {
1159
+ function jt(e) {
1156
1160
  return async (t, a) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1157
1161
  }
1158
1162
  function Rt(e) {
@@ -1160,7 +1164,7 @@ function Rt(e) {
1160
1164
  let o = e.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", n);
1161
1165
  t.length && (o = o.where("codes.tenant_id", "=", t));
1162
1166
  const r = await o.selectAll().executeTakeFirst();
1163
- return r ? w(r) : null;
1167
+ return r ? y(r) : null;
1164
1168
  };
1165
1169
  }
1166
1170
  function Jt(e) {
@@ -1171,9 +1175,9 @@ function Mt(e) {
1171
1175
  }
1172
1176
  function Lt(e) {
1173
1177
  return {
1174
- create: jt(e),
1178
+ create: Ft(e),
1175
1179
  list: At(e),
1176
- remove: Ft(e),
1180
+ remove: jt(e),
1177
1181
  used: Jt(e),
1178
1182
  consume: Mt(e),
1179
1183
  get: Rt(e)
@@ -1199,7 +1203,7 @@ function Kt(e) {
1199
1203
  }
1200
1204
  function X(e) {
1201
1205
  const { is_system: t, ...a } = e;
1202
- return w({
1206
+ return y({
1203
1207
  ...a,
1204
1208
  is_system: t ? !0 : void 0,
1205
1209
  options: JSON.parse(e.options)
@@ -1331,7 +1335,7 @@ function Gt(e) {
1331
1335
  if (!n)
1332
1336
  return null;
1333
1337
  const { tenant_id: o, ...r } = n;
1334
- return w({
1338
+ return y({
1335
1339
  ...r,
1336
1340
  // Convert integer fields back to booleans
1337
1341
  global: !!n.global,
@@ -1375,7 +1379,7 @@ function Gt(e) {
1375
1379
  function Vt(e) {
1376
1380
  return async (t) => {
1377
1381
  const a = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
1378
- return a ? w({
1382
+ return a ? y({
1379
1383
  ...a,
1380
1384
  // Convert integer fields back to booleans
1381
1385
  global: !!a.global,
@@ -1642,7 +1646,7 @@ function ca(e) {
1642
1646
  created_at: n,
1643
1647
  updated_at: n
1644
1648
  };
1645
- return await e.insertInto("client_grants").values(u).execute(), w({
1649
+ return await e.insertInto("client_grants").values(u).execute(), y({
1646
1650
  id: o,
1647
1651
  tenant_id: t,
1648
1652
  ...i,
@@ -1675,7 +1679,7 @@ function la(e) {
1675
1679
  created_at: n.created_at,
1676
1680
  updated_at: n.updated_at
1677
1681
  };
1678
- return w(o);
1682
+ return y(o);
1679
1683
  };
1680
1684
  }
1681
1685
  function da(e) {
@@ -1683,14 +1687,14 @@ function da(e) {
1683
1687
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1684
1688
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1685
1689
  if (s) {
1686
- 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 || "");
1687
- if (g && !T && y) {
1688
- 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}`);
1689
1693
  if (N === "allow_any_organization") {
1690
- const P = y === "true" ? 1 : 0;
1691
- 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);
1692
1696
  } else
1693
- v ? u = u.where(C, "!=", y) : u = u.where(C, "=", y);
1697
+ C ? u = u.where(x, "!=", w) : u = u.where(x, "=", w);
1694
1698
  } else
1695
1699
  u = k(e, u, _, []);
1696
1700
  }
@@ -1716,7 +1720,7 @@ function da(e) {
1716
1720
  created_at: _.created_at,
1717
1721
  updated_at: _.updated_at
1718
1722
  };
1719
- return w(p);
1723
+ return y(p);
1720
1724
  });
1721
1725
  if (!r)
1722
1726
  return {
@@ -1916,7 +1920,7 @@ function ba(e) {
1916
1920
  font_url: d,
1917
1921
  ...c
1918
1922
  } = a;
1919
- return w({
1923
+ return y({
1920
1924
  ...c,
1921
1925
  colors: {
1922
1926
  primary: o,
@@ -1933,7 +1937,7 @@ function ba(e) {
1933
1937
  }
1934
1938
  function Sa(e) {
1935
1939
  return async (t, a) => {
1936
- 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;
1937
1941
  const { colors: n, font: o, ...r } = a;
1938
1942
  try {
1939
1943
  await e.insertInto("branding").values({
@@ -1951,9 +1955,9 @@ function Sa(e) {
1951
1955
  ...r,
1952
1956
  colors_primary: n == null ? void 0 : n.primary,
1953
1957
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1954
- colors_page_background_start: (T = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : T.start,
1955
- colors_page_background_end: (N = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : N.end,
1956
- 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,
1957
1961
  font_url: (P = a.font) == null ? void 0 : P.url
1958
1962
  }).where("tenant_id", "=", t).execute();
1959
1963
  }
@@ -2019,15 +2023,15 @@ function za(e) {
2019
2023
  enabled: p,
2020
2024
  synchronous: f,
2021
2025
  created_at_ts: g,
2022
- updated_at_ts: y,
2023
- ...T
2024
- } = 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 }, [
2025
2029
  "created_at_ts",
2026
2030
  "updated_at_ts"
2027
2031
  ]);
2028
- return w({
2029
- ...T,
2032
+ return y({
2030
2033
  ...v,
2034
+ ...C,
2031
2035
  enabled: !!p,
2032
2036
  synchronous: !!f
2033
2037
  });
@@ -2062,7 +2066,7 @@ function Pa(e) {
2062
2066
  "created_at_ts",
2063
2067
  "updated_at_ts"
2064
2068
  ]);
2065
- return w({
2069
+ return y({
2066
2070
  ...i,
2067
2071
  ...u,
2068
2072
  enabled: !!i.enabled,
@@ -2094,7 +2098,7 @@ function Aa(e) {
2094
2098
  };
2095
2099
  };
2096
2100
  }
2097
- function ja(e) {
2101
+ function Fa(e) {
2098
2102
  return async (t, a, n) => {
2099
2103
  const { hook_id: o, ...r } = n, s = {
2100
2104
  ...r,
@@ -2105,12 +2109,12 @@ function ja(e) {
2105
2109
  return await e.updateTable("hooks").set(s).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", t).execute(), !0;
2106
2110
  };
2107
2111
  }
2108
- function Fa(e) {
2112
+ function ja(e) {
2109
2113
  return {
2110
2114
  create: Aa(e),
2111
2115
  get: Pa(e),
2112
2116
  list: za(e),
2113
- update: ja(e),
2117
+ update: Fa(e),
2114
2118
  remove: Da(e)
2115
2119
  };
2116
2120
  }
@@ -2208,7 +2212,7 @@ function Ba(e) {
2208
2212
  fonts_subtitle_bold: !!n.fonts_subtitle_bold,
2209
2213
  fonts_title_bold: !!n.fonts_title_bold
2210
2214
  };
2211
- return w(
2215
+ return y(
2212
2216
  _e(o, [
2213
2217
  "widget",
2214
2218
  "colors",
@@ -2246,7 +2250,7 @@ function Ha(e) {
2246
2250
  );
2247
2251
  return De.parse(
2248
2252
  _e(
2249
- w({
2253
+ y({
2250
2254
  ...i,
2251
2255
  ...u,
2252
2256
  state: n.state || le.PENDING,
@@ -2307,7 +2311,7 @@ function Za(e) {
2307
2311
  updated_at_ts: Date.now(),
2308
2312
  // Only update expires_at_ts if a new expires_at was provided
2309
2313
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2310
- ...s !== void 0 ? { expires_at_ts: x(s) } : {}
2314
+ ...s !== void 0 ? { expires_at_ts: T(s) } : {}
2311
2315
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2312
2316
  };
2313
2317
  }
@@ -2325,7 +2329,7 @@ function tn(e) {
2325
2329
  function an(e) {
2326
2330
  return async (t) => {
2327
2331
  const [a] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
2328
- return w({
2332
+ return y({
2329
2333
  identifier_first: !!(a != null && a.identifier_first),
2330
2334
  password_first: !!(a != null && a.password_first),
2331
2335
  webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
@@ -2334,7 +2338,7 @@ function an(e) {
2334
2338
  };
2335
2339
  }
2336
2340
  function oe(e) {
2337
- return w({
2341
+ return y({
2338
2342
  ...e,
2339
2343
  webauthn_platform_first_factor: e.webauthn_platform_first_factor ? !!e.webauthn_platform_first_factor : void 0,
2340
2344
  identifier_first: e.identifier_first ? !!e.identifier_first : void 0,
@@ -2373,7 +2377,7 @@ function rn(e) {
2373
2377
  enabled: s,
2374
2378
  ...i
2375
2379
  } = a;
2376
- return w({
2380
+ return y({
2377
2381
  ...i,
2378
2382
  credentials: JSON.parse(o),
2379
2383
  settings: JSON.parse(r),
@@ -2463,18 +2467,26 @@ function _n(e) {
2463
2467
  resource_servers: d,
2464
2468
  rotating: c,
2465
2469
  ...l
2466
- } = a, m = Date.now();
2467
- return await e.insertInto("refresh_tokens").values({
2468
- ...l,
2469
- tenant_id: t,
2470
- rotating: c ? 1 : 0,
2471
- device: JSON.stringify(u),
2472
- resource_servers: JSON.stringify(d),
2473
- created_at_ts: m,
2474
- expires_at_ts: x(r),
2475
- idle_expires_at_ts: s ? x(s) : null,
2476
- last_exchanged_at_ts: i ? x(i) : null
2477
- }).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 };
2478
2490
  };
2479
2491
  }
2480
2492
  function mn(e) {
@@ -2498,11 +2510,27 @@ function hn(e) {
2498
2510
  rotating: c !== void 0 ? c ? 1 : 0 : void 0,
2499
2511
  // Convert date fields to bigint format
2500
2512
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2501
- expires_at_ts: r !== void 0 ? x(r) : void 0,
2502
- idle_expires_at_ts: s !== void 0 ? x(s) : void 0,
2503
- 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
2504
2516
  };
2505
- 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
+ });
2506
2534
  };
2507
2535
  }
2508
2536
  function pn(e) {
@@ -2520,16 +2548,16 @@ function pn(e) {
2520
2548
  const {
2521
2549
  tenant_id: f,
2522
2550
  created_at_ts: g,
2523
- expires_at_ts: y,
2524
- idle_expires_at_ts: T,
2525
- last_exchanged_at_ts: v,
2551
+ expires_at_ts: w,
2552
+ idle_expires_at_ts: v,
2553
+ last_exchanged_at_ts: C,
2526
2554
  ...N
2527
2555
  } = p, I = z(
2528
2556
  {
2529
2557
  created_at_ts: g,
2530
- expires_at_ts: y,
2531
- idle_expires_at_ts: T,
2532
- last_exchanged_at_ts: v
2558
+ expires_at_ts: w,
2559
+ idle_expires_at_ts: v,
2560
+ last_exchanged_at_ts: C
2533
2561
  },
2534
2562
  ["created_at_ts"],
2535
2563
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
@@ -2668,7 +2696,7 @@ function vn(e) {
2668
2696
  _.ending = JSON.parse(_.ending);
2669
2697
  } catch {
2670
2698
  }
2671
- return q.parse(w(_));
2699
+ return q.parse(y(_));
2672
2700
  });
2673
2701
  if (!r)
2674
2702
  return {
@@ -2712,7 +2740,7 @@ function xn(e) {
2712
2740
  o.ending = JSON.parse(o.ending);
2713
2741
  } catch {
2714
2742
  }
2715
- return q.parse(w(o));
2743
+ return q.parse(y(o));
2716
2744
  };
2717
2745
  }
2718
2746
  function Tn(e) {
@@ -2742,7 +2770,7 @@ function bn(e) {
2742
2770
  ...a,
2743
2771
  created_at: n,
2744
2772
  updated_at: n
2745
- }, r = je.parse(o), {
2773
+ }, r = Fe.parse(o), {
2746
2774
  verificationKey: s,
2747
2775
  scopes: i,
2748
2776
  options: u,
@@ -2764,7 +2792,7 @@ function bn(e) {
2764
2792
  created_at: n,
2765
2793
  updated_at: n
2766
2794
  };
2767
- return await e.insertInto("resource_servers").values(p).execute(), w(r);
2795
+ return await e.insertInto("resource_servers").values(p).execute(), y(r);
2768
2796
  };
2769
2797
  }
2770
2798
  function Sn(e) {
@@ -2780,7 +2808,7 @@ function Sn(e) {
2780
2808
  is_system: c,
2781
2809
  metadata: l,
2782
2810
  ...m
2783
- } = o, _ = w({
2811
+ } = o, _ = y({
2784
2812
  ...m,
2785
2813
  scopes: s ? JSON.parse(s) : [],
2786
2814
  options: i ? JSON.parse(i) : {},
@@ -2799,10 +2827,10 @@ function On(e) {
2799
2827
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2800
2828
  let i = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
2801
2829
  if (s) {
2802
- 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 || "");
2803
- if (f && !y) {
2804
- const T = !!f[1], v = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2805
- 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}%`);
2806
2834
  } else
2807
2835
  i = k(e, i, m, [
2808
2836
  "resource_servers.name",
@@ -2814,23 +2842,23 @@ function On(e) {
2814
2842
  verification_key: p,
2815
2843
  scopes: f,
2816
2844
  options: g,
2817
- skip_consent_for_verifiable_first_party_clients: y,
2818
- allow_offline_access: T,
2819
- is_system: v,
2845
+ skip_consent_for_verifiable_first_party_clients: w,
2846
+ allow_offline_access: v,
2847
+ is_system: C,
2820
2848
  metadata: N,
2821
2849
  ...I
2822
- } = _, C = w({
2850
+ } = _, x = y({
2823
2851
  ...I,
2824
2852
  scopes: f ? JSON.parse(f) : [],
2825
2853
  options: g ? JSON.parse(g) : {},
2826
- skip_consent_for_verifiable_first_party_clients: !!y,
2827
- allow_offline_access: !!T,
2828
- 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,
2829
2857
  metadata: N ? JSON.parse(N) : void 0,
2830
2858
  // Convert verification_key back to verificationKey for API
2831
2859
  verificationKey: p
2832
2860
  });
2833
- 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;
2834
2862
  });
2835
2863
  if (!r)
2836
2864
  return {
@@ -2966,7 +2994,7 @@ function An(e) {
2966
2994
  return Number(n.numDeletedRows) > 0;
2967
2995
  };
2968
2996
  }
2969
- function jn(e) {
2997
+ function Fn(e) {
2970
2998
  return {
2971
2999
  create: In(e),
2972
3000
  get: zn(e),
@@ -2975,7 +3003,7 @@ function jn(e) {
2975
3003
  remove: An(e)
2976
3004
  };
2977
3005
  }
2978
- function Fn(e) {
3006
+ function jn(e) {
2979
3007
  return async (t, a, n) => {
2980
3008
  if (n.length === 0) return !0;
2981
3009
  const o = (/* @__PURE__ */ new Date()).toISOString();
@@ -3060,7 +3088,7 @@ function Jn(e) {
3060
3088
  }
3061
3089
  function Mn(e) {
3062
3090
  return {
3063
- assign: Fn(e),
3091
+ assign: jn(e),
3064
3092
  remove: Rn(e),
3065
3093
  list: Jn(e)
3066
3094
  };
@@ -3239,7 +3267,7 @@ function Vn(e) {
3239
3267
  function Xn(e) {
3240
3268
  return async (t, a) => {
3241
3269
  let n = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
3242
- 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({
3243
3271
  ...n,
3244
3272
  branding: n.branding ? JSON.parse(n.branding) : {},
3245
3273
  metadata: n.metadata ? JSON.parse(n.metadata) : {},
@@ -3284,7 +3312,7 @@ function Zn(e) {
3284
3312
  s = Number((l == null ? void 0 : l.count) || 0);
3285
3313
  }
3286
3314
  const i = r.map(
3287
- (c) => w({
3315
+ (c) => y({
3288
3316
  ...c,
3289
3317
  branding: c.branding ? JSON.parse(c.branding) : {},
3290
3318
  metadata: c.metadata ? JSON.parse(c.metadata) : {},
@@ -3527,7 +3555,7 @@ function _o(e) {
3527
3555
  user_metadata: {},
3528
3556
  roles: []
3529
3557
  });
3530
- return w({
3558
+ return y({
3531
3559
  ...o,
3532
3560
  send_invitation_email: n.send_invitation_email === 1
3533
3561
  });
@@ -3548,7 +3576,7 @@ function mo(e) {
3548
3576
  user_metadata: {},
3549
3577
  roles: []
3550
3578
  });
3551
- return w({
3579
+ return y({
3552
3580
  ...i,
3553
3581
  send_invitation_email: s.send_invitation_email === 1
3554
3582
  });
@@ -3951,7 +3979,7 @@ function Ao(e) {
3951
3979
  return Number(a.numDeletedRows);
3952
3980
  };
3953
3981
  }
3954
- function jo(e) {
3982
+ function Fo(e) {
3955
3983
  return {
3956
3984
  create: So(e),
3957
3985
  getByIds: Oo(e),
@@ -3974,7 +4002,7 @@ class ve {
3974
4002
  return this.migrations;
3975
4003
  }
3976
4004
  }
3977
- async function Fo(e) {
4005
+ async function jo(e) {
3978
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(
3979
4007
  "tenant_id",
3980
4008
  "varchar(255)",
@@ -4052,7 +4080,7 @@ async function Ro(e) {
4052
4080
  const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4053
4081
  __proto__: null,
4054
4082
  down: Ro,
4055
- up: Fo
4083
+ up: jo
4056
4084
  }, Symbol.toStringTag, { value: "Module" }));
4057
4085
  async function Mo(e) {
4058
4086
  await e.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
@@ -4279,19 +4307,19 @@ async function Dr(e) {
4279
4307
  }
4280
4308
  async function Ar(e) {
4281
4309
  }
4282
- const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4310
+ const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4283
4311
  __proto__: null,
4284
4312
  down: Ar,
4285
4313
  up: Dr
4286
4314
  }, Symbol.toStringTag, { value: "Module" }));
4287
- async function Fr(e) {
4315
+ async function jr(e) {
4288
4316
  }
4289
4317
  async function Rr(e) {
4290
4318
  }
4291
4319
  const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4292
4320
  __proto__: null,
4293
4321
  down: Rr,
4294
- up: Fr
4322
+ up: jr
4295
4323
  }, Symbol.toStringTag, { value: "Module" }));
4296
4324
  async function Mr(e) {
4297
4325
  await e.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
@@ -4476,19 +4504,19 @@ async function Ds(e) {
4476
4504
  async function As(e) {
4477
4505
  await e.schema.dropTable("authentication_codes").execute();
4478
4506
  }
4479
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4507
+ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4480
4508
  __proto__: null,
4481
4509
  down: As,
4482
4510
  up: Ds
4483
4511
  }, Symbol.toStringTag, { value: "Module" }));
4484
- async function Fs(e) {
4512
+ async function js(e) {
4485
4513
  }
4486
4514
  async function Rs(e) {
4487
4515
  }
4488
4516
  const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4489
4517
  __proto__: null,
4490
4518
  down: Rs,
4491
- up: Fs
4519
+ up: js
4492
4520
  }, Symbol.toStringTag, { value: "Module" }));
4493
4521
  async function Ms(e) {
4494
4522
  await e.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
@@ -4723,12 +4751,12 @@ async function Ai(e) {
4723
4751
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4724
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();
4725
4753
  }
4726
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4754
+ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4727
4755
  __proto__: null,
4728
4756
  down: Ai,
4729
4757
  up: Di
4730
4758
  }, Symbol.toStringTag, { value: "Module" }));
4731
- async function Fi(e) {
4759
+ async function ji(e) {
4732
4760
  await e.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
4733
4761
  }
4734
4762
  async function Ri(e) {
@@ -4737,7 +4765,7 @@ async function Ri(e) {
4737
4765
  const Ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4738
4766
  __proto__: null,
4739
4767
  down: Ri,
4740
- up: Fi
4768
+ up: ji
4741
4769
  }, Symbol.toStringTag, { value: "Module" }));
4742
4770
  async function Mi(e) {
4743
4771
  }
@@ -4982,12 +5010,12 @@ async function Dc(e) {
4982
5010
  async function Ac(e) {
4983
5011
  await e.schema.dropTable("sessions_2").execute(), await e.schema.dropTable("refresh_tokens_2").execute();
4984
5012
  }
4985
- const jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5013
+ const Fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4986
5014
  __proto__: null,
4987
5015
  down: Ac,
4988
5016
  up: Dc
4989
5017
  }, Symbol.toStringTag, { value: "Module" }));
4990
- async function Fc(e) {
5018
+ async function jc(e) {
4991
5019
  await e.schema.createTable("custom_domains").addColumn(
4992
5020
  "custom_domain_id",
4993
5021
  "varchar(21)",
@@ -5008,7 +5036,7 @@ async function Rc(e) {
5008
5036
  const Jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5009
5037
  __proto__: null,
5010
5038
  down: Rc,
5011
- up: Fc
5039
+ up: jc
5012
5040
  }, Symbol.toStringTag, { value: "Module" }));
5013
5041
  async function Mc(e) {
5014
5042
  }
@@ -5298,12 +5326,12 @@ async function Dl(e) {
5298
5326
  async function Al(e) {
5299
5327
  await e.schema.dropTable("roles").execute(), await e.schema.dropTable("resource_servers").execute();
5300
5328
  }
5301
- const jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5329
+ const Fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5302
5330
  __proto__: null,
5303
5331
  down: Al,
5304
5332
  up: Dl
5305
5333
  }, Symbol.toStringTag, { value: "Module" }));
5306
- async function Fl(e) {
5334
+ async function jl(e) {
5307
5335
  await e.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("role_id", "varchar(21)", (t) => t.notNull()).addColumn(
5308
5336
  "resource_server_identifier",
5309
5337
  "varchar(191)",
@@ -5330,7 +5358,7 @@ async function Rl(e) {
5330
5358
  const Jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5331
5359
  __proto__: null,
5332
5360
  down: Rl,
5333
- up: Fl
5361
+ up: jl
5334
5362
  }, Symbol.toStringTag, { value: "Module" }));
5335
5363
  async function Ml(e) {
5336
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", [
@@ -5887,12 +5915,12 @@ const Dd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5887
5915
  async function Ad(e) {
5888
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();
5889
5917
  }
5890
- async function jd(e) {
5918
+ async function Fd(e) {
5891
5919
  await e.schema.dropTable("invites").execute();
5892
5920
  }
5893
- const Fd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5921
+ const jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5894
5922
  __proto__: null,
5895
- down: jd,
5923
+ down: Fd,
5896
5924
  up: Ad
5897
5925
  }, Symbol.toStringTag, { value: "Module" }));
5898
5926
  async function Rd(e) {
@@ -6188,7 +6216,7 @@ async function pu(e) {
6188
6216
  const t = await hu(e);
6189
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();
6190
6218
  }
6191
- async function F(e, t, a) {
6219
+ async function j(e, t, a) {
6192
6220
  try {
6193
6221
  await e.schema.dropIndex(t).on(a).execute();
6194
6222
  } catch (n) {
@@ -6207,7 +6235,7 @@ async function S(e, t, a) {
6207
6235
  }
6208
6236
  }
6209
6237
  async function fu(e) {
6210
- 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");
6211
6239
  }
6212
6240
  const gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6213
6241
  __proto__: null,
@@ -6338,20 +6366,20 @@ const Au = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6338
6366
  down: Du,
6339
6367
  up: Pu
6340
6368
  }, Symbol.toStringTag, { value: "Module" }));
6341
- async function ju(e) {
6369
+ async function Fu(e) {
6342
6370
  await e.schema.createTable("universal_login_templates").addColumn(
6343
6371
  "tenant_id",
6344
6372
  "varchar(191)",
6345
6373
  (t) => t.primaryKey().references("tenants.id").onDelete("cascade")
6346
6374
  ).addColumn("body", "text", (t) => t.notNull()).addColumn("updated_at_ts", "integer", (t) => t.notNull()).addColumn("created_at_ts", "integer", (t) => t.notNull()).execute();
6347
6375
  }
6348
- async function Fu(e) {
6376
+ async function ju(e) {
6349
6377
  await e.schema.dropTable("universal_login_templates").execute();
6350
6378
  }
6351
6379
  const Ru = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6352
6380
  __proto__: null,
6353
- down: Fu,
6354
- up: ju
6381
+ down: ju,
6382
+ up: Fu
6355
6383
  }, Symbol.toStringTag, { value: "Module" }));
6356
6384
  async function Ju(e) {
6357
6385
  await e.schema.createTable("custom_text").addColumn(
@@ -6704,12 +6732,12 @@ async function D_(e) {
6704
6732
  async function A_(e) {
6705
6733
  await e.schema.dropTable("actions").execute();
6706
6734
  }
6707
- const j_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6735
+ const F_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6708
6736
  __proto__: null,
6709
6737
  down: A_,
6710
6738
  up: D_
6711
6739
  }, Symbol.toStringTag, { value: "Module" }));
6712
- async function F_(e) {
6740
+ async function j_(e) {
6713
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();
6714
6742
  }
6715
6743
  async function R_(e) {
@@ -6718,7 +6746,7 @@ async function R_(e) {
6718
6746
  const J_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6719
6747
  __proto__: null,
6720
6748
  down: R_,
6721
- up: F_
6749
+ up: j_
6722
6750
  }, Symbol.toStringTag, { value: "Module" }));
6723
6751
  async function M_(e) {
6724
6752
  await e.schema.alterTable("users").addColumn("registration_completed_at", "varchar(35)").execute(), await e.updateTable("users").set({
@@ -6761,7 +6789,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6761
6789
  n15_userEmailIndex: Or,
6762
6790
  n16_userLocale: Er,
6763
6791
  n17_signingKeys: Pr,
6764
- n18_logsFields: jr,
6792
+ n18_logsFields: Fr,
6765
6793
  n19_connectionsUserinfo: Jr,
6766
6794
  n20_missingFields: Kr,
6767
6795
  n21_sessionDeletedAt: Br,
@@ -6779,7 +6807,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6779
6807
  n33_vendorIdInUniversalLoginSession: Os,
6780
6808
  n34_auth0ClientInUniversalLoginSession: Es,
6781
6809
  n35_increaseUniversalSessionStateLength: Ps,
6782
- n36_authenticationCodes: js,
6810
+ n36_authenticationCodes: Fs,
6783
6811
  n37_disableSignUps: Js,
6784
6812
  n38_otpIpAddress: Ks,
6785
6813
  n39_increaseUserAgentLength: Bs,
@@ -6797,7 +6825,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6797
6825
  n51_connectionid: Oi,
6798
6826
  n52_cert: Ei,
6799
6827
  n53_codes_primary_key: Pi,
6800
- n54_cleanup_tables: ji,
6828
+ n54_cleanup_tables: Fi,
6801
6829
  n55_logs_index: Ji,
6802
6830
  n56_application_fields: Ki,
6803
6831
  n57_prompt_settings: Bi,
@@ -6815,7 +6843,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6815
6843
  n70_refresh_tokens: Oc,
6816
6844
  n71_session_new_fields: Ec,
6817
6845
  n72_session_primary_key: Pc,
6818
- n73_drop_sessions: jc,
6846
+ n73_drop_sessions: Fc,
6819
6847
  n74_custom_domains: Jc,
6820
6848
  n75_organizations: Kc,
6821
6849
  n76_authorization_url_length: Bc,
@@ -6833,7 +6861,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6833
6861
  n88_add_redirect_uri_to_codes: Ol,
6834
6862
  n89_add_nonce_and_state_to_codes: El,
6835
6863
  n90_themes: Pl,
6836
- n91_resource_servers_rules_permissions: jl,
6864
+ n91_resource_servers_rules_permissions: Fl,
6837
6865
  n92_role_permissions: Jl,
6838
6866
  n93_add_permissions_to_roles: Kl,
6839
6867
  n94_keys_connection_and_extend_columns: Bl,
@@ -6850,7 +6878,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6850
6878
  o006_remove_redundant_user_organizations_tenant_index: kd,
6851
6879
  o007_tenant_settings: Id,
6852
6880
  o008_merge_tenant_settings_into_tenants: Dd,
6853
- o009_create_invites_table: Fd,
6881
+ o009_create_invites_table: jd,
6854
6882
  o010_add_log_id_to_logs: Md,
6855
6883
  o011_add_location_info_to_logs: qd,
6856
6884
  o012_add_password_history: Qd,
@@ -6885,7 +6913,7 @@ const B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6885
6913
  o041_add_outbox_claim_columns: O_,
6886
6914
  o042_add_outbox_claim_index: E_,
6887
6915
  o043_add_code_hooks: P_,
6888
- o044_create_actions: j_,
6916
+ o044_create_actions: F_,
6889
6917
  o045_outbox_dead_letter: J_,
6890
6918
  o046_user_registration_completed_at: K_,
6891
6919
  o047_outbox_dead_lettered_tenant_index: B_
@@ -6928,7 +6956,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6928
6956
  flows: ut(e),
6929
6957
  forms: Nn(e),
6930
6958
  hookCode: Ka(e),
6931
- hooks: Fa(e),
6959
+ hooks: ja(e),
6932
6960
  invites: fo(e),
6933
6961
  keys: ga(e),
6934
6962
  loginSessions: tn(e),
@@ -6941,7 +6969,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6941
6969
  rolePermissions: Mn(e),
6942
6970
  userPermissions: Bn(e),
6943
6971
  userRoles: Gn(e),
6944
- roles: jn(e),
6972
+ roles: Fn(e),
6945
6973
  sessions: $t(e),
6946
6974
  sessionCleanup: wn(e),
6947
6975
  tenants: wt(e),
@@ -6952,7 +6980,7 @@ function Q_(e, t = { useTransactions: !0 }) {
6952
6980
  organizations: ao(e),
6953
6981
  userOrganizations: lo(e),
6954
6982
  stats: wo(e),
6955
- outbox: jo(e),
6983
+ outbox: Fo(e),
6956
6984
  async transaction(n) {
6957
6985
  return t.useTransactions === !1 ? n(a) : e.transaction().execute(async (o) => {
6958
6986
  const r = Q_(o, {