@haex-space/vault-sdk 2.3.7 → 2.3.10

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 (41) hide show
  1. package/dist/cli/index.js +5 -1
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/cli/index.mjs +5 -1
  4. package/dist/cli/index.mjs.map +1 -1
  5. package/dist/{client-D4hDL-PR.d.ts → client-BdeVsDdi.d.mts} +28 -1
  6. package/dist/{client-BIiJwbdW.d.mts → client-Ctv_qXuk.d.ts} +28 -1
  7. package/dist/index.d.mts +4 -4
  8. package/dist/index.d.ts +4 -4
  9. package/dist/index.js +96 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +96 -2
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/node.d.mts +1 -1
  14. package/dist/node.d.ts +1 -1
  15. package/dist/react.d.mts +2 -2
  16. package/dist/react.d.ts +2 -2
  17. package/dist/react.js +91 -1
  18. package/dist/react.js.map +1 -1
  19. package/dist/react.mjs +91 -1
  20. package/dist/react.mjs.map +1 -1
  21. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  22. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  23. package/dist/runtime/nuxt.plugin.client.js +91 -1
  24. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  25. package/dist/runtime/nuxt.plugin.client.mjs +91 -1
  26. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  27. package/dist/svelte.d.mts +2 -2
  28. package/dist/svelte.d.ts +2 -2
  29. package/dist/svelte.js +91 -1
  30. package/dist/svelte.js.map +1 -1
  31. package/dist/svelte.mjs +91 -1
  32. package/dist/svelte.mjs.map +1 -1
  33. package/dist/{types-FE9ewl3r.d.mts → types-DBF83o_W.d.mts} +41 -1
  34. package/dist/{types-FE9ewl3r.d.ts → types-DBF83o_W.d.ts} +41 -1
  35. package/dist/vue.d.mts +2 -2
  36. package/dist/vue.d.ts +2 -2
  37. package/dist/vue.js +91 -1
  38. package/dist/vue.js.map +1 -1
  39. package/dist/vue.mjs +91 -1
  40. package/dist/vue.mjs.map +1 -1
  41. package/package.json +1 -1
package/dist/node.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { H as HaextensionConfig, g as getExtensionDir, r as readHaextensionConfig } from './config-D_HXjsEV.mjs';
2
- import { E as ExtensionManifest } from './types-FE9ewl3r.mjs';
2
+ import { E as ExtensionManifest } from './types-DBF83o_W.mjs';
3
3
 
