amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.08k stars 1.16k forks source link

GunHookCallbackAuth has the wrong type in Typescript def #1298

Open nerocui opened 1 year ago

nerocui commented 1 year ago

when I do gun. On('auth', (user, message, event) => {}). The user object I get at runtime is this as stated in documents

// on success calls callback with a reference to the gun user
// cb(at) where at is an object as below
{
    ack: 2,
    back: object, //reference to the root object (internal)
    get: "~publicKeyOfUser",
    gun: object, //gun root (internal)
    id: 6, //id of the node in graph (internal)
    on: function onto(),
    opt: object, //uuid function object (internal)
    put: object, //object containing pub, alias and epub of the user
    root: object, //gun root reference (internal)
    sea: object, //object containing keys of the user
    soul: "~publicKeyOfUser",
    tag: object //gun in and out reference (internal)
}
// on failure callback is called cb(ack) where ack is as below
{
    err: 'Wrong user or password.'
}

But the type definition in typescript is

export type GunUser = {
  /** Username or Alias which can be used to find a user */
  alias: string;
  // auth: string;
  /** public key for encryption */
  epub: string;
  /** public key */
  pub: string;
};

as defined in https://github.com/amark/gun/blob/master/types/sea/GunUser.d.ts

vageherder commented 1 year ago

M61