@wocker/ws 1.0.21 → 1.0.23
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/README.md +8 -0
- package/lib/AppModule.js +46 -75
- package/lib/controllers/DebugController.d.ts +4 -2
- package/lib/controllers/DebugController.js +19 -11
- package/lib/controllers/ExperimentalController.d.ts +8 -0
- package/lib/controllers/ExperimentalController.js +77 -0
- package/lib/controllers/PluginController.d.ts +4 -5
- package/lib/controllers/PluginController.js +14 -59
- package/lib/controllers/PresetController.d.ts +9 -3
- package/lib/controllers/PresetController.js +61 -52
- package/lib/controllers/ProjectController.d.ts +7 -2
- package/lib/controllers/ProjectController.js +124 -94
- package/lib/controllers/index.d.ts +1 -3
- package/lib/controllers/index.js +1 -3
- package/lib/env.d.ts +2 -2
- package/lib/env.js +3 -3
- package/lib/main.js +16 -7
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- package/lib/makes/Logger.d.ts +1 -1
- package/lib/makes/Plugin.d.ts +5 -0
- package/lib/makes/Plugin.js +15 -0
- package/lib/makes/index.d.ts +1 -1
- package/lib/makes/index.js +1 -1
- package/lib/modules/app/index.d.ts +2 -0
- package/lib/{plugins/proxmox → modules/app}/index.js +6 -13
- package/lib/modules/docker/index.d.ts +8 -0
- package/lib/modules/docker/index.js +41 -0
- package/lib/modules/docker/services/ContainerService.d.ts +14 -0
- package/lib/modules/docker/services/ContainerService.js +115 -0
- package/lib/{services → modules/docker/services}/DockerService.d.ts +12 -5
- package/lib/{services → modules/docker/services}/DockerService.js +33 -117
- package/lib/modules/docker/services/ImageService.d.ts +18 -0
- package/lib/modules/docker/services/ImageService.js +68 -0
- package/lib/modules/docker/services/ModemService.d.ts +14 -0
- package/lib/modules/docker/services/ModemService.js +137 -0
- package/lib/modules/docker/services/ProtoService.d.ts +6 -0
- package/lib/modules/docker/services/ProtoService.js +20 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/{plugins → modules}/index.js +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.d.ts +11 -0
- package/lib/modules/keystore/controllers/KeystoreController.js +106 -0
- package/lib/modules/keystore/index.d.ts +4 -0
- package/lib/{plugins/elastic-search → modules/keystore}/index.js +16 -9
- package/lib/modules/keystore/providers/FileKeystoreProvider.d.ts +16 -0
- package/lib/modules/keystore/providers/FileKeystoreProvider.js +97 -0
- package/lib/modules/keystore/providers/KeytarKeystoreProvider.d.ts +9 -0
- package/lib/modules/keystore/providers/KeytarKeystoreProvider.js +74 -0
- package/lib/modules/keystore/services/KeystoreService.d.ts +12 -0
- package/lib/modules/keystore/services/KeystoreService.js +70 -0
- package/lib/modules/keystore/types/FileKeystore.d.ts +17 -0
- package/lib/modules/keystore/types/FileKeystore.js +33 -0
- package/lib/modules/keystore/types/Keytar.d.ts +8 -0
- package/lib/modules/keystore/types/Keytar.js +2 -0
- package/lib/modules/keystore/utils/createEncryptionKey.d.ts +1 -0
- package/lib/modules/keystore/utils/createEncryptionKey.js +46 -0
- package/lib/modules/keystore/utils/createPasswordHash.d.ts +1 -0
- package/lib/modules/keystore/utils/createPasswordHash.js +20 -0
- package/lib/modules/keystore/utils/decrypt.d.ts +1 -0
- package/lib/modules/keystore/utils/decrypt.js +15 -0
- package/lib/modules/keystore/utils/encrypt.d.ts +1 -0
- package/lib/modules/keystore/utils/encrypt.js +19 -0
- package/lib/modules/keystore/utils/index.d.ts +5 -0
- package/lib/{services → modules/keystore/utils}/index.js +5 -10
- package/lib/modules/keystore/utils/verifyPasswordHash.d.ts +1 -0
- package/lib/modules/keystore/utils/verifyPasswordHash.js +9 -0
- package/lib/{controllers → modules/proxy/controllers}/CertController.d.ts +2 -1
- package/lib/{controllers → modules/proxy/controllers}/CertController.js +4 -3
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.d.ts +4 -1
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.js +46 -37
- package/lib/modules/proxy/index.d.ts +5 -0
- package/lib/modules/proxy/index.js +39 -0
- package/lib/{services → modules/proxy/services}/CertService.d.ts +3 -3
- package/lib/{services → modules/proxy/services}/CertService.js +11 -11
- package/lib/{services → modules/proxy/services}/ProxyService.d.ts +2 -2
- package/lib/{services → modules/proxy/services}/ProxyService.js +21 -13
- package/lib/repositories/PresetRepository.d.ts +23 -0
- package/lib/repositories/PresetRepository.js +115 -0
- package/lib/repositories/index.d.ts +1 -0
- package/lib/repositories/index.js +17 -0
- package/lib/services/AppConfigService.d.ts +6 -2
- package/lib/services/AppConfigService.js +60 -53
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- package/lib/services/LogService.d.ts +3 -1
- package/lib/services/LogService.js +12 -10
- package/lib/services/PluginService.d.ts +8 -2
- package/lib/services/PluginService.js +69 -16
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +145 -260
- package/lib/services/ProjectService.d.ts +8 -5
- package/lib/services/ProjectService.js +44 -18
- package/lib/utils/followProgress2.d.ts +1 -0
- package/lib/utils/followProgress2.js +63 -0
- package/lib/utils/index.d.ts +1 -4
- package/lib/utils/index.js +1 -4
- package/package.json +24 -15
- package/proto/buildkit.proto +55 -0
- package/proto/solver/pb/ops.proto +443 -0
- package/lib/controllers/ImageController.d.ts +0 -7
- package/lib/controllers/ImageController.js +0 -46
- package/lib/makes/FS.d.ts +0 -27
- package/lib/makes/FS.js +0 -284
- package/lib/makes/LineConvertStream.d.ts +0 -11
- package/lib/makes/LineConvertStream.js +0 -42
- package/lib/makes/Model.d.ts +0 -5
- package/lib/makes/Model.js +0 -12
- package/lib/plugins/MongodbPlugin.d.ts +0 -20
- package/lib/plugins/MongodbPlugin.js +0 -288
- package/lib/plugins/elastic-search/controllers/ElasticSearchController.d.ts +0 -10
- package/lib/plugins/elastic-search/controllers/ElasticSearchController.js +0 -91
- package/lib/plugins/elastic-search/index.d.ts +0 -2
- package/lib/plugins/index.d.ts +0 -3
- package/lib/plugins/proxmox/controllers/ProxmoxController.d.ts +0 -14
- package/lib/plugins/proxmox/controllers/ProxmoxController.js +0 -127
- package/lib/plugins/proxmox/index.d.ts +0 -2
- package/lib/services/index.d.ts +0 -10
- package/lib/utils/followProgress.d.ts +0 -1
- package/lib/utils/followProgress.js +0 -73
- package/lib/utils/volumeFormat.d.ts +0 -6
- package/lib/utils/volumeFormat.js +0 -8
- package/lib/utils/volumeParse.d.ts +0 -2
- package/lib/utils/volumeParse.js +0 -13
- package/presets/bun/Dockerfile +0 -11
- package/presets/bun/config.json +0 -4
- /package/lib/{utils/format-size-units.d.ts → modules/docker/utils/formatSizeUnits.d.ts} +0 -0
- /package/lib/{utils/format-size-units.js → modules/docker/utils/formatSizeUnits.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileKeystore = void 0;
|
|
4
|
+
class FileKeystore {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
const { passwordHash, secrets = {} } = data;
|
|
7
|
+
this.passwordHash = passwordHash;
|
|
8
|
+
this.secrets = secrets;
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
if (!(key in this.secrets)) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return this.secrets[key];
|
|
15
|
+
}
|
|
16
|
+
set(key, value) {
|
|
17
|
+
this.secrets[key] = value;
|
|
18
|
+
}
|
|
19
|
+
delete(key) {
|
|
20
|
+
if (!(key in this.secrets)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
delete this.secrets[key];
|
|
24
|
+
}
|
|
25
|
+
toObject() {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
const secrets = JSON.stringify(this.secrets, null, 4);
|
|
30
|
+
return `// Wocker keystore\nexports.passwordHash = "${this.passwordHash}";\nexports.secrets = ${secrets};\n`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.FileKeystore = FileKeystore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { getPassword, setPassword, deletePassword, findPassword, findCredentials } from "keytar";
|
|
2
|
+
export type Keytar = {
|
|
3
|
+
getPassword: typeof getPassword;
|
|
4
|
+
setPassword: typeof setPassword;
|
|
5
|
+
deletePassword: typeof deletePassword;
|
|
6
|
+
findPassword: typeof findPassword;
|
|
7
|
+
findCredentials: typeof findCredentials;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createEncryptionKey: (password: string, passwordHash: string) => Buffer<ArrayBufferLike>;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createEncryptionKey = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const verifyPasswordHash_1 = require("./verifyPasswordHash");
|
|
39
|
+
const createEncryptionKey = (password, passwordHash) => {
|
|
40
|
+
if (!(0, verifyPasswordHash_1.verifyPasswordHash)(password, passwordHash)) {
|
|
41
|
+
throw new Error("Invalid password provided");
|
|
42
|
+
}
|
|
43
|
+
const [, saltValue] = passwordHash.split(":"), salt = Buffer.from(saltValue, "hex");
|
|
44
|
+
return crypto.scryptSync(password, salt, 32);
|
|
45
|
+
};
|
|
46
|
+
exports.createEncryptionKey = createEncryptionKey;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createPasswordHash: (password: string, salt?: string) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPasswordHash = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const createPasswordHash = (password, salt) => {
|
|
9
|
+
const saltBuffer = salt
|
|
10
|
+
? Buffer.from(salt, "hex")
|
|
11
|
+
: crypto_1.default.randomBytes(16);
|
|
12
|
+
if (!salt) {
|
|
13
|
+
salt = saltBuffer.toString("hex");
|
|
14
|
+
}
|
|
15
|
+
const hash = crypto_1.default.createHmac("sha256", saltBuffer)
|
|
16
|
+
.update(password)
|
|
17
|
+
.digest("hex");
|
|
18
|
+
return `${hash}:${salt}`;
|
|
19
|
+
};
|
|
20
|
+
exports.createPasswordHash = createPasswordHash;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const decrypt: (encryptedKey: Buffer, encryptedValue: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.decrypt = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const decrypt = (encryptedKey, encryptedValue) => {
|
|
9
|
+
const buffer = Buffer.from(encryptedValue, "base64"), iv = buffer.subarray(0, 12), authTag = buffer.subarray(12, 28), encrypted = buffer.subarray(28).toString("base64"), decipher = crypto_1.default.createDecipheriv("aes-256-gcm", encryptedKey, iv);
|
|
10
|
+
decipher.setAuthTag(authTag);
|
|
11
|
+
let decrypted = decipher.update(encrypted, "base64", "utf8");
|
|
12
|
+
decrypted += decipher.final("utf8");
|
|
13
|
+
return decrypted;
|
|
14
|
+
};
|
|
15
|
+
exports.decrypt = decrypt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const encrypt: (encryptedKey: Buffer, value: string) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.encrypt = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const encrypt = (encryptedKey, value) => {
|
|
9
|
+
const iv = crypto_1.default.randomBytes(12), cipher = crypto_1.default.createCipheriv("aes-256-gcm", encryptedKey, iv);
|
|
10
|
+
let encrypted = cipher.update(value, "utf8", "base64");
|
|
11
|
+
encrypted += cipher.final("base64");
|
|
12
|
+
const authTag = cipher.getAuthTag();
|
|
13
|
+
return Buffer.concat([
|
|
14
|
+
iv,
|
|
15
|
+
authTag,
|
|
16
|
+
Buffer.from(encrypted, "base64")
|
|
17
|
+
]).toString("base64");
|
|
18
|
+
};
|
|
19
|
+
exports.encrypt = encrypt;
|
|
@@ -14,13 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./NpmService"), exports);
|
|
23
|
-
__exportStar(require("./PluginService"), exports);
|
|
24
|
-
__exportStar(require("./PresetService"), exports);
|
|
25
|
-
__exportStar(require("./ProjectService"), exports);
|
|
26
|
-
__exportStar(require("./ProxyService"), exports);
|
|
17
|
+
__exportStar(require("./createEncryptionKey"), exports);
|
|
18
|
+
__exportStar(require("./createPasswordHash"), exports);
|
|
19
|
+
__exportStar(require("./decrypt"), exports);
|
|
20
|
+
__exportStar(require("./encrypt"), exports);
|
|
21
|
+
__exportStar(require("./verifyPasswordHash"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const verifyPasswordHash: (password: string, passwordHash: string) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyPasswordHash = void 0;
|
|
4
|
+
const createPasswordHash_1 = require("./createPasswordHash");
|
|
5
|
+
const verifyPasswordHash = (password, passwordHash) => {
|
|
6
|
+
const [, salt = ""] = (passwordHash || "").split(":");
|
|
7
|
+
return passwordHash === (0, createPasswordHash_1.createPasswordHash)(password, salt);
|
|
8
|
+
};
|
|
9
|
+
exports.verifyPasswordHash = verifyPasswordHash;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CertService } from "../services/CertService";
|
|
2
|
+
import { ProjectService } from "../../../services/ProjectService";
|
|
2
3
|
export declare class CertController {
|
|
3
4
|
protected readonly projectService: ProjectService;
|
|
4
5
|
protected readonly certService: CertService;
|
|
@@ -14,7 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CertController = void 0;
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
|
-
const
|
|
17
|
+
const CertService_1 = require("../services/CertService");
|
|
18
|
+
const ProjectService_1 = require("../../../services/ProjectService");
|
|
18
19
|
let CertController = class CertController {
|
|
19
20
|
constructor(projectService, certService) {
|
|
20
21
|
this.projectService = projectService;
|
|
@@ -108,6 +109,6 @@ __decorate([
|
|
|
108
109
|
], CertController.prototype, "existsOtherNames", null);
|
|
109
110
|
exports.CertController = CertController = __decorate([
|
|
110
111
|
(0, core_1.Controller)(),
|
|
111
|
-
__metadata("design:paramtypes", [
|
|
112
|
-
|
|
112
|
+
__metadata("design:paramtypes", [ProjectService_1.ProjectService,
|
|
113
|
+
CertService_1.CertService])
|
|
113
114
|
], CertController);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Project } from "@wocker/core";
|
|
2
|
-
import { AppConfigService
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
|
+
import { AppEventsService } from "../../../services/AppEventsService";
|
|
4
|
+
import { ProjectService } from "../../../services/ProjectService";
|
|
5
|
+
import { ProxyService } from "../services/ProxyService";
|
|
3
6
|
export declare class ProxyController {
|
|
4
7
|
protected readonly appConfigService: AppConfigService;
|
|
5
8
|
protected readonly appEventsService: AppEventsService;
|
|
@@ -18,8 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.ProxyController = void 0;
|
|
19
19
|
const core_1 = require("@wocker/core");
|
|
20
20
|
const utils_1 = require("@wocker/utils");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
22
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
23
|
+
const AppEventsService_1 = require("../../../services/AppEventsService");
|
|
24
|
+
const ProjectService_1 = require("../../../services/ProjectService");
|
|
25
|
+
const ProxyService_1 = require("../services/ProxyService");
|
|
23
26
|
let ProxyController = class ProxyController {
|
|
24
27
|
constructor(appConfigService, appEventsService, projectService, proxyService) {
|
|
25
28
|
this.appConfigService = appConfigService;
|
|
@@ -35,9 +38,9 @@ let ProxyController = class ProxyController {
|
|
|
35
38
|
if (project.domains.length === 0) {
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
console.info(
|
|
41
|
+
console.info(yoctocolors_cjs_1.default.green("Don't forget to add these lines into hosts file:"));
|
|
39
42
|
for (const domain of project.domains) {
|
|
40
|
-
console.info(
|
|
43
|
+
console.info(yoctocolors_cjs_1.default.gray(`127.0.0.1 ${domain}`));
|
|
41
44
|
}
|
|
42
45
|
await this.start();
|
|
43
46
|
}
|
|
@@ -48,47 +51,47 @@ let ProxyController = class ProxyController {
|
|
|
48
51
|
return projects.map((project) => project.name);
|
|
49
52
|
}
|
|
50
53
|
async init(httpPort, httpsPort, sshPort, sshPassword) {
|
|
51
|
-
const config = this.appConfigService.
|
|
54
|
+
const config = this.appConfigService.config;
|
|
52
55
|
if (httpPort === null || typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
53
|
-
httpPort = await (0, utils_1.
|
|
56
|
+
httpPort = await (0, utils_1.promptInput)({
|
|
54
57
|
required: true,
|
|
55
|
-
message: "Http port
|
|
58
|
+
message: "Http port",
|
|
56
59
|
type: "number",
|
|
57
|
-
default: config.getMeta("PROXY_HTTP_PORT", "80")
|
|
60
|
+
default: parseInt(config.getMeta("PROXY_HTTP_PORT", "80"))
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
61
64
|
if (httpsPort === null || typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
62
|
-
httpsPort = await (0, utils_1.
|
|
65
|
+
httpsPort = await (0, utils_1.promptInput)({
|
|
63
66
|
required: true,
|
|
64
|
-
message: "Https port
|
|
67
|
+
message: "Https port",
|
|
65
68
|
type: "number",
|
|
66
|
-
default: config.getMeta("PROXY_HTTPS_PORT", "443")
|
|
69
|
+
default: parseInt(config.getMeta("PROXY_HTTPS_PORT", "443"))
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
config.setMeta("PROXY_HTTPS_PORT", httpsPort.toString());
|
|
70
|
-
let enableSsh =
|
|
71
|
-
|
|
72
|
-
enableSsh = await (0, utils_1.promptConfirm)({
|
|
73
|
+
let enableSsh = !sshPassword && !sshPort
|
|
74
|
+
? await (0, utils_1.promptConfirm)({
|
|
73
75
|
message: "Enable ssh proxy?",
|
|
74
76
|
default: false
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
if (enableSsh && !sshPassword) {
|
|
78
|
-
sshPassword = await (0, utils_1.promptText)({
|
|
79
|
-
message: "SSH Password:",
|
|
80
|
-
type: "string",
|
|
81
|
-
default: config.getMeta("PROXY_SSH_PASSWORD")
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (enableSsh && !sshPort) {
|
|
85
|
-
sshPort = await (0, utils_1.promptText)({
|
|
86
|
-
message: "SSH port:",
|
|
87
|
-
type: "number",
|
|
88
|
-
default: config.getMeta("PROXY_SSH_PORT", "22")
|
|
89
|
-
});
|
|
90
|
-
}
|
|
77
|
+
})
|
|
78
|
+
: true;
|
|
91
79
|
if (enableSsh) {
|
|
80
|
+
if (!sshPassword) {
|
|
81
|
+
sshPassword = await (0, utils_1.promptInput)({
|
|
82
|
+
message: "SSH Password",
|
|
83
|
+
type: "password",
|
|
84
|
+
required: true,
|
|
85
|
+
default: config.getMeta("PROXY_SSH_PASSWORD")
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (!sshPort) {
|
|
89
|
+
sshPort = await (0, utils_1.promptInput)({
|
|
90
|
+
message: "SSH port",
|
|
91
|
+
type: "number",
|
|
92
|
+
default: parseInt(config.getMeta("PROXY_SSH_PORT", "22"))
|
|
93
|
+
});
|
|
94
|
+
}
|
|
92
95
|
config.setMeta("PROXY_SSH_PASSWORD", sshPassword);
|
|
93
96
|
config.setMeta("PROXY_SSH_PORT", sshPort.toString());
|
|
94
97
|
}
|
|
@@ -96,7 +99,7 @@ let ProxyController = class ProxyController {
|
|
|
96
99
|
config.unsetMeta("PROXY_SSH_PASSWORD");
|
|
97
100
|
config.unsetMeta("PROXY_SSH_PORT");
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
this.appConfigService.save();
|
|
100
103
|
}
|
|
101
104
|
async start(restart, rebuild) {
|
|
102
105
|
await this.proxyService.start(restart, rebuild);
|
|
@@ -118,6 +121,7 @@ __decorate([
|
|
|
118
121
|
], ProxyController.prototype, "getProjectNames", null);
|
|
119
122
|
__decorate([
|
|
120
123
|
(0, core_1.Command)("proxy:init"),
|
|
124
|
+
(0, core_1.Description)("Initializes proxy configurations"),
|
|
121
125
|
__param(0, (0, core_1.Option)("http-port", {
|
|
122
126
|
type: "number",
|
|
123
127
|
description: "Http port"
|
|
@@ -131,6 +135,7 @@ __decorate([
|
|
|
131
135
|
description: "SSH port"
|
|
132
136
|
})),
|
|
133
137
|
__param(3, (0, core_1.Option)("ssh-password", {
|
|
138
|
+
type: "string",
|
|
134
139
|
description: "SSH password"
|
|
135
140
|
})),
|
|
136
141
|
__metadata("design:type", Function),
|
|
@@ -139,15 +144,16 @@ __decorate([
|
|
|
139
144
|
], ProxyController.prototype, "init", null);
|
|
140
145
|
__decorate([
|
|
141
146
|
(0, core_1.Command)("proxy:start"),
|
|
147
|
+
(0, core_1.Description)("This command starts the proxy for the project. Options are available to restart or rebuild the proxy if needed."),
|
|
142
148
|
__param(0, (0, core_1.Option)("restart", {
|
|
143
149
|
type: "boolean",
|
|
144
150
|
alias: "r",
|
|
145
|
-
description: "
|
|
151
|
+
description: "Restarts the proxy before starting it"
|
|
146
152
|
})),
|
|
147
153
|
__param(1, (0, core_1.Option)("rebuild", {
|
|
148
154
|
type: "boolean",
|
|
149
155
|
alias: "b",
|
|
150
|
-
description: "
|
|
156
|
+
description: "Rebuilds the proxy before starting it"
|
|
151
157
|
})),
|
|
152
158
|
__metadata("design:type", Function),
|
|
153
159
|
__metadata("design:paramtypes", [Boolean, Boolean]),
|
|
@@ -155,20 +161,23 @@ __decorate([
|
|
|
155
161
|
], ProxyController.prototype, "start", null);
|
|
156
162
|
__decorate([
|
|
157
163
|
(0, core_1.Command)("proxy:stop"),
|
|
164
|
+
(0, core_1.Description)("This command stops the currently running proxy for the project. It ensures that all proxy-related services are properly halted."),
|
|
158
165
|
__metadata("design:type", Function),
|
|
159
166
|
__metadata("design:paramtypes", []),
|
|
160
167
|
__metadata("design:returntype", Promise)
|
|
161
168
|
], ProxyController.prototype, "stop", null);
|
|
162
169
|
__decorate([
|
|
163
170
|
(0, core_1.Command)("proxy:logs"),
|
|
171
|
+
(0, core_1.Description)("Displays the proxy logs"),
|
|
164
172
|
__metadata("design:type", Function),
|
|
165
173
|
__metadata("design:paramtypes", []),
|
|
166
174
|
__metadata("design:returntype", Promise)
|
|
167
175
|
], ProxyController.prototype, "logs", null);
|
|
168
176
|
exports.ProxyController = ProxyController = __decorate([
|
|
169
177
|
(0, core_1.Controller)(),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
(0, core_1.Description)("Proxy commands"),
|
|
179
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
180
|
+
AppEventsService_1.AppEventsService,
|
|
181
|
+
ProjectService_1.ProjectService,
|
|
182
|
+
ProxyService_1.ProxyService])
|
|
174
183
|
], ProxyController);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CertService = exports.ProxyService = exports.ProxyModule = void 0;
|
|
10
|
+
const core_1 = require("@wocker/core");
|
|
11
|
+
const docker_1 = require("../docker");
|
|
12
|
+
const CertController_1 = require("./controllers/CertController");
|
|
13
|
+
const ProxyController_1 = require("./controllers/ProxyController");
|
|
14
|
+
const CertService_1 = require("./services/CertService");
|
|
15
|
+
Object.defineProperty(exports, "CertService", { enumerable: true, get: function () { return CertService_1.CertService; } });
|
|
16
|
+
const ProxyService_1 = require("./services/ProxyService");
|
|
17
|
+
Object.defineProperty(exports, "ProxyService", { enumerable: true, get: function () { return ProxyService_1.ProxyService; } });
|
|
18
|
+
let ProxyModule = class ProxyModule {
|
|
19
|
+
};
|
|
20
|
+
exports.ProxyModule = ProxyModule;
|
|
21
|
+
exports.ProxyModule = ProxyModule = __decorate([
|
|
22
|
+
(0, core_1.Module)({
|
|
23
|
+
imports: [
|
|
24
|
+
docker_1.DockerModule
|
|
25
|
+
],
|
|
26
|
+
controllers: [
|
|
27
|
+
CertController_1.CertController,
|
|
28
|
+
ProxyController_1.ProxyController
|
|
29
|
+
],
|
|
30
|
+
providers: [
|
|
31
|
+
ProxyService_1.ProxyService,
|
|
32
|
+
CertService_1.CertService
|
|
33
|
+
],
|
|
34
|
+
exports: [
|
|
35
|
+
ProxyService_1.ProxyService,
|
|
36
|
+
CertService_1.CertService
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
], ProxyModule);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Project } from "@wocker/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DockerService } from "../../docker";
|
|
3
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
4
4
|
import { ProxyService } from "./ProxyService";
|
|
5
5
|
type CertMap = {
|
|
6
6
|
[name: string]: string[];
|
|
@@ -12,7 +12,7 @@ export declare class CertService {
|
|
|
12
12
|
constructor(appConfigService: AppConfigService, proxyService: ProxyService, dockerService: DockerService);
|
|
13
13
|
list(): Promise<string>;
|
|
14
14
|
generate(certName: string, dns: string[]): Promise<void>;
|
|
15
|
-
getCertsMap():
|
|
15
|
+
getCertsMap(): CertMap;
|
|
16
16
|
use(project: Project, name: string): Promise<void>;
|
|
17
17
|
remove(project: Project): Promise<void>;
|
|
18
18
|
delete(name: string): Promise<void>;
|
|
@@ -49,8 +49,8 @@ exports.CertService = void 0;
|
|
|
49
49
|
const core_1 = require("@wocker/core");
|
|
50
50
|
const Path = __importStar(require("path"));
|
|
51
51
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const docker_1 = require("../../docker");
|
|
53
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
54
54
|
const ProxyService_1 = require("./ProxyService");
|
|
55
55
|
let CertService = class CertService {
|
|
56
56
|
constructor(appConfigService, proxyService, dockerService) {
|
|
@@ -62,7 +62,7 @@ let CertService = class CertService {
|
|
|
62
62
|
const table = new cli_table3_1.default({
|
|
63
63
|
head: ["Name"]
|
|
64
64
|
});
|
|
65
|
-
const certMap =
|
|
65
|
+
const certMap = this.getCertsMap();
|
|
66
66
|
for (const name in certMap) {
|
|
67
67
|
table.push([name]);
|
|
68
68
|
}
|
|
@@ -93,8 +93,8 @@ let CertService = class CertService {
|
|
|
93
93
|
cmd: ["wocker-create-cert", certName]
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
const files =
|
|
96
|
+
getCertsMap() {
|
|
97
|
+
const files = this.appConfigService.fs.readdir("certs/projects");
|
|
98
98
|
return files.reduce((res, file) => {
|
|
99
99
|
const ext = Path.extname(file);
|
|
100
100
|
const name = Path.basename(file, ext);
|
|
@@ -106,7 +106,7 @@ let CertService = class CertService {
|
|
|
106
106
|
}, {});
|
|
107
107
|
}
|
|
108
108
|
async use(project, name) {
|
|
109
|
-
const certs =
|
|
109
|
+
const certs = this.getCertsMap();
|
|
110
110
|
if (!name) {
|
|
111
111
|
name = project.domains.find((domain) => domain in certs);
|
|
112
112
|
}
|
|
@@ -121,23 +121,23 @@ let CertService = class CertService {
|
|
|
121
121
|
throw new Error(`${name}.key file missing`);
|
|
122
122
|
}
|
|
123
123
|
project.setEnv("CERT_NAME", name);
|
|
124
|
-
|
|
124
|
+
project.save();
|
|
125
125
|
}
|
|
126
126
|
async remove(project) {
|
|
127
127
|
if (!project.hasEnv("CERT_NAME")) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
project.unsetEnv("CERT_NAME");
|
|
131
|
-
|
|
131
|
+
project.save();
|
|
132
132
|
}
|
|
133
133
|
async delete(name) {
|
|
134
|
-
const certs =
|
|
134
|
+
const certs = this.getCertsMap();
|
|
135
135
|
if (!(name in certs)) {
|
|
136
136
|
console.warn(`Cert ${name} not found`);
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
for (const ext of certs[name]) {
|
|
140
|
-
|
|
140
|
+
this.appConfigService.fs.rm(`certs/projects/${name}${ext}`);
|
|
141
141
|
}
|
|
142
142
|
console.info(`Cert ${name} deleted`);
|
|
143
143
|
}
|
|
@@ -147,5 +147,5 @@ exports.CertService = CertService = __decorate([
|
|
|
147
147
|
(0, core_1.Injectable)(),
|
|
148
148
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
149
149
|
ProxyService_1.ProxyService,
|
|
150
|
-
|
|
150
|
+
docker_1.DockerService])
|
|
151
151
|
], CertService);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Project, ProxyService as CoreProxyService } from "@wocker/core";
|
|
2
|
-
import { AppConfigService } from "
|
|
3
|
-
import { DockerService } from "
|
|
2
|
+
import { AppConfigService } from "../../../services/AppConfigService";
|
|
3
|
+
import { DockerService } from "../../docker";
|
|
4
4
|
export declare class ProxyService extends CoreProxyService {
|
|
5
5
|
protected readonly appConfigService: AppConfigService;
|
|
6
6
|
protected readonly dockerService: DockerService;
|
|
@@ -46,9 +46,9 @@ exports.ProxyService = void 0;
|
|
|
46
46
|
const core_1 = require("@wocker/core");
|
|
47
47
|
const utils_1 = require("@wocker/utils");
|
|
48
48
|
const Path = __importStar(require("path"));
|
|
49
|
-
const env_1 = require("
|
|
50
|
-
const AppConfigService_1 = require("
|
|
51
|
-
const
|
|
49
|
+
const env_1 = require("../../../env");
|
|
50
|
+
const AppConfigService_1 = require("../../../services/AppConfigService");
|
|
51
|
+
const docker_1 = require("../../docker");
|
|
52
52
|
let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
53
53
|
constructor(appConfigService, dockerService) {
|
|
54
54
|
super();
|
|
@@ -61,13 +61,13 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
61
61
|
];
|
|
62
62
|
}
|
|
63
63
|
async init(project) {
|
|
64
|
-
const appPort = await (0, utils_1.
|
|
65
|
-
message: "App port
|
|
64
|
+
const appPort = await (0, utils_1.promptInput)({
|
|
65
|
+
message: "App port",
|
|
66
66
|
type: "number",
|
|
67
|
-
default: project.getEnv("VIRTUAL_PORT", "80")
|
|
67
|
+
default: parseInt(project.getEnv("VIRTUAL_PORT", "80"))
|
|
68
68
|
});
|
|
69
|
-
project.setEnv("VIRTUAL_PORT", appPort);
|
|
70
|
-
|
|
69
|
+
project.setEnv("VIRTUAL_PORT", appPort.toString());
|
|
70
|
+
project.save();
|
|
71
71
|
}
|
|
72
72
|
async start(restart, rebuild) {
|
|
73
73
|
if (restart || rebuild) {
|
|
@@ -77,6 +77,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
77
77
|
if (!container) {
|
|
78
78
|
console.info("Proxy starting...");
|
|
79
79
|
await this.build(rebuild);
|
|
80
|
+
const fs = this.appConfigService.fs;
|
|
80
81
|
if (!this.appConfigService.fs.exists("certs/ca")) {
|
|
81
82
|
this.appConfigService.fs.mkdir("certs/ca", {
|
|
82
83
|
recursive: true,
|
|
@@ -89,7 +90,13 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
89
90
|
mode: 0o700
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
if (!fs.exists("nginx/vhost.d")) {
|
|
94
|
+
fs.mkdir("nginx/vhost.d", {
|
|
95
|
+
recursive: true,
|
|
96
|
+
mode: 0o700
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const config = this.appConfigService.config;
|
|
93
100
|
const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
|
|
94
101
|
const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
|
|
95
102
|
const sshPort = config.getMeta("PROXY_SSH_PORT", "22");
|
|
@@ -110,8 +117,9 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
110
117
|
],
|
|
111
118
|
volumes: [
|
|
112
119
|
"/var/run/docker.sock:/tmp/docker.sock:ro",
|
|
113
|
-
`${
|
|
114
|
-
`${
|
|
120
|
+
`${fs.path("certs/projects")}:/etc/nginx/certs`,
|
|
121
|
+
`${fs.path("certs/ca")}:/etc/nginx/ca-certs`,
|
|
122
|
+
`${fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`
|
|
115
123
|
],
|
|
116
124
|
network: "workspace"
|
|
117
125
|
});
|
|
@@ -137,7 +145,7 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
|
|
|
137
145
|
for (const oldImage of this.oldImages) {
|
|
138
146
|
await this.dockerService.imageRm(oldImage);
|
|
139
147
|
}
|
|
140
|
-
const config = this.appConfigService.
|
|
148
|
+
const config = this.appConfigService.config;
|
|
141
149
|
await this.dockerService.buildImage({
|
|
142
150
|
tag: this.imageName,
|
|
143
151
|
context: Path.join(env_1.PLUGINS_DIR, "proxy"),
|
|
@@ -155,5 +163,5 @@ exports.ProxyService = ProxyService;
|
|
|
155
163
|
exports.ProxyService = ProxyService = __decorate([
|
|
156
164
|
(0, core_1.Injectable)("PROXY_SERVICE"),
|
|
157
165
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
158
|
-
|
|
166
|
+
docker_1.DockerService])
|
|
159
167
|
], ProxyService);
|