@ms-cloudpack/remote-cache 0.11.1 → 0.11.2

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 (39) hide show
  1. package/dist/{AzureRemoteCacheClient-RQPQQPU4.js → AzureRemoteCacheClient-UFUB2BJI.js} +129 -187
  2. package/dist/{chunk-XND2VV4N.js → chunk-JNKRKLGF.js} +217 -7796
  3. package/dist/chunk-LEHUXQFL.js +7606 -0
  4. package/dist/chunk-N4V3CONX.js +80 -0
  5. package/dist/getCredential-EQJXGMRZ.js +20878 -0
  6. package/dist/index.js +45 -19
  7. package/lib/AzureAppRegistryClient.d.ts +1 -1
  8. package/lib/authentication/forks/identity-cache-persistence/cachePersistencePlugin.d.ts +34 -0
  9. package/lib/authentication/forks/identity-cache-persistence/platforms.d.ts +50 -0
  10. package/lib/authentication/forks/identity-cache-persistence/provider.d.ts +17 -0
  11. package/lib/authentication/forks/msal-node-extensions/error/PersistenceError.d.ts +37 -0
  12. package/lib/authentication/forks/msal-node-extensions/lock/CrossPlatformLock.d.ts +25 -0
  13. package/lib/authentication/forks/msal-node-extensions/lock/CrossPlatformLockOptions.d.ts +16 -0
  14. package/lib/authentication/forks/msal-node-extensions/persistence/BasePersistence.d.ts +6 -0
  15. package/lib/authentication/forks/msal-node-extensions/persistence/FilePersistence.d.ts +31 -0
  16. package/lib/authentication/forks/msal-node-extensions/persistence/FilePersistenceWithDataProtection.d.ts +30 -0
  17. package/lib/authentication/forks/msal-node-extensions/persistence/IPersistence.d.ts +17 -0
  18. package/lib/authentication/forks/msal-node-extensions/persistence/IPersistenceConfiguration.d.ts +16 -0
  19. package/lib/authentication/forks/msal-node-extensions/persistence/NapiRsKeyRingPersistence.d.ts +19 -0
  20. package/lib/authentication/forks/msal-node-extensions/persistence/PersistenceCachePlugin.d.ts +35 -0
  21. package/lib/authentication/forks/msal-node-extensions/utils/Constants.d.ts +44 -0
  22. package/lib/authentication/forks/msal-node-extensions/utils/TypeGuards.d.ts +10 -0
  23. package/lib/authentication/getAuthenticationRecord.d.ts +8 -0
  24. package/lib/authentication/getAuthenticationRecordPath.d.ts +7 -0
  25. package/lib/authentication/getCredential.d.ts +21 -0
  26. package/lib/authentication/lock-file/deleteAuthenticationLockFile.d.ts +7 -0
  27. package/lib/authentication/lock-file/doesLockFileExist.d.ts +6 -0
  28. package/lib/authentication/lock-file/getAuthenticationLockFilePath.d.ts +19 -0
  29. package/lib/authentication/lock-file/readAuthenticationLockFile.d.ts +6 -0
  30. package/lib/authentication/lock-file/tryCleaningLockFile.d.ts +6 -0
  31. package/lib/authentication/saveAuthenticationRecord.d.ts +9 -0
  32. package/lib/authentication/tokenCachePersistenceOptions.d.ts +9 -0
  33. package/lib/createAppRegistryClient.d.ts +1 -1
  34. package/lib/createRemoteCacheClient.d.ts +1 -1
  35. package/lib/index.d.ts +1 -0
  36. package/lib/registerAzureLogger.d.ts +6 -0
  37. package/lib/types/LoginMethod.d.ts +2 -0
  38. package/lib/utils/isProcessRunning.d.ts +7 -0
  39. package/package.json +9 -3
package/dist/index.js CHANGED
@@ -4,18 +4,20 @@ import topLevelUrl from 'node:url';
4
4
  const require = topLevelCreateRequire(import.meta.url);
