core-services-sdk 1.3.78 → 1.3.80
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
|
@@ -240,7 +240,7 @@ export function buildEnvReport(definition, values, validationResult, mask) {
|
|
|
240
240
|
? validationResult.data[key]
|
|
241
241
|
: rawValue
|
|
242
242
|
|
|
243
|
-
const displayValue = isSecret ? maskValue(value) : String(value)
|
|
243
|
+
const displayValue = isSecret ? maskValue(value, '.', 3) : String(value)
|
|
244
244
|
|
|
245
245
|
const errors = validationResult.success
|
|
246
246
|
? undefined
|
|
@@ -17,7 +17,9 @@ export const maskSingle = (
|
|
|
17
17
|
if (value == null) {
|
|
18
18
|
return ''
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
const str = String(value)
|
|
22
|
+
|
|
21
23
|
if (str.length === 0) {
|
|
22
24
|
return ''
|
|
23
25
|
}
|
|
@@ -25,16 +27,20 @@ export const maskSingle = (
|
|
|
25
27
|
if (typeof value === 'boolean') {
|
|
26
28
|
return str
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
// default: max 3 mask characters
|
|
32
|
+
const calculated = Math.max(1, str.length - (left + right))
|
|
33
|
+
const m = maskLen == null ? Math.min(3, calculated) : Math.max(0, maskLen)
|
|
30
34
|
|
|
31
35
|
if (str.length <= left + right) {
|
|
32
36
|
if (str.length === 1) {
|
|
33
37
|
return fill
|
|
34
38
|
}
|
|
39
|
+
|
|
35
40
|
if (str.length === 2) {
|
|
36
|
-
return str[0] + fill
|
|
41
|
+
return str[0] + fill
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
return str.slice(0, 1) + fill.repeat(m) + str.slice(-1)
|
|
39
45
|
}
|
|
40
46
|
|
|
@@ -5,11 +5,11 @@ import { mask, maskSingle } from '../../src/util/index.js'
|
|
|
5
5
|
describe('maskSingle', () => {
|
|
6
6
|
it('masks middle of a regular string (length == left+right)', () => {
|
|
7
7
|
const value = maskSingle('abcdefgh')
|
|
8
|
-
expect(value).toBe('ab
|
|
8
|
+
expect(value).toBe('ab...gh')
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
it('masks numbers with default settings', () => {
|
|
12
|
-
expect(maskSingle(12345678)).toBe('12
|
|
12
|
+
expect(maskSingle(12345678)).toBe('12...78')
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
it('masks booleans', () => {
|
|
@@ -45,8 +45,8 @@ describe('maskSingle', () => {
|
|
|
45
45
|
|
|
46
46
|
describe('mask', () => {
|
|
47
47
|
it('masks primitives (string, number, boolean)', () => {
|
|
48
|
-
expect(mask('abcdefgh')).toBe('ab
|
|
49
|
-
expect(mask(12345678)).toBe('12
|
|
48
|
+
expect(mask('abcdefgh')).toBe('ab...gh')
|
|
49
|
+
expect(mask(12345678)).toBe('12...78')
|
|
50
50
|
const trueValue = mask(true)
|
|
51
51
|
expect(trueValue).toBe('true')
|
|
52
52
|
expect(mask(false)).toBe('false')
|
|
@@ -59,20 +59,20 @@ describe('mask', () => {
|
|
|
59
59
|
|
|
60
60
|
it('masks arrays recursively', () => {
|
|
61
61
|
const value = mask(['abcdefgh', 12345678])
|
|
62
|
-
expect(value).toEqual(['ab
|
|
62
|
+
expect(value).toEqual(['ab...gh', '12...78'])
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
it('masks objects recursively', () => {
|
|
66
66
|
expect(mask({ a: 'abcdefgh', b: 12345678 })).toEqual({
|
|
67
|
-
a: 'ab
|
|
68
|
-
b: '12
|
|
67
|
+
a: 'ab...gh',
|
|
68
|
+
b: '12...78',
|
|
69
69
|
})
|
|
70
70
|
})
|
|
71
71
|
|
|
72
72
|
it('masks nested objects/arrays recursively', () => {
|
|
73
73
|
const input = { arr: ['abcdefgh', { num: 12345678 }] }
|
|
74
74
|
const expected = { arr: ['ab....gh', { num: '12....78' }] }
|
|
75
|
-
const value = mask(input)
|
|
75
|
+
const value = mask(input, undefined, 4)
|
|
76
76
|
expect(value).toEqual(expected)
|
|
77
77
|
})
|
|
78
78
|
|
|
@@ -96,4 +96,25 @@ describe('mask', () => {
|
|
|
96
96
|
const value = mask(input, '*', 3)
|
|
97
97
|
expect(value).toEqual(expected)
|
|
98
98
|
})
|
|
99
|
+
|
|
100
|
+
it('limits default mask to max 3 characters', () => {
|
|
101
|
+
const value = maskSingle('abcdefghijklmnop')
|
|
102
|
+
expect(value).toBe('ab...op')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('does not exceed available middle length', () => {
|
|
106
|
+
const value = maskSingle('abcde') // left=2 right=2 → middle=1
|
|
107
|
+
expect(value).toBe('ab.de')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('allows maskLen = 0', () => {
|
|
111
|
+
const value = maskSingle('abcdefgh', '.', 0)
|
|
112
|
+
expect(value).toBe('abgh')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('handles Date inside object', () => {
|
|
116
|
+
const d = new Date('2025-01-01T00:00:00.000Z')
|
|
117
|
+
const value = mask({ date: d })
|
|
118
|
+
expect(value).toEqual({ date: d.toISOString() })
|
|
119
|
+
})
|
|
99
120
|
})
|