@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/index.mjs
CHANGED
|
@@ -373,7 +373,9 @@ var HAEXTENSION_EVENTS = {
|
|
|
373
373
|
/** Context (theme, locale, platform) has changed */
|
|
374
374
|
CONTEXT_CHANGED: "haextension:context:changed",
|
|
375
375
|
/** Search request from HaexHub */
|
|
376
|
-
SEARCH_REQUEST: "haextension:search:request"
|
|
376
|
+
SEARCH_REQUEST: "haextension:search:request",
|
|
377
|
+
/** External request from authorized client (browser extension, CLI, server, etc.) */
|
|
378
|
+
EXTERNAL_REQUEST: "haextension:external:request"
|
|
377
379
|
};
|
|
378
380
|
|
|
379
381
|
// src/methods.ts
|
|
@@ -816,6 +818,7 @@ var HaexVaultClient = class {
|
|
|
816
818
|
constructor(config = {}) {
|
|
817
819
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
818
820
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
821
|
+
this.externalRequestHandlers = /* @__PURE__ */ new Map();
|
|
819
822
|
this.messageHandler = null;
|
|
820
823
|
this.initialized = false;
|
|
821
824
|
this.requestCounter = 0;
|
|
@@ -1078,6 +1081,40 @@ var HaexVaultClient = class {
|
|
|
1078
1081
|
results
|
|
1079
1082
|
});
|
|
1080
1083
|
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Register a handler for external requests (from browser extensions, CLI, servers, etc.)
|
|
1086
|
+
*
|
|
1087
|
+
* @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
|
|
1088
|
+
* @param handler - Function that processes the request and returns a response
|
|
1089
|
+
* @returns Unsubscribe function to remove the handler
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```typescript
|
|
1093
|
+
* client.onExternalRequest("get-logins", async (request) => {
|
|
1094
|
+
* const entries = await getMatchingEntries(request.payload.url);
|
|
1095
|
+
* return {
|
|
1096
|
+
* requestId: request.requestId,
|
|
1097
|
+
* success: true,
|
|
1098
|
+
* data: { entries }
|
|
1099
|
+
* };
|
|
1100
|
+
* });
|
|
1101
|
+
* ```
|
|
1102
|
+
*/
|
|
1103
|
+
onExternalRequest(action, handler) {
|
|
1104
|
+
this.externalRequestHandlers.set(action, handler);
|
|
1105
|
+
this.log(`[ExternalRequest] Registered handler for action: ${action}`);
|
|
1106
|
+
return () => {
|
|
1107
|
+
this.externalRequestHandlers.delete(action);
|
|
1108
|
+
this.log(`[ExternalRequest] Unregistered handler for action: ${action}`);
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Send a response to an external request back to haex-vault
|
|
1113
|
+
* This is called internally after a handler processes a request
|
|
1114
|
+
*/
|
|
1115
|
+
async respondToExternalRequest(response) {
|
|
1116
|
+
await this.request("external.respond", response);
|
|
1117
|
+
}
|
|
1081
1118
|
async request(method, params = {}) {
|
|
1082
1119
|
if (this.isNativeWindow && typeof window.__TAURI__ !== "undefined") {
|
|
1083
1120
|
return this.invoke(method, params);
|
|
@@ -1175,6 +1212,13 @@ var HaexVaultClient = class {
|
|
|
1175
1212
|
extensionVersion: params.extensionVersion,
|
|
1176
1213
|
migrations: params.migrations
|
|
1177
1214
|
});
|
|
1215
|
+
case "external.respond":
|
|
1216
|
+
return invoke("webview_extension_external_respond", {
|
|
1217
|
+
requestId: params.requestId,
|
|
1218
|
+
success: params.success,
|
|
1219
|
+
data: params.data,
|
|
1220
|
+
error: params.error
|
|
1221
|
+
});
|
|
1178
1222
|
default:
|
|
1179
1223
|
throw new HaexHubError(
|
|
1180
1224
|
"METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
|
|
@@ -1243,6 +1287,22 @@ var HaexVaultClient = class {
|
|
|
1243
1287
|
console.error("[HaexSpace SDK] Failed to setup context change listener:", error);
|
|
1244
1288
|
this.log("Failed to setup context change listener:", error);
|
|
1245
1289
|
}
|
|
1290
|
+
try {
|
|
1291
|
+
await listen(HAEXTENSION_EVENTS.EXTERNAL_REQUEST, (event) => {
|
|
1292
|
+
this.log("Received external request event:", event);
|
|
1293
|
+
if (event.payload) {
|
|
1294
|
+
this.handleEvent({
|
|
1295
|
+
type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
|
|
1296
|
+
data: event.payload,
|
|
1297
|
+
timestamp: Date.now()
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
console.log("[HaexSpace SDK] External request listener registered successfully");
|
|
1302
|
+
} catch (error) {
|
|
1303
|
+
console.error("[HaexSpace SDK] Failed to setup external request listener:", error);
|
|
1304
|
+
this.log("Failed to setup external request listener:", error);
|
|
1305
|
+
}
|
|
1246
1306
|
this.resolveReady();
|
|
1247
1307
|
return;
|
|
1248
1308
|
}
|
|
@@ -1364,8 +1424,38 @@ postMessage error: ${e}`);
|
|
|
1364
1424
|
this.log("Context updated:", this._context);
|
|
1365
1425
|
this.notifySubscribers();
|
|
1366
1426
|
}
|
|
1427
|
+
if (event.type === HAEXTENSION_EVENTS.EXTERNAL_REQUEST) {
|
|
1428
|
+
const externalEvent = event;
|
|
1429
|
+
this.handleExternalRequest(externalEvent.data);
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1367
1432
|
this.emitEvent(event);
|
|
1368
1433
|
}
|
|
1434
|
+
async handleExternalRequest(request) {
|
|
1435
|
+
this.log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
1436
|
+
const handler = this.externalRequestHandlers.get(request.action);
|
|
1437
|
+
if (!handler) {
|
|
1438
|
+
this.log(`[ExternalRequest] No handler for action: ${request.action}`);
|
|
1439
|
+
await this.respondToExternalRequest({
|
|
1440
|
+
requestId: request.requestId,
|
|
1441
|
+
success: false,
|
|
1442
|
+
error: `No handler registered for action: ${request.action}`
|
|
1443
|
+
});
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
try {
|
|
1447
|
+
const response = await handler(request);
|
|
1448
|
+
await this.respondToExternalRequest(response);
|
|
1449
|
+
this.log(`[ExternalRequest] Response sent for: ${request.action}`);
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
this.log(`[ExternalRequest] Handler error:`, error);
|
|
1452
|
+
await this.respondToExternalRequest({
|
|
1453
|
+
requestId: request.requestId,
|
|
1454
|
+
success: false,
|
|
1455
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1369
1459
|
emitEvent(event) {
|
|
1370
1460
|
this.log("Event received:", event);
|
|
1371
1461
|
const listeners = this.eventListeners.get(event.type);
|