@uipath/platform-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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-pmd7gj8b.js";
6
+ } from "./tool-jdfyn3w1.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -28139,7 +28139,7 @@ var package_default = {
28139
28139
  name: "@uipath/platform-tool",
28140
28140
  author: "UiPath",
28141
28141
  license: "SEE LICENSE IN LICENSE.txt",
28142
- version: "1.204.0-preview.255",
28142
+ version: "1.205.0-preview.256",
28143
28143
  description: "Manage UiPath platform-level resources such as tenant licensing.",
28144
28144
  publishConfig: {
28145
28145
  registry: "https://npm.pkg.github.com/"
@@ -28288,22 +28288,12 @@ var resolveConfigAsync = async ({
28288
28288
  baseUrl = DEFAULT_BASE_URL;
28289
28289
  }
28290
28290
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
28291
- let clientId = customClientId;
28292
- if (!clientId && fileAuth.clientId) {
28293
- clientId = fileAuth.clientId;
28294
- }
28295
- if (!clientId) {
28296
- clientId = DEFAULT_CLIENT_ID;
28297
- }
28298
- let clientSecret = customClientSecret;
28299
- if (!clientSecret && fileAuth.clientSecret) {
28300
- clientSecret = fileAuth.clientSecret;
28301
- }
28302
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
28291
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
28292
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
28303
28293
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
28304
28294
  return {
28305
28295
  clientId,
28306
- clientSecret,
28296
+ clientSecret: customClientSecret,
28307
28297
  scopes,
28308
28298
  baseUrl,
28309
28299
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -28496,6 +28486,16 @@ class NodeFileSystem {
28496
28486
  async rename(oldPath, newPath) {
28497
28487
  await fs.rename(oldPath, newPath);
28498
28488
  }
28489
+ async isSymbolicLink(filePath) {
28490
+ try {
28491
+ return (await fs.lstat(filePath)).isSymbolicLink();
28492
+ } catch (error) {
28493
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
28494
+ return false;
28495
+ }
28496
+ throw error;
28497
+ }
28498
+ }
28499
28499
  async realpath(filePath) {
28500
28500
  try {
28501
28501
  return await fs.realpath(filePath);
@@ -28707,6 +28707,16 @@ var resolveIdentityType = (claims, authFlow, email) => {
28707
28707
  }
28708
28708
  return;
28709
28709
  };
28710
+ var resolveApplicationSubtype = (claims, authFlow) => {
28711
+ switch (asString(claims?.sub_type)) {
28712
+ case "service.external":
28713
+ return "External";
28714
+ case "service.internal":
28715
+ return "Internal";
28716
+ default:
28717
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
28718
+ }
28719
+ };
28710
28720
  var looksLikeEmail = (value) => value?.includes("@") ?? false;
28711
28721
  var pickEmail = (claims) => {
28712
28722
  for (const candidate of [claims?.email, claims?.preferred_username]) {
@@ -28748,6 +28758,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
28748
28758
  const clientId = asString(claims?.client_id);
28749
28759
  if (clientId)
28750
28760
  identity.clientId = clientId;
28761
+ const subType = asString(claims?.sub_type);
28762
+ if (subType)
28763
+ identity.subType = subType;
28764
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
28765
+ if (applicationSubtype)
28766
+ identity.applicationSubtype = applicationSubtype;
28751
28767
  return identity;
28752
28768
  };
28753
28769
  var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
@@ -29040,6 +29056,40 @@ var tryRobotClientFallback = async (options = {}) => {
29040
29056
  }
29041
29057
  };
29042
29058
 
29059
+ // ../auth/src/tenantSelection.ts
29060
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
29061
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
29062
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
29063
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
29064
+ if (response.redirected) {
29065
+ 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}`;
29066
+ }
29067
+ const contentType = response.headers.get("content-type") ?? "unknown";
29068
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
29069
+ };
29070
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
29071
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
29072
+ const response = await fetch(url, {
29073
+ headers: {
29074
+ Authorization: `Bearer ${accessToken}`
29075
+ },
29076
+ ...signal ? { signal } : {}
29077
+ });
29078
+ if (!response.ok) {
29079
+ if (response.status === 401) {
29080
+ 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);
29081
+ }
29082
+ const errorText = await response.text();
29083
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
29084
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
29085
+ }
29086
+ const [parseError, data] = await catchError(response.json());
29087
+ if (parseError) {
29088
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
29089
+ }
29090
+ return data;
29091
+ };
29092
+
29043
29093
  // ../auth/src/tokenRefresh.ts
29044
29094
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
29045
29095
 
@@ -29252,6 +29302,8 @@ var saveEnvFileAsync = async ({
29252
29302
  };
29253
29303
 
29254
29304
  // ../auth/src/loginStatus.ts
29305
+ var defaultRobotTenantIdCache = new Map;
29306
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
29255
29307
  var getLoginStatusAsync = async (options = {}) => {
29256
29308
  return getLoginStatusWithDeps(options);
29257
29309
  };
@@ -29264,12 +29316,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
29264
29316
  refreshToken: refreshTokenFn = refreshAccessToken,
29265
29317
  resolveConfig = resolveConfigAsync,
29266
29318
  robotFallback = tryRobotClientFallback,
29319
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
29320
+ robotTenantIdCache = defaultRobotTenantIdCache,
29321
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
29267
29322
  loadBreaker = loadRefreshBreaker,
29268
29323
  saveBreaker = saveRefreshBreaker,
29269
29324
  clearBreaker = clearRefreshBreaker
29270
29325
  } = deps;
29326
+ const robotDeps = {
29327
+ fetchTenantsAndOrgs,
29328
+ cache: robotTenantIdCache,
29329
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
29330
+ };
29271
29331
  if (isRobotAuthEnforced()) {
29272
- return resolveRobotEnforcedStatus(robotFallback);
29332
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
29273
29333
  }
29274
29334
  if (isEnvAuthEnabled()) {
29275
29335
  return readAuthFromEnv();
@@ -29287,7 +29347,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
29287
29347
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
29288
29348
  };
29289
29349
  }
29290
- return resolveBorrowedRobotStatus(robotFallback);
29350
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
29291
29351
  }
29292
29352
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
29293
29353
  if ("status" in loaded) {
@@ -29329,7 +29389,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
29329
29389
  }
29330
29390
  return buildFileStatus(tokens, credentials, globalHint);
29331
29391
  };
29332
- async function resolveRobotEnforcedStatus(robotFallback) {
29392
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
29333
29393
  if (isEnvAuthEnabled()) {
29334
29394
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
29335
29395
  }
@@ -29340,11 +29400,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
29340
29400
  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.`
29341
29401
  };
29342
29402
  }
29343
- return buildRobotStatus(robotCreds);
29403
+ return buildRobotStatus(robotCreds, deps);
29344
29404
  }
29345
- async function resolveBorrowedRobotStatus(robotFallback) {
29405
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
29346
29406
  const robotCreds = await robotFallback();
29347
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
29407
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
29348
29408
  }
29349
29409
  async function loadFileCredentials(loadEnvFile, absolutePath) {
29350
29410
  let credentials;
@@ -29479,9 +29539,10 @@ function identityFields(accessToken, credentials) {
29479
29539
  ...scopes ? { scopes } : {}
29480
29540
  };
29481
29541
  }
29482
- function buildRobotStatus(robotCreds) {
29542
+ async function buildRobotStatus(robotCreds, deps) {
29483
29543
  const identity = resolveSessionIdentity(robotCreds.accessToken);
29484
29544
  const scopes = readTokenScopes(robotCreds.accessToken);
29545
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
29485
29546
  return {
29486
29547
  loginStatus: "Logged in",
29487
29548
  accessToken: robotCreds.accessToken,
@@ -29489,14 +29550,62 @@ function buildRobotStatus(robotCreds) {
29489
29550
  organizationName: robotCreds.organizationName,
29490
29551
  organizationId: robotCreds.organizationId,
29491
29552
  tenantName: robotCreds.tenantName,
29492
- tenantId: robotCreds.tenantId,
29553
+ tenantId: tenant.tenantId,
29493
29554
  issuer: robotCreds.issuer,
29494
29555
  expiration: getTokenExpiration(robotCreds.accessToken),
29495
29556
  source: "robot" /* Robot */,
29557
+ ...tenant.hint ? { hint: tenant.hint } : {},
29496
29558
  ...identity ? { identity } : {},
29497
29559
  ...scopes ? { scopes } : {}
29498
29560
  };
29499
29561
  }
29562
+ async function resolveRobotTenantId(robotCreds, deps) {
29563
+ const { baseUrl, accessToken, tenantName } = robotCreds;
29564
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
29565
+ if (!tenantName || !organization) {
29566
+ return {};
29567
+ }
29568
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
29569
+ let pending = deps.cache.get(key);
29570
+ if (!pending) {
29571
+ pending = catchError(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
29572
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
29573
+ if (!settled.tenantId) {
29574
+ deps.cache.delete(key);
29575
+ }
29576
+ return settled;
29577
+ });
29578
+ deps.cache.set(key, pending);
29579
+ }
29580
+ return pending;
29581
+ }
29582
+ async function lookupRobotTenantId(target, deps) {
29583
+ const { baseUrl, accessToken, organization, tenantName } = target;
29584
+ const [error, data] = await catchError(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
29585
+ if (error) {
29586
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
29587
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
29588
+ }
29589
+ const rows = data?.tenants;
29590
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
29591
+ const wantedName = decodePathSegment(tenantName);
29592
+ const wanted = wantedName.toLowerCase();
29593
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
29594
+ if (!match) {
29595
+ const names = tenants.map((tenant) => tenant.name).join(", ");
29596
+ return {
29597
+ 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.`
29598
+ };
29599
+ }
29600
+ return { tenantId: match.id };
29601
+ }
29602
+ function tenantLookupFailureHint(tenantName, reason) {
29603
+ 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.`;
29604
+ }
29605
+ function decodePathSegment(segment) {
29606
+ const [error, decoded] = catchError(() => decodeURIComponent(segment));
29607
+ return error ? segment : decoded;
29608
+ }
29500
29609
  var isFileNotFoundError = (error) => {
29501
29610
  if (!(error instanceof Object))
29502
29611
  return false;
@@ -29765,39 +29874,6 @@ var getAuthContext = async (options = {}) => {
29765
29874
  identity: status.identity
29766
29875
  };
29767
29876
  };
29768
- // ../auth/src/tenantSelection.ts
29769
- var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
29770
- var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
29771
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
29772
- var describeNonJsonResponse = (organizationId, response, parseError) => {
29773
- if (response.redirected) {
29774
- 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}`;
29775
- }
29776
- const contentType = response.headers.get("content-type") ?? "unknown";
29777
- return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
29778
- };
29779
- var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
29780
- const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
29781
- const response = await fetch(url, {
29782
- headers: {
29783
- Authorization: `Bearer ${accessToken}`
29784
- }
29785
- });
29786
- if (!response.ok) {
29787
- if (response.status === 401) {
29788
- 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);
29789
- }
29790
- const errorText = await response.text();
29791
- const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
29792
- throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
29793
- }
29794
- const [parseError, data] = await catchError(response.json());
29795
- if (parseError) {
29796
- throw new Error(describeNonJsonResponse(organizationId, response, parseError));
29797
- }
29798
- return data;
29799
- };
29800
-
29801
29877
  // ../auth/src/selectTenant.ts
29802
29878
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
29803
29879
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -30790,7 +30866,7 @@ function setGlobalLogFilePath(path2) {
30790
30866
  function getGlobalLogFilePath() {
30791
30867
  return logFilePathSlot.get("");
30792
30868
  }
30793
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
30869
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
30794
30870
 
30795
30871
  class SimpleLogger {
30796
30872
  __brand = "SimpleLogger";
@@ -31057,7 +31133,9 @@ var ErrorDimensions = {
31057
31133
  Result: "Result",
31058
31134
  ErrorCode: "ErrorCode",
31059
31135
  Retry: "Retry",
31060
- ErrorMessage: "ErrorMessage"
31136
+ ErrorMessage: "ErrorMessage",
31137
+ HttpStatus: "HttpStatus",
31138
+ UpstreamErrorCode: "UpstreamErrorCode"
31061
31139
  };
31062
31140
  var AuthDimensions = {
31063
31141
  AuthenticationMethod: "AuthenticationMethod",
@@ -32045,7 +32123,9 @@ var CLI_ERROR_CODES = [
32045
32123
  "timeout",
32046
32124
  "server_error",
32047
32125
  "method_not_allowed",
32126
+ "not_supported",
32048
32127
  "configuration_error",
32128
+ "execution_failed",
32049
32129
  "unknown_error"
32050
32130
  ];
32051
32131
  var RETRY_HINTS = [
@@ -33035,7 +33115,9 @@ var OutputFormatter;
33035
33115
  [ErrorDimensions.Result]: data.Result,
33036
33116
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
33037
33117
  [ErrorDimensions.Retry]: data.Retry,
33038
- [ErrorDimensions.ErrorMessage]: data.Message
33118
+ [ErrorDimensions.ErrorMessage]: data.Message,
33119
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
33120
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
33039
33121
  });
33040
33122
  }
33041
33123
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -35291,7 +35373,7 @@ var package_default2 = {
35291
35373
  name: "@uipath/identity-sdk",
35292
35374
  author: "UiPath",
35293
35375
  license: "SEE LICENSE IN LICENSE.txt",
35294
- version: "1.204.0",
35376
+ version: "1.205.0",
35295
35377
  repository: {
35296
35378
  type: "git",
35297
35379
  url: "https://github.com/UiPath/cli.git",
@@ -37948,4 +38030,4 @@ var registerCommands = async (program2) => {
37948
38030
 
37949
38031
  export { Command, metadata, registerCommands };
37950
38032
 
37951
- //# debugId=5A7E77AF68ACB3A264756E2164756E21
38033
+ //# debugId=C943D6A008E0C28764756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-pmd7gj8b.js";
4
+ } from "./tool-jdfyn3w1.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/platform-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 UiPath platform-level resources such as tenant licensing.",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/"
@@ -21,5 +21,5 @@
21
21
  "keywords": [
22
22
  "cli-tool"
23
23
  ],
24
- "gitHead": "699c58dabb59414557755a8933bcbe40aa420df3"
24
+ "gitHead": "63740c6cbb7ff282fa9118cc16a148eb030b245f"
25
25
  }