@uipath/codedapp-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.
Files changed (35) hide show
  1. package/README.md +48 -0
  2. package/dist/{browser-strategy-6atc7v8s.js → browser-strategy-z97p0ezf.js} +5 -6
  3. package/dist/{embedded-file-reader-r66242ey.js → embedded-file-reader-0228j82a.js} +1 -4
  4. package/dist/first-party-service-ahcc6xc6.js +8 -0
  5. package/dist/{index-0k30knwv.js → index-0py5k2e9.js} +177 -2055
  6. package/dist/index-c3zcyvwz.js +20 -0
  7. package/dist/index-cw1j9s6d.js +3176 -0
  8. package/dist/{index-h8cph72k.js → index-nzr4mx5p.js} +2 -22
  9. package/dist/index-z2qk2qn6.js +24 -0
  10. package/dist/index.js +14 -17
  11. package/dist/{jmespath-e4a59c8w.js → jmespath-wwym30dp.js} +1 -1
  12. package/dist/{js-yaml-87cdx6bm.js → js-yaml-a2bk27p6.js} +1 -3
  13. package/dist/{node-strategy-myagr1zp.js → node-strategy-fk02jqd8.js} +9 -12
  14. package/dist/{packager-tool-5ebgtev7.js → packager-tool-06tdd0p9.js} +3168 -3092
  15. package/dist/{packager-tool-je2re4j6.js → packager-tool-0ajs8pnk.js} +53 -8
  16. package/dist/{packager-tool-vc19fcdp.js → packager-tool-19x86hb2.js} +3 -21
  17. package/dist/{packager-tool-0gctz400.js → packager-tool-2rwzcase.js} +2 -5
  18. package/dist/{packager-tool-s8h46737.js → packager-tool-3ss96mpk.js} +82 -709
  19. package/dist/{packager-tool-d94wjncg.js → packager-tool-5t7c439j.js} +97 -97
  20. package/dist/{packager-tool-1yh8g550.js → packager-tool-6an893wm.js} +12 -3
  21. package/dist/packager-tool-8pm90w77.js +6640 -0
  22. package/dist/{packager-tool-cmfktvbt.js → packager-tool-h9q8znad.js} +885 -439
  23. package/dist/{packager-tool-ahrmbx21.js → packager-tool-hzve3h1v.js} +1676 -1451
  24. package/dist/{packager-tool-gdtpsdn7.js → packager-tool-mm1x18d6.js} +223 -28
  25. package/dist/{packager-tool-qa9gftnj.js → packager-tool-xd2w5pct.js} +3 -3
  26. package/dist/packager-tool.js +7 -8
  27. package/dist/tool.js +13 -16
  28. package/package.json +2 -2
  29. package/dist/first-party-service-srxaftkn.js +0 -27
  30. package/dist/index-78bnpdqb.js +0 -3177
  31. package/dist/index-kmp9fmhb.js +0 -25
  32. package/dist/index-wbp18pm0.js +0 -157
  33. package/dist/packager-tool-53w8skv5.js +0 -262
  34. package/dist/packager-tool-m7tmga2c.js +0 -20538
  35. /package/dist/{packager-tool-yc4kw997.js → packager-tool-1qg04b7q.js} +0 -0
@@ -1,30 +1,27 @@
1
1
  import {
2
- getGlobalThis,
3
- isBrowser
4
- } from "./packager-tool-0gctz400.js";
5
- import {
6
- catchError
7
- } from "./packager-tool-qa9gftnj.js";
8
- import {
9
- getFileSystem
10
- } from "./packager-tool-je2re4j6.js";
11
- import {
2
+ UIPATH_HOME_DIR,
12
3
  AUTH_FILENAME,
13
4
  DEFAULT_BASE_URL,
14
- DEFAULT_REDIRECT_URI,
15
- UIPATH_HOME_DIR
16
- } from "./packager-tool-yc4kw997.js";
5
+ DEFAULT_REDIRECT_URI
6
+ } from "./packager-tool-1qg04b7q.js";
7
+ import {
8
+ getFileSystem
9
+ } from "./packager-tool-0ajs8pnk.js";
17
10
  import {
18
11
  __require
19
- } from "./packager-tool-1yh8g550.js";
12
+ } from "./packager-tool-6an893wm.js";
13
+ import {
14
+ isBrowser,
15
+ getGlobalThis
16
+ } from "./packager-tool-2rwzcase.js";
17
+ import {
18
+ catchError2
19
+ } from "./packager-tool-xd2w5pct.js";
20
20
 
21
21
  // ../auth/src/config.ts
22
22
  var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
23
23
  var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
24
24
  var globalSlot = globalThis;
25
- var setAuthFileConfig = (cfg) => {
26
- globalSlot[AUTH_FILE_CONFIG_KEY] = cfg ?? {};
27
- };
28
25
  var getAuthFileConfig = () => globalSlot[AUTH_FILE_CONFIG_KEY] ?? {};
29
26
 
30
27
  class InvalidBaseUrlError extends Error {
@@ -61,7 +58,7 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
61
58
  baseUrl = `https://${baseUrl}`;
62
59
  }
63
60
  const resolvedBaseUrl = baseUrl;
64
- const [urlError, url] = catchError(() => new URL(resolvedBaseUrl));
61
+ const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
65
62
  if (urlError) {
66
63
  const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
67
64
  throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
@@ -289,14 +286,14 @@ function ClientSecretPost2(clientSecret) {
289
286
  return ClientSecretPost(clientSecret);
290
287
  }
291
288
  tbi ||= new WeakMap;
292
- return (as, client, body, headers2) => {
289
+ return (as, client, body, headers) => {
293
290
  let auth;
294
291
  if (!(auth = tbi.get(client))) {
295
292
  assertString2(client.client_secret, '"metadata.client_secret"');
296
293
  auth = ClientSecretPost(client.client_secret);
297
294
  tbi.set(client, auth);
298
295
  }
299
- return auth(as, client, body, headers2);
296
+ return auth(as, client, body, headers);
300
297
  };
301
298
  }
302
299
  function assertString2(input, it) {
@@ -473,7 +470,7 @@ function isAuthProfileStorage(value) {
473
470
  return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
474
471
  }
475
472
  function createProfileStorage() {
476
- const [error, mod] = catchError(() => __require("node:async_hooks"));
473
+ const [error, mod] = catchError2(() => __require("node:async_hooks"));
477
474
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
478
475
  return {
479
476
  getStore: () => {
@@ -510,31 +507,6 @@ function normalizeAuthProfileName(profile) {
510
507
  }
511
508
  return profile;
512
509
  }
513
- function setActiveAuthProfile(profile) {
514
- const normalized = normalizeAuthProfileName(profile);
515
- const scopedState = profileStorage.getStore();
516
- if (scopedState !== undefined) {
517
- if (normalized === undefined) {
518
- delete scopedState.profile;
519
- return;
520
- }
521
- scopedState.profile = normalized;
522
- return;
523
- }
524
- if (normalized === undefined) {
525
- delete globalSlot2[ACTIVE_AUTH_PROFILE_KEY];
526
- return;
527
- }
528
- globalSlot2[ACTIVE_AUTH_PROFILE_KEY] = { profile: normalized };
529
- }
530
- function clearActiveAuthProfile() {
531
- const scopedState = profileStorage.getStore();
532
- if (scopedState !== undefined) {
533
- delete scopedState.profile;
534
- return;
535
- }
536
- delete globalSlot2[ACTIVE_AUTH_PROFILE_KEY];
537
- }
538
510
  function getActiveAuthProfile() {
539
511
  const scopedState = profileStorage.getStore();
540
512
  if (scopedState !== undefined) {
@@ -542,10 +514,6 @@ function getActiveAuthProfile() {
542
514
  }
543
515
  return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
544
516
  }
545
- function runWithAuthProfile(profile, fn) {
546
- const normalized = normalizeAuthProfileName(profile);
547
- return profileStorage.run(normalized === undefined ? {} : { profile: normalized }, fn);
548
- }
549
517
  function resolveAuthProfileFilePath(profile) {
550
518
  const normalized = normalizeAuthProfileName(profile);
551
519
  if (normalized === undefined) {
@@ -558,63 +526,6 @@ function getActiveAuthProfileFilePath() {
558
526
  const profile = getActiveAuthProfile();
559
527
  return profile ? resolveAuthProfileFilePath(profile) : undefined;
560
528
  }
561
- function getAuthProfilesRootPath() {
562
- const fs = getFileSystem();
563
- return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR);
564
- }
565
- function resolveAuthProfileDirPath(profile) {
566
- const normalized = normalizeAuthProfileName(profile);
567
- if (normalized === undefined) {
568
- throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile directory.`);
569
- }
570
- const fs = getFileSystem();
571
- return fs.path.join(getAuthProfilesRootPath(), normalized);
572
- }
573
- async function listAuthProfileNamesAsync() {
574
- const fs = getFileSystem();
575
- const root = getAuthProfilesRootPath();
576
- if (!await fs.exists(root)) {
577
- return [];
578
- }
579
- const [readError, entries] = await catchError(fs.readdir(root));
580
- if (readError || !entries) {
581
- return [];
582
- }
583
- const names = [];
584
- for (const entry of entries) {
585
- if (!PROFILE_NAME_RE.test(entry) || entry === DEFAULT_AUTH_PROFILE) {
586
- continue;
587
- }
588
- const stats = await fs.stat(fs.path.join(root, entry));
589
- if (stats?.isDirectory()) {
590
- names.push(entry);
591
- }
592
- }
593
- return names.sort((a, b) => a.localeCompare(b));
594
- }
595
- async function authProfileExistsAsync(profile) {
596
- const fs = getFileSystem();
597
- const [pathError, dir] = catchError(() => resolveAuthProfileDirPath(profile));
598
- if (pathError || dir === undefined) {
599
- return false;
600
- }
601
- const stats = await fs.stat(dir);
602
- return stats?.isDirectory() === true;
603
- }
604
- async function deleteAuthProfileAsync(profile) {
605
- const dir = resolveAuthProfileDirPath(profile);
606
- const fs = getFileSystem();
607
- const relativeToRoot = fs.path.relative(getAuthProfilesRootPath(), dir);
608
- if (relativeToRoot === "" || relativeToRoot.startsWith("..") || fs.path.isAbsolute(relativeToRoot)) {
609
- throw new AuthProfileValidationError(`Refusing to delete "${profile}": resolved path escapes the profiles directory.`);
610
- }
611
- const stats = await fs.stat(dir);
612
- if (stats?.isDirectory() !== true) {
613
- return;
614
- }
615
- await fs.rm(dir);
616
- return dir;
617
- }
618
529
 
619
530
  // ../auth/src/utils/jwt.ts
620
531
  class InvalidIssuerError extends Error {
@@ -690,7 +601,7 @@ var getTokenExpiration = (accessToken) => {
690
601
  // ../auth/src/sessionIdentity.ts
691
602
  var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
692
603
  var decodeClaims = (accessToken) => {
693
- const [error, claims] = catchError(() => parseJWT(accessToken));
604
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
694
605
  return error ? undefined : claims;
695
606
  };
696
607
  var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
@@ -737,7 +648,7 @@ var pickScopes = (claims) => {
737
648
  const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
738
649
  return scopes.length > 0 ? scopes : undefined;
739
650
  };
740
- var resolveSessionIdentity = (accessToken, authFlow) => {
651
+ var resolveSessionIdentity2 = (accessToken, authFlow) => {
741
652
  const claims = accessToken ? decodeClaims(accessToken) : undefined;
742
653
  const email = pickEmail(claims);
743
654
  const type = resolveIdentityType(claims, authFlow, email);
@@ -768,7 +679,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
768
679
  identity.applicationSubtype = applicationSubtype;
769
680
  return identity;
770
681
  };
771
- var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
682
+ var readTokenScopes2 = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
772
683
 
773
684
  // ../auth/src/envAuth.ts
774
685
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
@@ -782,6 +693,8 @@ var ENV_AUTH_VARS = {
782
693
  };
783
694
 
784
695
  class EnvAuthConfigError extends Error {
696
+ errorCode = "configuration_error";
697
+ retry = "RetryWillNotFix";
785
698
  constructor(message) {
786
699
  super(message);
787
700
  this.name = "EnvAuthConfigError";
@@ -798,7 +711,7 @@ var requireEnv = (name) => {
798
711
  };
799
712
  var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
800
713
  var resolveBaseUrl = (rawUrl, failureContext) => {
801
- const [baseUrlError, baseUrl] = catchError(() => normalizeAndValidateBaseUrl(rawUrl));
714
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
802
715
  if (baseUrlError) {
803
716
  if (baseUrlError instanceof InvalidBaseUrlError) {
804
717
  throw baseUrlError;
@@ -813,18 +726,18 @@ var readAuthFromEnv = () => {
813
726
  const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
814
727
  const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
815
728
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
816
- const [parseError, payload] = catchError(() => parseJWT(accessToken));
729
+ const [parseError, payload] = catchError2(() => parseJWT(accessToken));
817
730
  if (parseError) {
818
731
  const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
819
732
  const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
820
733
  if (!rawUrl) {
821
734
  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}).`);
822
735
  }
823
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
736
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
824
737
  return {
825
738
  loginStatus: "Logged in",
826
739
  accessToken,
827
- baseUrl: baseUrl2,
740
+ baseUrl,
828
741
  organizationName,
829
742
  organizationId,
830
743
  tenantName,
@@ -840,8 +753,8 @@ var readAuthFromEnv = () => {
840
753
  const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
841
754
  const expiration = getTokenExpiration(accessToken);
842
755
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
843
- const identity = resolveSessionIdentity(accessToken);
844
- const scopes = readTokenScopes(accessToken);
756
+ const identity = resolveSessionIdentity2(accessToken);
757
+ const scopes = readTokenScopes2(accessToken);
845
758
  return {
846
759
  loginStatus,
847
760
  accessToken,
@@ -934,13 +847,13 @@ var defaultIsRobotIpcAvailable = async () => {
934
847
  if (process.platform === "win32") {
935
848
  return true;
936
849
  }
937
- const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
850
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
938
851
  if (pipeNamesError || !pipeNames) {
939
852
  return false;
940
853
  }
941
854
  const fs = getFileSystem();
942
855
  for (const pipeName of pipeNames) {
943
- const [existsError, exists] = await catchError(fs.exists(pipeName));
856
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
944
857
  if (!existsError && exists === true) {
945
858
  return true;
946
859
  }
@@ -958,7 +871,7 @@ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
958
871
  });
959
872
  });
960
873
  var parseResourceUrl = (url) => {
961
- const [error, parsed] = catchError(() => new URL(url));
874
+ const [error, parsed] = catchError2(() => new URL(url));
962
875
  if (error || !parsed)
963
876
  return;
964
877
  const segments = parsed.pathname.split("/").filter(Boolean);
@@ -969,9 +882,6 @@ var parseResourceUrl = (url) => {
969
882
  };
970
883
  };
971
884
  var ROBOT_CLIENT_LOADER_KEY = Symbol.for("@uipath/auth/RobotClientLoader");
972
- var registerRobotClientLoader = (loader) => {
973
- globalThis[ROBOT_CLIENT_LOADER_KEY] = loader;
974
- };
975
885
  var getRegisteredRobotClientLoader = () => {
976
886
  const loader = globalThis[ROBOT_CLIENT_LOADER_KEY];
977
887
  return typeof loader === "function" ? loader : undefined;
@@ -981,7 +891,7 @@ var defaultLoadModule = async () => {
981
891
  if (!hostLoader) {
982
892
  return;
983
893
  }
984
- const [error, mod] = await catchError(() => hostLoader());
894
+ const [error, mod] = await catchError2(() => hostLoader());
985
895
  if (error || !mod) {
986
896
  return;
987
897
  }
@@ -1007,7 +917,7 @@ var tryRobotClientFallback = async (options = {}) => {
1007
917
  const mod = await loadModule();
1008
918
  if (!mod)
1009
919
  return;
1010
- const [ctorError, proxy] = catchError(() => new mod.RobotProxyConstructor);
920
+ const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
1011
921
  if (ctorError || !proxy) {
1012
922
  return;
1013
923
  }
@@ -1030,7 +940,7 @@ var tryRobotClientFallback = async (options = {}) => {
1030
940
  let organizationIdFromToken;
1031
941
  let tenantIdFromToken;
1032
942
  let issuerFromToken;
1033
- const [jwtError, claims] = catchError(() => parseJWT(accessToken));
943
+ const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
1034
944
  if (!jwtError && claims) {
1035
945
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
1036
946
  if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
@@ -1057,7 +967,7 @@ var tryRobotClientFallback = async (options = {}) => {
1057
967
  } catch {
1058
968
  return;
1059
969
  } finally {
1060
- await catchError(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
970
+ await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
1061
971
  }
1062
972
  };
1063
973
 
@@ -1088,7 +998,7 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId,
1088
998
  const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
1089
999
  throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
1090
1000
  }
1091
- const [parseError, data] = await catchError(response.json());
1001
+ const [parseError, data] = await catchError2(response.json());
1092
1002
  if (parseError) {
1093
1003
  throw new Error(describeNonJsonResponse(organizationId, response, parseError));
1094
1004
  }
@@ -1127,9 +1037,12 @@ var refreshAccessToken = async ({
1127
1037
  body: tokenParams
1128
1038
  });
1129
1039
  const tokenData = await tokenResponse.json();
1130
- if (!tokenResponse.ok) {
1040
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
1131
1041
  throw new TokenRefreshOAuthError;
1132
1042
  }
1043
+ if (!tokenResponse.ok) {
1044
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
1045
+ }
1133
1046
  const newAccessToken = tokenData.access_token;
1134
1047
  const newRefreshToken = tokenData.refresh_token;
1135
1048
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -1145,7 +1058,6 @@ var refreshAccessToken = async ({
1145
1058
  var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
1146
1059
 
1147
1060
  // ../auth/src/utils/envFile.ts
1148
- var DEFAULT_AUTH_FILENAME = AUTH_FILENAME;
1149
1061
  var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR}/${AUTH_FILENAME}`;
1150
1062
  var KNOWN_ERROR_CODES = new Set([
1151
1063
  "EISDIR",
@@ -1193,20 +1105,20 @@ var probeAsync = async (fs, candidate) => {
1193
1105
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
1194
1106
  const fs = getFileSystem();
1195
1107
  if (fs.path.isAbsolute(envFilePath)) {
1196
- const probe2 = await probeAsync(fs, envFilePath);
1197
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
1108
+ const probe = await probeAsync(fs, envFilePath);
1109
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
1198
1110
  exists: false,
1199
1111
  absolutePath: envFilePath,
1200
1112
  source: "absolute",
1201
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
1113
+ ...probe.unusable ? { unusable: probe.unusable } : {}
1202
1114
  };
1203
1115
  }
1204
1116
  const cwd = opts?.cwd ?? fs.env.cwd();
1205
1117
  let searchDir = cwd;
1206
1118
  while (true) {
1207
1119
  const candidate = fs.path.join(searchDir, envFilePath);
1208
- const probe2 = await probeAsync(fs, candidate);
1209
- if (probe2.exists) {
1120
+ const probe = await probeAsync(fs, candidate);
1121
+ if (probe.exists) {
1210
1122
  return {
1211
1123
  exists: true,
1212
1124
  absolutePath: candidate,
@@ -1274,7 +1186,7 @@ var loadEnvFileAsync = async ({ envPath }) => {
1274
1186
  }
1275
1187
  return parseEnvContent(content);
1276
1188
  };
1277
- var saveEnvFileAsync = async ({
1189
+ var saveEnvFileAsync2 = async ({
1278
1190
  envPath,
1279
1191
  data,
1280
1192
  merge = true
@@ -1308,22 +1220,16 @@ var saveEnvFileAsync = async ({
1308
1220
  };
1309
1221
 
1310
1222
  // ../auth/src/loginStatus.ts
1311
- var CredentialSource;
1312
- ((CredentialSource2) => {
1313
- CredentialSource2["SavedLogin"] = "saved-login";
1314
- CredentialSource2["Robot"] = "robot";
1315
- CredentialSource2["EnvironmentVariables"] = "env-vars";
1316
- })(CredentialSource ||= {});
1317
1223
  var defaultRobotTenantIdCache = new Map;
1318
1224
  var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
1319
- var getLoginStatusAsync = async (options = {}) => {
1225
+ var getLoginStatusAsync2 = async (options = {}) => {
1320
1226
  return getLoginStatusWithDeps(options);
1321
1227
  };
1322
1228
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
1323
1229
  const {
1324
1230
  resolveEnvFilePath = resolveEnvFilePathAsync,
1325
1231
  loadEnvFile = loadEnvFileAsync,
1326
- saveEnvFile = saveEnvFileAsync,
1232
+ saveEnvFile = saveEnvFileAsync2,
1327
1233
  getFs = getFileSystem,
1328
1234
  refreshToken: refreshTokenFn = refreshAccessToken,
1329
1235
  resolveConfig = resolveConfigAsync,
@@ -1544,16 +1450,16 @@ async function buildFileStatus(tokens, credentials, globalHint) {
1544
1450
  return result;
1545
1451
  }
1546
1452
  function identityFields(accessToken, credentials) {
1547
- const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
1548
- const scopes = readTokenScopes(accessToken);
1453
+ const identity = resolveSessionIdentity2(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
1454
+ const scopes = readTokenScopes2(accessToken);
1549
1455
  return {
1550
1456
  ...identity ? { identity } : {},
1551
1457
  ...scopes ? { scopes } : {}
1552
1458
  };
1553
1459
  }
1554
1460
  async function buildRobotStatus(robotCreds, deps) {
1555
- const identity = resolveSessionIdentity(robotCreds.accessToken);
1556
- const scopes = readTokenScopes(robotCreds.accessToken);
1461
+ const identity = resolveSessionIdentity2(robotCreds.accessToken);
1462
+ const scopes = readTokenScopes2(robotCreds.accessToken);
1557
1463
  const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
1558
1464
  return {
1559
1465
  loginStatus: "Logged in",
@@ -1580,7 +1486,7 @@ async function resolveRobotTenantId(robotCreds, deps) {
1580
1486
  const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
1581
1487
  let pending = deps.cache.get(key);
1582
1488
  if (!pending) {
1583
- pending = catchError(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
1489
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
1584
1490
  const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
1585
1491
  if (!settled.tenantId) {
1586
1492
  deps.cache.delete(key);
@@ -1593,7 +1499,7 @@ async function resolveRobotTenantId(robotCreds, deps) {
1593
1499
  }
1594
1500
  async function lookupRobotTenantId(target, deps) {
1595
1501
  const { baseUrl, accessToken, organization, tenantName } = target;
1596
- const [error, data] = await catchError(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
1502
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
1597
1503
  if (error) {
1598
1504
  const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
1599
1505
  return { hint: tenantLookupFailureHint(tenantName, reason) };
@@ -1615,7 +1521,7 @@ function tenantLookupFailureHint(tenantName, reason) {
1615
1521
  return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
1616
1522
  }
1617
1523
  function decodePathSegment(segment) {
1618
- const [error, decoded] = catchError(() => decodeURIComponent(segment));
1524
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
1619
1525
  return error ? segment : decoded;
1620
1526
  }
1621
1527
  var isFileNotFoundError = (error) => {
@@ -1855,26 +1761,38 @@ function errorMessage(error) {
1855
1761
  }
1856
1762
 
1857
1763
  // ../auth/src/authContext.ts
1858
- var getAuthContext = async (options = {}) => {
1859
- const status = await getLoginStatusAsync({
1764
+ class AuthContextUnavailableError extends Error {
1765
+ instructionContext;
1766
+ sessionHint;
1767
+ errorCode = "authentication_required";
1768
+ retry = "RetryWillNotFix";
1769
+ constructor(message, instructionContext = "auth", sessionHint) {
1770
+ super(message);
1771
+ this.instructionContext = instructionContext;
1772
+ this.sessionHint = sessionHint;
1773
+ this.name = "AuthContextUnavailableError";
1774
+ }
1775
+ }
1776
+ var getAuthContext2 = async (options = {}) => {
1777
+ const status = await getLoginStatusAsync2({
1860
1778
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
1861
1779
  envFilePath: options.envFilePath
1862
1780
  });
1863
1781
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
1864
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
1782
+ throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
1865
1783
  }
1866
- const tenantName = options.tenant ?? status.tenantName;
1784
+ const tenantName = options.tenant || status.tenantName;
1867
1785
  if (options.requireOrganizationId && !status.organizationId) {
1868
- throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
1786
+ throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
1869
1787
  }
1870
1788
  if (options.requireOrganizationName && !status.organizationName) {
1871
- throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
1789
+ throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
1872
1790
  }
1873
1791
  if (options.requireTenantId && !status.tenantId) {
1874
- throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
1792
+ throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
1875
1793
  }
1876
- if (options.requireTenantName && tenantName === undefined) {
1877
- 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.");
1794
+ if (options.requireTenantName && !tenantName) {
1795
+ 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");
1878
1796
  }
1879
1797
  return {
1880
1798
  baseUrl: status.baseUrl,
@@ -1886,561 +1804,16 @@ var getAuthContext = async (options = {}) => {
1886
1804
  identity: status.identity
1887
1805
  };
1888
1806
  };
1889
- var getAuthEnv = async (options = {}) => {
1890
- const authEnv = {};
1891
- let status;
1892
- try {
1893
- status = await getLoginStatusAsync(options);
1894
- } catch {
1895
- return { authEnv };
1896
- }
1897
- if (status.loginStatus === "Logged in" && status.accessToken) {
1898
- authEnv.UIPATH_ACCESS_TOKEN = status.accessToken;
1899
- if (status.baseUrl) {
1900
- const org = status.organizationName || status.organizationId;
1901
- const tenant = status.tenantName || status.tenantId;
1902
- if (org && tenant) {
1903
- authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${org}/${tenant}`;
1904
- }
1905
- }
1906
- if (status.organizationId)
1907
- authEnv.UIPATH_ORGANIZATION_ID = status.organizationId;
1908
- if (status.organizationName)
1909
- authEnv.UIPATH_ORGANIZATION_NAME = status.organizationName;
1910
- if (status.tenantId)
1911
- authEnv.UIPATH_TENANT_ID = status.tenantId;
1912
- if (status.tenantName)
1913
- authEnv.UIPATH_TENANT_NAME = status.tenantName;
1914
- }
1915
- return { authEnv, loginStatus: status };
1916
- };
1917
- // ../auth/src/authProfileDetails.ts
1918
- var ORGANIZATION_NAME_KEY = "UIPATH_ORGANIZATION_NAME";
1919
- var TENANT_NAME_KEY = "UIPATH_TENANT_NAME";
1920
- var URL_KEY = "UIPATH_URL";
1921
- var ACCESS_TOKEN_KEY = "UIPATH_ACCESS_TOKEN";
1922
- function statusFromToken(accessToken) {
1923
- if (!accessToken) {
1924
- return { status: "Not logged in" };
1925
- }
1926
- const expiration = getTokenExpiration(accessToken);
1927
- if (expiration === undefined) {
1928
- return { status: "Logged in" };
1929
- }
1930
- return {
1931
- status: expiration.getTime() <= Date.now() ? "Expired" : "Logged in",
1932
- expiresAt: expiration.toISOString()
1933
- };
1934
- }
1935
- async function describeAuthProfileAsync(name, filePath, active) {
1936
- const base = {
1937
- name,
1938
- active,
1939
- ...filePath ? { path: filePath } : {}
1940
- };
1941
- if (!filePath) {
1942
- return { ...base, status: "Not logged in" };
1943
- }
1944
- const fs = getFileSystem();
1945
- const [readError, content] = await catchError(fs.readFile(filePath, "utf-8"));
1946
- if (readError) {
1947
- return { ...base, status: "Unreadable" };
1948
- }
1949
- if (content === null || content === undefined) {
1950
- return { ...base, status: "Not logged in" };
1951
- }
1952
- const values = parseEnvContent(content);
1953
- return {
1954
- ...base,
1955
- ...values[ORGANIZATION_NAME_KEY] ? { organizationName: values[ORGANIZATION_NAME_KEY] } : {},
1956
- ...values[TENANT_NAME_KEY] ? { tenantName: values[TENANT_NAME_KEY] } : {},
1957
- ...values[URL_KEY] ? { url: values[URL_KEY] } : {},
1958
- ...statusFromToken(values[ACCESS_TOKEN_KEY])
1959
- };
1960
- }
1961
- async function describeAuthProfilesAsync() {
1962
- const activeProfile = getActiveAuthProfile();
1963
- const [defaultPathError, defaultLocation] = await catchError(resolveEnvFilePathAsync());
1964
- const rows = [
1965
- await describeAuthProfileAsync(DEFAULT_AUTH_PROFILE, defaultPathError ? undefined : defaultLocation?.absolutePath, activeProfile === undefined)
1966
- ];
1967
- for (const name of await listAuthProfileNamesAsync()) {
1968
- rows.push(await describeAuthProfileAsync(name, resolveAuthProfileFilePath(name), activeProfile === name));
1969
- }
1970
- return rows;
1971
- }
1972
- // ../auth/src/tokenGrant.ts
1973
- var requestClientCredentialsToken = async ({
1974
- tokenEndpoint,
1975
- baseUrl,
1976
- params,
1977
- buildError
1978
- }) => {
1979
- const tokenResponse = await fetch(tokenEndpoint, {
1980
- method: "POST",
1981
- headers: {
1982
- "Content-Type": "application/x-www-form-urlencoded"
1983
- },
1984
- body: new URLSearchParams(params)
1985
- });
1986
- const [parseError, tokenData] = await catchError(tokenResponse.json());
1987
- if (!tokenResponse.ok) {
1988
- const data = parseError ? {} : tokenData ?? {};
1989
- throw buildError({
1990
- status: tokenResponse.status,
1991
- errorType: data.error || "authentication_failed",
1992
- errorDesc: data.error_description || "Unknown error"
1993
- });
1994
- }
1995
- if (parseError || !tokenData) {
1996
- throw buildError({
1997
- status: tokenResponse.status,
1998
- errorType: "invalid_response",
1999
- errorDesc: "Token endpoint returned a non-JSON response."
2000
- });
2001
- }
2002
- if (!tokenData.access_token) {
2003
- throw buildError({
2004
- status: tokenResponse.status,
2005
- errorType: "invalid_response",
2006
- errorDesc: "Token endpoint response did not include an access_token."
2007
- });
2008
- }
2009
- return {
2010
- UIPATH_ACCESS_TOKEN: tokenData.access_token,
2011
- UIPATH_URL: baseUrl
2012
- };
2013
- };
2014
-
2015
- // ../auth/src/clientCredentials.ts
2016
- class ClientCredentialsAuthenticationError extends Error {
2017
- status;
2018
- constructor(message, status) {
2019
- super(message);
2020
- this.name = "ClientCredentialsAuthenticationError";
2021
- this.status = status;
2022
- }
2023
- }
2024
- var buildClientCredentialsError = ({
2025
- status,
2026
- errorType,
2027
- errorDesc
2028
- }) => {
2029
- let troubleshooting = "";
2030
- if (errorType === "invalid_client" || status === 401) {
2031
- troubleshooting = `
2032
-
2033
- Troubleshooting:` + `
2034
- • Verify your Client ID is correct` + `
2035
- • Ensure your Client Secret hasn't expired` + `
2036
- • Check that the external application is enabled in UiPath` + `
2037
- • Confirm you're using the correct authority URL`;
2038
- } else if (errorType === "invalid_scope") {
2039
- troubleshooting = `
2040
-
2041
- Troubleshooting:` + `
2042
- • The requested scopes may not be available for your account` + `
2043
- • Try using default scopes or contact your UiPath administrator`;
2044
- }
2045
- return new ClientCredentialsAuthenticationError(`Client Credentials authentication failed (${status})
2046
- ` + `Error: ${errorType}
2047
- ` + `Details: ${errorDesc}${troubleshooting}`, status);
2048
- };
2049
- var clientCredentialsLogin = async ({
2050
- clientId,
2051
- clientSecret,
2052
- scope,
2053
- authority
2054
- }) => {
2055
- const config = await resolveConfigAsync({
2056
- customAuthority: authority,
2057
- customClientId: clientId,
2058
- customClientSecret: clientSecret,
2059
- customScopes: scope
2060
- });
2061
- const params = {
2062
- grant_type: "client_credentials",
2063
- client_id: config.clientId,
2064
- client_secret: config.clientSecret ?? ""
2065
- };
2066
- if (config.scopes.length > 0) {
2067
- params.scope = config.scopes.join(" ");
2068
- }
2069
- return await requestClientCredentialsToken({
2070
- tokenEndpoint: config.tokenEndpoint,
2071
- baseUrl: config.baseUrl,
2072
- params,
2073
- buildError: buildClientCredentialsError
2074
- });
2075
- };
2076
- // ../auth/src/federatedCredentials.ts
2077
- var JWT_BEARER_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
2078
-
2079
- class FederatedCredentialsAuthenticationError extends Error {
2080
- status;
2081
- constructor(message, status) {
2082
- super(message);
2083
- this.name = "FederatedCredentialsAuthenticationError";
2084
- this.status = status;
2085
- }
2086
- }
2087
- var buildFederatedError = ({
2088
- status,
2089
- errorType,
2090
- errorDesc
2091
- }) => {
2092
- let troubleshooting = "";
2093
- if (errorType === "invalid_client" || errorType === "invalid_grant" || errorType === "invalid_request" || status === 401) {
2094
- troubleshooting = `
2095
-
2096
- Troubleshooting:` + `
2097
- • Verify your Client ID matches the external application` + `
2098
- • Confirm a federated credential is registered on the app whose` + `
2099
- issuer, audience, and subject exactly match the token's claims` + `
2100
- (list them: uip admin external-apps federated-credentials list <client-id>)` + `
2101
- • Check the token was issued by the expected provider and has not expired` + `
2102
- • Confirm you're using the correct authority URL`;
2103
- } else if (errorType === "invalid_scope") {
2104
- troubleshooting = `
2105
-
2106
- Troubleshooting:` + `
2107
- • The requested scopes may not be available for your application` + `
2108
- • Try using default scopes or contact your UiPath administrator`;
2109
- }
2110
- return new FederatedCredentialsAuthenticationError(`Federated Credentials authentication failed (${status})
2111
- ` + `Error: ${errorType}
2112
- ` + `Details: ${errorDesc}${troubleshooting}`, status);
2113
- };
2114
- var federatedCredentialsLogin = async ({
2115
- clientId,
2116
- clientAssertion,
2117
- scope,
2118
- authority
2119
- }) => {
2120
- const config = await resolveConfigAsync({
2121
- customAuthority: authority,
2122
- customClientId: clientId,
2123
- customClientAssertion: clientAssertion,
2124
- customScopes: scope
2125
- });
2126
- const params = {
2127
- grant_type: "client_credentials",
2128
- client_id: config.clientId,
2129
- client_assertion: clientAssertion,
2130
- client_assertion_type: JWT_BEARER_ASSERTION_TYPE
2131
- };
2132
- if (config.scopes.length > 0) {
2133
- params.scope = config.scopes.join(" ");
2134
- }
2135
- return await requestClientCredentialsToken({
2136
- tokenEndpoint: config.tokenEndpoint,
2137
- baseUrl: config.baseUrl,
2138
- params,
2139
- buildError: buildFederatedError
2140
- });
2141
- };
2142
1807
  // ../auth/src/selectTenant.ts
2143
1808
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
2144
1809
  var INVALID_TENANT_CODE = "INVALID_TENANT";
2145
-
2146
- class TenantSelectionError extends Error {
2147
- availableTenants;
2148
- organizationName;
2149
- constructor(message, organizationName, availableTenants) {
2150
- super(message);
2151
- this.organizationName = organizationName;
2152
- this.availableTenants = availableTenants;
2153
- }
2154
- }
2155
-
2156
- class TenantSelectionRequiredError extends TenantSelectionError {
2157
- code = TENANT_SELECTION_REQUIRED_CODE;
2158
- constructor(organizationName, availableTenants) {
2159
- super(`Multiple tenants available in organization "${organizationName}"; none selected.`, organizationName, availableTenants);
2160
- this.name = "TenantSelectionRequiredError";
2161
- }
2162
- }
2163
-
2164
- class InvalidTenantError extends TenantSelectionError {
2165
- code = INVALID_TENANT_CODE;
2166
- requestedTenant;
2167
- constructor(requestedTenant, organizationName, availableTenants) {
2168
- super(`Invalid tenant requested: "${requestedTenant}"
2169
- ` + `Organization: ${organizationName}
2170
- ` + `Available tenants: ${availableTenants.join(", ")}`, organizationName, availableTenants);
2171
- this.name = "InvalidTenantError";
2172
- this.requestedTenant = requestedTenant;
2173
- }
2174
- }
2175
1810
  var TENANT_SELECTION_CODES = new Set([
2176
1811
  TENANT_SELECTION_REQUIRED_CODE,
2177
1812
  INVALID_TENANT_CODE
2178
1813
  ]);
2179
- function isTenantSelectionError(error) {
2180
- if (!(error instanceof Object) || !("code" in error)) {
2181
- return false;
2182
- }
2183
- const code = error.code;
2184
- return typeof code === "string" && TENANT_SELECTION_CODES.has(code) && Array.isArray(error.availableTenants);
2185
- }
2186
- var selectTenantWithDeps = async (baseUrl, accessToken, organizationId, targetTenantName, interactive, deps = {}) => {
2187
- const {
2188
- fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
2189
- selectFromList
2190
- } = deps;
2191
- const data = await fetchTenantsAndOrgs(baseUrl, accessToken, organizationId);
2192
- const { tenants, organization } = data;
2193
- if (!tenants || tenants.length === 0) {
2194
- throw new Error("No tenants found for this organization");
2195
- }
2196
- const tenantNames = tenants.map((tenant) => tenant.name);
2197
- let selectedIndex;
2198
- if (targetTenantName !== undefined) {
2199
- selectedIndex = tenants.findIndex((tenant) => tenant.name === targetTenantName);
2200
- if (selectedIndex === -1) {
2201
- throw new InvalidTenantError(targetTenantName, organization.name, tenantNames);
2202
- }
2203
- } else if (tenants.length === 1) {
2204
- selectedIndex = 0;
2205
- } else if (interactive) {
2206
- if (!selectFromList) {
2207
- throw new Error("Interactive tenant selection requires a `selectFromList` callback. " + "Pass one via the `deps` argument of `selectTenantWithDeps`.");
2208
- }
2209
- selectedIndex = await selectFromList(tenantNames, "Select a tenant:");
2210
- } else {
2211
- throw new TenantSelectionRequiredError(organization.name, tenantNames);
2212
- }
2213
- const selectedTenant = tenants[selectedIndex];
2214
- return [selectedTenant.name, selectedTenant.id, organization.name];
2215
- };
2216
-
2217
- // ../auth/src/interactive.ts
2218
- var interactiveLoginWithDeps = async (options, deps) => {
2219
- const {
2220
- resolveConfig = resolveConfigAsync,
2221
- clientCredentials = clientCredentialsLogin,
2222
- federatedCredentials = federatedCredentialsLogin,
2223
- auth = authenticate,
2224
- saveEnvFile = saveEnvFileAsync,
2225
- loadEnvFile = loadEnvFileAsync,
2226
- getFs = getFileSystem,
2227
- jwtParser = parseJWT,
2228
- issuerAsserter = assertIssuerMatchesAuthority,
2229
- tenantSelector = (baseUrl, accessToken, organizationId, tenantName, interactive2) => selectTenantWithDeps(baseUrl, accessToken, organizationId, tenantName, interactive2, { selectFromList: options.selectFromList })
2230
- } = deps;
2231
- const {
2232
- envFilePath,
2233
- scope,
2234
- authority,
2235
- clientId,
2236
- clientSecret,
2237
- clientAssertion,
2238
- tenant,
2239
- organization,
2240
- interactive,
2241
- onEvent,
2242
- timeoutMs,
2243
- noBrowser,
2244
- signal
2245
- } = options;
2246
- const emit = (event) => {
2247
- if (!onEvent)
2248
- return;
2249
- try {
2250
- onEvent(event);
2251
- } catch {}
2252
- };
2253
- const deliverAuthUrl = (url) => {
2254
- try {
2255
- onEvent?.({ type: "auth-url", url });
2256
- } catch (error) {
2257
- throw new Error("Failed to deliver the authorize URL to the onEvent subscriber; " + "cannot continue headless login.", { cause: error });
2258
- }
2259
- };
2260
- const config = await resolveConfig({
2261
- customAuthority: authority,
2262
- customClientId: clientId,
2263
- customClientSecret: clientSecret,
2264
- customClientAssertion: clientAssertion
2265
- });
2266
- const { clientSecret: resolvedSecret } = config;
2267
- if (noBrowser && !resolvedSecret && !clientAssertion && !onEvent) {
2268
- throw new Error("noBrowser login requires an onEvent subscriber to receive the " + "auth-url event — the authorize URL is delivered through it.");
2269
- }
2270
- const authFlow = clientAssertion ? "federated_credentials" : resolvedSecret ? "client_credentials" : "authorization_code";
2271
- const authPromise = clientAssertion ? (async () => {
2272
- return await federatedCredentials({
2273
- clientId: config.clientId,
2274
- clientAssertion,
2275
- authority: config.baseUrl,
2276
- scope
2277
- });
2278
- })() : resolvedSecret ? (async () => {
2279
- return await clientCredentials({
2280
- clientId: config.clientId,
2281
- clientSecret: resolvedSecret,
2282
- authority: config.baseUrl,
2283
- scope
2284
- });
2285
- })() : (async () => {
2286
- const authTokens = await auth({
2287
- baseUrl: authority,
2288
- clientId,
2289
- clientSecret,
2290
- scope,
2291
- organization,
2292
- timeoutMs,
2293
- noBrowser,
2294
- signal,
2295
- onAuthUrl: noBrowser ? (url) => deliverAuthUrl(url) : undefined,
2296
- onPortReclaimed: ({ pid }) => emit({
2297
- type: "port-reclaimed",
2298
- message: `A previous 'uip login'${pid === undefined ? "" : ` (PID ${pid})`} was still holding the callback port ` + `(${new URL(DEFAULT_REDIRECT_URI).port}) and was released; continuing with this login.`
2299
- })
2300
- });
2301
- return {
2302
- UIPATH_ACCESS_TOKEN: authTokens.accessToken,
2303
- UIPATH_REFRESH_TOKEN: authTokens.refreshToken
2304
- };
2305
- })();
2306
- const [authError, tokens] = await catchError(authPromise);
2307
- if (authError) {
2308
- throw authError;
2309
- }
2310
- issuerAsserter(tokens.UIPATH_ACCESS_TOKEN, config.baseUrl);
2311
- const credentials = {
2312
- ...tokens,
2313
- UIPATH_URL: config.baseUrl,
2314
- [AUTH_FLOW_ENV_VAR]: authFlow
2315
- };
2316
- if (authFlow !== "authorization_code") {
2317
- credentials.UIPATH_REFRESH_TOKEN = undefined;
2318
- }
2319
- try {
2320
- const tokenData = jwtParser(tokens.UIPATH_ACCESS_TOKEN);
2321
- const orgId = tokenData.prtId || tokenData.organizationId || tokenData.prt_id;
2322
- if (typeof orgId !== "string" || orgId.length === 0) {
2323
- throw new Error("Organization ID not available from login token. Cannot establish an active tenant.");
2324
- }
2325
- credentials.UIPATH_ORGANIZATION_ID = orgId;
2326
- if (organization) {
2327
- credentials.UIPATH_ORGANIZATION_NAME = organization;
2328
- }
2329
- const [tenantName, tenantId, orgName] = await tenantSelector(config.baseUrl, tokens.UIPATH_ACCESS_TOKEN, orgId, tenant, interactive);
2330
- credentials.UIPATH_ORGANIZATION_NAME = orgName;
2331
- credentials.UIPATH_TENANT_NAME = tenantName;
2332
- credentials.UIPATH_TENANT_ID = tenantId;
2333
- } catch (error) {
2334
- if (!isTenantSelectionError(error)) {
2335
- emit({
2336
- type: "tenant-fetch-failed",
2337
- message: error instanceof Error ? error.message : String(error)
2338
- });
2339
- }
2340
- throw error;
2341
- }
2342
- const fs = getFs();
2343
- const requestedPath = envFilePath ?? DEFAULT_ENV_FILENAME;
2344
- let savePath = requestedPath;
2345
- let savedLocally = false;
2346
- if (!fs.path.isAbsolute(savePath)) {
2347
- let searchDir = fs.env.cwd();
2348
- while (true) {
2349
- const candidate = fs.path.join(searchDir, savePath);
2350
- if (await fs.exists(candidate)) {
2351
- try {
2352
- const existing = await loadEnvFile({
2353
- envPath: candidate
2354
- });
2355
- if (existing.UIPATH_ACCESS_TOKEN) {
2356
- savePath = candidate;
2357
- savedLocally = true;
2358
- break;
2359
- }
2360
- } catch {}
2361
- }
2362
- const parentDir = fs.path.dirname(searchDir);
2363
- if (parentDir === searchDir) {
2364
- break;
2365
- }
2366
- searchDir = parentDir;
2367
- }
2368
- }
2369
- let saveRelease;
2370
- try {
2371
- if (typeof fs.acquireLock === "function") {
2372
- saveRelease = await fs.acquireLock(savePath);
2373
- }
2374
- } catch {
2375
- saveRelease = undefined;
2376
- }
2377
- try {
2378
- await saveEnvFile({
2379
- envPath: savePath,
2380
- data: credentials,
2381
- merge: true
2382
- });
2383
- } finally {
2384
- if (saveRelease) {
2385
- await saveRelease().catch(() => {});
2386
- }
2387
- }
2388
- const reportedPath = fs.path.isAbsolute(savePath) ? savePath : fs.path.join(fs.env.homedir(), savePath);
2389
- emit({
2390
- type: "saved",
2391
- path: reportedPath,
2392
- locality: savedLocally ? "local" : "global"
2393
- });
2394
- return credentials;
2395
- };
2396
- var interactiveLogin = async (options) => {
2397
- return interactiveLoginWithDeps(options, {});
2398
- };
2399
- // ../auth/src/logout.ts
2400
- async function logoutWithDeps(options, deps = {}) {
2401
- const {
2402
- resolveEnvFilePath = resolveEnvFilePathAsync,
2403
- getFileSystem: getFs = getFileSystem,
2404
- clearBreaker = clearRefreshBreaker,
2405
- getActiveProfileFilePath = getActiveAuthProfileFilePath
2406
- } = deps;
2407
- const fs = getFs();
2408
- const { absolutePath } = await resolveEnvFilePath(options.file ?? getActiveProfileFilePath());
2409
- if (absolutePath && await fs.exists(absolutePath)) {
2410
- let release;
2411
- try {
2412
- if (typeof fs.acquireLock === "function") {
2413
- release = await fs.acquireLock(absolutePath);
2414
- }
2415
- } catch {
2416
- release = undefined;
2417
- }
2418
- try {
2419
- await fs.rm(absolutePath);
2420
- await clearBreaker(absolutePath);
2421
- } finally {
2422
- if (release) {
2423
- await release().catch(() => {});
2424
- }
2425
- }
2426
- return {
2427
- success: true,
2428
- message: `Logged out successfully. Removed ${absolutePath}`,
2429
- removedPath: absolutePath
2430
- };
2431
- }
2432
- return {
2433
- success: false,
2434
- message: "No credentials file found. You are already logged out.",
2435
- reason: "no_credentials_file"
2436
- };
2437
- }
2438
- async function logout(options) {
2439
- return logoutWithDeps(options);
2440
- }
2441
1814
 
2442
1815
  // ../auth/src/index.ts
2443
- var authenticate = async ({
1816
+ var authenticate2 = async ({
2444
1817
  baseUrl,
2445
1818
  clientId,
2446
1819
  clientSecret,
@@ -2495,10 +1868,10 @@ var authenticate = async ({
2495
1868
  const authUrl = `${authorizationEndpoint}?${authParams.toString()}`;
2496
1869
  let strategy;
2497
1870
  if (isBrowser()) {
2498
- const { BrowserAuthStrategy } = await import("./browser-strategy-6atc7v8s.js");
1871
+ const { BrowserAuthStrategy } = await import("./browser-strategy-z97p0ezf.js");
2499
1872
  strategy = new BrowserAuthStrategy;
2500
1873
  } else {
2501
- const { NodeAuthStrategy } = await import("./node-strategy-myagr1zp.js");
1874
+ const { NodeAuthStrategy } = await import("./node-strategy-fk02jqd8.js");
2502
1875
  strategy = new NodeAuthStrategy;
2503
1876
  }
2504
1877
  const code = await strategy.execute(authUrl, effectiveRedirectUriUrl, state, {
@@ -2518,6 +1891,6 @@ var authenticate = async ({
2518
1891
  });
2519
1892
  };
2520
1893
 
2521
- export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, getAuthProfilesRootPath, resolveAuthProfileDirPath, listAuthProfileNamesAsync, authProfileExistsAsync, deleteAuthProfileAsync, parseJWT, parseAuthFlow, resolveSessionIdentity, readTokenScopes, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, fetchTenantsAndOrganizations, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, describeAuthProfilesAsync, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
1894
+ export { resolveSessionIdentity2, readTokenScopes2, saveEnvFileAsync2, getLoginStatusAsync2, getAuthContext2, authenticate2 };
2522
1895
 
2523
- //# debugId=40192C240CF134F264756E2164756E21
1896
+ //# debugId=C06F925426D93BFE64756E2164756E21