fix: validate status and some security

This commit is contained in:
Wathanyu Phromma
2022-03-20 14:01:35 +07:00
parent 31d4a5f24b
commit a2c408c63d
387 changed files with 33710 additions and 4612 deletions

2
node_modules/retry-axios/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
var e,t=(e=require("axios"))&&"object"==typeof e&&"default"in e?e.default:e;function r(e){return e}function n(e){var t=[];if(e)return Array.isArray(e)?e:("object"==typeof e&&Object.keys(e).forEach(function(r){"number"==typeof r&&(t[r]=e[r])}),t)}function o(e){if(t.isCancel(e))return Promise.reject(e);var r=f(e)||{};if(r.currentRetryAttempt=r.currentRetryAttempt||0,r.retry="number"==typeof r.retry?r.retry:3,r.retryDelay="number"==typeof r.retryDelay?r.retryDelay:100,r.instance=r.instance||t,r.backoffType=r.backoffType||"exponential",r.httpMethodsToRetry=n(r.httpMethodsToRetry)||["GET","HEAD","PUT","OPTIONS","DELETE"],r.noResponseRetries="number"==typeof r.noResponseRetries?r.noResponseRetries:2,r.checkRetryAfter="boolean"!=typeof r.checkRetryAfter||r.checkRetryAfter,r.maxRetryAfter="number"==typeof r.maxRetryAfter?r.maxRetryAfter:3e5,r.statusCodesToRetry=n(r.statusCodesToRetry)||[[100,199],[429,429],[500,599]],e.config=e.config||{},e.config.raxConfig=Object.assign({},r),!(r.shouldRetry||s)(e))return Promise.reject(e);var o=new Promise(function(t,n){var o=0;if(r.checkRetryAfter&&e.response&&e.response.headers["retry-after"]){var s=function(e){var t=Number(e);if(!Number.isNaN(t))return 1e3*t;var r=Date.parse(e);return Number.isNaN(r)?void 0:r-Date.now()}(e.response.headers["retry-after"]);if(!(s&&s>0&&s<=r.maxRetryAfter))return n(e);o=s}e.config.raxConfig.currentRetryAttempt+=1;var f=e.config.raxConfig.currentRetryAttempt;0===o&&(o="linear"===r.backoffType?1e3*f:"static"===r.backoffType?r.retryDelay:(Math.pow(2,f)-1)/2*1e3,"number"==typeof r.maxRetryDelay&&(o=Math.min(o,r.maxRetryDelay))),setTimeout(t,o)}),i=r.onRetryAttempt?Promise.resolve(r.onRetryAttempt(e)):Promise.resolve();return Promise.resolve().then(function(){return o}).then(function(){return i}).then(function(){return r.instance.request(e.config)})}function s(e){var t=e.config.raxConfig;if(!t||0===t.retry)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!e.config.method||t.httpMethodsToRetry.indexOf(e.config.method.toUpperCase())<0)return!1;if(e.response&&e.response.status){for(var r=!1,n=0,o=t.statusCodesToRetry;n<o.length;n+=1){var s=o[n],f=e.response.status;if(f>=s[0]&&f<=s[1]){r=!0;break}}if(!r)return!1}return t.currentRetryAttempt=t.currentRetryAttempt||0,!(t.currentRetryAttempt>=t.retry)}function f(e){if(e&&e.config)return e.config.raxConfig}exports.attach=function(e){return(e=e||t).interceptors.response.use(r,o)},exports.detach=function(e,r){(r=r||t).interceptors.response.eject(e)},exports.shouldRetryRequest=s,exports.getConfig=f;
//# sourceMappingURL=index.js.map

