|
| 1 | +# VetKey Password Manager with Metadata (Motoko) |
| 2 | + |
| 3 | +[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/vetkeys/password_manager_with_metadata) |
| 4 | + |
| 5 | +Also available in: [Rust](../../../rust/vetkeys/password_manager_with_metadata) |
| 6 | + |
| 7 | +The **VetKey Password Manager** is an example application demonstrating how to use **VetKeys** and **Encrypted Maps** to build a secure, decentralized password manager on the **Internet Computer (IC)**. This application allows users to create password vaults, store encrypted passwords, and share vaults with other users via their **Internet Identity Principal**. |
| 8 | + |
| 9 | +This version extends the basic password manager by supporting unencrypted metadata, such as URLs and tags, alongside encrypted passwords. The goal is to demonstrate how to make atomic updates to the Encrypted Maps canister, storing both encrypted and unencrypted data in a single update call. |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- **Secure Password Storage**: Uses VetKey to encrypt passwords before storing them in Encrypted Maps. |
| 14 | +- **Vault-Based Organization**: Users can create multiple vaults, each containing multiple passwords. |
| 15 | +- **Access Control**: Vaults can be shared with other users via their **Internet Identity Principal**. |
| 16 | +- **Atomic Updates**: Stores encrypted passwords along with unencrypted metadata in a single update call. |
| 17 | + |
| 18 | +## Build and deploy from the command line |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | + |
| 22 | +- Install [Node.js](https://nodejs.org/en/download/) |
| 23 | +- Install [icp-cli](https://cli.internetcomputer.org): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` |
| 24 | +- Install [ic-mops](https://mops.one): `npm install -g ic-mops` |
| 25 | + |
| 26 | +### (Optionally) choose a different master key |
| 27 | + |
| 28 | +This example uses `test_key_1` by default. To use a different [available master key](https://docs.internetcomputer.org/concepts/vetkeys/#api-overview), change the `init_args` value in `icp.yaml` before deploying. |
| 29 | + |
| 30 | +### Install |
| 31 | + |
| 32 | +```bash |
| 33 | +git clone https://github.com/dfinity/examples |
| 34 | +cd examples/motoko/vetkeys/password_manager_with_metadata |
| 35 | +``` |
| 36 | + |
| 37 | +### Deploy |
| 38 | + |
| 39 | +```bash |
| 40 | +icp network start -d |
| 41 | +icp deploy |
| 42 | +``` |
| 43 | + |
| 44 | +Open the frontend URL printed by `icp deploy`. |
| 45 | + |
| 46 | +To run the frontend in development mode with hot reloading (after `icp deploy`): |
| 47 | + |
| 48 | +```bash |
| 49 | +npm run dev |
| 50 | +``` |
| 51 | + |
| 52 | +When done, stop the local network to free up the port for other projects: |
| 53 | + |
| 54 | +```bash |
| 55 | +icp network stop |
| 56 | +``` |
| 57 | + |
| 58 | +## Example components |
| 59 | + |
| 60 | +### Backend (`backend/`) |
| 61 | + |
| 62 | +An **Encrypted Maps**-enabled Motoko canister that stores encrypted passwords together with unencrypted metadata (URLs, tags) in atomic update calls. |
| 63 | + |
| 64 | +> **Note on naming.** The backend methods are snake_case (rather than the usual Motoko camelCase). The standard Encrypted Maps methods are called by these exact names by the `@icp-sdk/vetkeys` Encrypted Maps client, and the custom metadata methods follow the same convention — renaming them would break the frontend. An upstream Motoko actor mixin that generates the Encrypted Maps endpoint set automatically is in progress ([dfinity/vetkeys#405](https://github.com/dfinity/vetkeys/pull/405)). |
| 65 | +
|
| 66 | +### Frontend (`frontend/`) |
| 67 | + |
| 68 | +A **Svelte** application for managing vaults and passwords. It uses the `@icp-sdk/vetkeys` Encrypted Maps client for the crypto operations and a canister actor (bindings generated from `backend/backend.did` by the `@icp-sdk/bindgen` Vite plugin) for the metadata methods. |
| 69 | + |
| 70 | +## Limitations |
| 71 | + |
| 72 | +This example app does not implement key rotation, which is strongly recommended in a production environment. Key rotation involves periodically changing encryption keys and re-encrypting data to enhance security. In a production app, key rotation would be useful to limit the impact of a potential key compromise, or to limit access when users are added to or removed from sharing. |
| 73 | + |
| 74 | +## Additional resources |
| 75 | + |
| 76 | +- **[Basic Password Manager](../../../rust/vetkeys/password_manager)** — a simpler example without metadata. |
| 77 | +- **[What are VetKeys](https://docs.internetcomputer.org/concepts/vetkeys)** — more information about VetKeys and VetKD. |
| 78 | +- [Security best practices](https://docs.internetcomputer.org/guides/security/overview/) |
0 commit comments