@uipath/guardrails-tool 1.206.0-preview.312 → 1.206.0-preview.323

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.
Files changed (2) hide show
  1. package/dist/tool.js +73 -11
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -2082,7 +2082,7 @@ var package_default = {
2082
2082
  name: "@uipath/guardrails-tool",
2083
2083
  author: "UiPath",
2084
2084
  license: "SEE LICENSE IN LICENSE.txt",
2085
- version: "1.206.0-preview.312",
2085
+ version: "1.206.0-preview.323",
2086
2086
  description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
2087
2087
  private: false,
2088
2088
  repository: {
@@ -2170,12 +2170,26 @@ class NodeFileSystem {
2170
2170
  throw error;
2171
2171
  }
2172
2172
  }
2173
- async writeFile(filePath, data) {
2173
+ async writeFile(filePath, data, options) {
2174
2174
  const dir = path.dirname(filePath);
2175
2175
  if (dir) {
2176
2176
  await fs.mkdir(dir, { recursive: true });
2177
2177
  }
2178
- await fs.writeFile(filePath, data);
2178
+ if (options?.mode === undefined || process.platform === "win32") {
2179
+ if (options?.exclusive) {
2180
+ await fs.writeFile(filePath, data, { flag: "wx" });
2181
+ } else {
2182
+ await fs.writeFile(filePath, data);
2183
+ }
2184
+ return;
2185
+ }
2186
+ const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
2187
+ try {
2188
+ await handle.chmod(options.mode);
2189
+ await handle.writeFile(data);
2190
+ } finally {
2191
+ await handle.close();
2192
+ }
2179
2193
  }
2180
2194
  async appendFile(filePath, data) {
2181
2195
  const dir = path.dirname(filePath);
@@ -2210,7 +2224,8 @@ class NodeFileSystem {
2210
2224
  isDirectory: () => stats.isDirectory(),
2211
2225
  size: stats.size,
2212
2226
  mtimeMs: stats.mtimeMs,
2213
- ctimeMs: stats.ctimeMs
2227
+ ctimeMs: stats.ctimeMs,
2228
+ mode: stats.mode
2214
2229
  };
2215
2230
  } catch (error) {
2216
2231
  if (this.isEnoent(error))
@@ -2221,8 +2236,13 @@ class NodeFileSystem {
2221
2236
  async exists(filePath) {
2222
2237
  return existsSync(filePath);
2223
2238
  }
2224
- async mkdir(dirPath) {
2225
- await fs.mkdir(dirPath, { recursive: true });
2239
+ async mkdir(dirPath, options) {
2240
+ await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
2241
+ }
2242
+ async chmod(targetPath, mode) {
2243
+ if (process.platform === "win32")
2244
+ return;
2245
+ await fs.chmod(targetPath, mode);
2226
2246
  }
2227
2247
  async acquireLock(lockPath) {
2228
2248
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -6961,6 +6981,8 @@ function settlePromiseLike2(thenable) {
6961
6981
  // ../../auth/src/constants.ts
6962
6982
  var UIPATH_HOME_DIR = ".uipath";
6963
6983
  var AUTH_FILENAME = ".auth";
6984
+ var AUTH_FILE_MODE = 384;
6985
+ var AUTH_DIR_MODE = 448;
6964
6986
  var DEFAULT_BASE_URL = "https://cloud.uipath.com";
6965
6987
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
6966
6988
 
@@ -7784,6 +7806,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
7784
7806
  }
7785
7807
  return parseEnvContent(content);
7786
7808
  };
7809
+ var findAuthHomeDir = (fs, dir) => {
7810
+ let current = dir;
7811
+ for (;; ) {
7812
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
7813
+ return current;
7814
+ const parent = fs.path.dirname(current);
7815
+ if (parent === current)
7816
+ return;
7817
+ current = parent;
7818
+ }
7819
+ };
7820
+ var TEMP_FILE_ATTEMPTS = 5;
7821
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
7822
+ var writeTempFile = async (fs, targetPath, content) => {
7823
+ for (let attempt = 1;; attempt++) {
7824
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
7825
+ try {
7826
+ await fs.writeFile(tempPath, content, {
7827
+ mode: AUTH_FILE_MODE,
7828
+ exclusive: true
7829
+ });
7830
+ return tempPath;
7831
+ } catch (error) {
7832
+ if (!isFileExists(error)) {
7833
+ await fs.rm(tempPath).catch(() => {});
7834
+ throw error;
7835
+ }
7836
+ if (attempt === TEMP_FILE_ATTEMPTS)
7837
+ throw error;
7838
+ }
7839
+ }
7840
+ };
7787
7841
  var saveEnvFileAsync = async ({
7788
7842
  envPath,
7789
7843
  data,
@@ -7811,10 +7865,18 @@ var saveEnvFileAsync = async ({
7811
7865
  `)}
7812
7866
  `;
7813
7867
  const dir = fs.path.dirname(absolutePath);
7814
- await fs.mkdir(dir);
7815
- const tempPath = `${absolutePath}.tmp`;
7816
- await fs.writeFile(tempPath, content);
7817
- await fs.rename(tempPath, absolutePath);
7868
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
7869
+ const authHomeDir = findAuthHomeDir(fs, dir);
7870
+ if (authHomeDir !== undefined) {
7871
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
7872
+ }
7873
+ const tempPath = await writeTempFile(fs, absolutePath, content);
7874
+ try {
7875
+ await fs.rename(tempPath, absolutePath);
7876
+ } catch (error) {
7877
+ await fs.rm(tempPath).catch(() => {});
7878
+ throw error;
7879
+ }
7818
7880
  };
7819
7881
 
7820
7882
  // ../../auth/src/loginStatus.ts
@@ -8912,4 +8974,4 @@ export {
8912
8974
  registerCommands
8913
8975
  };
8914
8976
 
8915
- //# debugId=8C4324FC35C0393064756E2164756E21
8977
+ //# debugId=C6F2D6EDCDB18FC864756E2164756E21
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.206.0-preview.312",
5
+ "version": "1.206.0-preview.323",
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": "ee91749054ba110153977dd920a4c84761ce82cd"
27
+ "gitHead": "a752d8a8d78de138e3be0a19642620fec7893d99"
28
28
  }