@johnhenry/browsermesh-primitives 0.0.1 → 0.0.3

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.
Files changed (3) hide show
  1. package/README.md +23 -2
  2. package/package.json +13 -4
  3. package/src/index.d.ts +18 -0
package/README.md CHANGED
@@ -1,10 +1,31 @@
1
1
  # browsermesh-primitives
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%40johnhenry%2Fbrowsermesh-primitives.svg)](https://www.npmjs.com/package/@johnhenry/browsermesh-primitives)
4
+ [![license](https://img.shields.io/npm/l/%40johnhenry%2Fbrowsermesh-primitives.svg)](LICENSE)
5
+
3
6
  Shared primitives for browser mesh networking -- wire format, identity (Ed25519), CRDTs, capabilities, trust model, and ACL engine. Zero dependencies, pure ES modules, runs in browsers and Node.js.
4
7
 
8
+ ## Why this exists
9
+
10
+ Every other package in this monorepo needs the same handful of building blocks -- an identity to sign with, a wire format to put bytes on the network, CRDTs that merge deterministically across peers, and a shared vocabulary for "does this peer have permission to do X." Reimplementing any of those per package would mean N slightly-different Ed25519 key derivations, N incompatible wire encodings, and no guarantee that two packages' capability tokens even mean the same thing. `browsermesh-primitives` exists to be that one shared, dependency-free floor: every downstream package imports its identity, CRDT, capability, or wire-format types directly rather than rolling its own, so two peers running different BrowserMesh packages built against the same primitives version can always talk to, sign for, and verify each other. It has zero dependencies of its own on purpose -- nothing downstream should have to worry about *this* package dragging in a second copy of anything.
11
+
12
+ ## Used by
13
+
14
+ Every other package in this monorepo depends on `browsermesh-primitives` directly, or transitively through one that does:
15
+
16
+ - `@johnhenry/browsermesh-core` -- identity, keyring, ACL, and trust-graph classes wrap this package's `PodIdentity`, `MESH_TYPE`, and capability/CRDT types.
17
+ - `@johnhenry/browsermesh-discovery` -- DHT, naming, and swarm messages are tagged with this package's `MESH_TYPE` constants.
18
+ - `@johnhenry/browsermesh-pod` -- `Pod` generates its Ed25519 identity via `PodIdentity.generate()`.
19
+ - `@johnhenry/browsermesh-sync` -- `SyncDocument` is built directly on this package's `VectorClock`, `LWWRegister`, `GCounter`, `PNCounter`, `ORSet`, `RGA`, and `LWWMap` CRDT classes.
20
+ - `@johnhenry/browsermesh-transport` -- transport message/error types (`MESH_TYPE`, `MESH_ERROR`) come from here.
21
+ - `@johnhenry/browsermesh-apps` -- imports this package directly (`MESH_TYPE`, `LWWMap`, base64url helpers) alongside its required `browsermesh-sync` peer.
22
+ - `@johnhenry/browsermesh-embed` -- transitively, through its hard dependency on `browsermesh-pod`.
23
+
24
+ `browsermesh-kernel`, `browsermesh-netway`, and `browsermesh-priority-mux` are the exceptions: each is deliberately zero-dependency and imports nothing from this package.
25
+
5
26
  ## Provenance
6
27
 
7
- Previously published as `browsermesh-primitives@0.1.1`. Imported into the `@johnhenry` npm scope as part of the browsermesh monorepo consolidation; the version restarts at `0.0.0` per family convention (a new address is a new era).
28
+ Previously maintained as an independent, standalone repository and published to npm, unscoped, as `browsermesh-primitives@0.1.1` (initial release `0.1.0`, 2026-03-15), with its own CI already wired up (tests, CodeQL, dependency review). Imported into the `@johnhenry/browsermesh` monorepo via `git subtree` -- preserving its full commit history -- and rescoped to `@johnhenry/browsermesh-primitives`; the version restarts at `0.0.0` per family convention.
8
29
 
9
30
  ## Install
10
31
 
@@ -31,7 +52,7 @@ import {
31
52
  ACLEngine,
32
53
  encodeMeshMessage,
33
54
  decodeMeshMessage,
34
- } from 'browsermesh-primitives'
55
+ } from '@johnhenry/browsermesh-primitives'
35
56
 
36
57
  // Generate an Ed25519 identity
37
58
  const identity = await PodIdentity.generate()
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@johnhenry/browsermesh-primitives",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Shared primitives for browser mesh networking — wire format, identity (Ed25519), CRDTs, capabilities, trust model, and ACL engine",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
7
+ "types": "./src/index.d.ts",
7
8
  "exports": {
8
- ".": "./src/index.mjs"
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./src/index.mjs"
12
+ }
9
13
  },
10
14
  "files": [
11
15
  "src",
@@ -28,9 +32,14 @@
28
32
  },
29
33
  "homepage": "https://opensource.johnhenry.me/browsermesh/",
30
34
  "scripts": {
31
- "test": "node --test test/*.test.mjs"
35
+ "pretest": "npm run typecheck",
36
+ "test": "node --test test/*.test.mjs",
37
+ "typecheck": "tsc --noEmit -p test/tsconfig.json"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "^7.0.2"
32
41
  },
33
42
  "engines": {
34
- "node": ">=24.0.0"
43
+ "node": ">=26.0.0"
35
44
  }
36
45
  }
package/src/index.d.ts CHANGED
@@ -19,6 +19,24 @@ export declare function encodeBase64url(bytes: Uint8Array): string;
19
19
  export declare function decodeBase64url(str: string): Uint8Array;
20
20
  export declare function derivePodId(publicKey: CryptoKey): Promise<string>;
21
21
 
22
+ /**
23
+ * Probe for WebCrypto Ed25519 support by asking for a key. Resolves true or
24
+ * false, never throws, and caches the answer. Call this before
25
+ * `PodIdentity.generate()` if you need to degrade gracefully rather than
26
+ * catch a NotSupportedError from four frames down.
27
+ */
28
+ export declare function probeEd25519Support(): Promise<boolean>;
29
+
30
+ /**
31
+ * Cached answer from `probeEd25519Support()`, or `null` when the probe has
32
+ * not resolved yet. Treat `null` as "unknown"; await `probeEd25519Support()`
33
+ * for a definite answer.
34
+ */
35
+ export declare function supportsEd25519(): boolean | null;
36
+
37
+ /** Reset the cached Ed25519 probe. Tests only. */
38
+ export declare function _resetEd25519Probe(): void;
39
+
22
40
  export declare class PodIdentity {
23
41
  keyPair: CryptoKeyPair;
24
42
  podId: string;