@alwaysai/device-agent 1.4.0 → 2.0.0
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/application-control/config.d.ts.map +1 -1
- package/lib/application-control/config.js +10 -5
- package/lib/application-control/config.js.map +1 -1
- package/lib/application-control/environment-variables.d.ts +1 -5
- package/lib/application-control/environment-variables.d.ts.map +1 -1
- package/lib/application-control/environment-variables.js +9 -26
- package/lib/application-control/environment-variables.js.map +1 -1
- package/lib/application-control/environment-variables.test.js +27 -7
- package/lib/application-control/environment-variables.test.js.map +1 -1
- package/lib/application-control/index.d.ts +4 -4
- package/lib/application-control/index.d.ts.map +1 -1
- package/lib/application-control/index.js +1 -4
- package/lib/application-control/index.js.map +1 -1
- package/lib/application-control/install.d.ts.map +1 -1
- package/lib/application-control/install.js +9 -7
- package/lib/application-control/install.js.map +1 -1
- package/lib/application-control/models.d.ts +5 -11
- package/lib/application-control/models.d.ts.map +1 -1
- package/lib/application-control/models.js +27 -64
- package/lib/application-control/models.js.map +1 -1
- package/lib/application-control/status.d.ts.map +1 -1
- package/lib/application-control/status.js +10 -12
- package/lib/application-control/status.js.map +1 -1
- package/lib/application-control/utils.d.ts +0 -4
- package/lib/application-control/utils.d.ts.map +1 -1
- package/lib/application-control/utils.js +3 -26
- package/lib/application-control/utils.js.map +1 -1
- package/lib/cloud-connection/bootstrap-provision.js +3 -2
- package/lib/cloud-connection/bootstrap-provision.js.map +1 -1
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts +11 -16
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
- package/lib/cloud-connection/device-agent-cloud-connection.js +295 -246
- package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
- package/lib/cloud-connection/device-agent.d.ts.map +1 -1
- package/lib/cloud-connection/device-agent.js +11 -9
- package/lib/cloud-connection/device-agent.js.map +1 -1
- package/lib/cloud-connection/live-updates-handler.d.ts +18 -27
- package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -1
- package/lib/cloud-connection/live-updates-handler.js +58 -170
- package/lib/cloud-connection/live-updates-handler.js.map +1 -1
- package/lib/cloud-connection/live-updates-handler.test.js +76 -54
- package/lib/cloud-connection/live-updates-handler.test.js.map +1 -1
- package/lib/cloud-connection/passthrough-handler.d.ts +9 -4
- package/lib/cloud-connection/passthrough-handler.d.ts.map +1 -1
- package/lib/cloud-connection/passthrough-handler.js +95 -62
- package/lib/cloud-connection/passthrough-handler.js.map +1 -1
- package/lib/cloud-connection/shadow-handler.d.ts +5 -1
- package/lib/cloud-connection/shadow-handler.d.ts.map +1 -1
- package/lib/cloud-connection/shadow-handler.js +63 -31
- package/lib/cloud-connection/shadow-handler.js.map +1 -1
- package/lib/cloud-connection/shadow-handler.test.js +45 -57
- package/lib/cloud-connection/shadow-handler.test.js.map +1 -1
- package/lib/cloud-connection/shadow.d.ts.map +1 -1
- package/lib/cloud-connection/shadow.js +2 -1
- package/lib/cloud-connection/shadow.js.map +1 -1
- package/lib/cloud-connection/transaction-manager.d.ts +7 -2
- package/lib/cloud-connection/transaction-manager.d.ts.map +1 -1
- package/lib/cloud-connection/transaction-manager.js +29 -29
- package/lib/cloud-connection/transaction-manager.js.map +1 -1
- package/lib/cloud-connection/transaction-manager.test.js +105 -3
- package/lib/cloud-connection/transaction-manager.test.js.map +1 -1
- package/lib/device-control/device-control.d.ts +14 -6
- package/lib/device-control/device-control.d.ts.map +1 -1
- package/lib/device-control/device-control.js +172 -72
- package/lib/device-control/device-control.js.map +1 -1
- package/lib/docker/docker-compose.d.ts +14 -0
- package/lib/docker/docker-compose.d.ts.map +1 -0
- package/lib/docker/docker-compose.js +57 -0
- package/lib/docker/docker-compose.js.map +1 -0
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/infrastructure/agent-config.d.ts +46 -14
- package/lib/infrastructure/agent-config.d.ts.map +1 -1
- package/lib/infrastructure/agent-config.js +36 -21
- package/lib/infrastructure/agent-config.js.map +1 -1
- package/lib/infrastructure/agent-config.test.js +6 -1
- package/lib/infrastructure/agent-config.test.js.map +1 -1
- package/lib/infrastructure/config-check-utility.d.ts +6 -0
- package/lib/infrastructure/config-check-utility.d.ts.map +1 -0
- package/lib/infrastructure/config-check-utility.js +67 -0
- package/lib/infrastructure/config-check-utility.js.map +1 -0
- package/lib/infrastructure/config-check-utility.test.d.ts +2 -0
- package/lib/infrastructure/config-check-utility.test.d.ts.map +1 -0
- package/lib/infrastructure/config-check-utility.test.js +109 -0
- package/lib/infrastructure/config-check-utility.test.js.map +1 -0
- package/lib/infrastructure/device-certificate.d.ts +10 -0
- package/lib/infrastructure/device-certificate.d.ts.map +1 -0
- package/lib/infrastructure/device-certificate.js +47 -0
- package/lib/infrastructure/device-certificate.js.map +1 -0
- package/lib/infrastructure/device-certificate.test.d.ts +2 -0
- package/lib/infrastructure/device-certificate.test.d.ts.map +1 -0
- package/lib/infrastructure/device-certificate.test.js +24 -0
- package/lib/infrastructure/device-certificate.test.js.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts +2 -0
- package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-file.test.js +61 -0
- package/lib/infrastructure/legacy-migration/legacy-file.test.js.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-files.d.ts +75 -0
- package/lib/infrastructure/legacy-migration/legacy-files.d.ts.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-files.js +75 -0
- package/lib/infrastructure/legacy-migration/legacy-files.js.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.d.ts +6 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.d.ts.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.js +149 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.js.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts +2 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts.map +1 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.test.js +226 -0
- package/lib/infrastructure/legacy-migration/legacy-migration.test.js.map +1 -0
- package/lib/infrastructure/require-files-present-ready.test.d.ts +2 -0
- package/lib/infrastructure/require-files-present-ready.test.d.ts.map +1 -0
- package/lib/infrastructure/require-files-present-ready.test.js +44 -0
- package/lib/infrastructure/require-files-present-ready.test.js.map +1 -0
- package/lib/infrastructure/required-config-checks.d.ts +2 -0
- package/lib/infrastructure/required-config-checks.d.ts.map +1 -0
- package/lib/infrastructure/required-config-checks.js +30 -0
- package/lib/infrastructure/required-config-checks.js.map +1 -0
- package/lib/infrastructure/tokens-and-device-cfg.d.ts.map +1 -1
- package/lib/infrastructure/tokens-and-device-cfg.js +11 -8
- package/lib/infrastructure/tokens-and-device-cfg.js.map +1 -1
- package/lib/local-connection/rabbitmq-connection.d.ts.map +1 -1
- package/lib/local-connection/rabbitmq-connection.js +21 -21
- package/lib/local-connection/rabbitmq-connection.js.map +1 -1
- package/lib/secure-tunneling/secure-tunneling.d.ts +15 -23
- package/lib/secure-tunneling/secure-tunneling.d.ts.map +1 -1
- package/lib/secure-tunneling/secure-tunneling.js +52 -47
- package/lib/secure-tunneling/secure-tunneling.js.map +1 -1
- package/lib/secure-tunneling/secure-tunneling.test.js +29 -31
- package/lib/secure-tunneling/secure-tunneling.test.js.map +1 -1
- package/lib/subcommands/app/analytics.d.ts.map +1 -1
- package/lib/subcommands/app/analytics.js +1 -2
- package/lib/subcommands/app/analytics.js.map +1 -1
- package/lib/subcommands/app/env-vars.d.ts +4 -0
- package/lib/subcommands/app/env-vars.d.ts.map +1 -1
- package/lib/subcommands/app/env-vars.js +52 -6
- package/lib/subcommands/app/env-vars.js.map +1 -1
- package/lib/subcommands/app/index.d.ts.map +1 -1
- package/lib/subcommands/app/index.js +1 -3
- package/lib/subcommands/app/index.js.map +1 -1
- package/lib/subcommands/app/models.d.ts +0 -11
- package/lib/subcommands/app/models.d.ts.map +1 -1
- package/lib/subcommands/app/models.js +2 -58
- package/lib/subcommands/app/models.js.map +1 -1
- package/lib/subcommands/app/shadow.d.ts.map +1 -1
- package/lib/subcommands/app/shadow.js +6 -5
- package/lib/subcommands/app/shadow.js.map +1 -1
- package/lib/subcommands/app/version.d.ts.map +1 -1
- package/lib/subcommands/app/version.js +2 -4
- package/lib/subcommands/app/version.js.map +1 -1
- package/lib/subcommands/config.d.ts +2 -0
- package/lib/subcommands/config.d.ts.map +1 -0
- package/lib/subcommands/config.js +39 -0
- package/lib/subcommands/config.js.map +1 -0
- package/lib/subcommands/device/clean.d.ts +1 -1
- package/lib/subcommands/device/clean.d.ts.map +1 -1
- package/lib/subcommands/device/clean.js +25 -15
- package/lib/subcommands/device/clean.js.map +1 -1
- package/lib/subcommands/device/get-info.d.ts +2 -0
- package/lib/subcommands/device/get-info.d.ts.map +1 -0
- package/lib/subcommands/device/get-info.js +36 -0
- package/lib/subcommands/device/get-info.js.map +1 -0
- package/lib/subcommands/device/index.d.ts.map +1 -1
- package/lib/subcommands/device/index.js +13 -2
- package/lib/subcommands/device/index.js.map +1 -1
- package/lib/subcommands/device/init.d.ts +5 -0
- package/lib/subcommands/device/init.d.ts.map +1 -0
- package/lib/subcommands/device/{device.js → init.js} +10 -49
- package/lib/subcommands/device/init.js.map +1 -0
- package/lib/subcommands/device/migrate.d.ts +2 -0
- package/lib/subcommands/device/migrate.d.ts.map +1 -0
- package/lib/subcommands/device/migrate.js +24 -0
- package/lib/subcommands/device/migrate.js.map +1 -0
- package/lib/subcommands/device/refresh.d.ts +2 -0
- package/lib/subcommands/device/refresh.d.ts.map +1 -0
- package/lib/subcommands/device/refresh.js +25 -0
- package/lib/subcommands/device/refresh.js.map +1 -0
- package/lib/subcommands/device/restart.d.ts +2 -0
- package/lib/subcommands/device/restart.d.ts.map +1 -0
- package/lib/subcommands/device/restart.js +14 -0
- package/lib/subcommands/device/restart.js.map +1 -0
- package/lib/subcommands/index.d.ts +1 -1
- package/lib/subcommands/index.d.ts.map +1 -1
- package/lib/subcommands/index.js +3 -1
- package/lib/subcommands/index.js.map +1 -1
- package/lib/subcommands/rabbitmq-connection.d.ts +1 -1
- package/lib/subcommands/rabbitmq-connection.d.ts.map +1 -1
- package/lib/util/aai-error.d.ts +12 -0
- package/lib/util/aai-error.d.ts.map +1 -0
- package/lib/util/aai-error.js +11 -0
- package/lib/util/aai-error.js.map +1 -0
- package/lib/util/aws-regions.d.ts +2 -0
- package/lib/util/aws-regions.d.ts.map +1 -0
- package/lib/util/{cloud-mode-ready.js → aws-regions.js} +2 -20
- package/lib/util/aws-regions.js.map +1 -0
- package/lib/util/check-for-updates.d.ts +3 -0
- package/lib/util/check-for-updates.d.ts.map +1 -0
- package/lib/util/check-for-updates.js +46 -0
- package/lib/util/check-for-updates.js.map +1 -0
- package/lib/util/clean-certs.d.ts.map +1 -1
- package/lib/util/clean-certs.js +5 -4
- package/lib/util/clean-certs.js.map +1 -1
- package/lib/util/directories.d.ts +4 -18
- package/lib/util/directories.d.ts.map +1 -1
- package/lib/util/directories.js +18 -32
- package/lib/util/directories.js.map +1 -1
- package/lib/util/file.d.ts +11 -0
- package/lib/util/file.d.ts.map +1 -0
- package/lib/util/file.js +127 -0
- package/lib/util/file.js.map +1 -0
- package/lib/util/file.test.d.ts +2 -0
- package/lib/util/file.test.d.ts.map +1 -0
- package/lib/util/file.test.js +87 -0
- package/lib/util/file.test.js.map +1 -0
- package/lib/util/get-device-id.d.ts.map +1 -1
- package/lib/util/get-device-id.js +7 -1
- package/lib/util/get-device-id.js.map +1 -1
- package/lib/util/http-client.js +3 -3
- package/lib/util/http-client.js.map +1 -1
- package/package.json +22 -19
- package/readme.md +15 -35
- package/src/application-control/config.ts +10 -13
- package/src/application-control/environment-variables.test.ts +28 -7
- package/src/application-control/environment-variables.ts +13 -40
- package/src/application-control/index.ts +3 -16
- package/src/application-control/install.ts +16 -10
- package/src/application-control/models.ts +40 -98
- package/src/application-control/status.ts +9 -7
- package/src/application-control/utils.ts +1 -29
- package/src/cloud-connection/bootstrap-provision.ts +7 -7
- package/src/cloud-connection/device-agent-cloud-connection.ts +647 -509
- package/src/cloud-connection/device-agent.ts +16 -7
- package/src/cloud-connection/live-updates-handler.test.ts +137 -64
- package/src/cloud-connection/live-updates-handler.ts +103 -234
- package/src/cloud-connection/passthrough-handler.ts +134 -75
- package/src/cloud-connection/shadow-handler.test.ts +45 -57
- package/src/cloud-connection/shadow-handler.ts +114 -56
- package/src/cloud-connection/shadow.ts +4 -1
- package/src/cloud-connection/transaction-manager.test.ts +127 -3
- package/src/cloud-connection/transaction-manager.ts +68 -39
- package/src/device-control/device-control.ts +179 -72
- package/src/docker/docker-compose.ts +61 -0
- package/src/index.ts +2 -6
- package/src/infrastructure/agent-config.test.ts +9 -2
- package/src/infrastructure/agent-config.ts +45 -46
- package/src/infrastructure/config-check-utility.test.ts +154 -0
- package/src/infrastructure/config-check-utility.ts +77 -0
- package/src/infrastructure/device-certificate.test.ts +40 -0
- package/src/infrastructure/device-certificate.ts +58 -0
- package/src/infrastructure/legacy-migration/legacy-file.test.ts +88 -0
- package/src/infrastructure/legacy-migration/legacy-files.ts +101 -0
- package/src/infrastructure/legacy-migration/legacy-migration.test.ts +396 -0
- package/src/infrastructure/legacy-migration/legacy-migration.ts +229 -0
- package/src/infrastructure/require-files-present-ready.test.ts +53 -0
- package/src/infrastructure/required-config-checks.ts +33 -0
- package/src/infrastructure/tokens-and-device-cfg.ts +12 -10
- package/src/local-connection/rabbitmq-connection.ts +28 -23
- package/src/secure-tunneling/secure-tunneling.test.ts +37 -39
- package/src/secure-tunneling/secure-tunneling.ts +74 -69
- package/src/subcommands/app/analytics.ts +2 -4
- package/src/subcommands/app/env-vars.ts +72 -9
- package/src/subcommands/app/index.ts +3 -11
- package/src/subcommands/app/models.ts +5 -81
- package/src/subcommands/app/shadow.ts +6 -5
- package/src/subcommands/app/version.ts +3 -4
- package/src/subcommands/config.ts +42 -0
- package/src/subcommands/device/clean.ts +32 -18
- package/src/subcommands/device/get-info.ts +49 -0
- package/src/subcommands/device/index.ts +13 -2
- package/src/subcommands/device/{device.ts → init.ts} +11 -69
- package/src/subcommands/device/migrate.ts +20 -0
- package/src/subcommands/device/refresh.ts +23 -0
- package/src/subcommands/device/restart.ts +11 -0
- package/src/subcommands/index.ts +3 -1
- package/src/util/aai-error.ts +20 -0
- package/src/util/{cloud-mode-ready.ts → aws-regions.ts} +0 -24
- package/src/util/check-for-updates.ts +53 -0
- package/src/util/clean-certs.ts +8 -4
- package/src/util/directories.ts +23 -67
- package/src/util/file.test.ts +90 -0
- package/src/util/file.ts +156 -0
- package/src/util/get-device-id.ts +7 -7
- package/src/util/http-client.ts +2 -2
- package/lib/docker/docker-compose-cmd.d.ts +0 -5
- package/lib/docker/docker-compose-cmd.d.ts.map +0 -1
- package/lib/docker/docker-compose-cmd.js +0 -16
- package/lib/docker/docker-compose-cmd.js.map +0 -1
- package/lib/subcommands/device/device.d.ts +0 -7
- package/lib/subcommands/device/device.d.ts.map +0 -1
- package/lib/subcommands/device/device.js.map +0 -1
- package/lib/util/cloud-mode-ready.d.ts +0 -3
- package/lib/util/cloud-mode-ready.d.ts.map +0 -1
- package/lib/util/cloud-mode-ready.js.map +0 -1
- package/lib/util/download-file.d.ts +0 -6
- package/lib/util/download-file.d.ts.map +0 -1
- package/lib/util/download-file.js +0 -25
- package/lib/util/download-file.js.map +0 -1
- package/lib/util/fetch-with-timeout.d.ts +0 -4
- package/lib/util/fetch-with-timeout.d.ts.map +0 -1
- package/lib/util/fetch-with-timeout.js +0 -30
- package/lib/util/fetch-with-timeout.js.map +0 -1
- package/lib/util/parsing.d.ts +0 -2
- package/lib/util/parsing.d.ts.map +0 -1
- package/lib/util/parsing.js +0 -17
- package/lib/util/parsing.js.map +0 -1
- package/lib/util/safe-rimraf.d.ts +0 -2
- package/lib/util/safe-rimraf.d.ts.map +0 -1
- package/lib/util/safe-rimraf.js +0 -16
- package/lib/util/safe-rimraf.js.map +0 -1
- package/src/docker/docker-compose-cmd.ts +0 -15
- package/src/util/download-file.ts +0 -25
- package/src/util/fetch-with-timeout.ts +0 -35
- package/src/util/parsing.ts +0 -11
- package/src/util/safe-rimraf.ts +0 -14
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_check_utility_1 = require("./config-check-utility");
|
|
4
|
+
const required_config_checks_1 = require("./required-config-checks");
|
|
5
|
+
const mockedDeviceCfgCheckFunction = jest.fn();
|
|
6
|
+
const mockedCertCheckFunction = jest.fn();
|
|
7
|
+
const mockedAaiCfgCheckFunction = jest.fn();
|
|
8
|
+
jest.mock('./config-check-utility');
|
|
9
|
+
jest
|
|
10
|
+
.mocked(config_check_utility_1.checkAaiConfigPresent)
|
|
11
|
+
.mockImplementation(mockedAaiCfgCheckFunction);
|
|
12
|
+
jest
|
|
13
|
+
.mocked(config_check_utility_1.checkDeviceConfigPresent)
|
|
14
|
+
.mockImplementation(mockedDeviceCfgCheckFunction);
|
|
15
|
+
jest
|
|
16
|
+
.mocked(config_check_utility_1.checkCertificatesPresent)
|
|
17
|
+
.mockImplementation(mockedCertCheckFunction);
|
|
18
|
+
describe('test requiredConfigFilesPresentAndValid', () => {
|
|
19
|
+
function setupMocks(mockDeviceCfgCheck, mockCertCheck, mockAaiCfgCheck) {
|
|
20
|
+
mockedDeviceCfgCheckFunction.mockResolvedValue(mockDeviceCfgCheck);
|
|
21
|
+
mockedCertCheckFunction.mockResolvedValue(mockCertCheck);
|
|
22
|
+
mockedAaiCfgCheckFunction.mockResolvedValue(mockAaiCfgCheck);
|
|
23
|
+
}
|
|
24
|
+
it('test return value when checkDeviceConfigPresent is false', async () => {
|
|
25
|
+
setupMocks(false, true, true);
|
|
26
|
+
const newConfigsPresent = await (0, required_config_checks_1.requiredConfigFilesPresentAndValid)();
|
|
27
|
+
expect(newConfigsPresent).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it('test return value when checkCertificatesPresent is false', async () => {
|
|
30
|
+
setupMocks(true, false, false);
|
|
31
|
+
const newConfigsPresent = await (0, required_config_checks_1.requiredConfigFilesPresentAndValid)();
|
|
32
|
+
expect(newConfigsPresent).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
it('test return value when checkAaiConfigPresent is false', async () => {
|
|
35
|
+
setupMocks(true, true, false);
|
|
36
|
+
const newConfigsPresent = await (0, required_config_checks_1.requiredConfigFilesPresentAndValid)();
|
|
37
|
+
expect(newConfigsPresent).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
it('test return value when all included functions return true', async () => {
|
|
40
|
+
setupMocks(true, true, true);
|
|
41
|
+
expect(await (0, required_config_checks_1.requiredConfigFilesPresentAndValid)()).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=require-files-present-ready.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-files-present-ready.test.js","sourceRoot":"","sources":["../../src/infrastructure/require-files-present-ready.test.ts"],"names":[],"mappings":";;AAAA,iEAIgC;AAChC,qEAA8E;AAE9E,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAC/C,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAC1C,MAAM,yBAAyB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE5C,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAEpC,IAAI;KACD,MAAM,CAAC,4CAAqB,CAAC;KAC7B,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;AACjD,IAAI;KACD,MAAM,CAAC,+CAAwB,CAAC;KAChC,kBAAkB,CAAC,4BAA4B,CAAC,CAAC;AACpD,IAAI;KACD,MAAM,CAAC,+CAAwB,CAAC;KAChC,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;AAE/C,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACvD,SAAS,UAAU,CAAC,kBAAkB,EAAE,aAAa,EAAE,eAAe;QACpE,4BAA4B,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;QACnE,uBAAuB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACzD,yBAAyB,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC/D,CAAC;IAED,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACxE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9B,MAAM,iBAAiB,GAAG,MAAM,IAAA,2DAAkC,GAAE,CAAC;QACrE,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACxE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/B,MAAM,iBAAiB,GAAG,MAAM,IAAA,2DAAkC,GAAE,CAAC;QACrE,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9B,MAAM,iBAAiB,GAAG,MAAM,IAAA,2DAAkC,GAAE,CAAC;QACrE,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QACzE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,IAAA,2DAAkC,GAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-config-checks.d.ts","sourceRoot":"","sources":["../../src/infrastructure/required-config-checks.ts"],"names":[],"mappings":"AAOA,wBAAsB,kCAAkC,CAAC,OAAO,CAAC,KAAA,oBAyBhE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requiredConfigFilesPresentAndValid = void 0;
|
|
4
|
+
const logger_1 = require("../util/logger");
|
|
5
|
+
const config_check_utility_1 = require("./config-check-utility");
|
|
6
|
+
async function requiredConfigFilesPresentAndValid(baseDir) {
|
|
7
|
+
// we need device/certificates, alwaysai.config.json, and device/alwaysai.device.json
|
|
8
|
+
logger_1.logger.debug('Checking for required configuration files.');
|
|
9
|
+
const newDeviceConfigPresent = await (0, config_check_utility_1.checkDeviceConfigPresent)(baseDir);
|
|
10
|
+
if (!newDeviceConfigPresent) {
|
|
11
|
+
logger_1.logger.debug('Required device configuration is not present and valid.');
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// check new certificates are present
|
|
15
|
+
const certificatesPresent = await (0, config_check_utility_1.checkCertificatesPresent)(baseDir);
|
|
16
|
+
if (!certificatesPresent) {
|
|
17
|
+
logger_1.logger.debug('Required certificates paths not found.');
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// TODO: add alwaysai.config.json check here
|
|
21
|
+
const aaiConfigPresent = await (0, config_check_utility_1.checkAaiConfigPresent)(baseDir);
|
|
22
|
+
if (!aaiConfigPresent) {
|
|
23
|
+
logger_1.logger.debug('Required aai configuration file is not present and valid.');
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
logger_1.logger.debug('All configuration files appear to be present.');
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
exports.requiredConfigFilesPresentAndValid = requiredConfigFilesPresentAndValid;
|
|
30
|
+
//# sourceMappingURL=required-config-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-config-checks.js","sourceRoot":"","sources":["../../src/infrastructure/required-config-checks.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,iEAIgC;AAEzB,KAAK,UAAU,kCAAkC,CAAC,OAAQ;IAC/D,qFAAqF;IACrF,eAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC3D,MAAM,sBAAsB,GAAG,MAAM,IAAA,+CAAwB,EAAC,OAAO,CAAC,CAAC;IACvE,IAAI,CAAC,sBAAsB,EAAE;QAC3B,eAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC;KACd;IAED,qCAAqC;IACrC,MAAM,mBAAmB,GAAG,MAAM,IAAA,+CAAwB,EAAC,OAAO,CAAC,CAAC;IACpE,IAAI,CAAC,mBAAmB,EAAE;QACxB,eAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC;KACd;IAED,4CAA4C;IAC5C,MAAM,gBAAgB,GAAG,MAAM,IAAA,4CAAqB,EAAC,OAAO,CAAC,CAAC;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACrB,eAAM,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC1E,OAAO,KAAK,CAAC;KACd;IAED,eAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC;AAzBD,gFAyBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens-and-device-cfg.d.ts","sourceRoot":"","sources":["../../src/infrastructure/tokens-and-device-cfg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokens-and-device-cfg.d.ts","sourceRoot":"","sources":["../../src/infrastructure/tokens-and-device-cfg.ts"],"names":[],"mappings":"AAaA,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,iBAsBzE"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeTokenAndDeviceCfg = void 0;
|
|
4
|
-
const logger_1 = require("../util/logger");
|
|
5
|
-
const http_client_1 = require("../util/http-client");
|
|
6
|
-
const require_logged_in_and_paid_plan_1 = require("../util/require-logged-in-and-paid-plan");
|
|
7
4
|
const device_1 = require("alwaysai/lib/core/device");
|
|
8
|
-
const
|
|
5
|
+
const infrastructure_1 = require("alwaysai/lib/infrastructure");
|
|
9
6
|
const paths_1 = require("alwaysai/lib/paths");
|
|
7
|
+
const util_1 = require("alwaysai/lib/util");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const http_client_1 = require("../util/http-client");
|
|
10
|
+
const logger_1 = require("../util/logger");
|
|
11
|
+
const require_logged_in_and_paid_plan_1 = require("../util/require-logged-in-and-paid-plan");
|
|
10
12
|
// NOTE: This closely follows the flow of deviceCheckAndUpdateComponent in the CLI
|
|
11
13
|
async function writeTokenAndDeviceCfg(props) {
|
|
12
14
|
const { deviceUuid } = props;
|
|
13
15
|
await (0, require_logged_in_and_paid_plan_1.requireLoggedInAndPaidPlan)();
|
|
14
16
|
const { accessToken, refreshToken, idToken } = await (0, http_client_1.microServiceHttpClient)('token-service', 'create-device-tokens', 'POST', JSON.stringify({}));
|
|
15
17
|
const tokens = {
|
|
16
|
-
|
|
18
|
+
deviceUuid,
|
|
17
19
|
accessToken,
|
|
18
20
|
refreshToken,
|
|
19
21
|
idToken
|
|
20
22
|
};
|
|
21
|
-
const tokenSpawner = (0, util_1.JsSpawner)({
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const tokenSpawner = (0, util_1.JsSpawner)({
|
|
24
|
+
path: (0, path_1.join)(paths_1.LOCAL_AAI_CFG_DIR, (0, infrastructure_1.getDeviceConfigPath)())
|
|
25
|
+
});
|
|
26
|
+
await (0, device_1.writeOrValidateDeviceCfgFile)(Object.assign({ spawner: tokenSpawner }, tokens));
|
|
24
27
|
logger_1.logger.info('Updated tokens and certificate');
|
|
25
28
|
}
|
|
26
29
|
exports.writeTokenAndDeviceCfg = writeTokenAndDeviceCfg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens-and-device-cfg.js","sourceRoot":"","sources":["../../src/infrastructure/tokens-and-device-cfg.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"tokens-and-device-cfg.js","sourceRoot":"","sources":["../../src/infrastructure/tokens-and-device-cfg.ts"],"names":[],"mappings":";;;AAAA,qDAGkC;AAClC,gEAAkE;AAClE,8CAAuD;AACvD,4CAA8C;AAC9C,+BAA4B;AAC5B,qDAA6D;AAC7D,2CAAwC;AACxC,6FAAqF;AAErF,kFAAkF;AAC3E,KAAK,UAAU,sBAAsB,CAAC,KAA6B;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC7B,MAAM,IAAA,4DAA0B,GAAE,CAAC;IACnC,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,oCAAsB,EACzE,eAAe,EACf,sBAAsB,EACtB,MAAM,EACN,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CACnB,CAAC;IAEF,MAAM,MAAM,GAAiB;QAC3B,UAAU;QACV,WAAW;QACX,YAAY;QACZ,OAAO;KACR,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,gBAAS,EAAC;QAC7B,IAAI,EAAE,IAAA,WAAI,EAAC,yBAAiB,EAAE,IAAA,oCAAmB,GAAE,CAAC;KACrD,CAAC,CAAC;IACH,MAAM,IAAA,qCAA4B,kBAAG,OAAO,EAAE,YAAY,IAAK,MAAM,EAAG,CAAC;IAEzE,eAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC;AAtBD,wDAsBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbitmq-connection.d.ts","sourceRoot":"","sources":["../../src/local-connection/rabbitmq-connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rabbitmq-connection.d.ts","sourceRoot":"","sources":["../../src/local-connection/rabbitmq-connection.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE,wBAAsB,6BAA6B,qBAwBlD;AAED,wBAAsB,8BAA8B,kBAgCnD;AAED,wBAAsB,sBAAsB,kBA+B3C;AAED,wBAAsB,qBAAqB,kBAgB1C"}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stopRabbitMQContainer = exports.setupRabbitMQContainer = exports.writeRabbitMQDockerComposeFile = exports.checkRabbitMQContainerRunning = exports.rabbitMQContainerName = exports.rabbitMQServiceName = void 0;
|
|
4
|
-
const
|
|
5
|
-
const sleep_1 = require("../util/sleep");
|
|
6
|
-
const docker_compose_1 = require("docker-compose");
|
|
4
|
+
const util_1 = require("alwaysai/lib/util");
|
|
7
5
|
const YAML = require("yaml");
|
|
6
|
+
const docker_compose_1 = require("../docker/docker-compose");
|
|
8
7
|
const directories_1 = require("../util/directories");
|
|
9
|
-
const
|
|
8
|
+
const logger_1 = require("../util/logger");
|
|
9
|
+
const sleep_1 = require("../util/sleep");
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
11
|
exports.rabbitMQServiceName = 'alwaysAIRabbitMQ';
|
|
12
12
|
exports.rabbitMQContainerName = 'alwaysAIRabbitMQContainer';
|
|
13
13
|
async function checkRabbitMQContainerRunning() {
|
|
14
14
|
logger_1.logger.debug('Checking alwaysAI Local Connection Container status');
|
|
15
15
|
const spawner = (0, util_1.JsSpawner)();
|
|
16
|
-
if (!(await spawner.exists(directories_1.
|
|
16
|
+
if (!(await spawner.exists((0, directories_1.getDeviceAgentDockerComposePath)()))) {
|
|
17
17
|
logger_1.logger.warn('alwaysAI Location Connection configuration file is not present');
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
const containerData = await docker_compose_1.
|
|
21
|
-
if (
|
|
20
|
+
const containerData = await docker_compose_1.compose.ps({ cwd: (0, directories_1.getDeviceAgentConfigPath)() });
|
|
21
|
+
if (containerData !== undefined) {
|
|
22
22
|
const rabbitmqService = containerData.data.services[0];
|
|
23
|
-
if (rabbitmqService.name === exports.rabbitMQContainerName &&
|
|
24
|
-
rabbitmqService.state
|
|
25
|
-
logger_1.logger.debug('alwaysAI Local Connection is
|
|
23
|
+
if ((rabbitmqService === null || rabbitmqService === void 0 ? void 0 : rabbitmqService.name) === exports.rabbitMQContainerName &&
|
|
24
|
+
rabbitmqService.state.includes('Up')) {
|
|
25
|
+
logger_1.logger.debug('alwaysAI Local Connection Container is up');
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
|
-
logger_1.logger.debug('alwaysAI Local Connection is not
|
|
28
|
+
logger_1.logger.debug('alwaysAI Local Connection Container is not up');
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
|
-
logger_1.logger.warn('alwaysAI Local Connection
|
|
31
|
+
logger_1.logger.warn('alwaysAI Local Connection Container is undefined');
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
exports.checkRabbitMQContainerRunning = checkRabbitMQContainerRunning;
|
|
35
35
|
async function writeRabbitMQDockerComposeFile() {
|
|
36
36
|
const spawner = (0, util_1.JsSpawner)();
|
|
37
|
-
if (!(await spawner.exists(directories_1.
|
|
38
|
-
await (0, util_1.JsSpawner)().mkdirp(directories_1.
|
|
37
|
+
if (!(await spawner.exists((0, directories_1.getDeviceAgentConfigPath)()))) {
|
|
38
|
+
await (0, util_1.JsSpawner)().mkdirp((0, directories_1.getDeviceAgentConfigPath)());
|
|
39
39
|
}
|
|
40
40
|
logger_1.logger.debug(`Writing Local Connection Docker compose files with Local Connection port: ${constants_1.LOCAL_CONNECTION_PORT}`);
|
|
41
41
|
const rabbitmqDockerComposeCmd = {
|
|
@@ -55,7 +55,7 @@ async function writeRabbitMQDockerComposeFile() {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
const RabbitMQDockerComposeYaml = YAML.stringify(rabbitmqDockerComposeCmd);
|
|
58
|
-
await spawner.writeFile(directories_1.
|
|
58
|
+
await spawner.writeFile((0, directories_1.getDeviceAgentDockerComposePath)(), RabbitMQDockerComposeYaml);
|
|
59
59
|
}
|
|
60
60
|
exports.writeRabbitMQDockerComposeFile = writeRabbitMQDockerComposeFile;
|
|
61
61
|
async function setupRabbitMQContainer() {
|
|
@@ -64,11 +64,11 @@ async function setupRabbitMQContainer() {
|
|
|
64
64
|
await writeRabbitMQDockerComposeFile();
|
|
65
65
|
}
|
|
66
66
|
catch (e) {
|
|
67
|
-
logger_1.logger.error(`An error occurred setting up docker-compose.yaml for Device Agent pass through
|
|
67
|
+
logger_1.logger.error(`An error occurred setting up docker-compose.yaml for Device Agent pass through!\n${(0, util_1.stringifyError)(e)}`);
|
|
68
68
|
}
|
|
69
69
|
try {
|
|
70
|
-
const upOut = await docker_compose_1.
|
|
71
|
-
cwd: directories_1.
|
|
70
|
+
const upOut = await docker_compose_1.compose.upAll({
|
|
71
|
+
cwd: (0, directories_1.getDeviceAgentConfigPath)()
|
|
72
72
|
});
|
|
73
73
|
logger_1.logger.debug(`Docker compose up for alwaysAI Local Connection:\n${JSON.stringify(upOut)}`);
|
|
74
74
|
// check if the container is up
|
|
@@ -77,18 +77,18 @@ async function setupRabbitMQContainer() {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
|
-
logger_1.logger.error(`Unable to start alwaysAI Device Agent Local Connection Container
|
|
80
|
+
logger_1.logger.error(`Unable to start alwaysAI Device Agent Local Connection Container!\n${(0, util_1.stringifyError)(e)}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
exports.setupRabbitMQContainer = setupRabbitMQContainer;
|
|
84
84
|
async function stopRabbitMQContainer() {
|
|
85
85
|
try {
|
|
86
|
-
const downOut = await docker_compose_1.
|
|
86
|
+
const downOut = await docker_compose_1.compose.down({ cwd: (0, directories_1.getDeviceAgentConfigPath)() });
|
|
87
87
|
logger_1.logger.debug(`Stopping alwaysAI Local Connection container`);
|
|
88
88
|
logger_1.logger.debug(`Docker compose down for alwaysAI Local Connection:\n${JSON.stringify(downOut)}`);
|
|
89
89
|
}
|
|
90
90
|
catch (e) {
|
|
91
|
-
logger_1.logger.error(`Unable to stop alwaysAI Device Agent Local Connection Container
|
|
91
|
+
logger_1.logger.error(`Unable to stop alwaysAI Device Agent Local Connection Container!\n${(0, util_1.stringifyError)(e)}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
exports.stopRabbitMQContainer = stopRabbitMQContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbitmq-connection.js","sourceRoot":"","sources":["../../src/local-connection/rabbitmq-connection.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"rabbitmq-connection.js","sourceRoot":"","sources":["../../src/local-connection/rabbitmq-connection.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
enabled: boolean;
|
|
3
|
-
type: string;
|
|
4
|
-
ip: string;
|
|
5
|
-
port: number;
|
|
6
|
-
};
|
|
7
|
-
export declare type SecureTunnelShadowDesRep = {
|
|
8
|
-
st_ports: SecureTunnelPortInfo[];
|
|
9
|
-
};
|
|
1
|
+
import { SecureTunnelShadowUpdate } from '@alwaysai/device-agent-schemas';
|
|
10
2
|
export declare type SecureTunnelShadowState = {
|
|
11
|
-
reported?:
|
|
12
|
-
desired?:
|
|
3
|
+
reported?: SecureTunnelShadowUpdate;
|
|
4
|
+
desired?: SecureTunnelShadowUpdate;
|
|
13
5
|
};
|
|
14
6
|
export declare type SecureTunnelShadowUpdateDelta = {
|
|
15
7
|
version: number;
|
|
16
8
|
timestamp: number;
|
|
17
|
-
state:
|
|
9
|
+
state: SecureTunnelShadowUpdate;
|
|
18
10
|
metadata?: any;
|
|
19
11
|
};
|
|
20
|
-
export declare type
|
|
12
|
+
export declare type SecureTunnelShadow = {
|
|
21
13
|
version: number;
|
|
22
14
|
state: SecureTunnelShadowState;
|
|
23
15
|
};
|
|
@@ -33,7 +25,7 @@ export declare class SecureTunnelHandlerSingleton {
|
|
|
33
25
|
private static instance;
|
|
34
26
|
private reported;
|
|
35
27
|
private httpProxyMap;
|
|
36
|
-
private
|
|
28
|
+
private localProxyInfo;
|
|
37
29
|
/**
|
|
38
30
|
* Initializes private variables of SecureTunnel handler.
|
|
39
31
|
* private constructor to prevent instantiation from outside
|
|
@@ -49,15 +41,15 @@ export declare class SecureTunnelHandlerSingleton {
|
|
|
49
41
|
destroy(): Promise<void>;
|
|
50
42
|
/**
|
|
51
43
|
* Returns current state of SecureTunnel shadow
|
|
52
|
-
* @returns {
|
|
44
|
+
* @returns {SecureTunnelShadowUpdate} - reported state of the SecureTunnel shadow
|
|
53
45
|
*/
|
|
54
|
-
getSecureTunnelShadow():
|
|
46
|
+
getSecureTunnelShadow(): SecureTunnelShadowUpdate;
|
|
55
47
|
/**
|
|
56
48
|
* Updates current state of SecureTunnel shadow
|
|
57
49
|
* @param {SecureTunnelShadowUpdateDelta} deltaMsg - delta message, which includes desired state of the SecureTunnel shadow
|
|
58
|
-
* @return {
|
|
50
|
+
* @return {SecureTunnelShadowUpdate} update reported message to send back to AWS IoT device shadow
|
|
59
51
|
*/
|
|
60
|
-
syncShadowToDeviceState(deltaMsg: SecureTunnelShadowUpdateDelta): Promise<
|
|
52
|
+
syncShadowToDeviceState(deltaMsg: SecureTunnelShadowUpdateDelta): Promise<SecureTunnelShadowUpdate>;
|
|
61
53
|
/**
|
|
62
54
|
* Starts SecureTunnel
|
|
63
55
|
* @param {SecureTunnelNotificationType} message - AWS notification received
|
|
@@ -79,20 +71,20 @@ export declare class SecureTunnelHandlerSingleton {
|
|
|
79
71
|
*/
|
|
80
72
|
private stopProxyMapping;
|
|
81
73
|
/**
|
|
82
|
-
* Starts SecureTunnel
|
|
74
|
+
* Starts SecureTunnel localProxy process
|
|
83
75
|
*/
|
|
84
|
-
private
|
|
76
|
+
private startLocalProxy;
|
|
85
77
|
/**
|
|
86
|
-
* Stops SecureTunnel
|
|
78
|
+
* Stops SecureTunnel local proxy process
|
|
87
79
|
*/
|
|
88
|
-
private
|
|
80
|
+
private stopLocalProxy;
|
|
89
81
|
/**
|
|
90
82
|
* processes and validate notify message
|
|
91
83
|
* @param {string[]} message - message, which contains: clientAccessToken, region, services
|
|
92
84
|
*/
|
|
93
85
|
private processNotifyMessage;
|
|
94
86
|
/**
|
|
95
|
-
* Downloads SecureTunnel
|
|
87
|
+
* Downloads SecureTunnel local proxy, if it was not downloaded before
|
|
96
88
|
*/
|
|
97
89
|
private downloadSecureTunnel;
|
|
98
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-tunneling.d.ts","sourceRoot":"","sources":["../../src/secure-tunneling/secure-tunneling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"secure-tunneling.d.ts","sourceRoot":"","sources":["../../src/secure-tunneling/secure-tunneling.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAuBxC,oBAAY,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IACpC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAsBF,aAAK,4BAA4B,GAAG;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAMF;;GAEG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,cAAc,CAA6B;IAEnD;;;OAGG;IACH,OAAO;IAqBP;;OAEG;WACW,WAAW,IAAI,4BAA4B;IAUzD;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBrC;;;OAGG;IACI,qBAAqB,IAAI,wBAAwB;IAOxD;;;;OAIG;IACU,uBAAuB,CAClC,QAAQ,EAAE,6BAA6B,GACtC,OAAO,CAAC,wBAAwB,CAAC;IA0DpC;;;OAGG;IACU,yBAAyB,CACpC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;OAGG;YACW,oBAAoB;IAkClC;;;OAGG;YACW,iBAAiB;IAiD/B;;;OAGG;YACW,gBAAgB;IA2C9B;;OAEG;YACW,eAAe;IAuB7B;;OAEG;YACW,cAAc;IA4B5B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAmF5B;;OAEG;YACW,oBAAoB;IAwClC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,SAAS;CAmBlB"}
|
|
@@ -5,12 +5,12 @@ const paths_1 = require("alwaysai/lib/paths");
|
|
|
5
5
|
const util_1 = require("alwaysai/lib/util");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const urls_1 = require("../urls");
|
|
8
|
-
const
|
|
8
|
+
const aws_regions_1 = require("../util/aws-regions");
|
|
9
9
|
const directories_1 = require("../util/directories");
|
|
10
|
-
const download_file_1 = require("../util/download-file");
|
|
11
10
|
const logger_1 = require("../util/logger");
|
|
12
11
|
const system_info_1 = require("../util/system-info");
|
|
13
12
|
const spawner_detached_1 = require("./spawner-detached");
|
|
13
|
+
const file_1 = require("../util/file");
|
|
14
14
|
var SecureTunnelServiceType;
|
|
15
15
|
(function (SecureTunnelServiceType) {
|
|
16
16
|
SecureTunnelServiceType["SSH"] = "SSH";
|
|
@@ -39,7 +39,7 @@ class SecureTunnelHandlerSingleton {
|
|
|
39
39
|
st_ports: [JSON.parse(JSON.stringify(defaultSecureTunnelPortInfo))]
|
|
40
40
|
};
|
|
41
41
|
this.httpProxyMap = [];
|
|
42
|
-
this.
|
|
42
|
+
this.localProxyInfo = {
|
|
43
43
|
lpDstAccessKey: '',
|
|
44
44
|
lpRegion: '',
|
|
45
45
|
lpServices: '',
|
|
@@ -83,12 +83,12 @@ class SecureTunnelHandlerSingleton {
|
|
|
83
83
|
};
|
|
84
84
|
logger_1.logger.debug(`httpProxyMap after : ${JSON.stringify(this.httpProxyMap)}`);
|
|
85
85
|
logger_1.logger.debug(`reported after : ${JSON.stringify(this.reported)}`);
|
|
86
|
-
await this.
|
|
86
|
+
await this.stopLocalProxy();
|
|
87
87
|
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.destroy');
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns current state of SecureTunnel shadow
|
|
91
|
-
* @returns {
|
|
91
|
+
* @returns {SecureTunnelShadowUpdate} - reported state of the SecureTunnel shadow
|
|
92
92
|
*/
|
|
93
93
|
getSecureTunnelShadow() {
|
|
94
94
|
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.getSecureTunnelShadow');
|
|
@@ -99,7 +99,7 @@ class SecureTunnelHandlerSingleton {
|
|
|
99
99
|
/**
|
|
100
100
|
* Updates current state of SecureTunnel shadow
|
|
101
101
|
* @param {SecureTunnelShadowUpdateDelta} deltaMsg - delta message, which includes desired state of the SecureTunnel shadow
|
|
102
|
-
* @return {
|
|
102
|
+
* @return {SecureTunnelShadowUpdate} update reported message to send back to AWS IoT device shadow
|
|
103
103
|
*/
|
|
104
104
|
async syncShadowToDeviceState(deltaMsg) {
|
|
105
105
|
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.syncShadowToDeviceState');
|
|
@@ -140,7 +140,7 @@ class SecureTunnelHandlerSingleton {
|
|
|
140
140
|
}
|
|
141
141
|
// if all entries are disabled, we need also to kill local proxy
|
|
142
142
|
if (this.reported.st_ports.every((portInfo) => !portInfo.enabled)) {
|
|
143
|
-
await this.
|
|
143
|
+
await this.stopLocalProxy();
|
|
144
144
|
}
|
|
145
145
|
// need to order list in the same order as desired before sending back
|
|
146
146
|
const sortedPorts = this.sortPorts(state);
|
|
@@ -155,15 +155,15 @@ class SecureTunnelHandlerSingleton {
|
|
|
155
155
|
async secureTunnelNotifyHandler(message) {
|
|
156
156
|
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.secureTunnelNotifyHandler');
|
|
157
157
|
try {
|
|
158
|
-
await this.
|
|
158
|
+
await this.stopLocalProxy();
|
|
159
159
|
this.processNotifyMessage(message);
|
|
160
160
|
await this.downloadSecureTunnel();
|
|
161
|
-
await this.
|
|
161
|
+
await this.startLocalProxy();
|
|
162
162
|
}
|
|
163
|
-
catch (
|
|
164
|
-
logger_1.logger.error(
|
|
163
|
+
catch (e) {
|
|
164
|
+
logger_1.logger.error((0, util_1.stringifyError)(e));
|
|
165
165
|
}
|
|
166
|
-
logger_1.logger.info(`Local Proxy Started: ${JSON.stringify(this.
|
|
166
|
+
logger_1.logger.info(`Local Proxy Started: ${JSON.stringify(this.localProxyInfo)}`);
|
|
167
167
|
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.secureTunnelNotifyHandler');
|
|
168
168
|
}
|
|
169
169
|
//---------------------------------------------------------------------------
|
|
@@ -229,8 +229,8 @@ class SecureTunnelHandlerSingleton {
|
|
|
229
229
|
});
|
|
230
230
|
logger_1.logger.info(`Started Port Proxy Mapping for: ${JSON.stringify(this.httpProxyMap[this.httpProxyMap.length - 1])}`);
|
|
231
231
|
}
|
|
232
|
-
catch (
|
|
233
|
-
logger_1.logger.error(`ERROR: starting socat for: ${portInfo.ip}:${portInfo.port} on localhost port: ${localPort},
|
|
232
|
+
catch (e) {
|
|
233
|
+
logger_1.logger.error(`ERROR: starting socat for: ${portInfo.ip}:${portInfo.port} on localhost port: ${localPort}\nerror:\n${(0, util_1.stringifyError)(e)}`);
|
|
234
234
|
const lastHttpProxyMap = this.httpProxyMap.pop();
|
|
235
235
|
logger_1.logger.info(`removed last proxyMap: ${JSON.stringify(lastHttpProxyMap)}`);
|
|
236
236
|
}
|
|
@@ -259,7 +259,7 @@ class SecureTunnelHandlerSingleton {
|
|
|
259
259
|
logger_1.logger.debug(`Remaining map: ${JSON.stringify(this.httpProxyMap)}`);
|
|
260
260
|
}
|
|
261
261
|
catch (e) {
|
|
262
|
-
logger_1.logger.error(
|
|
262
|
+
logger_1.logger.error(`ERROR: killing socat process:\n${(0, util_1.stringifyError)(e)}`);
|
|
263
263
|
}
|
|
264
264
|
logger_1.logger.debug(`Removing map: ${JSON.stringify(this.httpProxyMap[itemIndex])}`);
|
|
265
265
|
this.httpProxyMap.splice(itemIndex, 1);
|
|
@@ -267,52 +267,52 @@ class SecureTunnelHandlerSingleton {
|
|
|
267
267
|
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.stopProxyMapping');
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
270
|
-
* Starts SecureTunnel
|
|
270
|
+
* Starts SecureTunnel localProxy process
|
|
271
271
|
*/
|
|
272
|
-
async
|
|
273
|
-
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.
|
|
272
|
+
async startLocalProxy() {
|
|
273
|
+
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.startLocalProxy');
|
|
274
274
|
const args = [
|
|
275
275
|
'--destination-app',
|
|
276
|
-
this.
|
|
276
|
+
this.localProxyInfo.lpServices,
|
|
277
277
|
'--region',
|
|
278
|
-
this.
|
|
278
|
+
this.localProxyInfo.lpRegion,
|
|
279
279
|
'--capath',
|
|
280
280
|
directories_1.AWS_ROOT_CERTIFICATE_FILE_PATH,
|
|
281
281
|
'--local-bind-address',
|
|
282
282
|
'0.0.0.0',
|
|
283
283
|
'-t',
|
|
284
|
-
this.
|
|
284
|
+
this.localProxyInfo.lpDstAccessKey
|
|
285
285
|
];
|
|
286
|
-
this.
|
|
287
|
-
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.
|
|
286
|
+
this.localProxyInfo.lpProcess = await (0, spawner_detached_1.runDetachedProcess)(directories_1.SECURE_TUNNEL_BIN_PATH, args);
|
|
287
|
+
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.startLocalProxy');
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
|
-
* Stops SecureTunnel
|
|
290
|
+
* Stops SecureTunnel local proxy process
|
|
291
291
|
*/
|
|
292
|
-
async
|
|
293
|
-
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.
|
|
294
|
-
if (!this.
|
|
295
|
-
logger_1.logger.debug('No
|
|
296
|
-
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.
|
|
292
|
+
async stopLocalProxy() {
|
|
293
|
+
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.stopLocalProxy');
|
|
294
|
+
if (!this.localProxyInfo.lpProcess) {
|
|
295
|
+
logger_1.logger.debug('No local proxy process running');
|
|
296
|
+
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.stopLocalProxy');
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
try {
|
|
300
|
-
logger_1.logger.debug(`About to kill
|
|
301
|
-
await (0, spawner_detached_1.killDetachedProcess)(this.
|
|
300
|
+
logger_1.logger.debug(`About to kill local proxy: ${this.localProxyInfo.lpDstAccessKey}`);
|
|
301
|
+
await (0, spawner_detached_1.killDetachedProcess)(this.localProxyInfo.lpProcess, [
|
|
302
302
|
directories_1.SECURE_TUNNEL_BIN_PATH
|
|
303
303
|
]);
|
|
304
|
-
logger_1.logger.debug('SUCCESS: killing
|
|
304
|
+
logger_1.logger.debug('SUCCESS: killing local proxy process');
|
|
305
305
|
}
|
|
306
306
|
catch (e) {
|
|
307
|
-
logger_1.logger.error(
|
|
307
|
+
logger_1.logger.error(`ERROR: killing local proxy process:\n${(0, util_1.stringifyError)(e)}`);
|
|
308
308
|
}
|
|
309
|
-
this.
|
|
309
|
+
this.localProxyInfo = {
|
|
310
310
|
lpDstAccessKey: '',
|
|
311
311
|
lpRegion: '',
|
|
312
312
|
lpServices: '',
|
|
313
313
|
lpProcess: null
|
|
314
314
|
};
|
|
315
|
-
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.
|
|
315
|
+
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.stopLocalProxy');
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
318
|
* processes and validate notify message
|
|
@@ -325,7 +325,7 @@ class SecureTunnelHandlerSingleton {
|
|
|
325
325
|
if (clientAccessToken === '') {
|
|
326
326
|
throw new Error('ERROR: invalid destination access token');
|
|
327
327
|
}
|
|
328
|
-
if (!(0,
|
|
328
|
+
if (!(0, aws_regions_1.isValidAwsRegion)(region)) {
|
|
329
329
|
throw new Error(`ERROR: invalid/unsupported region: ${region}`);
|
|
330
330
|
}
|
|
331
331
|
if (services.length === 0) {
|
|
@@ -366,15 +366,15 @@ class SecureTunnelHandlerSingleton {
|
|
|
366
366
|
portMappingList.push(`${port}=${this.httpProxyMap[index].localhostPort}`);
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
this.
|
|
370
|
-
this.
|
|
371
|
-
this.
|
|
369
|
+
this.localProxyInfo.lpDstAccessKey = clientAccessToken;
|
|
370
|
+
this.localProxyInfo.lpRegion = region;
|
|
371
|
+
this.localProxyInfo.lpServices = portMappingList.join(',');
|
|
372
372
|
logger_1.logger.debug(`reported = ${JSON.stringify(this.reported.st_ports)}`);
|
|
373
|
-
logger_1.logger.debug(`
|
|
373
|
+
logger_1.logger.debug(`localProxyInfo = ${JSON.stringify(this.localProxyInfo)}`);
|
|
374
374
|
logger_1.logger.debug('<- SecureTunnelHandlerSingleton.processNotifyMessage');
|
|
375
375
|
}
|
|
376
376
|
/**
|
|
377
|
-
* Downloads SecureTunnel
|
|
377
|
+
* Downloads SecureTunnel local proxy, if it was not downloaded before
|
|
378
378
|
*/
|
|
379
379
|
async downloadSecureTunnel() {
|
|
380
380
|
logger_1.logger.debug('-> SecureTunnelHandlerSingleton.downloadSecureTunnel');
|
|
@@ -387,14 +387,19 @@ class SecureTunnelHandlerSingleton {
|
|
|
387
387
|
(0, system_info_1.getDistribution)(),
|
|
388
388
|
(0, system_info_1.getOsVersion)()
|
|
389
389
|
]);
|
|
390
|
-
logger_1.logger.info('Downloading SecureTunnel
|
|
390
|
+
logger_1.logger.info('Downloading SecureTunnel local proxy ...');
|
|
391
391
|
const url = `${urls_1.aaiArtifactsBucketUrl}/securetunnel/${linuxDistro}/${osVersion}/${arch}/${directories_1.SECURE_TUNNEL_BIN_NAME}`;
|
|
392
392
|
await (0, util_1.JsSpawner)().mkdirp((0, path_1.join)(paths_1.AAI_DIR, directories_1.SECURE_TUNNEL_BIN_DIR));
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
try {
|
|
394
|
+
await (0, file_1.downloadToFile)({
|
|
395
|
+
url,
|
|
396
|
+
path: directories_1.SECURE_TUNNEL_BIN_PATH
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
logger_1.logger.error(`Secure Tunnel bin for ${linuxDistro} ${osVersion} ${arch} not found}: ${(0, util_1.stringifyError)(error)}`);
|
|
401
|
+
throw new Error(`Secure Tunnel bin for ${linuxDistro} ${osVersion} ${arch} not found}`);
|
|
402
|
+
}
|
|
398
403
|
await (0, util_1.JsSpawner)().run({
|
|
399
404
|
exe: 'chmod',
|
|
400
405
|
args: ['+x', directories_1.SECURE_TUNNEL_BIN_PATH]
|