This is an example Metamask Snap that allows the user to manage their passwords for websites and store them securely in Metamask.
Example.mov
This Snap uses the entropy for Garlicoin to encrypt the user's passwords. It requests the following permissions:
"initialPermissions": {
"snap_confirm": {},
"snap_manageState": {},
"snap_getBip44Entropy_69420": {}
},
* 69420 is the chain ID for Garlicoin.
It then uses @MetaMask/browser-passworder to encrypt the full state with the encryption key being the Bip44 entropy derived by MetaMask.
import * as passworder from '@metamask/browser-passworder';
const entropy = await wallet.request({
method: 'snap_getBip44Entropy_69420',
});
const newState = {
[website]: { username, password },
};
const encryptedState = {
passwords: await passworder.encrypt(entropy.key, newState),
};
wallet.request({
method: 'snap_manageState',
params: ['update', encryptedState],
});
It also has some extra features like using async-mutex for async-safe state management and fuzzy searching for retrieving specific passwords. Follow the steps below to run this snap locally and see how it works.
yarn install
yarn build
yarn serve
Run yarn test
to run the tests once.
Run yarn lint
to run the linter, or run yarn lint:fix
to run the linter and fix any automatically fixable issues.