@nextera.one/axis-server-sdk 1.0.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,29 +39,34 @@ 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
+ AxisIdDto: () => AxisIdDto,
47
48
  AxisPacketTags: () => T,
48
- BodyProfile: () => BodyProfile,
49
+ AxisPartialType: () => AxisPartialType,
50
+ AxisResponseDto: () => AxisResponseDto,
51
+ AxisTlvDto: () => AxisTlvDto,
52
+ BodyProfile: () => import_axis_protocol2.BodyProfile,
49
53
  CAPABILITIES: () => CAPABILITIES,
50
54
  ContractViolationError: () => ContractViolationError,
51
55
  DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
52
56
  DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
53
57
  Decision: () => Decision,
54
- ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
55
- ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
56
- ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
57
- 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,
58
62
  ExecutionMeter: () => ExecutionMeter,
59
63
  FALLBACK_CONTRACT: () => FALLBACK_CONTRACT,
60
- FLAG_BODY_TLV: () => FLAG_BODY_TLV,
61
- FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
62
- 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,
63
67
  HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
64
68
  Handler: () => Handler,
69
+ INTENT_METADATA_KEY: () => INTENT_METADATA_KEY,
65
70
  INTENT_REQUIREMENTS: () => INTENT_REQUIREMENTS,
66
71
  INTENT_ROUTES_KEY: () => INTENT_ROUTES_KEY,
67
72
  INTENT_SENSITIVITY_MAP: () => INTENT_SENSITIVITY_MAP,
