UNPKG

@citrineos/util

Version:

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

45 lines (44 loc) 1.98 kB
import type { BootstrapConfig, IFileStorage, SystemConfig } from '@citrineos/base'; import { OCPP2_0_1 } from '@citrineos/base'; import type { ILogObj } from 'tslog'; import { Logger } from 'tslog'; /** * Util to process and validate signed meter values. */ export declare class SignedMeterValuesUtil { private readonly _fileStorage; private readonly _logger; private readonly _chargingStationSecurityInfoRepository; private readonly _signedMeterValuesConfiguration; /** * @param {IFileStorage} [fileStorage] - The `fileStorage` allows access to the configured file storage. * * @param {BootstrapConfig & SystemConfig} config - The `config` contains the current system configuration settings. * * @param {Logger<ILogObj>} [logger] - The `logger` represents an instance of {@link Logger<ILogObj>}. * */ constructor(fileStorage: IFileStorage, config: BootstrapConfig & SystemConfig, logger: Logger<ILogObj>); /** * Checks the validity of a meter value. * * If a meter value is unsigned, it is valid. * * If a meter value is signed, it is valid if: * - SignedMeterValuesConfig is configured * AND * - The incoming signed meter value's signing method matches the configured signing method * AND * - The incoming signed meter value's public key is empty but there is a public key stored for that charging station * OR * - The incoming signed meter value's public key isn't empty and it matches the configured public key * * @param stationId - The charging station the meter values belong to * @param meterValues - The list of meter values */ validateMeterValues(tenantId: number, stationId: string, meterValues: [OCPP2_0_1.MeterValueType, ...OCPP2_0_1.MeterValueType[]]): Promise<boolean>; private validateSignedSampledValue; private validateSignedMeterValueSignature; private validateRsaSignature; private formatKey; }