@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.
Files changed (313) hide show
  1. package/lib/application-control/config.d.ts.map +1 -1
  2. package/lib/application-control/config.js +10 -5
  3. package/lib/application-control/config.js.map +1 -1
  4. package/lib/application-control/environment-variables.d.ts +1 -5
  5. package/lib/application-control/environment-variables.d.ts.map +1 -1
  6. package/lib/application-control/environment-variables.js +9 -26
  7. package/lib/application-control/environment-variables.js.map +1 -1
  8. package/lib/application-control/environment-variables.test.js +27 -7
  9. package/lib/application-control/environment-variables.test.js.map +1 -1
  10. package/lib/application-control/index.d.ts +4 -4
  11. package/lib/application-control/index.d.ts.map +1 -1
  12. package/lib/application-control/index.js +1 -4
  13. package/lib/application-control/index.js.map +1 -1
  14. package/lib/application-control/install.d.ts.map +1 -1
  15. package/lib/application-control/install.js +9 -7
  16. package/lib/application-control/install.js.map +1 -1
  17. package/lib/application-control/models.d.ts +5 -11
  18. package/lib/application-control/models.d.ts.map +1 -1
  19. package/lib/application-control/models.js +27 -64
  20. package/lib/application-control/models.js.map +1 -1
  21. package/lib/application-control/status.d.ts.map +1 -1
  22. package/lib/application-control/status.js +10 -12
  23. package/lib/application-control/status.js.map +1 -1
  24. package/lib/application-control/utils.d.ts +0 -4
  25. package/lib/application-control/utils.d.ts.map +1 -1
  26. package/lib/application-control/utils.js +3 -26
  27. package/lib/application-control/utils.js.map +1 -1
  28. package/lib/cloud-connection/bootstrap-provision.js +3 -2
  29. package/lib/cloud-connection/bootstrap-provision.js.map +1 -1
  30. package/lib/cloud-connection/device-agent-cloud-connection.d.ts +11 -16
  31. package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
  32. package/lib/cloud-connection/device-agent-cloud-connection.js +295 -246
  33. package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
  34. package/lib/cloud-connection/device-agent.d.ts.map +1 -1
  35. package/lib/cloud-connection/device-agent.js +11 -9
  36. package/lib/cloud-connection/device-agent.js.map +1 -1
  37. package/lib/cloud-connection/live-updates-handler.d.ts +18 -27
  38. package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -1
  39. package/lib/cloud-connection/live-updates-handler.js +58 -170
  40. package/lib/cloud-connection/live-updates-handler.js.map +1 -1
  41. package/lib/cloud-connection/live-updates-handler.test.js +76 -54
  42. package/lib/cloud-connection/live-updates-handler.test.js.map +1 -1
  43. package/lib/cloud-connection/passthrough-handler.d.ts +9 -4
  44. package/lib/cloud-connection/passthrough-handler.d.ts.map +1 -1
  45. package/lib/cloud-connection/passthrough-handler.js +95 -62
  46. package/lib/cloud-connection/passthrough-handler.js.map +1 -1
  47. package/lib/cloud-connection/shadow-handler.d.ts +5 -1
  48. package/lib/cloud-connection/shadow-handler.d.ts.map +1 -1
  49. package/lib/cloud-connection/shadow-handler.js +63 -31
  50. package/lib/cloud-connection/shadow-handler.js.map +1 -1
  51. package/lib/cloud-connection/shadow-handler.test.js +45 -57
  52. package/lib/cloud-connection/shadow-handler.test.js.map +1 -1
  53. package/lib/cloud-connection/shadow.d.ts.map +1 -1
  54. package/lib/cloud-connection/shadow.js +2 -1
  55. package/lib/cloud-connection/shadow.js.map +1 -1
  56. package/lib/cloud-connection/transaction-manager.d.ts +7 -2
  57. package/lib/cloud-connection/transaction-manager.d.ts.map +1 -1
  58. package/lib/cloud-connection/transaction-manager.js +29 -29
  59. package/lib/cloud-connection/transaction-manager.js.map +1 -1
  60. package/lib/cloud-connection/transaction-manager.test.js +105 -3
  61. package/lib/cloud-connection/transaction-manager.test.js.map +1 -1
  62. package/lib/device-control/device-control.d.ts +14 -6
  63. package/lib/device-control/device-control.d.ts.map +1 -1
  64. package/lib/device-control/device-control.js +172 -72
  65. package/lib/device-control/device-control.js.map +1 -1
  66. package/lib/docker/docker-compose.d.ts +14 -0
  67. package/lib/docker/docker-compose.d.ts.map +1 -0
  68. package/lib/docker/docker-compose.js +57 -0
  69. package/lib/docker/docker-compose.js.map +1 -0
  70. package/lib/index.js +2 -5
  71. package/lib/index.js.map +1 -1
  72. package/lib/infrastructure/agent-config.d.ts +46 -14
  73. package/lib/infrastructure/agent-config.d.ts.map +1 -1
  74. package/lib/infrastructure/agent-config.js +36 -21
  75. package/lib/infrastructure/agent-config.js.map +1 -1
  76. package/lib/infrastructure/agent-config.test.js +6 -1
  77. package/lib/infrastructure/agent-config.test.js.map +1 -1
  78. package/lib/infrastructure/config-check-utility.d.ts +6 -0
  79. package/lib/infrastructure/config-check-utility.d.ts.map +1 -0
  80. package/lib/infrastructure/config-check-utility.js +67 -0
  81. package/lib/infrastructure/config-check-utility.js.map +1 -0
  82. package/lib/infrastructure/config-check-utility.test.d.ts +2 -0
  83. package/lib/infrastructure/config-check-utility.test.d.ts.map +1 -0
  84. package/lib/infrastructure/config-check-utility.test.js +109 -0
  85. package/lib/infrastructure/config-check-utility.test.js.map +1 -0
  86. package/lib/infrastructure/device-certificate.d.ts +10 -0
  87. package/lib/infrastructure/device-certificate.d.ts.map +1 -0
  88. package/lib/infrastructure/device-certificate.js +47 -0
  89. package/lib/infrastructure/device-certificate.js.map +1 -0
  90. package/lib/infrastructure/device-certificate.test.d.ts +2 -0
  91. package/lib/infrastructure/device-certificate.test.d.ts.map +1 -0
  92. package/lib/infrastructure/device-certificate.test.js +24 -0
  93. package/lib/infrastructure/device-certificate.test.js.map +1 -0
  94. package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts +2 -0
  95. package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts.map +1 -0
  96. package/lib/infrastructure/legacy-migration/legacy-file.test.js +61 -0
  97. package/lib/infrastructure/legacy-migration/legacy-file.test.js.map +1 -0
  98. package/lib/infrastructure/legacy-migration/legacy-files.d.ts +75 -0
  99. package/lib/infrastructure/legacy-migration/legacy-files.d.ts.map +1 -0
  100. package/lib/infrastructure/legacy-migration/legacy-files.js +75 -0
  101. package/lib/infrastructure/legacy-migration/legacy-files.js.map +1 -0
  102. package/lib/infrastructure/legacy-migration/legacy-migration.d.ts +6 -0
  103. package/lib/infrastructure/legacy-migration/legacy-migration.d.ts.map +1 -0
  104. package/lib/infrastructure/legacy-migration/legacy-migration.js +149 -0
  105. package/lib/infrastructure/legacy-migration/legacy-migration.js.map +1 -0
  106. package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts +2 -0
  107. package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts.map +1 -0
  108. package/lib/infrastructure/legacy-migration/legacy-migration.test.js +226 -0
  109. package/lib/infrastructure/legacy-migration/legacy-migration.test.js.map +1 -0
  110. package/lib/infrastructure/require-files-present-ready.test.d.ts +2 -0
  111. package/lib/infrastructure/require-files-present-ready.test.d.ts.map +1 -0
  112. package/lib/infrastructure/require-files-present-ready.test.js +44 -0
  113. package/lib/infrastructure/require-files-present-ready.test.js.map +1 -0
  114. package/lib/infrastructure/required-config-checks.d.ts +2 -0
  115. package/lib/infrastructure/required-config-checks.d.ts.map +1 -0
  116. package/lib/infrastructure/required-config-checks.js +30 -0
  117. package/lib/infrastructure/required-config-checks.js.map +1 -0
  118. package/lib/infrastructure/tokens-and-device-cfg.d.ts.map +1 -1
  119. package/lib/infrastructure/tokens-and-device-cfg.js +11 -8
  120. package/lib/infrastructure/tokens-and-device-cfg.js.map +1 -1
  121. package/lib/local-connection/rabbitmq-connection.d.ts.map +1 -1
  122. package/lib/local-connection/rabbitmq-connection.js +21 -21
  123. package/lib/local-connection/rabbitmq-connection.js.map +1 -1
  124. package/lib/secure-tunneling/secure-tunneling.d.ts +15 -23
  125. package/lib/secure-tunneling/secure-tunneling.d.ts.map +1 -1
  126. package/lib/secure-tunneling/secure-tunneling.js +52 -47
  127. package/lib/secure-tunneling/secure-tunneling.js.map +1 -1
  128. package/lib/secure-tunneling/secure-tunneling.test.js +29 -31
  129. package/lib/secure-tunneling/secure-tunneling.test.js.map +1 -1
  130. package/lib/subcommands/app/analytics.d.ts.map +1 -1
  131. package/lib/subcommands/app/analytics.js +1 -2
  132. package/lib/subcommands/app/analytics.js.map +1 -1
  133. package/lib/subcommands/app/env-vars.d.ts +4 -0
  134. package/lib/subcommands/app/env-vars.d.ts.map +1 -1
  135. package/lib/subcommands/app/env-vars.js +52 -6
  136. package/lib/subcommands/app/env-vars.js.map +1 -1
  137. package/lib/subcommands/app/index.d.ts.map +1 -1
  138. package/lib/subcommands/app/index.js +1 -3
  139. package/lib/subcommands/app/index.js.map +1 -1
  140. package/lib/subcommands/app/models.d.ts +0 -11
  141. package/lib/subcommands/app/models.d.ts.map +1 -1
  142. package/lib/subcommands/app/models.js +2 -58
  143. package/lib/subcommands/app/models.js.map +1 -1
  144. package/lib/subcommands/app/shadow.d.ts.map +1 -1
  145. package/lib/subcommands/app/shadow.js +6 -5
  146. package/lib/subcommands/app/shadow.js.map +1 -1
  147. package/lib/subcommands/app/version.d.ts.map +1 -1
  148. package/lib/subcommands/app/version.js +2 -4
  149. package/lib/subcommands/app/version.js.map +1 -1
  150. package/lib/subcommands/config.d.ts +2 -0
  151. package/lib/subcommands/config.d.ts.map +1 -0
  152. package/lib/subcommands/config.js +39 -0
  153. package/lib/subcommands/config.js.map +1 -0
  154. package/lib/subcommands/device/clean.d.ts +1 -1
  155. package/lib/subcommands/device/clean.d.ts.map +1 -1
  156. package/lib/subcommands/device/clean.js +25 -15
  157. package/lib/subcommands/device/clean.js.map +1 -1
  158. package/lib/subcommands/device/get-info.d.ts +2 -0
  159. package/lib/subcommands/device/get-info.d.ts.map +1 -0
  160. package/lib/subcommands/device/get-info.js +36 -0
  161. package/lib/subcommands/device/get-info.js.map +1 -0
  162. package/lib/subcommands/device/index.d.ts.map +1 -1
  163. package/lib/subcommands/device/index.js +13 -2
  164. package/lib/subcommands/device/index.js.map +1 -1
  165. package/lib/subcommands/device/init.d.ts +5 -0
  166. package/lib/subcommands/device/init.d.ts.map +1 -0
  167. package/lib/subcommands/device/{device.js → init.js} +10 -49
  168. package/lib/subcommands/device/init.js.map +1 -0
  169. package/lib/subcommands/device/migrate.d.ts +2 -0
  170. package/lib/subcommands/device/migrate.d.ts.map +1 -0
  171. package/lib/subcommands/device/migrate.js +24 -0
  172. package/lib/subcommands/device/migrate.js.map +1 -0
  173. package/lib/subcommands/device/refresh.d.ts +2 -0
  174. package/lib/subcommands/device/refresh.d.ts.map +1 -0
  175. package/lib/subcommands/device/refresh.js +25 -0
  176. package/lib/subcommands/device/refresh.js.map +1 -0
  177. package/lib/subcommands/device/restart.d.ts +2 -0
  178. package/lib/subcommands/device/restart.d.ts.map +1 -0
  179. package/lib/subcommands/device/restart.js +14 -0
  180. package/lib/subcommands/device/restart.js.map +1 -0
  181. package/lib/subcommands/index.d.ts +1 -1
  182. package/lib/subcommands/index.d.ts.map +1 -1
  183. package/lib/subcommands/index.js +3 -1
  184. package/lib/subcommands/index.js.map +1 -1
  185. package/lib/subcommands/rabbitmq-connection.d.ts +1 -1
  186. package/lib/subcommands/rabbitmq-connection.d.ts.map +1 -1
  187. package/lib/util/aai-error.d.ts +12 -0
  188. package/lib/util/aai-error.d.ts.map +1 -0
  189. package/lib/util/aai-error.js +11 -0
  190. package/lib/util/aai-error.js.map +1 -0
  191. package/lib/util/aws-regions.d.ts +2 -0
  192. package/lib/util/aws-regions.d.ts.map +1 -0
  193. package/lib/util/{cloud-mode-ready.js → aws-regions.js} +2 -20
  194. package/lib/util/aws-regions.js.map +1 -0
  195. package/lib/util/check-for-updates.d.ts +3 -0
  196. package/lib/util/check-for-updates.d.ts.map +1 -0
  197. package/lib/util/check-for-updates.js +46 -0
  198. package/lib/util/check-for-updates.js.map +1 -0
  199. package/lib/util/clean-certs.d.ts.map +1 -1
  200. package/lib/util/clean-certs.js +5 -4
  201. package/lib/util/clean-certs.js.map +1 -1
  202. package/lib/util/directories.d.ts +4 -18
  203. package/lib/util/directories.d.ts.map +1 -1
  204. package/lib/util/directories.js +18 -32
  205. package/lib/util/directories.js.map +1 -1
  206. package/lib/util/file.d.ts +11 -0
  207. package/lib/util/file.d.ts.map +1 -0
  208. package/lib/util/file.js +127 -0
  209. package/lib/util/file.js.map +1 -0
  210. package/lib/util/file.test.d.ts +2 -0
  211. package/lib/util/file.test.d.ts.map +1 -0
  212. package/lib/util/file.test.js +87 -0
  213. package/lib/util/file.test.js.map +1 -0
  214. package/lib/util/get-device-id.d.ts.map +1 -1
  215. package/lib/util/get-device-id.js +7 -1
  216. package/lib/util/get-device-id.js.map +1 -1
  217. package/lib/util/http-client.js +3 -3
  218. package/lib/util/http-client.js.map +1 -1
  219. package/package.json +22 -19
  220. package/readme.md +15 -35
  221. package/src/application-control/config.ts +10 -13
  222. package/src/application-control/environment-variables.test.ts +28 -7
  223. package/src/application-control/environment-variables.ts +13 -40
  224. package/src/application-control/index.ts +3 -16
  225. package/src/application-control/install.ts +16 -10
  226. package/src/application-control/models.ts +40 -98
  227. package/src/application-control/status.ts +9 -7
  228. package/src/application-control/utils.ts +1 -29
  229. package/src/cloud-connection/bootstrap-provision.ts +7 -7
  230. package/src/cloud-connection/device-agent-cloud-connection.ts +647 -509
  231. package/src/cloud-connection/device-agent.ts +16 -7
  232. package/src/cloud-connection/live-updates-handler.test.ts +137 -64
  233. package/src/cloud-connection/live-updates-handler.ts +103 -234
  234. package/src/cloud-connection/passthrough-handler.ts +134 -75
  235. package/src/cloud-connection/shadow-handler.test.ts +45 -57
  236. package/src/cloud-connection/shadow-handler.ts +114 -56
  237. package/src/cloud-connection/shadow.ts +4 -1
  238. package/src/cloud-connection/transaction-manager.test.ts +127 -3
  239. package/src/cloud-connection/transaction-manager.ts +68 -39
  240. package/src/device-control/device-control.ts +179 -72
  241. package/src/docker/docker-compose.ts +61 -0
  242. package/src/index.ts +2 -6
  243. package/src/infrastructure/agent-config.test.ts +9 -2
  244. package/src/infrastructure/agent-config.ts +45 -46
  245. package/src/infrastructure/config-check-utility.test.ts +154 -0
  246. package/src/infrastructure/config-check-utility.ts +77 -0
  247. package/src/infrastructure/device-certificate.test.ts +40 -0
  248. package/src/infrastructure/device-certificate.ts +58 -0
  249. package/src/infrastructure/legacy-migration/legacy-file.test.ts +88 -0
  250. package/src/infrastructure/legacy-migration/legacy-files.ts +101 -0
  251. package/src/infrastructure/legacy-migration/legacy-migration.test.ts +396 -0
  252. package/src/infrastructure/legacy-migration/legacy-migration.ts +229 -0
  253. package/src/infrastructure/require-files-present-ready.test.ts +53 -0
  254. package/src/infrastructure/required-config-checks.ts +33 -0
  255. package/src/infrastructure/tokens-and-device-cfg.ts +12 -10
  256. package/src/local-connection/rabbitmq-connection.ts +28 -23
  257. package/src/secure-tunneling/secure-tunneling.test.ts +37 -39
  258. package/src/secure-tunneling/secure-tunneling.ts +74 -69
  259. package/src/subcommands/app/analytics.ts +2 -4
  260. package/src/subcommands/app/env-vars.ts +72 -9
  261. package/src/subcommands/app/index.ts +3 -11
  262. package/src/subcommands/app/models.ts +5 -81
  263. package/src/subcommands/app/shadow.ts +6 -5
  264. package/src/subcommands/app/version.ts +3 -4
  265. package/src/subcommands/config.ts +42 -0
  266. package/src/subcommands/device/clean.ts +32 -18
  267. package/src/subcommands/device/get-info.ts +49 -0
  268. package/src/subcommands/device/index.ts +13 -2
  269. package/src/subcommands/device/{device.ts → init.ts} +11 -69
  270. package/src/subcommands/device/migrate.ts +20 -0
  271. package/src/subcommands/device/refresh.ts +23 -0
  272. package/src/subcommands/device/restart.ts +11 -0
  273. package/src/subcommands/index.ts +3 -1
  274. package/src/util/aai-error.ts +20 -0
  275. package/src/util/{cloud-mode-ready.ts → aws-regions.ts} +0 -24
  276. package/src/util/check-for-updates.ts +53 -0
  277. package/src/util/clean-certs.ts +8 -4
  278. package/src/util/directories.ts +23 -67
  279. package/src/util/file.test.ts +90 -0
  280. package/src/util/file.ts +156 -0
  281. package/src/util/get-device-id.ts +7 -7
  282. package/src/util/http-client.ts +2 -2
  283. package/lib/docker/docker-compose-cmd.d.ts +0 -5
  284. package/lib/docker/docker-compose-cmd.d.ts.map +0 -1
  285. package/lib/docker/docker-compose-cmd.js +0 -16
  286. package/lib/docker/docker-compose-cmd.js.map +0 -1
  287. package/lib/subcommands/device/device.d.ts +0 -7
  288. package/lib/subcommands/device/device.d.ts.map +0 -1
  289. package/lib/subcommands/device/device.js.map +0 -1
  290. package/lib/util/cloud-mode-ready.d.ts +0 -3
  291. package/lib/util/cloud-mode-ready.d.ts.map +0 -1
  292. package/lib/util/cloud-mode-ready.js.map +0 -1
  293. package/lib/util/download-file.d.ts +0 -6
  294. package/lib/util/download-file.d.ts.map +0 -1
  295. package/lib/util/download-file.js +0 -25
  296. package/lib/util/download-file.js.map +0 -1
  297. package/lib/util/fetch-with-timeout.d.ts +0 -4
  298. package/lib/util/fetch-with-timeout.d.ts.map +0 -1
  299. package/lib/util/fetch-with-timeout.js +0 -30
  300. package/lib/util/fetch-with-timeout.js.map +0 -1
  301. package/lib/util/parsing.d.ts +0 -2
  302. package/lib/util/parsing.d.ts.map +0 -1
  303. package/lib/util/parsing.js +0 -17
  304. package/lib/util/parsing.js.map +0 -1
  305. package/lib/util/safe-rimraf.d.ts +0 -2
  306. package/lib/util/safe-rimraf.d.ts.map +0 -1
  307. package/lib/util/safe-rimraf.js +0 -16
  308. package/lib/util/safe-rimraf.js.map +0 -1
  309. package/src/docker/docker-compose-cmd.ts +0 -15
  310. package/src/util/download-file.ts +0 -25
  311. package/src/util/fetch-with-timeout.ts +0 -35
  312. package/src/util/parsing.ts +0 -11
  313. 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,yBAAy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AI,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,2 @@
