@haex-space/vault-sdk 2.5.87 → 2.5.90

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/svelte.mjs CHANGED
@@ -511,6 +511,52 @@ var REMOTE_STORAGE_COMMANDS = {
511
511
  list: "extension_remote_storage_list"
512
512
  };
513
513
 
514
+ // src/commands/localsend.ts
515
+ var LOCALSEND_COMMANDS = {
516
+ // Initialization
517
+ /** Initialize LocalSend (generate identity, etc.) */
518
+ init: "localsend_init",
519
+ /** Get our device info */
520
+ getDeviceInfo: "localsend_get_device_info",
521
+ /** Set our device alias */
522
+ setAlias: "localsend_set_alias",
523
+ // Settings
524
+ /** Get current settings */
525
+ getSettings: "localsend_get_settings",
526
+ /** Update settings */
527
+ setSettings: "localsend_set_settings",
528
+ // Discovery (desktop only)
529
+ /** Start device discovery via multicast UDP */
530
+ startDiscovery: "localsend_start_discovery",
531
+ /** Stop device discovery */
532
+ stopDiscovery: "localsend_stop_discovery",
533
+ /** Get list of discovered devices */
534
+ getDevices: "localsend_get_devices",
535
+ // Network scan (mobile only)
536
+ /** Scan network for devices via HTTP */
537
+ scanNetwork: "localsend_scan_network",
538
+ // Server (receiving files)
539
+ /** Start the HTTPS server for receiving files */
540
+ startServer: "localsend_start_server",
541
+ /** Stop the HTTPS server */
542
+ stopServer: "localsend_stop_server",
543
+ /** Get server status */
544
+ getServerStatus: "localsend_get_server_status",
545
+ /** Get pending incoming transfer requests */
546
+ getPendingTransfers: "localsend_get_pending_transfers",
547
+ /** Accept an incoming transfer */
548
+ acceptTransfer: "localsend_accept_transfer",
549
+ /** Reject an incoming transfer */
550
+ rejectTransfer: "localsend_reject_transfer",
551
+ // Client (sending files)
552
+ /** Prepare files for sending - collect metadata */
553
+ prepareFiles: "localsend_prepare_files",
554
+ /** Send files to a device */
555
+ sendFiles: "localsend_send_files",
556
+ /** Cancel an outgoing transfer */
557
+ cancelSend: "localsend_cancel_send"
558
+ };
559
+
514
560
  // src/api/storage.ts
