normalizeKeyId

Normalizes a key ID by extracting the fragment identifier.

Key IDs can be provided in multiple formats:

  • Full DID URL: did:key:z6Mk...#key-1 → returns key-1

  • Fragment only: #key-1 → returns key-1

  • Plain key ID: key-1 → returns key-1

Example:

normalizeKeyId("did:key:z6Mk...#key-1") // returns "key-1"
normalizeKeyId("#key-1") // returns "key-1"
normalizeKeyId("key-1") // returns "key-1"
normalizeKeyId("did:key:z6Mk...") // returns "did:key:z6Mk..."

Return

The normalized key ID (fragment part if present, otherwise the original keyId)

Parameters

keyId

The key ID to normalize (may include DID URL or fragment)