Item auth_params
This commit is contained in:
@@ -75,12 +75,12 @@ angular.module('app')
|
||||
|
||||
syncManager.setKeyRequestHandler(async () => {
|
||||
let offline = authManager.offline();
|
||||
let version = offline ? passcodeManager.protocolVersion() : await authManager.protocolVersion();
|
||||
let auth_params = offline ? passcodeManager.passcodeAuthParams() : await authManager.getAuthParams();
|
||||
let keys = offline ? passcodeManager.keys() : await authManager.keys();
|
||||
return {
|
||||
keys: keys,
|
||||
offline: offline,
|
||||
version: version
|
||||
auth_params: auth_params
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ angular.module('app')
|
||||
this.createNewNote();
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedNote = note;
|
||||
note.conflict_of = null; // clear conflict
|
||||
this.selectionMade()(note);
|
||||
|
||||
@@ -173,7 +173,7 @@ class PasswordWizard {
|
||||
}
|
||||
|
||||
// Ensure value for current password matches what's saved
|
||||
let authParams = authManager.getAuthParams();
|
||||
let authParams = await authManager.getAuthParams();
|
||||
let password = $scope.formData.currentPassword;
|
||||
SFJS.crypto.computeEncryptionKeysForUser(password, authParams).then(async (keys) => {
|
||||
let success = keys.mk === (await authManager.keys()).mk;
|
||||
|
||||
@@ -179,7 +179,7 @@ class ActionsManager {
|
||||
if(decrypted) {
|
||||
keys = null;
|
||||
}
|
||||
var itemParams = new SFItemParams(item, keys, await this.authManager.protocolVersion());
|
||||
var itemParams = new SFItemParams(item, keys, await this.authManager.getAuthParams());
|
||||
return itemParams.paramsForExtension();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@ class ArchiveManager {
|
||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||
keys = this.passcodeManager.keys();
|
||||
authParams = this.passcodeManager.passcodeAuthParams();
|
||||
protocolVersion = authParams.version;
|
||||
} else {
|
||||
keys = await this.authManager.keys();
|
||||
authParams = this.authManager.getAuthParams();
|
||||
protocolVersion = await this.authManager.protocolVersion();
|
||||
authParams = await this.authManager.getAuthParams();
|
||||
}
|
||||
}
|
||||
this.__itemsData(keys, authParams, protocolVersion).then((data) => {
|
||||
this.__itemsData(keys, authParams).then((data) => {
|
||||
this.__downloadData(data, `SN Archive - ${new Date()}.txt`);
|
||||
|
||||
// download as zipped plain text files
|
||||
@@ -39,8 +37,8 @@ class ArchiveManager {
|
||||
Private
|
||||
*/
|
||||
|
||||
async __itemsData(keys, authParams, protocolVersion) {
|
||||
let data = await this.modelManager.getAllItemsJSONData(keys, authParams, protocolVersion);
|
||||
async __itemsData(keys, authParams) {
|
||||
let data = await this.modelManager.getAllItemsJSONData(keys, authParams);
|
||||
let blobData = new Blob([data], {type: 'text/json'});
|
||||
return blobData;
|
||||
}
|
||||
|
||||
@@ -49,15 +49,8 @@ class AuthManager extends SFAuthManager {
|
||||
}
|
||||
}
|
||||
|
||||
getAuthParams() {
|
||||
if(!this._authParams) {
|
||||
this._authParams = JSON.parse(this.storageManager.getItemSync("auth_params"));
|
||||
}
|
||||
return this._authParams;
|
||||
}
|
||||
|
||||
async protocolVersion() {
|
||||
var authParams = this.getAuthParams();
|
||||
var authParams = await this.getAuthParams();
|
||||
if(authParams && authParams.version) {
|
||||
return authParams.version;
|
||||
}
|
||||
|
||||
@@ -134,17 +134,14 @@ class DesktopManager {
|
||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||
keys = this.passcodeManager.keys();
|
||||
authParams = this.passcodeManager.passcodeAuthParams();
|
||||
protocolVersion = authParams.version;
|
||||
} else {
|
||||
keys = await this.authManager.keys();
|
||||
authParams = this.authManager.getAuthParams();
|
||||
protocolVersion = await this.authManager.protocolVersion();
|
||||
authParams = await this.authManager.getAuthParams();
|
||||
}
|
||||
|
||||
this.modelManager.getAllItemsJSONData(
|
||||
keys,
|
||||
authParams,
|
||||
protocolVersion,
|
||||
true /* return null on empty */
|
||||
).then((data) => {
|
||||
callback(data);
|
||||
|
||||
@@ -154,7 +154,7 @@ class StorageManager extends SFStorageManager {
|
||||
encryptedStorage.content.storage = this.storageAsHash();
|
||||
|
||||
// Save new encrypted storage in Fixed storage
|
||||
var params = new SFItemParams(encryptedStorage, this.encryptedStorageKeys, this.encryptedStorageAuthParams.version);
|
||||
var params = new SFItemParams(encryptedStorage, this.encryptedStorageKeys, this.encryptedStorageAuthParams);
|
||||
params.paramsForSync().then((syncParams) => {
|
||||
this.setItem("encryptedStorage", JSON.stringify(syncParams), StorageManager.Fixed);
|
||||
})
|
||||
|
||||
@@ -373,10 +373,6 @@ describe("syncing", () => {
|
||||
let authManager = Factory.globalAuthManager();
|
||||
let syncManager = new SFSyncManager(modelManager, Factory.globalStorageManager(), Factory.globalHttpManager());
|
||||
|
||||
syncManager.setEventHandler(() => {
|
||||
|
||||
})
|
||||
|
||||
syncManager.setKeyRequestHandler(async () => {
|
||||
return {
|
||||
keys: await authManager.keys(),
|
||||
@@ -392,7 +388,7 @@ describe("syncing", () => {
|
||||
})
|
||||
}
|
||||
|
||||
it.only('syncing a note many times does not cause duplication', async () => {
|
||||
it('syncing a note many times does not cause duplication', async () => {
|
||||
modelManager.resetLocalMemory();
|
||||
let pair = createRelatedNoteTagPair();
|
||||
let noteParams = pair[0];
|
||||
@@ -421,8 +417,6 @@ describe("syncing", () => {
|
||||
|
||||
let syncManager = new SFSyncManager(modelManager, Factory.globalStorageManager(), Factory.globalHttpManager());
|
||||
|
||||
syncManager.setEventHandler(() => {})
|
||||
|
||||
// be offline
|
||||
syncManager.setKeyRequestHandler(async () => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user