@haex-space/vault-sdk 2.4.0 → 2.5.2

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.
@@ -17,10 +17,18 @@ declare const HAEXTENSION_EVENTS: {
17
17
  readonly CONTEXT_CHANGED: "haextension:context:changed";
18
18
  /** Search request from HaexHub */
19
19
  readonly SEARCH_REQUEST: "haextension:search:request";
20
- /** External request from authorized client (browser extension, CLI, server, etc.) */
21
- readonly EXTERNAL_REQUEST: "haextension:external:request";
22
20
  };
23
21
  type HaextensionEvent = typeof HAEXTENSION_EVENTS[keyof typeof HAEXTENSION_EVENTS];
22
+ /**
23
+ * Events for external client communication (browser extensions, CLI tools, servers, etc.)
24
+ */
25
+ declare const EXTERNAL_EVENTS: {
26
+ /** External request from authorized client */
27
+ readonly REQUEST: "haextension:external:request";
28
+ /** New external client requesting authorization */
29
+ readonly AUTHORIZATION_REQUEST: "external:authorization-request";
30
+ };
31
+ type ExternalEvent = typeof EXTERNAL_EVENTS[keyof typeof EXTERNAL_EVENTS];
24
32
 
25
33
  declare const DEFAULT_TIMEOUT = 30000;
26
34
  declare const TABLE_SEPARATOR = "__";
