+ public buildProtocolRequest(
+ id: string,
+ procedureName: ProcedureName,
+ requestPayload: RequestPayload
+ ): ProtocolRequest {
+ return [id, procedureName, requestPayload];
+ }
+
+ public buildProtocolResponse(id: string, responsePayload: ResponsePayload): ProtocolResponse {
+ return [id, responsePayload];
+ }
+
+ protected isBasicAuthEnabled(): boolean {
+ return (
+ this.uiServerConfiguration.authentication?.enabled === true &&
+ this.uiServerConfiguration.authentication?.type === AuthenticationType.BASIC_AUTH
+ );
+ }
+
+ protected isValidBasicAuth(req: IncomingMessage): boolean {
+ const authorizationHeader = req.headers.authorization ?? '';
+ const authorizationToken = authorizationHeader.split(/\s+/).pop() ?? '';
+ const authentication = Buffer.from(authorizationToken, 'base64').toString();
+ const authenticationParts = authentication.split(/:/);
+ const username = authenticationParts.shift();
+ const password = authenticationParts.join(':');
+ return (
+ this.uiServerConfiguration.authentication?.username === username &&
+ this.uiServerConfiguration.authentication?.password === password
+ );
+ }
+