File

src/crypto/key/dto/key-import.dto.ts

Description

DTO for importing a key.

Index

Properties

Properties

Optional crt
Type : string
Decorators :
@IsString()
@IsOptional()

Optional certificate in PEM format.

Optional description
Type : string
Decorators :
@IsString()
@IsOptional()

Description of the key.

privateKey
Type : Key
Decorators :
@ValidateNested()
@Type(undefined)

The private key in JWK format.

import { Type } from "class-transformer";
import { IsEnum, IsOptional, IsString, ValidateNested } from "class-validator";
import { JWK } from "jose";

class Key implements JWK {
    @IsString()
    kid: string; // Key ID
    @IsEnum(["EC"])
    kty: string; // Key Type
    @IsString()
    x: string; // X coordinate for EC keys
    @IsString()
    y: string; // Y coordinate for EC keys
    @IsString()
    crv: string; // Curve name for EC keys
    @IsString()
    d: string; // Private key value for EC keys
    @IsString()
    alg: string; // Algorithm used with the key
}

/**
 * DTO for importing a key.
 */
export class KeyImportDto {
    /**
     * The private key in JWK format.
     */
    @ValidateNested()
    @Type(() => Key)
    privateKey: Key;

    /**
     * Optional certificate in PEM format.
     */
    @IsString()
    @IsOptional()
    crt?: string;

    /**
     * Description of the key.
     */
    @IsString()
    @IsOptional()
    description?: string;
}

results matching ""

    No results matching ""