import { _decryptStream } from './decrypt_stream' ; import { _decrypt } from './decrypt' ; import { CommitmentPolicy , needs , SignaturePolicy , ClientOptions , } from '@aws-crypto/material-management-node' ; type CurryFirst < fn extends ( ... a : any [ ] ) => any > = fn extends ( _ : any , ... tail : infer TAIL ) => any ? TAIL : never ; export function buildDecrypt ( 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 { decryptUnsignedMessageStream : _decryptStream . bind ( { } , { signaturePolicy : SignaturePolicy . ALLOW_ENCRYPT_FORBID_DECRYPT , clientOptions , } ) , decryptStream : _decryptStream . bind ( { } , { signaturePolicy : SignaturePolicy . ALLOW_ENCRYPT_ALLOW_DECRYPT , clientOptions , } ) , decrypt : _decrypt . bind ( { } , { signaturePolicy : SignaturePolicy . ALLOW_ENCRYPT_ALLOW_DECRYPT , clientOptions , } ) , } ; } const { decryptUnsignedMessageStream , decryptStream , decrypt } = buildDecrypt ( ) ; decryptUnsignedMessageStream ( { } as any ) ;