/** * What a password-reset token can look like (CF-085 / S6b-13). * * `app/api/auth/reset-callback/route.ts` moves the `?token=` of the emailed link into an httpOnly cookie. * It used to do that for ANY string, so a link such as `/api/auth/reset-callback?token=abc` planted a * junk cookie (and a 10 KB value planted a 10 KB cookie). The backend issues 64 hexadecimal characters; * this accepts the wider `[A-Za-z0-9_-]{16,256}` so a change of token format on the server does not lock * every shopper out, and refuses everything else without setting anything. * * ⚠ This is a shape check, not proof that the token is real or that THIS browser asked for it: the link * is routinely opened on a different device than the one that requested it, and the API has no endpoint * to validate a token without spending it. A real token of someone else's account still plants; the * victim would then reset that account's password, which exposes none of the victim's data. * * ⛔ Imports nothing, on purpose: `scripts/check-oauth-state.mjs` runs this file as plain TypeScript. */ const RESET_TOKEN_SHAPE = /^[A-Za-z0-9_-]{16,256}$/; export function isPlausibleResetToken(value: unknown): value is string { return typeof value === 'string' && RESET_TOKEN_SHAPE.test(value); }