@avatarsd-llc/libtracer 0.11.0 → 0.12.0
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/dist/codec.d.mts +15 -3
- package/dist/codec.mjs +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/wire.d.ts +1 -1
- package/dist/wire.js +1 -1
- package/package.json +1 -1
package/dist/codec.d.mts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief True for either bound-path code — the two types whose body is a fixed-stride 8-byte
|
|
3
|
+
* element array rather than a self-describing payload (RFC-0024 §4.2, §7.1 amendment 2).
|
|
4
|
+
*
|
|
5
|
+
* `0x15` sits adjacent to `0x14` so this stays one masked compare on the per-TLV parse path.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} typeB the TLV's type byte
|
|
8
|
+
* @returns {boolean} true when the bound-path body shape rules apply (RFC-0024 §4.2/§4.3)
|
|
9
|
+
*/
|
|
10
|
+
export function isPathRefType(typeB: number): boolean;
|
|
1
11
|
/**
|
|
2
12
|
* @brief CRC-32C (Castagnoli): reflected poly 0x82F63B78, init/xor 0xFFFFFFFF.
|
|
3
13
|
*
|
|
@@ -78,9 +88,10 @@ export type TYPE = number;
|
|
|
78
88
|
* 0x0E SPEC is the in-band vertex-creation spec. 0x0F FWD and 0x10 FIELD are the
|
|
79
89
|
* remote-operation frames (RFC-0004 / ADR-0035, the v1 fast-track range
|
|
80
90
|
* 0x0F-0x1F). All are structured (opt.PL=1) and handled generically by the codec.
|
|
81
|
-
* 0x14 PATH_REF is the bound-path address form (RFC-0024 §4) and
|
|
82
|
-
*
|
|
83
|
-
*
|
|
91
|
+
* 0x14 PATH_REF is the bound-path address form (RFC-0024 §4) and 0x15
|
|
92
|
+
* PATH_REF_REVERSE the reverse-direction list a mint-flagged request accumulates
|
|
93
|
+
* (§7.1 amendment 2) — the two exceptions: their body is a bare fixed-stride
|
|
94
|
+
* 8-byte record array (opt.PL=0), so the decoder checks their shape by type.
|
|
84
95
|
*
|
|
85
96
|
* @readonly
|
|
86
97
|
* @enum {number}
|
|
@@ -102,6 +113,7 @@ export const TYPE: Readonly<{
|
|
|
102
113
|
FWD: 15;
|
|
103
114
|
FIELD: 16;
|
|
104
115
|
PATH_REF: 20;
|
|
116
|
+
PATH_REF_REVERSE: 21;
|
|
105
117
|
}>;
|
|
106
118
|
/** @brief The `PATH_REF` element stride — 8 bytes, `(u32 index, u32 generation)` LE (RFC-0024 §4.4). */
|
|
107
119
|
export const PATH_REF_ELEMENT_BYTES: 8;
|
package/dist/codec.mjs
CHANGED
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
* 0x0E SPEC is the in-band vertex-creation spec. 0x0F FWD and 0x10 FIELD are the
|
|
23
23
|
* remote-operation frames (RFC-0004 / ADR-0035, the v1 fast-track range
|
|
24
24
|
* 0x0F-0x1F). All are structured (opt.PL=1) and handled generically by the codec.
|
|
25
|
-
* 0x14 PATH_REF is the bound-path address form (RFC-0024 §4) and
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* 0x14 PATH_REF is the bound-path address form (RFC-0024 §4) and 0x15
|
|
26
|
+
* PATH_REF_REVERSE the reverse-direction list a mint-flagged request accumulates
|
|
27
|
+
* (§7.1 amendment 2) — the two exceptions: their body is a bare fixed-stride
|
|
28
|
+
* 8-byte record array (opt.PL=0), so the decoder checks their shape by type.
|
|
28
29
|
*
|
|
29
30
|
* @readonly
|
|
30
31
|
* @enum {number}
|
|
@@ -46,7 +47,20 @@ export const TYPE = Object.freeze({
|
|
|
46
47
|
FWD: 0x0f,
|
|
47
48
|
FIELD: 0x10,
|
|
48
49
|
PATH_REF: 0x14,
|
|
50
|
+
PATH_REF_REVERSE: 0x15,
|
|
49
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* @brief True for either bound-path code — the two types whose body is a fixed-stride 8-byte
|
|
54
|
+
* element array rather than a self-describing payload (RFC-0024 §4.2, §7.1 amendment 2).
|
|
55
|
+
*
|
|
56
|
+
* `0x15` sits adjacent to `0x14` so this stays one masked compare on the per-TLV parse path.
|
|
57
|
+
*
|
|
58
|
+
* @param {number} typeB the TLV's type byte
|
|
59
|
+
* @returns {boolean} true when the bound-path body shape rules apply (RFC-0024 §4.2/§4.3)
|
|
60
|
+
*/
|
|
61
|
+
export function isPathRefType(typeB) {
|
|
62
|
+
return (typeB & 0xfe) === TYPE.PATH_REF;
|
|
63
|
+
}
|
|
50
64
|
/** @brief The `PATH_REF` element stride — 8 bytes, `(u32 index, u32 generation)` LE (RFC-0024 §4.4). */
|
|
51
65
|
export const PATH_REF_ELEMENT_BYTES = 8;
|
|
52
66
|
/** @brief The `PATH_REF` element-count bound — 255 elements / 2040 body bytes (RFC-0024 §4.3). */
|
|
@@ -326,7 +340,7 @@ function parseOne(buf) {
|
|
|
326
340
|
// The one per-type structural rule (RFC-0024 §4.2/§4.3), through the single predicate
|
|
327
341
|
// encode() now shares — see pathRefBodyValid for the four clauses and why they are shape
|
|
328
342
|
// rather than meaning.
|
|
329
|
-
if (typeB
|
|
343
|
+
if (isPathRefType(typeB) && !pathRefBodyValid(opt.pl, opt.ll, length)) {
|
|
330
344
|
throw new CodecError(ERROR.FRAME_INVALID);
|
|
331
345
|
}
|
|
332
346
|
const tsSize = opt.ts ? (opt.tf ? 4 : 8) : 0;
|
|
@@ -451,7 +465,7 @@ export function encode(tlv) {
|
|
|
451
465
|
// The emitted type byte is `type & 0xff` (below), so the guard reads the byte the wire will
|
|
452
466
|
// actually carry. A PATH_REF body is never structured, so `payload` IS the body length: an
|
|
453
467
|
// opt.PL PATH_REF fails the PL clause before the children branch below ever runs.
|
|
454
|
-
if ((tlv.type & 0xff)
|
|
468
|
+
if (isPathRefType(tlv.type & 0xff) &&
|
|
455
469
|
!pathRefBodyValid(tlv.opt.pl, tlv.opt.ll, tlv.payload.length)) {
|
|
456
470
|
return new Uint8Array(0);
|
|
457
471
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare const SPEC_VERSION: 1;
|
|
|
12
12
|
* (core/src/frame.cpp), gated by the shared conformance vectors. Re-exported
|
|
13
13
|
* from ./wire.ts (the subpath entry).
|
|
14
14
|
*/
|
|
15
|
-
export { TYPE, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './wire.js';
|
|
15
|
+
export { TYPE, isPathRefType, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './wire.js';
|
|
16
16
|
export type { Opt, Timestamp, Crc, Trailer, Tlv } from './wire.js';
|
package/dist/index.js
CHANGED
|
@@ -14,4 +14,4 @@ export const SPEC_VERSION = 1;
|
|
|
14
14
|
* (core/src/frame.cpp), gated by the shared conformance vectors. Re-exported
|
|
15
15
|
* from ./wire.ts (the subpath entry).
|
|
16
16
|
*/
|
|
17
|
-
export { TYPE, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './wire.js';
|
|
17
|
+
export { TYPE, isPathRefType, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './wire.js';
|
package/dist/wire.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* L0/L1/L4 subpaths (./mem, ./view, ./graph) are reserved for when those layers
|
|
8
8
|
* land in TS — see docs/adr/0033-npm-subpackage-monorepo.md.
|
|
9
9
|
*/
|
|
10
|
-
export { TYPE, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './codec.mjs';
|
|
10
|
+
export { TYPE, isPathRefType, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './codec.mjs';
|
|
11
11
|
export type { Opt, Timestamp, Crc, Trailer, Tlv } from './codec.mjs';
|
package/dist/wire.js
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* L0/L1/L4 subpaths (./mem, ./view, ./graph) are reserved for when those layers
|
|
10
10
|
* land in TS — see docs/adr/0033-npm-subpackage-monorepo.md.
|
|
11
11
|
*/
|
|
12
|
-
export { TYPE, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './codec.mjs';
|
|
12
|
+
export { TYPE, isPathRefType, PATH_REF_ELEMENT_BYTES, MAX_PATH_REF_ELEMENTS, ERROR, CodecError, decode, encode, equal, crc32c, crc16ccitt, } from './codec.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avatarsd-llc/libtracer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "TypeScript core for libtracer — a lightweight decentralized graph-based networking protocol. Native pure-TS implementation (in-process codec; no transports), conformance-gated against the shared vectors.",
|
|
5
5
|
"author": "avatarsd LLC",
|
|
6
6
|
"license": "Apache-2.0",
|