ios-jsc icon indicating copy to clipboard operation
ios-jsc copied to clipboard

Support Web Crypto API

Open baryon opened this issue 6 years ago • 6 comments

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

baryon avatar Jan 07 '19 09:01 baryon

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.

mbektchiev avatar Jan 07 '19 12:01 mbektchiev

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

baryon avatar Jan 07 '19 12:01 baryon

@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

danielgek avatar Jan 07 '19 12:01 danielgek

@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.

mbektchiev avatar Jan 07 '19 13:01 mbektchiev

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

danielgek avatar Jan 07 '19 13:01 danielgek

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.

mbektchiev avatar Jan 07 '19 14:01 mbektchiev