From ddb06ca2148bf5d548ca9283225a7a14ddef424a Mon Sep 17 00:00:00 2001 From: TheDuffman85 Date: Wed, 10 Feb 2021 14:24:59 +0100 Subject: [PATCH 01/15] Added translation for today and tomorrow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I had missread the documentation of moment.js. We've to provide the translation for today and tomorrow ourselves. For the translation I use the standard MM² translation mechanism. --- modules/default/calendar/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 05e50efe..a4346c64 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -372,8 +372,8 @@ Module.register("calendar", { } else { timeWrapper.innerHTML = this.capFirst( moment(event.startDate, "x").calendar(null, { - sameDay: "[Today]", - nextDay: "[Tomorrow]", + sameDay: "[" + this.translate("TODAY") + "]", + nextDay: "[" + this.translate("TOMORROW") + "]", nextWeek: "dddd" }) ); From b46160bcbcc8a545c3d9c343f857b759bfe7504c Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:20:16 +0100 Subject: [PATCH 02/15] Simplify weather-compliments test, increase timeWaitout for it --- tests/e2e/modules/weather_spec.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index 4b0944d3..cd386f3c 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -15,7 +15,8 @@ describe("Weather module", function () { async function setup(responses) { app = await helpers.startApplication({ - args: ["js/electron.js"] + args: ["js/electron.js"], + waitTimeout: 100000 }); wdajaxstub.init(app.client, responses); @@ -101,16 +102,7 @@ describe("Weather module", function () { const weather = generateWeather(); await setup({ template, data: weather }); - const wait = (time) => new Promise((resolve) => setTimeout(resolve, time)); - - var text = ""; - do { - await wait(3000); - elem = await app.client.$(".compliments"); - text = await elem.getText(".compliments .module-content span"); - } while (text === ""); - - return expect(text.trim()).to.equal("snow"); + return app.client.waitUntilTextExists(".compliments .module-content span", "snow"); }); }); From dbea348779aba476b78ab226d31c3cfd8b58fce2 Mon Sep 17 00:00:00 2001 From: veeck Date: Wed, 6 Jan 2021 12:41:52 +0100 Subject: [PATCH 03/15] Cleanup port usage in tests --- tests/configs/modules/calendar/auth-default.js | 2 +- tests/configs/modules/calendar/basic-auth.js | 2 +- tests/configs/modules/calendar/fail-basic-auth.js | 2 +- tests/configs/modules/calendar/old-basic-auth.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/configs/modules/calendar/auth-default.js b/tests/configs/modules/calendar/auth-default.js index 0cb29184..dd65c53e 100644 --- a/tests/configs/modules/calendar/auth-default.js +++ b/tests/configs/modules/calendar/auth-default.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8011/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "CallMeADog" diff --git a/tests/configs/modules/calendar/basic-auth.js b/tests/configs/modules/calendar/basic-auth.js index 706e14ca..8937b2a3 100644 --- a/tests/configs/modules/calendar/basic-auth.js +++ b/tests/configs/modules/calendar/basic-auth.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8010/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "CallMeADog", diff --git a/tests/configs/modules/calendar/fail-basic-auth.js b/tests/configs/modules/calendar/fail-basic-auth.js index 7ccb8bce..b5856589 100644 --- a/tests/configs/modules/calendar/fail-basic-auth.js +++ b/tests/configs/modules/calendar/fail-basic-auth.js @@ -28,7 +28,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8020/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "StairwayToHeaven", diff --git a/tests/configs/modules/calendar/old-basic-auth.js b/tests/configs/modules/calendar/old-basic-auth.js index e34954d5..fa7b70f3 100644 --- a/tests/configs/modules/calendar/old-basic-auth.js +++ b/tests/configs/modules/calendar/old-basic-auth.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8012/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", user: "MagicMirror", pass: "CallMeADog" } From 68bc77c81e6f28dfd8f614d1d4949c50b651af76 Mon Sep 17 00:00:00 2001 From: rejas Date: Fri, 5 Feb 2021 22:41:23 +0100 Subject: [PATCH 04/15] Cleanup global-setup code --- tests/e2e/global-setup.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index cce9fc05..ed6217d3 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -20,7 +20,7 @@ global.before(function () { }); exports.getElectronPath = function () { - var electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron"); + let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron"); if (process.platform === "win32") { electronPath += ".cmd"; } @@ -42,9 +42,9 @@ exports.startApplication = function (options) { options.startTimeout = 30000; } - var app = new Application(options); + const app = new Application(options); return app.start().then(function () { - assert.equal(app.isRunning(), true); + assert.strictEqual(app.isRunning(), true); chaiAsPromised.transferPromiseness = app.transferPromiseness; return app; }); @@ -56,6 +56,6 @@ exports.stopApplication = function (app) { } return app.stop().then(function () { - assert.equal(app.isRunning(), false); + assert.strictEqual(app.isRunning(), false); }); }; From efec49bb475e20962f0c1d0df47f72b49e9ccc22 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:22:03 +0100 Subject: [PATCH 05/15] Use es6 notations --- tests/e2e/vendor_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/vendor_spec.js b/tests/e2e/vendor_spec.js index 206ee2ea..bc318b2e 100644 --- a/tests/e2e/vendor_spec.js +++ b/tests/e2e/vendor_spec.js @@ -28,7 +28,7 @@ describe("Vendors", function () { }); describe("Get list vendors", function () { - var vendors = require(__dirname + "/../../vendor/vendor.js"); + const vendors = require(__dirname + "/../../vendor/vendor.js"); Object.keys(vendors).forEach((vendor) => { it(`should return 200 HTTP code for vendor "${vendor}"`, function () { var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor]; From 35f3b315a2370d25c2ddeda52b73a7f948bf70c8 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:22:56 +0100 Subject: [PATCH 06/15] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f22622f1..0c8e29a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ _This release is scheduled to be released on 2021-04-01._ - Moving weather provider specific code and configuration into each provider and making hourly part of the interface. - Bump electron to v11. - Dont update the DOM when a module is not displayed. -- Cleaned up jsdoc. +- Cleaned up jsdoc and tests. ### Removed From bdc4ed4d864a149863d6e9d001595b8a7d5ebdd1 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 22:18:51 +0100 Subject: [PATCH 07/15] Add specific change-port test and fix the others --- .../configs/modules/calendar/changed-port.js | 44 +++++++++++++++++++ .../modules/calendar/fail-basic-auth.js | 2 +- tests/e2e/modules/calendar_spec.js | 25 ++++++----- 3 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 tests/configs/modules/calendar/changed-port.js diff --git a/tests/configs/modules/calendar/changed-port.js b/tests/configs/modules/calendar/changed-port.js new file mode 100644 index 00000000..fa0f7ae7 --- /dev/null +++ b/tests/configs/modules/calendar/changed-port.js @@ -0,0 +1,44 @@ +/* Magic Mirror Test config default calendar with auth by default + * + * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com + * MIT Licensed. + */ + +var config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 12, + units: "metric", + electronOptions: { + webPreferences: { + nodeIntegration: true, + enableRemoteModule: true + } + }, + + modules: [ + { + module: "calendar", + position: "bottom_bar", + config: { + calendars: [ + { + maximumNumberOfDays: 10000, + url: "http://localhost:8010/tests/configs/data/calendar_test.ics", + auth: { + user: "MagicMirror", + pass: "CallMeADog" + } + } + ] + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/configs/modules/calendar/fail-basic-auth.js b/tests/configs/modules/calendar/fail-basic-auth.js index b5856589..7ccb8bce 100644 --- a/tests/configs/modules/calendar/fail-basic-auth.js +++ b/tests/configs/modules/calendar/fail-basic-auth.js @@ -28,7 +28,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8080/tests/configs/data/calendar_test.ics", + url: "http://localhost:8020/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "StairwayToHeaven", diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index 3712871c..8d9b0c5a 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -76,11 +76,11 @@ describe("Calendar module", function () { }); }); - describe("Basic auth", function () { + describe("Changed port", function () { before(function () { serverBasicAuth.listen(8010); // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js"; + process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js"; }); after(function (done) { @@ -92,17 +92,23 @@ describe("Calendar module", function () { }); }); + describe("Basic auth", function () { + before(function () { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js"; + }); + + it("should return TestEvents", function () { + return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); + }); + }); + describe("Basic auth by default", function () { before(function () { - serverBasicAuth.listen(8011); // Set config sample for use in test process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js"; }); - after(function (done) { - serverBasicAuth.close(done()); - }); - it("should return TestEvents", function () { return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); }); @@ -110,15 +116,10 @@ describe("Calendar module", function () { describe("Basic auth backward compatibility configuration: DEPRECATED", function () { before(function () { - serverBasicAuth.listen(8012); // Set config sample for use in test process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js"; }); - after(function (done) { - serverBasicAuth.close(done()); - }); - it("should return TestEvents", function () { return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); }); From 04491ac5aca2176adcbfc773906050e78cc8f8ee Mon Sep 17 00:00:00 2001 From: Krouty Date: Sat, 13 Feb 2021 17:13:00 +0100 Subject: [PATCH 08/15] This is supposed to make self signed certs work with the calendar module Many people use Own-/Nextcloud together witht he https protocol. This is supposed to make self-signed certificates work with the calendar module and fix the issue #466. --- modules/default/calendar/calendarfetcher.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 6c268c46..d4aa7b02 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -50,6 +50,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }, gzip: true }; + + if (selfSignedCert) { + var agentOptions = { + rejectUnauthorized: false + }; + opts.agentOptions = agentOptions; + } if (auth) { if (auth.method === "bearer") { From e2b4823e433b0ccf722cc1442cea04fed528ed4b Mon Sep 17 00:00:00 2001 From: Felix Wiedenbach Date: Tue, 16 Feb 2021 22:06:53 +0100 Subject: [PATCH 09/15] added locale to sample config --- CHANGELOG.md | 1 + config/config.js.sample | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8e29a0..3f9427c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ _This release is scheduled to be released on 2021-04-01._ - Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP. - Respect parameter ColoredSymbolOnly also for custom events - Added a new parameter to hide time portion on relative times +- Added locale to sample config file ### Updated diff --git a/config/config.js.sample b/config/config.js.sample index f775f941..e17ae195 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -28,6 +28,7 @@ var config = { httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true language: "en", + locale: "en-US", logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging timeFormat: 24, units: "metric", From b18d98f5ea3f7f5b9edd161c5d4d6b737309b2ff Mon Sep 17 00:00:00 2001 From: Felix Wiedenbach Date: Thu, 18 Feb 2021 19:14:53 +0100 Subject: [PATCH 10/15] exposed logger as node module --- CHANGELOG.md | 1 + js/app.js | 13 +++++++------ js/electron.js | 2 +- js/node_helper.js | 2 +- js/server.js | 2 +- modules/default/calendar/calendarfetcher.js | 2 +- modules/default/calendar/node_helper.js | 2 +- modules/default/currentweather/node_helper.js | 2 +- modules/default/newsfeed/newsfeedfetcher.js | 2 +- modules/default/newsfeed/node_helper.js | 2 +- modules/default/updatenotification/node_helper.js | 2 +- modules/default/weatherforecast/node_helper.js | 2 +- package.json | 3 ++- serveronly/index.js | 2 +- 14 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9427c8..e0b60007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ _This release is scheduled to be released on 2021-04-01._ - Bump electron to v11. - Dont update the DOM when a module is not displayed. - Cleaned up jsdoc and tests. +- Exposed logger as node module for easier access for 3rd party modules ### Removed diff --git a/js/app.js b/js/app.js index 9cec4902..e5156b19 100644 --- a/js/app.js +++ b/js/app.js @@ -4,16 +4,17 @@ * By Michael Teeuw https://michaelteeuw.nl * MIT Licensed. */ -const fs = require("fs"); -const path = require("path"); -const Log = require(`${__dirname}/logger`); -const Server = require(`${__dirname}/server`); -const Utils = require(`${__dirname}/utils`); -const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`); // Alias modules mentioned in package.js under _moduleAliases. require("module-alias/register"); +const fs = require("fs"); +const path = require("path"); +const Log = require("logger"); +const Server = require(`${__dirname}/server`); +const Utils = require(`${__dirname}/utils`); +const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`); + // Get version number. global.version = require(`${__dirname}/../package.json`).version; Log.log("Starting MagicMirror: v" + global.version); diff --git a/js/electron.js b/js/electron.js index 8df04b68..3e791359 100644 --- a/js/electron.js +++ b/js/electron.js @@ -2,7 +2,7 @@ const electron = require("electron"); const core = require("./app.js"); -const Log = require("./logger.js"); +const Log = require("logger"); // Config let config = process.env.config ? JSON.parse(process.env.config) : {}; diff --git a/js/node_helper.js b/js/node_helper.js index f394d505..81d2d9d5 100644 --- a/js/node_helper.js +++ b/js/node_helper.js @@ -5,7 +5,7 @@ * MIT Licensed. */ const Class = require("./class.js"); -const Log = require("./logger.js"); +const Log = require("logger"); const express = require("express"); const NodeHelper = Class.extend({ diff --git a/js/server.js b/js/server.js index 3c561514..5ce9435d 100644 --- a/js/server.js +++ b/js/server.js @@ -11,7 +11,7 @@ const ipfilter = require("express-ipfilter").IpFilter; const fs = require("fs"); const helmet = require("helmet"); -const Log = require("./logger.js"); +const Log = require("logger"); const Utils = require("./utils.js"); /** diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 6c268c46..55e5cdaa 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -4,7 +4,7 @@ * By Michael Teeuw https://michaelteeuw.nl * MIT Licensed. */ -const Log = require("../../../js/logger.js"); +const Log = require("logger"); const ical = require("node-ical"); const request = require("request"); diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 06fa28ec..c44e91fc 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -7,7 +7,7 @@ const NodeHelper = require("node_helper"); const validUrl = require("valid-url"); const CalendarFetcher = require("./calendarfetcher.js"); -const Log = require("../../../js/logger"); +const Log = require("logger"); module.exports = NodeHelper.create({ // Override start method. diff --git a/modules/default/currentweather/node_helper.js b/modules/default/currentweather/node_helper.js index dd00dc73..d4c7a14c 100644 --- a/modules/default/currentweather/node_helper.js +++ b/modules/default/currentweather/node_helper.js @@ -1,5 +1,5 @@ const NodeHelper = require("node_helper"); -const Log = require("../../../js/logger"); +const Log = require("logger"); module.exports = NodeHelper.create({ // Override start method. diff --git a/modules/default/newsfeed/newsfeedfetcher.js b/modules/default/newsfeed/newsfeedfetcher.js index 20e45258..68ac75ac 100644 --- a/modules/default/newsfeed/newsfeedfetcher.js +++ b/modules/default/newsfeed/newsfeedfetcher.js @@ -4,7 +4,7 @@ * By Michael Teeuw https://michaelteeuw.nl * MIT Licensed. */ -const Log = require("../../../js/logger.js"); +const Log = require("logger"); const FeedMe = require("feedme"); const request = require("request"); const iconv = require("iconv-lite"); diff --git a/modules/default/newsfeed/node_helper.js b/modules/default/newsfeed/node_helper.js index bdfcbfcc..18984f31 100644 --- a/modules/default/newsfeed/node_helper.js +++ b/modules/default/newsfeed/node_helper.js @@ -8,7 +8,7 @@ const NodeHelper = require("node_helper"); const validUrl = require("valid-url"); const NewsfeedFetcher = require("./newsfeedfetcher.js"); -const Log = require("../../../js/logger"); +const Log = require("logger"); module.exports = NodeHelper.create({ // Override start method. diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index 973dca51..a8b75c3e 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -3,7 +3,7 @@ const simpleGits = []; const fs = require("fs"); const path = require("path"); const defaultModules = require(__dirname + "/../defaultmodules.js"); -const Log = require(__dirname + "/../../../js/logger.js"); +const Log = require("logger"); const NodeHelper = require("node_helper"); module.exports = NodeHelper.create({ diff --git a/modules/default/weatherforecast/node_helper.js b/modules/default/weatherforecast/node_helper.js index dd00dc73..d4c7a14c 100644 --- a/modules/default/weatherforecast/node_helper.js +++ b/modules/default/weatherforecast/node_helper.js @@ -1,5 +1,5 @@ const NodeHelper = require("node_helper"); -const Log = require("../../../js/logger"); +const Log = require("logger"); module.exports = NodeHelper.create({ // Override start method. diff --git a/package.json b/package.json index 14303f91..8ca6cd30 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,8 @@ "valid-url": "^1.0.9" }, "_moduleAliases": { - "node_helper": "js/node_helper.js" + "node_helper": "js/node_helper.js", + "logger": "js/logger.js" }, "engines": { "node": ">=10" diff --git a/serveronly/index.js b/serveronly/index.js index 9cc7d942..136eaa00 100644 --- a/serveronly/index.js +++ b/serveronly/index.js @@ -1,5 +1,5 @@ const app = require("../js/app.js"); -const Log = require("../js/logger.js"); +const Log = require("logger"); app.start(function (config) { var bindAddress = config.address ? config.address : "localhost"; From 1aacc37c831aa16b2f61c39fd0452b73f00bf82b Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 10:29:40 +0100 Subject: [PATCH 11/15] Added selfSignedCert as a parameter Added selfSignedCert as a parameter, so that it can be enabled only when it is required. --- modules/default/calendar/calendarfetcher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index d4aa7b02..91d1689b 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -25,9 +25,10 @@ const moment = require("moment"); * @param {number} maximumNumberOfDays The maximum number of days an event should be in the future. * @param {object} auth The object containing options for authentication against the calendar. * @param {boolean} includePastEvents If true events from the past maximumNumberOfDays will be fetched too + * @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs. * @class */ -const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents) { +const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents, selfSignedCert) { const self = this; let reloadTimer = null; From c6aff8b7dcf0c42baae63528b7579dac2ca80aef Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:29:19 +0100 Subject: [PATCH 12/15] Added suppoert for self-signed certificates Added support for self-signed certificates --- modules/default/calendar/calendar.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index a4346c64..2cce00c7 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -58,7 +58,8 @@ Module.register("calendar", { excludedEvents: [], sliceMultiDayEvents: false, broadcastPastEvents: false, - nextDaysRelative: false + nextDaysRelative: false, + selfSignedCert: false }, requiresVersion: "2.1.0", @@ -101,7 +102,8 @@ Module.register("calendar", { var calendarConfig = { maximumEntries: calendar.maximumEntries, maximumNumberOfDays: calendar.maximumNumberOfDays, - broadcastPastEvents: calendar.broadcastPastEvents + broadcastPastEvents: calendar.broadcastPastEvents, + selfSignedCert: calendar.selfSignedCert }; if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) { calendarConfig.symbolClass = ""; @@ -606,7 +608,8 @@ Module.register("calendar", { titleClass: calendarConfig.titleClass, timeClass: calendarConfig.timeClass, auth: auth, - broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents + broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents, + selfSignedCert: calendarConfig.selfSignedCert || this.config.selfSignedCert }); }, From beb5faef8b80048ed4e3410aba0ed099007ba250 Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:32:03 +0100 Subject: [PATCH 13/15] Added support for self-signed certificates Added support for self-signed certificates --- modules/default/calendar/node_helper.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 06fa28ec..3b6e4a55 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -19,7 +19,7 @@ module.exports = NodeHelper.create({ // Override socketNotificationReceived method. socketNotificationReceived: function (notification, payload) { if (notification === "ADD_CALENDAR") { - this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.id); + this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.selfSignedCert, payload.id); } }, @@ -34,9 +34,10 @@ module.exports = NodeHelper.create({ * @param {number} maximumNumberOfDays The maximum number of days an event should be in the future. * @param {object} auth The object containing options for authentication against the calendar. * @param {boolean} broadcastPastEvents If true events from the past maximumNumberOfDays will be included in event broadcasts + * @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs. * @param {string} identifier ID of the module */ - createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, identifier) { + createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert, identifier) { var self = this; if (!validUrl.isUri(url)) { @@ -47,7 +48,7 @@ module.exports = NodeHelper.create({ var fetcher; if (typeof self.fetchers[identifier + url] === "undefined") { Log.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval); - fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents); + fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert); fetcher.onReceive(function (fetcher) { self.sendSocketNotification("CALENDAR_EVENTS", { From 1db0dbf52bae6cff399e3d3380bdfd5c0c6d189c Mon Sep 17 00:00:00 2001 From: Krouty Date: Sun, 21 Feb 2021 11:45:15 +0100 Subject: [PATCH 14/15] Added support for self-signed certificates Added support for self-signed certificates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8e29a0..b08ff58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ _This release is scheduled to be released on 2021-04-01._ - Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP. - Respect parameter ColoredSymbolOnly also for custom events - Added a new parameter to hide time portion on relative times +- Added support for self-signed certificates for the default calendar module (#466) ### Updated From 5b270b84b4dc1a65313923b70595315532071997 Mon Sep 17 00:00:00 2001 From: config Date: Sun, 21 Feb 2021 19:56:02 +0100 Subject: [PATCH 15/15] linted calendarfetcher.js --- modules/default/calendar/calendarfetcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 91d1689b..92c6d38f 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -51,12 +51,12 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }, gzip: true }; - + if (selfSignedCert) { var agentOptions = { rejectUnauthorized: false }; - opts.agentOptions = agentOptions; + opts.agentOptions = agentOptions; } if (auth) {