Remove unused CDSH code
This commit is contained in:
parent
413b6dbd5c
commit
c18fa35354
6 changed files with 0 additions and 147 deletions
|
@ -385,12 +385,6 @@ async function prepareUrl(
|
|||
config.get<string | null>('directoryCDSIUrl') || undefined,
|
||||
directoryCDSIMRENCLAVE:
|
||||
config.get<string | null>('directoryCDSIMRENCLAVE') || undefined,
|
||||
directoryCDSHUrl:
|
||||
config.get<string | null>('directoryCDSHUrl') || undefined,
|
||||
directoryCDSHPublicKey:
|
||||
config.get<string | null>('directoryCDSHPublicKey') || undefined,
|
||||
directoryCDSHCodeHashes:
|
||||
config.get<Array<string> | null>('directoryCDSHCodeHashes') || undefined,
|
||||
});
|
||||
if (!directoryConfig.success) {
|
||||
throw new Error(
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
"directoryTrustAnchor": null,
|
||||
"directoryCDSIUrl": "https://cdsi.staging.signal.org",
|
||||
"directoryCDSIMRENCLAVE": "ef4787a56a154ac6d009138cac17155acd23cfe4329281252365dd7c252e7fbf",
|
||||
"directoryCDSHUrl": null,
|
||||
"directoryCDSHPublicKey": null,
|
||||
"directoryCDSHCodeHashes": null,
|
||||
"cdn": {
|
||||
"0": "https://cdn-staging.signal.org",
|
||||
"2": "https://cdn2-staging.signal.org"
|
||||
|
|
|
@ -48,7 +48,6 @@ import type {
|
|||
import type { CDSBase } from './cds/CDSBase';
|
||||
import { LegacyCDS } from './cds/LegacyCDS';
|
||||
import type { LegacyCDSPutAttestationResponseType } from './cds/LegacyCDS';
|
||||
import { CDSH } from './cds/CDSH';
|
||||
import { CDSI } from './cds/CDSI';
|
||||
import type WebSocketResource from './WebsocketResources';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
|
@ -1206,32 +1205,6 @@ export function initialize({
|
|||
},
|
||||
});
|
||||
}
|
||||
if (directoryType === 'cdsh') {
|
||||
const {
|
||||
directoryCDSHUrl,
|
||||
directoryCDSHPublicKey,
|
||||
directoryCDSHCodeHashes,
|
||||
} = directoryConfig;
|
||||
|
||||
cds = new CDSH({
|
||||
logger: log,
|
||||
proxyUrl,
|
||||
|
||||
url: directoryCDSHUrl,
|
||||
publicKey: directoryCDSHPublicKey,
|
||||
codeHashes: directoryCDSHCodeHashes,
|
||||
certificateAuthority,
|
||||
version,
|
||||
|
||||
async getAuth() {
|
||||
return (await _ajax({
|
||||
call: 'directoryAuthV2',
|
||||
httpType: 'GET',
|
||||
responseType: 'json',
|
||||
})) as CDSAuthType;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let fetchForLinkPreviews: linkPreviewFetch.FetchFn;
|
||||
if (proxyUrl) {
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { HsmEnclaveClient } from '@signalapp/libsignal-client';
|
||||
import type { connection as WebSocket } from 'websocket';
|
||||
|
||||
import * as Bytes from '../../Bytes';
|
||||
import { CDSHSocket } from './CDSHSocket';
|
||||
import type { CDSSocketManagerBaseOptionsType } from './CDSSocketManagerBase';
|
||||
import { CDSSocketManagerBase } from './CDSSocketManagerBase';
|
||||
|
||||
export type CDSHOptionsType = Readonly<{
|
||||
publicKey: string;
|
||||
codeHashes: ReadonlyArray<string>;
|
||||
}> &
|
||||
CDSSocketManagerBaseOptionsType;
|
||||
|
||||
export class CDSH extends CDSSocketManagerBase<CDSHSocket, CDSHOptionsType> {
|
||||
private readonly publicKey: Buffer;
|
||||
|
||||
private readonly codeHashes: Array<Buffer>;
|
||||
|
||||
constructor(options: CDSHOptionsType) {
|
||||
super(options);
|
||||
|
||||
this.publicKey = Buffer.from(Bytes.fromHex(options.publicKey));
|
||||
this.codeHashes = options.codeHashes.map(hash =>
|
||||
Buffer.from(Bytes.fromHex(hash))
|
||||
);
|
||||
}
|
||||
|
||||
protected override getSocketUrl(): string {
|
||||
const { publicKey: publicKeyHex, codeHashes } = this.options;
|
||||
|
||||
return (
|
||||
`${this.options.url}/discovery/${publicKeyHex}/` +
|
||||
`${codeHashes.join(',')}`
|
||||
);
|
||||
}
|
||||
|
||||
protected override createSocket(socket: WebSocket): CDSHSocket {
|
||||
const enclaveClient = HsmEnclaveClient.new(this.publicKey, this.codeHashes);
|
||||
|
||||
return new CDSHSocket({
|
||||
logger: this.logger,
|
||||
socket,
|
||||
enclaveClient,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { HsmEnclaveClient } from '@signalapp/libsignal-client';
|
||||
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { CDSSocketBase, CDSSocketState } from './CDSSocketBase';
|
||||
import type { CDSSocketBaseOptionsType } from './CDSSocketBase';
|
||||
|
||||
export type CDSHSocketOptionsType = Readonly<{
|
||||
enclaveClient: HsmEnclaveClient;
|
||||
}> &
|
||||
CDSSocketBaseOptionsType;
|
||||
|
||||
export class CDSHSocket extends CDSSocketBase<CDSHSocketOptionsType> {
|
||||
public override async handshake(): Promise<void> {
|
||||
strictAssert(
|
||||
this.state === CDSSocketState.Open,
|
||||
'CDSH handshake called twice'
|
||||
);
|
||||
this.state = CDSSocketState.Handshake;
|
||||
|
||||
// Handshake
|
||||
this.socket.sendBytes(this.options.enclaveClient.initialRequest());
|
||||
|
||||
const { done, value: message } = await this.socketIterator.next();
|
||||
strictAssert(!done, 'Expected CDSH handshake response');
|
||||
|
||||
this.options.enclaveClient.completeHandshake(message);
|
||||
this.state = CDSSocketState.Established;
|
||||
}
|
||||
|
||||
protected override async sendRequest(
|
||||
version: number,
|
||||
request: Buffer
|
||||
): Promise<void> {
|
||||
this.socket.sendBytes(
|
||||
this.options.enclaveClient.establishedSend(
|
||||
Buffer.concat([Buffer.from([version]), request])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected override async decryptResponse(
|
||||
ciphertext: Buffer
|
||||
): Promise<Buffer> {
|
||||
return this.options.enclaveClient.establishedRecv(ciphertext);
|
||||
}
|
||||
}
|
|
@ -42,13 +42,6 @@ const directoryMirroredCDSIConfigSchema = z.object({
|
|||
directoryCDSIMRENCLAVE: configRequiredStringSchema,
|
||||
});
|
||||
|
||||
const directoryCDSHConfigSchema = z.object({
|
||||
directoryType: z.literal('cdsh'),
|
||||
directoryCDSHCodeHashes: z.array(z.string().nonempty()),
|
||||
directoryCDSHPublicKey: configRequiredStringSchema,
|
||||
directoryCDSHUrl: configRequiredStringSchema,
|
||||
});
|
||||
|
||||
export const directoryConfigSchema = z
|
||||
.object({
|
||||
// Unknown defaults
|
||||
|
@ -58,16 +51,11 @@ export const directoryConfigSchema = z
|
|||
|
||||
directoryCDSIUrl: configOptionalUnknownSchema,
|
||||
directoryCDSIMRENCLAVE: configOptionalUnknownSchema,
|
||||
|
||||
directoryCDSHCodeHashes: configOptionalUnknownSchema,
|
||||
directoryCDSHPublicKey: configOptionalUnknownSchema,
|
||||
directoryCDSHUrl: configOptionalUnknownSchema,
|
||||
})
|
||||
.and(
|
||||
directoryLegacyConfigSchema
|
||||
.or(directoryMirroredCDSIConfigSchema)
|
||||
.or(directoryCDSIConfigSchema)
|
||||
.or(directoryCDSHConfigSchema)
|
||||
);
|
||||
|
||||
export type DirectoryConfigType = z.infer<typeof directoryConfigSchema>;
|
||||
|
|
Loading…
Add table
Reference in a new issue