This commit is contained in:
xiaojunnuo
2024-11-01 02:13:34 +08:00
parent 5160b9fbd6
commit dc9040a68e
25 changed files with 65 additions and 279 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
const { readCsrDomains } = require('./crypto');
const { log } = require('./logger');
const { wait } = require('./wait');
const { CancelError } = require('./error');
const defaultOpts = {
csr: null,
@@ -250,7 +251,7 @@ module.exports = async (client, userOpts) => {
i += 1;
log(`开始第${i}`);
if (opts.signal && opts.signal.aborted) {
throw new Error('用户取消');
throw new CancelError('用户取消');
}
try {
+6 -4
View File
@@ -12,6 +12,7 @@ const AcmeApi = require('./api');
const verify = require('./verify');
const util = require('./util');
const auto = require('./auto');
const { CancelError } = require('./error');
/**
* ACME states
@@ -490,9 +491,10 @@ class AcmeClient {
const keyAuthorization = await this.getChallengeKeyAuthorization(challenge);
const verifyFn = async () => {
const verifyFn = async (abort) => {
if (this.opts.signal && this.opts.signal.aborted) {
throw new Error('用户取消');
abort();
throw new CancelError('用户取消');
}
await verify[challenge.type](authz, challenge, keyAuthorization);
};
@@ -518,7 +520,7 @@ class AcmeClient {
async completeChallenge(challenge) {
if (this.opts.signal && this.opts.signal.aborted) {
throw new Error('用户取消');
throw new CancelError('用户取消');
}
const resp = await this.api.completeChallenge(challenge.url, {});
return resp.data;
@@ -559,7 +561,7 @@ class AcmeClient {
const verifyFn = async (abort) => {
if (this.opts.signal && this.opts.signal.aborted) {
abort();
throw new Error('用户取消');
throw new CancelError('用户取消');
}
const resp = await this.api.apiRequest(item.url, null, [200]);
+10
View File
@@ -0,0 +1,10 @@
class CancelError extends Error {
constructor(message) {
super(message);
this.name = 'CancelError';
}
}
module.exports = {
CancelError,
};
+1
View File
@@ -48,3 +48,4 @@ exports.agents = require('./agents');
exports.setLogger = require('./logger').setLogger;
exports.walkTxtRecord = require('./verify').walkTxtRecord;
exports.CancelError = require('./error').CancelError;
+1 -1
View File
@@ -5,5 +5,5 @@ async function wait(ms) {
}
module.exports = {
wait
wait,
};