gameglue 4.0.0 → 4.0.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.
Files changed (56) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +275 -275
  3. package/babel.config.cjs +5 -5
  4. package/coverage/auth.js.html +525 -525
  5. package/coverage/base.css +224 -224
  6. package/coverage/block-navigation.js +87 -87
  7. package/coverage/favicon.png +0 -0
  8. package/coverage/index.html +175 -175
  9. package/coverage/index.js.html +309 -309
  10. package/coverage/lcov-report/auth.js.html +525 -525
  11. package/coverage/lcov-report/base.css +224 -224
  12. package/coverage/lcov-report/block-navigation.js +87 -87
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/index.html +175 -175
  15. package/coverage/lcov-report/index.js.html +309 -309
  16. package/coverage/lcov-report/listener.js.html +528 -528
  17. package/coverage/lcov-report/prettify.css +1 -1
  18. package/coverage/lcov-report/prettify.js +2 -2
  19. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  20. package/coverage/lcov-report/sorter.js +210 -210
  21. package/coverage/lcov-report/user.js.html +117 -117
  22. package/coverage/lcov-report/utils.js.html +117 -117
  23. package/coverage/lcov.info +391 -391
  24. package/coverage/listener.js.html +528 -528
  25. package/coverage/prettify.css +1 -1
  26. package/coverage/prettify.js +2 -2
  27. package/coverage/sort-arrow-sprite.png +0 -0
  28. package/coverage/sorter.js +210 -210
  29. package/coverage/user.js.html +117 -117
  30. package/coverage/utils.js.html +117 -117
  31. package/dist/gg.cjs.js +1 -1
  32. package/dist/gg.cjs.js.map +1 -1
  33. package/dist/gg.esm.js +1 -1
  34. package/dist/gg.esm.js.map +1 -1
  35. package/dist/gg.umd.js +1 -1
  36. package/dist/gg.umd.js.map +1 -1
  37. package/examples/certs/cert.pem +19 -19
  38. package/examples/certs/key.pem +28 -28
  39. package/examples/flight-dashboard.html +431 -431
  40. package/examples/server.js +99 -99
  41. package/examples/telemetry-validator.html +1410 -1410
  42. package/jest.config.cjs +33 -33
  43. package/package.json +56 -56
  44. package/rollup.config.js +57 -57
  45. package/src/auth.js +255 -255
  46. package/src/auth.spec.js +481 -481
  47. package/src/index.js +168 -168
  48. package/src/listener.js +196 -193
  49. package/src/listener.spec.js +598 -598
  50. package/src/presence_listener.js +112 -112
  51. package/src/test/fixtures.js +106 -106
  52. package/src/test/setup.js +51 -51
  53. package/src/utils.js +63 -63
  54. package/src/utils.spec.js +78 -78
  55. package/types/index.d.ts +338 -338
  56. package/webpack.config.js +15 -15
