This project is a single-page web application demonstrating the use of the @semiotic-labs/agentium-sdk for Decentralized Identifier (DID) and Verifiable Credential (VC) management.
This demo showcases the following features of the @semiotic-labs/agentium-sdk:
- Decentralized Identifier (DID) Creation: Create a DID from a Google ID token.
- Verifiable Credential (VC) Issuance: Issue and manage the lifecycle of VCs.
- Client-Side VC Verification: Verify VCs on the client-side using a WebAssembly (WASM) module.
- OAuth Token Management: Refresh OAuth access tokens.
This demo showcases a modern and robust integration of the @semiotic-labs/agentium-sdk in a React application. The following architectural patterns and SDK features are highlighted:
-
Agentium Client: The
AgentiumClientis initialized once at the application's entry point (src/main.tsx) and provided to the entire component tree using a React Context (src/contexts/AgentiumContext.tsx). -
WASM-based Verification: The demo utilizes a WebAssembly (WASM) module for efficient, client-side verification of Verifiable Credentials.
-
Component-based Examples: The
src/componentsdirectory contains several React components that demonstrate different SDK features:StandardLogin.tsxandZkLogin.tsx: These components demonstrate how to use theconnectGoogleIdentitymethod to create a DID from a Google ID token. They also showcase handling both standard and zkLogin authentication flows.VCIssuance.tsx: This component demonstrates the full lifecycle of a Verifiable Credential, including fetching, verifying, and storing VCs in the browser usingfetchMembershipCredential,verifyCredential, andconnectAndStoreMembership.TokenTest.tsx: This component illustrates how to use therefreshTokenmethod to refresh OAuth access tokens.
This project uses environment variables to manage sensitive information like the Google OAuth Client ID.
-
Copy
.env.exampleto.envand set your Google OAuth Client ID.VITE_GOOGLE_CLIENT_ID="YOUR_ACTUAL_GOOGLE_CLIENT_ID.apps.googleusercontent.com"
Install the project dependencies using npm:
npm installTo start the development server:
npm run devThe application will typically be accessible at http://localhost:5173.
For both the Google Sign-In and zkLogin flow to work, you need to configure your Google OAuth Client ID correctly in the Google Cloud Console:
- Ensure your Authorized JavaScript origins includes
http://localhost:5173. - Ensure your Authorized redirect URIs includes
http://localhost:5173.
This project uses ESLint for linting and Prettier for code formatting. The following npm scripts are available:
-
Check all (lint and format):
npm run check
-
Run Linter:
npm run lint
-
Check formatting only:
npm run format:check
-
Format code (fix issues):
npm run format:write
This project follows the REUSE Specification. To ensure compliance:
-
Install REUSE Tool: You'll need to install the
reusecommand-line tool, for example viapip:pip install reuse
-
Applying SPDX Headers: To add or update SPDX license and copyright headers to all relevant files:
npm run reuse:write
-
Verify Compliance: To check if the project is fully REUSE compliant:
npm run reuse:check
To compile the TypeScript code into JavaScript in the dist folder:
npm run buildNote: This demo focuses on the frontend authentication flows. It does not include backend integration for DID creation or the full zkLogin proof generation and transaction signing beyond JWT retrieval.