MCPcopy Create free account
hub / github.com/mscdex/ssh2 / authInfoReq

Method authInfoReq

lib/protocol/Protocol.js:1864–1915  ·  view source on GitHub ↗
(name, instructions, prompts)

Source from the content-addressed store, hash-verified

1862 sendPacket(this, this._packetRW.write.finalize(packet));
1863 }
1864 authInfoReq(name, instructions, prompts) {
1865 if (!this._server)
1866 throw new Error('Server-only method called in client mode');
1867
1868 let promptsLen = 0;
1869 const nameLen = name ? Buffer.byteLength(name) : 0;
1870 const instrLen = instructions ? Buffer.byteLength(instructions) : 0;
1871
1872 for (let i = 0; i < prompts.length; ++i)
1873 promptsLen += 4 + Buffer.byteLength(prompts[i].prompt) + 1;
1874
1875 let p = this._packetRW.write.allocStart;
1876 const packet = this._packetRW.write.alloc(
1877 1 + 4 + nameLen + 4 + instrLen + 4 + 4 + promptsLen
1878 );
1879
1880 packet[p] = MESSAGE.USERAUTH_INFO_REQUEST;
1881
1882 writeUInt32BE(packet, nameLen, ++p);
1883 p += 4;
1884 if (name) {
1885 packet.utf8Write(name, p, nameLen);
1886 p += nameLen;
1887 }
1888
1889 writeUInt32BE(packet, instrLen, p);
1890 p += 4;
1891 if (instructions) {
1892 packet.utf8Write(instructions, p, instrLen);
1893 p += instrLen;
1894 }
1895
1896 writeUInt32BE(packet, 0, p);
1897
1898 writeUInt32BE(packet, prompts.length, p += 4);
1899 p += 4;
1900 for (let i = 0; i < prompts.length; ++i) {
1901 const prompt = prompts[i];
1902 const promptLen = Buffer.byteLength(prompt.prompt);
1903
1904 writeUInt32BE(packet, promptLen, p);
1905 p += 4;
1906 if (promptLen) {
1907 packet.utf8Write(prompt.prompt, p, promptLen);
1908 p += promptLen;
1909 }
1910 packet[p++] = (prompt.echo ? 1 : 0);
1911 }
1912
1913 this._debug && this._debug('Outbound: Sending USERAUTH_INFO_REQUEST');
1914 sendPacket(this, this._packetRW.write.finalize(packet));
1915 }
1916}
1917
1918// SSH-protoversion-softwareversion (SP comments) CR LF

Callers 1

promptMethod · 0.80

Calls 3

writeUInt32BEFunction · 0.85
allocMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected