Fix PNI serviceId bytes on export

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-17 14:18:41 -05:00
committed by GitHub
parent fdfecdb5d9
commit b0f3f5fa56

View File

@@ -28,6 +28,7 @@ import { getStickerPacksForBackup } from '../../types/Stickers.preload.js';
import {
isPniString,
isServiceIdString,
type PniString,
type AciString,
type ServiceIdString,
} from '../../types/ServiceId.std.js';
@@ -1240,11 +1241,9 @@ export class BackupExportStream extends Readable {
const maybePni = convo.pni ?? convo.serviceId;
const aci = isAciString(convo.serviceId)
? Aci.parseFromServiceIdString(convo.serviceId).getRawUuidBytes()
: null;
const pni = isPniString(maybePni)
? Pni.parseFromServiceIdString(maybePni).getRawUuidBytes()
? this.#aciToBytes(convo.serviceId)
: null;
const pni = isPniString(maybePni) ? this.#pniToRawBytes(maybePni) : null;
const e164 = convo.e164 ? BigInt(convo.e164) : null;
strictAssert(
@@ -1935,8 +1934,14 @@ export class BackupExportStream extends Readable {
return null;
}
/** For fields explicitly marked as PNI (validator will expect 16 bytes) */
#pniToRawBytes(pni: PniString | string): Uint8Array {
return Pni.parseFromServiceIdString(pni).getRawUuidBytes();
}
/** For fields that can accept either ACI or PNI bytes */
#serviceIdToBytes(serviceId: ServiceIdString): Uint8Array {
return ServiceId.parseFromServiceIdString(serviceId).getRawUuidBytes();
return ServiceId.parseFromServiceIdString(serviceId).getServiceIdBinary();
}
async #toChatItemFromNonBubble(
@@ -2840,7 +2845,7 @@ export class BackupExportStream extends Readable {
? this.#aciToBytes(detail.serviceId)
: null,
inviteePni: isPniString(detail.serviceId)
? this.#serviceIdToBytes(detail.serviceId)
? this.#pniToRawBytes(detail.serviceId)
: null,
},
],