@ubercode/channelvault 0.3.0-rc.3 → 0.3.0-rc.5
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 +50 -0
- package/README.md +66 -13
- package/dist/cli.js +1669 -793
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/docs/roadmap.md +2 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ interface ClientConfig {
|
|
|
69
69
|
https?: boolean;
|
|
70
70
|
/** default false; set true for self-signed certs */
|
|
71
71
|
disableTlsCheck?: boolean;
|
|
72
|
+
/** SHA-256 of the only certificate accepted, 64 lowercase hex digits; replaces CA verification. */
|
|
73
|
+
tlsFingerprint?: string;
|
|
72
74
|
/**
|
|
73
75
|
* default false. Put the server's response body in error messages. A body
|
|
74
76
|
* can echo the credentials that were sent; it is decoded and has credential
|
|
@@ -159,6 +161,7 @@ interface MirthClientExt extends MirthClient {
|
|
|
159
161
|
putCodeTemplateLibraries(libraries: Record<string, unknown>[]): Promise<void>;
|
|
160
162
|
/** PUT /server/globalScripts, from the `globalScripts` value of a server configuration. */
|
|
161
163
|
putGlobalScripts(globalScripts: unknown): Promise<void>;
|
|
164
|
+
putConfigurationMap(map: unknown): Promise<void>;
|
|
162
165
|
/** POST /channels/{id}/_deploy; throws if deployment fails. */
|
|
163
166
|
deployChannel(id: string): Promise<void>;
|
|
164
167
|
/** Ids of the channels currently deployed (GET /channels/statuses). */
|
package/dist/index.js
CHANGED
|
@@ -924,7 +924,9 @@ function createExplodeEngine() {
|
|
|
924
924
|
|
|
925
925
|
// src/client/index.ts
|
|
926
926
|
import { CookieJar } from "tough-cookie";
|
|
927
|
-
import {
|
|
927
|
+
import { isIP } from "net";
|
|
928
|
+
import { connect as tlsConnect } from "tls";
|
|
929
|
+
import { Agent, buildConnector } from "undici";
|
|
928
930
|
|
|
929
931
|
// src/secrets/detect.ts
|
|
930
932
|
import { createHash } from "crypto";
|
|
@@ -1144,6 +1146,26 @@ function connectionError(url, err) {
|
|
|
1144
1146
|
error.code = code;
|
|
1145
1147
|
return error;
|
|
1146
1148
|
}
|
|
1149
|
+
function fingerprintOf(socket) {
|
|
1150
|
+
return (socket.getPeerCertificate().fingerprint256 ?? "").replace(/:/g, "").toLowerCase();
|
|
1151
|
+
}
|
|
1152
|
+
function pinnedConnector(pin) {
|
|
1153
|
+
const base = buildConnector({ rejectUnauthorized: false, maxCachedSessions: 0 });
|
|
1154
|
+
return (options, callback) => {
|
|
1155
|
+
base(options, (err, socket) => {
|
|
1156
|
+
if (err) return callback(err, null);
|
|
1157
|
+
const presented = fingerprintOf(socket);
|
|
1158
|
+
if (presented === pin) return callback(null, socket);
|
|
1159
|
+
socket.destroy();
|
|
1160
|
+
const mismatch = new Error(
|
|
1161
|
+
`the server presented certificate SHA-256 ${presented || "(none)"}, but the pinned fingerprint is ${pin}; nothing was sent`
|
|
1162
|
+
);
|
|
1163
|
+
mismatch.code = "TLS_PIN_MISMATCH";
|
|
1164
|
+
mismatch.presented = presented;
|
|
1165
|
+
callback(mismatch, null);
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1147
1169
|
function redirectTarget(url, response) {
|
|
1148
1170
|
const location = response.headers.get("location");
|
|
1149
1171
|
if (!location) return "";
|
|
@@ -1175,7 +1197,7 @@ var MirthClientImpl = class {
|
|
|
1175
1197
|
const protocol = config.https !== false ? "https" : "http";
|
|
1176
1198
|
this.baseUrl = `${protocol}://${config.host}:${config.port}/api`;
|
|
1177
1199
|
this.cookieJar = new CookieJar();
|
|
1178
|
-
this.dispatcher = new Agent(config.disableTlsCheck ? { connect: { rejectUnauthorized: false } } : {});
|
|
1200
|
+
this.dispatcher = new Agent(config.tlsFingerprint ? { connect: pinnedConnector(config.tlsFingerprint) } : config.disableTlsCheck ? { connect: { rejectUnauthorized: false } } : {});
|
|
1179
1201
|
}
|
|
1180
1202
|
isAuthenticated() {
|
|
1181
1203
|
return this.authenticated;
|
|
@@ -1341,6 +1363,10 @@ var MirthClientImpl = class {
|
|
|
1341
1363
|
async putCodeTemplateLibraries(libraries) {
|
|
1342
1364
|
await this.sendJson("PUT", "/codeTemplateLibraries", { list: { codeTemplateLibrary: libraries } }, { override: true });
|
|
1343
1365
|
}
|
|
1366
|
+
/** PUT /server/configurationMap: replaces the whole map. */
|
|
1367
|
+
async putConfigurationMap(map) {
|
|
1368
|
+
await this.sendJson("PUT", "/server/configurationMap", { map });
|
|
1369
|
+
}
|
|
1344
1370
|
async putGlobalScripts(globalScripts) {
|
|
1345
1371
|
await this.sendJson("PUT", "/server/globalScripts", { map: globalScripts });
|
|
1346
1372
|
}
|