This commit is contained in:
Karsten Hassel 2021-03-02 00:40:55 +01:00
parent 53e300bd31
commit 92a35692f2
2 changed files with 12 additions and 10 deletions

View File

@ -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();

View File

@ -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",