Skip to content

Instantly share code, notes, and snippets.

@sondreb
Created October 16, 2024 10:03
Show Gist options
  • Save sondreb/4aa0067e009f647b2583879cf0cdfad7 to your computer and use it in GitHub Desktop.
Save sondreb/4aa0067e009f647b2583879cf0cdfad7 to your computer and use it in GitHub Desktop.
Custom DID Method for Web5.connect()
const customAgentVault = new HdIdentityVault({
keyDerivationWorkFactor: 210_000,
store: new LevelStore<string, string>({ location: `DATA/AGENT/VAULT_STORE` }),
});
await customAgentVault.unlock({ password });
const didApi = new AgentDidApi({
didMethods: [DidDht, DidJwk, DidStellar],
resolverCache: new AgentDidResolverCache({ location: `DATA/AGENT/DID_RESOLVERCACHE` }),
store: new DwnDidStore(),
});
const agentDid = await customAgentVault.getDid();
const customAgent = await Web5IdentityAgent.create({ didApi, agentDid, agentVault: customAgentVault });
console.log('Connecting to Web5...');
const result = await Web5.connect({ agent: customAgent, connectedDid, password, sync: this.syncInterval });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment