diff options
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/credential.service.ts | 8 | ||||
-rw-r--r-- | src/app/edit-identity/edit-identity.component.ts | 36 | ||||
-rw-r--r-- | src/app/nonceparams.ts | 4 | ||||
-rw-r--r-- | src/app/pabc.service.ts | 28 |
4 files changed, 75 insertions, 1 deletions
diff --git a/src/app/credential.service.ts b/src/app/credential.service.ts index 9ae5a22..df831e6 100644 --- a/src/app/credential.service.ts +++ b/src/app/credential.service.ts | |||
@@ -90,4 +90,12 @@ export class CredentialService { | |||
90 | getIssuerName(cred: Credential) { | 90 | getIssuerName(cred: Credential) { |
91 | return this.mapIssuerName(cred.name); | 91 | return this.mapIssuerName(cred.name); |
92 | } | 92 | } |
93 | |||
94 | getIssuerPicture(cred: Credential): string { | ||
95 | let name = this.mapIssuerName(cred.name); | ||
96 | if (name == cred.name) { | ||
97 | return null; | ||
98 | } | ||
99 | return "assets/" + name.replace(" ", "-").toLowerCase() + ".png"; | ||
100 | } | ||
93 | } | 101 | } |
diff --git a/src/app/edit-identity/edit-identity.component.ts b/src/app/edit-identity/edit-identity.component.ts index c9778bc..21801dc 100644 --- a/src/app/edit-identity/edit-identity.component.ts +++ b/src/app/edit-identity/edit-identity.component.ts | |||
@@ -17,6 +17,7 @@ import { LanguageService } from '../language.service'; | |||
17 | import { IdProvider } from '../idProvider'; | 17 | import { IdProvider } from '../idProvider'; |
18 | import { Scope } from '../scope'; | 18 | import { Scope } from '../scope'; |
19 | import { OAuthService, LoginOptions } from 'angular-oauth2-oidc'; | 19 | import { OAuthService, LoginOptions } from 'angular-oauth2-oidc'; |
20 | import { PabcService } from '../pabc.service'; | ||
20 | 21 | ||
21 | @Component({ | 22 | @Component({ |
22 | selector: 'app-edit-identity', | 23 | selector: 'app-edit-identity', |
@@ -72,6 +73,7 @@ export class EditIdentityComponent implements OnInit { | |||
72 | private languageService: LanguageService, | 73 | private languageService: LanguageService, |
73 | private credentialService: CredentialService, | 74 | private credentialService: CredentialService, |
74 | private oauthService: OAuthService, | 75 | private oauthService: OAuthService, |
76 | private pabcService: PabcService, | ||
75 | private router: Router,) {} | 77 | private router: Router,) {} |
76 | 78 | ||
77 | ngOnInit() { | 79 | ngOnInit() { |
@@ -618,7 +620,39 @@ export class EditIdentityComponent implements OnInit { | |||
618 | break; | 620 | break; |
619 | } | 621 | } |
620 | } | 622 | } |
621 | this.importAttributesFromCredential(); | 623 | /** |
624 | * Check for privacy credential support | ||
625 | */ | ||
626 | let grantedScopes = this.oauthService.getGrantedScopes(); | ||
627 | if (!Array.isArray(grantedScopes) || | ||
628 | !grantedScopes.includes("pabc")) { | ||
629 | this.importAttributesFromCredential(); | ||
630 | return; | ||
631 | } | ||
632 | console.log("Privacy credentials supported. Trying..."); | ||
633 | this.pabcService.getNonceFromIssuer(this.oauthService | ||
634 | .issuer).subscribe(nonceParams => { | ||
635 | console.log("Got metadata: " + JSON.stringify(nonceParams)); | ||
636 | /* Get credential request */ | ||
637 | let crMetadata = { | ||
638 | nonce: nonceParams.nonce, | ||
639 | public_params: nonceParams.public_params, | ||
640 | issuer: this.oauthService.issuer, | ||
641 | id_token: this.oauthService.getIdToken(), | ||
642 | identity: this.identity | ||
643 | } | ||
644 | this.pabcService.getCredentialRequest(crMetadata).subscribe(cr => { | ||
645 | console.log("Got CR: " + JSON.stringify (cr)); | ||
646 | this.pabcService.getPrivacyCredential(this.oauthService.issuer, | ||
647 | cr).subscribe(cred => { | ||
648 | console.log("Got Credential: " + JSON.stringify (cred)); | ||
649 | this.newCredential.value = cred; | ||
650 | this.newCredential.name = this.importIdProvider.name + "pabc"; | ||
651 | this.newCredential.type = 'pabc'; | ||
652 | this.importAttributesFromCredential(); | ||
653 | }); | ||
654 | }); | ||
655 | }); | ||
622 | } | 656 | } |
623 | 657 | ||
624 | private tryImportCredential() { | 658 | private tryImportCredential() { |
diff --git a/src/app/nonceparams.ts b/src/app/nonceparams.ts new file mode 100644 index 0000000..f5f155f --- /dev/null +++ b/src/app/nonceparams.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export class NonceParams { | ||
2 | constructor(public nonce: string, | ||
3 | public public_params: string) {} | ||
4 | } | ||
diff --git a/src/app/pabc.service.ts b/src/app/pabc.service.ts new file mode 100644 index 0000000..b3f15d7 --- /dev/null +++ b/src/app/pabc.service.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
2 | import { Injectable } from '@angular/core'; | ||
3 | import { Observable } from 'rxjs'; | ||
4 | |||
5 | import { NonceParams } from './nonceparams'; | ||
6 | import { ConfigService } from './config.service'; | ||
7 | import { Identity } from './identity'; | ||
8 | |||
9 | @Injectable() | ||
10 | export class PabcService { | ||
11 | |||
12 | constructor(private http: HttpClient, private config: ConfigService) { } | ||
13 | |||
14 | getNonceFromIssuer(issuer: string): Observable<NonceParams> { | ||
15 | return this.http.get<NonceParams>(issuer + '/pabc'); | ||
16 | } | ||
17 | |||
18 | getPrivacyCredential(issuer: string, cr: object): Observable<any> { | ||
19 | return this.http.post<any>(issuer + '/pabc/cr', cr); | ||
20 | } | ||
21 | |||
22 | |||
23 | getCredentialRequest(crMetadata: object) { | ||
24 | return this.http.post<any>(this.config.get().apiUrl + | ||
25 | '/pabc/cr', crMetadata); | ||
26 | } | ||
27 | |||
28 | } | ||