@pikku/mongodb 0.12.2 → 0.12.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @pikku/mongodb
2
2
 
3
+ ## 0.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - a2ee6d0: Replace process.exit(1) with thrown error on MongoDB connection failure to allow graceful error handling.
8
+ - 87433f0: Validate state key names in updateRunState to prevent MongoDB operator injection.
9
+ - Updated dependencies [e412b4d]
10
+ - Updated dependencies [53dc8c8]
11
+ - Updated dependencies [0a1cc51]
12
+ - Updated dependencies [0a1cc51]
13
+ - Updated dependencies [0a1cc51]
14
+ - Updated dependencies [0a1cc51]
15
+ - Updated dependencies [0a1cc51]
16
+ - Updated dependencies [0a1cc51]
17
+ - Updated dependencies [0a1cc51]
18
+ - Updated dependencies [0a1cc51]
19
+ - Updated dependencies [0a1cc51]
20
+ - Updated dependencies [8b9b2e9]
21
+ - Updated dependencies [8b9b2e9]
22
+ - Updated dependencies [b973d44]
23
+ - Updated dependencies [8b9b2e9]
24
+ - Updated dependencies [8b9b2e9]
25
+ - @pikku/core@0.12.9
26
+
3
27
  ## 0.12.2
4
28
 
5
29
  ### Patch Changes
@@ -50,7 +50,7 @@ export class MongoDBSecretService {
50
50
  async getSecret(key) {
51
51
  const row = await this.secrets.findOne({ _id: key });
52
52
  if (!row)
53
- throw new Error(`Secret not found: ${key}`);
53
+ throw new Error('Requested secret not found');
54
54
  const kek = this.getKEK(row.keyVersion);
55
55
  const result = await envelopeDecrypt(kek, row.ciphertext, row.wrappedDek);
56
56
  await this.logAudit(key, 'read');
@@ -311,6 +311,9 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
311
311
  await this.steps.updateOne({ _id: stepId }, { $set: { branchTaken: branchKey, updatedAt: new Date() } });
312
312
  }
313
313
  async updateRunState(runId, name, value) {
314
+ if (!/^[a-zA-Z0-9_]+$/.test(name)) {
315
+ throw new Error('Invalid state key name');
316
+ }
314
317
  await this.runs.updateOne({ _id: runId }, {
315
318
  $set: {
316
319
  [`state.${name}`]: value,
@@ -26,7 +26,7 @@ export class PikkuMongoDB {
26
26
  }
27
27
  catch (error) {
28
28
  this.logger.error('Error connecting to MongoDB', error);
29
- process.exit(1);
29
+ throw error;
30
30
  }
31
31
  }
32
32
  async close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/mongodb",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "module": "dist/src/index.js",
@@ -17,7 +17,7 @@
17
17
  "prepublishOnly": "yarn build"
18
18
  },
19
19
  "peerDependencies": {
20
- "@pikku/core": "^0.12.6"
20
+ "@pikku/core": "^0.12.9"
21
21
  },
22
22
  "dependencies": {
23
23
  "mongodb": "^6.12.0"
@@ -89,7 +89,7 @@ export class MongoDBSecretService implements SecretService {
89
89
 
90
90
  async getSecret(key: string): Promise<string> {
91
91
  const row = await this.secrets.findOne({ _id: key })
92
- if (!row) throw new Error(`Secret not found: ${key}`)
92
+ if (!row) throw new Error('Requested secret not found')
93
93
 
94
94
  const kek = this.getKEK(row.keyVersion)
95
95
  const result = await envelopeDecrypt<string>(
@@ -515,6 +515,9 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
515
515
  name: string,
516
516
  value: unknown
517
517
  ): Promise<void> {
518
+ if (!/^[a-zA-Z0-9_]+$/.test(name)) {
519
+ throw new Error('Invalid state key name')
520
+ }
518
521
  await this.runs.updateOne(
519
522
  { _id: runId },
520
523
  {
@@ -29,7 +29,7 @@ export class PikkuMongoDB {
29
29
  this.logger.info('MongoDB connection successful')
30
30
  } catch (error) {
31
31
  this.logger.error('Error connecting to MongoDB', error)
32
- process.exit(1)
32
+ throw error
33
33
  }
34
34
  }
35
35