Cookbook
Onboard a borrower
Connect ID sign-in, reuse or a new KYC L2, then the customer in LENS.
Harbor Lending onboards borrowers. A borrower signs in with Connect ID; if they already hold a KYC L2 attestation, they reuse it; otherwise they verify.
1. Sign in
Ask for openid profile identity:verified connection:grant. After the code exchange:
const tokens = await dc.id.exchangeCode({ code, redirectUri, clientId, clientSecret, codeVerifier });
const claims = await dc.id.userinfo(tokens.access_token);
// claims.sub, claims.kyc_status, claims.kyc_levelconnection:grant links the person to your platform: their sub is the identity_id you can
verify.
2. Verify, or reuse
const session = await dc.verify.sessions.create({
flow_id: process.env.BORROWER_FLOW_ID!, // kyc, l2, accept_reuse: true
subject: { reference: borrower.id, identity_id: claims.sub, country: 'US' },
});
redirect(session.url);With session.reuse.available, the hosted page asks the person to share their attestation; otherwise it
runs the checks of L2.
3. Wait for the decision
on('verify.session.approved', async (event) => {
await db.borrowers.update(event.data.subject_reference, { kyc_level: event.data.level });
});The customer is now linked in LENS under the same reference: its first events are scored with its verification state.

