@kyro-cms/admin 0.1.2 → 0.1.3
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/package.json +17 -6
- package/src/components/Admin.tsx +50 -1
- package/src/components/LoginPage.tsx +223 -0
- package/src/components/layout/Sidebar.tsx +35 -0
- package/src/index.ts +35 -0
- package/src/middleware.ts +2 -0
- package/src/pages/api/auth/register.ts +133 -0
- package/src/styles/main.css +148 -0
- package/.astro/content.d.ts +0 -154
- package/.astro/settings.json +0 -5
- package/.astro/types.d.ts +0 -2
- package/astro.config.mjs +0 -28
- package/bun.lock +0 -1374
- package/dist/client/_astro/AdminLayout.DkDpng53.css +0 -1
- package/dist/client/_astro/AutoForm.3eJCmCJp.js +0 -1
- package/dist/client/_astro/client.DyczpTbx.js +0 -9
- package/dist/client/_astro/index.B02hbnpo.js +0 -1
- package/dist/client/fonts/Serotiva-Black.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Bold.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Medium.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Regular.woff2 +0 -0
- package/dist/client/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/dist/server/chunks/AdminLayout_D-_JeUqC.mjs +0 -26
- package/dist/server/chunks/_id__BzI_o0qT.mjs +0 -50
- package/dist/server/chunks/_id__Cd-jOuY3.mjs +0 -238
- package/dist/server/chunks/_id__DvbD--iR.mjs +0 -992
- package/dist/server/chunks/_id__vpVaEo16.mjs +0 -128
- package/dist/server/chunks/_virtual_astro_server-island-manifest_CQQ1F5PF.mjs +0 -7
- package/dist/server/chunks/_virtual_astro_session-driver_Bk3Q189E.mjs +0 -4
- package/dist/server/chunks/astro-component_Dbx3T2Nh.mjs +0 -37
- package/dist/server/chunks/audit-logs_DrnUMRvY.mjs +0 -74
- package/dist/server/chunks/config_CPXslElD.mjs +0 -4221
- package/dist/server/chunks/dataStore_Dl7cA2Qp.mjs +0 -89
- package/dist/server/chunks/index_CVqOkerS.mjs +0 -2960
- package/dist/server/chunks/index_CX8SQ4BF.mjs +0 -55
- package/dist/server/chunks/index_CYofDU51.mjs +0 -58
- package/dist/server/chunks/index_DdNRhuaM.mjs +0 -55
- package/dist/server/chunks/index_DupPvtIF.mjs +0 -42
- package/dist/server/chunks/index_YTS_M-B9.mjs +0 -263
- package/dist/server/chunks/index_YeCzuVps.mjs +0 -53
- package/dist/server/chunks/login_DLyqMRO8.mjs +0 -93
- package/dist/server/chunks/logout_CSbt5wea.mjs +0 -50
- package/dist/server/chunks/me_C04jlYhH.mjs +0 -41
- package/dist/server/chunks/new_BbQ9b55M.mjs +0 -92
- package/dist/server/chunks/node_9bvTewss.mjs +0 -1014
- package/dist/server/chunks/noop-entrypoint_BOlrdqWF.mjs +0 -3
- package/dist/server/chunks/sequence_9cl7AJy-.mjs +0 -2503
- package/dist/server/chunks/server_peBx9VXG.mjs +0 -8117
- package/dist/server/chunks/sharp_pmJ7nHES.mjs +0 -142
- package/dist/server/chunks/users_Dzddy_YR.mjs +0 -137
- package/dist/server/entry.mjs +0 -5
- package/dist/server/virtual_astro_middleware.mjs +0 -48
- package/public/fonts/Serotiva-Black.woff2 +0 -0
- package/public/fonts/Serotiva-Bold.woff2 +0 -0
- package/public/fonts/Serotiva-Medium.woff2 +0 -0
- package/public/fonts/Serotiva-Regular.woff2 +0 -0
- package/public/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/tsconfig.json +0 -12
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { createAuditContext, RedisAuthAdapter, AuditLogger } from './index_CVqOkerS.mjs';
|
|
2
|
-
import 'bcryptjs';
|
|
3
|
-
|
|
4
|
-
const redisAdapter = new RedisAuthAdapter({
|
|
5
|
-
url: process.env.REDIS_URL || "redis://localhost:6379"
|
|
6
|
-
});
|
|
7
|
-
const auditLogger = new AuditLogger(redisAdapter);
|
|
8
|
-
async function ensureConnection() {
|
|
9
|
-
try {
|
|
10
|
-
await redisAdapter.connect();
|
|
11
|
-
} catch (e) {
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const GET = async ({ params }) => {
|
|
15
|
-
await ensureConnection();
|
|
16
|
-
const { id } = params;
|
|
17
|
-
try {
|
|
18
|
-
const user = await redisAdapter.findUserById(id);
|
|
19
|
-
if (!user) {
|
|
20
|
-
return new Response(JSON.stringify({ error: "User not found" }), {
|
|
21
|
-
status: 404,
|
|
22
|
-
headers: { "Content-Type": "application/json" }
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const { passwordHash, ...safeUser } = user;
|
|
26
|
-
return new Response(JSON.stringify({ data: safeUser }), {
|
|
27
|
-
status: 200,
|
|
28
|
-
headers: { "Content-Type": "application/json" }
|
|
29
|
-
});
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error("Error fetching user:", error);
|
|
32
|
-
return new Response(JSON.stringify({ error: "Failed to fetch user" }), {
|
|
33
|
-
status: 500,
|
|
34
|
-
headers: { "Content-Type": "application/json" }
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const PUT = async ({ params, request }) => {
|
|
39
|
-
await ensureConnection();
|
|
40
|
-
const { id } = params;
|
|
41
|
-
const { ipAddress, userAgent } = createAuditContext(request);
|
|
42
|
-
try {
|
|
43
|
-
const body = await request.json();
|
|
44
|
-
const { email, role, tenantId, locked, emailVerified } = body;
|
|
45
|
-
const existing = await redisAdapter.findUserById(id);
|
|
46
|
-
if (!existing) {
|
|
47
|
-
return new Response(JSON.stringify({ error: "User not found" }), {
|
|
48
|
-
status: 404,
|
|
49
|
-
headers: { "Content-Type": "application/json" }
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const updateData = {};
|
|
53
|
-
if (email !== void 0) updateData.email = email;
|
|
54
|
-
if (role !== void 0) updateData.role = role;
|
|
55
|
-
if (tenantId !== void 0) updateData.tenantId = tenantId;
|
|
56
|
-
if (locked !== void 0) updateData.locked = locked;
|
|
57
|
-
if (emailVerified !== void 0) updateData.emailVerified = emailVerified;
|
|
58
|
-
const user = await redisAdapter.updateUser(id, updateData);
|
|
59
|
-
await auditLogger.log({
|
|
60
|
-
action: "user_update",
|
|
61
|
-
userId: id,
|
|
62
|
-
userEmail: existing.email,
|
|
63
|
-
role: existing.role,
|
|
64
|
-
resource: "users",
|
|
65
|
-
ipAddress,
|
|
66
|
-
userAgent,
|
|
67
|
-
success: true,
|
|
68
|
-
metadata: { updateData }
|
|
69
|
-
});
|
|
70
|
-
const { passwordHash, ...safeUser } = user;
|
|
71
|
-
return new Response(JSON.stringify({ data: safeUser }), {
|
|
72
|
-
status: 200,
|
|
73
|
-
headers: { "Content-Type": "application/json" }
|
|
74
|
-
});
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("Error updating user:", error);
|
|
77
|
-
return new Response(JSON.stringify({ error: "Failed to update user" }), {
|
|
78
|
-
status: 500,
|
|
79
|
-
headers: { "Content-Type": "application/json" }
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const DELETE = async ({ params, request }) => {
|
|
84
|
-
await ensureConnection();
|
|
85
|
-
const { id } = params;
|
|
86
|
-
const { ipAddress, userAgent } = createAuditContext(request);
|
|
87
|
-
try {
|
|
88
|
-
const existing = await redisAdapter.findUserById(id);
|
|
89
|
-
if (!existing) {
|
|
90
|
-
return new Response(JSON.stringify({ error: "User not found" }), {
|
|
91
|
-
status: 404,
|
|
92
|
-
headers: { "Content-Type": "application/json" }
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
await redisAdapter.deleteUser(id);
|
|
96
|
-
await auditLogger.log({
|
|
97
|
-
action: "user_delete",
|
|
98
|
-
userId: id,
|
|
99
|
-
userEmail: existing.email,
|
|
100
|
-
role: existing.role,
|
|
101
|
-
resource: "users",
|
|
102
|
-
ipAddress,
|
|
103
|
-
userAgent,
|
|
104
|
-
success: true
|
|
105
|
-
});
|
|
106
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
107
|
-
status: 200,
|
|
108
|
-
headers: { "Content-Type": "application/json" }
|
|
109
|
-
});
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.error("Error deleting user:", error);
|
|
112
|
-
return new Response(JSON.stringify({ error: "Failed to delete user" }), {
|
|
113
|
-
status: 500,
|
|
114
|
-
headers: { "Content-Type": "application/json" }
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
120
|
-
__proto__: null,
|
|
121
|
-
DELETE,
|
|
122
|
-
GET,
|
|
123
|
-
PUT
|
|
124
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
125
|
-
|
|
126
|
-
const page = () => _page;
|
|
127
|
-
|
|
128
|
-
export { page };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { A as AstroError, be as InvalidComponentArgs } from './sequence_9cl7AJy-.mjs';
|
|
2
|
-
|
|
3
|
-
function validateArgs(args) {
|
|
4
|
-
if (args.length !== 3) return false;
|
|
5
|
-
if (!args[0] || typeof args[0] !== "object") return false;
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
function baseCreateComponent(cb, moduleId, propagation) {
|
|
9
|
-
const name = moduleId?.split("/").pop()?.replace(".astro", "") ?? "";
|
|
10
|
-
const fn = (...args) => {
|
|
11
|
-
if (!validateArgs(args)) {
|
|
12
|
-
throw new AstroError({
|
|
13
|
-
...InvalidComponentArgs,
|
|
14
|
-
message: InvalidComponentArgs.message(name)
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return cb(...args);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(fn, "name", { value: name, writable: false });
|
|
20
|
-
fn.isAstroComponentFactory = true;
|
|
21
|
-
fn.moduleId = moduleId;
|
|
22
|
-
fn.propagation = propagation;
|
|
23
|
-
return fn;
|
|
24
|
-
}
|
|
25
|
-
function createComponentWithOptions(opts) {
|
|
26
|
-
const cb = baseCreateComponent(opts.factory, opts.moduleId, opts.propagation);
|
|
27
|
-
return cb;
|
|
28
|
-
}
|
|
29
|
-
function createComponent(arg1, moduleId, propagation) {
|
|
30
|
-
if (typeof arg1 === "function") {
|
|
31
|
-
return baseCreateComponent(arg1, moduleId, propagation);
|
|
32
|
-
} else {
|
|
33
|
-
return createComponentWithOptions(arg1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { createComponent as c };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { AuditLogger, RedisAuthAdapter } from './index_CVqOkerS.mjs';
|
|
2
|
-
|
|
3
|
-
const redisAdapter = new RedisAuthAdapter({
|
|
4
|
-
url: process.env.REDIS_URL || "redis://localhost:6379"
|
|
5
|
-
});
|
|
6
|
-
const auditLogger = new AuditLogger(redisAdapter);
|
|
7
|
-
async function ensureConnection() {
|
|
8
|
-
try {
|
|
9
|
-
await redisAdapter.connect();
|
|
10
|
-
} catch (e) {
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const GET = async ({ url }) => {
|
|
14
|
-
await ensureConnection();
|
|
15
|
-
const page = parseInt(url.searchParams.get("page") || "1");
|
|
16
|
-
const limit = parseInt(url.searchParams.get("limit") || "25");
|
|
17
|
-
const action = url.searchParams.get("action") || "";
|
|
18
|
-
const userId = url.searchParams.get("userId") || "";
|
|
19
|
-
const success = url.searchParams.get("success");
|
|
20
|
-
try {
|
|
21
|
-
const logs = await auditLogger.getLogs({
|
|
22
|
-
action: action || void 0,
|
|
23
|
-
userId: userId || void 0,
|
|
24
|
-
success: success === "true" ? true : success === "false" ? false : void 0
|
|
25
|
-
});
|
|
26
|
-
const thirtyDaysAgo = /* @__PURE__ */ new Date();
|
|
27
|
-
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
|
28
|
-
const filteredLogs = logs.filter((log) => {
|
|
29
|
-
const logDate = new Date(log.timestamp);
|
|
30
|
-
return logDate >= thirtyDaysAgo;
|
|
31
|
-
});
|
|
32
|
-
const sortedLogs = filteredLogs.sort(
|
|
33
|
-
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
34
|
-
);
|
|
35
|
-
const totalDocs = sortedLogs.length;
|
|
36
|
-
const startIndex = (page - 1) * limit;
|
|
37
|
-
const paginatedLogs = sortedLogs.slice(startIndex, startIndex + limit);
|
|
38
|
-
return new Response(
|
|
39
|
-
JSON.stringify({
|
|
40
|
-
docs: paginatedLogs,
|
|
41
|
-
totalDocs,
|
|
42
|
-
page,
|
|
43
|
-
limit,
|
|
44
|
-
totalPages: Math.ceil(totalDocs / limit)
|
|
45
|
-
}),
|
|
46
|
-
{
|
|
47
|
-
status: 200,
|
|
48
|
-
headers: { "Content-Type": "application/json" }
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error("Error fetching audit logs:", error);
|
|
53
|
-
return new Response(
|
|
54
|
-
JSON.stringify({
|
|
55
|
-
error: "Failed to fetch audit logs",
|
|
56
|
-
docs: [],
|
|
57
|
-
totalDocs: 0
|
|
58
|
-
}),
|
|
59
|
-
{
|
|
60
|
-
status: 200,
|
|
61
|
-
headers: { "Content-Type": "application/json" }
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
68
|
-
__proto__: null,
|
|
69
|
-
GET
|
|
70
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
71
|
-
|
|
72
|
-
const page = () => _page;
|
|
73
|
-
|
|
74
|
-
export { page };
|