NobGit
public anord read

Ledger

Why work hard when you can work easier?

Languages

Repository composition by tracked source files.

TypeScript
TypeScript 86% CSS 10% SQL 3% Shell 1% HTML 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/anord/ledger.git
ssh://[email protected]:2222/orgs/anord/ledger.git
auth.test.ts
import { describe, expect, it } from "vitest";
import { createSessionToken, hashPassword, verifyPassword, verifySessionToken } from "../services/auth.js";

describe("auth helpers", () => {
  it("hashes and verifies passwords", async () => {
    const hash = await hashPassword("Password123!");
    await expect(verifyPassword("Password123!", hash)).resolves.toBe(true);
    await expect(verifyPassword("WrongPassword!", hash)).resolves.toBe(false);
  });

  it("creates and verifies session tokens", () => {
    const token = createSessionToken({
      id: "user-1",
      email: "[email protected]",
      displayName: "User",
      role: "viewer",
      groupIds: []
    });

    expect(verifySessionToken(token).email).toBe("[email protected]");
  });
});