Commit Graph

20 Commits

Author SHA1 Message Date
8aecf977e9 Phase 2 green: implement crypto primitives
Each stub is replaced with a thin wrapper over libsodium-wrappers-sumo:

  * init() awaits sodium.ready
  * toBase64 / toBase64URL / fromBase64 use sodium's base64 variants;
    fromBase64 tries all four (standard, standard-no-pad, URL-safe,
    URL-safe-no-pad) so callers don't have to know which form Ente
    delivered
  * deriveKEK is sodium.crypto_pwhash with ALG_ARGON2ID13 and 32-byte
    output
  * deriveLoginSubkey is sodium.crypto_kdf_derive_from_key(32, 1,
    'loginctx', kek).slice(0, 16) per the upstream Ente clients
  * decryptBox is sodium.crypto_secretbox_open_easy
  * decryptSealed is sodium.crypto_box_seal_open
  * initStreamPull / pullStreamChunk wrap the secretstream pull API,
    throwing on authentication failure rather than returning false

All 32 tests pass; make check is green.
2026-05-09 12:44:59 -07:00
676d42c5eb Phase 2 red: crypto primitive tests and stub modules
Tests for the entire crypto/ public surface, written against the API
shape declared in the README. The accompanying src/crypto/ modules are
stubs that throw 'not implemented' so the test files compile and tests
fail with clear errors rather than module-not-found.

Tests cover:
  * init() resolves and is idempotent
  * fromBase64 / toBase64 / toBase64URL round-trips, including URL-safe
    input with stripped padding (the form Ente uses for auth tokens)
  * deriveKEK matches sodium.crypto_pwhash with Argon2id parameters
  * deriveLoginSubkey matches sodium.crypto_kdf_derive_from_key with
    subkey id 1 and ctx 'loginctx', truncated to 16 bytes
  * decryptBox round-trips, rejects tampering, wrong key, wrong nonce
  * decryptSealed round-trips, rejects wrong keypair and tampering
  * Secretstream pull decrypts multi-chunk streams in order, exposes
    per-chunk tags, rejects tampering, wrong key, and out-of-order chunks
  * Constants STREAM_CHUNK_SIZE (4 MiB) and STREAM_CHUNK_OVERHEAD (17)

Tests are commented to serve as the canonical API documentation per the
README development workflow policy. Verified: 29 tests fail (red), 3
trivial constant tests pass; lint and fmt-check are green.

eslint.config.mjs is updated to honour the leading-underscore convention
for intentionally unused parameters (the stubs).
2026-05-09 12:43:52 -07:00
64a3ace33a Add libsodium-wrappers-sumo runtime dependency
The 'sumo' build is required for crypto_pwhash (Argon2id), which Ente
uses to derive the KEK from the user's password. Pinned to exact
versions in package.json with integrity hashes in yarn.lock per repo
policy on hash-pinned external references.
2026-05-09 21:40:38 +02:00
5fc01f4558 Merge: relax pre-commit hook to support TDD red-phase commits 2026-05-09 21:39:34 +02:00
0d504294b5 Pre-commit hook runs lint+fmt-check, not full check (TDD)
Tests are deliberately excluded from the pre-commit hook so that the
TDD red-phase commit (failing tests landing before implementation) can
land on a feature branch. CI still runs full make check via docker build
so a red branch cannot reach main.
2026-05-09 21:39:32 +02:00
22c80d07ee Merge: TDD development workflow 2026-05-09 21:37:40 +02:00
3ccb00d6c8 Mandate TDD in README development workflow
All changes go on a feature branch; the first commit on the branch is the
failing test suite for the change; the branch can only merge to main when
make check is green. Tests are the canonical API documentation and must be
commented thoroughly so a reader can learn the library from them.
2026-05-09 21:37:33 +02:00
b35c677e23 Merge initial scaffolding
Initial repo scaffolding per sneak/prompts NEW_REPO_CHECKLIST: WTFPL
LICENSE, REPO_POLICIES.md, editor and prettier dotfiles, JS toolchain
(TypeScript, ESLint, Prettier, Vitest with pinned versions), Makefile,
Dockerfile (node:22-alpine pinned by sha256), Gitea Actions workflow.
make check and make docker both pass.
2026-05-09 21:33:08 +02:00
42cc1f4a77 Tick off Phase 1 scaffolding TODO items in README 2026-05-09 21:32:32 +02:00
d64db876ca Add Gitea Actions workflow that runs docker build on push 2026-05-09 21:31:01 +02:00
7d087ba7f9 Add Dockerfile pinning node:22-alpine by sha256
Non-server image: brings up the dev environment and runs make check, per
repo policy on Dockerfiles for non-server repos. Base image hash matches
the sneak/prompts template (node 22-alpine, 2026-02-22).
2026-05-09 21:31:00 +02:00
d7d3cd1af7 Add Makefile with check, build, docker, hooks targets
Targets: test (vitest, with conditional verbose rerun pattern), lint
(eslint + prettier), fmt / fmt-check (prettier), check (test + lint +
fmt-check), build (tsc), dev (tsc --watch), clean, docker, hooks.

Uses GNU timeout when available to hard-cap make test at 30 seconds, per
repo policy. Falls through without a cap on systems where timeout is
absent.
2026-05-09 21:30:34 +02:00
47cdb5ca8b Add JS toolchain: TypeScript, ESLint, Prettier, Vitest
package.json declares the project as ESM with NodeNext module resolution,
exposing dist/index.js as the library entry and dist/bin/quack.js as the
CLI binary. Dev dependencies are pinned to exact versions (yarn.lock holds
the integrity hashes per repo policy on hash-pinned external references).
Adds a placeholder src/index.ts and a single smoke test so make check is
not a no-op.
2026-05-09 21:29:13 +02:00
65b5124cf5 gitignore: ignore .claude/ local agent settings 2026-05-09 21:29:09 +02:00
ed8b3a8fff Reflow README to prettier 80-column prose wrap 2026-05-09 21:29:08 +02:00
fde1a1da29 Add editor, prettier, and ignore dotfiles
.gitignore extended for TypeScript/Node build artifacts on top of the
prompts-repo template. .editorconfig and .prettierrc match the prompts
template (4-space indents, prose-wrap always for markdown).
2026-05-09 21:27:16 +02:00
31f092b7bc Add REPO_POLICIES.md from sneak/prompts (synced 2026-05-09) 2026-05-09 21:27:03 +02:00
0146ee4ea2 Add WTFPL license 2026-05-09 21:27:03 +02:00
64108536fb Expand README: desktop-client motivation and API reference
Reframes the project as the protocol foundation for a future Electron-based
Ente desktop client (the existing official clients are unsatisfactory).
Adds an API reference section with TypeScript declarations for every
exported name across crypto, auth, model, api, session, and Client modules.
Adds Phase 10 desktop-client TODO items so a future agent can pick up the
plan.
2026-05-09 21:25:05 +02:00
0006af4f70 Initial commit: README with project spec and implementation plan 2026-05-09 18:57:58 +02:00