diff --git a/package.json b/package.json index d74c57d6..35068fc8 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "release": "aegir release" }, "dependencies": { - "@libp2p/crypto": "^0.22.11", + "@libp2p/crypto": "^0.22.12", "@libp2p/interfaces": "^1.3.32", "@libp2p/logger": "^1.1.4", "@libp2p/peer-id": "^1.1.10", @@ -162,7 +162,7 @@ "p-map": "^5.3.0", "p-queue": "^7.2.0", "private-ip": "^2.3.3", - "protons-runtime": "^1.0.2", + "protons-runtime": "^1.0.4", "streaming-iterables": "^6.0.0", "timeout-abort-controller": "^3.0.0", "uint8arrays": "^3.0.0", @@ -187,7 +187,7 @@ "lodash.random": "^3.2.0", "lodash.range": "^3.2.0", "p-retry": "^5.0.0", - "protons": "^3.0.2", + "protons": "^3.0.4", "sinon": "^13.0.1", "ts-sinon": "^2.0.2", "which": "^2.0.2" diff --git a/src/message/dht.ts b/src/message/dht.ts index 7f0c0929..f46af45b 100644 --- a/src/message/dht.ts +++ b/src/message/dht.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-namespace */ import { encodeMessage, decodeMessage, message, bytes, string, enumeration, int32 } from 'protons-runtime' +import type { Codec } from 'protons-runtime' export interface Record { key?: Uint8Array @@ -12,7 +13,7 @@ export interface Record { } export namespace Record { - export const codec = () => { + export const codec = (): Codec => { return message({ 1: { name: 'key', codec: bytes, optional: true }, 2: { name: 'value', codec: bytes, optional: true }, @@ -50,11 +51,21 @@ export namespace Message { PING = 'PING' } + enum __MessageTypeValues { + PUT_VALUE = 0, + GET_VALUE = 1, + ADD_PROVIDER = 2, + GET_PROVIDERS = 3, + FIND_NODE = 4, + PING = 5 + } + export namespace MessageType { export const codec = () => { - return enumeration(MessageType) + return enumeration(__MessageTypeValues) } } + export enum ConnectionType { NOT_CONNECTED = 'NOT_CONNECTED', CONNECTED = 'CONNECTED', @@ -62,11 +73,19 @@ export namespace Message { CANNOT_CONNECT = 'CANNOT_CONNECT' } + enum __ConnectionTypeValues { + NOT_CONNECTED = 0, + CONNECTED = 1, + CAN_CONNECT = 2, + CANNOT_CONNECT = 3 + } + export namespace ConnectionType { export const codec = () => { - return enumeration(ConnectionType) + return enumeration(__ConnectionTypeValues) } } + export interface Peer { id?: Uint8Array addrs: Uint8Array[] @@ -74,7 +93,7 @@ export namespace Message { } export namespace Peer { - export const codec = () => { + export const codec = (): Codec => { return message({ 1: { name: 'id', codec: bytes, optional: true }, 2: { name: 'addrs', codec: bytes, repeats: true }, @@ -91,7 +110,7 @@ export namespace Message { } } - export const codec = () => { + export const codec = (): Codec => { return message({ 1: { name: 'type', codec: Message.MessageType.codec(), optional: true }, 10: { name: 'clusterLevelRaw', codec: int32, optional: true },