UNPKG

@waku/proto

Version:
443 lines 17.2 kB
/* eslint-disable import/export */ /* eslint-disable complexity */ /* eslint-disable @typescript-eslint/no-namespace */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable import/consistent-type-specifier-style */ /* eslint-disable @typescript-eslint/no-unused-vars */ import { decodeMessage, encodeMessage, MaxLengthError, message } from 'protons-runtime'; import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'; export var FilterRequest; (function (FilterRequest) { let ContentFilter; (function (ContentFilter) { let _codec; ContentFilter.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if ((obj.contentTopic != null && obj.contentTopic !== '')) { w.uint32(10); w.string(obj.contentTopic); } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { contentTopic: '' }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { obj.contentTopic = reader.string(); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; ContentFilter.encode = (obj) => { return encodeMessage(obj, ContentFilter.codec()); }; ContentFilter.decode = (buf, opts) => { return decodeMessage(buf, ContentFilter.codec(), opts); }; })(ContentFilter = FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {})); let _codec; FilterRequest.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if ((obj.subscribe != null && obj.subscribe !== false)) { w.uint32(8); w.bool(obj.subscribe); } if ((obj.topic != null && obj.topic !== '')) { w.uint32(18); w.string(obj.topic); } if (obj.contentFilters != null) { for (const value of obj.contentFilters) { w.uint32(26); FilterRequest.ContentFilter.codec().encode(value, w); } } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { subscribe: false, topic: '', contentFilters: [] }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { obj.subscribe = reader.bool(); break; } case 2: { obj.topic = reader.string(); break; } case 3: { if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) { throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements'); } obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), { limits: opts.limits?.contentFilters$ })); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; FilterRequest.encode = (obj) => { return encodeMessage(obj, FilterRequest.codec()); }; FilterRequest.decode = (buf, opts) => { return decodeMessage(buf, FilterRequest.codec(), opts); }; })(FilterRequest || (FilterRequest = {})); export var MessagePush; (function (MessagePush) { let _codec; MessagePush.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if (obj.messages != null) { for (const value of obj.messages) { w.uint32(10); WakuMessage.codec().encode(value, w); } } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { messages: [] }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) { throw new MaxLengthError('Decode error - map field "messages" had too many elements'); } obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), { limits: opts.limits?.messages$ })); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; MessagePush.encode = (obj) => { return encodeMessage(obj, MessagePush.codec()); }; MessagePush.decode = (buf, opts) => { return decodeMessage(buf, MessagePush.codec(), opts); }; })(MessagePush || (MessagePush = {})); export var FilterRpc; (function (FilterRpc) { let _codec; FilterRpc.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if ((obj.requestId != null && obj.requestId !== '')) { w.uint32(10); w.string(obj.requestId); } if (obj.request != null) { w.uint32(18); FilterRequest.codec().encode(obj.request, w); } if (obj.push != null) { w.uint32(26); MessagePush.codec().encode(obj.push, w); } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { requestId: '' }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { obj.requestId = reader.string(); break; } case 2: { obj.request = FilterRequest.codec().decode(reader, reader.uint32(), { limits: opts.limits?.request }); break; } case 3: { obj.push = MessagePush.codec().decode(reader, reader.uint32(), { limits: opts.limits?.push }); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; FilterRpc.encode = (obj) => { return encodeMessage(obj, FilterRpc.codec()); }; FilterRpc.decode = (buf, opts) => { return decodeMessage(buf, FilterRpc.codec(), opts); }; })(FilterRpc || (FilterRpc = {})); export var RateLimitProof; (function (RateLimitProof) { let _codec; RateLimitProof.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if ((obj.proof != null && obj.proof.byteLength > 0)) { w.uint32(10); w.bytes(obj.proof); } if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) { w.uint32(18); w.bytes(obj.merkleRoot); } if ((obj.epoch != null && obj.epoch.byteLength > 0)) { w.uint32(26); w.bytes(obj.epoch); } if ((obj.shareX != null && obj.shareX.byteLength > 0)) { w.uint32(34); w.bytes(obj.shareX); } if ((obj.shareY != null && obj.shareY.byteLength > 0)) { w.uint32(42); w.bytes(obj.shareY); } if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) { w.uint32(50); w.bytes(obj.nullifier); } if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) { w.uint32(58); w.bytes(obj.rlnIdentifier); } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { proof: uint8ArrayAlloc(0), merkleRoot: uint8ArrayAlloc(0), epoch: uint8ArrayAlloc(0), shareX: uint8ArrayAlloc(0), shareY: uint8ArrayAlloc(0), nullifier: uint8ArrayAlloc(0), rlnIdentifier: uint8ArrayAlloc(0) }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { obj.proof = reader.bytes(); break; } case 2: { obj.merkleRoot = reader.bytes(); break; } case 3: { obj.epoch = reader.bytes(); break; } case 4: { obj.shareX = reader.bytes(); break; } case 5: { obj.shareY = reader.bytes(); break; } case 6: { obj.nullifier = reader.bytes(); break; } case 7: { obj.rlnIdentifier = reader.bytes(); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; RateLimitProof.encode = (obj) => { return encodeMessage(obj, RateLimitProof.codec()); }; RateLimitProof.decode = (buf, opts) => { return decodeMessage(buf, RateLimitProof.codec(), opts); }; })(RateLimitProof || (RateLimitProof = {})); export var WakuMessage; (function (WakuMessage) { let _codec; WakuMessage.codec = () => { if (_codec == null) { _codec = message((obj, w, opts = {}) => { if (opts.lengthDelimited !== false) { w.fork(); } if ((obj.payload != null && obj.payload.byteLength > 0)) { w.uint32(10); w.bytes(obj.payload); } if ((obj.contentTopic != null && obj.contentTopic !== '')) { w.uint32(18); w.string(obj.contentTopic); } if (obj.version != null) { w.uint32(24); w.uint32(obj.version); } if (obj.timestamp != null) { w.uint32(80); w.sint64(obj.timestamp); } if (obj.meta != null) { w.uint32(90); w.bytes(obj.meta); } if (obj.rateLimitProof != null) { w.uint32(170); RateLimitProof.codec().encode(obj.rateLimitProof, w); } if (obj.ephemeral != null) { w.uint32(248); w.bool(obj.ephemeral); } if (opts.lengthDelimited !== false) { w.ldelim(); } }, (reader, length, opts = {}) => { const obj = { payload: uint8ArrayAlloc(0), contentTopic: '' }; const end = length == null ? reader.len : reader.pos + length; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { obj.payload = reader.bytes(); break; } case 2: { obj.contentTopic = reader.string(); break; } case 3: { obj.version = reader.uint32(); break; } case 10: { obj.timestamp = reader.sint64(); break; } case 11: { obj.meta = reader.bytes(); break; } case 21: { obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), { limits: opts.limits?.rateLimitProof }); break; } case 31: { obj.ephemeral = reader.bool(); break; } default: { reader.skipType(tag & 7); break; } } } return obj; }); } return _codec; }; WakuMessage.encode = (obj) => { return encodeMessage(obj, WakuMessage.codec()); }; WakuMessage.decode = (buf, opts) => { return decodeMessage(buf, WakuMessage.codec(), opts); }; })(WakuMessage || (WakuMessage = {})); //# sourceMappingURL=filter.js.map