Skip to content

Commit

Permalink
add random citizen generation
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Sep 6, 2024
1 parent 6637595 commit 643d2b3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
21 changes: 21 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"proto:generate": "protoc --experimental_allow_proto3_optional --ts_proto_out=./src --proto_path=../shared/proto identity/domain_linkage.proto identity/presentation.proto identity/credentials.proto identity/utils.proto user/user.proto oid4vc/siopv2.proto oid4vc/oid4vci.proto oid4vc/oid4vp.proto --ts_proto_opt=esModuleInterop=true --ts_proto_opt=nestJs=true"
},
"dependencies": {
"@faker-js/faker": "^9.0.0",
"@grpc/grpc-js": "^1.9.13",
"@grpc/proto-loader": "^0.7.10",
"@nestjs/axios": "^3.0.2",
Expand Down
25 changes: 25 additions & 0 deletions backend/src/webapp/webapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Providers } from '../../../shared/types/Providers';
import { ValidateDidResponse } from 'src/identity/domain_linkage';
import { JwtCreationResponse } from 'src/identity/credentials';
import { IotaDidToAliasAddressResponse } from 'src/identity/utils';
import { faker } from '@faker-js/faker';

type Token = {
sessionId: string;
Expand Down Expand Up @@ -256,6 +257,30 @@ export class WebAppService {
obj[key] = new Date().toISOString();
break;

case '**TEMPLATE_FIRSTNAME':
obj[key] = faker.person.firstName;
break;

case '**TEMPLATE_LASTNAME':
obj[key] = faker.person.firstName;
break;

case '**TEMPLATE_NATIONALITY':
obj[key] = faker.location.countryCode;
break;

case '**TEMPLATE_BIRTHPLACE':
obj[key] = faker.location.city;
break;

case '**TEMPLATE_COUNTRY':
obj[key] = faker.location.country;
break;

case '**TEMPLATE_PHONE':
obj[key] = faker.phone.number;
break;

case '**TEMPLATE_BIRTHDAY':
const start = new Date(1955, 0, 1);
const end = new Date(2012, 0, 1);
Expand Down
12 changes: 6 additions & 6 deletions shared/credentials/CitizenCredential.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"issuer": "PLACEHOLDER",
"credentialSubject": {
"id": "PLACEHOLDER",
"firstName": "Ben",
"lastName": "Utzer",
"firstName": "**TEMPLATE_FIRSTNAME",
"lastName": "**TEMPLATE_LASTNAME",
"date": "**TEMPLATE_BIRTHDAY",
"nationality": "german",
"birthplace": "Musterstadt",
"country": "Germany",
"phone": "00-0000"
"nationality": "**TEMPLATE_NATIONALITY",
"birthplace": "**TEMPLATE_BIRTHPLACE",
"country": "**TEMPLATE_COUNTRY",
"phone": "**TEMPLATE_PHONE"
}
},
"input_descriptors": [
Expand Down

0 comments on commit 643d2b3

Please sign in to comment.