UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

45 lines (44 loc) 1.98 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "WebDAVExceptionsFilter", { enumerable: true, get: function() { return WebDAVExceptionsFilter; } }); const _common = require("@nestjs/common"); const _appconstants = require("../../../app.constants"); const _webdav = require("../constants/webdav"); function _ts_decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } let WebDAVExceptionsFilter = class WebDAVExceptionsFilter { catch(exception, host) { const ctx = host.switchToHttp(); const res = ctx.getResponse(); const status = exception.getStatus(); if (status === 401) { // req.authInfo from the AuthBasicGuard res.header('WWW-Authenticate', `Basic realm="${_appconstants.SERVER_NAME}"`).status(status).send(); } else { let response = exception.getResponse(); if (typeof response === 'object' && response !== null) { response = response.message; } res.type(_webdav.XML_CONTENT_TYPE).status(status).send(response); } } }; WebDAVExceptionsFilter = _ts_decorate([ (0, _common.Catch)(_common.HttpException) ], WebDAVExceptionsFilter); //# sourceMappingURL=webdav.filter.js.map