import { Logger } from 'winston'; import { IAuthorizonConfig } from '../config'; import { Dict } from '../utils/dict'; import { IUser } from '../enforcement/interfaces'; export interface ITenant { key: string; name: string; description?: string; } /** * This interface contains *read actions* that goes outside * of your local network and queries authorizon cloud api. * You should be aware that these actions incur some cross-cloud latency. */ export interface IAuthorizonCloudReads { getUser(userKey: string): Promise; getRole(roleKey: string): Promise; getTenant(tenantKey: string): Promise; getAssignedRoles(userKey: string, tenantKey?: string): Promise; } /** * This interface contains *write actions* (or mutations) that manipulate remote * state by calling the authorizon api. These api calls goes *outside* your local network. * You should be aware that these actions incur some cross-cloud latency. */ export interface IAuthorizonCloudMutations { syncUser(user: IUser): Promise; deleteUser(userKey: string): Promise; createTenant(tenant: ITenant): Promise; updateTenant(tenant: ITenant): Promise; deleteTenant(tenantKey: string): Promise; assignRole(userKey: string, roleKey: string, tenantKey: string): Promise; unassignRole(userKey: string, roleKey: string, tenantKey: string): Promise; } export interface CloudReadCallback { (api: IAuthorizonCloudReads): Promise; } export interface CloudWriteCallback { (api: IAuthorizonCloudMutations): Promise; } export interface IMutationsClient { read(callback: CloudReadCallback): Promise; save(callback: CloudWriteCallback): Promise; } export declare class MutationsClient implements IAuthorizonCloudReads, IAuthorizonCloudMutations, IMutationsClient { private config; private logger; private client; constructor(config: IAuthorizonConfig, logger: Logger); getUser(userKey: string): Promise; getRole(roleKey: string): Promise; getTenant(tenantKey: string): Promise; getAssignedRoles(userKey: string, tenantKey?: string): Promise; syncUser(user: IUser): Promise; deleteUser(userKey: string): Promise; createTenant(tenant: ITenant): Promise; updateTenant(tenant: ITenant): Promise; deleteTenant(tenantKey: string): Promise; assignRole(userKey: string, roleKey: string, tenantKey: string): Promise; unassignRole(userKey: string, roleKey: string, tenantKey: string): Promise; read(callback: CloudReadCallback): Promise; save(callback: CloudWriteCallback): Promise; getMethods(): IMutationsClient; }