@uipath/authz-tool 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +716 -157
- package/dist/tool.js +716 -157
- package/package.json +28 -37
package/dist/index.js
CHANGED
|
@@ -2800,6 +2800,7 @@ var init_open = __esm(() => {
|
|
|
2800
2800
|
});
|
|
2801
2801
|
|
|
2802
2802
|
// ../../filesystem/src/node.ts
|
|
2803
|
+
import { randomUUID } from "node:crypto";
|
|
2803
2804
|
import { existsSync } from "node:fs";
|
|
2804
2805
|
import * as fs6 from "node:fs/promises";
|
|
2805
2806
|
import * as os2 from "node:os";
|
|
@@ -2881,6 +2882,90 @@ class NodeFileSystem {
|
|
|
2881
2882
|
async mkdir(dirPath) {
|
|
2882
2883
|
await fs6.mkdir(dirPath, { recursive: true });
|
|
2883
2884
|
}
|
|
2885
|
+
async acquireLock(lockPath) {
|
|
2886
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
2887
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
2888
|
+
const ownerId = randomUUID();
|
|
2889
|
+
const start = Date.now();
|
|
2890
|
+
while (true) {
|
|
2891
|
+
try {
|
|
2892
|
+
await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
2893
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
2894
|
+
} catch (error) {
|
|
2895
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2896
|
+
throw error;
|
|
2897
|
+
}
|
|
2898
|
+
const stats = await fs6.stat(lockFile).catch(() => null);
|
|
2899
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2900
|
+
const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2901
|
+
if (reclaimed)
|
|
2902
|
+
continue;
|
|
2903
|
+
}
|
|
2904
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2905
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2906
|
+
}
|
|
2907
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
async canonicalizeLockTarget(lockPath) {
|
|
2912
|
+
const absolute = path2.resolve(lockPath);
|
|
2913
|
+
const fullReal = await fs6.realpath(absolute).catch(() => null);
|
|
2914
|
+
if (fullReal)
|
|
2915
|
+
return fullReal;
|
|
2916
|
+
const parent = path2.dirname(absolute);
|
|
2917
|
+
const base = path2.basename(absolute);
|
|
2918
|
+
const canonicalParent = await fs6.realpath(parent).catch(() => parent);
|
|
2919
|
+
return path2.join(canonicalParent, base);
|
|
2920
|
+
}
|
|
2921
|
+
createLockRelease(lockFile, ownerId) {
|
|
2922
|
+
const heartbeatStart = Date.now();
|
|
2923
|
+
let heartbeatTimer;
|
|
2924
|
+
let stopped = false;
|
|
2925
|
+
const stopHeartbeat = () => {
|
|
2926
|
+
stopped = true;
|
|
2927
|
+
if (heartbeatTimer)
|
|
2928
|
+
clearTimeout(heartbeatTimer);
|
|
2929
|
+
};
|
|
2930
|
+
const scheduleNextHeartbeat = () => {
|
|
2931
|
+
if (stopped)
|
|
2932
|
+
return;
|
|
2933
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
2934
|
+
stopped = true;
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
heartbeatTimer = setTimeout(() => {
|
|
2938
|
+
runHeartbeat();
|
|
2939
|
+
}, LOCK_HEARTBEAT_MS);
|
|
2940
|
+
heartbeatTimer.unref?.();
|
|
2941
|
+
};
|
|
2942
|
+
const runHeartbeat = async () => {
|
|
2943
|
+
if (stopped)
|
|
2944
|
+
return;
|
|
2945
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
2946
|
+
if (stopped)
|
|
2947
|
+
return;
|
|
2948
|
+
if (current !== ownerId) {
|
|
2949
|
+
stopped = true;
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
const now = Date.now() / 1000;
|
|
2953
|
+
await fs6.utimes(lockFile, now, now).catch(() => {});
|
|
2954
|
+
scheduleNextHeartbeat();
|
|
2955
|
+
};
|
|
2956
|
+
scheduleNextHeartbeat();
|
|
2957
|
+
let released = false;
|
|
2958
|
+
return async () => {
|
|
2959
|
+
if (released)
|
|
2960
|
+
return;
|
|
2961
|
+
released = true;
|
|
2962
|
+
stopHeartbeat();
|
|
2963
|
+
const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
|
|
2964
|
+
if (current === ownerId) {
|
|
2965
|
+
await fs6.rm(lockFile, { force: true });
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2884
2969
|
async rm(filePath) {
|
|
2885
2970
|
await fs6.rm(filePath, { recursive: true, force: true });
|
|
2886
2971
|
}
|
|
@@ -2926,9 +3011,13 @@ class NodeFileSystem {
|
|
|
2926
3011
|
}
|
|
2927
3012
|
}
|
|
2928
3013
|
isEnoent(error) {
|
|
2929
|
-
return
|
|
3014
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
3015
|
+
}
|
|
3016
|
+
hasErrnoCode(error, code) {
|
|
3017
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2930
3018
|
}
|
|
2931
3019
|
}
|
|
3020
|
+
var LOCK_HEARTBEAT_MS = 5000, LOCK_STALE_MS = 15000, LOCK_MAX_WAIT_MS = 20000, LOCK_MAX_HOLD_MS = 60000, LOCK_RETRY_MIN_MS = 100, LOCK_RETRY_JITTER_MS = 200;
|
|
2932
3021
|
var init_node = __esm(() => {
|
|
2933
3022
|
init_open();
|
|
2934
3023
|
});
|
|
@@ -2942,7 +3031,7 @@ var init_src = __esm(() => {
|
|
|
2942
3031
|
|
|
2943
3032
|
// ../../../node_modules/@uipath/coreipc/index.js
|
|
2944
3033
|
var require_coreipc = __commonJS((exports, module) => {
|
|
2945
|
-
var __dirname = "/
|
|
3034
|
+
var __dirname = "/home/runner/work/cli/cli/node_modules/@uipath/coreipc";
|
|
2946
3035
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2947
3036
|
(function(e, t) {
|
|
2948
3037
|
typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.ipc = t() : e.ipc = t();
|
|
@@ -21134,6 +21223,10 @@ var require_dist = __commonJS((exports) => {
|
|
|
21134
21223
|
exports.RobotProxyConstructor = RobotProxyConstructor;
|
|
21135
21224
|
__exportStar(require_agent(), exports);
|
|
21136
21225
|
});
|
|
21226
|
+
// ../../auth/src/server.ts
|
|
21227
|
+
var init_server = __esm(() => {
|
|
21228
|
+
init_constants();
|
|
21229
|
+
});
|
|
21137
21230
|
|
|
21138
21231
|
// ../../../node_modules/commander/esm.mjs
|
|
21139
21232
|
var import__ = __toESM(require_commander(), 1);
|
|
@@ -21153,7 +21246,8 @@ var {
|
|
|
21153
21246
|
// package.json
|
|
21154
21247
|
var package_default = {
|
|
21155
21248
|
name: "@uipath/authz-tool",
|
|
21156
|
-
|
|
21249
|
+
license: "MIT",
|
|
21250
|
+
version: "1.2.0",
|
|
21157
21251
|
description: "CLI plugin for the UiPath Authorization service.",
|
|
21158
21252
|
private: false,
|
|
21159
21253
|
repository: {
|
|
@@ -21222,32 +21316,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
21222
21316
|
this.name = "InvalidBaseUrlError";
|
|
21223
21317
|
}
|
|
21224
21318
|
}
|
|
21225
|
-
var DEFAULT_SCOPES = [
|
|
21226
|
-
"offline_access",
|
|
21227
|
-
"ProcessMining",
|
|
21228
|
-
"OrchestratorApiUserAccess",
|
|
21229
|
-
"StudioWebBackend",
|
|
21230
|
-
"IdentityServerApi",
|
|
21231
|
-
"ConnectionService",
|
|
21232
|
-
"DataService",
|
|
21233
|
-
"DataServiceApiUserAccess",
|
|
21234
|
-
"DocumentUnderstanding",
|
|
21235
|
-
"EnterpriseContextService",
|
|
21236
|
-
"Directory",
|
|
21237
|
-
"JamJamApi",
|
|
21238
|
-
"LLMGateway",
|
|
21239
|
-
"LLMOps",
|
|
21240
|
-
"OMS",
|
|
21241
|
-
"RCS.FolderAuthorization",
|
|
21242
|
-
"RCS.TagsManagement",
|
|
21243
|
-
"TestmanagerApiUserAccess",
|
|
21244
|
-
"AutomationSolutions",
|
|
21245
|
-
"StudioWebTypeCacheService",
|
|
21246
|
-
"Docs.GPT.Search",
|
|
21247
|
-
"Insights",
|
|
21248
|
-
"ReferenceToken",
|
|
21249
|
-
"Audit.Read"
|
|
21250
|
-
];
|
|
21319
|
+
var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
|
|
21251
21320
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
21252
21321
|
let baseUrl = rawUrl;
|
|
21253
21322
|
if (baseUrl.endsWith("/identity_/")) {
|
|
@@ -21297,7 +21366,8 @@ var resolveConfigAsync = async ({
|
|
|
21297
21366
|
if (!clientSecret && fileAuth.clientSecret) {
|
|
21298
21367
|
clientSecret = fileAuth.clientSecret;
|
|
21299
21368
|
}
|
|
21300
|
-
const
|
|
21369
|
+
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
21370
|
+
const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
|
|
21301
21371
|
return {
|
|
21302
21372
|
clientId,
|
|
21303
21373
|
clientSecret,
|
|
@@ -21797,6 +21867,129 @@ function normalizeTokenRefreshFailure() {
|
|
|
21797
21867
|
function normalizeTokenRefreshUnavailableFailure() {
|
|
21798
21868
|
return "token refresh failed before authentication completed";
|
|
21799
21869
|
}
|
|
21870
|
+
function errorMessage(error) {
|
|
21871
|
+
return error instanceof Error ? error.message : String(error);
|
|
21872
|
+
}
|
|
21873
|
+
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
21874
|
+
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
21875
|
+
}
|
|
21876
|
+
async function runRefreshLocked(inputs) {
|
|
21877
|
+
const {
|
|
21878
|
+
absolutePath,
|
|
21879
|
+
refreshToken: callerRefreshToken,
|
|
21880
|
+
customAuthority,
|
|
21881
|
+
ensureTokenValidityMinutes,
|
|
21882
|
+
loadEnvFile,
|
|
21883
|
+
saveEnvFile,
|
|
21884
|
+
refreshFn,
|
|
21885
|
+
resolveConfig
|
|
21886
|
+
} = inputs;
|
|
21887
|
+
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
21888
|
+
let fresh;
|
|
21889
|
+
try {
|
|
21890
|
+
fresh = await loadEnvFile({ envPath: absolutePath });
|
|
21891
|
+
} catch (error) {
|
|
21892
|
+
return {
|
|
21893
|
+
kind: "fail",
|
|
21894
|
+
status: {
|
|
21895
|
+
loginStatus: "Refresh Failed",
|
|
21896
|
+
hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
|
|
21897
|
+
tokenRefresh: {
|
|
21898
|
+
attempted: false,
|
|
21899
|
+
success: false,
|
|
21900
|
+
errorMessage: `auth file read failed: ${errorMessage(error)}`
|
|
21901
|
+
}
|
|
21902
|
+
}
|
|
21903
|
+
};
|
|
21904
|
+
}
|
|
21905
|
+
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
21906
|
+
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
21907
|
+
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
21908
|
+
return {
|
|
21909
|
+
kind: "ok",
|
|
21910
|
+
accessToken: freshAccess,
|
|
21911
|
+
refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
|
|
21912
|
+
expiration: freshExp,
|
|
21913
|
+
tokenRefresh: { attempted: false, success: true }
|
|
21914
|
+
};
|
|
21915
|
+
}
|
|
21916
|
+
const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
|
|
21917
|
+
let refreshedAccess;
|
|
21918
|
+
let refreshedRefresh;
|
|
21919
|
+
try {
|
|
21920
|
+
const config = await resolveConfig({ customAuthority });
|
|
21921
|
+
const refreshed = await refreshFn({
|
|
21922
|
+
refreshToken: tokenForIdP,
|
|
21923
|
+
tokenEndpoint: config.tokenEndpoint,
|
|
21924
|
+
clientId: config.clientId,
|
|
21925
|
+
expectedAuthority: customAuthority
|
|
21926
|
+
});
|
|
21927
|
+
refreshedAccess = refreshed.accessToken;
|
|
21928
|
+
refreshedRefresh = refreshed.refreshToken;
|
|
21929
|
+
} catch (error) {
|
|
21930
|
+
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
21931
|
+
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.";
|
|
21932
|
+
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
21933
|
+
return {
|
|
21934
|
+
kind: "fail",
|
|
21935
|
+
status: {
|
|
21936
|
+
loginStatus: "Refresh Failed",
|
|
21937
|
+
hint,
|
|
21938
|
+
tokenRefresh: {
|
|
21939
|
+
attempted: true,
|
|
21940
|
+
success: false,
|
|
21941
|
+
errorMessage: message
|
|
21942
|
+
}
|
|
21943
|
+
}
|
|
21944
|
+
};
|
|
21945
|
+
}
|
|
21946
|
+
const refreshedExp = getTokenExpiration(refreshedAccess);
|
|
21947
|
+
if (!refreshedExp || refreshedExp <= new Date) {
|
|
21948
|
+
return {
|
|
21949
|
+
kind: "fail",
|
|
21950
|
+
status: {
|
|
21951
|
+
loginStatus: "Refresh Failed",
|
|
21952
|
+
hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
|
|
21953
|
+
tokenRefresh: {
|
|
21954
|
+
attempted: true,
|
|
21955
|
+
success: false,
|
|
21956
|
+
errorMessage: "refreshed token has no valid expiration claim"
|
|
21957
|
+
}
|
|
21958
|
+
}
|
|
21959
|
+
};
|
|
21960
|
+
}
|
|
21961
|
+
try {
|
|
21962
|
+
await saveEnvFile({
|
|
21963
|
+
envPath: absolutePath,
|
|
21964
|
+
data: {
|
|
21965
|
+
UIPATH_ACCESS_TOKEN: refreshedAccess,
|
|
21966
|
+
UIPATH_REFRESH_TOKEN: refreshedRefresh
|
|
21967
|
+
},
|
|
21968
|
+
merge: true
|
|
21969
|
+
});
|
|
21970
|
+
return {
|
|
21971
|
+
kind: "ok",
|
|
21972
|
+
accessToken: refreshedAccess,
|
|
21973
|
+
refreshToken: refreshedRefresh,
|
|
21974
|
+
expiration: refreshedExp,
|
|
21975
|
+
tokenRefresh: { attempted: true, success: true }
|
|
21976
|
+
};
|
|
21977
|
+
} catch (error) {
|
|
21978
|
+
const msg = errorMessage(error);
|
|
21979
|
+
return {
|
|
21980
|
+
kind: "ok",
|
|
21981
|
+
accessToken: refreshedAccess,
|
|
21982
|
+
refreshToken: refreshedRefresh,
|
|
21983
|
+
expiration: refreshedExp,
|
|
21984
|
+
persistenceWarning: `Access token refreshed in memory but could not be written to ${absolutePath}: ${msg}. The next CLI invocation will fail until the file can be updated — run 'uip login' to re-authenticate.`,
|
|
21985
|
+
tokenRefresh: {
|
|
21986
|
+
attempted: true,
|
|
21987
|
+
success: true,
|
|
21988
|
+
errorMessage: `persistence failed: ${msg}`
|
|
21989
|
+
}
|
|
21990
|
+
};
|
|
21991
|
+
}
|
|
21992
|
+
}
|
|
21800
21993
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
21801
21994
|
const {
|
|
21802
21995
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
@@ -21871,73 +22064,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
21871
22064
|
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
21872
22065
|
let expiration = getTokenExpiration(accessToken);
|
|
21873
22066
|
let persistenceWarning;
|
|
22067
|
+
let lockReleaseFailed = false;
|
|
21874
22068
|
let tokenRefresh;
|
|
21875
|
-
const
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
|
|
22069
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
22070
|
+
const tryGlobalCredsHint = async () => {
|
|
22071
|
+
const fs7 = getFs();
|
|
22072
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
22073
|
+
if (absolutePath === globalPath)
|
|
22074
|
+
return;
|
|
22075
|
+
if (!await fs7.exists(globalPath))
|
|
22076
|
+
return;
|
|
21879
22077
|
try {
|
|
21880
|
-
const
|
|
21881
|
-
|
|
21882
|
-
|
|
21883
|
-
const
|
|
21884
|
-
|
|
21885
|
-
|
|
21886
|
-
|
|
21887
|
-
|
|
21888
|
-
|
|
21889
|
-
refreshedAccess = refreshed.accessToken;
|
|
21890
|
-
refreshedRefresh = refreshed.refreshToken;
|
|
21891
|
-
} catch (error) {
|
|
21892
|
-
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
21893
|
-
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.";
|
|
21894
|
-
const errorMessage = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
21895
|
-
return {
|
|
21896
|
-
loginStatus: "Refresh Failed",
|
|
21897
|
-
hint,
|
|
21898
|
-
tokenRefresh: {
|
|
21899
|
-
attempted: true,
|
|
21900
|
-
success: false,
|
|
21901
|
-
errorMessage
|
|
21902
|
-
}
|
|
21903
|
-
};
|
|
22078
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
22079
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
22080
|
+
return;
|
|
22081
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
22082
|
+
if (globalExp && globalExp <= new Date)
|
|
22083
|
+
return;
|
|
22084
|
+
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.`;
|
|
22085
|
+
} catch {
|
|
22086
|
+
return;
|
|
21904
22087
|
}
|
|
21905
|
-
|
|
21906
|
-
|
|
22088
|
+
};
|
|
22089
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
22090
|
+
let release;
|
|
22091
|
+
try {
|
|
22092
|
+
release = await getFs().acquireLock(absolutePath);
|
|
22093
|
+
} catch (error) {
|
|
22094
|
+
const msg = errorMessage(error);
|
|
22095
|
+
const globalHint = await tryGlobalCredsHint();
|
|
22096
|
+
if (globalHint) {
|
|
22097
|
+
return {
|
|
22098
|
+
loginStatus: "Expired",
|
|
22099
|
+
accessToken,
|
|
22100
|
+
refreshToken,
|
|
22101
|
+
baseUrl: credentials.UIPATH_URL,
|
|
22102
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
22103
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
22104
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
22105
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
22106
|
+
expiration,
|
|
22107
|
+
source: "file" /* File */,
|
|
22108
|
+
hint: globalHint,
|
|
22109
|
+
tokenRefresh: {
|
|
22110
|
+
attempted: false,
|
|
22111
|
+
success: false,
|
|
22112
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
22113
|
+
}
|
|
22114
|
+
};
|
|
22115
|
+
}
|
|
21907
22116
|
return {
|
|
21908
22117
|
loginStatus: "Refresh Failed",
|
|
21909
|
-
hint: "
|
|
22118
|
+
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.",
|
|
21910
22119
|
tokenRefresh: {
|
|
21911
|
-
attempted:
|
|
22120
|
+
attempted: false,
|
|
21912
22121
|
success: false,
|
|
21913
|
-
errorMessage:
|
|
22122
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
21914
22123
|
}
|
|
21915
22124
|
};
|
|
21916
22125
|
}
|
|
21917
|
-
|
|
21918
|
-
refreshToken = refreshedRefresh;
|
|
21919
|
-
expiration = refreshedExp;
|
|
22126
|
+
let lockedFailure;
|
|
21920
22127
|
try {
|
|
21921
|
-
await
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
21926
|
-
|
|
21927
|
-
|
|
22128
|
+
const outcome = await runRefreshLocked({
|
|
22129
|
+
absolutePath,
|
|
22130
|
+
refreshToken,
|
|
22131
|
+
customAuthority: credentials.UIPATH_URL,
|
|
22132
|
+
ensureTokenValidityMinutes,
|
|
22133
|
+
loadEnvFile,
|
|
22134
|
+
saveEnvFile,
|
|
22135
|
+
refreshFn: refreshTokenFn,
|
|
22136
|
+
resolveConfig
|
|
21928
22137
|
});
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21932
|
-
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
21940
|
-
|
|
22138
|
+
if (outcome.kind === "fail") {
|
|
22139
|
+
lockedFailure = outcome.status;
|
|
22140
|
+
} else {
|
|
22141
|
+
accessToken = outcome.accessToken;
|
|
22142
|
+
refreshToken = outcome.refreshToken;
|
|
22143
|
+
expiration = outcome.expiration;
|
|
22144
|
+
tokenRefresh = outcome.tokenRefresh;
|
|
22145
|
+
if (outcome.persistenceWarning) {
|
|
22146
|
+
persistenceWarning = outcome.persistenceWarning;
|
|
22147
|
+
}
|
|
22148
|
+
}
|
|
22149
|
+
} finally {
|
|
22150
|
+
try {
|
|
22151
|
+
await release();
|
|
22152
|
+
} catch {
|
|
22153
|
+
lockReleaseFailed = true;
|
|
22154
|
+
}
|
|
22155
|
+
}
|
|
22156
|
+
if (lockedFailure) {
|
|
22157
|
+
const globalHint = await tryGlobalCredsHint();
|
|
22158
|
+
const base = globalHint ? {
|
|
22159
|
+
...lockedFailure,
|
|
22160
|
+
loginStatus: "Expired",
|
|
22161
|
+
hint: globalHint
|
|
22162
|
+
} : lockedFailure;
|
|
22163
|
+
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
21941
22164
|
}
|
|
21942
22165
|
}
|
|
21943
22166
|
const result = {
|
|
@@ -21952,23 +22175,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
21952
22175
|
expiration,
|
|
21953
22176
|
source: "file" /* File */,
|
|
21954
22177
|
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
22178
|
+
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
21955
22179
|
...tokenRefresh ? { tokenRefresh } : {}
|
|
21956
22180
|
};
|
|
21957
22181
|
if (result.loginStatus === "Expired") {
|
|
21958
|
-
const
|
|
21959
|
-
|
|
21960
|
-
|
|
21961
|
-
try {
|
|
21962
|
-
const globalCreds = await loadEnvFile({
|
|
21963
|
-
envPath: globalPath
|
|
21964
|
-
});
|
|
21965
|
-
if (globalCreds.UIPATH_ACCESS_TOKEN) {
|
|
21966
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
21967
|
-
if (!globalExp || globalExp > new Date) {
|
|
21968
|
-
result.hint = `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
|
|
21969
|
-
}
|
|
21970
|
-
}
|
|
21971
|
-
} catch {}
|
|
22182
|
+
const globalHint = await tryGlobalCredsHint();
|
|
22183
|
+
if (globalHint) {
|
|
22184
|
+
result.hint = globalHint;
|
|
21972
22185
|
}
|
|
21973
22186
|
}
|
|
21974
22187
|
return result;
|
|
@@ -22016,6 +22229,140 @@ var getAuthContext = async (options = {}) => {
|
|
|
22016
22229
|
init_src();
|
|
22017
22230
|
// ../../auth/src/logout.ts
|
|
22018
22231
|
init_src();
|
|
22232
|
+
|
|
22233
|
+
// ../../auth/src/index.ts
|
|
22234
|
+
init_server();
|
|
22235
|
+
|
|
22236
|
+
// ../../common/src/singleton.ts
|
|
22237
|
+
var PREFIX = "@uipath/common/";
|
|
22238
|
+
var _g = globalThis;
|
|
22239
|
+
function singleton(ctorOrName) {
|
|
22240
|
+
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
22241
|
+
const key = Symbol.for(PREFIX + name);
|
|
22242
|
+
return {
|
|
22243
|
+
get(fallback) {
|
|
22244
|
+
return _g[key] ?? fallback;
|
|
22245
|
+
},
|
|
22246
|
+
set(value) {
|
|
22247
|
+
_g[key] = value;
|
|
22248
|
+
},
|
|
22249
|
+
clear() {
|
|
22250
|
+
delete _g[key];
|
|
22251
|
+
},
|
|
22252
|
+
getOrInit(factory, guard) {
|
|
22253
|
+
const existing = _g[key];
|
|
22254
|
+
if (existing != null && typeof existing === "object") {
|
|
22255
|
+
if (!guard || guard(existing)) {
|
|
22256
|
+
return existing;
|
|
22257
|
+
}
|
|
22258
|
+
}
|
|
22259
|
+
const instance = factory();
|
|
22260
|
+
_g[key] = instance;
|
|
22261
|
+
return instance;
|
|
22262
|
+
}
|
|
22263
|
+
};
|
|
22264
|
+
}
|
|
22265
|
+
|
|
22266
|
+
// ../../common/src/sdk-user-agent.ts
|
|
22267
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
22268
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
22269
|
+
function userAgentPatchKey(userAgent) {
|
|
22270
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
22271
|
+
}
|
|
22272
|
+
function splitUserAgentTokens(value) {
|
|
22273
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
22274
|
+
}
|
|
22275
|
+
function appendUserAgentToken(value, userAgent) {
|
|
22276
|
+
const tokens = splitUserAgentTokens(value);
|
|
22277
|
+
const seen = new Set(tokens);
|
|
22278
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
22279
|
+
if (!seen.has(token)) {
|
|
22280
|
+
tokens.push(token);
|
|
22281
|
+
seen.add(token);
|
|
22282
|
+
}
|
|
22283
|
+
}
|
|
22284
|
+
return tokens.join(" ");
|
|
22285
|
+
}
|
|
22286
|
+
function getEffectiveUserAgent(userAgent) {
|
|
22287
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
22288
|
+
}
|
|
22289
|
+
function isHeadersLike(headers) {
|
|
22290
|
+
return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
|
|
22291
|
+
}
|
|
22292
|
+
function getSdkUserAgentToken(pkg) {
|
|
22293
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
22294
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
22295
|
+
}
|
|
22296
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
22297
|
+
const result = { ...headers ?? {} };
|
|
22298
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
22299
|
+
const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
22300
|
+
if (headerName) {
|
|
22301
|
+
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
22302
|
+
} else {
|
|
22303
|
+
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
22304
|
+
}
|
|
22305
|
+
return result;
|
|
22306
|
+
}
|
|
22307
|
+
function withSdkUserAgentHeader(headers, userAgent) {
|
|
22308
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
22309
|
+
if (isHeadersLike(headers)) {
|
|
22310
|
+
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
22311
|
+
return headers;
|
|
22312
|
+
}
|
|
22313
|
+
if (Array.isArray(headers)) {
|
|
22314
|
+
const result = headers.map((entry) => {
|
|
22315
|
+
const [key, value] = entry;
|
|
22316
|
+
return [key, value];
|
|
22317
|
+
});
|
|
22318
|
+
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
22319
|
+
if (headerIndex >= 0) {
|
|
22320
|
+
const [key, value] = result[headerIndex];
|
|
22321
|
+
result[headerIndex] = [
|
|
22322
|
+
key,
|
|
22323
|
+
appendUserAgentToken(value, effectiveUserAgent)
|
|
22324
|
+
];
|
|
22325
|
+
} else {
|
|
22326
|
+
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
22327
|
+
}
|
|
22328
|
+
return result;
|
|
22329
|
+
}
|
|
22330
|
+
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
22331
|
+
}
|
|
22332
|
+
function withUserAgentInitOverride(initOverrides, userAgent) {
|
|
22333
|
+
return async (requestContext) => {
|
|
22334
|
+
const initWithUserAgent = {
|
|
22335
|
+
...requestContext.init,
|
|
22336
|
+
headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
|
|
22337
|
+
};
|
|
22338
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
22339
|
+
...requestContext,
|
|
22340
|
+
init: initWithUserAgent
|
|
22341
|
+
}) : initOverrides;
|
|
22342
|
+
return {
|
|
22343
|
+
...override ?? {},
|
|
22344
|
+
headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
|
|
22345
|
+
};
|
|
22346
|
+
};
|
|
22347
|
+
}
|
|
22348
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
22349
|
+
const prototype = BaseApiClass.prototype;
|
|
22350
|
+
const patchKey = userAgentPatchKey(userAgent);
|
|
22351
|
+
if (prototype[patchKey]) {
|
|
22352
|
+
return;
|
|
22353
|
+
}
|
|
22354
|
+
if (typeof prototype.request !== "function") {
|
|
22355
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
22356
|
+
}
|
|
22357
|
+
const originalRequest = prototype.request;
|
|
22358
|
+
prototype.request = function requestWithUserAgent(context, initOverrides) {
|
|
22359
|
+
return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
|
|
22360
|
+
};
|
|
22361
|
+
Object.defineProperty(prototype, patchKey, {
|
|
22362
|
+
value: true
|
|
22363
|
+
});
|
|
22364
|
+
}
|
|
22365
|
+
|
|
22019
22366
|
// ../authz-sdk/generated/src/runtime.ts
|
|
22020
22367
|
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
22021
22368
|
|
|
@@ -22265,6 +22612,57 @@ class VoidApiResponse {
|
|
|
22265
22612
|
return;
|
|
22266
22613
|
}
|
|
22267
22614
|
}
|
|
22615
|
+
// ../authz-sdk/package.json
|
|
22616
|
+
var package_default2 = {
|
|
22617
|
+
name: "@uipath/authz-sdk",
|
|
22618
|
+
license: "MIT",
|
|
22619
|
+
version: "1.2.0",
|
|
22620
|
+
description: "SDK for the UiPath Authorization Service API.",
|
|
22621
|
+
repository: {
|
|
22622
|
+
type: "git",
|
|
22623
|
+
url: "https://github.com/UiPath/cli.git",
|
|
22624
|
+
directory: "packages/admin/authz-sdk"
|
|
22625
|
+
},
|
|
22626
|
+
publishConfig: {
|
|
22627
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
22628
|
+
},
|
|
22629
|
+
keywords: [
|
|
22630
|
+
"uipath",
|
|
22631
|
+
"authorization",
|
|
22632
|
+
"authz",
|
|
22633
|
+
"sdk"
|
|
22634
|
+
],
|
|
22635
|
+
type: "module",
|
|
22636
|
+
main: "./dist/index.js",
|
|
22637
|
+
types: "./dist/src/index.d.ts",
|
|
22638
|
+
exports: {
|
|
22639
|
+
".": {
|
|
22640
|
+
types: "./dist/src/index.d.ts",
|
|
22641
|
+
default: "./dist/index.js"
|
|
22642
|
+
}
|
|
22643
|
+
},
|
|
22644
|
+
files: [
|
|
22645
|
+
"dist"
|
|
22646
|
+
],
|
|
22647
|
+
private: true,
|
|
22648
|
+
scripts: {
|
|
22649
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
22650
|
+
generate: "bun run src/scripts/generate-sdk.ts",
|
|
22651
|
+
lint: "biome check ."
|
|
22652
|
+
},
|
|
22653
|
+
devDependencies: {
|
|
22654
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
22655
|
+
"@types/node": "^25.5.2",
|
|
22656
|
+
"@uipath/auth": "workspace:*",
|
|
22657
|
+
"@uipath/common": "workspace:*",
|
|
22658
|
+
"@uipath/filesystem": "workspace:*",
|
|
22659
|
+
typescript: "^6.0.2"
|
|
22660
|
+
}
|
|
22661
|
+
};
|
|
22662
|
+
|
|
22663
|
+
// ../authz-sdk/src/user-agent.ts
|
|
22664
|
+
var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
|
|
22665
|
+
installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
|
|
22268
22666
|
|
|
22269
22667
|
// ../authz-sdk/generated/src/models/ActionDetailDto.ts
|
|
22270
22668
|
function ActionDetailDtoFromJSON(json) {
|
|
@@ -22791,7 +23189,8 @@ async function resolveConfig(plane, options) {
|
|
|
22791
23189
|
return {
|
|
22792
23190
|
config: new Configuration({
|
|
22793
23191
|
basePath,
|
|
22794
|
-
accessToken: async () => bearerToken
|
|
23192
|
+
accessToken: async () => bearerToken,
|
|
23193
|
+
headers: addSdkUserAgentHeader(undefined, SDK_USER_AGENT)
|
|
22795
23194
|
}),
|
|
22796
23195
|
organizationId: status.organizationId,
|
|
22797
23196
|
tenantId: status.tenantId,
|
|
@@ -22951,10 +23350,15 @@ async function extractErrorDetails(error, options) {
|
|
|
22951
23350
|
}
|
|
22952
23351
|
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
22953
23352
|
context.errorCode = parsedBody.errorCode;
|
|
23353
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
23354
|
+
context.errorCode = parsedBody.code;
|
|
22954
23355
|
}
|
|
22955
23356
|
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
22956
23357
|
context.requestId = parsedBody.requestId;
|
|
22957
23358
|
}
|
|
23359
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
23360
|
+
context.traceId = parsedBody.traceId;
|
|
23361
|
+
}
|
|
22958
23362
|
if (status === 429) {
|
|
22959
23363
|
const resp = response;
|
|
22960
23364
|
const headersObj = resp?.headers;
|
|
@@ -22974,7 +23378,35 @@ async function extractErrorDetails(error, options) {
|
|
|
22974
23378
|
}
|
|
22975
23379
|
}
|
|
22976
23380
|
const hasContext = Object.keys(context).length > 0;
|
|
22977
|
-
|
|
23381
|
+
let parsedErrors;
|
|
23382
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
23383
|
+
const errors = {};
|
|
23384
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
23385
|
+
if (Array.isArray(raw)) {
|
|
23386
|
+
const messages = raw.map((entry) => {
|
|
23387
|
+
if (typeof entry === "string")
|
|
23388
|
+
return entry;
|
|
23389
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
23390
|
+
return entry.message;
|
|
23391
|
+
}
|
|
23392
|
+
return String(entry);
|
|
23393
|
+
}).filter(Boolean);
|
|
23394
|
+
if (messages.length > 0)
|
|
23395
|
+
errors[field] = messages;
|
|
23396
|
+
} else if (typeof raw === "string") {
|
|
23397
|
+
errors[field] = [raw];
|
|
23398
|
+
}
|
|
23399
|
+
}
|
|
23400
|
+
if (Object.keys(errors).length > 0)
|
|
23401
|
+
parsedErrors = errors;
|
|
23402
|
+
}
|
|
23403
|
+
return {
|
|
23404
|
+
result,
|
|
23405
|
+
message,
|
|
23406
|
+
details,
|
|
23407
|
+
...hasContext ? { context } : {},
|
|
23408
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
23409
|
+
};
|
|
22978
23410
|
}
|
|
22979
23411
|
async function extractErrorMessage(error, options) {
|
|
22980
23412
|
const { message } = await extractErrorDetails(error, options);
|
|
@@ -22986,36 +23418,6 @@ Command.prototype.examples = function(examples) {
|
|
|
22986
23418
|
examplesByCommand.set(this, examples);
|
|
22987
23419
|
return this;
|
|
22988
23420
|
};
|
|
22989
|
-
// ../../common/src/singleton.ts
|
|
22990
|
-
var PREFIX = "@uipath/common/";
|
|
22991
|
-
var _g = globalThis;
|
|
22992
|
-
function singleton(ctorOrName) {
|
|
22993
|
-
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
22994
|
-
const key = Symbol.for(PREFIX + name);
|
|
22995
|
-
return {
|
|
22996
|
-
get(fallback) {
|
|
22997
|
-
return _g[key] ?? fallback;
|
|
22998
|
-
},
|
|
22999
|
-
set(value) {
|
|
23000
|
-
_g[key] = value;
|
|
23001
|
-
},
|
|
23002
|
-
clear() {
|
|
23003
|
-
delete _g[key];
|
|
23004
|
-
},
|
|
23005
|
-
getOrInit(factory, guard) {
|
|
23006
|
-
const existing = _g[key];
|
|
23007
|
-
if (existing != null && typeof existing === "object") {
|
|
23008
|
-
if (!guard || guard(existing)) {
|
|
23009
|
-
return existing;
|
|
23010
|
-
}
|
|
23011
|
-
}
|
|
23012
|
-
const instance = factory();
|
|
23013
|
-
_g[key] = instance;
|
|
23014
|
-
return instance;
|
|
23015
|
-
}
|
|
23016
|
-
};
|
|
23017
|
-
}
|
|
23018
|
-
|
|
23019
23421
|
// ../../common/src/output-context.ts
|
|
23020
23422
|
function createStorage() {
|
|
23021
23423
|
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
@@ -28105,6 +28507,60 @@ function escapeNonAscii(jsonText) {
|
|
|
28105
28507
|
function needsAsciiSafeJson(sink) {
|
|
28106
28508
|
return process.platform === "win32" && !sink.capabilities.isInteractive;
|
|
28107
28509
|
}
|
|
28510
|
+
function isPlainRecord(value) {
|
|
28511
|
+
if (value === null || typeof value !== "object")
|
|
28512
|
+
return false;
|
|
28513
|
+
const prototype = Object.getPrototypeOf(value);
|
|
28514
|
+
return prototype === Object.prototype || prototype === null;
|
|
28515
|
+
}
|
|
28516
|
+
function toLowerCamelCaseKey(key) {
|
|
28517
|
+
if (!key)
|
|
28518
|
+
return key;
|
|
28519
|
+
if (/[_\-\s]/.test(key)) {
|
|
28520
|
+
const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
|
|
28521
|
+
if (!firstPart)
|
|
28522
|
+
return key;
|
|
28523
|
+
return [
|
|
28524
|
+
toLowerCamelCaseSimpleKey(firstPart),
|
|
28525
|
+
...restParts.map((part) => {
|
|
28526
|
+
const normalized = toLowerCamelCaseSimpleKey(part);
|
|
28527
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
28528
|
+
})
|
|
28529
|
+
].join("");
|
|
28530
|
+
}
|
|
28531
|
+
return toLowerCamelCaseSimpleKey(key);
|
|
28532
|
+
}
|
|
28533
|
+
function toLowerCamelCaseSimpleKey(key) {
|
|
28534
|
+
if (/^[A-Z0-9]+$/.test(key))
|
|
28535
|
+
return key.toLowerCase();
|
|
28536
|
+
return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
|
|
28537
|
+
}
|
|
28538
|
+
function toPascalCaseKey(key) {
|
|
28539
|
+
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
28540
|
+
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
28541
|
+
}
|
|
28542
|
+
function toPascalCaseData(value) {
|
|
28543
|
+
if (Array.isArray(value))
|
|
28544
|
+
return value.map(toPascalCaseData);
|
|
28545
|
+
if (!isPlainRecord(value))
|
|
28546
|
+
return value;
|
|
28547
|
+
const result = {};
|
|
28548
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
28549
|
+
result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
|
|
28550
|
+
}
|
|
28551
|
+
return result;
|
|
28552
|
+
}
|
|
28553
|
+
function normalizeDataKeys(data) {
|
|
28554
|
+
return toPascalCaseData(data);
|
|
28555
|
+
}
|
|
28556
|
+
function normalizeOutputKeys(data) {
|
|
28557
|
+
const result = {};
|
|
28558
|
+
for (const [key, value] of Object.entries(data)) {
|
|
28559
|
+
const pascalKey = toPascalCaseKey(key);
|
|
28560
|
+
result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
|
|
28561
|
+
}
|
|
28562
|
+
return result;
|
|
28563
|
+
}
|
|
28108
28564
|
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
28109
28565
|
if (!data) {
|
|
28110
28566
|
logFn("Empty response object. No data to display.");
|
|
@@ -28167,7 +28623,7 @@ function wrapText(text, width) {
|
|
|
28167
28623
|
function printTable(data, logFn, externalLogValue) {
|
|
28168
28624
|
if (data.length === 0)
|
|
28169
28625
|
return;
|
|
28170
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
28626
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
28171
28627
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
28172
28628
|
const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
|
|
28173
28629
|
logFn(header);
|
|
@@ -28182,7 +28638,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
28182
28638
|
}
|
|
28183
28639
|
}
|
|
28184
28640
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
28185
|
-
const keys = Object.keys(data).filter((key) =>
|
|
28641
|
+
const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
28186
28642
|
if (keys.length === 0)
|
|
28187
28643
|
return;
|
|
28188
28644
|
const maxKeyWidth = Math.max(...keys.map((key) => key.length));
|
|
@@ -28198,7 +28654,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
28198
28654
|
function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
28199
28655
|
if (data.length === 0)
|
|
28200
28656
|
return;
|
|
28201
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
28657
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
28202
28658
|
if (keys.length === 0)
|
|
28203
28659
|
return;
|
|
28204
28660
|
if (!process.stdout.isTTY) {
|
|
@@ -28274,8 +28730,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
|
28274
28730
|
function toYaml(data) {
|
|
28275
28731
|
return dump(data);
|
|
28276
28732
|
}
|
|
28733
|
+
class FilterEvaluationError extends Error {
|
|
28734
|
+
__brand = "FilterEvaluationError";
|
|
28735
|
+
filter;
|
|
28736
|
+
instructions;
|
|
28737
|
+
result = RESULTS.ValidationError;
|
|
28738
|
+
constructor(filter, cause) {
|
|
28739
|
+
const underlying = cause instanceof Error ? cause.message : String(cause);
|
|
28740
|
+
super(`Filter '${filter}' failed to evaluate: ${underlying}`);
|
|
28741
|
+
this.name = "FilterEvaluationError";
|
|
28742
|
+
this.filter = filter;
|
|
28743
|
+
this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
|
|
28744
|
+
}
|
|
28745
|
+
}
|
|
28277
28746
|
function applyFilter(data, filter) {
|
|
28278
|
-
|
|
28747
|
+
let result;
|
|
28748
|
+
try {
|
|
28749
|
+
result = search(data, filter);
|
|
28750
|
+
} catch (err) {
|
|
28751
|
+
throw new FilterEvaluationError(filter, err);
|
|
28752
|
+
}
|
|
28279
28753
|
if (result == null)
|
|
28280
28754
|
return [];
|
|
28281
28755
|
if (Array.isArray(result)) {
|
|
@@ -28292,13 +28766,18 @@ function applyFilter(data, filter) {
|
|
|
28292
28766
|
}
|
|
28293
28767
|
var OutputFormatter;
|
|
28294
28768
|
((OutputFormatter) => {
|
|
28295
|
-
function success(data) {
|
|
28769
|
+
function success(data, options) {
|
|
28296
28770
|
data.Log ??= getLogFilePath() || undefined;
|
|
28771
|
+
const normalize = !options?.preserveDataKeys;
|
|
28772
|
+
if (normalize) {
|
|
28773
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
28774
|
+
}
|
|
28297
28775
|
const filter = getOutputFilter();
|
|
28298
28776
|
if (filter) {
|
|
28299
|
-
|
|
28777
|
+
const filtered = applyFilter(data.Data, filter);
|
|
28778
|
+
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
28300
28779
|
}
|
|
28301
|
-
logOutput(data, getOutputFormat());
|
|
28780
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
28302
28781
|
}
|
|
28303
28782
|
OutputFormatter.success = success;
|
|
28304
28783
|
function error(data) {
|
|
@@ -28308,7 +28787,7 @@ var OutputFormatter;
|
|
|
28308
28787
|
result: data.Result,
|
|
28309
28788
|
message: data.Message
|
|
28310
28789
|
});
|
|
28311
|
-
logOutput(data, getOutputFormat());
|
|
28790
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
28312
28791
|
}
|
|
28313
28792
|
OutputFormatter.error = error;
|
|
28314
28793
|
function emitList(code, items, opts) {
|
|
@@ -28329,13 +28808,14 @@ var OutputFormatter;
|
|
|
28329
28808
|
function log(data) {
|
|
28330
28809
|
const format = getOutputFormat();
|
|
28331
28810
|
const sink = getOutputSink();
|
|
28811
|
+
const normalized = toPascalCaseData(data);
|
|
28332
28812
|
if (format === "json") {
|
|
28333
|
-
const json2 = JSON.stringify(
|
|
28813
|
+
const json2 = JSON.stringify(normalized);
|
|
28334
28814
|
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
|
|
28335
28815
|
sink.writeErr(`${safe}
|
|
28336
28816
|
`);
|
|
28337
28817
|
} else {
|
|
28338
|
-
for (const [key, value] of Object.entries(
|
|
28818
|
+
for (const [key, value] of Object.entries(normalized)) {
|
|
28339
28819
|
sink.writeErr(`${key}: ${value}
|
|
28340
28820
|
`);
|
|
28341
28821
|
}
|
|
@@ -28344,12 +28824,16 @@ var OutputFormatter;
|
|
|
28344
28824
|
OutputFormatter.log = log;
|
|
28345
28825
|
function formatToString(data) {
|
|
28346
28826
|
const filter = getOutputFilter();
|
|
28347
|
-
if (
|
|
28348
|
-
data.Data =
|
|
28827
|
+
if ("Data" in data && data.Data != null) {
|
|
28828
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
28829
|
+
if (filter) {
|
|
28830
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
|
|
28831
|
+
}
|
|
28349
28832
|
}
|
|
28833
|
+
const output = normalizeOutputKeys(data);
|
|
28350
28834
|
const lines = [];
|
|
28351
28835
|
const sink = getOutputSink();
|
|
28352
|
-
printOutput(
|
|
28836
|
+
printOutput(output, getOutputFormat(), (msg) => {
|
|
28353
28837
|
lines.push(msg);
|
|
28354
28838
|
}, needsAsciiSafeJson(sink));
|
|
28355
28839
|
return lines.join(`
|
|
@@ -29760,6 +30244,22 @@ JSONPath.prototype.safeVm = {
|
|
|
29760
30244
|
Script: SafeScript
|
|
29761
30245
|
};
|
|
29762
30246
|
JSONPath.prototype.vm = vm;
|
|
30247
|
+
// ../../common/src/polling/types.ts
|
|
30248
|
+
var PollOutcome = {
|
|
30249
|
+
Completed: "completed",
|
|
30250
|
+
Timeout: "timeout",
|
|
30251
|
+
Interrupted: "interrupted",
|
|
30252
|
+
Aborted: "aborted",
|
|
30253
|
+
Failed: "failed"
|
|
30254
|
+
};
|
|
30255
|
+
|
|
30256
|
+
// ../../common/src/polling/poll-failure-mapping.ts
|
|
30257
|
+
var REASON_BY_OUTCOME = {
|
|
30258
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
30259
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
30260
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
30261
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
30262
|
+
};
|
|
29763
30263
|
// ../../common/src/polling/terminal-statuses.ts
|
|
29764
30264
|
var TERMINAL_STATUSES = new Set([
|
|
29765
30265
|
"completed",
|
|
@@ -29965,17 +30465,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
29965
30465
|
const telemetryName = deriveCommandPath(command);
|
|
29966
30466
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
29967
30467
|
const startTime = performance.now();
|
|
29968
|
-
let
|
|
30468
|
+
let errorMessage2;
|
|
29969
30469
|
const [error] = await catchError2(fn(...args));
|
|
29970
30470
|
if (error) {
|
|
29971
|
-
|
|
29972
|
-
logger.
|
|
30471
|
+
errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
30472
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage2}`);
|
|
30473
|
+
const typed = error;
|
|
30474
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
30475
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
30476
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
29973
30477
|
OutputFormatter.error({
|
|
29974
|
-
Result:
|
|
29975
|
-
Message:
|
|
29976
|
-
Instructions: "An unexpected error occurred. Run with --log-level debug for details."
|
|
30478
|
+
Result: finalResult,
|
|
30479
|
+
Message: errorMessage2,
|
|
30480
|
+
Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
|
|
29977
30481
|
});
|
|
29978
|
-
context.exit(
|
|
30482
|
+
context.exit(EXIT_CODES[finalResult]);
|
|
29979
30483
|
}
|
|
29980
30484
|
const durationMs = performance.now() - startTime;
|
|
29981
30485
|
const success = !error && (process.exitCode === undefined || process.exitCode === 0);
|
|
@@ -29984,7 +30488,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
29984
30488
|
...props,
|
|
29985
30489
|
duration: String(durationMs),
|
|
29986
30490
|
success: String(success),
|
|
29987
|
-
...
|
|
30491
|
+
...errorMessage2 ? { errorMessage: errorMessage2 } : {}
|
|
29988
30492
|
}));
|
|
29989
30493
|
});
|
|
29990
30494
|
};
|
|
@@ -30237,6 +30741,57 @@ class VoidApiResponse2 {
|
|
|
30237
30741
|
return;
|
|
30238
30742
|
}
|
|
30239
30743
|
}
|
|
30744
|
+
// ../identity-sdk/package.json
|
|
30745
|
+
var package_default3 = {
|
|
30746
|
+
name: "@uipath/identity-sdk",
|
|
30747
|
+
license: "MIT",
|
|
30748
|
+
version: "1.2.0",
|
|
30749
|
+
repository: {
|
|
30750
|
+
type: "git",
|
|
30751
|
+
url: "https://github.com/UiPath/cli.git",
|
|
30752
|
+
directory: "packages/admin/identity-sdk"
|
|
30753
|
+
},
|
|
30754
|
+
publishConfig: {
|
|
30755
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
30756
|
+
},
|
|
30757
|
+
keywords: [
|
|
30758
|
+
"uipath",
|
|
30759
|
+
"identity",
|
|
30760
|
+
"sdk"
|
|
30761
|
+
],
|
|
30762
|
+
type: "module",
|
|
30763
|
+
main: "./dist/index.js",
|
|
30764
|
+
types: "./dist/src/index.d.ts",
|
|
30765
|
+
exports: {
|
|
30766
|
+
".": {
|
|
30767
|
+
types: "./dist/src/index.d.ts",
|
|
30768
|
+
default: "./dist/index.js"
|
|
30769
|
+
}
|
|
30770
|
+
},
|
|
30771
|
+
files: [
|
|
30772
|
+
"dist"
|
|
30773
|
+
],
|
|
30774
|
+
private: true,
|
|
30775
|
+
scripts: {
|
|
30776
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
30777
|
+
generate: "bun run src/scripts/generate-sdk.ts",
|
|
30778
|
+
lint: "biome check .",
|
|
30779
|
+
test: "vitest run",
|
|
30780
|
+
"test:coverage": "vitest run --coverage"
|
|
30781
|
+
},
|
|
30782
|
+
devDependencies: {
|
|
30783
|
+
"@uipath/auth": "workspace:*",
|
|
30784
|
+
"@uipath/common": "workspace:*",
|
|
30785
|
+
"@uipath/filesystem": "workspace:*",
|
|
30786
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
30787
|
+
"@types/node": "^25.5.2",
|
|
30788
|
+
typescript: "^6.0.2"
|
|
30789
|
+
}
|
|
30790
|
+
};
|
|
30791
|
+
|
|
30792
|
+
// ../identity-sdk/src/user-agent.ts
|
|
30793
|
+
var SDK_USER_AGENT2 = getSdkUserAgentToken(package_default3);
|
|
30794
|
+
installSdkUserAgentHeader(BaseAPI2, SDK_USER_AGENT2);
|
|
30240
30795
|
|
|
30241
30796
|
// ../identity-sdk/generated/src/models/BulkSoftDeleteCommand.ts
|
|
30242
30797
|
function BulkSoftDeleteCommandToJSON(json2) {
|
|
@@ -30757,19 +31312,23 @@ class UserApi extends BaseAPI2 {
|
|
|
30757
31312
|
async function createIdentityConfig(options) {
|
|
30758
31313
|
const ctx = await getAuthContext({
|
|
30759
31314
|
ensureTokenValidityMinutes: options?.loginValidity,
|
|
30760
|
-
requireOrganizationId:
|
|
31315
|
+
requireOrganizationId: options?.organization === undefined,
|
|
30761
31316
|
requireTenantName: true
|
|
30762
31317
|
});
|
|
30763
|
-
const
|
|
30764
|
-
|
|
31318
|
+
const organizationId = options?.organization ?? ctx.organizationId;
|
|
31319
|
+
if (organizationId === undefined || organizationId.length === 0) {
|
|
31320
|
+
throw new Error("Organization ID not available. Provide --organization or log in with an organization context.");
|
|
31321
|
+
}
|
|
31322
|
+
const identityBasePath = `${ctx.baseUrl}/${organizationId}/identity_`;
|
|
31323
|
+
const headers = addSdkUserAgentHeader({
|
|
30765
31324
|
Authorization: `Bearer ${ctx.accessToken}`
|
|
30766
|
-
};
|
|
31325
|
+
}, SDK_USER_AGENT2);
|
|
30767
31326
|
return {
|
|
30768
31327
|
config: new Configuration2({
|
|
30769
31328
|
basePath: identityBasePath,
|
|
30770
31329
|
headers
|
|
30771
31330
|
}),
|
|
30772
|
-
organizationId
|
|
31331
|
+
organizationId
|
|
30773
31332
|
};
|
|
30774
31333
|
}
|
|
30775
31334
|
async function createApiClient2(ApiClass, options) {
|