@nextera.one/axis-server-sdk 2.1.6 → 2.1.8

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.
@@ -0,0 +1,10 @@
1
+ type Axis1FrameToEncode = {
2
+ ver: number;
3
+ flags: number;
4
+ hdr: Buffer;
5
+ body: Buffer;
6
+ sig: Buffer;
7
+ };
8
+ declare function encodeAxis1Frame(f: Axis1FrameToEncode): Buffer;
9
+
10
+ export { type Axis1FrameToEncode, encodeAxis1Frame };
@@ -0,0 +1,10 @@
1
+ type Axis1FrameToEncode = {
2
+ ver: number;
3
+ flags: number;
4
+ hdr: Buffer;
5
+ body: Buffer;
6
+ sig: Buffer;
7
+ };
8
+ declare function encodeAxis1Frame(f: Axis1FrameToEncode): Buffer;
9
+
10
+ export { type Axis1FrameToEncode, encodeAxis1Frame };
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/codec/axis1.encode.ts
20
+ var axis1_encode_exports = {};
21
+ __export(axis1_encode_exports, {
22
+ encodeAxis1Frame: () => encodeAxis1Frame
23
+ });
24
+ module.exports = __toCommonJS(axis1_encode_exports);
25
+ var import_axis_protocol = require("@nextera.one/axis-protocol");
26
+
27
+ // src/codec/tlv.encode.ts
28
+ function encVarint(x) {
29
+ if (x < 0n) throw new Error("VARINT_NEG");
30
+ const out = [];
31
+ while (x >= 0x80n) {
32
+ out.push(Number(x & 0x7fn | 0x80n));
33
+ x >>= 7n;
34
+ }
35
+ out.push(Number(x));
36
+ return Buffer.from(out);
37
+ }
38
+
39
+ // src/codec/axis1.encode.ts
40
+ var MAGIC = Buffer.from(import_axis_protocol.AXIS_MAGIC);
41
+ function encodeAxis1Frame(f) {
42
+ if (!Buffer.isBuffer(f.hdr) || !Buffer.isBuffer(f.body) || !Buffer.isBuffer(f.sig)) {
43
+ throw new Error("AXIS1_BAD_BUFFERS");
44
+ }
45
+ if (f.ver !== import_axis_protocol.AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
46
+ const hdrLen = encVarint(BigInt(f.hdr.length));
47
+ const bodyLen = encVarint(BigInt(f.body.length));
48
+ const sigLen = encVarint(BigInt(f.sig.length));
49
+ return Buffer.concat([
50
+ MAGIC,
51
+ Buffer.from([f.ver & 255]),
52
+ Buffer.from([f.flags & 255]),
53
+ hdrLen,
54
+ bodyLen,
55
+ sigLen,
56
+ f.hdr,
57
+ f.body,
58
+ f.sig
59
+ ]);
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ encodeAxis1Frame
64
+ });
65
+ //# sourceMappingURL=axis1.encode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codec/axis1.encode.ts","../../src/codec/tlv.encode.ts"],"sourcesContent":["// axis1.encode.ts\nimport { AXIS_MAGIC, AXIS_VERSION } from '@nextera.one/axis-protocol';\n\nimport { encVarint } from './tlv.encode';\n\nconst MAGIC = Buffer.from(AXIS_MAGIC);\n\nexport type Axis1FrameToEncode = {\n ver: number; // 1\n flags: number; // bit flags\n hdr: Buffer; // TLVs\n body: Buffer; // TLVs or raw payload\n sig: Buffer; // signature bytes\n};\n\nexport function encodeAxis1Frame(f: Axis1FrameToEncode): Buffer {\n if (\n !Buffer.isBuffer(f.hdr) ||\n !Buffer.isBuffer(f.body) ||\n !Buffer.isBuffer(f.sig)\n ) {\n throw new Error('AXIS1_BAD_BUFFERS');\n }\n if (f.ver !== AXIS_VERSION) throw new Error('AXIS1_BAD_VER');\n\n const hdrLen = encVarint(BigInt(f.hdr.length));\n const bodyLen = encVarint(BigInt(f.body.length));\n const sigLen = encVarint(BigInt(f.sig.length));\n\n return Buffer.concat([\n MAGIC,\n Buffer.from([f.ver & 0xff]),\n Buffer.from([f.flags & 0xff]),\n hdrLen,\n bodyLen,\n sigLen,\n f.hdr,\n f.body,\n f.sig,\n ]);\n}\n","// tlv.encode.ts\nimport { randomBytes } from 'crypto';\n\nexport function encVarint(x: bigint): Buffer {\n if (x < 0n) throw new Error('VARINT_NEG');\n const out: number[] = [];\n while (x >= 0x80n) {\n out.push(Number((x & 0x7fn) | 0x80n));\n x >>= 7n;\n }\n out.push(Number(x));\n return Buffer.from(out);\n}\n\nexport function varintU(x: number | bigint): Buffer {\n const v = typeof x === 'number' ? BigInt(x) : x;\n return encVarint(v);\n}\n\nexport function u64be(x: bigint): Buffer {\n if (x < 0n) throw new Error('U64_NEG');\n const b = Buffer.alloc(8);\n b.writeBigUInt64BE(x, 0);\n return b;\n}\n\nexport function utf8(s: string): Buffer {\n return Buffer.from(s, 'utf8');\n}\n\nexport function bytes(b: Uint8Array | Buffer): Buffer {\n return Buffer.isBuffer(b) ? b : Buffer.from(b);\n}\n\nexport function nonce16(): Buffer {\n return randomBytes(16);\n}\n\nexport function tlv(type: number, value: Buffer): Buffer {\n if (!Number.isSafeInteger(type) || type < 0) throw new Error('TLV_BAD_TYPE');\n return Buffer.concat([\n encVarint(BigInt(type)),\n encVarint(BigInt(value.length)),\n value,\n ]);\n}\n\n/**\n * Canonical TLV encoding:\n * - sorted by type ascending\n * - no duplicates by default\n */\nexport function buildTLVs(\n items: { type: number; value: Buffer }[],\n opts?: { allowDupTypes?: Set<number> },\n): Buffer {\n const allow = opts?.allowDupTypes ?? new Set<number>();\n const sorted = [...items].sort((a, b) => a.type - b.type);\n\n for (let i = 1; i < sorted.length; i++) {\n if (sorted[i].type === sorted[i - 1].type && !allow.has(sorted[i].type)) {\n throw new Error(`TLV_DUP_TYPE_${sorted[i].type}`);\n }\n }\n\n return Buffer.concat(sorted.map((it) => tlv(it.type, it.value)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAAyC;;;ACElC,SAAS,UAAU,GAAmB;AAC3C,MAAI,IAAI,GAAI,OAAM,IAAI,MAAM,YAAY;AACxC,QAAM,MAAgB,CAAC;AACvB,SAAO,KAAK,OAAO;AACjB,QAAI,KAAK,OAAQ,IAAI,QAAS,KAAK,CAAC;AACpC,UAAM;AAAA,EACR;AACA,MAAI,KAAK,OAAO,CAAC,CAAC;AAClB,SAAO,OAAO,KAAK,GAAG;AACxB;;;ADPA,IAAM,QAAQ,OAAO,KAAK,+BAAU;AAU7B,SAAS,iBAAiB,GAA+B;AAC9D,MACE,CAAC,OAAO,SAAS,EAAE,GAAG,KACtB,CAAC,OAAO,SAAS,EAAE,IAAI,KACvB,CAAC,OAAO,SAAS,EAAE,GAAG,GACtB;AACA,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AACA,MAAI,EAAE,QAAQ,kCAAc,OAAM,IAAI,MAAM,eAAe;AAE3D,QAAM,SAAS,UAAU,OAAO,EAAE,IAAI,MAAM,CAAC;AAC7C,QAAM,UAAU,UAAU,OAAO,EAAE,KAAK,MAAM,CAAC;AAC/C,QAAM,SAAS,UAAU,OAAO,EAAE,IAAI,MAAM,CAAC;AAE7C,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,OAAO,KAAK,CAAC,EAAE,MAAM,GAAI,CAAC;AAAA,IAC1B,OAAO,KAAK,CAAC,EAAE,QAAQ,GAAI,CAAC;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE;AAAA,IACF,EAAE;AAAA,IACF,EAAE;AAAA,EACJ,CAAC;AACH;","names":[]}
@@ -0,0 +1,41 @@
1
+ // src/codec/axis1.encode.ts
2
+ import { AXIS_MAGIC, AXIS_VERSION } from "@nextera.one/axis-protocol";
3
+
4
+ // src/codec/tlv.encode.ts
5
+ function encVarint(x) {
6
+ if (x < 0n) throw new Error("VARINT_NEG");
7
+ const out = [];
8
+ while (x >= 0x80n) {
9
+ out.push(Number(x & 0x7fn | 0x80n));
10
+ x >>= 7n;
11
+ }
12
+ out.push(Number(x));
13
+ return Buffer.from(out);
14
+ }
15
+
16
+ // src/codec/axis1.encode.ts
17
+ var MAGIC = Buffer.from(AXIS_MAGIC);
18
+ function encodeAxis1Frame(f) {
19
+ if (!Buffer.isBuffer(f.hdr) || !Buffer.isBuffer(f.body) || !Buffer.isBuffer(f.sig)) {
20
+ throw new Error("AXIS1_BAD_BUFFERS");
21
+ }
22
+ if (f.ver !== AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
23
+ const hdrLen = encVarint(BigInt(f.hdr.length));
24
+ const bodyLen = encVarint(BigInt(f.body.length));
25
+ const sigLen = encVarint(BigInt(f.sig.length));
26
+ return Buffer.concat([
27
+ MAGIC,
28
+ Buffer.from([f.ver & 255]),
29
+ Buffer.from([f.flags & 255]),
30
+ hdrLen,
31
+ bodyLen,
32
+ sigLen,
33
+ f.hdr,
34
+ f.body,
35
+ f.sig
36
+ ]);
37
+ }
38
+ export {
39
+ encodeAxis1Frame
40
+ };
41
+ //# sourceMappingURL=axis1.encode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codec/axis1.encode.ts","../../src/codec/tlv.encode.ts"],"sourcesContent":["// axis1.encode.ts\nimport { AXIS_MAGIC, AXIS_VERSION } from '@nextera.one/axis-protocol';\n\nimport { encVarint } from './tlv.encode';\n\nconst MAGIC = Buffer.from(AXIS_MAGIC);\n\nexport type Axis1FrameToEncode = {\n ver: number; // 1\n flags: number; // bit flags\n hdr: Buffer; // TLVs\n body: Buffer; // TLVs or raw payload\n sig: Buffer; // signature bytes\n};\n\nexport function encodeAxis1Frame(f: Axis1FrameToEncode): Buffer {\n if (\n !Buffer.isBuffer(f.hdr) ||\n !Buffer.isBuffer(f.body) ||\n !Buffer.isBuffer(f.sig)\n ) {\n throw new Error('AXIS1_BAD_BUFFERS');\n }\n if (f.ver !== AXIS_VERSION) throw new Error('AXIS1_BAD_VER');\n\n const hdrLen = encVarint(BigInt(f.hdr.length));\n const bodyLen = encVarint(BigInt(f.body.length));\n const sigLen = encVarint(BigInt(f.sig.length));\n\n return Buffer.concat([\n MAGIC,\n Buffer.from([f.ver & 0xff]),\n Buffer.from([f.flags & 0xff]),\n hdrLen,\n bodyLen,\n sigLen,\n f.hdr,\n f.body,\n f.sig,\n ]);\n}\n","// tlv.encode.ts\nimport { randomBytes } from 'crypto';\n\nexport function encVarint(x: bigint): Buffer {\n if (x < 0n) throw new Error('VARINT_NEG');\n const out: number[] = [];\n while (x >= 0x80n) {\n out.push(Number((x & 0x7fn) | 0x80n));\n x >>= 7n;\n }\n out.push(Number(x));\n return Buffer.from(out);\n}\n\nexport function varintU(x: number | bigint): Buffer {\n const v = typeof x === 'number' ? BigInt(x) : x;\n return encVarint(v);\n}\n\nexport function u64be(x: bigint): Buffer {\n if (x < 0n) throw new Error('U64_NEG');\n const b = Buffer.alloc(8);\n b.writeBigUInt64BE(x, 0);\n return b;\n}\n\nexport function utf8(s: string): Buffer {\n return Buffer.from(s, 'utf8');\n}\n\nexport function bytes(b: Uint8Array | Buffer): Buffer {\n return Buffer.isBuffer(b) ? b : Buffer.from(b);\n}\n\nexport function nonce16(): Buffer {\n return randomBytes(16);\n}\n\nexport function tlv(type: number, value: Buffer): Buffer {\n if (!Number.isSafeInteger(type) || type < 0) throw new Error('TLV_BAD_TYPE');\n return Buffer.concat([\n encVarint(BigInt(type)),\n encVarint(BigInt(value.length)),\n value,\n ]);\n}\n\n/**\n * Canonical TLV encoding:\n * - sorted by type ascending\n * - no duplicates by default\n */\nexport function buildTLVs(\n items: { type: number; value: Buffer }[],\n opts?: { allowDupTypes?: Set<number> },\n): Buffer {\n const allow = opts?.allowDupTypes ?? new Set<number>();\n const sorted = [...items].sort((a, b) => a.type - b.type);\n\n for (let i = 1; i < sorted.length; i++) {\n if (sorted[i].type === sorted[i - 1].type && !allow.has(sorted[i].type)) {\n throw new Error(`TLV_DUP_TYPE_${sorted[i].type}`);\n }\n }\n\n return Buffer.concat(sorted.map((it) => tlv(it.type, it.value)));\n}\n"],"mappings":";AACA,SAAS,YAAY,oBAAoB;;;ACElC,SAAS,UAAU,GAAmB;AAC3C,MAAI,IAAI,GAAI,OAAM,IAAI,MAAM,YAAY;AACxC,QAAM,MAAgB,CAAC;AACvB,SAAO,KAAK,OAAO;AACjB,QAAI,KAAK,OAAQ,IAAI,QAAS,KAAK,CAAC;AACpC,UAAM;AAAA,EACR;AACA,MAAI,KAAK,OAAO,CAAC,CAAC;AAClB,SAAO,OAAO,KAAK,GAAG;AACxB;;;ADPA,IAAM,QAAQ,OAAO,KAAK,UAAU;AAU7B,SAAS,iBAAiB,GAA+B;AAC9D,MACE,CAAC,OAAO,SAAS,EAAE,GAAG,KACtB,CAAC,OAAO,SAAS,EAAE,IAAI,KACvB,CAAC,OAAO,SAAS,EAAE,GAAG,GACtB;AACA,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AACA,MAAI,EAAE,QAAQ,aAAc,OAAM,IAAI,MAAM,eAAe;AAE3D,QAAM,SAAS,UAAU,OAAO,EAAE,IAAI,MAAM,CAAC;AAC7C,QAAM,UAAU,UAAU,OAAO,EAAE,KAAK,MAAM,CAAC;AAC/C,QAAM,SAAS,UAAU,OAAO,EAAE,IAAI,MAAM,CAAC;AAE7C,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,OAAO,KAAK,CAAC,EAAE,MAAM,GAAI,CAAC;AAAA,IAC1B,OAAO,KAAK,CAAC,EAAE,QAAQ,GAAI,CAAC;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE;AAAA,IACF,EAAE;AAAA,IACF,EAAE;AAAA,EACJ,CAAC;AACH;","names":[]}
@@ -0,0 +1,8 @@
1
+ declare function axis1SigningBytes(params: {
2
+ ver: number;
3
+ flags: number;
4
+ hdr: Buffer;
5
+ body: Buffer;
6
+ }): Buffer;
7
+
8
+ export { axis1SigningBytes };
@@ -0,0 +1,8 @@
1
+ declare function axis1SigningBytes(params: {
2
+ ver: number;
3
+ flags: number;
4
+ hdr: Buffer;
5
+ body: Buffer;
6
+ }): Buffer;
7
+
8
+ export { axis1SigningBytes };
@@ -0,0 +1,61 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/codec/axis1.signing.ts
20
+ var axis1_signing_exports = {};
21
+ __export(axis1_signing_exports, {
22
+ axis1SigningBytes: () => axis1SigningBytes
23
+ });
24
+ module.exports = __toCommonJS(axis1_signing_exports);
25
+ var import_axis_protocol = require("@nextera.one/axis-protocol");
26
+
27
+ // src/codec/tlv.encode.ts
28
+ function encVarint(x) {
29
+ if (x < 0n) throw new Error("VARINT_NEG");
30
+ const out = [];
31
+ while (x >= 0x80n) {
32
+ out.push(Number(x & 0x7fn | 0x80n));
33
+ x >>= 7n;
34
+ }
35
+ out.push(Number(x));
36
+ return Buffer.from(out);
37
+ }
38
+
39
+ // src/codec/axis1.signing.ts
40
+ var MAGIC = Buffer.from(import_axis_protocol.AXIS_MAGIC);
41
+ function axis1SigningBytes(params) {
42
+ if (params.ver !== import_axis_protocol.AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
43
+ const hdrLen = encVarint(BigInt(params.hdr.length));
44
+ const bodyLen = encVarint(BigInt(params.body.length));
45
+ const sigLenZero = encVarint(0n);
46
+ return Buffer.concat([
47
+ MAGIC,
48
+ Buffer.from([params.ver & 255]),
49
+ Buffer.from([params.flags & 255]),
50
+ hdrLen,
51
+ bodyLen,
52
+ sigLenZero,
53
+ params.hdr,
54
+ params.body
55
+ ]);
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ axis1SigningBytes
60
+ });
61
+ //# sourceMappingURL=axis1.signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codec/axis1.signing.ts","../../src/codec/tlv.encode.ts"],"sourcesContent":["// axis1.signing.ts\nimport { AXIS_MAGIC, AXIS_VERSION } from '@nextera.one/axis-protocol';\n\nimport { encVarint } from './tlv.encode';\n\nconst MAGIC = Buffer.from(AXIS_MAGIC);\n\nexport function axis1SigningBytes(params: {\n ver: number;\n flags: number;\n hdr: Buffer;\n body: Buffer;\n}): Buffer {\n if (params.ver !== AXIS_VERSION) throw new Error('AXIS1_BAD_VER');\n const hdrLen = encVarint(BigInt(params.hdr.length));\n const bodyLen = encVarint(BigInt(params.body.length));\n const sigLenZero = encVarint(0n); // IMPORTANT: sigLen=0 in signing bytes\n\n return Buffer.concat([\n MAGIC,\n Buffer.from([params.ver & 0xff]),\n Buffer.from([params.flags & 0xff]),\n hdrLen,\n bodyLen,\n sigLenZero,\n params.hdr,\n params.body,\n ]);\n}\n","// tlv.encode.ts\nimport { randomBytes } from 'crypto';\n\nexport function encVarint(x: bigint): Buffer {\n if (x < 0n) throw new Error('VARINT_NEG');\n const out: number[] = [];\n while (x >= 0x80n) {\n out.push(Number((x & 0x7fn) | 0x80n));\n x >>= 7n;\n }\n out.push(Number(x));\n return Buffer.from(out);\n}\n\nexport function varintU(x: number | bigint): Buffer {\n const v = typeof x === 'number' ? BigInt(x) : x;\n return encVarint(v);\n}\n\nexport function u64be(x: bigint): Buffer {\n if (x < 0n) throw new Error('U64_NEG');\n const b = Buffer.alloc(8);\n b.writeBigUInt64BE(x, 0);\n return b;\n}\n\nexport function utf8(s: string): Buffer {\n return Buffer.from(s, 'utf8');\n}\n\nexport function bytes(b: Uint8Array | Buffer): Buffer {\n return Buffer.isBuffer(b) ? b : Buffer.from(b);\n}\n\nexport function nonce16(): Buffer {\n return randomBytes(16);\n}\n\nexport function tlv(type: number, value: Buffer): Buffer {\n if (!Number.isSafeInteger(type) || type < 0) throw new Error('TLV_BAD_TYPE');\n return Buffer.concat([\n encVarint(BigInt(type)),\n encVarint(BigInt(value.length)),\n value,\n ]);\n}\n\n/**\n * Canonical TLV encoding:\n * - sorted by type ascending\n * - no duplicates by default\n */\nexport function buildTLVs(\n items: { type: number; value: Buffer }[],\n opts?: { allowDupTypes?: Set<number> },\n): Buffer {\n const allow = opts?.allowDupTypes ?? new Set<number>();\n const sorted = [...items].sort((a, b) => a.type - b.type);\n\n for (let i = 1; i < sorted.length; i++) {\n if (sorted[i].type === sorted[i - 1].type && !allow.has(sorted[i].type)) {\n throw new Error(`TLV_DUP_TYPE_${sorted[i].type}`);\n }\n }\n\n return Buffer.concat(sorted.map((it) => tlv(it.type, it.value)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAAyC;;;ACElC,SAAS,UAAU,GAAmB;AAC3C,MAAI,IAAI,GAAI,OAAM,IAAI,MAAM,YAAY;AACxC,QAAM,MAAgB,CAAC;AACvB,SAAO,KAAK,OAAO;AACjB,QAAI,KAAK,OAAQ,IAAI,QAAS,KAAK,CAAC;AACpC,UAAM;AAAA,EACR;AACA,MAAI,KAAK,OAAO,CAAC,CAAC;AAClB,SAAO,OAAO,KAAK,GAAG;AACxB;;;ADPA,IAAM,QAAQ,OAAO,KAAK,+BAAU;AAE7B,SAAS,kBAAkB,QAKvB;AACT,MAAI,OAAO,QAAQ,kCAAc,OAAM,IAAI,MAAM,eAAe;AAChE,QAAM,SAAS,UAAU,OAAO,OAAO,IAAI,MAAM,CAAC;AAClD,QAAM,UAAU,UAAU,OAAO,OAAO,KAAK,MAAM,CAAC;AACpD,QAAM,aAAa,UAAU,EAAE;AAE/B,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,OAAO,KAAK,CAAC,OAAO,MAAM,GAAI,CAAC;AAAA,IAC/B,OAAO,KAAK,CAAC,OAAO,QAAQ,GAAI,CAAC;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EACT,CAAC;AACH;","names":[]}
@@ -0,0 +1,37 @@
1
+ // src/codec/axis1.signing.ts
2
+ import { AXIS_MAGIC, AXIS_VERSION } from "@nextera.one/axis-protocol";
3
+
4
+ // src/codec/tlv.encode.ts
5
+ function encVarint(x) {
6
+ if (x < 0n) throw new Error("VARINT_NEG");
7
+ const out = [];
8
+ while (x >= 0x80n) {
9
+ out.push(Number(x & 0x7fn | 0x80n));
10
+ x >>= 7n;
11
+ }
12
+ out.push(Number(x));
13
+ return Buffer.from(out);
14
+ }
15
+
16
+ // src/codec/axis1.signing.ts
17
+ var MAGIC = Buffer.from(AXIS_MAGIC);
18
+ function axis1SigningBytes(params) {
19
+ if (params.ver !== AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
20
+ const hdrLen = encVarint(BigInt(params.hdr.length));
21
+ const bodyLen = encVarint(BigInt(params.body.length));
22
+ const sigLenZero = encVarint(0n);
23
+ return Buffer.concat([
24
+ MAGIC,
25
+ Buffer.from([params.ver & 255]),
26
+ Buffer.from([params.flags & 255]),
27
+ hdrLen,
28
+ bodyLen,
29
+ sigLenZero,
30
+ params.hdr,
31
+ params.body
32
+ ]);
33
+ }
34
+ export {
35
+ axis1SigningBytes
36
+ };
37
+ //# sourceMappingURL=axis1.signing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codec/axis1.signing.ts","../../src/codec/tlv.encode.ts"],"sourcesContent":["// axis1.signing.ts\nimport { AXIS_MAGIC, AXIS_VERSION } from '@nextera.one/axis-protocol';\n\nimport { encVarint } from './tlv.encode';\n\nconst MAGIC = Buffer.from(AXIS_MAGIC);\n\nexport function axis1SigningBytes(params: {\n ver: number;\n flags: number;\n hdr: Buffer;\n body: Buffer;\n}): Buffer {\n if (params.ver !== AXIS_VERSION) throw new Error('AXIS1_BAD_VER');\n const hdrLen = encVarint(BigInt(params.hdr.length));\n const bodyLen = encVarint(BigInt(params.body.length));\n const sigLenZero = encVarint(0n); // IMPORTANT: sigLen=0 in signing bytes\n\n return Buffer.concat([\n MAGIC,\n Buffer.from([params.ver & 0xff]),\n Buffer.from([params.flags & 0xff]),\n hdrLen,\n bodyLen,\n sigLenZero,\n params.hdr,\n params.body,\n ]);\n}\n","// tlv.encode.ts\nimport { randomBytes } from 'crypto';\n\nexport function encVarint(x: bigint): Buffer {\n if (x < 0n) throw new Error('VARINT_NEG');\n const out: number[] = [];\n while (x >= 0x80n) {\n out.push(Number((x & 0x7fn) | 0x80n));\n x >>= 7n;\n }\n out.push(Number(x));\n return Buffer.from(out);\n}\n\nexport function varintU(x: number | bigint): Buffer {\n const v = typeof x === 'number' ? BigInt(x) : x;\n return encVarint(v);\n}\n\nexport function u64be(x: bigint): Buffer {\n if (x < 0n) throw new Error('U64_NEG');\n const b = Buffer.alloc(8);\n b.writeBigUInt64BE(x, 0);\n return b;\n}\n\nexport function utf8(s: string): Buffer {\n return Buffer.from(s, 'utf8');\n}\n\nexport function bytes(b: Uint8Array | Buffer): Buffer {\n return Buffer.isBuffer(b) ? b : Buffer.from(b);\n}\n\nexport function nonce16(): Buffer {\n return randomBytes(16);\n}\n\nexport function tlv(type: number, value: Buffer): Buffer {\n if (!Number.isSafeInteger(type) || type < 0) throw new Error('TLV_BAD_TYPE');\n return Buffer.concat([\n encVarint(BigInt(type)),\n encVarint(BigInt(value.length)),\n value,\n ]);\n}\n\n/**\n * Canonical TLV encoding:\n * - sorted by type ascending\n * - no duplicates by default\n */\nexport function buildTLVs(\n items: { type: number; value: Buffer }[],\n opts?: { allowDupTypes?: Set<number> },\n): Buffer {\n const allow = opts?.allowDupTypes ?? new Set<number>();\n const sorted = [...items].sort((a, b) => a.type - b.type);\n\n for (let i = 1; i < sorted.length; i++) {\n if (sorted[i].type === sorted[i - 1].type && !allow.has(sorted[i].type)) {\n throw new Error(`TLV_DUP_TYPE_${sorted[i].type}`);\n }\n }\n\n return Buffer.concat(sorted.map((it) => tlv(it.type, it.value)));\n}\n"],"mappings":";AACA,SAAS,YAAY,oBAAoB;;;ACElC,SAAS,UAAU,GAAmB;AAC3C,MAAI,IAAI,GAAI,OAAM,IAAI,MAAM,YAAY;AACxC,QAAM,MAAgB,CAAC;AACvB,SAAO,KAAK,OAAO;AACjB,QAAI,KAAK,OAAQ,IAAI,QAAS,KAAK,CAAC;AACpC,UAAM;AAAA,EACR;AACA,MAAI,KAAK,OAAO,CAAC,CAAC;AAClB,SAAO,OAAO,KAAK,GAAG;AACxB;;;ADPA,IAAM,QAAQ,OAAO,KAAK,UAAU;AAE7B,SAAS,kBAAkB,QAKvB;AACT,MAAI,OAAO,QAAQ,aAAc,OAAM,IAAI,MAAM,eAAe;AAChE,QAAM,SAAS,UAAU,OAAO,OAAO,IAAI,MAAM,CAAC;AAClD,QAAM,UAAU,UAAU,OAAO,OAAO,KAAK,MAAM,CAAC;AACpD,QAAM,aAAa,UAAU,EAAE;AAE/B,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,OAAO,KAAK,CAAC,OAAO,MAAM,GAAI,CAAC;AAAA,IAC/B,OAAO,KAAK,CAAC,OAAO,QAAQ,GAAI,CAAC;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EACT,CAAC;AACH;","names":[]}
@@ -1,3 +1,3 @@
1
- export { a as AxisBinaryFrame, b as AxisError, A as AxisFrame, c as AxisFrameZ, d as AxisMediaTypes, e as computeReceiptHash, f as computeSignaturePayload, g as decodeFrame, h as encodeFrame, j as generateEd25519KeyPair, k as getSignTarget, s as sha256, l as signFrame, v as verifyFrameSignature } from '../index-DXHfWxLG.mjs';
2
- export { AXIS_MAGIC, AXIS_VERSION, BodyProfile, ERR_BAD_SIGNATURE, ERR_CONTRACT_VIOLATION, ERR_INVALID_PACKET, ERR_REPLAY_DETECTED, FLAG_BODY_TLV, FLAG_CHAIN_REQ, FLAG_HAS_WITNESS, MAX_BODY_LEN, MAX_FRAME_LEN, MAX_HDR_LEN, MAX_SIG_LEN, NCERT_ALG, NCERT_EXP, NCERT_ISSUER_KID, NCERT_KID, NCERT_NBF, NCERT_NODE_ID, NCERT_PAYLOAD, NCERT_PUB, NCERT_SCOPE, NCERT_SIG, PROOF_CAPSULE, PROOF_JWT, PROOF_LOOM, PROOF_MTLS, PROOF_NONE, PROOF_WITNESS, ProofType, TLV, TLV_ACTOR_ID, TLV_AUD, TLV_BODY_ARR, TLV_BODY_OBJ, TLV_CAPSULE, TLV_EFFECT, TLV_ERROR_CODE, TLV_ERROR_MSG, TLV_INDEX, TLV_INTENT, TLV_KID, TLV_LOOM_PRESENCE_ID, TLV_LOOM_THREAD_HASH, TLV_LOOM_WRIT, TLV_NODE, TLV_NODE_CERT_HASH, TLV_NODE_KID, TLV_NONCE, TLV_OFFSET, TLV_OK, TLV_PID, TLV_PREV_HASH, TLV_PROOF_REF, TLV_PROOF_TYPE, TLV_REALM, TLV_RECEIPT_HASH, TLV_RID, TLV_SHA256_CHUNK, TLV_TRACE_ID, TLV_TS, TLV_UPLOAD_ID, decodeArray, decodeObject, decodeTLVs, decodeTLVsList, decodeVarint, encodeTLVs, encodeVarint, varintLength } from '@nextera.one/axis-protocol';
1
+ export * from '@nextera.one/axis-protocol';
2
+ export { A as AxisError, a as AxisFrameZ, c as computeReceiptHash, b as computeSignaturePayload, g as generateEd25519KeyPair, s as sha256, d as signFrame, v as verifyFrameSignature } from '../index-VxXqZPuH.mjs';
3
3
  import 'zod';
@@ -1,3 +1,3 @@
1
- export { a as AxisBinaryFrame, b as AxisError, A as AxisFrame, c as AxisFrameZ, d as AxisMediaTypes, e as computeReceiptHash, f as computeSignaturePayload, g as decodeFrame, h as encodeFrame, j as generateEd25519KeyPair, k as getSignTarget, s as sha256, l as signFrame, v as verifyFrameSignature } from '../index-DXHfWxLG.js';
2
- export { AXIS_MAGIC, AXIS_VERSION, BodyProfile, ERR_BAD_SIGNATURE, ERR_CONTRACT_VIOLATION, ERR_INVALID_PACKET, ERR_REPLAY_DETECTED, FLAG_BODY_TLV, FLAG_CHAIN_REQ, FLAG_HAS_WITNESS, MAX_BODY_LEN, MAX_FRAME_LEN, MAX_HDR_LEN, MAX_SIG_LEN, NCERT_ALG, NCERT_EXP, NCERT_ISSUER_KID, NCERT_KID, NCERT_NBF, NCERT_NODE_ID, NCERT_PAYLOAD, NCERT_PUB, NCERT_SCOPE, NCERT_SIG, PROOF_CAPSULE, PROOF_JWT, PROOF_LOOM, PROOF_MTLS, PROOF_NONE, PROOF_WITNESS, ProofType, TLV, TLV_ACTOR_ID, TLV_AUD, TLV_BODY_ARR, TLV_BODY_OBJ, TLV_CAPSULE, TLV_EFFECT, TLV_ERROR_CODE, TLV_ERROR_MSG, TLV_INDEX, TLV_INTENT, TLV_KID, TLV_LOOM_PRESENCE_ID, TLV_LOOM_THREAD_HASH, TLV_LOOM_WRIT, TLV_NODE, TLV_NODE_CERT_HASH, TLV_NODE_KID, TLV_NONCE, TLV_OFFSET, TLV_OK, TLV_PID, TLV_PREV_HASH, TLV_PROOF_REF, TLV_PROOF_TYPE, TLV_REALM, TLV_RECEIPT_HASH, TLV_RID, TLV_SHA256_CHUNK, TLV_TRACE_ID, TLV_TS, TLV_UPLOAD_ID, decodeArray, decodeObject, decodeTLVs, decodeTLVsList, decodeVarint, encodeTLVs, encodeVarint, varintLength } from '@nextera.one/axis-protocol';
1
+ export * from '@nextera.one/axis-protocol';
2
+ export { A as AxisError, a as AxisFrameZ, c as computeReceiptHash, b as computeSignaturePayload, g as generateEd25519KeyPair, s as sha256, d as signFrame, v as verifyFrameSignature } from '../index-VxXqZPuH.js';
3
3
  import 'zod';
@@ -16,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
21
  // If the importer is in node compatibility mode or this is not an ESM
21
22
  // file that has been converted to a CommonJS file using a Babel-
@@ -29,124 +30,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
30
  // src/core/index.ts
30
31
  var core_exports = {};
31
32
  __export(core_exports, {
32
- AXIS_MAGIC: () => import_axis_protocol.AXIS_MAGIC,
33
- AXIS_VERSION: () => import_axis_protocol.AXIS_VERSION,
34
33
  AxisError: () => AxisError,
35
34
  AxisFrameZ: () => AxisFrameZ,
36
- AxisMediaTypes: () => AxisMediaTypes,
37
- BodyProfile: () => import_axis_protocol.BodyProfile,
38
- ERR_BAD_SIGNATURE: () => import_axis_protocol.ERR_BAD_SIGNATURE,
39
- ERR_CONTRACT_VIOLATION: () => import_axis_protocol.ERR_CONTRACT_VIOLATION,
40
- ERR_INVALID_PACKET: () => import_axis_protocol.ERR_INVALID_PACKET,
41
- ERR_REPLAY_DETECTED: () => import_axis_protocol.ERR_REPLAY_DETECTED,
42
- FLAG_BODY_TLV: () => import_axis_protocol.FLAG_BODY_TLV,
43
- FLAG_CHAIN_REQ: () => import_axis_protocol.FLAG_CHAIN_REQ,
44
- FLAG_HAS_WITNESS: () => import_axis_protocol.FLAG_HAS_WITNESS,
45
- MAX_BODY_LEN: () => import_axis_protocol.MAX_BODY_LEN,
46
- MAX_FRAME_LEN: () => import_axis_protocol.MAX_FRAME_LEN,
47
- MAX_HDR_LEN: () => import_axis_protocol.MAX_HDR_LEN,
48
- MAX_SIG_LEN: () => import_axis_protocol.MAX_SIG_LEN,
49
- NCERT_ALG: () => import_axis_protocol.NCERT_ALG,
50
- NCERT_EXP: () => import_axis_protocol.NCERT_EXP,
51
- NCERT_ISSUER_KID: () => import_axis_protocol.NCERT_ISSUER_KID,
52
- NCERT_KID: () => import_axis_protocol.NCERT_KID,
53
- NCERT_NBF: () => import_axis_protocol.NCERT_NBF,
54
- NCERT_NODE_ID: () => import_axis_protocol.NCERT_NODE_ID,
55
- NCERT_PAYLOAD: () => import_axis_protocol.NCERT_PAYLOAD,
56
- NCERT_PUB: () => import_axis_protocol.NCERT_PUB,
57
- NCERT_SCOPE: () => import_axis_protocol.NCERT_SCOPE,
58
- NCERT_SIG: () => import_axis_protocol.NCERT_SIG,
59
- PROOF_CAPSULE: () => import_axis_protocol.PROOF_CAPSULE,
60
- PROOF_JWT: () => import_axis_protocol.PROOF_JWT,
61
- PROOF_LOOM: () => import_axis_protocol.PROOF_LOOM,
62
- PROOF_MTLS: () => import_axis_protocol.PROOF_MTLS,
63
- PROOF_NONE: () => import_axis_protocol.PROOF_NONE,
64
- PROOF_WITNESS: () => import_axis_protocol.PROOF_WITNESS,
65
- ProofType: () => import_axis_protocol.ProofType,
66
- TLV: () => import_axis_protocol3.TLV,
67
- TLV_ACTOR_ID: () => import_axis_protocol.TLV_ACTOR_ID,
68
- TLV_AUD: () => import_axis_protocol.TLV_AUD,
69
- TLV_BODY_ARR: () => import_axis_protocol.TLV_BODY_ARR,
70
- TLV_BODY_OBJ: () => import_axis_protocol.TLV_BODY_OBJ,
71
- TLV_CAPSULE: () => import_axis_protocol.TLV_CAPSULE,
72
- TLV_EFFECT: () => import_axis_protocol.TLV_EFFECT,
73
- TLV_ERROR_CODE: () => import_axis_protocol.TLV_ERROR_CODE,
74
- TLV_ERROR_MSG: () => import_axis_protocol.TLV_ERROR_MSG,
75
- TLV_INDEX: () => import_axis_protocol.TLV_INDEX,
76
- TLV_INTENT: () => import_axis_protocol.TLV_INTENT,
77
- TLV_KID: () => import_axis_protocol.TLV_KID,
78
- TLV_LOOM_PRESENCE_ID: () => import_axis_protocol.TLV_LOOM_PRESENCE_ID,
79
- TLV_LOOM_THREAD_HASH: () => import_axis_protocol.TLV_LOOM_THREAD_HASH,
80
- TLV_LOOM_WRIT: () => import_axis_protocol.TLV_LOOM_WRIT,
81
- TLV_NODE: () => import_axis_protocol.TLV_NODE,
82
- TLV_NODE_CERT_HASH: () => import_axis_protocol.TLV_NODE_CERT_HASH,
83
- TLV_NODE_KID: () => import_axis_protocol.TLV_NODE_KID,
84
- TLV_NONCE: () => import_axis_protocol.TLV_NONCE,
85
- TLV_OFFSET: () => import_axis_protocol.TLV_OFFSET,
86
- TLV_OK: () => import_axis_protocol.TLV_OK,
87
- TLV_PID: () => import_axis_protocol.TLV_PID,
88
- TLV_PREV_HASH: () => import_axis_protocol.TLV_PREV_HASH,
89
- TLV_PROOF_REF: () => import_axis_protocol.TLV_PROOF_REF,
90
- TLV_PROOF_TYPE: () => import_axis_protocol.TLV_PROOF_TYPE,
91
- TLV_REALM: () => import_axis_protocol.TLV_REALM,
92
- TLV_RECEIPT_HASH: () => import_axis_protocol.TLV_RECEIPT_HASH,
93
- TLV_RID: () => import_axis_protocol.TLV_RID,
94
- TLV_SHA256_CHUNK: () => import_axis_protocol.TLV_SHA256_CHUNK,
95
- TLV_TRACE_ID: () => import_axis_protocol.TLV_TRACE_ID,
96
- TLV_TS: () => import_axis_protocol.TLV_TS,
97
- TLV_UPLOAD_ID: () => import_axis_protocol.TLV_UPLOAD_ID,
98
35
  computeReceiptHash: () => computeReceiptHash,
99
36
  computeSignaturePayload: () => computeSignaturePayload,
100
- decodeArray: () => import_axis_protocol3.decodeArray,
101
- decodeFrame: () => decodeFrame,
102
- decodeObject: () => import_axis_protocol3.decodeObject,
103
- decodeTLVs: () => import_axis_protocol3.decodeTLVs,
104
- decodeTLVsList: () => import_axis_protocol3.decodeTLVsList,
105
- decodeVarint: () => import_axis_protocol2.decodeVarint,
106
- encodeFrame: () => encodeFrame,
107
- encodeTLVs: () => import_axis_protocol3.encodeTLVs,
108
- encodeVarint: () => import_axis_protocol2.encodeVarint,
109
37
  generateEd25519KeyPair: () => generateEd25519KeyPair,
110
- getSignTarget: () => getSignTarget,
111
38
  sha256: () => sha256,
112
39
  signFrame: () => signFrame,
113
- varintLength: () => import_axis_protocol2.varintLength,
114
40
  verifyFrameSignature: () => verifyFrameSignature
115
41
  });
116
42
  module.exports = __toCommonJS(core_exports);
117
-
118
- // src/core/constants.ts
119
- var import_axis_protocol = require("@nextera.one/axis-protocol");
120
- var _AxisMediaTypes = class _AxisMediaTypes {
121
- static normalize(value) {
122
- if (!value) return void 0;
123
- return value.split(";", 1)[0].trim().toLowerCase();
124
- }
125
- static isAxisContentType(value) {
126
- const normalized = _AxisMediaTypes.normalize(value);
127
- return !!normalized && _AxisMediaTypes.VALID_AXIS_CONTENT_TYPES.some(
128
- (contentType) => contentType === normalized
129
- );
130
- }
131
- };
132
- _AxisMediaTypes.BINARY = "application/axis-bin";
133
- _AxisMediaTypes.OCTET_STREAM = "application/octet-stream";
134
- _AxisMediaTypes.LEGACY_BINARY = "application/x-axis";
135
- _AxisMediaTypes.VALID_AXIS_CONTENT_TYPES = [
136
- _AxisMediaTypes.BINARY,
137
- _AxisMediaTypes.OCTET_STREAM,
138
- _AxisMediaTypes.LEGACY_BINARY
139
- ];
140
- var AxisMediaTypes = _AxisMediaTypes;
141
-
142
- // src/core/varint.ts
143
- var import_axis_protocol2 = require("@nextera.one/axis-protocol");
144
-
145
- // src/core/tlv.ts
146
- var import_axis_protocol3 = require("@nextera.one/axis-protocol");
43
+ __reExport(core_exports, require("@nextera.one/axis-protocol"), module.exports);
147
44
 
148
45
  // src/core/axis-bin.ts
149
46
  var z = __toESM(require("zod"));
47
+ var import_axis_protocol = require("@nextera.one/axis-protocol");
150
48
  var AxisFrameZ = z.object({
151
49
  /** Flag bits for protocol control (e.g., encryption, compression) */
152
50
  flags: z.number().int().nonnegative(),
@@ -160,96 +58,11 @@ var AxisFrameZ = z.object({
160
58
  /** The cryptographic signature covering the frame (except the signature itself) */
161
59
  sig: z.custom((v) => v instanceof Uint8Array)
162
60
  });
163
- function encodeFrame(frame) {
164
- const hdrBytes = (0, import_axis_protocol3.encodeTLVs)(
165
- Array.from(frame.headers.entries()).map(([t, v]) => ({
166
- type: t,
167
- value: v
168
- }))
169
- );
170
- if (hdrBytes.length > import_axis_protocol.MAX_HDR_LEN) throw new Error("Header too large");
171
- if (frame.body.length > import_axis_protocol.MAX_BODY_LEN) throw new Error("Body too large");
172
- if (frame.sig.length > import_axis_protocol.MAX_SIG_LEN) throw new Error("Signature too large");
173
- const hdrLenBytes = (0, import_axis_protocol2.encodeVarint)(hdrBytes.length);
174
- const bodyLenBytes = (0, import_axis_protocol2.encodeVarint)(frame.body.length);
175
- const sigLenBytes = (0, import_axis_protocol2.encodeVarint)(frame.sig.length);
176
- const totalLen = 5 + // Magic (AXIS1)
177
- 1 + // Version
178
- 1 + // Flags
179
- hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
180
- if (totalLen > import_axis_protocol.MAX_FRAME_LEN) throw new Error("Total frame too large");
181
- const buf = new Uint8Array(totalLen);
182
- let offset = 0;
183
- buf.set(import_axis_protocol.AXIS_MAGIC, offset);
184
- offset += 5;
185
- buf[offset++] = import_axis_protocol.AXIS_VERSION;
186
- buf[offset++] = frame.flags;
187
- buf.set(hdrLenBytes, offset);
188
- offset += hdrLenBytes.length;
189
- buf.set(bodyLenBytes, offset);
190
- offset += bodyLenBytes.length;
191
- buf.set(sigLenBytes, offset);
192
- offset += sigLenBytes.length;
193
- buf.set(hdrBytes, offset);
194
- offset += hdrBytes.length;
195
- buf.set(frame.body, offset);
196
- offset += frame.body.length;
197
- buf.set(frame.sig, offset);
198
- offset += frame.sig.length;
199
- return buf;
200
- }
201
- function decodeFrame(buf) {
202
- let offset = 0;
203
- if (offset + 5 > buf.length) throw new Error("Packet too short");
204
- for (let i = 0; i < 5; i++) {
205
- if (buf[offset + i] !== import_axis_protocol.AXIS_MAGIC[i]) throw new Error("Invalid Magic");
206
- }
207
- offset += 5;
208
- const ver = buf[offset++];
209
- if (ver !== import_axis_protocol.AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
210
- const flags = buf[offset++];
211
- const { value: hdrLen, length: hlLen } = (0, import_axis_protocol2.decodeVarint)(buf, offset);
212
- offset += hlLen;
213
- if (hdrLen > import_axis_protocol.MAX_HDR_LEN) throw new Error("Header limit exceeded");
214
- const { value: bodyLen, length: blLen } = (0, import_axis_protocol2.decodeVarint)(buf, offset);
215
- offset += blLen;
216
- if (bodyLen > import_axis_protocol.MAX_BODY_LEN) throw new Error("Body limit exceeded");
217
- const { value: sigLen, length: slLen } = (0, import_axis_protocol2.decodeVarint)(buf, offset);
218
- offset += slLen;
219
- if (sigLen > import_axis_protocol.MAX_SIG_LEN) throw new Error("Signature limit exceeded");
220
- if (offset + hdrLen + bodyLen + sigLen > buf.length) {
221
- throw new Error("Frame truncated");
222
- }
223
- const hdrBytes = buf.slice(offset, offset + hdrLen);
224
- offset += hdrLen;
225
- const bodyBytes = buf.slice(offset, offset + bodyLen);
226
- offset += bodyLen;
227
- const sigBytes = buf.slice(offset, offset + sigLen);
228
- offset += sigLen;
229
- const headers = (0, import_axis_protocol3.decodeTLVs)(hdrBytes);
230
- return {
231
- flags,
232
- headers,
233
- body: bodyBytes,
234
- sig: sigBytes
235
- };
236
- }
237
- function getSignTarget(frame) {
238
- return encodeFrame({
239
- ...frame,
240
- sig: new Uint8Array(0)
241
- });
242
- }
243
61
 
244
62
  // src/core/signature.ts
245
63
  var crypto = __toESM(require("crypto"));
246
64
  function computeSignaturePayload(frame) {
247
- const frameWithoutSig = {
248
- ...frame,
249
- sig: new Uint8Array(0)
250
- };
251
- const encoded = encodeFrame(frameWithoutSig);
252
- return Buffer.from(encoded);
65
+ return Buffer.from((0, import_axis_protocol.getSignTarget)(frame));
253
66
  }
254
67
  function signFrame(frame, privateKey) {
255
68
  const payload = computeSignaturePayload(frame);
@@ -372,88 +185,14 @@ var AxisError = class extends Error {
372
185
  };
373
186
  // Annotate the CommonJS export names for ESM import in node:
374
187
  0 && (module.exports = {
375
- AXIS_MAGIC,
376
- AXIS_VERSION,
377
188
  AxisError,
378
189
  AxisFrameZ,
379
- AxisMediaTypes,
380
- BodyProfile,
381
- ERR_BAD_SIGNATURE,
382
- ERR_CONTRACT_VIOLATION,
383
- ERR_INVALID_PACKET,
384
- ERR_REPLAY_DETECTED,
385
- FLAG_BODY_TLV,
386
- FLAG_CHAIN_REQ,
387
- FLAG_HAS_WITNESS,
388
- MAX_BODY_LEN,
389
- MAX_FRAME_LEN,
390
- MAX_HDR_LEN,
391
- MAX_SIG_LEN,
392
- NCERT_ALG,
393
- NCERT_EXP,
394
- NCERT_ISSUER_KID,
395
- NCERT_KID,
396
- NCERT_NBF,
397
- NCERT_NODE_ID,
398
- NCERT_PAYLOAD,
399
- NCERT_PUB,
400
- NCERT_SCOPE,
401
- NCERT_SIG,
402
- PROOF_CAPSULE,
403
- PROOF_JWT,
404
- PROOF_LOOM,
405
- PROOF_MTLS,
406
- PROOF_NONE,
407
- PROOF_WITNESS,
408
- ProofType,
409
- TLV,
410
- TLV_ACTOR_ID,
411
- TLV_AUD,
412
- TLV_BODY_ARR,
413
- TLV_BODY_OBJ,
414
- TLV_CAPSULE,
415
- TLV_EFFECT,
416
- TLV_ERROR_CODE,
417
- TLV_ERROR_MSG,
418
- TLV_INDEX,
419
- TLV_INTENT,
420
- TLV_KID,
421
- TLV_LOOM_PRESENCE_ID,
422
- TLV_LOOM_THREAD_HASH,
423
- TLV_LOOM_WRIT,
424
- TLV_NODE,
425
- TLV_NODE_CERT_HASH,
426
- TLV_NODE_KID,
427
- TLV_NONCE,
428
- TLV_OFFSET,
429
- TLV_OK,
430
- TLV_PID,
431
- TLV_PREV_HASH,
432
- TLV_PROOF_REF,
433
- TLV_PROOF_TYPE,
434
- TLV_REALM,
435
- TLV_RECEIPT_HASH,
436
- TLV_RID,
437
- TLV_SHA256_CHUNK,
438
- TLV_TRACE_ID,
439
- TLV_TS,
440
- TLV_UPLOAD_ID,
441
190
  computeReceiptHash,
442
191
  computeSignaturePayload,
443
- decodeArray,
444
- decodeFrame,
445
- decodeObject,
446
- decodeTLVs,
447
- decodeTLVsList,
448
- decodeVarint,
449
- encodeFrame,
450
- encodeTLVs,
451
- encodeVarint,
452
192
  generateEd25519KeyPair,
453
- getSignTarget,
454
193
  sha256,
455
194
  signFrame,
456
- varintLength,
457
- verifyFrameSignature
195
+ verifyFrameSignature,
196
+ ...require("@nextera.one/axis-protocol")
458
197
  });
459
198
  //# sourceMappingURL=index.js.map