From 00f0ccd900b6318edb7d8d5ea39b5f550553b0b2 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 30 Aug 2023 05:15:28 +0200 Subject: [PATCH] Explicit ACI check for contact serviceId --- ts/util/safetyNumber.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ts/util/safetyNumber.ts b/ts/util/safetyNumber.ts index 428ba25ced..f798736191 100644 --- a/ts/util/safetyNumber.ts +++ b/ts/util/safetyNumber.ts @@ -15,6 +15,7 @@ import { SafetyNumberIdentifierType, SafetyNumberMode, } from '../types/safetyNumber'; +import { isAciString } from '../types/ServiceId'; const ITERATION_COUNT = 5200; const E164_VERSION = 1; @@ -37,8 +38,9 @@ export async function generateSafetyNumbers( const us = storage.protocol.getIdentityRecord(ourAci); const ourKeyBuffer = us ? us.publicKey : null; - const theirAci = - contact.pni !== contact.serviceId ? contact.serviceId : undefined; + const theirAci = isAciString(contact.serviceId) + ? contact.serviceId + : undefined; const them = theirAci ? await storage.protocol.getOrMigrateIdentityRecord(theirAci) : undefined;