Commit a07b602f authored by Benjamin Bouvier's avatar Benjamin Bouvier
Browse files

Build;

parent 35b038b5
This diff is collapsed.
......@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
});
exports.update = exports.poll = exports.fetchAccounts = exports.fetchOperations = exports.create = exports.destroy = exports.getAccounts = exports.preloadAccess = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// Preloads a bank access (sets @access).
var preloadAccess = exports.preloadAccess = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(req, res, next, accessId) {
......@@ -208,8 +210,6 @@ var destroy = exports.destroy = function () {
// Creates a new bank access (expecting at least (bank / login / password)), and
// retrieves its accounts and operations.
var create = exports.create = function () {
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(req, res) {
var access, createdAccess, retrievedAccounts, params, similarAccesses, errcode, _ref5, accounts, newOperations, _accounts, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, acc;
......@@ -247,7 +247,7 @@ var create = exports.create = function () {
case 12:
_context4.next = 14;
return _access2.default.create(params);
return _access2.default.create(sanitizeCustomFields(params));
case 14:
access = _context4.sent;
......@@ -560,7 +560,7 @@ var update = exports.update = function () {
}
_context8.next = 5;
return req.preloaded.access.updateAttributes(access);
return req.preloaded.access.updateAttributes(sanitizeCustomFields(access));
case 5:
_context8.next = 7;
......@@ -635,4 +635,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var log = (0, _helpers.makeLogger)('controllers/accesses');
\ No newline at end of file
var log = (0, _helpers.makeLogger)('controllers/accesses');
function sanitizeCustomFields(access) {
if (typeof access.customFields !== 'undefined') {
try {
JSON.parse(access.customFields);
} catch (e) {
log.warn('Sanitizing unparseable access.customFields.');
var sanitized = _extends({}, access);
sanitized.customFields = '[]';
return sanitized;
}
}
return access;
}
\ No newline at end of file
......@@ -108,10 +108,15 @@ var _fetchHelper = function () {
throw new _helpers.KError("Weboob doesn't seem to be installed, skipping fetch.", 500, _errors.WEBOOB_NOT_INSTALLED);
case 15:
log.info('Got error while fetching ' + command + ': ' + _context3.t0.error_code + '.');
log.error('Got error while fetching ' + command + ': ' + _context3.t0.message);
if (typeof _context3.t0.error_code !== 'undefined') {
log.error('\t(error code: ' + _context3.t0.error_code + ')');
}
throw _context3.t0;
case 17:
case 18:
case 'end':
return _context3.stop();
}
......
......@@ -270,7 +270,9 @@ var oldAll = (_context = Config).all.bind(_context);
// A list of all the settings that are implied at runtime and should not be
// saved into the database.
Config.ghostSettings = new Set(['weboob-installed', 'standalone-mode', 'url-prefix', 'emails-enabled']);
// *Never* ever remove a name from this list, since these are used also to
// know which settings shouldn't be imported or exported.
Config.ghostSettings = new Set(['weboob-version', 'weboob-installed', 'standalone-mode', 'url-prefix', 'emails-enabled']);
// Returns all the config name/value pairs, except for the ghost ones that are
// implied at runtime.
......
......@@ -77,17 +77,17 @@ var updateCustomFields = function () {
* value, which indicates the next migration to run.
*/
var run = exports.run = function () {
var _ref17 = _asyncToGenerator(regeneratorRuntime.mark(function _callee16() {
var _ref19 = _asyncToGenerator(regeneratorRuntime.mark(function _callee18() {
var migrationVersion, cache, firstMigrationIndex, m;
return regeneratorRuntime.wrap(function _callee16$(_context16) {
return regeneratorRuntime.wrap(function _callee18$(_context18) {
while (1) {
switch (_context16.prev = _context16.next) {
switch (_context18.prev = _context18.next) {
case 0:
_context16.next = 2;
_context18.next = 2;
return _config2.default.findOrCreateDefault('migration-version');
case 2:
migrationVersion = _context16.sent;
migrationVersion = _context18.sent;
// Cache to prevent loading multiple times the same data from the db.
......@@ -97,34 +97,34 @@ var run = exports.run = function () {
case 6:
if (!(m < migrations.length)) {
_context16.next = 15;
_context18.next = 15;
break;
}
_context16.next = 9;
_context18.next = 9;
return migrations[m](cache);
case 9:
migrationVersion.value = (m + 1).toString();
_context16.next = 12;
_context18.next = 12;
return migrationVersion.save();
case 12:
m++;
_context16.next = 6;
_context18.next = 6;
break;
case 15:
case 'end':
return _context16.stop();
return _context18.stop();
}
}
}, _callee16, this);
}, _callee18, this);
}));
return function run() {
return _ref17.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}();
......@@ -2010,4 +2010,180 @@ var migrations = [function () {
}
return m13;
}(), function () {
var _ref17 = _asyncToGenerator(regeneratorRuntime.mark(function _callee16(cache) {
var _iteratorNormalCompletion18, _didIteratorError18, _iteratorError18, _iterator18, _step18, access;
return regeneratorRuntime.wrap(function _callee16$(_context16) {
while (1) {
switch (_context16.prev = _context16.next) {
case 0:
_context16.prev = 0;
log.info('Migrating empty access.customFields...');
_context16.t0 = cache.accesses;
if (_context16.t0) {
_context16.next = 7;
break;
}
_context16.next = 6;
return _access2.default.all();
case 6:
_context16.t0 = _context16.sent;
case 7:
cache.accesses = _context16.t0;
_iteratorNormalCompletion18 = true;
_didIteratorError18 = false;
_iteratorError18 = undefined;
_context16.prev = 11;
_iterator18 = cache.accesses[Symbol.iterator]();
case 13:
if (_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done) {
_context16.next = 30;
break;
}
access = _step18.value;
if (!(typeof access.customFields === 'undefined')) {
_context16.next = 17;
break;
}
return _context16.abrupt('continue', 27);
case 17:
_context16.prev = 17;
JSON.parse(access.customFields);
_context16.next = 27;
break;
case 21:
_context16.prev = 21;
_context16.t1 = _context16['catch'](17);
log.info('Found invalid access.customFields for access with id=' + access.id + ', replacing by empty array.');
access.customFields = '[]';
_context16.next = 27;
return access.save();
case 27:
_iteratorNormalCompletion18 = true;
_context16.next = 13;
break;
case 30:
_context16.next = 36;
break;
case 32:
_context16.prev = 32;
_context16.t2 = _context16['catch'](11);
_didIteratorError18 = true;
_iteratorError18 = _context16.t2;
case 36:
_context16.prev = 36;
_context16.prev = 37;
if (!_iteratorNormalCompletion18 && _iterator18.return) {
_iterator18.return();
}
case 39:
_context16.prev = 39;
if (!_didIteratorError18) {
_context16.next = 42;
break;
}
throw _iteratorError18;
case 42:
return _context16.finish(39);
case 43:
return _context16.finish(36);
case 44:
_context16.next = 49;
break;
case 46:
_context16.prev = 46;
_context16.t3 = _context16['catch'](0);
log.error('Error while migrating empty access.customFields:', _context16.t3.toString());
case 49:
case 'end':
return _context16.stop();
}
}
}, _callee16, this, [[0, 46], [11, 32, 36, 44], [17, 21], [37,, 39, 43]]);
}));
function m14(_x12) {
return _ref17.apply(this, arguments);
}
return m14;
}(), function () {
var _ref18 = _asyncToGenerator(regeneratorRuntime.mark(function _callee17() {
var found;
return regeneratorRuntime.wrap(function _callee17$(_context17) {
while (1) {
switch (_context17.prev = _context17.next) {
case 0:
log.info('Removing weboob-version from the database...');
_context17.prev = 1;
_context17.next = 4;
return _config2.default.byName('weboob-version');
case 4:
found = _context17.sent;
if (found) {
_context17.next = 7;
break;
}
return _context17.abrupt('return');
case 7:
_context17.next = 9;
return found.destroy();
case 9:
log.info('Found and deleted weboob-version.');
_context17.next = 15;
break;
case 12:
_context17.prev = 12;
_context17.t0 = _context17['catch'](1);
log.error('Error while removing weboob-version: ', _context17.t0.toString());
case 15:
case 'end':
return _context17.stop();
}
}
}, _callee17, this, [[1, 12]]);
}));
function m15() {
return _ref18.apply(this, arguments);
}
return m15;
}()];
\ No newline at end of file
......@@ -281,7 +281,8 @@
"unknown_module": "Your bank requires a module not supported by Kresus (and Weboob) or a dependency is missing. Please try updating Weboob or ask a maintainer.",
"unknown_error": "This is an error unknown to Kresus, please try updating Weboob, and if it doesn't work, please report the error.",
"action_needed": "Your bank's website requires a manual action from you. Please log in manually on your bank's website, follow the instructions, and try again.",
"weboob_not_installed": "Weboob is not installed. You will now be redirected to the dedicated help page."
"weboob_not_installed": "Weboob is not installed. You will now be redirected to the dedicated help page.",
"bank_already_exists": "This bank/login/password combination has already been linked within Kresus, aborting."
},
"type": {
"none": "None",
......
......@@ -281,7 +281,8 @@
"unknown_module": "Votre banque utilise un module non supporté par Kresus (et Weboob) ou il manque une dépendance. Essayez de mettre à jour Weboob ou contactez un mainteneur.",
"unknown_error": "Erreur inconnue de Kresus : essayez de mettre à jour Weboob, et si cela ne règle pas votre problème, merci de signaler l'erreur aux auteurs de Kresus.",
"action_needed": "Le site web de votre banque nécessite une action manuelle de votre part. Veuillez vous connecter sur le site de votre banque, suivez les instructions et réessayez.",
"weboob_not_installed": "Weboob n'est pas installé. Vous allez maintenant être redirigé vers la page d'aide associée."
"weboob_not_installed": "Weboob n'est pas installé. Vous allez maintenant être redirigé vers la page d'aide associée.",
"bank_already_exists": "Cette combinaison banque/login/mot de passe a déjà été liée à Kresus, annulation de l'action."
},
"type": {
"none": "Aucun",
......
......@@ -50,10 +50,16 @@ def error(error_code, error_short, error_long):
:param error_code: Kresus-specific error code. See ``shared/errors.json``.
:param error_content: Error string.
"""
error_message = None
if error_long is not None:
error_message = "%s\n%s" % (error_short, error_long)
else:
error_message = error_short
error_object = {
'error_code': error_code,
'error_short': error_short,
'error_message': "%s\n%s" % (error_short, error_long)
'error_message': error_message
}
print(json.dumps(error_object))
sys.exit(1)
......@@ -514,19 +520,22 @@ class Connector(object):
with backend: # Acquire lock on backend
results['values'].extend(fetch_function(backend))
except ActionNeeded as exc:
results['error_code'] = ACTION_NEEDED
results['error_content'] = unicode(exc)
except NoAccountsException:
results['error_code'] = NO_ACCOUNTS
except ModuleLoadError:
results['error_code'] = UNKNOWN_MODULE
except BrowserPasswordExpired:
results['error_code'] = EXPIRED_PASSWORD
except ActionNeeded as exc:
# This `except` clause is not in alphabetic order and cannot be,
# because BrowserPasswordExpired (above) inherits from it in
# Weboob 1.4.
results['error_code'] = ACTION_NEEDED
results['error_content'] = unicode(exc)
except BrowserIncorrectPassword:
# This `except` clause is not in alphabetic order and cannot be.
# This is due to the fact that BrowserPasswordExpired inherits from
# BrowserIncorrectPassword in Weboob 1.3.
# This `except` clause is not in alphabetic order and cannot be,
# because BrowserPasswordExpired (above) inherits from it in
# Weboob 1.3.
results['error_code'] = INVALID_PASSWORD
except Module.ConfigError as exc:
results['error_code'] = INVALID_PARAMETERS
......
{
"name": "kresus",
"version": "0.12.1",
"version": "0.12.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -1130,15 +1130,15 @@
}
},
"is-index-x": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-index-x/-/is-index-x-1.0.0.tgz",
"integrity": "sha512-BJ7vtw0jvcjBX4UsT7KkpZUliAMX3vJugZimDKy4W6ilGDtvUZ8nYsYnROVrrsjNjg5LJ3MN9NvyRVALfDW/wQ==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-index-x/-/is-index-x-1.1.0.tgz",
"integrity": "sha512-qULKLMepQLGC8rSVdi8uF2vI4LiDrU9XSDg1D+Aa657GIB7GV1jHpga7uXgQvkt/cpQ5mVBHUFTpSehYSqT6+A==",
"requires": {
"math-clamp-x": "1.2.0",
"max-safe-integer": "1.0.1",
"safe-to-string-x": "2.0.3",
"to-integer-x": "2.1.0",
"to-number-x": "1.2.0"
"to-integer-x": "3.0.0",
"to-number-x": "2.0.0",
"to-string-symbols-supported-x": "1.0.0"
}
},
"is-nan-x": {
......@@ -1428,29 +1428,15 @@
"integrity": "sha512-tqpjpBcIf9UulApz3EjWXqTZpMlr2vLN9PryC9ghoyCuRmqZaf3JJhPddzgQpJnKLi2QhoFnvKBFtJekAIBSYg==",
"requires": {
"to-number-x": "2.0.0"
},
"dependencies": {
"to-number-x": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-number-x/-/to-number-x-2.0.0.tgz",
"integrity": "sha512-lGOnCoccUoSzjZ/9Uen8TC4+VFaQcFGhTroWTv2tYWxXgyJV1zqAZ8hEIMkez/Eo790fBMOjidTnQ/OJSCvAoQ==",
"requires": {
"cached-constructors-x": "1.0.0",
"nan-x": "1.0.0",
"parse-int-x": "2.0.0",
"to-primitive-x": "1.1.0",
"trim-x": "3.0.0"
}
}
}
},
"math-sign-x": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/math-sign-x/-/math-sign-x-2.1.0.tgz",
"integrity": "sha512-3shFG0Ea5vOMCgQCrylyzu3POQRTvvaclb4VArnICToTgshMfA4Dlb9q9lZO1SD/rUD9mOTJZ7dTtlfCq7I91A==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/math-sign-x/-/math-sign-x-3.0.0.tgz",
"integrity": "sha512-OzPas41Pn4d16KHnaXmGxxY3/l3zK4OIXtmIwdhgZsxz4FDDcNnbrABYPg2vGfxIkaT9ezGnzDviRH7RfF44jQ==",
"requires": {
"is-nan-x": "1.0.1",
"to-number-x": "1.2.0"
"to-number-x": "2.0.0"
}
},
"max-safe-integer": {
......@@ -1737,7 +1723,7 @@
"has-own-property-x": "3.2.0",
"has-symbol-support-x": "1.4.1",
"is-falsey-x": "1.0.1",
"is-index-x": "1.0.0",
"is-index-x": "1.1.0",
"is-primitive": "2.0.0",
"is-string": "1.0.4",
"property-is-enumerable-x": "1.1.0",
......@@ -2119,14 +2105,6 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
"safe-to-string-x": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/safe-to-string-x/-/safe-to-string-x-2.0.3.tgz",
"integrity": "sha512-hbxWZc0a+3VG7SpSKpZbBiXwQOV/bW/hwNvMFRPCL/60Ze/6Y8atHqv/0dWiWc9sHmkFqVCMR5gjmukMzKnA6A==",
"requires": {
"to-string-symbols-supported-x": "1.0.0"
}
},
"semver": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
......@@ -2378,73 +2356,26 @@
"integrity": "sha512-PstxY3K6hVEHnY3FITs8XBoJbt0RI1e4MLIhAL9hWa3BtVLCrb86vU5z6lEKh7uZZjiPiLqIKMmfMro1nNgtXQ=="
},
"to-integer-x": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/to-integer-x/-/to-integer-x-2.1.0.tgz",
"integrity": "sha512-M9iETTi+xMMZtUC70q4VE63XL2mXmNABxwxsIebOfd8K4ZHKCJLD9GyE6RlEPnbOPZj21QinuoVkqWsBsBknRA==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/to-integer-x/-/to-integer-x-3.0.0.tgz",
"integrity": "sha512-794L2Lpwjtynm7RxahJi2YdbRY75gTxUW27TMuN26UgwPkmJb/+HPhkFEFbz+E4vNoiP0dxq5tq5fkXoXLaK/w==",
"requires": {
"is-finite-x": "3.0.2",
"is-nan-x": "1.0.1",
"math-sign-x": "2.1.0",
"to-number-x": "1.2.0"
"math-sign-x": "3.0.0",
"to-number-x": "2.0.0"
}
},
"to-number-x": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/to-number-x/-/to-number-x-1.2.0.tgz",
"integrity": "sha512-Pv/VvC0nLIqtEK1FRtmfWCSWE1gliXt0YSjFcjSIy8YMGyIovbUfX2HIgn/KXqtgB7NlqWWKIaj3mFukzPf0ig==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-number-x/-/to-number-x-2.0.0.tgz",
"integrity": "sha512-lGOnCoccUoSzjZ/9Uen8TC4+VFaQcFGhTroWTv2tYWxXgyJV1zqAZ8hEIMkez/Eo790fBMOjidTnQ/OJSCvAoQ==",
"requires": {
"cached-constructors-x": "1.0.0",
"nan-x": "1.0.0",
"parse-int-x": "1.1.0",
"parse-int-x": "2.0.0",
"to-primitive-x": "1.1.0",
"trim-x": "2.0.2"
},
"dependencies": {
"parse-int-x": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/parse-int-x/-/parse-int-x-1.1.0.tgz",
"integrity": "sha512-gEo/Rb66RiK7Ba89Va5JWYrfF2TdIblmawQuJEs4XxHIsTE0wi1ME5M/O21L8JJ9NjOlA+CqHCbkZjHRZnQPrg==",
"requires": {
"cached-constructors-x": "1.0.0",
"to-string-x": "1.4.2",
"trim-x": "2.0.2",
"white-space-x": "2.0.3"
}
},
"trim-left-x": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/trim-left-x/-/trim-left-x-2.0.1.tgz",
"integrity": "sha512-7JTQAjTmsUB07eDuVoBxAtRbvrC141gYhEnKoP5FHZGc7phaqjbqII7+nFT15gc73F0D7qPb7W+Ny8Im0Kip/Q==",
"requires": {
"cached-constructors-x": "1.0.0",
"require-coercible-to-string-x": "1.0.0",
"white-space-x": "2.0.3"
}
},
"trim-right-x": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/trim-right-x/-/trim-right-x-2.0.1.tgz",
"integrity": "sha512-hdz1fDE/roIkWWNtA43matOTi3dHgLhDkKTo+hFgLwlYSqjNt7Qr0QKZyik8ZDTpjUmrgHtU5/lb+gL/pngWvQ==",
"requires": {
"cached-constructors-x": "1.0.0",
"require-coercible-to-string-x": "1.0.0",
"white-space-x": "2.0.3"
}
},
"trim-x": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/trim-x/-/trim-x-2.0.2.tgz",
"integrity": "sha512-FnvMjV360hsj/OQpAaXqAKspNqyawkVe5zkWH/aOVOGcSnbeJYpeOYiaKIZYpu0ZQes3pq7IRm4whHJqAoev7w==",
"requires": {
"trim-left-x": "2.0.1",
"trim-right-x": "2.0.1"
}
},
"white-space-x": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/white-space-x/-/white-space-x-2.0.3.tgz",
"integrity": "sha512-An6uHDfZizY0t7x8iyY8nLej1lnqyaFSyTKjwwqS0VIhvV4tof6a+Et4uJVFlZh7HUAOgKoZfm5hFzl/D4xDgw=="
}
"trim-x": "3.0.0"
}
},
"to-object-x": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment