Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import Promise from 'bluebird'
import assert from 'assert'
import utils from './lib/utils'
import Login from './lib/login'
import MobileLogin from './lib/mobile-login'
import _ from 'underscore'
import Methods from './lib/methods'
Expand Down Expand Up @@ -55,13 +54,7 @@ let Fut = class Fut extends Methods {
this.isReady = false // instance will be ready after we called _init func
Object.assign(this.options, defaultOptions, options)

if (this.options.loginType === 'web') {
this.loginLib = Promise.promisifyAll(new Login({proxy: options.proxy}))
} else if (this.options.loginType === 'mobile') {
this.loginLib = new MobileLogin({...options, tfCodeHandler: options.tfAuthHandler})
} else {
throw new Error(`Unknown loginType ${this.options.loginType}`)
}
this.loginLib = new MobileLogin({...options, tfCodeHandler: options.tfAuthHandler})
}

async loadVariable (key) {
Expand All @@ -86,15 +79,13 @@ let Fut = class Fut extends Methods {

async login () {
await this._init()
const loginMethod = this.options.loginType === 'web' ? 'loginAsync' : 'login'
const loginMethod = 'login'
const loginResponse = await this.loginLib[loginMethod](this.options.email, this.options.password, this.options.secret, this.options.platform, this.options.tfAuthHandler, this.options.captchaHandler)

await this.saveVariable('cookie', this.loginLib.getCookieJarJSON())
this.rawApi = loginResponse.apiRequest

const loginDefaults = _.omit(this.loginLib.getLoginDefaults(), 'jar')
await this.saveVariable('loginDefaults', loginDefaults)
if (this.options.loginType === 'web') this.rawApi = Promise.promisify(this.rawApi, this)
this.isReady = true
const user = await this.getUser()
if (user.userInfo.feature.trade === 0) {
Expand Down
Loading