sealed-lattice 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ The current implementation ships:
22
22
 
23
23
  - a real `sha256Hex` helper on the safe root package
24
24
  - a typed `UnsupportedRuntimeError` for missing Web Crypto support
25
- - the same repo, docs, testing, and publish workflow shape used by `threshold-elgamal`
25
+ - a hardened repo, docs, testing, and publish workflow around that narrow surface
26
26
  - a deliberately narrow public surface while the lattice-native architecture is still being proven
27
27
 
28
28
  This repository is a hardened research prototype. It is not audited production voting software.
@@ -31,7 +31,7 @@ This repository is a hardened research prototype. It is not audited production v
31
31
 
32
32
  This repository currently tracks the initial public `sealed-lattice` surface.
33
33
 
34
- The public surface is intentionally narrow while the repo, CI, docs, tests, coverage, and packaging experience are brought up to parity with the existing classical baseline. Lattice cryptography, threshold flows, transport payloads, proofs, protocol types, and any future subpath structure are still being designed and are not frozen yet.
34
+ The public surface is intentionally narrow while the repo, CI, docs, tests, coverage, and packaging experience are stabilized. Lattice cryptography, threshold flows, transport payloads, proofs, protocol types, and any future subpath structure are still being designed and are not frozen yet.
35
35
 
36
36
  ## Installation
37
37
 
@@ -43,6 +43,7 @@ pnpm add sealed-lattice
43
43
 
44
44
  - Use ESM imports such as `import { sha256Hex } from 'sealed-lattice'`. The published package does not expose CommonJS `require()` entry points.
45
45
  - Browsers need `globalThis.crypto.subtle` and `TextEncoder`.
46
+ - CI validates Chromium, Firefox, and WebKit on desktop, plus Chromium and WebKit in mobile emulation.
46
47
  - Node requires version `24.14.1` or newer with `globalThis.crypto`.
47
48
 
48
49
  ## Safe quickstart
@@ -67,6 +68,7 @@ No additional public subpaths are promised yet. Future capability areas such as
67
68
 
