Update got/form-data to latest
This commit is contained in:
parent
fa66ddde0f
commit
1466f9f1b2
9 changed files with 205 additions and 167 deletions
|
@ -55,7 +55,7 @@ export const upload = async (
|
|||
): Promise<string> => {
|
||||
const headers = { 'User-Agent': getUserAgent(appVersion) };
|
||||
|
||||
const signedForm = await got.get(BASE_URL, { json: true, headers });
|
||||
const signedForm = await got.get(BASE_URL, { responseType: 'json', headers });
|
||||
const { fields, url } = parseTokenBody(signedForm.body);
|
||||
|
||||
const uploadKey = `${fields.key}.gz`;
|
||||
|
|
10
ts/proxy-agent.d.ts
vendored
10
ts/proxy-agent.d.ts
vendored
|
@ -1,10 +0,0 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
declare module 'proxy-agent' {
|
||||
import { Agent } from 'http';
|
||||
|
||||
export default class ProxyAgent extends Agent {
|
||||
constructor(url: string);
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ describe('upload', () => {
|
|||
|
||||
sinon.assert.calledOnce(this.fakeGet);
|
||||
sinon.assert.calledWith(this.fakeGet, 'https://debuglogs.org', {
|
||||
json: true,
|
||||
responseType: 'json',
|
||||
headers: { 'User-Agent': 'Signal-Desktop/1.2.3 Linux' },
|
||||
});
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ export class SocketManager extends EventListener {
|
|||
|
||||
private credentials?: WebAPICredentials;
|
||||
|
||||
private readonly proxyAgent?: ProxyAgent;
|
||||
private readonly proxyAgent?: ReturnType<typeof ProxyAgent>;
|
||||
|
||||
private status = SocketStatus.CLOSED;
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ const FIVE_MINUTES = 5 * durations.MINUTE;
|
|||
type AgentCacheType = {
|
||||
[name: string]: {
|
||||
timestamp: number;
|
||||
agent: ProxyAgent | Agent;
|
||||
agent: ReturnType<typeof ProxyAgent> | Agent;
|
||||
};
|
||||
};
|
||||
const agents: AgentCacheType = {};
|
||||
|
|
|
@ -16,7 +16,7 @@ import ProxyAgent from 'proxy-agent';
|
|||
import { FAILSAFE_SCHEMA, safeLoad } from 'js-yaml';
|
||||
import { gt } from 'semver';
|
||||
import config from 'config';
|
||||
import { get, GotOptions, stream } from 'got';
|
||||
import got, { StrictOptions as GotOptions } from 'got';
|
||||
import { v4 as getGuid } from 'uuid';
|
||||
import pify from 'pify';
|
||||
import mkdirp from 'mkdirp';
|
||||
|
@ -133,11 +133,11 @@ export async function downloadUpdate(
|
|||
validatePath(tempDir, targetSignaturePath);
|
||||
|
||||
logger.info(`downloadUpdate: Downloading signature ${signatureUrl}`);
|
||||
const { body } = await get(signatureUrl, getGotOptions());
|
||||
const { body } = await got.get(signatureUrl, getGotOptions());
|
||||
await writeFile(targetSignaturePath, body);
|
||||
|
||||
logger.info(`downloadUpdate: Downloading update ${updateFileUrl}`);
|
||||
const downloadStream = stream(updateFileUrl, getGotOptions());
|
||||
const downloadStream = got.stream(updateFileUrl, getGotOptions());
|
||||
const writeStream = createWriteStream(targetUpdatePath);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
|
@ -265,28 +265,34 @@ export function parseYaml(yaml: string): JSONUpdateSchema {
|
|||
|
||||
async function getUpdateYaml(): Promise<string> {
|
||||
const targetUrl = getUpdateCheckUrl();
|
||||
const { body } = await get(targetUrl, getGotOptions());
|
||||
const body = await got(targetUrl, getGotOptions()).text();
|
||||
|
||||
if (!body) {
|
||||
throw new Error('Got unexpected response back from update check');
|
||||
}
|
||||
|
||||
return body.toString('utf8');
|
||||
return body;
|
||||
}
|
||||
|
||||
function getGotOptions(): GotOptions<null> {
|
||||
const ca = getCertificateAuthority();
|
||||
function getGotOptions(): GotOptions {
|
||||
const certificateAuthority = getCertificateAuthority();
|
||||
const proxyUrl = getProxyUrl();
|
||||
const agent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
|
||||
const agent = proxyUrl
|
||||
? {
|
||||
http: new ProxyAgent(proxyUrl),
|
||||
https: new ProxyAgent(proxyUrl),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
agent,
|
||||
ca,
|
||||
https: {
|
||||
certificateAuthority,
|
||||
},
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
'User-Agent': getUserAgent(packageJson.version),
|
||||
},
|
||||
useElectronNet: false,
|
||||
timeout: {
|
||||
connect: GOT_CONNECT_TIMEOUT,
|
||||
lookup: GOT_LOOKUP_TIMEOUT,
|
||||
|
|
|
@ -889,6 +889,13 @@
|
|||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-19T18:13:29.628Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/cacheable-lookup/source/index.js",
|
||||
"line": "\t\t].map(promise => wrap(promise)));",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-10-06T15:40:12.124Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/caching-transform/index.js",
|
||||
|
@ -3689,18 +3696,32 @@
|
|||
"reasonDetail": "Part of their google closure 'debug loader'"
|
||||
},
|
||||
{
|
||||
"rule": "DOM-innerHTML",
|
||||
"path": "node_modules/got/node_modules/@sindresorhus/is/dist/index.js",
|
||||
"line": " 'innerHTML',",
|
||||
"rule": "jQuery-append(",
|
||||
"path": "node_modules/got/dist/source/core/index.js",
|
||||
"line": " searchParameters.append(key, '');",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-15T00:38:04.183Z"
|
||||
"updated": "2021-10-06T15:40:12.124Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-append(",
|
||||
"path": "node_modules/got/dist/source/core/index.js",
|
||||
"line": " searchParameters.append(key, value);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-10-06T15:40:12.124Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-append(",
|
||||
"path": "node_modules/got/dist/source/core/index.js",
|
||||
"line": " searchParameters.append(key, value);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-10-06T15:40:12.124Z"
|
||||
},
|
||||
{
|
||||
"rule": "DOM-innerHTML",
|
||||
"path": "node_modules/got/node_modules/@sindresorhus/is/dist/source/index.js",
|
||||
"line": " 'innerHTML',",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-15T00:38:04.183Z"
|
||||
"path": "node_modules/got/node_modules/@sindresorhus/is/dist/index.js",
|
||||
"line": " 'innerHTML',",
|
||||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2021-10-06T15:40:12.124Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-$(",
|
||||
|
@ -14080,4 +14101,4 @@
|
|||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2021-09-17T21:02:59.414Z"
|
||||
}
|
||||
]
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue