wire-mesh-core 1.0.1 → 1.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.
@@ -1,5 +1,5 @@
1
1
  import { j as IdentityKey, v as DeviceId } from "../protocol-B26-5VX7.cjs";
2
- import { IdentityPort } from "../ports/identity.cjs";
2
+ import { t as IdentityPort } from "../identity-BRLEUfVY.cjs";
3
3
  import { webcrypto } from "node:crypto";
4
4
  //#region src/adapters/node-identity.d.ts
5
5
  export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
@@ -1,5 +1,5 @@
1
1
  import { j as IdentityKey, v as DeviceId } from "../protocol-B26-5VX7.mjs";
2
- import { IdentityPort } from "../ports/identity.mjs";
2
+ import { t as IdentityPort } from "../identity-qNkmGytv.mjs";
3
3
  import { webcrypto } from "node:crypto";
4
4
  //#region src/adapters/node-identity.d.ts
5
5
  export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
@@ -1,4 +1,4 @@
1
- import { Clock } from "../ports/clock.cjs";
1
+ import { t as Clock } from "../clock-DiSx-WKM.cjs";
2
2
  //#region src/adapters/system-clock.d.ts
3
3
  /** Wraps the system wall clock -- the only place Date.now() appears in this package. */
4
4
  export declare function createSystemClock(): Clock;
@@ -1,4 +1,4 @@
1
- import { Clock } from "../ports/clock.mjs";
1
+ import { t as Clock } from "../clock-DiSx-WKM.mjs";
2
2
  //#region src/adapters/system-clock.d.ts
3
3
  /** Wraps the system wall clock -- the only place Date.now() appears in this package. */
4
4
  export declare function createSystemClock(): Clock;
