import { Type } from 'class-transformer' ; import { PairingQR } from './krpairing' ; export enum RequestType { unpair = 'unpair' , getState = 'getState' , refreshPopup = 'refreshPopup' } export class Message { public static newRequest ( r ) { const m = new Message ( ) ; m . request = r ; return m ; } public static newResponse ( r ) { const m = new Message ( ) ; m . response = r ; return m ; } public static newToast ( t ) { const m = new Message ( ) ; m . toast = t ; return m ; } @ Type ( ( ) => Request ) public request ? : Request ; @ Type ( ( ) => Response ) public response ? : Response ; @ Type ( ( ) => Toast ) public toast ? : Toast ; } export class Request { public ty : RequestType ; constructor ( t ) { this . ty = t ; } } export class Response { public paired : boolean ; public phoneName ? : string ; @ Type ( ( ) => PairingQR ) public qr ? : PairingQR ; public u2fAccounts ? : string [ ] ; } export class Toast { public error ? : string ; public success ? : string ; public pending ? : string ; }