File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
accessibility-automation/plugin Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 11const path = require ( "node:path" ) ;
2+ const { decodeJWTToken } = require ( "../../helpers/utils" ) ;
3+ const utils = require ( '../../helpers/utils' ) ;
24
35const browserstackAccessibility = ( on , config ) => {
46 let browser_validation = true ;
@@ -31,6 +33,19 @@ const browserstackAccessibility = (on, config) => {
3133 if ( browser_validation ) {
3234 const ally_path = path . dirname ( process . env . ACCESSIBILITY_EXTENSION_PATH )
3335 launchOptions . extensions . push ( ally_path ) ;
36+ try {
37+ const { _, payload} = decodeJWTToken ( process . env . ACCESSIBILITY_AUTH ) ;
38+ if ( ! utils . isUndefined ( payload ) && ! utils . isUndefined ( payload . a11y_core_config ) && payload . a11y_core_config . domForge === true ) {
39+ launchOptions . args . push ( "--auto-open-devtools-for-tabs" ) ;
40+ launchOptions . preferences . default [ "devtools" ] = launchOptions . preferences . default [ "devtools" ] || { } ;
41+ launchOptions . preferences . default [ "devtools" ] [ "preferences" ] = launchOptions . preferences . default [ "devtools" ] [ "preferences" ] || { } ;
42+ launchOptions . preferences . default [ "devtools" ] [ "preferences" ] [
43+ "currentDockState"
44+ ] = '"undocked"' ;
45+ }
46+ } catch ( error ) {
47+ console . log ( "Error:" , error . message ) ;
48+ }
3449 return launchOptions
3550 }
3651 }
Original file line number Diff line number Diff line change @@ -1775,3 +1775,25 @@ exports.getMajorVersion = (version) => {
17751775 return null ;
17761776 }
17771777}
1778+
1779+ const base64UrlDecode = ( str ) => {
1780+ const base64 = str . replace ( / - / g, '+' ) . replace ( / _ / g, '/' ) ;
1781+ const buffer = Buffer . from ( base64 , 'base64' ) ;
1782+ return buffer . toString ( 'utf-8' ) ;
1783+ } ;
1784+
1785+
1786+ exports . decodeJWTToken = ( token ) => {
1787+ try {
1788+ const parts = token . split ( '.' ) ;
1789+ if ( parts . length < 2 ) {
1790+ throw new Error ( 'Invalid JWT token' ) ;
1791+ }
1792+ const header = JSON . parse ( base64UrlDecode ( parts [ 0 ] ) ) ;
1793+ const payload = JSON . parse ( base64UrlDecode ( parts [ 1 ] ) ) ;
1794+ return { header, payload } ;
1795+ } catch ( error ) {
1796+ logger . err ( error . message ) ;
1797+ return { undefined, undefined} ;
1798+ }
1799+ }
You can’t perform that action at this time.
0 commit comments