Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reject(SASLError.fromElement(element))
} else if (element.name === 'success') {
resolve()
}
entity.removeListener('nonza', handler)
}
entity.on('nonza', handler)
if (mech.clientFirst) {
entity.send(
xml(
'auth',
{xmlns: NS, mechanism: mech.name},
encode(mech.response(creds))
)
)
}
})
}
const handler = element => {
if (element.attrs.xmlns !== NS) {
return
}
if (element.name === 'challenge') {
mech.challenge(decode(element.text()))
const resp = mech.response(creds)
entity.send(
xml(
'response',
{xmlns: NS, mechanism: mech.name},
typeof resp === 'string' ? encode(resp) : ''
)
)
return
}
if (element.name === 'failure') {
reject(SASLError.fromElement(element))
} else if (element.name === 'success') {
resolve()
}
entity.removeListener('nonza', handler)
}
const handler = element => {
if (element.attrs.xmlns !== NS) {
return
}
if (element.name === 'challenge') {
mech.challenge(decode(element.text()))
const resp = mech.response(creds)
entity.send(
xml(
'response',
{xmlns: NS, mechanism: mech.name},
typeof resp === 'string' ? encode(resp) : ''
)
)
return
}
if (element.name === 'failure') {
reject(SASLError.fromElement(element))
} else if (element.name === 'success') {
resolve()
}