mic & mac part 2, VBB salt

Many thanks to @alexander-albers!
This commit is contained in:
Jannis R 2018-01-19 15:47:41 +01:00
parent 6f958e14be
commit 5ac8d5f89e
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 10 additions and 2 deletions

View file

@ -41,7 +41,8 @@ const request = (profile, data) => {
const mic = md5(Buffer.from(req.body, 'utf8')) const mic = md5(Buffer.from(req.body, 'utf8'))
req.query.mic = mic.toString('hex') 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') req.query.mac = mac.toString('hex')
} }
} }

View file

@ -22,7 +22,7 @@ const formatBitmask = createFormatBitmask(modes)
const transformReqBody = (body) => { const transformReqBody = (body) => {
body.client = {type: 'IPA', id: 'VBB', name: 'vbbPROD', v: '4010300'} body.client = {type: 'IPA', id: 'VBB', name: 'vbbPROD', v: '4010300'}
body.ext = 'VBB.1' 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'} body.auth = {type: 'AID', aid: 'hafas-vbb-apps'}
return body return body
@ -168,6 +168,12 @@ const vbbProfile = {
locale: 'de-DE', locale: 'de-DE',
timezone: 'Europe/Berlin', timezone: 'Europe/Berlin',
endpoint: 'https://fahrinfo.vbb.de/bin/mgate.exe', 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, transformReqBody,
products: modes.allProducts, products: modes.allProducts,

View file

@ -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. - [`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-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-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. - [`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) - [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) - [Collection of european transport JavaScript modules.](https://github.com/public-transport/european-transport-modules)