mqtt5-wasm 0.4.0 → 0.7.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.
package/README.md CHANGED
@@ -4,12 +4,15 @@ MQTT v5.0 and v3.1.1 WebAssembly client and broker for browser environments.
4
4
 
5
5
  ## Features
6
6
 
7
- - **WebSocket transport** - Connect to remote MQTT brokers
7
+ - **WebSocket transport** - Connect to remote MQTT brokers via `ws://` or `wss://`
8
8
  - **In-tab broker** - Run a complete MQTT broker in the browser
9
- - **MessagePort/BroadcastChannel** - Inter-tab communication
9
+ - **MessagePort/BroadcastChannel** - Inter-tab and worker communication
10
10
  - **Broker bridging** - Connect multiple in-browser brokers via MessagePort
11
- - **Full QoS support** - QoS 0, 1, and 2
12
- - **Automatic keepalive** - Connection health monitoring
11
+ - **Full QoS support** - QoS 0, 1, and 2 with proper acknowledgment
12
+ - **Shared subscriptions** - Load balancing across multiple subscribers
13
+ - **Event callbacks** - Connection, disconnect, and error event handlers
14
+ - **Automatic keepalive** - Connection health monitoring with timeout detection
15
+ - **Will messages** - Last Will and Testament (LWT) support
13
16
 
14
17
  ## Installation
15
18
 
@@ -23,7 +26,7 @@ npm install mqtt5-wasm
23
26
 
24
27
  ```toml
25
28
  [dependencies]
26
- mqtt5-wasm = "0.4"
29
+ mqtt5-wasm = "0.7"
27
30
  ```
28
31
 
29
32
  Build with wasm-pack:
@@ -34,19 +37,57 @@ wasm-pack build --target web --features client,broker
34
37
 
35
38
  ## Usage
36
39
 
40
+ ### Basic Example
41
+
37
42
  ```javascript
38
43
  import init, { WasmMqttClient } from "mqtt5-wasm";
39
44
 
40
45
  await init();
41
46
  const client = new WasmMqttClient("browser-client");
42
47
 
43
- await client.connect("ws://broker.example.com:8080/mqtt");
48
+ await client.connect("wss://broker.example.com:8084/mqtt");
44
49
 
45
50
  await client.subscribe_with_callback("sensors/#", (topic, payload) => {
46
51
  console.log(`${topic}: ${new TextDecoder().decode(payload)}`);
47
52
  });
48
53
 
49
54
  await client.publish("sensors/temp", new TextEncoder().encode("25.5"));
55
+
56
+ await client.disconnect();
57
+ ```
58
+
59
+ ### Event Callbacks
60
+
61
+ ```javascript
62
+ const client = new WasmMqttClient("browser-client");
63
+
64
+ client.on_connect((reasonCode, sessionPresent) => {
65
+ console.log(`Connected: reason=${reasonCode}, session=${sessionPresent}`);
66
+ });
67
+
68
+ client.on_disconnect(() => {
69
+ console.log("Disconnected from broker");
70
+ });
71
+
72
+ client.on_error((error) => {
73
+ console.error(`Error: ${error}`);
74
+ });
75
+
76
+ await client.connect("wss://broker.example.com:8084/mqtt");
77
+ ```
78
+
79
+ ### In-Browser Broker
80
+
81
+ ```javascript
82
+ import init, { WasmBroker, WasmMqttClient } from "mqtt5-wasm";
83
+
84
+ await init();
85
+
86
+ const broker = new WasmBroker();
87
+ const port = broker.create_client_port();
88
+
89
+ const client = new WasmMqttClient("local-client");
90
+ await client.connect_message_port(port);
50
91
  ```
51
92
 
52
93
  ## Documentation
