Skip to content

Commit 6406b62

Browse files
committed
Revert "no more cookie"
This reverts commit 9c50555.
1 parent 43be56c commit 6406b62

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

manifest-chrome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"background": {
3434
"scripts": [
3535
"dist/background.js"
36-
]
36+
],
37+
"persistent": false
3738
},
3839
"permissions": [
3940
"activeTab",

src/components/Popup/MainHeader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export default Vue.extend({
100100
this.$store.commit("accounts/stopFilter");
101101
},
102102
lock() {
103+
document.cookie = 'passphrase=";expires=Thu, 01 Jan 1970 00:00:00 GMT"';
103104
chrome.runtime.sendMessage({ action: "lock" }, window.close);
104105
return;
105106
},

src/import.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ init();
3232
function getCachedPassphrase() {
3333
return new Promise(
3434
(resolve: (value: string) => void, reject: (reason: Error) => void) => {
35+
const cookie = document.cookie;
36+
const cookieMatch = cookie
37+
? document.cookie.match(/passphrase=([^;]*)/)
38+
: null;
39+
const cachedPassphrase =
40+
cookieMatch && cookieMatch.length > 1 ? cookieMatch[1] : null;
41+
if (cachedPassphrase) {
42+
return resolve(cachedPassphrase);
43+
}
44+
3545
chrome.runtime.sendMessage(
3646
{ action: "passphrase" },
3747
(passphrase: string) => {

src/store/Accounts.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export class Accounts implements IModule {
163163
state.commit("style/hideInfo", null, { root: true });
164164

165165
if (!state.getters.currentlyEncrypted) {
166+
document.cookie = "passphrase=" + password;
166167
chrome.runtime.sendMessage({
167168
action: "cachePassphrase",
168169
value: password
@@ -180,6 +181,7 @@ export class Accounts implements IModule {
180181
);
181182

182183
state.state.encryption.updateEncryptionPassword(password);
184+
document.cookie = "passphrase=" + password;
183185
chrome.runtime.sendMessage({
184186
action: "cachePassphrase",
185187
value: password
@@ -352,6 +354,21 @@ export class Accounts implements IModule {
352354
private getCachedPassphrase() {
353355
return new Promise(
354356
(resolve: (value: string) => void, reject: (reason: Error) => void) => {
357+
const cookie = document.cookie;
358+
const cookieMatch = cookie
359+
? document.cookie.match(/passphrase=([^;]*)/)
360+
: null;
361+
const cachedPassphrase =
362+
cookieMatch && cookieMatch.length > 1 ? cookieMatch[1] : null;
363+
const cachedPassphraseLocalStorage = localStorage.encodedPhrase
364+
? CryptoJS.AES.decrypt(localStorage.encodedPhrase, "").toString(
365+
CryptoJS.enc.Utf8
366+
)
367+
: "";
368+
if (cachedPassphrase || cachedPassphraseLocalStorage) {
369+
return resolve(cachedPassphrase || cachedPassphraseLocalStorage);
370+
}
371+
355372
chrome.runtime.sendMessage(
356373
{ action: "passphrase" },
357374
(passphrase: string) => {

0 commit comments

Comments
 (0)