@uipath/tasks-tool 1.204.0-preview.255 → 1.205.0-preview.256

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.
@@ -3238,6 +3238,16 @@ class NodeFileSystem {
3238
3238
  async rename(oldPath, newPath) {
3239
3239
  await fs.rename(oldPath, newPath);
3240
3240
  }
3241
+ async isSymbolicLink(filePath) {
3242
+ try {
3243
+ return (await fs.lstat(filePath)).isSymbolicLink();
3244
+ } catch (error) {
3245
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
3246
+ return false;
3247
+ }
3248
+ throw error;
3249
+ }
3250
+ }
3241
3251
  async realpath(filePath) {
3242
3252
  try {
3243
3253
  return await fs.realpath(filePath);
@@ -3327,7 +3337,7 @@ function setGlobalLogFilePath(path2) {
3327
3337
  function getGlobalLogFilePath() {
3328
3338
  return logFilePathSlot.get("");
3329
3339
  }
3330
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
3340
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
3331
3341
 
3332
3342
  class SimpleLogger {
3333
3343
  __brand = "SimpleLogger";
@@ -3594,7 +3604,9 @@ var ErrorDimensions = {
3594
3604
  Result: "Result",
3595
3605
  ErrorCode: "ErrorCode",
3596
3606
  Retry: "Retry",
3597
- ErrorMessage: "ErrorMessage"
3607
+ ErrorMessage: "ErrorMessage",
3608
+ HttpStatus: "HttpStatus",
3609
+ UpstreamErrorCode: "UpstreamErrorCode"
3598
3610
  };
3599
3611
  var AuthDimensions = {
3600
3612
  AuthenticationMethod: "AuthenticationMethod",
@@ -4582,7 +4594,9 @@ var CLI_ERROR_CODES = [
4582
4594
  "timeout",
4583
4595
  "server_error",
4584
4596
  "method_not_allowed",
4597
+ "not_supported",
4585
4598
  "configuration_error",
4599
+ "execution_failed",
4586
4600
  "unknown_error"
4587
4601
  ];
4588
4602
  var RETRY_HINTS = [
@@ -5539,7 +5553,9 @@ var OutputFormatter;
5539
5553
  [ErrorDimensions.Result]: data.Result,
5540
5554
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
5541
5555
  [ErrorDimensions.Retry]: data.Retry,
5542
- [ErrorDimensions.ErrorMessage]: data.Message
5556
+ [ErrorDimensions.ErrorMessage]: data.Message,
5557
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
5558
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
5543
5559
  });
5544
5560
  }
5545
5561
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -6518,6 +6534,165 @@ function settlePromiseLike2(thenable) {
6518
6534
  ]);
6519
6535
  }
6520
6536
 
6537
+ // ../auth/src/utils/platform.ts
6538
+ function isBrowser() {
6539
+ return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6540
+ }
6541
+
6542
+ // ../auth/src/utils/jwt.ts
6543
+ class InvalidIssuerError extends Error {
6544
+ expected;
6545
+ actual;
6546
+ constructor(expected, actual) {
6547
+ const actualText = actual ?? "<missing>";
6548
+ super(`Token issuer does not match the authority used to log in.
6549
+ ` + `Expected: ${expected}
6550
+ ` + `Actual: ${actualText}
6551
+
6552
+ ` + `The identity server that issued this token is not the one ` + `you pointed --authority at. Refusing to save credentials.`);
6553
+ this.expected = expected;
6554
+ this.actual = actual;
6555
+ this.name = "InvalidIssuerError";
6556
+ }
6557
+ }
6558
+ var parseJWT = (token) => {
6559
+ try {
6560
+ const parts = token.split(".");
6561
+ const base64Url = parts[1];
6562
+ if (!base64Url) {
6563
+ throw new Error("Invalid JWT token format - missing payload section");
6564
+ }
6565
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
6566
+ let decodedString;
6567
+ if (isBrowser() && typeof atob !== "undefined") {
6568
+ decodedString = atob(base64);
6569
+ } else {
6570
+ decodedString = Buffer.from(base64, "base64").toString();
6571
+ }
6572
+ const jsonPayload = decodeURIComponent(decodedString.split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));
6573
+ const parsed = JSON.parse(jsonPayload);
6574
+ return parsed;
6575
+ } catch (error) {
6576
+ throw new Error(`Failed to parse JWT: ${error instanceof Error ? error.message : "Unknown error"}`);
6577
+ }
6578
+ };
6579
+ var assertIssuerMatchesAuthority = (token, authority) => {
6580
+ let payload;
6581
+ try {
6582
+ payload = parseJWT(token);
6583
+ } catch (error) {
6584
+ throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
6585
+ }
6586
+ const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
6587
+ const expected = `${stripTrailingSlash(authority)}/identity_`;
6588
+ const actual = typeof payload.iss === "string" ? stripTrailingSlash(payload.iss) : undefined;
6589
+ if (actual !== expected) {
6590
+ throw new InvalidIssuerError(expected, payload.iss);
6591
+ }
6592
+ };
6593
+ var getTokenExpiration = (accessToken) => {
6594
+ try {
6595
+ const parts = accessToken.split(".");
6596
+ if (parts.length !== 3) {
6597
+ return;
6598
+ }
6599
+ const payload = parts[1];
6600
+ const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
6601
+ const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
6602
+ const decoded = atob(padded);
6603
+ const claims = JSON.parse(decoded);
6604
+ if (typeof claims.exp !== "number") {
6605
+ return;
6606
+ }
6607
+ return new Date(claims.exp * 1000);
6608
+ } catch {
6609
+ return;
6610
+ }
6611
+ };
6612
+
6613
+ // ../auth/src/sessionIdentity.ts
6614
+ var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
6615
+ var decodeClaims = (accessToken) => {
6616
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
6617
+ return error ? undefined : claims;
6618
+ };
6619
+ var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
6620
+ var resolveIdentityType = (claims, authFlow, email) => {
6621
+ const subType = asString(claims?.sub_type);
6622
+ if (subType) {
6623
+ return subType.startsWith("service") ? "Application" : "User";
6624
+ }
6625
+ if (authFlow) {
6626
+ return authFlow === "authorization_code" ? "User" : "Application";
6627
+ }
6628
+ if (email)
6629
+ return "User";
6630
+ if (asString(claims?.client_id) && !asString(claims?.sub)) {
6631
+ return "Application";
6632
+ }
6633
+ return;
6634
+ };
6635
+ var resolveApplicationSubtype = (claims, authFlow) => {
6636
+ switch (asString(claims?.sub_type)) {
6637
+ case "service.external":
6638
+ return "External";
6639
+ case "service.internal":
6640
+ return "Internal";
6641
+ default:
6642
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
6643
+ }
6644
+ };
6645
+ var looksLikeEmail = (value) => value?.includes("@") ?? false;
6646
+ var pickEmail = (claims) => {
6647
+ for (const candidate of [claims?.email, claims?.preferred_username]) {
6648
+ const value = asString(candidate);
6649
+ if (looksLikeEmail(value))
6650
+ return value;
6651
+ }
6652
+ return;
6653
+ };
6654
+ var pickName = (claims) => {
6655
+ const username = asString(claims?.preferred_username);
6656
+ return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
6657
+ };
6658
+ var pickScopes = (claims) => {
6659
+ const raw = claims?.scope;
6660
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6661
+ return scopes.length > 0 ? scopes : undefined;
6662
+ };
6663
+ var resolveSessionIdentity = (accessToken, authFlow) => {
6664
+ const claims = accessToken ? decodeClaims(accessToken) : undefined;
6665
+ const email = pickEmail(claims);
6666
+ const type = resolveIdentityType(claims, authFlow, email);
6667
+ if (!type)
6668
+ return;
6669
+ const identity = { type };
6670
+ if (authFlow)
6671
+ identity.authFlow = authFlow;
6672
+ if (type === "User") {
6673
+ const userId = asString(claims?.sub);
6674
+ if (userId)
6675
+ identity.userId = userId;
6676
+ if (email)
6677
+ identity.userEmail = email;
6678
+ const name = pickName(claims);
6679
+ if (name)
6680
+ identity.userName = name;
6681
+ return identity;
6682
+ }
6683
+ const clientId = asString(claims?.client_id);
6684
+ if (clientId)
6685
+ identity.clientId = clientId;
6686
+ const subType = asString(claims?.sub_type);
6687
+ if (subType)
6688
+ identity.subType = subType;
6689
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
6690
+ if (applicationSubtype)
6691
+ identity.applicationSubtype = applicationSubtype;
6692
+ return identity;
6693
+ };
6694
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
6695
+
6521
6696
  // ../auth/src/constants.ts
