Category: javascript
Category Added in a WPeMatico Campaign
Error of gateway urls while uploading encrypted secrets to DON – Chainlink Functions
Body
I’m trying to upload encrypted secrets to Chainlink Decentralized Oracle Network (DON) gateways using the @chainlink/functions-toolkit in my RWA project. However, I’m encountering an error when sending the request to the gateways.
Error I am getting in terminal
Error encountered when attempting to send request to DON gateway URL #1 of 2
https://01.functions-gateway.testnet.chain.link/: AggregateError
Error encountered when attempting to send request to DON gateway URL #2 of 2
https://02.functions-gateway.testnet.chain.link/: AggregateError
Error: Failed to send request to any of the DON gateway URLs:
["https://01.functions-gateway.testnet.chain.link/","https://02.functions-gateway.testnet.chain.link/"]
Script to upload secrets – uploadSecrets.js
const {
SecretsManager,
} = require("@chainlink/functions-toolkit")
const {ethers} = require('ethers');
const uploadSecrets = async () => {
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0" //sepolia
const donId = "fun-ethereum-sepolia-1"
const gatewayUrls = [
"https://01.functions-gateway.testnet.chain.link/",
"https://02.functions-gateway.testnet.chain.link/",
]
const privateKey = process.env.PRIVATE_KEY.replace(/r/g, "").trim();
if (!privateKey)
throw new Error(
"private key not provided - check your environment variables"
)
const rpcUrl = process.env.SEPOLIA_RPC_URL
if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`)
const secrets = { alpacaKey: process.env.ALPACA_KEY ?? "", alpacaSecret: process.env.ALPACA_SECRET ?? "" }
const provider = new ethers.providers.JsonRpcProvider(rpcUrl)
const wallet = new ethers.Wallet(privateKey)
const signer = wallet.connect(provider)
const secretsManager = new SecretsManager({
signer: signer,
functionsRouterAddress: routerAddress,
donId: donId,
})
await secretsManager.initialize()
const encryptedSecretsObj = await secretsManager.encryptSecrets(secrets)
const slotIdNumber = 0
const expirationTimeMinutes = 1440
console.log(
`Upload encrypted secret to gateways ${gatewayUrls}. slotId ${slotIdNumber}. Expiration in minutes: ${expirationTimeMinutes}`
)
// Upload secrets
const uploadResult = await secretsManager.uploadEncryptedSecretsToDON({
encryptedSecretsHexstring: encryptedSecretsObj.encryptedSecrets,
gatewayUrls: gatewayUrls,
slotId: slotIdNumber,
minutesUntilExpiration: expirationTimeMinutes,
})
if (!uploadResult.success)
throw new Error(`Encrypted secrets not uploaded to ${gatewayUrls}`)
console.log(
`n Secrets uploaded properly to gateways ${gatewayUrls}! Gateways response: `,
uploadResult
)
const donHostedSecretsVersion = parseInt(uploadResult.version)
console.log(`n Secrets version: ${donHostedSecretsVersion}`)
}
uploadSecrets().catch((e) => {
console.error(e)
process.exit(1)
})
Expected Result in console
Secrets uploaded properly to gateways https://01.functions-gateway.testnet.chain.link/! Gateways response
Firebase functions not building correctly
I am simply trying to build a firebase function using typescript. Right now my file is as follows:
import { onRequest } from "firebase-functions/v2/https";
import * as logger from "firebase-functions/logger";
import * as admin from "firebase-admin";
admin.initializeApp();
// Start writing functions
// https://firebase.google.com/docs/functions/typescript
export const helloWorld = onRequest((request, response) => {
logger.info("Hello logs!", { structuredData: true });
response.send("Hello from Firebase!");
});
And here is my tsconfig:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
}
and for added measure, package.json
{
"name": "functions",
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^12.1.0",
"firebase-functions": "^5.0.0"
},
"devDependencies": {
"typescript": "^4.9.0",
"firebase-functions-test": "^3.1.0"
},
"private": true
}
Now, the fun part. When i run
tsc index.ts
I get the following error message
../node_modules/gaxios/build/src/gaxios.d.ts:6:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
6 #private;
~~~~~~~~
../node_modules/google-auth-library/build/src/auth/awsclient.d.ts:84:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
84 #private;
~~~~~~~~
../node_modules/google-auth-library/build/src/util.d.ts:134:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
134 #private;
~~~~~~~~
../node_modules/gtoken/build/src/index.d.ts:38:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
38 #private;
~~~~~~~~
Found 4 errors in 4 files.
Errors Files
1 ../node_modules/gaxios/build/src/gaxios.d.ts:6
1 ../node_modules/google-auth-library/build/src/auth/awsclient.d.ts:84
1 ../node_modules/google-auth-library/build/src/util.d.ts:134
1 ../node_modules/gtoken/build/src/index.d.ts:38
I have NO idea what I am doing wrong. This has never been an issue before. This code is being run in an isolated folder, so there are no other dependencies it could be interfering with. Please, someone help.
jQuery MagicToolBox 360 plugin free alternative?
After Electron package .env file variable are not setting up
In my Electron Project I have my env files like this
and I have my package.json file like this
Issue is in the development when i use npm start .env variable setting up , but when I use npm package:win to package the project the .env variable are not setting up , How to fix this ?
After Package these are not setting up ,
Highcharts heatmap is smushing the data and overlapping
I am trying to create a heatmap but the data is getting all smushed and overlapping. Not use what is wrong with my code.
// Substring template helper for the responsive labels
Highcharts.Templating.helpers.substr = (s, from, length) =>
s.substr(from, length);
// Create the chart
Highcharts.chart('container', {
chart: {
backgroundColor: "#fbfcf8",
type: "heatmap",
plotBorderWidth: 1,
},
title: {
text: "Views",
align: "center",
},
exporting: {
enabled: true,
buttons: {
contextButton: {
menuItems: [
"viewFullscreen",
"printChart",
"separator",
"downloadPNG",
"downloadJPEG",
"separator",
"downloadPDF",
"downloadCSV",
],
},
},
},
credits: {
enabled: false,
},
legend: {
enabled: true,
itemStyle: {
color: "#000",
},
},
rangeSelector: {
enabled: false,
},
navigator: {
enabled: false,
},
scrollbar: {
enabled: false,
},
xAxis: {
categories: [
"Africa",
"North America",
"South America",
"Eurasia",
"Pacifica",
"South & Central Asia",
"News Network"
]
},
yAxis: {
categories: [
"Jun 16, 2024",
"Jun 23, 2024",
"Jun 30, 2024",
"Jul 7, 2024",
"Jul 14, 2024"
],
title: null,
reversed: true
},
accessibility: {
point: {
descriptionFormat: '{(add index 1)}. ' +
'{series.xAxis.categories.(x)} sales ' +
'{series.yAxis.categories.(y)}, {value}.'
}
},
colorAxis: {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 280
},
tooltip: {
format: '<b>{series.xAxis.categories.(point.x)}</b> sold<br>' +
'<b>{point.value}</b> items on <br>' +
'<b>{series.yAxis.categories.(point.y)}</b>'
},
series: [{
name: 'Sales per employee',
borderWidth: 1,
data: [
[0, 0, 1232832],
[0, 1, 1187983],
[0, 2, 1318736],
[0, 3, 3384636],
[0, 4, 594455],
[1, 5, 4001117],
[1, 6, 5292507],
[1, 7, 6121291],
[1, 8, 5814796],
[1, 9, 1611414],
[2, 10, 208481],
[2, 11, 218970],
[2, 12, 225507],
[2, 13, 600113],
[2, 14, 191908],
[3, 15, 2293868],
[3, 16, 1630162],
[3, 17, 2099544],
[3, 18, 1863363],
[3, 19, 590216],
[4, 20, 643923],
[4, 21, 795437],
[4, 22, 904703],
[4, 23, 467513],
[4, 24, 546069],
[5, 25, 10916105],
[5, 26, 14178090],
[5, 27, 12766301],
[5, 28, 21131347],
[5, 29, 5413607],
[6, 30, 206725],
[6, 31, 231642],
[6, 32, 238180],
[6, 33, 319477],
[6, 34, 133786]
],
dataLabels: {
enabled: true,
color: '#000000'
}
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
yAxis: {
labels: {
format: '{substr value 0 1}'
}
}
}
}]
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
I have also attached a fiddle. Please let me know how to fix this.
convert html content to save as docx document
I want to upload docx file and do some modification to remove special chracters, adjust style, and then save back as docx document.
Read file: Currently i am using docx-preview library to read the file and convert to html content to get all the font, style, and special characters.
Save file: After research, i found out that html-to-docx library might be useful, but i have encountered the following error:
test.html:77 Uncaught (in promise)
ReferenceError: HTMLtoDOCX is not defined
at test.html:77:32
at HTMLButtonElement.<anonymous> (test.html:90:15)
(anonymous) @ test.html:77
(anonymous) @ test.html:90
and have tried a while already still cannot successfully get this library used in my script.
Therefore I want to ask for help about this part. Does anyone have the experience to save html content as docx document? not neccessarily need to use the html-to-docx library.
my whole code is as following, it can be directly saved to test.html and browse in broswer:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Word Document Reader</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
#container {
margin-top: 20px;
font-size: 16px;
color: #333;
}
#downloadButton {
display: none;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Word Document Reader</h1>
<input type="file" id="fileInput" accept=".docx">
<button id="downloadButton">Download Document</button>
<div id="container"></div>
<!-- Optional polyfill for promise -->
<script src="https://unpkg.com/promise-polyfill/dist/polyfill.min.js"></script>
<!-- lib uses jszip -->
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<script src="https://unpkg.com/docx-preview/dist/docx-preview.min.js"></script>
<script src="https://unpkg.com/docx/build/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html-to-docx.umd.js"></script>
<script>
let currentBlob = null;
let modifiedContent = '';
document.getElementById('fileInput').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file && file.name.endsWith('.docx')) {
const reader = new FileReader();
reader.onload = function(event) {
const arrayBuffer = event.target.result;
currentBlob = new Blob([arrayBuffer], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
docx.renderAsync(currentBlob, document.getElementById("container"))
.then(() => {
console.log("docx: finished");
let renderedContent = document.getElementById("container").innerHTML;
console.log("Original Rendered Content:", renderedContent);
// Replace the specific span pattern with -->
const pattern = /</span><span><span style="font-family: Wingdings;"></span></span><span>/g;
modifiedContent = renderedContent.replace(pattern, '-->');
// Update the container with the modified content
document.getElementById("container").innerHTML = modifiedContent;
console.log("Modified Rendered Content:", modifiedContent);
document.getElementById('downloadButton').style.display = 'block';
})
.catch(err => console.error("docx: error", err));
};
reader.readAsArrayBuffer(file);
} else {
alert('Please upload a valid .docx file.');
}
});
document.getElementById('downloadButton').addEventListener('click', function() {
(async () => {
const fileBuffer = await HTMLtoDOCX(htmlString, null, {
table: { row: { cantSplit: true } },
footer: true,
pageNumber: true,
});
fs.writeFile(filePath, fileBuffer, (error) => {
if (error) {
console.log('Docx file creation failed');
return;
}
console.log('Docx file created successfully');
});
})();
});
</script>
</body>
</html>
Tried: use html-to-docx library to convert html content to docx docuemnt but fail.
Expect: the conversion from htmo content to docx file can be successfully excuted.
Performance issue of ECharts
When drawing random nosise data, ECharts seems quite slow.
See demo
Even for 3000 points, the axisPointer tooltip response time is not acceptable.
Is this normal or should I turn off some settings?
“Advice for Becoming a React Developer After Manual Test”
I have been doing manual testing for 2 years. Before this, I had a software development career. Now, I am curious about the JavaScript library and React. Can you tell me what I need to do to become a React developer and which websites I should use to learn?
I have been studying JavaScript basics and have completed some online tutorials. I have also read some documentation about React. I was expecting to find a clear path or a set of recommended resources to guide my learning process. However, I am still unsure about the best practices and the most effective resources to use.
Iframe Form/Label element error how to fix?
I keep getting this label error while using a google map on an html website and need it to go away. error details in picture. I have tried making new maps but it still does show this error. I also cant tell if its my code or something in the google map linked into the html
This is the picture of the error I have right now:Picture of error
This is the code that I have:
//div class=”gmap”
iframe id=”Google Map” title=”Google Map” src=”https://www.google.com/maps/d/embed?mid=11-FpnGO0gGMRNXwO24bMDQfy_rwsRLw&ehbc=2E312F&noprof=1″></iframe
/div//
Trying to truncate text on smaller screens, but the common solutions don’t work
This code works fine, only when the_title() text is longer and the window is small, the text wraps to the next line:
<div class="metabox metabox--position-up metabox--with-home-link">
<p>
<span class="metabox__main"><?php esc_html(the_title()); ?></span>
</p>
</div>
.metabox {
background-color: #FAF0CA;
border-radius: 3px;
padding: 10px 15px;
display: inline-block;
margin-bottom: 20px;
margin-top: 6px;
box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.07);
}
.metabox--position-up {
position: absolute;
top: 0;
transform: translateY(-50%);
}
.metabox--with-home-link {
padding: 0;
}
.metabox__main {
padding: 10px 15px 10px 11px;
}
.metabox p {
margin: 0;
font-size: 0.9rem;
color: #a79038;
}
@media (min-width: 425px) and (max-width: 765px){
.metabox__main {
padding: 2px 4px 2px 2px;
}
}
If I change the media query to the following common solution, all the text just drops down a line instead of wrapping:
@media (min-width: 425px) and (max-width: 765px){
.metabox__main {
padding: 2px 4px 2px 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
I’ve tried quite a few solutions and nothings working, most solutions break it worse.
Would appreciate any help with this.
Can’t I make a 3d model copy the movements through the webcam?
I write JavaScript.
I want to use the webcam of my laptop to estimate the pose and download the 3D model of Mixamo to move this model.
But it’s not moving. I need help. How can I control my movement?
Right now, I
three.js, tensorflow.js, mediapipe/holistic, mediapipe/camera, mediapipe/drawing, fflate, FBXLoader.js
It is being used as a CDN.
If you have any other tips or techniques to add, please let me know
Google Apps Script dayjs Plugin Import
I am trying to use the dayjs library in my Google apps script and some of its plugins.
I first added the library to my project by searching for the following script ID:
1ShsRhHc8tgPy5wGOzUvgEhOedJUQD53m-gd8lG2MOgs-dXC_aCZn9lFB
Then I used it in my function like so:
const { dayjs } = Daygs;
function myFunction() {
Logger.log(dayjs());
}
This works perfectly fine but I want to use a plugin library, like IsSameOrBefore, but I’m not sure how exactly I’m supposed to import and use it.
Any idea how to import this plugin and get this to work? Also open to suggestions on better date libraries to use.
I’ve tried all the following and nothing works:
const { dayjs } = Daygs;
// const { isSameOrBefore } = Daygs.plugin.isSameOrBefore;
// const { isSameOrBefore } = 'dayjs/plugin/isSameOrBefore';
// const isSameOrBefore = require("dayjs/plugin/isSameOrBefore");
// const isSameOrBefore = Daygs.plugin.isSameOrBefore;
// const isSameOrBefore = dayjs.plugin.isSameOrBefore;
// const { isSameOrBefore } = dayjs.plugin.isSameOrBefore;
// import { isSameOrBefore } from "dayjs/plugin/isSameOrBefore";
function myFunction() {
dayjs.extend(isSameOrBefore);
Logger.log(dayjs());
}
Posting a JSON array to Sequelize Update query results in a stalled request
I’m using node and a Sequelize (6.37.1) update query and it is stalling continuously. This is the only query with issues. This is a CRUD app where inputs are contextual so I’m using Ajax to post a JSON object and I can confirm the query is executing; terminal shows the following:
Executing (default): UPDATE [entities] SET [fname1]=@0,[lname1]=@1...
Here is the post script…
const rowObject = JSON.parse(JSON.stringify(entity))
$.ajax({
type: "POST",
url: '/api/entities/update',
data: rowObject,
dataType: 'application/json',
})
console.log ('Updating Single Entity:'+ document.getElementById("entityID").value + JSON.stringify(rowObject))
It appears to be performing as it should be – I can see the JSON object in the console and it executes but I get the following result:

I simplified the model query to the bare minimum – shown as follows:
exports.update = (req, res) => {
try {
console.log("Sending Single through the server = " + req.body.chkSec)
Entities.update({
fname1: req.body.fname1,
lname1: req.body.lname1,
//Other key:value - not all shown
},
{where:{entityID:JSON.parse(req.body.entityID)}}
).then((result)=>{return result})
}catch(error){
console.log (error)
}
}
This is my first real attempt at building an app like this so I may be missing something simple. I don’t understand why it is stalling.
Is .value Cross-Site Scripting (XSS) safe?
I am writing a static page for a tool: User pastes in base64 and it gets converted into plaintext. Not like it matters, but because the context is cryptographic, I want to prevent XSS.
I noticed document.getElementById("myTextarea").value allows you to change/set the content of a textarea without it appearing in the HTML code (even as an attribute), and unlike .innerHTML or attributes I couldn’t do anything with .value.
So is .value actually safe? And is there a “simpler” HTML element that has similar behavior?
Maybe I am bad at Googling or just lazy, but I couldn’t find anything on it (XSS does work in textarea innerHTML as asked and answered on other StackOverflow posts). (“How do I google this?”)
I know about validation and encoding, but then I can’t feed the output straight into a reverse converter to get the initial base64.
Questions:
- Is
.valueXSS safe? - Is there a “simpler” HTML element that has similar behavior?




