handleOfDid

tcmts.registry.handleOfDid · #5aq5h2mw · term · runs anywhere

A visitor's handle, as their DID document says it (for showing who's signed in), or their DID.

import { didDocument } from "#codebase/tcmts/atproto";

export async function handleOfDid(did: string): Promise<string> {
  try {
    const aka = (await didDocument(did)).alsoKnownAs?.find((a) => a.startsWith("at://"));
    return aka ? aka.slice(5) : did;
  } catch {
    return did;
  }
}

uses

used by