mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Upgrade axios
dependency (0.21.1
→ 0.27.2
). (#111655)
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@elastic.co>
This commit is contained in:
parent
155e5bf54e
commit
b191f141f3
19 changed files with 2631 additions and 359 deletions
|
@ -223,7 +223,7 @@
|
|||
"abort-controller": "^3.0.0",
|
||||
"antlr4ts": "^0.5.0-alpha.3",
|
||||
"archiver": "^5.2.0",
|
||||
"axios": "^0.21.1",
|
||||
"axios": "^0.27.2",
|
||||
"base64-js": "^1.3.1",
|
||||
"bitmap-sdf": "^1.0.3",
|
||||
"brace": "0.11.1",
|
||||
|
@ -951,7 +951,6 @@
|
|||
"url-loader": "^2.2.0",
|
||||
"val-loader": "^1.1.1",
|
||||
"vinyl-fs": "^3.0.3",
|
||||
"wait-on": "^5.2.1",
|
||||
"watchpack": "^1.6.0",
|
||||
"webpack": "^4.41.5",
|
||||
"webpack-bundle-analyzer": "^4.5.0",
|
||||
|
|
2883
packages/kbn-pm/dist/index.js
vendored
2883
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -196,7 +196,7 @@ describe('downloadToDisk', () => {
|
|||
retryDelaySecMultiplier: 0.1,
|
||||
});
|
||||
await expect(promise).rejects.toMatchInlineSnapshot(
|
||||
`[Error: Request failed with status code 500]`
|
||||
`[AxiosError: Request failed with status code 500]`
|
||||
);
|
||||
expect(logWritter.messages).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
|
@ -269,7 +269,7 @@ describe('downloadToString', () => {
|
|||
maxAttempts: 1,
|
||||
});
|
||||
await expect(promise).rejects.toMatchInlineSnapshot(
|
||||
`[Error: Request failed with status code 200]`
|
||||
`[AxiosError: Request failed with status code 200]`
|
||||
);
|
||||
expect(logWritter.messages).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
|
|
|
@ -18,6 +18,7 @@ export const request = async <T = unknown>({
|
|||
method = 'get',
|
||||
data,
|
||||
configurationUtilities,
|
||||
headers,
|
||||
...rest
|
||||
}: {
|
||||
axios: AxiosInstance;
|
||||
|
@ -37,6 +38,8 @@ export const request = async <T = unknown>({
|
|||
return await axios(url, {
|
||||
...rest,
|
||||
method,
|
||||
// Axios doesn't support `null` value for `headers` property.
|
||||
headers: headers ?? undefined,
|
||||
data: data ?? {},
|
||||
// use httpAgent and httpsAgent and set axios proxy: false, to be able to handle fail on invalid certs
|
||||
httpAgent,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import axios from 'axios';
|
||||
|
||||
import { Logger } from '@kbn/core/server';
|
||||
import { loggingSystemMock } from '@kbn/core/server/mocks';
|
||||
|
@ -16,6 +16,7 @@ import {
|
|||
throwIfSubActionIsNotSupported,
|
||||
getAxiosInstance,
|
||||
} from './utils';
|
||||
import type { ResponseError } from './types';
|
||||
import { connectorTokenClientMock } from '../lib/connector_token_client.mock';
|
||||
import { actionsConfigMock } from '../../actions_config.mock';
|
||||
import { getOAuthJwtAccessToken } from '../lib/get_oauth_jwt_access_token';
|
||||
|
@ -73,7 +74,7 @@ describe('utils', () => {
|
|||
const axiosError = {
|
||||
message: 'An error occurred',
|
||||
response: { data: { error: { message: 'Denied', detail: 'no access' } } },
|
||||
} as AxiosError;
|
||||
} as ResponseError;
|
||||
|
||||
expect(createServiceError(axiosError, 'Unable to do action').message).toBe(
|
||||
'[Action][ServiceNow]: Unable to do action. Error: An error occurred Reason: Denied: no access'
|
||||
|
@ -84,7 +85,7 @@ describe('utils', () => {
|
|||
const axiosError = {
|
||||
message: 'An error occurred',
|
||||
response: { data: { error: null } },
|
||||
} as AxiosError;
|
||||
} as ResponseError;
|
||||
|
||||
expect(createServiceError(axiosError, 'Unable to do action').message).toBe(
|
||||
'[Action][ServiceNow]: Unable to do action. Error: An error occurred Reason: unknown: no error in error response'
|
||||
|
|
|
@ -134,7 +134,11 @@ export const getAxiosInstance = ({
|
|||
tokenUrl: `${snServiceUrl}/oauth_token.do`,
|
||||
connectorTokenClient,
|
||||
});
|
||||
axiosConfig.headers.Authorization = accessToken;
|
||||
|
||||
if (accessToken) {
|
||||
axiosConfig.headers = { ...axiosConfig.headers, Authorization: accessToken };
|
||||
}
|
||||
|
||||
return axiosConfig;
|
||||
},
|
||||
(error) => {
|
||||
|
|
|
@ -158,7 +158,7 @@ export async function executor(
|
|||
|
||||
const axiosInstance = axios.create();
|
||||
|
||||
const result: Result<AxiosResponse, AxiosError> = await promiseResult(
|
||||
const result: Result<AxiosResponse, AxiosError<{ message: string }>> = await promiseResult(
|
||||
request({
|
||||
axios: axiosInstance,
|
||||
method,
|
||||
|
|
|
@ -34,7 +34,7 @@ const getBaseUrl = once(async (kibanaHostname: string) => {
|
|||
await axios.request({ url: kibanaHostname, maxRedirects: 0 });
|
||||
} catch (e) {
|
||||
if (isAxiosError(e)) {
|
||||
const location = e.response?.headers?.location;
|
||||
const location = e.response?.headers?.location ?? '';
|
||||
const hasBasePath = RegExp(/^\/\w{3}$/).test(location);
|
||||
const basePath = hasBasePath ? location : '';
|
||||
return `${kibanaHostname}${basePath}`;
|
||||
|
|
|
@ -6,18 +6,23 @@
|
|||
*/
|
||||
|
||||
import { fetch, arrayBufferFetch } from './fetch';
|
||||
import { AxiosInstance, HeadersDefaults } from 'axios';
|
||||
|
||||
describe('fetch', () => {
|
||||
// WORKAROUND: wrong Axios types, should be fixed in https://github.com/axios/axios/pull/4475
|
||||
const getDefaultHeader = (axiosInstance: AxiosInstance, headerName: string) =>
|
||||
(axiosInstance.defaults.headers as HeadersDefaults & Record<string, string>)[headerName];
|
||||
|
||||
it('test fetch headers', () => {
|
||||
expect(fetch.defaults.headers.Accept).toBe('application/json');
|
||||
expect(fetch.defaults.headers['Content-Type']).toBe('application/json');
|
||||
expect(fetch.defaults.headers['kbn-xsrf']).toBe('professionally-crafted-string-of-text');
|
||||
expect(getDefaultHeader(fetch, 'Accept')).toBe('application/json');
|
||||
expect(getDefaultHeader(fetch, 'Content-Type')).toBe('application/json');
|
||||
expect(getDefaultHeader(fetch, 'kbn-xsrf')).toBe('professionally-crafted-string-of-text');
|
||||
});
|
||||
|
||||
it('test arrayBufferFetch headers', () => {
|
||||
expect(arrayBufferFetch.defaults.headers.Accept).toBe('application/json');
|
||||
expect(arrayBufferFetch.defaults.headers['Content-Type']).toBe('application/json');
|
||||
expect(arrayBufferFetch.defaults.headers['kbn-xsrf']).toBe(
|
||||
expect(getDefaultHeader(arrayBufferFetch, 'Accept')).toBe('application/json');
|
||||
expect(getDefaultHeader(arrayBufferFetch, 'Content-Type')).toBe('application/json');
|
||||
expect(getDefaultHeader(arrayBufferFetch, 'kbn-xsrf')).toBe(
|
||||
'professionally-crafted-string-of-text'
|
||||
);
|
||||
expect(arrayBufferFetch.defaults.responseType).toBe('arraybuffer');
|
||||
|
|
|
@ -168,7 +168,7 @@ export class TelemetryEventsSender {
|
|||
const resp = await axios.post(telemetryUrl, ndjson, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-ndjson',
|
||||
'X-Elastic-Cluster-ID': clusterUuid,
|
||||
...(clusterUuid ? { 'X-Elastic-Cluster-ID': clusterUuid } : undefined),
|
||||
'X-Elastic-Stack-Version': clusterVersionNumber ? clusterVersionNumber : '7.16.0',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -267,8 +267,8 @@ export class TelemetryEventsSender {
|
|||
const resp = await axios.post(telemetryUrl, ndjson, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-ndjson',
|
||||
'X-Elastic-Cluster-ID': clusterUuid,
|
||||
'X-Elastic-Cluster-Name': clusterName,
|
||||
...(clusterUuid ? { 'X-Elastic-Cluster-ID': clusterUuid } : undefined),
|
||||
...(clusterName ? { 'X-Elastic-Cluster-Name': clusterName } : undefined),
|
||||
'X-Elastic-Stack-Version': clusterVersionNumber ? clusterVersionNumber : '8.0.0',
|
||||
...(licenseId ? { 'X-Elastic-License-ID': licenseId } : {}),
|
||||
},
|
||||
|
|
|
@ -55,7 +55,7 @@ class BlocklistDataLoaderError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
const handleThrowAxiosHttpError = (err: AxiosError): never => {
|
||||
const handleThrowAxiosHttpError = (err: AxiosError<{ message?: string }>): never => {
|
||||
let message = err.message;
|
||||
|
||||
if (err.response) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class EventFilterDataLoaderError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
const handleThrowAxiosHttpError = (err: AxiosError): never => {
|
||||
const handleThrowAxiosHttpError = (err: AxiosError<{ message?: string }>): never => {
|
||||
let message = err.message;
|
||||
|
||||
if (err.response) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class HostIsolationExceptionDataLoaderError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
const handleThrowAxiosHttpError = (err: AxiosError): never => {
|
||||
const handleThrowAxiosHttpError = (err: AxiosError<{ message?: string }>): never => {
|
||||
let message = err.message;
|
||||
|
||||
if (err.response) {
|
||||
|
|
|
@ -299,8 +299,8 @@ export class TelemetryEventsSender implements ITelemetryEventsSender {
|
|||
const resp = await axiosInstance.post(telemetryUrl, ndjson, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-ndjson',
|
||||
'X-Elastic-Cluster-ID': clusterUuid,
|
||||
'X-Elastic-Cluster-Name': clusterName,
|
||||
...(clusterUuid ? { 'X-Elastic-Cluster-ID': clusterUuid } : undefined),
|
||||
...(clusterName ? { 'X-Elastic-Cluster-Name': clusterName } : undefined),
|
||||
'X-Elastic-Stack-Version': clusterVersionNumber ? clusterVersionNumber : '8.0.0',
|
||||
...(licenseId ? { 'X-Elastic-License-ID': licenseId } : {}),
|
||||
},
|
||||
|
|
|
@ -174,8 +174,8 @@ export class TelemetryEventsSender {
|
|||
const resp = await axios.post(telemetryUrl, ndjson, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-ndjson',
|
||||
'X-Elastic-Cluster-ID': clusterUuid,
|
||||
'X-Elastic-Cluster-Name': clusterName,
|
||||
...(clusterUuid ? { 'X-Elastic-Cluster-ID': clusterUuid } : undefined),
|
||||
...(clusterName ? { 'X-Elastic-Cluster-Name': clusterName } : undefined),
|
||||
'X-Elastic-Stack-Version': clusterVersionNumber ? clusterVersionNumber : '8.2.0',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ export interface Credentials {
|
|||
}
|
||||
|
||||
function extractCookieValue(authResponse: AxiosResponse) {
|
||||
return authResponse.headers['set-cookie'][0].toString().split(';')[0].split('sid=')[1] as string;
|
||||
return authResponse.headers['set-cookie']?.[0].toString().split(';')[0].split('sid=')[1] ?? '';
|
||||
}
|
||||
export class AuthService extends FtrService {
|
||||
private readonly kibanaServer = this.ctx.getService('kibanaServer');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import axios, { AxiosInstance, AxiosRequestHeaders } from 'axios';
|
||||
import type { Capabilities as UICapabilities } from '@kbn/core/types';
|
||||
import { format as formatUrl } from 'url';
|
||||
import util from 'util';
|
||||
|
@ -61,7 +61,7 @@ export class UICapabilitiesService {
|
|||
this.log.debug(
|
||||
`requesting ${spaceUrlPrefix}/api/core/capabilities to parse the uiCapabilities`
|
||||
);
|
||||
const requestHeaders = credentials
|
||||
const requestHeaders: AxiosRequestHeaders = credentials
|
||||
? {
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
`${credentials.username}:${credentials.password}`
|
||||
|
|
37
yarn.lock
37
yarn.lock
|
@ -8693,11 +8693,11 @@ axe-core@^4.2.0:
|
|||
integrity sha512-WKTW1+xAzhMS5dJsxWkliixlO/PqC4VhmO9T4juNYcaTg9jzWiJsou6m5pxWYGfigWbwzJWeFY6z47a+4neRXA==
|
||||
|
||||
axios@^0.21.1:
|
||||
version "0.21.1"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
|
||||
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
|
||||
version "0.21.4"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
||||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
|
||||
dependencies:
|
||||
follow-redirects "^1.10.0"
|
||||
follow-redirects "^1.14.0"
|
||||
|
||||
axios@^0.24.0:
|
||||
version "0.24.0"
|
||||
|
@ -8713,6 +8713,14 @@ axios@^0.25.0:
|
|||
dependencies:
|
||||
follow-redirects "^1.14.7"
|
||||
|
||||
axios@^0.27.2:
|
||||
version "0.27.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.9"
|
||||
form-data "^4.0.0"
|
||||
|
||||
axobject-query@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
||||
|
@ -14743,10 +14751,10 @@ follow-redirects@1.12.1:
|
|||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.12.1.tgz#de54a6205311b93d60398ebc01cf7015682312b6"
|
||||
integrity sha512-tmRv0AVuR7ZyouUHLeNSiO6pqulF7dYa3s19c6t+wz9LD69/uSzdMxJ2S91nTI9U3rt/IldxpzMOFejp6f0hjg==
|
||||
|
||||
follow-redirects@^1.0.0, follow-redirects@^1.10.0, follow-redirects@^1.14.4, follow-redirects@^1.14.7:
|
||||
version "1.14.9"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
|
||||
integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==
|
||||
follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.7, follow-redirects@^1.14.9:
|
||||
version "1.15.0"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
|
||||
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
|
||||
|
||||
font-awesome@4.7.0:
|
||||
version "4.7.0"
|
||||
|
@ -25435,7 +25443,7 @@ rxjs-marbles@^5.0.6:
|
|||
dependencies:
|
||||
fast-equals "^2.0.0"
|
||||
|
||||
rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.3:
|
||||
rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0:
|
||||
version "6.6.3"
|
||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
|
||||
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
|
||||
|
@ -29651,17 +29659,6 @@ w3c-xmlserializer@^2.0.0:
|
|||
dependencies:
|
||||
xml-name-validator "^3.0.0"
|
||||
|
||||
wait-on@^5.2.1:
|
||||
version "5.2.1"
|
||||
resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-5.2.1.tgz#05b66fcb4d7f5da01537f03e7cf96e8836422996"
|
||||
integrity sha512-H2F986kNWMU9hKlI9l/ppO6tN8ZSJd35yBljMLa1/vjzWP++Qh6aXyt77/u7ySJFZQqBtQxnvm/xgG48AObXcw==
|
||||
dependencies:
|
||||
axios "^0.21.1"
|
||||
joi "^17.3.0"
|
||||
lodash "^4.17.20"
|
||||
minimist "^1.2.5"
|
||||
rxjs "^6.6.3"
|
||||
|
||||
walk@^2.3.14:
|
||||
version "2.3.14"
|
||||
resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.14.tgz#60ec8631cfd23276ae1e7363ce11d626452e1ef3"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue