Commit f68e60f
authored
Align DID-document generation with did:nostr 0.0.12 (#39)
* Align DID-document generation with did:nostr 0.0.12
Three conformance fixes surfaced by diffing the live nostr.social output
against the 0.0.12 spec:
- profile.timestamp -> profile.created_at (nostrcg/did-nostr#117), using the
kind-0 created_at (now a defined context term, nostr:created_at).
- Emit "modified" (dcterms:modified, ISO-8601) = max(created_at) over the
signed parts composed into the document (nostrcg/did-nostr#106). Minimal docs
(no signed parts) carry none.
- Bound inlined follows to a subset (500) rather than serving the entire list —
one live doc was inlining 4760 follows. The complete signed list is the kind-3
event on the relays (nostrcg/did-nostr#104 / #125).
diddoc unit tests updated and passing (created_at, modified, bounded follows).
* Use Number.isFinite for profile.created_at gate (preserve created_at=0)
Address Copilot review on #39: the truthiness gate dropped a valid created_at
of 0, while the modified computation uses Number.isFinite. Make them consistent.
* Short-circuit follows collection at FOLLOWS_LIMIT
Address Copilot review on #39: collect up to FOLLOWS_LIMIT valid entries and
stop, instead of validating/mapping the whole kind-3 list before slicing.
* Harden modified against corrupt created_at (no throw, no null serialization)
Address Copilot review on #39:
- isoFromUnix returns null for non-safe-integer or out-of-range timestamps
instead of throwing RangeError in the public resolver path.
- Filter stamps with Number.isSafeInteger (Nostr created_at is integer seconds)
and only set modified when isoFromUnix yields a value (never modified: null).
- profile.created_at gate also uses Number.isSafeInteger for consistency.
* Count kind-0 created_at toward modified when it composes via alsoKnownAs
Address Copilot review on #39: a kind-0 event can contribute alsoKnownAs with
no profile fields, so gating the kind-0 created_at on doc.profile alone could
understate modified. Gate on (doc.profile || doc.alsoKnownAs).
* Fix: don't emit a profile that is only a created_at
The created_at was added to the profile object before the non-empty check, so a
kind-0 with only alsoKnownAs produced doc.profile = {created_at}. Attach
created_at only when the kind-0 contributes real profile fields; alsoKnownAs-only
kind-0 now yields no profile but still counts toward modified (prior commit's
gate). Fixes the test added in fcc3382.1 parent 3a9460d commit f68e60f
2 files changed
Lines changed: 80 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
| |||
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
16 | 35 | | |
17 | 36 | | |
18 | 37 | | |
| |||
39 | 58 | | |
40 | 59 | | |
41 | 60 | | |
42 | | - | |
43 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
44 | 67 | | |
45 | 68 | | |
46 | 69 | | |
| |||
54 | 77 | | |
55 | 78 | | |
56 | 79 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
60 | 89 | | |
61 | 90 | | |
62 | 91 | | |
| |||
67 | 96 | | |
68 | 97 | | |
69 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
70 | 113 | | |
71 | 114 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
41 | 69 | | |
42 | 70 | | |
43 | 71 | | |
| |||
0 commit comments