@alwaysai/device-agent 1.3.0-1 → 1.3.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application-control/environment-variables.d.ts +1 -0
- package/lib/application-control/environment-variables.d.ts.map +1 -1
- package/lib/application-control/environment-variables.js +22 -20
- package/lib/application-control/environment-variables.js.map +1 -1
- package/lib/application-control/environment-variables.test.js +37 -2
- package/lib/application-control/environment-variables.test.js.map +1 -1
- package/lib/application-control/install.js +1 -1
- package/lib/application-control/install.js.map +1 -1
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts +4 -3
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
- package/lib/cloud-connection/device-agent-cloud-connection.js +149 -113
- package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
- package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -1
- package/lib/cloud-connection/live-updates-handler.js +30 -25
- package/lib/cloud-connection/live-updates-handler.js.map +1 -1
- package/lib/cloud-connection/live-updates-handler.test.js +15 -0
- package/lib/cloud-connection/live-updates-handler.test.js.map +1 -1
- package/lib/cloud-connection/messages.d.ts +1 -3
- package/lib/cloud-connection/messages.d.ts.map +1 -1
- package/lib/cloud-connection/messages.js +1 -9
- package/lib/cloud-connection/messages.js.map +1 -1
- package/lib/cloud-connection/publisher.d.ts +1 -0
- package/lib/cloud-connection/publisher.d.ts.map +1 -1
- package/lib/cloud-connection/publisher.js +3 -0
- package/lib/cloud-connection/publisher.js.map +1 -1
- package/lib/cloud-connection/shadow-handler.d.ts +12 -0
- package/lib/cloud-connection/shadow-handler.d.ts.map +1 -1
- package/lib/cloud-connection/shadow-handler.js +36 -22
- package/lib/cloud-connection/shadow-handler.js.map +1 -1
- package/lib/cloud-connection/shadow-handler.test.js +84 -40
- package/lib/cloud-connection/shadow-handler.test.js.map +1 -1
- package/lib/cloud-connection/transaction-manager.d.ts +25 -9
- package/lib/cloud-connection/transaction-manager.d.ts.map +1 -1
- package/lib/cloud-connection/transaction-manager.js +97 -28
- package/lib/cloud-connection/transaction-manager.js.map +1 -1
- package/lib/cloud-connection/transaction-manager.test.js +169 -22
- package/lib/cloud-connection/transaction-manager.test.js.map +1 -1
- package/lib/secure-tunneling/secure-tunneling.d.ts +105 -0
- package/lib/secure-tunneling/secure-tunneling.d.ts.map +1 -0
- package/lib/secure-tunneling/secure-tunneling.js +435 -0
- package/lib/secure-tunneling/secure-tunneling.js.map +1 -0
- package/lib/secure-tunneling/secure-tunneling.test.d.ts +2 -0
- package/lib/secure-tunneling/secure-tunneling.test.d.ts.map +1 -0
- package/lib/secure-tunneling/secure-tunneling.test.js +1070 -0
- package/lib/secure-tunneling/secure-tunneling.test.js.map +1 -0
- package/lib/secure-tunneling/spawner-detached.d.ts +6 -0
- package/lib/secure-tunneling/spawner-detached.d.ts.map +1 -0
- package/lib/secure-tunneling/spawner-detached.js +90 -0
- package/lib/secure-tunneling/spawner-detached.js.map +1 -0
- package/lib/subcommands/app/analytics.d.ts +10 -0
- package/lib/subcommands/app/analytics.d.ts.map +1 -0
- package/lib/subcommands/app/analytics.js +83 -0
- package/lib/subcommands/app/analytics.js.map +1 -0
- package/lib/subcommands/app/index.d.ts.map +1 -1
- package/lib/subcommands/app/index.js +3 -1
- package/lib/subcommands/app/index.js.map +1 -1
- package/lib/subcommands/app/models.d.ts +0 -5
- package/lib/subcommands/app/models.d.ts.map +1 -1
- package/lib/subcommands/app/models.js +11 -47
- package/lib/subcommands/app/models.js.map +1 -1
- package/lib/subcommands/app/status.d.ts +1 -0
- package/lib/subcommands/app/status.d.ts.map +1 -1
- package/lib/subcommands/app/status.js +14 -3
- package/lib/subcommands/app/status.js.map +1 -1
- package/lib/subcommands/app/version.d.ts +2 -1
- package/lib/subcommands/app/version.d.ts.map +1 -1
- package/lib/subcommands/app/version.js +16 -3
- package/lib/subcommands/app/version.js.map +1 -1
- package/lib/util/cloud-mode-ready.d.ts +1 -0
- package/lib/util/cloud-mode-ready.d.ts.map +1 -1
- package/lib/util/cloud-mode-ready.js +36 -1
- package/lib/util/cloud-mode-ready.js.map +1 -1
- package/lib/util/parsing.d.ts +2 -0
- package/lib/util/parsing.d.ts.map +1 -0
- package/lib/util/parsing.js +17 -0
- package/lib/util/parsing.js.map +1 -0
- package/package.json +4 -6
- package/readme.md +146 -92
- package/src/application-control/environment-variables.test.ts +43 -3
- package/src/application-control/environment-variables.ts +29 -19
- package/src/application-control/install.ts +1 -1
- package/src/cloud-connection/device-agent-cloud-connection.ts +216 -172
- package/src/cloud-connection/live-updates-handler.test.ts +20 -0
- package/src/cloud-connection/live-updates-handler.ts +45 -52
- package/src/cloud-connection/messages.ts +1 -14
- package/src/cloud-connection/publisher.ts +4 -0
- package/src/cloud-connection/shadow-handler.test.ts +93 -41
- package/src/cloud-connection/shadow-handler.ts +57 -21
- package/src/cloud-connection/transaction-manager.test.ts +183 -27
- package/src/cloud-connection/transaction-manager.ts +167 -36
- package/src/secure-tunneling/secure-tunneling.test.ts +1239 -0
- package/src/secure-tunneling/secure-tunneling.ts +606 -0
- package/src/secure-tunneling/spawner-detached.ts +107 -0
- package/src/subcommands/app/analytics.ts +99 -0
- package/src/subcommands/app/index.ts +4 -3
- package/src/subcommands/app/models.ts +13 -49
- package/src/subcommands/app/status.ts +20 -3
- package/src/subcommands/app/version.ts +19 -4
- package/src/util/cloud-mode-ready.ts +36 -0
- package/src/util/parsing.ts +11 -0
- package/lib/cloud-connection/cmd-status.d.ts +0 -8
- package/lib/cloud-connection/cmd-status.d.ts.map +0 -1
- package/lib/cloud-connection/cmd-status.js +0 -62
- package/lib/cloud-connection/cmd-status.js.map +0 -1
- package/lib/cloud-connection/message-builder.d.ts +0 -7
- package/lib/cloud-connection/message-builder.d.ts.map +0 -1
- package/lib/cloud-connection/message-builder.js +0 -63
- package/lib/cloud-connection/message-builder.js.map +0 -1
- package/lib/secure-tunneling/index.d.ts +0 -5
- package/lib/secure-tunneling/index.d.ts.map +0 -1
- package/lib/secure-tunneling/index.js +0 -64
- package/lib/secure-tunneling/index.js.map +0 -1
- package/src/cloud-connection/cmd-status.ts +0 -71
- package/src/cloud-connection/message-builder.ts +0 -117
- package/src/secure-tunneling/index.ts +0 -74
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CliFlagInput,
|
|
3
|
+
CliLeaf,
|
|
4
|
+
CliNumberInput,
|
|
5
|
+
CliStringInput
|
|
6
|
+
} from '@alwaysai/alwayscli';
|
|
7
|
+
import { readAppCfgFile } from '../../application-control';
|
|
8
|
+
import { DeviceAgentCloudConnection } from '../../cloud-connection/device-agent-cloud-connection';
|
|
9
|
+
import sleep from '../../util/sleep';
|
|
10
|
+
import { logger } from '../../util/logger';
|
|
11
|
+
import { assign, merge } from 'lodash';
|
|
12
|
+
|
|
13
|
+
export const getAnalyticsCfgCliLeaf = CliLeaf({
|
|
14
|
+
name: 'get-analytics-cfg',
|
|
15
|
+
description: 'Get analytics configuration for an application',
|
|
16
|
+
namedInputs: {
|
|
17
|
+
project: CliStringInput({
|
|
18
|
+
description: 'Project Id',
|
|
19
|
+
required: true
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
async action(_, opts) {
|
|
23
|
+
const { project } = opts;
|
|
24
|
+
const appCfg = await readAppCfgFile({ projectId: project });
|
|
25
|
+
if (appCfg.analytics !== undefined) {
|
|
26
|
+
console.log(JSON.stringify(appCfg.analytics, null, 2));
|
|
27
|
+
} else {
|
|
28
|
+
console.log('No analytics configuration for app!');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const setAnalyticsCfgCliLeaf = CliLeaf({
|
|
34
|
+
name: 'set-analytics-cfg',
|
|
35
|
+
description:
|
|
36
|
+
'Set analytics configuration for an application. Note that this resets the config so all desired options must be set',
|
|
37
|
+
namedInputs: {
|
|
38
|
+
project: CliStringInput({
|
|
39
|
+
description: 'Project Id',
|
|
40
|
+
required: true
|
|
41
|
+
}),
|
|
42
|
+
'enable-cloud-publish': CliFlagInput({
|
|
43
|
+
description: 'Enable publishing analytics to cloud'
|
|
44
|
+
}),
|
|
45
|
+
'enable-file-publish': CliFlagInput({
|
|
46
|
+
description: 'Enable publishing analytics to file'
|
|
47
|
+
}),
|
|
48
|
+
'file-size-bytes': CliNumberInput({
|
|
49
|
+
description: 'Set the max file size in bytes for analytics file writing',
|
|
50
|
+
required: false
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
async action(
|
|
54
|
+
_,
|
|
55
|
+
{
|
|
56
|
+
project,
|
|
57
|
+
'enable-cloud-publish': enableCLoudPublish,
|
|
58
|
+
'enable-file-publish': enableFilePublish,
|
|
59
|
+
'file-size-bytes': fileSizeBytes
|
|
60
|
+
}
|
|
61
|
+
) {
|
|
62
|
+
const deviceAgent = new DeviceAgentCloudConnection();
|
|
63
|
+
await deviceAgent.setupHandlers();
|
|
64
|
+
|
|
65
|
+
const newAppCfg = {
|
|
66
|
+
analytics: {
|
|
67
|
+
enable_cloud_publish: enableCLoudPublish,
|
|
68
|
+
enable_file_publish: enableFilePublish,
|
|
69
|
+
file_size_bytes: fileSizeBytes
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const existingAppCfg = await readAppCfgFile({ projectId: project });
|
|
73
|
+
const appCfg = assign(existingAppCfg, merge(existingAppCfg, newAppCfg));
|
|
74
|
+
|
|
75
|
+
// Update the shadow as a client
|
|
76
|
+
const topic = deviceAgent.getShadowTopics().projects.update;
|
|
77
|
+
const packet = {
|
|
78
|
+
state: {
|
|
79
|
+
desired: {
|
|
80
|
+
[project]: {
|
|
81
|
+
appConfig: JSON.stringify(appCfg) // Pack app config as string as dictated by schema
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
clientToken: 'client'
|
|
86
|
+
};
|
|
87
|
+
logger.debug(
|
|
88
|
+
`Publishing message:\n${JSON.stringify({ topic, packet }, null, 2)}`
|
|
89
|
+
);
|
|
90
|
+
deviceAgent.publisher.publish(topic, JSON.stringify(packet));
|
|
91
|
+
// Sleep for extra time to ensure time for shadow response
|
|
92
|
+
await sleep(10000);
|
|
93
|
+
|
|
94
|
+
while (deviceAgent.isCmdInProgress(project)) {
|
|
95
|
+
await sleep(1000);
|
|
96
|
+
}
|
|
97
|
+
await deviceAgent.stop();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
addModelCliLeaf,
|
|
6
6
|
removeModelCliLeaf,
|
|
7
7
|
replaceModelsCliLeaf,
|
|
8
|
-
updateModelsCliLeaf
|
|
9
|
-
installModelCliLeaf
|
|
8
|
+
updateModelsCliLeaf
|
|
10
9
|
} from './models';
|
|
11
10
|
import {
|
|
12
11
|
getAppStatusCliLeaf,
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
rollbackAppCliLeaf
|
|
23
22
|
} from './version';
|
|
24
23
|
import { getShadowCliLeaf, updateShadowCliLeaf } from './shadow';
|
|
24
|
+
import { getAnalyticsCfgCliLeaf, setAnalyticsCfgCliLeaf } from './analytics';
|
|
25
25
|
|
|
26
26
|
export const appCliBranch = CliBranch({
|
|
27
27
|
name: 'app',
|
|
@@ -40,10 +40,11 @@ export const appCliBranch = CliBranch({
|
|
|
40
40
|
addModelCliLeaf,
|
|
41
41
|
removeModelCliLeaf,
|
|
42
42
|
replaceModelsCliLeaf,
|
|
43
|
-
installModelCliLeaf,
|
|
44
43
|
updateModelsCliLeaf,
|
|
45
44
|
getAllEnvsCliLeaf,
|
|
46
45
|
setEnvCliLeaf,
|
|
46
|
+
getAnalyticsCfgCliLeaf,
|
|
47
|
+
setAnalyticsCfgCliLeaf,
|
|
47
48
|
getShadowCliLeaf,
|
|
48
49
|
updateShadowCliLeaf
|
|
49
50
|
]
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../../application-control';
|
|
14
14
|
import { DeviceAgentCloudConnection } from '../../cloud-connection/device-agent-cloud-connection';
|
|
15
15
|
import sleep from '../../util/sleep';
|
|
16
|
+
import { logger } from '../../util/logger';
|
|
16
17
|
|
|
17
18
|
export const showAppModelsCliLeaf = CliLeaf({
|
|
18
19
|
name: 'show-models',
|
|
@@ -52,66 +53,29 @@ export const addModelCliLeaf = CliLeaf({
|
|
|
52
53
|
const deviceAgent = new DeviceAgentCloudConnection();
|
|
53
54
|
await deviceAgent.setupHandlers();
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
// Update the shadow as a client
|
|
57
|
+
const topic = deviceAgent.getShadowTopics().projects.update;
|
|
56
58
|
|
|
57
59
|
const newAppCfg = await readAppCfgFile({ projectId: project });
|
|
58
60
|
newAppCfg.models[model] = Number(version);
|
|
59
61
|
|
|
60
|
-
const
|
|
61
|
-
version: 3,
|
|
62
|
-
timestamp: 0,
|
|
62
|
+
const packet = {
|
|
63
63
|
state: {
|
|
64
|
-
|
|
65
|
-
appConfig: JSON.stringify(newAppCfg)
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
clientToken: 'not-self'
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
await deviceAgent.handleMessage(topic, message);
|
|
72
|
-
while (deviceAgent.isCmdInProgress(project)) {
|
|
73
|
-
await sleep(1000);
|
|
74
|
-
}
|
|
75
|
-
await deviceAgent.stop();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export const installModelCliLeaf = CliLeaf({
|
|
80
|
-
name: 'install-model',
|
|
81
|
-
description: 'Install an alwaysAI model to a project',
|
|
82
|
-
namedInputs: {
|
|
83
|
-
project: CliStringInput({
|
|
84
|
-
description: 'Project ID',
|
|
85
|
-
required: true
|
|
86
|
-
}),
|
|
87
|
-
modelName: CliStringInput({
|
|
88
|
-
description: 'Model Name',
|
|
89
|
-
required: true
|
|
90
|
-
}),
|
|
91
|
-
modelVersion: CliNumberInput({
|
|
92
|
-
description: 'Model Version',
|
|
93
|
-
required: true
|
|
94
|
-
})
|
|
95
|
-
},
|
|
96
|
-
async action(_, opts) {
|
|
97
|
-
const { project, modelName, modelVersion } = opts;
|
|
98
|
-
const deviceAgent = new DeviceAgentCloudConnection();
|
|
99
|
-
await deviceAgent.setupHandlers();
|
|
100
|
-
const topic = deviceAgent.getShadowTopics().projects.getAccepted;
|
|
101
|
-
const newAppCfg = await readAppCfgFile({ projectId: project });
|
|
102
|
-
newAppCfg['models'][modelName] = modelVersion;
|
|
103
|
-
|
|
104
|
-
const message = {
|
|
105
|
-
state: {
|
|
106
|
-
delta: {
|
|
64
|
+
desired: {
|
|
107
65
|
[project]: {
|
|
108
66
|
appConfig: JSON.stringify(newAppCfg)
|
|
109
67
|
}
|
|
110
68
|
}
|
|
111
69
|
},
|
|
112
|
-
clientToken:
|
|
70
|
+
clientToken: 'client'
|
|
113
71
|
};
|
|
114
|
-
|
|
72
|
+
logger.debug(
|
|
73
|
+
`Publishing message:\n${JSON.stringify({ topic, packet }, null, 2)}`
|
|
74
|
+
);
|
|
75
|
+
deviceAgent.publisher.publish(topic, JSON.stringify(packet));
|
|
76
|
+
// Sleep for extra time to ensure time for shadow response
|
|
77
|
+
await sleep(10000);
|
|
78
|
+
|
|
115
79
|
while (deviceAgent.isCmdInProgress(project)) {
|
|
116
80
|
await sleep(1000);
|
|
117
81
|
}
|
|
@@ -32,13 +32,30 @@ export const startAppCliLeaf = CliLeaf({
|
|
|
32
32
|
description: 'Project ID',
|
|
33
33
|
required: true
|
|
34
34
|
}),
|
|
35
|
-
|
|
35
|
+
'docker-login-token': CliStringInput({
|
|
36
36
|
description: 'Docker login token'
|
|
37
|
+
}),
|
|
38
|
+
dockerLoginToken: CliStringInput({
|
|
39
|
+
description: 'Docker login token',
|
|
40
|
+
hidden: true
|
|
37
41
|
})
|
|
38
42
|
},
|
|
39
43
|
async action(_, opts) {
|
|
40
|
-
const {
|
|
41
|
-
|
|
44
|
+
const {
|
|
45
|
+
project,
|
|
46
|
+
dockerLoginToken,
|
|
47
|
+
'docker-login-token': dockerLoginTokenNew
|
|
48
|
+
} = opts;
|
|
49
|
+
if (dockerLoginToken) {
|
|
50
|
+
logger.warn(
|
|
51
|
+
`--dockerLoginToken is deprecated and will be removed in a future release. Please switch to --docker-login-token`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const dockerLoginTokenResolved = dockerLoginTokenNew || dockerLoginToken;
|
|
55
|
+
await startApp({
|
|
56
|
+
projectId: project,
|
|
57
|
+
dockerLoginToken: dockerLoginTokenResolved
|
|
58
|
+
});
|
|
42
59
|
}
|
|
43
60
|
});
|
|
44
61
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliLeaf, CliStringInput } from '@alwaysai/alwayscli';
|
|
1
|
+
import { CliLeaf, CliStringInput, CliTerseError } from '@alwaysai/alwayscli';
|
|
2
2
|
import {
|
|
3
3
|
AppVersionControlMessage,
|
|
4
4
|
generateTxId,
|
|
@@ -8,6 +8,7 @@ import { rollbackApp } from '../../application-control';
|
|
|
8
8
|
import { DeviceAgentCloudConnection } from '../../cloud-connection/device-agent-cloud-connection';
|
|
9
9
|
import { AgentConfigFile } from '../../infrastructure/agent-config';
|
|
10
10
|
import sleep from '../../util/sleep';
|
|
11
|
+
import { logger } from '../../util/logger';
|
|
11
12
|
|
|
12
13
|
export const listAppsCliLeaf = CliLeaf({
|
|
13
14
|
name: 'list',
|
|
@@ -27,13 +28,27 @@ export const installAppCliLeaf = CliLeaf({
|
|
|
27
28
|
description: 'Project ID',
|
|
28
29
|
required: true
|
|
29
30
|
}),
|
|
31
|
+
'release-hash': CliStringInput({
|
|
32
|
+
description: 'Release Hash',
|
|
33
|
+
required: false
|
|
34
|
+
}),
|
|
30
35
|
releaseHash: CliStringInput({
|
|
31
36
|
description: 'Release Hash',
|
|
32
|
-
required:
|
|
37
|
+
required: false,
|
|
38
|
+
hidden: true
|
|
33
39
|
})
|
|
34
40
|
},
|
|
35
41
|
async action(_, opts) {
|
|
36
|
-
const { project, releaseHash } = opts;
|
|
42
|
+
const { project, releaseHash, 'release-hash': releaseHashNew } = opts;
|
|
43
|
+
if (releaseHash) {
|
|
44
|
+
logger.warn(
|
|
45
|
+
`--releaseHash is deprecated and will be removed in a future release. Please switch to --release-hash`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const releaseHashResolved = releaseHashNew || releaseHash;
|
|
49
|
+
if (releaseHashResolved === undefined) {
|
|
50
|
+
throw new CliTerseError('--release-hash flag is required!');
|
|
51
|
+
}
|
|
37
52
|
const deviceAgent = new DeviceAgentCloudConnection();
|
|
38
53
|
await deviceAgent.setupHandlers();
|
|
39
54
|
const topic = deviceAgent.getToDeviceTopic();
|
|
@@ -45,7 +60,7 @@ export const installAppCliLeaf = CliLeaf({
|
|
|
45
60
|
payload: {
|
|
46
61
|
baseCommand: keyMirrors.appVersionControl.install,
|
|
47
62
|
projectId: project,
|
|
48
|
-
appReleaseHash:
|
|
63
|
+
appReleaseHash: releaseHashResolved
|
|
49
64
|
}
|
|
50
65
|
};
|
|
51
66
|
await deviceAgent.handleMessage(topic, message);
|
|
@@ -5,6 +5,42 @@ import {
|
|
|
5
5
|
DEVICE_CERTIFICATE_FILE_PATH
|
|
6
6
|
} from '../util/directories';
|
|
7
7
|
|
|
8
|
+
const VALID_AWS_REGIONS = [
|
|
9
|
+
// 'af-south-1', // Africa (Cape Town)
|
|
10
|
+
// 'ap-east-1', // Asia Pacific (Hong Kong)
|
|
11
|
+
// 'ap-south-2', // Asia Pacific (Hyderabad)
|
|
12
|
+
// 'ap-northeast-1', // Asia Pacific (Tokyo)
|
|
13
|
+
// 'ap-northeast-2', // Asia Pacific (Seoul)
|
|
14
|
+
// 'ap-northeast-3', // Asia Pacific (Osaka)
|
|
15
|
+
// 'ap-south-1', // Asia Pacific (Mumbai)
|
|
16
|
+
// 'ap-southeast-1', // Asia Pacific (Singapore)
|
|
17
|
+
// 'ap-southeast-2', // Asia Pacific (Sydney)
|
|
18
|
+
// 'ap-southeast-3', // Asia Pacific (Jakarta)
|
|
19
|
+
// 'ap-southeast-4', // Asia Pacific (Melbourne)
|
|
20
|
+
// 'ca-central-1', // Canada (Central)
|
|
21
|
+
// 'ca-west-1', // Canada West (Calgary)
|
|
22
|
+
// 'eu-west-2', // Europe (London)
|
|
23
|
+
// 'eu-west-3', // Europe (Paris)
|
|
24
|
+
// 'eu-central-1', // Europe (Frankfurt)
|
|
25
|
+
// 'eu-central-2', // Europe (Zurich)
|
|
26
|
+
// 'eu-north-1', // Europe (Stockholm)
|
|
27
|
+
// 'eu-south-1', // Europe (Milan)
|
|
28
|
+
// 'eu-south-2', // Europe (Spain)
|
|
29
|
+
// 'eu-west-1', // Europe (Ireland)
|
|
30
|
+
// 'il-central-1', // Israel (Tel Aviv)
|
|
31
|
+
// 'me-south-1', // Middle East (Bahrain)
|
|
32
|
+
// 'me-central-1', // Middle East (UAE)
|
|
33
|
+
// 'sa-east-1' // South America (São Paulo)
|
|
34
|
+
// 'us-east-2', // US East (Ohio)
|
|
35
|
+
// 'us-east-1', // US East (Virginia)
|
|
36
|
+
// 'us-west-1', // US West (N. California)
|
|
37
|
+
'us-west-2' // US West (Oregon)
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function isValidAwsRegion(region: string): boolean {
|
|
41
|
+
return VALID_AWS_REGIONS.includes(region);
|
|
42
|
+
}
|
|
43
|
+
|
|
8
44
|
export function cloudModeReady() {
|
|
9
45
|
let ready = true;
|
|
10
46
|
const requiredFiles = [
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function replaceFalseyWithNull(object: object, recurse?: boolean) {
|
|
2
|
+
if (typeof object === 'string' || object instanceof String) return;
|
|
3
|
+
|
|
4
|
+
object &&
|
|
5
|
+
Object.keys(object).forEach((key: string) => {
|
|
6
|
+
if (recurse) {
|
|
7
|
+
replaceFalseyWithNull(object[key], recurse);
|
|
8
|
+
}
|
|
9
|
+
if (!object[key]) object[key] = null;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cmd-status.d.ts","sourceRoot":"","sources":["../../src/cloud-connection/cmd-status.ts"],"names":[],"mappings":"AA0BA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAA0C;IAEzC,KAAK,CAAC,SAAS,EAAE,MAAM;IAevB,IAAI,CAAC,SAAS,EAAE,MAAM;IAW5B,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAO3C,gBAAgB;CAQxB"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CmdStatusManager = void 0;
|
|
4
|
-
const logger_1 = require("../util/logger");
|
|
5
|
-
class CmdStatus {
|
|
6
|
-
constructor(projectId, status) {
|
|
7
|
-
this.projectId = projectId;
|
|
8
|
-
this.status = status;
|
|
9
|
-
}
|
|
10
|
-
getProjectId() {
|
|
11
|
-
return this.projectId;
|
|
12
|
-
}
|
|
13
|
-
update(status) {
|
|
14
|
-
this.status = status;
|
|
15
|
-
}
|
|
16
|
-
getStatus() {
|
|
17
|
-
return this.status;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
class CmdStatusManager {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.apps = {};
|
|
23
|
-
}
|
|
24
|
-
async start(projectId) {
|
|
25
|
-
if (!(projectId in this.apps)) {
|
|
26
|
-
const cmdStatus = new CmdStatus(projectId, 'in_progress');
|
|
27
|
-
this.apps[projectId] = cmdStatus;
|
|
28
|
-
}
|
|
29
|
-
else if (this.apps[projectId].getStatus() !== 'in_progress') {
|
|
30
|
-
this.apps[projectId].update('in_progress');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
logger_1.logger.debug(`Ignoring start for ${projectId} since it already has a command in progress`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
logger_1.logger.debug(`Started command for ${projectId}`);
|
|
37
|
-
}
|
|
38
|
-
async stop(projectId) {
|
|
39
|
-
if (!(projectId in this.apps) ||
|
|
40
|
-
this.apps[projectId].getStatus() === 'idle') {
|
|
41
|
-
throw new Error(`No ongoing command to stop for ${projectId}`);
|
|
42
|
-
}
|
|
43
|
-
this.apps[projectId].update('idle');
|
|
44
|
-
logger_1.logger.debug(`Stopped command for ${projectId}`);
|
|
45
|
-
}
|
|
46
|
-
isCmdInProgress(projectId) {
|
|
47
|
-
if (!(projectId in this.apps)) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
return this.apps[projectId].getStatus() === 'in_progress';
|
|
51
|
-
}
|
|
52
|
-
anyCmdInProgress() {
|
|
53
|
-
for (const projectId in this.apps) {
|
|
54
|
-
if (this.apps[projectId].getStatus() === 'in_progress') {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.CmdStatusManager = CmdStatusManager;
|
|
62
|
-
//# sourceMappingURL=cmd-status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cmd-status.js","sourceRoot":"","sources":["../../src/cloud-connection/cmd-status.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAIxC,MAAM,SAAS;IAIb,YAAY,SAAiB,EAAE,MAAqB;QAClD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,MAAqB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAED,MAAa,gBAAgB;IAA7B;QACU,SAAI,GAAuC,EAAE,CAAC;IA2CxD,CAAC;IAzCQ,KAAK,CAAC,KAAK,CAAC,SAAiB;QAClC,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE;YAC7B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;SAClC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,KAAK,aAAa,EAAE;YAC7D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;SAC5C;aAAM;YACL,eAAM,CAAC,KAAK,CACV,sBAAsB,SAAS,6CAA6C,CAC7E,CAAC;YACF,OAAO;SACR;QACD,eAAM,CAAC,KAAK,CAAC,uBAAuB,SAAS,EAAE,CAAC,CAAC;IACnD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,SAAiB;QACjC,IACE,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,KAAK,MAAM,EAC3C;YACA,MAAM,IAAI,KAAK,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC;SAChE;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,eAAM,CAAC,KAAK,CAAC,uBAAuB,SAAS,EAAE,CAAC,CAAC;IACnD,CAAC;IAEM,eAAe,CAAC,SAAiB;QACtC,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE;YAC7B,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,KAAK,aAAa,CAAC;IAC5D,CAAC;IAEM,gBAAgB;QACrB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE;YACjC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,KAAK,aAAa,EAAE;gBACtD,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA5CD,4CA4CC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AppLogsMessage, AppLogsPayload, AppStateMessage, AppStatePayload, DeviceStatsMessage, DeviceStatsPayload, SignedUrlsRequestMessage, SignedUrlsRequestPayload, StatusResponseMessage, StatusResponsePayload } from '@alwaysai/device-agent-schemas';
|
|
2
|
-
export declare function buildAppLogsMessage(payload: AppLogsPayload, txId?: string): Promise<AppLogsMessage>;
|
|
3
|
-
export declare function buildAppStateMessage(payload: AppStatePayload, txId?: string): Promise<AppStateMessage>;
|
|
4
|
-
export declare function buildSignedUrlsRequestMessage(payload: SignedUrlsRequestPayload, txId?: string): Promise<SignedUrlsRequestMessage>;
|
|
5
|
-
export declare function buildStatusResponseMessage(payload: StatusResponsePayload, txId?: string): Promise<StatusResponseMessage>;
|
|
6
|
-
export declare function buildDeviceStatsMessage(payload: DeviceStatsPayload, txId?: string): Promise<DeviceStatsMessage>;
|
|
7
|
-
//# sourceMappingURL=message-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-builder.d.ts","sourceRoot":"","sources":["../../src/cloud-connection/message-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAEd,cAAc,EACd,eAAe,EAEf,eAAe,EAEf,kBAAkB,EAElB,kBAAkB,EAClB,wBAAwB,EAExB,wBAAwB,EACxB,qBAAqB,EAErB,qBAAqB,EAKtB,MAAM,gCAAgC,CAAC;AAiBxC,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,cAAc,EACvB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CAUzB;AAGD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,eAAe,EACxB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAU1B;AAGD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,wBAAwB,EACjC,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAUnC;AAGD,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,EAC9B,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAGD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,kBAAkB,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAU7B"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildDeviceStatsMessage = exports.buildStatusResponseMessage = exports.buildSignedUrlsRequestMessage = exports.buildAppStateMessage = exports.buildAppLogsMessage = void 0;
|
|
4
|
-
const device_agent_schemas_1 = require("@alwaysai/device-agent-schemas");
|
|
5
|
-
const get_device_id_1 = require("../util/get-device-id");
|
|
6
|
-
function buildBaseClientMessage(txId) {
|
|
7
|
-
const clientId = (0, get_device_id_1.getDeviceUuid)();
|
|
8
|
-
const baseClientMessage = {
|
|
9
|
-
timestamp: new Date().toUTCString(),
|
|
10
|
-
deviceId: clientId,
|
|
11
|
-
topic: (0, device_agent_schemas_1.getToClientTopic)(clientId),
|
|
12
|
-
txId: txId || (0, device_agent_schemas_1.generateTxId)()
|
|
13
|
-
};
|
|
14
|
-
return baseClientMessage;
|
|
15
|
-
}
|
|
16
|
-
// Public Message Builders
|
|
17
|
-
// app logs
|
|
18
|
-
async function buildAppLogsMessage(payload, txId) {
|
|
19
|
-
const baseMessage = buildBaseClientMessage(txId);
|
|
20
|
-
const messageType = device_agent_schemas_1.keyMirrors.toClientMessageType.app_logs;
|
|
21
|
-
const message = Object.assign(Object.assign({}, baseMessage), { messageType,
|
|
22
|
-
payload });
|
|
23
|
-
return message;
|
|
24
|
-
}
|
|
25
|
-
exports.buildAppLogsMessage = buildAppLogsMessage;
|
|
26
|
-
// app state
|
|
27
|
-
async function buildAppStateMessage(payload, txId) {
|
|
28
|
-
const baseMessage = buildBaseClientMessage(txId);
|
|
29
|
-
const messageType = device_agent_schemas_1.keyMirrors.toClientMessageType.app_state;
|
|
30
|
-
const message = Object.assign(Object.assign({}, baseMessage), { messageType,
|
|
31
|
-
payload });
|
|
32
|
-
return message;
|
|
33
|
-
}
|
|
34
|
-
exports.buildAppStateMessage = buildAppStateMessage;
|
|
35
|
-
// signed URLs
|
|
36
|
-
async function buildSignedUrlsRequestMessage(payload, txId) {
|
|
37
|
-
const baseMessage = buildBaseClientMessage(txId);
|
|
38
|
-
const messageType = device_agent_schemas_1.keyMirrors.toCloudMessageType.signed_urls_request;
|
|
39
|
-
const message = Object.assign(Object.assign({}, baseMessage), { messageType,
|
|
40
|
-
payload });
|
|
41
|
-
return message;
|
|
42
|
-
}
|
|
43
|
-
exports.buildSignedUrlsRequestMessage = buildSignedUrlsRequestMessage;
|
|
44
|
-
// status response
|
|
45
|
-
async function buildStatusResponseMessage(payload, txId) {
|
|
46
|
-
const baseMessage = buildBaseClientMessage(txId);
|
|
47
|
-
const messageType = device_agent_schemas_1.keyMirrors.toClientMessageType.status_response;
|
|
48
|
-
const message = Object.assign(Object.assign({}, baseMessage), { messageType,
|
|
49
|
-
payload });
|
|
50
|
-
const valid = (0, device_agent_schemas_1.validateToDeviceAgentMessage)(message);
|
|
51
|
-
return message;
|
|
52
|
-
}
|
|
53
|
-
exports.buildStatusResponseMessage = buildStatusResponseMessage;
|
|
54
|
-
// device stats
|
|
55
|
-
async function buildDeviceStatsMessage(payload, txId) {
|
|
56
|
-
const messageType = device_agent_schemas_1.keyMirrors.toClientMessageType.device_stats;
|
|
57
|
-
const baseMessage = buildBaseClientMessage(txId);
|
|
58
|
-
const message = Object.assign(Object.assign({}, baseMessage), { messageType,
|
|
59
|
-
payload });
|
|
60
|
-
return message;
|
|
61
|
-
}
|
|
62
|
-
exports.buildDeviceStatsMessage = buildDeviceStatsMessage;
|
|
63
|
-
//# sourceMappingURL=message-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-builder.js","sourceRoot":"","sources":["../../src/cloud-connection/message-builder.ts"],"names":[],"mappings":";;;AAAA,yEAqBwC;AACxC,yDAAsD;AAEtD,SAAS,sBAAsB,CAAC,IAAa;IAC3C,MAAM,QAAQ,GAAG,IAAA,6BAAa,GAAE,CAAC;IACjC,MAAM,iBAAiB,GAAG;QACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,IAAA,uCAAgB,EAAC,QAAQ,CAAC;QACjC,IAAI,EAAE,IAAI,IAAI,IAAA,mCAAY,GAAE;KAC7B,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,0BAA0B;AAE1B,WAAW;AACJ,KAAK,UAAU,mBAAmB,CACvC,OAAuB,EACvB,IAAa;IAEb,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,WAAW,GACf,iCAAU,CAAC,mBAAmB,CAAC,QAAQ,CAAC;IAC1C,MAAM,OAAO,mCACR,WAAW,KACd,WAAW;QACX,OAAO,GACR,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,kDAaC;AAED,YAAY;AACL,KAAK,UAAU,oBAAoB,CACxC,OAAwB,EACxB,IAAa;IAEb,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,WAAW,GACf,iCAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC;IAC3C,MAAM,OAAO,mCACR,WAAW,KACd,WAAW;QACX,OAAO,GACR,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,oDAaC;AAED,cAAc;AACP,KAAK,UAAU,6BAA6B,CACjD,OAAiC,EACjC,IAAa;IAEb,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,WAAW,GACf,iCAAU,CAAC,kBAAkB,CAAC,mBAAmB,CAAC;IACpD,MAAM,OAAO,mCACR,WAAW,KACd,WAAW;QACX,OAAO,GACR,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,sEAaC;AAED,kBAAkB;AACX,KAAK,UAAU,0BAA0B,CAC9C,OAA8B,EAC9B,IAAa;IAEb,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,WAAW,GACf,iCAAU,CAAC,mBAAmB,CAAC,eAAe,CAAC;IACjD,MAAM,OAAO,mCACR,WAAW,KACd,WAAW;QACX,OAAO,GACR,CAAC;IACF,MAAM,KAAK,GAAG,IAAA,mDAA4B,EAAC,OAAO,CAAC,CAAC;IACpD,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,gEAcC;AAED,eAAe;AACR,KAAK,UAAU,uBAAuB,CAC3C,OAA2B,EAC3B,IAAa;IAEb,MAAM,WAAW,GACf,iCAAU,CAAC,mBAAmB,CAAC,YAAY,CAAC;IAC9C,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,OAAO,mCACR,WAAW,KACd,WAAW;QACX,OAAO,GACR,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,0DAaC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/secure-tunneling/index.ts"],"names":[],"mappings":"AAcA,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IACvD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,iBAuBA"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secureTunnelNotifyHandler = void 0;
|
|
4
|
-
const download_file_1 = require("../util/download-file");
|
|
5
|
-
const directories_1 = require("../util/directories");
|
|
6
|
-
const paths_1 = require("alwaysai/lib/paths");
|
|
7
|
-
const util_1 = require("alwaysai/lib/util");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const logger_1 = require("../util/logger");
|
|
10
|
-
const urls_1 = require("../urls");
|
|
11
|
-
const system_info_1 = require("../util/system-info");
|
|
12
|
-
async function secureTunnelNotifyHandler(message) {
|
|
13
|
-
const { clientAccessToken, region } = message;
|
|
14
|
-
await terminateSecureTunnelProcess();
|
|
15
|
-
await downloadSecureTunnel();
|
|
16
|
-
logger_1.logger.info('Starting Secure Tunnel');
|
|
17
|
-
const args = [
|
|
18
|
-
'--destination-app',
|
|
19
|
-
'22',
|
|
20
|
-
'--region',
|
|
21
|
-
region,
|
|
22
|
-
'--capath',
|
|
23
|
-
directories_1.AWS_ROOT_CERTIFICATE_FILE_PATH,
|
|
24
|
-
'--local-bind-address',
|
|
25
|
-
'0.0.0.0',
|
|
26
|
-
'-t',
|
|
27
|
-
clientAccessToken
|
|
28
|
-
];
|
|
29
|
-
await (0, util_1.JsSpawner)().run({
|
|
30
|
-
exe: `${directories_1.SECURE_TUNNEL_BIN_PATH}`,
|
|
31
|
-
args
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.secureTunnelNotifyHandler = secureTunnelNotifyHandler;
|
|
35
|
-
async function downloadSecureTunnel() {
|
|
36
|
-
const arch = await (0, system_info_1.getArch)();
|
|
37
|
-
const linuxDistro = await (0, system_info_1.getDistribution)();
|
|
38
|
-
const osVersion = await (0, system_info_1.getOsVersion)();
|
|
39
|
-
const url = `${urls_1.aaiArtifactsBucketUrl}/securetunnel/${linuxDistro}/${osVersion}/${arch}/${directories_1.SECURE_TUNNEL_BIN_NAME}`;
|
|
40
|
-
await (0, util_1.JsSpawner)().mkdirp((0, path_1.join)(paths_1.AAI_DIR, directories_1.SECURE_TUNNEL_BIN_DIR));
|
|
41
|
-
await (0, download_file_1.downloadFile)({
|
|
42
|
-
url,
|
|
43
|
-
path: directories_1.SECURE_TUNNEL_BIN_PATH,
|
|
44
|
-
errorMessage: `Secure Tunnel bin for ${linuxDistro} ${osVersion} ${arch} not found}`
|
|
45
|
-
});
|
|
46
|
-
const spawner = (0, util_1.JsSpawner)();
|
|
47
|
-
await spawner.run({
|
|
48
|
-
exe: 'chmod',
|
|
49
|
-
args: ['+x', directories_1.SECURE_TUNNEL_BIN_PATH]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async function terminateSecureTunnelProcess() {
|
|
53
|
-
const spawner = (0, util_1.JsSpawner)();
|
|
54
|
-
try {
|
|
55
|
-
await spawner.run({
|
|
56
|
-
exe: 'pkill',
|
|
57
|
-
args: [directories_1.SECURE_TUNNEL_BIN_NAME]
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
logger_1.logger.debug('Proccess terminated if status code is 1');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/secure-tunneling/index.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AACrD,qDAK6B;AAC7B,8CAA6C;AAC7C,4CAA8C;AAC9C,+BAA4B;AAC5B,2CAAwC;AACxC,kCAAgD;AAChD,qDAA6E;AAEtE,KAAK,UAAU,yBAAyB,CAAC,OAG/C;IACC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC9C,MAAM,4BAA4B,EAAE,CAAC;IACrC,MAAM,oBAAoB,EAAE,CAAC;IAC7B,eAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAI,GAAG;QACX,mBAAmB;QACnB,IAAI;QACJ,UAAU;QACV,MAAM;QACN,UAAU;QACV,4CAA8B;QAC9B,sBAAsB;QACtB,SAAS;QACT,IAAI;QACJ,iBAAiB;KAClB,CAAC;IAEF,MAAM,IAAA,gBAAS,GAAE,CAAC,GAAG,CAAC;QACpB,GAAG,EAAE,GAAG,oCAAsB,EAAE;QAChC,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AA1BD,8DA0BC;AAED,KAAK,UAAU,oBAAoB;IACjC,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAO,GAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,MAAM,IAAA,6BAAe,GAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAY,GAAE,CAAC;IAEvC,MAAM,GAAG,GAAG,GAAG,4BAAqB,iBAAiB,WAAW,IAAI,SAAS,IAAI,IAAI,IAAI,oCAAsB,EAAE,CAAC;IAElH,MAAM,IAAA,gBAAS,GAAE,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,eAAO,EAAE,mCAAqB,CAAC,CAAC,CAAC;IAC/D,MAAM,IAAA,4BAAY,EAAC;QACjB,GAAG;QACH,IAAI,EAAE,oCAAsB;QAC5B,YAAY,EAAE,yBAAyB,WAAW,IAAI,SAAS,IAAI,IAAI,aAAa;KACrF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,gBAAS,GAAE,CAAC;IAC5B,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,CAAC,IAAI,EAAE,oCAAsB,CAAC;KACrC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,4BAA4B;IACzC,MAAM,OAAO,GAAG,IAAA,gBAAS,GAAE,CAAC;IAC5B,IAAI;QACF,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,CAAC,oCAAsB,CAAC;SAC/B,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;KACzD;AACH,CAAC"}
|