@uipath/llmgw-tool 1.196.0 → 1.197.0-preview.59
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/tool.js +878 -1889
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -4,7 +4,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
4
4
|
var package_default = {
|
|
5
5
|
name: "@uipath/llmgw-tool",
|
|
6
6
|
license: "MIT",
|
|
7
|
-
version: "1.
|
|
7
|
+
version: "1.197.0-preview.59",
|
|
8
8
|
description: "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
|
|
9
9
|
private: false,
|
|
10
10
|
repository: {
|
|
@@ -15,15 +15,19 @@ var package_default = {
|
|
|
15
15
|
publishConfig: {
|
|
16
16
|
registry: "https://npm.pkg.github.com/@uipath"
|
|
17
17
|
},
|
|
18
|
-
keywords: [
|
|
18
|
+
keywords: [
|
|
19
|
+
"cli-tool"
|
|
20
|
+
],
|
|
19
21
|
type: "module",
|
|
20
22
|
main: "./dist/tool.js",
|
|
21
23
|
exports: {
|
|
22
24
|
".": "./dist/tool.js"
|
|
23
25
|
},
|
|
24
|
-
files: [
|
|
26
|
+
files: [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
25
29
|
scripts: {
|
|
26
|
-
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander",
|
|
30
|
+
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander --sourcemap=linked",
|
|
27
31
|
package: "bun run build && bun pm pack",
|
|
28
32
|
lint: "biome check .",
|
|
29
33
|
"lint:fix": "biome check --write .",
|
|
@@ -924,27 +928,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
924
928
|
"ENETUNREACH",
|
|
925
929
|
"EAI_FAIL"
|
|
926
930
|
]);
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
931
|
+
var TLS_ERROR_CODES = new Set([
|
|
932
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
933
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
934
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
935
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
936
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
937
|
+
"CERT_HAS_EXPIRED",
|
|
938
|
+
"CERT_UNTRUSTED",
|
|
939
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
940
|
+
]);
|
|
941
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
942
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
943
|
+
function describeConnectivityError(error) {
|
|
944
|
+
let current = error;
|
|
945
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
946
|
+
const cur = current;
|
|
947
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
948
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
949
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
950
|
+
return {
|
|
951
|
+
code,
|
|
952
|
+
kind: "tls",
|
|
953
|
+
message: message ?? code,
|
|
954
|
+
instructions: TLS_INSTRUCTIONS
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
958
|
+
return {
|
|
959
|
+
code,
|
|
960
|
+
kind: "network",
|
|
961
|
+
message: message ?? code,
|
|
962
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
963
|
+
};
|
|
944
964
|
}
|
|
965
|
+
current = cur.cause;
|
|
945
966
|
}
|
|
946
967
|
return;
|
|
947
968
|
}
|
|
969
|
+
function parseHttpStatusFromMessage(message) {
|
|
970
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
971
|
+
if (!match)
|
|
972
|
+
return;
|
|
973
|
+
const status = Number(match[1]);
|
|
974
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
975
|
+
}
|
|
976
|
+
function isHtmlDocument(body) {
|
|
977
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
978
|
+
}
|
|
948
979
|
function retryHintForRetryAfter(seconds) {
|
|
949
980
|
if (seconds <= 1) {
|
|
950
981
|
return "RetryAfter1Second";
|
|
@@ -985,15 +1016,28 @@ function classifyError(status, error) {
|
|
|
985
1016
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
986
1017
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
987
1018
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1019
|
+
const connectivity = describeConnectivityError(error);
|
|
1020
|
+
if (connectivity) {
|
|
1021
|
+
return {
|
|
1022
|
+
errorCode: "network_error",
|
|
1023
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
1024
|
+
};
|
|
990
1025
|
}
|
|
991
1026
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
992
1027
|
}
|
|
1028
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
1029
|
+
if (extractedMessage) {
|
|
1030
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
1031
|
+
}
|
|
1032
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
1033
|
+
}
|
|
993
1034
|
async function extractErrorDetails(error, options) {
|
|
994
1035
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
995
1036
|
const response = err.response;
|
|
996
|
-
const
|
|
1037
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
1038
|
+
const explicitStatus = err.status ?? response?.status;
|
|
1039
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
1040
|
+
const status = explicitStatus ?? inferredStatus;
|
|
997
1041
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
998
1042
|
let rawBody;
|
|
999
1043
|
let extractedMessage;
|
|
@@ -1028,7 +1072,6 @@ async function extractErrorDetails(error, options) {
|
|
|
1028
1072
|
}
|
|
1029
1073
|
}
|
|
1030
1074
|
}
|
|
1031
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
1032
1075
|
let message;
|
|
1033
1076
|
let result = "Failure";
|
|
1034
1077
|
const classification = classifyError(status, error);
|
|
@@ -1042,10 +1085,10 @@ async function extractErrorDetails(error, options) {
|
|
|
1042
1085
|
} else if (status === 405) {
|
|
1043
1086
|
message = DEFAULT_405;
|
|
1044
1087
|
} else if (status === 400 || status === 422) {
|
|
1045
|
-
message =
|
|
1088
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
1046
1089
|
result = "ValidationError";
|
|
1047
1090
|
} else if (status === 429) {
|
|
1048
|
-
message =
|
|
1091
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
1049
1092
|
} else if (extractedMessage) {
|
|
1050
1093
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
1051
1094
|
message = rawMessage;
|
|
@@ -1053,7 +1096,9 @@ async function extractErrorDetails(error, options) {
|
|
|
1053
1096
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
1054
1097
|
}
|
|
1055
1098
|
} else if (status) {
|
|
1056
|
-
if (
|
|
1099
|
+
if (inferredStatus !== undefined) {
|
|
1100
|
+
message = rawMessage;
|
|
1101
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
1057
1102
|
const statusText = response.statusText;
|
|
1058
1103
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
1059
1104
|
} else {
|
|
@@ -1062,6 +1107,12 @@ async function extractErrorDetails(error, options) {
|
|
|
1062
1107
|
} else {
|
|
1063
1108
|
message = rawMessage;
|
|
1064
1109
|
}
|
|
1110
|
+
if (status === undefined) {
|
|
1111
|
+
const connectivity = describeConnectivityError(error);
|
|
1112
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
1113
|
+
message = `${message}: ${connectivity.message}`;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1065
1116
|
let details = rawMessage;
|
|
1066
1117
|
if (rawBody) {
|
|
1067
1118
|
if (parsedBody) {
|
|
@@ -1214,6 +1265,7 @@ var CONSOLE_FALLBACK = {
|
|
|
1214
1265
|
writeLog: (str) => process.stdout.write(str),
|
|
1215
1266
|
capabilities: {
|
|
1216
1267
|
isInteractive: false,
|
|
1268
|
+
canReadInput: false,
|
|
1217
1269
|
supportsColor: false,
|
|
1218
1270
|
outputWidth: 80
|
|
1219
1271
|
}
|
|
@@ -6413,6 +6465,29 @@ function isPlainRecord(value) {
|
|
|
6413
6465
|
const prototype = Object.getPrototypeOf(value);
|
|
6414
6466
|
return prototype === Object.prototype || prototype === null;
|
|
6415
6467
|
}
|
|
6468
|
+
function extractPagedRows(value) {
|
|
6469
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
6470
|
+
return null;
|
|
6471
|
+
const entries = Object.values(value);
|
|
6472
|
+
if (entries.length === 0)
|
|
6473
|
+
return null;
|
|
6474
|
+
let rows = null;
|
|
6475
|
+
let hasScalarSibling = false;
|
|
6476
|
+
for (const entry of entries) {
|
|
6477
|
+
if (Array.isArray(entry)) {
|
|
6478
|
+
if (rows !== null)
|
|
6479
|
+
return null;
|
|
6480
|
+
rows = entry;
|
|
6481
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
6482
|
+
return null;
|
|
6483
|
+
} else {
|
|
6484
|
+
hasScalarSibling = true;
|
|
6485
|
+
}
|
|
6486
|
+
}
|
|
6487
|
+
if (rows === null || !hasScalarSibling)
|
|
6488
|
+
return null;
|
|
6489
|
+
return rows;
|
|
6490
|
+
}
|
|
6416
6491
|
function toLowerCamelCaseKey(key) {
|
|
6417
6492
|
if (!key)
|
|
6418
6493
|
return key;
|
|
@@ -6477,7 +6552,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
6477
6552
|
break;
|
|
6478
6553
|
case "plain": {
|
|
6479
6554
|
if ("Data" in data && data.Data != null) {
|
|
6480
|
-
const
|
|
6555
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
6556
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
6481
6557
|
items.forEach((item) => {
|
|
6482
6558
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
6483
6559
|
logFn(values);
|
|
@@ -6489,10 +6565,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
6489
6565
|
break;
|
|
6490
6566
|
}
|
|
6491
6567
|
default: {
|
|
6492
|
-
|
|
6568
|
+
const hasData = "Data" in data && data.Data != null;
|
|
6569
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
6570
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
6571
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
6493
6572
|
const logValue = data.Log;
|
|
6494
|
-
if (
|
|
6495
|
-
printResizableTable(
|
|
6573
|
+
if (rows !== null) {
|
|
6574
|
+
printResizableTable(rows, logFn, logValue);
|
|
6496
6575
|
} else {
|
|
6497
6576
|
printVerticalTable(data.Data, logFn, logValue);
|
|
6498
6577
|
}
|
|
@@ -6680,6 +6759,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
6680
6759
|
return "unknown_error";
|
|
6681
6760
|
}
|
|
6682
6761
|
}
|
|
6762
|
+
function parseHttpStatusFromMessage2(message) {
|
|
6763
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
6764
|
+
if (!match)
|
|
6765
|
+
return;
|
|
6766
|
+
const status = Number(match[1]);
|
|
6767
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
6768
|
+
}
|
|
6769
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
6770
|
+
if (status === undefined)
|
|
6771
|
+
return;
|
|
6772
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
6773
|
+
return "invalid_argument";
|
|
6774
|
+
}
|
|
6775
|
+
if (status === 401)
|
|
6776
|
+
return "authentication_required";
|
|
6777
|
+
if (status === 403)
|
|
6778
|
+
return "permission_denied";
|
|
6779
|
+
if (status === 404)
|
|
6780
|
+
return "not_found";
|
|
6781
|
+
if (status === 405)
|
|
6782
|
+
return "method_not_allowed";
|
|
6783
|
+
if (status === 408)
|
|
6784
|
+
return "timeout";
|
|
6785
|
+
if (status === 429)
|
|
6786
|
+
return "rate_limited";
|
|
6787
|
+
if (status >= 500 && status < 600)
|
|
6788
|
+
return "server_error";
|
|
6789
|
+
return;
|
|
6790
|
+
}
|
|
6791
|
+
function defaultErrorCodeForFailure(data) {
|
|
6792
|
+
if (data.Result === RESULTS.Failure) {
|
|
6793
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
6794
|
+
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
6795
|
+
if (errorCode)
|
|
6796
|
+
return errorCode;
|
|
6797
|
+
}
|
|
6798
|
+
return defaultErrorCodeForResult(data.Result);
|
|
6799
|
+
}
|
|
6683
6800
|
function defaultRetryForErrorCode(errorCode) {
|
|
6684
6801
|
switch (errorCode) {
|
|
6685
6802
|
case "network_error":
|
|
@@ -6709,16 +6826,19 @@ var OutputFormatter;
|
|
|
6709
6826
|
OutputFormatter.success = success;
|
|
6710
6827
|
function error(data) {
|
|
6711
6828
|
data.Log ??= getLogFilePath() || undefined;
|
|
6712
|
-
data.ErrorCode ??=
|
|
6829
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
6713
6830
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
6714
6831
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6832
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
6833
|
+
if (!SuppressTelemetry) {
|
|
6834
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
6835
|
+
result: data.Result,
|
|
6836
|
+
errorCode: data.ErrorCode,
|
|
6837
|
+
retry: data.Retry,
|
|
6838
|
+
message: data.Message
|
|
6839
|
+
});
|
|
6840
|
+
}
|
|
6841
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
6722
6842
|
}
|
|
6723
6843
|
OutputFormatter.error = error;
|
|
6724
6844
|
function emitList(code, items, opts) {
|
|
@@ -7011,1609 +7131,218 @@ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
|
7011
7131
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
7012
7132
|
// ../../common/src/interactivity-context.ts
|
|
7013
7133
|
var modeSlot = singleton("InteractivityMode");
|
|
7014
|
-
//
|
|
7015
|
-
import
|
|
7134
|
+
// ../../common/src/option-aliases.ts
|
|
7135
|
+
import { Option } from "commander";
|
|
7136
|
+
// ../../common/src/option-validators.ts
|
|
7137
|
+
import { InvalidArgumentError } from "commander";
|
|
7138
|
+
// ../../common/src/polling/types.ts
|
|
7139
|
+
var PollOutcome = {
|
|
7140
|
+
Completed: "completed",
|
|
7141
|
+
Timeout: "timeout",
|
|
7142
|
+
Interrupted: "interrupted",
|
|
7143
|
+
Aborted: "aborted",
|
|
7144
|
+
Failed: "failed"
|
|
7145
|
+
};
|
|
7016
7146
|
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7147
|
+
// ../../common/src/polling/poll-failure-mapping.ts
|
|
7148
|
+
var REASON_BY_OUTCOME = {
|
|
7149
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
7150
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
7151
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
7152
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
7153
|
+
};
|
|
7154
|
+
// ../../common/src/polling/terminal-statuses.ts
|
|
7155
|
+
var TERMINAL_STATUSES = new Set([
|
|
7156
|
+
"completed",
|
|
7157
|
+
"successful",
|
|
7158
|
+
"faulted",
|
|
7159
|
+
"failed",
|
|
7160
|
+
"cancelled",
|
|
7161
|
+
"canceled",
|
|
7162
|
+
"stopped",
|
|
7163
|
+
"finished"
|
|
7164
|
+
]);
|
|
7165
|
+
var FAILURE_STATUSES = new Set([
|
|
7166
|
+
"faulted",
|
|
7167
|
+
"failed",
|
|
7168
|
+
"cancelled",
|
|
7169
|
+
"canceled",
|
|
7170
|
+
"stopped"
|
|
7171
|
+
]);
|
|
7172
|
+
// ../../common/src/preview.ts
|
|
7173
|
+
import { Command as Command3 } from "commander";
|
|
7174
|
+
var previewSlot = singleton("PreviewBuild");
|
|
7175
|
+
function isPreviewBuild() {
|
|
7176
|
+
return previewSlot.get(false) ?? false;
|
|
7038
7177
|
}
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
this.jsep = jsep;
|
|
7043
|
-
this.registered = {};
|
|
7178
|
+
Command3.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
7179
|
+
if (isPreviewBuild()) {
|
|
7180
|
+
return this.command(nameAndArgs, opts);
|
|
7044
7181
|
}
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
plugin.init(this.jsep);
|
|
7054
|
-
this.registered[plugin.name] = plugin;
|
|
7055
|
-
});
|
|
7182
|
+
return new Command3(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
7183
|
+
};
|
|
7184
|
+
// ../../common/src/screen-logger.ts
|
|
7185
|
+
var ScreenLogger;
|
|
7186
|
+
((ScreenLogger) => {
|
|
7187
|
+
function progress(message) {
|
|
7188
|
+
getOutputSink().writeErr(`${message}
|
|
7189
|
+
`);
|
|
7056
7190
|
}
|
|
7191
|
+
ScreenLogger.progress = progress;
|
|
7192
|
+
})(ScreenLogger ||= {});
|
|
7193
|
+
// ../../common/src/sdk-user-agent.ts
|
|
7194
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
7195
|
+
// ../../common/src/tool-provider.ts
|
|
7196
|
+
var factorySlot = singleton("PackagerFactoryProvider");
|
|
7197
|
+
// ../llmgw-sdk/dist/index.js
|
|
7198
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
7199
|
+
import fs7 from "node:fs";
|
|
7200
|
+
import fs22 from "node:fs";
|
|
7201
|
+
import process22 from "node:process";
|
|
7202
|
+
import os3 from "node:os";
|
|
7203
|
+
import fs32 from "node:fs";
|
|
7204
|
+
import process32 from "node:process";
|
|
7205
|
+
import { Buffer as Buffer22 } from "node:buffer";
|
|
7206
|
+
import { promisify as promisify7 } from "node:util";
|
|
7207
|
+
import childProcess4 from "node:child_process";
|
|
7208
|
+
import { promisify as promisify22 } from "node:util";
|
|
7209
|
+
import childProcess22 from "node:child_process";
|
|
7210
|
+
import fs42, { constants as fsConstants3 } from "node:fs/promises";
|
|
7211
|
+
import { promisify as promisify32 } from "node:util";
|
|
7212
|
+
import process42 from "node:process";
|
|
7213
|
+
import { execFile as execFile32 } from "node:child_process";
|
|
7214
|
+
import process52 from "node:process";
|
|
7215
|
+
import { promisify as promisify42 } from "node:util";
|
|
7216
|
+
import { execFile as execFile42, execFileSync as execFileSync3 } from "node:child_process";
|
|
7217
|
+
import { promisify as promisify52 } from "node:util";
|
|
7218
|
+
import { execFile as execFile52 } from "node:child_process";
|
|
7219
|
+
import { promisify as promisify62 } from "node:util";
|
|
7220
|
+
import process62 from "node:process";
|
|
7221
|
+
import { execFile as execFile62 } from "node:child_process";
|
|
7222
|
+
import process72 from "node:process";
|
|
7223
|
+
import process82 from "node:process";
|
|
7224
|
+
import path3 from "node:path";
|
|
7225
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7226
|
+
import childProcess32 from "node:child_process";
|
|
7227
|
+
import fs52, { constants as fsConstants22 } from "node:fs/promises";
|
|
7228
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
7229
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
7230
|
+
import * as fs62 from "node:fs/promises";
|
|
7231
|
+
import * as os22 from "node:os";
|
|
7232
|
+
import * as path22 from "node:path";
|
|
7233
|
+
var __create2 = Object.create;
|
|
7234
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
7235
|
+
var __defProp2 = Object.defineProperty;
|
|
7236
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
7237
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
7238
|
+
function __accessProp(key) {
|
|
7239
|
+
return this[key];
|
|
7057
7240
|
}
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
|
|
7068
|
-
Jsep.unary_ops[op_name] = 1;
|
|
7069
|
-
return Jsep;
|
|
7070
|
-
}
|
|
7071
|
-
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
7072
|
-
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
7073
|
-
Jsep.binary_ops[op_name] = precedence;
|
|
7074
|
-
if (isRightAssociative) {
|
|
7075
|
-
Jsep.right_associative.add(op_name);
|
|
7076
|
-
} else {
|
|
7077
|
-
Jsep.right_associative.delete(op_name);
|
|
7078
|
-
}
|
|
7079
|
-
return Jsep;
|
|
7080
|
-
}
|
|
7081
|
-
static addIdentifierChar(char) {
|
|
7082
|
-
Jsep.additional_identifier_chars.add(char);
|
|
7083
|
-
return Jsep;
|
|
7241
|
+
var __toESMCache_node;
|
|
7242
|
+
var __toESMCache_esm;
|
|
7243
|
+
var __toESM2 = (mod2, isNodeMode, target) => {
|
|
7244
|
+
var canCache = mod2 != null && typeof mod2 === "object";
|
|
7245
|
+
if (canCache) {
|
|
7246
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
7247
|
+
var cached = cache.get(mod2);
|
|
7248
|
+
if (cached)
|
|
7249
|
+
return cached;
|
|
7084
7250
|
}
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7251
|
+
target = mod2 != null ? __create2(__getProtoOf2(mod2)) : {};
|
|
7252
|
+
const to = isNodeMode || !mod2 || !mod2.__esModule ? __defProp2(target, "default", { value: mod2, enumerable: true }) : target;
|
|
7253
|
+
for (let key of __getOwnPropNames2(mod2))
|
|
7254
|
+
if (!__hasOwnProp2.call(to, key))
|
|
7255
|
+
__defProp2(to, key, {
|
|
7256
|
+
get: __accessProp.bind(mod2, key),
|
|
7257
|
+
enumerable: true
|
|
7258
|
+
});
|
|
7259
|
+
if (canCache)
|
|
7260
|
+
cache.set(mod2, to);
|
|
7261
|
+
return to;
|
|
7262
|
+
};
|
|
7263
|
+
var __commonJS = (cb, mod2) => () => (mod2 || cb((mod2 = { exports: {} }).exports, mod2), mod2.exports);
|
|
7264
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
7265
|
+
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
7266
|
+
function isPromiseLike2(value) {
|
|
7267
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
7268
|
+
}
|
|
7269
|
+
function catchError2(fnOrPromise) {
|
|
7270
|
+
if (isPromiseLike2(fnOrPromise)) {
|
|
7271
|
+
return settlePromiseLike2(fnOrPromise);
|
|
7088
7272
|
}
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
if (
|
|
7092
|
-
|
|
7273
|
+
try {
|
|
7274
|
+
const result = fnOrPromise();
|
|
7275
|
+
if (isPromiseLike2(result)) {
|
|
7276
|
+
return settlePromiseLike2(result);
|
|
7093
7277
|
}
|
|
7094
|
-
return
|
|
7095
|
-
}
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
}
|
|
7101
|
-
static removeIdentifierChar(char) {
|
|
7102
|
-
Jsep.additional_identifier_chars.delete(char);
|
|
7103
|
-
return Jsep;
|
|
7278
|
+
return [undefined, result];
|
|
7279
|
+
} catch (error) {
|
|
7280
|
+
return [
|
|
7281
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
7282
|
+
undefined
|
|
7283
|
+
];
|
|
7104
7284
|
}
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7285
|
+
}
|
|
7286
|
+
function settlePromiseLike2(thenable) {
|
|
7287
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
7288
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
7289
|
+
undefined
|
|
7290
|
+
]);
|
|
7291
|
+
}
|
|
7292
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
7293
|
+
var AUTH_FILENAME = ".auth";
|
|
7294
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
7295
|
+
var DEFAULT_AUTH_TIMEOUT_MS2;
|
|
7296
|
+
var init_constants = __esm(() => {
|
|
7297
|
+
DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
7298
|
+
});
|
|
7299
|
+
function isBrowser() {
|
|
7300
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
7301
|
+
}
|
|
7302
|
+
function hasDockerEnv2() {
|
|
7303
|
+
try {
|
|
7304
|
+
fs7.statSync("/.dockerenv");
|
|
7305
|
+
return true;
|
|
7306
|
+
} catch {
|
|
7307
|
+
return false;
|
|
7112
7308
|
}
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
return
|
|
7309
|
+
}
|
|
7310
|
+
function hasDockerCGroup2() {
|
|
7311
|
+
try {
|
|
7312
|
+
return fs7.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
7313
|
+
} catch {
|
|
7314
|
+
return false;
|
|
7117
7315
|
}
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7316
|
+
}
|
|
7317
|
+
function isDocker2() {
|
|
7318
|
+
if (isDockerCached2 === undefined) {
|
|
7319
|
+
isDockerCached2 = hasDockerEnv2() || hasDockerCGroup2();
|
|
7121
7320
|
}
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7321
|
+
return isDockerCached2;
|
|
7322
|
+
}
|
|
7323
|
+
var isDockerCached2;
|
|
7324
|
+
var init_is_docker = () => {};
|
|
7325
|
+
function isInsideContainer2() {
|
|
7326
|
+
if (cachedResult2 === undefined) {
|
|
7327
|
+
cachedResult2 = hasContainerEnv2() || isDocker2();
|
|
7125
7328
|
}
|
|
7126
|
-
|
|
7127
|
-
|
|
7329
|
+
return cachedResult2;
|
|
7330
|
+
}
|
|
7331
|
+
var cachedResult2;
|
|
7332
|
+
var hasContainerEnv2 = () => {
|
|
7333
|
+
try {
|
|
7334
|
+
fs22.statSync("/run/.containerenv");
|
|
7335
|
+
return true;
|
|
7336
|
+
} catch {
|
|
7337
|
+
return false;
|
|
7128
7338
|
}
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
static parse(expr) {
|
|
7137
|
-
return new Jsep(expr).parse();
|
|
7138
|
-
}
|
|
7139
|
-
static getMaxKeyLen(obj) {
|
|
7140
|
-
return Math.max(0, ...Object.keys(obj).map((k) => k.length));
|
|
7141
|
-
}
|
|
7142
|
-
static isDecimalDigit(ch) {
|
|
7143
|
-
return ch >= 48 && ch <= 57;
|
|
7144
|
-
}
|
|
7145
|
-
static binaryPrecedence(op_val) {
|
|
7146
|
-
return Jsep.binary_ops[op_val] || 0;
|
|
7147
|
-
}
|
|
7148
|
-
static isIdentifierStart(ch) {
|
|
7149
|
-
return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
|
|
7150
|
-
}
|
|
7151
|
-
static isIdentifierPart(ch) {
|
|
7152
|
-
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
7153
|
-
}
|
|
7154
|
-
throwError(message) {
|
|
7155
|
-
const error = new Error(message + " at character " + this.index);
|
|
7156
|
-
error.index = this.index;
|
|
7157
|
-
error.description = message;
|
|
7158
|
-
throw error;
|
|
7159
|
-
}
|
|
7160
|
-
runHook(name, node) {
|
|
7161
|
-
if (Jsep.hooks[name]) {
|
|
7162
|
-
const env = {
|
|
7163
|
-
context: this,
|
|
7164
|
-
node
|
|
7165
|
-
};
|
|
7166
|
-
Jsep.hooks.run(name, env);
|
|
7167
|
-
return env.node;
|
|
7168
|
-
}
|
|
7169
|
-
return node;
|
|
7170
|
-
}
|
|
7171
|
-
searchHook(name) {
|
|
7172
|
-
if (Jsep.hooks[name]) {
|
|
7173
|
-
const env = {
|
|
7174
|
-
context: this
|
|
7175
|
-
};
|
|
7176
|
-
Jsep.hooks[name].find(function(callback) {
|
|
7177
|
-
callback.call(env.context, env);
|
|
7178
|
-
return env.node;
|
|
7179
|
-
});
|
|
7180
|
-
return env.node;
|
|
7181
|
-
}
|
|
7182
|
-
}
|
|
7183
|
-
gobbleSpaces() {
|
|
7184
|
-
let ch = this.code;
|
|
7185
|
-
while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
|
|
7186
|
-
ch = this.expr.charCodeAt(++this.index);
|
|
7187
|
-
}
|
|
7188
|
-
this.runHook("gobble-spaces");
|
|
7189
|
-
}
|
|
7190
|
-
parse() {
|
|
7191
|
-
this.runHook("before-all");
|
|
7192
|
-
const nodes = this.gobbleExpressions();
|
|
7193
|
-
const node = nodes.length === 1 ? nodes[0] : {
|
|
7194
|
-
type: Jsep.COMPOUND,
|
|
7195
|
-
body: nodes
|
|
7196
|
-
};
|
|
7197
|
-
return this.runHook("after-all", node);
|
|
7198
|
-
}
|
|
7199
|
-
gobbleExpressions(untilICode) {
|
|
7200
|
-
let nodes = [], ch_i, node;
|
|
7201
|
-
while (this.index < this.expr.length) {
|
|
7202
|
-
ch_i = this.code;
|
|
7203
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
7204
|
-
this.index++;
|
|
7205
|
-
} else {
|
|
7206
|
-
if (node = this.gobbleExpression()) {
|
|
7207
|
-
nodes.push(node);
|
|
7208
|
-
} else if (this.index < this.expr.length) {
|
|
7209
|
-
if (ch_i === untilICode) {
|
|
7210
|
-
break;
|
|
7211
|
-
}
|
|
7212
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
7213
|
-
}
|
|
7214
|
-
}
|
|
7215
|
-
}
|
|
7216
|
-
return nodes;
|
|
7217
|
-
}
|
|
7218
|
-
gobbleExpression() {
|
|
7219
|
-
const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
7220
|
-
this.gobbleSpaces();
|
|
7221
|
-
return this.runHook("after-expression", node);
|
|
7222
|
-
}
|
|
7223
|
-
gobbleBinaryOp() {
|
|
7224
|
-
this.gobbleSpaces();
|
|
7225
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
7226
|
-
let tc_len = to_check.length;
|
|
7227
|
-
while (tc_len > 0) {
|
|
7228
|
-
if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
7229
|
-
this.index += tc_len;
|
|
7230
|
-
return to_check;
|
|
7231
|
-
}
|
|
7232
|
-
to_check = to_check.substr(0, --tc_len);
|
|
7233
|
-
}
|
|
7234
|
-
return false;
|
|
7235
|
-
}
|
|
7236
|
-
gobbleBinaryExpression() {
|
|
7237
|
-
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
7238
|
-
left = this.gobbleToken();
|
|
7239
|
-
if (!left) {
|
|
7240
|
-
return left;
|
|
7241
|
-
}
|
|
7242
|
-
biop = this.gobbleBinaryOp();
|
|
7243
|
-
if (!biop) {
|
|
7244
|
-
return left;
|
|
7245
|
-
}
|
|
7246
|
-
biop_info = {
|
|
7247
|
-
value: biop,
|
|
7248
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
7249
|
-
right_a: Jsep.right_associative.has(biop)
|
|
7250
|
-
};
|
|
7251
|
-
right = this.gobbleToken();
|
|
7252
|
-
if (!right) {
|
|
7253
|
-
this.throwError("Expected expression after " + biop);
|
|
7254
|
-
}
|
|
7255
|
-
stack = [left, biop_info, right];
|
|
7256
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
7257
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
7258
|
-
if (prec === 0) {
|
|
7259
|
-
this.index -= biop.length;
|
|
7260
|
-
break;
|
|
7261
|
-
}
|
|
7262
|
-
biop_info = {
|
|
7263
|
-
value: biop,
|
|
7264
|
-
prec,
|
|
7265
|
-
right_a: Jsep.right_associative.has(biop)
|
|
7266
|
-
};
|
|
7267
|
-
cur_biop = biop;
|
|
7268
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
7269
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
7270
|
-
right = stack.pop();
|
|
7271
|
-
biop = stack.pop().value;
|
|
7272
|
-
left = stack.pop();
|
|
7273
|
-
node = {
|
|
7274
|
-
type: Jsep.BINARY_EXP,
|
|
7275
|
-
operator: biop,
|
|
7276
|
-
left,
|
|
7277
|
-
right
|
|
7278
|
-
};
|
|
7279
|
-
stack.push(node);
|
|
7280
|
-
}
|
|
7281
|
-
node = this.gobbleToken();
|
|
7282
|
-
if (!node) {
|
|
7283
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
7284
|
-
}
|
|
7285
|
-
stack.push(biop_info, node);
|
|
7286
|
-
}
|
|
7287
|
-
i = stack.length - 1;
|
|
7288
|
-
node = stack[i];
|
|
7289
|
-
while (i > 1) {
|
|
7290
|
-
node = {
|
|
7291
|
-
type: Jsep.BINARY_EXP,
|
|
7292
|
-
operator: stack[i - 1].value,
|
|
7293
|
-
left: stack[i - 2],
|
|
7294
|
-
right: node
|
|
7295
|
-
};
|
|
7296
|
-
i -= 2;
|
|
7297
|
-
}
|
|
7298
|
-
return node;
|
|
7299
|
-
}
|
|
7300
|
-
gobbleToken() {
|
|
7301
|
-
let ch, to_check, tc_len, node;
|
|
7302
|
-
this.gobbleSpaces();
|
|
7303
|
-
node = this.searchHook("gobble-token");
|
|
7304
|
-
if (node) {
|
|
7305
|
-
return this.runHook("after-token", node);
|
|
7306
|
-
}
|
|
7307
|
-
ch = this.code;
|
|
7308
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
7309
|
-
return this.gobbleNumericLiteral();
|
|
7310
|
-
}
|
|
7311
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
7312
|
-
node = this.gobbleStringLiteral();
|
|
7313
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
7314
|
-
node = this.gobbleArray();
|
|
7315
|
-
} else {
|
|
7316
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
7317
|
-
tc_len = to_check.length;
|
|
7318
|
-
while (tc_len > 0) {
|
|
7319
|
-
if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
7320
|
-
this.index += tc_len;
|
|
7321
|
-
const argument = this.gobbleToken();
|
|
7322
|
-
if (!argument) {
|
|
7323
|
-
this.throwError("missing unaryOp argument");
|
|
7324
|
-
}
|
|
7325
|
-
return this.runHook("after-token", {
|
|
7326
|
-
type: Jsep.UNARY_EXP,
|
|
7327
|
-
operator: to_check,
|
|
7328
|
-
argument,
|
|
7329
|
-
prefix: true
|
|
7330
|
-
});
|
|
7331
|
-
}
|
|
7332
|
-
to_check = to_check.substr(0, --tc_len);
|
|
7333
|
-
}
|
|
7334
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
7335
|
-
node = this.gobbleIdentifier();
|
|
7336
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
7337
|
-
node = {
|
|
7338
|
-
type: Jsep.LITERAL,
|
|
7339
|
-
value: Jsep.literals[node.name],
|
|
7340
|
-
raw: node.name
|
|
7341
|
-
};
|
|
7342
|
-
} else if (node.name === Jsep.this_str) {
|
|
7343
|
-
node = {
|
|
7344
|
-
type: Jsep.THIS_EXP
|
|
7345
|
-
};
|
|
7346
|
-
}
|
|
7347
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
7348
|
-
node = this.gobbleGroup();
|
|
7349
|
-
}
|
|
7350
|
-
}
|
|
7351
|
-
if (!node) {
|
|
7352
|
-
return this.runHook("after-token", false);
|
|
7353
|
-
}
|
|
7354
|
-
node = this.gobbleTokenProperty(node);
|
|
7355
|
-
return this.runHook("after-token", node);
|
|
7356
|
-
}
|
|
7357
|
-
gobbleTokenProperty(node) {
|
|
7358
|
-
this.gobbleSpaces();
|
|
7359
|
-
let ch = this.code;
|
|
7360
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
7361
|
-
let optional;
|
|
7362
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
7363
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
7364
|
-
break;
|
|
7365
|
-
}
|
|
7366
|
-
optional = true;
|
|
7367
|
-
this.index += 2;
|
|
7368
|
-
this.gobbleSpaces();
|
|
7369
|
-
ch = this.code;
|
|
7370
|
-
}
|
|
7371
|
-
this.index++;
|
|
7372
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
7373
|
-
node = {
|
|
7374
|
-
type: Jsep.MEMBER_EXP,
|
|
7375
|
-
computed: true,
|
|
7376
|
-
object: node,
|
|
7377
|
-
property: this.gobbleExpression()
|
|
7378
|
-
};
|
|
7379
|
-
if (!node.property) {
|
|
7380
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
7381
|
-
}
|
|
7382
|
-
this.gobbleSpaces();
|
|
7383
|
-
ch = this.code;
|
|
7384
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
7385
|
-
this.throwError("Unclosed [");
|
|
7386
|
-
}
|
|
7387
|
-
this.index++;
|
|
7388
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
7389
|
-
node = {
|
|
7390
|
-
type: Jsep.CALL_EXP,
|
|
7391
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
7392
|
-
callee: node
|
|
7393
|
-
};
|
|
7394
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
7395
|
-
if (optional) {
|
|
7396
|
-
this.index--;
|
|
7397
|
-
}
|
|
7398
|
-
this.gobbleSpaces();
|
|
7399
|
-
node = {
|
|
7400
|
-
type: Jsep.MEMBER_EXP,
|
|
7401
|
-
computed: false,
|
|
7402
|
-
object: node,
|
|
7403
|
-
property: this.gobbleIdentifier()
|
|
7404
|
-
};
|
|
7405
|
-
}
|
|
7406
|
-
if (optional) {
|
|
7407
|
-
node.optional = true;
|
|
7408
|
-
}
|
|
7409
|
-
this.gobbleSpaces();
|
|
7410
|
-
ch = this.code;
|
|
7411
|
-
}
|
|
7412
|
-
return node;
|
|
7413
|
-
}
|
|
7414
|
-
gobbleNumericLiteral() {
|
|
7415
|
-
let number = "", ch, chCode;
|
|
7416
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
7417
|
-
number += this.expr.charAt(this.index++);
|
|
7418
|
-
}
|
|
7419
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
7420
|
-
number += this.expr.charAt(this.index++);
|
|
7421
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
7422
|
-
number += this.expr.charAt(this.index++);
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
ch = this.char;
|
|
7426
|
-
if (ch === "e" || ch === "E") {
|
|
7427
|
-
number += this.expr.charAt(this.index++);
|
|
7428
|
-
ch = this.char;
|
|
7429
|
-
if (ch === "+" || ch === "-") {
|
|
7430
|
-
number += this.expr.charAt(this.index++);
|
|
7431
|
-
}
|
|
7432
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
7433
|
-
number += this.expr.charAt(this.index++);
|
|
7434
|
-
}
|
|
7435
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
7436
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
7437
|
-
}
|
|
7438
|
-
}
|
|
7439
|
-
chCode = this.code;
|
|
7440
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
7441
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
7442
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
7443
|
-
this.throwError("Unexpected period");
|
|
7444
|
-
}
|
|
7445
|
-
return {
|
|
7446
|
-
type: Jsep.LITERAL,
|
|
7447
|
-
value: parseFloat(number),
|
|
7448
|
-
raw: number
|
|
7449
|
-
};
|
|
7450
|
-
}
|
|
7451
|
-
gobbleStringLiteral() {
|
|
7452
|
-
let str = "";
|
|
7453
|
-
const startIndex = this.index;
|
|
7454
|
-
const quote = this.expr.charAt(this.index++);
|
|
7455
|
-
let closed = false;
|
|
7456
|
-
while (this.index < this.expr.length) {
|
|
7457
|
-
let ch = this.expr.charAt(this.index++);
|
|
7458
|
-
if (ch === quote) {
|
|
7459
|
-
closed = true;
|
|
7460
|
-
break;
|
|
7461
|
-
} else if (ch === "\\") {
|
|
7462
|
-
ch = this.expr.charAt(this.index++);
|
|
7463
|
-
switch (ch) {
|
|
7464
|
-
case "n":
|
|
7465
|
-
str += `
|
|
7466
|
-
`;
|
|
7467
|
-
break;
|
|
7468
|
-
case "r":
|
|
7469
|
-
str += "\r";
|
|
7470
|
-
break;
|
|
7471
|
-
case "t":
|
|
7472
|
-
str += "\t";
|
|
7473
|
-
break;
|
|
7474
|
-
case "b":
|
|
7475
|
-
str += "\b";
|
|
7476
|
-
break;
|
|
7477
|
-
case "f":
|
|
7478
|
-
str += "\f";
|
|
7479
|
-
break;
|
|
7480
|
-
case "v":
|
|
7481
|
-
str += "\v";
|
|
7482
|
-
break;
|
|
7483
|
-
default:
|
|
7484
|
-
str += ch;
|
|
7485
|
-
}
|
|
7486
|
-
} else {
|
|
7487
|
-
str += ch;
|
|
7488
|
-
}
|
|
7489
|
-
}
|
|
7490
|
-
if (!closed) {
|
|
7491
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
7492
|
-
}
|
|
7493
|
-
return {
|
|
7494
|
-
type: Jsep.LITERAL,
|
|
7495
|
-
value: str,
|
|
7496
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
7497
|
-
};
|
|
7498
|
-
}
|
|
7499
|
-
gobbleIdentifier() {
|
|
7500
|
-
let ch = this.code, start = this.index;
|
|
7501
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
7502
|
-
this.index++;
|
|
7503
|
-
} else {
|
|
7504
|
-
this.throwError("Unexpected " + this.char);
|
|
7505
|
-
}
|
|
7506
|
-
while (this.index < this.expr.length) {
|
|
7507
|
-
ch = this.code;
|
|
7508
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
7509
|
-
this.index++;
|
|
7510
|
-
} else {
|
|
7511
|
-
break;
|
|
7512
|
-
}
|
|
7513
|
-
}
|
|
7514
|
-
return {
|
|
7515
|
-
type: Jsep.IDENTIFIER,
|
|
7516
|
-
name: this.expr.slice(start, this.index)
|
|
7517
|
-
};
|
|
7518
|
-
}
|
|
7519
|
-
gobbleArguments(termination) {
|
|
7520
|
-
const args = [];
|
|
7521
|
-
let closed = false;
|
|
7522
|
-
let separator_count = 0;
|
|
7523
|
-
while (this.index < this.expr.length) {
|
|
7524
|
-
this.gobbleSpaces();
|
|
7525
|
-
let ch_i = this.code;
|
|
7526
|
-
if (ch_i === termination) {
|
|
7527
|
-
closed = true;
|
|
7528
|
-
this.index++;
|
|
7529
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
7530
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
7531
|
-
}
|
|
7532
|
-
break;
|
|
7533
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
7534
|
-
this.index++;
|
|
7535
|
-
separator_count++;
|
|
7536
|
-
if (separator_count !== args.length) {
|
|
7537
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
7538
|
-
this.throwError("Unexpected token ,");
|
|
7539
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
7540
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
7541
|
-
args.push(null);
|
|
7542
|
-
}
|
|
7543
|
-
}
|
|
7544
|
-
}
|
|
7545
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
7546
|
-
this.throwError("Expected comma");
|
|
7547
|
-
} else {
|
|
7548
|
-
const node = this.gobbleExpression();
|
|
7549
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
7550
|
-
this.throwError("Expected comma");
|
|
7551
|
-
}
|
|
7552
|
-
args.push(node);
|
|
7553
|
-
}
|
|
7554
|
-
}
|
|
7555
|
-
if (!closed) {
|
|
7556
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
7557
|
-
}
|
|
7558
|
-
return args;
|
|
7559
|
-
}
|
|
7560
|
-
gobbleGroup() {
|
|
7561
|
-
this.index++;
|
|
7562
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
7563
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
7564
|
-
this.index++;
|
|
7565
|
-
if (nodes.length === 1) {
|
|
7566
|
-
return nodes[0];
|
|
7567
|
-
} else if (!nodes.length) {
|
|
7568
|
-
return false;
|
|
7569
|
-
} else {
|
|
7570
|
-
return {
|
|
7571
|
-
type: Jsep.SEQUENCE_EXP,
|
|
7572
|
-
expressions: nodes
|
|
7573
|
-
};
|
|
7574
|
-
}
|
|
7575
|
-
} else {
|
|
7576
|
-
this.throwError("Unclosed (");
|
|
7577
|
-
}
|
|
7578
|
-
}
|
|
7579
|
-
gobbleArray() {
|
|
7580
|
-
this.index++;
|
|
7581
|
-
return {
|
|
7582
|
-
type: Jsep.ARRAY_EXP,
|
|
7583
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
7584
|
-
};
|
|
7585
|
-
}
|
|
7586
|
-
}
|
|
7587
|
-
var hooks = new Hooks;
|
|
7588
|
-
Object.assign(Jsep, {
|
|
7589
|
-
hooks,
|
|
7590
|
-
plugins: new Plugins(Jsep),
|
|
7591
|
-
COMPOUND: "Compound",
|
|
7592
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
7593
|
-
IDENTIFIER: "Identifier",
|
|
7594
|
-
MEMBER_EXP: "MemberExpression",
|
|
7595
|
-
LITERAL: "Literal",
|
|
7596
|
-
THIS_EXP: "ThisExpression",
|
|
7597
|
-
CALL_EXP: "CallExpression",
|
|
7598
|
-
UNARY_EXP: "UnaryExpression",
|
|
7599
|
-
BINARY_EXP: "BinaryExpression",
|
|
7600
|
-
ARRAY_EXP: "ArrayExpression",
|
|
7601
|
-
TAB_CODE: 9,
|
|
7602
|
-
LF_CODE: 10,
|
|
7603
|
-
CR_CODE: 13,
|
|
7604
|
-
SPACE_CODE: 32,
|
|
7605
|
-
PERIOD_CODE: 46,
|
|
7606
|
-
COMMA_CODE: 44,
|
|
7607
|
-
SQUOTE_CODE: 39,
|
|
7608
|
-
DQUOTE_CODE: 34,
|
|
7609
|
-
OPAREN_CODE: 40,
|
|
7610
|
-
CPAREN_CODE: 41,
|
|
7611
|
-
OBRACK_CODE: 91,
|
|
7612
|
-
CBRACK_CODE: 93,
|
|
7613
|
-
QUMARK_CODE: 63,
|
|
7614
|
-
SEMCOL_CODE: 59,
|
|
7615
|
-
COLON_CODE: 58,
|
|
7616
|
-
unary_ops: {
|
|
7617
|
-
"-": 1,
|
|
7618
|
-
"!": 1,
|
|
7619
|
-
"~": 1,
|
|
7620
|
-
"+": 1
|
|
7621
|
-
},
|
|
7622
|
-
binary_ops: {
|
|
7623
|
-
"||": 1,
|
|
7624
|
-
"??": 1,
|
|
7625
|
-
"&&": 2,
|
|
7626
|
-
"|": 3,
|
|
7627
|
-
"^": 4,
|
|
7628
|
-
"&": 5,
|
|
7629
|
-
"==": 6,
|
|
7630
|
-
"!=": 6,
|
|
7631
|
-
"===": 6,
|
|
7632
|
-
"!==": 6,
|
|
7633
|
-
"<": 7,
|
|
7634
|
-
">": 7,
|
|
7635
|
-
"<=": 7,
|
|
7636
|
-
">=": 7,
|
|
7637
|
-
"<<": 8,
|
|
7638
|
-
">>": 8,
|
|
7639
|
-
">>>": 8,
|
|
7640
|
-
"+": 9,
|
|
7641
|
-
"-": 9,
|
|
7642
|
-
"*": 10,
|
|
7643
|
-
"/": 10,
|
|
7644
|
-
"%": 10,
|
|
7645
|
-
"**": 11
|
|
7646
|
-
},
|
|
7647
|
-
right_associative: new Set(["**"]),
|
|
7648
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
7649
|
-
literals: {
|
|
7650
|
-
true: true,
|
|
7651
|
-
false: false,
|
|
7652
|
-
null: null
|
|
7653
|
-
},
|
|
7654
|
-
this_str: "this"
|
|
7655
|
-
});
|
|
7656
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
7657
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
7658
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
7659
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
7660
|
-
});
|
|
7661
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
7662
|
-
jsep[m] = Jsep[m];
|
|
7663
|
-
});
|
|
7664
|
-
jsep.Jsep = Jsep;
|
|
7665
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
7666
|
-
var ternary = {
|
|
7667
|
-
name: "ternary",
|
|
7668
|
-
init(jsep2) {
|
|
7669
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
7670
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
7671
|
-
this.index++;
|
|
7672
|
-
const test = env.node;
|
|
7673
|
-
const consequent = this.gobbleExpression();
|
|
7674
|
-
if (!consequent) {
|
|
7675
|
-
this.throwError("Expected expression");
|
|
7676
|
-
}
|
|
7677
|
-
this.gobbleSpaces();
|
|
7678
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
7679
|
-
this.index++;
|
|
7680
|
-
const alternate = this.gobbleExpression();
|
|
7681
|
-
if (!alternate) {
|
|
7682
|
-
this.throwError("Expected expression");
|
|
7683
|
-
}
|
|
7684
|
-
env.node = {
|
|
7685
|
-
type: CONDITIONAL_EXP,
|
|
7686
|
-
test,
|
|
7687
|
-
consequent,
|
|
7688
|
-
alternate
|
|
7689
|
-
};
|
|
7690
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
7691
|
-
let newTest = test;
|
|
7692
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
7693
|
-
newTest = newTest.right;
|
|
7694
|
-
}
|
|
7695
|
-
env.node.test = newTest.right;
|
|
7696
|
-
newTest.right = env.node;
|
|
7697
|
-
env.node = test;
|
|
7698
|
-
}
|
|
7699
|
-
} else {
|
|
7700
|
-
this.throwError("Expected :");
|
|
7701
|
-
}
|
|
7702
|
-
}
|
|
7703
|
-
});
|
|
7704
|
-
}
|
|
7705
|
-
};
|
|
7706
|
-
jsep.plugins.register(ternary);
|
|
7707
|
-
var FSLASH_CODE = 47;
|
|
7708
|
-
var BSLASH_CODE = 92;
|
|
7709
|
-
var index = {
|
|
7710
|
-
name: "regex",
|
|
7711
|
-
init(jsep2) {
|
|
7712
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
7713
|
-
if (this.code === FSLASH_CODE) {
|
|
7714
|
-
const patternIndex = ++this.index;
|
|
7715
|
-
let inCharSet = false;
|
|
7716
|
-
while (this.index < this.expr.length) {
|
|
7717
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
7718
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
7719
|
-
let flags = "";
|
|
7720
|
-
while (++this.index < this.expr.length) {
|
|
7721
|
-
const code = this.code;
|
|
7722
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
7723
|
-
flags += this.char;
|
|
7724
|
-
} else {
|
|
7725
|
-
break;
|
|
7726
|
-
}
|
|
7727
|
-
}
|
|
7728
|
-
let value;
|
|
7729
|
-
try {
|
|
7730
|
-
value = new RegExp(pattern, flags);
|
|
7731
|
-
} catch (e) {
|
|
7732
|
-
this.throwError(e.message);
|
|
7733
|
-
}
|
|
7734
|
-
env.node = {
|
|
7735
|
-
type: jsep2.LITERAL,
|
|
7736
|
-
value,
|
|
7737
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
7738
|
-
};
|
|
7739
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
7740
|
-
return env.node;
|
|
7741
|
-
}
|
|
7742
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
7743
|
-
inCharSet = true;
|
|
7744
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
7745
|
-
inCharSet = false;
|
|
7746
|
-
}
|
|
7747
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
7748
|
-
}
|
|
7749
|
-
this.throwError("Unclosed Regex");
|
|
7750
|
-
}
|
|
7751
|
-
});
|
|
7752
|
-
}
|
|
7753
|
-
};
|
|
7754
|
-
var PLUS_CODE = 43;
|
|
7755
|
-
var MINUS_CODE = 45;
|
|
7756
|
-
var plugin = {
|
|
7757
|
-
name: "assignment",
|
|
7758
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
7759
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
7760
|
-
assignmentPrecedence: 0.9,
|
|
7761
|
-
init(jsep2) {
|
|
7762
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
7763
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
7764
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
7765
|
-
const code = this.code;
|
|
7766
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
7767
|
-
this.index += 2;
|
|
7768
|
-
env.node = {
|
|
7769
|
-
type: "UpdateExpression",
|
|
7770
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
7771
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
7772
|
-
prefix: true
|
|
7773
|
-
};
|
|
7774
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
7775
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
7776
|
-
}
|
|
7777
|
-
}
|
|
7778
|
-
});
|
|
7779
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
7780
|
-
if (env.node) {
|
|
7781
|
-
const code = this.code;
|
|
7782
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
7783
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
7784
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
7785
|
-
}
|
|
7786
|
-
this.index += 2;
|
|
7787
|
-
env.node = {
|
|
7788
|
-
type: "UpdateExpression",
|
|
7789
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
7790
|
-
argument: env.node,
|
|
7791
|
-
prefix: false
|
|
7792
|
-
};
|
|
7793
|
-
}
|
|
7794
|
-
}
|
|
7795
|
-
});
|
|
7796
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
7797
|
-
if (env.node) {
|
|
7798
|
-
updateBinariesToAssignments(env.node);
|
|
7799
|
-
}
|
|
7800
|
-
});
|
|
7801
|
-
function updateBinariesToAssignments(node) {
|
|
7802
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
7803
|
-
node.type = "AssignmentExpression";
|
|
7804
|
-
updateBinariesToAssignments(node.left);
|
|
7805
|
-
updateBinariesToAssignments(node.right);
|
|
7806
|
-
} else if (!node.operator) {
|
|
7807
|
-
Object.values(node).forEach((val) => {
|
|
7808
|
-
if (val && typeof val === "object") {
|
|
7809
|
-
updateBinariesToAssignments(val);
|
|
7810
|
-
}
|
|
7811
|
-
});
|
|
7812
|
-
}
|
|
7813
|
-
}
|
|
7814
|
-
}
|
|
7815
|
-
};
|
|
7816
|
-
jsep.plugins.register(index, plugin);
|
|
7817
|
-
jsep.addUnaryOp("typeof");
|
|
7818
|
-
jsep.addUnaryOp("void");
|
|
7819
|
-
jsep.addLiteral("null", null);
|
|
7820
|
-
jsep.addLiteral("undefined", undefined);
|
|
7821
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
7822
|
-
var SafeEval = {
|
|
7823
|
-
evalAst(ast, subs) {
|
|
7824
|
-
switch (ast.type) {
|
|
7825
|
-
case "BinaryExpression":
|
|
7826
|
-
case "LogicalExpression":
|
|
7827
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
7828
|
-
case "Compound":
|
|
7829
|
-
return SafeEval.evalCompound(ast, subs);
|
|
7830
|
-
case "ConditionalExpression":
|
|
7831
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
7832
|
-
case "Identifier":
|
|
7833
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
7834
|
-
case "Literal":
|
|
7835
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
7836
|
-
case "MemberExpression":
|
|
7837
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
7838
|
-
case "UnaryExpression":
|
|
7839
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
7840
|
-
case "ArrayExpression":
|
|
7841
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
7842
|
-
case "CallExpression":
|
|
7843
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
7844
|
-
case "AssignmentExpression":
|
|
7845
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
7846
|
-
default:
|
|
7847
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
7848
|
-
}
|
|
7849
|
-
},
|
|
7850
|
-
evalBinaryExpression(ast, subs) {
|
|
7851
|
-
const result = {
|
|
7852
|
-
"||": (a, b) => a || b(),
|
|
7853
|
-
"&&": (a, b) => a && b(),
|
|
7854
|
-
"|": (a, b) => a | b(),
|
|
7855
|
-
"^": (a, b) => a ^ b(),
|
|
7856
|
-
"&": (a, b) => a & b(),
|
|
7857
|
-
"==": (a, b) => a == b(),
|
|
7858
|
-
"!=": (a, b) => a != b(),
|
|
7859
|
-
"===": (a, b) => a === b(),
|
|
7860
|
-
"!==": (a, b) => a !== b(),
|
|
7861
|
-
"<": (a, b) => a < b(),
|
|
7862
|
-
">": (a, b) => a > b(),
|
|
7863
|
-
"<=": (a, b) => a <= b(),
|
|
7864
|
-
">=": (a, b) => a >= b(),
|
|
7865
|
-
"<<": (a, b) => a << b(),
|
|
7866
|
-
">>": (a, b) => a >> b(),
|
|
7867
|
-
">>>": (a, b) => a >>> b(),
|
|
7868
|
-
"+": (a, b) => a + b(),
|
|
7869
|
-
"-": (a, b) => a - b(),
|
|
7870
|
-
"*": (a, b) => a * b(),
|
|
7871
|
-
"/": (a, b) => a / b(),
|
|
7872
|
-
"%": (a, b) => a % b()
|
|
7873
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
7874
|
-
return result;
|
|
7875
|
-
},
|
|
7876
|
-
evalCompound(ast, subs) {
|
|
7877
|
-
let last;
|
|
7878
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
7879
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
7880
|
-
i += 1;
|
|
7881
|
-
}
|
|
7882
|
-
const expr = ast.body[i];
|
|
7883
|
-
last = SafeEval.evalAst(expr, subs);
|
|
7884
|
-
}
|
|
7885
|
-
return last;
|
|
7886
|
-
},
|
|
7887
|
-
evalConditionalExpression(ast, subs) {
|
|
7888
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
7889
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
7890
|
-
}
|
|
7891
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
7892
|
-
},
|
|
7893
|
-
evalIdentifier(ast, subs) {
|
|
7894
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
7895
|
-
return subs[ast.name];
|
|
7896
|
-
}
|
|
7897
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
7898
|
-
},
|
|
7899
|
-
evalLiteral(ast) {
|
|
7900
|
-
return ast.value;
|
|
7901
|
-
},
|
|
7902
|
-
evalMemberExpression(ast, subs) {
|
|
7903
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
7904
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
7905
|
-
if (obj === undefined || obj === null) {
|
|
7906
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
7907
|
-
}
|
|
7908
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
7909
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
7910
|
-
}
|
|
7911
|
-
const result = obj[prop];
|
|
7912
|
-
if (typeof result === "function") {
|
|
7913
|
-
return result.bind(obj);
|
|
7914
|
-
}
|
|
7915
|
-
return result;
|
|
7916
|
-
},
|
|
7917
|
-
evalUnaryExpression(ast, subs) {
|
|
7918
|
-
const result = {
|
|
7919
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
7920
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
7921
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
7922
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
7923
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
7924
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
7925
|
-
}[ast.operator](ast.argument);
|
|
7926
|
-
return result;
|
|
7927
|
-
},
|
|
7928
|
-
evalArrayExpression(ast, subs) {
|
|
7929
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
7930
|
-
},
|
|
7931
|
-
evalCallExpression(ast, subs) {
|
|
7932
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
7933
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
7934
|
-
if (func === Function) {
|
|
7935
|
-
throw new Error("Function constructor is disabled");
|
|
7936
|
-
}
|
|
7937
|
-
return func(...args);
|
|
7938
|
-
},
|
|
7939
|
-
evalAssignmentExpression(ast, subs) {
|
|
7940
|
-
if (ast.left.type !== "Identifier") {
|
|
7941
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
7942
|
-
}
|
|
7943
|
-
const id = ast.left.name;
|
|
7944
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
7945
|
-
subs[id] = value;
|
|
7946
|
-
return subs[id];
|
|
7947
|
-
}
|
|
7948
|
-
};
|
|
7949
|
-
|
|
7950
|
-
class SafeScript {
|
|
7951
|
-
constructor(expr) {
|
|
7952
|
-
this.code = expr;
|
|
7953
|
-
this.ast = jsep(this.code);
|
|
7954
|
-
}
|
|
7955
|
-
runInNewContext(context) {
|
|
7956
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
7957
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
7958
|
-
}
|
|
7959
|
-
}
|
|
7960
|
-
function push(arr, item) {
|
|
7961
|
-
arr = arr.slice();
|
|
7962
|
-
arr.push(item);
|
|
7963
|
-
return arr;
|
|
7964
|
-
}
|
|
7965
|
-
function unshift(item, arr) {
|
|
7966
|
-
arr = arr.slice();
|
|
7967
|
-
arr.unshift(item);
|
|
7968
|
-
return arr;
|
|
7969
|
-
}
|
|
7970
|
-
|
|
7971
|
-
class NewError extends Error {
|
|
7972
|
-
constructor(value) {
|
|
7973
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
7974
|
-
this.avoidNew = true;
|
|
7975
|
-
this.value = value;
|
|
7976
|
-
this.name = "NewError";
|
|
7977
|
-
}
|
|
7978
|
-
}
|
|
7979
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
7980
|
-
if (!(this instanceof JSONPath)) {
|
|
7981
|
-
try {
|
|
7982
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
7983
|
-
} catch (e) {
|
|
7984
|
-
if (!e.avoidNew) {
|
|
7985
|
-
throw e;
|
|
7986
|
-
}
|
|
7987
|
-
return e.value;
|
|
7988
|
-
}
|
|
7989
|
-
}
|
|
7990
|
-
if (typeof opts === "string") {
|
|
7991
|
-
otherTypeCallback = callback;
|
|
7992
|
-
callback = obj;
|
|
7993
|
-
obj = expr;
|
|
7994
|
-
expr = opts;
|
|
7995
|
-
opts = null;
|
|
7996
|
-
}
|
|
7997
|
-
const optObj = opts && typeof opts === "object";
|
|
7998
|
-
opts = opts || {};
|
|
7999
|
-
this.json = opts.json || obj;
|
|
8000
|
-
this.path = opts.path || expr;
|
|
8001
|
-
this.resultType = opts.resultType || "value";
|
|
8002
|
-
this.flatten = opts.flatten || false;
|
|
8003
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
8004
|
-
this.sandbox = opts.sandbox || {};
|
|
8005
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
8006
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
8007
|
-
this.parent = opts.parent || null;
|
|
8008
|
-
this.parentProperty = opts.parentProperty || null;
|
|
8009
|
-
this.callback = opts.callback || callback || null;
|
|
8010
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
8011
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
8012
|
-
};
|
|
8013
|
-
if (opts.autostart !== false) {
|
|
8014
|
-
const args = {
|
|
8015
|
-
path: optObj ? opts.path : expr
|
|
8016
|
-
};
|
|
8017
|
-
if (!optObj) {
|
|
8018
|
-
args.json = obj;
|
|
8019
|
-
} else if ("json" in opts) {
|
|
8020
|
-
args.json = opts.json;
|
|
8021
|
-
}
|
|
8022
|
-
const ret = this.evaluate(args);
|
|
8023
|
-
if (!ret || typeof ret !== "object") {
|
|
8024
|
-
throw new NewError(ret);
|
|
8025
|
-
}
|
|
8026
|
-
return ret;
|
|
8027
|
-
}
|
|
8028
|
-
}
|
|
8029
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
8030
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
8031
|
-
let {
|
|
8032
|
-
flatten,
|
|
8033
|
-
wrap
|
|
8034
|
-
} = this;
|
|
8035
|
-
this.currResultType = this.resultType;
|
|
8036
|
-
this.currEval = this.eval;
|
|
8037
|
-
this.currSandbox = this.sandbox;
|
|
8038
|
-
callback = callback || this.callback;
|
|
8039
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
8040
|
-
json = json || this.json;
|
|
8041
|
-
expr = expr || this.path;
|
|
8042
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
8043
|
-
if (!expr.path && expr.path !== "") {
|
|
8044
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
8045
|
-
}
|
|
8046
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
8047
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
8048
|
-
}
|
|
8049
|
-
({
|
|
8050
|
-
json
|
|
8051
|
-
} = expr);
|
|
8052
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
8053
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
8054
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
8055
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
8056
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
8057
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
8058
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
8059
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
8060
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
8061
|
-
expr = expr.path;
|
|
8062
|
-
}
|
|
8063
|
-
currParent = currParent || null;
|
|
8064
|
-
currParentProperty = currParentProperty || null;
|
|
8065
|
-
if (Array.isArray(expr)) {
|
|
8066
|
-
expr = JSONPath.toPathString(expr);
|
|
8067
|
-
}
|
|
8068
|
-
if (!expr && expr !== "" || !json) {
|
|
8069
|
-
return;
|
|
8070
|
-
}
|
|
8071
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
8072
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
8073
|
-
exprList.shift();
|
|
8074
|
-
}
|
|
8075
|
-
this._hasParentSelector = null;
|
|
8076
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
8077
|
-
return ea && !ea.isParentSelector;
|
|
8078
|
-
});
|
|
8079
|
-
if (!result.length) {
|
|
8080
|
-
return wrap ? [] : undefined;
|
|
8081
|
-
}
|
|
8082
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
8083
|
-
return this._getPreferredOutput(result[0]);
|
|
8084
|
-
}
|
|
8085
|
-
return result.reduce((rslt, ea) => {
|
|
8086
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
8087
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
8088
|
-
rslt = rslt.concat(valOrPath);
|
|
8089
|
-
} else {
|
|
8090
|
-
rslt.push(valOrPath);
|
|
8091
|
-
}
|
|
8092
|
-
return rslt;
|
|
8093
|
-
}, []);
|
|
8094
|
-
};
|
|
8095
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
8096
|
-
const resultType = this.currResultType;
|
|
8097
|
-
switch (resultType) {
|
|
8098
|
-
case "all": {
|
|
8099
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
8100
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
8101
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
8102
|
-
return ea;
|
|
8103
|
-
}
|
|
8104
|
-
case "value":
|
|
8105
|
-
case "parent":
|
|
8106
|
-
case "parentProperty":
|
|
8107
|
-
return ea[resultType];
|
|
8108
|
-
case "path":
|
|
8109
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
8110
|
-
case "pointer":
|
|
8111
|
-
return JSONPath.toPointer(ea.path);
|
|
8112
|
-
default:
|
|
8113
|
-
throw new TypeError("Unknown result type");
|
|
8114
|
-
}
|
|
8115
|
-
};
|
|
8116
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
8117
|
-
if (callback) {
|
|
8118
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
8119
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
8120
|
-
callback(preferredOutput, type, fullRetObj);
|
|
8121
|
-
}
|
|
8122
|
-
};
|
|
8123
|
-
JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
8124
|
-
let retObj;
|
|
8125
|
-
if (!expr.length) {
|
|
8126
|
-
retObj = {
|
|
8127
|
-
path: path3,
|
|
8128
|
-
value: val,
|
|
8129
|
-
parent,
|
|
8130
|
-
parentProperty: parentPropName,
|
|
8131
|
-
hasArrExpr
|
|
8132
|
-
};
|
|
8133
|
-
this._handleCallback(retObj, callback, "value");
|
|
8134
|
-
return retObj;
|
|
8135
|
-
}
|
|
8136
|
-
const loc = expr[0], x = expr.slice(1);
|
|
8137
|
-
const ret = [];
|
|
8138
|
-
function addRet(elems) {
|
|
8139
|
-
if (Array.isArray(elems)) {
|
|
8140
|
-
elems.forEach((t) => {
|
|
8141
|
-
ret.push(t);
|
|
8142
|
-
});
|
|
8143
|
-
} else {
|
|
8144
|
-
ret.push(elems);
|
|
8145
|
-
}
|
|
8146
|
-
}
|
|
8147
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
8148
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
8149
|
-
} else if (loc === "*") {
|
|
8150
|
-
this._walk(val, (m) => {
|
|
8151
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
8152
|
-
});
|
|
8153
|
-
} else if (loc === "..") {
|
|
8154
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
8155
|
-
this._walk(val, (m) => {
|
|
8156
|
-
if (typeof val[m] === "object") {
|
|
8157
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
8158
|
-
}
|
|
8159
|
-
});
|
|
8160
|
-
} else if (loc === "^") {
|
|
8161
|
-
this._hasParentSelector = true;
|
|
8162
|
-
return {
|
|
8163
|
-
path: path3.slice(0, -1),
|
|
8164
|
-
expr: x,
|
|
8165
|
-
isParentSelector: true
|
|
8166
|
-
};
|
|
8167
|
-
} else if (loc === "~") {
|
|
8168
|
-
retObj = {
|
|
8169
|
-
path: push(path3, loc),
|
|
8170
|
-
value: parentPropName,
|
|
8171
|
-
parent,
|
|
8172
|
-
parentProperty: null
|
|
8173
|
-
};
|
|
8174
|
-
this._handleCallback(retObj, callback, "property");
|
|
8175
|
-
return retObj;
|
|
8176
|
-
} else if (loc === "$") {
|
|
8177
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
8178
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
8179
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
8180
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
8181
|
-
if (this.currEval === false) {
|
|
8182
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
8183
|
-
}
|
|
8184
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
8185
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
8186
|
-
if (nested) {
|
|
8187
|
-
this._walk(val, (m) => {
|
|
8188
|
-
const npath = [nested[2]];
|
|
8189
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
8190
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
8191
|
-
if (filterResults.length > 0) {
|
|
8192
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
8193
|
-
}
|
|
8194
|
-
});
|
|
8195
|
-
} else {
|
|
8196
|
-
this._walk(val, (m) => {
|
|
8197
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
8198
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
8199
|
-
}
|
|
8200
|
-
});
|
|
8201
|
-
}
|
|
8202
|
-
} else if (loc[0] === "(") {
|
|
8203
|
-
if (this.currEval === false) {
|
|
8204
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
8205
|
-
}
|
|
8206
|
-
addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
8207
|
-
} else if (loc[0] === "@") {
|
|
8208
|
-
let addType = false;
|
|
8209
|
-
const valueType = loc.slice(1, -2);
|
|
8210
|
-
switch (valueType) {
|
|
8211
|
-
case "scalar":
|
|
8212
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
8213
|
-
addType = true;
|
|
8214
|
-
}
|
|
8215
|
-
break;
|
|
8216
|
-
case "boolean":
|
|
8217
|
-
case "string":
|
|
8218
|
-
case "undefined":
|
|
8219
|
-
case "function":
|
|
8220
|
-
if (typeof val === valueType) {
|
|
8221
|
-
addType = true;
|
|
8222
|
-
}
|
|
8223
|
-
break;
|
|
8224
|
-
case "integer":
|
|
8225
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
8226
|
-
addType = true;
|
|
8227
|
-
}
|
|
8228
|
-
break;
|
|
8229
|
-
case "number":
|
|
8230
|
-
if (Number.isFinite(val)) {
|
|
8231
|
-
addType = true;
|
|
8232
|
-
}
|
|
8233
|
-
break;
|
|
8234
|
-
case "nonFinite":
|
|
8235
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
8236
|
-
addType = true;
|
|
8237
|
-
}
|
|
8238
|
-
break;
|
|
8239
|
-
case "object":
|
|
8240
|
-
if (val && typeof val === valueType) {
|
|
8241
|
-
addType = true;
|
|
8242
|
-
}
|
|
8243
|
-
break;
|
|
8244
|
-
case "array":
|
|
8245
|
-
if (Array.isArray(val)) {
|
|
8246
|
-
addType = true;
|
|
8247
|
-
}
|
|
8248
|
-
break;
|
|
8249
|
-
case "other":
|
|
8250
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
8251
|
-
break;
|
|
8252
|
-
case "null":
|
|
8253
|
-
if (val === null) {
|
|
8254
|
-
addType = true;
|
|
8255
|
-
}
|
|
8256
|
-
break;
|
|
8257
|
-
default:
|
|
8258
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
8259
|
-
}
|
|
8260
|
-
if (addType) {
|
|
8261
|
-
retObj = {
|
|
8262
|
-
path: path3,
|
|
8263
|
-
value: val,
|
|
8264
|
-
parent,
|
|
8265
|
-
parentProperty: parentPropName
|
|
8266
|
-
};
|
|
8267
|
-
this._handleCallback(retObj, callback, "value");
|
|
8268
|
-
return retObj;
|
|
8269
|
-
}
|
|
8270
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
8271
|
-
const locProp = loc.slice(1);
|
|
8272
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
8273
|
-
} else if (loc.includes(",")) {
|
|
8274
|
-
const parts = loc.split(",");
|
|
8275
|
-
for (const part of parts) {
|
|
8276
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
8277
|
-
}
|
|
8278
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
8279
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
8280
|
-
}
|
|
8281
|
-
if (this._hasParentSelector) {
|
|
8282
|
-
for (let t = 0;t < ret.length; t++) {
|
|
8283
|
-
const rett = ret[t];
|
|
8284
|
-
if (rett && rett.isParentSelector) {
|
|
8285
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
8286
|
-
if (Array.isArray(tmp)) {
|
|
8287
|
-
ret[t] = tmp[0];
|
|
8288
|
-
const tl = tmp.length;
|
|
8289
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
8290
|
-
t++;
|
|
8291
|
-
ret.splice(t, 0, tmp[tt]);
|
|
8292
|
-
}
|
|
8293
|
-
} else {
|
|
8294
|
-
ret[t] = tmp;
|
|
8295
|
-
}
|
|
8296
|
-
}
|
|
8297
|
-
}
|
|
8298
|
-
}
|
|
8299
|
-
return ret;
|
|
8300
|
-
};
|
|
8301
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
8302
|
-
if (Array.isArray(val)) {
|
|
8303
|
-
const n = val.length;
|
|
8304
|
-
for (let i = 0;i < n; i++) {
|
|
8305
|
-
f(i);
|
|
8306
|
-
}
|
|
8307
|
-
} else if (val && typeof val === "object") {
|
|
8308
|
-
Object.keys(val).forEach((m) => {
|
|
8309
|
-
f(m);
|
|
8310
|
-
});
|
|
8311
|
-
}
|
|
8312
|
-
};
|
|
8313
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
8314
|
-
if (!Array.isArray(val)) {
|
|
8315
|
-
return;
|
|
8316
|
-
}
|
|
8317
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
8318
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
8319
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
8320
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
8321
|
-
const ret = [];
|
|
8322
|
-
for (let i = start;i < end; i += step) {
|
|
8323
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
8324
|
-
tmp.forEach((t) => {
|
|
8325
|
-
ret.push(t);
|
|
8326
|
-
});
|
|
8327
|
-
}
|
|
8328
|
-
return ret;
|
|
8329
|
-
};
|
|
8330
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
8331
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
8332
|
-
this.currSandbox._$_parent = parent;
|
|
8333
|
-
this.currSandbox._$_property = _vname;
|
|
8334
|
-
this.currSandbox._$_root = this.json;
|
|
8335
|
-
this.currSandbox._$_v = _v;
|
|
8336
|
-
const containsPath = code.includes("@path");
|
|
8337
|
-
if (containsPath) {
|
|
8338
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
8339
|
-
}
|
|
8340
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
8341
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
8342
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
8343
|
-
if (containsPath) {
|
|
8344
|
-
script = script.replaceAll("@path", "_$_path");
|
|
8345
|
-
}
|
|
8346
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
8347
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
8348
|
-
} else if (this.currEval === "native") {
|
|
8349
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
8350
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
8351
|
-
const CurrEval = this.currEval;
|
|
8352
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
8353
|
-
} else if (typeof this.currEval === "function") {
|
|
8354
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
8355
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
8356
|
-
};
|
|
8357
|
-
} else {
|
|
8358
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
try {
|
|
8362
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
8363
|
-
} catch (e) {
|
|
8364
|
-
if (this.ignoreEvalErrors) {
|
|
8365
|
-
return false;
|
|
8366
|
-
}
|
|
8367
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
8368
|
-
}
|
|
8369
|
-
};
|
|
8370
|
-
JSONPath.cache = {};
|
|
8371
|
-
JSONPath.toPathString = function(pathArr) {
|
|
8372
|
-
const x = pathArr, n = x.length;
|
|
8373
|
-
let p = "$";
|
|
8374
|
-
for (let i = 1;i < n; i++) {
|
|
8375
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
8376
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
8377
|
-
}
|
|
8378
|
-
}
|
|
8379
|
-
return p;
|
|
8380
|
-
};
|
|
8381
|
-
JSONPath.toPointer = function(pointer) {
|
|
8382
|
-
const x = pointer, n = x.length;
|
|
8383
|
-
let p = "";
|
|
8384
|
-
for (let i = 1;i < n; i++) {
|
|
8385
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
8386
|
-
p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
8387
|
-
}
|
|
8388
|
-
}
|
|
8389
|
-
return p;
|
|
8390
|
-
};
|
|
8391
|
-
JSONPath.toPathArray = function(expr) {
|
|
8392
|
-
const {
|
|
8393
|
-
cache
|
|
8394
|
-
} = JSONPath;
|
|
8395
|
-
if (cache[expr]) {
|
|
8396
|
-
return cache[expr].concat();
|
|
8397
|
-
}
|
|
8398
|
-
const subx = [];
|
|
8399
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
8400
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
8401
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
8402
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
8403
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
8404
|
-
return ";" + ups.split("").join(";") + ";";
|
|
8405
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
8406
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
8407
|
-
const match = exp.match(/#(\d+)/u);
|
|
8408
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
8409
|
-
});
|
|
8410
|
-
cache[expr] = exprList;
|
|
8411
|
-
return cache[expr].concat();
|
|
8412
|
-
};
|
|
8413
|
-
JSONPath.prototype.safeVm = {
|
|
8414
|
-
Script: SafeScript
|
|
8415
|
-
};
|
|
8416
|
-
JSONPath.prototype.vm = vm;
|
|
8417
|
-
// ../../common/src/option-aliases.ts
|
|
8418
|
-
import { Option } from "commander";
|
|
8419
|
-
// ../../common/src/option-validators.ts
|
|
8420
|
-
import { InvalidArgumentError } from "commander";
|
|
8421
|
-
// ../../common/src/polling/types.ts
|
|
8422
|
-
var PollOutcome = {
|
|
8423
|
-
Completed: "completed",
|
|
8424
|
-
Timeout: "timeout",
|
|
8425
|
-
Interrupted: "interrupted",
|
|
8426
|
-
Aborted: "aborted",
|
|
8427
|
-
Failed: "failed"
|
|
8428
|
-
};
|
|
8429
|
-
|
|
8430
|
-
// ../../common/src/polling/poll-failure-mapping.ts
|
|
8431
|
-
var REASON_BY_OUTCOME = {
|
|
8432
|
-
[PollOutcome.Timeout]: "poll_timeout",
|
|
8433
|
-
[PollOutcome.Failed]: "poll_failed",
|
|
8434
|
-
[PollOutcome.Interrupted]: "poll_failed",
|
|
8435
|
-
[PollOutcome.Aborted]: "poll_aborted"
|
|
8436
|
-
};
|
|
8437
|
-
// ../../common/src/polling/terminal-statuses.ts
|
|
8438
|
-
var TERMINAL_STATUSES = new Set([
|
|
8439
|
-
"completed",
|
|
8440
|
-
"successful",
|
|
8441
|
-
"faulted",
|
|
8442
|
-
"failed",
|
|
8443
|
-
"cancelled",
|
|
8444
|
-
"canceled",
|
|
8445
|
-
"stopped",
|
|
8446
|
-
"finished"
|
|
8447
|
-
]);
|
|
8448
|
-
var FAILURE_STATUSES = new Set([
|
|
8449
|
-
"faulted",
|
|
8450
|
-
"failed",
|
|
8451
|
-
"cancelled",
|
|
8452
|
-
"canceled",
|
|
8453
|
-
"stopped"
|
|
8454
|
-
]);
|
|
8455
|
-
// ../../common/src/screen-logger.ts
|
|
8456
|
-
var ScreenLogger;
|
|
8457
|
-
((ScreenLogger) => {
|
|
8458
|
-
function progress(message) {
|
|
8459
|
-
getOutputSink().writeErr(`${message}
|
|
8460
|
-
`);
|
|
8461
|
-
}
|
|
8462
|
-
ScreenLogger.progress = progress;
|
|
8463
|
-
})(ScreenLogger ||= {});
|
|
8464
|
-
// ../../common/src/sdk-user-agent.ts
|
|
8465
|
-
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
8466
|
-
// ../../common/src/tool-provider.ts
|
|
8467
|
-
var factorySlot = singleton("PackagerFactoryProvider");
|
|
8468
|
-
// ../llmgw-sdk/dist/index.js
|
|
8469
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
8470
|
-
import fs7 from "node:fs";
|
|
8471
|
-
import fs22 from "node:fs";
|
|
8472
|
-
import process22 from "node:process";
|
|
8473
|
-
import os3 from "node:os";
|
|
8474
|
-
import fs32 from "node:fs";
|
|
8475
|
-
import process32 from "node:process";
|
|
8476
|
-
import { Buffer as Buffer22 } from "node:buffer";
|
|
8477
|
-
import { promisify as promisify7 } from "node:util";
|
|
8478
|
-
import childProcess4 from "node:child_process";
|
|
8479
|
-
import { promisify as promisify22 } from "node:util";
|
|
8480
|
-
import childProcess22 from "node:child_process";
|
|
8481
|
-
import fs42, { constants as fsConstants3 } from "node:fs/promises";
|
|
8482
|
-
import { promisify as promisify32 } from "node:util";
|
|
8483
|
-
import process42 from "node:process";
|
|
8484
|
-
import { execFile as execFile32 } from "node:child_process";
|
|
8485
|
-
import process52 from "node:process";
|
|
8486
|
-
import { promisify as promisify42 } from "node:util";
|
|
8487
|
-
import { execFile as execFile42, execFileSync as execFileSync3 } from "node:child_process";
|
|
8488
|
-
import { promisify as promisify52 } from "node:util";
|
|
8489
|
-
import { execFile as execFile52 } from "node:child_process";
|
|
8490
|
-
import { promisify as promisify62 } from "node:util";
|
|
8491
|
-
import process62 from "node:process";
|
|
8492
|
-
import { execFile as execFile62 } from "node:child_process";
|
|
8493
|
-
import process72 from "node:process";
|
|
8494
|
-
import process82 from "node:process";
|
|
8495
|
-
import path3 from "node:path";
|
|
8496
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8497
|
-
import childProcess32 from "node:child_process";
|
|
8498
|
-
import fs52, { constants as fsConstants22 } from "node:fs/promises";
|
|
8499
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8500
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
8501
|
-
import * as fs62 from "node:fs/promises";
|
|
8502
|
-
import * as os22 from "node:os";
|
|
8503
|
-
import * as path22 from "node:path";
|
|
8504
|
-
var __create2 = Object.create;
|
|
8505
|
-
var __getProtoOf2 = Object.getPrototypeOf;
|
|
8506
|
-
var __defProp2 = Object.defineProperty;
|
|
8507
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
8508
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
8509
|
-
function __accessProp(key) {
|
|
8510
|
-
return this[key];
|
|
8511
|
-
}
|
|
8512
|
-
var __toESMCache_node;
|
|
8513
|
-
var __toESMCache_esm;
|
|
8514
|
-
var __toESM2 = (mod2, isNodeMode, target) => {
|
|
8515
|
-
var canCache = mod2 != null && typeof mod2 === "object";
|
|
8516
|
-
if (canCache) {
|
|
8517
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
8518
|
-
var cached = cache.get(mod2);
|
|
8519
|
-
if (cached)
|
|
8520
|
-
return cached;
|
|
8521
|
-
}
|
|
8522
|
-
target = mod2 != null ? __create2(__getProtoOf2(mod2)) : {};
|
|
8523
|
-
const to = isNodeMode || !mod2 || !mod2.__esModule ? __defProp2(target, "default", { value: mod2, enumerable: true }) : target;
|
|
8524
|
-
for (let key of __getOwnPropNames2(mod2))
|
|
8525
|
-
if (!__hasOwnProp2.call(to, key))
|
|
8526
|
-
__defProp2(to, key, {
|
|
8527
|
-
get: __accessProp.bind(mod2, key),
|
|
8528
|
-
enumerable: true
|
|
8529
|
-
});
|
|
8530
|
-
if (canCache)
|
|
8531
|
-
cache.set(mod2, to);
|
|
8532
|
-
return to;
|
|
8533
|
-
};
|
|
8534
|
-
var __commonJS = (cb, mod2) => () => (mod2 || cb((mod2 = { exports: {} }).exports, mod2), mod2.exports);
|
|
8535
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
8536
|
-
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
8537
|
-
function isPromiseLike2(value) {
|
|
8538
|
-
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
8539
|
-
}
|
|
8540
|
-
function catchError2(fnOrPromise) {
|
|
8541
|
-
if (isPromiseLike2(fnOrPromise)) {
|
|
8542
|
-
return settlePromiseLike2(fnOrPromise);
|
|
8543
|
-
}
|
|
8544
|
-
try {
|
|
8545
|
-
const result = fnOrPromise();
|
|
8546
|
-
if (isPromiseLike2(result)) {
|
|
8547
|
-
return settlePromiseLike2(result);
|
|
8548
|
-
}
|
|
8549
|
-
return [undefined, result];
|
|
8550
|
-
} catch (error) {
|
|
8551
|
-
return [
|
|
8552
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
8553
|
-
undefined
|
|
8554
|
-
];
|
|
8555
|
-
}
|
|
8556
|
-
}
|
|
8557
|
-
function settlePromiseLike2(thenable) {
|
|
8558
|
-
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
8559
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
8560
|
-
undefined
|
|
8561
|
-
]);
|
|
8562
|
-
}
|
|
8563
|
-
var UIPATH_HOME_DIR = ".uipath";
|
|
8564
|
-
var AUTH_FILENAME = ".auth";
|
|
8565
|
-
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
8566
|
-
var DEFAULT_AUTH_TIMEOUT_MS2;
|
|
8567
|
-
var init_constants = __esm(() => {
|
|
8568
|
-
DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
8569
|
-
});
|
|
8570
|
-
function isBrowser() {
|
|
8571
|
-
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
8572
|
-
}
|
|
8573
|
-
function hasDockerEnv2() {
|
|
8574
|
-
try {
|
|
8575
|
-
fs7.statSync("/.dockerenv");
|
|
8576
|
-
return true;
|
|
8577
|
-
} catch {
|
|
8578
|
-
return false;
|
|
8579
|
-
}
|
|
8580
|
-
}
|
|
8581
|
-
function hasDockerCGroup2() {
|
|
8582
|
-
try {
|
|
8583
|
-
return fs7.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
8584
|
-
} catch {
|
|
8585
|
-
return false;
|
|
8586
|
-
}
|
|
8587
|
-
}
|
|
8588
|
-
function isDocker2() {
|
|
8589
|
-
if (isDockerCached2 === undefined) {
|
|
8590
|
-
isDockerCached2 = hasDockerEnv2() || hasDockerCGroup2();
|
|
8591
|
-
}
|
|
8592
|
-
return isDockerCached2;
|
|
8593
|
-
}
|
|
8594
|
-
var isDockerCached2;
|
|
8595
|
-
var init_is_docker = () => {};
|
|
8596
|
-
function isInsideContainer2() {
|
|
8597
|
-
if (cachedResult2 === undefined) {
|
|
8598
|
-
cachedResult2 = hasContainerEnv2() || isDocker2();
|
|
8599
|
-
}
|
|
8600
|
-
return cachedResult2;
|
|
8601
|
-
}
|
|
8602
|
-
var cachedResult2;
|
|
8603
|
-
var hasContainerEnv2 = () => {
|
|
8604
|
-
try {
|
|
8605
|
-
fs22.statSync("/run/.containerenv");
|
|
8606
|
-
return true;
|
|
8607
|
-
} catch {
|
|
8608
|
-
return false;
|
|
8609
|
-
}
|
|
8610
|
-
};
|
|
8611
|
-
var init_is_inside_container = __esm(() => {
|
|
8612
|
-
init_is_docker();
|
|
8613
|
-
});
|
|
8614
|
-
var isWsl2 = () => {
|
|
8615
|
-
if (process22.platform !== "linux") {
|
|
8616
|
-
return false;
|
|
7339
|
+
};
|
|
7340
|
+
var init_is_inside_container = __esm(() => {
|
|
7341
|
+
init_is_docker();
|
|
7342
|
+
});
|
|
7343
|
+
var isWsl2 = () => {
|
|
7344
|
+
if (process22.platform !== "linux") {
|
|
7345
|
+
return false;
|
|
8617
7346
|
}
|
|
8618
7347
|
if (os3.release().toLowerCase().includes("microsoft")) {
|
|
8619
7348
|
if (isInsideContainer2()) {
|
|
@@ -19874,8 +18603,8 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
19874
18603
|
if (_parentOrParents instanceof Subscription2) {
|
|
19875
18604
|
_parentOrParents.remove(this);
|
|
19876
18605
|
} else if (_parentOrParents !== null) {
|
|
19877
|
-
for (var
|
|
19878
|
-
var parent_1 = _parentOrParents[
|
|
18606
|
+
for (var index = 0;index < _parentOrParents.length; ++index) {
|
|
18607
|
+
var parent_1 = _parentOrParents[index];
|
|
19879
18608
|
parent_1.remove(this);
|
|
19880
18609
|
}
|
|
19881
18610
|
}
|
|
@@ -19890,10 +18619,10 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
19890
18619
|
}
|
|
19891
18620
|
}
|
|
19892
18621
|
if (isArray_1.isArray(_subscriptions)) {
|
|
19893
|
-
var
|
|
18622
|
+
var index = -1;
|
|
19894
18623
|
var len = _subscriptions.length;
|
|
19895
|
-
while (++
|
|
19896
|
-
var sub2 = _subscriptions[
|
|
18624
|
+
while (++index < len) {
|
|
18625
|
+
var sub2 = _subscriptions[index];
|
|
19897
18626
|
if (isObject_1.isObject(sub2)) {
|
|
19898
18627
|
try {
|
|
19899
18628
|
sub2.unsubscribe();
|
|
@@ -21289,13 +20018,13 @@ var require_AsyncAction = __commonJS((exports) => {
|
|
|
21289
20018
|
var id = this.id;
|
|
21290
20019
|
var scheduler = this.scheduler;
|
|
21291
20020
|
var actions = scheduler.actions;
|
|
21292
|
-
var
|
|
20021
|
+
var index = actions.indexOf(this);
|
|
21293
20022
|
this.work = null;
|
|
21294
20023
|
this.state = null;
|
|
21295
20024
|
this.pending = false;
|
|
21296
20025
|
this.scheduler = null;
|
|
21297
|
-
if (
|
|
21298
|
-
actions.splice(
|
|
20026
|
+
if (index !== -1) {
|
|
20027
|
+
actions.splice(index, 1);
|
|
21299
20028
|
}
|
|
21300
20029
|
if (id != null) {
|
|
21301
20030
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
@@ -22101,17 +20830,17 @@ var require_AsapScheduler = __commonJS((exports) => {
|
|
|
22101
20830
|
this.scheduled = undefined;
|
|
22102
20831
|
var actions = this.actions;
|
|
22103
20832
|
var error;
|
|
22104
|
-
var
|
|
20833
|
+
var index = -1;
|
|
22105
20834
|
var count = actions.length;
|
|
22106
20835
|
action = action || actions.shift();
|
|
22107
20836
|
do {
|
|
22108
20837
|
if (error = action.execute(action.state, action.delay)) {
|
|
22109
20838
|
break;
|
|
22110
20839
|
}
|
|
22111
|
-
} while (++
|
|
20840
|
+
} while (++index < count && (action = actions.shift()));
|
|
22112
20841
|
this.active = false;
|
|
22113
20842
|
if (error) {
|
|
22114
|
-
while (++
|
|
20843
|
+
while (++index < count && (action = actions.shift())) {
|
|
22115
20844
|
action.unsubscribe();
|
|
22116
20845
|
}
|
|
22117
20846
|
throw error;
|
|
@@ -22226,17 +20955,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
|
|
|
22226
20955
|
this.scheduled = undefined;
|
|
22227
20956
|
var actions = this.actions;
|
|
22228
20957
|
var error;
|
|
22229
|
-
var
|
|
20958
|
+
var index = -1;
|
|
22230
20959
|
var count = actions.length;
|
|
22231
20960
|
action = action || actions.shift();
|
|
22232
20961
|
do {
|
|
22233
20962
|
if (error = action.execute(action.state, action.delay)) {
|
|
22234
20963
|
break;
|
|
22235
20964
|
}
|
|
22236
|
-
} while (++
|
|
20965
|
+
} while (++index < count && (action = actions.shift()));
|
|
22237
20966
|
this.active = false;
|
|
22238
20967
|
if (error) {
|
|
22239
|
-
while (++
|
|
20968
|
+
while (++index < count && (action = actions.shift())) {
|
|
22240
20969
|
action.unsubscribe();
|
|
22241
20970
|
}
|
|
22242
20971
|
throw error;
|
|
@@ -22316,16 +21045,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
|
|
|
22316
21045
|
exports.VirtualTimeScheduler = VirtualTimeScheduler;
|
|
22317
21046
|
var VirtualAction = function(_super) {
|
|
22318
21047
|
__extends(VirtualAction2, _super);
|
|
22319
|
-
function VirtualAction2(scheduler, work,
|
|
22320
|
-
if (
|
|
22321
|
-
|
|
21048
|
+
function VirtualAction2(scheduler, work, index) {
|
|
21049
|
+
if (index === undefined) {
|
|
21050
|
+
index = scheduler.index += 1;
|
|
22322
21051
|
}
|
|
22323
21052
|
var _this = _super.call(this, scheduler, work) || this;
|
|
22324
21053
|
_this.scheduler = scheduler;
|
|
22325
21054
|
_this.work = work;
|
|
22326
|
-
_this.index =
|
|
21055
|
+
_this.index = index;
|
|
22327
21056
|
_this.active = true;
|
|
22328
|
-
_this.index = scheduler.index =
|
|
21057
|
+
_this.index = scheduler.index = index;
|
|
22329
21058
|
return _this;
|
|
22330
21059
|
}
|
|
22331
21060
|
VirtualAction2.prototype.schedule = function(state, delay) {
|
|
@@ -23416,9 +22145,9 @@ var require_mergeMap = __commonJS((exports) => {
|
|
|
23416
22145
|
};
|
|
23417
22146
|
MergeMapSubscriber2.prototype._tryNext = function(value) {
|
|
23418
22147
|
var result;
|
|
23419
|
-
var
|
|
22148
|
+
var index = this.index++;
|
|
23420
22149
|
try {
|
|
23421
|
-
result = this.project(value,
|
|
22150
|
+
result = this.project(value, index);
|
|
23422
22151
|
} catch (err) {
|
|
23423
22152
|
this.destination.error(err);
|
|
23424
22153
|
return;
|
|
@@ -23968,12 +22697,12 @@ var require_pairs2 = __commonJS((exports) => {
|
|
|
23968
22697
|
}
|
|
23969
22698
|
exports.pairs = pairs;
|
|
23970
22699
|
function dispatch(state) {
|
|
23971
|
-
var { keys, index
|
|
22700
|
+
var { keys, index, subscriber, subscription, obj } = state;
|
|
23972
22701
|
if (!subscriber.closed) {
|
|
23973
|
-
if (
|
|
23974
|
-
var key = keys[
|
|
22702
|
+
if (index < keys.length) {
|
|
22703
|
+
var key = keys[index];
|
|
23975
22704
|
subscriber.next([key, obj[key]]);
|
|
23976
|
-
subscription.add(this.schedule({ keys, index:
|
|
22705
|
+
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
|
23977
22706
|
} else {
|
|
23978
22707
|
subscriber.complete();
|
|
23979
22708
|
}
|
|
@@ -24176,18 +22905,18 @@ var require_range = __commonJS((exports) => {
|
|
|
24176
22905
|
count = start;
|
|
24177
22906
|
start = 0;
|
|
24178
22907
|
}
|
|
24179
|
-
var
|
|
22908
|
+
var index = 0;
|
|
24180
22909
|
var current = start;
|
|
24181
22910
|
if (scheduler) {
|
|
24182
22911
|
return scheduler.schedule(dispatch, 0, {
|
|
24183
|
-
index
|
|
22912
|
+
index,
|
|
24184
22913
|
count,
|
|
24185
22914
|
start,
|
|
24186
22915
|
subscriber
|
|
24187
22916
|
});
|
|
24188
22917
|
} else {
|
|
24189
22918
|
do {
|
|
24190
|
-
if (
|
|
22919
|
+
if (index++ >= count) {
|
|
24191
22920
|
subscriber.complete();
|
|
24192
22921
|
break;
|
|
24193
22922
|
}
|
|
@@ -24202,8 +22931,8 @@ var require_range = __commonJS((exports) => {
|
|
|
24202
22931
|
}
|
|
24203
22932
|
exports.range = range;
|
|
24204
22933
|
function dispatch(state) {
|
|
24205
|
-
var { start, index
|
|
24206
|
-
if (
|
|
22934
|
+
var { start, index, count, subscriber } = state;
|
|
22935
|
+
if (index >= count) {
|
|
24207
22936
|
subscriber.complete();
|
|
24208
22937
|
return;
|
|
24209
22938
|
}
|
|
@@ -24211,7 +22940,7 @@ var require_range = __commonJS((exports) => {
|
|
|
24211
22940
|
if (subscriber.closed) {
|
|
24212
22941
|
return;
|
|
24213
22942
|
}
|
|
24214
|
-
state.index =
|
|
22943
|
+
state.index = index + 1;
|
|
24215
22944
|
state.start = start + 1;
|
|
24216
22945
|
this.schedule(state);
|
|
24217
22946
|
}
|
|
@@ -24247,14 +22976,14 @@ var require_timer = __commonJS((exports) => {
|
|
|
24247
22976
|
}
|
|
24248
22977
|
exports.timer = timer;
|
|
24249
22978
|
function dispatch(state) {
|
|
24250
|
-
var { index
|
|
24251
|
-
subscriber.next(
|
|
22979
|
+
var { index, period, subscriber } = state;
|
|
22980
|
+
subscriber.next(index);
|
|
24252
22981
|
if (subscriber.closed) {
|
|
24253
22982
|
return;
|
|
24254
22983
|
} else if (period === -1) {
|
|
24255
22984
|
return subscriber.complete();
|
|
24256
22985
|
}
|
|
24257
|
-
state.index =
|
|
22986
|
+
state.index = index + 1;
|
|
24258
22987
|
this.schedule(state, period);
|
|
24259
22988
|
}
|
|
24260
22989
|
});
|
|
@@ -27247,6 +25976,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
27247
25976
|
}
|
|
27248
25977
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
27249
25978
|
};
|
|
25979
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
25980
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
25981
|
+
if (isExternalAppAuth)
|
|
25982
|
+
return requestedScopes;
|
|
25983
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
25984
|
+
};
|
|
27250
25985
|
var resolveConfigAsync = async ({
|
|
27251
25986
|
customAuthority,
|
|
27252
25987
|
customClientId,
|
|
@@ -27277,7 +26012,7 @@ var resolveConfigAsync = async ({
|
|
|
27277
26012
|
clientSecret = fileAuth.clientSecret;
|
|
27278
26013
|
}
|
|
27279
26014
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
27280
|
-
const scopes =
|
|
26015
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
27281
26016
|
return {
|
|
27282
26017
|
clientId,
|
|
27283
26018
|
clientSecret,
|
|
@@ -27289,6 +26024,74 @@ var resolveConfigAsync = async ({
|
|
|
27289
26024
|
};
|
|
27290
26025
|
init_constants();
|
|
27291
26026
|
init_src();
|
|
26027
|
+
init_src();
|
|
26028
|
+
init_constants();
|
|
26029
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
26030
|
+
var PROFILE_DIR = "profiles";
|
|
26031
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
26032
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
26033
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
26034
|
+
var globalSlot2 = globalThis;
|
|
26035
|
+
function isAuthProfileStorage(value) {
|
|
26036
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
26037
|
+
}
|
|
26038
|
+
function createProfileStorage() {
|
|
26039
|
+
const [error, mod2] = catchError2(() => __require2("node:async_hooks"));
|
|
26040
|
+
if (error || typeof mod2?.AsyncLocalStorage !== "function") {
|
|
26041
|
+
return {
|
|
26042
|
+
getStore: () => {
|
|
26043
|
+
return;
|
|
26044
|
+
},
|
|
26045
|
+
run: (_store, fn) => fn()
|
|
26046
|
+
};
|
|
26047
|
+
}
|
|
26048
|
+
return new mod2.AsyncLocalStorage;
|
|
26049
|
+
}
|
|
26050
|
+
function getProfileStorage() {
|
|
26051
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
26052
|
+
if (isAuthProfileStorage(existing)) {
|
|
26053
|
+
return existing;
|
|
26054
|
+
}
|
|
26055
|
+
const storage = createProfileStorage();
|
|
26056
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
26057
|
+
return storage;
|
|
26058
|
+
}
|
|
26059
|
+
var profileStorage = getProfileStorage();
|
|
26060
|
+
|
|
26061
|
+
class AuthProfileValidationError extends Error {
|
|
26062
|
+
constructor(message) {
|
|
26063
|
+
super(message);
|
|
26064
|
+
this.name = "AuthProfileValidationError";
|
|
26065
|
+
}
|
|
26066
|
+
}
|
|
26067
|
+
function normalizeAuthProfileName(profile) {
|
|
26068
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
26069
|
+
return;
|
|
26070
|
+
}
|
|
26071
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
26072
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
26073
|
+
}
|
|
26074
|
+
return profile;
|
|
26075
|
+
}
|
|
26076
|
+
function getActiveAuthProfile() {
|
|
26077
|
+
const scopedState = profileStorage.getStore();
|
|
26078
|
+
if (scopedState !== undefined) {
|
|
26079
|
+
return scopedState.profile;
|
|
26080
|
+
}
|
|
26081
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
26082
|
+
}
|
|
26083
|
+
function resolveAuthProfileFilePath(profile) {
|
|
26084
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
26085
|
+
if (normalized === undefined) {
|
|
26086
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
26087
|
+
}
|
|
26088
|
+
const fs72 = getFileSystem2();
|
|
26089
|
+
return fs72.path.join(fs72.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
26090
|
+
}
|
|
26091
|
+
function getActiveAuthProfileFilePath() {
|
|
26092
|
+
const profile = getActiveAuthProfile();
|
|
26093
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
26094
|
+
}
|
|
27292
26095
|
|
|
27293
26096
|
class InvalidIssuerError extends Error {
|
|
27294
26097
|
expected;
|
|
@@ -27415,21 +26218,70 @@ var readAuthFromEnv = () => {
|
|
|
27415
26218
|
organizationId,
|
|
27416
26219
|
tenantName,
|
|
27417
26220
|
tenantId,
|
|
27418
|
-
expiration
|
|
26221
|
+
expiration,
|
|
26222
|
+
source: "env"
|
|
27419
26223
|
};
|
|
27420
26224
|
};
|
|
27421
26225
|
init_src();
|
|
26226
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
26227
|
+
var BACKOFF_BASE_MS = 60000;
|
|
26228
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
26229
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
26230
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
26231
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
26232
|
+
if (globalThis.crypto?.subtle) {
|
|
26233
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
26234
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
26235
|
+
}
|
|
26236
|
+
const { createHash } = await import("node:crypto");
|
|
26237
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
26238
|
+
}
|
|
26239
|
+
function breakerPathFor(authPath) {
|
|
26240
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
26241
|
+
}
|
|
26242
|
+
async function loadRefreshBreaker(authPath) {
|
|
26243
|
+
const fs72 = getFileSystem2();
|
|
26244
|
+
try {
|
|
26245
|
+
const content = await fs72.readFile(breakerPathFor(authPath), "utf-8");
|
|
26246
|
+
if (!content)
|
|
26247
|
+
return {};
|
|
26248
|
+
const parsed = JSON.parse(content);
|
|
26249
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
26250
|
+
} catch {
|
|
26251
|
+
return {};
|
|
26252
|
+
}
|
|
26253
|
+
}
|
|
26254
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
26255
|
+
try {
|
|
26256
|
+
const fs72 = getFileSystem2();
|
|
26257
|
+
const path32 = breakerPathFor(authPath);
|
|
26258
|
+
await fs72.mkdir(fs72.path.dirname(path32));
|
|
26259
|
+
const tempPath = `${path32}.tmp`;
|
|
26260
|
+
await fs72.writeFile(tempPath, JSON.stringify(state));
|
|
26261
|
+
await fs72.rename(tempPath, path32);
|
|
26262
|
+
} catch {}
|
|
26263
|
+
}
|
|
26264
|
+
async function clearRefreshBreaker(authPath) {
|
|
26265
|
+
const fs72 = getFileSystem2();
|
|
26266
|
+
const path32 = breakerPathFor(authPath);
|
|
26267
|
+
try {
|
|
26268
|
+
if (await fs72.exists(path32)) {
|
|
26269
|
+
await fs72.rm(path32);
|
|
26270
|
+
}
|
|
26271
|
+
} catch {}
|
|
26272
|
+
}
|
|
26273
|
+
function nextBackoffMs(attempts) {
|
|
26274
|
+
const shift = Math.max(0, attempts - 1);
|
|
26275
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
26276
|
+
}
|
|
26277
|
+
function shouldSurface(state, nowMs) {
|
|
26278
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
26279
|
+
return true;
|
|
26280
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
26281
|
+
}
|
|
26282
|
+
init_src();
|
|
27422
26283
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
27423
26284
|
var CLOSE_TIMEOUT_MS = 500;
|
|
27424
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
27425
|
-
var printNoticeOnce = () => {
|
|
27426
|
-
const slot = globalThis;
|
|
27427
|
-
if (slot[NOTICE_SENTINEL])
|
|
27428
|
-
return;
|
|
27429
|
-
slot[NOTICE_SENTINEL] = true;
|
|
27430
|
-
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
27431
|
-
`));
|
|
27432
|
-
};
|
|
27433
26285
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
27434
26286
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
27435
26287
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -27545,7 +26397,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
27545
26397
|
issuerFromToken = issClaim;
|
|
27546
26398
|
}
|
|
27547
26399
|
}
|
|
27548
|
-
printNoticeOnce();
|
|
27549
26400
|
return {
|
|
27550
26401
|
accessToken,
|
|
27551
26402
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -27764,18 +26615,327 @@ var saveEnvFileAsync = async ({
|
|
|
27764
26615
|
await fs72.writeFile(tempPath, content);
|
|
27765
26616
|
await fs72.rename(tempPath, absolutePath);
|
|
27766
26617
|
};
|
|
27767
|
-
|
|
27768
|
-
return
|
|
26618
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
26619
|
+
return getLoginStatusWithDeps(options);
|
|
26620
|
+
};
|
|
26621
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
26622
|
+
const {
|
|
26623
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
26624
|
+
loadEnvFile = loadEnvFileAsync,
|
|
26625
|
+
saveEnvFile = saveEnvFileAsync,
|
|
26626
|
+
getFs = getFileSystem2,
|
|
26627
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
26628
|
+
resolveConfig = resolveConfigAsync,
|
|
26629
|
+
robotFallback = tryRobotClientFallback,
|
|
26630
|
+
loadBreaker = loadRefreshBreaker,
|
|
26631
|
+
saveBreaker = saveRefreshBreaker,
|
|
26632
|
+
clearBreaker = clearRefreshBreaker
|
|
26633
|
+
} = deps;
|
|
26634
|
+
if (isRobotAuthEnforced()) {
|
|
26635
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
26636
|
+
}
|
|
26637
|
+
if (isEnvAuthEnabled()) {
|
|
26638
|
+
return readAuthFromEnv();
|
|
26639
|
+
}
|
|
26640
|
+
const activeProfile = getActiveAuthProfile();
|
|
26641
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
26642
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
26643
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
26644
|
+
const { ensureTokenValidityMinutes } = options;
|
|
26645
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
26646
|
+
if (absolutePath === undefined) {
|
|
26647
|
+
if (usingActiveProfile) {
|
|
26648
|
+
return {
|
|
26649
|
+
loginStatus: "Not logged in",
|
|
26650
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
26651
|
+
};
|
|
26652
|
+
}
|
|
26653
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
26654
|
+
}
|
|
26655
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
26656
|
+
if ("status" in loaded) {
|
|
26657
|
+
return loaded.status;
|
|
26658
|
+
}
|
|
26659
|
+
const { credentials } = loaded;
|
|
26660
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
26661
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
26662
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
26663
|
+
let tokens = {
|
|
26664
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
26665
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
26666
|
+
expiration,
|
|
26667
|
+
lockReleaseFailed: false
|
|
26668
|
+
};
|
|
26669
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
26670
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
26671
|
+
const refreshed = await attemptRefresh({
|
|
26672
|
+
absolutePath,
|
|
26673
|
+
credentials,
|
|
26674
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
26675
|
+
refreshToken,
|
|
26676
|
+
expiration,
|
|
26677
|
+
ensureTokenValidityMinutes,
|
|
26678
|
+
getFs,
|
|
26679
|
+
loadEnvFile,
|
|
26680
|
+
saveEnvFile,
|
|
26681
|
+
refreshFn: refreshTokenFn,
|
|
26682
|
+
resolveConfig,
|
|
26683
|
+
loadBreaker,
|
|
26684
|
+
saveBreaker,
|
|
26685
|
+
clearBreaker,
|
|
26686
|
+
globalHint
|
|
26687
|
+
});
|
|
26688
|
+
if (refreshed.kind === "terminal") {
|
|
26689
|
+
return refreshed.status;
|
|
26690
|
+
}
|
|
26691
|
+
tokens = refreshed.tokens;
|
|
26692
|
+
}
|
|
26693
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
26694
|
+
};
|
|
26695
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
26696
|
+
if (isEnvAuthEnabled()) {
|
|
26697
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true are mutually exclusive. Unset one of them and re-run.`);
|
|
26698
|
+
}
|
|
26699
|
+
const robotCreds = await robotFallback({ force: true });
|
|
26700
|
+
if (!robotCreds) {
|
|
26701
|
+
return {
|
|
26702
|
+
loginStatus: "Not logged in",
|
|
26703
|
+
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.`
|
|
26704
|
+
};
|
|
26705
|
+
}
|
|
26706
|
+
return buildRobotStatus(robotCreds);
|
|
27769
26707
|
}
|
|
27770
|
-
function
|
|
27771
|
-
|
|
26708
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
26709
|
+
const robotCreds = await robotFallback();
|
|
26710
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
27772
26711
|
}
|
|
27773
|
-
function
|
|
27774
|
-
|
|
26712
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
26713
|
+
let credentials;
|
|
26714
|
+
try {
|
|
26715
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
26716
|
+
} catch (error) {
|
|
26717
|
+
if (isFileNotFoundError(error)) {
|
|
26718
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
26719
|
+
}
|
|
26720
|
+
throw error;
|
|
26721
|
+
}
|
|
26722
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
26723
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
26724
|
+
}
|
|
26725
|
+
return { credentials };
|
|
26726
|
+
}
|
|
26727
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
26728
|
+
const fs72 = getFs();
|
|
26729
|
+
const globalPath = fs72.path.join(fs72.env.homedir(), envFilePath);
|
|
26730
|
+
if (absolutePath === globalPath)
|
|
26731
|
+
return;
|
|
26732
|
+
if (!await fs72.exists(globalPath))
|
|
26733
|
+
return;
|
|
26734
|
+
try {
|
|
26735
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
26736
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
26737
|
+
return;
|
|
26738
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
26739
|
+
if (globalExp && globalExp <= new Date)
|
|
26740
|
+
return;
|
|
26741
|
+
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.`;
|
|
26742
|
+
} catch {
|
|
26743
|
+
return;
|
|
26744
|
+
}
|
|
27775
26745
|
}
|
|
27776
26746
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
27777
26747
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
27778
26748
|
}
|
|
26749
|
+
async function attemptRefresh(ctx) {
|
|
26750
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
26751
|
+
if (shortCircuit) {
|
|
26752
|
+
return { kind: "terminal", status: shortCircuit };
|
|
26753
|
+
}
|
|
26754
|
+
let release;
|
|
26755
|
+
try {
|
|
26756
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
26757
|
+
} catch (error) {
|
|
26758
|
+
return {
|
|
26759
|
+
kind: "terminal",
|
|
26760
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
26761
|
+
};
|
|
26762
|
+
}
|
|
26763
|
+
let lockedFailure;
|
|
26764
|
+
let lockReleaseFailed = false;
|
|
26765
|
+
let success;
|
|
26766
|
+
try {
|
|
26767
|
+
const outcome = await runRefreshLocked({
|
|
26768
|
+
absolutePath: ctx.absolutePath,
|
|
26769
|
+
refreshToken: ctx.refreshToken,
|
|
26770
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
26771
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
26772
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
26773
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
26774
|
+
refreshFn: ctx.refreshFn,
|
|
26775
|
+
resolveConfig: ctx.resolveConfig,
|
|
26776
|
+
loadBreaker: ctx.loadBreaker,
|
|
26777
|
+
saveBreaker: ctx.saveBreaker,
|
|
26778
|
+
clearBreaker: ctx.clearBreaker
|
|
26779
|
+
});
|
|
26780
|
+
if (outcome.kind === "fail") {
|
|
26781
|
+
lockedFailure = outcome.status;
|
|
26782
|
+
} else {
|
|
26783
|
+
success = outcome;
|
|
26784
|
+
}
|
|
26785
|
+
} finally {
|
|
26786
|
+
try {
|
|
26787
|
+
await release();
|
|
26788
|
+
} catch {
|
|
26789
|
+
lockReleaseFailed = true;
|
|
26790
|
+
}
|
|
26791
|
+
}
|
|
26792
|
+
if (lockedFailure) {
|
|
26793
|
+
const globalHint = await ctx.globalHint();
|
|
26794
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
26795
|
+
return {
|
|
26796
|
+
kind: "terminal",
|
|
26797
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
26798
|
+
};
|
|
26799
|
+
}
|
|
26800
|
+
return {
|
|
26801
|
+
kind: "refreshed",
|
|
26802
|
+
tokens: {
|
|
26803
|
+
accessToken: success?.accessToken,
|
|
26804
|
+
refreshToken: success?.refreshToken,
|
|
26805
|
+
expiration: success?.expiration,
|
|
26806
|
+
tokenRefresh: success?.tokenRefresh,
|
|
26807
|
+
persistenceWarning: success?.persistenceWarning,
|
|
26808
|
+
lockReleaseFailed
|
|
26809
|
+
}
|
|
26810
|
+
};
|
|
26811
|
+
}
|
|
26812
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
26813
|
+
const result = {
|
|
26814
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
26815
|
+
accessToken: tokens.accessToken,
|
|
26816
|
+
refreshToken: tokens.refreshToken,
|
|
26817
|
+
baseUrl: credentials.UIPATH_URL,
|
|
26818
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
26819
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
26820
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
26821
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
26822
|
+
expiration: tokens.expiration,
|
|
26823
|
+
source: "file",
|
|
26824
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
26825
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
26826
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
26827
|
+
};
|
|
26828
|
+
if (result.loginStatus === "Expired") {
|
|
26829
|
+
const hint = await globalHint();
|
|
26830
|
+
if (hint) {
|
|
26831
|
+
result.hint = hint;
|
|
26832
|
+
}
|
|
26833
|
+
}
|
|
26834
|
+
return result;
|
|
26835
|
+
}
|
|
26836
|
+
function buildRobotStatus(robotCreds) {
|
|
26837
|
+
return {
|
|
26838
|
+
loginStatus: "Logged in",
|
|
26839
|
+
accessToken: robotCreds.accessToken,
|
|
26840
|
+
baseUrl: robotCreds.baseUrl,
|
|
26841
|
+
organizationName: robotCreds.organizationName,
|
|
26842
|
+
organizationId: robotCreds.organizationId,
|
|
26843
|
+
tenantName: robotCreds.tenantName,
|
|
26844
|
+
tenantId: robotCreds.tenantId,
|
|
26845
|
+
issuer: robotCreds.issuer,
|
|
26846
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
26847
|
+
source: "robot"
|
|
26848
|
+
};
|
|
26849
|
+
}
|
|
26850
|
+
var isFileNotFoundError = (error) => {
|
|
26851
|
+
if (!(error instanceof Object))
|
|
26852
|
+
return false;
|
|
26853
|
+
return error.code === "ENOENT";
|
|
26854
|
+
};
|
|
26855
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
26856
|
+
const {
|
|
26857
|
+
absolutePath,
|
|
26858
|
+
refreshToken,
|
|
26859
|
+
accessToken,
|
|
26860
|
+
credentials,
|
|
26861
|
+
expiration,
|
|
26862
|
+
loadBreaker,
|
|
26863
|
+
saveBreaker,
|
|
26864
|
+
clearBreaker
|
|
26865
|
+
} = ctx;
|
|
26866
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
26867
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
26868
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
26869
|
+
await clearBreaker(absolutePath);
|
|
26870
|
+
breaker.deadTokenFp = undefined;
|
|
26871
|
+
}
|
|
26872
|
+
const nowMs = Date.now();
|
|
26873
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
26874
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
26875
|
+
if (!tokenIsDead && !inBackoff)
|
|
26876
|
+
return;
|
|
26877
|
+
const globalHint = await ctx.globalHint();
|
|
26878
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
26879
|
+
if (!suppressed) {
|
|
26880
|
+
await saveBreaker(absolutePath, {
|
|
26881
|
+
...breaker,
|
|
26882
|
+
lastSurfacedAtMs: nowMs
|
|
26883
|
+
});
|
|
26884
|
+
}
|
|
26885
|
+
const deadHint = "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>.";
|
|
26886
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
26887
|
+
return {
|
|
26888
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
26889
|
+
...globalHint ? {
|
|
26890
|
+
accessToken,
|
|
26891
|
+
refreshToken,
|
|
26892
|
+
baseUrl: credentials.UIPATH_URL,
|
|
26893
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
26894
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
26895
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
26896
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
26897
|
+
expiration,
|
|
26898
|
+
source: "file"
|
|
26899
|
+
} : {},
|
|
26900
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
26901
|
+
refreshCircuitOpen: true,
|
|
26902
|
+
refreshTelemetrySuppressed: suppressed,
|
|
26903
|
+
tokenRefresh: { attempted: false, success: false }
|
|
26904
|
+
};
|
|
26905
|
+
}
|
|
26906
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
26907
|
+
const msg = errorMessage(error);
|
|
26908
|
+
const globalHint = await ctx.globalHint();
|
|
26909
|
+
if (globalHint) {
|
|
26910
|
+
return {
|
|
26911
|
+
loginStatus: "Expired",
|
|
26912
|
+
accessToken: ctx.accessToken,
|
|
26913
|
+
refreshToken: ctx.refreshToken,
|
|
26914
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
26915
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
26916
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
26917
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
26918
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
26919
|
+
expiration: ctx.expiration,
|
|
26920
|
+
source: "file",
|
|
26921
|
+
hint: globalHint,
|
|
26922
|
+
tokenRefresh: {
|
|
26923
|
+
attempted: false,
|
|
26924
|
+
success: false,
|
|
26925
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
26926
|
+
}
|
|
26927
|
+
};
|
|
26928
|
+
}
|
|
26929
|
+
return {
|
|
26930
|
+
loginStatus: "Refresh Failed",
|
|
26931
|
+
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.",
|
|
26932
|
+
tokenRefresh: {
|
|
26933
|
+
attempted: false,
|
|
26934
|
+
success: false,
|
|
26935
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
26936
|
+
}
|
|
26937
|
+
};
|
|
26938
|
+
}
|
|
27779
26939
|
async function runRefreshLocked(inputs) {
|
|
27780
26940
|
const {
|
|
27781
26941
|
absolutePath,
|
|
@@ -27785,7 +26945,10 @@ async function runRefreshLocked(inputs) {
|
|
|
27785
26945
|
loadEnvFile,
|
|
27786
26946
|
saveEnvFile,
|
|
27787
26947
|
refreshFn,
|
|
27788
|
-
resolveConfig
|
|
26948
|
+
resolveConfig,
|
|
26949
|
+
loadBreaker,
|
|
26950
|
+
saveBreaker,
|
|
26951
|
+
clearBreaker
|
|
27789
26952
|
} = inputs;
|
|
27790
26953
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
27791
26954
|
let fresh;
|
|
@@ -27808,6 +26971,7 @@ async function runRefreshLocked(inputs) {
|
|
|
27808
26971
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
27809
26972
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
27810
26973
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
26974
|
+
await clearBreaker(absolutePath);
|
|
27811
26975
|
return {
|
|
27812
26976
|
kind: "ok",
|
|
27813
26977
|
accessToken: freshAccess,
|
|
@@ -27831,8 +26995,21 @@ async function runRefreshLocked(inputs) {
|
|
|
27831
26995
|
refreshedRefresh = refreshed.refreshToken;
|
|
27832
26996
|
} catch (error) {
|
|
27833
26997
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
27834
|
-
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.";
|
|
26998
|
+
const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
|
|
27835
26999
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
27000
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
27001
|
+
if (isOAuthFailure) {
|
|
27002
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
27003
|
+
} else {
|
|
27004
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
27005
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
27006
|
+
await saveBreaker(absolutePath, {
|
|
27007
|
+
...prior,
|
|
27008
|
+
deadTokenFp: undefined,
|
|
27009
|
+
attempts,
|
|
27010
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
27011
|
+
});
|
|
27012
|
+
}
|
|
27836
27013
|
return {
|
|
27837
27014
|
kind: "fail",
|
|
27838
27015
|
status: {
|
|
@@ -27861,6 +27038,7 @@ async function runRefreshLocked(inputs) {
|
|
|
27861
27038
|
}
|
|
27862
27039
|
};
|
|
27863
27040
|
}
|
|
27041
|
+
await clearBreaker(absolutePath);
|
|
27864
27042
|
try {
|
|
27865
27043
|
await saveEnvFile({
|
|
27866
27044
|
envPath: absolutePath,
|
|
@@ -27893,213 +27071,22 @@ async function runRefreshLocked(inputs) {
|
|
|
27893
27071
|
};
|
|
27894
27072
|
}
|
|
27895
27073
|
}
|
|
27896
|
-
|
|
27897
|
-
|
|
27898
|
-
|
|
27899
|
-
|
|
27900
|
-
|
|
27901
|
-
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
|
|
27905
|
-
} = deps;
|
|
27906
|
-
if (isRobotAuthEnforced()) {
|
|
27907
|
-
if (isEnvAuthEnabled()) {
|
|
27908
|
-
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
27909
|
-
}
|
|
27910
|
-
const robotCreds = await robotFallback({ force: true });
|
|
27911
|
-
if (!robotCreds) {
|
|
27912
|
-
return {
|
|
27913
|
-
loginStatus: "Not logged in",
|
|
27914
|
-
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.`
|
|
27915
|
-
};
|
|
27916
|
-
}
|
|
27917
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
27918
|
-
return {
|
|
27919
|
-
loginStatus: "Logged in",
|
|
27920
|
-
accessToken: robotCreds.accessToken,
|
|
27921
|
-
baseUrl: robotCreds.baseUrl,
|
|
27922
|
-
organizationName: robotCreds.organizationName,
|
|
27923
|
-
organizationId: robotCreds.organizationId,
|
|
27924
|
-
tenantName: robotCreds.tenantName,
|
|
27925
|
-
tenantId: robotCreds.tenantId,
|
|
27926
|
-
issuer: robotCreds.issuer,
|
|
27927
|
-
expiration: expiration2,
|
|
27928
|
-
source: "robot"
|
|
27929
|
-
};
|
|
27930
|
-
}
|
|
27931
|
-
if (isEnvAuthEnabled()) {
|
|
27932
|
-
return readAuthFromEnv();
|
|
27933
|
-
}
|
|
27934
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
27935
|
-
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
27936
|
-
if (absolutePath === undefined) {
|
|
27937
|
-
const robotCreds = await robotFallback();
|
|
27938
|
-
if (robotCreds) {
|
|
27939
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
27940
|
-
const status = {
|
|
27941
|
-
loginStatus: "Logged in",
|
|
27942
|
-
accessToken: robotCreds.accessToken,
|
|
27943
|
-
baseUrl: robotCreds.baseUrl,
|
|
27944
|
-
organizationName: robotCreds.organizationName,
|
|
27945
|
-
organizationId: robotCreds.organizationId,
|
|
27946
|
-
tenantName: robotCreds.tenantName,
|
|
27947
|
-
tenantId: robotCreds.tenantId,
|
|
27948
|
-
issuer: robotCreds.issuer,
|
|
27949
|
-
expiration: expiration2,
|
|
27950
|
-
source: "robot"
|
|
27951
|
-
};
|
|
27952
|
-
return status;
|
|
27953
|
-
}
|
|
27954
|
-
return { loginStatus: "Not logged in" };
|
|
27955
|
-
}
|
|
27956
|
-
let credentials;
|
|
27957
|
-
try {
|
|
27958
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
27959
|
-
} catch (error) {
|
|
27960
|
-
if (isFileNotFoundError(error)) {
|
|
27961
|
-
return { loginStatus: "Not logged in" };
|
|
27962
|
-
}
|
|
27963
|
-
throw error;
|
|
27964
|
-
}
|
|
27965
|
-
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
27966
|
-
return { loginStatus: "Not logged in" };
|
|
27967
|
-
}
|
|
27968
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
27969
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
27970
|
-
let expiration = getTokenExpiration(accessToken);
|
|
27971
|
-
let persistenceWarning;
|
|
27972
|
-
let lockReleaseFailed = false;
|
|
27973
|
-
let tokenRefresh;
|
|
27974
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
27975
|
-
const tryGlobalCredsHint = async () => {
|
|
27976
|
-
const fs72 = getFs();
|
|
27977
|
-
const globalPath = fs72.path.join(fs72.env.homedir(), envFilePath);
|
|
27978
|
-
if (absolutePath === globalPath)
|
|
27979
|
-
return;
|
|
27980
|
-
if (!await fs72.exists(globalPath))
|
|
27981
|
-
return;
|
|
27982
|
-
try {
|
|
27983
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
27984
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
27985
|
-
return;
|
|
27986
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
27987
|
-
if (globalExp && globalExp <= new Date)
|
|
27988
|
-
return;
|
|
27989
|
-
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.`;
|
|
27990
|
-
} catch {
|
|
27991
|
-
return;
|
|
27992
|
-
}
|
|
27993
|
-
};
|
|
27994
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
27995
|
-
let release;
|
|
27996
|
-
try {
|
|
27997
|
-
release = await getFs().acquireLock(absolutePath);
|
|
27998
|
-
} catch (error) {
|
|
27999
|
-
const msg = errorMessage(error);
|
|
28000
|
-
const globalHint = await tryGlobalCredsHint();
|
|
28001
|
-
if (globalHint) {
|
|
28002
|
-
return {
|
|
28003
|
-
loginStatus: "Expired",
|
|
28004
|
-
accessToken,
|
|
28005
|
-
refreshToken,
|
|
28006
|
-
baseUrl: credentials.UIPATH_URL,
|
|
28007
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
28008
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
28009
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
28010
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
28011
|
-
expiration,
|
|
28012
|
-
source: "file",
|
|
28013
|
-
hint: globalHint,
|
|
28014
|
-
tokenRefresh: {
|
|
28015
|
-
attempted: false,
|
|
28016
|
-
success: false,
|
|
28017
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
28018
|
-
}
|
|
28019
|
-
};
|
|
28020
|
-
}
|
|
28021
|
-
return {
|
|
28022
|
-
loginStatus: "Refresh Failed",
|
|
28023
|
-
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.",
|
|
28024
|
-
tokenRefresh: {
|
|
28025
|
-
attempted: false,
|
|
28026
|
-
success: false,
|
|
28027
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
28028
|
-
}
|
|
28029
|
-
};
|
|
28030
|
-
}
|
|
28031
|
-
let lockedFailure;
|
|
28032
|
-
try {
|
|
28033
|
-
const outcome = await runRefreshLocked({
|
|
28034
|
-
absolutePath,
|
|
28035
|
-
refreshToken,
|
|
28036
|
-
customAuthority: credentials.UIPATH_URL,
|
|
28037
|
-
ensureTokenValidityMinutes,
|
|
28038
|
-
loadEnvFile,
|
|
28039
|
-
saveEnvFile,
|
|
28040
|
-
refreshFn: refreshTokenFn,
|
|
28041
|
-
resolveConfig
|
|
28042
|
-
});
|
|
28043
|
-
if (outcome.kind === "fail") {
|
|
28044
|
-
lockedFailure = outcome.status;
|
|
28045
|
-
} else {
|
|
28046
|
-
accessToken = outcome.accessToken;
|
|
28047
|
-
refreshToken = outcome.refreshToken;
|
|
28048
|
-
expiration = outcome.expiration;
|
|
28049
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
28050
|
-
if (outcome.persistenceWarning) {
|
|
28051
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
28052
|
-
}
|
|
28053
|
-
}
|
|
28054
|
-
} finally {
|
|
28055
|
-
try {
|
|
28056
|
-
await release();
|
|
28057
|
-
} catch {
|
|
28058
|
-
lockReleaseFailed = true;
|
|
28059
|
-
}
|
|
28060
|
-
}
|
|
28061
|
-
if (lockedFailure) {
|
|
28062
|
-
const globalHint = await tryGlobalCredsHint();
|
|
28063
|
-
const base = globalHint ? {
|
|
28064
|
-
...lockedFailure,
|
|
28065
|
-
loginStatus: "Expired",
|
|
28066
|
-
hint: globalHint
|
|
28067
|
-
} : lockedFailure;
|
|
28068
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
28069
|
-
}
|
|
28070
|
-
}
|
|
28071
|
-
const result = {
|
|
28072
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
28073
|
-
accessToken,
|
|
28074
|
-
refreshToken,
|
|
28075
|
-
baseUrl: credentials.UIPATH_URL,
|
|
28076
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
28077
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
28078
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
28079
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
28080
|
-
expiration,
|
|
28081
|
-
source: "file",
|
|
28082
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
28083
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
28084
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
28085
|
-
};
|
|
28086
|
-
if (result.loginStatus === "Expired") {
|
|
28087
|
-
const globalHint = await tryGlobalCredsHint();
|
|
28088
|
-
if (globalHint) {
|
|
28089
|
-
result.hint = globalHint;
|
|
28090
|
-
}
|
|
28091
|
-
}
|
|
28092
|
-
return result;
|
|
28093
|
-
};
|
|
28094
|
-
var isFileNotFoundError = (error) => {
|
|
28095
|
-
if (!(error instanceof Object))
|
|
28096
|
-
return false;
|
|
28097
|
-
return error.code === "ENOENT";
|
|
28098
|
-
};
|
|
28099
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
28100
|
-
return getLoginStatusWithDeps(options);
|
|
28101
|
-
};
|
|
27074
|
+
function normalizeTokenRefreshFailure() {
|
|
27075
|
+
return "stored refresh token is invalid or expired";
|
|
27076
|
+
}
|
|
27077
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
27078
|
+
return "token refresh failed before authentication completed";
|
|
27079
|
+
}
|
|
27080
|
+
function errorMessage(error) {
|
|
27081
|
+
return error instanceof Error ? error.message : String(error);
|
|
27082
|
+
}
|
|
28102
27083
|
init_src();
|
|
27084
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
27085
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
27086
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
27087
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
27088
|
+
INVALID_TENANT_CODE
|
|
27089
|
+
]);
|
|
28103
27090
|
init_src();
|
|
28104
27091
|
init_server();
|
|
28105
27092
|
var SERVICE_PATH = {
|
|
@@ -29475,3 +28462,5 @@ export {
|
|
|
29475
28462
|
registerCommands,
|
|
29476
28463
|
metadata
|
|
29477
28464
|
};
|
|
28465
|
+
|
|
28466
|
+
//# debugId=DCEFC83A05FE4ADC64756E2164756E21
|