mirror of https://github.com/BTCPrivate/copay.git
Derive token from cid, bring back the custom version of peerjs
This commit is contained in:
parent
a579e35437
commit
f8ea3a4090
|
@ -914,7 +914,7 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
|||
<script src="lib/angular-route/angular-route.min.js"></script>
|
||||
<script src="lib/angular-foundation/mm-foundation.min.js"></script>
|
||||
<script src="lib/angular-foundation/mm-foundation-tpls.min.js"></script>
|
||||
<script src="lib/peerjs/peer.min.js"></script>
|
||||
<script src="lib/peer.js"></script> <!-- TODO Change this on PeerJS version 0.3.9 -->
|
||||
<script src="lib/bitcore/browser/bundle.js"></script>
|
||||
<script src="lib/crypto-js/rollups/sha256.js"></script>
|
||||
<script src="lib/crypto-js/rollups/pbkdf2.js"></script>
|
||||
|
|
|
@ -38,12 +38,6 @@ function Wallet(opts) {
|
|||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.name = opts.name;
|
||||
|
||||
// Renew token every 24hs
|
||||
if (opts.tokenTime && new Date().getTime() - opts.tokenTime < 86400000) {
|
||||
this.token = opts.token;
|
||||
this.tokenTime = opts.tokenTime;
|
||||
}
|
||||
|
||||
this.verbose = opts.verbose;
|
||||
this.publicKeyRing.walletId = this.id;
|
||||
this.txProposals.walletId = this.id;
|
||||
|
@ -222,11 +216,6 @@ Wallet.prototype._optsToObj = function() {
|
|||
version: this.version,
|
||||
};
|
||||
|
||||
if (this.token) {
|
||||
obj.token = this.token;
|
||||
obj.tokenTime = new Date().getTime();
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
@ -284,7 +273,6 @@ Wallet.prototype.netStart = function(callback) {
|
|||
var startOpts = {
|
||||
copayerId: myId,
|
||||
privkey: myIdPriv,
|
||||
token: self.token,
|
||||
maxPeers: self.totalCopayers
|
||||
};
|
||||
|
||||
|
@ -294,7 +282,6 @@ Wallet.prototype.netStart = function(callback) {
|
|||
|
||||
net.start(startOpts, function() {
|
||||
self.emit('ready', net.getPeer());
|
||||
self.token = net.peer.options.token;
|
||||
setTimeout(function() {
|
||||
self.emit('publicKeyRingUpdated', true);
|
||||
self.scheduleConnect();
|
||||
|
@ -382,8 +369,6 @@ Wallet.fromObj = function(o, storage, network, blockchain) {
|
|||
|
||||
Wallet.prototype.toEncryptedObj = function() {
|
||||
var walletObj = this.toObj();
|
||||
delete walletObj.opts.token;
|
||||
delete walletObj.opts.tokenTime;
|
||||
return this.storage.export(walletObj);
|
||||
};
|
||||
|
||||
|
|
|
@ -346,6 +346,7 @@ Network.prototype.start = function(opts, openCallback) {
|
|||
|
||||
if (!self.criticalError && self.tries < self.reconnectAttempts) {
|
||||
self.tries++;
|
||||
self.opts.token = util.sha256(self.peerId).toString('hex');
|
||||
self.peer = new Peer(self.peerId, self.opts);
|
||||
self.started = true;
|
||||
self._setupPeerHandlers(openCallback);
|
||||
|
|
Loading…
Reference in New Issue