natelindev / tsdav

WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser
https://tsdav.vercel.app
MIT License
236 stars 38 forks source link

can't not fetchCalendarObjects from caldav.wecom.work #221

Open quanru opened 3 days ago

quanru commented 3 days ago
import { createDAVClient } from 'tsdav';

(async () => {
  const client = await createDAVClient({
    serverUrl: 'https://caldav.wecom.work',
    credentials: {
      username: 'linyibing@lifeos1.wecom.work',
      password: 'FtBpSvuc69SYzgSB',
    },
    authMethod: 'Basic',
    defaultAccountType: 'caldav',
  });

  const calendars = await client.fetchCalendars();
  console.log('calendars: ', calendars);

  const calendar = calendars[0];

  const calendarObjects = await client.fetchCalendarObjects({
    calendar: calendar,
    expand: true,
  });

  console.log(JSON.stringify(calendarObjects, null, 2));
})().catch(error => {
  console.error('error:', error);
});
DEBUG=* node tsdav.mjs
Debugger attached.
  tsdav:authHelper Basic auth token generated: bGlueWliaW5nQGxpZmVvczEud2Vjb20ud29yazpGdEJwU3Z1YzY5U1l6Z1NC +0ms
  tsdav:account Service discovery... +0ms
  tsdav:account Service discovery redirected to https://caldav.wecom.work/calendar/ +587ms
  tsdav:account Fetching principal url from path https://caldav.wecom.work/calendar/ +1ms
  tsdav:account Fetched principal url /calendar/linyibing%40lifeos1.wecom.work +523ms
  tsdav:account Fetch home url from https://caldav.wecom.work/calendar/linyibing%40lifeos1.wecom.work +0ms
  tsdav:account Fetched home url https://caldav.wecom.work/calendar/ +480ms
calendars:  [
  {
    description: 'linyibing@lifeos1.wecom.work',
    timezone: 'BEGIN:VTIMEZONE\r\n' +
      'TZID:Asia/Shanghai\r\n' +
      'X-LIC-LOCATION:Asia/Shanghai\r\n' +
      'BEGIN:STANDARD\r\n' +
      'TZOFFSETFROM:+0800\r\n' +
      'TZOFFSETTO:+0800\r\n' +
      'TZNAME:CST\r\n' +
      'DTSTART:19700101T000000\r\n' +
      'END:STANDARD\r\n' +
      'END:VTIMEZONE',
    url: 'https://caldav.wecom.work/calendar/1688855375594291/',
    ctag: 1731112901,
    calendarColor: '#2d8eff',
    displayName: 'xxx',
    components: [ 'VEVENT' ],
    resourcetype: [ 'collection', 'calendar' ],
    syncToken: 'http://dav.exmail.qq.com/ns/sync-token/1731112901',
    projectedProps: {},
    reports: [ 'expandProperty', 'syncCollection' ]
  }
]
  tsdav:calendar Fetching calendar objects from https://caldav.wecom.work/calendar/1688855375594291/ +0ms
[
  {
    "url": "https://caldav.wecom.work/calendar/1688855375594291/",
    "etag": "[object Object]",
    "data": {}
  },
  {
    "url": "https://caldav.wecom.work/calendar/1688855375594291/f3a370bed921ec2bce27ca8111b25f15uprduwqs.ics",
    "etag": "1731113340",
    "data": {}
  }
]
quanru commented 2 days ago

I can manually download content of https://caldav.wecom.work/calendar/1688855375594291/f3a370bed921ec2bce27ca8111b25f15uprduwqs.ics:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Tencent Inc.//QQMail//CalDAV v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:TZ08
BEGIN:STANDARD
DTSTART:19700101T000000
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:f3a370bed921ec2bce27ca8111b25f15uprduwqs
DTSTAMP:20241109T084900
CREATED:20241109T084141
SEQUENCE:4723483
DTSTART;TZID=TZ08:20241109T090000
DTEND;TZID=TZ08:20241109T100000
SUMMARY:企业微信日历调试
ORGANIZER;CN="林宜丙":mailto:linyibing@lifeos1.wecom.work
TRANSP:OPAQUE
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR