Comparing version 2.0.1 to 2.0.2
@@ -165,3 +165,2 @@ 'use strict'; | ||
this.triggerEvent('beforeRefreshToken', this); | ||
console.log('refreshing token'); | ||
@@ -203,4 +202,4 @@ var _options2 = this._options, | ||
}, { | ||
key: 'waitUserAuth', | ||
value: function waitUserAuth() { | ||
key: 'waitUserAction', | ||
value: function waitUserAction() { | ||
var _this5 = this; | ||
@@ -211,14 +210,22 @@ | ||
} | ||
var server = new _AuthServer2.default(_extends({}, this._options.server, { | ||
var options = _extends({}, this._options.server, { | ||
state: this.getState() | ||
})); | ||
}), | ||
server = new _AuthServer2.default(options); | ||
this._server = server; | ||
return new Promise(function (resolve) { | ||
var handleCode = new Promise(function (resolve) { | ||
server.on('code', function (code) { | ||
server.stop(); | ||
_this5._server = null; | ||
_this5.setCode(code).then(resolve); | ||
resolve(code); | ||
}); | ||
server.run(); | ||
}); | ||
return handleCode.then(function (code) { | ||
server.stop(); | ||
return code; | ||
}).then(function (code) { | ||
_this5._server = null; | ||
return _this5.setCode(code); | ||
}); | ||
} | ||
@@ -243,3 +250,3 @@ }, { | ||
} else if (this._options.server) { | ||
return this.waitUserAuth(); | ||
return this.waitUserAction(); | ||
} else { | ||
@@ -246,0 +253,0 @@ return; |
@@ -54,4 +54,4 @@ 'use strict'; | ||
return new Promise(function (resolve) { | ||
return _this2._server.close().on('close', resolve); | ||
return new Promise(function (resolve, reject) { | ||
return _this2._server.close().on('close', resolve).on('error', reject); | ||
}); | ||
@@ -58,0 +58,0 @@ } |
{ | ||
"name": "amocrm-js", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "JS Library for AmoCRM", | ||
@@ -5,0 +5,0 @@ "main": "dist/AmoCRM.js", |
@@ -124,3 +124,2 @@ 'use strict'; | ||
this.triggerEvent( 'beforeRefreshToken', this ); | ||
console.log('refreshing token'); | ||
const { | ||
@@ -160,20 +159,29 @@ client_id, | ||
waitUserAuth() { | ||
waitUserAction() { | ||
if ( this._server ) { | ||
return; | ||
} | ||
const server = new AuthServer({ | ||
...this._options.server, | ||
state: this.getState() | ||
}); | ||
const options = { | ||
...this._options.server, | ||
state: this.getState() | ||
}, | ||
server = new AuthServer( options ); | ||
this._server = server; | ||
return new Promise( resolve => { | ||
const handleCode = new Promise( resolve => { | ||
server.on('code', code => { | ||
resolve( code ); | ||
}); | ||
server.run(); | ||
}); | ||
return handleCode | ||
.then( code => { | ||
server.stop(); | ||
return code; | ||
}) | ||
.then( code => { | ||
this._server = null; | ||
this.setCode( code ) | ||
.then( resolve ); | ||
return this.setCode( code ); | ||
}); | ||
server.run(); | ||
}) | ||
} | ||
@@ -197,3 +205,3 @@ | ||
else if ( this._options.server ) { | ||
return this.waitUserAuth(); | ||
return this.waitUserAction(); | ||
} | ||
@@ -200,0 +208,0 @@ else { |
@@ -17,5 +17,6 @@ import http from 'http'; | ||
stop() { | ||
return new Promise( resolve => | ||
return new Promise(( resolve, reject ) => | ||
this._server.close() | ||
.on( 'close', resolve ) | ||
.on( 'error', reject ) | ||
); | ||
@@ -22,0 +23,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198512
4078