@mimik/mongooser 4.0.1 → 4.1.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.
package/README.md CHANGED
@@ -41,6 +41,8 @@ Creates a MongoDB connection manager for mimik microservices.
41
41
  | [config.encryption.aws] | <code>object</code> | AWS KMS provider settings. |
42
42
  | [config.encryption.database] | <code>string</code> | Database name for key vault. |
43
43
  | [config.encryption.keyVaultTable] | <code>string</code> | Collection name for key vault. |
44
+ | [config.encryption.cryptSharedLibPath] | <code>string</code> | Absolute path to the crypt_shared library (.dylib/.so/.dll). When set, uses crypt_shared instead of mongocryptd and sets cryptSharedLibRequired: true so mongocryptd is never spawned. Download from https://www.mongodb.com/try/download/enterprise |
45
+ | [config.encryption.mongocryptdURI] | <code>string</code> | URI of a remote mongocryptd process (e.g. Atlas-hosted). When set, the driver connects to this URI instead of spawning a local mongocryptd. Takes precedence over cryptSharedLibPath. |
44
46
 
45
47
  <a name="module_mongooser--module.exports..validate"></a>
46
48
 
@@ -80,9 +82,13 @@ Database initialization.
80
82
  **Kind**: inner method of [<code>module.exports</code>](#exp_module_mongooser--module.exports)
81
83
  **Returns**: <code>object</code> - The mongoose database object. Connection is established asynchronously in the background.
82
84
 
83
- When encryption is enabled, configures auto-encryption by setting `keyVaultNamespace` and `kmsProviders`
84
- on the mongoose connection options.
85
- Check MongoDB documentation for the full autoEncryption specification: https://docs.mongodb.com/manual/reference/method/Mongo/#clientsidefieldlevelencryptionoptions
85
+ When encryption is enabled, configures auto-encryption by setting `keyVaultNamespace`, `kmsProviders`,
86
+ and optionally `extraOptions.cryptSharedLibPath` on the mongoose connection options.
87
+ When `config.encryption.mongocryptdURI` is set, the driver connects to that remote mongocryptd (e.g. Atlas-hosted)
88
+ and bypasses local auto-spawn. When `config.encryption.cryptSharedLibPath` is set instead, `crypt_shared` is used
89
+ (no separate process required). `mongocryptdURI` takes precedence over `cryptSharedLibPath` if both are set.
90
+ Without either, the driver falls back to spawning `mongocryptd` at localhost:27020 (requires MongoDB Enterprise).
91
+ Note: `ClientEncryption` for explicit encryption should be imported from `mongodb`, not `mongodb-client-encryption`.
86
92
 
87
93
  Will exit 1 if the connection request generates an error or the connection state is `disconnected` or `disconnecting`.
88
94
  **Category**: sync
@@ -0,0 +1,25 @@
1
+ # bitbucket-pipelines.yml
2
+ image: node:24-alpine
3
+
4
+ pipelines:
5
+ branches:
6
+ develop:
7
+ - step:
8
+ name: Test package
9
+ runs-on:
10
+ - backend.services
11
+ script:
12
+ - npm install
13
+ - npm run lint
14
+ - npm run test
15
+ - step:
16
+ name: Build and Publish
17
+ runs-on:
18
+ - backend.services
19
+ trigger: 'manual'
20
+ script:
21
+ - npm install
22
+ - pipe: atlassian/npm-publish:1.1.1
23
+ variables:
24
+ NPM_TOKEN: $NPM_TOKEN
25
+ EXTRA_ARGS: "--access public"
package/index.js CHANGED
@@ -46,6 +46,8 @@ const MILLI_SEC = 1000;
46
46
  * @param {object} [config.encryption.aws] - AWS KMS provider settings.
47
47
  * @param {string} [config.encryption.database] - Database name for key vault.
48
48
  * @param {string} [config.encryption.keyVaultTable] - Collection name for key vault.
49
+ * @param {string} [config.encryption.cryptSharedLibPath] - Absolute path to the crypt_shared library (.dylib/.so/.dll). When set, uses crypt_shared instead of mongocryptd and sets cryptSharedLibRequired: true so mongocryptd is never spawned. Download from https://www.mongodb.com/try/download/enterprise
50
+ * @param {string} [config.encryption.mongocryptdURI] - URI of a remote mongocryptd process (e.g. Atlas-hosted). When set, the driver connects to this URI instead of spawning a local mongocryptd. Takes precedence over cryptSharedLibPath.
49
51
  * @return {object} Object with methods: initializeSync, validate, replicaSet, getKMSProviders.
50
52
  */
51
53
  export default (config) => {
@@ -88,9 +90,13 @@ export default (config) => {
88
90
  * @category sync
89
91
  * @return {object} The mongoose database object. Connection is established asynchronously in the background.
90
92
  *
91
- * When encryption is enabled, configures auto-encryption by setting `keyVaultNamespace` and `kmsProviders`
92
- * on the mongoose connection options.
93
- * Check MongoDB documentation for the full autoEncryption specification: https://docs.mongodb.com/manual/reference/method/Mongo/#clientsidefieldlevelencryptionoptions
93
+ * When encryption is enabled, configures auto-encryption by setting `keyVaultNamespace`, `kmsProviders`,
94
+ * and optionally `extraOptions.cryptSharedLibPath` on the mongoose connection options.
95
+ * When `config.encryption.mongocryptdURI` is set, the driver connects to that remote mongocryptd (e.g. Atlas-hosted)
96
+ * and bypasses local auto-spawn. When `config.encryption.cryptSharedLibPath` is set instead, `crypt_shared` is used
97
+ * (no separate process required). `mongocryptdURI` takes precedence over `cryptSharedLibPath` if both are set.
98
+ * Without either, the driver falls back to spawning `mongocryptd` at localhost:27020 (requires MongoDB Enterprise).
99
+ * Note: `ClientEncryption` for explicit encryption should be imported from `mongodb`, not `mongodb-client-encryption`.
94
100
  *
95
101
  * Will exit 1 if the connection request generates an error or the connection state is `disconnected` or `disconnecting`.
96
102
  */
@@ -102,6 +108,18 @@ export default (config) => {
102
108
  autoEncryption: {
103
109
  keyVaultNamespace: `${encryption.database}.${encryption.keyVaultTable}`,
104
110
  kmsProviders: getKMSProviders(),
111
+ ...(encryption.mongocryptdURI && {
112
+ extraOptions: {
113
+ mongocryptdURI: encryption.mongocryptdURI,
114
+ mongocryptdBypassSpawn: true,
115
+ },
116
+ }),
117
+ ...(!encryption.mongocryptdURI && encryption.cryptSharedLibPath && {
118
+ extraOptions: {
119
+ cryptSharedLibPath: encryption.cryptSharedLibPath,
120
+ cryptSharedLibRequired: true,
121
+ },
122
+ }),
105
123
  },
106
124
  }
107
125
  : options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/mongooser",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Helper for setting up mongodb using mongoose for mimik microservices",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -11,8 +11,8 @@
11
11
  "scripts": {
12
12
  "lint": "eslint . --no-error-on-unmatched-pattern",
13
13
  "docs": "jsdoc2md index.js > README.md",
14
- "test": "mocha --reporter mochawesome --bail --exit test/",
15
- "test-ci": "c8 --reporter=lcov --reporter=text npm test",
14
+ "test": "mocha",
15
+ "test-ci": "c8 npm test",
16
16
  "prepublishOnly": "npm run docs && npm run lint && npm run test-ci",
17
17
  "commit-ready": "npm run docs && npm run lint && npm run test-ci"
18
18
  },
@@ -27,25 +27,26 @@
27
27
  "url": "https://bitbucket.org/mimiktech/mongooser"
28
28
  },
29
29
  "dependencies": {
30
- "@mimik/lib-filters": "^2.0.8",
31
- "@mimik/request-helper": "^2.0.6",
32
- "@mimik/sumologic-winston-logger": "^2.2.2",
33
- "mongoose": "9.3.1"
30
+ "@mimik/lib-filters": "^2.0.9",
31
+ "@mimik/request-helper": "^2.0.7",
32
+ "@mimik/sumologic-winston-logger": "^2.2.4",
33
+ "mongoose": "9.6.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@eslint/js": "9.39.4",
37
- "@mimik/eslint-plugin-document-env": "^2.0.9",
38
- "@mimik/eslint-plugin-logger": "^1.0.3",
36
+ "@eslint/js": "10.0.1",
37
+ "@mimik/eslint-plugin-document-env": "^2.1.0",
38
+ "@mimik/eslint-plugin-logger": "^1.0.4",
39
39
  "@stylistic/eslint-plugin": "5.10.0",
40
40
  "c8": "11.0.0",
41
41
  "chai": "6.2.2",
42
- "eslint": "9.39.4",
43
- "eslint-plugin-import": "2.32.0",
44
- "esmock": "2.7.3",
45
- "globals": "17.4.0",
42
+ "eslint": "10.4.1",
43
+ "eslint-plugin-import-x": "4.16.2",
44
+ "esmock": "2.7.6",
45
+ "globals": "17.6.0",
46
46
  "husky": "9.1.7",
47
47
  "jsdoc-to-markdown": "9.1.3",
48
- "mocha": "11.7.5",
48
+ "mocha": "11.7.6",
49
49
  "mochawesome": "7.1.4"
50
- }
50
+ },
51
+ "packageManager": "pnpm@11.5.1+sha512.93f7b57422ea7068257235b4c16eb60762eb68e1dc23723199cc739043ea9be2c4143274a399d8c6defa2b1176226d9ca1c4b63482d6200c1a8fbaa78c1d1485"
51
52
  }