Skip to content

Commit 5bdac9a

Browse files
Joshua LamkeJoshua Lamke
authored andcommitted
add optional context to encryptdata eem to have available in eem rule function
1 parent a07ab13 commit 5bdac9a

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lambda-stream",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "Create stream processors with AWS Lambda functions.",
55
"keywords": [
66
"aws",

src/utils/encryption.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ export const encryptData = ({
165165
masterKeyAlias = process.env.MASTER_KEY_ALIAS,
166166
regions = (process.env.KMS_REGIONS && process.env.KMS_REGIONS.split(',')),
167167
AES = true,
168-
} = {}) => async (data) => {
169-
const eemMetadata = typeof eem === 'function' ? eem(data) : eem;
168+
} = {}) => async (data, ctx = {}) => {
169+
const eemMetadata = typeof eem === 'function' ? eem(data, ctx) : eem;
170170
const result = await encryptObject(data, {
171171
masterKeyAlias,
172172
regions,

test/unit/utils/encryption.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,22 @@ describe('utils/encryption.js', () => {
266266
...uow.event.thing,
267267
discriminator: 'thing',
268268
timestamp: uow.event.timestamp,
269+
}, {
270+
event: {
271+
eem: {
272+
fields: [
273+
'description',
274+
],
275+
},
276+
},
269277
})),
270278
}),
271-
eem: (data) => {
279+
eem: (data, ctx) => {
272280
if (data.discriminator === 'thing') {
273281
return {
274282
fields: [
275283
'name',
276-
'description',
284+
...ctx.event.eem.fields,
277285
],
278286
};
279287
} else {

0 commit comments

Comments
 (0)