Ensure nostr session actor matches login pubkey

This commit is contained in:
thePR0M3TH3AN committed 2025-10-27 15:56:08 -04:00
1 parent f68a82f7ee
commit f6a3e8b2ae
2 files changed
+26

No files matched your search

+7
View File
@@ -3499,6 +3499,13 @@ class Application {
return false;
}
const sessionActorPubkey = this.normalizeHexPubkey(
nostrClient?.sessionActor?.pubkey,
);
if (sessionActorPubkey && sessionActorPubkey !== normalizedPubkey) {
return false;
}
return true;
}
+19
View File
@@ -89,3 +89,22 @@ test("isUserLoggedIn guards against mismatched nostrClient state", () => {
nostrClient.sessionActor = previousSessionActor;
}
});
test("isUserLoggedIn rejects mismatched session actor pubkeys", () => {
const previousPubkey = nostrClient.pubkey;
const previousSessionActor = nostrClient.sessionActor;
try {
const pubkey = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
nostrClient.pubkey = pubkey;
nostrClient.sessionActor = {
pubkey: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
};
const app = createTestApp(pubkey);
assert.equal(app.isUserLoggedIn(), false);
} finally {
nostrClient.pubkey = previousPubkey;
nostrClient.sessionActor = previousSessionActor;
}
});