gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 454/459: start pabc work


From: gnunet
Subject: [reclaim-ui] 454/459: start pabc work
Date: Fri, 11 Jun 2021 23:29:06 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.

commit 1141adfbc9750d9f4b8f445ff3900ada56db6dba
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Tue Apr 20 10:48:37 2021 +0200

    start pabc work
---
 src/app/credential.service.ts                    |  8 ++++++
 src/app/edit-identity/edit-identity.component.ts | 36 +++++++++++++++++++++++-
 src/app/nonceparams.ts                           |  4 +++
 src/app/pabc.service.ts                          | 28 ++++++++++++++++++
 4 files changed, 75 insertions(+), 1 deletion(-)

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 {
     getIssuerName(cred: Credential) {
       return this.mapIssuerName(cred.name);
     }
+
+    getIssuerPicture(cred: Credential): string {
+      let name = this.mapIssuerName(cred.name);
+      if (name == cred.name) {
+        return null;
+      }
+      return "assets/" + name.replace(" ", "-").toLowerCase() + ".png";
+    }
 }
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';
 import { IdProvider } from '../idProvider';
 import { Scope } from '../scope';
 import { OAuthService, LoginOptions } from 'angular-oauth2-oidc';
+import { PabcService } from '../pabc.service';
 
 @Component({
   selector: 'app-edit-identity',
@@ -72,6 +73,7 @@ export class EditIdentityComponent implements OnInit {
               private languageService: LanguageService,
               private credentialService: CredentialService,
               private oauthService: OAuthService,
+              private pabcService: PabcService,
               private router: Router,) {}
 
   ngOnInit() {
@@ -618,7 +620,39 @@ export class EditIdentityComponent implements OnInit {
         break;
       }
     }
-    this.importAttributesFromCredential();
+    /**
+     * Check for privacy credential support
+     */
+    let grantedScopes = this.oauthService.getGrantedScopes();
+    if (!Array.isArray(grantedScopes) ||
+        !grantedScopes.includes("pabc")) {
+      this.importAttributesFromCredential();
+      return;
+    }
+    console.log("Privacy credentials supported. Trying...");
+    this.pabcService.getNonceFromIssuer(this.oauthService
+                                        .issuer).subscribe(nonceParams => {
+      console.log("Got metadata: " + JSON.stringify(nonceParams));
+      /* Get credential request */
+      let crMetadata = {
+        nonce: nonceParams.nonce,
+        public_params: nonceParams.public_params,
+        issuer: this.oauthService.issuer,
+        id_token: this.oauthService.getIdToken(),
+        identity: this.identity
+      }
+      this.pabcService.getCredentialRequest(crMetadata).subscribe(cr => {
+        console.log("Got CR: " + JSON.stringify (cr));
+        this.pabcService.getPrivacyCredential(this.oauthService.issuer,
+                                              cr).subscribe(cred => {
+          console.log("Got Credential: " + JSON.stringify (cred));
+          this.newCredential.value = cred;
+          this.newCredential.name = this.importIdProvider.name + "pabc";
+          this.newCredential.type = 'pabc';
+          this.importAttributesFromCredential();
+        });
+      });
+    });
   }
 
   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 @@
+export class NonceParams {
+  constructor(public nonce: string,
+              public public_params: string) {}
+}
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 @@
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+
+import { NonceParams } from './nonceparams';
+import { ConfigService } from './config.service';
+import { Identity } from './identity';
+
+@Injectable()
+export class PabcService {
+
+  constructor(private http: HttpClient, private config: ConfigService) { }
+
+  getNonceFromIssuer(issuer: string): Observable<NonceParams> {
+    return this.http.get<NonceParams>(issuer + '/pabc');
+  }
+
+  getPrivacyCredential(issuer: string, cr: object): Observable<any> {
+    return this.http.post<any>(issuer + '/pabc/cr', cr);
+  }
+
+
+  getCredentialRequest(crMetadata: object) {
+    return this.http.post<any>(this.config.get().apiUrl +
+      '/pabc/cr', crMetadata);
+  }
+
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]