Remove unused CDSH code
This commit is contained in:
parent
413b6dbd5c
commit
c18fa35354
|
@ -385,12 +385,6 @@ async function prepareUrl(
|
||||||
config.get<string | null>('directoryCDSIUrl') || undefined,
|
config.get<string | null>('directoryCDSIUrl') || undefined,
|
||||||
directoryCDSIMRENCLAVE:
|
directoryCDSIMRENCLAVE:
|
||||||
config.get<string | null>('directoryCDSIMRENCLAVE') || undefined,
|
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) {
|
if (!directoryConfig.success) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
"directoryTrustAnchor": null,
|
"directoryTrustAnchor": null,
|
||||||
"directoryCDSIUrl": "https://cdsi.staging.signal.org",
|
"directoryCDSIUrl": "https://cdsi.staging.signal.org",
|
||||||
"directoryCDSIMRENCLAVE": "ef4787a56a154ac6d009138cac17155acd23cfe4329281252365dd7c252e7fbf",
|
"directoryCDSIMRENCLAVE": "ef4787a56a154ac6d009138cac17155acd23cfe4329281252365dd7c252e7fbf",
|
||||||
"directoryCDSHUrl": null,
|
|
||||||
"directoryCDSHPublicKey": null,
|
|
||||||
"directoryCDSHCodeHashes": null,
|
|
||||||
"cdn": {
|
"cdn": {
|
||||||
"0": "https://cdn-staging.signal.org",
|
"0": "https://cdn-staging.signal.org",
|
||||||
"2": "https://cdn2-staging.signal.org"
|
"2": "https://cdn2-staging.signal.org"
|
||||||
|
|
|
@ -48,7 +48,6 @@ import type {
|
||||||
import type { CDSBase } from './cds/CDSBase';
|
import type { CDSBase } from './cds/CDSBase';
|
||||||
import { LegacyCDS } from './cds/LegacyCDS';
|
import { LegacyCDS } from './cds/LegacyCDS';
|
||||||
import type { LegacyCDSPutAttestationResponseType } from './cds/LegacyCDS';
|
import type { LegacyCDSPutAttestationResponseType } from './cds/LegacyCDS';
|
||||||
import { CDSH } from './cds/CDSH';
|
|
||||||
import { CDSI } from './cds/CDSI';
|
import { CDSI } from './cds/CDSI';
|
||||||
import type WebSocketResource from './WebsocketResources';
|
import type WebSocketResource from './WebsocketResources';
|
||||||
import { SignalService as Proto } from '../protobuf';
|
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;
|
let fetchForLinkPreviews: linkPreviewFetch.FetchFn;
|
||||||
if (proxyUrl) {
|
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,
|
directoryCDSIMRENCLAVE: configRequiredStringSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
const directoryCDSHConfigSchema = z.object({
|
|
||||||
directoryType: z.literal('cdsh'),
|
|
||||||
directoryCDSHCodeHashes: z.array(z.string().nonempty()),
|
|
||||||
directoryCDSHPublicKey: configRequiredStringSchema,
|
|
||||||
directoryCDSHUrl: configRequiredStringSchema,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const directoryConfigSchema = z
|
export const directoryConfigSchema = z
|
||||||
.object({
|
.object({
|
||||||
// Unknown defaults
|
// Unknown defaults
|
||||||
|
@ -58,16 +51,11 @@ export const directoryConfigSchema = z
|
||||||
|
|
||||||
directoryCDSIUrl: configOptionalUnknownSchema,
|
directoryCDSIUrl: configOptionalUnknownSchema,
|
||||||
directoryCDSIMRENCLAVE: configOptionalUnknownSchema,
|
directoryCDSIMRENCLAVE: configOptionalUnknownSchema,
|
||||||
|
|
||||||
directoryCDSHCodeHashes: configOptionalUnknownSchema,
|
|
||||||
directoryCDSHPublicKey: configOptionalUnknownSchema,
|
|
||||||
directoryCDSHUrl: configOptionalUnknownSchema,
|
|
||||||
})
|
})
|
||||||
.and(
|
.and(
|
||||||
directoryLegacyConfigSchema
|
directoryLegacyConfigSchema
|
||||||
.or(directoryMirroredCDSIConfigSchema)
|
.or(directoryMirroredCDSIConfigSchema)
|
||||||
.or(directoryCDSIConfigSchema)
|
.or(directoryCDSIConfigSchema)
|
||||||
.or(directoryCDSHConfigSchema)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export type DirectoryConfigType = z.infer<typeof directoryConfigSchema>;
|
export type DirectoryConfigType = z.infer<typeof directoryConfigSchema>;
|
||||||
|
|
Loading…
Reference in New Issue