@@ -34,7 +34,7 @@ function frameReader(socket) {
34
34
  buffer = buffer.subarray(LENGTH_PREFIX_BYTES + bodyLength);
35
35
  let decoded;
36
36
  try {
37
- decoded = (0, cbor2.decode)(body, cbor2.cdeDecodeOptions);
37
+ decoded = (0, cbor2.decode)(new Uint8Array(body.buffer, body.byteOffset, body.byteLength), cbor2.cdeDecodeOptions);
38
38
  } catch (error) {
39
39
  const connectionError = error instanceof Error ? error : /* @__PURE__ */ new Error(`frame body failed to decode: ${String(error)}`);
40
40
  failAll(connectionError);
@@ -33,7 +33,7 @@ function frameReader(socket) {
33
33
  buffer = buffer.subarray(LENGTH_PREFIX_BYTES + bodyLength);
34
34
  let decoded;
35
35
  try {
36
- decoded = decode(body, cdeDecodeOptions);
36
+ decoded = decode(new Uint8Array(body.buffer, body.byteOffset, body.byteLength), cdeDecodeOptions);
37
37
  } catch (error) {
38
38
  const connectionError = error instanceof Error ? error : /* @__PURE__ */ new Error(`frame body failed to decode: ${String(error)}`);
39
39
  failAll(connectionError);
@@ -35,7 +35,7 @@ function frameReader(socket) {
35
35
  buffer = buffer.subarray(LENGTH_PREFIX_BYTES + bodyLength);
36
36
  let decoded;
37
37
  try {
38
- decoded = (0, cbor2.decode)(body, cbor2.cdeDecodeOptions);
38
+ decoded = (0, cbor2.decode)(new Uint8Array(body.buffer, body.byteOffset, body.byteLength), cbor2.cdeDecodeOptions);
39
39
  } catch (error) {
40
40
  const connectionError = error instanceof Error ? error : /* @__PURE__ */ new Error(`frame body failed to decode: ${String(error)}`);
41
41
  failAll(connectionError);
@@ -34,7 +34,7 @@ function frameReader(socket) {
34
34
  buffer = buffer.subarray(LENGTH_PREFIX_BYTES + bodyLength);
35
35
  let decoded;
36
36
  try {
37
- decoded = decode(body, cdeDecodeOptions);
37
+ decoded = decode(new Uint8Array(body.buffer, body.byteOffset, body.byteLength), cdeDecodeOptions);
38
38
  } catch (error) {
39
39
  const connectionError = error instanceof Error ? error : /* @__PURE__ */ new Error(`frame body failed to decode: ${String(error)}`);
40
40
  failAll(connectionError);
@@ -0,0 +1,7 @@
1
+ //#region src/ports/clock.d.ts
2
+ interface Clock {
3
+ /** Current time as Unix milliseconds, matching every uint timestamp field in the protocol (token-claims.expires, revocation-entry.revoked-at, handshake params, etc.). */
4
+ now: () => number;
5
+ }
6
+ //#endregion
7
+ export { Clock as t };
@@ -0,0 +1,7 @@
1
+ //#region src/ports/clock.d.ts
2
+ interface Clock {
3
+ /** Current time as Unix milliseconds, matching every uint timestamp field in the protocol (token-claims.expires, revocation-entry.revoked-at, handshake params, etc.). */
4
+ now: () => number;
5
+ }
6
+ //#endregion
7
+ export { Clock as t };
@@ -1,6 +1,6 @@
1
1
  import { F as ManageOk, M as ManageCommand, P as ManageError, U as PeerAdvert, Z as ProtocolVersion, ct as RevocationEntry, i as CapabilityToken, r as CapabilityScope, v as DeviceId, w as Frame } from "../protocol-B26-5VX7.cjs";
2
- import { IdentityPort } from "../ports/identity.cjs";
3
- import { Clock } from "../ports/clock.cjs";
2
+ import { t as IdentityPort } from "../identity-BRLEUfVY.cjs";
3
+ import { t as Clock } from "../clock-DiSx-WKM.cjs";
4
4
  import { Connection, Transport } from "../ports/transport.cjs";
5
5
  //#region src/domain/mesh-session.d.ts
6
6
  /** How long to wait for the node's handshake before calling it unanswered. A relay-only node never sends one; that is a state to display, not an error. */
@@ -1,6 +1,6 @@
1
1
  import { F as ManageOk, M as ManageCommand, P as ManageError, U as PeerAdvert, Z as ProtocolVersion, ct as RevocationEntry, i as CapabilityToken, r as CapabilityScope, v as DeviceId, w as Frame } from "../protocol-B26-5VX7.mjs";
2
- import { IdentityPort } from "../ports/identity.mjs";
3
- import { Clock } from "../ports/clock.mjs";
2
+ import { t as IdentityPort } from "../identity-qNkmGytv.mjs";
3
+ import { t as Clock } from "../clock-DiSx-WKM.mjs";
4
4
  import { Connection, Transport } from "../ports/transport.mjs";
5
5
  //#region src/domain/mesh-session.d.ts
6
6
  /** How long to wait for the node's handshake before calling it unanswered. A relay-only node never sends one; that is a state to display, not an error. */
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_domain_device_id = require("./device-id.cjs");
3
+ const require_domain_tokens = require("./tokens.cjs");
4
+ //#region src/domain/revocation-view.ts
5
+ function revocationKey(tokenId, issuer) {
6
+ return `${require_domain_device_id.bytesToHex(tokenId)}:${require_domain_device_id.deviceIdToHex(issuer)}`;
7
+ }
8
+ function createRevocationView() {
9
+ const revoked = /* @__PURE__ */ new Set();
10
+ return {
11
+ async isRevoked(tokenId, issuer) {
12
+ return Promise.resolve(revoked.has(revocationKey(tokenId, issuer)));
13
+ },
14
+ async record(entry, options) {
15
+ const verdict = await require_domain_tokens.verifyRevocationEntry(entry, options);
16
+ if (verdict.ok) revoked.add(revocationKey(verdict.claims["token-id"], verdict.claims.issuer));
17
+ return verdict;
18
+ }
19
+ };
20
+ }
21
+ //#endregion
22
+ exports.createRevocationView = createRevocationView;
@@ -0,0 +1,12 @@
1
+ import { ct as RevocationEntry } from "../protocol-B26-5VX7.cjs";
2
+ import { RevocationCheck, RevocationEntryVerdict, VerifyRevocationEntryOptions } from "./tokens.cjs";
3
+ //#region src/domain/revocation-view.d.ts
4
+ /**
5
+ * An in-memory RevocationCheck fed by ingested revocation-announce frames. Keyed by (token-id, issuer) per management.cddl's contract: an entry counts against a token only when both match, so a third party's entry for someone else's token-id is stored (it is a well-formed, self-certifying entry) but never matches a lookup for the token it does not actually govern.
6
+ */
7
+ export interface RevocationView extends RevocationCheck {
8
+ /** Verifies one gossiped revocation-entry via verifyRevocationEntry and, if it verifies, records it. An entry that fails verification is dropped, not stored -- the returned verdict lets a caller log or otherwise report the refusal. */
9
+ record: (entry: RevocationEntry, options: VerifyRevocationEntryOptions) => Promise<RevocationEntryVerdict>;
10
+ }
11
+ export declare function createRevocationView(): RevocationView;
12
+ //#endregion
@@ -0,0 +1,12 @@
1
+ import { ct as RevocationEntry } from "../protocol-B26-5VX7.mjs";
2
+ import { RevocationCheck, RevocationEntryVerdict, VerifyRevocationEntryOptions } from "./tokens.mjs";
3
+ //#region src/domain/revocation-view.d.ts
4
+ /**
5
+ * An in-memory RevocationCheck fed by ingested revocation-announce frames. Keyed by (token-id, issuer) per management.cddl's contract: an entry counts against a token only when both match, so a third party's entry for someone else's token-id is stored (it is a well-formed, self-certifying entry) but never matches a lookup for the token it does not actually govern.
6
+ */
7
+ export interface RevocationView extends RevocationCheck {
8
+ /** Verifies one gossiped revocation-entry via verifyRevocationEntry and, if it verifies, records it. An entry that fails verification is dropped, not stored -- the returned verdict lets a caller log or otherwise report the refusal. */
9
+ record: (entry: RevocationEntry, options: VerifyRevocationEntryOptions) => Promise<RevocationEntryVerdict>;
10
+ }
11
+ export declare function createRevocationView(): RevocationView;
12
+ //#endregion
@@ -0,0 +1,21 @@
1
+ import { bytesToHex, deviceIdToHex } from "./device-id.mjs";
2
+ import { verifyRevocationEntry } from "./tokens.mjs";
3
+ //#region src/domain/revocation-view.ts
4
+ function revocationKey(tokenId, issuer) {
5
+ return `${bytesToHex(tokenId)}:${deviceIdToHex(issuer)}`;
6
+ }
7
+ function createRevocationView() {
8
+ const revoked = /* @__PURE__ */ new Set();
9
+ return {
10
+ async isRevoked(tokenId, issuer) {
11
+ return Promise.resolve(revoked.has(revocationKey(tokenId, issuer)));
12
+ },
13
+ async record(entry, options) {
14
+ const verdict = await verifyRevocationEntry(entry, options);
15
+ if (verdict.ok) revoked.add(revocationKey(verdict.claims["token-id"], verdict.claims.issuer));
16
+ return verdict;
17
+ }
18
+ };
19
+ }
20
+ //#endregion
21
+ export { createRevocationView };
@@ -1,6 +1,6 @@
1
1
  import { Et as TokenClaims, ct as RevocationEntry, i as CapabilityToken, st as RevocationClaims, v as DeviceId } from "../protocol-B26-5VX7.cjs";
2
- import { IdentityPort } from "../ports/identity.cjs";
3
- import { Clock } from "../ports/clock.cjs";
2
+ import { t as IdentityPort } from "../identity-BRLEUfVY.cjs";
3
+ import { t as Clock } from "../clock-DiSx-WKM.cjs";
4
4
  //#region src/domain/tokens.d.ts
5
5
  /**
6
6
  * The revocation view a verifier consults. Contract per management.cddl: an entry counts against a token only when BOTH its token-id and its issuer match the token's own -- only a token's own issuer may revoke it, so a third party's entry for someone else's token-id must be ignored. Implementations ingest gossiped revocation-announce frames via verifyRevocationEntry (which enforces each entry's own signature and self-certification) and key the resulting claims by token-id + issuer.
@@ -1,6 +1,6 @@
1
1
  import { Et as TokenClaims, ct as RevocationEntry, i as CapabilityToken, st as RevocationClaims, v as DeviceId } from "../protocol-B26-5VX7.mjs";
2
- import { IdentityPort } from "../ports/identity.mjs";
3
- import { Clock } from "../ports/clock.mjs";
2
+ import { t as IdentityPort } from "../identity-qNkmGytv.mjs";
3
+ import { t as Clock } from "../clock-DiSx-WKM.mjs";
4
4
  //#region src/domain/tokens.d.ts
5
5
  /**
6
6
  * The revocation view a verifier consults. Contract per management.cddl: an entry counts against a token only when BOTH its token-id and its issuer match the token's own -- only a token's own issuer may revoke it, so a third party's entry for someone else's token-id must be ignored. Implementations ingest gossiped revocation-announce frames via verifyRevocationEntry (which enforces each entry's own signature and self-certification) and key the resulting claims by token-id + issuer.
@@ -0,0 +1,17 @@
1
+ import { j as IdentityKey, v as DeviceId } from "./protocol-B26-5VX7.cjs";
2
+ //#region src/ports/identity.d.ts
3
+ /**
4
+ * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
+ */
6
+ interface IdentityPort {
7
+ readonly deviceId: DeviceId;
8
+ readonly identityKey: IdentityKey;
9
+ /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
+ sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
+ /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
+ verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
+ /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
+ deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
+ }
16
+ //#endregion
17
+ export { IdentityPort as t };
@@ -0,0 +1,17 @@
1
+ import { j as IdentityKey, v as DeviceId } from "./protocol-B26-5VX7.mjs";
2
+ //#region src/ports/identity.d.ts
3
+ /**
4
+ * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
+ */
6
+ interface IdentityPort {
7
+ readonly deviceId: DeviceId;
8
+ readonly identityKey: IdentityKey;
9
+ /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
+ sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
+ /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
+ verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
+ /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
+ deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
+ }
16
+ //#endregion
17
+ export { IdentityPort as t };
@@ -1,6 +1,2 @@
1
- //#region src/ports/clock.d.ts
2
- export interface Clock {
3
- /** Current time as Unix milliseconds, matching every uint timestamp field in the protocol (token-claims.expires, revocation-entry.revoked-at, handshake params, etc.). */
4
- now: () => number;
5
- }
6
- //#endregion
1
+ import { t as Clock } from "../clock-DiSx-WKM.cjs";
2
+ export { Clock };
@@ -1,6 +1,2 @@
1
- //#region src/ports/clock.d.ts
2
- export interface Clock {
3
- /** Current time as Unix milliseconds, matching every uint timestamp field in the protocol (token-claims.expires, revocation-entry.revoked-at, handshake params, etc.). */
4
- now: () => number;
5
- }
6
- //#endregion
1
+ import { t as Clock } from "../clock-DiSx-WKM.mjs";
2
+ export { Clock };
@@ -1,16 +1,2 @@
1
- import { j as IdentityKey, v as DeviceId } from "../protocol-B26-5VX7.cjs";
2
- //#region src/ports/identity.d.ts
3
- /**
4
- * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
- */
6
- export interface IdentityPort {
7
- readonly deviceId: DeviceId;
8
- readonly identityKey: IdentityKey;
9
- /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
- sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
- /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
- verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
- /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
- deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
- }
16
- //#endregion
1
+ import { t as IdentityPort } from "../identity-BRLEUfVY.cjs";
2
+ export { IdentityPort };
@@ -1,16 +1,2 @@
1
- import { j as IdentityKey, v as DeviceId } from "../protocol-B26-5VX7.mjs";
2
- //#region src/ports/identity.d.ts
3
- /**
4
- * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
- */
6
- export interface IdentityPort {
7
- readonly deviceId: DeviceId;
8
- readonly identityKey: IdentityKey;
9
- /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
- sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
- /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
- verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
- /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
- deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
- }
16
- //#endregion
1
+ import { t as IdentityPort } from "../identity-qNkmGytv.mjs";
2
+ export { IdentityPort };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wire-mesh-core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "repository": {
@@ -96,6 +96,10 @@
96
96
  "import": "./dist/domain/relay-hub.mjs",
97
97
  "require": "./dist/domain/relay-hub.cjs"
98
98
  },
99
+ "./domain/revocation-view": {
100
+ "import": "./dist/domain/revocation-view.mjs",
101
+ "require": "./dist/domain/revocation-view.cjs"
102
+ },
99
103
  "./domain/tokens": {
100
104
  "import": "./dist/domain/tokens.mjs",
101
105
  "require": "./dist/domain/tokens.cjs"