@trap_stevo/filetide 0.0.84 → 0.0.86
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/SCL-1.0-Universal.md +228 -0
- package/dist/cjs/FileMessagerClient.js +138 -71
- package/dist/cjs/FileTide.js +165 -83
- package/dist/cjs/{FileMessager.js → FileTideAnchor.js} +444 -264
- package/dist/cjs/HUDComponents/FileTidePathsConfigurations.js +57 -0
- package/dist/cjs/HUDManagers/EndpointManager.js +157 -0
- package/dist/cjs/HUDManagers/FileMessagerConfigManager.js +2 -0
- package/dist/cjs/HUDManagers/{FileNetClientManager.js → FileTideAnchorClientManager.js} +3 -2
- package/dist/cjs/HUDManagers/{FileNetUtilityManager.js → FileTideAnchorUtilityManager.js} +2 -2
- package/dist/cjs/HUDManagers/FileTideDebugUtilityManager.js +6 -0
- package/dist/cjs/HUDManagers/FileTideNetworkTrafficManager.js +419 -0
- package/dist/cjs/HUDManagers/FileTideUniversalPathsUtilityManager.js +14 -0
- package/dist/cjs/HUDManagers/FileTransferManager.js +90 -157
- package/dist/cjs/HUDManagers/FileTransferReceiverManager.js +169 -9
- package/dist/cjs/HUDManagers/FileTransferStatsManager.js +138 -0
- package/dist/cjs/HUDManagers/FileTransferTrackingManager.js +22 -0
- package/dist/cjs/HUDManagers/FileUtilityManager.js +2 -1
- package/dist/cjs/HUDManagers/TidalyticsInstanceManager.js +2 -1
- package/dist/cjs/HUDManagers/TideSentinelManager.js +8 -7
- package/dist/cjs/HUDManagers/TideTokenEnforcementManager.js +2 -1
- package/package.json +4 -5
- package/LICENSE.md +0 -79
- package/dist/cjs/HUDComponents/ConsoleProgressBarManager.js +0 -288
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const LogicTide = require("@trap_stevo/logictide");
|
|
4
|
+
const {
|
|
5
|
+
getUniversalPrefix
|
|
6
|
+
} = require("../HUDManagers/FileTideUniversalPathsUtilityManager.js");
|
|
7
|
+
|
|
8
|
+
// ~ Universal FileTide Root Path Configurations ~
|
|
9
|
+
|
|
10
|
+
LogicTide.defineLogic("filetide-root-path", "development", () => {
|
|
11
|
+
return ".filetide";
|
|
12
|
+
});
|
|
13
|
+
LogicTide.defineLogic("filetide-root-path", "production", () => {
|
|
14
|
+
return `${getUniversalPrefix()}/.filetide`;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// ~ Universal Tidalytics Path Configurations ~
|
|
18
|
+
|
|
19
|
+
LogicTide.defineLogic("tidalytics-path", "development", () => {
|
|
20
|
+
return ".filetide/filetide_core/.tidalytics";
|
|
21
|
+
});
|
|
22
|
+
LogicTide.defineLogic("tidalytics-path", "production", () => {
|
|
23
|
+
return `${getUniversalPrefix()}/.filetide/filetide_core/.tidalytics`;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// ~ Universal Tide Sentinel Path Configurations ~
|
|
27
|
+
|
|
28
|
+
LogicTide.defineLogic("tide-sentinel-path", "development", () => {
|
|
29
|
+
return ".filetide/filetide_core/tide_sentinel";
|
|
30
|
+
});
|
|
31
|
+
LogicTide.defineLogic("tide-sentinel-path", "production", () => {
|
|
32
|
+
return `${getUniversalPrefix()}/.filetide/filetide_core/tide_sentinel`;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ~ Universal Tidal Core Path Configurations ~
|
|
36
|
+
|
|
37
|
+
LogicTide.defineLogic("tidal-core-path", "development", () => {
|
|
38
|
+
return ".filetide/tidal_core";
|
|
39
|
+
});
|
|
40
|
+
LogicTide.defineLogic("tidal-core-path", "production", () => {
|
|
41
|
+
return `${getUniversalPrefix()}/.filetide/tidal_core`;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// ~ Universal Tide Sessions Path Configurations ~
|
|
45
|
+
|
|
46
|
+
LogicTide.defineLogic("tide-session-ids-path", "development", () => {
|
|
47
|
+
return ".filetide/tidal_client/tide_session_ids.json";
|
|
48
|
+
});
|
|
49
|
+
LogicTide.defineLogic("tide-session-ids-path", "production", () => {
|
|
50
|
+
return `${getUniversalPrefix()}/.filetide/tidal_client/tide_session_ids.json`;
|
|
51
|
+
});
|
|
52
|
+
LogicTide.defineLogic("tide-session-id-path", "development", () => {
|
|
53
|
+
return ".filetide/tidal_client/tide_session_id.json";
|
|
54
|
+
});
|
|
55
|
+
LogicTide.defineLogic("tide-session-id-path", "production", () => {
|
|
56
|
+
return `${getUniversalPrefix()}/.filetide/tidal_client/tide_session_id.json`;
|
|
57
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
class EndpointManager {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.baseUrl = this.cleanBaseUrl(options.baseUrl || process.env.FILETIDE_BACKEND_URL);
|
|
8
|
+
this.licenseKey = options.licenseKey || process.env.FILETIDE_LICENSE_KEY;
|
|
9
|
+
this.endpointId = options.endpointId || process.env.FILETIDE_ENDPOINT_ID || os.hostname();
|
|
10
|
+
this.endpointSecret = options.endpointSecret || process.env.FILETIDE_ENDPOINT_SECRET;
|
|
11
|
+
this.routesPath = options.routesPath || process.env.FILETIDE_ROUTES_PATH || '/api/filetide/routes';
|
|
12
|
+
this.timeoutMs = Number(options.timeoutMs || 15000);
|
|
13
|
+
this.routes = {
|
|
14
|
+
health: '/status',
|
|
15
|
+
registerEndpoint: '/api/endpoints/register',
|
|
16
|
+
heartbeat: '/api/endpoints/heartbeat',
|
|
17
|
+
resolveTransferPolicy: '/api/transfers/policy',
|
|
18
|
+
recordTransfer: '/api/transfers/usage',
|
|
19
|
+
quoteMonthToDate: '/api/billing/quote',
|
|
20
|
+
finalizeInvoice: '/api/billing/finalize'
|
|
21
|
+
};
|
|
22
|
+
if (!this.baseUrl) {
|
|
23
|
+
throw new Error('Missing FILETIDE_BACKEND_URL');
|
|
24
|
+
}
|
|
25
|
+
if (!this.licenseKey) {
|
|
26
|
+
throw new Error('Missing FILETIDE_LICENSE_KEY');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
cleanBaseUrl(url) {
|
|
30
|
+
if (!url) return '';
|
|
31
|
+
return String(url).replace(/\/+$/, '');
|
|
32
|
+
}
|
|
33
|
+
buildUrl(path) {
|
|
34
|
+
if (!path.startsWith('/')) path = `/${path}`;
|
|
35
|
+
return `${this.baseUrl}${path}`;
|
|
36
|
+
}
|
|
37
|
+
makeAuthHeaders(body = '') {
|
|
38
|
+
const timestamp = new Date().toISOString();
|
|
39
|
+
const signature = this.endpointSecret ? crypto.createHmac('sha256', this.endpointSecret).update(`${timestamp}.${body}`).digest('hex') : '';
|
|
40
|
+
return {
|
|
41
|
+
'content-type': 'application/json',
|
|
42
|
+
'x-filetide-license-key': this.licenseKey,
|
|
43
|
+
'x-filetide-endpoint-id': this.endpointId,
|
|
44
|
+
'x-filetide-timestamp': timestamp,
|
|
45
|
+
...(signature ? {
|
|
46
|
+
'x-filetide-signature': signature
|
|
47
|
+
} : {})
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async request(method, path, payload = undefined) {
|
|
51
|
+
const body = payload === undefined ? '' : JSON.stringify(payload);
|
|
52
|
+
const controller = new AbortController();
|
|
53
|
+
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(this.buildUrl(path), {
|
|
56
|
+
method,
|
|
57
|
+
headers: this.makeAuthHeaders(body),
|
|
58
|
+
body: method === 'GET' ? undefined : body,
|
|
59
|
+
signal: controller.signal
|
|
60
|
+
});
|
|
61
|
+
const text = await response.text();
|
|
62
|
+
let data = null;
|
|
63
|
+
try {
|
|
64
|
+
data = text ? JSON.parse(text) : null;
|
|
65
|
+
} catch {
|
|
66
|
+
data = text;
|
|
67
|
+
}
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const error = new Error(`FileTide backend request failed: ${method} ${path} ${response.status}`);
|
|
70
|
+
error.status = response.status;
|
|
71
|
+
error.data = data;
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
return data;
|
|
75
|
+
} finally {
|
|
76
|
+
clearTimeout(timeout);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async discoverRoutes() {
|
|
80
|
+
try {
|
|
81
|
+
const data = await this.request('GET', this.routesPath);
|
|
82
|
+
if (data && typeof data === 'object') {
|
|
83
|
+
const discoveredRoutes = data.routes || data;
|
|
84
|
+
this.routes = {
|
|
85
|
+
...this.routes,
|
|
86
|
+
...discoveredRoutes
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return this.routes;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error.status === 404) {
|
|
92
|
+
return this.routes;
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async health() {
|
|
98
|
+
return this.request('GET', this.routes.health);
|
|
99
|
+
}
|
|
100
|
+
async registerEndpoint(extra = {}) {
|
|
101
|
+
return this.request('POST', this.routes.registerEndpoint, {
|
|
102
|
+
licenseKey: this.licenseKey,
|
|
103
|
+
endpointId: this.endpointId,
|
|
104
|
+
hostname: os.hostname(),
|
|
105
|
+
platform: os.platform(),
|
|
106
|
+
arch: os.arch(),
|
|
107
|
+
uptimeSeconds: os.uptime(),
|
|
108
|
+
networkInterfaces: os.networkInterfaces(),
|
|
109
|
+
...extra
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async heartbeat(extra = {}) {
|
|
113
|
+
return this.request('POST', this.routes.heartbeat, {
|
|
114
|
+
licenseKey: this.licenseKey,
|
|
115
|
+
endpointId: this.endpointId,
|
|
116
|
+
hostname: os.hostname(),
|
|
117
|
+
uptimeSeconds: os.uptime(),
|
|
118
|
+
memory: {
|
|
119
|
+
total: os.totalmem(),
|
|
120
|
+
free: os.freemem()
|
|
121
|
+
},
|
|
122
|
+
loadAverage: os.loadavg(),
|
|
123
|
+
timestamp: new Date().toISOString(),
|
|
124
|
+
...extra
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async resolveTransferPolicy(input = {}) {
|
|
128
|
+
return this.request('POST', this.routes.resolveTransferPolicy, {
|
|
129
|
+
licenseKey: this.licenseKey,
|
|
130
|
+
endpointId: this.endpointId,
|
|
131
|
+
...input
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async recordTransfer(input = {}) {
|
|
135
|
+
return this.request('POST', this.routes.recordTransfer, {
|
|
136
|
+
licenseKey: this.licenseKey,
|
|
137
|
+
endpointId: this.endpointId,
|
|
138
|
+
...input
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async quoteMonthToDate(input = {}) {
|
|
142
|
+
return this.request('POST', this.routes.quoteMonthToDate, {
|
|
143
|
+
licenseKey: this.licenseKey,
|
|
144
|
+
endpointId: this.endpointId,
|
|
145
|
+
...input
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async finalizeInvoice(input = {}) {
|
|
149
|
+
return this.request('POST', this.routes.finalizeInvoice, {
|
|
150
|
+
licenseKey: this.licenseKey,
|
|
151
|
+
endpointId: this.endpointId,
|
|
152
|
+
...input
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
;
|
|
157
|
+
module.exports = EndpointManager;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const LogicTide = require("@trap_stevo/logictide");
|
|
3
4
|
class FileMessagerConfigManager {
|
|
4
5
|
static getServerOptions({
|
|
5
6
|
maxHttpBufferSize = 1e9,
|
|
@@ -16,6 +17,7 @@ class FileMessagerConfigManager {
|
|
|
16
17
|
useCors,
|
|
17
18
|
port,
|
|
18
19
|
tidalCoreOptions: {
|
|
20
|
+
tidalCorePath: LogicTide.runSync("tidal-core-path"),
|
|
19
21
|
persist: true
|
|
20
22
|
},
|
|
21
23
|
socketOptions: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const currentOnlineClients = new Map();
|
|
4
|
-
class
|
|
4
|
+
class FileTideAnchorClientManager {
|
|
5
5
|
static addOnlineClient(clientID, pClientID, tideID, id, details = {}) {
|
|
6
6
|
if (currentOnlineClients.get(pClientID)) {
|
|
7
7
|
currentOnlineClients.delete(pClientID);
|
|
@@ -48,6 +48,7 @@ class FileNetClientManager {
|
|
|
48
48
|
return currentOnlineClients;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
;
|
|
51
52
|
module.exports = {
|
|
52
|
-
|
|
53
|
+
FileTideAnchorClientManager
|
|
53
54
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const {
|
|
4
4
|
HUDUtilityManager
|
|
5
5
|
} = require("@trap_stevo/legendarybuilderpronodejs-utilities");
|
|
6
|
-
class
|
|
6
|
+
class FileTideAnchorUtilityManager {
|
|
7
7
|
static convertSeconds(seconds) {
|
|
8
8
|
if (seconds === 0) return "0 s";
|
|
9
9
|
const units = [{
|
|
@@ -67,5 +67,5 @@ class FileNetUtilityManager {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
module.exports = {
|
|
70
|
-
|
|
70
|
+
FileTideAnchorUtilityManager
|
|
71
71
|
};
|
|
@@ -8,6 +8,7 @@ const significantMessageColors = ["#00C897", "#00E0FF"];
|
|
|
8
8
|
const noticeMessageColors = ["#4A90E2", "#A3D8F4"];
|
|
9
9
|
const infoAccentMessageColors = ["#6B768F", "#8D99AB"];
|
|
10
10
|
const errorMessageColors = ["#F94144", "#F3722C"];
|
|
11
|
+
const debugMessageColors = ["#8B5CF6", "#C084FC"];
|
|
11
12
|
const infoMessageColors = ["#028090", "#56cfe1"];
|
|
12
13
|
const logHandler = {
|
|
13
14
|
"significant": function (includeDate = false, ...message) {
|
|
@@ -25,6 +26,10 @@ const logHandler = {
|
|
|
25
26
|
"info": function (includeDate = false, ...message) {
|
|
26
27
|
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
|
|
27
28
|
outputGradient(log + message.join(" "), infoMessageColors);
|
|
29
|
+
},
|
|
30
|
+
"debug": function (includeDate = false, ...message) {
|
|
31
|
+
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
|
|
32
|
+
outputGradient(log + message.join(" "), debugMessageColors);
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
35
|
function gradientText(text, colors, options = {
|
|
@@ -107,6 +112,7 @@ module.exports = {
|
|
|
107
112
|
significantMessageColors,
|
|
108
113
|
noticeMessageColors,
|
|
109
114
|
errorMessageColors,
|
|
115
|
+
debugMessageColors,
|
|
110
116
|
infoAccentMessageColors,
|
|
111
117
|
infoMessageColors
|
|
112
118
|
};
|