| 50 | raise ConfigurationError("MONGODB-AWS authentication requires MongoDB version 4.4 or later") |
| 51 | |
| 52 | class AwsSaslContext(pymongo_auth_aws.AwsSaslContext): # type: ignore |
| 53 | # Dependency injection: |
| 54 | def binary_type(self) -> Type[Binary]: |
| 55 | """Return the bson.binary.Binary type.""" |
| 56 | return Binary |
| 57 | |
| 58 | def bson_encode(self, doc: Mapping[str, Any]) -> bytes: |
| 59 | """Encode a dictionary to BSON.""" |
| 60 | return bson.encode(doc) |
| 61 | |
| 62 | def bson_decode(self, data: _ReadableBuffer) -> Mapping[str, Any]: |
| 63 | """Decode BSON to a dictionary.""" |
| 64 | return bson.decode(data) |
| 65 | |
| 66 | try: |
| 67 | ctx = AwsSaslContext( |