aboutsummaryrefslogtreecommitdiff
path: root/src/app/pabc.service.ts
blob: 5eb345f199b07a110feb2fb94eb0b5e0d984850a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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, at: string): Observable<NonceParams> {
    const httpHeaders: HttpHeaders = new HttpHeaders({
    Authorization: 'Bearer ' + at
});
    return this.http.get<NonceParams>(issuer + '/pabc', { headers: httpHeaders });
  }

  getPrivacyCredential(issuer: string, cr: object, at: string): Observable<any> {
    const httpHeaders: HttpHeaders = new HttpHeaders({
    Authorization: 'Bearer ' + at
});
    return this.http.post<any>(issuer + '/pabc/cr', cr, { headers: httpHeaders });
  }


  getCredentialRequest(crMetadata: object) {
    return this.http.post<any>(this.config.get().apiUrl +
      '/pabc/cr', crMetadata);
  }

}