mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
chore: acme-client依赖于basic
This commit is contained in:
@@ -4,9 +4,8 @@
|
||||
import axios from 'axios';
|
||||
import { parseRetryAfterHeader } from './util.js';
|
||||
import { log } from './logger.js';
|
||||
import * as Agents from './agents.js';
|
||||
const { AxiosError } = axios;
|
||||
|
||||
import {getGlobalAgents, HttpError} from '@certd/basic'
|
||||
/**
|
||||
* Defaults
|
||||
*/
|
||||
@@ -73,7 +72,7 @@ function validateStatus(response) {
|
||||
response,
|
||||
);
|
||||
|
||||
throw new Agents.HttpError(err);
|
||||
throw new HttpError(err);
|
||||
}
|
||||
|
||||
/* Pass all responses through the error interceptor */
|
||||
@@ -83,7 +82,7 @@ instance.interceptors.request.use((config) => {
|
||||
}
|
||||
config.validateStatus = () => false;
|
||||
|
||||
const agents = Agents.getGlobalAgents();
|
||||
const agents = getGlobalAgents();
|
||||
// if (config.skipSslVerify) {
|
||||
// logger.info('跳过SSL验证');
|
||||
// agents = createAgent({ rejectUnauthorized: false } as any);
|
||||
@@ -100,7 +99,7 @@ instance.interceptors.response.use(null, async (error) => {
|
||||
const { config, response } = error;
|
||||
|
||||
if (!config) {
|
||||
return Promise.reject(new Agents.HttpError(error));
|
||||
return Promise.reject(new HttpError(error));
|
||||
}
|
||||
|
||||
/* Pick up errors we want to retry */
|
||||
@@ -120,7 +119,7 @@ instance.interceptors.response.use(null, async (error) => {
|
||||
const waitMinutes = (headerRetryAfter / 60).toFixed(1);
|
||||
log(`Found retry-after response header with value: ${response.headers['retry-after']}, waiting ${waitMinutes} minutes`);
|
||||
log(JSON.stringify(response.data));
|
||||
return Promise.reject(new Agents.HttpError(error));
|
||||
return Promise.reject(new HttpError(error));
|
||||
}
|
||||
|
||||
log(`waiting ${retryAfter} seconds`);
|
||||
@@ -132,7 +131,7 @@ instance.interceptors.response.use(null, async (error) => {
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
return Promise.reject(new Agents.HttpError(error));
|
||||
return Promise.reject(new HttpError(error));
|
||||
}
|
||||
/* Validate and return response */
|
||||
return validateStatus(response);
|
||||
|
||||
Reference in New Issue
Block a user