@uipath/codedapp-tool 1.202.0 → 1.203.0-preview.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import {
2
- catchError,
3
- getFileSystem
4
- } from "./packager-tool-qyctya2j.js";
5
1
  import {
6
2
  getGlobalThis,
7
3
  isBrowser
8
4
  } from "./packager-tool-0gctz400.js";
5
+ import {
6
+ catchError,
7
+ getFileSystem
8
+ } from "./packager-tool-qyctya2j.js";
9
9
  import {
10
10
  AUTH_FILENAME,
11
11
  DEFAULT_BASE_URL,
@@ -566,6 +566,63 @@ function getActiveAuthProfileFilePath() {
566
566
  const profile = getActiveAuthProfile();
567
567
  return profile ? resolveAuthProfileFilePath(profile) : undefined;
568
568
  }
569
+ function getAuthProfilesRootPath() {
570
+ const fs = getFileSystem();
571
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR);
572
+ }
573
+ function resolveAuthProfileDirPath(profile) {
574
+ const normalized = normalizeAuthProfileName(profile);
575
+ if (normalized === undefined) {
576
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile directory.`);
577
+ }
578
+ const fs = getFileSystem();
579
+ return fs.path.join(getAuthProfilesRootPath(), normalized);
580
+ }
581
+ async function listAuthProfileNamesAsync() {
582
+ const fs = getFileSystem();
583
+ const root = getAuthProfilesRootPath();
584
+ if (!await fs.exists(root)) {
585
+ return [];
586
+ }
587
+ const [readError, entries] = await catchError(fs.readdir(root));
588
+ if (readError || !entries) {
589
+ return [];
590
+ }
591
+ const names = [];
592
+ for (const entry of entries) {
593
+ if (!PROFILE_NAME_RE.test(entry) || entry === DEFAULT_AUTH_PROFILE) {
594
+ continue;
595
+ }
596
+ const stats = await fs.stat(fs.path.join(root, entry));
597
+ if (stats?.isDirectory()) {
598
+ names.push(entry);
599
+ }
600
+ }
601
+ return names.sort((a, b) => a.localeCompare(b));
602
+ }
603
+ async function authProfileExistsAsync(profile) {
604
+ const fs = getFileSystem();
605
+ const [pathError, dir] = catchError(() => resolveAuthProfileDirPath(profile));
606
+ if (pathError || dir === undefined) {
607
+ return false;
608
+ }
609
+ const stats = await fs.stat(dir);
610
+ return stats?.isDirectory() === true;
611
+ }
612
+ async function deleteAuthProfileAsync(profile) {
613
+ const dir = resolveAuthProfileDirPath(profile);
614
+ const fs = getFileSystem();
615
+ const relativeToRoot = fs.path.relative(getAuthProfilesRootPath(), dir);
616
+ if (relativeToRoot === "" || relativeToRoot.startsWith("..") || fs.path.isAbsolute(relativeToRoot)) {
617
+ throw new AuthProfileValidationError(`Refusing to delete "${profile}": resolved path escapes the profiles directory.`);
618
+ }
619
+ const stats = await fs.stat(dir);
620
+ if (stats?.isDirectory() !== true) {
621
+ return;
622
+ }
623
+ await fs.rm(dir);
624
+ return dir;
625
+ }
569
626
 
570
627
  // ../auth/src/utils/jwt.ts
571
628
  class InvalidIssuerError extends Error {
@@ -1134,16 +1191,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
1134
1191
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
1135
1192
  };
1136
1193
  };
1137
- var loadEnvFileAsync = async ({ envPath }) => {
1138
- const fs = getFileSystem();
1139
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
1140
- if (!await fs.exists(absolutePath)) {
1141
- throw new Error(`Environment file not found: ${envPath}`);
1142
- }
1143
- const content = await fs.readFile(absolutePath, "utf-8");
1144
- if (content === null) {
1145
- throw new Error(`Environment file not found: ${envPath}`);
1146
- }
1194
+ var parseEnvContent = (content) => {
1147
1195
  const env = {};
1148
1196
  for (const line of content.split(`
1149
1197
  `)) {
@@ -1164,6 +1212,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
1164
1212
  }
1165
1213
  return env;
1166
1214
  };
1215
+ var loadEnvFileAsync = async ({ envPath }) => {
1216
+ const fs = getFileSystem();
1217
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
1218
+ if (!await fs.exists(absolutePath)) {
1219
+ throw new Error(`Environment file not found: ${envPath}`);
1220
+ }
1221
+ const content = await fs.readFile(absolutePath, "utf-8");
1222
+ if (content === null) {
1223
+ throw new Error(`Environment file not found: ${envPath}`);
1224
+ }
1225
+ return parseEnvContent(content);
1226
+ };
1167
1227
  var saveEnvFileAsync = async ({
1168
1228
  envPath,
1169
1229
  data,
@@ -1738,6 +1798,61 @@ var getAuthEnv = async (options = {}) => {
1738
1798
  }
1739
1799
  return { authEnv, loginStatus: status };
1740
1800
  };
1801
+ // ../auth/src/authProfileDetails.ts
1802
+ var ORGANIZATION_NAME_KEY = "UIPATH_ORGANIZATION_NAME";
1803
+ var TENANT_NAME_KEY = "UIPATH_TENANT_NAME";
1804
+ var URL_KEY = "UIPATH_URL";
1805
+ var ACCESS_TOKEN_KEY = "UIPATH_ACCESS_TOKEN";
1806
+ function statusFromToken(accessToken) {
1807
+ if (!accessToken) {
1808
+ return { status: "Not logged in" };
1809
+ }
1810
+ const expiration = getTokenExpiration(accessToken);
1811
+ if (expiration === undefined) {
1812
+ return { status: "Logged in" };
1813
+ }
1814
+ return {
1815
+ status: expiration.getTime() <= Date.now() ? "Expired" : "Logged in",
1816
+ expiresAt: expiration.toISOString()
1817
+ };
1818
+ }
1819
+ async function describeAuthProfileAsync(name, filePath, active) {
1820
+ const base = {
1821
+ name,
1822
+ active,
1823
+ ...filePath ? { path: filePath } : {}
1824
+ };
1825
+ if (!filePath) {
1826
+ return { ...base, status: "Not logged in" };
1827
+ }
1828
+ const fs = getFileSystem();
1829
+ const [readError, content] = await catchError(fs.readFile(filePath, "utf-8"));
1830
+ if (readError) {
1831
+ return { ...base, status: "Unreadable" };
1832
+ }
1833
+ if (content === null || content === undefined) {
1834
+ return { ...base, status: "Not logged in" };
1835
+ }
1836
+ const values = parseEnvContent(content);
1837
+ return {
1838
+ ...base,
1839
+ ...values[ORGANIZATION_NAME_KEY] ? { organizationName: values[ORGANIZATION_NAME_KEY] } : {},
1840
+ ...values[TENANT_NAME_KEY] ? { tenantName: values[TENANT_NAME_KEY] } : {},
1841
+ ...values[URL_KEY] ? { url: values[URL_KEY] } : {},
1842
+ ...statusFromToken(values[ACCESS_TOKEN_KEY])
1843
+ };
1844
+ }
1845
+ async function describeAuthProfilesAsync() {
1846
+ const activeProfile = getActiveAuthProfile();
1847
+ const [defaultPathError, defaultLocation] = await catchError(resolveEnvFilePathAsync());
1848
+ const rows = [
1849
+ await describeAuthProfileAsync(DEFAULT_AUTH_PROFILE, defaultPathError ? undefined : defaultLocation?.absolutePath, activeProfile === undefined)
1850
+ ];
1851
+ for (const name of await listAuthProfileNamesAsync()) {
1852
+ rows.push(await describeAuthProfileAsync(name, resolveAuthProfileFilePath(name), activeProfile === name));
1853
+ }
1854
+ return rows;
1855
+ }
1741
1856
  // ../auth/src/tokenGrant.ts
1742
1857
  var requestClientCredentialsToken = async ({
1743
1858
  tokenEndpoint,
@@ -2320,6 +2435,6 @@ var authenticate = async ({
2320
2435
  });
2321
2436
  };
2322
2437
 
2323
- export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, parseJWT, parseAuthFlow, resolveSessionIdentity, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
2438
+ export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, getAuthProfilesRootPath, resolveAuthProfileDirPath, listAuthProfileNamesAsync, authProfileExistsAsync, deleteAuthProfileAsync, parseJWT, parseAuthFlow, resolveSessionIdentity, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, 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, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
2324
2439
 
2325
- //# debugId=432C00A85D700C2164756E2164756E21
2440
+ //# debugId=E7AC7F320178FAB464756E2164756E21