Add initial shared code packages
This commit is contained in:
commit
838a97d344
54 files changed
+6265
No files matched your search
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user