index.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 size for the private key in bits
  10. * @default 1024
  11. */
  12. keySize?: number
  13. /**
  14. * additional extensions for the certificate
  15. */
  16. extensions?: any[];
  17. /**
  18. * The signature algorithm sha256 or sha1
  19. * @default "sha1"
  20. */
  21. algorithm?: string
  22. /**
  23. * include PKCS#7 as part of the output
  24. * @default false
  25. */
  26. pkcs7?: boolean
  27. /**
  28. * generate client cert signed by the original key
  29. * @default false
  30. */
  31. clientCertificate?: undefined
  32. /**
  33. * client certificate's common name
  34. * @default "John Doe jdoe123"
  35. */
  36. clientCertificateCN?: string
  37. }
  38. declare interface GenerateResult {
  39. private: string
  40. public: string
  41. cert: string
  42. fingerprint: string
  43. }
  44. declare function generate(
  45. attrs?: pki.CertificateField[],
  46. opts?: SelfsignedOptions
  47. ): GenerateResult
  48. declare function generate(
  49. attrs?: pki.CertificateField[],
  50. opts?: SelfsignedOptions,
  51. /** Optional callback, if not provided the generation is synchronous */
  52. done?: (err: undefined | Error, result: GenerateResult) => any
  53. ): void