@haex-space/vault-sdk 3.2.8 → 3.3.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.
@@ -19,6 +19,10 @@ var HAEXTENSION_EVENTS = {
19
19
  * subscribe via `client.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, ...)`. */
20
20
  PERMISSION_RESOLVED: "extension:permission-resolved"
21
21
  };
22
+ var NOTIFICATION_EVENTS = {
23
+ /** A click on one of this extension's notifications (body or action button). */
24
+ CLICK: "haextension:notification:click"
25
+ };
22
26
  var EXTERNAL_EVENTS = {
23
27
  /** External request from authorized client */
24
28
  REQUEST: "haextension:external:request",
@@ -303,6 +307,14 @@ var MAIL_COMMANDS = {
303
307
  buildRfc822: "extension_mail_build_rfc822"
304
308
  };
305
309
 
310
+ // src/commands/notifications.ts
311
+ var NOTIFICATION_COMMANDS = {
312
+ /** Show an OS notification. Returns the assigned notification id. */
313
+ show: "extension_notifications_show",
314
+ /** Dismiss a previously shown notification (only own notifications). */
315
+ dismiss: "extension_notifications_dismiss"
316
+ };
317
+
306
318
  // src/api/storage.ts
307
319
  var StorageAPI = class {
308
320
  constructor(client) {
@@ -1402,6 +1414,38 @@ var MailAPI = class {
1402
1414
  }
1403
1415
  };
1404
1416
 
1417
+ // src/api/notifications.ts
1418
+ var NotificationsAPI = class {
1419
+ constructor(client) {
1420
+ this.client = client;
1421
+ }
1422
+ /** Show a notification. Returns its id so it can be dismissed later. */
1423
+ async show(opts) {
1424
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
1425
+ options: opts
1426
+ });
1427
+ }
1428
+ /** Dismiss a previously shown notification (only own notifications). */
1429
+ async dismiss(id) {
1430
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
1431
+ }
1432
+ /**
1433
+ * Listen for clicks on this extension's notifications. Useful when the
1434
+ * extension is already open and wants to react in-app (e.g. router.push the
1435
+ * `path`) instead of relying on the host to focus the webview.
1436
+ *
1437
+ * Returns an unsubscribe function.
1438
+ */
1439
+ onClick(handler) {
1440
+ const wrapped = (event) => {
1441
+ const data = event.data;
1442
+ if (data) handler(data);
1443
+ };
1444
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
1445
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
1446
+ }
1447
+ };
1448
+
1405
1449
  // src/messages.ts
1406
1450
  var HAEXSPACE_MESSAGE_TYPES = {
1407
1451
  /** Debug message for development/troubleshooting */
@@ -1660,6 +1704,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1660
1704
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
1661
1705
  EXTERNAL_EVENTS.REQUEST,
1662
1706
  EXTERNAL_EVENTS.ACTION_REQUEST,
1707
+ NOTIFICATION_EVENTS.CLICK,
1663
1708
  ...Object.values(LOCALSEND_EVENTS)
1664
1709
  ]) {
1665
1710
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2135,6 +2180,7 @@ var HaexVaultSdk = class {
2135
2180
  this.shell = new ShellAPI(this);
2136
2181
  this.passwords = new PasswordsAPI(this);
2137
2182
  this.mail = new MailAPI(this);
2183
+ this.notifications = new NotificationsAPI(this);
2138
2184
  installConsoleForwarding(this.config.debug);
2139
2185
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2140
2186
  const data = event.data;