@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.mjs
CHANGED
|
@@ -31,20 +31,366 @@ function Handler(intent) {
|
|
|
31
31
|
|
|
32
32
|
// src/decorators/intent.decorator.ts
|
|
33
33
|
import "reflect-metadata";
|
|
34
|
+
var INTENT_METADATA_KEY = "axis:intent";
|
|
34
35
|
var INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
35
36
|
function Intent(action, options) {
|
|
36
37
|
return (target, propertyKey) => {
|
|
38
|
+
Reflect.defineMetadata(
|
|
39
|
+
INTENT_METADATA_KEY,
|
|
40
|
+
{ intent: action, ...options },
|
|
41
|
+
target,
|
|
42
|
+
propertyKey
|
|
43
|
+
);
|
|
37
44
|
const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
|
|
38
45
|
routes.push({
|
|
39
46
|
action,
|
|
40
47
|
methodName: propertyKey,
|
|
41
48
|
absolute: options?.absolute,
|
|
42
|
-
frame: options?.frame
|
|
49
|
+
frame: options?.frame,
|
|
50
|
+
kind: options?.kind,
|
|
51
|
+
bodyProfile: options?.bodyProfile,
|
|
52
|
+
tlv: options?.tlv,
|
|
53
|
+
dto: options?.dto
|
|
43
54
|
});
|
|
44
55
|
Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
|
|
45
56
|
};
|
|
46
57
|
}
|
|
47
58
|
|
|
59
|
+
// src/decorators/tlv-field.decorator.ts
|
|
60
|
+
import "reflect-metadata";
|
|
61
|
+
var TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
62
|
+
var TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
63
|
+
function TlvField(tag, options) {
|
|
64
|
+
return (target, propertyKey) => {
|
|
65
|
+
const existing = Reflect.getOwnMetadata(TLV_FIELDS_KEY, target.constructor) || [];
|
|
66
|
+
existing.push({
|
|
67
|
+
property: String(propertyKey),
|
|
68
|
+
tag,
|
|
69
|
+
options
|
|
70
|
+
});
|
|
71
|
+
Reflect.defineMetadata(TLV_FIELDS_KEY, existing, target.constructor);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function TlvValidate(validator) {
|
|
75
|
+
return (target, propertyKey) => {
|
|
76
|
+
const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
77
|
+
const prop = String(propertyKey);
|
|
78
|
+
let entry = existing.find((e) => e.property === prop);
|
|
79
|
+
if (!entry) {
|
|
80
|
+
entry = { property: prop, tag: 0, validators: [] };
|
|
81
|
+
existing.push(entry);
|
|
82
|
+
}
|
|
83
|
+
entry.validators.push(validator);
|
|
84
|
+
Reflect.defineMetadata(TLV_VALIDATORS_KEY, existing, target.constructor);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function TlvUtf8Pattern(pattern, message) {
|
|
88
|
+
return TlvValidate((val, prop) => {
|
|
89
|
+
const str = new TextDecoder().decode(val);
|
|
90
|
+
return pattern.test(str) ? null : message || `${prop}: failed pattern check`;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function TlvMinLen(min, message) {
|
|
94
|
+
return TlvValidate((val, prop) => {
|
|
95
|
+
return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function TlvEnum(allowed, message) {
|
|
99
|
+
const set = new Set(allowed);
|
|
100
|
+
return TlvValidate((val, prop) => {
|
|
101
|
+
const str = new TextDecoder().decode(val);
|
|
102
|
+
return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function TlvRange(min, max, message) {
|
|
106
|
+
return TlvValidate((val, prop) => {
|
|
107
|
+
if (val.length !== 8) return `${prop}: u64 must be 8 bytes`;
|
|
108
|
+
let n = 0n;
|
|
109
|
+
for (const b of val) n = n << 8n | BigInt(b);
|
|
110
|
+
if (n < min || n > max) {
|
|
111
|
+
return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/decorators/dto-schema.util.ts
|
|
118
|
+
import "reflect-metadata";
|
|
119
|
+
|
|
120
|
+
// src/core/varint.ts
|
|
121
|
+
function encodeVarint(value) {
|
|
122
|
+
if (value < 0) throw new Error("Varint must be unsigned");
|
|
123
|
+
const bytes2 = [];
|
|
124
|
+
while (true) {
|
|
125
|
+
const byte = value & 127;
|
|
126
|
+
value >>>= 7;
|
|
127
|
+
if (value === 0) {
|
|
128
|
+
bytes2.push(byte);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
bytes2.push(byte | 128);
|
|
132
|
+
}
|
|
133
|
+
return new Uint8Array(bytes2);
|
|
134
|
+
}
|
|
135
|
+
function decodeVarint(buf, offset = 0) {
|
|
136
|
+
let value = 0;
|
|
137
|
+
let shift = 0;
|
|
138
|
+
let length = 0;
|
|
139
|
+
while (true) {
|
|
140
|
+
if (offset + length >= buf.length) {
|
|
141
|
+
throw new Error("Varint decode out of bounds");
|
|
142
|
+
}
|
|
143
|
+
const byte = buf[offset + length];
|
|
144
|
+
value += (byte & 127) * Math.pow(2, shift);
|
|
145
|
+
length++;
|
|
146
|
+
shift += 7;
|
|
147
|
+
if ((byte & 128) === 0) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (length > 8) throw new Error("Varint too large");
|
|
151
|
+
}
|
|
152
|
+
return { value, length };
|
|
153
|
+
}
|
|
154
|
+
function varintLength(value) {
|
|
155
|
+
if (value < 0) throw new Error("Varint must be unsigned");
|
|
156
|
+
let len = 0;
|
|
157
|
+
do {
|
|
158
|
+
value >>>= 7;
|
|
159
|
+
len++;
|
|
160
|
+
} while (value !== 0);
|
|
161
|
+
return len;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/core/tlv.ts
|
|
165
|
+
function encodeTLVs(tlvs) {
|
|
166
|
+
const sorted = [...tlvs].sort((a, b) => a.type - b.type);
|
|
167
|
+
for (let i = 0; i < sorted.length - 1; i++) {
|
|
168
|
+
if (sorted[i].type === sorted[i + 1].type) {
|
|
169
|
+
throw new Error(`Duplicate TLV type: ${sorted[i].type}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
let totalSize = 0;
|
|
173
|
+
for (const t of sorted) {
|
|
174
|
+
totalSize += varintLength(t.type);
|
|
175
|
+
totalSize += varintLength(t.value.length);
|
|
176
|
+
totalSize += t.value.length;
|
|
177
|
+
}
|
|
178
|
+
const buf = new Uint8Array(totalSize);
|
|
179
|
+
let offset = 0;
|
|
180
|
+
for (const t of sorted) {
|
|
181
|
+
const typeBytes = encodeVarint(t.type);
|
|
182
|
+
buf.set(typeBytes, offset);
|
|
183
|
+
offset += typeBytes.length;
|
|
184
|
+
const lenBytes = encodeVarint(t.value.length);
|
|
185
|
+
buf.set(lenBytes, offset);
|
|
186
|
+
offset += lenBytes.length;
|
|
187
|
+
buf.set(t.value, offset);
|
|
188
|
+
offset += t.value.length;
|
|
189
|
+
}
|
|
190
|
+
return buf;
|
|
191
|
+
}
|
|
192
|
+
function decodeTLVsList(buf, maxItems = 1024) {
|
|
193
|
+
const list = [];
|
|
194
|
+
let offset = 0;
|
|
195
|
+
while (offset < buf.length) {
|
|
196
|
+
if (list.length >= maxItems) throw new Error("TLV_LIMIT");
|
|
197
|
+
const { value: type, length: typeLen } = decodeVarint(buf, offset);
|
|
198
|
+
offset += typeLen;
|
|
199
|
+
const { value: len, length: lenLen } = decodeVarint(buf, offset);
|
|
200
|
+
offset += lenLen;
|
|
201
|
+
if (offset + len > buf.length) {
|
|
202
|
+
throw new Error(`TLV violation: Length ${len} exceeds buffer`);
|
|
203
|
+
}
|
|
204
|
+
const value = buf.slice(offset, offset + len);
|
|
205
|
+
list.push({ type, value });
|
|
206
|
+
offset += len;
|
|
207
|
+
}
|
|
208
|
+
return list;
|
|
209
|
+
}
|
|
210
|
+
function decodeTLVs(buf) {
|
|
211
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
212
|
+
let offset = 0;
|
|
213
|
+
let lastType = -1;
|
|
214
|
+
while (offset < buf.length) {
|
|
215
|
+
const { value: type, length: typeLen } = decodeVarint(buf, offset);
|
|
216
|
+
offset += typeLen;
|
|
217
|
+
if (type <= lastType) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`TLV violation: Unsorted or duplicate type ${type} after ${lastType}`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
lastType = type;
|
|
223
|
+
const { value: len, length: lenLen } = decodeVarint(buf, offset);
|
|
224
|
+
offset += lenLen;
|
|
225
|
+
if (offset + len > buf.length) {
|
|
226
|
+
throw new Error(`TLV violation: Length ${len} exceeds buffer`);
|
|
227
|
+
}
|
|
228
|
+
const value = buf.slice(offset, offset + len);
|
|
229
|
+
map2.set(type, value);
|
|
230
|
+
offset += len;
|
|
231
|
+
}
|
|
232
|
+
return map2;
|
|
233
|
+
}
|
|
234
|
+
function decodeObject(bytes2, depth = 0, limits = { maxDepth: 8, maxItems: 128 }) {
|
|
235
|
+
if (depth > limits.maxDepth) {
|
|
236
|
+
throw new Error("OBJECT_DEPTH_EXCEEDED");
|
|
237
|
+
}
|
|
238
|
+
const map2 = decodeTLVs(bytes2);
|
|
239
|
+
return map2;
|
|
240
|
+
}
|
|
241
|
+
function decodeArray(bytes2, itemType, maxItems = 256) {
|
|
242
|
+
const list = decodeTLVsList(bytes2, maxItems);
|
|
243
|
+
const items = [];
|
|
244
|
+
for (const tlv2 of list) {
|
|
245
|
+
if (tlv2.type !== itemType) {
|
|
246
|
+
throw new Error(`INVALID_ARRAY_ITEM:${tlv2.type}`);
|
|
247
|
+
}
|
|
248
|
+
items.push(tlv2.value);
|
|
249
|
+
}
|
|
250
|
+
return items;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/decorators/dto-schema.util.ts
|
|
254
|
+
function extractDtoSchema(dto) {
|
|
255
|
+
const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
|
|
256
|
+
if (fieldMetas.length === 0) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
const tagByProp = /* @__PURE__ */ new Map();
|
|
262
|
+
const fields = fieldMetas.map((m) => {
|
|
263
|
+
tagByProp.set(m.property, m.tag);
|
|
264
|
+
return {
|
|
265
|
+
name: m.property,
|
|
266
|
+
tag: m.tag,
|
|
267
|
+
kind: m.options.kind,
|
|
268
|
+
required: m.options.required,
|
|
269
|
+
maxLen: m.options.maxLen,
|
|
270
|
+
max: m.options.max,
|
|
271
|
+
scope: m.options.scope
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
const validatorMetas = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, dto) || [];
|
|
275
|
+
const validators = /* @__PURE__ */ new Map();
|
|
276
|
+
for (const vm of validatorMetas) {
|
|
277
|
+
const tag = tagByProp.get(vm.property);
|
|
278
|
+
if (tag === void 0) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
`@TlvValidate on ${dto.name}.${vm.property} but no @TlvField found for that property`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
vm.tag = tag;
|
|
284
|
+
validators.set(tag, vm.validators);
|
|
285
|
+
}
|
|
286
|
+
return { fields, validators };
|
|
287
|
+
}
|
|
288
|
+
function buildDtoDecoder(dto) {
|
|
289
|
+
const fieldMetas = Reflect.getOwnMetadata(TLV_FIELDS_KEY, dto) || [];
|
|
290
|
+
if (fieldMetas.length === 0) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
`DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
296
|
+
for (const m of fieldMetas) {
|
|
297
|
+
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
298
|
+
}
|
|
299
|
+
return (bodyBytes) => {
|
|
300
|
+
const tlvMap2 = decodeTLVs(new Uint8Array(bodyBytes));
|
|
301
|
+
const result = {};
|
|
302
|
+
for (const [tag, raw] of tlvMap2) {
|
|
303
|
+
const meta = tagMap.get(tag);
|
|
304
|
+
if (!meta) continue;
|
|
305
|
+
switch (meta.kind) {
|
|
306
|
+
case "utf8":
|
|
307
|
+
result[meta.property] = new TextDecoder().decode(raw);
|
|
308
|
+
break;
|
|
309
|
+
case "u64": {
|
|
310
|
+
let n = 0n;
|
|
311
|
+
for (let i = 0; i < raw.length; i++) {
|
|
312
|
+
n = n << 8n | BigInt(raw[i]);
|
|
313
|
+
}
|
|
314
|
+
result[meta.property] = n;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
case "bytes":
|
|
318
|
+
case "bytes16":
|
|
319
|
+
result[meta.property] = raw;
|
|
320
|
+
break;
|
|
321
|
+
case "bool":
|
|
322
|
+
result[meta.property] = raw.length > 0 && raw[0] !== 0;
|
|
323
|
+
break;
|
|
324
|
+
case "obj":
|
|
325
|
+
case "arr":
|
|
326
|
+
result[meta.property] = JSON.parse(new TextDecoder().decode(raw));
|
|
327
|
+
break;
|
|
328
|
+
default:
|
|
329
|
+
result[meta.property] = raw;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return result;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/base/axis-tlv.dto.ts
|
|
337
|
+
var AxisTlvDto = class {
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/base/axis-id.dto.ts
|
|
341
|
+
var AxisIdDto = class extends AxisTlvDto {
|
|
342
|
+
};
|
|
343
|
+
__decorateClass([
|
|
344
|
+
TlvField(1, { kind: "utf8", required: true, maxLen: 128 }),
|
|
345
|
+
TlvMinLen(1, "id must not be empty")
|
|
346
|
+
], AxisIdDto.prototype, "id", 2);
|
|
347
|
+
|
|
348
|
+
// src/base/axis-partial-type.ts
|
|
349
|
+
import "reflect-metadata";
|
|
350
|
+
function AxisPartialType(BaseDto) {
|
|
351
|
+
class PartialDto extends BaseDto {
|
|
352
|
+
}
|
|
353
|
+
const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
|
|
354
|
+
const partialFields = fields.map((f) => ({
|
|
355
|
+
property: f.property,
|
|
356
|
+
tag: f.tag,
|
|
357
|
+
options: { ...f.options, required: false }
|
|
358
|
+
}));
|
|
359
|
+
Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
360
|
+
const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
361
|
+
if (validators.length > 0) {
|
|
362
|
+
Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
363
|
+
}
|
|
364
|
+
Object.defineProperty(PartialDto, "name", {
|
|
365
|
+
value: `Partial${BaseDto.name}`
|
|
366
|
+
});
|
|
367
|
+
return PartialDto;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/base/axis-response.dto.ts
|
|
371
|
+
var RESPONSE_TAG_ID = 1;
|
|
372
|
+
var RESPONSE_TAG_CREATED_AT = 2;
|
|
373
|
+
var RESPONSE_TAG_UPDATED_AT = 3;
|
|
374
|
+
var RESPONSE_TAG_CREATED_BY = 4;
|
|
375
|
+
var RESPONSE_TAG_UPDATED_BY = 5;
|
|
376
|
+
var AxisResponseDto = class extends AxisTlvDto {
|
|
377
|
+
};
|
|
378
|
+
__decorateClass([
|
|
379
|
+
TlvField(RESPONSE_TAG_ID, { kind: "utf8" })
|
|
380
|
+
], AxisResponseDto.prototype, "id", 2);
|
|
381
|
+
__decorateClass([
|
|
382
|
+
TlvField(RESPONSE_TAG_CREATED_AT, { kind: "u64" })
|
|
383
|
+
], AxisResponseDto.prototype, "created_at", 2);
|
|
384
|
+
__decorateClass([
|
|
385
|
+
TlvField(RESPONSE_TAG_UPDATED_AT, { kind: "u64" })
|
|
386
|
+
], AxisResponseDto.prototype, "updated_at", 2);
|
|
387
|
+
__decorateClass([
|
|
388
|
+
TlvField(RESPONSE_TAG_CREATED_BY, { kind: "utf8" })
|
|
389
|
+
], AxisResponseDto.prototype, "created_by", 2);
|
|
390
|
+
__decorateClass([
|
|
391
|
+
TlvField(RESPONSE_TAG_UPDATED_BY, { kind: "utf8" })
|
|
392
|
+
], AxisResponseDto.prototype, "updated_by", 2);
|
|
393
|
+
|
|
48
394
|
// src/engine/intent.router.ts
|
|
49
395
|
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
50
396
|
var IntentRouter = class {
|
|
@@ -285,139 +631,6 @@ var ERR_BAD_SIGNATURE = "BAD_SIGNATURE";
|
|
|
285
631
|
var ERR_REPLAY_DETECTED = "REPLAY_DETECTED";
|
|
286
632
|
var ERR_CONTRACT_VIOLATION = "CONTRACT_VIOLATION";
|
|
287
633
|
|
|
288
|
-
// src/core/varint.ts
|
|
289
|
-
function encodeVarint(value) {
|
|
290
|
-
if (value < 0) throw new Error("Varint must be unsigned");
|
|
291
|
-
const bytes2 = [];
|
|
292
|
-
while (true) {
|
|
293
|
-
const byte = value & 127;
|
|
294
|
-
value >>>= 7;
|
|
295
|
-
if (value === 0) {
|
|
296
|
-
bytes2.push(byte);
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
bytes2.push(byte | 128);
|
|
300
|
-
}
|
|
301
|
-
return new Uint8Array(bytes2);
|
|
302
|
-
}
|
|
303
|
-
function decodeVarint(buf, offset = 0) {
|
|
304
|
-
let value = 0;
|
|
305
|
-
let shift = 0;
|
|
306
|
-
let length = 0;
|
|
307
|
-
while (true) {
|
|
308
|
-
if (offset + length >= buf.length) {
|
|
309
|
-
throw new Error("Varint decode out of bounds");
|
|
310
|
-
}
|
|
311
|
-
const byte = buf[offset + length];
|
|
312
|
-
value += (byte & 127) * Math.pow(2, shift);
|
|
313
|
-
length++;
|
|
314
|
-
shift += 7;
|
|
315
|
-
if ((byte & 128) === 0) {
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
if (length > 8) throw new Error("Varint too large");
|
|
319
|
-
}
|
|
320
|
-
return { value, length };
|
|
321
|
-
}
|
|
322
|
-
function varintLength(value) {
|
|
323
|
-
if (value < 0) throw new Error("Varint must be unsigned");
|
|
324
|
-
let len = 0;
|
|
325
|
-
do {
|
|
326
|
-
value >>>= 7;
|
|
327
|
-
len++;
|
|
328
|
-
} while (value !== 0);
|
|
329
|
-
return len;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// src/core/tlv.ts
|
|
333
|
-
function encodeTLVs(tlvs) {
|
|
334
|
-
const sorted = [...tlvs].sort((a, b) => a.type - b.type);
|
|
335
|
-
for (let i = 0; i < sorted.length - 1; i++) {
|
|
336
|
-
if (sorted[i].type === sorted[i + 1].type) {
|
|
337
|
-
throw new Error(`Duplicate TLV type: ${sorted[i].type}`);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
let totalSize = 0;
|
|
341
|
-
for (const t of sorted) {
|
|
342
|
-
totalSize += varintLength(t.type);
|
|
343
|
-
totalSize += varintLength(t.value.length);
|
|
344
|
-
totalSize += t.value.length;
|
|
345
|
-
}
|
|
346
|
-
const buf = new Uint8Array(totalSize);
|
|
347
|
-
let offset = 0;
|
|
348
|
-
for (const t of sorted) {
|
|
349
|
-
const typeBytes = encodeVarint(t.type);
|
|
350
|
-
buf.set(typeBytes, offset);
|
|
351
|
-
offset += typeBytes.length;
|
|
352
|
-
const lenBytes = encodeVarint(t.value.length);
|
|
353
|
-
buf.set(lenBytes, offset);
|
|
354
|
-
offset += lenBytes.length;
|
|
355
|
-
buf.set(t.value, offset);
|
|
356
|
-
offset += t.value.length;
|
|
357
|
-
}
|
|
358
|
-
return buf;
|
|
359
|
-
}
|
|
360
|
-
function decodeTLVsList(buf, maxItems = 1024) {
|
|
361
|
-
const list = [];
|
|
362
|
-
let offset = 0;
|
|
363
|
-
while (offset < buf.length) {
|
|
364
|
-
if (list.length >= maxItems) throw new Error("TLV_LIMIT");
|
|
365
|
-
const { value: type, length: typeLen } = decodeVarint(buf, offset);
|
|
366
|
-
offset += typeLen;
|
|
367
|
-
const { value: len, length: lenLen } = decodeVarint(buf, offset);
|
|
368
|
-
offset += lenLen;
|
|
369
|
-
if (offset + len > buf.length) {
|
|
370
|
-
throw new Error(`TLV violation: Length ${len} exceeds buffer`);
|
|
371
|
-
}
|
|
372
|
-
const value = buf.slice(offset, offset + len);
|
|
373
|
-
list.push({ type, value });
|
|
374
|
-
offset += len;
|
|
375
|
-
}
|
|
376
|
-
return list;
|
|
377
|
-
}
|
|
378
|
-
function decodeTLVs(buf) {
|
|
379
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
380
|
-
let offset = 0;
|
|
381
|
-
let lastType = -1;
|
|
382
|
-
while (offset < buf.length) {
|
|
383
|
-
const { value: type, length: typeLen } = decodeVarint(buf, offset);
|
|
384
|
-
offset += typeLen;
|
|
385
|
-
if (type <= lastType) {
|
|
386
|
-
throw new Error(
|
|
387
|
-
`TLV violation: Unsorted or duplicate type ${type} after ${lastType}`
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
lastType = type;
|
|
391
|
-
const { value: len, length: lenLen } = decodeVarint(buf, offset);
|
|
392
|
-
offset += lenLen;
|
|
393
|
-
if (offset + len > buf.length) {
|
|
394
|
-
throw new Error(`TLV violation: Length ${len} exceeds buffer`);
|
|
395
|
-
}
|
|
396
|
-
const value = buf.slice(offset, offset + len);
|
|
397
|
-
map2.set(type, value);
|
|
398
|
-
offset += len;
|
|
399
|
-
}
|
|
400
|
-
return map2;
|
|
401
|
-
}
|
|
402
|
-
function decodeObject(bytes2, depth = 0, limits = { maxDepth: 8, maxItems: 128 }) {
|
|
403
|
-
if (depth > limits.maxDepth) {
|
|
404
|
-
throw new Error("OBJECT_DEPTH_EXCEEDED");
|
|
405
|
-
}
|
|
406
|
-
const map2 = decodeTLVs(bytes2);
|
|
407
|
-
return map2;
|
|
408
|
-
}
|
|
409
|
-
function decodeArray(bytes2, itemType, maxItems = 256) {
|
|
410
|
-
const list = decodeTLVsList(bytes2, maxItems);
|
|
411
|
-
const items = [];
|
|
412
|
-
for (const tlv2 of list) {
|
|
413
|
-
if (tlv2.type !== itemType) {
|
|
414
|
-
throw new Error(`INVALID_ARRAY_ITEM:${tlv2.type}`);
|
|
415
|
-
}
|
|
416
|
-
items.push(tlv2.value);
|
|
417
|
-
}
|
|
418
|
-
return items;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
634
|
// src/core/signature.ts
|
|
422
635
|
import * as crypto from "crypto";
|
|
423
636
|
|
|
@@ -2189,7 +2402,11 @@ export {
|
|
|
2189
2402
|
AXIS_VERSION,
|
|
2190
2403
|
ats1_exports as Ats1Codec,
|
|
2191
2404
|
AxisFrameZ,
|
|
2405
|
+
AxisIdDto,
|
|
2192
2406
|
T as AxisPacketTags,
|
|
2407
|
+
AxisPartialType,
|
|
2408
|
+
AxisResponseDto,
|
|
2409
|
+
AxisTlvDto,
|
|
2193
2410
|
BodyProfile,
|
|
2194
2411
|
CAPABILITIES,
|
|
2195
2412
|
ContractViolationError,
|
|
@@ -2207,6 +2424,7 @@ export {
|
|
|
2207
2424
|
FLAG_HAS_WITNESS,
|
|
2208
2425
|
HANDLER_METADATA_KEY,
|
|
2209
2426
|
Handler,
|
|
2427
|
+
INTENT_METADATA_KEY,
|
|
2210
2428
|
INTENT_REQUIREMENTS,
|
|
2211
2429
|
INTENT_ROUTES_KEY,
|
|
2212
2430
|
INTENT_SENSITIVITY_MAP,
|
|
@@ -2236,6 +2454,11 @@ export {
|
|
|
2236
2454
|
PROOF_NONE,
|
|
2237
2455
|
PROOF_WITNESS,
|
|
2238
2456
|
ProofType,
|
|
2457
|
+
RESPONSE_TAG_CREATED_AT,
|
|
2458
|
+
RESPONSE_TAG_CREATED_BY,
|
|
2459
|
+
RESPONSE_TAG_ID,
|
|
2460
|
+
RESPONSE_TAG_UPDATED_AT,
|
|
2461
|
+
RESPONSE_TAG_UPDATED_BY,
|
|
2239
2462
|
RiskDecision,
|
|
2240
2463
|
Schema2002_PasskeyLoginOptionsRes,
|
|
2241
2464
|
Schema2011_PasskeyLoginVerifyReq,
|
|
@@ -2250,6 +2473,7 @@ export {
|
|
|
2250
2473
|
TLV_EFFECT,
|
|
2251
2474
|
TLV_ERROR_CODE,
|
|
2252
2475
|
TLV_ERROR_MSG,
|
|
2476
|
+
TLV_FIELDS_KEY,
|
|
2253
2477
|
TLV_INDEX,
|
|
2254
2478
|
TLV_INTENT,
|
|
2255
2479
|
TLV_KID,
|
|
@@ -2273,12 +2497,20 @@ export {
|
|
|
2273
2497
|
TLV_TRACE_ID,
|
|
2274
2498
|
TLV_TS,
|
|
2275
2499
|
TLV_UPLOAD_ID,
|
|
2500
|
+
TLV_VALIDATORS_KEY,
|
|
2501
|
+
TlvEnum,
|
|
2502
|
+
TlvField,
|
|
2503
|
+
TlvMinLen,
|
|
2504
|
+
TlvRange,
|
|
2505
|
+
TlvUtf8Pattern,
|
|
2506
|
+
TlvValidate,
|
|
2276
2507
|
axis1SigningBytes,
|
|
2277
2508
|
b64urlDecode,
|
|
2278
2509
|
b64urlDecodeString,
|
|
2279
2510
|
b64urlEncode,
|
|
2280
2511
|
b64urlEncodeString,
|
|
2281
2512
|
buildAts1Hdr,
|
|
2513
|
+
buildDtoDecoder,
|
|
2282
2514
|
buildPacket,
|
|
2283
2515
|
buildReceiptHash,
|
|
2284
2516
|
buildTLVs,
|
|
@@ -2301,6 +2533,7 @@ export {
|
|
|
2301
2533
|
encodeFrame,
|
|
2302
2534
|
encodeTLVs,
|
|
2303
2535
|
encodeVarint,
|
|
2536
|
+
extractDtoSchema,
|
|
2304
2537
|
generateEd25519KeyPair,
|
|
2305
2538
|
getSignTarget,
|
|
2306
2539
|
hasScope,
|