@jjrawlins/cdk-iam-policy-builder-helper 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +211 -62
- package/.mergify.yml +60 -0
- package/cdk-iam-policy-builder-helper/go.mod +13 -0
- package/{jjrawlinscdkiampolicybuilderhelper → cdk-iam-policy-builder-helper}/jsii/jsii.go +2 -2
- package/cdk-iam-policy-builder-helper/version +1 -0
- package/lib/bin/download-actions-json.js +3 -7
- package/lib/constructs/Actions.d.ts +800 -61
- package/lib/constructs/Actions.js +801 -62
- package/lib/constructs/ManagedPolicies.d.ts +248 -40
- package/lib/constructs/ManagedPolicies.js +249 -41
- package/methods_list.txt +19274 -0
- package/node_modules/axios/CHANGELOG.md +257 -0
- package/node_modules/axios/README.md +71 -87
- package/node_modules/axios/dist/axios.js +303 -235
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -1
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +230 -177
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +230 -177
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -1
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +268 -187
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +22 -6
- package/node_modules/axios/index.d.ts +14 -4
- package/node_modules/axios/lib/adapters/fetch.js +22 -22
- package/node_modules/axios/lib/adapters/http.js +7 -7
- package/node_modules/axios/lib/cancel/CancelToken.js +14 -0
- package/node_modules/axios/lib/core/Axios.js +20 -6
- package/node_modules/axios/lib/core/AxiosError.js +5 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +15 -3
- package/node_modules/axios/lib/core/buildFullPath.js +3 -2
- package/node_modules/axios/lib/core/mergeConfig.js +6 -6
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/buildURL.js +7 -1
- package/node_modules/axios/lib/helpers/composeSignals.js +31 -29
- package/node_modules/axios/lib/helpers/formDataToStream.js +6 -5
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +12 -65
- package/node_modules/axios/lib/helpers/resolveConfig.js +1 -1
- package/node_modules/axios/lib/helpers/throttle.js +1 -1
- package/node_modules/axios/lib/helpers/toFormData.js +4 -0
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +4 -3
- package/node_modules/axios/lib/helpers/trackStream.js +25 -5
- package/node_modules/axios/lib/helpers/validator.js +8 -0
- package/node_modules/axios/lib/platform/common/utils.js +5 -4
- package/node_modules/axios/lib/platform/node/index.js +26 -0
- package/node_modules/axios/lib/utils.js +48 -28
- package/node_modules/axios/package.json +14 -5
- package/node_modules/form-data/CHANGELOG.md +601 -0
- package/node_modules/form-data/{Readme.md → README.md} +34 -37
- package/node_modules/form-data/lib/browser.js +3 -1
- package/node_modules/form-data/lib/form_data.js +126 -135
- package/node_modules/form-data/lib/populate.js +5 -5
- package/node_modules/form-data/package.json +24 -16
- package/package.json +16 -10
- package/jjrawlinscdkiampolicybuilderhelper/go.mod +0 -13
- package/jjrawlinscdkiampolicybuilderhelper/version +0 -1
- package/node_modules/axios/SECURITY.md +0 -6
- /package/{jjrawlinscdkiampolicybuilderhelper → cdk-iam-policy-builder-helper}/LICENSE +0 -0
- /package/{jjrawlinscdkiampolicybuilderhelper → cdk-iam-policy-builder-helper}/README.md +0 -0
|
@@ -6,7 +6,7 @@ type MethodsHeaders = Partial<{
|
|
|
6
6
|
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
|
7
7
|
} & {common: AxiosHeaders}>;
|
|
8
8
|
|
|
9
|
-
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string
|
|
9
|
+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
|
|
10
10
|
|
|
11
11
|
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
|
|
12
12
|
|
|
@@ -77,6 +77,8 @@ declare class AxiosHeaders {
|
|
|
77
77
|
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
|
78
78
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
|
79
79
|
|
|
80
|
+
getSetCookie(): string[];
|
|
81
|
+
|
|
80
82
|
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -97,6 +99,14 @@ declare class AxiosError<T = unknown, D = any> extends Error {
|
|
|
97
99
|
status?: number;
|
|
98
100
|
toJSON: () => object;
|
|
99
101
|
cause?: Error;
|
|
102
|
+
static from<T = unknown, D = any>(
|
|
103
|
+
error: Error | unknown,
|
|
104
|
+
code?: string,
|
|
105
|
+
config?: axios.InternalAxiosRequestConfig<D>,
|
|
106
|
+
request?: any,
|
|
107
|
+
response?: axios.AxiosResponse<T, D>,
|
|
108
|
+
customProps?: object,
|
|
109
|
+
): AxiosError<T, D>;
|
|
100
110
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
|
101
111
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
|
102
112
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
|
@@ -359,7 +369,7 @@ declare namespace axios {
|
|
|
359
369
|
|
|
360
370
|
type Milliseconds = number;
|
|
361
371
|
|
|
362
|
-
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
|
|
372
|
+
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
|
|
363
373
|
|
|
364
374
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
|
365
375
|
|
|
@@ -376,6 +386,7 @@ declare namespace axios {
|
|
|
376
386
|
url?: string;
|
|
377
387
|
method?: Method | string;
|
|
378
388
|
baseURL?: string;
|
|
389
|
+
allowAbsoluteUrls?: boolean;
|
|
379
390
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
|
380
391
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
|
381
392
|
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
|
@@ -417,13 +428,13 @@ declare namespace axios {
|
|
|
417
428
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
418
429
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
419
430
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
420
|
-
fetchOptions?: Record<string, any>;
|
|
431
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
421
432
|
}
|
|
422
433
|
|
|
423
434
|
// Alias
|
|
424
435
|
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
|
425
436
|
|
|
426
|
-
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
|
437
|
+
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
|
427
438
|
headers: AxiosRequestHeaders;
|
|
428
439
|
}
|
|
429
440
|
|
|
@@ -493,8 +504,12 @@ declare namespace axios {
|
|
|
493
504
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
|
494
505
|
}
|
|
495
506
|
|
|
507
|
+
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
|
508
|
+
|
|
509
|
+
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
|
510
|
+
|
|
496
511
|
interface AxiosInterceptorManager<V> {
|
|
497
|
-
use
|
|
512
|
+
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
|
498
513
|
eject(id: number): void;
|
|
499
514
|
clear(): void;
|
|
500
515
|
}
|
|
@@ -503,6 +518,7 @@ declare namespace axios {
|
|
|
503
518
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
504
519
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
505
520
|
|
|
521
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
506
522
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
|
507
523
|
headers: HeadersDefaults & {
|
|
508
524
|
[key: string]: AxiosHeaderValue
|
|
@@ -521,7 +537,6 @@ declare namespace axios {
|
|
|
521
537
|
}
|
|
522
538
|
|
|
523
539
|
interface AxiosStatic extends AxiosInstance {
|
|
524
|
-
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
525
540
|
Cancel: CancelStatic;
|
|
526
541
|
CancelToken: CancelTokenStatic;
|
|
527
542
|
Axios: typeof Axios;
|
|
@@ -537,6 +552,7 @@ declare namespace axios {
|
|
|
537
552
|
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
|
538
553
|
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
|
539
554
|
AxiosHeaders: typeof AxiosHeaders;
|
|
555
|
+
mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
|
540
556
|
}
|
|
541
557
|
}
|
|
542
558
|
|
|
@@ -74,6 +74,8 @@ export class AxiosHeaders {
|
|
|
74
74
|
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
|
75
75
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
|
76
76
|
|
|
77
|
+
getSetCookie(): string[];
|
|
78
|
+
|
|
77
79
|
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -300,7 +302,7 @@ export interface AxiosProgressEvent {
|
|
|
300
302
|
|
|
301
303
|
type Milliseconds = number;
|
|
302
304
|
|
|
303
|
-
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | string;
|
|
305
|
+
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
|
|
304
306
|
|
|
305
307
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
|
306
308
|
|
|
@@ -317,6 +319,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
317
319
|
url?: string;
|
|
318
320
|
method?: Method | string;
|
|
319
321
|
baseURL?: string;
|
|
322
|
+
allowAbsoluteUrls?: boolean;
|
|
320
323
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
|
321
324
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
|
322
325
|
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
|
@@ -358,7 +361,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
358
361
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
359
362
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
360
363
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
361
|
-
fetchOptions?: Record<string, any>;
|
|
364
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
// Alias
|
|
@@ -476,8 +479,12 @@ export interface AxiosInterceptorOptions {
|
|
|
476
479
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
|
477
480
|
}
|
|
478
481
|
|
|
482
|
+
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
|
483
|
+
|
|
484
|
+
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
|
485
|
+
|
|
479
486
|
export interface AxiosInterceptorManager<V> {
|
|
480
|
-
use
|
|
487
|
+
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
|
481
488
|
eject(id: number): void;
|
|
482
489
|
clear(): void;
|
|
483
490
|
}
|
|
@@ -507,6 +514,7 @@ export interface AxiosInstance extends Axios {
|
|
|
507
514
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
508
515
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
509
516
|
|
|
517
|
+
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
510
518
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
|
511
519
|
headers: HeadersDefaults & {
|
|
512
520
|
[key: string]: AxiosHeaderValue
|
|
@@ -538,8 +546,9 @@ export function isCancel(value: any): value is Cancel;
|
|
|
538
546
|
|
|
539
547
|
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
|
540
548
|
|
|
549
|
+
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
|
550
|
+
|
|
541
551
|
export interface AxiosStatic extends AxiosInstance {
|
|
542
|
-
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
543
552
|
Cancel: CancelStatic;
|
|
544
553
|
CancelToken: CancelTokenStatic;
|
|
545
554
|
Axios: typeof Axios;
|
|
@@ -555,6 +564,7 @@ export interface AxiosStatic extends AxiosInstance {
|
|
|
555
564
|
getAdapter: typeof getAdapter;
|
|
556
565
|
CanceledError: typeof CanceledError;
|
|
557
566
|
AxiosHeaders: typeof AxiosHeaders;
|
|
567
|
+
mergeConfig: typeof mergeConfig;
|
|
558
568
|
}
|
|
559
569
|
|
|
560
570
|
declare const axios: AxiosStatic;
|
|
@@ -69,7 +69,11 @@ const getBodyLength = async (body) => {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if(utils.isSpecCompliantForm(body)) {
|
|
72
|
-
|
|
72
|
+
const _request = new Request(platform.origin, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body,
|
|
75
|
+
});
|
|
76
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
if(utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) {
|
|
@@ -109,18 +113,13 @@ export default isFetchSupported && (async (config) => {
|
|
|
109
113
|
|
|
110
114
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
111
115
|
|
|
112
|
-
let
|
|
113
|
-
composeSignals([signal, cancelToken], timeout) : [];
|
|
114
|
-
|
|
115
|
-
let finished, request;
|
|
116
|
+
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
!finished && setTimeout(() => {
|
|
119
|
-
composedSignal && composedSignal.unsubscribe();
|
|
120
|
-
});
|
|
118
|
+
let request;
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
121
|
+
composedSignal.unsubscribe();
|
|
122
|
+
});
|
|
124
123
|
|
|
125
124
|
let requestContentLength;
|
|
126
125
|
|
|
@@ -147,7 +146,7 @@ export default isFetchSupported && (async (config) => {
|
|
|
147
146
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
148
147
|
);
|
|
149
148
|
|
|
150
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
|
149
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
|
|
@@ -155,6 +154,9 @@ export default isFetchSupported && (async (config) => {
|
|
|
155
154
|
withCredentials = withCredentials ? 'include' : 'omit';
|
|
156
155
|
}
|
|
157
156
|
|
|
157
|
+
// Cloudflare Workers throws when credentials are defined
|
|
158
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
159
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
158
160
|
request = new Request(url, {
|
|
159
161
|
...fetchOptions,
|
|
160
162
|
signal: composedSignal,
|
|
@@ -162,14 +164,14 @@ export default isFetchSupported && (async (config) => {
|
|
|
162
164
|
headers: headers.normalize().toJSON(),
|
|
163
165
|
body: data,
|
|
164
166
|
duplex: "half",
|
|
165
|
-
credentials: withCredentials
|
|
167
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
166
168
|
});
|
|
167
169
|
|
|
168
|
-
let response = await fetch(request);
|
|
170
|
+
let response = await fetch(request, fetchOptions);
|
|
169
171
|
|
|
170
172
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
171
173
|
|
|
172
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
174
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
173
175
|
const options = {};
|
|
174
176
|
|
|
175
177
|
['status', 'statusText', 'headers'].forEach(prop => {
|
|
@@ -186,8 +188,8 @@ export default isFetchSupported && (async (config) => {
|
|
|
186
188
|
response = new Response(
|
|
187
189
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
188
190
|
flush && flush();
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
+
unsubscribe && unsubscribe();
|
|
192
|
+
}),
|
|
191
193
|
options
|
|
192
194
|
);
|
|
193
195
|
}
|
|
@@ -196,9 +198,7 @@ export default isFetchSupported && (async (config) => {
|
|
|
196
198
|
|
|
197
199
|
let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config);
|
|
198
200
|
|
|
199
|
-
!isStreamResponse &&
|
|
200
|
-
|
|
201
|
-
stopTimeout && stopTimeout();
|
|
201
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
202
202
|
|
|
203
203
|
return await new Promise((resolve, reject) => {
|
|
204
204
|
settle(resolve, reject, {
|
|
@@ -211,9 +211,9 @@ export default isFetchSupported && (async (config) => {
|
|
|
211
211
|
})
|
|
212
212
|
})
|
|
213
213
|
} catch (err) {
|
|
214
|
-
|
|
214
|
+
unsubscribe && unsubscribe();
|
|
215
215
|
|
|
216
|
-
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
216
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
217
217
|
throw Object.assign(
|
|
218
218
|
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
219
219
|
{
|
|
@@ -4,7 +4,7 @@ import utils from './../utils.js';
|
|
|
4
4
|
import settle from './../core/settle.js';
|
|
5
5
|
import buildFullPath from '../core/buildFullPath.js';
|
|
6
6
|
import buildURL from './../helpers/buildURL.js';
|
|
7
|
-
import
|
|
7
|
+
import proxyFromEnv from 'proxy-from-env';
|
|
8
8
|
import http from 'http';
|
|
9
9
|
import https from 'https';
|
|
10
10
|
import util from 'util';
|
|
@@ -83,7 +83,7 @@ function dispatchBeforeRedirect(options, responseDetails) {
|
|
|
83
83
|
function setProxy(options, configProxy, location) {
|
|
84
84
|
let proxy = configProxy;
|
|
85
85
|
if (!proxy && proxy !== false) {
|
|
86
|
-
const proxyUrl = getProxyForUrl(location);
|
|
86
|
+
const proxyUrl = proxyFromEnv.getProxyForUrl(location);
|
|
87
87
|
if (proxyUrl) {
|
|
88
88
|
proxy = new URL(proxyUrl);
|
|
89
89
|
}
|
|
@@ -228,8 +228,8 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// Parse url
|
|
231
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
232
|
-
const parsed = new URL(fullPath,
|
|
231
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
232
|
+
const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
|
|
233
233
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
234
234
|
|
|
235
235
|
if (protocol === 'data:') {
|
|
@@ -314,7 +314,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
314
314
|
} catch (e) {
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
} else if (utils.isBlob(data)) {
|
|
317
|
+
} else if (utils.isBlob(data) || utils.isFile(data)) {
|
|
318
318
|
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
|
319
319
|
headers.setContentLength(data.size || 0);
|
|
320
320
|
data = stream.Readable.from(readBlob(data));
|
|
@@ -427,7 +427,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
427
427
|
if (config.socketPath) {
|
|
428
428
|
options.socketPath = config.socketPath;
|
|
429
429
|
} else {
|
|
430
|
-
options.hostname = parsed.hostname;
|
|
430
|
+
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
431
431
|
options.port = parsed.port;
|
|
432
432
|
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
|
433
433
|
}
|
|
@@ -569,7 +569,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
const err = new AxiosError(
|
|
572
|
-
'
|
|
572
|
+
'stream has been aborted',
|
|
573
573
|
AxiosError.ERR_BAD_RESPONSE,
|
|
574
574
|
config,
|
|
575
575
|
lastRequest
|
|
@@ -102,6 +102,20 @@ class CancelToken {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
toAbortSignal() {
|
|
106
|
+
const controller = new AbortController();
|
|
107
|
+
|
|
108
|
+
const abort = (err) => {
|
|
109
|
+
controller.abort(err);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
this.subscribe(abort);
|
|
113
|
+
|
|
114
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
115
|
+
|
|
116
|
+
return controller.signal;
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
/**
|
|
106
120
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
107
121
|
* cancels the `CancelToken`.
|
|
@@ -20,7 +20,7 @@ const validators = validator.validators;
|
|
|
20
20
|
*/
|
|
21
21
|
class Axios {
|
|
22
22
|
constructor(instanceConfig) {
|
|
23
|
-
this.defaults = instanceConfig;
|
|
23
|
+
this.defaults = instanceConfig || {};
|
|
24
24
|
this.interceptors = {
|
|
25
25
|
request: new InterceptorManager(),
|
|
26
26
|
response: new InterceptorManager()
|
|
@@ -40,9 +40,9 @@ class Axios {
|
|
|
40
40
|
return await this._request(configOrUrl, config);
|
|
41
41
|
} catch (err) {
|
|
42
42
|
if (err instanceof Error) {
|
|
43
|
-
let dummy;
|
|
43
|
+
let dummy = {};
|
|
44
44
|
|
|
45
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy
|
|
45
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
46
46
|
|
|
47
47
|
// slice off the Error: ... line
|
|
48
48
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
@@ -97,6 +97,20 @@ class Axios {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// Set config.allowAbsoluteUrls
|
|
101
|
+
if (config.allowAbsoluteUrls !== undefined) {
|
|
102
|
+
// do nothing
|
|
103
|
+
} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
104
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
105
|
+
} else {
|
|
106
|
+
config.allowAbsoluteUrls = true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
validator.assertOptions(config, {
|
|
110
|
+
baseUrl: validators.spelling('baseURL'),
|
|
111
|
+
withXsrfToken: validators.spelling('withXSRFToken')
|
|
112
|
+
}, true);
|
|
113
|
+
|
|
100
114
|
// Set config.method
|
|
101
115
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
102
116
|
|
|
@@ -139,8 +153,8 @@ class Axios {
|
|
|
139
153
|
|
|
140
154
|
if (!synchronousRequestInterceptors) {
|
|
141
155
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
142
|
-
chain.unshift
|
|
143
|
-
chain.push
|
|
156
|
+
chain.unshift(...requestInterceptorChain);
|
|
157
|
+
chain.push(...responseInterceptorChain);
|
|
144
158
|
len = chain.length;
|
|
145
159
|
|
|
146
160
|
promise = Promise.resolve(config);
|
|
@@ -187,7 +201,7 @@ class Axios {
|
|
|
187
201
|
|
|
188
202
|
getUri(config) {
|
|
189
203
|
config = mergeConfig(this.defaults, config);
|
|
190
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
204
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
191
205
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
192
206
|
}
|
|
193
207
|
}
|
|
@@ -27,7 +27,10 @@ function AxiosError(message, code, config, request, response) {
|
|
|
27
27
|
code && (this.code = code);
|
|
28
28
|
config && (this.config = config);
|
|
29
29
|
request && (this.request = request);
|
|
30
|
-
|
|
30
|
+
if (response) {
|
|
31
|
+
this.response = response;
|
|
32
|
+
this.status = response.status ? response.status : null;
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
utils.inherits(AxiosError, Error, {
|
|
@@ -47,7 +50,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
47
50
|
// Axios
|
|
48
51
|
config: utils.toJSONObject(this.config),
|
|
49
52
|
code: this.code,
|
|
50
|
-
status: this.
|
|
53
|
+
status: this.status
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
56
|
});
|
|
@@ -100,10 +100,18 @@ class AxiosHeaders {
|
|
|
100
100
|
setHeaders(header, valueOrRewrite)
|
|
101
101
|
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
102
102
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
103
|
-
} else if (utils.
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
} else if (utils.isObject(header) && utils.isIterable(header)) {
|
|
104
|
+
let obj = {}, dest, key;
|
|
105
|
+
for (const entry of header) {
|
|
106
|
+
if (!utils.isArray(entry)) {
|
|
107
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
obj[key = entry[0]] = (dest = obj[key]) ?
|
|
111
|
+
(utils.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
|
|
106
112
|
}
|
|
113
|
+
|
|
114
|
+
setHeaders(obj, valueOrRewrite)
|
|
107
115
|
} else {
|
|
108
116
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
109
117
|
}
|
|
@@ -245,6 +253,10 @@ class AxiosHeaders {
|
|
|
245
253
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
246
254
|
}
|
|
247
255
|
|
|
256
|
+
getSetCookie() {
|
|
257
|
+
return this.get("set-cookie") || [];
|
|
258
|
+
}
|
|
259
|
+
|
|
248
260
|
get [Symbol.toStringTag]() {
|
|
249
261
|
return 'AxiosHeaders';
|
|
250
262
|
}
|
|
@@ -13,8 +13,9 @@ import combineURLs from '../helpers/combineURLs.js';
|
|
|
13
13
|
*
|
|
14
14
|
* @returns {string} The combined full path
|
|
15
15
|
*/
|
|
16
|
-
export default function buildFullPath(baseURL, requestedURL) {
|
|
17
|
-
|
|
16
|
+
export default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
17
|
+
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
18
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
18
19
|
return combineURLs(baseURL, requestedURL);
|
|
19
20
|
}
|
|
20
21
|
return requestedURL;
|
|
@@ -19,7 +19,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
19
19
|
config2 = config2 || {};
|
|
20
20
|
const config = {};
|
|
21
21
|
|
|
22
|
-
function getMergedValue(target, source, caseless) {
|
|
22
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
23
23
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
24
24
|
return utils.merge.call({caseless}, target, source);
|
|
25
25
|
} else if (utils.isPlainObject(source)) {
|
|
@@ -31,11 +31,11 @@ export default function mergeConfig(config1, config2) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// eslint-disable-next-line consistent-return
|
|
34
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
34
|
+
function mergeDeepProperties(a, b, prop , caseless) {
|
|
35
35
|
if (!utils.isUndefined(b)) {
|
|
36
|
-
return getMergedValue(a, b, caseless);
|
|
36
|
+
return getMergedValue(a, b, prop , caseless);
|
|
37
37
|
} else if (!utils.isUndefined(a)) {
|
|
38
|
-
return getMergedValue(undefined, a, caseless);
|
|
38
|
+
return getMergedValue(undefined, a, prop , caseless);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -93,10 +93,10 @@ export default function mergeConfig(config1, config2) {
|
|
|
93
93
|
socketPath: defaultToConfig2,
|
|
94
94
|
responseEncoding: defaultToConfig2,
|
|
95
95
|
validateStatus: mergeDirectKeys,
|
|
96
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
96
|
+
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
utils.forEach(Object.keys(
|
|
99
|
+
utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
100
100
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
101
101
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
102
102
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.11.0";
|
|
@@ -26,7 +26,7 @@ function encode(val) {
|
|
|
26
26
|
*
|
|
27
27
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
28
28
|
* @param {object} [params] The params to be appended
|
|
29
|
-
* @param {?object} options
|
|
29
|
+
* @param {?(object|Function)} options
|
|
30
30
|
*
|
|
31
31
|
* @returns {string} The formatted url
|
|
32
32
|
*/
|
|
@@ -38,6 +38,12 @@ export default function buildURL(url, params, options) {
|
|
|
38
38
|
|
|
39
39
|
const _encode = options && options.encode || encode;
|
|
40
40
|
|
|
41
|
+
if (utils.isFunction(options)) {
|
|
42
|
+
options = {
|
|
43
|
+
serialize: options
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
const serializeFn = options && options.serialize;
|
|
42
48
|
|
|
43
49
|
let serializedParams;
|
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import CanceledError from "../cancel/CanceledError.js";
|
|
2
2
|
import AxiosError from "../core/AxiosError.js";
|
|
3
|
+
import utils from '../utils.js';
|
|
3
4
|
|
|
4
5
|
const composeSignals = (signals, timeout) => {
|
|
5
|
-
|
|
6
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
if (timeout || length) {
|
|
9
|
+
let controller = new AbortController();
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
if (!aborted) {
|
|
11
|
-
aborted = true;
|
|
12
|
-
unsubscribe();
|
|
13
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
|
14
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
11
|
+
let aborted;
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const onabort = function (reason) {
|
|
14
|
+
if (!aborted) {
|
|
15
|
+
aborted = true;
|
|
16
|
+
unsubscribe();
|
|
17
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
18
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
if (signals) {
|
|
24
|
-
timer && clearTimeout(timer);
|
|
22
|
+
let timer = timeout && setTimeout(() => {
|
|
25
23
|
timer = null;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
signals
|
|
24
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT))
|
|
25
|
+
}, timeout)
|
|
26
|
+
|
|
27
|
+
const unsubscribe = () => {
|
|
28
|
+
if (signals) {
|
|
29
|
+
timer && clearTimeout(timer);
|
|
30
|
+
timer = null;
|
|
31
|
+
signals.forEach(signal => {
|
|
32
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
33
|
+
});
|
|
34
|
+
signals = null;
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
|
-
}
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
const {signal} = controller;
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
signal.unsubscribe = () => utils.asap(unsubscribe);
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
timer = null;
|
|
43
|
-
}];
|
|
44
|
+
return signal;
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export default composeSignals;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import util from 'util';
|
|
2
2
|
import {Readable} from 'stream';
|
|
3
3
|
import utils from "../utils.js";
|
|
4
4
|
import readBlob from "./readBlob.js";
|
|
5
|
+
import platform from "../platform/index.js";
|
|
5
6
|
|
|
6
|
-
const BOUNDARY_ALPHABET =
|
|
7
|
+
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
|
7
8
|
|
|
8
|
-
const textEncoder = new TextEncoder();
|
|
9
|
+
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
|
|
9
10
|
|
|
10
11
|
const CRLF = '\r\n';
|
|
11
12
|
const CRLF_BYTES = textEncoder.encode(CRLF);
|
|
@@ -63,7 +64,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
63
64
|
const {
|
|
64
65
|
tag = 'form-data-boundary',
|
|
65
66
|
size = 25,
|
|
66
|
-
boundary = tag + '-' +
|
|
67
|
+
boundary = tag + '-' + platform.generateString(size, BOUNDARY_ALPHABET)
|
|
67
68
|
} = options || {};
|
|
68
69
|
|
|
69
70
|
if(!utils.isFormData(form)) {
|
|
@@ -75,7 +76,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
78
|
-
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF
|
|
79
|
+
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
79
80
|
let contentLength = footerBytes.byteLength;
|
|
80
81
|
|
|
81
82
|
const parts = Array.from(form.entries()).map(([name, value]) => {
|