- 
    Type:
Investigation
 - 
    Resolution: Done
 - 
    Priority:
Major - P3
 - 
    Affects Version/s: None
 - 
    Component/s: None
 
- 
        Not Needed
 
Use Case
As a... node driver developer
I want... fle bindings javascript logic to live in the driver
So that... there is less code duplication and testing and releases require less work
User Impact
- Starting in driver 6.0.0 and mongodb-client-encryption 6.0.0, FLE logic will live in the driver instead of mongodb-client-encryption. If a user wishes to use FLE 6.0+, the user must
	
- install a 6.0+ driver
 - install mongodb-client-encryption 6.0+
 - import the Javascript FLE code from the driver, instead of `mongodb-client-encryption`
 
 
This is different from a pre-6.0 world, where the user was only required to install mongodb-client-encryption.
Dependencies
- N/A
 
Unknowns
- N/A
 
Open Questions
Do we want to generate documentation for mongodb-client-encryption after these changes? - No, see doc requirements
Acceptance Criteria
Implementation Requirements
- Add js bindings code to the driver
	
- [Subtask] Move JS logic and integrate into test suite 
		
- Add @aws-sdk/credential-providers and gcp-metadata as optional peer dependencies in the driver. Ensure that these dependencies are lazy loaded.
			
- If `socks` is not a peer optional dependency when doing this work, do nothing. If `socks` is a peer optional dependency in the driver, make sure `socks` is lazy-loaded into the FLE code that uses it.
 
 - Move tests from bindings/node/test to driver relevant test directories. Ensure tests pass against the local linked mongodb-client-encryption.
 - Export any code needed from the libmongocrypt bindings needed to get the tests passing in the driver (i.e., class MongoCrypt). A proper reworking of the bindings will come in a subsequent subtask but we need some restructuring here in order to run the driver's tests.
 - Add rough TS types for any changes to mongodb-client-encryption in deps.ts so that the driver can use it.
 
 - Add @aws-sdk/credential-providers and gcp-metadata as optional peer dependencies in the driver. Ensure that these dependencies are lazy loaded.
			
 - [Subtask] Clean up bindings in the driver
		
- Convert to TS when moving - fix duplicate types.
 - Unify constants between the repos.
 - Make MongoCryptErrors (and subclasses) subclasses of MongoError
 
 - Release a 6.x pre-release of mongodb-client-encryption for driver to use (note: we plan to bump mongodb-client-encryption to 6.x at the next major so it aligns with the driver’s and bson’s major versions)
 
 - [Subtask] Move JS logic and integrate into test suite 
		
 - [Subtask] Remove js bindings code from libmongocrypt
	
- Create unit tests in mongodb-client-encryption to test bindings only.
 - Cleanup driver evergreen tasks to no longer run the tests in mongodb-client-encryption.
 - Create public types for the bindings.
 - Cleanup unused dependencies from mongodb-client-encryption (@aws-sdk/credential-providers, gcp-metadata, socks, and mongodb)
 
 - [Subtask] Export new CSFLE types from the driver.
 - [Subtask] Add driver CI testing against the lowest supported peer dependency range version of the bindings alongside the latest version
 - [Subtask] Export javascript FLE logic from legacy mongodb package and setup driver testing with mongodb-legacy for all FLE logic.
 
Testing Requirements
- Unit tests if/as needed
 - CI test for lowest supported peer dependency range version (see above)
 
Documentation Requirements
The following changes are downstream docs changes (not driver API docs):
- Adjust FLE documentation for Node to install the driver and mongodb-client-encryption, instead of just mongodb-client-encryption.
 - Adjust existing FLE examples to import explicit encryption code from the driver, instead of from `mongodb-client-encryption`
	
- Coordinate with the docs team to ensure any example code is updated.
 
 - Add a note to mongodb-client-encryption readme stating that this package is not intended to be used in isolation and that we reserve the right to make changes that fall outside of semver
 - Adjust any internal documentation on generating docs and testing (in the driver and libmongocrypt) as necessary
 
Follow Up Requirements
- N/A
 
- depends on
 - 
                    
NODE-5283 Move js logic from mongodb-client-encryption to the driver
-         
 - Closed
 
 -