1
node_modules/retry-axios/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2
node_modules/retry-axios/dist/index.module.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import e from"axios";function r(r){return(r=r||e).interceptors.response.use(n,s)}function t(r,t){(t=t||e).interceptors.response.eject(r)}function n(e){return e}function o(e){var r=[];if(e)return Array.isArray(e)?e:("object"==typeof e&&Object.keys(e).forEach(function(t){"number"==typeof t&&(r[t]=e[t])}),r)}function s(r){if(e.isCancel(r))return Promise.reject(r);var t=i(r)||{};if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry="number"==typeof t.retry?t.retry:3,t.retryDelay="number"==typeof t.retryDelay?t.retryDelay:100,t.instance=t.instance||e,t.backoffType=t.backoffType||"exponential",t.httpMethodsToRetry=o(t.httpMethodsToRetry)||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries="number"==typeof t.noResponseRetries?t.noResponseRetries:2,t.checkRetryAfter="boolean"!=typeof t.checkRetryAfter||t.checkRetryAfter,t.maxRetryAfter="number"==typeof t.maxRetryAfter?t.maxRetryAfter:3e5,t.statusCodesToRetry=o(t.statusCodesToRetry)||[[100,199],[429,429],[500,599]],r.config=r.config||{},r.config.raxConfig=Object.assign({},t),!(t.shouldRetry||f)(r))return Promise.reject(r);var n=new Promise(function(e,n){var o=0;if(t.checkRetryAfter&&r.response&&r.response.headers["retry-after"]){var s=function(e){var r=Number(e);if(!Number.isNaN(r))return 1e3*r;var t=Date.parse(e);return Number.isNaN(t)?void 0:t-Date.now()}(r.response.headers["retry-after"]);if(!(s&&s>0&&s<=t.maxRetryAfter))return n(r);o=s}r.config.raxConfig.currentRetryAttempt+=1;var f=r.config.raxConfig.currentRetryAttempt;0===o&&(o="linear"===t.backoffType?1e3*f:"static"===t.backoffType?t.retryDelay:(Math.pow(2,f)-1)/2*1e3,"number"==typeof t.maxRetryDelay&&(o=Math.min(o,t.maxRetryDelay))),setTimeout(e,o)}),s=t.onRetryAttempt?Promise.resolve(t.onRetryAttempt(r)):Promise.resolve();return Promise.resolve().then(function(){return n}).then(function(){return s}).then(function(){return t.instance.request(r.config)})}function f(e){var r=e.config.raxConfig;if(!r||0===r.retry)return!1;if(!e.response&&(r.currentRetryAttempt||0)>=r.noResponseRetries)return!1;if(!e.config.method||r.httpMethodsToRetry.indexOf(e.config.method.toUpperCase())<0)return!1;if(e.response&&e.response.status){for(var t=!1,n=0,o=r.statusCodesToRetry;n<o.length;n+=1){var s=o[n],f=e.response.status;if(f>=s[0]&&f<=s[1]){t=!0;break}}if(!t)return!1}return r.currentRetryAttempt=r.currentRetryAttempt||0,!(r.currentRetryAttempt>=r.retry)}function i(e){if(e&&e.config)return e.config.raxConfig}export{r as attach,t as detach,f as shouldRetryRequest,i as getConfig};
//# sourceMappingURL=index.module.js.map

1
node_modules/retry-axios/dist/index.module.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2
node_modules/retry-axios/dist/index.umd.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t(e.retryAxios={},e.axios)}(this,function(e,t){function r(e){return e}function n(e){var t=[];if(e)return Array.isArray(e)?e:("object"==typeof e&&Object.keys(e).forEach(function(r){"number"==typeof r&&(t[r]=e[r])}),t)}function o(e){if(t.isCancel(e))return Promise.reject(e);var r=f(e)||{};if(r.currentRetryAttempt=r.currentRetryAttempt||0,r.retry="number"==typeof r.retry?r.retry:3,r.retryDelay="number"==typeof r.retryDelay?r.retryDelay:100,r.instance=r.instance||t,r.backoffType=r.backoffType||"exponential",r.httpMethodsToRetry=n(r.httpMethodsToRetry)||["GET","HEAD","PUT","OPTIONS","DELETE"],r.noResponseRetries="number"==typeof r.noResponseRetries?r.noResponseRetries:2,r.checkRetryAfter="boolean"!=typeof r.checkRetryAfter||r.checkRetryAfter,r.maxRetryAfter="number"==typeof r.maxRetryAfter?r.maxRetryAfter:3e5,r.statusCodesToRetry=n(r.statusCodesToRetry)||[[100,199],[429,429],[500,599]],e.config=e.config||{},e.config.raxConfig=Object.assign({},r),!(r.shouldRetry||s)(e))return Promise.reject(e);var o=new Promise(function(t,n){var o=0;if(r.checkRetryAfter&&e.response&&e.response.headers["retry-after"]){var s=function(e){var t=Number(e);if(!Number.isNaN(t))return 1e3*t;var r=Date.parse(e);return Number.isNaN(r)?void 0:r-Date.now()}(e.response.headers["retry-after"]);if(!(s&&s>0&&s<=r.maxRetryAfter))return n(e);o=s}e.config.raxConfig.currentRetryAttempt+=1;var f=e.config.raxConfig.currentRetryAttempt;0===o&&(o="linear"===r.backoffType?1e3*f:"static"===r.backoffType?r.retryDelay:(Math.pow(2,f)-1)/2*1e3,"number"==typeof r.maxRetryDelay&&(o=Math.min(o,r.maxRetryDelay))),setTimeout(t,o)}),i=r.onRetryAttempt?Promise.resolve(r.onRetryAttempt(e)):Promise.resolve();return Promise.resolve().then(function(){return o}).then(function(){return i}).then(function(){return r.instance.request(e.config)})}function s(e){var t=e.config.raxConfig;if(!t||0===t.retry)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!e.config.method||t.httpMethodsToRetry.indexOf(e.config.method.toUpperCase())<0)return!1;if(e.response&&e.response.status){for(var r=!1,n=0,o=t.statusCodesToRetry;n<o.length;n+=1){var s=o[n],f=e.response.status;if(f>=s[0]&&f<=s[1]){r=!0;break}}if(!r)return!1}return t.currentRetryAttempt=t.currentRetryAttempt||0,!(t.currentRetryAttempt>=t.retry)}function f(e){if(e&&e.config)return e.config.raxConfig}t=t&&t.hasOwnProperty("default")?t.default:t,e.attach=function(e){return(e=e||t).interceptors.response.use(r,o)},e.detach=function(e,r){(r=r||t).interceptors.response.eject(e)},e.shouldRetryRequest=s,e.getConfig=f});
//# sourceMappingURL=index.umd.js.map

