Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const device = utils.getDevice(username);
const storage = utils.getCookieStorage(`${username}.json`);
const session = new Client.Session(device, storage);
const request = new Client.Request(session);
request.setMethod('POST')
.setUrl(Client.CONSTANTS.API_ENDPOINT + "accounts/two_factor_login/")
.generateUUID()
.setData({
username: username,
verification_code: code,
two_factor_identifier: twoFactorIdentifier,
trust_this_device: trustThisDevice,
verification_method: verificationMethod,
})
.signPayload()
.send()
.then(() => session.loginFlow())
.then(() => resolve(session))
.catch(reject)
})
}