This commit is contained in:
xiaojunnuo
2025-12-28 01:05:48 +08:00
parent 776fa924e3
commit f847c4a414
@@ -1,8 +1,9 @@
import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, Step, TaskInput, TaskOutput } from "@certd/pipeline"; import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import type { CertInfo } from "../acme.js";
import { CertReader } from "../cert-reader.js";
import { CertApplyBasePlugin } from "../base.js";
import { AliyunAccess, createRemoteSelectInputDefine } from "@certd/plugin-lib"; import { AliyunAccess, createRemoteSelectInputDefine } from "@certd/plugin-lib";
import type { CertInfo } from "../acme.js";
import { CertApplyBasePlugin } from "../base.js";
import { CertReader } from "../cert-reader.js";
import dayjs from "dayjs";
export { CertReader }; export { CertReader };
export type { CertInfo }; export type { CertInfo };
@@ -36,17 +37,32 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
title: "证书订单ID", title: "证书订单ID",
helper: "订阅模式的证书订单Id", helper: "订阅模式的证书订单Id",
typeName: "CertApplyGetFormAliyun", typeName: "CertApplyGetFormAliyun",
component: {
name: "RemoteAutoComplete",
vModel: "value",
},
action: CertApplyGetFormAliyunPlugin.prototype.onGetOrderList.name, action: CertApplyGetFormAliyunPlugin.prototype.onGetOrderList.name,
}) })
) )
orderId!: number; orderId!: string;
async onInit(): Promise<void> {} async onInit(): Promise<void> {}
async doCertApply(): Promise<CertReader> { async doCertApply(): Promise<CertReader> {
const access = await this.getAccess<AliyunAccess>(this.accessId); const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = await access.getClient("cas.aliyuncs.com"); const client = await access.getClient("cas.aliyuncs.com");
const certDetail = await this.getCertDetail(client, this.orderId); this.logger.info(`开始获取证书,orderId:${this.orderId}`);
let orderId: any = this.orderId;
if (!orderId) {
throw new Error("请先输入证书订单ID");
}
if (typeof orderId !== "string") {
orderId = parseInt(orderId);
}
const certState = await this.getCertificateState(client, orderId);
this.logger.info(`获取到证书Id:${JSON.stringify(certState.CertId)}`);
const certDetail = await this.getCertDetail(client, certState.CertId);
this.logger.info(`获取到证书:${certDetail.getAllDomains()}, 过期时间:${dayjs(certDetail.expires).format("YYYY-MM-DD HH:mm:ss")}`);
return certDetail; return certDetail;
} }
@@ -82,7 +98,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
}); });
} }
async getCertificateState(client: any, orderId: any) { async getCertificateState(client: any, orderId: any): Promise<{ CertId: string; Type: string; Domain: string }> {
const res = await client.doRequest({ const res = await client.doRequest({
// 接口名称 // 接口名称
action: "DescribeCertificateState", action: "DescribeCertificateState",
@@ -103,7 +119,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
}, },
}); });
return res.CertId; return res;
} }
async onGetOrderList(req: PageSearch) { async onGetOrderList(req: PageSearch) {