@uipath/guardrails-tool 1.204.0-preview.254 → 1.205.0-preview.256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tool.js +141 -29
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -2101,7 +2101,7 @@ var package_default = {
|
|
|
2101
2101
|
name: "@uipath/guardrails-tool",
|
|
2102
2102
|
author: "UiPath",
|
|
2103
2103
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2104
|
-
version: "1.
|
|
2104
|
+
version: "1.205.0-preview.256",
|
|
2105
2105
|
description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
|
|
2106
2106
|
private: false,
|
|
2107
2107
|
repository: {
|
|
@@ -2320,6 +2320,16 @@ class NodeFileSystem {
|
|
|
2320
2320
|
async rename(oldPath, newPath) {
|
|
2321
2321
|
await fs.rename(oldPath, newPath);
|
|
2322
2322
|
}
|
|
2323
|
+
async isSymbolicLink(filePath) {
|
|
2324
|
+
try {
|
|
2325
|
+
return (await fs.lstat(filePath)).isSymbolicLink();
|
|
2326
|
+
} catch (error) {
|
|
2327
|
+
if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
|
|
2328
|
+
return false;
|
|
2329
|
+
}
|
|
2330
|
+
throw error;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2323
2333
|
async realpath(filePath) {
|
|
2324
2334
|
try {
|
|
2325
2335
|
return await fs.realpath(filePath);
|
|
@@ -3027,7 +3037,7 @@ function setGlobalLogFilePath(path2) {
|
|
|
3027
3037
|
function getGlobalLogFilePath() {
|
|
3028
3038
|
return logFilePathSlot.get("");
|
|
3029
3039
|
}
|
|
3030
|
-
var DEFAULT_LOG_LEVEL =
|
|
3040
|
+
var DEFAULT_LOG_LEVEL = 2 /* WARN */;
|
|
3031
3041
|
|
|
3032
3042
|
class SimpleLogger {
|
|
3033
3043
|
__brand = "SimpleLogger";
|
|
@@ -3294,7 +3304,9 @@ var ErrorDimensions = {
|
|
|
3294
3304
|
Result: "Result",
|
|
3295
3305
|
ErrorCode: "ErrorCode",
|
|
3296
3306
|
Retry: "Retry",
|
|
3297
|
-
ErrorMessage: "ErrorMessage"
|
|
3307
|
+
ErrorMessage: "ErrorMessage",
|
|
3308
|
+
HttpStatus: "HttpStatus",
|
|
3309
|
+
UpstreamErrorCode: "UpstreamErrorCode"
|
|
3298
3310
|
};
|
|
3299
3311
|
var AuthDimensions = {
|
|
3300
3312
|
AuthenticationMethod: "AuthenticationMethod",
|
|
@@ -4282,7 +4294,9 @@ var CLI_ERROR_CODES = [
|
|
|
4282
4294
|
"timeout",
|
|
4283
4295
|
"server_error",
|
|
4284
4296
|
"method_not_allowed",
|
|
4297
|
+
"not_supported",
|
|
4285
4298
|
"configuration_error",
|
|
4299
|
+
"execution_failed",
|
|
4286
4300
|
"unknown_error"
|
|
4287
4301
|
];
|
|
4288
4302
|
var RETRY_HINTS = [
|
|
@@ -5239,7 +5253,9 @@ var OutputFormatter;
|
|
|
5239
5253
|
[ErrorDimensions.Result]: data.Result,
|
|
5240
5254
|
[ErrorDimensions.ErrorCode]: data.ErrorCode,
|
|
5241
5255
|
[ErrorDimensions.Retry]: data.Retry,
|
|
5242
|
-
[ErrorDimensions.ErrorMessage]: data.Message
|
|
5256
|
+
[ErrorDimensions.ErrorMessage]: data.Message,
|
|
5257
|
+
[ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
|
|
5258
|
+
[ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
|
|
5243
5259
|
});
|
|
5244
5260
|
}
|
|
5245
5261
|
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
@@ -6223,22 +6239,12 @@ var resolveConfigAsync = async ({
|
|
|
6223
6239
|
baseUrl = DEFAULT_BASE_URL;
|
|
6224
6240
|
}
|
|
6225
6241
|
baseUrl = normalizeAndValidateBaseUrl(baseUrl);
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
clientId = fileAuth.clientId;
|
|
6229
|
-
}
|
|
6230
|
-
if (!clientId) {
|
|
6231
|
-
clientId = DEFAULT_CLIENT_ID;
|
|
6232
|
-
}
|
|
6233
|
-
let clientSecret = customClientSecret;
|
|
6234
|
-
if (!clientSecret && fileAuth.clientSecret) {
|
|
6235
|
-
clientSecret = fileAuth.clientSecret;
|
|
6236
|
-
}
|
|
6237
|
-
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
|
|
6242
|
+
const clientId = customClientId || DEFAULT_CLIENT_ID;
|
|
6243
|
+
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
|
|
6238
6244
|
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
6239
6245
|
return {
|
|
6240
6246
|
clientId,
|
|
6241
|
-
clientSecret,
|
|
6247
|
+
clientSecret: customClientSecret,
|
|
6242
6248
|
scopes,
|
|
6243
6249
|
baseUrl,
|
|
6244
6250
|
authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
|
|
@@ -6412,6 +6418,16 @@ var resolveIdentityType = (claims, authFlow, email) => {
|
|
|
6412
6418
|
}
|
|
6413
6419
|
return;
|
|
6414
6420
|
};
|
|
6421
|
+
var resolveApplicationSubtype = (claims, authFlow) => {
|
|
6422
|
+
switch (asString(claims?.sub_type)) {
|
|
6423
|
+
case "service.external":
|
|
6424
|
+
return "External";
|
|
6425
|
+
case "service.internal":
|
|
6426
|
+
return "Internal";
|
|
6427
|
+
default:
|
|
6428
|
+
return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
|
|
6429
|
+
}
|
|
6430
|
+
};
|
|
6415
6431
|
var looksLikeEmail = (value) => value?.includes("@") ?? false;
|
|
6416
6432
|
var pickEmail = (claims) => {
|
|
6417
6433
|
for (const candidate of [claims?.email, claims?.preferred_username]) {
|
|
@@ -6453,6 +6469,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
|
6453
6469
|
const clientId = asString(claims?.client_id);
|
|
6454
6470
|
if (clientId)
|
|
6455
6471
|
identity.clientId = clientId;
|
|
6472
|
+
const subType = asString(claims?.sub_type);
|
|
6473
|
+
if (subType)
|
|
6474
|
+
identity.subType = subType;
|
|
6475
|
+
const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
|
|
6476
|
+
if (applicationSubtype)
|
|
6477
|
+
identity.applicationSubtype = applicationSubtype;
|
|
6456
6478
|
return identity;
|
|
6457
6479
|
};
|
|
6458
6480
|
var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
|
|
@@ -6745,6 +6767,40 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
6745
6767
|
}
|
|
6746
6768
|
};
|
|
6747
6769
|
|
|
6770
|
+
// ../../auth/src/tenantSelection.ts
|
|
6771
|
+
var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
|
|
6772
|
+
var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
|
|
6773
|
+
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
6774
|
+
var describeNonJsonResponse = (organizationId, response, parseError) => {
|
|
6775
|
+
if (response.redirected) {
|
|
6776
|
+
return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
|
|
6777
|
+
}
|
|
6778
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
6779
|
+
return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
|
|
6780
|
+
};
|
|
6781
|
+
var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
|
|
6782
|
+
const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
|
|
6783
|
+
const response = await fetch(url, {
|
|
6784
|
+
headers: {
|
|
6785
|
+
Authorization: `Bearer ${accessToken}`
|
|
6786
|
+
},
|
|
6787
|
+
...signal ? { signal } : {}
|
|
6788
|
+
});
|
|
6789
|
+
if (!response.ok) {
|
|
6790
|
+
if (response.status === 401) {
|
|
6791
|
+
throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
|
|
6792
|
+
}
|
|
6793
|
+
const errorText = await response.text();
|
|
6794
|
+
const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
|
|
6795
|
+
throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
|
|
6796
|
+
}
|
|
6797
|
+
const [parseError, data] = await catchError2(response.json());
|
|
6798
|
+
if (parseError) {
|
|
6799
|
+
throw new Error(describeNonJsonResponse(organizationId, response, parseError));
|
|
6800
|
+
}
|
|
6801
|
+
return data;
|
|
6802
|
+
};
|
|
6803
|
+
|
|
6748
6804
|
// ../../auth/src/tokenRefresh.ts
|
|
6749
6805
|
var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
|
|
6750
6806
|
|
|
@@ -6957,6 +7013,8 @@ var saveEnvFileAsync = async ({
|
|
|
6957
7013
|
};
|
|
6958
7014
|
|
|
6959
7015
|
// ../../auth/src/loginStatus.ts
|
|
7016
|
+
var defaultRobotTenantIdCache = new Map;
|
|
7017
|
+
var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
|
|
6960
7018
|
var getLoginStatusAsync = async (options = {}) => {
|
|
6961
7019
|
return getLoginStatusWithDeps(options);
|
|
6962
7020
|
};
|
|
@@ -6969,12 +7027,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
6969
7027
|
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
6970
7028
|
resolveConfig = resolveConfigAsync,
|
|
6971
7029
|
robotFallback = tryRobotClientFallback,
|
|
7030
|
+
fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
|
|
7031
|
+
robotTenantIdCache = defaultRobotTenantIdCache,
|
|
7032
|
+
robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
|
|
6972
7033
|
loadBreaker = loadRefreshBreaker,
|
|
6973
7034
|
saveBreaker = saveRefreshBreaker,
|
|
6974
7035
|
clearBreaker = clearRefreshBreaker
|
|
6975
7036
|
} = deps;
|
|
7037
|
+
const robotDeps = {
|
|
7038
|
+
fetchTenantsAndOrgs,
|
|
7039
|
+
cache: robotTenantIdCache,
|
|
7040
|
+
lookupTimeoutMs: robotTenantLookupTimeoutMs
|
|
7041
|
+
};
|
|
6976
7042
|
if (isRobotAuthEnforced()) {
|
|
6977
|
-
return resolveRobotEnforcedStatus(robotFallback);
|
|
7043
|
+
return resolveRobotEnforcedStatus(robotFallback, robotDeps);
|
|
6978
7044
|
}
|
|
6979
7045
|
if (isEnvAuthEnabled()) {
|
|
6980
7046
|
return readAuthFromEnv();
|
|
@@ -6992,7 +7058,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
6992
7058
|
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
6993
7059
|
};
|
|
6994
7060
|
}
|
|
6995
|
-
return resolveBorrowedRobotStatus(robotFallback);
|
|
7061
|
+
return resolveBorrowedRobotStatus(robotFallback, robotDeps);
|
|
6996
7062
|
}
|
|
6997
7063
|
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
6998
7064
|
if ("status" in loaded) {
|
|
@@ -7034,7 +7100,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
7034
7100
|
}
|
|
7035
7101
|
return buildFileStatus(tokens, credentials, globalHint);
|
|
7036
7102
|
};
|
|
7037
|
-
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
7103
|
+
async function resolveRobotEnforcedStatus(robotFallback, deps) {
|
|
7038
7104
|
if (isEnvAuthEnabled()) {
|
|
7039
7105
|
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
7040
7106
|
}
|
|
@@ -7045,11 +7111,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
|
|
|
7045
7111
|
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.`
|
|
7046
7112
|
};
|
|
7047
7113
|
}
|
|
7048
|
-
return buildRobotStatus(robotCreds);
|
|
7114
|
+
return buildRobotStatus(robotCreds, deps);
|
|
7049
7115
|
}
|
|
7050
|
-
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
7116
|
+
async function resolveBorrowedRobotStatus(robotFallback, deps) {
|
|
7051
7117
|
const robotCreds = await robotFallback();
|
|
7052
|
-
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
7118
|
+
return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
|
|
7053
7119
|
}
|
|
7054
7120
|
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
7055
7121
|
let credentials;
|
|
@@ -7184,9 +7250,10 @@ function identityFields(accessToken, credentials) {
|
|
|
7184
7250
|
...scopes ? { scopes } : {}
|
|
7185
7251
|
};
|
|
7186
7252
|
}
|
|
7187
|
-
function buildRobotStatus(robotCreds) {
|
|
7253
|
+
async function buildRobotStatus(robotCreds, deps) {
|
|
7188
7254
|
const identity = resolveSessionIdentity(robotCreds.accessToken);
|
|
7189
7255
|
const scopes = readTokenScopes(robotCreds.accessToken);
|
|
7256
|
+
const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
|
|
7190
7257
|
return {
|
|
7191
7258
|
loginStatus: "Logged in",
|
|
7192
7259
|
accessToken: robotCreds.accessToken,
|
|
@@ -7194,14 +7261,62 @@ function buildRobotStatus(robotCreds) {
|
|
|
7194
7261
|
organizationName: robotCreds.organizationName,
|
|
7195
7262
|
organizationId: robotCreds.organizationId,
|
|
7196
7263
|
tenantName: robotCreds.tenantName,
|
|
7197
|
-
tenantId:
|
|
7264
|
+
tenantId: tenant.tenantId,
|
|
7198
7265
|
issuer: robotCreds.issuer,
|
|
7199
7266
|
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
7200
7267
|
source: "robot" /* Robot */,
|
|
7268
|
+
...tenant.hint ? { hint: tenant.hint } : {},
|
|
7201
7269
|
...identity ? { identity } : {},
|
|
7202
7270
|
...scopes ? { scopes } : {}
|
|
7203
7271
|
};
|
|
7204
7272
|
}
|
|
7273
|
+
async function resolveRobotTenantId(robotCreds, deps) {
|
|
7274
|
+
const { baseUrl, accessToken, tenantName } = robotCreds;
|
|
7275
|
+
const organization = robotCreds.organizationName ?? robotCreds.organizationId;
|
|
7276
|
+
if (!tenantName || !organization) {
|
|
7277
|
+
return {};
|
|
7278
|
+
}
|
|
7279
|
+
const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
|
|
7280
|
+
let pending = deps.cache.get(key);
|
|
7281
|
+
if (!pending) {
|
|
7282
|
+
pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
|
|
7283
|
+
const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
|
|
7284
|
+
if (!settled.tenantId) {
|
|
7285
|
+
deps.cache.delete(key);
|
|
7286
|
+
}
|
|
7287
|
+
return settled;
|
|
7288
|
+
});
|
|
7289
|
+
deps.cache.set(key, pending);
|
|
7290
|
+
}
|
|
7291
|
+
return pending;
|
|
7292
|
+
}
|
|
7293
|
+
async function lookupRobotTenantId(target, deps) {
|
|
7294
|
+
const { baseUrl, accessToken, organization, tenantName } = target;
|
|
7295
|
+
const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
|
|
7296
|
+
if (error) {
|
|
7297
|
+
const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
|
|
7298
|
+
return { hint: tenantLookupFailureHint(tenantName, reason) };
|
|
7299
|
+
}
|
|
7300
|
+
const rows = data?.tenants;
|
|
7301
|
+
const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
|
|
7302
|
+
const wantedName = decodePathSegment(tenantName);
|
|
7303
|
+
const wanted = wantedName.toLowerCase();
|
|
7304
|
+
const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
|
|
7305
|
+
if (!match) {
|
|
7306
|
+
const names = tenants.map((tenant) => tenant.name).join(", ");
|
|
7307
|
+
return {
|
|
7308
|
+
hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
|
|
7309
|
+
};
|
|
7310
|
+
}
|
|
7311
|
+
return { tenantId: match.id };
|
|
7312
|
+
}
|
|
7313
|
+
function tenantLookupFailureHint(tenantName, reason) {
|
|
7314
|
+
return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
|
|
7315
|
+
}
|
|
7316
|
+
function decodePathSegment(segment) {
|
|
7317
|
+
const [error, decoded] = catchError2(() => decodeURIComponent(segment));
|
|
7318
|
+
return error ? segment : decoded;
|
|
7319
|
+
}
|
|
7205
7320
|
var isFileNotFoundError = (error) => {
|
|
7206
7321
|
if (!(error instanceof Object))
|
|
7207
7322
|
return false;
|
|
@@ -7470,9 +7585,6 @@ var getAuthContext = async (options = {}) => {
|
|
|
7470
7585
|
identity: status.identity
|
|
7471
7586
|
};
|
|
7472
7587
|
};
|
|
7473
|
-
// ../../auth/src/tenantSelection.ts
|
|
7474
|
-
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
7475
|
-
|
|
7476
7588
|
// ../../auth/src/selectTenant.ts
|
|
7477
7589
|
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
7478
7590
|
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
@@ -7984,4 +8096,4 @@ export {
|
|
|
7984
8096
|
registerCommands
|
|
7985
8097
|
};
|
|
7986
8098
|
|
|
7987
|
-
//# debugId=
|
|
8099
|
+
//# debugId=5E739DF5BE182D9E64756E2164756E21
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/guardrails-tool",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.205.0-preview.256",
|
|
6
6
|
"description": "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
|
|
7
7
|
"private": false,
|
|
8
8
|
"repository": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "63740c6cbb7ff282fa9118cc16a148eb030b245f"
|
|
28
28
|
}
|