Verifiable Credential issuer
Use this tool to issue Verifiable Credentials claming email and phone verifications.
Try it out at email-verifier.identity.rifos.org
The backend enables email and phone verificatoins:
- Email verificatoins - uses
nodemailer - Phones verifications sending SMS - uses Twilo
- Verifies digital signatures - uses
ethereumjs-util - Issues Verifiable Credentials - uses
did-jwt-vc - Saves the issued credentials in a database - uses
typeormand SQLite
The frontend is a simple app that serves as tool and code example:
- Integrates RSK compatible wallets - uses
@rsksmart/rLogin - Allows to save credentials in the cloud - uses RIF Data Vault
Development mode will allow you to run the tool without actual verifications. The verificatoin code will be logged and sent via Ethereal
- Install dependencies
npm i
npm run setup
- Configure the backend, create a
.envfile in './back' folder with
PRIVATE_KEY=ab12cd34... # a 32 bytes private key used to sign the verifiable credentials- Configure the frontend. Change the endpoint in the
.envfile in./frontfolder with
# REACT_APP_BACK_END_URL=https://email-verifier-backend.identity.rifos.org
REACT_APP_BACK_END_URL=http://localhost:5108If you run the frontend from anopther port than 3000, please configure the new port in the
whitelist
npm test
npm start
npm run start:dev
mainhas latest release. Merge intomainwill deploy front-end to email-verifier.identity.rifos.org. Do merge commits.develophas latest approved PR. PRs need to passci, LGTM and Sonar. Do squash & merge.- Use branches pointing to
developto add new PRs. - Do external PRs against latest commit in
develop.
You can optionally run any of the services. You will need to add some .env variables to activate the features. First add
NODE_ENV=production
SMTP_HOST=
SMTP_PORT=
SMTP_USER=
SMTP_PASS=TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_PHONE_NUMBER=LOG_FILE=./log/email-vc-issuer.log # relative path of the log file
LOG_ERROR_FILE=./log/email-vc-issuer.log # relative path of the error log file
NETWORK_NAME=rsk # rsk:testnet or rsk, for the issuer DID
PORT=5108 # port where the service will be servedCreate the .env following the description above and run it
cd back/
docker-compose build
docker-compose up -d
It opens port 5108. Change it in the compose if you have changed it in the config file.
The tool will make the user digirally sign a verificatoin code that is sent via email/phone. This will proove that the user controls the asset and the wallet. The backend will verify this signature, sign a Verifiable Credentials and send it to the user. The user can then save to their Data Vault
The service is built to make easy to add new verification services. You need to:
- Set up the Credential subject
- Create the new Schemas at
@rsksmart/vc-json-schemasand@rsksmart/vc-json-schemas-parser - Create a template function to create the new VC in
./back/src/vc.ts
- Create the new Schemas at
- Set up the transport service
- Add the transport service configurations to
./back/src/config.ts - Create a
Senderclass implementingsendVerificationCodefunction
- Add the transport service configurations to
- Prepare the instance of
VCIssueratsetupServicesin./back/src/index.tsusing the template, theSenderand a desiredcredentialType - Backend all set! The API is no serverd at
/${credentialType.toLowerCase()}/requestVerificationand/${credentialType.toLowerCase()}/verify - Now, to add the feature to the front, just add to
front/src/App.tsxthe credential typeCredentialTypeindicating the API module namegetKeyByCredentialTypefor the file key in the Data Vault
The best example is Twilo integration
import { Logger } from '@rsksmart/rif-node-utils/lib/logger'
import { Twilio } from 'twilio'
import { MessageInstance } from 'twilio/lib/rest/api/v2010/account/message'
import { Sender } from './sender'
export class SMSSender extends Sender<MessageInstance> {
twilio: Twilio
from: string
constructor(twilio: Twilio, from: string, logger: Logger) {
super(logger)
this.twilio = twilio
this.from = from
}
logSendResult = (result: MessageInstance): void => { this.logger.info(`SMS sent: ${result.sid}`) }
sendVerificationCode = (to: string, text: string): Promise<any> => this.twilio.messages.create({ from: this.from, to, body: text })
}