caldav-adapter 9.3.10 → 9.3.12

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.
Files changed (2) hide show
  1. package/index.js +28 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -44,17 +44,20 @@ module.exports = function (options) {
44
44
  principalRegex.keys
45
45
  );
46
46
 
47
- const calendarRoutes = cal({
48
- logEnabled: options.logEnabled,
49
- logLevel: options.logLevel,
50
- data: options.data
51
- });
52
-
53
- const principalRoutes = pri({
54
- logEnabled: options.logEnabled,
55
- logLevel: options.logLevel,
56
- data: options.data
57
- });
47
+ //
48
+ // IMPORTANT: forward the *entire* options object (not just `data`,
49
+ // `logEnabled`, and `logLevel`) so that downstream tag handlers
50
+ // (common/tags.js) receive `pushTopicProvider`, `pushSubscriptionURL`,
51
+ // `pushEnv`, and `pushRefreshInterval`. Without this, iOS Calendar
52
+ // never sees the <CS:push-transports> advertisement on the calendar
53
+ // home and never POSTs to /apns to register for silent push (the
54
+ // tags handler short-circuits via `typeof options.pushTopicProvider
55
+ // !== 'function'`). See Apple's caldav-pubsubdiscovery.txt:
56
+ // https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt
57
+ //
58
+ const calendarRoutes = cal(options);
59
+
60
+ const principalRoutes = pri(options);
58
61
 
59
62
  const fillParameters = function (ctx) {
60
63
  ctx.state.params = {};
@@ -123,20 +126,31 @@ module.exports = function (options) {
123
126
  const fillRoutes = function (ctx) {
124
127
  ctx.state.principalRootUrl = principalRoute;
125
128
  if (ctx.state.params.principalId) {
129
+ // Encode @ as %40 in principalId for URL construction.
130
+ // iOS/macOS URL parser treats bare @ in path segments as a userinfo
131
+ // separator (RFC 3986 §3.2.1), which corrupts the request URL and
132
+ // causes events to silently not appear in Apple Calendar.
133
+ // All URLs returned by the server (calendar-home-set, principal-URL,
134
+ // schedule-inbox-URL, event hrefs, etc.) must use %40 so that Apple
135
+ // clients send subsequent requests with the encoded form.
136
+ const encodedPrincipalId = ctx.state.params.principalId.replaceAll(
137
+ '@',
138
+ '%40'
139
+ );
126
140
  ctx.state.calendarHomeUrl = path.join(
127
141
  calendarRoute,
128
- ctx.state.params.principalId,
142
+ encodedPrincipalId,
129
143
  '/'
130
144
  );
131
145
  ctx.state.principalUrl = path.join(
132
146
  principalRoute,
133
- ctx.state.params.principalId,
147
+ encodedPrincipalId,
134
148
  '/'
135
149
  );
136
150
  if (ctx.state.params.calendarId) {
137
151
  ctx.state.calendarUrl = path.join(
138
152
  calendarRoute,
139
- ctx.state.params.principalId,
153
+ encodedPrincipalId,
140
154
  ctx.state.params.calendarId,
141
155
  '/'
142
156
  );
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.10",
4
+ "version": "9.3.12",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",