new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · Plugins · all subjects

api-key/custom

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Custom key generation with customKeyGenerator

You can customize the key generation process by providing a customKeyGenerator function in the plugin options. This function receives an options object with length (number) and prefix (string or undefined) properties and should return the generated API key string. Example: customKeyGenerator could use crypto.randomUUID() or a custom algorithm.

defaultKeyLength requirement for custom key generators

If a customKeyGenerator function does not use the length property provided in options, you must set the defaultKeyLength property in plugin options to specify the actual length of generated keys. This is required for the verification system to work correctly.

Custom API key validator with customAPIKeyValidator

You can provide a customAPIKeyValidator async function in the plugin options that receives an object with ctx (context) and key (the API key string) properties and returns a boolean indicating if the key is valid. This allows custom validation logic. Even with a custom validator, the key must still match against the database's stored key for the final verification.

Give your agent this brain