@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.
package/dist/react.mjs CHANGED
@@ -402,6 +402,10 @@ var HAEXTENSION_EVENTS = {
402
402
  * subscribe via `client.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, ...)`. */
403
403
  PERMISSION_RESOLVED: "extension:permission-resolved"
404
404
  };
405
+ var NOTIFICATION_EVENTS = {
406
+ /** A click on one of this extension's notifications (body or action button). */
407
+ CLICK: "haextension:notification:click"
408
+ };
405
409
  var EXTERNAL_EVENTS = {
406
410
  /** External request from authorized client */
407
411
  REQUEST: "haextension:external:request",
@@ -686,6 +690,14 @@ var MAIL_COMMANDS = {
686
690
  buildRfc822: "extension_mail_build_rfc822"
687
691
  };
688
692
 
693
+ // src/commands/notifications.ts
694
+ var NOTIFICATION_COMMANDS = {
695
+ /** Show an OS notification. Returns the assigned notification id. */
696
+ show: "extension_notifications_show",
697
+ /** Dismiss a previously shown notification (only own notifications). */
698
+ dismiss: "extension_notifications_dismiss"
699
+ };
700
+
689
701
  // src/api/storage.ts
690
702
  var StorageAPI = class {
691
703
  constructor(client) {
@@ -1760,6 +1772,38 @@ var MailAPI = class {
1760
1772
  }
1761
1773
  };
1762
1774
 
1775
+ // src/api/notifications.ts
1776
+ var NotificationsAPI = class {
1777
+ constructor(client) {
1778
+ this.client = client;
1779
+ }
1780
+ /** Show a notification. Returns its id so it can be dismissed later. */
1781
+ async show(opts) {
1782
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
1783
+ options: opts
1784
+ });
1785
+ }
1786
+ /** Dismiss a previously shown notification (only own notifications). */
1787
+ async dismiss(id) {
1788
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
1789
+ }
1790
+ /**
1791
+ * Listen for clicks on this extension's notifications. Useful when the
1792
+ * extension is already open and wants to react in-app (e.g. router.push the
1793
+ * `path`) instead of relying on the host to focus the webview.
1794
+ *
1795
+ * Returns an unsubscribe function.
1796
+ */
1797
+ onClick(handler) {
1798
+ const wrapped = (event) => {
1799
+ const data = event.data;
1800
+ if (data) handler(data);
1801
+ };
1802
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
1803
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
1804
+ }
1805
+ };
1806
+
1763
1807
  // src/client/tableName.ts
1764
1808
  function validatePublicKey(publicKey) {
1765
1809
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1927,6 +1971,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1927
1971
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
1928
1972
  EXTERNAL_EVENTS.REQUEST,
1929
1973
  EXTERNAL_EVENTS.ACTION_REQUEST,
1974
+ NOTIFICATION_EVENTS.CLICK,
1930
1975
  ...Object.values(LOCALSEND_EVENTS)
1931
1976
  ]) {
1932
1977
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2402,6 +2447,7 @@ var HaexVaultSdk = class {
2402
2447
  this.shell = new ShellAPI(this);
2403
2448
  this.passwords = new PasswordsAPI(this);
2404
2449
  this.mail = new MailAPI(this);
2450
+ this.notifications = new NotificationsAPI(this);
2405
2451
  installConsoleForwarding(this.config.debug);
2406
2452
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2407
2453
  const data = event.data;