Integrating DIDs in a Web App
In this tutorial, we’ll demonstrate how to integrate Decentralized Identifiers (DIDs) into a web application to allow users to prove they control a DID
Step 1: Set Up Veramo in Your Web App
First, install Veramo packages in your web app:
npm install @veramo/core @veramo/did-manager
Step 2: Create a DID
Generate a DID for the user during sign-up:
const userDid = await agent.didManagerCreate({
provider: "did:key",
});
console.log("User DID:", userDid);
This DID can be used as a subject of Verifiable Credentials, and the user can prove they control the DID.
Step 3: Use DIDs for Authentication
When a user logs in, their DID corresponding to the VC can be verified:
TODO: add proof of control
const isValid = await agent.verifyPresentation({
presentation: userPresentation,
});
console.log("User Authenticated:", isValid);
By integrating DIDs in your web app, you can offer decentralized proof of control over DIDs