@ms-cloudpack/remote-cache 0.5.1 → 0.5.3

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,5 +1,5 @@
1
1
  import { AzureCliCredential, DeviceCodeCredential, InteractiveBrowserCredential, useIdentityPlugin, } from '@azure/identity';
2
- import { cachePersistencePlugin } from '../cache-persistance/cachePersistencePlugin.js';
2
+ import { cachePersistencePlugin } from '@azure/identity-cache-persistence';
3
3
  import { getAuthenticationRecord } from './getAuthenticationRecord.js';
4
4
  import { saveAuthenticationRecord } from './saveAuthenticationRecord.js';
5
5
  const tokenCachePersistenceOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,4BAA4B,GAAiC;IACjE,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF,SAAS,qBAAqB,CAAC,WAAwB,EAAE,oBAA2C;IAClG,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,IAAI,4BAA4B,CAAC;gBACtC,WAAW,EAAE,uBAAuB;gBACpC,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL,KAAK,aAAa;YAChB,OAAO,IAAI,oBAAoB,CAAC;gBAC9B,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAwB,EAAE,SAAiB;IAC7E,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;IAE1C,IAAI,oBAAoB,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAE9D,MAAM,UAAU,GAAG,qBAAqB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAE5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAE7E,IAAI,WAAW,IAAI,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACV,kKAAkK,CACnK,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,oCAAoC,CAAC;QAC1D,oBAAoB,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACnE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEtD,8EAA8E;QAC9E,kLAAkL;QAClL,MAAM,uBAAuB,GAAoB;YAC/C,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;SACF,CAAC;QAEF,IAAI,oBAAoB,EAAE,CAAC;YACzB,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import {\n AzureCliCredential,\n DeviceCodeCredential,\n InteractiveBrowserCredential,\n useIdentityPlugin,\n type AuthenticationRecord,\n type TokenCachePersistenceOptions,\n type TokenCredential,\n} from '@azure/identity';\nimport type { LoginMethod } from '../types/LoginMethod.js';\nimport { cachePersistencePlugin } from '../cache-persistance/cachePersistencePlugin.js';\nimport { getAuthenticationRecord } from './getAuthenticationRecord.js';\nimport { saveAuthenticationRecord } from './saveAuthenticationRecord.js';\n\nconst tokenCachePersistenceOptions: TokenCachePersistenceOptions = {\n enabled: true,\n name: 'cloudpack',\n};\n\nfunction getCredentialInternal(loginMethod: LoginMethod, authenticationRecord?: AuthenticationRecord) {\n switch (loginMethod) {\n case 'interactive':\n return new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n case 'device-code':\n return new DeviceCodeCredential({\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n default:\n throw new Error(`Invalid login method: ${loginMethod}`);\n }\n}\n\n/**\n * Gets a credential for the given login method.\n * If the login method is 'azure-cli', it will return an AzureCliCredential.\n * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.\n * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.\n */\nexport async function getCredential(loginMethod: LoginMethod, cachePath: string) {\n if (loginMethod == 'azure-cli') {\n return new AzureCliCredential();\n }\n\n useIdentityPlugin(cachePersistencePlugin);\n\n let authenticationRecord = getAuthenticationRecord(cachePath);\n\n const credential = getCredentialInternal(loginMethod, authenticationRecord);\n\n if (!authenticationRecord) {\n console.warn('Cloudpack requires authentication to access Azure resources.');\n\n if (loginMethod == 'interactive') {\n console.warn(\n \"Prepare to sign in – we're launching a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process.\",\n );\n }\n\n const storageScope = 'https://storage.azure.com/.default';\n authenticationRecord = await credential.authenticate(storageScope);\n const token = await credential.getToken(storageScope);\n\n // Creating a custom credential with the token from the authentication record.\n // This ensures that we can use the token without having to authenticate again. Otherwise, we may have to authenticate again to get the token which can create concurrency issues.\n const storageCustomCredential: TokenCredential = {\n getToken: async () => {\n return Promise.resolve(token);\n },\n };\n\n if (authenticationRecord) {\n saveAuthenticationRecord(cachePath, authenticationRecord);\n }\n\n return storageCustomCredential;\n }\n\n return credential;\n}\n"]}
1
+ {"version":3,"file":"getCredential.js","sourceRoot":"","sources":["../../src/authentication/getCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,4BAA4B,GAAiC;IACjE,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF,SAAS,qBAAqB,CAAC,WAAwB,EAAE,oBAA2C;IAClG,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,IAAI,4BAA4B,CAAC;gBACtC,WAAW,EAAE,uBAAuB;gBACpC,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL,KAAK,aAAa;YAChB,OAAO,IAAI,oBAAoB,CAAC;gBAC9B,oBAAoB;gBACpB,4BAA4B;aAC7B,CAAC,CAAC;QACL;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAwB,EAAE,SAAiB;IAC7E,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;IAE1C,IAAI,oBAAoB,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAE9D,MAAM,UAAU,GAAG,qBAAqB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAE5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAE7E,IAAI,WAAW,IAAI,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACV,kKAAkK,CACnK,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,oCAAoC,CAAC;QAC1D,oBAAoB,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACnE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEtD,8EAA8E;QAC9E,kLAAkL;QAClL,MAAM,uBAAuB,GAAoB;YAC/C,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;SACF,CAAC;QAEF,IAAI,oBAAoB,EAAE,CAAC;YACzB,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import {\n AzureCliCredential,\n DeviceCodeCredential,\n InteractiveBrowserCredential,\n useIdentityPlugin,\n type AuthenticationRecord,\n type TokenCachePersistenceOptions,\n type TokenCredential,\n} from '@azure/identity';\nimport type { LoginMethod } from '../types/LoginMethod.js';\nimport { cachePersistencePlugin } from '@azure/identity-cache-persistence';\nimport { getAuthenticationRecord } from './getAuthenticationRecord.js';\nimport { saveAuthenticationRecord } from './saveAuthenticationRecord.js';\n\nconst tokenCachePersistenceOptions: TokenCachePersistenceOptions = {\n enabled: true,\n name: 'cloudpack',\n};\n\nfunction getCredentialInternal(loginMethod: LoginMethod, authenticationRecord?: AuthenticationRecord) {\n switch (loginMethod) {\n case 'interactive':\n return new InteractiveBrowserCredential({\n redirectUri: 'http://localhost:1337',\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n case 'device-code':\n return new DeviceCodeCredential({\n authenticationRecord,\n tokenCachePersistenceOptions,\n });\n default:\n throw new Error(`Invalid login method: ${loginMethod}`);\n }\n}\n\n/**\n * Gets a credential for the given login method.\n * If the login method is 'azure-cli', it will return an AzureCliCredential.\n * Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.\n * If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.\n */\nexport async function getCredential(loginMethod: LoginMethod, cachePath: string) {\n if (loginMethod == 'azure-cli') {\n return new AzureCliCredential();\n }\n\n useIdentityPlugin(cachePersistencePlugin);\n\n let authenticationRecord = getAuthenticationRecord(cachePath);\n\n const credential = getCredentialInternal(loginMethod, authenticationRecord);\n\n if (!authenticationRecord) {\n console.warn('Cloudpack requires authentication to access Azure resources.');\n\n if (loginMethod == 'interactive') {\n console.warn(\n \"Prepare to sign in – we're launching a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process.\",\n );\n }\n\n const storageScope = 'https://storage.azure.com/.default';\n authenticationRecord = await credential.authenticate(storageScope);\n const token = await credential.getToken(storageScope);\n\n // Creating a custom credential with the token from the authentication record.\n // This ensures that we can use the token without having to authenticate again. Otherwise, we may have to authenticate again to get the token which can create concurrency issues.\n const storageCustomCredential: TokenCredential = {\n getToken: async () => {\n return Promise.resolve(token);\n },\n };\n\n if (authenticationRecord) {\n saveAuthenticationRecord(cachePath, authenticationRecord);\n }\n\n return storageCustomCredential;\n }\n\n return credential;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/remote-cache",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,13 +30,12 @@
30
30
  "lib/**/!(*.test.*)"
31
31
  ],
32
32
  "dependencies": {
33
- "@azure/msal-node": "^2.6.0",
34
- "@azure/msal-node-extensions": "^1.0.10",
35
- "@ms-cloudpack/task-reporter": "^0.11.2",
36
- "@ms-cloudpack/telemetry": "^0.4.6",
37
- "@ms-cloudpack/retry": "^0.1.1",
38
- "@azure/identity": "^3.4.0",
33
+ "@azure/identity": "^4.0.0",
34
+ "@azure/identity-cache-persistence": "^1.1.0",
39
35
  "@azure/storage-blob": "^12.17.0",
36
+ "@ms-cloudpack/retry": "^0.1.1",
37
+ "@ms-cloudpack/task-reporter": "^0.11.2",
38
+ "@ms-cloudpack/telemetry": "^0.4.8",
40
39
  "backfill": "^6.2.1",
41
40
  "backfill-config": "^6.4.1"
42
41
  }
@@ -1,32 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- import type { IdentityPlugin } from '@azure/identity';
5
- /**
6
- * A plugin that provides persistent token caching for `@azure/identity`
7
- * credentials. The plugin API is compatible with `@azure/identity` versions
8
- * 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
9
- * function, imported from `@azure/identity`.
10
- *
11
- * In order to enable this functionality, you must also pass
12
- * `tokenCachePersistenceOptions` to your credential constructors with an
13
- * `enabled` property set to true.
14
- *
15
- * Example:
16
- *
17
- * ```javascript
18
- * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
19
- * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
20
- *
21
- * // Load the plugin
22
- * useIdentityPlugin(cachePersistencePlugin);
23
- *
24
- * const credential = new DeviceCodeCredential({
25
- * tokenCachePersistenceOptions: {
26
- * enabled: true
27
- * }
28
- * });
29
- * ```
30
- */
31
- export declare const cachePersistencePlugin: IdentityPlugin;
32
- //# sourceMappingURL=cachePersistencePlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cachePersistencePlugin.d.ts","sourceRoot":"","sources":["../../src/cache-persistance/cachePersistencePlugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,eAAO,MAAM,sBAAsB,EAAE,cAGpC,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- import { createPersistenceCachePlugin } from './provider.js';
5
- /**
6
- * A plugin that provides persistent token caching for `@azure/identity`
7
- * credentials. The plugin API is compatible with `@azure/identity` versions
8
- * 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
9
- * function, imported from `@azure/identity`.
10
- *
11
- * In order to enable this functionality, you must also pass
12
- * `tokenCachePersistenceOptions` to your credential constructors with an
13
- * `enabled` property set to true.
14
- *
15
- * Example:
16
- *
17
- * ```javascript
18
- * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
19
- * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
20
- *
21
- * // Load the plugin
22
- * useIdentityPlugin(cachePersistencePlugin);
23
- *
24
- * const credential = new DeviceCodeCredential({
25
- * tokenCachePersistenceOptions: {
26
- * enabled: true
27
- * }
28
- * });
29
- * ```
30
- */
31
- export const cachePersistencePlugin = (context) => {
32
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
33
- context.cachePluginControl.setPersistence(createPersistenceCachePlugin);
34
- };
35
- //# sourceMappingURL=cachePersistencePlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cachePersistencePlugin.js","sourceRoot":"","sources":["../../src/cache-persistance/cachePersistencePlugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAmB,CAAC,OAAO,EAAE,EAAE;IAChE,6IAA6I;IAC5I,OAAe,CAAC,kBAAkB,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;AACnF,CAAC,CAAC","sourcesContent":["/**\n * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence\n */\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// import { AzurePluginContext } from '../../identity/src/plugins/provider';\nimport type { IdentityPlugin } from '@azure/identity';\nimport { createPersistenceCachePlugin } from './provider.js';\n\n/**\n * A plugin that provides persistent token caching for `@azure/identity`\n * credentials. The plugin API is compatible with `@azure/identity` versions\n * 2.0.0 and later. Load this plugin using the `useIdentityPlugin`\n * function, imported from `@azure/identity`.\n *\n * In order to enable this functionality, you must also pass\n * `tokenCachePersistenceOptions` to your credential constructors with an\n * `enabled` property set to true.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, DeviceCodeCredential } from \"@azure/identity\";\n * import { cachePersistencePlugin } from \"@azure/identity-cache-persistence\";\n *\n * // Load the plugin\n * useIdentityPlugin(cachePersistencePlugin);\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true\n * }\n * });\n * ```\n */\n\nexport const cachePersistencePlugin: IdentityPlugin = (context) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n (context as any).cachePluginControl.setPersistence(createPersistenceCachePlugin);\n};\n"]}
@@ -1,55 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- /// <reference types="node" resolution-mode="require"/>
5
- import { type IPersistence as Persistence } from '@azure/msal-node-extensions';
6
- import type { TokenCachePersistenceOptions } from '@azure/identity';
7
- /**
8
- * Dictionary of values that we use as default as we discover, pick and enable the persistence layer.
9
- * @internal
10
- */
11
- export declare const defaultMsalValues: {
12
- tokenCache: {
13
- name: string;
14
- directory: string;
15
- };
16
- keyRing: {
17
- label: string;
18
- schema: string;
19
- collection: string;
20
- attributes: {
21
- MsalClientID: string;
22
- 'Microsoft.Developer.IdentityService': string;
23
- };
24
- service: string;
25
- account: string;
26
- };
27
- keyChain: {
28
- service: string;
29
- account: string;
30
- };
31
- };
32
- /**
33
- * Options that are used by the underlying MSAL cache provider.
34
- * @internal
35
- */
36
- export type MsalPersistenceOptions = Omit<TokenCachePersistenceOptions, 'enabled'>;
37
- /**
38
- * A function that returns a persistent token cache instance.
39
- * @internal
40
- */
41
- type MsalPersistenceFactory = (options?: MsalPersistenceOptions) => Promise<Persistence>;
42
- /**
43
- * Set of the platforms we attempt to deliver persistence on.
44
- *
45
- * - On Windows we use DPAPI.
46
- * - On OSX (Darwin), we try to use the system's Keychain, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
47
- * - On Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
48
- *
49
- * Other platforms _are not supported_ at this time.
50
- *
51
- * @internal
52
- */
53
- export declare const msalPersistencePlatforms: Partial<Record<NodeJS.Platform, MsalPersistenceFactory>>;
54
- export {};
55
- //# sourceMappingURL=platforms.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../../src/cache-persistance/platforms.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAKH,OAAO,EAML,KAAK,YAAY,IAAI,WAAW,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAapE;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;CAwB7B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;AAEnF;;;GAGG;AACH,KAAK,sBAAsB,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAazF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CA2C7F,CAAC"}
@@ -1,109 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- // Copyright (c) Microsoft Corporation.
5
- // Licensed under the MIT license.
6
- import * as path from 'path';
7
- import { DataProtectionScope, FilePersistence, FilePersistenceWithDataProtection, KeychainPersistence, LibSecretPersistence, } from '@azure/msal-node-extensions';
8
- /**
9
- * Local application data folder
10
- * Expected values:
11
- * - Darwin: '/Users/user/'
12
- * - Windows 8+: 'C:\Users\user\AppData\Local'
13
- * - Linux: '/home/user/.local/share'
14
- * @internal
15
- */
16
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
- const localApplicationDataFolder = process.env.APPDATA?.replace?.(/(.Roaming)*$/, '\\Local') ?? process.env.HOME;
18
- /**
19
- * Dictionary of values that we use as default as we discover, pick and enable the persistence layer.
20
- * @internal
21
- */
22
- export const defaultMsalValues = {
23
- tokenCache: {
24
- name: 'msal.cache',
25
- // Expected values:
26
- // - Darwin: '/Users/user/.IdentityService'
27
- // - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService'
28
- // - Linux: '/home/user/.IdentityService'
29
- directory: path.join(localApplicationDataFolder, '.IdentityService'),
30
- },
31
- keyRing: {
32
- label: 'MSALCache',
33
- schema: 'msal.cache',
34
- collection: 'default',
35
- attributes: {
36
- MsalClientID: 'Microsoft.Developer.IdentityService',
37
- 'Microsoft.Developer.IdentityService': '1.0.0.0',
38
- },
39
- service: 'Microsoft.Developer.IdentityService',
40
- account: 'MSALCache',
41
- },
42
- keyChain: {
43
- service: 'Microsoft.Developer.IdentityService',
44
- account: 'MSALCache',
45
- },
46
- };
47
- /**
48
- * Expected responses:
49
- * - Darwin: '/Users/user/.IdentityService/<name>'
50
- * - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService\<name>'
51
- * - Linux: '/home/user/.IdentityService/<name>'
52
- * @internal
53
- */
54
- function getPersistencePath(name) {
55
- return path.join(defaultMsalValues.tokenCache.directory, name);
56
- }
57
- /**
58
- * Set of the platforms we attempt to deliver persistence on.
59
- *
60
- * - On Windows we use DPAPI.
61
- * - On OSX (Darwin), we try to use the system's Keychain, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
62
- * - On Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
63
- *
64
- * Other platforms _are not supported_ at this time.
65
- *
66
- * @internal
67
- */
68
- export const msalPersistencePlatforms = {
69
- win32: ({ name = defaultMsalValues.tokenCache.name } = {}) => FilePersistenceWithDataProtection.create(getPersistencePath(name), DataProtectionScope.CurrentUser),
70
- darwin: async (options = {}) => {
71
- const { name, unsafeAllowUnencryptedStorage } = options;
72
- const { service, account } = defaultMsalValues.keyChain;
73
- const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
74
- try {
75
- const persistence = await KeychainPersistence.create(persistencePath, service, account);
76
- // If we don't encounter an error when trying to read from the keychain, then we should be good to go.
77
- await persistence.load();
78
- return persistence;
79
- }
80
- catch {
81
- // If we got an error while trying to read from the keyring,
82
- // we will proceed only if the user has specified that unencrypted storage is allowed.
83
- if (!unsafeAllowUnencryptedStorage) {
84
- throw new Error('Unable to read from the macOS Keychain.');
85
- }
86
- return FilePersistence.create(persistencePath);
87
- }
88
- },
89
- linux: async (options = {}) => {
90
- const { name, unsafeAllowUnencryptedStorage } = options;
91
- const { service, account } = defaultMsalValues.keyRing;
92
- const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
93
- try {
94
- const persistence = await LibSecretPersistence.create(persistencePath, service, account);
95
- // If we don't encounter an error when trying to read from the keyring, then we should be good to go.
96
- await persistence.load();
97
- return persistence;
98
- }
99
- catch {
100
- // If we got an error while trying to read from the keyring,
101
- // we will proceed only if the user has specified that unencrypted storage is allowed.
102
- if (!unsafeAllowUnencryptedStorage) {
103
- throw new Error('Unable to read from the system keyring (libsecret).');
104
- }
105
- return FilePersistence.create(persistencePath);
106
- }
107
- },
108
- };
109
- //# sourceMappingURL=platforms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platforms.js","sourceRoot":"","sources":["../../src/cache-persistance/platforms.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence\n */\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport * as path from 'path';\nimport {\n DataProtectionScope,\n FilePersistence,\n FilePersistenceWithDataProtection,\n KeychainPersistence,\n LibSecretPersistence,\n type IPersistence as Persistence,\n} from '@azure/msal-node-extensions';\nimport type { TokenCachePersistenceOptions } from '@azure/identity';\n\n/**\n * Local application data folder\n * Expected values:\n * - Darwin: '/Users/user/'\n * - Windows 8+: 'C:\\Users\\user\\AppData\\Local'\n * - Linux: '/home/user/.local/share'\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nconst localApplicationDataFolder = process.env.APPDATA?.replace?.(/(.Roaming)*$/, '\\\\Local') ?? process.env.HOME!;\n\n/**\n * Dictionary of values that we use as default as we discover, pick and enable the persistence layer.\n * @internal\n */\nexport const defaultMsalValues = {\n tokenCache: {\n name: 'msal.cache',\n // Expected values:\n // - Darwin: '/Users/user/.IdentityService'\n // - Windows 8+: 'C:\\Users\\user\\AppData\\Local\\.IdentityService'\n // - Linux: '/home/user/.IdentityService'\n directory: path.join(localApplicationDataFolder, '.IdentityService'),\n },\n keyRing: {\n label: 'MSALCache',\n schema: 'msal.cache',\n collection: 'default',\n attributes: {\n MsalClientID: 'Microsoft.Developer.IdentityService',\n 'Microsoft.Developer.IdentityService': '1.0.0.0',\n },\n service: 'Microsoft.Developer.IdentityService',\n account: 'MSALCache',\n },\n keyChain: {\n service: 'Microsoft.Developer.IdentityService',\n account: 'MSALCache',\n },\n};\n\n/**\n * Options that are used by the underlying MSAL cache provider.\n * @internal\n */\nexport type MsalPersistenceOptions = Omit<TokenCachePersistenceOptions, 'enabled'>;\n\n/**\n * A function that returns a persistent token cache instance.\n * @internal\n */\ntype MsalPersistenceFactory = (options?: MsalPersistenceOptions) => Promise<Persistence>;\n\n/**\n * Expected responses:\n * - Darwin: '/Users/user/.IdentityService/<name>'\n * - Windows 8+: 'C:\\Users\\user\\AppData\\Local\\.IdentityService\\<name>'\n * - Linux: '/home/user/.IdentityService/<name>'\n * @internal\n */\nfunction getPersistencePath(name: string): string {\n return path.join(defaultMsalValues.tokenCache.directory, name);\n}\n\n/**\n * Set of the platforms we attempt to deliver persistence on.\n *\n * - On Windows we use DPAPI.\n * - On OSX (Darwin), we try to use the system's Keychain, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.\n * - On Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.\n *\n * Other platforms _are not supported_ at this time.\n *\n * @internal\n */\nexport const msalPersistencePlatforms: Partial<Record<NodeJS.Platform, MsalPersistenceFactory>> = {\n win32: ({ name = defaultMsalValues.tokenCache.name } = {}): Promise<Persistence> =>\n FilePersistenceWithDataProtection.create(getPersistencePath(name), DataProtectionScope.CurrentUser),\n\n darwin: async (options: MsalPersistenceOptions = {}): Promise<Persistence> => {\n const { name, unsafeAllowUnencryptedStorage } = options;\n const { service, account } = defaultMsalValues.keyChain;\n const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);\n\n try {\n const persistence = await KeychainPersistence.create(persistencePath, service, account);\n // If we don't encounter an error when trying to read from the keychain, then we should be good to go.\n await persistence.load();\n return persistence;\n } catch {\n // If we got an error while trying to read from the keyring,\n // we will proceed only if the user has specified that unencrypted storage is allowed.\n if (!unsafeAllowUnencryptedStorage) {\n throw new Error('Unable to read from the macOS Keychain.');\n }\n return FilePersistence.create(persistencePath);\n }\n },\n\n linux: async (options: MsalPersistenceOptions = {}): Promise<Persistence> => {\n const { name, unsafeAllowUnencryptedStorage } = options;\n const { service, account } = defaultMsalValues.keyRing;\n const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);\n\n try {\n const persistence = await LibSecretPersistence.create(persistencePath, service, account);\n // If we don't encounter an error when trying to read from the keyring, then we should be good to go.\n await persistence.load();\n return persistence;\n } catch {\n // If we got an error while trying to read from the keyring,\n // we will proceed only if the user has specified that unencrypted storage is allowed.\n if (!unsafeAllowUnencryptedStorage) {\n throw new Error('Unable to read from the system keyring (libsecret).');\n }\n return FilePersistence.create(persistencePath);\n }\n },\n};\n"]}
@@ -1,15 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- import type { MsalPersistenceOptions } from './platforms.js';
5
- import type { IPersistence as Persistence } from '@azure/msal-node-extensions';
6
- import type { ICachePlugin as CachePlugin } from '@azure/msal-node';
7
- /**
8
- * This is used to gain access to the underlying Persistence instance, which we use for testing
9
- *
10
- * @returns a raw persistence instance
11
- * @internal
12
- */
13
- export declare function createPersistence(options: MsalPersistenceOptions): Promise<Persistence>;
14
- export declare function createPersistenceCachePlugin(options?: MsalPersistenceOptions): Promise<CachePlugin>;
15
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/cache-persistance/provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,IAAI,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,KAAK,EAAE,YAAY,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQ7F;AAED,wBAAsB,4BAA4B,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAOzG"}
@@ -1,26 +0,0 @@
1
- /**
2
- * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence
3
- */
4
- import { msalPersistencePlatforms } from './platforms.js';
5
- import { PersistenceCachePlugin } from '@azure/msal-node-extensions';
6
- /**
7
- * This is used to gain access to the underlying Persistence instance, which we use for testing
8
- *
9
- * @returns a raw persistence instance
10
- * @internal
11
- */
12
- export async function createPersistence(options) {
13
- const persistence = await msalPersistencePlatforms[process.platform]?.(options);
14
- if (persistence === undefined) {
15
- throw new Error('no persistence providers are available on this platform');
16
- }
17
- return persistence;
18
- }
19
- export async function createPersistenceCachePlugin(options) {
20
- const persistence = await createPersistence(options ?? {});
21
- return new PersistenceCachePlugin(persistence, {
22
- retryNumber: 100,
23
- retryDelay: 50,
24
- });
25
- }
26
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/cache-persistance/provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA+B;IACrE,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAEhF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,OAAgC;IACjF,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAE3D,OAAO,IAAI,sBAAsB,CAAC,WAAW,EAAE;QAC7C,WAAW,EAAE,GAAG;QAChB,UAAU,EAAE,EAAE;KACf,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * This file is a fork of https://github.com/altinokdarici/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence\n */\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport type { MsalPersistenceOptions } from './platforms.js';\nimport { msalPersistencePlatforms } from './platforms.js';\nimport type { IPersistence as Persistence } from '@azure/msal-node-extensions';\nimport { PersistenceCachePlugin } from '@azure/msal-node-extensions';\nimport type { ICachePlugin as CachePlugin } from '@azure/msal-node';\n\n/**\n * This is used to gain access to the underlying Persistence instance, which we use for testing\n *\n * @returns a raw persistence instance\n * @internal\n */\nexport async function createPersistence(options: MsalPersistenceOptions): Promise<Persistence> {\n const persistence = await msalPersistencePlatforms[process.platform]?.(options);\n\n if (persistence === undefined) {\n throw new Error('no persistence providers are available on this platform');\n }\n\n return persistence;\n}\n\nexport async function createPersistenceCachePlugin(options?: MsalPersistenceOptions): Promise<CachePlugin> {\n const persistence = await createPersistence(options ?? {});\n\n return new PersistenceCachePlugin(persistence, {\n retryNumber: 100,\n retryDelay: 50,\n });\n}\n"]}