Commit f13526f
authored
* 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.
1 parent 0976f3e commit f13526f
2 files changed
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
498 | 507 | | |
499 | 508 | | |
500 | 509 | | |
501 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
502 | 515 | | |
503 | 516 | | |
504 | 517 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
| |||
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
142 | 166 | | |
143 | 167 | | |
144 | 168 | | |
| |||
0 commit comments