Add initial shared code packages

This commit is contained in:
Gabriel20xx committed 2026-08-04 15:17:15 +02:00
commit 838a97d344
54 files changed
+6265

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
createSessionToken,
hashPassword,
hashToken,
verifyPassword,
} from '../src/auth.js';
test('password hashes verify and reject a different password', () => {
const hash = hashPassword('correct horse battery staple');
assert.equal(verifyPassword('correct horse battery staple', hash), true);
assert.equal(verifyPassword('wrong password', hash), false);
});
test('session token hashes are not the raw token', () => {
const { token, tokenHash } = createSessionToken();
assert.notEqual(token, tokenHash);
assert.equal(hashToken(token), tokenHash);
});