CryptoKey definition not found
Using the newest 0.7.0-rc.10 the definition of CryptoKey does not seem to be properly exported?
I have to manually import it using
import { CryptoKey } from "react-native-quick-crypto/src/keys"
Is there a way to have it available using tsconfig/babel resolve?
You are right. crypto.webcrypto didn't get the same treatment as crypto.subtle.
Do you want to throw a PR together? If not, I can get to it after I release 0.7.0 and #349.
Its just a missing type export I guess? Then a PR would be possible.
Well, probably it's missing webcrypto.ts file in the top-level of JS code, and then put the exports in there, according to Node docs and implementation-coverage.md in this repo. Then one last add to index.ts inside of QuickCrypto object.
I think i hava the same issue but the definition is needed in third-party code. I'm trying to sign a jwt using jose library (alg: RS256) and somewhere it performs isCryptoKey check. I can't find the function in node_modules so ig i can't manually add import. Is there a work around? The project doesn't use ts yet if that matters.
I have this fix in an upcoming PR
After upgrading to 0.7.1 am still getting the ReferenceError: Property 'CryptoKey' doesn't exist error in react-native using jose.exportJWK
Can someone give me a small reproducible app in a repo, with errors, as well as expected outcomes? Maybe just a branch with a failing test in this repo would do... I just need more to go on.
Can someone give me a small reproducible app in a repo, with errors, as well as expected outcomes? Maybe just a branch with a failing test in this repo would do... I just need more to go on.
Here it is: https://github.com/esperor/mre-rnqc
Error is ReferenceError: Property 'CryptoKey' doesn't exist
Expected outcome is jose.exportPKCS8 doesn't throw the error and exports the key successfully
I think this might be an issue with how jose detects a CryptoKey instance.
If you look here, you can see that interop is a known thing.
RNQC and Node use the same code in their isCryptoKey() functions. jose does things differently for browser and node. When I change jose browser code (I assume node doesn't work in RN) in node_modules to match RNQC and Node codebase, your test function succeeds.
I don't know exactly how to proceed. Maybe talk to the jose folks and get their thoughts on library interoperability and the Web Crypto API for CryptoKey.
@boorad Thank you very much for your help. I managed to make it work for me via forked & edited release tag.