@haex-space/vault-sdk 3.7.0 → 4.0.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-C6pEREPM.d.ts} +48 -3
  7. package/dist/{client-Dn4AbXbT.d.mts → client-GdCi-m2s.d.mts} +48 -3
  8. package/dist/haex_bundle_bg.wasm +0 -0
  9. package/dist/index.d.mts +11 -59
  10. package/dist/index.d.ts +11 -59
  11. package/dist/index.js +130 -105
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +149 -123
  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 +137 -7
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +157 -27
  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 +45 -7
  34. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  35. package/dist/runtime/nuxt.plugin.client.mjs +45 -7
  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 +137 -7
  40. package/dist/svelte.js.map +1 -1
  41. package/dist/svelte.mjs +157 -27
  42. package/dist/svelte.mjs.map +1 -1
  43. package/dist/{types-DQZCRfC-.d.mts → types-Ba4G6ZpC.d.mts} +10 -2
  44. package/dist/{types-DQZCRfC-.d.ts → types-Ba4G6ZpC.d.ts} +10 -2
  45. package/dist/vue.d.mts +2 -2
  46. package/dist/vue.d.ts +2 -2
  47. package/dist/vue.js +137 -7
  48. package/dist/vue.js.map +1 -1
  49. package/dist/vue.mjs +157 -27
  50. package/dist/vue.mjs.map +1 -1
  51. package/package.json +8 -6
@@ -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-Dn4AbXbT.mjs';
4
- import { A as ApplicationContext } from '../types-DQZCRfC-.mjs';
3
+ import { H as HaexVaultSdk } from '../client-GdCi-m2s.mjs';
4
+ import { A as ApplicationContext } from '../types-Ba4G6ZpC.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-DH4Km77u.js';
4
- import { A as ApplicationContext } from '../types-DQZCRfC-.js';
3
+ import { H as HaexVaultSdk } from '../client-C6pEREPM.js';
4
+ import { A as ApplicationContext } from '../types-Ba4G6ZpC.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
7
7
  declare const _default: nuxt_app.Plugin<{
@@ -182,7 +182,12 @@ var EXTENSION_COMMANDS = {
182
182
  /** Get extension info (manifest, id, etc.) */
183
183
  getInfo: "extension_get_info",
184
184
  /** Get application context (theme, locale, etc.) */
185
- getContext: "extension_context_get"};
185
+ getContext: "extension_context_get",
186
+ /** Ask the host to mark (or unmark) this extension's own tab as wanting attention */
187
+ tabAttention: "extension_tab_attention",
188
+ /** Ask the user to confirm, in a dialog the host draws over this extension's tab */
189
+ dialogConfirm: "extension_dialog_confirm"
190
+ };
186
191
 
187
192
  // src/commands/remoteStorage.ts
188
193
  var REMOTE_STORAGE_COMMANDS = {
@@ -1517,6 +1522,32 @@ var NotificationsAPI = class {
1517
1522
  }
1518
1523
  };
1519
1524
 
1525
+ // src/api/tab.ts
1526
+ var TabAPI = class {
1527
+ constructor(client) {
1528
+ this.client = client;
1529
+ }
1530
+ /**
1531
+ * Mark the tab as wanting the user's attention (`true`), e.g. for unread
1532
+ * content, or clear the mark (`false`).
1533
+ */
1534
+ async requestAttention(active) {
1535
+ await this.client.request(EXTENSION_COMMANDS.tabAttention, { active });
1536
+ }
1537
+ };
1538
+
1539
+ // src/api/dialog.ts
1540
+ var DialogAPI = class {
1541
+ constructor(client) {
1542
+ this.client = client;
1543
+ }
1544
+ /** Asks the user; resolves `true` for confirm, `false` for cancel or when the dialog is closed. */
1545
+ async confirm(options) {
1546
+ const answer = await this.client.request(EXTENSION_COMMANDS.dialogConfirm, { ...options }, { timeout: null });
1547
+ return answer === true;
1548
+ }
1549
+ };
1550
+
1520
1551
  // src/messages.ts
1521
1552
  var HAEXSPACE_MESSAGE_TYPES = {
1522
1553
  /** Debug message for development/troubleshooting */
@@ -1842,6 +1873,10 @@ function waitForHostPortAsync(log) {
1842
1873
  const handler = (event) => {
1843
1874
  const type = event.data?.type;
1844
1875
  if (type !== HAEXSPACE_MESSAGE_TYPES.PORT_INIT) return;
1876
+ if (event.source !== window.parent) {
1877
+ log("PORT_INIT from a window other than the parent \u2014 ignoring");
1878
+ return;
1879
+ }
1845
1880
  const port = event.ports[0];
1846
1881
  if (!port) {
1847
1882
  log("PORT_INIT received but event.ports is empty \u2014 ignoring");
@@ -1878,7 +1913,7 @@ postMessage error: ${e}`);
1878
1913
  function generateRequestId(counter) {
1879
1914
  return `req_${counter}`;
1880
1915
  }
1881
- function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port) {
1916
+ function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port, timeoutMs = config.timeout) {
1882
1917
  if (!port) {
1883
1918
  return Promise.reject(
1884
1919
  new HaexVaultSdkError(
@@ -1893,14 +1928,14 @@ function sendPostMessage(method, params, requestId, config, extensionInfo, pendi
1893
1928
  timestamp: Date.now()
1894
1929
  };
1895
1930
  return new Promise((resolve, reject) => {
1896
- const timeout = setTimeout(() => {
1931
+ const timeout = timeoutMs === null ? void 0 : setTimeout(() => {
1897
1932
  pendingRequests.delete(requestId);
1898
1933
  reject(
1899
1934
  new HaexVaultSdkError("TIMEOUT" /* TIMEOUT */, "errors.timeout", {
1900
- timeout: config.timeout
1935
+ timeout: timeoutMs
1901
1936
  })
1902
1937
  );
1903
- }, config.timeout);
1938
+ }, timeoutMs);
1904
1939
  pendingRequests.set(requestId, { resolve, reject, timeout });
1905
1940
  if (config.debug) {
1906
1941
  console.log("[SDK Debug] ========== Sending Request ==========");
@@ -2253,6 +2288,8 @@ var HaexVaultSdk = class {
2253
2288
  this.passwords = new PasswordsAPI(this);
2254
2289
  this.mail = new MailAPI(this);
2255
2290
  this.notifications = new NotificationsAPI(this);
2291
+ this.tab = new TabAPI(this);
2292
+ this.dialog = new DialogAPI(this);
2256
2293
  installConsoleForwarding(this.config.debug);
2257
2294
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2258
2295
  const data = event.data;
@@ -2408,7 +2445,7 @@ var HaexVaultSdk = class {
2408
2445
  // ==========================================================================
2409
2446
  // Communication
2410
2447
  // ==========================================================================
2411
- async request(method, params) {
2448
+ async request(method, params, options) {
2412
2449
  const resolvedParams = params ?? {};
2413
2450
  const send = () => {
2414
2451
  if (this.isNativeWindow && hasTauri()) {
@@ -2427,7 +2464,8 @@ var HaexVaultSdk = class {
2427
2464
  this.config,
2428
2465
  this._extensionInfo,
2429
2466
  this.pendingRequests,
2430
- this.hostPort
2467
+ this.hostPort,
2468
+ options?.timeout
2431
2469
  );
2432
2470
  };
2433
2471
  return withPermissionRetry(send, this.permissionWaiters, this.log.bind(this));