fix: resolve AES-GCM Web Crypto interop failure in Pyodide worker#42
fix: resolve AES-GCM Web Crypto interop failure in Pyodide worker#42Shubhashish-Chakraborty wants to merge 3 commits into
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 42 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai resume |
✅ Actions performedReviews resumed. |
|
Fixed |
Problem
All
encrypt_aesanddecrypt_aescalls were failing withNotSupportedError: Unrecognized key import algorithm "undefined". This leads to user registration failure. Previously this issue was already addressed in #27 and PR was merged but after a further commit 8ac4409... , this reintroduced the AES bug.Root Cause
In Pyodide, passing a bare Python dict to
js.crypto.subtleAPIs does not produce a plain JS object. Without an explicit converter,to_js({"name": "AES-GCM"})produces a JS Map. The Web Crypto API reads algorithm parameters via dot-notation (e.g. algo.name), which returns undefined on a Map, and hence the error.The previous correct fix used
dict_converter=js.Object.fromEntries. Commit 8ac4409 removed that, leaving raw Python dicts and rebreaking everything.FIx
Replaced all three algorithm parameter constructions in
_import_aes_key,encrypt_aes, anddecrypt_aeswithjs.Object.new()instances, setting .name and .iv as explicit JS properties.Aditionally:
I've added
_JsObjectand_JsObjectClassstubs so thatjs.Object.new()works in the test environment.