@ubercode/channelvault 0.3.0-rc.1 → 0.3.0-rc.3
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/CHANGELOG.md +30 -0
- package/README.md +7 -6
- package/dist/cli.js +389 -161
- package/dist/cli.js.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1144,6 +1144,15 @@ function connectionError(url, err) {
|
|
|
1144
1144
|
error.code = code;
|
|
1145
1145
|
return error;
|
|
1146
1146
|
}
|
|
1147
|
+
function redirectTarget(url, response) {
|
|
1148
|
+
const location = response.headers.get("location");
|
|
1149
|
+
if (!location) return "";
|
|
1150
|
+
try {
|
|
1151
|
+
return `, to ${new URL(location, url).origin}`;
|
|
1152
|
+
} catch {
|
|
1153
|
+
return "";
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1147
1156
|
var SERVER_CONFIG_KEY = "serverConfiguration";
|
|
1148
1157
|
function unwrapSingleKey(value) {
|
|
1149
1158
|
const keys = Object.keys(value);
|
|
@@ -1388,17 +1397,28 @@ var MirthClientImpl = class {
|
|
|
1388
1397
|
}
|
|
1389
1398
|
return response;
|
|
1390
1399
|
}
|
|
1391
|
-
/**
|
|
1400
|
+
/**
|
|
1401
|
+
* fetch through this client's pool, with network failures explained. Never
|
|
1402
|
+
* follows a redirect: fetch re-sends a 307/308 body, so a redirected login
|
|
1403
|
+
* would post the username and password to wherever the server points.
|
|
1404
|
+
*/
|
|
1392
1405
|
async send(url, init) {
|
|
1406
|
+
let response;
|
|
1393
1407
|
try {
|
|
1394
|
-
|
|
1408
|
+
response = await fetch(url, {
|
|
1395
1409
|
...init,
|
|
1410
|
+
redirect: "manual",
|
|
1396
1411
|
// @ts-expect-error - dispatcher is a Node.js/undici specific option
|
|
1397
1412
|
dispatcher: this.dispatcher
|
|
1398
1413
|
});
|
|
1399
1414
|
} catch (err) {
|
|
1400
1415
|
throw connectionError(url, err);
|
|
1401
1416
|
}
|
|
1417
|
+
if (response.status >= 300 && response.status < 400) {
|
|
1418
|
+
await response.body?.cancel();
|
|
1419
|
+
throw new Error(`the server answered ${new URL(url).pathname} with a redirect (HTTP ${response.status}${redirectTarget(url, response)}); channelvault does not follow redirects, so credentials and session cookies are never sent elsewhere. Connect to the address it redirects to: check https vs --no-https, --host and --port (or MIRTH_HOST/MIRTH_PORT)`);
|
|
1420
|
+
}
|
|
1421
|
+
return response;
|
|
1402
1422
|
}
|
|
1403
1423
|
/** Build an absolute URL with an optional query string. */
|
|
1404
1424
|
buildUrl(path2, query) {
|