core-services-sdk 1.3.42 → 1.3.44
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 +1 -1
- package/src/ids/generators.js +8 -0
- package/src/ids/prefixes.js +3 -0
- package/src/rabbit-mq/rabbit-mq.js +6 -3
- package/tests/ids/prefixes.unit.test.js +1 -1
- package/tests/util/mask-sensitive.unit.test.js +9 -0
- package/types/ids/generators.d.ts +1 -0
- package/types/ids/prefixes.d.ts +2 -0
package/package.json
CHANGED
package/src/ids/generators.js
CHANGED
|
@@ -215,3 +215,11 @@ export const generateAlertId = () => generatePrefixedId(ID_PREFIXES.ALERT)
|
|
|
215
215
|
* @returns {string} A resource ID.
|
|
216
216
|
*/
|
|
217
217
|
export const generateResourceId = () => generatePrefixedId(ID_PREFIXES.RESOURCE)
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Generates a resource ID with a `ieml_` prefix.
|
|
221
|
+
*
|
|
222
|
+
* @returns {string} An incoming email ID.
|
|
223
|
+
*/
|
|
224
|
+
export const generateIncomingEmailId = () =>
|
|
225
|
+
generatePrefixedId(ID_PREFIXES.INCOMING_EMAIL)
|
package/src/ids/prefixes.js
CHANGED
|
@@ -21,7 +21,10 @@ const generateMsgId = () => `rbt_${ulid()}`
|
|
|
21
21
|
*/
|
|
22
22
|
export const connectQueueService = async ({ host, log }) => {
|
|
23
23
|
const t0 = Date.now()
|
|
24
|
-
const logger = log.child({
|
|
24
|
+
const logger = log.child({
|
|
25
|
+
op: 'connectQueueService',
|
|
26
|
+
host: mask(host, '.', 3),
|
|
27
|
+
})
|
|
25
28
|
|
|
26
29
|
try {
|
|
27
30
|
logger.debug('start')
|
|
@@ -50,7 +53,7 @@ export const connectQueueService = async ({ host, log }) => {
|
|
|
50
53
|
*/
|
|
51
54
|
export const createChannel = async ({ host, log }) => {
|
|
52
55
|
const t0 = Date.now()
|
|
53
|
-
const logger = log.child({ op: 'createChannel', host: mask(host) })
|
|
56
|
+
const logger = log.child({ op: 'createChannel', host: mask(host, '.', 3) })
|
|
54
57
|
|
|
55
58
|
try {
|
|
56
59
|
logger.debug('start')
|
|
@@ -175,7 +178,7 @@ export const subscribeToQueue = async ({
|
|
|
175
178
|
*/
|
|
176
179
|
export const initializeQueue = async ({ host, log }) => {
|
|
177
180
|
const { channel, connection } = await createChannel({ host, log })
|
|
178
|
-
const logger = log.child({ op: 'initializeQueue', host: mask(host) })
|
|
181
|
+
const logger = log.child({ op: 'initializeQueue', host: mask(host, '.', 3) })
|
|
179
182
|
|
|
180
183
|
/**
|
|
181
184
|
* Publishes a message to a queue with a generated `rbt_<ulid>` ID.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { describe, it, expect } from 'vitest'
|
|
3
|
-
|
|
4
3
|
import { ID_PREFIXES } from '../../src/ids/prefixes.js'
|
|
5
4
|
|
|
6
5
|
describe('ID_PREFIXES', () => {
|
|
@@ -32,6 +31,7 @@ describe('ID_PREFIXES', () => {
|
|
|
32
31
|
DEVICE: 'dev',
|
|
33
32
|
ALERT: 'alr',
|
|
34
33
|
RESOURCE: 'res',
|
|
34
|
+
INCOMING_EMAIL: 'ieml', // ✅ added
|
|
35
35
|
})
|
|
36
36
|
})
|
|
37
37
|
|
|
@@ -87,4 +87,13 @@ describe('mask', () => {
|
|
|
87
87
|
const value = mask(input, '*', 5)
|
|
88
88
|
expect(value).toEqual(expected)
|
|
89
89
|
})
|
|
90
|
+
|
|
91
|
+
it('mask long string with maskLen in recursive calls', () => {
|
|
92
|
+
const input = {
|
|
93
|
+
val: 'abcdsdkljhfjksdhgfjksdghkhsdkjfhasldkjjhskjfgsdkjhgfhskdgfefgh',
|
|
94
|
+
}
|
|
95
|
+
const expected = { val: 'ab***gh' }
|
|
96
|
+
const value = mask(input, '*', 3)
|
|
97
|
+
expect(value).toEqual(expected)
|
|
98
|
+
})
|
|
90
99
|
})
|