orbitdb-archive / orbit-db-identity-provider

Default identity provider for OrbitDB
MIT License
31 stars 17 forks source link

Ability to restore Eth Identity from without Signer #79

Open panpansh opened 2 years ago

panpansh commented 2 years ago
import path from "path";
import ODBKeystore from "orbit-db-keystore";
import Identities from "orbit-db-identity-provider";

const account = accounts[0];
const odbIdentitykeysPath = path.join("./orbitdb", "identity", "identitykeys");
const keystore = new ODBKeystore(odbIdentitykeysPath);
// if account exist in IDB: restore else sign
const identity = await keystore.hasKey(account)
    ? await Identities.createIdentity({
        type: "orbitdb",
        id: account,
    })
   : await Identities.createIdentity({
        type: "ethereum",
        wallet: provider.getSigner(),
    });
panpansh commented 2 years ago

https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/identities.js#L58-L64 to be clear the create works fine, the problem is when i want to restore my identity, actually in the code in my case i want "identityProvider.getId" as Ethereum but i want "identityProvider.signIdentity" as Orbitdb.

Because if a wallet is not specified when he getId as ethereum, he create a new one and return the new one https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/ethereum-identity-provider.js#L18

And giving the id like that as createIdentity param, I dont need this transformation as orbitdb https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/orbit-db-identity-provider.js#L26

panpansh commented 2 years ago

I'm certainly wrong, I can't restore the identity without asking for the signature after refreshing the page