import {Data, Events, Message} from './Messages'; import {RequestIdHelper} from './RequestIdHelper'; import { Secrets } from './Secrets'; interface PairRequestData extends Data { padding: boolean } // // Pairing Interaction 1: Outgoing // export class PairRequest { ToMessage() { const data = { padding: true }; return new Message(RequestIdHelper.Id("pr"), Events.PairRequest, data, false); } } export interface KeyRequestData extends Data { enc: { A: string; }; hmac: { A: string; }; } // Pairing Interaction 2: Incoming export class KeyRequest { public RequestId: string; public Aenc: string; public Ahmac: string; constructor(m: Message) { this.RequestId = m.Id; this.Aenc = m.Data.enc.A; this.Ahmac = m.Data.hmac.A; } } // Pairing Interaction 3: Outgoing export class KeyResponse { public RequestId: string; public Benc: string; public Bhmac: string; constructor(requestId: string, Benc: string, Bhmac: string) { this.RequestId = requestId; this.Benc = Benc; this.Bhmac = Bhmac; } ToMessage() { const data = { enc: { B: this.Benc }, hmac: { B: this.Bhmac } }; return new Message(this.RequestId, Events.KeyResponse, data, false); } } // Pairing Interaction 4: Incoming export class KeyCheck { public ConfirmationCode: string; constructor(m: Message) { this.ConfirmationCode = m.IncomingHmac.substring(0,6); } } // Pairing Interaction 5: Incoming export class PairResponse { public Success: boolean; constructor(m: Message) { this.Success = m.Data.success; } } // Holder class for Secrets and KeyResponse, so that we can use them together in method signatures. export class SecretsAndKeyResponse { public Secrets: Secrets; public KeyResponse: KeyResponse; constructor(secrets: Secrets, keyResponse: KeyResponse) { this.Secrets = secrets; this.KeyResponse = keyResponse; } } export class DropKeysRequest { ToMessage() { return new Message(RequestIdHelper.Id("drpkys"), Events.DropKeysAdvice, null, true); } }