awslabs / llrt

LLRT (Low Latency Runtime) is an experimental, lightweight JavaScript runtime designed to address the growing demand for fast and efficient Serverless applications.
Apache License 2.0
8.14k stars 359 forks source link

SubtleCrypto #184

Open richarddavison opened 9 months ago

richarddavison commented 9 months ago

https://w3c.github.io/webcrypto/#dfn-SubtleCrypto https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto?retiredLocale=sv-SE

### Related issues
- [ ] https://github.com/awslabs/llrt/issues/125
- [ ] https://github.com/awslabs/llrt/issues/208
tmokmss commented 8 months ago

Missing crypto.createVerify is also a blocker to use aws-jwt-verify.

edit) I found aws-jwt-verify has web browser support (doc), so we should be able to use the package after LLRT will implement SubtleCrypto.

panva commented 7 months ago

~Missing crypto.createVerify is also a blocker~ to use aws-jwt-verify.

edit) I found aws-jwt-verify has web browser support (doc), so we should be able to use the package after LLRT will implement SubtleCrypto.

https://www.npmjs.com/package/jose will be out of the box compatible as soon as SubtleCrypto is implemented as well.

ShivamJoker commented 6 months ago

Hi @richarddavison do we have any ETAs on the crypto implementation? I'm unable to migrate my codebase to LLRT because I'm blocked due to SubtleCrypto and RSA.

richarddavison commented 6 months ago

Hi @richarddavison do we have any ETAs on the crypto implementation? I'm unable to migrate my codebase to LLRT because I'm blocked due to SubtleCrypto and RSA.

Hi @ShivamJoker! Thanks for your patience. We are working on it so should be weeks rather than months. It's not a super complex API, but you'd have to hang on for a bit longer 🙂

stephencroberts commented 4 months ago

@richarddavison I was looking into this as well as we'd like to provide a Web Crypto API for our customers. If there's anything I can help with, let me know! I can allocate some time to contribute.

It may also be helpful to use the WebCryptoAPI web-platform-tests once we merge https://github.com/awslabs/llrt/pull/447 which adds the WPT test harness.

richarddavison commented 4 months ago

@stephencroberts that would be fantastic. We appreciate all the help we could get đź‘Ś Here is a reference implementation (not using the same JS engine, but contains all the algorithms we need so we can take a lot a inspiration from there) https://github.com/lagonapp/lagon/blob/main/crates/runtime_crypto/src/lib.rs

stephencroberts commented 4 months ago

@richarddavison Is there a work-in-progress somewhere or would I start with what's in main?

richarddavison commented 4 months ago

@richarddavison Is there a work-in-progress somewhere or would I start with what's in main?

Please start of main and create a draft PR as soon as you have something even if it’s far from complete so we can “tag along” 🙂

stephencroberts commented 4 months ago

FYI @richarddavison, this is on the back burner for now for us, so someone else is free to pick this up. If/when it becomes a priority again for us, I can revisit it.

dreamorosi commented 4 months ago

Also looking to implement an auth use case - the methods that would help would be importKey, verify, sign, generateKey, and exportKey - all from SubtleCrypto.

I've looked at contributing but unfortunately I'm too out of my depth with Rust atm.

perpil commented 1 month ago

I'm attempting to use jose to mint/verify JWT tokens and I'm seeing this error: SyntaxError: Could not find export 'KeyObject' in module 'crypto' AFAICT I'm using the latest llrt 0.2.2-beta, is this expected?

panva commented 1 month ago

I'm attempting to use jose to mint/verify JWT tokens and I'm seeing this error: SyntaxError: Could not find export 'KeyObject' in module 'crypto' AFAICT I'm using the latest llrt 0.2.2-beta, is this expected?

Yeah, there's no crypto implementation in llrt, that's what this issue is about.

richarddavison commented 1 month ago

@panva @perpil @stephencroberts thanks for your patience, we understand this its frustrating to don't have a crypto API. Crypto support will be added. There are a few differences between Node.js crypto libraries and WinterCG subtle crypto. Ideally we would support both, but Subtile will have priority.