UNPKG

@citrineos/util

Version:

The OCPP util module which supplies helpful utilities like cache and queue connectors, etc.

50 lines (49 loc) 2.42 kB
import * as pkijs from 'pkijs'; import { Certificate } from '@citrineos/data'; import jsrsasign from 'jsrsasign'; import KJUR = jsrsasign.KJUR; import OCSPRequest = jsrsasign.KJUR.asn1.ocsp.OCSPRequest; import Request = jsrsasign.KJUR.asn1.ocsp.Request; import { CertificationRequest } from 'pkijs'; import moment from 'moment'; import { ILogObj, Logger } from 'tslog'; export declare const dateTimeFormat = "YYMMDDHHmmssZ"; export declare function getValidityTimeString(time: moment.Moment): string; export declare function createPemBlock(type: string, content: string): string; export declare function parseCertificateChainPem(pem: string): string[]; /** * Decode the pem and extract certificates * @param pem - base64 encoded certificate chain string without header and footer * @return array of pkijs.CertificateSetItem */ export declare function extractCertificateArrayFromEncodedString(pem: string): pkijs.CertificateSetItem[]; /** * extracts the base64-encoded content from a pem encoded csr * @param csrPem * @private * @return {string} The parsed CSR or the original CSR if it cannot be parsed */ export declare function extractEncodedContentFromCSR(csrPem: string): string; /** * Generate certificate and its private key * * @param certificateEntity - the certificate * @param logger - the logger * @param issuerKeyPem - the issuer private key * @param issuerCertPem - the issuer certificate * * @return generated certificate pem and its private key pem */ export declare function generateCertificate(certificateEntity: Certificate, logger: Logger<ILogObj>, issuerKeyPem?: string, issuerCertPem?: string): [string, string]; /** * Create a signed certificate for the provided CSR using the issuer certificate, and its private key. * * @param csrPem - The CSR that need to be signed. * @param issuerCertPem - The issuer certificate. * @param issuerPrivateKeyPem - The issuer private key. * @return {KJUR.asn1.x509.Certificate} The signed certificate. */ export declare function createSignedCertificateFromCSR(csrPem: string, issuerCertPem: string, issuerPrivateKeyPem: string): KJUR.asn1.x509.Certificate; export declare function sendOCSPRequest(ocspRequest: OCSPRequest | Request, responderURL: string): Promise<string>; export declare function parseCSRForVerification(csrPem: string): CertificationRequest; export declare function generateCSR(certificate: Certificate): [string, string];