{"_id":"@blmarket/dav","_rev":"3-a72d44b08cac54314afbd9479d27bce6","name":"@blmarket/dav","description":"WebDAV, CalDAV, and CardDAV client for nodejs and the browser","dist-tags":{"latest":"1.7.8"},"versions":{"1.7.8":{"name":"@blmarket/dav","version":"1.7.8","author":{"name":"Gareth Aye [:gaye]","email":"gaye@mozilla.com"},"description":"WebDAV, CalDAV, and CardDAV client for nodejs and the browser","license":"MPL-2.0","main":"./dav.js","repository":{"type":"git","url":"git+https://github.com/blmarket/dav.git"},"keywords":["address book","calendar","contacts","dav","caldav","carddav","webdav","ical","vcard","sync","rfc 4791","rfc 6352","rfc 6578"],"dependencies":{"co":"^4.6.0","xmldom":"^0.1.19","xmlhttprequest":"^1.7.0"},"devDependencies":{"babel":"^5.8.23","browserify":"^11.0.1","chai":"^3.2.0","doctoc":"^0.15.0","mocha":"^2.3.2","nock":"^2.10.0","sinon":"^1.16.1","tcp-port-used":"^0.1.2","uglify-js":"^2.4.24"},"scripts":{"test":"make test"},"gitHead":"5d04d303d866a03e2a9c925e0236051bf725e3a2","bugs":{"url":"https://github.com/blmarket/dav/issues"},"homepage":"https://github.com/blmarket/dav#readme","_id":"@blmarket/dav@1.7.8","_shasum":"1a1a6cf12aaab76c4f7f1cb4a0488d33b8faf6c3","_from":".","_npmVersion":"3.5.3","_nodeVersion":"5.4.1","_npmUser":{"name":"blmarket","email":"blmarket@gmail.com"},"dist":{"shasum":"1a1a6cf12aaab76c4f7f1cb4a0488d33b8faf6c3","tarball":"https://registry.npmjs.org/@blmarket/dav/-/dav-1.7.8.tgz","integrity":"sha512-Syy6lYm6qFuogH2klFAvoTZCujuyWPgIKdJ41p/okk6GiCeYaQJliRQb6llkSke2N2/8v9VOhqjim2b0MpWT3Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEWG5tNTUb284pEnbaOUngyDtSbj1v28HyFIuVklZDK3AiEAuFiaOQ56ZWgIID1BELNEoPWCncHnNYrWgj6/r1Ga3Nw="}]},"maintainers":[{"name":"blmarket","email":"blmarket@gmail.com"}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/dav-1.7.8.tgz_1457151983728_0.21647836733609438"}}},"readme":"dav\n===\n\n[![Build Status](https://travis-ci.org/gaye/dav.png?branch=master)](https://travis-ci.org/gaye/dav)\n\nWebDAV, CalDAV, and CardDAV client for nodejs and the browser.\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n**Table of Contents**  *generated with [DocToc](http://doctoc.herokuapp.com/)*\n\n- [API](#api)\n  - [accounts](#accounts)\n    - [dav.createAccount(options)](#davcreateaccountoptions)\n  - [calendars](#calendars)\n    - [dav.createCalendarObject(calendar, options)](#davcreatecalendarobjectcalendar-options)\n    - [dav.updateCalendarObject(calendarObject, options)](#davupdatecalendarobjectcalendarobject-options)\n    - [dav.deleteCalendarObject(calendarObject, options)](#davdeletecalendarobjectcalendarobject-options)\n    - [dav.syncCalendar(calendar, options)](#davsynccalendarcalendar-options)\n    - [dav.syncCaldavAccount(account, options)](#davsynccaldavaccountaccount-options)\n  - [contacts](#contacts)\n    - [dav.createCard(addressBook, options)](#davcreatecardaddressbook-options)\n    - [dav.updateCard(card, options)](#davupdatecardcard-options)\n    - [dav.deleteCard(card, options)](#davdeletecardcard-options)\n    - [dav.syncAddressBook(addressBook, options)](#davsyncaddressbookaddressbook-options)\n    - [dav.syncCarddavAccount(account, options)](#davsynccarddavaccountaccount-options)\n  - [sandbox](#sandbox)\n    - [dav.Sandbox()](#davsandbox)\n  - [transport](#transport)\n    - [dav.transport.Basic(credentials)](#davtransportbasiccredentials)\n      - [dav.transport.Basic.send(request, options)](#davtransportbasicsendrequest-options)\n    - [dav.transport.OAuth2(credentials)](#davtransportoauth2credentials)\n      - [dav.transport.OAuth2.send(request, options)](#davtransportoauth2sendrequest-options)\n  - [request](#request)\n    - [dav.request.addressBookQuery(options)](#davrequestaddressbookqueryoptions)\n    - [dav.request.basic(options)](#davrequestbasicoptions)\n    - [dav.request.calendarQuery(options)](#davrequestcalendarqueryoptions)\n    - [dav.request.propfind(options)](#davrequestpropfindoptions)\n    - [dav.request.syncCollection(options)](#davrequestsynccollectionoptions)\n  - [Client](#client)\n    - [dav.Client(xhr, options)](#davclientxhr-options)\n      - [dav.Client.send(req, options)](#davclientsendreq-options)\n  - [etc](#etc)\n    - [dav.ns](#davns)\n  - [Example Usage](#example-usage)\n    - [Using the lower-level webdav request api](#using-the-lower-level-webdav-request-api)\n- [Debugging](#debugging)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## API\n\n### accounts\n\n#### dav.createAccount(options)\n\nPerform an initial download of a caldav or carddav account's data. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled with a [dav.Account](https://github.com/gaye/dav/blob/master/lib/model/account.js) object.\n\n```\nOptions:\n\n  (String) accountType - one of 'caldav' or 'carddav'. Defaults to 'caldav'.\n  (Array.<Object>) filters - list of caldav filters to send with request.\n  (Boolean) loadCollections - whether or not to load dav collections.\n  (Boolean) loadObjects - whether or not to load dav objects.\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (String) server - some url for server (needn't be base url).\n  (String) timezone - VTIMEZONE calendar object.\n  (dav.Transport) xhr - request sender.\n```\n\n### calendars\n\n#### dav.createCalendarObject(calendar, options)\n\nCreate a calendar object on the parameter calendar. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the calendar has been created.\n\n```\n@param {dav.Calendar} calendar the calendar to put the object on.\n\nOptions:\n\n  (String) data - rfc 5545 VCALENDAR object.\n  (String) filename - name for the calendar ics file.\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.updateCalendarObject(calendarObject, options)\n\nPersist updates to the parameter calendar object to the server. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the calendar has been updated.\n\n```\n@param {dav.CalendarObject} calendarObject updated calendar object.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.deleteCalendarObject(calendarObject, options)\n\nDelete the parameter calendar object on the server. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the calendar has been deleted.\n\n```\n@param {dav.CalendarObject} calendarObject target calendar object.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.syncCalendar(calendar, options)\n\nFetch changes from the remote server to the parameter calendar. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled with an updated [dav.Calendar](https://github.com/gaye/dav/blob/master/lib/model/calendar.js) object once sync is complete.\n\n```\n@param {dav.Calendar} calendar the calendar to fetch changes for.\n\nOptions:\n\n  (Array.<Object>) filters - list of caldav filters to send with request.\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (String) syncMethod - either 'basic' or 'webdav'. If unspecified, will\n      try to do webdav sync and failover to basic sync if rfc 6578 is not\n      supported by the server.\n  (String) timezone - VTIMEZONE calendar object.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.syncCaldavAccount(account, options)\n\nFetch changes from the remote server to the account's calendars. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled with an updated [dav.Account](https://github.com/gaye/dav/blob/master/lib/model/account.js) object once sync is complete.\n\n```\n@param {dav.Account} account the calendar account to sync.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n### contacts\n\n#### dav.createCard(addressBook, options)\n\nCreate a vcard object on the parameter address book. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the vcard has been created.\n\n```\n@param {dav.AddressBook} addressBook the address book to put the object on.\n\nOptions:\n\n  (String) data - VCARD object.\n  (String) filename - name for the vcard vcf file.\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.updateCard(card, options)\n\nPersist updates to the parameter vcard object to the server. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the vcard has been updated.\n\n```\n@param {dav.VCard} card updated vcard object.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.deleteCard(card, options)\n\nDelete the parameter vcard object on the server. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled when the vcard has been deleted.\n\n```\n@param {dav.VCard} card target vcard object.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n#### dav.syncAddressBook(addressBook, options)\n\nFetch changes from the remote server to the parameter address books. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled with an updated [dav.AddressBook](https://github.com/gaye/dav/blob/master/lib/model/address_book.js) object once sync is complete.\n\n```\n@param {dav.AddressBook} addressBook the address book to fetch changes for.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (String) syncMethod - either 'basic' or 'webdav'. If unspecified, will\n      try to do webdav sync and failover to basic sync if rfc 6578 is not\n      supported by the server.\n  (dav.Transport) xhr - request sender.\n```\n#### dav.syncCarddavAccount(account, options)\n\nFetch changes from the remote server to the account's address books. Returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) which will be fulfilled with an updated [dav.Account](https://github.com/gaye/dav/blob/master/lib/model/account.js) object once sync is complete.\n\n```\n@param {dav.Account} account the address book account to sync.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (dav.Transport) xhr - request sender.\n```\n\n### sandbox\n\n#### dav.Sandbox()\n\nCreate a request sandbox. There is also a deprecated interface\n`dav.createSandbox()`. Add requests to the sandbox like so:\n\n```js\nvar sandbox = new dav.Sandbox();\n// sandbox instanceof Sandbox\ndav.createAccount({\n  username: 'Yoshi',\n  password: 'babybowsersoscaryomg',\n  server: 'https://caldav.yoshisstory.com',\n  sandbox: sandbox  // <- Insert sandbox here!\n})\n.then(function(calendars) {\n  // etc, etc.\n});\n```\nAnd abort sandboxed requests as a group with `sandbox.abort()`.\n\n### transport\n\n#### dav.transport.Basic(credentials)\n\nCreate a new `dav.transport.Basic` object. This sends dav requests using http basic authentication.\n\n```\n@param {dav.Credentials} credentials user authorization.\n```\n\n##### dav.transport.Basic.send(request, options)\n\n```\n@param {dav.Request} request object with request info.\n@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request `transformResponse` function to the xhr object after its readyState is 4.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n```\n\n#### dav.transport.OAuth2(credentials)\n\nCreate a new `dav.transport.OAuth2` object. This sends dav requests authorized via rfc 6749 oauth2.\n\n```\n@param {dav.Credentials} credentials user authorization.\n```\n\n##### dav.transport.OAuth2.send(request, options)\n\n```\n@param {dav.Request} request object with request info.\n@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request `transformResponse` function to the xhr object after its readyState is 4.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n```\n\n### request\n\n#### dav.request.addressBookQuery(options)\n\n```\nOptions:\n\n  (String) depth - optional value for Depth header.\n  (Array.<Object>) props - list of props to request.\n```\n\n#### dav.request.basic(options)\n\n```\nOptions:\n\n  (String) data - put request body.\n  (String) method - http method.\n  (String) etag - cached calendar object etag.\n```\n\n#### dav.request.calendarQuery(options)\n\n```\nOptions:\n\n  (String) depth - optional value for Depth header.\n  (Array.<Object>) filters - list of filters to send with request.\n  (Array.<Object>) props - list of props to request.\n  (String) timezone - VTIMEZONE calendar object.\n```\n\n#### dav.request.propfind(options)\n\n```\nOptions:\n\n  (String) depth - optional value for Depth header.\n  (Array.<Object>) props - list of props to request.\n```\n\n#### dav.request.syncCollection(options)\n\n```\nOptions:\n\n  (String) depth - option value for Depth header.\n  (Array.<Object>) props - list of props to request.\n  (Number) syncLevel - indicates scope of the sync report request.\n  (String) syncToken - synchronization token provided by the server.\n```\n\n### Client\n\n#### dav.Client(xhr, options)\n\nCreate a new `dav.Client` object. The client interface allows consumers to set their credentials and transport once and then make authorized requests without passing them to each request. Each of the other, public API methods should be available on `dav.Client` objects.\n\n```\n@param {dav.Transport} xhr - request sender.\n\nOptions:\n\n  (String) baseUrl - root url to resolve relative request urls with.\n```\n\n##### dav.Client.send(req, options)\n\nSend a request using this client's transport (and perhaps baseUrl).\n\n```\n@param {dav.request.Request} req - dav request.\n@return {Promise} a promise that will be resolved with an xhr request after its readyState is 4 or the result of applying an optional request `transformResponse` function to the xhr object after its readyState is 4.\n\nOptions:\n\n  (dav.Sandbox) sandbox - optional request sandbox.\n  (String) url - relative url for request.\n```\n\n### etc\n\n#### dav.ns\n\nObject that holds various xml namespace constants.\n\n### Example Usage\n\n```js\nvar dav = require('dav');\n\nvar xhr = new dav.transport.Basic(\n  new dav.Credentials({\n    username: 'xxx',\n    password: 'xxx'\n  })\n);\n\ndav.createAccount({ server: 'http://dav.example.com', xhr: xhr })\n.then(function(account) {\n  // account instanceof dav.Account\n  account.calendars.forEach(function(calendar) {\n    console.log('Found calendar named ' + calendar.displayName);\n    // etc.\n  });\n});\n\n// Or, using the dav.Client interface:\n\nvar client = new dav.Client(xhr);\n// No transport arg\nclient.createAccount({\n  server: 'http://dav.example.com',\n  accountType: 'carddav'\n})\n.then(function(account) {\n  account.addressBooks.forEach(function(addressBook) {\n    console.log('Found address book name ' + addressBook.displayName);\n    // etc.\n  });\n});\n```\n\n#### Using the lower-level webdav request api\n\n_Caution_: The lower-level request api is undergoing some _major_ reworking with frequent changes which will break consumers upgrading from earlier versions. If you're looking for a stable api and can live with the higher-level CalDAV and/or CardDAV abstractions, I _strongly_ recommend those since that api is largely stable.\n\n```\nvar dav = require('dav');\n\nvar client = new dav.Client(\n  new dav.transport.Basic(\n    new dav.Credentials({\n      username: 'xxx',\n      password: 'xxx'\n    })\n  ),\n  {\n    baseUrl: 'https://mail.mozilla.com'\n  }\n);\n\nvar req = dav.request.basic({\n  method: 'PUT',\n  data: 'BEGIN:VCALENDAR\\nEND:VCALENDAR',\n  etag: '12345'\n});\n\n// req instanceof dav.Request\n\nclient.send(req, '/calendars/123.ics')\n.then(function(response) {\n  // response instanceof XMLHttpRequest\n});\n```\n\nOr perhaps without the client:\n\n```\nvar dav = require('dav');\n\nvar xhr = new dav.transport.Basic(\n  new dav.Credentials({\n    username: 'xxx',\n    password: 'xxx'\n  })\n);\n\n// xhr instanceof dav.Transport\n\nvar req = dav.request.basic({\n  method: 'PUT',\n  data: 'BEGIN:VCALENDAR\\nEND:VCALENDAR',\n  etag: '12345'\n});\n\n// req instanceof dav.Request\n\nxhr.send(req, 'https://mail.mozilla.com/calendars/123.ics')\n.then(function(response) {\n  // response instanceof XMLHttpRequest\n});\n```\n\nFor more example usages, check out the [suite of integration tests](https://github.com/gaye/dav/tree/master/test/integration).\n\n## Debugging\n\ndav can tell you a lot of potentially useful things if you set `dav.debug.enabled = true`.\n","maintainers":[{"name":"blmarket","email":"blmarket@gmail.com"}],"time":{"modified":"2022-06-12T15:21:43.042Z","created":"2016-03-05T04:26:25.030Z","1.7.8":"2016-03-05T04:26:25.030Z"},"homepage":"https://github.com/blmarket/dav#readme","keywords":["address book","calendar","contacts","dav","caldav","carddav","webdav","ical","vcard","sync","rfc 4791","rfc 6352","rfc 6578"],"repository":{"type":"git","url":"git+https://github.com/blmarket/dav.git"},"author":{"name":"Gareth Aye [:gaye]","email":"gaye@mozilla.com"},"bugs":{"url":"https://github.com/blmarket/dav/issues"},"license":"MPL-2.0","readmeFilename":"README.md"}