@ms-cloudpack/remote-cache 0.7.3 → 0.7.5

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.
@@ -8,7 +8,7 @@ import {
8
8
  __commonJS,
9
9
  __name,
10
10
  __require
11
- } from "./chunk-E6II3DDV.js";
11
+ } from "./chunk-B4GP6UPK.js";
12
12
 
13
13
  // ../../node_modules/.store/safe-buffer-npm-5.2.1-3481c8aa9b/package/index.js
14
14
  var require_package = __commonJS({
@@ -6,7 +6,7 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
6
  const __dirname = topLevelPath.dirname(__filename);
7
7
  import {
8
8
  __name
9
- } from "./chunk-E6II3DDV.js";
9
+ } from "./chunk-B4GP6UPK.js";
10
10
 
11
11
  // src/createBlobStorageUrl.ts
12
12
  function createBlobStorageUrl(storageAccount) {
@@ -7,20 +7,20 @@ const __dirname = topLevelPath.dirname(__filename);
7
7
  import {
8
8
  esm_node_exports,
9
9
  init_esm_node,
10
- init_tslib_es6,
11
- require_commonjs,
12
- require_commonjs3 as require_commonjs2,
13
- require_dist,
14
- tslib_es6_exports
15
- } from "./chunk-LRLTRMOZ.js";
10
+ require_commonjs2,
11
+ require_dist
12
+ } from "./chunk-26KCJU2L.js";
16
13
  import {
17
14
  __commonJS,
18
15
  __esm,
19
16
  __export,
20
17
  __name,
21
18
  __require,
22
- __toCommonJS
23
- } from "./chunk-E6II3DDV.js";
19
+ __toCommonJS,
20
+ init_tslib_es6,
21
+ require_commonjs,
22
+ tslib_es6_exports
23
+ } from "./chunk-B4GP6UPK.js";
24
24
 
25
25
  // ../../node_modules/.store/xml2js-npm-0.5.0-06e57a2771/package/lib/defaults.js
26
26
  var require_defaults = __commonJS({
@@ -6,17 +6,14 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
6
  const __dirname = topLevelPath.dirname(__filename);
7
7
  import {
8
8
  require_package
9
- } from "./chunk-YEA5VY6V.js";
9
+ } from "./chunk-FUGMINXQ.js";
10
10
  import {
11
11
  init_esm_node,
12
- init_tslib_es6,
13
- require_commonjs,
14
- require_commonjs2,
15
- require_commonjs3,
12
+ require_commonjs as require_commonjs2,
13
+ require_commonjs2 as require_commonjs3,
16
14
  require_dist,
17
- tslib_es6_exports,
18
15
  v4_default
19
- } from "./chunk-LRLTRMOZ.js";
16
+ } from "./chunk-26KCJU2L.js";
20
17
  import {
21
18
  __commonJS,
22
19
  __esm,
@@ -24,8 +21,11 @@ import {
24
21
  __name,
25
22
  __require,
26
23
  __toCommonJS,
27
- __toESM
28
- } from "./chunk-E6II3DDV.js";
24
+ __toESM,
25
+ init_tslib_es6,
26
+ require_commonjs,
27
+ tslib_es6_exports
28
+ } from "./chunk-B4GP6UPK.js";
29
29
 
30
30
  // ../../node_modules/.store/@azure-core-client-npm-1.9.2-1ef0857920/package/dist/commonjs/base64.js
