@extrahorizon/exh-cli 1.9.0-dev-91-ec8a18d → 1.9.0-dev-92-eb0bddb

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.
@@ -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('❌ No credentials were found for the existing user');
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.find(({ name }) => name === roleName);
80
+ const userRole = user.roles?.find(({ name }) => name === roleName);
69
81
  if (!userRole) {
70
82
  await assignRoleToUser(sdk, user.id, role.id);
71
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.9.0-dev-91-ec8a18d",
3
+ "version": "1.9.0-dev-92-eb0bddb",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",