@@ -1209,12 +1209,7 @@ class VwWeconnect extends utils.Adapter {
12091209 return ;
12101210 }
12111211
1212- let hash = "" ;
1213- if ( getRequest . uri . hash ) {
1214- hash = getRequest . uri . hash ;
1215- } else {
1216- hash = getRequest . uri . query ;
1217- }
1212+ const hash = getRequest . uri . hash || getRequest . uri . query ;
12181213 const hashArray = hash . split ( "&" ) ;
12191214 // eslint-disable-next-line no-unused-vars
12201215 let state ;
@@ -1333,12 +1328,10 @@ class VwWeconnect extends utils.Adapter {
13331328 }
13341329 if ( this . config . type === "id" ) {
13351330 url = "https://emea.bff.cariad.digital/user-login/login/v1" ;
1336- let redirerctUri = "weconnect://authenticated" ;
1337-
13381331 body = JSON . stringify ( {
13391332 state : jwtstate ,
13401333 id_token : jwtid_token ,
1341- redirect_uri : redirerctUri ,
1334+ redirect_uri : "weconnect://authenticated" ,
13421335 region : "emea" ,
13431336 access_token : jwtaccess_token ,
13441337 authorizationCode : jwtauth_code ,
@@ -1357,7 +1350,6 @@ class VwWeconnect extends utils.Adapter {
13571350 url =
13581351 "https://prod.emea.cbs.charging.cariad.digital/user-identity/v1/identity/login?redirect_uri=wecharge://authenticated&code=" +
13591352 jwtauth_code ;
1360- redirerctUri = "wecharge://authenticated" ;
13611353 headers [ "x-api-key" ] = "yabajourasW9N8sm+9F/oP==" ;
13621354 }
13631355 }
@@ -4272,9 +4264,6 @@ class VwWeconnect extends utils.Adapter {
42724264 this . log . debug ( "We Charge disabled in config" ) ;
42734265 return ;
42744266 }
4275- if ( ! limit ) {
4276- limit = 25 ;
4277- }
42784267 const wechargeState = await this . getObjectAsync ( "wecharge" ) ;
42794268 if ( wechargeState ) {
42804269 if ( wechargeState . type !== "channel" ) {
@@ -5735,25 +5724,21 @@ class VwWeconnect extends utils.Adapter {
57355724 } ) ;
57365725 }
57375726 getCodeChallenge ( ) {
5738- let hash = "" ;
5739- let result = "" ;
57405727 const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
5741- result = "" ;
5728+ let result = "" ;
57425729 for ( let i = 64 ; i > 0 ; -- i ) result += chars [ Math . floor ( Math . random ( ) * chars . length ) ] ;
57435730 result = Buffer . from ( result ) . toString ( "base64" ) ;
57445731 result = result . replace ( / \+ / g, "-" ) . replace ( / \/ / g, "_" ) . replace ( / = / g, "" ) ;
5745- hash = crypto . createHash ( "sha256" ) . update ( result ) . digest ( "base64" ) ;
5732+ let hash = crypto . createHash ( "sha256" ) . update ( result ) . digest ( "base64" ) ;
57465733 hash = hash . replace ( / \+ / g, "-" ) . replace ( / \/ / g, "_" ) . replace ( / = / g, "" ) ;
57475734
57485735 return [ result , hash ] ;
57495736 }
57505737 getCodeChallengev2 ( ) {
5751- let hash = "" ;
5752- let result = "" ;
57535738 const chars = "0123456789abcdef" ;
5754- result = "" ;
5739+ let result = "" ;
57555740 for ( let i = 64 ; i > 0 ; -- i ) result += chars [ Math . floor ( Math . random ( ) * chars . length ) ] ;
5756- hash = crypto . createHash ( "sha256" ) . update ( result ) . digest ( "base64" ) ;
5741+ let hash = crypto . createHash ( "sha256" ) . update ( result ) . digest ( "base64" ) ;
57575742 hash = hash . replace ( / \+ / g, "-" ) . replace ( / \/ / g, "_" ) . replace ( / = / g, "" ) ;
57585743
57595744 return [ result , hash ] ;
0 commit comments