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

Commit

Permalink
0.1.7-alpha1 (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf authored Feb 23, 2018
1 parent 709ce91 commit fecb7b8
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 25 deletions.
17 changes: 17 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Lockbox Release Notes

## 0.1.7-alpha1

_Dtae: 2018-02-23_

This release is to address a critical defect from the previous release.

### What's Fixed

* If you linked your Firefox Account, Lockbox would stop working when you restart Firefox ([#568](https://github.com/mozilla-lockbox/lockbox-extension/issues/568))

* 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.
* Once you link a Firefox Account to Lockbox, you cannot unlink it from that account.
* Once you link a Firefox Account to Lockbox, signing in with a different account can render Lockbox unusable until you quit and restart Firefox.
* 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.
* 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.


## 0.1.7-alpha

_Date: 2018-02-22_
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Lockbox",
"name": "lockbox",
"id": "lockbox@mozilla.com",
"version": "0.1.7-alpha",
"version": "0.1.7-alpha1",
"main": "dist/bootstrap.js",
"description": "The simple way to store, retrieve and manage website login info",
"author": "Lockbox Team <lockbox-dev@mozilla.com>",
Expand Down
10 changes: 8 additions & 2 deletions src/webextension/background/accounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ export class Account {
let account;
export default function getAccount() {
if (!account) {
// eslint-disable-next-line no-console
console.warn("creating a default un-stored account instance!");
account = new Account({});
}
return account;
Expand All @@ -336,6 +338,10 @@ export async function loadAccount(storage) {
...stored.account,
storage,
});
} else {
account = new Account({
storage,
});
}
return getAccount();
}
Expand All @@ -350,8 +356,8 @@ export async function openAccount(storage) {
console.log(`loaded account for (${account.mode.toString()}) '${account.uid || ""}'`);
} catch (err) {
// eslint-disable-next-line no-console
console.error(`loading account failed (fallback to empty GUEST): ${err.message}`);
account = getAccount();
console.error(`loading account failed: ${err.message}`);
throw err;
}

return account;
Expand Down
9 changes: 7 additions & 2 deletions src/webextension/background/browser-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ export default async function updateBrowserAction({account = getAccount(), datas
if (account.mode === accounts.GUEST) {
// unlock on user's behalf ...
// XXXX: is this a bad idea or terrible idea?
await datastore.unlock(DEFAULT_APP_KEY);
return installEntriesAction();
try {
await datastore.unlock(DEFAULT_APP_KEY);
return installEntriesAction();
} catch (err) {
// eslint-disable-next-line no-console
console.log(`WARNING: datastore is in an inconsistent state. You may need to reset and start again`);
}
}
// setup unlock popup
return installPopup("unlock/index.html");
Expand Down
4 changes: 4 additions & 0 deletions src/webextension/background/datastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const DEFAULT_APP_KEY = {
"k": "WsTdZ2tjji2W36JN9vk9s2AYsvp8eYy1pBbKPgcSLL4",
};

export function clearDataStore() {
datastore = undefined;
}

export default async function openDataStore(cfg = {}) {
if (!datastore) {
datastore = await DataStore.open({
Expand Down
7 changes: 6 additions & 1 deletion src/webextension/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import updateBrowserAction from "./browser-action";
openAccount(browser.storage.local).then(async (account) => {
let datastore = await openDataStore({ salt: account.uid });
if (datastore.initialized && account.mode === GUEST) {
await datastore.unlock(DEFAULT_APP_KEY);
try {
await datastore.unlock(DEFAULT_APP_KEY);
} catch (err) {
// eslint-disable-next-line no-console
console.log(`WARNING: datastore is in an inconsistent state.`);
}
}

initializeMessagePorts();
Expand Down
22 changes: 15 additions & 7 deletions src/webextension/background/message-ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import openDataStore, { DEFAULT_APP_KEY } from "./datastore";
import openDataStore, { clearDataStore, DEFAULT_APP_KEY } from "./datastore";
import getAccount, * as accounts from "./accounts";
import updateBrowserAction from "./browser-action";
import * as telemetry from "./telemetry";
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function initializeMessagePorts() {
await updateBrowserAction({ account, datastore });
telemetry.recordEvent("fxaUpgrade", "accounts");
} catch (err) {
telemetry.recordEvent("fxaFailed", "accounts", err.message);
telemetry.recordEvent("fxaFailed", "accounts", { message: err.message });
throw err;
}

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

return {};
}).catch((err) => {
// eslint-disable-next-line no-console
console.log(`failed to reset: ${err.message}`);
throw err;
});


case "signin":
return openDataStore().then(async (datastore) => {
const account = getAccount();
let appKey;
return Promise.resolve(getAccount()).then(async (account) => {
let appKey = DEFAULT_APP_KEY;
try {
if (account.mode === accounts.UNAUTHENTICATED) {
if (account.mode !== accounts.AUTHENTICATED) {
await account.signIn();
}
if (account.mode === accounts.AUTHENTICATED) {
appKey = account.keys.get(accounts.APP_KEY_NAME);
}

// XXXX: Find a better way to affect recovery
clearDataStore();
const datastore = await openDataStore({ salt: account.uid });

await datastore.unlock(appKey);
await updateBrowserAction({ datastore });
telemetry.recordEvent("fxaSignin", "accounts");
} catch (err) {
telemetry.recordEvent("fxaFailed", "accounts", err.message);
telemetry.recordEvent("fxaFailed", "accounts", { message: err.message });
throw err;
}

Expand Down
36 changes: 25 additions & 11 deletions test/unit/background/accounts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("background > accounts", () => {

describe("loadAccount()", () => {
it("with saved account", async () => {
const result = await accounts.loadAccount({
const mockStorage = {
get: async () => ({
account: {
config: "dev-latest",
Expand All @@ -38,21 +38,25 @@ describe("background > accounts", () => {
},
},
}),
});
};
const result = await accounts.loadAccount(mockStorage);
expect(result.info).to.deep.equal({verified: true, uid: "1234"});
expect(result.storage).to.equal(mockStorage);
});

it("without saved account", async () => {
const result = await accounts.loadAccount({
const mockStorage = {
get: async () => ({}),
});
};
const result = await accounts.loadAccount(mockStorage);
expect(result.info).to.equal(undefined);
expect(result.storage).to.equal(mockStorage);
});
});

describe("openAccount()", () => {
it("with saved account", async () => {
const result = await accounts.openAccount({
const mockStorage = {
get: async () => ({
account: {
config: "dev-latest",
Expand All @@ -62,24 +66,34 @@ describe("background > accounts", () => {
},
},
}),
});
};
const result = await accounts.openAccount(mockStorage);
expect(result.info).to.deep.equal({ verified: true, uid: "1234" });
expect(result.storage).to.equal(mockStorage);
});

it("without saved account", async () => {
const result = await accounts.openAccount({
const mockStorage = {
get: async () => ({}),
});
};
const result = await accounts.openAccount(mockStorage);
expect(result.info).to.equal(undefined);
expect(result.storage).to.equal(mockStorage);
});

it("with error", async () => {
const result = await accounts.openAccount({
const mockStorage = {
get: async () => {
throw new Error("test for failure");
},
});
expect(result.info).to.equal(undefined);
};

try {
await accounts.openAccount(mockStorage);
expect(false, "unexpected success").to.be.ok;
} catch (err) {
expect(err.message).to.equal("test for failure");
}
});
});

Expand Down

0 comments on commit fecb7b8

Please sign in to comment.