| 1 | import { ApiProperty } from '@nestjs/swagger'; |
| 2 | import { IsString, MaxLength |
| 3 | |
| 4 | /** Armor for a 4096-bit key with a few user ids still fits well inside this. */ |
| 5 | export const MAX_PUBLIC_KEY_LENGTH = |
| 6 | |
| 7 | export class AddGpgKeyDTO |
| 8 | @ApiProperty({ |
| 9 | description: |
| 10 | 'Armored OpenPGP public key, as `gpg --armor --export` prints it.', |
| 11 | example: '-----BEGIN PGP PUBLIC KEY BLOCK-----\n...', |
| 12 | maxLength: MAX_PUBLIC_KEY_LENGTH, |
| 13 | }) |
| 14 | @IsString() |
| 15 | @MaxLength(MAX_PUBLIC_KEY_LENGTH) |
| 16 | publicKey: string; |
| 17 | } |
| 18 | |
| 19 | export class GpgKeyDTO |
| 20 | @ApiProperty() |
| 21 | id: string; |
| 22 | |
| 23 | @ApiProperty({ |
| 24 | description: 'Long key id, lowercase hex. Signatures name this.', |
| 25 | }) |
| 26 | keyId: string; |
| 27 | |
| 28 | @ApiProperty({ description |
| 29 | fingerprint: string; |
| 30 | |
| 31 | @ApiProperty({ |
| 32 | type: [String], |
| 33 | description: "Addresses the key's user ids claim.", |
| 34 | }) |
| 35 | emails: string[] |
| 36 | |
| 37 | @ApiProperty({ description |
| 38 | createdAt: string; |
| 39 | } |
| 40 | |
| 41 | export class ListGpgKeysResponseDTO |
| 42 | @ApiProperty({ type |
| 43 | keys: GpgKeyDTO |
| 44 | } |