/**
 * Self-check: safeNextPath blocks open redirects.
 * Run: npx --yes tsx src/lib/authRedirect.check.ts
 */
import { safeNextPath, loginHref } from './authRedirect.ts';

let passed = 0;
function assert(cond: boolean, msg: string) {
  if (!cond) throw new Error(msg);
  passed += 1;
}

assert(safeNextPath('/wallet') === '/wallet', 'internal ok');
assert(safeNextPath('//evil.com') === '/', 'protocol-relative blocked');
assert(safeNextPath('https://evil.com') === '/', 'absolute blocked');
assert(loginHref('/kyc').includes('next=%2Fkyc'), 'login next encoded');
console.log(`authRedirect.check: ${passed} asserts ok`);
