@haex-space/vault-sdk 3.7.0 → 4.1.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.
Files changed (51) hide show
  1. package/README.md +51 -19
  2. package/dist/cli/index.js +437 -355
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli/index.mjs +428 -339
  5. package/dist/cli/index.mjs.map +1 -1
  6. package/dist/{client-DH4Km77u.d.ts → client-CD5QZi7F.d.ts} +76 -12
  7. package/dist/{client-Dn4AbXbT.d.mts → client-Cx4ZyQFL.d.mts} +76 -12
  8. package/dist/haex_bundle_bg.wasm +0 -0
  9. package/dist/index.d.mts +16 -61
  10. package/dist/index.d.ts +16 -61
  11. package/dist/index.js +185 -116
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +204 -134
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/node.d.mts +53 -2
  16. package/dist/node.d.ts +53 -2
  17. package/dist/node.js +319 -2
  18. package/dist/node.js.map +1 -1
  19. package/dist/node.mjs +320 -5
  20. package/dist/node.mjs.map +1 -1
  21. package/dist/nuxt.js +7 -5
  22. package/dist/nuxt.js.map +1 -1
  23. package/dist/nuxt.mjs +3 -2
  24. package/dist/nuxt.mjs.map +1 -1
  25. package/dist/react.d.mts +2 -2
  26. package/dist/react.d.ts +2 -2
  27. package/dist/react.js +192 -18
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +212 -38
  30. package/dist/react.mjs.map +1 -1
  31. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  32. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  33. package/dist/runtime/nuxt.plugin.client.js +100 -18
  34. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  35. package/dist/runtime/nuxt.plugin.client.mjs +100 -18
  36. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  37. package/dist/svelte.d.mts +2 -2
  38. package/dist/svelte.d.ts +2 -2
  39. package/dist/svelte.js +192 -18
  40. package/dist/svelte.js.map +1 -1
  41. package/dist/svelte.mjs +212 -38
  42. package/dist/svelte.mjs.map +1 -1
  43. package/dist/{types-DQZCRfC-.d.mts → types-BwFKGH70.d.mts} +11 -3
  44. package/dist/{types-DQZCRfC-.d.ts → types-BwFKGH70.d.ts} +11 -3
  45. package/dist/vue.d.mts +2 -2
  46. package/dist/vue.d.ts +2 -2
  47. package/dist/vue.js +192 -18
  48. package/dist/vue.js.map +1 -1
  49. package/dist/vue.mjs +212 -38
  50. package/dist/vue.mjs.map +1 -1
  51. package/package.json +9 -7
package/dist/vue.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import 'path';
2
+ import 'url';
1
3
  import { ref, readonly } from 'vue';
2
4
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
3
5
 
@@ -5,6 +7,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
7
  var __esm = (fn, res) => function __init() {
6
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
9
  };
10
+ var init_esm_shims = __esm({
11
+ "node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.29_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js"() {
12
+ }
13
+ });
8
14
 
9
15
  // src/crypto/vaultKey.ts
