From 92a35692f2526d9cc898026f9bdb35b346aceaa6 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Tue, 2 Mar 2021 00:40:55 +0100 Subject: [PATCH] snapshot --- modules/default/calendar/calendarfetcher.js | 21 +++++++++++---------- package.json | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index b0849da7..e4748cf7 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -6,7 +6,7 @@ */ const Log = require("logger"); const ical = require("node-ical"); -const fetch = require("node-fetch"); +const fetch = require("digest-fetch"); const https = require('https'); /** @@ -45,6 +45,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn clearTimeout(reloadTimer); reloadTimer = null; httpsAgent = null; + user = ""; + password = ""; const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]); const headers = { @@ -59,22 +61,21 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn // todo: auth, // https://github.com/devfans/digest-fetch +// https://github.com/pablopunk/auth-fetch/blob/master/index.js // https://hackersandslackers.com/making-api-requests-with-nodejs/ if (auth) { if (auth.method === "bearer") { - opts.auth = { - bearer: auth.pass - }; + // opts.auth = { + // bearer: auth.pass + // }; } else { - opts.auth = { - user: auth.user, - pass: auth.pass, - sendImmediately: auth.method !== "digest" - }; + user = auth.user; + password = auth.pass; } } - fetch(url, { headers: headers, httpsAgent: httpsAgent }) + const client = new fetch(user, password) ; + client.fetch(url, { headers: headers, httpsAgent: httpsAgent }) .catch(error => { fetchFailedCallback(self, error); scheduleTimer(); diff --git a/package.json b/package.json index 97e52710..43add524 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "dependencies": { "colors": "^1.4.0", "console-stamp": "^3.0.0-rc4.2", + "digest-fetch": "^1.1.6", "eslint": "^7.19.0", "express": "^4.17.1", "express-ipfilter": "^1.1.2",