Skip to content

Types for CompositeDidDocumentResolver#resolve and isDid are not compatible #46

@ThisIsMissEm

Description

@ThisIsMissEm

I noticed that the types for the resolve method on CompositeDidDocumentResolver does not accept any input did, and isDid returns an incompatible type:

import { isDid } from "@atcute/lexicons/syntax";
import {
  CompositeDidDocumentResolver,
  PlcDidDocumentResolver,
  WebDidDocumentResolver,
} from "@atcute/identity-resolver";

const argv = process.argv.slice(2);
const did = isDid(argv[0])

const didResolver = new CompositeDidDocumentResolver({
  methods: {
    plc: new PlcDidDocumentResolver(),
    web: new WebDidDocumentResolver(),
  },
})

didResolver.resolve(did) // Type Error: Type '`did:${string}:${string}`' is not assignable to type '`did:plc:${string}` | `did:web:${string}` | undefined'.

Perhaps there should be a isAtDid or something that narrows to did:plc: or did:web:? I can of course cast to AtprotoDid fine too, but it was a little unexpected when working with the atcute APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions