@bananacool467/authtics-host 0.2.3 → 0.2.5
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/README.md +8 -7
- package/dist/cli.js +40 -37
- package/dist/devPanel.js +26 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Authtics Host
|
|
2
2
|
|
|
3
|
-
Version 0.2.
|
|
4
|
-
License: MIT
|
|
3
|
+
Version 0.2.5, License: MIT
|
|
5
4
|
|
|
6
5
|
Authtics Host is a web framework inspired by Next.js. Authtics Host supports SSR (Server-Side Rendering) and uses esbuild. This is not to be confused with auth platforms.
|
|
7
6
|
|
|
@@ -37,7 +36,7 @@ To make your app, with auto paging and auto filing, your file tree should look l
|
|
|
37
36
|
index.tsx
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
**(
|
|
39
|
+
**(Note: the public folder is for auto filing)**
|
|
41
40
|
|
|
42
41
|
`index.ts` should look like:
|
|
43
42
|
```ts
|
|
@@ -115,9 +114,9 @@ export default function App() {
|
|
|
115
114
|
)
|
|
116
115
|
}
|
|
117
116
|
```
|
|
118
|
-
**(
|
|
117
|
+
**(Note: You can change the `statusCode` to anything you want, the property is optional, it either gives 404 or 200 if the `statusCode` is missing.)**
|
|
119
118
|
|
|
120
|
-
**(
|
|
119
|
+
**(Note: To make an 404 page you can use:**
|
|
121
120
|
```tsx
|
|
122
121
|
<Route statusCode={404} page={NotFound} />
|
|
123
122
|
```
|
|
@@ -167,7 +166,7 @@ The Developer Panel is what you could use to help you debug your code. The Devel
|
|
|
167
166
|
|
|
168
167
|
The information the Developer Panel shows outside of the tabs is just your **DAT** (Developer Access Token).
|
|
169
168
|
|
|
170
|
-
**(
|
|
169
|
+
**(Note: If you do not set DAT restriction (Which will be explained on how to set it up in the next section), you will only get access to the Console and Network tabs)**
|
|
171
170
|
|
|
172
171
|
The Developer Panel also have remote buttons:
|
|
173
172
|
|
|
@@ -229,6 +228,8 @@ export function Component() {
|
|
|
229
228
|
|
|
230
229
|
The developer might also redesign the UI for the DevPanel using [UI Tools](https://npmjs.com/package/@bananakitssu/ui-tools).
|
|
231
230
|
|
|
231
|
+
And also maybe, add Developer Panel customization.
|
|
232
|
+
|
|
232
233
|
> **Warning**:
|
|
233
234
|
> Asking AI about HostJS is not recommended, it will give an Auth platform and call HostJS/Authtics Host a typo, say it doesn't exist, say it was renamed, it is private, or the account doesn't exist. Or if it knows, it may swap your server script with regular **Node.js**/**ExpressJS**/**Next.js** or use **Next.js-like** code because this framework is **Next.js-inspired**
|
|
234
235
|
|
|
@@ -254,7 +255,7 @@ But if you have multiple DATs, then use:
|
|
|
254
255
|
|
|
255
256
|
There isn't any limit of DATs you can add.
|
|
256
257
|
|
|
257
|
-
**(
|
|
258
|
+
**(Note: Adding your DAT will give you access to Restart and Shutdown and Pause/Resume Users and other features in the Developer Panel)**
|
|
258
259
|
|
|
259
260
|
## Reasons for the name, Authtics Host
|
|
260
261
|
|
package/dist/cli.js
CHANGED
|
@@ -143,9 +143,9 @@ export default class App {
|
|
|
143
143
|
this.startServer();
|
|
144
144
|
this.post('/__authtics_host_apis__/set-users-paused', async (req, res) => {
|
|
145
145
|
let datMatched = false;
|
|
146
|
-
if (config_.dat && config_.dat == req.
|
|
146
|
+
if (config_.dat && config_.dat == req.dat)
|
|
147
147
|
datMatched = true;
|
|
148
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
148
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
149
149
|
datMatched = true;
|
|
150
150
|
if (datMatched) {
|
|
151
151
|
usersPaused = req.body.paused;
|
|
@@ -157,9 +157,9 @@ export default class App {
|
|
|
157
157
|
});
|
|
158
158
|
this.post('/__authtics_host_apis__/is-users-paused', async (req, res) => {
|
|
159
159
|
let datMatched = false;
|
|
160
|
-
if (config_.dat && config_.dat == req.
|
|
160
|
+
if (config_.dat && config_.dat == req.dat)
|
|
161
161
|
datMatched = true;
|
|
162
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
162
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
163
163
|
datMatched = true;
|
|
164
164
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
165
165
|
if (datMatched) {
|
|
@@ -172,11 +172,11 @@ export default class App {
|
|
|
172
172
|
this.post('/__authtics_host_apis__/get-dat-restriction-missing', async (req, res) => {
|
|
173
173
|
let datMatched = false;
|
|
174
174
|
let datRestrictedEnv = false;
|
|
175
|
-
if (config_.dat && config_.dat == req.
|
|
175
|
+
if (config_.dat && config_.dat == req.dat)
|
|
176
176
|
datMatched = true;
|
|
177
177
|
if (config_.dat == undefined)
|
|
178
178
|
datMatched = true;
|
|
179
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
179
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
180
180
|
datMatched = true;
|
|
181
181
|
if (datMatched) {
|
|
182
182
|
if (config_.dat !== undefined)
|
|
@@ -189,11 +189,11 @@ export default class App {
|
|
|
189
189
|
});
|
|
190
190
|
this.post('/__authtics_host_apis__/get-dat-matching', async (req, res) => {
|
|
191
191
|
let datMatched = false;
|
|
192
|
-
if (config_.dat && config_.dat == req.
|
|
192
|
+
if (config_.dat && config_.dat == req.dat)
|
|
193
193
|
datMatched = true;
|
|
194
194
|
if (config_.dat == undefined)
|
|
195
195
|
datMatched = true;
|
|
196
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
196
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
197
197
|
datMatched = true;
|
|
198
198
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
199
199
|
res.end(JSON.stringify({
|
|
@@ -202,9 +202,9 @@ export default class App {
|
|
|
202
202
|
});
|
|
203
203
|
this.post('/__authtics_host_apis__/get-cpu_memory', async (req, res) => {
|
|
204
204
|
let datMatched = false;
|
|
205
|
-
if (config_.dat && config_.dat == req.
|
|
205
|
+
if (config_.dat && config_.dat == req.dat)
|
|
206
206
|
datMatched = true;
|
|
207
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
207
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
208
208
|
datMatched = true;
|
|
209
209
|
if (datMatched) {
|
|
210
210
|
const { heapUsed, heapTotal, rss } = process.memoryUsage();
|
|
@@ -212,15 +212,16 @@ export default class App {
|
|
|
212
212
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
213
213
|
res.end(JSON.stringify({
|
|
214
214
|
cpuUsage,
|
|
215
|
-
heapUsed
|
|
215
|
+
heapUsed,
|
|
216
|
+
heapTotal
|
|
216
217
|
}));
|
|
217
218
|
}
|
|
218
219
|
});
|
|
219
220
|
this.post('/__authtics_host_apis__/get-user-settings', async (req, res) => {
|
|
220
221
|
let datMatched = false;
|
|
221
|
-
if (config_.dat && config_.dat == req.
|
|
222
|
+
if (config_.dat && config_.dat == req.dat)
|
|
222
223
|
datMatched = true;
|
|
223
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
224
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
224
225
|
datMatched = true;
|
|
225
226
|
if (datMatched) {
|
|
226
227
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -231,9 +232,9 @@ export default class App {
|
|
|
231
232
|
});
|
|
232
233
|
this.post("/__authtics_host_apis__/get-server-info", async (req, res) => {
|
|
233
234
|
let datMatched = false;
|
|
234
|
-
if (config_.dat && config_.dat == req.
|
|
235
|
+
if (config_.dat && config_.dat == req.dat)
|
|
235
236
|
datMatched = true;
|
|
236
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
237
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
237
238
|
datMatched = true;
|
|
238
239
|
if (datMatched) {
|
|
239
240
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -244,9 +245,9 @@ export default class App {
|
|
|
244
245
|
});
|
|
245
246
|
this.post("/__authtics_host_apis__/restart", async (req, res) => {
|
|
246
247
|
let datMatched = false;
|
|
247
|
-
if (config_.dat && config_.dat == req.
|
|
248
|
+
if (config_.dat && config_.dat == req.dat)
|
|
248
249
|
datMatched = true;
|
|
249
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
250
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
250
251
|
datMatched = true;
|
|
251
252
|
if (datMatched) {
|
|
252
253
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -257,14 +258,16 @@ export default class App {
|
|
|
257
258
|
stdio: 'inherit'
|
|
258
259
|
});
|
|
259
260
|
child.unref();
|
|
260
|
-
|
|
261
|
+
this.server.close(() => {
|
|
262
|
+
process.kill(process.pid, 'SIGTERM');
|
|
263
|
+
});
|
|
261
264
|
}
|
|
262
265
|
});
|
|
263
266
|
this.post("/__authtics_host_apis__/shutdown", async (req, res) => {
|
|
264
267
|
let datMatched = false;
|
|
265
|
-
if (config_.dat && config_.dat == req.
|
|
268
|
+
if (config_.dat && config_.dat == req.dat)
|
|
266
269
|
datMatched = true;
|
|
267
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
270
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
268
271
|
datMatched = true;
|
|
269
272
|
if (datMatched) {
|
|
270
273
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -276,9 +279,9 @@ export default class App {
|
|
|
276
279
|
});
|
|
277
280
|
this.post("/__authtics_host_apis__/get-is-ssr", async (req, res) => {
|
|
278
281
|
let datMatched = false;
|
|
279
|
-
if (config_.dat && config_.dat == req.
|
|
282
|
+
if (config_.dat && config_.dat == req.dat)
|
|
280
283
|
datMatched = true;
|
|
281
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
284
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
282
285
|
datMatched = true;
|
|
283
286
|
if (datMatched) {
|
|
284
287
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -289,9 +292,9 @@ export default class App {
|
|
|
289
292
|
});
|
|
290
293
|
this.post("/__authtics_host_apis__/get-compiler", async (req, res) => {
|
|
291
294
|
let datMatched = false;
|
|
292
|
-
if (config_.dat && config_.dat == req.
|
|
295
|
+
if (config_.dat && config_.dat == req.dat)
|
|
293
296
|
datMatched = true;
|
|
294
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
297
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
295
298
|
datMatched = true;
|
|
296
299
|
if (datMatched) {
|
|
297
300
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -302,9 +305,9 @@ export default class App {
|
|
|
302
305
|
});
|
|
303
306
|
this.post("/__authtics_host_apis__/get-host-ver", async (req, res) => {
|
|
304
307
|
let datMatched = false;
|
|
305
|
-
if (config_.dat && config_.dat == req.
|
|
308
|
+
if (config_.dat && config_.dat == req.dat)
|
|
306
309
|
datMatched = true;
|
|
307
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
310
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
308
311
|
datMatched = true;
|
|
309
312
|
if (datMatched) {
|
|
310
313
|
const packageJsonPath = path.join(__dirname, '../package.json');
|
|
@@ -320,9 +323,9 @@ export default class App {
|
|
|
320
323
|
});
|
|
321
324
|
this.post("/__authtics_host_apis__/get-file-by-pathname", async (req, res) => {
|
|
322
325
|
let datMatched = false;
|
|
323
|
-
if (config_.dat && config_.dat == req.
|
|
326
|
+
if (config_.dat && config_.dat == req.dat)
|
|
324
327
|
datMatched = true;
|
|
325
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
328
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
326
329
|
datMatched = true;
|
|
327
330
|
if (datMatched) {
|
|
328
331
|
const pathname = req.body.pathname;
|
|
@@ -357,9 +360,9 @@ export default class App {
|
|
|
357
360
|
});
|
|
358
361
|
this.post("/__authtics_host_apis__/ping", async (req, res) => {
|
|
359
362
|
let datMatched = false;
|
|
360
|
-
if (config_.dat && config_.dat == req.
|
|
363
|
+
if (config_.dat && config_.dat == req.dat)
|
|
361
364
|
datMatched = true;
|
|
362
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
365
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
363
366
|
datMatched = true;
|
|
364
367
|
if (datMatched) {
|
|
365
368
|
res.setHeader("Content-Type", "application/json");
|
|
@@ -368,9 +371,9 @@ export default class App {
|
|
|
368
371
|
});
|
|
369
372
|
this.post('/__authtics_host_apis__/get-connection', async (req, res) => {
|
|
370
373
|
let datMatched = false;
|
|
371
|
-
if (config_.dat && config_.dat == req.
|
|
374
|
+
if (config_.dat && config_.dat == req.dat)
|
|
372
375
|
datMatched = true;
|
|
373
|
-
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.
|
|
376
|
+
if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(req.dat))
|
|
374
377
|
datMatched = true;
|
|
375
378
|
if (datMatched) {
|
|
376
379
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -552,7 +555,7 @@ async function start() {
|
|
|
552
555
|
}
|
|
553
556
|
const routeKey = `${method}:${pathname}`;
|
|
554
557
|
if (routes.has(routeKey)) {
|
|
555
|
-
if (Array.isArray(config_.dat) && !config_.dat.includes(req.
|
|
558
|
+
if (Array.isArray(config_.dat) && !config_.dat.includes(req.dat) && usersPaused && !routeKey.endsWith('.js')) {
|
|
556
559
|
if (autoPaging) {
|
|
557
560
|
const pausedTsxFile = pagesDir ? path.join(pagesDir, "_paused.tsx") : undefined;
|
|
558
561
|
if (fs.existsSync(pausedTsxFile || "")) {
|
|
@@ -562,7 +565,7 @@ async function start() {
|
|
|
562
565
|
res.setHeader("Content-Type", "application/javascript");
|
|
563
566
|
res.end(f);
|
|
564
567
|
});
|
|
565
|
-
}, (p) => { routes.delete(`GET:${p}`); }, req.
|
|
568
|
+
}, (p) => { routes.delete(`GET:${p}`); }, req.dat, config_.dat);
|
|
566
569
|
html = html.replace("<script>", "<script>\nwindow.__paused__ = true;");
|
|
567
570
|
res.setHeader("Content-Type", "text/html");
|
|
568
571
|
return res.end(html);
|
|
@@ -605,7 +608,7 @@ async function start() {
|
|
|
605
608
|
message: "unhandled request"
|
|
606
609
|
}));
|
|
607
610
|
}
|
|
608
|
-
if (config_.dat !== req.
|
|
611
|
+
if (config_.dat !== req.dat && usersPaused && !routeKey.endsWith('.js') && !Array.isArray(config_.dat)) {
|
|
609
612
|
if (autoPaging) {
|
|
610
613
|
const pausedTsxFile = pagesDir ? path.join(pagesDir, "_paused.tsx") : undefined;
|
|
611
614
|
if (fs.existsSync(pausedTsxFile || "")) {
|
|
@@ -679,7 +682,7 @@ async function start() {
|
|
|
679
682
|
req.on('close', () => { hmrClients.delete(res); users--; });
|
|
680
683
|
return;
|
|
681
684
|
}
|
|
682
|
-
if (Array.isArray(config_.dat) && !config_.dat.includes(req.
|
|
685
|
+
if (Array.isArray(config_.dat) && !config_.dat.includes(req.dat) && usersPaused) {
|
|
683
686
|
if (autoPaging) {
|
|
684
687
|
const pausedTsxFile = pagesDir ? path.join(pagesDir, "_paused.tsx") : undefined;
|
|
685
688
|
if (fs.existsSync(pausedTsxFile || "")) {
|
|
@@ -732,7 +735,7 @@ async function start() {
|
|
|
732
735
|
message: "unhandled request"
|
|
733
736
|
}));
|
|
734
737
|
}
|
|
735
|
-
if (config.dat !== req.
|
|
738
|
+
if (config.dat !== req.dat && usersPaused && !Array.isArray(config_.dat)) {
|
|
736
739
|
if (autoPaging) {
|
|
737
740
|
const pausedTsxFile = pagesDir ? path.join(pagesDir, "_paused.tsx") : undefined;
|
|
738
741
|
if (fs.existsSync(pausedTsxFile || "")) {
|
package/dist/devPanel.js
CHANGED
|
@@ -367,6 +367,7 @@ export default function DevPanel() {
|
|
|
367
367
|
const datRestrictionMissingRef = useRef(true);
|
|
368
368
|
const cpuUsage = useRef(0);
|
|
369
369
|
const heapUsage = useRef(0);
|
|
370
|
+
const heapTotal = useRef(0);
|
|
370
371
|
const [datMatch, setDatMatch] = useState(false);
|
|
371
372
|
const [compilerType, setCompilerType] = useState("?");
|
|
372
373
|
const [httpVersion, setHttpVersion] = useState("v?.?");
|
|
@@ -384,6 +385,7 @@ export default function DevPanel() {
|
|
|
384
385
|
const consoleScrollRef = useRef(null);
|
|
385
386
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
386
387
|
const [datRestrictionMissing, setDatRestrictionMissing] = useState(true);
|
|
388
|
+
const [heapResult, setHeapResult] = useState("0 Bytes / 0 Bytes");
|
|
387
389
|
const cookie = {
|
|
388
390
|
set: (k, v) => document.cookie = `${k}=${v}; path=/`,
|
|
389
391
|
get: (k) => Object.fromEntries(document.cookie.split(";")
|
|
@@ -484,6 +486,7 @@ export default function DevPanel() {
|
|
|
484
486
|
const data = await resp.json();
|
|
485
487
|
cpuUsage.current = data.cpuUsage;
|
|
486
488
|
heapUsage.current = data.heapUsed;
|
|
489
|
+
heapTotal.current = data.heapTotal;
|
|
487
490
|
}
|
|
488
491
|
};
|
|
489
492
|
const getHostVersion = async () => {
|
|
@@ -630,19 +633,31 @@ export default function DevPanel() {
|
|
|
630
633
|
}, 1000);
|
|
631
634
|
return () => clearInterval(interval);
|
|
632
635
|
}, []);
|
|
636
|
+
const formatBytes = (b, d = 2, r = false) => {
|
|
637
|
+
if (b === 0)
|
|
638
|
+
return r ? 'Bytes' : '0 Bytes';
|
|
639
|
+
const k = 1024;
|
|
640
|
+
const dm = d < 0 ? 0 : d;
|
|
641
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
642
|
+
const i = Math.floor(Math.log(b) / Math.log(k));
|
|
643
|
+
return r ? sizes[i] : parseFloat((b / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
644
|
+
};
|
|
633
645
|
useEffect(() => {
|
|
634
646
|
const interval = setInterval(() => {
|
|
635
647
|
const s = pendingSent.current;
|
|
636
648
|
const r = pendingReceived.current;
|
|
637
649
|
const c = cpuUsage.current;
|
|
638
|
-
const h = heapUsage.current;
|
|
650
|
+
const h = formatBytes(heapUsage.current);
|
|
651
|
+
const t = ` ${formatBytes(heapUsage.current, 0, true)} / ` + formatBytes(heapTotal.current);
|
|
652
|
+
setHeapResult(t);
|
|
653
|
+
const h_num = Number(h.split(" ")[0]);
|
|
639
654
|
const f = frames.current;
|
|
640
655
|
pendingSent.current = 0;
|
|
641
656
|
pendingReceived.current = 0;
|
|
642
657
|
cpuUsage.current = 0;
|
|
643
658
|
heapUsage.current = 0;
|
|
644
659
|
setCpuUsageHistory(prev => [...prev.slice(-(MAX_POINTS - 1)), c]);
|
|
645
|
-
setHeapUsageHistory(prev => [...prev.slice(-(MAX_POINTS - 1)),
|
|
660
|
+
setHeapUsageHistory(prev => [...prev.slice(-(MAX_POINTS - 1)), h_num]);
|
|
646
661
|
setSentHistory(prev => [...prev.slice(-(MAX_POINTS - 1)), s]);
|
|
647
662
|
setReceivedHistory(prev => [...prev.slice(-(MAX_POINTS - 1)), r]);
|
|
648
663
|
setFpsHistory(prev => [...prev.slice(-(MAX_POINTS - 1)), f]);
|
|
@@ -667,11 +682,7 @@ export default function DevPanel() {
|
|
|
667
682
|
;
|
|
668
683
|
};
|
|
669
684
|
try {
|
|
670
|
-
|
|
671
|
-
try {
|
|
672
|
-
existingToken = localStorage.getItem('dat');
|
|
673
|
-
}
|
|
674
|
-
catch (e) { }
|
|
685
|
+
const existingToken = cookie.get('dat');
|
|
675
686
|
if (existingToken) {
|
|
676
687
|
setToken(existingToken);
|
|
677
688
|
let length_ = existingToken?.split('');
|
|
@@ -685,22 +696,12 @@ export default function DevPanel() {
|
|
|
685
696
|
const serverDatRestricted = cfg?.datRestricted === true;
|
|
686
697
|
if (serverDevMode && !serverDatRestricted) {
|
|
687
698
|
const newToken = generateToken();
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
cookie.set('dat', localStorageToken || newToken);
|
|
695
|
-
setToken(newToken);
|
|
696
|
-
let length_ = newToken?.split('');
|
|
697
|
-
let length;
|
|
698
|
-
length = length_?.length;
|
|
699
|
-
setTokenLength(length);
|
|
700
|
-
}
|
|
701
|
-
catch (error) {
|
|
702
|
-
console.error('[Authtics Host] Error storing token in localStorage:', error);
|
|
703
|
-
}
|
|
699
|
+
cookie.set('dat', newToken);
|
|
700
|
+
setToken(newToken);
|
|
701
|
+
let length_ = newToken?.split('');
|
|
702
|
+
let length;
|
|
703
|
+
length = length_?.length;
|
|
704
|
+
setTokenLength(length);
|
|
704
705
|
}
|
|
705
706
|
}
|
|
706
707
|
}
|
|
@@ -1168,7 +1169,7 @@ export default function DevPanel() {
|
|
|
1168
1169
|
border: '1px solid #eee',
|
|
1169
1170
|
fontSize: '12px',
|
|
1170
1171
|
color: '#333',
|
|
1171
|
-
}, children: [_jsx("span", { style: { fontSize: '12px', color: '#333' }, children: "Total current users" }), _jsx("span", { style: { fontSize: '12px', color: 'blue' }, children: users })] }), _jsx(Sparkline, { data: cpuUsageHistory, color: "#3b82f6", label: "CPU Usage", unit: "" }), _jsx(Sparkline, { data: heapUsageHistory, color: "#3b82f6", label: "Heap Used", unit:
|
|
1172
|
+
}, children: [_jsx("span", { style: { fontSize: '12px', color: '#333' }, children: "Total current users" }), _jsx("span", { style: { fontSize: '12px', color: 'blue' }, children: users })] }), _jsx(Sparkline, { data: cpuUsageHistory, color: "#3b82f6", label: "CPU Usage", unit: "" }), _jsx(Sparkline, { data: heapUsageHistory, color: "#3b82f6", label: "Heap Used", unit: heapResult })] })] })) : !shutdown ? (_jsxs(_Fragment, { children: [_jsxs("div", { style: { padding: '8px', gap: '4px', display: 'flex', flexDirection: 'column' }, children: [_jsxs(PanelButton, { onClick: () => setConsoleOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Terminal, { size: 12, color: "#16a34a" }), " Console"] }), logs.length > 0 && (_jsx("span", { style: { color: '#111', borderRadius: '100px', padding: '1px 6px', fontSize: '10px' }, children: logs.length }))] }), _jsxs(PanelButton, { onClick: () => setRouteOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Route, { size: 12, color: "#3b82f6" }), " Route"] }), _jsxs("span", { style: { color: '#111', borderRadius: '100px', padding: '1px 6px', fontSize: '10px', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '4px' }, children: [datRestrictionMissing && _jsx(TriangleAlert, { size: 12, color: "orange" }), pathName] })] }), _jsxs(PanelButton, { onClick: () => setWebpageInfoOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Globe, { size: 12, color: "#3b82f6" }), " Webpage Info"] }), datRestrictionMissing && _jsx(TriangleAlert, { size: 12, color: "orange" })] }), _jsx(PanelButton, { onClick: () => setNetworkOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: _jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Wifi, { size: 12, color: "#3b82f6" }), " Network"] }) }), _jsxs(PanelButton, { onClick: () => setClientInfoOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Info, { size: 12, color: "#3b82f6" }), " Client Info"] }), datRestrictionMissing && _jsx(TriangleAlert, { size: 12, color: "orange" })] }), _jsxs(PanelButton, { onClick: () => setAboutHostOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(ShieldCheck, { size: 12, color: "#f472b6" }), " About HostJS"] }), datRestrictionMissing && _jsx(TriangleAlert, { size: 12, color: "orange" })] }), _jsxs(PanelButton, { onClick: () => setServerInfoOpen(true), fullWidth: true, style: { color: '#333', justifyContent: 'space-between', height: '32px' }, children: [_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx(Server, { size: 12, color: "#f472b6" }), " Server Info"] }), datRestrictionMissing && _jsx(TriangleAlert, { size: 12, color: "orange" })] })] }), _jsxs("div", { style: {
|
|
1172
1173
|
padding: '6px 8px',
|
|
1173
1174
|
borderTop: '1px solid #ddd',
|
|
1174
1175
|
background: '#fff',
|
|
@@ -1222,7 +1223,7 @@ export default function DevPanel() {
|
|
|
1222
1223
|
gap: '6px',
|
|
1223
1224
|
color: '#fff',
|
|
1224
1225
|
flexDirection: 'row',
|
|
1225
|
-
}, children: "Updates to security. Apps with version 0.0.1-beta.9 and over will now require DAT restriction to access remote features like restarting and shutting down the app." }) })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { restart(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#ba4e4e') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Restart App" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Restarting the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { shutDown(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#ba4e4e') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Shut Down App" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Shutting down the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { pause_Resume_Users(); }, fullWidth: true, style: { color: (datRestrictionMissing ? '#fff' : '#333'), justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#f2f2f2') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: usersPausedRealInfo ? "Resume Users" : "Pause Users" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Pausing users from accessing the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {}))] })] })) : (_jsx(_Fragment, {}))] }) }), datMatch ? (_jsxs("div", { onClick: () => setOpen(o => !o), style: {
|
|
1226
|
+
}, children: "Updates to security. Apps with version 0.0.1-beta.9 and over will now require DAT restriction to access remote features like restarting and shutting down the app." }) })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { restart(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#ba4e4e') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Restart App" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Restarting the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { shutDown(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#ba4e4e') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: shuttingDown ? "Shutting Down App" : "Shut Down App" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Shutting down the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { pause_Resume_Users(); }, fullWidth: true, style: { color: (datRestrictionMissing ? '#fff' : '#333'), justifyContent: 'center', height: '32px', background: (datRestrictionMissing ? '#bdbdbd' : '#f2f2f2') }, disabled: datRestrictionMissing, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: usersPausedRealInfo ? "Resume Users" : "Pause Users" }) }), datRestrictionMissing ? (_jsxs("span", { style: { display: 'flex', opacity: 0.5, fontSize: 10, justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(Info, { size: 30 }), "Pausing users from accessing the app is unavaliable. Set \"dat\" to your current DAT in the Authtics Host config to set restriction and then restart."] })) : (_jsx(_Fragment, {}))] })] })) : (_jsx(_Fragment, {}))] }) }), datMatch ? (_jsxs("div", { onClick: () => setOpen(o => !o), style: {
|
|
1226
1227
|
display: 'flex',
|
|
1227
1228
|
flexDirection: 'row',
|
|
1228
1229
|
alignItems: 'center',
|
package/package.json
CHANGED