gun icon indicating copy to clipboard operation
gun copied to clipboard

about sea login

Open mccoysc opened this issue 7 years ago • 11 comments

` var user = gun.user(); user.create('bob', 'unsafepassword', login);

    function login(ack) {
        console.log("login...");
        user.auth('bob', 'unsafepassword', write);
    }

    function write(ack) {
        console.log("write...");
        var alice = {
            name: "bob"
        };
        alice.boss = {
            name: "Fluffy",
            species: "Kitty",
            slave: alice
        };
        user.get('profile').put(alice, read);
    }

    function read() {
        console.log("read...");
        user.get('profile').get('boss').get('slave').get('name').val(data =>
            console.log("The boss's slave's name is:", data) // Alice
        );
    }`

when run the above code first,it's all working well. but if re-run the same code,the login would nerver call my callback "write". but if i re-run the same code again, it would get ok again and repeat all the procedure.

mccoysc avatar Dec 11 '18 06:12 mccoysc

@amark

mccoysc avatar Dec 11 '18 06:12 mccoysc

@mccoysc I don't know if this is related, but I have recently upgraded .create to automatically call .auth if no callback is provided. If you want to manually control whether a user should be auto-logged in after an account is created or not... then pass a callback.

Upon re-running, it looks like it will create ANOTHER bob user (usernames are not unique), actually I think it should error if it find a conflict (but you can override this with {already: true option). Just FYI.

But you are saying that create/auth only works 50% of the time? Or something else?

What environment are you running this in, what storage engine, operating system, browser, etc. ?

amark avatar Dec 14 '18 01:12 amark

In chrome version 70,work and not work,50%. this time work and next not

mccoysc avatar Dec 14 '18 02:12 mccoysc

and as the above code,i supplied all callback needed

mccoysc avatar Dec 14 '18 02:12 mccoysc

and also,i used the new "gun.js" and 'sea.js' code in github which time are shown "2 days agao". the same code as above, after first run ,every i run the code again,it shows like the following:

User already created! Wrong user or password.

@amark

mccoysc avatar Dec 14 '18 04:12 mccoysc

Can't create user on master nor tag 0.9.999999

 u = gun.user();
u.create('testing2','testing',function(){ console.log(Array.from(arguments)); })
User {_: {…}}
 [{…}] { ok: 0, pub: "TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks",
gun.js?v=301:1 

On serverside I read the same:

NO! Unverified data. {
  '~TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks': {
    _: {
      '#': '~TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks',
      '>': [Object]
    },
    pub: 'TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks',
    alias: 'SEA{"m":["~TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks","alias","testing2",1574493758703],"s":""}',
    epub: 'SEA{"m":["~TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks","epub","-X6yTXR31b-cMbkCzEVQxlvOGC7pUzrW-y7mTyjAO6g.6k3q9FAKewkwsa_b4eg7bjsyBH3klNST2S-I00XM2Bw",1574493758703],"s":""}',
    auth: 'SEA{"m":["~TZeUaonNPbTYuBz3eqnyRuLvW28UxyTRelZ7KavdweA.GcOyw9evjMPI84Koz0B5UQJS4U-6llZgfKRBM5ufJks","auth","{\\"s\\":\\"TXqtCRsGlZ3sOQ7VhfCjCXIDWmt1jGIRiWVLMqDB7k1CqZU9TfEUcJLAiEdI62Iq\\"}",1574493758703],"s":""}'
  }
}
Signature did not match.
Signature did not match.

jabis avatar Nov 23 '19 07:11 jabis

Adding to this, on master branch the error is:

TypeError: SEA.I is not a function
    at Object.SEA.encrypt (sea.js?v=301:519)
    at Object.act.e (sea.js?v=301:794)
    at Object.act.d (sea.js?v=301:790)
    at act.c (sea.js?v=301:786)
    at Object.SEA.pair (sea.js?v=301:360)  

and serverside

TypeError: Cannot read property 'byteLength' of undefined
    at Function.from (/gun/sea.js:131:34)
    at Object.SEA.opt.fall_verify (/gun/sea.js:480:27)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.SEA.verify (/gun/sea.js:443:18)
NO! Unverified data. {
  '~sTFdAiN2T1x1Lz5YQa_GzQypMN1ksehG7nJhdLYsOrM.4CEmguGIFKOZXZ3T1MY7eYyk52u6QVhIVpGH8sqz9Bg': {
    _: {
      '#': '~sTFdAiN2T1x1Lz5YQa_GzQypMN1ksehG7nJhdLYsOrM.4CEmguGIFKOZXZ3T1MY7eYyk52u6QVhIVpGH8sqz9Bg',
      '>': [Object]
    },
    pub: 'sTFdAiN2T1x1Lz5YQa_GzQypMN1ksehG7nJhdLYsOrM.4CEmguGIFKOZXZ3T1MY7eYyk52u6QVhIVpGH8sqz9Bg',
    alias: '{":":"testing2","~":""}',
    epub: '{":":"C95731h-2zxTBtuGaAYRe5ITVP8p2R06UoQV7aQQuhc.ctrfg1Xnnx0ojvgHABJzvqsduH3LUzBZAcCkSHjQbPs","~":""}',
    auth: '{":":{"s":"WXmeuQkQ1jVun2zmZx1iUIL121r7Ix5k8Ophe82UsE9ONOLf4aIZwup9drEg93Qu"},"~":""}'
  }
}
TypeError: Cannot read property 'byteLength' of undefined
    at Function.from (/gun/sea.js:131:34)
    at Object.SEA.opt.fall_verify (/gun/sea.js:480:27)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.SEA.verify (/gun/gun/sea.js:443:18)
TypeError: Cannot read property 'byteLength' of undefined
    at Function.from (/gun/sea.js:131:34)
    at Object.SEA.opt.fall_verify (/gun/sea.js:480:27)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.SEA.verify (/gun/sea.js:443:18)

jabis avatar Nov 23 '19 07:11 jabis

Traced this one back to old SafeBuffer ( sea/buffer.js ) was not handling the string decoding properly kept filling the SeaArray(64) with [0..] - had to clean the gun-directory, issue a hard reset and npm install again, and the problem was solved.

jabis avatar Nov 24 '19 01:11 jabis

I get SEA.I error on master too.

Here's the code causing the error, it happens inside ('messages').on() https://github.com/shocknet/api/pull/103/files#diff-1208e94b60141916fd368583f90040feR16-R54

erbesharat avatar Aug 11 '20 09:08 erbesharat

@erbesharat SEA.I is intended for browsers/extensions to manage private keys for you, not the app. It gets triggered when no keys are passed to the crypto functions, so it then assumes the keys are managed by the browser. If the browser does not support the spec or have an extension, then it crashes with that error. This makes me think something else is going on that caused your app to not pass keys.

amark avatar Aug 21 '20 18:08 amark

@erbesharat SEA.I is intended for browsers/extensions to manage private keys for you, not the app. It gets triggered when no keys are passed to the crypto functions, so it then assumes the keys are managed by the browser. If the browser does not support the spec or have an extension, then it crashes with that error. This makes me think something else is going on that caused your app to not pass keys.

I got the same issue with playing with examples/basic/private.html - trying to use the search function. Was not serving the page, rather just opening from file system.

madmartian5 avatar Nov 17 '20 10:11 madmartian5