From 78f3edd71d514f9b13bce413b6925d0c7123c6cf Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 19 Nov 2022 19:54:04 -0500 Subject: [PATCH] *Update dist --- dist/{dhtOnlineBase.d.ts => DHTDataBase.d.ts} | 14 ++- dist/DHTDataBase.d.ts.map | 1 + dist/{dhtOnlineBase.js => DHTDataBase.js} | 103 ++++++++++++------ dist/dhtOnlineBase.d.ts.map | 1 - dist/index.d.ts | 5 +- dist/index.d.ts.map | 2 +- dist/index.js | 10 +- dist/messages.d.ts | 18 ++- dist/messages.d.ts.map | 2 +- dist/messages.js | 38 ++++++- 10 files changed, 139 insertions(+), 55 deletions(-) rename dist/{dhtOnlineBase.d.ts => DHTDataBase.d.ts} (68%) create mode 100644 dist/DHTDataBase.d.ts.map rename dist/{dhtOnlineBase.js => DHTDataBase.js} (65%) delete mode 100644 dist/dhtOnlineBase.d.ts.map diff --git a/dist/dhtOnlineBase.d.ts b/dist/DHTDataBase.d.ts similarity index 68% rename from dist/dhtOnlineBase.d.ts rename to dist/DHTDataBase.d.ts index dc9d3d6..a9620d8 100644 --- a/dist/dhtOnlineBase.d.ts +++ b/dist/DHTDataBase.d.ts @@ -1,14 +1,14 @@ /// /// import EventEmitter from "events"; -export default class DHTOnlineBase extends EventEmitter { +export default class DHTDataBase extends EventEmitter { + protected swarm: any; private id; private bootstrapped; private graph; private connectedTo; - private encoding; - constructor(id: Buffer, { encoding }?: { - encoding?: string | undefined; + constructor(id: Buffer, { swarm }?: { + swarm?: any; }); private _data; get data(): {}; @@ -16,7 +16,11 @@ export default class DHTOnlineBase extends EventEmitter { private _online; get online(): string[]; broadcast(data: any, ttl?: number): void; + getPeerRaw(id: Buffer | string): any; + getPeerField(id: Buffer | string, field: string): any; getPeerData(id: Buffer | string): any; + getPeerTimestamp(id: Buffer | string): any; + getPeerSignature(id: Buffer | string): any; protected onAddPeer(id: Buffer): void; protected onRemovePeer(id: Buffer): void; protected onGetBroadcast(message: Buffer, id: Buffer): void; @@ -31,4 +35,4 @@ export default class DHTOnlineBase extends EventEmitter { private _recalculate; private _maybeHexify; } -//# sourceMappingURL=dhtOnlineBase.d.ts.map \ No newline at end of file +//# sourceMappingURL=DHTDataBase.d.ts.map \ No newline at end of file diff --git a/dist/DHTDataBase.d.ts.map b/dist/DHTDataBase.d.ts.map new file mode 100644 index 0000000..fec2374 --- /dev/null +++ b/dist/DHTDataBase.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DHTDataBase.d.ts","sourceRoot":"","sources":["../src/DHTDataBase.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAiBlC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,YAAY;IACnD,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,WAAW,CAAW;gBAElB,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,GAAG,CAAA;KAAO;IAavD,OAAO,CAAC,KAAK,CAAK;IAElB,IAAI,IAAI,IAAI,EAAE,CAEb;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAcjB;IAED,OAAO,CAAC,OAAO,CAAW;IAE1B,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI9B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM;IAI/C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAG/B,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIpC,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIpC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM;IAqC9B,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM;IAiBjC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAqDpD,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,cAAc;IAuCtB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,YAAY;CAOrB"} \ No newline at end of file diff --git a/dist/dhtOnlineBase.js b/dist/DHTDataBase.js similarity index 65% rename from dist/dhtOnlineBase.js rename to dist/DHTDataBase.js index 0c66758..ac6be72 100644 --- a/dist/dhtOnlineBase.js +++ b/dist/DHTDataBase.js @@ -6,16 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true }); const events_1 = __importDefault(require("events")); // @ts-ignore const jsnetworkx_1 = require("jsnetworkx"); -const codecs_1 = __importDefault(require("codecs")); +// @ts-ignore +const ordered_json_1 = __importDefault(require("ordered-json")); +// @ts-ignore +const hypercore_crypto_1 = __importDefault(require("hypercore-crypto")); +const b4a_1 = __importDefault(require("b4a")); const messages_js_1 = require("./messages.js"); -const DEFAULT_ENCODING = "json"; -class DHTOnlineBase extends events_1.default { +const debug_1 = __importDefault(require("debug")); +class DHTDataBase extends events_1.default { + swarm; id; bootstrapped; graph; connectedTo; - encoding; - constructor(id, { encoding = DEFAULT_ENCODING } = {}) { + constructor(id, { swarm } = {}) { super(); if (!id) throw new TypeError("Must provide id for self"); @@ -24,8 +28,8 @@ class DHTOnlineBase extends events_1.default { this.graph = new jsnetworkx_1.DiGraph(); this.connectedTo = new Set(); this._data = {}; - this.encoding = (0, codecs_1.default)(encoding || DEFAULT_ENCODING); this._online = [this._maybeHexify(this.id)]; + this.swarm = swarm; } _data; get data() { @@ -33,7 +37,10 @@ class DHTOnlineBase extends events_1.default { } set data(value) { this._data = value; - this._setPeer(this.id, value); + const timestamp = BigInt(Date.now()); + const rawData = ordered_json_1.default.stringify(value); + const signature = hypercore_crypto_1.default.sign(b4a_1.default.from(`${timestamp}${rawData}`), this.swarm.keyPair.secretKey); + this._setPeer(this.id, value, timestamp, signature); this._broadcastData(); } _online; @@ -43,9 +50,21 @@ class DHTOnlineBase extends events_1.default { broadcast(data, ttl) { throw new TypeError("Broadcast has not been implemented"); } - getPeerData(id) { + getPeerRaw(id) { return this.graph.node.get(this._maybeHexify(id)); } + getPeerField(id, field) { + return this.getPeerRaw(id)?.[field]; + } + getPeerData(id) { + return this.getPeerField(id, "data"); + } + getPeerTimestamp(id) { + return this.getPeerField(id, "timestamp"); + } + getPeerSignature(id) { + return this.getPeerField(id, "signature"); + } onAddPeer(id) { const stringId = id.toString("hex"); if (this.connectedTo.has(stringId)) { @@ -91,11 +110,16 @@ class DHTOnlineBase extends events_1.default { throw new Error("Missing Type In Message"); } if (type === messages_js_1.Type.STATE) { - const { data: rawData } = decoded; - const data = this.encoding.decode(rawData); - this._setPeer(id, data); - this.emit("peer-data", data, id); - this._recalculate(); + const { data: rawData, timestamp, signature } = decoded; + if (signature && + hypercore_crypto_1.default.verify(b4a_1.default.from(`${timestamp}${rawData}`), signature, id)) { + const data = rawData ? ordered_json_1.default.parse(rawData) : null; + this._setPeer(id, data, timestamp, signature); + this.emit("peer-data", data, id); + this._recalculate(); + return; + } + (0, debug_1.default)(`Invalid signature received for peer ${id}`); } else if (type === messages_js_1.Type.CONNECTED) { const { id: toId } = decoded; @@ -126,17 +150,24 @@ class DHTOnlineBase extends events_1.default { if (!Object.keys(rawData).length) { return; } - const data = this.encoding.encode(rawData); + const data = ordered_json_1.default.stringify(rawData); + const { timestamp, signature } = this.getPeerRaw(this.id); this.broadcast(messages_js_1.Message.toBinary(messages_js_1.Message.create({ type: messages_js_1.Type.STATE, - data, + data: b4a_1.default.from(data), + signature, + timestamp, }))); } _hasSeenPeer(id) { return this.graph.hasNode(this._maybeHexify(id)); } - _setPeer(id, data) { - this.graph.addNode(this._maybeHexify(id), data); + _setPeer(id, data, timestamp, signature) { + this.graph.addNode(this._maybeHexify(id), { + timestamp, + signature, + data, + }); } _ensurePeer(id) { id = this._maybeHexify(id); @@ -165,19 +196,26 @@ class DHTOnlineBase extends events_1.default { return; } for (const id in bootstrap) { - const { data, connectedTo } = bootstrap[id]; - const parsedData = data ? this.encoding.decode(data) : null; - let peerData = parsedData || {}; - if (id === this.id.toString("hex")) + const { data, connectedTo, signature, timestamp } = bootstrap[id]; + if (id === this.id.toString("hex")) { continue; - // If we're already tracking them - if (this._hasSeenPeer(id)) { - // See what data we already have for them - // Add their existing data to what we got from the bootstrap - const existingPeerData = this.getPeerData(id); - peerData = { ...existingPeerData, ...peerData }; } - this._setPeer(id, peerData); + if (signature && + hypercore_crypto_1.default.verify(b4a_1.default.from(`${timestamp}${data}`), signature, b4a_1.default.from(id))) { + const parsedData = data ? ordered_json_1.default.parse(data) : null; + let peerData = parsedData || {}; + // If we're already tracking them + if (this._hasSeenPeer(id)) { + // See what data we already have for them + // Add their existing data to what we got from the bootstrap + const existingPeerData = this.getPeerData(id); + peerData = { ...existingPeerData, ...peerData }; + this._setPeer(id, peerData, timestamp, signature); + } + } + else { + (0, debug_1.default)(`Invalid signature received for peer ${id}`); + } for (const connection of connectedTo) { this._addPeerConnection(id, Buffer.from(connection)); } @@ -191,8 +229,9 @@ class DHTOnlineBase extends events_1.default { const connectedTo = this.graph .neighbors(id) .map((id) => Buffer.from(id, "hex")); - const data = rawData ? this.encoding.encode(rawData) : null; - state[id] = { data, connectedTo }; + const data = rawData ? ordered_json_1.default.stringify(rawData?.data) : null; + const { timestamp = undefined, signature = undefined } = rawData; + state[id] = { data: b4a_1.default.from(data), connectedTo, timestamp, signature }; } return state; } @@ -217,10 +256,10 @@ class DHTOnlineBase extends events_1.default { this.emit("online", online); } _maybeHexify(data) { - if (Buffer.isBuffer(data)) { + if (b4a_1.default.isBuffer(data)) { return data.toString("hex"); } return data; } } -exports.default = DHTOnlineBase; +exports.default = DHTDataBase; diff --git a/dist/dhtOnlineBase.d.ts.map b/dist/dhtOnlineBase.d.ts.map deleted file mode 100644 index 88c119a..0000000 --- a/dist/dhtOnlineBase.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dhtOnlineBase.d.ts","sourceRoot":"","sources":["../src/dhtOnlineBase.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAYlC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,YAAY;IACrD,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,QAAQ,CAAoB;gBAExB,EAAE,EAAE,MAAM,EAAE,EAAE,QAA2B,EAAE;;KAAK;IAa5D,OAAO,CAAC,KAAK,CAAK;IAElB,IAAI,IAAI,IAAI,EAAE,CAEb;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAMjB;IAED,OAAO,CAAC,OAAO,CAAW;IAE1B,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI/B,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM;IAqC9B,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM;IAiBjC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IA6CpD,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,YAAY;CAOrB"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 56730eb..fcf8473 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,8 +1,7 @@ /// -import DHTOnlineBase from "./dhtOnlineBase.js"; -export default class DHTOnline extends DHTOnlineBase { +import DHTDataBase from "./DHTDataBase.js"; +export default class DHTData extends DHTDataBase { private flood; - private swarm; constructor(swarm: any, { id, data, ...opts }?: { id?: Buffer; data?: {}; diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index ead5631..b0179e5 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAK/C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,aAAa;IAClD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,KAAK,CAAM;gBAGjB,KAAK,EAAE,GAAG,EACV,EACE,EAA4B,EAC5B,IAAS,EACT,GAAG,IAAI,EACR,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO;IAmBxD,aAAa,CAAC,IAAI,EAAE,GAAG;IAKvB,gBAAgB,CAAC,IAAI,EAAE,GAAG;IAW1B,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM;CAGrC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,WAAW;IAC9C,OAAO,CAAC,KAAK,CAAW;gBAGtB,KAAK,EAAE,GAAG,EACV,EACE,EAA4B,EAC5B,IAAS,EACT,GAAG,IAAI,EACR,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO;IAkBxD,aAAa,CAAC,IAAI,EAAE,GAAG;IAKvB,gBAAgB,CAAC,IAAI,EAAE,GAAG;IAW1B,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM;CAGrC"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index af12c65..c1e04dc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,16 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -const dhtOnlineBase_js_1 = __importDefault(require("./dhtOnlineBase.js")); +const DHTDataBase_js_1 = __importDefault(require("./DHTDataBase.js")); const dht_flood_1 = __importDefault(require("@lumeweb/dht-flood")); const DISCONNECT_SMOOTH = 500; -class DHTOnline extends dhtOnlineBase_js_1.default { +class DHTData extends DHTDataBase_js_1.default { flood; - swarm; constructor(swarm, { id = swarm.keyPair.publicKey, data = {}, ...opts } = {}) { - super(id, opts); + super(id, { swarm, ...opts }); this.flood = new dht_flood_1.default({ id, swarm, ...opts }); - this.swarm = swarm; this.flood.on("peer-open", (peer) => this.handlePeerAdd(peer)); this.flood.on("peer-remove", (peer) => this.handlePeerRemove(peer)); this.flood.on("message", (message, id) => this.onGetBroadcast(message, id)); @@ -38,4 +36,4 @@ class DHTOnline extends dhtOnlineBase_js_1.default { this.flood.broadcast(message, ttl); } } -exports.default = DHTOnline; +exports.default = DHTData; diff --git a/dist/messages.d.ts b/dist/messages.d.ts index 5ccd512..2fd39df 100644 --- a/dist/messages.d.ts +++ b/dist/messages.d.ts @@ -23,7 +23,15 @@ export interface Message { */ data?: Uint8Array; /** - * @generated from protobuf field: optional bytes id = 4; + * @generated from protobuf field: optional bytes signature = 4; + */ + signature?: Uint8Array; + /** + * @generated from protobuf field: optional int64 timestamp = 5; + */ + timestamp?: bigint; + /** + * @generated from protobuf field: optional bytes id = 6; */ id?: Uint8Array; } @@ -39,6 +47,14 @@ export interface State { * @generated from protobuf field: optional bytes data = 2; */ data?: Uint8Array; + /** + * @generated from protobuf field: optional bytes signature = 3; + */ + signature?: Uint8Array; + /** + * @generated from protobuf field: optional int64 timestamp = 4; + */ + timestamp?: bigint; } /** * @generated from protobuf enum Type diff --git a/dist/messages.d.ts.map b/dist/messages.d.ts.map index 4d49951..4bf0559 100644 --- a/dist/messages.d.ts.map +++ b/dist/messages.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,SAAS,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;KACxB,CAAC;IACF;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,UAAU,CAAC;CACnB;AACD;;GAEG;AACH,MAAM,WAAW,KAAK;IAClB;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACrB;AACD;;GAEG;AACH,oBAAY,IAAI;IACZ;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,iBAAiB,IAAI;IACrB;;OAEG;IACH,kBAAkB,IAAI;IACtB;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,KAAK,IAAI;CACZ;AAED,cAAM,YAAa,SAAQ,WAAW,CAAC,OAAO,CAAC;;IAS3C,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;IAOhD,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IA4BhH,OAAO,CAAC,cAAc;IAgBtB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAsB3G;AACD;;GAEG;AACH,eAAO,MAAM,OAAO,cAAqB,CAAC;AAE1C,cAAM,UAAW,SAAQ,WAAW,CAAC,KAAK,CAAC;;IAOvC,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK;IAO5C,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;IAsB5G,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAYzG;AACD;;GAEG;AACH,eAAO,MAAM,KAAK,YAAmB,CAAC"} \ No newline at end of file +{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,SAAS,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;KACxB,CAAC;IACF;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,EAAE,CAAC,EAAE,UAAU,CAAC;CACnB;AACD;;GAEG;AACH,MAAM,WAAW,KAAK;IAClB;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;GAEG;AACH,oBAAY,IAAI;IACZ;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,iBAAiB,IAAI;IACrB;;OAEG;IACH,kBAAkB,IAAI;IACtB;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,KAAK,IAAI;CACZ;AAED,cAAM,YAAa,SAAQ,WAAW,CAAC,OAAO,CAAC;;IAW3C,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO;IAOhD,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAkChH,OAAO,CAAC,cAAc;IAgBtB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CA4B3G;AACD;;GAEG;AACH,eAAO,MAAM,OAAO,cAAqB,CAAC;AAE1C,cAAM,UAAW,SAAQ,WAAW,CAAC,KAAK,CAAC;;IASvC,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK;IAO5C,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;IA4B5G,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAkBzG;AACD;;GAEG;AACH,eAAO,MAAM,KAAK,YAAmB,CAAC"} \ No newline at end of file diff --git a/dist/messages.js b/dist/messages.js index 10a2520..61bd989 100644 --- a/dist/messages.js +++ b/dist/messages.js @@ -43,7 +43,9 @@ class Message$Type extends runtime_5.MessageType { { no: 1, name: "type", kind: "enum", T: () => ["Type", Type] }, { no: 2, name: "bootstrap", kind: "map", K: 9 /*ScalarType.STRING*/, V: { kind: "message", T: () => exports.State } }, { no: 3, name: "data", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ }, - { no: 4, name: "id", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ } + { no: 4, name: "signature", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ }, + { no: 5, name: "timestamp", kind: "scalar", opt: true, T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 6, name: "id", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ } ]); } create(value) { @@ -67,7 +69,13 @@ class Message$Type extends runtime_5.MessageType { case /* optional bytes data */ 3: message.data = reader.bytes(); break; - case /* optional bytes id */ 4: + case /* optional bytes signature */ 4: + message.signature = reader.bytes(); + break; + case /* optional int64 timestamp */ 5: + message.timestamp = reader.int64().toBigInt(); + break; + case /* optional bytes id */ 6: message.id = reader.bytes(); break; default: @@ -111,9 +119,15 @@ class Message$Type extends runtime_5.MessageType { /* optional bytes data = 3; */ if (message.data !== undefined) writer.tag(3, runtime_1.WireType.LengthDelimited).bytes(message.data); - /* optional bytes id = 4; */ + /* optional bytes signature = 4; */ + if (message.signature !== undefined) + writer.tag(4, runtime_1.WireType.LengthDelimited).bytes(message.signature); + /* optional int64 timestamp = 5; */ + if (message.timestamp !== undefined) + writer.tag(5, runtime_1.WireType.Varint).int64(message.timestamp); + /* optional bytes id = 6; */ if (message.id !== undefined) - writer.tag(4, runtime_1.WireType.LengthDelimited).bytes(message.id); + writer.tag(6, runtime_1.WireType.LengthDelimited).bytes(message.id); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -129,7 +143,9 @@ class State$Type extends runtime_5.MessageType { constructor() { super("State", [ { no: 1, name: "connectedTo", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ }, - { no: 2, name: "data", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ } + { no: 2, name: "data", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ }, + { no: 3, name: "signature", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ }, + { no: 4, name: "timestamp", kind: "scalar", opt: true, T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ } ]); } create(value) { @@ -150,6 +166,12 @@ class State$Type extends runtime_5.MessageType { case /* optional bytes data */ 2: message.data = reader.bytes(); break; + case /* optional bytes signature */ 3: + message.signature = reader.bytes(); + break; + case /* optional int64 timestamp */ 4: + message.timestamp = reader.int64().toBigInt(); + break; default: let u = options.readUnknownField; if (u === "throw") @@ -168,6 +190,12 @@ class State$Type extends runtime_5.MessageType { /* optional bytes data = 2; */ if (message.data !== undefined) writer.tag(2, runtime_1.WireType.LengthDelimited).bytes(message.data); + /* optional bytes signature = 3; */ + if (message.signature !== undefined) + writer.tag(3, runtime_1.WireType.LengthDelimited).bytes(message.signature); + /* optional int64 timestamp = 4; */ + if (message.timestamp !== undefined) + writer.tag(4, runtime_1.WireType.Varint).int64(message.timestamp); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);