1
node_modules/retry-axios/dist/index.umd.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

91
node_modules/retry-axios/dist/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,91 @@
import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
/**
* Configuration for the Axios `request` method.
*/
export interface RetryConfig {
/**
* The number of times to retry the request. Defaults to 3.
*/
retry?: number;
/**
* The number of retries already attempted.
*/
currentRetryAttempt?: number;
/**
* The amount of time to initially delay the retry. Defaults to 100.
*/
retryDelay?: number;
/**
* The instance of the axios object to which the interceptor is attached.
*/
instance?: AxiosInstance;
/**
* The HTTP Methods that will be automatically retried.
* Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
*/
httpMethodsToRetry?: string[];
/**
* The HTTP response status codes that will automatically be retried.
* Defaults to: [[100, 199], [429, 429], [500, 599]]
*/
statusCodesToRetry?: number[][];
/**
* Function to invoke when a retry attempt is made.
*/
onRetryAttempt?: (err: AxiosError) => void;
/**
* Function to invoke which determines if you should retry
*/
shouldRetry?: (err: AxiosError) => boolean;
/**
* When there is no response, the number of retries to attempt. Defaults to 2.
*/
noResponseRetries?: number;
/**
* Backoff Type; 'linear', 'static' or 'exponential'.
*/
backoffType?: 'linear' | 'static' | 'exponential';
/**
* Whether to check for 'Retry-After' header in response and use value as delay. Defaults to true.
*/
checkRetryAfter?: boolean;
/**
* Max permitted Retry-After value (in ms) - rejects if greater. Defaults to 5 mins.
*/
maxRetryAfter?: number;
/**
* Ceiling for calculated delay (in ms) - delay will not exceed this value.
*/
maxRetryDelay?: number;
}
export declare type RaxConfig = {
raxConfig: RetryConfig;
} & AxiosRequestConfig;
/**
* Attach the interceptor to the Axios instance.
* @param instance The optional Axios instance on which to attach the
* interceptor.
* @returns The id of the interceptor attached to the axios instance.
*/
export declare function attach(instance?: AxiosInstance): number;
/**
* Eject the Axios interceptor that is providing retry capabilities.
* @param interceptorId The interceptorId provided in the config.
* @param instance The axios instance using this interceptor.
*/
export declare function detach(interceptorId: number, instance?: AxiosInstance): void;
/**
* Determine based on config if we should retry the request.
* @param err The AxiosError passed to the interceptor.
*/
export declare function shouldRetryRequest(err: AxiosError): boolean;
/**
* Acquire the raxConfig object from an AxiosError if available.
* @param err The Axios error with a config object.
*/
export declare function getConfig(err: AxiosError): RetryConfig | undefined;
declare module 'axios' {
interface AxiosRequestConfig {
raxConfig?: RetryConfig;
}
}

1
node_modules/retry-axios/dist/test/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};