From 6b635033ddf255392ded26fd03fe1f128b15ad69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 21 Feb 2023 22:10:24 +0100 Subject: [PATCH] feat(simulator): add certificates related OCPP 2.x types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/OCPPConstants.ts | 4 +- src/types/ocpp/2.0/Common.ts | 93 +++++++++++++++++++++- src/types/ocpp/2.0/Requests.ts | 6 ++ src/types/ocpp/2.0/Responses.ts | 6 ++ src/types/ocpp/Responses.ts | 4 +- 5 files changed, 108 insertions(+), 5 deletions(-) diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index f6b9af80..1064a95a 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -12,8 +12,8 @@ import { export class OCPPConstants { static readonly OCPP_REQUEST_EMPTY = Object.freeze({}); static readonly OCPP_RESPONSE_EMPTY = Object.freeze({}); - static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.ACCEPTED }); - static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.REJECTED }); + static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted }); + static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected }); static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({ status: ConfigurationStatus.ACCEPTED, diff --git a/src/types/ocpp/2.0/Common.ts b/src/types/ocpp/2.0/Common.ts index 5e47a251..ba908562 100644 --- a/src/types/ocpp/2.0/Common.ts +++ b/src/types/ocpp/2.0/Common.ts @@ -1,4 +1,17 @@ -import type { JsonObject } from '../../internal'; +import type { GenericStatus, JsonObject } from '../../internal'; + +export enum DataEnumType { + // eslint-disable-next-line id-blacklist + string = 'string', + decimal = 'decimal', + integer = 'integer', + dateTime = 'dateTime', + // eslint-disable-next-line id-blacklist + boolean = 'boolean', + OptionList = 'OptionList', + SequenceList = 'SequenceList', + MemberList = 'MemberList', +} export enum BootReasonEnumType { ApplicationReset = 'ApplicationReset', @@ -20,6 +33,84 @@ export enum OCPP20ConnectorStatusEnumType { FAULTED = 'Faulted', } +export type GenericStatusEnumType = GenericStatus; + +export enum HashAlgorithmEnumType { + SHA256 = 'SHA256', + SHA384 = 'SHA384', + SHA512 = 'SHA512', +} + +export enum GetCertificateIdUseEnumType { + V2GRootCertificate = 'V2GRootCertificate', + MORootCertificate = 'MORootCertificate', + CSMSRootCertificate = 'CSMSRootCertificate', + V2GCertificateChain = 'V2GCertificateChain', + ManufacturerRootCertificate = 'ManufacturerRootCertificate', +} + +export enum GetCertificateStatusEnumType { + Accepted = 'Accepted', + Failed = 'Failed', +} + +export enum GetInstalledCertificateStatusEnumType { + Accepted = 'Accepted', + NotFound = 'NotFound', +} + +export enum InstallCertificateStatusEnumType { + Accepted = 'Accepted', + Rejected = 'Rejected', + Failed = 'Failed', +} + +export enum InstallCertificateUseEnumType { + V2GRootCertificate = 'V2GRootCertificate', + MORootCertificate = 'MORootCertificate', + CSMSRootCertificate = 'CSMSRootCertificate', + ManufacturerRootCertificate = 'ManufacturerRootCertificate', +} + +export enum DeleteCertificateStatusEnumType { + Accepted = 'Accepted', + Failed = 'Failed', + NotFound = 'NotFound', +} + +export enum CertificateActionEnumType { + Install = 'Install', + Update = 'Update', +} + +export enum CertificateSigningUseEnumType { + ChargingStationCertificate = 'ChargingStationCertificate', + V2GCertificate = 'V2GCertificate', +} + +export type CertificateSignedStatusEnumType = GenericStatus; + +export type CertificateHashDataType = { + hashAlgorithm: HashAlgorithmEnumType; + issuerNameHash: string; + issuerKeyHash: string; + serialNumber: string; +} & JsonObject; + +export type CertificateHashDataChainType = { + certificateType: GetCertificateIdUseEnumType; + certificateHashData: CertificateHashDataType; + childCertificateHashData?: CertificateHashDataType; +} & JsonObject; + +export type OCSPRequestDataType = { + hashAlgorithm: HashAlgorithmEnumType; + issuerNameHash: string; + issuerKeyHash: string; + serialNumber: string; + responderURL: string; +} & JsonObject; + export type StatusInfoType = { reasonCode: string; additionalInfo?: string; diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index 220a39b6..d584c828 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -1,6 +1,7 @@ import type { BootReasonEnumType, EmptyObject, + InstallCertificateUseEnumType, JsonObject, OCPP20ConnectorStatusEnumType, OCPP20SetVariableDataType, @@ -50,3 +51,8 @@ export type OCPP20StatusNotificationRequest = { export type OCPP20SetVariablesRequest = { setVariableData: OCPP20SetVariableDataType[]; } & JsonObject; + +export type OCPP20InstallCertificateRequest = { + certificateType: InstallCertificateUseEnumType; + certificate: string; +} & JsonObject; diff --git a/src/types/ocpp/2.0/Responses.ts b/src/types/ocpp/2.0/Responses.ts index fdbebf15..5fac747a 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -1,6 +1,7 @@ import type { EmptyObject, GenericStatus, + InstallCertificateStatusEnumType, JsonObject, OCPP20SetVariableResultType, RegistrationStatusEnumType, @@ -28,3 +29,8 @@ export type OCPP20StatusNotificationResponse = EmptyObject; export type OCPP20SetVariablesResponse = { setVariableResult: OCPP20SetVariableResultType[]; } & JsonObject; + +export type OCPP20InstallCertificateResponse = { + status: InstallCertificateStatusEnumType; + statusInfo?: StatusInfoType; +} & JsonObject; diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index ae6ae45d..f14ef426 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -53,8 +53,8 @@ export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotif export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse; export enum GenericStatus { - ACCEPTED = 'Accepted', - REJECTED = 'Rejected', + Accepted = 'Accepted', + Rejected = 'Rejected', } export type GenericResponse = { -- 2.34.1