@@ -3061,7 +3061,7 @@ class VwWeconnect extends utils.Adapter {
30613061 let credentials = await this . loadFcmCredentials ( ) ;
30623062
30633063 if ( credentials && credentials . fcm && credentials . fcm . registration && credentials . fcm . registration . token ) {
3064- if ( credentials . version !== 2 ) {
3064+ if ( credentials . version !== 3 ) {
30653065 this . log . info ( "MQTT: FCM credentials outdated (missing Android headers), re-registering..." ) ;
30663066 credentials = null ;
30673067 } else {
@@ -3086,7 +3086,7 @@ class VwWeconnect extends utils.Adapter {
30863086 const keys = this . generateFcmKeys ( ) ;
30873087 const registration = await this . fcmRegister ( gcmData , installation , keys ) ;
30883088
3089- credentials = { version : 2 , gcm : gcmData , fcm : { installation, registration } , keys } ;
3089+ credentials = { version : 3 , gcm : gcmData , fcm : { installation, registration } , keys } ;
30903090 await this . saveFcmCredentials ( credentials ) ;
30913091 this . log . info ( "MQTT: FCM registration successful" ) ;
30923092
@@ -3135,7 +3135,7 @@ class VwWeconnect extends utils.Adapter {
31353135 }
31363136
31373137 async gcmRegister ( checkinData ) {
3138- const appId = `wp:cz.skodaauto.myskoda #${ crypto . randomUUID ( ) } ` ;
3138+ const appId = `wp:receiver.push.com #${ crypto . randomUUID ( ) } ` ;
31393139 const body = new URLSearchParams ( {
31403140 app : "org.chromium.linux" ,
31413141 "X-subtype" : appId ,
@@ -3222,10 +3222,11 @@ class VwWeconnect extends utils.Adapter {
32223222 const ecdh = crypto . createECDH ( "prime256v1" ) ;
32233223 ecdh . generateKeys ( ) ;
32243224 const authSecret = crypto . randomBytes ( 16 ) ;
3225+ const addPadding = ( b64 ) => b64 + "=" . repeat ( ( 4 - ( b64 . length % 4 ) ) % 4 ) ;
32253226 return {
3226- publicKey : ecdh . getPublicKey ( "base64url" ) ,
3227- privateKey : ecdh . getPrivateKey ( "base64url" ) ,
3228- authSecret : authSecret . toString ( "base64url" ) ,
3227+ publicKey : addPadding ( ecdh . getPublicKey ( "base64url" ) ) ,
3228+ privateKey : addPadding ( ecdh . getPrivateKey ( "base64url" ) ) ,
3229+ authSecret : addPadding ( authSecret . toString ( "base64url" ) ) ,
32293230 } ;
32303231 }
32313232
@@ -3238,15 +3239,24 @@ class VwWeconnect extends utils.Adapter {
32383239 headers : {
32393240 "Content-Type" : "application/json" ,
32403241 Authorization : `Bearer ${ this . config . atoken } ` ,
3242+ "User-Agent" :
3243+ "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.185 Mobile Safari/537.36" ,
3244+ Accept :
3245+ "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3" ,
3246+ "Accept-Language" : "en-US,en;q=0.9" ,
3247+ "Accept-Encoding" : "gzip, deflate" ,
3248+ "x-requested-with" : "cz.skodaauto.connect" ,
32413249 } ,
3242- body : JSON . stringify ( { devicePlatform : "ANDROID" , appVersion : "8.11.0" , language : "de" } ) ,
3250+ body : JSON . stringify ( { devicePlatform : "ANDROID" , appVersion : "8.11.0" , language : "en" } ) ,
3251+ redirect : "follow" ,
32433252 } ,
32443253 ) ;
32453254 if ( res . ok ) {
32463255 this . log . debug ( "MQTT: FCM token registered with Skoda (" + res . status + ")" ) ;
32473256 return true ;
32483257 } else {
3249- this . log . warn ( "MQTT: FCM token registration returned " + res . status ) ;
3258+ const body = await res . text ( ) ;
3259+ this . log . warn ( "MQTT: FCM token registration returned " + res . status + ": " + body . substring ( 0 , 200 ) ) ;
32503260 return false ;
32513261 }
32523262 } catch ( e ) {
0 commit comments