6522
6697
  var UIPATH_HOME_DIR = ".uipath";
6523
6698
  var AUTH_FILENAME = ".auth";
@@ -6667,22 +6842,12 @@ var resolveConfigAsync = async ({
6667
6842
  baseUrl = DEFAULT_BASE_URL;
6668
6843
  }
6669
6844
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
6670
- let clientId = customClientId;
6671
- if (!clientId && fileAuth.clientId) {
6672
- clientId = fileAuth.clientId;
6673
- }
6674
- if (!clientId) {
6675
- clientId = DEFAULT_CLIENT_ID;
6676
- }
6677
- let clientSecret = customClientSecret;
6678
- if (!clientSecret && fileAuth.clientSecret) {
6679
- clientSecret = fileAuth.clientSecret;
6680
- }
6681
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
6845
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
6846
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
6682
6847
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
6683
6848
  return {
6684
6849
  clientId,
6685
- clientSecret,
6850
+ clientSecret: customClientSecret,
6686
6851
  scopes,
6687
6852
  baseUrl,
6688
6853
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -6690,149 +6855,6 @@ var resolveConfigAsync = async ({
6690
6855
  };
6691
6856
  };
6692
6857
 
6693
- // ../auth/src/utils/platform.ts
6694
- function isBrowser() {
6695
- return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6696
- }
6697
-
6698
- // ../auth/src/utils/jwt.ts
6699
- class InvalidIssuerError extends Error {
6700
- expected;
6701
- actual;
6702
- constructor(expected, actual) {
6703
- const actualText = actual ?? "<missing>";
6704
- super(`Token issuer does not match the authority used to log in.
6705
- ` + `Expected: ${expected}
6706
- ` + `Actual: ${actualText}
6707
-
6708
- ` + `The identity server that issued this token is not the one ` + `you pointed --authority at. Refusing to save credentials.`);
6709
- this.expected = expected;
6710
- this.actual = actual;
6711
- this.name = "InvalidIssuerError";
6712
- }
6713
- }
6714
- var parseJWT = (token) => {
6715
- try {
6716
- const parts = token.split(".");
6717
- const base64Url = parts[1];
6718
- if (!base64Url) {
6719
- throw new Error("Invalid JWT token format - missing payload section");
6720
- }
6721
- const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
6722
- let decodedString;
6723
- if (isBrowser() && typeof atob !== "undefined") {
6724
- decodedString = atob(base64);
6725
- } else {
6726
- decodedString = Buffer.from(base64, "base64").toString();
6727
- }
6728
- const jsonPayload = decodeURIComponent(decodedString.split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));
6729
- const parsed = JSON.parse(jsonPayload);
6730
- return parsed;
6731
- } catch (error) {
6732
- throw new Error(`Failed to parse JWT: ${error instanceof Error ? error.message : "Unknown error"}`);
6733
- }
6734
- };
6735
- var assertIssuerMatchesAuthority = (token, authority) => {
6736
- let payload;
6737
- try {
6738
- payload = parseJWT(token);
6739
- } catch (error) {
6740
- throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
6741
- }
6742
- const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
6743
- const expected = `${stripTrailingSlash(authority)}/identity_`;
6744
- const actual = typeof payload.iss === "string" ? stripTrailingSlash(payload.iss) : undefined;
6745
- if (actual !== expected) {
6746
- throw new InvalidIssuerError(expected, payload.iss);
6747
- }
6748
- };
6749
- var getTokenExpiration = (accessToken) => {
6750
- try {
6751
- const parts = accessToken.split(".");
6752
- if (parts.length !== 3) {
6753
- return;
6754
- }
6755
- const payload = parts[1];
6756
- const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
6757
- const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
6758
- const decoded = atob(padded);
6759
- const claims = JSON.parse(decoded);
6760
- if (typeof claims.exp !== "number") {
6761
- return;
6762
- }
6763
- return new Date(claims.exp * 1000);
6764
- } catch {
6765
- return;
6766
- }
6767
- };
6768
-
6769
- // ../auth/src/sessionIdentity.ts
6770
- var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
6771
- var decodeClaims = (accessToken) => {
6772
- const [error, claims] = catchError2(() => parseJWT(accessToken));
6773
- return error ? undefined : claims;
6774
- };
6775
- var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
6776
- var resolveIdentityType = (claims, authFlow, email) => {
6777
- const subType = asString(claims?.sub_type);
6778
- if (subType) {
6779
- return subType.startsWith("service") ? "Application" : "User";
6780
- }
6781
- if (authFlow) {
6782
- return authFlow === "authorization_code" ? "User" : "Application";
6783
- }
6784
- if (email)
6785
- return "User";
6786
- if (asString(claims?.client_id) && !asString(claims?.sub)) {
6787
- return "Application";
6788
- }
6789
- return;
6790
- };
6791
- var looksLikeEmail = (value) => value?.includes("@") ?? false;
6792
- var pickEmail = (claims) => {
6793
- for (const candidate of [claims?.email, claims?.preferred_username]) {
6794
- const value = asString(candidate);
6795
- if (looksLikeEmail(value))
6796
- return value;
6797
- }
6798
- return;
6799
- };
6800
- var pickName = (claims) => {
6801
- const username = asString(claims?.preferred_username);
6802
- return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
6803
- };
6804
- var pickScopes = (claims) => {
6805
- const raw = claims?.scope;
6806
- const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6807
- return scopes.length > 0 ? scopes : undefined;
6808
- };
6809
- var resolveSessionIdentity = (accessToken, authFlow) => {
6810
- const claims = accessToken ? decodeClaims(accessToken) : undefined;
6811
- const email = pickEmail(claims);
6812
- const type = resolveIdentityType(claims, authFlow, email);
6813
- if (!type)
6814
- return;
6815
- const identity = { type };
6816
- if (authFlow)
6817
- identity.authFlow = authFlow;
6818
- if (type === "User") {
6819
- const userId = asString(claims?.sub);
6820
- if (userId)
6821
- identity.userId = userId;
6822
- if (email)
6823
- identity.userEmail = email;
6824
- const name = pickName(claims);
6825
- if (name)
6826
- identity.userName = name;
6827
- return identity;
6828
- }
6829
- const clientId = asString(claims?.client_id);
6830
- if (clientId)
6831
- identity.clientId = clientId;
6832
- return identity;
6833
- };
6834
- var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
6835
-
6836
6858
  // ../auth/src/envAuth.ts
6837
6859
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
6838
6860
  var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
@@ -7121,6 +7143,40 @@ var tryRobotClientFallback = async (options = {}) => {
7121
7143
  }
7122
7144
  };
