mirror of
https://github.com/amark/gun.git
synced 2026-03-19 06:39:10 +00:00
* Thank you Murage Martin @murageyun for donating!!! * Fix opt.s3.fakes3 parsing issue (#1318) * Fix opt.s3.fakes3 parsing issue * Fix second typo within if block * Support variable number of auth retry attempts through opt.retries (#1325) Maintain default to 9 to ensure backwards compatibility * Thanks Jason Stallings @octalmage !!! * Remove unused imports (#1337) * Update README.md * yay format change * encode objects * WS ws.path fix (#1343) * Update wire.js * Update wire.js * Update wire.js * add one click deploy to readme (#1342) * update src/index (#1254) * update src/index * update * src/index fix * added src/core * is ??? this a MVP of book & rad ???? thanks to @rogowski * book & rad APIs stabilizing * RAD & Book promoted! + buggy example: test/rad/book.html * bump path * cleaned up Book results & sorting & caching * sea blobs! (#1353) * sea blobs! * and null origins * null fix * null check is last * add a way to select stats file from url (#1351) * react-native detection, and load needed shims (#1349) * react-native detection * added lib mobile * changed back to gun. for another solution * have unbuild function wrap to prevent scope leaks & allow RETURN hehehe so I can reject @bmatusiak 's lS change O:) O:) I love you you're a hero! later with @bmatusiak check sea.then for '../gun.js' vs '../' vs ... note: src/index -> core.js TODO: something about WebRTC candidates hitting ack decrement limits? * quick-fix (#1355) * Fix SEA certificate verification, allow multiple pubs (#1358) * Create SECURITY.md (#1364) * ... works (#1357) * Loading fix (#1356) * does this load better * check window.Gun too in rfs * update SECURITY.md file and change the versions to 0.2020.x (#1365) * webrtc accept getUserMedia streams as peer * Check atom exists in graph when deciding to read from disk (#1371) * fix: ERROR: Radisk needs `store.put` interface (#1374) * Update STUN servers (#1381) Commented out sipgate.net STUN server. Added Cloudflare STUN server. * universal notification system --------- Co-authored-by: ritchia1 <andrew.ritchie@estimateone.com> Co-authored-by: Anton <dev@atjn.dk> Co-authored-by: Bradley Matusiak <bmatusiak@gmail.com> Co-authored-by: Jay Byoun <jay8061@pm.me> Co-authored-by: mimiza <dev@mimiza.com> Co-authored-by: Simardeep Singh <1003simar@gmail.com> Co-authored-by: Malcolm Blaney <mblaney@gmail.com> Co-authored-by: Andreas Heissenberger <andreas@heissenberger.at> Co-authored-by: carlin978 <120719190+carlin978@users.noreply.github.com>
75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
;(function(){
|
|
|
|
var SEA = require('./root');
|
|
var shim = require('./shim');
|
|
var S = require('./settings');
|
|
|
|
SEA.name = SEA.name || (async (cb, opt) => { try {
|
|
if(cb){ try{ cb() }catch(e){console.log(e)} }
|
|
return;
|
|
} catch(e) {
|
|
console.log(e);
|
|
SEA.err = e;
|
|
if(SEA.throw){ throw e }
|
|
if(cb){ cb() }
|
|
return;
|
|
}});
|
|
|
|
//SEA.pair = async (data, proof, cb) => { try {
|
|
SEA.pair = SEA.pair || (async (cb, opt) => { try {
|
|
|
|
var ecdhSubtle = shim.ossl || shim.subtle;
|
|
// First: ECDSA keys for signing/verifying...
|
|
var sa = await shim.subtle.generateKey({name: 'ECDSA', namedCurve: 'P-256'}, true, [ 'sign', 'verify' ])
|
|
.then(async (keys) => {
|
|
// privateKey scope doesn't leak out from here!
|
|
//const { d: priv } = await shim.subtle.exportKey('jwk', keys.privateKey)
|
|
var key = {};
|
|
key.priv = (await shim.subtle.exportKey('jwk', keys.privateKey)).d;
|
|
var pub = await shim.subtle.exportKey('jwk', keys.publicKey);
|
|
//const pub = Buff.from([ x, y ].join(':')).toString('base64') // old
|
|
key.pub = pub.x+'.'+pub.y; // new
|
|
// x and y are already base64
|
|
// pub is UTF8 but filename/URL safe (https://www.ietf.org/rfc/rfc3986.txt)
|
|
// but split on a non-base64 letter.
|
|
return key;
|
|
})
|
|
|
|
// To include PGPv4 kind of keyId:
|
|
// const pubId = await SEA.keyid(keys.pub)
|
|
// Next: ECDH keys for encryption/decryption...
|
|
|
|
try{
|
|
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 = {};
|
|
key.epriv = (await ecdhSubtle.exportKey('jwk', keys.privateKey)).d;
|
|
var pub = await ecdhSubtle.exportKey('jwk', keys.publicKey);
|
|
//const epub = Buff.from([ ex, ey ].join(':')).toString('base64') // old
|
|
key.epub = pub.x+'.'+pub.y; // new
|
|
// ex and ey are already base64
|
|
// epub is UTF8 but filename/URL safe (https://www.ietf.org/rfc/rfc3986.txt)
|
|
// but split on a non-base64 letter.
|
|
return key;
|
|
})
|
|
}catch(e){
|
|
if(SEA.window){ throw e }
|
|
if(e == 'Error: ECDH is not a supported algorithm'){ console.log('Ignoring ECDH...') }
|
|
else { throw e }
|
|
} dh = dh || {};
|
|
|
|
var r = { pub: sa.pub, priv: sa.priv, /* pubId, */ epub: dh.epub, epriv: dh.epriv }
|
|
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
|
|
return r;
|
|
} catch(e) {
|
|
console.log(e);
|
|
SEA.err = e;
|
|
if(SEA.throw){ throw e }
|
|
if(cb){ cb() }
|
|
return;
|
|
}});
|
|
|
|
module.exports = SEA.pair;
|
|
|
|
}()); |