@azure/identity-cache-persistence 1.1.2-alpha.20241204.3 → 1.1.2-alpha.20241209.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/{types/identity-cache-persistence.d.ts → dist/browser/index.d.ts} +29 -31
- package/dist/browser/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/index.js +1 -1
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/platforms.d.ts +51 -0
- package/dist/browser/platforms.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/platforms.js +1 -1
- package/dist/browser/platforms.js.map +1 -0
- package/dist/browser/provider.d.ts +12 -0
- package/dist/browser/provider.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/provider.js +1 -1
- package/dist/browser/provider.js.map +1 -0
- package/dist/commonjs/index.d.ts +29 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +38 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/platforms.d.ts +51 -0
- package/dist/commonjs/platforms.d.ts.map +1 -0
- package/dist/commonjs/platforms.js +111 -0
- package/dist/commonjs/platforms.js.map +1 -0
- package/dist/commonjs/provider.d.ts +12 -0
- package/dist/commonjs/provider.d.ts.map +1 -0
- package/dist/commonjs/provider.js +35 -0
- package/dist/commonjs/provider.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/index.d.ts +29 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/platforms.d.ts +51 -0
- package/dist/esm/platforms.d.ts.map +1 -0
- package/dist/esm/platforms.js +108 -0
- package/dist/esm/platforms.js.map +1 -0
- package/dist/esm/provider.d.ts +12 -0
- package/dist/esm/provider.d.ts.map +1 -0
- package/dist/esm/provider.js +31 -0
- package/dist/esm/provider.js.map +1 -0
- package/dist/react-native/index.d.ts +29 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +34 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/platforms.d.ts +51 -0
- package/dist/react-native/platforms.d.ts.map +1 -0
- package/dist/react-native/platforms.js +108 -0
- package/dist/react-native/platforms.js.map +1 -0
- package/dist/react-native/provider.d.ts +12 -0
- package/dist/react-native/provider.d.ts.map +1 -0
- package/dist/react-native/provider.js +31 -0
- package/dist/react-native/provider.js.map +1 -0
- package/package.json +60 -30
- package/dist/index.js +0 -194
- package/dist/index.js.map +0 -1
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/platforms.js.map +0 -1
- package/dist-esm/src/provider.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/identity-cache-persistence",
|
|
3
|
-
"version": "1.1.2-alpha.
|
|
3
|
+
"version": "1.1.2-alpha.20241209.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
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist
|
|
8
|
-
"types": "./
|
|
6
|
+
"main": "./dist/commonjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "npm run clean &&
|
|
10
|
+
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
|
|
11
11
|
"build:samples": "echo skipped",
|
|
12
|
-
"build:test": "
|
|
12
|
+
"build:test": "dev-tool run build-package && dev-tool run bundle",
|
|
13
13
|
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
|
|
14
14
|
"clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log",
|
|
15
15
|
"execute:samples": "echo skipped",
|
|
16
|
-
"extract-api": "
|
|
16
|
+
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
|
|
17
17
|
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples-dev/**/*.ts\"",
|
|
18
18
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
19
19
|
"integration-test:browser": "echo skipped",
|
|
@@ -26,13 +26,11 @@
|
|
|
26
26
|
"test:node": "npm run clean && npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
27
27
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
28
28
|
"unit-test:browser": "echo skipped",
|
|
29
|
-
"unit-test:node": "
|
|
30
|
-
"update-snippets": "
|
|
29
|
+
"unit-test:node": "echo skipped",
|
|
30
|
+
"update-snippets": "echo skipped"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"dist/",
|
|
34
|
-
"dist-esm/src",
|
|
35
|
-
"types/identity-cache-persistence.d.ts",
|
|
36
34
|
"README.md",
|
|
37
35
|
"LICENSE"
|
|
38
36
|
],
|
|
@@ -58,33 +56,65 @@
|
|
|
58
56
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-cache-persistence/README.md",
|
|
59
57
|
"sideEffects": false,
|
|
60
58
|
"dependencies": {
|
|
61
|
-
"@azure/core-auth": "^1.
|
|
62
|
-
"@azure/identity": "^4.0
|
|
63
|
-
"@azure/msal-node": "^2.
|
|
64
|
-
"@azure/msal-node-extensions": "^1.0
|
|
59
|
+
"@azure/core-auth": "^1.9.0",
|
|
60
|
+
"@azure/identity": "^4.5.0",
|
|
61
|
+
"@azure/msal-node": "^2.16.2",
|
|
62
|
+
"@azure/msal-node-extensions": "^1.5.0",
|
|
65
63
|
"keytar": "^7.6.0",
|
|
66
|
-
"tslib": "^2.
|
|
64
|
+
"tslib": "^2.8.1"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
69
|
-
"@azure-tools/test-recorder": "
|
|
70
|
-
"@azure-tools/test-utils": "
|
|
71
|
-
"@azure/core-client": "^1.
|
|
67
|
+
"@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
|
|
68
|
+
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
|
69
|
+
"@azure/core-client": "^1.9.2",
|
|
72
70
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
73
71
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
74
|
-
"@azure/logger": "^1.
|
|
75
|
-
"@types/jws": "^3.2.2",
|
|
76
|
-
"@types/mocha": "^10.0.0",
|
|
72
|
+
"@azure/logger": "^1.1.4",
|
|
77
73
|
"@types/node": "^18.0.0",
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
74
|
+
"@vitest/browser": "^2.1.8",
|
|
75
|
+
"@vitest/coverage-istanbul": "^2.1.8",
|
|
80
76
|
"dotenv": "^16.0.0",
|
|
81
77
|
"eslint": "^9.9.0",
|
|
82
|
-
"
|
|
83
|
-
"mocha": "^10.0.0",
|
|
84
|
-
"puppeteer": "^23.0.2",
|
|
85
|
-
"sinon": "^17.0.0",
|
|
86
|
-
"ts-node": "^10.0.0",
|
|
78
|
+
"playwright": "^1.49.0",
|
|
87
79
|
"typescript": "~5.6.2",
|
|
88
|
-
"
|
|
80
|
+
"vitest": "^2.1.8"
|
|
81
|
+
},
|
|
82
|
+
"type": "module",
|
|
83
|
+
"tshy": {
|
|
84
|
+
"exports": {
|
|
85
|
+
"./package.json": "./package.json",
|
|
86
|
+
".": "./src/index.ts"
|
|
87
|
+
},
|
|
88
|
+
"dialects": [
|
|
89
|
+
"esm",
|
|
90
|
+
"commonjs"
|
|
91
|
+
],
|
|
92
|
+
"esmDialects": [
|
|
93
|
+
"browser",
|
|
94
|
+
"react-native"
|
|
95
|
+
],
|
|
96
|
+
"selfLink": false
|
|
97
|
+
},
|
|
98
|
+
"browser": "./dist/browser/index.js",
|
|
99
|
+
"exports": {
|
|
100
|
+
"./package.json": "./package.json",
|
|
101
|
+
".": {
|
|
102
|
+
"browser": {
|
|
103
|
+
"types": "./dist/browser/index.d.ts",
|
|
104
|
+
"default": "./dist/browser/index.js"
|
|
105
|
+
},
|
|
106
|
+
"react-native": {
|
|
107
|
+
"types": "./dist/react-native/index.d.ts",
|
|
108
|
+
"default": "./dist/react-native/index.js"
|
|
109
|
+
},
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/esm/index.d.ts",
|
|
112
|
+
"default": "./dist/esm/index.js"
|
|
113
|
+
},
|
|
114
|
+
"require": {
|
|
115
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
116
|
+
"default": "./dist/commonjs/index.js"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
89
119
|
}
|
|
90
120
|
}
|
package/dist/index.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var msalNodeExtensions = require('@azure/msal-node-extensions');
|
|
8
|
-
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
27
|
-
|
|
28
|
-
// Copyright (c) Microsoft Corporation.
|
|
29
|
-
// Licensed under the MIT License.
|
|
30
|
-
var _a, _b, _c;
|
|
31
|
-
/**
|
|
32
|
-
* Local application data folder
|
|
33
|
-
* Expected values:
|
|
34
|
-
* - Darwin: '/Users/user/'
|
|
35
|
-
* - Windows 8+: 'C:\Users\user\AppData\Local'
|
|
36
|
-
* - Linux: '/home/user/.local/share'
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
const localApplicationDataFolder = (_c = (_b = (_a = process.env.APPDATA) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, /(.Roaming)*$/, "\\Local")) !== null && _c !== void 0 ? _c : process.env.HOME;
|
|
40
|
-
/**
|
|
41
|
-
* Dictionary of values that we use as default as we discover, pick and enable the persistence layer.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
const defaultMsalValues = {
|
|
45
|
-
tokenCache: {
|
|
46
|
-
name: "msal.cache",
|
|
47
|
-
// Expected values:
|
|
48
|
-
// - Darwin: '/Users/user/.IdentityService'
|
|
49
|
-
// - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService'
|
|
50
|
-
// - Linux: '/home/user/.IdentityService'
|
|
51
|
-
directory: path__namespace.join(localApplicationDataFolder, ".IdentityService"),
|
|
52
|
-
},
|
|
53
|
-
keyRing: {
|
|
54
|
-
label: "MSALCache",
|
|
55
|
-
schema: "msal.cache",
|
|
56
|
-
collection: "default",
|
|
57
|
-
attributes: {
|
|
58
|
-
MsalClientID: "Microsoft.Developer.IdentityService",
|
|
59
|
-
"Microsoft.Developer.IdentityService": "1.0.0.0",
|
|
60
|
-
},
|
|
61
|
-
service: "Microsoft.Developer.IdentityService",
|
|
62
|
-
account: "MSALCache",
|
|
63
|
-
},
|
|
64
|
-
keyChain: {
|
|
65
|
-
service: "Microsoft.Developer.IdentityService",
|
|
66
|
-
account: "MSALCache",
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Expected responses:
|
|
71
|
-
* - Darwin: '/Users/user/.IdentityService/<name>'
|
|
72
|
-
* - Windows 8+: 'C:\Users\user\AppData\Local\.IdentityService\<name>'
|
|
73
|
-
* - Linux: '/home/user/.IdentityService/<name>'
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
function getPersistencePath(name) {
|
|
77
|
-
return path__namespace.join(defaultMsalValues.tokenCache.directory, name);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Set of the platforms we attempt to deliver persistence on.
|
|
81
|
-
*
|
|
82
|
-
* - On Windows we use DPAPI.
|
|
83
|
-
* - 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.
|
|
84
|
-
* - On Linux, we try to use the system's Keyring, otherwise if the property `unsafeAllowUnencryptedStorage` is set to true, we use an unencrypted file.
|
|
85
|
-
*
|
|
86
|
-
* Other platforms _are not supported_ at this time.
|
|
87
|
-
*
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
const msalPersistencePlatforms = {
|
|
91
|
-
win32: ({ name = defaultMsalValues.tokenCache.name } = {}) => msalNodeExtensions.FilePersistenceWithDataProtection.create(getPersistencePath(name), msalNodeExtensions.DataProtectionScope.CurrentUser),
|
|
92
|
-
darwin: (...args_1) => tslib.__awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
|
93
|
-
const { name, unsafeAllowUnencryptedStorage } = options;
|
|
94
|
-
const { service, account } = defaultMsalValues.keyChain;
|
|
95
|
-
const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
|
|
96
|
-
try {
|
|
97
|
-
const persistence = yield msalNodeExtensions.KeychainPersistence.create(persistencePath, service, account);
|
|
98
|
-
// If we don't encounter an error when trying to read from the keychain, then we should be good to go.
|
|
99
|
-
yield persistence.load();
|
|
100
|
-
return persistence;
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
// If we got an error while trying to read from the keyring,
|
|
104
|
-
// we will proceed only if the user has specified that unencrypted storage is allowed.
|
|
105
|
-
if (!unsafeAllowUnencryptedStorage) {
|
|
106
|
-
throw new Error("Unable to read from the macOS Keychain.");
|
|
107
|
-
}
|
|
108
|
-
return msalNodeExtensions.FilePersistence.create(persistencePath);
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
linux: (...args_1) => tslib.__awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
|
112
|
-
const { name, unsafeAllowUnencryptedStorage } = options;
|
|
113
|
-
const { service, account } = defaultMsalValues.keyRing;
|
|
114
|
-
const persistencePath = getPersistencePath(name || defaultMsalValues.tokenCache.name);
|
|
115
|
-
try {
|
|
116
|
-
const persistence = yield msalNodeExtensions.LibSecretPersistence.create(persistencePath, service, account);
|
|
117
|
-
// If we don't encounter an error when trying to read from the keyring, then we should be good to go.
|
|
118
|
-
yield persistence.load();
|
|
119
|
-
return persistence;
|
|
120
|
-
}
|
|
121
|
-
catch (e) {
|
|
122
|
-
// If we got an error while trying to read from the keyring,
|
|
123
|
-
// we will proceed only if the user has specified that unencrypted storage is allowed.
|
|
124
|
-
if (!unsafeAllowUnencryptedStorage) {
|
|
125
|
-
throw new Error("Unable to read from the system keyring (libsecret).");
|
|
126
|
-
}
|
|
127
|
-
return msalNodeExtensions.FilePersistence.create(persistencePath);
|
|
128
|
-
}
|
|
129
|
-
}),
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// Copyright (c) Microsoft Corporation.
|
|
133
|
-
// Licensed under the MIT License.
|
|
134
|
-
/**
|
|
135
|
-
* This is used to gain access to the underlying Persistence instance, which we use for testing
|
|
136
|
-
*
|
|
137
|
-
* @returns a raw persistence instance
|
|
138
|
-
* @internal
|
|
139
|
-
*/
|
|
140
|
-
function createPersistence(options) {
|
|
141
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
var _a;
|
|
143
|
-
const persistence = yield ((_a = msalPersistencePlatforms[process.platform]) === null || _a === void 0 ? void 0 : _a.call(msalPersistencePlatforms, options));
|
|
144
|
-
if (persistence === undefined) {
|
|
145
|
-
throw new Error("no persistence providers are available on this platform");
|
|
146
|
-
}
|
|
147
|
-
return persistence;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function createPersistenceCachePlugin(options) {
|
|
151
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const persistence = yield createPersistence(options !== null && options !== void 0 ? options : {});
|
|
153
|
-
return new msalNodeExtensions.PersistenceCachePlugin(persistence, {
|
|
154
|
-
retryNumber: 100,
|
|
155
|
-
retryDelay: 50,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Copyright (c) Microsoft Corporation.
|
|
161
|
-
// Licensed under the MIT License.
|
|
162
|
-
/**
|
|
163
|
-
* A plugin that provides persistent token caching for `@azure/identity`
|
|
164
|
-
* credentials. The plugin API is compatible with `@azure/identity` versions
|
|
165
|
-
* 2.0.0 and later. Load this plugin using the `useIdentityPlugin`
|
|
166
|
-
* function, imported from `@azure/identity`.
|
|
167
|
-
*
|
|
168
|
-
* In order to enable this functionality, you must also pass
|
|
169
|
-
* `tokenCachePersistenceOptions` to your credential constructors with an
|
|
170
|
-
* `enabled` property set to true.
|
|
171
|
-
*
|
|
172
|
-
* Example:
|
|
173
|
-
*
|
|
174
|
-
* ```ts snippet:device_code_credential_example
|
|
175
|
-
* import { DeviceCodeCredential } from "@azure/identity";
|
|
176
|
-
*
|
|
177
|
-
* const credential = new DeviceCodeCredential({
|
|
178
|
-
* tokenCachePersistenceOptions: {
|
|
179
|
-
* enabled: true,
|
|
180
|
-
* },
|
|
181
|
-
* });
|
|
182
|
-
* // We'll use the Microsoft Graph scope as an example
|
|
183
|
-
* const scope = "https://graph.microsoft.com/.default";
|
|
184
|
-
* // Print out part of the access token
|
|
185
|
-
* console.log((await credential.getToken(scope)).token.substring(0, 10), "...");
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
const cachePersistencePlugin = (context) => {
|
|
189
|
-
const { cachePluginControl } = context;
|
|
190
|
-
cachePluginControl.setPersistence(createPersistenceCachePlugin);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
exports.cachePersistencePlugin = cachePersistencePlugin;
|
|
194
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/platforms.ts","../src/provider.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable tsdoc/syntax */\n\nimport * as path from \"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 * @internal\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 * @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(\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { MsalPersistenceOptions } from \"./platforms\";\nimport { msalPersistencePlatforms } from \"./platforms\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin, TokenCachePersistenceOptions } from \"@azure/identity\";\nimport { createPersistenceCachePlugin } from \"./provider\";\n\n/**\n * Plugin context entries for controlling cache plugins.\n */\ninterface CachePluginControl {\n setPersistence(\n persistenceFactory: (\n options?: TokenCachePersistenceOptions,\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:device_code_credential_example\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true,\n * },\n * });\n * // We'll use the Microsoft Graph scope as an example\n * const scope = \"https://graph.microsoft.com/.default\";\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"],"names":["path","FilePersistenceWithDataProtection","DataProtectionScope","__awaiter","KeychainPersistence","FilePersistence","LibSecretPersistence","PersistenceCachePlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;;AAeA;;;;;;;AAOG;AACH,MAAM,0BAA0B,GAC9B,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAA,OAAO,CAAC,GAAG,CAAC,OAAO,MAAA,IAAA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c,CAAC,4BAA4B,CAAC;AACjE;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAsB1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAmB,CAAC,OAAO,EAAE,EAAE;IAChE,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAA6B,CAAC;IAE7D,kBAAkB,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;AAClE,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin, TokenCachePersistenceOptions } from \"@azure/identity\";\nimport { createPersistenceCachePlugin } from \"./provider\";\n\n/**\n * Plugin context entries for controlling cache plugins.\n */\ninterface CachePluginControl {\n setPersistence(\n persistenceFactory: (\n options?: TokenCachePersistenceOptions,\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:device_code_credential_example\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true,\n * },\n * });\n * // We'll use the Microsoft Graph scope as an example\n * const scope = \"https://graph.microsoft.com/.default\";\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platforms.js","sourceRoot":"","sources":["../../src/platforms.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iCAAiC;AAEjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC;;;;;;;GAOG;AACH,MAAM,0BAA0B,GAC9B,MAAA,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,OAAO,0CAAE,OAAO,mDAAG,cAAc,EAAE,SAAS,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAK,CAAC;AAEjF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,UAAU,EAAE;QACV,IAAI,EAAE,YAAY;QAClB,mBAAmB;QACnB,2CAA2C;QAC3C,+DAA+D;QAC/D,yCAAyC;QACzC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;KACrE;IACD,OAAO,EAAE;QACP,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,YAAY;QACpB,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE;YACV,YAAY,EAAE,qCAAqC;YACnD,qCAAqC,EAAE,SAAS;SACjD;QACD,OAAO,EAAE,qCAAqC;QAC9C,OAAO,EAAE,WAAW;KACrB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,qCAAqC;QAC9C,OAAO,EAAE,WAAW;KACrB;CACF,CAAC;AAcF;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,IA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,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC;QACvD,MAAM,eAAe,GAAG,kBAAkB,CAAC,IAAI,IAAI,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEtF,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACzF,qGAAqG;YACrG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YACzB,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,4DAA4D;YAC5D,sFAAsF;YACtF,IAAI,CAAC,6BAA6B,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YACD,OAAO,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAA;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable tsdoc/syntax */\n\nimport * as path from \"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 * @internal\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 * @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(\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,UAAgB,iBAAiB,CAAC,OAA+B;;;QACrE,MAAM,WAAW,GAAG,MAAM,CAAA,MAAA,wBAAwB,CAAC,OAAO,CAAC,QAAQ,CAAC,yEAAG,OAAO,CAAC,CAAA,CAAC;QAEhF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CAAA;AAED,MAAM,UAAgB,4BAA4B,CAChD,OAAgC;;QAEhC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC;QAE3D,OAAO,IAAI,sBAAsB,CAAC,WAAW,EAAE;YAC7C,WAAW,EAAE,GAAG;YAChB,UAAU,EAAE,EAAE;SACf,CAAC,CAAC;IACL,CAAC;CAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { MsalPersistenceOptions } from \"./platforms\";\nimport { msalPersistencePlatforms } from \"./platforms\";\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"]}
|