Skip to content
This repository was archived by the owner on Feb 7, 2019. It is now read-only.

Commit fecb7b8

Browse files
authored
0.1.7-alpha1 (#574)
1 parent 709ce91 commit fecb7b8

File tree

9 files changed

+84
-25
lines changed

9 files changed

+84
-25
lines changed

docs/release-notes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Lockbox Release Notes
22

3+
## 0.1.7-alpha1
4+
5+
_Dtae: 2018-02-23_
6+
7+
This release is to address a critical defect from the previous release.
8+
9+
### What's Fixed
10+
11+
* If you linked your Firefox Account, Lockbox would stop working when you restart Firefox ([#568](https://github.com/mozilla-lockbox/lockbox-extension/issues/568))
12+
13+
* Profile information about you is only fetched and updated when you sign in; any changes made to your Firefox Accounts display name or avatar will not be displayed in Lockbox until you sign in again.
14+
* Once you link a Firefox Account to Lockbox, you cannot unlink it from that account.
15+
* Once you link a Firefox Account to Lockbox, signing in with a different account can render Lockbox unusable until you quit and restart Firefox.
16+
* Once you link a Firefox Account to Lockbox, resetting your Firefox Account password through "forgot your password" will render all your logins inaccessible; the only recourse is to reset Lockbox and start over.
17+
* Firefox's default prompt to save logins is only disabled on new installs of this extension; updating Lockbox will not change your current Firefox preferences.
18+
19+
320
## 0.1.7-alpha
421

522
_Date: 2018-02-22_

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"title": "Lockbox",
33
"name": "lockbox",
44
"id": "lockbox@mozilla.com",
5-
"version": "0.1.7-alpha",
5+
"version": "0.1.7-alpha1",
66
"main": "dist/bootstrap.js",
77
"description": "The simple way to store, retrieve and manage website login info",
88
"author": "Lockbox Team <lockbox-dev@mozilla.com>",

src/webextension/background/accounts/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ export class Account {
320320
let account;
321321
export default function getAccount() {
322322
if (!account) {
323+
// eslint-disable-next-line no-console
324+
console.warn("creating a default un-stored account instance!");
323325
account = new Account({});
324326
}
325327
return account;
@@ -336,6 +338,10 @@ export async function loadAccount(storage) {
336338
...stored.account,
337339
storage,
338340
});
341+
} else {
342+
account = new Account({
343+
storage,
344+
});
339345
}
340346
return getAccount();
341347
}
@@ -350,8 +356,8 @@ export async function openAccount(storage) {
350356
console.log(`loaded account for (${account.mode.toString()}) '${account.uid || ""}'`);
351357
} catch (err) {
352358
// eslint-disable-next-line no-console
353-
console.error(`loading account failed (fallback to empty GUEST): ${err.message}`);
354-
account = getAccount();
359+
console.error(`loading account failed: ${err.message}`);
360+
throw err;
355361
}
356362

357363
return account;

src/webextension/background/browser-action.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ export default async function updateBrowserAction({account = getAccount(), datas
6060
if (account.mode === accounts.GUEST) {
6161
// unlock on user's behalf ...
6262
// XXXX: is this a bad idea or terrible idea?
63-
await datastore.unlock(DEFAULT_APP_KEY);
64-
return installEntriesAction();
63+
try {
64+
await datastore.unlock(DEFAULT_APP_KEY);
65+
return installEntriesAction();
66+
} catch (err) {
67+
// eslint-disable-next-line no-console
68+
console.log(`WARNING: datastore is in an inconsistent state. You may need to reset and start again`);
69+
}
6570
}
6671
// setup unlock popup
6772
return installPopup("unlock/index.html");

src/webextension/background/datastore.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const DEFAULT_APP_KEY = {
2626
"k": "WsTdZ2tjji2W36JN9vk9s2AYsvp8eYy1pBbKPgcSLL4",
2727
};
2828

29+
export function clearDataStore() {
30+
datastore = undefined;
31+
}
32+
2933
export default async function openDataStore(cfg = {}) {
3034
if (!datastore) {
3135
datastore = await DataStore.open({

src/webextension/background/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import updateBrowserAction from "./browser-action";
1010
openAccount(browser.storage.local).then(async (account) => {
1111
let datastore = await openDataStore({ salt: account.uid });
1212
if (datastore.initialized && account.mode === GUEST) {
13-
await datastore.unlock(DEFAULT_APP_KEY);
13+
try {
14+
await datastore.unlock(DEFAULT_APP_KEY);
15+
} catch (err) {
16+
// eslint-disable-next-line no-console
17+
console.log(`WARNING: datastore is in an inconsistent state.`);
18+
}
1419
}
1520

1621
initializeMessagePorts();

src/webextension/background/message-ports.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import openDataStore, { DEFAULT_APP_KEY } from "./datastore";
5+
import openDataStore, { clearDataStore, DEFAULT_APP_KEY } from "./datastore";
66
import getAccount, * as accounts from "./accounts";
77
import updateBrowserAction from "./browser-action";
88
import * as telemetry from "./telemetry";
@@ -81,7 +81,7 @@ export default function initializeMessagePorts() {
8181
await updateBrowserAction({ account, datastore });
8282
telemetry.recordEvent("fxaUpgrade", "accounts");
8383
} catch (err) {
84-
telemetry.recordEvent("fxaFailed", "accounts", err.message);
84+
telemetry.recordEvent("fxaFailed", "accounts", { message: err.message });
8585
throw err;
8686
}
8787

@@ -107,25 +107,33 @@ export default function initializeMessagePorts() {
107107
openView("firstrun");
108108

109109
return {};
110+
}).catch((err) => {
111+
// eslint-disable-next-line no-console
112+
console.log(`failed to reset: ${err.message}`);
113+
throw err;
110114
});
111115

112116

113117
case "signin":
114-
return openDataStore().then(async (datastore) => {
115-
const account = getAccount();
116-
let appKey;
118+
return Promise.resolve(getAccount()).then(async (account) => {
119+
let appKey = DEFAULT_APP_KEY;
117120
try {
118-
if (account.mode === accounts.UNAUTHENTICATED) {
121+
if (account.mode !== accounts.AUTHENTICATED) {
119122
await account.signIn();
120123
}
121124
if (account.mode === accounts.AUTHENTICATED) {
122125
appKey = account.keys.get(accounts.APP_KEY_NAME);
123126
}
127+
128+
// XXXX: Find a better way to affect recovery
129+
clearDataStore();
130+
const datastore = await openDataStore({ salt: account.uid });
131+
124132
await datastore.unlock(appKey);
125133
await updateBrowserAction({ datastore });
126134
telemetry.recordEvent("fxaSignin", "accounts");
127135
} catch (err) {
128-
telemetry.recordEvent("fxaFailed", "accounts", err.message);
136+
telemetry.recordEvent("fxaFailed", "accounts", { message: err.message });
129137
throw err;
130138
}
131139

test/unit/background/accounts-test.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("background > accounts", () => {
2828

2929
describe("loadAccount()", () => {
3030
it("with saved account", async () => {
31-
const result = await accounts.loadAccount({
31+
const mockStorage = {
3232
get: async () => ({
3333
account: {
3434
config: "dev-latest",
@@ -38,21 +38,25 @@ describe("background > accounts", () => {
3838
},
3939
},
4040
}),
41-
});
41+
};
42+
const result = await accounts.loadAccount(mockStorage);
4243
expect(result.info).to.deep.equal({verified: true, uid: "1234"});
44+
expect(result.storage).to.equal(mockStorage);
4345
});
4446

4547
it("without saved account", async () => {
46-
const result = await accounts.loadAccount({
48+
const mockStorage = {
4749
get: async () => ({}),
48-
});
50+
};
51+
const result = await accounts.loadAccount(mockStorage);
4952
expect(result.info).to.equal(undefined);
53+
expect(result.storage).to.equal(mockStorage);
5054
});
5155
});
5256

5357
describe("openAccount()", () => {
5458
it("with saved account", async () => {
55-
const result = await accounts.openAccount({
59+
const mockStorage = {
5660
get: async () => ({
5761
account: {
5862
config: "dev-latest",
@@ -62,24 +66,34 @@ describe("background > accounts", () => {
6266
},
6367
},
6468
}),
65-
});
69+
};
70+
const result = await accounts.openAccount(mockStorage);
6671
expect(result.info).to.deep.equal({ verified: true, uid: "1234" });
72+
expect(result.storage).to.equal(mockStorage);
6773
});
6874

6975
it("without saved account", async () => {
70-
const result = await accounts.openAccount({
76+
const mockStorage = {
7177
get: async () => ({}),
72-
});
78+
};
79+
const result = await accounts.openAccount(mockStorage);
7380
expect(result.info).to.equal(undefined);
81+
expect(result.storage).to.equal(mockStorage);
7482
});
7583

7684
it("with error", async () => {
77-
const result = await accounts.openAccount({
85+
const mockStorage = {
7886
get: async () => {
7987
throw new Error("test for failure");
8088
},
81-
});
82-
expect(result.info).to.equal(undefined);
89+
};
90+
91+
try {
92+
await accounts.openAccount(mockStorage);
93+
expect(false, "unexpected success").to.be.ok;
94+
} catch (err) {
95+
expect(err.message).to.equal("test for failure");
96+
}
8397
});
8498
});
8599

0 commit comments

Comments
 (0)