Migrate to private class properties/methods
This commit is contained in:
@@ -14,7 +14,7 @@ export type CDSISocketOptionsType = Readonly<{
|
||||
CDSSocketBaseOptionsType;
|
||||
|
||||
export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
|
||||
private privCdsClient: Cds2Client | undefined;
|
||||
#privCdsClient: Cds2Client | undefined;
|
||||
|
||||
public override async handshake(): Promise<void> {
|
||||
strictAssert(
|
||||
@@ -31,23 +31,23 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
|
||||
const earliestValidTimestamp = new Date();
|
||||
|
||||
strictAssert(
|
||||
this.privCdsClient === undefined,
|
||||
this.#privCdsClient === undefined,
|
||||
'CDSI handshake called twice'
|
||||
);
|
||||
this.privCdsClient = Cds2Client.new(
|
||||
this.#privCdsClient = Cds2Client.new(
|
||||
this.options.mrenclave,
|
||||
attestationMessage,
|
||||
earliestValidTimestamp
|
||||
);
|
||||
}
|
||||
|
||||
this.socket.sendBytes(this.cdsClient.initialRequest());
|
||||
this.socket.sendBytes(this.#cdsClient.initialRequest());
|
||||
|
||||
{
|
||||
const { done, value: message } = await this.socketIterator.next();
|
||||
strictAssert(!done, 'CDSI socket expected handshake data');
|
||||
|
||||
this.cdsClient.completeHandshake(message);
|
||||
this.#cdsClient.completeHandshake(message);
|
||||
}
|
||||
|
||||
this.state = CDSSocketState.Established;
|
||||
@@ -57,7 +57,7 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
|
||||
_version: number,
|
||||
request: Buffer
|
||||
): Promise<void> {
|
||||
this.socket.sendBytes(this.cdsClient.establishedSend(request));
|
||||
this.socket.sendBytes(this.#cdsClient.establishedSend(request));
|
||||
|
||||
const { done, value: ciphertext } = await this.socketIterator.next();
|
||||
strictAssert(!done, 'CDSISocket.sendRequest(): expected token message');
|
||||
@@ -70,7 +70,7 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
|
||||
strictAssert(token, 'CDSISocket.sendRequest(): expected token');
|
||||
|
||||
this.socket.sendBytes(
|
||||
this.cdsClient.establishedSend(
|
||||
this.#cdsClient.establishedSend(
|
||||
Buffer.from(
|
||||
Proto.CDSClientRequest.encode({
|
||||
tokenAck: true,
|
||||
@@ -83,15 +83,15 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
|
||||
protected override async decryptResponse(
|
||||
ciphertext: Buffer
|
||||
): Promise<Buffer> {
|
||||
return this.cdsClient.establishedRecv(ciphertext);
|
||||
return this.#cdsClient.establishedRecv(ciphertext);
|
||||
}
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
|
||||
private get cdsClient(): Cds2Client {
|
||||
strictAssert(this.privCdsClient, 'CDSISocket did not start handshake');
|
||||
return this.privCdsClient;
|
||||
get #cdsClient(): Cds2Client {
|
||||
strictAssert(this.#privCdsClient, 'CDSISocket did not start handshake');
|
||||
return this.#privCdsClient;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user