TokenGenerator/src/app/pages/decrypt/decrypt.component.ts
2022-11-30 02:36:36 +10:00

42 lines
1.1 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import {HttpClient, HttpHeaders} from "@angular/common/http";
import {IWrap} from "../../models/ResponseToken";
import {IResponseData} from "../../models/ResponseData";
@Component({
selector: 'app-decrypt',
templateUrl: './decrypt.component.html',
styleUrls: ['./decrypt.component.scss']
})
export class DecryptComponent implements OnInit {
constructor(private http: HttpClient) { }
api_endpoint: string = 'http://vault.vdk2ch.ru:8200/v1/sys/wrapping/unwrap';
tokenToSend:string = '';
response: any
receivedValue: string = ''
outUnwrap(){
this.getUnwrap(this.tokenToSend).subscribe(response => {
this.response = response.data;
this.receivedValue = response.data.body.token;
})
}
getUnwrap(token: string){
let body = new URLSearchParams();
body.set("token", token)
let headers: HttpHeaders = new HttpHeaders();
headers = headers.append('X-Vault-Token', 'vdk2ch');
headers = headers.append('Content-Type', 'application/x-www-form-urlencoded')
return this.http.post<IResponseData>(this.api_endpoint , body, {headers})
}
ngOnInit(): void {
}
}