@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.
@@ -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",
@@ -291,6 +295,8 @@ var MAIL_COMMANDS = {
291
295
  fetchEnvelopes: "extension_mail_fetch_envelopes",
292
296
  /** Full message fetch (envelope + body + attachment metadata) */
293
297
  fetchMessage: "extension_mail_fetch_message",
298
+ /** Fetch a single attachment's bytes (base64) by part index */
299
+ fetchAttachment: "extension_mail_fetch_attachment",
294
300
  /** Set or unset IMAP flags on a UID set */
295
301
  setFlags: "extension_mail_set_flags",
296
302
  /** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
@@ -303,6 +309,14 @@ var MAIL_COMMANDS = {
303
309
  buildRfc822: "extension_mail_build_rfc822"
304
310
  };
305
311
 
312
+ // src/commands/notifications.ts
313
+ var NOTIFICATION_COMMANDS = {
314
+ /** Show an OS notification. Returns the assigned notification id. */
315
+ show: "extension_notifications_show",
316
+ /** Dismiss a previously shown notification (only own notifications). */
317
+ dismiss: "extension_notifications_dismiss"
318
+ };
319
+
306
320
  // src/api/storage.ts
307
321
  var StorageAPI = class {
308
322
  constructor(client) {
@@ -1347,6 +1361,21 @@ var MailAPI = class {
1347
1361
  uid
1348
1362
  });
1349
1363
  }
1364
+ /**
1365
+ * Fetch a single attachment's raw bytes by its `partIndex` (from the
1366
+ * `attachments` array of a fetched `MailMessage`), returned as a
1367
+ * standard-alphabet base64 string. The base64 form drops straight into
1368
+ * `OutgoingAttachment.data` when forwarding, and decodes to bytes for
1369
+ * viewing or downloading.
1370
+ */
1371
+ async fetchAttachmentAsync(imap, mailbox, uid, partIndex) {
1372
+ return this.client.request(MAIL_COMMANDS.fetchAttachment, {
1373
+ imap,
1374
+ mailbox,
1375
+ uid,
1376
+ partIndex
1377
+ });
1378
+ }
1350
1379
  /**
1351
1380
  * Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
1352
1381
  * mark messages as read; `add=false` removes the flag(s).
@@ -1402,6 +1431,38 @@ var MailAPI = class {
1402
1431
  }
1403
1432
  };
1404
1433
 
1434
+ // src/api/notifications.ts
1435
+ var NotificationsAPI = class {
1436
+ constructor(client) {
1437
+ this.client = client;
1438
+ }
1439
+ /** Show a notification. Returns its id so it can be dismissed later. */
1440
+ async show(opts) {
1441
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
1442
+ options: opts
1443
+ });
1444
+ }
1445
+ /** Dismiss a previously shown notification (only own notifications). */
1446
+ async dismiss(id) {
1447
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
1448
+ }
1449
+ /**
1450
+ * Listen for clicks on this extension's notifications. Useful when the
1451
+ * extension is already open and wants to react in-app (e.g. router.push the
1452
+ * `path`) instead of relying on the host to focus the webview.
1453
+ *
1454
+ * Returns an unsubscribe function.
1455
+ */
1456
+ onClick(handler) {
1457
+ const wrapped = (event) => {
1458
+ const data = event.data;
1459
+ if (data) handler(data);
1460
+ };
1461
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
1462
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
1463
+ }
1464
+ };
1465
+
1405
1466
  // src/messages.ts
1406
1467
  var HAEXSPACE_MESSAGE_TYPES = {
1407
1468
  /** Debug message for development/troubleshooting */
@@ -1660,6 +1721,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1660
1721
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
1661
1722
  EXTERNAL_EVENTS.REQUEST,
1662
1723
  EXTERNAL_EVENTS.ACTION_REQUEST,
1724
+ NOTIFICATION_EVENTS.CLICK,
1663
1725
  ...Object.values(LOCALSEND_EVENTS)
1664
1726
  ]) {
1665
1727
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2135,6 +2197,7 @@ var HaexVaultSdk = class {
2135
2197
  this.shell = new ShellAPI(this);
2136
2198
  this.passwords = new PasswordsAPI(this);
2137
2199
  this.mail = new MailAPI(this);
2200
+ this.notifications = new NotificationsAPI(this);
2138
2201
  installConsoleForwarding(this.config.debug);
2139
2202
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2140
2203
  const data = event.data;