google / webcrypto.dart

Cross-platform implementation of Web Cryptography APIs
https://pub.dev/packages/webcrypto
Apache License 2.0
81 stars 48 forks source link

Better detection of when `window.crypto.subtle` works (detection of secure context) #159

Open jonasfj opened 1 month ago

jonasfj commented 1 month ago

The webcrypto API is only available in "secure contexts". We should detect when this isn't the case, make sure we throw UnsupportedError with a description error message, and ideally a link to some documentation about "secure contexts".

We could potentially write up a note about this in the "compatibility notes" section in the README.md.


Also it'd be nice if we had some test cases for this. Those might have to be manual test cases, because dart test running in the browser will probably fake a secure context.