@uipath/aops-policy-sdk 1.205.0-preview.277 → 1.206.0-preview.279
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 +197 -112
- package/dist/policy-resolver.js +1 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
15
12
|
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
13
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
14
|
|
|
19
15
|
// ../../auth/src/catch-error.ts
|
|
@@ -400,12 +396,6 @@ var init_is_in_ssh = __esm(() => {
|
|
|
400
396
|
});
|
|
401
397
|
|
|
402
398
|
// ../../../node_modules/open/index.js
|
|
403
|
-
var exports_open = {};
|
|
404
|
-
__export(exports_open, {
|
|
405
|
-
apps: () => apps,
|
|
406
|
-
default: () => open_default,
|
|
407
|
-
openApp: () => openApp
|
|
408
|
-
});
|
|
409
399
|
import process8 from "node:process";
|
|
410
400
|
import path from "node:path";
|
|
411
401
|
import { fileURLToPath } from "node:url";
|
|
@@ -639,21 +629,6 @@ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEach
|
|
|
639
629
|
...options,
|
|
640
630
|
target
|
|
641
631
|
});
|
|
642
|
-
}, openApp = (name, options) => {
|
|
643
|
-
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
644
|
-
throw new TypeError("Expected a valid `name`");
|
|
645
|
-
}
|
|
646
|
-
const { arguments: appArguments = [] } = options ?? {};
|
|
647
|
-
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
|
648
|
-
throw new TypeError("Expected `appArguments` as Array type");
|
|
649
|
-
}
|
|
650
|
-
return baseOpen({
|
|
651
|
-
...options,
|
|
652
|
-
app: {
|
|
653
|
-
name,
|
|
654
|
-
arguments: appArguments
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
632
|
}, apps, open_default;
|
|
658
633
|
var init_open = __esm(() => {
|
|
659
634
|
init_wsl_utils();
|
|
@@ -710,7 +685,7 @@ var init_open = __esm(() => {
|
|
|
710
685
|
});
|
|
711
686
|
|
|
712
687
|
// ../../filesystem/src/node.ts
|
|
713
|
-
import { randomUUID } from "node:crypto";
|
|
688
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
714
689
|
import { existsSync } from "node:fs";
|
|
715
690
|
import * as fs6 from "node:fs/promises";
|
|
716
691
|
import * as os2 from "node:os";
|
|
@@ -733,16 +708,16 @@ class NodeFileSystem {
|
|
|
733
708
|
};
|
|
734
709
|
utils = {
|
|
735
710
|
open: async (url) => {
|
|
736
|
-
|
|
737
|
-
await
|
|
711
|
+
await Promise.resolve().then(() => init_open());
|
|
712
|
+
await open_default(url);
|
|
738
713
|
}
|
|
739
714
|
};
|
|
740
|
-
async readFile(
|
|
715
|
+
async readFile(path, options) {
|
|
741
716
|
try {
|
|
742
717
|
if (options) {
|
|
743
|
-
return await fs6.readFile(
|
|
718
|
+
return await fs6.readFile(path, "utf-8");
|
|
744
719
|
}
|
|
745
|
-
return await fs6.readFile(
|
|
720
|
+
return await fs6.readFile(path);
|
|
746
721
|
} catch (error) {
|
|
747
722
|
if (this.isEnoent(error))
|
|
748
723
|
return null;
|
|
@@ -772,6 +747,15 @@ class NodeFileSystem {
|
|
|
772
747
|
throw error;
|
|
773
748
|
}
|
|
774
749
|
}
|
|
750
|
+
async readdirEntries(dirPath) {
|
|
751
|
+
try {
|
|
752
|
+
return await fs6.readdir(dirPath, { withFileTypes: true });
|
|
753
|
+
} catch (error) {
|
|
754
|
+
if (this.isEnoent(error))
|
|
755
|
+
return [];
|
|
756
|
+
throw error;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
775
759
|
async stat(filePath) {
|
|
776
760
|
try {
|
|
777
761
|
const stats = await fs6.stat(filePath);
|
|
@@ -779,7 +763,8 @@ class NodeFileSystem {
|
|
|
779
763
|
isFile: () => stats.isFile(),
|
|
780
764
|
isDirectory: () => stats.isDirectory(),
|
|
781
765
|
size: stats.size,
|
|
782
|
-
mtimeMs: stats.mtimeMs
|
|
766
|
+
mtimeMs: stats.mtimeMs,
|
|
767
|
+
ctimeMs: stats.ctimeMs
|
|
783
768
|
};
|
|
784
769
|
} catch (error) {
|
|
785
770
|
if (this.isEnoent(error))
|
|
@@ -893,6 +878,42 @@ class NodeFileSystem {
|
|
|
893
878
|
throw error;
|
|
894
879
|
}
|
|
895
880
|
}
|
|
881
|
+
async hashFile(filePath) {
|
|
882
|
+
let handle;
|
|
883
|
+
try {
|
|
884
|
+
handle = await fs6.open(filePath, "r");
|
|
885
|
+
} catch (error) {
|
|
886
|
+
if (this.isEnoent(error))
|
|
887
|
+
return null;
|
|
888
|
+
throw error;
|
|
889
|
+
}
|
|
890
|
+
const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
|
|
891
|
+
try {
|
|
892
|
+
const opened = await handle.stat();
|
|
893
|
+
const stats = {
|
|
894
|
+
isFile: () => opened.isFile(),
|
|
895
|
+
isDirectory: () => opened.isDirectory(),
|
|
896
|
+
size: opened.size,
|
|
897
|
+
mtimeMs: opened.mtimeMs,
|
|
898
|
+
ctimeMs: opened.ctimeMs
|
|
899
|
+
};
|
|
900
|
+
const hash = createHash("sha256");
|
|
901
|
+
let size = 0;
|
|
902
|
+
for (;; ) {
|
|
903
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
|
|
904
|
+
if (bytesRead === 0)
|
|
905
|
+
break;
|
|
906
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
907
|
+
size += bytesRead;
|
|
908
|
+
}
|
|
909
|
+
return { sha256: hash.digest("hex"), size, stats };
|
|
910
|
+
} finally {
|
|
911
|
+
if (hashBuffers.length < HASH_BUFFERS_KEPT) {
|
|
912
|
+
hashBuffers.push(buffer);
|
|
913
|
+
}
|
|
914
|
+
await handle.close();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
896
917
|
async realpath(filePath) {
|
|
897
918
|
try {
|
|
898
919
|
return await fs6.realpath(filePath);
|
|
@@ -938,8 +959,11 @@ class NodeFileSystem {
|
|
|
938
959
|
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
939
960
|
}
|
|
940
961
|
}
|
|
941
|
-
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;
|
|
942
|
-
var init_node = () => {
|
|
962
|
+
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, HASH_CHUNK_BYTES, hashBuffers, HASH_BUFFERS_KEPT = 64;
|
|
963
|
+
var init_node = __esm(() => {
|
|
964
|
+
HASH_CHUNK_BYTES = 256 * 1024;
|
|
965
|
+
hashBuffers = [];
|
|
966
|
+
});
|
|
943
967
|
// ../../filesystem/src/index.ts
|
|
944
968
|
var fsInstance, getFileSystem = () => fsInstance;
|
|
945
969
|
var init_src = __esm(() => {
|
|
@@ -1016,6 +1040,21 @@ var CommandDimensions = {
|
|
|
1016
1040
|
ProductArea: "ProductArea",
|
|
1017
1041
|
Mode: "Mode"
|
|
1018
1042
|
};
|
|
1043
|
+
var ProjectDimensions = {
|
|
1044
|
+
ProjectKey: "ProjectKey",
|
|
1045
|
+
ProjectType: "ProjectType",
|
|
1046
|
+
ProjectIdentityStatus: "ProjectIdentityStatus",
|
|
1047
|
+
SolutionKey: "SolutionKey",
|
|
1048
|
+
SolutionProjectKey: "SolutionProjectKey",
|
|
1049
|
+
SolutionIdentityStatus: "SolutionIdentityStatus",
|
|
1050
|
+
PreviousSolutionKey: "PreviousSolutionKey"
|
|
1051
|
+
};
|
|
1052
|
+
var GUID_KEY_DIMENSIONS = new Set([
|
|
1053
|
+
ProjectDimensions.ProjectKey,
|
|
1054
|
+
ProjectDimensions.SolutionKey,
|
|
1055
|
+
ProjectDimensions.SolutionProjectKey,
|
|
1056
|
+
ProjectDimensions.PreviousSolutionKey
|
|
1057
|
+
]);
|
|
1019
1058
|
var ShipDimensions = {
|
|
1020
1059
|
ShipKind: "ShipKind",
|
|
1021
1060
|
Target: "Target",
|
|
@@ -1083,6 +1122,7 @@ var RESERVED_DIMENSION_NAMES = new Set([
|
|
|
1083
1122
|
...Object.values(BaseDimensions),
|
|
1084
1123
|
...Object.values(CommandDimensions),
|
|
1085
1124
|
...Object.values(ShipDimensions),
|
|
1125
|
+
...Object.values(ProjectDimensions),
|
|
1086
1126
|
...Object.values(ErrorDimensions),
|
|
1087
1127
|
...Object.values(AuthDimensions),
|
|
1088
1128
|
...Object.values(SkillsDimensions),
|
|
@@ -1108,7 +1148,8 @@ var CURATED_DIMENSIONS = new Set([
|
|
|
1108
1148
|
BaseDimensions.SessionIdSource,
|
|
1109
1149
|
BaseDimensions.SessionId,
|
|
1110
1150
|
...Object.values(CommandDimensions),
|
|
1111
|
-
...Object.values(ShipDimensions)
|
|
1151
|
+
...Object.values(ShipDimensions),
|
|
1152
|
+
...Object.values(ProjectDimensions)
|
|
1112
1153
|
]);
|
|
1113
1154
|
|
|
1114
1155
|
// ../../common/src/sdk-user-agent.ts
|
|
@@ -1487,7 +1528,7 @@ var package_default = {
|
|
|
1487
1528
|
name: "@uipath/aops-policy-sdk",
|
|
1488
1529
|
author: "UiPath",
|
|
1489
1530
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
1490
|
-
version: "1.
|
|
1531
|
+
version: "1.206.0-preview.279",
|
|
1491
1532
|
description: "SDK for the UiPath AOps Governance API — policy management and deployment.",
|
|
1492
1533
|
repository: {
|
|
1493
1534
|
type: "git",
|
|
@@ -7099,8 +7140,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
7099
7140
|
if (normalized === undefined) {
|
|
7100
7141
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
7101
7142
|
}
|
|
7102
|
-
const
|
|
7103
|
-
return
|
|
7143
|
+
const fs = getFileSystem();
|
|
7144
|
+
return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
7104
7145
|
}
|
|
7105
7146
|
function getActiveAuthProfileFilePath() {
|
|
7106
7147
|
const profile = getActiveAuthProfile();
|
|
@@ -7272,6 +7313,8 @@ var ENV_AUTH_VARS = {
|
|
|
7272
7313
|
};
|
|
7273
7314
|
|
|
7274
7315
|
class EnvAuthConfigError extends Error {
|
|
7316
|
+
errorCode = "configuration_error";
|
|
7317
|
+
retry = "RetryWillNotFix";
|
|
7275
7318
|
constructor(message) {
|
|
7276
7319
|
super(message);
|
|
7277
7320
|
this.name = "EnvAuthConfigError";
|
|
@@ -7310,11 +7353,11 @@ var readAuthFromEnv = () => {
|
|
|
7310
7353
|
if (!rawUrl) {
|
|
7311
7354
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
|
|
7312
7355
|
}
|
|
7313
|
-
const
|
|
7356
|
+
const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
7314
7357
|
return {
|
|
7315
7358
|
loginStatus: "Logged in",
|
|
7316
7359
|
accessToken,
|
|
7317
|
-
baseUrl
|
|
7360
|
+
baseUrl,
|
|
7318
7361
|
organizationName,
|
|
7319
7362
|
organizationId,
|
|
7320
7363
|
tenantName,
|
|
@@ -7366,9 +7409,9 @@ function breakerPathFor(authPath) {
|
|
|
7366
7409
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
7367
7410
|
}
|
|
7368
7411
|
async function loadRefreshBreaker(authPath) {
|
|
7369
|
-
const
|
|
7412
|
+
const fs = getFileSystem();
|
|
7370
7413
|
try {
|
|
7371
|
-
const content = await
|
|
7414
|
+
const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
|
|
7372
7415
|
if (!content)
|
|
7373
7416
|
return {};
|
|
7374
7417
|
const parsed = JSON.parse(content);
|
|
@@ -7379,20 +7422,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
7379
7422
|
}
|
|
7380
7423
|
async function saveRefreshBreaker(authPath, state) {
|
|
7381
7424
|
try {
|
|
7382
|
-
const
|
|
7383
|
-
const
|
|
7384
|
-
await
|
|
7385
|
-
const tempPath = `${
|
|
7386
|
-
await
|
|
7387
|
-
await
|
|
7425
|
+
const fs = getFileSystem();
|
|
7426
|
+
const path = breakerPathFor(authPath);
|
|
7427
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
7428
|
+
const tempPath = `${path}.tmp`;
|
|
7429
|
+
await fs.writeFile(tempPath, JSON.stringify(state));
|
|
7430
|
+
await fs.rename(tempPath, path);
|
|
7388
7431
|
} catch {}
|
|
7389
7432
|
}
|
|
7390
7433
|
async function clearRefreshBreaker(authPath) {
|
|
7391
|
-
const
|
|
7392
|
-
const
|
|
7434
|
+
const fs = getFileSystem();
|
|
7435
|
+
const path = breakerPathFor(authPath);
|
|
7393
7436
|
try {
|
|
7394
|
-
if (await
|
|
7395
|
-
await
|
|
7437
|
+
if (await fs.exists(path)) {
|
|
7438
|
+
await fs.rm(path);
|
|
7396
7439
|
}
|
|
7397
7440
|
} catch {}
|
|
7398
7441
|
}
|
|
@@ -7414,13 +7457,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
7414
7457
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
7415
7458
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
7416
7459
|
var getRobotIpcPipeNames = async () => {
|
|
7417
|
-
const
|
|
7418
|
-
const username =
|
|
7460
|
+
const fs = getFileSystem();
|
|
7461
|
+
const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
|
|
7419
7462
|
if (!username) {
|
|
7420
7463
|
throw new Error("Unable to determine current username");
|
|
7421
7464
|
}
|
|
7422
|
-
const tempPath =
|
|
7423
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
7465
|
+
const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
|
|
7466
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
7424
7467
|
};
|
|
7425
7468
|
var defaultIsRobotIpcAvailable = async () => {
|
|
7426
7469
|
if (process.platform === "win32") {
|
|
@@ -7430,20 +7473,20 @@ var defaultIsRobotIpcAvailable = async () => {
|
|
|
7430
7473
|
if (pipeNamesError || !pipeNames) {
|
|
7431
7474
|
return false;
|
|
7432
7475
|
}
|
|
7433
|
-
const
|
|
7476
|
+
const fs = getFileSystem();
|
|
7434
7477
|
for (const pipeName of pipeNames) {
|
|
7435
|
-
const [existsError,
|
|
7436
|
-
if (!existsError &&
|
|
7478
|
+
const [existsError, exists] = await catchError(fs.exists(pipeName));
|
|
7479
|
+
if (!existsError && exists === true) {
|
|
7437
7480
|
return true;
|
|
7438
7481
|
}
|
|
7439
7482
|
}
|
|
7440
7483
|
return false;
|
|
7441
7484
|
};
|
|
7442
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
7485
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
|
|
7443
7486
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
7444
7487
|
promise.then((value) => {
|
|
7445
7488
|
clearTimeout(timer);
|
|
7446
|
-
|
|
7489
|
+
resolve(value);
|
|
7447
7490
|
}, (error) => {
|
|
7448
7491
|
clearTimeout(timer);
|
|
7449
7492
|
reject(error);
|
|
@@ -7616,9 +7659,12 @@ var refreshAccessToken = async ({
|
|
|
7616
7659
|
body: tokenParams
|
|
7617
7660
|
});
|
|
7618
7661
|
const tokenData = await tokenResponse.json();
|
|
7619
|
-
if (
|
|
7662
|
+
if (tokenResponse.status === 400 || tokenResponse.status === 401) {
|
|
7620
7663
|
throw new TokenRefreshOAuthError;
|
|
7621
7664
|
}
|
|
7665
|
+
if (!tokenResponse.ok) {
|
|
7666
|
+
throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
|
|
7667
|
+
}
|
|
7622
7668
|
const newAccessToken = tokenData.access_token;
|
|
7623
7669
|
const newRefreshToken = tokenData.refresh_token;
|
|
7624
7670
|
if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
|
|
@@ -7652,9 +7698,9 @@ var errorCode = (err) => {
|
|
|
7652
7698
|
}
|
|
7653
7699
|
return "EUNKNOWN";
|
|
7654
7700
|
};
|
|
7655
|
-
var probeAsync = async (
|
|
7701
|
+
var probeAsync = async (fs, candidate) => {
|
|
7656
7702
|
try {
|
|
7657
|
-
const stats = await
|
|
7703
|
+
const stats = await fs.stat(candidate);
|
|
7658
7704
|
if (stats === null) {
|
|
7659
7705
|
return { exists: false };
|
|
7660
7706
|
}
|
|
@@ -7681,36 +7727,36 @@ var probeAsync = async (fs7, candidate) => {
|
|
|
7681
7727
|
}
|
|
7682
7728
|
};
|
|
7683
7729
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
7684
|
-
const
|
|
7685
|
-
if (
|
|
7686
|
-
const
|
|
7687
|
-
return
|
|
7730
|
+
const fs = getFileSystem();
|
|
7731
|
+
if (fs.path.isAbsolute(envFilePath)) {
|
|
7732
|
+
const probe = await probeAsync(fs, envFilePath);
|
|
7733
|
+
return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
7688
7734
|
exists: false,
|
|
7689
7735
|
absolutePath: envFilePath,
|
|
7690
7736
|
source: "absolute",
|
|
7691
|
-
...
|
|
7737
|
+
...probe.unusable ? { unusable: probe.unusable } : {}
|
|
7692
7738
|
};
|
|
7693
7739
|
}
|
|
7694
|
-
const cwd = opts?.cwd ??
|
|
7740
|
+
const cwd = opts?.cwd ?? fs.env.cwd();
|
|
7695
7741
|
let searchDir = cwd;
|
|
7696
7742
|
while (true) {
|
|
7697
|
-
const candidate =
|
|
7698
|
-
const
|
|
7699
|
-
if (
|
|
7743
|
+
const candidate = fs.path.join(searchDir, envFilePath);
|
|
7744
|
+
const probe = await probeAsync(fs, candidate);
|
|
7745
|
+
if (probe.exists) {
|
|
7700
7746
|
return {
|
|
7701
7747
|
exists: true,
|
|
7702
7748
|
absolutePath: candidate,
|
|
7703
7749
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
7704
7750
|
};
|
|
7705
7751
|
}
|
|
7706
|
-
const parentDir =
|
|
7752
|
+
const parentDir = fs.path.dirname(searchDir);
|
|
7707
7753
|
if (parentDir === searchDir) {
|
|
7708
7754
|
break;
|
|
7709
7755
|
}
|
|
7710
7756
|
searchDir = parentDir;
|
|
7711
7757
|
}
|
|
7712
|
-
const homePath =
|
|
7713
|
-
const probe = await probeAsync(
|
|
7758
|
+
const homePath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7759
|
+
const probe = await probeAsync(fs, homePath);
|
|
7714
7760
|
if (probe.exists) {
|
|
7715
7761
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
7716
7762
|
}
|
|
@@ -7753,12 +7799,12 @@ var parseEnvContent = (content) => {
|
|
|
7753
7799
|
return env;
|
|
7754
7800
|
};
|
|
7755
7801
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
7756
|
-
const
|
|
7757
|
-
const absolutePath =
|
|
7758
|
-
if (!await
|
|
7802
|
+
const fs = getFileSystem();
|
|
7803
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
|
|
7804
|
+
if (!await fs.exists(absolutePath)) {
|
|
7759
7805
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
7760
7806
|
}
|
|
7761
|
-
const content = await
|
|
7807
|
+
const content = await fs.readFile(absolutePath, "utf-8");
|
|
7762
7808
|
if (content === null) {
|
|
7763
7809
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
7764
7810
|
}
|
|
@@ -7769,10 +7815,10 @@ var saveEnvFileAsync = async ({
|
|
|
7769
7815
|
data,
|
|
7770
7816
|
merge = true
|
|
7771
7817
|
}) => {
|
|
7772
|
-
const
|
|
7773
|
-
const absolutePath =
|
|
7818
|
+
const fs = getFileSystem();
|
|
7819
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
|
|
7774
7820
|
let existingData = {};
|
|
7775
|
-
if (merge && await
|
|
7821
|
+
if (merge && await fs.exists(absolutePath)) {
|
|
7776
7822
|
try {
|
|
7777
7823
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
7778
7824
|
} catch {}
|
|
@@ -7790,11 +7836,11 @@ var saveEnvFileAsync = async ({
|
|
|
7790
7836
|
const content = `${lines.join(`
|
|
7791
7837
|
`)}
|
|
7792
7838
|
`;
|
|
7793
|
-
const dir =
|
|
7794
|
-
await
|
|
7839
|
+
const dir = fs.path.dirname(absolutePath);
|
|
7840
|
+
await fs.mkdir(dir);
|
|
7795
7841
|
const tempPath = `${absolutePath}.tmp`;
|
|
7796
|
-
await
|
|
7797
|
-
await
|
|
7842
|
+
await fs.writeFile(tempPath, content);
|
|
7843
|
+
await fs.rename(tempPath, absolutePath);
|
|
7798
7844
|
};
|
|
7799
7845
|
|
|
7800
7846
|
// ../../auth/src/loginStatus.ts
|
|
@@ -7918,11 +7964,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
7918
7964
|
return { credentials };
|
|
7919
7965
|
}
|
|
7920
7966
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
7921
|
-
const
|
|
7922
|
-
const globalPath =
|
|
7967
|
+
const fs = getFs();
|
|
7968
|
+
const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7923
7969
|
if (absolutePath === globalPath)
|
|
7924
7970
|
return;
|
|
7925
|
-
if (!await
|
|
7971
|
+
if (!await fs.exists(globalPath))
|
|
7926
7972
|
return;
|
|
7927
7973
|
try {
|
|
7928
7974
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -8337,6 +8383,51 @@ function normalizeTokenRefreshUnavailableFailure() {
|
|
|
8337
8383
|
function errorMessage(error) {
|
|
8338
8384
|
return error instanceof Error ? error.message : String(error);
|
|
8339
8385
|
}
|
|
8386
|
+
|
|
8387
|
+
// ../../auth/src/authContext.ts
|
|
8388
|
+
class AuthContextUnavailableError extends Error {
|
|
8389
|
+
instructionContext;
|
|
8390
|
+
sessionHint;
|
|
8391
|
+
errorCode = "authentication_required";
|
|
8392
|
+
retry = "RetryWillNotFix";
|
|
8393
|
+
constructor(message, instructionContext = "auth", sessionHint) {
|
|
8394
|
+
super(message);
|
|
8395
|
+
this.instructionContext = instructionContext;
|
|
8396
|
+
this.sessionHint = sessionHint;
|
|
8397
|
+
this.name = "AuthContextUnavailableError";
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
8400
|
+
var getAuthContext = async (options = {}) => {
|
|
8401
|
+
const status = await getLoginStatusAsync({
|
|
8402
|
+
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
8403
|
+
envFilePath: options.envFilePath
|
|
8404
|
+
});
|
|
8405
|
+
if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
|
|
8406
|
+
throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
|
|
8407
|
+
}
|
|
8408
|
+
const tenantName = options.tenant || status.tenantName;
|
|
8409
|
+
if (options.requireOrganizationId && !status.organizationId) {
|
|
8410
|
+
throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
|
|
8411
|
+
}
|
|
8412
|
+
if (options.requireOrganizationName && !status.organizationName) {
|
|
8413
|
+
throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
|
|
8414
|
+
}
|
|
8415
|
+
if (options.requireTenantId && !status.tenantId) {
|
|
8416
|
+
throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
|
|
8417
|
+
}
|
|
8418
|
+
if (options.requireTenantName && !tenantName) {
|
|
8419
|
+
throw new AuthContextUnavailableError("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.", "identity");
|
|
8420
|
+
}
|
|
8421
|
+
return {
|
|
8422
|
+
baseUrl: status.baseUrl,
|
|
8423
|
+
accessToken: status.accessToken,
|
|
8424
|
+
organizationId: status.organizationId,
|
|
8425
|
+
organizationName: status.organizationName,
|
|
8426
|
+
tenantId: status.tenantId,
|
|
8427
|
+
tenantName,
|
|
8428
|
+
identity: status.identity
|
|
8429
|
+
};
|
|
8430
|
+
};
|
|
8340
8431
|
// ../../auth/src/authProfileDetails.ts
|
|
8341
8432
|
init_src();
|
|
8342
8433
|
// ../../auth/src/index.ts
|
|
@@ -8357,18 +8448,12 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
8357
8448
|
init_src();
|
|
8358
8449
|
// src/client-factory.ts
|
|
8359
8450
|
async function createGovernanceConfig(options) {
|
|
8360
|
-
const
|
|
8361
|
-
ensureTokenValidityMinutes: options?.loginValidity
|
|
8451
|
+
const auth = await getAuthContext({
|
|
8452
|
+
ensureTokenValidityMinutes: options?.loginValidity,
|
|
8453
|
+
requireOrganizationId: true
|
|
8362
8454
|
});
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
throw new Error(message);
|
|
8366
|
-
}
|
|
8367
|
-
if (!status.organizationId) {
|
|
8368
|
-
throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
|
|
8369
|
-
}
|
|
8370
|
-
const basePath = `${status.baseUrl}/${status.organizationId}/roboticsops_`;
|
|
8371
|
-
const bearerToken = options?.s2sToken ?? status.accessToken;
|
|
8455
|
+
const basePath = `${auth.baseUrl}/${encodeURIComponent(auth.organizationId)}/roboticsops_`;
|
|
8456
|
+
const bearerToken = options?.s2sToken ?? auth.accessToken;
|
|
8372
8457
|
return new Configuration({
|
|
8373
8458
|
basePath,
|
|
8374
8459
|
apiKey: () => `Bearer ${bearerToken}`,
|
|
@@ -8791,4 +8876,4 @@ export {
|
|
|
8791
8876
|
querystring
|
|
8792
8877
|
};
|
|
8793
8878
|
|
|
8794
|
-
//# debugId=
|
|
8879
|
+
//# debugId=3D588E8D38776E8564756E2164756E21
|
package/dist/policy-resolver.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
-
|
|
19
1
|
// generated/src/runtime.ts
|
|
20
2
|
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
21
3
|
|
|
@@ -1984,4 +1966,4 @@ export {
|
|
|
1984
1966
|
resolvePolicyAsync
|
|
1985
1967
|
};
|
|
1986
1968
|
|
|
1987
|
-
//# debugId=
|
|
1969
|
+
//# debugId=480264F18D5EE75E64756E2164756E21
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/aops-policy-sdk",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.206.0-preview.279",
|
|
6
6
|
"description": "SDK for the UiPath AOps Governance API — policy management and deployment.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"private": false,
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "d2176feff38d4e91a9d84723af847b2dfd5c6008"
|
|
39
39
|
}
|