index.d.ts 1.4 KB

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