-
Notifications
You must be signed in to change notification settings - Fork 64
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
JavaScript instanceOf and different versions of the underlying Encryption SDK modules. #126
Comments
This is blocking me from adding the @awslabs/node-client module to my node application. Tracing down failures it seems like instanceOf checks in "needs(...." functions are failing. |
Are you using jest? Can you give me a little more detail about how you are trying to use the client? |
Hi! All I have to do is add the library to my existing node project, then just copy/pasting the kms simple example from the examples for node fails. If I check out this repo, it works The only difference seems to be other packages, and since it fails complaining about instanceOf checks on KMS responses, I figure it has to be this bug. For now, to be honest I have to give up on making this SDK work. Isolating which other package in my project is affecting this one would be too time consuming. |
Is your existing project a public repo? Can you point me to a simple way to reproduce your issue?
|
Any word on this? This appears to be happening to me as well. I'm passing a string to encrypt and getting an If I'm following the code correctly, when I pass a string, the lib turns it into a Buffer which should make this condition (https://github.com/aws/aws-encryption-sdk-javascript/blob/master/modules/encrypt-node/src/encrypt.ts#L45) be true, a Buffer is an instance of Uint8Array. However I get the error on line 50 anyway. I'm not exactly sure how to figure out what is causing this, and unfortunately my project is not public :( I can try to repro it in a sample type project, but hopefully I can get some insight before I go that far |
@dotDeeka I'm not sure how this is an My guess would be that it is not falling into the this https://github.com/aws/aws-encryption-sdk-javascript/blob/master/modules/encrypt-node/src/encrypt.ts#L33. Why not try changing the argument to a Buffer before passing it to the encrypt function? |
The issue appears to be related to Jest. There are some details listed in this issue in the Jest repo jestjs/jest#4422 |
Yes the issue you are having is with jest, you can see what node has to say about it here: nodejs/node#20978 (comment) And this jestjs/jest#7780 (comment) may help with injecting the globals into jest. |
@seebees I opened the issue aws-amplify/amplify-js#6552 ~3weeks ago. Today after digging into |
Hi, I ran across this issue and have some additional details to add, as well as a potential fix. We have a monorepo with many different packages owned by different teams, that depend on different node modules (and different versions of the same node modules). In this case, most of our packages were using an old version of The error is the same as reported here #638 that couldn't be reproduced. I took texastony's working test case, and was able to make it fail simply by adding other
Which causes the type error, due to a failed
The structure of node_modules looks something like this:
This reproduction is using mocha, not jest, and like I said we originally ran across this error in a webpacked lambda function at runtime, so this issue has a bigger impact than just jest as previous comments suggest. I think these issues could be solved with peer dependencies, by making all of the underlying encryption modules depend on each other through peerDependencies. Then
@seebees thoughts? or should I create another issue? |
We use instanceOf to insure some security properties of Cryptographic Materials, and Encrypted Data Keys. However, under some conditions, versions of the dependent packages may result in copies of these files being installed (local node_modules folders) for the packages that have differing versions.
This means that these instanceOf checks may fail. Because while the code is the same, the actual instances are not.
What is the best direction?
How pervasive can this be?
The text was updated successfully, but these errors were encountered: