{"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,i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