Add KYC Certificate
2
3
4
5
Start the KYC Verification
const provider = providers.find((p) => p.id === "Footprint");
const verification = await provider.startVerification();
console.log(verification.webURL);KycProvider? provider = providers.FirstOrDefault(candidate => candidate.Id == "Footprint");
VerificationOutcome created = await kycClient.StartVerification(provider, Countries, cancellationToken: cancellationToken);
if (created.Ready is null) {
Verification verification = created.Ready;
Console.WriteLine(verification.WebUrl);
}6
7
Add KYC Certificate to User Account
for (const [i, certGroup] of certificates.results.entries()) {
// Re-wrap with the user's account as the subject key so sensitive
// attributes (PII) can be decrypted
const cert = new KeetaAnchor.lib.Certificates.Certificate(
certGroup.certificate.toPEM(),
{ subjectKey: userAccount }
);
// Construct the Certificate Bundle from Intermediates
const intermediates = certGroup.intermediates
? new KeetaAnchor.KeetaNet.lib.Utils.Certificate.CertificateBundle([...certGroup.intermediates])
: null;
// Attach the certificate to the user's account onchain
await userClient.modifyCertificate(
KeetaAnchor.KeetaNet.lib.Block.AdjustMethod.ADD,
cert,
intermediates
);
}foreach (IssuedCertificate issued in results.Ready.Results)
{
index++;
using KycCertificate certificate = runtime.KycCertificates.Parse(issued.Value);
Console.WriteLine($"\n Certificate {index}:");
using CryptoCertificate baseCertificate = certificate.Base();
Console.WriteLine($" Subject: {baseCertificate.Subject}");
Console.WriteLine($" Valid: {certificate.IsValidAt(DateTimeOffset.UtcNow)}");
if (issued.Intermediates.Count > 0)
{
Console.WriteLine($" Intermediate certificates: {issued.Intermediates.Count}");
}
if (certificate.GetAttributeNames().Contains("fullName", StringComparer.Ordinal))
{
KycAttributeValue fullName = certificate.GetAttribute("fullName", userAccount);
Console.WriteLine($" Full name (decrypted): {fullName.AsText()}");
}
await userClient.ModifyCertificateAsync(
runtime,
issued.Value,
issued.Intermediates,
cancellationToken: cancellationToken).ConfigureAwait(false);
}8
Read Certificates from User Account
const onChain = await userClient.client.getAllCertificates(userAccount);
console.log(`\nOn-chain certificates for this account: ${onChain.length}`);IReadOnlyList<IssuedCertificate> onChain = await nodeClient.GetAllCertificates(userAccount, cancellationToken);
Console.WriteLine($"\nOn-chain certificates for this account: {onChain.Count}");Full Code Example
https://github.com/KeetaNetwork/keetanet-examples/blob/main/src/anchor/kyc-client.ts
https://github.com/KeetaNetwork/keetanet-examples/blob/main/csharp/src/Anchor/KycClient.cs
Last updated