@valtimo/access-control 13.37.0 → 13.39.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.
@@ -135,6 +135,7 @@ class PermissionService {
135
135
  this.QUEUE_COLLECTION_PERIOD_MS = 15;
136
136
  this._cachedResolvedPermissions = {};
137
137
  this._pendingPermissions = {};
138
+ this._permissionRequestsByKey = {};
138
139
  this._permissionRequestQueue = [];
139
140
  }
140
141
  requestPermission(permissionRequest, context) {
@@ -151,10 +152,40 @@ class PermissionService {
151
152
  return pendingPermissionRequest;
152
153
  }
153
154
  this._pendingPermissions[permissionRequestKey] = new Subject();
155
+ this._permissionRequestsByKey[permissionRequestKey] = permissionRequestWithContext;
154
156
  this.queuePermission(permissionRequestWithContext);
155
157
  this.logger.debug('Permissions: return new pending', permissionRequestKey);
156
158
  return this._pendingPermissions[permissionRequestKey].asObservable();
157
159
  }
160
+ /**
161
+ * Invalidates cached and in-flight permission results for the provided resource, so that
162
+ * subsequent permission requests are re-evaluated by the backend. Call this after an action
163
+ * that can change the outcome of permission checks (e.g. changing a task assignment).
164
+ *
165
+ * @param resource the resource type to invalidate, e.g.
166
+ * `com.ritense.valtimo.operaton.domain.OperatonTask`
167
+ * @param identifier when provided, only permissions requested with a context for this specific
168
+ * resource instance (or without an instance context) are invalidated; otherwise all permissions
169
+ * for the resource are invalidated
170
+ */
171
+ invalidateResource(resource, identifier) {
172
+ Object.entries(this._permissionRequestsByKey).forEach(([permissionRequestKey, permissionRequest]) => {
173
+ if (!this.permissionRequestMatchesResource(permissionRequest, resource, identifier)) {
174
+ return;
175
+ }
176
+ this.logger.debug('Permissions: invalidate permission request', permissionRequestKey);
177
+ delete this._cachedResolvedPermissions[permissionRequestKey];
178
+ delete this._pendingPermissions[permissionRequestKey];
179
+ delete this._permissionRequestsByKey[permissionRequestKey];
180
+ });
181
+ }
182
+ permissionRequestMatchesResource(permissionRequest, resource, identifier) {
183
+ const context = permissionRequest.context;
184
+ if (context?.resource === resource) {
185
+ return !identifier || context.identifier === identifier;
186
+ }
187
+ return permissionRequest.resource === resource;
188
+ }
158
189
  queuePermission(permissionRequest) {
159
190
  if (!this._permissionQueueSubscription || this._permissionQueueSubscription.closed) {
160
191
  this.logger.debug('Permissions: open new queue subscription');
@@ -172,11 +203,21 @@ class PermissionService {
172
203
  .resolvePermissionRequestQueue(queueCopy)
173
204
  .pipe(take(1))
174
205
  .subscribe(resolvedPermissions => {
206
+ const resolvedPendingPermissions = {};
175
207
  Object.keys(resolvedPermissions).forEach(permissionRequestKey => {
176
- this._pendingPermissions[permissionRequestKey].next(resolvedPermissions[permissionRequestKey]);
208
+ const pendingPermission = this._pendingPermissions[permissionRequestKey];
209
+ // requests invalidated while in flight no longer have a pending permission
210
+ // and their results are discarded to prevent caching a stale value
211
+ if (!pendingPermission)
212
+ return;
213
+ pendingPermission.next(resolvedPermissions[permissionRequestKey]);
214
+ pendingPermission.complete();
215
+ delete this._pendingPermissions[permissionRequestKey];
216
+ resolvedPendingPermissions[permissionRequestKey] =
217
+ resolvedPermissions[permissionRequestKey];
177
218
  this.logger.debug(`Permissions: resolved pending permission request ${permissionRequestKey}`, resolvedPermissions[permissionRequestKey]);
178
219
  });
179
- this.cacheResolvedPermissions(resolvedPermissions);
220
+ this.cacheResolvedPermissions(resolvedPendingPermissions);
180
221
  });
181
222
  });
182
223
  }
