Skip to content

Commit

Permalink
Add kyc plus verification on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
luistorres committed Apr 26, 2024
1 parent a9d5120 commit 247a265
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/web-app/app/_server/idos/idos-grantee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ export class idOSGrantee {
);
}

async fetchUserCountryFromSharedCredential(
async fetchUserCountryFromSharedPlusCredential(
dataId: string,
): Promise<string | undefined> {
const credentialString =
await this.getSharedCredentialContentDecrypted(dataId);
const credential = JSON.parse(credentialString);

if (credential?.level !== 'plus') return undefined;

return credential?.credentialSubject?.residential_address_country;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/web-app/app/_server/idos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const userFilter = async (grantee: idOSGrantee, userAddress: string) => {
.parse(grantsResult)
?.filter((grant) => isValidGrant(grant.lockedUntil));

if (!grants.length) throw new Error('No valid grants found');
if (!grants.length) return null;

const country = await grantee.fetchUserCountryFromSharedCredential(
const country = await grantee.fetchUserCountryFromSharedPlusCredential(
grants[0].dataId,
);

if (!country) throw new Error('No country found');
if (!country) return null;

const isBlockedCountry = blockedCountries.some(
(blockedCountry) => blockedCountry === country,
Expand Down

0 comments on commit 247a265

Please sign in to comment.