File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
accessibility-automation/plugin Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1
1
const path = require ( "node:path" ) ;
2
+ const { decodeJWTToken } = require ( "../../helpers/utils" ) ;
3
+ const utils = require ( '../../helpers/utils' ) ;
2
4
3
5
const browserstackAccessibility = ( on , config ) => {
4
6
let browser_validation = true ;
@@ -30,7 +32,16 @@ const browserstackAccessibility = (on, config) => {
30
32
}
31
33
if ( browser_validation ) {
32
34
const ally_path = path . dirname ( process . env . ACCESSIBILITY_EXTENSION_PATH )
35
+ const { _, payload} = decodeJWTToken ( process . env . ACCESSIBILITY_AUTH ) ;
33
36
launchOptions . extensions . push ( ally_path ) ;
37
+ if ( ! utils . isUndefined ( payload ) && ! utils . isUndefined ( payload . a11y_core_config ) && payload . a11y_core_config . domForge === true ) {
38
+ launchOptions . args . push ( "--auto-open-devtools-for-tabs" ) ;
39
+ launchOptions . preferences . default [ "devtools" ] = launchOptions . preferences . default [ "devtools" ] || { } ;
40
+ launchOptions . preferences . default [ "devtools" ] [ "preferences" ] = launchOptions . preferences . default [ "devtools" ] [ "preferences" ] || { } ;
41
+ launchOptions . preferences . default [ "devtools" ] [ "preferences" ] [
42
+ "currentDockState"
43
+ ] = '"undocked"' ;
44
+ }
34
45
return launchOptions
35
46
}
36
47
}
Original file line number Diff line number Diff line change @@ -1775,3 +1775,24 @@ exports.getMajorVersion = (version) => {
1775
1775
return null ;
1776
1776
}
1777
1777
}
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
+ exports . decodeJWTToken = ( token ) => {
1786
+ try {
1787
+ const parts = token . split ( '.' ) ;
1788
+ if ( parts . length < 2 ) {
1789
+ throw new Error ( 'Invalid JWT token' ) ;
1790
+ }
1791
+ const header = JSON . parse ( base64UrlDecode ( parts [ 0 ] ) ) ;
1792
+ const payload = JSON . parse ( base64UrlDecode ( parts [ 1 ] ) ) ;
1793
+ return { header, payload } ;
1794
+ } catch ( error ) {
1795
+ logger . err ( error . message ) ;
1796
+ return { undefined, undefined} ;
1797
+ }
1798
+ }
You can’t perform that action at this time.
0 commit comments