diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7c08fc4..2f93cb3 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -9,7 +9,10 @@ const routes: Routes = [ then(m => m.PresentationDefinitionModule )}, { path: 'siop', loadChildren: () => import('./features/siop/siop.module'). - then(m => m.SIOPModule )} + then(m => m.SIOPModule )}, + { path: 'cbor', + loadChildren: () => import('./features/cbor/cbor.module'). + then(m => m.CborModule )} ]; @NgModule({ diff --git a/src/app/core/data/pid_presentation_definition.ts b/src/app/core/data/pid_presentation_definition.ts new file mode 100644 index 0000000..c29b9b8 --- /dev/null +++ b/src/app/core/data/pid_presentation_definition.ts @@ -0,0 +1,210 @@ +export const PID_PRESENTATION_DEFINITION = { + 'type': 'vp_token', + 'presentation_definition': { + 'id': '32f54163-7166-48f1-93d8-ff217bdb0653', + 'input_descriptors': [ + { + 'id': 'eudi_pid', + 'name': 'EUDI PID', + 'purpose': 'We need to verify your identity', + 'constraints': { + 'fields': [ + { + 'path': [ + '$.mdoc.doctype' + ], + 'filter': { + 'type': 'string', + 'const': 'eu.europa.ec.eudiw.pid.1' + } + }, + { + 'path': [ + '$.mdoc.namespace' + ], + 'filter': { + 'type': 'string', + 'const': 'eu.europa.ec.eudiw.pid.1' + } + }, + { + 'path': [ + '$.mdoc.family_name' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.given_name' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.birth_date' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.age_over_18' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.age_in_years' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.age_birth_year' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.unique_id' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.family_name_birth' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.given_name_birth' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.birth_place' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.birth_country' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.birth_state' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.birth_city' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_address' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_country' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_state' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_city' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_postal_code' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_street' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.resident_house_number' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.gender' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.nationality' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.issuance_date' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.expiry_date' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.issuing_authority' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.document_number' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.administrative_number' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.issuing_country' + ], + 'intent_to_retain': false + }, + { + 'path': [ + '$.mdoc.issuing_jurisdiction' + ], + 'intent_to_retain': false + } + ] + } + } + ] + }, + 'nonce' : 'nonce' +}; diff --git a/src/app/core/services/online-authentication-siop.service.ts b/src/app/core/services/online-authentication-siop.service.ts index c43b4ee..f663a21 100644 --- a/src/app/core/services/online-authentication-siop.service.ts +++ b/src/app/core/services/online-authentication-siop.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { HttpService } from '../network/http/http.service'; import { PresentationDefinitionResponse } from '../models/presentation-definition-response'; +import { PID_PRESENTATION_DEFINITION } from '../data/pid_presentation_definition'; @Injectable() export class OnlineAuthenticationSIOPService { @@ -19,4 +20,12 @@ export class OnlineAuthenticationSIOPService { return this.httpService.post ('ui/presentations', dataRequest,); } + initCborTransaction (): Observable { + // const dataRequest = { + // 'type': 'id_token', + // 'id_token_type': 'subject_signed_id_token', + // 'nonce': 'nonce' + // }; + return this.httpService.post('ui/presentations', PID_PRESENTATION_DEFINITION); + } } diff --git a/src/app/features/cbor/cbor-routing.module.ts b/src/app/features/cbor/cbor-routing.module.ts new file mode 100644 index 0000000..a0c733d --- /dev/null +++ b/src/app/features/cbor/cbor-routing.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { HomeComponent } from './home/home.component'; + +const routes: Routes = [ + { + path: '', + component: HomeComponent, + children: [ + { + path: '', + loadComponent: () => import('../verifiable-credential/components/qr-code/qr-code.component').then(c => c.QrCodeComponent) + } + ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class CborRoutingModule { } diff --git a/src/app/features/cbor/cbor.module.ts b/src/app/features/cbor/cbor.module.ts new file mode 100644 index 0000000..3038766 --- /dev/null +++ b/src/app/features/cbor/cbor.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { CborRoutingModule } from './cbor-routing.module'; +import { HomeComponent } from './home/home.component'; +import { LayoutComponent } from '@app/core/layout/layout/layout.component'; + + +@NgModule({ + declarations: [ + HomeComponent + ], + imports: [ + CommonModule, + LayoutComponent, + CborRoutingModule + ] +}) +export class CborModule { } diff --git a/src/app/features/cbor/home/home.component.html b/src/app/features/cbor/home/home.component.html new file mode 100644 index 0000000..dd86287 --- /dev/null +++ b/src/app/features/cbor/home/home.component.html @@ -0,0 +1,4 @@ + +

OID4VP + CBOR

+ +
diff --git a/src/app/features/cbor/home/home.component.spec.ts b/src/app/features/cbor/home/home.component.spec.ts new file mode 100644 index 0000000..5075be7 --- /dev/null +++ b/src/app/features/cbor/home/home.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HomeComponent } from './home.component'; + +describe('HomeComponent', () => { + let component: HomeComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ HomeComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(HomeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/features/cbor/home/home.component.ts b/src/app/features/cbor/home/home.component.ts new file mode 100644 index 0000000..af5dbac --- /dev/null +++ b/src/app/features/cbor/home/home.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'vc-home', + templateUrl: './home.component.html' +}) +export class HomeComponent { + +} diff --git a/src/app/features/home/components/home/home.component.ts b/src/app/features/home/components/home/home.component.ts index 54ee698..82d3550 100644 --- a/src/app/features/home/components/home/home.component.ts +++ b/src/app/features/home/components/home/home.component.ts @@ -32,7 +32,7 @@ export class HomeComponent { { key: 'OID4VP_CBOR', value: 'OID4VP + CBOR', - isDisabled: true, + isDisabled: false, }, { key: 'OID4VP_C', @@ -45,7 +45,7 @@ export class HomeComponent { if (choose === 'SIOP') { this.navPath = 'siop'; } else if (choose === 'OID4VP_CBOR') { - this.navPath = 'OID4VP_CBOR'; + this.navPath = 'cbor'; } else if (choose === 'OID4VP_C') { this.navPath = '/presentation'; } @@ -59,6 +59,11 @@ export class HomeComponent { this.dataService.setQRCode(data); this.navigateService.navigateTo(this.navPath); }); + } else if(this.navPath === 'cbor') { + this.onlineAuthenticationSIOPService.initCborTransaction().subscribe((data) => { + this.dataService.setQRCode(data); + this.navigateService.navigateTo(this.navPath); + }); } } }