Add validation for vcard.

This commit is contained in:
Spencer Ofwiti 2021-04-27 17:10:50 +03:00
parent 63f0fe3070
commit cb14b9b5dc
3 changed files with 7 additions and 5 deletions

6
package-lock.json generated
View File

@ -4791,9 +4791,9 @@
}
},
"cic-schemas-data-validator": {
"version": "1.0.0-alpha.2",
"resolved": "https://registry.npmjs.org/cic-schemas-data-validator/-/cic-schemas-data-validator-1.0.0-alpha.2.tgz",
"integrity": "sha512-CYOAuKUUEaVWmWZ1/WFhc1jsJGs35r57A1UPXZhq7nUUDACRR8LXPAqv5qNjZoA3P+f/9uBxXh/Ds9qnzZveKw==",
"version": "1.0.0-alpha.3",
"resolved": "https://registry.npmjs.org/cic-schemas-data-validator/-/cic-schemas-data-validator-1.0.0-alpha.3.tgz",
"integrity": "sha512-0Cgl6oyPnXfXGX03bAmBr0xzVeq2z2OuD4aw7akYmTYqjCdt2Zt7Y+JWUmIZCyP1F5pii4UK6SNw4dF6AVTXgg==",
"requires": {
"@apidevtools/json-schema-ref-parser": "^9.0.7",
"ajv": "^8.1.0"

View File

@ -32,7 +32,7 @@
"chart.js": "^2.9.4",
"cic-client": "0.1.4",
"cic-client-meta": "0.0.7-alpha.6",
"cic-schemas-data-validator": "^1.0.0-alpha.2",
"cic-schemas-data-validator": "^1.0.0-alpha.3",
"datatables.net": "^1.10.22",
"datatables.net-dt": "^1.10.22",
"ethers": "^5.0.31",

View File

@ -12,7 +12,7 @@ import {MutableKeyStore, PGPSigner, Signer} from '@app/_pgp';
import {RegistryService} from '@app/_services/registry.service';
import {CICRegistry} from 'cic-client';
import {AuthService} from './auth.service';
import {personValidation} from '@app/_helpers';
import {personValidation, vcardValidation} from '@app/_helpers';
const vCard = require('vcard-parser');
@Injectable({
@ -88,6 +88,7 @@ export class UserService {
accountInfo.location.area = location;
accountInfo.location.area_name = userLocation;
accountInfo.location.area_type = locationType;
await vcardValidation(accountInfo.vcard);
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
await personValidation(accountInfo);
const accountKey = await User.toKey(address);
@ -188,6 +189,7 @@ export class UserService {
await personValidation(accountInfo);
accountInfo.balance = await this.tokenService.getTokenBalance(accountInfo.identities.evm['bloxberg:8996'][0]);
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
await vcardValidation(accountInfo.vcard);
this.accounts.unshift(accountInfo);
if (this.accounts.length > limit) {
this.accounts.length = limit;