natelindev/tsdav
关于
适用于 JavaScript 运行时和浏览器的 WebDAV、CALDAV 与 CARDDAV 客户端
效率与自动化可以做什么
- Easy to use, well documented JSON based WEBDAV API
- Works in Browsers, Node.js (>= 18), Bun, Deno, and Cloudflare Workers
- Supports Both commonjs and esm
- OAuth2 & basic auth helpers built-in
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
webdav request made easy
Features
- Easy to use, well documented JSON based WEBDAV API
- Works in
Browsers,Node.js(>= 18),Bun,Deno, andCloudflare Workers - Supports Both
commonjsandesm - OAuth2 & basic auth helpers built-in
- Native typescript, fully linted and well tested
- Supports WEBDAV, CALDAV, CARDDAV
- Tested with multiple cloud providers
Install
npm install tsdav
or
yarn add tsdav
Runtime usage
tsdav works in Node.js (>= 18), browsers, Bun, Deno, and Cloudflare Workers.
See the runtime-specific usage docs for Bun, Deno, Cloudflare Workers, browser CORS notes, and custom fetch transports.
Quickstart
Google CALDAV
import { createDAVClient } from 'tsdav';
(async () => {
const client = await createDAVClient({
serverUrl: 'https://apidata.googleusercontent.com/caldav/v2/',
credentials: {
tokenUrl: 'https://accounts.google.com/o/oauth2/token',
username: 'YOUR_EMAIL_ADDRESS',
refreshToken: 'YOUR_REFRESH_TOKEN_WITH_CALDAV_PERMISSION',
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
},
authMethod: 'Oauth',
defaultAccountType: 'caldav',
});
const calendars = await client.fetchCalendars();
const calendarObjects = await client.fetchCalendarObjects({
calendar: calendars[0],
});
})();
Apple CARDDAV
import { createDAVClient } from 'tsdav';
(async () => {
const client = await createDAVClient({
serverUrl: 'https://contacts.icloud.com',
credentials: {
username: 'YOUR_APPLE_ID',
password: 'YOUR_APP_SPECIFIC_PASSWORD',
},
authMethod: 'Basic',
defaultAccountType: 'carddav',
});
const addressBooks = await client.fetchAddressBooks();
const vcards = await client.fetchVCards({
addressBook: addressBooks[0],
});
})();
After v1.1.0, you have a new way of creating clients.
Google CALDAV
import { DAVClient } from 'tsdav';
const client = new DAVClient({
serverUrl: 'https://apidata.googleusercontent.com/caldav/v2/',
credentials: {
tokenUrl: 'https://accounts.google.com/o/oauth2/token',
username: 'YOUR_EMAIL_ADDRESS',
refreshToken: 'YOUR_REFRESH_TOKEN_WITH_CALDAV_PERMISSION',
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
},
authMethod: 'Oauth',
defaultAccountType: 'caldav',
});
(async () => {
await client.login();
const calendars = await client.fetchCalendars();
const calendarObjects = await client.fetchCalendarObjects({
calendar: calendars[0],
});
})();
Apple CARDDAV
import { DAVClient } from 'tsdav';
const client = new DAVClient({
serverUrl: 'https://contacts.icloud.com',
credentials: {
username: 'YOUR_APPLE_ID',
password: 'YOUR_APP_SPECIFIC_PASSWORD',
},
authMethod: 'Basic',
defaultAccountType: 'carddav',
});
(async () => {
await client.login();
const addressBooks = await client.fetchAddressBooks();
const vcards = await client.fetchVCards({
addressBook: addressBooks[0],
});
})();
Documentation
Check out the Documentation
License
Changelog
refers to Changelog
Debugging
this package uses debug package,
add tsdav:* to DEBUG env variable to enable debug logs
FAQ
Can I use token-based auth (e.g., OIDC) with Nextcloud?
Yes, if your Nextcloud instance is configured to support it (e.g., via the user_oidc app), you can use authMethod: 'Bearer':
const client = new DAVClient({
serverUrl: 'https://<your-nextcloud-host>/remote.php/dav',
credentials: {
accessToken: 'YOUR_OIDC_ACCESS_TOKEN',
},
authMethod: 'Bearer',
defaultAccountType: 'caldav',
});
Note: Some Nextcloud configurations may still require Basic auth (username + app password) for DAV endpoints if OIDC is not fully integrated with the DAV subsystem.
探索相关项目
加载中…