lambdabaa / dav

WebDAV, CalDAV, and CardDAV client for nodejs and the browser.
Mozilla Public License 2.0
304 stars 71 forks source link

Not working against SOGo caldav server #88

Open matthiasg opened 9 years ago

matthiasg commented 9 years ago

I cannot get this to work against a test SOGo server that we setup (Caldav applications on android work against it):

var dav = require('dav');

dav.debug.enabled = true;

var xhr = new dav.transport.Basic(
  new dav.Credentials({
    username: 'sogo1',
    password: 'xxxxxxx'
  })
);

dav.createAccount({
  server: 'https://sogo.mydomain.com/SOGo/dav/sogo1/', // This url is defined by SOGo to include the username (also tried without)
  xhr: xhr })
.then(function(account) {
  console.log(account);
  // account instanceof dav.Account
  account.calendars.forEach(function(calendar) {
    console.log('Found calendar named ' + calendar.displayName);
    // etc.
  });
})
.catch(function(err){
  console.log("ERROR", err);
});

tried with 'iojs and nodejs (using bluebird for Promise)'

Error Message:

ERROR [TypeError: Cannot read property 'props' of undefined]

Debug Output:

[dav:accounts] Attempt service discovery.
[dav:xmlhttprequest] Sending request data: undefined
[dav:accounts] Discovery failed... failover to the provided url
[dav:accounts] Fetch principal url from context path https://sogo.mydomain.com/SOGo/dav/sogo1/.
[dav:xmlhttprequest] Sending request data: <d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"
              xmlns:card="urn:ietf:params:xml:ns:carddav"
              xmlns:cs="http://calendarserver.org/ns/"
              xmlns:d="DAV:">
    <d:prop>
      <d:current-user-principal />
    </d:prop>
  </d:propfind>
[dav:parser] Unexpected node of type href encountered while parsing response node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type currentUserPrincipal encountered while parsing prop node!
[dav:parser] input:
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:"><D:response><D:href>/SOGo/dav/sogo1/</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status><D:prop><D:current-user-principal xmlns:D="DAV:"><D:href>/SOGo/dav/sogo1</D:href></D:current-user-principal></D:prop></D:propstat></D:response></D:multistatus>
output:
{"response":[{"propstat":[{"status":"HTTP/1.1 200 OK","prop":{"currentUserPrincipal":"/SOGo/dav/sogo1"}}],"href":"/SOGo/dav/sogo1/"}]}

[dav:accounts] Received principal: /SOGo/dav/sogo1
[dav:accounts] Fetch home url from principal url https://sogo.mydomain.com/SOGo/dav/sogo1.
[dav:xmlhttprequest] Sending request data: <d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"
              xmlns:card="urn:ietf:params:xml:ns:carddav"
              xmlns:cs="http://calendarserver.org/ns/"
              xmlns:d="DAV:">
    <d:prop>
      <c:calendar-home-set />
    </d:prop>
  </d:propfind>
[dav:parser] Unexpected node of type href encountered while parsing response node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type calendarHomeSet encountered while parsing prop node!
[dav:parser] Unexpected node of type href encountered while parsing response node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type calendarHomeSet encountered while parsing prop node!
[dav:parser] Unexpected node of type href encountered while parsing response node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type calendarHomeSet encountered while parsing prop node!
[dav:parser] Unexpected node of type href encountered while parsing response node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type status encountered while parsing propstat node!
[dav:parser] Unexpected node of type calendarHomeSet encountered while parsing prop node!
[dav:parser] input:
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:a="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:"><D:response><D:href>/SOGo/dav/sogo1/freebusy.ifb</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status><D:prop></D:prop></D:propstat><D:propstat><D:status>HTTP/1.1 404 Not Found</D:status><D:prop><a:calendar-home-set/></D:prop></D:propstat></D:response><D:response><D:href>/SOGo/dav/sogo1/Calendar</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status><D:prop></D:prop></D:propstat><D:propstat><D:status>HTTP/1.1 404 Not Found</D:status><D:prop><a:calendar-home-set/></D:prop></D:propstat></D:response><D:response><D:href>/SOGo/dav/sogo1/Contacts</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status><D:prop></D:prop></D:propstat><D:propstat><D:status>HTTP/1.1 404 Not Found</D:status><D:prop><a:calendar-home-set/></D:prop></D:propstat></D:response><D:response><D:href>/SOGo/dav/sogo1/Mail</D:href><D:propstat><D:status>HTTP/1.1 200 OK</D:status><D:prop></D:prop></D:propstat><D:propstat><D:status>HTTP/1.1 404 Not Found</D:status><D:prop><a:calendar-home-set/></D:prop></D:propstat></D:response></D:multistatus>
output:
{"response":[{"propstat":[{"status":"HTTP/1.1 200 OK","prop":{}},{"status":"HTTP/1.1 404 Not Found","prop":{"calendarHomeSet":""}}],"href":"/SOGo/dav/sogo1/freebusy.ifb"},{"propstat":[{"status":"HTTP/1.1 200 OK","prop":{}},{"status":"HTTP/1.1 404 Not Found","prop":{"calendarHomeSet":""}}],"href":"/SOGo/dav/sogo1/Calendar"},{"propstat":[{"status":"HTTP/1.1 200 OK","prop":{}},{"status":"HTTP/1.1 404 Not Found","prop":{"calendarHomeSet":""}}],"href":"/SOGo/dav/sogo1/Contacts"},{"propstat":[{"status":"HTTP/1.1 200 OK","prop":{}},{"status":"HTTP/1.1 404 Not Found","prop":{"calendarHomeSet":""}}],"href":"/SOGo/dav/sogo1/Mail"}]}

ERROR [TypeError: Cannot read property 'props' of undefined]

Dont know about the protocol yet to make sense of this .. Any pointers or hints are appreciated.

Goal is to read calendar and add/edit appointments etc...

matthiasg commented 9 years ago

I can setup a live sogo Test Server for testing if required or helpful..

matthiasg commented 9 years ago

Ok looking at this some more i see that SOGo does return a few responses for the initial account query. this returns 4 urls (/SOGo/dav/sogo1/freebusy.ifb, .../Calendar/, .../Contacts/ and ../Mail/) on that a find is performed which doesnt find anything applicable and thus fails

response = responses.find(function (response) {
          return (0, _fuzzy_url_equals2['default'])(account.principalUrl, response.href);
        });

orginal code

  let response = responses.find(response => {
    return fuzzyUrlEquals(account.principalUrl, response.href);
  });
lambdabaa commented 9 years ago

@matthiasg A live server would be very helpful!

matthiasg commented 9 years ago

https://sogo.curasystems.com sogo3 / 7neSSUhN. The server is not configured to send mail or anything yet.. but its sufficient for testing. Its an OOB setup based on their virtual appliance.

i will leave it open for now.

fondberg commented 8 years ago

Any news on this?

wankdanker commented 6 years ago

@lipanski's branch https://github.com/lipanski/dav/commit/4bddb8b478948556a14b3f80f73711f366ce92b8 appears to work with SOGo at first glance.