@extrahorizon/exh-cli 1.9.0-dev-91-ec8a18d → 1.9.0-dev-93-fe9299d
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.
|
@@ -90,6 +90,13 @@ async function validateConfig(config) {
|
|
|
90
90
|
else {
|
|
91
91
|
throw new Error('Code path not specified');
|
|
92
92
|
}
|
|
93
|
+
if (config.executionCredentials) {
|
|
94
|
+
const restrictedProperties = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
|
|
95
|
+
const foundProperties = Object.keys(config.environment).filter(key => restrictedProperties.includes(key));
|
|
96
|
+
if (foundProperties.length > 0) {
|
|
97
|
+
throw new Error(`❌ Environment variables [${foundProperties.join(', ')}] may not be provided when using executionCredentials`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
93
100
|
assertExecutionPermission(config.executionPermission);
|
|
94
101
|
return true;
|
|
95
102
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.syncFunctionUser = exports.zipFileFromDirectory = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const os_1 = require("os");
|
|
6
|
+
const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
|
|
6
7
|
const archiver = require("archiver");
|
|
7
8
|
const chalk = require("chalk");
|
|
8
9
|
const uuid_1 = require("uuid");
|
|
@@ -62,10 +63,21 @@ async function syncFunctionUser(sdk, data) {
|
|
|
62
63
|
currentFunction?.environmentVariables?.API_OAUTH_CONSUMER_KEY?.value &&
|
|
63
64
|
currentFunction?.environmentVariables?.API_OAUTH_CONSUMER_SECRET?.value);
|
|
64
65
|
if (!hasExistingCredentials) {
|
|
65
|
-
throw new Error('❌
|
|
66
|
+
throw new Error('❌ The user for the task-config.json executionCredentials exists, but no credentials were found in the Function environmentVariables');
|
|
67
|
+
}
|
|
68
|
+
const taskUserSdk = (0, javascript_sdk_1.createOAuth1Client)({
|
|
69
|
+
host: currentFunction.environmentVariables.API_HOST.value,
|
|
70
|
+
tokenSecret: currentFunction.environmentVariables.API_OAUTH_TOKEN_SECRET.value,
|
|
71
|
+
token: currentFunction.environmentVariables.API_OAUTH_TOKEN.value,
|
|
72
|
+
consumerKey: currentFunction.environmentVariables.API_OAUTH_CONSUMER_KEY.value,
|
|
73
|
+
consumerSecret: currentFunction.environmentVariables.API_OAUTH_CONSUMER_SECRET.value,
|
|
74
|
+
});
|
|
75
|
+
const taskUser = await taskUserSdk.users.me();
|
|
76
|
+
if (taskUser.id !== user.id) {
|
|
77
|
+
throw new Error(`❌ The credentials found in the Function (${taskUser.email}) do not match the user found for the task-config.json executionCredentials (${user.email})`);
|
|
66
78
|
}
|
|
67
79
|
console.log(chalk.white('⚙️ Reusing existing user credentials...'));
|
|
68
|
-
const userRole = user.roles
|
|
80
|
+
const userRole = user.roles?.find(({ name }) => name === roleName);
|
|
69
81
|
if (!userRole) {
|
|
70
82
|
await assignRoleToUser(sdk, user.id, role.id);
|
|
71
83
|
}
|