Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
414c0a58d3
commit
366b875fd2
269 changed files with 5832 additions and 5550 deletions
|
@ -9,8 +9,9 @@ import Long from 'long';
|
|||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { UUID_BYTE_SIZE } from '../../types/UUID';
|
||||
import { isAciString, isUntaggedPniString } from '../../types/ServiceId';
|
||||
import * as Bytes from '../../Bytes';
|
||||
import { UUID_BYTE_SIZE } from '../../Crypto';
|
||||
import { uuidToBytes, bytesToUuid } from '../../util/uuidToBytes';
|
||||
import { SignalService as Proto } from '../../protobuf';
|
||||
import type {
|
||||
|
@ -246,6 +247,14 @@ function decodeSingleResponse(
|
|||
const e164 = `+${e164Long.toString()}`;
|
||||
const pni = bytesToUuid(pniBytes);
|
||||
const aci = bytesToUuid(aciBytes);
|
||||
strictAssert(
|
||||
aci === undefined || isAciString(aci),
|
||||
'CDSI response has invalid ACI'
|
||||
);
|
||||
strictAssert(
|
||||
pni === undefined || isUntaggedPniString(pni),
|
||||
'CDSI response has invalid PNI'
|
||||
);
|
||||
|
||||
resultMap.set(e164, { pni, aci });
|
||||
}
|
||||
|
|
8
ts/textsecure/cds/Types.d.ts
vendored
8
ts/textsecure/cds/Types.d.ts
vendored
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { UUIDStringType } from '../../types/UUID';
|
||||
import type { AciString, UntaggedPniString } from '../../types/ServiceId';
|
||||
|
||||
export type CDSAuthType = Readonly<{
|
||||
username: string;
|
||||
|
@ -9,15 +9,15 @@ export type CDSAuthType = Readonly<{
|
|||
}>;
|
||||
|
||||
export type CDSResponseEntryType = Readonly<{
|
||||
aci: UUIDStringType | undefined;
|
||||
pni: UUIDStringType | undefined;
|
||||
aci: AciString | undefined;
|
||||
pni: UntaggedPniString | undefined;
|
||||
}>;
|
||||
|
||||
export type CDSResponseType = ReadonlyMap<string, CDSResponseEntryType>;
|
||||
|
||||
export type CDSRequestOptionsType = Readonly<{
|
||||
e164s: ReadonlyArray<string>;
|
||||
acis: ReadonlyArray<UUIDStringType>;
|
||||
acis: ReadonlyArray<AciString>;
|
||||
accessKeys: ReadonlyArray<string>;
|
||||
returnAcisWithoutUaks?: boolean;
|
||||
timeout?: number;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue