index.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /// <reference types="node" />
  2. import { Logger } from 'vite';
  3. import { BaseSource } from './source';
  4. export declare type SourceType = 'github' | 'coding' | BaseSource;
  5. export declare type MkcertOptions = {
  6. /**
  7. * Whether to force generate
  8. */
  9. force?: boolean;
  10. /**
  11. * Automatically upgrade mkcert
  12. *
  13. * @default false
  14. */
  15. autoUpgrade?: boolean;
  16. /**
  17. * Specify mkcert download source
  18. *
  19. * @default github
  20. */
  21. source?: SourceType;
  22. /**
  23. * If your network is restricted, you can specify a local binary file instead of downloading
  24. *
  25. * @description it should be absolute path
  26. * @default none
  27. */
  28. mkcertPath?: string;
  29. };
  30. export declare type MkcertProps = MkcertOptions & {
  31. logger: Logger;
  32. };
  33. declare class Mkcert {
  34. private force?;
  35. private autoUpgrade?;
  36. private mkcertLocalPath?;
  37. private source;
  38. private logger;
  39. private mkcertSavedPath;
  40. private sourceType;
  41. private config;
  42. static create(options: MkcertProps): Mkcert;
  43. private constructor();
  44. private getMkcertBinnary;
  45. /**
  46. * Check if mkcert exists
  47. */
  48. private checkMkcert;
  49. private getCertificate;
  50. private createCertificate;
  51. private getLatestHash;
  52. private regenerate;
  53. init(): Promise<void>;
  54. private getSourceInfo;
  55. private initMkcert;
  56. private upgradeMkcert;
  57. private downloadMkcert;
  58. renew(hosts: string[]): Promise<void>;
  59. /**
  60. * Get certificates
  61. *
  62. * @param hosts host collection
  63. * @returns cretificates
  64. */
  65. install(hosts: string[]): Promise<{
  66. key: Buffer;
  67. cert: Buffer;
  68. }>;
  69. }
  70. export default Mkcert;