@uipath/oms-tool 1.196.0 → 1.197.0-preview.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +882 -1917
- package/dist/tool.js +887 -1921
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -11440,8 +11440,8 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
11440
11440
|
if (_parentOrParents instanceof Subscription2) {
|
|
11441
11441
|
_parentOrParents.remove(this);
|
|
11442
11442
|
} else if (_parentOrParents !== null) {
|
|
11443
|
-
for (var
|
|
11444
|
-
var parent_1 = _parentOrParents[
|
|
11443
|
+
for (var index = 0;index < _parentOrParents.length; ++index) {
|
|
11444
|
+
var parent_1 = _parentOrParents[index];
|
|
11445
11445
|
parent_1.remove(this);
|
|
11446
11446
|
}
|
|
11447
11447
|
}
|
|
@@ -11456,10 +11456,10 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
11456
11456
|
}
|
|
11457
11457
|
}
|
|
11458
11458
|
if (isArray_1.isArray(_subscriptions)) {
|
|
11459
|
-
var
|
|
11459
|
+
var index = -1;
|
|
11460
11460
|
var len = _subscriptions.length;
|
|
11461
|
-
while (++
|
|
11462
|
-
var sub2 = _subscriptions[
|
|
11461
|
+
while (++index < len) {
|
|
11462
|
+
var sub2 = _subscriptions[index];
|
|
11463
11463
|
if (isObject_1.isObject(sub2)) {
|
|
11464
11464
|
try {
|
|
11465
11465
|
sub2.unsubscribe();
|
|
@@ -12889,13 +12889,13 @@ var require_AsyncAction = __commonJS((exports) => {
|
|
|
12889
12889
|
var id = this.id;
|
|
12890
12890
|
var scheduler = this.scheduler;
|
|
12891
12891
|
var actions = scheduler.actions;
|
|
12892
|
-
var
|
|
12892
|
+
var index = actions.indexOf(this);
|
|
12893
12893
|
this.work = null;
|
|
12894
12894
|
this.state = null;
|
|
12895
12895
|
this.pending = false;
|
|
12896
12896
|
this.scheduler = null;
|
|
12897
|
-
if (
|
|
12898
|
-
actions.splice(
|
|
12897
|
+
if (index !== -1) {
|
|
12898
|
+
actions.splice(index, 1);
|
|
12899
12899
|
}
|
|
12900
12900
|
if (id != null) {
|
|
12901
12901
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
@@ -13739,17 +13739,17 @@ var require_AsapScheduler = __commonJS((exports) => {
|
|
|
13739
13739
|
this.scheduled = undefined;
|
|
13740
13740
|
var actions = this.actions;
|
|
13741
13741
|
var error;
|
|
13742
|
-
var
|
|
13742
|
+
var index = -1;
|
|
13743
13743
|
var count = actions.length;
|
|
13744
13744
|
action = action || actions.shift();
|
|
13745
13745
|
do {
|
|
13746
13746
|
if (error = action.execute(action.state, action.delay)) {
|
|
13747
13747
|
break;
|
|
13748
13748
|
}
|
|
13749
|
-
} while (++
|
|
13749
|
+
} while (++index < count && (action = actions.shift()));
|
|
13750
13750
|
this.active = false;
|
|
13751
13751
|
if (error) {
|
|
13752
|
-
while (++
|
|
13752
|
+
while (++index < count && (action = actions.shift())) {
|
|
13753
13753
|
action.unsubscribe();
|
|
13754
13754
|
}
|
|
13755
13755
|
throw error;
|
|
@@ -13872,17 +13872,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
|
|
|
13872
13872
|
this.scheduled = undefined;
|
|
13873
13873
|
var actions = this.actions;
|
|
13874
13874
|
var error;
|
|
13875
|
-
var
|
|
13875
|
+
var index = -1;
|
|
13876
13876
|
var count = actions.length;
|
|
13877
13877
|
action = action || actions.shift();
|
|
13878
13878
|
do {
|
|
13879
13879
|
if (error = action.execute(action.state, action.delay)) {
|
|
13880
13880
|
break;
|
|
13881
13881
|
}
|
|
13882
|
-
} while (++
|
|
13882
|
+
} while (++index < count && (action = actions.shift()));
|
|
13883
13883
|
this.active = false;
|
|
13884
13884
|
if (error) {
|
|
13885
|
-
while (++
|
|
13885
|
+
while (++index < count && (action = actions.shift())) {
|
|
13886
13886
|
action.unsubscribe();
|
|
13887
13887
|
}
|
|
13888
13888
|
throw error;
|
|
@@ -13966,16 +13966,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
|
|
|
13966
13966
|
exports.VirtualTimeScheduler = VirtualTimeScheduler;
|
|
13967
13967
|
var VirtualAction = function(_super) {
|
|
13968
13968
|
__extends(VirtualAction2, _super);
|
|
13969
|
-
function VirtualAction2(scheduler, work,
|
|
13970
|
-
if (
|
|
13971
|
-
|
|
13969
|
+
function VirtualAction2(scheduler, work, index) {
|
|
13970
|
+
if (index === undefined) {
|
|
13971
|
+
index = scheduler.index += 1;
|
|
13972
13972
|
}
|
|
13973
13973
|
var _this = _super.call(this, scheduler, work) || this;
|
|
13974
13974
|
_this.scheduler = scheduler;
|
|
13975
13975
|
_this.work = work;
|
|
13976
|
-
_this.index =
|
|
13976
|
+
_this.index = index;
|
|
13977
13977
|
_this.active = true;
|
|
13978
|
-
_this.index = scheduler.index =
|
|
13978
|
+
_this.index = scheduler.index = index;
|
|
13979
13979
|
return _this;
|
|
13980
13980
|
}
|
|
13981
13981
|
VirtualAction2.prototype.schedule = function(state, delay) {
|
|
@@ -15122,9 +15122,9 @@ var require_mergeMap = __commonJS((exports) => {
|
|
|
15122
15122
|
};
|
|
15123
15123
|
MergeMapSubscriber2.prototype._tryNext = function(value) {
|
|
15124
15124
|
var result;
|
|
15125
|
-
var
|
|
15125
|
+
var index = this.index++;
|
|
15126
15126
|
try {
|
|
15127
|
-
result = this.project(value,
|
|
15127
|
+
result = this.project(value, index);
|
|
15128
15128
|
} catch (err) {
|
|
15129
15129
|
this.destination.error(err);
|
|
15130
15130
|
return;
|
|
@@ -15704,12 +15704,12 @@ var require_pairs2 = __commonJS((exports) => {
|
|
|
15704
15704
|
}
|
|
15705
15705
|
exports.pairs = pairs;
|
|
15706
15706
|
function dispatch(state) {
|
|
15707
|
-
var { keys, index
|
|
15707
|
+
var { keys, index, subscriber, subscription, obj } = state;
|
|
15708
15708
|
if (!subscriber.closed) {
|
|
15709
|
-
if (
|
|
15710
|
-
var key = keys[
|
|
15709
|
+
if (index < keys.length) {
|
|
15710
|
+
var key = keys[index];
|
|
15711
15711
|
subscriber.next([key, obj[key]]);
|
|
15712
|
-
subscription.add(this.schedule({ keys, index:
|
|
15712
|
+
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
|
15713
15713
|
} else {
|
|
15714
15714
|
subscriber.complete();
|
|
15715
15715
|
}
|
|
@@ -15922,18 +15922,18 @@ var require_range = __commonJS((exports) => {
|
|
|
15922
15922
|
count = start;
|
|
15923
15923
|
start = 0;
|
|
15924
15924
|
}
|
|
15925
|
-
var
|
|
15925
|
+
var index = 0;
|
|
15926
15926
|
var current = start;
|
|
15927
15927
|
if (scheduler) {
|
|
15928
15928
|
return scheduler.schedule(dispatch, 0, {
|
|
15929
|
-
index
|
|
15929
|
+
index,
|
|
15930
15930
|
count,
|
|
15931
15931
|
start,
|
|
15932
15932
|
subscriber
|
|
15933
15933
|
});
|
|
15934
15934
|
} else {
|
|
15935
15935
|
do {
|
|
15936
|
-
if (
|
|
15936
|
+
if (index++ >= count) {
|
|
15937
15937
|
subscriber.complete();
|
|
15938
15938
|
break;
|
|
15939
15939
|
}
|
|
@@ -15948,8 +15948,8 @@ var require_range = __commonJS((exports) => {
|
|
|
15948
15948
|
}
|
|
15949
15949
|
exports.range = range;
|
|
15950
15950
|
function dispatch(state) {
|
|
15951
|
-
var { start, index
|
|
15952
|
-
if (
|
|
15951
|
+
var { start, index, count, subscriber } = state;
|
|
15952
|
+
if (index >= count) {
|
|
15953
15953
|
subscriber.complete();
|
|
15954
15954
|
return;
|
|
15955
15955
|
}
|
|
@@ -15957,7 +15957,7 @@ var require_range = __commonJS((exports) => {
|
|
|
15957
15957
|
if (subscriber.closed) {
|
|
15958
15958
|
return;
|
|
15959
15959
|
}
|
|
15960
|
-
state.index =
|
|
15960
|
+
state.index = index + 1;
|
|
15961
15961
|
state.start = start + 1;
|
|
15962
15962
|
this.schedule(state);
|
|
15963
15963
|
}
|
|
@@ -15995,14 +15995,14 @@ var require_timer = __commonJS((exports) => {
|
|
|
15995
15995
|
}
|
|
15996
15996
|
exports.timer = timer;
|
|
15997
15997
|
function dispatch(state) {
|
|
15998
|
-
var { index
|
|
15999
|
-
subscriber.next(
|
|
15998
|
+
var { index, period, subscriber } = state;
|
|
15999
|
+
subscriber.next(index);
|
|
16000
16000
|
if (subscriber.closed) {
|
|
16001
16001
|
return;
|
|
16002
16002
|
} else if (period === -1) {
|
|
16003
16003
|
return subscriber.complete();
|
|
16004
16004
|
}
|
|
16005
|
-
state.index =
|
|
16005
|
+
state.index = index + 1;
|
|
16006
16006
|
this.schedule(state, period);
|
|
16007
16007
|
}
|
|
16008
16008
|
});
|
|
@@ -19150,7 +19150,7 @@ var init_server = __esm(() => {
|
|
|
19150
19150
|
var package_default = {
|
|
19151
19151
|
name: "@uipath/oms-tool",
|
|
19152
19152
|
license: "MIT",
|
|
19153
|
-
version: "1.
|
|
19153
|
+
version: "1.197.0-preview.59",
|
|
19154
19154
|
description: "CLI plugin for the UiPath Organization Management Service.",
|
|
19155
19155
|
private: false,
|
|
19156
19156
|
repository: {
|
|
@@ -19176,7 +19176,7 @@ var package_default = {
|
|
|
19176
19176
|
"dist"
|
|
19177
19177
|
],
|
|
19178
19178
|
scripts: {
|
|
19179
|
-
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander && bun build ./src/index.ts --outdir dist --format esm --target node",
|
|
19179
|
+
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander --sourcemap=linked && bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked",
|
|
19180
19180
|
package: "bun run build && bun pm pack",
|
|
19181
19181
|
lint: "biome check .",
|
|
19182
19182
|
"lint:fix": "biome check --write .",
|
|
@@ -19240,27 +19240,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
19240
19240
|
"ENETUNREACH",
|
|
19241
19241
|
"EAI_FAIL"
|
|
19242
19242
|
]);
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
|
|
19251
|
-
|
|
19252
|
-
|
|
19253
|
-
|
|
19254
|
-
|
|
19255
|
-
|
|
19256
|
-
|
|
19257
|
-
|
|
19258
|
-
|
|
19259
|
-
|
|
19243
|
+
var TLS_ERROR_CODES = new Set([
|
|
19244
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
19245
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
19246
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
19247
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
19248
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
19249
|
+
"CERT_HAS_EXPIRED",
|
|
19250
|
+
"CERT_UNTRUSTED",
|
|
19251
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
19252
|
+
]);
|
|
19253
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
19254
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
19255
|
+
function describeConnectivityError(error) {
|
|
19256
|
+
let current = error;
|
|
19257
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
19258
|
+
const cur = current;
|
|
19259
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
19260
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
19261
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
19262
|
+
return {
|
|
19263
|
+
code,
|
|
19264
|
+
kind: "tls",
|
|
19265
|
+
message: message ?? code,
|
|
19266
|
+
instructions: TLS_INSTRUCTIONS
|
|
19267
|
+
};
|
|
19268
|
+
}
|
|
19269
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
19270
|
+
return {
|
|
19271
|
+
code,
|
|
19272
|
+
kind: "network",
|
|
19273
|
+
message: message ?? code,
|
|
19274
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
19275
|
+
};
|
|
19260
19276
|
}
|
|
19277
|
+
current = cur.cause;
|
|
19261
19278
|
}
|
|
19262
19279
|
return;
|
|
19263
19280
|
}
|
|
19281
|
+
function parseHttpStatusFromMessage(message) {
|
|
19282
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
19283
|
+
if (!match)
|
|
19284
|
+
return;
|
|
19285
|
+
const status = Number(match[1]);
|
|
19286
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
19287
|
+
}
|
|
19288
|
+
function isHtmlDocument(body) {
|
|
19289
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
19290
|
+
}
|
|
19264
19291
|
function retryHintForRetryAfter(seconds) {
|
|
19265
19292
|
if (seconds <= 1) {
|
|
19266
19293
|
return "RetryAfter1Second";
|
|
@@ -19301,15 +19328,28 @@ function classifyError(status, error) {
|
|
|
19301
19328
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
19302
19329
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
19303
19330
|
}
|
|
19304
|
-
|
|
19305
|
-
|
|
19331
|
+
const connectivity = describeConnectivityError(error);
|
|
19332
|
+
if (connectivity) {
|
|
19333
|
+
return {
|
|
19334
|
+
errorCode: "network_error",
|
|
19335
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
19336
|
+
};
|
|
19306
19337
|
}
|
|
19307
19338
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
19308
19339
|
}
|
|
19340
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
19341
|
+
if (extractedMessage) {
|
|
19342
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
19343
|
+
}
|
|
19344
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
19345
|
+
}
|
|
19309
19346
|
async function extractErrorDetails(error, options) {
|
|
19310
19347
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
19311
19348
|
const response = err.response;
|
|
19312
|
-
const
|
|
19349
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
19350
|
+
const explicitStatus = err.status ?? response?.status;
|
|
19351
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
19352
|
+
const status = explicitStatus ?? inferredStatus;
|
|
19313
19353
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
19314
19354
|
let rawBody;
|
|
19315
19355
|
let extractedMessage;
|
|
@@ -19344,7 +19384,6 @@ async function extractErrorDetails(error, options) {
|
|
|
19344
19384
|
}
|
|
19345
19385
|
}
|
|
19346
19386
|
}
|
|
19347
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
19348
19387
|
let message;
|
|
19349
19388
|
let result = "Failure";
|
|
19350
19389
|
const classification = classifyError(status, error);
|
|
@@ -19358,10 +19397,10 @@ async function extractErrorDetails(error, options) {
|
|
|
19358
19397
|
} else if (status === 405) {
|
|
19359
19398
|
message = DEFAULT_405;
|
|
19360
19399
|
} else if (status === 400 || status === 422) {
|
|
19361
|
-
message =
|
|
19400
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
19362
19401
|
result = "ValidationError";
|
|
19363
19402
|
} else if (status === 429) {
|
|
19364
|
-
message =
|
|
19403
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
19365
19404
|
} else if (extractedMessage) {
|
|
19366
19405
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
19367
19406
|
message = rawMessage;
|
|
@@ -19369,7 +19408,9 @@ async function extractErrorDetails(error, options) {
|
|
|
19369
19408
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
19370
19409
|
}
|
|
19371
19410
|
} else if (status) {
|
|
19372
|
-
if (
|
|
19411
|
+
if (inferredStatus !== undefined) {
|
|
19412
|
+
message = rawMessage;
|
|
19413
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
19373
19414
|
const statusText = response.statusText;
|
|
19374
19415
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
19375
19416
|
} else {
|
|
@@ -19378,6 +19419,12 @@ async function extractErrorDetails(error, options) {
|
|
|
19378
19419
|
} else {
|
|
19379
19420
|
message = rawMessage;
|
|
19380
19421
|
}
|
|
19422
|
+
if (status === undefined) {
|
|
19423
|
+
const connectivity = describeConnectivityError(error);
|
|
19424
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
19425
|
+
message = `${message}: ${connectivity.message}`;
|
|
19426
|
+
}
|
|
19427
|
+
}
|
|
19381
19428
|
let details = rawMessage;
|
|
19382
19429
|
if (rawBody) {
|
|
19383
19430
|
if (parsedBody) {
|
|
@@ -19530,6 +19577,7 @@ var CONSOLE_FALLBACK = {
|
|
|
19530
19577
|
writeLog: (str) => process.stdout.write(str),
|
|
19531
19578
|
capabilities: {
|
|
19532
19579
|
isInteractive: false,
|
|
19580
|
+
canReadInput: false,
|
|
19533
19581
|
supportsColor: false,
|
|
19534
19582
|
outputWidth: 80
|
|
19535
19583
|
}
|
|
@@ -24730,6 +24778,29 @@ function isPlainRecord(value) {
|
|
|
24730
24778
|
const prototype = Object.getPrototypeOf(value);
|
|
24731
24779
|
return prototype === Object.prototype || prototype === null;
|
|
24732
24780
|
}
|
|
24781
|
+
function extractPagedRows(value) {
|
|
24782
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
24783
|
+
return null;
|
|
24784
|
+
const entries = Object.values(value);
|
|
24785
|
+
if (entries.length === 0)
|
|
24786
|
+
return null;
|
|
24787
|
+
let rows = null;
|
|
24788
|
+
let hasScalarSibling = false;
|
|
24789
|
+
for (const entry of entries) {
|
|
24790
|
+
if (Array.isArray(entry)) {
|
|
24791
|
+
if (rows !== null)
|
|
24792
|
+
return null;
|
|
24793
|
+
rows = entry;
|
|
24794
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
24795
|
+
return null;
|
|
24796
|
+
} else {
|
|
24797
|
+
hasScalarSibling = true;
|
|
24798
|
+
}
|
|
24799
|
+
}
|
|
24800
|
+
if (rows === null || !hasScalarSibling)
|
|
24801
|
+
return null;
|
|
24802
|
+
return rows;
|
|
24803
|
+
}
|
|
24733
24804
|
function toLowerCamelCaseKey(key) {
|
|
24734
24805
|
if (!key)
|
|
24735
24806
|
return key;
|
|
@@ -24794,7 +24865,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
24794
24865
|
break;
|
|
24795
24866
|
case "plain": {
|
|
24796
24867
|
if ("Data" in data && data.Data != null) {
|
|
24797
|
-
const
|
|
24868
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
24869
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
24798
24870
|
items.forEach((item) => {
|
|
24799
24871
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
24800
24872
|
logFn(values);
|
|
@@ -24806,10 +24878,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
24806
24878
|
break;
|
|
24807
24879
|
}
|
|
24808
24880
|
default: {
|
|
24809
|
-
|
|
24881
|
+
const hasData = "Data" in data && data.Data != null;
|
|
24882
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
24883
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
24884
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
24810
24885
|
const logValue = data.Log;
|
|
24811
|
-
if (
|
|
24812
|
-
printResizableTable(
|
|
24886
|
+
if (rows !== null) {
|
|
24887
|
+
printResizableTable(rows, logFn, logValue);
|
|
24813
24888
|
} else {
|
|
24814
24889
|
printVerticalTable(data.Data, logFn, logValue);
|
|
24815
24890
|
}
|
|
@@ -24997,6 +25072,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
24997
25072
|
return "unknown_error";
|
|
24998
25073
|
}
|
|
24999
25074
|
}
|
|
25075
|
+
function parseHttpStatusFromMessage2(message) {
|
|
25076
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
25077
|
+
if (!match)
|
|
25078
|
+
return;
|
|
25079
|
+
const status = Number(match[1]);
|
|
25080
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
25081
|
+
}
|
|
25082
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
25083
|
+
if (status === undefined)
|
|
25084
|
+
return;
|
|
25085
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
25086
|
+
return "invalid_argument";
|
|
25087
|
+
}
|
|
25088
|
+
if (status === 401)
|
|
25089
|
+
return "authentication_required";
|
|
25090
|
+
if (status === 403)
|
|
25091
|
+
return "permission_denied";
|
|
25092
|
+
if (status === 404)
|
|
25093
|
+
return "not_found";
|
|
25094
|
+
if (status === 405)
|
|
25095
|
+
return "method_not_allowed";
|
|
25096
|
+
if (status === 408)
|
|
25097
|
+
return "timeout";
|
|
25098
|
+
if (status === 429)
|
|
25099
|
+
return "rate_limited";
|
|
25100
|
+
if (status >= 500 && status < 600)
|
|
25101
|
+
return "server_error";
|
|
25102
|
+
return;
|
|
25103
|
+
}
|
|
25104
|
+
function defaultErrorCodeForFailure(data) {
|
|
25105
|
+
if (data.Result === RESULTS.Failure) {
|
|
25106
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
25107
|
+
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
25108
|
+
if (errorCode)
|
|
25109
|
+
return errorCode;
|
|
25110
|
+
}
|
|
25111
|
+
return defaultErrorCodeForResult(data.Result);
|
|
25112
|
+
}
|
|
25000
25113
|
function defaultRetryForErrorCode(errorCode) {
|
|
25001
25114
|
switch (errorCode) {
|
|
25002
25115
|
case "network_error":
|
|
@@ -25026,16 +25139,19 @@ var OutputFormatter;
|
|
|
25026
25139
|
OutputFormatter.success = success;
|
|
25027
25140
|
function error(data) {
|
|
25028
25141
|
data.Log ??= getLogFilePath() || undefined;
|
|
25029
|
-
data.ErrorCode ??=
|
|
25142
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
25030
25143
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
25031
25144
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25145
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
25146
|
+
if (!SuppressTelemetry) {
|
|
25147
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
25148
|
+
result: data.Result,
|
|
25149
|
+
errorCode: data.ErrorCode,
|
|
25150
|
+
retry: data.Retry,
|
|
25151
|
+
message: data.Message
|
|
25152
|
+
});
|
|
25153
|
+
}
|
|
25154
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
25039
25155
|
}
|
|
25040
25156
|
OutputFormatter.error = error;
|
|
25041
25157
|
function emitList(code, items, opts) {
|
|
@@ -25328,1657 +25444,241 @@ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
|
25328
25444
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
25329
25445
|
// ../../common/src/interactivity-context.ts
|
|
25330
25446
|
var modeSlot = singleton("InteractivityMode");
|
|
25331
|
-
//
|
|
25332
|
-
import
|
|
25447
|
+
// ../../common/src/option-aliases.ts
|
|
25448
|
+
import { Option } from "commander";
|
|
25449
|
+
// ../../common/src/option-validators.ts
|
|
25450
|
+
import { InvalidArgumentError } from "commander";
|
|
25451
|
+
// ../../common/src/polling/types.ts
|
|
25452
|
+
var PollOutcome = {
|
|
25453
|
+
Completed: "completed",
|
|
25454
|
+
Timeout: "timeout",
|
|
25455
|
+
Interrupted: "interrupted",
|
|
25456
|
+
Aborted: "aborted",
|
|
25457
|
+
Failed: "failed"
|
|
25458
|
+
};
|
|
25333
25459
|
|
|
25334
|
-
|
|
25335
|
-
|
|
25336
|
-
|
|
25337
|
-
|
|
25338
|
-
|
|
25339
|
-
|
|
25340
|
-
|
|
25341
|
-
|
|
25342
|
-
|
|
25343
|
-
|
|
25344
|
-
|
|
25345
|
-
|
|
25346
|
-
|
|
25347
|
-
|
|
25348
|
-
|
|
25349
|
-
|
|
25350
|
-
|
|
25351
|
-
|
|
25352
|
-
|
|
25353
|
-
|
|
25354
|
-
|
|
25460
|
+
// ../../common/src/polling/poll-failure-mapping.ts
|
|
25461
|
+
var REASON_BY_OUTCOME = {
|
|
25462
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
25463
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
25464
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
25465
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
25466
|
+
};
|
|
25467
|
+
// ../../common/src/polling/terminal-statuses.ts
|
|
25468
|
+
var TERMINAL_STATUSES = new Set([
|
|
25469
|
+
"completed",
|
|
25470
|
+
"successful",
|
|
25471
|
+
"faulted",
|
|
25472
|
+
"failed",
|
|
25473
|
+
"cancelled",
|
|
25474
|
+
"canceled",
|
|
25475
|
+
"stopped",
|
|
25476
|
+
"finished"
|
|
25477
|
+
]);
|
|
25478
|
+
var FAILURE_STATUSES = new Set([
|
|
25479
|
+
"faulted",
|
|
25480
|
+
"failed",
|
|
25481
|
+
"cancelled",
|
|
25482
|
+
"canceled",
|
|
25483
|
+
"stopped"
|
|
25484
|
+
]);
|
|
25485
|
+
// ../../common/src/preview.ts
|
|
25486
|
+
import { Command as Command3 } from "commander";
|
|
25487
|
+
var previewSlot = singleton("PreviewBuild");
|
|
25488
|
+
function isPreviewBuild() {
|
|
25489
|
+
return previewSlot.get(false) ?? false;
|
|
25355
25490
|
}
|
|
25356
|
-
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
this.jsep = jsep;
|
|
25360
|
-
this.registered = {};
|
|
25491
|
+
Command3.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
25492
|
+
if (isPreviewBuild()) {
|
|
25493
|
+
return this.command(nameAndArgs, opts);
|
|
25361
25494
|
}
|
|
25362
|
-
|
|
25363
|
-
|
|
25364
|
-
|
|
25365
|
-
|
|
25366
|
-
|
|
25367
|
-
|
|
25368
|
-
|
|
25369
|
-
|
|
25370
|
-
plugin.init(this.jsep);
|
|
25371
|
-
this.registered[plugin.name] = plugin;
|
|
25372
|
-
});
|
|
25495
|
+
return new Command3(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
25496
|
+
};
|
|
25497
|
+
// ../../common/src/screen-logger.ts
|
|
25498
|
+
var ScreenLogger;
|
|
25499
|
+
((ScreenLogger) => {
|
|
25500
|
+
function progress(message) {
|
|
25501
|
+
getOutputSink().writeErr(`${message}
|
|
25502
|
+
`);
|
|
25373
25503
|
}
|
|
25504
|
+
ScreenLogger.progress = progress;
|
|
25505
|
+
})(ScreenLogger ||= {});
|
|
25506
|
+
// ../../common/src/sdk-user-agent.ts
|
|
25507
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
25508
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
25509
|
+
function userAgentPatchKey(userAgent) {
|
|
25510
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
25374
25511
|
}
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
Jsep.unary_ops[op_name] = 1;
|
|
25386
|
-
return Jsep;
|
|
25387
|
-
}
|
|
25388
|
-
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
25389
|
-
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
25390
|
-
Jsep.binary_ops[op_name] = precedence;
|
|
25391
|
-
if (isRightAssociative) {
|
|
25392
|
-
Jsep.right_associative.add(op_name);
|
|
25393
|
-
} else {
|
|
25394
|
-
Jsep.right_associative.delete(op_name);
|
|
25512
|
+
function splitUserAgentTokens(value) {
|
|
25513
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
25514
|
+
}
|
|
25515
|
+
function appendUserAgentToken(value, userAgent) {
|
|
25516
|
+
const tokens = splitUserAgentTokens(value);
|
|
25517
|
+
const seen = new Set(tokens);
|
|
25518
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
25519
|
+
if (!seen.has(token)) {
|
|
25520
|
+
tokens.push(token);
|
|
25521
|
+
seen.add(token);
|
|
25395
25522
|
}
|
|
25396
|
-
return Jsep;
|
|
25397
25523
|
}
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
25524
|
+
return tokens.join(" ");
|
|
25525
|
+
}
|
|
25526
|
+
function getEffectiveUserAgent(userAgent) {
|
|
25527
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
25528
|
+
}
|
|
25529
|
+
function getHeaderName(headers, headerName) {
|
|
25530
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
25531
|
+
}
|
|
25532
|
+
function getSdkUserAgentToken(pkg) {
|
|
25533
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
25534
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
25535
|
+
}
|
|
25536
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
25537
|
+
const result = { ...headers ?? {} };
|
|
25538
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
25539
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
25540
|
+
return result;
|
|
25541
|
+
}
|
|
25542
|
+
function asHeaderRecord(headers) {
|
|
25543
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
25544
|
+
}
|
|
25545
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
25546
|
+
return async (requestContext) => {
|
|
25547
|
+
const initWithHeaders = {
|
|
25548
|
+
...requestContext.init,
|
|
25549
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
25550
|
+
};
|
|
25551
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
25552
|
+
...requestContext,
|
|
25553
|
+
init: initWithHeaders
|
|
25554
|
+
}) : initOverrides;
|
|
25555
|
+
return {
|
|
25556
|
+
...override ?? {},
|
|
25557
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
25558
|
+
};
|
|
25559
|
+
};
|
|
25560
|
+
}
|
|
25561
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
25562
|
+
const prototype = BaseApiClass.prototype;
|
|
25563
|
+
if (prototype[patchKey]) {
|
|
25564
|
+
return;
|
|
25405
25565
|
}
|
|
25406
|
-
|
|
25407
|
-
|
|
25408
|
-
if (op_name.length === Jsep.max_unop_len) {
|
|
25409
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
25410
|
-
}
|
|
25411
|
-
return Jsep;
|
|
25566
|
+
if (typeof prototype.request !== "function") {
|
|
25567
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
25412
25568
|
}
|
|
25413
|
-
|
|
25414
|
-
|
|
25415
|
-
|
|
25416
|
-
|
|
25569
|
+
const originalRequest = prototype.request;
|
|
25570
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
25571
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
25572
|
+
};
|
|
25573
|
+
Object.defineProperty(prototype, patchKey, {
|
|
25574
|
+
value: true
|
|
25575
|
+
});
|
|
25576
|
+
}
|
|
25577
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
25578
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
25579
|
+
}
|
|
25580
|
+
// ../../common/src/tool-provider.ts
|
|
25581
|
+
var factorySlot = singleton("PackagerFactoryProvider");
|
|
25582
|
+
// ../oms-sdk/generated/v1/src/runtime.ts
|
|
25583
|
+
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
25584
|
+
|
|
25585
|
+
class Configuration {
|
|
25586
|
+
configuration;
|
|
25587
|
+
constructor(configuration = {}) {
|
|
25588
|
+
this.configuration = configuration;
|
|
25417
25589
|
}
|
|
25418
|
-
|
|
25419
|
-
|
|
25420
|
-
return Jsep;
|
|
25590
|
+
set config(configuration) {
|
|
25591
|
+
this.configuration = configuration;
|
|
25421
25592
|
}
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
25425
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
25426
|
-
}
|
|
25427
|
-
Jsep.right_associative.delete(op_name);
|
|
25428
|
-
return Jsep;
|
|
25593
|
+
get basePath() {
|
|
25594
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
25429
25595
|
}
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
Jsep.max_binop_len = 0;
|
|
25433
|
-
return Jsep;
|
|
25596
|
+
get fetchApi() {
|
|
25597
|
+
return this.configuration.fetchApi;
|
|
25434
25598
|
}
|
|
25435
|
-
|
|
25436
|
-
|
|
25437
|
-
return Jsep;
|
|
25599
|
+
get middleware() {
|
|
25600
|
+
return this.configuration.middleware || [];
|
|
25438
25601
|
}
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
return Jsep;
|
|
25602
|
+
get queryParamsStringify() {
|
|
25603
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
25442
25604
|
}
|
|
25443
|
-
get
|
|
25444
|
-
return this.
|
|
25605
|
+
get username() {
|
|
25606
|
+
return this.configuration.username;
|
|
25445
25607
|
}
|
|
25446
|
-
get
|
|
25447
|
-
return this.
|
|
25608
|
+
get password() {
|
|
25609
|
+
return this.configuration.password;
|
|
25448
25610
|
}
|
|
25449
|
-
|
|
25450
|
-
|
|
25451
|
-
|
|
25611
|
+
get apiKey() {
|
|
25612
|
+
const apiKey = this.configuration.apiKey;
|
|
25613
|
+
if (apiKey) {
|
|
25614
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
25615
|
+
}
|
|
25616
|
+
return;
|
|
25452
25617
|
}
|
|
25453
|
-
|
|
25454
|
-
|
|
25618
|
+
get accessToken() {
|
|
25619
|
+
const accessToken = this.configuration.accessToken;
|
|
25620
|
+
if (accessToken) {
|
|
25621
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
25622
|
+
}
|
|
25623
|
+
return;
|
|
25455
25624
|
}
|
|
25456
|
-
|
|
25457
|
-
return
|
|
25625
|
+
get headers() {
|
|
25626
|
+
return this.configuration.headers;
|
|
25458
25627
|
}
|
|
25459
|
-
|
|
25460
|
-
return
|
|
25628
|
+
get credentials() {
|
|
25629
|
+
return this.configuration.credentials;
|
|
25461
25630
|
}
|
|
25462
|
-
|
|
25463
|
-
|
|
25631
|
+
}
|
|
25632
|
+
var DefaultConfig = new Configuration;
|
|
25633
|
+
|
|
25634
|
+
class BaseAPI {
|
|
25635
|
+
configuration;
|
|
25636
|
+
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
25637
|
+
middleware;
|
|
25638
|
+
constructor(configuration = DefaultConfig) {
|
|
25639
|
+
this.configuration = configuration;
|
|
25640
|
+
this.middleware = configuration.middleware;
|
|
25464
25641
|
}
|
|
25465
|
-
|
|
25466
|
-
|
|
25642
|
+
withMiddleware(...middlewares) {
|
|
25643
|
+
const next = this.clone();
|
|
25644
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
25645
|
+
return next;
|
|
25467
25646
|
}
|
|
25468
|
-
|
|
25469
|
-
|
|
25647
|
+
withPreMiddleware(...preMiddlewares) {
|
|
25648
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
25649
|
+
return this.withMiddleware(...middlewares);
|
|
25470
25650
|
}
|
|
25471
|
-
|
|
25472
|
-
const
|
|
25473
|
-
|
|
25474
|
-
error.description = message;
|
|
25475
|
-
throw error;
|
|
25651
|
+
withPostMiddleware(...postMiddlewares) {
|
|
25652
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
25653
|
+
return this.withMiddleware(...middlewares);
|
|
25476
25654
|
}
|
|
25477
|
-
|
|
25478
|
-
if (
|
|
25479
|
-
|
|
25480
|
-
context: this,
|
|
25481
|
-
node
|
|
25482
|
-
};
|
|
25483
|
-
Jsep.hooks.run(name, env);
|
|
25484
|
-
return env.node;
|
|
25655
|
+
isJsonMime(mime) {
|
|
25656
|
+
if (!mime) {
|
|
25657
|
+
return false;
|
|
25485
25658
|
}
|
|
25486
|
-
return
|
|
25659
|
+
return BaseAPI.jsonRegex.test(mime);
|
|
25487
25660
|
}
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
|
|
25491
|
-
|
|
25492
|
-
|
|
25493
|
-
Jsep.hooks[name].find(function(callback) {
|
|
25494
|
-
callback.call(env.context, env);
|
|
25495
|
-
return env.node;
|
|
25496
|
-
});
|
|
25497
|
-
return env.node;
|
|
25661
|
+
async request(context, initOverrides) {
|
|
25662
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
25663
|
+
const response = await this.fetchApi(url, init);
|
|
25664
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
25665
|
+
return response;
|
|
25498
25666
|
}
|
|
25667
|
+
throw new ResponseError(response, "Response returned an error code");
|
|
25499
25668
|
}
|
|
25500
|
-
|
|
25501
|
-
let
|
|
25502
|
-
|
|
25503
|
-
|
|
25669
|
+
async createFetchParams(context, initOverrides) {
|
|
25670
|
+
let url = this.configuration.basePath + context.path;
|
|
25671
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
25672
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
25504
25673
|
}
|
|
25505
|
-
this.
|
|
25506
|
-
|
|
25507
|
-
|
|
25508
|
-
|
|
25509
|
-
|
|
25510
|
-
|
|
25511
|
-
|
|
25512
|
-
|
|
25513
|
-
};
|
|
25514
|
-
return this.runHook("after-all", node);
|
|
25515
|
-
}
|
|
25516
|
-
gobbleExpressions(untilICode) {
|
|
25517
|
-
let nodes = [], ch_i, node;
|
|
25518
|
-
while (this.index < this.expr.length) {
|
|
25519
|
-
ch_i = this.code;
|
|
25520
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
25521
|
-
this.index++;
|
|
25522
|
-
} else {
|
|
25523
|
-
if (node = this.gobbleExpression()) {
|
|
25524
|
-
nodes.push(node);
|
|
25525
|
-
} else if (this.index < this.expr.length) {
|
|
25526
|
-
if (ch_i === untilICode) {
|
|
25527
|
-
break;
|
|
25528
|
-
}
|
|
25529
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
25530
|
-
}
|
|
25531
|
-
}
|
|
25532
|
-
}
|
|
25533
|
-
return nodes;
|
|
25534
|
-
}
|
|
25535
|
-
gobbleExpression() {
|
|
25536
|
-
const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
25537
|
-
this.gobbleSpaces();
|
|
25538
|
-
return this.runHook("after-expression", node);
|
|
25539
|
-
}
|
|
25540
|
-
gobbleBinaryOp() {
|
|
25541
|
-
this.gobbleSpaces();
|
|
25542
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
25543
|
-
let tc_len = to_check.length;
|
|
25544
|
-
while (tc_len > 0) {
|
|
25545
|
-
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)))) {
|
|
25546
|
-
this.index += tc_len;
|
|
25547
|
-
return to_check;
|
|
25548
|
-
}
|
|
25549
|
-
to_check = to_check.substr(0, --tc_len);
|
|
25550
|
-
}
|
|
25551
|
-
return false;
|
|
25552
|
-
}
|
|
25553
|
-
gobbleBinaryExpression() {
|
|
25554
|
-
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
25555
|
-
left = this.gobbleToken();
|
|
25556
|
-
if (!left) {
|
|
25557
|
-
return left;
|
|
25558
|
-
}
|
|
25559
|
-
biop = this.gobbleBinaryOp();
|
|
25560
|
-
if (!biop) {
|
|
25561
|
-
return left;
|
|
25562
|
-
}
|
|
25563
|
-
biop_info = {
|
|
25564
|
-
value: biop,
|
|
25565
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
25566
|
-
right_a: Jsep.right_associative.has(biop)
|
|
25567
|
-
};
|
|
25568
|
-
right = this.gobbleToken();
|
|
25569
|
-
if (!right) {
|
|
25570
|
-
this.throwError("Expected expression after " + biop);
|
|
25571
|
-
}
|
|
25572
|
-
stack = [left, biop_info, right];
|
|
25573
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
25574
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
25575
|
-
if (prec === 0) {
|
|
25576
|
-
this.index -= biop.length;
|
|
25577
|
-
break;
|
|
25578
|
-
}
|
|
25579
|
-
biop_info = {
|
|
25580
|
-
value: biop,
|
|
25581
|
-
prec,
|
|
25582
|
-
right_a: Jsep.right_associative.has(biop)
|
|
25583
|
-
};
|
|
25584
|
-
cur_biop = biop;
|
|
25585
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
25586
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
25587
|
-
right = stack.pop();
|
|
25588
|
-
biop = stack.pop().value;
|
|
25589
|
-
left = stack.pop();
|
|
25590
|
-
node = {
|
|
25591
|
-
type: Jsep.BINARY_EXP,
|
|
25592
|
-
operator: biop,
|
|
25593
|
-
left,
|
|
25594
|
-
right
|
|
25595
|
-
};
|
|
25596
|
-
stack.push(node);
|
|
25597
|
-
}
|
|
25598
|
-
node = this.gobbleToken();
|
|
25599
|
-
if (!node) {
|
|
25600
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
25601
|
-
}
|
|
25602
|
-
stack.push(biop_info, node);
|
|
25603
|
-
}
|
|
25604
|
-
i = stack.length - 1;
|
|
25605
|
-
node = stack[i];
|
|
25606
|
-
while (i > 1) {
|
|
25607
|
-
node = {
|
|
25608
|
-
type: Jsep.BINARY_EXP,
|
|
25609
|
-
operator: stack[i - 1].value,
|
|
25610
|
-
left: stack[i - 2],
|
|
25611
|
-
right: node
|
|
25612
|
-
};
|
|
25613
|
-
i -= 2;
|
|
25614
|
-
}
|
|
25615
|
-
return node;
|
|
25616
|
-
}
|
|
25617
|
-
gobbleToken() {
|
|
25618
|
-
let ch, to_check, tc_len, node;
|
|
25619
|
-
this.gobbleSpaces();
|
|
25620
|
-
node = this.searchHook("gobble-token");
|
|
25621
|
-
if (node) {
|
|
25622
|
-
return this.runHook("after-token", node);
|
|
25623
|
-
}
|
|
25624
|
-
ch = this.code;
|
|
25625
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
25626
|
-
return this.gobbleNumericLiteral();
|
|
25627
|
-
}
|
|
25628
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
25629
|
-
node = this.gobbleStringLiteral();
|
|
25630
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
25631
|
-
node = this.gobbleArray();
|
|
25632
|
-
} else {
|
|
25633
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
25634
|
-
tc_len = to_check.length;
|
|
25635
|
-
while (tc_len > 0) {
|
|
25636
|
-
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)))) {
|
|
25637
|
-
this.index += tc_len;
|
|
25638
|
-
const argument = this.gobbleToken();
|
|
25639
|
-
if (!argument) {
|
|
25640
|
-
this.throwError("missing unaryOp argument");
|
|
25641
|
-
}
|
|
25642
|
-
return this.runHook("after-token", {
|
|
25643
|
-
type: Jsep.UNARY_EXP,
|
|
25644
|
-
operator: to_check,
|
|
25645
|
-
argument,
|
|
25646
|
-
prefix: true
|
|
25647
|
-
});
|
|
25648
|
-
}
|
|
25649
|
-
to_check = to_check.substr(0, --tc_len);
|
|
25650
|
-
}
|
|
25651
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
25652
|
-
node = this.gobbleIdentifier();
|
|
25653
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
25654
|
-
node = {
|
|
25655
|
-
type: Jsep.LITERAL,
|
|
25656
|
-
value: Jsep.literals[node.name],
|
|
25657
|
-
raw: node.name
|
|
25658
|
-
};
|
|
25659
|
-
} else if (node.name === Jsep.this_str) {
|
|
25660
|
-
node = {
|
|
25661
|
-
type: Jsep.THIS_EXP
|
|
25662
|
-
};
|
|
25663
|
-
}
|
|
25664
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
25665
|
-
node = this.gobbleGroup();
|
|
25666
|
-
}
|
|
25667
|
-
}
|
|
25668
|
-
if (!node) {
|
|
25669
|
-
return this.runHook("after-token", false);
|
|
25670
|
-
}
|
|
25671
|
-
node = this.gobbleTokenProperty(node);
|
|
25672
|
-
return this.runHook("after-token", node);
|
|
25673
|
-
}
|
|
25674
|
-
gobbleTokenProperty(node) {
|
|
25675
|
-
this.gobbleSpaces();
|
|
25676
|
-
let ch = this.code;
|
|
25677
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
25678
|
-
let optional;
|
|
25679
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
25680
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
25681
|
-
break;
|
|
25682
|
-
}
|
|
25683
|
-
optional = true;
|
|
25684
|
-
this.index += 2;
|
|
25685
|
-
this.gobbleSpaces();
|
|
25686
|
-
ch = this.code;
|
|
25687
|
-
}
|
|
25688
|
-
this.index++;
|
|
25689
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
25690
|
-
node = {
|
|
25691
|
-
type: Jsep.MEMBER_EXP,
|
|
25692
|
-
computed: true,
|
|
25693
|
-
object: node,
|
|
25694
|
-
property: this.gobbleExpression()
|
|
25695
|
-
};
|
|
25696
|
-
if (!node.property) {
|
|
25697
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
25698
|
-
}
|
|
25699
|
-
this.gobbleSpaces();
|
|
25700
|
-
ch = this.code;
|
|
25701
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
25702
|
-
this.throwError("Unclosed [");
|
|
25703
|
-
}
|
|
25704
|
-
this.index++;
|
|
25705
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
25706
|
-
node = {
|
|
25707
|
-
type: Jsep.CALL_EXP,
|
|
25708
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
25709
|
-
callee: node
|
|
25710
|
-
};
|
|
25711
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
25712
|
-
if (optional) {
|
|
25713
|
-
this.index--;
|
|
25714
|
-
}
|
|
25715
|
-
this.gobbleSpaces();
|
|
25716
|
-
node = {
|
|
25717
|
-
type: Jsep.MEMBER_EXP,
|
|
25718
|
-
computed: false,
|
|
25719
|
-
object: node,
|
|
25720
|
-
property: this.gobbleIdentifier()
|
|
25721
|
-
};
|
|
25722
|
-
}
|
|
25723
|
-
if (optional) {
|
|
25724
|
-
node.optional = true;
|
|
25725
|
-
}
|
|
25726
|
-
this.gobbleSpaces();
|
|
25727
|
-
ch = this.code;
|
|
25728
|
-
}
|
|
25729
|
-
return node;
|
|
25730
|
-
}
|
|
25731
|
-
gobbleNumericLiteral() {
|
|
25732
|
-
let number = "", ch, chCode;
|
|
25733
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
25734
|
-
number += this.expr.charAt(this.index++);
|
|
25735
|
-
}
|
|
25736
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
25737
|
-
number += this.expr.charAt(this.index++);
|
|
25738
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
25739
|
-
number += this.expr.charAt(this.index++);
|
|
25740
|
-
}
|
|
25741
|
-
}
|
|
25742
|
-
ch = this.char;
|
|
25743
|
-
if (ch === "e" || ch === "E") {
|
|
25744
|
-
number += this.expr.charAt(this.index++);
|
|
25745
|
-
ch = this.char;
|
|
25746
|
-
if (ch === "+" || ch === "-") {
|
|
25747
|
-
number += this.expr.charAt(this.index++);
|
|
25748
|
-
}
|
|
25749
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
25750
|
-
number += this.expr.charAt(this.index++);
|
|
25751
|
-
}
|
|
25752
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
25753
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
25754
|
-
}
|
|
25755
|
-
}
|
|
25756
|
-
chCode = this.code;
|
|
25757
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
25758
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
25759
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
25760
|
-
this.throwError("Unexpected period");
|
|
25761
|
-
}
|
|
25762
|
-
return {
|
|
25763
|
-
type: Jsep.LITERAL,
|
|
25764
|
-
value: parseFloat(number),
|
|
25765
|
-
raw: number
|
|
25766
|
-
};
|
|
25767
|
-
}
|
|
25768
|
-
gobbleStringLiteral() {
|
|
25769
|
-
let str = "";
|
|
25770
|
-
const startIndex = this.index;
|
|
25771
|
-
const quote = this.expr.charAt(this.index++);
|
|
25772
|
-
let closed = false;
|
|
25773
|
-
while (this.index < this.expr.length) {
|
|
25774
|
-
let ch = this.expr.charAt(this.index++);
|
|
25775
|
-
if (ch === quote) {
|
|
25776
|
-
closed = true;
|
|
25777
|
-
break;
|
|
25778
|
-
} else if (ch === "\\") {
|
|
25779
|
-
ch = this.expr.charAt(this.index++);
|
|
25780
|
-
switch (ch) {
|
|
25781
|
-
case "n":
|
|
25782
|
-
str += `
|
|
25783
|
-
`;
|
|
25784
|
-
break;
|
|
25785
|
-
case "r":
|
|
25786
|
-
str += "\r";
|
|
25787
|
-
break;
|
|
25788
|
-
case "t":
|
|
25789
|
-
str += "\t";
|
|
25790
|
-
break;
|
|
25791
|
-
case "b":
|
|
25792
|
-
str += "\b";
|
|
25793
|
-
break;
|
|
25794
|
-
case "f":
|
|
25795
|
-
str += "\f";
|
|
25796
|
-
break;
|
|
25797
|
-
case "v":
|
|
25798
|
-
str += "\v";
|
|
25799
|
-
break;
|
|
25800
|
-
default:
|
|
25801
|
-
str += ch;
|
|
25802
|
-
}
|
|
25803
|
-
} else {
|
|
25804
|
-
str += ch;
|
|
25805
|
-
}
|
|
25806
|
-
}
|
|
25807
|
-
if (!closed) {
|
|
25808
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
25809
|
-
}
|
|
25810
|
-
return {
|
|
25811
|
-
type: Jsep.LITERAL,
|
|
25812
|
-
value: str,
|
|
25813
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
25814
|
-
};
|
|
25815
|
-
}
|
|
25816
|
-
gobbleIdentifier() {
|
|
25817
|
-
let ch = this.code, start = this.index;
|
|
25818
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
25819
|
-
this.index++;
|
|
25820
|
-
} else {
|
|
25821
|
-
this.throwError("Unexpected " + this.char);
|
|
25822
|
-
}
|
|
25823
|
-
while (this.index < this.expr.length) {
|
|
25824
|
-
ch = this.code;
|
|
25825
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
25826
|
-
this.index++;
|
|
25827
|
-
} else {
|
|
25828
|
-
break;
|
|
25829
|
-
}
|
|
25830
|
-
}
|
|
25831
|
-
return {
|
|
25832
|
-
type: Jsep.IDENTIFIER,
|
|
25833
|
-
name: this.expr.slice(start, this.index)
|
|
25834
|
-
};
|
|
25835
|
-
}
|
|
25836
|
-
gobbleArguments(termination) {
|
|
25837
|
-
const args = [];
|
|
25838
|
-
let closed = false;
|
|
25839
|
-
let separator_count = 0;
|
|
25840
|
-
while (this.index < this.expr.length) {
|
|
25841
|
-
this.gobbleSpaces();
|
|
25842
|
-
let ch_i = this.code;
|
|
25843
|
-
if (ch_i === termination) {
|
|
25844
|
-
closed = true;
|
|
25845
|
-
this.index++;
|
|
25846
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
25847
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
25848
|
-
}
|
|
25849
|
-
break;
|
|
25850
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
25851
|
-
this.index++;
|
|
25852
|
-
separator_count++;
|
|
25853
|
-
if (separator_count !== args.length) {
|
|
25854
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
25855
|
-
this.throwError("Unexpected token ,");
|
|
25856
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
25857
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
25858
|
-
args.push(null);
|
|
25859
|
-
}
|
|
25860
|
-
}
|
|
25861
|
-
}
|
|
25862
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
25863
|
-
this.throwError("Expected comma");
|
|
25864
|
-
} else {
|
|
25865
|
-
const node = this.gobbleExpression();
|
|
25866
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
25867
|
-
this.throwError("Expected comma");
|
|
25868
|
-
}
|
|
25869
|
-
args.push(node);
|
|
25870
|
-
}
|
|
25871
|
-
}
|
|
25872
|
-
if (!closed) {
|
|
25873
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
25874
|
-
}
|
|
25875
|
-
return args;
|
|
25876
|
-
}
|
|
25877
|
-
gobbleGroup() {
|
|
25878
|
-
this.index++;
|
|
25879
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
25880
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
25881
|
-
this.index++;
|
|
25882
|
-
if (nodes.length === 1) {
|
|
25883
|
-
return nodes[0];
|
|
25884
|
-
} else if (!nodes.length) {
|
|
25885
|
-
return false;
|
|
25886
|
-
} else {
|
|
25887
|
-
return {
|
|
25888
|
-
type: Jsep.SEQUENCE_EXP,
|
|
25889
|
-
expressions: nodes
|
|
25890
|
-
};
|
|
25891
|
-
}
|
|
25892
|
-
} else {
|
|
25893
|
-
this.throwError("Unclosed (");
|
|
25894
|
-
}
|
|
25895
|
-
}
|
|
25896
|
-
gobbleArray() {
|
|
25897
|
-
this.index++;
|
|
25898
|
-
return {
|
|
25899
|
-
type: Jsep.ARRAY_EXP,
|
|
25900
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
25901
|
-
};
|
|
25902
|
-
}
|
|
25903
|
-
}
|
|
25904
|
-
var hooks = new Hooks;
|
|
25905
|
-
Object.assign(Jsep, {
|
|
25906
|
-
hooks,
|
|
25907
|
-
plugins: new Plugins(Jsep),
|
|
25908
|
-
COMPOUND: "Compound",
|
|
25909
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
25910
|
-
IDENTIFIER: "Identifier",
|
|
25911
|
-
MEMBER_EXP: "MemberExpression",
|
|
25912
|
-
LITERAL: "Literal",
|
|
25913
|
-
THIS_EXP: "ThisExpression",
|
|
25914
|
-
CALL_EXP: "CallExpression",
|
|
25915
|
-
UNARY_EXP: "UnaryExpression",
|
|
25916
|
-
BINARY_EXP: "BinaryExpression",
|
|
25917
|
-
ARRAY_EXP: "ArrayExpression",
|
|
25918
|
-
TAB_CODE: 9,
|
|
25919
|
-
LF_CODE: 10,
|
|
25920
|
-
CR_CODE: 13,
|
|
25921
|
-
SPACE_CODE: 32,
|
|
25922
|
-
PERIOD_CODE: 46,
|
|
25923
|
-
COMMA_CODE: 44,
|
|
25924
|
-
SQUOTE_CODE: 39,
|
|
25925
|
-
DQUOTE_CODE: 34,
|
|
25926
|
-
OPAREN_CODE: 40,
|
|
25927
|
-
CPAREN_CODE: 41,
|
|
25928
|
-
OBRACK_CODE: 91,
|
|
25929
|
-
CBRACK_CODE: 93,
|
|
25930
|
-
QUMARK_CODE: 63,
|
|
25931
|
-
SEMCOL_CODE: 59,
|
|
25932
|
-
COLON_CODE: 58,
|
|
25933
|
-
unary_ops: {
|
|
25934
|
-
"-": 1,
|
|
25935
|
-
"!": 1,
|
|
25936
|
-
"~": 1,
|
|
25937
|
-
"+": 1
|
|
25938
|
-
},
|
|
25939
|
-
binary_ops: {
|
|
25940
|
-
"||": 1,
|
|
25941
|
-
"??": 1,
|
|
25942
|
-
"&&": 2,
|
|
25943
|
-
"|": 3,
|
|
25944
|
-
"^": 4,
|
|
25945
|
-
"&": 5,
|
|
25946
|
-
"==": 6,
|
|
25947
|
-
"!=": 6,
|
|
25948
|
-
"===": 6,
|
|
25949
|
-
"!==": 6,
|
|
25950
|
-
"<": 7,
|
|
25951
|
-
">": 7,
|
|
25952
|
-
"<=": 7,
|
|
25953
|
-
">=": 7,
|
|
25954
|
-
"<<": 8,
|
|
25955
|
-
">>": 8,
|
|
25956
|
-
">>>": 8,
|
|
25957
|
-
"+": 9,
|
|
25958
|
-
"-": 9,
|
|
25959
|
-
"*": 10,
|
|
25960
|
-
"/": 10,
|
|
25961
|
-
"%": 10,
|
|
25962
|
-
"**": 11
|
|
25963
|
-
},
|
|
25964
|
-
right_associative: new Set(["**"]),
|
|
25965
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
25966
|
-
literals: {
|
|
25967
|
-
true: true,
|
|
25968
|
-
false: false,
|
|
25969
|
-
null: null
|
|
25970
|
-
},
|
|
25971
|
-
this_str: "this"
|
|
25972
|
-
});
|
|
25973
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
25974
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
25975
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
25976
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
25977
|
-
});
|
|
25978
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
25979
|
-
jsep[m] = Jsep[m];
|
|
25980
|
-
});
|
|
25981
|
-
jsep.Jsep = Jsep;
|
|
25982
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
25983
|
-
var ternary = {
|
|
25984
|
-
name: "ternary",
|
|
25985
|
-
init(jsep2) {
|
|
25986
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
25987
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
25988
|
-
this.index++;
|
|
25989
|
-
const test = env.node;
|
|
25990
|
-
const consequent = this.gobbleExpression();
|
|
25991
|
-
if (!consequent) {
|
|
25992
|
-
this.throwError("Expected expression");
|
|
25993
|
-
}
|
|
25994
|
-
this.gobbleSpaces();
|
|
25995
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
25996
|
-
this.index++;
|
|
25997
|
-
const alternate = this.gobbleExpression();
|
|
25998
|
-
if (!alternate) {
|
|
25999
|
-
this.throwError("Expected expression");
|
|
26000
|
-
}
|
|
26001
|
-
env.node = {
|
|
26002
|
-
type: CONDITIONAL_EXP,
|
|
26003
|
-
test,
|
|
26004
|
-
consequent,
|
|
26005
|
-
alternate
|
|
26006
|
-
};
|
|
26007
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
26008
|
-
let newTest = test;
|
|
26009
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
26010
|
-
newTest = newTest.right;
|
|
26011
|
-
}
|
|
26012
|
-
env.node.test = newTest.right;
|
|
26013
|
-
newTest.right = env.node;
|
|
26014
|
-
env.node = test;
|
|
26015
|
-
}
|
|
26016
|
-
} else {
|
|
26017
|
-
this.throwError("Expected :");
|
|
26018
|
-
}
|
|
26019
|
-
}
|
|
26020
|
-
});
|
|
26021
|
-
}
|
|
26022
|
-
};
|
|
26023
|
-
jsep.plugins.register(ternary);
|
|
26024
|
-
var FSLASH_CODE = 47;
|
|
26025
|
-
var BSLASH_CODE = 92;
|
|
26026
|
-
var index = {
|
|
26027
|
-
name: "regex",
|
|
26028
|
-
init(jsep2) {
|
|
26029
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
26030
|
-
if (this.code === FSLASH_CODE) {
|
|
26031
|
-
const patternIndex = ++this.index;
|
|
26032
|
-
let inCharSet = false;
|
|
26033
|
-
while (this.index < this.expr.length) {
|
|
26034
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
26035
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
26036
|
-
let flags = "";
|
|
26037
|
-
while (++this.index < this.expr.length) {
|
|
26038
|
-
const code = this.code;
|
|
26039
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
26040
|
-
flags += this.char;
|
|
26041
|
-
} else {
|
|
26042
|
-
break;
|
|
26043
|
-
}
|
|
26044
|
-
}
|
|
26045
|
-
let value;
|
|
26046
|
-
try {
|
|
26047
|
-
value = new RegExp(pattern, flags);
|
|
26048
|
-
} catch (e) {
|
|
26049
|
-
this.throwError(e.message);
|
|
26050
|
-
}
|
|
26051
|
-
env.node = {
|
|
26052
|
-
type: jsep2.LITERAL,
|
|
26053
|
-
value,
|
|
26054
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
26055
|
-
};
|
|
26056
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
26057
|
-
return env.node;
|
|
26058
|
-
}
|
|
26059
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
26060
|
-
inCharSet = true;
|
|
26061
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
26062
|
-
inCharSet = false;
|
|
26063
|
-
}
|
|
26064
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
26065
|
-
}
|
|
26066
|
-
this.throwError("Unclosed Regex");
|
|
26067
|
-
}
|
|
26068
|
-
});
|
|
26069
|
-
}
|
|
26070
|
-
};
|
|
26071
|
-
var PLUS_CODE = 43;
|
|
26072
|
-
var MINUS_CODE = 45;
|
|
26073
|
-
var plugin = {
|
|
26074
|
-
name: "assignment",
|
|
26075
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
26076
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
26077
|
-
assignmentPrecedence: 0.9,
|
|
26078
|
-
init(jsep2) {
|
|
26079
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
26080
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
26081
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
26082
|
-
const code = this.code;
|
|
26083
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
26084
|
-
this.index += 2;
|
|
26085
|
-
env.node = {
|
|
26086
|
-
type: "UpdateExpression",
|
|
26087
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
26088
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
26089
|
-
prefix: true
|
|
26090
|
-
};
|
|
26091
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
26092
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
26093
|
-
}
|
|
26094
|
-
}
|
|
26095
|
-
});
|
|
26096
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
26097
|
-
if (env.node) {
|
|
26098
|
-
const code = this.code;
|
|
26099
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
26100
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
26101
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
26102
|
-
}
|
|
26103
|
-
this.index += 2;
|
|
26104
|
-
env.node = {
|
|
26105
|
-
type: "UpdateExpression",
|
|
26106
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
26107
|
-
argument: env.node,
|
|
26108
|
-
prefix: false
|
|
26109
|
-
};
|
|
26110
|
-
}
|
|
26111
|
-
}
|
|
26112
|
-
});
|
|
26113
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
26114
|
-
if (env.node) {
|
|
26115
|
-
updateBinariesToAssignments(env.node);
|
|
26116
|
-
}
|
|
26117
|
-
});
|
|
26118
|
-
function updateBinariesToAssignments(node) {
|
|
26119
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
26120
|
-
node.type = "AssignmentExpression";
|
|
26121
|
-
updateBinariesToAssignments(node.left);
|
|
26122
|
-
updateBinariesToAssignments(node.right);
|
|
26123
|
-
} else if (!node.operator) {
|
|
26124
|
-
Object.values(node).forEach((val) => {
|
|
26125
|
-
if (val && typeof val === "object") {
|
|
26126
|
-
updateBinariesToAssignments(val);
|
|
26127
|
-
}
|
|
26128
|
-
});
|
|
26129
|
-
}
|
|
26130
|
-
}
|
|
26131
|
-
}
|
|
26132
|
-
};
|
|
26133
|
-
jsep.plugins.register(index, plugin);
|
|
26134
|
-
jsep.addUnaryOp("typeof");
|
|
26135
|
-
jsep.addUnaryOp("void");
|
|
26136
|
-
jsep.addLiteral("null", null);
|
|
26137
|
-
jsep.addLiteral("undefined", undefined);
|
|
26138
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
26139
|
-
var SafeEval = {
|
|
26140
|
-
evalAst(ast, subs) {
|
|
26141
|
-
switch (ast.type) {
|
|
26142
|
-
case "BinaryExpression":
|
|
26143
|
-
case "LogicalExpression":
|
|
26144
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
26145
|
-
case "Compound":
|
|
26146
|
-
return SafeEval.evalCompound(ast, subs);
|
|
26147
|
-
case "ConditionalExpression":
|
|
26148
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
26149
|
-
case "Identifier":
|
|
26150
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
26151
|
-
case "Literal":
|
|
26152
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
26153
|
-
case "MemberExpression":
|
|
26154
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
26155
|
-
case "UnaryExpression":
|
|
26156
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
26157
|
-
case "ArrayExpression":
|
|
26158
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
26159
|
-
case "CallExpression":
|
|
26160
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
26161
|
-
case "AssignmentExpression":
|
|
26162
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
26163
|
-
default:
|
|
26164
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
26165
|
-
}
|
|
26166
|
-
},
|
|
26167
|
-
evalBinaryExpression(ast, subs) {
|
|
26168
|
-
const result = {
|
|
26169
|
-
"||": (a, b) => a || b(),
|
|
26170
|
-
"&&": (a, b) => a && b(),
|
|
26171
|
-
"|": (a, b) => a | b(),
|
|
26172
|
-
"^": (a, b) => a ^ b(),
|
|
26173
|
-
"&": (a, b) => a & b(),
|
|
26174
|
-
"==": (a, b) => a == b(),
|
|
26175
|
-
"!=": (a, b) => a != b(),
|
|
26176
|
-
"===": (a, b) => a === b(),
|
|
26177
|
-
"!==": (a, b) => a !== b(),
|
|
26178
|
-
"<": (a, b) => a < b(),
|
|
26179
|
-
">": (a, b) => a > b(),
|
|
26180
|
-
"<=": (a, b) => a <= b(),
|
|
26181
|
-
">=": (a, b) => a >= b(),
|
|
26182
|
-
"<<": (a, b) => a << b(),
|
|
26183
|
-
">>": (a, b) => a >> b(),
|
|
26184
|
-
">>>": (a, b) => a >>> b(),
|
|
26185
|
-
"+": (a, b) => a + b(),
|
|
26186
|
-
"-": (a, b) => a - b(),
|
|
26187
|
-
"*": (a, b) => a * b(),
|
|
26188
|
-
"/": (a, b) => a / b(),
|
|
26189
|
-
"%": (a, b) => a % b()
|
|
26190
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
26191
|
-
return result;
|
|
26192
|
-
},
|
|
26193
|
-
evalCompound(ast, subs) {
|
|
26194
|
-
let last;
|
|
26195
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
26196
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
26197
|
-
i += 1;
|
|
26198
|
-
}
|
|
26199
|
-
const expr = ast.body[i];
|
|
26200
|
-
last = SafeEval.evalAst(expr, subs);
|
|
26201
|
-
}
|
|
26202
|
-
return last;
|
|
26203
|
-
},
|
|
26204
|
-
evalConditionalExpression(ast, subs) {
|
|
26205
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
26206
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
26207
|
-
}
|
|
26208
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
26209
|
-
},
|
|
26210
|
-
evalIdentifier(ast, subs) {
|
|
26211
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
26212
|
-
return subs[ast.name];
|
|
26213
|
-
}
|
|
26214
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
26215
|
-
},
|
|
26216
|
-
evalLiteral(ast) {
|
|
26217
|
-
return ast.value;
|
|
26218
|
-
},
|
|
26219
|
-
evalMemberExpression(ast, subs) {
|
|
26220
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
26221
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
26222
|
-
if (obj === undefined || obj === null) {
|
|
26223
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
26224
|
-
}
|
|
26225
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
26226
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
26227
|
-
}
|
|
26228
|
-
const result = obj[prop];
|
|
26229
|
-
if (typeof result === "function") {
|
|
26230
|
-
return result.bind(obj);
|
|
26231
|
-
}
|
|
26232
|
-
return result;
|
|
26233
|
-
},
|
|
26234
|
-
evalUnaryExpression(ast, subs) {
|
|
26235
|
-
const result = {
|
|
26236
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
26237
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
26238
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
26239
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
26240
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
26241
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
26242
|
-
}[ast.operator](ast.argument);
|
|
26243
|
-
return result;
|
|
26244
|
-
},
|
|
26245
|
-
evalArrayExpression(ast, subs) {
|
|
26246
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
26247
|
-
},
|
|
26248
|
-
evalCallExpression(ast, subs) {
|
|
26249
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
26250
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
26251
|
-
if (func === Function) {
|
|
26252
|
-
throw new Error("Function constructor is disabled");
|
|
26253
|
-
}
|
|
26254
|
-
return func(...args);
|
|
26255
|
-
},
|
|
26256
|
-
evalAssignmentExpression(ast, subs) {
|
|
26257
|
-
if (ast.left.type !== "Identifier") {
|
|
26258
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
26259
|
-
}
|
|
26260
|
-
const id = ast.left.name;
|
|
26261
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
26262
|
-
subs[id] = value;
|
|
26263
|
-
return subs[id];
|
|
26264
|
-
}
|
|
26265
|
-
};
|
|
26266
|
-
|
|
26267
|
-
class SafeScript {
|
|
26268
|
-
constructor(expr) {
|
|
26269
|
-
this.code = expr;
|
|
26270
|
-
this.ast = jsep(this.code);
|
|
26271
|
-
}
|
|
26272
|
-
runInNewContext(context) {
|
|
26273
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
26274
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
26275
|
-
}
|
|
26276
|
-
}
|
|
26277
|
-
function push(arr, item) {
|
|
26278
|
-
arr = arr.slice();
|
|
26279
|
-
arr.push(item);
|
|
26280
|
-
return arr;
|
|
26281
|
-
}
|
|
26282
|
-
function unshift(item, arr) {
|
|
26283
|
-
arr = arr.slice();
|
|
26284
|
-
arr.unshift(item);
|
|
26285
|
-
return arr;
|
|
26286
|
-
}
|
|
26287
|
-
|
|
26288
|
-
class NewError extends Error {
|
|
26289
|
-
constructor(value) {
|
|
26290
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
26291
|
-
this.avoidNew = true;
|
|
26292
|
-
this.value = value;
|
|
26293
|
-
this.name = "NewError";
|
|
26294
|
-
}
|
|
26295
|
-
}
|
|
26296
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
26297
|
-
if (!(this instanceof JSONPath)) {
|
|
26298
|
-
try {
|
|
26299
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
26300
|
-
} catch (e) {
|
|
26301
|
-
if (!e.avoidNew) {
|
|
26302
|
-
throw e;
|
|
26303
|
-
}
|
|
26304
|
-
return e.value;
|
|
26305
|
-
}
|
|
26306
|
-
}
|
|
26307
|
-
if (typeof opts === "string") {
|
|
26308
|
-
otherTypeCallback = callback;
|
|
26309
|
-
callback = obj;
|
|
26310
|
-
obj = expr;
|
|
26311
|
-
expr = opts;
|
|
26312
|
-
opts = null;
|
|
26313
|
-
}
|
|
26314
|
-
const optObj = opts && typeof opts === "object";
|
|
26315
|
-
opts = opts || {};
|
|
26316
|
-
this.json = opts.json || obj;
|
|
26317
|
-
this.path = opts.path || expr;
|
|
26318
|
-
this.resultType = opts.resultType || "value";
|
|
26319
|
-
this.flatten = opts.flatten || false;
|
|
26320
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
26321
|
-
this.sandbox = opts.sandbox || {};
|
|
26322
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
26323
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
26324
|
-
this.parent = opts.parent || null;
|
|
26325
|
-
this.parentProperty = opts.parentProperty || null;
|
|
26326
|
-
this.callback = opts.callback || callback || null;
|
|
26327
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
26328
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
26329
|
-
};
|
|
26330
|
-
if (opts.autostart !== false) {
|
|
26331
|
-
const args = {
|
|
26332
|
-
path: optObj ? opts.path : expr
|
|
26333
|
-
};
|
|
26334
|
-
if (!optObj) {
|
|
26335
|
-
args.json = obj;
|
|
26336
|
-
} else if ("json" in opts) {
|
|
26337
|
-
args.json = opts.json;
|
|
26338
|
-
}
|
|
26339
|
-
const ret = this.evaluate(args);
|
|
26340
|
-
if (!ret || typeof ret !== "object") {
|
|
26341
|
-
throw new NewError(ret);
|
|
26342
|
-
}
|
|
26343
|
-
return ret;
|
|
26344
|
-
}
|
|
26345
|
-
}
|
|
26346
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
26347
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
26348
|
-
let {
|
|
26349
|
-
flatten,
|
|
26350
|
-
wrap
|
|
26351
|
-
} = this;
|
|
26352
|
-
this.currResultType = this.resultType;
|
|
26353
|
-
this.currEval = this.eval;
|
|
26354
|
-
this.currSandbox = this.sandbox;
|
|
26355
|
-
callback = callback || this.callback;
|
|
26356
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
26357
|
-
json = json || this.json;
|
|
26358
|
-
expr = expr || this.path;
|
|
26359
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
26360
|
-
if (!expr.path && expr.path !== "") {
|
|
26361
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
26362
|
-
}
|
|
26363
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
26364
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
26365
|
-
}
|
|
26366
|
-
({
|
|
26367
|
-
json
|
|
26368
|
-
} = expr);
|
|
26369
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
26370
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
26371
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
26372
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
26373
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
26374
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
26375
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
26376
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
26377
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
26378
|
-
expr = expr.path;
|
|
26379
|
-
}
|
|
26380
|
-
currParent = currParent || null;
|
|
26381
|
-
currParentProperty = currParentProperty || null;
|
|
26382
|
-
if (Array.isArray(expr)) {
|
|
26383
|
-
expr = JSONPath.toPathString(expr);
|
|
26384
|
-
}
|
|
26385
|
-
if (!expr && expr !== "" || !json) {
|
|
26386
|
-
return;
|
|
26387
|
-
}
|
|
26388
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
26389
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
26390
|
-
exprList.shift();
|
|
26391
|
-
}
|
|
26392
|
-
this._hasParentSelector = null;
|
|
26393
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
26394
|
-
return ea && !ea.isParentSelector;
|
|
26395
|
-
});
|
|
26396
|
-
if (!result.length) {
|
|
26397
|
-
return wrap ? [] : undefined;
|
|
26398
|
-
}
|
|
26399
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
26400
|
-
return this._getPreferredOutput(result[0]);
|
|
26401
|
-
}
|
|
26402
|
-
return result.reduce((rslt, ea) => {
|
|
26403
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
26404
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
26405
|
-
rslt = rslt.concat(valOrPath);
|
|
26406
|
-
} else {
|
|
26407
|
-
rslt.push(valOrPath);
|
|
26408
|
-
}
|
|
26409
|
-
return rslt;
|
|
26410
|
-
}, []);
|
|
26411
|
-
};
|
|
26412
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
26413
|
-
const resultType = this.currResultType;
|
|
26414
|
-
switch (resultType) {
|
|
26415
|
-
case "all": {
|
|
26416
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
26417
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
26418
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
26419
|
-
return ea;
|
|
26420
|
-
}
|
|
26421
|
-
case "value":
|
|
26422
|
-
case "parent":
|
|
26423
|
-
case "parentProperty":
|
|
26424
|
-
return ea[resultType];
|
|
26425
|
-
case "path":
|
|
26426
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
26427
|
-
case "pointer":
|
|
26428
|
-
return JSONPath.toPointer(ea.path);
|
|
26429
|
-
default:
|
|
26430
|
-
throw new TypeError("Unknown result type");
|
|
26431
|
-
}
|
|
26432
|
-
};
|
|
26433
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
26434
|
-
if (callback) {
|
|
26435
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
26436
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
26437
|
-
callback(preferredOutput, type, fullRetObj);
|
|
26438
|
-
}
|
|
26439
|
-
};
|
|
26440
|
-
JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
26441
|
-
let retObj;
|
|
26442
|
-
if (!expr.length) {
|
|
26443
|
-
retObj = {
|
|
26444
|
-
path: path3,
|
|
26445
|
-
value: val,
|
|
26446
|
-
parent,
|
|
26447
|
-
parentProperty: parentPropName,
|
|
26448
|
-
hasArrExpr
|
|
26449
|
-
};
|
|
26450
|
-
this._handleCallback(retObj, callback, "value");
|
|
26451
|
-
return retObj;
|
|
26452
|
-
}
|
|
26453
|
-
const loc = expr[0], x = expr.slice(1);
|
|
26454
|
-
const ret = [];
|
|
26455
|
-
function addRet(elems) {
|
|
26456
|
-
if (Array.isArray(elems)) {
|
|
26457
|
-
elems.forEach((t) => {
|
|
26458
|
-
ret.push(t);
|
|
26459
|
-
});
|
|
26460
|
-
} else {
|
|
26461
|
-
ret.push(elems);
|
|
26462
|
-
}
|
|
26463
|
-
}
|
|
26464
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
26465
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
26466
|
-
} else if (loc === "*") {
|
|
26467
|
-
this._walk(val, (m) => {
|
|
26468
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
26469
|
-
});
|
|
26470
|
-
} else if (loc === "..") {
|
|
26471
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
26472
|
-
this._walk(val, (m) => {
|
|
26473
|
-
if (typeof val[m] === "object") {
|
|
26474
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
26475
|
-
}
|
|
26476
|
-
});
|
|
26477
|
-
} else if (loc === "^") {
|
|
26478
|
-
this._hasParentSelector = true;
|
|
26479
|
-
return {
|
|
26480
|
-
path: path3.slice(0, -1),
|
|
26481
|
-
expr: x,
|
|
26482
|
-
isParentSelector: true
|
|
26483
|
-
};
|
|
26484
|
-
} else if (loc === "~") {
|
|
26485
|
-
retObj = {
|
|
26486
|
-
path: push(path3, loc),
|
|
26487
|
-
value: parentPropName,
|
|
26488
|
-
parent,
|
|
26489
|
-
parentProperty: null
|
|
26490
|
-
};
|
|
26491
|
-
this._handleCallback(retObj, callback, "property");
|
|
26492
|
-
return retObj;
|
|
26493
|
-
} else if (loc === "$") {
|
|
26494
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
26495
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
26496
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
26497
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
26498
|
-
if (this.currEval === false) {
|
|
26499
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
26500
|
-
}
|
|
26501
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
26502
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
26503
|
-
if (nested) {
|
|
26504
|
-
this._walk(val, (m) => {
|
|
26505
|
-
const npath = [nested[2]];
|
|
26506
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
26507
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
26508
|
-
if (filterResults.length > 0) {
|
|
26509
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
26510
|
-
}
|
|
26511
|
-
});
|
|
26512
|
-
} else {
|
|
26513
|
-
this._walk(val, (m) => {
|
|
26514
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
26515
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
26516
|
-
}
|
|
26517
|
-
});
|
|
26518
|
-
}
|
|
26519
|
-
} else if (loc[0] === "(") {
|
|
26520
|
-
if (this.currEval === false) {
|
|
26521
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
26522
|
-
}
|
|
26523
|
-
addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
26524
|
-
} else if (loc[0] === "@") {
|
|
26525
|
-
let addType = false;
|
|
26526
|
-
const valueType = loc.slice(1, -2);
|
|
26527
|
-
switch (valueType) {
|
|
26528
|
-
case "scalar":
|
|
26529
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
26530
|
-
addType = true;
|
|
26531
|
-
}
|
|
26532
|
-
break;
|
|
26533
|
-
case "boolean":
|
|
26534
|
-
case "string":
|
|
26535
|
-
case "undefined":
|
|
26536
|
-
case "function":
|
|
26537
|
-
if (typeof val === valueType) {
|
|
26538
|
-
addType = true;
|
|
26539
|
-
}
|
|
26540
|
-
break;
|
|
26541
|
-
case "integer":
|
|
26542
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
26543
|
-
addType = true;
|
|
26544
|
-
}
|
|
26545
|
-
break;
|
|
26546
|
-
case "number":
|
|
26547
|
-
if (Number.isFinite(val)) {
|
|
26548
|
-
addType = true;
|
|
26549
|
-
}
|
|
26550
|
-
break;
|
|
26551
|
-
case "nonFinite":
|
|
26552
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
26553
|
-
addType = true;
|
|
26554
|
-
}
|
|
26555
|
-
break;
|
|
26556
|
-
case "object":
|
|
26557
|
-
if (val && typeof val === valueType) {
|
|
26558
|
-
addType = true;
|
|
26559
|
-
}
|
|
26560
|
-
break;
|
|
26561
|
-
case "array":
|
|
26562
|
-
if (Array.isArray(val)) {
|
|
26563
|
-
addType = true;
|
|
26564
|
-
}
|
|
26565
|
-
break;
|
|
26566
|
-
case "other":
|
|
26567
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
26568
|
-
break;
|
|
26569
|
-
case "null":
|
|
26570
|
-
if (val === null) {
|
|
26571
|
-
addType = true;
|
|
26572
|
-
}
|
|
26573
|
-
break;
|
|
26574
|
-
default:
|
|
26575
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
26576
|
-
}
|
|
26577
|
-
if (addType) {
|
|
26578
|
-
retObj = {
|
|
26579
|
-
path: path3,
|
|
26580
|
-
value: val,
|
|
26581
|
-
parent,
|
|
26582
|
-
parentProperty: parentPropName
|
|
26583
|
-
};
|
|
26584
|
-
this._handleCallback(retObj, callback, "value");
|
|
26585
|
-
return retObj;
|
|
26586
|
-
}
|
|
26587
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
26588
|
-
const locProp = loc.slice(1);
|
|
26589
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
26590
|
-
} else if (loc.includes(",")) {
|
|
26591
|
-
const parts = loc.split(",");
|
|
26592
|
-
for (const part of parts) {
|
|
26593
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
26594
|
-
}
|
|
26595
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
26596
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
26597
|
-
}
|
|
26598
|
-
if (this._hasParentSelector) {
|
|
26599
|
-
for (let t = 0;t < ret.length; t++) {
|
|
26600
|
-
const rett = ret[t];
|
|
26601
|
-
if (rett && rett.isParentSelector) {
|
|
26602
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
26603
|
-
if (Array.isArray(tmp)) {
|
|
26604
|
-
ret[t] = tmp[0];
|
|
26605
|
-
const tl = tmp.length;
|
|
26606
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
26607
|
-
t++;
|
|
26608
|
-
ret.splice(t, 0, tmp[tt]);
|
|
26609
|
-
}
|
|
26610
|
-
} else {
|
|
26611
|
-
ret[t] = tmp;
|
|
26612
|
-
}
|
|
26613
|
-
}
|
|
26614
|
-
}
|
|
26615
|
-
}
|
|
26616
|
-
return ret;
|
|
26617
|
-
};
|
|
26618
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
26619
|
-
if (Array.isArray(val)) {
|
|
26620
|
-
const n = val.length;
|
|
26621
|
-
for (let i = 0;i < n; i++) {
|
|
26622
|
-
f(i);
|
|
26623
|
-
}
|
|
26624
|
-
} else if (val && typeof val === "object") {
|
|
26625
|
-
Object.keys(val).forEach((m) => {
|
|
26626
|
-
f(m);
|
|
26627
|
-
});
|
|
26628
|
-
}
|
|
26629
|
-
};
|
|
26630
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
26631
|
-
if (!Array.isArray(val)) {
|
|
26632
|
-
return;
|
|
26633
|
-
}
|
|
26634
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
26635
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
26636
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
26637
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
26638
|
-
const ret = [];
|
|
26639
|
-
for (let i = start;i < end; i += step) {
|
|
26640
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
26641
|
-
tmp.forEach((t) => {
|
|
26642
|
-
ret.push(t);
|
|
26643
|
-
});
|
|
26644
|
-
}
|
|
26645
|
-
return ret;
|
|
26646
|
-
};
|
|
26647
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
26648
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
26649
|
-
this.currSandbox._$_parent = parent;
|
|
26650
|
-
this.currSandbox._$_property = _vname;
|
|
26651
|
-
this.currSandbox._$_root = this.json;
|
|
26652
|
-
this.currSandbox._$_v = _v;
|
|
26653
|
-
const containsPath = code.includes("@path");
|
|
26654
|
-
if (containsPath) {
|
|
26655
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
26656
|
-
}
|
|
26657
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
26658
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
26659
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
26660
|
-
if (containsPath) {
|
|
26661
|
-
script = script.replaceAll("@path", "_$_path");
|
|
26662
|
-
}
|
|
26663
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
26664
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
26665
|
-
} else if (this.currEval === "native") {
|
|
26666
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
26667
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
26668
|
-
const CurrEval = this.currEval;
|
|
26669
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
26670
|
-
} else if (typeof this.currEval === "function") {
|
|
26671
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
26672
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
26673
|
-
};
|
|
26674
|
-
} else {
|
|
26675
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
26676
|
-
}
|
|
26677
|
-
}
|
|
26678
|
-
try {
|
|
26679
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
26680
|
-
} catch (e) {
|
|
26681
|
-
if (this.ignoreEvalErrors) {
|
|
26682
|
-
return false;
|
|
26683
|
-
}
|
|
26684
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
26685
|
-
}
|
|
26686
|
-
};
|
|
26687
|
-
JSONPath.cache = {};
|
|
26688
|
-
JSONPath.toPathString = function(pathArr) {
|
|
26689
|
-
const x = pathArr, n = x.length;
|
|
26690
|
-
let p = "$";
|
|
26691
|
-
for (let i = 1;i < n; i++) {
|
|
26692
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
26693
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
26694
|
-
}
|
|
26695
|
-
}
|
|
26696
|
-
return p;
|
|
26697
|
-
};
|
|
26698
|
-
JSONPath.toPointer = function(pointer) {
|
|
26699
|
-
const x = pointer, n = x.length;
|
|
26700
|
-
let p = "";
|
|
26701
|
-
for (let i = 1;i < n; i++) {
|
|
26702
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
26703
|
-
p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
26704
|
-
}
|
|
26705
|
-
}
|
|
26706
|
-
return p;
|
|
26707
|
-
};
|
|
26708
|
-
JSONPath.toPathArray = function(expr) {
|
|
26709
|
-
const {
|
|
26710
|
-
cache
|
|
26711
|
-
} = JSONPath;
|
|
26712
|
-
if (cache[expr]) {
|
|
26713
|
-
return cache[expr].concat();
|
|
26714
|
-
}
|
|
26715
|
-
const subx = [];
|
|
26716
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
26717
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
26718
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
26719
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
26720
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
26721
|
-
return ";" + ups.split("").join(";") + ";";
|
|
26722
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
26723
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
26724
|
-
const match = exp.match(/#(\d+)/u);
|
|
26725
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
26726
|
-
});
|
|
26727
|
-
cache[expr] = exprList;
|
|
26728
|
-
return cache[expr].concat();
|
|
26729
|
-
};
|
|
26730
|
-
JSONPath.prototype.safeVm = {
|
|
26731
|
-
Script: SafeScript
|
|
26732
|
-
};
|
|
26733
|
-
JSONPath.prototype.vm = vm;
|
|
26734
|
-
// ../../common/src/option-aliases.ts
|
|
26735
|
-
import { Option } from "commander";
|
|
26736
|
-
// ../../common/src/option-validators.ts
|
|
26737
|
-
import { InvalidArgumentError } from "commander";
|
|
26738
|
-
// ../../common/src/polling/types.ts
|
|
26739
|
-
var PollOutcome = {
|
|
26740
|
-
Completed: "completed",
|
|
26741
|
-
Timeout: "timeout",
|
|
26742
|
-
Interrupted: "interrupted",
|
|
26743
|
-
Aborted: "aborted",
|
|
26744
|
-
Failed: "failed"
|
|
26745
|
-
};
|
|
26746
|
-
|
|
26747
|
-
// ../../common/src/polling/poll-failure-mapping.ts
|
|
26748
|
-
var REASON_BY_OUTCOME = {
|
|
26749
|
-
[PollOutcome.Timeout]: "poll_timeout",
|
|
26750
|
-
[PollOutcome.Failed]: "poll_failed",
|
|
26751
|
-
[PollOutcome.Interrupted]: "poll_failed",
|
|
26752
|
-
[PollOutcome.Aborted]: "poll_aborted"
|
|
26753
|
-
};
|
|
26754
|
-
// ../../common/src/polling/terminal-statuses.ts
|
|
26755
|
-
var TERMINAL_STATUSES = new Set([
|
|
26756
|
-
"completed",
|
|
26757
|
-
"successful",
|
|
26758
|
-
"faulted",
|
|
26759
|
-
"failed",
|
|
26760
|
-
"cancelled",
|
|
26761
|
-
"canceled",
|
|
26762
|
-
"stopped",
|
|
26763
|
-
"finished"
|
|
26764
|
-
]);
|
|
26765
|
-
var FAILURE_STATUSES = new Set([
|
|
26766
|
-
"faulted",
|
|
26767
|
-
"failed",
|
|
26768
|
-
"cancelled",
|
|
26769
|
-
"canceled",
|
|
26770
|
-
"stopped"
|
|
26771
|
-
]);
|
|
26772
|
-
// ../../common/src/screen-logger.ts
|
|
26773
|
-
var ScreenLogger;
|
|
26774
|
-
((ScreenLogger) => {
|
|
26775
|
-
function progress(message) {
|
|
26776
|
-
getOutputSink().writeErr(`${message}
|
|
26777
|
-
`);
|
|
26778
|
-
}
|
|
26779
|
-
ScreenLogger.progress = progress;
|
|
26780
|
-
})(ScreenLogger ||= {});
|
|
26781
|
-
// ../../common/src/sdk-user-agent.ts
|
|
26782
|
-
var USER_AGENT_HEADER = "User-Agent";
|
|
26783
|
-
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
26784
|
-
function userAgentPatchKey(userAgent) {
|
|
26785
|
-
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
26786
|
-
}
|
|
26787
|
-
function splitUserAgentTokens(value) {
|
|
26788
|
-
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
26789
|
-
}
|
|
26790
|
-
function appendUserAgentToken(value, userAgent) {
|
|
26791
|
-
const tokens = splitUserAgentTokens(value);
|
|
26792
|
-
const seen = new Set(tokens);
|
|
26793
|
-
for (const token of splitUserAgentTokens(userAgent)) {
|
|
26794
|
-
if (!seen.has(token)) {
|
|
26795
|
-
tokens.push(token);
|
|
26796
|
-
seen.add(token);
|
|
26797
|
-
}
|
|
26798
|
-
}
|
|
26799
|
-
return tokens.join(" ");
|
|
26800
|
-
}
|
|
26801
|
-
function getEffectiveUserAgent(userAgent) {
|
|
26802
|
-
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
26803
|
-
}
|
|
26804
|
-
function isHeadersLike(headers) {
|
|
26805
|
-
return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
|
|
26806
|
-
}
|
|
26807
|
-
function getSdkUserAgentToken(pkg) {
|
|
26808
|
-
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
26809
|
-
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
26810
|
-
}
|
|
26811
|
-
function addSdkUserAgentHeader(headers, userAgent) {
|
|
26812
|
-
const result = { ...headers ?? {} };
|
|
26813
|
-
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
26814
|
-
const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
26815
|
-
if (headerName) {
|
|
26816
|
-
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
26817
|
-
} else {
|
|
26818
|
-
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
26819
|
-
}
|
|
26820
|
-
return result;
|
|
26821
|
-
}
|
|
26822
|
-
function withSdkUserAgentHeader(headers, userAgent) {
|
|
26823
|
-
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
26824
|
-
if (isHeadersLike(headers)) {
|
|
26825
|
-
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
26826
|
-
return headers;
|
|
26827
|
-
}
|
|
26828
|
-
if (Array.isArray(headers)) {
|
|
26829
|
-
const result = headers.map((entry) => {
|
|
26830
|
-
const [key, value] = entry;
|
|
26831
|
-
return [key, value];
|
|
26832
|
-
});
|
|
26833
|
-
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
26834
|
-
if (headerIndex >= 0) {
|
|
26835
|
-
const [key, value] = result[headerIndex];
|
|
26836
|
-
result[headerIndex] = [
|
|
26837
|
-
key,
|
|
26838
|
-
appendUserAgentToken(value, effectiveUserAgent)
|
|
26839
|
-
];
|
|
26840
|
-
} else {
|
|
26841
|
-
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
26842
|
-
}
|
|
26843
|
-
return result;
|
|
26844
|
-
}
|
|
26845
|
-
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
26846
|
-
}
|
|
26847
|
-
function withUserAgentInitOverride(initOverrides, userAgent) {
|
|
26848
|
-
return async (requestContext) => {
|
|
26849
|
-
const initWithUserAgent = {
|
|
26850
|
-
...requestContext.init,
|
|
26851
|
-
headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
|
|
26852
|
-
};
|
|
26853
|
-
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
26854
|
-
...requestContext,
|
|
26855
|
-
init: initWithUserAgent
|
|
26856
|
-
}) : initOverrides;
|
|
26857
|
-
return {
|
|
26858
|
-
...override ?? {},
|
|
26859
|
-
headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
|
|
26860
|
-
};
|
|
26861
|
-
};
|
|
26862
|
-
}
|
|
26863
|
-
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
26864
|
-
const prototype = BaseApiClass.prototype;
|
|
26865
|
-
const patchKey = userAgentPatchKey(userAgent);
|
|
26866
|
-
if (prototype[patchKey]) {
|
|
26867
|
-
return;
|
|
26868
|
-
}
|
|
26869
|
-
if (typeof prototype.request !== "function") {
|
|
26870
|
-
throw new Error("Generated BaseAPI request function not found.");
|
|
26871
|
-
}
|
|
26872
|
-
const originalRequest = prototype.request;
|
|
26873
|
-
prototype.request = function requestWithUserAgent(context, initOverrides) {
|
|
26874
|
-
return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
|
|
26875
|
-
};
|
|
26876
|
-
Object.defineProperty(prototype, patchKey, {
|
|
26877
|
-
value: true
|
|
26878
|
-
});
|
|
26879
|
-
}
|
|
26880
|
-
// ../../common/src/tool-provider.ts
|
|
26881
|
-
var factorySlot = singleton("PackagerFactoryProvider");
|
|
26882
|
-
// ../oms-sdk/generated/v1/src/runtime.ts
|
|
26883
|
-
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
26884
|
-
|
|
26885
|
-
class Configuration {
|
|
26886
|
-
configuration;
|
|
26887
|
-
constructor(configuration = {}) {
|
|
26888
|
-
this.configuration = configuration;
|
|
26889
|
-
}
|
|
26890
|
-
set config(configuration) {
|
|
26891
|
-
this.configuration = configuration;
|
|
26892
|
-
}
|
|
26893
|
-
get basePath() {
|
|
26894
|
-
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
26895
|
-
}
|
|
26896
|
-
get fetchApi() {
|
|
26897
|
-
return this.configuration.fetchApi;
|
|
26898
|
-
}
|
|
26899
|
-
get middleware() {
|
|
26900
|
-
return this.configuration.middleware || [];
|
|
26901
|
-
}
|
|
26902
|
-
get queryParamsStringify() {
|
|
26903
|
-
return this.configuration.queryParamsStringify || querystring;
|
|
26904
|
-
}
|
|
26905
|
-
get username() {
|
|
26906
|
-
return this.configuration.username;
|
|
26907
|
-
}
|
|
26908
|
-
get password() {
|
|
26909
|
-
return this.configuration.password;
|
|
26910
|
-
}
|
|
26911
|
-
get apiKey() {
|
|
26912
|
-
const apiKey = this.configuration.apiKey;
|
|
26913
|
-
if (apiKey) {
|
|
26914
|
-
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
26915
|
-
}
|
|
26916
|
-
return;
|
|
26917
|
-
}
|
|
26918
|
-
get accessToken() {
|
|
26919
|
-
const accessToken = this.configuration.accessToken;
|
|
26920
|
-
if (accessToken) {
|
|
26921
|
-
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
26922
|
-
}
|
|
26923
|
-
return;
|
|
26924
|
-
}
|
|
26925
|
-
get headers() {
|
|
26926
|
-
return this.configuration.headers;
|
|
26927
|
-
}
|
|
26928
|
-
get credentials() {
|
|
26929
|
-
return this.configuration.credentials;
|
|
26930
|
-
}
|
|
26931
|
-
}
|
|
26932
|
-
var DefaultConfig = new Configuration;
|
|
26933
|
-
|
|
26934
|
-
class BaseAPI {
|
|
26935
|
-
configuration;
|
|
26936
|
-
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
26937
|
-
middleware;
|
|
26938
|
-
constructor(configuration = DefaultConfig) {
|
|
26939
|
-
this.configuration = configuration;
|
|
26940
|
-
this.middleware = configuration.middleware;
|
|
26941
|
-
}
|
|
26942
|
-
withMiddleware(...middlewares) {
|
|
26943
|
-
const next = this.clone();
|
|
26944
|
-
next.middleware = next.middleware.concat(...middlewares);
|
|
26945
|
-
return next;
|
|
26946
|
-
}
|
|
26947
|
-
withPreMiddleware(...preMiddlewares) {
|
|
26948
|
-
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
26949
|
-
return this.withMiddleware(...middlewares);
|
|
26950
|
-
}
|
|
26951
|
-
withPostMiddleware(...postMiddlewares) {
|
|
26952
|
-
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
26953
|
-
return this.withMiddleware(...middlewares);
|
|
26954
|
-
}
|
|
26955
|
-
isJsonMime(mime) {
|
|
26956
|
-
if (!mime) {
|
|
26957
|
-
return false;
|
|
26958
|
-
}
|
|
26959
|
-
return BaseAPI.jsonRegex.test(mime);
|
|
26960
|
-
}
|
|
26961
|
-
async request(context, initOverrides) {
|
|
26962
|
-
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
26963
|
-
const response = await this.fetchApi(url, init);
|
|
26964
|
-
if (response && (response.status >= 200 && response.status < 300)) {
|
|
26965
|
-
return response;
|
|
26966
|
-
}
|
|
26967
|
-
throw new ResponseError(response, "Response returned an error code");
|
|
26968
|
-
}
|
|
26969
|
-
async createFetchParams(context, initOverrides) {
|
|
26970
|
-
let url = this.configuration.basePath + context.path;
|
|
26971
|
-
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
26972
|
-
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
26973
|
-
}
|
|
26974
|
-
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
26975
|
-
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
26976
|
-
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
26977
|
-
const initParams = {
|
|
26978
|
-
method: context.method,
|
|
26979
|
-
headers,
|
|
26980
|
-
body: context.body,
|
|
26981
|
-
credentials: this.configuration.credentials
|
|
25674
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
25675
|
+
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
25676
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
25677
|
+
const initParams = {
|
|
25678
|
+
method: context.method,
|
|
25679
|
+
headers,
|
|
25680
|
+
body: context.body,
|
|
25681
|
+
credentials: this.configuration.credentials
|
|
26982
25682
|
};
|
|
26983
25683
|
const overriddenInit = {
|
|
26984
25684
|
...initParams,
|
|
@@ -27694,7 +26394,7 @@ function querystringSingleKey3(key, value, keyPrefix = "") {
|
|
|
27694
26394
|
var package_default2 = {
|
|
27695
26395
|
name: "@uipath/oms-sdk",
|
|
27696
26396
|
license: "MIT",
|
|
27697
|
-
version: "1.
|
|
26397
|
+
version: "1.197.0",
|
|
27698
26398
|
description: "SDK for the UiPath Organization Management Service API.",
|
|
27699
26399
|
repository: {
|
|
27700
26400
|
type: "git",
|
|
@@ -27724,7 +26424,7 @@ var package_default2 = {
|
|
|
27724
26424
|
],
|
|
27725
26425
|
private: true,
|
|
27726
26426
|
scripts: {
|
|
27727
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
26427
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
27728
26428
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
27729
26429
|
lint: "biome check ."
|
|
27730
26430
|
},
|
|
@@ -32171,6 +30871,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
32171
30871
|
}
|
|
32172
30872
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
32173
30873
|
};
|
|
30874
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
30875
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
30876
|
+
if (isExternalAppAuth)
|
|
30877
|
+
return requestedScopes;
|
|
30878
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
30879
|
+
};
|
|
32174
30880
|
var resolveConfigAsync = async ({
|
|
32175
30881
|
customAuthority,
|
|
32176
30882
|
customClientId,
|
|
@@ -32201,7 +30907,7 @@ var resolveConfigAsync = async ({
|
|
|
32201
30907
|
clientSecret = fileAuth.clientSecret;
|
|
32202
30908
|
}
|
|
32203
30909
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
32204
|
-
const scopes =
|
|
30910
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
32205
30911
|
return {
|
|
32206
30912
|
clientId,
|
|
32207
30913
|
clientSecret,
|
|
@@ -32216,6 +30922,76 @@ var resolveConfigAsync = async ({
|
|
|
32216
30922
|
init_constants();
|
|
32217
30923
|
// ../../auth/src/loginStatus.ts
|
|
32218
30924
|
init_src();
|
|
30925
|
+
|
|
30926
|
+
// ../../auth/src/authProfile.ts
|
|
30927
|
+
init_src();
|
|
30928
|
+
init_constants();
|
|
30929
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
30930
|
+
var PROFILE_DIR = "profiles";
|
|
30931
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
30932
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
30933
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
30934
|
+
var globalSlot2 = globalThis;
|
|
30935
|
+
function isAuthProfileStorage(value) {
|
|
30936
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
30937
|
+
}
|
|
30938
|
+
function createProfileStorage() {
|
|
30939
|
+
const [error, mod2] = catchError2(() => __require("node:async_hooks"));
|
|
30940
|
+
if (error || typeof mod2?.AsyncLocalStorage !== "function") {
|
|
30941
|
+
return {
|
|
30942
|
+
getStore: () => {
|
|
30943
|
+
return;
|
|
30944
|
+
},
|
|
30945
|
+
run: (_store, fn) => fn()
|
|
30946
|
+
};
|
|
30947
|
+
}
|
|
30948
|
+
return new mod2.AsyncLocalStorage;
|
|
30949
|
+
}
|
|
30950
|
+
function getProfileStorage() {
|
|
30951
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
30952
|
+
if (isAuthProfileStorage(existing)) {
|
|
30953
|
+
return existing;
|
|
30954
|
+
}
|
|
30955
|
+
const storage = createProfileStorage();
|
|
30956
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
30957
|
+
return storage;
|
|
30958
|
+
}
|
|
30959
|
+
var profileStorage = getProfileStorage();
|
|
30960
|
+
|
|
30961
|
+
class AuthProfileValidationError extends Error {
|
|
30962
|
+
constructor(message) {
|
|
30963
|
+
super(message);
|
|
30964
|
+
this.name = "AuthProfileValidationError";
|
|
30965
|
+
}
|
|
30966
|
+
}
|
|
30967
|
+
function normalizeAuthProfileName(profile) {
|
|
30968
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
30969
|
+
return;
|
|
30970
|
+
}
|
|
30971
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
30972
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
30973
|
+
}
|
|
30974
|
+
return profile;
|
|
30975
|
+
}
|
|
30976
|
+
function getActiveAuthProfile() {
|
|
30977
|
+
const scopedState = profileStorage.getStore();
|
|
30978
|
+
if (scopedState !== undefined) {
|
|
30979
|
+
return scopedState.profile;
|
|
30980
|
+
}
|
|
30981
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
30982
|
+
}
|
|
30983
|
+
function resolveAuthProfileFilePath(profile) {
|
|
30984
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
30985
|
+
if (normalized === undefined) {
|
|
30986
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
30987
|
+
}
|
|
30988
|
+
const fs7 = getFileSystem();
|
|
30989
|
+
return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
30990
|
+
}
|
|
30991
|
+
function getActiveAuthProfileFilePath() {
|
|
30992
|
+
const profile = getActiveAuthProfile();
|
|
30993
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
30994
|
+
}
|
|
32219
30995
|
// ../../auth/src/utils/jwt.ts
|
|
32220
30996
|
class InvalidIssuerError extends Error {
|
|
32221
30997
|
expected;
|
|
@@ -32344,23 +31120,74 @@ var readAuthFromEnv = () => {
|
|
|
32344
31120
|
organizationId,
|
|
32345
31121
|
tenantName,
|
|
32346
31122
|
tenantId,
|
|
32347
|
-
expiration
|
|
31123
|
+
expiration,
|
|
31124
|
+
source: "env" /* Env */
|
|
32348
31125
|
};
|
|
32349
31126
|
};
|
|
32350
31127
|
|
|
31128
|
+
// ../../auth/src/refreshCircuitBreaker.ts
|
|
31129
|
+
init_src();
|
|
31130
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
31131
|
+
var BACKOFF_BASE_MS = 60000;
|
|
31132
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
31133
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
31134
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
31135
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
31136
|
+
if (globalThis.crypto?.subtle) {
|
|
31137
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
31138
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
31139
|
+
}
|
|
31140
|
+
const { createHash } = await import("node:crypto");
|
|
31141
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
31142
|
+
}
|
|
31143
|
+
function breakerPathFor(authPath) {
|
|
31144
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
31145
|
+
}
|
|
31146
|
+
async function loadRefreshBreaker(authPath) {
|
|
31147
|
+
const fs7 = getFileSystem();
|
|
31148
|
+
try {
|
|
31149
|
+
const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
|
|
31150
|
+
if (!content)
|
|
31151
|
+
return {};
|
|
31152
|
+
const parsed = JSON.parse(content);
|
|
31153
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
31154
|
+
} catch {
|
|
31155
|
+
return {};
|
|
31156
|
+
}
|
|
31157
|
+
}
|
|
31158
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
31159
|
+
try {
|
|
31160
|
+
const fs7 = getFileSystem();
|
|
31161
|
+
const path3 = breakerPathFor(authPath);
|
|
31162
|
+
await fs7.mkdir(fs7.path.dirname(path3));
|
|
31163
|
+
const tempPath = `${path3}.tmp`;
|
|
31164
|
+
await fs7.writeFile(tempPath, JSON.stringify(state));
|
|
31165
|
+
await fs7.rename(tempPath, path3);
|
|
31166
|
+
} catch {}
|
|
31167
|
+
}
|
|
31168
|
+
async function clearRefreshBreaker(authPath) {
|
|
31169
|
+
const fs7 = getFileSystem();
|
|
31170
|
+
const path3 = breakerPathFor(authPath);
|
|
31171
|
+
try {
|
|
31172
|
+
if (await fs7.exists(path3)) {
|
|
31173
|
+
await fs7.rm(path3);
|
|
31174
|
+
}
|
|
31175
|
+
} catch {}
|
|
31176
|
+
}
|
|
31177
|
+
function nextBackoffMs(attempts) {
|
|
31178
|
+
const shift = Math.max(0, attempts - 1);
|
|
31179
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
31180
|
+
}
|
|
31181
|
+
function shouldSurface(state, nowMs) {
|
|
31182
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
31183
|
+
return true;
|
|
31184
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
31185
|
+
}
|
|
31186
|
+
|
|
32351
31187
|
// ../../auth/src/robotClientFallback.ts
|
|
32352
31188
|
init_src();
|
|
32353
31189
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
32354
31190
|
var CLOSE_TIMEOUT_MS = 500;
|
|
32355
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
32356
|
-
var printNoticeOnce = () => {
|
|
32357
|
-
const slot = globalThis;
|
|
32358
|
-
if (slot[NOTICE_SENTINEL])
|
|
32359
|
-
return;
|
|
32360
|
-
slot[NOTICE_SENTINEL] = true;
|
|
32361
|
-
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
32362
|
-
`));
|
|
32363
|
-
};
|
|
32364
31191
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
32365
31192
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
32366
31193
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -32476,7 +31303,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
32476
31303
|
issuerFromToken = issClaim;
|
|
32477
31304
|
}
|
|
32478
31305
|
}
|
|
32479
|
-
printNoticeOnce();
|
|
32480
31306
|
return {
|
|
32481
31307
|
accessToken,
|
|
32482
31308
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -32701,18 +31527,327 @@ var saveEnvFileAsync = async ({
|
|
|
32701
31527
|
};
|
|
32702
31528
|
|
|
32703
31529
|
// ../../auth/src/loginStatus.ts
|
|
32704
|
-
|
|
32705
|
-
return
|
|
31530
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
31531
|
+
return getLoginStatusWithDeps(options);
|
|
31532
|
+
};
|
|
31533
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
31534
|
+
const {
|
|
31535
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
31536
|
+
loadEnvFile = loadEnvFileAsync,
|
|
31537
|
+
saveEnvFile = saveEnvFileAsync,
|
|
31538
|
+
getFs = getFileSystem,
|
|
31539
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
31540
|
+
resolveConfig = resolveConfigAsync,
|
|
31541
|
+
robotFallback = tryRobotClientFallback,
|
|
31542
|
+
loadBreaker = loadRefreshBreaker,
|
|
31543
|
+
saveBreaker = saveRefreshBreaker,
|
|
31544
|
+
clearBreaker = clearRefreshBreaker
|
|
31545
|
+
} = deps;
|
|
31546
|
+
if (isRobotAuthEnforced()) {
|
|
31547
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
31548
|
+
}
|
|
31549
|
+
if (isEnvAuthEnabled()) {
|
|
31550
|
+
return readAuthFromEnv();
|
|
31551
|
+
}
|
|
31552
|
+
const activeProfile = getActiveAuthProfile();
|
|
31553
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
31554
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
31555
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
31556
|
+
const { ensureTokenValidityMinutes } = options;
|
|
31557
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
31558
|
+
if (absolutePath === undefined) {
|
|
31559
|
+
if (usingActiveProfile) {
|
|
31560
|
+
return {
|
|
31561
|
+
loginStatus: "Not logged in",
|
|
31562
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
31563
|
+
};
|
|
31564
|
+
}
|
|
31565
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
31566
|
+
}
|
|
31567
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
31568
|
+
if ("status" in loaded) {
|
|
31569
|
+
return loaded.status;
|
|
31570
|
+
}
|
|
31571
|
+
const { credentials } = loaded;
|
|
31572
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
31573
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
31574
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
31575
|
+
let tokens = {
|
|
31576
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
31577
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
31578
|
+
expiration,
|
|
31579
|
+
lockReleaseFailed: false
|
|
31580
|
+
};
|
|
31581
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
31582
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
31583
|
+
const refreshed = await attemptRefresh({
|
|
31584
|
+
absolutePath,
|
|
31585
|
+
credentials,
|
|
31586
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
31587
|
+
refreshToken,
|
|
31588
|
+
expiration,
|
|
31589
|
+
ensureTokenValidityMinutes,
|
|
31590
|
+
getFs,
|
|
31591
|
+
loadEnvFile,
|
|
31592
|
+
saveEnvFile,
|
|
31593
|
+
refreshFn: refreshTokenFn,
|
|
31594
|
+
resolveConfig,
|
|
31595
|
+
loadBreaker,
|
|
31596
|
+
saveBreaker,
|
|
31597
|
+
clearBreaker,
|
|
31598
|
+
globalHint
|
|
31599
|
+
});
|
|
31600
|
+
if (refreshed.kind === "terminal") {
|
|
31601
|
+
return refreshed.status;
|
|
31602
|
+
}
|
|
31603
|
+
tokens = refreshed.tokens;
|
|
31604
|
+
}
|
|
31605
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
31606
|
+
};
|
|
31607
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
31608
|
+
if (isEnvAuthEnabled()) {
|
|
31609
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
31610
|
+
}
|
|
31611
|
+
const robotCreds = await robotFallback({ force: true });
|
|
31612
|
+
if (!robotCreds) {
|
|
31613
|
+
return {
|
|
31614
|
+
loginStatus: "Not logged in",
|
|
31615
|
+
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.`
|
|
31616
|
+
};
|
|
31617
|
+
}
|
|
31618
|
+
return buildRobotStatus(robotCreds);
|
|
32706
31619
|
}
|
|
32707
|
-
function
|
|
32708
|
-
|
|
31620
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
31621
|
+
const robotCreds = await robotFallback();
|
|
31622
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
32709
31623
|
}
|
|
32710
|
-
function
|
|
32711
|
-
|
|
31624
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
31625
|
+
let credentials;
|
|
31626
|
+
try {
|
|
31627
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
31628
|
+
} catch (error) {
|
|
31629
|
+
if (isFileNotFoundError(error)) {
|
|
31630
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
31631
|
+
}
|
|
31632
|
+
throw error;
|
|
31633
|
+
}
|
|
31634
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
31635
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
31636
|
+
}
|
|
31637
|
+
return { credentials };
|
|
31638
|
+
}
|
|
31639
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
31640
|
+
const fs7 = getFs();
|
|
31641
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
31642
|
+
if (absolutePath === globalPath)
|
|
31643
|
+
return;
|
|
31644
|
+
if (!await fs7.exists(globalPath))
|
|
31645
|
+
return;
|
|
31646
|
+
try {
|
|
31647
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
31648
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
31649
|
+
return;
|
|
31650
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
31651
|
+
if (globalExp && globalExp <= new Date)
|
|
31652
|
+
return;
|
|
31653
|
+
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.`;
|
|
31654
|
+
} catch {
|
|
31655
|
+
return;
|
|
31656
|
+
}
|
|
32712
31657
|
}
|
|
32713
31658
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
32714
31659
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
32715
31660
|
}
|
|
31661
|
+
async function attemptRefresh(ctx) {
|
|
31662
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
31663
|
+
if (shortCircuit) {
|
|
31664
|
+
return { kind: "terminal", status: shortCircuit };
|
|
31665
|
+
}
|
|
31666
|
+
let release;
|
|
31667
|
+
try {
|
|
31668
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
31669
|
+
} catch (error) {
|
|
31670
|
+
return {
|
|
31671
|
+
kind: "terminal",
|
|
31672
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
31673
|
+
};
|
|
31674
|
+
}
|
|
31675
|
+
let lockedFailure;
|
|
31676
|
+
let lockReleaseFailed = false;
|
|
31677
|
+
let success;
|
|
31678
|
+
try {
|
|
31679
|
+
const outcome = await runRefreshLocked({
|
|
31680
|
+
absolutePath: ctx.absolutePath,
|
|
31681
|
+
refreshToken: ctx.refreshToken,
|
|
31682
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
31683
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
31684
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
31685
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
31686
|
+
refreshFn: ctx.refreshFn,
|
|
31687
|
+
resolveConfig: ctx.resolveConfig,
|
|
31688
|
+
loadBreaker: ctx.loadBreaker,
|
|
31689
|
+
saveBreaker: ctx.saveBreaker,
|
|
31690
|
+
clearBreaker: ctx.clearBreaker
|
|
31691
|
+
});
|
|
31692
|
+
if (outcome.kind === "fail") {
|
|
31693
|
+
lockedFailure = outcome.status;
|
|
31694
|
+
} else {
|
|
31695
|
+
success = outcome;
|
|
31696
|
+
}
|
|
31697
|
+
} finally {
|
|
31698
|
+
try {
|
|
31699
|
+
await release();
|
|
31700
|
+
} catch {
|
|
31701
|
+
lockReleaseFailed = true;
|
|
31702
|
+
}
|
|
31703
|
+
}
|
|
31704
|
+
if (lockedFailure) {
|
|
31705
|
+
const globalHint = await ctx.globalHint();
|
|
31706
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
31707
|
+
return {
|
|
31708
|
+
kind: "terminal",
|
|
31709
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
31710
|
+
};
|
|
31711
|
+
}
|
|
31712
|
+
return {
|
|
31713
|
+
kind: "refreshed",
|
|
31714
|
+
tokens: {
|
|
31715
|
+
accessToken: success?.accessToken,
|
|
31716
|
+
refreshToken: success?.refreshToken,
|
|
31717
|
+
expiration: success?.expiration,
|
|
31718
|
+
tokenRefresh: success?.tokenRefresh,
|
|
31719
|
+
persistenceWarning: success?.persistenceWarning,
|
|
31720
|
+
lockReleaseFailed
|
|
31721
|
+
}
|
|
31722
|
+
};
|
|
31723
|
+
}
|
|
31724
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
31725
|
+
const result = {
|
|
31726
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
31727
|
+
accessToken: tokens.accessToken,
|
|
31728
|
+
refreshToken: tokens.refreshToken,
|
|
31729
|
+
baseUrl: credentials.UIPATH_URL,
|
|
31730
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31731
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31732
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31733
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31734
|
+
expiration: tokens.expiration,
|
|
31735
|
+
source: "file" /* File */,
|
|
31736
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
31737
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
31738
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
31739
|
+
};
|
|
31740
|
+
if (result.loginStatus === "Expired") {
|
|
31741
|
+
const hint = await globalHint();
|
|
31742
|
+
if (hint) {
|
|
31743
|
+
result.hint = hint;
|
|
31744
|
+
}
|
|
31745
|
+
}
|
|
31746
|
+
return result;
|
|
31747
|
+
}
|
|
31748
|
+
function buildRobotStatus(robotCreds) {
|
|
31749
|
+
return {
|
|
31750
|
+
loginStatus: "Logged in",
|
|
31751
|
+
accessToken: robotCreds.accessToken,
|
|
31752
|
+
baseUrl: robotCreds.baseUrl,
|
|
31753
|
+
organizationName: robotCreds.organizationName,
|
|
31754
|
+
organizationId: robotCreds.organizationId,
|
|
31755
|
+
tenantName: robotCreds.tenantName,
|
|
31756
|
+
tenantId: robotCreds.tenantId,
|
|
31757
|
+
issuer: robotCreds.issuer,
|
|
31758
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
31759
|
+
source: "robot" /* Robot */
|
|
31760
|
+
};
|
|
31761
|
+
}
|
|
31762
|
+
var isFileNotFoundError = (error) => {
|
|
31763
|
+
if (!(error instanceof Object))
|
|
31764
|
+
return false;
|
|
31765
|
+
return error.code === "ENOENT";
|
|
31766
|
+
};
|
|
31767
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
31768
|
+
const {
|
|
31769
|
+
absolutePath,
|
|
31770
|
+
refreshToken,
|
|
31771
|
+
accessToken,
|
|
31772
|
+
credentials,
|
|
31773
|
+
expiration,
|
|
31774
|
+
loadBreaker,
|
|
31775
|
+
saveBreaker,
|
|
31776
|
+
clearBreaker
|
|
31777
|
+
} = ctx;
|
|
31778
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
31779
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
31780
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
31781
|
+
await clearBreaker(absolutePath);
|
|
31782
|
+
breaker.deadTokenFp = undefined;
|
|
31783
|
+
}
|
|
31784
|
+
const nowMs = Date.now();
|
|
31785
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
31786
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
31787
|
+
if (!tokenIsDead && !inBackoff)
|
|
31788
|
+
return;
|
|
31789
|
+
const globalHint = await ctx.globalHint();
|
|
31790
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
31791
|
+
if (!suppressed) {
|
|
31792
|
+
await saveBreaker(absolutePath, {
|
|
31793
|
+
...breaker,
|
|
31794
|
+
lastSurfacedAtMs: nowMs
|
|
31795
|
+
});
|
|
31796
|
+
}
|
|
31797
|
+
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>.";
|
|
31798
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
31799
|
+
return {
|
|
31800
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
31801
|
+
...globalHint ? {
|
|
31802
|
+
accessToken,
|
|
31803
|
+
refreshToken,
|
|
31804
|
+
baseUrl: credentials.UIPATH_URL,
|
|
31805
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31806
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31807
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31808
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31809
|
+
expiration,
|
|
31810
|
+
source: "file" /* File */
|
|
31811
|
+
} : {},
|
|
31812
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
31813
|
+
refreshCircuitOpen: true,
|
|
31814
|
+
refreshTelemetrySuppressed: suppressed,
|
|
31815
|
+
tokenRefresh: { attempted: false, success: false }
|
|
31816
|
+
};
|
|
31817
|
+
}
|
|
31818
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
31819
|
+
const msg = errorMessage(error);
|
|
31820
|
+
const globalHint = await ctx.globalHint();
|
|
31821
|
+
if (globalHint) {
|
|
31822
|
+
return {
|
|
31823
|
+
loginStatus: "Expired",
|
|
31824
|
+
accessToken: ctx.accessToken,
|
|
31825
|
+
refreshToken: ctx.refreshToken,
|
|
31826
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
31827
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
31828
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
31829
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
31830
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
31831
|
+
expiration: ctx.expiration,
|
|
31832
|
+
source: "file" /* File */,
|
|
31833
|
+
hint: globalHint,
|
|
31834
|
+
tokenRefresh: {
|
|
31835
|
+
attempted: false,
|
|
31836
|
+
success: false,
|
|
31837
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
31838
|
+
}
|
|
31839
|
+
};
|
|
31840
|
+
}
|
|
31841
|
+
return {
|
|
31842
|
+
loginStatus: "Refresh Failed",
|
|
31843
|
+
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.",
|
|
31844
|
+
tokenRefresh: {
|
|
31845
|
+
attempted: false,
|
|
31846
|
+
success: false,
|
|
31847
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
31848
|
+
}
|
|
31849
|
+
};
|
|
31850
|
+
}
|
|
32716
31851
|
async function runRefreshLocked(inputs) {
|
|
32717
31852
|
const {
|
|
32718
31853
|
absolutePath,
|
|
@@ -32722,7 +31857,10 @@ async function runRefreshLocked(inputs) {
|
|
|
32722
31857
|
loadEnvFile,
|
|
32723
31858
|
saveEnvFile,
|
|
32724
31859
|
refreshFn,
|
|
32725
|
-
resolveConfig
|
|
31860
|
+
resolveConfig,
|
|
31861
|
+
loadBreaker,
|
|
31862
|
+
saveBreaker,
|
|
31863
|
+
clearBreaker
|
|
32726
31864
|
} = inputs;
|
|
32727
31865
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
32728
31866
|
let fresh;
|
|
@@ -32745,6 +31883,7 @@ async function runRefreshLocked(inputs) {
|
|
|
32745
31883
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
32746
31884
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
32747
31885
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
31886
|
+
await clearBreaker(absolutePath);
|
|
32748
31887
|
return {
|
|
32749
31888
|
kind: "ok",
|
|
32750
31889
|
accessToken: freshAccess,
|
|
@@ -32768,8 +31907,21 @@ async function runRefreshLocked(inputs) {
|
|
|
32768
31907
|
refreshedRefresh = refreshed.refreshToken;
|
|
32769
31908
|
} catch (error) {
|
|
32770
31909
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
32771
|
-
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.";
|
|
31910
|
+
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.";
|
|
32772
31911
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
31912
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
31913
|
+
if (isOAuthFailure) {
|
|
31914
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
31915
|
+
} else {
|
|
31916
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
31917
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
31918
|
+
await saveBreaker(absolutePath, {
|
|
31919
|
+
...prior,
|
|
31920
|
+
deadTokenFp: undefined,
|
|
31921
|
+
attempts,
|
|
31922
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
31923
|
+
});
|
|
31924
|
+
}
|
|
32773
31925
|
return {
|
|
32774
31926
|
kind: "fail",
|
|
32775
31927
|
status: {
|
|
@@ -32798,6 +31950,7 @@ async function runRefreshLocked(inputs) {
|
|
|
32798
31950
|
}
|
|
32799
31951
|
};
|
|
32800
31952
|
}
|
|
31953
|
+
await clearBreaker(absolutePath);
|
|
32801
31954
|
try {
|
|
32802
31955
|
await saveEnvFile({
|
|
32803
31956
|
envPath: absolutePath,
|
|
@@ -32830,214 +31983,25 @@ async function runRefreshLocked(inputs) {
|
|
|
32830
31983
|
};
|
|
32831
31984
|
}
|
|
32832
31985
|
}
|
|
32833
|
-
|
|
32834
|
-
|
|
32835
|
-
|
|
32836
|
-
|
|
32837
|
-
|
|
32838
|
-
|
|
32839
|
-
|
|
32840
|
-
|
|
32841
|
-
|
|
32842
|
-
} = deps;
|
|
32843
|
-
if (isRobotAuthEnforced()) {
|
|
32844
|
-
if (isEnvAuthEnabled()) {
|
|
32845
|
-
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
32846
|
-
}
|
|
32847
|
-
const robotCreds = await robotFallback({ force: true });
|
|
32848
|
-
if (!robotCreds) {
|
|
32849
|
-
return {
|
|
32850
|
-
loginStatus: "Not logged in",
|
|
32851
|
-
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.`
|
|
32852
|
-
};
|
|
32853
|
-
}
|
|
32854
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
32855
|
-
return {
|
|
32856
|
-
loginStatus: "Logged in",
|
|
32857
|
-
accessToken: robotCreds.accessToken,
|
|
32858
|
-
baseUrl: robotCreds.baseUrl,
|
|
32859
|
-
organizationName: robotCreds.organizationName,
|
|
32860
|
-
organizationId: robotCreds.organizationId,
|
|
32861
|
-
tenantName: robotCreds.tenantName,
|
|
32862
|
-
tenantId: robotCreds.tenantId,
|
|
32863
|
-
issuer: robotCreds.issuer,
|
|
32864
|
-
expiration: expiration2,
|
|
32865
|
-
source: "robot" /* Robot */
|
|
32866
|
-
};
|
|
32867
|
-
}
|
|
32868
|
-
if (isEnvAuthEnabled()) {
|
|
32869
|
-
return readAuthFromEnv();
|
|
32870
|
-
}
|
|
32871
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
32872
|
-
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
32873
|
-
if (absolutePath === undefined) {
|
|
32874
|
-
const robotCreds = await robotFallback();
|
|
32875
|
-
if (robotCreds) {
|
|
32876
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
32877
|
-
const status = {
|
|
32878
|
-
loginStatus: "Logged in",
|
|
32879
|
-
accessToken: robotCreds.accessToken,
|
|
32880
|
-
baseUrl: robotCreds.baseUrl,
|
|
32881
|
-
organizationName: robotCreds.organizationName,
|
|
32882
|
-
organizationId: robotCreds.organizationId,
|
|
32883
|
-
tenantName: robotCreds.tenantName,
|
|
32884
|
-
tenantId: robotCreds.tenantId,
|
|
32885
|
-
issuer: robotCreds.issuer,
|
|
32886
|
-
expiration: expiration2,
|
|
32887
|
-
source: "robot" /* Robot */
|
|
32888
|
-
};
|
|
32889
|
-
return status;
|
|
32890
|
-
}
|
|
32891
|
-
return { loginStatus: "Not logged in" };
|
|
32892
|
-
}
|
|
32893
|
-
let credentials;
|
|
32894
|
-
try {
|
|
32895
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
32896
|
-
} catch (error) {
|
|
32897
|
-
if (isFileNotFoundError(error)) {
|
|
32898
|
-
return { loginStatus: "Not logged in" };
|
|
32899
|
-
}
|
|
32900
|
-
throw error;
|
|
32901
|
-
}
|
|
32902
|
-
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
32903
|
-
return { loginStatus: "Not logged in" };
|
|
32904
|
-
}
|
|
32905
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
32906
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
32907
|
-
let expiration = getTokenExpiration(accessToken);
|
|
32908
|
-
let persistenceWarning;
|
|
32909
|
-
let lockReleaseFailed = false;
|
|
32910
|
-
let tokenRefresh;
|
|
32911
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
32912
|
-
const tryGlobalCredsHint = async () => {
|
|
32913
|
-
const fs7 = getFs();
|
|
32914
|
-
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
32915
|
-
if (absolutePath === globalPath)
|
|
32916
|
-
return;
|
|
32917
|
-
if (!await fs7.exists(globalPath))
|
|
32918
|
-
return;
|
|
32919
|
-
try {
|
|
32920
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
32921
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
32922
|
-
return;
|
|
32923
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
32924
|
-
if (globalExp && globalExp <= new Date)
|
|
32925
|
-
return;
|
|
32926
|
-
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.`;
|
|
32927
|
-
} catch {
|
|
32928
|
-
return;
|
|
32929
|
-
}
|
|
32930
|
-
};
|
|
32931
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
32932
|
-
let release;
|
|
32933
|
-
try {
|
|
32934
|
-
release = await getFs().acquireLock(absolutePath);
|
|
32935
|
-
} catch (error) {
|
|
32936
|
-
const msg = errorMessage(error);
|
|
32937
|
-
const globalHint = await tryGlobalCredsHint();
|
|
32938
|
-
if (globalHint) {
|
|
32939
|
-
return {
|
|
32940
|
-
loginStatus: "Expired",
|
|
32941
|
-
accessToken,
|
|
32942
|
-
refreshToken,
|
|
32943
|
-
baseUrl: credentials.UIPATH_URL,
|
|
32944
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
32945
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
32946
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
32947
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
32948
|
-
expiration,
|
|
32949
|
-
source: "file" /* File */,
|
|
32950
|
-
hint: globalHint,
|
|
32951
|
-
tokenRefresh: {
|
|
32952
|
-
attempted: false,
|
|
32953
|
-
success: false,
|
|
32954
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
32955
|
-
}
|
|
32956
|
-
};
|
|
32957
|
-
}
|
|
32958
|
-
return {
|
|
32959
|
-
loginStatus: "Refresh Failed",
|
|
32960
|
-
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.",
|
|
32961
|
-
tokenRefresh: {
|
|
32962
|
-
attempted: false,
|
|
32963
|
-
success: false,
|
|
32964
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
32965
|
-
}
|
|
32966
|
-
};
|
|
32967
|
-
}
|
|
32968
|
-
let lockedFailure;
|
|
32969
|
-
try {
|
|
32970
|
-
const outcome = await runRefreshLocked({
|
|
32971
|
-
absolutePath,
|
|
32972
|
-
refreshToken,
|
|
32973
|
-
customAuthority: credentials.UIPATH_URL,
|
|
32974
|
-
ensureTokenValidityMinutes,
|
|
32975
|
-
loadEnvFile,
|
|
32976
|
-
saveEnvFile,
|
|
32977
|
-
refreshFn: refreshTokenFn,
|
|
32978
|
-
resolveConfig
|
|
32979
|
-
});
|
|
32980
|
-
if (outcome.kind === "fail") {
|
|
32981
|
-
lockedFailure = outcome.status;
|
|
32982
|
-
} else {
|
|
32983
|
-
accessToken = outcome.accessToken;
|
|
32984
|
-
refreshToken = outcome.refreshToken;
|
|
32985
|
-
expiration = outcome.expiration;
|
|
32986
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
32987
|
-
if (outcome.persistenceWarning) {
|
|
32988
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
32989
|
-
}
|
|
32990
|
-
}
|
|
32991
|
-
} finally {
|
|
32992
|
-
try {
|
|
32993
|
-
await release();
|
|
32994
|
-
} catch {
|
|
32995
|
-
lockReleaseFailed = true;
|
|
32996
|
-
}
|
|
32997
|
-
}
|
|
32998
|
-
if (lockedFailure) {
|
|
32999
|
-
const globalHint = await tryGlobalCredsHint();
|
|
33000
|
-
const base = globalHint ? {
|
|
33001
|
-
...lockedFailure,
|
|
33002
|
-
loginStatus: "Expired",
|
|
33003
|
-
hint: globalHint
|
|
33004
|
-
} : lockedFailure;
|
|
33005
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
33006
|
-
}
|
|
33007
|
-
}
|
|
33008
|
-
const result = {
|
|
33009
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
33010
|
-
accessToken,
|
|
33011
|
-
refreshToken,
|
|
33012
|
-
baseUrl: credentials.UIPATH_URL,
|
|
33013
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
33014
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
33015
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
33016
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
33017
|
-
expiration,
|
|
33018
|
-
source: "file" /* File */,
|
|
33019
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
33020
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
33021
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
33022
|
-
};
|
|
33023
|
-
if (result.loginStatus === "Expired") {
|
|
33024
|
-
const globalHint = await tryGlobalCredsHint();
|
|
33025
|
-
if (globalHint) {
|
|
33026
|
-
result.hint = globalHint;
|
|
33027
|
-
}
|
|
33028
|
-
}
|
|
33029
|
-
return result;
|
|
33030
|
-
};
|
|
33031
|
-
var isFileNotFoundError = (error) => {
|
|
33032
|
-
if (!(error instanceof Object))
|
|
33033
|
-
return false;
|
|
33034
|
-
return error.code === "ENOENT";
|
|
33035
|
-
};
|
|
33036
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
33037
|
-
return getLoginStatusWithDeps(options);
|
|
33038
|
-
};
|
|
31986
|
+
function normalizeTokenRefreshFailure() {
|
|
31987
|
+
return "stored refresh token is invalid or expired";
|
|
31988
|
+
}
|
|
31989
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
31990
|
+
return "token refresh failed before authentication completed";
|
|
31991
|
+
}
|
|
31992
|
+
function errorMessage(error) {
|
|
31993
|
+
return error instanceof Error ? error.message : String(error);
|
|
31994
|
+
}
|
|
33039
31995
|
// ../../auth/src/interactive.ts
|
|
33040
31996
|
init_src();
|
|
31997
|
+
|
|
31998
|
+
// ../../auth/src/selectTenant.ts
|
|
31999
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
32000
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
32001
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
32002
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
32003
|
+
INVALID_TENANT_CODE
|
|
32004
|
+
]);
|
|
33041
32005
|
// ../../auth/src/logout.ts
|
|
33042
32006
|
init_src();
|
|
33043
32007
|
|
|
@@ -34289,3 +33253,5 @@ export {
|
|
|
34289
33253
|
registerCommands,
|
|
34290
33254
|
metadata
|
|
34291
33255
|
};
|
|
33256
|
+
|
|
33257
|
+
//# debugId=46FB7EEC72E37B3764756E2164756E21
|