src/crypto/key/key.controller.ts
key
KeyController is responsible for managing keys in the system.
Methods |
| Async addKey | |||||||||
addKey(token: TokenPayload, body: KeyImportDto)
|
|||||||||
Decorators :
@Post()
|
|||||||||
|
Defined in src/crypto/key/key.controller.ts:60
|
|||||||||
|
Add a new key to the key service.
Parameters :
Returns :
Promise<literal type>
|
| deleteKey | |||||||||
deleteKey(token: TokenPayload, id: string)
|
|||||||||
Decorators :
@Delete(':id')
|
|||||||||
|
Defined in src/crypto/key/key.controller.ts:89
|
|||||||||
|
Delete a key from the key service.
Parameters :
Returns :
any
|
| getKey | |||||||||
getKey(token: TokenPayload, id: string)
|
|||||||||
Decorators :
@Get(':id')
|
|||||||||
|
Defined in src/crypto/key/key.controller.ts:46
|
|||||||||
|
Get a specific key by ID
Parameters :
Returns :
Promise<KeyEntity>
|
| getKeys | ||||||
getKeys(token: TokenPayload)
|
||||||
Decorators :
@Get()
|
||||||
|
Defined in src/crypto/key/key.controller.ts:35
|
||||||
|
Get all keys for the tenant.
Parameters :
Returns :
Promise<KeyEntity[]>
|
| Async updateKey | ||||||||||||
updateKey(token: TokenPayload, id: string, body: UpdateKeyDto)
|
||||||||||||
Decorators :
@Put(':id')
|
||||||||||||
|
Defined in src/crypto/key/key.controller.ts:75
|
||||||||||||
|
Updates an existing key in the key service.
Parameters :
Returns :
Promise<void>
|
import {
Body,
Controller,
Delete,
Get,
Inject,
Param,
Post,
Put,
} from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { Role } from "../../auth/roles/role.enum";
import { Secured } from "../../auth/secure.decorator";
import { Token, TokenPayload } from "../../auth/token.decorator";
import { KeyImportDto } from "./dto/key-import.dto";
import { UpdateKeyDto } from "./dto/key-update.dto";
import { KeyEntity } from "./entities/keys.entity";
import { KeyService } from "./key.service";
/**
* KeyController is responsible for managing keys in the system.
*/
@ApiTags("Key")
@Secured([Role.Issuances, Role.Presentations])
@Controller("key")
export class KeyController {
constructor(@Inject("KeyService") public readonly keyService: KeyService) {}
/**
* Get all keys for the tenant.
* @param token
* @returns
*/
@Get()
getKeys(@Token() token: TokenPayload): Promise<KeyEntity[]> {
return this.keyService.getKeys(token.entity!.id);
}
/**
* Get a specific key by ID
* @param token
* @param id
* @returns
*/
@Get(":id")
getKey(
@Token() token: TokenPayload,
@Param("id") id: string,
): Promise<KeyEntity> {
return this.keyService.getKey(token.entity!.id, id);
}
/**
* Add a new key to the key service.
* @param token
* @param body
* @returns
*/
@Post()
async addKey(
@Token() token: TokenPayload,
@Body() body: KeyImportDto,
): Promise<{ id: string }> {
const id = await this.keyService.import(token.entity!.id, body);
return { id };
}
/**
* Updates an existing key in the key service.
* @param token
* @param id
* @param body
*/
@Put(":id")
async updateKey(
@Token() token: TokenPayload,
@Param("id") id: string,
@Body() body: UpdateKeyDto,
): Promise<void> {
await this.keyService.update(token.entity!.id, id, body);
}
/**
* Delete a key from the key service.
* @param token
* @param id
*/
@Delete(":id")
deleteKey(@Token() token: TokenPayload, @Param("id") id: string) {
return this.keyService.deleteKey(token.entity!.id, id);
}
}