diff --git a/sea.js b/sea.js index 6bbe1247..b7f24d93 100644 --- a/sea.js +++ b/sea.js @@ -1341,7 +1341,7 @@ // ok, now "certificant" is in the "certificants" list, but is "path" allowed? Check path let path = soul.indexOf('/') > -1 ? soul.replace(soul.substring(0, soul.indexOf('/') + 1), '') : '' String.match = String.match || Gun.text.match - const w = typeof data.w === 'object' || typeof data.w === 'string' ? [data.w] : Array.isArray(data.w) ? data.w : [] + const w = Array.isArray(data.w) ? data.w : typeof data.w === 'object' || typeof data.w === 'string' ? [data.w] : [] for (const lex of w) { if ((String.match(path, lex['#']) && String.match(key, lex['.'])) || (!lex['.'] && String.match(path, lex['#'])) || (!lex['#'] && String.match(key, lex['.'])) || String.match((path ? path + '/' + key : key), lex['#'] || lex)) { // is Certificant forced to present in Path diff --git a/test/sea/sea.js b/test/sea/sea.js index ba12b0d6..5bc9f92e 100755 --- a/test/sea/sea.js +++ b/test/sea/sea.js @@ -586,6 +586,23 @@ describe('SEA', function(){ }) }())}) + it('Certify: Public inbox', function(done){(async function(){ + var alice = await SEA.pair() + var bob = await SEA.pair() + var cert = await SEA.certify('*', [{"*": "test", "+": "*"}, {"*": "inbox", "+": "*"}], alice) + + user.auth(bob, () => { + var data = Gun.state.lex() + gun.get("~" + alice.pub) + .get("inbox") + .get(user.is.pub) + .put(data, ack => { + expect(ack.ok).to.be(1) + done() + }, { opt: { cert } }) + }) + }())}) + it('Certify: Expiry', function(done){(async function(){ var alice = await SEA.pair() var bob = await SEA.pair()