From 66ab6476cf3d499c5d0ef435e8cb26e76decbefc Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Thu, 20 Oct 2016 01:48:37 +0300 Subject: [PATCH] Part of the fix for #40 and #224 --- dist/src/demo/demo.js | 2 ++ dist/src/demo/demo.js.map | 2 +- dist/src/login.js | 30 +++++++++++++++++++----------- dist/src/login.js.map | 2 +- src/demo/demo.ts | 2 ++ src/login.ts | 38 +++++++++++++++++++++++--------------- 6 files changed, 48 insertions(+), 28 deletions(-) diff --git a/dist/src/demo/demo.js b/dist/src/demo/demo.js index 898e85b..fce0f75 100644 --- a/dist/src/demo/demo.js +++ b/dist/src/demo/demo.js @@ -12,6 +12,8 @@ skyweb.login(username, password).then(function (skypeAccount) { console.log('Your contacts : ' + JSON.stringify(skyweb.contactsService.contacts, null, 2)); console.log('Going incognito.'); skyweb.setStatus('Hidden'); +}).catch(function (reason) { + console.log(reason); }); skyweb.authRequestCallback = function (requests) { requests.forEach(function (request) { diff --git a/dist/src/demo/demo.js.map b/dist/src/demo/demo.js.map index 939936b..d66f47a 100644 --- a/dist/src/demo/demo.js.map +++ b/dist/src/demo/demo.js.map @@ -1 +1 @@ -{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../../src/demo/demo.ts"],"names":[],"mappings":";AAAA,uBAAmB,WAAW,CAAC,CAAA;AAE/B,IAAI,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,IAAI,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AAC1F,CAAC;AAED,IAAI,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;AAC1B,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC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AAC,CAAC,CAAC;AACH,MAAM,CAAC,mBAAmB,GAAG,UAAC,QAAQ;IAClC,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;QACrB,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AACF,MAAM,CAAC,gBAAgB,GAAG,UAAC,QAAQ;IAC/B,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;QACrB,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,gBAAgB,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,qBAAqB,CAAC,CAAC,CAAC;YAChK,IAAI,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACzD,IAAI,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACvF,MAAM,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,GAAG,4BAA4B,CAAC,CAAC;QAChG,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/src/login.js b/dist/src/login.js index 6501e28..eaa5e2b 100644 --- a/dist/src/login.js +++ b/dist/src/login.js @@ -5,6 +5,10 @@ var utils_1 = require('./utils'); var Consts = require('./consts'); var url = require('url'); var es6_promise_1 = require("es6-promise"); +var rejectWithError = function (reject, error) { + utils_1.default.throwError(error); + reject(error); +}; var Login = (function () { function Login(cookieJar) { this.cookieJar = cookieJar; @@ -27,7 +31,7 @@ var Login = (function () { if (!error && response.statusCode == 200) { var ppft = / { console.log('Your contacts : ' + JSON.stringify(skyweb.contactsService.contacts, null, 2)); console.log('Going incognito.'); skyweb.setStatus('Hidden'); +}).catch((reason: string)=> { + console.log(reason); }); skyweb.authRequestCallback = (requests) => { requests.forEach((request) => { diff --git a/src/login.ts b/src/login.ts index 60f36c7..6a167a2 100644 --- a/src/login.ts +++ b/src/login.ts @@ -8,6 +8,11 @@ import * as url from 'url'; import {CookieJar} from "request"; import {Promise} from "es6-promise"; +const rejectWithError = (reject:(reason?:any)=>void, error: string) => { + Utils.throwError(error); + reject(error); +}; + export class Login { private requestWithJar: any; private cookieJar: CookieJar; @@ -37,7 +42,7 @@ export class Login { var ppft = /