@haex-space/vault-sdk 2.3.8 → 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.
- package/dist/{client-D4hDL-PR.d.ts → client-BdeVsDdi.d.mts} +28 -1
- package/dist/{client-BIiJwbdW.d.mts → client-Ctv_qXuk.d.ts} +28 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +91 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +91 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +91 -1
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
- package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
- package/dist/runtime/nuxt.plugin.client.js +91 -1
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +91 -1
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +91 -1
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +91 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-FE9ewl3r.d.mts → types-DBF83o_W.d.mts} +41 -1
- package/dist/{types-FE9ewl3r.d.ts → types-DBF83o_W.d.ts} +41 -1
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +91 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +91 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/vue.mjs
CHANGED
|
@@ -335,7 +335,9 @@ var HAEXTENSION_EVENTS = {
|
|
|
335
335
|
/** Context (theme, locale, platform) has changed */
|
|
336
336
|
CONTEXT_CHANGED: "haextension:context:changed",
|
|
337
337
|
/** Search request from HaexHub */
|
|
338
|
-
SEARCH_REQUEST: "haextension:search:request"
|
|
338
|
+
SEARCH_REQUEST: "haextension:search:request",
|
|
339
|
+
/** External request from authorized client (browser extension, CLI, server, etc.) */
|
|
340
|
+
EXTERNAL_REQUEST: "haextension:external:request"
|
|
339
341
|
};
|
|
340
342
|
|
|
341
343
|
// src/methods.ts
|
|
@@ -755,6 +757,7 @@ var HaexVaultClient = class {
|
|
|
755
757
|
constructor(config = {}) {
|
|
756
758
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
757
759
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
760
|
+
this.externalRequestHandlers = /* @__PURE__ */ new Map();
|
|
758
761
|
this.messageHandler = null;
|
|
759
762
|
this.initialized = false;
|
|
760
763
|
this.requestCounter = 0;
|
|
@@ -1017,6 +1020,40 @@ var HaexVaultClient = class {
|
|
|
1017
1020
|
results
|
|
1018
1021
|
});
|
|
1019
1022
|
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Register a handler for external requests (from browser extensions, CLI, servers, etc.)
|
|
1025
|
+
*
|
|
1026
|
+
* @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
|
|
1027
|
+
* @param handler - Function that processes the request and returns a response
|
|
1028
|
+
* @returns Unsubscribe function to remove the handler
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```typescript
|
|
1032
|
+
* client.onExternalRequest("get-logins", async (request) => {
|
|
1033
|
+
* const entries = await getMatchingEntries(request.payload.url);
|
|
1034
|
+
* return {
|
|
1035
|
+
* requestId: request.requestId,
|
|
1036
|
+
* success: true,
|
|
1037
|
+
* data: { entries }
|
|
1038
|
+
* };
|
|
1039
|
+
* });
|
|
1040
|
+
* ```
|
|
1041
|
+
*/
|
|
1042
|
+
onExternalRequest(action, handler) {
|
|
1043
|
+
this.externalRequestHandlers.set(action, handler);
|
|
1044
|
+
this.log(`[ExternalRequest] Registered handler for action: ${action}`);
|
|
1045
|
+
return () => {
|
|
1046
|
+
this.externalRequestHandlers.delete(action);
|
|
1047
|
+
this.log(`[ExternalRequest] Unregistered handler for action: ${action}`);
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Send a response to an external request back to haex-vault
|
|
1052
|
+
* This is called internally after a handler processes a request
|
|
1053
|
+
*/
|
|
1054
|
+
async respondToExternalRequest(response) {
|
|
1055
|
+
await this.request("external.respond", response);
|
|
1056
|
+
}
|
|
1020
1057
|
async request(method, params = {}) {
|
|
1021
1058
|
if (this.isNativeWindow && typeof window.__TAURI__ !== "undefined") {
|
|
1022
1059
|
return this.invoke(method, params);
|
|
@@ -1114,6 +1151,13 @@ var HaexVaultClient = class {
|
|
|
1114
1151
|
extensionVersion: params.extensionVersion,
|
|
1115
1152
|
migrations: params.migrations
|
|
1116
1153
|
});
|
|
1154
|
+
case "external.respond":
|
|
1155
|
+
return invoke("webview_extension_external_respond", {
|
|
1156
|
+
requestId: params.requestId,
|
|
1157
|
+
success: params.success,
|
|
1158
|
+
data: params.data,
|
|
1159
|
+
error: params.error
|
|
1160
|
+
});
|
|
1117
1161
|
default:
|
|
1118
1162
|
throw new HaexHubError(
|
|
1119
1163
|
"METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
|
|
@@ -1182,6 +1226,22 @@ var HaexVaultClient = class {
|
|
|
1182
1226
|
console.error("[HaexSpace SDK] Failed to setup context change listener:", error);
|
|
1183
1227
|
this.log("Failed to setup context change listener:", error);
|
|
1184
1228
|
}
|
|
1229
|
+
try {
|
|
1230
|
+
await listen(HAEXTENSION_EVENTS.EXTERNAL_REQUEST, (event) => {
|
|
1231
|
+
this.log("Received external request event:", event);
|
|
1232
|
+
if (event.payload) {
|
|
1233
|
+
this.handleEvent({
|
|
1234
|
+
type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
|
|
1235
|
+
data: event.payload,
|
|
1236
|
+
timestamp: Date.now()
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
console.log("[HaexSpace SDK] External request listener registered successfully");
|
|
1241
|
+
} catch (error) {
|
|
1242
|
+
console.error("[HaexSpace SDK] Failed to setup external request listener:", error);
|
|
1243
|
+
this.log("Failed to setup external request listener:", error);
|
|
1244
|
+
}
|
|
1185
1245
|
this.resolveReady();
|
|
1186
1246
|
return;
|
|
1187
1247
|
}
|
|
@@ -1303,8 +1363,38 @@ postMessage error: ${e}`);
|
|
|
1303
1363
|
this.log("Context updated:", this._context);
|
|
1304
1364
|
this.notifySubscribers();
|
|
1305
1365
|
}
|
|
1366
|
+
if (event.type === HAEXTENSION_EVENTS.EXTERNAL_REQUEST) {
|
|
1367
|
+
const externalEvent = event;
|
|
1368
|
+
this.handleExternalRequest(externalEvent.data);
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1306
1371
|
this.emitEvent(event);
|
|
1307
1372
|
}
|
|
1373
|
+
async handleExternalRequest(request) {
|
|
1374
|
+
this.log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
1375
|
+
const handler = this.externalRequestHandlers.get(request.action);
|
|
1376
|
+
if (!handler) {
|
|
1377
|
+
this.log(`[ExternalRequest] No handler for action: ${request.action}`);
|
|
1378
|
+
await this.respondToExternalRequest({
|
|
1379
|
+
requestId: request.requestId,
|
|
1380
|
+
success: false,
|
|
1381
|
+
error: `No handler registered for action: ${request.action}`
|
|
1382
|
+
});
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
try {
|
|
1386
|
+
const response = await handler(request);
|
|
1387
|
+
await this.respondToExternalRequest(response);
|
|
1388
|
+
this.log(`[ExternalRequest] Response sent for: ${request.action}`);
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
this.log(`[ExternalRequest] Handler error:`, error);
|
|
1391
|
+
await this.respondToExternalRequest({
|
|
1392
|
+
requestId: request.requestId,
|
|
1393
|
+
success: false,
|
|
1394
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1308
1398
|
emitEvent(event) {
|
|
1309
1399
|
this.log("Event received:", event);
|
|
1310
1400
|
const listeners = this.eventListeners.get(event.type);
|