Use untagged pnis in storage service

This commit is contained in:
Fedor Indutny 2023-09-28 01:14:55 +02:00 committed by GitHub
parent 283ef57779
commit eb7942dd1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 530 additions and 62 deletions

View file

@ -49,6 +49,10 @@ export function toTaggedPni(untagged: UntaggedPniString): PniString {
return `PNI:${untagged}` as PniString;
}
export function toUntaggedPni(pni: PniString): UntaggedPniString {
return pni.replace(/^PNI:/i, '') as UntaggedPniString;
}
export function normalizeServiceId(
rawServiceId: string,
context: string,
@ -106,10 +110,9 @@ export function normalizePni(
}
const result = rawPni.toLowerCase().replace(/^pni:/, 'PNI:');
if (!isPniString(result)) {
logger.warn(
`Normalizing invalid serviceId: ${rawPni} to ${result} in context "${context}"`
`Normalizing invalid pni: ${rawPni} to ${result} in context "${context}"`
);
// Cast anyway we don't want to throw here