caldav-adapter 9.3.8 → 9.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/tags.js +109 -0
- package/package.json +1 -1
package/common/tags.js
CHANGED
|
@@ -511,6 +511,115 @@ module.exports = function (options) {
|
|
|
511
511
|
},
|
|
512
512
|
'notification-URL': {
|
|
513
513
|
doc: 'https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-notifications.txt'
|
|
514
|
+
},
|
|
515
|
+
'push-transports': {
|
|
516
|
+
// https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt
|
|
517
|
+
doc: 'https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt',
|
|
518
|
+
async resp({ resource, calendar, ctx }) {
|
|
519
|
+
//
|
|
520
|
+
// Apple's caldav-pubsubdiscovery.txt places <CS:push-transports>
|
|
521
|
+
// on the principal AND on the calendar-home (see the spec's
|
|
522
|
+
// examples which target the calendar-home-set, and the Cyrus
|
|
523
|
+
// implementation in imap/http_caldav.c which advertises it on
|
|
524
|
+
// the home). In this adapter, the calendar-home resource is
|
|
525
|
+
// named `calCollection` (see routes/calendar/user/propfind.js),
|
|
526
|
+
// the per-collection resource is `calendar`, and the principal
|
|
527
|
+
// resource is `principal`.
|
|
528
|
+
//
|
|
529
|
+
// Previously this guard accepted only `principal` and `calendar`,
|
|
530
|
+
// which meant iOS Calendar (which queries push-transports on the
|
|
531
|
+
// calendar-home, NOT on individual collections) never saw the
|
|
532
|
+
// advertisement and consequently never POST'd to the subscription
|
|
533
|
+
// URL to register for push notifications. We now also accept
|
|
534
|
+
// `calCollection`.
|
|
535
|
+
//
|
|
536
|
+
if (
|
|
537
|
+
resource !== 'principal' &&
|
|
538
|
+
resource !== 'calendar' &&
|
|
539
|
+
resource !== 'calCollection'
|
|
540
|
+
)
|
|
541
|
+
return;
|
|
542
|
+
if (typeof options.pushTopicProvider !== 'function') return;
|
|
543
|
+
let topic;
|
|
544
|
+
try {
|
|
545
|
+
topic = await options.pushTopicProvider({
|
|
546
|
+
resource,
|
|
547
|
+
calendar,
|
|
548
|
+
ctx
|
|
549
|
+
});
|
|
550
|
+
} catch (err) {
|
|
551
|
+
log.warn('pushTopicProvider threw', err);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (!topic) return;
|
|
556
|
+
const subscriptionURL =
|
|
557
|
+
(typeof options.pushSubscriptionURL === 'string' &&
|
|
558
|
+
options.pushSubscriptionURL) ||
|
|
559
|
+
'/apns';
|
|
560
|
+
const pushEnv =
|
|
561
|
+
(typeof options.pushEnv === 'string' && options.pushEnv) ||
|
|
562
|
+
'PRODUCTION';
|
|
563
|
+
const refreshInterval =
|
|
564
|
+
(typeof options.pushRefreshInterval === 'string' &&
|
|
565
|
+
options.pushRefreshInterval) ||
|
|
566
|
+
'3600';
|
|
567
|
+
return {
|
|
568
|
+
[buildTag(cs, 'push-transports')]: {
|
|
569
|
+
[buildTag(cs, 'transport')]: {
|
|
570
|
+
'@type': 'APSD',
|
|
571
|
+
[buildTag(cs, 'subscription-url')]: {
|
|
572
|
+
[buildTag(dav, 'href')]: subscriptionURL
|
|
573
|
+
},
|
|
574
|
+
[buildTag(cs, 'apsbundleid')]: topic,
|
|
575
|
+
[buildTag(cs, 'env')]: pushEnv,
|
|
576
|
+
[buildTag(cs, 'refresh-interval')]: refreshInterval
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
pushkey: {
|
|
583
|
+
// https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt
|
|
584
|
+
doc: 'https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt',
|
|
585
|
+
async resp({ resource, calendar, ctx }) {
|
|
586
|
+
if (typeof options.pushTopicProvider !== 'function') return;
|
|
587
|
+
//
|
|
588
|
+
// Per Apple's caldav-pubsubdiscovery.txt the calendar-home itself
|
|
589
|
+
// also exposes a <CS:pushkey> covering home-level changes
|
|
590
|
+
// (calendar add/delete, principal property changes). iOS
|
|
591
|
+
// subscribes to that key so it can react to home-level mutations
|
|
592
|
+
// without having to subscribe to every individual calendar.
|
|
593
|
+
//
|
|
594
|
+
// We use the calendar identifier as the per-collection key and
|
|
595
|
+
// the principal id as the home-level key. These opaque values
|
|
596
|
+
// are echoed back to us by iOS in the /apns POST/GET, allowing
|
|
597
|
+
// us to map (device_token, key) -> (user, calendar|home).
|
|
598
|
+
//
|
|
599
|
+
let key;
|
|
600
|
+
if (resource === 'calendar' && calendar) {
|
|
601
|
+
key =
|
|
602
|
+
calendar.calendarId ||
|
|
603
|
+
(calendar._id &&
|
|
604
|
+
calendar._id.toString &&
|
|
605
|
+
calendar._id.toString()) ||
|
|
606
|
+
'';
|
|
607
|
+
} else if (resource === 'calCollection') {
|
|
608
|
+
key =
|
|
609
|
+
(ctx &&
|
|
610
|
+
ctx.state &&
|
|
611
|
+
ctx.state.params &&
|
|
612
|
+
ctx.state.params.principalId) ||
|
|
613
|
+
'';
|
|
614
|
+
} else {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (!key) return;
|
|
619
|
+
return {
|
|
620
|
+
[buildTag(cs, 'pushkey')]: key
|
|
621
|
+
};
|
|
622
|
+
}
|
|
514
623
|
}
|
|
515
624
|
},
|
|
516
625
|
[ical]: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-adapter",
|
|
3
3
|
"description": "CalDAV server for Node.js and Koa. Modernized and maintained for Forward Email.",
|
|
4
|
-
"version": "9.3.
|
|
4
|
+
"version": "9.3.10",
|
|
5
5
|
"author": "Sanders DeNardi and Forward Email LLC",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
|