@nextera.one/axis-server-sdk 1.1.0 → 1.2.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/index.js CHANGED
@@ -39,9 +39,9 @@ var index_exports = {};
39
39
  __export(index_exports, {
40
40
  ATS1_HDR: () => ATS1_HDR,
41
41
  ATS1_SCHEMA: () => ATS1_SCHEMA,
42
- AXIS_MAGIC: () => AXIS_MAGIC,
42
+ AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
43
43
  AXIS_OPCODES: () => AXIS_OPCODES,
44
- AXIS_VERSION: () => AXIS_VERSION,
44
+ AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
45
45
  Ats1Codec: () => ats1_exports,
46
46
  AxisFrameZ: () => AxisFrameZ,
47
47
  AxisIdDto: () => AxisIdDto,
@@ -49,21 +49,21 @@ __export(index_exports, {
49
49
  AxisPartialType: () => AxisPartialType,
50
50
  AxisResponseDto: () => AxisResponseDto,
51
51
  AxisTlvDto: () => AxisTlvDto,
52
- BodyProfile: () => BodyProfile,
52
+ BodyProfile: () => import_axis_protocol2.BodyProfile,
53
53
  CAPABILITIES: () => CAPABILITIES,
54
54
  ContractViolationError: () => ContractViolationError,
55
55
  DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
56
56
  DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
57
57
  Decision: () => Decision,
58
- ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
59
- ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
60
- ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
61
- ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
58
+ ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
59
+ ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
60
+ ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
61
+ ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
62
62
  ExecutionMeter: () => ExecutionMeter,
63
63
  FALLBACK_CONTRACT: () => FALLBACK_CONTRACT,
64
- FLAG_BODY_TLV: () => FLAG_BODY_TLV,
65
- FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
66
- FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
64
+ FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
65
+ FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
66
+ FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
67
67
  HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
68
68
  Handler: () => Handler,
69
69
  INTENT_METADATA_KEY: () => INTENT_METADATA_KEY,
@@ -74,28 +74,28 @@ __export(index_exports, {
74
74
  Intent: () => Intent,
75
75
  IntentRouter: () => IntentRouter,
76
76
  IntentSensitivity: () => IntentSensitivity,
77
- MAX_BODY_LEN: () => MAX_BODY_LEN,
78
- MAX_FRAME_LEN: () => MAX_FRAME_LEN,
79
- MAX_HDR_LEN: () => MAX_HDR_LEN,
80
- MAX_SIG_LEN: () => MAX_SIG_LEN,
81
- NCERT_ALG: () => NCERT_ALG,
82
- NCERT_EXP: () => NCERT_EXP,
83
- NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
84
- NCERT_KID: () => NCERT_KID,
85
- NCERT_NBF: () => NCERT_NBF,
86
- NCERT_NODE_ID: () => NCERT_NODE_ID,
87
- NCERT_PAYLOAD: () => NCERT_PAYLOAD,
88
- NCERT_PUB: () => NCERT_PUB,
89
- NCERT_SCOPE: () => NCERT_SCOPE,
90
- NCERT_SIG: () => NCERT_SIG,
77
+ MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
78
+ MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
79
+ MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
80
+ MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
81
+ NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
82
+ NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
83
+ NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
84
+ NCERT_KID: () => import_axis_protocol2.NCERT_KID,
85
+ NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
86
+ NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
87
+ NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
88
+ NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
89
+ NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
90
+ NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
91
91
  PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
92
- PROOF_CAPSULE: () => PROOF_CAPSULE,
93
- PROOF_JWT: () => PROOF_JWT,
94
- PROOF_LOOM: () => PROOF_LOOM,
95
- PROOF_MTLS: () => PROOF_MTLS,
96
- PROOF_NONE: () => PROOF_NONE,
97
- PROOF_WITNESS: () => PROOF_WITNESS,
98
- ProofType: () => ProofType,
92
+ PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
93
+ PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
94
+ PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
95
+ PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
96
+ PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
97
+ PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
98
+ ProofType: () => import_axis_protocol2.ProofType,
99
99
  RESPONSE_TAG_CREATED_AT: () => RESPONSE_TAG_CREATED_AT,
100
100
  RESPONSE_TAG_CREATED_BY: () => RESPONSE_TAG_CREATED_BY,
101
101
  RESPONSE_TAG_ID: () => RESPONSE_TAG_ID,
@@ -107,38 +107,39 @@ __export(index_exports, {
107
107
  Schema2012_PasskeyLoginVerifyRes: () => Schema2012_PasskeyLoginVerifyRes,
108
108
  Schema2021_PasskeyRegisterOptionsReq: () => Schema2021_PasskeyRegisterOptionsReq,
109
109
  SensorDecisions: () => SensorDecisions,
110
- TLV_ACTOR_ID: () => TLV_ACTOR_ID,
111
- TLV_AUD: () => TLV_AUD,
112
- TLV_BODY_ARR: () => TLV_BODY_ARR,
113
- TLV_BODY_OBJ: () => TLV_BODY_OBJ,
114
- TLV_CAPSULE: () => TLV_CAPSULE,
115
- TLV_EFFECT: () => TLV_EFFECT,
116
- TLV_ERROR_CODE: () => TLV_ERROR_CODE,
117
- TLV_ERROR_MSG: () => TLV_ERROR_MSG,
110
+ TLV: () => import_axis_protocol.TLV,
111
+ TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
112
+ TLV_AUD: () => import_axis_protocol2.TLV_AUD,
113
+ TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
114
+ TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
115
+ TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
116
+ TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
117
+ TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
118
+ TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
118
119
  TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
119
- TLV_INDEX: () => TLV_INDEX,
120
- TLV_INTENT: () => TLV_INTENT,
121
- TLV_KID: () => TLV_KID,
122
- TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
123
- TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
124
- TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
125
- TLV_NODE: () => TLV_NODE,
126
- TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
127
- TLV_NODE_KID: () => TLV_NODE_KID,
128
- TLV_NONCE: () => TLV_NONCE,
129
- TLV_OFFSET: () => TLV_OFFSET,
130
- TLV_OK: () => TLV_OK,
131
- TLV_PID: () => TLV_PID,
132
- TLV_PREV_HASH: () => TLV_PREV_HASH,
133
- TLV_PROOF_REF: () => TLV_PROOF_REF,
134
- TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
135
- TLV_REALM: () => TLV_REALM,
136
- TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
137
- TLV_RID: () => TLV_RID,
138
- TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
139
- TLV_TRACE_ID: () => TLV_TRACE_ID,
140
- TLV_TS: () => TLV_TS,
141
- TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
120
+ TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
121
+ TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
122
+ TLV_KID: () => import_axis_protocol2.TLV_KID,
123
+ TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
124
+ TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
125
+ TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
126
+ TLV_NODE: () => import_axis_protocol2.TLV_NODE,
127
+ TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
128
+ TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
129
+ TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
130
+ TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
131
+ TLV_OK: () => import_axis_protocol2.TLV_OK,
132
+ TLV_PID: () => import_axis_protocol2.TLV_PID,
133
+ TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
134
+ TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
135
+ TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
136
+ TLV_REALM: () => import_axis_protocol2.TLV_REALM,
137
+ TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
138
+ TLV_RID: () => import_axis_protocol2.TLV_RID,
139
+ TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
140
+ TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
141
+ TLV_TS: () => import_axis_protocol2.TLV_TS,
142
+ TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID,
142
143
  TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
143
144
  TlvEnum: () => TlvEnum,
144
145
  TlvField: () => TlvField,
@@ -163,18 +164,18 @@ __export(index_exports, {
163
164
  classifyIntent: () => classifyIntent,
164
165
  computeReceiptHash: () => computeReceiptHash,
165
166
  computeSignaturePayload: () => computeSignaturePayload,
166
- decodeArray: () => decodeArray,
167
+ decodeArray: () => import_axis_protocol.decodeArray,
167
168
  decodeAxis1Frame: () => decodeAxis1Frame,
168
169
  decodeFrame: () => decodeFrame,
169
- decodeObject: () => decodeObject,
170
- decodeTLVs: () => decodeTLVs,
171
- decodeTLVsList: () => decodeTLVsList,
172
- decodeVarint: () => decodeVarint,
170
+ decodeObject: () => import_axis_protocol.decodeObject,
171
+ decodeTLVs: () => import_axis_protocol.decodeTLVs,
172
+ decodeTLVsList: () => import_axis_protocol.decodeTLVsList,
173
+ decodeVarint: () => import_axis_protocol3.decodeVarint,
173
174
  encVarint: () => encVarint,
174
175
  encodeAxis1Frame: () => encodeAxis1Frame,
175
176
  encodeFrame: () => encodeFrame,
176
- encodeTLVs: () => encodeTLVs,
177
- encodeVarint: () => encodeVarint,
177
+ encodeTLVs: () => import_axis_protocol.encodeTLVs,
178
+ encodeVarint: () => import_axis_protocol3.encodeVarint,
178
179
  extractDtoSchema: () => extractDtoSchema,
179
180
  generateEd25519KeyPair: () => generateEd25519KeyPair,
180
181
  getSignTarget: () => getSignTarget,
@@ -201,7 +202,7 @@ __export(index_exports, {
201
202
  unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
202
203
  utf8: () => utf8,
203
204
  validateFrameShape: () => validateFrameShape,
204
- varintLength: () => varintLength,
205
+ varintLength: () => import_axis_protocol3.varintLength,
205
206
  varintU: () => varintU,
206
207
  verifyFrameSignature: () => verifyFrameSignature
207
208
  });
@@ -305,142 +306,12 @@ function TlvRange(min, max, message) {
305
306
  // src/decorators/dto-schema.util.ts
306
307
  var import_reflect_metadata3 = require("reflect-metadata");
307
308
 
308
- // src/core/varint.ts
309
- function encodeVarint(value) {
310
- if (value < 0) throw new Error("Varint must be unsigned");
311
- const bytes2 = [];
312
- while (true) {
313
- const byte = value & 127;
314
- value >>>= 7;
315
- if (value === 0) {
316
- bytes2.push(byte);
317
- break;
318
- }
319
- bytes2.push(byte | 128);
320
- }
321
- return new Uint8Array(bytes2);
322
- }
323
- function decodeVarint(buf, offset = 0) {
324
- let value = 0;
325
- let shift = 0;
326
- let length = 0;
327
- while (true) {
328
- if (offset + length >= buf.length) {
329
- throw new Error("Varint decode out of bounds");
330
- }
331
- const byte = buf[offset + length];
332
- value += (byte & 127) * Math.pow(2, shift);
333
- length++;
334
- shift += 7;
335
- if ((byte & 128) === 0) {
336
- break;
337
- }
338
- if (length > 8) throw new Error("Varint too large");
339
- }
340
- return { value, length };
341
- }
342
- function varintLength(value) {
343
- if (value < 0) throw new Error("Varint must be unsigned");
344
- let len = 0;
345
- do {
346
- value >>>= 7;
347
- len++;
348
- } while (value !== 0);
349
- return len;
350
- }
351
-
352
309
  // src/core/tlv.ts
353
- function encodeTLVs(tlvs) {
354
- const sorted = [...tlvs].sort((a, b) => a.type - b.type);
355
- for (let i = 0; i < sorted.length - 1; i++) {
356
- if (sorted[i].type === sorted[i + 1].type) {
357
- throw new Error(`Duplicate TLV type: ${sorted[i].type}`);
358
- }
359
- }
360
- let totalSize = 0;
361
- for (const t of sorted) {
362
- totalSize += varintLength(t.type);
363
- totalSize += varintLength(t.value.length);
364
- totalSize += t.value.length;
365
- }
366
- const buf = new Uint8Array(totalSize);
367
- let offset = 0;
368
- for (const t of sorted) {
369
- const typeBytes = encodeVarint(t.type);
370
- buf.set(typeBytes, offset);
371
- offset += typeBytes.length;
372
- const lenBytes = encodeVarint(t.value.length);
373
- buf.set(lenBytes, offset);
374
- offset += lenBytes.length;
375
- buf.set(t.value, offset);
376
- offset += t.value.length;
377
- }
378
- return buf;
379
- }
380
- function decodeTLVsList(buf, maxItems = 1024) {
381
- const list = [];
382
- let offset = 0;
383
- while (offset < buf.length) {
384
- if (list.length >= maxItems) throw new Error("TLV_LIMIT");
385
- const { value: type, length: typeLen } = decodeVarint(buf, offset);
386
- offset += typeLen;
387
- const { value: len, length: lenLen } = decodeVarint(buf, offset);
388
- offset += lenLen;
389
- if (offset + len > buf.length) {
390
- throw new Error(`TLV violation: Length ${len} exceeds buffer`);
391
- }
392
- const value = buf.slice(offset, offset + len);
393
- list.push({ type, value });
394
- offset += len;
395
- }
396
- return list;
397
- }
398
- function decodeTLVs(buf) {
399
- const map2 = /* @__PURE__ */ new Map();
400
- let offset = 0;
401
- let lastType = -1;
402
- while (offset < buf.length) {
403
- const { value: type, length: typeLen } = decodeVarint(buf, offset);
404
- offset += typeLen;
405
- if (type <= lastType) {
406
- throw new Error(
407
- `TLV violation: Unsorted or duplicate type ${type} after ${lastType}`
408
- );
409
- }
410
- lastType = type;
411
- const { value: len, length: lenLen } = decodeVarint(buf, offset);
412
- offset += lenLen;
413
- if (offset + len > buf.length) {
414
- throw new Error(`TLV violation: Length ${len} exceeds buffer`);
415
- }
416
- const value = buf.slice(offset, offset + len);
417
- map2.set(type, value);
418
- offset += len;
419
- }
420
- return map2;
421
- }
422
- function decodeObject(bytes2, depth = 0, limits = { maxDepth: 8, maxItems: 128 }) {
423
- if (depth > limits.maxDepth) {
424
- throw new Error("OBJECT_DEPTH_EXCEEDED");
425
- }
426
- const map2 = decodeTLVs(bytes2);
427
- return map2;
428
- }
429
- function decodeArray(bytes2, itemType, maxItems = 256) {
430
- const list = decodeTLVsList(bytes2, maxItems);
431
- const items = [];
432
- for (const tlv2 of list) {
433
- if (tlv2.type !== itemType) {
434
- throw new Error(`INVALID_ARRAY_ITEM:${tlv2.type}`);
435
- }
436
- items.push(tlv2.value);
437
- }
438
- return items;
439
- }
310
+ var import_axis_protocol = require("@nextera.one/axis-protocol");
440
311
 
441
312
  // src/decorators/dto-schema.util.ts
442
313
  function extractDtoSchema(dto) {
443
- const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
314
+ const fieldMetas = Reflect.getMetadata(TLV_FIELDS_KEY, dto) || [];
444
315
  if (fieldMetas.length === 0) {
445
316
  throw new Error(
446
317
  `DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate`
@@ -459,7 +330,7 @@ function extractDtoSchema(dto) {
459
330
  scope: m.options.scope
460
331
  };
461
332
  });
462
- const validatorMetas = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, dto) || [];
333
+ const validatorMetas = Reflect.getMetadata(TLV_VALIDATORS_KEY, dto) || [];
463
334
  const validators = /* @__PURE__ */ new Map();
464
335
  for (const vm of validatorMetas) {
465
336
  const tag = tagByProp.get(vm.property);
@@ -474,7 +345,7 @@ function extractDtoSchema(dto) {
474
345
  return { fields, validators };
475
346
  }
476
347
  function buildDtoDecoder(dto) {
477
- const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
348
+ const fieldMetas = Reflect.getMetadata(TLV_FIELDS_KEY, dto) || [];
478
349
  if (fieldMetas.length === 0) {
479
350
  throw new Error(
480
351
  `DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder`
@@ -485,7 +356,7 @@ function buildDtoDecoder(dto) {
485
356
  tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
486
357
  }
487
358
  return (bodyBytes) => {
488
- const tlvMap2 = decodeTLVs(new Uint8Array(bodyBytes));
359
+ const tlvMap2 = (0, import_axis_protocol.decodeTLVs)(new Uint8Array(bodyBytes));
489
360
  const result = {};
490
361
  for (const [tag, raw] of tlvMap2) {
491
362
  const meta = tagMap.get(tag);
@@ -742,82 +613,10 @@ IntentRouter = __decorateClass([
742
613
  ], IntentRouter);
743
614
 
744
615
  // src/core/constants.ts
745
- var AXIS_MAGIC = new Uint8Array([65, 88, 73, 83, 49]);
746
- var AXIS_VERSION = 1;
747
- var MAX_HDR_LEN = 2048;
748
- var MAX_BODY_LEN = 65536;
749
- var MAX_SIG_LEN = 128;
750
- var MAX_FRAME_LEN = 70 * 1024;
751
- var FLAG_BODY_TLV = 1;
752
- var FLAG_CHAIN_REQ = 2;
753
- var FLAG_HAS_WITNESS = 4;
754
- var TLV_PID = 1;
755
- var TLV_TS = 2;
756
- var TLV_INTENT = 3;
757
- var TLV_ACTOR_ID = 4;
758
- var TLV_PROOF_TYPE = 5;
759
- var TLV_PROOF_REF = 6;
760
- var TLV_NONCE = 7;
761
- var TLV_AUD = 8;
762
- var TLV_REALM = TLV_AUD;
763
- var TLV_NODE = 9;
764
- var TLV_TRACE_ID = 10;
765
- var TLV_KID = 11;
766
- var TLV_RID = 15;
767
- var TLV_OK = 16;
768
- var TLV_EFFECT = 17;
769
- var TLV_ERROR_CODE = 18;
770
- var TLV_ERROR_MSG = 19;
771
- var TLV_PREV_HASH = 20;
772
- var TLV_RECEIPT_HASH = 21;
773
- var TLV_NODE_KID = 30;
774
- var TLV_NODE_CERT_HASH = 34;
775
- var TLV_LOOM_PRESENCE_ID = 91;
776
- var TLV_LOOM_WRIT = 92;
777
- var TLV_LOOM_THREAD_HASH = 93;
778
- var TLV_UPLOAD_ID = 70;
779
- var TLV_INDEX = 71;
780
- var TLV_OFFSET = 72;
781
- var TLV_SHA256_CHUNK = 73;
782
- var TLV_CAPSULE = 90;
783
- var TLV_BODY_OBJ = 254;
784
- var TLV_BODY_ARR = 255;
785
- var NCERT_NODE_ID = 1;
786
- var NCERT_KID = 2;
787
- var NCERT_ALG = 3;
788
- var NCERT_PUB = 4;
789
- var NCERT_NBF = 5;
790
- var NCERT_EXP = 6;
791
- var NCERT_SCOPE = 7;
792
- var NCERT_ISSUER_KID = 8;
793
- var NCERT_PAYLOAD = 50;
794
- var NCERT_SIG = 51;
795
- var PROOF_NONE = 0;
796
- var PROOF_CAPSULE = 1;
797
- var PROOF_JWT = 2;
798
- var PROOF_MTLS = 3;
799
- var PROOF_LOOM = 4;
800
- var PROOF_WITNESS = 5;
801
- var ProofType = /* @__PURE__ */ ((ProofType2) => {
802
- ProofType2[ProofType2["NONE"] = 0] = "NONE";
803
- ProofType2[ProofType2["CAPSULE"] = 1] = "CAPSULE";
804
- ProofType2[ProofType2["JWT"] = 2] = "JWT";
805
- ProofType2[ProofType2["MTLS"] = 3] = "MTLS";
806
- ProofType2[ProofType2["LOOM"] = 4] = "LOOM";
807
- ProofType2[ProofType2["WITNESS"] = 5] = "WITNESS";
808
- return ProofType2;
809
- })(ProofType || {});
810
- var BodyProfile = /* @__PURE__ */ ((BodyProfile2) => {
811
- BodyProfile2[BodyProfile2["RAW"] = 0] = "RAW";
812
- BodyProfile2[BodyProfile2["TLV_MAP"] = 1] = "TLV_MAP";
813
- BodyProfile2[BodyProfile2["OBJ"] = 2] = "OBJ";
814
- BodyProfile2[BodyProfile2["ARR"] = 3] = "ARR";
815
- return BodyProfile2;
816
- })(BodyProfile || {});
817
- var ERR_INVALID_PACKET = "INVALID_PACKET";
818
- var ERR_BAD_SIGNATURE = "BAD_SIGNATURE";
819
- var ERR_REPLAY_DETECTED = "REPLAY_DETECTED";
820
- var ERR_CONTRACT_VIOLATION = "CONTRACT_VIOLATION";
616
+ var import_axis_protocol2 = require("@nextera.one/axis-protocol");
617
+
618
+ // src/core/varint.ts
619
+ var import_axis_protocol3 = require("@nextera.one/axis-protocol");
821
620
 
822
621
  // src/core/signature.ts
823
622
  var crypto = __toESM(require("crypto"));
@@ -838,28 +637,28 @@ var AxisFrameZ = z.object({
838
637
  sig: z.custom((v) => v instanceof Uint8Array)
839
638
  });
840
639
  function encodeFrame(frame) {
841
- const hdrBytes = encodeTLVs(
640
+ const hdrBytes = (0, import_axis_protocol.encodeTLVs)(
842
641
  Array.from(frame.headers.entries()).map(([t, v]) => ({
843
642
  type: t,
844
643
  value: v
845
644
  }))
846
645
  );
847
- if (hdrBytes.length > MAX_HDR_LEN) throw new Error("Header too large");
848
- if (frame.body.length > MAX_BODY_LEN) throw new Error("Body too large");
849
- if (frame.sig.length > MAX_SIG_LEN) throw new Error("Signature too large");
850
- const hdrLenBytes = encodeVarint(hdrBytes.length);
851
- const bodyLenBytes = encodeVarint(frame.body.length);
852
- const sigLenBytes = encodeVarint(frame.sig.length);
646
+ if (hdrBytes.length > import_axis_protocol2.MAX_HDR_LEN) throw new Error("Header too large");
647
+ if (frame.body.length > import_axis_protocol2.MAX_BODY_LEN) throw new Error("Body too large");
648
+ if (frame.sig.length > import_axis_protocol2.MAX_SIG_LEN) throw new Error("Signature too large");
649
+ const hdrLenBytes = (0, import_axis_protocol3.encodeVarint)(hdrBytes.length);
650
+ const bodyLenBytes = (0, import_axis_protocol3.encodeVarint)(frame.body.length);
651
+ const sigLenBytes = (0, import_axis_protocol3.encodeVarint)(frame.sig.length);
853
652
  const totalLen = 5 + // Magic (AXIS1)
854
653
  1 + // Version
855
654
  1 + // Flags
856
655
  hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
857
- if (totalLen > MAX_FRAME_LEN) throw new Error("Total frame too large");
656
+ if (totalLen > import_axis_protocol2.MAX_FRAME_LEN) throw new Error("Total frame too large");
858
657
  const buf = new Uint8Array(totalLen);
859
658
  let offset = 0;
860
- buf.set(AXIS_MAGIC, offset);
659
+ buf.set(import_axis_protocol2.AXIS_MAGIC, offset);
861
660
  offset += 5;
862
- buf[offset++] = AXIS_VERSION;
661
+ buf[offset++] = import_axis_protocol2.AXIS_VERSION;
863
662
  buf[offset++] = frame.flags;
864
663
  buf.set(hdrLenBytes, offset);
865
664
  offset += hdrLenBytes.length;
@@ -879,21 +678,21 @@ function decodeFrame(buf) {
879
678
  let offset = 0;
880
679
  if (offset + 5 > buf.length) throw new Error("Packet too short");
881
680
  for (let i = 0; i < 5; i++) {
882
- if (buf[offset + i] !== AXIS_MAGIC[i]) throw new Error("Invalid Magic");
681
+ if (buf[offset + i] !== import_axis_protocol2.AXIS_MAGIC[i]) throw new Error("Invalid Magic");
883
682
  }
884
683
  offset += 5;
885
684
  const ver = buf[offset++];
886
- if (ver !== AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
685
+ if (ver !== import_axis_protocol2.AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
887
686
  const flags = buf[offset++];
888
- const { value: hdrLen, length: hlLen } = decodeVarint(buf, offset);
687
+ const { value: hdrLen, length: hlLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
889
688
  offset += hlLen;
890
- if (hdrLen > MAX_HDR_LEN) throw new Error("Header limit exceeded");
891
- const { value: bodyLen, length: blLen } = decodeVarint(buf, offset);
689
+ if (hdrLen > import_axis_protocol2.MAX_HDR_LEN) throw new Error("Header limit exceeded");
690
+ const { value: bodyLen, length: blLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
892
691
  offset += blLen;
893
- if (bodyLen > MAX_BODY_LEN) throw new Error("Body limit exceeded");
894
- const { value: sigLen, length: slLen } = decodeVarint(buf, offset);
692
+ if (bodyLen > import_axis_protocol2.MAX_BODY_LEN) throw new Error("Body limit exceeded");
693
+ const { value: sigLen, length: slLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
895
694
  offset += slLen;
896
- if (sigLen > MAX_SIG_LEN) throw new Error("Signature limit exceeded");
695
+ if (sigLen > import_axis_protocol2.MAX_SIG_LEN) throw new Error("Signature limit exceeded");
897
696
  if (offset + hdrLen + bodyLen + sigLen > buf.length) {
898
697
  throw new Error("Frame truncated");
899
698
  }
@@ -903,7 +702,7 @@ function decodeFrame(buf) {
903
702
  offset += bodyLen;
904
703
  const sigBytes = buf.slice(offset, offset + sigLen);
905
704
  offset += sigLen;
906
- const headers = decodeTLVs(hdrBytes);
705
+ const headers = (0, import_axis_protocol.decodeTLVs)(hdrBytes);
907
706
  return {
908
707
  flags,
909
708
  headers,
@@ -2130,22 +1929,22 @@ function decodeAxis1Frame(buf) {
2130
1929
  // src/types/packet.ts
2131
1930
  var T = {
2132
1931
  /** The specific intent or action (e.g., 'vault.create') */
2133
- INTENT: TLV_INTENT,
1932
+ INTENT: import_axis_protocol2.TLV_INTENT,
2134
1933
  /** Package identifier / ID */
2135
- PID: TLV_PID,
1934
+ PID: import_axis_protocol2.TLV_PID,
2136
1935
  /** Versioning of the intent schema */
2137
1936
  INTENT_VERSION: 10,
2138
1937
  // Defaulting to TRACE_ID for now or a new tag if available
2139
1938
  /** Unique identifier for the requesting actor */
2140
- ACTOR_ID: TLV_ACTOR_ID,
1939
+ ACTOR_ID: import_axis_protocol2.TLV_ACTOR_ID,
2141
1940
  /** Optional Capability Token identifier (16 bytes) */
2142
- CAPSULE_ID: TLV_PROOF_REF,
1941
+ CAPSULE_ID: import_axis_protocol2.TLV_PROOF_REF,
2143
1942
  /** Unique session/request identifier (16 bytes) */
2144
- NONCE: TLV_NONCE,
1943
+ NONCE: import_axis_protocol2.TLV_NONCE,
2145
1944
  /** High-precision Unix timestamp in milliseconds */
2146
- TS_MS: TLV_TS,
1945
+ TS_MS: import_axis_protocol2.TLV_TS,
2147
1946
  /** Proof type */
2148
- PROOF_TYPE: TLV_PROOF_TYPE,
1947
+ PROOF_TYPE: import_axis_protocol2.TLV_PROOF_TYPE,
2149
1948
  /** Standard binary body tag */
2150
1949
  BODY: 100,
2151
1950
  /** Standard JSON-encoded body tag */
@@ -2322,12 +2121,12 @@ var CAPABILITIES = {
2322
2121
  witness: "witness"
2323
2122
  };
2324
2123
  var PROOF_CAPABILITIES = {
2325
- [PROOF_NONE]: [],
2326
- [PROOF_CAPSULE]: ["read", "write", "execute"],
2327
- [PROOF_JWT]: ["read"],
2328
- [PROOF_MTLS]: ["read", "write", "admin"],
2329
- [PROOF_LOOM]: ["read", "write", "execute"],
2330
- [PROOF_WITNESS]: ["read", "write", "execute", "witness"]
2124
+ [import_axis_protocol2.PROOF_NONE]: [],
2125
+ [import_axis_protocol2.PROOF_CAPSULE]: ["read", "write", "execute"],
2126
+ [import_axis_protocol2.PROOF_JWT]: ["read"],
2127
+ [import_axis_protocol2.PROOF_MTLS]: ["read", "write", "admin"],
2128
+ [import_axis_protocol2.PROOF_LOOM]: ["read", "write", "execute"],
2129
+ [import_axis_protocol2.PROOF_WITNESS]: ["read", "write", "execute", "witness"]
2331
2130
  };
2332
2131
  var INTENT_REQUIREMENTS = {
2333
2132
  "public.*": [],
@@ -2654,6 +2453,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
2654
2453
  Schema2012_PasskeyLoginVerifyRes,
2655
2454
  Schema2021_PasskeyRegisterOptionsReq,
2656
2455
  SensorDecisions,
2456
+ TLV,
2657
2457
  TLV_ACTOR_ID,
2658
2458
  TLV_AUD,
2659
2459
  TLV_BODY_ARR,