From 251e7925c9047bf92a867c3bae6fa945c461bcbf Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sun, 18 Apr 2021 19:02:54 +0200 Subject: [PATCH] pull more profile base data from transport-apis --- p/avv/base.json | 13 +++++++++++ p/avv/index.js | 15 +++---------- p/bart/base.json | 13 +++++++++++ p/bart/index.js | 15 +++---------- p/bvg/base.json | 16 ++++++++++++++ p/bvg/index.js | 13 ++--------- p/cfl/base.json | 15 +++++++++++++ p/cfl/index.js | 13 ++--------- p/cmta/base.json | 15 +++++++++++++ p/cmta/index.js | 17 ++------------- p/db-busradar-nrw/base.json | 16 ++++++++++++++ p/db-busradar-nrw/index.js | 19 +++-------------- p/db/base.json | 9 ++++---- p/hvv/base.json | 17 +++++++++++++++ p/hvv/index.js | 19 ++++------------- p/insa/base.json | 15 +++++++++++++ p/insa/index.js | 19 ++--------------- p/invg/base.json | 15 +++++++++++++ p/invg/index.js | 24 ++------------------- p/irish-rail/base.json | 15 +++++++++++++ p/irish-rail/index.js | 15 ++----------- p/mobil-nrw/base.json | 15 +++++++++++++ p/mobil-nrw/index.js | 23 ++------------------ p/mobiliteit-lu/base.json | 14 ++++++++++++ p/mobiliteit-lu/index.js | 18 ++-------------- p/nahsh/base.json | 14 ++++++++++++ p/nahsh/index.js | 17 ++------------- p/nvv/base.json | 16 ++++++++++++++ p/nvv/index.js | 23 ++------------------ p/oebb/base.json | 15 +++++++++++++ p/oebb/index.js | 24 +++------------------ p/pkp/base.json | 13 +++++++++++ p/pkp/index.js | 13 ++--------- p/rejseplanen/base.json | 14 ++++++++++++ p/rejseplanen/index.js | 13 ++--------- p/rmv/base.json | 15 +++++++++++++ p/rmv/index.js | 14 ++---------- p/rsag/base.json | 15 +++++++++++++ p/rsag/index.js | 14 ++---------- p/saarfahrplan/base.json | 15 +++++++++++++ p/saarfahrplan/index.js | 21 ++---------------- p/sbahn-muenchen/base.json | 17 +++++++++++++++ p/sbahn-muenchen/index.js | 14 ++---------- p/sbb/base.json | 14 ++++++++++++ p/sbb/index.js | 19 ++--------------- p/sncb/base.json | 15 +++++++++++++ p/sncb/index.js | 13 ++--------- p/svv/base.json | 15 +++++++++++++ p/svv/index.js | 13 ++--------- p/vbb/base.json | 16 ++++++++++++++ p/vbb/index.js | 17 +++------------ p/vbn/base.json | 15 +++++++++++++ p/vbn/index.js | 14 ++---------- p/vkg/base.json | 13 +++++++++++ p/vkg/index.js | 16 +++----------- p/vmt/base.json | 15 +++++++++++++ p/vmt/index.js | 15 ++----------- p/vos/base.json | 13 +++++++++++ p/vos/index.js | 15 +++---------- p/vrn/base.json | 16 ++++++++++++++ p/vrn/index.js | 14 ++---------- p/vsn/base.json | 15 +++++++++++++ p/vsn/index.js | 34 +++-------------------------- p/vvt/base.json | 13 +++++++++++ p/vvt/index.js | 16 +++----------- p/zvv/base.json | 16 ++++++++++++++ p/zvv/index.js | 18 ++-------------- tools/pull-profile-base-data.sh | 38 +++++++++++++++++++++++++++++++-- tools/transport-apis | 2 +- 69 files changed, 608 insertions(+), 497 deletions(-) create mode 100644 p/avv/base.json create mode 100644 p/bart/base.json create mode 100644 p/bvg/base.json create mode 100644 p/cfl/base.json create mode 100644 p/cmta/base.json create mode 100644 p/db-busradar-nrw/base.json create mode 100644 p/hvv/base.json create mode 100644 p/insa/base.json create mode 100644 p/invg/base.json create mode 100644 p/irish-rail/base.json create mode 100644 p/mobil-nrw/base.json create mode 100644 p/mobiliteit-lu/base.json create mode 100644 p/nahsh/base.json create mode 100644 p/nvv/base.json create mode 100644 p/oebb/base.json create mode 100644 p/pkp/base.json create mode 100644 p/rejseplanen/base.json create mode 100644 p/rmv/base.json create mode 100644 p/rsag/base.json create mode 100644 p/saarfahrplan/base.json create mode 100644 p/sbahn-muenchen/base.json create mode 100644 p/sbb/base.json create mode 100644 p/sncb/base.json create mode 100644 p/svv/base.json create mode 100644 p/vbb/base.json create mode 100644 p/vbn/base.json create mode 100644 p/vkg/base.json create mode 100644 p/vmt/base.json create mode 100644 p/vos/base.json create mode 100644 p/vrn/base.json create mode 100644 p/vsn/base.json create mode 100644 p/vvt/base.json create mode 100644 p/zvv/base.json diff --git a/p/avv/base.json b/p/avv/base.json new file mode 100644 index 00000000..76297013 --- /dev/null +++ b/p/avv/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "4vV1AcH3N511icH" + }, + "client": { + "type": "WEB", + "id": "AVV_AACHEN", + "name": "webapp" + }, + "endpoint": "https://auskunft.avv.de/bin/mgate.exe", + "defaultLanguage": "de" +} diff --git a/p/avv/index.js b/p/avv/index.js index 46b7f2c5..206a1d27 100644 --- a/p/avv/index.js +++ b/p/avv/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + const products = [{ id: 'regional-train', mode: 'train', @@ -80,20 +82,9 @@ const products = [{ }] const avvProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://auskunft.avv.de/bin/mgate.exe', - - auth: { - type: 'AID', - aid: '4vV1AcH3N511icH', - }, - client: { - id: 'AVV_AACHEN', - type: 'WEB', - name: 'webapp', - l: 'vs_avv', - }, ver: '1.18', products, diff --git a/p/bart/base.json b/p/bart/base.json new file mode 100644 index 00000000..da6a2940 --- /dev/null +++ b/p/bart/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "kEwHkFUCIL500dym" + }, + "client": { + "type": "WEB", + "id": "BART", + "name": "webapp" + }, + "endpoint": "https://planner.bart.gov/bin/mgate.exe", + "defaultLanguage": "en" +} diff --git a/p/bart/index.js b/p/bart/index.js index 86a28fb8..b7fb44fa 100644 --- a/p/bart/index.js +++ b/p/bart/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + const products = [{ id: 'bart', mode: 'train', @@ -45,20 +47,9 @@ const products = [{ }] const bartProfile = { + ...baseProfile, locale: 'en-US', timezone: 'America/Los_Angeles', - endpoint: 'https://planner.bart.gov/bin/mgate.exe', - - auth: { - type: 'AID', - aid: 'kEwHkFUCIL500dym', - }, - client: { - id: 'BART', - type: 'WEB', - name: 'webapp', - l: 'vs_webapp', - }, ver: '1.25', products, diff --git a/p/bvg/base.json b/p/bvg/base.json new file mode 100644 index 00000000..efb3b404 --- /dev/null +++ b/p/bvg/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "Mz0YdF9Fgx0Mb9" + }, + "client": { + "type": "IPA", + "id": "BVG", + "v": "6020000", + "name": "FahrInfo" + }, + "endpoint": "https://bvg-apps.hafas.de/bin/mgate.exe", + "ext": "BVG.1", + "ver": "1.44", + "defaultLanguage": "de" +} diff --git a/p/bvg/index.js b/p/bvg/index.js index 5b8b278f..88af2f43 100644 --- a/p/bvg/index.js +++ b/p/bvg/index.js @@ -12,17 +12,9 @@ const _parseDeparture = require('../../parse/departure') const _parseJourneyLeg = require('../../parse/journey-leg') const _formatStation = require('../../format/station') +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPA', id: 'BVG', name: 'FahrInfo', v: '6020000'} - body.ext = 'BVG.1' - body.ver = '1.21' - body.auth = {type: 'AID', aid: 'Mz0YdF9Fgx0Mb9'} - - return body -} - // todo: https://m.tagesspiegel.de/berlin/fahrerlebnis-wie-im-regionalexpress-so-faehrt-es-sich-in-der-neuen-express-s-bahn/25338674.html const parseLineWithMoreDetails = ({parsed}, p) => { parsed.name = p.name.replace(/^(bus|tram)\s+/i, '') @@ -120,11 +112,10 @@ const requestJourneysWithBerlkoenig = ({opt}, query) => { // todo: adapt/extend `vbb-parse-ticket` to support the BVG markup const bvgProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://bvg-apps.hafas.de/bin/mgate.exe', - transformReqBody, transformJourneysQuery: requestJourneysWithBerlkoenig, products, diff --git a/p/cfl/base.json b/p/cfl/base.json new file mode 100644 index 00000000..4573f32d --- /dev/null +++ b/p/cfl/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "ALT2vl7LAFDFu2dz" + }, + "client": { + "type": "IPH", + "id": "HAFAS", + "v": "4000000", + "name": "cflPROD-STORE" + }, + "endpoint": "https://horaires.cfl.lu/bin/mgate.exe", + "ver": "1.16", + "defaultLanguage": "fr" +} diff --git a/p/cfl/index.js b/p/cfl/index.js index 96a3b09b..4c3b3aa1 100644 --- a/p/cfl/index.js +++ b/p/cfl/index.js @@ -1,26 +1,17 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'HAFAS', - v: '4000000', - name: 'cflPROD-STORE', - os: 'iPhone OS 9.3.5' - } - body.ver = '1.16' - body.auth = {aid: 'ALT2vl7LAFDFu2dz'} body.lang = 'de' - return body } const cflProfile = { + ...baseProfile, locale: 'de-LU', timezone: 'Europe/Luxembourg', - endpoint: 'https://horaires.cfl.lu/bin/mgate.exe', transformReqBody, products: products, diff --git a/p/cmta/base.json b/p/cmta/base.json new file mode 100644 index 00000000..80e8033b --- /dev/null +++ b/p/cmta/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "ioslaskdcndrjcmlsd" + }, + "client": { + "type": "IPH", + "id": "CMTA", + "v": "2", + "name": "CapMetro" + }, + "endpoint": "https://capmetro.hafas.cloud/bin/mgate.exe", + "ver": "1.13", + "defaultLanguage": "en" +} diff --git a/p/cmta/index.js b/p/cmta/index.js index 27d22cfd..3506b918 100644 --- a/p/cmta/index.js +++ b/p/cmta/index.js @@ -1,25 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'CMTA', - v: '2', - name: 'CapMetro' - } - body.ver = '1.13' - body.auth = {type: 'AID', aid: 'ioslaskdcndrjcmlsd'} - - return body -} - const cmtaProfile = { + ...baseProfile, locale: 'en-US', timezone: 'America/Chicago', - endpoint: 'https://capmetro.hafas.cloud/bin/mgate.exe', - transformReqBody, products, diff --git a/p/db-busradar-nrw/base.json b/p/db-busradar-nrw/base.json new file mode 100644 index 00000000..aa2c4dd8 --- /dev/null +++ b/p/db-busradar-nrw/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "OGBAqytjHhCvr0J4" + }, + "client": { + "type": "AND", + "id": "DB-REGIO", + "v": 100021, + "name": "DB Busradar NRW" + }, + "endpoint": "https://db-regio.hafas.de/bin/hci/mgate.exe", + "ext": "DB.REGIO.1", + "ver": "1.10", + "defaultLanguage": "de" +} diff --git a/p/db-busradar-nrw/index.js b/p/db-busradar-nrw/index.js index 11ad5b3c..c3eecc7b 100644 --- a/p/db-busradar-nrw/index.js +++ b/p/db-busradar-nrw/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + // DB Busradar NRW app does not allow selecting specific modes of transport to filter results, // so the bitmasks had to be determined by querying some stations and looking at the results.. const products = [ @@ -73,25 +75,10 @@ const products = [ } ] -const transformReqBody = (_, body) => { - body.client = { - id: 'DB-REGIO', - name: 'DB Busradar NRW', - os: 'Android 9', - type: 'AND', - v: 100021 - } - body.ext = 'DB.REGIO.1' - body.ver = '1.10' - body.auth = {type: 'AID', aid: 'OGBAqytjHhCvr0J4'} - return body -} - const dbBusradarNrwProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://db-regio.hafas.de/bin/hci/mgate.exe', - transformReqBody, products: products, diff --git a/p/db/base.json b/p/db/base.json index de5f2a5c..d2179bf8 100644 --- a/p/db/base.json +++ b/p/db/base.json @@ -5,12 +5,13 @@ }, "salt": "6264493855566A34304B356676787766", "client": { + "type": "AND", "id": "DB", - "v": "16040000", - "type": "IPH", + "v": 19040000, "name": "DB Navigator" }, "endpoint": "https://reiseauskunft.bahn.de/bin/mgate.exe", - "ext": "DB.R19.04.a", - "ver": "1.15" + "ext": "DB.R19.12.a", + "ver": "1.18", + "defaultLanguage": "en" } diff --git a/p/hvv/base.json b/p/hvv/base.json new file mode 100644 index 00000000..a72e19be --- /dev/null +++ b/p/hvv/base.json @@ -0,0 +1,17 @@ +{ + "auth": { + "type": "AID", + "aid": "andcXUmC9Mq6hjrwDIGd2l3oiaMrTUzyH" + }, + "salt": "pqjM3iKEGOAhYbX76k9R5zutv", + "client": { + "type": "AND", + "id": "HVV", + "v": "4020100", + "name": "HVVPROD_ADHOC" + }, + "endpoint": "https://hvv-app.hafas.de/bin/mgate.exe", + "ext": "HVV.1", + "ver": "1.16", + "defaultLanguage": "de" +} diff --git a/p/hvv/index.js b/p/hvv/index.js index a0ae7129..76ce4407 100644 --- a/p/hvv/index.js +++ b/p/hvv/index.js @@ -1,27 +1,16 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'AND', id: 'HVV', name: 'HVVPROD_ADHOC', v: '4020100'} - body.ext = 'HVV.1' - body.ver = '1.16' - body.auth = {type: 'AID', aid: 'andcXUmC9Mq6hjrwDIGd2l3oiaMrTUzyH'} - - return body -} - const hvvProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://hvv-app.hafas.de/bin/mgate.exe', - - // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt - salt: Buffer.from('pqjM3iKEGOAhYbX76k9R5zutv', 'utf-8'), + // baseProfile.salt is interpreted as hex by hafas-client + salt: Buffer.from('pqjM3iKEGOAhYbX76k9R5zutv', 'utf8'), addMicMac: true, - transformReqBody, - products, trip: true, diff --git a/p/insa/base.json b/p/insa/base.json new file mode 100644 index 00000000..6627caaf --- /dev/null +++ b/p/insa/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "nasa-apps" + }, + "client": { + "type": "IPH", + "id": "NASA", + "v": "4000200", + "name": "nasaPROD" + }, + "endpoint": "https://reiseauskunft.insa.de/bin/mgate.exe", + "ver": "1.18", + "defaultLanguage": "de" +} diff --git a/p/insa/index.js b/p/insa/index.js index 3b8c91f8..7195afe2 100644 --- a/p/insa/index.js +++ b/p/insa/index.js @@ -1,27 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'NASA', - v: '4000200', - name: 'nasaPROD', - os: 'iPhone OS 11.2.5' - } - body.ver = '1.18' - body.auth = {type: 'AID', aid: "nasa-apps"} - body.lang = 'en' // todo: `de`? - - return body -} - const insaProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://reiseauskunft.insa.de/bin/mgate.exe', - transformReqBody, products: products, diff --git a/p/invg/base.json b/p/invg/base.json new file mode 100644 index 00000000..a0dfd151 --- /dev/null +++ b/p/invg/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "GITvwi3BGOmTQ2a5" + }, + "client": { + "type": "IPH", + "id": "INVG", + "v": "1040000", + "name": "invgPROD-APPSTORE-LIVE" + }, + "endpoint": "https://fpa.invg.de/bin/mgate.exe", + "ver": "1.16", + "defaultLanguage": "de" +} diff --git a/p/invg/index.js b/p/invg/index.js index 07e250bf..a0f2adf5 100644 --- a/p/invg/index.js +++ b/p/invg/index.js @@ -1,32 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'INVG', - name: 'invgPROD-APPSTORE-LIVE', - v: '1040000' - } - body.ver = '1.16' - body.auth = {type: 'AID', aid: 'GITvwi3BGOmTQ2a5'} - - return body -} - const invgProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://fpa.invg.de/bin/mgate.exe', - - // https://github.com/public-transport/hafas-client/issues/93#issuecomment-437594291 - // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt - // https://gist.github.com/derhuerst/840c72ad19065f6c55657cf1bc7aa52a#file-config-txt-L23-L24 - salt: Buffer.from('ERxotxpwFT7uYRsI', 'utf8'), - addMicMac: true, - - transformReqBody, products, diff --git a/p/irish-rail/base.json b/p/irish-rail/base.json new file mode 100644 index 00000000..32125a92 --- /dev/null +++ b/p/irish-rail/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "P9bplgVCGnozdgQE" + }, + "client": { + "type": "IPA", + "id": "IRISHRAIL", + "v": "4000100", + "name": "IrishRailPROD-APPSTORE" + }, + "endpoint": "https://journeyplanner.irishrail.ie/bin/mgate.exe", + "ver": "1.18", + "defaultLanguage": "en" +} diff --git a/p/irish-rail/index.js b/p/irish-rail/index.js index b63c3c9d..37c18221 100644 --- a/p/irish-rail/index.js +++ b/p/irish-rail/index.js @@ -1,29 +1,18 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPA', - id: 'IRISHRAIL', - v: '4000100', - name: 'IrishRailPROD-APPSTORE', - os: 'iOS 12.4.8', - } - body.ver = '1.18' - - body.auth = {type: 'AID', aid: 'P9bplgVCGnozdgQE'} body.lang = 'ga' - return body } const irishRailProfile = { + ...baseProfile, locale: 'en-IE', timezone: 'Europe/Dublin', - endpoint: 'https://journeyplanner.irishrail.ie/bin/mgate.exe', transformReqBody, - salt: Buffer.from('i5s7m3q9z6b4k1c2', 'utf8'), addMicMac: true, diff --git a/p/mobil-nrw/base.json b/p/mobil-nrw/base.json new file mode 100644 index 00000000..70a1ed05 --- /dev/null +++ b/p/mobil-nrw/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "Kdf0LNRWYg5k3499" + }, + "client": { + "type": "IPH", + "id": "DB-REGIO-NRW", + "v": "6000300", + "name": "NRW" + }, + "endpoint": "https://nrw.hafas.de/bin/mgate.exe", + "ver": "1.24", + "defaultLanguage": "de" +} diff --git a/p/mobil-nrw/index.js b/p/mobil-nrw/index.js index 737adcd4..51e554f7 100644 --- a/p/mobil-nrw/index.js +++ b/p/mobil-nrw/index.js @@ -1,31 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - id: 'DB-REGIO-NRW', - name: 'NRW', - os: 'iOS 12.4.9', - type: 'IPH', - v: '6000300', - } - body.ver = '1.24' - body.auth = { - type: 'AID', - aid: 'Kdf0LNRWYg5k3499' - } - body.lang = 'de' - // body.ext = 'DB.R19.04.a' - - return body -} - const cflProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://nrw.hafas.de/bin/mgate.exe', - transformReqBody, products, diff --git a/p/mobiliteit-lu/base.json b/p/mobiliteit-lu/base.json new file mode 100644 index 00000000..3f2d9dbb --- /dev/null +++ b/p/mobiliteit-lu/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "SkC81GuwuzL4e0" + }, + "client": { + "type": "WEB", + "id": "MMILUX", + "name": "webapp" + }, + "endpoint": "https://cdt.hafas.de/bin/mgate.exe", + "ver": "1.25", + "defaultLanguage": "de" +} diff --git a/p/mobiliteit-lu/index.js b/p/mobiliteit-lu/index.js index c8059b3b..02b9518d 100644 --- a/p/mobiliteit-lu/index.js +++ b/p/mobiliteit-lu/index.js @@ -1,26 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'WEB', - id: 'MMILUX', - name: 'webapp', - l: 'vs_webapp', - } - body.ver = '1.25' - body.auth = {type: 'AID', aid: 'SkC81GuwuzL4e0'} - body.lang = 'de' - - return body -} - const mobiliteitLuProfile = { + ...baseProfile, locale: 'de-LU', timezone: 'Europe/Luxembourg', - endpoint: 'https://cdt.hafas.de/bin/mgate.exe', - transformReqBody, products: products, diff --git a/p/nahsh/base.json b/p/nahsh/base.json new file mode 100644 index 00000000..4644cbf1 --- /dev/null +++ b/p/nahsh/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "r0Ot9FLFNAFxijLW" + }, + "client": { + "id": "NAHSH", + "v": "3000700", + "name": "NAHSHPROD" + }, + "endpoint": "https://nah.sh.hafas.de/bin/mgate.exe", + "ver": "1.16", + "defaultLanguage": "de" +} diff --git a/p/nahsh/index.js b/p/nahsh/index.js index 0a292d6b..076c942b 100644 --- a/p/nahsh/index.js +++ b/p/nahsh/index.js @@ -5,23 +5,11 @@ const {parseHook} = require('../../lib/profile-hooks') const _parseLocation = require('../../parse/location') const _parseJourney = require('../../parse/journey') const _parseMovement = require('../../parse/movement') +const baseProfile = require('./base.json') const products = require('./products') // todo: journey prices -const transformReqBody = (ctx, body) => { - body.client = { - id: 'NAHSH', - name: 'NAHSHPROD', - v: '3000700' - } - body.ver = '1.16' - body.auth = {aid: 'r0Ot9FLFNAFxijLW'} - body.lang = 'de' - - return body -} - const fixLocation = ({parsed}, l) => { // weird fix for empty lines, e.g. IC/EC at Flensburg Hbf if (parsed.lines) { @@ -79,10 +67,9 @@ const fixMovement = ({parsed}, m) => { } const nahshProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://nah.sh.hafas.de/bin/mgate.exe', - transformReqBody, products, diff --git a/p/nvv/base.json b/p/nvv/base.json new file mode 100644 index 00000000..fd120f37 --- /dev/null +++ b/p/nvv/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "Kt8eNOH7qjVeSxNA" + }, + "client": { + "type": "IPH", + "id": "NVV", + "v": "5000300", + "name": "NVVMobilPROD_APPSTORE" + }, + "endpoint": "https://auskunft.nvv.de/auskunft/bin/app/mgate.exe", + "ext": "NVV.6.0", + "ver": "1.18", + "defaultLanguage": "de" +} diff --git a/p/nvv/index.js b/p/nvv/index.js index 7adcde3a..f99c85df 100644 --- a/p/nvv/index.js +++ b/p/nvv/index.js @@ -1,31 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'NVV', - v: '5000300', - os: 'iOS 12.1.4', - name: 'NVVMobilPROD_APPSTORE' - } - body.ver = '1.18' - body.ext = 'NVV.6.0' - body.auth = {type: 'AID', aid: 'Kt8eNOH7qjVeSxNA'} - body.lang = 'de' - - return body -} - const saarfahrplanProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://auskunft.nvv.de/auskunft/bin/app/mgate.exe', - transformReqBody, - - // Although the app uses `mic` & `mac`, they don't seem to be necessary. - // addMicMac: true products: products, diff --git a/p/oebb/base.json b/p/oebb/base.json new file mode 100644 index 00000000..fdf2707f --- /dev/null +++ b/p/oebb/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "OWDL4fE4ixNiPBBm" + }, + "client": { + "type": "IPA", + "id": "OEBB", + "v": "6000500", + "name": "oebbIPAD_ADHOC" + }, + "endpoint": "http://fahrplan.oebb.at/bin/mgate.exe", + "ver": "1.16", + "defaultLanguage": "de" +} diff --git a/p/oebb/index.js b/p/oebb/index.js index 8064c37b..ada8a531 100644 --- a/p/oebb/index.js +++ b/p/oebb/index.js @@ -7,26 +7,9 @@ const {parseHook} = require('../../lib/profile-hooks') const _parseLocation = require('../../parse/location') const _parseMovement = require('../../parse/movement') +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'IPH', - id: 'OEBB', - v: '6030600', - name: 'oebbPROD-ADHOC', - os: 'iOS 14.3', - } - body.ver = '1.33' - body.auth = { - type: 'AID', - aid: 'OWDL4fE4ixNiPBBm', - } - body.lang = 'de' - - return body -} - // ÖBB has some 'stations' **in austria** with no departures/products, // like station entrances, that are actually POIs. const fixWeirdPOIs = ({parsed}) => { @@ -61,11 +44,10 @@ const fixMovement = ({parsed}, m) => { } const oebbProfile = { + ...baseProfile, locale: 'de-AT', timezone: 'Europe/Vienna', - // todo: there is also https://beta.verkehrsauskunft.at/bin/mgate.exe - endpoint: 'https://fahrplan.oebb.at/bin/mgate.exe', - transformReqBody, + defaultLanguage: 'de', products: products, diff --git a/p/pkp/base.json b/p/pkp/base.json new file mode 100644 index 00000000..53b015cc --- /dev/null +++ b/p/pkp/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "DrxJYtYZQpEBCtcb" + }, + "client": { + "type": "AND", + "id": "HAFAS" + }, + "endpoint": "https://mobil.rozklad-pkp.pl:8019/bin/mgate.exe", + "ver": "1.21", + "defaultLanguage": "en" +} diff --git a/p/pkp/index.js b/p/pkp/index.js index e911f4f7..b3e279d8 100644 --- a/p/pkp/index.js +++ b/p/pkp/index.js @@ -3,16 +3,9 @@ const {parseHook} = require('../../lib/profile-hooks') const parseLocation = require('../../parse/location') +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'AND', id: 'HAFAS', name: 'Rozklad-PKP', v: '1000110'} - body.ver = '1.18' // 1.24 is used by the app, but that version doesn't support getPassList for departures/arrivals - body.auth = {type: 'AID', aid: 'DrxJYtYZQpEBCtcb'} - - return body -} - const trimStopName = ({parsed}, l) => { if (parsed.type === 'stop' || parsed.type === 'station' && parsed.name) { parsed.name = parsed.name.replace(/(^-|-$)/g, '') @@ -21,11 +14,9 @@ const trimStopName = ({parsed}, l) => { } const pkpProfile = { + ...baseProfile, locale: 'pl-PL', timezone: 'Europe/Warsaw', - endpoint: 'https://mobil.rozklad-pkp.pl:8019/bin/mgate.exe', - - transformReqBody, products, diff --git a/p/rejseplanen/base.json b/p/rejseplanen/base.json new file mode 100644 index 00000000..a01451f7 --- /dev/null +++ b/p/rejseplanen/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "irkmpm9mdznstenr-android" + }, + "client": { + "type": "AND", + "id": "DK" + }, + "endpoint": "https://mobilapps.rejseplanen.dk/bin/iphone.exe", + "ext": "DK.9", + "ver": "1.21", + "defaultLanguage": "dk" +} diff --git a/p/rejseplanen/index.js b/p/rejseplanen/index.js index 348bf1e8..cc871ccf 100644 --- a/p/rejseplanen/index.js +++ b/p/rejseplanen/index.js @@ -1,21 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.ext = 'DK.9' - body.client = {type: 'AND', id: 'DK'} - body.ver = '1.21' - body.auth = {type: 'AID', aid: 'irkmpm9mdznstenr-android'} - - return body -} - const rejseplanenProfile = { + ...baseProfile, locale: 'da-DK', timezone: 'Europe/Copenhagen', - endpoint: 'https://mobilapps.rejseplanen.dk/bin/iphone.exe', - transformReqBody, products: products, diff --git a/p/rmv/base.json b/p/rmv/base.json new file mode 100644 index 00000000..c7fcc649 --- /dev/null +++ b/p/rmv/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "x0k4ZR33ICN9CWmj" + }, + "client": { + "type": "WEB", + "id": "RMV", + "name": "webapp" + }, + "endpoint": "https://www.rmv.de/auskunft/bin/jp/mgate.exe", + "ext": "RMV.1", + "ver": "1.18", + "defaultLanguage": "de" +} diff --git a/p/rmv/index.js b/p/rmv/index.js index dd054336..1527043b 100644 --- a/p/rmv/index.js +++ b/p/rmv/index.js @@ -1,22 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'WEB', id: 'RMV', name: 'webapp'} - body.ext = 'RMV.1' - body.ver = '1.18' - body.auth = {type: 'AID', aid: 'x0k4ZR33ICN9CWmj'} - - return body -} - const hvvProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://www.rmv.de/auskunft/bin/jp/mgate.exe', - - transformReqBody, products, diff --git a/p/rsag/base.json b/p/rsag/base.json new file mode 100644 index 00000000..3f22799d --- /dev/null +++ b/p/rsag/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "tF5JTs25rzUhGrrl" + }, + "client": { + "type": "WEB", + "id": "RSAG", + "name": "webapp" + }, + "endpoint": "https://fahrplan.rsag-online.de/bin/mgate.exe", + "ext": "VBN.2", + "ver": "1.24", + "defaultLanguage": "de" +} diff --git a/p/rsag/index.js b/p/rsag/index.js index 2799e50c..38793b54 100644 --- a/p/rsag/index.js +++ b/p/rsag/index.js @@ -1,22 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'WEB', id: 'RSAG', name: 'webapp'} - body.ext = 'VBN.2' - body.ver = '1.24' - body.auth = {type: 'AID', aid: 'tF5JTs25rzUhGrrl'} - - return body -} - const rsagProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://fahrplan.rsag-online.de/bin/mgate.exe', - - transformReqBody, products, diff --git a/p/saarfahrplan/base.json b/p/saarfahrplan/base.json new file mode 100644 index 00000000..30b351d6 --- /dev/null +++ b/p/saarfahrplan/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "51XfsVqgbdA6oXzHrx75jhlocRg6Xe" + }, + "client": { + "type": "AND", + "id": "ZPS-SAAR", + "v": 1000070, + "name": "Saarfahrplan" + }, + "endpoint": "https://saarfahrplan.de/bin/mgate.exe", + "ver": "1.21", + "defaultLanguage": "de" +} diff --git a/p/saarfahrplan/index.js b/p/saarfahrplan/index.js index 1be1b9cc..54a2d84d 100644 --- a/p/saarfahrplan/index.js +++ b/p/saarfahrplan/index.js @@ -3,23 +3,9 @@ const {parseHook} = require('../../lib/profile-hooks') const _parseMovement = require('../../parse/movement') +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = { - type: 'AND', - id: 'ZPS-SAAR', - v: 1000070, - name: 'Saarfahrplan', - os: 'Android 9' - } - body.ver = '1.21' - body.auth = {type: 'AID', aid: '51XfsVqgbdA6oXzHrx75jhlocRg6Xe'} - body.lang = 'de' - - return body -} - const fixMovement = ({parsed}, m) => { // filter out empty stopovers parsed.nextStopovers = parsed.nextStopovers.filter(st => !!st.stop) @@ -27,12 +13,9 @@ const fixMovement = ({parsed}, m) => { } const saarfahrplanProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://saarfahrplan.de/bin/mgate.exe', - transformReqBody, - - // decrypted form of https://gist.github.com/derhuerst/f5a8c07f9b3226ecad6c8f64d83df6a2#file-haf_config_base-properties-L70 salt: Buffer.from('HJtlubisvxiJxss', 'utf8'), addMicMac: true, diff --git a/p/sbahn-muenchen/base.json b/p/sbahn-muenchen/base.json new file mode 100644 index 00000000..040ead13 --- /dev/null +++ b/p/sbahn-muenchen/base.json @@ -0,0 +1,17 @@ +{ + "auth": { + "type": "AID", + "aid": "d491MVVhz9ZZts23" + }, + "salt": "ggnvMVV8RTt67gh1", + "client": { + "type": "IPH", + "id": "DB-REGIO-MVV", + "v": "5010100", + "name": "MuenchenNavigator" + }, + "endpoint": "https://s-bahn-muenchen.hafas.de/bin/540/mgate.exe", + "ext": "DB.R15.12.a", + "ver": "1.21", + "defaultLanguage": "en" +} diff --git a/p/sbahn-muenchen/index.js b/p/sbahn-muenchen/index.js index 99eb26c0..2e9593e1 100644 --- a/p/sbahn-muenchen/index.js +++ b/p/sbahn-muenchen/index.js @@ -1,24 +1,14 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPH', id: 'DB-REGIO-MVV', name: 'MuenchenNavigator', v: '5010100'} - body.ext = 'DB.R15.12.a' - body.ver = '1.21' - body.auth = {type: 'AID', aid: 'd491MVVhz9ZZts23'} - - return body -} - const sBahnMunichProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://s-bahn-muenchen.hafas.de/bin/540/mgate.exe', - salt: Buffer.from('ggnvMVV8RTt67gh1', 'utf8'), addMicMac: true, - transformReqBody, products, diff --git a/p/sbb/base.json b/p/sbb/base.json new file mode 100644 index 00000000..38d35f28 --- /dev/null +++ b/p/sbb/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "hf7mcf9bv3nv8g5f" + }, + "client": { + "type": "AND", + "id": "DBZUGRADARNETZ", + "v": "" + }, + "endpoint": "http://fahrplan.sbb.ch/bin/mgate.exe", + "ver": "1.18", + "defaultLanguage": "de" +} diff --git a/p/sbb/index.js b/p/sbb/index.js index 9788fe81..bf0cda13 100644 --- a/p/sbb/index.js +++ b/p/sbb/index.js @@ -1,27 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - // sourced from https://github.com/marudor/BahnhofsAbfahrten/blob/1c99d8b/packages/server/HAFAS/profiles.ts#L344-L361 - body.client = { - type: 'AND', - id: 'DBZUGRADARNETZ', - v: '', - } - body.ver = '1.18' - body.auth = { aid: 'hf7mcf9bv3nv8g5f', type:'AID' } - body.lang = 'deu' - - return body -} - const sbbProfile = { + ...baseProfile, locale: 'de-CH', timezone: 'Europe/Zurich', - // todo: find a way to use https: - endpoint: 'http://fahrplan.sbb.ch/bin/mgate.exe', - transformReqBody, products: products, diff --git a/p/sncb/base.json b/p/sncb/base.json new file mode 100644 index 00000000..3c397f4e --- /dev/null +++ b/p/sncb/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "sncb-mobi" + }, + "client": { + "type": "IPH", + "id": "SNCB", + "v": "4030200", + "name": "sncb" + }, + "endpoint": "https://www.belgianrail.be/jp/sncb-nmbs-routeplanner/mgate.exe", + "ver": "1.16", + "defaultLanguage": "fr" +} diff --git a/p/sncb/index.js b/p/sncb/index.js index d0b6193d..2f95675a 100644 --- a/p/sncb/index.js +++ b/p/sncb/index.js @@ -6,6 +6,7 @@ const {Agent} = require('https') const {strictEqual: eql} = require('assert') const {parseHook} = require('../../lib/profile-hooks') const parseLine = require('../../parse/line') +const baseProfile = require('./base.json') const products = require('./products') // `www.belgianrail.be:443` doesn't provide the necessary CA certificate @@ -15,15 +16,6 @@ const ca = readFileSync(join(__dirname, 'digicert-sha2-secure-server-ca.crt.pem' const agent = new Agent({ca}) const transformReq = (ctx, req) => ({...req, agent}) -const transformReqBody = ({opt}, body) => { - body.client = {type: 'IPH', id: 'SNCB', name: 'sncb', v: '4030200'} - body.ver = '1.16' - body.auth = {type: 'AID', aid: 'sncb-mobi'} - body.lang = opt.language || 'fr' - - return body -} - // todo: this is ugly const lineNameWithoutFahrtNr = ({parsed}) => { const {name, fahrtNr} = parsed @@ -54,12 +46,11 @@ eql(lineNameWithoutFahrtNr({ }).name, 'S1 123a') const sncbProfile = { + ...baseProfile, locale: 'fr-BE', timezone: 'Europe/Brussels', - endpoint: 'https://www.belgianrail.be/jp/sncb-nmbs-routeplanner/mgate.exe', transformReq, - transformReqBody, products, diff --git a/p/svv/base.json b/p/svv/base.json new file mode 100644 index 00000000..db779ae4 --- /dev/null +++ b/p/svv/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "wf7mcf9bv3nv8g5f" + }, + "client": { + "type": "WEB", + "id": "VAO", + "name": "webapp" + }, + "endpoint": "https://fahrplan.salzburg-verkehr.at/bin/mgate.exe", + "ext": "VAO.11", + "ver": "1.20", + "defaultLanguage": "de" +} diff --git a/p/svv/index.js b/p/svv/index.js index ae0d635f..a2a13d9b 100644 --- a/p/svv/index.js +++ b/p/svv/index.js @@ -1,21 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'WEB', id: 'VAO', name: 'webapp'} - body.ext = 'VAO.11' - body.ver = '1.20' - body.auth = {type: 'AID', aid: 'wf7mcf9bv3nv8g5f'} - return body -} - const svvProfile = { + ...baseProfile, locale: 'at-DE', timezone: 'Europe/Vienna', - endpoint: 'https://fahrplan.salzburg-verkehr.at/bin/mgate.exe', - - transformReqBody, products, diff --git a/p/vbb/base.json b/p/vbb/base.json new file mode 100644 index 00000000..fd487f41 --- /dev/null +++ b/p/vbb/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "hafas-vbb-apps" + }, + "client": { + "type": "IPA", + "id": "VBB", + "v": "4010300", + "name": "vbbPROD" + }, + "endpoint": "https://fahrinfo.vbb.de/bin/mgate.exe", + "ext": "VBB.1", + "ver": "1.16", + "defaultLanguage": "de" +} diff --git a/p/vbb/index.js b/p/vbb/index.js index f90e51e0..2ff43c18 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -13,17 +13,9 @@ const _parseJourney = require('../../parse/journey') const _parseDeparture = require('../../parse/departure') const _formatStation = require('../../format/station') +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPA', id: 'VBB', name: 'vbbPROD', v: '4010300'} - body.ext = 'VBB.1' - body.ver = '1.16' - body.auth = {type: 'AID', aid: 'hafas-vbb-apps'} - - return body -} - // todo: https://m.tagesspiegel.de/berlin/fahrerlebnis-wie-im-regionalexpress-so-faehrt-es-sich-in-der-neuen-express-s-bahn/25338674.html const parseLineWithMoreDetails = ({parsed}, p) => { parsed.name = p.name.replace(/^(bus|tram)\s+/i, '') @@ -98,17 +90,14 @@ const formatStation = (id) => { } const vbbProfile = { + ...baseProfile, 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'), + salt: Buffer.from('RCTJM2fFxFfxxQfI', 'utf8'), addMicMac: true, - transformReqBody, - products: products, parseLine: parseHook(_parseLine, parseLineWithMoreDetails), diff --git a/p/vbn/base.json b/p/vbn/base.json new file mode 100644 index 00000000..293da284 --- /dev/null +++ b/p/vbn/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "kaoxIXLn03zCr2KR" + }, + "client": { + "type": "IPH", + "id": "VBN", + "v": "6000000", + "name": "vbn" + }, + "endpoint": "https://fahrplaner.vbn.de/bin/mgate.exe", + "ver": "1.27", + "defaultLanguage": "de" +} diff --git a/p/vbn/index.js b/p/vbn/index.js index d2779bff..a0e310e1 100644 --- a/p/vbn/index.js +++ b/p/vbn/index.js @@ -1,27 +1,17 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPH', id: 'VBN', name: 'vbn', v: '6000000'} - body.ver = '1.27' - body.auth = {type: 'AID', aid: 'kaoxIXLn03zCr2KR'} - - return body -} - const insaProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://fahrplaner.vbn.de/bin/mgate.exe', - // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt // https://gist.github.com/derhuerst/fd2f81a597bde66cb1f689006d574d7f#file-config-txt-L22-L23 salt: Buffer.from('SP31mBufSyCLmNxp', 'utf-8'), addMicMac: true, - transformReqBody, - products: products, trip: true, diff --git a/p/vkg/base.json b/p/vkg/base.json new file mode 100644 index 00000000..91a6bb8f --- /dev/null +++ b/p/vkg/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "wf7mcf9bv3nv8g5f" + }, + "client": { + "type": "WEB", + "id": "VAO", + "name": "webapp" + }, + "endpoint": "https://routenplaner.kaerntner-linien.at/bin/mgate.exe", + "defaultLanguage": "de" +} diff --git a/p/vkg/index.js b/p/vkg/index.js index 42cc0082..bc67da99 100644 --- a/p/vkg/index.js +++ b/p/vkg/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + const products = [{ // todo: what is `8`? id: 'trains', mode: 'train', @@ -73,22 +75,10 @@ const products = [{ // todo: what is `8`? }] const vosProfile = { + ...baseProfile, locale: 'at-DE', timezone: 'Europe/Vienna', - endpoint: 'https://routenplaner.kaerntner-linien.at/bin/mgate.exe', - - auth: { - type: 'AID', - aid: 'wf7mcf9bv3nv8g5f', - }, - client: { - id: 'VAO', - type: 'WEB', - name: 'webapp', - l: 'vs_vkg', - }, ver: '1.32', - // todo: lang products, diff --git a/p/vmt/base.json b/p/vmt/base.json new file mode 100644 index 00000000..7416fb7c --- /dev/null +++ b/p/vmt/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "t2h7u1e6r4i8n3g7e0n" + }, + "client": { + "type": "IPH", + "id": "HAFAS", + "v": "2040100", + "name": "VMT" + }, + "endpoint": "https://vmt.hafas.de/bin/ticketing/mgate.exe", + "ver": "1.18", + "defaultLanguage": "de" +} diff --git a/p/vmt/index.js b/p/vmt/index.js index 1706ad82..9ddc50f2 100644 --- a/p/vmt/index.js +++ b/p/vmt/index.js @@ -1,28 +1,17 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPH', id: 'HAFAS', name: 'VMT', v: '2040100'} - body.ver = '1.18' - body.auth = {type: 'AID', aid: 't2h7u1e6r4i8n3g7e0n'} - - return body -} - const hvvProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - // todo: what about `https://vmt.hafas.de/bin/mgate.exe`? - endpoint: 'https://vmt.hafas.de/bin/ticketing/mgate.exe', - // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt // https://gist.github.com/derhuerst/b20adde9f614ceb6b2a8b9c7f4487da8#file-hafas-config-L31-L32 salt: Buffer.from('7x8d3n2a5m1b3c6z', 'utf-8'), addMicMac: true, - transformReqBody, - products, trip: true, diff --git a/p/vos/base.json b/p/vos/base.json new file mode 100644 index 00000000..ec21354b --- /dev/null +++ b/p/vos/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "PnYowCQP7Tp1V" + }, + "client": { + "type": "WEB", + "id": "SWO", + "name": "webapp" + }, + "endpoint": "https://fahrplan.vos.info/bin/mgate.exe", + "defaultLanguage": "de" +} diff --git a/p/vos/index.js b/p/vos/index.js index f6b800b4..f7c46ac4 100644 --- a/p/vos/index.js +++ b/p/vos/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + const products = [{ id: 'ice', mode: 'train', @@ -73,20 +75,9 @@ const products = [{ }] const vosProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://fahrplan.vos.info/bin/mgate.exe', - - auth: { - type: 'AID', - aid: 'PnYowCQP7Tp1V', - }, - client: { - id: 'SWO', - type: 'WEB', - name: 'webapp', - l: 'vs_swo', - }, ver: '1.32', products, diff --git a/p/vrn/base.json b/p/vrn/base.json new file mode 100644 index 00000000..c985d72f --- /dev/null +++ b/p/vrn/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "p091VRNZz79KtUz5" + }, + "client": { + "type": "IPH", + "id": "DB-REGIO-VRN", + "v": "6000400", + "name": "VRN" + }, + "endpoint": "https://vrn.hafas.de/bin/mgate.exe", + "ext": "DB.R19.04.a", + "ver": "1.24", + "defaultLanguage": "de" +} diff --git a/p/vrn/index.js b/p/vrn/index.js index 20a1bd33..f4d401c9 100644 --- a/p/vrn/index.js +++ b/p/vrn/index.js @@ -1,16 +1,8 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPH', id: 'DB-REGIO-VRN', name: 'VRN', v: '6000400'} - body.ext = 'DB.R19.04.a' - body.ver = '1.24' - body.auth = {type: 'AID', aid: 'p091VRNZz79KtUz5'} - - return body -} - const formatRefreshJourneyReq = ({opt}, refreshToken) => { return { meth: 'Reconstruction', @@ -23,11 +15,9 @@ const formatRefreshJourneyReq = ({opt}, refreshToken) => { module.exports = formatRefreshJourneyReq const hvvProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://vrn.hafas.de/bin/mgate.exe', - - transformReqBody, products, diff --git a/p/vsn/base.json b/p/vsn/base.json new file mode 100644 index 00000000..295fdca6 --- /dev/null +++ b/p/vsn/base.json @@ -0,0 +1,15 @@ +{ + "auth": { + "type": "AID", + "aid": "Mpf5UPC0DmzV8jkg" + }, + "client": { + "type": "IPA", + "id": "VSN", + "v": "5030100", + "name": "vsn" + }, + "endpoint": "https://fahrplaner.vsninfo.de/hafas/mgate.exe", + "ver": "1.24", + "defaultLanguage": "de" +} diff --git a/p/vsn/index.js b/p/vsn/index.js index b3757003..db67da59 100644 --- a/p/vsn/index.js +++ b/p/vsn/index.js @@ -1,45 +1,17 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPA', id: 'VSN', name: 'vsn', v: '5030100', os: 'iOS 13.3'} - body.ver = '1.24' - body.auth = {type: 'AID', aid: 'Mpf5UPC0DmzV8jkg'} - body.lang = 'de' - - return body -} - -const formatRefreshJourneyReq = (ctx, refreshToken) => { - // eslint-disable-next-line no-unused-vars - const {profile, opt} = ctx - - return { - meth: 'Reconstruction', - req: { - outReconL: [{ctx: refreshToken}], - getIST: true, // todo: make an option - getPasslist: !!opt.stopovers, - getPolyline: !!opt.polylines, - getTariff: !!opt.tickets - } - } -} - const vsnProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://fahrplaner.vsninfo.de/hafas/mgate.exe', - // https://gist.github.com/n0emis/3b6887572793f4f54da9d83b30548332#file-haf_config_base-properties-L31 // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt - salt: Buffer.from('535033316d4275665379434c6d4e7870', 'hex'), + salt: Buffer.from('SP31mBufSyCLmNxp', 'utf8'), addMicMac: true, - transformReqBody, - formatRefreshJourneyReq, - products: products, trip: true, diff --git a/p/vvt/base.json b/p/vvt/base.json new file mode 100644 index 00000000..7e528733 --- /dev/null +++ b/p/vvt/base.json @@ -0,0 +1,13 @@ +{ + "auth": { + "type": "AID", + "aid": "wf7mcf9bv3nv8g5f" + }, + "client": { + "type": "WEB", + "id": "VAO", + "name": "webapp" + }, + "endpoint": "https://smartride.vvt.at/bin/mgate.exe", + "defaultLanguage": "de" +} diff --git a/p/vvt/index.js b/p/vvt/index.js index 62ec753c..41133833 100644 --- a/p/vvt/index.js +++ b/p/vvt/index.js @@ -1,5 +1,7 @@ 'use strict' +const baseProfile = require('./base.json') + const products = [{ // todo: what is `8`? id: 'trains', mode: 'train', @@ -73,22 +75,10 @@ const products = [{ // todo: what is `8`? }] const vvtProfile = { + ...baseProfile, locale: 'at-DE', timezone: 'Europe/Vienna', - endpoint: 'https://smartride.vvt.at/bin/mgate.exe', - - auth: { - type: 'AID', - aid: 'wf7mcf9bv3nv8g5f', - }, - client: { - id: 'VAO', - type: 'WEB', - name: 'webapp', - l: 'vs_vvt', - }, ver: '1.32', - // todo: lang products, diff --git a/p/zvv/base.json b/p/zvv/base.json new file mode 100644 index 00000000..97e35045 --- /dev/null +++ b/p/zvv/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "TLRUqdDPF7ttB824Yoy2BN8mk" + }, + "client": { + "type": "IPH", + "id": "ZVV", + "v": "6000400", + "name": "zvvPROD-STORE" + }, + "endpoint": "https://online.fahrplan.zvv.ch/bin/mgate.exe", + "ext": "ZVV.2", + "ver": "1.24", + "defaultLanguage": "de" +} diff --git a/p/zvv/index.js b/p/zvv/index.js index 49787883..f6ec985d 100644 --- a/p/zvv/index.js +++ b/p/zvv/index.js @@ -1,26 +1,12 @@ 'use strict' +const baseProfile = require('./base.json') const products = require('./products') -const transformReqBody = (ctx, body) => { - body.client = {type: 'IPH', id: 'ZVV', name: 'zvvPROD-STORE', v: '6000400'} - body.ext = 'ZVV.2' - body.ver = '1.24' - body.auth = {type: 'AID', aid: 'TLRUqdDPF7ttB824Yoy2BN8mk'} - - return body -} - const zvvProfile = { + ...baseProfile, locale: 'de-CH', timezone: 'Europe/Zurich', - endpoint: 'https://online.fahrplan.zvv.ch/bin/mgate.exe', - - // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt - salt: Buffer.from('jCcZ864meuAbqGZ', 'utf-8'), - addMicMac: true, - - transformReqBody, products, diff --git a/tools/pull-profile-base-data.sh b/tools/pull-profile-base-data.sh index 804c45a0..ca15e558 100755 --- a/tools/pull-profile-base-data.sh +++ b/tools/pull-profile-base-data.sh @@ -20,11 +20,45 @@ query="(\ }, \ endpoint: p(_, 'options.endpoint'), \ ext: p(_, 'options.ext'), \ - ver: p(_, 'options.ver'), \ + ver: p(_, 'options.ver', p(_, 'options.version')), \ + defaultLanguage: _.supportedLanguages && _.supportedLanguages[0] || undefined, \ }, null, '\\t') )( require('lodash/get'), JSON.parse(require('fs').readFileSync(process.argv[1], {encoding: 'utf8'})), )" -jq -r --tab "$query" <"$src/de/db-hafas-mgate.json" >../p/db/base.json +node -p "$query" "$src/de/avv-hafas-mgate.json" >../p/avv/base.json +node -p "$query" "$src/us/bart-hafas-mgate.json" >../p/bart/base.json +node -p "$query" "$src/de/bvg-hafas-mgate.json" >../p/bvg/base.json +node -p "$query" "$src/lu/cfl-hafas-mgate.json" >../p/cfl/base.json +node -p "$query" "$src/us/cmta-hafas-mgate.json" >../p/cmta/base.json +node -p "$query" "$src/de/db-hafas-mgate.json" >../p/db/base.json +node -p "$query" "$src/de/db-busradar-nrw-hafas-mgate.json" >../p/db-busradar-nrw/base.json +node -p "$query" "$src/de/hvv-hafas-mgate.json" >../p/hvv/base.json +node -p "$query" "$src/de/nasa-hafas-mgate.json" >../p/insa/base.json +node -p "$query" "$src/de/invg-hafas-mgate.json" >../p/invg/base.json +node -p "$query" "$src/ie/iarnrod-eireann-hafas-mgate.json" >../p/irish-rail/base.json +node -p "$query" "$src/de/mobil-nrw-hafas-mgate.json" >../p/mobil-nrw/base.json +node -p "$query" "$src/lu/mobiliteit-lu-hafas-mgate.json" >../p/mobiliteit-lu/base.json +node -p "$query" "$src/de/nahsh-hafas-mgate.json" >../p/nahsh/base.json +node -p "$query" "$src/de/nvv-hafas-mgate.json" >../p/nvv/base.json +node -p "$query" "$src/at/oebb-hafas-mgate.json" >../p/oebb/base.json +node -p "$query" "$src/pl/pkp-hafas-mgate.json" >../p/pkp/base.json +node -p "$query" "$src/dk/rejseplanen-hafas-mgate.json" >../p/rejseplanen/base.json +node -p "$query" "$src/de/rmv-hafas-mgate.json" >../p/rmv/base.json +node -p "$query" "$src/de/rsag-hafas-mgate.json" >../p/rsag/base.json +node -p "$query" "$src/de/saarvv-hafas-mgate.json" >../p/saarfahrplan/base.json +node -p "$query" "$src/de/db-sbahn-muenchen-hafas-mgate.json" >../p/sbahn-muenchen/base.json +node -p "$query" "$src/ch/sbb-cff-ffs-hafas-mgate.json" >../p/sbb/base.json +node -p "$query" "$src/be/nmbs-sncb-hafas-mgate.json" >../p/sncb/base.json +node -p "$query" "$src/at/svv-hafas-mgate.json" >../p/svv/base.json +node -p "$query" "$src/de/vbb-hafas-mgate.json" >../p/vbb/base.json +node -p "$query" "$src/de/vbn-hafas-mgate.json" >../p/vbn/base.json +node -p "$query" "$src/at/vkg-hafas-mgate.json" >../p/vkg/base.json +node -p "$query" "$src/de/vmt-hafas-mgate.json" >../p/vmt/base.json +node -p "$query" "$src/de/vos-hafas-mgate.json" >../p/vos/base.json +node -p "$query" "$src/de/vrn-hafas-mgate.json" >../p/vrn/base.json +node -p "$query" "$src/de/vsn-hafas-mgate.json" >../p/vsn/base.json +node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json +node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json diff --git a/tools/transport-apis b/tools/transport-apis index d15fa68b..03095950 160000 --- a/tools/transport-apis +++ b/tools/transport-apis @@ -1 +1 @@ -Subproject commit d15fa68b3b4703ee172d706ea39b148e9dd8bd47 +Subproject commit 03095950efe3e938eeb262b4a79180fb9a279fb6