@@ -1,99 +1,99 @@
1
- import https from 'https';
2
- import http from 'http';
3
- import fs from 'fs';
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
- const PORT = process.env.PORT || 3000;
11
- const USE_HTTPS = process.env.HTTPS === 'true' || fs.existsSync(path.join(__dirname, 'certs', 'key.pem'));
12
-
13
- const MIME_TYPES = {
14
- '.html': 'text/html',
15
- '.js': 'application/javascript',
16
- '.css': 'text/css',
17
- '.json': 'application/json',
18
- '.png': 'image/png',
19
- '.jpg': 'image/jpeg',
20
- '.svg': 'image/svg+xml',
21
- '.ico': 'image/x-icon',
22
- };
23
-
24
- function handleRequest(req, res) {
25
- let filePath = req.url === '/' ? '/flight-dashboard.html' : req.url;
26
-
27
- // Remove query string
28
- filePath = filePath.split('?')[0];
29
-
30
- // Security: prevent directory traversal (normalize but keep forward slashes for URL matching)
31
- filePath = path.normalize(filePath).replace(/^(\.\.[\/\\])+/, '').split(path.sep).join('/');
32
-
33
- // Check if requesting SDK from parent dist folder
34
- if (filePath.startsWith('/dist/')) {
35
- filePath = path.join(__dirname, '..', filePath);
36
- } else {
37
- filePath = path.join(__dirname, filePath);
38
- }
39
-
40
- const ext = path.extname(filePath).toLowerCase();
41
- const contentType = MIME_TYPES[ext] || 'application/octet-stream';
42
-
43
- fs.readFile(filePath, (err, content) => {
44
- if (err) {
45
- if (err.code === 'ENOENT') {
46
- res.writeHead(404, { 'Content-Type': 'text/plain' });
47
- res.end('404 Not Found');
48
- } else {
49
- res.writeHead(500, { 'Content-Type': 'text/plain' });
50
- res.end('500 Internal Server Error');
51
- }
52
- return;
53
- }
54
-
55
- res.writeHead(200, { 'Content-Type': contentType });
56
- res.end(content);
57
- });
58
- }
59
-
60
- function startServer() {
61
- let server;
62
- let protocol;
63
-
64
- if (USE_HTTPS) {
65
- const certPath = path.join(__dirname, 'certs');
66
-
67
- if (!fs.existsSync(path.join(certPath, 'key.pem'))) {
68
- console.log('\nNo SSL certificates found. Generate them with:');
69
- console.log(' mkdir -p examples/certs');
70
- console.log(' openssl req -x509 -newkey rsa:2048 -keyout examples/certs/key.pem -out examples/certs/cert.pem -days 365 -nodes -subj "/CN=localhost"\n');
71
- console.log('Falling back to HTTP...\n');
72
- server = http.createServer(handleRequest);
73
- protocol = 'http';
74
- } else {
75
- const options = {
76
- key: fs.readFileSync(path.join(certPath, 'key.pem')),
77
- cert: fs.readFileSync(path.join(certPath, 'cert.pem')),
78
- };
79
- server = https.createServer(options, handleRequest);
80
- protocol = 'https';
81
- }
82
- } else {
83
- server = http.createServer(handleRequest);
84
- protocol = 'http';
85
- }
86
-
87
- server.listen(PORT, () => {
88
- console.log(`\n GameGlue Example Server`);
89
- console.log(` -----------------------`);
90
- console.log(` ${protocol.toUpperCase()} server running at:`);
91
- console.log(` ${protocol}://localhost:${PORT}/\n`);
92
-
93
- if (protocol === 'http') {
94
- console.log(` Note: OAuth may require HTTPS. Set HTTPS=true or add certs.\n`);
95
- }
96
- });
97
- }
98
-
99
- startServer();
1
+ import https from 'https';
2
+ import http from 'http';
3
+ import fs from 'fs';
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
+ const PORT = process.env.PORT || 3000;
11
+ const USE_HTTPS = process.env.HTTPS === 'true' || fs.existsSync(path.join(__dirname, 'certs', 'key.pem'));
12
+
13
+ const MIME_TYPES = {
14
+ '.html': 'text/html',
15
+ '.js': 'application/javascript',
16
+ '.css': 'text/css',
17
+ '.json': 'application/json',
18
+ '.png': 'image/png',
19
+ '.jpg': 'image/jpeg',
20
+ '.svg': 'image/svg+xml',
21
+ '.ico': 'image/x-icon',
22
+ };
23
+
24
+ function handleRequest(req, res) {
25
+ let filePath = req.url === '/' ? '/flight-dashboard.html' : req.url;
26
+
27
+ // Remove query string
28
+ filePath = filePath.split('?')[0];
29
+
30
+ // Security: prevent directory traversal (normalize but keep forward slashes for URL matching)
31
+ filePath = path.normalize(filePath).replace(/^(\.\.[\/\\])+/, '').split(path.sep).join('/');
32
+
33
+ // Check if requesting SDK from parent dist folder
34
+ if (filePath.startsWith('/dist/')) {
35
+ filePath = path.join(__dirname, '..', filePath);
36
+ } else {
37
+ filePath = path.join(__dirname, filePath);
38
+ }
39
+
40
+ const ext = path.extname(filePath).toLowerCase();
41
+ const contentType = MIME_TYPES[ext] || 'application/octet-stream';
42
+
43
+ fs.readFile(filePath, (err, content) => {
44
+ if (err) {
45
+ if (err.code === 'ENOENT') {
46
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
47
+ res.end('404 Not Found');
48
+ } else {
49
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
50
+ res.end('500 Internal Server Error');
51
+ }
52
+ return;
53
+ }
54
+
55
+ res.writeHead(200, { 'Content-Type': contentType });
56
+ res.end(content);
57
+ });
58
+ }
59
+
60
+ function startServer() {
61
+ let server;
62
+ let protocol;
63
+
64
+ if (USE_HTTPS) {
65
+ const certPath = path.join(__dirname, 'certs');
66
+
67
+ if (!fs.existsSync(path.join(certPath, 'key.pem'))) {
68
+ console.log('\nNo SSL certificates found. Generate them with:');
69
+ console.log(' mkdir -p examples/certs');
70
+ console.log(' openssl req -x509 -newkey rsa:2048 -keyout examples/certs/key.pem -out examples/certs/cert.pem -days 365 -nodes -subj "/CN=localhost"\n');
71
+ console.log('Falling back to HTTP...\n');
72
+ server = http.createServer(handleRequest);
73
+ protocol = 'http';
74
+ } else {
75
+ const options = {
76
+ key: fs.readFileSync(path.join(certPath, 'key.pem')),
77
+ cert: fs.readFileSync(path.join(certPath, 'cert.pem')),
78
+ };
79
+ server = https.createServer(options, handleRequest);
80
+ protocol = 'https';
81
+ }
82
+ } else {
83
+ server = http.createServer(handleRequest);
84
+ protocol = 'http';
85
+ }
86
+
87
+ server.listen(PORT, () => {
88
+ console.log(`\n GameGlue Example Server`);
89
+ console.log(` -----------------------`);
90
+ console.log(` ${protocol.toUpperCase()} server running at:`);
91
+ console.log(` ${protocol}://localhost:${PORT}/\n`);
92
+
93
+ if (protocol === 'http') {
94
+ console.log(` Note: OAuth may require HTTPS. Set HTTPS=true or add certs.\n`);
95
+ }
96
+ });
97
+ }
98
+
99
+ startServer();