import { _encryptStream } from './encrypt_stream' ; import { _encrypt } from './encrypt' ; import { CommitmentPolicy , ClientOptions , needs , } from '@aws-crypto/material-management-node' ; type CurryFirst < fn extends ( ... a : any [ ] ) => any > = fn extends ( _ : any , ... tail : infer TAIL ) => any ? TAIL : [ ] ; export function buildEncrypt ( options = { } ) { const { commitmentPolicy = CommitmentPolicy . REQUIRE_ENCRYPT_REQUIRE_DECRYPT , maxEncryptedDataKeys = false , } = typeof options === 'string' ? { commitmentPolicy : options } : options ; needs ( CommitmentPolicy [ commitmentPolicy ] , 'Invalid commitment policy.' ) ; needs ( maxEncryptedDataKeys === false || maxEncryptedDataKeys >= 1 , 'Invalid maxEncryptedDataKeys value.' ) ; const clientOptions = { commitmentPolicy , maxEncryptedDataKeys , } ; return { encryptStream : _encryptStream . bind ( { } , clientOptions ) , encrypt : _encrypt . bind ( { } , clientOptions ) , } ; }