515
561
  var StorageAPI = class {
516
562
  constructor(client) {
@@ -1148,6 +1194,177 @@ var BackendManagement = class {
1148
1194
  }
1149
1195
  };
1150
1196
 
1197
+ // src/api/localsend.ts
1198
+ var LOCALSEND_EVENTS = {
1199
+ /** New device discovered */
1200
+ deviceDiscovered: "localsend:device-discovered",
1201
+ /** Device lost (no longer visible) */
1202
+ deviceLost: "localsend:device-lost",
1203
+ /** New incoming transfer request */
1204
+ transferRequest: "localsend:transfer-request",
1205
+ /** Transfer progress update */
1206
+ transferProgress: "localsend:transfer-progress",
1207
+ /** Transfer completed */
1208
+ transferComplete: "localsend:transfer-complete",
1209
+ /** Transfer failed */
1210
+ transferFailed: "localsend:transfer-failed"
1211
+ };
1212
+ var LocalSendAPI = class {
1213
+ constructor(client) {
1214
+ this.client = client;
1215
+ }
1216
+ // ==========================================================================
1217
+ // Initialization
1218
+ // ==========================================================================
1219
+ /**
1220
+ * Initialize LocalSend (generate identity, etc.)
1221
+ * Call this on app start
1222
+ * @returns Our device info
1223
+ */
1224
+ async init() {
1225
+ return this.client.request(LOCALSEND_COMMANDS.init, {});
1226
+ }
1227
+ /**
1228
+ * Get our device info
1229
+ * @returns Our device info
1230
+ */
1231
+ async getDeviceInfo() {
1232
+ return this.client.request(LOCALSEND_COMMANDS.getDeviceInfo, {});
1233
+ }
1234
+ /**
1235
+ * Set our device alias (display name)
1236
+ * @param alias New alias
1237
+ */
1238
+ async setAlias(alias) {
1239
+ await this.client.request(LOCALSEND_COMMANDS.setAlias, { alias });
1240
+ }
1241
+ // ==========================================================================
1242
+ // Settings
1243
+ // ==========================================================================
1244
+ /**
1245
+ * Get current LocalSend settings
1246
+ * @returns Settings
1247
+ */
1248
+ async getSettings() {
1249
+ return this.client.request(LOCALSEND_COMMANDS.getSettings, {});
1250
+ }
1251
+ /**
1252
+ * Update LocalSend settings
1253
+ * @param settings New settings
1254
+ */
1255
+ async setSettings(settings) {
1256
+ await this.client.request(LOCALSEND_COMMANDS.setSettings, { settings });
1257
+ }
1258
+ // ==========================================================================
1259
+ // Discovery (Desktop only - multicast UDP)
1260
+ // ==========================================================================
1261
+ /**
1262
+ * Start device discovery via multicast UDP
1263
+ * Desktop only - on mobile use scanNetwork()
1264
+ */
1265
+ async startDiscovery() {
1266
+ await this.client.request(LOCALSEND_COMMANDS.startDiscovery, {});
1267
+ }
1268
+ /**
1269
+ * Stop device discovery
1270
+ * Desktop only
1271
+ */
1272
+ async stopDiscovery() {
1273
+ await this.client.request(LOCALSEND_COMMANDS.stopDiscovery, {});
1274
+ }
1275
+ /**
1276
+ * Get list of discovered devices
1277
+ * @returns Array of discovered devices
1278
+ */
1279
+ async getDevices() {
1280
+ return this.client.request(LOCALSEND_COMMANDS.getDevices, {});
1281
+ }
1282
+ // ==========================================================================
1283
+ // Network Scan (Mobile only - HTTP)
1284
+ // ==========================================================================
1285
+ /**
1286
+ * Scan network for devices via HTTP
1287
+ * Mobile only - on desktop use startDiscovery()
1288
+ * @returns Array of discovered devices
1289
+ */
1290
+ async scanNetwork() {
1291
+ return this.client.request(LOCALSEND_COMMANDS.scanNetwork, {});
1292
+ }
1293
+ // ==========================================================================
1294
+ // Server (Receiving files)
1295
+ // ==========================================================================
1296
+ /**
1297
+ * Start the HTTPS server for receiving files
1298
+ * @param port Optional port to listen on (default: 53317)
1299
+ * @returns Server info with port, fingerprint, and addresses
1300
+ */
1301
+ async startServer(port) {
1302
+ return this.client.request(LOCALSEND_COMMANDS.startServer, { port });
1303
+ }
1304
+ /**
1305
+ * Stop the HTTPS server
1306
+ */
1307
+ async stopServer() {
1308
+ await this.client.request(LOCALSEND_COMMANDS.stopServer, {});
1309
+ }
1310
+ /**
1311
+ * Get server status
1312
+ * @returns Server status
1313
+ */
1314
+ async getServerStatus() {
1315
+ return this.client.request(LOCALSEND_COMMANDS.getServerStatus, {});
1316
+ }
1317
+ /**
1318
+ * Get pending incoming transfer requests
1319
+ * @returns Array of pending transfers
1320
+ */
1321
+ async getPendingTransfers() {
1322
+ return this.client.request(LOCALSEND_COMMANDS.getPendingTransfers, {});
1323
+ }
1324
+ /**
1325
+ * Accept an incoming transfer
1326
+ * @param sessionId Session ID of the transfer
1327
+ * @param saveDir Directory to save files to
1328
+ */
1329
+ async acceptTransfer(sessionId, saveDir) {
1330
+ await this.client.request(LOCALSEND_COMMANDS.acceptTransfer, { sessionId, saveDir });
1331
+ }
1332
+ /**
1333
+ * Reject an incoming transfer
1334
+ * @param sessionId Session ID of the transfer
1335
+ */
1336
+ async rejectTransfer(sessionId) {
1337
+ await this.client.request(LOCALSEND_COMMANDS.rejectTransfer, { sessionId });
1338
+ }
1339
+ // ==========================================================================
1340
+ // Client (Sending files)
1341
+ // ==========================================================================
1342
+ /**
1343
+ * Prepare files for sending - collect metadata
1344
+ * @param paths Array of file/folder paths to send
1345
+ * @returns Array of file info with metadata
1346
+ */
1347
+ async prepareFiles(paths) {
1348
+ return this.client.request(LOCALSEND_COMMANDS.prepareFiles, { paths });
1349
+ }
1350
+ /**
1351
+ * Send files to a device
1352
+ * @param device Target device
1353
+ * @param files Files to send (from prepareFiles)
1354
+ * @returns Session ID for tracking progress
1355
+ */
1356
+ async sendFiles(device, files) {
1357
+ return this.client.request(LOCALSEND_COMMANDS.sendFiles, { device, files });
1358
+ }
1359
+ /**
1360
+ * Cancel an outgoing transfer
1361
+ * @param sessionId Session ID of the transfer
1362
+ */
1363
+ async cancelSend(sessionId) {
1364
+ await this.client.request(LOCALSEND_COMMANDS.cancelSend, { sessionId });
1365
+ }
1366
+ };
1367
+
1151
1368
  // src/client/tableName.ts
1152
1369
  function validatePublicKey(publicKey) {
1153
1370
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1346,6 +1563,105 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1346
1563
  console.error("[HaexVault SDK] Failed to setup sync tables updated listener:", error);
1347
1564
  log("Failed to setup sync tables updated listener:", error);
1348
1565
  }
1566
+ await setupLocalSendEventListeners(log, onEvent);
1567
+ }
1568
+ async function setupLocalSendEventListeners(log, onEvent) {
1569
+ const { listen } = getTauriEvent();
1570
+ try {
1571
+ await listen(LOCALSEND_EVENTS.deviceDiscovered, (event) => {
1572
+ console.log("[HaexVault SDK] LocalSend device discovered:", event.payload);
1573
+ log("Received LocalSend device discovered event:", event);
1574
+ if (event.payload) {
1575
+ onEvent({
1576
+ type: LOCALSEND_EVENTS.deviceDiscovered,
1577
+ data: event.payload,
1578
+ timestamp: Date.now()
1579
+ });
1580
+ }
1581
+ });
1582
+ console.log("[HaexVault SDK] LocalSend device discovered listener registered");
1583
+ } catch (error) {
1584
+ console.error("[HaexVault SDK] Failed to setup LocalSend device discovered listener:", error);
1585
+ }
1586
+ try {
1587
+ await listen(LOCALSEND_EVENTS.deviceLost, (event) => {
1588
+ console.log("[HaexVault SDK] LocalSend device lost:", event.payload);
1589
+ log("Received LocalSend device lost event:", event);
1590
+ if (event.payload) {
1591
+ onEvent({
1592
+ type: LOCALSEND_EVENTS.deviceLost,
1593
+ data: event.payload,
1594
+ timestamp: Date.now()
1595
+ });
1596
+ }
1597
+ });
1598
+ console.log("[HaexVault SDK] LocalSend device lost listener registered");
1599
+ } catch (error) {
1600
+ console.error("[HaexVault SDK] Failed to setup LocalSend device lost listener:", error);
1601
+ }
1602
+ try {
1603
+ await listen(LOCALSEND_EVENTS.transferRequest, (event) => {
1604
+ console.log("[HaexVault SDK] LocalSend transfer request:", event.payload);
1605
+ log("Received LocalSend transfer request event:", event);
1606
+ if (event.payload) {
1607
+ onEvent({
1608
+ type: LOCALSEND_EVENTS.transferRequest,
1609
+ data: event.payload,
1610
+ timestamp: Date.now()
1611
+ });
1612
+ }
1613
+ });
1614
+ console.log("[HaexVault SDK] LocalSend transfer request listener registered");
1615
+ } catch (error) {
1616
+ console.error("[HaexVault SDK] Failed to setup LocalSend transfer request listener:", error);
1617
+ }
1618
+ try {
1619
+ await listen(LOCALSEND_EVENTS.transferProgress, (event) => {
1620
+ log("Received LocalSend transfer progress event:", event);
1621
+ if (event.payload) {
1622
+ onEvent({
1623
+ type: LOCALSEND_EVENTS.transferProgress,
1624
+ data: event.payload,
1625
+ timestamp: Date.now()
1626
+ });
1627
+ }
1628
+ });
1629
+ console.log("[HaexVault SDK] LocalSend transfer progress listener registered");
1630
+ } catch (error) {
1631
+ console.error("[HaexVault SDK] Failed to setup LocalSend transfer progress listener:", error);
1632
+ }
1633
+ try {
1634
+ await listen(LOCALSEND_EVENTS.transferComplete, (event) => {
1635
+ console.log("[HaexVault SDK] LocalSend transfer complete:", event.payload);
1636
+ log("Received LocalSend transfer complete event:", event);
1637
+ if (event.payload) {
1638
+ onEvent({
1639
+ type: LOCALSEND_EVENTS.transferComplete,
1640
+ data: event.payload,
1641
+ timestamp: Date.now()
1642
+ });
1643
+ }
1644
+ });
1645
+ console.log("[HaexVault SDK] LocalSend transfer complete listener registered");
1646
+ } catch (error) {
1647
+ console.error("[HaexVault SDK] Failed to setup LocalSend transfer complete listener:", error);
1648
+ }
1649
+ try {
1650
+ await listen(LOCALSEND_EVENTS.transferFailed, (event) => {
1651
+ console.log("[HaexVault SDK] LocalSend transfer failed:", event.payload);
1652
+ log("Received LocalSend transfer failed event:", event);
1653
+ if (event.payload) {
1654
+ onEvent({
1655
+ type: LOCALSEND_EVENTS.transferFailed,
1656
+ data: event.payload,
1657
+ timestamp: Date.now()
1658
+ });
1659
+ }
1660
+ });
1661
+ console.log("[HaexVault SDK] LocalSend transfer failed listener registered");
1662
+ } catch (error) {
1663
+ console.error("[HaexVault SDK] Failed to setup LocalSend transfer failed listener:", error);
1664
+ }
1349
1665
  }
1350
1666
  async function initIframeMode(ctx, log, messageHandler, request) {
1351
1667
  if (!isInIframe()) {
@@ -1679,6 +1995,7 @@ var HaexVaultSdk = class {
1679
1995
  this.web = new WebAPI(this);
1680
1996
  this.permissions = new PermissionsAPI(this);
1681
1997
  this.remoteStorage = new RemoteStorageAPI(this);
1998
+ this.localsend = new LocalSendAPI(this);
1682
1999
  installConsoleForwarding(this.config.debug);
1683
2000
  this.readyPromise = new Promise((resolve) => {
1684
2001
  this.resolveReady = resolve;