package/mqtt5_wasm.d.ts CHANGED
@@ -24,19 +24,31 @@ export class WasmBroker {
24
24
  free(): void;
25
25
  [Symbol.dispose](): void;
26
26
  add_bridge(config: WasmBridgeConfig, remote_port: MessagePort): Promise<void>;
27
+ list_roles(): Promise<string[]>;
28
+ role_count(): Promise<number>;
27
29
  user_count(): Promise<number>;
30
+ assign_role(username: string, role_name: string): Promise<void>;
31
+ clear_roles(): Promise<void>;
32
+ remove_role(name: string): Promise<boolean>;
28
33
  remove_user(username: string): Promise<boolean>;
29
34
  static with_config(wasm_config: WasmBrokerConfig): WasmBroker;
30
35
  add_acl_rule(username: string, topic_pattern: string, permission: string): Promise<void>;
31
36
  list_bridges(): string[];
37
+ add_role_rule(role_name: string, topic_pattern: string, permission: string): Promise<void>;
32
38
  static hash_password(password: string): string;
33
39
  remove_bridge(name: string): Promise<void>;
40
+ unassign_role(username: string, role_name: string): Promise<boolean>;
34
41
  acl_rule_count(): Promise<number>;
42
+ get_user_roles(username: string): Promise<string[]>;
35
43
  clear_acl_rules(): Promise<void>;
44
+ stop_sys_topics(): void;
45
+ start_sys_topics(): void;
36
46
  stop_all_bridges(): Promise<void>;
37
47
  add_user_with_hash(username: string, password_hash: string): Promise<void>;
38
48
  create_client_port(): MessagePort;
49
+ start_sys_topics_with_interval_secs(interval_secs: number): void;
39
50
  constructor();
51
+ add_role(name: string): Promise<void>;
40
52
  add_user(username: string, password: string): Promise<void>;
41
53
  has_user(username: string): Promise<boolean>;
42
54
  }
