diff --git a/package.json b/package.json index 0dad59eed..3dd28a9be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockchain-wallet-client", - "version": "3.25.7", + "version": "3.26.1", "description": "Blockchain.info JavaScript Wallet", "homepage": "https://github.com/blockchain/my-wallet-v3", "bugs": { diff --git a/src/exchange-delegate.js b/src/exchange-delegate.js index 7fd1a75dd..b90131959 100644 --- a/src/exchange-delegate.js +++ b/src/exchange-delegate.js @@ -57,25 +57,6 @@ ExchangeDelegate.prototype.isMobileVerified = function () { return this._wallet.accountInfo.isMobileVerified; }; -ExchangeDelegate.prototype.getEmailToken = function () { - var self = this; - return API.request( - 'GET', - 'wallet/signed-token', - { - guid: self._wallet.guid, - sharedKey: self._wallet.sharedKey, - fields: 'email|wallet_age' - } - ).then(function (res) { - if (res.success) { - return res.token; - } else { - throw new Error('Unable to obtain email verification proof'); - } - }); -}; - ExchangeDelegate.prototype.getToken = function (partner, options) { options = options || {}; // assert(partner, 'Specify exchange partner'); @@ -84,7 +65,7 @@ ExchangeDelegate.prototype.getToken = function (partner, options) { // partner: partner, // Coinify doesn't support this yet guid: this._wallet.guid, sharedKey: this._wallet.sharedKey, - fields: `email${options.mobile ? '|mobile' : ''}|${options.walletAge ? '|wallet_age' : ''}` + fields: `email${options.mobile ? '|mobile' : ''}${options.walletAge ? '|wallet_age' : ''}` }; if (partner) { diff --git a/tests/exchange_delegate_spec.js.coffee b/tests/exchange_delegate_spec.js.coffee index cc260d7db..f3ce86dbc 100644 --- a/tests/exchange_delegate_spec.js.coffee +++ b/tests/exchange_delegate_spec.js.coffee @@ -49,19 +49,20 @@ API = request: (action, method, data, headers) -> return new Promise (resolve, reject) -> if action == 'GET' && method == "wallet/signed-token" - if emailVerified && data.fields == 'email' - resolve({success: true, token: 'json-web-token-email'}) + if data.fields == 'email' + if emailVerified + resolve({success: true, token: 'json-web-token-email'}) + else + resolve({success: false}) + if data.fields == 'email|mobile' + if emailVerified && mobileVerified + resolve({success: true, token: 'json-web-token-email-mobile'}) + else + resolve({success: false}) if emailVerified && data.fields == 'email|wallet_age' resolve({success: true, token: 'json-web-token-email-wallet-age'}) if emailVerified && data.fields == 'mobile' resolve({success: true, token: 'json-web-token-mobile'}) - if emailVerified && data.fields == 'email|mobile' - resolve({success: true, token: 'json-web-token-email-mobile'}) - else - resolve({success: false}) - if action == 'GET' && method == "wallet/signed-token" - if emailVerified && mobileVerified - resolve({success: true, token: 'json-web-token'}) else resolve({success: false}) else @@ -146,36 +147,23 @@ describe "ExchangeDelegate", -> it "should be true is users mobile is verified", -> expect(delegate.isMobileVerified()).toEqual(true) - describe "getEmailToken()", -> - afterEach -> - emailVerified = true - - it 'should get the token', (done) -> - promise = delegate.getEmailToken() - expect(promise).toBeResolvedWith('json-web-token-email-wallet-age', done); - - it 'should reject if email is not verified', (done) -> - emailVerified = false - promise = delegate.getEmailToken() - expect(promise).toBeRejected(done); - describe "getToken()", -> afterEach -> emailVerified = true mobileVerified = true it 'should get the token', (done) -> - promise = delegate.getToken() + promise = delegate.getToken('partner', {mobile: true}) expect(promise).toBeResolvedWith('json-web-token-email-mobile', done); it 'should reject if email is not verified', (done) -> emailVerified = false - promise = delegate.getToken() + promise = delegate.getToken('partner', {mobile: true}) expect(promise).toBeRejected(done); it 'should reject if mobile is not verified', (done) -> - emailVerified = false - promise = delegate.getToken() + mobileVerified = false + promise = delegate.getToken('partner', {mobile: true}) expect(promise).toBeRejected(done); describe "getReceiveAddress()", ->