WIP: use isomorphic-webcrypto for RN

This commit is contained in:
Hadar 2019-09-10 23:30:00 +03:00
parent fc4a23e148
commit 209909ce94
4 changed files with 260 additions and 18 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
*

258
package-lock.json generated
View File

@ -1,9 +1,79 @@
{
"name": "gun",
"version": "0.2019.711",
"version": "0.2019.726",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@peculiar/asn1-schema": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-1.0.3.tgz",
"integrity": "sha512-Tfgj9eNJ6cTKEtEuidKenLHMx/Q5M8KEE9hnohHqvdpqHJXWYr5RlT3GjAHPjGXy5+mr7sSfuXfzE6aAkEGN7A==",
"optional": true,
"requires": {
"asn1js": "^2.0.22",
"tslib": "^1.9.3"
}
},
"@peculiar/json-schema": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.5.tgz",
"integrity": "sha512-y5XYA3pf9+c+YKVpWnPtQbNmlNCs2ehNHyMLJvq4K5Fjwc1N64YGy7MNecKW3uYLga+sqbGTQSUdOdlnaRRbpA==",
"optional": true,
"requires": {
"tslib": "^1.9.3"
}
},
"@peculiar/webcrypto": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.0.19.tgz",
"integrity": "sha512-+lF69A18LJBLp0/gJIQatCARLah6cTUmLwY0Cdab0zsk+Z53BcpjKQyyP4LIN8oW601ZXv28mWEQ4Cm7MllF6w==",
"optional": true,
"requires": {
"@peculiar/asn1-schema": "^1.0.3",
"@peculiar/json-schema": "^1.1.5",
"asn1js": "^2.0.26",
"pvtsutils": "^1.0.6",
"tslib": "^1.10.0",
"webcrypto-core": "^1.0.14"
},
"dependencies": {
"webcrypto-core": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.0.14.tgz",
"integrity": "sha512-iGZQcH/o3Jv6mpvCbzan6uAcUcLTTnUCil6RVYakcNh5/QXIKRRC06EFxHru9lHgVKucZy3gG4OBiup0IsOr0g==",
"optional": true,
"requires": {
"pvtsutils": "^1.0.4",
"tslib": "^1.10.0"
}
}
}
},
"@types/node": {
"version": "10.14.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.17.tgz",
"integrity": "sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ=="
},
"@unimodules/core": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@unimodules/core/-/core-3.0.2.tgz",
"integrity": "sha512-EMZjVp+yrtoPKpDBPvj4+hyDWALl7gvpWeUsDz2Nb9MMBPLnhag1uNk3KC98StJdnjbSXKSdKrCMMidOXnyKcg==",
"optional": true,
"requires": {
"compare-versions": "^3.4.0"
}
},
"@unimodules/react-native-adapter": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@unimodules/react-native-adapter/-/react-native-adapter-3.0.0.tgz",
"integrity": "sha512-zkFFE0HQ2Flfx/aY3hBKDgMvQ1meUm3H6vMIacY1KywexCuKW8ivBobkOsHIet4jf7km0Eklt6WtB3LqQVw5yw==",
"optional": true,
"requires": {
"invariant": "^2.2.4",
"lodash": "^4.5.0",
"prop-types": "^15.6.1"
}
},
"addressparser": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/addressparser/-/addressparser-0.3.2.tgz",
@ -22,11 +92,24 @@
"integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=",
"dev": true
},
"asn1js": {
"version": "2.0.26",
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-2.0.26.tgz",
"integrity": "sha512-yG89F0j9B4B0MKIcFyWWxnpZPLaNTjCj4tkE3fjbAoo0qmpGw0PYYqSbX/4ebnd9Icn8ZgK4K1fvDyEtW1JYtQ==",
"requires": {
"pvutils": "^1.0.17"
}
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"atob": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
},
"aws-sdk": {
"version": "2.238.1",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.238.1.tgz",
@ -45,6 +128,23 @@
"xmlbuilder": "4.2.1"
}
},
"b64-lite": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/b64-lite/-/b64-lite-1.3.1.tgz",
"integrity": "sha512-A3n/YWszeQeUeKKy+XRfsDW/s/+1cvD110HYA4uXtkNswNLd1MxrNblYt2lgKisUS3UfPPTaXhvFegD+l4YuOA==",
"requires": {
"base-64": "^0.1.0"
}
},
"b64u-lite": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/b64u-lite/-/b64u-lite-1.0.1.tgz",
"integrity": "sha512-4E6rqyrCnrAdzayWUS8XwFC/vRTBbmR7fgqb/IuHXRM2z63VH/tNxtzDWZhgCXCORTiwy2mIhCtmHyc9TMBj7Q==",
"optional": true,
"requires": {
"b64-lite": "^1.1.1"
}
},
"backo2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
@ -57,6 +157,11 @@
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
"integrity": "sha1-eAqZyE59YAJgNhURxId2E78k9rs="
},
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
@ -66,8 +171,7 @@
"base64-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
"dev": true
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
},
"base64id": {
"version": "1.0.0",
@ -112,6 +216,16 @@
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"btoa": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz",
"integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g=="
},
"btoa-atob": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/btoa-atob/-/btoa-atob-0.1.2.tgz",
"integrity": "sha1-Pt1ZAryDnZmXWrLh6plVob0Ih+I="
},
"buffer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
@ -135,6 +249,12 @@
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"compare-versions": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.5.1.tgz",
"integrity": "sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg==",
"optional": true
},
"component-bind": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
@ -334,6 +454,15 @@
"integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=",
"dev": true
},
"expo-random": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/expo-random/-/expo-random-6.0.0.tgz",
"integrity": "sha512-nXWmopErqgwkGGfaKPG8v4BNqTXZH4oA/4aAnn6zkTVFdeWBDpWn+Ena3/jnM3raMR3pMNI39YNLqNrut81HvA==",
"optional": true,
"requires": {
"base64-js": "^1.3.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -423,6 +552,15 @@
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"invariant": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
"optional": true,
"requires": {
"loose-envify": "^1.0.0"
}
},
"ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
@ -441,12 +579,35 @@
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
},
"isomorphic-webcrypto": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/isomorphic-webcrypto/-/isomorphic-webcrypto-2.2.2.tgz",
"integrity": "sha512-92LgiUr6a+FO3N/o4G+ZDsLHBHoVffIdKTKoi8Lt4F1Fq/j6FhjRSjFhUJN1AaB4VPiNsmW/7lHi1q0UWMzElA==",
"optional": true,
"requires": {
"@peculiar/webcrypto": "^1.0.19",
"@unimodules/core": "*",
"@unimodules/react-native-adapter": "*",
"b64-lite": "^1.3.1",
"b64u-lite": "^1.0.1",
"expo-random": "*",
"msrcrypto": "^1.5.5",
"react-native-securerandom": "^0.1.1",
"str2buf": "^1.3.0",
"webcrypto-shim": "^0.1.4"
}
},
"jmespath": {
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz",
"integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=",
"dev": true
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"json3": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
@ -456,8 +617,15 @@
"lodash": {
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==",
"dev": true
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"mime-db": {
"version": "1.33.0",
@ -532,11 +700,16 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"msrcrypto": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/msrcrypto/-/msrcrypto-1.5.5.tgz",
"integrity": "sha512-FtB24sqRTsXfLyaqx0b364GP73M29mkW0i0NzvaxJLBHV2h1WbOlu26Ejm2kNuwDhrCVPmT7xanMkAcO0x57Zg==",
"optional": true
},
"nan": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==",
"optional": true
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
},
"negotiator": {
"version": "0.6.1",
@ -545,10 +718,9 @@
"dev": true
},
"node-webcrypto-ossl": {
"version": "1.0.47",
"resolved": "https://registry.npmjs.org/node-webcrypto-ossl/-/node-webcrypto-ossl-1.0.47.tgz",
"integrity": "sha512-73q5ClXxhr7c1LE5dYajdnCVAPr0dhceX/qkATmJGQWyn7xTLgW9s727Bep/6JPqdnx5v7aBraPc+1c2nqjctw==",
"optional": true,
"version": "1.0.48",
"resolved": "https://registry.npmjs.org/node-webcrypto-ossl/-/node-webcrypto-ossl-1.0.48.tgz",
"integrity": "sha512-MWUkQ/5wrs7lpAr+fhsLMfjdxKGd3dQFVqWbNMkyYyCMRW8E7ScailqtCZYDLTnJtU6B+91rXxCJNyZvbYaSOg==",
"requires": {
"mkdirp": "^0.5.1",
"nan": "^2.13.2",
@ -665,12 +837,45 @@
"integrity": "sha1-SSIQiSM1vTExwKCN2i2T7DVD5CM=",
"dev": true
},
"prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"optional": true,
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
},
"dependencies": {
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"optional": true
}
}
},
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
"dev": true
},
"pvtsutils": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.0.6.tgz",
"integrity": "sha512-0yNrOdJyLE7FZzmeEHTKanwBr5XbmDAd020cKa4ZiTYuGMBYBZmq7vHOhcOqhVllh6gghDBbaz1lnVdOqiB7cw==",
"requires": {
"@types/node": "^10.14.17",
"tslib": "^1.10.0"
}
},
"pvutils": {
"version": "1.0.17",
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.0.17.tgz",
"integrity": "sha512-wLHYUQxWaXVQvKnwIDWFVKDJku9XDCvyhhxoq8dc5MFdIlRenyPI9eSfEtcvgHgD7FlvCyGAlWgOzRnZD99GZQ=="
},
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
@ -683,6 +888,21 @@
"integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==",
"optional": true
},
"react-is": {
"version": "16.9.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
"integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==",
"optional": true
},
"react-native-securerandom": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/react-native-securerandom/-/react-native-securerandom-0.1.1.tgz",
"integrity": "sha1-8TBiOkEsM4sK+t7bwgTFy7i/IHA=",
"optional": true,
"requires": {
"base64-js": "*"
}
},
"sax": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
@ -831,6 +1051,12 @@
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"str2buf": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/str2buf/-/str2buf-1.3.0.tgz",
"integrity": "sha512-xIBmHIUHYZDP4HyoXGHYNVmxlXLXDrtFHYT0eV6IOdEj3VO9ccaF1Ejl9Oq8iFjITllpT8FhaXb4KsNmw+3EuA==",
"optional": true
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
@ -855,8 +1081,7 @@
"tslib": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
"optional": true
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ=="
},
"uglify-js": {
"version": "3.3.24",
@ -896,11 +1121,16 @@
"version": "0.1.26",
"resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-0.1.26.tgz",
"integrity": "sha512-BZVgJZkkHyuz8loKvsaOKiBDXDpmMZf5xG4QAOlSeYdXlFUl9c1FRrVnAXcOdb4fTHMG+TRu81odJwwSfKnWTA==",
"optional": true,
"requires": {
"tslib": "^1.7.1"
}
},
"webcrypto-shim": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/webcrypto-shim/-/webcrypto-shim-0.1.4.tgz",
"integrity": "sha512-I2lnL+K2oPNE9ryVHwo42oDnt8XQ9E1KKMGCmcT7OXaAKPmUeCi/G0nUgLR6M6Ztj05ZCxLMGf5bXNaSo+wURg==",
"optional": true
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.2019.726",
"version": "1.0.0-beta.8",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.js",
@ -55,7 +55,9 @@
},
"optionalDependencies": {
"text-encoding": "^0.7.0",
"node-webcrypto-ossl": "^1.0.47",
"isomorphic-webcrypto": "^2.x",
"atob": "^2.1.2",
"btoa": "^1.2.1",
"emailjs": "^2.2.0"
},
"devDependencies": {

13
sea.js
View File

@ -3,6 +3,10 @@
/* UNBUILD */
var root;
if(typeof window !== "undefined"){ root = window }
if (typeof btoa === "undefined") {
global.btoa = require("btoa");
global.atob = require("atob");
}
if(typeof global !== "undefined"){ root = global }
root = root || {};
var console = root.console || {log: function(){}};
@ -158,6 +162,9 @@
if(SEA.window){
api.crypto = window.crypto || window.msCrypto;
if(!api.crypto) {
api.crypto = require('isomorphic-webcrypto');
}
api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle;
api.TextEncoder = window.TextEncoder;
api.TextDecoder = window.TextDecoder;
@ -174,8 +181,10 @@
random: (len) => Buffer.from(crypto.randomBytes(len))
});
//try{
const WebCrypto = USE('node-webcrypto-ossl', 1);
api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
// const WebCrypto = USE('node-webcrypto-ossl', 1);
// api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
const isocrypto = require('isomorphic-webcrypto');
api.ossl = api.subtle = isocrypto.subtle
//}catch(e){
//console.log("node-webcrypto-ossl is optionally needed for ECDH, please install if needed.");
//}