diff --git a/.omo/evidence/the-commons-hollow/task-4-the-commons-hollow.json b/.omo/evidence/the-commons-hollow/task-4-the-commons-hollow.json new file mode 100644 index 0000000..733df59 --- /dev/null +++ b/.omo/evidence/the-commons-hollow/task-4-the-commons-hollow.json @@ -0,0 +1,40 @@ +{ + "task": "task-4-the-commons-hollow", + "todo": 4, + "title": "Local identity (Ed25519 keypair)", + "summary": "Client-side, non-custodial Ed25519 identity generated on first init via @noble/ed25519 and persisted in IndexedDB via Dexie. Public key exposed for later signing use; private key never transmitted and no server-issued identity involved.", + "changed_files": [ + "src/lib/identity.ts", + "src/lib/db.ts", + "src/lib/identity.test.ts", + "src/lib/test-setup.ts", + "vitest.config.ts", + "package.json", + "package-lock.json" + ], + "verify": { + "framework": "vitest", + "command": "npx vitest run --reporter=verbose", + "result": "pass", + "tests_passed": 4, + "tests_total": 4, + "test_cases": [ + "generates and persists a 32-byte keypair on first init", + "returns the same public key on re-init instead of regenerating", + "signs a message and verifies it against the persisted public key", + "fails verification against a tampered message" + ], + "raw_output": "\n RUN v5.1.0 /home/athapa/patriothacks-wt/wave-1-foundation\n\n\n ❯ src/lib/identity.test.ts [queued]\n\n Test Files 0 passed (1)\n Tests 0 passed (0)\n Start at 16:43:52\n Duration 0ms\n\n ❯ src/lib/identity.test.ts 1/4\n\n Test Files 0 passed (1)\n Tests 1 passed (4)\n Start at 16:43:52\n Duration 100ms\n ✓ src/lib/identity.test.ts > identity > generates and persists a 32-byte keypair on first init 36ms\n ✓ src/lib/identity.test.ts > identity > returns the same public key on re-init instead of regenerating 5ms\n ✓ src/lib/identity.test.ts > identity > signs a message and verifies it against the persisted public key 5ms\n ✓ src/lib/identity.test.ts > identity > fails verification against a tampered message 5ms\n\n Test Files 1 passed (1)\n Tests 4 passed (4)\n Start at 16:43:52\n Duration 191ms (tests 48%, setup 20%, import 15%, transform 13%, worker 4%)" + }, + "manual_qa": { + "description": "Ran the real vitest suite (not a dry run) against the identity module using fake-indexeddb as the IndexedDB backend in a Node test environment, and confirmed `npm run build` (tsc -b strict + vite build) still exits 0 with the new files in place.", + "build_output_tail": "✓ built in 169ms\\nPWA v2.0.0\\nmode generateSW\\nprecache 10 entries (269.40 KiB)\\nfiles generated\\n dist/sw.js\\n dist/workbox-2fbc6a65.js" + }, + "constraints_confirmed": { + "no_server_issued_identity": true, + "no_custodial_key_storage": true, + "private_key_never_transmitted": true, + "notes": "Keypair generated entirely client-side via @noble/ed25519 keygenAsync(); secretKey is stored only in the browser's IndexedDB (Dexie 'identity' table) and is never sent over the network by any code path in this module." + }, + "timestamp": "2026-11-17T21:44:02.738Z" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 542604c..57bb6cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "the-commons-hollow", "version": "0.0.0", "dependencies": { + "@noble/ed25519": "^3.2.0", + "dexie": "^4.4.7", "react": "^19.3.1", "react-dom": "^19.3.1" }, @@ -16,11 +18,13 @@ "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.2", + "fake-indexeddb": "^6.2.8", "oxlint": "^1.90.0", "playwright": "^1.65.1", "typescript": "~7.0.2", "vite": "^8.3.6", "vite-plugin-pwa": "^2.0.0", + "vitest": "^5.1.0", "workbox-window": "^7.4.1" } }, @@ -1711,6 +1715,15 @@ "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" } }, + "node_modules/@noble/ed25519": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-3.2.0.tgz", + "integrity": "sha512-criDgRlnUA09hchYrTy/JUWPIEap5rZxQe6wDWzRx51oWWpDRcUpuNzlgPxDJaOK6AsW9c0wKcj3rKRv6t+bPQ==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@oxc-project/types": { "version": "0.156.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", @@ -2917,6 +2930,24 @@ "tslib": "^2.4.0" } }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", @@ -3338,6 +3369,64 @@ } } }, + "node_modules/@vitest/mocker": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.1.0", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/@vitest/mocker/node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/@vitest/spy": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/acorn": { "version": "8.19.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", @@ -3407,6 +3496,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/async": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", @@ -3640,6 +3739,16 @@ ], "license": "CC-BY-4.0" }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -3841,6 +3950,12 @@ "node": ">=8" } }, + "node_modules/dexie": { + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/dexie/-/dexie-4.4.7.tgz", + "integrity": "sha512-wemFiCl3DTCnfzyqepUTX1ugbYbkTrw3aEZOG7YjAOUoEQB5g5PrEywPzk5JpbX/SxqQ9IvjUpxCDIEjoOWEfA==", + "license": "Apache-2.0" + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -3987,6 +4102,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", @@ -4077,6 +4199,26 @@ "url": "https://github.com/bgub/eta?sponsor=1" } }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fake-indexeddb": { + "version": "6.2.8", + "resolved": "https://registry.npmjs.org/fake-indexeddb/-/fake-indexeddb-6.2.8.tgz", + "integrity": "sha512-mpVW/HLUqwKXJ6F/s0hMgdK1eQfM4ncTHDioNGHWL0WKV3VcZCoZq1NKgboBbAge07aRCO7L48yziKssL59XEQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -5478,6 +5620,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/own-keys": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz", @@ -6227,6 +6383,13 @@ "node": ">=0.10.0" } }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, "node_modules/stop-iteration-iterator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", @@ -6415,6 +6578,26 @@ "node": ">=10" } }, + "node_modules/tinybench": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.3.tgz", + "integrity": "sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/tinyglobby": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", @@ -6809,6 +6992,99 @@ } } }, + "node_modules/vitest": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.1.0", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.3", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.2", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.1.0", + "@vitest/browser-preview": "5.1.0", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/vitest/node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -6914,6 +7190,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + }, "node_modules/workbox-background-sync": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.4.1.tgz", diff --git a/package.json b/package.json index ddd1ba3..9703abb 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,12 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "oxlint", - "preview": "vite preview" + "preview": "vite preview", + "test": "vitest run" }, "dependencies": { + "@noble/ed25519": "^3.2.0", + "dexie": "^4.4.7", "react": "^19.3.1", "react-dom": "^19.3.1" }, @@ -18,11 +21,13 @@ "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.2", + "fake-indexeddb": "^6.2.8", "oxlint": "^1.90.0", "playwright": "^1.65.1", "typescript": "~7.0.2", "vite": "^8.3.6", "vite-plugin-pwa": "^2.0.0", + "vitest": "^5.1.0", "workbox-window": "^7.4.1" } } diff --git a/src/lib/db.ts b/src/lib/db.ts new file mode 100644 index 0000000..7715655 --- /dev/null +++ b/src/lib/db.ts @@ -0,0 +1,25 @@ +import Dexie, { type EntityTable } from "dexie"; + +/** A single, non-custodial local identity record. Exactly one row ever exists. */ +export interface IdentityRecord { + /** Fixed primary key - there is only ever one local identity. */ + id: "local"; + /** 32-byte Ed25519 public key. */ + publicKey: Uint8Array; + /** 32-byte Ed25519 secret-key seed. Never leaves this device. */ + secretKey: Uint8Array; + createdAt: number; +} + +export class CommonsDatabase extends Dexie { + identity!: EntityTable; + + constructor() { + super("the-commons-hollow"); + this.version(1).stores({ + identity: "id", + }); + } +} + +export const db = new CommonsDatabase(); diff --git a/src/lib/identity.test.ts b/src/lib/identity.test.ts new file mode 100644 index 0000000..4bb992b --- /dev/null +++ b/src/lib/identity.test.ts @@ -0,0 +1,55 @@ +import { beforeEach, describe, expect, it } from "vitest"; +import { db } from "./db"; +import { getPublicKey, init, sign, verify } from "./identity"; + +beforeEach(async () => { + indexedDB.deleteDatabase(db.name); + db.close(); + await db.open(); +}); + +describe("identity", () => { + it("generates and persists a 32-byte keypair on first init", async () => { + const { publicKey } = await init(); + + expect(publicKey).toBeInstanceOf(Uint8Array); + expect(publicKey.length).toBe(32); + + const stored = await db.identity.get("local"); + expect(stored).toBeDefined(); + expect(stored!.publicKey.length).toBe(32); + expect(stored!.secretKey.length).toBe(32); + expect(await db.identity.count()).toBe(1); + }); + + it("returns the same public key on re-init instead of regenerating", async () => { + const first = await init(); + const second = await init(); + + expect(second.publicKey).toEqual(first.publicKey); + expect(await db.identity.count()).toBe(1); + }); + + it("signs a message and verifies it against the persisted public key", async () => { + await init(); + const message = new TextEncoder().encode("the-commons-hollow"); + + const signature = await sign(message); + const publicKey = await getPublicKey(); + const isValid = await verify(signature, message, publicKey); + + expect(isValid).toBe(true); + }); + + it("fails verification against a tampered message", async () => { + await init(); + const message = new TextEncoder().encode("original payload"); + const tampered = new TextEncoder().encode("tampered payload"); + + const signature = await sign(message); + const publicKey = await getPublicKey(); + const isValid = await verify(signature, tampered, publicKey); + + expect(isValid).toBe(false); + }); +}); diff --git a/src/lib/identity.ts b/src/lib/identity.ts new file mode 100644 index 0000000..8a012b7 --- /dev/null +++ b/src/lib/identity.ts @@ -0,0 +1,54 @@ +import * as ed from "@noble/ed25519"; +import { db, type IdentityRecord } from "./db"; + +export class IdentityMissingError extends Error { + constructor() { + super("No local identity found. Call identity.init() before signing."); + this.name = "IdentityMissingError"; + } +} + +export interface LocalIdentity { + publicKey: Uint8Array; +} + +async function loadExisting(): Promise { + return db.identity.get("local"); +} + +export async function init(): Promise { + const existing = await loadExisting(); + if (existing) { + return { publicKey: existing.publicKey }; + } + + const { secretKey, publicKey } = await ed.keygenAsync(); + const record: IdentityRecord = { + id: "local", + secretKey, + publicKey, + createdAt: Date.now(), + }; + await db.identity.add(record); + return { publicKey }; +} + +export async function getPublicKey(): Promise { + const record = await loadExisting(); + if (!record) throw new IdentityMissingError(); + return record.publicKey; +} + +export async function sign(message: Uint8Array): Promise { + const record = await loadExisting(); + if (!record) throw new IdentityMissingError(); + return ed.signAsync(message, record.secretKey); +} + +export async function verify( + signature: Uint8Array, + message: Uint8Array, + publicKey: Uint8Array, +): Promise { + return ed.verifyAsync(signature, message, publicKey); +} diff --git a/src/lib/test-setup.ts b/src/lib/test-setup.ts new file mode 100644 index 0000000..e7657ee --- /dev/null +++ b/src/lib/test-setup.ts @@ -0,0 +1 @@ +import "fake-indexeddb/auto"; diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..b2b8bd2 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + setupFiles: ["./src/lib/test-setup.ts"], + }, +});