@strapi-community/plugin-better-auth-dashboard 1.0.0-alpha.1 → 1.0.0-alpha.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/dist/admin/{Root-Bl4iPGDu.js → Root-BnRbzS-u.js} +1285 -854
- package/dist/admin/{Root-hwPhIfaT.mjs → Root-DBjGZL7H.mjs} +1287 -856
- package/dist/admin/index-BpruO4vo.mjs +67 -0
- package/dist/admin/index-xZ2FHX3i.js +66 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +99 -2
- package/dist/server/index.mjs +99 -2
- package/package.json +1 -1
- package/dist/admin/index-A9PUvldu.js +0 -26
- package/dist/admin/index-Cvcysa5M.mjs +0 -27
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
const PluginIcon = ({
|
|
3
|
+
size = 16,
|
|
4
|
+
background = "transparent",
|
|
5
|
+
opacity = 1,
|
|
6
|
+
rotation = 0,
|
|
7
|
+
shadow = 0,
|
|
8
|
+
flipHorizontal = false,
|
|
9
|
+
flipVertical = false,
|
|
10
|
+
padding = 0
|
|
11
|
+
}) => {
|
|
12
|
+
const transforms = [];
|
|
13
|
+
if (rotation !== 0) transforms.push(`rotate(${rotation}deg)`);
|
|
14
|
+
if (flipHorizontal) transforms.push("scaleX(-1)");
|
|
15
|
+
if (flipVertical) transforms.push("scaleY(-1)");
|
|
16
|
+
const viewBoxSize = 24 + padding * 2;
|
|
17
|
+
const viewBoxOffset = -padding;
|
|
18
|
+
const viewBox = `${viewBoxOffset} ${viewBoxOffset} ${viewBoxSize} ${viewBoxSize}`;
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
"svg",
|
|
21
|
+
{
|
|
22
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
23
|
+
viewBox,
|
|
24
|
+
width: size,
|
|
25
|
+
height: size,
|
|
26
|
+
fill: "none",
|
|
27
|
+
style: {
|
|
28
|
+
opacity,
|
|
29
|
+
transform: transforms.join(" ") || void 0,
|
|
30
|
+
filter: shadow > 0 ? `drop-shadow(0 ${shadow}px ${shadow * 2}px rgba(0,0,0,0.3))` : void 0,
|
|
31
|
+
backgroundColor: background !== "transparent" ? background : void 0
|
|
32
|
+
},
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("title", { children: "Better Auth Logo" }),
|
|
35
|
+
/* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M0 3.39v17.22h5.783v-5.55h6.434V8.939H5.783V3.39Zm12.217 5.55h5.638v6.122h-5.638v5.548H24V3.391H12.217Z" })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
const PLUGIN_ID = "better-auth-dashboard";
|
|
41
|
+
function captureApp(app) {
|
|
42
|
+
window.__betterAuthDashApp = app;
|
|
43
|
+
}
|
|
44
|
+
function getMediaLibraryComponent() {
|
|
45
|
+
return window.__betterAuthDashApp?.library?.components?.["media-library"] ?? null;
|
|
46
|
+
}
|
|
47
|
+
const index = {
|
|
48
|
+
register(app) {
|
|
49
|
+
captureApp(app);
|
|
50
|
+
app.addMenuLink({
|
|
51
|
+
to: `/plugins/${PLUGIN_ID}`,
|
|
52
|
+
icon: PluginIcon,
|
|
53
|
+
intlLabel: {
|
|
54
|
+
id: `${PLUGIN_ID}.plugin.name`,
|
|
55
|
+
defaultMessage: "Auth Dashboard"
|
|
56
|
+
},
|
|
57
|
+
Component: async () => import("./Root-DBjGZL7H.mjs")
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
bootstrap() {
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
PluginIcon as P,
|
|
65
|
+
getMediaLibraryComponent as g,
|
|
66
|
+
index as i
|
|
67
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const PluginIcon = ({
|
|
4
|
+
size = 16,
|
|
5
|
+
background = "transparent",
|
|
6
|
+
opacity = 1,
|
|
7
|
+
rotation = 0,
|
|
8
|
+
shadow = 0,
|
|
9
|
+
flipHorizontal = false,
|
|
10
|
+
flipVertical = false,
|
|
11
|
+
padding = 0
|
|
12
|
+
}) => {
|
|
13
|
+
const transforms = [];
|
|
14
|
+
if (rotation !== 0) transforms.push(`rotate(${rotation}deg)`);
|
|
15
|
+
if (flipHorizontal) transforms.push("scaleX(-1)");
|
|
16
|
+
if (flipVertical) transforms.push("scaleY(-1)");
|
|
17
|
+
const viewBoxSize = 24 + padding * 2;
|
|
18
|
+
const viewBoxOffset = -padding;
|
|
19
|
+
const viewBox = `${viewBoxOffset} ${viewBoxOffset} ${viewBoxSize} ${viewBoxSize}`;
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21
|
+
"svg",
|
|
22
|
+
{
|
|
23
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
+
viewBox,
|
|
25
|
+
width: size,
|
|
26
|
+
height: size,
|
|
27
|
+
fill: "none",
|
|
28
|
+
style: {
|
|
29
|
+
opacity,
|
|
30
|
+
transform: transforms.join(" ") || void 0,
|
|
31
|
+
filter: shadow > 0 ? `drop-shadow(0 ${shadow}px ${shadow * 2}px rgba(0,0,0,0.3))` : void 0,
|
|
32
|
+
backgroundColor: background !== "transparent" ? background : void 0
|
|
33
|
+
},
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: "Better Auth Logo" }),
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { fill: "currentColor", d: "M0 3.39v17.22h5.783v-5.55h6.434V8.939H5.783V3.39Zm12.217 5.55h5.638v6.122h-5.638v5.548H24V3.391H12.217Z" })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
const PLUGIN_ID = "better-auth-dashboard";
|
|
42
|
+
function captureApp(app) {
|
|
43
|
+
window.__betterAuthDashApp = app;
|
|
44
|
+
}
|
|
45
|
+
function getMediaLibraryComponent() {
|
|
46
|
+
return window.__betterAuthDashApp?.library?.components?.["media-library"] ?? null;
|
|
47
|
+
}
|
|
48
|
+
const index = {
|
|
49
|
+
register(app) {
|
|
50
|
+
captureApp(app);
|
|
51
|
+
app.addMenuLink({
|
|
52
|
+
to: `/plugins/${PLUGIN_ID}`,
|
|
53
|
+
icon: PluginIcon,
|
|
54
|
+
intlLabel: {
|
|
55
|
+
id: `${PLUGIN_ID}.plugin.name`,
|
|
56
|
+
defaultMessage: "Auth Dashboard"
|
|
57
|
+
},
|
|
58
|
+
Component: async () => Promise.resolve().then(() => require("./Root-BnRbzS-u.js"))
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
bootstrap() {
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.PluginIcon = PluginIcon;
|
|
65
|
+
exports.getMediaLibraryComponent = getMediaLibraryComponent;
|
|
66
|
+
exports.index = index;
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -37,7 +37,6 @@ const proxyController = () => ({
|
|
|
37
37
|
overrideOptions: { jwt: { expirationTime: "5m" } }
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
console.log("Generated JWT with payload:", { token });
|
|
41
40
|
const url = new URL(
|
|
42
41
|
ctx.request.url,
|
|
43
42
|
`${ctx.request.protocol}://${ctx.request.host}`
|
|
@@ -72,8 +71,88 @@ const proxyController = () => ({
|
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
});
|
|
74
|
+
function assertValidUid(ctx, uid) {
|
|
75
|
+
if (typeof uid !== "string" || !uid.startsWith("plugin::") && !uid.startsWith("api::") && !uid.startsWith("admin::")) {
|
|
76
|
+
ctx.status = 400;
|
|
77
|
+
ctx.body = { error: "uid must be a valid Strapi content-type UID" };
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const dbController = () => ({
|
|
83
|
+
/**
|
|
84
|
+
* List documents.
|
|
85
|
+
*
|
|
86
|
+
* Query params (all optional):
|
|
87
|
+
* uid – content-type UID, e.g. plugin::better-auth.session
|
|
88
|
+
* filters – Strapi filter object, supports nested qs syntax:
|
|
89
|
+
* ?filters[userId][$eq]=1
|
|
90
|
+
* sort – sort string or array, e.g. sort[0]=createdAt:desc
|
|
91
|
+
* pagination[page] – 1-indexed page number (default 1)
|
|
92
|
+
* pagination[pageSize] – items per page (default 50)
|
|
93
|
+
* populate – "*" for all relations, or comma-separated field names
|
|
94
|
+
*
|
|
95
|
+
* Response: { results: [...], pagination: { page, pageSize, total, pageCount } }
|
|
96
|
+
*/
|
|
97
|
+
async list(ctx) {
|
|
98
|
+
const { uid, filters, pagination, populate } = ctx.query;
|
|
99
|
+
if (!assertValidUid(ctx, uid)) return;
|
|
100
|
+
const page = Math.max(1, parseInt(pagination?.page ?? "1", 10));
|
|
101
|
+
const pageSize = Math.min(
|
|
102
|
+
200,
|
|
103
|
+
Math.max(1, parseInt(pagination?.pageSize ?? "50", 10))
|
|
104
|
+
);
|
|
105
|
+
const populateArg = populate ? populate === "*" ? "*" : populate.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
|
|
106
|
+
const service = strapi.documents(uid);
|
|
107
|
+
const [results, total] = await Promise.all([
|
|
108
|
+
service.findMany({
|
|
109
|
+
filters: filters ?? {},
|
|
110
|
+
sort: "createdAt:desc",
|
|
111
|
+
limit: pageSize,
|
|
112
|
+
start: (page - 1) * pageSize,
|
|
113
|
+
...populateArg ? { populate: populateArg } : {}
|
|
114
|
+
}),
|
|
115
|
+
strapi.documents(uid).count({ filters: filters ?? {} })
|
|
116
|
+
]);
|
|
117
|
+
ctx.body = {
|
|
118
|
+
results,
|
|
119
|
+
pagination: {
|
|
120
|
+
page,
|
|
121
|
+
pageSize,
|
|
122
|
+
total,
|
|
123
|
+
pageCount: Math.ceil(total / pageSize)
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* Update a single document by its documentId (UUID).
|
|
129
|
+
*
|
|
130
|
+
* Query params:
|
|
131
|
+
* uid – content-type UID
|
|
132
|
+
*
|
|
133
|
+
* Body: partial field values to update.
|
|
134
|
+
*
|
|
135
|
+
* Response: updated document.
|
|
136
|
+
*/
|
|
137
|
+
async update(ctx) {
|
|
138
|
+
const { uid } = ctx.query;
|
|
139
|
+
if (!assertValidUid(ctx, uid)) return;
|
|
140
|
+
const { documentId } = ctx.params;
|
|
141
|
+
const result = await strapi.documents(uid).update({
|
|
142
|
+
documentId,
|
|
143
|
+
data: ctx.request.body
|
|
144
|
+
});
|
|
145
|
+
if (!result) {
|
|
146
|
+
ctx.status = 404;
|
|
147
|
+
ctx.body = { error: "Document not found" };
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
ctx.body = result;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
75
153
|
const controllers = {
|
|
76
|
-
"auth-controller": proxyController
|
|
154
|
+
"auth-controller": proxyController,
|
|
155
|
+
"db-controller": dbController
|
|
77
156
|
};
|
|
78
157
|
const adminRoutes = () => ({
|
|
79
158
|
type: "admin",
|
|
@@ -127,6 +206,24 @@ const adminRoutes = () => ({
|
|
|
127
206
|
auth: false,
|
|
128
207
|
prefix: ""
|
|
129
208
|
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
method: "GET",
|
|
212
|
+
path: "/better-auth-dashboard/db",
|
|
213
|
+
handler: "db-controller.list",
|
|
214
|
+
config: {
|
|
215
|
+
policies: [],
|
|
216
|
+
prefix: ""
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
method: "PUT",
|
|
221
|
+
path: "/better-auth-dashboard/db/:documentId",
|
|
222
|
+
handler: "db-controller.update",
|
|
223
|
+
config: {
|
|
224
|
+
policies: [],
|
|
225
|
+
prefix: ""
|
|
226
|
+
}
|
|
130
227
|
}
|
|
131
228
|
]
|
|
132
229
|
});
|
package/dist/server/index.mjs
CHANGED
|
@@ -35,7 +35,6 @@ const proxyController = () => ({
|
|
|
35
35
|
overrideOptions: { jwt: { expirationTime: "5m" } }
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
console.log("Generated JWT with payload:", { token });
|
|
39
38
|
const url = new URL(
|
|
40
39
|
ctx.request.url,
|
|
41
40
|
`${ctx.request.protocol}://${ctx.request.host}`
|
|
@@ -70,8 +69,88 @@ const proxyController = () => ({
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
});
|
|
72
|
+
function assertValidUid(ctx, uid) {
|
|
73
|
+
if (typeof uid !== "string" || !uid.startsWith("plugin::") && !uid.startsWith("api::") && !uid.startsWith("admin::")) {
|
|
74
|
+
ctx.status = 400;
|
|
75
|
+
ctx.body = { error: "uid must be a valid Strapi content-type UID" };
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
const dbController = () => ({
|
|
81
|
+
/**
|
|
82
|
+
* List documents.
|
|
83
|
+
*
|
|
84
|
+
* Query params (all optional):
|
|
85
|
+
* uid – content-type UID, e.g. plugin::better-auth.session
|
|
86
|
+
* filters – Strapi filter object, supports nested qs syntax:
|
|
87
|
+
* ?filters[userId][$eq]=1
|
|
88
|
+
* sort – sort string or array, e.g. sort[0]=createdAt:desc
|
|
89
|
+
* pagination[page] – 1-indexed page number (default 1)
|
|
90
|
+
* pagination[pageSize] – items per page (default 50)
|
|
91
|
+
* populate – "*" for all relations, or comma-separated field names
|
|
92
|
+
*
|
|
93
|
+
* Response: { results: [...], pagination: { page, pageSize, total, pageCount } }
|
|
94
|
+
*/
|
|
95
|
+
async list(ctx) {
|
|
96
|
+
const { uid, filters, pagination, populate } = ctx.query;
|
|
97
|
+
if (!assertValidUid(ctx, uid)) return;
|
|
98
|
+
const page = Math.max(1, parseInt(pagination?.page ?? "1", 10));
|
|
99
|
+
const pageSize = Math.min(
|
|
100
|
+
200,
|
|
101
|
+
Math.max(1, parseInt(pagination?.pageSize ?? "50", 10))
|
|
102
|
+
);
|
|
103
|
+
const populateArg = populate ? populate === "*" ? "*" : populate.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
|
|
104
|
+
const service = strapi.documents(uid);
|
|
105
|
+
const [results, total] = await Promise.all([
|
|
106
|
+
service.findMany({
|
|
107
|
+
filters: filters ?? {},
|
|
108
|
+
sort: "createdAt:desc",
|
|
109
|
+
limit: pageSize,
|
|
110
|
+
start: (page - 1) * pageSize,
|
|
111
|
+
...populateArg ? { populate: populateArg } : {}
|
|
112
|
+
}),
|
|
113
|
+
strapi.documents(uid).count({ filters: filters ?? {} })
|
|
114
|
+
]);
|
|
115
|
+
ctx.body = {
|
|
116
|
+
results,
|
|
117
|
+
pagination: {
|
|
118
|
+
page,
|
|
119
|
+
pageSize,
|
|
120
|
+
total,
|
|
121
|
+
pageCount: Math.ceil(total / pageSize)
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Update a single document by its documentId (UUID).
|
|
127
|
+
*
|
|
128
|
+
* Query params:
|
|
129
|
+
* uid – content-type UID
|
|
130
|
+
*
|
|
131
|
+
* Body: partial field values to update.
|
|
132
|
+
*
|
|
133
|
+
* Response: updated document.
|
|
134
|
+
*/
|
|
135
|
+
async update(ctx) {
|
|
136
|
+
const { uid } = ctx.query;
|
|
137
|
+
if (!assertValidUid(ctx, uid)) return;
|
|
138
|
+
const { documentId } = ctx.params;
|
|
139
|
+
const result = await strapi.documents(uid).update({
|
|
140
|
+
documentId,
|
|
141
|
+
data: ctx.request.body
|
|
142
|
+
});
|
|
143
|
+
if (!result) {
|
|
144
|
+
ctx.status = 404;
|
|
145
|
+
ctx.body = { error: "Document not found" };
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
ctx.body = result;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
73
151
|
const controllers = {
|
|
74
|
-
"auth-controller": proxyController
|
|
152
|
+
"auth-controller": proxyController,
|
|
153
|
+
"db-controller": dbController
|
|
75
154
|
};
|
|
76
155
|
const adminRoutes = () => ({
|
|
77
156
|
type: "admin",
|
|
@@ -125,6 +204,24 @@ const adminRoutes = () => ({
|
|
|
125
204
|
auth: false,
|
|
126
205
|
prefix: ""
|
|
127
206
|
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
method: "GET",
|
|
210
|
+
path: "/better-auth-dashboard/db",
|
|
211
|
+
handler: "db-controller.list",
|
|
212
|
+
config: {
|
|
213
|
+
policies: [],
|
|
214
|
+
prefix: ""
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
method: "PUT",
|
|
219
|
+
path: "/better-auth-dashboard/db/:documentId",
|
|
220
|
+
handler: "db-controller.update",
|
|
221
|
+
config: {
|
|
222
|
+
policies: [],
|
|
223
|
+
prefix: ""
|
|
224
|
+
}
|
|
128
225
|
}
|
|
129
226
|
]
|
|
130
227
|
});
|
package/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const PLUGIN_ID = "better-auth-dashboard";
|
|
3
|
-
function captureApp(app) {
|
|
4
|
-
window.__betterAuthDashApp = app;
|
|
5
|
-
}
|
|
6
|
-
function getMediaLibraryComponent() {
|
|
7
|
-
return window.__betterAuthDashApp?.library?.components?.["media-library"] ?? null;
|
|
8
|
-
}
|
|
9
|
-
const index = {
|
|
10
|
-
register(app) {
|
|
11
|
-
captureApp(app);
|
|
12
|
-
app.addMenuLink({
|
|
13
|
-
to: `/plugins/${PLUGIN_ID}`,
|
|
14
|
-
icon: () => null,
|
|
15
|
-
intlLabel: {
|
|
16
|
-
id: `${PLUGIN_ID}.plugin.name`,
|
|
17
|
-
defaultMessage: "Auth Dashboard"
|
|
18
|
-
},
|
|
19
|
-
Component: async () => Promise.resolve().then(() => require("./Root-Bl4iPGDu.js"))
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
bootstrap() {
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.getMediaLibraryComponent = getMediaLibraryComponent;
|
|
26
|
-
exports.index = index;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const PLUGIN_ID = "better-auth-dashboard";
|
|
2
|
-
function captureApp(app) {
|
|
3
|
-
window.__betterAuthDashApp = app;
|
|
4
|
-
}
|
|
5
|
-
function getMediaLibraryComponent() {
|
|
6
|
-
return window.__betterAuthDashApp?.library?.components?.["media-library"] ?? null;
|
|
7
|
-
}
|
|
8
|
-
const index = {
|
|
9
|
-
register(app) {
|
|
10
|
-
captureApp(app);
|
|
11
|
-
app.addMenuLink({
|
|
12
|
-
to: `/plugins/${PLUGIN_ID}`,
|
|
13
|
-
icon: () => null,
|
|
14
|
-
intlLabel: {
|
|
15
|
-
id: `${PLUGIN_ID}.plugin.name`,
|
|
16
|
-
defaultMessage: "Auth Dashboard"
|
|
17
|
-
},
|
|
18
|
-
Component: async () => import("./Root-hwPhIfaT.mjs")
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
bootstrap() {
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
getMediaLibraryComponent as g,
|
|
26
|
-
index as i
|
|
27
|
-
};
|