@friggframework/core 2.0.0--canary.419.29d9541.0 → 2.0.0--canary.419.8343c27.0

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.
@@ -150,21 +150,6 @@ const createTestEncryptionModel = () => {
150
150
  );
151
151
  };
152
152
 
153
- const createTestDocument = async (TestModel) => {
154
- const testData = {
155
- testSecret: 'This is a secret value that should be encrypted',
156
- normalField: 'This is a normal field that should not be encrypted',
157
- nestedSecret: {
158
- value: 'This is a nested secret that should be encrypted',
159
- },
160
- };
161
-
162
- const testDoc = new TestModel(testData);
163
- await testDoc.save();
164
-
165
- return { testDoc, testData };
166
- };
167
-
168
153
  const verifyDecryption = (retrievedDoc, originalData) => {
169
154
  return (
170
155
  retrievedDoc &&
@@ -238,18 +223,51 @@ const evaluateEncryptionTestResults = (decryptionWorks, encryptionResults) => {
238
223
  };
239
224
  };
240
225
 
226
+ const withTimeout = (promise, ms, errorMessage) => {
227
+ return Promise.race([
228
+ promise,
229
+ new Promise((_, reject) =>
230
+ setTimeout(() => reject(new Error(errorMessage)), ms)
231
+ ),
232
+ ]);
233
+ };
234
+
241
235
  const testEncryption = async () => {
236
+ // eslint-disable-next-line no-console
237
+ console.log('Starting encryption test');
242
238
  const TestModel = createTestEncryptionModel();
243
- const { testDoc, testData } = await createTestDocument(TestModel);
239
+ // eslint-disable-next-line no-console
240
+ console.log('Test model created');
241
+
242
+ const testData = {
243
+ testSecret: 'This is a secret value that should be encrypted',
244
+ normalField: 'This is a normal field that should not be encrypted',
245
+ nestedSecret: {
246
+ value: 'This is a nested secret that should be encrypted',
247
+ },
248
+ };
249
+
250
+ const testDoc = new TestModel(testData);
251
+ await withTimeout(testDoc.save(), 5000, 'Save operation timed out');
252
+ // eslint-disable-next-line no-console
253
+ console.log('Test document saved');
244
254
 
245
255
  try {
246
- const retrievedDoc = await TestModel.findById(testDoc._id);
256
+ const retrievedDoc = await withTimeout(
257
+ TestModel.findById(testDoc._id),
258
+ 5000,
259
+ 'Find operation timed out'
260
+ );
261
+ // eslint-disable-next-line no-console
262
+ console.log('Test document retrieved');
247
263
  const decryptionWorks = verifyDecryption(retrievedDoc, testData);
248
- const encryptionResults = await verifyEncryptionInDatabase(
249
- testDoc,
250
- testData,
251
- TestModel
264
+ const encryptionResults = await withTimeout(
265
+ verifyEncryptionInDatabase(testDoc, testData, TestModel),
266
+ 5000,
267
+ 'Database verification timed out'
252
268
  );
269
+ // eslint-disable-next-line no-console
270
+ console.log('Encryption verification completed');
253
271
 
254
272
  const evaluation = evaluateEncryptionTestResults(
255
273
  decryptionWorks,
@@ -261,7 +279,13 @@ const testEncryption = async () => {
261
279
  encryptionWorks: decryptionWorks,
262
280
  };
263
281
  } finally {
264
- await TestModel.deleteOne({ _id: testDoc._id });
282
+ await withTimeout(
283
+ TestModel.deleteOne({ _id: testDoc._id }),
284
+ 5000,
285
+ 'Delete operation timed out'
286
+ );
287
+ // eslint-disable-next-line no-console
288
+ console.log('Test document deleted');
265
289
  }
266
290
  };
267
291
 
@@ -269,6 +293,12 @@ const checkEncryptionHealth = async () => {
269
293
  const config = getEncryptionConfiguration();
270
294
 
271
295
  if (config.isBypassed || config.mode === 'none') {
296
+ // eslint-disable-next-line no-console
297
+ console.log('Encryption check bypassed:', {
298
+ stage: config.stage,
299
+ mode: config.mode,
300
+ });
301
+
272
302
  const testResult = config.isBypassed
273
303
  ? 'Encryption bypassed for this stage'
274
304
  : 'No encryption keys configured';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.419.29d9541.0",
4
+ "version": "2.0.0--canary.419.8343c27.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "aws-sdk": "^2.1200.0",
@@ -22,9 +22,9 @@
22
22
  "uuid": "^9.0.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@friggframework/eslint-config": "2.0.0--canary.419.29d9541.0",
26
- "@friggframework/prettier-config": "2.0.0--canary.419.29d9541.0",
27
- "@friggframework/test": "2.0.0--canary.419.29d9541.0",
25
+ "@friggframework/eslint-config": "2.0.0--canary.419.8343c27.0",
26
+ "@friggframework/prettier-config": "2.0.0--canary.419.8343c27.0",
27
+ "@friggframework/test": "2.0.0--canary.419.8343c27.0",
28
28
  "@types/lodash": "4.17.15",
29
29
  "@typescript-eslint/eslint-plugin": "^8.0.0",
30
30
  "chai": "^4.3.6",
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "29d95417b566c13df23e8d211caff257e49742bf"
59
+ "gitHead": "8343c27a69423f9186421c9caf188399e56bbf67"
60
60
  }