@ms-cloudpack/remote-cache 0.6.5 → 0.7.1

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.
@@ -1,19 +1,21 @@
1
1
  import {
2
- __commonJS,
3
- __esm,
4
- __export,
5
- __name,
6
- __require,
7
- __toCommonJS,
8
2
  esm_node_exports,
9
- init_esbuildCjsShims,
10
3
  init_esm_node,
11
4
  init_tslib_es6,
12
5
  require_dist,
13
6
  require_dist2,
14
7
  require_dist3,
15
8
  tslib_es6_exports
16
- } from "./chunk-OPD65OLQ.js";
9
+ } from "./chunk-4P62L7ZZ.js";
10
+ import {
11
+ __commonJS,
12
+ __esm,
13
+ __export,
14
+ __name,
15
+ __require,
16
+ __toCommonJS,
17
+ init_esbuildCjsShims
18
+ } from "./chunk-TQLTL4XO.js";
17
19
 
18
20
  // ../../node_modules/.store/xml2js-npm-0.5.0-06e57a2771/package/lib/defaults.js
19
21
  var require_defaults = __commonJS({
@@ -6067,7 +6069,7 @@ var require_dist4 = __commonJS({
6067
6069
  "use strict";
6068
6070
  init_esbuildCjsShims();
6069
6071
  Object.defineProperty(exports, "__esModule", { value: true });
6070
- var coreUtil = require_dist2();
6072
+ var coreUtil = require_dist3();
6071
6073
  var _AzureKeyCredential = class _AzureKeyCredential {
6072
6074
  /**
6073
6075
  * The value of the key to be used in authentication
@@ -20925,13 +20927,13 @@ var require_dist6 = __commonJS({
20925
20927
  var util = __require("util");
20926
20928
  var tslib = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
20927
20929
  var xml2js = require_xml2js();
20928
- var coreUtil = require_dist2();
20929
- var logger$1 = require_dist3();
20930
+ var coreUtil = require_dist3();
20931
+ var logger$1 = require_dist();
20930
20932
  var coreAuth = require_dist4();
20931
20933
  var os = __require("os");
20932
20934
  var http = __require("http");
20933
20935
  var https = __require("https");
20934
- var abortController = require_dist();
20936
+ var abortController = require_dist2();
20935
20937
  var tunnel = require_package();
20936
20938
  var stream = __require("stream");
20937
20939
  var FormData = require_form_data();
@@ -25485,9 +25487,9 @@ var require_dist8 = __commonJS({
25485
25487
  "use strict";
25486
25488
  init_esbuildCjsShims();
25487
25489
  Object.defineProperty(exports, "__esModule", { value: true });
25488
- var logger$1 = require_dist3();
25489
- var abortController = require_dist();
25490
- var coreUtil = require_dist2();
25490
+ var logger$1 = require_dist();
25491
+ var abortController = require_dist2();
25492
+ var coreUtil = require_dist3();
25491
25493
  var logger = logger$1.createClientLogger("core-lro");
25492
25494
  var POLL_INTERVAL_IN_MS = 2e3;
25493
25495
  var terminalStates = ["succeeded", "canceled", "failed"];
@@ -26536,8 +26538,8 @@ var require_dist9 = __commonJS({
26536
26538
  var coreHttp = require_dist6();
26537
26539
  var tslib = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
26538
26540
  var coreTracing = require_dist5();
26539
- var logger$1 = require_dist3();
26540
- var abortController = require_dist();
26541
+ var logger$1 = require_dist();
26542
+ var abortController = require_dist2();
26541
26543
  var os = __require("os");
26542
26544
  var crypto = __require("crypto");
26543
26545
  var stream = __require("stream");
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __name,
3
3
  init_esbuildCjsShims
4
- } from "./chunk-OPD65OLQ.js";
4
+ } from "./chunk-TQLTL4XO.js";
5
5
 
6
6
  // src/createBlobStorageUrl.ts
7
7
  init_esbuildCjsShims();
@@ -0,0 +1,65 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __esm = (fn, res) => function __init() {
16
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
+ };
18
+ var __commonJS = (cb, mod) => function __require2() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
+
43
+ // ../../scripts/esbuildCjsShims.js
44
+ import { createRequire } from "node:module";
45
+ import path from "node:path";
46
+ import url from "node:url";
47
+ var init_esbuildCjsShims = __esm({
48
+ "../../scripts/esbuildCjsShims.js"() {
49
+ "use strict";
50
+ globalThis.require = createRequire(import.meta.url);
51
+ globalThis.__filename = url.fileURLToPath(import.meta.url);
52
+ globalThis.__dirname = path.dirname(__filename);
53
+ }
54
+ });
55
+
56
+ export {
57
+ __name,
58
+ __require,
59
+ __esm,
60
+ __commonJS,
61
+ __export,
62
+ __toESM,
63
+ __toCommonJS,
64
+ init_esbuildCjsShims
65
+ };
@@ -1,12 +1,4 @@
1
1
  import {
2
- __commonJS,
3
- __esm,
4
- __export,
5
- __name,
6
- __require,
7
- __toCommonJS,
8
- __toESM,
9
- init_esbuildCjsShims,
10
2
  init_esm_node,
11
3
  init_tslib_es6,
12
4
  require_dist,
@@ -14,7 +6,17 @@ import {
14
6
  require_dist3,
15
7
  tslib_es6_exports,
16
8
  v4_default
17
- } from "./chunk-OPD65OLQ.js";
9
+ } from "./chunk-4P62L7ZZ.js";
10
+ import {
11
+ __commonJS,
12
+ __esm,
13
+ __export,
14
+ __name,
15
+ __require,
16
+ __toCommonJS,
17
+ __toESM,
18
+ init_esbuildCjsShims
19
+ } from "./chunk-TQLTL4XO.js";
18
20
 
19
21
  // ../../node_modules/.store/@azure-msal-node-npm-2.6.2-9183813942/package/dist/cache/serializer/Serializer.mjs
20
22
  var _Serializer, Serializer;
@@ -16522,10 +16524,10 @@ var require_dist8 = __commonJS({
16522
16524
  "use strict";
16523
16525
  init_esbuildCjsShims();
16524
16526
  Object.defineProperty(exports, "__esModule", { value: true });
16525
- var logger$1 = require_dist3();
16526
- var coreUtil = require_dist2();
16527
+ var logger$1 = require_dist();
16528
+ var coreUtil = require_dist3();
16527
16529
  var os = __require("os");
16528
- var abortController = require_dist();
16530
+ var abortController = require_dist2();
16529
16531
  var httpsProxyAgent = require_dist4();
16530
16532
  var httpProxyAgent = require_dist6();
16531
16533
  var coreTracing = require_dist7();
@@ -18553,7 +18555,7 @@ var require_dist9 = __commonJS({
18553
18555
  init_esbuildCjsShims();
18554
18556
  Object.defineProperty(exports, "__esModule", { value: true });
18555
18557
  var coreRestPipeline = require_dist8();
18556
- var logger$1 = require_dist3();
18558
+ var logger$1 = require_dist();
18557
18559
  function encodeByteArray(value) {
18558
18560
  const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer);
18559
18561
  return bufferValue.toString("base64");
@@ -19847,15 +19849,15 @@ var require_dist9 = __commonJS({
19847
19849
  let isAbsolutePath = false;
19848
19850
  let requestUrl = replaceAll(baseUri, urlReplacements);
19849
19851
  if (operationSpec.path) {
19850
- let path2 = replaceAll(operationSpec.path, urlReplacements);
19851
- if (operationSpec.path === "/{nextLink}" && path2.startsWith("/")) {
19852
- path2 = path2.substring(1);
19852
+ let path3 = replaceAll(operationSpec.path, urlReplacements);
19853
+ if (operationSpec.path === "/{nextLink}" && path3.startsWith("/")) {
19854
+ path3 = path3.substring(1);
19853
19855
  }
19854
- if (isAbsoluteUrl(path2)) {
19855
- requestUrl = path2;
19856
+ if (isAbsoluteUrl(path3)) {
19857
+ requestUrl = path3;
19856
19858
  isAbsolutePath = true;
19857
19859
  } else {
19858
- requestUrl = appendPath(requestUrl, path2);
19860
+ requestUrl = appendPath(requestUrl, path3);
19859
19861
  }
19860
19862
  }
19861
19863
  const { queryParams, sequenceParams } = calculateQueryParameters(operationSpec, operationArguments, fallbackObject);
@@ -19906,9 +19908,9 @@ var require_dist9 = __commonJS({
19906
19908
  }
19907
19909
  const searchStart = pathToAppend.indexOf("?");
19908
19910
  if (searchStart !== -1) {
19909
- const path2 = pathToAppend.substring(0, searchStart);
19911
+ const path3 = pathToAppend.substring(0, searchStart);
19910
19912
  const search = pathToAppend.substring(searchStart + 1);
19911
- newPath = newPath + path2;
19913
+ newPath = newPath + path3;
19912
19914
  if (search) {
19913
19915
  parsedUrl.search = parsedUrl.search ? `${parsedUrl.search}&${search}` : search;
19914
19916
  }
@@ -20377,13 +20379,13 @@ var require_package19 = __commonJS({
20377
20379
  var require_package20 = __commonJS({
20378
20380
  "../../node_modules/.store/open-npm-8.4.2-1f763e8b75/package/index.js"(exports, module) {
20379
20381
  init_esbuildCjsShims();
20380
- var path2 = __require("path");
20382
+ var path3 = __require("path");
20381
20383
  var childProcess = __require("child_process");
20382
20384
  var { promises: fs, constants: fsConstants } = __require("fs");
20383
20385
  var isWsl = require_package18();
20384
20386
  var isDocker = require_package17();
20385
20387
  var defineLazyProperty = require_package19();
20386
- var localXdgOpenPath = path2.join(__dirname, "xdg-open");
20388
+ var localXdgOpenPath = path3.join(__dirname, "xdg-open");
20387
20389
  var { platform, arch } = process;
20388
20390
  var hasContainerEnv = /* @__PURE__ */ __name(() => {
20389
20391
  try {
@@ -20639,15 +20641,15 @@ var require_dist10 = __commonJS({
20639
20641
  init_esbuildCjsShims();
20640
20642
  Object.defineProperty(exports, "__esModule", { value: true });
20641
20643
  var msalCommon = (init_dist2(), __toCommonJS(dist_exports));
20642
- var logger$o = require_dist3();
20643
- var abortController = require_dist();
20644
- var coreUtil = require_dist2();
20644
+ var logger$o = require_dist();
20645
+ var abortController = require_dist2();
20646
+ var coreUtil = require_dist3();
20645
20647
  var coreClient = require_dist9();
20646
20648
  var coreRestPipeline = require_dist8();
20647
20649
  var coreTracing = require_dist7();
20648
20650
  var fs = __require("fs");
20649
20651
  var os = __require("os");
20650
- var path2 = __require("path");
20652
+ var path3 = __require("path");
20651
20653
  var promises = __require("fs/promises");
20652
20654
  var https2 = __require("https");
20653
20655
  var child_process = __require("child_process");
@@ -21670,7 +21672,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
21670
21672
  const vsCodeFolder = "Code";
21671
21673
  const homedir = os.homedir();
21672
21674
  function loadProperty(...pathSegments) {
21673
- const fullPath = path2.join(...pathSegments, vsCodeFolder, ...settingsPath);
21675
+ const fullPath = path3.join(...pathSegments, vsCodeFolder, ...settingsPath);
21674
21676
  const settings = JSON.parse(fs.readFileSync(fullPath, { encoding: "utf8" }));
21675
21677
  return settings[property];
21676
21678
  }
@@ -22068,8 +22070,8 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
22068
22070
  });
22069
22071
  }
22070
22072
  __name(prepareRequestOptions$2, "prepareRequestOptions$2");
22071
- function readFileAsync$1(path3, options) {
22072
- return new Promise((resolve, reject) => fs.readFile(path3, options, (err, data) => {
22073
+ function readFileAsync$1(path4, options) {
22074
+ return new Promise((resolve, reject) => fs.readFile(path4, options, (err, data) => {
22073
22075
  if (err) {
22074
22076
  reject(err);
22075
22077
  }
@@ -24055,7 +24057,7 @@ var require_dist11 = __commonJS({
24055
24057
  init_esbuildCjsShims();
24056
24058
  Object.defineProperty(exports, "__esModule", { value: true });
24057
24059
  var tslib = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
24058
- var path2 = __require("path");
24060
+ var path3 = __require("path");
24059
24061
  var msalNodeExtensions = __require("@azure/msal-node-extensions");
24060
24062
  function _interopNamespaceDefault(e) {
24061
24063
  var n = /* @__PURE__ */ Object.create(null);
@@ -24076,7 +24078,7 @@ var require_dist11 = __commonJS({
24076
24078
  return Object.freeze(n);
24077
24079
  }
24078
24080
  __name(_interopNamespaceDefault, "_interopNamespaceDefault");
24079
- var path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path2);
24081
+ var path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path3);
24080
24082
  var _a;
24081
24083
  var _b;
24082
24084
  var _c;
@@ -24214,11 +24216,115 @@ function saveAuthenticationRecord(cachePath, authRecord) {
24214
24216
  }
24215
24217
  __name(saveAuthenticationRecord, "saveAuthenticationRecord");
24216
24218
 
24217
- // src/authentication/getCredential.ts
24219
+ // src/authentication/tokenCachePersistenceOptions.ts
24220
+ init_esbuildCjsShims();
24218
24221
  var tokenCachePersistenceOptions = {
24219
24222
  enabled: true,
24220
24223
  name: "cloudpack"
24221
24224
  };
24225
+
24226
+ // src/authentication/lock-file/tryCleaningLockFile.ts
24227
+ init_esbuildCjsShims();
24228
+
24229
+ // src/utils/isProcessRunning.ts
24230
+ init_esbuildCjsShims();
24231
+ function isProcessRunning(pid) {
24232
+ try {
24233
+ process.kill(pid, 0);
24234
+ return true;
24235
+ } catch (error) {
24236
+ if (error instanceof Error && "code" in error && error.code === "EPERM") {
24237
+ console.log(
24238
+ `Permission issue indicates that process ${pid} exists but user doesn't have permission to signal it.`
24239
+ );
24240
+ return true;
24241
+ } else if (error instanceof Error && "code" in error && error.code === "ESRCH") {
24242
+ console.log(`Process ${pid} does not exist.`);
24243
+ return false;
24244
+ } else {
24245
+ throw error;
24246
+ }
24247
+ }
24248
+ }
24249
+ __name(isProcessRunning, "isProcessRunning");
24250
+
24251
+ // src/authentication/lock-file/deleteAuthenticationLockFile.ts
24252
+ init_esbuildCjsShims();
24253
+ import { unlinkSync } from "fs";
24254
+
24255
+ // src/authentication/lock-file/getAuthenticationLockFilePath.ts
24256
+ init_esbuildCjsShims();
24257
+ import path2 from "path";
24258
+ function getAuthenticationLockFilePath() {
24259
+ var _a, _b;
24260
+ const localApplicationDataFolder = ((_b = (_a = process.env.APPDATA) == null ? void 0 : _a.replace) == null ? void 0 : _b.call(_a, /(.Roaming)*$/, "\\Local")) ?? (process.env.HOME || "");
24261
+ return path2.join(localApplicationDataFolder, ".IdentityService", tokenCachePersistenceOptions.name + ".lockfile");
24262
+ }
24263
+ __name(getAuthenticationLockFilePath, "getAuthenticationLockFilePath");
24264
+
24265
+ // src/authentication/lock-file/deleteAuthenticationLockFile.ts
24266
+ function deleteAuthenticationLockFile() {
24267
+ const lockFilePath = getAuthenticationLockFilePath();
24268
+ try {
24269
+ unlinkSync(lockFilePath);
24270
+ return true;
24271
+ } catch (error) {
24272
+ const errorCode = error instanceof Error && "code" in error ? error.code : void 0;
24273
+ switch (errorCode) {
24274
+ case "ENOENT":
24275
+ console.error(`Error: File ${lockFilePath} not found.`);
24276
+ break;
24277
+ case "EACCES":
24278
+ case "EPERM":
24279
+ console.error(`Error: Permission denied to delete ${lockFilePath}.`);
24280
+ break;
24281
+ case "EBUSY":
24282
+ console.error(`Error: ${lockFilePath} is currently in use and cannot be deleted.`);
24283
+ break;
24284
+ default:
24285
+ console.error(`Error deleting file ${lockFilePath}`, error);
24286
+ }
24287
+ }
24288
+ return false;
24289
+ }
24290
+ __name(deleteAuthenticationLockFile, "deleteAuthenticationLockFile");
24291
+
24292
+ // src/authentication/lock-file/doesLockFileExist.ts
24293
+ init_esbuildCjsShims();
24294
+ import { existsSync as existsSync3 } from "fs";
24295
+ function doesLockFileExist() {
24296
+ const lockFilePath = getAuthenticationLockFilePath();
24297
+ return existsSync3(lockFilePath);
24298
+ }
24299
+ __name(doesLockFileExist, "doesLockFileExist");
24300
+
24301
+ // src/authentication/lock-file/readAuthenticationLockFile.ts
24302
+ init_esbuildCjsShims();
24303
+ import { readFileSync as readFileSync2 } from "fs";
24304
+ function readAuthenticationLockFile() {
24305
+ const lockFilePath = getAuthenticationLockFilePath();
24306
+ const fileContent = readFileSync2(lockFilePath, "utf8");
24307
+ return parseInt(fileContent);
24308
+ }
24309
+ __name(readAuthenticationLockFile, "readAuthenticationLockFile");
24310
+
24311
+ // src/authentication/lock-file/tryCleaningLockFile.ts
24312
+ function tryCleaningLockFile() {
24313
+ if (!doesLockFileExist()) {
24314
+ return true;
24315
+ }
24316
+ const pid = readAuthenticationLockFile();
24317
+ console.log(`Process ID in the lock file: ${pid}`);
24318
+ if (!isProcessRunning(pid) && deleteAuthenticationLockFile()) {
24319
+ console.log("Auth lock file is deleted successfully");
24320
+ return true;
24321
+ }
24322
+ console.log("Auth lock file is not deleted.");
24323
+ return false;
24324
+ }
24325
+ __name(tryCleaningLockFile, "tryCleaningLockFile");
24326
+
24327
+ // src/authentication/getCredential.ts
24222
24328
  function getCredentialInternal(loginMethod, authenticationRecord, tenantId) {
24223
24329
  switch (loginMethod) {
24224
24330
  case "interactive":
@@ -24250,6 +24356,7 @@ async function getCredential(loginMethod, cachePath, tenantId) {
24250
24356
  "Prepare to sign in \u2013 we may launch a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process."
24251
24357
  );
24252
24358
  }
24359
+ tryCleaningLockFile();
24253
24360
  const storageScope = "https://storage.azure.com/.default";
24254
24361
  const authenticationRecord = await credential.authenticate(storageScope);
24255
24362
  const token = await credential.getToken(storageScope);
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  createBlobStorageUrl
3
- } from "./chunk-5BUSQ7SW.js";
3
+ } from "./chunk-R2VDVRDZ.js";
4
4
  import {
5
5
  require_dist
6
- } from "./chunk-YAIY33BG.js";
6
+ } from "./chunk-KFSFZYG6.js";
7
+ import "./chunk-4P62L7ZZ.js";
7
8
  import {
8
9
  __name,
9
10
  __toESM,
10
11
  init_esbuildCjsShims
11
- } from "./chunk-OPD65OLQ.js";
12
+ } from "./chunk-TQLTL4XO.js";
12
13
 
13
14
  // src/getListOfBlobs.ts
14
15
  init_esbuildCjsShims();
package/dist/index.js CHANGED
@@ -1,11 +1,7 @@
1
- import {
2
- require_dist
3
- } from "./chunk-YAIY33BG.js";
4
1
  import {
5
2
  __name,
6
- __toESM,
7
3
  init_esbuildCjsShims
8
- } from "./chunk-OPD65OLQ.js";
4
+ } from "./chunk-TQLTL4XO.js";
9
5
 
10
6
  // src/index.ts
11
7
  init_esbuildCjsShims();
@@ -82,77 +78,33 @@ var blockListIsInvalidRetryPolicy = {
82
78
 
83
79
  // src/createRemoteCacheClient.ts
84
80
  import { RetryManager } from "@ms-cloudpack/retry";
85
-
86
- // src/error/transformError.ts
87
- init_esbuildCjsShims();
88
-
89
- // src/error/RemoteCacheError.ts
90
- init_esbuildCjsShims();
91
- var _RemoteCacheError = class _RemoteCacheError extends Error {
92
- constructor(code, message) {
93
- super(message);
94
- this._code = code;
95
- }
96
- get code() {
97
- return this._code;
98
- }
99
- };
100
- __name(_RemoteCacheError, "RemoteCacheError");
101
- var RemoteCacheError = _RemoteCacheError;
102
-
103
- // src/error/isRestError.ts
104
- init_esbuildCjsShims();
105
- var import_storage_blob = __toESM(require_dist(), 1);
106
- function isRestError(error) {
107
- return error instanceof import_storage_blob.RestError;
108
- }
109
- __name(isRestError, "isRestError");
110
-
111
- // src/error/transformError.ts
112
- function transformError(error) {
113
- if (isRestError(error) && error.statusCode === 401 || error instanceof Error && error.name === "AuthenticationRequiredError") {
114
- return new RemoteCacheError("AUTH_ERROR", "Authentication failed. Please check your credentials and try again.");
115
- }
116
- if (isRestError(error) && error.code === "REQUEST_SEND_ERROR") {
117
- return new RemoteCacheError("CONNECTION_ERROR", "Connection failed. Please check your connection.");
118
- }
119
- return error;
120
- }
121
- __name(transformError, "transformError");
122
-
123
- // src/createRemoteCacheClient.ts
124
81
  async function createRemoteCacheClient(params) {
125
82
  const { context, options } = params;
126
83
  const { container, loginMethod, storageAccount, cachePath, tenantId } = options;
127
- const { getCredential } = await import("./getCredential-FIEDCLGJ.js");
128
- const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-NBBUAAXL.js");
129
- const { ReporterDecorator } = await import("./ReporterDecorator-YCOIU5LI.js");
130
- const { getListOfBlobs } = await import("./getListOfBlobs-VRDJ4A5S.js");
131
- try {
132
- const credential = await getCredential(loginMethod, cachePath, tenantId);
133
- const remoteCacheClientOptions = {
134
- storageAccount,
135
- container,
136
- credential
137
- };
138
- const listOfBlobs = await getListOfBlobs(remoteCacheClientOptions);
139
- const client = new ReporterDecorator(
140
- new RetryDecorator({
141
- retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),
142
- cacheClient: new InMemoryDecorator({
143
- cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
144
- getList: () => Promise.resolve(listOfBlobs)
145
- })
146
- }),
147
- context
148
- );
149
- return client;
150
- } catch (error) {
151
- throw transformError(error);
152
- }
84
+ const { getCredential } = await import("./getCredential-2R4O36RK.js");
85
+ const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-NEV2XCF7.js");
86
+ const { ReporterDecorator } = await import("./ReporterDecorator-SNBYNGOT.js");
87
+ const { getListOfBlobs } = await import("./getListOfBlobs-E5OFG2MF.js");
88
+ const credential = await getCredential(loginMethod, cachePath, tenantId);
89
+ const remoteCacheClientOptions = {
90
+ storageAccount,
91
+ container,
92
+ credential
93
+ };
94
+ const listOfBlobs = await getListOfBlobs(remoteCacheClientOptions);
95
+ const client = new ReporterDecorator(
96
+ new RetryDecorator({
97
+ retryManager: new RetryManager([blockListIsInvalidRetryPolicy]),
98
+ cacheClient: new InMemoryDecorator({
99
+ cacheClient: new AzureRemoteCacheClient(remoteCacheClientOptions),
100
+ getList: () => Promise.resolve(listOfBlobs)
101
+ })
102
+ }),
103
+ context
104
+ );
105
+ return client;
153
106
  }
154
107
  __name(createRemoteCacheClient, "createRemoteCacheClient");
155
108
  export {
156
- RemoteCacheError,
157
109
  createRemoteCacheClient
158
110
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Deletes the authentication lock file.
3
+ * If the file does not exist or is currently in use, cannot be deleted due to permission issues, it logs an error message.
4
+ * @returns - true if the file was successfully deleted, false otherwise.
5
+ */
6
+ export declare function deleteAuthenticationLockFile(): boolean;
7
+ //# sourceMappingURL=deleteAuthenticationLockFile.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Checks if the authentication lock file exists.
3
+ * @returns - true if the authentication lock file exists, false otherwise.
4
+ */
5
+ export declare function doesLockFileExist(): boolean;
6
+ //# sourceMappingURL=doesLockFileExist.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @returns The file path of the authentication lock file.
3
+ * Expected responses:
4
+ * - Darwin: '/Users/user/.IdentityService/cloudpack.lockfile'
5
+ * - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService\cloudpack.lockfile'
6
+ * - Linux: '/home/user/.IdentityService/cloudpack.lockfile'
7
+ *
8
+ * The lock file is generated by the @azure/identity and msal-node-extensions packages. Unfortunately, these packages do not provide an API to retrieve the lock file path directly. Therefore, we've implemented a function to obtain their lock file path, albeit without a formal contract.
9
+ */
10
+ export declare function getAuthenticationLockFilePath(): string;
11
+ //# sourceMappingURL=getAuthenticationLockFilePath.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Reads the authentication lock file and parse the content to int.
3
+ * @returns - The process ID stored in the authentication lock file.
4
+ */
5
+ export declare function readAuthenticationLockFile(): number;
6
+ //# sourceMappingURL=readAuthenticationLockFile.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Tries to clean the authentication lock file by deleting it if the other process is not running.
3
+ * @returns - true if the lock file is deleted successfully, false otherwise.
4
+ */
5
+ export declare function tryCleaningLockFile(): boolean;
6
+ //# sourceMappingURL=tryCleaningLockFile.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { type TokenCachePersistenceOptions } from '@azure/identity';
2
+ /**
3
+ * The options for token cache persistence.
4
+ * This will be used by the token cache plugin.
5
+ */
6
+ export declare const tokenCachePersistenceOptions: TokenCachePersistenceOptions & {
7
+ name: string;
8
+ };
9
+ //# sourceMappingURL=tokenCachePersistenceOptions.d.ts.map
package/lib/index.d.ts CHANGED
@@ -2,6 +2,4 @@ export { createRemoteCacheClient, type CreateRemoteCacheClientParams } from './c
2
2
  export type { RemoteCacheClient, RemoteCacheClientUploadOperationOptions as RemoteCacheClientDownloadOperationOptions, RemoteCacheClientOperationOptions, RemoteCacheClientOperationResult, } from './types/RemoteCacheClient.js';
3
3
  export type { LoginMethod } from './types/LoginMethod.js';
4
4
  export type { RemoteCacheClientOptions } from './types/RemoteCacheClientOptions.js';
5
- export { RemoteCacheError } from './error/RemoteCacheError.js';
6
- export type { RemoteCacheErrorType } from './error/RemoteCacheError.js';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if a process with the given PID is running.
3
+ * @param pid - The process ID to check.
4
+ * @returns - true if the process is running, false otherwise.
5
+ */
6
+ export declare function isProcessRunning(pid: number): boolean;
7
+ //# sourceMappingURL=isProcessRunning.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/remote-cache",
3
- "version": "0.6.5",
3
+ "version": "0.7.1",
4
4
  "description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,10 +0,0 @@
1
- export type RemoteCacheErrorType = 'CONNECTION_ERROR' | 'AUTH_ERROR';
2
- /**
3
- * An error thrown by a remote cache client.
4
- */
5
- export declare class RemoteCacheError extends Error {
6
- private _code;
7
- constructor(code: RemoteCacheErrorType, message: string);
8
- get code(): RemoteCacheErrorType;
9
- }
10
- //# sourceMappingURL=RemoteCacheError.d.ts.map