Socket
Socket
Sign inDemoInstall

@azure/identity-cache-persistence

Package Overview
Dependencies
74
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1-alpha.20231017.9 to 1.0.1-alpha.20231026.4

dist-esm/identity/src/credentials/brokerAuthOptions.js

2

dist-esm/identity/src/constants.js

@@ -6,3 +6,3 @@ // Copyright (c) Microsoft Corporation.

*/
export const SDK_VERSION = `3.3.2`;
export const SDK_VERSION = `4.0.0-beta.1`;
/**

@@ -9,0 +9,0 @@ * The default client ID for authentication

@@ -27,3 +27,4 @@ // Copyright (c) Microsoft Corporation.

*/
constructor(options = {}) {
constructor(options) {
var _a, _b, _c;
const redirectUri = typeof options.redirectUri === "function"

@@ -34,4 +35,20 @@ ? options.redirectUri()

this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger,
redirectUri }));
const ibcNodeOptions = options;
if ((_a = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _a === void 0 ? void 0 : _a.enabled) {
if (!((_b = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _b === void 0 ? void 0 : _b.parentWindowHandle)) {
throw new Error("In order to do WAM authentication, `parentWindowHandle` under `brokerOptions` is a required parameter");
}
else {
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger,
redirectUri, browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions, brokerOptions: {
enabled: true,
parentWindowHandle: ibcNodeOptions.brokerOptions.parentWindowHandle,
legacyEnableMsaPassthrough: (_c = ibcNodeOptions.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough,
} }));
}
}
else {
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger,
redirectUri, browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions }));
}
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;

@@ -38,0 +55,0 @@ }

@@ -27,2 +27,21 @@ // Copyright (c) Microsoft Corporation.

