@sera4/essentia 1.1.32 → 1.1.33

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sera4/essentia",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "A library of utilities for Teleporte Web Services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/package.tar.gz CHANGED
Binary file
@@ -67,25 +67,25 @@ const calcDelta = (current, next, exclude, strict, DEBUG = false) => {
67
67
  };
68
68
 
69
69
  const diffToString = val => {
70
- if (typeof val === 'undefined' || val === null)
70
+ if (typeof val === 'undefined' || val === null)
71
71
  return '';
72
72
 
73
73
  if (val === true)
74
74
  return '1';
75
75
 
76
- if (val === false)
76
+ if (val === false)
77
77
  return '0';
78
78
 
79
- if (typeof val === 'string')
79
+ if (typeof val === 'string')
80
80
  return val;
81
81
 
82
- if (!Number.isNaN(Number(val)))
82
+ if (!Number.isNaN(Number(val)))
83
83
  return `${String(val)}`;
84
84
 
85
- if ((typeof val === 'undefined' ? 'undefined' : typeof val) === 'object')
85
+ if ((typeof val === 'undefined' ? 'undefined' : typeof val) === 'object')
86
86
  return `${JSON.stringify(val)}`;
87
87
 
88
- if (Array.isArray(val))
88
+ if (Array.isArray(val))
89
89
  return `${JSON.stringify(val)}`;
90
90
 
91
91
  return '';
@@ -95,5 +95,5 @@ export default {
95
95
  capitalizeFirstLetter,
96
96
  toUnderscored,
97
97
  calcDelta,
98
- diffToString,
98
+ diffToString
99
99
  };
@@ -4,6 +4,8 @@ import helpers from './helpers.js';
4
4
  import paginator from "../paginator/sql-pagination.js";
5
5
  import { utils } from "../utils/index.js"
6
6
 
7
+ const censorText = "**********"
8
+
7
9
  let failHard = false;
8
10
  let als;
9
11
  let Sequelize = null;
@@ -31,6 +33,7 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
31
33
  ],
32
34
  // additional fields to exclude on a global basis
33
35
  excludeExtras: [],
36
+ censor: ["mfa_temp_secret", "mfa_secret"],
34
37
  revisionAttribute: 'revision',
35
38
  revisionModel: 'Revision',
36
39
  revisionChangeModel: 'RevisionChange',
@@ -660,6 +663,15 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
660
663
  values.document_id = values.document_id || values.document_uuid;
661
664
  delete values.document_uuid;
662
665
 
666
+ _.forEach(defaultOptions.censor, a => {
667
+ if (!utils.isBlank(values.document.newValues[a])){
668
+ values.document.newValues[a] = censorText;
669
+ }
670
+ if (!utils.isBlank(values.document.oldValues[a])){
671
+ values.document.oldValues[a] = censorText;
672
+ }
673
+ })
674
+
663
675
  return _.omitBy(values, function(value, key) {
664
676
  return (excludedFields.includes(key) || (value === null));
665
677
  });
package/utils/index.js CHANGED
@@ -36,5 +36,8 @@ export const utils = {
36
36
  return []
37
37
  }
38
38
  }
39
+ },
40
+ isBlank: (str) => {
41
+ return ((str === null) || (str === undefined) || /^\s*$/.test(str));
39
42
  }
40
43
  }