Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge ecosystem sales demo to main #20

Merged
merged 111 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
d34d6b9
Qr code Reader component added to handle DID
Feb 1, 2024
314399e
Added toast and fix Helper box
Feb 1, 2024
bce36f6
Fix Helper box now works with onboarding form
Feb 2, 2024
ec64c81
Added onboarding page item to sidebar
Feb 2, 2024
a51e1fb
Organizations page as Landing
Feb 5, 2024
451703b
Design fixes for landing page
Feb 5, 2024
13d37c9
Added new UI libraries
Feb 6, 2024
1f092b9
Added UI components folder
Feb 6, 2024
bae09e1
Added form components folder
Feb 6, 2024
f40a1d0
Assets for Quotient page
Feb 6, 2024
274f0b3
added Open bank Quotient page
Feb 6, 2024
afdae42
General style fixes and small refactor over Quotient page
Feb 6, 2024
9104ee8
Design fixes and Refactor for Quotient page
Feb 6, 2024
4c3481c
Styling Goverment docs for Quotient page
Feb 6, 2024
2c07c39
Added basic configuration for Issuing credentials
Feb 6, 2024
7d0ceb5
Successfully issuing credentials on Quotient
Feb 7, 2024
a5ff38b
Small fixes
Feb 7, 2024
0e92e26
Fix linting
Feb 7, 2024
db5a804
format check fix
Feb 7, 2024
88b68eb
removed lock.json file
Feb 7, 2024
a85cb87
Fix form-check to work with npm
Feb 7, 2024
43e3de0
feat: quotient loan form
Feb 8, 2024
cf4ed09
Fix:comments from PR#11
Feb 8, 2024
3a1d813
Changed the _credentials folder content
Feb 8, 2024
e762cc2
fix:Change component to jsx
Feb 9, 2024
d057f80
Issuers Did's on env file
Feb 10, 2024
ecf8530
Suggested fixes
Feb 12, 2024
687fee1
Desktop design complete for New Banking page
Feb 9, 2024
77a037a
feat - equinet dashboard page
Feb 9, 2024
c703c5f
Setting up QR generator with each template
Feb 9, 2024
5b28017
fix: generate Qr on loan
Feb 10, 2024
de457fc
Removed old pages
Feb 10, 2024
71d46dc
desktop design done for Equinet page
Feb 10, 2024
bbc6f59
Qr code & credentials styles for loan page
Feb 10, 2024
b2fbf68
Qr for new bank page
Feb 10, 2024
74c91b7
Landing page updated with demo flow items
Feb 10, 2024
037c5da
Cleaning componetns folder
Feb 10, 2024
70f98d9
deleted icons folder
Feb 10, 2024
f65cca8
Partners page created
Feb 10, 2024
3308b4e
partners pages desktop design
Feb 10, 2024
f0bcb50
Page layout moved to app.js & creating custom partner page
Feb 11, 2024
1b1a8f0
Custom partner content structure
Feb 11, 2024
bbd61c6
Partnert custom page complete with responsive
Feb 12, 2024
1e076ec
fix linting
Feb 12, 2024
083de59
Fixed success bank account created page
Feb 12, 2024
23c2732
Partners Componets move to new folder
Feb 12, 2024
cbd99b2
feat: urbanscape page & form
Feb 12, 2024
2c3089a
Desktop style ready for Urbanscape form & success screeen+
Feb 12, 2024
867ae48
Fix linting
Feb 12, 2024
c81890d
Qr code for urbanscape
Feb 12, 2024
9ee3391
Camera image for auto loan page
Feb 13, 2024
f2f31a3
Basic configuration for QR verification
Feb 13, 2024
d031aee
Verification complete for Loan page
Feb 13, 2024
944070d
Error handling for Qr code verification
Feb 13, 2024
ebdd61a
Created qrCodeStore to handle QrCode state around the app
Feb 14, 2024
e9f644f
Refactoring QrCode verification component to make it reusable
Feb 14, 2024
f89249b
Added Qr verification to create new bank account page
Feb 14, 2024
7ec227f
Added QR code verification for Urbanscape
Feb 14, 2024
1240aea
Refactoring Qr code verification & move all qr code into components/q…
Feb 14, 2024
aa99175
refactoring qr code refetching
Feb 14, 2024
db03940
Lint errors fixed
Feb 14, 2024
8980288
Setting mock values for create bank formulary
Feb 15, 2024
15e8f3a
Using verifyError in QrStore
Feb 15, 2024
36dd48e
fix lint and form-check
Feb 15, 2024
2292931
Fix Partner urbanscape custom page & fix Server url to own url
Feb 15, 2024
e87a9c2
changed Api Env name to not be public
Feb 15, 2024
753f305
Helper box accept 1 field, email or did
Feb 16, 2024
160644c
Responsive for all pages supporting min size of 300px
Feb 16, 2024
6cf7e28
Fix _credentials objects to use right options
Feb 19, 2024
4209bed
Issuing revokable credentials
Feb 20, 2024
a6e09bf
Error handling for Qr code verification and Isssue credentials
Feb 20, 2024
9df2dfb
Rekocation workflow done for equinet page
Feb 20, 2024
dba1d11
Fix urbanscame useQrCode
Feb 20, 2024
e90d628
Added webcam gif | fix back arrow for equinet | Fix load qr code in …
Feb 20, 2024
715b062
Urbanscape success page qr code fix
Feb 21, 2024
dce0332
Refactoring folder structure
Feb 21, 2024
cb21fe9
Fix triggering multiple times & credentials modified with persist true
Feb 22, 2024
f011e6b
Added real information for issuin credentials | Forms fill up from QR…
Feb 22, 2024
725407d
Updated .env.example values
Feb 22, 2024
ff46b9d
Reseting retrievedData from qr codes
Feb 22, 2024
6ff71fe
Changed proof template for loan page & added Readme File
Feb 23, 2024
6545fee
Fixing PR commets
Feb 13, 2024
e8c2c4d
fix: format-check failing because the identified lines did not adhere…
Dadogg80 Feb 14, 2024
869bdf9
fix: remove personal values as default values.
Dadogg80 Feb 14, 2024
ddc190f
Pusing for format-check
Feb 15, 2024
6067730
fix format-check
Feb 15, 2024
0c5e76c
Update pages/_app.js
Dadogg80 Feb 20, 2024
de905d9
fixing conflicts
Feb 23, 2024
55cebbe
General content modifications from list of fixes
Feb 26, 2024
04f1b97
Fix text for credentials component
Feb 27, 2024
64b089d
PR16 fixes: removed distribute from credentials & clean public folder
Feb 27, 2024
c8b77f4
Addred creditScore to equinet credetial
Feb 27, 2024
b473e15
Credit score added to equinet credential
Feb 27, 2024
4dba52d
Added distribute true back to _crendentials
Feb 28, 2024
00afb4a
temporarily disable bbs+
mike-parkhill Feb 28, 2024
2f0f96b
renable bbs+
mike-parkhill Feb 29, 2024
5b8dc22
remove holder check
mike-parkhill Feb 29, 2024
0b1d674
get holder DID from first VC in presentation
mike-parkhill Feb 29, 2024
0445f1a
remove revocation details from Bank Identity and make credit score no…
mike-parkhill Feb 29, 2024
95833b4
try to get equinet working again
mike-parkhill Feb 29, 2024
b88956a
log issue credential body
mike-parkhill Feb 29, 2024
6ae9cc1
use non BBS+ revocation
mike-parkhill Mar 1, 2024
cd7febb
some clean-up
mike-parkhill Mar 1, 2024
c14292d
fix reference to issuedCredential
mike-parkhill Mar 1, 2024
7d8cef3
remove reference to distributeCredential
mike-parkhill Mar 1, 2024
1c77a0a
remove persistence from Forsur VC
mike-parkhill Mar 1, 2024
18140cd
Fix revocation bug and some minor tweaks to spelling, etc. (#19)
mike-parkhill Mar 8, 2024
2bdcda2
updated lock files
mike-parkhill Mar 8, 2024
cbd0b21
fix merge mistake
mike-parkhill Mar 8, 2024
918cf0d
fixed another merge issue
mike-parkhill Mar 8, 2024
d56342c
copied lock files from other branch
mike-parkhill Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
DOCK_API_URL=https://api-testnet.dock.io
DOCK_API_TOKEN= # you can generate a key at https://certs.dock.io/keys
NEXT_PUBLIC_DOCK_API_URL="https://api-testnet.dock.io"

DOCK_API_TOKEN= ##DOCK_API_TOKEN

DOCK_API_DID= # the DID to use for the issuer. You can generate one here: https://certs.dock.io/dids
NEXT_PUBLIC_SERVER_URL= # the URL where this app is listening (e.g. http://192.168.0.100:3000 or http://localhost:3000)
NEXT_PUBLIC_SERVER_URL= http://localhost:3000

# Proof-Request Template Ids
NEXT_PUBLIC_QUOTIENT_LOAN_PROOF_TEMPLATE_ID= ##
NEXT_PUBLIC_FORSUR_ENROLLMENT_PROOF_TEMPLATE_ID= ##
NEXT_PUBLIC_FORSUR_VERIFICATION_PROOF_TEMPLATE_ID= ##
NEXT_PUBLIC_URBANSCAPE_BANKBIO_TEMPLATE_ID= ##
NEXT_PUBLIC_URBANSCAPE_CREDITSCORE_TEMPLATE_ID= ##
NEXT_PUBLIC_BANK_IDENDITY_TEMPLATE_ID= ##

# Organization Profiles
NEXT_PUBLIC_QUOTIENT_ISSUER_ID= ##
NEXT_PUBLIC_FORSUR_ISSUER_ID= ##
NEXT_PUBLIC_EQUINET_ISSUER_ID= ##

57 changes: 51 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
"browser": true,
"es6": true
},
"extends": ["next", "eslint:recommended", "plugin:react/recommended", "airbnb-base"],
"extends": [
"next",
"eslint:recommended",
"plugin:react/recommended",
"airbnb-base"
],
"rules": {
"no-use-before-define": ["error", { "functions": false, "classes": true, "variables": true }],
"no-use-before-define": [
"error",
{
"functions": false,
"classes": true,
"variables": false
}
],
"class-methods-use-this": "off",
"no-console": "off",
"no-nested-ternary": "off",
Expand All @@ -27,16 +39,49 @@
"indent": "off",
"implicit-arrow-linebreak": "off",
"function-paren-newline": "off",
"no-confusing-arrow": "off"
"no-confusing-arrow": "off",
"no-unused-vars": "off",
"no-trailing-spaces": "off",
"import/prefer-default-export": "off",
"no-shadow": "off",
"react/react-in-jsx-scope": "off", // Disable react/react-in-jsx-scope rule
"linebreak-style": ["off"],
"no-plusplus":"off"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
"ts",
"tsx"
],
"moduleDirectory": [
".",
"node_modules"
]
},
"alias": {
"map": [
["components", "./components"],
["utils", "./utils"]
[
"components",
"./components"
],
[
"utils",
"./utils"
],
[
"store",
"./store"
],
[
"lib",
"./lib"
]
]
}
}
}
}
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
188 changes: 168 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,178 @@
# Dock Bank Demo App
# Dock Sales Demo

