File

src/crypto/key/key.service.ts

Description

Generic interface for a key service

Index

Methods

Methods

Abstract getKid
getKid(tenantId: string)

Get the key id

Parameters :
Name Type Optional
tenantId string No
Returns : Promise<string>
Abstract getPublicKey
getPublicKey(type, tenantId: string)

Get the public key

Parameters :
Name Type Optional
type No
tenantId string No
Returns : Promise<JWK>
Abstract getPublicKey
getPublicKey(type, tenantId: string)
Parameters :
Name Type Optional
type No
tenantId string No
Returns : Promise<string>
Abstract getPublicKey
getPublicKey(type: "pem" | "jwk", tenantId: string)
Parameters :
Name Type Optional
type "pem" | "jwk" No
tenantId string No
Returns : Promise<JWK | string>
Abstract init
init(tenantId)

Initialize the key service

Parameters :
Name Optional
tenantId No
Returns : Promise<void>
Abstract signer
signer(tenantId: string)

Get the callback for the signer function

Parameters :
Name Type Optional
tenantId string No
Returns : Promise<Signer>
Abstract signJWT
signJWT(payload: JWTPayload, header: JoseHeaderParameters, tenantId: string)
Parameters :
Name Type Optional
payload JWTPayload No
header JoseHeaderParameters No
tenantId string No
Returns : Promise<string>
import { Signer } from '@sd-jwt/types';
import { JWK, JWTPayload, JoseHeaderParameters } from 'jose';

/**
 * Generic interface for a key service
 */
export abstract class KeyService {
    /**
     * Initialize the key service
     */
    abstract init(tenantId): Promise<void>;

    /**
     * Get the callback for the signer function
     * @param tenantId
     */
    abstract signer(tenantId: string): Promise<Signer>;

    /**
     * Get the key id
     * @returns
     */
    abstract getKid(tenantId: string): Promise<string>;

    /**
     * Get the public key
     * @returns
     */
    abstract getPublicKey(type: 'jwk', tenantId: string): Promise<JWK>;
    abstract getPublicKey(type: 'pem', tenantId: string): Promise<string>;
    abstract getPublicKey(
        type: 'pem' | 'jwk',
        tenantId: string,
    ): Promise<JWK | string>;

    //TODO: this can be handled via the signer callback
    abstract signJWT(
        payload: JWTPayload,
        header: JoseHeaderParameters,
        tenantId: string,
    ): Promise<string>;
}

results matching ""

    No results matching ""