MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / createDAVClient

Function createDAVClient

lib/models/dav.js:10573–10719  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

10571});
10572
10573const createDAVClient = async (params) => {
10574 var _a;
10575 const { serverUrl, credentials, authMethod, defaultAccountType, authFunction, rootUrl, principalUrl, homeUrl, } = params;
10576 let authHeaders = {};
10577 switch (authMethod) {
10578 case 'Basic':
10579 authHeaders = getBasicAuthHeaders(credentials);
10580 break;
10581 case 'Oauth':
10582 authHeaders = (await getOauthHeaders(credentials)).headers;
10583 break;
10584 case 'Digest':
10585 authHeaders = {
10586 Authorization: `Digest ${credentials.digestString}`,
10587 };
10588 break;
10589 case 'Custom':
10590 authHeaders = (_a = (await (authFunction === null || authFunction === void 0 ? void 0 : authFunction(credentials)))) !== null && _a !== void 0 ? _a : {};
10591 break;
10592 default:
10593 throw new Error('Invalid auth method');
10594 }
10595 const defaultAccount = defaultAccountType
10596 ? await createAccount({
10597 account: {
10598 serverUrl,
10599 credentials,
10600 accountType: defaultAccountType,
10601 rootUrl,
10602 principalUrl,
10603 homeUrl,
10604 },
10605 headers: authHeaders,
10606 })
10607 : undefined;
10608 const davRequest$1 = async (params0) => {
10609 const { init, ...rest } = params0;
10610 const { headers, ...restInit } = init;
10611 return davRequest({
10612 ...rest,
10613 init: {
10614 ...restInit,
10615 headers: {
10616 ...authHeaders,
10617 ...headers,
10618 },
10619 },
10620 });
10621 };
10622 const createObject$1 = defaultParam(createObject, {
10623 url: serverUrl,
10624 headers: authHeaders,
10625 });
10626 const updateObject$1 = defaultParam(updateObject, { headers: authHeaders, url: serverUrl });
10627 const deleteObject$1 = defaultParam(deleteObject, { headers: authHeaders, url: serverUrl });
10628 const propfind$1 = defaultParam(propfind, { headers: authHeaders });
10629 // account
10630 const createAccount$1 = async (params0) => {

Callers 2

getClientFunction · 0.90
getClientFunction · 0.90

Calls 4

getBasicAuthHeadersFunction · 0.85
getOauthHeadersFunction · 0.85
createAccountFunction · 0.85
defaultParamFunction · 0.85

Tested by

no test coverage detected