From 573734e6af28d26094125a3b541572a14f49132b Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Fri, 19 Feb 2021 11:06:09 +0100 Subject: [PATCH 1/9] chore(version): 3.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c935ecb0..25a958730 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-notes-web", - "version": "3.5.19", + "version": "3.6.0", "license": "AGPL-3.0-or-later", "repository": { "type": "git", From 4d30d019ee52aed511e0f23785ee27b27c9838ee Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Fri, 19 Feb 2021 12:19:31 +0100 Subject: [PATCH 2/9] feat: enable sessions management for every build --- app/assets/javascripts/directives/views/accountMenu.ts | 4 +--- app/assets/templates/directives/account-menu.pug | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/assets/javascripts/directives/views/accountMenu.ts b/app/assets/javascripts/directives/views/accountMenu.ts index 82fc6cdca..6012d5fbe 100644 --- a/app/assets/javascripts/directives/views/accountMenu.ts +++ b/app/assets/javascripts/directives/views/accountMenu.ts @@ -148,9 +148,7 @@ class AccountMenuCtrl extends PureViewCtrl { async $onInit() { super.$onInit(); this.setState({ - showSessions: - this.appState.enableUnfinishedFeatures && - (await this.application.userCanManageSessions()), + showSessions: await this.application.userCanManageSessions() }); const sync = this.appState.sync; diff --git a/app/assets/templates/directives/account-menu.pug b/app/assets/templates/directives/account-menu.pug index f5dbf61e2..e56af6939 100644 --- a/app/assets/templates/directives/account-menu.pug +++ b/app/assets/templates/directives/account-menu.pug @@ -156,7 +156,6 @@ ) Change Password a.sk-a.info.sk-panel-row.condensed( ng-click="self.openSessionsModal()" - ng-if="self.state.showSessions" ) Manage Sessions .sk-panel-section .sk-panel-section-title Encryption From ed7f093e02c3e69a889651c5967fde080ca609a6 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Mon, 22 Feb 2021 11:38:35 +0100 Subject: [PATCH 3/9] feat: make "Protected" flag more subtle --- app/assets/javascripts/views/notes/notes-view.pug | 4 +++- app/assets/javascripts/views/notes/notes_view.ts | 6 ------ app/assets/stylesheets/_notes.scss | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/views/notes/notes-view.pug b/app/assets/javascripts/views/notes/notes-view.pug index 6271ce2b8..599faaea0 100644 --- a/app/assets/javascripts/views/notes/notes-view.pug +++ b/app/assets/javascripts/views/notes/notes-view.pug @@ -143,7 +143,9 @@ .default-preview( ng-show='!note.preview_html && !note.preview_plain' ) {{note.text}} - .date.faded(ng-show='!self.state.hideDate') + .bottom-info.faded(ng-show='!self.state.hideDate || note.protected') + span(ng-if="note.protected") + | Protected •{{self.state.hideDate ? '' : ' '}} span(ng-show="self.state.sortBy == 'userModifiedDate'") | Modified {{note.updatedAtString || 'Now'}} span(ng-show="self.state.sortBy != 'userModifiedDate'") diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index 154a5f7f6..3bd631cf6 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -576,12 +576,6 @@ class NotesViewCtrl extends PureViewCtrl { class: 'warning' }); } - if (note.protected) { - flags.push({ - text: "Protected", - class: 'success' - }); - } if (note.locked) { flags.push({ text: "Locked", diff --git a/app/assets/stylesheets/_notes.scss b/app/assets/stylesheets/_notes.scss index 794255703..fa7d78c10 100644 --- a/app/assets/stylesheets/_notes.scss +++ b/app/assets/stylesheets/_notes.scss @@ -126,7 +126,7 @@ text-overflow: ellipsis; } - > .date { + > .bottom-info { font-size: 12px; margin-top: 4px; } From 944d5db9b749a955d3f762936635c05515ab5d51 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Mon, 22 Feb 2021 12:01:29 +0100 Subject: [PATCH 4/9] fix: only match protected note title --- .../javascripts/views/notes/note_utils.ts | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/views/notes/note_utils.ts b/app/assets/javascripts/views/notes/note_utils.ts index 7ddb91a73..6f8265982 100644 --- a/app/assets/javascripts/views/notes/note_utils.ts +++ b/app/assets/javascripts/views/notes/note_utils.ts @@ -5,44 +5,54 @@ export function notePassesFilter( showArchived: boolean, hidePinned: boolean, filterText: string -) { - +): boolean { const canShowArchived = showArchived; const canShowPinned = !hidePinned; - if ( - (note.archived && !canShowArchived) || - (note.pinned && !canShowPinned) - ) { + if ((note.archived && !canShowArchived) || (note.pinned && !canShowPinned)) { return false; } - return noteMatchesQuery(note, filterText); + if (note.protected) { + const match = noteMatchesQuery(note, filterText); + /** Only match title to prevent leaking protected note text */ + return match === Match.Title || match === Match.TitleAndText; + } else { + return noteMatchesQuery(note, filterText) !== Match.None; + } } -function noteMatchesQuery( - note: SNNote, - query: string -) { +enum Match { + None = 0, + Title = 1, + Text = 2, + TitleAndText = Title + Text, + Uuid = 5, +} + +function noteMatchesQuery(note: SNNote, query: string): Match { if (query.length === 0) { - return true; + return Match.TitleAndText; } const title = note.safeTitle().toLowerCase(); const text = note.safeText().toLowerCase(); const lowercaseText = query.toLowerCase(); + const words = lowercaseText.split(' '); const quotedText = stringBetweenQuotes(lowercaseText); if (quotedText) { - return title.includes(quotedText) || text.includes(quotedText); + return ( + (title.includes(quotedText) ? Match.Title : Match.None) + + (text.includes(quotedText) ? Match.Text : Match.None) + ); } if (stringIsUuid(lowercaseText)) { - return note.uuid === lowercaseText; + return note.uuid === lowercaseText ? Match.Uuid : Match.None; } - const words = lowercaseText.split(" "); const matchesTitle = words.every((word) => { return title.indexOf(word) >= 0; }); const matchesBody = words.every((word) => { return text.indexOf(word) >= 0; }); - return matchesTitle || matchesBody; + return (matchesTitle ? Match.Title : 0) + (matchesBody ? Match.Text : 0); } function stringBetweenQuotes(text: string) { From 6a3e070ea67ac339bbcaa685a18991a81ceda496 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Mon, 22 Feb 2021 17:41:45 +0100 Subject: [PATCH 5/9] fix: remove inconsistencies between protected note label and date --- app/assets/javascripts/views/notes/notes-view.pug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/views/notes/notes-view.pug b/app/assets/javascripts/views/notes/notes-view.pug index 599faaea0..a42e16bc1 100644 --- a/app/assets/javascripts/views/notes/notes-view.pug +++ b/app/assets/javascripts/views/notes/notes-view.pug @@ -145,10 +145,10 @@ ) {{note.text}} .bottom-info.faded(ng-show='!self.state.hideDate || note.protected') span(ng-if="note.protected") - | Protected •{{self.state.hideDate ? '' : ' '}} - span(ng-show="self.state.sortBy == 'userModifiedDate'") + | Protected{{self.state.hideDate ? '' : ' • '}} + span(ng-show="!self.state.hideDate && self.state.sortBy == 'userModifiedDate'") | Modified {{note.updatedAtString || 'Now'}} - span(ng-show="self.state.sortBy != 'userModifiedDate'") + span(ng-show="!self.state.hideDate && self.state.sortBy != 'userModifiedDate'") | {{note.createdAtString || 'Now'}} .tags-string(ng-if='!self.state.hideTags && self.state.renderedNotesTags[$index]') .faded {{self.state.renderedNotesTags[$index]}} From ef3a962d788c4d1c375ed0fee28ce92da5a914de Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Mon, 22 Feb 2021 17:51:45 +0100 Subject: [PATCH 6/9] feat: show warning when protecting a note with no protection source --- app/assets/javascripts/strings.ts | 2 ++ .../javascripts/views/editor/editor_view.ts | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index c8782ae29..25232bc9c 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -124,4 +124,6 @@ export const Strings = { : 'password manager'; return `Your keys are currently stored in your operating system's ${keychainName}. Adding a passcode prevents even your operating system from reading them.`; }, + protectingNoteWithoutProtectionSources: 'Access to this note will not be restricted until you set up a passcode or account.', + openAccountMenu: 'Open Account Menu' }; diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index c0f67f836..5fca2e50e 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -1,4 +1,4 @@ -import { STRING_ARCHIVE_LOCKED_ATTEMPT, STRING_SAVING_WHILE_DOCUMENT_HIDDEN, STRING_UNARCHIVE_LOCKED_ATTEMPT } from './../../strings'; +import { Strings, STRING_ARCHIVE_LOCKED_ATTEMPT, STRING_SAVING_WHILE_DOCUMENT_HIDDEN, STRING_UNARCHIVE_LOCKED_ATTEMPT } from './../../strings'; import { Editor } from '@/ui_models/editor'; import { WebApplication } from '@/ui_models/application'; import { PanelPuppet, WebDirective } from '@/types'; @@ -713,15 +713,23 @@ class EditorViewCtrl extends PureViewCtrl { ); } - toggleProtectNote() { - this.saveNote( - true, - false, - true, + async toggleProtectNote() { + const note = await this.application.changeAndSaveItem( + this.note.uuid, (mutator) => { mutator.protected = !this.note.protected; - } + }, + false ); + if (note?.protected && !this.application.hasProtectionSources()) { + if (await confirmDialog({ + text: Strings.protectingNoteWithoutProtectionSources, + confirmButtonText: Strings.openAccountMenu, + confirmButtonStyle: 'info', + })) { + this.appState.accountMenu.setShow(true); + } + } } toggleNotePreview() { From a3f73ba6645372a1be6628aa5c23e2d8c4d00534 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Tue, 23 Feb 2021 10:40:08 +0100 Subject: [PATCH 7/9] feat: make unprotecting a note a protected action --- .../javascripts/views/editor/editor_view.ts | 26 +++++++++---------- package.json | 2 +- yarn.lock | 8 +++--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 5fca2e50e..f5ed13f1a 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -714,20 +714,18 @@ class EditorViewCtrl extends PureViewCtrl { } async toggleProtectNote() { - const note = await this.application.changeAndSaveItem( - this.note.uuid, - (mutator) => { - mutator.protected = !this.note.protected; - }, - false - ); - if (note?.protected && !this.application.hasProtectionSources()) { - if (await confirmDialog({ - text: Strings.protectingNoteWithoutProtectionSources, - confirmButtonText: Strings.openAccountMenu, - confirmButtonStyle: 'info', - })) { - this.appState.accountMenu.setShow(true); + if (this.note.protected) { + void this.application.unprotectNote(this.note); + } else { + const note = await this.application.protectNote(this.note); + if (note?.protected && !this.application.hasProtectionSources()) { + if (await confirmDialog({ + text: Strings.protectingNoteWithoutProtectionSources, + confirmButtonText: Strings.openAccountMenu, + confirmButtonStyle: 'info', + })) { + this.appState.accountMenu.setShow(true); + } } } } diff --git a/package.json b/package.json index 25a958730..5537d4f98 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@reach/alert-dialog": "^0.13.0", "@reach/dialog": "^0.13.0", "@standardnotes/sncrypto-web": "^1.2.10", - "@standardnotes/snjs": "^2.0.57", + "@standardnotes/snjs": "^2.0.58", "mobx": "^6.1.6", "preact": "^10.5.12" } diff --git a/yarn.lock b/yarn.lock index c5287e1bd..21cf08f3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1845,10 +1845,10 @@ "@standardnotes/sncrypto-common" "^1.2.7" libsodium-wrappers "^0.7.8" -"@standardnotes/snjs@^2.0.57": - version "2.0.57" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.57.tgz#758d30d9074aa463ca2b642783d929a10a1a1c9f" - integrity sha512-s2FP024TziZnt0nJ10Tbja3IQ2KOITA67EGchadAN+vapXEicTDX2MSCPzlvk2D1M494zu15vWwQX1ryeHvHHA== +"@standardnotes/snjs@^2.0.58": + version "2.0.58" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.58.tgz#b3cc340699effd9ab2b55e48eb84745f71e058cb" + integrity sha512-eJnCpwTpI55RM916xjdgcGdzIcgaGJQ5EeykKvLxD4Oy7FRPfQnZc5hCp4LbeZvdlQQze+E2gH1nY77zPDsVXw== dependencies: "@standardnotes/sncrypto-common" "^1.2.9" From c94bc0edee2da752a1a2c41c80109d8d87969e40 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Thu, 25 Feb 2021 14:43:44 +0100 Subject: [PATCH 8/9] chore(deps): upgrade snjs --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5537d4f98..345e1b57f 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@reach/alert-dialog": "^0.13.0", "@reach/dialog": "^0.13.0", "@standardnotes/sncrypto-web": "^1.2.10", - "@standardnotes/snjs": "^2.0.58", + "@standardnotes/snjs": "^2.0.60", "mobx": "^6.1.6", "preact": "^10.5.12" } diff --git a/yarn.lock b/yarn.lock index 21cf08f3b..e308b8829 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1845,10 +1845,10 @@ "@standardnotes/sncrypto-common" "^1.2.7" libsodium-wrappers "^0.7.8" -"@standardnotes/snjs@^2.0.58": - version "2.0.58" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.58.tgz#b3cc340699effd9ab2b55e48eb84745f71e058cb" - integrity sha512-eJnCpwTpI55RM916xjdgcGdzIcgaGJQ5EeykKvLxD4Oy7FRPfQnZc5hCp4LbeZvdlQQze+E2gH1nY77zPDsVXw== +"@standardnotes/snjs@^2.0.60": + version "2.0.60" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.60.tgz#e8f4385a8c30f03658512725a3b2144b487ddfcc" + integrity sha512-y5AZeT1GyTrFnNPFNNI7M7RND5NlM1tsGuyCULCIwrGXEk4h+0dJwNdNRFsTkRuShosbthZV8hW91YdnqNIJFg== dependencies: "@standardnotes/sncrypto-common" "^1.2.9" From 14e2808ac0ecb8c0d1ecb082edc7411d5a1afd47 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Thu, 25 Feb 2021 17:14:25 +0100 Subject: [PATCH 9/9] chore(version): 3.6.0-beta01 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 345e1b57f..be23193eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-notes-web", - "version": "3.6.0", + "version": "3.6.0-beta01", "license": "AGPL-3.0-or-later", "repository": { "type": "git",