@seriousme/opifex 1.6.0 → 1.6.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/conformanceServer.ts +1 -2
  3. package/bin/mqtt.ts +2 -3
  4. package/deno/tcpClient.ts +8 -3
  5. package/deno/tcpServer.ts +2 -2
  6. package/deno.json +2 -2
  7. package/dist/bin/conformanceServer.js +1 -2
  8. package/dist/bin/mqtt.js +1 -2
  9. package/dist/mqttPacket/AuthenticationResult.js +2 -1
  10. package/dist/mqttPacket/connack.js +1 -1
  11. package/dist/mqttPacket/connect.js +1 -1
  12. package/dist/mqttPacket/disconnect.js +1 -1
  13. package/dist/mqttPacket/mod.js +14 -14
  14. package/dist/mqttPacket/pingreq.js +1 -1
  15. package/dist/mqttPacket/pingres.js +1 -1
  16. package/dist/mqttPacket/puback.js +1 -1
  17. package/dist/mqttPacket/pubcomp.js +1 -1
  18. package/dist/mqttPacket/publish.js +1 -1
  19. package/dist/mqttPacket/pubrec.js +1 -1
  20. package/dist/mqttPacket/pubrel.js +1 -1
  21. package/dist/mqttPacket/suback.js +1 -1
  22. package/dist/mqttPacket/subscribe.js +1 -1
  23. package/dist/mqttPacket/unsuback.js +1 -1
  24. package/dist/mqttPacket/unsubscribe.js +1 -1
  25. package/mqttPacket/AuthenticationResult.ts +4 -3
  26. package/mqttPacket/PacketType.ts +1 -1
  27. package/mqttPacket/connack.ts +4 -1
  28. package/mqttPacket/connect.ts +5 -2
  29. package/mqttPacket/disconnect.ts +5 -2
  30. package/mqttPacket/mod.ts +15 -15
  31. package/mqttPacket/pingreq.ts +5 -2
  32. package/mqttPacket/pingres.ts +5 -2
  33. package/mqttPacket/puback.ts +5 -2
  34. package/mqttPacket/pubcomp.ts +5 -2
  35. package/mqttPacket/publish.ts +5 -2
  36. package/mqttPacket/pubrec.ts +5 -2
  37. package/mqttPacket/pubrel.ts +5 -2
  38. package/mqttPacket/suback.ts +5 -2
  39. package/mqttPacket/subscribe.ts +5 -2
  40. package/mqttPacket/unsuback.ts +5 -2
  41. package/mqttPacket/unsubscribe.ts +5 -2
  42. package/package.json +3 -3
  43. package/utils/mod.ts +1 -0
  44. package/utils/platform.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ### Changed
6
6
 
7
+ ## [v1.6.1] 18-01-2025
8
+
9
+ ### Changed
10
+
11
+ - fix: fixed Deno lint type errors
12
+
7
13
  ## [v1.6.0] 18-01-2025
8
14
 
9
15
  ### Changed
@@ -3,8 +3,7 @@
3
3
 
4
4
  import { AuthenticationResult } from "../server/mod.ts";
5
5
  import type { Context, TAuthenticationResult, Topic } from "../server/mod.ts";
6
- import { logger, LogLevel } from "../utils/mod.ts";
7
- import { getArgs, parseArgs } from "../utils/mod.ts";
6
+ import { getArgs, logger, LogLevel, parseArgs } from "../utils/mod.ts";
8
7
  import { TcpServer } from "../node/tcpServer.ts";
9
8
 
10
9
  const utf8Decoder = new TextDecoder();
package/bin/mqtt.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env -S node --experimental-strip-types
2
2
  import { DEFAULT_URL } from "../client/mod.ts";
3
- import { logger, LogLevel } from "../utils/mod.ts";
4
- import { getArgs, parseArgs } from "../utils/mod.ts";
5
3
  import { getFileData, TcpClient } from "../node/tcpClient.ts";
6
- import type { Args } from "../utils/args.ts";
4
+ import { getArgs, logger, LogLevel, parseArgs } from "../utils/mod.ts";
5
+ import type { Args } from "../utils/mod.ts";
7
6
 
8
7
  const client = new TcpClient();
9
8
  const encoder = new TextEncoder();
