index.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import type { Logger } from 'vite';
  2. import { type BaseSource } from './source';
  3. export type SourceType = 'github' | 'coding' | BaseSource;
  4. export type MkcertBaseOptions = {
  5. /**
  6. * Whether to force generate
  7. */
  8. force?: boolean;
  9. /**
  10. * Automatically upgrade mkcert
  11. *
  12. * @default false
  13. */
  14. autoUpgrade?: boolean;
  15. /**
  16. * Specify mkcert download source
  17. *
  18. * @default github
  19. */
  20. source?: SourceType;
  21. /**
  22. * If your network is restricted, you can specify a local binary file instead of downloading, it should be an absolute path
  23. *
  24. * @default none
  25. */
  26. mkcertPath?: string;
  27. /**
  28. * The location to save the files, such as key and cert files
  29. */
  30. savePath?: string;
  31. /**
  32. * The name of private key file generated by mkcert
  33. */
  34. keyFileName?: string;
  35. /**
  36. * The name of cert file generated by mkcert
  37. */
  38. certFileName?: string;
  39. };
  40. export type MkcertOptions = MkcertBaseOptions & {
  41. logger: Logger;
  42. };
  43. declare class Mkcert {
  44. private force?;
  45. private autoUpgrade?;
  46. private sourceType;
  47. private savePath;
  48. private logger;
  49. private source;
  50. private localMkcert?;
  51. private savedMkcert;
  52. private keyFilePath;
  53. private certFilePath;
  54. private config;
  55. static create(options: MkcertOptions): Mkcert;
  56. private constructor();
  57. private getMkcertBinary;
  58. private checkCAExists;
  59. private retainExistedCA;
  60. private getCertificate;
  61. private createCertificate;
  62. private getLatestHash;
  63. private regenerate;
  64. init(): Promise<void>;
  65. private getSourceInfo;
  66. private initMkcert;
  67. private upgradeMkcert;
  68. private downloadMkcert;
  69. renew(hosts: string[]): Promise<void>;
  70. /**
  71. * Get certificates
  72. *
  73. * @param hosts host collection
  74. * @returns cretificates
  75. */
  76. install(hosts: string[]): Promise<{
  77. key: string;
  78. cert: string;
  79. }>;
  80. }
  81. export default Mkcert;