Encryptor for app builders
How the Encryptor extension is built: popup, background service worker, storage and permissions.
Encryptor is a Manifest V3 Chrome extension built with Vue 3, Vite and TypeScript. Key handling uses the ethers library (v6).
Parts
Popup (popup.html, Vue pages)
The UI: Welcome, Create, Seeds, Restore, Unlock, Main, Loading. It asks the background for state and sends commands
Background service worker (src/background/index.ts)
Holds the unlocked key in memory, stores the encrypted key, answers apps, emits events
Local storage (chrome.storage.local)
The encrypted key (encryptedWallet)
Figure: Data flow between a web app, the background worker, the popup and the stored key.
Messages
Popup to background (internal): create, unlock, restore, get key object, lock, get state.
Web page to background (external): only these four actions are accepted. Anything else returns "Requested action is not allowed."
getAppVersion
The extension version
getEncryptorState
not-generated, locked or unlocked
getPublicKey
The public key (nothing while locked)
computeSharedSecretKey
A shared secret for a public key you pass (nothing while locked)
Background to page (events), posted to the active tab as window.postMessage:
emitHeartbeat, once at worker start and every 30 seconds.emitEncryptorStateChange, with the new state, after create, unlock, restore or lock.
State logic
The background reports unlocked if the key is in memory. Otherwise it reports locked if an encrypted key exists, or not-generated if there is no stored key.
Permissions
storage
Saves the encrypted key
scripting
chrome.scripting.executeScript posts events into the active tab
activeTab
Added in 0.0.6 (11 Apr 2024)
See Security notes and the integration API.
Last updated