@@ -69,71 +74,86 @@ __export(index_exports, {
69
74
  Intent: () => Intent,
70
75
  IntentRouter: () => IntentRouter,
71
76
  IntentSensitivity: () => IntentSensitivity,
72
- MAX_BODY_LEN: () => MAX_BODY_LEN,
73
- MAX_FRAME_LEN: () => MAX_FRAME_LEN,
74
- MAX_HDR_LEN: () => MAX_HDR_LEN,
75
- MAX_SIG_LEN: () => MAX_SIG_LEN,
76
- NCERT_ALG: () => NCERT_ALG,
77
- NCERT_EXP: () => NCERT_EXP,
78
- NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
79
- NCERT_KID: () => NCERT_KID,
80
- NCERT_NBF: () => NCERT_NBF,
81
- NCERT_NODE_ID: () => NCERT_NODE_ID,
82
- NCERT_PAYLOAD: () => NCERT_PAYLOAD,
83
- NCERT_PUB: () => NCERT_PUB,
84
- NCERT_SCOPE: () => NCERT_SCOPE,
85
- 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,
86
91
  PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
87
- PROOF_CAPSULE: () => PROOF_CAPSULE,
88
- PROOF_JWT: () => PROOF_JWT,
89
- PROOF_LOOM: () => PROOF_LOOM,
90
- PROOF_MTLS: () => PROOF_MTLS,
91
- PROOF_NONE: () => PROOF_NONE,
92
- PROOF_WITNESS: () => PROOF_WITNESS,
93
- 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
+ RESPONSE_TAG_CREATED_AT: () => RESPONSE_TAG_CREATED_AT,
100
+ RESPONSE_TAG_CREATED_BY: () => RESPONSE_TAG_CREATED_BY,
101
+ RESPONSE_TAG_ID: () => RESPONSE_TAG_ID,
102
+ RESPONSE_TAG_UPDATED_AT: () => RESPONSE_TAG_UPDATED_AT,
103
+ RESPONSE_TAG_UPDATED_BY: () => RESPONSE_TAG_UPDATED_BY,
94
104
  RiskDecision: () => RiskDecision,
95
105
  Schema2002_PasskeyLoginOptionsRes: () => Schema2002_PasskeyLoginOptionsRes,
96
106
  Schema2011_PasskeyLoginVerifyReq: () => Schema2011_PasskeyLoginVerifyReq,
97
107
  Schema2012_PasskeyLoginVerifyRes: () => Schema2012_PasskeyLoginVerifyRes,
98
108
  Schema2021_PasskeyRegisterOptionsReq: () => Schema2021_PasskeyRegisterOptionsReq,
99
109
  SensorDecisions: () => SensorDecisions,
100
- TLV_ACTOR_ID: () => TLV_ACTOR_ID,
101
- TLV_AUD: () => TLV_AUD,
102
- TLV_BODY_ARR: () => TLV_BODY_ARR,
103
- TLV_BODY_OBJ: () => TLV_BODY_OBJ,
104
- TLV_CAPSULE: () => TLV_CAPSULE,
105
- TLV_EFFECT: () => TLV_EFFECT,
106
- TLV_ERROR_CODE: () => TLV_ERROR_CODE,
107
- TLV_ERROR_MSG: () => TLV_ERROR_MSG,
108
- TLV_INDEX: () => TLV_INDEX,
109
- TLV_INTENT: () => TLV_INTENT,
110
- TLV_KID: () => TLV_KID,
111
- TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
112
- TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
113
- TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
114
- TLV_NODE: () => TLV_NODE,
115
- TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
116
- TLV_NODE_KID: () => TLV_NODE_KID,
117
- TLV_NONCE: () => TLV_NONCE,
118
- TLV_OFFSET: () => TLV_OFFSET,
119
- TLV_OK: () => TLV_OK,
120
- TLV_PID: () => TLV_PID,
121
- TLV_PREV_HASH: () => TLV_PREV_HASH,
122
- TLV_PROOF_REF: () => TLV_PROOF_REF,
123
- TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
124
- TLV_REALM: () => TLV_REALM,
125
- TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
126
- TLV_RID: () => TLV_RID,
127
- TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
128
- TLV_TRACE_ID: () => TLV_TRACE_ID,
129
- TLV_TS: () => TLV_TS,
130
- TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
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,
119
+ TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
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,
143
+ TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
144
+ TlvEnum: () => TlvEnum,
145
+ TlvField: () => TlvField,
146
+ TlvMinLen: () => TlvMinLen,
147
+ TlvRange: () => TlvRange,
148
+ TlvUtf8Pattern: () => TlvUtf8Pattern,
149
+ TlvValidate: () => TlvValidate,
131
150
  axis1SigningBytes: () => axis1SigningBytes,
132
151
  b64urlDecode: () => b64urlDecode,
133
152
  b64urlDecodeString: () => b64urlDecodeString,
134
153
  b64urlEncode: () => b64urlEncode,
135
154
  b64urlEncodeString: () => b64urlEncodeString,
136
155
  buildAts1Hdr: () => buildAts1Hdr,
156
+ buildDtoDecoder: () => buildDtoDecoder,
137
157
  buildPacket: () => buildPacket,
138
158
  buildReceiptHash: () => buildReceiptHash,
139
159
  buildTLVs: () => buildTLVs,
@@ -144,18 +164,19 @@ __export(index_exports, {
144
164
  classifyIntent: () => classifyIntent,
145
165
  computeReceiptHash: () => computeReceiptHash,
146
166
  computeSignaturePayload: () => computeSignaturePayload,
147
- decodeArray: () => decodeArray,
167
+ decodeArray: () => import_axis_protocol.decodeArray,
148
168
  decodeAxis1Frame: () => decodeAxis1Frame,
149
169
  decodeFrame: () => decodeFrame,
150
- decodeObject: () => decodeObject,
151
- decodeTLVs: () => decodeTLVs,
152
- decodeTLVsList: () => decodeTLVsList,
153
- 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,
154
174
  encVarint: () => encVarint,
155
175
  encodeAxis1Frame: () => encodeAxis1Frame,
156
176
  encodeFrame: () => encodeFrame,
157
- encodeTLVs: () => encodeTLVs,
158
- encodeVarint: () => encodeVarint,
177
+ encodeTLVs: () => import_axis_protocol.encodeTLVs,
178
+ encodeVarint: () => import_axis_protocol3.encodeVarint,
179
+ extractDtoSchema: () => extractDtoSchema,
159
180
  generateEd25519KeyPair: () => generateEd25519KeyPair,
160
181
  getSignTarget: () => getSignTarget,
161
182
  hasScope: () => hasScope,
@@ -181,7 +202,7 @@ __export(index_exports, {
181
202
  unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
182
203
  utf8: () => utf8,
183
204
  validateFrameShape: () => validateFrameShape,
184
- varintLength: () => varintLength,
205
+ varintLength: () => import_axis_protocol3.varintLength,
185
206
  varintU: () => varintU,
186
207
  verifyFrameSignature: () => verifyFrameSignature
187
208
  });
@@ -199,20 +220,236 @@ function Handler(intent) {
199
220
 
200
221
  // src/decorators/intent.decorator.ts
201
222
  var import_reflect_metadata = require("reflect-metadata");
223
+ var INTENT_METADATA_KEY = "axis:intent";
202
224
  var INTENT_ROUTES_KEY = "axis:intent_routes";
203
225
  function Intent(action, options) {
204
226
  return (target, propertyKey) => {
227
+ Reflect.defineMetadata(
228
+ INTENT_METADATA_KEY,
229
+ { intent: action, ...options },
230
+ target,
231
+ propertyKey
232
+ );
205
233
  const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
206
234
  routes.push({
207
235
  action,
208
236
  methodName: propertyKey,
209
237
  absolute: options?.absolute,
210
- frame: options?.frame
238
+ frame: options?.frame,
239
+ kind: options?.kind,
240
+ bodyProfile: options?.bodyProfile,
241
+ tlv: options?.tlv,
242
+ dto: options?.dto
211
243
  });
212
244
  Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
213
245
  };
214
246
  }
215
247
 
248
+ // src/decorators/tlv-field.decorator.ts
249
+ var import_reflect_metadata2 = require("reflect-metadata");
250
+ var TLV_FIELDS_KEY = "axis:tlv:fields";
251
+ var TLV_VALIDATORS_KEY = "axis:tlv:validators";
252
+ function TlvField(tag, options) {
253
+ return (target, propertyKey) => {
254
+ const existing = Reflect.getOwnMetadata(TLV_FIELDS_KEY, target.constructor) || [];
255
+ existing.push({
256
+ property: String(propertyKey),
257
+ tag,
258
+ options
259
+ });
260
+ Reflect.defineMetadata(TLV_FIELDS_KEY, existing, target.constructor);
261
+ };
262
+ }
263
+ function TlvValidate(validator) {
264
+ return (target, propertyKey) => {
265
+ const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
266
+ const prop = String(propertyKey);
267
+ let entry = existing.find((e) => e.property === prop);
268
+ if (!entry) {
269
+ entry = { property: prop, tag: 0, validators: [] };
270
+ existing.push(entry);
271
+ }
272
+ entry.validators.push(validator);
273
+ Reflect.defineMetadata(TLV_VALIDATORS_KEY, existing, target.constructor);
274
+ };
275
+ }
276
+ function TlvUtf8Pattern(pattern, message) {
277
+ return TlvValidate((val, prop) => {
278
+ const str = new TextDecoder().decode(val);
279
+ return pattern.test(str) ? null : message || `${prop}: failed pattern check`;
280
+ });
281
+ }
282
+ function TlvMinLen(min, message) {
283
+ return TlvValidate((val, prop) => {
284
+ return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
285
+ });
286
+ }
287
+ function TlvEnum(allowed, message) {
288
+ const set = new Set(allowed);
289
+ return TlvValidate((val, prop) => {
290
+ const str = new TextDecoder().decode(val);
291
+ return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
292
+ });
293
+ }
294
+ function TlvRange(min, max, message) {
295
+ return TlvValidate((val, prop) => {
296
+ if (val.length !== 8) return `${prop}: u64 must be 8 bytes`;
297
+ let n = 0n;
298
+ for (const b of val) n = n << 8n | BigInt(b);
299
+ if (n < min || n > max) {
300
+ return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
301
+ }
302
+ return null;
303
+ });
304
+ }
305
+
306
+ // src/decorators/dto-schema.util.ts
307
+ var import_reflect_metadata3 = require("reflect-metadata");
308
+
309
+ // src/core/tlv.ts
310
+ var import_axis_protocol = require("@nextera.one/axis-protocol");
311
+
312
+ // src/decorators/dto-schema.util.ts
313
+ function extractDtoSchema(dto) {
314
+ const fieldMetas = Reflect.getMetadata(TLV_FIELDS_KEY, dto) || [];
315
+ if (fieldMetas.length === 0) {
316
+ throw new Error(
317
+ `DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate`
318
+ );
319
+ }
320
+ const tagByProp = /* @__PURE__ */ new Map();
321
+ const fields = fieldMetas.map((m) => {
322
+ tagByProp.set(m.property, m.tag);
323
+ return {
324
+ name: m.property,
325
+ tag: m.tag,
326
+ kind: m.options.kind,
327
+ required: m.options.required,
328
+ maxLen: m.options.maxLen,
329
+ max: m.options.max,
330
+ scope: m.options.scope
331
+ };
332
+ });
333
+ const validatorMetas = Reflect.getMetadata(TLV_VALIDATORS_KEY, dto) || [];
334
+ const validators = /* @__PURE__ */ new Map();
335
+ for (const vm of validatorMetas) {
336
+ const tag = tagByProp.get(vm.property);
337
+ if (tag === void 0) {
338
+ throw new Error(
339
+ `@TlvValidate on ${dto.name}.${vm.property} but no @TlvField found for that property`
340
+ );
341
+ }
342
+ vm.tag = tag;
343
+ validators.set(tag, vm.validators);
344
+ }
345
+ return { fields, validators };
346
+ }
347
+ function buildDtoDecoder(dto) {
348
+ const fieldMetas = Reflect.getMetadata(TLV_FIELDS_KEY, dto) || [];
349
+ if (fieldMetas.length === 0) {
350
+ throw new Error(
351
+ `DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder`
352
+ );
353
+ }
354
+ const tagMap = /* @__PURE__ */ new Map();
355
+ for (const m of fieldMetas) {
356
+ tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
357
+ }
358
+ return (bodyBytes) => {
359
+ const tlvMap2 = (0, import_axis_protocol.decodeTLVs)(new Uint8Array(bodyBytes));
360
+ const result = {};
361
+ for (const [tag, raw] of tlvMap2) {
362
+ const meta = tagMap.get(tag);
363
+ if (!meta) continue;
364
+ switch (meta.kind) {
365
+ case "utf8":
366
+ result[meta.property] = new TextDecoder().decode(raw);
367
+ break;
368
+ case "u64": {
369
+ let n = 0n;
370
+ for (let i = 0; i < raw.length; i++) {
371
+ n = n << 8n | BigInt(raw[i]);
372
+ }
373
+ result[meta.property] = n;
374
+ break;
375
+ }
376
+ case "bytes":
377
+ case "bytes16":
378
+ result[meta.property] = raw;
379
+ break;
380
+ case "bool":
381
+ result[meta.property] = raw.length > 0 && raw[0] !== 0;
382
+ break;
383
+ case "obj":
384
+ case "arr":
385
+ result[meta.property] = JSON.parse(new TextDecoder().decode(raw));
386
+ break;
387
+ default:
388
+ result[meta.property] = raw;
389
+ }
390
+ }
391
+ return result;
392
+ };
393
+ }
394
+
395
+ // src/base/axis-tlv.dto.ts
396
+ var AxisTlvDto = class {
397
+ };
398
+
399
+ // src/base/axis-id.dto.ts
400
+ var AxisIdDto = class extends AxisTlvDto {
401
+ };
402
+ __decorateClass([
403
+ TlvField(1, { kind: "utf8", required: true, maxLen: 128 }),
404
+ TlvMinLen(1, "id must not be empty")
405
+ ], AxisIdDto.prototype, "id", 2);
406
+
407
+ // src/base/axis-partial-type.ts
408
+ var import_reflect_metadata4 = require("reflect-metadata");
409
+ function AxisPartialType(BaseDto) {
410
+ class PartialDto extends BaseDto {
411
+ }
412
+ const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
413
+ const partialFields = fields.map((f) => ({
414
+ property: f.property,
415
+ tag: f.tag,
416
+ options: { ...f.options, required: false }
417
+ }));
418
+ Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
419
+ const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
420
+ if (validators.length > 0) {
421
+ Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
422
+ }
423
+ Object.defineProperty(PartialDto, "name", {
424
+ value: `Partial${BaseDto.name}`
425
+ });
426
+ return PartialDto;
427
+ }
428
+
429
+ // src/base/axis-response.dto.ts
430
+ var RESPONSE_TAG_ID = 1;
431
+ var RESPONSE_TAG_CREATED_AT = 2;
432
+ var RESPONSE_TAG_UPDATED_AT = 3;
433
+ var RESPONSE_TAG_CREATED_BY = 4;
434
+ var RESPONSE_TAG_UPDATED_BY = 5;
435
+ var AxisResponseDto = class extends AxisTlvDto {
436
+ };
437
+ __decorateClass([
438
+ TlvField(RESPONSE_TAG_ID, { kind: "utf8" })
439
+ ], AxisResponseDto.prototype, "id", 2);
440
+ __decorateClass([
441
+ TlvField(RESPONSE_TAG_CREATED_AT, { kind: "u64" })
442
+ ], AxisResponseDto.prototype, "created_at", 2);
443
+ __decorateClass([
444
+ TlvField(RESPONSE_TAG_UPDATED_AT, { kind: "u64" })
445
+ ], AxisResponseDto.prototype, "updated_at", 2);
446
+ __decorateClass([
447
+ TlvField(RESPONSE_TAG_CREATED_BY, { kind: "utf8" })
448
+ ], AxisResponseDto.prototype, "created_by", 2);
449
+ __decorateClass([
450
+ TlvField(RESPONSE_TAG_UPDATED_BY, { kind: "utf8" })
451
+ ], AxisResponseDto.prototype, "updated_by", 2);
452
+
216
453
  // src/engine/intent.router.ts
217
454
  var import_common2 = require("@nestjs/common");
218
455
  var IntentRouter = class {
@@ -376,215 +613,10 @@ IntentRouter = __decorateClass([
376
613
  ], IntentRouter);
377
614
 
378
615
  // src/core/constants.ts
379
- var AXIS_MAGIC = new Uint8Array([65, 88, 73, 83, 49]);
380
- var AXIS_VERSION = 1;
381
- var MAX_HDR_LEN = 2048;
382
- var MAX_BODY_LEN = 65536;
383
- var MAX_SIG_LEN = 128;
384
- var MAX_FRAME_LEN = 70 * 1024;
385
- var FLAG_BODY_TLV = 1;
386
- var FLAG_CHAIN_REQ = 2;
387
- var FLAG_HAS_WITNESS = 4;
388
- var TLV_PID = 1;
389
- var TLV_TS = 2;
390
- var TLV_INTENT = 3;
391
- var TLV_ACTOR_ID = 4;
392
- var TLV_PROOF_TYPE = 5;
393
- var TLV_PROOF_REF = 6;
394
- var TLV_NONCE = 7;
395
- var TLV_AUD = 8;
396
- var TLV_REALM = TLV_AUD;
397
- var TLV_NODE = 9;
398
- var TLV_TRACE_ID = 10;
399
- var TLV_KID = 11;
400
- var TLV_RID = 15;
401
- var TLV_OK = 16;
402
- var TLV_EFFECT = 17;
403
- var TLV_ERROR_CODE = 18;
404
- var TLV_ERROR_MSG = 19;
405
- var TLV_PREV_HASH = 20;
406
- var TLV_RECEIPT_HASH = 21;
407
- var TLV_NODE_KID = 30;
408
- var TLV_NODE_CERT_HASH = 34;
409
- var TLV_LOOM_PRESENCE_ID = 91;
410
- var TLV_LOOM_WRIT = 92;
411
- var TLV_LOOM_THREAD_HASH = 93;
412
- var TLV_UPLOAD_ID = 70;
413
- var TLV_INDEX = 71;
414
- var TLV_OFFSET = 72;
415
- var TLV_SHA256_CHUNK = 73;
416
- var TLV_CAPSULE = 90;
417
- var TLV_BODY_OBJ = 254;
418
- var TLV_BODY_ARR = 255;
419
- var NCERT_NODE_ID = 1;
420
- var NCERT_KID = 2;
421
- var NCERT_ALG = 3;
422
- var NCERT_PUB = 4;
423
- var NCERT_NBF = 5;
424
- var NCERT_EXP = 6;
425
- var NCERT_SCOPE = 7;
426
- var NCERT_ISSUER_KID = 8;
427
- var NCERT_PAYLOAD = 50;
428
- var NCERT_SIG = 51;
429
- var PROOF_NONE = 0;
430
- var PROOF_CAPSULE = 1;
431
- var PROOF_JWT = 2;
432
- var PROOF_MTLS = 3;
433
- var PROOF_LOOM = 4;
434
- var PROOF_WITNESS = 5;
435
- var ProofType = /* @__PURE__ */ ((ProofType2) => {
436
- ProofType2[ProofType2["NONE"] = 0] = "NONE";
437
- ProofType2[ProofType2["CAPSULE"] = 1] = "CAPSULE";
438
- ProofType2[ProofType2["JWT"] = 2] = "JWT";
439
- ProofType2[ProofType2["MTLS"] = 3] = "MTLS";
440
- ProofType2[ProofType2["LOOM"] = 4] = "LOOM";
441
- ProofType2[ProofType2["WITNESS"] = 5] = "WITNESS";
442
- return ProofType2;
443
- })(ProofType || {});
444
- var BodyProfile = /* @__PURE__ */ ((BodyProfile2) => {
445
- BodyProfile2[BodyProfile2["RAW"] = 0] = "RAW";
446
- BodyProfile2[BodyProfile2["TLV_MAP"] = 1] = "TLV_MAP";
447
- BodyProfile2[BodyProfile2["OBJ"] = 2] = "OBJ";
448
- BodyProfile2[BodyProfile2["ARR"] = 3] = "ARR";
449
- return BodyProfile2;
450
- })(BodyProfile || {});
451
- var ERR_INVALID_PACKET = "INVALID_PACKET";
452
- var ERR_BAD_SIGNATURE = "BAD_SIGNATURE";
453
- var ERR_REPLAY_DETECTED = "REPLAY_DETECTED";
454
- var ERR_CONTRACT_VIOLATION = "CONTRACT_VIOLATION";
616
+ var import_axis_protocol2 = require("@nextera.one/axis-protocol");
455
617
 
456
618
  // src/core/varint.ts
457
- function encodeVarint(value) {
458
- if (value < 0) throw new Error("Varint must be unsigned");
459
- const bytes2 = [];
460
- while (true) {
461
- const byte = value & 127;
462
- value >>>= 7;
463
- if (value === 0) {
464
- bytes2.push(byte);
465
- break;
466
- }
467
- bytes2.push(byte | 128);
468
- }
469
- return new Uint8Array(bytes2);
470
- }
471
- function decodeVarint(buf, offset = 0) {
472
- let value = 0;
473
- let shift = 0;
474
- let length = 0;
475
- while (true) {
476
- if (offset + length >= buf.length) {
477
- throw new Error("Varint decode out of bounds");
478
- }
479
- const byte = buf[offset + length];
480
- value += (byte & 127) * Math.pow(2, shift);
481
- length++;
482
- shift += 7;
483
- if ((byte & 128) === 0) {
484
- break;
485
- }
486
- if (length > 8) throw new Error("Varint too large");
487
- }
488
- return { value, length };
489
- }
490
- function varintLength(value) {
491
- if (value < 0) throw new Error("Varint must be unsigned");
492
- let len = 0;
493
- do {
494
- value >>>= 7;
495
- len++;
496
- } while (value !== 0);
497
- return len;
498
- }
499
-
500
- // src/core/tlv.ts
501
- function encodeTLVs(tlvs) {
502
- const sorted = [...tlvs].sort((a, b) => a.type - b.type);
503
- for (let i = 0; i < sorted.length - 1; i++) {
504
- if (sorted[i].type === sorted[i + 1].type) {
505
- throw new Error(`Duplicate TLV type: ${sorted[i].type}`);
506
- }
507
- }
508
- let totalSize = 0;
509
- for (const t of sorted) {
510
- totalSize += varintLength(t.type);
511
- totalSize += varintLength(t.value.length);
512
- totalSize += t.value.length;
513
- }
514
- const buf = new Uint8Array(totalSize);
515
- let offset = 0;
516
- for (const t of sorted) {
517
- const typeBytes = encodeVarint(t.type);
518
- buf.set(typeBytes, offset);
519
- offset += typeBytes.length;
520
- const lenBytes = encodeVarint(t.value.length);
521
- buf.set(lenBytes, offset);
522
- offset += lenBytes.length;
523
- buf.set(t.value, offset);
524
- offset += t.value.length;
525
- }
526
- return buf;
527
- }
528
- function decodeTLVsList(buf, maxItems = 1024) {
529
- const list = [];
530
- let offset = 0;
531
- while (offset < buf.length) {
532
- if (list.length >= maxItems) throw new Error("TLV_LIMIT");
533
- const { value: type, length: typeLen } = decodeVarint(buf, offset);
534
- offset += typeLen;
535
- const { value: len, length: lenLen } = decodeVarint(buf, offset);
536
- offset += lenLen;
537
- if (offset + len > buf.length) {
538
- throw new Error(`TLV violation: Length ${len} exceeds buffer`);
539
- }
540
- const value = buf.slice(offset, offset + len);
541
- list.push({ type, value });
542
- offset += len;
543
- }
544
- return list;
545
- }
546
- function decodeTLVs(buf) {
547
- const map2 = /* @__PURE__ */ new Map();
548
- let offset = 0;
549
- let lastType = -1;
550
- while (offset < buf.length) {
551
- const { value: type, length: typeLen } = decodeVarint(buf, offset);
552
- offset += typeLen;
553
- if (type <= lastType) {
554
- throw new Error(
555
- `TLV violation: Unsorted or duplicate type ${type} after ${lastType}`
556
- );
557
- }
558
- lastType = type;
559
- const { value: len, length: lenLen } = decodeVarint(buf, offset);
560
- offset += lenLen;
561
- if (offset + len > buf.length) {
562
- throw new Error(`TLV violation: Length ${len} exceeds buffer`);
563
- }
564
- const value = buf.slice(offset, offset + len);
565
- map2.set(type, value);
566
- offset += len;
567
- }
568
- return map2;
569
- }
570
- function decodeObject(bytes2, depth = 0, limits = { maxDepth: 8, maxItems: 128 }) {
571
- if (depth > limits.maxDepth) {
572
- throw new Error("OBJECT_DEPTH_EXCEEDED");
573
- }
574
- const map2 = decodeTLVs(bytes2);
575
- return map2;
576
- }
577
- function decodeArray(bytes2, itemType, maxItems = 256) {
578
- const list = decodeTLVsList(bytes2, maxItems);
579
- const items = [];
580
- for (const tlv2 of list) {
581
- if (tlv2.type !== itemType) {
582
- throw new Error(`INVALID_ARRAY_ITEM:${tlv2.type}`);
583
- }
584
- items.push(tlv2.value);
585
- }
586
- return items;
587
- }
619
+ var import_axis_protocol3 = require("@nextera.one/axis-protocol");
588
620
 
589
621
  // src/core/signature.ts
590
622
  var crypto = __toESM(require("crypto"));
@@ -605,28 +637,28 @@ var AxisFrameZ = z.object({
605
637
  sig: z.custom((v) => v instanceof Uint8Array)
606
638
  });
607
639
  function encodeFrame(frame) {
608
- const hdrBytes = encodeTLVs(
640
+ const hdrBytes = (0, import_axis_protocol.encodeTLVs)(
609
641
  Array.from(frame.headers.entries()).map(([t, v]) => ({
610
642
  type: t,
611
643
  value: v
612
644
  }))
613
645
  );
614
- if (hdrBytes.length > MAX_HDR_LEN) throw new Error("Header too large");
615
- if (frame.body.length > MAX_BODY_LEN) throw new Error("Body too large");
616
- if (frame.sig.length > MAX_SIG_LEN) throw new Error("Signature too large");
617
- const hdrLenBytes = encodeVarint(hdrBytes.length);
618
- const bodyLenBytes = encodeVarint(frame.body.length);
619
- 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);
620
652
  const totalLen = 5 + // Magic (AXIS1)
621
653
  1 + // Version
622
654
  1 + // Flags
623
655
  hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
624
- 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");
625
657
  const buf = new Uint8Array(totalLen);
626
658
  let offset = 0;
627
- buf.set(AXIS_MAGIC, offset);
659
+ buf.set(import_axis_protocol2.AXIS_MAGIC, offset);
628
660
  offset += 5;
629
- buf[offset++] = AXIS_VERSION;
661
+ buf[offset++] = import_axis_protocol2.AXIS_VERSION;
630
662
  buf[offset++] = frame.flags;
631
663
  buf.set(hdrLenBytes, offset);
632
664
  offset += hdrLenBytes.length;
@@ -646,21 +678,21 @@ function decodeFrame(buf) {
646
678
  let offset = 0;
647
679
  if (offset + 5 > buf.length) throw new Error("Packet too short");
648
680
  for (let i = 0; i < 5; i++) {
649
- 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");
650
682
  }
651
683
  offset += 5;
652
684
  const ver = buf[offset++];
653
- if (ver !== AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
685
+ if (ver !== import_axis_protocol2.AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
654
686
  const flags = buf[offset++];
655
- const { value: hdrLen, length: hlLen } = decodeVarint(buf, offset);
687
+ const { value: hdrLen, length: hlLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
656
688
  offset += hlLen;
657
- if (hdrLen > MAX_HDR_LEN) throw new Error("Header limit exceeded");
658
- 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);
659
691
  offset += blLen;
660
- if (bodyLen > MAX_BODY_LEN) throw new Error("Body limit exceeded");
661
- 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);
662
694
  offset += slLen;
663
- 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");
664
696
  if (offset + hdrLen + bodyLen + sigLen > buf.length) {
665
697
  throw new Error("Frame truncated");
666
698
  }
@@ -670,7 +702,7 @@ function decodeFrame(buf) {
670
702
  offset += bodyLen;
671
703
  const sigBytes = buf.slice(offset, offset + sigLen);
672
704
  offset += sigLen;
673
- const headers = decodeTLVs(hdrBytes);
705
+ const headers = (0, import_axis_protocol.decodeTLVs)(hdrBytes);
674
706
  return {
675
707
  flags,
676
708
  headers,
@@ -1897,22 +1929,22 @@ function decodeAxis1Frame(buf) {
1897
1929
  // src/types/packet.ts
1898
1930
  var T = {
1899
1931
  /** The specific intent or action (e.g., 'vault.create') */
1900
- INTENT: TLV_INTENT,
1932
+ INTENT: import_axis_protocol2.TLV_INTENT,
1901
1933
  /** Package identifier / ID */
1902
- PID: TLV_PID,
1934
+ PID: import_axis_protocol2.TLV_PID,
1903
1935
  /** Versioning of the intent schema */
1904
1936
  INTENT_VERSION: 10,
1905
1937
  // Defaulting to TRACE_ID for now or a new tag if available
1906
1938
  /** Unique identifier for the requesting actor */
1907
- ACTOR_ID: TLV_ACTOR_ID,
1939
+ ACTOR_ID: import_axis_protocol2.TLV_ACTOR_ID,
1908
1940
  /** Optional Capability Token identifier (16 bytes) */
1909
- CAPSULE_ID: TLV_PROOF_REF,
1941
+ CAPSULE_ID: import_axis_protocol2.TLV_PROOF_REF,
1910
1942
  /** Unique session/request identifier (16 bytes) */
1911
- NONCE: TLV_NONCE,
1943
+ NONCE: import_axis_protocol2.TLV_NONCE,
1912
1944
  /** High-precision Unix timestamp in milliseconds */
1913
- TS_MS: TLV_TS,
1945
+ TS_MS: import_axis_protocol2.TLV_TS,
1914
1946
  /** Proof type */
1915
- PROOF_TYPE: TLV_PROOF_TYPE,
1947
+ PROOF_TYPE: import_axis_protocol2.TLV_PROOF_TYPE,
1916
1948
  /** Standard binary body tag */
1917
1949
  BODY: 100,
1918
1950
  /** Standard JSON-encoded body tag */
@@ -2089,12 +2121,12 @@ var CAPABILITIES = {
2089
2121
  witness: "witness"
2090
2122
  };
2091
2123
  var PROOF_CAPABILITIES = {
2092
- [PROOF_NONE]: [],
2093
- [PROOF_CAPSULE]: ["read", "write", "execute"],
2094
- [PROOF_JWT]: ["read"],
2095
- [PROOF_MTLS]: ["read", "write", "admin"],
2096
- [PROOF_LOOM]: ["read", "write", "execute"],
2097
- [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"]
2098
2130
  };
2099
2131
  var INTENT_REQUIREMENTS = {
2100
2132
  "public.*": [],
@@ -2358,7 +2390,11 @@ function isTimestampValid(ts, skewSeconds = 120) {
2358
2390
  AXIS_VERSION,
2359
2391
  Ats1Codec,
2360
2392
  AxisFrameZ,
2393
+ AxisIdDto,
2361
2394
  AxisPacketTags,
2395
+ AxisPartialType,
2396
+ AxisResponseDto,
2397
+ AxisTlvDto,
2362
2398
  BodyProfile,
2363
2399
  CAPABILITIES,
2364
2400
  ContractViolationError,
@@ -2376,6 +2412,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
2376
2412
  FLAG_HAS_WITNESS,
2377
2413
  HANDLER_METADATA_KEY,
2378
2414
  Handler,
2415
+ INTENT_METADATA_KEY,
2379
2416
  INTENT_REQUIREMENTS,
2380
2417
  INTENT_ROUTES_KEY,
2381
2418
  INTENT_SENSITIVITY_MAP,
@@ -2405,12 +2442,18 @@ function isTimestampValid(ts, skewSeconds = 120) {
2405
2442
  PROOF_NONE,
2406
2443
  PROOF_WITNESS,
2407
2444
  ProofType,
2445
+ RESPONSE_TAG_CREATED_AT,
2446
+ RESPONSE_TAG_CREATED_BY,
2447
+ RESPONSE_TAG_ID,
2448
+ RESPONSE_TAG_UPDATED_AT,
2449
+ RESPONSE_TAG_UPDATED_BY,
2408
2450
  RiskDecision,
2409
2451
  Schema2002_PasskeyLoginOptionsRes,
2410
2452
  Schema2011_PasskeyLoginVerifyReq,
2411
2453
  Schema2012_PasskeyLoginVerifyRes,
2412
2454
  Schema2021_PasskeyRegisterOptionsReq,
2413
2455
  SensorDecisions,
2456
+ TLV,
2414
2457
  TLV_ACTOR_ID,
2415
2458
  TLV_AUD,
2416
2459
  TLV_BODY_ARR,
@@ -2419,6 +2462,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
2419
2462
  TLV_EFFECT,
2420
2463
  TLV_ERROR_CODE,
2421
2464
  TLV_ERROR_MSG,
2465
+ TLV_FIELDS_KEY,
2422
2466
  TLV_INDEX,
2423
2467
  TLV_INTENT,
2424
2468
  TLV_KID,
@@ -2442,12 +2486,20 @@ function isTimestampValid(ts, skewSeconds = 120) {
2442
2486
  TLV_TRACE_ID,
2443
2487
  TLV_TS,
2444
2488
  TLV_UPLOAD_ID,
2489
+ TLV_VALIDATORS_KEY,
2490
+ TlvEnum,
2491
+ TlvField,
2492
+ TlvMinLen,
2493
+ TlvRange,
2494
+ TlvUtf8Pattern,
2495
+ TlvValidate,
2445
2496
  axis1SigningBytes,
2446
2497
  b64urlDecode,
2447
2498
  b64urlDecodeString,
2448
2499
  b64urlEncode,
2449
2500
  b64urlEncodeString,
2450
2501
  buildAts1Hdr,
2502
+ buildDtoDecoder,
2451
2503
  buildPacket,
2452
2504
  buildReceiptHash,
2453
2505
  buildTLVs,
@@ -2470,6 +2522,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
2470
2522
  encodeFrame,
2471
2523
  encodeTLVs,
2472
2524
  encodeVarint,
2525
+ extractDtoSchema,
2473
2526
  generateEd25519KeyPair,
2474
2527
  getSignTarget,
2475
2528
  hasScope,