Transition from SFJS to SNJS

This commit is contained in:
Mo Bitar 2019-12-13 12:11:19 -06:00
parent 010d2793b1
commit 68fbd745d5
No known key found for this signature in database
GPG Key ID: C9EAD0759817F96F
19 changed files with 14142 additions and 28698 deletions

View File

@ -71,7 +71,6 @@ module.exports = function(grunt) {
},
app: {
src: [
'node_modules/snjs/dist/snjs.js',
'app/assets/javascripts/app/*.js',
'app/assets/javascripts/app/models/**/*.js',
'app/assets/javascripts/app/controllers/**/*.js',
@ -84,8 +83,8 @@ module.exports = function(grunt) {
lib: {
src: [
'node_modules/standard-file-js/dist/regenerator.js',
'node_modules/standard-file-js/dist/sfjs.js',
'node_modules/snjs/dist/regenerator.js',
'node_modules/snjs/dist/snjs.js',
'node_modules/sn-stylekit/dist/stylekit.js',
'node_modules/angular/angular.js',
'vendor/assets/javascripts/angular-sanitize.js',

View File

@ -308,9 +308,9 @@ class AccountMenu {
}
if(data.auth_params) {
SFJS.crypto.computeEncryptionKeysForUser(password, data.auth_params).then((keys) => {
SNJS.crypto.computeEncryptionKeysForUser(password, data.auth_params).then((keys) => {
try {
SFJS.itemTransformer.decryptMultipleItems(data.items, keys, false) /* throws = false as we don't want to interrupt all decryption if just one fails */
SNJS.itemTransformer.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){

View File

@ -211,7 +211,7 @@ class PasswordWizard {
// Ensure value for current password matches what's saved
let authParams = await authManager.getAuthParams();
let password = $scope.formData.currentPassword;
SFJS.crypto.computeEncryptionKeysForUser(password, authParams).then(async (keys) => {
SNJS.crypto.computeEncryptionKeysForUser(password, authParams).then(async (keys) => {
let success = keys.mk === (await authManager.keys()).mk;
if(success) {
this.currentServerPw = keys.pw;
@ -239,7 +239,7 @@ class PasswordWizard {
let currentServerPw = this.currentServerPw;
let results = await SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
let results = await SNJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
let newKeys = results.keys;
let newAuthParams = results.authParams;

View File

@ -32,7 +32,7 @@ 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 = SFJS.crypto.generateUUIDSync();
$scope.note.uuid = SNJS.crypto.generateUUIDSync();
if(editorForNote) {
// Create temporary copy, as a lot of componentManager is uuid based,

View File

@ -71,7 +71,7 @@ class ActionsManager {
let handleResponseDecryption = async (response, keys, merge) => {
var item = response.item;
await SFJS.itemTransformer.decryptItem(item, keys);
await SNJS.itemTransformer.decryptItem(item, keys);
if(!item.errorDecrypting) {
if(merge) {
@ -101,7 +101,7 @@ class ActionsManager {
}
triedPasswords.push(passwordCandidate);
var keyResults = await SFJS.crypto.computeEncryptionKeysForUser(passwordCandidate, response.auth_params);
var keyResults = await SNJS.crypto.computeEncryptionKeysForUser(passwordCandidate, response.auth_params);
if(!keyResults) {
continue;
}

View File

@ -17,7 +17,7 @@ class ArchiveManager {
async downloadBackupOfItems(items, encrypted) {
let run = async () => {
// download in Standard File format
// download in Standard Notes format
var keys, authParams;
if(encrypted) {
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {

View File

@ -99,7 +99,7 @@ class AuthManager extends SFAuthManager {
async verifyAccountPassword(password) {
let authParams = await this.getAuthParams();
let keys = await SFJS.crypto.computeEncryptionKeysForUser(password, authParams);
let keys = await SNJS.crypto.computeEncryptionKeysForUser(password, authParams);
let success = keys.mk === (await this.keys()).mk;
return success;
}
@ -109,7 +109,7 @@ class AuthManager extends SFAuthManager {
return false;
}
let latest = SFJS.version();
let latest = SNJS.version();
let updateAvailable = await this.protocolVersion() !== latest;
if(updateAvailable !== this.securityUpdateAvailable) {
this.securityUpdateAvailable = updateAvailable;

View File

@ -83,7 +83,7 @@ class PasscodeManager {
async verifyPasscode(passcode) {
return new Promise(async (resolve, reject) => {
var params = this.passcodeAuthParams();
let keys = await SFJS.crypto.computeEncryptionKeysForUser(passcode, params);
let keys = await SNJS.crypto.computeEncryptionKeysForUser(passcode, params);
if(keys.pw !== params.hash) {
resolve(false);
} else {
@ -94,7 +94,7 @@ class PasscodeManager {
unlock(passcode, callback) {
var params = this.passcodeAuthParams();
SFJS.crypto.computeEncryptionKeysForUser(passcode, params).then((keys) => {
SNJS.crypto.computeEncryptionKeysForUser(passcode, params).then((keys) => {
if(keys.pw !== params.hash) {
callback(false);
return;
@ -110,9 +110,9 @@ class PasscodeManager {
}
setPasscode(passcode, callback) {
var uuid = SFJS.crypto.generateUUIDSync();
var uuid = SNJS.crypto.generateUUIDSync();
SFJS.crypto.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => {
SNJS.crypto.generateInitialKeysAndAuthParamsForUser(uuid, passcode).then((results) => {
let keys = results.keys;
let authParams = results.authParams;

View File

@ -168,7 +168,7 @@ class StorageManager extends SFStorageManager {
async decryptStorage() {
var stored = JSON.parse(this.getItemSync("encryptedStorage", StorageManager.Fixed));
await SFJS.itemTransformer.decryptItem(stored, this.encryptedStorageKeys);
await SNJS.itemTransformer.decryptItem(stored, this.encryptedStorageKeys);
var encryptedStorage = new SNEncryptedStorage(stored);
for(var key of Object.keys(encryptedStorage.content.storage)) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2140
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,11 @@
"test": "karma start karma.conf.js --single-run"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/runtime": "^7.6.3",
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",
"@babel/runtime": "^7.7.6",
"angular": "1.7.9",
"babel-plugin-angularjs-annotate": "^0.10.0",
"chai": "^4.2.0",
@ -39,7 +39,6 @@
"mocha": "^6.2.2",
"serve-static": "^1.14.1",
"sn-stylekit": "2.0.19",
"snjs": "0.2.9",
"standard-file-js": "0.3.71"
"snjs": "1.0.0"
}
}

View File

@ -4,14 +4,14 @@ import '../vendor/chai-as-promised-built.js';
import '../../../vendor/assets/javascripts/lodash/lodash.custom.js';
import LocalStorageManager from './localStorageManager.js';
const sf_default = new StandardFile();
const sf_default = new StandardNotes();
SFItem.AppDomain = "org.standardnotes.sn";
var _globalStorageManager = null;
var _globalHttpManager = null;
var _globalAuthManager = null;
var _globalModelManager = null;
var _globalStandardFile = null;
var _globalStandardNotes = null;
export default class Factory {
@ -47,9 +47,9 @@ export default class Factory {
return _globalModelManager;
}
static globalStandardFile() {
if(_globalStandardFile == null) { _globalStandardFile = new StandardFile(); }
return _globalStandardFile;
static globalStandardNotes() {
if(_globalStandardNotes == null) { _globalStandardNotes = new StandardNotes(); }
return _globalStandardNotes;
}
static createModelManager() {
@ -62,7 +62,7 @@ export default class Factory {
static createItemParams() {
var params = {
uuid: SFJS.crypto.generateUUIDSync(),
uuid: SNJS.crypto.generateUUIDSync(),
content_type: "Note",
content: {
title: "hello",

View File

@ -9,7 +9,7 @@ var expect = chai.expect;
const getNoteParams = () => {
var params = {
uuid: SFJS.crypto.generateUUIDSync(),
uuid: SNJS.crypto.generateUUIDSync(),
content_type: "Note",
content: {
title: "hello",
@ -22,7 +22,7 @@ const getNoteParams = () => {
const createRelatedNoteTagPair = () => {
let noteParams = getNoteParams();
let tagParams = {
uuid: SFJS.crypto.generateUUIDSync(),
uuid: SNJS.crypto.generateUUIDSync(),
content_type: "Tag",
content: {
title: "thoughts",
@ -441,8 +441,8 @@ describe("syncing", () => {
var totalItemCount = 0;
beforeEach((done) => {
var email = Factory.globalStandardFile().crypto.generateUUIDSync();
var password = Factory.globalStandardFile().crypto.generateUUIDSync();
var email = Factory.globalStandardNotes().crypto.generateUUIDSync();
var password = Factory.globalStandardNotes().crypto.generateUUIDSync();
Factory.globalStorageManager().clearAllData().then(() => {
Factory.newRegisteredUser(email, password).then((user) => {
done();

View File

@ -2,7 +2,7 @@
var connect = require('connect');
var serveStatic = require('serve-static');
var port = 7000;
var port = 9002;
connect().use(serveStatic(__dirname)).listen(port, function(){
console.log(`Server running on ${port}...`);
});