Skip to content

Commit 0aaa789

Browse files
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 fcc3382 commit 0aaa789

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/diddoc.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ export function buildDidDocument(pubkey, { profile, follows, relays } = {}) {
5858
const p = {};
5959
for (const k of ['name', 'about', 'picture', 'website', 'nip05', 'lud16']) if (c[k]) p[k] = c[k];
6060
if (c.display_name && !p.name) p.name = c.display_name;
61-
if (Number.isSafeInteger(profile.created_at)) p.created_at = profile.created_at;
62-
if (Object.keys(p).length) doc.profile = p;
61+
// created_at is provenance *for the profile*: attach it only when the kind-0
62+
// actually contributes profile fields (not a bare timestamp object).
63+
if (Object.keys(p).length) {
64+
if (Number.isSafeInteger(profile.created_at)) p.created_at = profile.created_at;
65+
doc.profile = p;
66+
}
6367
if (Array.isArray(c.alsoKnownAs) && c.alsoKnownAs.length) doc.alsoKnownAs = c.alsoKnownAs;
6468
} catch { /* malformed kind-0 content */ }
6569
}

0 commit comments

Comments
 (0)