import { _encrypt } from './encrypt' ; import { CommitmentPolicy , ClientOptions , needs , } from '@aws-crypto/material-management-browser' ; 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 { encrypt : _encrypt . bind ( { } , clientOptions ) , } ; }