From 481c0143fc482f46178408ee6d12eed04d0e2992 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Mon, 2 Jun 2025 10:40:14 +0000 Subject: [PATCH] fix: avoid generating repetitive widgets Id --- apps/OpenSign/src/constant/Utils.jsx | 14 +++++++++----- apps/OpenSign/src/pages/Form.jsx | 4 ++-- apps/OpenSignServer/Dockerhubfile | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/OpenSign/src/constant/Utils.jsx b/apps/OpenSign/src/constant/Utils.jsx index 83659de4f..4facb5860 100644 --- a/apps/OpenSign/src/constant/Utils.jsx +++ b/apps/OpenSign/src/constant/Utils.jsx @@ -683,10 +683,14 @@ export const signPdfFun = async ( }; export const randomId = () => { - const randomBytes = crypto.getRandomValues(new Uint16Array(1)); - const randomValue = randomBytes[0]; - const randomDigit = 1000 + (randomValue % 9000); - return randomDigit; + // 1. Grab a cryptographically-secure 32-bit random value + const randomBytes = crypto.getRandomValues(new Uint32Array(1)); + const raw = randomBytes[0]; // 0 … 4 294 967 295 + + // 2. Collapse into a 90 000 000-wide band (0…89 999 999), then shift to 10 000 000…99 999 999 + const eightDigit = 10_000_000 + (raw % 90_000_000); + + return eightDigit; }; export const createDocument = async ( @@ -1552,7 +1556,7 @@ export const multiSignEmbed = async ( let hasError = false; for (let item of widgets) { //pdfOriginalWH contained all pdf's pages width and height - //'getSize' is used to get particular pdf's page width and height + //'getSize' is used to get particular pdf's page width and height const getSize = pdfOriginalWH.find( (page) => page?.pageNumber === item?.pageNumber ); diff --git a/apps/OpenSign/src/pages/Form.jsx b/apps/OpenSign/src/pages/Form.jsx index 324a57380..fd22ca954 100644 --- a/apps/OpenSign/src/pages/Form.jsx +++ b/apps/OpenSign/src/pages/Form.jsx @@ -455,7 +455,7 @@ const Forms = (props) => { setBcc([]); setFolder({ ObjectId: "", Name: "" }); const notifySign = - extUserData?.NotifyOnSignatures + extUserData?.NotifyOnSignatures !== undefined ? extUserData?.NotifyOnSignatures : true; setFormData({ @@ -534,7 +534,7 @@ const Forms = (props) => { setBcc([]); setFolder({ ObjectId: "", Name: "" }); const notifySign = - extUserData?.NotifyOnSignatures + extUserData?.NotifyOnSignatures !== undefined ? extUserData?.NotifyOnSignatures : true; let obj = { diff --git a/apps/OpenSignServer/Dockerhubfile b/apps/OpenSignServer/Dockerhubfile index 45a2aea7a..5f62e4d64 100644 --- a/apps/OpenSignServer/Dockerhubfile +++ b/apps/OpenSignServer/Dockerhubfile @@ -1,6 +1,8 @@ # Use an official Node runtime as the base image FROM node:22.14.0 +RUN wget https://download.oracle.com/java/23/archive/jdk-23_linux-x64_bin.deb \ + && dpkg -i jdk-23_linux-x64_bin.deb # Set the working directory inside the container WORKDIR /usr/src/app