4
4
  interface ReadManifestOptions {
5
5
  /** Root directory of the project */
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { H as HaextensionConfig, g as getExtensionDir, r as readHaextensionConfig } from './config-D_HXjsEV.js';
2
- import { E as ExtensionManifest } from './types-FE9ewl3r.js';
2
+ import { E as ExtensionManifest } from './types-DBF83o_W.js';
3
3
 
4
4
  interface ReadManifestOptions {
5
5
  /** Root directory of the project */
package/dist/react.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { H as HaexVaultClient, S as StorageAPI } from './client-BIiJwbdW.mjs';
1
+ import { H as HaexVaultClient, S as StorageAPI } from './client-BdeVsDdi.mjs';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
- import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-FE9ewl3r.mjs';
3
+ import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-DBF83o_W.mjs';
4
4
 
5
5
  /**
6
6
  * React hook for HaexHub SDK
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { H as HaexVaultClient, S as StorageAPI } from './client-D4hDL-PR.js';
1
+ import { H as HaexVaultClient, S as StorageAPI } from './client-Ctv_qXuk.js';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
- import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-FE9ewl3r.js';
3
+ import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-DBF83o_W.js';
4
4
 
5
5
  /**
6
6
  * React hook for HaexHub SDK
package/dist/react.js CHANGED
@@ -337,7 +337,9 @@ var HAEXTENSION_EVENTS = {
337
337
  /** Context (theme, locale, platform) has changed */
338
338
  CONTEXT_CHANGED: "haextension:context:changed",
339
339
  /** Search request from HaexHub */
340
- SEARCH_REQUEST: "haextension:search:request"
340
+ SEARCH_REQUEST: "haextension:search:request",
341
+ /** External request from authorized client (browser extension, CLI, server, etc.) */
342
+ EXTERNAL_REQUEST: "haextension:external:request"
341
343
  };
342
344
 
343
345
  // src/methods.ts
@@ -757,6 +759,7 @@ var HaexVaultClient = class {
757
759
  constructor(config = {}) {
758
760
  this.pendingRequests = /* @__PURE__ */ new Map();
759
761
  this.eventListeners = /* @__PURE__ */ new Map();
762
+ this.externalRequestHandlers = /* @__PURE__ */ new Map();
760
763
  this.messageHandler = null;
761
764
  this.initialized = false;
762
765
  this.requestCounter = 0;
@@ -1019,6 +1022,40 @@ var HaexVaultClient = class {
1019
1022
  results
1020
1023
  });
1021
1024
  }
1025
+ /**
1026
+ * Register a handler for external requests (from browser extensions, CLI, servers, etc.)
1027
+ *
1028
+ * @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
1029
+ * @param handler - Function that processes the request and returns a response
1030
+ * @returns Unsubscribe function to remove the handler
1031
+ *
1032
+ * @example
1033
+ * ```typescript
1034
+ * client.onExternalRequest("get-logins", async (request) => {
1035
+ * const entries = await getMatchingEntries(request.payload.url);
1036
+ * return {
1037
+ * requestId: request.requestId,
1038
+ * success: true,
1039
+ * data: { entries }
1040
+ * };
1041
+ * });
1042
+ * ```
1043
+ */
1044
+ onExternalRequest(action, handler) {
1045
+ this.externalRequestHandlers.set(action, handler);
1046
+ this.log(`[ExternalRequest] Registered handler for action: ${action}`);
1047
+ return () => {
1048
+ this.externalRequestHandlers.delete(action);
1049
+ this.log(`[ExternalRequest] Unregistered handler for action: ${action}`);
1050
+ };
1051
+ }
1052
+ /**
1053
+ * Send a response to an external request back to haex-vault
1054
+ * This is called internally after a handler processes a request
1055
+ */
1056
+ async respondToExternalRequest(response) {
1057
+ await this.request("external.respond", response);
1058
+ }
1022
1059
  async request(method, params = {}) {
1023
1060
  if (this.isNativeWindow && typeof window.__TAURI__ !== "undefined") {
1024
1061
  return this.invoke(method, params);
@@ -1116,6 +1153,13 @@ var HaexVaultClient = class {
1116
1153
  extensionVersion: params.extensionVersion,
1117
1154
  migrations: params.migrations
1118
1155
  });
1156
+ case "external.respond":
1157
+ return invoke("webview_extension_external_respond", {
1158
+ requestId: params.requestId,
1159
+ success: params.success,
1160
+ data: params.data,
1161
+ error: params.error
1162
+ });
1119
1163
  default:
1120
1164
  throw new HaexHubError(
1121
1165
  "METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
@@ -1184,6 +1228,22 @@ var HaexVaultClient = class {
1184
1228
  console.error("[HaexSpace SDK] Failed to setup context change listener:", error);
1185
1229
  this.log("Failed to setup context change listener:", error);
1186
1230
  }
1231
+ try {
1232
+ await listen(HAEXTENSION_EVENTS.EXTERNAL_REQUEST, (event) => {
1233
+ this.log("Received external request event:", event);
1234
+ if (event.payload) {
1235
+ this.handleEvent({
1236
+ type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
1237
+ data: event.payload,
1238
+ timestamp: Date.now()
1239
+ });
1240
+ }
1241
+ });
1242
+ console.log("[HaexSpace SDK] External request listener registered successfully");
1243
+ } catch (error) {
1244
+ console.error("[HaexSpace SDK] Failed to setup external request listener:", error);
1245
+ this.log("Failed to setup external request listener:", error);
1246
+ }
1187
1247
  this.resolveReady();
1188
1248
  return;
1189
1249
  }
@@ -1305,8 +1365,38 @@ postMessage error: ${e}`);
1305
1365
  this.log("Context updated:", this._context);
1306
1366
  this.notifySubscribers();
1307
1367
  }
1368
+ if (event.type === HAEXTENSION_EVENTS.EXTERNAL_REQUEST) {
1369
+ const externalEvent = event;
1370
+ this.handleExternalRequest(externalEvent.data);
1371
+ return;
1372
+ }
1308
1373
  this.emitEvent(event);
1309
1374
  }
1375
+ async handleExternalRequest(request) {
1376
+ this.log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
1377
+ const handler = this.externalRequestHandlers.get(request.action);
1378
+ if (!handler) {
1379
+ this.log(`[ExternalRequest] No handler for action: ${request.action}`);
1380
+ await this.respondToExternalRequest({
1381
+ requestId: request.requestId,
1382
+ success: false,
1383
+ error: `No handler registered for action: ${request.action}`
1384
+ });
1385
+ return;
1386
+ }
1387
+ try {
1388
+ const response = await handler(request);
1389
+ await this.respondToExternalRequest(response);
1390
+ this.log(`[ExternalRequest] Response sent for: ${request.action}`);
1391
+ } catch (error) {
1392
+ this.log(`[ExternalRequest] Handler error:`, error);
1393
+ await this.respondToExternalRequest({
1394
+ requestId: request.requestId,
1395
+ success: false,
1396
+ error: error instanceof Error ? error.message : String(error)
1397
+ });
1398
+ }
1399
+ }
1310
1400
  emitEvent(event) {
1311
1401
  this.log("Event received:", event);
1312
1402
  const listeners = this.eventListeners.get(event.type);