@uipath/auth 1.0.4 → 1.1.0
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.browser.js +83 -19
- package/dist/index.js +96 -36
- package/package.json +3 -10
package/dist/index.browser.js
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/loginStatus.ts
|
|
10
|
-
import { getFileSystem as
|
|
10
|
+
import { getFileSystem as getFileSystem3 } from "@uipath/filesystem";
|
|
11
11
|
|
|
12
12
|
// src/catch-error.ts
|
|
13
13
|
function isPromiseLike(value) {
|
|
@@ -91,7 +91,9 @@ var DEFAULT_SCOPES = [
|
|
|
91
91
|
"AutomationSolutions",
|
|
92
92
|
"StudioWebTypeCacheService",
|
|
93
93
|
"Docs.GPT.Search",
|
|
94
|
-
"Insights"
|
|
94
|
+
"Insights",
|
|
95
|
+
"ReferenceToken",
|
|
96
|
+
"Audit.Read"
|
|
95
97
|
];
|
|
96
98
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
97
99
|
let baseUrl = rawUrl;
|
|
@@ -234,6 +236,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
234
236
|
|
|
235
237
|
// src/envAuth.ts
|
|
236
238
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
239
|
+
var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
|
|
237
240
|
var ENV_AUTH_VARS = {
|
|
238
241
|
token: "UIPATH_CLI_AUTH_TOKEN",
|
|
239
242
|
organizationName: "UIPATH_CLI_ORGANIZATION_NAME",
|
|
@@ -249,6 +252,7 @@ class EnvAuthConfigError extends Error {
|
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
var isEnvAuthEnabled = () => process.env[ENV_AUTH_ENABLE_VAR] === "true";
|
|
255
|
+
var isRobotAuthEnforced = () => process.env[ENFORCE_ROBOT_AUTH_VAR] === "true";
|
|
252
256
|
var requireEnv = (name) => {
|
|
253
257
|
const value = process.env[name];
|
|
254
258
|
if (!value) {
|
|
@@ -292,6 +296,7 @@ var readAuthFromEnv = () => {
|
|
|
292
296
|
};
|
|
293
297
|
|
|
294
298
|
// src/robotClientFallback.ts
|
|
299
|
+
import { getFileSystem } from "@uipath/filesystem";
|
|
295
300
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
296
301
|
var CLOSE_TIMEOUT_MS = 500;
|
|
297
302
|
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
@@ -303,6 +308,35 @@ var printNoticeOnce = () => {
|
|
|
303
308
|
catchError(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
304
309
|
`));
|
|
305
310
|
};
|
|
311
|
+
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
312
|
+
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
313
|
+
var PIPE_NAME_MAX_LENGTH = 103;
|
|
314
|
+
var getRobotIpcPipeNames = async () => {
|
|
315
|
+
const fs = getFileSystem();
|
|
316
|
+
const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
|
|
317
|
+
if (!username) {
|
|
318
|
+
throw new Error("Unable to determine current username");
|
|
319
|
+
}
|
|
320
|
+
const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
|
|
321
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
322
|
+
};
|
|
323
|
+
var defaultIsRobotIpcAvailable = async () => {
|
|
324
|
+
if (process.platform === "win32") {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
|
|
328
|
+
if (pipeNamesError || !pipeNames) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
const fs = getFileSystem();
|
|
332
|
+
for (const pipeName of pipeNames) {
|
|
333
|
+
const [existsError, exists] = await catchError(fs.exists(pipeName));
|
|
334
|
+
if (!existsError && exists === true) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return false;
|
|
339
|
+
};
|
|
306
340
|
var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
|
|
307
341
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
308
342
|
promise.then((value) => {
|
|
@@ -334,14 +368,20 @@ var defaultLoadModule = async () => {
|
|
|
334
368
|
var tryRobotClientFallback = async (options = {}) => {
|
|
335
369
|
if (isBrowser())
|
|
336
370
|
return;
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
371
|
+
if (!options.force) {
|
|
372
|
+
if (process.env.CI || process.env.GITHUB_ACTIONS) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (process.env.UIPATH_URL) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
342
378
|
}
|
|
343
379
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
380
|
+
const isRobotIpcAvailable = options.isRobotIpcAvailable ?? defaultIsRobotIpcAvailable;
|
|
344
381
|
const loadModule = options.loadModule ?? defaultLoadModule;
|
|
382
|
+
if (!await isRobotIpcAvailable()) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
345
385
|
const mod = await loadModule();
|
|
346
386
|
if (!mod)
|
|
347
387
|
return;
|
|
@@ -441,7 +481,7 @@ var refreshAccessToken = async ({
|
|
|
441
481
|
};
|
|
442
482
|
|
|
443
483
|
// src/utils/envFile.ts
|
|
444
|
-
import { getFileSystem } from "@uipath/filesystem";
|
|
484
|
+
import { getFileSystem as getFileSystem2 } from "@uipath/filesystem";
|
|
445
485
|
var DEFAULT_AUTH_FILENAME = AUTH_FILENAME;
|
|
446
486
|
var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR}/${AUTH_FILENAME}`;
|
|
447
487
|
var KNOWN_ERROR_CODES = new Set([
|
|
@@ -488,7 +528,7 @@ var probeAsync = async (fs, candidate) => {
|
|
|
488
528
|
}
|
|
489
529
|
};
|
|
490
530
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME) => {
|
|
491
|
-
const fs =
|
|
531
|
+
const fs = getFileSystem2();
|
|
492
532
|
if (fs.path.isAbsolute(envFilePath)) {
|
|
493
533
|
const probe2 = await probeAsync(fs, envFilePath);
|
|
494
534
|
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
@@ -539,7 +579,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME) => {
|
|
|
539
579
|
};
|
|
540
580
|
};
|
|
541
581
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
542
|
-
const fs =
|
|
582
|
+
const fs = getFileSystem2();
|
|
543
583
|
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
|
|
544
584
|
if (!await fs.exists(absolutePath)) {
|
|
545
585
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
@@ -573,7 +613,7 @@ var saveEnvFileAsync = async ({
|
|
|
573
613
|
data,
|
|
574
614
|
merge = true
|
|
575
615
|
}) => {
|
|
576
|
-
const fs =
|
|
616
|
+
const fs = getFileSystem2();
|
|
577
617
|
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
|
|
578
618
|
let existingData = {};
|
|
579
619
|
if (merge && await fs.exists(absolutePath)) {
|
|
@@ -614,19 +654,43 @@ function normalizeTokenRefreshUnavailableFailure() {
|
|
|
614
654
|
return "token refresh failed before authentication completed";
|
|
615
655
|
}
|
|
616
656
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
617
|
-
if (isEnvAuthEnabled()) {
|
|
618
|
-
return readAuthFromEnv();
|
|
619
|
-
}
|
|
620
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
621
657
|
const {
|
|
622
658
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
623
659
|
loadEnvFile = loadEnvFileAsync,
|
|
624
660
|
saveEnvFile = saveEnvFileAsync,
|
|
625
|
-
getFs =
|
|
661
|
+
getFs = getFileSystem3,
|
|
626
662
|
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
627
663
|
resolveConfig = resolveConfigAsync,
|
|
628
664
|
robotFallback = tryRobotClientFallback
|
|
629
665
|
} = deps;
|
|
666
|
+
if (isRobotAuthEnforced()) {
|
|
667
|
+
if (isEnvAuthEnabled()) {
|
|
668
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
669
|
+
}
|
|
670
|
+
const robotCreds = await robotFallback({ force: true });
|
|
671
|
+
if (!robotCreds) {
|
|
672
|
+
return {
|
|
673
|
+
loginStatus: "Not logged in",
|
|
674
|
+
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.`
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
678
|
+
return {
|
|
679
|
+
loginStatus: "Logged in",
|
|
680
|
+
accessToken: robotCreds.accessToken,
|
|
681
|
+
baseUrl: robotCreds.baseUrl,
|
|
682
|
+
organizationName: robotCreds.organizationName,
|
|
683
|
+
organizationId: robotCreds.organizationId,
|
|
684
|
+
tenantName: robotCreds.tenantName,
|
|
685
|
+
tenantId: robotCreds.tenantId,
|
|
686
|
+
expiration: expiration2,
|
|
687
|
+
source: "robot" /* Robot */
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
if (isEnvAuthEnabled()) {
|
|
691
|
+
return readAuthFromEnv();
|
|
692
|
+
}
|
|
693
|
+
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
630
694
|
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
631
695
|
if (absolutePath === undefined) {
|
|
632
696
|
const robotCreds = await robotFallback();
|
|
@@ -793,7 +857,7 @@ var getAuthContext = async (options = {}) => {
|
|
|
793
857
|
throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
|
|
794
858
|
}
|
|
795
859
|
if (options.requireTenantName && tenantName === undefined) {
|
|
796
|
-
throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set.
|
|
860
|
+
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.");
|
|
797
861
|
}
|
|
798
862
|
return {
|
|
799
863
|
baseUrl: status.baseUrl,
|
|
@@ -860,11 +924,11 @@ Troubleshooting:` + `
|
|
|
860
924
|
};
|
|
861
925
|
};
|
|
862
926
|
// src/logout.ts
|
|
863
|
-
import { getFileSystem as
|
|
927
|
+
import { getFileSystem as getFileSystem4 } from "@uipath/filesystem";
|
|
864
928
|
async function logoutWithDeps(options, deps = {}) {
|
|
865
929
|
const {
|
|
866
930
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
867
|
-
getFileSystem: getFs =
|
|
931
|
+
getFileSystem: getFs = getFileSystem4
|
|
868
932
|
} = deps;
|
|
869
933
|
const fs = getFs();
|
|
870
934
|
const { absolutePath } = await resolveEnvFilePath(options.file);
|
package/dist/index.js
CHANGED
|
@@ -861,9 +861,7 @@ var init_node = __esm(() => {
|
|
|
861
861
|
init_open();
|
|
862
862
|
});
|
|
863
863
|
// ../filesystem/src/index.ts
|
|
864
|
-
var fsInstance, getFileSystem = () =>
|
|
865
|
-
return fsInstance;
|
|
866
|
-
};
|
|
864
|
+
var fsInstance, getFileSystem = () => fsInstance;
|
|
867
865
|
var init_src = __esm(() => {
|
|
868
866
|
init_node();
|
|
869
867
|
init_node();
|
|
@@ -19479,7 +19477,9 @@ var DEFAULT_SCOPES = [
|
|
|
19479
19477
|
"AutomationSolutions",
|
|
19480
19478
|
"StudioWebTypeCacheService",
|
|
19481
19479
|
"Docs.GPT.Search",
|
|
19482
|
-
"Insights"
|
|
19480
|
+
"Insights",
|
|
19481
|
+
"ReferenceToken",
|
|
19482
|
+
"Audit.Read"
|
|
19483
19483
|
];
|
|
19484
19484
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
19485
19485
|
let baseUrl = rawUrl;
|
|
@@ -20250,6 +20250,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
20250
20250
|
|
|
20251
20251
|
// src/envAuth.ts
|
|
20252
20252
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
20253
|
+
var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
|
|
20253
20254
|
var ENV_AUTH_VARS = {
|
|
20254
20255
|
token: "UIPATH_CLI_AUTH_TOKEN",
|
|
20255
20256
|
organizationName: "UIPATH_CLI_ORGANIZATION_NAME",
|
|
@@ -20265,6 +20266,7 @@ class EnvAuthConfigError extends Error {
|
|
|
20265
20266
|
}
|
|
20266
20267
|
}
|
|
20267
20268
|
var isEnvAuthEnabled = () => process.env[ENV_AUTH_ENABLE_VAR] === "true";
|
|
20269
|
+
var isRobotAuthEnforced = () => process.env[ENFORCE_ROBOT_AUTH_VAR] === "true";
|
|
20268
20270
|
var requireEnv = (name) => {
|
|
20269
20271
|
const value = process.env[name];
|
|
20270
20272
|
if (!value) {
|
|
@@ -20306,7 +20308,9 @@ var readAuthFromEnv = () => {
|
|
|
20306
20308
|
expiration
|
|
20307
20309
|
};
|
|
20308
20310
|
};
|
|
20311
|
+
|
|
20309
20312
|
// src/robotClientFallback.ts
|
|
20313
|
+
init_src();
|
|
20310
20314
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
20311
20315
|
var CLOSE_TIMEOUT_MS = 500;
|
|
20312
20316
|
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
@@ -20318,6 +20322,35 @@ var printNoticeOnce = () => {
|
|
|
20318
20322
|
catchError(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
20319
20323
|
`));
|
|
20320
20324
|
};
|
|
20325
|
+
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
20326
|
+
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
20327
|
+
var PIPE_NAME_MAX_LENGTH = 103;
|
|
20328
|
+
var getRobotIpcPipeNames = async () => {
|
|
20329
|
+
const fs7 = getFileSystem();
|
|
20330
|
+
const username = fs7.env.getenv("USER") ?? fs7.env.getenv("USERNAME");
|
|
20331
|
+
if (!username) {
|
|
20332
|
+
throw new Error("Unable to determine current username");
|
|
20333
|
+
}
|
|
20334
|
+
const tempPath = fs7.env.getenv("TMPDIR") ?? "/tmp/";
|
|
20335
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs7.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
20336
|
+
};
|
|
20337
|
+
var defaultIsRobotIpcAvailable = async () => {
|
|
20338
|
+
if (process.platform === "win32") {
|
|
20339
|
+
return true;
|
|
20340
|
+
}
|
|
20341
|
+
const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
|
|
20342
|
+
if (pipeNamesError || !pipeNames) {
|
|
20343
|
+
return false;
|
|
20344
|
+
}
|
|
20345
|
+
const fs7 = getFileSystem();
|
|
20346
|
+
for (const pipeName of pipeNames) {
|
|
20347
|
+
const [existsError, exists] = await catchError(fs7.exists(pipeName));
|
|
20348
|
+
if (!existsError && exists === true) {
|
|
20349
|
+
return true;
|
|
20350
|
+
}
|
|
20351
|
+
}
|
|
20352
|
+
return false;
|
|
20353
|
+
};
|
|
20321
20354
|
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
20322
20355
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
20323
20356
|
promise.then((value) => {
|
|
@@ -20349,14 +20382,20 @@ var defaultLoadModule = async () => {
|
|
|
20349
20382
|
var tryRobotClientFallback = async (options = {}) => {
|
|
20350
20383
|
if (isBrowser())
|
|
20351
20384
|
return;
|
|
20352
|
-
if (
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20385
|
+
if (!options.force) {
|
|
20386
|
+
if (process.env.CI || process.env.GITHUB_ACTIONS) {
|
|
20387
|
+
return;
|
|
20388
|
+
}
|
|
20389
|
+
if (process.env.UIPATH_URL) {
|
|
20390
|
+
return;
|
|
20391
|
+
}
|
|
20357
20392
|
}
|
|
20358
20393
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
20394
|
+
const isRobotIpcAvailable = options.isRobotIpcAvailable ?? defaultIsRobotIpcAvailable;
|
|
20359
20395
|
const loadModule = options.loadModule ?? defaultLoadModule;
|
|
20396
|
+
if (!await isRobotIpcAvailable()) {
|
|
20397
|
+
return;
|
|
20398
|
+
}
|
|
20360
20399
|
const mod = await loadModule();
|
|
20361
20400
|
if (!mod)
|
|
20362
20401
|
return;
|
|
@@ -20630,10 +20669,6 @@ function normalizeTokenRefreshUnavailableFailure() {
|
|
|
20630
20669
|
return "token refresh failed before authentication completed";
|
|
20631
20670
|
}
|
|
20632
20671
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
20633
|
-
if (isEnvAuthEnabled()) {
|
|
20634
|
-
return readAuthFromEnv();
|
|
20635
|
-
}
|
|
20636
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
20637
20672
|
const {
|
|
20638
20673
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
20639
20674
|
loadEnvFile = loadEnvFileAsync,
|
|
@@ -20643,6 +20678,34 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
20643
20678
|
resolveConfig = resolveConfigAsync,
|
|
20644
20679
|
robotFallback = tryRobotClientFallback
|
|
20645
20680
|
} = deps;
|
|
20681
|
+
if (isRobotAuthEnforced()) {
|
|
20682
|
+
if (isEnvAuthEnabled()) {
|
|
20683
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
20684
|
+
}
|
|
20685
|
+
const robotCreds = await robotFallback({ force: true });
|
|
20686
|
+
if (!robotCreds) {
|
|
20687
|
+
return {
|
|
20688
|
+
loginStatus: "Not logged in",
|
|
20689
|
+
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.`
|
|
20690
|
+
};
|
|
20691
|
+
}
|
|
20692
|
+
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
20693
|
+
return {
|
|
20694
|
+
loginStatus: "Logged in",
|
|
20695
|
+
accessToken: robotCreds.accessToken,
|
|
20696
|
+
baseUrl: robotCreds.baseUrl,
|
|
20697
|
+
organizationName: robotCreds.organizationName,
|
|
20698
|
+
organizationId: robotCreds.organizationId,
|
|
20699
|
+
tenantName: robotCreds.tenantName,
|
|
20700
|
+
tenantId: robotCreds.tenantId,
|
|
20701
|
+
expiration: expiration2,
|
|
20702
|
+
source: "robot" /* Robot */
|
|
20703
|
+
};
|
|
20704
|
+
}
|
|
20705
|
+
if (isEnvAuthEnabled()) {
|
|
20706
|
+
return readAuthFromEnv();
|
|
20707
|
+
}
|
|
20708
|
+
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
20646
20709
|
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
20647
20710
|
if (absolutePath === undefined) {
|
|
20648
20711
|
const robotCreds = await robotFallback();
|
|
@@ -20809,7 +20872,7 @@ var getAuthContext = async (options = {}) => {
|
|
|
20809
20872
|
throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
|
|
20810
20873
|
}
|
|
20811
20874
|
if (options.requireTenantName && tenantName === undefined) {
|
|
20812
|
-
throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set.
|
|
20875
|
+
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.");
|
|
20813
20876
|
}
|
|
20814
20877
|
return {
|
|
20815
20878
|
baseUrl: status.baseUrl,
|
|
@@ -21001,29 +21064,24 @@ var interactiveLoginWithDeps = async (options, deps) => {
|
|
|
21001
21064
|
try {
|
|
21002
21065
|
const tokenData = jwtParser(tokens.UIPATH_ACCESS_TOKEN);
|
|
21003
21066
|
const orgId = tokenData.prtId || tokenData.organizationId || tokenData.prt_id;
|
|
21004
|
-
if (typeof orgId
|
|
21005
|
-
|
|
21006
|
-
if (organization) {
|
|
21007
|
-
credentials.UIPATH_ORGANIZATION_NAME = organization;
|
|
21008
|
-
}
|
|
21009
|
-
try {
|
|
21010
|
-
const [tenantName, tenantId, orgName] = await tenantSelector(config.baseUrl, tokens.UIPATH_ACCESS_TOKEN, orgId, tenant, interactive);
|
|
21011
|
-
credentials.UIPATH_ORGANIZATION_NAME = orgName;
|
|
21012
|
-
credentials.UIPATH_TENANT_NAME = tenantName;
|
|
21013
|
-
credentials.UIPATH_TENANT_ID = tenantId;
|
|
21014
|
-
} catch (error) {
|
|
21015
|
-
credentials.UIPATH_TENANT_NAME = undefined;
|
|
21016
|
-
credentials.UIPATH_TENANT_ID = undefined;
|
|
21017
|
-
if (!organization) {
|
|
21018
|
-
credentials.UIPATH_ORGANIZATION_NAME = undefined;
|
|
21019
|
-
}
|
|
21020
|
-
emit({
|
|
21021
|
-
type: "tenant-fetch-failed",
|
|
21022
|
-
message: error instanceof Error ? error.message : String(error)
|
|
21023
|
-
});
|
|
21024
|
-
}
|
|
21067
|
+
if (typeof orgId !== "string" || orgId.length === 0) {
|
|
21068
|
+
throw new Error("Organization ID not available from login token. Cannot establish an active tenant.");
|
|
21025
21069
|
}
|
|
21026
|
-
|
|
21070
|
+
credentials.UIPATH_ORGANIZATION_ID = orgId;
|
|
21071
|
+
if (organization) {
|
|
21072
|
+
credentials.UIPATH_ORGANIZATION_NAME = organization;
|
|
21073
|
+
}
|
|
21074
|
+
const [tenantName, tenantId, orgName] = await tenantSelector(config.baseUrl, tokens.UIPATH_ACCESS_TOKEN, orgId, tenant, interactive);
|
|
21075
|
+
credentials.UIPATH_ORGANIZATION_NAME = orgName;
|
|
21076
|
+
credentials.UIPATH_TENANT_NAME = tenantName;
|
|
21077
|
+
credentials.UIPATH_TENANT_ID = tenantId;
|
|
21078
|
+
} catch (error) {
|
|
21079
|
+
emit({
|
|
21080
|
+
type: "tenant-fetch-failed",
|
|
21081
|
+
message: error instanceof Error ? error.message : String(error)
|
|
21082
|
+
});
|
|
21083
|
+
throw error;
|
|
21084
|
+
}
|
|
21027
21085
|
const fs7 = getFs();
|
|
21028
21086
|
const requestedPath = envFilePath ?? DEFAULT_ENV_FILENAME;
|
|
21029
21087
|
let savePath = requestedPath;
|
|
@@ -21174,6 +21232,7 @@ export {
|
|
|
21174
21232
|
logout,
|
|
21175
21233
|
loadEnvFileAsync,
|
|
21176
21234
|
isTokenRefreshOAuthFailure,
|
|
21235
|
+
isRobotAuthEnforced,
|
|
21177
21236
|
isNode,
|
|
21178
21237
|
isEnvAuthEnabled,
|
|
21179
21238
|
isBrowser,
|
|
@@ -21191,6 +21250,7 @@ export {
|
|
|
21191
21250
|
EnvAuthConfigError,
|
|
21192
21251
|
ENV_AUTH_VARS,
|
|
21193
21252
|
ENV_AUTH_ENABLE_VAR,
|
|
21253
|
+
ENFORCE_ROBOT_AUTH_VAR,
|
|
21194
21254
|
DEFAULT_ENV_FILENAME,
|
|
21195
21255
|
DEFAULT_AUTH_FILENAME
|
|
21196
21256
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/auth",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/UiPath/cli.git",
|
|
@@ -35,19 +35,12 @@
|
|
|
35
35
|
"mihaigirleanu",
|
|
36
36
|
"vlad-uipath"
|
|
37
37
|
],
|
|
38
|
-
"scripts": {
|
|
39
|
-
"build": "bun build ./src/index.ts --outdir dist --format esm --target node && bun build ./src/index.browser.ts --outdir dist --format esm --target browser --external @uipath/filesystem --external @uipath/robot-client",
|
|
40
|
-
"test": "vitest run",
|
|
41
|
-
"test:coverage": "vitest run --coverage",
|
|
42
|
-
"lint": "biome check .",
|
|
43
|
-
"typecheck": "tsc --noEmit"
|
|
44
|
-
},
|
|
45
38
|
"devDependencies": {
|
|
46
39
|
"@types/node": "^25.5.2",
|
|
47
|
-
"@uipath/filesystem": "1.0
|
|
40
|
+
"@uipath/filesystem": "1.1.0",
|
|
48
41
|
"@uipath/robot-client": "26.0.193-alpha22964",
|
|
49
42
|
"openid-client": "^6.8.2",
|
|
50
43
|
"typescript": "^6.0.2"
|
|
51
44
|
},
|
|
52
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "06e8c8f566df4b87da4a008635483c62f64f33f0"
|
|
53
46
|
}
|