Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Check that browserpass isn't using a copy action before using the clipboard #6

Merged
merged 3 commits into from
Apr 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ chrome.runtime.onMessageExternal.addListener(function(request, sender) {
return;
}

// hydrate request
if (!request.hasOwnProperty("version")) {
// REMOVE this block once browserpass-extension-3.1 is fully deployed in prod.
request.version = "3.0.12";
request.action = "noop";
}
request.version = (version => {
var [major, minor, patch] = version.split(".");
return parseInt(major) * 1000000 + parseInt(minor) * 1000 + parseInt(patch);
})(request.version);

// parse OTP object
if (request.otp.key === null) {
// this is an OTP URI, so extract the pieces
Expand Down Expand Up @@ -57,8 +68,10 @@ chrome.runtime.onMessageExternal.addListener(function(request, sender) {
console.log(`Unsupported OTP type: ${otp.type}`);
}

// generate code
copyToClipboard(otp.generate());
// copy to clipboard
if (!request.action.match(/^copy[A-Z]*/)) {
copyToClipboard(otp.generate());
}
});

/**
Expand Down