@uipath/resourcecatalog-tool 1.1.0 → 1.195.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.js +620 -118
- package/dist/tool.js +620 -118
- package/package.json +28 -34
package/dist/tool.js
CHANGED
|
@@ -667,6 +667,7 @@ var init_open = __esm(() => {
|
|
|
667
667
|
});
|
|
668
668
|
|
|
669
669
|
// ../../filesystem/src/node.ts
|
|
670
|
+
import { randomUUID } from "node:crypto";
|
|
670
671
|
import { existsSync } from "node:fs";
|
|
671
672
|
import * as fs6 from "node:fs/promises";
|
|
672
673
|
import * as os2 from "node:os";
|
|
@@ -748,6 +749,90 @@ class NodeFileSystem {
|
|
|
748
749
|
async mkdir(dirPath) {
|
|
749
750
|
await fs6.mkdir(dirPath, { recursive: true });
|
|
750
751
|
}
|
|
752
|
+
async acquireLock(lockPath) {
|
|
753
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
754
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
755
|
+
const ownerId = randomUUID();
|
|
756
|
+
const start = Date.now();
|
|
757
|
+
while (true) {
|
|
758
|
+
try {
|
|
759
|
+
await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
760
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
761
|
+
} catch (error) {
|
|
762
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
const stats = await fs6.stat(lockFile).catch(() => null);
|
|
766
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
767
|
+
const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
768
|
+
if (reclaimed)
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
772
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
773
|
+
}
|
|
774
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
async canonicalizeLockTarget(lockPath) {
|
|
779
|
+
const absolute = path2.resolve(lockPath);
|
|
780
|
+
const fullReal = await fs6.realpath(absolute).catch(() => null);
|
|
781
|
+
if (fullReal)
|
|
782
|
+
return fullReal;
|
|
783
|
+
const parent = path2.dirname(absolute);
|
|
784
|
+
const base = path2.basename(absolute);
|
|
785
|
+
const canonicalParent = await fs6.realpath(parent).catch(() => parent);
|
|
786
|
+
return path2.join(canonicalParent, base);
|
|
787
|
+
}
|
|
788
|
+
createLockRelease(lockFile, ownerId) {
|
|
789
|
+
const heartbeatStart = Date.now();
|
|
790
|
+
let heartbeatTimer;
|
|
791
|
+
let stopped = false;
|
|
792
|
+
const stopHeartbeat = () => {
|
|
793
|
+
stopped = true;
|
|
794
|
+
if (heartbeatTimer)
|
|
795
|
+
clearTimeout(heartbeatTimer);
|
|
796
|
+
};
|
|
797
|
+
const scheduleNextHeartbeat = () => {
|
|
798
|
+
if (stopped)
|
|
799
|
+
return;
|
|
800
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
801
|
+
stopped = true;
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
heartbeatTimer = setTimeout(() => {
|
|
805
|
+
runHeartbeat();
|
|
806
|
+
}, LOCK_HEARTBEAT_MS);
|
|
807
|
+
heartbeatTimer.unref?.();
|
|
808
|
+
};
|
|
809
|
+
const runHeartbeat = async () => {
|
|
810
|
+
if (stopped)
|
|
811
|
+
return;
|
|
812
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
813
|
+
if (stopped)
|
|
814
|
+
return;
|
|
815
|
+
if (current !== ownerId) {
|
|
816
|
+
stopped = true;
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const now = Date.now() / 1000;
|
|
820
|
+
await fs6.utimes(lockFile, now, now).catch(() => {});
|
|
821
|
+
scheduleNextHeartbeat();
|
|
822
|
+
};
|
|
823
|
+
scheduleNextHeartbeat();
|
|
824
|
+
let released = false;
|
|
825
|
+
return async () => {
|
|
826
|
+
if (released)
|
|
827
|
+
return;
|
|
828
|
+
released = true;
|
|
829
|
+
stopHeartbeat();
|
|
830
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
831
|
+
if (current === ownerId) {
|
|
832
|
+
await fs6.rm(lockFile, { force: true });
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
}
|
|
751
836
|
async rm(filePath) {
|
|
752
837
|
await fs6.rm(filePath, { recursive: true, force: true });
|
|
753
838
|
}
|
|
@@ -793,9 +878,13 @@ class NodeFileSystem {
|
|
|
793
878
|
}
|
|
794
879
|
}
|
|
795
880
|
isEnoent(error) {
|
|
796
|
-
return
|
|
881
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
882
|
+
}
|
|
883
|
+
hasErrnoCode(error, code) {
|
|
884
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
797
885
|
}
|
|
798
886
|
}
|
|
887
|
+
var LOCK_HEARTBEAT_MS = 5000, LOCK_STALE_MS = 15000, LOCK_MAX_WAIT_MS = 20000, LOCK_MAX_HOLD_MS = 60000, LOCK_RETRY_MIN_MS = 100, LOCK_RETRY_JITTER_MS = 200;
|
|
799
888
|
var init_node = __esm(() => {
|
|
800
889
|
init_open();
|
|
801
890
|
});
|
|
@@ -848,7 +937,7 @@ function isBrowser() {
|
|
|
848
937
|
|
|
849
938
|
// ../../../node_modules/@uipath/coreipc/index.js
|
|
850
939
|
var require_coreipc = __commonJS((exports, module) => {
|
|
851
|
-
var __dirname = "/
|
|
940
|
+
var __dirname = "/home/runner/work/cli/cli/node_modules/@uipath/coreipc";
|
|
852
941
|
/*! For license information please see index.js.LICENSE.txt */
|
|
853
942
|
(function(e, t) {
|
|
854
943
|
typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.ipc = t() : e.ipc = t();
|
|
@@ -19040,10 +19129,15 @@ var require_dist = __commonJS((exports) => {
|
|
|
19040
19129
|
exports.RobotProxyConstructor = RobotProxyConstructor;
|
|
19041
19130
|
__exportStar(require_agent(), exports);
|
|
19042
19131
|
});
|
|
19132
|
+
// ../../auth/src/server.ts
|
|
19133
|
+
var init_server = __esm(() => {
|
|
19134
|
+
init_constants();
|
|
19135
|
+
});
|
|
19043
19136
|
// package.json
|
|
19044
19137
|
var package_default = {
|
|
19045
19138
|
name: "@uipath/resourcecatalog-tool",
|
|
19046
|
-
|
|
19139
|
+
license: "MIT",
|
|
19140
|
+
version: "1.195.0",
|
|
19047
19141
|
description: "CLI plugin for the UiPath Resource Catalog Service.",
|
|
19048
19142
|
private: false,
|
|
19049
19143
|
repository: {
|
|
@@ -19222,10 +19316,15 @@ async function extractErrorDetails(error, options) {
|
|
|
19222
19316
|
}
|
|
19223
19317
|
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
19224
19318
|
context.errorCode = parsedBody.errorCode;
|
|
19319
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
19320
|
+
context.errorCode = parsedBody.code;
|
|
19225
19321
|
}
|
|
19226
19322
|
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
19227
19323
|
context.requestId = parsedBody.requestId;
|
|
19228
19324
|
}
|
|
19325
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
19326
|
+
context.traceId = parsedBody.traceId;
|
|
19327
|
+
}
|
|
19229
19328
|
if (status === 429) {
|
|
19230
19329
|
const resp = response;
|
|
19231
19330
|
const headersObj = resp?.headers;
|
|
@@ -19245,7 +19344,35 @@ async function extractErrorDetails(error, options) {
|
|
|
19245
19344
|
}
|
|
19246
19345
|
}
|
|
19247
19346
|
const hasContext = Object.keys(context).length > 0;
|
|
19248
|
-
|
|
19347
|
+
let parsedErrors;
|
|
19348
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
19349
|
+
const errors = {};
|
|
19350
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
19351
|
+
if (Array.isArray(raw)) {
|
|
19352
|
+
const messages = raw.map((entry) => {
|
|
19353
|
+
if (typeof entry === "string")
|
|
19354
|
+
return entry;
|
|
19355
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
19356
|
+
return entry.message;
|
|
19357
|
+
}
|
|
19358
|
+
return String(entry);
|
|
19359
|
+
}).filter(Boolean);
|
|
19360
|
+
if (messages.length > 0)
|
|
19361
|
+
errors[field] = messages;
|
|
19362
|
+
} else if (typeof raw === "string") {
|
|
19363
|
+
errors[field] = [raw];
|
|
19364
|
+
}
|
|
19365
|
+
}
|
|
19366
|
+
if (Object.keys(errors).length > 0)
|
|
19367
|
+
parsedErrors = errors;
|
|
19368
|
+
}
|
|
19369
|
+
return {
|
|
19370
|
+
result,
|
|
19371
|
+
message,
|
|
19372
|
+
details,
|
|
19373
|
+
...hasContext ? { context } : {},
|
|
19374
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
19375
|
+
};
|
|
19249
19376
|
}
|
|
19250
19377
|
async function extractErrorMessage(error, options) {
|
|
19251
19378
|
const { message } = await extractErrorDetails(error, options);
|
|
@@ -24378,6 +24505,60 @@ function escapeNonAscii(jsonText) {
|
|
|
24378
24505
|
function needsAsciiSafeJson(sink) {
|
|
24379
24506
|
return process.platform === "win32" && !sink.capabilities.isInteractive;
|
|
24380
24507
|
}
|
|
24508
|
+
function isPlainRecord(value) {
|
|
24509
|
+
if (value === null || typeof value !== "object")
|
|
24510
|
+
return false;
|
|
24511
|
+
const prototype = Object.getPrototypeOf(value);
|
|
24512
|
+
return prototype === Object.prototype || prototype === null;
|
|
24513
|
+
}
|
|
24514
|
+
function toLowerCamelCaseKey(key) {
|
|
24515
|
+
if (!key)
|
|
24516
|
+
return key;
|
|
24517
|
+
if (/[_\-\s]/.test(key)) {
|
|
24518
|
+
const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
|
|
24519
|
+
if (!firstPart)
|
|
24520
|
+
return key;
|
|
24521
|
+
return [
|
|
24522
|
+
toLowerCamelCaseSimpleKey(firstPart),
|
|
24523
|
+
...restParts.map((part) => {
|
|
24524
|
+
const normalized = toLowerCamelCaseSimpleKey(part);
|
|
24525
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
24526
|
+
})
|
|
24527
|
+
].join("");
|
|
24528
|
+
}
|
|
24529
|
+
return toLowerCamelCaseSimpleKey(key);
|
|
24530
|
+
}
|
|
24531
|
+
function toLowerCamelCaseSimpleKey(key) {
|
|
24532
|
+
if (/^[A-Z0-9]+$/.test(key))
|
|
24533
|
+
return key.toLowerCase();
|
|
24534
|
+
return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
|
|
24535
|
+
}
|
|
24536
|
+
function toPascalCaseKey(key) {
|
|
24537
|
+
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
24538
|
+
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
24539
|
+
}
|
|
24540
|
+
function toPascalCaseData(value) {
|
|
24541
|
+
if (Array.isArray(value))
|
|
24542
|
+
return value.map(toPascalCaseData);
|
|
24543
|
+
if (!isPlainRecord(value))
|
|
24544
|
+
return value;
|
|
24545
|
+
const result = {};
|
|
24546
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
24547
|
+
result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
|
|
24548
|
+
}
|
|
24549
|
+
return result;
|
|
24550
|
+
}
|
|
24551
|
+
function normalizeDataKeys(data) {
|
|
24552
|
+
return toPascalCaseData(data);
|
|
24553
|
+
}
|
|
24554
|
+
function normalizeOutputKeys(data) {
|
|
24555
|
+
const result = {};
|
|
24556
|
+
for (const [key, value] of Object.entries(data)) {
|
|
24557
|
+
const pascalKey = toPascalCaseKey(key);
|
|
24558
|
+
result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
|
|
24559
|
+
}
|
|
24560
|
+
return result;
|
|
24561
|
+
}
|
|
24381
24562
|
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
24382
24563
|
if (!data) {
|
|
24383
24564
|
logFn("Empty response object. No data to display.");
|
|
@@ -24440,7 +24621,7 @@ function wrapText(text, width) {
|
|
|
24440
24621
|
function printTable(data, logFn, externalLogValue) {
|
|
24441
24622
|
if (data.length === 0)
|
|
24442
24623
|
return;
|
|
24443
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
24624
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
24444
24625
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
24445
24626
|
const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
|
|
24446
24627
|
logFn(header);
|
|
@@ -24455,7 +24636,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
24455
24636
|
}
|
|
24456
24637
|
}
|
|
24457
24638
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
24458
|
-
const keys = Object.keys(data).filter((key) =>
|
|
24639
|
+
const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
24459
24640
|
if (keys.length === 0)
|
|
24460
24641
|
return;
|
|
24461
24642
|
const maxKeyWidth = Math.max(...keys.map((key) => key.length));
|
|
@@ -24471,7 +24652,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
24471
24652
|
function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
24472
24653
|
if (data.length === 0)
|
|
24473
24654
|
return;
|
|
24474
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
24655
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
24475
24656
|
if (keys.length === 0)
|
|
24476
24657
|
return;
|
|
24477
24658
|
if (!process.stdout.isTTY) {
|
|
@@ -24547,8 +24728,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
|
24547
24728
|
function toYaml(data) {
|
|
24548
24729
|
return dump(data);
|
|
24549
24730
|
}
|
|
24731
|
+
class FilterEvaluationError extends Error {
|
|
24732
|
+
__brand = "FilterEvaluationError";
|
|
24733
|
+
filter;
|
|
24734
|
+
instructions;
|
|
24735
|
+
result = RESULTS.ValidationError;
|
|
24736
|
+
constructor(filter, cause) {
|
|
24737
|
+
const underlying = cause instanceof Error ? cause.message : String(cause);
|
|
24738
|
+
super(`Filter '${filter}' failed to evaluate: ${underlying}`);
|
|
24739
|
+
this.name = "FilterEvaluationError";
|
|
24740
|
+
this.filter = filter;
|
|
24741
|
+
this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
|
|
24742
|
+
}
|
|
24743
|
+
}
|
|
24550
24744
|
function applyFilter(data, filter) {
|
|
24551
|
-
|
|
24745
|
+
let result;
|
|
24746
|
+
try {
|
|
24747
|
+
result = search(data, filter);
|
|
24748
|
+
} catch (err) {
|
|
24749
|
+
throw new FilterEvaluationError(filter, err);
|
|
24750
|
+
}
|
|
24552
24751
|
if (result == null)
|
|
24553
24752
|
return [];
|
|
24554
24753
|
if (Array.isArray(result)) {
|
|
@@ -24565,13 +24764,18 @@ function applyFilter(data, filter) {
|
|
|
24565
24764
|
}
|
|
24566
24765
|
var OutputFormatter;
|
|
24567
24766
|
((OutputFormatter) => {
|
|
24568
|
-
function success(data) {
|
|
24767
|
+
function success(data, options) {
|
|
24569
24768
|
data.Log ??= getLogFilePath() || undefined;
|
|
24769
|
+
const normalize = !options?.preserveDataKeys;
|
|
24770
|
+
if (normalize) {
|
|
24771
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
24772
|
+
}
|
|
24570
24773
|
const filter = getOutputFilter();
|
|
24571
24774
|
if (filter) {
|
|
24572
|
-
|
|
24775
|
+
const filtered = applyFilter(data.Data, filter);
|
|
24776
|
+
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
24573
24777
|
}
|
|
24574
|
-
logOutput(data, getOutputFormat());
|
|
24778
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
24575
24779
|
}
|
|
24576
24780
|
OutputFormatter.success = success;
|
|
24577
24781
|
function error(data) {
|
|
@@ -24581,7 +24785,7 @@ var OutputFormatter;
|
|
|
24581
24785
|
result: data.Result,
|
|
24582
24786
|
message: data.Message
|
|
24583
24787
|
});
|
|
24584
|
-
logOutput(data, getOutputFormat());
|
|
24788
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
24585
24789
|
}
|
|
24586
24790
|
OutputFormatter.error = error;
|
|
24587
24791
|
function emitList(code, items, opts) {
|
|
@@ -24602,13 +24806,14 @@ var OutputFormatter;
|
|
|
24602
24806
|
function log(data) {
|
|
24603
24807
|
const format = getOutputFormat();
|
|
24604
24808
|
const sink = getOutputSink();
|
|
24809
|
+
const normalized = toPascalCaseData(data);
|
|
24605
24810
|
if (format === "json") {
|
|
24606
|
-
const json2 = JSON.stringify(
|
|
24811
|
+
const json2 = JSON.stringify(normalized);
|
|
24607
24812
|
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
|
|
24608
24813
|
sink.writeErr(`${safe}
|
|
24609
24814
|
`);
|
|
24610
24815
|
} else {
|
|
24611
|
-
for (const [key, value] of Object.entries(
|
|
24816
|
+
for (const [key, value] of Object.entries(normalized)) {
|
|
24612
24817
|
sink.writeErr(`${key}: ${value}
|
|
24613
24818
|
`);
|
|
24614
24819
|
}
|
|
@@ -24617,12 +24822,16 @@ var OutputFormatter;
|
|
|
24617
24822
|
OutputFormatter.log = log;
|
|
24618
24823
|
function formatToString(data) {
|
|
24619
24824
|
const filter = getOutputFilter();
|
|
24620
|
-
if (
|
|
24621
|
-
data.Data =
|
|
24825
|
+
if ("Data" in data && data.Data != null) {
|
|
24826
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
24827
|
+
if (filter) {
|
|
24828
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
|
|
24829
|
+
}
|
|
24622
24830
|
}
|
|
24831
|
+
const output = normalizeOutputKeys(data);
|
|
24623
24832
|
const lines = [];
|
|
24624
24833
|
const sink = getOutputSink();
|
|
24625
|
-
printOutput(
|
|
24834
|
+
printOutput(output, getOutputFormat(), (msg) => {
|
|
24626
24835
|
lines.push(msg);
|
|
24627
24836
|
}, needsAsciiSafeJson(sink));
|
|
24628
24837
|
return lines.join(`
|
|
@@ -26076,6 +26285,22 @@ function warnDeprecatedTenantOption(tenant) {
|
|
|
26076
26285
|
}
|
|
26077
26286
|
// ../../common/src/option-validators.ts
|
|
26078
26287
|
import { InvalidArgumentError } from "commander";
|
|
26288
|
+
// ../../common/src/polling/types.ts
|
|
26289
|
+
var PollOutcome = {
|
|
26290
|
+
Completed: "completed",
|
|
26291
|
+
Timeout: "timeout",
|
|
26292
|
+
Interrupted: "interrupted",
|
|
26293
|
+
Aborted: "aborted",
|
|
26294
|
+
Failed: "failed"
|
|
26295
|
+
};
|
|
26296
|
+
|
|
26297
|
+
// ../../common/src/polling/poll-failure-mapping.ts
|
|
26298
|
+
var REASON_BY_OUTCOME = {
|
|
26299
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
26300
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
26301
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
26302
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
26303
|
+
};
|
|
26079
26304
|
// ../../common/src/polling/terminal-statuses.ts
|
|
26080
26305
|
var TERMINAL_STATUSES = new Set([
|
|
26081
26306
|
"completed",
|
|
@@ -26103,6 +26328,105 @@ var ScreenLogger;
|
|
|
26103
26328
|
}
|
|
26104
26329
|
ScreenLogger.progress = progress;
|
|
26105
26330
|
})(ScreenLogger ||= {});
|
|
26331
|
+
// ../../common/src/sdk-user-agent.ts
|
|
26332
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
26333
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
26334
|
+
function userAgentPatchKey(userAgent) {
|
|
26335
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
26336
|
+
}
|
|
26337
|
+
function splitUserAgentTokens(value) {
|
|
26338
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
26339
|
+
}
|
|
26340
|
+
function appendUserAgentToken(value, userAgent) {
|
|
26341
|
+
const tokens = splitUserAgentTokens(value);
|
|
26342
|
+
const seen = new Set(tokens);
|
|
26343
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
26344
|
+
if (!seen.has(token)) {
|
|
26345
|
+
tokens.push(token);
|
|
26346
|
+
seen.add(token);
|
|
26347
|
+
}
|
|
26348
|
+
}
|
|
26349
|
+
return tokens.join(" ");
|
|
26350
|
+
}
|
|
26351
|
+
function getEffectiveUserAgent(userAgent) {
|
|
26352
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
26353
|
+
}
|
|
26354
|
+
function isHeadersLike(headers) {
|
|
26355
|
+
return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
|
|
26356
|
+
}
|
|
26357
|
+
function getSdkUserAgentToken(pkg) {
|
|
26358
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
26359
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
26360
|
+
}
|
|
26361
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
26362
|
+
const result = { ...headers ?? {} };
|
|
26363
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
26364
|
+
const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
26365
|
+
if (headerName) {
|
|
26366
|
+
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
26367
|
+
} else {
|
|
26368
|
+
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
26369
|
+
}
|
|
26370
|
+
return result;
|
|
26371
|
+
}
|
|
26372
|
+
function withSdkUserAgentHeader(headers, userAgent) {
|
|
26373
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
26374
|
+
if (isHeadersLike(headers)) {
|
|
26375
|
+
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
26376
|
+
return headers;
|
|
26377
|
+
}
|
|
26378
|
+
if (Array.isArray(headers)) {
|
|
26379
|
+
const result = headers.map((entry) => {
|
|
26380
|
+
const [key, value] = entry;
|
|
26381
|
+
return [key, value];
|
|
26382
|
+
});
|
|
26383
|
+
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
26384
|
+
if (headerIndex >= 0) {
|
|
26385
|
+
const [key, value] = result[headerIndex];
|
|
26386
|
+
result[headerIndex] = [
|
|
26387
|
+
key,
|
|
26388
|
+
appendUserAgentToken(value, effectiveUserAgent)
|
|
26389
|
+
];
|
|
26390
|
+
} else {
|
|
26391
|
+
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
26392
|
+
}
|
|
26393
|
+
return result;
|
|
26394
|
+
}
|
|
26395
|
+
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
26396
|
+
}
|
|
26397
|
+
function withUserAgentInitOverride(initOverrides, userAgent) {
|
|
26398
|
+
return async (requestContext) => {
|
|
26399
|
+
const initWithUserAgent = {
|
|
26400
|
+
...requestContext.init,
|
|
26401
|
+
headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
|
|
26402
|
+
};
|
|
26403
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
26404
|
+
...requestContext,
|
|
26405
|
+
init: initWithUserAgent
|
|
26406
|
+
}) : initOverrides;
|
|
26407
|
+
return {
|
|
26408
|
+
...override ?? {},
|
|
26409
|
+
headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
|
|
26410
|
+
};
|
|
26411
|
+
};
|
|
26412
|
+
}
|
|
26413
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
26414
|
+
const prototype = BaseApiClass.prototype;
|
|
26415
|
+
const patchKey = userAgentPatchKey(userAgent);
|
|
26416
|
+
if (prototype[patchKey]) {
|
|
26417
|
+
return;
|
|
26418
|
+
}
|
|
26419
|
+
if (typeof prototype.request !== "function") {
|
|
26420
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
26421
|
+
}
|
|
26422
|
+
const originalRequest = prototype.request;
|
|
26423
|
+
prototype.request = function requestWithUserAgent(context, initOverrides) {
|
|
26424
|
+
return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
|
|
26425
|
+
};
|
|
26426
|
+
Object.defineProperty(prototype, patchKey, {
|
|
26427
|
+
value: true
|
|
26428
|
+
});
|
|
26429
|
+
}
|
|
26106
26430
|
// ../../common/src/tool-provider.ts
|
|
26107
26431
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
26108
26432
|
// ../../common/src/trackedAction.ts
|
|
@@ -26288,13 +26612,17 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
|
|
|
26288
26612
|
const [error] = await catchError(fn(...args));
|
|
26289
26613
|
if (error) {
|
|
26290
26614
|
errorMessage = error instanceof Error ? error.message : String(error);
|
|
26291
|
-
logger.
|
|
26615
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
26616
|
+
const typed = error;
|
|
26617
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
26618
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
26619
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
26292
26620
|
OutputFormatter.error({
|
|
26293
|
-
Result:
|
|
26621
|
+
Result: finalResult,
|
|
26294
26622
|
Message: errorMessage,
|
|
26295
|
-
Instructions: "An unexpected error occurred. Run with --log-level debug for details."
|
|
26623
|
+
Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
|
|
26296
26624
|
});
|
|
26297
|
-
context.exit(
|
|
26625
|
+
context.exit(EXIT_CODES[finalResult]);
|
|
26298
26626
|
}
|
|
26299
26627
|
const durationMs = performance.now() - startTime;
|
|
26300
26628
|
const success = !error && (process.exitCode === undefined || process.exitCode === 0);
|
|
@@ -26556,6 +26884,56 @@ class VoidApiResponse {
|
|
|
26556
26884
|
return;
|
|
26557
26885
|
}
|
|
26558
26886
|
}
|
|
26887
|
+
// ../resourcecatalog-sdk/package.json
|
|
26888
|
+
var package_default2 = {
|
|
26889
|
+
name: "@uipath/resourcecatalog-sdk",
|
|
26890
|
+
license: "MIT",
|
|
26891
|
+
version: "1.195.0",
|
|
26892
|
+
description: "SDK for the UiPath Resource Catalog Service API.",
|
|
26893
|
+
repository: {
|
|
26894
|
+
type: "git",
|
|
26895
|
+
url: "https://github.com/UiPath/cli.git",
|
|
26896
|
+
directory: "packages/admin/resourcecatalog-sdk"
|
|
26897
|
+
},
|
|
26898
|
+
publishConfig: {
|
|
26899
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
26900
|
+
},
|
|
26901
|
+
keywords: [
|
|
26902
|
+
"uipath",
|
|
26903
|
+
"resource-catalog",
|
|
26904
|
+
"sdk"
|
|
26905
|
+
],
|
|
26906
|
+
type: "module",
|
|
26907
|
+
main: "./dist/index.js",
|
|
26908
|
+
types: "./dist/src/index.d.ts",
|
|
26909
|
+
exports: {
|
|
26910
|
+
".": {
|
|
26911
|
+
types: "./dist/src/index.d.ts",
|
|
26912
|
+
default: "./dist/index.js"
|
|
26913
|
+
}
|
|
26914
|
+
},
|
|
26915
|
+
files: [
|
|
26916
|
+
"dist"
|
|
26917
|
+
],
|
|
26918
|
+
private: true,
|
|
26919
|
+
scripts: {
|
|
26920
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
26921
|
+
generate: "bun run src/scripts/generate-sdk.ts",
|
|
26922
|
+
lint: "biome check ."
|
|
26923
|
+
},
|
|
26924
|
+
devDependencies: {
|
|
26925
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
26926
|
+
"@types/node": "^25.5.2",
|
|
26927
|
+
"@uipath/auth": "workspace:*",
|
|
26928
|
+
"@uipath/common": "workspace:*",
|
|
26929
|
+
"@uipath/filesystem": "workspace:*",
|
|
26930
|
+
typescript: "^6.0.2"
|
|
26931
|
+
}
|
|
26932
|
+
};
|
|
26933
|
+
|
|
26934
|
+
// ../resourcecatalog-sdk/src/user-agent.ts
|
|
26935
|
+
var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
|
|
26936
|
+
installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
|
|
26559
26937
|
|
|
26560
26938
|
// ../resourcecatalog-sdk/generated/src/models/EntitySearchState.ts
|
|
26561
26939
|
function EntitySearchStateFromJSON(json2) {
|
|
@@ -27921,32 +28299,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
27921
28299
|
this.name = "InvalidBaseUrlError";
|
|
27922
28300
|
}
|
|
27923
28301
|
}
|
|
27924
|
-
var DEFAULT_SCOPES = [
|
|
27925
|
-
"offline_access",
|
|
27926
|
-
"ProcessMining",
|
|
27927
|
-
"OrchestratorApiUserAccess",
|
|
27928
|
-
"StudioWebBackend",
|
|
27929
|
-
"IdentityServerApi",
|
|
27930
|
-
"ConnectionService",
|
|
27931
|
-
"DataService",
|
|
27932
|
-
"DataServiceApiUserAccess",
|
|
27933
|
-
"DocumentUnderstanding",
|
|
27934
|
-
"EnterpriseContextService",
|
|
27935
|
-
"Directory",
|
|
27936
|
-
"JamJamApi",
|
|
27937
|
-
"LLMGateway",
|
|
27938
|
-
"LLMOps",
|
|
27939
|
-
"OMS",
|
|
27940
|
-
"RCS.FolderAuthorization",
|
|
27941
|
-
"RCS.TagsManagement",
|
|
27942
|
-
"TestmanagerApiUserAccess",
|
|
27943
|
-
"AutomationSolutions",
|
|
27944
|
-
"StudioWebTypeCacheService",
|
|
27945
|
-
"Docs.GPT.Search",
|
|
27946
|
-
"Insights",
|
|
27947
|
-
"ReferenceToken",
|
|
27948
|
-
"Audit.Read"
|
|
27949
|
-
];
|
|
28302
|
+
var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
|
|
27950
28303
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
27951
28304
|
let baseUrl = rawUrl;
|
|
27952
28305
|
if (baseUrl.endsWith("/identity_/")) {
|
|
@@ -27996,7 +28349,8 @@ var resolveConfigAsync = async ({
|
|
|
27996
28349
|
if (!clientSecret && fileAuth.clientSecret) {
|
|
27997
28350
|
clientSecret = fileAuth.clientSecret;
|
|
27998
28351
|
}
|
|
27999
|
-
const
|
|
28352
|
+
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
28353
|
+
const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
|
|
28000
28354
|
return {
|
|
28001
28355
|
clientId,
|
|
28002
28356
|
clientSecret,
|
|
@@ -28496,6 +28850,129 @@ function normalizeTokenRefreshFailure() {
|
|
|
28496
28850
|
function normalizeTokenRefreshUnavailableFailure() {
|
|
28497
28851
|
return "token refresh failed before authentication completed";
|
|
28498
28852
|
}
|
|
28853
|
+
function errorMessage(error) {
|
|
28854
|
+
return error instanceof Error ? error.message : String(error);
|
|
28855
|
+
}
|
|
28856
|
+
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
28857
|
+
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
28858
|
+
}
|
|
28859
|
+
async function runRefreshLocked(inputs) {
|
|
28860
|
+
const {
|
|
28861
|
+
absolutePath,
|
|
28862
|
+
refreshToken: callerRefreshToken,
|
|
28863
|
+
customAuthority,
|
|
28864
|
+
ensureTokenValidityMinutes,
|
|
28865
|
+
loadEnvFile,
|
|
28866
|
+
saveEnvFile,
|
|
28867
|
+
refreshFn,
|
|
28868
|
+
resolveConfig
|
|
28869
|
+
} = inputs;
|
|
28870
|
+
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
28871
|
+
let fresh;
|
|
28872
|
+
try {
|
|
28873
|
+
fresh = await loadEnvFile({ envPath: absolutePath });
|
|
28874
|
+
} catch (error) {
|
|
28875
|
+
return {
|
|
28876
|
+
kind: "fail",
|
|
28877
|
+
status: {
|
|
28878
|
+
loginStatus: "Refresh Failed",
|
|
28879
|
+
hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
|
|
28880
|
+
tokenRefresh: {
|
|
28881
|
+
attempted: false,
|
|
28882
|
+
success: false,
|
|
28883
|
+
errorMessage: `auth file read failed: ${errorMessage(error)}`
|
|
28884
|
+
}
|
|
28885
|
+
}
|
|
28886
|
+
};
|
|
28887
|
+
}
|
|
28888
|
+
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
28889
|
+
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
28890
|
+
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
28891
|
+
return {
|
|
28892
|
+
kind: "ok",
|
|
28893
|
+
accessToken: freshAccess,
|
|
28894
|
+
refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
|
|
28895
|
+
expiration: freshExp,
|
|
28896
|
+
tokenRefresh: { attempted: false, success: true }
|
|
28897
|
+
};
|
|
28898
|
+
}
|
|
28899
|
+
const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
|
|
28900
|
+
let refreshedAccess;
|
|
28901
|
+
let refreshedRefresh;
|
|
28902
|
+
try {
|
|
28903
|
+
const config = await resolveConfig({ customAuthority });
|
|
28904
|
+
const refreshed = await refreshFn({
|
|
28905
|
+
refreshToken: tokenForIdP,
|
|
28906
|
+
tokenEndpoint: config.tokenEndpoint,
|
|
28907
|
+
clientId: config.clientId,
|
|
28908
|
+
expectedAuthority: customAuthority
|
|
28909
|
+
});
|
|
28910
|
+
refreshedAccess = refreshed.accessToken;
|
|
28911
|
+
refreshedRefresh = refreshed.refreshToken;
|
|
28912
|
+
} catch (error) {
|
|
28913
|
+
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
28914
|
+
const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
|
|
28915
|
+
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
28916
|
+
return {
|
|
28917
|
+
kind: "fail",
|
|
28918
|
+
status: {
|
|
28919
|
+
loginStatus: "Refresh Failed",
|
|
28920
|
+
hint,
|
|
28921
|
+
tokenRefresh: {
|
|
28922
|
+
attempted: true,
|
|
28923
|
+
success: false,
|
|
28924
|
+
errorMessage: message
|
|
28925
|
+
}
|
|
28926
|
+
}
|
|
28927
|
+
};
|
|
28928
|
+
}
|
|
28929
|
+
const refreshedExp = getTokenExpiration(refreshedAccess);
|
|
28930
|
+
if (!refreshedExp || refreshedExp <= new Date) {
|
|
28931
|
+
return {
|
|
28932
|
+
kind: "fail",
|
|
28933
|
+
status: {
|
|
28934
|
+
loginStatus: "Refresh Failed",
|
|
28935
|
+
hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
|
|
28936
|
+
tokenRefresh: {
|
|
28937
|
+
attempted: true,
|
|
28938
|
+
success: false,
|
|
28939
|
+
errorMessage: "refreshed token has no valid expiration claim"
|
|
28940
|
+
}
|
|
28941
|
+
}
|
|
28942
|
+
};
|
|
28943
|
+
}
|
|
28944
|
+
try {
|
|
28945
|
+
await saveEnvFile({
|
|
28946
|
+
envPath: absolutePath,
|
|
28947
|
+
data: {
|
|
28948
|
+
UIPATH_ACCESS_TOKEN: refreshedAccess,
|
|
28949
|
+
UIPATH_REFRESH_TOKEN: refreshedRefresh
|
|
28950
|
+
},
|
|
28951
|
+
merge: true
|
|
28952
|
+
});
|
|
28953
|
+
return {
|
|
28954
|
+
kind: "ok",
|
|
28955
|
+
accessToken: refreshedAccess,
|
|
28956
|
+
refreshToken: refreshedRefresh,
|
|
28957
|
+
expiration: refreshedExp,
|
|
28958
|
+
tokenRefresh: { attempted: true, success: true }
|
|
28959
|
+
};
|
|
28960
|
+
} catch (error) {
|
|
28961
|
+
const msg = errorMessage(error);
|
|
28962
|
+
return {
|
|
28963
|
+
kind: "ok",
|
|
28964
|
+
accessToken: refreshedAccess,
|
|
28965
|
+
refreshToken: refreshedRefresh,
|
|
28966
|
+
expiration: refreshedExp,
|
|
28967
|
+
persistenceWarning: `Access token refreshed in memory but could not be written to ${absolutePath}: ${msg}. The next CLI invocation will fail until the file can be updated — run 'uip login' to re-authenticate.`,
|
|
28968
|
+
tokenRefresh: {
|
|
28969
|
+
attempted: true,
|
|
28970
|
+
success: true,
|
|
28971
|
+
errorMessage: `persistence failed: ${msg}`
|
|
28972
|
+
}
|
|
28973
|
+
};
|
|
28974
|
+
}
|
|
28975
|
+
}
|
|
28499
28976
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
28500
28977
|
const {
|
|
28501
28978
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
@@ -28570,73 +29047,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
28570
29047
|
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
28571
29048
|
let expiration = getTokenExpiration(accessToken);
|
|
28572
29049
|
let persistenceWarning;
|
|
29050
|
+
let lockReleaseFailed = false;
|
|
28573
29051
|
let tokenRefresh;
|
|
28574
|
-
const
|
|
28575
|
-
|
|
28576
|
-
|
|
28577
|
-
|
|
29052
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
29053
|
+
const tryGlobalCredsHint = async () => {
|
|
29054
|
+
const fs7 = getFs();
|
|
29055
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
29056
|
+
if (absolutePath === globalPath)
|
|
29057
|
+
return;
|
|
29058
|
+
if (!await fs7.exists(globalPath))
|
|
29059
|
+
return;
|
|
28578
29060
|
try {
|
|
28579
|
-
const
|
|
28580
|
-
|
|
28581
|
-
|
|
28582
|
-
const
|
|
28583
|
-
|
|
28584
|
-
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
|
|
28588
|
-
|
|
28589
|
-
|
|
29061
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
29062
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
29063
|
+
return;
|
|
29064
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
29065
|
+
if (globalExp && globalExp <= new Date)
|
|
29066
|
+
return;
|
|
29067
|
+
return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
|
|
29068
|
+
} catch {
|
|
29069
|
+
return;
|
|
29070
|
+
}
|
|
29071
|
+
};
|
|
29072
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
29073
|
+
let release;
|
|
29074
|
+
try {
|
|
29075
|
+
release = await getFs().acquireLock(absolutePath);
|
|
28590
29076
|
} catch (error) {
|
|
28591
|
-
const
|
|
28592
|
-
const
|
|
28593
|
-
|
|
29077
|
+
const msg = errorMessage(error);
|
|
29078
|
+
const globalHint = await tryGlobalCredsHint();
|
|
29079
|
+
if (globalHint) {
|
|
29080
|
+
return {
|
|
29081
|
+
loginStatus: "Expired",
|
|
29082
|
+
accessToken,
|
|
29083
|
+
refreshToken,
|
|
29084
|
+
baseUrl: credentials.UIPATH_URL,
|
|
29085
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
29086
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
29087
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
29088
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
29089
|
+
expiration,
|
|
29090
|
+
source: "file" /* File */,
|
|
29091
|
+
hint: globalHint,
|
|
29092
|
+
tokenRefresh: {
|
|
29093
|
+
attempted: false,
|
|
29094
|
+
success: false,
|
|
29095
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
29096
|
+
}
|
|
29097
|
+
};
|
|
29098
|
+
}
|
|
28594
29099
|
return {
|
|
28595
29100
|
loginStatus: "Refresh Failed",
|
|
28596
|
-
hint,
|
|
29101
|
+
hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
|
|
28597
29102
|
tokenRefresh: {
|
|
28598
|
-
attempted:
|
|
29103
|
+
attempted: false,
|
|
28599
29104
|
success: false,
|
|
28600
|
-
errorMessage
|
|
29105
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
28601
29106
|
}
|
|
28602
29107
|
};
|
|
28603
29108
|
}
|
|
28604
|
-
|
|
28605
|
-
if (!refreshedExp || refreshedExp <= new Date) {
|
|
28606
|
-
return {
|
|
28607
|
-
loginStatus: "Refresh Failed",
|
|
28608
|
-
hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
|
|
28609
|
-
tokenRefresh: {
|
|
28610
|
-
attempted: true,
|
|
28611
|
-
success: false,
|
|
28612
|
-
errorMessage: "refreshed token has no valid expiration claim"
|
|
28613
|
-
}
|
|
28614
|
-
};
|
|
28615
|
-
}
|
|
28616
|
-
accessToken = refreshedAccess;
|
|
28617
|
-
refreshToken = refreshedRefresh;
|
|
28618
|
-
expiration = refreshedExp;
|
|
29109
|
+
let lockedFailure;
|
|
28619
29110
|
try {
|
|
28620
|
-
await
|
|
28621
|
-
|
|
28622
|
-
|
|
28623
|
-
|
|
28624
|
-
|
|
28625
|
-
|
|
28626
|
-
|
|
29111
|
+
const outcome = await runRefreshLocked({
|
|
29112
|
+
absolutePath,
|
|
29113
|
+
refreshToken,
|
|
29114
|
+
customAuthority: credentials.UIPATH_URL,
|
|
29115
|
+
ensureTokenValidityMinutes,
|
|
29116
|
+
loadEnvFile,
|
|
29117
|
+
saveEnvFile,
|
|
29118
|
+
refreshFn: refreshTokenFn,
|
|
29119
|
+
resolveConfig
|
|
28627
29120
|
});
|
|
28628
|
-
|
|
28629
|
-
|
|
28630
|
-
|
|
28631
|
-
|
|
28632
|
-
|
|
28633
|
-
|
|
28634
|
-
|
|
28635
|
-
|
|
28636
|
-
|
|
28637
|
-
|
|
28638
|
-
|
|
28639
|
-
|
|
29121
|
+
if (outcome.kind === "fail") {
|
|
29122
|
+
lockedFailure = outcome.status;
|
|
29123
|
+
} else {
|
|
29124
|
+
accessToken = outcome.accessToken;
|
|
29125
|
+
refreshToken = outcome.refreshToken;
|
|
29126
|
+
expiration = outcome.expiration;
|
|
29127
|
+
tokenRefresh = outcome.tokenRefresh;
|
|
29128
|
+
if (outcome.persistenceWarning) {
|
|
29129
|
+
persistenceWarning = outcome.persistenceWarning;
|
|
29130
|
+
}
|
|
29131
|
+
}
|
|
29132
|
+
} finally {
|
|
29133
|
+
try {
|
|
29134
|
+
await release();
|
|
29135
|
+
} catch {
|
|
29136
|
+
lockReleaseFailed = true;
|
|
29137
|
+
}
|
|
29138
|
+
}
|
|
29139
|
+
if (lockedFailure) {
|
|
29140
|
+
const globalHint = await tryGlobalCredsHint();
|
|
29141
|
+
const base = globalHint ? {
|
|
29142
|
+
...lockedFailure,
|
|
29143
|
+
loginStatus: "Expired",
|
|
29144
|
+
hint: globalHint
|
|
29145
|
+
} : lockedFailure;
|
|
29146
|
+
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
28640
29147
|
}
|
|
28641
29148
|
}
|
|
28642
29149
|
const result = {
|
|
@@ -28651,23 +29158,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
28651
29158
|
expiration,
|
|
28652
29159
|
source: "file" /* File */,
|
|
28653
29160
|
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
29161
|
+
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
28654
29162
|
...tokenRefresh ? { tokenRefresh } : {}
|
|
28655
29163
|
};
|
|
28656
29164
|
if (result.loginStatus === "Expired") {
|
|
28657
|
-
const
|
|
28658
|
-
|
|
28659
|
-
|
|
28660
|
-
try {
|
|
28661
|
-
const globalCreds = await loadEnvFile({
|
|
28662
|
-
envPath: globalPath
|
|
28663
|
-
});
|
|
28664
|
-
if (globalCreds.UIPATH_ACCESS_TOKEN) {
|
|
28665
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
28666
|
-
if (!globalExp || globalExp > new Date) {
|
|
28667
|
-
result.hint = `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
|
|
28668
|
-
}
|
|
28669
|
-
}
|
|
28670
|
-
} catch {}
|
|
29165
|
+
const globalHint = await tryGlobalCredsHint();
|
|
29166
|
+
if (globalHint) {
|
|
29167
|
+
result.hint = globalHint;
|
|
28671
29168
|
}
|
|
28672
29169
|
}
|
|
28673
29170
|
return result;
|
|
@@ -28684,6 +29181,10 @@ var getLoginStatusAsync = async (options = {}) => {
|
|
|
28684
29181
|
init_src();
|
|
28685
29182
|
// ../../auth/src/logout.ts
|
|
28686
29183
|
init_src();
|
|
29184
|
+
|
|
29185
|
+
// ../../auth/src/index.ts
|
|
29186
|
+
init_server();
|
|
29187
|
+
|
|
28687
29188
|
// ../resourcecatalog-sdk/src/client-factory.ts
|
|
28688
29189
|
async function resolveConfig(options) {
|
|
28689
29190
|
const status = await getLoginStatusAsync({
|
|
@@ -28704,7 +29205,8 @@ async function resolveConfig(options) {
|
|
|
28704
29205
|
return {
|
|
28705
29206
|
config: new Configuration({
|
|
28706
29207
|
basePath,
|
|
28707
|
-
accessToken: async () => bearerToken
|
|
29208
|
+
accessToken: async () => bearerToken,
|
|
29209
|
+
headers: addSdkUserAgentHeader(undefined, SDK_USER_AGENT)
|
|
28708
29210
|
}),
|
|
28709
29211
|
organizationId: status.organizationId,
|
|
28710
29212
|
tenantName: tenant
|