diff --git a/src/app/settings/api-key.component.html b/src/app/settings/api-key.component.html index 8e042aa6..663ce687 100644 --- a/src/app/settings/api-key.component.html +++ b/src/app/settings/api-key.component.html @@ -35,6 +35,10 @@ icon="bwi bwi-key" *ngIf="clientSecret" > +

+ combined: + {{ combinedApiKey }} +

client_id:
{{ clientId }} diff --git a/src/app/settings/api-key.component.ts b/src/app/settings/api-key.component.ts index fd1eec7e..f5f26165 100644 --- a/src/app/settings/api-key.component.ts +++ b/src/app/settings/api-key.component.ts @@ -1,7 +1,9 @@ -import { Component } from "@angular/core"; +import { Component, OnInit } from "@angular/core"; +import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { LogService } from "jslib-common/abstractions/log.service"; import { UserVerificationService } from "jslib-common/abstractions/userVerification.service"; +import { Utils } from "jslib-common/misc/utils"; import { SecretVerificationRequest } from "jslib-common/models/request/secretVerificationRequest"; import { ApiKeyResponse } from "jslib-common/models/response/apiKeyResponse"; import { Verification } from "jslib-common/types/verification"; @@ -10,7 +12,7 @@ import { Verification } from "jslib-common/types/verification"; selector: "app-api-key", templateUrl: "api-key.component.html", }) -export class ApiKeyComponent { +export class ApiKeyComponent implements OnInit { keyType: string; isRotation: boolean; postKey: (entityId: string, request: SecretVerificationRequest) => Promise; @@ -25,12 +27,20 @@ export class ApiKeyComponent { formPromise: Promise; clientId: string; clientSecret: string; + clientKey: string; + clientLocalKeyHash: string; constructor( + private cryptoService: CryptoService, private userVerificationService: UserVerificationService, private logService: LogService ) {} + async ngOnInit(): Promise { + this.clientKey = Utils.fromBufferToB64((await this.cryptoService.getKey()).key); + this.clientLocalKeyHash = await this.cryptoService.getKeyHash(); + } + async submit() { try { this.formPromise = this.userVerificationService @@ -43,4 +53,17 @@ export class ApiKeyComponent { this.logService.error(e); } } + + get combinedApiKey() { + return Utils.fromUtf8ToB64( + JSON.stringify({ + clientId: this.clientId, + clientSecret: this.clientSecret, + encClientEncInfo: JSON.stringify({ + clientEncKey: this.clientKey, + clientLocalKeyHash: this.clientLocalKeyHash, + }), + }) + ); + } }