Handle SNJS rename of cryptoManager to protocolManager, extract test suite into SNJS
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { isDesktopApplication } from '@/utils';
|
||||
import { PrivilegesManager } from '@/services/privilegesManager';
|
||||
import template from '%/directives/account-menu.pug';
|
||||
import { cryptoManager } from 'snjs';
|
||||
import { protocolManager } from 'snjs';
|
||||
|
||||
export class AccountMenu {
|
||||
constructor() {
|
||||
@@ -326,9 +326,9 @@ export class AccountMenu {
|
||||
}
|
||||
|
||||
if(data.auth_params) {
|
||||
cryptoManager.computeEncryptionKeysForUser(password, data.auth_params).then((keys) => {
|
||||
protocolManager.computeEncryptionKeysForUser(password, data.auth_params).then((keys) => {
|
||||
try {
|
||||
cryptoManager.decryptMultipleItems(data.items, keys, false) /* throws = false as we don't want to interrupt all decryption if just one fails */
|
||||
protocolManager.decryptMultipleItems(data.items, keys, false) /* throws = false as we don't want to interrupt all decryption if just one fails */
|
||||
.then(() => {
|
||||
// delete items enc_item_key since the user's actually key will do the encrypting once its passed off
|
||||
data.items.forEach(function(item){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cryptoManager } from 'snjs';
|
||||
import { protocolManager } from 'snjs';
|
||||
import template from '%/directives/password-wizard.pug';
|
||||
|
||||
export class PasswordWizard {
|
||||
@@ -213,7 +213,7 @@ export class PasswordWizard {
|
||||
// Ensure value for current password matches what's saved
|
||||
let authParams = await authManager.getAuthParams();
|
||||
let password = $scope.formData.currentPassword;
|
||||
cryptoManager.computeEncryptionKeysForUser(password, authParams).then(async (keys) => {
|
||||
protocolManager.computeEncryptionKeysForUser(password, authParams).then(async (keys) => {
|
||||
let success = keys.mk === (await authManager.keys()).mk;
|
||||
if(success) {
|
||||
this.currentServerPw = keys.pw;
|
||||
@@ -241,7 +241,7 @@ export class PasswordWizard {
|
||||
|
||||
let currentServerPw = this.currentServerPw;
|
||||
|
||||
let results = await cryptoManager.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
|
||||
let results = await protocolManager.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
|
||||
let newKeys = results.keys;
|
||||
let newAuthParams = results.authParams;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cryptoManager, SNComponent, SFItem, SFModelManager } from 'snjs';
|
||||
import { protocolManager, SNComponent, SFItem, SFModelManager } from 'snjs';
|
||||
import template from '%/directives/revision-preview-modal.pug';
|
||||
|
||||
export class RevisionPreviewModal {
|
||||
@@ -33,7 +33,7 @@ export class RevisionPreviewModal {
|
||||
// but then generate new uuid for note as not to save changes to original, if editor makes changes.
|
||||
$scope.note.uuid = $scope.uuid;
|
||||
let editorForNote = componentManager.editorForNote($scope.note);
|
||||
$scope.note.uuid = cryptoManager.crypto.generateUUIDSync();
|
||||
$scope.note.uuid = protocolManager.crypto.generateUUIDSync();
|
||||
|
||||
if(editorForNote) {
|
||||
// Create temporary copy, as a lot of componentManager is uuid based,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import { Action, SFModelManager, SFItemParams, cryptoManager } from 'snjs';
|
||||
import { Action, SFModelManager, SFItemParams, protocolManager } from 'snjs';
|
||||
|
||||
export class ActionsManager {
|
||||
|
||||
@@ -85,7 +85,7 @@ export class ActionsManager {
|
||||
let handleResponseDecryption = async (response, keys, merge) => {
|
||||
var item = response.item;
|
||||
|
||||
await cryptoManager.decryptItem(item, keys);
|
||||
await protocolManager.decryptItem(item, keys);
|
||||
|
||||
if(!item.errorDecrypting) {
|
||||
if(merge) {
|
||||
@@ -115,7 +115,7 @@ export class ActionsManager {
|
||||
}
|
||||
triedPasswords.push(passwordCandidate);
|
||||
|
||||
var keyResults = await cryptoManager.computeEncryptionKeysForUser(passwordCandidate, response.auth_params);
|
||||
var keyResults = await protocolManager.computeEncryptionKeysForUser(passwordCandidate, response.auth_params);
|
||||
if(!keyResults) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import angular from 'angular';
|
||||
import { StorageManager } from './storageManager';
|
||||
import { cryptoManager, SFItem, SFPredicate, SFAuthManager } from 'snjs';
|
||||
import { protocolManager, SFItem, SFPredicate, SFAuthManager } from 'snjs';
|
||||
|
||||
export class AuthManager extends SFAuthManager {
|
||||
/* @ngInject */
|
||||
@@ -112,7 +112,7 @@ export class AuthManager extends SFAuthManager {
|
||||
|
||||
async verifyAccountPassword(password) {
|
||||
let authParams = await this.getAuthParams();
|
||||
let keys = await cryptoManager.computeEncryptionKeysForUser(password, authParams);
|
||||
let keys = await protocolManager.computeEncryptionKeysForUser(password, authParams);
|
||||
let success = keys.mk === (await this.keys()).mk;
|
||||
return success;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ export class AuthManager extends SFAuthManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
let latest = cryptoManager.version();
|
||||
let latest = protocolManager.version();
|
||||
let updateAvailable = await this.protocolVersion() !== latest;
|
||||
if(updateAvailable !== this.securityUpdateAvailable) {
|
||||
this.securityUpdateAvailable = updateAvailable;
|
||||
|
||||
@@ -1,32 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
SFItem,
|
||||
SFModelManager,
|
||||
SFPrivileges,
|
||||
SFPredicate,
|
||||
SNNote,
|
||||
SNTag,
|
||||
SNSmartTag,
|
||||
SNExtension,
|
||||
SNEditor,
|
||||
SNTheme,
|
||||
SNComponent,
|
||||
SNServerExtension,
|
||||
SNMfa
|
||||
} from 'snjs';
|
||||
|
||||
SFModelManager.ContentTypeClassMapping = {
|
||||
"Note" : SNNote,
|
||||
"Tag" : SNTag,
|
||||
"SN|SmartTag" : SNSmartTag,
|
||||
"Extension" : SNExtension,
|
||||
"SN|Editor" : SNEditor,
|
||||
"SN|Theme" : SNTheme,
|
||||
"SN|Component" : SNComponent,
|
||||
"SF|Extension" : SNServerExtension,
|
||||
"SF|MFA" : SNMfa,
|
||||
"SN|Privileges" : SFPrivileges
|
||||
};
|
||||
import { SFModelManager, SNSmartTag, SFPredicate } from 'snjs';
|
||||
|
||||
export class ModelManager extends SFModelManager {
|
||||
/* @ngInject */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { isDesktopApplication } from '@/utils';
|
||||
import { StorageManager } from './storageManager';
|
||||
import { cryptoManager } from 'snjs';
|
||||
import { protocolManager } from 'snjs';
|
||||
|
||||
const MillisecondsPerSecond = 1000;
|
||||
|
||||
@@ -88,7 +88,7 @@ export class PasscodeManager {
|
||||
async verifyPasscode(passcode) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
var params = this.passcodeAuthParams();
|
||||
let keys = await cryptoManager.computeEncryptionKeysForUser(passcode, params);
|
||||
let keys = await protocolManager.computeEncryptionKeysForUser(passcode, params);
|
||||
if(keys.pw !== params.hash) {
|
||||
resolve(false);
|
||||
} else {
|
||||
@@ -99,7 +99,7 @@ export class PasscodeManager {
|
||||
|
||||
unlock(passcode, callback) {
|
||||
var params = this.passcodeAuthParams();
|
||||
cryptoManager.computeEncryptionKeysForUser(passcode, params).then((keys) => {
|
||||
protocolManager.computeEncryptionKeysForUser(passcode, params).then((keys) => {
|
||||
if(keys.pw !== params.hash) {
|
||||
callback(false);
|
||||
return;
|
||||
@@ -115,9 +115,9 @@ export class PasscodeManager {
|
||||
}
|
||||
|
||||
setPasscode(passcode, callback) {
|
||||
var uuid = cryptoManager.crypto.generateUUIDSync();
|
||||
var uuid = protocolManager.crypto.generateUUIDSync();
|
||||
|
||||
cryptoManager.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => {
|
||||
protocolManager.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => {
|
||||
let keys = results.keys;
|
||||
let authParams = results.authParams;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cryptoManager, SNEncryptedStorage, SFStorageManager , SFItemParams } from 'snjs';
|
||||
import { protocolManager, SNEncryptedStorage, SFStorageManager , SFItemParams } from 'snjs';
|
||||
|
||||
export class MemoryStorage {
|
||||
constructor() {
|
||||
@@ -170,7 +170,7 @@ export class StorageManager extends SFStorageManager {
|
||||
|
||||
async decryptStorage() {
|
||||
var stored = JSON.parse(this.getItemSync("encryptedStorage", StorageManager.Fixed));
|
||||
await cryptoManager.decryptItem(stored, this.encryptedStorageKeys);
|
||||
await protocolManager.decryptItem(stored, this.encryptedStorageKeys);
|
||||
var encryptedStorage = new SNEncryptedStorage(stored);
|
||||
|
||||
for(var key of Object.keys(encryptedStorage.content.storage)) {
|
||||
|
||||
Reference in New Issue
Block a user