Passcode manager auth params
This commit is contained in:
@@ -26,6 +26,10 @@ angular.module('app')
|
|||||||
return JSON.parse(storageManager.getItem("offlineParams", StorageManager.Fixed));
|
return JSON.parse(storageManager.getItem("offlineParams", StorageManager.Fixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.protocolVersion = function() {
|
||||||
|
return this._authParams && this._authParams.version;
|
||||||
|
}
|
||||||
|
|
||||||
this.unlock = function(passcode, callback) {
|
this.unlock = function(passcode, callback) {
|
||||||
var params = this.passcodeAuthParams();
|
var params = this.passcodeAuthParams();
|
||||||
SFJS.crypto.computeEncryptionKeysForUser(passcode, params, (keys) => {
|
SFJS.crypto.computeEncryptionKeysForUser(passcode, params, (keys) => {
|
||||||
@@ -35,6 +39,7 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._keys = keys;
|
this._keys = keys;
|
||||||
|
this._authParams = params;
|
||||||
this.decryptLocalStorage(keys, params);
|
this.decryptLocalStorage(keys, params);
|
||||||
this._locked = false;
|
this._locked = false;
|
||||||
callback(true);
|
callback(true);
|
||||||
@@ -48,10 +53,12 @@ angular.module('app')
|
|||||||
authParams.hash = keys.pw;
|
authParams.hash = keys.pw;
|
||||||
this._keys = keys;
|
this._keys = keys;
|
||||||
this._hasPasscode = true;
|
this._hasPasscode = true;
|
||||||
|
this._authParams = authParams;
|
||||||
|
|
||||||
// Encrypting will initially clear localStorage
|
// Encrypting will initially clear localStorage
|
||||||
this.encryptLocalStorage(keys, authParams);
|
this.encryptLocalStorage(keys, authParams);
|
||||||
|
|
||||||
|
|
||||||
// After it's cleared, it's safe to write to it
|
// After it's cleared, it's safe to write to it
|
||||||
storageManager.setItem("offlineParams", JSON.stringify(authParams), StorageManager.Fixed);
|
storageManager.setItem("offlineParams", JSON.stringify(authParams), StorageManager.Fixed);
|
||||||
callback(true);
|
callback(true);
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class SyncManager {
|
|||||||
callback && callback();
|
callback && callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Use null to use the latest protocol version if offline
|
|
||||||
var version = this.authManager.offline() ? null : this.authManager.protocolVersion();
|
var version = this.authManager.offline() ? this.passcodeManager.protocolVersion() : this.authManager.protocolVersion();
|
||||||
var keys = this.authManager.offline() ? this.passcodeManager.keys() : this.authManager.keys();
|
var keys = this.authManager.offline() ? this.passcodeManager.keys() : this.authManager.keys();
|
||||||
var params = items.map(function(item) {
|
var params = items.map(function(item) {
|
||||||
var itemParams = new ItemParams(item, keys, version);
|
var itemParams = new ItemParams(item, keys, version);
|
||||||
|
|||||||
Reference in New Issue
Block a user