31
31
  var require_base64 = __commonJS({
@@ -2349,9 +2349,9 @@ var require_package2 = __commonJS({
2349
2349
  }
2350
2350
  });
2351
2351
 
2352
- // ../../node_modules/.store/debug-virtual-1d970e8425/package/src/common.js
2352
+ // ../../node_modules/.store/debug-virtual-11377b508d/package/src/common.js
2353
2353
  var require_common = __commonJS({
2354
- "../../node_modules/.store/debug-virtual-1d970e8425/package/src/common.js"(exports, module) {
2354
+ "../../node_modules/.store/debug-virtual-11377b508d/package/src/common.js"(exports, module) {
2355
2355
  function setup(env) {
2356
2356
  createDebug.debug = createDebug;
2357
2357
  createDebug.default = createDebug;
@@ -2523,9 +2523,9 @@ var require_common = __commonJS({
2523
2523
  }
2524
2524
  });
2525
2525
 
2526
- // ../../node_modules/.store/debug-virtual-1d970e8425/package/src/browser.js
2526
+ // ../../node_modules/.store/debug-virtual-11377b508d/package/src/browser.js
2527
2527
  var require_browser = __commonJS({
2528
- "../../node_modules/.store/debug-virtual-1d970e8425/package/src/browser.js"(exports, module) {
2528
+ "../../node_modules/.store/debug-virtual-11377b508d/package/src/browser.js"(exports, module) {
2529
2529
  exports.formatArgs = formatArgs;
2530
2530
  exports.save = save;
2531
2531
  exports.load = load;
@@ -2697,9 +2697,9 @@ var require_browser = __commonJS({
2697
2697
  }
2698
2698
  });
2699
2699
 
2700
- // ../../node_modules/.store/debug-virtual-1d970e8425/package/src/node.js
2700
+ // ../../node_modules/.store/debug-virtual-11377b508d/package/src/node.js
2701
2701
  var require_node = __commonJS({
2702
- "../../node_modules/.store/debug-virtual-1d970e8425/package/src/node.js"(exports, module) {
2702
+ "../../node_modules/.store/debug-virtual-11377b508d/package/src/node.js"(exports, module) {
2703
2703
  var tty = __require("tty");
2704
2704
  var util = __require("util");
2705
2705
  exports.init = init;
@@ -2878,9 +2878,9 @@ var require_node = __commonJS({
2878
2878
  }
2879
2879
  });
2880
2880
 
2881
- // ../../node_modules/.store/debug-virtual-1d970e8425/package/src/index.js
2881
+ // ../../node_modules/.store/debug-virtual-11377b508d/package/src/index.js
2882
2882
  var require_src = __commonJS({
2883
- "../../node_modules/.store/debug-virtual-1d970e8425/package/src/index.js"(exports, module) {
2883
+ "../../node_modules/.store/debug-virtual-11377b508d/package/src/index.js"(exports, module) {
2884
2884
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
2885
2885
  module.exports = require_browser();
2886
2886
  } else {
@@ -25501,6 +25501,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
25501
25501
  try {
25502
25502
  const interactiveRequest = {
25503
25503
  openBrowser: async (url) => {
25504
+ this.logger.verbose(`Opening browser to ${url}`);
25504
25505
  await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
25505
25506
  },
25506
25507
  scopes,
@@ -26177,17 +26178,24 @@ var tokenCachePersistenceOptions = {
26177
26178
  };
26178
26179
 
26179
26180
  // src/utils/isProcessRunning.ts
26181
+ function isErrorWithCode(error) {
26182
+ return error instanceof Error && "code" in error;
26183
+ }
26184
+ __name(isErrorWithCode, "isErrorWithCode");
26180
26185
  function isProcessRunning(pid) {
26181
26186
  try {
26182
26187
  process.kill(pid, 0);
26183
26188
  return true;
26184
26189
  } catch (error) {
26185
- if (error instanceof Error && "code" in error && error.code === "EPERM") {
26190
+ if (isErrorWithCode(error) && error.code === "ERR_INVALID_ARG_TYPE") {
26191
+ console.log(`Invalid PID: ${pid}`);
26192
+ return false;
26193
+ } else if (isErrorWithCode(error) && error.code === "EPERM") {
26186
26194
  console.log(
26187
26195
  `Permission issue indicates that process ${pid} exists but user doesn't have permission to signal it.`
26188
26196
  );
26189
26197
  return true;
26190
- } else if (error instanceof Error && "code" in error && error.code === "ESRCH") {
26198
+ } else if (isErrorWithCode(error) && error.code === "ESRCH") {
26191
26199
  console.log(`Process ${pid} does not exist.`);
26192
26200
  return false;
26193
26201
  } else {
@@ -26290,17 +26298,21 @@ function getCredentialInternal(loginMethod, authenticationRecord, tenantId) {
26290
26298
  }
26291
26299
  }
26292
26300
  __name(getCredentialInternal, "getCredentialInternal");
26293
- async function getCredential(loginMethod, cachePath, tenantId) {
26301
+ async function getCredential(options, context) {
26302
+ var _a;
26303
+ const { loginMethod, cachePath, tenantId } = options;
26304
+ const { reporter, azureLogger } = context;
26294
26305
  if (loginMethod == "azure-cli") {
26295
26306
  return new import_identity3.AzureCliCredential();
26296
26307
  }
26308
+ const tasks = {};
26309
+ azureLogger.once("MsalBrowserOpen", (url) => {
26310
+ tasks.interactiveAuthentication = reporter.addTask(
26311
+ `Prepare to sign in \u2013 we are launching a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process. You can manually access the login page by navigating to the folliwing url if you inadvertently close the authentication page or prefer to use a different web browser or a profile. ${url}`
26312
+ );
26313
+ });
26297
26314
  (0, import_identity3.useIdentityPlugin)(import_identity_cache_persistence.cachePersistencePlugin);
26298
26315
  const credential = getCredentialInternal(loginMethod, getAuthenticationRecord(cachePath), tenantId);
26299
- if (loginMethod == "interactive") {
26300
- console.warn(
26301
- "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."
26302
- );
26303
- }
26304
26316
  tryCleaningLockFile();
26305
26317
  const storageScope = "https://storage.azure.com/.default";
26306
26318
  const authenticationRecord = await credential.authenticate(storageScope);
@@ -26311,6 +26323,9 @@ async function getCredential(loginMethod, cachePath, tenantId) {
26311
26323
  if (authenticationRecord) {
26312
26324
  saveAuthenticationRecord(cachePath, authenticationRecord);
26313
26325
  }
26326
+ (_a = tasks.interactiveAuthentication) == null ? void 0 : _a.complete({
26327
+ message: "You have successfully signed in."
26328
+ });
26314
26329
  return storageCustomCredential;
26315
26330
  }
26316
26331
  __name(getCredential, "getCredential");
@@ -6,15 +6,15 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
6
  const __dirname = topLevelPath.dirname(__filename);
7
7
  import {
8
8
  createBlobStorageUrl
9
- } from "./chunk-65RH3KSH.js";
9
+ } from "./chunk-IVPGYNQL.js";
10
10
  import {
11
11
  require_dist
12
- } from "./chunk-W3GZC77T.js";
13
- import "./chunk-LRLTRMOZ.js";
12
+ } from "./chunk-OXARBRZV.js";
13
+ import "./chunk-26KCJU2L.js";
14
14
  import {
15
15
  __name,
16
16
  __toESM
17
- } from "./chunk-E6II3DDV.js";
17
+ } from "./chunk-B4GP6UPK.js";
18
18
 
19
19
  // src/getListOfBlobs.ts
20
20
  var import_storage_blob = __toESM(require_dist(), 1);
package/dist/index.js CHANGED
@@ -5,8 +5,25 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
6
  const __dirname = topLevelPath.dirname(__filename);
7
7
  import {
8
- __name
9
- } from "./chunk-E6II3DDV.js";
8
+ __name,
9
+ require_commonjs
10
+ } from "./chunk-B4GP6UPK.js";
11
+
12
+ // src/registerAzureLogger.ts
13
+ import EventEmitter from "events";
14
+ var logger = require_commonjs();
15
+ function registerAzureLogger() {
16
+ const emitter = new EventEmitter();
17
+ logger.setLogLevel("verbose");
18
+ logger.AzureLogger.log = (...messages) => {
19
+ if (messages[0] === "azure:identity:verbose Node.js MSAL Open Browser =>" && messages[1].includes("Opening browser")) {
20
+ const url = messages[1].split(" ")[3];
21
+ emitter.emit("MsalBrowserOpen", url);
22
+ }
23
+ };
24
+ return emitter;
25
+ }
26
+ __name(registerAzureLogger, "registerAzureLogger");
10
27
 
11
28
  // src/decorators/InMemoryDecorator.ts
12
29
  var _InMemoryDecorator = class _InMemoryDecorator {
@@ -75,13 +92,17 @@ var blockListIsInvalidRetryPolicy = {
75
92
  // src/createRemoteCacheClient.ts
76
93
  import { RetryManager } from "@ms-cloudpack/retry";
77
94
  async function createRemoteCacheClient(params) {
95
+ const azureLogEventHandler = registerAzureLogger();
78
96
  const { context, options } = params;
79
97
  const { container, loginMethod, storageAccount, cachePath, tenantId } = options;
80
- const { getCredential } = await import("./getCredential-TIS4HQAY.js");
81
- const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-4Q4WE4D3.js");
82
- const { ReporterDecorator } = await import("./ReporterDecorator-YVGD2WYR.js");
83
- const { getListOfBlobs } = await import("./getListOfBlobs-ZMH5R6FS.js");
84
- const credential = await getCredential(loginMethod, cachePath, tenantId);
98
+ const { getCredential } = await import("./getCredential-3U7LKZRE.js");
99
+ const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-ZZ27K4AF.js");
100
+ const { ReporterDecorator } = await import("./ReporterDecorator-I4CR7TWD.js");
101
+ const { getListOfBlobs } = await import("./getListOfBlobs-YTVBR3IU.js");
102
+ const credential = await getCredential(
103
+ { loginMethod, cachePath, tenantId },
104
+ { reporter: context.reporter, azureLogger: azureLogEventHandler }
105
+ );
85
106
  const remoteCacheClientOptions = {
86
107
  storageAccount,
87
108
  container,
@@ -1,10 +1,20 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  import { type TokenCredential } from '@azure/identity';
2
3
  import type { LoginMethod } from '../types/LoginMethod.js';
4
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
5
+ import type EventEmitter from 'events';
3
6
  /**
4
7
  * Gets a credential for the given login method.
5
8
  * If the login method is 'azure-cli', it will return an AzureCliCredential.
6
9
  * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.
7
10
  * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.
8
11
  */
9
- export declare function getCredential(loginMethod: LoginMethod, cachePath: string, tenantId?: string): Promise<TokenCredential>;
12
+ export declare function getCredential(options: {
13
+ loginMethod: LoginMethod;
14
+ cachePath: string;
15
+ tenantId?: string;
16
+ }, context: {
17
+ reporter: TaskReporter;
18
+ azureLogger: EventEmitter;
19
+ }): Promise<TokenCredential>;
10
20
  //# sourceMappingURL=getCredential.d.ts.map
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import EventEmitter from 'events';
3
+ /**
4
+ * Registers a custom logger for the Azure SDK that emits events for some specific log messages.
5
+ */
6
+ export declare function registerAzureLogger(): EventEmitter<[never]>;
7
+ //# sourceMappingURL=registerAzureLogger.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/remote-cache",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,12 +29,13 @@
29
29
  "dependencies": {
30
30
  "@azure/msal-node-extensions": "^1.0.10",
31
31
  "@ms-cloudpack/retry": "^0.1.1",
32
- "@ms-cloudpack/task-reporter": "^0.14.0",
32
+ "@ms-cloudpack/task-reporter": "^0.14.1",
33
33
  "@ms-cloudpack/telemetry": "^0.5.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@azure/identity": "^4.0.0",
37
37
  "@azure/identity-cache-persistence": "^1.1.0",
38
+ "@azure/logger": "^1.0.0",
38
39
  "@azure/storage-blob": "^12.17.0",
39
40
  "@ms-cloudpack/eslint-plugin-internal": "*",
40
41
  "@ms-cloudpack/scripts": "*",
@@ -1,57 +0,0 @@
1
- import { createRequire as topLevelCreateRequire } from 'node:module';
2
- import topLevelPath from 'node:path';
3
- import topLevelUrl from 'node:url';
4
- const require = topLevelCreateRequire(import.meta.url);
5
- const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
- const __dirname = topLevelPath.dirname(__filename);
7
- var __create = Object.create;
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __getProtoOf = Object.getPrototypeOf;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
15
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
16
- }) : x)(function(x) {
17
- if (typeof require !== "undefined")
18
- return require.apply(this, arguments);
19
- throw Error('Dynamic require of "' + x + '" is not supported');
20
- });
21
- var __esm = (fn, res) => function __init() {
22
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
23
- };
24
- var __commonJS = (cb, mod) => function __require2() {
25
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
- };
27
- var __export = (target, all) => {
28
- for (var name in all)
29
- __defProp(target, name, { get: all[name], enumerable: true });
30
- };
31
- var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (let key of __getOwnPropNames(from))
34
- if (!__hasOwnProp.call(to, key) && key !== except)
35
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
- }
37
- return to;
38
- };
39
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
40
- // If the importer is in node compatibility mode or this is not an ESM
41
- // file that has been converted to a CommonJS file using a Babel-
42
- // compatible transform (i.e. "__esModule" has not been set), then set
43
- // "default" to the CommonJS "module.exports" for node compatibility.
44
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
45
- mod
46
- ));
47
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
-
49
- export {
50
- __name,
51
- __require,
52
- __esm,
53
- __commonJS,
54
- __export,
55
- __toESM,
56
- __toCommonJS
57
- };