@@ -200,6 +241,7 @@ class PermissionService {
200
241
  .subscribe(() => {
201
242
  this.clearPending();
202
243
  this.clearCache();
244
+ this.clearPermissionRequests();
203
245
  });
204
246
  }
205
247
  emptyQueue() {
@@ -214,6 +256,10 @@ class PermissionService {
214
256
  this.logger.debug('Permissions: clear pending');
215
257
  this._pendingPermissions = {};
216
258
  }
259
+ clearPermissionRequests() {
260
+ this.logger.debug('Permissions: clear permission requests');
261
+ this._permissionRequestsByKey = {};
262
+ }
217
263
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PermissionService, deps: [{ token: i1$1.KeycloakService }, { token: i3.NGXLogger }, { token: PermissionApiService }], target: i0.ɵɵFactoryTarget.Injectable }); }
218
264
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PermissionService, providedIn: 'root' }); }
219
265
  }
@@ -1 +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-2025 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-2025 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-2025 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-2025 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-2025 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/shared';\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-2025 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 {jwtDecode} 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 = jwtDecode(token).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-2025 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-2025 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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iB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAAA,IAAA,CAAA,eAAA,EAAA,EAAA,EAAA,KAAA,EAAAC,EAAA,CAAA,SAAA,EAAA,EAAA,EAAA,KAAA,EAAAC,oBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAjB,IAAA,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;;4FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACnCD;;;;;;;;;;;;;;AAcG;;ACdH;;;;;;;;;;;;;;AAcG;AAEH;;AAEG;;AClBH;;AAEG;;;;"}
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-2025 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-2025 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-2025 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-2025 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-2025 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/shared';\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-2025 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 {jwtDecode} 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 _permissionRequestsByKey: {[permissionRequestKey: string]: PermissionRequest} = {};\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 this._permissionRequestsByKey[permissionRequestKey] = permissionRequestWithContext;\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 /**\n * Invalidates cached and in-flight permission results for the provided resource, so that\n * subsequent permission requests are re-evaluated by the backend. Call this after an action\n * that can change the outcome of permission checks (e.g. changing a task assignment).\n *\n * @param resource the resource type to invalidate, e.g.\n * `com.ritense.valtimo.operaton.domain.OperatonTask`\n * @param identifier when provided, only permissions requested with a context for this specific\n * resource instance (or without an instance context) are invalidated; otherwise all permissions\n * for the resource are invalidated\n */\n public invalidateResource(resource: string, identifier?: string): void {\n Object.entries(this._permissionRequestsByKey).forEach(\n ([permissionRequestKey, permissionRequest]) => {\n if (!this.permissionRequestMatchesResource(permissionRequest, resource, identifier)) {\n return;\n }\n\n this.logger.debug('Permissions: invalidate permission request', permissionRequestKey);\n\n delete this._cachedResolvedPermissions[permissionRequestKey];\n delete this._pendingPermissions[permissionRequestKey];\n delete this._permissionRequestsByKey[permissionRequestKey];\n }\n );\n }\n\n private permissionRequestMatchesResource(\n permissionRequest: PermissionRequest,\n resource: string,\n identifier?: string\n ): boolean {\n const context = permissionRequest.context;\n\n if (context?.resource === resource) {\n return !identifier || context.identifier === identifier;\n }\n\n return permissionRequest.resource === resource;\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 const resolvedPendingPermissions: ResolvedPermissions = {};\n\n Object.keys(resolvedPermissions).forEach(permissionRequestKey => {\n const pendingPermission = this._pendingPermissions[permissionRequestKey];\n\n // requests invalidated while in flight no longer have a pending permission\n // and their results are discarded to prevent caching a stale value\n if (!pendingPermission) return;\n\n pendingPermission.next(resolvedPermissions[permissionRequestKey]);\n pendingPermission.complete();\n delete this._pendingPermissions[permissionRequestKey];\n\n resolvedPendingPermissions[permissionRequestKey] =\n resolvedPermissions[permissionRequestKey];\n\n this.logger.debug(\n `Permissions: resolved pending permission request ${permissionRequestKey}`,\n resolvedPermissions[permissionRequestKey]\n );\n });\n\n this.cacheResolvedPermissions(resolvedPendingPermissions);\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 = jwtDecode(token).exp * 1000;\n const expiryTime = tokenExp - Date.now() - 1000;\n return timer(expiryTime);\n })\n )\n .subscribe(() => {\n this.clearPending();\n this.clearCache();\n this.clearPermissionRequests();\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 private clearPermissionRequests(): void {\n this.logger.debug('Permissions: clear permission requests');\n this._permissionRequestsByKey = {};\n }\n}\n","/*\n * Copyright 2015-2025 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-2025 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;AAC/C,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM;IAExB,IAAI,IAAI,GAAG,CAAC;AAEZ,IAAA,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;AAC/C,QAAA,IAAI,IAAI,CAAC,CAAC;IACZ;IACA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAE;AAClB;;AC7BA;;;;;;;;;;;;;;AAcG;;MCkBU,oBAAoB,CAAA;AAG/B,IAAA,WAAA,CACmB,IAAgB,EAChB,aAA4B,EAC5B,MAAiB,EAAA;QAFjB,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,aAAa,GAAb,aAAa;QACb,IAAA,CAAA,MAAM,GAAN,MAAM;AAEvB,QAAA,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW;IAC5E;AAEO,IAAA,6BAA6B,CAClC,sBAA8C,EAAA;QAE9C,IAAI,CAAC,MAAM,CA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PERIOD_MS;
12
12
  private _cachedResolvedPermissions;
