@nextera.one/axis-server-sdk 1.0.0 → 1.1.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.d.mts +82 -6
- package/dist/index.d.ts +82 -6
- package/dist/index.js +387 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +367 -134
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44,7 +44,11 @@ __export(index_exports, {
|
|
|
44
44
|
AXIS_VERSION: () => AXIS_VERSION,
|
|
45
45
|
Ats1Codec: () => ats1_exports,
|
|
46
46
|
AxisFrameZ: () => AxisFrameZ,
|
|
47
|
+
AxisIdDto: () => AxisIdDto,
|
|
47
48
|
AxisPacketTags: () => T,
|
|
49
|
+
AxisPartialType: () => AxisPartialType,
|
|
50
|
+
AxisResponseDto: () => AxisResponseDto,
|
|
51
|
+
AxisTlvDto: () => AxisTlvDto,
|
|
48
52
|
BodyProfile: () => BodyProfile,
|
|
49
53
|
CAPABILITIES: () => CAPABILITIES,
|
|
50
54
|
ContractViolationError: () => ContractViolationError,
|
|
@@ -62,6 +66,7 @@ __export(index_exports, {
|
|
|
62
66
|
FLAG_HAS_WITNESS: () => 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,
|
|
@@ -91,6 +96,11 @@ __export(index_exports, {
|
|
|
91
96
|
PROOF_NONE: () => PROOF_NONE,
|
|
92
97
|
PROOF_WITNESS: () => PROOF_WITNESS,
|
|
93
98
|
ProofType: () => 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,
|
|
@@ -105,6 +115,7 @@ __export(index_exports, {
|
|
|
105
115
|
TLV_EFFECT: () => TLV_EFFECT,
|
|
106
116
|
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
107
117
|
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
118
|
+
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
108
119
|
TLV_INDEX: () => TLV_INDEX,
|
|
109
120
|
TLV_INTENT: () => TLV_INTENT,
|
|
110
121
|
TLV_KID: () => TLV_KID,
|
|
@@ -128,12 +139,20 @@ __export(index_exports, {
|
|
|
128
139
|
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
129
140
|
TLV_TS: () => TLV_TS,
|
|
130
141
|
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
142
|
+
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
143
|
+
TlvEnum: () => TlvEnum,
|
|
144
|
+
TlvField: () => TlvField,
|
|
145
|
+
TlvMinLen: () => TlvMinLen,
|
|
146
|
+
TlvRange: () => TlvRange,
|
|
147
|
+
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
148
|
+
TlvValidate: () => TlvValidate,
|
|
131
149
|
axis1SigningBytes: () => axis1SigningBytes,
|
|
132
150
|
b64urlDecode: () => b64urlDecode,
|
|
133
151
|
b64urlDecodeString: () => b64urlDecodeString,
|
|
134
152
|
b64urlEncode: () => b64urlEncode,
|
|
135
153
|
b64urlEncodeString: () => b64urlEncodeString,
|
|
136
154
|
buildAts1Hdr: () => buildAts1Hdr,
|
|
155
|
+
buildDtoDecoder: () => buildDtoDecoder,
|
|
137
156
|
buildPacket: () => buildPacket,
|
|
138
157
|
buildReceiptHash: () => buildReceiptHash,
|
|
139
158
|
buildTLVs: () => buildTLVs,
|
|
@@ -156,6 +175,7 @@ __export(index_exports, {
|
|
|
156
175
|
encodeFrame: () => encodeFrame,
|
|
157
176
|
encodeTLVs: () => encodeTLVs,
|
|
158
177
|
encodeVarint: () => encodeVarint,
|
|
178
|
+
extractDtoSchema: () => extractDtoSchema,
|
|
159
179
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
160
180
|
getSignTarget: () => getSignTarget,
|
|
161
181
|
hasScope: () => hasScope,
|
|
@@ -199,20 +219,366 @@ function Handler(intent) {
|
|
|
199
219
|
|
|
200
220
|
// src/decorators/intent.decorator.ts
|
|
201
221
|
var import_reflect_metadata = require("reflect-metadata");
|
|
222
|
+
var INTENT_METADATA_KEY = "axis:intent";
|
|
202
223
|
var INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
203
224
|
function Intent(action, options) {
|
|
204
225
|
return (target, propertyKey) => {
|
|
226
|
+
Reflect.defineMetadata(
|
|
227
|
+
INTENT_METADATA_KEY,
|
|
228
|
+
{ intent: action, ...options },
|
|
229
|
+
target,
|
|
230
|
+
propertyKey
|
|
231
|
+
);
|
|
205
232
|
const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
|
|
206
233
|
routes.push({
|
|
207
234
|
action,
|
|
208
235
|
methodName: propertyKey,
|
|
209
236
|
absolute: options?.absolute,
|
|
210
|
-
frame: options?.frame
|
|
237
|
+
frame: options?.frame,
|
|
238
|
+
kind: options?.kind,
|
|
239
|
+
bodyProfile: options?.bodyProfile,
|
|
240
|
+
tlv: options?.tlv,
|
|
241
|
+
dto: options?.dto
|
|
211
242
|
});
|
|
212
243
|
Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
|
|
213
244
|
};
|
|
214
245
|
}
|
|
215
246
|
|
|
247
|
+
// src/decorators/tlv-field.decorator.ts
|
|
248
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
249
|
+
var TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
250
|
+
var TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
251
|
+
function TlvField(tag, options) {
|
|
252
|
+
return (target, propertyKey) => {
|
|
253
|
+
const existing = Reflect.getOwnMetadata(TLV_FIELDS_KEY, target.constructor) || [];
|
|
254
|
+
existing.push({
|
|
255
|
+
property: String(propertyKey),
|
|
256
|
+
tag,
|
|
257
|
+
options
|
|
258
|
+
});
|
|
259
|
+
Reflect.defineMetadata(TLV_FIELDS_KEY, existing, target.constructor);
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function TlvValidate(validator) {
|
|
263
|
+
return (target, propertyKey) => {
|
|
264
|
+
const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
265
|
+
const prop = String(propertyKey);
|
|
266
|
+
let entry = existing.find((e) => e.property === prop);
|
|
267
|
+
if (!entry) {
|
|
268
|
+
entry = { property: prop, tag: 0, validators: [] };
|
|
269
|
+
existing.push(entry);
|
|
270
|
+
}
|
|
271
|
+
entry.validators.push(validator);
|
|
272
|
+
Reflect.defineMetadata(TLV_VALIDATORS_KEY, existing, target.constructor);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function TlvUtf8Pattern(pattern, message) {
|
|
276
|
+
return TlvValidate((val, prop) => {
|
|
277
|
+
const str = new TextDecoder().decode(val);
|
|
278
|
+
return pattern.test(str) ? null : message || `${prop}: failed pattern check`;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function TlvMinLen(min, message) {
|
|
282
|
+
return TlvValidate((val, prop) => {
|
|
283
|
+
return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function TlvEnum(allowed, message) {
|
|
287
|
+
const set = new Set(allowed);
|
|
288
|
+
return TlvValidate((val, prop) => {
|
|
289
|
+
const str = new TextDecoder().decode(val);
|
|
290
|
+
return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function TlvRange(min, max, message) {
|
|
294
|
+
return TlvValidate((val, prop) => {
|
|
295
|
+
if (val.length !== 8) return `${prop}: u64 must be 8 bytes`;
|
|
296
|
+
let n = 0n;
|
|
297
|
+
for (const b of val) n = n << 8n | BigInt(b);
|
|
298
|
+
if (n < min || n > max) {
|
|
299
|
+
return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/decorators/dto-schema.util.ts
|
|
306
|
+
var import_reflect_metadata3 = require("reflect-metadata");
|
|
307
|
+
|
|
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
|
+
// 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
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/decorators/dto-schema.util.ts
|
|
442
|
+
function extractDtoSchema(dto) {
|
|
443
|
+
const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
|
|
444
|
+
if (fieldMetas.length === 0) {
|
|
445
|
+
throw new Error(
|
|
446
|
+
`DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate`
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
const tagByProp = /* @__PURE__ */ new Map();
|
|
450
|
+
const fields = fieldMetas.map((m) => {
|
|
451
|
+
tagByProp.set(m.property, m.tag);
|
|
452
|
+
return {
|
|
453
|
+
name: m.property,
|
|
454
|
+
tag: m.tag,
|
|
455
|
+
kind: m.options.kind,
|
|
456
|
+
required: m.options.required,
|
|
457
|
+
maxLen: m.options.maxLen,
|
|
458
|
+
max: m.options.max,
|
|
459
|
+
scope: m.options.scope
|
|
460
|
+
};
|
|
461
|
+
});
|
|
462
|
+
const validatorMetas = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, dto) || [];
|
|
463
|
+
const validators = /* @__PURE__ */ new Map();
|
|
464
|
+
for (const vm of validatorMetas) {
|
|
465
|
+
const tag = tagByProp.get(vm.property);
|
|
466
|
+
if (tag === void 0) {
|
|
467
|
+
throw new Error(
|
|
468
|
+
`@TlvValidate on ${dto.name}.${vm.property} but no @TlvField found for that property`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
vm.tag = tag;
|
|
472
|
+
validators.set(tag, vm.validators);
|
|
473
|
+
}
|
|
474
|
+
return { fields, validators };
|
|
475
|
+
}
|
|
476
|
+
function buildDtoDecoder(dto) {
|
|
477
|
+
const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
|
|
478
|
+
if (fieldMetas.length === 0) {
|
|
479
|
+
throw new Error(
|
|
480
|
+
`DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder`
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
484
|
+
for (const m of fieldMetas) {
|
|
485
|
+
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
486
|
+
}
|
|
487
|
+
return (bodyBytes) => {
|
|
488
|
+
const tlvMap2 = decodeTLVs(new Uint8Array(bodyBytes));
|
|
489
|
+
const result = {};
|
|
490
|
+
for (const [tag, raw] of tlvMap2) {
|
|
491
|
+
const meta = tagMap.get(tag);
|
|
492
|
+
if (!meta) continue;
|
|
493
|
+
switch (meta.kind) {
|
|
494
|
+
case "utf8":
|
|
495
|
+
result[meta.property] = new TextDecoder().decode(raw);
|
|
496
|
+
break;
|
|
497
|
+
case "u64": {
|
|
498
|
+
let n = 0n;
|
|
499
|
+
for (let i = 0; i < raw.length; i++) {
|
|
500
|
+
n = n << 8n | BigInt(raw[i]);
|
|
501
|
+
}
|
|
502
|
+
result[meta.property] = n;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
case "bytes":
|
|
506
|
+
case "bytes16":
|
|
507
|
+
result[meta.property] = raw;
|
|
508
|
+
break;
|
|
509
|
+
case "bool":
|
|
510
|
+
result[meta.property] = raw.length > 0 && raw[0] !== 0;
|
|
511
|
+
break;
|
|
512
|
+
case "obj":
|
|
513
|
+
case "arr":
|
|
514
|
+
result[meta.property] = JSON.parse(new TextDecoder().decode(raw));
|
|
515
|
+
break;
|
|
516
|
+
default:
|
|
517
|
+
result[meta.property] = raw;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return result;
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// src/base/axis-tlv.dto.ts
|
|
525
|
+
var AxisTlvDto = class {
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// src/base/axis-id.dto.ts
|
|
529
|
+
var AxisIdDto = class extends AxisTlvDto {
|
|
530
|
+
};
|
|
531
|
+
__decorateClass([
|
|
532
|
+
TlvField(1, { kind: "utf8", required: true, maxLen: 128 }),
|
|
533
|
+
TlvMinLen(1, "id must not be empty")
|
|
534
|
+
], AxisIdDto.prototype, "id", 2);
|
|
535
|
+
|
|
536
|
+
// src/base/axis-partial-type.ts
|
|
537
|
+
var import_reflect_metadata4 = require("reflect-metadata");
|
|
538
|
+
function AxisPartialType(BaseDto) {
|
|
539
|
+
class PartialDto extends BaseDto {
|
|
540
|
+
}
|
|
541
|
+
const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
|
|
542
|
+
const partialFields = fields.map((f) => ({
|
|
543
|
+
property: f.property,
|
|
544
|
+
tag: f.tag,
|
|
545
|
+
options: { ...f.options, required: false }
|
|
546
|
+
}));
|
|
547
|
+
Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
548
|
+
const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
549
|
+
if (validators.length > 0) {
|
|
550
|
+
Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
551
|
+
}
|
|
552
|
+
Object.defineProperty(PartialDto, "name", {
|
|
553
|
+
value: `Partial${BaseDto.name}`
|
|
554
|
+
});
|
|
555
|
+
return PartialDto;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// src/base/axis-response.dto.ts
|
|
559
|
+
var RESPONSE_TAG_ID = 1;
|
|
560
|
+
var RESPONSE_TAG_CREATED_AT = 2;
|
|
561
|
+
var RESPONSE_TAG_UPDATED_AT = 3;
|
|
562
|
+
var RESPONSE_TAG_CREATED_BY = 4;
|
|
563
|
+
var RESPONSE_TAG_UPDATED_BY = 5;
|
|
564
|
+
var AxisResponseDto = class extends AxisTlvDto {
|
|
565
|
+
};
|
|
566
|
+
__decorateClass([
|
|
567
|
+
TlvField(RESPONSE_TAG_ID, { kind: "utf8" })
|
|
568
|
+
], AxisResponseDto.prototype, "id", 2);
|
|
569
|
+
__decorateClass([
|
|
570
|
+
TlvField(RESPONSE_TAG_CREATED_AT, { kind: "u64" })
|
|
571
|
+
], AxisResponseDto.prototype, "created_at", 2);
|
|
572
|
+
__decorateClass([
|
|
573
|
+
TlvField(RESPONSE_TAG_UPDATED_AT, { kind: "u64" })
|
|
574
|
+
], AxisResponseDto.prototype, "updated_at", 2);
|
|
575
|
+
__decorateClass([
|
|
576
|
+
TlvField(RESPONSE_TAG_CREATED_BY, { kind: "utf8" })
|
|
577
|
+
], AxisResponseDto.prototype, "created_by", 2);
|
|
578
|
+
__decorateClass([
|
|
579
|
+
TlvField(RESPONSE_TAG_UPDATED_BY, { kind: "utf8" })
|
|
580
|
+
], AxisResponseDto.prototype, "updated_by", 2);
|
|
581
|
+
|
|
216
582
|
// src/engine/intent.router.ts
|
|
217
583
|
var import_common2 = require("@nestjs/common");
|
|
218
584
|
var IntentRouter = class {
|
|
@@ -453,139 +819,6 @@ var ERR_BAD_SIGNATURE = "BAD_SIGNATURE";
|
|
|
453
819
|
var ERR_REPLAY_DETECTED = "REPLAY_DETECTED";
|
|
454
820
|
var ERR_CONTRACT_VIOLATION = "CONTRACT_VIOLATION";
|
|
455
821
|
|
|
456
|
-
// 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
|
-
}
|
|
588
|
-
|
|
589
822
|
// src/core/signature.ts
|
|
590
823
|
var crypto = __toESM(require("crypto"));
|
|
591
824
|
|
|
@@ -2358,7 +2591,11 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2358
2591
|
AXIS_VERSION,
|
|
2359
2592
|
Ats1Codec,
|
|
2360
2593
|
AxisFrameZ,
|
|
2594
|
+
AxisIdDto,
|
|
2361
2595
|
AxisPacketTags,
|
|
2596
|
+
AxisPartialType,
|
|
2597
|
+
AxisResponseDto,
|
|
2598
|
+
AxisTlvDto,
|
|
2362
2599
|
BodyProfile,
|
|
2363
2600
|
CAPABILITIES,
|
|
2364
2601
|
ContractViolationError,
|
|
@@ -2376,6 +2613,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2376
2613
|
FLAG_HAS_WITNESS,
|
|
2377
2614
|
HANDLER_METADATA_KEY,
|
|
2378
2615
|
Handler,
|
|
2616
|
+
INTENT_METADATA_KEY,
|
|
2379
2617
|
INTENT_REQUIREMENTS,
|
|
2380
2618
|
INTENT_ROUTES_KEY,
|
|
2381
2619
|
INTENT_SENSITIVITY_MAP,
|
|
@@ -2405,6 +2643,11 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2405
2643
|
PROOF_NONE,
|
|
2406
2644
|
PROOF_WITNESS,
|
|
2407
2645
|
ProofType,
|
|
2646
|
+
RESPONSE_TAG_CREATED_AT,
|
|
2647
|
+
RESPONSE_TAG_CREATED_BY,
|
|
2648
|
+
RESPONSE_TAG_ID,
|
|
2649
|
+
RESPONSE_TAG_UPDATED_AT,
|
|
2650
|
+
RESPONSE_TAG_UPDATED_BY,
|
|
2408
2651
|
RiskDecision,
|
|
2409
2652
|
Schema2002_PasskeyLoginOptionsRes,
|
|
2410
2653
|
Schema2011_PasskeyLoginVerifyReq,
|
|
@@ -2419,6 +2662,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2419
2662
|
TLV_EFFECT,
|
|
2420
2663
|
TLV_ERROR_CODE,
|
|
2421
2664
|
TLV_ERROR_MSG,
|
|
2665
|
+
TLV_FIELDS_KEY,
|
|
2422
2666
|
TLV_INDEX,
|
|
2423
2667
|
TLV_INTENT,
|
|
2424
2668
|
TLV_KID,
|
|
@@ -2442,12 +2686,20 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2442
2686
|
TLV_TRACE_ID,
|
|
2443
2687
|
TLV_TS,
|
|
2444
2688
|
TLV_UPLOAD_ID,
|
|
2689
|
+
TLV_VALIDATORS_KEY,
|
|
2690
|
+
TlvEnum,
|
|
2691
|
+
TlvField,
|
|
2692
|
+
TlvMinLen,
|
|
2693
|
+
TlvRange,
|
|
2694
|
+
TlvUtf8Pattern,
|
|
2695
|
+
TlvValidate,
|
|
2445
2696
|
axis1SigningBytes,
|
|
2446
2697
|
b64urlDecode,
|
|
2447
2698
|
b64urlDecodeString,
|
|
2448
2699
|
b64urlEncode,
|
|
2449
2700
|
b64urlEncodeString,
|
|
2450
2701
|
buildAts1Hdr,
|
|
2702
|
+
buildDtoDecoder,
|
|
2451
2703
|
buildPacket,
|
|
2452
2704
|
buildReceiptHash,
|
|
2453
2705
|
buildTLVs,
|
|
@@ -2470,6 +2722,7 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2470
2722
|
encodeFrame,
|
|
2471
2723
|
encodeTLVs,
|
|
2472
2724
|
encodeVarint,
|
|
2725
|
+
extractDtoSchema,
|
|
2473
2726
|
generateEd25519KeyPair,
|
|
2474
2727
|
getSignTarget,
|
|
2475
2728
|
hasScope,
|