From 5ac8d5f89e2dc64c50cacf5511124a267e6483ef Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 19 Jan 2018 15:47:41 +0100 Subject: [PATCH] mic & mac part 2, VBB salt Many thanks to @alexander-albers! --- lib/request.js | 3 ++- p/vbb/index.js | 8 +++++++- readme.md | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/request.js b/lib/request.js index cc5192a9..dcfe552d 100644 --- a/lib/request.js +++ b/lib/request.js @@ -41,7 +41,8 @@ const request = (profile, data) => { const mic = md5(Buffer.from(req.body, 'utf8')) req.query.mic = mic.toString('hex') - const mac = md5(Buffer.concat([mic, profile.salt])) + const micAsHex = Buffer.from(mic.toString('hex'), 'utf8') + const mac = md5(Buffer.concat([micAsHex, profile.salt])) req.query.mac = mac.toString('hex') } } diff --git a/p/vbb/index.js b/p/vbb/index.js index 2c9325c6..56519259 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -22,7 +22,7 @@ const formatBitmask = createFormatBitmask(modes) const transformReqBody = (body) => { body.client = {type: 'IPA', id: 'VBB', name: 'vbbPROD', v: '4010300'} body.ext = 'VBB.1' - body.ver = '1.11' // todo: 1.16 with `mic` and `mac` query params + body.ver = '1.16' body.auth = {type: 'AID', aid: 'hafas-vbb-apps'} return body @@ -168,6 +168,12 @@ const vbbProfile = { locale: 'de-DE', timezone: 'Europe/Berlin', endpoint: 'https://fahrinfo.vbb.de/bin/mgate.exe', + + // https://gist.github.com/derhuerst/a8d94a433358abc015ff77df4481070c#file-haf_config_base-properties-L39 + // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt + salt: Buffer.from('5243544a4d3266467846667878516649', 'hex'), + addMicMac: true, + transformReqBody, products: modes.allProducts, diff --git a/readme.md b/readme.md index 8bcba40f..06081135 100644 --- a/readme.md +++ b/readme.md @@ -174,6 +174,7 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript - [`vbb-hafas`](https://github.com/derhuerst/vbb-hafas#vbb-hafas) – JavaScript client for Berlin & Brandenburg public transport HAFAS API. - [`hafas-departures-in-direction`](https://github.com/derhuerst/hafas-departures-in-direction#hafas-departures-in-direction) – Pass in a HAFAS client, get departures in a certain direction. - [`hafas-collect-departures-at`](https://github.com/derhuerst/hafas-collect-departures-at#hafas-collect-departures-at) – Utility to collect departures, using any HAFAS client. +- [`hafas-discover-stations`](https://github.com/derhuerst/hafas-discover-stations#hafas-discover-stations) – Pass in a HAFAS client, discover stations by querying departures. - [`hafas-rest-api`](https://github.com/derhuerst/hafas-rest-api#hafas-rest-api) – Expose a HAFAS client via an HTTP REST API. - [List of european long-distance transport operators, available API endpoints, GTFS feeds and client modules.](https://github.com/public-transport/european-transport-operators) - [Collection of european transport JavaScript modules.](https://github.com/public-transport/european-transport-modules)