aboutsummaryrefslogtreecommitdiffstats
path: root/lib/changeid.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/changeid.ts')
-rw-r--r--lib/changeid.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/changeid.ts b/lib/changeid.ts
index 1c6a6688..c7343ab3 100644
--- a/lib/changeid.ts
+++ b/lib/changeid.ts
@@ -16,9 +16,16 @@ export default async function changeid(un: string) {
user.id = nid;
user.password = "reset";
+ // A rekey assumes the account's credentials are compromised, nostr key
+ // included. Drop the pubkey's login mapping rather than pointing it at the
+ // new id, and revoke the key so nostr login can't register a fresh account
+ // with it either. user.pubkey stays on the record so an admin can re-link.
if (user.pubkey) {
- await s(user.pubkey, nid);
- await sa(user.pubkey, nid);
+ for (const k of [`user:${user.pubkey}`, user.pubkey]) {
+ await db.del(k);
+ await arc.del(k);
+ }
+ await db.sAdd("revoked:pubkeys", user.pubkey);
}
await s(`user:${un}`, nid);
await sa(`user:${un}`, nid);
@@ -33,6 +40,12 @@ export default async function changeid(un: string) {
`pending:${id}`,
`${id}:lastlen`,
`${id}:contacts`,
+ `${id}:offer`,
+ `${id}:trust`,
+ `${id}:subscriptions`,
+ `${id}:items`,
+ `${id}:pins`,
+ `${id}:square`,
`${id}:accounts`,
`${id}:payments`,
`account:${id}`,
@@ -116,6 +129,11 @@ export default async function changeid(un: string) {
} catch (e) {}
}
+ // Freezes and evictions are keyed by uid, so carry them to the new id or a
+ // rekey (which the blocked-address check triggers on its own) lifts them.
+ for (const set of ["blacklist", "evicted"])
+ if (await db.sIsMember(set, id)) await db.sAdd(set, nid);
+
l(`SECURITY: rekeyed ${un} from ${id} to ${nid}`);
return nid;
}