5
5
  const __filename = topLevelUrl.fileURLToPath(import.meta.url);
6
6
  const __dirname = topLevelPath.dirname(__filename);
7
+ import {
8
+ require_commonjs as require_commonjs5,
9
+ require_commonjs2 as require_commonjs7,
10
+ require_dist
11
+ } from "./chunk-JNKRKLGF.js";
7
12
  import {
8
13
  init_tslib_es6,
9
14
  require_commonjs,
10
- require_commonjs2,
11
- require_commonjs3,
12
- require_commonjs4,
13
- require_commonjs5,
15
+ require_commonjs3 as require_commonjs2,
16
+ require_commonjs4 as require_commonjs3,
17
+ require_commonjs5 as require_commonjs4,
14
18
  require_commonjs6,
15
- require_commonjs7,
16
- require_dist,
17
19
  tslib_es6_exports
18
- } from "./chunk-XND2VV4N.js";
20
+ } from "./chunk-LEHUXQFL.js";
19
21
  import {
20
22
  __commonJS,
21
23
  __name,
@@ -3209,7 +3211,7 @@ var require_dist2 = __commonJS({
3209
3211
  return coreAuth.isSASCredential(credential) || coreAuth.isNamedKeyCredential(credential) || coreAuth.isTokenCredential(credential);
3210
3212
  }
3211
3213
  __name(isCredential, "isCredential");
3212
- var logger = logger$1.createClientLogger("data-tables");
3214
+ var logger2 = logger$1.createClientLogger("data-tables");
3213
3215
  function setTokenChallengeAuthenticationPolicy(pipeline, credential, scopes) {
3214
3216
  pipeline.removePolicy({ name: "bearerTokenPolicy" });
3215
3217
  pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
@@ -3321,7 +3323,7 @@ var require_dist2 = __commonJS({
3321
3323
  const credential = isCredential(credentialOrOptions) ? credentialOrOptions : void 0;
3322
3324
  const clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
3323
3325
  const internalPipelineOptions = Object.assign(Object.assign({}, clientOptions), { endpoint: clientOptions.endpoint || this.url, loggingOptions: {
3324
- logger: logger.info,
3326
+ logger: logger2.info,
3325
3327
  additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames]
3326
3328
  }, deserializationOptions: {
3327
3329
  parseXML: coreXml.parseXML
@@ -3384,7 +3386,7 @@ var require_dist2 = __commonJS({
3384
3386
  try {
3385
3387
  await this.table.create({ name }, updatedOptions);
3386
3388
  } catch (e) {
3387
- handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { logger, tableName: name }));
3389
+ handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { logger: logger2, tableName: name }));
3388
3390
  }
3389
3391
  });
3390
3392
  }
@@ -3400,7 +3402,7 @@ var require_dist2 = __commonJS({
3400
3402
  await this.table.delete(name, updatedOptions);
3401
3403
  } catch (e) {
3402
3404
  if (e.statusCode === 404) {
3403
- logger.info("TableServiceClient.deleteTable: Table doesn't exist");
3405
+ logger2.info("TableServiceClient.deleteTable: Table doesn't exist");
3404
3406
  } else {
3405
3407
  throw e;
3406
3408
  }
@@ -4118,7 +4120,7 @@ var require_dist2 = __commonJS({
4118
4120
  this.clientOptions = (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};
4119
4121
  this.allowInsecureConnection = (_a = this.clientOptions.allowInsecureConnection) !== null && _a !== void 0 ? _a : false;
4120
4122
  const internalPipelineOptions = Object.assign(Object.assign({}, this.clientOptions), { endpoint: this.clientOptions.endpoint || this.url, loggingOptions: {
4121
- logger: logger.info,
4123
+ logger: logger2.info,
4122
4124
  additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames]
4123
4125
  }, deserializationOptions: {
4124
4126
  parseXML: coreXml.parseXML
@@ -4176,7 +4178,7 @@ var require_dist2 = __commonJS({
4176
4178
  await this.table.delete(this.tableName, updatedOptions);
4177
4179
  } catch (e) {
4178
4180
  if (e.statusCode === 404) {
4179
- logger.info("TableClient.deleteTable: Table doesn't exist");
4181
+ logger2.info("TableClient.deleteTable: Table doesn't exist");
4180
4182
  } else {
4181
4183
  throw e;
4182
4184
  }
@@ -4214,7 +4216,7 @@ var require_dist2 = __commonJS({
4214
4216
  try {
4215
4217
  await this.table.create({ name: this.tableName }, updatedOptions);
4216
4218
  } catch (e) {
4217
- handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { logger, tableName: this.tableName }));
4219
+ handleTableAlreadyExists(e, Object.assign(Object.assign({}, updatedOptions), { logger: logger2, tableName: this.tableName }));
4218
4220
  }
4219
4221
  });
4220
4222
  }
@@ -4670,6 +4672,22 @@ var require_dist2 = __commonJS({
4670
4672
  }
4671
4673
  });
4672
4674
 
4675
+ // src/registerAzureLogger.ts
4676
+ import EventEmitter from "events";
4677
+ var logger = require_commonjs();
4678
+ function registerAzureLogger() {
4679
+ const emitter = new EventEmitter();
4680
+ logger.setLogLevel("verbose");
4681
+ logger.AzureLogger.log = (...messages) => {
4682
+ if (messages[0] === "azure:identity:verbose Node.js MSAL Open Browser =>" && messages[1].includes("Opening browser")) {
4683
+ const url = messages[1].split(" ")[3];
4684
+ emitter.emit("MsalBrowserOpen", url);
4685
+ }
4686
+ };
4687
+ return emitter;
4688
+ }
4689
+ __name(registerAzureLogger, "registerAzureLogger");
4690
+
4673
4691
  // src/decorators/InMemoryDecorator.ts
4674
4692
  var _InMemoryDecorator = class _InMemoryDecorator {
4675
4693
  cacheClient;
@@ -4755,15 +4773,19 @@ __name(createTableStorageUrl, "createTableStorageUrl");
4755
4773
  // src/createRemoteCacheClient.ts
4756
4774
  var import_storage_blob = __toESM(require_dist(), 1);
4757
4775
  async function createRemoteCacheClient(params) {
4776
+ const azureLogEventHandler = registerAzureLogger();
4758
4777
  const { context, options } = params;
4759
4778
  const { container, loginMethod, storageAccount, cachePath, tenantId } = options;
4760
4779
  const { telemetryClient } = context;
4761
4780
  return telemetryClient.tracer.startActiveSpan("CREATE_REMOTE_CACHE_CLIENT", async () => {
4762
- const { getCredential } = await import("@ms-cloudpack/auth");
4763
- const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-RQPQQPU4.js");
4781
+ const { getCredential } = await import("./getCredential-EQJXGMRZ.js");
4782
+ const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-UFUB2BJI.js");
4764
4783
  const { ReporterDecorator } = await import("./ReporterDecorator-VYNWC6CL.js");
4765
4784
  const { getListOfBlobs } = await import("./getListOfBlobs-BGP2V7PV.js");
4766
- const credential = await getCredential({ loginMethod, cachePath, tenantId }, context);
4785
+ const credential = await getCredential(
4786
+ { loginMethod, cachePath, tenantId },
4787
+ { ...context, azureLogger: azureLogEventHandler }
4788
+ );
4767
4789
  const blobStorageClient = new import_storage_blob.BlobServiceClient(createBlobStorageUrl(storageAccount), credential);
4768
4790
  const containerClient = blobStorageClient.getContainerClient(container);
4769
4791
  const listOfBlobs = await getListOfBlobs(containerClient, context);
@@ -4908,8 +4930,12 @@ var defaultStorageAccount = "cloudpackstorage";
4908
4930
  async function createAppRegistryClient(params) {
4909
4931
  const { context, options } = params;
4910
4932
  const { loginMethod, cachePath, tenantId = defaultTenantId, storageAccount = defaultStorageAccount } = options;
4911
- const { getCredential } = await import("@ms-cloudpack/auth");
4912
- const credential = await getCredential({ loginMethod, cachePath, tenantId }, context);
4933
+ const azureLogEventHandler = registerAzureLogger();
4934
+ const { getCredential } = await import("./getCredential-EQJXGMRZ.js");
4935
+ const credential = await getCredential(
4936
+ { loginMethod, cachePath, tenantId },
4937
+ { ...context, azureLogger: azureLogEventHandler }
4938
+ );
4913
4939
  const url = createTableStorageUrl(storageAccount);
4914
4940
  const client = new AzureAppRegistryClient(url, credential);
4915
4941
  return client;
@@ -1,7 +1,7 @@
1
1
  import type { AppRegistration, AppRegistrationVersion } from './types/AppRegistration.js';
2
2
  import type { AppRegistryClient } from './types/AppRegistryClient.js';
3
3
  import type { PageSettings } from '@azure/core-paging';
4
- import type { TokenCredential } from '@ms-cloudpack/auth';
4
+ import type { TokenCredential } from '@azure/identity';
5
5
  import type { PagedResult } from './types/PagedResult.js';
6
6
  export declare class AzureAppRegistryClient implements AppRegistryClient {
7
7
  readonly storageUrl: string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/identity-cache-persistence` package.
4
+ * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-cache-persistence/src/index.ts
5
+ */
6
+ import type { IdentityPlugin } from '@azure/identity';
7
+ /**
8
+ * A plugin that provides persistent token caching for `@azure/identity`
9
+ * credentials. The plugin API is compatible with `@azure/identity` versions
10
+ * 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
11
+ * function, imported from `@azure/identity`.
12
+ *
13
+ * In order to enable this functionality, you must also pass
14
+ * `tokenCachePersistenceOptions` to your credential constructors with an
15
+ * `enabled` property set to true.
16
+ *
17
+ * Example:
18
+ *
19
+ * ```javascript
20
+ * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
21
+ * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
22
+ *
23
+ * // Load the plugin
24
+ * useIdentityPlugin(cachePersistencePlugin);
25
+ *
26
+ * const credential = new DeviceCodeCredential({
27
+ * tokenCachePersistenceOptions: {
28
+ * enabled: true
29
+ * }
30
+ * });
31
+ * ```
32
+ */
33
+ export declare const cachePersistencePlugin: IdentityPlugin;
34
+ //# sourceMappingURL=cachePersistencePlugin.d.ts.map
@@ -0,0 +1,50 @@
1
+ import type { TokenCachePersistenceOptions } from '@azure/identity';
2
+ import type { IPersistence } from '../msal-node-extensions/persistence/IPersistence.js';
3
+ /**
4
+ * Dictionary of values that we use as default as we discover, pick and enable the persistence layer.
5
+ * @internal
6
+ */
7
+ export declare const defaultMsalValues: {
8
+ tokenCache: {
9
+ name: string;
10
+ directory: string;
11
+ };
12
+ keyRing: {
13
+ label: string;
14
+ schema: string;
15
+ collection: string;
16
+ attributes: {
17
+ MsalClientID: string;
18
+ 'Microsoft.Developer.IdentityService': string;
19
+ };
20
+ service: string;
21
+ account: string;
22
+ };
23
+ keyChain: {
24
+ service: string;
25
+ account: string;
26
+ };
27
+ };
28
+ /**
29
+ * Options that are used by the underlying MSAL cache provider.
30
+ * @internal
31
+ */
32
+ export type MsalPersistenceOptions = Omit<TokenCachePersistenceOptions, 'enabled'>;
33
+ /**
34
+ * A function that returns a persistent token cache instance.
35
+ * @internal
36
+ */
37
+ type MsalPersistenceFactory = (options?: MsalPersistenceOptions) => Promise<IPersistence>;
38
+ /**
39
+ * Set of the platforms we attempt to deliver persistence on.
40
+ *
41
+ * - On Windows we use DPAPI.
42
+ * - On OSX (Darwin) and Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
43
+ *
44
+ * Other platforms _are not supported_ at this time.
45
+ *
46
+ * @internal
47
+ */
48
+ export declare const msalPersistencePlatforms: Partial<Record<NodeJS.Platform, MsalPersistenceFactory>>;
49
+ export {};
50
+ //# sourceMappingURL=platforms.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/identity-cache-persistence` package.
4
+ * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-cache-persistence/src/provider.ts
5
+ */
6
+ import type { MsalPersistenceOptions } from './platforms.js';
7
+ import type { ICachePlugin as CachePlugin } from '@azure/msal-node';
8
+ import type { IPersistence } from '../msal-node-extensions/persistence/IPersistence.js';
9
+ /**
10
+ * This is used to gain access to the underlying Persistence instance, which we use for testing
11
+ *
12
+ * @returns a raw persistence instance
13
+ * @internal
14
+ */
15
+ export declare function createPersistence(options: MsalPersistenceOptions): Promise<IPersistence>;
16
+ export declare function createPersistenceCachePlugin(options?: MsalPersistenceOptions): Promise<CachePlugin>;
17
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/error/PersistenceError.ts
5
+ */
6
+ /**
7
+ * Error thrown when trying to write MSAL cache to persistence.
8
+ */
9
+ export declare class PersistenceError extends Error {
10
+ errorCode: string;
11
+ errorMessage: string;
12
+ constructor(errorCode: string, errorMessage: string);
13
+ /**
14
+ * Error thrown when trying to access the file system.
15
+ */
16
+ static createFileSystemError(errorCode: string, errorMessage: string): PersistenceError;
17
+ /**
18
+ * Error thrown when trying to encrypt or decrypt data using DPAPI on Windows.
19
+ */
20
+ static createFilePersistenceWithDPAPIError(errorMessage: string): PersistenceError;
21
+ /**
22
+ * Error thrown when using the cross platform lock.
23
+ */
24
+ static createCrossPlatformLockError(errorMessage: string): PersistenceError;
25
+ /**
26
+ * Error thrown when trying to write, load, or delete data from NapiRsKeyRingPersistence.
27
+ */
28
+ static createNapiRsKeyRingPersistenceError(errorMessage: string): PersistenceError;
29
+ /**
30
+ * Throw cache persistence error
31
+ *
32
+ * @param errorMessage string
33
+ * @returns PersistenceError
34
+ */
35
+ static createCachePersistenceError(errorMessage: string): PersistenceError;
36
+ }
37
+ //# sourceMappingURL=PersistenceError.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type { CrossPlatformLockOptions } from './CrossPlatformLockOptions.js';
2
+ import type { Logger } from '@azure/msal-common';
3
+ /**
4
+ * Cross-process lock that works on all platforms.
5
+ */
6
+ export declare class CrossPlatformLock {
7
+ private readonly lockFilePath;
8
+ private lockFileHandle;
9
+ private readonly retryNumber;
10
+ private readonly retryDelay;
11
+ private logger;
12
+ constructor(lockFilePath: string, logger: Logger, lockOptions?: CrossPlatformLockOptions);
13
+ /**
14
+ * Locks cache from read or writes by creating file with same path and name as
15
+ * cache file but with .lockfile extension. If another process has already created
16
+ * the lockfile, will back off and retry based on configuration settings set by CrossPlatformLockOptions
17
+ */
18
+ lock(): Promise<void>;
19
+ /**
20
+ * unlocks cache file by deleting .lockfile.
21
+ */
22
+ unlock(): Promise<void>;
23
+ private sleep;
24
+ }
25
+ //# sourceMappingURL=CrossPlatformLock.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/lock/CrossPlatformLockOptions.ts
5
+ */
6
+ /**
7
+ * Options for CrossPlatform lock.
8
+ *
9
+ * retryNumber: Numbers of times we should try to acquire a lock. Defaults to 500.
10
+ * retryDelay: Time to wait before trying to retry a lock acquisition. Defaults to 100 ms.
11
+ */
12
+ export type CrossPlatformLockOptions = {
13
+ retryNumber: number;
14
+ retryDelay: number;
15
+ };
16
+ //# sourceMappingURL=CrossPlatformLockOptions.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { IPersistence } from './IPersistence.js';
2
+ export declare abstract class BasePersistence {
3
+ abstract createForPersistenceValidation(): Promise<IPersistence>;
4
+ verifyPersistence(): Promise<boolean>;
5
+ }
6
+ //# sourceMappingURL=BasePersistence.d.ts.map
@@ -0,0 +1,31 @@
1
+ import type { IPersistence } from './IPersistence.js';
2
+ import type { LoggerOptions } from '@azure/msal-common';
3
+ import { Logger } from '@azure/msal-common';
4
+ import { BasePersistence } from './BasePersistence.js';
5
+ /**
6
+ * Reads and writes data to file specified by file location. File contents are not
7
+ * encrypted.
8
+ *
9
+ * If file or directory has not been created, it FilePersistence.create() will create
10
+ * file and any directories in the path recursively.
11
+ */
12
+ export declare class FilePersistence extends BasePersistence implements IPersistence {
13
+ private filePath;
14
+ private logger;
15
+ private constructor();
16
+ static create(fileLocation: string, loggerOptions?: LoggerOptions): Promise<FilePersistence>;
17
+ save(contents: string): Promise<void>;
18
+ saveBuffer(contents: Uint8Array): Promise<void>;
19
+ load(): Promise<string | null>;
20
+ loadBuffer(): Promise<Uint8Array>;
21
+ delete(): Promise<boolean>;
22
+ getFilePath(): string;
23
+ reloadNecessary(lastSync: number): Promise<boolean>;
24
+ getLogger(): Logger;
25
+ createForPersistenceValidation(): Promise<FilePersistence>;
26
+ private static createDefaultLoggerOptions;
27
+ private timeLastModified;
28
+ private createCacheFile;
29
+ private createFileDirectory;
30
+ }
31
+ //# sourceMappingURL=FilePersistence.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/FilePersistenceWithDataProtection.ts
5
+ */
6
+ import type { IPersistence } from './IPersistence.js';
7
+ import { type DataProtectionScope } from 'node-dpapi-prebuilt';
8
+ import type { Logger, LoggerOptions } from '@azure/msal-common';
9
+ import { BasePersistence } from './BasePersistence.js';
10
+ /**
11
+ * Uses CryptProtectData and CryptUnprotectData on Windows to encrypt and decrypt file contents.
12
+ *
13
+ * scope: Scope of the data protection. Either local user or the current machine
14
+ * optionalEntropy: Password or other additional entropy used to encrypt the data
15
+ */
16
+ export declare class FilePersistenceWithDataProtection extends BasePersistence implements IPersistence {
17
+ private filePersistence;
18
+ private scope;
19
+ private optionalEntropy;
20
+ private constructor();
21
+ static create(fileLocation: string, scope: DataProtectionScope, optionalEntropy?: string, loggerOptions?: LoggerOptions): Promise<FilePersistenceWithDataProtection>;
22
+ save(contents: string): Promise<void>;
23
+ load(): Promise<string | null>;
24
+ delete(): Promise<boolean>;
25
+ reloadNecessary(lastSync: number): Promise<boolean>;
26
+ getFilePath(): string;
27
+ getLogger(): Logger;
28
+ createForPersistenceValidation(): Promise<FilePersistenceWithDataProtection>;
29
+ }
30
+ //# sourceMappingURL=FilePersistenceWithDataProtection.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/IPersistence.ts
5
+ */
6
+ import type { Logger } from '@azure/msal-common';
7
+ export interface IPersistence {
8
+ save(contents: string): Promise<void>;
9
+ load(): Promise<string | null>;
10
+ delete(): Promise<boolean>;
11
+ reloadNecessary(lastSync: number): Promise<boolean>;
12
+ getFilePath(): string;
13
+ getLogger(): Logger;
14
+ verifyPersistence(): Promise<boolean>;
15
+ createForPersistenceValidation(): Promise<IPersistence>;
16
+ }
17
+ //# sourceMappingURL=IPersistence.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/IPersistenceConfiguration.ts
5
+ */
6
+ import type { LoggerOptions } from '@azure/msal-common';
7
+ import type { DataProtectionScope } from 'node-dpapi-prebuilt';
8
+ export interface IPersistenceConfiguration {
9
+ cachePath?: string;
10
+ dataProtectionScope?: DataProtectionScope;
11
+ serviceName?: string;
12
+ accountName?: string;
13
+ usePlaintextFileOnLinux?: boolean;
14
+ loggerOptions?: LoggerOptions;
15
+ }
16
+ //# sourceMappingURL=IPersistenceConfiguration.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { Logger, LoggerOptions } from '@azure/msal-common';
2
+ import { BasePersistence } from './BasePersistence.js';
3
+ import type { IPersistence } from './IPersistence.js';
4
+ export declare class NapiRsKeyRingPersistence extends BasePersistence implements IPersistence {
5
+ readonly service: string;
6
+ readonly account: string;
7
+ private readonly entry;
8
+ private readonly filePersistence;
9
+ private constructor();
10
+ static create(fileLocation: string, serviceName: string, accountName: string, loggerOptions?: LoggerOptions): Promise<NapiRsKeyRingPersistence>;
11
+ save(contents: string): Promise<void>;
12
+ load(): Promise<string | null>;
13
+ delete(): Promise<boolean>;
14
+ reloadNecessary(lastSync: number): Promise<boolean>;
15
+ getFilePath(): string;
16
+ getLogger(): Logger;
17
+ createForPersistenceValidation(): Promise<IPersistence>;
18
+ }
19
+ //# sourceMappingURL=NapiRsKeyRingPersistence.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/PersistenceCachePlugin.ts
5
+ */
6
+ import type { IPersistence } from './IPersistence.js';
7
+ import type { CrossPlatformLockOptions } from '../lock/CrossPlatformLockOptions.js';
8
+ import type { TokenCacheContext, ICachePlugin } from '@azure/msal-common';
9
+ /**
10
+ * MSAL cache plugin which enables callers to write the MSAL cache to disk on Windows,
11
+ * macOs, and Linux.
12
+ */
13
+ export declare class PersistenceCachePlugin implements ICachePlugin {
14
+ persistence: IPersistence;
15
+ lastSync: number;
16
+ currentCache: string | null;
17
+ lockFilePath: string;
18
+ private crossPlatformLock;
19
+ private logger;
20
+ constructor(persistence: IPersistence, lockOptions?: CrossPlatformLockOptions);
21
+ /**
22
+ * Reads from storage and saves an in-memory copy. If persistence has not been updated
23
+ * since last time data was read, in memory copy is used.
24
+ *
25
+ * If cacheContext.cacheHasChanged === true, then file lock is created and not deleted until
26
+ * afterCacheAccess() is called, to prevent the cache file from changing in between
27
+ * beforeCacheAccess() and afterCacheAccess().
28
+ */
29
+ beforeCacheAccess(cacheContext: TokenCacheContext): Promise<void>;
30
+ /**
31
+ * Writes to storage if MSAL in memory copy of cache has been changed.
32
+ */
33
+ afterCacheAccess(cacheContext: TokenCacheContext): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=PersistenceCachePlugin.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/utils/Constants.ts
5
+ */
6
+ export declare const Constants: {
7
+ /**
8
+ * An existing file was the target of an operation that required that the target not exist
9
+ */
10
+ EEXIST_ERROR: string;
11
+ /**
12
+ * No such file or directory: Commonly raised by fs operations to indicate that a component
13
+ * of the specified pathname does not exist. No entity (file or directory) could be found
14
+ * by the given path
15
+ */
16
+ ENOENT_ERROR: string;
17
+ /**
18
+ * Operation not permitted. An attempt was made to perform an operation that requires
19
+ * elevated privileges.
20
+ */
21
+ EPERM_ERROR: string;
22
+ /**
23
+ * Default service name for using MSAL Keytar
24
+ */
25
+ DEFAULT_SERVICE_NAME: string;
26
+ /**
27
+ * Test data used to verify underlying persistence mechanism
28
+ */
29
+ PERSISTENCE_TEST_DATA: string;
30
+ DEFAULT_CACHE_FILE_NAME: string;
31
+ };
32
+ export declare const Platform: {
33
+ readonly WINDOWS: "win32";
34
+ readonly LINUX: "linux";
35
+ readonly MACOS: "darwin";
36
+ };
37
+ export type Platform = (typeof Platform)[keyof typeof Platform];
38
+ export declare const ErrorCodes: {
39
+ readonly INTERATION_REQUIRED_ERROR_CODE: "interaction_required";
40
+ readonly SERVER_UNAVAILABLE: "server_unavailable";
41
+ readonly UNKNOWN: "unknown_error";
42
+ };
43
+ export type ErrorCodes = (typeof ErrorCodes)[keyof typeof ErrorCodes];
44
+ //# sourceMappingURL=Constants.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * FORK NOTE:
3
+ * This file has been copied over from the `@azure/msal-node-extensions` package.
4
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/utils/TypeGuards.ts
5
+ */
6
+ /**
7
+ * Returns whether or not the given object is a Node.js error
8
+ */
9
+ export declare const isNodeError: (error: unknown) => error is NodeJS.ErrnoException;
10
+ //# sourceMappingURL=TypeGuards.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { type AuthenticationRecord } from '@azure/identity';
2
+ /**
3
+ * Retrieves the authentication record from Cloudpack's global cache folder.
4
+ * @param cachePath - The path to Cloudpack's cache folder.
5
+ * @returns - The authentication record if it exists; otherwise, returns `undefined`.
6
+ */
7
+ export declare function getAuthenticationRecord(cachePath: string): AuthenticationRecord | undefined;
8
+ //# sourceMappingURL=getAuthenticationRecord.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Constructs and returns the full path to the authentication record file within the specified cache folder.
3
+ * @param cachePath - The path to Cloudpack's cache folder.
4
+ * @returns - The full path to the authentication record file.
5
+ */
6
+ export declare function getAuthenticationRecordPath(cachePath: string): string;
7
+ //# sourceMappingURL=getAuthenticationRecordPath.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { type TokenCredential } from '@azure/identity';
2
+ import type { LoginMethod } from '../types/LoginMethod.js';
3
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
4
+ import type EventEmitter from 'events';
5
+ import type { TelemetryClient } from '@ms-cloudpack/telemetry';
6
+ /**
7
+ * Gets a credential for the given login method.
8
+ * If the login method is 'azure-cli', it will return an AzureCliCredential.
9
+ * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.
10
+ * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.
11
+ */
12
+ export declare function getCredential(options: {
13
+ loginMethod: LoginMethod;
14
+ cachePath: string;
15
+ tenantId?: string;
16
+ }, context: {
17
+ reporter: TaskReporter;
18
+ azureLogger: EventEmitter;
19
+ telemetryClient: TelemetryClient;
20
+ }): Promise<TokenCredential>;
21
+ //# sourceMappingURL=getCredential.d.ts.map
@@ -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,19 @@
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
+ /**
12
+ * Local application data folder
13
+ * Expected values:
14
+ * - Darwin: `/Users/user/`
15
+ * - Windows 8+: `C:\Users\user\AppData\Local`
16
+ * - Linux: `/home/user/.local/share`
17
+ */
18
+ export declare function getIdentityServiceCachePath(): string;
19
+ //# 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