@@ -162,7 +170,7 @@ interface SearchRequestEvent extends HaexHubEvent {
162
170
  * These requests come through the WebSocket bridge and are routed to the appropriate extension.
163
171
  */
164
172
  interface ExternalRequestEvent extends HaexHubEvent {
165
- type: typeof HAEXTENSION_EVENTS.EXTERNAL_REQUEST;
173
+ type: typeof EXTERNAL_EVENTS.REQUEST;
166
174
  data: ExternalRequest;
167
175
  }
168
176
  /**
@@ -195,6 +203,93 @@ interface ExternalResponse {
195
203
  * Handler function type for external requests
196
204
  */
197
205
  type ExternalRequestHandler = (request: ExternalRequest) => Promise<ExternalResponse> | ExternalResponse;
206
+ /**
207
+ * An authorized external client stored in the database
208
+ */
209
+ interface AuthorizedClient {
210
+ /** Row ID */
211
+ id: string;
212
+ /** Unique client identifier (public key fingerprint) */
213
+ clientId: string;
214
+ /** Human-readable client name */
215
+ clientName: string;
216
+ /** Client's public key (base64) */
217
+ publicKey: string;
218
+ /** Extension ID this client can access */
219
+ extensionId: string;
220
+ /** When the client was authorized (ISO 8601) */
221
+ authorizedAt: string | null;
222
+ /** Last time the client connected (ISO 8601) */
223
+ lastSeen: string | null;
224
+ }
225
+ /**
226
+ * A blocked external client stored in the database
227
+ */
228
+ interface BlockedClient {
229
+ /** Row ID */
230
+ id: string;
231
+ /** Unique client identifier (public key fingerprint) */
232
+ clientId: string;
233
+ /** Human-readable client name */
234
+ clientName: string;
235
+ /** Client's public key (base64) */
236
+ publicKey: string;
237
+ /** When the client was blocked (ISO 8601) */
238
+ blockedAt: string | null;
239
+ }
240
+ /**
241
+ * Pending authorization request waiting for user approval
242
+ */
243
+ interface PendingAuthorization {
244
+ /** Unique client identifier */
245
+ clientId: string;
246
+ /** Human-readable client name */
247
+ clientName: string;
248
+ /** Client's public key (base64) */
249
+ publicKey: string;
250
+ /** Requested extension ID */
251
+ extensionId: string;
252
+ }
253
+ /**
254
+ * Decision type for external authorization prompts
255
+ */
256
+ type ExternalAuthDecision = 'allow' | 'deny';
257
+ /**
258
+ * Connection state for external clients connecting to haex-vault via WebSocket.
259
+ * Used by browser extensions, CLI tools, servers, and other external clients.
260
+ */
261
+ declare enum ExternalConnectionState {
262
+ /** Not connected to haex-vault */
263
+ DISCONNECTED = "disconnected",
264
+ /** Attempting to establish connection */
265
+ CONNECTING = "connecting",
266
+ /** WebSocket connected but not yet authorized */
267
+ CONNECTED = "connected",
268
+ /** Connected and waiting for user approval in haex-vault */
269
+ PENDING_APPROVAL = "pending_approval",
270
+ /** Connected and authorized to communicate */
271
+ PAIRED = "paired"
272
+ }
273
+ /**
274
+ * Full connection status including state, client ID, and any error
275
+ */
276
+ interface ExternalConnection {
277
+ /** Current connection state */
278
+ state: ExternalConnectionState;
279
+ /** Client identifier (derived from public key) */
280
+ clientId: string | null;
281
+ /** Error message if connection failed */
282
+ error: string | null;
283
+ }
284
+ /**
285
+ * Check if external client connection state indicates an active connection
286
+ * (connected, pending approval, or paired)
287
+ */
288
+ declare function isExternalClientConnected(state: ExternalConnectionState): boolean;
289
+ /**
290
+ * Check if external client can send requests (only when paired/authorized)
291
+ */
292
+ declare function canExternalClientSendRequests(state: ExternalConnectionState): boolean;
198
293
  type EventCallback = (event: HaexHubEvent) => void;
199
294
  interface ExtensionManifest {
200
295
  name: string;
@@ -275,4 +370,4 @@ declare class HaexVaultSdkError extends Error {
275
370
  };
276
371
  }
277
372
 
278
- export { type ApplicationContext as A, type ContextChangedEvent as C, type DatabaseQueryResult as D, type ExtensionManifest as E, type HaexHubConfig as H, type Migration as M, type PermissionResponse as P, type SearchResult as S, TABLE_SEPARATOR as T, type WebRequestOptions as W, type ExtensionInfo as a, type MigrationResult as b, type WebResponse as c, type DatabasePermissionRequest as d, type ExternalRequestHandler as e, type ExternalResponse as f, type EventCallback as g, type HaexHubRequest as h, type HaexHubResponse as i, type HaexHubEvent as j, type DatabasePermission as k, type DatabaseQueryParams as l, type DatabaseExecuteParams as m, type DatabaseTableInfo as n, type DatabaseColumnInfo as o, type SearchQuery as p, type SearchRequestEvent as q, type ExternalRequestEvent as r, type ExternalRequest as s, PermissionStatus as t, ErrorCode as u, DEFAULT_TIMEOUT as v, getTableName as w, HaexVaultSdkError as x, HAEXTENSION_EVENTS as y, type HaextensionEvent as z };
373
+ export { type ApplicationContext as A, type BlockedClient as B, type ContextChangedEvent as C, type DatabaseQueryResult as D, type ExtensionManifest as E, getTableName as F, ExternalConnectionState as G, type HaexHubConfig as H, isExternalClientConnected as I, canExternalClientSendRequests as J, HaexVaultSdkError as K, HAEXTENSION_EVENTS as L, type Migration as M, type HaextensionEvent as N, EXTERNAL_EVENTS as O, type PermissionResponse as P, type ExternalEvent as Q, type SearchResult as S, TABLE_SEPARATOR as T, type WebRequestOptions as W, type ExtensionInfo as a, type MigrationResult as b, type WebResponse as c, type DatabasePermissionRequest as d, type ExternalRequestHandler as e, type ExternalResponse as f, type EventCallback as g, type HaexHubRequest as h, type HaexHubResponse as i, type HaexHubEvent as j, type DatabasePermission as k, type DatabaseQueryParams as l, type DatabaseExecuteParams as m, type DatabaseTableInfo as n, type DatabaseColumnInfo as o, type SearchQuery as p, type SearchRequestEvent as q, type ExternalRequestEvent as r, type ExternalRequest as s, type AuthorizedClient as t, type PendingAuthorization as u, type ExternalAuthDecision as v, type ExternalConnection as w, PermissionStatus as x, ErrorCode as y, DEFAULT_TIMEOUT as z };
@@ -17,10 +17,18 @@ declare const HAEXTENSION_EVENTS: {
17
17
  readonly CONTEXT_CHANGED: "haextension:context:changed";
18
18
  /** Search request from HaexHub */
19
19
  readonly SEARCH_REQUEST: "haextension:search:request";
20
- /** External request from authorized client (browser extension, CLI, server, etc.) */
21
- readonly EXTERNAL_REQUEST: "haextension:external:request";
22
20
  };
23
21
  type HaextensionEvent = typeof HAEXTENSION_EVENTS[keyof typeof HAEXTENSION_EVENTS];
22
+ /**
23
+ * Events for external client communication (browser extensions, CLI tools, servers, etc.)
24
+ */
25
+ declare const EXTERNAL_EVENTS: {
26
+ /** External request from authorized client */
27
+ readonly REQUEST: "haextension:external:request";
28
+ /** New external client requesting authorization */
29
+ readonly AUTHORIZATION_REQUEST: "external:authorization-request";
30
+ };
31
+ type ExternalEvent = typeof EXTERNAL_EVENTS[keyof typeof EXTERNAL_EVENTS];
24
32
 
25
33
  declare const DEFAULT_TIMEOUT = 30000;
26
34
  declare const TABLE_SEPARATOR = "__";
@@ -162,7 +170,7 @@ interface SearchRequestEvent extends HaexHubEvent {
162
170
  * These requests come through the WebSocket bridge and are routed to the appropriate extension.
163
171
  */
164
172
  interface ExternalRequestEvent extends HaexHubEvent {
165
- type: typeof HAEXTENSION_EVENTS.EXTERNAL_REQUEST;
173
+ type: typeof EXTERNAL_EVENTS.REQUEST;
166
174
  data: ExternalRequest;
167
175
  }
168
176
  /**
@@ -195,6 +203,93 @@ interface ExternalResponse {
195
203
  * Handler function type for external requests
196
204
  */
197
205
  type ExternalRequestHandler = (request: ExternalRequest) => Promise<ExternalResponse> | ExternalResponse;
206
+ /**
207
+ * An authorized external client stored in the database
208
+ */
209
+ interface AuthorizedClient {
210
+ /** Row ID */
211
+ id: string;
212
+ /** Unique client identifier (public key fingerprint) */
213
+ clientId: string;
214
+ /** Human-readable client name */
215
+ clientName: string;
216
+ /** Client's public key (base64) */
217
+ publicKey: string;
218
+ /** Extension ID this client can access */
219
+ extensionId: string;
220
+ /** When the client was authorized (ISO 8601) */
221
+ authorizedAt: string | null;
222
+ /** Last time the client connected (ISO 8601) */
223
+ lastSeen: string | null;
224
+ }
225
+ /**
226
+ * A blocked external client stored in the database
227
+ */
228
+ interface BlockedClient {
229
+ /** Row ID */
230
+ id: string;
231
+ /** Unique client identifier (public key fingerprint) */
232
+ clientId: string;
233
+ /** Human-readable client name */
234
+ clientName: string;
235
+ /** Client's public key (base64) */
236
+ publicKey: string;
237
+ /** When the client was blocked (ISO 8601) */
238
+ blockedAt: string | null;
239
+ }
240
+ /**
241
+ * Pending authorization request waiting for user approval
242
+ */
243
+ interface PendingAuthorization {
244
+ /** Unique client identifier */
245
+ clientId: string;
246
+ /** Human-readable client name */
247
+ clientName: string;
248
+ /** Client's public key (base64) */
249
+ publicKey: string;
250
+ /** Requested extension ID */
251
+ extensionId: string;
252
+ }
253
+ /**
254
+ * Decision type for external authorization prompts
255
+ */
256
+ type ExternalAuthDecision = 'allow' | 'deny';
257
+ /**
258
+ * Connection state for external clients connecting to haex-vault via WebSocket.
259
+ * Used by browser extensions, CLI tools, servers, and other external clients.
260
+ */
261
+ declare enum ExternalConnectionState {
262
+ /** Not connected to haex-vault */
263
+ DISCONNECTED = "disconnected",
264
+ /** Attempting to establish connection */
265
+ CONNECTING = "connecting",
266
+ /** WebSocket connected but not yet authorized */
267
+ CONNECTED = "connected",
268
+ /** Connected and waiting for user approval in haex-vault */
269
+ PENDING_APPROVAL = "pending_approval",
270
+ /** Connected and authorized to communicate */
271
+ PAIRED = "paired"
272
+ }
273
+ /**
274
+ * Full connection status including state, client ID, and any error
275
+ */
276
+ interface ExternalConnection {
277
+ /** Current connection state */
278
+ state: ExternalConnectionState;
279
+ /** Client identifier (derived from public key) */
280
+ clientId: string | null;
281
+ /** Error message if connection failed */
282
+ error: string | null;
283
+ }
284
+ /**
285
+ * Check if external client connection state indicates an active connection
286
+ * (connected, pending approval, or paired)
287
+ */
288
+ declare function isExternalClientConnected(state: ExternalConnectionState): boolean;
289
+ /**
290
+ * Check if external client can send requests (only when paired/authorized)
291
+ */
292
+ declare function canExternalClientSendRequests(state: ExternalConnectionState): boolean;
198
293
  type EventCallback = (event: HaexHubEvent) => void;
199
294
  interface ExtensionManifest {
200
295
  name: string;
@@ -275,4 +370,4 @@ declare class HaexVaultSdkError extends Error {
275
370
  };
276
371
  }
277
372
 
278
- export { type ApplicationContext as A, type ContextChangedEvent as C, type DatabaseQueryResult as D, type ExtensionManifest as E, type HaexHubConfig as H, type Migration as M, type PermissionResponse as P, type SearchResult as S, TABLE_SEPARATOR as T, type WebRequestOptions as W, type ExtensionInfo as a, type MigrationResult as b, type WebResponse as c, type DatabasePermissionRequest as d, type ExternalRequestHandler as e, type ExternalResponse as f, type EventCallback as g, type HaexHubRequest as h, type HaexHubResponse as i, type HaexHubEvent as j, type DatabasePermission as k, type DatabaseQueryParams as l, type DatabaseExecuteParams as m, type DatabaseTableInfo as n, type DatabaseColumnInfo as o, type SearchQuery as p, type SearchRequestEvent as q, type ExternalRequestEvent as r, type ExternalRequest as s, PermissionStatus as t, ErrorCode as u, DEFAULT_TIMEOUT as v, getTableName as w, HaexVaultSdkError as x, HAEXTENSION_EVENTS as y, type HaextensionEvent as z };
373
+ export { type ApplicationContext as A, type BlockedClient as B, type ContextChangedEvent as C, type DatabaseQueryResult as D, type ExtensionManifest as E, getTableName as F, ExternalConnectionState as G, type HaexHubConfig as H, isExternalClientConnected as I, canExternalClientSendRequests as J, HaexVaultSdkError as K, HAEXTENSION_EVENTS as L, type Migration as M, type HaextensionEvent as N, EXTERNAL_EVENTS as O, type PermissionResponse as P, type ExternalEvent as Q, type SearchResult as S, TABLE_SEPARATOR as T, type WebRequestOptions as W, type ExtensionInfo as a, type MigrationResult as b, type WebResponse as c, type DatabasePermissionRequest as d, type ExternalRequestHandler as e, type ExternalResponse as f, type EventCallback as g, type HaexHubRequest as h, type HaexHubResponse as i, type HaexHubEvent as j, type DatabasePermission as k, type DatabaseQueryParams as l, type DatabaseExecuteParams as m, type DatabaseTableInfo as n, type DatabaseColumnInfo as o, type SearchQuery as p, type SearchRequestEvent as q, type ExternalRequestEvent as r, type ExternalRequest as s, type AuthorizedClient as t, type PendingAuthorization as u, type ExternalAuthDecision as v, type ExternalConnection as w, PermissionStatus as x, ErrorCode as y, DEFAULT_TIMEOUT as z };
package/dist/vue.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultClient, S as StorageAPI } from './client-ClYpUDoI.mjs';
1
+ import { H as HaexVaultClient, S as StorageAPI } from './client-DTqEEmX-.mjs';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { Ref } from 'vue';
4
- import { H as HaexHubConfig } from './types-CmPqOcLB.mjs';
4
+ import { H as HaexHubConfig } from './types-Dzp3QG4t.mjs';
5
5
 
6
6
  /**
7
7
  * Vue 3 composable for HaexHub SDK
package/dist/vue.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultClient, S as StorageAPI } from './client-BSdAg7D1.js';
1
+ import { H as HaexVaultClient, S as StorageAPI } from './client-DfmTO8Mz.js';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { Ref } from 'vue';
4
- import { H as HaexHubConfig } from './types-CmPqOcLB.js';
4
+ import { H as HaexHubConfig } from './types-Dzp3QG4t.js';
5
5
 
6
6
  /**
7
7
  * Vue 3 composable for HaexHub SDK
package/dist/vue.js CHANGED
@@ -337,9 +337,7 @@ 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",
341
- /** External request from authorized client (browser extension, CLI, server, etc.) */
342
- EXTERNAL_REQUEST: "haextension:external:request"
340
+ SEARCH_REQUEST: "haextension:search:request"
343
341
  };
344
342
 
345
343
  // src/types.ts
@@ -1205,8 +1203,8 @@ var TAURI_COMMANDS = {
1205
1203
  showImage: "webview_extension_fs_show_image"
1206
1204
  },
1207
1205
  external: {
1208
- respond: "webview_extension_external_respond"
1209
- },
1206
+ // Response handling (called by extensions)
1207
+ respond: "external_respond"},
1210
1208
  filesync: {
1211
1209
  // Spaces
1212
1210
  listSpaces: "filesync_list_spaces",