Skip to content

Commit

Permalink
added a secret hash for security
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsRaghavGupta committed Apr 18, 2024
1 parent b49ad73 commit 3f2e3d0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
18 changes: 16 additions & 2 deletions clevertap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clevertap.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clevertap.min.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/modules/visualBuilder/pageBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let lastRange = null
const winRef = window.opener
let doc = document
let curURL = window.location.href
const secretKey = 'PointAndClick'

function rgbToHex (r, g, b) {
// Ensure values are within valid range (0-255)
Expand Down Expand Up @@ -452,11 +453,20 @@ function createAndAddFormTextV2 () {
}

function saveRes () {
// const winRef = window.opener
winRef.postMessage(ctSelector, '*')
const jsonData = JSON.stringify(ctSelector)
const concatenatedString = jsonData + secretKey
const hash = createHash(concatenatedString)
winRef.postMessage({ details: jsonData, hash }, '*')
window.close()
}

function createHash (str) {
const crypto = require('crypto')
const hash = crypto.createHash('sha256')
hash.update(str)
return hash.digest('hex')
}

function createEl (type, id, token, _type) {
const _el = document.createElement(type)
_el.setAttribute('id', id)
Expand Down

0 comments on commit 3f2e3d0

Please sign in to comment.