@bananacool467/authtics-host 0.0.1-beta.7 → 0.0.1-beta.8

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 CHANGED
@@ -1,9 +1,9 @@
1
1
  # Authtics Host
2
2
 
3
- Version 0.0.1-beta.7
3
+ Version 0.0.1-beta.8
4
4
  License: MIT
5
5
 
6
- (NOTE: This version is in BETA, bugs are expected)
6
+ **(NOTE: This version is in BETA, bugs are expected)**
7
7
 
8
8
  Authtics Host is a framework inspired by Next.js. Authtics Host supports SSR (Server-Side Rendering) and uses esbuild.
9
9
 
@@ -33,14 +33,14 @@ To make your app, with auto paging and auto filing, your file tree should look l
33
33
 
34
34
  **(NOTE: the public folder is for auto filing)**
35
35
 
36
- index.ts should look like:
36
+ `index.ts` should look like:
37
37
  ```ts
38
38
  import { App } from "@bananacool467/authtics-host";
39
39
 
40
40
  const app = new App();
41
41
  ```
42
42
 
43
- authtics_host.config.ts should look like:
43
+ `authtics_host.config.ts` should look like:
44
44
  ```ts
45
45
  import { defineConfig } from "@bananacool467/authtics-host";
46
46
 
@@ -55,7 +55,7 @@ export default defineConfig({
55
55
  })
56
56
  ```
57
57
 
58
- client/pages/index.tsx should look like:
58
+ `client/pages/index.tsx` should look like:
59
59
  ```tsx
60
60
  export default function Index () {
61
61
  return (
@@ -75,7 +75,7 @@ To make your app, without auto paging and auto filing, your file tree should loo
75
75
  index.tsx
76
76
  ```
77
77
 
78
- index.ts should look like:
78
+ `index.ts` should look like:
79
79
  ```ts
80
80
  import { App } from "@bananacool467/authtics-host";
81
81
 
@@ -83,7 +83,7 @@ const app = new App();
83
83
  app.registerApp("client/app.tsx");
84
84
  ```
85
85
 
86
- authtics_host.config.ts should look like:
86
+ `authtics_host.config.ts` should look like:
87
87
  ```ts
88
88
  import { defineConfig } from "@bananacool467/authtics-host";
89
89
 
@@ -96,7 +96,7 @@ export default defineConfig({
96
96
  })
97
97
  ```
98
98
 
99
- client/app.tsx should look like:
99
+ `client/app.tsx` should look like:
100
100
  ```tsx
101
101
  import { Route } from "@bananacool467/authtics-host";
102
102
  import Index from "./pages/index";
@@ -110,7 +110,7 @@ export default function App() {
110
110
  }
111
111
  ```
112
112
 
113
- client/pages/index.tsx should look like:
113
+ `client/pages/index.tsx` should look like:
114
114
  ```tsx
115
115
  export default function Index () {
116
116
  return (
@@ -119,14 +119,14 @@ export default function Index () {
119
119
  }
120
120
  ```
121
121
 
122
- ## To run the project
122
+ ## To Run The Project
123
123
 
124
- Make sure Node 22 is installed:
124
+ Make sure **Node 22** is installed:
125
125
  ```
126
126
  nvm install 22
127
127
  ```
128
128
 
129
- To switch to Node 22 use:
129
+ To switch to **Node 22** use:
130
130
  ```
131
131
  nvm use 22
132
132
  ```
@@ -138,9 +138,9 @@ node --experimental-strip-types index.ts
138
138
 
139
139
  ## Result
140
140
 
141
- Then when you run your project, you will get a page just saying **"Hello, World!"** and you should see a panel at the bottom-right.
141
+ Then when you run your project, you will get a page just saying **"Hello, World!"** and you should see a clickable Developer Panel at the bottom-right.
142
142
 
143
- ## Developer Panel Notes and Warnings And DAT (Developer Access Token)
143
+ ## Developer Panel Notes And Warnings And DAT (Developer Access Token)
144
144
 
145
145
  A DAT (Developer Access Token) is your token that is used to access the Developer Panel.
146
146
 
@@ -164,6 +164,6 @@ There isn't any limit of DATs you can add.
164
164
 
165
165
  **(Warning: Make sure `devMode` is set to `false` in production. If `devMode` is on and DAT restriction is disabled, anyone can access the restart and shutdown endpoints.)**
