@arch-cadre/core 0.0.41 → 0.0.43
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/core/auth/augment.js +6 -14
- package/dist/core/auth/email-verification.js +33 -43
- package/dist/core/auth/events.js +1 -2
- package/dist/core/auth/logic.js +71 -90
- package/dist/core/auth/password-reset.js +46 -56
- package/dist/core/auth/rbac.js +73 -90
- package/dist/core/auth/session.js +51 -66
- package/dist/core/auth/types.js +1 -2
- package/dist/core/auth/utils/encode.js +5 -9
- package/dist/core/auth/utils/encryption.js +12 -18
- package/dist/core/auth/validation.js +25 -28
- package/dist/core/bootstrap.js +16 -19
- package/dist/core/config.js +1 -4
- package/dist/core/config.server.js +14 -54
- package/dist/core/event-bus.js +2 -5
- package/dist/core/filesystem/index.js +7 -24
- package/dist/core/filesystem/providers/local.js +7 -14
- package/dist/core/filesystem/service.js +2 -5
- package/dist/core/filesystem/types.js +1 -2
- package/dist/core/notifications/actions.js +22 -28
- package/dist/core/notifications/index.js +3 -19
- package/dist/core/notifications/service.js +6 -9
- package/dist/core/notifications/types.js +1 -2
- package/dist/core/setup.js +7 -10
- package/dist/core/types.js +1 -2
- package/dist/index.js +7 -23
- package/dist/server/auth/email.js +9 -13
- package/dist/server/auth/password.js +6 -14
- package/dist/server/auth/types.js +1 -17
- package/dist/server/auth/user.js +76 -91
- package/dist/server/database/inject.js +2 -6
- package/dist/server/database/schema.js +107 -110
- package/dist/server/database/types.js +1 -2
- package/dist/server/emails/index.js +4 -10
- package/dist/server.js +24 -40
- package/package.json +2 -4
package/dist/core/bootstrap.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const service_1 = require("./notifications/service");
|
|
10
|
-
const setup_1 = require("./setup");
|
|
11
|
-
async function ensureSystemInitialized(providedDb) {
|
|
1
|
+
import { injectDb } from "../server/database/inject";
|
|
2
|
+
import { initEmailVerification } from "./auth/email-verification";
|
|
3
|
+
import { eventBus } from "./event-bus";
|
|
4
|
+
import { filesystemService } from "./filesystem/index";
|
|
5
|
+
import { LocalFileProvider } from "./filesystem/providers/local";
|
|
6
|
+
import { notificationService } from "./notifications/service";
|
|
7
|
+
import { isSystemInstalled } from "./setup";
|
|
8
|
+
export async function ensureSystemInitialized(providedDb) {
|
|
12
9
|
if (typeof window !== "undefined")
|
|
13
10
|
return;
|
|
14
11
|
const g = globalThis;
|
|
15
12
|
// 1. Immediate injection if provided
|
|
16
13
|
if (providedDb) {
|
|
17
|
-
|
|
14
|
+
injectDb(providedDb);
|
|
18
15
|
}
|
|
19
16
|
// 2. Prevent infinite recursion and double initialization
|
|
20
17
|
if (g.__KRYO_INITIALIZED__)
|
|
@@ -29,19 +26,19 @@ async function ensureSystemInitialized(providedDb) {
|
|
|
29
26
|
console.warn("[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...");
|
|
30
27
|
}
|
|
31
28
|
// Check if system is installed before initializing modules
|
|
32
|
-
if (await
|
|
29
|
+
if (await isSystemInstalled()) {
|
|
33
30
|
// Order matters: services first, then modules (which use services)
|
|
34
|
-
|
|
35
|
-
await
|
|
31
|
+
notificationService.init();
|
|
32
|
+
await initEmailVerification();
|
|
36
33
|
// Auto-register local filesystem provider as a fallback
|
|
37
|
-
const local = new
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const local = new LocalFileProvider();
|
|
35
|
+
filesystemService.registerProvider(local);
|
|
36
|
+
filesystemService.setDefaultProvider(local.id);
|
|
40
37
|
}
|
|
41
38
|
else {
|
|
42
39
|
console.log("[Kryo:Bootstrap] System not installed. Skipping module initialization.");
|
|
43
40
|
}
|
|
44
|
-
await
|
|
41
|
+
await eventBus.publish("system:start", { runtime: "nodejs" });
|
|
45
42
|
console.log("[Kryo:Bootstrap] System initialized successfully.");
|
|
46
43
|
g.__KRYO_INITIALIZED__ = true;
|
|
47
44
|
}
|
package/dist/core/config.js
CHANGED
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getKryoConfig = getKryoConfig;
|
|
40
|
-
exports.getModulesDir = getModulesDir;
|
|
41
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
42
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
43
|
-
const config_1 = require("./config");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { DEFAULT_CONFIG } from "./config";
|
|
44
4
|
let cachedConfig = null;
|
|
45
5
|
/**
|
|
46
6
|
* Loads the Kryo configuration from kryo.config.ts or kryo.config in the current working directory.
|
|
47
7
|
* SERVER ONLY.
|
|
48
8
|
*/
|
|
49
|
-
async function getKryoConfig() {
|
|
9
|
+
export async function getKryoConfig() {
|
|
50
10
|
// Prevent this from ever running on the client even if imported
|
|
51
11
|
if (typeof window !== "undefined") {
|
|
52
12
|
throw new Error("getKryoConfig can only be called on the server.");
|
|
@@ -56,27 +16,27 @@ async function getKryoConfig() {
|
|
|
56
16
|
return cachedConfig;
|
|
57
17
|
}
|
|
58
18
|
const cwd = process.cwd();
|
|
59
|
-
const configPathTS =
|
|
60
|
-
const configPathJS =
|
|
61
|
-
const configPathMJS =
|
|
19
|
+
const configPathTS = path.join(cwd, "kryo.config.ts");
|
|
20
|
+
const configPathJS = path.join(cwd, "kryo.config");
|
|
21
|
+
const configPathMJS = path.join(cwd, "kryo.config.mjs");
|
|
62
22
|
let loadedConfig = {};
|
|
63
23
|
try {
|
|
64
24
|
// Dynamic import jiti only on server to avoid bundling issues
|
|
65
|
-
const { createJiti } = await
|
|
25
|
+
const { createJiti } = await import("jiti");
|
|
66
26
|
const jiti = createJiti(cwd, {
|
|
67
27
|
fsCache: false,
|
|
68
28
|
moduleCache: false,
|
|
69
29
|
});
|
|
70
|
-
if (
|
|
30
|
+
if (fs.existsSync(configPathTS)) {
|
|
71
31
|
const cacheBuster = `?t=${Date.now()}`;
|
|
72
32
|
const imported = await jiti.import(`file://${configPathTS}${cacheBuster}`, { default: true });
|
|
73
33
|
loadedConfig = imported.default || imported;
|
|
74
34
|
}
|
|
75
|
-
else if (
|
|
35
|
+
else if (fs.existsSync(configPathMJS)) {
|
|
76
36
|
const imported = await jiti.import(configPathMJS, { default: true });
|
|
77
37
|
loadedConfig = imported.default || imported;
|
|
78
38
|
}
|
|
79
|
-
else if (
|
|
39
|
+
else if (fs.existsSync(configPathJS)) {
|
|
80
40
|
const imported = await jiti.import(configPathJS, { default: true });
|
|
81
41
|
loadedConfig = imported.default || imported;
|
|
82
42
|
}
|
|
@@ -84,7 +44,7 @@ async function getKryoConfig() {
|
|
|
84
44
|
catch (error) {
|
|
85
45
|
console.warn("[Kryo:Config] Could not load kryo.config.ts, using defaults.", error);
|
|
86
46
|
}
|
|
87
|
-
const finalConfig = { ...
|
|
47
|
+
const finalConfig = { ...DEFAULT_CONFIG, ...loadedConfig };
|
|
88
48
|
if (process.env.NODE_ENV === "production") {
|
|
89
49
|
cachedConfig = finalConfig;
|
|
90
50
|
}
|
|
@@ -94,8 +54,8 @@ async function getKryoConfig() {
|
|
|
94
54
|
* Helper returning the absolute path to the modules directory.
|
|
95
55
|
* SERVER ONLY.
|
|
96
56
|
*/
|
|
97
|
-
async function getModulesDir() {
|
|
57
|
+
export async function getModulesDir() {
|
|
98
58
|
const config = await getKryoConfig();
|
|
99
59
|
const dir = config.modulesDirectory || "modules";
|
|
100
|
-
return
|
|
60
|
+
return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);
|
|
101
61
|
}
|
package/dist/core/event-bus.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.eventBus = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* EventBus (Pub/Sub) - Global Singleton Pattern.
|
|
7
4
|
*/
|
|
@@ -50,5 +47,5 @@ class EventBus {
|
|
|
50
47
|
}
|
|
51
48
|
// Ensure global singleton
|
|
52
49
|
const globalForEventBus = globalThis;
|
|
53
|
-
|
|
54
|
-
globalForEventBus.__KRYO_EVENT_BUS__ =
|
|
50
|
+
export const eventBus = (_a = globalForEventBus.__KRYO_EVENT_BUS__) !== null && _a !== void 0 ? _a : new EventBus();
|
|
51
|
+
globalForEventBus.__KRYO_EVENT_BUS__ = eventBus;
|
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.filesystemService = void 0;
|
|
18
|
-
const local_1 = require("./providers/local");
|
|
19
|
-
const service_1 = require("./service");
|
|
20
|
-
Object.defineProperty(exports, "filesystemService", { enumerable: true, get: function () { return service_1.filesystemService; } });
|
|
21
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
import { LocalFileProvider } from "./providers/local";
|
|
2
|
+
import { filesystemService } from "./service";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export { filesystemService };
|
|
22
5
|
// Auto-register local provider
|
|
23
6
|
if (typeof window === "undefined") {
|
|
24
|
-
const local = new
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
const local = new LocalFileProvider();
|
|
8
|
+
filesystemService.registerProvider(local);
|
|
9
|
+
filesystemService.setDefaultProvider(local.id);
|
|
27
10
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LocalFileProvider = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
class LocalFileProvider {
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export class LocalFileProvider {
|
|
10
4
|
constructor() {
|
|
11
5
|
this.id = "local";
|
|
12
6
|
this.name = "Local Filesystem";
|
|
@@ -23,13 +17,13 @@ class LocalFileProvider {
|
|
|
23
17
|
var _a;
|
|
24
18
|
try {
|
|
25
19
|
const storageFolder = (_a = process.env.FILE_STORAGE_FOLDER) !== null && _a !== void 0 ? _a : "public/storage";
|
|
26
|
-
if (!
|
|
27
|
-
|
|
20
|
+
if (!fs.existsSync(storageFolder)) {
|
|
21
|
+
fs.mkdirSync(storageFolder, { recursive: true });
|
|
28
22
|
}
|
|
29
23
|
const name = this.generateUniqueImageName(file.name);
|
|
30
|
-
const filePath =
|
|
24
|
+
const filePath = path.join(storageFolder, name);
|
|
31
25
|
const buffer = await file.arrayBuffer();
|
|
32
|
-
|
|
26
|
+
fs.writeFileSync(filePath, Buffer.from(buffer));
|
|
33
27
|
const url = `${storageFolder}/${name}`.replace("public", "");
|
|
34
28
|
return {
|
|
35
29
|
name: name,
|
|
@@ -46,4 +40,3 @@ class LocalFileProvider {
|
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
|
-
exports.LocalFileProvider = LocalFileProvider;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.filesystemService = void 0;
|
|
5
2
|
class FilesystemService {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.providers = new Map();
|
|
@@ -50,5 +47,5 @@ class FilesystemService {
|
|
|
50
47
|
}
|
|
51
48
|
// Global Singleton Pattern
|
|
52
49
|
const globalForFilesystem = globalThis;
|
|
53
|
-
|
|
54
|
-
globalForFilesystem.__KRYO_FILESYSTEM_SERVICE__ =
|
|
50
|
+
export const filesystemService = (_a = globalForFilesystem.__KRYO_FILESYSTEM_SERVICE__) !== null && _a !== void 0 ? _a : new FilesystemService();
|
|
51
|
+
globalForFilesystem.__KRYO_FILESYSTEM_SERVICE__ = filesystemService;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use server";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const inject_1 = require("../../server/database/inject");
|
|
10
|
-
const schema_1 = require("../../server/database/schema");
|
|
11
|
-
const session_1 = require("../auth/session");
|
|
12
|
-
async function getUserNotifications() {
|
|
13
|
-
const { user } = await (0, session_1.getCurrentSession)();
|
|
2
|
+
import { desc, eq } from "drizzle-orm";
|
|
3
|
+
import { db } from "../../server/database/inject";
|
|
4
|
+
import { notificationTable } from "../../server/database/schema";
|
|
5
|
+
import { getCurrentSession } from "../auth/session";
|
|
6
|
+
export async function getUserNotifications() {
|
|
7
|
+
const { user } = await getCurrentSession();
|
|
14
8
|
if (!user)
|
|
15
9
|
return null;
|
|
16
|
-
return await
|
|
10
|
+
return await db
|
|
17
11
|
.select()
|
|
18
|
-
.from(
|
|
19
|
-
.where(
|
|
20
|
-
.orderBy(
|
|
12
|
+
.from(notificationTable)
|
|
13
|
+
.where(eq(notificationTable.userId, user.id))
|
|
14
|
+
.orderBy(desc(notificationTable.createdAt));
|
|
21
15
|
}
|
|
22
|
-
async function createNotification(data) {
|
|
23
|
-
const [notification] = await
|
|
24
|
-
.insert(
|
|
16
|
+
export async function createNotification(data) {
|
|
17
|
+
const [notification] = await db
|
|
18
|
+
.insert(notificationTable)
|
|
25
19
|
.values({
|
|
26
20
|
...data,
|
|
27
21
|
isRead: false,
|
|
@@ -29,21 +23,21 @@ async function createNotification(data) {
|
|
|
29
23
|
.returning();
|
|
30
24
|
return notification;
|
|
31
25
|
}
|
|
32
|
-
async function markNotificationAsRead(id) {
|
|
33
|
-
const [updated] = await
|
|
34
|
-
.update(
|
|
26
|
+
export async function markNotificationAsRead(id) {
|
|
27
|
+
const [updated] = await db
|
|
28
|
+
.update(notificationTable)
|
|
35
29
|
.set({ isRead: true })
|
|
36
|
-
.where(
|
|
30
|
+
.where(eq(notificationTable.id, id))
|
|
37
31
|
.returning();
|
|
38
32
|
return updated;
|
|
39
33
|
}
|
|
40
|
-
async function markAllNotificationsAsRead() {
|
|
41
|
-
const { user } = await
|
|
34
|
+
export async function markAllNotificationsAsRead() {
|
|
35
|
+
const { user } = await getCurrentSession();
|
|
42
36
|
if (!user)
|
|
43
37
|
return null;
|
|
44
|
-
return await
|
|
45
|
-
.update(
|
|
38
|
+
return await db
|
|
39
|
+
.update(notificationTable)
|
|
46
40
|
.set({ isRead: true })
|
|
47
|
-
.where(
|
|
41
|
+
.where(eq(notificationTable.userId, user.id))
|
|
48
42
|
.returning();
|
|
49
43
|
}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./actions"), exports);
|
|
18
|
-
__exportStar(require("./service"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from "./actions";
|
|
2
|
+
export * from "./service";
|
|
3
|
+
export * from "./types";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const event_bus_1 = require("../event-bus");
|
|
6
|
-
const actions_1 = require("./actions");
|
|
2
|
+
import { eventBus } from "../event-bus";
|
|
3
|
+
import { createNotification } from "./actions";
|
|
7
4
|
class NotificationService {
|
|
8
5
|
constructor() {
|
|
9
6
|
this.initialized = false;
|
|
@@ -14,11 +11,11 @@ class NotificationService {
|
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
13
|
console.log("[Notification Service] Subscribing to notification:send...");
|
|
17
|
-
|
|
14
|
+
eventBus.subscribe("notification:send", "notification-service", async (event) => {
|
|
18
15
|
console.log("[Notification Service] Received notification:send event", event.payload);
|
|
19
16
|
try {
|
|
20
17
|
// const { createNotification } = await import("./actions");
|
|
21
|
-
const result = await
|
|
18
|
+
const result = await createNotification(event.payload);
|
|
22
19
|
console.log("[Notification Service] Notification created successfully:", result.id);
|
|
23
20
|
}
|
|
24
21
|
catch (error) {
|
|
@@ -31,5 +28,5 @@ class NotificationService {
|
|
|
31
28
|
}
|
|
32
29
|
// Global Singleton Pattern
|
|
33
30
|
const globalForNotifications = globalThis;
|
|
34
|
-
|
|
35
|
-
globalForNotifications.__KRYO_NOTIFICATION_SERVICE__ =
|
|
31
|
+
export const notificationService = (_a = globalForNotifications.__KRYO_NOTIFICATION_SERVICE__) !== null && _a !== void 0 ? _a : new NotificationService();
|
|
32
|
+
globalForNotifications.__KRYO_NOTIFICATION_SERVICE__ = notificationService;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/core/setup.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const drizzle_orm_1 = require("drizzle-orm");
|
|
5
|
-
const inject_1 = require("../server/database/inject");
|
|
6
|
-
const schema_1 = require("../server/database/schema");
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { db } from "../server/database/inject";
|
|
3
|
+
import { userTable } from "../server/database/schema";
|
|
7
4
|
/**
|
|
8
5
|
* Checks if the system is installed.
|
|
9
6
|
* A system is considered installed if at least one user exists in the database.
|
|
10
7
|
*/
|
|
11
|
-
async function isSystemInstalled() {
|
|
8
|
+
export async function isSystemInstalled() {
|
|
12
9
|
var _a;
|
|
13
10
|
try {
|
|
14
11
|
// We check if the users table exists and has at least one record
|
|
15
12
|
console.log("[Kernel:Setup] Checking if system is installed...");
|
|
16
|
-
const result = await
|
|
17
|
-
.select({ count:
|
|
18
|
-
.from(
|
|
13
|
+
const result = await db
|
|
14
|
+
.select({ count: sql `count(*)` })
|
|
15
|
+
.from(userTable);
|
|
19
16
|
const count = Number(((_a = result[0]) === null || _a === void 0 ? void 0 : _a.count) || 0);
|
|
20
17
|
console.log(`[Kernel:Setup] User count: ${count}`);
|
|
21
18
|
return count > 0;
|
package/dist/core/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// export { ExtensionPoint } from "./client/extension-point";
|
|
3
2
|
// export { ExtensionPointClient } from "./client/extension-point-client";
|
|
4
3
|
// export { WidgetArea } from "./client/widget-area";
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
4
|
// Common Types & Constants
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
export * from "./core/auth/types";
|
|
6
|
+
export * from "./core/auth/validation";
|
|
23
7
|
// Shared Services (Singletons / Handlers)
|
|
24
|
-
|
|
8
|
+
export * from "./core/event-bus";
|
|
25
9
|
// Shared Constants & Models (Safe for Browser)
|
|
26
10
|
// export * from "./core/modules/ui";
|
|
27
11
|
// export * from "./core/modules/types";
|
|
28
12
|
// Client Hooks & Providers
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
export * from "./core/notifications/service";
|
|
14
|
+
export * from "./core/notifications/types";
|
|
15
|
+
export * from "./core/types";
|
|
16
|
+
export * from "./server/database/schema";
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.checkEmailAvailability = checkEmailAvailability;
|
|
5
|
-
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
|
-
const inject_1 = require("../database/inject");
|
|
7
|
-
const schema_1 = require("../database/schema");
|
|
1
|
+
import { count, eq } from "drizzle-orm";
|
|
2
|
+
import { db } from "../database/inject";
|
|
3
|
+
import { userTable } from "../database/schema";
|
|
8
4
|
/**
|
|
9
5
|
* Validates the email format and length.
|
|
10
6
|
*/
|
|
11
|
-
function verifyEmailInput(email) {
|
|
7
|
+
export function verifyEmailInput(email) {
|
|
12
8
|
return /^.+@.+\..+$/.test(email) && email.length < 256 && email.length > 0;
|
|
13
9
|
}
|
|
14
10
|
/**
|
|
15
11
|
* Checks if an email address is already in use.
|
|
16
12
|
* @returns True if the email is available, false otherwise.
|
|
17
13
|
*/
|
|
18
|
-
async function checkEmailAvailability(email) {
|
|
19
|
-
const [entries] = await
|
|
20
|
-
.select({ count:
|
|
21
|
-
.from(
|
|
22
|
-
.where(
|
|
14
|
+
export async function checkEmailAvailability(email) {
|
|
15
|
+
const [entries] = await db
|
|
16
|
+
.select({ count: count() })
|
|
17
|
+
.from(userTable)
|
|
18
|
+
.where(eq(userTable.email, email));
|
|
23
19
|
return entries.count === 0;
|
|
24
20
|
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use server";
|
|
3
|
-
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.hashPassword = hashPassword;
|
|
8
|
-
exports.verifyPasswordHash = verifyPasswordHash;
|
|
9
|
-
exports.verifyPasswordStrength = verifyPasswordStrength;
|
|
10
|
-
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
2
|
+
import bcrypt from "bcryptjs";
|
|
11
3
|
/**
|
|
12
4
|
* Hashes the password using bcrypt.
|
|
13
5
|
* @param password Password to be hashed.
|
|
14
6
|
* @returns Returns the hashed password.
|
|
15
7
|
*/
|
|
16
|
-
async function hashPassword(password) {
|
|
8
|
+
export async function hashPassword(password) {
|
|
17
9
|
const saltRounds = 10;
|
|
18
|
-
return await
|
|
10
|
+
return await bcrypt.hash(password, saltRounds);
|
|
19
11
|
// return password;
|
|
20
12
|
}
|
|
21
13
|
/**
|
|
@@ -24,8 +16,8 @@ async function hashPassword(password) {
|
|
|
24
16
|
* @param password Password for comparison.
|
|
25
17
|
* @returns Returns true if the password is correct, false otherwise.
|
|
26
18
|
*/
|
|
27
|
-
async function verifyPasswordHash(hash, password) {
|
|
28
|
-
return await
|
|
19
|
+
export async function verifyPasswordHash(hash, password) {
|
|
20
|
+
return await bcrypt.compare(password, hash);
|
|
29
21
|
// return password === hash;
|
|
30
22
|
}
|
|
31
23
|
/**
|
|
@@ -33,6 +25,6 @@ async function verifyPasswordHash(hash, password) {
|
|
|
33
25
|
* @param password Password to validate.
|
|
34
26
|
* @returns Returns true if the password meets complexity requirements.
|
|
35
27
|
*/
|
|
36
|
-
async function verifyPasswordStrength(password) {
|
|
28
|
+
export async function verifyPasswordStrength(password) {
|
|
37
29
|
return password.length >= 8 && password.length <= 255;
|
|
38
30
|
}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../../core/auth/types"), exports);
|
|
1
|
+
export * from "../../core/auth/types";
|