@uipath/aops-tool 1.196.0 → 1.197.0-preview.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -0
- package/dist/tool.js +808 -1873
- package/package.json +28 -37
- package/dist/index.js.map +0 -18
- package/dist/tool.js.map +0 -141
package/dist/tool.js
CHANGED
|
@@ -3030,7 +3030,7 @@ function isBrowser() {
|
|
|
3030
3030
|
|
|
3031
3031
|
// ../../node_modules/@uipath/coreipc/index.js
|
|
3032
3032
|
var require_coreipc = __commonJS((exports, module) => {
|
|
3033
|
-
var __dirname = "/
|
|
3033
|
+
var __dirname = "/home/runner/work/cli/cli/node_modules/@uipath/coreipc";
|
|
3034
3034
|
/*! For license information please see index.js.LICENSE.txt */
|
|
3035
3035
|
(function(e, t) {
|
|
3036
3036
|
typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.ipc = t() : e.ipc = t();
|
|
@@ -13520,8 +13520,8 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13520
13520
|
if (_parentOrParents instanceof Subscription2) {
|
|
13521
13521
|
_parentOrParents.remove(this);
|
|
13522
13522
|
} else if (_parentOrParents !== null) {
|
|
13523
|
-
for (var
|
|
13524
|
-
var parent_1 = _parentOrParents[
|
|
13523
|
+
for (var index = 0;index < _parentOrParents.length; ++index) {
|
|
13524
|
+
var parent_1 = _parentOrParents[index];
|
|
13525
13525
|
parent_1.remove(this);
|
|
13526
13526
|
}
|
|
13527
13527
|
}
|
|
@@ -13536,10 +13536,10 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13536
13536
|
}
|
|
13537
13537
|
}
|
|
13538
13538
|
if (isArray_1.isArray(_subscriptions)) {
|
|
13539
|
-
var
|
|
13539
|
+
var index = -1;
|
|
13540
13540
|
var len = _subscriptions.length;
|
|
13541
|
-
while (++
|
|
13542
|
-
var sub2 = _subscriptions[
|
|
13541
|
+
while (++index < len) {
|
|
13542
|
+
var sub2 = _subscriptions[index];
|
|
13543
13543
|
if (isObject_1.isObject(sub2)) {
|
|
13544
13544
|
try {
|
|
13545
13545
|
sub2.unsubscribe();
|
|
@@ -14969,13 +14969,13 @@ var require_AsyncAction = __commonJS((exports) => {
|
|
|
14969
14969
|
var id = this.id;
|
|
14970
14970
|
var scheduler = this.scheduler;
|
|
14971
14971
|
var actions = scheduler.actions;
|
|
14972
|
-
var
|
|
14972
|
+
var index = actions.indexOf(this);
|
|
14973
14973
|
this.work = null;
|
|
14974
14974
|
this.state = null;
|
|
14975
14975
|
this.pending = false;
|
|
14976
14976
|
this.scheduler = null;
|
|
14977
|
-
if (
|
|
14978
|
-
actions.splice(
|
|
14977
|
+
if (index !== -1) {
|
|
14978
|
+
actions.splice(index, 1);
|
|
14979
14979
|
}
|
|
14980
14980
|
if (id != null) {
|
|
14981
14981
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
@@ -15819,17 +15819,17 @@ var require_AsapScheduler = __commonJS((exports) => {
|
|
|
15819
15819
|
this.scheduled = undefined;
|
|
15820
15820
|
var actions = this.actions;
|
|
15821
15821
|
var error;
|
|
15822
|
-
var
|
|
15822
|
+
var index = -1;
|
|
15823
15823
|
var count = actions.length;
|
|
15824
15824
|
action = action || actions.shift();
|
|
15825
15825
|
do {
|
|
15826
15826
|
if (error = action.execute(action.state, action.delay)) {
|
|
15827
15827
|
break;
|
|
15828
15828
|
}
|
|
15829
|
-
} while (++
|
|
15829
|
+
} while (++index < count && (action = actions.shift()));
|
|
15830
15830
|
this.active = false;
|
|
15831
15831
|
if (error) {
|
|
15832
|
-
while (++
|
|
15832
|
+
while (++index < count && (action = actions.shift())) {
|
|
15833
15833
|
action.unsubscribe();
|
|
15834
15834
|
}
|
|
15835
15835
|
throw error;
|
|
@@ -15952,17 +15952,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
|
|
|
15952
15952
|
this.scheduled = undefined;
|
|
15953
15953
|
var actions = this.actions;
|
|
15954
15954
|
var error;
|
|
15955
|
-
var
|
|
15955
|
+
var index = -1;
|
|
15956
15956
|
var count = actions.length;
|
|
15957
15957
|
action = action || actions.shift();
|
|
15958
15958
|
do {
|
|
15959
15959
|
if (error = action.execute(action.state, action.delay)) {
|
|
15960
15960
|
break;
|
|
15961
15961
|
}
|
|
15962
|
-
} while (++
|
|
15962
|
+
} while (++index < count && (action = actions.shift()));
|
|
15963
15963
|
this.active = false;
|
|
15964
15964
|
if (error) {
|
|
15965
|
-
while (++
|
|
15965
|
+
while (++index < count && (action = actions.shift())) {
|
|
15966
15966
|
action.unsubscribe();
|
|
15967
15967
|
}
|
|
15968
15968
|
throw error;
|
|
@@ -16046,16 +16046,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
|
|
|
16046
16046
|
exports.VirtualTimeScheduler = VirtualTimeScheduler;
|
|
16047
16047
|
var VirtualAction = function(_super) {
|
|
16048
16048
|
__extends(VirtualAction2, _super);
|
|
16049
|
-
function VirtualAction2(scheduler, work,
|
|
16050
|
-
if (
|
|
16051
|
-
|
|
16049
|
+
function VirtualAction2(scheduler, work, index) {
|
|
16050
|
+
if (index === undefined) {
|
|
16051
|
+
index = scheduler.index += 1;
|
|
16052
16052
|
}
|
|
16053
16053
|
var _this = _super.call(this, scheduler, work) || this;
|
|
16054
16054
|
_this.scheduler = scheduler;
|
|
16055
16055
|
_this.work = work;
|
|
16056
|
-
_this.index =
|
|
16056
|
+
_this.index = index;
|
|
16057
16057
|
_this.active = true;
|
|
16058
|
-
_this.index = scheduler.index =
|
|
16058
|
+
_this.index = scheduler.index = index;
|
|
16059
16059
|
return _this;
|
|
16060
16060
|
}
|
|
16061
16061
|
VirtualAction2.prototype.schedule = function(state, delay) {
|
|
@@ -17202,9 +17202,9 @@ var require_mergeMap = __commonJS((exports) => {
|
|
|
17202
17202
|
};
|
|
17203
17203
|
MergeMapSubscriber2.prototype._tryNext = function(value) {
|
|
17204
17204
|
var result;
|
|
17205
|
-
var
|
|
17205
|
+
var index = this.index++;
|
|
17206
17206
|
try {
|
|
17207
|
-
result = this.project(value,
|
|
17207
|
+
result = this.project(value, index);
|
|
17208
17208
|
} catch (err) {
|
|
17209
17209
|
this.destination.error(err);
|
|
17210
17210
|
return;
|
|
@@ -17784,12 +17784,12 @@ var require_pairs2 = __commonJS((exports) => {
|
|
|
17784
17784
|
}
|
|
17785
17785
|
exports.pairs = pairs;
|
|
17786
17786
|
function dispatch(state) {
|
|
17787
|
-
var { keys, index
|
|
17787
|
+
var { keys, index, subscriber, subscription, obj } = state;
|
|
17788
17788
|
if (!subscriber.closed) {
|
|
17789
|
-
if (
|
|
17790
|
-
var key = keys[
|
|
17789
|
+
if (index < keys.length) {
|
|
17790
|
+
var key = keys[index];
|
|
17791
17791
|
subscriber.next([key, obj[key]]);
|
|
17792
|
-
subscription.add(this.schedule({ keys, index:
|
|
17792
|
+
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
|
17793
17793
|
} else {
|
|
17794
17794
|
subscriber.complete();
|
|
17795
17795
|
}
|
|
@@ -18002,18 +18002,18 @@ var require_range = __commonJS((exports) => {
|
|
|
18002
18002
|
count = start;
|
|
18003
18003
|
start = 0;
|
|
18004
18004
|
}
|
|
18005
|
-
var
|
|
18005
|
+
var index = 0;
|
|
18006
18006
|
var current = start;
|
|
18007
18007
|
if (scheduler) {
|
|
18008
18008
|
return scheduler.schedule(dispatch, 0, {
|
|
18009
|
-
index
|
|
18009
|
+
index,
|
|
18010
18010
|
count,
|
|
18011
18011
|
start,
|
|
18012
18012
|
subscriber
|
|
18013
18013
|
});
|
|
18014
18014
|
} else {
|
|
18015
18015
|
do {
|
|
18016
|
-
if (
|
|
18016
|
+
if (index++ >= count) {
|
|
18017
18017
|
subscriber.complete();
|
|
18018
18018
|
break;
|
|
18019
18019
|
}
|
|
@@ -18028,8 +18028,8 @@ var require_range = __commonJS((exports) => {
|
|
|
18028
18028
|
}
|
|
18029
18029
|
exports.range = range;
|
|
18030
18030
|
function dispatch(state) {
|
|
18031
|
-
var { start, index
|
|
18032
|
-
if (
|
|
18031
|
+
var { start, index, count, subscriber } = state;
|
|
18032
|
+
if (index >= count) {
|
|
18033
18033
|
subscriber.complete();
|
|
18034
18034
|
return;
|
|
18035
18035
|
}
|
|
@@ -18037,7 +18037,7 @@ var require_range = __commonJS((exports) => {
|
|
|
18037
18037
|
if (subscriber.closed) {
|
|
18038
18038
|
return;
|
|
18039
18039
|
}
|
|
18040
|
-
state.index =
|
|
18040
|
+
state.index = index + 1;
|
|
18041
18041
|
state.start = start + 1;
|
|
18042
18042
|
this.schedule(state);
|
|
18043
18043
|
}
|
|
@@ -18075,14 +18075,14 @@ var require_timer = __commonJS((exports) => {
|
|
|
18075
18075
|
}
|
|
18076
18076
|
exports.timer = timer;
|
|
18077
18077
|
function dispatch(state) {
|
|
18078
|
-
var { index
|
|
18079
|
-
subscriber.next(
|
|
18078
|
+
var { index, period, subscriber } = state;
|
|
18079
|
+
subscriber.next(index);
|
|
18080
18080
|
if (subscriber.closed) {
|
|
18081
18081
|
return;
|
|
18082
18082
|
} else if (period === -1) {
|
|
18083
18083
|
return subscriber.complete();
|
|
18084
18084
|
}
|
|
18085
|
-
state.index =
|
|
18085
|
+
state.index = index + 1;
|
|
18086
18086
|
this.schedule(state, period);
|
|
18087
18087
|
}
|
|
18088
18088
|
});
|
|
@@ -21230,7 +21230,7 @@ var init_server = __esm(() => {
|
|
|
21230
21230
|
var package_default = {
|
|
21231
21231
|
name: "@uipath/aops-tool",
|
|
21232
21232
|
license: "MIT",
|
|
21233
|
-
version: "1.
|
|
21233
|
+
version: "1.197.0-preview.60",
|
|
21234
21234
|
description: "Manage UiPath StudioAdmin AOps — connections, repos, projects, solutions, pipelines, executions.",
|
|
21235
21235
|
private: false,
|
|
21236
21236
|
repository: {
|
|
@@ -21359,6 +21359,13 @@ function describeConnectivityError(error) {
|
|
|
21359
21359
|
}
|
|
21360
21360
|
return;
|
|
21361
21361
|
}
|
|
21362
|
+
function parseHttpStatusFromMessage(message) {
|
|
21363
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
21364
|
+
if (!match)
|
|
21365
|
+
return;
|
|
21366
|
+
const status = Number(match[1]);
|
|
21367
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
21368
|
+
}
|
|
21362
21369
|
function isHtmlDocument(body) {
|
|
21363
21370
|
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
21364
21371
|
}
|
|
@@ -21411,10 +21418,19 @@ function classifyError(status, error) {
|
|
|
21411
21418
|
}
|
|
21412
21419
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
21413
21420
|
}
|
|
21421
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
21422
|
+
if (extractedMessage) {
|
|
21423
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
21424
|
+
}
|
|
21425
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
21426
|
+
}
|
|
21414
21427
|
async function extractErrorDetails(error, options) {
|
|
21415
21428
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
21416
21429
|
const response = err.response;
|
|
21417
|
-
const
|
|
21430
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21431
|
+
const explicitStatus = err.status ?? response?.status;
|
|
21432
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
21433
|
+
const status = explicitStatus ?? inferredStatus;
|
|
21418
21434
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
21419
21435
|
let rawBody;
|
|
21420
21436
|
let extractedMessage;
|
|
@@ -21449,7 +21465,6 @@ async function extractErrorDetails(error, options) {
|
|
|
21449
21465
|
}
|
|
21450
21466
|
}
|
|
21451
21467
|
}
|
|
21452
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21453
21468
|
let message;
|
|
21454
21469
|
let result = "Failure";
|
|
21455
21470
|
const classification = classifyError(status, error);
|
|
@@ -21463,10 +21478,10 @@ async function extractErrorDetails(error, options) {
|
|
|
21463
21478
|
} else if (status === 405) {
|
|
21464
21479
|
message = DEFAULT_405;
|
|
21465
21480
|
} else if (status === 400 || status === 422) {
|
|
21466
|
-
message =
|
|
21481
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21467
21482
|
result = "ValidationError";
|
|
21468
21483
|
} else if (status === 429) {
|
|
21469
|
-
message =
|
|
21484
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21470
21485
|
} else if (extractedMessage) {
|
|
21471
21486
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
21472
21487
|
message = rawMessage;
|
|
@@ -21474,7 +21489,9 @@ async function extractErrorDetails(error, options) {
|
|
|
21474
21489
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
21475
21490
|
}
|
|
21476
21491
|
} else if (status) {
|
|
21477
|
-
if (
|
|
21492
|
+
if (inferredStatus !== undefined) {
|
|
21493
|
+
message = rawMessage;
|
|
21494
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
21478
21495
|
const statusText = response.statusText;
|
|
21479
21496
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
21480
21497
|
} else {
|
|
@@ -21656,6 +21673,7 @@ var CONSOLE_FALLBACK = {
|
|
|
21656
21673
|
writeLog: (str) => process.stdout.write(str),
|
|
21657
21674
|
capabilities: {
|
|
21658
21675
|
isInteractive: false,
|
|
21676
|
+
canReadInput: false,
|
|
21659
21677
|
supportsColor: false,
|
|
21660
21678
|
outputWidth: 80
|
|
21661
21679
|
}
|
|
@@ -26856,6 +26874,29 @@ function isPlainRecord(value) {
|
|
|
26856
26874
|
const prototype = Object.getPrototypeOf(value);
|
|
26857
26875
|
return prototype === Object.prototype || prototype === null;
|
|
26858
26876
|
}
|
|
26877
|
+
function extractPagedRows(value) {
|
|
26878
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
26879
|
+
return null;
|
|
26880
|
+
const entries = Object.values(value);
|
|
26881
|
+
if (entries.length === 0)
|
|
26882
|
+
return null;
|
|
26883
|
+
let rows = null;
|
|
26884
|
+
let hasScalarSibling = false;
|
|
26885
|
+
for (const entry of entries) {
|
|
26886
|
+
if (Array.isArray(entry)) {
|
|
26887
|
+
if (rows !== null)
|
|
26888
|
+
return null;
|
|
26889
|
+
rows = entry;
|
|
26890
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
26891
|
+
return null;
|
|
26892
|
+
} else {
|
|
26893
|
+
hasScalarSibling = true;
|
|
26894
|
+
}
|
|
26895
|
+
}
|
|
26896
|
+
if (rows === null || !hasScalarSibling)
|
|
26897
|
+
return null;
|
|
26898
|
+
return rows;
|
|
26899
|
+
}
|
|
26859
26900
|
function toLowerCamelCaseKey(key) {
|
|
26860
26901
|
if (!key)
|
|
26861
26902
|
return key;
|
|
@@ -26920,7 +26961,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26920
26961
|
break;
|
|
26921
26962
|
case "plain": {
|
|
26922
26963
|
if ("Data" in data && data.Data != null) {
|
|
26923
|
-
const
|
|
26964
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
26965
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
26924
26966
|
items.forEach((item) => {
|
|
26925
26967
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
26926
26968
|
logFn(values);
|
|
@@ -26932,10 +26974,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26932
26974
|
break;
|
|
26933
26975
|
}
|
|
26934
26976
|
default: {
|
|
26935
|
-
|
|
26977
|
+
const hasData = "Data" in data && data.Data != null;
|
|
26978
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
26979
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
26980
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
26936
26981
|
const logValue = data.Log;
|
|
26937
|
-
if (
|
|
26938
|
-
printResizableTable(
|
|
26982
|
+
if (rows !== null) {
|
|
26983
|
+
printResizableTable(rows, logFn, logValue);
|
|
26939
26984
|
} else {
|
|
26940
26985
|
printVerticalTable(data.Data, logFn, logValue);
|
|
26941
26986
|
}
|
|
@@ -27123,6 +27168,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
27123
27168
|
return "unknown_error";
|
|
27124
27169
|
}
|
|
27125
27170
|
}
|
|
27171
|
+
function parseHttpStatusFromMessage2(message) {
|
|
27172
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
27173
|
+
if (!match)
|
|
27174
|
+
return;
|
|
27175
|
+
const status = Number(match[1]);
|
|
27176
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
27177
|
+
}
|
|
27178
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
27179
|
+
if (status === undefined)
|
|
27180
|
+
return;
|
|
27181
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
27182
|
+
return "invalid_argument";
|
|
27183
|
+
}
|
|
27184
|
+
if (status === 401)
|
|
27185
|
+
return "authentication_required";
|
|
27186
|
+
if (status === 403)
|
|
27187
|
+
return "permission_denied";
|
|
27188
|
+
if (status === 404)
|
|
27189
|
+
return "not_found";
|
|
27190
|
+
if (status === 405)
|
|
27191
|
+
return "method_not_allowed";
|
|
27192
|
+
if (status === 408)
|
|
27193
|
+
return "timeout";
|
|
27194
|
+
if (status === 429)
|
|
27195
|
+
return "rate_limited";
|
|
27196
|
+
if (status >= 500 && status < 600)
|
|
27197
|
+
return "server_error";
|
|
27198
|
+
return;
|
|
27199
|
+
}
|
|
27200
|
+
function defaultErrorCodeForFailure(data) {
|
|
27201
|
+
if (data.Result === RESULTS.Failure) {
|
|
27202
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
27203
|
+
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
27204
|
+
if (errorCode)
|
|
27205
|
+
return errorCode;
|
|
27206
|
+
}
|
|
27207
|
+
return defaultErrorCodeForResult(data.Result);
|
|
27208
|
+
}
|
|
27126
27209
|
function defaultRetryForErrorCode(errorCode) {
|
|
27127
27210
|
switch (errorCode) {
|
|
27128
27211
|
case "network_error":
|
|
@@ -27152,16 +27235,19 @@ var OutputFormatter;
|
|
|
27152
27235
|
OutputFormatter.success = success;
|
|
27153
27236
|
function error(data) {
|
|
27154
27237
|
data.Log ??= getLogFilePath() || undefined;
|
|
27155
|
-
data.ErrorCode ??=
|
|
27238
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
27156
27239
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
27157
27240
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
27158
|
-
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27241
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
27242
|
+
if (!SuppressTelemetry) {
|
|
27243
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
27244
|
+
result: data.Result,
|
|
27245
|
+
errorCode: data.ErrorCode,
|
|
27246
|
+
retry: data.Retry,
|
|
27247
|
+
message: data.Message
|
|
27248
|
+
});
|
|
27249
|
+
}
|
|
27250
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
27165
27251
|
}
|
|
27166
27252
|
OutputFormatter.error = error;
|
|
27167
27253
|
function emitList(code, items, opts) {
|
|
@@ -27465,1571 +27551,168 @@ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
|
27465
27551
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27466
27552
|
// ../common/src/interactivity-context.ts
|
|
27467
27553
|
var modeSlot = singleton("InteractivityMode");
|
|
27468
|
-
//
|
|
27469
|
-
|
|
27470
|
-
|
|
27471
|
-
|
|
27472
|
-
|
|
27473
|
-
|
|
27474
|
-
|
|
27475
|
-
|
|
27554
|
+
// ../common/src/option-aliases.ts
|
|
27555
|
+
function resolveDeprecatedOptionAlias({
|
|
27556
|
+
preferredValue,
|
|
27557
|
+
deprecatedValue,
|
|
27558
|
+
preferredFlag,
|
|
27559
|
+
deprecatedFlag
|
|
27560
|
+
}) {
|
|
27561
|
+
const hasPreferred = preferredValue !== undefined;
|
|
27562
|
+
const hasDeprecated = deprecatedValue !== undefined;
|
|
27563
|
+
if (hasPreferred && hasDeprecated) {
|
|
27564
|
+
return {
|
|
27565
|
+
value: undefined,
|
|
27566
|
+
usedDeprecated: true,
|
|
27567
|
+
error: {
|
|
27568
|
+
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
27569
|
+
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
27476
27570
|
}
|
|
27477
|
-
}
|
|
27478
|
-
(Array.isArray(name) ? name : [name]).forEach(function(name2) {
|
|
27479
|
-
this[name2] = this[name2] || [];
|
|
27480
|
-
if (callback) {
|
|
27481
|
-
this[name2][first ? "unshift" : "push"](callback);
|
|
27482
|
-
}
|
|
27483
|
-
}, this);
|
|
27484
|
-
}
|
|
27485
|
-
}
|
|
27486
|
-
run(name, env) {
|
|
27487
|
-
this[name] = this[name] || [];
|
|
27488
|
-
this[name].forEach(function(callback) {
|
|
27489
|
-
callback.call(env && env.context ? env.context : env, env);
|
|
27490
|
-
});
|
|
27571
|
+
};
|
|
27491
27572
|
}
|
|
27573
|
+
return {
|
|
27574
|
+
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
27575
|
+
usedDeprecated: hasDeprecated
|
|
27576
|
+
};
|
|
27492
27577
|
}
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
this.jsep = jsep;
|
|
27497
|
-
this.registered = {};
|
|
27498
|
-
}
|
|
27499
|
-
register(...plugins) {
|
|
27500
|
-
plugins.forEach((plugin) => {
|
|
27501
|
-
if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
|
|
27502
|
-
throw new Error("Invalid JSEP plugin format");
|
|
27503
|
-
}
|
|
27504
|
-
if (this.registered[plugin.name]) {
|
|
27505
|
-
return;
|
|
27506
|
-
}
|
|
27507
|
-
plugin.init(this.jsep);
|
|
27508
|
-
this.registered[plugin.name] = plugin;
|
|
27509
|
-
});
|
|
27510
|
-
}
|
|
27578
|
+
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
27579
|
+
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
27580
|
+
`);
|
|
27511
27581
|
}
|
|
27512
|
-
|
|
27513
|
-
|
|
27514
|
-
|
|
27515
|
-
|
|
27516
|
-
|
|
27517
|
-
static toString() {
|
|
27518
|
-
return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
|
|
27519
|
-
}
|
|
27520
|
-
static addUnaryOp(op_name) {
|
|
27521
|
-
Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
|
|
27522
|
-
Jsep.unary_ops[op_name] = 1;
|
|
27523
|
-
return Jsep;
|
|
27524
|
-
}
|
|
27525
|
-
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
27526
|
-
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
27527
|
-
Jsep.binary_ops[op_name] = precedence;
|
|
27528
|
-
if (isRightAssociative) {
|
|
27529
|
-
Jsep.right_associative.add(op_name);
|
|
27530
|
-
} else {
|
|
27531
|
-
Jsep.right_associative.delete(op_name);
|
|
27532
|
-
}
|
|
27533
|
-
return Jsep;
|
|
27534
|
-
}
|
|
27535
|
-
static addIdentifierChar(char) {
|
|
27536
|
-
Jsep.additional_identifier_chars.add(char);
|
|
27537
|
-
return Jsep;
|
|
27538
|
-
}
|
|
27539
|
-
static addLiteral(literal_name, literal_value) {
|
|
27540
|
-
Jsep.literals[literal_name] = literal_value;
|
|
27541
|
-
return Jsep;
|
|
27542
|
-
}
|
|
27543
|
-
static removeUnaryOp(op_name) {
|
|
27544
|
-
delete Jsep.unary_ops[op_name];
|
|
27545
|
-
if (op_name.length === Jsep.max_unop_len) {
|
|
27546
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
27547
|
-
}
|
|
27548
|
-
return Jsep;
|
|
27549
|
-
}
|
|
27550
|
-
static removeAllUnaryOps() {
|
|
27551
|
-
Jsep.unary_ops = {};
|
|
27552
|
-
Jsep.max_unop_len = 0;
|
|
27553
|
-
return Jsep;
|
|
27554
|
-
}
|
|
27555
|
-
static removeIdentifierChar(char) {
|
|
27556
|
-
Jsep.additional_identifier_chars.delete(char);
|
|
27557
|
-
return Jsep;
|
|
27558
|
-
}
|
|
27559
|
-
static removeBinaryOp(op_name) {
|
|
27560
|
-
delete Jsep.binary_ops[op_name];
|
|
27561
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
27562
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
27563
|
-
}
|
|
27564
|
-
Jsep.right_associative.delete(op_name);
|
|
27565
|
-
return Jsep;
|
|
27566
|
-
}
|
|
27567
|
-
static removeAllBinaryOps() {
|
|
27568
|
-
Jsep.binary_ops = {};
|
|
27569
|
-
Jsep.max_binop_len = 0;
|
|
27570
|
-
return Jsep;
|
|
27571
|
-
}
|
|
27572
|
-
static removeLiteral(literal_name) {
|
|
27573
|
-
delete Jsep.literals[literal_name];
|
|
27574
|
-
return Jsep;
|
|
27575
|
-
}
|
|
27576
|
-
static removeAllLiterals() {
|
|
27577
|
-
Jsep.literals = {};
|
|
27578
|
-
return Jsep;
|
|
27579
|
-
}
|
|
27580
|
-
get char() {
|
|
27581
|
-
return this.expr.charAt(this.index);
|
|
27582
|
-
}
|
|
27583
|
-
get code() {
|
|
27584
|
-
return this.expr.charCodeAt(this.index);
|
|
27585
|
-
}
|
|
27586
|
-
constructor(expr) {
|
|
27587
|
-
this.expr = expr;
|
|
27588
|
-
this.index = 0;
|
|
27589
|
-
}
|
|
27590
|
-
static parse(expr) {
|
|
27591
|
-
return new Jsep(expr).parse();
|
|
27592
|
-
}
|
|
27593
|
-
static getMaxKeyLen(obj) {
|
|
27594
|
-
return Math.max(0, ...Object.keys(obj).map((k) => k.length));
|
|
27595
|
-
}
|
|
27596
|
-
static isDecimalDigit(ch) {
|
|
27597
|
-
return ch >= 48 && ch <= 57;
|
|
27598
|
-
}
|
|
27599
|
-
static binaryPrecedence(op_val) {
|
|
27600
|
-
return Jsep.binary_ops[op_val] || 0;
|
|
27601
|
-
}
|
|
27602
|
-
static isIdentifierStart(ch) {
|
|
27603
|
-
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));
|
|
27604
|
-
}
|
|
27605
|
-
static isIdentifierPart(ch) {
|
|
27606
|
-
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
27607
|
-
}
|
|
27608
|
-
throwError(message) {
|
|
27609
|
-
const error = new Error(message + " at character " + this.index);
|
|
27610
|
-
error.index = this.index;
|
|
27611
|
-
error.description = message;
|
|
27612
|
-
throw error;
|
|
27582
|
+
// ../common/src/option-validators.ts
|
|
27583
|
+
function parseBoundedInt(raw, optionName, bounds) {
|
|
27584
|
+
const normalized = raw.trim();
|
|
27585
|
+
if (normalized === "") {
|
|
27586
|
+
throw new InvalidArgumentError(`${optionName} requires a value (got empty).`);
|
|
27613
27587
|
}
|
|
27614
|
-
|
|
27615
|
-
|
|
27616
|
-
const env = {
|
|
27617
|
-
context: this,
|
|
27618
|
-
node
|
|
27619
|
-
};
|
|
27620
|
-
Jsep.hooks.run(name, env);
|
|
27621
|
-
return env.node;
|
|
27622
|
-
}
|
|
27623
|
-
return node;
|
|
27588
|
+
if (!/^-?\d+$/.test(normalized)) {
|
|
27589
|
+
throw new InvalidArgumentError(`${optionName} must be an integer, got '${normalized}'.`);
|
|
27624
27590
|
}
|
|
27625
|
-
|
|
27626
|
-
|
|
27627
|
-
|
|
27628
|
-
context: this
|
|
27629
|
-
};
|
|
27630
|
-
Jsep.hooks[name].find(function(callback) {
|
|
27631
|
-
callback.call(env.context, env);
|
|
27632
|
-
return env.node;
|
|
27633
|
-
});
|
|
27634
|
-
return env.node;
|
|
27635
|
-
}
|
|
27591
|
+
const n = parseInt(normalized, 10);
|
|
27592
|
+
if (n < bounds.min || n > bounds.max) {
|
|
27593
|
+
throw new InvalidArgumentError(`${optionName} must be between ${bounds.min} and ${bounds.max}, got ${n}.`);
|
|
27636
27594
|
}
|
|
27637
|
-
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27595
|
+
return n;
|
|
27596
|
+
}
|
|
27597
|
+
// ../common/src/polling/format-utils.ts
|
|
27598
|
+
function msToDuration(ms) {
|
|
27599
|
+
if (!Number.isFinite(ms) || ms < 0) {
|
|
27600
|
+
return "00:00:00";
|
|
27643
27601
|
}
|
|
27644
|
-
|
|
27645
|
-
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
|
|
27602
|
+
const totalSec = Math.floor(ms / 1000);
|
|
27603
|
+
const h = Math.floor(totalSec / 3600);
|
|
27604
|
+
const m = Math.floor(totalSec % 3600 / 60);
|
|
27605
|
+
const s = totalSec % 60;
|
|
27606
|
+
return [h, m, s].map((v) => String(v).padStart(2, "0")).join(":");
|
|
27607
|
+
}
|
|
27608
|
+
// ../common/src/polling/types.ts
|
|
27609
|
+
var PollOutcome = {
|
|
27610
|
+
Completed: "completed",
|
|
27611
|
+
Timeout: "timeout",
|
|
27612
|
+
Interrupted: "interrupted",
|
|
27613
|
+
Aborted: "aborted",
|
|
27614
|
+
Failed: "failed"
|
|
27615
|
+
};
|
|
27616
|
+
var ErrorDecision = {
|
|
27617
|
+
Abort: "abort"
|
|
27618
|
+
};
|
|
27619
|
+
var POLL_DEFAULTS = {
|
|
27620
|
+
intervalMs: 5000,
|
|
27621
|
+
timeoutMs: 1800000,
|
|
27622
|
+
maxConsecutiveErrors: 3,
|
|
27623
|
+
logIntervalMs: 30000,
|
|
27624
|
+
logPrefix: "wait"
|
|
27625
|
+
};
|
|
27626
|
+
var BACKOFF_DEFAULTS = {
|
|
27627
|
+
initialMs: 1000,
|
|
27628
|
+
multiplier: 2,
|
|
27629
|
+
maxMs: 30000,
|
|
27630
|
+
jitter: 0.5
|
|
27631
|
+
};
|
|
27632
|
+
var MIN_INTERVAL_MS = 100;
|
|
27633
|
+
|
|
27634
|
+
// ../common/src/polling/poll-failure-mapping.ts
|
|
27635
|
+
var REASON_BY_OUTCOME = {
|
|
27636
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
27637
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
27638
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
27639
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
27640
|
+
};
|
|
27641
|
+
// ../common/src/polling/poll-until.ts
|
|
27642
|
+
function resolveIntervalFn(options) {
|
|
27643
|
+
if (typeof options.intervalMs === "function") {
|
|
27644
|
+
return options.intervalMs;
|
|
27652
27645
|
}
|
|
27653
|
-
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27657
|
-
|
|
27658
|
-
|
|
27659
|
-
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
|
|
27664
|
-
|
|
27665
|
-
|
|
27666
|
-
|
|
27667
|
-
|
|
27668
|
-
|
|
27646
|
+
const staticInterval = options.intervalMs ?? POLL_DEFAULTS.intervalMs;
|
|
27647
|
+
return () => staticInterval;
|
|
27648
|
+
}
|
|
27649
|
+
function resolveBackoffFn(options) {
|
|
27650
|
+
if (!options.backoff)
|
|
27651
|
+
return;
|
|
27652
|
+
const config = options.backoff === true ? { ...BACKOFF_DEFAULTS } : {
|
|
27653
|
+
initialMs: options.backoff.initialMs ?? BACKOFF_DEFAULTS.initialMs,
|
|
27654
|
+
multiplier: options.backoff.multiplier ?? BACKOFF_DEFAULTS.multiplier,
|
|
27655
|
+
maxMs: options.backoff.maxMs ?? BACKOFF_DEFAULTS.maxMs,
|
|
27656
|
+
jitter: Math.min(1, Math.max(0, options.backoff.jitter ?? BACKOFF_DEFAULTS.jitter))
|
|
27657
|
+
};
|
|
27658
|
+
return (errorCount) => {
|
|
27659
|
+
const exponent = Math.min(errorCount - 1, 30);
|
|
27660
|
+
const raw = Math.min(config.initialMs * config.multiplier ** exponent, config.maxMs);
|
|
27661
|
+
if (config.jitter > 0) {
|
|
27662
|
+
const jitterAmount = raw * config.jitter;
|
|
27663
|
+
return raw - jitterAmount * Math.random();
|
|
27669
27664
|
}
|
|
27670
|
-
return
|
|
27671
|
-
}
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
gobbleBinaryOp() {
|
|
27678
|
-
this.gobbleSpaces();
|
|
27679
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
27680
|
-
let tc_len = to_check.length;
|
|
27681
|
-
while (tc_len > 0) {
|
|
27682
|
-
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)))) {
|
|
27683
|
-
this.index += tc_len;
|
|
27684
|
-
return to_check;
|
|
27685
|
-
}
|
|
27686
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27665
|
+
return raw;
|
|
27666
|
+
};
|
|
27667
|
+
}
|
|
27668
|
+
function clampInterval(raw, label, prefix) {
|
|
27669
|
+
if (!Number.isFinite(raw) || Number.isNaN(raw)) {
|
|
27670
|
+
if (label) {
|
|
27671
|
+
logger.warn(`[${prefix}] ${label} — intervalMs returned ${raw}, falling back to ${POLL_DEFAULTS.intervalMs}ms`);
|
|
27687
27672
|
}
|
|
27688
|
-
return
|
|
27673
|
+
return POLL_DEFAULTS.intervalMs;
|
|
27689
27674
|
}
|
|
27690
|
-
|
|
27691
|
-
|
|
27692
|
-
|
|
27693
|
-
if (!left) {
|
|
27694
|
-
return left;
|
|
27695
|
-
}
|
|
27696
|
-
biop = this.gobbleBinaryOp();
|
|
27697
|
-
if (!biop) {
|
|
27698
|
-
return left;
|
|
27699
|
-
}
|
|
27700
|
-
biop_info = {
|
|
27701
|
-
value: biop,
|
|
27702
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
27703
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27704
|
-
};
|
|
27705
|
-
right = this.gobbleToken();
|
|
27706
|
-
if (!right) {
|
|
27707
|
-
this.throwError("Expected expression after " + biop);
|
|
27708
|
-
}
|
|
27709
|
-
stack = [left, biop_info, right];
|
|
27710
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
27711
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
27712
|
-
if (prec === 0) {
|
|
27713
|
-
this.index -= biop.length;
|
|
27714
|
-
break;
|
|
27715
|
-
}
|
|
27716
|
-
biop_info = {
|
|
27717
|
-
value: biop,
|
|
27718
|
-
prec,
|
|
27719
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27720
|
-
};
|
|
27721
|
-
cur_biop = biop;
|
|
27722
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
27723
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
27724
|
-
right = stack.pop();
|
|
27725
|
-
biop = stack.pop().value;
|
|
27726
|
-
left = stack.pop();
|
|
27727
|
-
node = {
|
|
27728
|
-
type: Jsep.BINARY_EXP,
|
|
27729
|
-
operator: biop,
|
|
27730
|
-
left,
|
|
27731
|
-
right
|
|
27732
|
-
};
|
|
27733
|
-
stack.push(node);
|
|
27734
|
-
}
|
|
27735
|
-
node = this.gobbleToken();
|
|
27736
|
-
if (!node) {
|
|
27737
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
27738
|
-
}
|
|
27739
|
-
stack.push(biop_info, node);
|
|
27740
|
-
}
|
|
27741
|
-
i = stack.length - 1;
|
|
27742
|
-
node = stack[i];
|
|
27743
|
-
while (i > 1) {
|
|
27744
|
-
node = {
|
|
27745
|
-
type: Jsep.BINARY_EXP,
|
|
27746
|
-
operator: stack[i - 1].value,
|
|
27747
|
-
left: stack[i - 2],
|
|
27748
|
-
right: node
|
|
27749
|
-
};
|
|
27750
|
-
i -= 2;
|
|
27751
|
-
}
|
|
27752
|
-
return node;
|
|
27753
|
-
}
|
|
27754
|
-
gobbleToken() {
|
|
27755
|
-
let ch, to_check, tc_len, node;
|
|
27756
|
-
this.gobbleSpaces();
|
|
27757
|
-
node = this.searchHook("gobble-token");
|
|
27758
|
-
if (node) {
|
|
27759
|
-
return this.runHook("after-token", node);
|
|
27760
|
-
}
|
|
27761
|
-
ch = this.code;
|
|
27762
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
27763
|
-
return this.gobbleNumericLiteral();
|
|
27764
|
-
}
|
|
27765
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
27766
|
-
node = this.gobbleStringLiteral();
|
|
27767
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
27768
|
-
node = this.gobbleArray();
|
|
27769
|
-
} else {
|
|
27770
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
27771
|
-
tc_len = to_check.length;
|
|
27772
|
-
while (tc_len > 0) {
|
|
27773
|
-
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)))) {
|
|
27774
|
-
this.index += tc_len;
|
|
27775
|
-
const argument = this.gobbleToken();
|
|
27776
|
-
if (!argument) {
|
|
27777
|
-
this.throwError("missing unaryOp argument");
|
|
27778
|
-
}
|
|
27779
|
-
return this.runHook("after-token", {
|
|
27780
|
-
type: Jsep.UNARY_EXP,
|
|
27781
|
-
operator: to_check,
|
|
27782
|
-
argument,
|
|
27783
|
-
prefix: true
|
|
27784
|
-
});
|
|
27785
|
-
}
|
|
27786
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27787
|
-
}
|
|
27788
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27789
|
-
node = this.gobbleIdentifier();
|
|
27790
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
27791
|
-
node = {
|
|
27792
|
-
type: Jsep.LITERAL,
|
|
27793
|
-
value: Jsep.literals[node.name],
|
|
27794
|
-
raw: node.name
|
|
27795
|
-
};
|
|
27796
|
-
} else if (node.name === Jsep.this_str) {
|
|
27797
|
-
node = {
|
|
27798
|
-
type: Jsep.THIS_EXP
|
|
27799
|
-
};
|
|
27800
|
-
}
|
|
27801
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27802
|
-
node = this.gobbleGroup();
|
|
27803
|
-
}
|
|
27804
|
-
}
|
|
27805
|
-
if (!node) {
|
|
27806
|
-
return this.runHook("after-token", false);
|
|
27675
|
+
if (raw < MIN_INTERVAL_MS) {
|
|
27676
|
+
if (label) {
|
|
27677
|
+
logger.warn(`[${prefix}] ${label} — intervalMs ${raw}ms clamped to minimum ${MIN_INTERVAL_MS}ms`);
|
|
27807
27678
|
}
|
|
27808
|
-
|
|
27809
|
-
return this.runHook("after-token", node);
|
|
27679
|
+
return MIN_INTERVAL_MS;
|
|
27810
27680
|
}
|
|
27811
|
-
|
|
27812
|
-
|
|
27813
|
-
|
|
27814
|
-
|
|
27815
|
-
|
|
27816
|
-
|
|
27817
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
27818
|
-
break;
|
|
27819
|
-
}
|
|
27820
|
-
optional = true;
|
|
27821
|
-
this.index += 2;
|
|
27822
|
-
this.gobbleSpaces();
|
|
27823
|
-
ch = this.code;
|
|
27824
|
-
}
|
|
27825
|
-
this.index++;
|
|
27826
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
27827
|
-
node = {
|
|
27828
|
-
type: Jsep.MEMBER_EXP,
|
|
27829
|
-
computed: true,
|
|
27830
|
-
object: node,
|
|
27831
|
-
property: this.gobbleExpression()
|
|
27832
|
-
};
|
|
27833
|
-
if (!node.property) {
|
|
27834
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
27835
|
-
}
|
|
27836
|
-
this.gobbleSpaces();
|
|
27837
|
-
ch = this.code;
|
|
27838
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
27839
|
-
this.throwError("Unclosed [");
|
|
27840
|
-
}
|
|
27841
|
-
this.index++;
|
|
27842
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27843
|
-
node = {
|
|
27844
|
-
type: Jsep.CALL_EXP,
|
|
27845
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
27846
|
-
callee: node
|
|
27847
|
-
};
|
|
27848
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
27849
|
-
if (optional) {
|
|
27850
|
-
this.index--;
|
|
27851
|
-
}
|
|
27852
|
-
this.gobbleSpaces();
|
|
27853
|
-
node = {
|
|
27854
|
-
type: Jsep.MEMBER_EXP,
|
|
27855
|
-
computed: false,
|
|
27856
|
-
object: node,
|
|
27857
|
-
property: this.gobbleIdentifier()
|
|
27858
|
-
};
|
|
27859
|
-
}
|
|
27860
|
-
if (optional) {
|
|
27861
|
-
node.optional = true;
|
|
27862
|
-
}
|
|
27863
|
-
this.gobbleSpaces();
|
|
27864
|
-
ch = this.code;
|
|
27865
|
-
}
|
|
27866
|
-
return node;
|
|
27681
|
+
return raw;
|
|
27682
|
+
}
|
|
27683
|
+
function abortError(signal) {
|
|
27684
|
+
const reason = signal.reason;
|
|
27685
|
+
if (reason instanceof Error && reason.name === "AbortError") {
|
|
27686
|
+
return reason;
|
|
27867
27687
|
}
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27688
|
+
const msg = reason instanceof Error ? reason.message : typeof reason === "string" || typeof reason === "number" ? String(reason) : "Aborted";
|
|
27689
|
+
const err = new Error(msg);
|
|
27690
|
+
err.name = "AbortError";
|
|
27691
|
+
return err;
|
|
27692
|
+
}
|
|
27693
|
+
function interruptibleSleep(ms, signal) {
|
|
27694
|
+
return new Promise((resolve2, reject) => {
|
|
27695
|
+
if (signal?.aborted) {
|
|
27696
|
+
reject(abortError(signal));
|
|
27697
|
+
return;
|
|
27872
27698
|
}
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
27876
|
-
|
|
27699
|
+
let onAbort;
|
|
27700
|
+
const cleanup = () => {
|
|
27701
|
+
if (onAbort) {
|
|
27702
|
+
signal?.removeEventListener("abort", onAbort);
|
|
27877
27703
|
}
|
|
27878
|
-
}
|
|
27879
|
-
|
|
27880
|
-
|
|
27881
|
-
|
|
27882
|
-
|
|
27883
|
-
|
|
27884
|
-
|
|
27885
|
-
|
|
27886
|
-
|
|
27887
|
-
|
|
27888
|
-
}
|
|
27889
|
-
|
|
27890
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
27891
|
-
}
|
|
27892
|
-
}
|
|
27893
|
-
chCode = this.code;
|
|
27894
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
27895
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
27896
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
27897
|
-
this.throwError("Unexpected period");
|
|
27898
|
-
}
|
|
27899
|
-
return {
|
|
27900
|
-
type: Jsep.LITERAL,
|
|
27901
|
-
value: parseFloat(number),
|
|
27902
|
-
raw: number
|
|
27903
|
-
};
|
|
27904
|
-
}
|
|
27905
|
-
gobbleStringLiteral() {
|
|
27906
|
-
let str = "";
|
|
27907
|
-
const startIndex = this.index;
|
|
27908
|
-
const quote = this.expr.charAt(this.index++);
|
|
27909
|
-
let closed = false;
|
|
27910
|
-
while (this.index < this.expr.length) {
|
|
27911
|
-
let ch = this.expr.charAt(this.index++);
|
|
27912
|
-
if (ch === quote) {
|
|
27913
|
-
closed = true;
|
|
27914
|
-
break;
|
|
27915
|
-
} else if (ch === "\\") {
|
|
27916
|
-
ch = this.expr.charAt(this.index++);
|
|
27917
|
-
switch (ch) {
|
|
27918
|
-
case "n":
|
|
27919
|
-
str += `
|
|
27920
|
-
`;
|
|
27921
|
-
break;
|
|
27922
|
-
case "r":
|
|
27923
|
-
str += "\r";
|
|
27924
|
-
break;
|
|
27925
|
-
case "t":
|
|
27926
|
-
str += "\t";
|
|
27927
|
-
break;
|
|
27928
|
-
case "b":
|
|
27929
|
-
str += "\b";
|
|
27930
|
-
break;
|
|
27931
|
-
case "f":
|
|
27932
|
-
str += "\f";
|
|
27933
|
-
break;
|
|
27934
|
-
case "v":
|
|
27935
|
-
str += "\v";
|
|
27936
|
-
break;
|
|
27937
|
-
default:
|
|
27938
|
-
str += ch;
|
|
27939
|
-
}
|
|
27940
|
-
} else {
|
|
27941
|
-
str += ch;
|
|
27942
|
-
}
|
|
27943
|
-
}
|
|
27944
|
-
if (!closed) {
|
|
27945
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
27946
|
-
}
|
|
27947
|
-
return {
|
|
27948
|
-
type: Jsep.LITERAL,
|
|
27949
|
-
value: str,
|
|
27950
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
27951
|
-
};
|
|
27952
|
-
}
|
|
27953
|
-
gobbleIdentifier() {
|
|
27954
|
-
let ch = this.code, start = this.index;
|
|
27955
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27956
|
-
this.index++;
|
|
27957
|
-
} else {
|
|
27958
|
-
this.throwError("Unexpected " + this.char);
|
|
27959
|
-
}
|
|
27960
|
-
while (this.index < this.expr.length) {
|
|
27961
|
-
ch = this.code;
|
|
27962
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
27963
|
-
this.index++;
|
|
27964
|
-
} else {
|
|
27965
|
-
break;
|
|
27966
|
-
}
|
|
27967
|
-
}
|
|
27968
|
-
return {
|
|
27969
|
-
type: Jsep.IDENTIFIER,
|
|
27970
|
-
name: this.expr.slice(start, this.index)
|
|
27971
|
-
};
|
|
27972
|
-
}
|
|
27973
|
-
gobbleArguments(termination) {
|
|
27974
|
-
const args = [];
|
|
27975
|
-
let closed = false;
|
|
27976
|
-
let separator_count = 0;
|
|
27977
|
-
while (this.index < this.expr.length) {
|
|
27978
|
-
this.gobbleSpaces();
|
|
27979
|
-
let ch_i = this.code;
|
|
27980
|
-
if (ch_i === termination) {
|
|
27981
|
-
closed = true;
|
|
27982
|
-
this.index++;
|
|
27983
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
27984
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
27985
|
-
}
|
|
27986
|
-
break;
|
|
27987
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
27988
|
-
this.index++;
|
|
27989
|
-
separator_count++;
|
|
27990
|
-
if (separator_count !== args.length) {
|
|
27991
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
27992
|
-
this.throwError("Unexpected token ,");
|
|
27993
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
27994
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
27995
|
-
args.push(null);
|
|
27996
|
-
}
|
|
27997
|
-
}
|
|
27998
|
-
}
|
|
27999
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
28000
|
-
this.throwError("Expected comma");
|
|
28001
|
-
} else {
|
|
28002
|
-
const node = this.gobbleExpression();
|
|
28003
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
28004
|
-
this.throwError("Expected comma");
|
|
28005
|
-
}
|
|
28006
|
-
args.push(node);
|
|
28007
|
-
}
|
|
28008
|
-
}
|
|
28009
|
-
if (!closed) {
|
|
28010
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
28011
|
-
}
|
|
28012
|
-
return args;
|
|
28013
|
-
}
|
|
28014
|
-
gobbleGroup() {
|
|
28015
|
-
this.index++;
|
|
28016
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
28017
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
28018
|
-
this.index++;
|
|
28019
|
-
if (nodes.length === 1) {
|
|
28020
|
-
return nodes[0];
|
|
28021
|
-
} else if (!nodes.length) {
|
|
28022
|
-
return false;
|
|
28023
|
-
} else {
|
|
28024
|
-
return {
|
|
28025
|
-
type: Jsep.SEQUENCE_EXP,
|
|
28026
|
-
expressions: nodes
|
|
28027
|
-
};
|
|
28028
|
-
}
|
|
28029
|
-
} else {
|
|
28030
|
-
this.throwError("Unclosed (");
|
|
28031
|
-
}
|
|
28032
|
-
}
|
|
28033
|
-
gobbleArray() {
|
|
28034
|
-
this.index++;
|
|
28035
|
-
return {
|
|
28036
|
-
type: Jsep.ARRAY_EXP,
|
|
28037
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
28038
|
-
};
|
|
28039
|
-
}
|
|
28040
|
-
}
|
|
28041
|
-
var hooks = new Hooks;
|
|
28042
|
-
Object.assign(Jsep, {
|
|
28043
|
-
hooks,
|
|
28044
|
-
plugins: new Plugins(Jsep),
|
|
28045
|
-
COMPOUND: "Compound",
|
|
28046
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
28047
|
-
IDENTIFIER: "Identifier",
|
|
28048
|
-
MEMBER_EXP: "MemberExpression",
|
|
28049
|
-
LITERAL: "Literal",
|
|
28050
|
-
THIS_EXP: "ThisExpression",
|
|
28051
|
-
CALL_EXP: "CallExpression",
|
|
28052
|
-
UNARY_EXP: "UnaryExpression",
|
|
28053
|
-
BINARY_EXP: "BinaryExpression",
|
|
28054
|
-
ARRAY_EXP: "ArrayExpression",
|
|
28055
|
-
TAB_CODE: 9,
|
|
28056
|
-
LF_CODE: 10,
|
|
28057
|
-
CR_CODE: 13,
|
|
28058
|
-
SPACE_CODE: 32,
|
|
28059
|
-
PERIOD_CODE: 46,
|
|
28060
|
-
COMMA_CODE: 44,
|
|
28061
|
-
SQUOTE_CODE: 39,
|
|
28062
|
-
DQUOTE_CODE: 34,
|
|
28063
|
-
OPAREN_CODE: 40,
|
|
28064
|
-
CPAREN_CODE: 41,
|
|
28065
|
-
OBRACK_CODE: 91,
|
|
28066
|
-
CBRACK_CODE: 93,
|
|
28067
|
-
QUMARK_CODE: 63,
|
|
28068
|
-
SEMCOL_CODE: 59,
|
|
28069
|
-
COLON_CODE: 58,
|
|
28070
|
-
unary_ops: {
|
|
28071
|
-
"-": 1,
|
|
28072
|
-
"!": 1,
|
|
28073
|
-
"~": 1,
|
|
28074
|
-
"+": 1
|
|
28075
|
-
},
|
|
28076
|
-
binary_ops: {
|
|
28077
|
-
"||": 1,
|
|
28078
|
-
"??": 1,
|
|
28079
|
-
"&&": 2,
|
|
28080
|
-
"|": 3,
|
|
28081
|
-
"^": 4,
|
|
28082
|
-
"&": 5,
|
|
28083
|
-
"==": 6,
|
|
28084
|
-
"!=": 6,
|
|
28085
|
-
"===": 6,
|
|
28086
|
-
"!==": 6,
|
|
28087
|
-
"<": 7,
|
|
28088
|
-
">": 7,
|
|
28089
|
-
"<=": 7,
|
|
28090
|
-
">=": 7,
|
|
28091
|
-
"<<": 8,
|
|
28092
|
-
">>": 8,
|
|
28093
|
-
">>>": 8,
|
|
28094
|
-
"+": 9,
|
|
28095
|
-
"-": 9,
|
|
28096
|
-
"*": 10,
|
|
28097
|
-
"/": 10,
|
|
28098
|
-
"%": 10,
|
|
28099
|
-
"**": 11
|
|
28100
|
-
},
|
|
28101
|
-
right_associative: new Set(["**"]),
|
|
28102
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
28103
|
-
literals: {
|
|
28104
|
-
true: true,
|
|
28105
|
-
false: false,
|
|
28106
|
-
null: null
|
|
28107
|
-
},
|
|
28108
|
-
this_str: "this"
|
|
28109
|
-
});
|
|
28110
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
28111
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
28112
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
28113
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
28114
|
-
});
|
|
28115
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
28116
|
-
jsep[m] = Jsep[m];
|
|
28117
|
-
});
|
|
28118
|
-
jsep.Jsep = Jsep;
|
|
28119
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
28120
|
-
var ternary = {
|
|
28121
|
-
name: "ternary",
|
|
28122
|
-
init(jsep2) {
|
|
28123
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
28124
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
28125
|
-
this.index++;
|
|
28126
|
-
const test = env.node;
|
|
28127
|
-
const consequent = this.gobbleExpression();
|
|
28128
|
-
if (!consequent) {
|
|
28129
|
-
this.throwError("Expected expression");
|
|
28130
|
-
}
|
|
28131
|
-
this.gobbleSpaces();
|
|
28132
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
28133
|
-
this.index++;
|
|
28134
|
-
const alternate = this.gobbleExpression();
|
|
28135
|
-
if (!alternate) {
|
|
28136
|
-
this.throwError("Expected expression");
|
|
28137
|
-
}
|
|
28138
|
-
env.node = {
|
|
28139
|
-
type: CONDITIONAL_EXP,
|
|
28140
|
-
test,
|
|
28141
|
-
consequent,
|
|
28142
|
-
alternate
|
|
28143
|
-
};
|
|
28144
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
28145
|
-
let newTest = test;
|
|
28146
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
28147
|
-
newTest = newTest.right;
|
|
28148
|
-
}
|
|
28149
|
-
env.node.test = newTest.right;
|
|
28150
|
-
newTest.right = env.node;
|
|
28151
|
-
env.node = test;
|
|
28152
|
-
}
|
|
28153
|
-
} else {
|
|
28154
|
-
this.throwError("Expected :");
|
|
28155
|
-
}
|
|
28156
|
-
}
|
|
28157
|
-
});
|
|
28158
|
-
}
|
|
28159
|
-
};
|
|
28160
|
-
jsep.plugins.register(ternary);
|
|
28161
|
-
var FSLASH_CODE = 47;
|
|
28162
|
-
var BSLASH_CODE = 92;
|
|
28163
|
-
var index = {
|
|
28164
|
-
name: "regex",
|
|
28165
|
-
init(jsep2) {
|
|
28166
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
28167
|
-
if (this.code === FSLASH_CODE) {
|
|
28168
|
-
const patternIndex = ++this.index;
|
|
28169
|
-
let inCharSet = false;
|
|
28170
|
-
while (this.index < this.expr.length) {
|
|
28171
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
28172
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
28173
|
-
let flags = "";
|
|
28174
|
-
while (++this.index < this.expr.length) {
|
|
28175
|
-
const code = this.code;
|
|
28176
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
28177
|
-
flags += this.char;
|
|
28178
|
-
} else {
|
|
28179
|
-
break;
|
|
28180
|
-
}
|
|
28181
|
-
}
|
|
28182
|
-
let value;
|
|
28183
|
-
try {
|
|
28184
|
-
value = new RegExp(pattern, flags);
|
|
28185
|
-
} catch (e) {
|
|
28186
|
-
this.throwError(e.message);
|
|
28187
|
-
}
|
|
28188
|
-
env.node = {
|
|
28189
|
-
type: jsep2.LITERAL,
|
|
28190
|
-
value,
|
|
28191
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
28192
|
-
};
|
|
28193
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
28194
|
-
return env.node;
|
|
28195
|
-
}
|
|
28196
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
28197
|
-
inCharSet = true;
|
|
28198
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
28199
|
-
inCharSet = false;
|
|
28200
|
-
}
|
|
28201
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
28202
|
-
}
|
|
28203
|
-
this.throwError("Unclosed Regex");
|
|
28204
|
-
}
|
|
28205
|
-
});
|
|
28206
|
-
}
|
|
28207
|
-
};
|
|
28208
|
-
var PLUS_CODE = 43;
|
|
28209
|
-
var MINUS_CODE = 45;
|
|
28210
|
-
var plugin = {
|
|
28211
|
-
name: "assignment",
|
|
28212
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
28213
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
28214
|
-
assignmentPrecedence: 0.9,
|
|
28215
|
-
init(jsep2) {
|
|
28216
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
28217
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
28218
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
28219
|
-
const code = this.code;
|
|
28220
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28221
|
-
this.index += 2;
|
|
28222
|
-
env.node = {
|
|
28223
|
-
type: "UpdateExpression",
|
|
28224
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28225
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
28226
|
-
prefix: true
|
|
28227
|
-
};
|
|
28228
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
28229
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28230
|
-
}
|
|
28231
|
-
}
|
|
28232
|
-
});
|
|
28233
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
28234
|
-
if (env.node) {
|
|
28235
|
-
const code = this.code;
|
|
28236
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28237
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
28238
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28239
|
-
}
|
|
28240
|
-
this.index += 2;
|
|
28241
|
-
env.node = {
|
|
28242
|
-
type: "UpdateExpression",
|
|
28243
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28244
|
-
argument: env.node,
|
|
28245
|
-
prefix: false
|
|
28246
|
-
};
|
|
28247
|
-
}
|
|
28248
|
-
}
|
|
28249
|
-
});
|
|
28250
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
28251
|
-
if (env.node) {
|
|
28252
|
-
updateBinariesToAssignments(env.node);
|
|
28253
|
-
}
|
|
28254
|
-
});
|
|
28255
|
-
function updateBinariesToAssignments(node) {
|
|
28256
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
28257
|
-
node.type = "AssignmentExpression";
|
|
28258
|
-
updateBinariesToAssignments(node.left);
|
|
28259
|
-
updateBinariesToAssignments(node.right);
|
|
28260
|
-
} else if (!node.operator) {
|
|
28261
|
-
Object.values(node).forEach((val) => {
|
|
28262
|
-
if (val && typeof val === "object") {
|
|
28263
|
-
updateBinariesToAssignments(val);
|
|
28264
|
-
}
|
|
28265
|
-
});
|
|
28266
|
-
}
|
|
28267
|
-
}
|
|
28268
|
-
}
|
|
28269
|
-
};
|
|
28270
|
-
jsep.plugins.register(index, plugin);
|
|
28271
|
-
jsep.addUnaryOp("typeof");
|
|
28272
|
-
jsep.addUnaryOp("void");
|
|
28273
|
-
jsep.addLiteral("null", null);
|
|
28274
|
-
jsep.addLiteral("undefined", undefined);
|
|
28275
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
28276
|
-
var SafeEval = {
|
|
28277
|
-
evalAst(ast, subs) {
|
|
28278
|
-
switch (ast.type) {
|
|
28279
|
-
case "BinaryExpression":
|
|
28280
|
-
case "LogicalExpression":
|
|
28281
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
28282
|
-
case "Compound":
|
|
28283
|
-
return SafeEval.evalCompound(ast, subs);
|
|
28284
|
-
case "ConditionalExpression":
|
|
28285
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
28286
|
-
case "Identifier":
|
|
28287
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
28288
|
-
case "Literal":
|
|
28289
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
28290
|
-
case "MemberExpression":
|
|
28291
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
28292
|
-
case "UnaryExpression":
|
|
28293
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
28294
|
-
case "ArrayExpression":
|
|
28295
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
28296
|
-
case "CallExpression":
|
|
28297
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
28298
|
-
case "AssignmentExpression":
|
|
28299
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
28300
|
-
default:
|
|
28301
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
28302
|
-
}
|
|
28303
|
-
},
|
|
28304
|
-
evalBinaryExpression(ast, subs) {
|
|
28305
|
-
const result = {
|
|
28306
|
-
"||": (a, b) => a || b(),
|
|
28307
|
-
"&&": (a, b) => a && b(),
|
|
28308
|
-
"|": (a, b) => a | b(),
|
|
28309
|
-
"^": (a, b) => a ^ b(),
|
|
28310
|
-
"&": (a, b) => a & b(),
|
|
28311
|
-
"==": (a, b) => a == b(),
|
|
28312
|
-
"!=": (a, b) => a != b(),
|
|
28313
|
-
"===": (a, b) => a === b(),
|
|
28314
|
-
"!==": (a, b) => a !== b(),
|
|
28315
|
-
"<": (a, b) => a < b(),
|
|
28316
|
-
">": (a, b) => a > b(),
|
|
28317
|
-
"<=": (a, b) => a <= b(),
|
|
28318
|
-
">=": (a, b) => a >= b(),
|
|
28319
|
-
"<<": (a, b) => a << b(),
|
|
28320
|
-
">>": (a, b) => a >> b(),
|
|
28321
|
-
">>>": (a, b) => a >>> b(),
|
|
28322
|
-
"+": (a, b) => a + b(),
|
|
28323
|
-
"-": (a, b) => a - b(),
|
|
28324
|
-
"*": (a, b) => a * b(),
|
|
28325
|
-
"/": (a, b) => a / b(),
|
|
28326
|
-
"%": (a, b) => a % b()
|
|
28327
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
28328
|
-
return result;
|
|
28329
|
-
},
|
|
28330
|
-
evalCompound(ast, subs) {
|
|
28331
|
-
let last;
|
|
28332
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
28333
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
28334
|
-
i += 1;
|
|
28335
|
-
}
|
|
28336
|
-
const expr = ast.body[i];
|
|
28337
|
-
last = SafeEval.evalAst(expr, subs);
|
|
28338
|
-
}
|
|
28339
|
-
return last;
|
|
28340
|
-
},
|
|
28341
|
-
evalConditionalExpression(ast, subs) {
|
|
28342
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
28343
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
28344
|
-
}
|
|
28345
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
28346
|
-
},
|
|
28347
|
-
evalIdentifier(ast, subs) {
|
|
28348
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
28349
|
-
return subs[ast.name];
|
|
28350
|
-
}
|
|
28351
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
28352
|
-
},
|
|
28353
|
-
evalLiteral(ast) {
|
|
28354
|
-
return ast.value;
|
|
28355
|
-
},
|
|
28356
|
-
evalMemberExpression(ast, subs) {
|
|
28357
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
28358
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
28359
|
-
if (obj === undefined || obj === null) {
|
|
28360
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28361
|
-
}
|
|
28362
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
28363
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28364
|
-
}
|
|
28365
|
-
const result = obj[prop];
|
|
28366
|
-
if (typeof result === "function") {
|
|
28367
|
-
return result.bind(obj);
|
|
28368
|
-
}
|
|
28369
|
-
return result;
|
|
28370
|
-
},
|
|
28371
|
-
evalUnaryExpression(ast, subs) {
|
|
28372
|
-
const result = {
|
|
28373
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
28374
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
28375
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
28376
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
28377
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
28378
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
28379
|
-
}[ast.operator](ast.argument);
|
|
28380
|
-
return result;
|
|
28381
|
-
},
|
|
28382
|
-
evalArrayExpression(ast, subs) {
|
|
28383
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
28384
|
-
},
|
|
28385
|
-
evalCallExpression(ast, subs) {
|
|
28386
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
28387
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
28388
|
-
if (func === Function) {
|
|
28389
|
-
throw new Error("Function constructor is disabled");
|
|
28390
|
-
}
|
|
28391
|
-
return func(...args);
|
|
28392
|
-
},
|
|
28393
|
-
evalAssignmentExpression(ast, subs) {
|
|
28394
|
-
if (ast.left.type !== "Identifier") {
|
|
28395
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
28396
|
-
}
|
|
28397
|
-
const id = ast.left.name;
|
|
28398
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
28399
|
-
subs[id] = value;
|
|
28400
|
-
return subs[id];
|
|
28401
|
-
}
|
|
28402
|
-
};
|
|
28403
|
-
|
|
28404
|
-
class SafeScript {
|
|
28405
|
-
constructor(expr) {
|
|
28406
|
-
this.code = expr;
|
|
28407
|
-
this.ast = jsep(this.code);
|
|
28408
|
-
}
|
|
28409
|
-
runInNewContext(context) {
|
|
28410
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
28411
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
28412
|
-
}
|
|
28413
|
-
}
|
|
28414
|
-
function push(arr, item) {
|
|
28415
|
-
arr = arr.slice();
|
|
28416
|
-
arr.push(item);
|
|
28417
|
-
return arr;
|
|
28418
|
-
}
|
|
28419
|
-
function unshift(item, arr) {
|
|
28420
|
-
arr = arr.slice();
|
|
28421
|
-
arr.unshift(item);
|
|
28422
|
-
return arr;
|
|
28423
|
-
}
|
|
28424
|
-
|
|
28425
|
-
class NewError extends Error {
|
|
28426
|
-
constructor(value) {
|
|
28427
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
28428
|
-
this.avoidNew = true;
|
|
28429
|
-
this.value = value;
|
|
28430
|
-
this.name = "NewError";
|
|
28431
|
-
}
|
|
28432
|
-
}
|
|
28433
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
28434
|
-
if (!(this instanceof JSONPath)) {
|
|
28435
|
-
try {
|
|
28436
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
28437
|
-
} catch (e) {
|
|
28438
|
-
if (!e.avoidNew) {
|
|
28439
|
-
throw e;
|
|
28440
|
-
}
|
|
28441
|
-
return e.value;
|
|
28442
|
-
}
|
|
28443
|
-
}
|
|
28444
|
-
if (typeof opts === "string") {
|
|
28445
|
-
otherTypeCallback = callback;
|
|
28446
|
-
callback = obj;
|
|
28447
|
-
obj = expr;
|
|
28448
|
-
expr = opts;
|
|
28449
|
-
opts = null;
|
|
28450
|
-
}
|
|
28451
|
-
const optObj = opts && typeof opts === "object";
|
|
28452
|
-
opts = opts || {};
|
|
28453
|
-
this.json = opts.json || obj;
|
|
28454
|
-
this.path = opts.path || expr;
|
|
28455
|
-
this.resultType = opts.resultType || "value";
|
|
28456
|
-
this.flatten = opts.flatten || false;
|
|
28457
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
28458
|
-
this.sandbox = opts.sandbox || {};
|
|
28459
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
28460
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
28461
|
-
this.parent = opts.parent || null;
|
|
28462
|
-
this.parentProperty = opts.parentProperty || null;
|
|
28463
|
-
this.callback = opts.callback || callback || null;
|
|
28464
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
28465
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
28466
|
-
};
|
|
28467
|
-
if (opts.autostart !== false) {
|
|
28468
|
-
const args = {
|
|
28469
|
-
path: optObj ? opts.path : expr
|
|
28470
|
-
};
|
|
28471
|
-
if (!optObj) {
|
|
28472
|
-
args.json = obj;
|
|
28473
|
-
} else if ("json" in opts) {
|
|
28474
|
-
args.json = opts.json;
|
|
28475
|
-
}
|
|
28476
|
-
const ret = this.evaluate(args);
|
|
28477
|
-
if (!ret || typeof ret !== "object") {
|
|
28478
|
-
throw new NewError(ret);
|
|
28479
|
-
}
|
|
28480
|
-
return ret;
|
|
28481
|
-
}
|
|
28482
|
-
}
|
|
28483
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
28484
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
28485
|
-
let {
|
|
28486
|
-
flatten,
|
|
28487
|
-
wrap
|
|
28488
|
-
} = this;
|
|
28489
|
-
this.currResultType = this.resultType;
|
|
28490
|
-
this.currEval = this.eval;
|
|
28491
|
-
this.currSandbox = this.sandbox;
|
|
28492
|
-
callback = callback || this.callback;
|
|
28493
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
28494
|
-
json = json || this.json;
|
|
28495
|
-
expr = expr || this.path;
|
|
28496
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
28497
|
-
if (!expr.path && expr.path !== "") {
|
|
28498
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28499
|
-
}
|
|
28500
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
28501
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28502
|
-
}
|
|
28503
|
-
({
|
|
28504
|
-
json
|
|
28505
|
-
} = expr);
|
|
28506
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
28507
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
28508
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
28509
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
28510
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
28511
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
28512
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
28513
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
28514
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
28515
|
-
expr = expr.path;
|
|
28516
|
-
}
|
|
28517
|
-
currParent = currParent || null;
|
|
28518
|
-
currParentProperty = currParentProperty || null;
|
|
28519
|
-
if (Array.isArray(expr)) {
|
|
28520
|
-
expr = JSONPath.toPathString(expr);
|
|
28521
|
-
}
|
|
28522
|
-
if (!expr && expr !== "" || !json) {
|
|
28523
|
-
return;
|
|
28524
|
-
}
|
|
28525
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
28526
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
28527
|
-
exprList.shift();
|
|
28528
|
-
}
|
|
28529
|
-
this._hasParentSelector = null;
|
|
28530
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
28531
|
-
return ea && !ea.isParentSelector;
|
|
28532
|
-
});
|
|
28533
|
-
if (!result.length) {
|
|
28534
|
-
return wrap ? [] : undefined;
|
|
28535
|
-
}
|
|
28536
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
28537
|
-
return this._getPreferredOutput(result[0]);
|
|
28538
|
-
}
|
|
28539
|
-
return result.reduce((rslt, ea) => {
|
|
28540
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
28541
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
28542
|
-
rslt = rslt.concat(valOrPath);
|
|
28543
|
-
} else {
|
|
28544
|
-
rslt.push(valOrPath);
|
|
28545
|
-
}
|
|
28546
|
-
return rslt;
|
|
28547
|
-
}, []);
|
|
28548
|
-
};
|
|
28549
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
28550
|
-
const resultType = this.currResultType;
|
|
28551
|
-
switch (resultType) {
|
|
28552
|
-
case "all": {
|
|
28553
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
28554
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
28555
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
28556
|
-
return ea;
|
|
28557
|
-
}
|
|
28558
|
-
case "value":
|
|
28559
|
-
case "parent":
|
|
28560
|
-
case "parentProperty":
|
|
28561
|
-
return ea[resultType];
|
|
28562
|
-
case "path":
|
|
28563
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
28564
|
-
case "pointer":
|
|
28565
|
-
return JSONPath.toPointer(ea.path);
|
|
28566
|
-
default:
|
|
28567
|
-
throw new TypeError("Unknown result type");
|
|
28568
|
-
}
|
|
28569
|
-
};
|
|
28570
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
28571
|
-
if (callback) {
|
|
28572
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
28573
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
28574
|
-
callback(preferredOutput, type, fullRetObj);
|
|
28575
|
-
}
|
|
28576
|
-
};
|
|
28577
|
-
JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
28578
|
-
let retObj;
|
|
28579
|
-
if (!expr.length) {
|
|
28580
|
-
retObj = {
|
|
28581
|
-
path: path3,
|
|
28582
|
-
value: val,
|
|
28583
|
-
parent,
|
|
28584
|
-
parentProperty: parentPropName,
|
|
28585
|
-
hasArrExpr
|
|
28586
|
-
};
|
|
28587
|
-
this._handleCallback(retObj, callback, "value");
|
|
28588
|
-
return retObj;
|
|
28589
|
-
}
|
|
28590
|
-
const loc = expr[0], x = expr.slice(1);
|
|
28591
|
-
const ret = [];
|
|
28592
|
-
function addRet(elems) {
|
|
28593
|
-
if (Array.isArray(elems)) {
|
|
28594
|
-
elems.forEach((t) => {
|
|
28595
|
-
ret.push(t);
|
|
28596
|
-
});
|
|
28597
|
-
} else {
|
|
28598
|
-
ret.push(elems);
|
|
28599
|
-
}
|
|
28600
|
-
}
|
|
28601
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
28602
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
28603
|
-
} else if (loc === "*") {
|
|
28604
|
-
this._walk(val, (m) => {
|
|
28605
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
28606
|
-
});
|
|
28607
|
-
} else if (loc === "..") {
|
|
28608
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28609
|
-
this._walk(val, (m) => {
|
|
28610
|
-
if (typeof val[m] === "object") {
|
|
28611
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
28612
|
-
}
|
|
28613
|
-
});
|
|
28614
|
-
} else if (loc === "^") {
|
|
28615
|
-
this._hasParentSelector = true;
|
|
28616
|
-
return {
|
|
28617
|
-
path: path3.slice(0, -1),
|
|
28618
|
-
expr: x,
|
|
28619
|
-
isParentSelector: true
|
|
28620
|
-
};
|
|
28621
|
-
} else if (loc === "~") {
|
|
28622
|
-
retObj = {
|
|
28623
|
-
path: push(path3, loc),
|
|
28624
|
-
value: parentPropName,
|
|
28625
|
-
parent,
|
|
28626
|
-
parentProperty: null
|
|
28627
|
-
};
|
|
28628
|
-
this._handleCallback(retObj, callback, "property");
|
|
28629
|
-
return retObj;
|
|
28630
|
-
} else if (loc === "$") {
|
|
28631
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
28632
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
28633
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
28634
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
28635
|
-
if (this.currEval === false) {
|
|
28636
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
28637
|
-
}
|
|
28638
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
28639
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
28640
|
-
if (nested) {
|
|
28641
|
-
this._walk(val, (m) => {
|
|
28642
|
-
const npath = [nested[2]];
|
|
28643
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
28644
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
28645
|
-
if (filterResults.length > 0) {
|
|
28646
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28647
|
-
}
|
|
28648
|
-
});
|
|
28649
|
-
} else {
|
|
28650
|
-
this._walk(val, (m) => {
|
|
28651
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
28652
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28653
|
-
}
|
|
28654
|
-
});
|
|
28655
|
-
}
|
|
28656
|
-
} else if (loc[0] === "(") {
|
|
28657
|
-
if (this.currEval === false) {
|
|
28658
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
28659
|
-
}
|
|
28660
|
-
addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28661
|
-
} else if (loc[0] === "@") {
|
|
28662
|
-
let addType = false;
|
|
28663
|
-
const valueType = loc.slice(1, -2);
|
|
28664
|
-
switch (valueType) {
|
|
28665
|
-
case "scalar":
|
|
28666
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
28667
|
-
addType = true;
|
|
28668
|
-
}
|
|
28669
|
-
break;
|
|
28670
|
-
case "boolean":
|
|
28671
|
-
case "string":
|
|
28672
|
-
case "undefined":
|
|
28673
|
-
case "function":
|
|
28674
|
-
if (typeof val === valueType) {
|
|
28675
|
-
addType = true;
|
|
28676
|
-
}
|
|
28677
|
-
break;
|
|
28678
|
-
case "integer":
|
|
28679
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
28680
|
-
addType = true;
|
|
28681
|
-
}
|
|
28682
|
-
break;
|
|
28683
|
-
case "number":
|
|
28684
|
-
if (Number.isFinite(val)) {
|
|
28685
|
-
addType = true;
|
|
28686
|
-
}
|
|
28687
|
-
break;
|
|
28688
|
-
case "nonFinite":
|
|
28689
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
28690
|
-
addType = true;
|
|
28691
|
-
}
|
|
28692
|
-
break;
|
|
28693
|
-
case "object":
|
|
28694
|
-
if (val && typeof val === valueType) {
|
|
28695
|
-
addType = true;
|
|
28696
|
-
}
|
|
28697
|
-
break;
|
|
28698
|
-
case "array":
|
|
28699
|
-
if (Array.isArray(val)) {
|
|
28700
|
-
addType = true;
|
|
28701
|
-
}
|
|
28702
|
-
break;
|
|
28703
|
-
case "other":
|
|
28704
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
28705
|
-
break;
|
|
28706
|
-
case "null":
|
|
28707
|
-
if (val === null) {
|
|
28708
|
-
addType = true;
|
|
28709
|
-
}
|
|
28710
|
-
break;
|
|
28711
|
-
default:
|
|
28712
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
28713
|
-
}
|
|
28714
|
-
if (addType) {
|
|
28715
|
-
retObj = {
|
|
28716
|
-
path: path3,
|
|
28717
|
-
value: val,
|
|
28718
|
-
parent,
|
|
28719
|
-
parentProperty: parentPropName
|
|
28720
|
-
};
|
|
28721
|
-
this._handleCallback(retObj, callback, "value");
|
|
28722
|
-
return retObj;
|
|
28723
|
-
}
|
|
28724
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
28725
|
-
const locProp = loc.slice(1);
|
|
28726
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
28727
|
-
} else if (loc.includes(",")) {
|
|
28728
|
-
const parts = loc.split(",");
|
|
28729
|
-
for (const part of parts) {
|
|
28730
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
28731
|
-
}
|
|
28732
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
28733
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
28734
|
-
}
|
|
28735
|
-
if (this._hasParentSelector) {
|
|
28736
|
-
for (let t = 0;t < ret.length; t++) {
|
|
28737
|
-
const rett = ret[t];
|
|
28738
|
-
if (rett && rett.isParentSelector) {
|
|
28739
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
28740
|
-
if (Array.isArray(tmp)) {
|
|
28741
|
-
ret[t] = tmp[0];
|
|
28742
|
-
const tl = tmp.length;
|
|
28743
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
28744
|
-
t++;
|
|
28745
|
-
ret.splice(t, 0, tmp[tt]);
|
|
28746
|
-
}
|
|
28747
|
-
} else {
|
|
28748
|
-
ret[t] = tmp;
|
|
28749
|
-
}
|
|
28750
|
-
}
|
|
28751
|
-
}
|
|
28752
|
-
}
|
|
28753
|
-
return ret;
|
|
28754
|
-
};
|
|
28755
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
28756
|
-
if (Array.isArray(val)) {
|
|
28757
|
-
const n = val.length;
|
|
28758
|
-
for (let i = 0;i < n; i++) {
|
|
28759
|
-
f(i);
|
|
28760
|
-
}
|
|
28761
|
-
} else if (val && typeof val === "object") {
|
|
28762
|
-
Object.keys(val).forEach((m) => {
|
|
28763
|
-
f(m);
|
|
28764
|
-
});
|
|
28765
|
-
}
|
|
28766
|
-
};
|
|
28767
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
28768
|
-
if (!Array.isArray(val)) {
|
|
28769
|
-
return;
|
|
28770
|
-
}
|
|
28771
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
28772
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
28773
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
28774
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
28775
|
-
const ret = [];
|
|
28776
|
-
for (let i = start;i < end; i += step) {
|
|
28777
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
28778
|
-
tmp.forEach((t) => {
|
|
28779
|
-
ret.push(t);
|
|
28780
|
-
});
|
|
28781
|
-
}
|
|
28782
|
-
return ret;
|
|
28783
|
-
};
|
|
28784
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
28785
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
28786
|
-
this.currSandbox._$_parent = parent;
|
|
28787
|
-
this.currSandbox._$_property = _vname;
|
|
28788
|
-
this.currSandbox._$_root = this.json;
|
|
28789
|
-
this.currSandbox._$_v = _v;
|
|
28790
|
-
const containsPath = code.includes("@path");
|
|
28791
|
-
if (containsPath) {
|
|
28792
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
28793
|
-
}
|
|
28794
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
28795
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
28796
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
28797
|
-
if (containsPath) {
|
|
28798
|
-
script = script.replaceAll("@path", "_$_path");
|
|
28799
|
-
}
|
|
28800
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
28801
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
28802
|
-
} else if (this.currEval === "native") {
|
|
28803
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
28804
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
28805
|
-
const CurrEval = this.currEval;
|
|
28806
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
28807
|
-
} else if (typeof this.currEval === "function") {
|
|
28808
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
28809
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
28810
|
-
};
|
|
28811
|
-
} else {
|
|
28812
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
28813
|
-
}
|
|
28814
|
-
}
|
|
28815
|
-
try {
|
|
28816
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
28817
|
-
} catch (e) {
|
|
28818
|
-
if (this.ignoreEvalErrors) {
|
|
28819
|
-
return false;
|
|
28820
|
-
}
|
|
28821
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
28822
|
-
}
|
|
28823
|
-
};
|
|
28824
|
-
JSONPath.cache = {};
|
|
28825
|
-
JSONPath.toPathString = function(pathArr) {
|
|
28826
|
-
const x = pathArr, n = x.length;
|
|
28827
|
-
let p = "$";
|
|
28828
|
-
for (let i = 1;i < n; i++) {
|
|
28829
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28830
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
28831
|
-
}
|
|
28832
|
-
}
|
|
28833
|
-
return p;
|
|
28834
|
-
};
|
|
28835
|
-
JSONPath.toPointer = function(pointer) {
|
|
28836
|
-
const x = pointer, n = x.length;
|
|
28837
|
-
let p = "";
|
|
28838
|
-
for (let i = 1;i < n; i++) {
|
|
28839
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28840
|
-
p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
28841
|
-
}
|
|
28842
|
-
}
|
|
28843
|
-
return p;
|
|
28844
|
-
};
|
|
28845
|
-
JSONPath.toPathArray = function(expr) {
|
|
28846
|
-
const {
|
|
28847
|
-
cache
|
|
28848
|
-
} = JSONPath;
|
|
28849
|
-
if (cache[expr]) {
|
|
28850
|
-
return cache[expr].concat();
|
|
28851
|
-
}
|
|
28852
|
-
const subx = [];
|
|
28853
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
28854
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
28855
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
28856
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
28857
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
28858
|
-
return ";" + ups.split("").join(";") + ";";
|
|
28859
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
28860
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
28861
|
-
const match = exp.match(/#(\d+)/u);
|
|
28862
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
28863
|
-
});
|
|
28864
|
-
cache[expr] = exprList;
|
|
28865
|
-
return cache[expr].concat();
|
|
28866
|
-
};
|
|
28867
|
-
JSONPath.prototype.safeVm = {
|
|
28868
|
-
Script: SafeScript
|
|
28869
|
-
};
|
|
28870
|
-
JSONPath.prototype.vm = vm;
|
|
28871
|
-
// ../common/src/option-aliases.ts
|
|
28872
|
-
function resolveDeprecatedOptionAlias({
|
|
28873
|
-
preferredValue,
|
|
28874
|
-
deprecatedValue,
|
|
28875
|
-
preferredFlag,
|
|
28876
|
-
deprecatedFlag
|
|
28877
|
-
}) {
|
|
28878
|
-
const hasPreferred = preferredValue !== undefined;
|
|
28879
|
-
const hasDeprecated = deprecatedValue !== undefined;
|
|
28880
|
-
if (hasPreferred && hasDeprecated) {
|
|
28881
|
-
return {
|
|
28882
|
-
value: undefined,
|
|
28883
|
-
usedDeprecated: true,
|
|
28884
|
-
error: {
|
|
28885
|
-
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
28886
|
-
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
28887
|
-
}
|
|
28888
|
-
};
|
|
28889
|
-
}
|
|
28890
|
-
return {
|
|
28891
|
-
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
28892
|
-
usedDeprecated: hasDeprecated
|
|
28893
|
-
};
|
|
28894
|
-
}
|
|
28895
|
-
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
28896
|
-
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
28897
|
-
`);
|
|
28898
|
-
}
|
|
28899
|
-
// ../common/src/option-validators.ts
|
|
28900
|
-
function parseBoundedInt(raw, optionName, bounds) {
|
|
28901
|
-
const normalized = raw.trim();
|
|
28902
|
-
if (normalized === "") {
|
|
28903
|
-
throw new InvalidArgumentError(`${optionName} requires a value (got empty).`);
|
|
28904
|
-
}
|
|
28905
|
-
if (!/^-?\d+$/.test(normalized)) {
|
|
28906
|
-
throw new InvalidArgumentError(`${optionName} must be an integer, got '${normalized}'.`);
|
|
28907
|
-
}
|
|
28908
|
-
const n = parseInt(normalized, 10);
|
|
28909
|
-
if (n < bounds.min || n > bounds.max) {
|
|
28910
|
-
throw new InvalidArgumentError(`${optionName} must be between ${bounds.min} and ${bounds.max}, got ${n}.`);
|
|
28911
|
-
}
|
|
28912
|
-
return n;
|
|
28913
|
-
}
|
|
28914
|
-
// ../common/src/polling/format-utils.ts
|
|
28915
|
-
function msToDuration(ms) {
|
|
28916
|
-
if (!Number.isFinite(ms) || ms < 0) {
|
|
28917
|
-
return "00:00:00";
|
|
28918
|
-
}
|
|
28919
|
-
const totalSec = Math.floor(ms / 1000);
|
|
28920
|
-
const h = Math.floor(totalSec / 3600);
|
|
28921
|
-
const m = Math.floor(totalSec % 3600 / 60);
|
|
28922
|
-
const s = totalSec % 60;
|
|
28923
|
-
return [h, m, s].map((v) => String(v).padStart(2, "0")).join(":");
|
|
28924
|
-
}
|
|
28925
|
-
// ../common/src/polling/types.ts
|
|
28926
|
-
var PollOutcome = {
|
|
28927
|
-
Completed: "completed",
|
|
28928
|
-
Timeout: "timeout",
|
|
28929
|
-
Interrupted: "interrupted",
|
|
28930
|
-
Aborted: "aborted",
|
|
28931
|
-
Failed: "failed"
|
|
28932
|
-
};
|
|
28933
|
-
var ErrorDecision = {
|
|
28934
|
-
Abort: "abort"
|
|
28935
|
-
};
|
|
28936
|
-
var POLL_DEFAULTS = {
|
|
28937
|
-
intervalMs: 5000,
|
|
28938
|
-
timeoutMs: 1800000,
|
|
28939
|
-
maxConsecutiveErrors: 3,
|
|
28940
|
-
logIntervalMs: 30000,
|
|
28941
|
-
logPrefix: "wait"
|
|
28942
|
-
};
|
|
28943
|
-
var BACKOFF_DEFAULTS = {
|
|
28944
|
-
initialMs: 1000,
|
|
28945
|
-
multiplier: 2,
|
|
28946
|
-
maxMs: 30000,
|
|
28947
|
-
jitter: 0.5
|
|
28948
|
-
};
|
|
28949
|
-
var MIN_INTERVAL_MS = 100;
|
|
28950
|
-
|
|
28951
|
-
// ../common/src/polling/poll-failure-mapping.ts
|
|
28952
|
-
var REASON_BY_OUTCOME = {
|
|
28953
|
-
[PollOutcome.Timeout]: "poll_timeout",
|
|
28954
|
-
[PollOutcome.Failed]: "poll_failed",
|
|
28955
|
-
[PollOutcome.Interrupted]: "poll_failed",
|
|
28956
|
-
[PollOutcome.Aborted]: "poll_aborted"
|
|
28957
|
-
};
|
|
28958
|
-
// ../common/src/polling/poll-until.ts
|
|
28959
|
-
function resolveIntervalFn(options) {
|
|
28960
|
-
if (typeof options.intervalMs === "function") {
|
|
28961
|
-
return options.intervalMs;
|
|
28962
|
-
}
|
|
28963
|
-
const staticInterval = options.intervalMs ?? POLL_DEFAULTS.intervalMs;
|
|
28964
|
-
return () => staticInterval;
|
|
28965
|
-
}
|
|
28966
|
-
function resolveBackoffFn(options) {
|
|
28967
|
-
if (!options.backoff)
|
|
28968
|
-
return;
|
|
28969
|
-
const config = options.backoff === true ? { ...BACKOFF_DEFAULTS } : {
|
|
28970
|
-
initialMs: options.backoff.initialMs ?? BACKOFF_DEFAULTS.initialMs,
|
|
28971
|
-
multiplier: options.backoff.multiplier ?? BACKOFF_DEFAULTS.multiplier,
|
|
28972
|
-
maxMs: options.backoff.maxMs ?? BACKOFF_DEFAULTS.maxMs,
|
|
28973
|
-
jitter: Math.min(1, Math.max(0, options.backoff.jitter ?? BACKOFF_DEFAULTS.jitter))
|
|
28974
|
-
};
|
|
28975
|
-
return (errorCount) => {
|
|
28976
|
-
const exponent = Math.min(errorCount - 1, 30);
|
|
28977
|
-
const raw = Math.min(config.initialMs * config.multiplier ** exponent, config.maxMs);
|
|
28978
|
-
if (config.jitter > 0) {
|
|
28979
|
-
const jitterAmount = raw * config.jitter;
|
|
28980
|
-
return raw - jitterAmount * Math.random();
|
|
28981
|
-
}
|
|
28982
|
-
return raw;
|
|
28983
|
-
};
|
|
28984
|
-
}
|
|
28985
|
-
function clampInterval(raw, label, prefix) {
|
|
28986
|
-
if (!Number.isFinite(raw) || Number.isNaN(raw)) {
|
|
28987
|
-
if (label) {
|
|
28988
|
-
logger.warn(`[${prefix}] ${label} — intervalMs returned ${raw}, falling back to ${POLL_DEFAULTS.intervalMs}ms`);
|
|
28989
|
-
}
|
|
28990
|
-
return POLL_DEFAULTS.intervalMs;
|
|
28991
|
-
}
|
|
28992
|
-
if (raw < MIN_INTERVAL_MS) {
|
|
28993
|
-
if (label) {
|
|
28994
|
-
logger.warn(`[${prefix}] ${label} — intervalMs ${raw}ms clamped to minimum ${MIN_INTERVAL_MS}ms`);
|
|
28995
|
-
}
|
|
28996
|
-
return MIN_INTERVAL_MS;
|
|
28997
|
-
}
|
|
28998
|
-
return raw;
|
|
28999
|
-
}
|
|
29000
|
-
function abortError(signal) {
|
|
29001
|
-
const reason = signal.reason;
|
|
29002
|
-
if (reason instanceof Error && reason.name === "AbortError") {
|
|
29003
|
-
return reason;
|
|
29004
|
-
}
|
|
29005
|
-
const msg = reason instanceof Error ? reason.message : typeof reason === "string" || typeof reason === "number" ? String(reason) : "Aborted";
|
|
29006
|
-
const err = new Error(msg);
|
|
29007
|
-
err.name = "AbortError";
|
|
29008
|
-
return err;
|
|
29009
|
-
}
|
|
29010
|
-
function interruptibleSleep(ms, signal) {
|
|
29011
|
-
return new Promise((resolve2, reject) => {
|
|
29012
|
-
if (signal?.aborted) {
|
|
29013
|
-
reject(abortError(signal));
|
|
29014
|
-
return;
|
|
29015
|
-
}
|
|
29016
|
-
let onAbort;
|
|
29017
|
-
const cleanup = () => {
|
|
29018
|
-
if (onAbort) {
|
|
29019
|
-
signal?.removeEventListener("abort", onAbort);
|
|
29020
|
-
}
|
|
29021
|
-
};
|
|
29022
|
-
const timer = setTimeout(() => {
|
|
29023
|
-
cleanup();
|
|
29024
|
-
resolve2();
|
|
29025
|
-
}, ms);
|
|
29026
|
-
if (signal) {
|
|
29027
|
-
onAbort = () => {
|
|
29028
|
-
clearTimeout(timer);
|
|
29029
|
-
cleanup();
|
|
29030
|
-
reject(abortError(signal));
|
|
29031
|
-
};
|
|
29032
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
27704
|
+
};
|
|
27705
|
+
const timer = setTimeout(() => {
|
|
27706
|
+
cleanup();
|
|
27707
|
+
resolve2();
|
|
27708
|
+
}, ms);
|
|
27709
|
+
if (signal) {
|
|
27710
|
+
onAbort = () => {
|
|
27711
|
+
clearTimeout(timer);
|
|
27712
|
+
cleanup();
|
|
27713
|
+
reject(abortError(signal));
|
|
27714
|
+
};
|
|
27715
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
29033
27716
|
}
|
|
29034
27717
|
});
|
|
29035
27718
|
}
|
|
@@ -29353,6 +28036,17 @@ var FAILURE_STATUSES = new Set([
|
|
|
29353
28036
|
"canceled",
|
|
29354
28037
|
"stopped"
|
|
29355
28038
|
]);
|
|
28039
|
+
// ../common/src/preview.ts
|
|
28040
|
+
var previewSlot = singleton("PreviewBuild");
|
|
28041
|
+
function isPreviewBuild() {
|
|
28042
|
+
return previewSlot.get(false) ?? false;
|
|
28043
|
+
}
|
|
28044
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
28045
|
+
if (isPreviewBuild()) {
|
|
28046
|
+
return this.command(nameAndArgs, opts);
|
|
28047
|
+
}
|
|
28048
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
28049
|
+
};
|
|
29356
28050
|
// ../common/src/screen-logger.ts
|
|
29357
28051
|
var ScreenLogger;
|
|
29358
28052
|
((ScreenLogger) => {
|
|
@@ -29385,8 +28079,8 @@ function appendUserAgentToken(value, userAgent) {
|
|
|
29385
28079
|
function getEffectiveUserAgent(userAgent) {
|
|
29386
28080
|
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
29387
28081
|
}
|
|
29388
|
-
function
|
|
29389
|
-
return
|
|
28082
|
+
function getHeaderName(headers, headerName) {
|
|
28083
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
29390
28084
|
}
|
|
29391
28085
|
function getSdkUserAgentToken(pkg) {
|
|
29392
28086
|
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
@@ -29394,59 +28088,31 @@ function getSdkUserAgentToken(pkg) {
|
|
|
29394
28088
|
}
|
|
29395
28089
|
function addSdkUserAgentHeader(headers, userAgent) {
|
|
29396
28090
|
const result = { ...headers ?? {} };
|
|
29397
|
-
const
|
|
29398
|
-
|
|
29399
|
-
if (headerName) {
|
|
29400
|
-
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
29401
|
-
} else {
|
|
29402
|
-
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
29403
|
-
}
|
|
28091
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
28092
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
29404
28093
|
return result;
|
|
29405
28094
|
}
|
|
29406
|
-
function
|
|
29407
|
-
|
|
29408
|
-
if (isHeadersLike(headers)) {
|
|
29409
|
-
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
29410
|
-
return headers;
|
|
29411
|
-
}
|
|
29412
|
-
if (Array.isArray(headers)) {
|
|
29413
|
-
const result = headers.map((entry) => {
|
|
29414
|
-
const [key, value] = entry;
|
|
29415
|
-
return [key, value];
|
|
29416
|
-
});
|
|
29417
|
-
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
29418
|
-
if (headerIndex >= 0) {
|
|
29419
|
-
const [key, value] = result[headerIndex];
|
|
29420
|
-
result[headerIndex] = [
|
|
29421
|
-
key,
|
|
29422
|
-
appendUserAgentToken(value, effectiveUserAgent)
|
|
29423
|
-
];
|
|
29424
|
-
} else {
|
|
29425
|
-
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
29426
|
-
}
|
|
29427
|
-
return result;
|
|
29428
|
-
}
|
|
29429
|
-
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
28095
|
+
function asHeaderRecord(headers) {
|
|
28096
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
29430
28097
|
}
|
|
29431
|
-
function
|
|
28098
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
29432
28099
|
return async (requestContext) => {
|
|
29433
|
-
const
|
|
28100
|
+
const initWithHeaders = {
|
|
29434
28101
|
...requestContext.init,
|
|
29435
|
-
headers:
|
|
28102
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
29436
28103
|
};
|
|
29437
28104
|
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
29438
28105
|
...requestContext,
|
|
29439
|
-
init:
|
|
28106
|
+
init: initWithHeaders
|
|
29440
28107
|
}) : initOverrides;
|
|
29441
28108
|
return {
|
|
29442
28109
|
...override ?? {},
|
|
29443
|
-
headers:
|
|
28110
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
29444
28111
|
};
|
|
29445
28112
|
};
|
|
29446
28113
|
}
|
|
29447
|
-
function
|
|
28114
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
29448
28115
|
const prototype = BaseApiClass.prototype;
|
|
29449
|
-
const patchKey = userAgentPatchKey(userAgent);
|
|
29450
28116
|
if (prototype[patchKey]) {
|
|
29451
28117
|
return;
|
|
29452
28118
|
}
|
|
@@ -29454,13 +28120,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
|
29454
28120
|
throw new Error("Generated BaseAPI request function not found.");
|
|
29455
28121
|
}
|
|
29456
28122
|
const originalRequest = prototype.request;
|
|
29457
|
-
prototype.request = function
|
|
29458
|
-
return originalRequest.call(this, context,
|
|
28123
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
28124
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
29459
28125
|
};
|
|
29460
28126
|
Object.defineProperty(prototype, patchKey, {
|
|
29461
28127
|
value: true
|
|
29462
28128
|
});
|
|
29463
28129
|
}
|
|
28130
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
28131
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
28132
|
+
}
|
|
29464
28133
|
// ../common/src/tool-provider.ts
|
|
29465
28134
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
29466
28135
|
// ../sc-sdk/generated/src/runtime.ts
|
|
@@ -29728,7 +28397,7 @@ class VoidApiResponse {
|
|
|
29728
28397
|
var package_default2 = {
|
|
29729
28398
|
name: "@uipath/sc-sdk",
|
|
29730
28399
|
license: "MIT",
|
|
29731
|
-
version: "1.
|
|
28400
|
+
version: "1.197.0",
|
|
29732
28401
|
description: "SDK for the UiPath SourceControl API — connections, repositories, automation projects, solutions.",
|
|
29733
28402
|
repository: {
|
|
29734
28403
|
type: "git",
|
|
@@ -29758,7 +28427,7 @@ var package_default2 = {
|
|
|
29758
28427
|
],
|
|
29759
28428
|
private: true,
|
|
29760
28429
|
scripts: {
|
|
29761
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
28430
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
29762
28431
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
29763
28432
|
lint: "biome check ."
|
|
29764
28433
|
},
|
|
@@ -30958,6 +29627,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
30958
29627
|
}
|
|
30959
29628
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
30960
29629
|
};
|
|
29630
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
29631
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
29632
|
+
if (isExternalAppAuth)
|
|
29633
|
+
return requestedScopes;
|
|
29634
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
29635
|
+
};
|
|
30961
29636
|
var resolveConfigAsync = async ({
|
|
30962
29637
|
customAuthority,
|
|
30963
29638
|
customClientId,
|
|
@@ -30988,7 +29663,7 @@ var resolveConfigAsync = async ({
|
|
|
30988
29663
|
clientSecret = fileAuth.clientSecret;
|
|
30989
29664
|
}
|
|
30990
29665
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
30991
|
-
const scopes =
|
|
29666
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
30992
29667
|
return {
|
|
30993
29668
|
clientId,
|
|
30994
29669
|
clientSecret,
|
|
@@ -31003,6 +29678,76 @@ var resolveConfigAsync = async ({
|
|
|
31003
29678
|
init_constants();
|
|
31004
29679
|
// ../auth/src/loginStatus.ts
|
|
31005
29680
|
init_src();
|
|
29681
|
+
|
|
29682
|
+
// ../auth/src/authProfile.ts
|
|
29683
|
+
init_src();
|
|
29684
|
+
init_constants();
|
|
29685
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
29686
|
+
var PROFILE_DIR = "profiles";
|
|
29687
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
29688
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
29689
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
29690
|
+
var globalSlot2 = globalThis;
|
|
29691
|
+
function isAuthProfileStorage(value) {
|
|
29692
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
29693
|
+
}
|
|
29694
|
+
function createProfileStorage() {
|
|
29695
|
+
const [error, mod2] = catchError2(() => __require("node:async_hooks"));
|
|
29696
|
+
if (error || typeof mod2?.AsyncLocalStorage !== "function") {
|
|
29697
|
+
return {
|
|
29698
|
+
getStore: () => {
|
|
29699
|
+
return;
|
|
29700
|
+
},
|
|
29701
|
+
run: (_store, fn) => fn()
|
|
29702
|
+
};
|
|
29703
|
+
}
|
|
29704
|
+
return new mod2.AsyncLocalStorage;
|
|
29705
|
+
}
|
|
29706
|
+
function getProfileStorage() {
|
|
29707
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
29708
|
+
if (isAuthProfileStorage(existing)) {
|
|
29709
|
+
return existing;
|
|
29710
|
+
}
|
|
29711
|
+
const storage = createProfileStorage();
|
|
29712
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
29713
|
+
return storage;
|
|
29714
|
+
}
|
|
29715
|
+
var profileStorage = getProfileStorage();
|
|
29716
|
+
|
|
29717
|
+
class AuthProfileValidationError extends Error {
|
|
29718
|
+
constructor(message) {
|
|
29719
|
+
super(message);
|
|
29720
|
+
this.name = "AuthProfileValidationError";
|
|
29721
|
+
}
|
|
29722
|
+
}
|
|
29723
|
+
function normalizeAuthProfileName(profile) {
|
|
29724
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
29725
|
+
return;
|
|
29726
|
+
}
|
|
29727
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
29728
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
29729
|
+
}
|
|
29730
|
+
return profile;
|
|
29731
|
+
}
|
|
29732
|
+
function getActiveAuthProfile() {
|
|
29733
|
+
const scopedState = profileStorage.getStore();
|
|
29734
|
+
if (scopedState !== undefined) {
|
|
29735
|
+
return scopedState.profile;
|
|
29736
|
+
}
|
|
29737
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
29738
|
+
}
|
|
29739
|
+
function resolveAuthProfileFilePath(profile) {
|
|
29740
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
29741
|
+
if (normalized === undefined) {
|
|
29742
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
29743
|
+
}
|
|
29744
|
+
const fs7 = getFileSystem();
|
|
29745
|
+
return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
29746
|
+
}
|
|
29747
|
+
function getActiveAuthProfileFilePath() {
|
|
29748
|
+
const profile = getActiveAuthProfile();
|
|
29749
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
29750
|
+
}
|
|
31006
29751
|
// ../auth/src/utils/jwt.ts
|
|
31007
29752
|
class InvalidIssuerError extends Error {
|
|
31008
29753
|
expected;
|
|
@@ -31131,23 +29876,74 @@ var readAuthFromEnv = () => {
|
|
|
31131
29876
|
organizationId,
|
|
31132
29877
|
tenantName,
|
|
31133
29878
|
tenantId,
|
|
31134
|
-
expiration
|
|
29879
|
+
expiration,
|
|
29880
|
+
source: "env" /* Env */
|
|
31135
29881
|
};
|
|
31136
29882
|
};
|
|
31137
29883
|
|
|
29884
|
+
// ../auth/src/refreshCircuitBreaker.ts
|
|
29885
|
+
init_src();
|
|
29886
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
29887
|
+
var BACKOFF_BASE_MS = 60000;
|
|
29888
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
29889
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
29890
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
29891
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
29892
|
+
if (globalThis.crypto?.subtle) {
|
|
29893
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
29894
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
29895
|
+
}
|
|
29896
|
+
const { createHash } = await import("node:crypto");
|
|
29897
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
29898
|
+
}
|
|
29899
|
+
function breakerPathFor(authPath) {
|
|
29900
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
29901
|
+
}
|
|
29902
|
+
async function loadRefreshBreaker(authPath) {
|
|
29903
|
+
const fs7 = getFileSystem();
|
|
29904
|
+
try {
|
|
29905
|
+
const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
|
|
29906
|
+
if (!content)
|
|
29907
|
+
return {};
|
|
29908
|
+
const parsed = JSON.parse(content);
|
|
29909
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
29910
|
+
} catch {
|
|
29911
|
+
return {};
|
|
29912
|
+
}
|
|
29913
|
+
}
|
|
29914
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
29915
|
+
try {
|
|
29916
|
+
const fs7 = getFileSystem();
|
|
29917
|
+
const path3 = breakerPathFor(authPath);
|
|
29918
|
+
await fs7.mkdir(fs7.path.dirname(path3));
|
|
29919
|
+
const tempPath = `${path3}.tmp`;
|
|
29920
|
+
await fs7.writeFile(tempPath, JSON.stringify(state));
|
|
29921
|
+
await fs7.rename(tempPath, path3);
|
|
29922
|
+
} catch {}
|
|
29923
|
+
}
|
|
29924
|
+
async function clearRefreshBreaker(authPath) {
|
|
29925
|
+
const fs7 = getFileSystem();
|
|
29926
|
+
const path3 = breakerPathFor(authPath);
|
|
29927
|
+
try {
|
|
29928
|
+
if (await fs7.exists(path3)) {
|
|
29929
|
+
await fs7.rm(path3);
|
|
29930
|
+
}
|
|
29931
|
+
} catch {}
|
|
29932
|
+
}
|
|
29933
|
+
function nextBackoffMs(attempts) {
|
|
29934
|
+
const shift = Math.max(0, attempts - 1);
|
|
29935
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
29936
|
+
}
|
|
29937
|
+
function shouldSurface(state, nowMs) {
|
|
29938
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
29939
|
+
return true;
|
|
29940
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
29941
|
+
}
|
|
29942
|
+
|
|
31138
29943
|
// ../auth/src/robotClientFallback.ts
|
|
31139
29944
|
init_src();
|
|
31140
29945
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
31141
29946
|
var CLOSE_TIMEOUT_MS = 500;
|
|
31142
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
31143
|
-
var printNoticeOnce = () => {
|
|
31144
|
-
const slot = globalThis;
|
|
31145
|
-
if (slot[NOTICE_SENTINEL])
|
|
31146
|
-
return;
|
|
31147
|
-
slot[NOTICE_SENTINEL] = true;
|
|
31148
|
-
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
31149
|
-
`));
|
|
31150
|
-
};
|
|
31151
29947
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
31152
29948
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
31153
29949
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -31263,7 +30059,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
31263
30059
|
issuerFromToken = issClaim;
|
|
31264
30060
|
}
|
|
31265
30061
|
}
|
|
31266
|
-
printNoticeOnce();
|
|
31267
30062
|
return {
|
|
31268
30063
|
accessToken,
|
|
31269
30064
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -31488,18 +30283,327 @@ var saveEnvFileAsync = async ({
|
|
|
31488
30283
|
};
|
|
31489
30284
|
|
|
31490
30285
|
// ../auth/src/loginStatus.ts
|
|
31491
|
-
|
|
31492
|
-
return
|
|
30286
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
30287
|
+
return getLoginStatusWithDeps(options);
|
|
30288
|
+
};
|
|
30289
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
30290
|
+
const {
|
|
30291
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
30292
|
+
loadEnvFile = loadEnvFileAsync,
|
|
30293
|
+
saveEnvFile = saveEnvFileAsync,
|
|
30294
|
+
getFs = getFileSystem,
|
|
30295
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
30296
|
+
resolveConfig: resolveConfig2 = resolveConfigAsync,
|
|
30297
|
+
robotFallback = tryRobotClientFallback,
|
|
30298
|
+
loadBreaker = loadRefreshBreaker,
|
|
30299
|
+
saveBreaker = saveRefreshBreaker,
|
|
30300
|
+
clearBreaker = clearRefreshBreaker
|
|
30301
|
+
} = deps;
|
|
30302
|
+
if (isRobotAuthEnforced()) {
|
|
30303
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
30304
|
+
}
|
|
30305
|
+
if (isEnvAuthEnabled()) {
|
|
30306
|
+
return readAuthFromEnv();
|
|
30307
|
+
}
|
|
30308
|
+
const activeProfile = getActiveAuthProfile();
|
|
30309
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
30310
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
30311
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
30312
|
+
const { ensureTokenValidityMinutes } = options;
|
|
30313
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
30314
|
+
if (absolutePath === undefined) {
|
|
30315
|
+
if (usingActiveProfile) {
|
|
30316
|
+
return {
|
|
30317
|
+
loginStatus: "Not logged in",
|
|
30318
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
30319
|
+
};
|
|
30320
|
+
}
|
|
30321
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
30322
|
+
}
|
|
30323
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
30324
|
+
if ("status" in loaded) {
|
|
30325
|
+
return loaded.status;
|
|
30326
|
+
}
|
|
30327
|
+
const { credentials } = loaded;
|
|
30328
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
30329
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
30330
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
30331
|
+
let tokens = {
|
|
30332
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
30333
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
30334
|
+
expiration,
|
|
30335
|
+
lockReleaseFailed: false
|
|
30336
|
+
};
|
|
30337
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
30338
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
30339
|
+
const refreshed = await attemptRefresh({
|
|
30340
|
+
absolutePath,
|
|
30341
|
+
credentials,
|
|
30342
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
30343
|
+
refreshToken,
|
|
30344
|
+
expiration,
|
|
30345
|
+
ensureTokenValidityMinutes,
|
|
30346
|
+
getFs,
|
|
30347
|
+
loadEnvFile,
|
|
30348
|
+
saveEnvFile,
|
|
30349
|
+
refreshFn: refreshTokenFn,
|
|
30350
|
+
resolveConfig: resolveConfig2,
|
|
30351
|
+
loadBreaker,
|
|
30352
|
+
saveBreaker,
|
|
30353
|
+
clearBreaker,
|
|
30354
|
+
globalHint
|
|
30355
|
+
});
|
|
30356
|
+
if (refreshed.kind === "terminal") {
|
|
30357
|
+
return refreshed.status;
|
|
30358
|
+
}
|
|
30359
|
+
tokens = refreshed.tokens;
|
|
30360
|
+
}
|
|
30361
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
30362
|
+
};
|
|
30363
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
30364
|
+
if (isEnvAuthEnabled()) {
|
|
30365
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
30366
|
+
}
|
|
30367
|
+
const robotCreds = await robotFallback({ force: true });
|
|
30368
|
+
if (!robotCreds) {
|
|
30369
|
+
return {
|
|
30370
|
+
loginStatus: "Not logged in",
|
|
30371
|
+
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.`
|
|
30372
|
+
};
|
|
30373
|
+
}
|
|
30374
|
+
return buildRobotStatus(robotCreds);
|
|
31493
30375
|
}
|
|
31494
|
-
function
|
|
31495
|
-
|
|
30376
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
30377
|
+
const robotCreds = await robotFallback();
|
|
30378
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
31496
30379
|
}
|
|
31497
|
-
function
|
|
31498
|
-
|
|
30380
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
30381
|
+
let credentials;
|
|
30382
|
+
try {
|
|
30383
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
30384
|
+
} catch (error) {
|
|
30385
|
+
if (isFileNotFoundError(error)) {
|
|
30386
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
30387
|
+
}
|
|
30388
|
+
throw error;
|
|
30389
|
+
}
|
|
30390
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
30391
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
30392
|
+
}
|
|
30393
|
+
return { credentials };
|
|
30394
|
+
}
|
|
30395
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
30396
|
+
const fs7 = getFs();
|
|
30397
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
30398
|
+
if (absolutePath === globalPath)
|
|
30399
|
+
return;
|
|
30400
|
+
if (!await fs7.exists(globalPath))
|
|
30401
|
+
return;
|
|
30402
|
+
try {
|
|
30403
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
30404
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
30405
|
+
return;
|
|
30406
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
30407
|
+
if (globalExp && globalExp <= new Date)
|
|
30408
|
+
return;
|
|
30409
|
+
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.`;
|
|
30410
|
+
} catch {
|
|
30411
|
+
return;
|
|
30412
|
+
}
|
|
31499
30413
|
}
|
|
31500
30414
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
31501
30415
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
31502
30416
|
}
|
|
30417
|
+
async function attemptRefresh(ctx) {
|
|
30418
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
30419
|
+
if (shortCircuit) {
|
|
30420
|
+
return { kind: "terminal", status: shortCircuit };
|
|
30421
|
+
}
|
|
30422
|
+
let release;
|
|
30423
|
+
try {
|
|
30424
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
30425
|
+
} catch (error) {
|
|
30426
|
+
return {
|
|
30427
|
+
kind: "terminal",
|
|
30428
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
30429
|
+
};
|
|
30430
|
+
}
|
|
30431
|
+
let lockedFailure;
|
|
30432
|
+
let lockReleaseFailed = false;
|
|
30433
|
+
let success;
|
|
30434
|
+
try {
|
|
30435
|
+
const outcome = await runRefreshLocked({
|
|
30436
|
+
absolutePath: ctx.absolutePath,
|
|
30437
|
+
refreshToken: ctx.refreshToken,
|
|
30438
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
30439
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
30440
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
30441
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
30442
|
+
refreshFn: ctx.refreshFn,
|
|
30443
|
+
resolveConfig: ctx.resolveConfig,
|
|
30444
|
+
loadBreaker: ctx.loadBreaker,
|
|
30445
|
+
saveBreaker: ctx.saveBreaker,
|
|
30446
|
+
clearBreaker: ctx.clearBreaker
|
|
30447
|
+
});
|
|
30448
|
+
if (outcome.kind === "fail") {
|
|
30449
|
+
lockedFailure = outcome.status;
|
|
30450
|
+
} else {
|
|
30451
|
+
success = outcome;
|
|
30452
|
+
}
|
|
30453
|
+
} finally {
|
|
30454
|
+
try {
|
|
30455
|
+
await release();
|
|
30456
|
+
} catch {
|
|
30457
|
+
lockReleaseFailed = true;
|
|
30458
|
+
}
|
|
30459
|
+
}
|
|
30460
|
+
if (lockedFailure) {
|
|
30461
|
+
const globalHint = await ctx.globalHint();
|
|
30462
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
30463
|
+
return {
|
|
30464
|
+
kind: "terminal",
|
|
30465
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
30466
|
+
};
|
|
30467
|
+
}
|
|
30468
|
+
return {
|
|
30469
|
+
kind: "refreshed",
|
|
30470
|
+
tokens: {
|
|
30471
|
+
accessToken: success?.accessToken,
|
|
30472
|
+
refreshToken: success?.refreshToken,
|
|
30473
|
+
expiration: success?.expiration,
|
|
30474
|
+
tokenRefresh: success?.tokenRefresh,
|
|
30475
|
+
persistenceWarning: success?.persistenceWarning,
|
|
30476
|
+
lockReleaseFailed
|
|
30477
|
+
}
|
|
30478
|
+
};
|
|
30479
|
+
}
|
|
30480
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
30481
|
+
const result = {
|
|
30482
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
30483
|
+
accessToken: tokens.accessToken,
|
|
30484
|
+
refreshToken: tokens.refreshToken,
|
|
30485
|
+
baseUrl: credentials.UIPATH_URL,
|
|
30486
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
30487
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
30488
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
30489
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
30490
|
+
expiration: tokens.expiration,
|
|
30491
|
+
source: "file" /* File */,
|
|
30492
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
30493
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
30494
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
30495
|
+
};
|
|
30496
|
+
if (result.loginStatus === "Expired") {
|
|
30497
|
+
const hint = await globalHint();
|
|
30498
|
+
if (hint) {
|
|
30499
|
+
result.hint = hint;
|
|
30500
|
+
}
|
|
30501
|
+
}
|
|
30502
|
+
return result;
|
|
30503
|
+
}
|
|
30504
|
+
function buildRobotStatus(robotCreds) {
|
|
30505
|
+
return {
|
|
30506
|
+
loginStatus: "Logged in",
|
|
30507
|
+
accessToken: robotCreds.accessToken,
|
|
30508
|
+
baseUrl: robotCreds.baseUrl,
|
|
30509
|
+
organizationName: robotCreds.organizationName,
|
|
30510
|
+
organizationId: robotCreds.organizationId,
|
|
30511
|
+
tenantName: robotCreds.tenantName,
|
|
30512
|
+
tenantId: robotCreds.tenantId,
|
|
30513
|
+
issuer: robotCreds.issuer,
|
|
30514
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
30515
|
+
source: "robot" /* Robot */
|
|
30516
|
+
};
|
|
30517
|
+
}
|
|
30518
|
+
var isFileNotFoundError = (error) => {
|
|
30519
|
+
if (!(error instanceof Object))
|
|
30520
|
+
return false;
|
|
30521
|
+
return error.code === "ENOENT";
|
|
30522
|
+
};
|
|
30523
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
30524
|
+
const {
|
|
30525
|
+
absolutePath,
|
|
30526
|
+
refreshToken,
|
|
30527
|
+
accessToken,
|
|
30528
|
+
credentials,
|
|
30529
|
+
expiration,
|
|
30530
|
+
loadBreaker,
|
|
30531
|
+
saveBreaker,
|
|
30532
|
+
clearBreaker
|
|
30533
|
+
} = ctx;
|
|
30534
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
30535
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
30536
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
30537
|
+
await clearBreaker(absolutePath);
|
|
30538
|
+
breaker.deadTokenFp = undefined;
|
|
30539
|
+
}
|
|
30540
|
+
const nowMs = Date.now();
|
|
30541
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
30542
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
30543
|
+
if (!tokenIsDead && !inBackoff)
|
|
30544
|
+
return;
|
|
30545
|
+
const globalHint = await ctx.globalHint();
|
|
30546
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
30547
|
+
if (!suppressed) {
|
|
30548
|
+
await saveBreaker(absolutePath, {
|
|
30549
|
+
...breaker,
|
|
30550
|
+
lastSurfacedAtMs: nowMs
|
|
30551
|
+
});
|
|
30552
|
+
}
|
|
30553
|
+
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>.";
|
|
30554
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
30555
|
+
return {
|
|
30556
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
30557
|
+
...globalHint ? {
|
|
30558
|
+
accessToken,
|
|
30559
|
+
refreshToken,
|
|
30560
|
+
baseUrl: credentials.UIPATH_URL,
|
|
30561
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
30562
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
30563
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
30564
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
30565
|
+
expiration,
|
|
30566
|
+
source: "file" /* File */
|
|
30567
|
+
} : {},
|
|
30568
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
30569
|
+
refreshCircuitOpen: true,
|
|
30570
|
+
refreshTelemetrySuppressed: suppressed,
|
|
30571
|
+
tokenRefresh: { attempted: false, success: false }
|
|
30572
|
+
};
|
|
30573
|
+
}
|
|
30574
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
30575
|
+
const msg = errorMessage(error);
|
|
30576
|
+
const globalHint = await ctx.globalHint();
|
|
30577
|
+
if (globalHint) {
|
|
30578
|
+
return {
|
|
30579
|
+
loginStatus: "Expired",
|
|
30580
|
+
accessToken: ctx.accessToken,
|
|
30581
|
+
refreshToken: ctx.refreshToken,
|
|
30582
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
30583
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
30584
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
30585
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
30586
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
30587
|
+
expiration: ctx.expiration,
|
|
30588
|
+
source: "file" /* File */,
|
|
30589
|
+
hint: globalHint,
|
|
30590
|
+
tokenRefresh: {
|
|
30591
|
+
attempted: false,
|
|
30592
|
+
success: false,
|
|
30593
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
30594
|
+
}
|
|
30595
|
+
};
|
|
30596
|
+
}
|
|
30597
|
+
return {
|
|
30598
|
+
loginStatus: "Refresh Failed",
|
|
30599
|
+
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.",
|
|
30600
|
+
tokenRefresh: {
|
|
30601
|
+
attempted: false,
|
|
30602
|
+
success: false,
|
|
30603
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
30604
|
+
}
|
|
30605
|
+
};
|
|
30606
|
+
}
|
|
31503
30607
|
async function runRefreshLocked(inputs) {
|
|
31504
30608
|
const {
|
|
31505
30609
|
absolutePath,
|
|
@@ -31509,7 +30613,10 @@ async function runRefreshLocked(inputs) {
|
|
|
31509
30613
|
loadEnvFile,
|
|
31510
30614
|
saveEnvFile,
|
|
31511
30615
|
refreshFn,
|
|
31512
|
-
resolveConfig: resolveConfig2
|
|
30616
|
+
resolveConfig: resolveConfig2,
|
|
30617
|
+
loadBreaker,
|
|
30618
|
+
saveBreaker,
|
|
30619
|
+
clearBreaker
|
|
31513
30620
|
} = inputs;
|
|
31514
30621
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
31515
30622
|
let fresh;
|
|
@@ -31532,6 +30639,7 @@ async function runRefreshLocked(inputs) {
|
|
|
31532
30639
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
31533
30640
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
31534
30641
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
30642
|
+
await clearBreaker(absolutePath);
|
|
31535
30643
|
return {
|
|
31536
30644
|
kind: "ok",
|
|
31537
30645
|
accessToken: freshAccess,
|
|
@@ -31555,8 +30663,21 @@ async function runRefreshLocked(inputs) {
|
|
|
31555
30663
|
refreshedRefresh = refreshed.refreshToken;
|
|
31556
30664
|
} catch (error) {
|
|
31557
30665
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
31558
|
-
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.";
|
|
30666
|
+
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.";
|
|
31559
30667
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
30668
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
30669
|
+
if (isOAuthFailure) {
|
|
30670
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
30671
|
+
} else {
|
|
30672
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
30673
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
30674
|
+
await saveBreaker(absolutePath, {
|
|
30675
|
+
...prior,
|
|
30676
|
+
deadTokenFp: undefined,
|
|
30677
|
+
attempts,
|
|
30678
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
30679
|
+
});
|
|
30680
|
+
}
|
|
31560
30681
|
return {
|
|
31561
30682
|
kind: "fail",
|
|
31562
30683
|
status: {
|
|
@@ -31585,6 +30706,7 @@ async function runRefreshLocked(inputs) {
|
|
|
31585
30706
|
}
|
|
31586
30707
|
};
|
|
31587
30708
|
}
|
|
30709
|
+
await clearBreaker(absolutePath);
|
|
31588
30710
|
try {
|
|
31589
30711
|
await saveEnvFile({
|
|
31590
30712
|
envPath: absolutePath,
|
|
@@ -31617,212 +30739,15 @@ async function runRefreshLocked(inputs) {
|
|
|
31617
30739
|
};
|
|
31618
30740
|
}
|
|
31619
30741
|
}
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31625
|
-
|
|
31626
|
-
|
|
31627
|
-
|
|
31628
|
-
|
|
31629
|
-
} = deps;
|
|
31630
|
-
if (isRobotAuthEnforced()) {
|
|
31631
|
-
if (isEnvAuthEnabled()) {
|
|
31632
|
-
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
31633
|
-
}
|
|
31634
|
-
const robotCreds = await robotFallback({ force: true });
|
|
31635
|
-
if (!robotCreds) {
|
|
31636
|
-
return {
|
|
31637
|
-
loginStatus: "Not logged in",
|
|
31638
|
-
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.`
|
|
31639
|
-
};
|
|
31640
|
-
}
|
|
31641
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
31642
|
-
return {
|
|
31643
|
-
loginStatus: "Logged in",
|
|
31644
|
-
accessToken: robotCreds.accessToken,
|
|
31645
|
-
baseUrl: robotCreds.baseUrl,
|
|
31646
|
-
organizationName: robotCreds.organizationName,
|
|
31647
|
-
organizationId: robotCreds.organizationId,
|
|
31648
|
-
tenantName: robotCreds.tenantName,
|
|
31649
|
-
tenantId: robotCreds.tenantId,
|
|
31650
|
-
issuer: robotCreds.issuer,
|
|
31651
|
-
expiration: expiration2,
|
|
31652
|
-
source: "robot" /* Robot */
|
|
31653
|
-
};
|
|
31654
|
-
}
|
|
31655
|
-
if (isEnvAuthEnabled()) {
|
|
31656
|
-
return readAuthFromEnv();
|
|
31657
|
-
}
|
|
31658
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
31659
|
-
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
31660
|
-
if (absolutePath === undefined) {
|
|
31661
|
-
const robotCreds = await robotFallback();
|
|
31662
|
-
if (robotCreds) {
|
|
31663
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
31664
|
-
const status = {
|
|
31665
|
-
loginStatus: "Logged in",
|
|
31666
|
-
accessToken: robotCreds.accessToken,
|
|
31667
|
-
baseUrl: robotCreds.baseUrl,
|
|
31668
|
-
organizationName: robotCreds.organizationName,
|
|
31669
|
-
organizationId: robotCreds.organizationId,
|
|
31670
|
-
tenantName: robotCreds.tenantName,
|
|
31671
|
-
tenantId: robotCreds.tenantId,
|
|
31672
|
-
issuer: robotCreds.issuer,
|
|
31673
|
-
expiration: expiration2,
|
|
31674
|
-
source: "robot" /* Robot */
|
|
31675
|
-
};
|
|
31676
|
-
return status;
|
|
31677
|
-
}
|
|
31678
|
-
return { loginStatus: "Not logged in" };
|
|
31679
|
-
}
|
|
31680
|
-
let credentials;
|
|
31681
|
-
try {
|
|
31682
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
31683
|
-
} catch (error) {
|
|
31684
|
-
if (isFileNotFoundError(error)) {
|
|
31685
|
-
return { loginStatus: "Not logged in" };
|
|
31686
|
-
}
|
|
31687
|
-
throw error;
|
|
31688
|
-
}
|
|
31689
|
-
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
31690
|
-
return { loginStatus: "Not logged in" };
|
|
31691
|
-
}
|
|
31692
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
31693
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
31694
|
-
let expiration = getTokenExpiration(accessToken);
|
|
31695
|
-
let persistenceWarning;
|
|
31696
|
-
let lockReleaseFailed = false;
|
|
31697
|
-
let tokenRefresh;
|
|
31698
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
31699
|
-
const tryGlobalCredsHint = async () => {
|
|
31700
|
-
const fs7 = getFs();
|
|
31701
|
-
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
31702
|
-
if (absolutePath === globalPath)
|
|
31703
|
-
return;
|
|
31704
|
-
if (!await fs7.exists(globalPath))
|
|
31705
|
-
return;
|
|
31706
|
-
try {
|
|
31707
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
31708
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
31709
|
-
return;
|
|
31710
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
31711
|
-
if (globalExp && globalExp <= new Date)
|
|
31712
|
-
return;
|
|
31713
|
-
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.`;
|
|
31714
|
-
} catch {
|
|
31715
|
-
return;
|
|
31716
|
-
}
|
|
31717
|
-
};
|
|
31718
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
31719
|
-
let release;
|
|
31720
|
-
try {
|
|
31721
|
-
release = await getFs().acquireLock(absolutePath);
|
|
31722
|
-
} catch (error) {
|
|
31723
|
-
const msg = errorMessage(error);
|
|
31724
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31725
|
-
if (globalHint) {
|
|
31726
|
-
return {
|
|
31727
|
-
loginStatus: "Expired",
|
|
31728
|
-
accessToken,
|
|
31729
|
-
refreshToken,
|
|
31730
|
-
baseUrl: credentials.UIPATH_URL,
|
|
31731
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31732
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31733
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31734
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31735
|
-
expiration,
|
|
31736
|
-
source: "file" /* File */,
|
|
31737
|
-
hint: globalHint,
|
|
31738
|
-
tokenRefresh: {
|
|
31739
|
-
attempted: false,
|
|
31740
|
-
success: false,
|
|
31741
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
31742
|
-
}
|
|
31743
|
-
};
|
|
31744
|
-
}
|
|
31745
|
-
return {
|
|
31746
|
-
loginStatus: "Refresh Failed",
|
|
31747
|
-
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.",
|
|
31748
|
-
tokenRefresh: {
|
|
31749
|
-
attempted: false,
|
|
31750
|
-
success: false,
|
|
31751
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
31752
|
-
}
|
|
31753
|
-
};
|
|
31754
|
-
}
|
|
31755
|
-
let lockedFailure;
|
|
31756
|
-
try {
|
|
31757
|
-
const outcome = await runRefreshLocked({
|
|
31758
|
-
absolutePath,
|
|
31759
|
-
refreshToken,
|
|
31760
|
-
customAuthority: credentials.UIPATH_URL,
|
|
31761
|
-
ensureTokenValidityMinutes,
|
|
31762
|
-
loadEnvFile,
|
|
31763
|
-
saveEnvFile,
|
|
31764
|
-
refreshFn: refreshTokenFn,
|
|
31765
|
-
resolveConfig: resolveConfig2
|
|
31766
|
-
});
|
|
31767
|
-
if (outcome.kind === "fail") {
|
|
31768
|
-
lockedFailure = outcome.status;
|
|
31769
|
-
} else {
|
|
31770
|
-
accessToken = outcome.accessToken;
|
|
31771
|
-
refreshToken = outcome.refreshToken;
|
|
31772
|
-
expiration = outcome.expiration;
|
|
31773
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
31774
|
-
if (outcome.persistenceWarning) {
|
|
31775
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
31776
|
-
}
|
|
31777
|
-
}
|
|
31778
|
-
} finally {
|
|
31779
|
-
try {
|
|
31780
|
-
await release();
|
|
31781
|
-
} catch {
|
|
31782
|
-
lockReleaseFailed = true;
|
|
31783
|
-
}
|
|
31784
|
-
}
|
|
31785
|
-
if (lockedFailure) {
|
|
31786
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31787
|
-
const base = globalHint ? {
|
|
31788
|
-
...lockedFailure,
|
|
31789
|
-
loginStatus: "Expired",
|
|
31790
|
-
hint: globalHint
|
|
31791
|
-
} : lockedFailure;
|
|
31792
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
31793
|
-
}
|
|
31794
|
-
}
|
|
31795
|
-
const result = {
|
|
31796
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
31797
|
-
accessToken,
|
|
31798
|
-
refreshToken,
|
|
31799
|
-
baseUrl: credentials.UIPATH_URL,
|
|
31800
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31801
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31802
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31803
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31804
|
-
expiration,
|
|
31805
|
-
source: "file" /* File */,
|
|
31806
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
31807
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
31808
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
31809
|
-
};
|
|
31810
|
-
if (result.loginStatus === "Expired") {
|
|
31811
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31812
|
-
if (globalHint) {
|
|
31813
|
-
result.hint = globalHint;
|
|
31814
|
-
}
|
|
31815
|
-
}
|
|
31816
|
-
return result;
|
|
31817
|
-
};
|
|
31818
|
-
var isFileNotFoundError = (error) => {
|
|
31819
|
-
if (!(error instanceof Object))
|
|
31820
|
-
return false;
|
|
31821
|
-
return error.code === "ENOENT";
|
|
31822
|
-
};
|
|
31823
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
31824
|
-
return getLoginStatusWithDeps(options);
|
|
31825
|
-
};
|
|
30742
|
+
function normalizeTokenRefreshFailure() {
|
|
30743
|
+
return "stored refresh token is invalid or expired";
|
|
30744
|
+
}
|
|
30745
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
30746
|
+
return "token refresh failed before authentication completed";
|
|
30747
|
+
}
|
|
30748
|
+
function errorMessage(error) {
|
|
30749
|
+
return error instanceof Error ? error.message : String(error);
|
|
30750
|
+
}
|
|
31826
30751
|
|
|
31827
30752
|
// ../auth/src/authContext.ts
|
|
31828
30753
|
var getAuthContext = async (options = {}) => {
|
|
@@ -31857,6 +30782,14 @@ var getAuthContext = async (options = {}) => {
|
|
|
31857
30782
|
};
|
|
31858
30783
|
// ../auth/src/interactive.ts
|
|
31859
30784
|
init_src();
|
|
30785
|
+
|
|
30786
|
+
// ../auth/src/selectTenant.ts
|
|
30787
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
30788
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
30789
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
30790
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
30791
|
+
INVALID_TENANT_CODE
|
|
30792
|
+
]);
|
|
31860
30793
|
// ../auth/src/logout.ts
|
|
31861
30794
|
init_src();
|
|
31862
30795
|
|
|
@@ -32147,7 +31080,7 @@ class VoidApiResponse2 {
|
|
|
32147
31080
|
var package_default3 = {
|
|
32148
31081
|
name: "@uipath/cicd-sdk",
|
|
32149
31082
|
license: "MIT",
|
|
32150
|
-
version: "1.
|
|
31083
|
+
version: "1.197.0",
|
|
32151
31084
|
description: "SDK for the UiPath StudioAdmin CICD API — pipelines, pipeline executions, partition configuration.",
|
|
32152
31085
|
repository: {
|
|
32153
31086
|
type: "git",
|
|
@@ -32178,7 +31111,7 @@ var package_default3 = {
|
|
|
32178
31111
|
],
|
|
32179
31112
|
private: true,
|
|
32180
31113
|
scripts: {
|
|
32181
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
31114
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
32182
31115
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
32183
31116
|
lint: "biome check ."
|
|
32184
31117
|
},
|
|
@@ -35918,3 +34851,5 @@ export {
|
|
|
35918
34851
|
registerCommands,
|
|
35919
34852
|
metadata
|
|
35920
34853
|
};
|
|
34854
|
+
|
|
34855
|
+
//# debugId=7F8A564705482C0F64756E2164756E21
|