@microsoft/vscode-azext-azureutils
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -432,1 +432,10 @@ /*--------------------------------------------------------------------------------------------- | ||
export function setupAzureLogger(logOutputChannel: LogOutputChannel): Disposable; | ||
/** | ||
* Replaces the usage of BasicAuthenticationCredentials for ServiceClients imported from @azure/core-pipelines | ||
* | ||
* @param client - The service client. This will typically be a generalClient | ||
* @param userName - Username to be used with basic authentication login | ||
* @param password - Password. Gets encoded before being set in the header | ||
*/ | ||
export function addBasicAuthenticationCredentialsToClient(client: ServiceClient, userName: string, password: string): void; |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CorrelationIdPolicy = exports.createGenericClient = exports.sendRequestWithTimeout = exports.createAzureSubscriptionClient = exports.createAzureClient = exports.parseClientContext = void 0; | ||
exports.CorrelationIdPolicy = exports.addBasicAuthenticationCredentialsToClient = exports.createGenericClient = exports.sendRequestWithTimeout = exports.createAzureSubscriptionClient = exports.createAzureClient = exports.parseClientContext = void 0; | ||
const core_client_1 = require("@azure/core-client"); | ||
@@ -123,2 +123,6 @@ const core_rest_pipeline_1 = require("@azure/core-rest-pipeline"); | ||
} | ||
function addBasicAuthenticationCredentialsToClient(client, userName, password) { | ||
client.pipeline.addPolicy(new BasicAuthenticationCredentialsPolicy(userName, password), { phase: 'Serialize' }); | ||
} | ||
exports.addBasicAuthenticationCredentialsToClient = addBasicAuthenticationCredentialsToClient; | ||
/** | ||
@@ -247,2 +251,25 @@ * Automatically add id to correlate our telemetry with the platform team's telemetry | ||
} | ||
/** | ||
* Encodes userName and password and signs a request with the Authentication header. | ||
* Imitates BasicAuthenticationCredentials from ms-rest-js | ||
*/ | ||
class BasicAuthenticationCredentialsPolicy { | ||
constructor(userName, password) { | ||
this.userName = userName; | ||
this.password = password; | ||
this.name = BasicAuthenticationCredentialsPolicy.Name; | ||
} | ||
sendRequest(request, next) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const credentials = `${this.userName}:${this.password}`; | ||
const DEFAULT_AUTHORIZATION_SCHEME = "Basic"; | ||
const encodedCredentials = `${DEFAULT_AUTHORIZATION_SCHEME} ${Buffer.from(credentials).toString("base64")}`; | ||
if (!request.headers) | ||
request.headers = (0, core_rest_pipeline_1.createHttpHeaders)(); | ||
request.headers.set("authorization", encodedCredentials); | ||
return yield next(request); | ||
}); | ||
} | ||
} | ||
BasicAuthenticationCredentialsPolicy.Name = 'BasicAuthenticationCredentialsPolicy'; | ||
//# sourceMappingURL=createAzureClient.js.map |
{ | ||
"name": "@microsoft/vscode-azext-azureutils", | ||
"author": "Microsoft Corporation", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Common Azure utils for developing Azure extensions for VS Code", | ||
@@ -6,0 +6,0 @@ "tags": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131066
2123