@trap_stevo/filetide 0.0.5 → 0.0.7

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.
@@ -38,11 +38,12 @@ class FileMessager {
38
38
 
39
39
  /**
40
40
  * Send file to a specific client
41
+ * @param {String} senderID - The ID of the sender (tide ID)
41
42
  * @param {String} clientId - The ID of the client (socket ID)
42
43
  * @param {Buffer} fileData - The file data to send
43
44
  * @param {String} fileName - The name of the file
44
45
  */
45
- sendFileToClient(clientId, fileData, fileName, filePath = process.cwd()) {
46
+ sendFileToClient(senderID, clientId, fileData, fileName, filePath = process.cwd()) {
46
47
  if (!this.messagerClients.has(clientId)) {
47
48
  console.log(`Client ~ ${clientId} not authorized.`);
48
49
  return;
@@ -59,9 +60,9 @@ class FileMessager {
59
60
  path: filePath
60
61
  });
61
62
  console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`);
62
- client.emit("transfer-status", {
63
+ this.fileNet.emitToTide(senderID, "transfer-status", {
63
64
  status: `[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`,
64
- receivingClientID: clientId,
65
+ recipientID: clientId,
65
66
  success: true
66
67
  });
67
68
  return;
@@ -58,19 +58,25 @@ class FileTide {
58
58
  }
59
59
  /**
60
60
  * Send a file directly to a device without it needing to create a client.
61
+ * @param {String} senderID - The ID of the client device that sent the file
61
62
  * @param {String} userID - The ID of the client device to send the file to
62
63
  * @param {Buffer} fileData - The file data to send
63
64
  * @param {String} fileName - The name of the file
64
65
  */
65
- sendFileToDevice(userID, fileData, filePath, fileName) {
66
+ sendFileToDevice(senderID, userID, fileData, filePath, fileName) {
66
67
  if (this.fileNet.onlineClients.has(userID)) {
68
+ const senderClient = this.clients[senderID];
67
69
  const currentClient = this.clients[userID];
70
+ if (!senderClient) {
71
+ console.log(`[FileTide] ~ Client ~ ${senderID} not authorized.`);
72
+ return;
73
+ }
68
74
  if (!currentClient) {
69
75
  console.log(`[FileTide] ~ Client ~ ${userID} not authorized.`);
70
76
  return;
71
77
  }
72
78
  console.log(`[FileTide] ~ Sending file to client ~ ${userID}...`);
73
- this.fileNet.sendFileToClient(currentClient.id, fileData, filePath, fileName);
79
+ this.fileNet.sendFileToClient(senderClient.tideID, currentClient.id, fileData, filePath, fileName);
74
80
  console.log(`[FileTide] ~ File sent to client ~ ${userID}!`);
75
81
  return;
76
82
  }
@@ -151,8 +157,4 @@ function _setupFileEventListeners(userID, client, onIncomingFile) {
151
157
  return;
152
158
  }
153
159
  ;
154
- const fileT = new FileTide();
155
- fileT.launchFileTide({
156
- port: 8869
157
- });
158
160
  module.exports = FileTide;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities with a tool designed for precision, efficiency, and effortless connectivity.",
5
5
  "main": "dist/cjs/FileTide.js",
6
6
  "scripts": {