diff --git a/README.md b/README.md index 1bf55db..b9cb2d6 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ by the [Open Charge Alliance][i1]. - [Utility enums](#utility-enums) - [Message types `SEND` and `CALLRESULTERROR` in OCPP 2.1](#message-types-send-and-callresulterror-in-ocpp-21) - [Utility types for OCPP 1.6](#utility-types-for-ocpp-16) + - [OCPP 1.6 Security Whitepaper](#ocpp-16-security-whitepaper) - [Utility types for OCPP 2.0](#utility-types-for-ocpp-20) - [Utility types for OCPP 2.1](#utility-types-for-ocpp-21) - [`ChargingManager` class](#chargingmanager-class) @@ -317,6 +318,15 @@ The following types may be used to model value descriptors within OCPP16.Status // status ("Available", "Reserved", ...) ``` +#### OCPP 1.6 Security Whitepaper + +This library includes types and schemas from the [OCPP 1.6 Security Whitepaper] +(4th edition) released on Feb 5th, 2026. The paper standardizes additional OCPP +messages that model some of the security enhancements introduced in OCPP 2.0, +backporting these features to OCPP 1.6. + +[OCPP 1.6 Security Whitepaper]: https://openchargealliance.org/ocpp-info-whitepapers/ocpp-1-6-security-whitepaper-4th-edition/ + #### Utility types for OCPP 2.0 ```typescript diff --git a/package.json b/package.json index 1db73d0..a2f4949 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "JSON", "JSON Schema", "Open Charge Alliance", - "Charging Station" + "Charging Station", + "Security Whitepaper" ] } diff --git a/schemas/ocpp16/CertificateSigned.json b/schemas/ocpp16/CertificateSigned.json new file mode 100644 index 0000000..e8a323f --- /dev/null +++ b/schemas/ocpp16/CertificateSigned.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:CertificateSigned.req", + "type": "object", + "properties": { + "certificateChain": { + "type": "string", + "maxLength": 10000 + } + }, + "additionalProperties": false, + "required": [ + "certificateChain" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/CertificateSignedResponse.json b/schemas/ocpp16/CertificateSignedResponse.json new file mode 100644 index 0000000..4907030 --- /dev/null +++ b/schemas/ocpp16/CertificateSignedResponse.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:CertificateSigned.conf", + "definitions": { + "CertificateSignedStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/CertificateSignedStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/DeleteCertificate.json b/schemas/ocpp16/DeleteCertificate.json new file mode 100644 index 0000000..a0d5ad8 --- /dev/null +++ b/schemas/ocpp16/DeleteCertificate.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:DeleteCertificate.req", + "definitions": { + "HashAlgorithmEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "CertificateHashDataType": { + "type": "object", + "additionalProperties": false, + "properties": { + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "type": "string", + "maxLength": 40 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "certificateHashData": { + "$ref": "#/definitions/CertificateHashDataType" + } + }, + "required": [ + "certificateHashData" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/DeleteCertificateResponse.json b/schemas/ocpp16/DeleteCertificateResponse.json new file mode 100644 index 0000000..75c30a2 --- /dev/null +++ b/schemas/ocpp16/DeleteCertificateResponse.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:DeleteCertificate.conf", + "definitions": { + "DeleteCertificateStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed", + "NotFound" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/DeleteCertificateStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/ExtendedTriggerMessage.json b/schemas/ocpp16/ExtendedTriggerMessage.json new file mode 100644 index 0000000..02735dd --- /dev/null +++ b/schemas/ocpp16/ExtendedTriggerMessage.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:ExtendedTriggerMessage.req", + "definitions": { + "MessageTriggerEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "BootNotification", + "LogStatusNotification", + "FirmwareStatusNotification", + "Heartbeat", + "MeterValues", + "SignChargePointCertificate", + "StatusNotification" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "requestedMessage": { + "$ref": "#/definitions/MessageTriggerEnumType" + }, + "connectorId": { + "type": "integer" + } + }, + "required": [ + "requestedMessage" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/ExtendedTriggerMessageResponse.json b/schemas/ocpp16/ExtendedTriggerMessageResponse.json new file mode 100644 index 0000000..a32f4c6 --- /dev/null +++ b/schemas/ocpp16/ExtendedTriggerMessageResponse.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:ExtendedTriggerMessage.conf", + "definitions": { + "TriggerMessageStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "NotImplemented" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/TriggerMessageStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/GetInstalledCertificateIds.json b/schemas/ocpp16/GetInstalledCertificateIds.json new file mode 100644 index 0000000..b3c91f1 --- /dev/null +++ b/schemas/ocpp16/GetInstalledCertificateIds.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:GetInstalledCertificateIds.req", + "definitions": { + "CertificateUseEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "CentralSystemRootCertificate", + "ManufacturerRootCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "certificateType": { + "$ref": "#/definitions/CertificateUseEnumType" + } + }, + "required": [ + "certificateType" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/GetInstalledCertificateIdsResponse.json b/schemas/ocpp16/GetInstalledCertificateIdsResponse.json new file mode 100644 index 0000000..2e78d76 --- /dev/null +++ b/schemas/ocpp16/GetInstalledCertificateIdsResponse.json @@ -0,0 +1,69 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:GetInstalledCertificateIds.conf", + "definitions": { + "GetInstalledCertificateStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "NotFound" + ] + }, + "HashAlgorithmEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "SHA256", + "SHA384", + "SHA512" + ] + }, + "CertificateHashDataType": { + "javaType": "CertificateHashData", + "type": "object", + "additionalProperties": false, + "properties": { + "hashAlgorithm": { + "$ref": "#/definitions/HashAlgorithmEnumType" + }, + "issuerNameHash": { + "type": "string", + "maxLength": 128 + }, + "issuerKeyHash": { + "type": "string", + "maxLength": 128 + }, + "serialNumber": { + "type": "string", + "maxLength": 40 + } + }, + "required": [ + "hashAlgorithm", + "issuerNameHash", + "issuerKeyHash", + "serialNumber" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "certificateHashData": { + "type": "array", + "additionalItems": false, + "items": { + "$ref": "#/definitions/CertificateHashDataType" + }, + "minItems": 1 + }, + "status": { + "$ref": "#/definitions/GetInstalledCertificateStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/GetLog.json b/schemas/ocpp16/GetLog.json new file mode 100644 index 0000000..f58a1a2 --- /dev/null +++ b/schemas/ocpp16/GetLog.json @@ -0,0 +1,59 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:GetLog.req", + "definitions": { + "LogEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "DiagnosticsLog", + "SecurityLog" + ] + }, + "LogParametersType": { + "type": "object", + "additionalProperties": false, + "properties": { + "remoteLocation": { + "type": "string", + "maxLength": 512 + }, + "oldestTimestamp": { + "type": "string", + "format": "date-time" + }, + "latestTimestamp": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "remoteLocation" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "log": { + "$ref": "#/definitions/LogParametersType" + }, + "logType": { + "$ref": "#/definitions/LogEnumType" + }, + "requestId": { + "type": "integer" + }, + "retries": { + "type": "integer" + }, + "retryInterval": { + "type": "integer" + } + }, + "required": [ + "logType", + "requestId", + "log" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/GetLogResponse.json b/schemas/ocpp16/GetLogResponse.json new file mode 100644 index 0000000..31003df --- /dev/null +++ b/schemas/ocpp16/GetLogResponse.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:GetLog.conf", + "definitions": { + "LogStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "AcceptedCanceled" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/LogStatusEnumType" + }, + "filename": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/InstallCertificate.json b/schemas/ocpp16/InstallCertificate.json new file mode 100644 index 0000000..a991593 --- /dev/null +++ b/schemas/ocpp16/InstallCertificate.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:InstallCertificate.req", + "definitions": { + "CertificateUseEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "CentralSystemRootCertificate", + "ManufacturerRootCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "certificateType": { + "$ref": "#/definitions/CertificateUseEnumType" + }, + "certificate": { + "type": "string", + "maxLength": 5500 + } + }, + "required": [ + "certificateType", + "certificate" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/InstallCertificateResponse.json b/schemas/ocpp16/InstallCertificateResponse.json new file mode 100644 index 0000000..f7afcb5 --- /dev/null +++ b/schemas/ocpp16/InstallCertificateResponse.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:InstallCertificate.conf", + "definitions": { + "InstallCertificateStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Failed", + "Rejected" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/InstallCertificateStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/LogStatusNotification.json b/schemas/ocpp16/LogStatusNotification.json new file mode 100644 index 0000000..6b3ea7e --- /dev/null +++ b/schemas/ocpp16/LogStatusNotification.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:LogStatusNotification.req", + "definitions": { + "UploadLogStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "BadMessage", + "Idle", + "NotSupportedOperation", + "PermissionDenied", + "Uploaded", + "UploadFailure", + "Uploading" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/UploadLogStatusEnumType" + }, + "requestId": { + "type": "integer" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/LogStatusNotificationResponse.json b/schemas/ocpp16/LogStatusNotificationResponse.json new file mode 100644 index 0000000..2685517 --- /dev/null +++ b/schemas/ocpp16/LogStatusNotificationResponse.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:LogStatusNotification.conf", + "type": "object", + "additionalProperties": false +} \ No newline at end of file diff --git a/schemas/ocpp16/SecurityEventNotification.json b/schemas/ocpp16/SecurityEventNotification.json new file mode 100644 index 0000000..f1e484f --- /dev/null +++ b/schemas/ocpp16/SecurityEventNotification.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SecurityEventNotification.req", + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "maxLength": 50 + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "techInfo": { + "type": "string", + "maxLength": 255 + } + }, + "required": [ + "type", + "timestamp" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/SecurityEventNotificationResponse.json b/schemas/ocpp16/SecurityEventNotificationResponse.json new file mode 100644 index 0000000..244ff74 --- /dev/null +++ b/schemas/ocpp16/SecurityEventNotificationResponse.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SecurityEventNotification.conf", + "type": "object", + "additionalProperties": false +} \ No newline at end of file diff --git a/schemas/ocpp16/SignCertificate.json b/schemas/ocpp16/SignCertificate.json new file mode 100644 index 0000000..b27650e --- /dev/null +++ b/schemas/ocpp16/SignCertificate.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignCertificate.req", + "type": "object", + "additionalProperties": false, + "properties": { + "csr": { + "type": "string", + "maxLength": 5500 + } + }, + "required": [ + "csr" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/SignCertificateResponse.json b/schemas/ocpp16/SignCertificateResponse.json new file mode 100644 index 0000000..449d5ff --- /dev/null +++ b/schemas/ocpp16/SignCertificateResponse.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignCertificate.conf", + "definitions": { + "GenericStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/GenericStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/SignedFirmwareStatusNotification.json b/schemas/ocpp16/SignedFirmwareStatusNotification.json new file mode 100644 index 0000000..a0ce83c --- /dev/null +++ b/schemas/ocpp16/SignedFirmwareStatusNotification.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignedFirmwareStatusNotification.req", + "definitions": { + "FirmwareStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Downloaded", + "DownloadFailed", + "Downloading", + "DownloadScheduled", + "DownloadPaused", + "Idle", + "InstallationFailed", + "Installing", + "Installed", + "InstallRebooting", + "InstallScheduled", + "InstallVerificationFailed", + "InvalidSignature", + "SignatureVerified" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/FirmwareStatusEnumType" + }, + "requestId": { + "type": "integer" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/SignedFirmwareStatusNotificationResponse.json b/schemas/ocpp16/SignedFirmwareStatusNotificationResponse.json new file mode 100644 index 0000000..3d9499e --- /dev/null +++ b/schemas/ocpp16/SignedFirmwareStatusNotificationResponse.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignedFirmwareStatusNotification.conf", + "type": "object", + "additionalProperties": false +} \ No newline at end of file diff --git a/schemas/ocpp16/SignedUpdateFirmware.json b/schemas/ocpp16/SignedUpdateFirmware.json new file mode 100644 index 0000000..756c149 --- /dev/null +++ b/schemas/ocpp16/SignedUpdateFirmware.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignedUpdateFirmware.req", + "definitions": { + "FirmwareType": { + "type": "object", + "additionalProperties": false, + "properties": { + "location": { + "type": "string", + "maxLength": 512 + }, + "retrieveDateTime": { + "type": "string", + "format": "date-time" + }, + "installDateTime": { + "type": "string", + "format": "date-time" + }, + "signingCertificate": { + "type": "string", + "maxLength": 5500 + }, + "signature": { + "type": "string", + "maxLength": 800 + } + }, + "required": [ + "location", + "retrieveDateTime", + "signingCertificate", + "signature" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "retries": { + "type": "integer" + }, + "retryInterval": { + "type": "integer" + }, + "requestId": { + "type": "integer" + }, + "firmware": { + "$ref": "#/definitions/FirmwareType" + } + }, + "required": [ + "requestId", + "firmware" + ] +} \ No newline at end of file diff --git a/schemas/ocpp16/SignedUpdateFirmwareResponse.json b/schemas/ocpp16/SignedUpdateFirmwareResponse.json new file mode 100644 index 0000000..e18d6b2 --- /dev/null +++ b/schemas/ocpp16/SignedUpdateFirmwareResponse.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "urn:OCPP:Cp:1.6:2020:3:SignedUpdateFirmware.conf", + "definitions": { + "UpdateFirmwareStatusEnumType": { + "type": "string", + "additionalProperties": false, + "enum": [ + "Accepted", + "Rejected", + "AcceptedCanceled", + "InvalidCertificate", + "RevokedCertificate" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "status": { + "$ref": "#/definitions/UpdateFirmwareStatusEnumType" + } + }, + "required": [ + "status" + ] +} \ No newline at end of file diff --git a/src/ocpp16/call.test.ts b/src/ocpp16/call.test.ts index 580bda7..d091906 100644 --- a/src/ocpp16/call.test.ts +++ b/src/ocpp16/call.test.ts @@ -77,6 +77,24 @@ describe('OCPP16 - Call', () => { }); + describe('GetLog', () => { + it('should validate GetLog request', () => { + const call = [ + 2, + "983728ed-5d83-467f-be81-81282b93e8b2", + OCPP16.Action.GetLog, + { + log: { + remoteLocation: 'remote', + }, + logType: 'DiagnosticsLog', + requestId: 0, + } + ]; + deepStrictEqual(validate(call), true); + }); + }); + }); }); diff --git a/src/ocpp16/call.ts b/src/ocpp16/call.ts index 9e25794..22c8210 100644 --- a/src/ocpp16/call.ts +++ b/src/ocpp16/call.ts @@ -37,6 +37,18 @@ export type TriggerMessageCall = BaseMessage; export type UpdateFirmwareCall = BaseMessage; +export type CertificateSignedCall = BaseMessage; +export type DeleteCertificateCall = BaseMessage; +export type ExtendedTriggerMessageCall = BaseMessage; +export type GetInstalledCertificateIdsCall = BaseMessage; +export type GetLogCall = BaseMessage; +export type InstallCertificateCall = BaseMessage; +export type LogStatusNotificationCall = BaseMessage; +export type SecurityEventNotificationCall = BaseMessage; +export type SignCertificateCall = BaseMessage; +export type SignedFirmwareStatusNotificationCall = BaseMessage; +export type SignedUpdateFirmwareCall = BaseMessage; + export type Call = AuthorizeCall | BootNotificationCall | CancelReservationCall @@ -65,6 +77,17 @@ export type Call = AuthorizeCall | TriggerMessageCall | UnlockConnectorCall | UpdateFirmwareCall + | CertificateSignedCall + | DeleteCertificateCall + | ExtendedTriggerMessageCall + | GetInstalledCertificateIdsCall + | GetLogCall + | InstallCertificateCall + | LogStatusNotificationCall + | SecurityEventNotificationCall + | SignCertificateCall + | SignedFirmwareStatusNotificationCall + | SignedUpdateFirmwareCall ; const schemasByCommand: Record = { @@ -96,6 +119,17 @@ const schemasByCommand: Record = { [Action.TriggerMessage]: schemas.TriggerMessageRequest, [Action.UnlockConnector]: schemas.UnlockConnectorRequest, [Action.UpdateFirmware]: schemas.UpdateFirmwareRequest, + [Action.CertificateSigned]: schemas.CertificateSignedRequest, + [Action.DeleteCertificate]: schemas.DeleteCertificateRequest, + [Action.ExtendedTriggerMessage]: schemas.ExtendedTriggerMessageRequest, + [Action.GetInstalledCertificateIds]: schemas.GetInstalledCertificateIdsRequest, + [Action.GetLog]: schemas.GetLogRequest, + [Action.InstallCertificate]: schemas.InstallCertificateRequest, + [Action.LogStatusNotification]: schemas.LogStatusNotificationRequest, + [Action.SecurityEventNotification]: schemas.SecurityEventNotificationRequest, + [Action.SignCertificate]: schemas.SignCertificateRequest, + [Action.SignedFirmwareStatusNotification]: schemas.SignedFirmwareStatusNotificationRequest, + [Action.SignedUpdateFirmware]: schemas.SignedUpdateFirmwareRequest, }; type BaseCall = BaseMessage; diff --git a/src/ocpp16/callresult.ts b/src/ocpp16/callresult.ts index 7faccf3..db42f42 100644 --- a/src/ocpp16/callresult.ts +++ b/src/ocpp16/callresult.ts @@ -51,8 +51,19 @@ export type StopTransactionCallResult = UncheckedCallResult; export type UnlockConnectorCallResult = UncheckedCallResult; export type UpdateFirmwareCallResult = UncheckedCallResult; +export type CertificateSignedCallResult = UncheckedCallResult; +export type DeleteCertificateCallResult = UncheckedCallResult; +export type ExtendedTriggerMessageCallResult = UncheckedCallResult; +export type GetInstalledCertificateIdsCallResult = UncheckedCallResult; +export type GetLogCallResult = UncheckedCallResult; +export type InstallCertificateCallResult = UncheckedCallResult; +export type LogStatusNotificationCallResult = UncheckedCallResult; +export type SecurityEventNotificationCallResult = UncheckedCallResult; +export type SignCertificateCallResult = UncheckedCallResult; +export type SignedFirmwareStatusNotificationCallResult = UncheckedCallResult; +export type SignedUpdateFirmwareCallResult = UncheckedCallResult; -export type CallResult = +export type CallResult = | AuthorizeCallResult | BootNotificationCallResult | CancelReservationCallResult @@ -81,6 +92,17 @@ export type CallResult = | TriggerMessageCallResult | UnlockConnectorCallResult | UpdateFirmwareCallResult + | CertificateSignedCallResult + | DeleteCertificateCallResult + | ExtendedTriggerMessageCallResult + | GetInstalledCertificateIdsCallResult + | GetLogCallResult + | InstallCertificateCallResult + | LogStatusNotificationCallResult + | SecurityEventNotificationCallResult + | SignCertificateCallResult + | SignedFirmwareStatusNotificationCallResult + | SignedUpdateFirmwareCallResult ; const schemasByCommand: Record = { @@ -112,6 +134,17 @@ const schemasByCommand: Record = { [Action.TriggerMessage]: schemas.TriggerMessageResponse, [Action.UnlockConnector]: schemas.UnlockConnectorResponse, [Action.UpdateFirmware]: schemas.UpdateFirmwareResponse, + [Action.CertificateSigned]: schemas.CertificateSignedResponse, + [Action.DeleteCertificate]: schemas.DeleteCertificateResponse, + [Action.ExtendedTriggerMessage]: schemas.ExtendedTriggerMessageResponse, + [Action.GetInstalledCertificateIds]: schemas.GetInstalledCertificateIdsResponse, + [Action.GetLog]: schemas.GetLogResponse, + [Action.InstallCertificate]: schemas.InstallCertificateResponse, + [Action.LogStatusNotification]: schemas.LogStatusNotificationResponse, + [Action.SecurityEventNotification]: schemas.SecurityEventNotificationResponse, + [Action.SignCertificate]: schemas.SignCertificateResponse, + [Action.SignedFirmwareStatusNotification]: schemas.SignedFirmwareStatusNotificationResponse, + [Action.SignedUpdateFirmware]: schemas.SignedUpdateFirmwareResponse, }; export const validateCallResult: ValidateFn = assign( @@ -155,6 +188,17 @@ export interface CallResultTypesByAction extends Record { [Action.TriggerMessage]: TriggerMessageCallResult, [Action.UnlockConnector]: UnlockConnectorCallResult, [Action.UpdateFirmware]: UpdateFirmwareCallResult, + [Action.CertificateSigned]: CertificateSignedCallResult, + [Action.DeleteCertificate]: DeleteCertificateCallResult, + [Action.ExtendedTriggerMessage]: ExtendedTriggerMessageCallResult, + [Action.GetInstalledCertificateIds]: GetInstalledCertificateIdsCallResult, + [Action.GetLog]: GetLogCallResult, + [Action.InstallCertificate]: InstallCertificateCallResult, + [Action.LogStatusNotification]: LogStatusNotificationCallResult, + [Action.SecurityEventNotification]: SecurityEventNotificationCallResult, + [Action.SignCertificate]: SignCertificateCallResult, + [Action.SignedFirmwareStatusNotification]: SignedFirmwareStatusNotificationCallResult, + [Action.SignedUpdateFirmware]: SignedUpdateFirmwareCallResult, }; export type CheckedCallResult = CallResultTypesByAction[C[2]]; diff --git a/src/ocpp16/index.ts b/src/ocpp16/index.ts index 4c2dde6..3cda128 100644 --- a/src/ocpp16/index.ts +++ b/src/ocpp16/index.ts @@ -28,6 +28,17 @@ import type { TriggerMessageRequest, UnlockConnectorRequest, UpdateFirmwareRequest, + CertificateSignedRequest, + DeleteCertificateRequest, + ExtendedTriggerMessageRequest, + GetInstalledCertificateIdsRequest, + GetLogRequest, + InstallCertificateRequest, + LogStatusNotificationRequest, + SecurityEventNotificationRequest, + SignCertificateRequest, + SignedFirmwareStatusNotificationRequest, + SignedUpdateFirmwareRequest, } from './types.js'; import type { @@ -59,6 +70,17 @@ import type { TriggerMessageResponse, UnlockConnectorResponse, UpdateFirmwareResponse, + CertificateSignedResponse, + DeleteCertificateResponse, + ExtendedTriggerMessageResponse, + GetInstalledCertificateIdsResponse, + GetLogResponse, + InstallCertificateResponse, + LogStatusNotificationResponse, + SecurityEventNotificationResponse, + SignCertificateResponse, + SignedFirmwareStatusNotificationResponse, + SignedUpdateFirmwareResponse, } from './types.js'; import type { @@ -90,6 +112,17 @@ import type { TriggerMessageCall, UnlockConnectorCall, UpdateFirmwareCall, + CertificateSignedCall, + DeleteCertificateCall, + ExtendedTriggerMessageCall, + GetInstalledCertificateIdsCall, + GetLogCall, + InstallCertificateCall, + LogStatusNotificationCall, + SecurityEventNotificationCall, + SignCertificateCall, + SignedFirmwareStatusNotificationCall, + SignedUpdateFirmwareCall, } from './call.js'; import type { @@ -121,16 +154,27 @@ import type { TriggerMessageCallResult, UnlockConnectorCallResult, UpdateFirmwareCallResult, + CertificateSignedCallResult, + DeleteCertificateCallResult, + ExtendedTriggerMessageCallResult, + GetInstalledCertificateIdsCallResult, + GetLogCallResult, + InstallCertificateCallResult, + LogStatusNotificationCallResult, + SecurityEventNotificationCallResult, + SignCertificateCallResult, + SignedFirmwareStatusNotificationCallResult, + SignedUpdateFirmwareCallResult, } from './callresult.js'; import type { - Context, - Measurand, - Phase, - Location, - Unit, - Format, - SampledValue, + Context, + Measurand, + Phase, + Location, + Unit, + Format, + SampledValue, MeterValue, Status, } from './utils.js'; @@ -139,7 +183,7 @@ import type { Call } from './call.js'; import type { CallError } from './callerror.js'; -import type { +import type { CallResult, CheckedCallResult, UncheckedCallResult, @@ -190,6 +234,17 @@ export declare namespace OCPP16 { TriggerMessageCall, UnlockConnectorCall, UpdateFirmwareCall, + CertificateSignedCall, + DeleteCertificateCall, + ExtendedTriggerMessageCall, + GetInstalledCertificateIdsCall, + GetLogCall, + InstallCertificateCall, + LogStatusNotificationCall, + SecurityEventNotificationCall, + SignCertificateCall, + SignedFirmwareStatusNotificationCall, + SignedUpdateFirmwareCall, }; export type { @@ -221,6 +276,17 @@ export declare namespace OCPP16 { TriggerMessageCallResult, UnlockConnectorCallResult, UpdateFirmwareCallResult, + CertificateSignedCallResult, + DeleteCertificateCallResult, + ExtendedTriggerMessageCallResult, + GetInstalledCertificateIdsCallResult, + GetLogCallResult, + InstallCertificateCallResult, + LogStatusNotificationCallResult, + SecurityEventNotificationCallResult, + SignCertificateCallResult, + SignedFirmwareStatusNotificationCallResult, + SignedUpdateFirmwareCallResult, }; export type { @@ -252,6 +318,17 @@ export declare namespace OCPP16 { TriggerMessageRequest, UnlockConnectorRequest, UpdateFirmwareRequest, + CertificateSignedRequest, + DeleteCertificateRequest, + ExtendedTriggerMessageRequest, + GetInstalledCertificateIdsRequest, + GetLogRequest, + InstallCertificateRequest, + LogStatusNotificationRequest, + SecurityEventNotificationRequest, + SignCertificateRequest, + SignedFirmwareStatusNotificationRequest, + SignedUpdateFirmwareRequest, }; export type { @@ -283,16 +360,27 @@ export declare namespace OCPP16 { TriggerMessageResponse, UnlockConnectorResponse, UpdateFirmwareResponse, + CertificateSignedResponse, + DeleteCertificateResponse, + ExtendedTriggerMessageResponse, + GetInstalledCertificateIdsResponse, + GetLogResponse, + InstallCertificateResponse, + LogStatusNotificationResponse, + SecurityEventNotificationResponse, + SignCertificateResponse, + SignedFirmwareStatusNotificationResponse, + SignedUpdateFirmwareResponse, }; export type { - Context, - Measurand, - Phase, - Location, - Unit, - Format, - SampledValue, + Context, + Measurand, + Phase, + Location, + Unit, + Format, + SampledValue, MeterValue, Status, }; @@ -309,8 +397,8 @@ export declare namespace OCPP16 { export namespace OCPP16 { - export import MessageType = MessageType_; - export import Action = Action_; + export import MessageType = MessageType_; + export import Action = Action_; export import ErrorCode = ErrorCode_; export const checkCallResult = checkCallResult_; @@ -366,4 +454,4 @@ export namespace OCPP16 { return msg[0] === MessageType_.CALLRESULT; }; -}; \ No newline at end of file +}; diff --git a/src/ocpp16/utils.ts b/src/ocpp16/utils.ts index 14a9a7a..9eb630a 100644 --- a/src/ocpp16/utils.ts +++ b/src/ocpp16/utils.ts @@ -29,7 +29,18 @@ export enum Action { StopTransaction = 'StopTransaction', TriggerMessage = 'TriggerMessage', UnlockConnector = 'UnlockConnector', - UpdateFirmware = 'UpdateFirmware' + UpdateFirmware = 'UpdateFirmware', + CertificateSigned = 'CertificateSigned', + DeleteCertificate = 'DeleteCertificate', + ExtendedTriggerMessage = 'ExtendedTriggerMessage', + GetInstalledCertificateIds = 'GetInstalledCertificateIds', + GetLog = 'GetLog', + InstallCertificate = 'InstallCertificate', + LogStatusNotification = 'LogStatusNotification', + SecurityEventNotification = 'SecurityEventNotification', + SignCertificate = 'SignCertificate', + SignedFirmwareStatusNotification = 'SignedFirmwareStatusNotification', + SignedUpdateFirmware = 'SignedUpdateFirmware', } export enum ErrorCode {