TBD54566975 / web5-wallet

A reference implementation of a web5 wallet in react native
Apache License 2.0
13 stars 8 forks source link

Identity Manager cannot create identity using `did` from by `DidDht` #186

Closed xiaoyunyang closed 6 months ago

xiaoyunyang commented 6 months ago

When I was implementing an identity manager the latest IdentityAgent from @web5/identity-agent, I ran into a problem trying to pass a did created using DidDht into identityManager.create() function. Specifically, the create function expects a different PortableDid type than the one that you can create using DidDht.

Here's the code I have

import { IdentityAgent } from "@web5/identity-agent";
import { DidDht } from "@web5/dids";

const didDht = await DidDht.create();
const portableDid = await didDht.export();

const agent = await IdentityAgent.create();

const identity = await agent.identityManager.create({
  name,
  kms: "local",
  did: portableDid, // <-- error occurs here
});

The error is

No overload matches this call.
  Overload 1 of 2, '(options: CreateWithDidMethod<keyof CreateDidMethodOptions>): Promise<ManagedIdentity>', gave the following error.
    Object literal may only specify known properties, and 'did' does not exist in type 'CreateWithDidMethod<keyof CreateDidMethodOptions>'.
  Overload 2 of 2, '(options: CreateWithDid): Promise<ManagedIdentity>', gave the following error.
    Type 'PortableDid' is missing the following properties from type 'PortableDid': did, keySet

I'm using these versions

{
  "@web5/dids": "^0.4.1",
  "@web5/identity-agent": "^0.2.6",
}
xiaoyunyang commented 6 months ago

Sorry submitted in the wrong repo