Bump tough-cookie and @azure/ms-rest-js (#1763)

* Bump tough-cookie and @azure/ms-rest-js

Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) and [@azure/ms-rest-js](https://github.com/Azure/ms-rest-js). These dependencies needed to be updated together.

Updates `tough-cookie` from 4.0.0 to 4.1.3
- [Release notes](https://github.com/salesforce/tough-cookie/releases)
- [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md)
- [Commits](https://github.com/salesforce/tough-cookie/compare/v4.0.0...v4.1.3)

Updates `@azure/ms-rest-js` from 2.6.2 to 2.7.0
- [Changelog](https://github.com/Azure/ms-rest-js/blob/master/Changelog.md)
- [Commits](https://github.com/Azure/ms-rest-js/commits)

---
updated-dependencies:
- dependency-name: tough-cookie
  dependency-type: indirect
- dependency-name: "@azure/ms-rest-js"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update checked-in dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-07-10 01:41:51 -07:00 committed by GitHub
parent 85c77f1dfc
commit 8f80d7761c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 4194 additions and 4573 deletions

View file

@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import * as tough from "tough-cookie";
import * as http from "http";
import * as https from "https";
import node_fetch from "node-fetch";
@ -17,8 +16,6 @@ import { WebResourceLike } from "./webResource";
import { createProxyAgent, ProxyAgent } from "./proxyAgent";
export class NodeFetchHttpClient extends FetchHttpClient {
private readonly cookieJar = new tough.CookieJar(undefined, { looseMode: true });
async fetch(input: CommonRequestInfo, init?: CommonRequestInit): Promise<CommonResponse> {
return (node_fetch(input, init) as unknown) as Promise<CommonResponse>;
}
@ -26,20 +23,6 @@ export class NodeFetchHttpClient extends FetchHttpClient {
async prepareRequest(httpRequest: WebResourceLike): Promise<Partial<RequestInit>> {
const requestInit: Partial<RequestInit & { agent?: any }> = {};
if (this.cookieJar && !httpRequest.headers.get("Cookie")) {
const cookieString = await new Promise<string>((resolve, reject) => {
this.cookieJar!.getCookieString(httpRequest.url, (err, cookie) => {
if (err) {
reject(err);
} else {
resolve(cookie);
}
});
});
httpRequest.headers.set("Cookie", cookieString);
}
if (httpRequest.agentSettings) {
const { http: httpAgent, https: httpsAgent } = httpRequest.agentSettings;
if (httpsAgent && httpRequest.url.startsWith("https")) {
@ -71,25 +54,8 @@ export class NodeFetchHttpClient extends FetchHttpClient {
return requestInit;
}
async processRequest(operationResponse: HttpOperationResponse): Promise<void> {
if (this.cookieJar) {
const setCookieHeader = operationResponse.headers.get("Set-Cookie");
if (setCookieHeader != undefined) {
await new Promise((resolve, reject) => {
this.cookieJar!.setCookie(
setCookieHeader,
operationResponse.request.url,
{ ignoreError: true },
(err) => {
if (err) {
reject(err);
} else {
resolve();
}
}
);
});
}
}
async processRequest(_operationResponse: HttpOperationResponse): Promise<void> {
/* no_op */
return;
}
}

View file

@ -7,7 +7,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "2.6.2",
msRestVersion: "2.7.0",
/**
* Specifies HTTP.

View file

@ -10,10 +10,14 @@ const parser = new DOMParser();
// according to the spec. There are no HTML/XSS security concerns on the usage of
// parseFromString() here.
let ttPolicy: Pick<TrustedTypePolicy, "createHTML"> | undefined;
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/ms-rest-js#xml.browser", {
createHTML: (s) => s,
});
try {
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/ms-rest-js#xml.browser", {
createHTML: (s: any) => s,
});
}
} catch (e) {
console.warn('Could not create trusted types policy "@azure/ms-rest-js#xml.browser"');
}
export function parseXML(str: string): Promise<any> {