@citrineos/util
Version:
The OCPP util module which supplies helpful utilities like cache and queue connectors, etc.
28 lines • 931 B
JavaScript
;
// Copyright Contributors to the CitrineOS Project
//
// SPDX-License-Identifier: Apache 2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpgradeAuthenticationError = void 0;
class UpgradeAuthenticationError extends Error {
constructor(message) {
super(message);
this.name = 'UpgradeAuthenticationError';
}
terminateConnection(socket) {
try {
socket.write('HTTP/1.1 401 Unauthorized\r\n');
socket.write('WWW-Authenticate: Basic realm="Access to the WebSocket", charset="UTF-8"\r\n');
socket.write('\r\n');
socket.end();
socket.destroy();
return true;
}
catch (error) {
this.message = error.message;
return false;
}
}
}
exports.UpgradeAuthenticationError = UpgradeAuthenticationError;
//# sourceMappingURL=AuthenticationError.js.map