@uipath/platform-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 +2 -0
- package/dist/tool.js +872 -1907
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -44724,7 +44724,7 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
44724
44724
|
var package_default = {
|
|
44725
44725
|
name: "@uipath/platform-tool",
|
|
44726
44726
|
license: "MIT",
|
|
44727
|
-
version: "1.
|
|
44727
|
+
version: "1.197.0-preview.59",
|
|
44728
44728
|
description: "Manage UiPath platform-level resources such as tenant licensing.",
|
|
44729
44729
|
type: "module",
|
|
44730
44730
|
main: "./dist/tool.js",
|
|
@@ -44806,6 +44806,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
44806
44806
|
}
|
|
44807
44807
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
44808
44808
|
};
|
|
44809
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
44810
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
44811
|
+
if (isExternalAppAuth)
|
|
44812
|
+
return requestedScopes;
|
|
44813
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
44814
|
+
};
|
|
44809
44815
|
var resolveConfigAsync = async ({
|
|
44810
44816
|
customAuthority,
|
|
44811
44817
|
customClientId,
|
|
@@ -44836,7 +44842,7 @@ var resolveConfigAsync = async ({
|
|
|
44836
44842
|
clientSecret = fileAuth.clientSecret;
|
|
44837
44843
|
}
|
|
44838
44844
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
44839
|
-
const scopes =
|
|
44845
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
44840
44846
|
return {
|
|
44841
44847
|
clientId,
|
|
44842
44848
|
clientSecret,
|
|
@@ -44851,6 +44857,76 @@ var resolveConfigAsync = async ({
|
|
|
44851
44857
|
init_constants();
|
|
44852
44858
|
// ../auth/src/loginStatus.ts
|
|
44853
44859
|
init_src();
|
|
44860
|
+
|
|
44861
|
+
// ../auth/src/authProfile.ts
|
|
44862
|
+
init_src();
|
|
44863
|
+
init_constants();
|
|
44864
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
44865
|
+
var PROFILE_DIR = "profiles";
|
|
44866
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
44867
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
44868
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
44869
|
+
var globalSlot2 = globalThis;
|
|
44870
|
+
function isAuthProfileStorage(value) {
|
|
44871
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
44872
|
+
}
|
|
44873
|
+
function createProfileStorage() {
|
|
44874
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
44875
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
44876
|
+
return {
|
|
44877
|
+
getStore: () => {
|
|
44878
|
+
return;
|
|
44879
|
+
},
|
|
44880
|
+
run: (_store, fn) => fn()
|
|
44881
|
+
};
|
|
44882
|
+
}
|
|
44883
|
+
return new mod.AsyncLocalStorage;
|
|
44884
|
+
}
|
|
44885
|
+
function getProfileStorage() {
|
|
44886
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
44887
|
+
if (isAuthProfileStorage(existing)) {
|
|
44888
|
+
return existing;
|
|
44889
|
+
}
|
|
44890
|
+
const storage = createProfileStorage();
|
|
44891
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
44892
|
+
return storage;
|
|
44893
|
+
}
|
|
44894
|
+
var profileStorage = getProfileStorage();
|
|
44895
|
+
|
|
44896
|
+
class AuthProfileValidationError extends Error {
|
|
44897
|
+
constructor(message) {
|
|
44898
|
+
super(message);
|
|
44899
|
+
this.name = "AuthProfileValidationError";
|
|
44900
|
+
}
|
|
44901
|
+
}
|
|
44902
|
+
function normalizeAuthProfileName(profile) {
|
|
44903
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
44904
|
+
return;
|
|
44905
|
+
}
|
|
44906
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
44907
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
44908
|
+
}
|
|
44909
|
+
return profile;
|
|
44910
|
+
}
|
|
44911
|
+
function getActiveAuthProfile() {
|
|
44912
|
+
const scopedState = profileStorage.getStore();
|
|
44913
|
+
if (scopedState !== undefined) {
|
|
44914
|
+
return scopedState.profile;
|
|
44915
|
+
}
|
|
44916
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
44917
|
+
}
|
|
44918
|
+
function resolveAuthProfileFilePath(profile) {
|
|
44919
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
44920
|
+
if (normalized === undefined) {
|
|
44921
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
44922
|
+
}
|
|
44923
|
+
const fs7 = getFileSystem();
|
|
44924
|
+
return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
44925
|
+
}
|
|
44926
|
+
function getActiveAuthProfileFilePath() {
|
|
44927
|
+
const profile = getActiveAuthProfile();
|
|
44928
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
44929
|
+
}
|
|
44854
44930
|
// ../auth/src/utils/jwt.ts
|
|
44855
44931
|
class InvalidIssuerError extends Error {
|
|
44856
44932
|
expected;
|
|
@@ -44979,23 +45055,74 @@ var readAuthFromEnv = () => {
|
|
|
44979
45055
|
organizationId,
|
|
44980
45056
|
tenantName,
|
|
44981
45057
|
tenantId,
|
|
44982
|
-
expiration
|
|
45058
|
+
expiration,
|
|
45059
|
+
source: "env" /* Env */
|
|
44983
45060
|
};
|
|
44984
45061
|
};
|
|
44985
45062
|
|
|
45063
|
+
// ../auth/src/refreshCircuitBreaker.ts
|
|
45064
|
+
init_src();
|
|
45065
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
45066
|
+
var BACKOFF_BASE_MS = 60000;
|
|
45067
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
45068
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
45069
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
45070
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
45071
|
+
if (globalThis.crypto?.subtle) {
|
|
45072
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
45073
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
45074
|
+
}
|
|
45075
|
+
const { createHash } = await import("node:crypto");
|
|
45076
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
45077
|
+
}
|
|
45078
|
+
function breakerPathFor(authPath) {
|
|
45079
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
45080
|
+
}
|
|
45081
|
+
async function loadRefreshBreaker(authPath) {
|
|
45082
|
+
const fs7 = getFileSystem();
|
|
45083
|
+
try {
|
|
45084
|
+
const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
|
|
45085
|
+
if (!content)
|
|
45086
|
+
return {};
|
|
45087
|
+
const parsed = JSON.parse(content);
|
|
45088
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
45089
|
+
} catch {
|
|
45090
|
+
return {};
|
|
45091
|
+
}
|
|
45092
|
+
}
|
|
45093
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
45094
|
+
try {
|
|
45095
|
+
const fs7 = getFileSystem();
|
|
45096
|
+
const path3 = breakerPathFor(authPath);
|
|
45097
|
+
await fs7.mkdir(fs7.path.dirname(path3));
|
|
45098
|
+
const tempPath = `${path3}.tmp`;
|
|
45099
|
+
await fs7.writeFile(tempPath, JSON.stringify(state));
|
|
45100
|
+
await fs7.rename(tempPath, path3);
|
|
45101
|
+
} catch {}
|
|
45102
|
+
}
|
|
45103
|
+
async function clearRefreshBreaker(authPath) {
|
|
45104
|
+
const fs7 = getFileSystem();
|
|
45105
|
+
const path3 = breakerPathFor(authPath);
|
|
45106
|
+
try {
|
|
45107
|
+
if (await fs7.exists(path3)) {
|
|
45108
|
+
await fs7.rm(path3);
|
|
45109
|
+
}
|
|
45110
|
+
} catch {}
|
|
45111
|
+
}
|
|
45112
|
+
function nextBackoffMs(attempts) {
|
|
45113
|
+
const shift = Math.max(0, attempts - 1);
|
|
45114
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
45115
|
+
}
|
|
45116
|
+
function shouldSurface(state, nowMs) {
|
|
45117
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
45118
|
+
return true;
|
|
45119
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
45120
|
+
}
|
|
45121
|
+
|
|
44986
45122
|
// ../auth/src/robotClientFallback.ts
|
|
44987
45123
|
init_src();
|
|
44988
45124
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
44989
45125
|
var CLOSE_TIMEOUT_MS = 500;
|
|
44990
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
44991
|
-
var printNoticeOnce = () => {
|
|
44992
|
-
const slot = globalThis;
|
|
44993
|
-
if (slot[NOTICE_SENTINEL])
|
|
44994
|
-
return;
|
|
44995
|
-
slot[NOTICE_SENTINEL] = true;
|
|
44996
|
-
catchError(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
44997
|
-
`));
|
|
44998
|
-
};
|
|
44999
45126
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
45000
45127
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
45001
45128
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -45111,7 +45238,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
45111
45238
|
issuerFromToken = issClaim;
|
|
45112
45239
|
}
|
|
45113
45240
|
}
|
|
45114
|
-
printNoticeOnce();
|
|
45115
45241
|
return {
|
|
45116
45242
|
accessToken,
|
|
45117
45243
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -45336,18 +45462,327 @@ var saveEnvFileAsync = async ({
|
|
|
45336
45462
|
};
|
|
45337
45463
|
|
|
45338
45464
|
// ../auth/src/loginStatus.ts
|
|
45339
|
-
|
|
45340
|
-
return
|
|
45465
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
45466
|
+
return getLoginStatusWithDeps(options);
|
|
45467
|
+
};
|
|
45468
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
45469
|
+
const {
|
|
45470
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
45471
|
+
loadEnvFile = loadEnvFileAsync,
|
|
45472
|
+
saveEnvFile = saveEnvFileAsync,
|
|
45473
|
+
getFs = getFileSystem,
|
|
45474
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
45475
|
+
resolveConfig = resolveConfigAsync,
|
|
45476
|
+
robotFallback = tryRobotClientFallback,
|
|
45477
|
+
loadBreaker = loadRefreshBreaker,
|
|
45478
|
+
saveBreaker = saveRefreshBreaker,
|
|
45479
|
+
clearBreaker = clearRefreshBreaker
|
|
45480
|
+
} = deps;
|
|
45481
|
+
if (isRobotAuthEnforced()) {
|
|
45482
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
45483
|
+
}
|
|
45484
|
+
if (isEnvAuthEnabled()) {
|
|
45485
|
+
return readAuthFromEnv();
|
|
45486
|
+
}
|
|
45487
|
+
const activeProfile = getActiveAuthProfile();
|
|
45488
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
45489
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
45490
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
45491
|
+
const { ensureTokenValidityMinutes } = options;
|
|
45492
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
45493
|
+
if (absolutePath === undefined) {
|
|
45494
|
+
if (usingActiveProfile) {
|
|
45495
|
+
return {
|
|
45496
|
+
loginStatus: "Not logged in",
|
|
45497
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
45498
|
+
};
|
|
45499
|
+
}
|
|
45500
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
45501
|
+
}
|
|
45502
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
45503
|
+
if ("status" in loaded) {
|
|
45504
|
+
return loaded.status;
|
|
45505
|
+
}
|
|
45506
|
+
const { credentials } = loaded;
|
|
45507
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
45508
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
45509
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
45510
|
+
let tokens = {
|
|
45511
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
45512
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
45513
|
+
expiration,
|
|
45514
|
+
lockReleaseFailed: false
|
|
45515
|
+
};
|
|
45516
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
45517
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
45518
|
+
const refreshed = await attemptRefresh({
|
|
45519
|
+
absolutePath,
|
|
45520
|
+
credentials,
|
|
45521
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
45522
|
+
refreshToken,
|
|
45523
|
+
expiration,
|
|
45524
|
+
ensureTokenValidityMinutes,
|
|
45525
|
+
getFs,
|
|
45526
|
+
loadEnvFile,
|
|
45527
|
+
saveEnvFile,
|
|
45528
|
+
refreshFn: refreshTokenFn,
|
|
45529
|
+
resolveConfig,
|
|
45530
|
+
loadBreaker,
|
|
45531
|
+
saveBreaker,
|
|
45532
|
+
clearBreaker,
|
|
45533
|
+
globalHint
|
|
45534
|
+
});
|
|
45535
|
+
if (refreshed.kind === "terminal") {
|
|
45536
|
+
return refreshed.status;
|
|
45537
|
+
}
|
|
45538
|
+
tokens = refreshed.tokens;
|
|
45539
|
+
}
|
|
45540
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
45541
|
+
};
|
|
45542
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
45543
|
+
if (isEnvAuthEnabled()) {
|
|
45544
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
45545
|
+
}
|
|
45546
|
+
const robotCreds = await robotFallback({ force: true });
|
|
45547
|
+
if (!robotCreds) {
|
|
45548
|
+
return {
|
|
45549
|
+
loginStatus: "Not logged in",
|
|
45550
|
+
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.`
|
|
45551
|
+
};
|
|
45552
|
+
}
|
|
45553
|
+
return buildRobotStatus(robotCreds);
|
|
45341
45554
|
}
|
|
45342
|
-
function
|
|
45343
|
-
|
|
45555
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
45556
|
+
const robotCreds = await robotFallback();
|
|
45557
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
45344
45558
|
}
|
|
45345
|
-
function
|
|
45346
|
-
|
|
45559
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
45560
|
+
let credentials;
|
|
45561
|
+
try {
|
|
45562
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
45563
|
+
} catch (error) {
|
|
45564
|
+
if (isFileNotFoundError(error)) {
|
|
45565
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
45566
|
+
}
|
|
45567
|
+
throw error;
|
|
45568
|
+
}
|
|
45569
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
45570
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
45571
|
+
}
|
|
45572
|
+
return { credentials };
|
|
45573
|
+
}
|
|
45574
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
45575
|
+
const fs7 = getFs();
|
|
45576
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
45577
|
+
if (absolutePath === globalPath)
|
|
45578
|
+
return;
|
|
45579
|
+
if (!await fs7.exists(globalPath))
|
|
45580
|
+
return;
|
|
45581
|
+
try {
|
|
45582
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
45583
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
45584
|
+
return;
|
|
45585
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
45586
|
+
if (globalExp && globalExp <= new Date)
|
|
45587
|
+
return;
|
|
45588
|
+
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.`;
|
|
45589
|
+
} catch {
|
|
45590
|
+
return;
|
|
45591
|
+
}
|
|
45347
45592
|
}
|
|
45348
45593
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
45349
45594
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
45350
45595
|
}
|
|
45596
|
+
async function attemptRefresh(ctx) {
|
|
45597
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
45598
|
+
if (shortCircuit) {
|
|
45599
|
+
return { kind: "terminal", status: shortCircuit };
|
|
45600
|
+
}
|
|
45601
|
+
let release;
|
|
45602
|
+
try {
|
|
45603
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
45604
|
+
} catch (error) {
|
|
45605
|
+
return {
|
|
45606
|
+
kind: "terminal",
|
|
45607
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
45608
|
+
};
|
|
45609
|
+
}
|
|
45610
|
+
let lockedFailure;
|
|
45611
|
+
let lockReleaseFailed = false;
|
|
45612
|
+
let success;
|
|
45613
|
+
try {
|
|
45614
|
+
const outcome = await runRefreshLocked({
|
|
45615
|
+
absolutePath: ctx.absolutePath,
|
|
45616
|
+
refreshToken: ctx.refreshToken,
|
|
45617
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
45618
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
45619
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
45620
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
45621
|
+
refreshFn: ctx.refreshFn,
|
|
45622
|
+
resolveConfig: ctx.resolveConfig,
|
|
45623
|
+
loadBreaker: ctx.loadBreaker,
|
|
45624
|
+
saveBreaker: ctx.saveBreaker,
|
|
45625
|
+
clearBreaker: ctx.clearBreaker
|
|
45626
|
+
});
|
|
45627
|
+
if (outcome.kind === "fail") {
|
|
45628
|
+
lockedFailure = outcome.status;
|
|
45629
|
+
} else {
|
|
45630
|
+
success = outcome;
|
|
45631
|
+
}
|
|
45632
|
+
} finally {
|
|
45633
|
+
try {
|
|
45634
|
+
await release();
|
|
45635
|
+
} catch {
|
|
45636
|
+
lockReleaseFailed = true;
|
|
45637
|
+
}
|
|
45638
|
+
}
|
|
45639
|
+
if (lockedFailure) {
|
|
45640
|
+
const globalHint = await ctx.globalHint();
|
|
45641
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
45642
|
+
return {
|
|
45643
|
+
kind: "terminal",
|
|
45644
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
45645
|
+
};
|
|
45646
|
+
}
|
|
45647
|
+
return {
|
|
45648
|
+
kind: "refreshed",
|
|
45649
|
+
tokens: {
|
|
45650
|
+
accessToken: success?.accessToken,
|
|
45651
|
+
refreshToken: success?.refreshToken,
|
|
45652
|
+
expiration: success?.expiration,
|
|
45653
|
+
tokenRefresh: success?.tokenRefresh,
|
|
45654
|
+
persistenceWarning: success?.persistenceWarning,
|
|
45655
|
+
lockReleaseFailed
|
|
45656
|
+
}
|
|
45657
|
+
};
|
|
45658
|
+
}
|
|
45659
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
45660
|
+
const result = {
|
|
45661
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
45662
|
+
accessToken: tokens.accessToken,
|
|
45663
|
+
refreshToken: tokens.refreshToken,
|
|
45664
|
+
baseUrl: credentials.UIPATH_URL,
|
|
45665
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
45666
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
45667
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
45668
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
45669
|
+
expiration: tokens.expiration,
|
|
45670
|
+
source: "file" /* File */,
|
|
45671
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
45672
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
45673
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
45674
|
+
};
|
|
45675
|
+
if (result.loginStatus === "Expired") {
|
|
45676
|
+
const hint = await globalHint();
|
|
45677
|
+
if (hint) {
|
|
45678
|
+
result.hint = hint;
|
|
45679
|
+
}
|
|
45680
|
+
}
|
|
45681
|
+
return result;
|
|
45682
|
+
}
|
|
45683
|
+
function buildRobotStatus(robotCreds) {
|
|
45684
|
+
return {
|
|
45685
|
+
loginStatus: "Logged in",
|
|
45686
|
+
accessToken: robotCreds.accessToken,
|
|
45687
|
+
baseUrl: robotCreds.baseUrl,
|
|
45688
|
+
organizationName: robotCreds.organizationName,
|
|
45689
|
+
organizationId: robotCreds.organizationId,
|
|
45690
|
+
tenantName: robotCreds.tenantName,
|
|
45691
|
+
tenantId: robotCreds.tenantId,
|
|
45692
|
+
issuer: robotCreds.issuer,
|
|
45693
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
45694
|
+
source: "robot" /* Robot */
|
|
45695
|
+
};
|
|
45696
|
+
}
|
|
45697
|
+
var isFileNotFoundError = (error) => {
|
|
45698
|
+
if (!(error instanceof Object))
|
|
45699
|
+
return false;
|
|
45700
|
+
return error.code === "ENOENT";
|
|
45701
|
+
};
|
|
45702
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
45703
|
+
const {
|
|
45704
|
+
absolutePath,
|
|
45705
|
+
refreshToken,
|
|
45706
|
+
accessToken,
|
|
45707
|
+
credentials,
|
|
45708
|
+
expiration,
|
|
45709
|
+
loadBreaker,
|
|
45710
|
+
saveBreaker,
|
|
45711
|
+
clearBreaker
|
|
45712
|
+
} = ctx;
|
|
45713
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
45714
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
45715
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
45716
|
+
await clearBreaker(absolutePath);
|
|
45717
|
+
breaker.deadTokenFp = undefined;
|
|
45718
|
+
}
|
|
45719
|
+
const nowMs = Date.now();
|
|
45720
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
45721
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
45722
|
+
if (!tokenIsDead && !inBackoff)
|
|
45723
|
+
return;
|
|
45724
|
+
const globalHint = await ctx.globalHint();
|
|
45725
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
45726
|
+
if (!suppressed) {
|
|
45727
|
+
await saveBreaker(absolutePath, {
|
|
45728
|
+
...breaker,
|
|
45729
|
+
lastSurfacedAtMs: nowMs
|
|
45730
|
+
});
|
|
45731
|
+
}
|
|
45732
|
+
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>.";
|
|
45733
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
45734
|
+
return {
|
|
45735
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
45736
|
+
...globalHint ? {
|
|
45737
|
+
accessToken,
|
|
45738
|
+
refreshToken,
|
|
45739
|
+
baseUrl: credentials.UIPATH_URL,
|
|
45740
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
45741
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
45742
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
45743
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
45744
|
+
expiration,
|
|
45745
|
+
source: "file" /* File */
|
|
45746
|
+
} : {},
|
|
45747
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
45748
|
+
refreshCircuitOpen: true,
|
|
45749
|
+
refreshTelemetrySuppressed: suppressed,
|
|
45750
|
+
tokenRefresh: { attempted: false, success: false }
|
|
45751
|
+
};
|
|
45752
|
+
}
|
|
45753
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
45754
|
+
const msg = errorMessage(error);
|
|
45755
|
+
const globalHint = await ctx.globalHint();
|
|
45756
|
+
if (globalHint) {
|
|
45757
|
+
return {
|
|
45758
|
+
loginStatus: "Expired",
|
|
45759
|
+
accessToken: ctx.accessToken,
|
|
45760
|
+
refreshToken: ctx.refreshToken,
|
|
45761
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
45762
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
45763
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
45764
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
45765
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
45766
|
+
expiration: ctx.expiration,
|
|
45767
|
+
source: "file" /* File */,
|
|
45768
|
+
hint: globalHint,
|
|
45769
|
+
tokenRefresh: {
|
|
45770
|
+
attempted: false,
|
|
45771
|
+
success: false,
|
|
45772
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
45773
|
+
}
|
|
45774
|
+
};
|
|
45775
|
+
}
|
|
45776
|
+
return {
|
|
45777
|
+
loginStatus: "Refresh Failed",
|
|
45778
|
+
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.",
|
|
45779
|
+
tokenRefresh: {
|
|
45780
|
+
attempted: false,
|
|
45781
|
+
success: false,
|
|
45782
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
45783
|
+
}
|
|
45784
|
+
};
|
|
45785
|
+
}
|
|
45351
45786
|
async function runRefreshLocked(inputs) {
|
|
45352
45787
|
const {
|
|
45353
45788
|
absolutePath,
|
|
@@ -45357,7 +45792,10 @@ async function runRefreshLocked(inputs) {
|
|
|
45357
45792
|
loadEnvFile,
|
|
45358
45793
|
saveEnvFile,
|
|
45359
45794
|
refreshFn,
|
|
45360
|
-
resolveConfig
|
|
45795
|
+
resolveConfig,
|
|
45796
|
+
loadBreaker,
|
|
45797
|
+
saveBreaker,
|
|
45798
|
+
clearBreaker
|
|
45361
45799
|
} = inputs;
|
|
45362
45800
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
45363
45801
|
let fresh;
|
|
@@ -45380,6 +45818,7 @@ async function runRefreshLocked(inputs) {
|
|
|
45380
45818
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
45381
45819
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
45382
45820
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
45821
|
+
await clearBreaker(absolutePath);
|
|
45383
45822
|
return {
|
|
45384
45823
|
kind: "ok",
|
|
45385
45824
|
accessToken: freshAccess,
|
|
@@ -45403,8 +45842,21 @@ async function runRefreshLocked(inputs) {
|
|
|
45403
45842
|
refreshedRefresh = refreshed.refreshToken;
|
|
45404
45843
|
} catch (error) {
|
|
45405
45844
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
45406
|
-
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.";
|
|
45845
|
+
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.";
|
|
45407
45846
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
45847
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
45848
|
+
if (isOAuthFailure) {
|
|
45849
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
45850
|
+
} else {
|
|
45851
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
45852
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
45853
|
+
await saveBreaker(absolutePath, {
|
|
45854
|
+
...prior,
|
|
45855
|
+
deadTokenFp: undefined,
|
|
45856
|
+
attempts,
|
|
45857
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
45858
|
+
});
|
|
45859
|
+
}
|
|
45408
45860
|
return {
|
|
45409
45861
|
kind: "fail",
|
|
45410
45862
|
status: {
|
|
@@ -45433,6 +45885,7 @@ async function runRefreshLocked(inputs) {
|
|
|
45433
45885
|
}
|
|
45434
45886
|
};
|
|
45435
45887
|
}
|
|
45888
|
+
await clearBreaker(absolutePath);
|
|
45436
45889
|
try {
|
|
45437
45890
|
await saveEnvFile({
|
|
45438
45891
|
envPath: absolutePath,
|
|
@@ -45465,234 +45918,37 @@ async function runRefreshLocked(inputs) {
|
|
|
45465
45918
|
};
|
|
45466
45919
|
}
|
|
45467
45920
|
}
|
|
45468
|
-
|
|
45469
|
-
|
|
45470
|
-
|
|
45471
|
-
|
|
45472
|
-
|
|
45473
|
-
|
|
45474
|
-
|
|
45475
|
-
|
|
45476
|
-
|
|
45477
|
-
|
|
45478
|
-
|
|
45479
|
-
|
|
45480
|
-
|
|
45481
|
-
|
|
45482
|
-
|
|
45483
|
-
|
|
45484
|
-
|
|
45485
|
-
|
|
45486
|
-
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.`
|
|
45487
|
-
};
|
|
45488
|
-
}
|
|
45489
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
45490
|
-
return {
|
|
45491
|
-
loginStatus: "Logged in",
|
|
45492
|
-
accessToken: robotCreds.accessToken,
|
|
45493
|
-
baseUrl: robotCreds.baseUrl,
|
|
45494
|
-
organizationName: robotCreds.organizationName,
|
|
45495
|
-
organizationId: robotCreds.organizationId,
|
|
45496
|
-
tenantName: robotCreds.tenantName,
|
|
45497
|
-
tenantId: robotCreds.tenantId,
|
|
45498
|
-
issuer: robotCreds.issuer,
|
|
45499
|
-
expiration: expiration2,
|
|
45500
|
-
source: "robot" /* Robot */
|
|
45501
|
-
};
|
|
45921
|
+
function normalizeTokenRefreshFailure() {
|
|
45922
|
+
return "stored refresh token is invalid or expired";
|
|
45923
|
+
}
|
|
45924
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
45925
|
+
return "token refresh failed before authentication completed";
|
|
45926
|
+
}
|
|
45927
|
+
function errorMessage(error) {
|
|
45928
|
+
return error instanceof Error ? error.message : String(error);
|
|
45929
|
+
}
|
|
45930
|
+
|
|
45931
|
+
// ../auth/src/authContext.ts
|
|
45932
|
+
var getAuthContext = async (options = {}) => {
|
|
45933
|
+
const status = await getLoginStatusAsync({
|
|
45934
|
+
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
45935
|
+
envFilePath: options.envFilePath
|
|
45936
|
+
});
|
|
45937
|
+
if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
|
|
45938
|
+
throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
|
|
45502
45939
|
}
|
|
45503
|
-
|
|
45504
|
-
|
|
45940
|
+
const tenantName = options.tenant ?? status.tenantName;
|
|
45941
|
+
if (options.requireOrganizationId && !status.organizationId) {
|
|
45942
|
+
throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
|
|
45505
45943
|
}
|
|
45506
|
-
|
|
45507
|
-
|
|
45508
|
-
if (absolutePath === undefined) {
|
|
45509
|
-
const robotCreds = await robotFallback();
|
|
45510
|
-
if (robotCreds) {
|
|
45511
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
45512
|
-
const status = {
|
|
45513
|
-
loginStatus: "Logged in",
|
|
45514
|
-
accessToken: robotCreds.accessToken,
|
|
45515
|
-
baseUrl: robotCreds.baseUrl,
|
|
45516
|
-
organizationName: robotCreds.organizationName,
|
|
45517
|
-
organizationId: robotCreds.organizationId,
|
|
45518
|
-
tenantName: robotCreds.tenantName,
|
|
45519
|
-
tenantId: robotCreds.tenantId,
|
|
45520
|
-
issuer: robotCreds.issuer,
|
|
45521
|
-
expiration: expiration2,
|
|
45522
|
-
source: "robot" /* Robot */
|
|
45523
|
-
};
|
|
45524
|
-
return status;
|
|
45525
|
-
}
|
|
45526
|
-
return { loginStatus: "Not logged in" };
|
|
45944
|
+
if (options.requireOrganizationName && !status.organizationName) {
|
|
45945
|
+
throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
|
|
45527
45946
|
}
|
|
45528
|
-
|
|
45529
|
-
|
|
45530
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
45531
|
-
} catch (error) {
|
|
45532
|
-
if (isFileNotFoundError(error)) {
|
|
45533
|
-
return { loginStatus: "Not logged in" };
|
|
45534
|
-
}
|
|
45535
|
-
throw error;
|
|
45947
|
+
if (options.requireTenantId && !status.tenantId) {
|
|
45948
|
+
throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
|
|
45536
45949
|
}
|
|
45537
|
-
if (
|
|
45538
|
-
|
|
45539
|
-
}
|
|
45540
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
45541
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
45542
|
-
let expiration = getTokenExpiration(accessToken);
|
|
45543
|
-
let persistenceWarning;
|
|
45544
|
-
let lockReleaseFailed = false;
|
|
45545
|
-
let tokenRefresh;
|
|
45546
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
45547
|
-
const tryGlobalCredsHint = async () => {
|
|
45548
|
-
const fs7 = getFs();
|
|
45549
|
-
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
45550
|
-
if (absolutePath === globalPath)
|
|
45551
|
-
return;
|
|
45552
|
-
if (!await fs7.exists(globalPath))
|
|
45553
|
-
return;
|
|
45554
|
-
try {
|
|
45555
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
45556
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
45557
|
-
return;
|
|
45558
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
45559
|
-
if (globalExp && globalExp <= new Date)
|
|
45560
|
-
return;
|
|
45561
|
-
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.`;
|
|
45562
|
-
} catch {
|
|
45563
|
-
return;
|
|
45564
|
-
}
|
|
45565
|
-
};
|
|
45566
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
45567
|
-
let release;
|
|
45568
|
-
try {
|
|
45569
|
-
release = await getFs().acquireLock(absolutePath);
|
|
45570
|
-
} catch (error) {
|
|
45571
|
-
const msg = errorMessage(error);
|
|
45572
|
-
const globalHint = await tryGlobalCredsHint();
|
|
45573
|
-
if (globalHint) {
|
|
45574
|
-
return {
|
|
45575
|
-
loginStatus: "Expired",
|
|
45576
|
-
accessToken,
|
|
45577
|
-
refreshToken,
|
|
45578
|
-
baseUrl: credentials.UIPATH_URL,
|
|
45579
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
45580
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
45581
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
45582
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
45583
|
-
expiration,
|
|
45584
|
-
source: "file" /* File */,
|
|
45585
|
-
hint: globalHint,
|
|
45586
|
-
tokenRefresh: {
|
|
45587
|
-
attempted: false,
|
|
45588
|
-
success: false,
|
|
45589
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
45590
|
-
}
|
|
45591
|
-
};
|
|
45592
|
-
}
|
|
45593
|
-
return {
|
|
45594
|
-
loginStatus: "Refresh Failed",
|
|
45595
|
-
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.",
|
|
45596
|
-
tokenRefresh: {
|
|
45597
|
-
attempted: false,
|
|
45598
|
-
success: false,
|
|
45599
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
45600
|
-
}
|
|
45601
|
-
};
|
|
45602
|
-
}
|
|
45603
|
-
let lockedFailure;
|
|
45604
|
-
try {
|
|
45605
|
-
const outcome = await runRefreshLocked({
|
|
45606
|
-
absolutePath,
|
|
45607
|
-
refreshToken,
|
|
45608
|
-
customAuthority: credentials.UIPATH_URL,
|
|
45609
|
-
ensureTokenValidityMinutes,
|
|
45610
|
-
loadEnvFile,
|
|
45611
|
-
saveEnvFile,
|
|
45612
|
-
refreshFn: refreshTokenFn,
|
|
45613
|
-
resolveConfig
|
|
45614
|
-
});
|
|
45615
|
-
if (outcome.kind === "fail") {
|
|
45616
|
-
lockedFailure = outcome.status;
|
|
45617
|
-
} else {
|
|
45618
|
-
accessToken = outcome.accessToken;
|
|
45619
|
-
refreshToken = outcome.refreshToken;
|
|
45620
|
-
expiration = outcome.expiration;
|
|
45621
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
45622
|
-
if (outcome.persistenceWarning) {
|
|
45623
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
45624
|
-
}
|
|
45625
|
-
}
|
|
45626
|
-
} finally {
|
|
45627
|
-
try {
|
|
45628
|
-
await release();
|
|
45629
|
-
} catch {
|
|
45630
|
-
lockReleaseFailed = true;
|
|
45631
|
-
}
|
|
45632
|
-
}
|
|
45633
|
-
if (lockedFailure) {
|
|
45634
|
-
const globalHint = await tryGlobalCredsHint();
|
|
45635
|
-
const base = globalHint ? {
|
|
45636
|
-
...lockedFailure,
|
|
45637
|
-
loginStatus: "Expired",
|
|
45638
|
-
hint: globalHint
|
|
45639
|
-
} : lockedFailure;
|
|
45640
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
45641
|
-
}
|
|
45642
|
-
}
|
|
45643
|
-
const result = {
|
|
45644
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
45645
|
-
accessToken,
|
|
45646
|
-
refreshToken,
|
|
45647
|
-
baseUrl: credentials.UIPATH_URL,
|
|
45648
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
45649
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
45650
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
45651
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
45652
|
-
expiration,
|
|
45653
|
-
source: "file" /* File */,
|
|
45654
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
45655
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
45656
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
45657
|
-
};
|
|
45658
|
-
if (result.loginStatus === "Expired") {
|
|
45659
|
-
const globalHint = await tryGlobalCredsHint();
|
|
45660
|
-
if (globalHint) {
|
|
45661
|
-
result.hint = globalHint;
|
|
45662
|
-
}
|
|
45663
|
-
}
|
|
45664
|
-
return result;
|
|
45665
|
-
};
|
|
45666
|
-
var isFileNotFoundError = (error) => {
|
|
45667
|
-
if (!(error instanceof Object))
|
|
45668
|
-
return false;
|
|
45669
|
-
return error.code === "ENOENT";
|
|
45670
|
-
};
|
|
45671
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
45672
|
-
return getLoginStatusWithDeps(options);
|
|
45673
|
-
};
|
|
45674
|
-
|
|
45675
|
-
// ../auth/src/authContext.ts
|
|
45676
|
-
var getAuthContext = async (options = {}) => {
|
|
45677
|
-
const status = await getLoginStatusAsync({
|
|
45678
|
-
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
45679
|
-
envFilePath: options.envFilePath
|
|
45680
|
-
});
|
|
45681
|
-
if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
|
|
45682
|
-
throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
|
|
45683
|
-
}
|
|
45684
|
-
const tenantName = options.tenant ?? status.tenantName;
|
|
45685
|
-
if (options.requireOrganizationId && !status.organizationId) {
|
|
45686
|
-
throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
|
|
45687
|
-
}
|
|
45688
|
-
if (options.requireOrganizationName && !status.organizationName) {
|
|
45689
|
-
throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
|
|
45690
|
-
}
|
|
45691
|
-
if (options.requireTenantId && !status.tenantId) {
|
|
45692
|
-
throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
|
|
45693
|
-
}
|
|
45694
|
-
if (options.requireTenantName && tenantName === undefined) {
|
|
45695
|
-
throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
|
|
45950
|
+
if (options.requireTenantName && tenantName === undefined) {
|
|
45951
|
+
throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
|
|
45696
45952
|
}
|
|
45697
45953
|
return {
|
|
45698
45954
|
baseUrl: status.baseUrl,
|
|
@@ -45724,6 +45980,14 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
45724
45980
|
const data = await response.json();
|
|
45725
45981
|
return data;
|
|
45726
45982
|
};
|
|
45983
|
+
|
|
45984
|
+
// ../auth/src/selectTenant.ts
|
|
45985
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
45986
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
45987
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
45988
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
45989
|
+
INVALID_TENANT_CODE
|
|
45990
|
+
]);
|
|
45727
45991
|
// ../auth/src/logout.ts
|
|
45728
45992
|
init_src();
|
|
45729
45993
|
|
|
@@ -45777,27 +46041,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
45777
46041
|
"ENETUNREACH",
|
|
45778
46042
|
"EAI_FAIL"
|
|
45779
46043
|
]);
|
|
45780
|
-
|
|
45781
|
-
|
|
45782
|
-
|
|
45783
|
-
|
|
45784
|
-
|
|
45785
|
-
|
|
45786
|
-
|
|
45787
|
-
|
|
45788
|
-
|
|
45789
|
-
|
|
45790
|
-
|
|
45791
|
-
|
|
45792
|
-
|
|
45793
|
-
|
|
45794
|
-
|
|
45795
|
-
|
|
45796
|
-
|
|
46044
|
+
var TLS_ERROR_CODES = new Set([
|
|
46045
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
46046
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
46047
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
46048
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
46049
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
46050
|
+
"CERT_HAS_EXPIRED",
|
|
46051
|
+
"CERT_UNTRUSTED",
|
|
46052
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
46053
|
+
]);
|
|
46054
|
+
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.";
|
|
46055
|
+
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.";
|
|
46056
|
+
function describeConnectivityError(error) {
|
|
46057
|
+
let current = error;
|
|
46058
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
46059
|
+
const cur = current;
|
|
46060
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
46061
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
46062
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
46063
|
+
return {
|
|
46064
|
+
code,
|
|
46065
|
+
kind: "tls",
|
|
46066
|
+
message: message ?? code,
|
|
46067
|
+
instructions: TLS_INSTRUCTIONS
|
|
46068
|
+
};
|
|
46069
|
+
}
|
|
46070
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
46071
|
+
return {
|
|
46072
|
+
code,
|
|
46073
|
+
kind: "network",
|
|
46074
|
+
message: message ?? code,
|
|
46075
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
46076
|
+
};
|
|
45797
46077
|
}
|
|
46078
|
+
current = cur.cause;
|
|
45798
46079
|
}
|
|
45799
46080
|
return;
|
|
45800
46081
|
}
|
|
46082
|
+
function parseHttpStatusFromMessage(message) {
|
|
46083
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
46084
|
+
if (!match)
|
|
46085
|
+
return;
|
|
46086
|
+
const status = Number(match[1]);
|
|
46087
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
46088
|
+
}
|
|
46089
|
+
function isHtmlDocument(body) {
|
|
46090
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
46091
|
+
}
|
|
45801
46092
|
function retryHintForRetryAfter(seconds) {
|
|
45802
46093
|
if (seconds <= 1) {
|
|
45803
46094
|
return "RetryAfter1Second";
|
|
@@ -45838,15 +46129,28 @@ function classifyError(status, error) {
|
|
|
45838
46129
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
45839
46130
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
45840
46131
|
}
|
|
45841
|
-
|
|
45842
|
-
|
|
46132
|
+
const connectivity = describeConnectivityError(error);
|
|
46133
|
+
if (connectivity) {
|
|
46134
|
+
return {
|
|
46135
|
+
errorCode: "network_error",
|
|
46136
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
46137
|
+
};
|
|
45843
46138
|
}
|
|
45844
46139
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
45845
46140
|
}
|
|
46141
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
46142
|
+
if (extractedMessage) {
|
|
46143
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
46144
|
+
}
|
|
46145
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
46146
|
+
}
|
|
45846
46147
|
async function extractErrorDetails(error, options) {
|
|
45847
46148
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
45848
46149
|
const response = err.response;
|
|
45849
|
-
const
|
|
46150
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
46151
|
+
const explicitStatus = err.status ?? response?.status;
|
|
46152
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
46153
|
+
const status = explicitStatus ?? inferredStatus;
|
|
45850
46154
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
45851
46155
|
let rawBody;
|
|
45852
46156
|
let extractedMessage;
|
|
@@ -45881,7 +46185,6 @@ async function extractErrorDetails(error, options) {
|
|
|
45881
46185
|
}
|
|
45882
46186
|
}
|
|
45883
46187
|
}
|
|
45884
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
45885
46188
|
let message;
|
|
45886
46189
|
let result = "Failure";
|
|
45887
46190
|
const classification = classifyError(status, error);
|
|
@@ -45895,10 +46198,10 @@ async function extractErrorDetails(error, options) {
|
|
|
45895
46198
|
} else if (status === 405) {
|
|
45896
46199
|
message = DEFAULT_405;
|
|
45897
46200
|
} else if (status === 400 || status === 422) {
|
|
45898
|
-
message =
|
|
46201
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
45899
46202
|
result = "ValidationError";
|
|
45900
46203
|
} else if (status === 429) {
|
|
45901
|
-
message =
|
|
46204
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
45902
46205
|
} else if (extractedMessage) {
|
|
45903
46206
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
45904
46207
|
message = rawMessage;
|
|
@@ -45906,7 +46209,9 @@ async function extractErrorDetails(error, options) {
|
|
|
45906
46209
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
45907
46210
|
}
|
|
45908
46211
|
} else if (status) {
|
|
45909
|
-
if (
|
|
46212
|
+
if (inferredStatus !== undefined) {
|
|
46213
|
+
message = rawMessage;
|
|
46214
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
45910
46215
|
const statusText = response.statusText;
|
|
45911
46216
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
45912
46217
|
} else {
|
|
@@ -45915,6 +46220,12 @@ async function extractErrorDetails(error, options) {
|
|
|
45915
46220
|
} else {
|
|
45916
46221
|
message = rawMessage;
|
|
45917
46222
|
}
|
|
46223
|
+
if (status === undefined) {
|
|
46224
|
+
const connectivity = describeConnectivityError(error);
|
|
46225
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
46226
|
+
message = `${message}: ${connectivity.message}`;
|
|
46227
|
+
}
|
|
46228
|
+
}
|
|
45918
46229
|
let details = rawMessage;
|
|
45919
46230
|
if (rawBody) {
|
|
45920
46231
|
if (parsedBody) {
|
|
@@ -46082,6 +46393,7 @@ var CONSOLE_FALLBACK = {
|
|
|
46082
46393
|
writeLog: (str) => process.stdout.write(str),
|
|
46083
46394
|
capabilities: {
|
|
46084
46395
|
isInteractive: false,
|
|
46396
|
+
canReadInput: false,
|
|
46085
46397
|
supportsColor: false,
|
|
46086
46398
|
outputWidth: 80
|
|
46087
46399
|
}
|
|
@@ -51303,6 +51615,29 @@ function isPlainRecord(value) {
|
|
|
51303
51615
|
const prototype = Object.getPrototypeOf(value);
|
|
51304
51616
|
return prototype === Object.prototype || prototype === null;
|
|
51305
51617
|
}
|
|
51618
|
+
function extractPagedRows(value) {
|
|
51619
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
51620
|
+
return null;
|
|
51621
|
+
const entries = Object.values(value);
|
|
51622
|
+
if (entries.length === 0)
|
|
51623
|
+
return null;
|
|
51624
|
+
let rows = null;
|
|
51625
|
+
let hasScalarSibling = false;
|
|
51626
|
+
for (const entry of entries) {
|
|
51627
|
+
if (Array.isArray(entry)) {
|
|
51628
|
+
if (rows !== null)
|
|
51629
|
+
return null;
|
|
51630
|
+
rows = entry;
|
|
51631
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
51632
|
+
return null;
|
|
51633
|
+
} else {
|
|
51634
|
+
hasScalarSibling = true;
|
|
51635
|
+
}
|
|
51636
|
+
}
|
|
51637
|
+
if (rows === null || !hasScalarSibling)
|
|
51638
|
+
return null;
|
|
51639
|
+
return rows;
|
|
51640
|
+
}
|
|
51306
51641
|
function toLowerCamelCaseKey(key) {
|
|
51307
51642
|
if (!key)
|
|
51308
51643
|
return key;
|
|
@@ -51367,7 +51702,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
51367
51702
|
break;
|
|
51368
51703
|
case "plain": {
|
|
51369
51704
|
if ("Data" in data && data.Data != null) {
|
|
51370
|
-
const
|
|
51705
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
51706
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
51371
51707
|
items.forEach((item) => {
|
|
51372
51708
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
51373
51709
|
logFn(values);
|
|
@@ -51379,10 +51715,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
51379
51715
|
break;
|
|
51380
51716
|
}
|
|
51381
51717
|
default: {
|
|
51382
|
-
|
|
51718
|
+
const hasData = "Data" in data && data.Data != null;
|
|
51719
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
51720
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
51721
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
51383
51722
|
const logValue = data.Log;
|
|
51384
|
-
if (
|
|
51385
|
-
printResizableTable(
|
|
51723
|
+
if (rows !== null) {
|
|
51724
|
+
printResizableTable(rows, logFn, logValue);
|
|
51386
51725
|
} else {
|
|
51387
51726
|
printVerticalTable(data.Data, logFn, logValue);
|
|
51388
51727
|
}
|
|
@@ -51570,6 +51909,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
51570
51909
|
return "unknown_error";
|
|
51571
51910
|
}
|
|
51572
51911
|
}
|
|
51912
|
+
function parseHttpStatusFromMessage2(message) {
|
|
51913
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
51914
|
+
if (!match)
|
|
51915
|
+
return;
|
|
51916
|
+
const status = Number(match[1]);
|
|
51917
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
51918
|
+
}
|
|
51919
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
51920
|
+
if (status === undefined)
|
|
51921
|
+
return;
|
|
51922
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
51923
|
+
return "invalid_argument";
|
|
51924
|
+
}
|
|
51925
|
+
if (status === 401)
|
|
51926
|
+
return "authentication_required";
|
|
51927
|
+
if (status === 403)
|
|
51928
|
+
return "permission_denied";
|
|
51929
|
+
if (status === 404)
|
|
51930
|
+
return "not_found";
|
|
51931
|
+
if (status === 405)
|
|
51932
|
+
return "method_not_allowed";
|
|
51933
|
+
if (status === 408)
|
|
51934
|
+
return "timeout";
|
|
51935
|
+
if (status === 429)
|
|
51936
|
+
return "rate_limited";
|
|
51937
|
+
if (status >= 500 && status < 600)
|
|
51938
|
+
return "server_error";
|
|
51939
|
+
return;
|
|
51940
|
+
}
|
|
51941
|
+
function defaultErrorCodeForFailure(data) {
|
|
51942
|
+
if (data.Result === RESULTS.Failure) {
|
|
51943
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
51944
|
+
const errorCode2 = defaultErrorCodeForHttpStatus(status);
|
|
51945
|
+
if (errorCode2)
|
|
51946
|
+
return errorCode2;
|
|
51947
|
+
}
|
|
51948
|
+
return defaultErrorCodeForResult(data.Result);
|
|
51949
|
+
}
|
|
51573
51950
|
function defaultRetryForErrorCode(errorCode2) {
|
|
51574
51951
|
switch (errorCode2) {
|
|
51575
51952
|
case "network_error":
|
|
@@ -51599,16 +51976,19 @@ var OutputFormatter;
|
|
|
51599
51976
|
OutputFormatter.success = success;
|
|
51600
51977
|
function error(data) {
|
|
51601
51978
|
data.Log ??= getLogFilePath() || undefined;
|
|
51602
|
-
data.ErrorCode ??=
|
|
51979
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
51603
51980
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
51604
51981
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
51605
|
-
|
|
51606
|
-
|
|
51607
|
-
|
|
51608
|
-
|
|
51609
|
-
|
|
51610
|
-
|
|
51611
|
-
|
|
51982
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
51983
|
+
if (!SuppressTelemetry) {
|
|
51984
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
51985
|
+
result: data.Result,
|
|
51986
|
+
errorCode: data.ErrorCode,
|
|
51987
|
+
retry: data.Retry,
|
|
51988
|
+
message: data.Message
|
|
51989
|
+
});
|
|
51990
|
+
}
|
|
51991
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
51612
51992
|
}
|
|
51613
51993
|
OutputFormatter.error = error;
|
|
51614
51994
|
function emitList(code, items, opts) {
|
|
@@ -51694,1613 +52074,210 @@ var SENSITIVE_KEY_PREFIXES = new Set([
|
|
|
51694
52074
|
"encryption",
|
|
51695
52075
|
"session",
|
|
51696
52076
|
"master",
|
|
51697
|
-
"shared",
|
|
51698
|
-
"root",
|
|
51699
|
-
"ssh",
|
|
51700
|
-
"rsa",
|
|
51701
|
-
"aes",
|
|
51702
|
-
"hmac",
|
|
51703
|
-
"oauth"
|
|
51704
|
-
]);
|
|
51705
|
-
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
51706
|
-
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
51707
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
51708
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
51709
|
-
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
51710
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
51711
|
-
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
51712
|
-
function shortHash(input) {
|
|
51713
|
-
let hash = 2166136261;
|
|
51714
|
-
for (let i = 0;i < input.length; i++) {
|
|
51715
|
-
hash ^= input.charCodeAt(i);
|
|
51716
|
-
hash = Math.imul(hash, 16777619);
|
|
51717
|
-
}
|
|
51718
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
51719
|
-
}
|
|
51720
|
-
function redactUrl(raw) {
|
|
51721
|
-
try {
|
|
51722
|
-
const url = new URL(raw);
|
|
51723
|
-
return `${url.protocol}//${url.host}`;
|
|
51724
|
-
} catch {
|
|
51725
|
-
return `url#${shortHash(raw)}`;
|
|
51726
|
-
}
|
|
51727
|
-
}
|
|
51728
|
-
function redactValueDetectors(value) {
|
|
51729
|
-
let out = value;
|
|
51730
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
51731
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
51732
|
-
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
51733
|
-
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
51734
|
-
return `${redactUrl(core)}${trailing}`;
|
|
51735
|
-
});
|
|
51736
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
51737
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
51738
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
51739
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
51740
|
-
if (out.length > MAX_VALUE_LENGTH) {
|
|
51741
|
-
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
51742
|
-
}
|
|
51743
|
-
return out;
|
|
51744
|
-
}
|
|
51745
|
-
function nameTokens(name) {
|
|
51746
|
-
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
51747
|
-
}
|
|
51748
|
-
function isSensitiveName(name) {
|
|
51749
|
-
const tokens = nameTokens(name);
|
|
51750
|
-
for (let i = 0;i < tokens.length; i++) {
|
|
51751
|
-
const token = tokens[i];
|
|
51752
|
-
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
51753
|
-
return true;
|
|
51754
|
-
}
|
|
51755
|
-
if (token === "key" || token === "keys") {
|
|
51756
|
-
const prev = tokens[i - 1];
|
|
51757
|
-
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
51758
|
-
return true;
|
|
51759
|
-
}
|
|
51760
|
-
}
|
|
51761
|
-
}
|
|
51762
|
-
return false;
|
|
51763
|
-
}
|
|
51764
|
-
function redactProperty(name, value) {
|
|
51765
|
-
if (value === undefined || value === null) {
|
|
51766
|
-
return;
|
|
51767
|
-
}
|
|
51768
|
-
if (isSensitiveName(name)) {
|
|
51769
|
-
return REDACTED;
|
|
51770
|
-
}
|
|
51771
|
-
if (typeof value === "boolean" || typeof value === "number") {
|
|
51772
|
-
return value;
|
|
51773
|
-
}
|
|
51774
|
-
if (typeof value !== "string") {
|
|
51775
|
-
return "[OBJECT]";
|
|
51776
|
-
}
|
|
51777
|
-
return redactValueDetectors(value);
|
|
51778
|
-
}
|
|
51779
|
-
function redactProperties(properties) {
|
|
51780
|
-
const out = {};
|
|
51781
|
-
for (const [name, value] of Object.entries(properties)) {
|
|
51782
|
-
const redacted = redactProperty(name, value);
|
|
51783
|
-
if (redacted !== undefined) {
|
|
51784
|
-
out[name] = redacted;
|
|
51785
|
-
}
|
|
51786
|
-
}
|
|
51787
|
-
return out;
|
|
51788
|
-
}
|
|
51789
|
-
|
|
51790
|
-
// ../common/src/trackedAction.ts
|
|
51791
|
-
var pollSignalSlot = singleton("PollSignal");
|
|
51792
|
-
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
51793
|
-
var retryHintValues = new Set(RETRY_HINTS);
|
|
51794
|
-
var processContext = {
|
|
51795
|
-
exit: (code) => {
|
|
51796
|
-
process.exitCode = code;
|
|
51797
|
-
},
|
|
51798
|
-
get pollSignal() {
|
|
51799
|
-
return pollSignalSlot.get();
|
|
51800
|
-
}
|
|
51801
|
-
};
|
|
51802
|
-
function extractCommandParams(cmd) {
|
|
51803
|
-
const params = {};
|
|
51804
|
-
const registered = cmd.registeredArguments ?? [];
|
|
51805
|
-
const processed = cmd.processedArgs ?? [];
|
|
51806
|
-
for (let i = 0;i < registered.length; i++) {
|
|
51807
|
-
const value = processed[i];
|
|
51808
|
-
if (value === undefined) {
|
|
51809
|
-
continue;
|
|
51810
|
-
}
|
|
51811
|
-
const name = registered[i].name();
|
|
51812
|
-
if (name) {
|
|
51813
|
-
params[name] = value;
|
|
51814
|
-
}
|
|
51815
|
-
}
|
|
51816
|
-
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
51817
|
-
if (value !== undefined) {
|
|
51818
|
-
params[key] = value;
|
|
51819
|
-
}
|
|
51820
|
-
}
|
|
51821
|
-
return params;
|
|
51822
|
-
}
|
|
51823
|
-
function deriveCommandPath(cmd) {
|
|
51824
|
-
const parts = [];
|
|
51825
|
-
let current = cmd;
|
|
51826
|
-
while (current) {
|
|
51827
|
-
const name = current.name();
|
|
51828
|
-
if (name) {
|
|
51829
|
-
parts.unshift(name);
|
|
51830
|
-
}
|
|
51831
|
-
current = current.parent;
|
|
51832
|
-
}
|
|
51833
|
-
if (parts.length > 1) {
|
|
51834
|
-
parts.shift();
|
|
51835
|
-
}
|
|
51836
|
-
return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
|
|
51837
|
-
}
|
|
51838
|
-
function isCliErrorCode(value) {
|
|
51839
|
-
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
51840
|
-
}
|
|
51841
|
-
function isRetryHint(value) {
|
|
51842
|
-
return typeof value === "string" && retryHintValues.has(value);
|
|
51843
|
-
}
|
|
51844
|
-
function isErrorContext(value) {
|
|
51845
|
-
return value !== null && typeof value === "object";
|
|
51846
|
-
}
|
|
51847
|
-
function commandHelpHint(commandPath) {
|
|
51848
|
-
const command = commandPath.replace(/\./g, " ");
|
|
51849
|
-
return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
51850
|
-
}
|
|
51851
|
-
Command.prototype.trackedAction = function(context, fn, properties) {
|
|
51852
|
-
const command = this;
|
|
51853
|
-
return this.action(async (...args) => {
|
|
51854
|
-
const telemetryName = deriveCommandPath(command);
|
|
51855
|
-
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
51856
|
-
const startTime = performance.now();
|
|
51857
|
-
let errorMessage2;
|
|
51858
|
-
const [error] = await catchError2(fn(...args));
|
|
51859
|
-
if (error) {
|
|
51860
|
-
errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
51861
|
-
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage2}`);
|
|
51862
|
-
const typed = error;
|
|
51863
|
-
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
51864
|
-
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
51865
|
-
const finalResult = customResult ?? RESULTS.Failure;
|
|
51866
|
-
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
51867
|
-
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
51868
|
-
const typedRetry = typed.retry ?? typed.Retry;
|
|
51869
|
-
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
51870
|
-
const typedContext = typed.context ?? typed.Context;
|
|
51871
|
-
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
51872
|
-
OutputFormatter.error({
|
|
51873
|
-
Result: finalResult,
|
|
51874
|
-
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
51875
|
-
Message: errorMessage2,
|
|
51876
|
-
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
51877
|
-
...customRetry ? { Retry: customRetry } : {},
|
|
51878
|
-
...customContext ? { Context: customContext } : {}
|
|
51879
|
-
});
|
|
51880
|
-
context.exit(EXIT_CODES[finalResult]);
|
|
51881
|
-
}
|
|
51882
|
-
const durationMs = performance.now() - startTime;
|
|
51883
|
-
const success = !error && (process.exitCode === undefined || process.exitCode === 0);
|
|
51884
|
-
telemetry.trackEvent(telemetryName, redactProperties({
|
|
51885
|
-
...extractCommandParams(command),
|
|
51886
|
-
...props,
|
|
51887
|
-
command: "true",
|
|
51888
|
-
duration: String(durationMs),
|
|
51889
|
-
success: String(success),
|
|
51890
|
-
...errorMessage2 ? { errorMessage: errorMessage2 } : {}
|
|
51891
|
-
}));
|
|
51892
|
-
});
|
|
51893
|
-
};
|
|
51894
|
-
// ../common/src/console-guard.ts
|
|
51895
|
-
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
51896
|
-
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
51897
|
-
// ../common/src/constants.ts
|
|
51898
|
-
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
51899
|
-
// ../common/src/interactivity-context.ts
|
|
51900
|
-
var modeSlot = singleton("InteractivityMode");
|
|
51901
|
-
// ../../node_modules/jsonpath-plus/dist/index-node-esm.js
|
|
51902
|
-
import vm from "vm";
|
|
51903
|
-
|
|
51904
|
-
class Hooks {
|
|
51905
|
-
add(name, callback, first) {
|
|
51906
|
-
if (typeof arguments[0] != "string") {
|
|
51907
|
-
for (let name2 in arguments[0]) {
|
|
51908
|
-
this.add(name2, arguments[0][name2], arguments[1]);
|
|
51909
|
-
}
|
|
51910
|
-
} else {
|
|
51911
|
-
(Array.isArray(name) ? name : [name]).forEach(function(name2) {
|
|
51912
|
-
this[name2] = this[name2] || [];
|
|
51913
|
-
if (callback) {
|
|
51914
|
-
this[name2][first ? "unshift" : "push"](callback);
|
|
51915
|
-
}
|
|
51916
|
-
}, this);
|
|
51917
|
-
}
|
|
51918
|
-
}
|
|
51919
|
-
run(name, env) {
|
|
51920
|
-
this[name] = this[name] || [];
|
|
51921
|
-
this[name].forEach(function(callback) {
|
|
51922
|
-
callback.call(env && env.context ? env.context : env, env);
|
|
51923
|
-
});
|
|
51924
|
-
}
|
|
51925
|
-
}
|
|
51926
|
-
|
|
51927
|
-
class Plugins {
|
|
51928
|
-
constructor(jsep) {
|
|
51929
|
-
this.jsep = jsep;
|
|
51930
|
-
this.registered = {};
|
|
51931
|
-
}
|
|
51932
|
-
register(...plugins) {
|
|
51933
|
-
plugins.forEach((plugin) => {
|
|
51934
|
-
if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
|
|
51935
|
-
throw new Error("Invalid JSEP plugin format");
|
|
51936
|
-
}
|
|
51937
|
-
if (this.registered[plugin.name]) {
|
|
51938
|
-
return;
|
|
51939
|
-
}
|
|
51940
|
-
plugin.init(this.jsep);
|
|
51941
|
-
this.registered[plugin.name] = plugin;
|
|
51942
|
-
});
|
|
51943
|
-
}
|
|
51944
|
-
}
|
|
51945
|
-
|
|
51946
|
-
class Jsep {
|
|
51947
|
-
static get version() {
|
|
51948
|
-
return "1.4.0";
|
|
51949
|
-
}
|
|
51950
|
-
static toString() {
|
|
51951
|
-
return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
|
|
51952
|
-
}
|
|
51953
|
-
static addUnaryOp(op_name) {
|
|
51954
|
-
Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
|
|
51955
|
-
Jsep.unary_ops[op_name] = 1;
|
|
51956
|
-
return Jsep;
|
|
51957
|
-
}
|
|
51958
|
-
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
51959
|
-
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
51960
|
-
Jsep.binary_ops[op_name] = precedence;
|
|
51961
|
-
if (isRightAssociative) {
|
|
51962
|
-
Jsep.right_associative.add(op_name);
|
|
51963
|
-
} else {
|
|
51964
|
-
Jsep.right_associative.delete(op_name);
|
|
51965
|
-
}
|
|
51966
|
-
return Jsep;
|
|
51967
|
-
}
|
|
51968
|
-
static addIdentifierChar(char) {
|
|
51969
|
-
Jsep.additional_identifier_chars.add(char);
|
|
51970
|
-
return Jsep;
|
|
51971
|
-
}
|
|
51972
|
-
static addLiteral(literal_name, literal_value) {
|
|
51973
|
-
Jsep.literals[literal_name] = literal_value;
|
|
51974
|
-
return Jsep;
|
|
51975
|
-
}
|
|
51976
|
-
static removeUnaryOp(op_name) {
|
|
51977
|
-
delete Jsep.unary_ops[op_name];
|
|
51978
|
-
if (op_name.length === Jsep.max_unop_len) {
|
|
51979
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
51980
|
-
}
|
|
51981
|
-
return Jsep;
|
|
51982
|
-
}
|
|
51983
|
-
static removeAllUnaryOps() {
|
|
51984
|
-
Jsep.unary_ops = {};
|
|
51985
|
-
Jsep.max_unop_len = 0;
|
|
51986
|
-
return Jsep;
|
|
51987
|
-
}
|
|
51988
|
-
static removeIdentifierChar(char) {
|
|
51989
|
-
Jsep.additional_identifier_chars.delete(char);
|
|
51990
|
-
return Jsep;
|
|
51991
|
-
}
|
|
51992
|
-
static removeBinaryOp(op_name) {
|
|
51993
|
-
delete Jsep.binary_ops[op_name];
|
|
51994
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
51995
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
51996
|
-
}
|
|
51997
|
-
Jsep.right_associative.delete(op_name);
|
|
51998
|
-
return Jsep;
|
|
51999
|
-
}
|
|
52000
|
-
static removeAllBinaryOps() {
|
|
52001
|
-
Jsep.binary_ops = {};
|
|
52002
|
-
Jsep.max_binop_len = 0;
|
|
52003
|
-
return Jsep;
|
|
52004
|
-
}
|
|
52005
|
-
static removeLiteral(literal_name) {
|
|
52006
|
-
delete Jsep.literals[literal_name];
|
|
52007
|
-
return Jsep;
|
|
52008
|
-
}
|
|
52009
|
-
static removeAllLiterals() {
|
|
52010
|
-
Jsep.literals = {};
|
|
52011
|
-
return Jsep;
|
|
52012
|
-
}
|
|
52013
|
-
get char() {
|
|
52014
|
-
return this.expr.charAt(this.index);
|
|
52015
|
-
}
|
|
52016
|
-
get code() {
|
|
52017
|
-
return this.expr.charCodeAt(this.index);
|
|
52018
|
-
}
|
|
52019
|
-
constructor(expr) {
|
|
52020
|
-
this.expr = expr;
|
|
52021
|
-
this.index = 0;
|
|
52022
|
-
}
|
|
52023
|
-
static parse(expr) {
|
|
52024
|
-
return new Jsep(expr).parse();
|
|
52025
|
-
}
|
|
52026
|
-
static getMaxKeyLen(obj) {
|
|
52027
|
-
return Math.max(0, ...Object.keys(obj).map((k) => k.length));
|
|
52028
|
-
}
|
|
52029
|
-
static isDecimalDigit(ch) {
|
|
52030
|
-
return ch >= 48 && ch <= 57;
|
|
52031
|
-
}
|
|
52032
|
-
static binaryPrecedence(op_val) {
|
|
52033
|
-
return Jsep.binary_ops[op_val] || 0;
|
|
52034
|
-
}
|
|
52035
|
-
static isIdentifierStart(ch) {
|
|
52036
|
-
return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
|
|
52037
|
-
}
|
|
52038
|
-
static isIdentifierPart(ch) {
|
|
52039
|
-
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
52040
|
-
}
|
|
52041
|
-
throwError(message) {
|
|
52042
|
-
const error = new Error(message + " at character " + this.index);
|
|
52043
|
-
error.index = this.index;
|
|
52044
|
-
error.description = message;
|
|
52045
|
-
throw error;
|
|
52046
|
-
}
|
|
52047
|
-
runHook(name, node) {
|
|
52048
|
-
if (Jsep.hooks[name]) {
|
|
52049
|
-
const env = {
|
|
52050
|
-
context: this,
|
|
52051
|
-
node
|
|
52052
|
-
};
|
|
52053
|
-
Jsep.hooks.run(name, env);
|
|
52054
|
-
return env.node;
|
|
52055
|
-
}
|
|
52056
|
-
return node;
|
|
52057
|
-
}
|
|
52058
|
-
searchHook(name) {
|
|
52059
|
-
if (Jsep.hooks[name]) {
|
|
52060
|
-
const env = {
|
|
52061
|
-
context: this
|
|
52062
|
-
};
|
|
52063
|
-
Jsep.hooks[name].find(function(callback) {
|
|
52064
|
-
callback.call(env.context, env);
|
|
52065
|
-
return env.node;
|
|
52066
|
-
});
|
|
52067
|
-
return env.node;
|
|
52068
|
-
}
|
|
52069
|
-
}
|
|
52070
|
-
gobbleSpaces() {
|
|
52071
|
-
let ch = this.code;
|
|
52072
|
-
while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
|
|
52073
|
-
ch = this.expr.charCodeAt(++this.index);
|
|
52074
|
-
}
|
|
52075
|
-
this.runHook("gobble-spaces");
|
|
52076
|
-
}
|
|
52077
|
-
parse() {
|
|
52078
|
-
this.runHook("before-all");
|
|
52079
|
-
const nodes = this.gobbleExpressions();
|
|
52080
|
-
const node = nodes.length === 1 ? nodes[0] : {
|
|
52081
|
-
type: Jsep.COMPOUND,
|
|
52082
|
-
body: nodes
|
|
52083
|
-
};
|
|
52084
|
-
return this.runHook("after-all", node);
|
|
52085
|
-
}
|
|
52086
|
-
gobbleExpressions(untilICode) {
|
|
52087
|
-
let nodes = [], ch_i, node;
|
|
52088
|
-
while (this.index < this.expr.length) {
|
|
52089
|
-
ch_i = this.code;
|
|
52090
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
52091
|
-
this.index++;
|
|
52092
|
-
} else {
|
|
52093
|
-
if (node = this.gobbleExpression()) {
|
|
52094
|
-
nodes.push(node);
|
|
52095
|
-
} else if (this.index < this.expr.length) {
|
|
52096
|
-
if (ch_i === untilICode) {
|
|
52097
|
-
break;
|
|
52098
|
-
}
|
|
52099
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
52100
|
-
}
|
|
52101
|
-
}
|
|
52102
|
-
}
|
|
52103
|
-
return nodes;
|
|
52104
|
-
}
|
|
52105
|
-
gobbleExpression() {
|
|
52106
|
-
const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
52107
|
-
this.gobbleSpaces();
|
|
52108
|
-
return this.runHook("after-expression", node);
|
|
52109
|
-
}
|
|
52110
|
-
gobbleBinaryOp() {
|
|
52111
|
-
this.gobbleSpaces();
|
|
52112
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
52113
|
-
let tc_len = to_check.length;
|
|
52114
|
-
while (tc_len > 0) {
|
|
52115
|
-
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)))) {
|
|
52116
|
-
this.index += tc_len;
|
|
52117
|
-
return to_check;
|
|
52118
|
-
}
|
|
52119
|
-
to_check = to_check.substr(0, --tc_len);
|
|
52120
|
-
}
|
|
52121
|
-
return false;
|
|
52122
|
-
}
|
|
52123
|
-
gobbleBinaryExpression() {
|
|
52124
|
-
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
52125
|
-
left = this.gobbleToken();
|
|
52126
|
-
if (!left) {
|
|
52127
|
-
return left;
|
|
52128
|
-
}
|
|
52129
|
-
biop = this.gobbleBinaryOp();
|
|
52130
|
-
if (!biop) {
|
|
52131
|
-
return left;
|
|
52132
|
-
}
|
|
52133
|
-
biop_info = {
|
|
52134
|
-
value: biop,
|
|
52135
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
52136
|
-
right_a: Jsep.right_associative.has(biop)
|
|
52137
|
-
};
|
|
52138
|
-
right = this.gobbleToken();
|
|
52139
|
-
if (!right) {
|
|
52140
|
-
this.throwError("Expected expression after " + biop);
|
|
52141
|
-
}
|
|
52142
|
-
stack = [left, biop_info, right];
|
|
52143
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
52144
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
52145
|
-
if (prec === 0) {
|
|
52146
|
-
this.index -= biop.length;
|
|
52147
|
-
break;
|
|
52148
|
-
}
|
|
52149
|
-
biop_info = {
|
|
52150
|
-
value: biop,
|
|
52151
|
-
prec,
|
|
52152
|
-
right_a: Jsep.right_associative.has(biop)
|
|
52153
|
-
};
|
|
52154
|
-
cur_biop = biop;
|
|
52155
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
52156
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
52157
|
-
right = stack.pop();
|
|
52158
|
-
biop = stack.pop().value;
|
|
52159
|
-
left = stack.pop();
|
|
52160
|
-
node = {
|
|
52161
|
-
type: Jsep.BINARY_EXP,
|
|
52162
|
-
operator: biop,
|
|
52163
|
-
left,
|
|
52164
|
-
right
|
|
52165
|
-
};
|
|
52166
|
-
stack.push(node);
|
|
52167
|
-
}
|
|
52168
|
-
node = this.gobbleToken();
|
|
52169
|
-
if (!node) {
|
|
52170
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
52171
|
-
}
|
|
52172
|
-
stack.push(biop_info, node);
|
|
52173
|
-
}
|
|
52174
|
-
i = stack.length - 1;
|
|
52175
|
-
node = stack[i];
|
|
52176
|
-
while (i > 1) {
|
|
52177
|
-
node = {
|
|
52178
|
-
type: Jsep.BINARY_EXP,
|
|
52179
|
-
operator: stack[i - 1].value,
|
|
52180
|
-
left: stack[i - 2],
|
|
52181
|
-
right: node
|
|
52182
|
-
};
|
|
52183
|
-
i -= 2;
|
|
52184
|
-
}
|
|
52185
|
-
return node;
|
|
52186
|
-
}
|
|
52187
|
-
gobbleToken() {
|
|
52188
|
-
let ch, to_check, tc_len, node;
|
|
52189
|
-
this.gobbleSpaces();
|
|
52190
|
-
node = this.searchHook("gobble-token");
|
|
52191
|
-
if (node) {
|
|
52192
|
-
return this.runHook("after-token", node);
|
|
52193
|
-
}
|
|
52194
|
-
ch = this.code;
|
|
52195
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
52196
|
-
return this.gobbleNumericLiteral();
|
|
52197
|
-
}
|
|
52198
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
52199
|
-
node = this.gobbleStringLiteral();
|
|
52200
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
52201
|
-
node = this.gobbleArray();
|
|
52202
|
-
} else {
|
|
52203
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
52204
|
-
tc_len = to_check.length;
|
|
52205
|
-
while (tc_len > 0) {
|
|
52206
|
-
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)))) {
|
|
52207
|
-
this.index += tc_len;
|
|
52208
|
-
const argument = this.gobbleToken();
|
|
52209
|
-
if (!argument) {
|
|
52210
|
-
this.throwError("missing unaryOp argument");
|
|
52211
|
-
}
|
|
52212
|
-
return this.runHook("after-token", {
|
|
52213
|
-
type: Jsep.UNARY_EXP,
|
|
52214
|
-
operator: to_check,
|
|
52215
|
-
argument,
|
|
52216
|
-
prefix: true
|
|
52217
|
-
});
|
|
52218
|
-
}
|
|
52219
|
-
to_check = to_check.substr(0, --tc_len);
|
|
52220
|
-
}
|
|
52221
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
52222
|
-
node = this.gobbleIdentifier();
|
|
52223
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
52224
|
-
node = {
|
|
52225
|
-
type: Jsep.LITERAL,
|
|
52226
|
-
value: Jsep.literals[node.name],
|
|
52227
|
-
raw: node.name
|
|
52228
|
-
};
|
|
52229
|
-
} else if (node.name === Jsep.this_str) {
|
|
52230
|
-
node = {
|
|
52231
|
-
type: Jsep.THIS_EXP
|
|
52232
|
-
};
|
|
52233
|
-
}
|
|
52234
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
52235
|
-
node = this.gobbleGroup();
|
|
52236
|
-
}
|
|
52237
|
-
}
|
|
52238
|
-
if (!node) {
|
|
52239
|
-
return this.runHook("after-token", false);
|
|
52240
|
-
}
|
|
52241
|
-
node = this.gobbleTokenProperty(node);
|
|
52242
|
-
return this.runHook("after-token", node);
|
|
52243
|
-
}
|
|
52244
|
-
gobbleTokenProperty(node) {
|
|
52245
|
-
this.gobbleSpaces();
|
|
52246
|
-
let ch = this.code;
|
|
52247
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
52248
|
-
let optional;
|
|
52249
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
52250
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
52251
|
-
break;
|
|
52252
|
-
}
|
|
52253
|
-
optional = true;
|
|
52254
|
-
this.index += 2;
|
|
52255
|
-
this.gobbleSpaces();
|
|
52256
|
-
ch = this.code;
|
|
52257
|
-
}
|
|
52258
|
-
this.index++;
|
|
52259
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
52260
|
-
node = {
|
|
52261
|
-
type: Jsep.MEMBER_EXP,
|
|
52262
|
-
computed: true,
|
|
52263
|
-
object: node,
|
|
52264
|
-
property: this.gobbleExpression()
|
|
52265
|
-
};
|
|
52266
|
-
if (!node.property) {
|
|
52267
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
52268
|
-
}
|
|
52269
|
-
this.gobbleSpaces();
|
|
52270
|
-
ch = this.code;
|
|
52271
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
52272
|
-
this.throwError("Unclosed [");
|
|
52273
|
-
}
|
|
52274
|
-
this.index++;
|
|
52275
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
52276
|
-
node = {
|
|
52277
|
-
type: Jsep.CALL_EXP,
|
|
52278
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
52279
|
-
callee: node
|
|
52280
|
-
};
|
|
52281
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
52282
|
-
if (optional) {
|
|
52283
|
-
this.index--;
|
|
52284
|
-
}
|
|
52285
|
-
this.gobbleSpaces();
|
|
52286
|
-
node = {
|
|
52287
|
-
type: Jsep.MEMBER_EXP,
|
|
52288
|
-
computed: false,
|
|
52289
|
-
object: node,
|
|
52290
|
-
property: this.gobbleIdentifier()
|
|
52291
|
-
};
|
|
52292
|
-
}
|
|
52293
|
-
if (optional) {
|
|
52294
|
-
node.optional = true;
|
|
52295
|
-
}
|
|
52296
|
-
this.gobbleSpaces();
|
|
52297
|
-
ch = this.code;
|
|
52298
|
-
}
|
|
52299
|
-
return node;
|
|
52300
|
-
}
|
|
52301
|
-
gobbleNumericLiteral() {
|
|
52302
|
-
let number = "", ch, chCode;
|
|
52303
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
52304
|
-
number += this.expr.charAt(this.index++);
|
|
52305
|
-
}
|
|
52306
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
52307
|
-
number += this.expr.charAt(this.index++);
|
|
52308
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
52309
|
-
number += this.expr.charAt(this.index++);
|
|
52310
|
-
}
|
|
52311
|
-
}
|
|
52312
|
-
ch = this.char;
|
|
52313
|
-
if (ch === "e" || ch === "E") {
|
|
52314
|
-
number += this.expr.charAt(this.index++);
|
|
52315
|
-
ch = this.char;
|
|
52316
|
-
if (ch === "+" || ch === "-") {
|
|
52317
|
-
number += this.expr.charAt(this.index++);
|
|
52318
|
-
}
|
|
52319
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
52320
|
-
number += this.expr.charAt(this.index++);
|
|
52321
|
-
}
|
|
52322
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
52323
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
52324
|
-
}
|
|
52325
|
-
}
|
|
52326
|
-
chCode = this.code;
|
|
52327
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
52328
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
52329
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
52330
|
-
this.throwError("Unexpected period");
|
|
52331
|
-
}
|
|
52332
|
-
return {
|
|
52333
|
-
type: Jsep.LITERAL,
|
|
52334
|
-
value: parseFloat(number),
|
|
52335
|
-
raw: number
|
|
52336
|
-
};
|
|
52337
|
-
}
|
|
52338
|
-
gobbleStringLiteral() {
|
|
52339
|
-
let str = "";
|
|
52340
|
-
const startIndex = this.index;
|
|
52341
|
-
const quote = this.expr.charAt(this.index++);
|
|
52342
|
-
let closed = false;
|
|
52343
|
-
while (this.index < this.expr.length) {
|
|
52344
|
-
let ch = this.expr.charAt(this.index++);
|
|
52345
|
-
if (ch === quote) {
|
|
52346
|
-
closed = true;
|
|
52347
|
-
break;
|
|
52348
|
-
} else if (ch === "\\") {
|
|
52349
|
-
ch = this.expr.charAt(this.index++);
|
|
52350
|
-
switch (ch) {
|
|
52351
|
-
case "n":
|
|
52352
|
-
str += `
|
|
52353
|
-
`;
|
|
52354
|
-
break;
|
|
52355
|
-
case "r":
|
|
52356
|
-
str += "\r";
|
|
52357
|
-
break;
|
|
52358
|
-
case "t":
|
|
52359
|
-
str += "\t";
|
|
52360
|
-
break;
|
|
52361
|
-
case "b":
|
|
52362
|
-
str += "\b";
|
|
52363
|
-
break;
|
|
52364
|
-
case "f":
|
|
52365
|
-
str += "\f";
|
|
52366
|
-
break;
|
|
52367
|
-
case "v":
|
|
52368
|
-
str += "\v";
|
|
52369
|
-
break;
|
|
52370
|
-
default:
|
|
52371
|
-
str += ch;
|
|
52372
|
-
}
|
|
52373
|
-
} else {
|
|
52374
|
-
str += ch;
|
|
52375
|
-
}
|
|
52376
|
-
}
|
|
52377
|
-
if (!closed) {
|
|
52378
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
52379
|
-
}
|
|
52380
|
-
return {
|
|
52381
|
-
type: Jsep.LITERAL,
|
|
52382
|
-
value: str,
|
|
52383
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
52384
|
-
};
|
|
52385
|
-
}
|
|
52386
|
-
gobbleIdentifier() {
|
|
52387
|
-
let ch = this.code, start = this.index;
|
|
52388
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
52389
|
-
this.index++;
|
|
52390
|
-
} else {
|
|
52391
|
-
this.throwError("Unexpected " + this.char);
|
|
52392
|
-
}
|
|
52393
|
-
while (this.index < this.expr.length) {
|
|
52394
|
-
ch = this.code;
|
|
52395
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
52396
|
-
this.index++;
|
|
52397
|
-
} else {
|
|
52398
|
-
break;
|
|
52399
|
-
}
|
|
52400
|
-
}
|
|
52401
|
-
return {
|
|
52402
|
-
type: Jsep.IDENTIFIER,
|
|
52403
|
-
name: this.expr.slice(start, this.index)
|
|
52404
|
-
};
|
|
52405
|
-
}
|
|
52406
|
-
gobbleArguments(termination) {
|
|
52407
|
-
const args = [];
|
|
52408
|
-
let closed = false;
|
|
52409
|
-
let separator_count = 0;
|
|
52410
|
-
while (this.index < this.expr.length) {
|
|
52411
|
-
this.gobbleSpaces();
|
|
52412
|
-
let ch_i = this.code;
|
|
52413
|
-
if (ch_i === termination) {
|
|
52414
|
-
closed = true;
|
|
52415
|
-
this.index++;
|
|
52416
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
52417
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
52418
|
-
}
|
|
52419
|
-
break;
|
|
52420
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
52421
|
-
this.index++;
|
|
52422
|
-
separator_count++;
|
|
52423
|
-
if (separator_count !== args.length) {
|
|
52424
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
52425
|
-
this.throwError("Unexpected token ,");
|
|
52426
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
52427
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
52428
|
-
args.push(null);
|
|
52429
|
-
}
|
|
52430
|
-
}
|
|
52431
|
-
}
|
|
52432
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
52433
|
-
this.throwError("Expected comma");
|
|
52434
|
-
} else {
|
|
52435
|
-
const node = this.gobbleExpression();
|
|
52436
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
52437
|
-
this.throwError("Expected comma");
|
|
52438
|
-
}
|
|
52439
|
-
args.push(node);
|
|
52440
|
-
}
|
|
52441
|
-
}
|
|
52442
|
-
if (!closed) {
|
|
52443
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
52444
|
-
}
|
|
52445
|
-
return args;
|
|
52446
|
-
}
|
|
52447
|
-
gobbleGroup() {
|
|
52448
|
-
this.index++;
|
|
52449
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
52450
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
52451
|
-
this.index++;
|
|
52452
|
-
if (nodes.length === 1) {
|
|
52453
|
-
return nodes[0];
|
|
52454
|
-
} else if (!nodes.length) {
|
|
52455
|
-
return false;
|
|
52456
|
-
} else {
|
|
52457
|
-
return {
|
|
52458
|
-
type: Jsep.SEQUENCE_EXP,
|
|
52459
|
-
expressions: nodes
|
|
52460
|
-
};
|
|
52461
|
-
}
|
|
52462
|
-
} else {
|
|
52463
|
-
this.throwError("Unclosed (");
|
|
52464
|
-
}
|
|
52465
|
-
}
|
|
52466
|
-
gobbleArray() {
|
|
52467
|
-
this.index++;
|
|
52468
|
-
return {
|
|
52469
|
-
type: Jsep.ARRAY_EXP,
|
|
52470
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
52471
|
-
};
|
|
52472
|
-
}
|
|
52473
|
-
}
|
|
52474
|
-
var hooks = new Hooks;
|
|
52475
|
-
Object.assign(Jsep, {
|
|
52476
|
-
hooks,
|
|
52477
|
-
plugins: new Plugins(Jsep),
|
|
52478
|
-
COMPOUND: "Compound",
|
|
52479
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
52480
|
-
IDENTIFIER: "Identifier",
|
|
52481
|
-
MEMBER_EXP: "MemberExpression",
|
|
52482
|
-
LITERAL: "Literal",
|
|
52483
|
-
THIS_EXP: "ThisExpression",
|
|
52484
|
-
CALL_EXP: "CallExpression",
|
|
52485
|
-
UNARY_EXP: "UnaryExpression",
|
|
52486
|
-
BINARY_EXP: "BinaryExpression",
|
|
52487
|
-
ARRAY_EXP: "ArrayExpression",
|
|
52488
|
-
TAB_CODE: 9,
|
|
52489
|
-
LF_CODE: 10,
|
|
52490
|
-
CR_CODE: 13,
|
|
52491
|
-
SPACE_CODE: 32,
|
|
52492
|
-
PERIOD_CODE: 46,
|
|
52493
|
-
COMMA_CODE: 44,
|
|
52494
|
-
SQUOTE_CODE: 39,
|
|
52495
|
-
DQUOTE_CODE: 34,
|
|
52496
|
-
OPAREN_CODE: 40,
|
|
52497
|
-
CPAREN_CODE: 41,
|
|
52498
|
-
OBRACK_CODE: 91,
|
|
52499
|
-
CBRACK_CODE: 93,
|
|
52500
|
-
QUMARK_CODE: 63,
|
|
52501
|
-
SEMCOL_CODE: 59,
|
|
52502
|
-
COLON_CODE: 58,
|
|
52503
|
-
unary_ops: {
|
|
52504
|
-
"-": 1,
|
|
52505
|
-
"!": 1,
|
|
52506
|
-
"~": 1,
|
|
52507
|
-
"+": 1
|
|
52508
|
-
},
|
|
52509
|
-
binary_ops: {
|
|
52510
|
-
"||": 1,
|
|
52511
|
-
"??": 1,
|
|
52512
|
-
"&&": 2,
|
|
52513
|
-
"|": 3,
|
|
52514
|
-
"^": 4,
|
|
52515
|
-
"&": 5,
|
|
52516
|
-
"==": 6,
|
|
52517
|
-
"!=": 6,
|
|
52518
|
-
"===": 6,
|
|
52519
|
-
"!==": 6,
|
|
52520
|
-
"<": 7,
|
|
52521
|
-
">": 7,
|
|
52522
|
-
"<=": 7,
|
|
52523
|
-
">=": 7,
|
|
52524
|
-
"<<": 8,
|
|
52525
|
-
">>": 8,
|
|
52526
|
-
">>>": 8,
|
|
52527
|
-
"+": 9,
|
|
52528
|
-
"-": 9,
|
|
52529
|
-
"*": 10,
|
|
52530
|
-
"/": 10,
|
|
52531
|
-
"%": 10,
|
|
52532
|
-
"**": 11
|
|
52533
|
-
},
|
|
52534
|
-
right_associative: new Set(["**"]),
|
|
52535
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
52536
|
-
literals: {
|
|
52537
|
-
true: true,
|
|
52538
|
-
false: false,
|
|
52539
|
-
null: null
|
|
52540
|
-
},
|
|
52541
|
-
this_str: "this"
|
|
52542
|
-
});
|
|
52543
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
52544
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
52545
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
52546
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
52547
|
-
});
|
|
52548
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
52549
|
-
jsep[m] = Jsep[m];
|
|
52550
|
-
});
|
|
52551
|
-
jsep.Jsep = Jsep;
|
|
52552
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
52553
|
-
var ternary = {
|
|
52554
|
-
name: "ternary",
|
|
52555
|
-
init(jsep2) {
|
|
52556
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
52557
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
52558
|
-
this.index++;
|
|
52559
|
-
const test = env.node;
|
|
52560
|
-
const consequent = this.gobbleExpression();
|
|
52561
|
-
if (!consequent) {
|
|
52562
|
-
this.throwError("Expected expression");
|
|
52563
|
-
}
|
|
52564
|
-
this.gobbleSpaces();
|
|
52565
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
52566
|
-
this.index++;
|
|
52567
|
-
const alternate = this.gobbleExpression();
|
|
52568
|
-
if (!alternate) {
|
|
52569
|
-
this.throwError("Expected expression");
|
|
52570
|
-
}
|
|
52571
|
-
env.node = {
|
|
52572
|
-
type: CONDITIONAL_EXP,
|
|
52573
|
-
test,
|
|
52574
|
-
consequent,
|
|
52575
|
-
alternate
|
|
52576
|
-
};
|
|
52577
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
52578
|
-
let newTest = test;
|
|
52579
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
52580
|
-
newTest = newTest.right;
|
|
52581
|
-
}
|
|
52582
|
-
env.node.test = newTest.right;
|
|
52583
|
-
newTest.right = env.node;
|
|
52584
|
-
env.node = test;
|
|
52585
|
-
}
|
|
52586
|
-
} else {
|
|
52587
|
-
this.throwError("Expected :");
|
|
52588
|
-
}
|
|
52589
|
-
}
|
|
52590
|
-
});
|
|
52591
|
-
}
|
|
52592
|
-
};
|
|
52593
|
-
jsep.plugins.register(ternary);
|
|
52594
|
-
var FSLASH_CODE = 47;
|
|
52595
|
-
var BSLASH_CODE = 92;
|
|
52596
|
-
var index = {
|
|
52597
|
-
name: "regex",
|
|
52598
|
-
init(jsep2) {
|
|
52599
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
52600
|
-
if (this.code === FSLASH_CODE) {
|
|
52601
|
-
const patternIndex = ++this.index;
|
|
52602
|
-
let inCharSet = false;
|
|
52603
|
-
while (this.index < this.expr.length) {
|
|
52604
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
52605
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
52606
|
-
let flags = "";
|
|
52607
|
-
while (++this.index < this.expr.length) {
|
|
52608
|
-
const code = this.code;
|
|
52609
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
52610
|
-
flags += this.char;
|
|
52611
|
-
} else {
|
|
52612
|
-
break;
|
|
52613
|
-
}
|
|
52614
|
-
}
|
|
52615
|
-
let value;
|
|
52616
|
-
try {
|
|
52617
|
-
value = new RegExp(pattern, flags);
|
|
52618
|
-
} catch (e) {
|
|
52619
|
-
this.throwError(e.message);
|
|
52620
|
-
}
|
|
52621
|
-
env.node = {
|
|
52622
|
-
type: jsep2.LITERAL,
|
|
52623
|
-
value,
|
|
52624
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
52625
|
-
};
|
|
52626
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
52627
|
-
return env.node;
|
|
52628
|
-
}
|
|
52629
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
52630
|
-
inCharSet = true;
|
|
52631
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
52632
|
-
inCharSet = false;
|
|
52633
|
-
}
|
|
52634
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
52635
|
-
}
|
|
52636
|
-
this.throwError("Unclosed Regex");
|
|
52637
|
-
}
|
|
52638
|
-
});
|
|
52639
|
-
}
|
|
52640
|
-
};
|
|
52641
|
-
var PLUS_CODE = 43;
|
|
52642
|
-
var MINUS_CODE = 45;
|
|
52643
|
-
var plugin = {
|
|
52644
|
-
name: "assignment",
|
|
52645
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
52646
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
52647
|
-
assignmentPrecedence: 0.9,
|
|
52648
|
-
init(jsep2) {
|
|
52649
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
52650
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
52651
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
52652
|
-
const code = this.code;
|
|
52653
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
52654
|
-
this.index += 2;
|
|
52655
|
-
env.node = {
|
|
52656
|
-
type: "UpdateExpression",
|
|
52657
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
52658
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
52659
|
-
prefix: true
|
|
52660
|
-
};
|
|
52661
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
52662
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
52663
|
-
}
|
|
52664
|
-
}
|
|
52665
|
-
});
|
|
52666
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
52667
|
-
if (env.node) {
|
|
52668
|
-
const code = this.code;
|
|
52669
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
52670
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
52671
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
52672
|
-
}
|
|
52673
|
-
this.index += 2;
|
|
52674
|
-
env.node = {
|
|
52675
|
-
type: "UpdateExpression",
|
|
52676
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
52677
|
-
argument: env.node,
|
|
52678
|
-
prefix: false
|
|
52679
|
-
};
|
|
52680
|
-
}
|
|
52681
|
-
}
|
|
52682
|
-
});
|
|
52683
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
52684
|
-
if (env.node) {
|
|
52685
|
-
updateBinariesToAssignments(env.node);
|
|
52686
|
-
}
|
|
52687
|
-
});
|
|
52688
|
-
function updateBinariesToAssignments(node) {
|
|
52689
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
52690
|
-
node.type = "AssignmentExpression";
|
|
52691
|
-
updateBinariesToAssignments(node.left);
|
|
52692
|
-
updateBinariesToAssignments(node.right);
|
|
52693
|
-
} else if (!node.operator) {
|
|
52694
|
-
Object.values(node).forEach((val) => {
|
|
52695
|
-
if (val && typeof val === "object") {
|
|
52696
|
-
updateBinariesToAssignments(val);
|
|
52697
|
-
}
|
|
52698
|
-
});
|
|
52699
|
-
}
|
|
52700
|
-
}
|
|
52701
|
-
}
|
|
52702
|
-
};
|
|
52703
|
-
jsep.plugins.register(index, plugin);
|
|
52704
|
-
jsep.addUnaryOp("typeof");
|
|
52705
|
-
jsep.addUnaryOp("void");
|
|
52706
|
-
jsep.addLiteral("null", null);
|
|
52707
|
-
jsep.addLiteral("undefined", undefined);
|
|
52708
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
52709
|
-
var SafeEval = {
|
|
52710
|
-
evalAst(ast, subs) {
|
|
52711
|
-
switch (ast.type) {
|
|
52712
|
-
case "BinaryExpression":
|
|
52713
|
-
case "LogicalExpression":
|
|
52714
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
52715
|
-
case "Compound":
|
|
52716
|
-
return SafeEval.evalCompound(ast, subs);
|
|
52717
|
-
case "ConditionalExpression":
|
|
52718
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
52719
|
-
case "Identifier":
|
|
52720
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
52721
|
-
case "Literal":
|
|
52722
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
52723
|
-
case "MemberExpression":
|
|
52724
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
52725
|
-
case "UnaryExpression":
|
|
52726
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
52727
|
-
case "ArrayExpression":
|
|
52728
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
52729
|
-
case "CallExpression":
|
|
52730
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
52731
|
-
case "AssignmentExpression":
|
|
52732
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
52733
|
-
default:
|
|
52734
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
52735
|
-
}
|
|
52736
|
-
},
|
|
52737
|
-
evalBinaryExpression(ast, subs) {
|
|
52738
|
-
const result = {
|
|
52739
|
-
"||": (a, b) => a || b(),
|
|
52740
|
-
"&&": (a, b) => a && b(),
|
|
52741
|
-
"|": (a, b) => a | b(),
|
|
52742
|
-
"^": (a, b) => a ^ b(),
|
|
52743
|
-
"&": (a, b) => a & b(),
|
|
52744
|
-
"==": (a, b) => a == b(),
|
|
52745
|
-
"!=": (a, b) => a != b(),
|
|
52746
|
-
"===": (a, b) => a === b(),
|
|
52747
|
-
"!==": (a, b) => a !== b(),
|
|
52748
|
-
"<": (a, b) => a < b(),
|
|
52749
|
-
">": (a, b) => a > b(),
|
|
52750
|
-
"<=": (a, b) => a <= b(),
|
|
52751
|
-
">=": (a, b) => a >= b(),
|
|
52752
|
-
"<<": (a, b) => a << b(),
|
|
52753
|
-
">>": (a, b) => a >> b(),
|
|
52754
|
-
">>>": (a, b) => a >>> b(),
|
|
52755
|
-
"+": (a, b) => a + b(),
|
|
52756
|
-
"-": (a, b) => a - b(),
|
|
52757
|
-
"*": (a, b) => a * b(),
|
|
52758
|
-
"/": (a, b) => a / b(),
|
|
52759
|
-
"%": (a, b) => a % b()
|
|
52760
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
52761
|
-
return result;
|
|
52762
|
-
},
|
|
52763
|
-
evalCompound(ast, subs) {
|
|
52764
|
-
let last;
|
|
52765
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
52766
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
52767
|
-
i += 1;
|
|
52768
|
-
}
|
|
52769
|
-
const expr = ast.body[i];
|
|
52770
|
-
last = SafeEval.evalAst(expr, subs);
|
|
52771
|
-
}
|
|
52772
|
-
return last;
|
|
52773
|
-
},
|
|
52774
|
-
evalConditionalExpression(ast, subs) {
|
|
52775
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
52776
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
52777
|
-
}
|
|
52778
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
52779
|
-
},
|
|
52780
|
-
evalIdentifier(ast, subs) {
|
|
52781
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
52782
|
-
return subs[ast.name];
|
|
52783
|
-
}
|
|
52784
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
52785
|
-
},
|
|
52786
|
-
evalLiteral(ast) {
|
|
52787
|
-
return ast.value;
|
|
52788
|
-
},
|
|
52789
|
-
evalMemberExpression(ast, subs) {
|
|
52790
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
52791
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
52792
|
-
if (obj === undefined || obj === null) {
|
|
52793
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
52794
|
-
}
|
|
52795
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
52796
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
52797
|
-
}
|
|
52798
|
-
const result = obj[prop];
|
|
52799
|
-
if (typeof result === "function") {
|
|
52800
|
-
return result.bind(obj);
|
|
52801
|
-
}
|
|
52802
|
-
return result;
|
|
52803
|
-
},
|
|
52804
|
-
evalUnaryExpression(ast, subs) {
|
|
52805
|
-
const result = {
|
|
52806
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
52807
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
52808
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
52809
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
52810
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
52811
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
52812
|
-
}[ast.operator](ast.argument);
|
|
52813
|
-
return result;
|
|
52814
|
-
},
|
|
52815
|
-
evalArrayExpression(ast, subs) {
|
|
52816
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
52817
|
-
},
|
|
52818
|
-
evalCallExpression(ast, subs) {
|
|
52819
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
52820
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
52821
|
-
if (func === Function) {
|
|
52822
|
-
throw new Error("Function constructor is disabled");
|
|
52823
|
-
}
|
|
52824
|
-
return func(...args);
|
|
52825
|
-
},
|
|
52826
|
-
evalAssignmentExpression(ast, subs) {
|
|
52827
|
-
if (ast.left.type !== "Identifier") {
|
|
52828
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
52829
|
-
}
|
|
52830
|
-
const id = ast.left.name;
|
|
52831
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
52832
|
-
subs[id] = value;
|
|
52833
|
-
return subs[id];
|
|
52834
|
-
}
|
|
52835
|
-
};
|
|
52836
|
-
|
|
52837
|
-
class SafeScript {
|
|
52838
|
-
constructor(expr) {
|
|
52839
|
-
this.code = expr;
|
|
52840
|
-
this.ast = jsep(this.code);
|
|
52841
|
-
}
|
|
52842
|
-
runInNewContext(context) {
|
|
52843
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
52844
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
52077
|
+
"shared",
|
|
52078
|
+
"root",
|
|
52079
|
+
"ssh",
|
|
52080
|
+
"rsa",
|
|
52081
|
+
"aes",
|
|
52082
|
+
"hmac",
|
|
52083
|
+
"oauth"
|
|
52084
|
+
]);
|
|
52085
|
+
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
52086
|
+
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
52087
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
52088
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
52089
|
+
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
52090
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
52091
|
+
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
52092
|
+
function shortHash(input) {
|
|
52093
|
+
let hash = 2166136261;
|
|
52094
|
+
for (let i = 0;i < input.length; i++) {
|
|
52095
|
+
hash ^= input.charCodeAt(i);
|
|
52096
|
+
hash = Math.imul(hash, 16777619);
|
|
52845
52097
|
}
|
|
52098
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
52846
52099
|
}
|
|
52847
|
-
function
|
|
52848
|
-
|
|
52849
|
-
|
|
52850
|
-
|
|
52851
|
-
}
|
|
52852
|
-
|
|
52853
|
-
|
|
52854
|
-
arr.unshift(item);
|
|
52855
|
-
return arr;
|
|
52100
|
+
function redactUrl(raw) {
|
|
52101
|
+
try {
|
|
52102
|
+
const url = new URL(raw);
|
|
52103
|
+
return `${url.protocol}//${url.host}`;
|
|
52104
|
+
} catch {
|
|
52105
|
+
return `url#${shortHash(raw)}`;
|
|
52106
|
+
}
|
|
52856
52107
|
}
|
|
52857
|
-
|
|
52858
|
-
|
|
52859
|
-
|
|
52860
|
-
|
|
52861
|
-
|
|
52862
|
-
|
|
52863
|
-
|
|
52108
|
+
function redactValueDetectors(value) {
|
|
52109
|
+
let out = value;
|
|
52110
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
52111
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
52112
|
+
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
52113
|
+
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
52114
|
+
return `${redactUrl(core)}${trailing}`;
|
|
52115
|
+
});
|
|
52116
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
52117
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
52118
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
52119
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
52120
|
+
if (out.length > MAX_VALUE_LENGTH) {
|
|
52121
|
+
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
52864
52122
|
}
|
|
52123
|
+
return out;
|
|
52865
52124
|
}
|
|
52866
|
-
function
|
|
52867
|
-
|
|
52868
|
-
|
|
52869
|
-
|
|
52870
|
-
|
|
52871
|
-
|
|
52872
|
-
|
|
52873
|
-
|
|
52874
|
-
return
|
|
52875
|
-
}
|
|
52876
|
-
}
|
|
52877
|
-
if (typeof opts === "string") {
|
|
52878
|
-
otherTypeCallback = callback;
|
|
52879
|
-
callback = obj;
|
|
52880
|
-
obj = expr;
|
|
52881
|
-
expr = opts;
|
|
52882
|
-
opts = null;
|
|
52883
|
-
}
|
|
52884
|
-
const optObj = opts && typeof opts === "object";
|
|
52885
|
-
opts = opts || {};
|
|
52886
|
-
this.json = opts.json || obj;
|
|
52887
|
-
this.path = opts.path || expr;
|
|
52888
|
-
this.resultType = opts.resultType || "value";
|
|
52889
|
-
this.flatten = opts.flatten || false;
|
|
52890
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
52891
|
-
this.sandbox = opts.sandbox || {};
|
|
52892
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
52893
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
52894
|
-
this.parent = opts.parent || null;
|
|
52895
|
-
this.parentProperty = opts.parentProperty || null;
|
|
52896
|
-
this.callback = opts.callback || callback || null;
|
|
52897
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
52898
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
52899
|
-
};
|
|
52900
|
-
if (opts.autostart !== false) {
|
|
52901
|
-
const args = {
|
|
52902
|
-
path: optObj ? opts.path : expr
|
|
52903
|
-
};
|
|
52904
|
-
if (!optObj) {
|
|
52905
|
-
args.json = obj;
|
|
52906
|
-
} else if ("json" in opts) {
|
|
52907
|
-
args.json = opts.json;
|
|
52125
|
+
function nameTokens(name) {
|
|
52126
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
52127
|
+
}
|
|
52128
|
+
function isSensitiveName(name) {
|
|
52129
|
+
const tokens = nameTokens(name);
|
|
52130
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
52131
|
+
const token = tokens[i];
|
|
52132
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
52133
|
+
return true;
|
|
52908
52134
|
}
|
|
52909
|
-
|
|
52910
|
-
|
|
52911
|
-
|
|
52135
|
+
if (token === "key" || token === "keys") {
|
|
52136
|
+
const prev = tokens[i - 1];
|
|
52137
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
52138
|
+
return true;
|
|
52139
|
+
}
|
|
52912
52140
|
}
|
|
52913
|
-
return ret;
|
|
52914
52141
|
}
|
|
52142
|
+
return false;
|
|
52915
52143
|
}
|
|
52916
|
-
|
|
52917
|
-
|
|
52918
|
-
let {
|
|
52919
|
-
flatten,
|
|
52920
|
-
wrap
|
|
52921
|
-
} = this;
|
|
52922
|
-
this.currResultType = this.resultType;
|
|
52923
|
-
this.currEval = this.eval;
|
|
52924
|
-
this.currSandbox = this.sandbox;
|
|
52925
|
-
callback = callback || this.callback;
|
|
52926
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
52927
|
-
json = json || this.json;
|
|
52928
|
-
expr = expr || this.path;
|
|
52929
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
52930
|
-
if (!expr.path && expr.path !== "") {
|
|
52931
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
52932
|
-
}
|
|
52933
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
52934
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
52935
|
-
}
|
|
52936
|
-
({
|
|
52937
|
-
json
|
|
52938
|
-
} = expr);
|
|
52939
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
52940
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
52941
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
52942
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
52943
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
52944
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
52945
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
52946
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
52947
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
52948
|
-
expr = expr.path;
|
|
52949
|
-
}
|
|
52950
|
-
currParent = currParent || null;
|
|
52951
|
-
currParentProperty = currParentProperty || null;
|
|
52952
|
-
if (Array.isArray(expr)) {
|
|
52953
|
-
expr = JSONPath.toPathString(expr);
|
|
52954
|
-
}
|
|
52955
|
-
if (!expr && expr !== "" || !json) {
|
|
52144
|
+
function redactProperty(name, value) {
|
|
52145
|
+
if (value === undefined || value === null) {
|
|
52956
52146
|
return;
|
|
52957
52147
|
}
|
|
52958
|
-
|
|
52959
|
-
|
|
52960
|
-
exprList.shift();
|
|
52148
|
+
if (isSensitiveName(name)) {
|
|
52149
|
+
return REDACTED;
|
|
52961
52150
|
}
|
|
52962
|
-
|
|
52963
|
-
|
|
52964
|
-
return ea && !ea.isParentSelector;
|
|
52965
|
-
});
|
|
52966
|
-
if (!result.length) {
|
|
52967
|
-
return wrap ? [] : undefined;
|
|
52151
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
52152
|
+
return value;
|
|
52968
52153
|
}
|
|
52969
|
-
if (
|
|
52970
|
-
return
|
|
52154
|
+
if (typeof value !== "string") {
|
|
52155
|
+
return "[OBJECT]";
|
|
52971
52156
|
}
|
|
52972
|
-
return
|
|
52973
|
-
|
|
52974
|
-
|
|
52975
|
-
|
|
52976
|
-
|
|
52977
|
-
|
|
52157
|
+
return redactValueDetectors(value);
|
|
52158
|
+
}
|
|
52159
|
+
function redactProperties(properties) {
|
|
52160
|
+
const out = {};
|
|
52161
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
52162
|
+
const redacted = redactProperty(name, value);
|
|
52163
|
+
if (redacted !== undefined) {
|
|
52164
|
+
out[name] = redacted;
|
|
52978
52165
|
}
|
|
52979
|
-
return rslt;
|
|
52980
|
-
}, []);
|
|
52981
|
-
};
|
|
52982
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
52983
|
-
const resultType = this.currResultType;
|
|
52984
|
-
switch (resultType) {
|
|
52985
|
-
case "all": {
|
|
52986
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
52987
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
52988
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
52989
|
-
return ea;
|
|
52990
|
-
}
|
|
52991
|
-
case "value":
|
|
52992
|
-
case "parent":
|
|
52993
|
-
case "parentProperty":
|
|
52994
|
-
return ea[resultType];
|
|
52995
|
-
case "path":
|
|
52996
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
52997
|
-
case "pointer":
|
|
52998
|
-
return JSONPath.toPointer(ea.path);
|
|
52999
|
-
default:
|
|
53000
|
-
throw new TypeError("Unknown result type");
|
|
53001
52166
|
}
|
|
53002
|
-
|
|
53003
|
-
|
|
53004
|
-
|
|
53005
|
-
|
|
53006
|
-
|
|
53007
|
-
|
|
52167
|
+
return out;
|
|
52168
|
+
}
|
|
52169
|
+
|
|
52170
|
+
// ../common/src/trackedAction.ts
|
|
52171
|
+
var pollSignalSlot = singleton("PollSignal");
|
|
52172
|
+
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
52173
|
+
var retryHintValues = new Set(RETRY_HINTS);
|
|
52174
|
+
var processContext = {
|
|
52175
|
+
exit: (code) => {
|
|
52176
|
+
process.exitCode = code;
|
|
52177
|
+
},
|
|
52178
|
+
get pollSignal() {
|
|
52179
|
+
return pollSignalSlot.get();
|
|
53008
52180
|
}
|
|
53009
52181
|
};
|
|
53010
|
-
|
|
53011
|
-
|
|
53012
|
-
|
|
53013
|
-
|
|
53014
|
-
|
|
53015
|
-
|
|
53016
|
-
|
|
53017
|
-
|
|
53018
|
-
hasArrExpr
|
|
53019
|
-
};
|
|
53020
|
-
this._handleCallback(retObj, callback, "value");
|
|
53021
|
-
return retObj;
|
|
53022
|
-
}
|
|
53023
|
-
const loc = expr[0], x = expr.slice(1);
|
|
53024
|
-
const ret = [];
|
|
53025
|
-
function addRet(elems) {
|
|
53026
|
-
if (Array.isArray(elems)) {
|
|
53027
|
-
elems.forEach((t) => {
|
|
53028
|
-
ret.push(t);
|
|
53029
|
-
});
|
|
53030
|
-
} else {
|
|
53031
|
-
ret.push(elems);
|
|
53032
|
-
}
|
|
53033
|
-
}
|
|
53034
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
53035
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
53036
|
-
} else if (loc === "*") {
|
|
53037
|
-
this._walk(val, (m) => {
|
|
53038
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
53039
|
-
});
|
|
53040
|
-
} else if (loc === "..") {
|
|
53041
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
53042
|
-
this._walk(val, (m) => {
|
|
53043
|
-
if (typeof val[m] === "object") {
|
|
53044
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
53045
|
-
}
|
|
53046
|
-
});
|
|
53047
|
-
} else if (loc === "^") {
|
|
53048
|
-
this._hasParentSelector = true;
|
|
53049
|
-
return {
|
|
53050
|
-
path: path3.slice(0, -1),
|
|
53051
|
-
expr: x,
|
|
53052
|
-
isParentSelector: true
|
|
53053
|
-
};
|
|
53054
|
-
} else if (loc === "~") {
|
|
53055
|
-
retObj = {
|
|
53056
|
-
path: push(path3, loc),
|
|
53057
|
-
value: parentPropName,
|
|
53058
|
-
parent,
|
|
53059
|
-
parentProperty: null
|
|
53060
|
-
};
|
|
53061
|
-
this._handleCallback(retObj, callback, "property");
|
|
53062
|
-
return retObj;
|
|
53063
|
-
} else if (loc === "$") {
|
|
53064
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
53065
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
53066
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
53067
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
53068
|
-
if (this.currEval === false) {
|
|
53069
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
53070
|
-
}
|
|
53071
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
53072
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
53073
|
-
if (nested) {
|
|
53074
|
-
this._walk(val, (m) => {
|
|
53075
|
-
const npath = [nested[2]];
|
|
53076
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
53077
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
53078
|
-
if (filterResults.length > 0) {
|
|
53079
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
53080
|
-
}
|
|
53081
|
-
});
|
|
53082
|
-
} else {
|
|
53083
|
-
this._walk(val, (m) => {
|
|
53084
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
53085
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
53086
|
-
}
|
|
53087
|
-
});
|
|
53088
|
-
}
|
|
53089
|
-
} else if (loc[0] === "(") {
|
|
53090
|
-
if (this.currEval === false) {
|
|
53091
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
52182
|
+
function extractCommandParams(cmd) {
|
|
52183
|
+
const params = {};
|
|
52184
|
+
const registered = cmd.registeredArguments ?? [];
|
|
52185
|
+
const processed = cmd.processedArgs ?? [];
|
|
52186
|
+
for (let i = 0;i < registered.length; i++) {
|
|
52187
|
+
const value = processed[i];
|
|
52188
|
+
if (value === undefined) {
|
|
52189
|
+
continue;
|
|
53092
52190
|
}
|
|
53093
|
-
|
|
53094
|
-
|
|
53095
|
-
|
|
53096
|
-
const valueType = loc.slice(1, -2);
|
|
53097
|
-
switch (valueType) {
|
|
53098
|
-
case "scalar":
|
|
53099
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
53100
|
-
addType = true;
|
|
53101
|
-
}
|
|
53102
|
-
break;
|
|
53103
|
-
case "boolean":
|
|
53104
|
-
case "string":
|
|
53105
|
-
case "undefined":
|
|
53106
|
-
case "function":
|
|
53107
|
-
if (typeof val === valueType) {
|
|
53108
|
-
addType = true;
|
|
53109
|
-
}
|
|
53110
|
-
break;
|
|
53111
|
-
case "integer":
|
|
53112
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
53113
|
-
addType = true;
|
|
53114
|
-
}
|
|
53115
|
-
break;
|
|
53116
|
-
case "number":
|
|
53117
|
-
if (Number.isFinite(val)) {
|
|
53118
|
-
addType = true;
|
|
53119
|
-
}
|
|
53120
|
-
break;
|
|
53121
|
-
case "nonFinite":
|
|
53122
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
53123
|
-
addType = true;
|
|
53124
|
-
}
|
|
53125
|
-
break;
|
|
53126
|
-
case "object":
|
|
53127
|
-
if (val && typeof val === valueType) {
|
|
53128
|
-
addType = true;
|
|
53129
|
-
}
|
|
53130
|
-
break;
|
|
53131
|
-
case "array":
|
|
53132
|
-
if (Array.isArray(val)) {
|
|
53133
|
-
addType = true;
|
|
53134
|
-
}
|
|
53135
|
-
break;
|
|
53136
|
-
case "other":
|
|
53137
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
53138
|
-
break;
|
|
53139
|
-
case "null":
|
|
53140
|
-
if (val === null) {
|
|
53141
|
-
addType = true;
|
|
53142
|
-
}
|
|
53143
|
-
break;
|
|
53144
|
-
default:
|
|
53145
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
53146
|
-
}
|
|
53147
|
-
if (addType) {
|
|
53148
|
-
retObj = {
|
|
53149
|
-
path: path3,
|
|
53150
|
-
value: val,
|
|
53151
|
-
parent,
|
|
53152
|
-
parentProperty: parentPropName
|
|
53153
|
-
};
|
|
53154
|
-
this._handleCallback(retObj, callback, "value");
|
|
53155
|
-
return retObj;
|
|
53156
|
-
}
|
|
53157
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
53158
|
-
const locProp = loc.slice(1);
|
|
53159
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
53160
|
-
} else if (loc.includes(",")) {
|
|
53161
|
-
const parts = loc.split(",");
|
|
53162
|
-
for (const part of parts) {
|
|
53163
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
53164
|
-
}
|
|
53165
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
53166
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
53167
|
-
}
|
|
53168
|
-
if (this._hasParentSelector) {
|
|
53169
|
-
for (let t = 0;t < ret.length; t++) {
|
|
53170
|
-
const rett = ret[t];
|
|
53171
|
-
if (rett && rett.isParentSelector) {
|
|
53172
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
53173
|
-
if (Array.isArray(tmp)) {
|
|
53174
|
-
ret[t] = tmp[0];
|
|
53175
|
-
const tl = tmp.length;
|
|
53176
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
53177
|
-
t++;
|
|
53178
|
-
ret.splice(t, 0, tmp[tt]);
|
|
53179
|
-
}
|
|
53180
|
-
} else {
|
|
53181
|
-
ret[t] = tmp;
|
|
53182
|
-
}
|
|
53183
|
-
}
|
|
52191
|
+
const name = registered[i].name();
|
|
52192
|
+
if (name) {
|
|
52193
|
+
params[name] = value;
|
|
53184
52194
|
}
|
|
53185
52195
|
}
|
|
53186
|
-
|
|
53187
|
-
|
|
53188
|
-
|
|
53189
|
-
if (Array.isArray(val)) {
|
|
53190
|
-
const n = val.length;
|
|
53191
|
-
for (let i = 0;i < n; i++) {
|
|
53192
|
-
f(i);
|
|
53193
|
-
}
|
|
53194
|
-
} else if (val && typeof val === "object") {
|
|
53195
|
-
Object.keys(val).forEach((m) => {
|
|
53196
|
-
f(m);
|
|
53197
|
-
});
|
|
53198
|
-
}
|
|
53199
|
-
};
|
|
53200
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
53201
|
-
if (!Array.isArray(val)) {
|
|
53202
|
-
return;
|
|
53203
|
-
}
|
|
53204
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
53205
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
53206
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
53207
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
53208
|
-
const ret = [];
|
|
53209
|
-
for (let i = start;i < end; i += step) {
|
|
53210
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
53211
|
-
tmp.forEach((t) => {
|
|
53212
|
-
ret.push(t);
|
|
53213
|
-
});
|
|
53214
|
-
}
|
|
53215
|
-
return ret;
|
|
53216
|
-
};
|
|
53217
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
53218
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
53219
|
-
this.currSandbox._$_parent = parent;
|
|
53220
|
-
this.currSandbox._$_property = _vname;
|
|
53221
|
-
this.currSandbox._$_root = this.json;
|
|
53222
|
-
this.currSandbox._$_v = _v;
|
|
53223
|
-
const containsPath = code.includes("@path");
|
|
53224
|
-
if (containsPath) {
|
|
53225
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
53226
|
-
}
|
|
53227
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
53228
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
53229
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
53230
|
-
if (containsPath) {
|
|
53231
|
-
script = script.replaceAll("@path", "_$_path");
|
|
53232
|
-
}
|
|
53233
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
53234
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
53235
|
-
} else if (this.currEval === "native") {
|
|
53236
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
53237
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
53238
|
-
const CurrEval = this.currEval;
|
|
53239
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
53240
|
-
} else if (typeof this.currEval === "function") {
|
|
53241
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
53242
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
53243
|
-
};
|
|
53244
|
-
} else {
|
|
53245
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
52196
|
+
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
52197
|
+
if (value !== undefined) {
|
|
52198
|
+
params[key] = value;
|
|
53246
52199
|
}
|
|
53247
52200
|
}
|
|
53248
|
-
|
|
53249
|
-
|
|
53250
|
-
|
|
53251
|
-
|
|
53252
|
-
|
|
52201
|
+
return params;
|
|
52202
|
+
}
|
|
52203
|
+
function deriveCommandPath(cmd) {
|
|
52204
|
+
const parts = [];
|
|
52205
|
+
let current = cmd;
|
|
52206
|
+
while (current) {
|
|
52207
|
+
const name = current.name();
|
|
52208
|
+
if (name) {
|
|
52209
|
+
parts.unshift(name);
|
|
53253
52210
|
}
|
|
53254
|
-
|
|
52211
|
+
current = current.parent;
|
|
53255
52212
|
}
|
|
53256
|
-
|
|
53257
|
-
|
|
53258
|
-
JSONPath.toPathString = function(pathArr) {
|
|
53259
|
-
const x = pathArr, n = x.length;
|
|
53260
|
-
let p = "$";
|
|
53261
|
-
for (let i = 1;i < n; i++) {
|
|
53262
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
53263
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
53264
|
-
}
|
|
52213
|
+
if (parts.length > 1) {
|
|
52214
|
+
parts.shift();
|
|
53265
52215
|
}
|
|
53266
|
-
return p;
|
|
53267
|
-
}
|
|
53268
|
-
|
|
53269
|
-
|
|
53270
|
-
|
|
53271
|
-
|
|
53272
|
-
|
|
53273
|
-
|
|
52216
|
+
return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
|
|
52217
|
+
}
|
|
52218
|
+
function isCliErrorCode(value) {
|
|
52219
|
+
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
52220
|
+
}
|
|
52221
|
+
function isRetryHint(value) {
|
|
52222
|
+
return typeof value === "string" && retryHintValues.has(value);
|
|
52223
|
+
}
|
|
52224
|
+
function isErrorContext(value) {
|
|
52225
|
+
return value !== null && typeof value === "object";
|
|
52226
|
+
}
|
|
52227
|
+
function commandHelpHint(commandPath) {
|
|
52228
|
+
const command = commandPath.replace(/\./g, " ");
|
|
52229
|
+
return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
52230
|
+
}
|
|
52231
|
+
Command.prototype.trackedAction = function(context, fn, properties) {
|
|
52232
|
+
const command = this;
|
|
52233
|
+
return this.action(async (...args) => {
|
|
52234
|
+
const telemetryName = deriveCommandPath(command);
|
|
52235
|
+
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
52236
|
+
const startTime = performance.now();
|
|
52237
|
+
let errorMessage2;
|
|
52238
|
+
const [error] = await catchError2(fn(...args));
|
|
52239
|
+
if (error) {
|
|
52240
|
+
errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
52241
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage2}`);
|
|
52242
|
+
const typed = error;
|
|
52243
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
52244
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
52245
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
52246
|
+
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
52247
|
+
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
52248
|
+
const typedRetry = typed.retry ?? typed.Retry;
|
|
52249
|
+
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
52250
|
+
const typedContext = typed.context ?? typed.Context;
|
|
52251
|
+
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
52252
|
+
OutputFormatter.error({
|
|
52253
|
+
Result: finalResult,
|
|
52254
|
+
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
52255
|
+
Message: errorMessage2,
|
|
52256
|
+
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
52257
|
+
...customRetry ? { Retry: customRetry } : {},
|
|
52258
|
+
...customContext ? { Context: customContext } : {}
|
|
52259
|
+
});
|
|
52260
|
+
context.exit(EXIT_CODES[finalResult]);
|
|
53274
52261
|
}
|
|
53275
|
-
|
|
53276
|
-
|
|
53277
|
-
|
|
53278
|
-
|
|
53279
|
-
|
|
53280
|
-
|
|
53281
|
-
|
|
53282
|
-
|
|
53283
|
-
|
|
53284
|
-
|
|
53285
|
-
const subx = [];
|
|
53286
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
53287
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
53288
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
53289
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
53290
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
53291
|
-
return ";" + ups.split("").join(";") + ";";
|
|
53292
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
53293
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
53294
|
-
const match = exp.match(/#(\d+)/u);
|
|
53295
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
52262
|
+
const durationMs = performance.now() - startTime;
|
|
52263
|
+
const success = !error && (process.exitCode === undefined || process.exitCode === 0);
|
|
52264
|
+
telemetry.trackEvent(telemetryName, redactProperties({
|
|
52265
|
+
...extractCommandParams(command),
|
|
52266
|
+
...props,
|
|
52267
|
+
command: "true",
|
|
52268
|
+
duration: String(durationMs),
|
|
52269
|
+
success: String(success),
|
|
52270
|
+
...errorMessage2 ? { errorMessage: errorMessage2 } : {}
|
|
52271
|
+
}));
|
|
53296
52272
|
});
|
|
53297
|
-
cache[expr] = exprList;
|
|
53298
|
-
return cache[expr].concat();
|
|
53299
|
-
};
|
|
53300
|
-
JSONPath.prototype.safeVm = {
|
|
53301
|
-
Script: SafeScript
|
|
53302
52273
|
};
|
|
53303
|
-
|
|
52274
|
+
// ../common/src/console-guard.ts
|
|
52275
|
+
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
52276
|
+
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
52277
|
+
// ../common/src/constants.ts
|
|
52278
|
+
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
52279
|
+
// ../common/src/interactivity-context.ts
|
|
52280
|
+
var modeSlot = singleton("InteractivityMode");
|
|
53304
52281
|
// ../common/src/polling/types.ts
|
|
53305
52282
|
var PollOutcome = {
|
|
53306
52283
|
Completed: "completed",
|
|
@@ -53335,6 +52312,17 @@ var FAILURE_STATUSES = new Set([
|
|
|
53335
52312
|
"canceled",
|
|
53336
52313
|
"stopped"
|
|
53337
52314
|
]);
|
|
52315
|
+
// ../common/src/preview.ts
|
|
52316
|
+
var previewSlot = singleton("PreviewBuild");
|
|
52317
|
+
function isPreviewBuild() {
|
|
52318
|
+
return previewSlot.get(false) ?? false;
|
|
52319
|
+
}
|
|
52320
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
52321
|
+
if (isPreviewBuild()) {
|
|
52322
|
+
return this.command(nameAndArgs, opts);
|
|
52323
|
+
}
|
|
52324
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
52325
|
+
};
|
|
53338
52326
|
// ../common/src/screen-logger.ts
|
|
53339
52327
|
var ScreenLogger;
|
|
53340
52328
|
((ScreenLogger) => {
|
|
@@ -53367,8 +52355,8 @@ function appendUserAgentToken(value, userAgent) {
|
|
|
53367
52355
|
function getEffectiveUserAgent(userAgent) {
|
|
53368
52356
|
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
53369
52357
|
}
|
|
53370
|
-
function
|
|
53371
|
-
return
|
|
52358
|
+
function getHeaderName(headers, headerName) {
|
|
52359
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
53372
52360
|
}
|
|
53373
52361
|
function getSdkUserAgentToken(pkg) {
|
|
53374
52362
|
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
@@ -53376,59 +52364,31 @@ function getSdkUserAgentToken(pkg) {
|
|
|
53376
52364
|
}
|
|
53377
52365
|
function addSdkUserAgentHeader(headers, userAgent) {
|
|
53378
52366
|
const result = { ...headers ?? {} };
|
|
53379
|
-
const
|
|
53380
|
-
|
|
53381
|
-
if (headerName) {
|
|
53382
|
-
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
53383
|
-
} else {
|
|
53384
|
-
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
53385
|
-
}
|
|
52367
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
52368
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
53386
52369
|
return result;
|
|
53387
52370
|
}
|
|
53388
|
-
function
|
|
53389
|
-
|
|
53390
|
-
if (isHeadersLike(headers)) {
|
|
53391
|
-
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
53392
|
-
return headers;
|
|
53393
|
-
}
|
|
53394
|
-
if (Array.isArray(headers)) {
|
|
53395
|
-
const result = headers.map((entry) => {
|
|
53396
|
-
const [key, value] = entry;
|
|
53397
|
-
return [key, value];
|
|
53398
|
-
});
|
|
53399
|
-
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
53400
|
-
if (headerIndex >= 0) {
|
|
53401
|
-
const [key, value] = result[headerIndex];
|
|
53402
|
-
result[headerIndex] = [
|
|
53403
|
-
key,
|
|
53404
|
-
appendUserAgentToken(value, effectiveUserAgent)
|
|
53405
|
-
];
|
|
53406
|
-
} else {
|
|
53407
|
-
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
53408
|
-
}
|
|
53409
|
-
return result;
|
|
53410
|
-
}
|
|
53411
|
-
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
52371
|
+
function asHeaderRecord(headers) {
|
|
52372
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
53412
52373
|
}
|
|
53413
|
-
function
|
|
52374
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
53414
52375
|
return async (requestContext) => {
|
|
53415
|
-
const
|
|
52376
|
+
const initWithHeaders = {
|
|
53416
52377
|
...requestContext.init,
|
|
53417
|
-
headers:
|
|
52378
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
53418
52379
|
};
|
|
53419
52380
|
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
53420
52381
|
...requestContext,
|
|
53421
|
-
init:
|
|
52382
|
+
init: initWithHeaders
|
|
53422
52383
|
}) : initOverrides;
|
|
53423
52384
|
return {
|
|
53424
52385
|
...override ?? {},
|
|
53425
|
-
headers:
|
|
52386
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
53426
52387
|
};
|
|
53427
52388
|
};
|
|
53428
52389
|
}
|
|
53429
|
-
function
|
|
52390
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
53430
52391
|
const prototype = BaseApiClass.prototype;
|
|
53431
|
-
const patchKey = userAgentPatchKey(userAgent);
|
|
53432
52392
|
if (prototype[patchKey]) {
|
|
53433
52393
|
return;
|
|
53434
52394
|
}
|
|
@@ -53436,13 +52396,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
|
53436
52396
|
throw new Error("Generated BaseAPI request function not found.");
|
|
53437
52397
|
}
|
|
53438
52398
|
const originalRequest = prototype.request;
|
|
53439
|
-
prototype.request = function
|
|
53440
|
-
return originalRequest.call(this, context,
|
|
52399
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
52400
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
53441
52401
|
};
|
|
53442
52402
|
Object.defineProperty(prototype, patchKey, {
|
|
53443
52403
|
value: true
|
|
53444
52404
|
});
|
|
53445
52405
|
}
|
|
52406
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
52407
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
52408
|
+
}
|
|
53446
52409
|
// ../common/src/tool-provider.ts
|
|
53447
52410
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
53448
52411
|
// src/utils/product-codes.ts
|
|
@@ -54339,7 +53302,7 @@ class JSONApiResponse {
|
|
|
54339
53302
|
var package_default2 = {
|
|
54340
53303
|
name: "@uipath/identity-sdk",
|
|
54341
53304
|
license: "MIT",
|
|
54342
|
-
version: "1.
|
|
53305
|
+
version: "1.197.0",
|
|
54343
53306
|
repository: {
|
|
54344
53307
|
type: "git",
|
|
54345
53308
|
url: "https://github.com/UiPath/cli.git",
|
|
@@ -54367,7 +53330,7 @@ var package_default2 = {
|
|
|
54367
53330
|
],
|
|
54368
53331
|
private: true,
|
|
54369
53332
|
scripts: {
|
|
54370
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
53333
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
54371
53334
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
54372
53335
|
lint: "biome check .",
|
|
54373
53336
|
test: "vitest run",
|
|
@@ -55540,17 +54503,17 @@ var parseDelta = (raw) => {
|
|
|
55540
54503
|
return parsed;
|
|
55541
54504
|
};
|
|
55542
54505
|
var buildCodeIndex = (licenses) => {
|
|
55543
|
-
const
|
|
54506
|
+
const index = new Map;
|
|
55544
54507
|
for (const license of licenses) {
|
|
55545
54508
|
for (const product of license.license?.products ?? []) {
|
|
55546
54509
|
if (typeof product.code === "string") {
|
|
55547
|
-
const candidates =
|
|
54510
|
+
const candidates = index.get(product.code) ?? [];
|
|
55548
54511
|
candidates.push(license);
|
|
55549
|
-
|
|
54512
|
+
index.set(product.code, candidates);
|
|
55550
54513
|
}
|
|
55551
54514
|
}
|
|
55552
54515
|
}
|
|
55553
|
-
return
|
|
54516
|
+
return index;
|
|
55554
54517
|
};
|
|
55555
54518
|
var routeDelta = (delta, codeIndex) => {
|
|
55556
54519
|
const groups = new Map;
|
|
@@ -56096,3 +55059,5 @@ export {
|
|
|
56096
55059
|
registerCommands,
|
|
56097
55060
|
metadata
|
|
56098
55061
|
};
|
|
55062
|
+
|
|
55063
|
+
//# debugId=0F5BA07C1FA31F7664756E2164756E21
|