Skip to content

Commit

Permalink
SDK-1907: added launchOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
osho-20 committed Dec 4, 2024
1 parent da5fc16 commit 48c4784
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/accessibility-automation/plugin/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require("node:path");
const { decodeJWTToken } = require("../../helpers/utils");
const utils = require('../../helpers/utils');

const browserstackAccessibility = (on, config) => {
let browser_validation = true;
Expand Down Expand Up @@ -30,7 +32,16 @@ const browserstackAccessibility = (on, config) => {
}
if (browser_validation) {
const ally_path = path.dirname(process.env.ACCESSIBILITY_EXTENSION_PATH)
const {_, payload} = decodeJWTToken(process.env.ACCESSIBILITY_AUTH);
launchOptions.extensions.push(ally_path);
if(!utils.isUndefined(payload) && !utils.isUndefined(payload.a11y_core_config) && payload.a11y_core_config.domForge === true) {
launchOptions.args.push("--auto-open-devtools-for-tabs");
launchOptions.preferences.default["devtools"] = launchOptions.preferences.default["devtools"] || {};
launchOptions.preferences.default["devtools"]["preferences"] = launchOptions.preferences.default["devtools"]["preferences"] || {};
launchOptions.preferences.default["devtools"]["preferences"][
"currentDockState"
] = '"undocked"';
}
return launchOptions
}
}
Expand Down
22 changes: 22 additions & 0 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1775,3 +1775,25 @@ exports.getMajorVersion = (version) => {
return null;
}
}

const base64UrlDecode = (str) => {
const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
const buffer = Buffer.from(base64, 'base64');
return buffer.toString('utf-8');
};


exports.decodeJWTToken = (token) => {
try{
const parts = token.split('.');
if (parts.length < 2) {
throw new Error('Invalid JWT token');
}
const header = JSON.parse(base64UrlDecode(parts[0]));
const payload = JSON.parse(base64UrlDecode(parts[1]));
return { header, payload };
} catch (error) {
logger.err(error.message);
return {undefined, undefined};
}
}

0 comments on commit 48c4784

Please sign in to comment.