13
13
  private _pendingPermissions;
14
+ private _permissionRequestsByKey;
14
15
  private _permissionRequestQueue;
15
16
  private _permissionQueueSubscription;
16
17
  private _clearCacheSubscription;
17
18
  constructor(keyCloakService: KeycloakService, logger: NGXLogger, permissionApiService: PermissionApiService);
18
19
  requestPermission(permissionRequest: PermissionRequest, context?: PermissionContext): Observable<boolean>;
20
+ /**
21
+ * Invalidates cached and in-flight permission results for the provided resource, so that
22
+ * subsequent permission requests are re-evaluated by the backend. Call this after an action
23
+ * that can change the outcome of permission checks (e.g. changing a task assignment).
24
+ *
25
+ * @param resource the resource type to invalidate, e.g.
26
+ * `com.ritense.valtimo.operaton.domain.OperatonTask`
27
+ * @param identifier when provided, only permissions requested with a context for this specific
28
+ * resource instance (or without an instance context) are invalidated; otherwise all permissions
29
+ * for the resource are invalidated
30
+ */
31
+ invalidateResource(resource: string, identifier?: string): void;
32
+ private permissionRequestMatchesResource;
19
33
  private queuePermission;
20
34
  private openQueueSubscription;
21
35
  private cacheResolvedPermissions;
@@ -23,6 +37,7 @@ export declare class PermissionService {
23
37
  private emptyQueue;
24
38
  private clearCache;
25
39
  private clearPending;
40
+ private clearPermissionRequests;
26
41
  static ɵfac: i0.ɵɵFactoryDeclaration<PermissionService, never>;
27
42
  static ɵprov: i0.ɵɵInjectableDeclaration<PermissionService>;
28
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valtimo/access-control",
3
- "version": "13.37.0",
3
+ "version": "13.39.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "19.2.25",
6
6
  "@angular/core": "19.2.25"