@seriousme/opifex 1.3.0 → 1.4.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.
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+
3
+ license='LICENSE.txt'
4
+ prefix='2016-'
5
+ current_year=$(date +%Y)
6
+ sed -i -e "s/$prefix\([0-9\]\+\)/$prefix$current_year/" $license
7
+
8
+ if [ "$(git diff $license)" ]; then
9
+ git add $license
10
+ git commit -m "Update license year to $current_year"
11
+ git push
12
+ else
13
+ echo "No changes detected in $license"
14
+ fi
@@ -0,0 +1,13 @@
1
+ name: Update License Year
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "5 12 1 1 *"
6
+
7
+ jobs:
8
+ update_license:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Update license year
13
+ run: ./update_license.sh
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Hans Klunder
3
+ Copyright (c) 2023-2025 Hans Klunder
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/client/client.ts CHANGED
@@ -25,6 +25,8 @@ type ConnectOptions = Omit<
25
25
  export type ConnectParameters = {
26
26
  url?: URL;
27
27
  caCerts?: string[];
28
+ cert?: string;
29
+ key?: string;
28
30
  numberOfRetries?: number;
29
31
  options?: ConnectOptions;
30
32
  };
@@ -70,6 +72,8 @@ export class Client {
70
72
  protected keepAlive = DEFAULT_KEEPALIVE;
71
73
  protected autoReconnect = true;
72
74
  private caCerts?: string[];
75
+ private cert?: string;
76
+ private key?: string;
73
77
  private clientId: string;
74
78
  private ctx = new Context(new MemoryStore());
75
79
  private connectPacket?: ConnectPacket;
@@ -84,6 +88,8 @@ export class Client {
84
88
  _hostname: string,
85
89
  _port?: number,
86
90
  _caCerts?: string[],
91
+ _cert?: string,
92
+ _key?: string,
87
93
  ): Promise<SockConn> {
88
94
  // if you need to support alternative connection types just
89
95
  // overload this method in your subclass
@@ -106,6 +112,8 @@ export class Client {
106
112
  this.url.hostname,
107
113
  Number(this.url.port) ?? undefined,
108
114
  this.caCerts,
115
+ this.cert,
116
+ this.key,
109
117
  );
110
118
  // if we get this far we have a connection
111
119
  tryConnect =
@@ -137,6 +145,8 @@ export class Client {
137
145
  this.url = params?.url || this.url;
138
146
  this.numberOfRetries = params.numberOfRetries || this.numberOfRetries;
139
147
  this.caCerts = params?.caCerts;
148
+ this.cert = params?.cert;
149
+ this.key = params?.key;
140
150
  const options = Object.assign(
141
151
  {
142
152
  keepAlive: this.keepAlive,
package/deno/client.ts CHANGED
@@ -25,9 +25,11 @@ export class TcpClient extends Client {
25
25
  hostname: string,
26
26
  port = 8883,
27
27
  caCerts?: string[],
28
+ cert?: string,
29
+ key?: string,
28
30
  ) {
29
- logger.debug({ hostname, port, caCerts });
30
- return await Deno.connectTls({ hostname, port, caCerts });
31
+ logger.debug({ hostname, port, caCerts, cert });
32
+ return await Deno.connectTls({ hostname, port, caCerts, cert, key });
31
33
  }
32
34
 
33
35
  protected override createConn(
@@ -35,11 +37,13 @@ export class TcpClient extends Client {
35
37
  hostname: string,
36
38
  port?: number,
37
39
  caCerts?: string[],
40
+ cert?: string,
41
+ key?: string,
38
42
  ): Promise<SockConn> {
39
43
  // if you need to support alternative connection types just
40
44
  // overload this method in your subclass
41
45
  if (protocol === "mqtts:") {
42
- return this.connectMQTTS(hostname, port, caCerts);
46
+ return this.connectMQTTS(hostname, port, caCerts, cert, key);
43
47
  }
44
48
  if (protocol === "mqtt:") {
45
49
  return this.connectMQTT(hostname, port);
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seriousme/opifex",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "exports": {
5
5
  "./server": "./server/mod.ts",
6
6
  "./client": "./client/mod.ts"
package/deno.lock CHANGED
@@ -2,29 +2,32 @@
2
2
  "version": "4",
3
3
  "specifiers": {
4
4
  "npm:@types/node@*": "22.5.4",
5
- "npm:@types/node@^22.8.6": "22.8.6"
5
+ "npm:@types/node@^22.10.0": "22.10.0"
6
6
  },
7
7
  "npm": {
8
- "@types/node@22.5.4": {
9
- "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
8
+ "@types/node@22.10.0": {
9
+ "integrity": "sha512-XC70cRZVElFHfIUB40FgZOBbgJYFKKMa5nb9lxcwYstFG/Mi+/Y0bGS+rs6Dmhmkpq4pnNiLiuZAbc02YCOnmA==",
10
10
  "dependencies": [
11
- "undici-types"
11
+ "undici-types@6.20.0"
12
12
  ]
13
13
  },
14
- "@types/node@22.8.6": {
15
- "integrity": "sha512-tosuJYKrIqjQIlVCM4PEGxOmyg3FCPa/fViuJChnGeEIhjA46oy8FMVoF9su1/v8PNs2a8Q0iFNyOx0uOF91nw==",
14
+ "@types/node@22.5.4": {
15
+ "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
16
16
  "dependencies": [
17
- "undici-types"
17
+ "undici-types@6.19.8"
18
18
  ]
19
19
  },
20
20
  "undici-types@6.19.8": {
21
21
  "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
22
+ },
23
+ "undici-types@6.20.0": {
24
+ "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="
22
25
  }
23
26
  },
24
27
  "workspace": {
25
28
  "packageJson": {
26
29
  "dependencies": [
27
- "npm:@types/node@^22.8.6"
30
+ "npm:@types/node@^22.10.0"
28
31
  ]
29
32
  }
30
33
  }
@@ -34,6 +34,8 @@ export class Client {
34
34
  keepAlive = DEFAULT_KEEPALIVE;
35
35
  autoReconnect = true;
36
36
  caCerts;
37
+ cert;
38
+ key;
37
39
  clientId;
38
40
  ctx = new Context(new MemoryStore());
39
41
  connectPacket;
@@ -41,7 +43,7 @@ export class Client {
41
43
  this.clientId = generateClientId(this.clientIdPrefix);
42
44
  this.numberOfRetries = DEFAULT_RETRIES;
43
45
  }
44
- createConn(protocol, _hostname, _port, _caCerts) {
46
+ createConn(protocol, _hostname, _port, _caCerts, _cert, _key) {
45
47
  // if you need to support alternative connection types just
46
48
  // overload this method in your subclass
47
49
  throw `Unsupported protocol: ${protocol}`;
@@ -57,7 +59,7 @@ export class Client {
57
59
  while (tryConnect) {
58
60
  logger.debug(`${isReconnect ? "re" : ""}connecting`);
59
61
  try {
60
- const conn = await this.createConn(this.url.protocol, this.url.hostname, Number(this.url.port) ?? undefined, this.caCerts);
62
+ const conn = await this.createConn(this.url.protocol, this.url.hostname, Number(this.url.port) ?? undefined, this.caCerts, this.cert, this.key);
61
63
  // if we get this far we have a connection
62
64
  tryConnect =
63
65
  (await this.ctx.handleConnection(conn, this.connectPacket)) &&
@@ -88,6 +90,8 @@ export class Client {
88
90
  this.url = params?.url || this.url;
89
91
  this.numberOfRetries = params.numberOfRetries || this.numberOfRetries;
90
92
  this.caCerts = params?.caCerts;
93
+ this.cert = params?.cert;
94
+ this.key = params?.key;
91
95
  const options = Object.assign({
92
96
  keepAlive: this.keepAlive,
93
97
  clientId: this.clientId,
@@ -25,7 +25,6 @@ export class TcpClient extends Client {
25
25
  resolve(wrapNodeSocket(socket));
26
26
  });
27
27
  socket.once("error", (err) => {
28
- // @ts-ignore the type spec of err is missing err.code
29
28
  logger.debug("Connection failed: ", err);
30
29
  reject(err);
31
30
  });
@@ -1 +1 @@
1
- {"root":["../bin/conformanceServer.ts","../bin/demoServer.ts","../bin/mqtt.ts"],"version":"5.7.0-beta"}
1
+ {"root":["../bin/conformanceServer.ts","../bin/demoServer.ts","../bin/mqtt.ts"],"version":"5.7.2"}
package/node/client.ts CHANGED
@@ -31,7 +31,6 @@ export class TcpClient extends Client {
31
31
  },
32
32
  );
33
33
  socket.once("error", (err) => {
34
- // @ts-ignore the type spec of err is missing err.code
35
34
  logger.debug("Connection failed: ", err);
36
35
  reject(err);
37
36
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@seriousme/opifex",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "MQTT client & server for Deno & NodeJS",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "test": "node --experimental-strip-types --test --test-skip-pattern='/^Deno/'",
8
8
  "prebuild": "rm -rf dist",
9
- "build": "npx -p typescript@beta tsc --build",
9
+ "build": "npx -p typescript tsc --build",
10
10
  "postbuild": "deno fmt",
11
11
  "preversion": "npm run test",
12
12
  "version": "npm run build",
@@ -45,6 +45,6 @@
45
45
  },
46
46
  "homepage": "https://github.com/seriousme/opifex#readme",
47
47
  "devDependencies": {
48
- "@types/node": "^22.8.6"
48
+ "@types/node": "^22.10.0"
49
49
  }
50
50
  }