@ms-cloudpack/remote-cache 0.6.3 → 0.6.4
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.
|
@@ -24221,52 +24221,47 @@ var tokenCachePersistenceOptions = {
|
|
|
24221
24221
|
enabled: true,
|
|
24222
24222
|
name: "cloudpack"
|
|
24223
24223
|
};
|
|
24224
|
-
function getCredentialInternal(loginMethod, authenticationRecord) {
|
|
24224
|
+
function getCredentialInternal(loginMethod, authenticationRecord, tenantId) {
|
|
24225
24225
|
switch (loginMethod) {
|
|
24226
24226
|
case "interactive":
|
|
24227
24227
|
return new import_identity3.InteractiveBrowserCredential({
|
|
24228
24228
|
redirectUri: "http://localhost:1337",
|
|
24229
24229
|
authenticationRecord,
|
|
24230
|
-
tokenCachePersistenceOptions
|
|
24230
|
+
tokenCachePersistenceOptions,
|
|
24231
|
+
tenantId
|
|
24231
24232
|
});
|
|
24232
24233
|
case "device-code":
|
|
24233
24234
|
return new import_identity3.DeviceCodeCredential({
|
|
24234
24235
|
authenticationRecord,
|
|
24235
|
-
tokenCachePersistenceOptions
|
|
24236
|
+
tokenCachePersistenceOptions,
|
|
24237
|
+
tenantId
|
|
24236
24238
|
});
|
|
24237
24239
|
default:
|
|
24238
24240
|
throw new Error(`Invalid login method: ${loginMethod}`);
|
|
24239
24241
|
}
|
|
24240
24242
|
}
|
|
24241
24243
|
__name(getCredentialInternal, "getCredentialInternal");
|
|
24242
|
-
async function getCredential(loginMethod, cachePath) {
|
|
24244
|
+
async function getCredential(loginMethod, cachePath, tenantId) {
|
|
24243
24245
|
if (loginMethod == "azure-cli") {
|
|
24244
24246
|
return new import_identity3.AzureCliCredential();
|
|
24245
24247
|
}
|
|
24246
24248
|
(0, import_identity3.useIdentityPlugin)(import_identity_cache_persistence.cachePersistencePlugin);
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
|
|
24253
|
-
|
|
24254
|
-
|
|
24255
|
-
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
return Promise.resolve(token);
|
|
24262
|
-
}
|
|
24263
|
-
};
|
|
24264
|
-
if (authenticationRecord) {
|
|
24265
|
-
saveAuthenticationRecord(cachePath, authenticationRecord);
|
|
24266
|
-
}
|
|
24267
|
-
return storageCustomCredential;
|
|
24249
|
+
const credential = getCredentialInternal(loginMethod, getAuthenticationRecord(cachePath), tenantId);
|
|
24250
|
+
if (loginMethod == "interactive") {
|
|
24251
|
+
console.warn(
|
|
24252
|
+
"Prepare to sign in \u2013 we may launch a browser page for you. Simply follow the instructions on the login page to seamlessly complete the authentication process."
|
|
24253
|
+
);
|
|
24254
|
+
}
|
|
24255
|
+
const storageScope = "https://storage.azure.com/.default";
|
|
24256
|
+
const authenticationRecord = await credential.authenticate(storageScope);
|
|
24257
|
+
const token = await credential.getToken(storageScope);
|
|
24258
|
+
const storageCustomCredential = {
|
|
24259
|
+
getToken: () => Promise.resolve(token)
|
|
24260
|
+
};
|
|
24261
|
+
if (authenticationRecord) {
|
|
24262
|
+
saveAuthenticationRecord(cachePath, authenticationRecord);
|
|
24268
24263
|
}
|
|
24269
|
-
return
|
|
24264
|
+
return storageCustomCredential;
|
|
24270
24265
|
}
|
|
24271
24266
|
__name(getCredential, "getCredential");
|
|
24272
24267
|
export {
|
package/dist/index.js
CHANGED
|
@@ -80,12 +80,12 @@ var blockListIsInvalidRetryPolicy = {
|
|
|
80
80
|
import { RetryManager } from "@ms-cloudpack/retry";
|
|
81
81
|
async function createRemoteCacheClient(params) {
|
|
82
82
|
const { context, options } = params;
|
|
83
|
-
const { container, loginMethod, storageAccount, cachePath } = options;
|
|
84
|
-
const { getCredential } = await import("./getCredential-
|
|
83
|
+
const { container, loginMethod, storageAccount, cachePath, tenantId } = options;
|
|
84
|
+
const { getCredential } = await import("./getCredential-DHB4UIE2.js");
|
|
85
85
|
const { AzureRemoteCacheClient } = await import("./AzureRemoteCacheClient-NEV2XCF7.js");
|
|
86
86
|
const { ReporterDecorator } = await import("./ReporterDecorator-SNBYNGOT.js");
|
|
87
87
|
const { getListOfBlobs } = await import("./getListOfBlobs-E5OFG2MF.js");
|
|
88
|
-
const credential = await getCredential(loginMethod, cachePath);
|
|
88
|
+
const credential = await getCredential(loginMethod, cachePath, tenantId);
|
|
89
89
|
const remoteCacheClientOptions = {
|
|
90
90
|
storageAccount,
|
|
91
91
|
container,
|
|
@@ -6,5 +6,5 @@ import type { LoginMethod } from '../types/LoginMethod.js';
|
|
|
6
6
|
* Otherwise, it will return an InteractiveBrowserCredential or a DeviceCodeCredential with persistent token settings.
|
|
7
7
|
* If an authentication record has never been saved before, it will authenticate the credential and save the authentication record.
|
|
8
8
|
*/
|
|
9
|
-
export declare function getCredential(loginMethod: LoginMethod, cachePath: string): Promise<TokenCredential>;
|
|
9
|
+
export declare function getCredential(loginMethod: LoginMethod, cachePath: string, tenantId?: string): Promise<TokenCredential>;
|
|
10
10
|
//# sourceMappingURL=getCredential.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/remote-cache",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Manages syncing the local Cloudpack cached assets to/from a remote storage service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@azure/msal-node-extensions": "^1.0.10",
|
|
31
31
|
"@ms-cloudpack/retry": "^0.1.1",
|
|
32
|
-
"@ms-cloudpack/task-reporter": "^0.
|
|
32
|
+
"@ms-cloudpack/task-reporter": "^0.13.0",
|
|
33
33
|
"@ms-cloudpack/telemetry": "^0.5.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|