mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
chore: 1
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, Step, TaskInput, TaskOutput } from "@certd/pipeline";
|
||||
import type { CertInfo } from "../acme.js";
|
||||
import { CertReader } from "../cert-reader.js";
|
||||
import { CertApplyBasePlugin } from "../base.js";
|
||||
import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
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 type { CertInfo };
|
||||
@@ -36,17 +37,32 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
|
||||
title: "证书订单ID",
|
||||
helper: "订阅模式的证书订单Id",
|
||||
typeName: "CertApplyGetFormAliyun",
|
||||
component: {
|
||||
name: "RemoteAutoComplete",
|
||||
vModel: "value",
|
||||
},
|
||||
action: CertApplyGetFormAliyunPlugin.prototype.onGetOrderList.name,
|
||||
})
|
||||
)
|
||||
orderId!: number;
|
||||
orderId!: string;
|
||||
|
||||
async onInit(): Promise<void> {}
|
||||
|
||||
async doCertApply(): Promise<CertReader> {
|
||||
const access = await this.getAccess<AliyunAccess>(this.accessId);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
// 接口名称
|
||||
action: "DescribeCertificateState",
|
||||
@@ -103,7 +119,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
|
||||
},
|
||||
});
|
||||
|
||||
return res.CertId;
|
||||
return res;
|
||||
}
|
||||
|
||||
async onGetOrderList(req: PageSearch) {
|
||||
|
||||
Reference in New Issue
Block a user