Hold CDSI lookup ACI & UAK args in one array
This commit is contained in:
parent
fcf2c0a3f0
commit
87659ef2b5
4 changed files with 13 additions and 33 deletions
|
@ -763,8 +763,7 @@ export type WhoamiResultType = z.infer<typeof whoamiResultZod>;
|
||||||
|
|
||||||
export type CdsLookupOptionsType = Readonly<{
|
export type CdsLookupOptionsType = Readonly<{
|
||||||
e164s: ReadonlyArray<string>;
|
e164s: ReadonlyArray<string>;
|
||||||
acis?: ReadonlyArray<AciString>;
|
acisAndAccessKeys?: ReadonlyArray<{ aci: AciString; accessKey: string }>;
|
||||||
accessKeys?: ReadonlyArray<string>;
|
|
||||||
returnAcisWithoutUaks?: boolean;
|
returnAcisWithoutUaks?: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
@ -3481,14 +3480,12 @@ export function initialize({
|
||||||
|
|
||||||
async function cdsLookup({
|
async function cdsLookup({
|
||||||
e164s,
|
e164s,
|
||||||
acis = [],
|
acisAndAccessKeys = [],
|
||||||
accessKeys = [],
|
|
||||||
returnAcisWithoutUaks,
|
returnAcisWithoutUaks,
|
||||||
}: CdsLookupOptionsType): Promise<CDSResponseType> {
|
}: CdsLookupOptionsType): Promise<CDSResponseType> {
|
||||||
return cds.request({
|
return cds.request({
|
||||||
e164s,
|
e164s,
|
||||||
acis,
|
acisAndAccessKeys,
|
||||||
accessKeys,
|
|
||||||
returnAcisWithoutUaks,
|
returnAcisWithoutUaks,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,7 @@ export abstract class CDSSocketBase<
|
||||||
|
|
||||||
public async request({
|
public async request({
|
||||||
e164s,
|
e164s,
|
||||||
acis,
|
acisAndAccessKeys,
|
||||||
accessKeys,
|
|
||||||
returnAcisWithoutUaks = false,
|
returnAcisWithoutUaks = false,
|
||||||
}: CDSRequestOptionsType): Promise<CDSResponseType> {
|
}: CDSRequestOptionsType): Promise<CDSResponseType> {
|
||||||
const log = this.logger;
|
const log = this.logger;
|
||||||
|
@ -81,23 +80,11 @@ export abstract class CDSSocketBase<
|
||||||
'CDS Connection not established'
|
'CDS Connection not established'
|
||||||
);
|
);
|
||||||
|
|
||||||
const aciUakPairs = new Array<Uint8Array>();
|
|
||||||
|
|
||||||
const version = 2;
|
const version = 2;
|
||||||
strictAssert(
|
|
||||||
acis.length === accessKeys.length,
|
|
||||||
`Number of ACIs ${acis.length} is different ` +
|
|
||||||
`from number of access keys ${accessKeys.length}`
|
|
||||||
);
|
|
||||||
|
|
||||||
for (let i = 0; i < acis.length; i += 1) {
|
const aciUakPairs = acisAndAccessKeys.map(({ aci, accessKey }) =>
|
||||||
aciUakPairs.push(
|
Bytes.concatenate([uuidToBytes(aci), Bytes.fromBase64(accessKey)])
|
||||||
Bytes.concatenate([
|
);
|
||||||
uuidToBytes(acis[i]),
|
|
||||||
Bytes.fromBase64(accessKeys[i]),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const request = Proto.CDSClientRequest.encode({
|
const request = Proto.CDSClientRequest.encode({
|
||||||
newE164s: Buffer.concat(
|
newE164s: Buffer.concat(
|
||||||
|
|
3
ts/textsecure/cds/Types.d.ts
vendored
3
ts/textsecure/cds/Types.d.ts
vendored
|
@ -17,8 +17,7 @@ export type CDSResponseType = ReadonlyMap<string, CDSResponseEntryType>;
|
||||||
|
|
||||||
export type CDSRequestOptionsType = Readonly<{
|
export type CDSRequestOptionsType = Readonly<{
|
||||||
e164s: ReadonlyArray<string>;
|
e164s: ReadonlyArray<string>;
|
||||||
acis: ReadonlyArray<AciString>;
|
acisAndAccessKeys: ReadonlyArray<{ aci: AciString; accessKey: string }>;
|
||||||
accessKeys: ReadonlyArray<string>;
|
|
||||||
returnAcisWithoutUaks?: boolean;
|
returnAcisWithoutUaks?: boolean;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}>;
|
}>;
|
||||||
|
|
|
@ -15,8 +15,7 @@ export async function getServiceIdsForE164s(
|
||||||
// Note: these have no relationship to supplied e164s. We just provide
|
// Note: these have no relationship to supplied e164s. We just provide
|
||||||
// all available information to the server so that it could return as many
|
// all available information to the server so that it could return as many
|
||||||
// ACI+PNI+E164 matches as possible.
|
// ACI+PNI+E164 matches as possible.
|
||||||
const acis = new Array<AciString>();
|
const acisAndAccessKeys = new Array<{ aci: AciString; accessKey: string }>();
|
||||||
const accessKeys = new Array<string>();
|
|
||||||
|
|
||||||
for (const convo of window.ConversationController.getAll()) {
|
for (const convo of window.ConversationController.getAll()) {
|
||||||
if (!isDirectConversation(convo.attributes) || isMe(convo.attributes)) {
|
if (!isDirectConversation(convo.attributes) || isMe(convo.attributes)) {
|
||||||
|
@ -34,8 +33,7 @@ export async function getServiceIdsForE164s(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
acis.push(aci);
|
acisAndAccessKeys.push({ aci, accessKey });
|
||||||
accessKeys.push(accessKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnAcisWithoutUaks =
|
const returnAcisWithoutUaks =
|
||||||
|
@ -43,13 +41,12 @@ export async function getServiceIdsForE164s(
|
||||||
isEnabled('desktop.cdsi.returnAcisWithoutUaks');
|
isEnabled('desktop.cdsi.returnAcisWithoutUaks');
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
`getServiceIdsForE164s(${e164s}): acis=${acis.length} ` +
|
`getServiceIdsForE164s(${e164s}): acis=${acisAndAccessKeys.length} ` +
|
||||||
`accessKeys=${accessKeys.length}`
|
`accessKeys=${acisAndAccessKeys.length}`
|
||||||
);
|
);
|
||||||
return server.cdsLookup({
|
return server.cdsLookup({
|
||||||
e164s,
|
e164s,
|
||||||
acis,
|
acisAndAccessKeys,
|
||||||
accessKeys,
|
|
||||||
returnAcisWithoutUaks,
|
returnAcisWithoutUaks,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue