@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.
@@ -1,7 +1,7 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-DaS2fAf-.mjs';
4
- import { A as ApplicationContext } from '../types-Cji-mUN0.mjs';
3
+ import { H as HaexVaultSdk } from '../client-BW3ayV19.mjs';
4
+ import { A as ApplicationContext } from '../types-fHuxbqa4.mjs';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
7
7
  declare const _default: nuxt_app.Plugin<{
@@ -1,7 +1,7 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-BBD-YsPv.js';
4
- import { A as ApplicationContext } from '../types-Cji-mUN0.js';
3
+ import { H as HaexVaultSdk } from '../client-Cm23j1wm.js';
4
+ import { A as ApplicationContext } from '../types-fHuxbqa4.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
7
7
  declare const _default: nuxt_app.Plugin<{
@@ -21,6 +21,10 @@ var HAEXTENSION_EVENTS = {
21
21
  * subscribe via `client.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, ...)`. */
22
22
  PERMISSION_RESOLVED: "extension:permission-resolved"
23
23
  };
24
+ var NOTIFICATION_EVENTS = {
25
+ /** A click on one of this extension's notifications (body or action button). */
26
+ CLICK: "haextension:notification:click"
27
+ };
24
28
  var EXTERNAL_EVENTS = {
25
29
  /** External request from authorized client */
26
30
  REQUEST: "haextension:external:request",
@@ -305,6 +309,14 @@ var MAIL_COMMANDS = {
305
309
  buildRfc822: "extension_mail_build_rfc822"
306
310
  };
307
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
+
308
320
  // src/api/storage.ts
309
321
  var StorageAPI = class {
310
322
  constructor(client) {
@@ -1404,6 +1416,38 @@ var MailAPI = class {
1404
1416
  }
1405
1417
  };
1406
1418
 
1419
+ // src/api/notifications.ts
1420
+ var NotificationsAPI = class {
1421
+ constructor(client) {
1422
+ this.client = client;
1423
+ }
1424
+ /** Show a notification. Returns its id so it can be dismissed later. */
1425
+ async show(opts) {
1426
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
1427
+ options: opts
1428
+ });
1429
+ }
1430
+ /** Dismiss a previously shown notification (only own notifications). */
1431
+ async dismiss(id) {
1432
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
1433
+ }
1434
+ /**
1435
+ * Listen for clicks on this extension's notifications. Useful when the
1436
+ * extension is already open and wants to react in-app (e.g. router.push the
1437
+ * `path`) instead of relying on the host to focus the webview.
1438
+ *
1439
+ * Returns an unsubscribe function.
1440
+ */
1441
+ onClick(handler) {
1442
+ const wrapped = (event) => {
1443
+ const data = event.data;
1444
+ if (data) handler(data);
1445
+ };
1446
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
1447
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
1448
+ }
1449
+ };
1450
+
1407
1451
  // src/messages.ts
1408
1452
  var HAEXSPACE_MESSAGE_TYPES = {
1409
1453
  /** Debug message for development/troubleshooting */
@@ -1662,6 +1706,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1662
1706
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
1663
1707
  EXTERNAL_EVENTS.REQUEST,
1664
1708
  EXTERNAL_EVENTS.ACTION_REQUEST,
1709
+ NOTIFICATION_EVENTS.CLICK,
1665
1710
  ...Object.values(LOCALSEND_EVENTS)
1666
1711
  ]) {
1667
1712
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2137,6 +2182,7 @@ var HaexVaultSdk = class {
2137
2182
  this.shell = new ShellAPI(this);
2138
2183
  this.passwords = new PasswordsAPI(this);
2139
2184
  this.mail = new MailAPI(this);
2185
+ this.notifications = new NotificationsAPI(this);
2140
2186
  installConsoleForwarding(this.config.debug);
2141
2187
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2142
2188
  const data = event.data;