)
* fix(did): lead DID document @context with did/v1 (did:nostr 0.1.1)
DID Core requires a DID document's @context to lead with
https://www.w3.org/ns/did/v1. did:nostr 0.1.1 adopted that ordering
(nostrcg/did-nostr#136, fixed by #139), so buildDidDocument now emits:
[did/v1, cid/v1, w3id.org/nostr/context]
cid/v1 is retained because the document's Multikey verification method
comes from the Controlled Identifiers vocabulary.
The requirement is normative for DID documents only, so the standalone
Multikey resource (src/keys/provision.js) and the WebID profile
(src/webid/profile.js) correctly keep cid/v1 alone and are untouched.
Both orderings expand to the same terms under JSON-LD, so existing
documents do not break; JSS's own consumer (src/auth/did-nostr.js) never
reads @context — it keys on verificationMethod.
Updates the full-shape assertion and adds a dedicated regression test for
the leading context, so a reordering failure names itself.
Closes #617
* test(did): assert @context shape before indexing
The dedicated ordering test indexed doc['@context'] and called .includes()
without first checking the field exists, so a regression that dropped
@context entirely would surface as a TypeError instead of the intended
assertion message — defeating the reason the check is a separate test.
Bind @context to a local, assert Array.isArray first, then check the
ordering. Verified: with @context removed from the builder the test now
fails with '@context must be present and an array' rather than a
TypeError.
Summary
Closes #138
Test plan