• 0
    • Not Needed
    • Not Needed

      Acceptance Criteria

      • Add support for two new options on ClientEncryptionOptions
        • the existing `algorithm` now has a new value, `RangePreview`
          • RangePreview must be marked as experimental
        • the existing `queryType` field has a new value, `rangePreview`
            • rangePreview must be marked as experimental
      • Add support for a new option, `RangeOptions`, on the `ClientEncryptionEncryptOptions` interface
        • a new option, `RangeOptions` is added.  the fields are defined in the specification
      • Enhance the NodeJS libmongocrypt bindings to support the `rangePreview` algorithm in MakeExplicitEncryptionContext 
      • Enhance MakeExplicitEncryptionContext to set the RangeOptions, if set
        • if the algorithm is `rangePreview` and there are range opts, call mongocrypt_ctx_setopt_algorithm
      • Enhance MakeExplicitEncryptionContext to take a new parameter option, `isExpression`
        • when set to true, MakeExplicitEncryptionContext calls mongocrypt_ctx_explicit_encrypt_expression_init
        • otherwise, call mongocrypt_ctx_explicit_encrypt_init (old behavior){}
      • refactor:
        • Move all ClientEncryption.encrypt() logic into a helper that uses async await.  Call this inside ClientEncryption.encrypt() wrapped inside of maybePromise.
        • rationale:
          • This work introduces a new helper for ClientEncryption that returns a document instead of a binary.  Our client encryption class makes no assumptions about the return type of `StateMachine.execute` and returns whatever raw result we get.  Our types, however, indicate that StateMachine.execute returns a Binary.  To reuse code in the new EncryptExpression helper, we can just call clientEncryption.encrypt().  However, this may be confusing to future developers because the return types of encrypt() and encryptExpression do not match.  Instead, I decided to move all the logic to a shared `_encrypt()` helper that uses async await, and to call this method in both locations.
      • Add a new helper on the ClientEncryption class that does the following
        • Accepts an aggregation expression or a match expression and EncryptOptions
        • Validates that the algorithm is RangePreview, the queryType is `rangePreview` and the `RangeOptions` argument is present
          • throws a TypeError if not present
        • serialize rangeOptions (it must be a binary when we pass it to MakeExplicitEncryptionContext)
        • serialize the expression document
        • calls _execute() with the expression and arguments.

      Testing Scenarios

      • ClientEncryption.encryptExpression()
        •  Test that errors are properly bubbled up from makeExplicitEncryptionContext
          • will test by calling encryptExpression with an invalid query types
        • test that errors are thrown if
          • algorithm is not 'RangePreview'
          • queryType is not 'RangeOptions'
          • rangeOptions is not present in the options object

      Notes

      • The new `encryptExpression` helper will not support callbacks.

      Open Questions

      • Will calling stateMachine.execute with an expression context automatically return a document instead of a binary? 
        • Kevin has confirmed yes, this is the case.

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: