{"version":3,"file":"alfresco-adf-core-auth.mjs","sources":["../../../../lib/core/auth/src/authentication.ts","../../../../lib/core/auth/src/authentication-interceptor/authentication.interceptor.ts","../../../../lib/core/auth/src/index.ts","../../../../lib/core/auth/src/alfresco-adf-core-auth.ts"],"sourcesContent":["/*!\n * @license\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { HttpHeaders } from '@angular/common/http';\nimport { Observable } from 'rxjs';\n\nexport abstract class Authentication {\n    public abstract addTokenToHeader(requestUrl: string, headers: HttpHeaders): Observable<HttpHeaders>;\n}\n","/*!\n * @license\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n    HttpContextToken,\n    HttpHandler,\n    HttpHeaderResponse,\n    HttpHeaders,\n    HttpInterceptor,\n    HttpProgressEvent,\n    HttpRequest,\n    HttpResponse,\n    HttpSentEvent,\n    HttpUserEvent\n} from '@angular/common/http';\nimport { Injectable, inject } from '@angular/core';\nimport { Observable, throwError as observableThrowError } from 'rxjs';\nimport { catchError, mergeMap } from 'rxjs/operators';\nimport { Authentication } from '../authentication';\n\nexport const SHOULD_ADD_AUTH_TOKEN = new HttpContextToken<boolean>(() => false);\n\n@Injectable()\nexport class AuthenticationInterceptor implements HttpInterceptor {\n    private readonly authService = inject(Authentication);\n\n    intercept(\n        req: HttpRequest<any>,\n        next: HttpHandler\n    ): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {\n        if (req.context.get(SHOULD_ADD_AUTH_TOKEN)) {\n            return this.authService.addTokenToHeader(req.url, req.headers).pipe(\n                mergeMap((headersWithBearer) => {\n                    const headerWithContentType = this.appendJsonContentType(headersWithBearer, req.body);\n                    const kcReq = req.clone({ headers: headerWithContentType });\n                    return next.handle(kcReq).pipe(catchError((error) => observableThrowError(error)));\n                })\n            );\n        }\n\n        return next.handle(req).pipe(catchError((error) => observableThrowError(error)));\n    }\n\n    private appendJsonContentType(headers: HttpHeaders, reqBody: any): HttpHeaders {\n        // prevent adding any content type, to properly handle formData with boundary browser generated value,\n        // as adding any Content-Type its going to break the upload functionality\n\n        if (headers.get('Content-Type') === 'multipart/form-data') {\n            return headers.delete('Content-Type');\n        }\n\n        if (!headers.get('Content-Type') && !(reqBody instanceof FormData)) {\n            return headers.set('Content-Type', 'application/json;charset=UTF-8');\n        }\n\n        return headers;\n    }\n}\n","/*!\n * @license\n * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './authentication';\nexport * from './authentication-interceptor/authentication.interceptor';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["observableThrowError"],"mappings":";;;;;;AAAA;;;;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