7123
7145
 
7146
+ // ../auth/src/tenantSelection.ts
7147
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
7148
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
7149
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7150
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
7151
+ if (response.redirected) {
7152
+ return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
7153
+ }
7154
+ const contentType = response.headers.get("content-type") ?? "unknown";
7155
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
7156
+ };
7157
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
7158
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
7159
+ const response = await fetch(url, {
7160
+ headers: {
7161
+ Authorization: `Bearer ${accessToken}`
7162
+ },
7163
+ ...signal ? { signal } : {}
7164
+ });
7165
+ if (!response.ok) {
7166
+ if (response.status === 401) {
7167
+ throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
7168
+ }
7169
+ const errorText = await response.text();
7170
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
7171
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
7172
+ }
7173
+ const [parseError, data] = await catchError2(response.json());
7174
+ if (parseError) {
7175
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
7176
+ }
7177
+ return data;
7178
+ };
7179
+
7124
7180
  // ../auth/src/tokenRefresh.ts
7125
7181
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
7126
7182
 
@@ -7333,6 +7389,8 @@ var saveEnvFileAsync = async ({
7333
7389
  };
7334
7390
 
7335
7391
  // ../auth/src/loginStatus.ts
7392
+ var defaultRobotTenantIdCache = new Map;
7393
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
7336
7394
  var getLoginStatusAsync = async (options = {}) => {
7337
7395
  return getLoginStatusWithDeps(options);
7338
7396
  };
@@ -7345,12 +7403,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7345
7403
  refreshToken: refreshTokenFn = refreshAccessToken,
7346
7404
  resolveConfig = resolveConfigAsync,
7347
7405
  robotFallback = tryRobotClientFallback,
7406
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
7407
+ robotTenantIdCache = defaultRobotTenantIdCache,
7408
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
7348
7409
  loadBreaker = loadRefreshBreaker,
7349
7410
  saveBreaker = saveRefreshBreaker,
7350
7411
  clearBreaker = clearRefreshBreaker
7351
7412
  } = deps;
