mirror of
https://github.com/certd/certd.git
synced 2026-04-21 02:20:52 +08:00
bf040d4c42
- 新增 FlexCDNRefreshCert 插件类,实现更新证书功能 - 添加 FlexCDNAccess 授权类和 FlexCDNClient 客户端类 - 实现获取证书列表和更新证书的 API 调用 - 提供插件配置界面和执行逻辑
111 lines
2.0 KiB
TypeScript
111 lines
2.0 KiB
TypeScript
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
|
|
import { HttpClient } from "@certd/basic";
|
|
import { FlexCDNClient } from "./client.js";
|
|
|
|
/**
|
|
*/
|
|
@IsAccess({
|
|
name: "flexcdn",
|
|
title: "FlexCDN授权",
|
|
desc: "",
|
|
icon: "svg:icon-lucky"
|
|
})
|
|
export class FlexCDNAccess extends BaseAccess {
|
|
@AccessInput({
|
|
title: "接口地址",
|
|
component: {
|
|
placeholder: "http://xxxxxxx:8080",
|
|
name: "a-input",
|
|
vModel: "value"
|
|
},
|
|
required: true
|
|
})
|
|
endpoint!: string;
|
|
|
|
@AccessInput({
|
|
title: "用户类型",
|
|
component: {
|
|
placeholder: "请选择",
|
|
name: "a-select",
|
|
vModel: "value",
|
|
options: [
|
|
{
|
|
value: "user",
|
|
label: "普通用户"
|
|
},
|
|
{
|
|
value: "admin",
|
|
label: "管理员"
|
|
}
|
|
]
|
|
},
|
|
required: true
|
|
})
|
|
type!: string;
|
|
|
|
@AccessInput({
|
|
title: "accessKeyId",
|
|
component: {
|
|
placeholder: "accessKeyId",
|
|
component: {
|
|
name: "a-input",
|
|
vModel: "value"
|
|
}
|
|
},
|
|
encrypt: false,
|
|
required: true
|
|
})
|
|
accessKeyId!: string;
|
|
|
|
@AccessInput({
|
|
title: "accessKey",
|
|
component: {
|
|
placeholder: "accessKey",
|
|
component: {
|
|
name: "a-input",
|
|
vModel: "value"
|
|
}
|
|
},
|
|
encrypt: true,
|
|
required: true
|
|
})
|
|
accessKey!: string;
|
|
|
|
@AccessInput({
|
|
title: "忽略证书校验",
|
|
component: {
|
|
name: "a-switch",
|
|
vModel: "checked"
|
|
},
|
|
encrypt: false,
|
|
required: true
|
|
})
|
|
skipSslVerify!: boolean;
|
|
|
|
@AccessInput({
|
|
title: "测试",
|
|
component: {
|
|
name: "api-test",
|
|
action: "TestRequest"
|
|
},
|
|
helper: "点击测试接口看是否正常"
|
|
})
|
|
testRequest = true;
|
|
|
|
async onTestRequest() {
|
|
const http: HttpClient = this.ctx.http;
|
|
const client = new FlexCDNClient({
|
|
logger: this.ctx.logger,
|
|
http,
|
|
access: this
|
|
});
|
|
const token = await client.getToken();
|
|
if (token) {
|
|
return "ok";
|
|
}
|
|
throw "测试失败,未知错误";
|
|
}
|
|
}
|
|
|
|
new FlexCDNAccess();
|