@valtimo/access-control 11.0.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/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # access-control
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version
4
+ 14.2.0.
5
+
6
+ ## Code scaffolding
7
+
8
+ Run `ng generate component component-name --project access-control` to generate a new component. You
9
+ can also use
10
+ `ng generate directive|pipe|service|class|guard|interface|enum|module --project access-control`.
11
+
12
+ > Note: Don't forget to add `--project access-control` or else it will be added to the default
13
+ > project in your `angular.json` file.
14
+
15
+ ## Build
16
+
17
+ Run `ng build access-control` to build the project. The build artifacts will be stored in the
18
+ `dist/` directory.
19
+
20
+ ## Publishing
21
+
22
+ After building your library with `ng build access-control`, go to the dist folder
23
+ `cd dist/access-control` and run `npm publish`.
24
+
25
+ ## Running unit tests
26
+
27
+ Run `ng test access-control` to execute the unit tests via [Karma](https://karma-runner.github.io).
28
+
29
+ ## Further help
30
+
31
+ To get more help on the Angular CLI use `ng help` or go check out the
32
+ [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './permission.model';
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uL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uICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcGVybWlzc2lvbi5tb2RlbCc7XG4iXX0=
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVybWlzc2lvbi5tb2RlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8vYWNjZXNzLWNvbnRyb2wvc3JjL2xpYi9tb2RlbHMvcGVybWlzc2lvbi5tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7R0FjRyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBDb3B5cmlnaHQgMjAxNS0yMDIzIFJpdGVuc2UgQlYsIHRoZSBOZXRoZXJsYW5kcy5cbiAqXG4gKiBMaWNlbnNlZCB1bmRlciBFVVBMLCBWZXJzaW9uIDEuMiAodGhlIFwiTGljZW5zZVwiKTtcbiAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS5cbiAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdFxuICpcbiAqIGh0dHBzOi8vam9pbnVwL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VybWlzc2lvblJlcXVlc3RLZXk6IHN0cmluZ106IGJvb2xlYW47XG59XG5cbmludGVyZmFjZSBQZW5kaW5nUGVybWlzc2lvbnMge1xuICBbcGVybWlzc2lvblJlcXVlc3RLZXk6IHN0cmluZ106IFN1YmplY3Q8Ym9vbGVhbj47XG59XG5cbmludGVyZmFjZSBSZXNvbHZlZFBlcm1pc3Npb25zIHtcbiAgW3Blcm1pc3Npb25SZXF1ZXN0S2V5OiBzdHJpbmddOiBib29sZWFuO1xufVxuXG5leHBvcnQge1xuICBDYWNoZWRSZXNvbHZlZFBlcm1pc3Npb25zLFxuICBQZW5kaW5nUGVybWlzc2lvbnMsXG4gIFBlcm1pc3Npb25Db250ZXh0LFxuICBQZXJtaXNzaW9uUmVxdWVzdCxcbiAgUGVybWlzc2lvblJlcXVlc3RRdWV1ZSxcbiAgUGVybWlzc2lvblJlc3BvbnNlLFxuICBSZXNvbHZlZFBlcm1pc3Npb25zLFxufTtcbiJdfQ==
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './permission.service';
17
+ export * from './permission-api.service';
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy92YWx0aW1vL2FjY2Vzcy1jb250cm9sL3NyYy9saWIvc2Vydmlj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2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL3Blcm1pc3Npb24tYXBpLnNlcnZpY2UnO1xuIl19
@@ -0,0 +1,37 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { map } from 'rxjs';
3
+ import { getPermissionRequestKey } from '../utils';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "@angular/common/http";
6
+ import * as i2 from "@valtimo/config";
7
+ import * as i3 from "ngx-logger";
8
+ export class PermissionApiService {
9
+ constructor(http, configService, logger) {
10
+ this.http = http;
11
+ this.configService = configService;
12
+ this.logger = logger;
13
+ this.valtimoEndpointUri = this.configService.config.valtimoApi.endpointUri;
14
+ }
15
+ resolvePermissionRequestQueue(permissionRequestQueue) {
16
+ this.logger.debug('Permissions: request to resolve permission queue', permissionRequestQueue);
17
+ return this.requestPermission(permissionRequestQueue).pipe(map((res) => {
18
+ const keys = permissionRequestQueue.map(permissionRequest => getPermissionRequestKey(permissionRequest));
19
+ return res.reduce((acc, curr, index) => ({
20
+ ...acc,
21
+ [keys[index]]: curr.available,
22
+ }), {});
23
+ }));
24
+ }
25
+ requestPermission(request) {
26
+ return this.http.post(`${this.valtimoEndpointUri}v1/permissions`, request);
27
+ }
28
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, deps: [{ token: i1.HttpClient }, { token: i2.ConfigService }, { token: i3.NGXLogger }], target: i0.ɵɵFactoryTarget.Injectable }); }
29
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, providedIn: 'root' }); }
30
+ }
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, decorators: [{
32
+ type: Injectable,
33
+ args: [{
34
+ providedIn: 'root',
35
+ }]
36
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.ConfigService }, { type: i3.NGXLogger }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cm1pc3Npb25SZXF1ZXN0KVxuICAgICAgICApO1xuXG4gICAgICAgIHJldHVybiByZXMucmVkdWNlKFxuICAgICAgICAgIChhY2M6IFJlc29sdmVkUGVybWlzc2lvbnMsIGN1cnI6IFBlcm1pc3Npb25SZXNwb25zZSwgaW5kZXg6IG51bWJlcikgPT4gKHtcbiAgICAgICAgICAgIC4uLmFjYyxcbiAgICAgICAgICAgIFtrZXlzW2luZGV4XV06IGN1cnIuYXZhaWxhYmxlLFxuICAgICAgICAgIH0pLFxuICAgICAgICAgIHt9XG4gICAgICAgICk7XG4gICAgICB9KVxuICAgICk7XG4gIH1cblxuICBwdWJsaWMgcmVxdWVzdFBlcm1pc3Npb24ocmVxdWVzdDogUGVybWlzc2lvblJlcXVlc3RbXSk6IE9ic2VydmFibGU8UGVybWlzc2lvblJlc3BvbnNlW10+IHtcbiAgICByZXR1cm4gdGhpcy5odHRwLnBvc3Q8UGVybWlzc2lvblJlc3BvbnNlW10+KFxuICAgICAgYCR7dGhpcy52YWx0aW1vRW5kcG9pbnRVcml9djEvcGVybWlzc2lvbnNgLFxuICAgICAgcmVxdWVzdFxuICAgICk7XG4gIH1cbn1cbiJdfQ==
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Injectable } from '@angular/core';
17
+ import jwt_decode from 'jwt-decode';
18
+ import { of, Subject, switchMap, take, timer } from 'rxjs';
19
+ import { fromPromise } from 'rxjs/internal/observable/innerFrom';
20
+ import { getPermissionRequestKey } from '../utils';
21
+ import * as i0 from "@angular/core";
22
+ import * as i1 from "keycloak-angular";
23
+ import * as i2 from "ngx-logger";
24
+ import * as i3 from "./permission-api.service";
25
+ export class PermissionService {
26
+ constructor(keyCloakService, logger, permissionApiService) {
27
+ this.keyCloakService = keyCloakService;
28
+ this.logger = logger;
29
+ this.permissionApiService = permissionApiService;
30
+ this.QUEUE_COLLECTION_PERIOD_MS = 15;
31
+ this._cachedResolvedPermissions = {};
32
+ this._pendingPermissions = {};
33
+ this._permissionRequestQueue = [];
34
+ }
35
+ requestPermission(permissionRequest, context) {
36
+ const permissionRequestWithContext = { ...permissionRequest, context };
37
+ const permissionRequestKey = getPermissionRequestKey(permissionRequestWithContext);
38
+ const cachedResolvedPermission = this._cachedResolvedPermissions[permissionRequestKey];
39
+ const pendingPermissionRequest = this._pendingPermissions[permissionRequestKey];
40
+ if (Object.keys(this._cachedResolvedPermissions).includes(permissionRequestKey)) {
41
+ this.logger.debug('Permissions: return cached resolved permission', permissionRequestKey, cachedResolvedPermission);
42
+ return of(cachedResolvedPermission);
43
+ }
44
+ if (pendingPermissionRequest) {
45
+ this.logger.debug('Permissions: return existing pending permission', permissionRequestKey);
46
+ return pendingPermissionRequest;
47
+ }
48
+ this._pendingPermissions[permissionRequestKey] = new Subject();
49
+ this.queuePermission(permissionRequestWithContext);
50
+ this.logger.debug('Permissions: return new pending', permissionRequestKey);
51
+ return this._pendingPermissions[permissionRequestKey].asObservable();
52
+ }
53
+ queuePermission(permissionRequest) {
54
+ if (!this._permissionQueueSubscription || this._permissionQueueSubscription.closed) {
55
+ this.logger.debug('Permissions: open new queue subscription');
56
+ this.openQueueSubscription();
57
+ }
58
+ this._permissionRequestQueue.push(permissionRequest);
59
+ this.logger.debug(`Permissions: add request to queue: ${JSON.stringify(permissionRequest)}`);
60
+ }
61
+ openQueueSubscription() {
62
+ this._permissionQueueSubscription = timer(this.QUEUE_COLLECTION_PERIOD_MS).subscribe(() => {
63
+ this.logger.debug('Permissions: queue timer finished');
64
+ const queueCopy = [...this._permissionRequestQueue];
65
+ this.emptyQueue();
66
+ this.permissionApiService
67
+ .resolvePermissionRequestQueue(queueCopy)
68
+ .pipe(take(1))
69
+ .subscribe(resolvedPermissions => {
70
+ Object.keys(resolvedPermissions).forEach(permissionRequestKey => {
71
+ this._pendingPermissions[permissionRequestKey].next(resolvedPermissions[permissionRequestKey]);
72
+ this.logger.debug(`Permissions: resolved pending permission request ${permissionRequestKey}`, resolvedPermissions[permissionRequestKey]);
73
+ });
74
+ this.cacheResolvedPermissions(resolvedPermissions);
75
+ });
76
+ });
77
+ }
78
+ cacheResolvedPermissions(resolvedPermissions) {
79
+ Object.keys(resolvedPermissions).forEach(permissionRequestKey => {
80
+ this._cachedResolvedPermissions[permissionRequestKey] =
81
+ resolvedPermissions[permissionRequestKey];
82
+ this.logger.debug('Permissions: cache resolved permission request', permissionRequestKey);
83
+ });
84
+ if (!this._clearCacheSubscription || this._clearCacheSubscription.closed) {
85
+ this.openClearCacheSubscription();
86
+ }
87
+ }
88
+ openClearCacheSubscription() {
89
+ this._clearCacheSubscription = fromPromise(this.keyCloakService.getToken())
90
+ .pipe(take(1), switchMap(token => {
91
+ const tokenExp = jwt_decode(token).exp * 1000;
92
+ const expiryTime = tokenExp - Date.now() - 1000;
93
+ return timer(expiryTime);
94
+ }))
95
+ .subscribe(() => {
96
+ this.clearPending();
97
+ this.clearCache();
98
+ });
99
+ }
100
+ emptyQueue() {
101
+ this.logger.debug('Permissions: empty queue');
102
+ this._permissionRequestQueue = [];
103
+ }
104
+ clearCache() {
105
+ this.logger.debug('Permissions: clear cache');
106
+ this._cachedResolvedPermissions = {};
107
+ }
108
+ clearPending() {
109
+ this.logger.debug('Permissions: clear pending');
110
+ this._pendingPermissions = {};
111
+ }
112
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, deps: [{ token: i1.KeycloakService }, { token: i2.NGXLogger }, { token: i3.PermissionApiService }], target: i0.ɵɵFactoryTarget.Injectable }); }
113
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, providedIn: 'root' }); }
114
+ }
115
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, decorators: [{
116
+ type: Injectable,
117
+ args: [{
118
+ providedIn: 'root',
119
+ }]
120
+ }], ctorParameters: function () { return [{ type: i1.KeycloakService }, { type: i2.NGXLogger }, { type: i3.PermissionApiService }]; } });
121
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVybWlzc2lvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvdmFsdGltby9hY2Nlc3MtY29udHJvbC9zcmMvbGliL3NlcnZpY2VzL3Blcm1pc3Npb24uc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7R0FjRztBQUVILE9BQU8sRUFBQyxVQUFVLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxVQUFVLE1BQU0sWUFBWSxDQUFDO0FBR3BDLE9BQU8sRUFBYSxFQUFFLEVBQUUsT0FBTyxFQUFnQixTQUFTLEVBQUUsSUFBSSxFQUFFLEtBQUssRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUNuRixPQUFPLEVBQUMsV0FBVyxFQUFDLE1BQU0sb0NBQW9DLENBQUM7QUFVL0QsT0FBTyxFQUFDLHVCQUF1QixFQUFDLE1BQU0sVUFBVSxDQUFDOzs7OztBQUtqRCxNQUFNLE9BQU8saUJBQWlCO0lBUTVCLFlBQ21CLGVBQWdDLEVBQ2hDLE1BQWlCLEVBQ2pCLG9CQUEwQztRQUYxQyxvQkF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ICAgICAgIHJldHVybiB0aW1lcihleHBpcnlUaW1lKTtcbiAgICAgICAgfSlcbiAgICAgIClcbiAgICAgIC5zdWJzY3JpYmUoKCkgPT4ge1xuICAgICAgICB0aGlzLmNsZWFyUGVuZGluZygpO1xuICAgICAgICB0aGlzLmNsZWFyQ2FjaGUoKTtcbiAgICAgIH0pO1xuICB9XG5cbiAgcHJpdmF0ZSBlbXB0eVF1ZXVlKCk6IHZvaWQge1xuICAgIHRoaXMubG9nZ2VyLmRlYnVnKCdQZXJtaXNzaW9uczogZW1wdHkgcXVldWUnKTtcbiAgICB0aGlzLl9wZXJtaXNzaW9uUmVxdWVzdFF1ZXVlID0gW107XG4gIH1cblxuICBwcml2YXRlIGNsZWFyQ2FjaGUoKTogdm9pZCB7XG4gICAgdGhpcy5sb2dnZXIuZGVidWcoJ1Blcm1pc3Npb25zOiBjbGVhciBjYWNoZScpO1xuICAgIHRoaXMuX2NhY2hlZFJlc29sdmVkUGVybWlzc2lvbnMgPSB7fTtcbiAgfVxuXG4gIHByaXZhdGUgY2xlYXJQZW5kaW5nKCk6IHZvaWQge1xuICAgIHRoaXMubG9nZ2VyLmRlYnVnKCdQZXJtaXNzaW9uczogY2xlYXIgcGVuZGluZycpO1xuICAgIHRoaXMuX3BlbmRpbmdQZXJtaXNzaW9ucyA9IHt9O1xuICB9XG59XG4iXX0=
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './permission.utils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gbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZFxuICogbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wZXJtaXNzaW9uLnV0aWxzJztcbiJdfQ==
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ const getPermissionRequestKey = (permissionRequest) => {
17
+ const input = JSON.stringify(permissionRequest);
18
+ const len = input.length;
19
+ let hash = 0;
20
+ for (let i = 0; i < len; i++) {
21
+ hash = (hash << 5) - hash + input.charCodeAt(i);
22
+ hash |= 0; // to 32bit integer
23
+ }
24
+ return `${hash}`;
25
+ };
26
+ export { getPermissionRequestKey };
27
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVybWlzc2lvbi51dGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8vYWNjZXNzLWNvbnRyb2wvc3JjL2xpYi91dGlscy9wZXJtaXNzaW9uLnV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7OztHQWNHO0FBSUgsTUFBTSx1QkFBdUIsR0FBRyxDQUFDLGlCQUFvQyxFQUFVLEVBQUU7SUFDL0UsTUFBTSxLQUFL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IHNvZnR3YXJlXG4gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiBcIkFTIElTXCIgYmFzaXMsXG4gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC5cbiAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmRcbiAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLlxuICovXG5cbmltcG9ydCB7UGVybWlzc2lvblJlcXVlc3R9IGZyb20gJy4uL21vZGVscyc7XG5cbmNvbnN0IGdldFBlcm1pc3Npb25SZXF1ZXN0S2V5ID0gKHBlcm1pc3Npb25SZXF1ZXN0OiBQZXJtaXNzaW9uUmVxdWVzdCk6IHN0cmluZyA9PiB7XG4gIGNvbnN0IGlucHV0ID0gSlNPTi5zdHJpbmdpZnkocGVybWlzc2lvblJlcXVlc3QpO1xuICBjb25zdCBsZW4gPSBpbnB1dC5sZW5ndGg7XG5cbiAgbGV0IGhhc2ggPSAwO1xuXG4gIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICBoYXNoID0gKGhhc2ggPDwgNSkgLSBoYXNoICsgaW5wdXQuY2hhckNvZGVBdChpKTtcbiAgICBoYXNoIHw9IDA7IC8vIHRvIDMyYml0IGludGVnZXJcbiAgfVxuICByZXR1cm4gYCR7aGFzaH1gO1xufTtcblxuZXhwb3J0IHtnZXRQZXJtaXNzaW9uUmVxdWVzdEtleX07XG4iXX0=
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
3
+ *
4
+ * Licensed under EUPL, Version 1.2 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /*
17
+ * Public API Surface of access-control
18
+ */
19
+ export * from './lib/models';
20
+ export * from './lib/services';
21
+ export * from './lib/utils';
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8vYWNjZXNzLWNvbnRyb2wvc3JjL3B1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFFSDs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxhQUFhLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogQ29weXJpZ2h0IDIwMTUtMjAyMyBSaXRlbnNlIEJWLCB0aGUgTmV0aGVybGFuZHMuXG4gKlxuICogTGljZW5zZWQgdW5kZXIgRVVQTCwgVmVyc2lvbiAxLjIgKHRoZSBcIkxpY2Vuc2VcIik7XG4gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuXG4gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXRcbiAqXG4gKiBodHRwczovL2pvaW51cC5lYy5ldXJvcGEuZXUvY29sbGVjdGlvbi9ldXBsL2V1cGwtdGV4dC1ldXBsLTEyXG4gKlxuICogVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZVxuICogZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gXCJBUyBJU1wiIGJhc2lzLFxuICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuXG4gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kXG4gKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS5cbiAqL1xuXG4vKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIGFjY2Vzcy1jb250cm9sXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9kZWxzJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3NlcnZpY2VzJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3V0aWxzJztcbiJdfQ==
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './public-api';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsdGltby1hY2Nlc3MtY29udHJvbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8vYWNjZXNzLWNvbnRyb2wvc3JjL3ZhbHRpbW8tYWNjZXNzLWNvbnRyb2wudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
@@ -0,0 +1,267 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable } from '@angular/core';
3
+ import jwt_decode from 'jwt-decode';
4
+ import { map, of, Subject, timer, take, switchMap } from 'rxjs';
5
+ import { fromPromise } from 'rxjs/internal/observable/innerFrom';
6
+ import * as i1$1 from 'keycloak-angular';
7
+ import * as i3 from 'ngx-logger';
8
+ import * as i1 from '@angular/common/http';
9
+ import * as i2 from '@valtimo/config';
10
+
11
+ /*
12
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
13
+ *
14
+ * Licensed under EUPL, Version 1.2 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" basis,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+ /*
28
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
29
+ *
30
+ * Licensed under EUPL, Version 1.2 (the "License");
31
+ * you may not use this file except in compliance with the License.
32
+ * You may obtain a copy of the License at
33
+ *
34
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
35
+ *
36
+ * Unless required by applicable law or agreed to in writing, software
37
+ * distributed under the License is distributed on an "AS IS" basis,
38
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
+ * See the License for the specific language governing permissions and
40
+ * limitations under the License.
41
+ */
42
+
43
+ /*
44
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
45
+ *
46
+ * Licensed under EUPL, Version 1.2 (the "License");
47
+ * you may not use this file except in compliance with the License.
48
+ * You may obtain a copy of the License at
49
+ *
50
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
51
+ *
52
+ * Unless required by applicable law or agreed to in writing, software
53
+ * distributed under the License is distributed on an "AS IS" basis,
54
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
+ * See the License for the specific language governing permissions and
56
+ * limitations under the License.
57
+ */
58
+ const getPermissionRequestKey = (permissionRequest) => {
59
+ const input = JSON.stringify(permissionRequest);
60
+ const len = input.length;
61
+ let hash = 0;
62
+ for (let i = 0; i < len; i++) {
63
+ hash = (hash << 5) - hash + input.charCodeAt(i);
64
+ hash |= 0; // to 32bit integer
65
+ }
66
+ return `${hash}`;
67
+ };
68
+
69
+ /*
70
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
71
+ *
72
+ * Licensed under EUPL, Version 1.2 (the "License");
73
+ * you may not use this file except in compliance with the License.
74
+ * You may obtain a copy of the License at
75
+ *
76
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
77
+ *
78
+ * Unless required by applicable law or agreed to in writing, software
79
+ * distributed under the License is distributed on an "AS IS" basis,
80
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81
+ * See the License for the specific language governing permissions and
82
+ * limitations under the License.
83
+ */
84
+
85
+ class PermissionApiService {
86
+ constructor(http, configService, logger) {
87
+ this.http = http;
88
+ this.configService = configService;
89
+ this.logger = logger;
90
+ this.valtimoEndpointUri = this.configService.config.valtimoApi.endpointUri;
91
+ }
92
+ resolvePermissionRequestQueue(permissionRequestQueue) {
93
+ this.logger.debug('Permissions: request to resolve permission queue', permissionRequestQueue);
94
+ return this.requestPermission(permissionRequestQueue).pipe(map((res) => {
95
+ const keys = permissionRequestQueue.map(permissionRequest => getPermissionRequestKey(permissionRequest));
96
+ return res.reduce((acc, curr, index) => ({
97
+ ...acc,
98
+ [keys[index]]: curr.available,
99
+ }), {});
100
+ }));
101
+ }
102
+ requestPermission(request) {
103
+ return this.http.post(`${this.valtimoEndpointUri}v1/permissions`, request);
104
+ }
105
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, deps: [{ token: i1.HttpClient }, { token: i2.ConfigService }, { token: i3.NGXLogger }], target: i0.ɵɵFactoryTarget.Injectable }); }
106
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, providedIn: 'root' }); }
107
+ }
108
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionApiService, decorators: [{
109
+ type: Injectable,
110
+ args: [{
111
+ providedIn: 'root',
112
+ }]
113
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.ConfigService }, { type: i3.NGXLogger }]; } });
114
+
115
+ /*
116
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
117
+ *
118
+ * Licensed under EUPL, Version 1.2 (the "License");
119
+ * you may not use this file except in compliance with the License.
120
+ * You may obtain a copy of the License at
121
+ *
122
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
123
+ *
124
+ * Unless required by applicable law or agreed to in writing, software
125
+ * distributed under the License is distributed on an "AS IS" basis,
126
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127
+ * See the License for the specific language governing permissions and
128
+ * limitations under the License.
129
+ */
130
+ class PermissionService {
131
+ constructor(keyCloakService, logger, permissionApiService) {
132
+ this.keyCloakService = keyCloakService;
133
+ this.logger = logger;
134
+ this.permissionApiService = permissionApiService;
135
+ this.QUEUE_COLLECTION_PERIOD_MS = 15;
136
+ this._cachedResolvedPermissions = {};
137
+ this._pendingPermissions = {};
138
+ this._permissionRequestQueue = [];
139
+ }
140
+ requestPermission(permissionRequest, context) {
141
+ const permissionRequestWithContext = { ...permissionRequest, context };
142
+ const permissionRequestKey = getPermissionRequestKey(permissionRequestWithContext);
143
+ const cachedResolvedPermission = this._cachedResolvedPermissions[permissionRequestKey];
144
+ const pendingPermissionRequest = this._pendingPermissions[permissionRequestKey];
145
+ if (Object.keys(this._cachedResolvedPermissions).includes(permissionRequestKey)) {
146
+ this.logger.debug('Permissions: return cached resolved permission', permissionRequestKey, cachedResolvedPermission);
147
+ return of(cachedResolvedPermission);
148
+ }
149
+ if (pendingPermissionRequest) {
150
+ this.logger.debug('Permissions: return existing pending permission', permissionRequestKey);
151
+ return pendingPermissionRequest;
152
+ }
153
+ this._pendingPermissions[permissionRequestKey] = new Subject();
154
+ this.queuePermission(permissionRequestWithContext);
155
+ this.logger.debug('Permissions: return new pending', permissionRequestKey);
156
+ return this._pendingPermissions[permissionRequestKey].asObservable();
157
+ }
158
+ queuePermission(permissionRequest) {
159
+ if (!this._permissionQueueSubscription || this._permissionQueueSubscription.closed) {
160
+ this.logger.debug('Permissions: open new queue subscription');
161
+ this.openQueueSubscription();
162
+ }
163
+ this._permissionRequestQueue.push(permissionRequest);
164
+ this.logger.debug(`Permissions: add request to queue: ${JSON.stringify(permissionRequest)}`);
165
+ }
166
+ openQueueSubscription() {
167
+ this._permissionQueueSubscription = timer(this.QUEUE_COLLECTION_PERIOD_MS).subscribe(() => {
168
+ this.logger.debug('Permissions: queue timer finished');
169
+ const queueCopy = [...this._permissionRequestQueue];
170
+ this.emptyQueue();
171
+ this.permissionApiService
172
+ .resolvePermissionRequestQueue(queueCopy)
173
+ .pipe(take(1))
174
+ .subscribe(resolvedPermissions => {
175
+ Object.keys(resolvedPermissions).forEach(permissionRequestKey => {
176
+ this._pendingPermissions[permissionRequestKey].next(resolvedPermissions[permissionRequestKey]);
177
+ this.logger.debug(`Permissions: resolved pending permission request ${permissionRequestKey}`, resolvedPermissions[permissionRequestKey]);
178
+ });
179
+ this.cacheResolvedPermissions(resolvedPermissions);
180
+ });
181
+ });
182
+ }
183
+ cacheResolvedPermissions(resolvedPermissions) {
184
+ Object.keys(resolvedPermissions).forEach(permissionRequestKey => {
185
+ this._cachedResolvedPermissions[permissionRequestKey] =
186
+ resolvedPermissions[permissionRequestKey];
187
+ this.logger.debug('Permissions: cache resolved permission request', permissionRequestKey);
188
+ });
189
+ if (!this._clearCacheSubscription || this._clearCacheSubscription.closed) {
190
+ this.openClearCacheSubscription();
191
+ }
192
+ }
193
+ openClearCacheSubscription() {
194
+ this._clearCacheSubscription = fromPromise(this.keyCloakService.getToken())
195
+ .pipe(take(1), switchMap(token => {
196
+ const tokenExp = jwt_decode(token).exp * 1000;
197
+ const expiryTime = tokenExp - Date.now() - 1000;
198
+ return timer(expiryTime);
199
+ }))
200
+ .subscribe(() => {
201
+ this.clearPending();
202
+ this.clearCache();
203
+ });
204
+ }
205
+ emptyQueue() {
206
+ this.logger.debug('Permissions: empty queue');
207
+ this._permissionRequestQueue = [];
208
+ }
209
+ clearCache() {
210
+ this.logger.debug('Permissions: clear cache');
211
+ this._cachedResolvedPermissions = {};
212
+ }
213
+ clearPending() {
214
+ this.logger.debug('Permissions: clear pending');
215
+ this._pendingPermissions = {};
216
+ }
217
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, deps: [{ token: i1$1.KeycloakService }, { token: i3.NGXLogger }, { token: PermissionApiService }], target: i0.ɵɵFactoryTarget.Injectable }); }
218
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, providedIn: 'root' }); }
219
+ }
220
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PermissionService, decorators: [{
221
+ type: Injectable,
222
+ args: [{
223
+ providedIn: 'root',
224
+ }]
225
+ }], ctorParameters: function () { return [{ type: i1$1.KeycloakService }, { type: i3.NGXLogger }, { type: PermissionApiService }]; } });
226
+
227
+ /*
228
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
229
+ *
230
+ * Licensed under EUPL, Version 1.2 (the "License");
231
+ * you may not use this file except in compliance with the License.
232
+ * You may obtain a copy of the License at
233
+ *
234
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
235
+ *
236
+ * Unless required by applicable law or agreed to in writing, software
237
+ * distributed under the License is distributed on an "AS IS" basis,
238
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
+ * See the License for the specific language governing permissions and
240
+ * limitations under the License.
241
+ */
242
+
243
+ /*
244
+ * Copyright 2015-2023 Ritense BV, the Netherlands.
245
+ *
246
+ * Licensed under EUPL, Version 1.2 (the "License");
247
+ * you may not use this file except in compliance with the License.
248
+ * You may obtain a copy of the License at
249
+ *
250
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
251
+ *
252
+ * Unless required by applicable law or agreed to in writing, software
253
+ * distributed under the License is distributed on an "AS IS" basis,
254
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
255
+ * See the License for the specific language governing permissions and
256
+ * limitations under the License.
257
+ */
258
+ /*
259
+ * Public API Surface of access-control
260
+ */
261
+
262
+ /**
263
+ * Generated bundle index. Do not edit.
264
+ */
265
+
266
+ export { PermissionApiService, PermissionService, getPermissionRequestKey };
267
+ //# sourceMappingURL=valtimo-access-control.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valtimo-access-control.mjs","sources":["../../../../projects/valtimo/access-control/src/lib/models/permission.model.ts","../../../../projects/valtimo/access-control/src/lib/models/index.ts","../../../../projects/valtimo/access-control/src/lib/utils/permission.utils.ts","../../../../projects/valtimo/access-control/src/lib/utils/index.ts","../../../../projects/valtimo/access-control/src/lib/services/permission-api.service.ts","../../../../projects/valtimo/access-control/src/lib/services/permission.service.ts","../../../../projects/valtimo/access-control/src/lib/services/index.ts","../../../../projects/valtimo/access-control/src/public-api.ts","../../../../projects/valtimo/access-control/src/valtimo-access-control.ts"],"sourcesContent":["/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 {Subject} from 'rxjs';\n\ninterface PermissionContext {\n identifier: string;\n resource: string;\n}\n\ninterface PermissionRequest {\n action: string;\n resource: string;\n context?: PermissionContext;\n}\n\ntype PermissionRequestQueue = Array<PermissionRequest>;\n\ninterface PermissionResponse {\n request: PermissionRequest;\n available: boolean;\n}\n\ninterface CachedResolvedPermissions {\n [permissionRequestKey: string]: boolean;\n}\n\ninterface PendingPermissions {\n [permissionRequestKey: string]: Subject<boolean>;\n}\n\ninterface ResolvedPermissions {\n [permissionRequestKey: string]: boolean;\n}\n\nexport {\n CachedResolvedPermissions,\n PendingPermissions,\n PermissionContext,\n PermissionRequest,\n PermissionRequestQueue,\n PermissionResponse,\n ResolvedPermissions,\n};\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 './permission.model';\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 {PermissionRequest} from '../models';\n\nconst getPermissionRequestKey = (permissionRequest: PermissionRequest): string => {\n const input = JSON.stringify(permissionRequest);\n const len = input.length;\n\n let hash = 0;\n\n for (let i = 0; i < len; i++) {\n hash = (hash << 5) - hash + input.charCodeAt(i);\n hash |= 0; // to 32bit integer\n }\n return `${hash}`;\n};\n\nexport {getPermissionRequestKey};\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 './permission.utils';\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 {HttpClient} from '@angular/common/http';\nimport {Injectable} from '@angular/core';\nimport {ConfigService} from '@valtimo/config';\nimport {map, Observable} from 'rxjs';\nimport {\n PermissionRequest,\n PermissionRequestQueue,\n PermissionResponse,\n ResolvedPermissions,\n} from '../models';\nimport {getPermissionRequestKey} from '../utils';\nimport {NGXLogger} from 'ngx-logger';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class PermissionApiService {\n private valtimoEndpointUri: string;\n\n constructor(\n private readonly http: HttpClient,\n private readonly configService: ConfigService,\n private readonly logger: NGXLogger\n ) {\n this.valtimoEndpointUri = this.configService.config.valtimoApi.endpointUri;\n }\n\n public resolvePermissionRequestQueue(\n permissionRequestQueue: PermissionRequestQueue\n ): Observable<ResolvedPermissions> {\n this.logger.debug('Permissions: request to resolve permission queue', permissionRequestQueue);\n\n return this.requestPermission(permissionRequestQueue).pipe(\n map((res: PermissionResponse[]) => {\n const keys: string[] = permissionRequestQueue.map(permissionRequest =>\n getPermissionRequestKey(permissionRequest)\n );\n\n return res.reduce(\n (acc: ResolvedPermissions, curr: PermissionResponse, index: number) => ({\n ...acc,\n [keys[index]]: curr.available,\n }),\n {}\n );\n })\n );\n }\n\n public requestPermission(request: PermissionRequest[]): Observable<PermissionResponse[]> {\n return this.http.post<PermissionResponse[]>(\n `${this.valtimoEndpointUri}v1/permissions`,\n request\n );\n }\n}\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 {Injectable} from '@angular/core';\nimport jwt_decode from 'jwt-decode';\nimport {KeycloakService} from 'keycloak-angular';\nimport {NGXLogger} from 'ngx-logger';\nimport {Observable, of, Subject, Subscription, switchMap, take, timer} from 'rxjs';\nimport {fromPromise} from 'rxjs/internal/observable/innerFrom';\nimport {\n CachedResolvedPermissions,\n PendingPermissions,\n PermissionContext,\n PermissionRequest,\n PermissionRequestQueue,\n ResolvedPermissions,\n} from '../models';\nimport {PermissionApiService} from './permission-api.service';\nimport {getPermissionRequestKey} from '../utils';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class PermissionService {\n private readonly QUEUE_COLLECTION_PERIOD_MS = 15;\n private _cachedResolvedPermissions: CachedResolvedPermissions = {};\n private _pendingPermissions: PendingPermissions = {};\n private _permissionRequestQueue: PermissionRequestQueue = [];\n private _permissionQueueSubscription!: Subscription;\n private _clearCacheSubscription!: Subscription;\n\n constructor(\n private readonly keyCloakService: KeycloakService,\n private readonly logger: NGXLogger,\n private readonly permissionApiService: PermissionApiService\n ) {}\n\n public requestPermission(\n permissionRequest: PermissionRequest,\n context: PermissionContext\n ): Observable<boolean> {\n const permissionRequestWithContext = {...permissionRequest, context};\n const permissionRequestKey = getPermissionRequestKey(permissionRequestWithContext);\n const cachedResolvedPermission = this._cachedResolvedPermissions[permissionRequestKey];\n const pendingPermissionRequest = this._pendingPermissions[permissionRequestKey];\n\n if (Object.keys(this._cachedResolvedPermissions).includes(permissionRequestKey)) {\n this.logger.debug(\n 'Permissions: return cached resolved permission',\n permissionRequestKey,\n cachedResolvedPermission\n );\n\n return of(cachedResolvedPermission);\n }\n\n if (pendingPermissionRequest) {\n this.logger.debug('Permissions: return existing pending permission', permissionRequestKey);\n\n return pendingPermissionRequest;\n }\n\n this._pendingPermissions[permissionRequestKey] = new Subject<boolean>();\n\n this.queuePermission(permissionRequestWithContext);\n\n this.logger.debug('Permissions: return new pending', permissionRequestKey);\n\n return this._pendingPermissions[permissionRequestKey].asObservable();\n }\n\n private queuePermission(permissionRequest: PermissionRequest): void {\n if (!this._permissionQueueSubscription || this._permissionQueueSubscription.closed) {\n this.logger.debug('Permissions: open new queue subscription');\n\n this.openQueueSubscription();\n }\n\n this._permissionRequestQueue.push(permissionRequest);\n\n this.logger.debug(`Permissions: add request to queue: ${JSON.stringify(permissionRequest)}`);\n }\n\n private openQueueSubscription(): void {\n this._permissionQueueSubscription = timer(this.QUEUE_COLLECTION_PERIOD_MS).subscribe(() => {\n this.logger.debug('Permissions: queue timer finished');\n\n const queueCopy = [...this._permissionRequestQueue];\n\n this.emptyQueue();\n\n this.permissionApiService\n .resolvePermissionRequestQueue(queueCopy)\n .pipe(take(1))\n .subscribe(resolvedPermissions => {\n Object.keys(resolvedPermissions).forEach(permissionRequestKey => {\n this._pendingPermissions[permissionRequestKey].next(\n resolvedPermissions[permissionRequestKey]\n );\n this.logger.debug(\n `Permissions: resolved pending permission request ${permissionRequestKey}`,\n resolvedPermissions[permissionRequestKey]\n );\n });\n\n this.cacheResolvedPermissions(resolvedPermissions);\n });\n });\n }\n\n private cacheResolvedPermissions(resolvedPermissions: ResolvedPermissions): void {\n Object.keys(resolvedPermissions).forEach(permissionRequestKey => {\n this._cachedResolvedPermissions[permissionRequestKey] =\n resolvedPermissions[permissionRequestKey];\n this.logger.debug('Permissions: cache resolved permission request', permissionRequestKey);\n });\n\n if (!this._clearCacheSubscription || this._clearCacheSubscription.closed) {\n this.openClearCacheSubscription();\n }\n }\n\n private openClearCacheSubscription(): void {\n this._clearCacheSubscription = fromPromise(this.keyCloakService.getToken())\n .pipe(\n take(1),\n switchMap(token => {\n const tokenExp = (jwt_decode(token) as any).exp * 1000;\n const expiryTime = tokenExp - Date.now() - 1000;\n return timer(expiryTime);\n })\n )\n .subscribe(() => {\n this.clearPending();\n this.clearCache();\n });\n }\n\n private emptyQueue(): void {\n this.logger.debug('Permissions: empty queue');\n this._permissionRequestQueue = [];\n }\n\n private clearCache(): void {\n this.logger.debug('Permissions: clear cache');\n this._cachedResolvedPermissions = {};\n }\n\n private clearPending(): void {\n this.logger.debug('Permissions: clear pending');\n this._pendingPermissions = {};\n }\n}\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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 './permission.service';\nexport * from './permission-api.service';\n","/*\n * Copyright 2015-2023 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (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 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\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\n/*\n * Public API Surface of access-control\n */\n\nexport * from './lib/models';\nexport * from './lib/services';\nexport * from './lib/utils';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1","i2","i3.PermissionApiService"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;;ACdH;;;;;;;;;;;;;;AAcG;;ACdH;;;;;;;;;;;;;;AAcG;AAIH,MAAM,uBAAuB,GAAG,CAAC,iBAAoC,KAAY;IAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAChD,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IAEzB,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;AAC5B,QAAA,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAChD,QAAA,IAAI,IAAI,CAAC,CAAC;AACX,KAAA;IACD,OAAO,CAAA,EAAG,IAAI,CAAA,CAAE,CAAC;AACnB;;AC7BA;;;;;;;;;;;;;;AAcG;;MCkBU,oBAAoB,CAAA;AAG/B,IAAA,WAAA,CACmB,IAAgB,EACh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AAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA,CAAA,EAAA;;4FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;ACnCD;;;;;;;;;;;;;;AAcG;;ACdH;;;;;;;;;;;;;;AAcG;AAEH;;AAEG;;AClBH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@valtimo/access-control" />
5
+ export * from './public-api';
@@ -0,0 +1 @@
1
+ export * from './permission.model';
@@ -0,0 +1,25 @@
1
+ import { Subject } from 'rxjs';
2
+ interface PermissionContext {
3
+ identifier: string;
4
+ resource: string;
5
+ }
6
+ interface PermissionRequest {
7
+ action: string;
8
+ resource: string;
9
+ context?: PermissionContext;
10
+ }
11
+ type PermissionRequestQueue = Array<PermissionRequest>;
12
+ interface PermissionResponse {
13
+ request: PermissionRequest;
14
+ available: boolean;
15
+ }
16
+ interface CachedResolvedPermissions {
17
+ [permissionRequestKey: string]: boolean;
18
+ }
19
+ interface PendingPermissions {
20
+ [permissionRequestKey: string]: Subject<boolean>;
21
+ }
22
+ interface ResolvedPermissions {
23
+ [permissionRequestKey: string]: boolean;
24
+ }
25
+ export { CachedResolvedPermissions, PendingPermissions, PermissionContext, PermissionRequest, PermissionRequestQueue, PermissionResponse, ResolvedPermissions, };
@@ -0,0 +1,2 @@
1
+ export * from './permission.service';
2
+ export * from './permission-api.service';
@@ -0,0 +1,17 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { ConfigService } from '@valtimo/config';
3
+ import { Observable } from 'rxjs';
4
+ import { PermissionRequest, PermissionRequestQueue, PermissionResponse, ResolvedPermissions } from '../models';
5
+ import { NGXLogger } from 'ngx-logger';
6
+ import * as i0 from "@angular/core";
7
+ export declare class PermissionApiService {
8
+ private readonly http;
9
+ private readonly configService;
10
+ private readonly logger;
11
+ private valtimoEndpointUri;
12
+ constructor(http: HttpClient, configService: ConfigService, logger: NGXLogger);
13
+ resolvePermissionRequestQueue(permissionRequestQueue: PermissionRequestQueue): Observable<ResolvedPermissions>;
14
+ requestPermission(request: PermissionRequest[]): Observable<PermissionResponse[]>;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<PermissionApiService, never>;
16
+ static ɵprov: i0.ɵɵInjectableDeclaration<PermissionApiService>;
17
+ }
@@ -0,0 +1,28 @@
1
+ import { KeycloakService } from 'keycloak-angular';
2
+ import { NGXLogger } from 'ngx-logger';
3
+ import { Observable } from 'rxjs';
4
+ import { PermissionContext, PermissionRequest } from '../models';
5
+ import { PermissionApiService } from './permission-api.service';
6
+ import * as i0 from "@angular/core";
7
+ export declare class PermissionService {
8
+ private readonly keyCloakService;
9
+ private readonly logger;
10
+ private readonly permissionApiService;
11
+ private readonly QUEUE_COLLECTION_PERIOD_MS;
12
+ private _cachedResolvedPermissions;
13
+ private _pendingPermissions;
14
+ private _permissionRequestQueue;
15
+ private _permissionQueueSubscription;
16
+ private _clearCacheSubscription;
17
+ constructor(keyCloakService: KeycloakService, logger: NGXLogger, permissionApiService: PermissionApiService);
18
+ requestPermission(permissionRequest: PermissionRequest, context: PermissionContext): Observable<boolean>;
19
+ private queuePermission;
20
+ private openQueueSubscription;
21
+ private cacheResolvedPermissions;
22
+ private openClearCacheSubscription;
23
+ private emptyQueue;
24
+ private clearCache;
25
+ private clearPending;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<PermissionService, never>;
27
+ static ɵprov: i0.ɵɵInjectableDeclaration<PermissionService>;
28
+ }
@@ -0,0 +1 @@
1
+ export * from './permission.utils';
@@ -0,0 +1,3 @@
1
+ import { PermissionRequest } from '../models';
2
+ declare const getPermissionRequestKey: (permissionRequest: PermissionRequest) => string;
3
+ export { getPermissionRequestKey };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@valtimo/access-control",
3
+ "version": "11.0.0",
4
+ "peerDependencies": {
5
+ "@angular/common": "^16.2.0",
6
+ "@angular/core": "^16.2.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "2.6.2"
10
+ },
11
+ "module": "fesm2022/valtimo-access-control.mjs",
12
+ "typings": "index.d.ts",
13
+ "exports": {
14
+ "./package.json": {
15
+ "default": "./package.json"
16
+ },
17
+ ".": {
18
+ "types": "./index.d.ts",
19
+ "esm2022": "./esm2022/valtimo-access-control.mjs",
20
+ "esm": "./esm2022/valtimo-access-control.mjs",
21
+ "default": "./fesm2022/valtimo-access-control.mjs"
22
+ }
23
+ },
24
+ "sideEffects": false
25
+ }
@@ -0,0 +1,3 @@
1
+ export * from './lib/models';
2
+ export * from './lib/services';
3
+ export * from './lib/utils';