1
+ export declare function requiredConfigFilesPresentAndValid(baseDir?: any): Promise<boolean>;
2
+ //# sourceMappingURL=required-config-checks.d.ts.map
@@ -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":"AAYA,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,iBAqBzE"}
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 util_1 = require("alwaysai/lib/util");
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
- deviceId: deviceUuid,
18
+ deviceUuid,
17
19
  accessToken,
18
20
  refreshToken,
19
21
  idToken
20
22
  };
21
- const tokenSpawner = (0, util_1.JsSpawner)({ path: paths_1.LOCAL_AAI_CFG_DIR });
22
- await (0, device_1.writeTokens)({ spawner: tokenSpawner, tokens });
23
- await (0, device_1.writeOrValidateDeviceCfgFile)({ spawner: tokenSpawner, deviceUuid });
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,2CAAwC;AACxC,qDAA6D;AAC7D,6FAAqF;AACrF,qDAIkC;AAClC,4CAA8C;AAC9C,8CAAuD;AAEvD,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,QAAQ,EAAE,UAAU;QACpB,WAAW;QACX,YAAY;QACZ,OAAO;KACR,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,gBAAS,EAAC,EAAE,IAAI,EAAE,yBAAiB,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAA,oBAAW,EAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,MAAM,IAAA,qCAA4B,EAAC,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;IAE1E,eAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC;AArBD,wDAqBC"}
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":"AAYA,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE,wBAAsB,6BAA6B,qBAwBlD;AAED,wBAAsB,8BAA8B,kBAgCnD;AAED,wBAAsB,sBAAsB,kBA2B3C;AAED,wBAAsB,qBAAqB,kBAc1C"}
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 logger_1 = require("../util/logger");
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 util_1 = require("alwaysai/lib/util");
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.DEVICE_AGENT_DOCKER_COMPOSE_PATH))) {
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.default.ps({ cwd: directories_1.DEVICE_AGENT_CFG_PATH });
21
- if (!(containerData === undefined)) {
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 === 'Up') {
25
- logger_1.logger.debug('alwaysAI Local Connection is running');
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 running');
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 container was undefined');
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.DEVICE_AGENT_CFG_PATH))) {
38
- await (0, util_1.JsSpawner)().mkdirp(directories_1.DEVICE_AGENT_CFG_PATH);
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.DEVICE_AGENT_DOCKER_COMPOSE_PATH, RabbitMQDockerComposeYaml);
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:\n{e.message}`);
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.default.upAll({
71
- cwd: directories_1.DEVICE_AGENT_CFG_PATH
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:\n${e.messaage}`);
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.default.down({ cwd: directories_1.DEVICE_AGENT_CFG_PATH });
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:\n${e.message}`);
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,2CAAwC;AACxC,yCAAkC;AAClC,mDAAqC;AACrC,6BAA6B;AAE7B,qDAG6B;AAC7B,4CAA8C;AAC9C,2CAAoD;AAEvC,QAAA,mBAAmB,GAAG,kBAAkB,CAAC;AACzC,QAAA,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D,KAAK,UAAU,6BAA6B;IACjD,eAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAA,gBAAS,GAAE,CAAC;IAC5B,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,8CAAgC,CAAC,CAAC,EAAE;QAC7D,eAAM,CAAC,IAAI,CACT,gEAAgE,CACjE,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IACD,MAAM,aAAa,GAAG,MAAM,wBAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,mCAAqB,EAAE,CAAC,CAAC;IACvE,IAAI,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,EAAE;QAClC,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACvD,IACE,eAAe,CAAC,IAAI,KAAK,6BAAqB;YAC9C,eAAe,CAAC,KAAK,KAAK,IAAI,EAC9B;YACA,eAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC;SACb;QACD,eAAM,CAAC,KAAK,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M,KAAK,GAAG,MAAM,wBAAO,CAAC,KAAK,CAAC;YAChC,GAAG,EAAE,mCAAqB;SAC3B,CAAC,CAAC;QACH,eAAM,CAAC,KAAK,CACV,qDAAqD,IAAI,CAAC,SAAS,CACjE,KAAK,CACN,EAAE,CACJ,CAAC;QACF,+BAA+B;QAC/B,OAAO,CAAC,CAAC,MAAM,6BAA6B,EAAE,CAAC,EAAE;YAC/C,MAAM,IAAA,eAAK,EAAC,EAAE,CAAC,CAAC;SACjB;KACF;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CACV,sEAAsE,CAAC,CAAC,QAAQ,EAAE,CACnF,CAAC;KACH;AACH,CAAC;AA3BD,wDA2BC;AAEM,KAAK,UAAU,qBAAqB;IACzC,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,wBAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,mCAAqB,EAAE,CAAC,CAAC;QACnE,eAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7D,eAAM,CAAC,KAAK,CACV,uDAAuD,IAAI,CAAC,SAAS,CACnE,OAAO,CACR,EAAE,CACJ,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CACV,qEAAqE,CAAC,CAAC,OAAO,EAAE,CACjF,CAAC;KACH;AACH,CAAC;AAdD,sDAcC"}
1
+ {"version":3,"file":"rabbitmq-connection.js","sourceRoot":"","sources":["../../src/local-connection/rabbitmq-connection.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAC9D,6BAA6B;AAC7B,6DAAmD;AACnD,qDAG6B;AAC7B,2CAAwC;AACxC,yCAAkC;AAClC,2CAAoD;AAEvC,QAAA,mBAAmB,GAAG,kBAAkB,CAAC;AACzC,QAAA,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D,KAAK,UAAU,6BAA6B;IACjD,eAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,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IAAI;QACF,MAAM,OAAO,GAAG,MAAM,wBAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAA,sCAAwB,GAAE,EAAE,CAAC,CAAC;QACxE,eAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7D,eAAM,CAAC,KAAK,CACV,uDAAuD,IAAI,CAAC,SAAS,CACnE,OAAO,CACR,EAAE,CACJ,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CACV,qEAAqE,IAAA,qBAAc,EACjF,CAAC,CACF,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AAhBD,sDAgBC"}
@@ -1,23 +1,15 @@
1
- export declare type SecureTunnelPortInfo = {
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?: SecureTunnelShadowDesRep;
12
- desired?: SecureTunnelShadowDesRep;
3
+ reported?: SecureTunnelShadowUpdate;
4
+ desired?: SecureTunnelShadowUpdate;
13
5
  };
14
6
  export declare type SecureTunnelShadowUpdateDelta = {
15
7
  version: number;
16
8
  timestamp: number;
17
- state: SecureTunnelShadowDesRep;
9
+ state: SecureTunnelShadowUpdate;
18
10
  metadata?: any;
19
11
  };
20
- export declare type SecureTunnelShadowUpdate = {
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 localproxyInfo;
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 {SecureTunnelShadowDesRep} - reported state of the SecureTunnel shadow
44
+ * @returns {SecureTunnelShadowUpdate} - reported state of the SecureTunnel shadow
53
45
  */
54
- getSecureTunnelShadow(): SecureTunnelShadowDesRep;
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 {SecureTunnelShadowDesRep} update reported message to send back to AWS IoT device shadow
50
+ * @return {SecureTunnelShadowUpdate} update reported message to send back to AWS IoT device shadow
59
51
  */
60
- syncShadowToDeviceState(deltaMsg: SecureTunnelShadowUpdateDelta): Promise<SecureTunnelShadowDesRep>;
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 localproxy process
74
+ * Starts SecureTunnel localProxy process
83
75
  */
84
- private startLocalproxy;
76
+ private startLocalProxy;
85
77
  /**
86
- * Stops SecureTunnel localproxy process
78
+ * Stops SecureTunnel local proxy process
87
79
  */
88
- private stopLocalproxy;
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 localproxy, if it was not downloaded before
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-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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 cloud_mode_ready_1 = require("../util/cloud-mode-ready");
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.localproxyInfo = {
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.stopLocalproxy();
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 {SecureTunnelShadowDesRep} - reported state of the SecureTunnel shadow
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 {SecureTunnelShadowDesRep} update reported message to send back to AWS IoT device shadow
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.stopLocalproxy();
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.stopLocalproxy();
158
+ await this.stopLocalProxy();
159
159
  this.processNotifyMessage(message);
160
160
  await this.downloadSecureTunnel();
161
- await this.startLocalproxy();
161
+ await this.startLocalProxy();
162
162
  }
163
- catch (error) {
164
- logger_1.logger.error(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.localproxyInfo)}`);
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 (error) {
233
- logger_1.logger.error(`ERROR: starting socat for: ${portInfo.ip}:${portInfo.port} on localhost port: ${localPort}, error: ${error}`);
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('ERROR: killing socat process:', e);
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 localproxy process
270
+ * Starts SecureTunnel localProxy process
271
271
  */
272
- async startLocalproxy() {
273
- logger_1.logger.debug('-> SecureTunnelHandlerSingleton.startLocalproxy');
272
+ async startLocalProxy() {
273
+ logger_1.logger.debug('-> SecureTunnelHandlerSingleton.startLocalProxy');
274
274
  const args = [
275
275
  '--destination-app',
276
- this.localproxyInfo.lpServices,
276
+ this.localProxyInfo.lpServices,
277
277
  '--region',
278
- this.localproxyInfo.lpRegion,
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.localproxyInfo.lpDstAccessKey
284
+ this.localProxyInfo.lpDstAccessKey
285
285
  ];
286
- this.localproxyInfo.lpProcess = await (0, spawner_detached_1.runDetachedProcess)(directories_1.SECURE_TUNNEL_BIN_PATH, args);
287
- logger_1.logger.debug('<- SecureTunnelHandlerSingleton.startLocalproxy');
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 localproxy process
290
+ * Stops SecureTunnel local proxy process
291
291
  */
292
- async stopLocalproxy() {
293
- logger_1.logger.debug('-> SecureTunnelHandlerSingleton.stopLocalproxy');
294
- if (!this.localproxyInfo.lpProcess) {
295
- logger_1.logger.debug('No localproxy process running');
296
- logger_1.logger.debug('<- SecureTunnelHandlerSingleton.stopLocalproxy');
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 localproxy: ${this.localproxyInfo.lpDstAccessKey}`);
301
- await (0, spawner_detached_1.killDetachedProcess)(this.localproxyInfo.lpProcess, [
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 localproxy process');
304
+ logger_1.logger.debug('SUCCESS: killing local proxy process');
305
305
  }
306
306
  catch (e) {
307
- logger_1.logger.error('ERROR: killing localproxy process:', e);
307
+ logger_1.logger.error(`ERROR: killing local proxy process:\n${(0, util_1.stringifyError)(e)}`);
308
308
  }
309
- this.localproxyInfo = {
309
+ this.localProxyInfo = {
310
310
  lpDstAccessKey: '',
311
311
  lpRegion: '',
312
312
  lpServices: '',
313
313
  lpProcess: null
314
314
  };
315
- logger_1.logger.debug('<- SecureTunnelHandlerSingleton.stopLocalproxy');
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, cloud_mode_ready_1.isValidAwsRegion)(region)) {
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.localproxyInfo.lpDstAccessKey = clientAccessToken;
370
- this.localproxyInfo.lpRegion = region;
371
- this.localproxyInfo.lpServices = portMappingList.join(',');
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(`localproxyInfo = ${JSON.stringify(this.localproxyInfo)}`);
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 localproxy, if it was not downloaded before
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 localproxy ...');
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
- await (0, download_file_1.downloadFile)({
394
- url,
395
- path: directories_1.SECURE_TUNNEL_BIN_PATH,
396
- errorMessage: `Secure Tunnel bin for ${linuxDistro} ${osVersion} ${arch} not found}`
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]