{"id":23869121,"url":"https://github.com/extrawest/ocpp-node-ts","last_synced_at":"2025-09-08T18:31:17.565Z","repository":{"id":121938780,"uuid":"602190221","full_name":"extrawest/ocpp-node-ts","owner":"extrawest","description":"Typescript package implementing the JSON version of the Open Charge Point Protocol (OCPP). Currently OCPP 2.0.1 is supported.","archived":false,"fork":false,"pushed_at":"2023-09-14T06:54:42.000Z","size":1400,"stargazers_count":18,"open_issues_count":2,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-08T16:29:00.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@extrawest/node-ts-ocpp","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extrawest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-15T17:28:04.000Z","updated_at":"2025-06-13T16:19:57.000Z","dependencies_parsed_at":"2023-12-01T04:43:05.462Z","dependency_job_id":null,"html_url":"https://github.com/extrawest/ocpp-node-ts","commit_stats":{"total_commits":46,"total_committers":3,"mean_commits":"15.333333333333334","dds":0.06521739130434778,"last_synced_commit":"fac0c19df2f374e768a211c784f31ff39cd5eae2"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/extrawest/ocpp-node-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Focpp-node-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Focpp-node-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Focpp-node-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Focpp-node-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extrawest","download_url":"https://codeload.github.com/extrawest/ocpp-node-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrawest%2Focpp-node-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229367,"owners_count":25245187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-03T12:16:08.245Z","updated_at":"2025-09-08T18:31:17.164Z","avatar_url":"https://github.com/extrawest.png","language":"TypeScript","funding_links":[],"categories":["Tools and Resources"],"sub_categories":["OCPP"],"readme":"![Maintaner](https://img.shields.io/badge/maintainer-extrawest.com-blue)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/extrawest/ocpp-node-ts)\n![GitHub release](https://img.shields.io/github/v/release/extrawest/ocpp-node-ts)\n[![GitHub tag](https://img.shields.io/github/v/tag/extrawest/ocpp-node-ts)](https://github.com/extrawest/ocpp-node-ts/tags/)\n#### Test coverage\n![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=flat)\n![Branches](https://img.shields.io/badge/branches-100%25-brightgreen.svg?style=flat)\n![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat)\n![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=flat)\n# Extrawest OCPP 2.0.1 package\n\nBased on great package [sepych/ocpp-ts][sepych/ocpp-ts] for OCPP 1.6 version.\n\nTypescript package implementing the JSON version of the Open Charge Point Protocol (OCPP). Currently OCPP 2.0.1 is\nsupported.\n\nOpen Charge Point Protocol (OCPP, \u003chttp://www.openchargealliance.org/\u003e) is a communication protocol between multiple\ncharging stations (\"charge points\") and a single management software (\"central system\").\n\n## Installation\n\n```\nnpm i @extrawest/node-ts-ocpp\n```\n\n## Usage\n\n### Central System\n\n```ts\nimport {\n    OcppServer, OcppClientConnection, BootNotificationRequest, BootNotificationResponse,\n} from 'ocpp-ts';\n\nconst centralSystemSimple = new OcppServer();\ncentralSystemSimple.listen(9220);\ncentralSystemSimple.on('connection', (client: OcppClientConnection) =\u003e {\n    console.log(`Client ${client.getCpId()} connected`);\n    client.on('close', (code: number, reason: Buffer) =\u003e {\n        console.log(`Client ${client.getCpId()} closed connection`, code, reason.toString());\n    });\n\n    client.on('BootNotification', (request: BootNotificationRequest, cb: (response: BootNotificationResponse) =\u003e void) =\u003e {\n        const response: BootNotificationResponse = {\n            status: 'Accepted',\n            currentTime: new Date().toISOString(),\n            interval: 60,\n        };\n        cb(response);\n    });\n});\n```\n\n### Charging Point\n\n```ts\nimport {\n    BootNotificationRequest,\n    BootNotificationResponse,\n    OcppClient, OcppError,\n} from 'ocpp-ts';\n\nconst chargingPointSimple = new OcppClient('CP1111');\nchargingPointSimple.on('error', (err: Error) =\u003e {\n    console.log(err.message);\n});\nchargingPointSimple.on('close', () =\u003e {\n    console.log('Connection closed');\n});\n\nchargingPointSimple.on('connect', async () =\u003e {\n    const boot: BootNotificationRequest = {\n        chargingStation: {\n            model: \"someModel\",\n            vendorName: \"someVendor\"\n        },\n        reason: \"Unknown\"\n    };\n\n    try {\n        const bootResp: BootNotificationResponse = await chargingPointSimple.callRequest('BootNotification', boot);\n        if (bootResp.status === 'Accepted') {\n            console.log('Bootnotification accepted');\n        }\n    } catch (e) {\n        if (e instanceof Error || e instanceof OcppError) {\n            console.error(e.message);\n        }\n    }\n});\nchargingPointSimple.connect('ws://localhost:9220/');\n```\n\n## Security\n\nAdd required certificates for Central System, note from OCPP protocol:\n\n*As some Charge Point implementations are using embedded systems with limited computing\nresources, we impose an additional restriction on the TLS configuration on the server side:*\n\n* The TLS certificate SHALL be an RSA certificate with a size no greater than 2048 bytes\n\n```ts\ncentralSystemSimple.on('authorization', (cbId: string, req: IncomingMessage, cb: (err?: Error) =\u003e void) =\u003e {\n    console.log('authorization', cbId, req.headers.authorization);\n    // validate authorization header\n    // cb(new Error('Unathorized')); // Deny\n    cb(); // Accept\n});\ncentralSystemSimple.listen(9220, {\n    cert: fs.readFileSync('cert.pem'),\n    key: fs.readFileSync('key.pem'),\n});\n```\n\nIf the central system requires authorization, an authorization header can be placed as the second parameter.\n\n```ts\nchargingPointSimple.connect('wss://somecs.com/ocpp/', {\n    Authorization: getBasicAuth(),\n});\n```\n\n---\nCreated by Extrawest Node.js Team\n[Extrawest.com](https://www.extrawest.com), 2023\n---\n\n\n[sepych/ocpp-ts]: https://www.npmjs.com/package/ocpp-ts","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrawest%2Focpp-node-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextrawest%2Focpp-node-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrawest%2Focpp-node-ts/lists"}