This is a demo application showing some real use cases of [Dock API](https://docs.api.dock.io) for credential issuance and verification.
## Overview

## Getting Started
The Dock Sales Demo showcases the integration of KYC, biometric services, and verifiable credentials to demonstrate the capabilities of Dock's API and wallet. It simulates a customer journey through KYC verification, credential issuance, and verification across various scenarios, emphasizing integration ease and user experience.

First, setup a .env file in the project's root folder
### Workflow Steps

```bash
DOCK_API_URL=https://api-testnet.dock.io
DOCK_API_TOKEN= # you can generate a key at https://certs.dock.io/keys
DOCK_API_DID= # the DID to use for the issuer. You can generate one here: https://certs.dock.io/dids
NEXT_PUBLIC_SERVER_URL= # the URL where this app is listening (e.g. http://192.168.0.100:3000 or http://localhost:3000)
```
1. 🚀 User initiates the KYC process.
2. 🔒 Biometric verification is conducted by scanning a QR code.
3. ✅ Upon successful verification, the user is issued verifiable credentials.
4. 🔍 The user presents the credentials for verification.

Then, run the development server:
*Note: The Dock wallet app, with the biometric service plugin enabled, is required.*

```bash
npm run dev -- -H IP_OR_HOSTNAME_WHERE_APP_IS_RUNNING
# or
yarn dev -- -H IP_OR_HOSTNAME_WHERE_APP_IS_RUNNING
```
## Technologies Used

The `-- -H [IP]` option above is needed to allow scanning of the credentials and presentations to work in your wallet app.
- Next.js 12.2.3
- Dock API for decentralized identity and credential management.
- Integration with biometric verification services on the mobile app.

Open [NEXT_PUBLIC_SERVER_URL] with your browser to see the app.
## 📚 Libraries and Dependencies

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
Our project, "dock-demo," incorporates a variety of technologies for optimal performance, state management, and UI aesthetics:

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
- **Next.js:** The core framework provides server-side rendering and static site generation.
- **React:** Enables building our UI with a component-based approach.
- **Tailwind CSS:** Allows for efficient styling within JSX, promoting rapid UI development.
- **Axios:** Facilitates promise-based HTTP requests for external API communication.
- **React Hook Form:** Optimizes form handling with minimal re-renders.
- **Lucide-react:** Enhances UI design with customizable vector icons.
- **Zustand:** Simplifies global state management with a minimalistic store.
- **Date-fns:** Offers comprehensive JavaScript date manipulation tools.
- **Radix UI & TanStack React Table:** Provides low-level UI primitives and a lightweight table component for creating accessible, custom designs.
- **PostCSS & Autoprefixer:** Transforms CSS with JS for future-proofing and cross-browser compatibility.
- **ESLint:** Maintains code quality and consistency.
- **Shadcn-ui/ui:** A UI component library from [shadcn-ui/ui on GitHub](https://github.com/shadcn-ui/ui), enhancing our application with a set of pre-designed, customizable UI components for a consistent and modern interface.

Each library and dependency has been carefully selected for its performance, reliability, and the support it offers to our development process.

## 📁 Folder Structure

- `/pages/api` - Server side API integration and communication with Dock.
- `/pages/org` - Organization pages for testing functionality.
- `/components/ui` - Interface components from ShadCn library.
- `/_credentials` - Credential Schemas used for issuing credentials.
- `/hooks` - Handle QR generation and verification and revoke credentials.
- `/store` - State management for user information and Qr code Status.
- `/utils` - Utility functions for API and server side communication for credentials and qr code.

Note: Most of the functions are documented inside of each file.

## Main Functions & Methods

### State management

The Qr code state is handle by `/store/qrCodeStore.js` folder, using the Zustand library, for updating the proof template Id and verification state.
Qr code track this states:

proofTemplateId -> Dock Cert Verification template id

qrCodeUrl -> Generated url from generateQR() function

proofID -> Unique Id for each Qr code generated

isLoading -> Boolean for loading code generation

verified -> Is verified by user, default to false

verificationError -> Boolean state for error handling

retrievedData -> Credential data retrieved when is verified

Each value also contain setter function.

### Main Functions

Under folder `/utils` are the files that handle all the communication with Dock API service.

`createRegistry(policyDid, type)` -> Creates Registry for a new credential.

`createCredential(registryId, credential)` -> Create new credential from registryId & credential schema.

`distributeCredential(credential)` -> Send a signed credential to a Did or email.

`issueRevokableCredential = async (credential, setRevokableCredential)` -> Entire process that carrie all previews functions.
revokeCredential = async (registryId, credentialId) -> Revoke credit score credential with a given registry and credential ids.


### Methods

There is 3 important methods under `/hooks` folder wich make the application workflow:

`useQrCode = ({ proofTemplateId })` ->
The useQrCode hook orchestrates the generation of QR codes associated with proof requests. It leverages state management through qrCodeStore, handling loading states, verification flags, and potential errors. Upon calling handleGenerateQR, it sets up the necessary parameters, initiates QR code creation via handleCreateQr, and updates relevant states accordingly.

`useVerifyProof = ()` ->
This React hook, useVerifyProof, facilitates verifying proof requests tied to a QR code. It utilizes intervals to periodically check the verification status. Upon successful verification, it updates relevant states, such as user DID, verification status, and retrieved data. In case of errors, it handles retries and sets a verification error flag.

### Main Component

`QrCodeAuthentication`

Hooks methods are use in single component `components/qrcode/qr-auth.jsx` with two responsabilities, generate and verify a Qr code using the previews hooks `useQrCode` & `useVerifyProof`.

The `QrCodeAuthentication` component manages QR code authentication flow. It renders UI elements conditionally based on whether the QR code is verified or not. If not verified, it displays QR code verification UI provided by VerifyQrCode component along with optional descriptive texts before and after. Upon verification, it shows a refresh icon to allow users to retry the authentication process. Additionally, it lists required credentials using CredentialCards component.

## 🎮 Running the Project

### 📓Prerequisites

- Node.js and npm installed.
- Dock account with API access.

### 🔑 Configuration

To configure the project, set up environment variables. Copy the `.env.example` file to a new file named `.env` and fill in the variables:

- `NEXT_PUBLIC_DOCK_API_URL`: URL to the Dock API, set to the testnet endpoint.
- `DOCK_API_TOKEN`: Your API token for authenticating with the Dock API.
- `DOCK_API_DID`: The DID to use for the issuer. You can generate a DID [here](https://certs.dock.io/dids).
- `NEXT_PUBLIC_SERVER_URL`: The URL of your server, defaulting to `http://localhost:3000` for local development.

### Proof-Request Template IDs and Organization Profiles

Create these IDs from [Certs Dock](https://certs.dock.io/). Fill in the template IDs and issuer IDs for your proof requests and organization profiles. These are crucial for the functioning of your verifiable credentials within the demo.

Ensure all these configurations are set properly in your `.env` file before running the project to ensure smooth operation and connectivity to the necessary services.

### 🛠️ Installation and Deployment

1. Clone the repo: `git clone <repo_url>`
2. Install dependencies: `npm install` or `yarn`
3. Start the project: `npm start` or `yarn dev`

## 🧪 Testing the Project Workflow

Before starting, remember to get the Dock Wallet mobile app, with the biometric service plugin enabled, is required. The Dock Wallet app is available on PlayStore or AppStore.

The demo workflow consists of going through the KYC process filling the formularies and scanning each QR code to get authenticated and test the organizations ecosystems.

It's based on 3 ecosystems:

**Quotient:** Get BankId and Credit Score credentials and Apply for an auto loan.

**Equinet:** Revoke Credit Score credential and issue a new one.

**Urbanscape:** Apply for an apartment providing your BankId and Credit Score credentials.

**1. Create a Bank account:** On the main page organizations click on “New Bank Account” from Quotient.

Fill the formulary required data and click on “Submit Application”. This will take you to the first QR code we need to scan with the Dock Wallet app using the option “Scan”. This QR code will trigger the biometric verification process on the mobile to get the Biometric credential.

Once QR code verification is successful, you will receive 2 credentials in your Dock Wallet, “Credit Score credential” and “BankId credential”.

**2. Obtain Auto Loan:** On the main page click on “Obtain Auto Loan” from Quotient.

Identify yourself scanning the QR code using your Dock Wallet app and select the required credentials: Biometric, BankId, and Credit Score.

On verification success will automatically fill the fields “First Name, Last Name, Street Address”, from your BankId credential details, then click on “Submit Application” to continue.

On the success page, you will find a second QR code to scan with the Dock Wallet to proof your Credit Score from your credential.

**3. Revoke & Reissue Credit Score:** On the main page click on “Visit Site” from Equinet. This page is the representation of a Credit Score credential history. You can revoke the actual Credit Score credential and issue another with one action. Click on “Revoke and Issue New credential” to test the functionality. Note: you need to complete previous steps to own this credential and revoke it.

**4. Apply for an apartment:** On the main page click on “Visit Site” from Urbanscape. Identify yourself scanning the QR code using your Dock Wallet app and select the required credentials: Biometric, BankId, and Credit Score.

On verification success will automatically fill the fields “First Name, Last Name, Street Address”, from your BankId credential details, then click on “Submit Application” to continue.

On the success page, you will find a second QR code to scan and proof your Credit Score from your credential.

With this, we finish the workflow from the application where we can have an overview of some usage of the decentralized identity and credentials management.

## Resources

- [Dock](https://www.dock.io/)
- [Dock API Documentation](https://docs.api.dock.io/)
- [Next.js](https://nextjs.org/)
40 changes: 40 additions & 0 deletions _credentials/equinet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { v4 as uuidv4 } from "uuid";
import { dockUrl } from "utils/constants";
import { validateEmail } from "utils/validation";

export function createCreditScoreCredential({ receiverDid, recipientEmail, creditScore }) {

console.log("Creating EquiNet - Credit Score Credential for:", receiverDid);

const credentialPayload = {
url: `${dockUrl}/credentials`,
body: {
anchor: false,
distribute: true,
credential: {
name: "EquiNet - Credit Score",
description: "This schema represents a Verified Credit Score Credential, issued by EquiNet. It standardizes the presentation of credit scores for reliable and efficient verification processes.",
type: [
"VerifiableCredential",
"EquiNetCreditScore"
],
issuer: {
name: "EquiNET",
description: "EquiNet is the credit bureau.",
logo: "https://img.dock.io/9f327cafda3be5f0cff0da2df44c55da",
id: process.env.NEXT_PUBLIC_EQUINET_ISSUER_ID
},
subject: {
id: receiverDid,
credit_score: creditScore,
}
}
}
}

if (recipientEmail && recipientEmail.length > 2 && validateEmail(recipientEmail)) {
credentialPayload.recipientEmail = recipientEmail
}

return credentialPayload;
}
50 changes: 50 additions & 0 deletions _credentials/forsur.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { v4 as uuidv4 } from "uuid";
import { dockUrl } from "utils/constants";

export function createBiometricsCredential({
receiverDid,
recipientEmail
}
) {

console.log("Creating ForSur - Biometric Enrollment Credential for:", receiverDid);

const credentialPayload = {
url: `${dockUrl}/credentials`,
body: {
anchor: false,
algorithm: "dockbbs+",
distribute: true,
credential: {
id: `https://creds-testnet.dock.io/${uuidv4()}`,
name: "ForSur - Biometric",
description: "The \"ForSur - Biometric\" schema is specifically developed for the secure registration and storage of biometric data.",
type: [
"VerifiableCredential",
"ForSurBiometric"
],
issuer: {
name: "Forsur",
description: "Forsur is the biometric provider.",
logo: "https://img.dock.io/80f154126a78bba321b413c3ffb8d4a7",
id: process.env.NEXT_PUBLIC_FORSUR_ISSUER_ID
},
subject: {
id: receiverDid,
biometric: {
id: uuidv4(),
created: new Date().toISOString(),
data: "some biometric data",
}
}
}
}
};

if (recipientEmail && recipientEmail.length > 2 && validateEmail(recipientEmail)) {
credentialPayload.recipientEmail = recipientEmail
}

return credentialPayload

}
Loading
Loading