webssh2_client 0.2.31-alpha.0 → 0.2.31-alpha.2
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/client/index.js +11 -3
- package/index.js +19 -10
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
// client
|
|
2
2
|
// client/index.js
|
|
3
|
-
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Read package.json synchronously for version
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
12
|
+
|
|
13
|
+
export default {
|
|
6
14
|
getPublicPath: () => path.join(__dirname, 'public'),
|
|
7
|
-
version:
|
|
15
|
+
version: packageJson.version
|
|
8
16
|
};
|
package/index.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
// client
|
|
2
2
|
// index.js
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Check if this file is being run directly
|
|
11
|
+
const isMainModule = import.meta.url === `file://${process.argv[1]}`;
|
|
12
|
+
|
|
13
|
+
if (isMainModule) {
|
|
5
14
|
// Run the development server
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const app = express();
|
|
15
|
+
const express = await import("express");
|
|
16
|
+
const app = express.default();
|
|
9
17
|
|
|
10
18
|
// Security headers middleware
|
|
11
|
-
const { securityHeadersMiddleware } =
|
|
19
|
+
const { securityHeadersMiddleware } = await import('./client/src/js/csp-config.js');
|
|
12
20
|
|
|
13
21
|
const port = 3000;
|
|
14
22
|
|
|
15
23
|
// Apply security headers to all responses
|
|
16
24
|
app.use(securityHeadersMiddleware);
|
|
17
25
|
|
|
18
|
-
app.use(express.static(path.join(__dirname, "client/public")));
|
|
26
|
+
app.use(express.default.static(path.join(__dirname, "client/public")));
|
|
19
27
|
|
|
20
28
|
app.get("/", (req, res) => {
|
|
21
29
|
res.sendFile(path.join(__dirname, "client/public", "client.htm"));
|
|
@@ -25,7 +33,8 @@ if (require.main === module) {
|
|
|
25
33
|
console.log(`Client server listening at http://localhost:${port}`);
|
|
26
34
|
console.log('Security headers including CSP are enabled');
|
|
27
35
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Always export the client module as default
|
|
39
|
+
const clientModule = await import('./client/index.js');
|
|
40
|
+
export default clientModule.default;
|