10
16
  function arrayBufferToBase64(buffer) {
@@ -34,17 +40,29 @@ function base64ToArrayBuffer(base64) {
34
40
  }
35
41
  var init_vaultKey = __esm({
36
42
  "src/crypto/vaultKey.ts"() {
43
+ init_esm_shims();
37
44
  }
38
45
  });
39
46
 
40
47
  // src/crypto/userKeypair.ts
41
48
  var init_userKeypair = __esm({
42
49
  "src/crypto/userKeypair.ts"() {
50
+ init_esm_shims();
43
51
  init_vaultKey();
44
52
  }
45
53
  });
46
54
 
55
+ // src/vue.ts
56
+ init_esm_shims();
57
+
58
+ // src/index.ts
59
+ init_esm_shims();
60
+
61
+ // src/polyfills/index.ts
62
+ init_esm_shims();
63
+
47
64
  // src/polyfills/localStorage.ts
65
+ init_esm_shims();
48
66
  function installLocalStoragePolyfill() {
49
67
  if (typeof window === "undefined") {
50
68
  return;
@@ -139,6 +157,7 @@ function installSessionStoragePolyfill() {
139
157
  }
140
158
 
141
159
  // src/polyfills/cookies.ts
160
+ init_esm_shims();
142
161
  function installCookiePolyfill() {
143
162
  if (typeof window === "undefined" || typeof document === "undefined") {
144
163
  return;
@@ -199,6 +218,7 @@ function installCookiePolyfill() {
199
218
  }
200
219
 
201
220
  // src/polyfills/history.ts
221
+ init_esm_shims();
202
222
  function installHistoryPolyfill() {
203
223
  if (typeof window === "undefined" || typeof history === "undefined") {
204
224
  return;
@@ -262,7 +282,11 @@ function installHistoryPolyfill() {
262
282
  }
263
283
  }
264
284
 
285
+ // src/polyfills/debug.ts
286
+ init_esm_shims();
287
+
265
288
  // src/messages.ts
289
+ init_esm_shims();
266
290
  var HAEXSPACE_MESSAGE_TYPES = {
267
291
  /** Debug message for development/troubleshooting */
268
292
  DEBUG: "haexspace:debug",
@@ -306,7 +330,11 @@ function installDebugDiagnostics() {
306
330
  }
307
331
  }
308
332
 
333
+ // src/polyfills/baseTag.ts
334
+ init_esm_shims();
335
+
309
336
  // src/polyfills/consoleForwarding.ts
337
+ init_esm_shims();
310
338
  var originalConsole = {
311
339
  log: console.log,
312
340
  info: console.info,
@@ -387,7 +415,14 @@ if (typeof window !== "undefined") {
387
415
  installPolyfills();
388
416
  }
389
417
 
418
+ // src/client.ts
419
+ init_esm_shims();
420
+
421
+ // src/types.ts
422
+ init_esm_shims();
423
+
390
424
  // src/events.ts
425
+ init_esm_shims();
391
426
  var HAEXTENSION_EVENTS = {
392
427
  /** Context (theme, locale, platform) has changed */
393
428
  CONTEXT_CHANGED: "haextension:context:changed",
@@ -465,7 +500,17 @@ var HaexVaultSdkError = class extends Error {
465
500
  }
466
501
  };
467
502
 
503
+ // src/api/storage.ts
504
+ init_esm_shims();
505
+
506
+ // src/commands.ts
507
+ init_esm_shims();
508
+
509
+ // src/commands/index.ts
510
+ init_esm_shims();
511
+
468
512
  // src/commands/database.ts
513
+ init_esm_shims();
469
514
  var DATABASE_COMMANDS = {
470
515
  /** Execute a SELECT query */
471
516
  query: "extension_database_query",
@@ -478,6 +523,7 @@ var DATABASE_COMMANDS = {
478
523
  };
479
524
 
480
525
  // src/commands/permissions.ts
526
+ init_esm_shims();
481
527
  var PERMISSIONS_COMMANDS = {
482
528
  /** Check web/fetch permission */
483
529
  checkWeb: "extension_permissions_check_web",
@@ -488,6 +534,7 @@ var PERMISSIONS_COMMANDS = {
488
534
  };
489
535
 
490
536
  // src/commands/web.ts
537
+ init_esm_shims();
491
538
  var WEB_COMMANDS = {
492
539
  /** Open URL in external browser */
493
540
  open: "extension_web_open",
@@ -496,6 +543,7 @@ var WEB_COMMANDS = {
496
543
  };
497
544
 
498
545
  // src/commands/webStorage.ts
546
+ init_esm_shims();
499
547
  var WEB_STORAGE_COMMANDS = {
500
548
  /** Get item from storage */
501
549
  getItem: "extension_web_storage_get_item",
@@ -510,6 +558,7 @@ var WEB_STORAGE_COMMANDS = {
510
558
  };
511
559
 
512
560
  // src/commands/filesystem.ts
561
+ init_esm_shims();
513
562
  var FILESYSTEM_COMMANDS = {
514
563
  // Dialog commands
515
564
  /** Show save file dialog */
@@ -553,19 +602,27 @@ var FILESYSTEM_COMMANDS = {
553
602
  };
554
603
 
555
604
  // src/commands/externalBridge.ts
605
+ init_esm_shims();
556
606
  var EXTERNAL_BRIDGE_COMMANDS = {
557
607
  // Response handling (called by extensions)
558
608
  /** Respond to an external request */
559
609
  respond: "external_bridge_respond"};
560
610
 
561
611
  // src/commands/extension.ts
612
+ init_esm_shims();
562
613
  var EXTENSION_COMMANDS = {
563
614
  /** Get extension info (manifest, id, etc.) */
564
615
  getInfo: "extension_get_info",
565
616
  /** Get application context (theme, locale, etc.) */
566
- getContext: "extension_context_get"};
617
+ getContext: "extension_context_get",
618
+ /** Ask the host to mark (or unmark) this extension's own tab as wanting attention */
619
+ tabAttention: "extension_tab_attention",
620
+ /** Ask the user to confirm, in a dialog the host draws over this extension's tab */
621
+ dialogConfirm: "extension_dialog_confirm"
622
+ };
567
623
 
568
624
  // src/commands/remoteStorage.ts
625
+ init_esm_shims();
569
626
  var REMOTE_STORAGE_COMMANDS = {
570
627
  // Backend Management
571
628
  /** List all storage backends */
@@ -590,6 +647,7 @@ var REMOTE_STORAGE_COMMANDS = {
590
647
  };
591
648
 
592
649
  // src/commands/localsend.ts
650
+ init_esm_shims();
593
651
  var LOCALSEND_COMMANDS = {
594
652
  // Initialization
595
653
  /** Initialize LocalSend (generate identity, etc.) */
@@ -636,6 +694,7 @@ var LOCALSEND_COMMANDS = {
636
694
  };
637
695
 
638
696
  // src/commands/spaces.ts
697
+ init_esm_shims();
639
698
  var SPACE_COMMANDS = {
640
699
  /** Bulk assign rows to spaces */
641
700
  assign: "extension_space_assign",
@@ -649,6 +708,7 @@ var SPACE_COMMANDS = {
649
708
  list: "extension_space_list"};
650
709
 
651
710
  // src/commands/shell.ts
711
+ init_esm_shims();
652
712
  var SHELL_COMMANDS = {
653
713
  /** List available shell environments (no permission required) */
654
714
  listAvailable: "extension_shell_list_available",
@@ -656,6 +716,8 @@ var SHELL_COMMANDS = {
656
716
  create: "extension_shell_create",
657
717
  /** Write data to a shell session's stdin */
658
718
  write: "extension_shell_write",
719
+ /** Acknowledge `shell:output` events handed on (backpressure; sent by the SDK itself) */
720
+ ack: "extension_shell_ack",
659
721
  /** Resize a shell session's terminal */
660
722
  resize: "extension_shell_resize",
661
723
  /** Close a shell session */
@@ -663,6 +725,7 @@ var SHELL_COMMANDS = {
663
725
  };
664
726
 
665
727
  // src/commands/passwords.ts
728
+ init_esm_shims();
666
729
  var PASSWORD_COMMANDS = {
667
730
  /** List items (no secrets) within the extension's tag scope */
668
731
  list: "extension_password_list",
@@ -677,6 +740,7 @@ var PASSWORD_COMMANDS = {
677
740
  };
678
741
 
679
742
  // src/commands/mail.ts
743
+ init_esm_shims();
680
744
  var MAIL_COMMANDS = {
681
745
  /** LIST mailboxes + optional STATUS counts */
682
746
  listMailboxes: "extension_mail_list_mailboxes",
@@ -696,13 +760,14 @@ var MAIL_COMMANDS = {
696
760
  sendMessage: "extension_mail_send_message",
697
761
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
698
762
  buildRfc822: "extension_mail_build_rfc822",
699
- /** Start (or replace) a background poll watch for an account/mailbox */
763
+ /** Start (or replace) a background new-mail watch for an account/mailbox */
700
764
  startWatch: "extension_mail_start_watch",
701
- /** Stop a background poll watch */
765
+ /** Stop a background new-mail watch */
702
766
  stopWatch: "extension_mail_stop_watch"
703
767
  };
704
768
 
705
769
  // src/commands/notifications.ts
770
+ init_esm_shims();
706
771
  var NOTIFICATION_COMMANDS = {
707
772
  /** Show an OS notification. Returns the assigned notification id. */
708
773
  show: "extension_notifications_show",
@@ -733,6 +798,7 @@ var StorageAPI = class {
733
798
  };
734
799
 
735
800
  // src/api/database.ts
801
+ init_esm_shims();
736
802
  function quoteIdent(identifier) {
737
803
  if (identifier.startsWith('"') && identifier.endsWith('"')) {
738
804
  return identifier;
@@ -832,6 +898,7 @@ var DatabaseAPI = class {
832
898
  };
833
899
 
834
900
  // src/api/filesystem.ts
901
+ init_esm_shims();
835
902
  init_vaultKey();
836
903
  var FilesystemAPI = class {
837
904
  constructor(client) {
@@ -898,10 +965,10 @@ var FilesystemAPI = class {
898
965
  * @param path Absolute path to the file
899
966
  * @returns File contents as Uint8Array
900
967
  */
901
- async readFile(path) {
968
+ async readFile(path2) {
902
969
  const base64 = await this.client.request(
903
970
  FILESYSTEM_COMMANDS.readFile,
904
- { path }
971
+ { path: path2 }
905
972
  );
906
973
  return base64ToArrayBuffer(base64);
907
974
  }
@@ -910,11 +977,11 @@ var FilesystemAPI = class {
910
977
  * @param path Absolute path to the file
911
978
  * @param data File contents as Uint8Array
912
979
  */
913
- async writeFile(path, data) {
980
+ async writeFile(path2, data) {
914
981
  const base64 = arrayBufferToBase64(data);
915
982
  await this.client.request(
916
983
  FILESYSTEM_COMMANDS.writeFile,
917
- { path, data: base64 }
984
+ { path: path2, data: base64 }
918
985
  );
919
986
  }
920
987
  /**
@@ -922,20 +989,20 @@ var FilesystemAPI = class {
922
989
  * @param path Absolute path to the directory
923
990
  * @returns Array of directory entries
924
991
  */
925
- async readDir(path) {
992
+ async readDir(path2) {
926
993
  return this.client.request(
927
994
  FILESYSTEM_COMMANDS.readDir,
928
- { path }
995
+ { path: path2 }
929
996
  );
930
997
  }
931
998
  /**
932
999
  * Create a directory (and parent directories if needed)
933
1000
  * @param path Absolute path to create
934
1001
  */
935
- async mkdir(path) {
1002
+ async mkdir(path2) {
936
1003
  await this.client.request(
937
1004
  FILESYSTEM_COMMANDS.mkdir,
938
- { path }
1005
+ { path: path2 }
939
1006
  );
940
1007
  }
941
1008
  /**
@@ -943,10 +1010,10 @@ var FilesystemAPI = class {
943
1010
  * @param path Absolute path to remove
944
1011
  * @param recursive If true, remove directories recursively
945
1012
  */
946
- async remove(path, recursive = false) {
1013
+ async remove(path2, recursive = false) {
947
1014
  await this.client.request(
948
1015
  FILESYSTEM_COMMANDS.remove,
949
- { path, recursive }
1016
+ { path: path2, recursive }
950
1017
  );
951
1018
  }
952
1019
  /**
@@ -954,10 +1021,10 @@ var FilesystemAPI = class {
954
1021
  * @param path Absolute path to check
955
1022
  * @returns True if the path exists
956
1023
  */
957
- async exists(path) {
1024
+ async exists(path2) {
958
1025
  return this.client.request(
959
1026
  FILESYSTEM_COMMANDS.exists,
960
- { path }
1027
+ { path: path2 }
961
1028
  );
962
1029
  }
963
1030
  /**
@@ -965,10 +1032,10 @@ var FilesystemAPI = class {
965
1032
  * @param path Absolute path
966
1033
  * @returns File metadata
967
1034
  */
968
- async stat(path) {
1035
+ async stat(path2) {
969
1036
  return this.client.request(
970
1037
  FILESYSTEM_COMMANDS.stat,
971
- { path }
1038
+ { path: path2 }
972
1039
  );
973
1040
  }
974
1041
  /**
@@ -1037,10 +1104,10 @@ var FilesystemAPI = class {
1037
1104
  * @param ruleId Unique identifier for this watch (e.g., sync rule ID)
1038
1105
  * @param path Absolute path to the directory to watch
1039
1106
  */
1040
- async watch(ruleId, path) {
1107
+ async watch(ruleId, path2) {
1041
1108
  await this.client.request(
1042
1109
  FILESYSTEM_COMMANDS.watch,
1043
- { ruleId, path }
1110
+ { ruleId, path: path2 }
1044
1111
  );
1045
1112
  }
1046
1113
  /**
@@ -1067,6 +1134,7 @@ var FilesystemAPI = class {
1067
1134
  };
1068
1135
 
1069
1136
  // src/api/web.ts
1137
+ init_esm_shims();
1070
1138
  var WebAPI = class {
1071
1139
  constructor(client) {
1072
1140
  this.client = client;
@@ -1180,6 +1248,7 @@ var WebAPI = class {
1180
1248
  };
1181
1249
 
1182
1250
  // src/api/permissions.ts
1251
+ init_esm_shims();
1183
1252
  var PermissionsAPI = class {
1184
1253
  constructor(client) {
1185
1254
  this.client = client;
@@ -1221,11 +1290,11 @@ var PermissionsAPI = class {
1221
1290
  * @param operation The operation type ("read" or "write")
1222
1291
  * @returns Promise<boolean> indicating if permission is granted
1223
1292
  */
1224
- async checkFilesystemAsync(path, operation) {
1293
+ async checkFilesystemAsync(path2, operation) {
1225
1294
  const response = await this.client.request(
1226
1295
  PERMISSIONS_COMMANDS.checkFilesystem,
1227
1296
  {
1228
- path,
1297
+ path: path2,
1229
1298
  operation
1230
1299
  }
1231
1300
  );
@@ -1234,6 +1303,7 @@ var PermissionsAPI = class {
1234
1303
  };
1235
1304
 
1236
1305
  // src/api/remoteStorage.ts
1306
+ init_esm_shims();
1237
1307
  init_vaultKey();
1238
1308
  var RemoteStorageAPI = class {
1239
1309
  constructor(client) {
@@ -1344,6 +1414,7 @@ var BackendManagement = class {
1344
1414
  };
1345
1415
 
1346
1416
  // src/api/localsend.ts
1417
+ init_esm_shims();
1347
1418
  var LOCALSEND_EVENTS = {
1348
1419
  /** New device discovered */
1349
1420
  deviceDiscovered: "localsend:device-discovered",
@@ -1515,6 +1586,7 @@ var LocalSendAPI = class {
1515
1586
  };
1516
1587
 
1517
1588
  // src/api/spaces.ts
1589
+ init_esm_shims();
1518
1590
  var SpacesAPI = class {
1519
1591
  constructor(client) {
1520
1592
  this.client = client;
@@ -1587,9 +1659,45 @@ var SpacesAPI = class {
1587
1659
  };
1588
1660
 
1589
1661
  // src/api/shell.ts
1662
+ init_esm_shims();
1663
+ var NOT_SUPPORTED = 8e3;
1664
+ function isUnsupported(error) {
1665
+ if (error?.code === NOT_SUPPORTED) return true;
1666
+ return typeof error === "string" && /\bcommand (\S+ )?not found\b/i.test(error);
1667
+ }
1590
1668
  var ShellAPI = class {
1591
1669
  constructor(sdk) {
1592
1670
  this.sdk = sdk;
1671
+ /** `shell:output` events per session handed on but not yet acknowledged. */
1672
+ this.unacknowledged = /* @__PURE__ */ new Map();
1673
+ this.flushScheduled = false;
1674
+ /** The host does not know `extension_shell_ack` (it reads output without backpressure). */
1675
+ this.ackUnsupported = false;
1676
+ this.sdk.on(SHELL_EVENTS.OUTPUT, (event) => this.acknowledge(event));
1677
+ }
1678
+ /**
1679
+ * Backpressure: the host keeps reading a shell's output only while this frame has few
1680
+ * events open, so a shell that writes fast waits instead of flooding the page. The SDK
1681
+ * acknowledges every event once the listeners have had it, in one request per session and
1682
+ * task.
1683
+ */
1684
+ acknowledge(event) {
1685
+ const sessionId = event.data?.sessionId;
1686
+ if (this.ackUnsupported || typeof sessionId !== "string") return;
1687
+ this.unacknowledged.set(sessionId, (this.unacknowledged.get(sessionId) ?? 0) + 1);
1688
+ if (this.flushScheduled) return;
1689
+ this.flushScheduled = true;
1690
+ queueMicrotask(() => this.flushAcknowledgements());
1691
+ }
1692
+ flushAcknowledgements() {
1693
+ this.flushScheduled = false;
1694
+ const counts = [...this.unacknowledged];
1695
+ this.unacknowledged.clear();
1696
+ for (const [sessionId, count] of counts) {
1697
+ this.sdk.request(SHELL_COMMANDS.ack, { sessionId, count }).catch((error) => {
1698
+ if (isUnsupported(error)) this.ackUnsupported = true;
1699
+ });
1700
+ }
1593
1701
  }
1594
1702
  /**
1595
1703
  * List available shell environments on the host system.
@@ -1658,6 +1766,7 @@ var ShellAPI = class {
1658
1766
  };
1659
1767
 
1660
1768
  // src/api/passwords.ts
1769
+ init_esm_shims();
1661
1770
  var PasswordsAPI = class {
1662
1771
  constructor(client) {
1663
1772
  this.client = client;
@@ -1703,6 +1812,7 @@ var PasswordsAPI = class {
1703
1812
  };
1704
1813
 
1705
1814
  // src/api/mail.ts
1815
+ init_esm_shims();
1706
1816
  var MailAPI = class {
1707
1817
  constructor(client) {
1708
1818
  this.client = client;
@@ -1805,22 +1915,29 @@ var MailAPI = class {
1805
1915
  });
1806
1916
  }
1807
1917
  /**
1808
- * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
1809
- * The host resolves credentials itself from `accountId` — no `ImapConfig`
1810
- * is passed in. Requires `mail` permission with action `poll` on the
1811
- * account's IMAP host (prompted on first call, same as `fetch`/`send`).
1918
+ * Start (or replace) a background watch for `accountId`/`mailboxName`.
1919
+ * Requires `mail` permission with action `poll` on the account's IMAP
1920
+ * host (`imap.host` when passed; prompted on first call, same as
1921
+ * `fetch`/`send`).
1922
+ *
1923
+ * Pass the account's `imap` config, as for every other mail call: the host
1924
+ * keeps the credentials in memory for as long as the watch runs and never
1925
+ * stores them. Hosts that wait with IMAP IDLE are told about new mail by the
1926
+ * server; `intervalSeconds` (clamped host-side to [30, 3600]) is the polling
1927
+ * interval for servers without IDLE. Listen for results via `onNewMessages`.
1812
1928
  *
1813
- * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
1814
- * results via `onNewMessages`.
1929
+ * `imap` is optional for hosts that resolve the credentials themselves from
1930
+ * `accountId`; holzi requires it.
1815
1931
  */
1816
- async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
1932
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds, imap) {
1817
1933
  return this.client.request(MAIL_COMMANDS.startWatch, {
1818
1934
  accountId,
1819
1935
  mailboxName,
1820
- intervalSeconds
1936
+ intervalSeconds,
1937
+ imap
1821
1938
  });
1822
1939
  }
1823
- /** Stop a background poll watch previously started with `startWatchingAsync`. */
1940
+ /** Stop a background watch previously started with `startWatchingAsync`. */
1824
1941
  async stopWatchingAsync(accountId, mailboxName) {
1825
1942
  return this.client.request(MAIL_COMMANDS.stopWatch, {
1826
1943
  accountId,
@@ -1842,6 +1959,7 @@ var MailAPI = class {
1842
1959
  };
1843
1960
 
1844
1961
  // src/api/notifications.ts
1962
+ init_esm_shims();
1845
1963
  var NotificationsAPI = class {
1846
1964
  constructor(client) {
1847
1965
  this.client = client;
@@ -1873,7 +1991,36 @@ var NotificationsAPI = class {
1873
1991
  }
1874
1992
  };
1875
1993
 
1994
+ // src/api/tab.ts
1995
+ init_esm_shims();
1996
+ var TabAPI = class {
1997
+ constructor(client) {
1998
+ this.client = client;
1999
+ }
2000
+ /**
2001
+ * Mark the tab as wanting the user's attention (`true`), e.g. for unread
2002
+ * content, or clear the mark (`false`).
2003
+ */
2004
+ async requestAttention(active) {
2005
+ await this.client.request(EXTENSION_COMMANDS.tabAttention, { active });
2006
+ }
2007
+ };
2008
+
2009
+ // src/api/dialog.ts
2010
+ init_esm_shims();
2011
+ var DialogAPI = class {
2012
+ constructor(client) {
2013
+ this.client = client;
2014
+ }
2015
+ /** Asks the user; resolves `true` for confirm, `false` for cancel or when the dialog is closed. */
2016
+ async confirm(options) {
2017
+ const answer = await this.client.request(EXTENSION_COMMANDS.dialogConfirm, { ...options }, { timeout: null });
2018
+ return answer === true;
2019
+ }
2020
+ };
2021
+
1876
2022
  // src/client/tableName.ts
2023
+ init_esm_shims();
1877
2024
  function validatePublicKey(publicKey) {
1878
2025
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
1879
2026
  throw new HaexVaultSdkError(
@@ -1959,6 +2106,7 @@ function parseTableName(fullTableName) {
1959
2106
  }
1960
2107
 
1961
2108
  // src/client/init.ts
2109
+ init_esm_shims();
1962
2110
  var PORT_HANDSHAKE_TIMEOUT_MS = 1e4;
1963
2111
  function getCurrentWebviewLabel() {
1964
2112
  const internals = window.__TAURI_INTERNALS__;
@@ -2050,8 +2198,8 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2050
2198
  data: { tables: payload.tables }
2051
2199
  }));
2052
2200
  await forwardEvent(listen, log, onEvent, listenOptions, HAEXTENSION_EVENTS.FILE_CHANGED, (payload) => {
2053
- const { ruleId, changeType, path } = payload;
2054
- return { ruleId, changeType, path };
2201
+ const { ruleId, changeType, path: path2 } = payload;
2202
+ return { ruleId, changeType, path: path2 };
2055
2203
  });
2056
2204
  await forwardEvent(listen, log, onEvent, listenOptions, SHELL_EVENTS.OUTPUT, (payload) => {
2057
2205
  const { sessionId, data } = payload;
@@ -2107,6 +2255,10 @@ function waitForHostPortAsync(log) {
2107
2255
  const handler = (event) => {
2108
2256
  const type = event.data?.type;
2109
2257
  if (type !== HAEXSPACE_MESSAGE_TYPES.PORT_INIT) return;
2258
+ if (event.source !== window.parent) {
2259
+ log("PORT_INIT from a window other than the parent \u2014 ignoring");
2260
+ return;
2261
+ }
2110
2262
  const port = event.ports[0];
2111
2263
  if (!port) {
2112
2264
  log("PORT_INIT received but event.ports is empty \u2014 ignoring");
@@ -2140,10 +2292,11 @@ postMessage error: ${e}`);
2140
2292
  }
2141
2293
 
2142
2294
  // src/client/transport.ts
2295
+ init_esm_shims();
2143
2296
  function generateRequestId(counter) {
2144
2297
  return `req_${counter}`;
2145
2298
  }
2146
- function sendPostMessage(method, params, requestId, config, extensionInfo2, pendingRequests, port) {
2299
+ function sendPostMessage(method, params, requestId, config, extensionInfo2, pendingRequests, port, timeoutMs = config.timeout) {
2147
2300
  if (!port) {
2148
2301
  return Promise.reject(
2149
2302
  new HaexVaultSdkError(
@@ -2158,14 +2311,14 @@ function sendPostMessage(method, params, requestId, config, extensionInfo2, pend
2158
2311
  timestamp: Date.now()
2159
2312
  };
2160
2313
  return new Promise((resolve, reject) => {
2161
- const timeout = setTimeout(() => {
2314
+ const timeout = timeoutMs === null ? void 0 : setTimeout(() => {
2162
2315
  pendingRequests.delete(requestId);
2163
2316
  reject(
2164
2317
  new HaexVaultSdkError("TIMEOUT" /* TIMEOUT */, "errors.timeout", {
2165
- timeout: config.timeout
2318
+ timeout: timeoutMs
2166
2319
  })
2167
2320
  );
2168
- }, config.timeout);
2321
+ }, timeoutMs);
2169
2322
  pendingRequests.set(requestId, { resolve, reject, timeout });
2170
2323
  if (config.debug) {
2171
2324
  console.log("[SDK Debug] ========== Sending Request ==========");
@@ -2191,6 +2344,7 @@ async function sendInvoke(method, params, config, _log) {
2191
2344
  }
2192
2345
 
2193
2346
  // src/client/events.ts
2347
+ init_esm_shims();
2194
2348
  function createMessageHandler(config, pendingRequests, extensionInfo2, onEvent) {
2195
2349
  return (event) => {
2196
2350
  if (config.debug) {
@@ -2290,6 +2444,9 @@ function removeEventListener(eventType, callback, eventListeners) {
2290
2444
  function notifySubscribers(subscribers) {
2291
2445
  subscribers.forEach((callback) => callback());
2292
2446
  }
2447
+
2448
+ // src/client/database.ts
2449
+ init_esm_shims();
2293
2450
  function createDrizzleInstance(schema, extensionInfo2, request, log) {
2294
2451
  if (!extensionInfo2) {
2295
2452
  throw new HaexVaultSdkError(
@@ -2358,6 +2515,7 @@ async function executeRaw(sql, params, request) {
2358
2515
  }
2359
2516
 
2360
2517
  // src/client/external.ts
2518
+ init_esm_shims();
2361
2519
  function registerExternalHandler(action, handler, handlers, log) {
2362
2520
  handlers.set(action, handler);
2363
2521
  log(`[ExternalRequest] Registered handler for action: ${action}`);
@@ -2399,12 +2557,14 @@ async function respondToExternalRequest(response, request) {
2399
2557
  }
2400
2558
 
2401
2559
  // src/commands/ai.ts
2560
+ init_esm_shims();
2402
2561
  var AI_COMMANDS = {
2403
2562
  /** Respond to an AI action request */
2404
2563
  actionRespond: "ai_action_respond"
2405
2564
  };
2406
2565
 
2407
2566
  // src/client/permissionRetry.ts
2567
+ init_esm_shims();
2408
2568
  var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
2409
2569
  var MAX_PERMISSION_RETRIES = 3;
2410
2570
  function permissionKey(resourceType, action, target) {
@@ -2518,6 +2678,8 @@ var HaexVaultSdk = class {
2518
2678
  this.passwords = new PasswordsAPI(this);
2519
2679
  this.mail = new MailAPI(this);
2520
2680
  this.notifications = new NotificationsAPI(this);
2681
+ this.tab = new TabAPI(this);
2682
+ this.dialog = new DialogAPI(this);
2521
2683
  installConsoleForwarding(this.config.debug);
2522
2684
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2523
2685
  const data = event.data;
@@ -2673,7 +2835,7 @@ var HaexVaultSdk = class {
2673
2835
  // ==========================================================================
2674
2836
  // Communication
2675
2837
  // ==========================================================================
2676
- async request(method, params) {
2838
+ async request(method, params, options) {
2677
2839
  const resolvedParams = params ?? {};
2678
2840
  const send = () => {
2679
2841
  if (this.isNativeWindow && hasTauri()) {
@@ -2692,7 +2854,8 @@ var HaexVaultSdk = class {
2692
2854
  this.config,
2693
2855
  this._extensionInfo,
2694
2856
  this.pendingRequests,
2695
- this.hostPort
2857
+ this.hostPort,
2858
+ options?.timeout
2696
2859
  );
2697
2860
  };
2698
2861
  return withPermissionRetry(send, this.permissionWaiters, this.log.bind(this));
@@ -2869,26 +3032,37 @@ var HaexVaultSdk = class {
2869
3032
  }
2870
3033
  };
2871
3034
 
3035
+ // src/types/external.ts
3036
+ init_esm_shims();
3037
+
3038
+ // src/types/spaces.ts
3039
+ init_esm_shims();
3040
+
2872
3041
  // src/index.ts
2873
3042
  init_vaultKey();
2874
3043
  init_userKeypair();
2875
3044
 
2876
3045
  // src/crypto/didKey.ts
3046
+ init_esm_shims();
2877
3047
  init_userKeypair();
2878
3048
  init_vaultKey();
2879
3049
 
2880
3050
  // src/crypto/spaceKey.ts
3051
+ init_esm_shims();
2881
3052
  init_userKeypair();
2882
3053
  init_vaultKey();
2883
3054
 
2884
3055
  // src/crypto/claims.ts
3056
+ init_esm_shims();
2885
3057
  init_userKeypair();
2886
3058
 
2887
3059
  // src/crypto/recordSigning.ts
3060
+ init_esm_shims();
2888
3061
  init_userKeypair();
2889
3062
  init_vaultKey();
2890
3063
 
2891
3064
  // src/crypto/passkey.ts
3065
+ init_esm_shims();
2892
3066
  init_vaultKey();
2893
3067
 
2894
3068
  // src/index.ts