Skip to content

Commit 638c2c3

Browse files
committed
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?
1 parent 5c52df2 commit 638c2c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+216
-78
lines changed

gun.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
};
137137
})(USE, './onto');
138138

139-
;USE(function(module){ ;(function(){
139+
;USE(function(module){
140140
// TODO: BUG! Unbuild will make these globals... CHANGE unbuild to wrap files in a function.
141141
// Book is a replacement for JS objects, maps, dictionaries.
142142
var sT = setTimeout, B = sT.Book || (sT.Book = function(text){
@@ -348,7 +348,6 @@
348348
}
349349

350350
try{module.exports=B}catch(e){}
351-
}());//delete later.
352351
})(USE, './book');
353352

354353
;USE(function(module){
@@ -716,7 +715,7 @@
716715
tmp = keys.length;
717716
console.STAT && console.STAT(S, -(S - (S = +new Date)), 'got copied some');
718717
DBG && (DBG.ga = +new Date);
719-
root.on('in', {'@': to, '#': id, put: put, '%': (tmp? (id = text_rand(9)) : u), $: root.$, _: faith, DBG: DBG, FOO: 1});
718+
root.on('in', {'@': to, '#': id, put: put, '%': (tmp? (id = text_rand(9)) : u), $: root.$, _: faith, DBG: DBG});
720719
console.STAT && console.STAT(S, +new Date - S, 'got in');
721720
if(!tmp){ return }
722721
setTimeout.turn(go);
@@ -1388,6 +1387,7 @@
13881387
var Gun = USE('./root');
13891388
USE('./shim');
13901389
USE('./onto');
1390+
USE('./book');
13911391
USE('./valid');
13921392
USE('./state');
13931393
USE('./dup');

lib/unbuild.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ var undent = function(code, n){
110110
if(rcode != code){
111111
console.log("unbuild:","update",file);
112112
}
113+
code = ";(function(){\n"+code+"\n}());";
113114
write(file, code);
114115
recurse();
115116
}());

sea/aeskey.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var shim = require('./shim');
34
var S = require('./settings');
@@ -13,4 +14,5 @@
1314
return await shim.subtle.importKey('jwk', jwkKey, {name:'AES-GCM'}, false, ['encrypt', 'decrypt'])
1415
}
1516
module.exports = importGen;
16-
17+
18+
}());

sea/array.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
require('./base64');
34
// This is Array extended to have .toString(['utf8'|'hex'|'base64'])
@@ -22,4 +23,5 @@
2223
}
2324
}
2425
module.exports = SeaArray;
25-
26+
27+
}());

sea/auth.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var User = require('./user'), SEA = User.SEA, Gun = User.GUN, noop = function(){};
34
// now that we have created a user, we want to authenticate them!
@@ -7,7 +8,8 @@
78
var pass = (alias || (pair && !(pair.priv && pair.epriv))) && typeof args[1] === 'string' ? args[1] : null;
89
var cb = args.filter(arg => typeof arg === 'function')[0] || null; // cb now can stand anywhere, after alias/pass or pair
910
var opt = args && args.length > 1 && typeof args[args.length-1] === 'object' ? args[args.length-1] : {}; // opt is always the last parameter which typeof === 'object' and stands after cb
10-
11+
var retries = typeof opt.retries === 'number' ? opt.retries : 9;
12+
1113
var gun = this, cat = (gun._), root = gun.back(-1);
1214

1315
if(cat.ing){
@@ -30,6 +32,10 @@
3032
var get = (act.list = (act.list||[]).concat(list||[])).shift();
3133
if(u === get){
3234
if(act.name){ return act.err('Your user account is not published for dApps to access, please consider syncing it online, or allowing local access by adding your device as a peer.') }
35+
if(alias && retries--){
36+
root.get('~@'+alias).once(act.a);
37+
return;
38+
}
3339
return act.err('Wrong user or password.')
3440
}
3541
root.get(get).once(act.a);
@@ -74,7 +80,7 @@
7480
if(SEA.window && ((gun.back('user')._).opt||opt).remember){
7581
// TODO: this needs to be modular.
7682
try{var sS = {};
77-
sS = window.sessionStorage; // TODO: FIX BUG putting on `.is`!
83+
sS = SEA.window.sessionStorage; // TODO: FIX BUG putting on `.is`!
7884
sS.recall = true;
7985
sS.pair = JSON.stringify(pair); // auth using pair is more reliable than alias/pass
8086
}catch(e){}
@@ -154,4 +160,5 @@
154160
}catch(e){o={}};
155161
return o;
156162
}
157-
163+
164+
}());

sea/base64.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var u;
34
if(u+''== typeof btoa){
@@ -7,4 +8,5 @@
78
global.btoa = function(data){ return Buffer.from(data, "binary").toString("base64") };
89
global.atob = function(data){ return Buffer.from(data, "base64").toString("binary") };
910
}
10-
11+
12+
}());

sea/buffer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
require('./base64');
34
// This is Buffer implementation used in SEA. Functionality is mostly
@@ -76,4 +77,5 @@
7677
SafeBuffer.prototype.toString = SeaArray.prototype.toString
7778

7879
module.exports = SafeBuffer;
79-
80+
81+
}());

sea/certify.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var SEA = require('./root');
34
// This is to certify that a group of "certificants" can "put" anything at a group of matched "paths" to the certificate authority's graph
@@ -69,4 +70,5 @@
6970
}});
7071

7172
module.exports = SEA.certify;
72-
73+
74+
}());

sea/create.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var User = require('./user'), SEA = User.SEA, Gun = User.GUN, noop = function(){};
34

@@ -94,11 +95,12 @@
9495
}
9596
if(SEA.window){
9697
try{var sS = {};
97-
sS = window.sessionStorage;
98+
sS = SEA.window.sessionStorage;
9899
delete sS.recall;
99100
delete sS.pair;
100101
}catch(e){};
101102
}
102103
return gun;
103104
}
104-
105+
106+
}());

sea/decrypt.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;(function(){
12

23
var SEA = require('./root');
34
var shim = require('./shim');
@@ -39,4 +40,5 @@
3940
}});
4041

4142
module.exports = SEA.decrypt;
42-
43+
44+
}());

0 commit comments

Comments
 (0)