Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@aws-crypto/client-browser Buffer usage in raw2der causing ReferenceError when decrypting #1050

Open
hunterabraham opened this issue Nov 7, 2022 · 3 comments

Comments

@hunterabraham
Copy link

Problem:

When using @aws-crypto/client-browser version 3.1.1, calling decrypt() will result in a ReferenceError. decrypt calls raw2der, which includes a reference to global Buffer type. The buffer npm package is not listed as a dependency in the package.json.

Solution:

Either decouple the browser and node ecdsa_signature.ts helpers and use a Uint8Array instance instead of Buffer or add the buffer dependency to the package.

@hunterabraham hunterabraham changed the title @aws-crypto/client-browser Buffer usage in raw2der @aws-crypto/client-browser Buffer usage in raw2der causing ReferenceError when decrypting Nov 7, 2022
@lavaleri
Copy link
Contributor

Hi @hunterabraham,

We have some examples of doing this in https://github.com/aws/aws-encryption-sdk-javascript/tree/master/modules/example-browser. Can you tell us how you are packaging your code for the browser so that we can repro and fix this?

@hunterabraham
Copy link
Author

hunterabraham commented Nov 17, 2022

Thanks for getting back to me, @lavaleri. We are using yarn for package management in our React app. This error occurs when I'm building locally using yarn run start. I have the following version in my package.json "@aws-crypto/client-browser": "^3.1.1". Our implementation is very simple encryption mirroring the kms_simple.ts example in the example repo.

@texastony
Copy link
Contributor

@hunterabraham

The AWS Encryption SDK for Java Script (ESDK-JS) is not built for nor tested in a React Native environment.
The issue you are bumping into maybe fixed by your proposed solution,
but I fear that it is the tip of the iceberg.

A challenge with React Native is supplying the Cryptographic Primitives.
Are you using msrCrypto for the primitives or another library?

Can you share a repository that uses the ESDK-JS in a React Native application?
(Ideally, something bare bones, and with this issue).
If you could share something for us to work from, we could move this issue forward faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants