Skip to content

🔥 The free & Open Source DocuSign alternative

#204 - Fix issue due to Signature URL validation

Rishab87c65e4beab9
diff --git a/microfrontends/SignDocuments/package-lock.json b/microfrontends/SignDocuments/package-lock.json
index 30f707e44..d087684f9 100644
--- a/microfrontends/SignDocuments/package-lock.json
+++ b/microfrontends/SignDocuments/package-lock.json
@@ -36,6 +36,7 @@
"react-scrollbars-custom": "^4.1.1",
"react-signature-canvas": "^1.0.6",
"reactour": "^1.19.1",
+ "validator": "^13.11.0",
"web-vitals": "^2.1.4"
}
},
@@ -20502,6 +20503,14 @@
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A=="
},
+ "node_modules/validator": {
+ "version": "13.11.0",
+ "resolved": "https://registry.npmjs.org/validator/-/validator-13.11.0.tgz",
+ "integrity": "sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
diff --git a/microfrontends/SignDocuments/package.json b/microfrontends/SignDocuments/package.json
index 97970e988..8389bf007 100644
--- a/microfrontends/SignDocuments/package.json
+++ b/microfrontends/SignDocuments/package.json
@@ -32,6 +32,7 @@
"react-scrollbars-custom": "^4.1.1",
"react-signature-canvas": "^1.0.6",
"reactour": "^1.19.1",
+ "validator": "^13.11.0",
"web-vitals": "^2.1.4"
},
"scripts": {
diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
index bfcfd7cb3..214999207 100644
--- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
+++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
@@ -14,7 +14,8 @@ import RenderAllPdfPage from "./component/renderAllPdfPage";
import {
contractDocument,
getBase64FromIMG,
- getBase64FromUrl
+ getBase64FromUrl,
+ urlValidator
} from "../utils/Utils";
import Loader from "./component/loader";
import HandleError from "./component/HandleError";
@@ -346,7 +347,7 @@ function PdfRequestFiles() {
imgUrlList.map(async (data) => {
//cheking signUrl is defau;t signature url of custom url
let ImgUrl = data.SignUrl;
- const checkUrl = ImgUrl.includes("https:");
+ const checkUrl = urlValidator(ImgUrl);
//if default signature url then convert it in base 64
if (checkUrl) {
@@ -434,7 +435,7 @@ function PdfRequestFiles() {
imgUrlList.map(async (url) => {
let signUrl = url.SignUrl;
- const checkUrl = url.SignUrl.includes("https:");
+ const checkUrl = urlValidator(signUrl);
if (checkUrl) {
signUrl = signUrl + "?get";
}
diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
index 2b5eebdc8..9044b38d9 100644
--- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
+++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
@@ -24,7 +24,7 @@ import HandleError from "./component/HandleError";
import Nodata from "./component/Nodata";
import Header from "./component/header";
import RenderPdf from "./component/renderPdf";
-import { contractUsers, contactBook } from "../utils/Utils";
+import { contractUsers, contactBook, urlValidator } from "../utils/Utils";
//For signYourself inProgress section signer can add sign and complete doc sign.
function SignYourSelf() {
const [pdfDetails, setPdfDetails] = useState([]);
@@ -444,7 +444,7 @@ function SignYourSelf() {
imgUrlList.map(async (data) => {
let ImgUrl = data.SignUrl;
//cheking signUrl is defau;t signature url of custom url
- const checkUrl = ImgUrl.includes("https:");
+ const checkUrl = urlValidator(ImgUrl);
//if default signature url then convert it in base 64
if (checkUrl) {
@@ -524,7 +524,7 @@ function SignYourSelf() {
imgUrlList.map(async (url) => {
let signUrl = url.SignUrl;
- const checkUrl = url.SignUrl.includes("https:");
+ const checkUrl = urlValidator(signUrl);
if (checkUrl) {
signUrl = signUrl + "?get";
}
diff --git a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
index 0b9a106c9..840db9409 100644
--- a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
+++ b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
@@ -16,7 +16,8 @@ import {
getBase64FromIMG,
contractUsers,
contactBook,
- contractDocument
+ contractDocument,
+ urlValidator
} from "../utils/Utils";
import Tour from "reactour";
import Signedby from "./component/signedby";
@@ -445,7 +446,7 @@ function EmbedPdfImage() {
imgUrlList.map(async (data) => {
//cheking signUrl is defau;t signature url of custom url
let ImgUrl = data.SignUrl;
- const checkUrl = ImgUrl.includes("https:");
+ const checkUrl = urlValidator(ImgUrl);
//if default signature url then convert it in base 64
if (checkUrl) {
@@ -523,7 +524,7 @@ function EmbedPdfImage() {
const images = await Promise.all(
imgUrlList.map(async (url) => {
let signUrl = url.SignUrl;
- const checkUrl = url.SignUrl.includes("https:");
+ const checkUrl = urlValidator(signUrl);
if (checkUrl) {
signUrl = signUrl + "?get";
}
diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js
index ecf6d0359..0413c7d87 100644
--- a/microfrontends/SignDocuments/src/utils/Utils.js
+++ b/microfrontends/SignDocuments/src/utils/Utils.js
@@ -1,4 +1,5 @@
import axios from "axios";
+import validator from 'validator';
export async function getBase64FromUrl(url) {
const data = await fetch(url);
@@ -299,3 +300,8 @@ export const contactBook = async (objectId) => {
});
return result;
};
+
+// function for validating URLs
+export function urlValidator(url) {
+ return validator.isURL(url);
+};
\ No newline at end of file