enhance checkOptions to reject invalid signer objects
I passed a Buffer instead of a string as a secret, and this resulted in an error message that "cookieSigner.sign is not a function" an at request time, rather than at plugin registration.
Someone else had a similar issue in the past https://github.com/fastify/help/issues/852
This PR makes checkOptions more comprehensive (explicitly checking for .sign and .unsign methods on signer objects passed as options.secret), and adds associated tests, so that this error is caught sooner and with a helpful message :)
Checklist
- [x] run
npm run testandnpm run benchmark - [x] tests and/or benchmarks are included
- [n/a] documentation is changed or added
- [x] commit message and code follows the Developer's Certification of Origin and the Code of conduct
CI failed, can you take a look?
@gurgunday It seems that the cookie "maxAge set by maxAge" test has a race condition, since the clock can run forwards 1ms between line 582 and line 583, changing the max age of the cookie from 1000 to 999.
Yeah I remember now