68
69
  - Hosted documentation site: [tenemo.github.io/sealed-lattice](https://tenemo.github.io/sealed-lattice/)
69
70
  - Get started: [tenemo.github.io/sealed-lattice/guides/getting-started](https://tenemo.github.io/sealed-lattice/guides/getting-started/)
71
+ - Browser and worker usage: [tenemo.github.io/sealed-lattice/guides/browser-and-worker-usage](https://tenemo.github.io/sealed-lattice/guides/browser-and-worker-usage/)
70
72
  - Runtime and compatibility: [tenemo.github.io/sealed-lattice/guides/runtime-and-compatibility](https://tenemo.github.io/sealed-lattice/guides/runtime-and-compatibility/)
71
73
  - Security and non-goals: [tenemo.github.io/sealed-lattice/guides/security-and-non-goals](https://tenemo.github.io/sealed-lattice/guides/security-and-non-goals/)
72
74
  - API reference: [tenemo.github.io/sealed-lattice/api](https://tenemo.github.io/sealed-lattice/api/)
@@ -74,15 +76,11 @@ No additional public subpaths are promised yet. Future capability areas such as
74
76
  ## Development
75
77
 
76
78
  ```bash
77
- pnpm install --frozen-lockfile
78
- pnpm run vectors:core
79
- pnpm run ci
80
- ```
81
-
82
- For the current digest microbenchmark, run:
83
-
84
- ```bash
85
- pnpm run bench:micro
79
+ pnpm install
80
+ pnpm run lint
81
+ pnpm run tsc
82
+ pnpm run test
83
+ pnpm run build
86
84
  ```
87
85
 
88
86
  ## License
@@ -1,5 +1,10 @@
1
+ type SupportedCrypto = Crypto & {
2
+ subtle: SubtleCrypto;
3
+ };
4
+ export declare const getWebCrypto: () => SupportedCrypto;
1
5
  /**
2
6
  * Returns the lowercase hexadecimal SHA-256 digest of the provided text or
3
7
  * byte input.
4
8
  */
5
9
  export declare const sha256Hex: (input: string | Uint8Array) => Promise<string>;
10
+ export {};
@@ -0,0 +1,18 @@
1
+ import { bytesToHex, normalizeInputToBytes } from './bytes.js';
2
+ import { UnsupportedRuntimeError } from './errors.js';
3
+ const hasDigest = (value) => typeof value?.subtle?.digest === 'function';
4
+ export const getWebCrypto = () => {
5
+ const cryptoApi = globalThis.crypto;
6
+ if (!hasDigest(cryptoApi)) {
7
+ throw new UnsupportedRuntimeError();
8
+ }
9
+ return cryptoApi;
10
+ };
11
+ /**
12
+ * Returns the lowercase hexadecimal SHA-256 digest of the provided text or
13
+ * byte input.
14
+ */
15
+ export const sha256Hex = async (input) => {
16
+ const digest = await getWebCrypto().subtle.digest('SHA-256', normalizeInputToBytes(input));
17
+ return bytesToHex(new Uint8Array(digest));
18
+ };
@@ -5,6 +5,7 @@
5
5
  export class UnsupportedRuntimeError extends Error {
6
6
  constructor(message = 'sealed-lattice requires globalThis.crypto.subtle.digest.') {
7
7
  super(message);
8
- this.name = 'UnsupportedRuntimeError';
8
+ this.name = new.target.name;
9
+ Object.setPrototypeOf(this, new.target.prototype);
9
10
  }
10
11
  }
@@ -1,2 +1,3 @@
1
+ export { bytesToHex, normalizeInputToBytes } from './bytes.js';
2
+ export { getWebCrypto, sha256Hex } from './crypto.js';
1
3
  export { UnsupportedRuntimeError } from './errors.js';
2
- export { sha256Hex } from './sha256.js';
@@ -1,2 +1,3 @@
1
+ export { bytesToHex, normalizeInputToBytes } from './bytes.js';
2
+ export { getWebCrypto, sha256Hex } from './crypto.js';
1
3
  export { UnsupportedRuntimeError } from './errors.js';
2
- export { sha256Hex } from './sha256.js';
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './core/index.js';
1
+ export { UnsupportedRuntimeError, sha256Hex } from './core/index.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export * from './core/index.js';
1
+ export { UnsupportedRuntimeError, sha256Hex } from './core/index.js';
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "sealed-lattice",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A browser-native TypeScript package for sealed-lattice research prototypes, currently shipping a narrow SHA-256 helper while the post-quantum architecture remains intentionally unfrozen.",
5
5
  "author": "Piotr Piech <piotr@piech.dev>",
6
6
  "license": "MPL-2.0",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "imports": {
10
13
  "#root": "./src/index.ts",
11
14
  "#core": "./src/core/index.ts"
@@ -27,36 +30,28 @@
27
30
  "packageManager": "pnpm@10.33.0",
28
31
  "scripts": {
29
32
  "lint": "eslint . -c eslint.config.js",
30
- "eslint": "pnpm run lint",
31
33
  "eslint:fix": "eslint . --fix -c eslint.config.js",
32
- "typecheck": "tsc",
33
- "tsc": "pnpm run typecheck",
34
- "guard:no-math-random": "tsx ./tests/guards/check-no-math-random.ts",
35
- "verify:package-surface": "tsx ./tools/verify-package-surface.ts",
36
- "package:smoke": "tsx ./tools/verify-package-tarball.ts",
37
- "vectors:core": "tsx ./tools/generate-core-vectors.ts",
38
- "bench:micro": "tsx ./tools/benchmarks/microbench.ts",
39
- "check": "pnpm run lint && pnpm run typecheck && pnpm run guard:no-math-random && pnpm run verify:package-surface && pnpm run test",
40
- "prebuild": "pnpm run check && pnpm exec del-cli dist",
41
- "build": "tsc --project tsconfig.build.json",
42
- "build:skip": "pnpm exec del-cli dist && tsc --project tsconfig.build.json",
34
+ "tsc": "tsc",
43
35
  "test:node": "vitest --project node --run",
44
- "test:browser": "vitest --project browser --run",
36
+ "test:browser": "vitest --project browser-desktop --project browser-mobile --run",
45
37
  "test": "pnpm run test:node && pnpm run test:browser",
46
38
  "test:watch": "vitest --project node --watch",
47
39
  "coverage:node": "vitest --project node --run --coverage",
48
40
  "coverage:badge": "pnpm run coverage:node && tsx ./tools/generate-coverage-badge.ts",
49
- "verify:docs:build": "tsx ./tools/verify-docs-build.ts",
50
- "docs:ci": "pnpm run docs:api && pnpm run verify:docs && pnpm run coverage:badge && pnpm run docs:build:site && pnpm run verify:docs:build",
51
- "ci": "pnpm run check && pnpm run build:skip && pnpm run package:smoke && pnpm run docs:ci",
41
+ "smoke:pack": "tsx ./tools/ci/verify-packed-package.ts",
42
+ "smoke:pack:npm": "tsx ./tools/ci/verify-packed-package.ts --package-manager npm",
43
+ "check:node": "pnpm run lint && tsc && knip && tsx ./tools/ci/verify-vectors.ts && pnpm run test:node",
44
+ "prebuild": "pnpm run lint && tsc && knip && tsx ./tools/ci/verify-vectors.ts && pnpm run test",
45
+ "build:dist": "pnpm exec del-cli dist && tsc --project tsconfig.build.json && tsx ./tools/build/rewrite-dist-relative-imports.ts",
46
+ "build:ci": "pnpm run check:node && pnpm run build:dist",
47
+ "build": "pnpm run build:dist",
48
+ "vectors:core": "tsx ./tools/generate-core-vectors.ts",
52
49
  "docs:api": "pnpm exec del-cli docs/src/content/docs/api/reference && tsx ./node_modules/typedoc/bin/typedoc --options typedoc.config.mjs && tsx ./typedoc/postprocess-site-docs.ts",
53
50
  "docs:dev": "pnpm run docs:api && astro dev --root docs",
54
- "docs:build": "pnpm run docs:api && pnpm run docs:build:site",
55
- "docs:build:site": "astro build --root docs",
51
+ "docs:build:site": "pnpm exec del-cli docs/dist && astro build --root docs --silent",
56
52
  "docs:preview": "astro preview --root docs",
57
- "verify:docs": "tsx ./typedoc/verify-docs.ts",
58
- "prepublish:public": "pnpm run ci",
59
- "publish:public": "pnpm publish --access public",
53
+ "verify:docs": "pnpm run docs:api && tsx ./typedoc/verify-docs.ts",
54
+ "bench:micro": "tsx ./tools/benchmarks/microbench.ts",
60
55
  "prepare": "husky"
61
56
  },
62
57
  "devDependencies": {
@@ -66,30 +61,29 @@
66
61
  "@eslint/js": "^10.0.1",
67
62
  "@fontsource/ibm-plex-sans": "^5.2.8",
68
63
  "@fontsource/jetbrains-mono": "^5.2.8",
69
- "@fontsource/space-grotesk": "^5.2.10",
70
64
  "@types/node": "^25.5.2",
71
65
  "@typescript-eslint/eslint-plugin": "^8.58.1",
72
66
  "@typescript-eslint/parser": "^8.58.1",
73
- "@vitest/browser-playwright": "^4.1.3",
74
- "@vitest/coverage-v8": "^4.1.3",
67
+ "@vitest/browser-playwright": "^4.1.4",
68
+ "@vitest/coverage-v8": "^4.1.4",
75
69
  "astro": "^6.1.5",
76
70
  "del-cli": "^7.0.0",
77
71
  "eslint": "^10.2.0",
78
72
  "eslint-config-prettier": "^10.1.8",
79
- "eslint-import-resolver-typescript": "^4.4.4",
80
- "eslint-plugin-import": "^2.32.0",
73
+ "eslint-plugin-import-x": "^4.16.2",
81
74
  "eslint-plugin-only-error": "^1.0.2",
82
75
  "eslint-plugin-prettier": "^5.5.5",
83
76
  "globals": "^17.4.0",
84
77
  "husky": "^9.1.7",
78
+ "knip": "^5.67.0",
85
79
  "playwright": "^1.59.1",
86
80
  "prettier": "^3.8.1",
87
81
  "tsx": "^4.21.0",
88
82
  "typedoc": "^0.28.18",
89
83
  "typedoc-plugin-markdown": "^4.11.0",
90
84
  "typescript": "^6.0.2",
91
- "vite": "^8.0.7",
92
- "vitest": "^4.1.3"
85
+ "vite": "^8.0.8",
86
+ "vitest": "^4.1.4"
93
87
  },
94
88
  "engines": {
95
89
  "node": ">=24.14.1"
@@ -1,5 +0,0 @@
1
- type SupportedCrypto = Crypto & {
2
- subtle: SubtleCrypto;
3
- };
4
- export declare const requireWebCrypto: () => SupportedCrypto;
5
- export {};
@@ -1,9 +0,0 @@
1
- import { UnsupportedRuntimeError } from './errors.js';
2
- const hasDigest = (value) => typeof value?.subtle?.digest === 'function';
3
- export const requireWebCrypto = () => {
4
- const cryptoApi = globalThis.crypto;
5
- if (!hasDigest(cryptoApi)) {
6
- throw new UnsupportedRuntimeError();
7
- }
8
- return cryptoApi;
9
- };
@@ -1,11 +0,0 @@
1
- import { bytesToHex, normalizeInputToBytes } from './bytes.js';
2
- import { requireWebCrypto } from './runtime.js';
3
- /**
4
- * Returns the lowercase hexadecimal SHA-256 digest of the provided text or
5
- * byte input.
6
- */
7
- export const sha256Hex = async (input) => {
8
- const cryptoApi = requireWebCrypto();
9
- const digest = await cryptoApi.subtle.digest('SHA-256', normalizeInputToBytes(input));
10
- return bytesToHex(new Uint8Array(digest));
11
- };