gun icon indicating copy to clipboard operation
gun copied to clipboard

Put silently fails when SEA certificate uses an array

Open Jahb opened this issue 2 years ago • 2 comments

Hi, The docs https://gun.eco/docs/SEA.certify mention that you can have an array of pubs when creating certificates. On the current version of Gun 0.2020.1239 two things happen:

  • Puts seem to fail silently and never call their callback function when using a certificate with an array of pubs.
  • The callbacks on gets to a node where you attempted to put will also never be called afterwards.
 console.log("Running test");
  const sea1 = await SEA.pair();
  const sea2 = await SEA.pair();
  const sea3 = await SEA.pair();

  const policy: any = { "*": "test", "+": "*" };
  const cert1 = await SEA.certify([sea2.pub, sea3.pub], policy, sea1);

  user.auth(sea2, (data: any) => {
    console.log("Authed");

    //The callback is never called on this put.
    gun
      .get(`~${sea1.pub}`)
      .get("test")
      .get(sea2.pub)
      .put({ test: "data" }, console.log, {
        opt: { cert: cert1 },
      });

    //The once call back is also never called.
    gun.get(`~${sea1.pub}`).get("test").get(sea2.pub).once(console.log);
  });

I have created a sandbox that shows the bug (see index.ts).

Jahb avatar Jan 17 '23 10:01 Jahb

🤦 that's not fun or good. Sorry.

I don't have bandwidth for this one until after AXE, RAD/Book. Probably would be good before SecureRender (since that's long term). Anyone want to have a stab? Can get on a code call if need.

amark avatar Feb 01 '23 01:02 amark

Thanks for reporting. This PR fixes the issue. Just wait for the merge. https://github.com/amark/gun/pull/1358

mimiza avatar Jan 23 '24 09:01 mimiza