@uipath/function-tool 1.205.0-preview.276 → 1.206.0-preview.279
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/README.md +12 -0
- package/dist/{browser-strategy-tyy1nbjg.js → browser-strategy-bxv33ex0.js} +3 -6
- package/dist/{cliRunner-6t7v6dqr.js → cliRunner-mb829q93.js} +91 -92
- package/dist/index-6n2xsc30.js +14 -0
- package/dist/index-8h152v0c.js +10221 -0
- package/dist/{index-jhfvqtwr.js → index-dtz2wm6p.js} +247 -209
- package/dist/{index-sby22td6.js → index-nzr4mx5p.js} +2 -22
- package/dist/index-t90k2g7s.js +1130 -0
- package/dist/{jmespath-231m3hyn.js → jmespath-ab6tdc42.js} +1 -1
- package/dist/{js-yaml-88tdqrtd.js → js-yaml-a2bk27p6.js} +1 -3
- package/dist/{node-strategy-nmepnk2k.js → node-strategy-dhvvrt9n.js} +7 -12
- package/dist/{packager-tool-f7enb48c.js → packager-tool-cmtxbmhx.js} +1761 -706
- package/dist/{packager-tool-1de529jm.js → packager-tool-epsr41wx.js} +12 -3
- package/dist/{packager-tool-1shggyya.js → packager-tool-qjerhjyd.js} +78 -684
- package/dist/packager-tool.js +670 -30
- package/dist/tool.js +31 -30
- package/package.json +2 -2
- package/dist/index-at7vc5xq.js +0 -157
- package/dist/index-fs5kc7z6.js +0 -6224
- package/dist/index-q8r0mcyb.js +0 -10221
- package/dist/packager-tool-0gctz400.js +0 -17
- package/dist/packager-tool-b098y4a2.js +0 -646
- package/dist/packager-tool-qa9gftnj.js +0 -31
- package/dist/packager-tool-y4vgqz1w.js +0 -247
- package/dist/packager-tool-yc4kw997.js +0 -13
- /package/dist/{packager-tool-h7ke7taj.js → packager-tool-3bw869ja.js} +0 -0
|
@@ -1,30 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
catchError
|
|
3
|
-
} from "./packager-tool-qa9gftnj.js";
|
|
4
1
|
import {
|
|
5
2
|
getFileSystem
|
|
6
|
-
} from "./packager-tool-
|
|
7
|
-
import {
|
|
8
|
-
getGlobalThis,
|
|
9
|
-
isBrowser
|
|
10
|
-
} from "./packager-tool-0gctz400.js";
|
|
11
|
-
import {
|
|
12
|
-
AUTH_FILENAME,
|
|
13
|
-
DEFAULT_BASE_URL,
|
|
14
|
-
DEFAULT_REDIRECT_URI,
|
|
15
|
-
UIPATH_HOME_DIR
|
|
16
|
-
} from "./packager-tool-yc4kw997.js";
|
|
3
|
+
} from "./packager-tool-cmtxbmhx.js";
|
|
17
4
|
import {
|
|
18
5
|
__require
|
|
19
|
-
} from "./packager-tool-
|
|
6
|
+
} from "./packager-tool-epsr41wx.js";
|
|
7
|
+
|
|
8
|
+
// ../auth/src/catch-error.ts
|
|
9
|
+
function isPromiseLike(value) {
|
|
10
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
11
|
+
}
|
|
12
|
+
function catchError(fnOrPromise) {
|
|
13
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
14
|
+
return settlePromiseLike(fnOrPromise);
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const result = fnOrPromise();
|
|
18
|
+
if (isPromiseLike(result)) {
|
|
19
|
+
return settlePromiseLike(result);
|
|
20
|
+
}
|
|
21
|
+
return [undefined, result];
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return [
|
|
24
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
25
|
+
undefined
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function settlePromiseLike(thenable) {
|
|
30
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
31
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
32
|
+
undefined
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../auth/src/constants.ts
|
|
37
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
38
|
+
var AUTH_FILENAME = ".auth";
|
|
39
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
40
|
+
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
41
|
+
var AUTH_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT";
|
|
42
|
+
var AUTH_CANCELLED_ERROR_CODE = "EAUTHCANCELLED";
|
|
43
|
+
var AUTH_RECLAIMED_ERROR_CODE = "EAUTHRECLAIMED";
|
|
44
|
+
var DEFAULT_REDIRECT_URI = "http://localhost:8104/oidc/login";
|
|
20
45
|
|
|
21
46
|
// ../auth/src/config.ts
|
|
22
47
|
var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
|
|
23
48
|
var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
|
|
24
49
|
var globalSlot = globalThis;
|
|
25
|
-
var setAuthFileConfig = (cfg) => {
|
|
26
|
-
globalSlot[AUTH_FILE_CONFIG_KEY] = cfg ?? {};
|
|
27
|
-
};
|
|
28
50
|
var getAuthFileConfig = () => globalSlot[AUTH_FILE_CONFIG_KEY] ?? {};
|
|
29
51
|
|
|
30
52
|
class InvalidBaseUrlError extends Error {
|
|
@@ -289,14 +311,14 @@ function ClientSecretPost2(clientSecret) {
|
|
|
289
311
|
return ClientSecretPost(clientSecret);
|
|
290
312
|
}
|
|
291
313
|
tbi ||= new WeakMap;
|
|
292
|
-
return (as, client, body,
|
|
314
|
+
return (as, client, body, headers) => {
|
|
293
315
|
let auth;
|
|
294
316
|
if (!(auth = tbi.get(client))) {
|
|
295
317
|
assertString2(client.client_secret, '"metadata.client_secret"');
|
|
296
318
|
auth = ClientSecretPost(client.client_secret);
|
|
297
319
|
tbi.set(client, auth);
|
|
298
320
|
}
|
|
299
|
-
return auth(as, client, body,
|
|
321
|
+
return auth(as, client, body, headers);
|
|
300
322
|
};
|
|
301
323
|
}
|
|
302
324
|
function assertString2(input, it) {
|
|
@@ -462,6 +484,17 @@ var exchangeCodeForTokens = async ({
|
|
|
462
484
|
return { accessToken, refreshToken };
|
|
463
485
|
};
|
|
464
486
|
|
|
487
|
+
// ../auth/src/utils/platform.ts
|
|
488
|
+
function isBrowser() {
|
|
489
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
490
|
+
}
|
|
491
|
+
function getGlobalThis() {
|
|
492
|
+
if (typeof globalThis !== "undefined") {
|
|
493
|
+
return globalThis;
|
|
494
|
+
}
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
465
498
|
// ../auth/src/authProfile.ts
|
|
466
499
|
var DEFAULT_AUTH_PROFILE = "default";
|
|
467
500
|
var PROFILE_DIR = "profiles";
|
|
@@ -510,31 +543,6 @@ function normalizeAuthProfileName(profile) {
|
|
|
510
543
|
}
|
|
511
544
|
return profile;
|
|
512
545
|
}
|
|
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
546
|
function getActiveAuthProfile() {
|
|
539
547
|
const scopedState = profileStorage.getStore();
|
|
540
548
|
if (scopedState !== undefined) {
|
|
@@ -542,10 +550,6 @@ function getActiveAuthProfile() {
|
|
|
542
550
|
}
|
|
543
551
|
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
544
552
|
}
|
|
545
|
-
function runWithAuthProfile(profile, fn) {
|
|
546
|
-
const normalized = normalizeAuthProfileName(profile);
|
|
547
|
-
return profileStorage.run(normalized === undefined ? {} : { profile: normalized }, fn);
|
|
548
|
-
}
|
|
549
553
|
function resolveAuthProfileFilePath(profile) {
|
|
550
554
|
const normalized = normalizeAuthProfileName(profile);
|
|
551
555
|
if (normalized === undefined) {
|
|
@@ -558,63 +562,6 @@ function getActiveAuthProfileFilePath() {
|
|
|
558
562
|
const profile = getActiveAuthProfile();
|
|
559
563
|
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
560
564
|
}
|
|
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
565
|
|
|
619
566
|
// ../auth/src/utils/jwt.ts
|
|
620
567
|
class InvalidIssuerError extends Error {
|
|
@@ -782,6 +729,8 @@ var ENV_AUTH_VARS = {
|
|
|
782
729
|
};
|
|
783
730
|
|
|
784
731
|
class EnvAuthConfigError extends Error {
|
|
732
|
+
errorCode = "configuration_error";
|
|
733
|
+
retry = "RetryWillNotFix";
|
|
785
734
|
constructor(message) {
|
|
786
735
|
super(message);
|
|
787
736
|
this.name = "EnvAuthConfigError";
|
|
@@ -820,11 +769,11 @@ var readAuthFromEnv = () => {
|
|
|
820
769
|
if (!rawUrl) {
|
|
821
770
|
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
771
|
}
|
|
823
|
-
const
|
|
772
|
+
const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
824
773
|
return {
|
|
825
774
|
loginStatus: "Logged in",
|
|
826
775
|
accessToken,
|
|
827
|
-
baseUrl
|
|
776
|
+
baseUrl,
|
|
828
777
|
organizationName,
|
|
829
778
|
organizationId,
|
|
830
779
|
tenantName,
|
|
@@ -969,9 +918,6 @@ var parseResourceUrl = (url) => {
|
|
|
969
918
|
};
|
|
970
919
|
};
|
|
971
920
|
var ROBOT_CLIENT_LOADER_KEY = Symbol.for("@uipath/auth/RobotClientLoader");
|
|
972
|
-
var registerRobotClientLoader = (loader) => {
|
|
973
|
-
globalThis[ROBOT_CLIENT_LOADER_KEY] = loader;
|
|
974
|
-
};
|
|
975
921
|
var getRegisteredRobotClientLoader = () => {
|
|
976
922
|
const loader = globalThis[ROBOT_CLIENT_LOADER_KEY];
|
|
977
923
|
return typeof loader === "function" ? loader : undefined;
|
|
@@ -1127,9 +1073,12 @@ var refreshAccessToken = async ({
|
|
|
1127
1073
|
body: tokenParams
|
|
1128
1074
|
});
|
|
1129
1075
|
const tokenData = await tokenResponse.json();
|
|
1130
|
-
if (
|
|
1076
|
+
if (tokenResponse.status === 400 || tokenResponse.status === 401) {
|
|
1131
1077
|
throw new TokenRefreshOAuthError;
|
|
1132
1078
|
}
|
|
1079
|
+
if (!tokenResponse.ok) {
|
|
1080
|
+
throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
|
|
1081
|
+
}
|
|
1133
1082
|
const newAccessToken = tokenData.access_token;
|
|
1134
1083
|
const newRefreshToken = tokenData.refresh_token;
|
|
1135
1084
|
if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
|
|
@@ -1145,7 +1094,6 @@ var refreshAccessToken = async ({
|
|
|
1145
1094
|
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
1146
1095
|
|
|
1147
1096
|
// ../auth/src/utils/envFile.ts
|
|
1148
|
-
var DEFAULT_AUTH_FILENAME = AUTH_FILENAME;
|
|
1149
1097
|
var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR}/${AUTH_FILENAME}`;
|
|
1150
1098
|
var KNOWN_ERROR_CODES = new Set([
|
|
1151
1099
|
"EISDIR",
|
|
@@ -1193,20 +1141,20 @@ var probeAsync = async (fs, candidate) => {
|
|
|
1193
1141
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
1194
1142
|
const fs = getFileSystem();
|
|
1195
1143
|
if (fs.path.isAbsolute(envFilePath)) {
|
|
1196
|
-
const
|
|
1197
|
-
return
|
|
1144
|
+
const probe = await probeAsync(fs, envFilePath);
|
|
1145
|
+
return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
1198
1146
|
exists: false,
|
|
1199
1147
|
absolutePath: envFilePath,
|
|
1200
1148
|
source: "absolute",
|
|
1201
|
-
...
|
|
1149
|
+
...probe.unusable ? { unusable: probe.unusable } : {}
|
|
1202
1150
|
};
|
|
1203
1151
|
}
|
|
1204
1152
|
const cwd = opts?.cwd ?? fs.env.cwd();
|
|
1205
1153
|
let searchDir = cwd;
|
|
1206
1154
|
while (true) {
|
|
1207
1155
|
const candidate = fs.path.join(searchDir, envFilePath);
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1156
|
+
const probe = await probeAsync(fs, candidate);
|
|
1157
|
+
if (probe.exists) {
|
|
1210
1158
|
return {
|
|
1211
1159
|
exists: true,
|
|
1212
1160
|
absolutePath: candidate,
|
|
@@ -1231,7 +1179,7 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
1231
1179
|
...probe.unusable ? { unusable: probe.unusable } : {}
|
|
1232
1180
|
};
|
|
1233
1181
|
};
|
|
1234
|
-
var
|
|
1182
|
+
var resolveEnvFilePathAsync2 = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
1235
1183
|
const location = await resolveEnvFileLocationAsync(envFilePath, opts);
|
|
1236
1184
|
if (location.exists) {
|
|
1237
1185
|
return { absolutePath: location.absolutePath };
|
|
@@ -1262,7 +1210,7 @@ var parseEnvContent = (content) => {
|
|
|
1262
1210
|
}
|
|
1263
1211
|
return env;
|
|
1264
1212
|
};
|
|
1265
|
-
var
|
|
1213
|
+
var loadEnvFileAsync2 = async ({ envPath }) => {
|
|
1266
1214
|
const fs = getFileSystem();
|
|
1267
1215
|
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
|
|
1268
1216
|
if (!await fs.exists(absolutePath)) {
|
|
@@ -1284,7 +1232,7 @@ var saveEnvFileAsync = async ({
|
|
|
1284
1232
|
let existingData = {};
|
|
1285
1233
|
if (merge && await fs.exists(absolutePath)) {
|
|
1286
1234
|
try {
|
|
1287
|
-
existingData = await
|
|
1235
|
+
existingData = await loadEnvFileAsync2({ envPath: absolutePath });
|
|
1288
1236
|
} catch {}
|
|
1289
1237
|
}
|
|
1290
1238
|
const finalData = { ...existingData, ...data };
|
|
@@ -1308,12 +1256,6 @@ var saveEnvFileAsync = async ({
|
|
|
1308
1256
|
};
|
|
1309
1257
|
|
|
1310
1258
|
// ../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
1259
|
var defaultRobotTenantIdCache = new Map;
|
|
1318
1260
|
var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
|
|
1319
1261
|
var getLoginStatusAsync = async (options = {}) => {
|
|
@@ -1321,8 +1263,8 @@ var getLoginStatusAsync = async (options = {}) => {
|
|
|
1321
1263
|
};
|
|
1322
1264
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
1323
1265
|
const {
|
|
1324
|
-
resolveEnvFilePath =
|
|
1325
|
-
loadEnvFile =
|
|
1266
|
+
resolveEnvFilePath = resolveEnvFilePathAsync2,
|
|
1267
|
+
loadEnvFile = loadEnvFileAsync2,
|
|
1326
1268
|
saveEnvFile = saveEnvFileAsync,
|
|
1327
1269
|
getFs = getFileSystem,
|
|
1328
1270
|
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
@@ -1855,38 +1797,7 @@ function errorMessage(error) {
|
|
|
1855
1797
|
}
|
|
1856
1798
|
|
|
1857
1799
|
// ../auth/src/authContext.ts
|
|
1858
|
-
var
|
|
1859
|
-
const status = await getLoginStatusAsync({
|
|
1860
|
-
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
1861
|
-
envFilePath: options.envFilePath
|
|
1862
|
-
});
|
|
1863
|
-
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.");
|
|
1865
|
-
}
|
|
1866
|
-
const tenantName = options.tenant ?? status.tenantName;
|
|
1867
|
-
if (options.requireOrganizationId && !status.organizationId) {
|
|
1868
|
-
throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
|
|
1869
|
-
}
|
|
1870
|
-
if (options.requireOrganizationName && !status.organizationName) {
|
|
1871
|
-
throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
|
|
1872
|
-
}
|
|
1873
|
-
if (options.requireTenantId && !status.tenantId) {
|
|
1874
|
-
throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
|
|
1875
|
-
}
|
|
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.");
|
|
1878
|
-
}
|
|
1879
|
-
return {
|
|
1880
|
-
baseUrl: status.baseUrl,
|
|
1881
|
-
accessToken: status.accessToken,
|
|
1882
|
-
organizationId: status.organizationId,
|
|
1883
|
-
organizationName: status.organizationName,
|
|
1884
|
-
tenantId: status.tenantId,
|
|
1885
|
-
tenantName,
|
|
1886
|
-
identity: status.identity
|
|
1887
|
-
};
|
|
1888
|
-
};
|
|
1889
|
-
var getAuthEnv = async (options = {}) => {
|
|
1800
|
+
var getAuthEnv2 = async (options = {}) => {
|
|
1890
1801
|
const authEnv = {};
|
|
1891
1802
|
let status;
|
|
1892
1803
|
try {
|
|
@@ -1900,7 +1811,7 @@ var getAuthEnv = async (options = {}) => {
|
|
|
1900
1811
|
const org = status.organizationName || status.organizationId;
|
|
1901
1812
|
const tenant = status.tenantName || status.tenantId;
|
|
1902
1813
|
if (org && tenant) {
|
|
1903
|
-
authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${org}/${tenant}`;
|
|
1814
|
+
authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(org)}/${encodeURIComponent(tenant)}`;
|
|
1904
1815
|
}
|
|
1905
1816
|
}
|
|
1906
1817
|
if (status.organizationId)
|
|
@@ -1914,533 +1825,16 @@ var getAuthEnv = async (options = {}) => {
|
|
|
1914
1825
|
}
|
|
1915
1826
|
return { authEnv, loginStatus: status };
|
|
1916
1827
|
};
|
|
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
1828
|
// ../auth/src/selectTenant.ts
|
|
2143
1829
|
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
2144
1830
|
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
1831
|
var TENANT_SELECTION_CODES = new Set([
|
|
2176
1832
|
TENANT_SELECTION_REQUIRED_CODE,
|
|
2177
1833
|
INVALID_TENANT_CODE
|
|
2178
1834
|
]);
|
|
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
1835
|
|
|
2442
1836
|
// ../auth/src/index.ts
|
|
2443
|
-
var
|
|
1837
|
+
var authenticate2 = async ({
|
|
2444
1838
|
baseUrl,
|
|
2445
1839
|
clientId,
|
|
2446
1840
|
clientSecret,
|
|
@@ -2495,10 +1889,10 @@ var authenticate = async ({
|
|
|
2495
1889
|
const authUrl = `${authorizationEndpoint}?${authParams.toString()}`;
|
|
2496
1890
|
let strategy;
|
|
2497
1891
|
if (isBrowser()) {
|
|
2498
|
-
const { BrowserAuthStrategy } = await import("./browser-strategy-
|
|
1892
|
+
const { BrowserAuthStrategy } = await import("./browser-strategy-bxv33ex0.js");
|
|
2499
1893
|
strategy = new BrowserAuthStrategy;
|
|
2500
1894
|
} else {
|
|
2501
|
-
const { NodeAuthStrategy } = await import("./node-strategy-
|
|
1895
|
+
const { NodeAuthStrategy } = await import("./node-strategy-dhvvrt9n.js");
|
|
2502
1896
|
strategy = new NodeAuthStrategy;
|
|
2503
1897
|
}
|
|
2504
1898
|
const code = await strategy.execute(authUrl, effectiveRedirectUriUrl, state, {
|
|
@@ -2518,6 +1912,6 @@ var authenticate = async ({
|
|
|
2518
1912
|
});
|
|
2519
1913
|
};
|
|
2520
1914
|
|
|
2521
|
-
export {
|
|
1915
|
+
export { catchError, DEFAULT_AUTH_TIMEOUT_MS, AUTH_TIMEOUT_ERROR_CODE, AUTH_CANCELLED_ERROR_CODE, AUTH_RECLAIMED_ERROR_CODE, getGlobalThis, resolveEnvFilePathAsync2, loadEnvFileAsync2, getAuthEnv2, authenticate2 };
|
|
2522
1916
|
|
|
2523
|
-
//# debugId=
|
|
1917
|
+
//# debugId=A75BC67F1A2D9AFD64756E2164756E21
|