ritave / snap-passwordManager

An example Metamask Snap that manages user passwords

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Password Manager snap

This is an example Metamask Snap that allows the user to manage their passwords for websites and store them securely in Metamask.

Example.mov

How This Works

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.

Setup

yarn install
yarn build
yarn serve

Testing and Linting

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.

About

An example Metamask Snap that manages user passwords


Languages

Language:HTML 51.3%Language:JavaScript 46.4%Language:Shell 2.3%