Disabled Firebase support on NodeJS 23 for now, added warning.
Ylian Saint-Hilaire committed
Nov 26, 2024 at 10:37 UTC
7bd5b66ebcf9ca0a7d45928eb02b0e729b6afddb
3 files changed
+31
-9
firebase.js
+4
@@ -28,6 +28,10 @@ module.exports.CreateFirebase = function (parent, senderid, serverkey) {
28
receivedBadArgs: 0
29
}
30
31
+ // In NodeJS v23, add util.isNullOrUndefined() to make node-xcs work correctly.
32
+ // Remove this when node-xcs moves to support NodeJS v23
33
+ if (require('util').isNullOrUndefined == null) { require('util').isNullOrUndefined = function (v) { return v == null; } }
34
+
35
const Sender = require('node-xcs').Sender;
36
const Message = require('node-xcs').Message;
37
const Notification = require('node-xcs').Notification;
meshcentral.js
+24
-7
@@ -1992,15 +1992,31 @@ function CreateMeshCentralServer(config, args) {
1992
if (typeof config.settings.webpush.gcmapi == 'string') { webpush.setGCMAPIKey(config.settings.webpush.gcmapi); }
1993
}
1994
1995
+ // Get the current node version
1996
+ const verSplit = process.version.substring(1).split('.');
1997
+ var nodeVersion = parseInt(verSplit[0]) + (parseInt(verSplit[1]) / 100);
1998
+
1999
// Setup Firebase
2000
if ((config.firebase != null) && (typeof config.firebase.senderid == 'string') && (typeof config.firebase.serverkey == 'string')) {
1997
- obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey);
2001
+ if (nodeVersion >= 23) {
2002
+ addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
2003
+ } else {
2004
+ obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey);
2005
+ }
2006
} else if ((typeof config.firebaserelay == 'object') && (typeof config.firebaserelay.url == 'string')) {
1999
- // Setup the push messaging relay
2000
- obj.firebase = require('./firebase').CreateFirebaseRelay(obj, config.firebaserelay.url, config.firebaserelay.key);
2007
+ if (nodeVersion >= 23) {
2008
+ addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
2009
+ } else {
2010
+ // Setup the push messaging relay
2011
+ obj.firebase = require('./firebase').CreateFirebaseRelay(obj, config.firebaserelay.url, config.firebaserelay.key);
2012
+ }
2013
} else if (obj.config.settings.publicpushnotifications === true) {
2002
- // Setup the Firebase push messaging relay using https://alt.meshcentral.com, this is the public push notification server.
2003
- obj.firebase = require('./firebase').CreateFirebaseRelay(obj, 'https://alt.meshcentral.com/firebaserelay.aspx');
2014
+ if (nodeVersion >= 23) {
2015
+ addServerWarning('Firebase is not supported on this version of NodeJS.', 27);
2016
+ } else {
2017
+ // Setup the Firebase push messaging relay using https://alt.meshcentral.com, this is the public push notification server.
2018
+ obj.firebase = require('./firebase').CreateFirebaseRelay(obj, 'https://alt.meshcentral.com/firebaserelay.aspx');
2019
+ }
2020
}
2021
2022
// Start periodic maintenance
@@ -4112,7 +4128,8 @@ var ServerWarnings = {
4128
23: "Unable to load agent icon file: {0}.",
4129
24: "Unable to load agent logo file: {0}.",
4130
25: "This NodeJS version does not support OpenID.",
4115
- 26: "This NodeJS version does not support Discord.js."
4131
+ 26: "This NodeJS version does not support Discord.js.",
4132
+ 27: "Firebase is not supported on this version of NodeJS."
4133
};
4134
*/
4135
@@ -4285,7 +4302,7 @@ function mainStart() {
4302
4303
// Firebase Support
4304
// Avoid 0.1.8 due to bugs: https://github.com/guness/node-xcs/issues/43
4288
- if (config.firebase != null) { modules.push('node-xcs@0.1.7'); }
4305
+ if (config.firebase != null) { modules.push('node-xcs@0.1.8'); }
4306
4307
// Syslog support
4308
if ((require('os').platform() != 'win32') && (config.settings.syslog || config.settings.syslogjson)) { modules.push('modern-syslog@1.2.0'); }
views/default.handlebars
+3
-2
@@ -1,4 +1,4 @@
1
-<!DOCTYPE html>
1
+<!DOCTYPE html>
2
<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
3
<head>
4
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@@ -2483,7 +2483,8 @@
2483
23: "Unable to load agent icon file: {0}.",
2484
24: "Unable to load agent logo file: {0}.",
2485
25: "This NodeJS version does not support OpenID.",
2486
- 26: "This NodeJS version does not support Discord.js."
2486
+ 26: "This NodeJS version does not support Discord.js.",
2487
+ 27: "Firebase is not supported on this version of NodeJS."
2488
};
2489
var x = '';
2490
for (var i in message.warnings) {