fix: encryption and decryption!
This commit is contained in:
parent
0d32654e2e
commit
6e5729afd2
4 changed files with 56 additions and 11 deletions
10
dist/bundle.es.js
vendored
10
dist/bundle.es.js
vendored
|
@ -2580,7 +2580,7 @@ function doResetSync() {
|
|||
resolve();
|
||||
});
|
||||
}
|
||||
function changeSyncPassword(oldPassword, newPassword) {
|
||||
function doSyncEncryptAndDecrypt(oldPassword, newPassword, encrypt) {
|
||||
return dispatch => {
|
||||
let data = {};
|
||||
return lbryRedux.Lbry.sync_hash().then(hash => {
|
||||
|
@ -2593,6 +2593,12 @@ function changeSyncPassword(oldPassword, newPassword) {
|
|||
password: oldPassword,
|
||||
data: syncGetResponse.data
|
||||
});
|
||||
}).then(() => {
|
||||
if (encrypt) {
|
||||
dispatch(lbryRedux.doWalletEncrypt(newPassword));
|
||||
} else {
|
||||
dispatch(lbryRedux.doWalletDecrypt());
|
||||
}
|
||||
}).then(() => lbryRedux.Lbry.sync_apply({
|
||||
password: newPassword
|
||||
})).then(syncApplyResponse => {
|
||||
|
@ -3269,7 +3275,6 @@ exports.Lbryio = Lbryio;
|
|||
exports.YOUTUBE_STATUSES = youtube;
|
||||
exports.authReducer = authReducer;
|
||||
exports.blacklistReducer = blacklistReducer;
|
||||
exports.changeSyncPassword = changeSyncPassword;
|
||||
exports.costInfoReducer = costInfoReducer;
|
||||
exports.doAuthenticate = doAuthenticate;
|
||||
exports.doBlackListedOutpointsSubscribe = doBlackListedOutpointsSubscribe;
|
||||
|
@ -3310,6 +3315,7 @@ exports.doSetSync = doSetSync;
|
|||
exports.doSetViewMode = doSetViewMode;
|
||||
exports.doShowSuggestedSubs = doShowSuggestedSubs;
|
||||
exports.doSyncApply = doSyncApply;
|
||||
exports.doSyncEncryptAndDecrypt = doSyncEncryptAndDecrypt;
|
||||
exports.doUpdateUnreadSubscriptions = doUpdateUnreadSubscriptions;
|
||||
exports.doUserCheckEmailVerified = doUserCheckEmailVerified;
|
||||
exports.doUserEmailNew = doUserEmailNew;
|
||||
|
|
37
dist/bundle.js
vendored
37
dist/bundle.js
vendored
|
@ -234,6 +234,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doResetSync", function() { return redux_actions_sync__WEBPACK_IMPORTED_MODULE_15__["doResetSync"]; });
|
||||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doSyncEncryptAndDecrypt", function() { return redux_actions_sync__WEBPACK_IMPORTED_MODULE_15__["doSyncEncryptAndDecrypt"]; });
|
||||
|
||||
/* harmony import */ var redux_reducers_auth__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(29);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "authReducer", function() { return redux_reducers_auth__WEBPACK_IMPORTED_MODULE_16__["authReducer"]; });
|
||||
|
||||
|
@ -3890,6 +3892,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doSyncApply", function() { return doSyncApply; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doCheckSync", function() { return doCheckSync; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doResetSync", function() { return doResetSync; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doSyncEncryptAndDecrypt", function() { return doSyncEncryptAndDecrypt; });
|
||||
/* harmony import */ var constants_action_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
||||
/* harmony import */ var lbryio__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
||||
/* harmony import */ var lbry_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
||||
|
@ -4039,7 +4042,9 @@ function doGetSync(passedPassword, callback) {
|
|||
data: data
|
||||
});
|
||||
handleCallback();
|
||||
})["catch"](function () {
|
||||
})["catch"](function (err) {
|
||||
console.log('error', err);
|
||||
|
||||
if (data.hasSyncedWallet) {
|
||||
var error = 'Error getting synced wallet';
|
||||
dispatch({
|
||||
|
@ -4145,6 +4150,36 @@ function doResetSync() {
|
|||
});
|
||||
};
|
||||
}
|
||||
function doSyncEncryptAndDecrypt(oldPassword, newPassword, encrypt) {
|
||||
return function (dispatch) {
|
||||
var data = {};
|
||||
return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_hash().then(function (hash) {
|
||||
return lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].call('sync', 'get', {
|
||||
hash: hash
|
||||
}, 'post');
|
||||
}).then(function (syncGetResponse) {
|
||||
data.oldHash = syncGetResponse.hash;
|
||||
return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
|
||||
password: oldPassword,
|
||||
data: syncGetResponse.data
|
||||
});
|
||||
}).then(function () {
|
||||
if (encrypt) {
|
||||
dispatch(Object(lbry_redux__WEBPACK_IMPORTED_MODULE_2__["doWalletEncrypt"])(newPassword));
|
||||
} else {
|
||||
dispatch(Object(lbry_redux__WEBPACK_IMPORTED_MODULE_2__["doWalletDecrypt"])());
|
||||
}
|
||||
}).then(function () {
|
||||
return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
|
||||
password: newPassword
|
||||
});
|
||||
}).then(function (syncApplyResponse) {
|
||||
if (syncApplyResponse.hash !== data.oldHash) {
|
||||
return dispatch(doSetSync(data.oldHash, syncApplyResponse.hash, syncApplyResponse.data));
|
||||
}
|
||||
})["catch"](console.error);
|
||||
};
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
/* 29 */
|
||||
|
|
|
@ -73,7 +73,7 @@ export {
|
|||
doSetDefaultAccount,
|
||||
doSyncApply,
|
||||
doResetSync,
|
||||
changeSyncPassword,
|
||||
doSyncEncryptAndDecrypt,
|
||||
} from 'redux/actions/sync';
|
||||
|
||||
// reducers
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as ACTIONS from 'constants/action_types';
|
||||
import Lbryio from 'lbryio';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { Lbry, doWalletEncrypt, doWalletDecrypt } from 'lbry-redux';
|
||||
|
||||
export function doSetDefaultAccount(success, failure) {
|
||||
return dispatch => {
|
||||
|
@ -231,19 +231,23 @@ export function doResetSync() {
|
|||
});
|
||||
}
|
||||
|
||||
export function changeSyncPassword(oldPassword, newPassword) {
|
||||
export function doSyncEncryptAndDecrypt(oldPassword, newPassword, encrypt) {
|
||||
return dispatch => {
|
||||
let data = {};
|
||||
|
||||
const data = {};
|
||||
return Lbry.sync_hash()
|
||||
.then(hash => {
|
||||
return Lbryio.call('sync', 'get', { hash }, 'post');
|
||||
})
|
||||
.then(hash => Lbryio.call('sync', 'get', { hash }, 'post'))
|
||||
.then(syncGetResponse => {
|
||||
data.oldHash = syncGetResponse.hash;
|
||||
|
||||
return Lbry.sync_apply({ password: oldPassword, data: syncGetResponse.data });
|
||||
})
|
||||
.then(() => {
|
||||
if (encrypt) {
|
||||
dispatch(doWalletEncrypt(newPassword));
|
||||
} else {
|
||||
dispatch(doWalletDecrypt());
|
||||
}
|
||||
})
|
||||
.then(() => Lbry.sync_apply({ password: newPassword }))
|
||||
.then(syncApplyResponse => {
|
||||
if (syncApplyResponse.hash !== data.oldHash) {
|
||||
|
|
Loading…
Reference in a new issue