@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as EventCallback } from './types-
|
|
1
|
+
import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-DBF83o_W.mjs';
|
|
2
2
|
import { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
|
|
4
4
|
declare class StorageAPI {
|
|
@@ -185,6 +185,7 @@ declare class HaexVaultClient {
|
|
|
185
185
|
private config;
|
|
186
186
|
private pendingRequests;
|
|
187
187
|
private eventListeners;
|
|
188
|
+
private externalRequestHandlers;
|
|
188
189
|
private messageHandler;
|
|
189
190
|
private initialized;
|
|
190
191
|
private requestCounter;
|
|
@@ -280,6 +281,31 @@ declare class HaexVaultClient {
|
|
|
280
281
|
requestDatabasePermission(request: DatabasePermissionRequest): Promise<PermissionResponse>;
|
|
281
282
|
checkDatabasePermission(resource: string, operation: "read" | "write"): Promise<boolean>;
|
|
282
283
|
respondToSearch(requestId: string, results: SearchResult[]): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Register a handler for external requests (from browser extensions, CLI, servers, etc.)
|
|
286
|
+
*
|
|
287
|
+
* @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
|
|
288
|
+
* @param handler - Function that processes the request and returns a response
|
|
289
|
+
* @returns Unsubscribe function to remove the handler
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* client.onExternalRequest("get-logins", async (request) => {
|
|
294
|
+
* const entries = await getMatchingEntries(request.payload.url);
|
|
295
|
+
* return {
|
|
296
|
+
* requestId: request.requestId,
|
|
297
|
+
* success: true,
|
|
298
|
+
* data: { entries }
|
|
299
|
+
* };
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
onExternalRequest(action: string, handler: ExternalRequestHandler): () => void;
|
|
304
|
+
/**
|
|
305
|
+
* Send a response to an external request back to haex-vault
|
|
306
|
+
* This is called internally after a handler processes a request
|
|
307
|
+
*/
|
|
308
|
+
respondToExternalRequest(response: ExternalResponse): Promise<void>;
|
|
283
309
|
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
284
310
|
private postMessage;
|
|
285
311
|
private invoke;
|
|
@@ -289,6 +315,7 @@ declare class HaexVaultClient {
|
|
|
289
315
|
private init;
|
|
290
316
|
private handleMessage;
|
|
291
317
|
private handleEvent;
|
|
318
|
+
private handleExternalRequest;
|
|
292
319
|
private emitEvent;
|
|
293
320
|
private generateRequestId;
|
|
294
321
|
private validatePublicKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as EventCallback } from './types-
|
|
1
|
+
import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-DBF83o_W.js';
|
|
2
2
|
import { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
|
|
4
4
|
declare class StorageAPI {
|
|
@@ -185,6 +185,7 @@ declare class HaexVaultClient {
|
|
|
185
185
|
private config;
|
|
186
186
|
private pendingRequests;
|
|
187
187
|
private eventListeners;
|
|
188
|
+
private externalRequestHandlers;
|
|
188
189
|
private messageHandler;
|
|
189
190
|
private initialized;
|
|
190
191
|
private requestCounter;
|
|
@@ -280,6 +281,31 @@ declare class HaexVaultClient {
|
|
|
280
281
|
requestDatabasePermission(request: DatabasePermissionRequest): Promise<PermissionResponse>;
|
|
281
282
|
checkDatabasePermission(resource: string, operation: "read" | "write"): Promise<boolean>;
|
|
282
283
|
respondToSearch(requestId: string, results: SearchResult[]): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Register a handler for external requests (from browser extensions, CLI, servers, etc.)
|
|
286
|
+
*
|
|
287
|
+
* @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
|
|
288
|
+
* @param handler - Function that processes the request and returns a response
|
|
289
|
+
* @returns Unsubscribe function to remove the handler
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* client.onExternalRequest("get-logins", async (request) => {
|
|
294
|
+
* const entries = await getMatchingEntries(request.payload.url);
|
|
295
|
+
* return {
|
|
296
|
+
* requestId: request.requestId,
|
|
297
|
+
* success: true,
|
|
298
|
+
* data: { entries }
|
|
299
|
+
* };
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
onExternalRequest(action: string, handler: ExternalRequestHandler): () => void;
|
|
304
|
+
/**
|
|
305
|
+
* Send a response to an external request back to haex-vault
|
|
306
|
+
* This is called internally after a handler processes a request
|
|
307
|
+
*/
|
|
308
|
+
respondToExternalRequest(response: ExternalResponse): Promise<void>;
|
|
283
309
|
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
284
310
|
private postMessage;
|
|
285
311
|
private invoke;
|
|
@@ -289,6 +315,7 @@ declare class HaexVaultClient {
|
|
|
289
315
|
private init;
|
|
290
316
|
private handleMessage;
|
|
291
317
|
private handleEvent;
|
|
318
|
+
private handleExternalRequest;
|
|
292
319
|
private emitEvent;
|
|
293
320
|
private generateRequestId;
|
|
294
321
|
private validatePublicKey;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { H as HaexVaultClient } from './client-
|
|
2
|
-
export { D as DatabaseAPI, F as FilesystemAPI, P as PermissionsAPI, W as WebAPI } from './client-
|
|
3
|
-
import { E as ExtensionManifest, H as HaexHubConfig } from './types-
|
|
4
|
-
export { A as ApplicationContext, C as ContextChangedEvent,
|
|
1
|
+
import { H as HaexVaultClient } from './client-BdeVsDdi.mjs';
|
|
2
|
+
export { D as DatabaseAPI, F as FilesystemAPI, P as PermissionsAPI, W as WebAPI } from './client-BdeVsDdi.mjs';
|
|
3
|
+
import { E as ExtensionManifest, H as HaexHubConfig } from './types-DBF83o_W.mjs';
|
|
4
|
+
export { A as ApplicationContext, C as ContextChangedEvent, v as DEFAULT_TIMEOUT, o as DatabaseColumnInfo, m as DatabaseExecuteParams, k as DatabasePermission, d as DatabasePermissionRequest, l as DatabaseQueryParams, D as DatabaseQueryResult, n as DatabaseTableInfo, u as ErrorCode, g as EventCallback, a as ExtensionInfo, s as ExternalRequest, r as ExternalRequestEvent, e as ExternalRequestHandler, f as ExternalResponse, y as HAEXTENSION_EVENTS, x as HaexHubError, j as HaexHubEvent, h as HaexHubRequest, i as HaexHubResponse, z as HaextensionEvent, P as PermissionResponse, t as PermissionStatus, p as SearchQuery, q as SearchRequestEvent, S as SearchResult, T as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, w as getTableName } from './types-DBF83o_W.mjs';
|
|
5
5
|
export { H as HaextensionConfig } from './config-D_HXjsEV.mjs';
|
|
6
6
|
import 'drizzle-orm/sqlite-proxy';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { H as HaexVaultClient } from './client-
|
|
2
|
-
export { D as DatabaseAPI, F as FilesystemAPI, P as PermissionsAPI, W as WebAPI } from './client-
|
|
3
|
-
import { E as ExtensionManifest, H as HaexHubConfig } from './types-
|
|
4
|
-
export { A as ApplicationContext, C as ContextChangedEvent,
|
|
1
|
+
import { H as HaexVaultClient } from './client-Ctv_qXuk.js';
|
|
2
|
+
export { D as DatabaseAPI, F as FilesystemAPI, P as PermissionsAPI, W as WebAPI } from './client-Ctv_qXuk.js';
|
|
3
|
+
import { E as ExtensionManifest, H as HaexHubConfig } from './types-DBF83o_W.js';
|
|
4
|
+
export { A as ApplicationContext, C as ContextChangedEvent, v as DEFAULT_TIMEOUT, o as DatabaseColumnInfo, m as DatabaseExecuteParams, k as DatabasePermission, d as DatabasePermissionRequest, l as DatabaseQueryParams, D as DatabaseQueryResult, n as DatabaseTableInfo, u as ErrorCode, g as EventCallback, a as ExtensionInfo, s as ExternalRequest, r as ExternalRequestEvent, e as ExternalRequestHandler, f as ExternalResponse, y as HAEXTENSION_EVENTS, x as HaexHubError, j as HaexHubEvent, h as HaexHubRequest, i as HaexHubResponse, z as HaextensionEvent, P as PermissionResponse, t as PermissionStatus, p as SearchQuery, q as SearchRequestEvent, S as SearchResult, T as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, w as getTableName } from './types-DBF83o_W.js';
|
|
5
5
|
export { H as HaextensionConfig } from './config-D_HXjsEV.js';
|
|
6
6
|
import 'drizzle-orm/sqlite-proxy';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -375,7 +375,9 @@ var HAEXTENSION_EVENTS = {
|
|
|
375
375
|
/** Context (theme, locale, platform) has changed */
|
|
376
376
|
CONTEXT_CHANGED: "haextension:context:changed",
|
|
377
377
|
/** Search request from HaexHub */
|
|
378
|
-
SEARCH_REQUEST: "haextension:search:request"
|
|
378
|
+
SEARCH_REQUEST: "haextension:search:request",
|
|
379
|
+
/** External request from authorized client (browser extension, CLI, server, etc.) */
|
|
380
|
+
EXTERNAL_REQUEST: "haextension:external:request"
|
|
379
381
|
};
|
|
380
382
|
|
|
381
383
|
// src/methods.ts
|
|
@@ -818,6 +820,7 @@ var HaexVaultClient = class {
|
|
|
818
820
|
constructor(config = {}) {
|
|
819
821
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
820
822
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
823
|
+
this.externalRequestHandlers = /* @__PURE__ */ new Map();
|
|
821
824
|
this.messageHandler = null;
|
|
822
825
|
this.initialized = false;
|
|
823
826
|
this.requestCounter = 0;
|
|
@@ -1080,6 +1083,40 @@ var HaexVaultClient = class {
|
|
|
1080
1083
|
results
|
|
1081
1084
|
});
|
|
1082
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Register a handler for external requests (from browser extensions, CLI, servers, etc.)
|
|
1088
|
+
*
|
|
1089
|
+
* @param action - The action/method name to handle (e.g., "get-logins", "get-totp")
|
|
1090
|
+
* @param handler - Function that processes the request and returns a response
|
|
1091
|
+
* @returns Unsubscribe function to remove the handler
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```typescript
|
|
1095
|
+
* client.onExternalRequest("get-logins", async (request) => {
|
|
1096
|
+
* const entries = await getMatchingEntries(request.payload.url);
|
|
1097
|
+
* return {
|
|
1098
|
+
* requestId: request.requestId,
|
|
1099
|
+
* success: true,
|
|
1100
|
+
* data: { entries }
|
|
1101
|
+
* };
|
|
1102
|
+
* });
|
|
1103
|
+
* ```
|
|
1104
|
+
*/
|
|
1105
|
+
onExternalRequest(action, handler) {
|
|
1106
|
+
this.externalRequestHandlers.set(action, handler);
|
|
1107
|
+
this.log(`[ExternalRequest] Registered handler for action: ${action}`);
|
|
1108
|
+
return () => {
|
|
1109
|
+
this.externalRequestHandlers.delete(action);
|
|
1110
|
+
this.log(`[ExternalRequest] Unregistered handler for action: ${action}`);
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Send a response to an external request back to haex-vault
|
|
1115
|
+
* This is called internally after a handler processes a request
|
|
1116
|
+
*/
|
|
1117
|
+
async respondToExternalRequest(response) {
|
|
1118
|
+
await this.request("external.respond", response);
|
|
1119
|
+
}
|
|
1083
1120
|
async request(method, params = {}) {
|
|
1084
1121
|
if (this.isNativeWindow && typeof window.__TAURI__ !== "undefined") {
|
|
1085
1122
|
return this.invoke(method, params);
|
|
@@ -1177,6 +1214,13 @@ var HaexVaultClient = class {
|
|
|
1177
1214
|
extensionVersion: params.extensionVersion,
|
|
1178
1215
|
migrations: params.migrations
|
|
1179
1216
|
});
|
|
1217
|
+
case "external.respond":
|
|
1218
|
+
return invoke("webview_extension_external_respond", {
|
|
1219
|
+
requestId: params.requestId,
|
|
1220
|
+
success: params.success,
|
|
1221
|
+
data: params.data,
|
|
1222
|
+
error: params.error
|
|
1223
|
+
});
|
|
1180
1224
|
default:
|
|
1181
1225
|
throw new HaexHubError(
|
|
1182
1226
|
"METHOD_NOT_FOUND" /* METHOD_NOT_FOUND */,
|
|
@@ -1245,6 +1289,22 @@ var HaexVaultClient = class {
|
|
|
1245
1289
|
console.error("[HaexSpace SDK] Failed to setup context change listener:", error);
|
|
1246
1290
|
this.log("Failed to setup context change listener:", error);
|
|
1247
1291
|
}
|
|
1292
|
+
try {
|
|
1293
|
+
await listen(HAEXTENSION_EVENTS.EXTERNAL_REQUEST, (event) => {
|
|
1294
|
+
this.log("Received external request event:", event);
|
|
1295
|
+
if (event.payload) {
|
|
1296
|
+
this.handleEvent({
|
|
1297
|
+
type: HAEXTENSION_EVENTS.EXTERNAL_REQUEST,
|
|
1298
|
+
data: event.payload,
|
|
1299
|
+
timestamp: Date.now()
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
console.log("[HaexSpace SDK] External request listener registered successfully");
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
console.error("[HaexSpace SDK] Failed to setup external request listener:", error);
|
|
1306
|
+
this.log("Failed to setup external request listener:", error);
|
|
1307
|
+
}
|
|
1248
1308
|
this.resolveReady();
|
|
1249
1309
|
return;
|
|
1250
1310
|
}
|
|
@@ -1366,8 +1426,38 @@ postMessage error: ${e}`);
|
|
|
1366
1426
|
this.log("Context updated:", this._context);
|
|
1367
1427
|
this.notifySubscribers();
|
|
1368
1428
|
}
|
|
1429
|
+
if (event.type === HAEXTENSION_EVENTS.EXTERNAL_REQUEST) {
|
|
1430
|
+
const externalEvent = event;
|
|
1431
|
+
this.handleExternalRequest(externalEvent.data);
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1369
1434
|
this.emitEvent(event);
|
|
1370
1435
|
}
|
|
1436
|
+
async handleExternalRequest(request) {
|
|
1437
|
+
this.log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
1438
|
+
const handler = this.externalRequestHandlers.get(request.action);
|
|
1439
|
+
if (!handler) {
|
|
1440
|
+
this.log(`[ExternalRequest] No handler for action: ${request.action}`);
|
|
1441
|
+
await this.respondToExternalRequest({
|
|
1442
|
+
requestId: request.requestId,
|
|
1443
|
+
success: false,
|
|
1444
|
+
error: `No handler registered for action: ${request.action}`
|
|
1445
|
+
});
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
try {
|
|
1449
|
+
const response = await handler(request);
|
|
1450
|
+
await this.respondToExternalRequest(response);
|
|
1451
|
+
this.log(`[ExternalRequest] Response sent for: ${request.action}`);
|
|
1452
|
+
} catch (error) {
|
|
1453
|
+
this.log(`[ExternalRequest] Handler error:`, error);
|
|
1454
|
+
await this.respondToExternalRequest({
|
|
1455
|
+
requestId: request.requestId,
|
|
1456
|
+
success: false,
|
|
1457
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1371
1461
|
emitEvent(event) {
|
|
1372
1462
|
this.log("Event received:", event);
|
|
1373
1463
|
const listeners = this.eventListeners.get(event.type);
|