package/deno/tcpClient.ts CHANGED
@@ -4,7 +4,9 @@ import { Client } from "../client/client.ts";
4
4
  import { logger } from "../client/deps.ts";
5
5
  import type { SockConn } from "../client/deps.ts";
6
6
 
7
- export async function getFileData(filename: string | undefined) {
7
+ export async function getFileData(
8
+ filename: string | undefined,
9
+ ): Promise<string | undefined> {
8
10
  if (!filename) {
9
11
  return;
10
12
  }
@@ -16,7 +18,10 @@ export async function getFileData(filename: string | undefined) {
16
18
  }
17
19
 
18
20
  export class TcpClient extends Client {
19
- protected async connectMQTT(hostname: string, port = 1883) {
21
+ protected async connectMQTT(
22
+ hostname: string,
23
+ port = 1883,
24
+ ): Promise<Deno.TcpConn> {
20
25
  logger.debug({ hostname, port });
21
26
  return await Deno.connect({ hostname, port });
22
27
  }
@@ -27,7 +32,7 @@ export class TcpClient extends Client {
27
32
  caCerts?: string[],
28
33
  cert?: string,
29
34
  key?: string,
30
- ) {
35
+ ): Promise<Deno.TlsConn> {
31
36
  logger.debug({ hostname, port, caCerts, cert });
32
37
  return await Deno.connectTls({ hostname, port, caCerts, cert, key });
33
38
  }
package/deno/tcpServer.ts CHANGED
@@ -23,14 +23,14 @@ export class TcpServer {
23
23
  this.listener.close();
24
24
  }
25
25
 
26
- get port() {
26
+ get port(): number | undefined {
27
27
  if (this.listener.addr.transport === "tcp") {
28
28
  return this.listener.addr.port;
29
29
  }
30
30
  return undefined;
31
31
  }
32
32
 
33
- get address() {
33
+ get address(): string | undefined {
34
34
  if (this.listener.addr.transport === "tcp") {
35
35
  return this.listener.addr.hostname;
36
36
  }
package/deno.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@seriousme/opifex",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "exports": {
5
5
  "./server": "./server/mod.ts",
6
6
  "./client": "./client/mod.ts",
7
7
  "./mqttPacket": "./mqttPacket/mod.ts",
8
- "./utils": "./utils/mod.ts,",
8
+ "./utils": "./utils/mod.ts",
9
9
  "./tcpClient": "./deno/tcpClient.ts",
10
10
  "./tcpServer": "./deno/tcpServer.ts"
11
11
  },
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env -S node --experimental-strip-types
2
2
  // this server is intended to be used with https://github.com/eclipse/iottestware
3
3
  import { AuthenticationResult } from "../server/mod.js";
4
- import { logger, LogLevel } from "../utils/mod.js";
5
- import { getArgs, parseArgs } from "../utils/mod.js";
4
+ import { getArgs, logger, LogLevel, parseArgs } from "../utils/mod.js";
6
5
  import { TcpServer } from "../node/tcpServer.js";
7
6
  const utf8Decoder = new TextDecoder();
8
7
  const userTable = new Map();
package/dist/bin/mqtt.js CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env -S node --experimental-strip-types
2
2
  import { DEFAULT_URL } from "../client/mod.js";
3
- import { logger, LogLevel } from "../utils/mod.js";
4
- import { getArgs, parseArgs } from "../utils/mod.js";
5
3
  import { getFileData, TcpClient } from "../node/tcpClient.js";
4
+ import { getArgs, logger, LogLevel, parseArgs } from "../utils/mod.js";
6
5
  const client = new TcpClient();
7
6
  const encoder = new TextEncoder();
8
7
  const decoder = new TextDecoder();
@@ -9,4 +9,5 @@ export const AuthenticationResult = {
9
9
  badUsernameOrPassword: 4,
10
10
  notAuthorized: 5,
11
11
  };
12
- export const AuthenticationResultByNumber = Object.fromEntries(Object.entries(AuthenticationResult).map(([k, v]) => [v, k]));
12
+ export const AuthenticationResultByNumber = Object
13
+ .fromEntries(Object.entries(AuthenticationResult).map(([k, v]) => [v, k]));
@@ -2,7 +2,7 @@ import { PacketType } from "./PacketType.js";
2
2
  import { BitMask } from "./BitMask.js";
3
3
  import { booleanFlag, Decoder, DecoderError } from "./decoder.js";
4
4
  import { AuthenticationResultByNumber } from "./AuthenticationResult.js";
5
- export default {
5
+ export const connack = {
6
6
  encode(packet) {
7
7
  const flags = 0;
8
8
  return {
@@ -8,7 +8,7 @@ function invalidProtocolName(version, name) {
8
8
  }
9
9
  return false;
10
10
  }
11
- export default {
11
+ export const connect = {
12
12
  encode(packet) {
13
13
  const flags = 0;
14
14
  const protocolLevel = 4;
@@ -1,6 +1,6 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { isEmptyBuf } from "./decoder.js";
3
- export default {
3
+ export const disconnect = {
4
4
  encode(_packet) {
5
5
  const flags = 0;
6
6
  return { flags, bytes: [] };
@@ -1,21 +1,21 @@
1
1
  import { PacketNameByType, PacketType } from "./PacketType.js";
2
2
  import { invalidTopic, invalidTopicFilter, invalidUTF8 } from "./validators.js";
3
3
  import { decodeLength, encodeLength } from "./length.js";
4
- import connect from "./connect.js";
5
- import connack from "./connack.js";
4
+ import { connect } from "./connect.js";
5
+ import { connack } from "./connack.js";
6
6
  import { AuthenticationResult, AuthenticationResultByNumber, } from "./AuthenticationResult.js";
7
- import publish from "./publish.js";
8
- import puback from "./puback.js";
9
- import pubrec from "./pubrec.js";
10
- import pubrel from "./pubrel.js";
11
- import pubcomp from "./pubcomp.js";
12
- import subscribe from "./subscribe.js";
13
- import suback from "./suback.js";
14
- import unsubscribe from "./unsubscribe.js";
15
- import unsuback from "./unsuback.js";
16
- import pingreq from "./pingreq.js";
17
- import pingres from "./pingres.js";
18
- import disconnect from "./disconnect.js";
7
+ import { publish } from "./publish.js";
8
+ import { puback } from "./puback.js";
9
+ import { pubrec } from "./pubrec.js";
10
+ import { pubrel } from "./pubrel.js";
11
+ import { pubcomp } from "./pubcomp.js";
12
+ import { subscribe } from "./subscribe.js";
13
+ import { suback } from "./suback.js";
14
+ import { unsubscribe } from "./unsubscribe.js";
15
+ import { unsuback } from "./unsuback.js";
16
+ import { pingreq } from "./pingreq.js";
17
+ import { pingres } from "./pingres.js";
18
+ import { disconnect } from "./disconnect.js";
19
19
  import { DecoderError } from "./decoder.js";
20
20
  export { AuthenticationResult, AuthenticationResultByNumber, decodeLength, encodeLength, invalidTopic, invalidTopicFilter, invalidUTF8, PacketNameByType, PacketType, };
21
21
  export const packetsByType = [
@@ -1,6 +1,6 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { hasEmptyFlags, isEmptyBuf } from "./decoder.js";
3
- export default {
3
+ export const pingreq = {
4
4
  encode(_packet) {
5
5
  const flags = 0;
6
6
  return { flags, bytes: [] };
@@ -1,6 +1,6 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { isEmptyBuf } from "./decoder.js";
3
- export default {
3
+ export const pingres = {
4
4
  encode(_packet) {
5
5
  const flags = 0;
6
6
  return { flags, bytes: [] };
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Decoder } from "./decoder.js";
3
3
  import { Encoder } from "./encoder.js";
4
- export default {
4
+ export const puback = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Decoder } from "./decoder.js";
3
3
  import { Encoder } from "./encoder.js";
4
- export default {
4
+ export const pubcomp = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -2,7 +2,7 @@ import { PacketType } from "./PacketType.js";
2
2
  import { BitMask } from "./BitMask.js";
3
3
  import { Encoder, EncoderError } from "./encoder.js";
4
4
  import { booleanFlag, Decoder, DecoderError } from "./decoder.js";
5
- export default {
5
+ export const publish = {
6
6
  encode(packet) {
7
7
  const qos = packet.qos || 0;
8
8
  const flags = (packet.dup ? BitMask.bit3 : 0) +
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Decoder } from "./decoder.js";
3
3
  import { Encoder } from "./encoder.js";
4
- export default {
4
+ export const pubrec = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Decoder } from "./decoder.js";
3
3
  import { Encoder } from "./encoder.js";
4
- export default {
4
+ export const pubrel = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Encoder } from "./encoder.js";
3
3
  import { Decoder } from "./decoder.js";
4
- export default {
4
+ export const suback = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -2,7 +2,7 @@ import { PacketType } from "./PacketType.js";
2
2
  import { BitMask } from "./BitMask.js";
3
3
  import { Encoder } from "./encoder.js";
4
4
  import { booleanFlag, Decoder, DecoderError } from "./decoder.js";
5
- export default {
5
+ export const subscribe = {
6
6
  encode(packet) {
7
7
  // Bits 3,2,1 and 0 of the fixed header of the SUBSCRIBE Control Packet are reserved and
8
8
  // MUST be set to 0,0,1 and 0 respectively. The Server MUST treat any other value as
@@ -1,7 +1,7 @@
1
1
  import { PacketType } from "./PacketType.js";
2
2
  import { Decoder } from "./decoder.js";
3
3
  import { Encoder } from "./encoder.js";
4
- export default {
4
+ export const unsuback = {
5
5
  encode(packet) {
6
6
  const flags = 0;
7
7
  const encoder = new Encoder();
@@ -2,7 +2,7 @@ import { PacketType } from "./PacketType.js";
2
2
  import { BitMask } from "./BitMask.js";
3
3
  import { Encoder } from "./encoder.js";
4
4
  import { booleanFlag, Decoder, DecoderError } from "./decoder.js";
5
- export default {
5
+ export const unsubscribe = {
6
6
  encode(packet) {
7
7
  // Bits 3,2,1 and 0 of the fixed header of the UNSUBSCRIBE Control Packet are reserved and
8
8
  // MUST be set to 0,0,1 and 0 respectively. The Server MUST treat any other value as
@@ -11,6 +11,7 @@ export const AuthenticationResult = {
11
11
  notAuthorized: 5,
12
12
  } as const;
13
13
 
14
- export const AuthenticationResultByNumber = Object.fromEntries(
15
- Object.entries(AuthenticationResult).map(([k, v]) => [v, k]),
16
- );
14
+ export const AuthenticationResultByNumber: Record<number, string> = Object
15
+ .fromEntries(
16
+ Object.entries(AuthenticationResult).map(([k, v]) => [v, k]),
17
+ );
@@ -16,6 +16,6 @@ export const PacketType = {
16
16
  disconnect: 14,
17
17
  } as const;
18
18
 
19
- export const PacketNameByType = Object.fromEntries(
19
+ export const PacketNameByType: Record<number, string> = Object.fromEntries(
20
20
  Object.entries(PacketType).map(([k, v]) => [v, k]),
21
21
  );
@@ -10,7 +10,10 @@ export type ConnackPacket = {
10
10
  returnCode: TAuthenticationResult;
11
11
  };
12
12
 
13
- export default {
13
+ export const connack: {
14
+ encode(packet: ConnackPacket): { flags: number; bytes: number[] };
15
+ decode(buffer: Uint8Array, _flags: number): ConnackPacket | undefined;
16
+ } = {
14
17
  encode(packet: ConnackPacket): { flags: number; bytes: number[] } {
15
18
  const flags = 0;
16
19
  return {
@@ -33,8 +33,11 @@ function invalidProtocolName(version: number, name: string): boolean {
33
33
  return false;
34
34
  }
35
35
 
36
- export default {
37
- encode(packet: ConnectPacket) {
36
+ export const connect: {
37
+ encode(packet: ConnectPacket): { flags: number; bytes: number[] };
38
+ decode(buffer: Uint8Array, flags: number): ConnectPacket;
39
+ } = {
40
+ encode(packet: ConnectPacket): { flags: number; bytes: number[] } {
38
41
  const flags = 0;
39
42
 
40
43
  const protocolLevel = 4;
@@ -6,8 +6,11 @@ export type DisconnectPacket = {
6
6
  type: TPacketType;
7
7
  };
8
8
 
9
- export default {
10
- encode(_packet: DisconnectPacket) {
9
+ export const disconnect: {
10
+ encode(_packet: DisconnectPacket): { flags: number; bytes: number[] };
11
+ decode(buffer: Uint8Array, _flags: number): DisconnectPacket;
12
+ } = {
13
+ encode(_packet: DisconnectPacket): { flags: number; bytes: number[] } {
11
14
  const flags = 0;
12
15
  return { flags, bytes: [] };
13
16
  },
package/mqttPacket/mod.ts CHANGED
@@ -13,24 +13,24 @@ import type {
13
13
  import { PacketNameByType, PacketType } from "./PacketType.ts";
14
14
  import { invalidTopic, invalidTopicFilter, invalidUTF8 } from "./validators.ts";
15
15
  import { decodeLength, encodeLength } from "./length.ts";
16
- import connect, { type ConnectPacket } from "./connect.ts";
17
- import connack, { type ConnackPacket } from "./connack.ts";
16
+ import { connect, type ConnectPacket } from "./connect.ts";
17
+ import { connack, type ConnackPacket } from "./connack.ts";
18
18
  import {
19
19
  AuthenticationResult,
20
20
  AuthenticationResultByNumber,
21
21
  } from "./AuthenticationResult.ts";
22
- import publish, { type PublishPacket } from "./publish.ts";
23
- import puback, { type PubackPacket } from "./puback.ts";
24
- import pubrec, { type PubrecPacket } from "./pubrec.ts";
25
- import pubrel, { type PubrelPacket } from "./pubrel.ts";
26
- import pubcomp, { type PubcompPacket } from "./pubcomp.ts";
27
- import subscribe, { type SubscribePacket } from "./subscribe.ts";
28
- import suback, { type SubackPacket } from "./suback.ts";
29
- import unsubscribe, { type UnsubscribePacket } from "./unsubscribe.ts";
30
- import unsuback, { type UnsubackPacket } from "./unsuback.ts";
31
- import pingreq, { type PingreqPacket } from "./pingreq.ts";
32
- import pingres, { type PingresPacket } from "./pingres.ts";
33
- import disconnect, { type DisconnectPacket } from "./disconnect.ts";
22
+ import { publish, type PublishPacket } from "./publish.ts";
23
+ import { puback, type PubackPacket } from "./puback.ts";
24
+ import { pubrec, type PubrecPacket } from "./pubrec.ts";
25
+ import { pubrel, type PubrelPacket } from "./pubrel.ts";
26
+ import { pubcomp, type PubcompPacket } from "./pubcomp.ts";
27
+ import { subscribe, type SubscribePacket } from "./subscribe.ts";
28
+ import { suback, type SubackPacket } from "./suback.ts";
29
+ import { unsubscribe, type UnsubscribePacket } from "./unsubscribe.ts";
30
+ import { unsuback, type UnsubackPacket } from "./unsuback.ts";
31
+ import { pingreq, type PingreqPacket } from "./pingreq.ts";
32
+ import { pingres, type PingresPacket } from "./pingres.ts";
33
+ import { disconnect, type DisconnectPacket } from "./disconnect.ts";
34
34
  import { DecoderError } from "./decoder.ts";
35
35
 
36
36
  export type AnyPacket =
@@ -108,7 +108,7 @@ export const packetsByType = [
108
108
  disconnect, // 14
109
109
  ] as const;
110
110
 
111
- export function encode(packet: AnyPacket) {
111
+ export function encode(packet: AnyPacket): Uint8Array {
112
112
  const packetType: number = packet.type;
113
113
  // deno-lint-ignore no-explicit-any
114
114
  const pkt: any = packet;
@@ -6,8 +6,11 @@ export type PingreqPacket = {
6
6
  type: TPacketType;
7
7
  };
8
8
 
9
- export default {
10
- encode(_packet: PingreqPacket) {
9
+ export const pingreq: {
10
+ encode(_packet: PingreqPacket): { flags: number; bytes: number[] };
11
+ decode(buffer: Uint8Array, flags: number): PingreqPacket;
12
+ } = {
13
+ encode(_packet: PingreqPacket): { flags: number; bytes: number[] } {
11
14
  const flags = 0;
12
15
  return { flags, bytes: [] };
13
16
  },
@@ -6,8 +6,11 @@ export type PingresPacket = {
6
6
  type: TPacketType;
7
7
  };
8
8
 
9
- export default {
10
- encode(_packet: PingresPacket) {
9
+ export const pingres: {
10
+ encode(_packet: PingresPacket): { flags: number; bytes: number[] };
11
+ decode(buffer: Uint8Array): PingresPacket;
12
+ } = {
13
+ encode(_packet: PingresPacket): { flags: number; bytes: number[] } {
11
14
  const flags = 0;
12
15
  return { flags, bytes: [] };
13
16
  },
@@ -8,8 +8,11 @@ export type PubackPacket = {
8
8
  id: PacketId;
9
9
  };
10
10
 
11
- export default {
12
- encode(packet: PubackPacket) {
11
+ export const puback: {
12
+ encode(packet: PubackPacket): { flags: number; bytes: number[] };
13
+ decode(buffer: Uint8Array): PubackPacket;
14
+ } = {
15
+ encode(packet: PubackPacket): { flags: number; bytes: number[] } {
13
16
  const flags = 0;
14
17
  const encoder = new Encoder();
15
18
  encoder.setInt16(packet.id);
@@ -8,8 +8,11 @@ export type PubcompPacket = {
8
8
  id: PacketId;
9
9
  };
10
10
 
11
- export default {
12
- encode(packet: PubcompPacket) {
11
+ export const pubcomp: {
12
+ encode(packet: PubcompPacket): { flags: number; bytes: number[] };
13
+ decode(buffer: Uint8Array): PubcompPacket;
14
+ } = {
15
+ encode(packet: PubcompPacket): { flags: number; bytes: number[] } {
13
16
  const flags = 0;
14
17
  const encoder = new Encoder();
15
18
  encoder.setInt16(packet.id);
@@ -14,8 +14,11 @@ export type PublishPacket = {
14
14
  id?: number;
15
15
  };
16
16
 
17
- export default {
18
- encode(packet: PublishPacket) {
17
+ export const publish: {
18
+ encode(packet: PublishPacket): { flags: number; bytes: number[] };
19
+ decode(buffer: Uint8Array, flags: number): PublishPacket;
20
+ } = {
21
+ encode(packet: PublishPacket): { flags: number; bytes: number[] } {
19
22
  const qos = packet.qos || 0;
20
23
 
21
24
  const flags = (packet.dup ? BitMask.bit3 : 0) +
@@ -8,8 +8,11 @@ export type PubrecPacket = {
8
8
  id: PacketId;
9
9
  };
10
10
 
11
- export default {
12
- encode(packet: PubrecPacket) {
11
+ export const pubrec: {
12
+ encode(packet: PubrecPacket): { flags: number; bytes: number[] };
13
+ decode(buffer: Uint8Array): PubrecPacket;
14
+ } = {
15
+ encode(packet: PubrecPacket): { flags: number; bytes: number[] } {
13
16
  const flags = 0;
14
17
  const encoder = new Encoder();
15
18
  encoder.setInt16(packet.id);
@@ -8,8 +8,11 @@ export type PubrelPacket = {
8
8
  id: PacketId;
9
9
  };
10
10
 
11
- export default {
12
- encode(packet: PubrelPacket) {
11
+ export const pubrel: {
12
+ encode(packet: PubrelPacket): { flags: number; bytes: number[] };
13
+ decode(buffer: Uint8Array): PubrelPacket;
14
+ } = {
15
+ encode(packet: PubrelPacket): { flags: number; bytes: number[] } {
13
16
  const flags = 0;
14
17
  const encoder = new Encoder();
15
18
  encoder.setInt16(packet.id);
@@ -9,8 +9,11 @@ export type SubackPacket = {
9
9
  returnCodes: ReturnCodes;
10
10
  };
11
11
 
12
- export default {
13
- encode(packet: SubackPacket) {
12
+ export const suback: {
13
+ encode(packet: SubackPacket): { flags: number; bytes: number[] };
14
+ decode(buffer: Uint8Array): SubackPacket;
15
+ } = {
16
+ encode(packet: SubackPacket): { flags: number; bytes: number[] } {
14
17
  const flags = 0;
15
18
  const encoder = new Encoder();
16
19
  encoder.setInt16(packet.id);
@@ -15,8 +15,11 @@ export type Subscription = {
15
15
  qos: QoS;
16
16
  };
17
17
 
18
- export default {
19
- encode(packet: SubscribePacket) {
18
+ export const subscribe: {
19
+ encode(packet: SubscribePacket): { flags: number; bytes: number[] };
20
+ decode(buffer: Uint8Array, flags: number): SubscribePacket;
21
+ } = {
22
+ encode(packet: SubscribePacket): { flags: number; bytes: number[] } {
20
23
  // Bits 3,2,1 and 0 of the fixed header of the SUBSCRIBE Control Packet are reserved and
21
24
  // MUST be set to 0,0,1 and 0 respectively. The Server MUST treat any other value as
22
25
  // malformed and close the Network Connection [MQTT-3.8.1-1].
@@ -8,8 +8,11 @@ export type UnsubackPacket = {
8
8
  id: PacketId;
9
9
  };
10
10
 
11
- export default {
12
- encode(packet: UnsubackPacket) {
11
+ export const unsuback: {
12
+ encode(packet: UnsubackPacket): { flags: number; bytes: number[] };
13
+ decode(buffer: Uint8Array): UnsubackPacket;
14
+ } = {
15
+ encode(packet: UnsubackPacket): { flags: number; bytes: number[] } {
13
16
  const flags = 0;
14
17
  const encoder = new Encoder();
15
18
  encoder.setInt16(packet.id);
@@ -10,8 +10,11 @@ export type UnsubscribePacket = {
10
10
  topicFilters: TopicFilter[];
11
11
  };
12
12
 
13
- export default {
14
- encode(packet: UnsubscribePacket) {
13
+ export const unsubscribe: {
14
+ encode(packet: UnsubscribePacket): { flags: number; bytes: number[] };
15
+ decode(buffer: Uint8Array, flags: number): UnsubscribePacket;
16
+ } = {
17
+ encode(packet: UnsubscribePacket): { flags: number; bytes: number[] } {
15
18
  // Bits 3,2,1 and 0 of the fixed header of the UNSUBSCRIBE Control Packet are reserved and
16
19
  // MUST be set to 0,0,1 and 0 respectively. The Server MUST treat any other value as
17
20
  // malformed and close the Network Connection [MQTT-3.10.1-1].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seriousme/opifex",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "MQTT client & server for Deno & NodeJS",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "./server": "./dist/server/mod.js",
26
26
  "./client": "./dist/client/mod.js",
27
27
  "./mqttPacket": "./dist/mqttPacket/mod.js",
28
- "./utils": "./dist/utils/mod.js,",
28
+ "./utils": "./dist/utils/mod.js",
29
29
  "./tcpClient": "./dist/node/tcpClient.js",
30
30
  "./tcpServer": "./dist/node/tcpServer.js"
31
31
  },
@@ -34,7 +34,7 @@
34
34
  "./server": "./server/mod.ts",
35
35
  "./client": "./client/mod.ts",
36
36
  "./mqttPacket": "./mqttPacket/mod.ts",
37
- "./utils": "./utils/mod.ts,",
37
+ "./utils": "./utils/mod.ts",
38
38
  "./tcpClient": "./deno/tcpClient.ts",
39
39
  "./tcpServer": "./deno/tcpServer.ts"
40
40
  },
package/utils/mod.ts CHANGED
@@ -4,4 +4,5 @@ export { Logger, logger, LogLevel } from "./logger.ts";
4
4
  export { AsyncQueue } from "./asyncQueue.ts";
5
5
  export { nextTick } from "./nextTick.ts";
6
6
  export { parseArgs } from "./args.ts";
7
+ export type { Args } from "./args.ts";
7
8
  export { getArgs } from "./platform.ts";
package/utils/platform.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { argv } from "node:process";
2
- export function getArgs() {
2
+ export function getArgs(): string[] {
3
3
  return argv.slice(2);
4
4
  }