* Send username/password authentication request
()
| 10729 | * Send username/password authentication request |
| 10730 | */ |
| 10731 | sendAuthRequest() { |
| 10732 | const { username, password } = this.options; |
| 10733 | if (!username || !password) { |
| 10734 | throw new InvalidArgumentError("Username and password required for authentication"); |
| 10735 | } |
| 10736 | debug("sending username/password auth"); |
| 10737 | const usernameBuffer = Buffer2.from(username); |
| 10738 | const passwordBuffer = Buffer2.from(password); |
| 10739 | if (usernameBuffer.length > 255 || passwordBuffer.length > 255) { |
| 10740 | throw new InvalidArgumentError("Username or password too long"); |
| 10741 | } |
| 10742 | const request = Buffer2.alloc(3 + usernameBuffer.length + passwordBuffer.length); |
| 10743 | request[0] = 1; |
| 10744 | request[1] = usernameBuffer.length; |
| 10745 | usernameBuffer.copy(request, 2); |
| 10746 | request[2 + usernameBuffer.length] = passwordBuffer.length; |
| 10747 | passwordBuffer.copy(request, 3 + usernameBuffer.length); |
| 10748 | this.socket.write(request); |
| 10749 | } |
| 10750 | /** |
| 10751 | * Handle authentication response |
| 10752 | */ |