@trap_stevo/filetide 0.0.62 → 0.0.64
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/cjs/FileMessager.js +622 -17
- package/dist/cjs/FileMessagerClient.js +9 -4
- package/dist/cjs/FileTide.js +55 -1
- package/dist/cjs/HUDManagers/TidalyticsInstanceManager.js +69 -0
- package/dist/cjs/HUDManagers/TidalyticsManager.js +9 -0
- package/dist/cjs/HUDManagers/TideSentinelManager.js +143 -0
- package/package.json +5 -3
- package/transfer_states/FileNetServer_FileNetClient_-Documents-TestFileTideDropZone-TidalCore.txt.json +7 -0
package/dist/cjs/FileMessager.js
CHANGED
|
@@ -19,7 +19,11 @@ const {
|
|
|
19
19
|
const {
|
|
20
20
|
FileTransferManager
|
|
21
21
|
} = require("./HUDManagers/FileTransferManager");
|
|
22
|
+
const TideSentinelManager = require("./HUDManagers/TideSentinelManager");
|
|
22
23
|
const HUDTargetQueue = require("./HUDManagers/HUDTargetQueueManager");
|
|
24
|
+
const {
|
|
25
|
+
tidalytics
|
|
26
|
+
} = require("./HUDManagers/TidalyticsManager");
|
|
23
27
|
var _FileMessager_brand = /*#__PURE__*/new WeakSet();
|
|
24
28
|
class FileMessager {
|
|
25
29
|
constructor(options = {
|
|
@@ -28,7 +32,7 @@ class FileMessager {
|
|
|
28
32
|
}, transportOptions = {
|
|
29
33
|
parallelChunks: 3,
|
|
30
34
|
maxRetries: 3
|
|
31
|
-
}, debugMode = false) {
|
|
35
|
+
}, onTideAction = null, debugMode = false, tideSentinelOptions = {}) {
|
|
32
36
|
_classPrivateMethodInitSpec(this, _FileMessager_brand);
|
|
33
37
|
const serverOptions = FileMessagerConfigManager.getServerOptions(options);
|
|
34
38
|
this.transporter = new FileTransferManager(transportOptions);
|
|
@@ -36,9 +40,15 @@ class FileMessager {
|
|
|
36
40
|
this.currentTransferBarrierTransfers = new Map();
|
|
37
41
|
this.clientTransferBarriers = new Map();
|
|
38
42
|
this.currentTidingTransfers = new Map();
|
|
43
|
+
this.tideSentinel = new TideSentinelManager(tideSentinelOptions);
|
|
44
|
+
this.tideSentinel.registerEntryAddedHook((key, entryData) => {
|
|
45
|
+
console.log(key, entryData);
|
|
46
|
+
});
|
|
39
47
|
this.fileNet = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
40
48
|
this.onlineClients = new OmniMap();
|
|
49
|
+
this.onTideAction = onTideAction ?? (() => {});
|
|
41
50
|
this.debugMode = debugMode;
|
|
51
|
+
this.tideSentinelOptions = tideSentinelOptions;
|
|
42
52
|
this.transporterOptions = transportOptions;
|
|
43
53
|
this.options = serverOptions;
|
|
44
54
|
return;
|
|
@@ -72,6 +82,7 @@ class FileMessager {
|
|
|
72
82
|
this.fileNet.on("transfer-complete", this.handleFileTransferComplete.bind(this));
|
|
73
83
|
this.fileNet.on("request-transfer-from-client", this.handleRequestTransferFromClient.bind(this));
|
|
74
84
|
this.fileNet.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
|
|
85
|
+
this.fileNet.on("check-client-banned", this.handleCheckClientBanned.bind(this));
|
|
75
86
|
this.fileNet.on("check-client-online", this.handleCheckClientOnline.bind(this));
|
|
76
87
|
this.fileNet.on("client-offline", this.handleClientOffline.bind(this));
|
|
77
88
|
this.fileNet.on("clients-online", this.handleClientsOnline.bind(this));
|
|
@@ -79,6 +90,140 @@ class FileMessager {
|
|
|
79
90
|
this.fileNet.on("client-tiding", this.handleClientTiding.bind(this));
|
|
80
91
|
return;
|
|
81
92
|
}
|
|
93
|
+
|
|
94
|
+
// --- File Messager Tidalytics Management ---
|
|
95
|
+
|
|
96
|
+
async getTidalyticsSince(interval = "1d", source = "storage", filter = {}) {
|
|
97
|
+
return await tidalytics.getMetricsSince(interval, source, filter);
|
|
98
|
+
}
|
|
99
|
+
async getStoredTidalytics(filter = {}) {
|
|
100
|
+
return await tidalytics.getStoredMetrics(filter);
|
|
101
|
+
}
|
|
102
|
+
async getTidalyticsInDomain(domain, options = {}) {
|
|
103
|
+
return await tidalytics.getMetricsInDomain(domain, options);
|
|
104
|
+
}
|
|
105
|
+
getTidalytics(filter = {}) {
|
|
106
|
+
return tidalytics.getMetrics(filter);
|
|
107
|
+
}
|
|
108
|
+
getTidalyticByID(id) {
|
|
109
|
+
return tidalytics.getMetricByID(id);
|
|
110
|
+
}
|
|
111
|
+
searchTidalyticByTagValue(key, match) {
|
|
112
|
+
return tidalytics.searchByTagValue(key, match);
|
|
113
|
+
}
|
|
114
|
+
getTidalyticAggregate(name) {
|
|
115
|
+
return tidalytics.getAggregate(name);
|
|
116
|
+
}
|
|
117
|
+
getTidalyticAggregateByType(type) {
|
|
118
|
+
return tidalytics.getAggregateByType(type);
|
|
119
|
+
}
|
|
120
|
+
groupTidalyticByTag(tagKey) {
|
|
121
|
+
return tidalytics.groupByTag(tagKey);
|
|
122
|
+
}
|
|
123
|
+
getTidalyticTimeSeries(name, options = {}) {
|
|
124
|
+
return tidalytics.getTimeSeries(name, options);
|
|
125
|
+
}
|
|
126
|
+
predictTidalytic(name, config = {}) {
|
|
127
|
+
return tidalytics.predictMetric(name, config);
|
|
128
|
+
}
|
|
129
|
+
async clearTidalytics(domain, options = {}) {
|
|
130
|
+
return await tidalytics.clearMetricsInDomain(domain, options);
|
|
131
|
+
}
|
|
132
|
+
clearAllTidalytics() {
|
|
133
|
+
return tidalytics.clearAllMetrics();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// --- File Messager Tide Sentinel Management ---
|
|
137
|
+
|
|
138
|
+
banClient(clientID, options = {}) {
|
|
139
|
+
const result = this.tideSentinel.banClient(clientID, options);
|
|
140
|
+
tidalytics.track("tider:banned", {
|
|
141
|
+
value: 1,
|
|
142
|
+
tags: {
|
|
143
|
+
"tider:banned": "tider:banned",
|
|
144
|
+
"tider": "tider",
|
|
145
|
+
clientID
|
|
146
|
+
},
|
|
147
|
+
metadata: {
|
|
148
|
+
clientID,
|
|
149
|
+
options
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this.onTideAction({
|
|
153
|
+
tideActionID: "ban-client-activated",
|
|
154
|
+
tideActionDate: Date.now(),
|
|
155
|
+
tideActionDetails: {
|
|
156
|
+
clientID,
|
|
157
|
+
options
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
unbanClient(clientID) {
|
|
163
|
+
const result = this.tideSentinel.unbanClient(clientID);
|
|
164
|
+
tidalytics.track("tider:unbanned", {
|
|
165
|
+
value: 1,
|
|
166
|
+
tags: {
|
|
167
|
+
"tider:unbanned": "tider:unbanned",
|
|
168
|
+
"tider": "tider",
|
|
169
|
+
clientID
|
|
170
|
+
},
|
|
171
|
+
metadata: {
|
|
172
|
+
clientID
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
this.onTideAction({
|
|
176
|
+
tideActionID: "unban-client-activated",
|
|
177
|
+
tideActionDate: Date.now(),
|
|
178
|
+
tideActionDetails: {
|
|
179
|
+
clientID
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
clientBanned(clientID) {
|
|
185
|
+
const result = this.tideSentinel.clientBanned(clientID);
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
getBanEntry(clientID) {
|
|
189
|
+
const result = this.tideSentinel.getBanEntry(clientID);
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
filterBannedClients(filter = {}) {
|
|
193
|
+
const result = this.tideSentinel.filterBannedClients(filter);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
registerTideSentinelExpireHook(list, callback) {
|
|
197
|
+
const result = this.tideSentinel.registerExpireHook(list, callback);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
addToTideList(list, key, data) {
|
|
201
|
+
const result = this.tideSentinel.addToList(list, key, data);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
removeFromTideList(list, key) {
|
|
205
|
+
const result = this.tideSentinel.removeFromList(list, key);
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
inTideList(list, key) {
|
|
209
|
+
const result = this.tideSentinel.inList(list, key);
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
getEntry(list, key) {
|
|
213
|
+
const result = this.tideSentinel.getEntry(list, key);
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
filterTideList(list, filter = {}) {
|
|
217
|
+
const result = this.tideSentinel.filterList(list, filter);
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
findSimilarKeys(keyword, options = {}) {
|
|
221
|
+
const result = this.tideSentinel.findSimilarKeys(keyword, options);
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// --- File Messager Client Management ---
|
|
226
|
+
|
|
82
227
|
getClientFromID(clientID) {
|
|
83
228
|
const client = this.onlineClients.get(clientID);
|
|
84
229
|
if (!client) {
|
|
@@ -126,6 +271,40 @@ class FileMessager {
|
|
|
126
271
|
path: filePath,
|
|
127
272
|
fileSize
|
|
128
273
|
});
|
|
274
|
+
tidalytics.track("tide:incoming-file", {
|
|
275
|
+
value: 1,
|
|
276
|
+
tags: {
|
|
277
|
+
"tide:incoming-file": "tide:incoming-file",
|
|
278
|
+
"tide": "tide",
|
|
279
|
+
recipientID: clientData.userID,
|
|
280
|
+
senderID: senderData.userID,
|
|
281
|
+
path: filePath,
|
|
282
|
+
fileSize,
|
|
283
|
+
fileName
|
|
284
|
+
},
|
|
285
|
+
metadata: {
|
|
286
|
+
recipientID: clientData.userID,
|
|
287
|
+
senderID: senderData.userID,
|
|
288
|
+
path: filePath,
|
|
289
|
+
fileSize,
|
|
290
|
+
fileName,
|
|
291
|
+
totalChunks,
|
|
292
|
+
chunkSize
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
this.onTideAction({
|
|
296
|
+
tideActionID: "tide-incoming-file",
|
|
297
|
+
tideActionDate: Date.now(),
|
|
298
|
+
tideActionDetails: {
|
|
299
|
+
recipientID: clientData.userID,
|
|
300
|
+
senderID: senderData.userID,
|
|
301
|
+
path: filePath,
|
|
302
|
+
fileSize,
|
|
303
|
+
fileName,
|
|
304
|
+
totalChunks,
|
|
305
|
+
chunkSize
|
|
306
|
+
}
|
|
307
|
+
});
|
|
129
308
|
}
|
|
130
309
|
this.fileNet.emitToTide(client.tideID, "transfer-progress", {
|
|
131
310
|
senderName: senderData.userID,
|
|
@@ -154,6 +333,24 @@ class FileMessager {
|
|
|
154
333
|
});
|
|
155
334
|
}
|
|
156
335
|
}
|
|
336
|
+
saveClientTransferStates(data) {
|
|
337
|
+
const tidingTransfers = this.currentTidingTransfers.get(data.clientID);
|
|
338
|
+
if (tidingTransfers && tidingTransfers.size > 0) {
|
|
339
|
+
for (let recipientID of tidingTransfers.keys()) {
|
|
340
|
+
const recipientConnectionID = FileNetClientManager.getOnlineClient(data.recipientID ?? recipientID).id;
|
|
341
|
+
const client = this.getClientFromID(recipientConnectionID);
|
|
342
|
+
if (client) {
|
|
343
|
+
this.fileNet.emitToTide(client.tideID, "save-current-transfer-states", {
|
|
344
|
+
clientID: recipientID
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
this.currentTidingTransfers.delete(data.clientID);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// --- File Messager Event Management ---
|
|
353
|
+
|
|
157
354
|
handleRequestTransferFromClient(senderTide, transferData) {
|
|
158
355
|
const {
|
|
159
356
|
requesterID,
|
|
@@ -183,6 +380,33 @@ class FileMessager {
|
|
|
183
380
|
totalItemsSent,
|
|
184
381
|
runningOn
|
|
185
382
|
});
|
|
383
|
+
tidalytics.track("file-list:received", {
|
|
384
|
+
value: 1,
|
|
385
|
+
tags: {
|
|
386
|
+
"file-list:received": "file-list:received",
|
|
387
|
+
"file-list": "file-list",
|
|
388
|
+
recipientID,
|
|
389
|
+
senderID,
|
|
390
|
+
totalItems: totalItemsSent,
|
|
391
|
+
runningOn
|
|
392
|
+
},
|
|
393
|
+
metadata: {
|
|
394
|
+
recipientID,
|
|
395
|
+
senderID,
|
|
396
|
+
totalItems: totalItemsSent,
|
|
397
|
+
runningOn
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
this.onTideAction({
|
|
401
|
+
tideActionID: "file-list-received",
|
|
402
|
+
tideActionDate: Date.now(),
|
|
403
|
+
tideActionDetails: {
|
|
404
|
+
recipientID,
|
|
405
|
+
senderID,
|
|
406
|
+
totalItems: totalItemsSent,
|
|
407
|
+
runningOn
|
|
408
|
+
}
|
|
409
|
+
});
|
|
186
410
|
} catch (error) {
|
|
187
411
|
console.error(`[FileTide ~ Net Scanner] ~ `, error);
|
|
188
412
|
return;
|
|
@@ -234,6 +458,30 @@ class FileMessager {
|
|
|
234
458
|
recipientID,
|
|
235
459
|
depth
|
|
236
460
|
});
|
|
461
|
+
tidalytics.track("file-list:request", {
|
|
462
|
+
value: 1,
|
|
463
|
+
tags: {
|
|
464
|
+
"file-list:request": "file-list:request",
|
|
465
|
+
"file-list": "file-list",
|
|
466
|
+
recipientID,
|
|
467
|
+
requesterID,
|
|
468
|
+
depth
|
|
469
|
+
},
|
|
470
|
+
metadata: {
|
|
471
|
+
recipientID,
|
|
472
|
+
requesterID,
|
|
473
|
+
depth
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
this.onTideAction({
|
|
477
|
+
tideActionID: "file-list-request",
|
|
478
|
+
tideActionDate: Date.now(),
|
|
479
|
+
tideActionDetails: {
|
|
480
|
+
recipientID,
|
|
481
|
+
requesterID,
|
|
482
|
+
depth
|
|
483
|
+
}
|
|
484
|
+
});
|
|
237
485
|
} catch (error) {
|
|
238
486
|
console.error(`[FileTide ~ Net Scanner] ~ `, error);
|
|
239
487
|
return;
|
|
@@ -281,6 +529,42 @@ class FileMessager {
|
|
|
281
529
|
fileName,
|
|
282
530
|
filePath
|
|
283
531
|
});
|
|
532
|
+
tidalytics.track("tide:completed-transfer", {
|
|
533
|
+
value: 1,
|
|
534
|
+
tags: {
|
|
535
|
+
"tide:completed-transfer": "tide:completed-transfer",
|
|
536
|
+
"tide": "tide",
|
|
537
|
+
recipientID: recipientId,
|
|
538
|
+
senderID,
|
|
539
|
+
path: filePath,
|
|
540
|
+
fileSize,
|
|
541
|
+
fileName
|
|
542
|
+
},
|
|
543
|
+
metadata: {
|
|
544
|
+
recipientID: recipientId,
|
|
545
|
+
senderID,
|
|
546
|
+
path: filePath,
|
|
547
|
+
fileSize,
|
|
548
|
+
fileName,
|
|
549
|
+
completedChunks,
|
|
550
|
+
totalChunks,
|
|
551
|
+
chunkSize
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
this.onTideAction({
|
|
555
|
+
tideActionID: "tide-completed-transfer",
|
|
556
|
+
tideActionDate: Date.now(),
|
|
557
|
+
tideActionDetails: {
|
|
558
|
+
recipientID: recipientId,
|
|
559
|
+
senderID,
|
|
560
|
+
path: filePath,
|
|
561
|
+
fileSize,
|
|
562
|
+
fileName,
|
|
563
|
+
completedChunks,
|
|
564
|
+
totalChunks,
|
|
565
|
+
chunkSize
|
|
566
|
+
}
|
|
567
|
+
});
|
|
284
568
|
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
285
569
|
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
286
570
|
if (tidingTransfers) {
|
|
@@ -325,6 +609,42 @@ class FileMessager {
|
|
|
325
609
|
fileName,
|
|
326
610
|
filePath
|
|
327
611
|
});
|
|
612
|
+
tidalytics.track("tide:completed-transfer", {
|
|
613
|
+
value: 1,
|
|
614
|
+
tags: {
|
|
615
|
+
"tide:completed-transfer": "tide:completed-transfer",
|
|
616
|
+
"tide": "tide",
|
|
617
|
+
recipientID: recipientId,
|
|
618
|
+
senderID,
|
|
619
|
+
path: filePath,
|
|
620
|
+
fileSize,
|
|
621
|
+
fileName
|
|
622
|
+
},
|
|
623
|
+
metadata: {
|
|
624
|
+
recipientID: recipientId,
|
|
625
|
+
senderID,
|
|
626
|
+
path: filePath,
|
|
627
|
+
fileSize,
|
|
628
|
+
fileName,
|
|
629
|
+
completedChunks,
|
|
630
|
+
totalChunks,
|
|
631
|
+
chunkSize
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
this.onTideAction({
|
|
635
|
+
tideActionID: "tide-completed-transfer",
|
|
636
|
+
tideActionDate: Date.now(),
|
|
637
|
+
tideActionDetails: {
|
|
638
|
+
recipientID: recipientId,
|
|
639
|
+
senderID,
|
|
640
|
+
path: filePath,
|
|
641
|
+
fileSize,
|
|
642
|
+
fileName,
|
|
643
|
+
completedChunks,
|
|
644
|
+
totalChunks,
|
|
645
|
+
chunkSize
|
|
646
|
+
}
|
|
647
|
+
});
|
|
328
648
|
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
329
649
|
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
330
650
|
if (tidingTransfers) {
|
|
@@ -356,12 +676,92 @@ class FileMessager {
|
|
|
356
676
|
this.fileNet.emitToTide(senderClient.tideID, "transfer-barrier-response", accepted);
|
|
357
677
|
this.currentTransferBarrierTransfers.delete(data.transferID);
|
|
358
678
|
if (accepted) {
|
|
679
|
+
tidalytics.track("tide-barrier:accepted", {
|
|
680
|
+
value: 1,
|
|
681
|
+
tags: {
|
|
682
|
+
"tide-barrier:accepted": "tide-barrier:accepted",
|
|
683
|
+
"tide-barrier": "tide-barrier",
|
|
684
|
+
recipientID: data.recipientID,
|
|
685
|
+
transferID: data.transferID,
|
|
686
|
+
senderID: data.clientID,
|
|
687
|
+
tideTransferType: data.transferType,
|
|
688
|
+
tideDestinationPath: data.path,
|
|
689
|
+
tideOriginPath: data.originPath,
|
|
690
|
+
tideItemSize: data.itemSize
|
|
691
|
+
},
|
|
692
|
+
metadata: {
|
|
693
|
+
recipientID: data.recipientID,
|
|
694
|
+
transferID: data.transferID,
|
|
695
|
+
senderID: data.clientID,
|
|
696
|
+
tideItemCount: data.itemCount,
|
|
697
|
+
tideItemSize: data.itemSize,
|
|
698
|
+
tideTransferContentType: data.transferContentType,
|
|
699
|
+
tideTransferType: data.transferType,
|
|
700
|
+
tideDestinationPath: data.path,
|
|
701
|
+
tideOriginPath: data.originPath
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
this.onTideAction({
|
|
705
|
+
tideActionID: "tide-barrier-accepted",
|
|
706
|
+
tideActionDate: Date.now(),
|
|
707
|
+
tideActionDetails: {
|
|
708
|
+
recipientID: data.recipientID,
|
|
709
|
+
transferID: data.transferID,
|
|
710
|
+
senderID: data.clientID,
|
|
711
|
+
tideItemCount: data.itemCount,
|
|
712
|
+
tideItemSize: data.itemSize,
|
|
713
|
+
tideTransferContentType: data.transferContentType,
|
|
714
|
+
tideTransferType: data.transferType,
|
|
715
|
+
tideDestinationPath: data.path,
|
|
716
|
+
tideOriginPath: data.originPath
|
|
717
|
+
}
|
|
718
|
+
});
|
|
359
719
|
this.fileNet.emitToTide(client.tideID, "accepted-transfer", {
|
|
360
720
|
accepted,
|
|
361
721
|
...data
|
|
362
722
|
});
|
|
363
723
|
return;
|
|
364
724
|
}
|
|
725
|
+
tidalytics.track("tide-barrier:denied", {
|
|
726
|
+
value: 1,
|
|
727
|
+
tags: {
|
|
728
|
+
"tide-barrier:denied": "tide-barrier:denied",
|
|
729
|
+
"tide-barrier": "tide-barrier",
|
|
730
|
+
recipientID: data.recipientID,
|
|
731
|
+
transferID: data.transferID,
|
|
732
|
+
senderID: data.clientID,
|
|
733
|
+
tideTransferType: data.transferType,
|
|
734
|
+
tideDestinationPath: data.path,
|
|
735
|
+
tideOriginPath: data.originPath,
|
|
736
|
+
tideItemSize: data.itemSize
|
|
737
|
+
},
|
|
738
|
+
metadata: {
|
|
739
|
+
recipientID: data.recipientID,
|
|
740
|
+
transferID: data.transferID,
|
|
741
|
+
senderID: data.clientID,
|
|
742
|
+
tideItemCount: data.itemCount,
|
|
743
|
+
tideItemSize: data.itemSize,
|
|
744
|
+
tideTransferContentType: data.transferContentType,
|
|
745
|
+
tideTransferType: data.transferType,
|
|
746
|
+
tideDestinationPath: data.path,
|
|
747
|
+
tideOriginPath: data.originPath
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
this.onTideAction({
|
|
751
|
+
tideActionID: "tide-barrier-denied",
|
|
752
|
+
tideActionDate: Date.now(),
|
|
753
|
+
tideActionDetails: {
|
|
754
|
+
recipientID: data.recipientID,
|
|
755
|
+
transferID: data.transferID,
|
|
756
|
+
senderID: data.clientID,
|
|
757
|
+
tideItemCount: data.itemCount,
|
|
758
|
+
tideItemSize: data.itemSize,
|
|
759
|
+
tideTransferContentType: data.transferContentType,
|
|
760
|
+
tideTransferType: data.transferType,
|
|
761
|
+
tideDestinationPath: data.path,
|
|
762
|
+
tideOriginPath: data.originPath
|
|
763
|
+
}
|
|
764
|
+
});
|
|
365
765
|
this.fileNet.emitToTide(client.tideID, "denied-transfer", {
|
|
366
766
|
accepted,
|
|
367
767
|
...data
|
|
@@ -430,7 +830,58 @@ class FileMessager {
|
|
|
430
830
|
}
|
|
431
831
|
handleAcknowledgeTransferTide(senderTide, data) {
|
|
432
832
|
try {
|
|
433
|
-
|
|
833
|
+
const transferETA = data.transferStats.timeLeft <= 0 ? "Now" : FileNetUtilityManager.convertSeconds(data.transferStats.timeLeft !== null && data.transferStats.timeLeft !== undefined ? data.transferStats.timeLeft.toFixed(2) : Infinity);
|
|
834
|
+
const transferProgress = data.transferStats.progress !== null && data.transferStats.progress !== undefined ? data.transferStats.progress.toFixed(2) : "N/A";
|
|
835
|
+
const currentTransferredSize = FileNetUtilityManager.getFormattedSize(data.transferStats.current, true);
|
|
836
|
+
const transferSize = FileNetUtilityManager.getFormattedSize(data.transferStats.totalSize, true);
|
|
837
|
+
const transferSpeed = FileNetUtilityManager.getFormattedSize(data.transferStats.speed, true);
|
|
838
|
+
const transferStartTime = data.transferStats.startTime;
|
|
839
|
+
const fileName = data.fileName;
|
|
840
|
+
console.log(`[FileTide ~ Net Activity] ~ ${data.recipientName} acknowledged tide transfer from ${data.senderName}.\n\n\t~ [${fileName}-${transferStartTime}] ~\n\n\t\tFile Name ~ ${fileName}\n\t\tDestination ~ ${data.path}\n\n\t\t\tProgress ~ ${transferProgress}%\n\t\t\tETA ~ ${transferETA}\n\t\t\tSpeed ~ ${transferSpeed}/s\n\t\t\tSize ~ ${transferSize}\n\t\t\tTransferred ~ ${currentTransferredSize}\n`);
|
|
841
|
+
tidalytics.track("tide:transfer-state", {
|
|
842
|
+
value: 1,
|
|
843
|
+
tags: {
|
|
844
|
+
"tide:transfer-state": "tide:transfer-state",
|
|
845
|
+
"tide": "tide",
|
|
846
|
+
transferStateID: data.transferStateID,
|
|
847
|
+
recipientID: data.recipientName,
|
|
848
|
+
senderID: data.senderName,
|
|
849
|
+
path: data.path,
|
|
850
|
+
startTime: transferStartTime,
|
|
851
|
+
transferSize,
|
|
852
|
+
fileName
|
|
853
|
+
},
|
|
854
|
+
metadata: {
|
|
855
|
+
transferStateID: data.transferStateID,
|
|
856
|
+
recipientID: data.recipientName,
|
|
857
|
+
senderID: data.senderName,
|
|
858
|
+
path: data.path,
|
|
859
|
+
startTime: transferStartTime,
|
|
860
|
+
currentTransferredSize,
|
|
861
|
+
speed: transferSpeed,
|
|
862
|
+
transferProgress,
|
|
863
|
+
transferSize,
|
|
864
|
+
transferETA,
|
|
865
|
+
fileName
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
this.onTideAction({
|
|
869
|
+
tideActionID: "tide-transfer-state",
|
|
870
|
+
tideActionDate: Date.now(),
|
|
871
|
+
tideActionDetails: {
|
|
872
|
+
transferStateID: data.transferStateID,
|
|
873
|
+
recipientID: data.recipientName,
|
|
874
|
+
senderID: data.senderName,
|
|
875
|
+
path: data.path,
|
|
876
|
+
startTime: transferStartTime,
|
|
877
|
+
currentTransferredSize,
|
|
878
|
+
speed: transferSpeed,
|
|
879
|
+
transferProgress,
|
|
880
|
+
transferSize,
|
|
881
|
+
transferETA,
|
|
882
|
+
fileName
|
|
883
|
+
}
|
|
884
|
+
});
|
|
434
885
|
} catch (error) {
|
|
435
886
|
console.error(`[FileTide ~ Net Activity] ~ ${data.recipientName} acknowledged tide transfer from ${data.senderName}.\n\n${error}`);
|
|
436
887
|
}
|
|
@@ -455,11 +906,45 @@ class FileMessager {
|
|
|
455
906
|
...data,
|
|
456
907
|
currentSender: data.senderID
|
|
457
908
|
});
|
|
909
|
+
const now = new Date();
|
|
910
|
+
tidalytics.track("tide:incoming-transfer", {
|
|
911
|
+
value: 1,
|
|
912
|
+
tags: {
|
|
913
|
+
"tide:incoming-transfer": "tide:incoming-transfer",
|
|
914
|
+
"tide": "tide",
|
|
915
|
+
recipientID: data.recipientID,
|
|
916
|
+
senderID: data.senderID,
|
|
917
|
+
fileSize: data.fileSize,
|
|
918
|
+
fileName: data.fileName,
|
|
919
|
+
path: data.path,
|
|
920
|
+
startedOn: now
|
|
921
|
+
},
|
|
922
|
+
metadata: {
|
|
923
|
+
recipientID: data.recipientID,
|
|
924
|
+
senderID: data.senderID,
|
|
925
|
+
fileSize: data.fileSize,
|
|
926
|
+
fileName: data.fileName,
|
|
927
|
+
path: data.path,
|
|
928
|
+
startedOn: now
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
this.onTideAction({
|
|
932
|
+
tideActionID: "tide-incoming-transfer",
|
|
933
|
+
tideActionDate: Date.now(),
|
|
934
|
+
tideActionDetails: {
|
|
935
|
+
recipientID: data.recipientID,
|
|
936
|
+
senderID: data.senderID,
|
|
937
|
+
fileSize: data.fileSize,
|
|
938
|
+
fileName: data.fileName,
|
|
939
|
+
path: data.path,
|
|
940
|
+
startedOn: now
|
|
941
|
+
}
|
|
942
|
+
});
|
|
458
943
|
if (!this.currentTidingTransfers.get(data.senderID) || this.currentTidingTransfers.get(data.senderID).length <= 0) {
|
|
459
944
|
const tidingTransfers = new Map();
|
|
460
945
|
tidingTransfers.set(data.recipientID, {
|
|
461
946
|
recipientID: data.recipientID,
|
|
462
|
-
startedOn:
|
|
947
|
+
startedOn: now,
|
|
463
948
|
size: data.fileSize,
|
|
464
949
|
path: data.path
|
|
465
950
|
});
|
|
@@ -468,7 +953,7 @@ class FileMessager {
|
|
|
468
953
|
}
|
|
469
954
|
this.currentTidingTransfers.get(data.senderID).set(data.recipientID, {
|
|
470
955
|
recipientID: data.recipientID,
|
|
471
|
-
startedOn:
|
|
956
|
+
startedOn: now,
|
|
472
957
|
size: data.fileSize,
|
|
473
958
|
path: data.path
|
|
474
959
|
});
|
|
@@ -483,6 +968,40 @@ class FileMessager {
|
|
|
483
968
|
handleFileTransferComplete(senderTide, data) {
|
|
484
969
|
console.log(`File transfer completed: ${data.fileName}`);
|
|
485
970
|
}
|
|
971
|
+
async handleCheckClientBanned(senderTide, data) {
|
|
972
|
+
console.log(`[FileTide ~ Net Activity] ~ Checking if client ~ ${data.clientID} banned...`);
|
|
973
|
+
try {
|
|
974
|
+
const clientBanned = await this.clientBanned(data.tideID);
|
|
975
|
+
if (!clientBanned) {
|
|
976
|
+
console.log(`[FileTide ~ Net Activity] ~ Client ~ ${data.clientID} access authorized!`);
|
|
977
|
+
this.fileNet.emit("retrieved-client-banned", {
|
|
978
|
+
banned: false,
|
|
979
|
+
clientID: data.clientID,
|
|
980
|
+
tideID: data.tideID,
|
|
981
|
+
bannedDetails: null
|
|
982
|
+
});
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
console.log(`[FileTide ~ Net Activity] ~ Client ~ ${data.clientID} banned.`);
|
|
986
|
+
const bannedClientDetails = await this.getBanEntry(data.tideID);
|
|
987
|
+
FileNetClientManager.clearOnlineClient(data.clientID);
|
|
988
|
+
this.saveClientTransferStates(data);
|
|
989
|
+
this.fileNet.emit("retrieved-client-banned", {
|
|
990
|
+
banned: true,
|
|
991
|
+
clientID: data.clientID,
|
|
992
|
+
tideID: data.tideID,
|
|
993
|
+
bannedDetails: bannedClientDetails
|
|
994
|
+
});
|
|
995
|
+
} catch (error) {
|
|
996
|
+
this.fileNet.emit("retrieved-client-banned", {
|
|
997
|
+
banned: false,
|
|
998
|
+
clientID: data.clientID,
|
|
999
|
+
tideID: data.tideID,
|
|
1000
|
+
bannedDetails: null
|
|
1001
|
+
});
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
486
1005
|
handleCheckClientOnline(senderTide, data) {
|
|
487
1006
|
console.log(`[FileTide ~ Net Activity] ~ Checking if client ~ ${data.clientID} online...`);
|
|
488
1007
|
try {
|
|
@@ -530,6 +1049,40 @@ class FileMessager {
|
|
|
530
1049
|
const currentClientID = clientID;
|
|
531
1050
|
clientID = nClientID;
|
|
532
1051
|
this.fileNet.emitToTide(tideID, "current-client-id-already-online", clientID);
|
|
1052
|
+
tidalytics.track("tider:already-online", {
|
|
1053
|
+
value: 1,
|
|
1054
|
+
tags: {
|
|
1055
|
+
"tider:already-online": "tider:already-online",
|
|
1056
|
+
"tider": "tider",
|
|
1057
|
+
originUser: originClientID,
|
|
1058
|
+
pUser: currentClientID,
|
|
1059
|
+
user: nClientID,
|
|
1060
|
+
tideID: senderTide.tideID,
|
|
1061
|
+
connectedOn: Date.now()
|
|
1062
|
+
},
|
|
1063
|
+
metadata: {
|
|
1064
|
+
currentTideChannel: currentTideChannel || "file-room",
|
|
1065
|
+
originUser: originClientID,
|
|
1066
|
+
user: nClientID,
|
|
1067
|
+
connectionID,
|
|
1068
|
+
pClientID: currentClientID,
|
|
1069
|
+
tideID: senderTide.tideID,
|
|
1070
|
+
connectedOn: Date.now()
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
this.onTideAction({
|
|
1074
|
+
tideActionID: "tider-already-online",
|
|
1075
|
+
tideActionDate: Date.now(),
|
|
1076
|
+
tideActionDetails: {
|
|
1077
|
+
currentTideChannel: currentTideChannel || "file-room",
|
|
1078
|
+
originUser: originClientID,
|
|
1079
|
+
user: nClientID,
|
|
1080
|
+
connectionID,
|
|
1081
|
+
pClientID: currentClientID,
|
|
1082
|
+
tideID: senderTide.tideID,
|
|
1083
|
+
connectedOn: Date.now()
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
533
1086
|
FileNetClientManager.updateOnlineClient(nClientID, {
|
|
534
1087
|
pClientID: currentClientID,
|
|
535
1088
|
clientID: nClientID,
|
|
@@ -541,6 +1094,38 @@ class FileMessager {
|
|
|
541
1094
|
});
|
|
542
1095
|
return;
|
|
543
1096
|
}
|
|
1097
|
+
tidalytics.track("tider:online", {
|
|
1098
|
+
value: 1,
|
|
1099
|
+
tags: {
|
|
1100
|
+
"tider:online": "tider:online",
|
|
1101
|
+
"tider": "tider",
|
|
1102
|
+
originUser: originClientID,
|
|
1103
|
+
user: clientID,
|
|
1104
|
+
tideID
|
|
1105
|
+
},
|
|
1106
|
+
metadata: {
|
|
1107
|
+
currentTideChannel: currentTideChannel || "file-room",
|
|
1108
|
+
connectedOn: Date.now(),
|
|
1109
|
+
originUser: originClientID,
|
|
1110
|
+
user: clientID,
|
|
1111
|
+
connectionID,
|
|
1112
|
+
pClientID,
|
|
1113
|
+
tideID
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
this.onTideAction({
|
|
1117
|
+
tideActionID: "tider-online",
|
|
1118
|
+
tideActionDate: Date.now(),
|
|
1119
|
+
tideActionDetails: {
|
|
1120
|
+
currentTideChannel: currentTideChannel || "file-room",
|
|
1121
|
+
connectedOn: Date.now(),
|
|
1122
|
+
originUser: originClientID,
|
|
1123
|
+
user: clientID,
|
|
1124
|
+
connectionID,
|
|
1125
|
+
pClientID,
|
|
1126
|
+
tideID
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
544
1129
|
FileNetClientManager.addOnlineClient(clientID, pClientID, tideID, connectionID, {
|
|
545
1130
|
connectedOn: Date.now(),
|
|
546
1131
|
currentTideChannel: currentTideChannel || "file-room",
|
|
@@ -563,6 +1148,38 @@ class FileMessager {
|
|
|
563
1148
|
console.log(!clientDetails ? `[FileTide ~ Net Activity] ~ Client ~ ${clientData.clientID} already offline.` : `[FileTide ~ Net Activity] ~ Unauthorized offline signal from connection ID ~ ${clientData.connectionID}.`);
|
|
564
1149
|
return;
|
|
565
1150
|
}
|
|
1151
|
+
tidalytics.track("tider:offline", {
|
|
1152
|
+
value: 1,
|
|
1153
|
+
tags: {
|
|
1154
|
+
"tider:offline": "tider:offline",
|
|
1155
|
+
"tider": "tider",
|
|
1156
|
+
originUser: clientDetails.originClientID,
|
|
1157
|
+
user: clientDetails.clientID,
|
|
1158
|
+
tideID: clientDetails.tideID
|
|
1159
|
+
},
|
|
1160
|
+
metadata: {
|
|
1161
|
+
currentTideChannel: clientDetails.currentTideChannel || "file-room",
|
|
1162
|
+
originUser: clientDetails.originClientID,
|
|
1163
|
+
user: clientDetails.clientID,
|
|
1164
|
+
connectionID: clientDetails.connectionID,
|
|
1165
|
+
pClientID: clientDetails.pClientID,
|
|
1166
|
+
tideID: clientDetails.tideID,
|
|
1167
|
+
connectedOn: clientDetails.connectedOn
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
this.onTideAction({
|
|
1171
|
+
tideActionID: "tider-offline",
|
|
1172
|
+
tideActionDate: Date.now(),
|
|
1173
|
+
tideActionDetails: {
|
|
1174
|
+
currentTideChannel: clientDetails.currentTideChannel || "file-room",
|
|
1175
|
+
originUser: clientDetails.originClientID,
|
|
1176
|
+
user: clientDetails.clientID,
|
|
1177
|
+
connectionID: clientDetails.connectionID,
|
|
1178
|
+
pClientID: clientDetails.pClientID,
|
|
1179
|
+
tideID: clientDetails.tideID,
|
|
1180
|
+
connectedOn: clientDetails.connectedOn
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
566
1183
|
FileNetClientManager.clearOnlineClient(clientData.clientID);
|
|
567
1184
|
const currentOnlineClients = Object.fromEntries(FileNetClientManager.getOnlineClients());
|
|
568
1185
|
this.fileNet.emit("current-online-clients", currentOnlineClients);
|
|
@@ -571,19 +1188,7 @@ class FileMessager {
|
|
|
571
1188
|
this.fileNet.emitToTide(senderClient.tideID, "save-current-transfer-states", {
|
|
572
1189
|
clientID: clientData.clientID
|
|
573
1190
|
});
|
|
574
|
-
|
|
575
|
-
if (tidingTransfers && tidingTransfers.size > 0) {
|
|
576
|
-
for (let recipientID of tidingTransfers.keys()) {
|
|
577
|
-
const recipientConnectionID = FileNetClientManager.getOnlineClient(clientData.recipientID).id;
|
|
578
|
-
const client = this.getClientFromID(recipientConnectionID);
|
|
579
|
-
if (client) {
|
|
580
|
-
this.fileNet.emitToTide(client.tideID, "save-current-transfer-states", {
|
|
581
|
-
clientID: recipientID
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
this.currentTidingTransfers.delete(clientData.clientID);
|
|
586
|
-
}
|
|
1191
|
+
this.saveClientTransferStates(clientData);
|
|
587
1192
|
} catch (error) {
|
|
588
1193
|
console.log(`[FileTide ~ Net Activity] ~ Did not process client ~ ${clientData} offline signal ~ ${error}`);
|
|
589
1194
|
}
|
|
@@ -36,23 +36,28 @@ class FileMessagerClient {
|
|
|
36
36
|
const {
|
|
37
37
|
maxReconnectionAttempts = 15,
|
|
38
38
|
reconnectionAttempts = 15,
|
|
39
|
-
maxReconnectionDelay = 10000
|
|
39
|
+
maxReconnectionDelay = 10000,
|
|
40
|
+
...messagerConfigurations
|
|
40
41
|
} = messagerSettings;
|
|
41
42
|
this.clientOptions = FileMessagerConfigManager.getClientOptions(options);
|
|
42
43
|
this.transporter = new FileTransferManager(transportOptions);
|
|
43
44
|
this.activeTransferTypes = new Map();
|
|
44
|
-
this.clientTide = new HUDIoTide(maxReconnectionAttempts, reconnectionAttempts, maxReconnectionDelay
|
|
45
|
+
this.clientTide = new HUDIoTide(maxReconnectionAttempts, reconnectionAttempts, maxReconnectionDelay, {
|
|
46
|
+
persistentTideIDs: true,
|
|
47
|
+
persistentTideID: true,
|
|
48
|
+
...messagerConfigurations
|
|
49
|
+
});
|
|
45
50
|
this.clients = new Map();
|
|
46
51
|
}
|
|
47
52
|
createClientInstance(clientID, clientOptions, options = {}, headers = {}, onConnect = null, onDisconnect = null, authURL = "", authHeaders = {}, useAuthentication = false, queryAuthToken = false) {
|
|
48
53
|
this.clientTide.createIO(clientID, clientOptions.url, {
|
|
49
54
|
transports: ["websocket"],
|
|
50
55
|
...options
|
|
51
|
-
}, headers, authURL, authHeaders, useAuthentication, queryAuthToken, onConnect, () => {
|
|
56
|
+
}, headers, authURL, authHeaders, useAuthentication, queryAuthToken, onConnect, async () => {
|
|
52
57
|
FileTransferTrackingManager.outputCurrentTransfers();
|
|
53
58
|
FileTransferRecoveryManager.flushToDisk();
|
|
54
59
|
if (onDisconnect) {
|
|
55
|
-
onDisconnect();
|
|
60
|
+
await onDisconnect();
|
|
56
61
|
}
|
|
57
62
|
});
|
|
58
63
|
FileTideDebugUtilityManager.outputGradient(`\n[FileTide ~ File Messager] ~ Created client with ID ${clientID} and socket ${clientID}!`, significantMessageColors);
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -47,6 +47,7 @@ class FileTide {
|
|
|
47
47
|
});
|
|
48
48
|
this.clientShorePolicies = new Map();
|
|
49
49
|
this.transferBarrier = false;
|
|
50
|
+
this.clientDetails = new Map();
|
|
50
51
|
this.clients = new Map();
|
|
51
52
|
this.currentUserID = "";
|
|
52
53
|
this.runningOn = os.platform();
|
|
@@ -109,11 +110,29 @@ class FileTide {
|
|
|
109
110
|
if (this.clients.has(userID)) {
|
|
110
111
|
this.stopMessager(userID);
|
|
111
112
|
}
|
|
113
|
+
const currentClientDetails = this.clientDetails.get(userID);
|
|
114
|
+
if (currentClientDetails && currentClientDetails.unauthorized) {
|
|
115
|
+
const {
|
|
116
|
+
onCurrentClientUnauthorized
|
|
117
|
+
} = options;
|
|
118
|
+
FileTide.outputGradient(`[FileTide ~ FileNet] ~ Unauthorized access detected.`, errorMessageColors);
|
|
119
|
+
if (onCurrentClientUnauthorized) {
|
|
120
|
+
onCurrentClientUnauthorized({
|
|
121
|
+
...currentClientDetails,
|
|
122
|
+
userID
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
112
127
|
const newClient = new FileMessagerClient(clientOptions, transportOptions, messagerSettings);
|
|
113
128
|
const enterRoom = newClient.joinRoom(userID, roomName, connectionOptions, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
|
|
114
129
|
this.transferBarrier = enableTransferBarrier;
|
|
115
130
|
this.clientShorePolicies.set(userID, [FileUtilityManager.getTidePath(">Downloads"), FileUtilityManager.getTidePath(">Documents"), FileUtilityManager.getTidePath(">Desktop"), FileUtilityManager.getTidePath(">Photos"), FileUtilityManager.getTidePath(">Videos"), FileUtilityManager.getTidePath(">Music")]);
|
|
116
131
|
this.clients.set(userID, newClient);
|
|
132
|
+
this.clientDetails.set(userID, {
|
|
133
|
+
unauthorized: false,
|
|
134
|
+
userID
|
|
135
|
+
});
|
|
117
136
|
FileTide.outputGradient(`[FileTide] ~ Messager launched successfully for client ~ ${userID}!`, significantMessageColors);
|
|
118
137
|
_assertClassBrand(_FileTide_brand, this, _setupFileEventListeners).call(this, userID, newClient, onTransferProgress, onIncomingTransfer, onIncomingFile, onTransferBarrier, options);
|
|
119
138
|
if (onLaunch) {
|
|
@@ -153,6 +172,10 @@ class FileTide {
|
|
|
153
172
|
FileTide.outputGradient(`[FileTide] Client ~ ${clientID} not found.`, errorMessageColors);
|
|
154
173
|
return;
|
|
155
174
|
}
|
|
175
|
+
clientMessager.clientTide.emitEvent(clientID, "check-client-banned", {
|
|
176
|
+
clientID,
|
|
177
|
+
tideID: clientMessager.clientTide.sockets[clientID].tideID
|
|
178
|
+
});
|
|
156
179
|
clientMessager.listFiles(clientID, recipientID, depth);
|
|
157
180
|
}
|
|
158
181
|
async listFiles(directories, depth = 1, onDirectory) {
|
|
@@ -201,6 +224,10 @@ class FileTide {
|
|
|
201
224
|
FileTide.outputGradient(`[FileTide] Client ~ ${clientID} not found.`, errorMessageColors);
|
|
202
225
|
return false;
|
|
203
226
|
}
|
|
227
|
+
clientMessager.clientTide.emitEvent(clientID, "check-client-banned", {
|
|
228
|
+
clientID,
|
|
229
|
+
tideID: clientMessager.clientTide.sockets[clientID].tideID
|
|
230
|
+
});
|
|
204
231
|
const recipientOnline = await clientMessager.clientTide.emitEventWithResponse(clientID, "check-client-online", "retrieved-client-online", {
|
|
205
232
|
clientID: recipientID
|
|
206
233
|
}, 5000);
|
|
@@ -350,7 +377,10 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
350
377
|
onFileListReceived,
|
|
351
378
|
onCurrentOnlineClients,
|
|
352
379
|
onClientTiding,
|
|
353
|
-
onCurrentClientIDAlreadyOnline
|
|
380
|
+
onCurrentClientIDAlreadyOnline,
|
|
381
|
+
onCurrentClientUnauthorized,
|
|
382
|
+
onBeforeCurrentClientUnauthorizedDisconnect,
|
|
383
|
+
onCurrentClientUnauthorizedDisconnect
|
|
354
384
|
} = options;
|
|
355
385
|
const cliTable = new ConsoleTable({
|
|
356
386
|
padding: 2,
|
|
@@ -380,6 +410,10 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
380
410
|
});
|
|
381
411
|
const fileTransferReceiver = new FileTransferReceiverManager();
|
|
382
412
|
client.clientTide.onEvent(userID, "current-online-clients", data => {
|
|
413
|
+
client.clientTide.emitEvent(userID, "check-client-banned", {
|
|
414
|
+
clientID: userID,
|
|
415
|
+
tideID: client.clientTide.sockets[userID].tideID
|
|
416
|
+
});
|
|
383
417
|
const currentClients = {};
|
|
384
418
|
Object.keys(data).forEach(key => {
|
|
385
419
|
if (key !== userID) {
|
|
@@ -430,6 +464,22 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
430
464
|
}
|
|
431
465
|
return;
|
|
432
466
|
});
|
|
467
|
+
client.clientTide.onEvent(userID, "retrieved-client-banned", async bannedDetails => {
|
|
468
|
+
const clientID = bannedDetails.clientID;
|
|
469
|
+
if (userID !== clientID) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (!bannedDetails.banned) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
_FileTide.outputGradient(`[FileTide ~ FileNet] ~ Unauthorized access detected.`, errorMessageColors);
|
|
476
|
+
await this.stopAllMessagers(onBeforeCurrentClientUnauthorizedDisconnect, onCurrentClientUnauthorizedDisconnect, async () => {
|
|
477
|
+
if (onCurrentClientUnauthorized) {
|
|
478
|
+
onCurrentClientUnauthorized(bannedDetails);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
return;
|
|
482
|
+
});
|
|
433
483
|
client.clientTide.onEvent(userID, "save-current-transfer-states", async data => {
|
|
434
484
|
this.saveTransferStates();
|
|
435
485
|
return;
|
|
@@ -687,6 +737,10 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
687
737
|
}
|
|
688
738
|
});
|
|
689
739
|
client.clientTide.onEvent(userID, "client-file-list", async data => {
|
|
740
|
+
client.clientTide.emitEvent(userID, "check-client-banned", {
|
|
741
|
+
clientID: userID,
|
|
742
|
+
tideID: client.clientTide.sockets[userID].tideID
|
|
743
|
+
});
|
|
690
744
|
_FileTide.outputGradient(`[${userID}] Received ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItems, false)} directory contents from ${data.senderID}'s file list!`, significantMessageColors);
|
|
691
745
|
if (onListFiles) {
|
|
692
746
|
onListFiles(data);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const MetricTide = require("@trap_stevo/metrictide");
|
|
4
|
+
class TidalyticsInstanceManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.instances = new Map();
|
|
7
|
+
}
|
|
8
|
+
createInstance(name = "default", config = {}) {
|
|
9
|
+
if (this.instances.has(name)) {
|
|
10
|
+
return this.instances.get(name);
|
|
11
|
+
}
|
|
12
|
+
const defaultConfig = {
|
|
13
|
+
dbPath: "./filetide_core/.tidalytics",
|
|
14
|
+
persistence: {
|
|
15
|
+
alwaysOn: true
|
|
16
|
+
},
|
|
17
|
+
loadMetricsOnLaunch: false,
|
|
18
|
+
onTrack: record => {
|
|
19
|
+
console.log("[Tidalytics] Tracked:", record.name, record.value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const mergedConfig = {
|
|
23
|
+
...defaultConfig,
|
|
24
|
+
...config,
|
|
25
|
+
persistence: {
|
|
26
|
+
...defaultConfig.persistence,
|
|
27
|
+
...(config.persistence || {})
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const instance = new MetricTide(mergedConfig);
|
|
31
|
+
this.instances.set(name, instance);
|
|
32
|
+
return instance;
|
|
33
|
+
}
|
|
34
|
+
getInstance(name = "default", configurations = {}) {
|
|
35
|
+
if (!this.instances.has(name)) {
|
|
36
|
+
if (configurations) {
|
|
37
|
+
return this.createInstance(name, configurations);
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return this.instances.get(name);
|
|
42
|
+
}
|
|
43
|
+
containsInstance(name = "default") {
|
|
44
|
+
return this.instances.has(name);
|
|
45
|
+
}
|
|
46
|
+
clearInstance(name = "default") {
|
|
47
|
+
this.instances.delete(name);
|
|
48
|
+
}
|
|
49
|
+
listInstances() {
|
|
50
|
+
return Array.from(this.instances.entries());
|
|
51
|
+
}
|
|
52
|
+
clearAll() {
|
|
53
|
+
this.instances.clear();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
;
|
|
57
|
+
let singleton = null;
|
|
58
|
+
const Tidalytics = {
|
|
59
|
+
get() {
|
|
60
|
+
if (!singleton) {
|
|
61
|
+
singleton = new TidalyticsInstanceManager();
|
|
62
|
+
}
|
|
63
|
+
return singleton;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
module.exports = {
|
|
67
|
+
TidalyticsInstanceManager,
|
|
68
|
+
Tidalytics
|
|
69
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
4
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
5
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
7
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
8
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
|
+
const Timelyst = require("@trap_stevo/timelyst");
|
|
10
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
11
|
+
var _lists = /*#__PURE__*/new WeakMap();
|
|
12
|
+
var _manager = /*#__PURE__*/new WeakMap();
|
|
13
|
+
var _onEntryAddedHooks = /*#__PURE__*/new WeakMap();
|
|
14
|
+
var _onExpireHooks = /*#__PURE__*/new WeakMap();
|
|
15
|
+
var _TideSentinelManager_brand = /*#__PURE__*/new WeakSet();
|
|
16
|
+
class TideSentinelManager {
|
|
17
|
+
constructor(config = {}) {
|
|
18
|
+
_classPrivateMethodInitSpec(this, _TideSentinelManager_brand);
|
|
19
|
+
_classPrivateFieldInitSpec(this, _config, void 0);
|
|
20
|
+
_classPrivateFieldInitSpec(this, _lists, void 0);
|
|
21
|
+
_classPrivateFieldInitSpec(this, _manager, void 0);
|
|
22
|
+
_classPrivateFieldInitSpec(this, _onEntryAddedHooks, {});
|
|
23
|
+
_classPrivateFieldInitSpec(this, _onExpireHooks, {});
|
|
24
|
+
const {
|
|
25
|
+
lists = {},
|
|
26
|
+
enableOfflineStorage = true,
|
|
27
|
+
autoCleanupInterval = "15s",
|
|
28
|
+
basePath = "./filetide_core/tide_sentinel",
|
|
29
|
+
...rest
|
|
30
|
+
} = config;
|
|
31
|
+
_classPrivateFieldSet(_config, this, {
|
|
32
|
+
enableOfflineStorage,
|
|
33
|
+
autoCleanupInterval,
|
|
34
|
+
basePath,
|
|
35
|
+
...rest
|
|
36
|
+
});
|
|
37
|
+
_classPrivateFieldSet(_lists, this, lists);
|
|
38
|
+
_classPrivateFieldSet(_manager, this, new Timelyst(_classPrivateFieldGet(_config, this)));
|
|
39
|
+
_classPrivateFieldGet(_manager, this).on("entry-expired", (list, key, entry) => {
|
|
40
|
+
const hook = _classPrivateFieldGet(_onExpireHooks, this)[list];
|
|
41
|
+
if (typeof hook === "function") {
|
|
42
|
+
hook(key, entry);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
_classPrivateFieldGet(_manager, this).on("entry-added", (list, key, entry) => {
|
|
46
|
+
const hook = _classPrivateFieldGet(_onEntryAddedHooks, this)[list];
|
|
47
|
+
if (typeof hook === "function") {
|
|
48
|
+
hook(key, entry);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
registerEntryAddedHook(list, callback) {
|
|
53
|
+
if (typeof callback === "function") {
|
|
54
|
+
_classPrivateFieldGet(_onEntryAddedHooks, this)[list] = callback;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
registerExpireHook(list, callback) {
|
|
58
|
+
if (typeof callback === "function") {
|
|
59
|
+
_classPrivateFieldGet(_onExpireHooks, this)[list] = callback;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async createList(name, options = {}) {
|
|
63
|
+
_classPrivateFieldGet(_lists, this)[name] = options;
|
|
64
|
+
return _classPrivateFieldGet(_manager, this).createList(name, options);
|
|
65
|
+
}
|
|
66
|
+
async deleteList(name) {
|
|
67
|
+
delete _classPrivateFieldGet(_lists, this)[name];
|
|
68
|
+
return _classPrivateFieldGet(_manager, this).deleteList(name);
|
|
69
|
+
}
|
|
70
|
+
async reconfigureList(name, newOptions = {}) {
|
|
71
|
+
Object.assign(_classPrivateFieldGet(_lists, this)[name] = _classPrivateFieldGet(_lists, this)[name] || {}, newOptions);
|
|
72
|
+
await _classPrivateFieldGet(_manager, this).deleteList(name);
|
|
73
|
+
return _classPrivateFieldGet(_manager, this).createList(name, _classPrivateFieldGet(_lists, this)[name]);
|
|
74
|
+
}
|
|
75
|
+
async banClient(clientID, options = {}) {
|
|
76
|
+
const {
|
|
77
|
+
reason = "Unspecified.",
|
|
78
|
+
duration = null,
|
|
79
|
+
tags = [],
|
|
80
|
+
priority = 10,
|
|
81
|
+
category = "ban",
|
|
82
|
+
details = {}
|
|
83
|
+
} = options;
|
|
84
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, "banned-tiders");
|
|
85
|
+
return _classPrivateFieldGet(_manager, this).addToList("banned-tiders", clientID, {
|
|
86
|
+
expiresIn: duration,
|
|
87
|
+
priority,
|
|
88
|
+
category,
|
|
89
|
+
tags,
|
|
90
|
+
details
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async unbanClient(clientID) {
|
|
94
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, "banned-tiders");
|
|
95
|
+
return _classPrivateFieldGet(_manager, this).removeFromList("banned-tiders", clientID);
|
|
96
|
+
}
|
|
97
|
+
async clientBanned(clientID) {
|
|
98
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, "banned-tiders");
|
|
99
|
+
return _classPrivateFieldGet(_manager, this).inList("banned-tiders", clientID);
|
|
100
|
+
}
|
|
101
|
+
async getBanEntry(clientID) {
|
|
102
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, "banned-tiders");
|
|
103
|
+
return _classPrivateFieldGet(_manager, this).getEntryByKey("banned-tiders", clientID);
|
|
104
|
+
}
|
|
105
|
+
async filterBannedClients(filter = {}) {
|
|
106
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, "banned-tiders");
|
|
107
|
+
return _classPrivateFieldGet(_manager, this).filterList("banned-tiders", filter);
|
|
108
|
+
}
|
|
109
|
+
async addToList(list, key, data) {
|
|
110
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, list);
|
|
111
|
+
return _classPrivateFieldGet(_manager, this).addToList(list, key, data);
|
|
112
|
+
}
|
|
113
|
+
async removeFromList(list, key) {
|
|
114
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, list);
|
|
115
|
+
return _classPrivateFieldGet(_manager, this).removeFromList(list, key);
|
|
116
|
+
}
|
|
117
|
+
async inList(list, key) {
|
|
118
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, list);
|
|
119
|
+
return _classPrivateFieldGet(_manager, this).inList(list, key);
|
|
120
|
+
}
|
|
121
|
+
async getEntry(list, key) {
|
|
122
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, list);
|
|
123
|
+
return _classPrivateFieldGet(_manager, this).getEntryByKey(list, key);
|
|
124
|
+
}
|
|
125
|
+
async filterList(list, filter = {}) {
|
|
126
|
+
await _assertClassBrand(_TideSentinelManager_brand, this, _ensureList).call(this, list);
|
|
127
|
+
return _classPrivateFieldGet(_manager, this).filterList(list, filter);
|
|
128
|
+
}
|
|
129
|
+
async findSimilarKeys(key, options = {}) {
|
|
130
|
+
return _classPrivateFieldGet(_manager, this).findSimilarKeys(key, options);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function _ensureList(name) {
|
|
134
|
+
if (!_classPrivateFieldGet(_lists, this)[name]) {
|
|
135
|
+
_classPrivateFieldGet(_lists, this)[name] = {};
|
|
136
|
+
}
|
|
137
|
+
const exists = await _classPrivateFieldGet(_manager, this).listOperational(name);
|
|
138
|
+
if (!exists) {
|
|
139
|
+
await _classPrivateFieldGet(_manager, this).createList(name, _classPrivateFieldGet(_lists, this)[name]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
;
|
|
143
|
+
module.exports = TideSentinelManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
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": {
|
|
@@ -34,9 +34,11 @@
|
|
|
34
34
|
"author": "Steven Compton",
|
|
35
35
|
"license": "See License in LICENSE.md",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@trap_stevo/iotide": "^0.0.
|
|
38
|
-
"@trap_stevo/iotide-client": "^0.0.
|
|
37
|
+
"@trap_stevo/iotide": "^0.0.43",
|
|
38
|
+
"@trap_stevo/iotide-client": "^0.0.25",
|
|
39
39
|
"@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.43",
|
|
40
|
+
"@trap_stevo/metrictide": "^0.0.3",
|
|
41
|
+
"@trap_stevo/timelyst": "^0.0.5",
|
|
40
42
|
"chalk": "^4.1.2",
|
|
41
43
|
"readline": "^1.3.0"
|
|
42
44
|
},
|