@certd/plugin-cert 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +1 -0
- package/CHANGELOG.md +8 -0
- package/dist/bundle.js +1 -0
- package/dist/d/dns-provider/api.d.ts +20 -0
- package/dist/d/dns-provider/decorator.d.ts +3 -0
- package/{src/dns-provider/index.ts → dist/d/dns-provider/index.d.ts} +3 -3
- package/dist/d/dns-provider/registry.d.ts +2 -0
- package/{src/index.ts → dist/d/index.d.ts} +2 -2
- package/dist/d/plugin/cert-plugin/acme.d.ts +45 -0
- package/dist/d/plugin/cert-plugin/cert-reader.d.ts +16 -0
- package/dist/d/plugin/cert-plugin/index.d.ts +48 -0
- package/{src/plugin/index.ts → dist/d/plugin/index.d.ts} +1 -2
- package/dist/plugin-cert.mjs +33826 -0
- package/dist/plugin-cert.umd.js +106 -0
- package/package.json +15 -6
- package/rollup.config.js +43 -0
- package/tsconfig.json +1 -2
- package/vite.config.ts +38 -6
- package/index.ts +0 -1
- package/src/dns-provider/api.ts +0 -23
- package/src/dns-provider/decorator.ts +0 -30
- package/src/dns-provider/registry.ts +0 -3
- package/src/plugin/cert-plugin/acme.ts +0 -205
- package/src/plugin/cert-plugin/cert-reader.ts +0 -52
- package/src/plugin/cert-plugin/index.ts +0 -276
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Registrable } from "@certd/pipeline";
|
|
2
|
+
export type DnsProviderDefine = Registrable & {
|
|
3
|
+
accessType: string;
|
|
4
|
+
autowire?: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type CreateRecordOptions = {
|
|
9
|
+
fullRecord: string;
|
|
10
|
+
type: string;
|
|
11
|
+
value: any;
|
|
12
|
+
};
|
|
13
|
+
export type RemoveRecordOptions = CreateRecordOptions & {
|
|
14
|
+
record: any;
|
|
15
|
+
};
|
|
16
|
+
export interface IDnsProvider {
|
|
17
|
+
onInstance(): Promise<void>;
|
|
18
|
+
createRecord(options: CreateRecordOptions): Promise<any>;
|
|
19
|
+
removeRecord(options: RemoveRecordOptions): Promise<any>;
|
|
20
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./registry";
|
|
3
|
-
export * from "./decorator";
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export * from "./registry";
|
|
3
|
+
export * from "./decorator";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./plugin";
|
|
2
|
-
export * from "./dns-provider";
|
|
1
|
+
export * from "./plugin";
|
|
2
|
+
export * from "./dns-provider";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as acme from "@certd/acme-client";
|
|
2
|
+
import { Logger } from "log4js";
|
|
3
|
+
import { IContext } from "@certd/pipeline/src/core/context";
|
|
4
|
+
import { IDnsProvider } from "../../dns-provider";
|
|
5
|
+
export type CertInfo = {
|
|
6
|
+
crt: string;
|
|
7
|
+
key: string;
|
|
8
|
+
csr: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class AcmeService {
|
|
11
|
+
userContext: IContext;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
userContext: IContext;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
});
|
|
17
|
+
getAccountConfig(email: string): Promise<any>;
|
|
18
|
+
buildAccountKey(email: string): string;
|
|
19
|
+
saveAccountConfig(email: string, conf: any): Promise<void>;
|
|
20
|
+
getAcmeClient(email: string, isTest?: boolean): Promise<acme.Client>;
|
|
21
|
+
createNewKey(): Promise<string>;
|
|
22
|
+
challengeCreateFn(authz: any, challenge: any, keyAuthorization: string, dnsProvider: IDnsProvider): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Function used to remove an ACME challenge response
|
|
25
|
+
*
|
|
26
|
+
* @param {object} authz Authorization object
|
|
27
|
+
* @param {object} challenge Selected challenge
|
|
28
|
+
* @param {string} keyAuthorization Authorization key
|
|
29
|
+
* @param recordItem challengeCreateFn create record item
|
|
30
|
+
* @param dnsProvider dnsProvider
|
|
31
|
+
* @returns {Promise}
|
|
32
|
+
*/
|
|
33
|
+
challengeRemoveFn(authz: any, challenge: any, keyAuthorization: string, recordItem: any, dnsProvider: IDnsProvider): Promise<void>;
|
|
34
|
+
order(options: {
|
|
35
|
+
email: string;
|
|
36
|
+
domains: string | string[];
|
|
37
|
+
dnsProvider: any;
|
|
38
|
+
csrInfo: any;
|
|
39
|
+
isTest?: boolean;
|
|
40
|
+
}): Promise<CertInfo>;
|
|
41
|
+
buildCommonNameByDomains(domains: string | string[]): {
|
|
42
|
+
commonName: string;
|
|
43
|
+
altNames: string[] | undefined;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CertInfo } from "./acme";
|
|
2
|
+
import forge from "node-forge";
|
|
3
|
+
export declare class CertReader implements CertInfo {
|
|
4
|
+
crt: string;
|
|
5
|
+
key: string;
|
|
6
|
+
csr: string;
|
|
7
|
+
detail: any;
|
|
8
|
+
expires: number;
|
|
9
|
+
constructor(certInfo: CertInfo);
|
|
10
|
+
toCertInfo(): CertInfo;
|
|
11
|
+
getCrtDetail(crt: string): {
|
|
12
|
+
detail: forge.pki.Certificate;
|
|
13
|
+
expires: Date;
|
|
14
|
+
};
|
|
15
|
+
saveToFile(type: "crt" | "key", filepath?: string): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbstractTaskPlugin, HttpClient, IAccessService, IContext, Step } from "@certd/pipeline";
|
|
2
|
+
import { AcmeService, CertInfo } from "./acme";
|
|
3
|
+
import { Logger } from "log4js";
|
|
4
|
+
import { CertReader } from "./cert-reader";
|
|
5
|
+
export { CertReader };
|
|
6
|
+
export type { CertInfo };
|
|
7
|
+
export declare class CertApplyPlugin extends AbstractTaskPlugin {
|
|
8
|
+
domains: string;
|
|
9
|
+
email: string;
|
|
10
|
+
dnsProviderType: string;
|
|
11
|
+
dnsProviderAccess: string;
|
|
12
|
+
renewDays: number;
|
|
13
|
+
forceUpdate: string;
|
|
14
|
+
csrInfo: any;
|
|
15
|
+
acme: AcmeService;
|
|
16
|
+
logger: Logger;
|
|
17
|
+
userContext: IContext;
|
|
18
|
+
accessService: IAccessService;
|
|
19
|
+
http: HttpClient;
|
|
20
|
+
lastStatus: Step;
|
|
21
|
+
cert?: CertInfo;
|
|
22
|
+
onInstance(): Promise<void>;
|
|
23
|
+
execute(): Promise<void>;
|
|
24
|
+
output(cert: CertInfo): void;
|
|
25
|
+
/**
|
|
26
|
+
* 是否更新证书
|
|
27
|
+
* @param input
|
|
28
|
+
*/
|
|
29
|
+
condition(): Promise<CertReader | null>;
|
|
30
|
+
doCertApply(): Promise<CertReader>;
|
|
31
|
+
formatCert(pem: string): string;
|
|
32
|
+
formatCerts(cert: {
|
|
33
|
+
crt: string;
|
|
34
|
+
key: string;
|
|
35
|
+
csr: string;
|
|
36
|
+
}): CertInfo;
|
|
37
|
+
readLastCert(): Promise<CertReader | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* 检查是否过期,默认提前20天
|
|
40
|
+
* @param expires
|
|
41
|
+
* @param maxDays
|
|
42
|
+
* @returns {boolean}
|
|
43
|
+
*/
|
|
44
|
+
isWillExpire(expires: number, maxDays?: number): {
|
|
45
|
+
isWillExpire: boolean;
|
|
46
|
+
leftDays: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./cert-plugin";
|
|
2
|
-
|
|
1
|
+
export * from "./cert-plugin";
|