import { IConnection } from './Connection'; import { IBunkerConsent } from './Transaction'; export declare enum ConsentResponse { Given = "given", Rejected = "rejected", Unknown = "unknown" } export interface IChallengeClaim { 'component-id': string; claim: any; } export interface IBunkerConsentPayload { key: string; secret: string; message?: string; transaction?: any; 'wallet-address'?: string; } export declare enum SecurityRating { Insufficient = "insufficient", Secure = "secure", Highlysecure = "highlysecure" } export declare enum PolicyAction { None = "none", Account = "account", SignMessage = "sign-message", SignTransaction = "sign-transaction", AddComponent = "component-add", AddPolicy = "policy-add", Key = "key-create" } export interface IPolicyComponent { title: string; description: string; 'component-id'?: string; 'module-name'?: string; fact?: any; 'seed-id'?: string; modified?: string; } /** * The policy-class of the wallet */ export declare class Policy { connection: IConnection; /** * initializes the class * @param connection The backend connection object. */ constructor(connection: IConnection); /** * Create new policy * T.B.D where to get consent response needs to be determined by bunker team. * @param consentResponse The consent response (T.B.D fixed value "given" is used atm, but will be changed) * @returns The policy-id */ createPolicy(consentResponse: ConsentResponse): Promise; /** * Removes a policy * @param consentResponse The consent response (T.B.D fixed value "given" is used atm, but will be changed) * @param policyId The policy id to delete * @returns true if successful */ removePolicy(consentResponse: ConsentResponse, policyId: string): Promise; /** * Updates a policy's components * @param consentResponse The consent response (T.B.D fixed value "given" is used atm, but will be changed) * @param policyId The policy id to update * @param components The new components * @returns true if successful */ updatePolicy(consentResponse: ConsentResponse, policyId: string, components: IPolicyComponent[]): Promise; /** * Verifies a policy (t.b.d what's this?) * @param action The action * @param components The components to verify * @returns The bunker response */ verifyPolicy(action: PolicyAction, components: IPolicyComponent[]): Promise<{ action: PolicyAction; score: SecurityRating; components: SecurityRating[]; }>; /** * Get all user's policies * @returns An array with the user's policies */ getUserPolicies(): Promise; /** * Adds a component to a policy * @param policyId The target policy id * @param component The component to add * @returns true if successful */ addComponentToPolicy(policyId: string, component: IPolicyComponent): Promise; /** * Updates a component for a policy * @param policyId The target policy id * @param componentId The component id to update * @param component The new component * @returns true if successful */ updateComponentForPolicy(policyId: string, componentId: string, component: IPolicyComponent): Promise; /** * Gets policy components of policy id * @param policyId The target policy id * @returns The policy-components */ getPolicyComponents(policyId: string): Promise; /** * Assign a policy to an action * @param action The action to be assigned a policy * @param entity The entity * @param policyId The target policy id * @returns true if successful */ assignPolicy(action: string, entity: string, policyId: string): Promise; /** * Sets a default policy * @param policyId The target policy id * @returns true if successful */ setDefaultPolicy(policyId: string): Promise; /** * The Challenge policy * @param policyId The target policy id * @param payload The payload * @param action The action to challenge * @param claims The claim * @returns */ challengePolicy(policyId: string, payload: IBunkerConsentPayload, action: PolicyAction, claims: IChallengeClaim[]): Promise; } export default Policy;