You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -307,7 +307,7 @@ The callback function is called with the following three arguments:
307
307
*`handshake` {Object} - A handshake object
308
308
*`protocols` {Set} - A set of subprotocols purportedly supported by the client.
309
309
*`identity` {String} - The identity portion of the connection URL, decoded.
310
-
*`password` {String} - If HTTP Basic auth was used in the connection, and the username correctly matches the identity, this field will contain the password (otherwise `undefined`). Read [Security Profile 1](#security-profile-1) for more details of how this works.
310
+
*`password` {Buffer} - If HTTP Basic auth was used in the connection, and the username correctly matches the identity, this field will contain the password (otherwise `undefined`). Typically this password would be a string, but the OCPP specs allow for this to be binary, so it is provided as a `Buffer` for you to interpret as you wish. Read [Security Profile 1](#security-profile-1) for more details of how this works.
311
311
*`endpoint` {String} - The endpoint path portion of the connection URL. This is the part of the path before the identity.
312
312
*`query` {URLSearchParams} - The query string parsed as [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
313
313
*`remoteAddress` {String} - The remote IP address of the socket.
@@ -384,7 +384,7 @@ Returns a `Promise` which resolves when the server has completed closing.
384
384
-`endpoint` {String} - The RPC server's endpoint (a websocket URL). **Required**.
385
385
-`identity` {String} - The RPC client's identity. Will be automatically encoded. **Required**.
386
386
-`protocols` {Array<String>} - Array of subprotocols supported by this client. Defaults to `[]`.
387
-
-`password` {String} - Optional password to use in [HTTP Basic auth](#security-profile-1). (The username will always be the identity).
387
+
-`password` {String|Buffer} - Optional password to use in [HTTP Basic auth](#security-profile-1). This can be a Buffer to allow for binary auth keys as recommended in the OCPP security whitepaper. If provided as a string, it will be encoded as UTF-8. (The corresponding username will always be the identity).
388
388
-`headers` {Object} - Additional HTTP headers to send along with the websocket upgrade request. Defaults to `{}`.
389
389
-`query` {Object|String} - An optional query string or object to append as the query string of the connection URL. Defaults to `''`.
390
390
-`callTimeoutMs` {Number} - Milliseconds to wait before unanswered outbound calls are rejected automatically. Defaults to `60000`.
@@ -675,7 +675,7 @@ The RPCServerClient is a subclass of RPCClient. This represents an RPCClient fro
675
675
* {Object}
676
676
*`protocols` {Set} - A set of subprotocols purportedly supported by the client.
677
677
*`identity` {String} - The identity portion of the connection URL, decoded.
678
-
*`password` {String} - If HTTP Basic auth was used in the connection, and the username correctly matches the identity, this field will contain the password (otherwise `undefined`). Read [Security Profile 1](#security-profile-1) for more details of how this works.
678
+
*`password` {Buffer} - If HTTP Basic auth was used in the connection, and the username correctly matches the identity, this field will contain the password (otherwise `undefined`). Typically this password would be a string, but the OCPP specs allow for this to be binary, so it is provided as a `Buffer` for you to interpret as you wish. Read [Security Profile 1](#security-profile-1) for more details of how this works.
679
679
*`endpoint` {String} - The endpoint path portion of the connection URL. This is the part of the path before the identity.
680
680
*`query` {URLSearchParams} - The query string parsed as [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
681
681
*`remoteAddress` {String} - The remote IP address of the socket.
@@ -855,7 +855,7 @@ const cli = new RPCClient({
855
855
856
856
constserver=newRPCServer();
857
857
server.auth((accept, reject, handshake) => {
858
-
if (handshake.identity==="AzureDiamond"&&handshake.password==="hunter2") {
858
+
if (handshake.identity==="AzureDiamond"&&handshake.password.toString('utf8')==="hunter2") {
859
859
accept();
860
860
} else {
861
861
reject(401);
@@ -876,6 +876,8 @@ In practice, it's not uncommon to see violations of RFC7617 in the wild. All maj
876
876
877
877
However, in OCPP, since we have the luxury of knowing that the username must always be equal to the client's identity, it is no longer necessary to rely upon a colon to delineate the username from the password. This module makes use of this guarantee to enable identities and passwords to contain as many or as few colons as you wish.
878
878
879
+
Additionally, the OCPP security whitepaper recommends passwords consist purely of random bytes (for maximum entropy), although this violates the Basic Auth RFC which requires all passwords to be TEXT (US-ASCII compatible with no control characters). For this reason, this library will not make any presumptions about the character encoding (or otherwise) of the password provided, and present the password as a `Buffer`.
0 commit comments