@haex-space/vault-sdk 3.2.8 → 3.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.
package/dist/vue.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",
@@ -674,6 +678,8 @@ var MAIL_COMMANDS = {
674
678
  fetchEnvelopes: "extension_mail_fetch_envelopes",
675
679
  /** Full message fetch (envelope + body + attachment metadata) */
676
680
  fetchMessage: "extension_mail_fetch_message",
681
+ /** Fetch a single attachment's bytes (base64) by part index */
682
+ fetchAttachment: "extension_mail_fetch_attachment",
677
683
  /** Set or unset IMAP flags on a UID set */
678
684
  setFlags: "extension_mail_set_flags",
679
685
  /** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
@@ -686,6 +692,14 @@ var MAIL_COMMANDS = {
686
692
  buildRfc822: "extension_mail_build_rfc822"
687
693
  };
688
694
 
695
+ // src/commands/notifications.ts
696
+ var NOTIFICATION_COMMANDS = {
697
+ /** Show an OS notification. Returns the assigned notification id. */
698
+ show: "extension_notifications_show",
699
+ /** Dismiss a previously shown notification (only own notifications). */
700
+ dismiss: "extension_notifications_dismiss"
701
+ };
702
+
689
703
  // src/api/storage.ts
690
704
  var StorageAPI = class {
691
705
  constructor(client) {
@@ -1705,6 +1719,21 @@ var MailAPI = class {
1705
1719
  uid
1706
1720
  });
1707
1721
  }
1722
+ /**
1723
+ * Fetch a single attachment's raw bytes by its `partIndex` (from the
1724
+ * `attachments` array of a fetched `MailMessage`), returned as a
1725
+ * standard-alphabet base64 string. The base64 form drops straight into
1726
+ * `OutgoingAttachment.data` when forwarding, and decodes to bytes for
1727
+ * viewing or downloading.
1728
+ */
1729
+ async fetchAttachmentAsync(imap, mailbox, uid, partIndex) {
1730
+ return this.client.request(MAIL_COMMANDS.fetchAttachment, {
1731
+ imap,
1732
+ mailbox,
1733
+ uid,
1734
+ partIndex
1735
+ });
1736
+ }
1708
1737
  /**
1709
1738
  * Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
1710
1739
  * mark messages as read; `add=false` removes the flag(s).
@@ -1760,6 +1789,38 @@ var MailAPI = class {
1760
1789
  }
1761
1790
  };
1762
1791
 
1792
+ // src/api/notifications.ts
1793
+ var NotificationsAPI = class {
1794
+ constructor(client) {
1795
+ this.client = client;
1796
+ }
1797
+ /** Show a notification. Returns its id so it can be dismissed later. */
1798
+ async show(opts) {
1799
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
1800
+ options: opts
1801
+ });
1802
+ }
1803
+ /** Dismiss a previously shown notification (only own notifications). */
1804
+ async dismiss(id) {
1805
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
1806
+ }
1807
+ /**
1808
+ * Listen for clicks on this extension's notifications. Useful when the
1809
+ * extension is already open and wants to react in-app (e.g. router.push the
1810
+ * `path`) instead of relying on the host to focus the webview.
1811
+ *
1812
+ * Returns an unsubscribe function.
1813
+ */
1814
+ onClick(handler) {
1815
+ const wrapped = (event) => {
1816
+ const data = event.data;
1817
+ if (data) handler(data);
1818
+ };
1819
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
1820
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
1821
+ }
1822
+ };
1823
+
1763
1824
  // src/client/tableName.ts
1764
1825
  function validatePublicKey(publicKey) {
1765
1826
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1927,6 +1988,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1927
1988
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
1928
1989
  EXTERNAL_EVENTS.REQUEST,
1929
1990
  EXTERNAL_EVENTS.ACTION_REQUEST,
1991
+ NOTIFICATION_EVENTS.CLICK,
1930
1992
  ...Object.values(LOCALSEND_EVENTS)
1931
1993
  ]) {
1932
1994
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2402,6 +2464,7 @@ var HaexVaultSdk = class {
2402
2464
  this.shell = new ShellAPI(this);
2403
2465
  this.passwords = new PasswordsAPI(this);
2404
2466
  this.mail = new MailAPI(this);
2467
+ this.notifications = new NotificationsAPI(this);
2405
2468
  installConsoleForwarding(this.config.debug);
2406
2469
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2407
2470
  const data = event.data;