@tramvai/cli 7.11.0 → 7.11.1
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/lib/api/shared/providers/selfSignedCertificateProvider.js +2 -2
- package/lib/api/shared/providers/selfSignedCertificateProvider.js.map +1 -1
- package/lib/api/shared/types/base.d.ts +0 -4
- package/lib/api/shared/types/base.d.ts.map +1 -1
- package/lib/api/start/providers/application/server.d.ts.map +1 -1
- package/lib/api/start/providers/application/server.js +3 -2
- package/lib/api/start/providers/application/server.js.map +1 -1
- package/lib/api/start/providers/application/shared.d.ts.map +1 -1
- package/lib/api/start/providers/application/shared.js +2 -1
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/utils/createServer.d.ts +1 -1
- package/lib/api/start/utils/createServer.d.ts.map +1 -1
- package/lib/api/start/utils/createServer.js.map +1 -1
- package/lib/api/start-prod/providers/application.d.ts.map +1 -1
- package/lib/api/start-prod/providers/application.js +3 -2
- package/lib/api/start-prod/providers/application.js.map +1 -1
- package/lib/di/tokens/server.d.ts +0 -6
- package/lib/di/tokens/server.d.ts.map +1 -1
- package/lib/di/tokens/server.js +1 -2
- package/lib/di/tokens/server.js.map +1 -1
- package/package.json +8 -8
- package/src/api/shared/providers/selfSignedCertificateProvider.ts +4 -4
- package/src/api/shared/types/base.ts +0 -5
- package/src/api/start/providers/application/server.ts +3 -7
- package/src/api/start/providers/application/shared.ts +2 -1
- package/src/api/start/utils/createServer.ts +2 -1
- package/src/api/start-prod/providers/application.ts +2 -1
- package/src/di/tokens/server.ts +0 -5
- package/lib/api/shared/utils/selfSignedCertificate/certificatedHostsList.d.ts +0 -4
- package/lib/api/shared/utils/selfSignedCertificate/certificatedHostsList.d.ts.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/certificatedHostsList.js +0 -22
- package/lib/api/shared/utils/selfSignedCertificate/certificatedHostsList.js.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/common.d.ts +0 -3
- package/lib/api/shared/utils/selfSignedCertificate/common.d.ts.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/common.js +0 -8
- package/lib/api/shared/utils/selfSignedCertificate/common.js.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.d.ts +0 -9
- package/lib/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.d.ts.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.js +0 -64
- package/lib/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.js.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/getHosts.d.ts +0 -3
- package/lib/api/shared/utils/selfSignedCertificate/getHosts.d.ts.map +0 -1
- package/lib/api/shared/utils/selfSignedCertificate/getHosts.js +0 -32
- package/lib/api/shared/utils/selfSignedCertificate/getHosts.js.map +0 -1
- package/src/api/shared/utils/selfSignedCertificate/certificatedHostsList.ts +0 -22
- package/src/api/shared/utils/selfSignedCertificate/common.ts +0 -4
- package/src/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.spec.ts +0 -154
- package/src/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.ts +0 -99
- package/src/api/shared/utils/selfSignedCertificate/getHosts.ts +0 -31
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selfSignedCertificateProvider = void 0;
|
|
4
4
|
const dippy_1 = require("@tinkoff/dippy");
|
|
5
|
+
const createSelfSignedCertificate_1 = require("@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate");
|
|
5
6
|
const tokens_1 = require("../../../di/tokens");
|
|
6
|
-
const createSelfSignedCertificate_1 = require("../utils/selfSignedCertificate/createSelfSignedCertificate");
|
|
7
7
|
exports.selfSignedCertificateProvider = [
|
|
8
8
|
(0, dippy_1.provide)({
|
|
9
|
-
provide:
|
|
9
|
+
provide: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
10
10
|
useFactory: ({ configManager, parameters }) => {
|
|
11
11
|
const { host } = configManager;
|
|
12
12
|
if (configManager.httpProtocol === 'https') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selfSignedCertificateProvider.js","sourceRoot":"","sources":["../../../../src/api/shared/providers/selfSignedCertificateProvider.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,+
|
|
1
|
+
{"version":3,"file":"selfSignedCertificateProvider.js","sourceRoot":"","sources":["../../../../src/api/shared/providers/selfSignedCertificateProvider.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,0HAGkF;AAElF,+CAAoF;AAEvE,QAAA,6BAA6B,GAAe;IACvD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2DAA6B;QACtC,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,EAAE,EAAE;YAC5C,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;YAC/B,IAAI,aAAa,CAAC,YAAY,KAAK,OAAO,EAAE;gBAC1C,OAAO,IAAA,yDAA2B,EAAC;oBACjC,IAAI;oBACJ,eAAe,EAAE,UAAU,EAAE,SAAS;oBACtC,OAAO,EAAE,UAAU,EAAE,QAAQ;iBAC9B,CAAC,CAAC;aACJ;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;YACnC,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/api/shared/types/base.ts"],"names":[],"mappings":";AAAA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/api/shared/types/base.ts"],"names":[],"mappings":";AAAA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C,eAAO,MAAM,eAAe,EAAE,SAAS,QAAQ,EA2CrC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serverProviders = void 0;
|
|
4
4
|
const dippy_1 = require("@tinkoff/dippy");
|
|
5
|
+
const createSelfSignedCertificate_1 = require("@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate");
|
|
5
6
|
const tokens_1 = require("../../tokens");
|
|
6
7
|
const tokens_2 = require("../../../../di/tokens");
|
|
7
8
|
const stopServer_1 = require("../../utils/stopServer");
|
|
@@ -15,7 +16,7 @@ exports.serverProviders = [
|
|
|
15
16
|
},
|
|
16
17
|
deps: {
|
|
17
18
|
selfSignedCertificate: {
|
|
18
|
-
token:
|
|
19
|
+
token: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
19
20
|
optional: true,
|
|
20
21
|
},
|
|
21
22
|
},
|
|
@@ -34,7 +35,7 @@ exports.serverProviders = [
|
|
|
34
35
|
deps: {
|
|
35
36
|
server: tokens_2.SERVER_TOKEN,
|
|
36
37
|
configManager: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
37
|
-
selfSignedCertificate:
|
|
38
|
+
selfSignedCertificate: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
38
39
|
},
|
|
39
40
|
}),
|
|
40
41
|
(0, dippy_1.provide)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":";;;AACA,0CAAyC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,0HAAyH;AAEzH,yCAAuE;AACvE,kDAA2E;AAC3E,uDAAoD;AACpD,2DAAwD;AACxD,2DAAwD;AAE3C,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,qBAAY;QACrB,UAAU,EAAE,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE;YACxC,OAAO,IAAA,2BAAY,EAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,KAAK,EAAE,2DAA6B;gBACpC,QAAQ,EAAE,IAAI;aACf;SACF;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,qBAAqB,EAAE,EAAE,EAAE;YAC/D,OAAO,KAAK,UAAU,kBAAkB;gBACtC,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;gBAChC,MAAM,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;gBAClF,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;gBAEpD,MAAM,IAAA,2BAAY,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,qBAAY;YACpB,aAAa,EAAE,6BAAoB;YACnC,qBAAqB,EAAE,2DAA6B;SACrD;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;YAC5B,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,qBAAY;SACrB;KACF,CAAC;CACM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoB/C,eAAO,MAAM,eAAe,EAAE,SAAS,QAAQ,EA6DrC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sharedProviders = void 0;
|
|
4
4
|
const dippy_1 = require("@tinkoff/dippy");
|
|
5
|
+
const createSelfSignedCertificate_1 = require("@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate");
|
|
5
6
|
const tokens_1 = require("../../tokens");
|
|
6
7
|
const tokens_2 = require("../../../../di/tokens");
|
|
7
8
|
const stopServer_1 = require("../../utils/stopServer");
|
|
@@ -36,7 +37,7 @@ exports.sharedProviders = [
|
|
|
36
37
|
},
|
|
37
38
|
deps: {
|
|
38
39
|
selfSignedCertificate: {
|
|
39
|
-
token:
|
|
40
|
+
token: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
40
41
|
optional: true,
|
|
41
42
|
},
|
|
42
43
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,yCAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,0HAAyH;AAEzH,yCAAuE;AACvE,kDAM+B;AAC/B,uDAAoD;AAEpD,oEAAuE;AACvE,2DAAwD;AACxD,2DAAwD;AACxD,2GAAwG;AACxG,+DAAoE;AAEvD,QAAA,eAAe,GAAwB;IAClD,GAAG,6DAA6B;IAChC,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAChE,IAAA,mCAAmB,EAAC,WAAqC,EAAE;YACzD,OAAO;YACP,GAAG,UAAU;YACb,MAAM,EAAE,UAAU,CAAC,GAAG;YACtB,GAAG,EAAE,aAAa;YAClB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,UAAU,EAAE,WAAW,CAAC,UAAU;SACnC,CAAC;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAkB;YAC/B,UAAU,EAAE,iCAAwB;YACpC,WAAW,EAAE,2BAAkB;YAC/B,OAAO,EAAE,uBAAc;SACxB;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE;YACxC,OAAO,IAAA,2BAAY,EAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,KAAK,EAAE,2DAA6B;gBACpC,QAAQ,EAAE,IAAI;aACf;SACF;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE;YAC9C,OAAO,KAAK,UAAU,kBAAkB;gBACtC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;gBAEjD,MAAM,IAAA,2BAAY,EAAC,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;YAC3F,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE;YAC5C,OAAO,KAAK,IAAI,EAAE;gBAChB,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;gBAC5B,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,WAAW,EAAE,2BAAkB;SAChC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import stoppable from 'stoppable';
|
|
4
|
-
import
|
|
4
|
+
import { Certificate } from '@tramvai/api/lib/utils/selfSignedCertificate/common';
|
|
5
5
|
export declare const createServer: (certificate?: Certificate) => (import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> & stoppable.WithStop) | (import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> & stoppable.WithStop);
|
|
6
6
|
//# sourceMappingURL=createServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../../../src/api/start/utils/createServer.ts"],"names":[],"mappings":";;AAGA,OAAO,SAAS,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../../../src/api/start/utils/createServer.ts"],"names":[],"mappings":";;AAGA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,qDAAqD,CAAC;AAiBlF,eAAO,MAAM,YAAY,iBAAkB,WAAW,2PAIrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../../../src/api/start/utils/createServer.ts"],"names":[],"mappings":";;;;AAAA,+BAAwD;AACxD,iCAA0D;AAC1D,2BAAkC;AAClC,kEAAkC;
|
|
1
|
+
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../../../src/api/start/utils/createServer.ts"],"names":[],"mappings":";;;;AAAA,+BAAwD;AACxD,iCAA0D;AAC1D,2BAAkC;AAClC,kEAAkC;AAIlC,MAAM,iBAAiB,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAe,EAAE,EAAE;IACtE,MAAM,OAAO,GAAG;QACd,GAAG,EAAE,IAAA,iBAAY,EAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,IAAA,iBAAY,EAAC,eAAe,CAAC;KACpC,CAAC;IACF,MAAM,WAAW,GAAG,IAAA,oBAAiB,EAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,MAAM,GAAG,IAAA,mBAAgB,GAAE,CAAC;IAElC,OAAO,IAAA,mBAAS,EAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,WAAyB,EAAE,EAAE;IACxD,OAAO,WAAW,IAAI,WAAW,EAAE,eAAe,IAAI,WAAW,EAAE,OAAO;QACxE,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC;QAChC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACzB,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAsB/C,eAAO,MAAM,qBAAqB,EAAE,SAAS,QAAQ,EA2F3C,CAAC"}
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const dippy_1 = require("@tinkoff/dippy");
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
|
+
const createSelfSignedCertificate_1 = require("@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate");
|
|
8
9
|
const tokens_1 = require("../../../di/tokens");
|
|
9
10
|
const tokens_2 = require("../tokens");
|
|
10
11
|
const utils_1 = require("../../../config/utils");
|
|
@@ -22,7 +23,7 @@ exports.applicationsProviders = [
|
|
|
22
23
|
},
|
|
23
24
|
deps: {
|
|
24
25
|
selfSignedCertificate: {
|
|
25
|
-
token:
|
|
26
|
+
token: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
26
27
|
optional: true,
|
|
27
28
|
},
|
|
28
29
|
},
|
|
@@ -80,7 +81,7 @@ exports.applicationsProviders = [
|
|
|
80
81
|
deps: {
|
|
81
82
|
configManager: tokens_1.CONFIG_MANAGER_TOKEN,
|
|
82
83
|
parameters: tokens_1.COMMAND_PARAMETERS_TOKEN,
|
|
83
|
-
selfSignedCertificate:
|
|
84
|
+
selfSignedCertificate: createSelfSignedCertificate_1.SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
84
85
|
},
|
|
85
86
|
}),
|
|
86
87
|
(0, dippy_1.provide)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,0CAAyC;AACzC,iDAAqC;AACrC,+
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,0CAAyC;AACzC,iDAAqC;AACrC,0HAAyH;AAEzH,+CAM4B;AAE5B,sCAAsE;AACtE,iDAAoD;AACpD,4DAAyD;AAEzD,iEAAoE;AACpE,wGAAqG;AACrG,iEAA8D;AAC9D,4DAAiE;AAEpD,QAAA,qBAAqB,GAAwB;IACxD,GAAG,6DAA6B;IAChC,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE;YACxC,OAAO,IAAA,2BAAY,EAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,KAAK,EAAE,2DAA6B;gBACpC,QAAQ,EAAE,IAAI;aACf;SACF;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OA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I
|
|
|
5
5
|
export declare const STATIC_SERVER_TOKEN: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> & import("stoppable").WithStop & {
|
|
6
6
|
__type?: "base token";
|
|
7
7
|
};
|
|
8
|
-
export declare const SELF_SIGNED_CERTIFICATE_TOKEN: {
|
|
9
|
-
keyPath: string;
|
|
10
|
-
certificatePath: string;
|
|
11
|
-
} & {
|
|
12
|
-
__type?: "base token";
|
|
13
|
-
};
|
|
14
8
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/di/tokens/server.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;CAAgD,CAAC;AAE1E,eAAO,MAAM,mBAAmB;;CAAsD,CAAC
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/di/tokens/server.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;CAAgD,CAAC;AAE1E,eAAO,MAAM,mBAAmB;;CAAsD,CAAC"}
|
package/lib/di/tokens/server.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.STATIC_SERVER_TOKEN = exports.SERVER_TOKEN = void 0;
|
|
4
4
|
const dippy_1 = require("@tinkoff/dippy");
|
|
5
5
|
exports.SERVER_TOKEN = (0, dippy_1.createToken)('server server');
|
|
6
6
|
exports.STATIC_SERVER_TOKEN = (0, dippy_1.createToken)('server staticServer');
|
|
7
|
-
exports.SELF_SIGNED_CERTIFICATE_TOKEN = (0, dippy_1.createToken)('self signed certificates token');
|
|
8
7
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/di/tokens/server.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAGhC,QAAA,YAAY,GAAG,IAAA,mBAAW,EAAkB,eAAe,CAAC,CAAC;AAE7D,QAAA,mBAAmB,GAAG,IAAA,mBAAW,EAAkB,qBAAqB,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/di/tokens/server.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAGhC,QAAA,YAAY,GAAG,IAAA,mBAAW,EAAkB,eAAe,CAAC,CAAC;AAE7D,QAAA,mBAAmB,GAAG,IAAA,mBAAW,EAAkB,qBAAqB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.1",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.18.1"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@loadable/webpack-plugin": "^5.15.0",
|
|
62
62
|
"@module-federation/node": "^0.15.1",
|
|
63
63
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
64
|
-
"@rsdoctor/webpack-plugin": "^1.
|
|
64
|
+
"@rsdoctor/webpack-plugin": "^1.5.4",
|
|
65
65
|
"@statoscope/webpack-plugin": "^5.29.0",
|
|
66
66
|
"@svgr/webpack": "^8.1.0",
|
|
67
67
|
"@tinkoff/browserslist-config": "0.7.1",
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"@tinkoff/request-plugin-retry": "^0.3.0",
|
|
76
76
|
"@tinkoff/utils": "^2.1.3",
|
|
77
77
|
"@tinkoff/webpack-dedupe-plugin": "6.0.1",
|
|
78
|
-
"@tramvai/api": "7.11.
|
|
78
|
+
"@tramvai/api": "7.11.1",
|
|
79
79
|
"@tramvai/build": "8.0.1",
|
|
80
|
-
"@tramvai/plugin-babel-transpiler": "7.11.
|
|
81
|
-
"@tramvai/plugin-swc-transpiler": "7.11.
|
|
82
|
-
"@tramvai/plugin-webpack-builder": "7.11.
|
|
83
|
-
"@tramvai/plugin-webpack-pwa": "7.11.
|
|
84
|
-
"@tramvai/react": "7.11.
|
|
80
|
+
"@tramvai/plugin-babel-transpiler": "7.11.1",
|
|
81
|
+
"@tramvai/plugin-swc-transpiler": "7.11.1",
|
|
82
|
+
"@tramvai/plugin-webpack-builder": "7.11.1",
|
|
83
|
+
"@tramvai/plugin-webpack-pwa": "7.11.1",
|
|
84
|
+
"@tramvai/react": "7.11.1",
|
|
85
85
|
"@tramvai/tools-check-versions": "0.9.2",
|
|
86
86
|
"@tramvai/tools-migrate": "0.11.3",
|
|
87
87
|
"ajv": "^8.12.0",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
3
|
import {
|
|
4
|
-
COMMAND_PARAMETERS_TOKEN,
|
|
5
|
-
CONFIG_MANAGER_TOKEN,
|
|
6
4
|
SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
createSelfSignedCertificate,
|
|
6
|
+
} from '@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate';
|
|
7
|
+
|
|
8
|
+
import { COMMAND_PARAMETERS_TOKEN, CONFIG_MANAGER_TOKEN } from '../../../di/tokens';
|
|
9
9
|
|
|
10
10
|
export const selfSignedCertificateProvider: Provider[] = [
|
|
11
11
|
provide({
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { SELF_SIGNED_CERTIFICATE_TOKEN } from '@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate';
|
|
4
|
+
|
|
5
5
|
import { INIT_HANDLER_TOKEN, CLOSE_HANDLER_TOKEN } from '../../tokens';
|
|
6
|
-
import {
|
|
7
|
-
CONFIG_MANAGER_TOKEN,
|
|
8
|
-
SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
9
|
-
SERVER_TOKEN,
|
|
10
|
-
} from '../../../../di/tokens';
|
|
6
|
+
import { CONFIG_MANAGER_TOKEN, SERVER_TOKEN } from '../../../../di/tokens';
|
|
11
7
|
import { stopServer } from '../../utils/stopServer';
|
|
12
8
|
import { createServer } from '../../utils/createServer';
|
|
13
9
|
import { listenServer } from '../../utils/listenServer';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
|
+
import { SELF_SIGNED_CERTIFICATE_TOKEN } from '@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate';
|
|
4
|
+
|
|
3
5
|
import { CLOSE_HANDLER_TOKEN, INIT_HANDLER_TOKEN } from '../../tokens';
|
|
4
6
|
import {
|
|
5
7
|
CONFIG_MANAGER_TOKEN,
|
|
@@ -7,7 +9,6 @@ import {
|
|
|
7
9
|
COMMAND_PARAMETERS_TOKEN,
|
|
8
10
|
STATIC_SERVER_TOKEN,
|
|
9
11
|
PORT_MANAGER_TOKEN,
|
|
10
|
-
SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
11
12
|
} from '../../../../di/tokens';
|
|
12
13
|
import { stopServer } from '../../utils/stopServer';
|
|
13
14
|
import type { ApplicationConfigEntry } from '../../../../typings/configEntry/application';
|
|
@@ -2,7 +2,8 @@ import { createServer as httpCreateServer } from 'http';
|
|
|
2
2
|
import { createServer as httpsCreateServer } from 'https';
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import stoppable from 'stoppable';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import { Certificate } from '@tramvai/api/lib/utils/selfSignedCertificate/common';
|
|
6
7
|
|
|
7
8
|
const createHttpsServer = ({ keyPath, certificatePath }: Certificate) => {
|
|
8
9
|
const options = {
|
|
@@ -2,12 +2,13 @@ import path from 'path';
|
|
|
2
2
|
import type { Provider } from '@tinkoff/dippy';
|
|
3
3
|
import { provide } from '@tinkoff/dippy';
|
|
4
4
|
import { fork } from 'child_process';
|
|
5
|
+
import { SELF_SIGNED_CERTIFICATE_TOKEN } from '@tramvai/api/lib/utils/selfSignedCertificate/createSelfSignedCertificate';
|
|
6
|
+
|
|
5
7
|
import {
|
|
6
8
|
COMMAND_PARAMETERS_TOKEN,
|
|
7
9
|
CONFIG_ENTRY_TOKEN,
|
|
8
10
|
CONFIG_MANAGER_TOKEN,
|
|
9
11
|
PORT_MANAGER_TOKEN,
|
|
10
|
-
SELF_SIGNED_CERTIFICATE_TOKEN,
|
|
11
12
|
STATIC_SERVER_TOKEN,
|
|
12
13
|
} from '../../../di/tokens';
|
|
13
14
|
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
package/src/di/tokens/server.ts
CHANGED
|
@@ -4,8 +4,3 @@ import type { StoppableServer } from 'stoppable';
|
|
|
4
4
|
export const SERVER_TOKEN = createToken<StoppableServer>('server server');
|
|
5
5
|
|
|
6
6
|
export const STATIC_SERVER_TOKEN = createToken<StoppableServer>('server staticServer');
|
|
7
|
-
|
|
8
|
-
export const SELF_SIGNED_CERTIFICATE_TOKEN = createToken<{
|
|
9
|
-
keyPath: string;
|
|
10
|
-
certificatePath: string;
|
|
11
|
-
}>('self signed certificates token');
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const certificatedHostsListFilePath: string;
|
|
2
|
-
export declare const createCertificatedHostsListFile: (data: string[]) => void;
|
|
3
|
-
export declare const readCertificatedHostsListFile: () => Set<string> | null;
|
|
4
|
-
//# sourceMappingURL=certificatedHostsList.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"certificatedHostsList.d.ts","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/certificatedHostsList.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,QAGzC,CAAC;AAGF,eAAO,MAAM,+BAA+B,SAAU,MAAM,EAAE,SAE7D,CAAC;AAEF,eAAO,MAAM,6BAA6B,QAAO,IAAI,MAAM,CAAC,GAAG,IAO9D,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readCertificatedHostsListFile = exports.createCertificatedHostsListFile = exports.certificatedHostsListFilePath = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
exports.certificatedHostsListFilePath = path_1.default.resolve(common_1.certificateDirectoryPath, 'certificatedHostsList');
|
|
9
|
-
const separator = ',';
|
|
10
|
-
const createCertificatedHostsListFile = (data) => {
|
|
11
|
-
fs_1.default.writeFileSync(exports.certificatedHostsListFilePath, data.join(separator), 'utf-8');
|
|
12
|
-
};
|
|
13
|
-
exports.createCertificatedHostsListFile = createCertificatedHostsListFile;
|
|
14
|
-
const readCertificatedHostsListFile = () => {
|
|
15
|
-
if (!fs_1.default.existsSync(exports.certificatedHostsListFilePath)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const data = fs_1.default.readFileSync(exports.certificatedHostsListFilePath, 'utf-8');
|
|
19
|
-
return new Set(data.split(separator));
|
|
20
|
-
};
|
|
21
|
-
exports.readCertificatedHostsListFile = readCertificatedHostsListFile;
|
|
22
|
-
//# sourceMappingURL=certificatedHostsList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"certificatedHostsList.js","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/certificatedHostsList.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AACxB,qCAAoD;AAEvC,QAAA,6BAA6B,GAAG,cAAI,CAAC,OAAO,CACvD,iCAAwB,EACxB,uBAAuB,CACxB,CAAC;AACF,MAAM,SAAS,GAAG,GAAG,CAAC;AAEf,MAAM,+BAA+B,GAAG,CAAC,IAAc,EAAE,EAAE;IAChE,YAAE,CAAC,aAAa,CAAC,qCAA6B,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;AACjF,CAAC,CAAC;AAFW,QAAA,+BAA+B,mCAE1C;AAEK,MAAM,6BAA6B,GAAG,GAAuB,EAAE;IACpE,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,qCAA6B,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,qCAA6B,EAAE,OAAO,CAAC,CAAC;IACrE,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAPW,QAAA,6BAA6B,iCAOxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,eAAO,MAAM,wBAAwB,QAAoD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.certificateDirectoryPath = exports.certificateDirectory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
exports.certificateDirectory = 'certificates';
|
|
7
|
-
exports.certificateDirectoryPath = path_1.default.resolve(process.cwd(), exports.certificateDirectory);
|
|
8
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/common.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAEX,QAAA,oBAAoB,GAAG,cAAc,CAAC;AACtC,QAAA,wBAAwB,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAAoB,CAAC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Certificate } from '../../types/base';
|
|
2
|
-
interface CreateSelfSignedCertificateOptions {
|
|
3
|
-
host?: string;
|
|
4
|
-
keyPath?: string;
|
|
5
|
-
certificatePath?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const createSelfSignedCertificate: (options: CreateSelfSignedCertificateOptions) => Certificate;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=createSelfSignedCertificate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSelfSignedCertificate.d.ts","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD,UAAU,kCAAkC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAGD,eAAO,MAAM,2BAA2B,YAC7B,kCAAkC,KAC1C,WA6EF,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSelfSignedCertificate = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
-
const getHosts_1 = require("./getHosts");
|
|
10
|
-
const common_1 = require("./common");
|
|
11
|
-
const certificatedHostsList_1 = require("./certificatedHostsList");
|
|
12
|
-
// eslint-disable-next-line max-statements
|
|
13
|
-
const createSelfSignedCertificate = (options) => {
|
|
14
|
-
try {
|
|
15
|
-
const { host } = options;
|
|
16
|
-
const hosts = (0, getHosts_1.getHosts)(host === '0.0.0.0' ? null : host);
|
|
17
|
-
const hostsFile = (0, certificatedHostsList_1.readCertificatedHostsListFile)();
|
|
18
|
-
const defaultKeyPath = path_1.default.resolve(common_1.certificateDirectoryPath, 'localhost-key.pem');
|
|
19
|
-
const defaultCertificatePath = path_1.default.resolve(common_1.certificateDirectoryPath, 'localhost.pem');
|
|
20
|
-
const keyPath = options.keyPath ? path_1.default.resolve(options.keyPath) : defaultKeyPath;
|
|
21
|
-
const certificatePath = options.certificatePath
|
|
22
|
-
? path_1.default.resolve(options.certificatePath)
|
|
23
|
-
: defaultCertificatePath;
|
|
24
|
-
// check if certificates are already generated, in this case we simply skip step
|
|
25
|
-
const isExternalCertificateProvided = options.certificatePath && options.keyPath;
|
|
26
|
-
const isCertificateAlreadyExist = !isExternalCertificateProvided &&
|
|
27
|
-
fs_1.default.existsSync(keyPath) &&
|
|
28
|
-
fs_1.default.existsSync(certificatePath) &&
|
|
29
|
-
hostsFile &&
|
|
30
|
-
hosts.every((h) => hostsFile.has(h));
|
|
31
|
-
const gitignorePath = path_1.default.resolve(process.cwd(), '.gitignore');
|
|
32
|
-
if (fs_1.default.existsSync(gitignorePath) &&
|
|
33
|
-
!fs_1.default.readFileSync(gitignorePath, 'utf-8').includes(common_1.certificateDirectory)) {
|
|
34
|
-
fs_1.default.appendFileSync(gitignorePath, `\n${common_1.certificateDirectory}`);
|
|
35
|
-
}
|
|
36
|
-
if (isExternalCertificateProvided || isCertificateAlreadyExist) {
|
|
37
|
-
console.log(chalk_1.default.blue('Certificates for https environment are already exist, skipping step with certificate generation'));
|
|
38
|
-
return {
|
|
39
|
-
keyPath,
|
|
40
|
-
certificatePath,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
fs_1.default.mkdirSync(common_1.certificateDirectoryPath, { recursive: true });
|
|
44
|
-
(0, certificatedHostsList_1.createCertificatedHostsListFile)(hosts);
|
|
45
|
-
// TODO: maybe it is better to install mkcert for users for better dx
|
|
46
|
-
// check https://github.com/liuweiGL/vite-plugin-mkcert/blob/main/plugin/index.ts and https://github.com/vercel/next.js/blob/28fdc367b1f6d41245ea036bc40d1035a8a4d0e4/packages/next/src/lib/mkcert.ts#L68
|
|
47
|
-
(0, child_process_1.execSync)(`mkcert -install -key-file "${keyPath}" -cert-file "${certificatePath}" ${hosts.join(' ')}`);
|
|
48
|
-
if (!fs_1.default.existsSync(keyPath) || !fs_1.default.existsSync(certificatePath)) {
|
|
49
|
-
throw new Error('Error occured while certificate creation. Generated certificate files not found');
|
|
50
|
-
}
|
|
51
|
-
const CAROOTFileLocation = (0, child_process_1.execSync)('mkcert -CAROOT').toString().trim();
|
|
52
|
-
console.log(chalk_1.default.green(`Root certificate located in ${chalk_1.default.blue(CAROOTFileLocation)}`));
|
|
53
|
-
return {
|
|
54
|
-
keyPath,
|
|
55
|
-
certificatePath,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error(chalk_1.default.red(`Error while generating the certificate. The mkcert tool may not be installed please check and install it if that is the case.`));
|
|
60
|
-
throw new Error(error);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports.createSelfSignedCertificate = createSelfSignedCertificate;
|
|
64
|
-
//# sourceMappingURL=createSelfSignedCertificate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSelfSignedCertificate.js","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/createSelfSignedCertificate.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAC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P,+HAA+H,CAChI,CACF,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;KACxB;AACH,CAAC,CAAC;AA/EW,QAAA,2BAA2B,+BA+EtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getHosts.d.ts","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/getHosts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,gBAmB3B,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,MAAM,aAOrC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHosts = exports.getDefaultHosts = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
-
const getDefaultHosts = () => {
|
|
7
|
-
const defaultHosts = ['localhost'];
|
|
8
|
-
const networkInterfaces = os_1.default.networkInterfaces();
|
|
9
|
-
for (const networkInterfaceKey in networkInterfaces) {
|
|
10
|
-
const networkInterfacesInfo = networkInterfaces[networkInterfaceKey];
|
|
11
|
-
if (networkInterfacesInfo) {
|
|
12
|
-
for (const info of networkInterfacesInfo) {
|
|
13
|
-
// https://github.com/nodejs/node/issues/42787
|
|
14
|
-
//@ts-expect-error
|
|
15
|
-
if (info.family === 'IPv4' || info.family === '4') {
|
|
16
|
-
defaultHosts.push(info.address);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return defaultHosts;
|
|
22
|
-
};
|
|
23
|
-
exports.getDefaultHosts = getDefaultHosts;
|
|
24
|
-
const getHosts = (host) => {
|
|
25
|
-
const hosts = new Set([...(0, exports.getDefaultHosts)()]);
|
|
26
|
-
if (host && !hosts.has(host)) {
|
|
27
|
-
hosts.add(host);
|
|
28
|
-
}
|
|
29
|
-
return Array.from(hosts);
|
|
30
|
-
};
|
|
31
|
-
exports.getHosts = getHosts;
|
|
32
|
-
//# sourceMappingURL=getHosts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getHosts.js","sourceRoot":"","sources":["../../../../../src/api/shared/utils/selfSignedCertificate/getHosts.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAEb,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,YAAY,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,iBAAiB,GAAG,YAAE,CAAC,iBAAiB,EAAE,CAAC;IAEjD,KAAK,MAAM,mBAAmB,IAAI,iBAAiB,EAAE;QACnD,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;QAErE,IAAI,qBAAqB,EAAE;YACzB,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE;gBACxC,8CAA8C;gBAC9C,kBAAkB;gBAClB,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;oBACjD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACjC;aACF;SACF;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B;AAEK,MAAM,QAAQ,GAAG,CAAC,IAAa,EAAE,EAAE;IACxC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAA,uBAAe,GAAE,CAAC,CAAC,CAAC;IAE9C,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC5B,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACjB;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC,CAAC;AAPW,QAAA,QAAQ,YAOnB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { certificateDirectoryPath } from './common';
|
|
4
|
-
|
|
5
|
-
export const certificatedHostsListFilePath = path.resolve(
|
|
6
|
-
certificateDirectoryPath,
|
|
7
|
-
'certificatedHostsList'
|
|
8
|
-
);
|
|
9
|
-
const separator = ',';
|
|
10
|
-
|
|
11
|
-
export const createCertificatedHostsListFile = (data: string[]) => {
|
|
12
|
-
fs.writeFileSync(certificatedHostsListFilePath, data.join(separator), 'utf-8');
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const readCertificatedHostsListFile = (): Set<string> | null => {
|
|
16
|
-
if (!fs.existsSync(certificatedHostsListFilePath)) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const data = fs.readFileSync(certificatedHostsListFilePath, 'utf-8');
|
|
21
|
-
return new Set(data.split(separator));
|
|
22
|
-
};
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import child_process from 'child_process';
|
|
5
|
-
|
|
6
|
-
import { createSelfSignedCertificate } from './createSelfSignedCertificate';
|
|
7
|
-
import { certificatedHostsListFilePath } from './certificatedHostsList';
|
|
8
|
-
import { certificateDirectoryPath } from './common';
|
|
9
|
-
|
|
10
|
-
const defaultKeyPath = path.resolve(certificateDirectoryPath, 'localhost-key.pem');
|
|
11
|
-
const defaultCertificatePath = path.resolve(certificateDirectoryPath, 'localhost.pem');
|
|
12
|
-
const gitignorePath = path.resolve(process.cwd(), '.gitignore');
|
|
13
|
-
const customHost = 'localhost.domain.com';
|
|
14
|
-
|
|
15
|
-
jest.mock('os', () => {
|
|
16
|
-
return {
|
|
17
|
-
networkInterfaces: (param: string) => {
|
|
18
|
-
return [];
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const existsSyncSpy = jest.spyOn(fs, 'existsSync');
|
|
24
|
-
const mkdirSyncSpy = jest.spyOn(fs, 'mkdirSync');
|
|
25
|
-
const writeFileSyncSpy = jest.spyOn(fs, 'writeFileSync');
|
|
26
|
-
const readFileSyncSpy = jest.spyOn(fs, 'readFileSync');
|
|
27
|
-
const execSyncSpy = jest.spyOn(child_process, 'execSync');
|
|
28
|
-
const appendFileSyncSpy = jest.spyOn(fs, 'appendFileSync');
|
|
29
|
-
|
|
30
|
-
describe('shared/utils/selfSignedCertificate', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
writeFileSyncSpy.mockImplementation(() => undefined);
|
|
33
|
-
mkdirSyncSpy.mockImplementation(() => {
|
|
34
|
-
return undefined;
|
|
35
|
-
});
|
|
36
|
-
execSyncSpy.mockImplementation((command) => {
|
|
37
|
-
if (command === 'mkcert -CAROOT') return '/location';
|
|
38
|
-
return '';
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
readFileSyncSpy.mockImplementation((path) => {
|
|
42
|
-
if (path === gitignorePath) return '';
|
|
43
|
-
return `localhost,${customHost}`;
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
jest.clearAllMocks();
|
|
48
|
-
existsSyncSpy.mockReset();
|
|
49
|
-
mkdirSyncSpy.mockReset();
|
|
50
|
-
writeFileSyncSpy.mockReset();
|
|
51
|
-
execSyncSpy.mockReset();
|
|
52
|
-
});
|
|
53
|
-
it('should generate certificate', async () => {
|
|
54
|
-
existsSyncSpy.mockImplementation((path) => {
|
|
55
|
-
if (path === certificatedHostsListFilePath || path === gitignorePath) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return true;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const result = createSelfSignedCertificate({});
|
|
62
|
-
|
|
63
|
-
expect(execSyncSpy).toHaveBeenNthCalledWith(
|
|
64
|
-
1,
|
|
65
|
-
`mkcert -install -key-file "${defaultKeyPath}" -cert-file "${defaultCertificatePath}" localhost`
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
expect(result).toEqual({
|
|
69
|
-
keyPath: defaultKeyPath,
|
|
70
|
-
certificatePath: defaultCertificatePath,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
it('should generate certificate for provided host', async () => {
|
|
74
|
-
existsSyncSpy.mockImplementation((path) => {
|
|
75
|
-
if (path === certificatedHostsListFilePath || path === gitignorePath) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
});
|
|
80
|
-
const result = createSelfSignedCertificate({ host: customHost });
|
|
81
|
-
expect(execSyncSpy).toHaveBeenNthCalledWith(
|
|
82
|
-
1,
|
|
83
|
-
`mkcert -install -key-file "${defaultKeyPath}" -cert-file "${defaultCertificatePath}" localhost ${customHost}`
|
|
84
|
-
);
|
|
85
|
-
expect(result).toEqual({
|
|
86
|
-
keyPath: defaultKeyPath,
|
|
87
|
-
certificatePath: defaultCertificatePath,
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should return already existed certificate if it was generated previously', async () => {
|
|
92
|
-
existsSyncSpy.mockImplementation((path) => {
|
|
93
|
-
if (path === gitignorePath) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
});
|
|
98
|
-
const result = createSelfSignedCertificate({ host: customHost });
|
|
99
|
-
expect(execSyncSpy).toHaveBeenCalledTimes(0);
|
|
100
|
-
|
|
101
|
-
expect(result).toEqual({
|
|
102
|
-
keyPath: defaultKeyPath,
|
|
103
|
-
certificatePath: defaultCertificatePath,
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should use custom certificate if provided', () => {
|
|
108
|
-
const customCertificate = {
|
|
109
|
-
certificatePath: path.resolve('path-to-custom-certificate/cert.pem'),
|
|
110
|
-
keyPath: path.resolve('path-to-custom-certificate/key.pem'),
|
|
111
|
-
};
|
|
112
|
-
const result = createSelfSignedCertificate({
|
|
113
|
-
host: customHost,
|
|
114
|
-
...customCertificate,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
expect(execSyncSpy).toHaveBeenCalledTimes(0);
|
|
118
|
-
|
|
119
|
-
expect(result).toEqual({
|
|
120
|
-
keyPath: customCertificate.keyPath,
|
|
121
|
-
certificatePath: customCertificate.certificatePath,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
it('if a new host be provided, a new certificate should be generated even if a certificate already exists.', () => {
|
|
125
|
-
existsSyncSpy.mockImplementation((path) => {
|
|
126
|
-
if (path === gitignorePath) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
});
|
|
131
|
-
const result = createSelfSignedCertificate({ host: 'new.localhost.domain' });
|
|
132
|
-
expect(execSyncSpy).toHaveBeenNthCalledWith(
|
|
133
|
-
1,
|
|
134
|
-
`mkcert -install -key-file "${defaultKeyPath}" -cert-file "${defaultCertificatePath}" localhost new.localhost.domain`
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
expect(result).toEqual({
|
|
138
|
-
keyPath: defaultKeyPath,
|
|
139
|
-
certificatePath: defaultCertificatePath,
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
it('should add certificates folder to .gitignore if .gitignore file exist', () => {
|
|
143
|
-
existsSyncSpy.mockImplementation((path) => {
|
|
144
|
-
return true;
|
|
145
|
-
});
|
|
146
|
-
const result = createSelfSignedCertificate({ host: 'new.localhost.domain' });
|
|
147
|
-
expect(appendFileSyncSpy).toHaveBeenCalledTimes(1);
|
|
148
|
-
|
|
149
|
-
expect(result).toEqual({
|
|
150
|
-
keyPath: defaultKeyPath,
|
|
151
|
-
certificatePath: defaultCertificatePath,
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import type { Certificate } from '../../types/base';
|
|
6
|
-
import { getHosts } from './getHosts';
|
|
7
|
-
import { certificateDirectoryPath, certificateDirectory } from './common';
|
|
8
|
-
import {
|
|
9
|
-
createCertificatedHostsListFile,
|
|
10
|
-
readCertificatedHostsListFile,
|
|
11
|
-
} from './certificatedHostsList';
|
|
12
|
-
|
|
13
|
-
interface CreateSelfSignedCertificateOptions {
|
|
14
|
-
host?: string;
|
|
15
|
-
keyPath?: string;
|
|
16
|
-
certificatePath?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line max-statements
|
|
20
|
-
export const createSelfSignedCertificate = (
|
|
21
|
-
options: CreateSelfSignedCertificateOptions
|
|
22
|
-
): Certificate => {
|
|
23
|
-
try {
|
|
24
|
-
const { host } = options;
|
|
25
|
-
const hosts = getHosts(host === '0.0.0.0' ? null : host);
|
|
26
|
-
const hostsFile = readCertificatedHostsListFile();
|
|
27
|
-
|
|
28
|
-
const defaultKeyPath = path.resolve(certificateDirectoryPath, 'localhost-key.pem');
|
|
29
|
-
const defaultCertificatePath = path.resolve(certificateDirectoryPath, 'localhost.pem');
|
|
30
|
-
|
|
31
|
-
const keyPath = options.keyPath ? path.resolve(options.keyPath) : defaultKeyPath;
|
|
32
|
-
const certificatePath = options.certificatePath
|
|
33
|
-
? path.resolve(options.certificatePath)
|
|
34
|
-
: defaultCertificatePath;
|
|
35
|
-
|
|
36
|
-
// check if certificates are already generated, in this case we simply skip step
|
|
37
|
-
|
|
38
|
-
const isExternalCertificateProvided = options.certificatePath && options.keyPath;
|
|
39
|
-
|
|
40
|
-
const isCertificateAlreadyExist =
|
|
41
|
-
!isExternalCertificateProvided &&
|
|
42
|
-
fs.existsSync(keyPath) &&
|
|
43
|
-
fs.existsSync(certificatePath) &&
|
|
44
|
-
hostsFile &&
|
|
45
|
-
hosts.every((h) => hostsFile.has(h));
|
|
46
|
-
|
|
47
|
-
const gitignorePath = path.resolve(process.cwd(), '.gitignore');
|
|
48
|
-
if (
|
|
49
|
-
fs.existsSync(gitignorePath) &&
|
|
50
|
-
!fs.readFileSync(gitignorePath, 'utf-8').includes(certificateDirectory)
|
|
51
|
-
) {
|
|
52
|
-
fs.appendFileSync(gitignorePath, `\n${certificateDirectory}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (isExternalCertificateProvided || isCertificateAlreadyExist) {
|
|
56
|
-
console.log(
|
|
57
|
-
chalk.blue(
|
|
58
|
-
'Certificates for https environment are already exist, skipping step with certificate generation'
|
|
59
|
-
)
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
keyPath,
|
|
64
|
-
certificatePath,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
fs.mkdirSync(certificateDirectoryPath, { recursive: true });
|
|
69
|
-
createCertificatedHostsListFile(hosts);
|
|
70
|
-
|
|
71
|
-
// TODO: maybe it is better to install mkcert for users for better dx
|
|
72
|
-
// check https://github.com/liuweiGL/vite-plugin-mkcert/blob/main/plugin/index.ts and https://github.com/vercel/next.js/blob/28fdc367b1f6d41245ea036bc40d1035a8a4d0e4/packages/next/src/lib/mkcert.ts#L68
|
|
73
|
-
execSync(
|
|
74
|
-
`mkcert -install -key-file "${keyPath}" -cert-file "${certificatePath}" ${hosts.join(' ')}`
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (!fs.existsSync(keyPath) || !fs.existsSync(certificatePath)) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
'Error occured while certificate creation. Generated certificate files not found'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const CAROOTFileLocation = execSync('mkcert -CAROOT').toString().trim();
|
|
84
|
-
|
|
85
|
-
console.log(chalk.green(`Root certificate located in ${chalk.blue(CAROOTFileLocation)}`));
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
keyPath,
|
|
89
|
-
certificatePath,
|
|
90
|
-
};
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error(
|
|
93
|
-
chalk.red(
|
|
94
|
-
`Error while generating the certificate. The mkcert tool may not be installed please check and install it if that is the case.`
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
throw new Error(error);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
|
|
3
|
-
export const getDefaultHosts = () => {
|
|
4
|
-
const defaultHosts = ['localhost'];
|
|
5
|
-
const networkInterfaces = os.networkInterfaces();
|
|
6
|
-
|
|
7
|
-
for (const networkInterfaceKey in networkInterfaces) {
|
|
8
|
-
const networkInterfacesInfo = networkInterfaces[networkInterfaceKey];
|
|
9
|
-
|
|
10
|
-
if (networkInterfacesInfo) {
|
|
11
|
-
for (const info of networkInterfacesInfo) {
|
|
12
|
-
// https://github.com/nodejs/node/issues/42787
|
|
13
|
-
//@ts-expect-error
|
|
14
|
-
if (info.family === 'IPv4' || info.family === '4') {
|
|
15
|
-
defaultHosts.push(info.address);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return defaultHosts;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const getHosts = (host?: string) => {
|
|
25
|
-
const hosts = new Set([...getDefaultHosts()]);
|
|
26
|
-
|
|
27
|
-
if (host && !hosts.has(host)) {
|
|
28
|
-
hosts.add(host);
|
|
29
|
-
}
|
|
30
|
-
return Array.from(hosts);
|
|
31
|
-
};
|