@laserdata/laser-sdk 0.4.0 → 0.5.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/README.md +49 -3
- package/dist/agent/reliable-consumer.d.ts.map +1 -1
- package/dist/agent/reliable-consumer.js +5 -1
- package/dist/agent/reliable-consumer.js.map +1 -1
- package/dist/bridges/a2a.d.ts +1 -1
- package/dist/bridges/a2a.js +1 -1
- package/dist/client/capabilities.d.ts +15 -2
- package/dist/client/capabilities.d.ts.map +1 -1
- package/dist/client/capabilities.js +22 -1
- package/dist/client/capabilities.js.map +1 -1
- package/dist/client/connect-options.d.ts +5 -0
- package/dist/client/connect-options.d.ts.map +1 -0
- package/dist/client/connect-options.js +18 -0
- package/dist/client/connect-options.js.map +1 -0
- package/dist/client/errors.d.ts +23 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +34 -0
- package/dist/client/errors.js.map +1 -1
- package/dist/client/laser.d.ts +17 -1
- package/dist/client/laser.d.ts.map +1 -1
- package/dist/client/laser.js +96 -26
- package/dist/client/laser.js.map +1 -1
- package/dist/client/managed.d.ts +1 -0
- package/dist/client/managed.d.ts.map +1 -1
- package/dist/client/managed.js +15 -2
- package/dist/client/managed.js.map +1 -1
- package/dist/iggy/apache-iggy.d.ts +69 -4
- package/dist/iggy/apache-iggy.d.ts.map +1 -1
- package/dist/iggy/apache-iggy.js +416 -23
- package/dist/iggy/apache-iggy.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/managed/filters.d.ts +358 -0
- package/dist/managed/filters.d.ts.map +1 -0
- package/dist/managed/filters.js +1913 -0
- package/dist/managed/filters.js.map +1 -0
- package/dist/stream/consumer.d.ts +11 -1
- package/dist/stream/consumer.d.ts.map +1 -1
- package/dist/stream/consumer.js +82 -9
- package/dist/stream/consumer.js.map +1 -1
- package/dist/stream/stream.d.ts +4 -1
- package/dist/stream/stream.d.ts.map +1 -1
- package/dist/stream/stream.js +11 -1
- package/dist/stream/stream.js.map +1 -1
- package/dist/stream/topic.d.ts +2 -0
- package/dist/stream/topic.d.ts.map +1 -1
- package/dist/stream/topic.js +6 -0
- package/dist/stream/topic.js.map +1 -1
- package/dist/wire/authz.d.ts +1 -1
- package/dist/wire/authz.d.ts.map +1 -1
- package/dist/wire/authz.js +12 -3
- package/dist/wire/authz.js.map +1 -1
- package/dist/wire/codes.d.ts +17 -0
- package/dist/wire/codes.d.ts.map +1 -1
- package/dist/wire/codes.js +17 -0
- package/dist/wire/codes.js.map +1 -1
- package/dist/wire/commands.d.ts +12 -1
- package/dist/wire/commands.d.ts.map +1 -1
- package/dist/wire/commands.js +13 -1
- package/dist/wire/commands.js.map +1 -1
- package/dist/wire/control.d.ts +4 -0
- package/dist/wire/control.d.ts.map +1 -1
- package/dist/wire/control.js +5 -0
- package/dist/wire/control.js.map +1 -1
- package/dist/wire/filter-codecs.d.ts +16 -0
- package/dist/wire/filter-codecs.d.ts.map +1 -0
- package/dist/wire/filter-codecs.js +519 -0
- package/dist/wire/filter-codecs.js.map +1 -0
- package/dist/wire/filter-eval.d.ts +75 -0
- package/dist/wire/filter-eval.d.ts.map +1 -0
- package/dist/wire/filter-eval.js +899 -0
- package/dist/wire/filter-eval.js.map +1 -0
- package/dist/wire/filter.d.ts +772 -0
- package/dist/wire/filter.d.ts.map +1 -0
- package/dist/wire/filter.js +2869 -0
- package/dist/wire/filter.js.map +1 -0
- package/dist/wire/hello.d.ts +18 -0
- package/dist/wire/hello.d.ts.map +1 -1
- package/dist/wire/hello.js +29 -3
- package/dist/wire/hello.js.map +1 -1
- package/dist/wire/http.d.ts +22 -0
- package/dist/wire/http.d.ts.map +1 -1
- package/dist/wire/http.js +54 -47
- package/dist/wire/http.js.map +1 -1
- package/dist/wire/limits.d.ts +25 -0
- package/dist/wire/limits.d.ts.map +1 -1
- package/dist/wire/limits.js +25 -0
- package/dist/wire/limits.js.map +1 -1
- package/dist/wire/result.d.ts +4 -0
- package/dist/wire/result.d.ts.map +1 -1
- package/dist/wire/result.js +50 -0
- package/dist/wire/result.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import { MAX_FILTER_SCHEMA_BYTES, MAX_FILTER_SCHEMA_DEPTH } from "./limits.js";
|
|
2
|
+
import avro from "avsc";
|
|
3
|
+
import protobuf from "protobufjs";
|
|
4
|
+
import "protobufjs/ext/descriptor.js";
|
|
5
|
+
import { InvalidError } from "../client/errors.js";
|
|
6
|
+
import { toNodeBuffer } from "../iggy/apache-iggy.js";
|
|
7
|
+
import { parseCanonicalJson } from "./filter.js";
|
|
8
|
+
const UTF8_STRICT = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
9
|
+
export class PayloadFault extends Error {
|
|
10
|
+
reason;
|
|
11
|
+
constructor(reason) {
|
|
12
|
+
super(`the payload does not decode: ${reason}`);
|
|
13
|
+
this.reason = reason;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const exactLong = avro.types.LongType.__with({
|
|
17
|
+
fromBuffer(value) {
|
|
18
|
+
return new DataView(value.buffer, value.byteOffset, value.byteLength).getBigInt64(0, true);
|
|
19
|
+
},
|
|
20
|
+
toBuffer(value) {
|
|
21
|
+
const bytes = new Uint8Array(8);
|
|
22
|
+
new DataView(bytes.buffer).setBigInt64(0, value, true);
|
|
23
|
+
return toNodeBuffer(bytes);
|
|
24
|
+
},
|
|
25
|
+
fromJSON(value) {
|
|
26
|
+
return BigInt(value);
|
|
27
|
+
},
|
|
28
|
+
toJSON(value) {
|
|
29
|
+
return value.toString();
|
|
30
|
+
},
|
|
31
|
+
isValid(value) {
|
|
32
|
+
return typeof value === "bigint" && value >= -(1n << 63n) && value < 1n << 63n;
|
|
33
|
+
},
|
|
34
|
+
compare(left, right) {
|
|
35
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
/** Immutable writer schemas prepared before scanning or local evaluation. */
|
|
39
|
+
export class PayloadDecoders {
|
|
40
|
+
filter;
|
|
41
|
+
schemas = new Map();
|
|
42
|
+
constructor(filter, schemas) {
|
|
43
|
+
this.filter = filter;
|
|
44
|
+
for (const id of filter.schemaRefs) {
|
|
45
|
+
const found = schemas.find((schema) => schema.id === id);
|
|
46
|
+
if (found === undefined)
|
|
47
|
+
throw new InvalidError(`writer schema ${String(id)} was not supplied`);
|
|
48
|
+
if (found.source.kind !== filter.codec)
|
|
49
|
+
throw new InvalidError(`writer schema ${String(id)} does not match codec ${filter.codec}`);
|
|
50
|
+
try {
|
|
51
|
+
switch (found.source.kind) {
|
|
52
|
+
case "avro": {
|
|
53
|
+
if (new TextEncoder().encode(found.source.schema).byteLength > MAX_FILTER_SCHEMA_BYTES)
|
|
54
|
+
throw new InvalidError("writer schema exceeds 1 MiB");
|
|
55
|
+
parseCanonicalJson(found.source.schema, "payload");
|
|
56
|
+
const source = JSON.parse(found.source.schema);
|
|
57
|
+
const pending = [[source, 1]];
|
|
58
|
+
while (pending.length > 0) {
|
|
59
|
+
const entry = pending.pop();
|
|
60
|
+
if (entry === undefined)
|
|
61
|
+
break;
|
|
62
|
+
const [value, depth] = entry;
|
|
63
|
+
if (value !== null && typeof value === "object") {
|
|
64
|
+
if (depth > MAX_FILTER_SCHEMA_DEPTH)
|
|
65
|
+
throw new InvalidError("writer schema exceeds depth 64");
|
|
66
|
+
for (const child of Object.values(value))
|
|
67
|
+
pending.push([child, depth + 1]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const schema = avro.Type.forSchema(source, {
|
|
71
|
+
wrapUnions: true,
|
|
72
|
+
typeHook: (schema) => schema === "long" ||
|
|
73
|
+
(typeof schema === "object" &&
|
|
74
|
+
!Array.isArray(schema) &&
|
|
75
|
+
"type" in schema &&
|
|
76
|
+
schema.type === "long")
|
|
77
|
+
? exactLong
|
|
78
|
+
: undefined
|
|
79
|
+
});
|
|
80
|
+
this.schemas.set(id, { kind: "avro", schema });
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case "protobuf": {
|
|
84
|
+
if (found.source.descriptorSet.byteLength > MAX_FILTER_SCHEMA_BYTES)
|
|
85
|
+
throw new InvalidError("writer schema exceeds 1 MiB");
|
|
86
|
+
const root = protobuf.Root.fromDescriptor(found.source.descriptorSet);
|
|
87
|
+
const schema = root.lookupType(found.source.messageType.replace(/^\./, ""));
|
|
88
|
+
schema.resolveAll();
|
|
89
|
+
this.schemas.set(id, { kind: "protobuf", schema });
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "unknown":
|
|
93
|
+
throw new InvalidError(`writer schema ${String(id)} has no payload decoder`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (cause) {
|
|
97
|
+
throw new InvalidError(`writer schema ${String(id)} does not compile`, undefined, { cause });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
decode(record, limits) {
|
|
102
|
+
try {
|
|
103
|
+
if (record.payload.byteLength > limits.maxPayloadBytes)
|
|
104
|
+
throw new PayloadFault("too_large");
|
|
105
|
+
const input = new Input(record.payload, limits);
|
|
106
|
+
if (this.filter.codec === "cbor") {
|
|
107
|
+
const value = input.cbor(0);
|
|
108
|
+
input.finish();
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
const header = record.headers.findLast((header) => header.key === "agdx.sid");
|
|
112
|
+
if (header?.value.kind !== "uint" || header.value.value > 0xffffffffn)
|
|
113
|
+
throw new PayloadFault("missing_schema");
|
|
114
|
+
const schema = this.schemas.get(Number(header.value.value));
|
|
115
|
+
if (schema === undefined)
|
|
116
|
+
throw new PayloadFault("schema_not_allowed");
|
|
117
|
+
if (schema.kind !== this.filter.codec)
|
|
118
|
+
throw new PayloadFault("schema_mismatch");
|
|
119
|
+
if (schema.kind === "avro") {
|
|
120
|
+
input.avro(schema.schema, 0);
|
|
121
|
+
input.finish();
|
|
122
|
+
return avroValue(schema.schema, schema.schema.fromBuffer(toNodeBuffer(record.payload)));
|
|
123
|
+
}
|
|
124
|
+
input.protobuf(schema.schema, 0);
|
|
125
|
+
return protoMessage(schema.schema, schema.schema.decode(record.payload));
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return error instanceof PayloadFault ? error : new PayloadFault("malformed");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function normalize(value) {
|
|
133
|
+
if (value === null ||
|
|
134
|
+
typeof value === "string" ||
|
|
135
|
+
typeof value === "boolean" ||
|
|
136
|
+
typeof value === "bigint")
|
|
137
|
+
return value;
|
|
138
|
+
if (typeof value === "number") {
|
|
139
|
+
if (!Number.isFinite(value))
|
|
140
|
+
throw new PayloadFault("malformed");
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
if (value instanceof Uint8Array)
|
|
144
|
+
return [...value].map(BigInt);
|
|
145
|
+
if (Array.isArray(value))
|
|
146
|
+
return value.map(normalize);
|
|
147
|
+
if (value instanceof Map) {
|
|
148
|
+
const entries = [];
|
|
149
|
+
for (const [key, item] of value) {
|
|
150
|
+
if (typeof key !== "string")
|
|
151
|
+
throw new PayloadFault("malformed");
|
|
152
|
+
entries.push([key, normalize(item)]);
|
|
153
|
+
}
|
|
154
|
+
return new Map(entries);
|
|
155
|
+
}
|
|
156
|
+
if (typeof value === "object")
|
|
157
|
+
return new Map(Object.entries(value).map(([key, item]) => [key, normalize(item)]));
|
|
158
|
+
throw new PayloadFault("malformed");
|
|
159
|
+
}
|
|
160
|
+
function avroValue(schema, value) {
|
|
161
|
+
switch (schema.typeName) {
|
|
162
|
+
case "int":
|
|
163
|
+
case "long":
|
|
164
|
+
case "abstract:long":
|
|
165
|
+
return BigInt(String(value));
|
|
166
|
+
case "record":
|
|
167
|
+
case "error": {
|
|
168
|
+
const values = value;
|
|
169
|
+
return new Map(schema.fields.map((field) => [
|
|
170
|
+
field.name,
|
|
171
|
+
avroValue(field.type, values[field.name])
|
|
172
|
+
]));
|
|
173
|
+
}
|
|
174
|
+
case "array":
|
|
175
|
+
return value.map((item) => avroValue(schema.itemsType, item));
|
|
176
|
+
case "map":
|
|
177
|
+
return new Map(Object.entries(value).map(([key, item]) => [
|
|
178
|
+
key,
|
|
179
|
+
avroValue(schema.valuesType, item)
|
|
180
|
+
]));
|
|
181
|
+
case "union:wrapped":
|
|
182
|
+
case "union:unwrapped": {
|
|
183
|
+
if (value === null)
|
|
184
|
+
return null;
|
|
185
|
+
const entry = Object.entries(value)[0];
|
|
186
|
+
if (entry === undefined)
|
|
187
|
+
throw new PayloadFault("malformed");
|
|
188
|
+
const [name, item] = entry;
|
|
189
|
+
const branch = schema.types.find((branch) => (branch.name ?? branch.typeName.replace(/^abstract:/, "")) === name);
|
|
190
|
+
if (branch === undefined)
|
|
191
|
+
throw new PayloadFault("malformed");
|
|
192
|
+
return avroValue(branch, item);
|
|
193
|
+
}
|
|
194
|
+
default:
|
|
195
|
+
return normalize(value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function protobufMapKey(hash, unsigned) {
|
|
199
|
+
if (hash.length !== 8)
|
|
200
|
+
throw new PayloadFault("malformed");
|
|
201
|
+
let value = 0n;
|
|
202
|
+
for (let index = 0; index < hash.length; index += 1) {
|
|
203
|
+
const byte = hash.charCodeAt(index);
|
|
204
|
+
if (byte > 255)
|
|
205
|
+
throw new PayloadFault("malformed");
|
|
206
|
+
value |= BigInt(byte) << BigInt(index * 8);
|
|
207
|
+
}
|
|
208
|
+
return (unsigned ? value : BigInt.asIntN(64, value)).toString();
|
|
209
|
+
}
|
|
210
|
+
function protoMessage(schema, message) {
|
|
211
|
+
const result = new Map();
|
|
212
|
+
const values = message;
|
|
213
|
+
for (const field of schema.fieldsArray) {
|
|
214
|
+
if (!Object.hasOwn(values, field.name)) {
|
|
215
|
+
if (field.required)
|
|
216
|
+
throw new PayloadFault("malformed");
|
|
217
|
+
if (field.hasPresence ||
|
|
218
|
+
(!field.map && !field.repeated && field.resolvedType instanceof protobuf.Type))
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const value = values[field.name];
|
|
222
|
+
const scalar = (value) => {
|
|
223
|
+
if (field.resolvedType instanceof protobuf.Type)
|
|
224
|
+
return protoMessage(field.resolvedType, value);
|
|
225
|
+
if (["int64", "sint64", "uint64", "fixed64", "sfixed64"].includes(field.type))
|
|
226
|
+
return BigInt(String(value));
|
|
227
|
+
if (field.resolvedType instanceof protobuf.Enum ||
|
|
228
|
+
["int32", "sint32", "uint32", "fixed32", "sfixed32"].includes(field.type))
|
|
229
|
+
return BigInt(String(value));
|
|
230
|
+
return normalize(value);
|
|
231
|
+
};
|
|
232
|
+
const lowered = field.map
|
|
233
|
+
? new Map(Object.entries(value).map(([key, item]) => [
|
|
234
|
+
field instanceof protobuf.MapField &&
|
|
235
|
+
["int64", "sint64", "uint64", "fixed64", "sfixed64"].includes(field.keyType)
|
|
236
|
+
? protobufMapKey(key, ["uint64", "fixed64"].includes(field.keyType))
|
|
237
|
+
: key,
|
|
238
|
+
scalar(item)
|
|
239
|
+
]))
|
|
240
|
+
: field.repeated
|
|
241
|
+
? value.map(scalar)
|
|
242
|
+
: scalar(value);
|
|
243
|
+
// A field without presence tracking (a proto3 scalar or any repeated
|
|
244
|
+
// field) is always part of the message, at its default when the bytes
|
|
245
|
+
// omit it, as in Rust.
|
|
246
|
+
result.set(field.name, lowered);
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
class Input {
|
|
251
|
+
bytes;
|
|
252
|
+
limits;
|
|
253
|
+
position = 0;
|
|
254
|
+
remaining;
|
|
255
|
+
constructor(bytes, limits) {
|
|
256
|
+
this.bytes = bytes;
|
|
257
|
+
this.limits = limits;
|
|
258
|
+
this.remaining = Math.max(1, limits.maxPayloadBytes);
|
|
259
|
+
}
|
|
260
|
+
finish() {
|
|
261
|
+
if (this.position !== this.bytes.length)
|
|
262
|
+
throw new PayloadFault("malformed");
|
|
263
|
+
}
|
|
264
|
+
visit(depth) {
|
|
265
|
+
if (depth > this.limits.maxDepth)
|
|
266
|
+
throw new PayloadFault("too_deep");
|
|
267
|
+
if (--this.remaining < 0)
|
|
268
|
+
throw new PayloadFault("too_large");
|
|
269
|
+
}
|
|
270
|
+
take(count) {
|
|
271
|
+
if (!Number.isSafeInteger(count) || count < 0 || count > this.bytes.length - this.position)
|
|
272
|
+
throw new PayloadFault("malformed");
|
|
273
|
+
const value = this.bytes.subarray(this.position, this.position + count);
|
|
274
|
+
this.position += count;
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
varint() {
|
|
278
|
+
let result = 0n;
|
|
279
|
+
for (let shift = 0n; shift < 70n; shift += 7n) {
|
|
280
|
+
const byte = this.take(1)[0] ?? 0;
|
|
281
|
+
if (shift === 63n && byte > 1)
|
|
282
|
+
throw new PayloadFault("malformed");
|
|
283
|
+
result |= BigInt(byte & 127) << shift;
|
|
284
|
+
if (byte < 128)
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
throw new PayloadFault("malformed");
|
|
288
|
+
}
|
|
289
|
+
long() {
|
|
290
|
+
const value = this.varint();
|
|
291
|
+
return (value >> 1n) ^ -(value & 1n);
|
|
292
|
+
}
|
|
293
|
+
sized(text = false) {
|
|
294
|
+
const bytes = this.take(Number(this.long()));
|
|
295
|
+
if (text)
|
|
296
|
+
UTF8_STRICT.decode(bytes);
|
|
297
|
+
}
|
|
298
|
+
avro(schema, depth) {
|
|
299
|
+
this.visit(depth);
|
|
300
|
+
switch (schema.typeName) {
|
|
301
|
+
case "null":
|
|
302
|
+
return;
|
|
303
|
+
case "boolean":
|
|
304
|
+
if ((this.take(1)[0] ?? 0) > 1)
|
|
305
|
+
throw new PayloadFault("malformed");
|
|
306
|
+
return;
|
|
307
|
+
case "int":
|
|
308
|
+
case "long":
|
|
309
|
+
case "abstract:long":
|
|
310
|
+
case "enum":
|
|
311
|
+
this.long();
|
|
312
|
+
return;
|
|
313
|
+
case "float":
|
|
314
|
+
case "double": {
|
|
315
|
+
const width = schema.typeName === "float" ? 4 : 8;
|
|
316
|
+
const bytes = this.take(width);
|
|
317
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, width);
|
|
318
|
+
if (!Number.isFinite(width === 4 ? view.getFloat32(0, true) : view.getFloat64(0, true)))
|
|
319
|
+
throw new PayloadFault("malformed");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
case "string":
|
|
323
|
+
this.sized(true);
|
|
324
|
+
return;
|
|
325
|
+
case "bytes":
|
|
326
|
+
this.sized();
|
|
327
|
+
return;
|
|
328
|
+
case "fixed":
|
|
329
|
+
this.take(schema.size);
|
|
330
|
+
return;
|
|
331
|
+
case "record":
|
|
332
|
+
case "error":
|
|
333
|
+
for (const field of schema.fields)
|
|
334
|
+
this.avro(field.type, depth + 1);
|
|
335
|
+
return;
|
|
336
|
+
case "union:unwrapped":
|
|
337
|
+
case "union:wrapped": {
|
|
338
|
+
const variant = schema.types[Number(this.long())];
|
|
339
|
+
if (variant === undefined)
|
|
340
|
+
throw new PayloadFault("malformed");
|
|
341
|
+
this.avro(variant, depth + 1);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
case "array":
|
|
345
|
+
case "map": {
|
|
346
|
+
const item = schema.typeName === "array"
|
|
347
|
+
? schema.itemsType
|
|
348
|
+
: schema.valuesType;
|
|
349
|
+
for (;;) {
|
|
350
|
+
let count = this.long();
|
|
351
|
+
if (count === 0n)
|
|
352
|
+
return;
|
|
353
|
+
const size = count < 0n ? Number(this.long()) : undefined;
|
|
354
|
+
const end = size === undefined ? undefined : this.position + size;
|
|
355
|
+
if (count < 0n)
|
|
356
|
+
count = -count;
|
|
357
|
+
if (count > BigInt(this.remaining))
|
|
358
|
+
throw new PayloadFault("too_large");
|
|
359
|
+
for (let index = 0n; index < count; index += 1n) {
|
|
360
|
+
if (schema.typeName === "map")
|
|
361
|
+
this.sized(true);
|
|
362
|
+
this.avro(item, depth + 1);
|
|
363
|
+
}
|
|
364
|
+
if (end !== undefined && this.position !== end)
|
|
365
|
+
throw new PayloadFault("malformed");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
throw new PayloadFault("schema_mismatch");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
protobuf(schema, depth, mapValue) {
|
|
373
|
+
this.visit(depth);
|
|
374
|
+
while (this.position < this.bytes.length) {
|
|
375
|
+
const key = this.varint();
|
|
376
|
+
const number = Number(key >> 3n);
|
|
377
|
+
if (number <= 0 || number > 0x1fffffff)
|
|
378
|
+
throw new PayloadFault("malformed");
|
|
379
|
+
const wire = Number(key & 7n);
|
|
380
|
+
const declared = mapValue === undefined ? schema.fieldsById[number] : undefined;
|
|
381
|
+
if (declared !== undefined) {
|
|
382
|
+
const expected = declared.map ||
|
|
383
|
+
declared.resolvedType instanceof protobuf.Type ||
|
|
384
|
+
["string", "bytes"].includes(declared.type)
|
|
385
|
+
? 2
|
|
386
|
+
: ["double", "fixed64", "sfixed64"].includes(declared.type)
|
|
387
|
+
? 1
|
|
388
|
+
: ["float", "fixed32", "sfixed32"].includes(declared.type)
|
|
389
|
+
? 5
|
|
390
|
+
: 0;
|
|
391
|
+
if (wire !== expected && !(declared.repeated && expected !== 2 && wire === 2))
|
|
392
|
+
throw new PayloadFault("malformed");
|
|
393
|
+
}
|
|
394
|
+
switch (wire) {
|
|
395
|
+
case 0:
|
|
396
|
+
this.varint();
|
|
397
|
+
break;
|
|
398
|
+
case 1:
|
|
399
|
+
this.take(8);
|
|
400
|
+
break;
|
|
401
|
+
case 5:
|
|
402
|
+
this.take(4);
|
|
403
|
+
break;
|
|
404
|
+
case 2: {
|
|
405
|
+
const bytes = this.take(Number(this.varint()));
|
|
406
|
+
const field = declared;
|
|
407
|
+
if (field?.type === "string" ||
|
|
408
|
+
(mapValue !== undefined &&
|
|
409
|
+
((number === 1 &&
|
|
410
|
+
mapValue instanceof protobuf.MapField &&
|
|
411
|
+
mapValue.keyType === "string") ||
|
|
412
|
+
(number === 2 && mapValue.type === "string"))))
|
|
413
|
+
UTF8_STRICT.decode(bytes);
|
|
414
|
+
const nested = mapValue !== undefined
|
|
415
|
+
? number === 2 && mapValue.resolvedType instanceof protobuf.Type
|
|
416
|
+
? mapValue.resolvedType
|
|
417
|
+
: undefined
|
|
418
|
+
: field?.map
|
|
419
|
+
? schema
|
|
420
|
+
: field?.resolvedType instanceof protobuf.Type
|
|
421
|
+
? field.resolvedType
|
|
422
|
+
: undefined;
|
|
423
|
+
if (nested !== undefined) {
|
|
424
|
+
const child = new Input(bytes, this.limits);
|
|
425
|
+
child.remaining = this.remaining;
|
|
426
|
+
child.protobuf(nested, depth + 1, field?.map === true ? field : undefined);
|
|
427
|
+
this.remaining = child.remaining;
|
|
428
|
+
}
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
default:
|
|
432
|
+
throw new PayloadFault("malformed");
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
cbor(depth) {
|
|
437
|
+
this.visit(depth);
|
|
438
|
+
const head = this.take(1)[0] ?? 0;
|
|
439
|
+
const major = head >> 5;
|
|
440
|
+
const info = head & 31;
|
|
441
|
+
if (major === 6 || info === 31)
|
|
442
|
+
throw new PayloadFault("malformed");
|
|
443
|
+
let value = BigInt(info);
|
|
444
|
+
if (info >= 24) {
|
|
445
|
+
if (info > 27)
|
|
446
|
+
throw new PayloadFault("malformed");
|
|
447
|
+
value = 0n;
|
|
448
|
+
for (const byte of this.take(2 ** (info - 24)))
|
|
449
|
+
value = (value << 8n) | BigInt(byte);
|
|
450
|
+
}
|
|
451
|
+
switch (major) {
|
|
452
|
+
case 0:
|
|
453
|
+
return value;
|
|
454
|
+
case 1:
|
|
455
|
+
if (value >= 1n << 63n)
|
|
456
|
+
throw new PayloadFault("malformed");
|
|
457
|
+
return -1n - value;
|
|
458
|
+
case 2:
|
|
459
|
+
return [...this.take(Number(value))].map(BigInt);
|
|
460
|
+
case 3:
|
|
461
|
+
return UTF8_STRICT.decode(this.take(Number(value)));
|
|
462
|
+
case 4: {
|
|
463
|
+
if (value > BigInt(this.bytes.length - this.position))
|
|
464
|
+
throw new PayloadFault("malformed");
|
|
465
|
+
const items = [];
|
|
466
|
+
for (let index = 0n; index < value; index++)
|
|
467
|
+
items.push(this.cbor(depth + 1));
|
|
468
|
+
return items;
|
|
469
|
+
}
|
|
470
|
+
case 5: {
|
|
471
|
+
if (value * 2n > BigInt(this.bytes.length - this.position))
|
|
472
|
+
throw new PayloadFault("malformed");
|
|
473
|
+
const items = new Map();
|
|
474
|
+
for (let index = 0n; index < value; index++) {
|
|
475
|
+
const key = this.cbor(depth + 1);
|
|
476
|
+
if (typeof key !== "string" || items.has(key))
|
|
477
|
+
throw new PayloadFault("malformed");
|
|
478
|
+
items.set(key, this.cbor(depth + 1));
|
|
479
|
+
}
|
|
480
|
+
return items;
|
|
481
|
+
}
|
|
482
|
+
case 7: {
|
|
483
|
+
if (info === 20 || info === 21)
|
|
484
|
+
return info === 21;
|
|
485
|
+
if (info === 22 || info === 23)
|
|
486
|
+
return null;
|
|
487
|
+
let result;
|
|
488
|
+
if (info === 25) {
|
|
489
|
+
const bits = Number(value);
|
|
490
|
+
const exponent = (bits >> 10) & 31;
|
|
491
|
+
const fraction = bits & 1023;
|
|
492
|
+
result =
|
|
493
|
+
(bits & 32768 ? -1 : 1) *
|
|
494
|
+
(exponent === 0
|
|
495
|
+
? (2 ** -14 * fraction) / 1024
|
|
496
|
+
: exponent === 31
|
|
497
|
+
? fraction === 0
|
|
498
|
+
? Infinity
|
|
499
|
+
: NaN
|
|
500
|
+
: 2 ** (exponent - 15) * (1 + fraction / 1024));
|
|
501
|
+
}
|
|
502
|
+
else if (info === 26 || info === 27) {
|
|
503
|
+
const bytes = new Uint8Array(8);
|
|
504
|
+
const view = new DataView(bytes.buffer);
|
|
505
|
+
view.setBigUint64(0, value);
|
|
506
|
+
result = info === 26 ? view.getFloat32(4) : view.getFloat64(0);
|
|
507
|
+
}
|
|
508
|
+
else
|
|
509
|
+
throw new PayloadFault("malformed");
|
|
510
|
+
if (!Number.isFinite(result))
|
|
511
|
+
throw new PayloadFault("malformed");
|
|
512
|
+
return result;
|
|
513
|
+
}
|
|
514
|
+
default:
|
|
515
|
+
throw new PayloadFault("malformed");
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
//# sourceMappingURL=filter-codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-codecs.js","sourceRoot":"","sources":["../../src/wire/filter-codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,8BAA8B,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD,OAAO,EAAE,kBAAkB,EAAyC,MAAM,aAAa,CAAA;AAGvF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAE9E,MAAM,OAAO,YAAa,SAAQ,KAAK;IAChB,MAAM;IAA3B,YAAqB,MAAmB;QACtC,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;sBAD5B,MAAM;IAE3B,CAAC;CACF;AAMD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC3C,UAAU,CAAC,KAAiB;QAC1B,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,C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AC,QAAQ,CAAC,MAAM,CAAC;oBAAE,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,CAAA;gBACjE,OAAO,MAAM,CAAA;YACf,CAAC;YACD;gBACE,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PayloadFault } from "./filter-codecs.js";
|
|
2
|
+
import type { SchemaDef } from "./control.js";
|
|
3
|
+
import { type ConsumerFilter, type FaultPolicy, type FaultReason, type FilterExplanation, type FilterExpr, type FilterHeader, type TextMatch, type TextPredicate, type Verdict } from "./filter.js";
|
|
4
|
+
/** Bounds on decoding one payload, checked before the payload is parsed. */
|
|
5
|
+
export interface DecodeLimits {
|
|
6
|
+
readonly maxPayloadBytes: number;
|
|
7
|
+
readonly maxDepth: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_DECODE_LIMITS: DecodeLimits;
|
|
10
|
+
/** One record as the evaluator sees it. */
|
|
11
|
+
export interface FilterRecord {
|
|
12
|
+
readonly payload: Uint8Array;
|
|
13
|
+
readonly headers: readonly FilterHeader[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A decoded payload value. Objects are maps, integers that fit i64 or u64 are
|
|
17
|
+
* bigints, and every other number is a double, exactly as the server decodes.
|
|
18
|
+
*/
|
|
19
|
+
export type JsonValue = null | boolean | bigint | number | string | readonly JsonValue[] | ReadonlyMap<string, JsonValue>;
|
|
20
|
+
/** A validated filter compiled for repeated evaluation. Compile once, evaluate per record. */
|
|
21
|
+
export declare class CompiledFilter {
|
|
22
|
+
readonly filter: ConsumerFilter;
|
|
23
|
+
readonly digest: Uint8Array;
|
|
24
|
+
private readonly root;
|
|
25
|
+
private readonly decoders;
|
|
26
|
+
private constructor();
|
|
27
|
+
get readsHeaders(): boolean;
|
|
28
|
+
/** Whether a caller must pass the record headers: a payload filter reads agdx.ct first. */
|
|
29
|
+
get needsHeaders(): boolean;
|
|
30
|
+
static compile(filter: ConsumerFilter, schemas?: readonly SchemaDef[]): CompiledFilter;
|
|
31
|
+
get faultPolicy(): FaultPolicy;
|
|
32
|
+
get readsPayload(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the record is selected, rejected, or could not be decoded. Header
|
|
35
|
+
* predicates run before the payload is touched, and the payload is decoded at
|
|
36
|
+
* most once.
|
|
37
|
+
*/
|
|
38
|
+
evaluate(record: FilterRecord, limits?: DecodeLimits): Verdict;
|
|
39
|
+
/** The verdict and, for a fault or a policy rejection, its reason, from one decode. */
|
|
40
|
+
outcomeOf(record: FilterRecord, limits?: DecodeLimits): {
|
|
41
|
+
verdict: Verdict;
|
|
42
|
+
fault?: FaultReason;
|
|
43
|
+
};
|
|
44
|
+
/** The fault reason of a record `evaluate` judged a fault, `undefined` otherwise. */
|
|
45
|
+
faultReason(record: FilterRecord, limits?: DecodeLimits): FaultReason | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The policy a record that faulted for `reason` follows: a record in another
|
|
48
|
+
* format the foreign policy, a type mismatch the mismatch policy, a broken
|
|
49
|
+
* payload the fault policy. A `reject` record policy maps to `drop`.
|
|
50
|
+
*/
|
|
51
|
+
policyFor(reason: FaultReason): FaultPolicy;
|
|
52
|
+
/** Each node's truth, for sample tests. The verdict is the delivery verdict of `evaluate`. */
|
|
53
|
+
explain(record: FilterRecord, limits?: DecodeLimits): FilterExplanation;
|
|
54
|
+
private context;
|
|
55
|
+
private outcome;
|
|
56
|
+
}
|
|
57
|
+
export declare function usesRegex(expr: FilterExpr): boolean;
|
|
58
|
+
/** A validated text predicate ready to run per record. */
|
|
59
|
+
export declare class TextMatcher {
|
|
60
|
+
readonly kind: TextMatch;
|
|
61
|
+
readonly source: string;
|
|
62
|
+
private readonly caseInsensitive;
|
|
63
|
+
private readonly pattern;
|
|
64
|
+
private readonly glob;
|
|
65
|
+
constructor(kind: TextMatch, source: string, caseInsensitive: boolean);
|
|
66
|
+
static of(predicate: TextPredicate): TextMatcher;
|
|
67
|
+
matches(text: string): boolean;
|
|
68
|
+
label(): string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Decode a JSON payload within `limits`. The depth is checked by a scan over
|
|
72
|
+
* the raw bytes before any value is built.
|
|
73
|
+
*/
|
|
74
|
+
export declare function decodeJsonPayload(payload: Uint8Array, limits: DecodeLimits): JsonValue | PayloadFault;
|
|
75
|
+
//# sourceMappingURL=filter-eval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-eval.d.ts","sourceRoot":"","sources":["../../src/wire/filter-eval.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAEL,KAAK,cAAc,EAGnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EAGjB,KAAK,SAAS,EACd,KAAK,aAAa,EAElB,KAAK,OAAO,EAQb,MAAM,aAAa,CAAA;AAiCpB,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,YAGnC,CAAA;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;CAC1C;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GACnB,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,SAAS,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAyDnG,8FAA8F;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