quankee-framework-interceptor 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025 Quankee Software, Lda
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Quankee Framework Interceptor
2
+
3
+ # libs
4
+ npm install --save-dev @angular/common
@@ -0,0 +1,44 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable } from '@angular/core';
3
+ import * as i1 from 'quankee-framework-keycloak';
4
+
5
+ function injectAuthHeader(req, token) {
6
+ if (token) {
7
+ return req.clone({
8
+ setHeaders: {
9
+ Authorization: `Bearer ${token}`,
10
+ },
11
+ });
12
+ }
13
+ return req;
14
+ }
15
+
16
+ class AuthorizationInterceptor {
17
+ keycloakService;
18
+ constructor(keycloakService) {
19
+ this.keycloakService = keycloakService;
20
+ }
21
+ intercept(req, next) {
22
+ console.log('[Interceptor] Executing...');
23
+ const token = this.keycloakService.getToken(); // returns string
24
+ const modifiedReq = injectAuthHeader(req, token);
25
+ console.warn('[Interceptor] No token found. Request sent without Authorization header.');
26
+ return next.handle(modifiedReq);
27
+ }
28
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AuthorizationInterceptor, deps: [{ token: i1.KeycloakService }], target: i0.ɵɵFactoryTarget.Injectable });
29
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AuthorizationInterceptor });
30
+ }
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AuthorizationInterceptor, decorators: [{
32
+ type: Injectable
33
+ }], ctorParameters: () => [{ type: i1.KeycloakService }] });
34
+
35
+ /*
36
+ * Public API Surface of quankee-framework-interceptor
37
+ */
38
+
39
+ /**
40
+ * Generated bundle index. Do not edit.
41
+ */
42
+
43
+ export { AuthorizationInterceptor, injectAuthHeader };
44
+ //# sourceMappingURL=quankee-framework-interceptor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quankee-framework-interceptor.mjs","sources":["../../../projects/quankee-framework-interceptor/src/lib/core/token.helper.ts","../../../projects/quankee-framework-interceptor/src/lib/core/authorization.interceptor.ts","../../../projects/quankee-framework-interceptor/src/public-api.ts","../../../projects/quankee-framework-interceptor/src/quankee-framework-interceptor.ts"],"sourcesContent":["export function injectAuthHeader(req: any, token: any): any {\n if (token) {\n return req.clone({\n setHeaders: {\n Authorization: `Bearer ${token}`,\n },\n });\n }\n return req;\n}\n","import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {Injectable} from '@angular/core';\nimport {KeycloakService} from 'quankee-framework-keycloak';\nimport {Observable} from 'rxjs';\nimport {injectAuthHeader} from './token.helper';\n\n@Injectable()\nexport class AuthorizationInterceptor implements HttpInterceptor {\n\n constructor(private readonly keycloakService: KeycloakService) {}\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n console.log('[Interceptor] Executing...');\n\n const token = this.keycloakService.getToken(); // returns string\n\n const modifiedReq = injectAuthHeader(req, token);\n\n console.warn('[Interceptor] No token found. Request sent without Authorization header.');\n return next.handle(modifiedReq);\n }\n\n}\n","/*\n * Public API Surface of quankee-framework-interceptor\n */\n\nexport * from './lib/core/token.helper';\nexport * from './lib/core/authorization.interceptor';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAgB,SAAA,gBAAgB,CAAC,GAAQ,EAAE,KAAU,EAAA;IACnD,IAAI,KAAK,EAAE;QACT,OAAO,GAAG,CAAC,KAAK,CAAC;AACf,YAAA,UAAU,EAAE;gBACV,aAAa,EAAE,CAAU,OAAA,EAAA,KAAK,CAAE,CAAA;AACjC,aAAA;AACF,SAAA,CAAC;;AAEJ,IAAA,OAAO,GAAG;AACZ;;MCFa,wBAAwB,CAAA;AAEN,IAAA,eAAA;AAA7B,IAAA,WAAA,CAA6B,eAAgC,EAAA;QAAhC,IAAe,CAAA,eAAA,GAAf,eAAe;;IAE5C,SAAS,CAAC,GAAqB,EAAE,IAAiB,EAAA;AAChD,QAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;QAEzC,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;QAE9C,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC;AAEhD,QAAA,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC;AACxF,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;;wGAZtB,wBAAwB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,eAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;4GAAxB,wBAAwB,EAAA,CAAA;;4FAAxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="quankee-framework-interceptor" />
5
+ export * from './public-api';
@@ -0,0 +1,11 @@
1
+ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
2
+ import { KeycloakService } from 'quankee-framework-keycloak';
3
+ import { Observable } from 'rxjs';
4
+ import * as i0 from "@angular/core";
5
+ export declare class AuthorizationInterceptor implements HttpInterceptor {
6
+ private readonly keycloakService;
7
+ constructor(keycloakService: KeycloakService);
8
+ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizationInterceptor, never>;
10
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizationInterceptor>;
11
+ }
@@ -0,0 +1 @@
1
+ export declare function injectAuthHeader(req: any, token: any): any;
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "quankee-framework-interceptor",
3
+ "description": "Quankee Framework Interceptor Lib",
4
+ "version": "1.4.0",
5
+ "author": {
6
+ "email": "info@quankee.co.mz",
7
+ "name": "Quankee Software, Lda",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://gitlab.com/quankee-framework/quankee-framework-common-ts"
12
+ },
13
+ "homepage": "https://gitlab.com/quankee-framework/quankee-framework-common-ts#readme",
14
+ "publishConfig": {
15
+ "registry": "https://registry.npmjs.org/"
16
+ }
17
+ },
18
+ "peerDependencies": {
19
+ "@angular/common": "^19.2.0",
20
+ "@angular/core": "^19.2.0"
21
+ },
22
+ "dependencies": {
23
+ "tslib": "^2.3.0"
24
+ },
25
+ "sideEffects": false,
26
+ "module": "fesm2022/quankee-framework-interceptor.mjs",
27
+ "typings": "index.d.ts",
28
+ "exports": {
29
+ "./package.json": {
30
+ "default": "./package.json"
31
+ },
32
+ ".": {
33
+ "types": "./index.d.ts",
34
+ "default": "./fesm2022/quankee-framework-interceptor.mjs"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ export * from './lib/core/token.helper';
2
+ export * from './lib/core/authorization.interceptor';