Disabled Firebase support on NodeJS 23 for now, added warning.

This commit is contained in:
Ylian Saint-Hilaire 2024-11-26 10:37:27 -08:00
parent 975e49a190
commit 7bd5b66ebc
3 changed files with 31 additions and 9 deletions

View File

@ -28,6 +28,10 @@ module.exports.CreateFirebase = function (parent, senderid, serverkey) {
receivedBadArgs: 0
}
// In NodeJS v23, add util.isNullOrUndefined() to make node-xcs work correctly.
// Remove this when node-xcs moves to support NodeJS v23
if (require('util').isNullOrUndefined == null) { require('util').isNullOrUndefined = function (v) { return v == null; } }
const Sender = require('node-xcs').Sender;
const Message = require('node-xcs').Message;
const Notification = require('node-xcs').Notification;

View File

@ -1992,15 +1992,31 @@ function CreateMeshCentralServer(config, args) {
if (typeof config.settings.webpush.gcmapi == 'string') { webpush.setGCMAPIKey(config.settings.webpush.gcmapi); }
}
// Get the current node version
const verSplit = process.version.substring(1).split('.');
var nodeVersion = parseInt(verSplit[0]) + (parseInt(verSplit[1]) / 100);
// Setup Firebase
if ((config.firebase != null) && (typeof config.firebase.senderid == 'string') && (typeof config.firebase.serverkey == 'string')) {
obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey);
if (nodeVersion >= 23) {
addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
} else {
obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey);
}
} else if ((typeof config.firebaserelay == 'object') && (typeof config.firebaserelay.url == 'string')) {
// Setup the push messaging relay
obj.firebase = require('./firebase').CreateFirebaseRelay(obj, config.firebaserelay.url, config.firebaserelay.key);
if (nodeVersion >= 23) {
addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
} else {
// Setup the push messaging relay
obj.firebase = require('./firebase').CreateFirebaseRelay(obj, config.firebaserelay.url, config.firebaserelay.key);
}
} else if (obj.config.settings.publicpushnotifications === true) {
// Setup the Firebase push messaging relay using https://alt.meshcentral.com, this is the public push notification server.
obj.firebase = require('./firebase').CreateFirebaseRelay(obj, 'https://alt.meshcentral.com/firebaserelay.aspx');
if (nodeVersion >= 23) {
addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
} else {
// Setup the Firebase push messaging relay using https://alt.meshcentral.com, this is the public push notification server.
obj.firebase = require('./firebase').CreateFirebaseRelay(obj, 'https://alt.meshcentral.com/firebaserelay.aspx');
}
}
// Start periodic maintenance
@ -4112,7 +4128,8 @@ var ServerWarnings = {
23: "Unable to load agent icon file: {0}.",
24: "Unable to load agent logo file: {0}.",
25: "This NodeJS version does not support OpenID.",
26: "This NodeJS version does not support Discord.js."
26: "This NodeJS version does not support Discord.js.",
27: "Firebase is not supported on this version of NodeJS."
};
*/
@ -4285,7 +4302,7 @@ function mainStart() {
// Firebase Support
// Avoid 0.1.8 due to bugs: https://github.com/guness/node-xcs/issues/43
if (config.firebase != null) { modules.push('node-xcs@0.1.7'); }
if (config.firebase != null) { modules.push('node-xcs@0.1.8'); }
// Syslog support
if ((require('os').platform() != 'win32') && (config.settings.syslog || config.settings.syslogjson)) { modules.push('modern-syslog@1.2.0'); }

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@ -2483,7 +2483,8 @@
23: "Unable to load agent icon file: {0}.",
24: "Unable to load agent logo file: {0}.",
25: "This NodeJS version does not support OpenID.",
26: "This NodeJS version does not support Discord.js."
26: "This NodeJS version does not support Discord.js.",
27: "Firebase is not supported on this version of NodeJS."
};
var x = '';
for (var i in message.warnings) {