Skip to content

Commit 65d1cdd

Browse files
committed
chore: comment mqtt-v5 username/password
Highlight: This version of the protocol allows the sending of a Password with no User Name, where MQTT v3.1.1 did not. refer: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901044 > 3.1.2.9 Password Flag > Position: bit 6 of the Connect Flags. > > If the Password Flag is set to 0, a Password MUST NOT be present in the Payload [MQTT-3.1.2-18]. If the Password Flag is set to 1, a Password MUST be present in the Payload [MQTT-3.1.2-19]. > > Non-normative comment > > This version of the protocol allows the sending of a Password with no User Name, where MQTT v3.1.1 did not. This reflects the common use of Password for credentials other than a password.
1 parent 944c85b commit 65d1cdd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

writeToStream.js

+2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ function connect (packet, stream, opts) {
201201
// Password
202202
if (password != null) {
203203
if (!providedUsername && protocolVersion !== 5) {
204+
// `username` is not required when password is present in MQTT-v5
205+
// see also: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901044
204206
stream.destroy(new Error('Username is required to use password'))
205207
return false
206208
}

0 commit comments

Comments
 (0)