import{Credentials,SimpleSigner}from'uport'importEmailVerifierfrom'uport-verify-email'// set up the uport app credentialsconstuPortApp=newCredentials({...,signer: newSimpleSigner(...)})// set up the email account for sending verification QRs// pass the uport app credentialsconstverifier=newEmailVerifier({credentials: uPortApp,callbackUrl: 'https://api.uport.me/verify',user: process.env.EMAIL_USER,pass: process.env.EMAIL_PASS,service: 'gmail',// as an alternative to service, can take the transport params// host: string (ex: 'smtp.uport.me')// port: number (ex: 465)// secure: boolean (ex: true for TLS)confirmationSubject: 'uPort Identity ',confirmationTemplate: qr=>`<html>...${qr}...</html>`,attestationSubject: 'uPort Email Attestation',attestationTemplate: qr=>`<html>...${qr}...</html>`,customRequestParams: {},})
Receiving an email address and sending selective disclosure QR
// endpoint reads email from request paramsconstemail=params.email// send an email to user containing the request QR and return the tokenconstrequestToken=verifier.receive(email)
Handling callback after user scans QR from their email
// endpoint reads access token from POST dataconstaccessToken=data.access_token// sign an attestation claiming control of the email// by default, push the attestation and send an email with QR to downloadconstidentity=verifier.verify(accessToken)// do something with the email and request identity attributesdb.createUser(identity)