aws / aws-encryption-sdk-javascript

AWS Encryption SDK for Javascript and Node.js
Apache License 2.0
239 stars 65 forks source link

Return friendly error if input is Base64 encoded #630

Open lavaleri opened 3 years ago

lavaleri commented 3 years ago

Problem:

We have some code that intends to return a friendly error if the first byte is base64 encoded:

However we can't ever get inside those statements because we first do a check at: https://github.com/aws/aws-encryption-sdk-javascript/blob/43813f463ef6c53bd4de1963e7843b56733d1bec/modules/serialize/src/deserialize_factory.ts#L74

Solution:

Move the logic checking the expected first byte in Base64 before the branch that determines which version we're deserializing.

Out of scope:

n/a

gauthaman92 commented 1 year ago

Could you please share the updated logic