@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import h from'bcryptjs';import {randomUUID,randomBytes}from'crypto';var w=class{db;prefix;sessionTTL;refreshTokenTTL;indexesEnsured=false;constructor(e){this.db=e.db,this.prefix=e.collectionPrefix||"",this.sessionTTL=e.sessionTTL||86400,this.refreshTokenTTL=e.refreshTokenTTL||604800;}col(e){return this.db.collection(`${this.prefix}${e}`)}async connect(){this.indexesEnsured||await this.ensureIndexes();}async disconnect(){}async ensureIndexes(){await this.col("users").createIndex({email:1},{unique:true}),await this.col("users").createIndex({tenantId:1}),await this.col("users").createIndex({role:1}),await this.col("sessions").createIndex({token:1},{unique:true}),await this.col("sessions").createIndex({refreshToken:1}),await this.col("sessions").createIndex({userId:1}),await this.col("sessions").createIndex({expiresAt:1},{expireAfterSeconds:0}),await this.col("audit_logs").createIndex({timestamp:-1}),await this.col("audit_logs").createIndex({userId:1}),await this.col("audit_logs").createIndex({action:1}),await this.col("audit_logs").createIndex({resource:1}),await this.col("password_history").createIndex({userId:1,createdAt:-1}),await this.col("lockouts").createIndex({userId:1},{unique:true}),await this.col("lockouts").createIndex({lockedUntil:1}),this.indexesEnsured=true;}async createUser(e){let s=randomUUID(),t=new Date,i=await this.hashPassword(e.password),n={_id:s,name:e.name||null,email:e.email.toLowerCase(),passwordHash:i,role:e.role||"customer",avatar:e.avatar||null,tenantId:e.tenantId||null,emailVerified:false,locked:false,lastLogin:null,failedLoginAttempts:0,createdAt:t,updatedAt:t};return await this.col("users").insertOne(n),this.docToAuthUser(n)}async findUserByEmail(e){let s=await this.col("users").findOne({email:e.toLowerCase()});return s?this.docToAuthUser(s):null}async findUserById(e){let s=await this.col("users").findOne({_id:e});return s?this.docToAuthUser(s):null}async updateUser(e,s){let t={updatedAt:new Date};s.name!==void 0&&(t.name=s.name),s.email!==void 0&&(t.email=s.email),s.passwordHash!==void 0&&(t.passwordHash=s.passwordHash),s.role!==void 0&&(t.role=s.role),s.avatar!==void 0&&(t.avatar=s.avatar),s.tenantId!==void 0&&(t.tenantId=s.tenantId),s.emailVerified!==void 0&&(t.emailVerified=s.emailVerified),s.locked!==void 0&&(t.locked=s.locked),s.lastLogin!==void 0&&(t.lastLogin=s.lastLogin?new Date(s.lastLogin):null),s.failedLoginAttempts!==void 0&&(t.failedLoginAttempts=s.failedLoginAttempts);let i=await this.col("users").findOneAndUpdate({_id:e},{$set:t},{returnDocument:"after"});return i?this.docToAuthUser(i):null}async deleteUser(e){return (await this.col("users").deleteOne({_id:e})).deletedCount>0}async verifyPassword(e,s){let t=await this.findUserByEmail(e);if(!t)return null;let i=await this.col("users").findOne({email:e.toLowerCase()},{projection:{passwordHash:1}});return i?.passwordHash&&await h.compare(s,i.passwordHash)?t:null}async hashPassword(e){return h.hash(e,12)}async createSession(e,s){let t=randomUUID(),i=randomBytes(32).toString("base64url"),n=randomBytes(32).toString("base64url"),a=new Date,u=new Date(a.getTime()+this.sessionTTL*1e3),d={_id:t,userId:e,token:i,refreshToken:n,ipAddress:s?.ipAddress||null,userAgent:s?.userAgent||null,expiresAt:u,createdAt:a};return await this.col("sessions").insertOne(d),this.docToSession(d)}async findSessionByToken(e){let s=await this.col("sessions").findOne({token:e,expiresAt:{$gt:new Date}});return s?this.docToSession(s):null}async findSessionByRefreshToken(e){let s=await this.col("sessions").findOne({refreshToken:e,expiresAt:{$gt:new Date}});return s?this.docToSession(s):null}async deleteSession(e){return (await this.col("sessions").deleteOne({_id:e})).deletedCount>0}async deleteUserSessions(e){return (await this.col("sessions").deleteMany({userId:e})).deletedCount}async hasAnyUsers(){return await this.col("users").countDocuments()>0}async addPasswordToHistory(e,s){await this.col("password_history").insertOne({userId:e,passwordHash:s,createdAt:new Date});}async getPasswordHistory(e,s=5){return (await this.col("password_history").find({userId:e}).sort({createdAt:-1}).limit(s).toArray()).map(i=>i.passwordHash)}async isPasswordInHistory(e,s,t=5){let i=await this.getPasswordHistory(s,t);for(let n of i)if(await h.compare(e,n))return true;return false}async findAuditLogs(e){let{limit:s=50,offset:t=0,userId:i,action:n,resource:a,resourceId:u,success:d,startDate:c,endDate:f}=e,o={};i&&(o.userId=i),n&&(Array.isArray(n)?o.action={$in:n}:o.action=n),a&&(o.resource=a),u&&(o.resourceId=u),d!==void 0&&(o.success=d),(c||f)&&(o.timestamp={},c&&(o.timestamp.$gte=c),f&&(o.timestamp.$lte=f));let g=await this.col("audit_logs").countDocuments(o);return {logs:(await this.col("audit_logs").find(o).sort({timestamp:-1}).skip(t).limit(s).toArray()).map(r=>({id:r._id,timestamp:r.timestamp,action:r.action,userId:r.userId||void 0,userEmail:r.userEmail||void 0,role:r.role||void 0,resource:r.resource,resourceId:r.resourceId||void 0,changes:r.changes||void 0,ipAddress:r.ipAddress||void 0,userAgent:r.userAgent||void 0,success:r.success,error:r.error||void 0,metadata:r.metadata||void 0})),total:g}}async createAuditLog(e){let s=randomUUID(),t=new Date;return await this.col("audit_logs").insertOne({_id:s,action:e.action,userId:e.userId||null,userEmail:e.userEmail||null,role:e.role||null,resource:e.resource,resourceId:e.resourceId||null,changes:e.changes||null,ipAddress:e.ipAddress||null,userAgent:e.userAgent||null,success:e.success,error:e.error||null,metadata:e.metadata||null,timestamp:t}),{...e,id:s,timestamp:t}}docToAuthUser(e){return {id:e._id,name:e.name||void 0,email:e.email,passwordHash:e.passwordHash||void 0,role:e.role,tenantId:e.tenantId||void 0,avatar:e.avatar||void 0,emailVerified:e.emailVerified||false,locked:e.locked||false,lastLogin:e.lastLogin?.toISOString?.()||e.lastLogin||void 0,failedLoginAttempts:e.failedLoginAttempts||0,createdAt:e.createdAt?.toISOString?.()||e.createdAt,updatedAt:e.updatedAt?.toISOString?.()||e.updatedAt}}docToSession(e){return {id:e._id,userId:e.userId,token:e.token,refreshToken:e.refreshToken||void 0,expiresAt:e.expiresAt?.toISOString?.()||e.expiresAt,createdAt:e.createdAt?.toISOString?.()||e.createdAt,ipAddress:e.ipAddress||void 0,userAgent:e.userAgent||void 0}}async createEmailVerificationToken(e){let s=randomBytes(32).toString("hex"),t=new Date(Date.now()+1440*60*1e3);return await this.db.collection("email_verifications").insertOne({userId:new(await import('mongodb')).ObjectId(e),token:s,expiresAt:t,createdAt:new Date}),{token:s,expiresAt:t}}async verifyEmailToken(e){let s=await this.db.collection("email_verifications").findOne({token:e});return s?s.expiresAt<new Date?{success:false,error:"Verification token has expired"}:(await this.db.collection("users").updateOne({_id:s.userId},{$set:{emailVerified:true}}),await this.db.collection("email_verifications").deleteOne({_id:s._id}),{success:true,userId:s.userId.toString()}):{success:false,error:"Invalid verification token"}}async createPasswordResetToken(e){let s=await this.findUserByEmail(e);if(!s)return {token:"",expiresAt:new Date,error:"User not found"};let t=randomBytes(32).toString("hex"),i=new Date(Date.now()+3600*1e3);return await this.db.collection("password_resets").insertOne({userId:new(await import('mongodb')).ObjectId(s.id),token:t,expiresAt:i,createdAt:new Date}),{token:t,expiresAt:i}}async resetPasswordWithToken(e,s){let t=await this.db.collection("password_resets").findOne({token:e});if(!t)return {success:false,error:"Invalid reset token"};if(t.expiresAt<new Date)return {success:false,error:"Reset token has expired"};if(t.usedAt)return {success:false,error:"Reset token has already been used"};let i=await this.hashPassword(s);return await this.db.collection("users").updateOne({_id:t.userId},{$set:{passwordHash:i,updatedAt:new Date}}),await this.db.collection("password_resets").updateOne({_id:t._id},{$set:{usedAt:new Date}}),await this.db.collection("sessions").deleteMany({userId:t.userId}),{success:true}}};export{w as a};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var d=[{name:"super_admin",level:100,inherits:[],description:"Full system access across all tenants"},{name:"admin",level:90,inherits:["editor"],description:"Full tenant access with all content permissions"},{name:"editor",level:70,inherits:["author"],description:"Edit and publish all content"},{name:"author",level:50,inherits:["customer"],description:"Create and edit own content"},{name:"customer",level:30,inherits:[],description:"Access own data and make purchases"},{name:"guest",level:10,inherits:[],description:"Public read-only access"}];var c={super_admin:["*"],admin:["users:admin","users:read","users:update","audit_logs:read","posts:admin","posts:read","posts:create","posts:update","posts:delete","pages:admin","pages:read","pages:create","pages:update","pages:delete","media:admin","media:read","media:create","media:update","media:delete","categories:admin","categories:read","categories:create","categories:update","categories:delete","products:admin","products:read","products:create","products:update","products:delete","orders:admin","orders:read","orders:update","customers:admin","customers:read","customers:update","coupons:admin","coupons:read","coupons:create","coupons:update","coupons:delete","navigation:admin","navigation:read","navigation:create","navigation:update","navigation:delete","settings:admin","settings:read","settings:update","profile:admin","profile:read","profile:update"],editor:["posts:admin","posts:read","posts:create","posts:update","posts:delete","pages:admin","pages:read","pages:create","pages:update","pages:delete","media:read","media:create","media:update","categories:read","categories:create","categories:update","products:read","orders:read","orders:update","navigation:read","navigation:create","navigation:update","profile:read","profile:update"],author:["posts:read","posts:create","posts:update","media:read","media:create","categories:read","profile:read","profile:update"],customer:["profile:read","profile:update","orders:read","orders:create"],guest:["posts:read","pages:read","products:read"]};function u(e,s=d){let t=[e],r=new Map(s.map(o=>[o.name,o])),n=o=>{let i=r.get(o);if(i&&i.inherits)for(let a of i.inherits)t.includes(a)||(t.push(a),n(a));};return n(e),t}function m(e,s,t=c){if(!e||!e.role)return false;let r=l(e,t);if(r.includes("*")||r.includes(s))return true;let[n,o]=s.split(":");return !!(r.includes(`${n}:*`)||r.includes(`${n}:admin`))}function f(e,s){if(!e||!e.role)return false;let t=u(e.role);return s.some(r=>t.includes(r))}function l(e,s=c){if(!e||!e.role)return [];let t=u(e.role),r=new Set;for(let n of t){let o=s[n];if(o)for(let i of o)r.add(i);}return Array.from(r)}exports.a=m;exports.b=f;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';var html=require('@tiptap/html'),d=require('@tiptap/starter-kit'),s=require('@tiptap/extension-link'),p=require('@tiptap/extension-image'),c=require('@tiptap/extension-text-align'),x=require('@tiptap/extension-underline'),u=require('@tiptap/extension-highlight'),m=require('@tiptap/extension-task-list'),g=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),y=require('@tiptap/extension-color');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var d__default=/*#__PURE__*/_interopDefault(d);var s__default=/*#__PURE__*/_interopDefault(s);var p__default=/*#__PURE__*/_interopDefault(p);var c__default=/*#__PURE__*/_interopDefault(c);var x__default=/*#__PURE__*/_interopDefault(x);var u__default=/*#__PURE__*/_interopDefault(u);var m__default=/*#__PURE__*/_interopDefault(m);var g__default=/*#__PURE__*/_interopDefault(g);var y__default=/*#__PURE__*/_interopDefault(y);function b(e){return e.type==="text"}function h(e){return e.type==="number"}function k(e){return e.type==="relationship"}function R(e){return e.type==="array"}function B(e){return e.type==="group"}function T(e){return e.type==="blocks"}function w(e){return e.type==="upload"}function L(e){return e.type==="image"}function I(e){return e.type==="richtext"}function V(e){return e.type==="select"}function A(e){return e.type==="row"||e.type==="collapsible"||e.type==="tabs"}var r=["text","number","checkbox","date","email","password","textarea","select","radio","color"],n=["richtext","json","code","upload","image","markdown"],o=["relationship","array","group","blocks"],a=["row","collapsible","tabs"],C=[...r,...n,...o,...a];function S(e,t,i){return {name:e,type:"relationship",relationTo:t,...i,required:i?.required??false}}var Y=`
|
|
2
|
+
.kyro-richtext {
|
|
3
|
+
color: inherit;
|
|
4
|
+
line-height: 1.7;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.kyro-richtext > *:first-child {
|
|
8
|
+
margin-top: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.kyro-richtext > *:last-child {
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.kyro-richtext p,
|
|
16
|
+
.kyro-richtext ul,
|
|
17
|
+
.kyro-richtext ol,
|
|
18
|
+
.kyro-richtext blockquote,
|
|
19
|
+
.kyro-richtext pre {
|
|
20
|
+
margin: 0 0 1rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.kyro-richtext h1,
|
|
24
|
+
.kyro-richtext h2,
|
|
25
|
+
.kyro-richtext h3,
|
|
26
|
+
.kyro-richtext h4,
|
|
27
|
+
.kyro-richtext h5,
|
|
28
|
+
.kyro-richtext h6 {
|
|
29
|
+
margin: 0 0 0.75rem;
|
|
30
|
+
line-height: 1.2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.kyro-richtext ul,
|
|
34
|
+
.kyro-richtext ol {
|
|
35
|
+
padding-left: 1.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.kyro-richtext blockquote {
|
|
39
|
+
border-left: 4px solid rgba(148, 163, 184, 0.5);
|
|
40
|
+
margin-left: 0;
|
|
41
|
+
padding-left: 1rem;
|
|
42
|
+
font-style: italic;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.kyro-richtext pre {
|
|
46
|
+
overflow-x: auto;
|
|
47
|
+
border-radius: 0.75rem;
|
|
48
|
+
background: rgba(15, 23, 42, 0.92);
|
|
49
|
+
color: #f8fafc;
|
|
50
|
+
padding: 1rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.kyro-richtext code {
|
|
54
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.kyro-richtext img {
|
|
58
|
+
display: block;
|
|
59
|
+
max-width: 100%;
|
|
60
|
+
height: auto;
|
|
61
|
+
border-radius: 0.75rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.kyro-richtext ul[data-type="taskList"] {
|
|
65
|
+
list-style: none;
|
|
66
|
+
padding: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.kyro-richtext li[data-type="taskItem"] {
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: flex-start;
|
|
72
|
+
gap: 0.5rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.kyro-richtext li[data-type="taskItem"] > label {
|
|
76
|
+
user-select: none;
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
margin-top: 0.2rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.kyro-richtext li[data-type="taskItem"] > div {
|
|
82
|
+
flex: 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.kyro-richtext mark {
|
|
86
|
+
background-color: #fef08a;
|
|
87
|
+
border-radius: 0.25rem;
|
|
88
|
+
padding: 0.125rem 0.25rem;
|
|
89
|
+
}
|
|
90
|
+
`.trim(),f=[d__default.default,s__default.default.configure({openOnClick:false}),p__default.default,c__default.default.configure({types:["heading","paragraph"]}),x__default.default,u__default.default.configure({multicolor:true}),m__default.default,g__default.default.configure({nested:true}),extensionTextStyle.TextStyle,y__default.default];function G(e){return typeof e=="object"&&e!==null?e:{}}function j(e){if(typeof e!="object"||e===null)return "";try{return `<div class="kyro-richtext">${html.generateHTML(e,f)}</div>`}catch(t){return console.error("Failed to render rich text:",t),""}}exports.a=b;exports.b=h;exports.c=k;exports.d=R;exports.e=B;exports.f=T;exports.g=w;exports.h=L;exports.i=I;exports.j=V;exports.k=A;exports.l=r;exports.m=n;exports.n=o;exports.o=a;exports.p=C;exports.q=S;exports.r=Y;exports.s=G;exports.t=j;
|
|
File without changes
|