@uipath/integrationservice-tool 1.205.0-preview.284 → 1.206.0-preview.282

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  __require
3
- } from "./tool-1yh8g550.js";
3
+ } from "./tool-6an893wm.js";
4
4
 
5
5
  // ../filesystem/src/node.ts
6
- import { randomUUID } from "node:crypto";
6
+ import { createHash, randomUUID } from "node:crypto";
7
7
  import { existsSync } from "node:fs";
8
8
  import * as fs from "node:fs/promises";
9
9
  import * as os from "node:os";
@@ -14,6 +14,9 @@ var LOCK_MAX_WAIT_MS = 20000;
14
14
  var LOCK_MAX_HOLD_MS = 60000;
15
15
  var LOCK_RETRY_MIN_MS = 100;
16
16
  var LOCK_RETRY_JITTER_MS = 200;
17
+ var HASH_CHUNK_BYTES = 256 * 1024;
18
+ var hashBuffers = [];
19
+ var HASH_BUFFERS_KEPT = 64;
17
20
 
18
21
  class NodeFileSystem {
19
22
  path = {
@@ -32,7 +35,7 @@ class NodeFileSystem {
32
35
  };
33
36
  utils = {
34
37
  open: async (url) => {
35
- const { default: open } = await import("./index-h8cph72k.js");
38
+ const { default: open } = await import("./index-nzr4mx5p.js");
36
39
  await open(url);
37
40
  }
38
41
  };
@@ -71,6 +74,15 @@ class NodeFileSystem {
71
74
  throw error;
72
75
  }
73
76
  }
77
+ async readdirEntries(dirPath) {
78
+ try {
79
+ return await fs.readdir(dirPath, { withFileTypes: true });
80
+ } catch (error) {
81
+ if (this.isEnoent(error))
82
+ return [];
83
+ throw error;
84
+ }
85
+ }
74
86
  async stat(filePath) {
75
87
  try {
76
88
  const stats = await fs.stat(filePath);
@@ -78,7 +90,8 @@ class NodeFileSystem {
78
90
  isFile: () => stats.isFile(),
79
91
  isDirectory: () => stats.isDirectory(),
80
92
  size: stats.size,
81
- mtimeMs: stats.mtimeMs
93
+ mtimeMs: stats.mtimeMs,
94
+ ctimeMs: stats.ctimeMs
82
95
  };
83
96
  } catch (error) {
84
97
  if (this.isEnoent(error))
@@ -192,6 +205,42 @@ class NodeFileSystem {
192
205
  throw error;
193
206
  }
194
207
  }
208
+ async hashFile(filePath) {
209
+ let handle;
210
+ try {
211
+ handle = await fs.open(filePath, "r");
212
+ } catch (error) {
213
+ if (this.isEnoent(error))
214
+ return null;
215
+ throw error;
216
+ }
217
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
218
+ try {
219
+ const opened = await handle.stat();
220
+ const stats = {
221
+ isFile: () => opened.isFile(),
222
+ isDirectory: () => opened.isDirectory(),
223
+ size: opened.size,
224
+ mtimeMs: opened.mtimeMs,
225
+ ctimeMs: opened.ctimeMs
226
+ };
227
+ const hash = createHash("sha256");
228
+ let size = 0;
229
+ for (;; ) {
230
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
231
+ if (bytesRead === 0)
232
+ break;
233
+ hash.update(buffer.subarray(0, bytesRead));
234
+ size += bytesRead;
235
+ }
236
+ return { sha256: hash.digest("hex"), size, stats };
237
+ } finally {
238
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
239
+ hashBuffers.push(buffer);
240
+ }
241
+ await handle.close();
242
+ }
243
+ }
195
244
  async realpath(filePath) {
196
245
  try {
197
246
  return await fs.realpath(filePath);
@@ -336,8 +385,8 @@ function resolveAuthProfileFilePath(profile) {
336
385
  if (normalized === undefined) {
337
386
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
338
387
  }
339
- const fs2 = getFileSystem();
340
- return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
388
+ const fs = getFileSystem();
389
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
341
390
  }
342
391
  function getActiveAuthProfileFilePath() {
343
392
  const profile = getActiveAuthProfile();
@@ -603,6 +652,8 @@ var ENV_AUTH_VARS = {
603
652
  };
604
653
 
605
654
  class EnvAuthConfigError extends Error {
655
+ errorCode = "configuration_error";
656
+ retry = "RetryWillNotFix";
606
657
  constructor(message) {
607
658
  super(message);
608
659
  this.name = "EnvAuthConfigError";
@@ -641,11 +692,11 @@ var readAuthFromEnv = () => {
641
692
  if (!rawUrl) {
642
693
  throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
643
694
  }
644
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
695
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
645
696
  return {
646
697
  loginStatus: "Logged in",
647
698
  accessToken,
648
- baseUrl: baseUrl2,
699
+ baseUrl,
649
700
  organizationName,
650
701
  organizationId,
651
702
  tenantName,
@@ -696,9 +747,9 @@ function breakerPathFor(authPath) {
696
747
  return `${authPath}${BREAKER_SUFFIX}`;
697
748
  }
698
749
  async function loadRefreshBreaker(authPath) {
699
- const fs2 = getFileSystem();
750
+ const fs = getFileSystem();
700
751
  try {
701
- const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
752
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
702
753
  if (!content)
703
754
  return {};
704
755
  const parsed = JSON.parse(content);
@@ -709,20 +760,20 @@ async function loadRefreshBreaker(authPath) {
709
760
  }
710
761
  async function saveRefreshBreaker(authPath, state) {
711
762
  try {
712
- const fs2 = getFileSystem();
713
- const path2 = breakerPathFor(authPath);
714
- await fs2.mkdir(fs2.path.dirname(path2));
715
- const tempPath = `${path2}.tmp`;
716
- await fs2.writeFile(tempPath, JSON.stringify(state));
717
- await fs2.rename(tempPath, path2);
763
+ const fs = getFileSystem();
764
+ const path = breakerPathFor(authPath);
765
+ await fs.mkdir(fs.path.dirname(path));
766
+ const tempPath = `${path}.tmp`;
767
+ await fs.writeFile(tempPath, JSON.stringify(state));
768
+ await fs.rename(tempPath, path);
718
769
  } catch {}
719
770
  }
720
771
  async function clearRefreshBreaker(authPath) {
721
- const fs2 = getFileSystem();
722
- const path2 = breakerPathFor(authPath);
772
+ const fs = getFileSystem();
773
+ const path = breakerPathFor(authPath);
723
774
  try {
724
- if (await fs2.exists(path2)) {
725
- await fs2.rm(path2);
775
+ if (await fs.exists(path)) {
776
+ await fs.rm(path);
726
777
  }
727
778
  } catch {}
728
779
  }
@@ -743,13 +794,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
743
794
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
744
795
  var PIPE_NAME_MAX_LENGTH = 103;
745
796
  var getRobotIpcPipeNames = async () => {
746
- const fs2 = getFileSystem();
747
- const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
797
+ const fs = getFileSystem();
798
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
748
799
  if (!username) {
749
800
  throw new Error("Unable to determine current username");
750
801
  }
751
- const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
752
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
802
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
803
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
753
804
  };
754
805
  var defaultIsRobotIpcAvailable = async () => {
755
806
  if (process.platform === "win32") {
@@ -759,20 +810,20 @@ var defaultIsRobotIpcAvailable = async () => {
759
810
  if (pipeNamesError || !pipeNames) {
760
811
  return false;
761
812
  }
762
- const fs2 = getFileSystem();
813
+ const fs = getFileSystem();
763
814
  for (const pipeName of pipeNames) {
764
- const [existsError, exists] = await catchError(fs2.exists(pipeName));
815
+ const [existsError, exists] = await catchError(fs.exists(pipeName));
765
816
  if (!existsError && exists === true) {
766
817
  return true;
767
818
  }
768
819
  }
769
820
  return false;
770
821
  };
771
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
822
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
772
823
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
773
824
  promise.then((value) => {
774
825
  clearTimeout(timer);
775
- resolve2(value);
826
+ resolve(value);
776
827
  }, (error) => {
777
828
  clearTimeout(timer);
778
829
  reject(error);
@@ -945,9 +996,12 @@ var refreshAccessToken = async ({
945
996
  body: tokenParams
946
997
  });
947
998
  const tokenData = await tokenResponse.json();
948
- if (!tokenResponse.ok) {
999
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
949
1000
  throw new TokenRefreshOAuthError;
950
1001
  }
1002
+ if (!tokenResponse.ok) {
1003
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
1004
+ }
951
1005
  const newAccessToken = tokenData.access_token;
952
1006
  const newRefreshToken = tokenData.refresh_token;
953
1007
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -979,9 +1033,9 @@ var errorCode = (err) => {
979
1033
  }
980
1034
  return "EUNKNOWN";
981
1035
  };
982
- var probeAsync = async (fs2, candidate) => {
1036
+ var probeAsync = async (fs, candidate) => {
983
1037
  try {
984
- const stats = await fs2.stat(candidate);
1038
+ const stats = await fs.stat(candidate);
985
1039
  if (stats === null) {
986
1040
  return { exists: false };
987
1041
  }
@@ -1008,36 +1062,36 @@ var probeAsync = async (fs2, candidate) => {
1008
1062
  }
1009
1063
  };
1010
1064
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
1011
- const fs2 = getFileSystem();
1012
- if (fs2.path.isAbsolute(envFilePath)) {
1013
- const probe2 = await probeAsync(fs2, envFilePath);
1014
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
1065
+ const fs = getFileSystem();
1066
+ if (fs.path.isAbsolute(envFilePath)) {
1067
+ const probe = await probeAsync(fs, envFilePath);
1068
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
1015
1069
  exists: false,
1016
1070
  absolutePath: envFilePath,
1017
1071
  source: "absolute",
1018
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
1072
+ ...probe.unusable ? { unusable: probe.unusable } : {}
1019
1073
  };
1020
1074
  }
1021
- const cwd = opts?.cwd ?? fs2.env.cwd();
1075
+ const cwd = opts?.cwd ?? fs.env.cwd();
1022
1076
  let searchDir = cwd;
1023
1077
  while (true) {
1024
- const candidate = fs2.path.join(searchDir, envFilePath);
1025
- const probe2 = await probeAsync(fs2, candidate);
1026
- if (probe2.exists) {
1078
+ const candidate = fs.path.join(searchDir, envFilePath);
1079
+ const probe = await probeAsync(fs, candidate);
1080
+ if (probe.exists) {
1027
1081
  return {
1028
1082
  exists: true,
1029
1083
  absolutePath: candidate,
1030
1084
  source: searchDir === cwd ? "cwd" : "ancestor"
1031
1085
  };
1032
1086
  }
1033
- const parentDir = fs2.path.dirname(searchDir);
1087
+ const parentDir = fs.path.dirname(searchDir);
1034
1088
  if (parentDir === searchDir) {
1035
1089
  break;
1036
1090
  }
1037
1091
  searchDir = parentDir;
1038
1092
  }
1039
- const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
1040
- const probe = await probeAsync(fs2, homePath);
1093
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
1094
+ const probe = await probeAsync(fs, homePath);
1041
1095
  if (probe.exists) {
1042
1096
  return { exists: true, absolutePath: homePath, source: "home" };
1043
1097
  }
@@ -1080,12 +1134,12 @@ var parseEnvContent = (content) => {
1080
1134
  return env;
1081
1135
  };
1082
1136
  var loadEnvFileAsync = async ({ envPath }) => {
1083
- const fs2 = getFileSystem();
1084
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
1085
- if (!await fs2.exists(absolutePath)) {
1137
+ const fs = getFileSystem();
1138
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
1139
+ if (!await fs.exists(absolutePath)) {
1086
1140
  throw new Error(`Environment file not found: ${envPath}`);
1087
1141
  }
1088
- const content = await fs2.readFile(absolutePath, "utf-8");
1142
+ const content = await fs.readFile(absolutePath, "utf-8");
1089
1143
  if (content === null) {
1090
1144
  throw new Error(`Environment file not found: ${envPath}`);
1091
1145
  }
@@ -1096,10 +1150,10 @@ var saveEnvFileAsync = async ({
1096
1150
  data,
1097
1151
  merge = true
1098
1152
  }) => {
1099
- const fs2 = getFileSystem();
1100
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
1153
+ const fs = getFileSystem();
1154
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
1101
1155
  let existingData = {};
1102
- if (merge && await fs2.exists(absolutePath)) {
1156
+ if (merge && await fs.exists(absolutePath)) {
1103
1157
  try {
1104
1158
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
1105
1159
  } catch {}
@@ -1117,11 +1171,11 @@ var saveEnvFileAsync = async ({
1117
1171
  const content = `${lines.join(`
1118
1172
  `)}
1119
1173
  `;
1120
- const dir = fs2.path.dirname(absolutePath);
1121
- await fs2.mkdir(dir);
1174
+ const dir = fs.path.dirname(absolutePath);
1175
+ await fs.mkdir(dir);
1122
1176
  const tempPath = `${absolutePath}.tmp`;
1123
- await fs2.writeFile(tempPath, content);
1124
- await fs2.rename(tempPath, absolutePath);
1177
+ await fs.writeFile(tempPath, content);
1178
+ await fs.rename(tempPath, absolutePath);
1125
1179
  };
1126
1180
 
1127
1181
  // ../auth/src/loginStatus.ts
@@ -1245,11 +1299,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
1245
1299
  return { credentials };
1246
1300
  }
1247
1301
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
1248
- const fs2 = getFs();
1249
- const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
1302
+ const fs = getFs();
1303
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
1250
1304
  if (absolutePath === globalPath)
1251
1305
  return;
1252
- if (!await fs2.exists(globalPath))
1306
+ if (!await fs.exists(globalPath))
1253
1307
  return;
1254
1308
  try {
1255
1309
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -1666,26 +1720,38 @@ function errorMessage(error) {
1666
1720
  }
1667
1721
 
1668
1722
  // ../auth/src/authContext.ts
1723
+ class AuthContextUnavailableError extends Error {
1724
+ instructionContext;
1725
+ sessionHint;
1726
+ errorCode = "authentication_required";
1727
+ retry = "RetryWillNotFix";
1728
+ constructor(message, instructionContext = "auth", sessionHint) {
1729
+ super(message);
1730
+ this.instructionContext = instructionContext;
1731
+ this.sessionHint = sessionHint;
1732
+ this.name = "AuthContextUnavailableError";
1733
+ }
1734
+ }
1669
1735
  var getAuthContext = async (options = {}) => {
1670
1736
  const status = await getLoginStatusAsync({
1671
1737
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
1672
1738
  envFilePath: options.envFilePath
1673
1739
  });
1674
1740
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
1675
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
1741
+ throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
1676
1742
  }
1677
- const tenantName = options.tenant ?? status.tenantName;
1743
+ const tenantName = options.tenant || status.tenantName;
1678
1744
  if (options.requireOrganizationId && !status.organizationId) {
1679
- throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
1745
+ throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
1680
1746
  }
1681
1747
  if (options.requireOrganizationName && !status.organizationName) {
1682
- throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
1748
+ throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
1683
1749
  }
1684
1750
  if (options.requireTenantId && !status.tenantId) {
1685
- throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
1751
+ throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
1686
1752
  }
1687
- if (options.requireTenantName && tenantName === undefined) {
1688
- throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
1753
+ if (options.requireTenantName && !tenantName) {
1754
+ throw new AuthContextUnavailableError("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.", "identity");
1689
1755
  }
1690
1756
  return {
1691
1757
  baseUrl: status.baseUrl,
@@ -1706,4 +1772,4 @@ var TENANT_SELECTION_CODES = new Set([
1706
1772
  ]);
1707
1773
  export { getFileSystem, resolveSessionIdentity, fetchTenantsAndOrganizations, getLoginStatusAsync, getAuthContext };
1708
1774
 
1709
- //# debugId=666AFD3F13B6C74464756E2164756E21
1775
+ //# debugId=27D6E0430309EC4D64756E2164756E21