Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coozzy/cal-dav

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coozzy/cal-dav - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/index.d.ts

@@ -13,2 +13,3 @@ import * as ICAL from 'ical.js';

listEventsInTimeRange(startDate: Date, endDate?: Date): Promise<ICAL.Event[]>;
multiGetEvents(eventUrls: string[]): Promise<ICAL.Event[]>;
}

@@ -24,4 +25,5 @@ export declare class DefaultCalDavClient {

listEventsInTimeRange: (startDate: Date, endDate?: Date) => Promise<ICAL.Event[]>;
multiGetEvents: (eventUrls: string[]) => Promise<ICAL.Event[]>;
createEvent: (eventUrl: string, id: string, referenceIds: string[], title: string, description: string, location: string, startDate: any, endDate: any, attendees: Attendee[], categories: string[]) => Promise<void>;
updateEvent: (eventUrl: string, event: any, referenceIds: string[], title: string, description: string, location: string, startDate: any, endDate: any, attendees: Attendee[], categories: string[]) => Promise<void>;
}

117

dist/index.js

@@ -136,3 +136,3 @@ "use strict";

this.listAllEvents = function () { return __awaiter(_this, void 0, void 0, function () {
var response, events, eventsData, _i, eventsData_1, eventData, calData, comp, vevents, i, urlParts, e_4;
var response, e_4;
return __generator(this, function (_a) {

@@ -145,24 +145,5 @@ switch (_a.label) {

response = _a.sent();
events = [];
if (!(response.status === 207)) return [3 /*break*/, 3];
return [4 /*yield*/, this.parser.parseListOfEvents(response.data)];
case 2:
eventsData = _a.sent();
if (eventsData.length) {
for (_i = 0, eventsData_1 = eventsData; _i < eventsData_1.length; _i++) {
eventData = eventsData_1[_i];
calData = ICAL.parse(eventData.event);
comp = new ICAL.Component(calData);
vevents = comp.getAllSubcomponents('vevent');
events.push.apply(events, vevents);
}
}
events = events.map(function (event) { return new ICAL.Event(event); });
for (i = 0; i < events.length; i++) {
urlParts = eventsData[i].url.split('/');
events[i].component.addPropertyWithValue('url', urlParts[urlParts.length - 1]);
/* eslint-enable security/detect-object-injection */
}
logger_1["default"].info('CalDavClient.ListAllEvents: Successfully listed all events. ');
return [2 /*return*/, events];
return [4 /*yield*/, this.parseListOfEvents(response.data, 'ListAllEvents')];
case 2: return [2 /*return*/, _a.sent()];
case 3: return [2 /*return*/, []];

@@ -178,37 +159,39 @@ case 4:

this.listEventsInTimeRange = function (startDate, endDate) { return __awaiter(_this, void 0, void 0, function () {
var response, events, eventsData, _i, eventsData_2, eventData, calData, comp, vevents, i, urlParts, e_5;
var response, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.service.listEventsInTimeRange(startDate, endDate)];
case 1:
response = _a.sent();
events = [];
if (!(response.status === 207)) return [3 /*break*/, 3];
return [4 /*yield*/, this.parser.parseListOfEvents(response.data)];
if (response.status === 207) {
return [2 /*return*/, this.parseListOfEvents(response.data, 'ListEventsInTimeRange')];
}
return [2 /*return*/, []];
case 2:
eventsData = _a.sent();
if (eventsData.length) {
for (_i = 0, eventsData_2 = eventsData; _i < eventsData_2.length; _i++) {
eventData = eventsData_2[_i];
calData = ICAL.parse(eventData.event);
comp = new ICAL.Component(calData);
vevents = comp.getAllSubcomponents('vevent');
events.push.apply(events, vevents);
}
}
events = events.map(function (event) { return new ICAL.Event(event); });
for (i = 0; i < events.length; i++) {
urlParts = eventsData[i].url.split('/');
events[i].component.addPropertyWithValue('url', urlParts[urlParts.length - 1]);
/* eslint-enable security/detect-object-injection */
}
logger_1["default"].info("CalDavClient.ListEventsInTimRange: Successfully listed events in time range " + startDate + " - " + (endDate ? endDate : '') + ". ");
return [2 /*return*/, events];
case 3: return [2 /*return*/, []];
case 4:
e_5 = _a.sent();
logger_1["default"].error("CalDavClient.ListEventsInTimRange: " + e_5.message + ". ");
return [2 /*return*/, []];
case 3: return [2 /*return*/];
}
});
}); };
this.multiGetEvents = function (eventUrls) { return __awaiter(_this, void 0, void 0, function () {
var response, e_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
return [4 /*yield*/, this.service.multiGetEvents(eventUrls)];
case 1:
response = _a.sent();
if (!(response.status === 207)) return [3 /*break*/, 3];
return [4 /*yield*/, this.parseListOfEvents(response.data, 'MultiGetEvents')];
case 2: return [2 /*return*/, _a.sent()];
case 3: return [2 /*return*/, []];
case 4:
e_6 = _a.sent();
logger_1["default"].error("CalDavClient.ListEventsInTimRange: " + e_6.message + ". ");
return [2 /*return*/, []];
case 5: return [2 /*return*/];

@@ -219,3 +202,3 @@ }

this.createEvent = function (eventUrl, id, referenceIds, title, description, location, startDate, endDate, attendees, categories) { return __awaiter(_this, void 0, void 0, function () {
var calendar, event_3, _i, categories_1, category, categoriesProperty, eventString, e_6;
var calendar, event_3, _i, categories_1, category, categoriesProperty, eventString, e_7;
return __generator(this, function (_a) {

@@ -258,4 +241,4 @@ switch (_a.label) {

case 2:
e_6 = _a.sent();
logger_1["default"].error("CalDavClient.CreateEvent: " + e_6.message + ". ");
e_7 = _a.sent();
logger_1["default"].error("CalDavClient.CreateEvent: " + e_7.message + ". ");
return [3 /*break*/, 3];

@@ -267,3 +250,3 @@ case 3: return [2 /*return*/];

this.updateEvent = function (eventUrl, event, referenceIds, title, description, location, startDate, endDate, attendees, categories) { return __awaiter(_this, void 0, void 0, function () {
var _i, categories_2, category, categoriesProperty, eventString, e_7;
var _i, categories_2, category, categoriesProperty, eventString, e_8;
return __generator(this, function (_a) {

@@ -302,4 +285,4 @@ switch (_a.label) {

case 2:
e_7 = _a.sent();
logger_1["default"].error("CalDavClient.UpdateEvent: " + e_7.message + ". ");
e_8 = _a.sent();
logger_1["default"].error("CalDavClient.UpdateEvent: " + e_8.message + ". ");
return [3 /*break*/, 3];

@@ -310,2 +293,30 @@ case 3: return [2 /*return*/];

}); };
this.parseListOfEvents = function (responseData, method) { return __awaiter(_this, void 0, void 0, function () {
var eventsData, events, _i, eventsData_1, eventData, calData, comp, vevents, i, urlParts;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.parser.parseListOfEvents(responseData)];
case 1:
eventsData = _a.sent();
events = [];
if (eventsData.length) {
for (_i = 0, eventsData_1 = eventsData; _i < eventsData_1.length; _i++) {
eventData = eventsData_1[_i];
calData = ICAL.parse(eventData.event);
comp = new ICAL.Component(calData);
vevents = comp.getAllSubcomponents('vevent');
events.push.apply(events, vevents);
}
}
events = events.map(function (event) { return new ICAL.Event(event); });
for (i = 0; i < events.length; i++) {
urlParts = eventsData[i].url.split('/');
events[i].component.addPropertyWithValue('url', urlParts[urlParts.length - 1]);
/* eslint-enable security/detect-object-injection */
}
logger_1["default"].debug(method + ": events successfully parsed.");
return [2 /*return*/, events];
}
});
}); };
this.service = service || new caldav_service_1.DefaultCalDavService(username, password, calendarUrl);

@@ -312,0 +323,0 @@ this.parser = parser || new caldav_parser_1.DefaultCalDavParser();

@@ -9,2 +9,3 @@ import { AxiosResponse, AxiosInstance } from 'axios';

listEventsInTimeRange(startDate: Date, endDate?: Date): Promise<AxiosResponse>;
multiGetEvents(eventUrls: string[]): Promise<AxiosResponse>;
getCtag(): Promise<AxiosResponse>;

@@ -25,4 +26,6 @@ getEtags(): Promise<AxiosResponse>;

listEventsInTimeRange: (startDate: Date, endDate?: Date) => Promise<AxiosResponse<any>>;
multiGetEvents: (eventUrls: string[]) => Promise<AxiosResponse<any>>;
getCtag: () => Promise<AxiosResponse<any>>;
getEtags: () => Promise<AxiosResponse<any>>;
private multiGetSetRequestUrls;
}

@@ -200,2 +200,25 @@ "use strict";

}); };
this.multiGetEvents = function (eventUrls) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.axios.request({
method: 'REPORT',
url: this.calendarUrl,
headers: {
'Prefer': 'return-minimal',
'Content-type': 'application/xml; charset=utf-8'
},
data: "<C:calendar-multiget xmlns:D=\"DAV:\"\n xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n <D:prop>\n <D:getetag/>\n <C:calendar-data/>\n </D:prop>\n " + this.multiGetSetRequestUrls(eventUrls) + "\n </C:calendar-multiget>",
auth: {
username: this.username,
password: this.password
}
})];
case 1:
// Method for getting multiple by their url
// Response status upon successfull request is 207
return [2 /*return*/, _a.sent()];
}
});
}); };
this.getCtag = function () { return __awaiter(_this, void 0, void 0, function () {

@@ -269,4 +292,12 @@ return __generator(this, function (_a) {

}
DefaultCalDavService.prototype.multiGetSetRequestUrls = function (eventUrls) {
var data = '';
for (var _i = 0, eventUrls_1 = eventUrls; _i < eventUrls_1.length; _i++) {
var url = eventUrls_1[_i];
data += "<D:href>" + url + "</D:href>\r\n";
}
return data;
};
return DefaultCalDavService;
}());
exports.DefaultCalDavService = DefaultCalDavService;
{
"name": "@coozzy/cal-dav",
"version": "1.0.0",
"version": "1.1.0",
"description": "Simple cal dav client.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc