mirror of
https://github.com/amark/gun.git
synced 2025-06-06 14:16:44 +00:00
fix: force use of isomorphiccrypto on react-native
This commit is contained in:
parent
4b14e7c645
commit
f287887e87
2
sea.js
2
sea.js
@ -170,7 +170,7 @@
|
||||
var o = {};
|
||||
|
||||
if(SEA.window){
|
||||
api.crypto = window.crypto || window.msCrypto || require('isomorphic-webcrypto');
|
||||
api.crypto = navigator && navigator.product === 'ReactNative' ? require('isomorphic-webcrypto') : window.crypto || window.msCrypto || require('isomorphic-webcrypto');
|
||||
api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle;
|
||||
api.TextEncoder = window.TextEncoder;
|
||||
api.TextDecoder = window.TextDecoder;
|
||||
|
@ -39,7 +39,7 @@
|
||||
// Next: ECDH keys for encryption/decryption...
|
||||
|
||||
try{
|
||||
var dh = await ecdhSubtle.generateKey({name: 'ECDH', namedCurve: 'P-256'};, true, ['deriveKey'])
|
||||
var dh = await ecdhSubtle.generateKey({name: 'ECDH', namedCurve: 'P-256'}, true, ['deriveKey'])
|
||||
.then(async (keys) => {
|
||||
// privateKey scope doesn't leak out from here!
|
||||
var key = {};
|
||||
|
@ -13,7 +13,7 @@
|
||||
var epriv = pair.epriv;
|
||||
var ecdhSubtle = shim.ossl || shim.subtle;
|
||||
var pubKeyData = keysToEcdhJwk(pub);
|
||||
var props = Object.assign({ public: await ecdhSubtle.importKey(...pubKeyData, true, []) },{name: 'ECDH', namedCurve: 'P-256'};); // Thanks to @sirpy !
|
||||
var props = Object.assign({ public: await ecdhSubtle.importKey(...pubKeyData, true, []) },{name: 'ECDH', namedCurve: 'P-256'}); // Thanks to @sirpy !
|
||||
var privKeyData = keysToEcdhJwk(epub, epriv);
|
||||
var derived = await ecdhSubtle.importKey(...privKeyData, false, ['deriveBits']).then(async (privKey) => {
|
||||
// privateKey scope doesn't leak out from here!
|
||||
@ -44,7 +44,7 @@
|
||||
jwk,
|
||||
{ x: x, y: y, kty: 'EC', crv: 'P-256', ext: true }
|
||||
), // ??? refactor
|
||||
{name: 'ECDH', namedCurve: 'P-256'};
|
||||
{name: 'ECDH', namedCurve: 'P-256'}
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
var o = {};
|
||||
|
||||
if(SEA.window){
|
||||
api.crypto = window.crypto || window.msCrypto || require('isomorphic-webcrypto');
|
||||
api.crypto = navigator && navigator.product === 'ReactNative' ? require('isomorphic-webcrypto') : window.crypto || window.msCrypto || require('isomorphic-webcrypto');
|
||||
api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle;
|
||||
api.TextEncoder = window.TextEncoder;
|
||||
api.TextDecoder = window.TextDecoder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user