@fto-consult/expo-ui 8.43.0 → 8.43.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/pdf/index.js +19 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "8.43.0",
3
+ "version": "8.43.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
package/src/pdf/index.js CHANGED
@@ -26,8 +26,12 @@ export const hashQRCode = (data)=>{
26
26
  }
27
27
  }
28
28
 
29
- export const decryptQRCode = (hashedQRCode)=>{
30
- return crypToJS.decode(hashedQRCode,QR_CODE_HASH_KEY);
29
+ export const decryptQRCodeData = (hashedQRCode)=>{
30
+ try {
31
+ return crypToJS.decode(hashedQRCode,QR_CODE_HASH_KEY);
32
+ } catch {
33
+ return null;
34
+ }
31
35
  }
32
36
 
33
37
  export const isValidQRCode = (data)=>{
@@ -35,7 +39,17 @@ export const isValidQRCode = (data)=>{
35
39
  data = JSON.parse(data);
36
40
  }
37
41
  data = defaultObj(data);
38
- return hashQRCode(data.data) === data.hash && QR_CODE_HASH_KEY_PREFIX.toLowerCase() == defaultStr(data.provider).toLowerCase().replace(/\s/g, "");
42
+ data.data = decryptQRCodeData(data.data);
43
+ if(!data.data || !isJSON(data.data)) return false;
44
+ return QR_CODE_HASH_KEY_PREFIX.toLowerCase() == defaultStr(data.provider).toLowerCase().replace(/\s/g, "");
45
+ }
46
+ export const decryptQRCode = (data)=>{
47
+ if(isJSON(data)){
48
+ data = JSON.parse(data);
49
+ }
50
+ data = defaultObj(data);
51
+ if(!isValidQRCode(data)) return null;
52
+ return data;
39
53
  }
40
54
 
41
55
  const {createPdf} = pdfMake;
@@ -198,7 +212,7 @@ export const getPrintSettings = ({multiple,duplicateDocOnPage,isTableData,tableD
198
212
  },
199
213
  qrCodeFitSize : {
200
214
  type :"number",
201
- defaultValue : 150,
215
+ defaultValue : 120,
202
216
  label : "Taille du QR Code",
203
217
  validType : "numberGreaterThanOrEquals[120]"
204
218
  },
@@ -289,7 +303,7 @@ export function printTableData(data,options){
289
303
  const pseudo = Auth.getUserPseudo();
290
304
  const fullName = Auth.getUserFullName() || pseudo || Auth.getLoggedUserCode();
291
305
  const printBy = isNonNullString(fullName)? (`${fullName}${uEmail?`[${uEmail}]`:""}`) : "";
292
- result.content.push({ qr: JSON.stringify({data:qrData,hash:hashQRCode(qrData),provider:defaultStr(appConfig.name).replace(/\s/g, ""),printBy,printDate:new Date().toFormat(DateLib.defaultDateTimeFormat),tableName:table}),margin:[0,8,0,5], fit: defaultNumber(data.qrCodeFitSize,150), alignment: qrCodeAlignmentPosition})
306
+ result.content.push({ qr: JSON.stringify({data:hashQRCode(qrData),provider:defaultStr(appConfig.name).replace(/\s/g, ""),printBy,printDate:new Date().toFormat(DateLib.defaultDateTimeFormat),tableName:table}),margin:[0,8,0,5], fit: defaultNumber(data.qrCodeFitSize,120), alignment: qrCodeAlignmentPosition})
293
307
  }
294
308
  }
295
309
  return result;