@mohasinac/appkit 4.30.17 → 4.30.18
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { batchDelete, getTestDataRefs } from "../handlers/_helpers";
|
|
2
2
|
import { BID_FIELDS } from "../../../../constants/field-names";
|
|
3
|
+
import { encryptPiiFields } from "../../../../security/pii-encrypt";
|
|
4
|
+
import { BID_PII_FIELDS, OFFER_PII_FIELDS, } from "../../../../security/pii-schemas";
|
|
3
5
|
import { SANDBOX_COLLECTIONS } from "./testerSandboxCleanup";
|
|
4
6
|
// Direct imports from each defining module (not the seed-data barrel) —
|
|
5
7
|
// this is internal appkit code, not part of the package's public API surface.
|
|
@@ -10,6 +12,29 @@ import { blogTesterSeedData } from "../../../../features/tester/seed-data/blog-t
|
|
|
10
12
|
import { eventsTesterSeedData } from "../../../../features/tester/seed-data/events-tester-seed-data";
|
|
11
13
|
import { offersTesterSeedData } from "../../../../features/tester/seed-data/offers-tester-seed-data";
|
|
12
14
|
import { bidsTesterSeedData } from "../../../../features/tester/seed-data/bids-tester-seed-data";
|
|
15
|
+
/**
|
|
16
|
+
* PII per sandbox collection — the same map `seed-cli.mjs` applies.
|
|
17
|
+
*
|
|
18
|
+
* This job wrote every document with a bare `batch.set(...)`, while its own
|
|
19
|
+
* comment claimed to mirror seed-cli's loadGeneric. loadGeneric ENCRYPTS;
|
|
20
|
+
* this did not. So the 4-hourly refresh re-seeded sandbox PII in plaintext and
|
|
21
|
+
* quietly undid the backfill for those fixtures — caught by reading the raw
|
|
22
|
+
* documents after a deploy, where `bids` had 37 encrypted rows and one
|
|
23
|
+
* plaintext one that had not existed at backfill time.
|
|
24
|
+
*
|
|
25
|
+
* A scheduled job writing straight to Firestore bypasses `applyWriteHooks`
|
|
26
|
+
* exactly like the hand-rolled repository overrides did. Same defect, one
|
|
27
|
+
* level up.
|
|
28
|
+
*/
|
|
29
|
+
const SANDBOX_PII = {
|
|
30
|
+
offers: OFFER_PII_FIELDS,
|
|
31
|
+
bids: BID_PII_FIELDS,
|
|
32
|
+
products: ["sellerName", "sellerEmail"],
|
|
33
|
+
};
|
|
34
|
+
function encryptForSandbox(collection, data) {
|
|
35
|
+
const fields = SANDBOX_PII[collection];
|
|
36
|
+
return fields ? encryptPiiFields(data, [...fields]) : data;
|
|
37
|
+
}
|
|
13
38
|
const SEED_BY_COLLECTION = {
|
|
14
39
|
categories: categoriesTesterSeedData,
|
|
15
40
|
stores: storesTesterSeedData,
|
|
@@ -44,7 +69,7 @@ export async function runTesterSandboxRefresh(ctx) {
|
|
|
44
69
|
// merge:true mirrors seed-cli.mjs's loadGeneric — the seed payload
|
|
45
70
|
// carries every canonical field, so this fully overwrites anything
|
|
46
71
|
// a tester edited through the UI.
|
|
47
|
-
batch.set(ctx.db.collection(collection).doc(id), data, { merge: true });
|
|
72
|
+
batch.set(ctx.db.collection(collection).doc(id), encryptForSandbox(collection, data), { merge: true });
|
|
48
73
|
reverted++;
|
|
49
74
|
}
|
|
50
75
|
await batch.commit();
|
|
@@ -66,7 +91,7 @@ export async function runTesterSandboxRefresh(ctx) {
|
|
|
66
91
|
const { id, ...data } = bid;
|
|
67
92
|
if (!id)
|
|
68
93
|
continue;
|
|
69
|
-
bidBatch.set(ctx.db.collection("bids").doc(id), data, { merge: true });
|
|
94
|
+
bidBatch.set(ctx.db.collection("bids").doc(id), encryptForSandbox("bids", data), { merge: true });
|
|
70
95
|
reverted++;
|
|
71
96
|
}
|
|
72
97
|
await bidBatch.commit();
|