/**
* The current native broker provider, undefined by default.
* @internal
*/
export let nativeBrokerInfo = undefined;
export function hasNativeBroker() {
return nativeBrokerInfo !== undefined;
}
/**
* An object that allows setting the native broker provider.
* @internal
*/
export const msalNodeFlowNativeBrokerControl = {
setNativeBroker(broker) {
nativeBrokerInfo = {
broker,
};
},
};
/**
* MSAL partial base client for Node.js.

@@ -38,8 +57,4 @@ *

constructor(options) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g;
super(options);
// protected publicApp: msalNode.PublicClientApplication | undefined;
// protected publicAppCae: msalNode.PublicClientApplication | undefined;
// protected confidentialApp: msalNode.ConfidentialClientApplication | undefined;
// protected confidentialAppCae: msalNode.ConfidentialClientApplication | undefined;
this.app = {};

@@ -55,4 +70,7 @@ this.caeApp = {};

}
this.enableBroker = (_b = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _b === void 0 ? void 0 : _b.enabled;
this.enableMsaPassthrough = (_c = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough;
this.parentWindowHandle = (_d = options.brokerOptions) === null || _d === void 0 ? void 0 : _d.parentWindowHandle;
// If persistence has been configured
if (persistenceProvider !== undefined && ((_b = options.tokenCachePersistenceOptions) === null || _b === void 0 ? void 0 : _b.enabled)) {
if (persistenceProvider !== undefined && ((_e = options.tokenCachePersistenceOptions) === null || _e === void 0 ? void 0 : _e.enabled)) {
const nonCaeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);

@@ -63,3 +81,3 @@ const caeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);

}
else if ((_c = options.tokenCachePersistenceOptions) === null || _c === void 0 ? void 0 : _c.enabled) {
else if ((_f = options.tokenCachePersistenceOptions) === null || _f === void 0 ? void 0 : _f.enabled) {
throw new Error([

@@ -72,3 +90,12 @@ "Persistent token caching was requested, but no persistence provider was configured.",

}
this.azureRegion = (_d = options.regionalAuthority) !== null && _d !== void 0 ? _d : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
// If broker has not been configured
if (!hasNativeBroker() && this.enableBroker) {
throw new Error([
"Broker for WAM was requested to be enabled, but no native broker was configured.",
"You must install the identity-broker plugin package (`npm install --save @azure/identity-broker`)",
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
"`useIdentityPlugin(createNativeBrokerPlugin())` before using `enableBroker`.",
].join(" "));
}
this.azureRegion = (_g = options.regionalAuthority) !== null && _g !== void 0 ? _g : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
if (this.azureRegion === RegionalAuthority.AutoDiscoverRegion) {

@@ -151,2 +178,11 @@ this.azureRegion = "AUTO_DISCOVER";

}
if (hasNativeBroker() && this.enableBroker) {
this.msalConfig.broker = {
nativeBrokerPlugin: nativeBrokerInfo.broker,
};
if (!this.parentWindowHandle) {
// error should have been thrown from within the constructor of InteractiveBrowserCredential
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
}
}
if (options === null || options === void 0 ? void 0 : options.enableCae) {

@@ -246,2 +282,14 @@ this.caeApp.public = new msalNode.PublicClientApplication(this.msalConfig);

};
if (hasNativeBroker() && this.enableBroker) {
if (!silentRequest.tokenQueryParameters) {
silentRequest.tokenQueryParameters = {};
}
if (!this.parentWindowHandle) {
// error should have been thrown from within the constructor of InteractiveBrowserCredential
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
}
if (this.enableMsaPassthrough) {
silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
}
}
try {

@@ -248,0 +296,0 @@ this.logger.info("Attempting to acquire token silently");

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __awaiter } from "tslib";
import { MsalNode } from "./msalNodeCommon";
import { MsalNode, hasNativeBroker } from "./msalNodeCommon";
import { credentialLogger } from "../../util/logging";

@@ -21,10 +21,14 @@ import open from "open";

constructor(options) {
var _a, _b;
super(options);
this.loginHint = options.loginHint;
this.errorTemplate = (_a = options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage;
this.successTemplate = (_b = options.browserCustomizationOptions) === null || _b === void 0 ? void 0 : _b.successMessage;
this.logger = credentialLogger("Node.js MSAL Open Browser");
}
doGetToken(scopes, options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
const result = yield this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive({
const interactiveRequest = {
openBrowser: (url) => __awaiter(this, void 0, void 0, function* () {

@@ -38,3 +42,26 @@ yield interactiveBrowserMockable.open(url, { wait: true, newInstance: true });

loginHint: this.loginHint,
});
errorTemplate: this.errorTemplate,
successTemplate: this.successTemplate,
};
if (hasNativeBroker() && this.enableBroker) {
this.logger.verbose("Authentication will resume through the broker");
if (this.parentWindowHandle) {
interactiveRequest.windowHandle = Buffer.from(this.parentWindowHandle);
}
else {
// error should have been thrown from within the constructor of InteractiveBrowserCredential
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
}
if (this.enableMsaPassthrough) {
((_a = interactiveRequest.tokenQueryParameters) !== null && _a !== void 0 ? _a : (interactiveRequest.tokenQueryParameters = {}))["msal_request_type"] =
"consumer_passthrough";
}
}
if (hasNativeBroker() && !this.enableBroker) {
this.logger.verbose("Authentication will resume normally without the broker, since it's not enabled");
}
const result = yield this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
if (result.fromNativeBroker) {
this.logger.verbose(`This result is returned from native broker`);
}
return this.handleResult(scopes, this.clientId, result || undefined);

@@ -41,0 +68,0 @@ }

@@ -174,2 +174,6 @@ // Copyright (c) Microsoft Corporation.

}
if (error.name === "NativeAuthError") {
this.logger.info(formatError(scopes, `Error from the native broker: ${error.message} with status code: ${error.statusCode}`));
return error;
}
return new AuthenticationRequiredError({ scopes, getTokenOptions, message: error.message });

@@ -176,0 +180,0 @@ }

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { msalNodeFlowCacheControl } from "../msal/nodeFlows/msalNodeCommon";
import { msalNodeFlowCacheControl, msalNodeFlowNativeBrokerControl, } from "../msal/nodeFlows/msalNodeCommon";
import { vsCodeCredentialControl } from "../credentials/visualStudioCodeCredential";

@@ -12,2 +12,3 @@ /**

cachePluginControl: msalNodeFlowCacheControl,
nativeBrokerPluginControl: msalNodeFlowNativeBrokerControl,
vsCodeCredentialControl: vsCodeCredentialControl,

@@ -14,0 +15,0 @@ };

{
"name": "@azure/identity-cache-persistence",
"version": "1.0.1-alpha.20231017.9",
"version": "1.0.1-alpha.20231026.4",
"sdk-type": "client",

@@ -63,4 +63,4 @@ "description": "A secure, persistent token cache for Azure Identity credentials that uses the OS secret-management API",

"@azure/core-auth": "^1.5.0",
"@azure/identity": "^3.3.1",
"@azure/msal-node": "^2.0.0",
"@azure/identity": ">=4.0.0-alpha <4.0.0-alphb",
"@azure/msal-node": "^2.3.0",
"@azure/msal-node-extensions": "1.0.0-alpha.25",

@@ -89,3 +89,3 @@ "keytar": "^7.6.0",

"rimraf": "^3.0.0",
"typescript": "~5.0.0",
"typescript": "~5.2.0",
"util": "^0.12.1",

@@ -92,0 +92,0 @@ "sinon": "^15.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc