add api service
This commit is contained in:
parent
bacb7cd7a0
commit
6f169534ca
|
@ -0,0 +1,8 @@
|
|||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||
|
||||
export abstract class UserAsymmetricKeysRegenerationApiService {
|
||||
abstract regenerateUserAsymmetricKeys: (
|
||||
userPublicKey: string,
|
||||
userKeyEncryptedUserPrivateKey: EncString,
|
||||
) => Promise<void>;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||
|
||||
export class KeyRegenerationRequest {
|
||||
userPublicKey: string;
|
||||
userKeyEncryptedUserPrivateKey: EncString;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||
|
||||
import { UserAsymmetricKeysRegenerationApiService } from "../abstractions/user-asymmetric-key-regeneration-api.service";
|
||||
import { KeyRegenerationRequest } from "../models/requests/key-regeneration.request";
|
||||
|
||||
export class DefaultUserAsymmetricKeysRegenerationApiService
|
||||
implements UserAsymmetricKeysRegenerationApiService
|
||||
{
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async regenerateUserAsymmetricKeys(
|
||||
userPublicKey: string,
|
||||
userKeyEncryptedUserPrivateKey: EncString,
|
||||
): Promise<void> {
|
||||
const request: KeyRegenerationRequest = {
|
||||
userPublicKey,
|
||||
userKeyEncryptedUserPrivateKey,
|
||||
};
|
||||
|
||||
await this.apiService.send(
|
||||
"POST",
|
||||
"/accounts/key-management/regenerate-keys",
|
||||
request,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue