import { OpenYoloCredential } from '../protocol/data' ; import { OpenYoloInternalError } from '../protocol/errors' ; import { RpcMessageType , saveMessage } from '../protocol/rpc_messages' ; import { BaseRequest } from './base_request' ; export class CredentialSave extends BaseRequest < void , OpenYoloCredential > { dispatchInternal ( credential ) { this . registerHandler ( RpcMessageType . saveResult , ( saved ) => { if ( saved ) { this . resolve ( ) ; } else { this . reject ( OpenYoloInternalError . userCanceled ( ) . toExposedError ( ) ) ; } this . dispose ( ) ; } ) ; this . channel . send ( saveMessage ( this . id , credential ) ) ; } }