@azure/identity-cache-persistence 1.2.2-alpha.20260227.2 → 1.2.2-alpha.20260304.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.
- package/dist/commonjs/index.js +29 -38
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/platforms.js +99 -102
- package/dist/commonjs/platforms.js.map +7 -1
- package/dist/commonjs/provider.js +40 -25
- package/dist/commonjs/provider.js.map +7 -1
- package/dist/esm/index.js +6 -34
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/platforms.js +70 -97
- package/dist/esm/platforms.js.map +7 -1
- package/dist/esm/provider.js +16 -21
- package/dist/esm/provider.js.map +7 -1
- package/package.json +1 -18
package/dist/commonjs/index.js
CHANGED
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* enabled: true,
|
|
25
|
-
* },
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // We'll use the Microsoft Graph scope as an example
|
|
29
|
-
* const scope = "https://graph.microsoft.com/.default";
|
|
30
|
-
*
|
|
31
|
-
* // Print out part of the access token
|
|
32
|
-
* console.log((await credential.getToken(scope)).token.substring(0, 10), "...");
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var src_exports = {};
|
|
19
|
+
__export(src_exports, {
|
|
20
|
+
cachePersistencePlugin: () => cachePersistencePlugin
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(src_exports);
|
|
23
|
+
var import_provider = require("./provider.js");
|
|
35
24
|
const cachePersistencePlugin = (context) => {
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
const { cachePluginControl } = context;
|
|
26
|
+
cachePluginControl.setPersistence(import_provider.createPersistenceCachePlugin);
|
|
38
27
|
};
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
cachePersistencePlugin
|
|
31
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin, TokenCachePersistenceOptions } from \"@azure/identity\";\nimport { createPersistenceCachePlugin } from \"./provider.js\";\n\n/**\n * Plugin context entries for controlling cache plugins.\n */\ninterface CachePluginControl {\n setPersistence(\n persistenceFactory: (\n options?: TokenCachePersistenceOptions,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ) => Promise<import(\"@azure/msal-node\").ICachePlugin>,\n ): void;\n}\n/**\n * Context options passed to a plugin during initialization.\n *\n * Represents a subset of the context defined in `@azure/identity`\n *\n */\ninterface AzurePluginContext {\n cachePluginControl: CachePluginControl;\n}\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 * ```ts snippet:ReadmeSampleDeviceCodeCredential\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true,\n * },\n * });\n *\n * // We'll use the Microsoft Graph scope as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substring(0, 10), \"...\");\n * ```\n */\n\nexport const cachePersistencePlugin: IdentityPlugin = (context) => {\n const { cachePluginControl } = context as AzurePluginContext;\n\n cachePluginControl.setPersistence(createPersistenceCachePlugin);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAA6C;AAoDtC,MAAM,yBAAyC,CAAC,YAAY;AACjE,QAAM,EAAE,mBAAmB,IAAI;AAE/B,qBAAmB,eAAe,4CAA4B;AAChE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,108 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var platforms_exports = {};
|
|
29
|
+
__export(platforms_exports, {
|
|
30
|
+
defaultMsalValues: () => defaultMsalValues,
|
|
31
|
+
msalPersistencePlatforms: () => msalPersistencePlatforms
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(platforms_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
|
35
|
+
var import_msal_node_extensions = require("@azure/msal-node-extensions");
|
|
17
36
|
const localApplicationDataFolder = process.env.APPDATA?.replace?.(/(.Roaming)*$/, "\\Local") ?? process.env.HOME;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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",
|
|
37
|
+
const defaultMsalValues = {
|
|
38
|
+
tokenCache: {
|
|
39
|
+
name: "msal.cache",
|
|
40
|
+
// Expected values:
|
|
41
|
+
// - Darwin: '/Users/user/.IdentityService'
|
|
42
|
+
// - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService'
|
|
43
|
+
// - Linux: '/home/user/.IdentityService'
|
|
44
|
+
directory: import_node_path.default.join(localApplicationDataFolder, ".IdentityService")
|
|
45
|
+
},
|
|
46
|
+
keyRing: {
|
|
47
|
+
label: "MSALCache",
|
|
48
|
+
schema: "msal.cache",
|
|
49
|
+
collection: "default",
|
|
50
|
+
attributes: {
|
|
51
|
+
MsalClientID: "Microsoft.Developer.IdentityService",
|
|
52
|
+
"Microsoft.Developer.IdentityService": "1.0.0.0"
|
|
45
53
|
},
|
|
54
|
+
service: "Microsoft.Developer.IdentityService",
|
|
55
|
+
account: "MSALCache"
|
|
56
|
+
},
|
|
57
|
+
keyChain: {
|
|
58
|
+
service: "Microsoft.Developer.IdentityService",
|
|
59
|
+
account: "MSALCache"
|
|
60
|
+
}
|
|
46
61
|
};
|
|
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
|
-
*/
|
|
53
62
|
function getPersistencePath(name) {
|
|
54
|
-
|
|
63
|
+
return import_node_path.default.join(defaultMsalValues.tokenCache.directory, name);
|
|
55
64
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const persistencePath = getPersistencePath(name || exports.defaultMsalValues.tokenCache.name);
|
|
92
|
-
try {
|
|
93
|
-
const persistence = await msal_node_extensions_1.LibSecretPersistence.create(persistencePath, service, account);
|
|
94
|
-
// If we don't encounter an error when trying to read from the keyring, then we should be good to go.
|
|
95
|
-
await persistence.load();
|
|
96
|
-
return persistence;
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
// If we got an error while trying to read from the keyring,
|
|
100
|
-
// we will proceed only if the user has specified that unencrypted storage is allowed.
|
|
101
|
-
if (!unsafeAllowUnencryptedStorage) {
|
|
102
|
-
throw new Error("Unable to read from the system keyring (libsecret).");
|
|
103
|
-
}
|
|
104
|
-
return msal_node_extensions_1.FilePersistence.create(persistencePath);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
65
|
+
const msalPersistencePlatforms = {
|
|
66
|
+
win32: ({ name = defaultMsalValues.tokenCache.name } = {}) => import_msal_node_extensions.FilePersistenceWithDataProtection.create(
|
|
67
|
+
getPersistencePath(name),
|
|
68
|
+
import_msal_node_extensions.DataProtectionScope.CurrentUser
|
|
69
|
+
),
|
|
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 import_msal_node_extensions.KeychainPersistence.create(persistencePath, service, account);
|
|
76
|
+
await persistence.load();
|
|
77
|
+
return persistence;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
if (!unsafeAllowUnencryptedStorage) {
|
|
80
|
+
throw new Error("Unable to read from the macOS Keychain.");
|
|
81
|
+
}
|
|
82
|
+
return import_msal_node_extensions.FilePersistence.create(persistencePath);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
linux: async (options = {}) => {
|
|
86
|
+
const { name, unsafeAllowUnencryptedStorage } = options;
|
|
87
|
+
const { service, account } = defaultMsalValues.keyRing;
|
|
88
|
+
const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
|
|
89
|
+
try {
|
|
90
|
+
const persistence = await import_msal_node_extensions.LibSecretPersistence.create(persistencePath, service, account);
|
|
91
|
+
await persistence.load();
|
|
92
|
+
return persistence;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
if (!unsafeAllowUnencryptedStorage) {
|
|
95
|
+
throw new Error("Unable to read from the system keyring (libsecret).");
|
|
96
|
+
}
|
|
97
|
+
return import_msal_node_extensions.FilePersistence.create(persistencePath);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
107
100
|
};
|
|
108
|
-
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
defaultMsalValues,
|
|
104
|
+
msalPersistencePlatforms
|
|
105
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/platforms.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable tsdoc/syntax */\n\nimport path from \"node:path\";\nimport type { IPersistence as Persistence } from \"@azure/msal-node-extensions\";\nimport {\n DataProtectionScope,\n FilePersistence,\n FilePersistenceWithDataProtection,\n KeychainPersistence,\n LibSecretPersistence,\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 */\nconst localApplicationDataFolder =\n 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 */\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 */\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(\n getPersistencePath(name),\n DataProtectionScope.CurrentUser,\n ),\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 (e: any) {\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 (e: any) {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAAiB;AAEjB,kCAMO;AAUP,MAAM,6BACJ,QAAQ,IAAI,SAAS,UAAU,gBAAgB,SAAS,KAAK,QAAQ,IAAI;AAMpE,MAAM,oBAAoB;AAAA,EAC/B,YAAY;AAAA,IACV,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKN,WAAW,iBAAAA,QAAK,KAAK,4BAA4B,kBAAkB;AAAA,EACrE;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,YAAY;AAAA,MACV,cAAc;AAAA,MACd,uCAAuC;AAAA,IACzC;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AACF;AAmBA,SAAS,mBAAmB,MAAsB;AAChD,SAAO,iBAAAA,QAAK,KAAK,kBAAkB,WAAW,WAAW,IAAI;AAC/D;AAaO,MAAM,2BAAqF;AAAA,EAChG,OAAO,CAAC,EAAE,OAAO,kBAAkB,WAAW,KAAK,IAAI,CAAC,MACtD,8DAAkC;AAAA,IAChC,mBAAmB,IAAI;AAAA,IACvB,gDAAoB;AAAA,EACtB;AAAA,EAEF,QAAQ,OAAO,UAAkC,CAAC,MAA4B;AAC5E,UAAM,EAAE,MAAM,8BAA8B,IAAI;AAChD,UAAM,EAAE,SAAS,QAAQ,IAAI,kBAAkB;AAC/C,UAAM,kBAAkB,mBAAmB,QAAQ,kBAAkB,WAAW,IAAI;AAEpF,QAAI;AACF,YAAM,cAAc,MAAM,gDAAoB,OAAO,iBAAiB,SAAS,OAAO;AAEtF,YAAM,YAAY,KAAK;AACvB,aAAO;AAAA,IACT,SAAS,GAAQ;AAGf,UAAI,CAAC,+BAA+B;AAClC,cAAM,IAAI,MAAM,yCAAyC;AAAA,MAC3D;AACA,aAAO,4CAAgB,OAAO,eAAe;AAAA,IAC/C;AAAA,EACF;AAAA,EAEA,OAAO,OAAO,UAAkC,CAAC,MAA4B;AAC3E,UAAM,EAAE,MAAM,8BAA8B,IAAI;AAChD,UAAM,EAAE,SAAS,QAAQ,IAAI,kBAAkB;AAC/C,UAAM,kBAAkB,mBAAmB,QAAQ,kBAAkB,WAAW,IAAI;AAEpF,QAAI;AACF,YAAM,cAAc,MAAM,iDAAqB,OAAO,iBAAiB,SAAS,OAAO;AAEvF,YAAM,YAAY,KAAK;AACvB,aAAO;AAAA,IACT,SAAS,GAAQ;AAGf,UAAI,CAAC,+BAA+B;AAClC,cAAM,IAAI,MAAM,qDAAqD;AAAA,MACvE;AACA,aAAO,4CAAgB,OAAO,eAAe;AAAA,IAC/C;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["path"]
|
|
7
|
+
}
|
|
@@ -1,29 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var provider_exports = {};
|
|
19
|
+
__export(provider_exports, {
|
|
20
|
+
createPersistence: () => createPersistence,
|
|
21
|
+
createPersistenceCachePlugin: () => createPersistenceCachePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(provider_exports);
|
|
24
|
+
var import_platforms = require("./platforms.js");
|
|
25
|
+
var import_msal_node_extensions = require("@azure/msal-node-extensions");
|
|
15
26
|
async function createPersistence(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const persistence = await import_platforms.msalPersistencePlatforms[process.platform]?.(options);
|
|
28
|
+
if (persistence === void 0) {
|
|
29
|
+
throw new Error("no persistence providers are available on this platform");
|
|
30
|
+
}
|
|
31
|
+
return persistence;
|
|
21
32
|
}
|
|
22
33
|
async function createPersistenceCachePlugin(options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
const persistence = await createPersistence(options ?? {});
|
|
35
|
+
return new import_msal_node_extensions.PersistenceCachePlugin(persistence, {
|
|
36
|
+
retryNumber: 100,
|
|
37
|
+
retryDelay: 50
|
|
38
|
+
});
|
|
28
39
|
}
|
|
29
|
-
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
createPersistence,
|
|
43
|
+
createPersistenceCachePlugin
|
|
44
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/provider.ts"],
|
|
4
|
+
"sourcesContent": ["// 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(\n options?: MsalPersistenceOptions,\n): Promise<CachePlugin> {\n const persistence = await createPersistence(options ?? {});\n\n return new PersistenceCachePlugin(persistence, {\n retryNumber: 100,\n retryDelay: 50,\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAyC;AAEzC,kCAAuC;AASvC,eAAsB,kBAAkB,SAAuD;AAC7F,QAAM,cAAc,MAAM,0CAAyB,QAAQ,QAAQ,IAAI,OAAO;AAE9E,MAAI,gBAAgB,QAAW;AAC7B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,SAAO;AACT;AAEA,eAAsB,6BACpB,SACsB;AACtB,QAAM,cAAc,MAAM,kBAAkB,WAAW,CAAC,CAAC;AAEzD,SAAO,IAAI,mDAAuB,aAAa;AAAA,IAC7C,aAAa;AAAA,IACb,YAAY;AAAA,EACd,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
1
|
import { createPersistenceCachePlugin } from "./provider.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* In order to enable this functionality, you must also pass
|
|
11
|
-
* `tokenCachePersistenceOptions` to your credential constructors with an
|
|
12
|
-
* `enabled` property set to true.
|
|
13
|
-
*
|
|
14
|
-
* Example:
|
|
15
|
-
*
|
|
16
|
-
* ```ts snippet:ReadmeSampleDeviceCodeCredential
|
|
17
|
-
* import { DeviceCodeCredential } from "@azure/identity";
|
|
18
|
-
*
|
|
19
|
-
* const credential = new DeviceCodeCredential({
|
|
20
|
-
* tokenCachePersistenceOptions: {
|
|
21
|
-
* enabled: true,
|
|
22
|
-
* },
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // We'll use the Microsoft Graph scope as an example
|
|
26
|
-
* const scope = "https://graph.microsoft.com/.default";
|
|
27
|
-
*
|
|
28
|
-
* // Print out part of the access token
|
|
29
|
-
* console.log((await credential.getToken(scope)).token.substring(0, 10), "...");
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export const cachePersistencePlugin = (context) => {
|
|
33
|
-
const { cachePluginControl } = context;
|
|
34
|
-
cachePluginControl.setPersistence(createPersistenceCachePlugin);
|
|
2
|
+
const cachePersistencePlugin = (context) => {
|
|
3
|
+
const { cachePluginControl } = context;
|
|
4
|
+
cachePluginControl.setPersistence(createPersistenceCachePlugin);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
cachePersistencePlugin
|
|
35
8
|
};
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin, TokenCachePersistenceOptions } from \"@azure/identity\";\nimport { createPersistenceCachePlugin } from \"./provider.js\";\n\n/**\n * Plugin context entries for controlling cache plugins.\n */\ninterface CachePluginControl {\n setPersistence(\n persistenceFactory: (\n options?: TokenCachePersistenceOptions,\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ) => Promise<import(\"@azure/msal-node\").ICachePlugin>,\n ): void;\n}\n/**\n * Context options passed to a plugin during initialization.\n *\n * Represents a subset of the context defined in `@azure/identity`\n *\n */\ninterface AzurePluginContext {\n cachePluginControl: CachePluginControl;\n}\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 * ```ts snippet:ReadmeSampleDeviceCodeCredential\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true,\n * },\n * });\n *\n * // We'll use the Microsoft Graph scope as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substring(0, 10), \"...\");\n * ```\n */\n\nexport const cachePersistencePlugin: IdentityPlugin = (context) => {\n const { cachePluginControl } = context as AzurePluginContext;\n\n cachePluginControl.setPersistence(createPersistenceCachePlugin);\n};\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,oCAAoC;AAoDtC,MAAM,yBAAyC,CAAC,YAAY;AACjE,QAAM,EAAE,mBAAmB,IAAI;AAE/B,qBAAmB,eAAe,4BAA4B;AAChE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/platforms.js
CHANGED
|
@@ -1,104 +1,77 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
/* eslint-disable tsdoc/syntax */
|
|
4
1
|
import path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
2
|
+
import {
|
|
3
|
+
DataProtectionScope,
|
|
4
|
+
FilePersistence,
|
|
5
|
+
FilePersistenceWithDataProtection,
|
|
6
|
+
KeychainPersistence,
|
|
7
|
+
LibSecretPersistence
|
|
8
|
+
} from "@azure/msal-node-extensions";
|
|
13
9
|
const localApplicationDataFolder = process.env.APPDATA?.replace?.(/(.Roaming)*$/, "\\Local") ?? process.env.HOME;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
collection: "default",
|
|
31
|
-
attributes: {
|
|
32
|
-
MsalClientID: "Microsoft.Developer.IdentityService",
|
|
33
|
-
"Microsoft.Developer.IdentityService": "1.0.0.0",
|
|
34
|
-
},
|
|
35
|
-
service: "Microsoft.Developer.IdentityService",
|
|
36
|
-
account: "MSALCache",
|
|
37
|
-
},
|
|
38
|
-
keyChain: {
|
|
39
|
-
service: "Microsoft.Developer.IdentityService",
|
|
40
|
-
account: "MSALCache",
|
|
10
|
+
const defaultMsalValues = {
|
|
11
|
+
tokenCache: {
|
|
12
|
+
name: "msal.cache",
|
|
13
|
+
// Expected values:
|
|
14
|
+
// - Darwin: '/Users/user/.IdentityService'
|
|
15
|
+
// - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService'
|
|
16
|
+
// - Linux: '/home/user/.IdentityService'
|
|
17
|
+
directory: path.join(localApplicationDataFolder, ".IdentityService")
|
|
18
|
+
},
|
|
19
|
+
keyRing: {
|
|
20
|
+
label: "MSALCache",
|
|
21
|
+
schema: "msal.cache",
|
|
22
|
+
collection: "default",
|
|
23
|
+
attributes: {
|
|
24
|
+
MsalClientID: "Microsoft.Developer.IdentityService",
|
|
25
|
+
"Microsoft.Developer.IdentityService": "1.0.0.0"
|
|
41
26
|
},
|
|
27
|
+
service: "Microsoft.Developer.IdentityService",
|
|
28
|
+
account: "MSALCache"
|
|
29
|
+
},
|
|
30
|
+
keyChain: {
|
|
31
|
+
service: "Microsoft.Developer.IdentityService",
|
|
32
|
+
account: "MSALCache"
|
|
33
|
+
}
|
|
42
34
|
};
|
|
43
|
-
/**
|
|
44
|
-
* Expected responses:
|
|
45
|
-
* - Darwin: '/Users/user/.IdentityService/<name>'
|
|
46
|
-
* - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService\<name>'
|
|
47
|
-
* - Linux: '/home/user/.IdentityService/<name>'
|
|
48
|
-
*/
|
|
49
35
|
function getPersistencePath(name) {
|
|
50
|
-
|
|
36
|
+
return path.join(defaultMsalValues.tokenCache.directory, name);
|
|
51
37
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
await persistence.load();
|
|
92
|
-
return persistence;
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
// If we got an error while trying to read from the keyring,
|
|
96
|
-
// we will proceed only if the user has specified that unencrypted storage is allowed.
|
|
97
|
-
if (!unsafeAllowUnencryptedStorage) {
|
|
98
|
-
throw new Error("Unable to read from the system keyring (libsecret).");
|
|
99
|
-
}
|
|
100
|
-
return FilePersistence.create(persistencePath);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
38
|
+
const msalPersistencePlatforms = {
|
|
39
|
+
win32: ({ name = defaultMsalValues.tokenCache.name } = {}) => FilePersistenceWithDataProtection.create(
|
|
40
|
+
getPersistencePath(name),
|
|
41
|
+
DataProtectionScope.CurrentUser
|
|
42
|
+
),
|
|
43
|
+
darwin: async (options = {}) => {
|
|
44
|
+
const { name, unsafeAllowUnencryptedStorage } = options;
|
|
45
|
+
const { service, account } = defaultMsalValues.keyChain;
|
|
46
|
+
const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
|
|
47
|
+
try {
|
|
48
|
+
const persistence = await KeychainPersistence.create(persistencePath, service, account);
|
|
49
|
+
await persistence.load();
|
|
50
|
+
return persistence;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
if (!unsafeAllowUnencryptedStorage) {
|
|
53
|
+
throw new Error("Unable to read from the macOS Keychain.");
|
|
54
|
+
}
|
|
55
|
+
return FilePersistence.create(persistencePath);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
linux: async (options = {}) => {
|
|
59
|
+
const { name, unsafeAllowUnencryptedStorage } = options;
|
|
60
|
+
const { service, account } = defaultMsalValues.keyRing;
|
|
61
|
+
const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
|
|
62
|
+
try {
|
|
63
|
+
const persistence = await LibSecretPersistence.create(persistencePath, service, account);
|
|
64
|
+
await persistence.load();
|
|
65
|
+
return persistence;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (!unsafeAllowUnencryptedStorage) {
|
|
68
|
+
throw new Error("Unable to read from the system keyring (libsecret).");
|
|
69
|
+
}
|
|
70
|
+
return FilePersistence.create(persistencePath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
defaultMsalValues,
|
|
76
|
+
msalPersistencePlatforms
|
|
103
77
|
};
|
|
104
|
-
//# sourceMappingURL=platforms.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/platforms.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable tsdoc/syntax */\n\nimport path from \"node:path\";\nimport type { IPersistence as Persistence } from \"@azure/msal-node-extensions\";\nimport {\n DataProtectionScope,\n FilePersistence,\n FilePersistenceWithDataProtection,\n KeychainPersistence,\n LibSecretPersistence,\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 */\nconst localApplicationDataFolder =\n 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 */\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 */\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(\n getPersistencePath(name),\n DataProtectionScope.CurrentUser,\n ),\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 (e: any) {\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 (e: any) {\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"],
|
|
5
|
+
"mappings": "AAKA,OAAO,UAAU;AAEjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,MAAM,6BACJ,QAAQ,IAAI,SAAS,UAAU,gBAAgB,SAAS,KAAK,QAAQ,IAAI;AAMpE,MAAM,oBAAoB;AAAA,EAC/B,YAAY;AAAA,IACV,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKN,WAAW,KAAK,KAAK,4BAA4B,kBAAkB;AAAA,EACrE;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,YAAY;AAAA,MACV,cAAc;AAAA,MACd,uCAAuC;AAAA,IACzC;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AACF;AAmBA,SAAS,mBAAmB,MAAsB;AAChD,SAAO,KAAK,KAAK,kBAAkB,WAAW,WAAW,IAAI;AAC/D;AAaO,MAAM,2BAAqF;AAAA,EAChG,OAAO,CAAC,EAAE,OAAO,kBAAkB,WAAW,KAAK,IAAI,CAAC,MACtD,kCAAkC;AAAA,IAChC,mBAAmB,IAAI;AAAA,IACvB,oBAAoB;AAAA,EACtB;AAAA,EAEF,QAAQ,OAAO,UAAkC,CAAC,MAA4B;AAC5E,UAAM,EAAE,MAAM,8BAA8B,IAAI;AAChD,UAAM,EAAE,SAAS,QAAQ,IAAI,kBAAkB;AAC/C,UAAM,kBAAkB,mBAAmB,QAAQ,kBAAkB,WAAW,IAAI;AAEpF,QAAI;AACF,YAAM,cAAc,MAAM,oBAAoB,OAAO,iBAAiB,SAAS,OAAO;AAEtF,YAAM,YAAY,KAAK;AACvB,aAAO;AAAA,IACT,SAAS,GAAQ;AAGf,UAAI,CAAC,+BAA+B;AAClC,cAAM,IAAI,MAAM,yCAAyC;AAAA,MAC3D;AACA,aAAO,gBAAgB,OAAO,eAAe;AAAA,IAC/C;AAAA,EACF;AAAA,EAEA,OAAO,OAAO,UAAkC,CAAC,MAA4B;AAC3E,UAAM,EAAE,MAAM,8BAA8B,IAAI;AAChD,UAAM,EAAE,SAAS,QAAQ,IAAI,kBAAkB;AAC/C,UAAM,kBAAkB,mBAAmB,QAAQ,kBAAkB,WAAW,IAAI;AAEpF,QAAI;AACF,YAAM,cAAc,MAAM,qBAAqB,OAAO,iBAAiB,SAAS,OAAO;AAEvF,YAAM,YAAY,KAAK;AACvB,aAAO;AAAA,IACT,SAAS,GAAQ;AAGf,UAAI,CAAC,+BAA+B;AAClC,cAAM,IAAI,MAAM,qDAAqD;AAAA,MACvE;AACA,aAAO,gBAAgB,OAAO,eAAe;AAAA,IAC/C;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/provider.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
1
|
import { msalPersistencePlatforms } from "./platforms.js";
|
|
4
2
|
import { PersistenceCachePlugin } from "@azure/msal-node-extensions";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export async function createPersistence(options) {
|
|
12
|
-
const persistence = await msalPersistencePlatforms[process.platform]?.(options);
|
|
13
|
-
if (persistence === undefined) {
|
|
14
|
-
throw new Error("no persistence providers are available on this platform");
|
|
15
|
-
}
|
|
16
|
-
return persistence;
|
|
3
|
+
async function createPersistence(options) {
|
|
4
|
+
const persistence = await msalPersistencePlatforms[process.platform]?.(options);
|
|
5
|
+
if (persistence === void 0) {
|
|
6
|
+
throw new Error("no persistence providers are available on this platform");
|
|
7
|
+
}
|
|
8
|
+
return persistence;
|
|
17
9
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
async function createPersistenceCachePlugin(options) {
|
|
11
|
+
const persistence = await createPersistence(options ?? {});
|
|
12
|
+
return new PersistenceCachePlugin(persistence, {
|
|
13
|
+
retryNumber: 100,
|
|
14
|
+
retryDelay: 50
|
|
15
|
+
});
|
|
24
16
|
}
|
|
25
|
-
|
|
17
|
+
export {
|
|
18
|
+
createPersistence,
|
|
19
|
+
createPersistenceCachePlugin
|
|
20
|
+
};
|
package/dist/esm/provider.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/identity/identity-cache-persistence/src/provider.ts"],
|
|
4
|
+
"sourcesContent": ["// 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(\n options?: MsalPersistenceOptions,\n): Promise<CachePlugin> {\n const persistence = await createPersistence(options ?? {});\n\n return new PersistenceCachePlugin(persistence, {\n retryNumber: 100,\n retryDelay: 50,\n });\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,gCAAgC;AAEzC,SAAS,8BAA8B;AASvC,eAAsB,kBAAkB,SAAuD;AAC7F,QAAM,cAAc,MAAM,yBAAyB,QAAQ,QAAQ,IAAI,OAAO;AAE9E,MAAI,gBAAgB,QAAW;AAC7B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,SAAO;AACT;AAEA,eAAsB,6BACpB,SACsB;AACtB,QAAM,cAAc,MAAM,kBAAkB,WAAW,CAAC,CAAC;AAEzD,SAAO,IAAI,uBAAuB,aAAa;AAAA,IAC7C,aAAa;AAAA,IACb,YAAY;AAAA,EACd,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/identity-cache-persistence",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.20260304.2",
|
|
4
4
|
"sdk-type": "client",
|
|
5
5
|
"description": "A secure, persistent token cache for Azure Identity credentials that uses the OS secret-management API",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"playwright": "^1.56.1",
|
|
53
53
|
"prettier": "^3.6.2",
|
|
54
54
|
"rimraf": "^6.1.0",
|
|
55
|
-
"tshy": "^3.0.3",
|
|
56
55
|
"typescript": "~5.9.3",
|
|
57
56
|
"vitest": "^4.0.8",
|
|
58
57
|
"@azure-tools/test-recorder": "^4.1.1",
|
|
@@ -61,22 +60,6 @@
|
|
|
61
60
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
|
|
62
61
|
},
|
|
63
62
|
"type": "module",
|
|
64
|
-
"tshy": {
|
|
65
|
-
"project": "../../../tsconfig.src.build.json",
|
|
66
|
-
"exports": {
|
|
67
|
-
"./package.json": "./package.json",
|
|
68
|
-
".": "./src/index.ts"
|
|
69
|
-
},
|
|
70
|
-
"dialects": [
|
|
71
|
-
"esm",
|
|
72
|
-
"commonjs"
|
|
73
|
-
],
|
|
74
|
-
"esmDialects": [
|
|
75
|
-
"browser",
|
|
76
|
-
"react-native"
|
|
77
|
-
],
|
|
78
|
-
"selfLink": false
|
|
79
|
-
},
|
|
80
63
|
"browser": "./dist/browser/index.js",
|
|
81
64
|
"exports": {
|
|
82
65
|
"./package.json": "./package.json",
|