@certd/plugin-cert 1.0.3 → 1.0.5

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.
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ import { DnsProviderDefine } from "./api";
2
+ export declare const DNS_PROVIDER_CLASS_KEY = "pipeline:dns-provider";
3
+ export declare function IsDnsProvider(define: DnsProviderDefine): ClassDecorator;
@@ -0,0 +1,3 @@
1
+ export * from "./api";
2
+ export * from "./registry";
3
+ export * from "./decorator";
@@ -0,0 +1,2 @@
1
+ import { Registry } from "@certd/pipeline";
2
+ export declare const dnsProviderRegistry: Registry<unknown>;
@@ -0,0 +1,2 @@
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
+ }
@@ -0,0 +1 @@
1
+ export * from "./cert-plugin";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@certd/plugin-cert",
3
3
  "private": false,
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/plugin-cert.mjs",
7
7
  "types": "./dist/es/plugin-cert.d.ts",
@@ -12,8 +12,8 @@
12
12
  "preview": "vite preview"
13
13
  },
14
14
  "dependencies": {
15
- "@certd/acme-client": "^1.0.3",
16
- "@certd/pipeline": "^1.0.3",
15
+ "@certd/acme-client": "^1.0.5",
16
+ "@certd/pipeline": "^1.0.5",
17
17
  "node-forge": "^0.10.0"
18
18
  },
19
19
  "devDependencies": {
@@ -51,5 +51,5 @@
51
51
  "vite": "^3.1.0",
52
52
  "vue-tsc": "^0.38.9"
53
53
  },
54
- "gitHead": "a43c5b0824d2cb19a731c16f62c5e7464f6635d6"
54
+ "gitHead": "60921d9adf0e602ca5029da4b04c65ed0b55ccc6"
55
55
  }
package/rollup.config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const resolve = require("@rollup/plugin-node-resolve");
2
2
  const commonjs = require("@rollup/plugin-commonjs");
3
- const rollupTypescript = require("rollup-plugin-typescript2");
3
+ //const Typescript = require("rollup-plugin-typescript2");
4
+ const Typescript = require("@rollup/plugin-typescript");
4
5
  const json = require("@rollup/plugin-json");
5
6
  const terser = require("@rollup/plugin-terser");
6
7
  module.exports = {
@@ -14,7 +15,14 @@ module.exports = {
14
15
  resolve(),
15
16
  // 识别 commonjs 模式第三方依赖
16
17
  commonjs(),
17
- rollupTypescript(),
18
+ Typescript({
19
+ target: "esnext",
20
+ rootDir: "src",
21
+ declaration: true,
22
+ declarationDir: "dist/d",
23
+ exclude: ["./node_modules/**", "./src/**/*.vue"],
24
+ allowSyntheticDefaultImports: true,
25
+ }),
18
26
  json(),
19
27
  terser(),
20
28
  ],
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src";