Here is one way which can help you @stevemc,
From frontend
Let’s say this is a input field
<fw-input
label="Freshdesk API Key"
icon-right="magic-wand"
placeholder="Freshdesk Portal > Profile > Copy API Key"
required="true"
minlength="5"
size="30"
class="secure-field"
></fw-input>
let apiKey = document.querySelector('.secure-field');
function postConfigs() {
return {
__meta: {
secure: ['apiKey']
},
api_key: apiKey.value,
};
}
async function validate() {
var URL = `https://${domain.value}/api/v2/tickets`;
var base64Encoded = btoa(apiKey.value);
var options = {
headers: {
Authorization: `Basic ${base64Encoded}`,
'Content-Type': 'application/json'
}
};
try {
let { status } = await client.request.get(URL, options);
if (status == 200) return true;
} catch (error) {
console.error(error);
return false;
}
}
In backend, as in server.js
You can use a npm package, for example this one - safe-buffer - npm
And try to use Buffer.from(..)
by listing the npm package in the manifest.
Native Node packages are blocked because of the security concerns of the platform. Hope those help.