@authhero/kysely-adapter 10.115.0 → 10.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +7 -7
- package/dist/kysely-adapter.mjs +438 -413
- package/package.json +1 -1
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Oe = Object.defineProperty;
|
|
2
2
|
var ke = (e, t, a) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
3
|
var K = (e, t, a) => ke(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
-
import { nanoid as
|
|
5
|
-
import { parseUserId as Ee, flowSchema as
|
|
4
|
+
import { nanoid as k, customAlphabet as $e } from "nanoid";
|
|
5
|
+
import { parseUserId as Ee, flowSchema as U, codeSchema as Ie, loginSessionSchema as ze, LoginSessionState as ie, promptSettingSchema as Pe, formSchema as q, resourceServerSchema as De } from "@authhero/adapter-interfaces";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
7
|
import { sql as h, Migrator as ce } from "kysely";
|
|
8
8
|
var F = class extends Error {
|
|
@@ -31,63 +31,49 @@ var F = class extends Error {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
function Ae(e
|
|
35
|
-
return async (
|
|
36
|
-
const { identities:
|
|
37
|
-
...
|
|
38
|
-
login_count:
|
|
34
|
+
function Ae(e) {
|
|
35
|
+
return async (t, a) => {
|
|
36
|
+
const { identities: n, phone_verified: o, password: r, ...s } = a, i = {
|
|
37
|
+
...s,
|
|
38
|
+
login_count: s.login_count ?? 0,
|
|
39
39
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40
40
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41
|
-
tenant_id:
|
|
42
|
-
email_verified:
|
|
43
|
-
phone_verified:
|
|
44
|
-
is_social:
|
|
45
|
-
app_metadata: JSON.stringify(
|
|
46
|
-
user_metadata: JSON.stringify(
|
|
47
|
-
address:
|
|
41
|
+
tenant_id: t,
|
|
42
|
+
email_verified: a.email_verified ? 1 : 0,
|
|
43
|
+
phone_verified: o !== void 0 ? o ? 1 : 0 : null,
|
|
44
|
+
is_social: a.is_social ? 1 : 0,
|
|
45
|
+
app_metadata: JSON.stringify(a.app_metadata),
|
|
46
|
+
user_metadata: JSON.stringify(a.user_metadata),
|
|
47
|
+
address: a.address ? JSON.stringify(a.address) : null
|
|
48
48
|
};
|
|
49
49
|
try {
|
|
50
|
-
|
|
51
|
-
if (await
|
|
52
|
-
const
|
|
53
|
-
id:
|
|
54
|
-
user_id:
|
|
55
|
-
password:
|
|
56
|
-
algorithm:
|
|
50
|
+
const d = async (u) => {
|
|
51
|
+
if (await u.insertInto("users").values(i).execute(), r && i.user_id) {
|
|
52
|
+
const c = {
|
|
53
|
+
id: k(),
|
|
54
|
+
user_id: i.user_id,
|
|
55
|
+
password: r.hash,
|
|
56
|
+
algorithm: r.algorithm,
|
|
57
57
|
is_current: 1,
|
|
58
58
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
59
59
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
60
|
-
tenant_id:
|
|
60
|
+
tenant_id: t
|
|
61
61
|
};
|
|
62
|
-
await
|
|
62
|
+
await u.insertInto("passwords").values(c).execute();
|
|
63
63
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (await d.insertInto("users").values(c).execute(), s && c.user_id) {
|
|
67
|
-
const u = {
|
|
68
|
-
id: b(),
|
|
69
|
-
user_id: c.user_id,
|
|
70
|
-
password: s.hash,
|
|
71
|
-
algorithm: s.algorithm,
|
|
72
|
-
is_current: 1,
|
|
73
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
74
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75
|
-
tenant_id: a
|
|
76
|
-
};
|
|
77
|
-
await d.insertInto("passwords").values(u).execute();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
64
|
+
};
|
|
65
|
+
e.isTransaction ? await d(e) : await e.transaction().execute(d);
|
|
80
66
|
} catch (d) {
|
|
81
67
|
throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new F(409, { message: "User already exists" }) : new F(500, { message: `${d.code}, ${d.message}` });
|
|
82
68
|
}
|
|
83
69
|
return {
|
|
84
|
-
...
|
|
70
|
+
...i,
|
|
85
71
|
// TODO: check if this is correct. Should it be optional?
|
|
86
|
-
email:
|
|
87
|
-
email_verified:
|
|
88
|
-
phone_verified:
|
|
89
|
-
is_social:
|
|
90
|
-
address:
|
|
72
|
+
email: i.email || "",
|
|
73
|
+
email_verified: i.email_verified === 1,
|
|
74
|
+
phone_verified: i.phone_verified !== null ? i.phone_verified === 1 : void 0,
|
|
75
|
+
is_social: i.is_social === 1,
|
|
76
|
+
address: a.address
|
|
91
77
|
// Return original address object, not serialized string
|
|
92
78
|
};
|
|
93
79
|
};
|
|
@@ -118,7 +104,7 @@ const je = [
|
|
|
118
104
|
"phone_verified",
|
|
119
105
|
"username"
|
|
120
106
|
];
|
|
121
|
-
function
|
|
107
|
+
function B(e, t = !1) {
|
|
122
108
|
const a = {
|
|
123
109
|
connection: e.connection,
|
|
124
110
|
provider: e.provider,
|
|
@@ -160,94 +146,94 @@ function Fe(e) {
|
|
|
160
146
|
user_metadata: JSON.parse(n.user_metadata),
|
|
161
147
|
address: n.address ? JSON.parse(n.address) : void 0,
|
|
162
148
|
identities: [
|
|
163
|
-
|
|
164
|
-
...o.map((
|
|
149
|
+
B(n, !0),
|
|
150
|
+
...o.map((d) => B(d))
|
|
165
151
|
]
|
|
166
152
|
};
|
|
167
153
|
return w(i);
|
|
168
154
|
};
|
|
169
155
|
}
|
|
170
|
-
function
|
|
156
|
+
function b(e, t, a, n) {
|
|
171
157
|
const o = a.split(/ OR /i);
|
|
172
158
|
if (o.length > 1)
|
|
173
|
-
return t.where((
|
|
174
|
-
const
|
|
159
|
+
return t.where((u) => {
|
|
160
|
+
const c = o.map((l) => {
|
|
175
161
|
const m = l.trim().match(/^([^:]+):(.+)$/);
|
|
176
162
|
if (m) {
|
|
177
163
|
const [, _, p] = m;
|
|
178
164
|
if (!_ || !p) return null;
|
|
179
165
|
const f = p.replace(/^"(.*)"$/, "$1");
|
|
180
|
-
return
|
|
166
|
+
return u(_.trim(), "=", f.trim());
|
|
181
167
|
}
|
|
182
168
|
return null;
|
|
183
169
|
}).filter(Boolean);
|
|
184
|
-
return
|
|
170
|
+
return u.or(c);
|
|
185
171
|
});
|
|
186
172
|
const r = [];
|
|
187
173
|
let s = "", i = !1;
|
|
188
|
-
for (let
|
|
189
|
-
const
|
|
190
|
-
|
|
174
|
+
for (let u = 0; u < a.length; u++) {
|
|
175
|
+
const c = a[u];
|
|
176
|
+
c === '"' ? (i = !i, s += c) : c === " " && !i ? s.trim() && (r.push(s.trim()), s = "") : s += c;
|
|
191
177
|
}
|
|
192
|
-
return s.trim() && r.push(s.trim()), r.map((
|
|
193
|
-
let
|
|
194
|
-
if (
|
|
195
|
-
l =
|
|
196
|
-
else if (
|
|
197
|
-
l =
|
|
198
|
-
else if (
|
|
199
|
-
const f =
|
|
178
|
+
return s.trim() && r.push(s.trim()), r.map((u) => u.replace(/^([^:]+)=/g, "$1:")).map((u) => {
|
|
179
|
+
let c = u.startsWith("-"), l = null, m = "", _ = !1, p;
|
|
180
|
+
if (u.startsWith("-_exists_:"))
|
|
181
|
+
l = u.substring(10), _ = !0, c = !0;
|
|
182
|
+
else if (u.startsWith("_exists_:"))
|
|
183
|
+
l = u.substring(9), _ = !0, c = !1;
|
|
184
|
+
else if (u.includes(":")) {
|
|
185
|
+
const f = c ? u.substring(1) : u, g = f.indexOf(":");
|
|
200
186
|
l = f.substring(0, g), m = f.substring(g + 1), _ = !1, m.startsWith(">=") ? (p = ">=", m = m.substring(2)) : m.startsWith(">") ? (p = ">", m = m.substring(1)) : m.startsWith("<=") ? (p = "<=", m = m.substring(2)) : m.startsWith("<") ? (p = "<", m = m.substring(1)) : p = "=", m.startsWith('"') && m.endsWith('"') && m.length > 1 && (m = m.slice(1, -1));
|
|
201
187
|
} else
|
|
202
|
-
l = null, m =
|
|
203
|
-
return { key: l, value: m, isNegation:
|
|
204
|
-
}).forEach(({ key:
|
|
205
|
-
if (
|
|
188
|
+
l = null, m = u, _ = !1;
|
|
189
|
+
return { key: l, value: m, isNegation: c, isExistsQuery: _, operator: p };
|
|
190
|
+
}).forEach(({ key: u, value: c, isNegation: l, isExistsQuery: m, operator: _ }) => {
|
|
191
|
+
if (u)
|
|
206
192
|
if (m)
|
|
207
|
-
l ? t = t.where(
|
|
193
|
+
l ? t = t.where(u, "is", null) : t = t.where(u, "is not", null);
|
|
208
194
|
else if (l)
|
|
209
195
|
switch (_) {
|
|
210
196
|
case ">":
|
|
211
|
-
t = t.where(
|
|
197
|
+
t = t.where(u, "<=", c);
|
|
212
198
|
break;
|
|
213
199
|
case ">=":
|
|
214
|
-
t = t.where(
|
|
200
|
+
t = t.where(u, "<", c);
|
|
215
201
|
break;
|
|
216
202
|
case "<":
|
|
217
|
-
t = t.where(
|
|
203
|
+
t = t.where(u, ">=", c);
|
|
218
204
|
break;
|
|
219
205
|
case "<=":
|
|
220
|
-
t = t.where(
|
|
206
|
+
t = t.where(u, ">", c);
|
|
221
207
|
break;
|
|
222
208
|
default:
|
|
223
|
-
t = t.where(
|
|
209
|
+
t = t.where(u, "!=", c);
|
|
224
210
|
}
|
|
225
211
|
else
|
|
226
|
-
t = t.where(
|
|
227
|
-
else if (
|
|
228
|
-
const { ref: p } = e.dynamic, f =
|
|
212
|
+
t = t.where(u, _, c);
|
|
213
|
+
else if (c) {
|
|
214
|
+
const { ref: p } = e.dynamic, f = c.includes("|") ? [...n, "user_id"] : n;
|
|
229
215
|
t = t.where(
|
|
230
216
|
(g) => g.or(
|
|
231
217
|
f.map(
|
|
232
|
-
(y) => y === "user_id" ? g(p(y), "=",
|
|
218
|
+
(y) => y === "user_id" ? g(p(y), "=", c) : g(p(y), "like", `%${c}%`)
|
|
233
219
|
)
|
|
234
220
|
)
|
|
235
221
|
);
|
|
236
222
|
}
|
|
237
223
|
}), t;
|
|
238
224
|
}
|
|
239
|
-
function
|
|
225
|
+
function O(e) {
|
|
240
226
|
return typeof e == "string" ? parseInt(e, 10) : typeof e == "bigint" ? Number(e) : e;
|
|
241
227
|
}
|
|
242
228
|
function Re(e) {
|
|
243
229
|
return async (t, a = {}) => {
|
|
244
230
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
|
|
245
|
-
let
|
|
246
|
-
if (i && (
|
|
231
|
+
let d = e.selectFrom("users").where("users.tenant_id", "=", t);
|
|
232
|
+
if (i && (d = b(e, d, i, ["email", "name", "phone_number"])), s && s.sort_by) {
|
|
247
233
|
const { ref: f } = e.dynamic;
|
|
248
|
-
|
|
234
|
+
d = d.orderBy(f(s.sort_by), s.sort_order);
|
|
249
235
|
}
|
|
250
|
-
const
|
|
236
|
+
const c = await d.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) => {
|
|
251
237
|
const g = m.filter(
|
|
252
238
|
(y) => y.linked_to === f.user_id
|
|
253
239
|
);
|
|
@@ -260,8 +246,8 @@ function Re(e) {
|
|
|
260
246
|
user_metadata: JSON.parse(f.user_metadata),
|
|
261
247
|
address: f.address ? JSON.parse(f.address) : void 0,
|
|
262
248
|
identities: [
|
|
263
|
-
|
|
264
|
-
...g.map((y) =>
|
|
249
|
+
B(f, !0),
|
|
250
|
+
...g.map((y) => B(y))
|
|
265
251
|
]
|
|
266
252
|
});
|
|
267
253
|
});
|
|
@@ -272,12 +258,12 @@ function Re(e) {
|
|
|
272
258
|
limit: 0,
|
|
273
259
|
length: 0
|
|
274
260
|
};
|
|
275
|
-
const { count: p } = await
|
|
261
|
+
const { count: p } = await d.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
276
262
|
return {
|
|
277
263
|
users: _,
|
|
278
264
|
start: n * o,
|
|
279
265
|
limit: o,
|
|
280
|
-
length:
|
|
266
|
+
length: O(p)
|
|
281
267
|
};
|
|
282
268
|
};
|
|
283
269
|
}
|
|
@@ -338,9 +324,9 @@ function Le(e) {
|
|
|
338
324
|
return (await e.updateTable("users").set(r).where("users.tenant_id", "=", t).where("users.user_id", "=", `${n}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
|
|
339
325
|
};
|
|
340
326
|
}
|
|
341
|
-
function Ke(e
|
|
327
|
+
function Ke(e) {
|
|
342
328
|
return {
|
|
343
|
-
create: Ae(e
|
|
329
|
+
create: Ae(e),
|
|
344
330
|
remove: Me(e),
|
|
345
331
|
get: Fe(e),
|
|
346
332
|
list: Re(e),
|
|
@@ -351,8 +337,8 @@ function Ke(e, t) {
|
|
|
351
337
|
}
|
|
352
338
|
function qe(e) {
|
|
353
339
|
return async (t, a) => {
|
|
354
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), o =
|
|
355
|
-
id: `af_${
|
|
340
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), o = U.parse({
|
|
341
|
+
id: `af_${k()}`,
|
|
356
342
|
...a,
|
|
357
343
|
actions: a.actions || [],
|
|
358
344
|
created_at: n,
|
|
@@ -383,7 +369,7 @@ function de(e, t, a = { ...e }) {
|
|
|
383
369
|
));
|
|
384
370
|
return a;
|
|
385
371
|
}
|
|
386
|
-
function
|
|
372
|
+
function Be(e) {
|
|
387
373
|
return async (t, a) => {
|
|
388
374
|
const n = await e.selectFrom("flows").selectAll().where("flows.id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
|
|
389
375
|
if (!n) return null;
|
|
@@ -391,34 +377,34 @@ function Ue(e) {
|
|
|
391
377
|
...n,
|
|
392
378
|
actions: P(n.actions, [])
|
|
393
379
|
};
|
|
394
|
-
return
|
|
380
|
+
return U.parse(w(o));
|
|
395
381
|
};
|
|
396
382
|
}
|
|
397
|
-
function
|
|
383
|
+
function Ue(e) {
|
|
398
384
|
return async (t, a = {}) => {
|
|
399
385
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
|
|
400
386
|
let i = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
401
|
-
s && (i =
|
|
402
|
-
const
|
|
387
|
+
s && (i = b(e, i, s, []));
|
|
388
|
+
const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
|
|
403
389
|
const _ = {
|
|
404
390
|
...m,
|
|
405
391
|
actions: P(m.actions, [])
|
|
406
392
|
};
|
|
407
|
-
return
|
|
393
|
+
return U.parse(w(_));
|
|
408
394
|
});
|
|
409
395
|
if (!r)
|
|
410
396
|
return {
|
|
411
|
-
flows:
|
|
397
|
+
flows: c,
|
|
412
398
|
start: 0,
|
|
413
399
|
limit: 0,
|
|
414
400
|
length: 0
|
|
415
401
|
};
|
|
416
402
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
417
403
|
return {
|
|
418
|
-
flows:
|
|
404
|
+
flows: c,
|
|
419
405
|
start: n * o,
|
|
420
406
|
limit: o,
|
|
421
|
-
length:
|
|
407
|
+
length: O(l)
|
|
422
408
|
};
|
|
423
409
|
};
|
|
424
410
|
}
|
|
@@ -432,7 +418,7 @@ function Qe(e) {
|
|
|
432
418
|
const { numUpdatedRows: r } = await e.updateTable("flows").set(o).where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
|
|
433
419
|
if (r === 0n) return null;
|
|
434
420
|
const s = await e.selectFrom("flows").selectAll().where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
|
|
435
|
-
return s ?
|
|
421
|
+
return s ? U.parse({
|
|
436
422
|
...s,
|
|
437
423
|
actions: s.actions ? JSON.parse(s.actions) : []
|
|
438
424
|
}) : null;
|
|
@@ -447,8 +433,8 @@ function He(e) {
|
|
|
447
433
|
function Ye(e) {
|
|
448
434
|
return {
|
|
449
435
|
create: qe(e),
|
|
450
|
-
get:
|
|
451
|
-
list:
|
|
436
|
+
get: Be(e),
|
|
437
|
+
list: Ue(e),
|
|
452
438
|
update: Qe(e),
|
|
453
439
|
remove: He(e)
|
|
454
440
|
};
|
|
@@ -504,7 +490,7 @@ function Ge(e) {
|
|
|
504
490
|
return async (t) => {
|
|
505
491
|
var o, r;
|
|
506
492
|
const a = {
|
|
507
|
-
id: t.id ||
|
|
493
|
+
id: t.id || k(),
|
|
508
494
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
509
495
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
510
496
|
...t
|
|
@@ -539,15 +525,15 @@ function Xe(e) {
|
|
|
539
525
|
const { ref: _ } = e.dynamic;
|
|
540
526
|
a = a.orderBy(_(s.sort_by), s.sort_order);
|
|
541
527
|
}
|
|
542
|
-
i && (a =
|
|
543
|
-
const
|
|
528
|
+
i && (a = b(e, a, i, ["friendly_name"]));
|
|
529
|
+
const c = (await a.offset(n * o).limit(o).selectAll().execute()).map(_e);
|
|
544
530
|
if (!r)
|
|
545
531
|
return {
|
|
546
|
-
tenants:
|
|
532
|
+
tenants: c
|
|
547
533
|
};
|
|
548
|
-
const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m =
|
|
534
|
+
const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = O(l);
|
|
549
535
|
return {
|
|
550
|
-
tenants:
|
|
536
|
+
tenants: c,
|
|
551
537
|
start: n * o,
|
|
552
538
|
limit: o,
|
|
553
539
|
length: m
|
|
@@ -582,18 +568,18 @@ function Z(e) {
|
|
|
582
568
|
const at = 256;
|
|
583
569
|
function nt(e) {
|
|
584
570
|
return async (t, a) => {
|
|
585
|
-
var i,
|
|
586
|
-
const n = (i = a.user_agent) == null ? void 0 : i.slice(0, at), o = a.log_id ||
|
|
571
|
+
var i, d, u;
|
|
572
|
+
const n = (i = a.user_agent) == null ? void 0 : i.slice(0, at), o = a.log_id || k(), { location_info: r, ...s } = a;
|
|
587
573
|
return await e.insertInto("logs").values({
|
|
588
574
|
...s,
|
|
589
575
|
log_id: o,
|
|
590
576
|
tenant_id: t,
|
|
591
577
|
user_agent: n,
|
|
592
|
-
description: (
|
|
578
|
+
description: (d = a.description) == null ? void 0 : d.substring(0, 256),
|
|
593
579
|
isMobile: a.isMobile ? 1 : 0,
|
|
594
580
|
scope: a.scope,
|
|
595
581
|
auth0_client: Z(a.auth0_client),
|
|
596
|
-
details: (
|
|
582
|
+
details: (u = Z(a.details)) == null ? void 0 : u.substring(0, 8192),
|
|
597
583
|
// Extract location_info fields for separate columns
|
|
598
584
|
country_code: r == null ? void 0 : r.country_code,
|
|
599
585
|
city_name: r == null ? void 0 : r.city_name,
|
|
@@ -641,15 +627,15 @@ function he(e) {
|
|
|
641
627
|
function ot(e) {
|
|
642
628
|
return async (t, a = {}) => {
|
|
643
629
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
|
|
644
|
-
let
|
|
645
|
-
i && (
|
|
646
|
-
let
|
|
630
|
+
let d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
631
|
+
i && (d = b(e, d, i, ["user_id", "ip"]));
|
|
632
|
+
let u = d;
|
|
647
633
|
if (s && s.sort_by) {
|
|
648
634
|
const { ref: _ } = e.dynamic;
|
|
649
|
-
|
|
635
|
+
u = u.orderBy(_(s.sort_by), s.sort_order);
|
|
650
636
|
}
|
|
651
|
-
|
|
652
|
-
const l = (await
|
|
637
|
+
u = u.offset(n * o).limit(o);
|
|
638
|
+
const l = (await u.selectAll().execute()).map(he);
|
|
653
639
|
if (!r)
|
|
654
640
|
return {
|
|
655
641
|
logs: l,
|
|
@@ -657,12 +643,12 @@ function ot(e) {
|
|
|
657
643
|
limit: 0,
|
|
658
644
|
length: 0
|
|
659
645
|
};
|
|
660
|
-
const { count: m } = await
|
|
646
|
+
const { count: m } = await d.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
661
647
|
return {
|
|
662
648
|
logs: l,
|
|
663
649
|
start: n * o,
|
|
664
650
|
limit: o,
|
|
665
|
-
length:
|
|
651
|
+
length: O(m)
|
|
666
652
|
};
|
|
667
653
|
};
|
|
668
654
|
}
|
|
@@ -725,9 +711,9 @@ function it(e) {
|
|
|
725
711
|
device: r,
|
|
726
712
|
clients: s,
|
|
727
713
|
created_at_ts: i,
|
|
728
|
-
updated_at_ts:
|
|
729
|
-
expires_at_ts:
|
|
730
|
-
idle_expires_at_ts:
|
|
714
|
+
updated_at_ts: d,
|
|
715
|
+
expires_at_ts: u,
|
|
716
|
+
idle_expires_at_ts: c,
|
|
731
717
|
authenticated_at_ts: l,
|
|
732
718
|
last_interaction_at_ts: m,
|
|
733
719
|
used_at_ts: _,
|
|
@@ -736,9 +722,9 @@ function it(e) {
|
|
|
736
722
|
} = n, g = D(
|
|
737
723
|
{
|
|
738
724
|
created_at_ts: i,
|
|
739
|
-
updated_at_ts:
|
|
740
|
-
expires_at_ts:
|
|
741
|
-
idle_expires_at_ts:
|
|
725
|
+
updated_at_ts: d,
|
|
726
|
+
expires_at_ts: u,
|
|
727
|
+
idle_expires_at_ts: c,
|
|
742
728
|
authenticated_at_ts: l,
|
|
743
729
|
last_interaction_at_ts: m,
|
|
744
730
|
used_at_ts: _,
|
|
@@ -771,9 +757,9 @@ function ct(e) {
|
|
|
771
757
|
}, {
|
|
772
758
|
expires_at: s,
|
|
773
759
|
idle_expires_at: i,
|
|
774
|
-
used_at:
|
|
775
|
-
revoked_at:
|
|
776
|
-
device:
|
|
760
|
+
used_at: d,
|
|
761
|
+
revoked_at: u,
|
|
762
|
+
device: c,
|
|
777
763
|
clients: l,
|
|
778
764
|
...m
|
|
779
765
|
} = a;
|
|
@@ -786,9 +772,9 @@ function ct(e) {
|
|
|
786
772
|
last_interaction_at_ts: n,
|
|
787
773
|
expires_at_ts: v(s),
|
|
788
774
|
idle_expires_at_ts: v(i),
|
|
789
|
-
used_at_ts: v(
|
|
790
|
-
revoked_at_ts: v(
|
|
791
|
-
device: JSON.stringify(
|
|
775
|
+
used_at_ts: v(d),
|
|
776
|
+
revoked_at_ts: v(u),
|
|
777
|
+
device: JSON.stringify(c),
|
|
792
778
|
clients: JSON.stringify(l)
|
|
793
779
|
}).execute(), r;
|
|
794
780
|
};
|
|
@@ -811,15 +797,15 @@ function dt(e) {
|
|
|
811
797
|
function ut(e) {
|
|
812
798
|
return async (t, a = {}) => {
|
|
813
799
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
|
|
814
|
-
let
|
|
815
|
-
i && (
|
|
816
|
-
let
|
|
800
|
+
let d = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
801
|
+
i && (d = b(e, d, i, ["user_id", "session_id"]));
|
|
802
|
+
let u = d;
|
|
817
803
|
if (s && s.sort_by) {
|
|
818
804
|
const { ref: p } = e.dynamic;
|
|
819
|
-
|
|
805
|
+
u = u.orderBy(p(s.sort_by), s.sort_order);
|
|
820
806
|
}
|
|
821
|
-
|
|
822
|
-
const l = (await
|
|
807
|
+
u = u.offset(n * o).limit(o);
|
|
808
|
+
const l = (await u.selectAll().execute()).map((p) => {
|
|
823
809
|
const {
|
|
824
810
|
tenant_id: f,
|
|
825
811
|
device: g,
|
|
@@ -866,7 +852,7 @@ function ut(e) {
|
|
|
866
852
|
limit: 0,
|
|
867
853
|
length: 0
|
|
868
854
|
};
|
|
869
|
-
const { count: m } = await
|
|
855
|
+
const { count: m } = await d.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = O(m);
|
|
870
856
|
return {
|
|
871
857
|
sessions: l,
|
|
872
858
|
start: n * o,
|
|
@@ -898,7 +884,7 @@ function mt(e) {
|
|
|
898
884
|
}
|
|
899
885
|
function ht(e) {
|
|
900
886
|
return async (t, a) => {
|
|
901
|
-
const n = a.id ||
|
|
887
|
+
const n = a.id || k(), o = a.is_current ?? !0, r = {
|
|
902
888
|
id: n,
|
|
903
889
|
...a,
|
|
904
890
|
is_current: o,
|
|
@@ -944,24 +930,24 @@ function wt(e) {
|
|
|
944
930
|
return async (t, a = {}) => {
|
|
945
931
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
|
|
946
932
|
let i = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
947
|
-
s && (i =
|
|
948
|
-
const
|
|
933
|
+
s && (i = b(e, i, s, ["code", "login_id"]));
|
|
934
|
+
const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
|
|
949
935
|
const { tenant_id: _, ...p } = m;
|
|
950
936
|
return Ie.parse(w(p));
|
|
951
937
|
});
|
|
952
938
|
if (!r)
|
|
953
939
|
return {
|
|
954
|
-
codes:
|
|
940
|
+
codes: c,
|
|
955
941
|
start: 0,
|
|
956
942
|
limit: 0,
|
|
957
943
|
length: 0
|
|
958
944
|
};
|
|
959
945
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
960
946
|
return {
|
|
961
|
-
codes:
|
|
947
|
+
codes: c,
|
|
962
948
|
start: n * o,
|
|
963
949
|
limit: o,
|
|
964
|
-
length:
|
|
950
|
+
length: O(l)
|
|
965
951
|
};
|
|
966
952
|
};
|
|
967
953
|
}
|
|
@@ -1066,21 +1052,21 @@ function Dt(e) {
|
|
|
1066
1052
|
return async (t, a = {}) => {
|
|
1067
1053
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
|
|
1068
1054
|
let i = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1069
|
-
s && (i =
|
|
1070
|
-
const
|
|
1055
|
+
s && (i = b(e, i, s, ["user_id", "ip"]));
|
|
1056
|
+
const u = await i.offset(n * o).limit(o).selectAll().execute(), c = Pt(u);
|
|
1071
1057
|
if (!r)
|
|
1072
1058
|
return {
|
|
1073
|
-
connections:
|
|
1059
|
+
connections: c,
|
|
1074
1060
|
start: 0,
|
|
1075
1061
|
limit: 0,
|
|
1076
1062
|
length: 0
|
|
1077
1063
|
};
|
|
1078
1064
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1079
1065
|
return {
|
|
1080
|
-
connections:
|
|
1066
|
+
connections: c,
|
|
1081
1067
|
start: n * o,
|
|
1082
1068
|
limit: o,
|
|
1083
|
-
length:
|
|
1069
|
+
length: O(l)
|
|
1084
1070
|
};
|
|
1085
1071
|
};
|
|
1086
1072
|
}
|
|
@@ -1273,53 +1259,92 @@ function Lt(e) {
|
|
|
1273
1259
|
function Kt(e) {
|
|
1274
1260
|
return async (t, a) => {
|
|
1275
1261
|
let n = e.selectFrom("clients").where("clients.tenant_id", "=", t);
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1262
|
+
if (a != null && a.q && (n = n.where(
|
|
1263
|
+
(c) => c.or([
|
|
1264
|
+
c("name", "like", `%${a.q}%`),
|
|
1265
|
+
c("client_id", "like", `%${a.q}%`)
|
|
1266
|
+
])
|
|
1267
|
+
)), a != null && a.sort) {
|
|
1268
|
+
const c = a.sort.sort_order === "asc" ? "asc" : "desc", l = a.sort.sort_by;
|
|
1269
|
+
["name", "client_id", "created_at", "updated_at"].includes(l) ? n = n.orderBy(l, c) : n = n.orderBy("created_at", "desc");
|
|
1270
|
+
} else
|
|
1271
|
+
n = n.orderBy("created_at", "desc");
|
|
1272
|
+
if ((a == null ? void 0 : a.from) !== void 0) {
|
|
1273
|
+
const c = parseInt(a.from, 10);
|
|
1274
|
+
isNaN(c) || (n = n.offset(c));
|
|
1275
|
+
} else if ((a == null ? void 0 : a.page) !== void 0) {
|
|
1276
|
+
const c = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, l = a.page * c;
|
|
1277
|
+
n = n.offset(l);
|
|
1278
|
+
}
|
|
1279
|
+
const o = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10;
|
|
1280
|
+
n = n.limit(o);
|
|
1281
|
+
const r = await n.selectAll().execute();
|
|
1282
|
+
let s = r.length;
|
|
1283
|
+
if (a != null && a.include_totals) {
|
|
1284
|
+
let c = e.selectFrom("clients").select(h`count(*)`.as("count")).where("clients.tenant_id", "=", t);
|
|
1285
|
+
a != null && a.q && (c = c.where(
|
|
1286
|
+
(m) => m.or([
|
|
1287
|
+
m("name", "like", `%${a.q}%`),
|
|
1288
|
+
m("client_id", "like", `%${a.q}%`)
|
|
1289
|
+
])
|
|
1290
|
+
));
|
|
1291
|
+
const l = await c.executeTakeFirst();
|
|
1292
|
+
s = Number((l == null ? void 0 : l.count) || 0);
|
|
1293
|
+
}
|
|
1294
|
+
const i = r.map((c) => ({
|
|
1295
|
+
...c,
|
|
1296
|
+
// Convert integer fields back to booleans
|
|
1297
|
+
global: !!c.global,
|
|
1298
|
+
is_first_party: !!c.is_first_party,
|
|
1299
|
+
oidc_conformant: !!c.oidc_conformant,
|
|
1300
|
+
auth0_conformant: !!c.auth0_conformant,
|
|
1301
|
+
sso: !!c.sso,
|
|
1302
|
+
sso_disabled: !!c.sso_disabled,
|
|
1303
|
+
cross_origin_authentication: !!c.cross_origin_authentication,
|
|
1304
|
+
custom_login_page_on: !!c.custom_login_page_on,
|
|
1305
|
+
require_pushed_authorization_requests: !!c.require_pushed_authorization_requests,
|
|
1306
|
+
require_proof_of_possession: !!c.require_proof_of_possession,
|
|
1307
|
+
// Parse JSON string fields back to objects/arrays
|
|
1308
|
+
callbacks: JSON.parse(c.callbacks),
|
|
1309
|
+
allowed_origins: JSON.parse(c.allowed_origins),
|
|
1310
|
+
web_origins: JSON.parse(c.web_origins),
|
|
1311
|
+
client_aliases: JSON.parse(c.client_aliases),
|
|
1312
|
+
allowed_clients: JSON.parse(c.allowed_clients),
|
|
1313
|
+
connections: JSON.parse(c.connections || "[]"),
|
|
1314
|
+
allowed_logout_urls: JSON.parse(c.allowed_logout_urls),
|
|
1315
|
+
session_transfer: JSON.parse(c.session_transfer),
|
|
1316
|
+
oidc_logout: JSON.parse(c.oidc_logout),
|
|
1317
|
+
grant_types: JSON.parse(c.grant_types),
|
|
1318
|
+
jwt_configuration: JSON.parse(c.jwt_configuration),
|
|
1319
|
+
signing_keys: JSON.parse(c.signing_keys),
|
|
1320
|
+
encryption_key: JSON.parse(c.encryption_key),
|
|
1321
|
+
addons: JSON.parse(c.addons),
|
|
1322
|
+
client_metadata: JSON.parse(c.client_metadata),
|
|
1323
|
+
mobile: JSON.parse(c.mobile),
|
|
1324
|
+
native_social_login: JSON.parse(c.native_social_login),
|
|
1325
|
+
refresh_token: JSON.parse(c.refresh_token),
|
|
1326
|
+
default_organization: JSON.parse(c.default_organization),
|
|
1327
|
+
client_authentication_methods: JSON.parse(
|
|
1328
|
+
c.client_authentication_methods
|
|
1329
|
+
),
|
|
1330
|
+
signed_request_object: JSON.parse(c.signed_request_object),
|
|
1331
|
+
token_quota: JSON.parse(c.token_quota)
|
|
1332
|
+
})), d = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, u = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * d : 0;
|
|
1333
|
+
return {
|
|
1334
|
+
clients: i,
|
|
1335
|
+
totals: {
|
|
1336
|
+
start: isNaN(u) ? 0 : u,
|
|
1337
|
+
limit: d,
|
|
1338
|
+
length: i.length,
|
|
1339
|
+
total: s
|
|
1340
|
+
}
|
|
1316
1341
|
};
|
|
1317
1342
|
};
|
|
1318
1343
|
}
|
|
1319
1344
|
function qt(e) {
|
|
1320
1345
|
return async (t, a) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
|
|
1321
1346
|
}
|
|
1322
|
-
function
|
|
1347
|
+
function Bt(e) {
|
|
1323
1348
|
return async (t, a, n) => {
|
|
1324
1349
|
const o = {
|
|
1325
1350
|
...n,
|
|
@@ -1370,14 +1395,14 @@ function Ut(e) {
|
|
|
1370
1395
|
), (await e.updateTable("clients").set(o).where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
|
|
1371
1396
|
};
|
|
1372
1397
|
}
|
|
1373
|
-
function
|
|
1398
|
+
function Ut(e) {
|
|
1374
1399
|
return {
|
|
1375
1400
|
create: Mt(e),
|
|
1376
1401
|
get: Jt(e),
|
|
1377
1402
|
getByClientId: Lt(e),
|
|
1378
1403
|
list: Kt(e),
|
|
1379
1404
|
remove: qt(e),
|
|
1380
|
-
update:
|
|
1405
|
+
update: Bt(e)
|
|
1381
1406
|
};
|
|
1382
1407
|
}
|
|
1383
1408
|
function Qt(e) {
|
|
@@ -1445,7 +1470,7 @@ function Vt(e) {
|
|
|
1445
1470
|
}
|
|
1446
1471
|
function Xt(e) {
|
|
1447
1472
|
return async (t, a) => {
|
|
1448
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), o =
|
|
1473
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), o = k(), { scope: r, authorization_details_types: s, ...i } = a, d = {
|
|
1449
1474
|
id: o,
|
|
1450
1475
|
tenant_id: t,
|
|
1451
1476
|
...i,
|
|
@@ -1457,7 +1482,7 @@ function Xt(e) {
|
|
|
1457
1482
|
created_at: n,
|
|
1458
1483
|
updated_at: n
|
|
1459
1484
|
};
|
|
1460
|
-
return await e.insertInto("client_grants").values(
|
|
1485
|
+
return await e.insertInto("client_grants").values(d).execute(), w({
|
|
1461
1486
|
id: o,
|
|
1462
1487
|
tenant_id: t,
|
|
1463
1488
|
...i,
|
|
@@ -1496,27 +1521,27 @@ function Zt(e) {
|
|
|
1496
1521
|
function ea(e) {
|
|
1497
1522
|
return async (t, a = {}) => {
|
|
1498
1523
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
|
|
1499
|
-
let
|
|
1524
|
+
let d = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
|
|
1500
1525
|
if (s) {
|
|
1501
1526
|
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] : "", S = /^(>=|>|<=|<)/.test(y || "");
|
|
1502
1527
|
if (g && !S && y) {
|
|
1503
1528
|
const C = !!g[1], $ = g[2], { ref: I } = e.dynamic, E = I(`client_grants.${$}`);
|
|
1504
1529
|
if ($ === "allow_any_organization") {
|
|
1505
1530
|
const z = y === "true" ? 1 : 0;
|
|
1506
|
-
C ?
|
|
1531
|
+
C ? d = d.where(E, "!=", z) : d = d.where(E, "=", z);
|
|
1507
1532
|
} else
|
|
1508
|
-
C ?
|
|
1533
|
+
C ? d = d.where(E, "!=", y) : d = d.where(E, "=", y);
|
|
1509
1534
|
} else
|
|
1510
|
-
|
|
1535
|
+
d = b(e, d, _, []);
|
|
1511
1536
|
}
|
|
1512
|
-
let
|
|
1537
|
+
let u = d;
|
|
1513
1538
|
if (i) {
|
|
1514
1539
|
const { ref: _ } = e.dynamic;
|
|
1515
|
-
|
|
1540
|
+
u = u.orderBy(_(i.sort_by), i.sort_order);
|
|
1516
1541
|
} else
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
const l = (await
|
|
1542
|
+
u = u.orderBy("client_grants.created_at", "desc");
|
|
1543
|
+
u = u.limit(o).offset(n * o);
|
|
1544
|
+
const l = (await u.selectAll().execute()).map((_) => {
|
|
1520
1545
|
const p = {
|
|
1521
1546
|
id: _.id,
|
|
1522
1547
|
client_id: _.client_id,
|
|
@@ -1540,12 +1565,12 @@ function ea(e) {
|
|
|
1540
1565
|
limit: 0,
|
|
1541
1566
|
length: 0
|
|
1542
1567
|
};
|
|
1543
|
-
const { count: m } = await
|
|
1568
|
+
const { count: m } = await d.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1544
1569
|
return {
|
|
1545
1570
|
client_grants: l,
|
|
1546
1571
|
start: n * o,
|
|
1547
1572
|
limit: o,
|
|
1548
|
-
length:
|
|
1573
|
+
length: O(m)
|
|
1549
1574
|
};
|
|
1550
1575
|
};
|
|
1551
1576
|
}
|
|
@@ -1554,13 +1579,13 @@ function ta(e) {
|
|
|
1554
1579
|
}
|
|
1555
1580
|
function aa(e) {
|
|
1556
1581
|
return async (t, a, n) => {
|
|
1557
|
-
const o = (/* @__PURE__ */ new Date()).toISOString(), { scope: r, authorization_details_types: s, ...i } = n,
|
|
1582
|
+
const o = (/* @__PURE__ */ new Date()).toISOString(), { scope: r, authorization_details_types: s, ...i } = n, d = {
|
|
1558
1583
|
...i,
|
|
1559
1584
|
updated_at: o
|
|
1560
1585
|
};
|
|
1561
|
-
return r !== void 0 && (
|
|
1586
|
+
return r !== void 0 && (d.scope = JSON.stringify(r)), s !== void 0 && (d.authorization_details_types = JSON.stringify(
|
|
1562
1587
|
s
|
|
1563
|
-
)), i.allow_any_organization !== void 0 && (
|
|
1588
|
+
)), i.allow_any_organization !== void 0 && (d.allow_any_organization = i.allow_any_organization ? 1 : 0), i.is_system !== void 0 && (d.is_system = i.is_system ? 1 : 0), ((await e.updateTable("client_grants").set(d).where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", a).executeTakeFirst()).numUpdatedRows ?? 0n) > 0n;
|
|
1564
1589
|
};
|
|
1565
1590
|
}
|
|
1566
1591
|
function na(e) {
|
|
@@ -1587,28 +1612,28 @@ function oa(e) {
|
|
|
1587
1612
|
_("revoked_at", "is", null)
|
|
1588
1613
|
])
|
|
1589
1614
|
);
|
|
1590
|
-
s && (i =
|
|
1615
|
+
s && (i = b(e, i, s, [
|
|
1591
1616
|
"kid",
|
|
1592
1617
|
"connection",
|
|
1593
1618
|
"fingerprint",
|
|
1594
1619
|
"thumbprint",
|
|
1595
1620
|
"type"
|
|
1596
1621
|
]));
|
|
1597
|
-
let
|
|
1598
|
-
const
|
|
1599
|
-
i = i.limit(n).offset(
|
|
1600
|
-
const
|
|
1622
|
+
let d = i.select((_) => _.fn.count("kid").as("count"));
|
|
1623
|
+
const u = a * n;
|
|
1624
|
+
i = i.limit(n).offset(u), r && (i = i.orderBy(r.sort_by, r.sort_order));
|
|
1625
|
+
const c = await i.selectAll().execute();
|
|
1601
1626
|
if (!o)
|
|
1602
1627
|
return {
|
|
1603
|
-
signingKeys:
|
|
1628
|
+
signingKeys: c,
|
|
1604
1629
|
start: 0,
|
|
1605
1630
|
limit: 0,
|
|
1606
1631
|
length: 0
|
|
1607
1632
|
};
|
|
1608
|
-
const l = await
|
|
1633
|
+
const l = await d.executeTakeFirst(), m = O((l == null ? void 0 : l.count) ?? 0);
|
|
1609
1634
|
return {
|
|
1610
|
-
signingKeys:
|
|
1611
|
-
start:
|
|
1635
|
+
signingKeys: c,
|
|
1636
|
+
start: u,
|
|
1612
1637
|
limit: n,
|
|
1613
1638
|
length: m
|
|
1614
1639
|
};
|
|
@@ -1632,7 +1657,7 @@ function ia(e) {
|
|
|
1632
1657
|
function ca(e) {
|
|
1633
1658
|
return async (t, a) => {
|
|
1634
1659
|
const n = {
|
|
1635
|
-
custom_domain_id: a.custom_domain_id ||
|
|
1660
|
+
custom_domain_id: a.custom_domain_id || k(),
|
|
1636
1661
|
status: "pending",
|
|
1637
1662
|
primary: !1,
|
|
1638
1663
|
...a
|
|
@@ -1679,7 +1704,7 @@ function ua(e) {
|
|
|
1679
1704
|
}
|
|
1680
1705
|
function _a(e) {
|
|
1681
1706
|
return async (t, a, n) => {
|
|
1682
|
-
const { verification: o, domain_metadata: r, primary: s, ...i } = n,
|
|
1707
|
+
const { verification: o, domain_metadata: r, primary: s, ...i } = n, d = {
|
|
1683
1708
|
...i,
|
|
1684
1709
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1685
1710
|
...s !== void 0 && { primary: s ? 1 : 0 },
|
|
@@ -1690,7 +1715,7 @@ function _a(e) {
|
|
|
1690
1715
|
verification: JSON.stringify(o)
|
|
1691
1716
|
}
|
|
1692
1717
|
};
|
|
1693
|
-
return (await e.updateTable("custom_domains").set(
|
|
1718
|
+
return (await e.updateTable("custom_domains").set(d).where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
|
|
1694
1719
|
};
|
|
1695
1720
|
}
|
|
1696
1721
|
function ma(e) {
|
|
@@ -1727,36 +1752,36 @@ function pa(e) {
|
|
|
1727
1752
|
colors_page_background_type: r,
|
|
1728
1753
|
colors_page_background_start: s,
|
|
1729
1754
|
colors_page_background_end: i,
|
|
1730
|
-
colors_page_background_angle_dev:
|
|
1731
|
-
font_url:
|
|
1732
|
-
...
|
|
1755
|
+
colors_page_background_angle_dev: d,
|
|
1756
|
+
font_url: u,
|
|
1757
|
+
...c
|
|
1733
1758
|
} = a;
|
|
1734
1759
|
return w({
|
|
1735
|
-
...
|
|
1760
|
+
...c,
|
|
1736
1761
|
colors: {
|
|
1737
1762
|
primary: o,
|
|
1738
1763
|
page_background: {
|
|
1739
1764
|
type: r,
|
|
1740
1765
|
start: s,
|
|
1741
1766
|
end: i,
|
|
1742
|
-
angle_deg:
|
|
1767
|
+
angle_deg: d
|
|
1743
1768
|
}
|
|
1744
1769
|
},
|
|
1745
|
-
font:
|
|
1770
|
+
font: u ? { url: u } : void 0
|
|
1746
1771
|
});
|
|
1747
1772
|
};
|
|
1748
1773
|
}
|
|
1749
1774
|
function fa(e) {
|
|
1750
1775
|
return async (t, a) => {
|
|
1751
|
-
var s, i,
|
|
1776
|
+
var s, i, d, u, c, l, m, _, p, f, g, y, S, C, $, I, E, z;
|
|
1752
1777
|
const { colors: n, font: o, ...r } = a;
|
|
1753
1778
|
try {
|
|
1754
1779
|
await e.insertInto("branding").values({
|
|
1755
1780
|
...r,
|
|
1756
1781
|
colors_primary: n == null ? void 0 : n.primary,
|
|
1757
1782
|
colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
|
|
1758
|
-
colors_page_background_start: (
|
|
1759
|
-
colors_page_background_end: (l = (
|
|
1783
|
+
colors_page_background_start: (u = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : u.start,
|
|
1784
|
+
colors_page_background_end: (l = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : l.end,
|
|
1760
1785
|
colors_page_background_angle_dev: (_ = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : _.angle_deg,
|
|
1761
1786
|
font_url: (p = a.font) == null ? void 0 : p.url,
|
|
1762
1787
|
tenant_id: t
|
|
@@ -1822,8 +1847,8 @@ function xa(e) {
|
|
|
1822
1847
|
return async (t, a = {}) => {
|
|
1823
1848
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
|
|
1824
1849
|
let i = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
|
|
1825
|
-
s && (i =
|
|
1826
|
-
const
|
|
1850
|
+
s && (i = b(e, i, s, ["url", "form_id", "template_id"]));
|
|
1851
|
+
const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
|
|
1827
1852
|
const {
|
|
1828
1853
|
tenant_id: _,
|
|
1829
1854
|
enabled: p,
|
|
@@ -1844,17 +1869,17 @@ function xa(e) {
|
|
|
1844
1869
|
});
|
|
1845
1870
|
if (!r)
|
|
1846
1871
|
return {
|
|
1847
|
-
hooks:
|
|
1872
|
+
hooks: c,
|
|
1848
1873
|
start: 0,
|
|
1849
1874
|
limit: 0,
|
|
1850
1875
|
length: 0
|
|
1851
1876
|
};
|
|
1852
1877
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1853
1878
|
return {
|
|
1854
|
-
hooks:
|
|
1879
|
+
hooks: c,
|
|
1855
1880
|
start: n * o,
|
|
1856
1881
|
limit: o,
|
|
1857
|
-
length:
|
|
1882
|
+
length: O(l)
|
|
1858
1883
|
};
|
|
1859
1884
|
};
|
|
1860
1885
|
}
|
|
@@ -1868,13 +1893,13 @@ function Ta(e) {
|
|
|
1868
1893
|
created_at_ts: r,
|
|
1869
1894
|
updated_at_ts: s,
|
|
1870
1895
|
...i
|
|
1871
|
-
} = n,
|
|
1896
|
+
} = n, d = D({ created_at_ts: r, updated_at_ts: s }, [
|
|
1872
1897
|
"created_at_ts",
|
|
1873
1898
|
"updated_at_ts"
|
|
1874
1899
|
]);
|
|
1875
1900
|
return w({
|
|
1876
1901
|
...i,
|
|
1877
|
-
...
|
|
1902
|
+
...d,
|
|
1878
1903
|
enabled: !!i.enabled,
|
|
1879
1904
|
synchronous: !!i.synchronous
|
|
1880
1905
|
});
|
|
@@ -1885,9 +1910,9 @@ function Na(e) {
|
|
|
1885
1910
|
}
|
|
1886
1911
|
function Sa(e) {
|
|
1887
1912
|
return async (t, a) => {
|
|
1888
|
-
const n = Date.now(), o = a.hook_id || $t(), { hook_id: r, enabled: s, synchronous: i, ...
|
|
1913
|
+
const n = Date.now(), o = a.hook_id || $t(), { hook_id: r, enabled: s, synchronous: i, ...d } = a;
|
|
1889
1914
|
return await e.insertInto("hooks").values({
|
|
1890
|
-
...
|
|
1915
|
+
...d,
|
|
1891
1916
|
hook_id: o,
|
|
1892
1917
|
tenant_id: t,
|
|
1893
1918
|
enabled: s ? 1 : 0,
|
|
@@ -1895,7 +1920,7 @@ function Sa(e) {
|
|
|
1895
1920
|
created_at_ts: n,
|
|
1896
1921
|
updated_at_ts: n
|
|
1897
1922
|
}).execute(), {
|
|
1898
|
-
...
|
|
1923
|
+
...d,
|
|
1899
1924
|
hook_id: o,
|
|
1900
1925
|
enabled: s ?? !1,
|
|
1901
1926
|
synchronous: i ?? !1,
|
|
@@ -1927,7 +1952,7 @@ function Oa(e) {
|
|
|
1927
1952
|
function ka(e) {
|
|
1928
1953
|
return async (t, a, n) => {
|
|
1929
1954
|
const o = {
|
|
1930
|
-
themeId: n ||
|
|
1955
|
+
themeId: n || k(),
|
|
1931
1956
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1932
1957
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1933
1958
|
...a
|
|
@@ -1988,7 +2013,7 @@ function Pa(e) {
|
|
|
1988
2013
|
return async (t, a) => {
|
|
1989
2014
|
const n = await e.selectFrom("login_sessions").where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
|
|
1990
2015
|
if (!n) return null;
|
|
1991
|
-
const { created_at_ts: o, updated_at_ts: r, expires_at_ts: s, ...i } = n,
|
|
2016
|
+
const { created_at_ts: o, updated_at_ts: r, expires_at_ts: s, ...i } = n, d = D(
|
|
1992
2017
|
{ created_at_ts: o, updated_at_ts: r, expires_at_ts: s },
|
|
1993
2018
|
["created_at_ts", "updated_at_ts", "expires_at_ts"]
|
|
1994
2019
|
);
|
|
@@ -1996,7 +2021,7 @@ function Pa(e) {
|
|
|
1996
2021
|
le(
|
|
1997
2022
|
w({
|
|
1998
2023
|
...i,
|
|
1999
|
-
...
|
|
2024
|
+
...d,
|
|
2000
2025
|
state: n.state || ie.PENDING,
|
|
2001
2026
|
state_data: n.state_data,
|
|
2002
2027
|
failure_reason: n.failure_reason
|
|
@@ -2049,9 +2074,9 @@ function Fa(e) {
|
|
|
2049
2074
|
}
|
|
2050
2075
|
function Ra(e) {
|
|
2051
2076
|
return async (t, a, n) => {
|
|
2052
|
-
const { created_at: o, updated_at: r, expires_at: s, ...i } = n,
|
|
2053
|
-
return delete
|
|
2054
|
-
...
|
|
2077
|
+
const { created_at: o, updated_at: r, expires_at: s, ...i } = n, d = R(i);
|
|
2078
|
+
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2079
|
+
...d,
|
|
2055
2080
|
updated_at_ts: Date.now(),
|
|
2056
2081
|
// Only update expires_at_ts if a new expires_at was provided
|
|
2057
2082
|
// Use !== undefined to preserve null values (which mean "doesn't expire")
|
|
@@ -2109,7 +2134,7 @@ function qa(e) {
|
|
|
2109
2134
|
set: Ka(e)
|
|
2110
2135
|
};
|
|
2111
2136
|
}
|
|
2112
|
-
function
|
|
2137
|
+
function Ba(e) {
|
|
2113
2138
|
return async (t) => {
|
|
2114
2139
|
const [a] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2115
2140
|
if (!a)
|
|
@@ -2129,7 +2154,7 @@ function Ua(e) {
|
|
|
2129
2154
|
});
|
|
2130
2155
|
};
|
|
2131
2156
|
}
|
|
2132
|
-
function
|
|
2157
|
+
function Ua(e) {
|
|
2133
2158
|
return async (t, a) => {
|
|
2134
2159
|
const { credentials: n, settings: o, enabled: r, ...s } = a;
|
|
2135
2160
|
await e.updateTable("email_providers").set({
|
|
@@ -2161,9 +2186,9 @@ function Ha(e) {
|
|
|
2161
2186
|
}
|
|
2162
2187
|
function Ya(e) {
|
|
2163
2188
|
return {
|
|
2164
|
-
get:
|
|
2189
|
+
get: Ba(e),
|
|
2165
2190
|
create: Qa(e),
|
|
2166
|
-
update:
|
|
2191
|
+
update: Ua(e),
|
|
2167
2192
|
remove: Ha(e)
|
|
2168
2193
|
};
|
|
2169
2194
|
}
|
|
@@ -2177,21 +2202,21 @@ function Wa(e) {
|
|
|
2177
2202
|
created_at_ts: r,
|
|
2178
2203
|
expires_at_ts: s,
|
|
2179
2204
|
idle_expires_at_ts: i,
|
|
2180
|
-
last_exchanged_at_ts:
|
|
2181
|
-
...
|
|
2182
|
-
} = n,
|
|
2205
|
+
last_exchanged_at_ts: d,
|
|
2206
|
+
...u
|
|
2207
|
+
} = n, c = D(
|
|
2183
2208
|
{
|
|
2184
2209
|
created_at_ts: r,
|
|
2185
2210
|
expires_at_ts: s,
|
|
2186
2211
|
idle_expires_at_ts: i,
|
|
2187
|
-
last_exchanged_at_ts:
|
|
2212
|
+
last_exchanged_at_ts: d
|
|
2188
2213
|
},
|
|
2189
2214
|
["created_at_ts"],
|
|
2190
2215
|
["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
|
|
2191
2216
|
);
|
|
2192
2217
|
return {
|
|
2193
|
-
...d,
|
|
2194
2218
|
...u,
|
|
2219
|
+
...c,
|
|
2195
2220
|
rotating: !!n.rotating,
|
|
2196
2221
|
device: n.device ? JSON.parse(n.device) : {},
|
|
2197
2222
|
resource_servers: n.resource_servers ? JSON.parse(n.resource_servers) : []
|
|
@@ -2207,17 +2232,17 @@ function Ga(e) {
|
|
|
2207
2232
|
expires_at: r,
|
|
2208
2233
|
idle_expires_at: s,
|
|
2209
2234
|
last_exchanged_at: i,
|
|
2210
|
-
device:
|
|
2211
|
-
resource_servers:
|
|
2212
|
-
rotating:
|
|
2235
|
+
device: d,
|
|
2236
|
+
resource_servers: u,
|
|
2237
|
+
rotating: c,
|
|
2213
2238
|
...l
|
|
2214
2239
|
} = a, m = Date.now();
|
|
2215
2240
|
return await e.insertInto("refresh_tokens").values({
|
|
2216
2241
|
...l,
|
|
2217
2242
|
tenant_id: t,
|
|
2218
|
-
rotating:
|
|
2219
|
-
device: JSON.stringify(
|
|
2220
|
-
resource_servers: JSON.stringify(
|
|
2243
|
+
rotating: c ? 1 : 0,
|
|
2244
|
+
device: JSON.stringify(d),
|
|
2245
|
+
resource_servers: JSON.stringify(u),
|
|
2221
2246
|
created_at_ts: m,
|
|
2222
2247
|
expires_at_ts: v(r),
|
|
2223
2248
|
idle_expires_at_ts: s ? v(s) : null,
|
|
@@ -2235,15 +2260,15 @@ function Xa(e) {
|
|
|
2235
2260
|
expires_at: r,
|
|
2236
2261
|
idle_expires_at: s,
|
|
2237
2262
|
last_exchanged_at: i,
|
|
2238
|
-
device:
|
|
2239
|
-
resource_servers:
|
|
2240
|
-
rotating:
|
|
2263
|
+
device: d,
|
|
2264
|
+
resource_servers: u,
|
|
2265
|
+
rotating: c,
|
|
2241
2266
|
...l
|
|
2242
2267
|
} = n, m = {
|
|
2243
2268
|
...l,
|
|
2244
|
-
device:
|
|
2245
|
-
resource_servers:
|
|
2246
|
-
rotating:
|
|
2269
|
+
device: d ? JSON.stringify(d) : void 0,
|
|
2270
|
+
resource_servers: u ? JSON.stringify(u) : void 0,
|
|
2271
|
+
rotating: c !== void 0 ? c ? 1 : 0 : void 0,
|
|
2247
2272
|
// Convert date fields to bigint format
|
|
2248
2273
|
// Use !== undefined to preserve null values (which mean "doesn't expire")
|
|
2249
2274
|
expires_at_ts: r !== void 0 ? v(r) : void 0,
|
|
@@ -2256,15 +2281,15 @@ function Xa(e) {
|
|
|
2256
2281
|
function Za(e) {
|
|
2257
2282
|
return async (t, a = {}) => {
|
|
2258
2283
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
|
|
2259
|
-
let
|
|
2260
|
-
i && (
|
|
2261
|
-
let
|
|
2284
|
+
let d = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
2285
|
+
i && (d = b(e, d, i, ["token", "login_id"]));
|
|
2286
|
+
let u = d;
|
|
2262
2287
|
if (s && s.sort_by) {
|
|
2263
2288
|
const { ref: p } = e.dynamic;
|
|
2264
|
-
|
|
2289
|
+
u = u.orderBy(p(s.sort_by), s.sort_order);
|
|
2265
2290
|
}
|
|
2266
|
-
|
|
2267
|
-
const l = (await
|
|
2291
|
+
u = u.offset(n * o).limit(o);
|
|
2292
|
+
const l = (await u.selectAll().execute()).map((p) => {
|
|
2268
2293
|
const {
|
|
2269
2294
|
tenant_id: f,
|
|
2270
2295
|
created_at_ts: g,
|
|
@@ -2297,7 +2322,7 @@ function Za(e) {
|
|
|
2297
2322
|
limit: 0,
|
|
2298
2323
|
length: 0
|
|
2299
2324
|
};
|
|
2300
|
-
const { count: m } = await
|
|
2325
|
+
const { count: m } = await d.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = O(m);
|
|
2301
2326
|
return {
|
|
2302
2327
|
refresh_tokens: l,
|
|
2303
2328
|
start: n * o,
|
|
@@ -2318,10 +2343,10 @@ function en(e) {
|
|
|
2318
2343
|
const tn = 7 * 24 * 60 * 60 * 1e3;
|
|
2319
2344
|
function an(e) {
|
|
2320
2345
|
return async (t) => {
|
|
2321
|
-
var i,
|
|
2346
|
+
var i, d, u;
|
|
2322
2347
|
const { tenant_id: a, user_id: n } = t || {}, r = Date.now() - tn, s = 1e3;
|
|
2323
2348
|
try {
|
|
2324
|
-
let
|
|
2349
|
+
let c = 0;
|
|
2325
2350
|
for (; ; ) {
|
|
2326
2351
|
let _ = e.deleteFrom("refresh_tokens").where(
|
|
2327
2352
|
(g) => g.or([
|
|
@@ -2339,7 +2364,7 @@ function an(e) {
|
|
|
2339
2364
|
n
|
|
2340
2365
|
));
|
|
2341
2366
|
const p = await _.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
|
|
2342
|
-
if (
|
|
2367
|
+
if (c += f, f < s) break;
|
|
2343
2368
|
}
|
|
2344
2369
|
let l = 0;
|
|
2345
2370
|
for (; ; ) {
|
|
@@ -2350,7 +2375,7 @@ function an(e) {
|
|
|
2350
2375
|
])
|
|
2351
2376
|
);
|
|
2352
2377
|
a && (_ = _.where("tenant_id", "=", a)), n && (_ = _.where("user_id", "=", n));
|
|
2353
|
-
const p = await _.limit(s).execute(), f = Number(((
|
|
2378
|
+
const p = await _.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
|
|
2354
2379
|
if (l += f, f < s) break;
|
|
2355
2380
|
}
|
|
2356
2381
|
let m = 0;
|
|
@@ -2365,21 +2390,21 @@ function an(e) {
|
|
|
2365
2390
|
"=",
|
|
2366
2391
|
n
|
|
2367
2392
|
));
|
|
2368
|
-
const p = await _.limit(s).execute(), f = Number(((
|
|
2393
|
+
const p = await _.limit(s).execute(), f = Number(((u = p[0]) == null ? void 0 : u.numDeletedRows) ?? 0);
|
|
2369
2394
|
if (m += f, f < s) break;
|
|
2370
2395
|
}
|
|
2371
|
-
(
|
|
2372
|
-
`Session cleanup: deleted ${
|
|
2396
|
+
(c > 0 || l > 0 || m > 0) && console.log(
|
|
2397
|
+
`Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${m} login_sessions`
|
|
2373
2398
|
);
|
|
2374
|
-
} catch (
|
|
2375
|
-
console.error("Error during session cleanup:",
|
|
2399
|
+
} catch (c) {
|
|
2400
|
+
console.error("Error during session cleanup:", c);
|
|
2376
2401
|
}
|
|
2377
2402
|
};
|
|
2378
2403
|
}
|
|
2379
2404
|
function nn(e) {
|
|
2380
2405
|
return async (t, a) => {
|
|
2381
2406
|
const n = q.parse({
|
|
2382
|
-
id:
|
|
2407
|
+
id: k(),
|
|
2383
2408
|
...a,
|
|
2384
2409
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2385
2410
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2398,8 +2423,8 @@ function on(e) {
|
|
|
2398
2423
|
return async (t, a = {}) => {
|
|
2399
2424
|
const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
|
|
2400
2425
|
let i = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
2401
|
-
s && (i =
|
|
2402
|
-
const
|
|
2426
|
+
s && (i = b(e, i, s, []));
|
|
2427
|
+
const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
|
|
2403
2428
|
const _ = { ...m };
|
|
2404
2429
|
if (typeof _.nodes == "string")
|
|
2405
2430
|
try {
|
|
@@ -2420,17 +2445,17 @@ function on(e) {
|
|
|
2420
2445
|
});
|
|
2421
2446
|
if (!r)
|
|
2422
2447
|
return {
|
|
2423
|
-
forms:
|
|
2448
|
+
forms: c,
|
|
2424
2449
|
start: 0,
|
|
2425
2450
|
limit: 0,
|
|
2426
2451
|
length: 0
|
|
2427
2452
|
};
|
|
2428
2453
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2429
2454
|
return {
|
|
2430
|
-
forms:
|
|
2455
|
+
forms: c,
|
|
2431
2456
|
start: n * o,
|
|
2432
2457
|
limit: o,
|
|
2433
|
-
length:
|
|
2458
|
+
length: O(l)
|
|
2434
2459
|
};
|
|
2435
2460
|
};
|
|
2436
2461
|
}
|
|
@@ -2493,9 +2518,9 @@ function dn(e) {
|
|
|
2493
2518
|
}, r = De.parse(o), {
|
|
2494
2519
|
verificationKey: s,
|
|
2495
2520
|
scopes: i,
|
|
2496
|
-
options:
|
|
2497
|
-
skip_consent_for_verifiable_first_party_clients:
|
|
2498
|
-
allow_offline_access:
|
|
2521
|
+
options: d,
|
|
2522
|
+
skip_consent_for_verifiable_first_party_clients: u,
|
|
2523
|
+
allow_offline_access: c,
|
|
2499
2524
|
is_system: l,
|
|
2500
2525
|
metadata: m,
|
|
2501
2526
|
..._
|
|
@@ -2503,9 +2528,9 @@ function dn(e) {
|
|
|
2503
2528
|
..._,
|
|
2504
2529
|
tenant_id: t,
|
|
2505
2530
|
scopes: i ? JSON.stringify(i) : "[]",
|
|
2506
|
-
options:
|
|
2507
|
-
skip_consent_for_verifiable_first_party_clients:
|
|
2508
|
-
allow_offline_access:
|
|
2531
|
+
options: d ? JSON.stringify(d) : "{}",
|
|
2532
|
+
skip_consent_for_verifiable_first_party_clients: u ? 1 : 0,
|
|
2533
|
+
allow_offline_access: c ? 1 : 0,
|
|
2509
2534
|
is_system: l ? 1 : 0,
|
|
2510
2535
|
metadata: m ? JSON.stringify(m) : void 0,
|
|
2511
2536
|
verification_key: s,
|
|
@@ -2523,18 +2548,18 @@ function un(e) {
|
|
|
2523
2548
|
verification_key: r,
|
|
2524
2549
|
scopes: s,
|
|
2525
2550
|
options: i,
|
|
2526
|
-
skip_consent_for_verifiable_first_party_clients:
|
|
2527
|
-
allow_offline_access:
|
|
2528
|
-
is_system:
|
|
2551
|
+
skip_consent_for_verifiable_first_party_clients: d,
|
|
2552
|
+
allow_offline_access: u,
|
|
2553
|
+
is_system: c,
|
|
2529
2554
|
metadata: l,
|
|
2530
2555
|
...m
|
|
2531
2556
|
} = o, _ = {
|
|
2532
2557
|
...m,
|
|
2533
2558
|
scopes: s ? JSON.parse(s) : [],
|
|
2534
2559
|
options: i ? JSON.parse(i) : {},
|
|
2535
|
-
skip_consent_for_verifiable_first_party_clients: !!
|
|
2536
|
-
allow_offline_access: !!
|
|
2537
|
-
is_system:
|
|
2560
|
+
skip_consent_for_verifiable_first_party_clients: !!d,
|
|
2561
|
+
allow_offline_access: !!u,
|
|
2562
|
+
is_system: c ? !0 : void 0,
|
|
2538
2563
|
metadata: l ? JSON.parse(l) : void 0,
|
|
2539
2564
|
// Convert verification_key back to verificationKey for API
|
|
2540
2565
|
verificationKey: r
|
|
@@ -2552,12 +2577,12 @@ function _n(e) {
|
|
|
2552
2577
|
const S = !!f[1], C = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
2553
2578
|
i = S ? i.where(C, "not like", `%${g}%`) : i.where(C, "like", `%${g}%`);
|
|
2554
2579
|
} else
|
|
2555
|
-
i =
|
|
2580
|
+
i = b(e, i, m, [
|
|
2556
2581
|
"resource_servers.name",
|
|
2557
2582
|
"resource_servers.identifier"
|
|
2558
2583
|
]);
|
|
2559
2584
|
}
|
|
2560
|
-
const
|
|
2585
|
+
const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
|
|
2561
2586
|
const _ = m, {
|
|
2562
2587
|
verification_key: p,
|
|
2563
2588
|
scopes: f,
|
|
@@ -2582,17 +2607,17 @@ function _n(e) {
|
|
|
2582
2607
|
});
|
|
2583
2608
|
if (!r)
|
|
2584
2609
|
return {
|
|
2585
|
-
resource_servers:
|
|
2610
|
+
resource_servers: c,
|
|
2586
2611
|
start: 0,
|
|
2587
2612
|
limit: 0,
|
|
2588
2613
|
length: 0
|
|
2589
2614
|
};
|
|
2590
2615
|
const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2591
2616
|
return {
|
|
2592
|
-
resource_servers:
|
|
2617
|
+
resource_servers: c,
|
|
2593
2618
|
start: n * o,
|
|
2594
2619
|
limit: o,
|
|
2595
|
-
length:
|
|
2620
|
+
length: O(l)
|
|
2596
2621
|
};
|
|
2597
2622
|
};
|
|
2598
2623
|
}
|
|
@@ -2609,9 +2634,9 @@ function hn(e) {
|
|
|
2609
2634
|
scopes: r,
|
|
2610
2635
|
options: s,
|
|
2611
2636
|
skip_consent_for_verifiable_first_party_clients: i,
|
|
2612
|
-
allow_offline_access:
|
|
2613
|
-
is_system:
|
|
2614
|
-
metadata:
|
|
2637
|
+
allow_offline_access: d,
|
|
2638
|
+
is_system: u,
|
|
2639
|
+
metadata: c,
|
|
2615
2640
|
...l
|
|
2616
2641
|
} = n, m = {
|
|
2617
2642
|
...l,
|
|
@@ -2621,7 +2646,7 @@ function hn(e) {
|
|
|
2621
2646
|
const p = await e.selectFrom("resource_servers").select("options").where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst(), g = { ...p != null && p.options ? JSON.parse(p.options) : {}, ...s };
|
|
2622
2647
|
m.options = JSON.stringify(g);
|
|
2623
2648
|
}
|
|
2624
|
-
|
|
2649
|
+
c !== void 0 && (m.metadata = JSON.stringify(c)), i !== void 0 && (m.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), d !== void 0 && (m.allow_offline_access = d ? 1 : 0), u !== void 0 && (m.is_system = u ? 1 : 0);
|
|
2625
2650
|
const _ = await e.updateTable("resource_servers").set(m).where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
|
|
2626
2651
|
return Number(_.numUpdatedRows) > 0;
|
|
2627
2652
|
};
|
|
@@ -2637,18 +2662,18 @@ function pn(e) {
|
|
|
2637
2662
|
}
|
|
2638
2663
|
function fn(e) {
|
|
2639
2664
|
return async (t, a) => {
|
|
2640
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id ||
|
|
2665
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || k(), { is_system: r, id: s, metadata: i, ...d } = a, u = {
|
|
2641
2666
|
id: o,
|
|
2642
|
-
...
|
|
2667
|
+
...d,
|
|
2643
2668
|
tenant_id: t,
|
|
2644
2669
|
is_system: r ? 1 : 0,
|
|
2645
2670
|
metadata: i ? JSON.stringify(i) : void 0,
|
|
2646
2671
|
created_at: n,
|
|
2647
2672
|
updated_at: n
|
|
2648
2673
|
};
|
|
2649
|
-
return await e.insertInto("roles").values(
|
|
2674
|
+
return await e.insertInto("roles").values(u).execute(), {
|
|
2650
2675
|
id: o,
|
|
2651
|
-
...
|
|
2676
|
+
...d,
|
|
2652
2677
|
is_system: r ? !0 : void 0,
|
|
2653
2678
|
metadata: i,
|
|
2654
2679
|
created_at: n,
|
|
@@ -2660,9 +2685,9 @@ function gn(e) {
|
|
|
2660
2685
|
return async (t, a) => {
|
|
2661
2686
|
const n = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", a).executeTakeFirst();
|
|
2662
2687
|
if (!n) return null;
|
|
2663
|
-
const o = n, { is_system: r, tenant_id: s, metadata: i, ...
|
|
2688
|
+
const o = n, { is_system: r, tenant_id: s, metadata: i, ...d } = o;
|
|
2664
2689
|
return {
|
|
2665
|
-
...
|
|
2690
|
+
...d,
|
|
2666
2691
|
is_system: r ? !0 : void 0,
|
|
2667
2692
|
metadata: i ? JSON.parse(i) : void 0
|
|
2668
2693
|
};
|
|
@@ -2672,8 +2697,8 @@ function wn(e) {
|
|
|
2672
2697
|
return async (t, a) => {
|
|
2673
2698
|
let n = e.selectFrom("roles").where("roles.tenant_id", "=", t);
|
|
2674
2699
|
const { page: o = 0, per_page: r = 50, include_totals: s = !1 } = a;
|
|
2675
|
-
a.q && (n =
|
|
2676
|
-
const
|
|
2700
|
+
a.q && (n = b(e, n, a.q, ["name"]));
|
|
2701
|
+
const u = (await n.offset(o * r).limit(r).selectAll().execute()).map((l) => {
|
|
2677
2702
|
const m = l, { is_system: _, tenant_id: p, metadata: f, ...g } = m;
|
|
2678
2703
|
return {
|
|
2679
2704
|
...g,
|
|
@@ -2683,17 +2708,17 @@ function wn(e) {
|
|
|
2683
2708
|
});
|
|
2684
2709
|
if (!s)
|
|
2685
2710
|
return {
|
|
2686
|
-
roles:
|
|
2711
|
+
roles: u,
|
|
2687
2712
|
start: o * r,
|
|
2688
2713
|
limit: r,
|
|
2689
|
-
length:
|
|
2714
|
+
length: u.length
|
|
2690
2715
|
};
|
|
2691
|
-
const { count:
|
|
2716
|
+
const { count: c } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2692
2717
|
return {
|
|
2693
|
-
roles:
|
|
2718
|
+
roles: u,
|
|
2694
2719
|
start: o * r,
|
|
2695
2720
|
limit: r,
|
|
2696
|
-
length:
|
|
2721
|
+
length: O(c)
|
|
2697
2722
|
};
|
|
2698
2723
|
};
|
|
2699
2724
|
}
|
|
@@ -2704,8 +2729,8 @@ function yn(e) {
|
|
|
2704
2729
|
is_system: o !== void 0 ? o ? 1 : 0 : void 0,
|
|
2705
2730
|
metadata: r !== void 0 ? JSON.stringify(r) : void 0,
|
|
2706
2731
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2707
|
-
},
|
|
2708
|
-
return Number(
|
|
2732
|
+
}, d = await e.updateTable("roles").set(i).where("roles.tenant_id", "=", t).where("roles.id", "=", a).executeTakeFirst();
|
|
2733
|
+
return Number(d.numUpdatedRows) > 0;
|
|
2709
2734
|
};
|
|
2710
2735
|
}
|
|
2711
2736
|
function vn(e) {
|
|
@@ -2793,7 +2818,7 @@ function Nn(e) {
|
|
|
2793
2818
|
"role_permissions.created_at",
|
|
2794
2819
|
"resource_servers.name as resource_server_name"
|
|
2795
2820
|
]).where("role_permissions.tenant_id", "=", t).where("role_permissions.role_id", "=", a);
|
|
2796
|
-
const
|
|
2821
|
+
const c = (await i.offset(o * r).limit(r).execute()).map((l) => ({
|
|
2797
2822
|
role_id: l.role_id,
|
|
2798
2823
|
resource_server_identifier: l.resource_server_identifier,
|
|
2799
2824
|
resource_server_name: l.resource_server_name || l.resource_server_identifier,
|
|
@@ -2803,7 +2828,7 @@ function Nn(e) {
|
|
|
2803
2828
|
// No description available from role_permissions directly
|
|
2804
2829
|
created_at: l.created_at
|
|
2805
2830
|
}));
|
|
2806
|
-
return s && await i.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(),
|
|
2831
|
+
return s && await i.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c;
|
|
2807
2832
|
};
|
|
2808
2833
|
}
|
|
2809
2834
|
function Sn(e) {
|
|
@@ -3000,20 +3025,20 @@ function Rn(e) {
|
|
|
3000
3025
|
return async (t, a) => {
|
|
3001
3026
|
let n = e.selectFrom("organizations").selectAll().where("tenant_id", "=", t);
|
|
3002
3027
|
if (a != null && a.q && (n = n.where(
|
|
3003
|
-
(
|
|
3004
|
-
|
|
3005
|
-
|
|
3028
|
+
(c) => c.or([
|
|
3029
|
+
c("name", "like", `%${a.q}%`),
|
|
3030
|
+
c("display_name", "like", `%${a.q}%`)
|
|
3006
3031
|
])
|
|
3007
3032
|
)), a != null && a.sort) {
|
|
3008
|
-
const
|
|
3009
|
-
["name", "display_name", "created_at"].includes(l) ? n = n.orderBy(l,
|
|
3033
|
+
const c = a.sort.sort_order === "asc" ? "asc" : "desc", l = a.sort.sort_by;
|
|
3034
|
+
["name", "display_name", "created_at"].includes(l) ? n = n.orderBy(l, c) : n = n.orderBy("created_at", "desc");
|
|
3010
3035
|
} else
|
|
3011
3036
|
n = n.orderBy("created_at", "desc");
|
|
3012
3037
|
if ((a == null ? void 0 : a.from) !== void 0) {
|
|
3013
|
-
const
|
|
3014
|
-
isNaN(
|
|
3038
|
+
const c = parseInt(a.from, 10);
|
|
3039
|
+
isNaN(c) || (n = n.offset(c));
|
|
3015
3040
|
} else if ((a == null ? void 0 : a.page) !== void 0) {
|
|
3016
|
-
const
|
|
3041
|
+
const c = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, l = a.page * c;
|
|
3017
3042
|
n = n.offset(l);
|
|
3018
3043
|
}
|
|
3019
3044
|
const o = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10;
|
|
@@ -3021,29 +3046,29 @@ function Rn(e) {
|
|
|
3021
3046
|
const r = await n.execute();
|
|
3022
3047
|
let s = r.length;
|
|
3023
3048
|
if (a != null && a.include_totals) {
|
|
3024
|
-
let
|
|
3025
|
-
a != null && a.q && (
|
|
3049
|
+
let c = e.selectFrom("organizations").select(h`count(*)`.as("count")).where("tenant_id", "=", t);
|
|
3050
|
+
a != null && a.q && (c = c.where(
|
|
3026
3051
|
(m) => m.or([
|
|
3027
3052
|
m("name", "like", `%${a.q}%`),
|
|
3028
3053
|
m("display_name", "like", `%${a.q}%`)
|
|
3029
3054
|
])
|
|
3030
3055
|
));
|
|
3031
|
-
const l = await
|
|
3056
|
+
const l = await c.executeTakeFirst();
|
|
3032
3057
|
s = Number((l == null ? void 0 : l.count) || 0);
|
|
3033
3058
|
}
|
|
3034
3059
|
const i = r.map(
|
|
3035
|
-
(
|
|
3036
|
-
...
|
|
3037
|
-
branding:
|
|
3038
|
-
metadata:
|
|
3039
|
-
enabled_connections:
|
|
3040
|
-
token_quota:
|
|
3060
|
+
(c) => w({
|
|
3061
|
+
...c,
|
|
3062
|
+
branding: c.branding ? JSON.parse(c.branding) : {},
|
|
3063
|
+
metadata: c.metadata ? JSON.parse(c.metadata) : {},
|
|
3064
|
+
enabled_connections: c.enabled_connections ? JSON.parse(c.enabled_connections) : [],
|
|
3065
|
+
token_quota: c.token_quota ? JSON.parse(c.token_quota) : {}
|
|
3041
3066
|
})
|
|
3042
|
-
),
|
|
3067
|
+
), d = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, u = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * d : 0;
|
|
3043
3068
|
return {
|
|
3044
3069
|
organizations: i,
|
|
3045
|
-
start: isNaN(
|
|
3046
|
-
limit:
|
|
3070
|
+
start: isNaN(u) ? 0 : u,
|
|
3071
|
+
limit: d,
|
|
3047
3072
|
length: i.length,
|
|
3048
3073
|
total: s
|
|
3049
3074
|
};
|
|
@@ -3054,15 +3079,15 @@ function Mn(e) {
|
|
|
3054
3079
|
}
|
|
3055
3080
|
function Jn(e) {
|
|
3056
3081
|
return async (t, a, n) => {
|
|
3057
|
-
const { branding: o, metadata: r, enabled_connections: s, token_quota: i, ...
|
|
3058
|
-
...
|
|
3082
|
+
const { branding: o, metadata: r, enabled_connections: s, token_quota: i, ...d } = n, u = {
|
|
3083
|
+
...d,
|
|
3059
3084
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3060
3085
|
};
|
|
3061
3086
|
return J(
|
|
3062
3087
|
n,
|
|
3063
3088
|
["branding", "metadata", "enabled_connections", "token_quota"],
|
|
3064
|
-
|
|
3065
|
-
), (await e.updateTable("organizations").set(
|
|
3089
|
+
u
|
|
3090
|
+
), (await e.updateTable("organizations").set(u).where("tenant_id", "=", t).where("id", "=", a).execute()).length > 0;
|
|
3066
3091
|
};
|
|
3067
3092
|
}
|
|
3068
3093
|
function Ln(e) {
|
|
@@ -3077,7 +3102,7 @@ function Ln(e) {
|
|
|
3077
3102
|
function Kn(e) {
|
|
3078
3103
|
return async (t, a) => {
|
|
3079
3104
|
const n = {
|
|
3080
|
-
id:
|
|
3105
|
+
id: k(),
|
|
3081
3106
|
tenant_id: t,
|
|
3082
3107
|
user_id: a.user_id,
|
|
3083
3108
|
organization_id: a.organization_id,
|
|
@@ -3108,7 +3133,7 @@ function qn(e) {
|
|
|
3108
3133
|
} : null;
|
|
3109
3134
|
};
|
|
3110
3135
|
}
|
|
3111
|
-
function
|
|
3136
|
+
function Bn(e) {
|
|
3112
3137
|
return async (t, a) => {
|
|
3113
3138
|
const n = (a == null ? void 0 : a.page) || 0, o = (a == null ? void 0 : a.per_page) || 50, r = n * o;
|
|
3114
3139
|
let s = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
@@ -3123,17 +3148,17 @@ function Un(e) {
|
|
|
3123
3148
|
}
|
|
3124
3149
|
s = s.orderBy("created_at", "desc"), o > 0 && (s = s.limit(o).offset(r));
|
|
3125
3150
|
const i = await s.execute();
|
|
3126
|
-
let
|
|
3151
|
+
let d = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
|
|
3127
3152
|
if (a != null && a.q) {
|
|
3128
3153
|
if (a.q.startsWith("user_id:")) {
|
|
3129
3154
|
const l = a.q.replace("user_id:", "");
|
|
3130
|
-
|
|
3155
|
+
d = d.where("user_id", "=", l);
|
|
3131
3156
|
} else if (a.q.startsWith("organization_id:")) {
|
|
3132
3157
|
const l = a.q.replace("organization_id:", "");
|
|
3133
|
-
|
|
3158
|
+
d = d.where("organization_id", "=", l);
|
|
3134
3159
|
}
|
|
3135
3160
|
}
|
|
3136
|
-
const
|
|
3161
|
+
const u = await d.executeTakeFirst();
|
|
3137
3162
|
return {
|
|
3138
3163
|
userOrganizations: i.map((l) => ({
|
|
3139
3164
|
id: l.id,
|
|
@@ -3144,11 +3169,11 @@ function Un(e) {
|
|
|
3144
3169
|
})),
|
|
3145
3170
|
start: r,
|
|
3146
3171
|
limit: o,
|
|
3147
|
-
length: Number((
|
|
3172
|
+
length: Number((u == null ? void 0 : u.count) || 0)
|
|
3148
3173
|
};
|
|
3149
3174
|
};
|
|
3150
3175
|
}
|
|
3151
|
-
function
|
|
3176
|
+
function Un(e) {
|
|
3152
3177
|
return async (t, a, n) => {
|
|
3153
3178
|
const o = (n == null ? void 0 : n.page) || 0, r = (n == null ? void 0 : n.per_page) || 50, s = o * r;
|
|
3154
3179
|
let i = e.selectFrom("user_organizations").innerJoin(
|
|
@@ -3167,12 +3192,12 @@ function Bn(e) {
|
|
|
3167
3192
|
"user_organizations.created_at as joined_at"
|
|
3168
3193
|
]).where("user_organizations.tenant_id", "=", t).where("user_organizations.user_id", "=", a);
|
|
3169
3194
|
i = i.orderBy("user_organizations.created_at", "desc"), r > 0 && (i = i.limit(r).offset(s));
|
|
3170
|
-
const
|
|
3195
|
+
const d = await i.execute(), u = await e.selectFrom("user_organizations").innerJoin(
|
|
3171
3196
|
"organizations",
|
|
3172
3197
|
(l) => l.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)
|
|
3173
3198
|
).select(e.fn.count("user_organizations.id").as("count")).where("user_organizations.tenant_id", "=", t).where("user_organizations.user_id", "=", a).executeTakeFirst();
|
|
3174
3199
|
return {
|
|
3175
|
-
organizations:
|
|
3200
|
+
organizations: d.map((l) => ({
|
|
3176
3201
|
id: l.id,
|
|
3177
3202
|
name: l.name,
|
|
3178
3203
|
display_name: l.display_name,
|
|
@@ -3187,7 +3212,7 @@ function Bn(e) {
|
|
|
3187
3212
|
})),
|
|
3188
3213
|
start: s,
|
|
3189
3214
|
limit: r,
|
|
3190
|
-
length: Number((
|
|
3215
|
+
length: Number((u == null ? void 0 : u.count) || 0)
|
|
3191
3216
|
};
|
|
3192
3217
|
};
|
|
3193
3218
|
}
|
|
@@ -3208,8 +3233,8 @@ function Yn(e) {
|
|
|
3208
3233
|
// CRUD operations
|
|
3209
3234
|
create: Kn(e),
|
|
3210
3235
|
get: qn(e),
|
|
3211
|
-
list:
|
|
3212
|
-
listUserOrganizations:
|
|
3236
|
+
list: Bn(e),
|
|
3237
|
+
listUserOrganizations: Un(e),
|
|
3213
3238
|
remove: Qn(e),
|
|
3214
3239
|
update: Hn(e)
|
|
3215
3240
|
};
|
|
@@ -3239,10 +3264,10 @@ function Wn(e) {
|
|
|
3239
3264
|
);
|
|
3240
3265
|
try {
|
|
3241
3266
|
await e.insertInto("invites").values(i).execute();
|
|
3242
|
-
} catch (
|
|
3243
|
-
throw
|
|
3267
|
+
} catch (d) {
|
|
3268
|
+
throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new F(409, {
|
|
3244
3269
|
message: "Invite already exists"
|
|
3245
|
-
}) :
|
|
3270
|
+
}) : d;
|
|
3246
3271
|
}
|
|
3247
3272
|
return {
|
|
3248
3273
|
id: n,
|
|
@@ -3358,9 +3383,9 @@ function ao(e) {
|
|
|
3358
3383
|
async getDaily(t, a = {}) {
|
|
3359
3384
|
const { from: n, to: o } = a, r = /* @__PURE__ */ new Date(), s = new Date(r);
|
|
3360
3385
|
s.setDate(s.getDate() - 30);
|
|
3361
|
-
const i = n ? oe(n) : re(s),
|
|
3362
|
-
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(
|
|
3363
|
-
|
|
3386
|
+
const i = n ? oe(n) : re(s), d = o ? oe(o) : re(r), u = h`DATE(logs.date)`;
|
|
3387
|
+
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(u, ">=", i).where(u, "<=", d).select((l) => [
|
|
3388
|
+
u.as("date"),
|
|
3364
3389
|
l.fn.sum(
|
|
3365
3390
|
l.case().when("type", "in", ne).then(1).else(0).end()
|
|
3366
3391
|
).as("logins"),
|
|
@@ -3370,7 +3395,7 @@ function ao(e) {
|
|
|
3370
3395
|
).as("leaked_passwords"),
|
|
3371
3396
|
l.fn.min("date").as("first_event"),
|
|
3372
3397
|
l.fn.max("date").as("last_event")
|
|
3373
|
-
]).groupBy(
|
|
3398
|
+
]).groupBy(u).orderBy("date", "asc").execute()).map((l) => ({
|
|
3374
3399
|
date: l.date,
|
|
3375
3400
|
logins: Number(l.logins) || 0,
|
|
3376
3401
|
signups: Number(l.signups) || 0,
|
|
@@ -3524,7 +3549,7 @@ function co(e) {
|
|
|
3524
3549
|
}
|
|
3525
3550
|
function lo(e) {
|
|
3526
3551
|
return async (t, a) => {
|
|
3527
|
-
const n =
|
|
3552
|
+
const n = k();
|
|
3528
3553
|
await e.insertInto("outbox_events").values({
|
|
3529
3554
|
id: n,
|
|
3530
3555
|
tenant_id: t,
|
|
@@ -3827,14 +3852,14 @@ const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3827
3852
|
down: Ko,
|
|
3828
3853
|
up: Lo
|
|
3829
3854
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3830
|
-
async function Uo(e) {
|
|
3831
|
-
}
|
|
3832
3855
|
async function Bo(e) {
|
|
3833
3856
|
}
|
|
3857
|
+
async function Uo(e) {
|
|
3858
|
+
}
|
|
3834
3859
|
const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3835
3860
|
__proto__: null,
|
|
3836
|
-
down:
|
|
3837
|
-
up:
|
|
3861
|
+
down: Uo,
|
|
3862
|
+
up: Bo
|
|
3838
3863
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3839
3864
|
async function Ho(e) {
|
|
3840
3865
|
}
|
|
@@ -4025,15 +4050,15 @@ const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4025
4050
|
down: Kr,
|
|
4026
4051
|
up: Lr
|
|
4027
4052
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4028
|
-
async function Ur(e) {
|
|
4029
|
-
}
|
|
4030
4053
|
async function Br(e) {
|
|
4054
|
+
}
|
|
4055
|
+
async function Ur(e) {
|
|
4031
4056
|
await e.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
|
|
4032
4057
|
}
|
|
4033
4058
|
const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4034
4059
|
__proto__: null,
|
|
4035
|
-
down:
|
|
4036
|
-
up:
|
|
4060
|
+
down: Ur,
|
|
4061
|
+
up: Br
|
|
4037
4062
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4038
4063
|
async function Hr(e) {
|
|
4039
4064
|
await e.schema.alterTable("otps").dropColumn("state").execute(), await e.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
|
|
@@ -4244,16 +4269,16 @@ const qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4244
4269
|
down: Ks,
|
|
4245
4270
|
up: Ls
|
|
4246
4271
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4247
|
-
async function
|
|
4272
|
+
async function Bs(e) {
|
|
4248
4273
|
await e.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
|
|
4249
4274
|
}
|
|
4250
|
-
async function
|
|
4275
|
+
async function Us(e) {
|
|
4251
4276
|
await e.schema.alterTable("logins").dropColumn("auth0Client").execute();
|
|
4252
4277
|
}
|
|
4253
4278
|
const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4254
4279
|
__proto__: null,
|
|
4255
|
-
down:
|
|
4256
|
-
up:
|
|
4280
|
+
down: Us,
|
|
4281
|
+
up: Bs
|
|
4257
4282
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4258
4283
|
async function Hs(e) {
|
|
4259
4284
|
await e.schema.alterTable("logins").dropColumn("authParams_state").execute(), await e.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
|
|
@@ -4479,16 +4504,16 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4479
4504
|
down: Ki,
|
|
4480
4505
|
up: Li
|
|
4481
4506
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4482
|
-
async function
|
|
4507
|
+
async function Bi(e) {
|
|
4483
4508
|
await e.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
|
|
4484
4509
|
}
|
|
4485
|
-
async function
|
|
4510
|
+
async function Ui(e) {
|
|
4486
4511
|
await e.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
|
|
4487
4512
|
}
|
|
4488
4513
|
const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4489
4514
|
__proto__: null,
|
|
4490
|
-
down:
|
|
4491
|
-
up:
|
|
4515
|
+
down: Ui,
|
|
4516
|
+
up: Bi
|
|
4492
4517
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4493
4518
|
async function Hi(e) {
|
|
4494
4519
|
await e.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
|
|
@@ -4770,16 +4795,16 @@ const qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4770
4795
|
down: Kc,
|
|
4771
4796
|
up: Lc
|
|
4772
4797
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4773
|
-
async function
|
|
4798
|
+
async function Bc(e) {
|
|
4774
4799
|
await e.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await e.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await e.updateTable("hooks").set((t) => ({ url_tmp: t.ref("url") })).execute(), await e.schema.alterTable("hooks").dropColumn("url").execute(), await e.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
|
|
4775
4800
|
}
|
|
4776
|
-
async function
|
|
4801
|
+
async function Uc(e) {
|
|
4777
4802
|
await e.schema.dropTable("hooks").ifExists().execute(), await e.schema.createTable("hooks").addColumn("hook_id", "text", (t) => t.primaryKey()).addColumn("tenant_id", "text", (t) => t.notNull()).addColumn("trigger_id", "text", (t) => t.notNull()).addColumn("enabled", "integer", (t) => t.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (t) => t.notNull()).addColumn("synchronous", "integer", (t) => t.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (t) => t.notNull()).addColumn("updated_at", "text", (t) => t.notNull()).execute();
|
|
4778
4803
|
}
|
|
4779
4804
|
const Qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4780
4805
|
__proto__: null,
|
|
4781
|
-
down:
|
|
4782
|
-
up:
|
|
4806
|
+
down: Uc,
|
|
4807
|
+
up: Bc
|
|
4783
4808
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4784
4809
|
async function Hc(e) {
|
|
4785
4810
|
await e.schema.alterTable("login_sessions").addColumn(
|
|
@@ -5333,12 +5358,12 @@ async function ql(e) {
|
|
|
5333
5358
|
FROM login_sessions_temp`.execute(t), await h`DROP TABLE login_sessions_temp`.execute(t);
|
|
5334
5359
|
});
|
|
5335
5360
|
}
|
|
5336
|
-
const
|
|
5361
|
+
const Bl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5337
5362
|
__proto__: null,
|
|
5338
5363
|
down: Ll,
|
|
5339
5364
|
up: Rl
|
|
5340
5365
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5341
|
-
async function
|
|
5366
|
+
async function Ul(e) {
|
|
5342
5367
|
await e.schema.createTable("client_grants").addColumn("id", "varchar(21)", (t) => t.notNull()).addColumn(
|
|
5343
5368
|
"tenant_id",
|
|
5344
5369
|
"varchar(191)",
|
|
@@ -5361,7 +5386,7 @@ async function Ql(e) {
|
|
|
5361
5386
|
const Hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5362
5387
|
__proto__: null,
|
|
5363
5388
|
down: Ql,
|
|
5364
|
-
up:
|
|
5389
|
+
up: Ul
|
|
5365
5390
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5366
5391
|
async function Yl(e) {
|
|
5367
5392
|
await e.schema.dropTable("applications").execute();
|
|
@@ -5595,7 +5620,7 @@ async function Nd(e) {
|
|
|
5595
5620
|
}
|
|
5596
5621
|
for (const o of n)
|
|
5597
5622
|
await e.insertInto("password_history").values({
|
|
5598
|
-
id:
|
|
5623
|
+
id: k(),
|
|
5599
5624
|
user_id: o.user_id,
|
|
5600
5625
|
tenant_id: o.tenant_id,
|
|
5601
5626
|
password: o.password,
|
|
@@ -5794,12 +5819,12 @@ async function qd(e) {
|
|
|
5794
5819
|
login_completed: h`CASE WHEN state = 'completed' THEN 1 ELSE 0 END`
|
|
5795
5820
|
}).execute(), await e.schema.dropIndex("login_sessions_state_updated_idx").execute(), await e.schema.dropIndex("login_sessions_state_idx").execute(), await e.schema.dropIndex("login_sessions_tenant_user_idx").execute(), await e.schema.alterTable("login_sessions").dropColumn("state").dropColumn("state_data").dropColumn("failure_reason").dropColumn("user_id").execute();
|
|
5796
5821
|
}
|
|
5797
|
-
const
|
|
5822
|
+
const Bd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5798
5823
|
__proto__: null,
|
|
5799
5824
|
down: qd,
|
|
5800
5825
|
up: Kd
|
|
5801
5826
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5802
|
-
async function
|
|
5827
|
+
async function Ud(e) {
|
|
5803
5828
|
await e.schema.alterTable("roles").addColumn("metadata", "varchar(4096)").execute(), await e.schema.alterTable("resource_servers").addColumn("metadata", "varchar(4096)").execute();
|
|
5804
5829
|
}
|
|
5805
5830
|
async function Qd(e) {
|
|
@@ -5808,7 +5833,7 @@ async function Qd(e) {
|
|
|
5808
5833
|
const Hd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5809
5834
|
__proto__: null,
|
|
5810
5835
|
down: Qd,
|
|
5811
|
-
up:
|
|
5836
|
+
up: Ud
|
|
5812
5837
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5813
5838
|
async function Yd(e) {
|
|
5814
5839
|
try {
|
|
@@ -6102,7 +6127,7 @@ async function se(e, t, a) {
|
|
|
6102
6127
|
}
|
|
6103
6128
|
}
|
|
6104
6129
|
async function $u(e) {
|
|
6105
|
-
var r, s, i,
|
|
6130
|
+
var r, s, i, d, u;
|
|
6106
6131
|
const t = await Ce(e);
|
|
6107
6132
|
console.log(
|
|
6108
6133
|
"Running preflight integrity check on hooks timestamp columns..."
|
|
@@ -6117,11 +6142,11 @@ async function $u(e) {
|
|
|
6117
6142
|
);
|
|
6118
6143
|
if (console.log(" Preflight check passed — all _ts columns are populated."), t === "mysql") {
|
|
6119
6144
|
console.log("Running preflight length check on columns being narrowed...");
|
|
6120
|
-
const { rows:
|
|
6145
|
+
const { rows: c } = await h`SELECT
|
|
6121
6146
|
SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
|
|
6122
6147
|
SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
|
|
6123
6148
|
SUM(CASE WHEN CHAR_LENGTH(template_id) > 64 THEN 1 ELSE 0 END) AS long_template_id
|
|
6124
|
-
FROM hooks`.execute(e), l = Number(((i =
|
|
6149
|
+
FROM hooks`.execute(e), l = Number(((i = c[0]) == null ? void 0 : i.long_hook_id) ?? 0), m = Number(((d = c[0]) == null ? void 0 : d.long_form_id) ?? 0), _ = Number(((u = c[0]) == null ? void 0 : u.long_template_id) ?? 0), p = [];
|
|
6125
6150
|
if (l > 0 && p.push(`${l} row(s) with hook_id longer than 21 chars`), m > 0 && p.push(
|
|
6126
6151
|
`${m} row(s) with form_id longer than 128 chars`
|
|
6127
6152
|
), _ > 0 && p.push(
|
|
@@ -6137,7 +6162,7 @@ async function $u(e) {
|
|
|
6137
6162
|
console.log("Dropping old date columns from hooks..."), await se(e, "hooks", "created_at"), await se(e, "hooks", "updated_at"), t === "mysql" && (console.log("Fixing hook column types..."), await e.schema.alterTable("hooks").modifyColumn(
|
|
6138
6163
|
"hook_id",
|
|
6139
6164
|
"varchar(21)",
|
|
6140
|
-
(
|
|
6165
|
+
(c) => c.notNull().primaryKey()
|
|
6141
6166
|
).execute(), await e.schema.alterTable("hooks").modifyColumn("form_id", "varchar(128)").execute(), await e.schema.alterTable("hooks").modifyColumn("template_id", "varchar(64)").execute());
|
|
6142
6167
|
}
|
|
6143
6168
|
async function Eu(e) {
|
|
@@ -6247,16 +6272,16 @@ const qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
6247
6272
|
down: Ku,
|
|
6248
6273
|
up: Lu
|
|
6249
6274
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6250
|
-
async function
|
|
6275
|
+
async function Bu(e) {
|
|
6251
6276
|
await e.schema.alterTable("login_sessions").addColumn("auth_connection", "varchar(255)").execute();
|
|
6252
6277
|
}
|
|
6253
|
-
async function
|
|
6278
|
+
async function Uu(e) {
|
|
6254
6279
|
await e.schema.alterTable("login_sessions").dropColumn("auth_connection").execute();
|
|
6255
6280
|
}
|
|
6256
6281
|
const Qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6257
6282
|
__proto__: null,
|
|
6258
|
-
down:
|
|
6259
|
-
up:
|
|
6283
|
+
down: Uu,
|
|
6284
|
+
up: Bu
|
|
6260
6285
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6261
6286
|
async function Hu(e) {
|
|
6262
6287
|
await e.schema.createTable("mfa_enrollments").addColumn("id", "varchar(26)", (t) => t.primaryKey()).addColumn(
|
|
@@ -6403,7 +6428,7 @@ const o_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
6403
6428
|
n96_create_user_organizations_table: Il,
|
|
6404
6429
|
n97_add_organization_to_user_permissions_and_roles: Dl,
|
|
6405
6430
|
n98_clients: Fl,
|
|
6406
|
-
n99_update_client_foreign_keys:
|
|
6431
|
+
n99_update_client_foreign_keys: Bl,
|
|
6407
6432
|
o001_client_grants: Hl,
|
|
6408
6433
|
o002_drop_applications: Gl,
|
|
6409
6434
|
o003_phone_number_index: Zl,
|
|
@@ -6421,7 +6446,7 @@ const o_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
6421
6446
|
o015_flows: Ad,
|
|
6422
6447
|
o016_add_is_system_column: Rd,
|
|
6423
6448
|
o017_connections_composite_key: Ld,
|
|
6424
|
-
o018_login_session_state:
|
|
6449
|
+
o018_login_session_state: Bd,
|
|
6425
6450
|
o019_roles_resource_servers_metadata: Hd,
|
|
6426
6451
|
o020_session_add_timestamp_columns: Vd,
|
|
6427
6452
|
o021_session_cleanup_and_ulid: eu,
|
|
@@ -6472,7 +6497,7 @@ async function __(e) {
|
|
|
6472
6497
|
function r_(e, t = { useTransactions: !0 }) {
|
|
6473
6498
|
const a = {
|
|
6474
6499
|
branding: ga(e),
|
|
6475
|
-
clients:
|
|
6500
|
+
clients: Ut(e),
|
|
6476
6501
|
clientConnections: Vt(e),
|
|
6477
6502
|
clientGrants: na(e),
|
|
6478
6503
|
codes: Nt(e),
|
|
@@ -6501,14 +6526,14 @@ function r_(e, t = { useTransactions: !0 }) {
|
|
|
6501
6526
|
themes: za(e),
|
|
6502
6527
|
universalLoginTemplates: Ca(e),
|
|
6503
6528
|
customText: no(e),
|
|
6504
|
-
users: Ke(e
|
|
6529
|
+
users: Ke(e),
|
|
6505
6530
|
organizations: Ln(e),
|
|
6506
6531
|
userOrganizations: Yn(e),
|
|
6507
6532
|
stats: ao(e),
|
|
6508
6533
|
outbox: fo(e),
|
|
6509
6534
|
async transaction(n) {
|
|
6510
6535
|
return t.useTransactions === !1 ? n(a) : e.transaction().execute(async (o) => {
|
|
6511
|
-
const r = r_(o, t);
|
|
6536
|
+
const r = r_(o, { ...t, useTransactions: !1 });
|
|
6512
6537
|
return n(r);
|
|
6513
6538
|
});
|
|
6514
6539
|
}
|