166
166
 
167
- ## Contacting
167
+ ## Contacting The Developer Of Authtics Host
168
168
 
169
169
  If you ever encounter a bug, report it to (or have questions, contact): authtics@proton.me
package/dist/cli.js CHANGED
@@ -110,6 +110,20 @@ export default class App {
110
110
  server;
111
111
  constructor() {
112
112
  this.server = start();
113
+ this.post('/__authtics_host_apis__/get-dat-matching', async (req, res) => {
114
+ const reqBody = (await getJsonBody(req));
115
+ let datMatched = false;
116
+ if (config_.dat && config_.dat == reqBody.dat)
117
+ datMatched = true;
118
+ if (config_.dat == undefined)
119
+ datMatched = true;
120
+ if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(reqBody.dat))
121
+ datMatched = true;
122
+ res.writeHead(200, { "Content-Type": "application/json" });
123
+ res.end(JSON.stringify({
124
+ isMatching: datMatched
125
+ }));
126
+ });
113
127
  this.post('/__authtics_host_apis__/get-cpu_memory', async (req, res) => {
114
128
  const reqBody = (await getJsonBody(req));
115
129
  let datMatched = false;
@@ -233,6 +247,27 @@ export default class App {
233
247
  }));
234
248
  }
235
249
  });
250
+ this.post("/__authtics_host_apis__/get-host-ver", async (req, res) => {
251
+ const reqBody = (await getJsonBody(req));
252
+ let datMatched = false;
253
+ if (config_.dat && config_.dat == reqBody.dat)
254
+ datMatched = true;
255
+ if (config_.dat == undefined)
256
+ datMatched = true;
257
+ if (config_.dat && Array.isArray(config_.dat) && config_.dat.includes(reqBody.dat))
258
+ datMatched = true;
259
+ if (datMatched) {
260
+ const packageJsonPath = path.join(__dirname, '../package.json');
261
+ let packageJson;
262
+ if (fs.existsSync(packageJsonPath))
263
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
264
+ const packageJsonVersion = packageJson.version || "Unknown";
265
+ res.writeHead(200, { "Content-Type": "application/json" });
266
+ res.end(JSON.stringify({
267
+ version: packageJsonVersion
268
+ }));
269
+ }
270
+ });
236
271
  this.post("/__authtics_host_apis__/get-file-by-pathname", async (req, res) => {
237
272
  const reqBody = (await getJsonBody(req));
238
273
  let datMatched = false;
@@ -245,7 +280,8 @@ export default class App {
245
280
  if (datMatched) {
246
281
  const pathname = reqBody.pathname;
247
282
  const pagesDir = config_.autoPage === true ? path.join(process.cwd(), config_.autoPageDir || "") : undefined;
248
- const filePath = pagesDir ? path.join(pagesDir, pathname + ".tsx") : undefined;
283
+ const safePath = path.normalize(pathname).replace(/^(\.\.[\/\\])+/, '');
284
+ const filePath = pagesDir ? path.join(pagesDir, safePath + ".tsx") : undefined;
249
285
  const fileExists = filePath ? fs.existsSync(filePath) : true;
250
286
  res.writeHead(200, { "Content-Type": "application/json" });
251
287
  res.end(JSON.stringify({
package/dist/devPanel.js CHANGED
@@ -194,12 +194,14 @@ export default function DevPanel() {
194
194
  const [isSsr, setIsSsr] = useState(false);
195
195
  const cpuUsage = useRef(0);
196
196
  const heapUsage = useRef(0);
197
+ const [datMatch, setDatMatch] = useState(false);
197
198
  const [compilerType, setCompilerType] = useState("?");
198
199
  const [errorDetail, setErrorDetail] = useState(undefined);
199
200
  const [httpVersion, setHttpVersion] = useState("v?.?");
200
201
  const [errorBoxOpenable, setErrorBoxOpenable] = useState(false);
201
202
  const [uptime, setUptime] = useState("00:00:00:00");
202
203
  const [requests, setRequests] = useState(0);
204
+ const [hostVersion, setHostVersion] = useState("Loading...");
203
205
  const [users, setUsers] = useState(0);
204
206
  const [token, setToken] = useState(null);
205
207
  const [tokenLength, setTokenLength] = useState(0);
@@ -476,6 +478,20 @@ useEffect(() => {
476
478
  setPath(data.filePath);
477
479
  }
478
480
  };
481
+ const getDatMatching = async () => {
482
+ const resp = await fetch('/__authtics_host_apis__/get-dat-matching', {
483
+ method: 'POST',
484
+ headers: { 'Content-Type': 'application/json' },
485
+ body: JSON.stringify({ dat: localStorage.getItem('dat') })
486
+ });
487
+ if (resp.status === 200) {
488
+ const data = await resp.json();
489
+ setDatMatch(data.isMatching);
490
+ if (!data.isMatching) {
491
+ doc?.getElementById('authtics-dev-panel-root')?.remove();
492
+ }
493
+ }
494
+ };
479
495
  const isSSR = async () => {
480
496
  const resp = await fetch('/__authtics_host_apis__/get-is-ssr', {
481
497
  method: 'POST',
@@ -499,6 +515,17 @@ useEffect(() => {
499
515
  heapUsage.current = data.heapUsed;
500
516
  }
501
517
  };
518
+ const getHostVersion = async () => {
519
+ const resp = await fetch('/__authtics_host_apis__/get-host-ver', {
520
+ method: 'POST',
521
+ headers: { 'Content-Type': 'application/json' },
522
+ body: JSON.stringify({ dat: localStorage.getItem('dat') })
523
+ });
524
+ if (resp.status === 200) {
525
+ const data = await resp.json();
526
+ setHostVersion(data.version);
527
+ }
528
+ };
502
529
  const getCompilerType = async () => {
503
530
  const resp = await fetch('/__authtics_host_apis__/get-compiler', {
504
531
  method: 'POST',
@@ -559,6 +586,8 @@ useEffect(() => {
559
586
  getHttpVersion();
560
587
  isSSR();
561
588
  userSettings();
589
+ getHostVersion();
590
+ getDatMatching();
562
591
  setInterval(() => {
563
592
  getUsage();
564
593
  }, 250);
@@ -1104,7 +1133,7 @@ useEffect(() => {
1104
1133
  border: '1px solid #eee',
1105
1134
  fontSize: '12px',
1106
1135
  color: '#333',
1107
- }, children: [_jsx("span", { style: { fontSize: '12px', color: '#333' }, children: "Version" }), _jsx("span", { style: { fontSize: '12px', color: 'blue' }, children: "v0.0.1-beta.7" })] }), _jsxs("div", { style: {
1136
+ }, children: [_jsx("span", { style: { fontSize: '12px', color: '#333' }, children: "Version" }), _jsxs("span", { style: { fontSize: '12px', color: 'blue' }, children: ["v", hostVersion] })] }), _jsxs("div", { style: {
1108
1137
  display: 'flex',
1109
1138
  justifyContent: 'space-between',
1110
1139
  padding: '6px 10px',
@@ -1186,7 +1215,7 @@ useEffect(() => {
1186
1215
  gap: '6px',
1187
1216
  color: '#fff',
1188
1217
  flexDirection: 'row',
1189
- }, children: [_jsx(CircleX, { size: 12 }), "Invalid Developer Access Token (DAT)"] }) })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { restart(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: '#ba4e4e' }, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Restart App" }) }), _jsx(PanelButton, { onClick: () => { shutDown(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: '#ba4e4e' }, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Shut Down App" }) })] })] })) }) }), compilerType !== "?" ? (_jsxs("div", { onClick: () => setOpen(o => !o), style: {
1218
+ }, children: [_jsx(CircleX, { size: 12 }), "Invalid Developer Access Token (DAT)"] }) })) : (_jsx(_Fragment, {})), _jsx(PanelButton, { onClick: () => { restart(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: '#ba4e4e' }, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Restart App" }) }), _jsx(PanelButton, { onClick: () => { shutDown(); }, fullWidth: true, style: { color: '#fff', justifyContent: 'center', height: '32px', background: '#ba4e4e' }, children: _jsx("span", { style: { display: 'flex', alignItems: 'center', gap: '6px', textAlign: 'center' }, children: "Shut Down App" }) })] })] })) }) }), datMatch ? (_jsxs("div", { onClick: () => setOpen(o => !o), style: {
1190
1219
  display: 'flex',
1191
1220
  flexDirection: 'row',
1192
1221
  alignItems: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananacool467/authtics-host",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.8",
4
4
  "description": "A Next.js-inspired SSR framework for Node.js with TypeScript and JSX support.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",