add the group id from mobile as valid pubkey key

pull/1246/head
Audric Ackermann 5 years ago
parent c843da0e94
commit f491158b3f
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1,10 +1,14 @@
export class PubKey { export class PubKey {
public static readonly PUBKEY_LEN = 66; public static readonly PUBKEY_LEN = 66;
public static readonly MOBILE_GROUP_PUBKEY_LEN = 32;
private static readonly regexForMobileGroupID = `__textsecure_group__![0-9a-fA-F]{${PubKey.MOBILE_GROUP_PUBKEY_LEN}}`;
// prettier-ignore
private static readonly regexForPubkeys = `((05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - 2}})`;
private static readonly regex: RegExp = new RegExp( private static readonly regex: RegExp = new RegExp(
`^(05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - 2}}$` `^${PubKey.regexForPubkeys}|${PubKey.regexForMobileGroupID}$`
); );
public readonly key: string; public readonly key: string;
/** /**
* A PubKey object. * A PubKey object.
* If `pubKeyString` is not valid then this will throw an `Error`. * If `pubKeyString` is not valid then this will throw an `Error`.
@ -44,11 +48,7 @@ export class PubKey {
} }
public static validate(pubkeyString: string): boolean { public static validate(pubkeyString: string): boolean {
if (this.regex.test(pubkeyString)) { return this.regex.test(pubkeyString);
return true;
}
return false;
} }
public isEqual(comparator: PubKey | string) { public isEqual(comparator: PubKey | string) {

Loading…
Cancel
Save