Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
}