7413
+ const robotDeps = {
7414
+ fetchTenantsAndOrgs,
7415
+ cache: robotTenantIdCache,
7416
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
7417
+ };
7352
7418
  if (isRobotAuthEnforced()) {
7353
- return resolveRobotEnforcedStatus(robotFallback);
7419
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
7354
7420
  }
7355
7421
  if (isEnvAuthEnabled()) {
7356
7422
  return readAuthFromEnv();
@@ -7368,7 +7434,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7368
7434
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
7369
7435
  };
7370
7436
  }
7371
- return resolveBorrowedRobotStatus(robotFallback);
7437
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
7372
7438
  }
7373
7439
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
7374
7440
  if ("status" in loaded) {
@@ -7410,7 +7476,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7410
7476
  }
7411
7477
  return buildFileStatus(tokens, credentials, globalHint);
7412
7478
  };
7413
- async function resolveRobotEnforcedStatus(robotFallback) {
7479
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
7414
7480
  if (isEnvAuthEnabled()) {
7415
7481
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
7416
7482
  }
@@ -7421,11 +7487,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
7421
7487
  hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
7422
7488
  };
7423
7489
  }
7424
- return buildRobotStatus(robotCreds);
7490
+ return buildRobotStatus(robotCreds, deps);
7425
7491
  }
