@veramo/data-store
Version:
Veramo data storage plugin based on TypeORM database drivers
57 lines (49 loc) • 1.51 kB
text/typescript
import { KeyMetadata, TKeyType } from '@veramo/core-types'
import { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne, Relation } from 'typeorm'
import { Identifier } from './identifier.js'
/**
* Mirrors {@link @veramo/core-types#TKeyType | TKeyType}
*
* @beta - This API may change without a BREAKING CHANGE notice.
*/
export type KeyType = TKeyType
/**
* Represents some properties of a {@link @veramo/core-types#IKey | IKey} that are stored in a TypeORM
* database for the purpose of keeping track of the {@link @veramo/key-manager#AbstractKeyManagementSystem}
* implementations and the keys they are able to use.
*
* @see {@link @veramo/data-store#KeyStore | KeyStore} for the implementation used by the
* {@link @veramo/key-manager#KeyManager | KeyManager}.
*
* @beta This API may change without a BREAKING CHANGE notice.
*/
('key')
export class Key extends BaseEntity {
()
// @ts-ignore
kid: string
()
// @ts-ignore
kms: string
()
// @ts-ignore
type: KeyType
()
// @ts-ignore
publicKeyHex: string
({
type: 'simple-json',
nullable: true,
transformer: {
to: (value: any): KeyMetadata | null => {
return value
},
from: (value: KeyMetadata | null): object | null => {
return value
},
},
})
meta?: KeyMetadata | null
((type) => Identifier, (identifier) => identifier?.keys, { onDelete: 'CASCADE' })
identifier?: Relation<Identifier>
}