@medicus.ai/medicus-report-pdf-generator 1.0.216 → 1.0.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,7 @@ body {
73
73
  }
74
74
 
75
75
  .first-page .logo {
76
- width: 25%
76
+ width: 21.5%
77
77
  }
78
78
 
79
79
  .first-page .company-logo {
@@ -107,7 +107,7 @@ body {
107
107
  }
108
108
 
109
109
  .report-title {
110
- font-size: 300%;
110
+ font-size: 387%;
111
111
  font-weight: 700;
112
112
  float: right;
113
113
  width: 75%;
@@ -227,11 +227,11 @@ td.bar-title span {
227
227
  text-align: right;
228
228
  direction: ltr;
229
229
  }
230
- /*
230
+
231
231
  .participant-analytics-section .container .side-chart-container:nth-child(odd) .bar-title span {
232
232
  text-align: left;
233
233
  }
234
- */
234
+
235
235
  .side-chart.side-chart-with-border table tr.empty-tr {
236
236
  height: 52px;
237
237
  }
@@ -264,22 +264,22 @@ td {
264
264
  min-width: 60px;
265
265
  }
266
266
 
267
- .participant-analytics-section .container .side-chart-container table {
267
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table {
268
268
  direction: rtl;
269
269
  }
270
270
 
271
- .participant-analytics-section .container .side-chart-container {
271
+ .participant-analytics-section .container .side-chart-container:nth-child(even) {
272
272
  float: right;
273
273
  }
274
274
 
275
- .participant-analytics-section .container .side-chart-container table td.bar-title {
275
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table td.bar-title {
276
276
  border-right: 1px solid;
277
277
  border-left: 0;
278
278
  padding-right: 13px;
279
279
  padding-left: 0;
280
280
  }
281
281
 
282
- .participant-analytics-section .container .side-chart-container table .bar-chart {
282
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table .bar-chart {
283
283
  float: left;
284
284
  border-radius: 0 20px 20px 0;
285
285
  }
@@ -40,6 +40,9 @@ td.bar-title span {
40
40
  .participant-analytics-section.single-section.page {
41
41
  margin-top: 0px;
42
42
  }
43
+ .participant-analytics-section .container .side-chart-container:nth-child(odd) .bar-title span {
44
+ text-align: right;
45
+ }
43
46
 
44
47
  .container {
45
48
  padding-right: 0px;
@@ -54,18 +57,22 @@ td.bar-title span {
54
57
  border-bottom-left-radius: 0;
55
58
  }
56
59
 
57
- .participant-analytics-section .container .side-chart-container table {
60
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table {
58
61
  direction: ltr;
59
62
  }
60
63
 
61
- .participant-analytics-section .container .side-chart-container table td.bar-title {
64
+ .participant-analytics-section .container .side-chart-container:nth-child(even) {
65
+ float: left;
66
+ }
67
+
68
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table td.bar-title {
62
69
  border-left: 1px solid;
63
70
  border-right: 0;
64
71
  padding-left: 13px;
65
72
  padding-right: 0;
66
73
  }
67
74
 
68
- .participant-analytics-section .container .side-chart-container table .bar-chart {
75
+ .participant-analytics-section .container .side-chart-container:nth-child(even) table .bar-chart {
69
76
  float: right;
70
77
  border-radius: 20px 0 0 20px;
71
78
  }
package/index.js CHANGED
@@ -5,6 +5,8 @@ const {fork} = require('child_process');
5
5
  const {join} = require('path');
6
6
  const {sendNascoEmail, sendEmailNotification} = require('./lib/sendEmail')
7
7
  const {generatePDFCorporateReport, generateHTMLCorporateReport} = require('./lib/corporate_report_generator')
8
+ const encryptDecrypt = require('./lib/encrypt_decrypt');
9
+
8
10
  module.exports = {
9
11
  generateHTMLStaging,
10
12
  generateMedicusPDF: async (base64Object, isDebugging, isDownloadable, onlyHTML) => {
@@ -87,8 +89,13 @@ module.exports = {
87
89
 
88
90
  },
89
91
  generateNascoPDF: async (data, isDebugging, isDownloadable, shouldSendEmail) => {
92
+
90
93
  let reportData = JSON.parse(data)
91
- let base64Object = reportData.data
94
+ let encryptionKey=reportData.encryptionKey
95
+ let sentData=reportData.data
96
+ let ecbDecrypted = encryptDecrypt.ecbDecrypt(sentData, encryptionKey)
97
+ let xorDecrypted = encryptDecrypt.XORDecrypt(ecbDecrypted, encryptionKey)
98
+ let base64Object = Buffer.from(xorDecrypted, 'utf8').toString('base64');
92
99
  let LOGS = '';
93
100
  let LOGS_FILE_PATH = __dirname + '/output/LOGS.txt';
94
101
  let PDF_FILE_PATH = __dirname + '/output/nasco-sample.pdf';
@@ -166,8 +173,12 @@ module.exports = {
166
173
  } else {
167
174
  if (shouldSendEmail)
168
175
  return await sendNascoEmail(decodedJSON, PDF_FILE_PATH, mailConfig,reportData.client)
169
- else
170
- return base64data;
176
+ else{
177
+ let xorEncrypted = encryptDecrypt.XOREncrypt(base64data, encryptionKey)
178
+ let ecbEncrypted = encryptDecrypt.ecbEncrypt(xorEncrypted.toString(), encryptionKey)
179
+ return ecbEncrypted;
180
+ }
181
+
171
182
  }
172
183
  },
173
184
  sendEmail: async (json) => {
@@ -213,7 +224,7 @@ module.exports = {
213
224
 
214
225
 
215
226
  let html = await generateHTMLCorporateReport(decodedJSON, isDebugging);
216
-
227
+
217
228
 
218
229
  // 3: save PDF buffer
219
230
  let fileBuffer = await generatePDFCorporateReport(html);
@@ -113,7 +113,6 @@ let generateHTMLCorporateReport = async (data, isDebugging) => {
113
113
  const dom = new JSDOM(html);
114
114
  let historyData = [];
115
115
  debugLog("templates loaded");
116
-
117
116
  let display_second_log = show_second_footer_logo ? "" : "display:none";
118
117
  let show_medicus = show_medicus_logo ? path.resolve(__dirname + "/../assets/corporate_report/images/medicus-logo-footer.png") : ""
119
118
  coverPageTemplate = coverPageTemplate
@@ -0,0 +1,59 @@
1
+ const CryptoJS = require('crypto-js');
2
+
3
+ function ecbEncrypt(data, key) {
4
+ let encJson = CryptoJS.AES.encrypt(JSON.stringify(data), key).toString();
5
+ return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(encJson));
6
+ }
7
+
8
+ function ecbDecrypt(data, key) {
9
+ var keys = CryptoJS.enc.Utf8.parse(key);
10
+ let base64 = CryptoJS.enc.Base64.parse(data);
11
+ let src = CryptoJS.enc.Base64.stringify(base64);
12
+ var decrypt = CryptoJS.AES.decrypt(src, keys, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
13
+ return decrypt.toString(CryptoJS.enc.Utf8);
14
+ }
15
+
16
+
17
+ function XORDecrypt(input, key) {
18
+ console.log("key",key)
19
+ key = typeof key === 'object' ? JSON.stringify(key) : key.toString();
20
+ var decodedText = atob(input);
21
+ var plainText = '';
22
+ var length = decodedText.length;
23
+
24
+ for (var i = 0; i < length; i++) {
25
+ plainText += String.fromCharCode(decodedText.charCodeAt(i) ^ key.charCodeAt(Math.floor(i % key.length)));
26
+ }
27
+
28
+ return plainText;
29
+ }
30
+
31
+ function XOREncrypt(input, key){
32
+ var c = '';
33
+ while (key.length < input.length) {
34
+ key += key;
35
+ }
36
+ for(var i=0; i<input.length; i++) {
37
+ var value1 = input[i].charCodeAt(0);
38
+ var value2 = key[i].charCodeAt(0);
39
+
40
+ var xorValue = value1 ^ value2;
41
+
42
+ var xorValueAsHexString = xorValue.toString("16");
43
+
44
+ if (xorValueAsHexString.length < 2) {
45
+ xorValueAsHexString = "0" + xorValueAsHexString;
46
+ }
47
+
48
+ c += xorValueAsHexString;
49
+ }
50
+ return c;
51
+ }
52
+
53
+ module.exports =
54
+ {
55
+ ecbEncrypt,
56
+ ecbDecrypt,
57
+ XORDecrypt,
58
+ XOREncrypt
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medicus.ai/medicus-report-pdf-generator",
3
- "version": "1.0.216",
3
+ "version": "1.0.218",
4
4
  "description": "Nasco corporate report - latest update in 2/11/2022 - Fix sanusx coprorate report issues",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,6 +40,7 @@
40
40
  "babel-polyfill": "^6.26.0",
41
41
  "babel-preset-es2015": "^6.24.1",
42
42
  "babel-preset-stage-0": "^6.24.1",
43
+ "crypto-js": "^4.1.1",
43
44
  "webpack": "^4.28.4"
44
45
  }
45
46
  }