7426
- async function resolveBorrowedRobotStatus(robotFallback) {
7492
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
7427
7493
  const robotCreds = await robotFallback();
7428
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
7494
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
7429
7495
  }
7430
7496
  async function loadFileCredentials(loadEnvFile, absolutePath) {
7431
7497
  let credentials;
@@ -7560,9 +7626,10 @@ function identityFields(accessToken, credentials) {
7560
7626
  ...scopes ? { scopes } : {}
7561
7627
  };
7562
7628
  }
7563
- function buildRobotStatus(robotCreds) {
7629
+ async function buildRobotStatus(robotCreds, deps) {
7564
7630
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7565
7631
  const scopes = readTokenScopes(robotCreds.accessToken);
7632
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
7566
7633
  return {
7567
7634
  loginStatus: "Logged in",
7568
7635
  accessToken: robotCreds.accessToken,
@@ -7570,14 +7637,62 @@ function buildRobotStatus(robotCreds) {
7570
7637
  organizationName: robotCreds.organizationName,
7571
7638
  organizationId: robotCreds.organizationId,
7572
7639
  tenantName: robotCreds.tenantName,
7573
- tenantId: robotCreds.tenantId,
7640
+ tenantId: tenant.tenantId,
7574
7641
  issuer: robotCreds.issuer,
7575
7642
  expiration: getTokenExpiration(robotCreds.accessToken),
7576
7643
  source: "robot" /* Robot */,
7644
+ ...tenant.hint ? { hint: tenant.hint } : {},
7577
7645
  ...identity ? { identity } : {},
7578
7646
  ...scopes ? { scopes } : {}
7579
7647
  };
7580
7648
  }
7649
+ async function resolveRobotTenantId(robotCreds, deps) {
7650
+ const { baseUrl, accessToken, tenantName } = robotCreds;
7651
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
7652
+ if (!tenantName || !organization) {
7653
+ return {};
7654
+ }
7655
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
7656
+ let pending = deps.cache.get(key);
7657
+ if (!pending) {
7658
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
7659
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
7660
+ if (!settled.tenantId) {
7661
+ deps.cache.delete(key);
7662
+ }
7663
+ return settled;
7664
+ });
7665
+ deps.cache.set(key, pending);
7666
+ }
7667
+ return pending;
7668
+ }
7669
+ async function lookupRobotTenantId(target, deps) {
7670
+ const { baseUrl, accessToken, organization, tenantName } = target;
7671
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
7672
+ if (error) {
7673
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
7674
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
7675
+ }
7676
+ const rows = data?.tenants;
7677
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
7678
+ const wantedName = decodePathSegment(tenantName);
7679
+ const wanted = wantedName.toLowerCase();
7680
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
7681
+ if (!match) {
7682
+ const names = tenants.map((tenant) => tenant.name).join(", ");
7683
+ return {
7684
+ hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
7685
+ };
7686
+ }
7687
+ return { tenantId: match.id };
7688
+ }
7689
+ function tenantLookupFailureHint(tenantName, reason) {
7690
+ 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.`;
7691
+ }
7692
+ function decodePathSegment(segment) {
7693
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
7694
+ return error ? segment : decoded;
7695
+ }
7581
7696
  var isFileNotFoundError = (error) => {
7582
7697
  if (!(error instanceof Object))
7583
7698
  return false;
@@ -7846,9 +7961,6 @@ var getAuthContext = async (options = {}) => {
7846
7961
  identity: status.identity
7847
7962
  };
7848
7963
  };
7849
- // ../auth/src/tenantSelection.ts
7850
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7851
-
7852
7964
  // ../auth/src/selectTenant.ts
7853
7965
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
7854
7966
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -7856,6 +7968,6 @@ var TENANT_SELECTION_CODES = new Set([
7856
7968
  TENANT_SELECTION_REQUIRED_CODE,
7857
7969
  INVALID_TENANT_CODE
7858
7970
  ]);
7859
- export { catchError, extractErrorMessage, extractErrorMessageSync, RESULTS, OutputFormatter, classifiedFailure, Command, Option, processContext, isGuid, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, getLoginStatusAsync, getAuthContext };
7971
+ export { catchError, extractErrorMessage, extractErrorMessageSync, RESULTS, OutputFormatter, classifiedFailure, Command, Option, processContext, isGuid, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, resolveSessionIdentity, getLoginStatusAsync, getAuthContext };
7860
7972
 
7861
- //# debugId=03C7C5922AA9CA8C64756E2164756E21
7973
+ //# debugId=F7E91F021C30087964756E2164756E21
package/dist/tool.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-2nc68g5z.js";
5
- import"./tool-x7dndnx8.js";
4
+ } from "./tool-2nzkz5r2.js";
5
+ import"./tool-s6dm918n.js";
6
6
  import"./tool-bndhpxxj.js";
7
7
  import"./tool-1de529jm.js";
8
8
  export {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/tasks-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0-preview.255",
5
+ "version": "1.205.0-preview.256",
6
6
  "description": "Manage Action Center tasks.",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/"
@@ -18,5 +18,5 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "gitHead": "699c58dabb59414557755a8933bcbe40aa420df3"
21
+ "gitHead": "63740c6cbb7ff282fa9118cc16a148eb030b245f"
22
22
  }