Skip to content

Add tests for did:nostr to WebID resolution #39

@melvincarvalho

Description

@melvincarvalho

Summary

Add unit and integration tests for the did:nostr → WebID resolution feature added in v0.0.58.

Test Coverage Needed

Unit Tests (src/auth/did-nostr.js)

  • resolveDidNostrToWebId()

    • Returns null for invalid pubkey
    • Returns null when DID document not found (404)
    • Returns null when no alsoKnownAs in DID doc
    • Returns null when WebID doesn't link back (no bidirectional proof)
    • Returns WebID when bidirectional link exists
    • Caches results for 5 minutes
    • Handles network timeouts gracefully
  • checkSameAsLink()

    • Finds owl:sameAs string value
    • Finds sameAs string value
    • Finds owl:sameAs as object with @id
    • Finds sameAs in array
    • Case-insensitive DID matching

Integration Tests

  • Full flow: Nostr NIP-98 auth → DID resolution → WebID authentication
  • Mock nostr.social DID endpoint
  • Verify fallback to did:nostr when no WebID linked

Files

  • test/did-nostr.test.js (new)
  • Update test/auth.test.js if needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    nostrNostr relay, did:nostr auth, NIP-related

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions