Przeglądaj źródła

Merge pull request #17034 from overleaf/dp-remove-access-token-encryptor-mongo-dependency

Remove mongodb dependency for libraries/access-token-encryptor

GitOrigin-RevId: 47241e200df6a9cba34d1effc6ef3203ea95a8a7
David 2 lat temu
rodzic
commit
19aaed64f8

+ 0 - 3
libraries/access-token-encryptor/package.json

@@ -21,9 +21,6 @@
   "dependencies": {
   "dependencies": {
     "lodash": "^4.17.21"
     "lodash": "^4.17.21"
   },
   },
-  "peerDependencies": {
-    "mongodb": "*"
-  },
   "devDependencies": {
   "devDependencies": {
     "chai": "^4.3.6",
     "chai": "^4.3.6",
     "mocha": "^10.2.0",
     "mocha": "^10.2.0",

+ 3 - 2
libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js

@@ -1,4 +1,3 @@
-const { ReadPreference } = require('mongodb')
 const _ = require('lodash')
 const _ = require('lodash')
 const { formatTokenUsageStats } = require('./format-usage-stats')
 const { formatTokenUsageStats } = require('./format-usage-stats')
 
 
@@ -26,12 +25,14 @@ async function reEncryptTokens(accessTokenEncryptor, encryptedJson) {
  * @param {AccessTokenEncryptor} accessTokenEncryptor
  * @param {AccessTokenEncryptor} accessTokenEncryptor
  * @param {Collection} collection
  * @param {Collection} collection
  * @param {Object} paths
  * @param {Object} paths
+ * @param {Object} queryOptions
  * @return {Promise<{}>}
  * @return {Promise<{}>}
  */
  */
 async function reEncryptTokensInCollection({
 async function reEncryptTokensInCollection({
   accessTokenEncryptor,
   accessTokenEncryptor,
   collection,
   collection,
   paths,
   paths,
+  queryOptions,
 }) {
 }) {
   const { collectionName } = collection
   const { collectionName } = collection
   const stats = {}
   const stats = {}
@@ -56,7 +57,7 @@ async function reEncryptTokensInCollection({
   const cursor = collection.find(
   const cursor = collection.find(
     {},
     {},
     {
     {
-      readPreference: ReadPreference.secondaryPreferred,
+      ...queryOptions,
       projection,
       projection,
     }
     }
   )
   )

+ 0 - 3
package-lock.json

@@ -90,9 +90,6 @@
         "mocha": "^10.2.0",
         "mocha": "^10.2.0",
         "sandboxed-module": "^2.0.4",
         "sandboxed-module": "^2.0.4",
         "typescript": "^5.0.4"
         "typescript": "^5.0.4"
-      },
-      "peerDependencies": {
-        "mongodb": "*"
       }
       }
     },
     },
     "libraries/eslint-plugin": {
     "libraries/eslint-plugin": {