@fastybird/smart-panel-backend 1.1.0-alpha.3 → 1.1.0-alpha.4
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/dist/common/filters/conflict-exception.filter.d.ts +6 -0
- package/dist/common/filters/conflict-exception.filter.js +59 -0
- package/dist/common/filters/conflict-exception.filter.js.map +1 -0
- package/dist/common/filters/global-error.filter.js +1 -4
- package/dist/common/filters/global-error.filter.js.map +1 -1
- package/dist/common/filters/global-filters.d.ts +3 -0
- package/dist/common/filters/global-filters.js +22 -0
- package/dist/common/filters/global-filters.js.map +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.d.ts +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.js +15 -3
- package/dist/common/filters/unprocessable-entity-exception.filter.js.map +1 -1
- package/dist/main.js +2 -7
- package/dist/main.js.map +1 -1
- package/dist/modules/platform/services/platform.service.d.ts +13 -4
- package/dist/modules/platform/services/platform.service.js +57 -35
- package/dist/modules/platform/services/platform.service.js.map +1 -1
- package/dist/modules/remote-access/dto/update-config.dto.js +5 -0
- package/dist/modules/remote-access/dto/update-config.dto.js.map +1 -1
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js +5 -2
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js.map +1 -1
- package/dist/modules/system/services/privileged-worker.service.d.ts +10 -0
- package/dist/modules/system/services/privileged-worker.service.js +137 -11
- package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +6 -9
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +26 -10
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +28 -3
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +19 -0
- package/dist/plugins/remote-access-tailscale/models/status.model.js +158 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +13 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +27 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +2 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +1 -1
- package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +61 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +12 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +23 -2
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +26 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +245 -29
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +8 -3
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +39 -12
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +14 -5
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +51 -16
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FastifyReply as Response } from 'fastify';
|
|
2
|
+
import { ArgumentsHost, ConflictException, ExceptionFilter } from '@nestjs/common';
|
|
3
|
+
export declare class ConflictExceptionFilter implements ExceptionFilter {
|
|
4
|
+
catch(exception: ConflictException, host: ArgumentsHost): Response<import("fastify").RouteGenericInterface, import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
|
|
5
|
+
private extractApplicationCode;
|
|
6
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.ConflictExceptionFilter = void 0;
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const app_constants_1 = require("../../app.constants");
|
|
13
|
+
let ConflictExceptionFilter = class ConflictExceptionFilter {
|
|
14
|
+
catch(exception, host) {
|
|
15
|
+
const ctx = host.switchToHttp();
|
|
16
|
+
const request = ctx.getRequest();
|
|
17
|
+
const response = ctx.getResponse();
|
|
18
|
+
const status = exception.getStatus() || common_1.HttpStatus.CONFLICT;
|
|
19
|
+
const exceptionResponse = exception.getResponse();
|
|
20
|
+
const requestId = (0, uuid_1.v4)();
|
|
21
|
+
const details = {
|
|
22
|
+
reason: exception.message,
|
|
23
|
+
};
|
|
24
|
+
const applicationCode = this.extractApplicationCode(exceptionResponse);
|
|
25
|
+
if (applicationCode !== undefined) {
|
|
26
|
+
details.code = applicationCode;
|
|
27
|
+
}
|
|
28
|
+
return response
|
|
29
|
+
.code(status)
|
|
30
|
+
.type('application/json')
|
|
31
|
+
.send({
|
|
32
|
+
status: app_constants_1.RequestResultState.ERROR,
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
request_id: requestId,
|
|
35
|
+
path: request.originalUrl,
|
|
36
|
+
method: request.method,
|
|
37
|
+
error: {
|
|
38
|
+
code: 'ConflictError',
|
|
39
|
+
message: exception.message,
|
|
40
|
+
details,
|
|
41
|
+
},
|
|
42
|
+
metadata: {
|
|
43
|
+
server_time: new Date().toISOString(),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
extractApplicationCode(exceptionResponse) {
|
|
48
|
+
if (typeof exceptionResponse === 'object' && exceptionResponse !== null && 'code' in exceptionResponse) {
|
|
49
|
+
const code = exceptionResponse.code;
|
|
50
|
+
return typeof code === 'string' ? code : undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.ConflictExceptionFilter = ConflictExceptionFilter;
|
|
56
|
+
exports.ConflictExceptionFilter = ConflictExceptionFilter = __decorate([
|
|
57
|
+
(0, common_1.Catch)(common_1.ConflictException)
|
|
58
|
+
], ConflictExceptionFilter);
|
|
59
|
+
//# sourceMappingURL=conflict-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-exception.filter.js","s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,WAAW,EAAE;aACrC;SACD,CAAC,CAAC;IACL,CAAC;IASO,sBAAsB,CAAC,iBAA0B;QACxD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,IAAI,iBAAiB,KAAK,IAAI,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACxG,MAAM,IAAI,GAAI,iBAA6C,CAAC,IAAI,CAAC;YAEjE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACpD,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAA;AAvDY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,cAAK,EAAC,0BAAiB,CAAC;GACZ,uBAAuB,CAuDnC"}
|
|
@@ -41,7 +41,6 @@ let GlobalErrorFilter = GlobalErrorFilter_1 = class GlobalErrorFilter {
|
|
|
41
41
|
exceptionMessage = 'Unknown error';
|
|
42
42
|
}
|
|
43
43
|
this.logger.error(`[ERROR] [GlobalErrorFilter] ${request.method} ${request.originalUrl} ${status} - ${exceptionMessage}`, exception instanceof Error ? exception.stack : undefined);
|
|
44
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
|
45
44
|
const errorResponse = {
|
|
46
45
|
status: app_constants_1.RequestResultState.ERROR,
|
|
47
46
|
timestamp: new Date().toISOString(),
|
|
@@ -51,9 +50,7 @@ let GlobalErrorFilter = GlobalErrorFilter_1 = class GlobalErrorFilter {
|
|
|
51
50
|
error: {
|
|
52
51
|
code: exception instanceof common_1.HttpException ? exception.name : 'InternalServerError',
|
|
53
52
|
message: errorMessage,
|
|
54
|
-
details:
|
|
55
|
-
? exception.getResponse()
|
|
56
|
-
: { reason: 'An unexpected server error occurred.' },
|
|
53
|
+
details: { reason: 'An unexpected server error occurred.' },
|
|
57
54
|
},
|
|
58
55
|
metadata: {
|
|
59
56
|
server_time: new Date().toISOString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-error.filter.js","sourceRoot":"","sources":["../../../src/common/filters/global-error.filter.ts"],"names":[],"mappings":";;;;;;;;;;AACA,+BAAoC;AAEpC,2CAA0G;AAE1G,uDAAyD;
|
|
1
|
+
{"version":3,"file":"global-error.filter.js","sourceRoot":"","sources":["../../../src/common/filters/global-error.filter.ts"],"names":[],"mappings":";;;;;;;;;;AACA,+BAAoC;AAEpC,2CAA0G;AAE1G,uDAAyD;AAclD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB;QACW,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAoD9D,CAAC;IAlDA,KAAK,CAAC,SAAkB,EAAE,IAAmB;QAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAA,SAAM,GAAE,CAAC;QAG3B,MAAM,MAAM,GAAG,SAAS,YAAY,sBAAa,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;QAE7G,MAAM,YAAY,GAAG,SAAS,YAAY,sBAAa,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;QAE9G,IAAI,gBAAwB,CAAC;QAC7B,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAChC,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC;QACtC,CAAC;aAAM,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YAChE,IAAI,CAAC;gBACJ,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAC9C,CAAC;YAAC,MAAM,CAAC;gBAER,gBAAgB,GAAG,MAA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
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGlobalExceptionFilters = createGlobalExceptionFilters;
|
|
4
|
+
const bad_request_exception_filter_1 = require("./bad-request-exception.filter");
|
|
5
|
+
const conflict_exception_filter_1 = require("./conflict-exception.filter");
|
|
6
|
+
const global_error_filter_1 = require("./global-error.filter");
|
|
7
|
+
const internal_server_error_exception_filter_1 = require("./internal-server-error-exception.filter");
|
|
8
|
+
const not_found_exception_filter_1 = require("./not-found-exception.filter");
|
|
9
|
+
const query_failed_exception_filter_1 = require("./query-failed-exception.filter");
|
|
10
|
+
const unprocessable_entity_exception_filter_1 = require("./unprocessable-entity-exception.filter");
|
|
11
|
+
function createGlobalExceptionFilters(configService) {
|
|
12
|
+
return [
|
|
13
|
+
new global_error_filter_1.GlobalErrorFilter(),
|
|
14
|
+
new internal_server_error_exception_filter_1.InternalServerErrorExceptionFilter(),
|
|
15
|
+
new bad_request_exception_filter_1.BadRequestExceptionFilter(),
|
|
16
|
+
new conflict_exception_filter_1.ConflictExceptionFilter(),
|
|
17
|
+
new unprocessable_entity_exception_filter_1.UnprocessableEntityExceptionFilter(),
|
|
18
|
+
new not_found_exception_filter_1.NotFoundExceptionFilter(configService),
|
|
19
|
+
new query_failed_exception_filter_1.QueryFailedExceptionFilter(),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=global-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-filters.js","sourceRoot":"","sources":["../../../src/common/filters/global-filters.ts"],"names":[],"mappings":";;AA0BA,oEAUC;AAjCD,iFAA2E;AAC3E,2EAAsE;AACtE,+DAA0D;AAC1D,qGAA8F;AAC9F,6EAAuE;AACvE,mFAA6E;AAC7E,mGAA6F;AAiB7F,SAAgB,4BAA4B,CAAC,aAA4B;IACxE,OAAO;QACN,IAAI,uCAAiB,EAAE;QACvB,IAAI,2EAAkC,EAAE;QACxC,IAAI,wDAAyB,EAAE;QAC/B,IAAI,mDAAuB,EAAE;QAC7B,IAAI,0EAAkC,EAAE;QACxC,IAAI,oDAAuB,CAAC,aAAa,CAAC;QAC1C,IAAI,0DAA0B,EAAE;KAChC,CAAC;AACH,CAAC"}
|
|
@@ -2,4 +2,5 @@ import { FastifyReply as Response } from 'fastify';
|
|
|
2
2
|
import { ArgumentsHost, ExceptionFilter, UnprocessableEntityException } from '@nestjs/common';
|
|
3
3
|
export declare class UnprocessableEntityExceptionFilter implements ExceptionFilter {
|
|
4
4
|
catch(exception: UnprocessableEntityException, host: ArgumentsHost): Response<import("fastify").RouteGenericInterface, import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
|
|
5
|
+
private extractApplicationCode;
|
|
5
6
|
}
|
|
@@ -18,6 +18,13 @@ let UnprocessableEntityExceptionFilter = class UnprocessableEntityExceptionFilte
|
|
|
18
18
|
const status = exception.getStatus() || common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
19
19
|
const exceptionResponse = exception.getResponse();
|
|
20
20
|
const requestId = (0, uuid_1.v4)();
|
|
21
|
+
const details = {
|
|
22
|
+
reason: exceptionResponse.message || `The data provided could not be processed in its current state.`,
|
|
23
|
+
};
|
|
24
|
+
const applicationCode = this.extractApplicationCode(exception.getResponse());
|
|
25
|
+
if (applicationCode !== undefined) {
|
|
26
|
+
details.code = applicationCode;
|
|
27
|
+
}
|
|
21
28
|
return response
|
|
22
29
|
.code(status)
|
|
23
30
|
.type('application/json')
|
|
@@ -30,15 +37,20 @@ let UnprocessableEntityExceptionFilter = class UnprocessableEntityExceptionFilte
|
|
|
30
37
|
error: {
|
|
31
38
|
code: 'UnprocessableEntity',
|
|
32
39
|
message: 'The request could not be processed due to semantic issues.',
|
|
33
|
-
details
|
|
34
|
-
reason: exceptionResponse.message || `The data provided could not be processed in its current state.`,
|
|
35
|
-
},
|
|
40
|
+
details,
|
|
36
41
|
},
|
|
37
42
|
metadata: {
|
|
38
43
|
server_time: new Date().toISOString(),
|
|
39
44
|
},
|
|
40
45
|
});
|
|
41
46
|
}
|
|
47
|
+
extractApplicationCode(exceptionResponse) {
|
|
48
|
+
if (typeof exceptionResponse === 'object' && exceptionResponse !== null && 'code' in exceptionResponse) {
|
|
49
|
+
const code = exceptionResponse.code;
|
|
50
|
+
return typeof code === 'string' ? code : undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
42
54
|
};
|
|
43
55
|
exports.UnprocessableEntityExceptionFilter = UnprocessableEntityExceptionFilter;
|
|
44
56
|
exports.UnprocessableEntityExceptionFilter = UnprocessableEntityExceptionFilter = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unprocessable-entity-exception.filter.js","sourceRoot":"","sources":["../../../src/common/filters/unprocessable-entity-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAAoC;AAEpC,2CAAiH;AAEjH,uDAAyD;AAGlD,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC9C,KAAK,CAAC,SAAuC,EAAE,IAAmB;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,mBAAU,CAAC,qBAAqB,CAAC;QACzE,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,EAE9C,CAAC;QACF,MAAM,SAAS,GAAG,IAAA,SAAM,GAAE,CAAC;QAE3B,OAAO,QAAQ;aACb,IAAI,CAAC,MAAM,CAAC;aACZ,IAAI,CAAC,kBAAkB,CAAC;aACxB,IAAI,CAAC;YACL,MAAM,EAAE,kCAAkB,CAAC,KAAK;YAChC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,SAAS;YACrB,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE;gBACN,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EAAE,4DAA4D;gBACrE,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"unprocessable-entity-exception.filter.js","sourceRoot":"","sources":["../../../src/common/filters/unprocessable-entity-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAAoC;AAEpC,2CAAiH;AAEjH,uDAAyD;AAGlD,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC9C,KAAK,CAAC,SAAuC,EAAE,IAAmB;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,mBAAU,CAAC,qBAAqB,CAAC;QACzE,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,EAE9C,CAAC;QACF,MAAM,SAAS,GAAG,IAAA,SAAM,GAAE,CAAC;QAE3B,MAAM,OAAO,GAAuC;YACnD,MAAM,EAAE,iBAAiB,CAAC,OAAO,IAAI,gEAAgE;SACrG,CAAC;QAMF,MAAM,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QAE7E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC;QAChC,CAAC;QAED,OAAO,QAAQ;aACb,IAAI,CAAC,MAAM,CAAC;aACZ,IAAI,CAAC,kBAAkB,CAAC;aACxB,IAAI,CAAC;YACL,MAAM,EAAE,kCAAkB,CAAC,KAAK;YAChC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,SAAS;YACrB,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE;gBACN,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EAAE,4DAA4D;gBACrE,OAAO;aACP;YACD,QAAQ,EAAE;gBACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACrC;SACD,CAAC,CAAC;IACL,CAAC;IAEO,sBAAsB,CAAC,iBAA0B;QACxD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,IAAI,iBAAiB,KAAK,IAAI,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACxG,MAAM,IAAI,GAAI,iBAA6C,CAAC,IAAI,CAAC;YAEjE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACpD,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAA;AAtDY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,cAAK,EAAC,qCAA4B,CAAC;GACvB,kCAAkC,CAsD9C"}
|
package/dist/main.js
CHANGED
|
@@ -15,12 +15,7 @@ const core_1 = require("@nestjs/core");
|
|
|
15
15
|
const platform_fastify_1 = require("@nestjs/platform-fastify");
|
|
16
16
|
const app_constants_1 = require("./app.constants");
|
|
17
17
|
const app_module_1 = require("./app.module");
|
|
18
|
-
const
|
|
19
|
-
const global_error_filter_1 = require("./common/filters/global-error.filter");
|
|
20
|
-
const internal_server_error_exception_filter_1 = require("./common/filters/internal-server-error-exception.filter");
|
|
21
|
-
const not_found_exception_filter_1 = require("./common/filters/not-found-exception.filter");
|
|
22
|
-
const query_failed_exception_filter_1 = require("./common/filters/query-failed-exception.filter");
|
|
23
|
-
const unprocessable_entity_exception_filter_1 = require("./common/filters/unprocessable-entity-exception.filter");
|
|
18
|
+
const global_filters_1 = require("./common/filters/global-filters");
|
|
24
19
|
const app_instance_holder_service_1 = require("./common/services/app-instance-holder.service");
|
|
25
20
|
const config_utils_1 = require("./common/utils/config.utils");
|
|
26
21
|
const validation_exception_factory_1 = require("./common/validation/validation-exception-factory");
|
|
@@ -92,7 +87,7 @@ async function bootstrap() {
|
|
|
92
87
|
decorateReply: true,
|
|
93
88
|
});
|
|
94
89
|
}
|
|
95
|
-
app.useGlobalFilters(
|
|
90
|
+
app.useGlobalFilters(...(0, global_filters_1.createGlobalExceptionFilters)(configService));
|
|
96
91
|
app.useGlobalPipes(new common_1.ValidationPipe({
|
|
97
92
|
transform: true,
|
|
98
93
|
whitelist: true,
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;AAAA,qDAA+C;AAE/C,2BAAgC;AAChC,gDAAwB;AAExB,6DAAqC;AACrC,mEAAkD;AAClD,6DAA4C;AAC5C,2CAAgE;AAChE,2CAAoE;AACpE,uCAA2C;AAC3C,+DAAkF;AAElF,mDAA4F;AAC5F,6CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;AAAA,qDAA+C;AAE/C,2BAAgC;AAChC,gDAAwB;AAExB,6DAAqC;AACrC,mEAAkD;AAClD,6DAA4C;AAC5C,2CAAgE;AAChE,2CAAoE;AACpE,uCAA2C;AAC3C,+DAAkF;AAElF,mDAA4F;AAC5F,6CAAyC;AACzC,oEAA+E;AAC/E,+FAAkF;AAClF,8DAA0D;AAC1D,mGAA8F;AAC9F,4FAAuF;AACvF,yGAAmG;AACnG,+DAA8F;AAC9F,oGAA8F;AAC9F,uEAAmE;AACnE,2FAAsF;AACtF,wEAAyE;AACzE,qFAAiF;AAEjF,KAAK,UAAU,SAAS;IACvB,MAAM,UAAU,GAAG,MAAM,I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
1
|
import { PlatformType } from '../platform.constants';
|
|
2
|
+
export interface PrivilegedWorkerSupport {
|
|
3
|
+
supported: boolean;
|
|
4
|
+
reason: string | null;
|
|
5
|
+
checkedAt: string;
|
|
6
|
+
}
|
|
2
7
|
export declare class PlatformService {
|
|
3
8
|
private platform;
|
|
4
9
|
private platformType;
|
|
5
10
|
private readonly logger;
|
|
6
11
|
private readonly platformDetection;
|
|
7
|
-
private
|
|
12
|
+
private privilegedWorkerSupportCache;
|
|
13
|
+
private privilegedWorkerSupportCacheExpiresAt;
|
|
14
|
+
private privilegedWorkerSupportPromise;
|
|
8
15
|
constructor();
|
|
9
16
|
getPlatformType(): PlatformType;
|
|
10
17
|
getPlatformTypeAsync(): Promise<PlatformType>;
|
|
11
18
|
supportsPrivilegedWorkers(): Promise<boolean>;
|
|
12
|
-
|
|
19
|
+
getPrivilegedWorkerSupport(): Promise<PrivilegedWorkerSupport>;
|
|
20
|
+
isPlatformCapableOfPrivilegedWorkers(): boolean;
|
|
21
|
+
private getFreshPrivilegedWorkerSupportCache;
|
|
22
|
+
private probePrivilegedWorkerSupport;
|
|
13
23
|
getSystemInfo(): Promise<import("../dto/system-info.dto").SystemInfoDto>;
|
|
14
24
|
getThrottleStatus(): Promise<import("../dto/throttle-status.dto").ThrottleStatusDto>;
|
|
15
25
|
getTemperature(): Promise<import("../dto/temperature.dto").TemperatureDto>;
|
|
@@ -24,7 +34,6 @@ export declare class PlatformService {
|
|
|
24
34
|
private detectPlatform;
|
|
25
35
|
private autoDetectPlatform;
|
|
26
36
|
private isRaspberryPiHardware;
|
|
27
|
-
private
|
|
28
|
-
private probeSystemdRunAvailable;
|
|
37
|
+
private probeSystemdRunScope;
|
|
29
38
|
private createPlatform;
|
|
30
39
|
}
|
|
@@ -16,7 +16,6 @@ exports.PlatformService = void 0;
|
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const node_child_process_1 = require("node:child_process");
|
|
18
18
|
const systeminformation_1 = __importDefault(require("systeminformation"));
|
|
19
|
-
const util_1 = require("util");
|
|
20
19
|
const common_1 = require("@nestjs/common");
|
|
21
20
|
const logger_1 = require("../../../common/logger");
|
|
22
21
|
const platform_constants_1 = require("../platform.constants");
|
|
@@ -25,16 +24,19 @@ const docker_platform_1 = require("../platforms/docker.platform");
|
|
|
25
24
|
const generic_platform_1 = require("../platforms/generic.platform");
|
|
26
25
|
const home_assistant_platform_1 = require("../platforms/home-assistant.platform");
|
|
27
26
|
const raspberry_platform_1 = require("../platforms/raspberry.platform");
|
|
28
|
-
const execFileAsync = (0, util_1.promisify)(node_child_process_1.execFile);
|
|
29
27
|
const PRIVILEGED_WORKERS_UNSUPPORTED_PLATFORMS = new Set([
|
|
30
28
|
platform_constants_1.PlatformType.DOCKER,
|
|
31
29
|
platform_constants_1.PlatformType.HOME_ASSISTANT,
|
|
32
30
|
platform_constants_1.PlatformType.DEVELOPMENT,
|
|
33
31
|
]);
|
|
32
|
+
const PRIVILEGED_WORKER_SUPPORT_NEGATIVE_CACHE_TTL_MS = 60_000;
|
|
33
|
+
const PRIVILEGED_WORKER_PROBE_TIMEOUT_MS = 5_000;
|
|
34
34
|
let PlatformService = class PlatformService {
|
|
35
35
|
constructor() {
|
|
36
36
|
this.logger = (0, logger_1.createExtensionLogger)(platform_constants_1.PLATFORM_MODULE_NAME, 'PlatformService');
|
|
37
|
-
this.
|
|
37
|
+
this.privilegedWorkerSupportCache = null;
|
|
38
|
+
this.privilegedWorkerSupportCacheExpiresAt = null;
|
|
39
|
+
this.privilegedWorkerSupportPromise = null;
|
|
38
40
|
this.platformDetection = this.detectPlatform()
|
|
39
41
|
.then(({ platform, type }) => {
|
|
40
42
|
this.platform = platform;
|
|
@@ -58,21 +60,49 @@ let PlatformService = class PlatformService {
|
|
|
58
60
|
return this.platformType;
|
|
59
61
|
}
|
|
60
62
|
async supportsPrivilegedWorkers() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return this.privilegedWorkersSupportedPromise;
|
|
63
|
+
const { supported } = await this.getPrivilegedWorkerSupport();
|
|
64
|
+
return supported;
|
|
65
65
|
}
|
|
66
|
-
async
|
|
66
|
+
async getPrivilegedWorkerSupport() {
|
|
67
67
|
await this.platformDetection;
|
|
68
|
+
const cached = this.getFreshPrivilegedWorkerSupportCache();
|
|
69
|
+
if (cached) {
|
|
70
|
+
return cached;
|
|
71
|
+
}
|
|
72
|
+
if (this.privilegedWorkerSupportPromise === null) {
|
|
73
|
+
this.privilegedWorkerSupportPromise = this.probePrivilegedWorkerSupport().finally(() => {
|
|
74
|
+
this.privilegedWorkerSupportPromise = null;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const result = await this.privilegedWorkerSupportPromise;
|
|
78
|
+
this.privilegedWorkerSupportCache = result;
|
|
79
|
+
this.privilegedWorkerSupportCacheExpiresAt =
|
|
80
|
+
result.supported || PRIVILEGED_WORKERS_UNSUPPORTED_PLATFORMS.has(this.platformType)
|
|
81
|
+
? null
|
|
82
|
+
: Date.now() + PRIVILEGED_WORKER_SUPPORT_NEGATIVE_CACHE_TTL_MS;
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
isPlatformCapableOfPrivilegedWorkers() {
|
|
86
|
+
return !PRIVILEGED_WORKERS_UNSUPPORTED_PLATFORMS.has(this.platformType);
|
|
87
|
+
}
|
|
88
|
+
getFreshPrivilegedWorkerSupportCache() {
|
|
89
|
+
if (!this.privilegedWorkerSupportCache) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const fresh = this.privilegedWorkerSupportCacheExpiresAt === null || Date.now() < this.privilegedWorkerSupportCacheExpiresAt;
|
|
93
|
+
return fresh ? this.privilegedWorkerSupportCache : null;
|
|
94
|
+
}
|
|
95
|
+
async probePrivilegedWorkerSupport() {
|
|
96
|
+
const checkedAt = new Date().toISOString();
|
|
68
97
|
if (PRIVILEGED_WORKERS_UNSUPPORTED_PLATFORMS.has(this.platformType)) {
|
|
69
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
supported: false,
|
|
100
|
+
reason: `The '${this.platformType}' platform does not support privileged workers.`,
|
|
101
|
+
checkedAt,
|
|
102
|
+
};
|
|
70
103
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
this.probeSystemdRunAvailable(),
|
|
74
|
-
]);
|
|
75
|
-
return sudoAvailable && systemdRunAvailable;
|
|
104
|
+
const probe = await this.probeSystemdRunScope();
|
|
105
|
+
return { supported: probe.success, reason: probe.success ? null : probe.reason, checkedAt };
|
|
76
106
|
}
|
|
77
107
|
getSystemInfo() {
|
|
78
108
|
this.logger.debug('Fetching system information');
|
|
@@ -160,27 +190,19 @@ let PlatformService = class PlatformService {
|
|
|
160
190
|
}
|
|
161
191
|
return false;
|
|
162
192
|
}
|
|
163
|
-
async
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
await execFileAsync('which', ['systemd-run'], { timeout: 2000 });
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
const err = error;
|
|
181
|
-
this.logger.debug(`systemd-run availability probe failed, treating privileged workers as unsupported: ${err.message}`);
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
193
|
+
async probeSystemdRunScope() {
|
|
194
|
+
const unit = `smart-panel-privileged-probe-${process.pid}`;
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
(0, node_child_process_1.execFile)('sudo', ['-n', 'systemd-run', '--scope', '--quiet', `--unit=${unit}`, '/bin/true'], { timeout: PRIVILEGED_WORKER_PROBE_TIMEOUT_MS }, (error, _stdout, stderr) => {
|
|
197
|
+
if (!error) {
|
|
198
|
+
resolve({ success: true, reason: null });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const detail = (stderr ?? '').toString().trim() || error.message;
|
|
202
|
+
this.logger.debug(`Privileged-worker probe (systemd-run scope) failed: ${detail}`);
|
|
203
|
+
resolve({ success: false, reason: detail });
|
|
204
|
+
});
|
|
205
|
+
});
|
|
184
206
|
}
|
|
185
207
|
createPlatform(type) {
|
|
186
208
|
switch (type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.service.js","sourceRoot":"","sources":["../../../../src/modules/platform/services/platform.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2BAA8C;AAC9C,2DAA8C;AAC9C,0EAAmC;
|
|
1
|
+
{"version":3,"file":"platform.service.js","sourceRoot":"","sources":["../../../../src/modules/platform/services/platform.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2BAA8C;AAC9C,2DAA8C;AAC9C,0EAAmC;AAEnC,2CAA4C;AAE5C,mDAA+D;AAC/D,8DAA8F;AAE9F,4EAAwE;AACxE,kEAA8D;AAC9D,oEAAgE;AAChE,kFAA6E;AAC7E,wEAAoE;AAKpE,MAAM,wCAAwC,GAA8B,IAAI,GAAG,CAAC;IACnF,iCAAY,CAAC,MAAM;IACnB,iCAAY,CAAC,cAAc;IAC3B,iCAAY,CAAC,WAAW;CACxB,CAAC,CAAC;AAMH,MAAM,+CAA+C,GAAG,MAAM,CAAC;AAI/D,MAAM,kCAAkC,GAAG,KAAK,CAAC;AAgB1C,IAAM,eAAe,GAArB,MAAM,eAAe;IAsB3B;QAnBiB,WAAM,GAAG,IAAA,8BAAqB,EAAC,yCAAoB,EAAE,iBAAiB,CAAC,CAAC;QAWjF,iCAA4B,GAAmC,IAAI,CAAC;QACpE,0CAAqC,GAAkB,IAAI,CAAC;QAK5D,mCAA8B,GAA4C,IAAI,CAAC;QAGtF,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE;aAC5C,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;YAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAA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AC,OAAO,CAAC;gBAEjE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uDAAuD,MAAM,EAAE,CAAC,CAAC;gBAEnF,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7C,CAAC,CACD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,IAAkB;QACxC,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,iCAAY,CAAC,SAAS;gBAC1B,OAAO,IAAI,sCAAiB,EAAE,CAAC;YAChC,KAAK,iCAAY,CAAC,MAAM;gBACvB,OAAO,IAAI,gCAAc,EAAE,CAAC;YAC7B,KAAK,iCAAY,CAAC,WAAW;gBAC5B,OAAO,IAAI,0CAAmB,EAAE,CAAC;YAClC,KAAK,iCAAY,CAAC,cAAc;gBAC/B,OAAO,IAAI,+CAAqB,EAAE,CAAC;YACpC,KAAK,iCAAY,CAAC,OAAO,CAAC;YAC1B;gBACC,OAAO,IAAI,kCAAe,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC;CACD,CAAA;AA1VY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;;GACA,eAAe,CA0V3B"}
|
|
@@ -17,6 +17,9 @@ const config_dto_1 = require("../../config/dto/config.dto");
|
|
|
17
17
|
const remote_access_constants_1 = require("../remote-access.constants");
|
|
18
18
|
const is_remote_access_url_validator_1 = require("../validators/is-remote-access-url.validator");
|
|
19
19
|
const is_trusted_proxy_entry_validator_1 = require("../validators/is-trusted-proxy-entry.validator");
|
|
20
|
+
function normalizeRemoteAccessUrlField({ value }) {
|
|
21
|
+
return typeof value === 'string' ? ((0, is_remote_access_url_validator_1.normalizeRemoteAccessUrl)(value) ?? value) : value;
|
|
22
|
+
}
|
|
20
23
|
let UpdateRemoteAccessConfigDto = class UpdateRemoteAccessConfigDto extends config_dto_1.UpdateModuleConfigDto {
|
|
21
24
|
constructor() {
|
|
22
25
|
super(...arguments);
|
|
@@ -44,6 +47,7 @@ __decorate([
|
|
|
44
47
|
}),
|
|
45
48
|
(0, class_transformer_1.Expose)({ name: 'internal_url' }),
|
|
46
49
|
(0, class_validator_1.IsOptional)(),
|
|
50
|
+
(0, class_transformer_1.Transform)(normalizeRemoteAccessUrlField),
|
|
47
51
|
(0, class_validator_1.Validate)(is_remote_access_url_validator_1.IsRemoteAccessUrlConstraint, {
|
|
48
52
|
message: '[{"field":"internal_url","reason":"Internal URL must be a normalized absolute HTTP(S) origin without a path, query, fragment, or credentials."}]',
|
|
49
53
|
}),
|
|
@@ -60,6 +64,7 @@ __decorate([
|
|
|
60
64
|
}),
|
|
61
65
|
(0, class_transformer_1.Expose)({ name: 'external_url' }),
|
|
62
66
|
(0, class_validator_1.IsOptional)(),
|
|
67
|
+
(0, class_transformer_1.Transform)(normalizeRemoteAccessUrlField),
|
|
63
68
|
(0, class_validator_1.Validate)(is_remote_access_url_validator_1.IsRemoteAccessUrlConstraint, {
|
|
64
69
|
message: '[{"field":"external_url","reason":"External URL must be a normalized absolute HTTP(S) origin without a path, query, fragment, or credentials."}]',
|
|
65
70
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-config.dto.js","sourceRoot":"","sources":["../../../../src/modules/remote-access/dto/update-config.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"update-config.dto.js","sourceRoot":"","sources":["../../../../src/modules/remote-access/dto/update-config.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAsD;AACtD,qDAA8G;AAE9G,6CAA8E;AAE9E,4DAAoE;AACpE,wEAAuE;AACvE,iGAAqH;AACrH,qGAA+F;AAO/F,SAAS,6BAA6B,CAAC,EAAE,KAAK,EAAsB;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAA,yDAAwB,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC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AkJ;KACnJ,CAAC;IACD,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;;iEACZ;AAc7B;IAZC,IAAA,6BAAmB,EAAC;QACpB,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EACV,+HAA+H;QAChI,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;KACd,CAAC;IACD,IAAA,0BAAM,EAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC;IAC3C,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC;QACV,OAAO,EAAE,mGAAmG;KAC5G,CAAC;;4EACgC;AAkBlC;IAhBC,IAAA,6BAAmB,EAAC;QACpB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,kFAAkF;QAC/F,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,OAAO,EAAE,EAAE;KACX,CAAC;IACD,IAAA,0BAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IACnC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,EAAC,EAAE,OAAO,EAAE,wFAAwF,EAAE,CAAC;IAC9G,IAAA,6BAAW,EAAC,EAAE,OAAO,EAAE,uFAAuF,EAAE,CAAC;IACjH,IAAA,0BAAQ,EAAC,gEAA6B,EAAE;QACxC,IAAI,EAAE,IAAI;QACV,OAAO,EACN,8GAA8G;KAC/G,CAAC;;oEACyB;sCA3Ef,2BAA2B;IADvC,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC;GACzC,2BAA2B,CA4EvC"}
|
|
@@ -10,7 +10,11 @@ exports.IsRemoteAccessUrlConstraint = void 0;
|
|
|
10
10
|
exports.normalizeRemoteAccessUrl = normalizeRemoteAccessUrl;
|
|
11
11
|
const class_validator_1 = require("class-validator");
|
|
12
12
|
const common_1 = require("@nestjs/common");
|
|
13
|
+
const RAW_DOT_SEGMENT_PATTERN = /\/\.\.?(?:[/?#]|$)/;
|
|
13
14
|
function normalizeRemoteAccessUrl(value) {
|
|
15
|
+
if (RAW_DOT_SEGMENT_PATTERN.test(value)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
14
18
|
let url;
|
|
15
19
|
try {
|
|
16
20
|
url = new URL(value);
|
|
@@ -27,8 +31,7 @@ function normalizeRemoteAccessUrl(value) {
|
|
|
27
31
|
url.pathname !== '/') {
|
|
28
32
|
return null;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
return normalized === value ? normalized : null;
|
|
34
|
+
return url.origin;
|
|
32
35
|
}
|
|
33
36
|
let IsRemoteAccessUrlConstraint = class IsRemoteAccessUrlConstraint {
|
|
34
37
|
validate(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-remote-access-url.validator.js","sourceRoot":"","sources":["../../../../src/modules/remote-access/validators/is-remote-access-url.validator.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"is-remote-access-url.validator.js","sourceRoot":"","sources":["../../../../src/modules/remote-access/validators/is-remote-access-url.validator.ts"],"names":[],"mappings":";;;;;;;;;AAyBA,4DA0BC;AAnDD,qDAAyG;AAEzG,2CAA4C;AAqB5C,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAErD,SAAgB,wBAAwB,CAAC,KAAa;IACrD,IAAI,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,GAAQ,CAAC;IAEb,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IACC,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACvD,CAAC,GAAG,CAAC,QAAQ;QACb,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,MAAM;QACV,GAAG,CAAC,IAAI;QACR,GAAG,CAAC,QAAQ,KAAK,GAAG,EACnB,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC;AACnB,CAAC;AAIM,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACvC,QAAQ,CAAC,KAAc;QACtB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,wBAAwB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC9E,CAAC;IAED,cAAc,CAAC,KAA0B;QACxC,OAAO,yGAAyG,CAAC;IAClH,CAAC;CACD,CAAA;AARY,kEAA2B;sCAA3B,2BAA2B;IAFvC,IAAA,qCAAmB,EAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAChE,IAAA,mBAAU,GAAE;GACA,2BAA2B,CAQvC"}
|
|
@@ -7,12 +7,14 @@ export interface PrivilegedJobSpec {
|
|
|
7
7
|
statusFile: string;
|
|
8
8
|
timeoutMs?: number;
|
|
9
9
|
mapStatus?: (raw: Record<string, unknown>) => Partial<PrivilegedJobStatus> | null;
|
|
10
|
+
redact?: (line: string) => string;
|
|
10
11
|
}
|
|
11
12
|
export interface PrivilegedJobStatus {
|
|
12
13
|
id: string;
|
|
13
14
|
state: 'running' | 'complete' | 'failed' | 'timeout';
|
|
14
15
|
step?: string;
|
|
15
16
|
message?: string;
|
|
17
|
+
stderr?: string;
|
|
16
18
|
updatedAt: string;
|
|
17
19
|
}
|
|
18
20
|
type StatusHandler = (status: PrivilegedJobStatus) => void;
|
|
@@ -27,9 +29,17 @@ export declare class PrivilegedWorkerService {
|
|
|
27
29
|
}>;
|
|
28
30
|
getStatus(id: string): PrivilegedJobStatus | null;
|
|
29
31
|
onStatus(id: string, handler: StatusHandler): () => void;
|
|
32
|
+
private getCapturedStderr;
|
|
33
|
+
private buildFailureMessage;
|
|
34
|
+
private buildGenericFailureMessage;
|
|
30
35
|
private startPolling;
|
|
36
|
+
private stopUnit;
|
|
37
|
+
private isUnitActive;
|
|
38
|
+
private handleTimeout;
|
|
31
39
|
private logInvalidStatusOnce;
|
|
32
40
|
private finishJob;
|
|
41
|
+
private notifyHandlers;
|
|
33
42
|
private stopPolling;
|
|
43
|
+
private schedulePrune;
|
|
34
44
|
}
|
|
35
45
|
export {};
|