From f491158b3f1e8e51a74db1cda75a1914f8ceb9f1 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 14 Jul 2020 12:33:07 +1000 Subject: [PATCH] add the group id from mobile as valid pubkey key --- ts/session/types/PubKey.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ts/session/types/PubKey.ts b/ts/session/types/PubKey.ts index b64e899dc..8fad0664f 100644 --- a/ts/session/types/PubKey.ts +++ b/ts/session/types/PubKey.ts @@ -1,10 +1,14 @@ export class PubKey { 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( - `^(05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - 2}}$` + `^${PubKey.regexForPubkeys}|${PubKey.regexForMobileGroupID}$` ); public readonly key: string; - /** * A PubKey object. * If `pubKeyString` is not valid then this will throw an `Error`. @@ -44,11 +48,7 @@ export class PubKey { } public static validate(pubkeyString: string): boolean { - if (this.regex.test(pubkeyString)) { - return true; - } - - return false; + return this.regex.test(pubkeyString); } public isEqual(comparator: PubKey | string) {