UNPKG

@citrineos/certificates

Version:

The certificates module for OCPP v2.0.1. This module is not intended to be used directly, but rather as a dependency for other modules.

70 lines (69 loc) 3.61 kB
import { AbstractModuleApi, IFileStorage, Namespace, OCPP1_6_Namespace, OCPP2_0_1_Namespace, WebsocketServerConfig } from '@citrineos/base'; import { FastifyInstance, FastifyRequest } from 'fastify'; import { ILogObj, Logger } from 'tslog'; import { ICertificatesModuleApi } from './interface'; import { CertificatesModule } from './module'; import { WebsocketNetworkConnection } from '@citrineos/util'; import { Certificate, GenerateCertificateChainRequest, InstallRootCertificateRequest, TlsCertificatesRequest, UpdateTlsCertificateQueryString } from '@citrineos/data'; /** * Server API for the Certificates module. */ export declare class CertificatesDataApi extends AbstractModuleApi<CertificatesModule> implements ICertificatesModuleApi { private readonly _networkConnection; private readonly _websocketServersConfig; private readonly _fileStorage; /** * Constructs a new instance of the class. * * @param {CertificatesModule} certificatesModule - The Certificates module. * @param {FastifyInstance} server - The Fastify server instance. * @param {IFileStorage} fileStorage - The fileStorage * @param {WebsocketNetworkConnection} networkConnection - The NetworkConnection * @param {WebsocketServerConfig[]} websocketServersConfig - Configuration for websocket servers * @param {Logger<ILogObj>} [logger] - The logger instance. */ constructor(certificatesModule: CertificatesModule, server: FastifyInstance, fileStorage: IFileStorage, networkConnection: WebsocketNetworkConnection, websocketServersConfig: WebsocketServerConfig[], logger?: Logger<ILogObj>); putTlsCertificates(request: FastifyRequest<{ Body: TlsCertificatesRequest; Querystring: UpdateTlsCertificateQueryString; }>): Promise<void>; /** * This endpoint is used to create certificate chain, root CA, sub CA and leaf certificate * * @param request - GenerateRootCertificatesRequest * @return Promise<Certificate[]> - An array of generated certificates */ generateCertificateChain(request: FastifyRequest<{ Body: GenerateCertificateChainRequest; }>): Promise<Certificate[]>; installRootCertificate(request: FastifyRequest<{ Body: InstallRootCertificateRequest; }>): Promise<void>; /** * Overrides superclass method to generate the URL path based on the input {@link Namespace} * and the module's endpoint prefix configuration. * * @param {Namespace} input - The input {@link Namespace}. * @return {string} - The generated URL path. */ protected _toDataPath(input: OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace): string; private _replaceFile; private _updateCertificates; /** * Generates a sub CA certificate signed by a CA server. * * @param {Certificate} certificate - The certificate information used for generating the root certificate. * @return {Promise<[string, string]>} An array containing the signed certificate and the private key. */ private _generateSubCACertificateSignedByCAServer; /** * Store certificate in file storage and db. * @param certificateEntity certificate to be stored in db * @param certPem certificate pem to be stored in file storage * @param keyPem private key pem to be stored in file storage * @param filePrefix prefix for file name to be stored in file storage * @param filePath file path in file storage (For directus files, it is the folder id) * @return certificate stored in db */ private _storeCertificateAndKey; }