@kyro-cms/core 0.10.4 → 0.10.6
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/api-handler-graphql.cjs +1 -49
- package/dist/api-handler-graphql.js +1 -46
- package/dist/api-handler-trpc.cjs +1 -38
- package/dist/api-handler-trpc.js +1 -36
- package/dist/api-handler.cjs +1 -44
- package/dist/api-handler.js +1 -27
- package/dist/bootstrap-HIAV5ZFT.cjs +1 -0
- package/dist/bootstrap-P7QPQYQP.js +1 -0
- package/dist/chunk-2BTRHVT3.cjs +20 -0
- package/dist/chunk-2W4FK6CJ.js +122 -0
- package/dist/chunk-4ORJMSJU.cjs +1 -0
- package/dist/chunk-65G73T7Z.cjs +2 -0
- package/dist/chunk-7N6NKCRT.js +1 -0
- package/dist/chunk-7WOX27LK.js +259 -0
- package/dist/chunk-AE6GXUT7.js +1 -0
- package/dist/chunk-AJAZ7D3W.cjs +259 -0
- package/dist/chunk-ATLSIYRH.cjs +1 -0
- package/dist/chunk-AU6IWTBO.js +2 -0
- package/dist/chunk-CDL7ARXT.js +133 -0
- package/dist/chunk-CUTFS6N2.cjs +1 -0
- package/dist/chunk-CVVW4LXZ.cjs +1 -0
- package/dist/chunk-DGJUBN33.js +1 -0
- package/dist/chunk-DV4LFLPL.cjs +1 -0
- package/dist/chunk-EEWCANFX.js +1 -0
- package/dist/chunk-ELICKLFM.cjs +3 -0
- package/dist/chunk-EQUQJBPP.cjs +2 -0
- package/dist/chunk-ET6NN2V2.cjs +122 -0
- package/dist/chunk-F7P36SLX.cjs +74 -0
- package/dist/chunk-F7SR5IDT.cjs +1 -0
- package/dist/chunk-FO3HLBC7.js +1 -0
- package/dist/chunk-FS7GL2BR.js +73 -0
- package/dist/chunk-G6A7OSIG.js +2 -0
- package/dist/chunk-GFU7AOI3.cjs +1 -0
- package/dist/chunk-GYQMNXXW.cjs +114 -0
- package/dist/chunk-HLSB2MCK.js +1 -0
- package/dist/chunk-HVXO3OFB.cjs +1 -0
- package/dist/chunk-IFJJ44OQ.cjs +133 -0
- package/dist/chunk-ISWMETHJ.cjs +1 -0
- package/dist/chunk-K6WUOU6P.js +1 -0
- package/dist/chunk-KDNYHLD2.js +1 -0
- package/dist/chunk-KIW36TG7.cjs +86 -0
- package/dist/chunk-L6CZYN3L.cjs +20 -0
- package/dist/chunk-LRGAPGG3.js +74 -0
- package/dist/chunk-LZ6YFYQM.js +20 -0
- package/dist/chunk-MIOMMB23.cjs +1 -0
- package/dist/chunk-NGBJKZMT.js +90 -0
- package/dist/chunk-NRLIGDYF.js +1 -0
- package/dist/chunk-NY47CFVP.cjs +1 -0
- package/dist/chunk-NZ35PV5R.js +2 -0
- package/dist/chunk-OG7CNQGU.js +1 -0
- package/dist/chunk-OQD3WG6Z.cjs +1 -0
- package/dist/chunk-P7CESLDJ.js +1 -0
- package/dist/chunk-PP5S2UBV.js +0 -0
- package/dist/chunk-Q3Q7BJVQ.cjs +1 -0
- package/dist/chunk-Q4CSLXCO.cjs +90 -0
- package/dist/chunk-QRXDCV6K.js +0 -0
- package/dist/chunk-R7DVVXXI.cjs +73 -0
- package/dist/chunk-RHCWCG3O.js +114 -0
- package/dist/chunk-SL3LZQCF.js +1 -0
- package/dist/chunk-UBHFUFD4.cjs +1 -0
- package/dist/chunk-UBRYJP2G.js +1 -0
- package/dist/chunk-UDSJGML2.cjs +2 -0
- package/dist/chunk-UHFDH3PG.js +20 -0
- package/dist/chunk-UJNSOOYZ.cjs +1 -0
- package/dist/chunk-URCLFIME.js +86 -0
- package/dist/chunk-UVTS2IWM.js +1 -0
- package/dist/chunk-V65NPSR5.cjs +1 -0
- package/dist/chunk-WIZ6C5QZ.cjs +1 -0
- package/dist/chunk-ZAQOSRP6.js +1 -0
- package/dist/chunk-ZELCS7IC.js +3 -0
- package/dist/cli/index.cjs +35 -405
- package/dist/cli/index.js +35 -402
- package/dist/client.cjs +1 -55
- package/dist/client.js +1 -6
- package/dist/drizzle/index.cjs +1 -50
- package/dist/drizzle/index.d.cts +1 -2
- package/dist/drizzle/index.d.ts +1 -2
- package/dist/drizzle/index.js +1 -9
- package/dist/fields/index.cjs +1 -89
- package/dist/fields/index.js +1 -4
- package/dist/graphql/index.cjs +1 -31
- package/dist/graphql/index.d.cts +1 -1
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.js +1 -6
- package/dist/{index-jLs0zlft.d.ts → index-DXr33e0x.d.ts} +1 -1
- package/dist/{index-DHbywDs-.d.cts → index-DuuUzWBq.d.cts} +1 -1
- package/dist/index.cjs +29 -2464
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -1929
- package/dist/integration.cjs +1 -10
- package/dist/integration.js +1 -4
- package/dist/media-NSSMOB7N.cjs +1 -0
- package/dist/media-RNMCZYPZ.js +1 -0
- package/dist/mongo-auth-adapter-JYJ4GBZE.cjs +1 -0
- package/dist/mongo-auth-adapter-XI7EPURZ.js +1 -0
- package/dist/mongodb/index.cjs +1 -29
- package/dist/mongodb/index.d.cts +1 -2
- package/dist/mongodb/index.d.ts +1 -2
- package/dist/mongodb/index.js +1 -8
- package/dist/postgres-auth-adapter-E7OGMDD4.cjs +1 -0
- package/dist/postgres-auth-adapter-F4KLOGAG.js +1 -0
- package/dist/redis-adapter-AQJVABYT.cjs +1 -0
- package/dist/redis-adapter-AUKOV74G.js +1 -0
- package/dist/rest/index.cjs +1 -31
- package/dist/rest/index.d.cts +1 -1
- package/dist/rest/index.d.ts +1 -1
- package/dist/rest/index.js +1 -18
- package/dist/schema-5XNROI7I.js +1 -0
- package/dist/schema-6O4JTJRU.cjs +1 -0
- package/dist/sqlite-adapter-5XFLNJDH.js +1 -0
- package/dist/sqlite-adapter-W53Q32N5.cjs +1 -0
- package/dist/templates/index.cjs +1 -207
- package/dist/templates/index.js +1 -6
- package/dist/trpc/index.cjs +1 -48
- package/dist/trpc/index.js +1 -7
- package/dist/ws/index.cjs +1 -25
- package/dist/ws/index.js +1 -4
- package/package.json +44 -13
- package/dist/api-handler-graphql.cjs.map +0 -1
- package/dist/api-handler-graphql.js.map +0 -1
- package/dist/api-handler-trpc.cjs.map +0 -1
- package/dist/api-handler-trpc.js.map +0 -1
- package/dist/api-handler.cjs.map +0 -1
- package/dist/api-handler.js.map +0 -1
- package/dist/bootstrap-FUAPY2OF.cjs +0 -32
- package/dist/bootstrap-FUAPY2OF.cjs.map +0 -1
- package/dist/bootstrap-OXNVM7FP.js +0 -7
- package/dist/bootstrap-OXNVM7FP.js.map +0 -1
- package/dist/chunk-2HFJUUFZ.js +0 -250
- package/dist/chunk-2HFJUUFZ.js.map +0 -1
- package/dist/chunk-3AKCVYDB.js +0 -162
- package/dist/chunk-3AKCVYDB.js.map +0 -1
- package/dist/chunk-3KTWGODI.cjs +0 -178
- package/dist/chunk-3KTWGODI.cjs.map +0 -1
- package/dist/chunk-3YELQL7Z.cjs +0 -4
- package/dist/chunk-3YELQL7Z.cjs.map +0 -1
- package/dist/chunk-4CV4JOE5.js +0 -24
- package/dist/chunk-4CV4JOE5.js.map +0 -1
- package/dist/chunk-4OCMVGEY.cjs +0 -173
- package/dist/chunk-4OCMVGEY.cjs.map +0 -1
- package/dist/chunk-4PWRCMTQ.cjs +0 -15
- package/dist/chunk-4PWRCMTQ.cjs.map +0 -1
- package/dist/chunk-53NYVYVX.js +0 -3243
- package/dist/chunk-53NYVYVX.js.map +0 -1
- package/dist/chunk-5GFQPHGT.cjs +0 -156
- package/dist/chunk-5GFQPHGT.cjs.map +0 -1
- package/dist/chunk-5RPRLTTN.js +0 -861
- package/dist/chunk-5RPRLTTN.js.map +0 -1
- package/dist/chunk-74YSDAWE.cjs +0 -2749
- package/dist/chunk-74YSDAWE.cjs.map +0 -1
- package/dist/chunk-7OGPN7MP.js +0 -352
- package/dist/chunk-7OGPN7MP.js.map +0 -1
- package/dist/chunk-7OS7TX2Q.cjs +0 -495
- package/dist/chunk-7OS7TX2Q.cjs.map +0 -1
- package/dist/chunk-ADLJSJSN.cjs +0 -13
- package/dist/chunk-ADLJSJSN.cjs.map +0 -1
- package/dist/chunk-B6X3LN25.cjs +0 -6486
- package/dist/chunk-B6X3LN25.cjs.map +0 -1
- package/dist/chunk-BYBMTIMT.js +0 -419
- package/dist/chunk-BYBMTIMT.js.map +0 -1
- package/dist/chunk-CF7OL6HR.js +0 -355
- package/dist/chunk-CF7OL6HR.js.map +0 -1
- package/dist/chunk-CJX74IYK.js +0 -489
- package/dist/chunk-CJX74IYK.js.map +0 -1
- package/dist/chunk-CKVOU6MX.cjs +0 -52
- package/dist/chunk-CKVOU6MX.cjs.map +0 -1
- package/dist/chunk-CZLDE2OZ.cjs +0 -28
- package/dist/chunk-CZLDE2OZ.cjs.map +0 -1
- package/dist/chunk-DPA3KWPY.cjs +0 -205
- package/dist/chunk-DPA3KWPY.cjs.map +0 -1
- package/dist/chunk-EEJUFDMF.cjs +0 -424
- package/dist/chunk-EEJUFDMF.cjs.map +0 -1
- package/dist/chunk-FIAMXNTH.js +0 -220
- package/dist/chunk-FIAMXNTH.js.map +0 -1
- package/dist/chunk-GAOXD3XT.js +0 -175
- package/dist/chunk-GAOXD3XT.js.map +0 -1
- package/dist/chunk-GTGRLD4Y.js +0 -3
- package/dist/chunk-GTGRLD4Y.js.map +0 -1
- package/dist/chunk-GUUB5EAG.cjs +0 -223
- package/dist/chunk-GUUB5EAG.cjs.map +0 -1
- package/dist/chunk-GXFOGU7N.cjs +0 -359
- package/dist/chunk-GXFOGU7N.cjs.map +0 -1
- package/dist/chunk-GZS4LMR7.js +0 -422
- package/dist/chunk-GZS4LMR7.js.map +0 -1
- package/dist/chunk-HY6B7B5A.js +0 -150
- package/dist/chunk-HY6B7B5A.js.map +0 -1
- package/dist/chunk-HZOMOK5Y.js +0 -2728
- package/dist/chunk-HZOMOK5Y.js.map +0 -1
- package/dist/chunk-IDVRRRAK.cjs +0 -824
- package/dist/chunk-IDVRRRAK.cjs.map +0 -1
- package/dist/chunk-KC2GDBLS.cjs +0 -84
- package/dist/chunk-KC2GDBLS.cjs.map +0 -1
- package/dist/chunk-L4EZKIEX.js +0 -185
- package/dist/chunk-L4EZKIEX.js.map +0 -1
- package/dist/chunk-LNTFRAHF.cjs +0 -473
- package/dist/chunk-LNTFRAHF.cjs.map +0 -1
- package/dist/chunk-MTIRYI7F.cjs +0 -4
- package/dist/chunk-MTIRYI7F.cjs.map +0 -1
- package/dist/chunk-N4GN6Q3V.cjs +0 -869
- package/dist/chunk-N4GN6Q3V.cjs.map +0 -1
- package/dist/chunk-N4H37VN4.cjs +0 -259
- package/dist/chunk-N4H37VN4.cjs.map +0 -1
- package/dist/chunk-N5QSHUA6.js +0 -1135
- package/dist/chunk-N5QSHUA6.js.map +0 -1
- package/dist/chunk-NKPKR5BW.cjs +0 -188
- package/dist/chunk-NKPKR5BW.cjs.map +0 -1
- package/dist/chunk-OIRG6ZRV.cjs +0 -1073
- package/dist/chunk-OIRG6ZRV.cjs.map +0 -1
- package/dist/chunk-OJ2AM75W.cjs +0 -253
- package/dist/chunk-OJ2AM75W.cjs.map +0 -1
- package/dist/chunk-OLV7K22H.js +0 -6457
- package/dist/chunk-OLV7K22H.js.map +0 -1
- package/dist/chunk-OX6GOIPH.js +0 -516
- package/dist/chunk-OX6GOIPH.js.map +0 -1
- package/dist/chunk-P2YW545G.js +0 -11
- package/dist/chunk-P2YW545G.js.map +0 -1
- package/dist/chunk-PHJRNPHY.cjs +0 -3291
- package/dist/chunk-PHJRNPHY.cjs.map +0 -1
- package/dist/chunk-Q72BOAPK.js +0 -817
- package/dist/chunk-Q72BOAPK.js.map +0 -1
- package/dist/chunk-QU2RFFH4.js +0 -3
- package/dist/chunk-QU2RFFH4.js.map +0 -1
- package/dist/chunk-RP7VZUEL.js +0 -49
- package/dist/chunk-RP7VZUEL.js.map +0 -1
- package/dist/chunk-SHTTJMLT.cjs +0 -361
- package/dist/chunk-SHTTJMLT.cjs.map +0 -1
- package/dist/chunk-SX76DNOO.js +0 -103
- package/dist/chunk-SX76DNOO.js.map +0 -1
- package/dist/chunk-THBQG64D.cjs +0 -425
- package/dist/chunk-THBQG64D.cjs.map +0 -1
- package/dist/chunk-TQG7G7YI.cjs +0 -526
- package/dist/chunk-TQG7G7YI.cjs.map +0 -1
- package/dist/chunk-U3VVLYXG.cjs +0 -189
- package/dist/chunk-U3VVLYXG.cjs.map +0 -1
- package/dist/chunk-UUDTPZX6.js +0 -193
- package/dist/chunk-UUDTPZX6.js.map +0 -1
- package/dist/chunk-V5AWATUP.js +0 -1059
- package/dist/chunk-V5AWATUP.js.map +0 -1
- package/dist/chunk-VAXLFZCV.cjs +0 -110
- package/dist/chunk-VAXLFZCV.cjs.map +0 -1
- package/dist/chunk-VKREAIBA.cjs +0 -1139
- package/dist/chunk-VKREAIBA.cjs.map +0 -1
- package/dist/chunk-WDTTHKDS.js +0 -458
- package/dist/chunk-WDTTHKDS.js.map +0 -1
- package/dist/chunk-WXVB364T.js +0 -218
- package/dist/chunk-WXVB364T.js.map +0 -1
- package/dist/chunk-X4BPPD6K.js +0 -181
- package/dist/chunk-X4BPPD6K.js.map +0 -1
- package/dist/chunk-XEB7PH2E.js +0 -81
- package/dist/chunk-XEB7PH2E.js.map +0 -1
- package/dist/chunk-YT7HXXVN.js +0 -13
- package/dist/chunk-YT7HXXVN.js.map +0 -1
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/drizzle/index.cjs.map +0 -1
- package/dist/drizzle/index.js.map +0 -1
- package/dist/fields/index.cjs.map +0 -1
- package/dist/fields/index.js.map +0 -1
- package/dist/graphql/index.cjs.map +0 -1
- package/dist/graphql/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration.cjs.map +0 -1
- package/dist/integration.js.map +0 -1
- package/dist/media-7WDX4BDJ.js +0 -4
- package/dist/media-7WDX4BDJ.js.map +0 -1
- package/dist/media-TUSLVRQ6.cjs +0 -17
- package/dist/media-TUSLVRQ6.cjs.map +0 -1
- package/dist/mongo-auth-adapter-GT4S7SCU.cjs +0 -17
- package/dist/mongo-auth-adapter-GT4S7SCU.cjs.map +0 -1
- package/dist/mongo-auth-adapter-M7VV4LNB.js +0 -4
- package/dist/mongo-auth-adapter-M7VV4LNB.js.map +0 -1
- package/dist/mongodb/index.cjs.map +0 -1
- package/dist/mongodb/index.js.map +0 -1
- package/dist/postgres-auth-adapter-AFAPISH7.js +0 -5
- package/dist/postgres-auth-adapter-AFAPISH7.js.map +0 -1
- package/dist/postgres-auth-adapter-SFDTLONT.cjs +0 -14
- package/dist/postgres-auth-adapter-SFDTLONT.cjs.map +0 -1
- package/dist/redis-adapter-UQX4EE3B.cjs +0 -13
- package/dist/redis-adapter-UQX4EE3B.cjs.map +0 -1
- package/dist/redis-adapter-XALOGWY3.js +0 -4
- package/dist/redis-adapter-XALOGWY3.js.map +0 -1
- package/dist/rest/index.cjs.map +0 -1
- package/dist/rest/index.js.map +0 -1
- package/dist/schema-6QL3USNB.cjs +0 -67
- package/dist/schema-6QL3USNB.cjs.map +0 -1
- package/dist/schema-FNNWEAAW.js +0 -6
- package/dist/schema-FNNWEAAW.js.map +0 -1
- package/dist/sqlite-adapter-AQB5TCGV.cjs +0 -13
- package/dist/sqlite-adapter-AQB5TCGV.cjs.map +0 -1
- package/dist/sqlite-adapter-N5H6IM2X.js +0 -4
- package/dist/sqlite-adapter-N5H6IM2X.js.map +0 -1
- package/dist/templates/index.cjs.map +0 -1
- package/dist/templates/index.js.map +0 -1
- package/dist/trpc/index.cjs.map +0 -1
- package/dist/trpc/index.js.map +0 -1
- package/dist/ws/index.cjs.map +0 -1
- package/dist/ws/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2478 +1,43 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var chunkOIRG6ZRV_cjs = require('./chunk-OIRG6ZRV.cjs');
|
|
24
|
-
var chunk7OS7TX2Q_cjs = require('./chunk-7OS7TX2Q.cjs');
|
|
25
|
-
require('./chunk-DPA3KWPY.cjs');
|
|
26
|
-
require('./chunk-MTIRYI7F.cjs');
|
|
27
|
-
var chunkTHBQG64D_cjs = require('./chunk-THBQG64D.cjs');
|
|
28
|
-
var chunkGXFOGU7N_cjs = require('./chunk-GXFOGU7N.cjs');
|
|
29
|
-
var chunkGUUB5EAG_cjs = require('./chunk-GUUB5EAG.cjs');
|
|
30
|
-
require('./chunk-NKPKR5BW.cjs');
|
|
31
|
-
require('./chunk-CZLDE2OZ.cjs');
|
|
32
|
-
var crypto2 = require('crypto');
|
|
33
|
-
var fs = require('fs');
|
|
34
|
-
var path = require('path');
|
|
35
|
-
var zod = require('zod');
|
|
36
|
-
var unstorage = require('unstorage');
|
|
37
|
-
var indexedbDriver = require('unstorage/drivers/indexedb');
|
|
38
|
-
var fsDriver = require('unstorage/drivers/fs');
|
|
39
|
-
|
|
40
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
41
|
-
|
|
42
|
-
var crypto2__default = /*#__PURE__*/_interopDefault(crypto2);
|
|
43
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
44
|
-
var indexedbDriver__default = /*#__PURE__*/_interopDefault(indexedbDriver);
|
|
45
|
-
var fsDriver__default = /*#__PURE__*/_interopDefault(fsDriver);
|
|
46
|
-
|
|
47
|
-
// src/hooks/types.ts
|
|
48
|
-
async function runHooks(hooks, args) {
|
|
49
|
-
let result = args.data;
|
|
50
|
-
for (const hook of hooks) {
|
|
51
|
-
const hookResult = await hook({
|
|
52
|
-
...args,
|
|
53
|
-
data: result
|
|
54
|
-
});
|
|
55
|
-
if (hookResult !== void 0) {
|
|
56
|
-
result = hookResult;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
async function runFieldHooks(hooks, args) {
|
|
62
|
-
return runHooks(hooks, args);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/plugins/index.ts
|
|
66
|
-
var KyroPlugin = class {
|
|
67
|
-
name;
|
|
68
|
-
version;
|
|
69
|
-
description;
|
|
70
|
-
hooks = {};
|
|
71
|
-
collections = [];
|
|
72
|
-
globals = [];
|
|
73
|
-
fields = [];
|
|
74
|
-
extensions = { collections: [], globals: [] };
|
|
75
|
-
adminComponents = {};
|
|
76
|
-
adminStyles = [];
|
|
77
|
-
serverMiddleware;
|
|
78
|
-
clientMiddleware;
|
|
79
|
-
constructor(name) {
|
|
80
|
-
this.name = name;
|
|
81
|
-
}
|
|
82
|
-
async init(api) {
|
|
83
|
-
}
|
|
84
|
-
async beforeInit(api) {
|
|
85
|
-
}
|
|
86
|
-
async afterInit(api) {
|
|
87
|
-
}
|
|
88
|
-
getCollections() {
|
|
89
|
-
return this.collections;
|
|
90
|
-
}
|
|
91
|
-
getGlobals() {
|
|
92
|
-
return this.globals;
|
|
93
|
-
}
|
|
94
|
-
getHooks() {
|
|
95
|
-
return this.hooks;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var PluginManager = class {
|
|
99
|
-
plugins = /* @__PURE__ */ new Map();
|
|
100
|
-
hooks = /* @__PURE__ */ new Map();
|
|
101
|
-
register(plugin) {
|
|
102
|
-
if (this.plugins.has(plugin.name)) {
|
|
103
|
-
throw new Error(`Plugin "${plugin.name}" is already registered`);
|
|
104
|
-
}
|
|
105
|
-
this.plugins.set(plugin.name, plugin);
|
|
106
|
-
const pluginHooks = plugin.getHooks?.() || {};
|
|
107
|
-
for (const [event, handlers] of Object.entries(pluginHooks)) {
|
|
108
|
-
if (Array.isArray(handlers)) {
|
|
109
|
-
for (const handler of handlers) {
|
|
110
|
-
this.registerHook(event, handler);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
unregister(name) {
|
|
116
|
-
const plugin = this.plugins.get(name);
|
|
117
|
-
if (!plugin) return;
|
|
118
|
-
const pluginHooks = plugin.getHooks?.() || {};
|
|
119
|
-
for (const [event, handlers] of Object.entries(pluginHooks)) {
|
|
120
|
-
if (Array.isArray(handlers)) {
|
|
121
|
-
for (const handler of handlers) {
|
|
122
|
-
this.unregisterHook(event, handler);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
this.plugins.delete(name);
|
|
127
|
-
}
|
|
128
|
-
get(name) {
|
|
129
|
-
return this.plugins.get(name);
|
|
130
|
-
}
|
|
131
|
-
getAll() {
|
|
132
|
-
return Array.from(this.plugins.values());
|
|
133
|
-
}
|
|
134
|
-
has(name) {
|
|
135
|
-
return this.plugins.has(name);
|
|
136
|
-
}
|
|
137
|
-
registerHook(event, handler) {
|
|
138
|
-
if (!this.hooks.has(event)) {
|
|
139
|
-
this.hooks.set(event, []);
|
|
140
|
-
}
|
|
141
|
-
this.hooks.get(event).push(handler);
|
|
142
|
-
}
|
|
143
|
-
unregisterHook(event, handler) {
|
|
144
|
-
const handlers = this.hooks.get(event);
|
|
145
|
-
if (handlers) {
|
|
146
|
-
const index = handlers.indexOf(handler);
|
|
147
|
-
if (index > -1) {
|
|
148
|
-
handlers.splice(index, 1);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async executeHook(event, args) {
|
|
153
|
-
const handlers = this.hooks.get(event) || [];
|
|
154
|
-
let result = args;
|
|
155
|
-
for (const handler of handlers) {
|
|
156
|
-
try {
|
|
157
|
-
const hookResult = await handler({ ...args, data: result });
|
|
158
|
-
if (hookResult !== void 0) {
|
|
159
|
-
result = hookResult;
|
|
160
|
-
}
|
|
161
|
-
} catch (error) {
|
|
162
|
-
console.error(`[PluginManager] Error in hook "${event}":`, error);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
// ========================================================================
|
|
168
|
-
// Collection/Field Extensions
|
|
169
|
-
// ========================================================================
|
|
170
|
-
getAllCollections() {
|
|
171
|
-
const collections = [];
|
|
172
|
-
for (const plugin of this.plugins.values()) {
|
|
173
|
-
const pluginCollections = plugin.getCollections?.() || [];
|
|
174
|
-
collections.push(...pluginCollections);
|
|
175
|
-
}
|
|
176
|
-
return collections;
|
|
177
|
-
}
|
|
178
|
-
getAllGlobals() {
|
|
179
|
-
const globals = [];
|
|
180
|
-
for (const plugin of this.plugins.values()) {
|
|
181
|
-
const pluginGlobals = plugin.getGlobals?.() || [];
|
|
182
|
-
globals.push(...pluginGlobals);
|
|
183
|
-
}
|
|
184
|
-
return globals;
|
|
185
|
-
}
|
|
186
|
-
getAllFields() {
|
|
187
|
-
const fields = [];
|
|
188
|
-
for (const plugin of this.plugins.values()) {
|
|
189
|
-
fields.push(...plugin.fields);
|
|
190
|
-
}
|
|
191
|
-
return fields;
|
|
192
|
-
}
|
|
193
|
-
getAdminComponents() {
|
|
194
|
-
const components = {};
|
|
195
|
-
for (const plugin of this.plugins.values()) {
|
|
196
|
-
Object.assign(components, plugin.adminComponents);
|
|
197
|
-
}
|
|
198
|
-
return components;
|
|
199
|
-
}
|
|
200
|
-
getAdminStyles() {
|
|
201
|
-
const styles = [];
|
|
202
|
-
for (const plugin of this.plugins.values()) {
|
|
203
|
-
styles.push(...plugin.adminStyles);
|
|
204
|
-
}
|
|
205
|
-
return styles;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
var SEOPLugin = class extends KyroPlugin {
|
|
209
|
-
constructor() {
|
|
210
|
-
super("seo");
|
|
211
|
-
this.description = "Advanced SEO features including sitemaps, robots.txt, and structured data";
|
|
212
|
-
this.collections.push({
|
|
213
|
-
slug: "seo-settings",
|
|
214
|
-
label: "SEO Settings",
|
|
215
|
-
fields: [
|
|
216
|
-
{
|
|
217
|
-
name: "sitemap",
|
|
218
|
-
type: "checkbox",
|
|
219
|
-
label: "Enable Sitemap",
|
|
220
|
-
defaultValue: true
|
|
221
|
-
},
|
|
222
|
-
{ name: "robotsTxt", type: "richtext", label: "robots.txt Content" },
|
|
223
|
-
{
|
|
224
|
-
name: "canonicalUrl",
|
|
225
|
-
type: "text",
|
|
226
|
-
variant: "url",
|
|
227
|
-
label: "Canonical URL"
|
|
228
|
-
},
|
|
229
|
-
{ name: "ogImage", type: "text", label: "Default OG Image URL" }
|
|
230
|
-
]
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
var AnalyticsPlugin = class extends KyroPlugin {
|
|
235
|
-
constructor() {
|
|
236
|
-
super("analytics");
|
|
237
|
-
this.description = "Analytics integration for tracking page views and events";
|
|
238
|
-
this.collections.push({
|
|
239
|
-
slug: "analytics-events",
|
|
240
|
-
label: "Analytics Events",
|
|
241
|
-
fields: [
|
|
242
|
-
{ name: "name", type: "text", required: true },
|
|
243
|
-
{ name: "properties", type: "json", label: "Event Properties" },
|
|
244
|
-
{ name: "timestamp", type: "date", required: true },
|
|
245
|
-
{ name: "userId", type: "text", label: "User ID" },
|
|
246
|
-
{ name: "sessionId", type: "text", label: "Session ID" }
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
this.adminComponents["AnalyticsDashboard"] = {};
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
var CommentsPlugin = class extends KyroPlugin {
|
|
253
|
-
constructor() {
|
|
254
|
-
super("comments");
|
|
255
|
-
this.description = "Commenting system for products and posts";
|
|
256
|
-
this.collections.push({
|
|
257
|
-
slug: "comments",
|
|
258
|
-
label: "Comments",
|
|
259
|
-
fields: [
|
|
260
|
-
{ name: "content", type: "richtext", required: true },
|
|
261
|
-
{ name: "author", type: "text", required: true },
|
|
262
|
-
{ name: "email", type: "email" },
|
|
263
|
-
{ name: "approved", type: "checkbox", defaultValue: false },
|
|
264
|
-
{ name: "parent", type: "text", label: "Parent Comment ID" },
|
|
265
|
-
{ name: "resourceType", type: "text", required: true },
|
|
266
|
-
{ name: "resourceId", type: "text", required: true }
|
|
267
|
-
]
|
|
268
|
-
});
|
|
269
|
-
this.adminComponents["CommentModeration"] = {};
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
var ReviewsPlugin = class extends KyroPlugin {
|
|
273
|
-
constructor() {
|
|
274
|
-
super("reviews");
|
|
275
|
-
this.description = "Product reviews and ratings";
|
|
276
|
-
this.collections.push({
|
|
277
|
-
slug: "reviews",
|
|
278
|
-
label: "Reviews",
|
|
279
|
-
fields: [
|
|
280
|
-
{ name: "rating", type: "number", required: true, min: 1, max: 5 },
|
|
281
|
-
{ name: "title", type: "text" },
|
|
282
|
-
{ name: "content", type: "richtext", required: true },
|
|
283
|
-
{ name: "author", type: "relationship", relationTo: "customers" },
|
|
284
|
-
{
|
|
285
|
-
name: "product",
|
|
286
|
-
type: "relationship",
|
|
287
|
-
relationTo: "products",
|
|
288
|
-
required: true
|
|
289
|
-
},
|
|
290
|
-
{ name: "approved", type: "checkbox", defaultValue: false },
|
|
291
|
-
{ name: "verified", type: "checkbox", label: "Verified Purchase" },
|
|
292
|
-
{
|
|
293
|
-
name: "helpful",
|
|
294
|
-
type: "number",
|
|
295
|
-
label: "Helpful Count",
|
|
296
|
-
defaultValue: 0
|
|
297
|
-
}
|
|
298
|
-
]
|
|
299
|
-
});
|
|
300
|
-
this.adminComponents["ReviewModeration"] = {};
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
var WishlistPlugin = class extends KyroPlugin {
|
|
304
|
-
constructor() {
|
|
305
|
-
super("wishlist");
|
|
306
|
-
this.description = "Customer wishlists";
|
|
307
|
-
this.collections.push({
|
|
308
|
-
slug: "wishlists",
|
|
309
|
-
label: "Wishlists",
|
|
310
|
-
fields: [
|
|
311
|
-
{
|
|
312
|
-
name: "customer",
|
|
313
|
-
type: "relationship",
|
|
314
|
-
relationTo: "customers",
|
|
315
|
-
required: true
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
name: "name",
|
|
319
|
-
type: "text",
|
|
320
|
-
label: "Wishlist Name",
|
|
321
|
-
defaultValue: "My Wishlist"
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
name: "items",
|
|
325
|
-
type: "blocks",
|
|
326
|
-
label: "Items",
|
|
327
|
-
blocks: [
|
|
328
|
-
{
|
|
329
|
-
slug: "wishlist-item",
|
|
330
|
-
label: "Item",
|
|
331
|
-
fields: [
|
|
332
|
-
{
|
|
333
|
-
name: "product",
|
|
334
|
-
type: "relationship",
|
|
335
|
-
relationTo: "products"
|
|
336
|
-
},
|
|
337
|
-
{ name: "quantity", type: "number", defaultValue: 1 },
|
|
338
|
-
{ name: "addedAt", type: "date" },
|
|
339
|
-
{
|
|
340
|
-
name: "priority",
|
|
341
|
-
type: "select",
|
|
342
|
-
options: [
|
|
343
|
-
{ label: "Low", value: "low" },
|
|
344
|
-
{ label: "Medium", value: "medium" },
|
|
345
|
-
{ label: "High", value: "high" }
|
|
346
|
-
]
|
|
347
|
-
}
|
|
348
|
-
]
|
|
349
|
-
}
|
|
350
|
-
]
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
var presetPlugins = {
|
|
357
|
-
SEO: SEOPLugin,
|
|
358
|
-
Analytics: AnalyticsPlugin,
|
|
359
|
-
Comments: CommentsPlugin,
|
|
360
|
-
Reviews: ReviewsPlugin,
|
|
361
|
-
Wishlist: WishlistPlugin
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// src/auth/security/lockout.ts
|
|
365
|
-
var DEFAULT_LOCKOUT_CONFIG = {
|
|
366
|
-
maxAttempts: 5,
|
|
367
|
-
lockDuration: 9e5,
|
|
368
|
-
notifyUser: true,
|
|
369
|
-
notifyAdmin: true,
|
|
370
|
-
adminNotifyAfter: 3
|
|
371
|
-
};
|
|
372
|
-
var AccountLockout = class {
|
|
373
|
-
redis;
|
|
374
|
-
prefix;
|
|
375
|
-
config;
|
|
376
|
-
constructor(redis, config = {}, prefix = "kyro:lockout:") {
|
|
377
|
-
this.redis = redis;
|
|
378
|
-
this.prefix = prefix;
|
|
379
|
-
this.config = { ...DEFAULT_LOCKOUT_CONFIG, ...config };
|
|
380
|
-
}
|
|
381
|
-
lockKey(userId) {
|
|
382
|
-
return `${this.prefix}${userId}`;
|
|
383
|
-
}
|
|
384
|
-
historyKey(userId) {
|
|
385
|
-
return `${this.prefix}${userId}:history`;
|
|
386
|
-
}
|
|
387
|
-
async checkLockout(userId) {
|
|
388
|
-
const key = this.lockKey(userId);
|
|
389
|
-
const data = await this.redis.hgetall(key);
|
|
390
|
-
if (!data || Object.keys(data).length === 0) {
|
|
391
|
-
return {
|
|
392
|
-
locked: false,
|
|
393
|
-
attemptsRemaining: this.config.maxAttempts,
|
|
394
|
-
totalAttempts: 0
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
const attempts = parseInt(data.attempts, 10);
|
|
398
|
-
const lockedUntil = data.lockedUntil ? new Date(parseInt(data.lockedUntil, 10)) : void 0;
|
|
399
|
-
if (lockedUntil && lockedUntil > /* @__PURE__ */ new Date()) {
|
|
400
|
-
return {
|
|
401
|
-
locked: true,
|
|
402
|
-
attemptsRemaining: 0,
|
|
403
|
-
lockedUntil,
|
|
404
|
-
totalAttempts: attempts
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
if (lockedUntil && lockedUntil <= /* @__PURE__ */ new Date()) {
|
|
408
|
-
await this.unlockAccount(userId);
|
|
409
|
-
return {
|
|
410
|
-
locked: false,
|
|
411
|
-
attemptsRemaining: this.config.maxAttempts,
|
|
412
|
-
totalAttempts: 0
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
return {
|
|
416
|
-
locked: false,
|
|
417
|
-
attemptsRemaining: Math.max(0, this.config.maxAttempts - attempts),
|
|
418
|
-
totalAttempts: attempts
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
async recordFailedAttempt(userId) {
|
|
422
|
-
const key = this.lockKey(userId);
|
|
423
|
-
const historyKey = this.historyKey(userId);
|
|
424
|
-
const now = Date.now();
|
|
425
|
-
const current = await this.redis.hincrby(key, "attempts", 1);
|
|
426
|
-
await this.redis.hset(key, "lastAttempt", now.toString());
|
|
427
|
-
await this.redis.lpush(historyKey, now.toString());
|
|
428
|
-
await this.redis.ltrim(historyKey, 0, 99);
|
|
429
|
-
if (current >= this.config.maxAttempts) {
|
|
430
|
-
const lockedUntil = new Date(now + this.config.lockDuration);
|
|
431
|
-
await this.redis.hset(key, {
|
|
432
|
-
lockedAt: now.toString(),
|
|
433
|
-
lockedUntil: lockedUntil.getTime().toString()
|
|
434
|
-
});
|
|
435
|
-
await this.redis.expire(
|
|
436
|
-
key,
|
|
437
|
-
Math.ceil(this.config.lockDuration / 1e3) + 3600
|
|
438
|
-
);
|
|
439
|
-
return {
|
|
440
|
-
locked: true,
|
|
441
|
-
attemptsRemaining: 0,
|
|
442
|
-
lockedUntil,
|
|
443
|
-
totalAttempts: current
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
return {
|
|
447
|
-
locked: false,
|
|
448
|
-
attemptsRemaining: Math.max(0, this.config.maxAttempts - current),
|
|
449
|
-
totalAttempts: current
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
async lockAccount(userId, duration) {
|
|
453
|
-
const key = this.lockKey(userId);
|
|
454
|
-
const now = Date.now();
|
|
455
|
-
const lockDuration = duration || this.config.lockDuration;
|
|
456
|
-
const lockedUntil = new Date(now + lockDuration);
|
|
457
|
-
const pipeline = this.redis.pipeline();
|
|
458
|
-
pipeline.hset(key, {
|
|
459
|
-
attempts: this.config.maxAttempts.toString(),
|
|
460
|
-
lockedAt: now.toString(),
|
|
461
|
-
lockedUntil: lockedUntil.getTime().toString()
|
|
462
|
-
});
|
|
463
|
-
pipeline.expire(key, Math.ceil(lockDuration / 1e3) + 3600);
|
|
464
|
-
await pipeline.exec();
|
|
465
|
-
}
|
|
466
|
-
async unlockAccount(userId) {
|
|
467
|
-
const key = this.lockKey(userId);
|
|
468
|
-
await this.redis.del(key);
|
|
469
|
-
}
|
|
470
|
-
async resetAttempts(userId) {
|
|
471
|
-
const key = this.lockKey(userId);
|
|
472
|
-
const data = await this.redis.hgetall(key);
|
|
473
|
-
if (data.lockedAt) {
|
|
474
|
-
await this.redis.hset(key, {
|
|
475
|
-
attempts: "0",
|
|
476
|
-
lockedAt: "",
|
|
477
|
-
lockedUntil: ""
|
|
478
|
-
});
|
|
479
|
-
} else {
|
|
480
|
-
await this.redis.del(key);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
async getLockoutHistory(userId, limit = 10) {
|
|
484
|
-
const historyKey = this.historyKey(userId);
|
|
485
|
-
const timestamps = await this.redis.lrange(historyKey, 0, limit - 1);
|
|
486
|
-
return timestamps.map((ts) => new Date(parseInt(ts, 10)));
|
|
487
|
-
}
|
|
488
|
-
async getLockoutStats(userId) {
|
|
489
|
-
const historyKey = this.historyKey(userId);
|
|
490
|
-
const timestamps = await this.redis.lrange(historyKey, 0, -1);
|
|
491
|
-
const lockouts = timestamps.filter((_, i) => {
|
|
492
|
-
const attemptNum = i + 1;
|
|
493
|
-
return attemptNum % this.config.maxAttempts === 0;
|
|
494
|
-
}).length;
|
|
495
|
-
const lastLockoutData = await this.redis.hget(
|
|
496
|
-
this.lockKey(userId),
|
|
497
|
-
"lockedAt"
|
|
498
|
-
);
|
|
499
|
-
return {
|
|
500
|
-
totalFailedAttempts: timestamps.length,
|
|
501
|
-
lockoutCount: lockouts,
|
|
502
|
-
lastLockout: lastLockoutData ? new Date(parseInt(lastLockoutData, 10)) : null,
|
|
503
|
-
averageAttemptsBeforeLockout: lockouts > 0 ? this.config.maxAttempts : 0
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
shouldNotifyAdmin(currentAttempts) {
|
|
507
|
-
return this.config.notifyAdmin && currentAttempts >= this.config.adminNotifyAfter;
|
|
508
|
-
}
|
|
509
|
-
getConfig() {
|
|
510
|
-
return { ...this.config };
|
|
511
|
-
}
|
|
512
|
-
setConfig(config) {
|
|
513
|
-
this.config = { ...this.config, ...config };
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
// src/auth/security/rate-limit.ts
|
|
518
|
-
var DEFAULT_RATE_LIMITS = {
|
|
519
|
-
"auth:login": { window: 9e5, max: 5 },
|
|
520
|
-
"auth:register": { window: 36e5, max: 3 },
|
|
521
|
-
"auth:forgot": { window: 36e5, max: 3 },
|
|
522
|
-
"auth:reset": { window: 36e5, max: 5 },
|
|
523
|
-
"auth:verify": { window: 36e5, max: 5 },
|
|
524
|
-
"api:general": { window: 6e4, max: 100 },
|
|
525
|
-
"api:authenticated": { window: 6e4, max: 200 }
|
|
526
|
-
};
|
|
527
|
-
var RateLimiter = class {
|
|
528
|
-
redis;
|
|
529
|
-
prefix;
|
|
530
|
-
limits;
|
|
531
|
-
userLimits;
|
|
532
|
-
constructor(redis, limits, userLimits, prefix = "kyro:ratelimit:") {
|
|
533
|
-
this.redis = redis;
|
|
534
|
-
this.prefix = prefix;
|
|
535
|
-
this.limits = { ...DEFAULT_RATE_LIMITS, ...limits };
|
|
536
|
-
this.userLimits = userLimits || {
|
|
537
|
-
"user:api": { window: 6e4, max: 500 },
|
|
538
|
-
"user:write": { window: 36e5, max: 100 }
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
getKey(type, identifier) {
|
|
542
|
-
return `${this.prefix}${type}:${identifier}`;
|
|
543
|
-
}
|
|
544
|
-
async check(type, identifier) {
|
|
545
|
-
const config = this.limits[type] || this.limits["api:general"];
|
|
546
|
-
const key = this.getKey(type, identifier);
|
|
547
|
-
const now = Date.now();
|
|
548
|
-
const windowStart = now - config.window;
|
|
549
|
-
const pipeline = this.redis.pipeline();
|
|
550
|
-
pipeline.zremrangebyscore(key, 0, windowStart);
|
|
551
|
-
pipeline.zcard(key);
|
|
552
|
-
pipeline.zadd(key, now, `${now}:${Math.random()}`);
|
|
553
|
-
pipeline.expire(key, Math.ceil(config.window / 1e3) + 1);
|
|
554
|
-
const results = await pipeline.exec();
|
|
555
|
-
const count = results?.[1]?.[1] || 0;
|
|
556
|
-
if (count >= config.max) {
|
|
557
|
-
const oldestTimestamp = await this.redis.zrange(key, 0, 0, "WITHSCORES");
|
|
558
|
-
const resetAt = oldestTimestamp.length > 1 ? parseInt(oldestTimestamp[1], 10) + config.window : now + config.window;
|
|
559
|
-
return {
|
|
560
|
-
allowed: false,
|
|
561
|
-
remaining: 0,
|
|
562
|
-
resetAt,
|
|
563
|
-
retryAfter: Math.ceil((resetAt - now) / 1e3)
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
allowed: true,
|
|
568
|
-
remaining: config.max - count - 1,
|
|
569
|
-
resetAt: now + config.window
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
async checkUser(type, userId, identifier) {
|
|
573
|
-
const config = this.userLimits[type] || this.userLimits["user:api"];
|
|
574
|
-
const key = this.getKey(`user:${type}:${userId}`, identifier);
|
|
575
|
-
const now = Date.now();
|
|
576
|
-
const windowStart = now - config.window;
|
|
577
|
-
const pipeline = this.redis.pipeline();
|
|
578
|
-
pipeline.zremrangebyscore(key, 0, windowStart);
|
|
579
|
-
pipeline.zcard(key);
|
|
580
|
-
pipeline.zadd(key, now, `${now}:${Math.random()}`);
|
|
581
|
-
pipeline.expire(key, Math.ceil(config.window / 1e3) + 1);
|
|
582
|
-
const results = await pipeline.exec();
|
|
583
|
-
const count = results?.[1]?.[1] || 0;
|
|
584
|
-
if (count >= config.max) {
|
|
585
|
-
const oldestTimestamp = await this.redis.zrange(key, 0, 0, "WITHSCORES");
|
|
586
|
-
const resetAt = oldestTimestamp.length > 1 ? parseInt(oldestTimestamp[1], 10) + config.window : now + config.window;
|
|
587
|
-
return {
|
|
588
|
-
allowed: false,
|
|
589
|
-
remaining: 0,
|
|
590
|
-
resetAt,
|
|
591
|
-
retryAfter: Math.ceil((resetAt - now) / 1e3)
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
return {
|
|
595
|
-
allowed: true,
|
|
596
|
-
remaining: config.max - count - 1,
|
|
597
|
-
resetAt: now + config.window
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
async reset(type, identifier) {
|
|
601
|
-
const key = this.getKey(type, identifier);
|
|
602
|
-
await this.redis.del(key);
|
|
603
|
-
}
|
|
604
|
-
async resetUser(type, userId, identifier) {
|
|
605
|
-
const key = this.getKey(`user:${type}:${userId}`, identifier);
|
|
606
|
-
await this.redis.del(key);
|
|
607
|
-
}
|
|
608
|
-
async getStatus(type, identifier) {
|
|
609
|
-
const config = this.limits[type] || this.limits["api:general"];
|
|
610
|
-
const key = this.getKey(type, identifier);
|
|
611
|
-
const now = Date.now();
|
|
612
|
-
const windowStart = now - config.window;
|
|
613
|
-
await this.redis.zremrangebyscore(key, 0, windowStart);
|
|
614
|
-
const count = await this.redis.zcard(key);
|
|
615
|
-
return {
|
|
616
|
-
count,
|
|
617
|
-
limit: config.max,
|
|
618
|
-
remaining: Math.max(0, config.max - count),
|
|
619
|
-
resetAt: now + config.window
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
setLimit(type, config) {
|
|
623
|
-
this.limits[type] = config;
|
|
624
|
-
}
|
|
625
|
-
setUserLimit(type, config) {
|
|
626
|
-
this.userLimits[type] = config;
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
var InMemoryAuthAdapter = class {
|
|
630
|
-
users = /* @__PURE__ */ new Map();
|
|
631
|
-
sessions = /* @__PURE__ */ new Map();
|
|
632
|
-
refreshTokens = /* @__PURE__ */ new Map();
|
|
633
|
-
emailToUserId = /* @__PURE__ */ new Map();
|
|
634
|
-
passwordHistory = /* @__PURE__ */ new Map();
|
|
635
|
-
emailVerificationTokens = /* @__PURE__ */ new Map();
|
|
636
|
-
passwordResetTokens = /* @__PURE__ */ new Map();
|
|
637
|
-
auditLogs = [];
|
|
638
|
-
externalDb = false;
|
|
639
|
-
constructor() {
|
|
640
|
-
}
|
|
641
|
-
async connect() {
|
|
642
|
-
}
|
|
643
|
-
async disconnect() {
|
|
644
|
-
this.users.clear();
|
|
645
|
-
this.sessions.clear();
|
|
646
|
-
this.refreshTokens.clear();
|
|
647
|
-
this.emailToUserId.clear();
|
|
648
|
-
this.passwordHistory.clear();
|
|
649
|
-
}
|
|
650
|
-
async createUser(data) {
|
|
651
|
-
const userId = crypto2.randomBytes(16).toString("hex");
|
|
652
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
653
|
-
const passwordHash = await this.hashPassword(data.password);
|
|
654
|
-
const user = {
|
|
655
|
-
id: userId,
|
|
656
|
-
email: data.email.toLowerCase(),
|
|
657
|
-
passwordHash,
|
|
658
|
-
role: data.role || "customer",
|
|
659
|
-
tenantId: data.tenantId,
|
|
660
|
-
createdAt: now,
|
|
661
|
-
updatedAt: now
|
|
662
|
-
};
|
|
663
|
-
this.users.set(userId, user);
|
|
664
|
-
this.emailToUserId.set(data.email.toLowerCase(), userId);
|
|
665
|
-
this.passwordHistory.set(userId, []);
|
|
666
|
-
return user;
|
|
667
|
-
}
|
|
668
|
-
async findUserByEmail(email) {
|
|
669
|
-
const userId = this.emailToUserId.get(email.toLowerCase());
|
|
670
|
-
if (!userId) return null;
|
|
671
|
-
return this.findUserById(userId);
|
|
672
|
-
}
|
|
673
|
-
async findUserById(userId) {
|
|
674
|
-
return this.users.get(userId) || null;
|
|
675
|
-
}
|
|
676
|
-
async updateUser(userId, data) {
|
|
677
|
-
const existing = await this.findUserById(userId);
|
|
678
|
-
if (!existing) return null;
|
|
679
|
-
const updated = {
|
|
680
|
-
...existing,
|
|
681
|
-
...data,
|
|
682
|
-
id: userId,
|
|
683
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
684
|
-
};
|
|
685
|
-
if (data.email && data.email !== existing.email) {
|
|
686
|
-
this.emailToUserId.delete(existing.email.toLowerCase());
|
|
687
|
-
this.emailToUserId.set(data.email.toLowerCase(), userId);
|
|
688
|
-
}
|
|
689
|
-
this.users.set(userId, updated);
|
|
690
|
-
return updated;
|
|
691
|
-
}
|
|
692
|
-
async deleteUser(userId) {
|
|
693
|
-
const user = await this.findUserById(userId);
|
|
694
|
-
if (!user) return false;
|
|
695
|
-
this.users.delete(userId);
|
|
696
|
-
this.emailToUserId.delete(user.email.toLowerCase());
|
|
697
|
-
this.refreshTokens.forEach((sessionId, refreshToken) => {
|
|
698
|
-
if (this.sessions.get(sessionId)?.userId === userId) {
|
|
699
|
-
this.refreshTokens.delete(refreshToken);
|
|
700
|
-
this.sessions.delete(sessionId);
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
this.passwordHistory.delete(userId);
|
|
704
|
-
this.sessions.forEach((session, sessionId) => {
|
|
705
|
-
if (session.userId === userId) {
|
|
706
|
-
this.sessions.delete(sessionId);
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
return true;
|
|
710
|
-
}
|
|
711
|
-
async hashPassword(password) {
|
|
712
|
-
const bcrypt = (await import('bcryptjs')).default;
|
|
713
|
-
return bcrypt.hash(password, 12);
|
|
714
|
-
}
|
|
715
|
-
async verifyPassword(email, password) {
|
|
716
|
-
const user = await this.findUserByEmail(email);
|
|
717
|
-
if (!user || !user.passwordHash) return null;
|
|
718
|
-
const bcrypt = (await import('bcryptjs')).default;
|
|
719
|
-
const valid = await bcrypt.compare(password, user.passwordHash);
|
|
720
|
-
return valid ? user : null;
|
|
721
|
-
}
|
|
722
|
-
async createSession(userId, data = {}) {
|
|
723
|
-
const sessionId = crypto2.randomBytes(32).toString("hex");
|
|
724
|
-
const token = crypto2.randomBytes(32).toString("base64url");
|
|
725
|
-
const refreshToken = crypto2.randomBytes(32).toString("base64url");
|
|
726
|
-
const now = /* @__PURE__ */ new Date();
|
|
727
|
-
const session = {
|
|
728
|
-
id: sessionId,
|
|
729
|
-
userId,
|
|
730
|
-
token,
|
|
731
|
-
refreshToken,
|
|
732
|
-
expiresAt: new Date(now.getTime() + 86400 * 1e3).toISOString(),
|
|
733
|
-
// 24 hours
|
|
734
|
-
createdAt: now.toISOString(),
|
|
735
|
-
ipAddress: data.ipAddress,
|
|
736
|
-
userAgent: data.userAgent
|
|
737
|
-
};
|
|
738
|
-
this.sessions.set(sessionId, session);
|
|
739
|
-
this.refreshTokens.set(refreshToken, sessionId);
|
|
740
|
-
return session;
|
|
741
|
-
}
|
|
742
|
-
async findSessionByToken(token) {
|
|
743
|
-
return this.sessions.get(token) || null;
|
|
744
|
-
}
|
|
745
|
-
async findSessionByRefreshToken(refreshToken) {
|
|
746
|
-
const sessionId = this.refreshTokens.get(refreshToken);
|
|
747
|
-
if (!sessionId) return null;
|
|
748
|
-
const session = this.sessions.get(sessionId);
|
|
749
|
-
return session || null;
|
|
750
|
-
}
|
|
751
|
-
async deleteSession(sessionId) {
|
|
752
|
-
const session = this.sessions.get(sessionId);
|
|
753
|
-
if (!session) return false;
|
|
754
|
-
if (session.refreshToken) {
|
|
755
|
-
this.refreshTokens.delete(session.refreshToken);
|
|
756
|
-
}
|
|
757
|
-
this.sessions.delete(sessionId);
|
|
758
|
-
return true;
|
|
759
|
-
}
|
|
760
|
-
async deleteUserSessions(userId) {
|
|
761
|
-
let deleted = 0;
|
|
762
|
-
this.sessions.forEach((session, sessionId) => {
|
|
763
|
-
if (session.userId === userId) {
|
|
764
|
-
if (session.refreshToken) {
|
|
765
|
-
this.refreshTokens.delete(session.refreshToken);
|
|
766
|
-
}
|
|
767
|
-
this.sessions.delete(sessionId);
|
|
768
|
-
deleted++;
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
return deleted;
|
|
772
|
-
}
|
|
773
|
-
async addPasswordToHistory(userId, passwordHash) {
|
|
774
|
-
const history = this.passwordHistory.get(userId) || [];
|
|
775
|
-
history.push(passwordHash);
|
|
776
|
-
if (history.length > 5) {
|
|
777
|
-
history.splice(0, history.length - 5);
|
|
778
|
-
}
|
|
779
|
-
this.passwordHistory.set(userId, history);
|
|
780
|
-
}
|
|
781
|
-
async getPasswordHistory(userId, count = 5) {
|
|
782
|
-
return this.passwordHistory.get(userId) || [];
|
|
783
|
-
}
|
|
784
|
-
async isPasswordInHistory(password, userId, historyCount = 5) {
|
|
785
|
-
const history = await this.getPasswordHistory(userId, historyCount);
|
|
786
|
-
const bcrypt = (await import('bcryptjs')).default;
|
|
787
|
-
for (const hash of history) {
|
|
788
|
-
if (await bcrypt.compare(password, hash)) {
|
|
789
|
-
return true;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
return false;
|
|
793
|
-
}
|
|
794
|
-
async createEmailVerificationToken(userId) {
|
|
795
|
-
const token = crypto2.randomBytes(32).toString("hex");
|
|
796
|
-
const expiresAt = new Date(Date.now() + 24 * 60 * 60 * 1e3);
|
|
797
|
-
this.emailVerificationTokens.set(token, { userId, expiresAt });
|
|
798
|
-
return { token, expiresAt };
|
|
799
|
-
}
|
|
800
|
-
async verifyEmailToken(token) {
|
|
801
|
-
const data = this.emailVerificationTokens.get(token);
|
|
802
|
-
if (!data || data.expiresAt < /* @__PURE__ */ new Date()) {
|
|
803
|
-
this.emailVerificationTokens.delete(token);
|
|
804
|
-
return { success: false, error: "Invalid or expired token" };
|
|
805
|
-
}
|
|
806
|
-
this.emailVerificationTokens.delete(token);
|
|
807
|
-
return { success: true, userId: data.userId };
|
|
808
|
-
}
|
|
809
|
-
async createPasswordResetToken(email) {
|
|
810
|
-
const user = await this.findUserByEmail(email);
|
|
811
|
-
if (!user) {
|
|
812
|
-
return { token: "", expiresAt: /* @__PURE__ */ new Date(), error: "User not found" };
|
|
813
|
-
}
|
|
814
|
-
const token = crypto2.randomBytes(32).toString("hex");
|
|
815
|
-
const expiresAt = new Date(Date.now() + 60 * 60 * 1e3);
|
|
816
|
-
this.passwordResetTokens.set(token, { userId: user.id, expiresAt });
|
|
817
|
-
return { token, expiresAt };
|
|
818
|
-
}
|
|
819
|
-
async resetPasswordWithToken(token, newPassword) {
|
|
820
|
-
const data = this.passwordResetTokens.get(token);
|
|
821
|
-
if (!data || data.expiresAt < /* @__PURE__ */ new Date()) {
|
|
822
|
-
this.passwordResetTokens.delete(token);
|
|
823
|
-
return { success: false, error: "Invalid or expired token" };
|
|
824
|
-
}
|
|
825
|
-
const passwordHash = await this.hashPassword(newPassword);
|
|
826
|
-
await this.updateUser(data.userId, { passwordHash });
|
|
827
|
-
this.passwordResetTokens.delete(token);
|
|
828
|
-
return { success: true };
|
|
829
|
-
}
|
|
830
|
-
async hasAnyUsers() {
|
|
831
|
-
return this.users.size > 0;
|
|
832
|
-
}
|
|
833
|
-
async findAuditLogs(filter) {
|
|
834
|
-
const { limit = 50, offset = 0 } = filter;
|
|
835
|
-
let logs = this.auditLogs.slice().reverse();
|
|
836
|
-
if (filter.userId) logs = logs.filter((l) => l.userId === filter.userId);
|
|
837
|
-
if (filter.action) {
|
|
838
|
-
if (Array.isArray(filter.action)) {
|
|
839
|
-
logs = logs.filter((l) => filter.action.includes(String(l.action)));
|
|
840
|
-
} else {
|
|
841
|
-
logs = logs.filter((l) => l.action === filter.action);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
if (filter.resource)
|
|
845
|
-
logs = logs.filter((l) => l.resource === filter.resource);
|
|
846
|
-
if (filter.success !== void 0)
|
|
847
|
-
logs = logs.filter((l) => l.success === filter.success);
|
|
848
|
-
return { logs: logs.slice(offset, offset + limit), total: logs.length };
|
|
849
|
-
}
|
|
850
|
-
async createAuditLog(data) {
|
|
851
|
-
const id = crypto2.randomBytes(16).toString("hex");
|
|
852
|
-
const timestamp = /* @__PURE__ */ new Date();
|
|
853
|
-
const log = { ...data, id, timestamp };
|
|
854
|
-
this.auditLogs.push(log);
|
|
855
|
-
return log;
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
// src/auth/security/in-memory-lockout.ts
|
|
860
|
-
var InMemoryAccountLockout = class {
|
|
861
|
-
storage = /* @__PURE__ */ new Map();
|
|
862
|
-
history = /* @__PURE__ */ new Map();
|
|
863
|
-
// userId -> attempt timestamps
|
|
864
|
-
config;
|
|
865
|
-
constructor(config = {}) {
|
|
866
|
-
this.config = {
|
|
867
|
-
maxAttempts: 5,
|
|
868
|
-
lockDuration: 9e5,
|
|
869
|
-
// 15 minutes
|
|
870
|
-
notifyUser: true,
|
|
871
|
-
notifyAdmin: true,
|
|
872
|
-
adminNotifyAfter: 3,
|
|
873
|
-
...config
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
|
-
async checkLockout(userId) {
|
|
877
|
-
const now = Date.now();
|
|
878
|
-
const record = this.storage.get(userId);
|
|
879
|
-
if (record && record.lockedUntil !== null && record.lockedUntil <= now) {
|
|
880
|
-
await this.resetAttempts(userId);
|
|
881
|
-
return {
|
|
882
|
-
locked: false,
|
|
883
|
-
attemptsRemaining: this.config.maxAttempts,
|
|
884
|
-
totalAttempts: 0
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
if (!record) {
|
|
888
|
-
return {
|
|
889
|
-
locked: false,
|
|
890
|
-
attemptsRemaining: this.config.maxAttempts,
|
|
891
|
-
totalAttempts: 0
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
const { attempts, lockedUntil } = record;
|
|
895
|
-
if (lockedUntil !== null && lockedUntil > now) {
|
|
896
|
-
return {
|
|
897
|
-
locked: true,
|
|
898
|
-
attemptsRemaining: 0,
|
|
899
|
-
lockedUntil: new Date(lockedUntil),
|
|
900
|
-
totalAttempts: attempts
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
return {
|
|
904
|
-
locked: false,
|
|
905
|
-
attemptsRemaining: Math.max(0, this.config.maxAttempts - attempts),
|
|
906
|
-
totalAttempts: attempts
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
async recordFailedAttempt(userId) {
|
|
910
|
-
const now = Date.now();
|
|
911
|
-
const record = this.storage.get(userId) || {
|
|
912
|
-
attempts: 0,
|
|
913
|
-
lastAttempt: null,
|
|
914
|
-
lockedAt: null,
|
|
915
|
-
lockedUntil: null
|
|
916
|
-
};
|
|
917
|
-
record.attempts += 1;
|
|
918
|
-
record.lastAttempt = now;
|
|
919
|
-
let history = this.history.get(userId) || [];
|
|
920
|
-
history.push(now);
|
|
921
|
-
if (history.length > 100) {
|
|
922
|
-
history.splice(0, history.length - 100);
|
|
923
|
-
}
|
|
924
|
-
this.history.set(userId, history);
|
|
925
|
-
this.storage.set(userId, record);
|
|
926
|
-
if (record.attempts >= this.config.maxAttempts) {
|
|
927
|
-
const lockedUntil = new Date(now + this.config.lockDuration);
|
|
928
|
-
record.lockedAt = now;
|
|
929
|
-
record.lockedUntil = lockedUntil.getTime();
|
|
930
|
-
this.storage.set(userId, record);
|
|
931
|
-
return {
|
|
932
|
-
locked: true,
|
|
933
|
-
attemptsRemaining: 0,
|
|
934
|
-
lockedUntil,
|
|
935
|
-
totalAttempts: record.attempts
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
return {
|
|
939
|
-
locked: false,
|
|
940
|
-
attemptsRemaining: Math.max(0, this.config.maxAttempts - record.attempts),
|
|
941
|
-
totalAttempts: record.attempts
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
async lockAccount(userId, duration) {
|
|
945
|
-
const now = Date.now();
|
|
946
|
-
const lockDuration = duration || this.config.lockDuration;
|
|
947
|
-
const lockedUntil = new Date(now + lockDuration);
|
|
948
|
-
const record = this.storage.get(userId) || {
|
|
949
|
-
attempts: 0,
|
|
950
|
-
lastAttempt: null,
|
|
951
|
-
lockedAt: null,
|
|
952
|
-
lockedUntil: null
|
|
953
|
-
};
|
|
954
|
-
record.attempts = this.config.maxAttempts;
|
|
955
|
-
record.lockedAt = now;
|
|
956
|
-
record.lockedUntil = lockedUntil.getTime();
|
|
957
|
-
this.storage.set(userId, record);
|
|
958
|
-
}
|
|
959
|
-
async unlockAccount(userId) {
|
|
960
|
-
await this.resetAttempts(userId);
|
|
961
|
-
}
|
|
962
|
-
async resetAttempts(userId) {
|
|
963
|
-
const record = this.storage.get(userId);
|
|
964
|
-
if (record) {
|
|
965
|
-
record.attempts = 0;
|
|
966
|
-
record.lockedAt = null;
|
|
967
|
-
record.lockedUntil = null;
|
|
968
|
-
this.storage.set(userId, record);
|
|
969
|
-
}
|
|
970
|
-
this.history.delete(userId);
|
|
971
|
-
}
|
|
972
|
-
async getLockoutHistory(userId, limit = 10) {
|
|
973
|
-
const history = this.history.get(userId) || [];
|
|
974
|
-
return history.slice(-limit).reverse().map((timestamp) => new Date(timestamp));
|
|
975
|
-
}
|
|
976
|
-
async getLockoutStats(userId) {
|
|
977
|
-
const history = this.history.get(userId) || [];
|
|
978
|
-
const totalFailedAttempts = history.length;
|
|
979
|
-
const lockoutCount = Math.floor(
|
|
980
|
-
totalFailedAttempts / this.config.maxAttempts
|
|
981
|
-
);
|
|
982
|
-
let lastLockout = null;
|
|
983
|
-
const record = this.storage.get(userId);
|
|
984
|
-
if (record && record.lockedAt !== null) {
|
|
985
|
-
lastLockout = new Date(record.lockedAt);
|
|
986
|
-
}
|
|
987
|
-
const averageAttemptsBeforeLockout = lockoutCount > 0 ? this.config.maxAttempts : 0;
|
|
988
|
-
return {
|
|
989
|
-
totalFailedAttempts,
|
|
990
|
-
lockoutCount,
|
|
991
|
-
lastLockout,
|
|
992
|
-
averageAttemptsBeforeLockout
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
shouldNotifyAdmin(currentAttempts) {
|
|
996
|
-
return this.config.notifyAdmin && currentAttempts >= this.config.adminNotifyAfter;
|
|
997
|
-
}
|
|
998
|
-
getConfig() {
|
|
999
|
-
return { ...this.config };
|
|
1000
|
-
}
|
|
1001
|
-
setConfig(config) {
|
|
1002
|
-
this.config = { ...this.config, ...config };
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
function getEnv(key, fallback = "") {
|
|
1006
|
-
return process.env[key] || fallback;
|
|
1007
|
-
}
|
|
1008
|
-
function getEnvBool(key, fallback = false) {
|
|
1009
|
-
const val = process.env[key];
|
|
1010
|
-
if (!val) return fallback;
|
|
1011
|
-
return val.toLowerCase() === "true";
|
|
1012
|
-
}
|
|
1013
|
-
function getEnvNum(key, fallback = 0) {
|
|
1014
|
-
const val = process.env[key];
|
|
1015
|
-
if (!val) return fallback;
|
|
1016
|
-
return parseInt(val, 10);
|
|
1017
|
-
}
|
|
1018
|
-
function detectDatabaseType() {
|
|
1019
|
-
const envDb = process.env.KYRO_AUTH_DATABASE?.toLowerCase();
|
|
1020
|
-
if (envDb && ["sqlite", "postgres", "mongodb", "memory"].includes(envDb)) {
|
|
1021
|
-
return envDb;
|
|
1022
|
-
}
|
|
1023
|
-
try {
|
|
1024
|
-
const configPath = path.join(process.cwd(), "kyro.config.ts");
|
|
1025
|
-
const configContent = fs.readFileSync(configPath, "utf8");
|
|
1026
|
-
if (configContent.includes("createLocalAdapter")) {
|
|
1027
|
-
return "sqlite";
|
|
1028
|
-
} else if (configContent.includes("createDrizzleAdapter")) {
|
|
1029
|
-
if (configContent.includes("postgres") || configContent.includes("postgresql")) {
|
|
1030
|
-
return "postgres";
|
|
1031
|
-
}
|
|
1032
|
-
return "postgres";
|
|
1033
|
-
} else if (configContent.includes("createMongoDBAdapter")) {
|
|
1034
|
-
return "mongodb";
|
|
1035
|
-
}
|
|
1036
|
-
} catch {
|
|
1037
|
-
}
|
|
1038
|
-
return "memory";
|
|
1039
|
-
}
|
|
1040
|
-
async function createAuthAdapter(databaseType) {
|
|
1041
|
-
const cwd = process.cwd();
|
|
1042
|
-
const rootDir = cwd.endsWith("admin") ? path.join(cwd, "..") : cwd;
|
|
1043
|
-
const defaultAuthDbPath = path.resolve(rootDir, "data", "auth.db");
|
|
1044
|
-
switch (databaseType) {
|
|
1045
|
-
case "sqlite":
|
|
1046
|
-
return new chunkIDVRRRAK_cjs.SQLiteAuthAdapter({
|
|
1047
|
-
path: getEnv("KYRO_AUTH_DB_PATH", defaultAuthDbPath)
|
|
1048
|
-
});
|
|
1049
|
-
case "postgres": {
|
|
1050
|
-
try {
|
|
1051
|
-
const databaseUrl = getEnv("DATABASE_URL", "");
|
|
1052
|
-
if (databaseUrl) {
|
|
1053
|
-
const { drizzle } = await import('drizzle-orm/postgres-js');
|
|
1054
|
-
const postgres = await import('postgres');
|
|
1055
|
-
const sql = postgres.default(databaseUrl, { onnotice: () => {
|
|
1056
|
-
} });
|
|
1057
|
-
const drizzleDb = drizzle(sql);
|
|
1058
|
-
return new chunk7OS7TX2Q_cjs.PostgresAuthAdapter({ db: drizzleDb });
|
|
1059
|
-
}
|
|
1060
|
-
} catch (e) {
|
|
1061
|
-
console.warn("[Auth] Could not create PostgresAuthAdapter, falling back to SQLite auth adapter.");
|
|
1062
|
-
}
|
|
1063
|
-
return new chunkIDVRRRAK_cjs.SQLiteAuthAdapter({
|
|
1064
|
-
path: getEnv("KYRO_AUTH_DB_PATH", defaultAuthDbPath)
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
case "mongodb": {
|
|
1068
|
-
try {
|
|
1069
|
-
const mongoUri = getEnv("MONGODB_URI", "");
|
|
1070
|
-
if (mongoUri) {
|
|
1071
|
-
const { MongoClient } = await import('mongodb');
|
|
1072
|
-
const client = new MongoClient(mongoUri);
|
|
1073
|
-
await client.connect();
|
|
1074
|
-
const url = new URL(mongoUri);
|
|
1075
|
-
const dbName = url.pathname.replace(/^\//, "") || "kyro_cms";
|
|
1076
|
-
const mongoDb = client.db(dbName);
|
|
1077
|
-
return new chunkGXFOGU7N_cjs.MongoDBAuthAdapter({ db: mongoDb });
|
|
1078
|
-
}
|
|
1079
|
-
} catch (e) {
|
|
1080
|
-
console.warn("[Auth] Could not create MongoDBAuthAdapter, falling back to SQLite auth adapter.");
|
|
1081
|
-
}
|
|
1082
|
-
return new chunkIDVRRRAK_cjs.SQLiteAuthAdapter({
|
|
1083
|
-
path: getEnv("KYRO_AUTH_DB_PATH", defaultAuthDbPath)
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
case "memory":
|
|
1087
|
-
default:
|
|
1088
|
-
return new InMemoryAuthAdapter();
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
async function createAuthConfig(databaseType, db) {
|
|
1092
|
-
const distributed = getEnvBool("KYRO_DISTRIBUTED", false);
|
|
1093
|
-
let authAdapter;
|
|
1094
|
-
if (distributed) {
|
|
1095
|
-
const { RedisAuthAdapter: RedisAuthAdapter2 } = await import('./redis-adapter-UQX4EE3B.cjs');
|
|
1096
|
-
const redisUrl = getEnv("REDIS_URL", "redis://localhost:6379");
|
|
1097
|
-
const redisTls = getEnvBool("REDIS_TLS", false);
|
|
1098
|
-
const redisAdapter = new RedisAuthAdapter2({ url: redisUrl, tls: redisTls });
|
|
1099
|
-
await redisAdapter.connect?.();
|
|
1100
|
-
authAdapter = redisAdapter;
|
|
1101
|
-
} else {
|
|
1102
|
-
const initialDbType = databaseType || detectDatabaseType();
|
|
1103
|
-
authAdapter = await createAuthAdapter(initialDbType);
|
|
1104
|
-
if (authAdapter.connect) {
|
|
1105
|
-
await authAdapter.connect();
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
const email = db ? await chunkVKREAIBA_cjs.EmailTransport.fromConfig(db).catch(() => null) || chunkVKREAIBA_cjs.EmailTransport.fromEnv() || void 0 : chunkVKREAIBA_cjs.EmailTransport.fromEnv() || void 0;
|
|
1109
|
-
const passwordPolicy = new chunkVKREAIBA_cjs.PasswordPolicy({
|
|
1110
|
-
minLength: getEnvNum("PASSWORD_MIN_LENGTH", 12),
|
|
1111
|
-
requireUppercase: getEnvBool("PASSWORD_REQUIRE_UPPERCASE", true),
|
|
1112
|
-
requireLowercase: getEnvBool("PASSWORD_REQUIRE_LOWERCASE", true),
|
|
1113
|
-
requireNumbers: getEnvBool("PASSWORD_REQUIRE_NUMBERS", true),
|
|
1114
|
-
requireSpecialChars: getEnvBool("PASSWORD_REQUIRE_SPECIAL", true),
|
|
1115
|
-
preventReuse: getEnvNum("PASSWORD_PREVENT_REUSE", 5),
|
|
1116
|
-
maxLength: getEnvNum("PASSWORD_MAX_LENGTH", 128)
|
|
1117
|
-
});
|
|
1118
|
-
let lockout;
|
|
1119
|
-
let rateLimiter;
|
|
1120
|
-
let auditLogger;
|
|
1121
|
-
if (distributed) {
|
|
1122
|
-
const redis = authAdapter;
|
|
1123
|
-
const redisClient = redis.redis;
|
|
1124
|
-
lockout = new AccountLockout(redisClient, {
|
|
1125
|
-
maxAttempts: getEnvNum("LOCKOUT_MAX_ATTEMPTS", 5),
|
|
1126
|
-
lockDuration: getEnvNum("LOCKOUT_DURATION_MINUTES", 15) * 60 * 1e3
|
|
1127
|
-
});
|
|
1128
|
-
rateLimiter = new RateLimiter(redisClient, {
|
|
1129
|
-
"auth:login": {
|
|
1130
|
-
window: getEnvNum("RATE_LIMIT_AUTH_WINDOW_MS", 9e5),
|
|
1131
|
-
max: getEnvNum("RATE_LIMIT_AUTH_MAX_REQUESTS", 10)
|
|
1132
|
-
},
|
|
1133
|
-
"api:general": {
|
|
1134
|
-
window: getEnvNum("RATE_LIMIT_WINDOW_MS", 6e4),
|
|
1135
|
-
max: getEnvNum("RATE_LIMIT_MAX_REQUESTS", 100)
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
auditLogger = new chunkB6X3LN25_cjs.AuditLogger(
|
|
1139
|
-
redisClient,
|
|
1140
|
-
getEnvNum("AUDIT_LOG_RETENTION_DAYS", 30)
|
|
1141
|
-
);
|
|
1142
|
-
} else {
|
|
1143
|
-
lockout = new InMemoryAccountLockout({
|
|
1144
|
-
maxAttempts: getEnvNum("LOCKOUT_MAX_ATTEMPTS", 5),
|
|
1145
|
-
lockDuration: getEnvNum("LOCKOUT_DURATION_MINUTES", 15) * 60 * 1e3
|
|
1146
|
-
});
|
|
1147
|
-
rateLimiter = new chunkB6X3LN25_cjs.InMemoryRateLimiter({
|
|
1148
|
-
"auth:login": {
|
|
1149
|
-
window: getEnvNum("RATE_LIMIT_AUTH_WINDOW_MS", 9e5),
|
|
1150
|
-
max: getEnvNum("RATE_LIMIT_AUTH_MAX_REQUESTS", 10)
|
|
1151
|
-
},
|
|
1152
|
-
"api:general": {
|
|
1153
|
-
window: getEnvNum("RATE_LIMIT_WINDOW_MS", 6e4),
|
|
1154
|
-
max: getEnvNum("RATE_LIMIT_MAX_REQUESTS", 100)
|
|
1155
|
-
}
|
|
1156
|
-
});
|
|
1157
|
-
auditLogger = getEnvBool("AUDIT_LOG_ENABLED", true) ? new chunkB6X3LN25_cjs.InMemoryAuditLogger(getEnvNum("AUDIT_LOG_RETENTION_DAYS", 30)) : void 0;
|
|
1158
|
-
}
|
|
1159
|
-
const routes = new chunkB6X3LN25_cjs.AuthRoutes({
|
|
1160
|
-
redis: authAdapter,
|
|
1161
|
-
email,
|
|
1162
|
-
jwtSecret: getEnv("APP_SECRET", "change-me"),
|
|
1163
|
-
jwtExpiresIn: getEnv("JWT_EXPIRES_IN", "24h"),
|
|
1164
|
-
jwtIssuer: getEnv("JWT_ISSUER", "kyro-cms"),
|
|
1165
|
-
jwtAudience: getEnv("JWT_AUDIENCE", "kyro-cms-client"),
|
|
1166
|
-
passwordPolicy,
|
|
1167
|
-
lockout,
|
|
1168
|
-
rateLimiter,
|
|
1169
|
-
auditLogger,
|
|
1170
|
-
baseUrl: getEnv("EMAIL_BASE_URL", "http://localhost:4321"),
|
|
1171
|
-
emailVerificationRequired: getEnvBool("EMAIL_VERIFICATION_REQUIRED", true)
|
|
1172
|
-
});
|
|
1173
|
-
const actualDbType = distributed ? "distributed" : databaseType || detectDatabaseType();
|
|
1174
|
-
return {
|
|
1175
|
-
authAdapter,
|
|
1176
|
-
databaseType: actualDbType,
|
|
1177
|
-
email,
|
|
1178
|
-
passwordPolicy,
|
|
1179
|
-
lockout,
|
|
1180
|
-
rateLimiter,
|
|
1181
|
-
auditLogger,
|
|
1182
|
-
routes
|
|
1183
|
-
};
|
|
1184
|
-
}
|
|
1185
|
-
var authConfig = createAuthConfig().catch((err) => {
|
|
1186
|
-
console.warn("[AuthConfig] Failed to initialize auth config:", err.message);
|
|
1187
|
-
return null;
|
|
1188
|
-
});
|
|
1189
|
-
|
|
1190
|
-
// src/auth/index.ts
|
|
1191
|
-
var DEFAULT_SALT_ROUNDS = 12;
|
|
1192
|
-
var DEFAULT_EXPIRES_IN = "24h";
|
|
1193
|
-
var DEFAULT_REFRESH_EXPIRES_IN = "7d";
|
|
1194
|
-
var Auth = class {
|
|
1195
|
-
adapter;
|
|
1196
|
-
config;
|
|
1197
|
-
constructor(adapter, config) {
|
|
1198
|
-
this.adapter = adapter;
|
|
1199
|
-
this.config = {
|
|
1200
|
-
secret: config.secret,
|
|
1201
|
-
expiresIn: config.expiresIn ?? DEFAULT_EXPIRES_IN,
|
|
1202
|
-
refreshExpiresIn: config.refreshExpiresIn ?? DEFAULT_REFRESH_EXPIRES_IN,
|
|
1203
|
-
issuer: config.issuer ?? "kyro-cms",
|
|
1204
|
-
audience: config.audience ?? [],
|
|
1205
|
-
saltRounds: config.saltRounds ?? DEFAULT_SALT_ROUNDS
|
|
1206
|
-
};
|
|
1207
|
-
}
|
|
1208
|
-
async register(data) {
|
|
1209
|
-
try {
|
|
1210
|
-
const existing = await this.adapter.findUserByEmail(data.email);
|
|
1211
|
-
if (existing) {
|
|
1212
|
-
return { success: false, error: "Email already registered" };
|
|
1213
|
-
}
|
|
1214
|
-
const user = await this.adapter.createUser({
|
|
1215
|
-
email: data.email,
|
|
1216
|
-
password: data.password,
|
|
1217
|
-
role: data.role ?? "customer",
|
|
1218
|
-
tenantId: data.tenantId
|
|
1219
|
-
});
|
|
1220
|
-
return this.createSessionForUser(user);
|
|
1221
|
-
} catch (error) {
|
|
1222
|
-
return { success: false, error: String(error) };
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
async login(credentials) {
|
|
1226
|
-
try {
|
|
1227
|
-
const user = await this.adapter.verifyPassword(
|
|
1228
|
-
credentials.email,
|
|
1229
|
-
credentials.password
|
|
1230
|
-
);
|
|
1231
|
-
if (!user) {
|
|
1232
|
-
return { success: false, error: "Invalid credentials" };
|
|
1233
|
-
}
|
|
1234
|
-
return this.createSessionForUser(user);
|
|
1235
|
-
} catch (error) {
|
|
1236
|
-
return { success: false, error: String(error) };
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
async logout(token) {
|
|
1240
|
-
await this.adapter.deleteSession(token);
|
|
1241
|
-
}
|
|
1242
|
-
async refreshToken(refreshToken) {
|
|
1243
|
-
try {
|
|
1244
|
-
const session = await this.adapter.findSessionByToken(refreshToken);
|
|
1245
|
-
if (!session || new Date(session.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
1246
|
-
return { success: false, error: "Invalid or expired refresh token" };
|
|
1247
|
-
}
|
|
1248
|
-
const user = await this.adapter.findUserById(session.userId);
|
|
1249
|
-
if (!user) {
|
|
1250
|
-
return { success: false, error: "User not found" };
|
|
1251
|
-
}
|
|
1252
|
-
await this.adapter.deleteSession(refreshToken);
|
|
1253
|
-
return this.createSessionForUser(user);
|
|
1254
|
-
} catch (error) {
|
|
1255
|
-
return { success: false, error: String(error) };
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
async verifyToken(token) {
|
|
1259
|
-
try {
|
|
1260
|
-
const { default: jwtModule } = await import('jsonwebtoken');
|
|
1261
|
-
const decoded = jwtModule.verify(token, this.config.secret, {
|
|
1262
|
-
issuer: this.config.issuer,
|
|
1263
|
-
audience: this.config.audience.length > 0 ? this.config.audience[0] : void 0
|
|
1264
|
-
});
|
|
1265
|
-
return decoded;
|
|
1266
|
-
} catch {
|
|
1267
|
-
return null;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
async getUserFromToken(token) {
|
|
1271
|
-
const payload = await this.verifyToken(token);
|
|
1272
|
-
if (!payload) return null;
|
|
1273
|
-
return this.adapter.findUserById(payload.sub);
|
|
1274
|
-
}
|
|
1275
|
-
async changePassword(userId, currentPassword, newPassword) {
|
|
1276
|
-
try {
|
|
1277
|
-
const user = await this.adapter.findUserById(userId);
|
|
1278
|
-
if (!user) {
|
|
1279
|
-
return { success: false, error: "User not found" };
|
|
1280
|
-
}
|
|
1281
|
-
const valid = await this.adapter.verifyPassword(
|
|
1282
|
-
user.email,
|
|
1283
|
-
currentPassword
|
|
1284
|
-
);
|
|
1285
|
-
if (!valid) {
|
|
1286
|
-
return { success: false, error: "Current password is incorrect" };
|
|
1287
|
-
}
|
|
1288
|
-
await this.adapter.updateUser(userId, { password: newPassword });
|
|
1289
|
-
await this.adapter.deleteUserSessions(userId);
|
|
1290
|
-
return { success: true, user };
|
|
1291
|
-
} catch (error) {
|
|
1292
|
-
return { success: false, error: String(error) };
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
async resetPassword(email, newPassword) {
|
|
1296
|
-
try {
|
|
1297
|
-
const user = await this.adapter.findUserByEmail(email);
|
|
1298
|
-
if (!user) {
|
|
1299
|
-
return { success: false, error: "User not found" };
|
|
1300
|
-
}
|
|
1301
|
-
await this.adapter.updateUser(user.id, { password: newPassword });
|
|
1302
|
-
await this.adapter.deleteUserSessions(user.id);
|
|
1303
|
-
return { success: true, user };
|
|
1304
|
-
} catch (error) {
|
|
1305
|
-
return { success: false, error: String(error) };
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
async sendEmailVerification(userId) {
|
|
1309
|
-
try {
|
|
1310
|
-
const { token, expiresAt } = await this.adapter.createEmailVerificationToken(userId);
|
|
1311
|
-
return { success: true };
|
|
1312
|
-
} catch (error) {
|
|
1313
|
-
return { success: false, error: String(error) };
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
async verifyEmail(token) {
|
|
1317
|
-
try {
|
|
1318
|
-
return await this.adapter.verifyEmailToken(token);
|
|
1319
|
-
} catch (error) {
|
|
1320
|
-
return { success: false, error: String(error) };
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
async requestPasswordReset(email) {
|
|
1324
|
-
try {
|
|
1325
|
-
const result = await this.adapter.createPasswordResetToken(email);
|
|
1326
|
-
if (result.error) {
|
|
1327
|
-
return { success: false, error: result.error };
|
|
1328
|
-
}
|
|
1329
|
-
return { success: true };
|
|
1330
|
-
} catch (error) {
|
|
1331
|
-
return { success: false, error: String(error) };
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
async resetPasswordWithToken(token, newPassword) {
|
|
1335
|
-
try {
|
|
1336
|
-
return await this.adapter.resetPasswordWithToken(token, newPassword);
|
|
1337
|
-
} catch (error) {
|
|
1338
|
-
return { success: false, error: String(error) };
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
async deleteAccount(userId) {
|
|
1342
|
-
try {
|
|
1343
|
-
const user = await this.adapter.findUserById(userId);
|
|
1344
|
-
if (!user) {
|
|
1345
|
-
return { success: false, error: "User not found" };
|
|
1346
|
-
}
|
|
1347
|
-
await this.adapter.deleteUserSessions(userId);
|
|
1348
|
-
await this.adapter.deleteUser(userId);
|
|
1349
|
-
return { success: true };
|
|
1350
|
-
} catch (error) {
|
|
1351
|
-
return { success: false, error: String(error) };
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
async createSessionForUser(user) {
|
|
1355
|
-
const token = await this.generateToken(user);
|
|
1356
|
-
const session = await this.adapter.createSession(user.id);
|
|
1357
|
-
return {
|
|
1358
|
-
success: true,
|
|
1359
|
-
user,
|
|
1360
|
-
session,
|
|
1361
|
-
token
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
async generateToken(user) {
|
|
1365
|
-
const { default: jwtModule } = await import('jsonwebtoken');
|
|
1366
|
-
const payload = {
|
|
1367
|
-
sub: user.id,
|
|
1368
|
-
email: user.email,
|
|
1369
|
-
role: user.role,
|
|
1370
|
-
tenantId: user.tenantId
|
|
1371
|
-
};
|
|
1372
|
-
const signOptions = {
|
|
1373
|
-
expiresIn: this.parseExpiresIn(this.config.expiresIn) / 1e3,
|
|
1374
|
-
issuer: this.config.issuer
|
|
1375
|
-
};
|
|
1376
|
-
if (this.config.audience.length > 0) {
|
|
1377
|
-
signOptions.audience = this.config.audience[0];
|
|
1378
|
-
}
|
|
1379
|
-
return jwtModule.sign(payload, this.config.secret, signOptions);
|
|
1380
|
-
}
|
|
1381
|
-
async hashPassword(password) {
|
|
1382
|
-
const { default: bcrypt } = await import('bcryptjs');
|
|
1383
|
-
return bcrypt.hash(password, this.config.saltRounds);
|
|
1384
|
-
}
|
|
1385
|
-
parseExpiresIn(value) {
|
|
1386
|
-
if (typeof value === "number") return value;
|
|
1387
|
-
const match = value.match(/^(\d+)([smhd])$/);
|
|
1388
|
-
if (!match) return 864e5;
|
|
1389
|
-
const num = parseInt(match[1], 10);
|
|
1390
|
-
switch (match[2]) {
|
|
1391
|
-
case "s":
|
|
1392
|
-
return num * 1e3;
|
|
1393
|
-
case "m":
|
|
1394
|
-
return num * 6e4;
|
|
1395
|
-
case "h":
|
|
1396
|
-
return num * 36e5;
|
|
1397
|
-
case "d":
|
|
1398
|
-
return num * 864e5;
|
|
1399
|
-
default:
|
|
1400
|
-
return 864e5;
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
};
|
|
1404
|
-
function createAuth(adapter, config) {
|
|
1405
|
-
return new Auth(adapter, config);
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
// src/versions/types.ts
|
|
1409
|
-
function getDefaultDraftPublishConfig() {
|
|
1410
|
-
return {
|
|
1411
|
-
enabled: true,
|
|
1412
|
-
draftsEnabled: true,
|
|
1413
|
-
publishEnabled: true,
|
|
1414
|
-
scheduleEnabled: false,
|
|
1415
|
-
versioningEnabled: true,
|
|
1416
|
-
maxVersionsPerDocument: 50,
|
|
1417
|
-
autoPublish: false,
|
|
1418
|
-
requirePublishPermission: true
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// src/versions/index.ts
|
|
1423
|
-
var VersionManager = class {
|
|
1424
|
-
adapter;
|
|
1425
|
-
config;
|
|
1426
|
-
constructor(adapter, config) {
|
|
1427
|
-
this.adapter = adapter;
|
|
1428
|
-
this.config = { ...getDefaultDraftPublishConfig(), ...config };
|
|
1429
|
-
}
|
|
1430
|
-
async createVersion(options) {
|
|
1431
|
-
const latestVersion = await this.adapter.getLatestVersion(options.collection, options.documentId);
|
|
1432
|
-
const nextVersion = (latestVersion?.version ?? 0) + 1;
|
|
1433
|
-
const versionOptions = {
|
|
1434
|
-
...options,
|
|
1435
|
-
version: nextVersion
|
|
1436
|
-
};
|
|
1437
|
-
const version = await this.adapter.createVersion(versionOptions);
|
|
1438
|
-
if (this.config.maxVersionsPerDocument > 0) {
|
|
1439
|
-
await this.pruneOldVersions(options.collection, options.documentId);
|
|
1440
|
-
}
|
|
1441
|
-
return version;
|
|
1442
|
-
}
|
|
1443
|
-
async publishVersion(options) {
|
|
1444
|
-
const version = await this.adapter.getVersion(options.collection, options.versionId);
|
|
1445
|
-
if (!version) {
|
|
1446
|
-
throw new Error("Version not found");
|
|
1447
|
-
}
|
|
1448
|
-
if (version.status === "published") {
|
|
1449
|
-
throw new Error("Version is already published");
|
|
1450
|
-
}
|
|
1451
|
-
await this.adapter.publishVersion(options);
|
|
1452
|
-
}
|
|
1453
|
-
async unpublishDocument(collection, documentId) {
|
|
1454
|
-
const versions = await this.adapter.getVersions({
|
|
1455
|
-
collection,
|
|
1456
|
-
documentId,
|
|
1457
|
-
limit: 1e3
|
|
1458
|
-
});
|
|
1459
|
-
for (const version of versions) {
|
|
1460
|
-
if (version.status === "published") {
|
|
1461
|
-
await this.createVersion({
|
|
1462
|
-
collection,
|
|
1463
|
-
documentId,
|
|
1464
|
-
data: version.data,
|
|
1465
|
-
status: "draft",
|
|
1466
|
-
createdBy: "system",
|
|
1467
|
-
changeDescription: "Unpublished document"
|
|
1468
|
-
});
|
|
1469
|
-
break;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
async revertToVersion(collection, documentId, versionId, userId) {
|
|
1474
|
-
const targetVersion = await this.adapter.getVersion(collection, versionId);
|
|
1475
|
-
if (!targetVersion) {
|
|
1476
|
-
throw new Error("Version not found");
|
|
1477
|
-
}
|
|
1478
|
-
const newVersion = await this.adapter.revertToVersion({
|
|
1479
|
-
collection,
|
|
1480
|
-
documentId,
|
|
1481
|
-
versionId,
|
|
1482
|
-
userId
|
|
1483
|
-
});
|
|
1484
|
-
return newVersion;
|
|
1485
|
-
}
|
|
1486
|
-
async getVersionHistory(collection, documentId, limit = 20, offset = 0) {
|
|
1487
|
-
return this.adapter.getVersions({
|
|
1488
|
-
collection,
|
|
1489
|
-
documentId,
|
|
1490
|
-
limit,
|
|
1491
|
-
offset
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
async compareTwoVersions(collection, documentId, versionA, versionB) {
|
|
1495
|
-
return this.adapter.compareVersions({
|
|
1496
|
-
collection,
|
|
1497
|
-
documentId,
|
|
1498
|
-
versionA,
|
|
1499
|
-
versionB
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
async getLatestDraft(collection, documentId) {
|
|
1503
|
-
return this.adapter.getLatestVersion(collection, documentId);
|
|
1504
|
-
}
|
|
1505
|
-
async getPublishedVersion(collection, documentId) {
|
|
1506
|
-
return this.adapter.getPublishedVersion(collection, documentId);
|
|
1507
|
-
}
|
|
1508
|
-
async getVersion(collection, versionId) {
|
|
1509
|
-
return this.adapter.getVersion(collection, versionId);
|
|
1510
|
-
}
|
|
1511
|
-
async schedulePublish(collection, documentId, versionId, scheduledFor) {
|
|
1512
|
-
if (!this.config.scheduleEnabled) {
|
|
1513
|
-
throw new Error("Scheduled publishing is not enabled");
|
|
1514
|
-
}
|
|
1515
|
-
const version = await this.adapter.getVersion(collection, versionId);
|
|
1516
|
-
if (!version) {
|
|
1517
|
-
throw new Error("Version not found");
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
async deleteVersionHistory(collection, documentId) {
|
|
1521
|
-
await this.adapter.deleteVersions(collection, documentId);
|
|
1522
|
-
}
|
|
1523
|
-
async pruneOldVersions(collection, documentId) {
|
|
1524
|
-
const versions = await this.adapter.getVersions({
|
|
1525
|
-
collection,
|
|
1526
|
-
documentId,
|
|
1527
|
-
limit: this.config.maxVersionsPerDocument + 100
|
|
1528
|
-
});
|
|
1529
|
-
if (versions.length <= this.config.maxVersionsPerDocument) {
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
versions.slice(0, this.config.maxVersionsPerDocument);
|
|
1533
|
-
const versionsToDelete = versions.slice(this.config.maxVersionsPerDocument);
|
|
1534
|
-
for (const version of versionsToDelete) {
|
|
1535
|
-
if (version.status !== "published") {
|
|
1536
|
-
await this.adapter.deleteVersions(collection, documentId);
|
|
1537
|
-
break;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
};
|
|
1542
|
-
function createVersionManager(adapter, config) {
|
|
1543
|
-
return new VersionManager(adapter, config);
|
|
1544
|
-
}
|
|
1545
|
-
function isPublished(status) {
|
|
1546
|
-
return status === "published";
|
|
1547
|
-
}
|
|
1548
|
-
function isDraft(status) {
|
|
1549
|
-
return status === "draft";
|
|
1550
|
-
}
|
|
1551
|
-
function isArchived(status) {
|
|
1552
|
-
return status === "archived";
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
// src/registry/config.ts
|
|
1556
|
-
function normalizeCollections(collections) {
|
|
1557
|
-
if (!collections) return [];
|
|
1558
|
-
if (Array.isArray(collections)) return collections;
|
|
1559
|
-
return Object.values(collections);
|
|
1560
|
-
}
|
|
1561
|
-
function normalizeGlobals(globals) {
|
|
1562
|
-
if (!globals) return [];
|
|
1563
|
-
if (Array.isArray(globals)) return globals;
|
|
1564
|
-
return Object.values(globals);
|
|
1565
|
-
}
|
|
1566
|
-
function defineConfig(config) {
|
|
1567
|
-
return {
|
|
1568
|
-
collections: normalizeCollections(config.collections),
|
|
1569
|
-
globals: normalizeGlobals(config.globals),
|
|
1570
|
-
adapter: config.adapter,
|
|
1571
|
-
plugins: config.plugins,
|
|
1572
|
-
auth: config.auth,
|
|
1573
|
-
cors: config.cors,
|
|
1574
|
-
admin: config.admin,
|
|
1575
|
-
upload: config.upload,
|
|
1576
|
-
graphQL: config.graphQL,
|
|
1577
|
-
typescript: config.typescript,
|
|
1578
|
-
localization: config.localization,
|
|
1579
|
-
rateLimit: config.rateLimit,
|
|
1580
|
-
debug: config.debug
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
var defineKyroConfig = defineConfig;
|
|
1584
|
-
|
|
1585
|
-
// src/lib/seo.ts
|
|
1586
|
-
function generateSeoTags(options) {
|
|
1587
|
-
const { siteSettings, seoSettings, title, description, image, url } = options;
|
|
1588
|
-
if (!siteSettings) return "";
|
|
1589
|
-
const siteName = siteSettings.siteName || "";
|
|
1590
|
-
const rawTitle = title || seoSettings?.defaultTitle || siteName;
|
|
1591
|
-
const titleTemplate = seoSettings?.titleTemplate;
|
|
1592
|
-
const separator = seoSettings?.separator || " | ";
|
|
1593
|
-
const siteNameInTitle = seoSettings?.siteNameInTitle !== false;
|
|
1594
|
-
const finalTitle = titleTemplate ? titleTemplate.replace(/\{\{title\}\}/g, rawTitle).replace(/\{\{siteName\}\}/g, siteNameInTitle ? siteName : "").replace(/\{\{separator\}\}/g, separator).replace(/\s+/g, " ").trim() : rawTitle;
|
|
1595
|
-
const finalDesc = description || seoSettings?.defaultDescription || siteSettings.siteDescription || "";
|
|
1596
|
-
const finalImage = image || siteSettings.siteOgImage?.url || "";
|
|
1597
|
-
const finalUrl = url || siteSettings.siteUrl || "";
|
|
1598
|
-
let tags = `
|
|
1599
|
-
<title>${finalTitle}</title>
|
|
1600
|
-
<meta name="description" content="${finalDesc}">
|
|
1601
|
-
`;
|
|
1602
|
-
if (siteSettings.siteFavicon?.url) {
|
|
1603
|
-
tags += `
|
|
1604
|
-
<link rel="icon" type="${siteSettings.siteFavicon.mimeType || "image/x-icon"}" href="${siteSettings.siteFavicon.url}">`;
|
|
1605
|
-
}
|
|
1606
|
-
const robots = seoSettings?.meta?.robots;
|
|
1607
|
-
if (robots) {
|
|
1608
|
-
tags += `
|
|
1609
|
-
<meta name="robots" content="${robots}">`;
|
|
1610
|
-
}
|
|
1611
|
-
const canonical = seoSettings?.meta?.canonicalUrl || finalUrl;
|
|
1612
|
-
if (canonical) {
|
|
1613
|
-
tags += `
|
|
1614
|
-
<link rel="canonical" href="${canonical}">`;
|
|
1615
|
-
}
|
|
1616
|
-
const ogType = seoSettings?.meta?.ogType || "website";
|
|
1617
|
-
tags += `
|
|
1618
|
-
<meta property="og:type" content="${ogType}">
|
|
1619
|
-
<meta property="og:title" content="${finalTitle}">
|
|
1620
|
-
<meta property="og:description" content="${finalDesc}">
|
|
1621
|
-
<meta property="og:site_name" content="${siteName}">
|
|
1622
|
-
`;
|
|
1623
|
-
if (finalUrl) tags += `
|
|
1624
|
-
<meta property="og:url" content="${finalUrl}">`;
|
|
1625
|
-
if (finalImage) tags += `
|
|
1626
|
-
<meta property="og:image" content="${finalImage}">`;
|
|
1627
|
-
if (seoSettings?.social?.fbAppId) {
|
|
1628
|
-
tags += `
|
|
1629
|
-
<meta property="fb:app_id" content="${seoSettings.social.fbAppId}">`;
|
|
1630
|
-
}
|
|
1631
|
-
const twitterCard = seoSettings?.social?.twitterCardType || "summary_large_image";
|
|
1632
|
-
tags += `
|
|
1633
|
-
<meta name="twitter:card" content="${twitterCard}">
|
|
1634
|
-
<meta name="twitter:title" content="${finalTitle}">
|
|
1635
|
-
<meta name="twitter:description" content="${finalDesc}">
|
|
1636
|
-
`;
|
|
1637
|
-
if (seoSettings?.social?.twitterHandle) {
|
|
1638
|
-
tags += `
|
|
1639
|
-
<meta name="twitter:site" content="${seoSettings.social.twitterHandle}">`;
|
|
1640
|
-
}
|
|
1641
|
-
if (finalImage) tags += `
|
|
1642
|
-
<meta name="twitter:image" content="${finalImage}">`;
|
|
1643
|
-
if (siteSettings.enableI18n && siteSettings.i18n?.language) {
|
|
1644
|
-
tags += `
|
|
1645
|
-
<meta http-equiv="content-language" content="${siteSettings.i18n.language}">`;
|
|
1646
|
-
}
|
|
1647
|
-
return tags;
|
|
1648
|
-
}
|
|
1649
|
-
function generateAnalyticsTags(siteSettings) {
|
|
1650
|
-
if (!siteSettings || !siteSettings.analyticsEnabled || !siteSettings.analytics) {
|
|
1651
|
-
return "";
|
|
1652
|
-
}
|
|
1653
|
-
const { googleAnalyticsId, googleTagManagerId, plausibleDomain } = siteSettings.analytics;
|
|
1654
|
-
let scripts = "";
|
|
1655
|
-
if (googleAnalyticsId) {
|
|
1656
|
-
scripts += `
|
|
1
|
+
'use strict';var chunkEQUQJBPP_cjs=require('./chunk-EQUQJBPP.cjs'),chunkELICKLFM_cjs=require('./chunk-ELICKLFM.cjs'),chunkL6CZYN3L_cjs=require('./chunk-L6CZYN3L.cjs'),chunkR7DVVXXI_cjs=require('./chunk-R7DVVXXI.cjs'),chunkUJNSOOYZ_cjs=require('./chunk-UJNSOOYZ.cjs');require('./chunk-65G73T7Z.cjs');var chunk2BTRHVT3_cjs=require('./chunk-2BTRHVT3.cjs'),chunkQ4CSLXCO_cjs=require('./chunk-Q4CSLXCO.cjs'),chunkCVVW4LXZ_cjs=require('./chunk-CVVW4LXZ.cjs'),chunkF7P36SLX_cjs=require('./chunk-F7P36SLX.cjs'),chunkKIW36TG7_cjs=require('./chunk-KIW36TG7.cjs'),chunkAJAZ7D3W_cjs=require('./chunk-AJAZ7D3W.cjs');require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GFU7AOI3.cjs');var chunkET6NN2V2_cjs=require('./chunk-ET6NN2V2.cjs');require('./chunk-HVXO3OFB.cjs');var chunkISWMETHJ_cjs=require('./chunk-ISWMETHJ.cjs'),chunkNY47CFVP_cjs=require('./chunk-NY47CFVP.cjs'),chunkF7SR5IDT_cjs=require('./chunk-F7SR5IDT.cjs');require('./chunk-4ORJMSJU.cjs');var chunkIFJJ44OQ_cjs=require('./chunk-IFJJ44OQ.cjs'),chunkGYQMNXXW_cjs=require('./chunk-GYQMNXXW.cjs');require('./chunk-MIOMMB23.cjs'),require('./chunk-UBHFUFD4.cjs');var chunkUDSJGML2_cjs=require('./chunk-UDSJGML2.cjs'),chunkATLSIYRH_cjs=require('./chunk-ATLSIYRH.cjs'),chunkDV4LFLPL_cjs=require('./chunk-DV4LFLPL.cjs');require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-OQD3WG6Z.cjs');var q=require('crypto'),fs=require('fs'),Me=require('path'),zod=require('zod'),unstorage=require('unstorage'),$r=require('unstorage/drivers/indexedb'),zr=require('unstorage/drivers/fs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var q__default=/*#__PURE__*/_interopDefault(q);var Me__default=/*#__PURE__*/_interopDefault(Me);var $r__default=/*#__PURE__*/_interopDefault($r);var zr__default=/*#__PURE__*/_interopDefault(zr);async function Ie(s,e){let t=e.data;for(let r of s){let o=await r({...e,data:t});o!==void 0&&(t=o);}return t}async function br(s,e){return Ie(s,e)}var b=class{name;version;description;hooks={};collections=[];globals=[];fields=[];extensions={collections:[],globals:[]};adminComponents={};adminStyles=[];serverMiddleware;clientMiddleware;constructor(e){this.name=e;}async init(e){}async beforeInit(e){}async afterInit(e){}getCollections(){return this.collections}getGlobals(){return this.globals}getHooks(){return this.hooks}},$=class{plugins=new Map;hooks=new Map;register(e){if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);this.plugins.set(e.name,e);let t=e.getHooks?.()||{};for(let[r,o]of Object.entries(t))if(Array.isArray(o))for(let i of o)this.registerHook(r,i);}unregister(e){let t=this.plugins.get(e);if(!t)return;let r=t.getHooks?.()||{};for(let[o,i]of Object.entries(r))if(Array.isArray(i))for(let n of i)this.unregisterHook(o,n);this.plugins.delete(e);}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}registerHook(e,t){this.hooks.has(e)||this.hooks.set(e,[]),this.hooks.get(e).push(t);}unregisterHook(e,t){let r=this.hooks.get(e);if(r){let o=r.indexOf(t);o>-1&&r.splice(o,1);}}async executeHook(e,t){let r=this.hooks.get(e)||[],o=t;for(let i of r)try{let n=await i({...t,data:o});n!==void 0&&(o=n);}catch(n){console.error(`[PluginManager] Error in hook "${e}":`,n);}return o}getAllCollections(){let e=[];for(let t of this.plugins.values()){let r=t.getCollections?.()||[];e.push(...r);}return e}getAllGlobals(){let e=[];for(let t of this.plugins.values()){let r=t.getGlobals?.()||[];e.push(...r);}return e}getAllFields(){let e=[];for(let t of this.plugins.values())e.push(...t.fields);return e}getAdminComponents(){let e={};for(let t of this.plugins.values())Object.assign(e,t.adminComponents);return e}getAdminStyles(){let e=[];for(let t of this.plugins.values())e.push(...t.adminStyles);return e}},L=class extends b{constructor(){super("seo"),this.description="Advanced SEO features including sitemaps, robots.txt, and structured data",this.collections.push({slug:"seo-settings",label:"SEO Settings",fields:[{name:"sitemap",type:"checkbox",label:"Enable Sitemap",defaultValue:true},{name:"robotsTxt",type:"richtext",label:"robots.txt Content"},{name:"canonicalUrl",type:"text",variant:"url",label:"Canonical URL"},{name:"ogImage",type:"text",label:"Default OG Image URL"}]});}},E=class extends b{constructor(){super("analytics"),this.description="Analytics integration for tracking page views and events",this.collections.push({slug:"analytics-events",label:"Analytics Events",fields:[{name:"name",type:"text",required:true},{name:"properties",type:"json",label:"Event Properties"},{name:"timestamp",type:"date",required:true},{name:"userId",type:"text",label:"User ID"},{name:"sessionId",type:"text",label:"Session ID"}]}),this.adminComponents.AnalyticsDashboard={};}},U=class extends b{constructor(){super("comments"),this.description="Commenting system for products and posts",this.collections.push({slug:"comments",label:"Comments",fields:[{name:"content",type:"richtext",required:true},{name:"author",type:"text",required:true},{name:"email",type:"email"},{name:"approved",type:"checkbox",defaultValue:false},{name:"parent",type:"text",label:"Parent Comment ID"},{name:"resourceType",type:"text",required:true},{name:"resourceId",type:"text",required:true}]}),this.adminComponents.CommentModeration={};}},V=class extends b{constructor(){super("reviews"),this.description="Product reviews and ratings",this.collections.push({slug:"reviews",label:"Reviews",fields:[{name:"rating",type:"number",required:true,min:1,max:5},{name:"title",type:"text"},{name:"content",type:"richtext",required:true},{name:"author",type:"relationship",relationTo:"customers"},{name:"product",type:"relationship",relationTo:"products",required:true},{name:"approved",type:"checkbox",defaultValue:false},{name:"verified",type:"checkbox",label:"Verified Purchase"},{name:"helpful",type:"number",label:"Helpful Count",defaultValue:0}]}),this.adminComponents.ReviewModeration={};}},O=class extends b{constructor(){super("wishlist"),this.description="Customer wishlists",this.collections.push({slug:"wishlists",label:"Wishlists",fields:[{name:"customer",type:"relationship",relationTo:"customers",required:true},{name:"name",type:"text",label:"Wishlist Name",defaultValue:"My Wishlist"},{name:"items",type:"blocks",label:"Items",blocks:[{slug:"wishlist-item",label:"Item",fields:[{name:"product",type:"relationship",relationTo:"products"},{name:"quantity",type:"number",defaultValue:1},{name:"addedAt",type:"date"},{name:"priority",type:"select",options:[{label:"Low",value:"low"},{label:"Medium",value:"medium"},{label:"High",value:"high"}]}]}]}]});}},Ar={SEO:L,Analytics:E,Comments:U,Reviews:V,Wishlist:O};var wr={maxAttempts:5,lockDuration:9e5,notifyUser:true,notifyAdmin:true,adminNotifyAfter:3},x=class{redis;prefix;config;constructor(e,t={},r="kyro:lockout:"){this.redis=e,this.prefix=r,this.config={...wr,...t};}lockKey(e){return `${this.prefix}${e}`}historyKey(e){return `${this.prefix}${e}:history`}async checkLockout(e){let t=this.lockKey(e),r=await this.redis.hgetall(t);if(!r||Object.keys(r).length===0)return {locked:false,attemptsRemaining:this.config.maxAttempts,totalAttempts:0};let o=parseInt(r.attempts,10),i=r.lockedUntil?new Date(parseInt(r.lockedUntil,10)):void 0;return i&&i>new Date?{locked:true,attemptsRemaining:0,lockedUntil:i,totalAttempts:o}:i&&i<=new Date?(await this.unlockAccount(e),{locked:false,attemptsRemaining:this.config.maxAttempts,totalAttempts:0}):{locked:false,attemptsRemaining:Math.max(0,this.config.maxAttempts-o),totalAttempts:o}}async recordFailedAttempt(e){let t=this.lockKey(e),r=this.historyKey(e),o=Date.now(),i=await this.redis.hincrby(t,"attempts",1);if(await this.redis.hset(t,"lastAttempt",o.toString()),await this.redis.lpush(r,o.toString()),await this.redis.ltrim(r,0,99),i>=this.config.maxAttempts){let n=new Date(o+this.config.lockDuration);return await this.redis.hset(t,{lockedAt:o.toString(),lockedUntil:n.getTime().toString()}),await this.redis.expire(t,Math.ceil(this.config.lockDuration/1e3)+3600),{locked:true,attemptsRemaining:0,lockedUntil:n,totalAttempts:i}}return {locked:false,attemptsRemaining:Math.max(0,this.config.maxAttempts-i),totalAttempts:i}}async lockAccount(e,t){let r=this.lockKey(e),o=Date.now(),i=t||this.config.lockDuration,n=new Date(o+i),a=this.redis.pipeline();a.hset(r,{attempts:this.config.maxAttempts.toString(),lockedAt:o.toString(),lockedUntil:n.getTime().toString()}),a.expire(r,Math.ceil(i/1e3)+3600),await a.exec();}async unlockAccount(e){let t=this.lockKey(e);await this.redis.del(t);}async resetAttempts(e){let t=this.lockKey(e);(await this.redis.hgetall(t)).lockedAt?await this.redis.hset(t,{attempts:"0",lockedAt:"",lockedUntil:""}):await this.redis.del(t);}async getLockoutHistory(e,t=10){let r=this.historyKey(e);return (await this.redis.lrange(r,0,t-1)).map(i=>new Date(parseInt(i,10)))}async getLockoutStats(e){let t=this.historyKey(e),r=await this.redis.lrange(t,0,-1),o=r.filter((n,a)=>(a+1)%this.config.maxAttempts===0).length,i=await this.redis.hget(this.lockKey(e),"lockedAt");return {totalFailedAttempts:r.length,lockoutCount:o,lastLockout:i?new Date(parseInt(i,10)):null,averageAttemptsBeforeLockout:o>0?this.config.maxAttempts:0}}shouldNotifyAdmin(e){return this.config.notifyAdmin&&e>=this.config.adminNotifyAfter}getConfig(){return {...this.config}}setConfig(e){this.config={...this.config,...e};}};var kr={"auth:login":{window:9e5,max:5},"auth:register":{window:36e5,max:3},"auth:forgot":{window:36e5,max:3},"auth:reset":{window:36e5,max:5},"auth:verify":{window:36e5,max:5},"api:general":{window:6e4,max:100},"api:authenticated":{window:6e4,max:200}},S=class{redis;prefix;limits;userLimits;constructor(e,t,r,o="kyro:ratelimit:"){this.redis=e,this.prefix=o,this.limits={...kr,...t},this.userLimits=r||{"user:api":{window:6e4,max:500},"user:write":{window:36e5,max:100}};}getKey(e,t){return `${this.prefix}${e}:${t}`}async check(e,t){let r=this.limits[e]||this.limits["api:general"],o=this.getKey(e,t),i=Date.now(),n=i-r.window,a=this.redis.pipeline();a.zremrangebyscore(o,0,n),a.zcard(o),a.zadd(o,i,`${i}:${Math.random()}`),a.expire(o,Math.ceil(r.window/1e3)+1);let c=(await a.exec())?.[1]?.[1]||0;if(c>=r.max){let g=await this.redis.zrange(o,0,0,"WITHSCORES"),d=g.length>1?parseInt(g[1],10)+r.window:i+r.window;return {allowed:false,remaining:0,resetAt:d,retryAfter:Math.ceil((d-i)/1e3)}}return {allowed:true,remaining:r.max-c-1,resetAt:i+r.window}}async checkUser(e,t,r){let o=this.userLimits[e]||this.userLimits["user:api"],i=this.getKey(`user:${e}:${t}`,r),n=Date.now(),a=n-o.window,l=this.redis.pipeline();l.zremrangebyscore(i,0,a),l.zcard(i),l.zadd(i,n,`${n}:${Math.random()}`),l.expire(i,Math.ceil(o.window/1e3)+1);let g=(await l.exec())?.[1]?.[1]||0;if(g>=o.max){let d=await this.redis.zrange(i,0,0,"WITHSCORES"),u=d.length>1?parseInt(d[1],10)+o.window:n+o.window;return {allowed:false,remaining:0,resetAt:u,retryAfter:Math.ceil((u-n)/1e3)}}return {allowed:true,remaining:o.max-g-1,resetAt:n+o.window}}async reset(e,t){let r=this.getKey(e,t);await this.redis.del(r);}async resetUser(e,t,r){let o=this.getKey(`user:${e}:${t}`,r);await this.redis.del(o);}async getStatus(e,t){let r=this.limits[e]||this.limits["api:general"],o=this.getKey(e,t),i=Date.now(),n=i-r.window;await this.redis.zremrangebyscore(o,0,n);let a=await this.redis.zcard(o);return {count:a,limit:r.max,remaining:Math.max(0,r.max-a),resetAt:i+r.window}}setLimit(e,t){this.limits[e]=t;}setUserLimit(e,t){this.userLimits[e]=t;}};var P=class{users=new Map;sessions=new Map;refreshTokens=new Map;emailToUserId=new Map;passwordHistory=new Map;emailVerificationTokens=new Map;passwordResetTokens=new Map;auditLogs=[];externalDb=false;constructor(){}async connect(){}async disconnect(){this.users.clear(),this.sessions.clear(),this.refreshTokens.clear(),this.emailToUserId.clear(),this.passwordHistory.clear();}async createUser(e){let t=q.randomBytes(16).toString("hex"),r=new Date().toISOString(),o=await this.hashPassword(e.password),i={id:t,email:e.email.toLowerCase(),passwordHash:o,role:e.role||"customer",tenantId:e.tenantId,createdAt:r,updatedAt:r};return this.users.set(t,i),this.emailToUserId.set(e.email.toLowerCase(),t),this.passwordHistory.set(t,[]),i}async findUserByEmail(e){let t=this.emailToUserId.get(e.toLowerCase());return t?this.findUserById(t):null}async findUserById(e){return this.users.get(e)||null}async updateUser(e,t){let r=await this.findUserById(e);if(!r)return null;let o={...r,...t,id:e,updatedAt:new Date().toISOString()};return t.email&&t.email!==r.email&&(this.emailToUserId.delete(r.email.toLowerCase()),this.emailToUserId.set(t.email.toLowerCase(),e)),this.users.set(e,o),o}async deleteUser(e){let t=await this.findUserById(e);return t?(this.users.delete(e),this.emailToUserId.delete(t.email.toLowerCase()),this.refreshTokens.forEach((r,o)=>{this.sessions.get(r)?.userId===e&&(this.refreshTokens.delete(o),this.sessions.delete(r));}),this.passwordHistory.delete(e),this.sessions.forEach((r,o)=>{r.userId===e&&this.sessions.delete(o);}),true):false}async hashPassword(e){return (await import('bcryptjs')).default.hash(e,12)}async verifyPassword(e,t){let r=await this.findUserByEmail(e);return !r||!r.passwordHash?null:await(await import('bcryptjs')).default.compare(t,r.passwordHash)?r:null}async createSession(e,t={}){let r=q.randomBytes(32).toString("hex"),o=q.randomBytes(32).toString("base64url"),i=q.randomBytes(32).toString("base64url"),n=new Date,a={id:r,userId:e,token:o,refreshToken:i,expiresAt:new Date(n.getTime()+86400*1e3).toISOString(),createdAt:n.toISOString(),ipAddress:t.ipAddress,userAgent:t.userAgent};return this.sessions.set(r,a),this.refreshTokens.set(i,r),a}async findSessionByToken(e){return this.sessions.get(e)||null}async findSessionByRefreshToken(e){let t=this.refreshTokens.get(e);return t&&this.sessions.get(t)||null}async deleteSession(e){let t=this.sessions.get(e);return t?(t.refreshToken&&this.refreshTokens.delete(t.refreshToken),this.sessions.delete(e),true):false}async deleteUserSessions(e){let t=0;return this.sessions.forEach((r,o)=>{r.userId===e&&(r.refreshToken&&this.refreshTokens.delete(r.refreshToken),this.sessions.delete(o),t++);}),t}async addPasswordToHistory(e,t){let r=this.passwordHistory.get(e)||[];r.push(t),r.length>5&&r.splice(0,r.length-5),this.passwordHistory.set(e,r);}async getPasswordHistory(e,t=5){return this.passwordHistory.get(e)||[]}async isPasswordInHistory(e,t,r=5){let o=await this.getPasswordHistory(t,r),i=(await import('bcryptjs')).default;for(let n of o)if(await i.compare(e,n))return true;return false}async createEmailVerificationToken(e){let t=q.randomBytes(32).toString("hex"),r=new Date(Date.now()+1440*60*1e3);return this.emailVerificationTokens.set(t,{userId:e,expiresAt:r}),{token:t,expiresAt:r}}async verifyEmailToken(e){let t=this.emailVerificationTokens.get(e);return !t||t.expiresAt<new Date?(this.emailVerificationTokens.delete(e),{success:false,error:"Invalid or expired token"}):(this.emailVerificationTokens.delete(e),{success:true,userId:t.userId})}async createPasswordResetToken(e){let t=await this.findUserByEmail(e);if(!t)return {token:"",expiresAt:new Date,error:"User not found"};let r=q.randomBytes(32).toString("hex"),o=new Date(Date.now()+3600*1e3);return this.passwordResetTokens.set(r,{userId:t.id,expiresAt:o}),{token:r,expiresAt:o}}async resetPasswordWithToken(e,t){let r=this.passwordResetTokens.get(e);if(!r||r.expiresAt<new Date)return this.passwordResetTokens.delete(e),{success:false,error:"Invalid or expired token"};let o=await this.hashPassword(t);return await this.updateUser(r.userId,{passwordHash:o}),this.passwordResetTokens.delete(e),{success:true}}async hasAnyUsers(){return this.users.size>0}async findAuditLogs(e){let{limit:t=50,offset:r=0}=e,o=this.auditLogs.slice().reverse();return e.userId&&(o=o.filter(i=>i.userId===e.userId)),e.action&&(Array.isArray(e.action)?o=o.filter(i=>e.action.includes(String(i.action))):o=o.filter(i=>i.action===e.action)),e.resource&&(o=o.filter(i=>i.resource===e.resource)),e.success!==void 0&&(o=o.filter(i=>i.success===e.success)),{logs:o.slice(r,r+t),total:o.length}}async createAuditLog(e){let t=q.randomBytes(16).toString("hex"),o={...e,id:t,timestamp:new Date};return this.auditLogs.push(o),o}};var C=class{storage=new Map;history=new Map;config;constructor(e={}){this.config={maxAttempts:5,lockDuration:9e5,notifyUser:true,notifyAdmin:true,adminNotifyAfter:3,...e};}async checkLockout(e){let t=Date.now(),r=this.storage.get(e);if(r&&r.lockedUntil!==null&&r.lockedUntil<=t)return await this.resetAttempts(e),{locked:false,attemptsRemaining:this.config.maxAttempts,totalAttempts:0};if(!r)return {locked:false,attemptsRemaining:this.config.maxAttempts,totalAttempts:0};let{attempts:o,lockedUntil:i}=r;return i!==null&&i>t?{locked:true,attemptsRemaining:0,lockedUntil:new Date(i),totalAttempts:o}:{locked:false,attemptsRemaining:Math.max(0,this.config.maxAttempts-o),totalAttempts:o}}async recordFailedAttempt(e){let t=Date.now(),r=this.storage.get(e)||{attempts:0,lastAttempt:null,lockedAt:null,lockedUntil:null};r.attempts+=1,r.lastAttempt=t;let o=this.history.get(e)||[];if(o.push(t),o.length>100&&o.splice(0,o.length-100),this.history.set(e,o),this.storage.set(e,r),r.attempts>=this.config.maxAttempts){let i=new Date(t+this.config.lockDuration);return r.lockedAt=t,r.lockedUntil=i.getTime(),this.storage.set(e,r),{locked:true,attemptsRemaining:0,lockedUntil:i,totalAttempts:r.attempts}}return {locked:false,attemptsRemaining:Math.max(0,this.config.maxAttempts-r.attempts),totalAttempts:r.attempts}}async lockAccount(e,t){let r=Date.now(),o=t||this.config.lockDuration,i=new Date(r+o),n=this.storage.get(e)||{attempts:0,lastAttempt:null,lockedAt:null,lockedUntil:null};n.attempts=this.config.maxAttempts,n.lockedAt=r,n.lockedUntil=i.getTime(),this.storage.set(e,n);}async unlockAccount(e){await this.resetAttempts(e);}async resetAttempts(e){let t=this.storage.get(e);t&&(t.attempts=0,t.lockedAt=null,t.lockedUntil=null,this.storage.set(e,t)),this.history.delete(e);}async getLockoutHistory(e,t=10){return (this.history.get(e)||[]).slice(-t).reverse().map(o=>new Date(o))}async getLockoutStats(e){let r=(this.history.get(e)||[]).length,o=Math.floor(r/this.config.maxAttempts),i=null,n=this.storage.get(e);n&&n.lockedAt!==null&&(i=new Date(n.lockedAt));let a=o>0?this.config.maxAttempts:0;return {totalFailedAttempts:r,lockoutCount:o,lastLockout:i,averageAttemptsBeforeLockout:a}}shouldNotifyAdmin(e){return this.config.notifyAdmin&&e>=this.config.adminNotifyAfter}getConfig(){return {...this.config}}setConfig(e){this.config={...this.config,...e};}};function h(s,e=""){return process.env[s]||e}function A(s,e=false){let t=process.env[s];return t?t.toLowerCase()==="true":e}function p(s,e=0){let t=process.env[s];return t?parseInt(t,10):e}function Le(){let s=process.env.KYRO_AUTH_DATABASE?.toLowerCase();if(s&&["sqlite","postgres","mongodb","memory"].includes(s))return s;try{let e=Me.join(process.cwd(),"kyro.config.ts"),t=fs.readFileSync(e,"utf8");if(t.includes("createLocalAdapter"))return "sqlite";if(t.includes("createDrizzleAdapter"))return t.includes("postgres")||t.includes("postgresql"),"postgres";if(t.includes("createMongoDBAdapter"))return "mongodb"}catch{}return "memory"}async function Pr(s){let e=process.cwd(),t=e.endsWith("admin")?Me.join(e,".."):e,r=Me.resolve(t,"data","auth.db");switch(s){case "sqlite":return new chunkET6NN2V2_cjs.a({path:h("KYRO_AUTH_DB_PATH",r)});case "postgres":{try{let o=h("DATABASE_URL","");if(o){let{drizzle:i}=await import('drizzle-orm/postgres-js'),a=(await import('postgres')).default(o,{onnotice:()=>{}}),l=i(a);return new chunkGYQMNXXW_cjs.a({db:l})}}catch{console.warn("[Auth] Could not create PostgresAuthAdapter, falling back to SQLite auth adapter.");}return new chunkET6NN2V2_cjs.a({path:h("KYRO_AUTH_DB_PATH",r)})}case "mongodb":{try{let o=h("MONGODB_URI","");if(o){let{MongoClient:i}=await import('mongodb'),n=new i(o);await n.connect();let l=new URL(o).pathname.replace(/^\//,"")||"kyro_cms",c=n.db(l);return new chunkATLSIYRH_cjs.a({db:c})}}catch{console.warn("[Auth] Could not create MongoDBAuthAdapter, falling back to SQLite auth adapter.");}return new chunkET6NN2V2_cjs.a({path:h("KYRO_AUTH_DB_PATH",r)})}default:return new P}}async function W(s,e){let t=A("KYRO_DISTRIBUTED",false),r;if(t){let{RedisAuthAdapter:d}=await import('./redis-adapter-AQJVABYT.cjs'),u=h("REDIS_URL","redis://localhost:6379"),y=A("REDIS_TLS",false),f=new d({url:u,tls:y});await f.connect?.(),r=f;}else {let d=s||Le();r=await Pr(d),r.connect&&await r.connect();}let o=e?await chunkAJAZ7D3W_cjs.b.fromConfig(e).catch(()=>null)||chunkAJAZ7D3W_cjs.b.fromEnv()||void 0:chunkAJAZ7D3W_cjs.b.fromEnv()||void 0,i=new chunkAJAZ7D3W_cjs.c({minLength:p("PASSWORD_MIN_LENGTH",12),requireUppercase:A("PASSWORD_REQUIRE_UPPERCASE",true),requireLowercase:A("PASSWORD_REQUIRE_LOWERCASE",true),requireNumbers:A("PASSWORD_REQUIRE_NUMBERS",true),requireSpecialChars:A("PASSWORD_REQUIRE_SPECIAL",true),preventReuse:p("PASSWORD_PREVENT_REUSE",5),maxLength:p("PASSWORD_MAX_LENGTH",128)}),n,a,l;if(t){let u=r.redis;n=new x(u,{maxAttempts:p("LOCKOUT_MAX_ATTEMPTS",5),lockDuration:p("LOCKOUT_DURATION_MINUTES",15)*60*1e3}),a=new S(u,{"auth:login":{window:p("RATE_LIMIT_AUTH_WINDOW_MS",9e5),max:p("RATE_LIMIT_AUTH_MAX_REQUESTS",10)},"api:general":{window:p("RATE_LIMIT_WINDOW_MS",6e4),max:p("RATE_LIMIT_MAX_REQUESTS",100)}}),l=new chunkKIW36TG7_cjs.n(u,p("AUDIT_LOG_RETENTION_DAYS",30));}else n=new C({maxAttempts:p("LOCKOUT_MAX_ATTEMPTS",5),lockDuration:p("LOCKOUT_DURATION_MINUTES",15)*60*1e3}),a=new chunkKIW36TG7_cjs.m({"auth:login":{window:p("RATE_LIMIT_AUTH_WINDOW_MS",9e5),max:p("RATE_LIMIT_AUTH_MAX_REQUESTS",10)},"api:general":{window:p("RATE_LIMIT_WINDOW_MS",6e4),max:p("RATE_LIMIT_MAX_REQUESTS",100)}}),l=A("AUDIT_LOG_ENABLED",true)?new chunkKIW36TG7_cjs.p(p("AUDIT_LOG_RETENTION_DAYS",30)):void 0;let c=new chunkKIW36TG7_cjs.q({redis:r,email:o,jwtSecret:h("APP_SECRET","change-me"),jwtExpiresIn:h("JWT_EXPIRES_IN","24h"),jwtIssuer:h("JWT_ISSUER","kyro-cms"),jwtAudience:h("JWT_AUDIENCE","kyro-cms-client"),passwordPolicy:i,lockout:n,rateLimiter:a,auditLogger:l,baseUrl:h("EMAIL_BASE_URL","http://localhost:4321"),emailVerificationRequired:A("EMAIL_VERIFICATION_REQUIRED",true)}),g=t?"distributed":s||Le();return {authAdapter:r,databaseType:g,email:o,passwordPolicy:i,lockout:n,rateLimiter:a,auditLogger:l,routes:c}}var Ue=W().catch(s=>(console.warn("[AuthConfig] Failed to initialize auth config:",s.message),null));var Cr=12,Tr="24h",vr="7d",H=class{adapter;config;constructor(e,t){this.adapter=e,this.config={secret:t.secret,expiresIn:t.expiresIn??Tr,refreshExpiresIn:t.refreshExpiresIn??vr,issuer:t.issuer??"kyro-cms",audience:t.audience??[],saltRounds:t.saltRounds??Cr};}async register(e){try{if(await this.adapter.findUserByEmail(e.email))return {success:!1,error:"Email already registered"};let r=await this.adapter.createUser({email:e.email,password:e.password,role:e.role??"customer",tenantId:e.tenantId});return this.createSessionForUser(r)}catch(t){return {success:false,error:String(t)}}}async login(e){try{let t=await this.adapter.verifyPassword(e.email,e.password);return t?this.createSessionForUser(t):{success:!1,error:"Invalid credentials"}}catch(t){return {success:false,error:String(t)}}}async logout(e){await this.adapter.deleteSession(e);}async refreshToken(e){try{let t=await this.adapter.findSessionByToken(e);if(!t||new Date(t.expiresAt)<new Date)return {success:!1,error:"Invalid or expired refresh token"};let r=await this.adapter.findUserById(t.userId);return r?(await this.adapter.deleteSession(e),this.createSessionForUser(r)):{success:!1,error:"User not found"}}catch(t){return {success:false,error:String(t)}}}async verifyToken(e){try{let{default:t}=await import('jsonwebtoken');return t.verify(e,this.config.secret,{issuer:this.config.issuer,audience:this.config.audience.length>0?this.config.audience[0]:void 0})}catch{return null}}async getUserFromToken(e){let t=await this.verifyToken(e);return t?this.adapter.findUserById(t.sub):null}async changePassword(e,t,r){try{let o=await this.adapter.findUserById(e);return o?await this.adapter.verifyPassword(o.email,t)?(await this.adapter.updateUser(e,{password:r}),await this.adapter.deleteUserSessions(e),{success:!0,user:o}):{success:!1,error:"Current password is incorrect"}:{success:!1,error:"User not found"}}catch(o){return {success:false,error:String(o)}}}async resetPassword(e,t){try{let r=await this.adapter.findUserByEmail(e);return r?(await this.adapter.updateUser(r.id,{password:t}),await this.adapter.deleteUserSessions(r.id),{success:!0,user:r}):{success:!1,error:"User not found"}}catch(r){return {success:false,error:String(r)}}}async sendEmailVerification(e){try{let{token:t,expiresAt:r}=await this.adapter.createEmailVerificationToken(e);return {success:!0}}catch(t){return {success:false,error:String(t)}}}async verifyEmail(e){try{return await this.adapter.verifyEmailToken(e)}catch(t){return {success:false,error:String(t)}}}async requestPasswordReset(e){try{let t=await this.adapter.createPasswordResetToken(e);return t.error?{success:!1,error:t.error}:{success:!0}}catch(t){return {success:false,error:String(t)}}}async resetPasswordWithToken(e,t){try{return await this.adapter.resetPasswordWithToken(e,t)}catch(r){return {success:false,error:String(r)}}}async deleteAccount(e){try{return await this.adapter.findUserById(e)?(await this.adapter.deleteUserSessions(e),await this.adapter.deleteUser(e),{success:!0}):{success:!1,error:"User not found"}}catch(t){return {success:false,error:String(t)}}}async createSessionForUser(e){let t=await this.generateToken(e),r=await this.adapter.createSession(e.id);return {success:true,user:e,session:r,token:t}}async generateToken(e){let{default:t}=await import('jsonwebtoken'),r={sub:e.id,email:e.email,role:e.role,tenantId:e.tenantId},o={expiresIn:this.parseExpiresIn(this.config.expiresIn)/1e3,issuer:this.config.issuer};return this.config.audience.length>0&&(o.audience=this.config.audience[0]),t.sign(r,this.config.secret,o)}async hashPassword(e){let{default:t}=await import('bcryptjs');return t.hash(e,this.config.saltRounds)}parseExpiresIn(e){if(typeof e=="number")return e;let t=e.match(/^(\d+)([smhd])$/);if(!t)return 864e5;let r=parseInt(t[1],10);switch(t[2]){case "s":return r*1e3;case "m":return r*6e4;case "h":return r*36e5;case "d":return r*864e5;default:return 864e5}}};function Rr(s,e){return new H(s,e)}function _(){return {enabled:true,draftsEnabled:true,publishEnabled:true,scheduleEnabled:false,versioningEnabled:true,maxVersionsPerDocument:50,autoPublish:false,requirePublishPermission:true}}var M=class{adapter;config;constructor(e,t){this.adapter=e,this.config={..._(),...t};}async createVersion(e){let r=((await this.adapter.getLatestVersion(e.collection,e.documentId))?.version??0)+1,o={...e,version:r},i=await this.adapter.createVersion(o);return this.config.maxVersionsPerDocument>0&&await this.pruneOldVersions(e.collection,e.documentId),i}async publishVersion(e){let t=await this.adapter.getVersion(e.collection,e.versionId);if(!t)throw new Error("Version not found");if(t.status==="published")throw new Error("Version is already published");await this.adapter.publishVersion(e);}async unpublishDocument(e,t){let r=await this.adapter.getVersions({collection:e,documentId:t,limit:1e3});for(let o of r)if(o.status==="published"){await this.createVersion({collection:e,documentId:t,data:o.data,status:"draft",createdBy:"system",changeDescription:"Unpublished document"});break}}async revertToVersion(e,t,r,o){if(!await this.adapter.getVersion(e,r))throw new Error("Version not found");return await this.adapter.revertToVersion({collection:e,documentId:t,versionId:r,userId:o})}async getVersionHistory(e,t,r=20,o=0){return this.adapter.getVersions({collection:e,documentId:t,limit:r,offset:o})}async compareTwoVersions(e,t,r,o){return this.adapter.compareVersions({collection:e,documentId:t,versionA:r,versionB:o})}async getLatestDraft(e,t){return this.adapter.getLatestVersion(e,t)}async getPublishedVersion(e,t){return this.adapter.getPublishedVersion(e,t)}async getVersion(e,t){return this.adapter.getVersion(e,t)}async schedulePublish(e,t,r,o){if(!this.config.scheduleEnabled)throw new Error("Scheduled publishing is not enabled");if(!await this.adapter.getVersion(e,r))throw new Error("Version not found")}async deleteVersionHistory(e,t){await this.adapter.deleteVersions(e,t);}async pruneOldVersions(e,t){let r=await this.adapter.getVersions({collection:e,documentId:t,limit:this.config.maxVersionsPerDocument+100});if(r.length<=this.config.maxVersionsPerDocument)return;r.slice(0,this.config.maxVersionsPerDocument);let i=r.slice(this.config.maxVersionsPerDocument);for(let n of i)if(n.status!=="published"){await this.adapter.deleteVersions(e,t);break}}};function Dr(s,e){return new M(s,e)}function Ir(s){return s==="published"}function Lr(s){return s==="draft"}function Er(s){return s==="archived"}function Ur(s){return s?Array.isArray(s)?s:Object.values(s):[]}function Vr(s){return s?Array.isArray(s)?s:Object.values(s):[]}function Ve(s){return {collections:Ur(s.collections),globals:Vr(s.globals),adapter:s.adapter,plugins:s.plugins,auth:s.auth,cors:s.cors,admin:s.admin,upload:s.upload,graphQL:s.graphQL,typescript:s.typescript,localization:s.localization,rateLimit:s.rateLimit,debug:s.debug}}var Or=Ve;function Hr(s){let{siteSettings:e,seoSettings:t,title:r,description:o,image:i,url:n}=s;if(!e)return "";let a=e.siteName||"",l=r||t?.defaultTitle||a,c=t?.titleTemplate,g=t?.separator||" | ",d=t?.siteNameInTitle!==false,u=c?c.replace(/\{\{title\}\}/g,l).replace(/\{\{siteName\}\}/g,d?a:"").replace(/\{\{separator\}\}/g,g).replace(/\s+/g," ").trim():l,y=o||t?.defaultDescription||e.siteDescription||"",f=i||e.siteOgImage?.url||"",F=n||e.siteUrl||"",m=`
|
|
2
|
+
<title>${u}</title>
|
|
3
|
+
<meta name="description" content="${y}">
|
|
4
|
+
`;e.siteFavicon?.url&&(m+=`
|
|
5
|
+
<link rel="icon" type="${e.siteFavicon.mimeType||"image/x-icon"}" href="${e.siteFavicon.url}">`);let X=t?.meta?.robots;X&&(m+=`
|
|
6
|
+
<meta name="robots" content="${X}">`);let J=t?.meta?.canonicalUrl||F;J&&(m+=`
|
|
7
|
+
<link rel="canonical" href="${J}">`);let Be=t?.meta?.ogType||"website";m+=`
|
|
8
|
+
<meta property="og:type" content="${Be}">
|
|
9
|
+
<meta property="og:title" content="${u}">
|
|
10
|
+
<meta property="og:description" content="${y}">
|
|
11
|
+
<meta property="og:site_name" content="${a}">
|
|
12
|
+
`,F&&(m+=`
|
|
13
|
+
<meta property="og:url" content="${F}">`),f&&(m+=`
|
|
14
|
+
<meta property="og:image" content="${f}">`),t?.social?.fbAppId&&(m+=`
|
|
15
|
+
<meta property="fb:app_id" content="${t.social.fbAppId}">`);let Ne=t?.social?.twitterCardType||"summary_large_image";return m+=`
|
|
16
|
+
<meta name="twitter:card" content="${Ne}">
|
|
17
|
+
<meta name="twitter:title" content="${u}">
|
|
18
|
+
<meta name="twitter:description" content="${y}">
|
|
19
|
+
`,t?.social?.twitterHandle&&(m+=`
|
|
20
|
+
<meta name="twitter:site" content="${t.social.twitterHandle}">`),f&&(m+=`
|
|
21
|
+
<meta name="twitter:image" content="${f}">`),e.enableI18n&&e.i18n?.language&&(m+=`
|
|
22
|
+
<meta http-equiv="content-language" content="${e.i18n.language}">`),m}function _r(s){if(!s||!s.analyticsEnabled||!s.analytics)return "";let{googleAnalyticsId:e,googleTagManagerId:t,plausibleDomain:r}=s.analytics,o="";return e&&(o+=`
|
|
1657
23
|
<!-- Google Analytics -->
|
|
1658
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=${
|
|
24
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=${e}"></script>
|
|
1659
25
|
<script>
|
|
1660
26
|
window.dataLayer = window.dataLayer || [];
|
|
1661
27
|
function gtag(){dataLayer.push(arguments);}
|
|
1662
28
|
gtag('js', new Date());
|
|
1663
|
-
gtag('config', '${
|
|
29
|
+
gtag('config', '${e}');
|
|
1664
30
|
</script>
|
|
1665
|
-
|
|
1666
|
-
}
|
|
1667
|
-
if (googleTagManagerId) {
|
|
1668
|
-
scripts += `
|
|
31
|
+
`),t&&(o+=`
|
|
1669
32
|
<!-- Google Tag Manager -->
|
|
1670
33
|
<script>
|
|
1671
34
|
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
1672
35
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
1673
36
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
1674
37
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
1675
|
-
})(window,document,'script','dataLayer','${
|
|
38
|
+
})(window,document,'script','dataLayer','${t}');
|
|
1676
39
|
</script>
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
if (plausibleDomain) {
|
|
1680
|
-
scripts += `
|
|
40
|
+
`),r&&(o+=`
|
|
1681
41
|
<!-- Plausible Analytics -->
|
|
1682
|
-
<script defer data-domain="${
|
|
1683
|
-
`;
|
|
1684
|
-
}
|
|
1685
|
-
return scripts;
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
// src/lib/social.ts
|
|
1689
|
-
var PLATFORM_META = {
|
|
1690
|
-
facebook: { label: "Facebook" },
|
|
1691
|
-
twitter: { label: "Twitter / X" },
|
|
1692
|
-
instagram: { label: "Instagram" },
|
|
1693
|
-
linkedin: { label: "LinkedIn" },
|
|
1694
|
-
youtube: { label: "YouTube" },
|
|
1695
|
-
tiktok: { label: "TikTok" },
|
|
1696
|
-
pinterest: { label: "Pinterest" },
|
|
1697
|
-
discord: { label: "Discord" },
|
|
1698
|
-
twitch: { label: "Twitch" },
|
|
1699
|
-
github: { label: "GitHub" },
|
|
1700
|
-
mastodon: { label: "Mastodon" }
|
|
1701
|
-
};
|
|
1702
|
-
var ALL_PLATFORMS = [
|
|
1703
|
-
"facebook",
|
|
1704
|
-
"twitter",
|
|
1705
|
-
"instagram",
|
|
1706
|
-
"linkedin",
|
|
1707
|
-
"youtube",
|
|
1708
|
-
"tiktok",
|
|
1709
|
-
"pinterest",
|
|
1710
|
-
"discord",
|
|
1711
|
-
"twitch",
|
|
1712
|
-
"github",
|
|
1713
|
-
"mastodon"
|
|
1714
|
-
];
|
|
1715
|
-
function getSocialLinksFromSettings(socialSettings) {
|
|
1716
|
-
if (!socialSettings) return [];
|
|
1717
|
-
const showAll = socialSettings.showAll === true;
|
|
1718
|
-
const links = [];
|
|
1719
|
-
for (const platform of ALL_PLATFORMS) {
|
|
1720
|
-
const url = socialSettings[platform];
|
|
1721
|
-
if (!url) continue;
|
|
1722
|
-
const isNiche = ["tiktok", "pinterest", "discord", "twitch", "github", "mastodon"].includes(platform);
|
|
1723
|
-
if (isNiche && !showAll) continue;
|
|
1724
|
-
const meta = PLATFORM_META[platform];
|
|
1725
|
-
links.push({
|
|
1726
|
-
platform,
|
|
1727
|
-
url,
|
|
1728
|
-
label: meta?.label || platform
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
return links;
|
|
1732
|
-
}
|
|
1733
|
-
async function getSocialLinks(db, options) {
|
|
1734
|
-
try {
|
|
1735
|
-
const doc = await db.findOne({
|
|
1736
|
-
collection: "_globals_social-settings",
|
|
1737
|
-
where: {},
|
|
1738
|
-
draft: options?.draft ?? false
|
|
1739
|
-
});
|
|
1740
|
-
return getSocialLinksFromSettings(doc);
|
|
1741
|
-
} catch {
|
|
1742
|
-
return [];
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
// src/lib/store.ts
|
|
1747
|
-
function getStoreConfigFromSettings(settings) {
|
|
1748
|
-
if (!settings) return {};
|
|
1749
|
-
return {
|
|
1750
|
-
storeName: settings.storeName,
|
|
1751
|
-
storeEmail: settings.storeEmail,
|
|
1752
|
-
storePhone: settings.storePhone,
|
|
1753
|
-
address: settings.address,
|
|
1754
|
-
currency: settings.currency,
|
|
1755
|
-
tax: settings.tax,
|
|
1756
|
-
shipping: settings.shipping,
|
|
1757
|
-
orders: settings.orders
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
async function getStoreConfig(db, options) {
|
|
1761
|
-
try {
|
|
1762
|
-
const doc = await db.findOne({
|
|
1763
|
-
collection: "_globals_store-settings",
|
|
1764
|
-
where: {},
|
|
1765
|
-
draft: options?.draft ?? false
|
|
1766
|
-
});
|
|
1767
|
-
return getStoreConfigFromSettings(doc);
|
|
1768
|
-
} catch {
|
|
1769
|
-
return {};
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
// src/lib/payment.ts
|
|
1774
|
-
function getPaymentConfigFromSettings(settings) {
|
|
1775
|
-
if (!settings) return {};
|
|
1776
|
-
return {
|
|
1777
|
-
testMode: settings.testMode,
|
|
1778
|
-
provider: settings.provider,
|
|
1779
|
-
stripe: settings.stripe,
|
|
1780
|
-
paypal: settings.paypal,
|
|
1781
|
-
square: settings.square,
|
|
1782
|
-
methods: settings.methods,
|
|
1783
|
-
bankTransfer: settings.bankTransfer
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
async function getPaymentConfig(db, options) {
|
|
1787
|
-
try {
|
|
1788
|
-
const doc = await db.findOne({
|
|
1789
|
-
collection: "_globals_payment-settings",
|
|
1790
|
-
where: {},
|
|
1791
|
-
draft: options?.draft ?? false
|
|
1792
|
-
});
|
|
1793
|
-
return getPaymentConfigFromSettings(doc);
|
|
1794
|
-
} catch {
|
|
1795
|
-
return {};
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
async function createBrowserStorage(options = {}) {
|
|
1799
|
-
const { namespace = "kyro", ttl } = options;
|
|
1800
|
-
const store = unstorage.createStorage({
|
|
1801
|
-
driver: indexedbDriver__default.default({
|
|
1802
|
-
dbName: "kyro-cms",
|
|
1803
|
-
storeName: namespace
|
|
1804
|
-
})
|
|
1805
|
-
});
|
|
1806
|
-
const prefix = namespace ? `${namespace}:` : "";
|
|
1807
|
-
const storage = {
|
|
1808
|
-
getItem: async (name) => {
|
|
1809
|
-
const key = `${prefix}${name}`;
|
|
1810
|
-
const raw = await store.getItem(key);
|
|
1811
|
-
if (raw == null) return null;
|
|
1812
|
-
try {
|
|
1813
|
-
const parsed = JSON.parse(raw);
|
|
1814
|
-
if (parsed.expiry && Date.now() > parsed.expiry) {
|
|
1815
|
-
await store.removeItem(key);
|
|
1816
|
-
return null;
|
|
1817
|
-
}
|
|
1818
|
-
return parsed.value;
|
|
1819
|
-
} catch {
|
|
1820
|
-
return raw;
|
|
1821
|
-
}
|
|
1822
|
-
},
|
|
1823
|
-
setItem: async (name, value) => {
|
|
1824
|
-
const key = `${prefix}${name}`;
|
|
1825
|
-
const data = JSON.stringify(
|
|
1826
|
-
ttl ? { value, expiry: Date.now() + ttl } : { value }
|
|
1827
|
-
);
|
|
1828
|
-
await store.setItem(key, data);
|
|
1829
|
-
},
|
|
1830
|
-
removeItem: async (name) => {
|
|
1831
|
-
await store.removeItem(`${prefix}${name}`);
|
|
1832
|
-
}
|
|
1833
|
-
};
|
|
1834
|
-
return {
|
|
1835
|
-
storage,
|
|
1836
|
-
cleanup: async () => {
|
|
1837
|
-
await store.dispose?.();
|
|
1838
|
-
}
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
function getEncryptionKey2(secret) {
|
|
1842
|
-
const appSecret = secret || process.env.APP_SECRET || process.env.AUTH_SECRET || "development-secret-key";
|
|
1843
|
-
return crypto2__default.default.createHash("sha256").update(appSecret).digest("hex");
|
|
1844
|
-
}
|
|
1845
|
-
function encrypt(text, key) {
|
|
1846
|
-
const iv = crypto2__default.default.randomBytes(16);
|
|
1847
|
-
const cipher = crypto2__default.default.createCipheriv("aes-256-gcm", Buffer.from(key, "hex").subarray(0, 32), iv);
|
|
1848
|
-
let encrypted = cipher.update(text, "utf8", "hex");
|
|
1849
|
-
encrypted += cipher.final("hex");
|
|
1850
|
-
const authTag = cipher.getAuthTag().toString("hex");
|
|
1851
|
-
return `${iv.toString("hex")}:${authTag}:${encrypted}`;
|
|
1852
|
-
}
|
|
1853
|
-
function decrypt(encryptedText, key) {
|
|
1854
|
-
const [ivHex, authTagHex, encrypted] = encryptedText.split(":");
|
|
1855
|
-
const iv = Buffer.from(ivHex, "hex");
|
|
1856
|
-
const authTag = Buffer.from(authTagHex, "hex");
|
|
1857
|
-
const decipher = crypto2__default.default.createDecipheriv("aes-256-gcm", Buffer.from(key, "hex").subarray(0, 32), iv);
|
|
1858
|
-
decipher.setAuthTag(authTag);
|
|
1859
|
-
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
1860
|
-
decrypted += decipher.final("utf8");
|
|
1861
|
-
return decrypted;
|
|
1862
|
-
}
|
|
1863
|
-
async function createNodeStorage(options = {}) {
|
|
1864
|
-
const {
|
|
1865
|
-
namespace = "kyro",
|
|
1866
|
-
ttl,
|
|
1867
|
-
encryption = true,
|
|
1868
|
-
secret,
|
|
1869
|
-
basePath
|
|
1870
|
-
} = options;
|
|
1871
|
-
const defaultPath = basePath ? path__default.default.join(basePath, ".astro", "kyro.json") : path__default.default.join(process.cwd(), ".astro", "kyro.json");
|
|
1872
|
-
const store = unstorage.createStorage({
|
|
1873
|
-
driver: fsDriver__default.default({ base: defaultPath })
|
|
1874
|
-
});
|
|
1875
|
-
const encKey = encryption ? getEncryptionKey2(secret) : null;
|
|
1876
|
-
const prefix = namespace ? `${namespace}:` : "";
|
|
1877
|
-
return {
|
|
1878
|
-
storage: {
|
|
1879
|
-
getItem: async (name) => {
|
|
1880
|
-
const key = `${prefix}${name}`;
|
|
1881
|
-
const raw = await store.getItem(key);
|
|
1882
|
-
if (raw == null) return null;
|
|
1883
|
-
try {
|
|
1884
|
-
const data = encKey ? decrypt(raw, encKey) : raw;
|
|
1885
|
-
const parsed = JSON.parse(data);
|
|
1886
|
-
if (parsed.expiry && Date.now() > parsed.expiry) {
|
|
1887
|
-
await store.removeItem(key);
|
|
1888
|
-
return null;
|
|
1889
|
-
}
|
|
1890
|
-
return parsed.value;
|
|
1891
|
-
} catch {
|
|
1892
|
-
return raw;
|
|
1893
|
-
}
|
|
1894
|
-
},
|
|
1895
|
-
setItem: async (name, value) => {
|
|
1896
|
-
const key = `${prefix}${name}`;
|
|
1897
|
-
const data = JSON.stringify(
|
|
1898
|
-
ttl ? { value, expiry: Date.now() + ttl } : { value }
|
|
1899
|
-
);
|
|
1900
|
-
await store.setItem(key, encKey ? encrypt(data, encKey) : data);
|
|
1901
|
-
},
|
|
1902
|
-
removeItem: async (name) => {
|
|
1903
|
-
await store.removeItem(`${prefix}${name}`);
|
|
1904
|
-
}
|
|
1905
|
-
},
|
|
1906
|
-
cleanup: async () => {
|
|
1907
|
-
await store.dispose?.();
|
|
1908
|
-
}
|
|
1909
|
-
};
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
// src/lib/storage/factory.ts
|
|
1913
|
-
async function createStorage3(config) {
|
|
1914
|
-
const { environment, adapter, connectionString, encryption } = config;
|
|
1915
|
-
const secret = process.env.APP_SECRET || process.env.AUTH_SECRET;
|
|
1916
|
-
const encryptionOptions = {
|
|
1917
|
-
enabled: encryption?.enabled ?? true,
|
|
1918
|
-
algorithm: encryption?.algorithm
|
|
1919
|
-
};
|
|
1920
|
-
if (environment === "browser") {
|
|
1921
|
-
return createBrowserStorage({
|
|
1922
|
-
namespace: "kyro"
|
|
1923
|
-
});
|
|
1924
|
-
}
|
|
1925
|
-
return createNodeStorage({
|
|
1926
|
-
namespace: "kyro",
|
|
1927
|
-
encryption: encryptionOptions.enabled,
|
|
1928
|
-
secret
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
async function createAuthStorage(config) {
|
|
1932
|
-
const storageConfig = {
|
|
1933
|
-
...config,
|
|
1934
|
-
encryption: {
|
|
1935
|
-
enabled: true,
|
|
1936
|
-
algorithm: config.encryption?.algorithm
|
|
1937
|
-
}
|
|
1938
|
-
};
|
|
1939
|
-
return createStorage3(storageConfig);
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
// src/index.ts
|
|
1943
|
-
chunkB6X3LN25_cjs.init_secret();
|
|
1944
|
-
|
|
1945
|
-
Object.defineProperty(exports, "RedisAuthAdapter", {
|
|
1946
|
-
enumerable: true,
|
|
1947
|
-
get: function () { return chunkSHTTJMLT_cjs.RedisAuthAdapter; }
|
|
1948
|
-
});
|
|
1949
|
-
Object.defineProperty(exports, "allSettingsGlobals", {
|
|
1950
|
-
enumerable: true,
|
|
1951
|
-
get: function () { return chunkPHJRNPHY_cjs.allSettingsGlobals; }
|
|
1952
|
-
});
|
|
1953
|
-
Object.defineProperty(exports, "blogCollections", {
|
|
1954
|
-
enumerable: true,
|
|
1955
|
-
get: function () { return chunkPHJRNPHY_cjs.blogCollections; }
|
|
1956
|
-
});
|
|
1957
|
-
Object.defineProperty(exports, "blogGlobals", {
|
|
1958
|
-
enumerable: true,
|
|
1959
|
-
get: function () { return chunkPHJRNPHY_cjs.blogGlobals; }
|
|
1960
|
-
});
|
|
1961
|
-
Object.defineProperty(exports, "coreSettingsGlobals", {
|
|
1962
|
-
enumerable: true,
|
|
1963
|
-
get: function () { return chunkPHJRNPHY_cjs.coreSettingsGlobals; }
|
|
1964
|
-
});
|
|
1965
|
-
Object.defineProperty(exports, "createTemplateConfig", {
|
|
1966
|
-
enumerable: true,
|
|
1967
|
-
get: function () { return chunkPHJRNPHY_cjs.createTemplateConfig; }
|
|
1968
|
-
});
|
|
1969
|
-
Object.defineProperty(exports, "ecommerceCollections", {
|
|
1970
|
-
enumerable: true,
|
|
1971
|
-
get: function () { return chunkPHJRNPHY_cjs.ecommerceCollections; }
|
|
1972
|
-
});
|
|
1973
|
-
Object.defineProperty(exports, "ecommerceGlobals", {
|
|
1974
|
-
enumerable: true,
|
|
1975
|
-
get: function () { return chunkPHJRNPHY_cjs.ecommerceGlobals; }
|
|
1976
|
-
});
|
|
1977
|
-
Object.defineProperty(exports, "kitchenSinkCollections", {
|
|
1978
|
-
enumerable: true,
|
|
1979
|
-
get: function () { return chunkPHJRNPHY_cjs.kitchenSinkCollections; }
|
|
1980
|
-
});
|
|
1981
|
-
Object.defineProperty(exports, "mediaCollections", {
|
|
1982
|
-
enumerable: true,
|
|
1983
|
-
get: function () { return chunkPHJRNPHY_cjs.mediaCollections; }
|
|
1984
|
-
});
|
|
1985
|
-
Object.defineProperty(exports, "minimalCollections", {
|
|
1986
|
-
enumerable: true,
|
|
1987
|
-
get: function () { return chunkPHJRNPHY_cjs.minimalCollections; }
|
|
1988
|
-
});
|
|
1989
|
-
Object.defineProperty(exports, "templateCollections", {
|
|
1990
|
-
enumerable: true,
|
|
1991
|
-
get: function () { return chunkPHJRNPHY_cjs.templateCollections; }
|
|
1992
|
-
});
|
|
1993
|
-
Object.defineProperty(exports, "kyro", {
|
|
1994
|
-
enumerable: true,
|
|
1995
|
-
get: function () { return chunkU3VVLYXG_cjs.kyro; }
|
|
1996
|
-
});
|
|
1997
|
-
Object.defineProperty(exports, "ConfigValidationError", {
|
|
1998
|
-
enumerable: true,
|
|
1999
|
-
get: function () { return chunk74YSDAWE_cjs.ConfigValidationError; }
|
|
2000
|
-
});
|
|
2001
|
-
Object.defineProperty(exports, "Kyro", {
|
|
2002
|
-
enumerable: true,
|
|
2003
|
-
get: function () { return chunk74YSDAWE_cjs.Kyro; }
|
|
2004
|
-
});
|
|
2005
|
-
Object.defineProperty(exports, "LocalAdapter", {
|
|
2006
|
-
enumerable: true,
|
|
2007
|
-
get: function () { return chunk74YSDAWE_cjs.LocalAdapter; }
|
|
2008
|
-
});
|
|
2009
|
-
Object.defineProperty(exports, "Registry", {
|
|
2010
|
-
enumerable: true,
|
|
2011
|
-
get: function () { return chunk74YSDAWE_cjs.Registry; }
|
|
2012
|
-
});
|
|
2013
|
-
Object.defineProperty(exports, "collectionToCreateZod", {
|
|
2014
|
-
enumerable: true,
|
|
2015
|
-
get: function () { return chunk74YSDAWE_cjs.collectionToCreateZod; }
|
|
2016
|
-
});
|
|
2017
|
-
Object.defineProperty(exports, "collectionToUpdateZod", {
|
|
2018
|
-
enumerable: true,
|
|
2019
|
-
get: function () { return chunk74YSDAWE_cjs.collectionToUpdateZod; }
|
|
2020
|
-
});
|
|
2021
|
-
Object.defineProperty(exports, "collectionToWhereZod", {
|
|
2022
|
-
enumerable: true,
|
|
2023
|
-
get: function () { return chunk74YSDAWE_cjs.collectionToWhereZod; }
|
|
2024
|
-
});
|
|
2025
|
-
Object.defineProperty(exports, "collectionToZod", {
|
|
2026
|
-
enumerable: true,
|
|
2027
|
-
get: function () { return chunk74YSDAWE_cjs.collectionToZod; }
|
|
2028
|
-
});
|
|
2029
|
-
Object.defineProperty(exports, "createKyro", {
|
|
2030
|
-
enumerable: true,
|
|
2031
|
-
get: function () { return chunk74YSDAWE_cjs.createKyro; }
|
|
2032
|
-
});
|
|
2033
|
-
Object.defineProperty(exports, "createLocalAdapter", {
|
|
2034
|
-
enumerable: true,
|
|
2035
|
-
get: function () { return chunk74YSDAWE_cjs.createLocalAdapter; }
|
|
2036
|
-
});
|
|
2037
|
-
Object.defineProperty(exports, "createRegistry", {
|
|
2038
|
-
enumerable: true,
|
|
2039
|
-
get: function () { return chunk74YSDAWE_cjs.createRegistry; }
|
|
2040
|
-
});
|
|
2041
|
-
Object.defineProperty(exports, "fieldToZod", {
|
|
2042
|
-
enumerable: true,
|
|
2043
|
-
get: function () { return chunk74YSDAWE_cjs.fieldToZod; }
|
|
2044
|
-
});
|
|
2045
|
-
Object.defineProperty(exports, "getRegistry", {
|
|
2046
|
-
enumerable: true,
|
|
2047
|
-
get: function () { return chunk74YSDAWE_cjs.getRegistry; }
|
|
2048
|
-
});
|
|
2049
|
-
Object.defineProperty(exports, "globalToZod", {
|
|
2050
|
-
enumerable: true,
|
|
2051
|
-
get: function () { return chunk74YSDAWE_cjs.globalToZod; }
|
|
2052
|
-
});
|
|
2053
|
-
Object.defineProperty(exports, "resetRegistry", {
|
|
2054
|
-
enumerable: true,
|
|
2055
|
-
get: function () { return chunk74YSDAWE_cjs.resetRegistry; }
|
|
2056
|
-
});
|
|
2057
|
-
Object.defineProperty(exports, "validateCollection", {
|
|
2058
|
-
enumerable: true,
|
|
2059
|
-
get: function () { return chunk74YSDAWE_cjs.validateCollection; }
|
|
2060
|
-
});
|
|
2061
|
-
Object.defineProperty(exports, "validateConfig", {
|
|
2062
|
-
enumerable: true,
|
|
2063
|
-
get: function () { return chunk74YSDAWE_cjs.validateConfig; }
|
|
2064
|
-
});
|
|
2065
|
-
Object.defineProperty(exports, "validateFields", {
|
|
2066
|
-
enumerable: true,
|
|
2067
|
-
get: function () { return chunk74YSDAWE_cjs.validateFields; }
|
|
2068
|
-
});
|
|
2069
|
-
Object.defineProperty(exports, "validateGlobal", {
|
|
2070
|
-
enumerable: true,
|
|
2071
|
-
get: function () { return chunk74YSDAWE_cjs.validateGlobal; }
|
|
2072
|
-
});
|
|
2073
|
-
Object.defineProperty(exports, "autoBootstrap", {
|
|
2074
|
-
enumerable: true,
|
|
2075
|
-
get: function () { return chunk5GFQPHGT_cjs.autoBootstrap; }
|
|
2076
|
-
});
|
|
2077
|
-
Object.defineProperty(exports, "bootstrapAdmin", {
|
|
2078
|
-
enumerable: true,
|
|
2079
|
-
get: function () { return chunk5GFQPHGT_cjs.bootstrapAdmin; }
|
|
2080
|
-
});
|
|
2081
|
-
Object.defineProperty(exports, "bootstrapWithRetry", {
|
|
2082
|
-
enumerable: true,
|
|
2083
|
-
get: function () { return chunk5GFQPHGT_cjs.bootstrapWithRetry; }
|
|
2084
|
-
});
|
|
2085
|
-
Object.defineProperty(exports, "getBootstrapFromEnv", {
|
|
2086
|
-
enumerable: true,
|
|
2087
|
-
get: function () { return chunk5GFQPHGT_cjs.getBootstrapFromEnv; }
|
|
2088
|
-
});
|
|
2089
|
-
Object.defineProperty(exports, "CSSGenerator", {
|
|
2090
|
-
enumerable: true,
|
|
2091
|
-
get: function () { return chunkN4H37VN4_cjs.CSSGenerator; }
|
|
2092
|
-
});
|
|
2093
|
-
Object.defineProperty(exports, "createAdminStyling", {
|
|
2094
|
-
enumerable: true,
|
|
2095
|
-
get: function () { return chunkN4H37VN4_cjs.createAdminStyling; }
|
|
2096
|
-
});
|
|
2097
|
-
Object.defineProperty(exports, "defaultDarkTheme", {
|
|
2098
|
-
enumerable: true,
|
|
2099
|
-
get: function () { return chunkN4H37VN4_cjs.defaultDarkTheme; }
|
|
2100
|
-
});
|
|
2101
|
-
Object.defineProperty(exports, "defaultFieldStyling", {
|
|
2102
|
-
enumerable: true,
|
|
2103
|
-
get: function () { return chunkN4H37VN4_cjs.defaultFieldStyling; }
|
|
2104
|
-
});
|
|
2105
|
-
Object.defineProperty(exports, "defaultLightTheme", {
|
|
2106
|
-
enumerable: true,
|
|
2107
|
-
get: function () { return chunkN4H37VN4_cjs.defaultLightTheme; }
|
|
2108
|
-
});
|
|
2109
|
-
Object.defineProperty(exports, "ecommerce2026Theme", {
|
|
2110
|
-
enumerable: true,
|
|
2111
|
-
get: function () { return chunkN4H37VN4_cjs.ecommerce2026Theme; }
|
|
2112
|
-
});
|
|
2113
|
-
Object.defineProperty(exports, "generateCSSVariables", {
|
|
2114
|
-
enumerable: true,
|
|
2115
|
-
get: function () { return chunkN4H37VN4_cjs.generateCSSVariables; }
|
|
2116
|
-
});
|
|
2117
|
-
Object.defineProperty(exports, "generateTailwindConfig", {
|
|
2118
|
-
enumerable: true,
|
|
2119
|
-
get: function () { return chunkN4H37VN4_cjs.generateTailwindConfig; }
|
|
2120
|
-
});
|
|
2121
|
-
Object.defineProperty(exports, "ALL_FIELD_TYPES", {
|
|
2122
|
-
enumerable: true,
|
|
2123
|
-
get: function () { return chunkOJ2AM75W_cjs.ALL_FIELD_TYPES; }
|
|
2124
|
-
});
|
|
2125
|
-
Object.defineProperty(exports, "COMPLEX_FIELD_TYPES", {
|
|
2126
|
-
enumerable: true,
|
|
2127
|
-
get: function () { return chunkOJ2AM75W_cjs.COMPLEX_FIELD_TYPES; }
|
|
2128
|
-
});
|
|
2129
|
-
Object.defineProperty(exports, "LAYOUT_FIELD_TYPES", {
|
|
2130
|
-
enumerable: true,
|
|
2131
|
-
get: function () { return chunkOJ2AM75W_cjs.LAYOUT_FIELD_TYPES; }
|
|
2132
|
-
});
|
|
2133
|
-
Object.defineProperty(exports, "PRIMITIVE_FIELD_TYPES", {
|
|
2134
|
-
enumerable: true,
|
|
2135
|
-
get: function () { return chunkOJ2AM75W_cjs.PRIMITIVE_FIELD_TYPES; }
|
|
2136
|
-
});
|
|
2137
|
-
Object.defineProperty(exports, "RELATIONAL_FIELD_TYPES", {
|
|
2138
|
-
enumerable: true,
|
|
2139
|
-
get: function () { return chunkOJ2AM75W_cjs.RELATIONAL_FIELD_TYPES; }
|
|
2140
|
-
});
|
|
2141
|
-
Object.defineProperty(exports, "isArrayField", {
|
|
2142
|
-
enumerable: true,
|
|
2143
|
-
get: function () { return chunkOJ2AM75W_cjs.isArrayField; }
|
|
2144
|
-
});
|
|
2145
|
-
Object.defineProperty(exports, "isBlocksField", {
|
|
2146
|
-
enumerable: true,
|
|
2147
|
-
get: function () { return chunkOJ2AM75W_cjs.isBlocksField; }
|
|
2148
|
-
});
|
|
2149
|
-
Object.defineProperty(exports, "isGroupField", {
|
|
2150
|
-
enumerable: true,
|
|
2151
|
-
get: function () { return chunkOJ2AM75W_cjs.isGroupField; }
|
|
2152
|
-
});
|
|
2153
|
-
Object.defineProperty(exports, "isImageField", {
|
|
2154
|
-
enumerable: true,
|
|
2155
|
-
get: function () { return chunkOJ2AM75W_cjs.isImageField; }
|
|
2156
|
-
});
|
|
2157
|
-
Object.defineProperty(exports, "isLayoutField", {
|
|
2158
|
-
enumerable: true,
|
|
2159
|
-
get: function () { return chunkOJ2AM75W_cjs.isLayoutField; }
|
|
2160
|
-
});
|
|
2161
|
-
Object.defineProperty(exports, "isNumberField", {
|
|
2162
|
-
enumerable: true,
|
|
2163
|
-
get: function () { return chunkOJ2AM75W_cjs.isNumberField; }
|
|
2164
|
-
});
|
|
2165
|
-
Object.defineProperty(exports, "isRelationshipField", {
|
|
2166
|
-
enumerable: true,
|
|
2167
|
-
get: function () { return chunkOJ2AM75W_cjs.isRelationshipField; }
|
|
2168
|
-
});
|
|
2169
|
-
Object.defineProperty(exports, "isRichTextField", {
|
|
2170
|
-
enumerable: true,
|
|
2171
|
-
get: function () { return chunkOJ2AM75W_cjs.isRichTextField; }
|
|
2172
|
-
});
|
|
2173
|
-
Object.defineProperty(exports, "isSelectField", {
|
|
2174
|
-
enumerable: true,
|
|
2175
|
-
get: function () { return chunkOJ2AM75W_cjs.isSelectField; }
|
|
2176
|
-
});
|
|
2177
|
-
Object.defineProperty(exports, "isTextField", {
|
|
2178
|
-
enumerable: true,
|
|
2179
|
-
get: function () { return chunkOJ2AM75W_cjs.isTextField; }
|
|
2180
|
-
});
|
|
2181
|
-
Object.defineProperty(exports, "isUploadField", {
|
|
2182
|
-
enumerable: true,
|
|
2183
|
-
get: function () { return chunkOJ2AM75W_cjs.isUploadField; }
|
|
2184
|
-
});
|
|
2185
|
-
Object.defineProperty(exports, "normalizeRichTextValue", {
|
|
2186
|
-
enumerable: true,
|
|
2187
|
-
get: function () { return chunkOJ2AM75W_cjs.normalizeRichTextValue; }
|
|
2188
|
-
});
|
|
2189
|
-
Object.defineProperty(exports, "renderRichText", {
|
|
2190
|
-
enumerable: true,
|
|
2191
|
-
get: function () { return chunkOJ2AM75W_cjs.renderRichText; }
|
|
2192
|
-
});
|
|
2193
|
-
Object.defineProperty(exports, "richTextStyles", {
|
|
2194
|
-
enumerable: true,
|
|
2195
|
-
get: function () { return chunkOJ2AM75W_cjs.richTextStyles; }
|
|
2196
|
-
});
|
|
2197
|
-
Object.defineProperty(exports, "createContext", {
|
|
2198
|
-
enumerable: true,
|
|
2199
|
-
get: function () { return chunkTQG7G7YI_cjs.createContext; }
|
|
2200
|
-
});
|
|
2201
|
-
Object.defineProperty(exports, "createCountProcedure", {
|
|
2202
|
-
enumerable: true,
|
|
2203
|
-
get: function () { return chunkTQG7G7YI_cjs.createCountProcedure; }
|
|
2204
|
-
});
|
|
2205
|
-
Object.defineProperty(exports, "createCreateProcedure", {
|
|
2206
|
-
enumerable: true,
|
|
2207
|
-
get: function () { return chunkTQG7G7YI_cjs.createCreateProcedure; }
|
|
2208
|
-
});
|
|
2209
|
-
Object.defineProperty(exports, "createDeleteProcedure", {
|
|
2210
|
-
enumerable: true,
|
|
2211
|
-
get: function () { return chunkTQG7G7YI_cjs.createDeleteProcedure; }
|
|
2212
|
-
});
|
|
2213
|
-
Object.defineProperty(exports, "createDynamicRouter", {
|
|
2214
|
-
enumerable: true,
|
|
2215
|
-
get: function () { return chunkTQG7G7YI_cjs.createDynamicRouter; }
|
|
2216
|
-
});
|
|
2217
|
-
Object.defineProperty(exports, "createFindByIDProcedure", {
|
|
2218
|
-
enumerable: true,
|
|
2219
|
-
get: function () { return chunkTQG7G7YI_cjs.createFindByIDProcedure; }
|
|
2220
|
-
});
|
|
2221
|
-
Object.defineProperty(exports, "createFindProcedure", {
|
|
2222
|
-
enumerable: true,
|
|
2223
|
-
get: function () { return chunkTQG7G7YI_cjs.createFindProcedure; }
|
|
2224
|
-
});
|
|
2225
|
-
Object.defineProperty(exports, "createKyroServer", {
|
|
2226
|
-
enumerable: true,
|
|
2227
|
-
get: function () { return chunkTQG7G7YI_cjs.createKyroServer; }
|
|
2228
|
-
});
|
|
2229
|
-
Object.defineProperty(exports, "createUpdateProcedure", {
|
|
2230
|
-
enumerable: true,
|
|
2231
|
-
get: function () { return chunkTQG7G7YI_cjs.createUpdateProcedure; }
|
|
2232
|
-
});
|
|
2233
|
-
Object.defineProperty(exports, "buildGraphQLSchema", {
|
|
2234
|
-
enumerable: true,
|
|
2235
|
-
get: function () { return chunkN4GN6Q3V_cjs.buildGraphQLSchema; }
|
|
2236
|
-
});
|
|
2237
|
-
Object.defineProperty(exports, "createGraphQLSchema", {
|
|
2238
|
-
enumerable: true,
|
|
2239
|
-
get: function () { return chunkN4GN6Q3V_cjs.createGraphQLSchema; }
|
|
2240
|
-
});
|
|
2241
|
-
Object.defineProperty(exports, "AuditLogger", {
|
|
2242
|
-
enumerable: true,
|
|
2243
|
-
get: function () { return chunkB6X3LN25_cjs.AuditLogger; }
|
|
2244
|
-
});
|
|
2245
|
-
Object.defineProperty(exports, "InMemoryAuditLogger", {
|
|
2246
|
-
enumerable: true,
|
|
2247
|
-
get: function () { return chunkB6X3LN25_cjs.InMemoryAuditLogger; }
|
|
2248
|
-
});
|
|
2249
|
-
Object.defineProperty(exports, "InMemoryRateLimiter", {
|
|
2250
|
-
enumerable: true,
|
|
2251
|
-
get: function () { return chunkB6X3LN25_cjs.InMemoryRateLimiter; }
|
|
2252
|
-
});
|
|
2253
|
-
Object.defineProperty(exports, "MediaService", {
|
|
2254
|
-
enumerable: true,
|
|
2255
|
-
get: function () { return chunkB6X3LN25_cjs.MediaService; }
|
|
2256
|
-
});
|
|
2257
|
-
Object.defineProperty(exports, "createAuditContext", {
|
|
2258
|
-
enumerable: true,
|
|
2259
|
-
get: function () { return chunkB6X3LN25_cjs.createAuditContext; }
|
|
2260
|
-
});
|
|
2261
|
-
Object.defineProperty(exports, "createHonoApp", {
|
|
2262
|
-
enumerable: true,
|
|
2263
|
-
get: function () { return chunkB6X3LN25_cjs.createHonoApp; }
|
|
2264
|
-
});
|
|
2265
|
-
Object.defineProperty(exports, "createLocalStorage", {
|
|
2266
|
-
enumerable: true,
|
|
2267
|
-
get: function () { return chunkB6X3LN25_cjs.createLocalStorage; }
|
|
2268
|
-
});
|
|
2269
|
-
Object.defineProperty(exports, "createRESTAPI", {
|
|
2270
|
-
enumerable: true,
|
|
2271
|
-
get: function () { return chunkB6X3LN25_cjs.createRESTAPI; }
|
|
2272
|
-
});
|
|
2273
|
-
Object.defineProperty(exports, "getAppSecret", {
|
|
2274
|
-
enumerable: true,
|
|
2275
|
-
get: function () { return chunkB6X3LN25_cjs.getAppSecret; }
|
|
2276
|
-
});
|
|
2277
|
-
Object.defineProperty(exports, "getEncryptionKey", {
|
|
2278
|
-
enumerable: true,
|
|
2279
|
-
get: function () { return chunkB6X3LN25_cjs.getEncryptionKey; }
|
|
2280
|
-
});
|
|
2281
|
-
Object.defineProperty(exports, "getSessionConfig", {
|
|
2282
|
-
enumerable: true,
|
|
2283
|
-
get: function () { return chunkB6X3LN25_cjs.getSessionConfig; }
|
|
2284
|
-
});
|
|
2285
|
-
Object.defineProperty(exports, "loadSecrets", {
|
|
2286
|
-
enumerable: true,
|
|
2287
|
-
get: function () { return chunkB6X3LN25_cjs.loadSecrets; }
|
|
2288
|
-
});
|
|
2289
|
-
Object.defineProperty(exports, "resolveProvider", {
|
|
2290
|
-
enumerable: true,
|
|
2291
|
-
get: function () { return chunkB6X3LN25_cjs.resolveProvider; }
|
|
2292
|
-
});
|
|
2293
|
-
Object.defineProperty(exports, "setDbAdapter", {
|
|
2294
|
-
enumerable: true,
|
|
2295
|
-
get: function () { return chunkB6X3LN25_cjs.setDbAdapter; }
|
|
2296
|
-
});
|
|
2297
|
-
Object.defineProperty(exports, "ConfigService", {
|
|
2298
|
-
enumerable: true,
|
|
2299
|
-
get: function () { return chunkVKREAIBA_cjs.ConfigService; }
|
|
2300
|
-
});
|
|
2301
|
-
Object.defineProperty(exports, "EmailTransport", {
|
|
2302
|
-
enumerable: true,
|
|
2303
|
-
get: function () { return chunkVKREAIBA_cjs.EmailTransport; }
|
|
2304
|
-
});
|
|
2305
|
-
Object.defineProperty(exports, "PasswordPolicy", {
|
|
2306
|
-
enumerable: true,
|
|
2307
|
-
get: function () { return chunkVKREAIBA_cjs.PasswordPolicy; }
|
|
2308
|
-
});
|
|
2309
|
-
Object.defineProperty(exports, "SQLiteAuthAdapter", {
|
|
2310
|
-
enumerable: true,
|
|
2311
|
-
get: function () { return chunkIDVRRRAK_cjs.SQLiteAuthAdapter; }
|
|
2312
|
-
});
|
|
2313
|
-
Object.defineProperty(exports, "ALL_WEBHOOK_EVENTS", {
|
|
2314
|
-
enumerable: true,
|
|
2315
|
-
get: function () { return chunkLNTFRAHF_cjs.ALL_WEBHOOK_EVENTS; }
|
|
2316
|
-
});
|
|
2317
|
-
Object.defineProperty(exports, "WEBHOOK_COLLECTION", {
|
|
2318
|
-
enumerable: true,
|
|
2319
|
-
get: function () { return chunkLNTFRAHF_cjs.WEBHOOK_COLLECTION; }
|
|
2320
|
-
});
|
|
2321
|
-
Object.defineProperty(exports, "WEBHOOK_DELIVERY_COLLECTION", {
|
|
2322
|
-
enumerable: true,
|
|
2323
|
-
get: function () { return chunkLNTFRAHF_cjs.WEBHOOK_DELIVERY_COLLECTION; }
|
|
2324
|
-
});
|
|
2325
|
-
Object.defineProperty(exports, "WEBHOOK_EVENTS", {
|
|
2326
|
-
enumerable: true,
|
|
2327
|
-
get: function () { return chunkLNTFRAHF_cjs.WEBHOOK_EVENTS; }
|
|
2328
|
-
});
|
|
2329
|
-
Object.defineProperty(exports, "WebhookService", {
|
|
2330
|
-
enumerable: true,
|
|
2331
|
-
get: function () { return chunkLNTFRAHF_cjs.WebhookService; }
|
|
2332
|
-
});
|
|
2333
|
-
Object.defineProperty(exports, "buildDeliveryRecord", {
|
|
2334
|
-
enumerable: true,
|
|
2335
|
-
get: function () { return chunkLNTFRAHF_cjs.buildDeliveryRecord; }
|
|
2336
|
-
});
|
|
2337
|
-
Object.defineProperty(exports, "createTestPayload", {
|
|
2338
|
-
enumerable: true,
|
|
2339
|
-
get: function () { return chunkLNTFRAHF_cjs.createTestPayload; }
|
|
2340
|
-
});
|
|
2341
|
-
Object.defineProperty(exports, "createWebhookService", {
|
|
2342
|
-
enumerable: true,
|
|
2343
|
-
get: function () { return chunkLNTFRAHF_cjs.createWebhookService; }
|
|
2344
|
-
});
|
|
2345
|
-
Object.defineProperty(exports, "deliverWebhook", {
|
|
2346
|
-
enumerable: true,
|
|
2347
|
-
get: function () { return chunkLNTFRAHF_cjs.deliverWebhook; }
|
|
2348
|
-
});
|
|
2349
|
-
Object.defineProperty(exports, "deliverWithRetry", {
|
|
2350
|
-
enumerable: true,
|
|
2351
|
-
get: function () { return chunkLNTFRAHF_cjs.deliverWithRetry; }
|
|
2352
|
-
});
|
|
2353
|
-
Object.defineProperty(exports, "generateWebhookSecret", {
|
|
2354
|
-
enumerable: true,
|
|
2355
|
-
get: function () { return chunkLNTFRAHF_cjs.generateWebhookSecret; }
|
|
2356
|
-
});
|
|
2357
|
-
Object.defineProperty(exports, "signPayload", {
|
|
2358
|
-
enumerable: true,
|
|
2359
|
-
get: function () { return chunkLNTFRAHF_cjs.signPayload; }
|
|
2360
|
-
});
|
|
2361
|
-
Object.defineProperty(exports, "evaluateAccess", {
|
|
2362
|
-
enumerable: true,
|
|
2363
|
-
get: function () { return chunk4OCMVGEY_cjs.evaluateAccess; }
|
|
2364
|
-
});
|
|
2365
|
-
Object.defineProperty(exports, "getWhereClause", {
|
|
2366
|
-
enumerable: true,
|
|
2367
|
-
get: function () { return chunk4OCMVGEY_cjs.getWhereClause; }
|
|
2368
|
-
});
|
|
2369
|
-
Object.defineProperty(exports, "mergeWhereClauses", {
|
|
2370
|
-
enumerable: true,
|
|
2371
|
-
get: function () { return chunk4OCMVGEY_cjs.mergeWhereClauses; }
|
|
2372
|
-
});
|
|
2373
|
-
Object.defineProperty(exports, "KyroPubSub", {
|
|
2374
|
-
enumerable: true,
|
|
2375
|
-
get: function () { return chunkEEJUFDMF_cjs.KyroPubSub; }
|
|
2376
|
-
});
|
|
2377
|
-
Object.defineProperty(exports, "KyroWSServer", {
|
|
2378
|
-
enumerable: true,
|
|
2379
|
-
get: function () { return chunkEEJUFDMF_cjs.KyroWSServer; }
|
|
2380
|
-
});
|
|
2381
|
-
Object.defineProperty(exports, "PubSub", {
|
|
2382
|
-
enumerable: true,
|
|
2383
|
-
get: function () { return chunkEEJUFDMF_cjs.PubSub; }
|
|
2384
|
-
});
|
|
2385
|
-
Object.defineProperty(exports, "createWSServer", {
|
|
2386
|
-
enumerable: true,
|
|
2387
|
-
get: function () { return chunkEEJUFDMF_cjs.createWSServer; }
|
|
2388
|
-
});
|
|
2389
|
-
Object.defineProperty(exports, "DrizzleAdapter", {
|
|
2390
|
-
enumerable: true,
|
|
2391
|
-
get: function () { return chunkOIRG6ZRV_cjs.DrizzleAdapter; }
|
|
2392
|
-
});
|
|
2393
|
-
Object.defineProperty(exports, "collectionToDrizzleSchema", {
|
|
2394
|
-
enumerable: true,
|
|
2395
|
-
get: function () { return chunkOIRG6ZRV_cjs.collectionToDrizzleSchema; }
|
|
2396
|
-
});
|
|
2397
|
-
Object.defineProperty(exports, "createDatabase", {
|
|
2398
|
-
enumerable: true,
|
|
2399
|
-
get: function () { return chunkOIRG6ZRV_cjs.createDatabase; }
|
|
2400
|
-
});
|
|
2401
|
-
Object.defineProperty(exports, "createDrizzleAdapter", {
|
|
2402
|
-
enumerable: true,
|
|
2403
|
-
get: function () { return chunkOIRG6ZRV_cjs.createDrizzleAdapter; }
|
|
2404
|
-
});
|
|
2405
|
-
Object.defineProperty(exports, "fieldToDrizzleType", {
|
|
2406
|
-
enumerable: true,
|
|
2407
|
-
get: function () { return chunkOIRG6ZRV_cjs.fieldToDrizzleType; }
|
|
2408
|
-
});
|
|
2409
|
-
Object.defineProperty(exports, "runMigrations", {
|
|
2410
|
-
enumerable: true,
|
|
2411
|
-
get: function () { return chunkOIRG6ZRV_cjs.runMigrations; }
|
|
2412
|
-
});
|
|
2413
|
-
Object.defineProperty(exports, "seedDefaultRoles", {
|
|
2414
|
-
enumerable: true,
|
|
2415
|
-
get: function () { return chunkOIRG6ZRV_cjs.seedDefaultRoles; }
|
|
2416
|
-
});
|
|
2417
|
-
Object.defineProperty(exports, "PostgresAuthAdapter", {
|
|
2418
|
-
enumerable: true,
|
|
2419
|
-
get: function () { return chunk7OS7TX2Q_cjs.PostgresAuthAdapter; }
|
|
2420
|
-
});
|
|
2421
|
-
Object.defineProperty(exports, "MongoDBAdapter", {
|
|
2422
|
-
enumerable: true,
|
|
2423
|
-
get: function () { return chunkTHBQG64D_cjs.MongoDBAdapter; }
|
|
2424
|
-
});
|
|
2425
|
-
Object.defineProperty(exports, "createMongoDBAdapter", {
|
|
2426
|
-
enumerable: true,
|
|
2427
|
-
get: function () { return chunkTHBQG64D_cjs.createMongoDBAdapter; }
|
|
2428
|
-
});
|
|
2429
|
-
Object.defineProperty(exports, "MongoDBAuthAdapter", {
|
|
2430
|
-
enumerable: true,
|
|
2431
|
-
get: function () { return chunkGXFOGU7N_cjs.MongoDBAuthAdapter; }
|
|
2432
|
-
});
|
|
2433
|
-
Object.defineProperty(exports, "AbstractBaseAdapter", {
|
|
2434
|
-
enumerable: true,
|
|
2435
|
-
get: function () { return chunkGUUB5EAG_cjs.AbstractBaseAdapter; }
|
|
2436
|
-
});
|
|
2437
|
-
Object.defineProperty(exports, "z", {
|
|
2438
|
-
enumerable: true,
|
|
2439
|
-
get: function () { return zod.z; }
|
|
2440
|
-
});
|
|
2441
|
-
exports.AccountLockout = AccountLockout;
|
|
2442
|
-
exports.AnalyticsPlugin = AnalyticsPlugin;
|
|
2443
|
-
exports.Auth = Auth;
|
|
2444
|
-
exports.CommentsPlugin = CommentsPlugin;
|
|
2445
|
-
exports.InMemoryAccountLockout = InMemoryAccountLockout;
|
|
2446
|
-
exports.InMemoryAuthAdapter = InMemoryAuthAdapter;
|
|
2447
|
-
exports.KyroPlugin = KyroPlugin;
|
|
2448
|
-
exports.PluginManager = PluginManager;
|
|
2449
|
-
exports.RateLimiter = RateLimiter;
|
|
2450
|
-
exports.ReviewsPlugin = ReviewsPlugin;
|
|
2451
|
-
exports.SEOPLugin = SEOPLugin;
|
|
2452
|
-
exports.VersionManager = VersionManager;
|
|
2453
|
-
exports.WishlistPlugin = WishlistPlugin;
|
|
2454
|
-
exports.authConfig = authConfig;
|
|
2455
|
-
exports.createAuth = createAuth;
|
|
2456
|
-
exports.createAuthConfig = createAuthConfig;
|
|
2457
|
-
exports.createAuthStorage = createAuthStorage;
|
|
2458
|
-
exports.createStorage = createStorage3;
|
|
2459
|
-
exports.createVersionManager = createVersionManager;
|
|
2460
|
-
exports.defineConfig = defineConfig;
|
|
2461
|
-
exports.defineKyroConfig = defineKyroConfig;
|
|
2462
|
-
exports.generateAnalyticsTags = generateAnalyticsTags;
|
|
2463
|
-
exports.generateSeoTags = generateSeoTags;
|
|
2464
|
-
exports.getDefaultDraftPublishConfig = getDefaultDraftPublishConfig;
|
|
2465
|
-
exports.getPaymentConfig = getPaymentConfig;
|
|
2466
|
-
exports.getPaymentConfigFromSettings = getPaymentConfigFromSettings;
|
|
2467
|
-
exports.getSocialLinks = getSocialLinks;
|
|
2468
|
-
exports.getSocialLinksFromSettings = getSocialLinksFromSettings;
|
|
2469
|
-
exports.getStoreConfig = getStoreConfig;
|
|
2470
|
-
exports.getStoreConfigFromSettings = getStoreConfigFromSettings;
|
|
2471
|
-
exports.isArchived = isArchived;
|
|
2472
|
-
exports.isDraft = isDraft;
|
|
2473
|
-
exports.isPublished = isPublished;
|
|
2474
|
-
exports.presetPlugins = presetPlugins;
|
|
2475
|
-
exports.runFieldHooks = runFieldHooks;
|
|
2476
|
-
exports.runHooks = runHooks;
|
|
2477
|
-
//# sourceMappingURL=index.cjs.map
|
|
2478
|
-
//# sourceMappingURL=index.cjs.map
|
|
42
|
+
<script defer data-domain="${r}" src="https://plausible.io/js/script.js"></script>
|
|
43
|
+
`),o}var Mr={facebook:{label:"Facebook"},twitter:{label:"Twitter / X"},instagram:{label:"Instagram"},linkedin:{label:"LinkedIn"},youtube:{label:"YouTube"},tiktok:{label:"TikTok"},pinterest:{label:"Pinterest"},discord:{label:"Discord"},twitch:{label:"Twitch"},github:{label:"GitHub"},mastodon:{label:"Mastodon"}},Fr=["facebook","twitter","instagram","linkedin","youtube","tiktok","pinterest","discord","twitch","github","mastodon"];function Oe(s){if(!s)return [];let e=s.showAll===true,t=[];for(let r of Fr){let o=s[r];if(!o||["tiktok","pinterest","discord","twitch","github","mastodon"].includes(r)&&!e)continue;let n=Mr[r];t.push({platform:r,url:o,label:n?.label||r});}return t}async function Br(s,e){try{let t=await s.findOne({collection:"_globals_social-settings",where:{},draft:e?.draft??!1});return Oe(t)}catch{return []}}function He(s){return s?{storeName:s.storeName,storeEmail:s.storeEmail,storePhone:s.storePhone,address:s.address,currency:s.currency,tax:s.tax,shipping:s.shipping,orders:s.orders}:{}}async function Nr(s,e){try{let t=await s.findOne({collection:"_globals_store-settings",where:{},draft:e?.draft??!1});return He(t)}catch{return {}}}function _e(s){return s?{testMode:s.testMode,provider:s.provider,stripe:s.stripe,paypal:s.paypal,square:s.square,methods:s.methods,bankTransfer:s.bankTransfer}:{}}async function Kr(s,e){try{let t=await s.findOne({collection:"_globals_payment-settings",where:{},draft:e?.draft??!1});return _e(t)}catch{return {}}}async function G(s={}){let{namespace:e="kyro",ttl:t}=s,r=unstorage.createStorage({driver:$r__default.default({dbName:"kyro-cms",storeName:e})}),o=e?`${e}:`:"";return {storage:{getItem:async n=>{let a=`${o}${n}`,l=await r.getItem(a);if(l==null)return null;try{let c=JSON.parse(l);return c.expiry&&Date.now()>c.expiry?(await r.removeItem(a),null):c.value}catch{return l}},setItem:async(n,a)=>{let l=`${o}${n}`,c=JSON.stringify(t?{value:a,expiry:Date.now()+t}:{value:a});await r.setItem(l,c);},removeItem:async n=>{await r.removeItem(`${o}${n}`);}},cleanup:async()=>{await r.dispose?.();}}}function z(s){let e=s||process.env.APP_SECRET||process.env.AUTH_SECRET||"development-secret-key";return q__default.default.createHash("sha256").update(e).digest("hex")}function qr(s,e){let t=q__default.default.randomBytes(16),r=q__default.default.createCipheriv("aes-256-gcm",Buffer.from(e,"hex").subarray(0,32),t),o=r.update(s,"utf8","hex");o+=r.final("hex");let i=r.getAuthTag().toString("hex");return `${t.toString("hex")}:${i}:${o}`}function Qr(s,e){let[t,r,o]=s.split(":"),i=Buffer.from(t,"hex"),n=Buffer.from(r,"hex"),a=q__default.default.createDecipheriv("aes-256-gcm",Buffer.from(e,"hex").subarray(0,32),i);a.setAuthTag(n);let l=a.update(o,"hex","utf8");return l+=a.final("utf8"),l}async function Q(s={}){let{namespace:e="kyro",ttl:t,encryption:r=true,secret:o,basePath:i}=s,n=i?Me__default.default.join(i,".astro","kyro.json"):Me__default.default.join(process.cwd(),".astro","kyro.json"),a=unstorage.createStorage({driver:zr__default.default({base:n})}),l=r?z(o):null,c=e?`${e}:`:"";return {storage:{getItem:async g=>{let d=`${c}${g}`,u=await a.getItem(d);if(u==null)return null;try{let y=l?Qr(u,l):u,f=JSON.parse(y);return f.expiry&&Date.now()>f.expiry?(await a.removeItem(d),null):f.value}catch{return u}},setItem:async(g,d)=>{let u=`${c}${g}`,y=JSON.stringify(t?{value:d,expiry:Date.now()+t}:{value:d});await a.setItem(u,l?qr(y,l):y);},removeItem:async g=>{await a.removeItem(`${c}${g}`);}},cleanup:async()=>{await a.dispose?.();}}}async function Y(s){let{environment:e,adapter:t,connectionString:r,encryption:o}=s,i=process.env.APP_SECRET||process.env.AUTH_SECRET,n={enabled:o?.enabled??true,algorithm:o?.algorithm};return e==="browser"?G({namespace:"kyro"}):Q({namespace:"kyro",encryption:n.enabled,secret:i})}async function Fe(s){let e={...s,encryption:{enabled:true,algorithm:s.encryption?.algorithm}};return Y(e)}chunkKIW36TG7_cjs.l();Object.defineProperty(exports,"RedisAuthAdapter",{enumerable:true,get:function(){return chunkEQUQJBPP_cjs.a}});Object.defineProperty(exports,"allSettingsGlobals",{enumerable:true,get:function(){return chunkELICKLFM_cjs.P}});Object.defineProperty(exports,"blogCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.c}});Object.defineProperty(exports,"blogGlobals",{enumerable:true,get:function(){return chunkELICKLFM_cjs.d}});Object.defineProperty(exports,"coreSettingsGlobals",{enumerable:true,get:function(){return chunkELICKLFM_cjs.Q}});Object.defineProperty(exports,"createTemplateConfig",{enumerable:true,get:function(){return chunkELICKLFM_cjs.U}});Object.defineProperty(exports,"ecommerceCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.e}});Object.defineProperty(exports,"ecommerceGlobals",{enumerable:true,get:function(){return chunkELICKLFM_cjs.f}});Object.defineProperty(exports,"kitchenSinkCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.g}});Object.defineProperty(exports,"mediaCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.i}});Object.defineProperty(exports,"minimalCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.a}});Object.defineProperty(exports,"templateCollections",{enumerable:true,get:function(){return chunkELICKLFM_cjs.T}});Object.defineProperty(exports,"kyro",{enumerable:true,get:function(){return chunkL6CZYN3L_cjs.a}});Object.defineProperty(exports,"ConfigValidationError",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.a}});Object.defineProperty(exports,"Kyro",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.p}});Object.defineProperty(exports,"LocalAdapter",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.r}});Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.l}});Object.defineProperty(exports,"collectionToCreateZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.h}});Object.defineProperty(exports,"collectionToUpdateZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.i}});Object.defineProperty(exports,"collectionToWhereZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.j}});Object.defineProperty(exports,"collectionToZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.g}});Object.defineProperty(exports,"createKyro",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.q}});Object.defineProperty(exports,"createLocalAdapter",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.s}});Object.defineProperty(exports,"createRegistry",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.o}});Object.defineProperty(exports,"fieldToZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.f}});Object.defineProperty(exports,"getRegistry",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.m}});Object.defineProperty(exports,"globalToZod",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.k}});Object.defineProperty(exports,"resetRegistry",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.n}});Object.defineProperty(exports,"validateCollection",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.b}});Object.defineProperty(exports,"validateConfig",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.e}});Object.defineProperty(exports,"validateFields",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.d}});Object.defineProperty(exports,"validateGlobal",{enumerable:true,get:function(){return chunkR7DVVXXI_cjs.c}});Object.defineProperty(exports,"autoBootstrap",{enumerable:true,get:function(){return chunkUJNSOOYZ_cjs.d}});Object.defineProperty(exports,"bootstrapAdmin",{enumerable:true,get:function(){return chunkUJNSOOYZ_cjs.a}});Object.defineProperty(exports,"bootstrapWithRetry",{enumerable:true,get:function(){return chunkUJNSOOYZ_cjs.e}});Object.defineProperty(exports,"getBootstrapFromEnv",{enumerable:true,get:function(){return chunkUJNSOOYZ_cjs.c}});Object.defineProperty(exports,"CSSGenerator",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.a}});Object.defineProperty(exports,"createAdminStyling",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.g}});Object.defineProperty(exports,"defaultDarkTheme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.d}});Object.defineProperty(exports,"defaultFieldStyling",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.h}});Object.defineProperty(exports,"defaultLightTheme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.c}});Object.defineProperty(exports,"ecommerce2026Theme",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.e}});Object.defineProperty(exports,"generateCSSVariables",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.f}});Object.defineProperty(exports,"generateTailwindConfig",{enumerable:true,get:function(){return chunk2BTRHVT3_cjs.b}});Object.defineProperty(exports,"ALL_FIELD_TYPES",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.p}});Object.defineProperty(exports,"COMPLEX_FIELD_TYPES",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.m}});Object.defineProperty(exports,"LAYOUT_FIELD_TYPES",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.o}});Object.defineProperty(exports,"PRIMITIVE_FIELD_TYPES",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.l}});Object.defineProperty(exports,"RELATIONAL_FIELD_TYPES",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.n}});Object.defineProperty(exports,"isArrayField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.d}});Object.defineProperty(exports,"isBlocksField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.f}});Object.defineProperty(exports,"isGroupField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.e}});Object.defineProperty(exports,"isImageField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.h}});Object.defineProperty(exports,"isLayoutField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.k}});Object.defineProperty(exports,"isNumberField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.b}});Object.defineProperty(exports,"isRelationshipField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.c}});Object.defineProperty(exports,"isRichTextField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.i}});Object.defineProperty(exports,"isSelectField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.j}});Object.defineProperty(exports,"isTextField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.a}});Object.defineProperty(exports,"isUploadField",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.g}});Object.defineProperty(exports,"normalizeRichTextValue",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.s}});Object.defineProperty(exports,"renderRichText",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.t}});Object.defineProperty(exports,"richTextStyles",{enumerable:true,get:function(){return chunkQ4CSLXCO_cjs.r}});Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.a}});Object.defineProperty(exports,"createCountProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.g}});Object.defineProperty(exports,"createCreateProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.d}});Object.defineProperty(exports,"createDeleteProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.f}});Object.defineProperty(exports,"createDynamicRouter",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.h}});Object.defineProperty(exports,"createFindByIDProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.c}});Object.defineProperty(exports,"createFindProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.b}});Object.defineProperty(exports,"createKyroServer",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.i}});Object.defineProperty(exports,"createUpdateProcedure",{enumerable:true,get:function(){return chunkCVVW4LXZ_cjs.e}});Object.defineProperty(exports,"buildGraphQLSchema",{enumerable:true,get:function(){return chunkF7P36SLX_cjs.I}});Object.defineProperty(exports,"createGraphQLSchema",{enumerable:true,get:function(){return chunkF7P36SLX_cjs.J}});Object.defineProperty(exports,"AuditLogger",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.n}});Object.defineProperty(exports,"InMemoryAuditLogger",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.p}});Object.defineProperty(exports,"InMemoryRateLimiter",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.m}});Object.defineProperty(exports,"MediaService",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.r}});Object.defineProperty(exports,"createAuditContext",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.o}});Object.defineProperty(exports,"createHonoApp",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.s}});Object.defineProperty(exports,"createLocalStorage",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.e}});Object.defineProperty(exports,"createRESTAPI",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.t}});Object.defineProperty(exports,"getAppSecret",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.i}});Object.defineProperty(exports,"getEncryptionKey",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.j}});Object.defineProperty(exports,"getSessionConfig",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.k}});Object.defineProperty(exports,"loadSecrets",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.h}});Object.defineProperty(exports,"resolveProvider",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.d}});Object.defineProperty(exports,"setDbAdapter",{enumerable:true,get:function(){return chunkKIW36TG7_cjs.g}});Object.defineProperty(exports,"ConfigService",{enumerable:true,get:function(){return chunkAJAZ7D3W_cjs.a}});Object.defineProperty(exports,"EmailTransport",{enumerable:true,get:function(){return chunkAJAZ7D3W_cjs.b}});Object.defineProperty(exports,"PasswordPolicy",{enumerable:true,get:function(){return chunkAJAZ7D3W_cjs.c}});Object.defineProperty(exports,"SQLiteAuthAdapter",{enumerable:true,get:function(){return chunkET6NN2V2_cjs.a}});Object.defineProperty(exports,"ALL_WEBHOOK_EVENTS",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.d}});Object.defineProperty(exports,"WEBHOOK_COLLECTION",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.e}});Object.defineProperty(exports,"WEBHOOK_DELIVERY_COLLECTION",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.f}});Object.defineProperty(exports,"WEBHOOK_EVENTS",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.c}});Object.defineProperty(exports,"WebhookService",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.m}});Object.defineProperty(exports,"buildDeliveryRecord",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.k}});Object.defineProperty(exports,"createTestPayload",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.l}});Object.defineProperty(exports,"createWebhookService",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.n}});Object.defineProperty(exports,"deliverWebhook",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.i}});Object.defineProperty(exports,"deliverWithRetry",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.j}});Object.defineProperty(exports,"generateWebhookSecret",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.h}});Object.defineProperty(exports,"signPayload",{enumerable:true,get:function(){return chunkISWMETHJ_cjs.g}});Object.defineProperty(exports,"evaluateAccess",{enumerable:true,get:function(){return chunkNY47CFVP_cjs.a}});Object.defineProperty(exports,"getWhereClause",{enumerable:true,get:function(){return chunkNY47CFVP_cjs.c}});Object.defineProperty(exports,"mergeWhereClauses",{enumerable:true,get:function(){return chunkNY47CFVP_cjs.b}});Object.defineProperty(exports,"KyroPubSub",{enumerable:true,get:function(){return chunkF7SR5IDT_cjs.b}});Object.defineProperty(exports,"KyroWSServer",{enumerable:true,get:function(){return chunkF7SR5IDT_cjs.c}});Object.defineProperty(exports,"PubSub",{enumerable:true,get:function(){return chunkF7SR5IDT_cjs.a}});Object.defineProperty(exports,"createWSServer",{enumerable:true,get:function(){return chunkF7SR5IDT_cjs.d}});Object.defineProperty(exports,"DrizzleAdapter",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.c}});Object.defineProperty(exports,"collectionToDrizzleSchema",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.b}});Object.defineProperty(exports,"createDatabase",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.f}});Object.defineProperty(exports,"createDrizzleAdapter",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.d}});Object.defineProperty(exports,"fieldToDrizzleType",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.a}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.g}});Object.defineProperty(exports,"seedDefaultRoles",{enumerable:true,get:function(){return chunkIFJJ44OQ_cjs.h}});Object.defineProperty(exports,"PostgresAuthAdapter",{enumerable:true,get:function(){return chunkGYQMNXXW_cjs.a}});Object.defineProperty(exports,"MongoDBAdapter",{enumerable:true,get:function(){return chunkUDSJGML2_cjs.a}});Object.defineProperty(exports,"createMongoDBAdapter",{enumerable:true,get:function(){return chunkUDSJGML2_cjs.b}});Object.defineProperty(exports,"MongoDBAuthAdapter",{enumerable:true,get:function(){return chunkATLSIYRH_cjs.a}});Object.defineProperty(exports,"AbstractBaseAdapter",{enumerable:true,get:function(){return chunkDV4LFLPL_cjs.a}});Object.defineProperty(exports,"z",{enumerable:true,get:function(){return zod.z}});exports.AccountLockout=x;exports.AnalyticsPlugin=E;exports.Auth=H;exports.CommentsPlugin=U;exports.InMemoryAccountLockout=C;exports.InMemoryAuthAdapter=P;exports.KyroPlugin=b;exports.PluginManager=$;exports.RateLimiter=S;exports.ReviewsPlugin=V;exports.SEOPLugin=L;exports.VersionManager=M;exports.WishlistPlugin=O;exports.authConfig=Ue;exports.createAuth=Rr;exports.createAuthConfig=W;exports.createAuthStorage=Fe;exports.createStorage=Y;exports.createVersionManager=Dr;exports.defineConfig=Ve;exports.defineKyroConfig=Or;exports.generateAnalyticsTags=_r;exports.generateSeoTags=Hr;exports.getDefaultDraftPublishConfig=_;exports.getPaymentConfig=Kr;exports.getPaymentConfigFromSettings=_e;exports.getSocialLinks=Br;exports.getSocialLinksFromSettings=Oe;exports.getStoreConfig=Nr;exports.getStoreConfigFromSettings=He;exports.isArchived=Er;exports.isDraft=Lr;exports.isPublished=Ir;exports.presetPlugins=Ar;exports.runFieldHooks=br;exports.runHooks=Ie;
|