@reproapp/node-sdk 0.0.5 → 0.0.7
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/dist/index.d.ts +16 -10
- package/dist/index.js +630 -580
- package/package.json +2 -2
- package/src/index.ts +739 -647
- package/test/circular-capture.test.js +1 -1
- package/test/disable-subtree.test.js +1 -1
- package/test/kafka-runtime-privacy-policy.test.js +451 -18
- package/test/request-flush-timing.test.js +123 -0
- package/test/runtime-privacy-materialization.test.js +76 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const assert = require('node:assert');
|
|
2
|
+
const { __reproTestHooks } = require('../dist/index.js');
|
|
3
|
+
|
|
4
|
+
async function withTimeout(promise, ms) {
|
|
5
|
+
let timeout;
|
|
6
|
+
try {
|
|
7
|
+
return await Promise.race([
|
|
8
|
+
promise,
|
|
9
|
+
new Promise((_, reject) => {
|
|
10
|
+
timeout = setTimeout(() => reject(new Error(`timed out after ${ms}ms`)), ms);
|
|
11
|
+
}),
|
|
12
|
+
]);
|
|
13
|
+
} finally {
|
|
14
|
+
if (timeout) clearTimeout(timeout);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
const mongooseLikeDoc = {
|
|
20
|
+
$__: {},
|
|
21
|
+
toObject() {
|
|
22
|
+
return {
|
|
23
|
+
_id: '6a0e53c8aba8240c69b27d7b',
|
|
24
|
+
caseId: 'privacy-lab-debug-root',
|
|
25
|
+
payload: {
|
|
26
|
+
rawMessage: '{"eventType":"privacy-lab.case.observed"}',
|
|
27
|
+
nested: {
|
|
28
|
+
reviewerEmail: 'privacy.operator@example.com',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
mongooseLikeDoc.$__.owner = mongooseLikeDoc;
|
|
35
|
+
mongooseLikeDoc.$__.cache = {
|
|
36
|
+
veryLargeInternalValue: 'x'.repeat(10000),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const materialized = await withTimeout(
|
|
40
|
+
__reproTestHooks.materializeInlinePrivacyValueAsyncForTest(
|
|
41
|
+
'db.query',
|
|
42
|
+
{
|
|
43
|
+
op: 'insertOne',
|
|
44
|
+
doc: mongooseLikeDoc,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
appId: 'APP_test',
|
|
48
|
+
appSecret: 'secret',
|
|
49
|
+
tenantId: 'TENANT_test',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
method: 'POST',
|
|
53
|
+
path: '/api/privacy-lab-drills/run',
|
|
54
|
+
key: 'POST /api/privacy-lab-drills/run',
|
|
55
|
+
},
|
|
56
|
+
null,
|
|
57
|
+
null,
|
|
58
|
+
null,
|
|
59
|
+
),
|
|
60
|
+
1000,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
assert.strictEqual(materialized.skipped, undefined);
|
|
64
|
+
assert.strictEqual(materialized.value.doc.$__, undefined);
|
|
65
|
+
assert.strictEqual(materialized.value.doc.caseId, 'privacy-lab-debug-root');
|
|
66
|
+
assert.strictEqual(materialized.value.doc.payload.rawMessage, '{"eventType":"privacy-lab.case.observed"}');
|
|
67
|
+
assert.match(materialized.value.doc.payload.nested.reviewerEmail, /^email_tok_[a-f0-9]+$/);
|
|
68
|
+
assert.deepStrictEqual(Object.keys(materialized.value.doc).sort(), ['_id', 'caseId', 'payload']);
|
|
69
|
+
|
|
70
|
+
console.log('runtime privacy materialization OK');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main().catch((error) => {
|
|
74
|
+
console.error(error);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|