You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1006 B
TypeScript
34 lines
1006 B
TypeScript
import { SignalProtocolAddress } from '../../../window/types/libsignal-protocol';
|
|
|
|
export class SignalProtocolAddressStub extends SignalProtocolAddress {
|
|
private readonly hexEncodedPublicKey: string;
|
|
private readonly deviceId: number;
|
|
constructor(hexEncodedPublicKey: string, deviceId: number) {
|
|
super(hexEncodedPublicKey, deviceId);
|
|
this.hexEncodedPublicKey = hexEncodedPublicKey;
|
|
this.deviceId = deviceId;
|
|
}
|
|
|
|
// tslint:disable-next-line: function-name
|
|
public static fromString(encodedAddress: string): SignalProtocolAddressStub {
|
|
const values = encodedAddress.split('.');
|
|
|
|
return new SignalProtocolAddressStub(values[0], Number(values[1]));
|
|
}
|
|
|
|
public getName(): string {
|
|
return this.hexEncodedPublicKey;
|
|
}
|
|
public getDeviceId(): number {
|
|
return this.deviceId;
|
|
}
|
|
|
|
public equals(other: SignalProtocolAddress): boolean {
|
|
return other.getName() === this.hexEncodedPublicKey;
|
|
}
|
|
|
|
public toString(): string {
|
|
return this.hexEncodedPublicKey;
|
|
}
|
|
}
|