1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-19 10:54:00 +00:00

Add get other user's keys endpoint

This commit is contained in:
Bernd Schoolmann
2025-05-19 11:29:25 +02:00
parent 54a69aac32
commit 99454812e5
7 changed files with 63 additions and 12 deletions

View File

@@ -0,0 +1,15 @@
import { VerifyingKey } from "@bitwarden/key-management";
import { SignedPublicKeyOwnershipClaim } from "../../types";
export class PublicAccountKeysResponseModel {
readonly VerifyingKey: VerifyingKey;
readonly PublicKey: string;
readonly SignedPublicKeyOwnershipClaim: SignedPublicKeyOwnershipClaim;
constructor(response: any) {
this.VerifyingKey = new VerifyingKey(response.verifyingKey, response.verifyingKeyAlgorithm);
this.PublicKey = response.publicKey;
this.SignedPublicKeyOwnershipClaim = response.signedPublicKeyOwnershipClaim;
}
}

View File

@@ -0,0 +1,5 @@
import { PublicAccountKeysResponseModel } from "../../response/public-account-keys.response";
export class KeyApiService {
getUserPublicKeys: (id: string) => Promise<PublicAccountKeysResponseModel>;
}

View File

@@ -0,0 +1,13 @@
import { ApiService } from "../../../abstractions/api.service";
import { PublicAccountKeysResponseModel } from "../response/public-account-keys.response";
import { KeyApiService } from "./abstractions/key-api-service.abstraction";
export class DefaultKeyApiService implements KeyApiService {
constructor(private apiService: ApiService) {}
async getUserPublicKeys(id: string): Promise<PublicAccountKeysResponseModel> {
const r = await this.apiService.send("GET", "/users/" + id + "/keys", null, true, true);
return new PublicAccountKeysResponseModel(r);
}
}