Update npm packages (73 packages including @jqhtml 2.3.36)

Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-02-20 11:31:28 +00:00
parent d01a6179aa
commit b5eb27a827
1690 changed files with 47348 additions and 16848 deletions

487
node_modules/axios/CHANGELOG.md generated vendored

File diff suppressed because it is too large Load Diff

878
node_modules/axios/MIGRATION_GUIDE.md generated vendored
View File

@@ -1,3 +1,877 @@
# Migration Guide
# Axios Migration Guide
## 0.x.x -> 1.1.0
> **Migrating from Axios 0.x to 1.x**
>
> This guide helps developers upgrade from Axios 0.x to 1.x by documenting breaking changes, providing migration strategies, and offering solutions to common upgrade challenges.
## Table of Contents
- [Overview](#overview)
- [Breaking Changes](#breaking-changes)
- [Error Handling Migration](#error-handling-migration)
- [API Changes](#api-changes)
- [Configuration Changes](#configuration-changes)
- [Migration Strategies](#migration-strategies)
- [Common Patterns](#common-patterns)
- [Troubleshooting](#troubleshooting)
- [Resources](#resources)
## Overview
Axios 1.x introduced several breaking changes to improve consistency, security, and developer experience. While these changes provide better error handling and more predictable behavior, they require code updates when migrating from 0.x versions.
### Key Changes Summary
| Area | 0.x Behavior | 1.x Behavior | Impact |
|------|--------------|--------------|--------|
| Error Handling | Selective throwing | Consistent throwing | High |
| JSON Parsing | Lenient | Strict | Medium |
| Browser Support | IE11+ | Modern browsers | Low-Medium |
| TypeScript | Partial | Full support | Low |
### Migration Complexity
- **Simple applications**: 1-2 hours
- **Medium applications**: 1-2 days
- **Large applications with complex error handling**: 3-5 days
## Breaking Changes
### 1. Error Handling Changes
**The most significant change in Axios 1.x is how errors are handled.**
#### 0.x Behavior
```javascript
// Axios 0.x - Some HTTP error codes didn't throw
axios.get('/api/data')
.then(response => {
// Response interceptor could handle all errors
console.log('Success:', response.data);
});
// Response interceptor handled everything
axios.interceptors.response.use(
response => response,
error => {
handleError(error);
// Error was "handled" and didn't propagate
}
);
```
#### 1.x Behavior
```javascript
// Axios 1.x - All HTTP errors throw consistently
axios.get('/api/data')
.then(response => {
console.log('Success:', response.data);
})
.catch(error => {
// Must handle errors at call site or they propagate
console.error('Request failed:', error);
});
// Response interceptor must re-throw or return rejected promise
axios.interceptors.response.use(
response => response,
error => {
handleError(error);
// Must explicitly handle propagation
return Promise.reject(error); // or throw error;
}
);
```
#### Impact
- **Response interceptors** can no longer "swallow" errors silently
- **Every API call** must handle errors explicitly or they become unhandled promise rejections
- **Centralized error handling** requires new patterns
### 2. JSON Parsing Changes
#### 0.x Behavior
```javascript
// Axios 0.x - Lenient JSON parsing
// Would attempt to parse even invalid JSON
response.data; // Might contain partial data or fallbacks
```
#### 1.x Behavior
```javascript
// Axios 1.x - Strict JSON parsing
// Throws clear errors for invalid JSON
try {
const data = response.data;
} catch (error) {
// Handle JSON parsing errors explicitly
}
```
### 3. Request/Response Transform Changes
#### 0.x Behavior
```javascript
// Implicit transformations with some edge cases
transformRequest: [function (data) {
// Less predictable behavior
return data;
}]
```
#### 1.x Behavior
```javascript
// More consistent transformation pipeline
transformRequest: [function (data, headers) {
// Headers parameter always available
// More predictable behavior
return data;
}]
```
### 4. Browser Support Changes
- **0.x**: Supported IE11 and older browsers
- **1.x**: Requires modern browsers with Promise support
- **Polyfills**: May be needed for older browser support
## Error Handling Migration
The error handling changes are the most complex part of migrating to Axios 1.x. Here are proven strategies:
### Strategy 1: Centralized Error Handling with Error Boundary
```javascript
// Create a centralized error handler
class ApiErrorHandler {
constructor() {
this.setupInterceptors();
}
setupInterceptors() {
axios.interceptors.response.use(
response => response,
error => {
// Centralized error processing
this.processError(error);
// Return a resolved promise with error info for handled errors
if (this.isHandledError(error)) {
return Promise.resolve({
data: null,
error: this.normalizeError(error),
handled: true
});
}
// Re-throw unhandled errors
return Promise.reject(error);
}
);
}
processError(error) {
// Log errors
console.error('API Error:', error);
// Show user notifications
if (error.response?.status === 401) {
this.handleAuthError();
} else if (error.response?.status >= 500) {
this.showErrorNotification('Server error occurred');
}
}
isHandledError(error) {
// Define which errors are "handled" centrally
const handledStatuses = [401, 403, 404, 422, 500, 502, 503];
return handledStatuses.includes(error.response?.status);
}
normalizeError(error) {
return {
status: error.response?.status,
message: error.response?.data?.message || error.message,
code: error.response?.data?.code || error.code
};
}
handleAuthError() {
// Redirect to login, clear tokens, etc.
localStorage.removeItem('token');
window.location.href = '/login';
}
showErrorNotification(message) {
// Show user-friendly error message
console.error(message); // Replace with your notification system
}
}
// Initialize globally
const errorHandler = new ApiErrorHandler();
// Usage in components/services
async function fetchUserData(userId) {
try {
const response = await axios.get(`/api/users/${userId}`);
// Check if error was handled centrally
if (response.handled) {
return { data: null, error: response.error };
}
return { data: response.data, error: null };
} catch (error) {
// Unhandled errors still need local handling
return { data: null, error: { message: 'Unexpected error occurred' } };
}
}
```
### Strategy 2: Wrapper Function Pattern
```javascript
// Create a wrapper that provides 0.x-like behavior
function createApiWrapper() {
const api = axios.create();
// Add response interceptor for centralized handling
api.interceptors.response.use(
response => response,
error => {
// Handle common errors centrally
if (error.response?.status === 401) {
// Handle auth errors
handleAuthError();
}
if (error.response?.status >= 500) {
// Handle server errors
showServerErrorNotification();
}
// Always reject to maintain error propagation
return Promise.reject(error);
}
);
// Wrapper function that mimics 0.x behavior
function safeRequest(requestConfig, options = {}) {
return api(requestConfig)
.then(response => response)
.catch(error => {
if (options.suppressErrors) {
// Return error info instead of throwing
return {
data: null,
error: {
status: error.response?.status,
message: error.response?.data?.message || error.message
}
};
}
throw error;
});
}
return { safeRequest, axios: api };
}
// Usage
const { safeRequest } = createApiWrapper();
// For calls where you want centralized error handling
const result = await safeRequest(
{ method: 'get', url: '/api/data' },
{ suppressErrors: true }
);
if (result.error) {
// Handle error case
console.log('Request failed:', result.error.message);
} else {
// Handle success case
console.log('Data:', result.data);
}
```
### Strategy 3: Global Error Handler with Custom Events
```javascript
// Set up global error handling with events
class GlobalErrorHandler extends EventTarget {
constructor() {
super();
this.setupInterceptors();
}
setupInterceptors() {
axios.interceptors.response.use(
response => response,
error => {
// Emit custom event for global handling
this.dispatchEvent(new CustomEvent('apiError', {
detail: { error, timestamp: new Date() }
}));
// Always reject to maintain proper error flow
return Promise.reject(error);
}
);
}
}
const globalErrorHandler = new GlobalErrorHandler();
// Set up global listeners
globalErrorHandler.addEventListener('apiError', (event) => {
const { error } = event.detail;
// Centralized error logic
if (error.response?.status === 401) {
handleAuthError();
}
if (error.response?.status >= 500) {
showErrorNotification('Server error occurred');
}
});
// Usage remains clean
async function apiCall() {
try {
const response = await axios.get('/api/data');
return response.data;
} catch (error) {
// Error was already handled globally
// Just handle component-specific logic
return null;
}
}
```
## API Changes
### Request Configuration
#### 0.x to 1.x Changes
```javascript
// 0.x - Some properties had different defaults
const config = {
timeout: 0, // No timeout by default
maxContentLength: -1, // No limit
};
// 1.x - More secure defaults
const config = {
timeout: 0, // Still no timeout, but easier to configure
maxContentLength: 2000, // Default limit for security
maxBodyLength: 2000, // New property
};
```
### Response Object
The response object structure remains largely the same, but error responses are more consistent:
```javascript
// Both 0.x and 1.x
response = {
data: {}, // Response body
status: 200, // HTTP status
statusText: 'OK', // HTTP status message
headers: {}, // Response headers
config: {}, // Request config
request: {} // Request object
};
// Error responses are more consistent in 1.x
error.response = {
data: {}, // Error response body
status: 404, // HTTP error status
statusText: 'Not Found',
headers: {},
config: {},
request: {}
};
```
## Configuration Changes
### Default Configuration Updates
```javascript
// 0.x defaults
axios.defaults.timeout = 0; // No timeout
axios.defaults.maxContentLength = -1; // No limit
// 1.x defaults (more secure)
axios.defaults.timeout = 0; // Still no timeout
axios.defaults.maxContentLength = 2000; // 2MB limit
axios.defaults.maxBodyLength = 2000; // 2MB limit
```
### Instance Configuration
```javascript
// 0.x - Instance creation
const api = axios.create({
baseURL: 'https://api.example.com',
timeout: 1000,
});
// 1.x - Same API, but more options available
const api = axios.create({
baseURL: 'https://api.example.com',
timeout: 1000,
maxBodyLength: Infinity, // Override default if needed
maxContentLength: Infinity,
});
```
## Migration Strategies
### Step-by-Step Migration Process
#### Phase 1: Preparation
1. **Audit Current Error Handling**
```bash
# Find all axios usage
grep -r "axios\." src/
grep -r "\.catch" src/
grep -r "interceptors" src/
```
2. **Identify Patterns**
- Response interceptors that handle errors
- Components that rely on centralized error handling
- Authentication and retry logic
3. **Create Test Cases**
```javascript
// Test current error handling behavior
describe('Error Handling Migration', () => {
it('should handle 401 errors consistently', async () => {
// Test authentication error flows
});
it('should handle 500 errors with user feedback', async () => {
// Test server error handling
});
});
```
#### Phase 2: Implementation
1. **Update Dependencies**
```bash
npm update axios
```
2. **Implement New Error Handling**
- Choose one of the strategies above
- Update response interceptors
- Add error handling to API calls
3. **Update Authentication Logic**
```javascript
// 0.x pattern
axios.interceptors.response.use(null, error => {
if (error.response?.status === 401) {
logout();
// Error was "handled"
}
});
// 1.x pattern
axios.interceptors.response.use(
response => response,
error => {
if (error.response?.status === 401) {
logout();
}
return Promise.reject(error); // Always propagate
}
);
```
#### Phase 3: Testing and Validation
1. **Test Error Scenarios**
- Network failures
- HTTP error codes (401, 403, 404, 500, etc.)
- Timeout errors
- JSON parsing errors
2. **Validate User Experience**
- Error messages are shown appropriately
- Authentication redirects work
- Loading states are handled correctly
### Gradual Migration Approach
For large applications, consider gradual migration:
```javascript
// Create a compatibility layer
const axiosCompat = {
// Use new axios instance for new code
v1: axios.create({
// 1.x configuration
}),
// Wrapper for legacy code
legacy: createLegacyWrapper(axios.create({
// Configuration that mimics 0.x behavior
}))
};
function createLegacyWrapper(axiosInstance) {
// Add interceptors that provide 0.x-like behavior
axiosInstance.interceptors.response.use(
response => response,
error => {
// Handle errors in 0.x style for legacy code
handleLegacyError(error);
// Don't propagate certain errors
if (shouldSuppressError(error)) {
return Promise.resolve({ data: null, error: true });
}
return Promise.reject(error);
}
);
return axiosInstance;
}
```
## Common Patterns
### Authentication Interceptors
#### Updated Authentication Pattern
```javascript
// Token refresh interceptor for 1.x
let isRefreshing = false;
let refreshSubscribers = [];
function subscribeTokenRefresh(cb) {
refreshSubscribers.push(cb);
}
function onTokenRefreshed(token) {
refreshSubscribers.forEach(cb => cb(token));
refreshSubscribers = [];
}
axios.interceptors.response.use(
response => response,
async error => {
const originalRequest = error.config;
if (error.response?.status === 401 && !originalRequest._retry) {
if (isRefreshing) {
// Wait for token refresh
return new Promise(resolve => {
subscribeTokenRefresh(token => {
originalRequest.headers.Authorization = `Bearer ${token}`;
resolve(axios(originalRequest));
});
});
}
originalRequest._retry = true;
isRefreshing = true;
try {
const newToken = await refreshToken();
onTokenRefreshed(newToken);
isRefreshing = false;
originalRequest.headers.Authorization = `Bearer ${newToken}`;
return axios(originalRequest);
} catch (refreshError) {
isRefreshing = false;
logout();
return Promise.reject(refreshError);
}
}
return Promise.reject(error);
}
);
```
### Retry Logic
```javascript
// Retry interceptor for 1.x
function createRetryInterceptor(maxRetries = 3, retryDelay = 1000) {
return axios.interceptors.response.use(
response => response,
async error => {
const config = error.config;
if (!config || !config.retry) {
return Promise.reject(error);
}
config.__retryCount = config.__retryCount || 0;
if (config.__retryCount >= maxRetries) {
return Promise.reject(error);
}
config.__retryCount += 1;
// Exponential backoff
const delay = retryDelay * Math.pow(2, config.__retryCount - 1);
await new Promise(resolve => setTimeout(resolve, delay));
return axios(config);
}
);
}
// Usage
const api = axios.create();
createRetryInterceptor(3, 1000);
// Make request with retry
api.get('/api/data', { retry: true });
```
### Loading State Management
```javascript
// Loading interceptor for 1.x
class LoadingManager {
constructor() {
this.requests = new Set();
this.setupInterceptors();
}
setupInterceptors() {
axios.interceptors.request.use(config => {
this.requests.add(config);
this.updateLoadingState();
return config;
});
axios.interceptors.response.use(
response => {
this.requests.delete(response.config);
this.updateLoadingState();
return response;
},
error => {
this.requests.delete(error.config);
this.updateLoadingState();
return Promise.reject(error);
}
);
}
updateLoadingState() {
const isLoading = this.requests.size > 0;
// Update your loading UI
document.body.classList.toggle('loading', isLoading);
}
}
const loadingManager = new LoadingManager();
```
## Troubleshooting
### Common Migration Issues
#### Issue 1: Unhandled Promise Rejections
**Problem:**
```javascript
// This pattern worked in 0.x but causes unhandled rejections in 1.x
axios.get('/api/data'); // No .catch() handler
```
**Solution:**
```javascript
// Always handle promises
axios.get('/api/data')
.catch(error => {
// Handle error appropriately
console.error('Request failed:', error.message);
});
// Or use async/await with try/catch
async function fetchData() {
try {
const response = await axios.get('/api/data');
return response.data;
} catch (error) {
console.error('Request failed:', error.message);
return null;
}
}
```
#### Issue 2: Response Interceptors Not "Handling" Errors
**Problem:**
```javascript
// 0.x style - interceptor "handled" errors
axios.interceptors.response.use(null, error => {
showErrorMessage(error.message);
// Error was considered "handled"
});
```
**Solution:**
```javascript
// 1.x style - explicitly control error propagation
axios.interceptors.response.use(
response => response,
error => {
showErrorMessage(error.message);
// Choose whether to propagate the error
if (shouldPropagateError(error)) {
return Promise.reject(error);
}
// Return success-like response for "handled" errors
return Promise.resolve({
data: null,
handled: true,
error: normalizeError(error)
});
}
);
```
#### Issue 3: JSON Parsing Errors
**Problem:**
```javascript
// 1.x is stricter about JSON parsing
// This might throw where 0.x was lenient
const data = response.data;
```
**Solution:**
```javascript
// Add response transformer for better error handling
axios.defaults.transformResponse = [
function (data) {
if (typeof data === 'string') {
try {
return JSON.parse(data);
} catch (e) {
// Handle JSON parsing errors gracefully
console.warn('Invalid JSON response:', data);
return { error: 'Invalid JSON', rawData: data };
}
}
return data;
}
];
```
#### Issue 4: TypeScript Errors After Upgrade
**Problem:**
```typescript
// TypeScript errors after upgrade
const response = await axios.get('/api/data');
// Property 'someProperty' does not exist on type 'any'
```
**Solution:**
```typescript
// Define proper interfaces
interface ApiResponse {
data: any;
message: string;
success: boolean;
}
const response = await axios.get<ApiResponse>('/api/data');
// Now properly typed
console.log(response.data.data);
```
### Debug Migration Issues
#### Enable Debug Logging
```javascript
// Add request/response logging
axios.interceptors.request.use(config => {
console.log('Request:', config);
return config;
});
axios.interceptors.response.use(
response => {
console.log('Response:', response);
return response;
},
error => {
console.log('Error:', error);
return Promise.reject(error);
}
);
```
#### Compare Behavior
```javascript
// Create side-by-side comparison during migration
const axios0x = require('axios-0x'); // Keep old version for testing
const axios1x = require('axios');
async function compareRequests(config) {
try {
const [result0x, result1x] = await Promise.allSettled([
axios0x(config),
axios1x(config)
]);
console.log('0.x result:', result0x);
console.log('1.x result:', result1x);
} catch (error) {
console.log('Comparison error:', error);
}
}
```
## Resources
### Official Documentation
- [Axios 1.x Documentation](https://axios-http.com/)
- [Axios GitHub Repository](https://github.com/axios/axios)
- [Axios Changelog](https://github.com/axios/axios/blob/main/CHANGELOG.md)
### Migration Tools
- [Axios Migration Codemod](https://github.com/axios/axios-migration-codemod) *(if available)*
- [ESLint Rules for Axios 1.x](https://github.com/axios/eslint-plugin-axios) *(if available)*
### Community Resources
- [Stack Overflow - Axios Migration Questions](https://stackoverflow.com/questions/tagged/axios+migration)
- [GitHub Discussions](https://github.com/axios/axios/discussions)
- [Axios Discord Community](https://discord.gg/axios) *(if available)*
### Related Issues
- [Error Handling Changes Discussion](https://github.com/axios/axios/issues/7208)
- [Migration Guide Request](https://github.com/axios/axios/issues/xxxx) *(link to related issues)*
---
## Need Help?
If you encounter issues during migration that aren't covered in this guide:
1. **Search existing issues** in the [Axios GitHub repository](https://github.com/axios/axios/issues)
2. **Ask questions** in [GitHub Discussions](https://github.com/axios/axios/discussions)
3. **Contribute improvements** to this migration guide
---
*This migration guide is maintained by the community. If you find errors or have suggestions, please [open an issue](https://github.com/axios/axios/issues) or submit a pull request.*

1029
node_modules/axios/README.md generated vendored

File diff suppressed because it is too large Load Diff

1682
node_modules/axios/dist/axios.js generated vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

632
node_modules/axios/dist/esm/axios.js generated vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

25
node_modules/axios/index.d.cts generated vendored
View File

@@ -100,7 +100,7 @@ declare class AxiosError<T = unknown, D = any> extends Error {
isAxiosError: boolean;
status?: number;
toJSON: () => object;
cause?: unknown;
cause?: Error;
event?: BrowserProgressEvent;
static from<T = unknown, D = any>(
error: Error | unknown,
@@ -302,6 +302,7 @@ declare namespace axios {
silentJSONParsing?: boolean;
forcedJSONParsing?: boolean;
clarifyTimeoutError?: boolean;
legacyInterceptorReqResOrdering?: boolean;
}
interface GenericAbortSignal {
@@ -515,14 +516,32 @@ declare namespace axios {
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
}
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
type AxiosInterceptorRejected = (error: any) => any;
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
type AxiosRequestInterceptorUse<T> = (
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
onRejected?: AxiosInterceptorRejected | null,
options?: AxiosInterceptorOptions
) => number;
type AxiosResponseInterceptorUse<T> = (
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
onRejected?: AxiosInterceptorRejected | null
) => number;
interface AxiosInterceptorHandler<T> {
fulfilled: AxiosInterceptorFulfilled<T>;
rejected?: AxiosInterceptorRejected;
synchronous: boolean;
runWhen?: (config: AxiosRequestConfig) => boolean;
}
interface AxiosInterceptorManager<V> {
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
eject(id: number): void;
clear(): void;
handlers?: Array<AxiosInterceptorHandler<V>>;
}
interface AxiosInstance extends Axios {

453
node_modules/axios/index.d.ts generated vendored
View File

@@ -1,27 +1,49 @@
// TypeScript Version: 4.7
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
export type AxiosHeaderValue =
| AxiosHeaders
| string
| string[]
| number
| boolean
| null;
interface RawAxiosHeaders {
[key: string]: AxiosHeaderValue;
}
type MethodsHeaders = Partial<{
[Key in Method as Lowercase<Key>]: AxiosHeaders;
} & {common: AxiosHeaders}>;
type MethodsHeaders = Partial<
{
[Key in Method as Lowercase<Key>]: AxiosHeaders;
} & { common: AxiosHeaders }
>;
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
type AxiosHeaderMatcher =
| string
| RegExp
| ((this: AxiosHeaders, value: string, name: string) => boolean);
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
type AxiosHeaderParser = (
this: AxiosHeaders,
value: AxiosHeaderValue,
header: string,
) => any;
export class AxiosHeaders {
constructor(
headers?: RawAxiosHeaders | AxiosHeaders | string
);
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
[key: string]: any;
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
set(
headerName?: string,
value?: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
set(
headers?: RawAxiosHeaders | AxiosHeaders | string,
rewrite?: boolean,
): AxiosHeaders;
get(headerName: string, parser: RegExp): RegExpExecArray | null;
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
@@ -34,7 +56,11 @@ export class AxiosHeaders {
normalize(format: boolean): AxiosHeaders;
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
concat(
...targets: Array<
AxiosHeaders | RawAxiosHeaders | string | undefined | null
>
): AxiosHeaders;
toJSON(asStrings?: boolean): RawAxiosHeaders;
@@ -42,34 +68,56 @@ export class AxiosHeaders {
static accessor(header: string | string[]): AxiosHeaders;
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
static concat(
...targets: Array<
AxiosHeaders | RawAxiosHeaders | string | undefined | null
>
): AxiosHeaders;
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setContentType(
value: ContentType,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getContentType(parser?: RegExp): RegExpExecArray | null;
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setContentLength(
value: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getContentLength(parser?: RegExp): RegExpExecArray | null;
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setAccept(
value: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getAccept(parser?: RegExp): RegExpExecArray | null;
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setUserAgent(
value: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getUserAgent(parser?: RegExp): RegExpExecArray | null;
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setContentEncoding(
value: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
setAuthorization(
value: AxiosHeaderValue,
rewrite?: boolean | AxiosHeaderMatcher,
): AxiosHeaders;
getAuthorization(parser?: RegExp): RegExpExecArray | null;
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
@@ -79,19 +127,38 @@ export class AxiosHeaders {
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
}
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization';
type CommonRequestHeadersList =
| "Accept"
| "Content-Length"
| "User-Agent"
| "Content-Encoding"
| "Authorization";
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
type ContentType =
| AxiosHeaderValue
| "text/html"
| "text/plain"
| "multipart/form-data"
| "application/json"
| "application/x-www-form-urlencoded"
| "application/octet-stream";
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
} & {
'Content-Type': ContentType
}>;
export type RawAxiosRequestHeaders = Partial<
RawAxiosHeaders & {
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
} & {
"Content-Type": ContentType;
}
>;
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
type CommonResponseHeadersList =
| "Server"
| "Content-Type"
| "Content-Length"
| "Cache-Control"
| "Content-Encoding";
type RawCommonResponseHeaders = {
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
@@ -99,16 +166,27 @@ type RawCommonResponseHeaders = {
"set-cookie": string[];
};
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
export type RawAxiosResponseHeaders = Partial<
RawAxiosHeaders & RawCommonResponseHeaders
>;
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
export interface AxiosRequestTransformer {
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
(
this: InternalAxiosRequestConfig,
data: any,
headers: AxiosRequestHeaders,
): any;
}
export interface AxiosResponseTransformer {
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
(
this: InternalAxiosRequestConfig,
data: any,
headers: AxiosResponseHeaders,
status?: number,
): any;
}
export interface AxiosAdapter {
@@ -194,44 +272,67 @@ export enum HttpStatusCode {
}
export type Method =
| 'get' | 'GET'
| 'delete' | 'DELETE'
| 'head' | 'HEAD'
| 'options' | 'OPTIONS'
| 'post' | 'POST'
| 'put' | 'PUT'
| 'patch' | 'PATCH'
| 'purge' | 'PURGE'
| 'link' | 'LINK'
| 'unlink' | 'UNLINK';
| "get"
| "GET"
| "delete"
| "DELETE"
| "head"
| "HEAD"
| "options"
| "OPTIONS"
| "post"
| "POST"
| "put"
| "PUT"
| "patch"
| "PATCH"
| "purge"
| "PURGE"
| "link"
| "LINK"
| "unlink"
| "UNLINK";
export type ResponseType =
| 'arraybuffer'
| 'blob'
| 'document'
| 'json'
| 'text'
| 'stream'
| 'formdata';
| "arraybuffer"
| "blob"
| "document"
| "json"
| "text"
| "stream"
| "formdata";
export type responseEncoding =
| 'ascii' | 'ASCII'
| 'ansi' | 'ANSI'
| 'binary' | 'BINARY'
| 'base64' | 'BASE64'
| 'base64url' | 'BASE64URL'
| 'hex' | 'HEX'
| 'latin1' | 'LATIN1'
| 'ucs-2' | 'UCS-2'
| 'ucs2' | 'UCS2'
| 'utf-8' | 'UTF-8'
| 'utf8' | 'UTF8'
| 'utf16le' | 'UTF16LE';
| "ascii"
| "ASCII"
| "ansi"
| "ANSI"
| "binary"
| "BINARY"
| "base64"
| "BASE64"
| "base64url"
| "BASE64URL"
| "hex"
| "HEX"
| "latin1"
| "LATIN1"
| "ucs-2"
| "UCS-2"
| "ucs2"
| "UCS2"
| "utf-8"
| "UTF-8"
| "utf8"
| "UTF8"
| "utf16le"
| "UTF16LE";
export interface TransitionalOptions {
silentJSONParsing?: boolean;
forcedJSONParsing?: boolean;
clarifyTimeoutError?: boolean;
legacyInterceptorReqResOrdering?: boolean;
}
export interface GenericAbortSignal {
@@ -249,11 +350,11 @@ export interface FormDataVisitorHelpers {
export interface SerializerVisitor {
(
this: GenericFormData,
value: any,
key: string | number,
path: null | Array<string | number>,
helpers: FormDataVisitorHelpers
this: GenericFormData,
value: any,
key: string | number,
path: null | Array<string | number>,
helpers: FormDataVisitorHelpers,
): boolean;
}
@@ -265,8 +366,7 @@ export interface SerializerOptions {
}
// tslint:disable-next-line
export interface FormSerializerOptions extends SerializerOptions {
}
export interface FormSerializerOptions extends SerializerOptions {}
export interface ParamEncoder {
(value: any, defaultEncoder: (value: any) => any): any;
@@ -302,7 +402,7 @@ export interface AxiosProgressEvent {
type Milliseconds = number;
type AxiosAdapterName = 'fetch' | 'xhr' | 'http' | (string & {});
type AxiosAdapterName = StringLiteralsOrString<"xhr" | "http" | "fetch">;
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
@@ -317,7 +417,7 @@ export type LookupAddress = string | LookupAddressEntry;
export interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method | string;
method?: StringLiteralsOrString<Method>;
baseURL?: string;
allowAbsoluteUrls?: boolean;
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
@@ -332,7 +432,7 @@ export interface AxiosRequestConfig<D = any> {
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
auth?: AxiosBasicCredentials;
responseType?: ResponseType;
responseEncoding?: responseEncoding | string;
responseEncoding?: StringLiteralsOrString<responseEncoding>;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
@@ -342,33 +442,74 @@ export interface AxiosRequestConfig<D = any> {
maxBodyLength?: number;
maxRedirects?: number;
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
beforeRedirect?: (
options: Record<string, any>,
responseDetails: {
headers: Record<string, string>;
statusCode: HttpStatusCode;
},
) => void;
socketPath?: string | null;
transport?: any;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig | false;
cancelToken?: CancelToken;
cancelToken?: CancelToken | undefined;
decompress?: boolean;
transitional?: TransitionalOptions;
signal?: GenericAbortSignal;
insecureHTTPParser?: boolean;
env?: {
FormData?: new (...args: any[]) => object;
fetch?: (input: URL | Request | string, init?: RequestInit) => Promise<Response>;
Request?: new (input: URL | Request | string, init?: RequestInit) => Request;
fetch?: (
input: URL | Request | string,
init?: RequestInit,
) => Promise<Response>;
Request?: new (
input: URL | Request | string,
init?: RequestInit,
) => Request;
Response?: new (
body?: ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | string | null,
init?: ResponseInit
body?:
| ArrayBuffer
| ArrayBufferView
| Blob
| FormData
| URLSearchParams
| string
| null,
init?: ResponseInit,
) => Response;
};
formSerializer?: FormSerializerOptions;
family?: AddressFamily;
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
lookup?:
| ((
hostname: string,
options: object,
cb: (
err: Error | null,
address: LookupAddress | LookupAddress[],
family?: AddressFamily,
) => void,
) => void)
| ((
hostname: string,
options: object,
) => Promise<
| [
address: LookupAddressEntry | LookupAddressEntry[],
family?: AddressFamily,
]
| LookupAddress
>);
withXSRFToken?:
| boolean
| ((config: InternalAxiosRequestConfig) => boolean | undefined);
parseReviver?: (this: any, key: string, value: any) => any;
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
fetchOptions?:
| Omit<RequestInit, "body" | "headers" | "method" | "signal">
| Record<string, any>;
httpVersion?: 1 | 2;
http2Options?: Record<string, any> & {
sessionTimeout?: number;
@@ -378,7 +519,9 @@ export interface AxiosRequestConfig<D = any> {
// Alias
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
export interface InternalAxiosRequestConfig<
D = any,
> extends AxiosRequestConfig<D> {
headers: AxiosRequestHeaders;
}
@@ -396,11 +539,17 @@ export interface HeadersDefaults {
unlink?: RawAxiosRequestHeaders;
}
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
export interface AxiosDefaults<D = any> extends Omit<
AxiosRequestConfig<D>,
"headers"
> {
headers: HeadersDefaults;
}
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
export interface CreateAxiosDefaults<D = any> extends Omit<
AxiosRequestConfig<D>,
"headers"
> {
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
}
@@ -408,18 +557,18 @@ export interface AxiosResponse<T = any, D = any, H = {}> {
data: T;
status: number;
statusText: string;
headers: H & RawAxiosResponseHeaders | AxiosResponseHeaders;
headers: (H & RawAxiosResponseHeaders) | AxiosResponseHeaders;
config: InternalAxiosRequestConfig<D>;
request?: any;
}
export class AxiosError<T = unknown, D = any> extends Error {
constructor(
message?: string,
code?: string,
config?: InternalAxiosRequestConfig<D>,
request?: any,
response?: AxiosResponse<T, D>
message?: string,
code?: string,
config?: InternalAxiosRequestConfig<D>,
request?: any,
response?: AxiosResponse<T, D>,
);
config?: InternalAxiosRequestConfig<D>;
@@ -429,7 +578,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
isAxiosError: boolean;
status?: number;
toJSON: () => object;
cause?: unknown;
cause?: Error;
event?: BrowserProgressEvent;
static from<T = unknown, D = any>(
error: Error | unknown,
@@ -438,7 +587,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
request?: any,
response?: AxiosResponse<T, D>,
customProps?: object,
): AxiosError<T, D>;
): AxiosError<T, D>;
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
@@ -492,14 +641,34 @@ export interface AxiosInterceptorOptions {
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
}
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
type AxiosInterceptorRejected = (error: any) => any;
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
type AxiosRequestInterceptorUse<T> = (
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
onRejected?: AxiosInterceptorRejected | null,
options?: AxiosInterceptorOptions,
) => number;
type AxiosResponseInterceptorUse<T> = (
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
onRejected?: AxiosInterceptorRejected | null,
) => number;
interface AxiosInterceptorHandler<T> {
fulfilled: AxiosInterceptorFulfilled<T>;
rejected?: AxiosInterceptorRejected;
synchronous: boolean;
runWhen: (config: AxiosRequestConfig) => boolean | null;
}
export interface AxiosInterceptorManager<V> {
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
use: V extends AxiosResponse
? AxiosResponseInterceptorUse<V>
: AxiosRequestInterceptorUse<V>;
eject(id: number): void;
clear(): void;
handlers?: Array<AxiosInterceptorHandler<V>>;
}
export class Axios {
@@ -510,28 +679,71 @@ export class Axios {
response: AxiosInterceptorManager<AxiosResponse>;
};
getUri(config?: AxiosRequestConfig): string;
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
request<T = any, R = AxiosResponse<T>, D = any>(
config: AxiosRequestConfig<D>,
): Promise<R>;
get<T = any, R = AxiosResponse<T>, D = any>(
url: string,
config?: AxiosRequestConfig<D>,
): Promise<R>;
delete<T = any, R = AxiosResponse<T>, D = any>(
url: string,
config?: AxiosRequestConfig<D>,
): Promise<R>;
head<T = any, R = AxiosResponse<T>, D = any>(
url: string,
config?: AxiosRequestConfig<D>,
): Promise<R>;
options<T = any, R = AxiosResponse<T>, D = any>(
url: string,
config?: AxiosRequestConfig<D>,
): Promise<R>;
post<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
put<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
patch<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
postForm<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
putForm<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
patchForm<T = any, R = AxiosResponse<T>, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>,
): Promise<R>;
}
export interface AxiosInstance extends Axios {
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
<T = any, R = AxiosResponse<T>, D = any>(
config: AxiosRequestConfig<D>,
): Promise<R>;
<T = any, R = AxiosResponse<T>, D = any>(
url: string,
config?: AxiosRequestConfig<D>,
): Promise<R>;
create(config?: CreateAxiosDefaults): AxiosInstance;
defaults: Omit<AxiosDefaults, 'headers'> & {
defaults: Omit<AxiosDefaults, "headers"> & {
headers: HeadersDefaults & {
[key: string]: AxiosHeaderValue
}
[key: string]: AxiosHeaderValue;
};
};
}
@@ -545,13 +757,23 @@ export interface GenericHTMLFormElement {
submit(): void;
}
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
export function getAdapter(
adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined,
): AxiosAdapter;
export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
export function toFormData(
sourceObj: object,
targetFormData?: GenericFormData,
options?: FormSerializerOptions,
): GenericFormData;
export function formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
export function formToJSON(
form: GenericFormData | GenericHTMLFormElement,
): object;
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
export function isAxiosError<T = any, D = any>(
payload: any,
): payload is AxiosError<T, D>;
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
@@ -559,7 +781,10 @@ export function isCancel<T = any>(value: any): value is CanceledError<T>;
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
export function mergeConfig<D = any>(
config1: AxiosRequestConfig<D>,
config2: AxiosRequestConfig<D>,
): AxiosRequestConfig<D>;
export interface AxiosStatic extends AxiosInstance {
Cancel: CancelStatic;

View File

@@ -5,7 +5,7 @@ The modules under `adapters/` are modules that handle dispatching a request and
## Example
```js
var settle = require('./../core/settle');
var settle = require('../core/settle');
module.exports = function myAdapter(config) {
// At this point:

View File

@@ -247,14 +247,14 @@ const factory = (env) => {
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
throw Object.assign(
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
{
cause: err.cause || err
}
)
}
throw AxiosError.from(err, err && err.code, config, request);
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
}
}
}

View File

@@ -1,7 +1,7 @@
import utils from './../utils.js';
import settle from './../core/settle.js';
import utils from '../utils.js';
import settle from '../core/settle.js';
import buildFullPath from '../core/buildFullPath.js';
import buildURL from './../helpers/buildURL.js';
import buildURL from '../helpers/buildURL.js';
import proxyFromEnv from 'proxy-from-env';
import http from 'http';
import https from 'https';
@@ -193,12 +193,16 @@ function setProxy(options, configProxy, location) {
if (proxy.auth) {
// Support proxy auth object form
if (proxy.auth.username || proxy.auth.password) {
const validProxyAuth = Boolean(proxy.auth.username || proxy.auth.password);
if (validProxyAuth) {
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
} else if (typeof proxy.auth === 'object') {
throw new AxiosError('Invalid proxy authorization', AxiosError.ERR_BAD_OPTION, { proxy });
}
const base64 = Buffer
.from(proxy.auth, 'utf8')
.toString('base64');
const base64 = Buffer.from(proxy.auth, 'utf8').toString('base64');
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
}
@@ -264,7 +268,8 @@ const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(addr
const http2Transport = {
request(options, cb) {
const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80);
const authority = options.protocol + '//' + options.hostname + ':' + (options.port ||(options.protocol === 'https:' ? 443 : 80));
const {http2Options, headers} = options;
@@ -812,8 +817,6 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
// Handle errors
req.on('error', function handleRequestError(err) {
// @todo remove
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
reject(AxiosError.from(err, null, config, req));
});

View File

@@ -1,5 +1,5 @@
import utils from './../utils.js';
import settle from './../core/settle.js';
import utils from '../utils.js';
import settle from '../core/settle.js';
import transitionalDefaults from '../defaults/transitional.js';
import AxiosError from '../core/AxiosError.js';
import CanceledError from '../cancel/CanceledError.js';

View File

@@ -1,25 +1,22 @@
'use strict';
import AxiosError from '../core/AxiosError.js';
import utils from '../utils.js';
/**
* A `CanceledError` is an object that is thrown when an operation is canceled.
*
* @param {string=} message The message.
* @param {Object=} config The config.
* @param {Object=} request The request.
*
* @returns {CanceledError} The created error.
*/
function CanceledError(message, config, request) {
// eslint-disable-next-line no-eq-null,eqeqeq
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
this.name = 'CanceledError';
class CanceledError extends AxiosError {
/**
* A `CanceledError` is an object that is thrown when an operation is canceled.
*
* @param {string=} message The message.
* @param {Object=} config The config.
* @param {Object=} request The request.
*
* @returns {CanceledError} The created error.
*/
constructor(message, config, request) {
super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
this.name = 'CanceledError';
this.__CANCEL__ = true;
}
}
utils.inherits(CanceledError, AxiosError, {
__CANCEL__: true
});
export default CanceledError;

15
node_modules/axios/lib/core/Axios.js generated vendored
View File

@@ -1,6 +1,6 @@
'use strict';
import utils from './../utils.js';
import utils from '../utils.js';
import buildURL from '../helpers/buildURL.js';
import InterceptorManager from './InterceptorManager.js';
import dispatchRequest from './dispatchRequest.js';
@@ -8,6 +8,7 @@ import mergeConfig from './mergeConfig.js';
import buildFullPath from './buildFullPath.js';
import validator from '../helpers/validator.js';
import AxiosHeaders from './AxiosHeaders.js';
import transitionalDefaults from '../defaults/transitional.js';
const validators = validator.validators;
@@ -80,7 +81,8 @@ class Axios {
validator.assertOptions(transitional, {
silentJSONParsing: validators.transitional(validators.boolean),
forcedJSONParsing: validators.transitional(validators.boolean),
clarifyTimeoutError: validators.transitional(validators.boolean)
clarifyTimeoutError: validators.transitional(validators.boolean),
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
}, false);
}
@@ -139,7 +141,14 @@ class Axios {
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
const transitional = config.transitional || transitionalDefaults;
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
if (legacyInterceptorReqResOrdering) {
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
} else {
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
}
});
const responseInterceptorChain = [];

View File

@@ -2,109 +2,72 @@
import utils from '../utils.js';
/**
* Create an Error with the specified message, config, error code, request and response.
*
* @param {string} message The error message.
* @param {string} [code] The error code (for example, 'ECONNABORTED').
* @param {Object} [config] The config.
* @param {Object} [request] The request.
* @param {Object} [response] The response.
*
* @returns {Error} The created error.
*/
function AxiosError(message, code, config, request, response) {
Error.call(this);
class AxiosError extends Error {
static from(error, code, config, request, response, customProps) {
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
axiosError.cause = error;
axiosError.name = error.name;
customProps && Object.assign(axiosError, customProps);
return axiosError;
}
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error()).stack;
}
/**
* Create an Error with the specified message, config, error code, request and response.
*
* @param {string} message The error message.
* @param {string} [code] The error code (for example, 'ECONNABORTED').
* @param {Object} [config] The config.
* @param {Object} [request] The request.
* @param {Object} [response] The response.
*
* @returns {Error} The created error.
*/
constructor(message, code, config, request, response) {
super(message);
this.name = 'AxiosError';
this.isAxiosError = true;
code && (this.code = code);
config && (this.config = config);
request && (this.request = request);
if (response) {
this.response = response;
this.status = response.status;
}
}
this.message = message;
this.name = 'AxiosError';
code && (this.code = code);
config && (this.config = config);
request && (this.request = request);
if (response) {
this.response = response;
this.status = response.status ? response.status : null;
}
toJSON() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: utils.toJSONObject(this.config),
code: this.code,
status: this.status,
};
}
}
utils.inherits(AxiosError, Error, {
toJSON: function toJSON() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: utils.toJSONObject(this.config),
code: this.code,
status: this.status
};
}
});
const prototype = AxiosError.prototype;
const descriptors = {};
[
'ERR_BAD_OPTION_VALUE',
'ERR_BAD_OPTION',
'ECONNABORTED',
'ETIMEDOUT',
'ERR_NETWORK',
'ERR_FR_TOO_MANY_REDIRECTS',
'ERR_DEPRECATED',
'ERR_BAD_RESPONSE',
'ERR_BAD_REQUEST',
'ERR_CANCELED',
'ERR_NOT_SUPPORT',
'ERR_INVALID_URL'
// eslint-disable-next-line func-names
].forEach(code => {
descriptors[code] = {value: code};
});
Object.defineProperties(AxiosError, descriptors);
Object.defineProperty(prototype, 'isAxiosError', {value: true});
// eslint-disable-next-line func-names
AxiosError.from = (error, code, config, request, response, customProps) => {
const axiosError = Object.create(prototype);
utils.toFlatObject(error, axiosError, function filter(obj) {
return obj !== Error.prototype;
}, prop => {
return prop !== 'isAxiosError';
});
const msg = error && error.message ? error.message : 'Error';
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
const errCode = code == null && error ? error.code : code;
AxiosError.call(axiosError, msg, errCode, config, request, response);
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
if (error && axiosError.cause == null) {
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
}
axiosError.name = (error && error.name) || 'Error';
customProps && Object.assign(axiosError, customProps);
return axiosError;
};
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
AxiosError.ECONNABORTED = 'ECONNABORTED';
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
export default AxiosError;

View File

@@ -1,6 +1,6 @@
'use strict';
import utils from './../utils.js';
import utils from '../utils.js';
class InterceptorManager {
constructor() {
@@ -12,6 +12,7 @@ class InterceptorManager {
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
* @param {Object} options The options for the interceptor, synchronous and runWhen
*
* @return {Number} An ID used to remove interceptor later
*/

View File

@@ -1,9 +1,10 @@
'use strict';
"use strict";
import utils from '../utils.js';
import utils from "../utils.js";
import AxiosHeaders from "./AxiosHeaders.js";
const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
const headersToObject = (thing) =>
thing instanceof AxiosHeaders ? { ...thing } : thing;
/**
* Config-specific merge-function which creates a new config-object
@@ -21,7 +22,7 @@ export default function mergeConfig(config1, config2) {
function getMergedValue(target, source, prop, caseless) {
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
return utils.merge.call({caseless}, target, source);
return utils.merge.call({ caseless }, target, source);
} else if (utils.isPlainObject(source)) {
return utils.merge({}, source);
} else if (utils.isArray(source)) {
@@ -30,7 +31,6 @@ export default function mergeConfig(config1, config2) {
return source;
}
// eslint-disable-next-line consistent-return
function mergeDeepProperties(a, b, prop, caseless) {
if (!utils.isUndefined(b)) {
return getMergedValue(a, b, prop, caseless);
@@ -93,14 +93,27 @@ export default function mergeConfig(config1, config2) {
socketPath: defaultToConfig2,
responseEncoding: defaultToConfig2,
validateStatus: mergeDirectKeys,
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
headers: (a, b, prop) =>
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
};
utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
const merge = mergeMap[prop] || mergeDeepProperties;
const configValue = merge(config1[prop], config2[prop], prop);
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
});
utils.forEach(
Object.keys({ ...config1, ...config2 }),
function computeConfigValue(prop) {
if (
prop === "__proto__" ||
prop === "constructor" ||
prop === "prototype"
)
return;
const merge = utils.hasOwnProp(mergeMap, prop)
? mergeMap[prop]
: mergeDeepProperties;
const configValue = merge(config1[prop], config2[prop], prop);
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) ||
(config[prop] = configValue);
},
);
return config;
}

View File

@@ -1,6 +1,6 @@
'use strict';
import utils from './../utils.js';
import utils from '../utils.js';
import defaults from '../defaults/index.js';
import AxiosHeaders from '../core/AxiosHeaders.js';

View File

@@ -3,5 +3,6 @@
export default {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
clarifyTimeoutError: false,
legacyInterceptorReqResOrdering: true
};

2
node_modules/axios/lib/env/data.js generated vendored
View File

@@ -1 +1 @@
export const VERSION = "1.13.2";
export const VERSION = "1.13.5";

View File

@@ -29,29 +29,26 @@ function encode(val) {
* @returns {string} The formatted url
*/
export default function buildURL(url, params, options) {
/*eslint no-param-reassign:0*/
if (!params) {
return url;
}
const _encode = options && options.encode || encode;
if (utils.isFunction(options)) {
options = {
serialize: options
};
}
const _options = utils.isFunction(options) ? {
serialize: options
} : options;
const serializeFn = options && options.serialize;
const serializeFn = _options && _options.serialize;
let serializedParams;
if (serializeFn) {
serializedParams = serializeFn(params, options);
serializedParams = serializeFn(params, _options);
} else {
serializedParams = utils.isURLSearchParams(params) ?
params.toString() :
new AxiosURLSearchParams(params, options).toString(_encode);
new AxiosURLSearchParams(params, _options).toString(_encode);
}
if (serializedParams) {

View File

@@ -21,7 +21,7 @@ const composeSignals = (signals, timeout) => {
let timer = timeout && setTimeout(() => {
timer = null;
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT))
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT))
}, timeout)
const unsubscribe = () => {

View File

@@ -1,4 +1,4 @@
import utils from './../utils.js';
import utils from '../utils.js';
import platform from '../platform/index.js';
export default platform.hasStandardBrowserEnv ?

View File

@@ -11,5 +11,10 @@ export default function isAbsoluteURL(url) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
if (typeof url !== 'string') {
return false;
}
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
}

View File

@@ -1,6 +1,6 @@
'use strict';
import utils from './../utils.js';
import utils from '../utils.js';
/**
* Determines whether the payload is an error thrown by Axios

View File

@@ -1,6 +1,6 @@
'use strict';
import utils from './../utils.js';
import utils from '../utils.js';
// RawAxiosHeaders whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers

View File

@@ -7,7 +7,7 @@
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* const args = [1, 2, 3];
* f.apply(null, args);
* ```
*

357
node_modules/axios/lib/utils.js generated vendored
View File

@@ -1,33 +1,33 @@
'use strict';
"use strict";
import bind from './helpers/bind.js';
import bind from "./helpers/bind.js";
// utils is a library of generic helper functions non-specific to axios
const {toString} = Object.prototype;
const {getPrototypeOf} = Object;
const {iterator, toStringTag} = Symbol;
const { toString } = Object.prototype;
const { getPrototypeOf } = Object;
const { iterator, toStringTag } = Symbol;
const kindOf = (cache => thing => {
const str = toString.call(thing);
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
const kindOf = ((cache) => (thing) => {
const str = toString.call(thing);
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
})(Object.create(null));
const kindOfTest = (type) => {
type = type.toLowerCase();
return (thing) => kindOf(thing) === type
}
return (thing) => kindOf(thing) === type;
};
const typeOfTest = type => thing => typeof thing === type;
const typeOfTest = (type) => (thing) => typeof thing === type;
/**
* Determine if a value is an Array
* Determine if a value is a non-null object
*
* @param {Object} val The value to test
*
* @returns {boolean} True if value is an Array, otherwise false
*/
const {isArray} = Array;
const { isArray } = Array;
/**
* Determine if a value is undefined
@@ -36,7 +36,7 @@ const {isArray} = Array;
*
* @returns {boolean} True if the value is undefined, otherwise false
*/
const isUndefined = typeOfTest('undefined');
const isUndefined = typeOfTest("undefined");
/**
* Determine if a value is a Buffer
@@ -46,8 +46,14 @@ const isUndefined = typeOfTest('undefined');
* @returns {boolean} True if value is a Buffer, otherwise false
*/
function isBuffer(val) {
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
return (
val !== null &&
!isUndefined(val) &&
val.constructor !== null &&
!isUndefined(val.constructor) &&
isFunction(val.constructor.isBuffer) &&
val.constructor.isBuffer(val)
);
}
/**
@@ -57,8 +63,7 @@ function isBuffer(val) {
*
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
*/
const isArrayBuffer = kindOfTest('ArrayBuffer');
const isArrayBuffer = kindOfTest("ArrayBuffer");
/**
* Determine if a value is a view on an ArrayBuffer
@@ -69,10 +74,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
*/
function isArrayBufferView(val) {
let result;
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
result = ArrayBuffer.isView(val);
} else {
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
result = val && val.buffer && isArrayBuffer(val.buffer);
}
return result;
}
@@ -84,7 +89,7 @@ function isArrayBufferView(val) {
*
* @returns {boolean} True if value is a String, otherwise false
*/
const isString = typeOfTest('string');
const isString = typeOfTest("string");
/**
* Determine if a value is a Function
@@ -92,7 +97,7 @@ const isString = typeOfTest('string');
* @param {*} val The value to test
* @returns {boolean} True if value is a Function, otherwise false
*/
const isFunction = typeOfTest('function');
const isFunction = typeOfTest("function");
/**
* Determine if a value is a Number
@@ -101,7 +106,7 @@ const isFunction = typeOfTest('function');
*
* @returns {boolean} True if value is a Number, otherwise false
*/
const isNumber = typeOfTest('number');
const isNumber = typeOfTest("number");
/**
* Determine if a value is an Object
@@ -110,7 +115,7 @@ const isNumber = typeOfTest('number');
*
* @returns {boolean} True if value is an Object, otherwise false
*/
const isObject = (thing) => thing !== null && typeof thing === 'object';
const isObject = (thing) => thing !== null && typeof thing === "object";
/**
* Determine if a value is a Boolean
@@ -118,7 +123,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
* @param {*} thing The value to test
* @returns {boolean} True if value is a Boolean, otherwise false
*/
const isBoolean = thing => thing === true || thing === false;
const isBoolean = (thing) => thing === true || thing === false;
/**
* Determine if a value is a plain Object
@@ -128,13 +133,19 @@ const isBoolean = thing => thing === true || thing === false;
* @returns {boolean} True if value is a plain Object, otherwise false
*/
const isPlainObject = (val) => {
if (kindOf(val) !== 'object') {
if (kindOf(val) !== "object") {
return false;
}
const prototype = getPrototypeOf(val);
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
}
return (
(prototype === null ||
prototype === Object.prototype ||
Object.getPrototypeOf(prototype) === null) &&
!(toStringTag in val) &&
!(iterator in val)
);
};
/**
* Determine if a value is an empty object (safely handles Buffers)
@@ -150,12 +161,15 @@ const isEmptyObject = (val) => {
}
try {
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
return (
Object.keys(val).length === 0 &&
Object.getPrototypeOf(val) === Object.prototype
);
} catch (e) {
// Fallback for any other objects that might cause RangeError with Object.keys()
return false;
}
}
};
/**
* Determine if a value is a Date
@@ -164,7 +178,7 @@ const isEmptyObject = (val) => {
*
* @returns {boolean} True if value is a Date, otherwise false
*/
const isDate = kindOfTest('Date');
const isDate = kindOfTest("Date");
/**
* Determine if a value is a File
@@ -173,7 +187,7 @@ const isDate = kindOfTest('Date');
*
* @returns {boolean} True if value is a File, otherwise false
*/
const isFile = kindOfTest('File');
const isFile = kindOfTest("File");
/**
* Determine if a value is a Blob
@@ -182,7 +196,7 @@ const isFile = kindOfTest('File');
*
* @returns {boolean} True if value is a Blob, otherwise false
*/
const isBlob = kindOfTest('Blob');
const isBlob = kindOfTest("Blob");
/**
* Determine if a value is a FileList
@@ -191,7 +205,7 @@ const isBlob = kindOfTest('Blob');
*
* @returns {boolean} True if value is a File, otherwise false
*/
const isFileList = kindOfTest('FileList');
const isFileList = kindOfTest("FileList");
/**
* Determine if a value is a Stream
@@ -211,16 +225,17 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
*/
const isFormData = (thing) => {
let kind;
return thing && (
(typeof FormData === 'function' && thing instanceof FormData) || (
isFunction(thing.append) && (
(kind = kindOf(thing)) === 'formdata' ||
// detect form-data instance
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
)
)
)
}
return (
thing &&
((typeof FormData === "function" && thing instanceof FormData) ||
(isFunction(thing.append) &&
((kind = kindOf(thing)) === "formdata" ||
// detect form-data instance
(kind === "object" &&
isFunction(thing.toString) &&
thing.toString() === "[object FormData]"))))
);
};
/**
* Determine if a value is a URLSearchParams object
@@ -229,9 +244,14 @@ const isFormData = (thing) => {
*
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
const isURLSearchParams = kindOfTest('URLSearchParams');
const isURLSearchParams = kindOfTest("URLSearchParams");
const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
const [isReadableStream, isRequest, isResponse, isHeaders] = [
"ReadableStream",
"Request",
"Response",
"Headers",
].map(kindOfTest);
/**
* Trim excess whitespace off the beginning and end of a string
@@ -240,8 +260,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
*
* @returns {String} The String freed of excess whitespace
*/
const trim = (str) => str.trim ?
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
const trim = (str) =>
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
/**
* Iterate over an Array or an Object invoking a function for each item.
@@ -252,15 +272,16 @@ const trim = (str) => str.trim ?
* If 'obj' is an Object callback will be called passing
* the value, key, and complete object for each property.
*
* @param {Object|Array} obj The object to iterate
* @param {Object|Array<unknown>} obj The object to iterate
* @param {Function} fn The callback to invoke for each item
*
* @param {Boolean} [allOwnKeys = false]
* @param {Object} [options]
* @param {Boolean} [options.allOwnKeys = false]
* @returns {any}
*/
function forEach(obj, fn, {allOwnKeys = false} = {}) {
function forEach(obj, fn, { allOwnKeys = false } = {}) {
// Don't bother if no value provided
if (obj === null || typeof obj === 'undefined') {
if (obj === null || typeof obj === "undefined") {
return;
}
@@ -268,7 +289,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
let l;
// Force an array if not already something iterable
if (typeof obj !== 'object') {
if (typeof obj !== "object") {
/*eslint no-param-reassign:0*/
obj = [obj];
}
@@ -285,7 +306,9 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
}
// Iterate over object keys
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
const keys = allOwnKeys
? Object.getOwnPropertyNames(obj)
: Object.keys(obj);
const len = keys.length;
let key;
@@ -297,7 +320,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
}
function findKey(obj, key) {
if (isBuffer(obj)){
if (isBuffer(obj)) {
return null;
}
@@ -317,10 +340,15 @@ function findKey(obj, key) {
const _global = (() => {
/*eslint no-undef:0*/
if (typeof globalThis !== "undefined") return globalThis;
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
return typeof self !== "undefined"
? self
: typeof window !== "undefined"
? window
: global;
})();
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
const isContextDefined = (context) =>
!isUndefined(context) && context !== _global;
/**
* Accepts varargs expecting each argument to be an object, then
@@ -332,7 +360,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
* Example:
*
* ```js
* var result = merge({foo: 123}, {foo: 456});
* const result = merge({foo: 123}, {foo: 456});
* console.log(result.foo); // outputs 456
* ```
*
@@ -341,10 +369,15 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
* @returns {Object} Result of all merge properties
*/
function merge(/* obj1, obj2, obj3, ... */) {
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
const result = {};
const assignValue = (val, key) => {
const targetKey = caseless && findKey(result, key) || key;
// Skip dangerous property names to prevent prototype pollution
if (key === "__proto__" || key === "constructor" || key === "prototype") {
return;
}
const targetKey = (caseless && findKey(result, key)) || key;
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
result[targetKey] = merge(result[targetKey], val);
} else if (isPlainObject(val)) {
@@ -354,7 +387,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
} else if (!skipUndefined || !isUndefined(val)) {
result[targetKey] = val;
}
}
};
for (let i = 0, l = arguments.length; i < l; i++) {
arguments[i] && forEach(arguments[i], assignValue);
@@ -369,19 +402,34 @@ function merge(/* obj1, obj2, obj3, ... */) {
* @param {Object} b The object to copy properties from
* @param {Object} thisArg The object to bind function to
*
* @param {Boolean} [allOwnKeys]
* @param {Object} [options]
* @param {Boolean} [options.allOwnKeys]
* @returns {Object} The resulting value of object a
*/
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
forEach(b, (val, key) => {
if (thisArg && isFunction(val)) {
a[key] = bind(val, thisArg);
} else {
a[key] = val;
}
}, {allOwnKeys});
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
forEach(
b,
(val, key) => {
if (thisArg && isFunction(val)) {
Object.defineProperty(a, key, {
value: bind(val, thisArg),
writable: true,
enumerable: true,
configurable: true,
});
} else {
Object.defineProperty(a, key, {
value: val,
writable: true,
enumerable: true,
configurable: true,
});
}
},
{ allOwnKeys },
);
return a;
}
};
/**
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
@@ -391,11 +439,11 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
* @returns {string} content value without BOM
*/
const stripBOM = (content) => {
if (content.charCodeAt(0) === 0xFEFF) {
if (content.charCodeAt(0) === 0xfeff) {
content = content.slice(1);
}
return content;
}
};
/**
* Inherit the prototype methods from one constructor into another
@@ -407,13 +455,21 @@ const stripBOM = (content) => {
* @returns {void}
*/
const inherits = (constructor, superConstructor, props, descriptors) => {
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
constructor.prototype.constructor = constructor;
Object.defineProperty(constructor, 'super', {
value: superConstructor.prototype
constructor.prototype = Object.create(
superConstructor.prototype,
descriptors,
);
Object.defineProperty(constructor.prototype, "constructor", {
value: constructor,
writable: true,
enumerable: false,
configurable: true,
});
Object.defineProperty(constructor, "super", {
value: superConstructor.prototype,
});
props && Object.assign(constructor.prototype, props);
}
};
/**
* Resolve object with deep prototype chain to a flat object
@@ -439,16 +495,23 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
i = props.length;
while (i-- > 0) {
prop = props[i];
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
if (
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
!merged[prop]
) {
destObj[prop] = sourceObj[prop];
merged[prop] = true;
}
}
sourceObj = filter !== false && getPrototypeOf(sourceObj);
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
} while (
sourceObj &&
(!filter || filter(sourceObj, destObj)) &&
sourceObj !== Object.prototype
);
return destObj;
}
};
/**
* Determines whether a string ends with the characters of a specified string
@@ -467,8 +530,7 @@ const endsWith = (str, searchString, position) => {
position -= searchString.length;
const lastIndex = str.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
}
};
/**
* Returns new array from array like object or null if failed
@@ -487,7 +549,7 @@ const toArray = (thing) => {
arr[i] = thing[i];
}
return arr;
}
};
/**
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
@@ -498,12 +560,12 @@ const toArray = (thing) => {
* @returns {Array}
*/
// eslint-disable-next-line func-names
const isTypedArray = (TypedArray => {
const isTypedArray = ((TypedArray) => {
// eslint-disable-next-line func-names
return thing => {
return (thing) => {
return TypedArray && thing instanceof TypedArray;
};
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
/**
* For each entry in the object, call the function with the key and value.
@@ -524,7 +586,7 @@ const forEachEntry = (obj, fn) => {
const pair = result.value;
fn.call(obj, pair[0], pair[1]);
}
}
};
/**
* It takes a regular expression and a string, and returns an array of all the matches
@@ -543,21 +605,25 @@ const matchAll = (regExp, str) => {
}
return arr;
}
};
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
const isHTMLForm = kindOfTest('HTMLFormElement');
const isHTMLForm = kindOfTest("HTMLFormElement");
const toCamelCase = str => {
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
function replacer(m, p1, p2) {
const toCamelCase = (str) => {
return str
.toLowerCase()
.replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
return p1.toUpperCase() + p2;
}
);
});
};
/* Creating a function that will check if an object has a property. */
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
const hasOwnProperty = (
({ hasOwnProperty }) =>
(obj, prop) =>
hasOwnProperty.call(obj, prop)
)(Object.prototype);
/**
* Determine if a value is a RegExp object
@@ -566,7 +632,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
*
* @returns {boolean} True if value is a RegExp object, otherwise false
*/
const isRegExp = kindOfTest('RegExp');
const isRegExp = kindOfTest("RegExp");
const reduceDescriptors = (obj, reducer) => {
const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -580,7 +646,7 @@ const reduceDescriptors = (obj, reducer) => {
});
Object.defineProperties(obj, reducedDescriptors);
}
};
/**
* Makes all methods read-only
@@ -590,7 +656,10 @@ const reduceDescriptors = (obj, reducer) => {
const freezeMethods = (obj) => {
reduceDescriptors(obj, (descriptor, name) => {
// skip restricted props in strict mode
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
if (
isFunction(obj) &&
["arguments", "caller", "callee"].indexOf(name) !== -1
) {
return false;
}
@@ -600,40 +669,42 @@ const freezeMethods = (obj) => {
descriptor.enumerable = false;
if ('writable' in descriptor) {
if ("writable" in descriptor) {
descriptor.writable = false;
return;
}
if (!descriptor.set) {
descriptor.set = () => {
throw Error('Can not rewrite read-only method \'' + name + '\'');
throw Error("Can not rewrite read-only method '" + name + "'");
};
}
});
}
};
const toObjectSet = (arrayOrString, delimiter) => {
const obj = {};
const define = (arr) => {
arr.forEach(value => {
arr.forEach((value) => {
obj[value] = true;
});
}
};
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
isArray(arrayOrString)
? define(arrayOrString)
: define(String(arrayOrString).split(delimiter));
return obj;
}
};
const noop = () => {}
const noop = () => {};
const toFiniteNumber = (value, defaultValue) => {
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
}
return value != null && Number.isFinite((value = +value))
? value
: defaultValue;
};
/**
* If the thing is a FormData object, return true, otherwise return false.
@@ -643,14 +714,18 @@ const toFiniteNumber = (value, defaultValue) => {
* @returns {boolean}
*/
function isSpecCompliantForm(thing) {
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
return !!(
thing &&
isFunction(thing.append) &&
thing[toStringTag] === "FormData" &&
thing[iterator]
);
}
const toJSONObject = (obj) => {
const stack = new Array(10);
const visit = (source, i) => {
if (isObject(source)) {
if (stack.indexOf(source) >= 0) {
return;
@@ -661,7 +736,7 @@ const toJSONObject = (obj) => {
return source;
}
if(!('toJSON' in source)) {
if (!("toJSON" in source)) {
stack[i] = source;
const target = isArray(source) ? [] : {};
@@ -677,15 +752,18 @@ const toJSONObject = (obj) => {
}
return source;
}
};
return visit(obj, 0);
}
};
const isAsyncFn = kindOfTest('AsyncFunction');
const isAsyncFn = kindOfTest("AsyncFunction");
const isThenable = (thing) =>
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
thing &&
(isObject(thing) || isFunction(thing)) &&
isFunction(thing.then) &&
isFunction(thing.catch);
// original code
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -695,32 +773,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
return setImmediate;
}
return postMessageSupported ? ((token, callbacks) => {
_global.addEventListener("message", ({source, data}) => {
if (source === _global && data === token) {
callbacks.length && callbacks.shift()();
}
}, false);
return postMessageSupported
? ((token, callbacks) => {
_global.addEventListener(
"message",
({ source, data }) => {
if (source === _global && data === token) {
callbacks.length && callbacks.shift()();
}
},
false,
);
return (cb) => {
callbacks.push(cb);
_global.postMessage(token, "*");
}
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
})(
typeof setImmediate === 'function',
isFunction(_global.postMessage)
);
return (cb) => {
callbacks.push(cb);
_global.postMessage(token, "*");
};
})(`axios@${Math.random()}`, [])
: (cb) => setTimeout(cb);
})(typeof setImmediate === "function", isFunction(_global.postMessage));
const asap = typeof queueMicrotask !== 'undefined' ?
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
const asap =
typeof queueMicrotask !== "undefined"
? queueMicrotask.bind(_global)
: (typeof process !== "undefined" && process.nextTick) || _setImmediate;
// *********************
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
export default {
isArray,
isArrayBuffer,
@@ -778,5 +859,5 @@ export default {
isThenable,
setImmediate: _setImmediate,
asap,
isIterable
isIterable,
};

117
node_modules/axios/package.json generated vendored
View File

@@ -1,14 +1,19 @@
{
"name": "axios",
"version": "1.13.2",
"version": "1.13.5",
"description": "Promise based HTTP client for the browser and node.js",
"main": "index.js",
"main": "./dist/node/axios.cjs",
"module": "./index.js",
"exports": {
".": {
"types": {
"require": "./index.d.cts",
"default": "./index.d.ts"
},
"bun": {
"require": "./dist/node/axios.cjs",
"default": "./index.js"
},
"react-native": {
"require": "./dist/browser/axios.cjs",
"default": "./dist/esm/axios.js"
@@ -42,10 +47,10 @@
"scripts": {
"test": "npm run test:node && npm run test:browser && npm run test:package",
"test:node": "npm run test:mocha",
"test:node:coverage": "c8 npm run test:mocha",
"test:browser": "npm run test:karma",
"test:package": "npm run test:eslint && npm run test:dtslint && npm run test:exports",
"test:package": "npm run test:eslint && npm run test:exports",
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
"test:dtslint": "dtslint --localTs node_modules/typescript/lib",
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit",
"test:karma": "node ./bin/run-karma-tests.js",
@@ -56,20 +61,12 @@
"preversion": "gulp version",
"version": "npm run build && git add package.json",
"prepublishOnly": "npm run test:build:version",
"postpublish": "git push && git push --tags",
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
"examples": "node ./examples/server.js",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"fix": "eslint --fix lib/**/*.js",
"prepare": "husky install && npm run prepare:hooks",
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"",
"release:dry": "release-it --dry-run --no-npm",
"release:info": "release-it --release-version",
"release:beta:no-npm": "release-it --preRelease=beta --no-npm",
"release:beta": "release-it --preRelease=beta",
"release:no-npm": "release-it --no-npm",
"release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md",
"release": "release-it"
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\""
},
"repository": {
"type": "git",
@@ -94,30 +91,29 @@
},
"homepage": "https://axios-http.com",
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@release-it/conventional-changelog": "^5.1.1",
"@rollup/plugin-alias": "^5.1.0",
"@babel/core": "^7.28.6",
"@babel/preset-env": "^7.28.6",
"@commitlint/cli": "^20.3.1",
"@commitlint/config-conventional": "^20.3.1",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"abortcontroller-polyfill": "^1.7.5",
"auto-changelog": "^2.4.0",
"body-parser": "^1.20.2",
"chalk": "^5.3.0",
"abortcontroller-polyfill": "^1.7.8",
"auto-changelog": "^2.5.0",
"body-parser": "^1.20.4",
"c8": "^10.1.3",
"chalk": "^5.6.2",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"dev-null": "^0.1.1",
"dtslint": "^4.2.1",
"es6-promise": "^4.2.8",
"eslint": "^8.56.0",
"express": "^4.18.2",
"eslint": "^8.57.1",
"express": "^4.22.1",
"formdata-node": "^5.0.1",
"formidable": "^2.1.2",
"formidable": "^2.1.5",
"fs-extra": "^10.1.0",
"get-stream": "^3.0.0",
"gulp": "^4.0.2",
@@ -125,24 +121,23 @@
"husky": "^8.0.3",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine-core": "^2.99.1",
"karma": "^6.3.17",
"karma": "^6.4.4",
"karma-chrome-launcher": "^3.2.0",
"karma-firefox-launcher": "^2.1.2",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-ajax": "^0.1.13",
"karma-rollup-preprocessor": "^7.0.8",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^4.3.6",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.8",
"memoizee": "^0.4.15",
"karma-sourcemap-loader": "^0.4.0",
"memoizee": "^0.4.17",
"minimist": "^1.2.8",
"mocha": "^10.3.0",
"mocha": "^10.8.2",
"multer": "^1.4.4",
"pacote": "^20.0.0",
"pretty-bytes": "^6.1.1",
"release-it": "^15.11.0",
"rollup": "^2.79.1",
"rollup": "^2.79.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
@@ -167,8 +162,8 @@
"unpkg": "dist/axios.min.js",
"typings": "./index.d.ts",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.4",
"follow-redirects": "^1.15.11",
"form-data": "^4.0.5",
"proxy-from-env": "^1.1.0"
},
"bundlesize": [
@@ -188,42 +183,11 @@
"Martti Laine (https://github.com/codeclown)",
"Xianming Zhong (https://github.com/chinesedfan)",
"Remco Haszing (https://github.com/remcohaszing)",
"Rikki Gibson (https://github.com/RikkiGibson)",
"Willian Agostini (https://github.com/WillianAgostini)",
"Rikki Gibson (https://github.com/RikkiGibson)",
"Ben Carp (https://github.com/carpben)"
],
"sideEffects": false,
"release-it": {
"git": {
"commitMessage": "chore(release): v${version}",
"push": true,
"commit": true,
"tag": true,
"requireCommits": false,
"requireCleanWorkingDir": false
},
"github": {
"release": true,
"draft": true
},
"npm": {
"publish": false,
"ignoreVersion": false
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular",
"infile": "CHANGELOG.md",
"header": "# Changelog"
}
},
"hooks": {
"before:init": "npm test",
"after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version",
"before:release": "npm run release:changelog:fix && git add ./package-lock.json",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
}
},
"commitlint": {
"rules": {
"header-max-length": [
@@ -235,5 +199,22 @@
"extends": [
"@commitlint/config-conventional"
]
},
"c8": {
"all": true,
"include": [
"lib/**/*.js",
"lib/**/*.ts"
],
"exclude": [
"test",
"sandbox"
],
"reporter": [
"text",
"lcov",
"html"
],
"report-dir": "./coverage"
}
}