@strapi-community/plugin-better-auth-dashboard 1.0.0-alpha.1 → 1.0.0-alpha.4

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.
@@ -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-7EredGQZ.js"))
59
+ });
60
+ },
61
+ bootstrap() {
62
+ }
63
+ };
64
+ exports.PluginIcon = PluginIcon;
65
+ exports.getMediaLibraryComponent = getMediaLibraryComponent;
66
+ exports.index = index;
@@ -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-B1LuKMEv.mjs")
58
+ });
59
+ },
60
+ bootstrap() {
61
+ }
62
+ };
63
+ export {
64
+ PluginIcon as P,
65
+ getMediaLibraryComponent as g,
66
+ index as i
67
+ };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-A9PUvldu.js");
3
+ const index = require("./index-CIxfFlzU.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "./index-Cvcysa5M.mjs";
1
+ import { i } from "./index-QVlTR8eL.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
@@ -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}`
@@ -63,17 +62,98 @@ const proxyController = () => ({
63
62
  ctx.set(key, value);
64
63
  });
65
64
  const contentType = response.headers.get("content-type");
66
- if (contentType?.includes("application/json")) {
67
- ctx.body = await response.json();
68
- } else if (contentType?.includes("text/")) {
69
- ctx.body = await response.text();
65
+ const text = await response.text();
66
+ if (!text) {
67
+ ctx.body = {};
68
+ } else if (contentType?.includes("application/json")) {
69
+ ctx.body = JSON.parse(text);
70
70
  } else {
71
- ctx.body = await response.text();
71
+ ctx.body = text;
72
72
  }
73
73
  }
74
74
  });
75
+ function assertValidUid(ctx, uid) {
76
+ if (typeof uid !== "string" || !uid.startsWith("plugin::") && !uid.startsWith("api::") && !uid.startsWith("admin::")) {
77
+ ctx.status = 400;
78
+ ctx.body = { error: "uid must be a valid Strapi content-type UID" };
79
+ return false;
80
+ }
81
+ return true;
82
+ }
83
+ const dbController = () => ({
84
+ /**
85
+ * List documents.
86
+ *
87
+ * Query params (all optional):
88
+ * uid – content-type UID, e.g. plugin::better-auth.session
89
+ * filters – Strapi filter object, supports nested qs syntax:
90
+ * ?filters[userId][$eq]=1
91
+ * sort – sort string or array, e.g. sort[0]=createdAt:desc
92
+ * pagination[page] – 1-indexed page number (default 1)
93
+ * pagination[pageSize] – items per page (default 50)
94
+ * populate – "*" for all relations, or comma-separated field names
95
+ *
96
+ * Response: { results: [...], pagination: { page, pageSize, total, pageCount } }
97
+ */
98
+ async list(ctx) {
99
+ const { uid, filters, pagination, populate } = ctx.query;
100
+ if (!assertValidUid(ctx, uid)) return;
101
+ const page = Math.max(1, parseInt(pagination?.page ?? "1", 10));
102
+ const pageSize = Math.min(
103
+ 200,
104
+ Math.max(1, parseInt(pagination?.pageSize ?? "50", 10))
105
+ );
106
+ const populateArg = populate ? populate === "*" ? "*" : populate.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
107
+ const service = strapi.documents(uid);
108
+ const [results, total] = await Promise.all([
109
+ service.findMany({
110
+ filters: filters ?? {},
111
+ sort: "createdAt:desc",
112
+ limit: pageSize,
113
+ start: (page - 1) * pageSize,
114
+ ...populateArg ? { populate: populateArg } : {}
115
+ }),
116
+ strapi.documents(uid).count({ filters: filters ?? {} })
117
+ ]);
118
+ ctx.body = {
119
+ results,
120
+ pagination: {
121
+ page,
122
+ pageSize,
123
+ total,
124
+ pageCount: Math.ceil(total / pageSize)
125
+ }
126
+ };
127
+ },
128
+ /**
129
+ * Update a single document by its documentId (UUID).
130
+ *
131
+ * Query params:
132
+ * uid – content-type UID
133
+ *
134
+ * Body: partial field values to update.
135
+ *
136
+ * Response: updated document.
137
+ */
138
+ async update(ctx) {
139
+ const { uid } = ctx.query;
140
+ if (!assertValidUid(ctx, uid)) return;
141
+ const { documentId } = ctx.params;
142
+ const result = await strapi.documents(uid).update({
143
+ documentId,
144
+ data: ctx.request.body
145
+ });
146
+ if (!result) {
147
+ ctx.status = 404;
148
+ ctx.body = { error: "Document not found" };
149
+ return;
150
+ }
151
+ ctx.body = result;
152
+ }
153
+ });
75
154
  const controllers = {
76
- "auth-controller": proxyController
155
+ "auth-controller": proxyController,
156
+ "db-controller": dbController
77
157
  };
78
158
  const adminRoutes = () => ({
79
159
  type: "admin",
@@ -127,6 +207,24 @@ const adminRoutes = () => ({
127
207
  auth: false,
128
208
  prefix: ""
129
209
  }
210
+ },
211
+ {
212
+ method: "GET",
213
+ path: "/better-auth-dashboard/db",
214
+ handler: "db-controller.list",
215
+ config: {
216
+ policies: [],
217
+ prefix: ""
218
+ }
219
+ },
220
+ {
221
+ method: "PUT",
222
+ path: "/better-auth-dashboard/db/:documentId",
223
+ handler: "db-controller.update",
224
+ config: {
225
+ policies: [],
226
+ prefix: ""
227
+ }
130
228
  }
131
229
  ]
132
230
  });
@@ -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}`
@@ -61,17 +60,98 @@ const proxyController = () => ({
61
60
  ctx.set(key, value);
62
61
  });
63
62
  const contentType = response.headers.get("content-type");
64
- if (contentType?.includes("application/json")) {
65
- ctx.body = await response.json();
66
- } else if (contentType?.includes("text/")) {
67
- ctx.body = await response.text();
63
+ const text = await response.text();
64
+ if (!text) {
65
+ ctx.body = {};
66
+ } else if (contentType?.includes("application/json")) {
67
+ ctx.body = JSON.parse(text);
68
68
  } else {
69
- ctx.body = await response.text();
69
+ ctx.body = text;
70
70
  }
71
71
  }
72
72
  });
73
+ function assertValidUid(ctx, uid) {
74
+ if (typeof uid !== "string" || !uid.startsWith("plugin::") && !uid.startsWith("api::") && !uid.startsWith("admin::")) {
75
+ ctx.status = 400;
76
+ ctx.body = { error: "uid must be a valid Strapi content-type UID" };
77
+ return false;
78
+ }
79
+ return true;
80
+ }
81
+ const dbController = () => ({
82
+ /**
83
+ * List documents.
84
+ *
85
+ * Query params (all optional):
86
+ * uid – content-type UID, e.g. plugin::better-auth.session
87
+ * filters – Strapi filter object, supports nested qs syntax:
88
+ * ?filters[userId][$eq]=1
89
+ * sort – sort string or array, e.g. sort[0]=createdAt:desc
90
+ * pagination[page] – 1-indexed page number (default 1)
91
+ * pagination[pageSize] – items per page (default 50)
92
+ * populate – "*" for all relations, or comma-separated field names
93
+ *
94
+ * Response: { results: [...], pagination: { page, pageSize, total, pageCount } }
95
+ */
96
+ async list(ctx) {
97
+ const { uid, filters, pagination, populate } = ctx.query;
98
+ if (!assertValidUid(ctx, uid)) return;
99
+ const page = Math.max(1, parseInt(pagination?.page ?? "1", 10));
100
+ const pageSize = Math.min(
101
+ 200,
102
+ Math.max(1, parseInt(pagination?.pageSize ?? "50", 10))
103
+ );
104
+ const populateArg = populate ? populate === "*" ? "*" : populate.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
105
+ const service = strapi.documents(uid);
106
+ const [results, total] = await Promise.all([
107
+ service.findMany({
108
+ filters: filters ?? {},
109
+ sort: "createdAt:desc",
110
+ limit: pageSize,
111
+ start: (page - 1) * pageSize,
112
+ ...populateArg ? { populate: populateArg } : {}
113
+ }),
114
+ strapi.documents(uid).count({ filters: filters ?? {} })
115
+ ]);
116
+ ctx.body = {
117
+ results,
118
+ pagination: {
119
+ page,
120
+ pageSize,
121
+ total,
122
+ pageCount: Math.ceil(total / pageSize)
123
+ }
124
+ };
125
+ },
126
+ /**
127
+ * Update a single document by its documentId (UUID).
128
+ *
129
+ * Query params:
130
+ * uid – content-type UID
131
+ *
132
+ * Body: partial field values to update.
133
+ *
134
+ * Response: updated document.
135
+ */
136
+ async update(ctx) {
137
+ const { uid } = ctx.query;
138
+ if (!assertValidUid(ctx, uid)) return;
139
+ const { documentId } = ctx.params;
140
+ const result = await strapi.documents(uid).update({
141
+ documentId,
142
+ data: ctx.request.body
143
+ });
144
+ if (!result) {
145
+ ctx.status = 404;
146
+ ctx.body = { error: "Document not found" };
147
+ return;
148
+ }
149
+ ctx.body = result;
150
+ }
151
+ });
73
152
  const controllers = {
74
- "auth-controller": proxyController
153
+ "auth-controller": proxyController,
154
+ "db-controller": dbController
75
155
  };
76
156
  const adminRoutes = () => ({
77
157
  type: "admin",
@@ -125,6 +205,24 @@ const adminRoutes = () => ({
125
205
  auth: false,
126
206
  prefix: ""
127
207
  }
208
+ },
209
+ {
210
+ method: "GET",
211
+ path: "/better-auth-dashboard/db",
212
+ handler: "db-controller.list",
213
+ config: {
214
+ policies: [],
215
+ prefix: ""
216
+ }
217
+ },
218
+ {
219
+ method: "PUT",
220
+ path: "/better-auth-dashboard/db/:documentId",
221
+ handler: "db-controller.update",
222
+ config: {
223
+ policies: [],
224
+ prefix: ""
225
+ }
128
226
  }
129
227
  ]
130
228
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi-community/plugin-better-auth-dashboard",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "Better Auth dashboard for the Strapi admin panel",
5
5
  "keywords": [
6
6
  "strapi",
@@ -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
- };