NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
298 stars 59 forks source link

Support Web Crypto API #1045

Open baryon opened 5 years ago

baryon commented 5 years ago

In the NS runtime, the code will return undefine var crypto = global.crypto || global.msCrypto Any plan to support Web Crypto API?

https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API

mbektchiev commented 5 years ago

We haven't considered adding Crypto API in the Runtime for now.

In WebKit it's implemented in the WebCore framework (Crypto.h, Crypto.cpp, DOMWindow::crypto()) and it could be possible to reuse it from there, but this won't be a straightforward task and we still cannot estimate how much effort will be needed and when we can start working on it.

Depending on the demand we could raise the priority of this task and research it in some of the next releases of NativeScript.

baryon commented 5 years ago

no crypto supporting, we can’t use some npm package and features like random and hash functions directly and safety

danielgek commented 5 years ago

@mbektchiev honestly i think this is a must have, big companies and governments usually require a custom implementation because the framework doesn't support it OOTB, @baryon you can checkout this repo , but i don't know if it works in its current state

mbektchiev commented 5 years ago

@danielgek @baryon It is not entirely correct to state that there's no cryptographic implementation out-of-the-box because actually all crypto APIs provided by the iOS and Android OSes are directly accessible from NativeScript. For example all iOS Security Framework's APIs can be freely used in {N} applications.

danielgek commented 5 years ago

I totally agree with you, it's there and might be not that hard to implement but requires more work than expected ;)

mbektchiev commented 5 years ago

Yep, that's true. Maybe having a plugin similar to nativescript-crypto which provides an API similar to Web Crypto's would be a really nice thing to have.