@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/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import 'path';
2
+ import 'url';
1
3
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
2
4
 
3
5
  var __defProp = Object.defineProperty;
@@ -9,6 +11,10 @@ var __export = (target, all) => {
9
11
  for (var name in all)
10
12
  __defProp(target, name, { get: all[name], enumerable: true });
11
13
  };
14
+ var init_esm_shims = __esm({
15
+ "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"() {
16
+ }
17
+ });
12
18
 
13
19
  // src/crypto/vaultKey.ts
14
20
  async function deriveKeyFromPassword(password, salt) {
@@ -227,6 +233,7 @@ function base64ToArrayBuffer(base64) {
227
233
  var PBKDF2_ITERATIONS, KEY_LENGTH, ALGORITHM;
228
234
  var init_vaultKey = __esm({
229
235
  "src/crypto/vaultKey.ts"() {
236
+ init_esm_shims();
230
237
  PBKDF2_ITERATIONS = 6e5;
231
238
  KEY_LENGTH = 256;
232
239
  ALGORITHM = "AES-GCM";
@@ -310,13 +317,21 @@ async function decryptPrivateKeyAsync(encryptedPrivateKey, nonce, salt, password
310
317
  var SIGNING_ALGO, KEY_AGREEMENT_ALGO;
311
318
  var init_userKeypair = __esm({
312
319
  "src/crypto/userKeypair.ts"() {
320
+ init_esm_shims();
313
321
  init_vaultKey();
314
322
  SIGNING_ALGO = { name: "Ed25519" };
315
323
  KEY_AGREEMENT_ALGO = { name: "X25519" };
316
324
  }
317
325
  });
318
326
 
327
+ // src/index.ts
328
+ init_esm_shims();
329
+
330
+ // src/polyfills/index.ts
331
+ init_esm_shims();
332
+
319
333
  // src/polyfills/localStorage.ts
334
+ init_esm_shims();
320
335
  function installLocalStoragePolyfill() {
321
336
  if (typeof window === "undefined") {
322
337
  return;
@@ -411,6 +426,7 @@ function installSessionStoragePolyfill() {
411
426
  }
412
427
 
413
428
  // src/polyfills/cookies.ts
429
+ init_esm_shims();
414
430
  function installCookiePolyfill() {
415
431
  if (typeof window === "undefined" || typeof document === "undefined") {
416
432
  return;
@@ -471,6 +487,7 @@ function installCookiePolyfill() {
471
487
  }
472
488
 
473
489
  // src/polyfills/history.ts
490
+ init_esm_shims();
474
491
  function installHistoryPolyfill() {
475
492
  if (typeof window === "undefined" || typeof history === "undefined") {
476
493
  return;
@@ -534,7 +551,11 @@ function installHistoryPolyfill() {
534
551
  }
535
552
  }
536
553
 
554
+ // src/polyfills/debug.ts
555
+ init_esm_shims();
556
+
537
557
  // src/messages.ts
558
+ init_esm_shims();
538
559
  var HAEXSPACE_MESSAGE_TYPES = {
539
560
  /** Debug message for development/troubleshooting */
540
561
  DEBUG: "haexspace:debug",
@@ -579,6 +600,7 @@ function installDebugDiagnostics() {
579
600
  }
580
601
 
581
602
  // src/polyfills/baseTag.ts
603
+ init_esm_shims();
582
604
  function installBaseTag() {
583
605
  if (typeof window === "undefined" || typeof document === "undefined") {
584
606
  return;
@@ -620,6 +642,7 @@ function installBaseTag() {
620
642
  }
621
643
 
622
644
  // src/polyfills/consoleForwarding.ts
645
+ init_esm_shims();
623
646
  var originalConsole = {
624
647
  log: console.log,
625
648
  info: console.info,
@@ -700,7 +723,14 @@ if (typeof window !== "undefined") {
700
723
  installPolyfills();
701
724
  }
702
725
 
726
+ // src/client.ts
727
+ init_esm_shims();
728
+
729
+ // src/types.ts
730
+ init_esm_shims();
731
+
703
732
  // src/events.ts
733
+ init_esm_shims();
704
734
  var HAEXTENSION_EVENTS = {
705
735
  /** Context (theme, locale, platform) has changed */
706
736
  CONTEXT_CHANGED: "haextension:context:changed",
@@ -815,7 +845,17 @@ var HaexVaultSdkError = class extends Error {
815
845
  }
816
846
  };
817
847
 
848
+ // src/api/storage.ts
849
+ init_esm_shims();
850
+
851
+ // src/commands.ts
852
+ init_esm_shims();
853
+
854
+ // src/commands/index.ts
855
+ init_esm_shims();
856
+
818
857
  // src/commands/database.ts
858
+ init_esm_shims();
819
859
  var DATABASE_COMMANDS = {
820
860
  /** Execute a SELECT query */
821
861
  query: "extension_database_query",
@@ -828,6 +868,7 @@ var DATABASE_COMMANDS = {
828
868
  };
829
869
 
830
870
  // src/commands/permissions.ts
871
+ init_esm_shims();
831
872
  var PERMISSIONS_COMMANDS = {
832
873
  /** Check web/fetch permission */
833
874
  checkWeb: "extension_permissions_check_web",
@@ -838,6 +879,7 @@ var PERMISSIONS_COMMANDS = {
838
879
  };
839
880
 
840
881
  // src/commands/web.ts
882
+ init_esm_shims();
841
883
  var WEB_COMMANDS = {
842
884
  /** Open URL in external browser */
843
885
  open: "extension_web_open",
@@ -846,6 +888,7 @@ var WEB_COMMANDS = {
846
888
  };
847
889
 
848
890
  // src/commands/webStorage.ts
891
+ init_esm_shims();
849
892
  var WEB_STORAGE_COMMANDS = {
850
893
  /** Get item from storage */
851
894
  getItem: "extension_web_storage_get_item",
@@ -860,6 +903,7 @@ var WEB_STORAGE_COMMANDS = {
860
903
  };
861
904
 
862
905
  // src/commands/filesystem.ts
906
+ init_esm_shims();
863
907
  var FILESYSTEM_COMMANDS = {
864
908
  // Dialog commands
865
909
  /** Show save file dialog */
@@ -903,6 +947,7 @@ var FILESYSTEM_COMMANDS = {
903
947
  };
904
948
 
905
949
  // src/commands/externalBridge.ts
950
+ init_esm_shims();
906
951
  var EXTERNAL_BRIDGE_COMMANDS = {
907
952
  // Response handling (called by extensions)
908
953
  /** Respond to an external request */
@@ -942,6 +987,7 @@ var EXTERNAL_BRIDGE_COMMANDS = {
942
987
  };
943
988
 
944
989
  // src/commands/extension.ts
990
+ init_esm_shims();
945
991
  var EXTENSION_COMMANDS = {
946
992
  /** Get extension info (manifest, id, etc.) */
947
993
  getInfo: "extension_get_info",
@@ -956,10 +1002,15 @@ var EXTENSION_COMMANDS = {
956
1002
  /** Filter sync tables by extension permissions (returns filtered map) */
957
1003
  filterSyncTables: "extension_filter_sync_tables",
958
1004
  /** Emit sync tables to webviews (host-only, desktop only) */
959
- emitSyncTables: "extension_emit_sync_tables"
1005
+ emitSyncTables: "extension_emit_sync_tables",
1006
+ /** Ask the host to mark (or unmark) this extension's own tab as wanting attention */
1007
+ tabAttention: "extension_tab_attention",
1008
+ /** Ask the user to confirm, in a dialog the host draws over this extension's tab */
1009
+ dialogConfirm: "extension_dialog_confirm"
960
1010
  };
961
1011
 
962
1012
  // src/commands/remoteStorage.ts
1013
+ init_esm_shims();
963
1014
  var REMOTE_STORAGE_COMMANDS = {
964
1015
  // Backend Management
965
1016
  /** List all storage backends */
@@ -984,6 +1035,7 @@ var REMOTE_STORAGE_COMMANDS = {
984
1035
  };
985
1036
 
986
1037
  // src/commands/localsend.ts
1038
+ init_esm_shims();
987
1039
  var LOCALSEND_COMMANDS = {
988
1040
  // Initialization
989
1041
  /** Initialize LocalSend (generate identity, etc.) */
@@ -1030,6 +1082,7 @@ var LOCALSEND_COMMANDS = {
1030
1082
  };
1031
1083
 
1032
1084
  // src/commands/spaces.ts
1085
+ init_esm_shims();
1033
1086
  var SPACE_COMMANDS = {
1034
1087
  /** Bulk assign rows to spaces */
1035
1088
  assign: "extension_space_assign",
@@ -1048,6 +1101,7 @@ var SPACE_COMMANDS = {
1048
1101
  };
1049
1102
 
1050
1103
  // src/commands/shell.ts
1104
+ init_esm_shims();
1051
1105
  var SHELL_COMMANDS = {
1052
1106
  /** List available shell environments (no permission required) */
1053
1107
  listAvailable: "extension_shell_list_available",
@@ -1055,6 +1109,8 @@ var SHELL_COMMANDS = {
1055
1109
  create: "extension_shell_create",
1056
1110
  /** Write data to a shell session's stdin */
1057
1111
  write: "extension_shell_write",
1112
+ /** Acknowledge `shell:output` events handed on (backpressure; sent by the SDK itself) */
1113
+ ack: "extension_shell_ack",
1058
1114
  /** Resize a shell session's terminal */
1059
1115
  resize: "extension_shell_resize",
1060
1116
  /** Close a shell session */
@@ -1062,6 +1118,7 @@ var SHELL_COMMANDS = {
1062
1118
  };
1063
1119
 
1064
1120
  // src/commands/passwords.ts
1121
+ init_esm_shims();
1065
1122
  var PASSWORD_COMMANDS = {
1066
1123
  /** List items (no secrets) within the extension's tag scope */
1067
1124
  list: "extension_password_list",
@@ -1076,6 +1133,7 @@ var PASSWORD_COMMANDS = {
1076
1133
  };
1077
1134
 
1078
1135
  // src/commands/mail.ts
1136
+ init_esm_shims();
1079
1137
  var MAIL_COMMANDS = {
1080
1138
  /** LIST mailboxes + optional STATUS counts */
1081
1139
  listMailboxes: "extension_mail_list_mailboxes",
@@ -1095,13 +1153,14 @@ var MAIL_COMMANDS = {
1095
1153
  sendMessage: "extension_mail_send_message",
1096
1154
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
1097
1155
  buildRfc822: "extension_mail_build_rfc822",
1098
- /** Start (or replace) a background poll watch for an account/mailbox */
1156
+ /** Start (or replace) a background new-mail watch for an account/mailbox */
1099
1157
  startWatch: "extension_mail_start_watch",
1100
- /** Stop a background poll watch */
1158
+ /** Stop a background new-mail watch */
1101
1159
  stopWatch: "extension_mail_stop_watch"
1102
1160
  };
1103
1161
 
1104
1162
  // src/commands/notifications.ts
1163
+ init_esm_shims();
1105
1164
  var NOTIFICATION_COMMANDS = {
1106
1165
  /** Show an OS notification. Returns the assigned notification id. */
1107
1166
  show: "extension_notifications_show",
@@ -1150,6 +1209,7 @@ var StorageAPI = class {
1150
1209
  };
1151
1210
 
1152
1211
  // src/api/database.ts
1212
+ init_esm_shims();
1153
1213
  function quoteIdent(identifier) {
1154
1214
  if (identifier.startsWith('"') && identifier.endsWith('"')) {
1155
1215
  return identifier;
@@ -1249,6 +1309,7 @@ var DatabaseAPI = class {
1249
1309
  };
1250
1310
 
1251
1311
  // src/api/filesystem.ts
1312
+ init_esm_shims();
1252
1313
  init_vaultKey();
1253
1314
  var KnownPath = /* @__PURE__ */ ((KnownPath2) => {
1254
1315
  KnownPath2["Home"] = "home";
@@ -1324,10 +1385,10 @@ var FilesystemAPI = class {
1324
1385
  * @param path Absolute path to the file
1325
1386
  * @returns File contents as Uint8Array
1326
1387
  */
1327
- async readFile(path) {
1388
+ async readFile(path2) {
1328
1389
  const base64 = await this.client.request(
1329
1390
  FILESYSTEM_COMMANDS.readFile,
1330
- { path }
1391
+ { path: path2 }
1331
1392
  );
1332
1393
  return base64ToArrayBuffer(base64);
1333
1394
  }
@@ -1336,11 +1397,11 @@ var FilesystemAPI = class {
1336
1397
  * @param path Absolute path to the file
1337
1398
  * @param data File contents as Uint8Array
1338
1399
  */
1339
- async writeFile(path, data) {
1400
+ async writeFile(path2, data) {
1340
1401
  const base64 = arrayBufferToBase64(data);
1341
1402
  await this.client.request(
1342
1403
  FILESYSTEM_COMMANDS.writeFile,
1343
- { path, data: base64 }
1404
+ { path: path2, data: base64 }
1344
1405
  );
1345
1406
  }
1346
1407
  /**
@@ -1348,20 +1409,20 @@ var FilesystemAPI = class {
1348
1409
  * @param path Absolute path to the directory
1349
1410
  * @returns Array of directory entries
1350
1411
  */
1351
- async readDir(path) {
1412
+ async readDir(path2) {
1352
1413
  return this.client.request(
1353
1414
  FILESYSTEM_COMMANDS.readDir,
1354
- { path }
1415
+ { path: path2 }
1355
1416
  );
1356
1417
  }
1357
1418
  /**
1358
1419
  * Create a directory (and parent directories if needed)
1359
1420
  * @param path Absolute path to create
1360
1421
  */
1361
- async mkdir(path) {
1422
+ async mkdir(path2) {
1362
1423
  await this.client.request(
1363
1424
  FILESYSTEM_COMMANDS.mkdir,
1364
- { path }
1425
+ { path: path2 }
1365
1426
  );
1366
1427
  }
1367
1428
  /**
@@ -1369,10 +1430,10 @@ var FilesystemAPI = class {
1369
1430
  * @param path Absolute path to remove
1370
1431
  * @param recursive If true, remove directories recursively
1371
1432
  */
1372
- async remove(path, recursive = false) {
1433
+ async remove(path2, recursive = false) {
1373
1434
  await this.client.request(
1374
1435
  FILESYSTEM_COMMANDS.remove,
1375
- { path, recursive }
1436
+ { path: path2, recursive }
1376
1437
  );
1377
1438
  }
1378
1439
  /**
@@ -1380,10 +1441,10 @@ var FilesystemAPI = class {
1380
1441
  * @param path Absolute path to check
1381
1442
  * @returns True if the path exists
1382
1443
  */
1383
- async exists(path) {
1444
+ async exists(path2) {
1384
1445
  return this.client.request(
1385
1446
  FILESYSTEM_COMMANDS.exists,
1386
- { path }
1447
+ { path: path2 }
1387
1448
  );
1388
1449
  }
1389
1450
  /**
@@ -1391,10 +1452,10 @@ var FilesystemAPI = class {
1391
1452
  * @param path Absolute path
1392
1453
  * @returns File metadata
1393
1454
  */
1394
- async stat(path) {
1455
+ async stat(path2) {
1395
1456
  return this.client.request(
1396
1457
  FILESYSTEM_COMMANDS.stat,
1397
- { path }
1458
+ { path: path2 }
1398
1459
  );
1399
1460
  }
1400
1461
  /**
@@ -1463,10 +1524,10 @@ var FilesystemAPI = class {
1463
1524
  * @param ruleId Unique identifier for this watch (e.g., sync rule ID)
1464
1525
  * @param path Absolute path to the directory to watch
1465
1526
  */
1466
- async watch(ruleId, path) {
1527
+ async watch(ruleId, path2) {
1467
1528
  await this.client.request(
1468
1529
  FILESYSTEM_COMMANDS.watch,
1469
- { ruleId, path }
1530
+ { ruleId, path: path2 }
1470
1531
  );
1471
1532
  }
1472
1533
  /**
@@ -1493,6 +1554,7 @@ var FilesystemAPI = class {
1493
1554
  };
1494
1555
 
1495
1556
  // src/api/web.ts
1557
+ init_esm_shims();
1496
1558
  var WebAPI = class {
1497
1559
  constructor(client) {
1498
1560
  this.client = client;
@@ -1606,6 +1668,7 @@ var WebAPI = class {
1606
1668
  };
1607
1669
 
1608
1670
  // src/api/permissions.ts
1671
+ init_esm_shims();
1609
1672
  var PermissionsAPI = class {
1610
1673
  constructor(client) {
1611
1674
  this.client = client;
@@ -1647,11 +1710,11 @@ var PermissionsAPI = class {
1647
1710
  * @param operation The operation type ("read" or "write")
1648
1711
  * @returns Promise<boolean> indicating if permission is granted
1649
1712
  */
1650
- async checkFilesystemAsync(path, operation) {
1713
+ async checkFilesystemAsync(path2, operation) {
1651
1714
  const response = await this.client.request(
1652
1715
  PERMISSIONS_COMMANDS.checkFilesystem,
1653
1716
  {
1654
- path,
1717
+ path: path2,
1655
1718
  operation
1656
1719
  }
1657
1720
  );
@@ -1660,6 +1723,7 @@ var PermissionsAPI = class {
1660
1723
  };
1661
1724
 
1662
1725
  // src/api/remoteStorage.ts
1726
+ init_esm_shims();
1663
1727
  init_vaultKey();
1664
1728
  var RemoteStorageAPI = class {
1665
1729
  constructor(client) {
@@ -1770,6 +1834,7 @@ var BackendManagement = class {
1770
1834
  };
1771
1835
 
1772
1836
  // src/api/localsend.ts
1837
+ init_esm_shims();
1773
1838
  var LOCALSEND_EVENTS = {
1774
1839
  /** New device discovered */
1775
1840
  deviceDiscovered: "localsend:device-discovered",
@@ -1941,6 +2006,7 @@ var LocalSendAPI = class {
1941
2006
  };
1942
2007
 
1943
2008
  // src/api/spaces.ts
2009
+ init_esm_shims();
1944
2010
  var SpacesAPI = class {
1945
2011
  constructor(client) {
1946
2012
  this.client = client;
@@ -2013,9 +2079,45 @@ var SpacesAPI = class {
2013
2079
  };
2014
2080
 
2015
2081
  // src/api/shell.ts
2082
+ init_esm_shims();
2083
+ var NOT_SUPPORTED = 8e3;
2084
+ function isUnsupported(error) {
2085
+ if (error?.code === NOT_SUPPORTED) return true;
2086
+ return typeof error === "string" && /\bcommand (\S+ )?not found\b/i.test(error);
2087
+ }
2016
2088
  var ShellAPI = class {
2017
2089
  constructor(sdk) {
2018
2090
  this.sdk = sdk;
2091
+ /** `shell:output` events per session handed on but not yet acknowledged. */
2092
+ this.unacknowledged = /* @__PURE__ */ new Map();
2093
+ this.flushScheduled = false;
2094
+ /** The host does not know `extension_shell_ack` (it reads output without backpressure). */
2095
+ this.ackUnsupported = false;
2096
+ this.sdk.on(SHELL_EVENTS.OUTPUT, (event) => this.acknowledge(event));
2097
+ }
2098
+ /**
2099
+ * Backpressure: the host keeps reading a shell's output only while this frame has few
2100
+ * events open, so a shell that writes fast waits instead of flooding the page. The SDK
2101
+ * acknowledges every event once the listeners have had it, in one request per session and
2102
+ * task.
2103
+ */
2104
+ acknowledge(event) {
2105
+ const sessionId = event.data?.sessionId;
2106
+ if (this.ackUnsupported || typeof sessionId !== "string") return;
2107
+ this.unacknowledged.set(sessionId, (this.unacknowledged.get(sessionId) ?? 0) + 1);
2108
+ if (this.flushScheduled) return;
2109
+ this.flushScheduled = true;
2110
+ queueMicrotask(() => this.flushAcknowledgements());
2111
+ }
2112
+ flushAcknowledgements() {
2113
+ this.flushScheduled = false;
2114
+ const counts = [...this.unacknowledged];
2115
+ this.unacknowledged.clear();
2116
+ for (const [sessionId, count] of counts) {
2117
+ this.sdk.request(SHELL_COMMANDS.ack, { sessionId, count }).catch((error) => {
2118
+ if (isUnsupported(error)) this.ackUnsupported = true;
2119
+ });
2120
+ }
2019
2121
  }
2020
2122
  /**
2021
2123
  * List available shell environments on the host system.
@@ -2084,6 +2186,7 @@ var ShellAPI = class {
2084
2186
  };
2085
2187
 
2086
2188
  // src/api/passwords.ts
2189
+ init_esm_shims();
2087
2190
  var PasswordsAPI = class {
2088
2191
  constructor(client) {
2089
2192
  this.client = client;
@@ -2129,6 +2232,7 @@ var PasswordsAPI = class {
2129
2232
  };
2130
2233
 
2131
2234
  // src/api/mail.ts
2235
+ init_esm_shims();
2132
2236
  var MailAPI = class {
2133
2237
  constructor(client) {
2134
2238
  this.client = client;
@@ -2231,22 +2335,29 @@ var MailAPI = class {
2231
2335
  });
2232
2336
  }
2233
2337
  /**
2234
- * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
2235
- * The host resolves credentials itself from `accountId` — no `ImapConfig`
2236
- * is passed in. Requires `mail` permission with action `poll` on the
2237
- * account's IMAP host (prompted on first call, same as `fetch`/`send`).
2338
+ * Start (or replace) a background watch for `accountId`/`mailboxName`.
2339
+ * Requires `mail` permission with action `poll` on the account's IMAP
2340
+ * host (`imap.host` when passed; prompted on first call, same as
2341
+ * `fetch`/`send`).
2342
+ *
2343
+ * Pass the account's `imap` config, as for every other mail call: the host
2344
+ * keeps the credentials in memory for as long as the watch runs and never
2345
+ * stores them. Hosts that wait with IMAP IDLE are told about new mail by the
2346
+ * server; `intervalSeconds` (clamped host-side to [30, 3600]) is the polling
2347
+ * interval for servers without IDLE. Listen for results via `onNewMessages`.
2238
2348
  *
2239
- * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
2240
- * results via `onNewMessages`.
2349
+ * `imap` is optional for hosts that resolve the credentials themselves from
2350
+ * `accountId`; holzi requires it.
2241
2351
  */
2242
- async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
2352
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds, imap) {
2243
2353
  return this.client.request(MAIL_COMMANDS.startWatch, {
2244
2354
  accountId,
2245
2355
  mailboxName,
2246
- intervalSeconds
2356
+ intervalSeconds,
2357
+ imap
2247
2358
  });
2248
2359
  }
2249
- /** Stop a background poll watch previously started with `startWatchingAsync`. */
2360
+ /** Stop a background watch previously started with `startWatchingAsync`. */
2250
2361
  async stopWatchingAsync(accountId, mailboxName) {
2251
2362
  return this.client.request(MAIL_COMMANDS.stopWatch, {
2252
2363
  accountId,
@@ -2268,6 +2379,7 @@ var MailAPI = class {
2268
2379
  };
2269
2380
 
2270
2381
  // src/api/notifications.ts
2382
+ init_esm_shims();
2271
2383
  var NotificationsAPI = class {
2272
2384
  constructor(client) {
2273
2385
  this.client = client;
@@ -2299,7 +2411,36 @@ var NotificationsAPI = class {
2299
2411
  }
2300
2412
  };
2301
2413
 
2414
+ // src/api/tab.ts
2415
+ init_esm_shims();
2416
+ var TabAPI = class {
2417
+ constructor(client) {
2418
+ this.client = client;
2419
+ }
2420
+ /**
2421
+ * Mark the tab as wanting the user's attention (`true`), e.g. for unread
2422
+ * content, or clear the mark (`false`).
2423
+ */
2424
+ async requestAttention(active) {
2425
+ await this.client.request(EXTENSION_COMMANDS.tabAttention, { active });
2426
+ }
2427
+ };
2428
+
2429
+ // src/api/dialog.ts
2430
+ init_esm_shims();
2431
+ var DialogAPI = class {
2432
+ constructor(client) {
2433
+ this.client = client;
2434
+ }
2435
+ /** Asks the user; resolves `true` for confirm, `false` for cancel or when the dialog is closed. */
2436
+ async confirm(options) {
2437
+ const answer = await this.client.request(EXTENSION_COMMANDS.dialogConfirm, { ...options }, { timeout: null });
2438
+ return answer === true;
2439
+ }
2440
+ };
2441
+
2302
2442
  // src/client/tableName.ts
2443
+ init_esm_shims();
2303
2444
  function validatePublicKey(publicKey) {
2304
2445
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
2305
2446
  throw new HaexVaultSdkError(
@@ -2385,6 +2526,7 @@ function parseTableName(fullTableName) {
2385
2526
  }
2386
2527
 
2387
2528
  // src/client/init.ts
2529
+ init_esm_shims();
2388
2530
  var PORT_HANDSHAKE_TIMEOUT_MS = 1e4;
2389
2531
  function getCurrentWebviewLabel() {
2390
2532
  const internals = window.__TAURI_INTERNALS__;
@@ -2476,8 +2618,8 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2476
2618
  data: { tables: payload.tables }
2477
2619
  }));
2478
2620
  await forwardEvent(listen, log, onEvent, listenOptions, HAEXTENSION_EVENTS.FILE_CHANGED, (payload) => {
2479
- const { ruleId, changeType, path } = payload;
2480
- return { ruleId, changeType, path };
2621
+ const { ruleId, changeType, path: path2 } = payload;
2622
+ return { ruleId, changeType, path: path2 };
2481
2623
  });
2482
2624
  await forwardEvent(listen, log, onEvent, listenOptions, SHELL_EVENTS.OUTPUT, (payload) => {
2483
2625
  const { sessionId, data } = payload;
@@ -2533,6 +2675,10 @@ function waitForHostPortAsync(log) {
2533
2675
  const handler = (event) => {
2534
2676
  const type = event.data?.type;
2535
2677
  if (type !== HAEXSPACE_MESSAGE_TYPES.PORT_INIT) return;
2678
+ if (event.source !== window.parent) {
2679
+ log("PORT_INIT from a window other than the parent \u2014 ignoring");
2680
+ return;
2681
+ }
2536
2682
  const port = event.ports[0];
2537
2683
  if (!port) {
2538
2684
  log("PORT_INIT received but event.ports is empty \u2014 ignoring");
@@ -2566,10 +2712,11 @@ postMessage error: ${e}`);
2566
2712
  }
2567
2713
 
2568
2714
  // src/client/transport.ts
2715
+ init_esm_shims();
2569
2716
  function generateRequestId(counter) {
2570
2717
  return `req_${counter}`;
2571
2718
  }
2572
- function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port) {
2719
+ function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port, timeoutMs = config.timeout) {
2573
2720
  if (!port) {
2574
2721
  return Promise.reject(
2575
2722
  new HaexVaultSdkError(
@@ -2584,14 +2731,14 @@ function sendPostMessage(method, params, requestId, config, extensionInfo, pendi
2584
2731
  timestamp: Date.now()
2585
2732
  };
2586
2733
  return new Promise((resolve, reject) => {
2587
- const timeout = setTimeout(() => {
2734
+ const timeout = timeoutMs === null ? void 0 : setTimeout(() => {
2588
2735
  pendingRequests.delete(requestId);
2589
2736
  reject(
2590
2737
  new HaexVaultSdkError("TIMEOUT" /* TIMEOUT */, "errors.timeout", {
2591
- timeout: config.timeout
2738
+ timeout: timeoutMs
2592
2739
  })
2593
2740
  );
2594
- }, config.timeout);
2741
+ }, timeoutMs);
2595
2742
  pendingRequests.set(requestId, { resolve, reject, timeout });
2596
2743
  if (config.debug) {
2597
2744
  console.log("[SDK Debug] ========== Sending Request ==========");
@@ -2617,6 +2764,7 @@ async function sendInvoke(method, params, config, _log) {
2617
2764
  }
2618
2765
 
2619
2766
  // src/client/events.ts
2767
+ init_esm_shims();
2620
2768
  function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
2621
2769
  return (event) => {
2622
2770
  if (config.debug) {
@@ -2716,6 +2864,9 @@ function removeEventListener(eventType, callback, eventListeners) {
2716
2864
  function notifySubscribers(subscribers) {
2717
2865
  subscribers.forEach((callback) => callback());
2718
2866
  }
2867
+
2868
+ // src/client/database.ts
2869
+ init_esm_shims();
2719
2870
  function createDrizzleInstance(schema, extensionInfo, request, log) {
2720
2871
  if (!extensionInfo) {
2721
2872
  throw new HaexVaultSdkError(
@@ -2784,6 +2935,7 @@ async function executeRaw(sql, params, request) {
2784
2935
  }
2785
2936
 
2786
2937
  // src/client/external.ts
2938
+ init_esm_shims();
2787
2939
  function registerExternalHandler(action, handler, handlers, log) {
2788
2940
  handlers.set(action, handler);
2789
2941
  log(`[ExternalRequest] Registered handler for action: ${action}`);
@@ -2825,12 +2977,14 @@ async function respondToExternalRequest(response, request) {
2825
2977
  }
2826
2978
 
2827
2979
  // src/commands/ai.ts
2980
+ init_esm_shims();
2828
2981
  var AI_COMMANDS = {
2829
2982
  /** Respond to an AI action request */
2830
2983
  actionRespond: "ai_action_respond"
2831
2984
  };
2832
2985
 
2833
2986
  // src/client/permissionRetry.ts
2987
+ init_esm_shims();
2834
2988
  var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
2835
2989
  var MAX_PERMISSION_RETRIES = 3;
2836
2990
  function permissionKey(resourceType, action, target) {
@@ -2944,6 +3098,8 @@ var HaexVaultSdk = class {
2944
3098
  this.passwords = new PasswordsAPI(this);
2945
3099
  this.mail = new MailAPI(this);
2946
3100
  this.notifications = new NotificationsAPI(this);
3101
+ this.tab = new TabAPI(this);
3102
+ this.dialog = new DialogAPI(this);
2947
3103
  installConsoleForwarding(this.config.debug);
2948
3104
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2949
3105
  const data = event.data;
@@ -3099,7 +3255,7 @@ var HaexVaultSdk = class {
3099
3255
  // ==========================================================================
3100
3256
  // Communication
3101
3257
  // ==========================================================================
3102
- async request(method, params) {
3258
+ async request(method, params, options) {
3103
3259
  const resolvedParams = params ?? {};
3104
3260
  const send = () => {
3105
3261
  if (this.isNativeWindow && hasTauri()) {
@@ -3118,7 +3274,8 @@ var HaexVaultSdk = class {
3118
3274
  this.config,
3119
3275
  this._extensionInfo,
3120
3276
  this.pendingRequests,
3121
- this.hostPort
3277
+ this.hostPort,
3278
+ options?.timeout
3122
3279
  );
3123
3280
  };
3124
3281
  return withPermissionRetry(send, this.permissionWaiters, this.log.bind(this));
@@ -3296,6 +3453,7 @@ var HaexVaultSdk = class {
3296
3453
  };
3297
3454
 
3298
3455
  // src/types/external.ts
3456
+ init_esm_shims();
3299
3457
  var ExternalConnectionState = /* @__PURE__ */ ((ExternalConnectionState2) => {
3300
3458
  ExternalConnectionState2["DISCONNECTED"] = "disconnected";
3301
3459
  ExternalConnectionState2["CONNECTING"] = "connecting";
@@ -3323,107 +3481,15 @@ function canExternalClientSendRequests(state) {
3323
3481
  return state === "paired" /* PAIRED */;
3324
3482
  }
3325
3483
 
3326
- // src/crypto/verify.ts
3327
- function sortObjectKeysRecursively(obj) {
3328
- if (typeof obj !== "object" || obj === null) {
3329
- return obj;
3330
- }
3331
- if (Array.isArray(obj)) {
3332
- return obj.map((item) => sortObjectKeysRecursively(item));
3333
- }
3334
- return Object.keys(obj).sort().reduce((result, key) => {
3335
- result[key] = sortObjectKeysRecursively(obj[key]);
3336
- return result;
3337
- }, {});
3338
- }
3339
- function hexToBytes(hex) {
3340
- const bytes = new Uint8Array(hex.length / 2);
3341
- for (let i = 0; i < hex.length; i += 2) {
3342
- bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
3343
- }
3344
- return bytes.buffer;
3345
- }
3346
- async function verifyExtensionSignature(files, manifest) {
3347
- try {
3348
- if (typeof crypto === "undefined" || !crypto.subtle) {
3349
- return { valid: false, error: "WebCrypto API not available" };
3350
- }
3351
- const { publicKey: publicKeyHex, signature: signatureHex } = manifest;
3352
- if (!publicKeyHex) {
3353
- return { valid: false, error: "Missing publicKey in manifest" };
3354
- }
3355
- if (!signatureHex) {
3356
- return { valid: false, error: "Missing signature in manifest" };
3357
- }
3358
- if (!/^[0-9a-fA-F]+$/.test(publicKeyHex)) {
3359
- return { valid: false, error: "Invalid publicKey format (must be hex)" };
3360
- }
3361
- if (!/^[0-9a-fA-F]+$/.test(signatureHex)) {
3362
- return { valid: false, error: "Invalid signature format (must be hex)" };
3363
- }
3364
- const publicKeyBuffer = hexToBytes(publicKeyHex);
3365
- let publicKey;
3366
- try {
3367
- publicKey = await crypto.subtle.importKey(
3368
- "raw",
3369
- publicKeyBuffer,
3370
- { name: "Ed25519", namedCurve: "Ed25519" },
3371
- false,
3372
- ["verify"]
3373
- );
3374
- } catch (err) {
3375
- return {
3376
- valid: false,
3377
- error: `Failed to import public key: ${err instanceof Error ? err.message : "Ed25519 may not be supported in this browser"}`
3378
- };
3379
- }
3380
- const manifestForHashing = sortObjectKeysRecursively({
3381
- ...manifest,
3382
- signature: ""
3383
- });
3384
- const manifestJson = JSON.stringify(manifestForHashing, null, 2);
3385
- const manifestBytes = new TextEncoder().encode(manifestJson);
3386
- const filesForHashing = files.map((file) => {
3387
- if (file.path === "haextension/manifest.json") {
3388
- return { path: file.path, content: manifestBytes };
3389
- }
3390
- return file;
3391
- });
3392
- filesForHashing.sort((a, b) => {
3393
- if (a.path < b.path) return -1;
3394
- if (a.path > b.path) return 1;
3395
- return 0;
3396
- });
3397
- const totalLength = filesForHashing.reduce((sum, f) => sum + f.content.length, 0);
3398
- const combined = new Uint8Array(totalLength);
3399
- let offset = 0;
3400
- for (const file of filesForHashing) {
3401
- combined.set(file.content, offset);
3402
- offset += file.content.length;
3403
- }
3404
- const hashBuffer = await crypto.subtle.digest("SHA-256", combined);
3405
- const signatureBuffer = hexToBytes(signatureHex);
3406
- const isValid = await crypto.subtle.verify(
3407
- "Ed25519",
3408
- publicKey,
3409
- signatureBuffer,
3410
- hashBuffer
3411
- );
3412
- return { valid: isValid };
3413
- } catch (err) {
3414
- console.error("Signature verification error:", err);
3415
- return {
3416
- valid: false,
3417
- error: err instanceof Error ? err.message : "Unknown verification error"
3418
- };
3419
- }
3420
- }
3484
+ // src/types/spaces.ts
3485
+ init_esm_shims();
3421
3486
 
3422
3487
  // src/index.ts
3423
3488
  init_vaultKey();
3424
3489
  init_userKeypair();
3425
3490
 
3426
3491
  // src/crypto/didKey.ts
3492
+ init_esm_shims();
3427
3493
  init_userKeypair();
3428
3494
  init_vaultKey();
3429
3495
  var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -3522,6 +3588,7 @@ async function generateIdentityAsync() {
3522
3588
  }
3523
3589
 
3524
3590
  // src/crypto/spaceKey.ts
3591
+ init_esm_shims();
3525
3592
  init_userKeypair();
3526
3593
  init_vaultKey();
3527
3594
  function generateSpaceKey() {
@@ -3612,6 +3679,7 @@ async function decryptSpaceNameAsync(spaceKey, encryptedName, nameNonce) {
3612
3679
  }
3613
3680
 
3614
3681
  // src/crypto/claims.ts
3682
+ init_esm_shims();
3615
3683
  init_userKeypair();
3616
3684
  async function signClaimPresentationAsync(did, publicKeyBase64, claims, privateKeyBase64) {
3617
3685
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
@@ -3648,6 +3716,7 @@ async function verifyClaimPresentationAsync(presentation) {
3648
3716
  }
3649
3717
 
3650
3718
  // src/crypto/recordSigning.ts
3719
+ init_esm_shims();
3651
3720
  init_userKeypair();
3652
3721
  init_vaultKey();
3653
3722
  function canonicalize(record) {
@@ -3712,6 +3781,7 @@ async function verifySpaceChallengeAsync(spaceId, timestamp, signatureBase64, pu
3712
3781
  }
3713
3782
 
3714
3783
  // src/crypto/passkey.ts
3784
+ init_esm_shims();
3715
3785
  init_vaultKey();
3716
3786
  function toArrayBuffer(data) {
3717
3787
  if (data instanceof ArrayBuffer) {
@@ -3882,6 +3952,6 @@ function createHaexVaultSdk(config = {}) {
3882
3952
  return new HaexVaultSdk(config);
3883
3953
  }
3884
3954
 
3885
- export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyClaimPresentationAsync, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3955
+ export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3886
3956
  //# sourceMappingURL=index.mjs.map
3887
3957
  //# sourceMappingURL=index.mjs.map