This documentation is based on the KeyApiClient
class defined in src/data/client/key-api-client.ts
.
Fetches all keys.
- Request Parameters: None
- Response:
- Success (
200 OK
):- Returns an array of
KeyDTO
objects representing the keys.
- Returns an array of
- Success (
async get(): Promise<KeyDTO[]> {
return this.request<KeyDTO[]>('/api/keys', 'GET', { ecnryptedFields: [] }) as Promise<KeyDTO[]>;
}
Updates a key.
- Request Body:
PutKeyRequest
: AKeyDTO
object representing the key to be updated.
- Response:
- Success (
200 OK
):PutKeyResponseSuccess
: Contains a message, the updatedKeyDTO
object, and a status code.
- Error (
400 Bad Request
):PutKeyResponseError
: Contains an error message, status code, and optional issues.
- Success (
async put(key: PutKeyRequest): Promise<PutKeyResponse> {
return this.request<PutKeyResponse>('/api/keys', 'PUT', { ecnryptedFields: [] }, key) as Promise<PutKeyResponse>;
}
Deletes a key.
- Request Parameters:
keyLocatorHash
(Path): The locator hash of the key to be deleted.
- Response:
- Success (
200 OK
):PutKeyResponseSuccess
: Contains a message and a status code.
- Error (
400 Bad Request
):PutKeyResponseError
: Contains an error message, status code, and optional issues.
- Success (
async delete(keyLocatorHash: string): Promise<PutKeyResponse> {
return this.request<PutKeyResponse>('/api/keys/' + keyLocatorHash, 'DELETE', { ecnryptedFields: [] }) as Promise<PutKeyResponse>;
}
Represents a key in the system.
export interface KeyDTO {
id: number;
name: string;
value: string;
createdAt: string;
updatedAt: string;
}
A KeyDTO
object representing the key to be updated.
export type PutKeyRequest = KeyDTO;
Represents a successful response for updating a key.
export type PutKeyResponseSuccess = {
message: string;
data: KeyDTO;
status: 200;
};
Represents an error response for updating a key.
export type PutKeyResponseError = {
message: string;
status: 400;
issues?: ZodIssue[];
};
A union type of PutKeyResponseSuccess
and PutKeyResponseError
.
export type PutKeyResponse = PutKeyResponseSuccess | PutKeyResponseError;
For more details, see the source code.