diff --git a/README.md b/README.md index daefa2f..8edaada 100644 --- a/README.md +++ b/README.md @@ -87,14 +87,12 @@ pluginBasicSsl({ Options passing to `selfsigned`, see [selfsigned - Options](https://github.com/jfromaniello/selfsigned?tab=readme-ov-file#options) for details. -In addition, the plugin supports a `days` option to set the validity period of the certificate. It is converted to `notAfterDate` and ignored if `notAfterDate` is set. - -- **Type:** `SelfsignedOptions & { days?: number }` +- **Type:** `SelfsignedOptions` - **Default:** ```ts const defaultOptions = { - days: 30, + notAfterDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), keySize: 2048, }; ``` @@ -104,7 +102,7 @@ const defaultOptions = { ```ts pluginBasicSsl({ selfsignedOptions: { - days: 100, + notAfterDate: new Date(Date.now() + 100 * 24 * 60 * 60 * 1000), }, }); ``` diff --git a/src/index.ts b/src/index.ts index 32d3264..dc17f97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,14 +22,7 @@ export type PluginBasicSslOptions = { /** * Options passing to `selfsigned`. */ - selfsignedOptions?: SelfsignedOptions & { - /** - * Validity period of the certificate in days. - * Ignored if `notAfterDate` is set. - * @default 30 - */ - days?: number; - }; + selfsignedOptions?: SelfsignedOptions; }; export const pluginBasicSsl = ( diff --git a/src/util.ts b/src/util.ts index 8ae7f5e..e294f01 100644 --- a/src/util.ts +++ b/src/util.ts @@ -46,11 +46,10 @@ export const resolveHttpsConfig = async ( options.filename ?? 'fake-cert.pem', ); - const { days = 30, ...restOptions } = options.selfsignedOptions ?? {}; const selfsignedOptions = { keySize: 2048, - notAfterDate: new Date(Date.now() + days * 24 * 60 * 60 * 1000), - ...restOptions, + notAfterDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), + ...options.selfsignedOptions, }; if (fs.existsSync(certPath)) { diff --git a/test/selfsigned-options/index.test.ts b/test/selfsigned-options/index.test.ts index 84d2f21..8e9ddcb 100644 --- a/test/selfsigned-options/index.test.ts +++ b/test/selfsigned-options/index.test.ts @@ -13,7 +13,7 @@ test('should print HTTPS server URLs when custom selfsigned options', async () = plugins: [ pluginBasicSsl({ selfsignedOptions: { - days: 1, + notAfterDate: new Date(Date.now() + 24 * 60 * 60 * 1000), }, }), ],