@tutti-os/auth-bridge 0.0.198 → 0.0.200
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/dist/node.js +18 -4
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { createServer as createNetServer } from "net";
|
|
25
25
|
import { hostname } from "os";
|
|
26
26
|
import { dirname } from "path";
|
|
27
|
+
var BRIDGE_SERVER_FORCE_CLOSE_TIMEOUT_MS = 1e3;
|
|
27
28
|
function createTuttiNodeAuthClient(options) {
|
|
28
29
|
const authJsonPath = options.authJsonPath.trim();
|
|
29
30
|
const appCallbackUrl = options.appCallbackUrl.trim();
|
|
@@ -505,7 +506,8 @@ function sendCors(res, status) {
|
|
|
505
506
|
"Access-Control-Allow-Origin": "*",
|
|
506
507
|
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
507
508
|
"Access-Control-Allow-Headers": "Content-Type",
|
|
508
|
-
"Access-Control-Allow-Private-Network": "true"
|
|
509
|
+
"Access-Control-Allow-Private-Network": "true",
|
|
510
|
+
Connection: "close"
|
|
509
511
|
});
|
|
510
512
|
res.end();
|
|
511
513
|
}
|
|
@@ -523,12 +525,13 @@ function sendJson(res, status, payload) {
|
|
|
523
525
|
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
524
526
|
"Access-Control-Allow-Headers": "Content-Type",
|
|
525
527
|
"Access-Control-Allow-Private-Network": "true",
|
|
526
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
528
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
529
|
+
Connection: "close"
|
|
527
530
|
});
|
|
528
531
|
res.end(JSON.stringify(payload));
|
|
529
532
|
}
|
|
530
533
|
function sendRedirect(res, location) {
|
|
531
|
-
res.writeHead(302, { Location: location });
|
|
534
|
+
res.writeHead(302, { Location: location, Connection: "close" });
|
|
532
535
|
res.end();
|
|
533
536
|
}
|
|
534
537
|
function buildBridgeResultUrl(input, status, safeErrorCode) {
|
|
@@ -570,7 +573,18 @@ function isAllowedAppCallbackProtocol(protocol) {
|
|
|
570
573
|
return protocol === "tutti:" || protocol === "tutti-dev:" || protocol === legacyProtocol || protocol === legacyDevProtocol;
|
|
571
574
|
}
|
|
572
575
|
function closeServer(server) {
|
|
573
|
-
return new Promise((resolve) =>
|
|
576
|
+
return new Promise((resolve) => {
|
|
577
|
+
const forceCloseTimer = setTimeout(() => {
|
|
578
|
+
server.closeAllConnections();
|
|
579
|
+
resolve();
|
|
580
|
+
}, BRIDGE_SERVER_FORCE_CLOSE_TIMEOUT_MS);
|
|
581
|
+
forceCloseTimer.unref();
|
|
582
|
+
server.close(() => {
|
|
583
|
+
clearTimeout(forceCloseTimer);
|
|
584
|
+
resolve();
|
|
585
|
+
});
|
|
586
|
+
server.closeIdleConnections();
|
|
587
|
+
});
|
|
574
588
|
}
|
|
575
589
|
function openUrlWithDefaultBrowser(url) {
|
|
576
590
|
const command = process.platform === "darwin" ? { file: "open", args: [url] } : process.platform === "win32" ? { file: "cmd", args: ["/c", "start", "", url] } : { file: "xdg-open", args: [url] };
|