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

Equinet schema and KVAC support #31

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 15 additions & 14 deletions _credentials/equinet.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { v4 as uuidv4 } from "uuid";
import { dockUrl } from "utils/constants";
import { validateEmail } from "utils/validation";
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);
console.log('Creating EquiNet - Credit Score Credential for:', receiverDid);

const credentialPayload = {
url: `${dockUrl}/credentials`,
body: {
anchor: false,
distribute: true,
algorithm: 'bbdt16',
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.",
name: 'EquiNet - Credit Score',
schema: 'https://schema.dock.io/EquiNetCreditScore-V2-1706975901761.json',
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"
'VerifiableCredential',
'EquiNetCreditScore'
],
issuer: {
name: "EquiNET",
description: "EquiNet is the credit bureau.",
logo: "https://img.dock.io/9f327cafda3be5f0cff0da2df44c55da",
name: 'EquiNET',
description: 'EquiNet is the credit bureau.',
logo: 'https://img.dock.io/9f327cafda3be5f0cff0da2df44c55da',
id: process.env.NEXT_PUBLIC_EQUINET_ISSUER_ID
},
subject: {
Expand All @@ -30,10 +31,10 @@ export function createCreditScoreCredential({ receiverDid, recipientEmail, credi
}
}
}
}
};

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

return credentialPayload;
Expand Down
9 changes: 8 additions & 1 deletion pages/org/quotient/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ const QuotientBankForm = () => {
function getBiometricalData() {
if (retrievedData !== null) {
const credential = retrievedData.credentials.find((obj) => Object.prototype.hasOwnProperty.call(obj.credentialSubject, 'biometric'));
if (credential) return credential.credentialSubject.biometric;

// TODO: get wallet to return a string rather than a boolean so we don't have to do this hack
const biometric = credential?.credentialSubject?.biometric;

if (biometric) {
biometric.data = biometric.data?.toString();
return biometric;
}
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion utils/issue-crendentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const issueRevokableCredential = async (credential, setRevokableCredentia

let registry = null;
if (isRevocable) {
const type = credentialPayload.algorithm === 'dockbbs' ? 'DockVBAccumulator2022' : 'StatusList2021Entry';
const type = credentialPayload.algorithm === ('dockbbs' || 'bbdt16') ? 'DockVBAccumulator2022' : 'StatusList2021Entry';
registry = await getExistingRegistry(_credential.issuer.id, type);

if (!registry) {
Expand Down
Loading