@@ -212,17 +224,29 @@ export interface InitOutput {
212
224
  readonly wasmbroker_acl_rule_count: (a: number) => any;
213
225
  readonly wasmbroker_add_acl_rule: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
214
226
  readonly wasmbroker_add_bridge: (a: number, b: number, c: any) => any;
227
+ readonly wasmbroker_add_role: (a: number, b: number, c: number) => any;
228
+ readonly wasmbroker_add_role_rule: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
215
229
  readonly wasmbroker_add_user: (a: number, b: number, c: number, d: number, e: number) => any;
216
230
  readonly wasmbroker_add_user_with_hash: (a: number, b: number, c: number, d: number, e: number) => any;
231
+ readonly wasmbroker_assign_role: (a: number, b: number, c: number, d: number, e: number) => any;
217
232
  readonly wasmbroker_clear_acl_rules: (a: number) => any;
233
+ readonly wasmbroker_clear_roles: (a: number) => any;
218
234
  readonly wasmbroker_create_client_port: (a: number) => [number, number, number];
235
+ readonly wasmbroker_get_user_roles: (a: number, b: number, c: number) => any;
219
236
  readonly wasmbroker_has_user: (a: number, b: number, c: number) => any;
220
237
  readonly wasmbroker_hash_password: (a: number, b: number) => [number, number, number, number];
221
238
  readonly wasmbroker_list_bridges: (a: number) => [number, number];
239
+ readonly wasmbroker_list_roles: (a: number) => any;
222
240
  readonly wasmbroker_new: () => [number, number, number];
223
241
  readonly wasmbroker_remove_bridge: (a: number, b: number, c: number) => any;
242
+ readonly wasmbroker_remove_role: (a: number, b: number, c: number) => any;
224
243
  readonly wasmbroker_remove_user: (a: number, b: number, c: number) => any;
244
+ readonly wasmbroker_role_count: (a: number) => any;
245
+ readonly wasmbroker_start_sys_topics: (a: number) => void;
246
+ readonly wasmbroker_start_sys_topics_with_interval_secs: (a: number, b: number) => void;
225
247
  readonly wasmbroker_stop_all_bridges: (a: number) => any;
248
+ readonly wasmbroker_stop_sys_topics: (a: number) => void;
249
+ readonly wasmbroker_unassign_role: (a: number, b: number, c: number, d: number, e: number) => any;
226
250
  readonly wasmbroker_user_count: (a: number) => any;
227
251
  readonly wasmbroker_with_config: (a: number) => [number, number, number];
228
252
  readonly wasmbrokerconfig_new: () => number;
@@ -260,6 +284,7 @@ export interface InitOutput {
260
284
  readonly wasmconnectoptions_set_receiveMaximum: (a: number, b: number) => void;
261
285
  readonly wasmconnectoptions_set_requestProblemInformation: (a: number, b: number) => void;
262
286
  readonly wasmconnectoptions_set_requestResponseInformation: (a: number, b: number) => void;
287
+ readonly wasmconnectoptions_set_sessionExpiryInterval: (a: number, b: number) => void;
263
288
  readonly wasmconnectoptions_set_topicAliasMaximum: (a: number, b: number) => void;
264
289
  readonly wasmconnectoptions_set_username: (a: number, b: number, c: number) => void;
265
290
  readonly wasmconnectoptions_set_will: (a: number, b: number) => void;
@@ -268,6 +293,7 @@ export interface InitOutput {
268
293
  readonly wasmmessageproperties_contentType: (a: number) => [number, number];
269
294
  readonly wasmmessageproperties_correlationData: (a: number) => [number, number];
270
295
  readonly wasmmessageproperties_getUserProperties: (a: number) => any;
296
+ readonly wasmmessageproperties_messageExpiryInterval: (a: number) => number;
271
297
  readonly wasmmessageproperties_payloadFormatIndicator: (a: number) => number;
272
298
  readonly wasmmessageproperties_responseTopic: (a: number) => [number, number];
273
299
  readonly wasmmessageproperties_subscriptionIdentifiers: (a: number) => [number, number];
@@ -295,6 +321,7 @@ export interface InitOutput {
295
321
  readonly wasmpublishoptions_addUserProperty: (a: number, b: number, c: number, d: number, e: number) => void;
296
322
  readonly wasmpublishoptions_clearUserProperties: (a: number) => void;
297
323
  readonly wasmpublishoptions_contentType: (a: number) => [number, number];
324
+ readonly wasmpublishoptions_messageExpiryInterval: (a: number) => number;
298
325
  readonly wasmpublishoptions_new: () => number;
299
326
  readonly wasmpublishoptions_payloadFormatIndicator: (a: number) => number;
300
327
  readonly wasmpublishoptions_qos: (a: number) => number;
@@ -302,6 +329,7 @@ export interface InitOutput {
302
329
  readonly wasmpublishoptions_retain: (a: number) => number;
303
330
  readonly wasmpublishoptions_set_contentType: (a: number, b: number, c: number) => void;
304
331
  readonly wasmpublishoptions_set_correlationData: (a: number, b: number, c: number) => void;
332
+ readonly wasmpublishoptions_set_messageExpiryInterval: (a: number, b: number) => void;
305
333
  readonly wasmpublishoptions_set_payloadFormatIndicator: (a: number, b: number) => void;
306
334
  readonly wasmpublishoptions_set_qos: (a: number, b: number) => void;
307
335
  readonly wasmpublishoptions_set_responseTopic: (a: number, b: number, c: number) => void;
@@ -317,37 +345,33 @@ export interface InitOutput {
317
345
  readonly wasmsubscribeoptions_set_qos: (a: number, b: number) => void;
318
346
  readonly wasmsubscribeoptions_set_retainAsPublished: (a: number, b: number) => void;
319
347
  readonly wasmsubscribeoptions_set_retainHandling: (a: number, b: number) => void;
348
+ readonly wasmsubscribeoptions_set_subscriptionIdentifier: (a: number, b: number) => void;
349
+ readonly wasmsubscribeoptions_subscriptionIdentifier: (a: number) => number;
320
350
  readonly wasmtopicmapping_new: (a: number, b: number, c: number) => number;
321
351
  readonly wasmtopicmapping_set_local_prefix: (a: number, b: number, c: number) => void;
322
352
  readonly wasmtopicmapping_set_qos: (a: number, b: number) => void;
323
353
  readonly wasmtopicmapping_set_remote_prefix: (a: number, b: number, c: number) => void;
324
354
  readonly wasmwillmessage_contentType: (a: number) => [number, number];
355
+ readonly wasmwillmessage_messageExpiryInterval: (a: number) => number;
325
356
  readonly wasmwillmessage_new: (a: number, b: number, c: number, d: number) => number;
326
357
  readonly wasmwillmessage_qos: (a: number) => number;
327
358
  readonly wasmwillmessage_responseTopic: (a: number) => [number, number];
328
359
  readonly wasmwillmessage_retain: (a: number) => number;
329
360
  readonly wasmwillmessage_set_contentType: (a: number, b: number, c: number) => void;
361
+ readonly wasmwillmessage_set_messageExpiryInterval: (a: number, b: number) => void;
330
362
  readonly wasmwillmessage_set_qos: (a: number, b: number) => void;
331
363
  readonly wasmwillmessage_set_responseTopic: (a: number, b: number, c: number) => void;
332
364
  readonly wasmwillmessage_set_retain: (a: number, b: number) => void;
333
365
  readonly wasmwillmessage_set_topic: (a: number, b: number, c: number) => void;
366
+ readonly wasmwillmessage_set_willDelayInterval: (a: number, b: number) => void;
334
367
  readonly wasmwillmessage_topic: (a: number) => [number, number];
335
- readonly wasmmessageproperties_messageExpiryInterval: (a: number) => number;
336
- readonly wasmpublishoptions_messageExpiryInterval: (a: number) => number;
337
- readonly wasmsubscribeoptions_subscriptionIdentifier: (a: number) => number;
338
- readonly wasmwillmessage_messageExpiryInterval: (a: number) => number;
339
368
  readonly wasmwillmessage_willDelayInterval: (a: number) => number;
340
- readonly wasmconnectoptions_set_sessionExpiryInterval: (a: number, b: number) => void;
341
- readonly wasmpublishoptions_set_messageExpiryInterval: (a: number, b: number) => void;
342
- readonly wasmsubscribeoptions_set_subscriptionIdentifier: (a: number, b: number) => void;
343
- readonly wasmwillmessage_set_willDelayInterval: (a: number, b: number) => void;
344
- readonly wasmwillmessage_set_messageExpiryInterval: (a: number, b: number) => void;
345
- readonly wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e: (a: number, b: number, c: any) => void;
346
- readonly wasm_bindgen__closure__destroy__h21a697eaf8c5d6e0: (a: number, b: number) => void;
347
- readonly wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b: (a: number, b: number) => void;
348
- readonly wasm_bindgen__closure__destroy__he9d43d9a42a0e056: (a: number, b: number) => void;
349
369
  readonly wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0: (a: number, b: number, c: any) => void;
350
370
  readonly wasm_bindgen__closure__destroy__h849099dfd9acf928: (a: number, b: number) => void;
371
+ readonly wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a: (a: number, b: number, c: any) => void;
372
+ readonly wasm_bindgen__closure__destroy__h25acc308bc5379fe: (a: number, b: number) => void;
373
+ readonly wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b: (a: number, b: number) => void;
374
+ readonly wasm_bindgen__closure__destroy__he9d43d9a42a0e056: (a: number, b: number) => void;
351
375
  readonly wasm_bindgen__convert__closures_____invoke__h1ee277075b103ebf: (a: number, b: number, c: any, d: any) => void;
352
376
  readonly __wbindgen_malloc: (a: number, b: number) => number;
353
377
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -355,8 +379,8 @@ export interface InitOutput {
355
379
  readonly __externref_table_alloc: () => number;
356
380
  readonly __wbindgen_externrefs: WebAssembly.Table;
357
381
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
358
- readonly __externref_table_dealloc: (a: number) => void;
359
382
  readonly __externref_drop_slice: (a: number, b: number) => void;
383
+ readonly __externref_table_dealloc: (a: number) => void;
360
384
  readonly __wbindgen_start: () => void;
361
385
  }
362
386
 
package/mqtt5_wasm.js CHANGED
@@ -251,16 +251,16 @@ if (!('encodeInto' in cachedTextEncoder)) {
251
251
 
252
252
  let WASM_VECTOR_LEN = 0;
253
253
 
254
- function wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e(arg0, arg1, arg2) {
255
- wasm.wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e(arg0, arg1, arg2);
254
+ function wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0(arg0, arg1, arg2) {
255
+ wasm.wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0(arg0, arg1, arg2);
256
256
  }
257
257
 
258
- function wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b(arg0, arg1) {
259
- wasm.wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b(arg0, arg1);
258
+ function wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a(arg0, arg1, arg2) {
259
+ wasm.wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a(arg0, arg1, arg2);
260
260
  }
261
261
 
262
- function wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0(arg0, arg1, arg2) {
263
- wasm.wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0(arg0, arg1, arg2);
262
+ function wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b(arg0, arg1) {
263
+ wasm.wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b(arg0, arg1);
264
264
  }
265
265
 
266
266
  function wasm_bindgen__convert__closures_____invoke__h1ee277075b103ebf(arg0, arg1, arg2, arg3) {
@@ -422,6 +422,20 @@ export class WasmBroker {
422
422
  const ret = wasm.wasmbroker_add_bridge(this.__wbg_ptr, ptr0, remote_port);
423
423
  return ret;
424
424
  }
425
+ /**
426
+ * @returns {Promise<string[]>}
427
+ */
428
+ list_roles() {
429
+ const ret = wasm.wasmbroker_list_roles(this.__wbg_ptr);
430
+ return ret;
431
+ }
432
+ /**
433
+ * @returns {Promise<number>}
434
+ */
435
+ role_count() {
436
+ const ret = wasm.wasmbroker_role_count(this.__wbg_ptr);
437
+ return ret;
438
+ }
425
439
  /**
426
440
  * @returns {Promise<number>}
427
441
  */
@@ -429,6 +443,36 @@ export class WasmBroker {
429
443
  const ret = wasm.wasmbroker_user_count(this.__wbg_ptr);
430
444
  return ret;
431
445
  }
446
+ /**
447
+ * @param {string} username
448
+ * @param {string} role_name
449
+ * @returns {Promise<void>}
450
+ */
451
+ assign_role(username, role_name) {
452
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
453
+ const len0 = WASM_VECTOR_LEN;
454
+ const ptr1 = passStringToWasm0(role_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
455
+ const len1 = WASM_VECTOR_LEN;
456
+ const ret = wasm.wasmbroker_assign_role(this.__wbg_ptr, ptr0, len0, ptr1, len1);
457
+ return ret;
458
+ }
459
+ /**
460
+ * @returns {Promise<void>}
461
+ */
462
+ clear_roles() {
463
+ const ret = wasm.wasmbroker_clear_roles(this.__wbg_ptr);
464
+ return ret;
465
+ }
466
+ /**
467
+ * @param {string} name
468
+ * @returns {Promise<boolean>}
469
+ */
470
+ remove_role(name) {
471
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ret = wasm.wasmbroker_remove_role(this.__wbg_ptr, ptr0, len0);
474
+ return ret;
475
+ }
432
476
  /**
433
477
  * @param {string} username
434
478
  * @returns {Promise<boolean>}
@@ -477,6 +521,22 @@ export class WasmBroker {
477
521
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
478
522
  return v1;
479
523
  }
524
+ /**
525
+ * @param {string} role_name
526
+ * @param {string} topic_pattern
527
+ * @param {string} permission
528
+ * @returns {Promise<void>}
529
+ */
530
+ add_role_rule(role_name, topic_pattern, permission) {
531
+ const ptr0 = passStringToWasm0(role_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
+ const len0 = WASM_VECTOR_LEN;
533
+ const ptr1 = passStringToWasm0(topic_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
534
+ const len1 = WASM_VECTOR_LEN;
535
+ const ptr2 = passStringToWasm0(permission, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
536
+ const len2 = WASM_VECTOR_LEN;
537
+ const ret = wasm.wasmbroker_add_role_rule(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
538
+ return ret;
539
+ }
480
540
  /**
481
541
  * @param {string} password
482
542
  * @returns {string}
@@ -511,6 +571,19 @@ export class WasmBroker {
511
571
  const ret = wasm.wasmbroker_remove_bridge(this.__wbg_ptr, ptr0, len0);
512
572
  return ret;
513
573
  }
574
+ /**
575
+ * @param {string} username
576
+ * @param {string} role_name
577
+ * @returns {Promise<boolean>}
578
+ */
579
+ unassign_role(username, role_name) {
580
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
581
+ const len0 = WASM_VECTOR_LEN;
582
+ const ptr1 = passStringToWasm0(role_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
583
+ const len1 = WASM_VECTOR_LEN;
584
+ const ret = wasm.wasmbroker_unassign_role(this.__wbg_ptr, ptr0, len0, ptr1, len1);
585
+ return ret;
586
+ }
514
587
  /**
515
588
  * @returns {Promise<number>}
516
589
  */
@@ -518,6 +591,16 @@ export class WasmBroker {
518
591
  const ret = wasm.wasmbroker_acl_rule_count(this.__wbg_ptr);
519
592
  return ret;
520
593
  }
594
+ /**
595
+ * @param {string} username
596
+ * @returns {Promise<string[]>}
597
+ */
598
+ get_user_roles(username) {
599
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
600
+ const len0 = WASM_VECTOR_LEN;
601
+ const ret = wasm.wasmbroker_get_user_roles(this.__wbg_ptr, ptr0, len0);
602
+ return ret;
603
+ }
521
604
  /**
522
605
  * @returns {Promise<void>}
523
606
  */
@@ -525,6 +608,12 @@ export class WasmBroker {
525
608
  const ret = wasm.wasmbroker_clear_acl_rules(this.__wbg_ptr);
526
609
  return ret;
527
610
  }
611
+ stop_sys_topics() {
612
+ wasm.wasmbroker_stop_sys_topics(this.__wbg_ptr);
613
+ }
614
+ start_sys_topics() {
615
+ wasm.wasmbroker_start_sys_topics(this.__wbg_ptr);
616
+ }
528
617
  /**
529
618
  * @returns {Promise<void>}
530
619
  */
@@ -555,6 +644,12 @@ export class WasmBroker {
555
644
  }
556
645
  return takeFromExternrefTable0(ret[0]);
557
646
  }
647
+ /**
648
+ * @param {number} interval_secs
649
+ */
650
+ start_sys_topics_with_interval_secs(interval_secs) {
651
+ wasm.wasmbroker_start_sys_topics_with_interval_secs(this.__wbg_ptr, interval_secs);
652
+ }
558
653
  constructor() {
559
654
  const ret = wasm.wasmbroker_new();
560
655
  if (ret[2]) {
@@ -564,6 +659,16 @@ export class WasmBroker {
564
659
  WasmBrokerFinalization.register(this, this.__wbg_ptr, this);
565
660
  return this;
566
661
  }
662
+ /**
663
+ * @param {string} name
664
+ * @returns {Promise<void>}
665
+ */
666
+ add_role(name) {
667
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
668
+ const len0 = WASM_VECTOR_LEN;
669
+ const ret = wasm.wasmbroker_add_role(this.__wbg_ptr, ptr0, len0);
670
+ return ret;
671
+ }
567
672
  /**
568
673
  * @param {string} username
569
674
  * @param {string} password
@@ -837,7 +942,7 @@ export class WasmConnectOptions {
837
942
  * @param {number | null} [value]
838
943
  */
839
944
  set sessionExpiryInterval(value) {
840
- wasm.wasmbrokerconfig_set_server_keep_alive_secs(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
945
+ wasm.wasmconnectoptions_set_sessionExpiryInterval(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
841
946
  }
842
947
  /**
843
948
  * @returns {boolean | undefined}
@@ -959,7 +1064,7 @@ export class WasmMessageProperties {
959
1064
  * @returns {number | undefined}
960
1065
  */
961
1066
  get messageExpiryInterval() {
962
- const ret = wasm.wasmconnectoptions_sessionExpiryInterval(this.__wbg_ptr);
1067
+ const ret = wasm.wasmmessageproperties_messageExpiryInterval(this.__wbg_ptr);
963
1068
  return ret === 0x100000001 ? undefined : ret;
964
1069
  }
965
1070
  /**
@@ -1300,7 +1405,7 @@ export class WasmPublishOptions {
1300
1405
  * @returns {number | undefined}
1301
1406
  */
1302
1407
  get messageExpiryInterval() {
1303
- const ret = wasm.wasmconnectoptions_sessionExpiryInterval(this.__wbg_ptr);
1408
+ const ret = wasm.wasmpublishoptions_messageExpiryInterval(this.__wbg_ptr);
1304
1409
  return ret === 0x100000001 ? undefined : ret;
1305
1410
  }
1306
1411
  /**
@@ -1314,7 +1419,7 @@ export class WasmPublishOptions {
1314
1419
  * @param {number | null} [value]
1315
1420
  */
1316
1421
  set messageExpiryInterval(value) {
1317
- wasm.wasmbrokerconfig_set_server_keep_alive_secs(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1422
+ wasm.wasmpublishoptions_set_messageExpiryInterval(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1318
1423
  }
1319
1424
  /**
1320
1425
  * @param {boolean | null} [value]
@@ -1398,14 +1503,14 @@ export class WasmSubscribeOptions {
1398
1503
  * @returns {number | undefined}
1399
1504
  */
1400
1505
  get subscriptionIdentifier() {
1401
- const ret = wasm.wasmconnectoptions_sessionExpiryInterval(this.__wbg_ptr);
1506
+ const ret = wasm.wasmsubscribeoptions_subscriptionIdentifier(this.__wbg_ptr);
1402
1507
  return ret === 0x100000001 ? undefined : ret;
1403
1508
  }
1404
1509
  /**
1405
1510
  * @param {number | null} [value]
1406
1511
  */
1407
1512
  set subscriptionIdentifier(value) {
1408
- wasm.wasmbrokerconfig_set_server_keep_alive_secs(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1513
+ wasm.wasmsubscribeoptions_set_subscriptionIdentifier(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1409
1514
  }
1410
1515
  constructor() {
1411
1516
  const ret = wasm.wasmsubscribeoptions_new();
@@ -1545,27 +1650,27 @@ export class WasmWillMessage {
1545
1650
  * @returns {number | undefined}
1546
1651
  */
1547
1652
  get willDelayInterval() {
1548
- const ret = wasm.wasmconnectoptions_sessionExpiryInterval(this.__wbg_ptr);
1653
+ const ret = wasm.wasmwillmessage_willDelayInterval(this.__wbg_ptr);
1549
1654
  return ret === 0x100000001 ? undefined : ret;
1550
1655
  }
1551
1656
  /**
1552
1657
  * @returns {number | undefined}
1553
1658
  */
1554
1659
  get messageExpiryInterval() {
1555
- const ret = wasm.wasmconnectoptions_maximumPacketSize(this.__wbg_ptr);
1660
+ const ret = wasm.wasmwillmessage_messageExpiryInterval(this.__wbg_ptr);
1556
1661
  return ret === 0x100000001 ? undefined : ret;
1557
1662
  }
1558
1663
  /**
1559
1664
  * @param {number | null} [value]
1560
1665
  */
1561
1666
  set willDelayInterval(value) {
1562
- wasm.wasmbrokerconfig_set_server_keep_alive_secs(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1667
+ wasm.wasmwillmessage_set_willDelayInterval(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1563
1668
  }
1564
1669
  /**
1565
1670
  * @param {number | null} [value]
1566
1671
  */
1567
1672
  set messageExpiryInterval(value) {
1568
- wasm.wasmconnectoptions_set_maximumPacketSize(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1673
+ wasm.wasmwillmessage_set_messageExpiryInterval(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
1569
1674
  }
1570
1675
  /**
1571
1676
  * @param {string} topic
@@ -1936,24 +2041,31 @@ function __wbg_get_imports() {
1936
2041
  const ret = getStringFromWasm0(arg0, arg1);
1937
2042
  return ret;
1938
2043
  };
1939
- imports.wbg.__wbindgen_cast_272c165660a21b68 = function(arg0, arg1) {
1940
- // Cast intrinsic for `Closure(Closure { dtor_idx: 280, function: Function { arguments: [Externref], shim_idx: 281, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1941
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h849099dfd9acf928, wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0);
2044
+ imports.wbg.__wbindgen_cast_25a0a844437d0e92 = function(arg0, arg1) {
2045
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2046
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2047
+ // Cast intrinsic for `Vector(NamedExternref("string")) -> Externref`.
2048
+ const ret = v0;
1942
2049
  return ret;
1943
2050
  };
1944
- imports.wbg.__wbindgen_cast_7776c8637c2963f5 = function(arg0, arg1) {
1945
- // Cast intrinsic for `Closure(Closure { dtor_idx: 14, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 15, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1946
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h21a697eaf8c5d6e0, wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e);
2051
+ imports.wbg.__wbindgen_cast_5208882bb9fe3820 = function(arg0, arg1) {
2052
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2053
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he9d43d9a42a0e056, wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b);
1947
2054
  return ret;
1948
2055
  };
1949
- imports.wbg.__wbindgen_cast_943816c95a67e66d = function(arg0, arg1) {
1950
- // Cast intrinsic for `Closure(Closure { dtor_idx: 269, function: Function { arguments: [], shim_idx: 270, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1951
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he9d43d9a42a0e056, wasm_bindgen__convert__closures_____invoke__hf9723d0014506a5b);
2056
+ imports.wbg.__wbindgen_cast_663c73182bf372f2 = function(arg0, arg1) {
2057
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 369, function: Function { arguments: [Externref], shim_idx: 370, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2058
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h849099dfd9acf928, wasm_bindgen__convert__closures_____invoke__ha9d3e198cd0951b0);
2059
+ return ret;
2060
+ };
2061
+ imports.wbg.__wbindgen_cast_a6d58121ace2ceaa = function(arg0, arg1) {
2062
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 7, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 8, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2063
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h25acc308bc5379fe, wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a);
1952
2064
  return ret;
1953
2065
  };
1954
- imports.wbg.__wbindgen_cast_b05293a5b76000cf = function(arg0, arg1) {
1955
- // Cast intrinsic for `Closure(Closure { dtor_idx: 14, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 15, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1956
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h21a697eaf8c5d6e0, wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e);
2066
+ imports.wbg.__wbindgen_cast_d3f7166d7f91ad34 = function(arg0, arg1) {
2067
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 7, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 8, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2068
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h25acc308bc5379fe, wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a);
1957
2069
  return ret;
1958
2070
  };
1959
2071
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
@@ -1961,9 +2073,9 @@ function __wbg_get_imports() {
1961
2073
  const ret = arg0;
1962
2074
  return ret;
1963
2075
  };
1964
- imports.wbg.__wbindgen_cast_e5e5fe8f2379daee = function(arg0, arg1) {
1965
- // Cast intrinsic for `Closure(Closure { dtor_idx: 14, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 15, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1966
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h21a697eaf8c5d6e0, wasm_bindgen__convert__closures_____invoke__h01763d79c10fe65e);
2076
+ imports.wbg.__wbindgen_cast_fac85390ef55bfaa = function(arg0, arg1) {
2077
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 7, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 8, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2078
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h25acc308bc5379fe, wasm_bindgen__convert__closures_____invoke__h083737b2f77d415a);
1967
2079
  return ret;
1968
2080
  };
1969
2081
  imports.wbg.__wbindgen_init_externref_table = function() {
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "fabriciobracht <fabricio@bracht.dev>"
6
6
  ],
7
7
  "description": "MQTT v5.0 WebAssembly client and broker for browser environments",
8
- "version": "0.4.0",
8
+ "version": "0.7.0",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",