import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; export declare type Permission = { exp: number; resource_set_id: string; resource_set_name: string; scopes: Array; }; export declare type UserRoleData = { assignee_id: string; assignee_type: string; inherited: boolean; inherited_from: string; role_name: string; }; export declare class PermissionService { private http; private authApi; private jwtHelper; private headers; constructor(http: HttpClient, authApi: string); /** * Returns all the scopes a user has for a specific resource. * @param resourceId ID of a specific resource such as a Space */ getAllScopes(resourceId: string): Observable; /** * Checks if a user has a specific scope for a resource. * @param resourceId ID of a specific resource such as a Space * @param scope the scope you want to check for. Ex - `can edit` */ hasScope(resourceId: string, scope: string): Observable; /** * Returns the permission for a specific resource. * If there is no permission info in current RPT then we need to audit new RPT token. * @param resourceId ID of a specific resource such as a Space */ getPermission(resourceId: string): Observable; /** * Assign a specific role to a one or more users in a resource such as space. * @param resourceId ID of a specific resource such as a Space * @param roleName Role to be assigned for the resource * @param userIDs IDs for users that need to be assigned the specified role. */ assignRole(resourceId: string, roleName: string, userIDs: Array): Observable; /** * Get all the users who have a speicific role. * @param resourceId ID of a specific resource such as a Space * @param roleName Role to get all the users for the resource */ getUsersByRole(resourceId: string, roleName: string): Observable; /** * Call the Audit RPT API to get a new RPT token if the token if not an RPT * Or if the token doesn't contain permission info for a particular resource * @param resourceId ID of a specific resource such as a Space */ findPermissionAfterAudit(resourceId: string): Observable; /** * Find permission info for a particular resource in decoded RPT token. * @param token Decoded RPT token * @param resourceId ID of a specific resource such as a Space */ private findPermission; /** * Saves new token with RPT info as auth_token in localStorage. * @param rpt RPT token returned after calling audit API */ private saveRPT; /** * Decodes the JWT token using JwtHelperService from `angular-jwt`. * If the token if not valid RPT the call auditRPT to get new token. */ private getDecodedToken; }