MCPcopy
hub / github.com/electerm/electerm / splitRoundKeyboardInteractiveAuth

Function splitRoundKeyboardInteractiveAuth

test/unit-ci/session-ssh.spec.js:205–232  ·  view source on GitHub ↗
(rounds = [])

Source from the content-addressed store, hash-verified

203}
204
205function splitRoundKeyboardInteractiveAuth (rounds = []) {
206 return (ctx) => {
207 if (ctx.method === 'none') {
208 return ctx.reject(['keyboard-interactive'])
209 }
210 if (ctx.method === 'keyboard-interactive' && ctx.username === USERNAME) {
211 rounds.push('otp')
212 return ctx.prompt([
213 { prompt: 'Verification code:', echo: false }
214 ], 'electerm-test', 'otp round', (otpResponses) => {
215 if (otpResponses[0] !== OTP) {
216 return ctx.reject(['keyboard-interactive'])
217 }
218 rounds.push('password')
219 ctx.prompt([
220 { prompt: 'Password:', echo: false }
221 ], 'electerm-test', 'password round', (passwordResponses) => {
222 if (passwordResponses[0] === PASSWORD) {
223 ctx.accept()
224 } else {
225 ctx.reject(['keyboard-interactive'])
226 }
227 })
228 })
229 }
230 return ctx.reject(['keyboard-interactive'])
231 }
232}
233
234function startAgent () {
235 const socketPath = path.join(os.tmpdir(), `ea-${process.pid}-${Date.now()}.sock`)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected