bdy 1.22.54-stage → 1.22.55-dev
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/distTs/package.json +1 -1
- package/distTs/src/tunnel/http.js +11 -1
- package/distTs/src/tunnel/tunnel.js +42 -1
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NO_CACHE_HEADER = void 0;
|
|
6
7
|
const events_1 = __importDefault(require("events"));
|
|
7
8
|
const uuid_1 = require("uuid");
|
|
8
9
|
const http_1 = __importDefault(require("http"));
|
|
@@ -18,6 +19,7 @@ const html_1 = __importDefault(require("./html"));
|
|
|
18
19
|
const agent_1 = __importDefault(require("./agent"));
|
|
19
20
|
const punycode_1 = __importDefault(require("punycode/"));
|
|
20
21
|
const tunnel_1 = require("../types/tunnel");
|
|
22
|
+
exports.NO_CACHE_HEADER = 'private, no-cache, no-store, max-age=0, must-revalidate';
|
|
21
23
|
class TunnelHttp extends events_1.default {
|
|
22
24
|
id;
|
|
23
25
|
req;
|
|
@@ -31,6 +33,7 @@ class TunnelHttp extends events_1.default {
|
|
|
31
33
|
httpIdentify;
|
|
32
34
|
verify;
|
|
33
35
|
compression;
|
|
36
|
+
noCache;
|
|
34
37
|
headers;
|
|
35
38
|
responseHeaders;
|
|
36
39
|
httpLog;
|
|
@@ -38,7 +41,7 @@ class TunnelHttp extends events_1.default {
|
|
|
38
41
|
auth;
|
|
39
42
|
proxyRes;
|
|
40
43
|
proxyReq;
|
|
41
|
-
constructor({ req, res, proto, host, port, hostHeader, serve, timeout, httpIdentify, verify, httpLog, compression, headers, responseHeaders, auth = null, }) {
|
|
44
|
+
constructor({ req, res, proto, host, port, hostHeader, serve, timeout, httpIdentify, verify, noCache, httpLog, compression, headers, responseHeaders, auth = null, }) {
|
|
42
45
|
super();
|
|
43
46
|
this.id = (0, uuid_1.v4)();
|
|
44
47
|
this.host = host;
|
|
@@ -53,6 +56,7 @@ class TunnelHttp extends events_1.default {
|
|
|
53
56
|
this.verify = verify;
|
|
54
57
|
this.compression = compression;
|
|
55
58
|
this.headers = {};
|
|
59
|
+
this.noCache = noCache;
|
|
56
60
|
this.responseHeaders = {};
|
|
57
61
|
this.serve = serve;
|
|
58
62
|
if (responseHeaders) {
|
|
@@ -78,6 +82,9 @@ class TunnelHttp extends events_1.default {
|
|
|
78
82
|
}
|
|
79
83
|
if (this.httpLog)
|
|
80
84
|
this.httpLog.newResponse(code, {}, this.logRequest);
|
|
85
|
+
if (this.noCache) {
|
|
86
|
+
this.res.setHeader('cache-control', exports.NO_CACHE_HEADER);
|
|
87
|
+
}
|
|
81
88
|
this.res.statusCode = code;
|
|
82
89
|
this.res.end(html);
|
|
83
90
|
}
|
|
@@ -106,6 +113,9 @@ class TunnelHttp extends events_1.default {
|
|
|
106
113
|
Object.keys(this.responseHeaders).forEach((name) => {
|
|
107
114
|
this.res.setHeader(name.toLowerCase(), this.responseHeaders[name]);
|
|
108
115
|
});
|
|
116
|
+
if (this.noCache) {
|
|
117
|
+
this.res.setHeader('cache-control', exports.NO_CACHE_HEADER);
|
|
118
|
+
}
|
|
109
119
|
setImmediate(() => {
|
|
110
120
|
try {
|
|
111
121
|
if (this.res && !this.res.headersSent)
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -9,7 +42,7 @@ const events_1 = __importDefault(require("events"));
|
|
|
9
42
|
const tcp_1 = __importDefault(require("./tcp"));
|
|
10
43
|
const logger_1 = __importDefault(require("../logger"));
|
|
11
44
|
const identification_1 = __importDefault(require("./identification"));
|
|
12
|
-
const http_1 =
|
|
45
|
+
const http_1 = __importStar(require("./http"));
|
|
13
46
|
const http2_1 = __importDefault(require("./server/http2"));
|
|
14
47
|
const http1_1 = __importDefault(require("./server/http1"));
|
|
15
48
|
const log_1 = __importDefault(require("./http/log"));
|
|
@@ -863,6 +896,10 @@ class Tunnel extends events_1.default {
|
|
|
863
896
|
verifier,
|
|
864
897
|
};
|
|
865
898
|
}
|
|
899
|
+
_requiresAuthCacheControl() {
|
|
900
|
+
return (this.authType === tunnel_1.TUNNEL_HTTP_AUTH_TYPE.BASIC ||
|
|
901
|
+
this.authType === tunnel_1.TUNNEL_HTTP_AUTH_TYPE.BUDDY);
|
|
902
|
+
}
|
|
866
903
|
_redirectHttpToBuddyAuth(pathname, search, req, res) {
|
|
867
904
|
let host = this.agent.host;
|
|
868
905
|
if (/^https:\/\/\d+\.\d+\.\d+\.\d+$/.test(host)) {
|
|
@@ -937,6 +974,9 @@ class Tunnel extends events_1.default {
|
|
|
937
974
|
return true;
|
|
938
975
|
}
|
|
939
976
|
httpEndFast(req, res, statusCode, msg, headers = {}) {
|
|
977
|
+
if (this._requiresAuthCacheControl() && !headers['cache-control']) {
|
|
978
|
+
headers['cache-control'] = http_1.NO_CACHE_HEADER;
|
|
979
|
+
}
|
|
940
980
|
let log;
|
|
941
981
|
if (this.httpLog) {
|
|
942
982
|
log = this.httpLog.newRequest(req.method, req.headers, req.url, req.httpVersion, req);
|
|
@@ -1051,6 +1091,7 @@ class Tunnel extends events_1.default {
|
|
|
1051
1091
|
headers: this.headers,
|
|
1052
1092
|
serve: this.serve,
|
|
1053
1093
|
responseHeaders: this.responseHeaders,
|
|
1094
|
+
noCache: this._requiresAuthCacheControl(),
|
|
1054
1095
|
httpIdentify: this.identify?.type,
|
|
1055
1096
|
httpLog: this.httpLog,
|
|
1056
1097
|
});
|