From a9bdcecc2819d45befc1b08c8242b38e124a23a7 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 28 Sep 2026 18:59:47 +0200 Subject: [PATCH] Version constants: 0.1.0-dev, implementing spec 0.8.2 - src/lib/dkc/version.ts exports VERSION (0.1.0-dev, which becomes 0.1.0 once phase 2 adds the opening of capsules) and SPEC_VERSION (0.8.2, the tag spec-v0.8.2 of datekeys-go), from index.ts too. - package.json and its lockfile move to 0.1.0-dev. version.test.ts ties VERSION to both and checks it is semantic versioning. It also ties SPEC_VERSION to the spec field of the shared vectors and fixtures. testing/vectors.ts now takes SPEC_VERSION from version.ts, so every vector file is checked against the version the library declares. - The footer of the page shows both, instead of a fixed 0.8.2. - README.md gains a "Versiones" section: the three versions (format, specification, library) and what 0.1.0-dev covers. CHANGELOG.md is new. The Go reference gained datekeys.SpecVersion, datekeys.Version() and `datekeys version` in 5b342d3. npm run verify is green: 2,406 tests. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ README.md | 21 +++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/lib/dkc/index.ts | 1 + src/lib/dkc/testing/vectors.ts | 5 +++-- src/lib/dkc/version.test.ts | 24 ++++++++++++++++++++++++ src/lib/dkc/version.ts | 17 +++++++++++++++++ src/routes/+layout.svelte | 5 +++-- 9 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 src/lib/dkc/version.test.ts create mode 100644 src/lib/dkc/version.ts diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b257d54 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +Cambios notables de la librería TypeScript y de la página. El proyecto usa versionado semántico; mientras sea 0.x, no hay promesa de estabilidad. La sección «Versiones» del [README](README.md) explica qué cubre cada número. + +## 0.1.0 — sin publicar + +Implementa la especificación DateKeys 0.8.2 (tag `spec-v0.8.2` de `datekeys-go`) para el perfil Quicknet, y pasa todos los vectores y fixtures compartidos de `datekeys-go` en `9ac9cd9`. + +### Hecho + +- Codec CBOR del perfil de §58 con los textos de error de la referencia Go. +- Schemas del Provider Profile, `PUBLIC_HEADER`, `CONTROL_CBOR` y `.dkk`. +- Tramas DKC1 y DKK1, cabeceras `age` y DateKey (`dk1_`). +- Extensiones, con los objetos y arrays de su registro. +- La inspección de los pasos 1 a 8 de §63. +- La página estática `/inspect`, sin red. Tras cada compilación se comprueban su política de seguridad y los paquetes de su bundle. +- Fase 2, en curso: + - dependencias de ejecución (`age-encryption` 0.3.1, `@noble/curves` y `@noble/hashes` 2.4.0) con sus guardas; + - el IBE de tlock (`ibe.ts`) y la verificación local de releases (`release.ts`), contrastados con la referencia Go. +- `VERSION` y `SPEC_VERSION`, también en el pie de la página. + +### Pendiente para 0.1.0 + +- La apertura de cápsulas, pasos 9 a 18 de §63 (fase 2, pasos 5 a 8). diff --git a/README.md b/README.md index 9810632..c2f67de 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,27 @@ La implementación de referencia es la librería Go `g.activething.com/go/DateKe | Página inspector, sin red | SvelteKit estático: `src/routes/`, `src/lib/inspector/`, `src/lib/components/` | 5 | hecho | | Cifrado y descifrado en el navegador | fase 2: [docs/PLAN_fase2_ibe_noble2.md](docs/PLAN_fase2_ibe_noble2.md) | 6 | en curso: dependencias y guardas hechas (paso 2 de la fase) | +## Versiones + +Hay tres números de versión, cada uno con su significado, como en la referencia Go: + +| Versión | Dónde | Cambia cuando | +|---|---|---| +| Formato | Dentro de los objetos: la versión de framing de DKC1 y DKK1 y la de schema de la clave 1, hoy todas 1 | Cambia el formato. Un lector rechaza una versión que no conoce (§70) | +| Especificación | `SPEC_VERSION` de `src/lib/dkc/version.ts`, hoy `0.8.2`: la del tag `spec-v0.8.2` de `datekeys-go` | Cambia el texto normativo | +| Librería | `VERSION` de `src/lib/dkc/version.ts`, igual al campo `version` de `package.json` | Cambia la API o el comportamiento. Versionado semántico, sin promesa de estabilidad antes de 1.0.0 | + +`version.test.ts` comprueba que `VERSION` coincide con `package.json` y con su lockfile, y que `SPEC_VERSION` es la versión que nombran los vectores y fixtures compartidos; `vectors.test.ts` exige esa versión a cada fichero. El pie de la página muestra las dos. + +La versión actual es `0.1.0-dev`. Será `0.1.0` cuando la fase 2 añada la apertura de cápsulas. Cubre: +- la especificación 0.8.2, con versiones de formato 1; +- solo el scheme de Quicknet (`bls-unchained-g1-rfc9380`): un perfil de otro scheme se inspecciona, pero su release no se verifica (decisión 3 del plan de la fase 2); +- la inspección de los pasos 1 a 8, el IBE de tlock (`ibe.ts`) y la verificación de releases (`release.ts`). La apertura (pasos 9 a 18) llega en la fase 2 y el cifrado en la fase 3; +- todos los vectores y fixtures compartidos de `datekeys-go` en `9ac9cd9` (`spec-v0.8.2`); +- navegadores con Web Crypto y Node 20 o posterior. + +[CHANGELOG.md](CHANGELOG.md) recoge los cambios de cada versión. + ## `src/lib/dkc` Lo que hay hoy (pasos 1 a 8) no importa ninguna dependencia. Funciona en navegadores y en Node 20+: solo usa `Uint8Array`, `DataView`, `TextEncoder`/`TextDecoder`, `BigInt` y `crypto.subtle` (SHA-256). La fase 2 añade las dependencias de ejecución de su sección, y noble solo lo importarán `ibe.ts` y `release.ts`. diff --git a/package-lock.json b/package-lock.json index e22f343..ab0c88a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "datekeys-app", - "version": "0.0.0", + "version": "0.1.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "datekeys-app", - "version": "0.0.0", + "version": "0.1.0-dev", "license": "Apache-2.0", "dependencies": { "@noble/curves": "2.4.0", diff --git a/package.json b/package.json index e444c76..39f1c09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datekeys-app", - "version": "0.0.0", + "version": "0.1.0-dev", "private": true, "description": "DateKeys in TypeScript: canonical CBOR codec, DKC1/DKK1 parsers, capsule inspector library and its static inspector page; later, browser encryption and decryption.", "license": "Apache-2.0", diff --git a/src/lib/dkc/index.ts b/src/lib/dkc/index.ts index e4b4e72..6414dc3 100644 --- a/src/lib/dkc/index.ts +++ b/src/lib/dkc/index.ts @@ -16,3 +16,4 @@ export * from './framing.ts'; export * from './header.ts'; export * from './inspect.ts'; export * from './profile.ts'; +export * from './version.ts'; diff --git a/src/lib/dkc/testing/vectors.ts b/src/lib/dkc/testing/vectors.ts index a593d63..db2e847 100644 --- a/src/lib/dkc/testing/vectors.ts +++ b/src/lib/dkc/testing/vectors.ts @@ -6,11 +6,12 @@ import { fromHex } from '../bytes.ts'; import { isErrorCode } from '../errors.ts'; +import { SPEC_VERSION } from '../version.ts'; export type Json = Record; -/** The version of the specification every vector file must name. */ -export const SPEC_VERSION = '0.8.2'; +/** The version of the specification every vector file must name: the one the library implements. */ +export { SPEC_VERSION }; export class FormatError extends Error { constructor(where: string, what: string) { diff --git a/src/lib/dkc/version.test.ts b/src/lib/dkc/version.test.ts new file mode 100644 index 0000000..ad65834 --- /dev/null +++ b/src/lib/dkc/version.test.ts @@ -0,0 +1,24 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; +import { readJSON } from './testing/testdata.ts'; +import { SPEC_VERSION, VERSION } from './version.ts'; + +// The version of the library is the one of package.json and its lockfile; +// the version of the specification is the one every shared vector file +// names (vectors.test.ts checks each file against it). +describe('versions', () => { + it('VERSION is the version of package.json and of its lockfile, in semantic versioning', () => { + const root = new URL('../../../', import.meta.url); + const pkg = JSON.parse(readFileSync(new URL('package.json', root), 'utf8')) as { version: string }; + const lock = JSON.parse(readFileSync(new URL('package-lock.json', root), 'utf8')) as { version: string; packages: Record }; + expect(VERSION).toBe(pkg.version); + expect([lock.version, lock.packages['']?.version]).toEqual([VERSION, VERSION]); + expect(VERSION).toMatch(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/); + }); + + it('SPEC_VERSION is the specification of the shared vectors and fixtures', () => { + for (const file of ['vectors/cbor.json', 'vectors/mutations.json', 'vectors/tlock_ibe.json', 'fixtures/time_only.json']) { + expect(readJSON<{ spec: string }>(file).spec, file).toBe(SPEC_VERSION); + } + }); +}); diff --git a/src/lib/dkc/version.ts b/src/lib/dkc/version.ts new file mode 100644 index 0000000..3b67325 --- /dev/null +++ b/src/lib/dkc/version.ts @@ -0,0 +1,17 @@ +// The versions of this library. There are three, each with its own meaning +// (README, "Versiones"): the format versions inside the objects (framing and +// schema, 1 today; spec §70), the version of the specification it +// implements, and its own version. + +/** + * The version of this library, as in package.json: 0.1.0 once phase 2 adds + * the opening of capsules to their inspection; 0.1.0-dev until then. + */ +export const VERSION = '0.1.0-dev'; + +/** + * The version of the DateKeys Protocol Specification that this library + * implements: the tag spec-v0.8.2 of the Go reference, whose shared vectors + * and fixtures (testdata/) all name it. + */ +export const SPEC_VERSION = '0.8.2'; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 870777e..eae12bb 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,6 +4,7 @@ import { resolve } from '$app/paths'; import { page } from '$app/state'; import Mark from '$lib/components/Mark.svelte'; + import { SPEC_VERSION, VERSION } from '$lib/dkc/version.ts'; let { children }: { children: Snippet } = $props(); @@ -32,8 +33,8 @@