libmongocrypt-helper 1.8.0.0.1001 → 1.11.0.0.1001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (385) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +33 -0
  3. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +12 -1
  4. data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +151 -3
  6. data/ext/libmongocrypt/libmongocrypt/README.md +36 -40
  7. data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +1 -0
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Driver.snk +0 -0
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +2 -2
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +16 -2
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +8 -4
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +10 -0
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +81 -44
  14. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +2 -1
  15. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +2 -0
  16. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +2 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +3 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +21 -26
  19. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.config +3 -0
  20. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +0 -0
  21. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/build.gradle.kts +28 -0
  22. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +217 -0
  23. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +24 -0
  24. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +21 -6
  25. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
  26. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +1 -1
  27. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +154 -108
  28. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +7 -18
  29. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +1 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +41 -6
  31. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +5 -5
  32. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +27 -1
  33. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +34 -19
  34. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +6 -4
  35. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +180 -0
  36. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +134 -0
  37. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +44 -2
  38. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +1 -1
  39. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -900
  41. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +60 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +41 -20
  43. data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +6 -24
  44. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +4 -13
  45. data/ext/libmongocrypt/libmongocrypt/bindings/python/hatch_build.py +36 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +1 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +2 -2
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/auto_encrypter.py +61 -0
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/credentials.py +156 -0
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +156 -0
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +149 -0
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +2 -46
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +14 -17
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +107 -61
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -4
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +2 -121
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +31 -20
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +2 -2
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +2 -233
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +168 -238
  61. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +265 -0
  62. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +2 -141
  63. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/auto_encrypter.py +61 -0
  64. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/credentials.py +156 -0
  65. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +156 -0
  66. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +149 -0
  67. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  68. data/ext/libmongocrypt/libmongocrypt/bindings/python/pyproject.toml +118 -0
  69. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +97 -61
  70. data/ext/libmongocrypt/libmongocrypt/bindings/python/{test-requirements.txt → requirements-test.txt} +4 -1
  71. data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements.txt +4 -0
  72. data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +76 -0
  73. data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +6 -7
  74. data/ext/libmongocrypt/libmongocrypt/bindings/python/synchro.py +64 -0
  75. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -0
  76. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +1 -1
  77. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +1 -1
  78. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +21 -21
  79. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +1 -1
  80. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +1 -1
  81. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +1 -1
  82. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
  83. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/rangeopts.json +11 -0
  84. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/value-to-encrypt.json +20 -0
  85. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +1 -1
  86. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +1 -1
  87. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +1 -1
  88. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +1 -1
  89. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +1 -1
  90. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +1 -1
  91. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +1 -1
  92. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +1 -1
  93. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/keyDocument.json +24 -0
  94. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/perf_test.py +165 -0
  95. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +8 -12
  96. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +9 -11
  97. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +988 -340
  98. data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +14 -0
  99. data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +19 -1
  100. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +23 -0
  101. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +19 -227
  102. data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -0
  103. data/ext/libmongocrypt/libmongocrypt/doc/img/cli-icon.png +0 -0
  104. data/ext/libmongocrypt/libmongocrypt/doc/img/reference-targets.png +0 -0
  105. data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +153 -0
  106. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +61 -28
  107. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +73 -0
  108. data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +108 -0
  109. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +1 -1
  110. data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +27 -0
  111. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-alpine-arm-fix.patch +17 -0
  112. data/ext/libmongocrypt/libmongocrypt/etc/packager.py +120 -91
  113. data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +14 -0
  114. data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +56 -0
  115. data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +70 -0
  116. data/ext/libmongocrypt/libmongocrypt/etc/ssdlc_compliance_report.md +37 -0
  117. data/ext/libmongocrypt/libmongocrypt/etc/third_party_vulnerabilities.md +42 -0
  118. data/ext/libmongocrypt/libmongocrypt/integrating.md +18 -1
  119. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +11 -3
  120. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
  121. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +17 -0
  122. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +6 -0
  123. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +211 -1
  124. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +163 -0
  125. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +2 -1
  126. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +17 -0
  127. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +6 -0
  128. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +3 -2
  129. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -2
  130. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -2
  131. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +23 -2
  132. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +13 -10
  133. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +1 -1
  134. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +16 -2
  135. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +94 -6
  136. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +15 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +114 -53
  138. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +1 -1
  139. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +1 -1
  140. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +2 -2
  141. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +2 -2
  142. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +21 -6
  143. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +5 -5
  144. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +38 -2
  145. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +1 -1
  146. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +20 -7
  147. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +8 -8
  148. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +89 -1
  149. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +3 -3
  150. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +1 -23
  151. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +4 -3
  152. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +15 -12
  153. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +11 -0
  154. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +16 -6
  155. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +64 -22
  156. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +23 -4
  157. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +359 -65
  158. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +26 -14
  159. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +17 -6
  160. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +31 -13
  161. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +16 -3
  162. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +259 -63
  163. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +40 -24
  164. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +57 -13
  165. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +17 -0
  166. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +5 -0
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +0 -5
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +5 -7
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +1 -0
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -18
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +105 -76
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +9 -3
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +170 -89
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +5 -5
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +505 -124
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +31 -6
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +81 -13
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +7 -0
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +5 -1
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +161 -103
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +2 -7
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +191 -69
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +1 -1
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +50 -15
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +365 -69
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +2 -1
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +200 -107
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +50 -5
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +591 -15
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +6 -13
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +3 -2
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +47 -234
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +75 -24
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +18 -2
  195. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +4 -0
  196. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/bypassQueryAnalysis/payload.json +53 -0
  197. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd-to-mongocryptd.json +23 -0
  198. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +20 -0
  199. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd-to-mongocryptd.json +50 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd.json +20 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/collinfo.json +44 -0
  202. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-field-map.json +24 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-payload-pattern.json +53 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/mongocryptd-reply.json +62 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd-to-mongocryptd.json +30 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd.json +17 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/mongocryptd-reply.json +39 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +21 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +20 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +9 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/encrypted-payload.json +4 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/cmd.json +1 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +63 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-field-config-map.json +61 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload-range-v2.json +37 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +29 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/cmd.json +1 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +64 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +105 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload.json +30 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/cmd.json +1 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +47 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-payload.json +23 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +15 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +10 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +104 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +6 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +4 -4
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +3 -3
  231. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/decrypt-response.txt +16 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/encrypt-response.txt +16 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/oauth-response.txt +19 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/cmd.json +9 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-field-map.json +19 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-payload.json +62 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/mongocryptd-reply.json +69 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/cmd.json +11 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-field-map.json +19 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-payload.json +40 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/mongocryptd-reply.json +47 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +1 -1
  243. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +8637 -7958
  244. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +5522 -1382
  245. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +5042 -1262
  246. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +1 -1
  247. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +1 -1
  248. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +1 -1
  249. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +2 -2
  250. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +1 -1
  251. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +1 -1
  252. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/cmd.json +8 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-field-map.json +19 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/mongocryptd-reply.json +58 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/cmd.json +11 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-field-map.json +19 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-payload.json +40 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/mongocryptd-reply.json +45 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/expected.json +26 -0
  261. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/to-encrypt.json +20 -0
  262. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/expected.json +26 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/to-encrypt.json +20 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-double/expected.json +8 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32/expected.json +8 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32-defaults/expected.json +8 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +7 -4
  268. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +9 -5
  269. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +9 -5
  270. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +1 -0
  271. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +8 -8
  272. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +6 -4
  273. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +43 -3
  274. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +76 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +5 -5
  276. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +89 -14
  277. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +342 -76
  278. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +94 -12
  279. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +205 -7
  280. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +49 -23
  281. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +16 -19
  282. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -1
  283. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +94 -11
  284. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +374 -0
  285. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +121 -42
  286. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +134 -4
  287. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +40 -0
  288. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +16 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +11 -11
  290. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +8 -5
  291. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +922 -92
  292. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +2 -2
  293. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +114 -12
  294. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +14 -9
  295. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +424 -3
  296. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +1 -1
  297. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +447 -28
  298. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +30 -26
  300. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +7 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +3 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +66 -14
  303. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +11 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +2381 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +3 -1
  306. data/ext/libmongocrypt/libmongocrypt/test/util/README.md +1 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +4 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
  309. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +38 -3
  310. data/lib/libmongocrypt_helper/version.rb +2 -2
  311. metadata +112 -106
  312. checksums.yaml.gz.sig +0 -0
  313. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
  314. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +0 -79
  315. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +0 -105
  316. data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +0 -201
  317. data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +0 -79
  318. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +0 -44
  319. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +0 -36
  320. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -641
  321. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +0 -420
  322. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +0 -123
  323. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +0 -821
  324. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -98
  325. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
  326. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +0 -75
  327. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -73
  328. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
  329. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +0 -26
  330. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +0 -178
  331. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +0 -24
  332. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +0 -54
  333. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +0 -39
  334. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -492
  335. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -15302
  336. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -100
  337. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -956
  338. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
  339. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -950
  340. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
  341. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -1093
  342. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +0 -94
  343. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -240
  344. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +0 -5
  345. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +0 -6
  346. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +0 -37
  347. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +0 -8
  348. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +0 -11
  349. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +0 -30
  350. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +0 -32
  351. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +0 -30
  352. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +0 -18
  353. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +0 -45
  354. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
  355. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +0 -551
  356. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -66
  357. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -51
  358. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
  359. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +0 -8
  360. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
  361. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +0 -63
  362. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -89
  363. data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +0 -79
  364. data/ext/libmongocrypt/libmongocrypt/debian/changelog +0 -105
  365. data/ext/libmongocrypt/libmongocrypt/debian/compat +0 -1
  366. data/ext/libmongocrypt/libmongocrypt/debian/control +0 -41
  367. data/ext/libmongocrypt/libmongocrypt/debian/copyright +0 -129
  368. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +0 -23
  369. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +0 -2
  370. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +0 -5
  371. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +0 -1
  372. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +0 -1
  373. data/ext/libmongocrypt/libmongocrypt/debian/rules +0 -46
  374. data/ext/libmongocrypt/libmongocrypt/debian/source/format +0 -1
  375. data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +0 -3
  376. data/ext/libmongocrypt/libmongocrypt/debian/source/options +0 -1
  377. data/ext/libmongocrypt/libmongocrypt/debian/watch +0 -3
  378. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +0 -72
  379. data.tar.gz.sig +0 -1
  380. metadata.gz.sig +0 -0
  381. /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-decrypt-reply.txt → test/data/kms-aws/decrypt-response.txt} +0 -0
  382. /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-encrypt-reply.txt → test/data/kms-aws/encrypt-response.txt} +0 -0
  383. /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/decrypt-response.txt +0 -0
  384. /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/encrypt-response.txt +0 -0
  385. /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/oauth-response.txt +0 -0
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- const { MongoCryptKMSRequestNetworkTimeoutError } = require('../errors');
4
- const http = require('http');
5
-
6
- /**
7
- * @param {URL | string} url
8
- * @param {http.RequestOptions} options
9
- *
10
- * @returns { Promise<{ body: string, status: number }> }
11
- * @ignore
12
- */
13
- function get(url, options = {}) {
14
- return new Promise((resolve, reject) => {
15
- let timeoutId;
16
- const request = http
17
- .get(url, options, response => {
18
- response.setEncoding('utf8');
19
- let body = '';
20
- response.on('data', chunk => (body += chunk));
21
- response.on('end', () => {
22
- clearTimeout(timeoutId);
23
- resolve({ status: response.statusCode, body });
24
- });
25
- })
26
- .on('error', error => {
27
- clearTimeout(timeoutId);
28
- reject(error);
29
- })
30
- .end();
31
- timeoutId = setTimeout(() => {
32
- request.destroy(
33
- new MongoCryptKMSRequestNetworkTimeoutError(`request timed out after 10 seconds`)
34
- );
35
- }, 10000);
36
- });
37
- }
38
-
39
- module.exports = { get };
@@ -1,492 +0,0 @@
1
- 'use strict';
2
-
3
- const { promisify } = require('util');
4
-
5
- module.exports = function (modules) {
6
- const tls = require('tls');
7
- const net = require('net');
8
- const fs = require('fs');
9
- const { once } = require('events');
10
- const { SocksClient } = require('socks');
11
-
12
- // Try first to import 4.x name, fallback to 3.x name
13
- const MongoNetworkTimeoutError =
14
- modules.mongodb.MongoNetworkTimeoutError || modules.mongodb.MongoTimeoutError;
15
-
16
- const common = require('./common');
17
- const debug = common.debug;
18
- const databaseNamespace = common.databaseNamespace;
19
- const collectionNamespace = common.collectionNamespace;
20
- const { MongoCryptError } = require('./errors');
21
- const { BufferPool } = require('./buffer_pool');
22
-
23
- // libmongocrypt states
24
- const MONGOCRYPT_CTX_ERROR = 0;
25
- const MONGOCRYPT_CTX_NEED_MONGO_COLLINFO = 1;
26
- const MONGOCRYPT_CTX_NEED_MONGO_MARKINGS = 2;
27
- const MONGOCRYPT_CTX_NEED_MONGO_KEYS = 3;
28
- const MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS = 7;
29
- const MONGOCRYPT_CTX_NEED_KMS = 4;
30
- const MONGOCRYPT_CTX_READY = 5;
31
- const MONGOCRYPT_CTX_DONE = 6;
32
-
33
- const HTTPS_PORT = 443;
34
-
35
- const stateToString = new Map([
36
- [MONGOCRYPT_CTX_ERROR, 'MONGOCRYPT_CTX_ERROR'],
37
- [MONGOCRYPT_CTX_NEED_MONGO_COLLINFO, 'MONGOCRYPT_CTX_NEED_MONGO_COLLINFO'],
38
- [MONGOCRYPT_CTX_NEED_MONGO_MARKINGS, 'MONGOCRYPT_CTX_NEED_MONGO_MARKINGS'],
39
- [MONGOCRYPT_CTX_NEED_MONGO_KEYS, 'MONGOCRYPT_CTX_NEED_MONGO_KEYS'],
40
- [MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS, 'MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS'],
41
- [MONGOCRYPT_CTX_NEED_KMS, 'MONGOCRYPT_CTX_NEED_KMS'],
42
- [MONGOCRYPT_CTX_READY, 'MONGOCRYPT_CTX_READY'],
43
- [MONGOCRYPT_CTX_DONE, 'MONGOCRYPT_CTX_DONE']
44
- ]);
45
-
46
- const INSECURE_TLS_OPTIONS = [
47
- 'tlsInsecure',
48
- 'tlsAllowInvalidCertificates',
49
- 'tlsAllowInvalidHostnames',
50
- 'tlsDisableOCSPEndpointCheck',
51
- 'tlsDisableCertificateRevocationCheck'
52
- ];
53
-
54
- /**
55
- * @ignore
56
- * @callback StateMachine~executeCallback
57
- * @param {Error} [err] If present, indicates that the execute call failed with the given error
58
- * @param {object} [result] If present, is the result of executing the state machine.
59
- * @returns {void}
60
- */
61
-
62
- /**
63
- * @ignore
64
- * @callback StateMachine~fetchCollectionInfoCallback
65
- * @param {Error} [err] If present, indicates that fetching the collection info failed with the given error
66
- * @param {object} [result] If present, is the fetched collection info for the first collection to match the given filter
67
- * @returns {void}
68
- */
69
-
70
- /**
71
- * @ignore
72
- * @callback StateMachine~markCommandCallback
73
- * @param {Error} [err] If present, indicates that marking the command failed with the given error
74
- * @param {Buffer} [result] If present, is the marked command serialized into bson
75
- * @returns {void}
76
- */
77
-
78
- /**
79
- * @ignore
80
- * @callback StateMachine~fetchKeysCallback
81
- * @param {Error} [err] If present, indicates that fetching the keys failed with the given error
82
- * @param {object[]} [result] If present, is all the keys from the keyVault collection that matched the given filter
83
- */
84
-
85
- /**
86
- * @ignore
87
- * An internal class that executes across a MongoCryptContext until either
88
- * a finishing state or an error is reached. Do not instantiate directly.
89
- * @class StateMachine
90
- */
91
- class StateMachine {
92
- constructor(options) {
93
- this.options = options || {};
94
- this.bson = options.bson;
95
-
96
- this.executeAsync = promisify((autoEncrypter, context, callback) =>
97
- this.execute(autoEncrypter, context, callback)
98
- );
99
- }
100
-
101
- /**
102
- * @ignore
103
- * Executes the state machine according to the specification
104
- * @param {AutoEncrypter|ClientEncryption} autoEncrypter The JS encryption object
105
- * @param {object} context The C++ context object returned from the bindings
106
- * @param {StateMachine~executeCallback} callback Invoked with the result/error of executing the state machine
107
- * @returns {void}
108
- */
109
- execute(autoEncrypter, context, callback) {
110
- const bson = this.bson;
111
- const keyVaultNamespace = autoEncrypter._keyVaultNamespace;
112
- const keyVaultClient = autoEncrypter._keyVaultClient;
113
- const metaDataClient = autoEncrypter._metaDataClient;
114
- const mongocryptdClient = autoEncrypter._mongocryptdClient;
115
- const mongocryptdManager = autoEncrypter._mongocryptdManager;
116
-
117
- debug(`[context#${context.id}] ${stateToString.get(context.state) || context.state}`);
118
- switch (context.state) {
119
- case MONGOCRYPT_CTX_NEED_MONGO_COLLINFO: {
120
- const filter = bson.deserialize(context.nextMongoOperation());
121
- this.fetchCollectionInfo(metaDataClient, context.ns, filter, (err, collInfo) => {
122
- if (err) {
123
- return callback(err, null);
124
- }
125
-
126
- if (collInfo) {
127
- context.addMongoOperationResponse(collInfo);
128
- }
129
-
130
- context.finishMongoOperation();
131
- this.execute(autoEncrypter, context, callback);
132
- });
133
-
134
- return;
135
- }
136
-
137
- case MONGOCRYPT_CTX_NEED_MONGO_MARKINGS: {
138
- const command = context.nextMongoOperation();
139
- this.markCommand(mongocryptdClient, context.ns, command, (err, markedCommand) => {
140
- if (err) {
141
- // If we are not bypassing spawning, then we should retry once on a MongoTimeoutError (server selection error)
142
- if (
143
- err instanceof MongoNetworkTimeoutError &&
144
- mongocryptdManager &&
145
- !mongocryptdManager.bypassSpawn
146
- ) {
147
- mongocryptdManager.spawn(() => {
148
- // TODO: should we be shadowing the variables here?
149
- this.markCommand(mongocryptdClient, context.ns, command, (err, markedCommand) => {
150
- if (err) return callback(err, null);
151
-
152
- context.addMongoOperationResponse(markedCommand);
153
- context.finishMongoOperation();
154
-
155
- this.execute(autoEncrypter, context, callback);
156
- });
157
- });
158
- return;
159
- }
160
- return callback(err, null);
161
- }
162
- context.addMongoOperationResponse(markedCommand);
163
- context.finishMongoOperation();
164
-
165
- this.execute(autoEncrypter, context, callback);
166
- });
167
-
168
- return;
169
- }
170
-
171
- case MONGOCRYPT_CTX_NEED_MONGO_KEYS: {
172
- const filter = context.nextMongoOperation();
173
- this.fetchKeys(keyVaultClient, keyVaultNamespace, filter, (err, keys) => {
174
- if (err) return callback(err, null);
175
- keys.forEach(key => {
176
- context.addMongoOperationResponse(bson.serialize(key));
177
- });
178
-
179
- context.finishMongoOperation();
180
- this.execute(autoEncrypter, context, callback);
181
- });
182
-
183
- return;
184
- }
185
-
186
- case MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS: {
187
- autoEncrypter
188
- .askForKMSCredentials()
189
- .then(kmsProviders => {
190
- context.provideKMSProviders(
191
- !Buffer.isBuffer(kmsProviders) ? bson.serialize(kmsProviders) : kmsProviders
192
- );
193
- this.execute(autoEncrypter, context, callback);
194
- })
195
- .catch(err => {
196
- callback(err, null);
197
- });
198
-
199
- return;
200
- }
201
-
202
- case MONGOCRYPT_CTX_NEED_KMS: {
203
- const promises = [];
204
-
205
- let request;
206
- while ((request = context.nextKMSRequest())) {
207
- promises.push(this.kmsRequest(request));
208
- }
209
-
210
- Promise.all(promises)
211
- .then(() => {
212
- context.finishKMSRequests();
213
- this.execute(autoEncrypter, context, callback);
214
- })
215
- .catch(err => {
216
- callback(err, null);
217
- });
218
-
219
- return;
220
- }
221
-
222
- // terminal states
223
- case MONGOCRYPT_CTX_READY: {
224
- const finalizedContext = context.finalize();
225
- // TODO: Maybe rework the logic here so that instead of doing
226
- // the callback here, finalize stores the result, and then
227
- // we wait to MONGOCRYPT_CTX_DONE to do the callback
228
- if (context.state === MONGOCRYPT_CTX_ERROR) {
229
- const message = context.status.message || 'Finalization error';
230
- callback(new MongoCryptError(message));
231
- return;
232
- }
233
- callback(null, bson.deserialize(finalizedContext, this.options));
234
- return;
235
- }
236
- case MONGOCRYPT_CTX_ERROR: {
237
- const message = context.status.message;
238
- callback(new MongoCryptError(message));
239
- return;
240
- }
241
-
242
- case MONGOCRYPT_CTX_DONE:
243
- callback();
244
- return;
245
-
246
- default:
247
- callback(new MongoCryptError(`Unknown state: ${context.state}`));
248
- return;
249
- }
250
- }
251
-
252
- /**
253
- * @ignore
254
- * Handles the request to the KMS service. Exposed for testing purposes. Do not directly invoke.
255
- * @param {*} kmsContext A C++ KMS context returned from the bindings
256
- * @returns {Promise<void>} A promise that resolves when the KMS reply has be fully parsed
257
- */
258
- kmsRequest(request) {
259
- const parsedUrl = request.endpoint.split(':');
260
- const port = parsedUrl[1] != null ? Number.parseInt(parsedUrl[1], 10) : HTTPS_PORT;
261
- const options = { host: parsedUrl[0], servername: parsedUrl[0], port };
262
- const message = request.message;
263
-
264
- // TODO(NODE-3959): We can adopt `for-await on(socket, 'data')` with logic to control abort
265
- // eslint-disable-next-line no-async-promise-executor
266
- return new Promise(async (resolve, reject) => {
267
- const buffer = new BufferPool();
268
-
269
- let socket;
270
- let rawSocket;
271
-
272
- function destroySockets() {
273
- for (const sock of [socket, rawSocket]) {
274
- if (sock) {
275
- sock.removeAllListeners();
276
- sock.destroy();
277
- }
278
- }
279
- }
280
-
281
- function ontimeout() {
282
- destroySockets();
283
- reject(new MongoCryptError('KMS request timed out'));
284
- }
285
-
286
- function onerror(err) {
287
- destroySockets();
288
- const mcError = new MongoCryptError('KMS request failed');
289
- mcError.originalError = err;
290
- reject(mcError);
291
- }
292
-
293
- if (this.options.proxyOptions && this.options.proxyOptions.proxyHost) {
294
- rawSocket = net.connect({
295
- host: this.options.proxyOptions.proxyHost,
296
- port: this.options.proxyOptions.proxyPort || 1080
297
- });
298
-
299
- rawSocket.on('timeout', ontimeout);
300
- rawSocket.on('error', onerror);
301
- try {
302
- await once(rawSocket, 'connect');
303
- options.socket = (
304
- await SocksClient.createConnection({
305
- existing_socket: rawSocket,
306
- command: 'connect',
307
- destination: { host: options.host, port: options.port },
308
- proxy: {
309
- // host and port are ignored because we pass existing_socket
310
- host: 'iLoveJavaScript',
311
- port: 0,
312
- type: 5,
313
- userId: this.options.proxyOptions.proxyUsername,
314
- password: this.options.proxyOptions.proxyPassword
315
- }
316
- })
317
- ).socket;
318
- } catch (err) {
319
- return onerror(err);
320
- }
321
- }
322
-
323
- const tlsOptions = this.options.tlsOptions;
324
- if (tlsOptions) {
325
- const kmsProvider = request.kmsProvider;
326
- const providerTlsOptions = tlsOptions[kmsProvider];
327
- if (providerTlsOptions) {
328
- const error = this.validateTlsOptions(kmsProvider, providerTlsOptions);
329
- if (error) reject(error);
330
- this.setTlsOptions(providerTlsOptions, options);
331
- }
332
- }
333
- socket = tls.connect(options, () => {
334
- socket.write(message);
335
- });
336
-
337
- socket.once('timeout', ontimeout);
338
- socket.once('error', onerror);
339
-
340
- socket.on('data', data => {
341
- buffer.append(data);
342
- while (request.bytesNeeded > 0 && buffer.length) {
343
- const bytesNeeded = Math.min(request.bytesNeeded, buffer.length);
344
- request.addResponse(buffer.read(bytesNeeded));
345
- }
346
-
347
- if (request.bytesNeeded <= 0) {
348
- // There's no need for any more activity on this socket at this point.
349
- destroySockets();
350
- resolve();
351
- }
352
- });
353
- });
354
- }
355
-
356
- /**
357
- * @ignore
358
- * Validates the provided TLS options are secure.
359
- *
360
- * @param {string} kmsProvider The KMS provider name.
361
- * @param {ClientEncryptionTLSOptions} tlsOptions The client TLS options for the provider.
362
- *
363
- * @returns {Error} If any option is invalid.
364
- */
365
- validateTlsOptions(kmsProvider, tlsOptions) {
366
- const tlsOptionNames = Object.keys(tlsOptions);
367
- for (const option of INSECURE_TLS_OPTIONS) {
368
- if (tlsOptionNames.includes(option)) {
369
- return new MongoCryptError(
370
- `Insecure TLS options prohibited for ${kmsProvider}: ${option}`
371
- );
372
- }
373
- }
374
- }
375
-
376
- /**
377
- * @ignore
378
- * Sets only the valid secure TLS options.
379
- *
380
- * @param {ClientEncryptionTLSOptions} tlsOptions The client TLS options for the provider.
381
- * @param {Object} options The existing connection options.
382
- */
383
- setTlsOptions(tlsOptions, options) {
384
- if (tlsOptions.tlsCertificateKeyFile) {
385
- const cert = fs.readFileSync(tlsOptions.tlsCertificateKeyFile);
386
- options.cert = options.key = cert;
387
- }
388
- if (tlsOptions.tlsCAFile) {
389
- options.ca = fs.readFileSync(tlsOptions.tlsCAFile);
390
- }
391
- if (tlsOptions.tlsCertificateKeyFilePassword) {
392
- options.passphrase = tlsOptions.tlsCertificateKeyFilePassword;
393
- }
394
- }
395
-
396
- /**
397
- * @ignore
398
- * Fetches collection info for a provided namespace, when libmongocrypt
399
- * enters the `MONGOCRYPT_CTX_NEED_MONGO_COLLINFO` state. The result is
400
- * used to inform libmongocrypt of the schema associated with this
401
- * namespace. Exposed for testing purposes. Do not directly invoke.
402
- *
403
- * @param {MongoClient} client A MongoClient connected to the topology
404
- * @param {string} ns The namespace to list collections from
405
- * @param {object} filter A filter for the listCollections command
406
- * @param {StateMachine~fetchCollectionInfoCallback} callback Invoked with the info of the requested collection, or with an error
407
- */
408
- fetchCollectionInfo(client, ns, filter, callback) {
409
- const bson = this.bson;
410
- const dbName = databaseNamespace(ns);
411
-
412
- client
413
- .db(dbName)
414
- .listCollections(filter, {
415
- promoteLongs: false,
416
- promoteValues: false
417
- })
418
- .toArray()
419
- .then(
420
- collections => {
421
- const info = collections.length > 0 ? bson.serialize(collections[0]) : null;
422
- return callback(null, info);
423
- },
424
- err => {
425
- callback(err, null);
426
- }
427
- );
428
- }
429
-
430
- /**
431
- * @ignore
432
- * Calls to the mongocryptd to provide markings for a command.
433
- * Exposed for testing purposes. Do not directly invoke.
434
- * @param {MongoClient} client A MongoClient connected to a mongocryptd
435
- * @param {string} ns The namespace (database.collection) the command is being executed on
436
- * @param {object} command The command to execute.
437
- * @param {StateMachine~markCommandCallback} callback Invoked with the serialized and marked bson command, or with an error
438
- * @returns {void}
439
- */
440
- markCommand(client, ns, command, callback) {
441
- const bson = this.bson;
442
- const options = { promoteLongs: false, promoteValues: false };
443
- const dbName = databaseNamespace(ns);
444
- const rawCommand = bson.deserialize(command, options);
445
-
446
- client
447
- .db(dbName)
448
- .command(rawCommand, options)
449
- .then(
450
- response => {
451
- return callback(null, bson.serialize(response, this.options));
452
- },
453
- err => {
454
- callback(err, null);
455
- }
456
- );
457
- }
458
-
459
- /**
460
- * @ignore
461
- * Requests keys from the keyVault collection on the topology.
462
- * Exposed for testing purposes. Do not directly invoke.
463
- * @param {MongoClient} client A MongoClient connected to the topology
464
- * @param {string} keyVaultNamespace The namespace (database.collection) of the keyVault Collection
465
- * @param {object} filter The filter for the find query against the keyVault Collection
466
- * @param {StateMachine~fetchKeysCallback} callback Invoked with the found keys, or with an error
467
- * @returns {void}
468
- */
469
- fetchKeys(client, keyVaultNamespace, filter, callback) {
470
- const bson = this.bson;
471
- const dbName = databaseNamespace(keyVaultNamespace);
472
- const collectionName = collectionNamespace(keyVaultNamespace);
473
- filter = bson.deserialize(filter);
474
-
475
- client
476
- .db(dbName)
477
- .collection(collectionName, { readConcern: { level: 'majority' } })
478
- .find(filter)
479
- .toArray()
480
- .then(
481
- keys => {
482
- return callback(null, keys);
483
- },
484
- err => {
485
- callback(err, null);
486
- }
487
- );
488
- }
489
- }
490
-
491
- return { StateMachine };
492
- };