Include ACI+Access Keys pairs with CDSI requests
This commit is contained in:
parent
13046dc020
commit
757af2cbbe
17 changed files with 145 additions and 144 deletions
|
@ -671,9 +671,9 @@ export default class OutgoingMessage {
|
|||
if (isValidUuid(identifier)) {
|
||||
// We're good!
|
||||
} else if (isValidNumber(identifier)) {
|
||||
if (!window.textsecure.messaging) {
|
||||
if (!window.textsecure.server) {
|
||||
throw new Error(
|
||||
'sendToIdentifier: window.textsecure.messaging is not available!'
|
||||
'sendToIdentifier: window.textsecure.server is not available!'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ export default class OutgoingMessage {
|
|||
conversations: [
|
||||
window.ConversationController.getOrCreate(identifier, 'private'),
|
||||
],
|
||||
messaging: window.textsecure.messaging,
|
||||
server: window.textsecure.server,
|
||||
});
|
||||
|
||||
const uuid =
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import { z } from 'zod';
|
||||
import type { Dictionary } from 'lodash';
|
||||
import Long from 'long';
|
||||
import PQueue from 'p-queue';
|
||||
import type { PlaintextContent } from '@signalapp/libsignal-client';
|
||||
|
@ -25,7 +24,7 @@ import { SenderKeys } from '../LibSignalStores';
|
|||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
import { MIMETypeToString } from '../types/MIME';
|
||||
import type * as Attachment from '../types/Attachment';
|
||||
import type { UUID, UUIDStringType } from '../types/UUID';
|
||||
import type { UUID } from '../types/UUID';
|
||||
import type {
|
||||
ChallengeType,
|
||||
GetGroupLogOptionsType,
|
||||
|
@ -49,7 +48,6 @@ import type {
|
|||
SendLogCallbackType,
|
||||
} from './OutgoingMessage';
|
||||
import OutgoingMessage from './OutgoingMessage';
|
||||
import type { CDSResponseType } from './cds/Types.d';
|
||||
import * as Bytes from '../Bytes';
|
||||
import { getRandomBytes, getZeroes, encryptAttachment } from '../Crypto';
|
||||
import {
|
||||
|
@ -2447,34 +2445,12 @@ export default class MessageSender {
|
|||
return this.server.getProfile(uuid.toString(), options);
|
||||
}
|
||||
|
||||
async checkAccountExistence(uuid: UUID): Promise<boolean> {
|
||||
return this.server.checkAccountExistence(uuid);
|
||||
}
|
||||
|
||||
async getProfileForUsername(
|
||||
username: string
|
||||
): ReturnType<WebAPIType['getProfileForUsername']> {
|
||||
return this.server.getProfileForUsername(username);
|
||||
}
|
||||
|
||||
async getUuidsForE164s(
|
||||
numbers: ReadonlyArray<string>
|
||||
): Promise<Dictionary<UUIDStringType | null>> {
|
||||
return this.server.getUuidsForE164s(numbers);
|
||||
}
|
||||
|
||||
async getUuidsForE164sV2(
|
||||
e164s: ReadonlyArray<string>,
|
||||
acis: ReadonlyArray<UUIDStringType>,
|
||||
accessKeys: ReadonlyArray<string>
|
||||
): Promise<CDSResponseType> {
|
||||
return this.server.getUuidsForE164sV2({
|
||||
e164s,
|
||||
acis,
|
||||
accessKeys,
|
||||
});
|
||||
}
|
||||
|
||||
async getAvatar(path: string): Promise<ReturnType<WebAPIType['getAvatar']>> {
|
||||
return this.server.getAvatar(path);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import type { Response } from 'node-fetch';
|
|||
import fetch from 'node-fetch';
|
||||
import ProxyAgent from 'proxy-agent';
|
||||
import { Agent } from 'https';
|
||||
import type { Dictionary } from 'lodash';
|
||||
import { escapeRegExp, isNumber } from 'lodash';
|
||||
import is from '@sindresorhus/is';
|
||||
import PQueue from 'p-queue';
|
||||
|
@ -767,10 +766,10 @@ export type ConfirmCodeResultType = Readonly<{
|
|||
deviceId?: number;
|
||||
}>;
|
||||
|
||||
export type GetUuidsForE164sV2OptionsType = Readonly<{
|
||||
export type CdsLookupOptionsType = Readonly<{
|
||||
e164s: ReadonlyArray<string>;
|
||||
acis: ReadonlyArray<UUIDStringType>;
|
||||
accessKeys: ReadonlyArray<string>;
|
||||
acis?: ReadonlyArray<UUIDStringType>;
|
||||
accessKeys?: ReadonlyArray<string>;
|
||||
}>;
|
||||
|
||||
type GetProfileCommonOptionsType = Readonly<
|
||||
|
@ -812,6 +811,7 @@ export type GetGroupCredentialsResultType = Readonly<{
|
|||
export type WebAPIType = {
|
||||
startRegistration(): unknown;
|
||||
finishRegistration(baton: unknown): void;
|
||||
cdsLookup: (options: CdsLookupOptionsType) => Promise<CDSResponseType>;
|
||||
confirmCode: (
|
||||
number: string,
|
||||
code: string,
|
||||
|
@ -880,12 +880,6 @@ export type WebAPIType = {
|
|||
getStorageCredentials: MessageSender['getStorageCredentials'];
|
||||
getStorageManifest: MessageSender['getStorageManifest'];
|
||||
getStorageRecords: MessageSender['getStorageRecords'];
|
||||
getUuidsForE164s: (
|
||||
e164s: ReadonlyArray<string>
|
||||
) => Promise<Dictionary<UUIDStringType | null>>;
|
||||
getUuidsForE164sV2: (
|
||||
options: GetUuidsForE164sV2OptionsType
|
||||
) => Promise<CDSResponseType>;
|
||||
fetchLinkPreviewMetadata: (
|
||||
href: string,
|
||||
abortSignal: AbortSignal
|
||||
|
@ -1251,6 +1245,7 @@ export function initialize({
|
|||
unregisterRequestHandler,
|
||||
authenticate,
|
||||
logout,
|
||||
cdsLookup,
|
||||
checkAccountExistence,
|
||||
confirmCode,
|
||||
createGroup,
|
||||
|
@ -1285,8 +1280,6 @@ export function initialize({
|
|||
getStorageCredentials,
|
||||
getStorageManifest,
|
||||
getStorageRecords,
|
||||
getUuidsForE164s,
|
||||
getUuidsForE164sV2,
|
||||
makeProxiedRequest,
|
||||
makeSfuRequest,
|
||||
modifyGroup,
|
||||
|
@ -2858,25 +2851,11 @@ export function initialize({
|
|||
return socketManager.getProvisioningResource(handler);
|
||||
}
|
||||
|
||||
async function getUuidsForE164s(
|
||||
e164s: ReadonlyArray<string>
|
||||
): Promise<Dictionary<UUIDStringType | null>> {
|
||||
const map = await cds.request({
|
||||
e164s,
|
||||
});
|
||||
|
||||
const result: Dictionary<UUIDStringType | null> = {};
|
||||
for (const [key, value] of map) {
|
||||
result[key] = value.pni ?? value.aci ?? null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getUuidsForE164sV2({
|
||||
async function cdsLookup({
|
||||
e164s,
|
||||
acis,
|
||||
accessKeys,
|
||||
}: GetUuidsForE164sV2OptionsType): Promise<CDSResponseType> {
|
||||
acis = [],
|
||||
accessKeys = [],
|
||||
}: CdsLookupOptionsType): Promise<CDSResponseType> {
|
||||
return cds.request({
|
||||
e164s,
|
||||
acis,
|
||||
|
|
|
@ -85,28 +85,20 @@ export abstract class CDSSocketBase<
|
|||
|
||||
const aciUakPairs = new Array<Uint8Array>();
|
||||
|
||||
let version: 1 | 2;
|
||||
if (acis) {
|
||||
strictAssert(accessKeys, 'accessKeys are required when acis are present');
|
||||
const version = 2;
|
||||
strictAssert(
|
||||
acis.length === accessKeys.length,
|
||||
`Number of ACIs ${acis.length} is different ` +
|
||||
`from number of access keys ${accessKeys.length}`
|
||||
);
|
||||
|
||||
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) {
|
||||
aciUakPairs.push(
|
||||
Bytes.concatenate([
|
||||
uuidToBytes(acis[i]),
|
||||
Bytes.fromBase64(accessKeys[i]),
|
||||
])
|
||||
);
|
||||
|
||||
version = 2;
|
||||
|
||||
for (let i = 0; i < acis.length; i += 1) {
|
||||
aciUakPairs.push(
|
||||
Bytes.concatenate([
|
||||
uuidToBytes(acis[i]),
|
||||
Bytes.fromBase64(accessKeys[i]),
|
||||
])
|
||||
);
|
||||
}
|
||||
} else {
|
||||
version = 1;
|
||||
}
|
||||
|
||||
const request = Proto.CDSClientRequest.encode({
|
||||
|
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from '../../Crypto';
|
||||
import { calculateAgreement, generateKeyPair } from '../../Curve';
|
||||
import * as Bytes from '../../Bytes';
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { UUID } from '../../types/UUID';
|
||||
import type { CDSBaseOptionsType } from './CDSBase';
|
||||
import { CDSBase } from './CDSBase';
|
||||
|
@ -125,11 +124,7 @@ function getSgxConstants() {
|
|||
export class LegacyCDS extends CDSBase<LegacyCDSOptionsType> {
|
||||
public override async request({
|
||||
e164s,
|
||||
acis,
|
||||
accessKeys,
|
||||
}: CDSRequestOptionsType): Promise<CDSResponseType> {
|
||||
strictAssert(!acis && !accessKeys, 'LegacyCDS does not support PNP');
|
||||
|
||||
const directoryAuth = await this.getAuth();
|
||||
const attestationResult = await this.putAttestation(directoryAuth);
|
||||
|
||||
|
|
4
ts/textsecure/cds/Types.d.ts
vendored
4
ts/textsecure/cds/Types.d.ts
vendored
|
@ -17,7 +17,7 @@ export type CDSResponseType = ReadonlyMap<string, CDSResponseEntryType>;
|
|||
|
||||
export type CDSRequestOptionsType = Readonly<{
|
||||
e164s: ReadonlyArray<string>;
|
||||
acis?: ReadonlyArray<UUIDStringType>;
|
||||
accessKeys?: ReadonlyArray<string>;
|
||||
acis: ReadonlyArray<UUIDStringType>;
|
||||
accessKeys: ReadonlyArray<string>;
|
||||
timeout?: number;
|
||||
}>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue