UNPKG

1.45 kBTypeScriptView Raw
1import { pki } from 'node-forge'
2
3declare interface SelfsignedOptions {
4 /**
5 * The number of days before expiration
6 *
7 * @default 365 */
8 days?: number
9
10 /**
11 * The date before which the certificate should not be valid
12 *
13 * @default now */
14 notBeforeDate?: Date
15
16 /**
17 * the size for the private key in bits
18 * @default 1024
19 */
20 keySize?: number
21 /**
22 * additional extensions for the certificate
23 */
24 extensions?: any[];
25 /**
26 * The signature algorithm sha256 or sha1
27 * @default "sha1"
28 */
29 algorithm?: string
30 /**
31 * include PKCS#7 as part of the output
32 * @default false
33 */
34 pkcs7?: boolean
35 /**
36 * generate client cert signed by the original key
37 * @default false
38 */
39 clientCertificate?: boolean
40 /**
41 * client certificate's common name
42 * @default "John Doe jdoe123"
43 */
44 clientCertificateCN?: string
45 /**
46 * the size for the client private key in bits
47 * @default 1024
48 */
49 clientCertificateKeySize?: number
50}
51
52declare interface GenerateResult {
53 private: string
54 public: string
55 cert: string
56 fingerprint: string
57}
58
59declare function generate(
60 attrs?: pki.CertificateField[],
61 opts?: SelfsignedOptions
62): GenerateResult
63
64declare function generate(
65 attrs?: pki.CertificateField[],
66 opts?: SelfsignedOptions,
67 /** Optional callback, if not provided the generation is synchronous */
68 done?: (err: undefined | Error, result: GenerateResult) => any
69): void
70
\No newline at end of file