src/crypto/key/entities/keys.entity.ts
Properties |
|
| certificates |
Type : CertEntity[]
|
Decorators :
@OneToMany(undefined, cert => cert.key)
|
|
Defined in src/crypto/key/entities/keys.entity.ts:69
|
|
Certificates associated with this key. |
| createdAt |
Type : Date
|
Decorators :
@CreateDateColumn()
|
|
Defined in src/crypto/key/entities/keys.entity.ts:75
|
|
The timestamp when the key was created. |
| Optional description |
Type : string
|
Decorators :
@IsString()
|
|
Defined in src/crypto/key/entities/keys.entity.ts:35
|
|
Description of the key. |
| id |
Type : string
|
Decorators :
@IsString()
|
|
Defined in src/crypto/key/entities/keys.entity.ts:27
|
|
Unique identifier for the key. |
| key |
Type : JWK
|
Decorators :
@Column('text', {transformer: EncryptedJsonTransformer})
|
|
Defined in src/crypto/key/entities/keys.entity.ts:54
|
|
The key material. Encrypted at rest using AES-256-GCM. |
| tenant |
Type : TenantEntity
|
Decorators :
@ManyToOne(undefined, {cascade: true, onDelete: 'CASCADE'})
|
|
Defined in src/crypto/key/entities/keys.entity.ts:47
|
|
The tenant that owns this object. |
| tenantId |
Type : string
|
Decorators :
@Column('varchar', {primary: true})
|
|
Defined in src/crypto/key/entities/keys.entity.ts:41
|
|
Tenant ID for the key. |
| updatedAt |
Type : Date
|
Decorators :
@UpdateDateColumn()
|
|
Defined in src/crypto/key/entities/keys.entity.ts:81
|
|
The timestamp when the key was last updated. |
| usage |
Type : KeyUsage
|
Decorators :
@Column('varchar', {default: 'sign'})
|
|
Defined in src/crypto/key/entities/keys.entity.ts:60
|
|
The usage type of the key. |
import { IsOptional, IsString } from "class-validator";
import { JWK } from "jose";
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
OneToMany,
UpdateDateColumn,
} from "typeorm";
import { TenantEntity } from "../../../auth/tenant/entitites/tenant.entity";
import { EncryptedJsonTransformer } from "../../../shared/utils/encryption";
import { CertEntity } from "./cert.entity";
/**
* Key usage types.
*/
export type KeyUsage = "sign" | "encrypt";
@Entity()
export class KeyEntity {
/**
* Unique identifier for the key.
*/
@IsString()
@Column("varchar", { primary: true })
id!: string;
/**
* Description of the key.
*/
@IsString()
@IsOptional()
@Column("varchar", { nullable: true })
description?: string;
/**
* Tenant ID for the key.
*/
@Column("varchar", { primary: true })
tenantId!: string;
/**
* The tenant that owns this object.
*/
@ManyToOne(() => TenantEntity, { cascade: true, onDelete: "CASCADE" })
tenant!: TenantEntity;
/**
* The key material.
* Encrypted at rest using AES-256-GCM.
*/
@Column("text", { transformer: EncryptedJsonTransformer })
key!: JWK;
/**
* The usage type of the key.
*/
@Column("varchar", { default: "sign" })
usage!: KeyUsage;
/**
* Certificates associated with this key.
*/
@OneToMany(
() => CertEntity,
(cert) => cert.key,
)
certificates: CertEntity[];
/**
* The timestamp when the key was created.
*/
@CreateDateColumn()
createdAt!: Date;
/**
* The timestamp when the key was last updated.
*/
@UpdateDateColumn()
updatedAt!: Date;
}