Treat session actors as logged out for zaps

This commit is contained in:
thePR0M3TH3AN committed 2025-10-19 18:28:47 -04:00
1 parent 0c211cd411
commit ed1166c16e
2 files changed
+57 -2

No files matched your search

+13 -1
View File
@@ -3038,7 +3038,19 @@ class Application {
}
isUserLoggedIn() {
return Boolean(this.normalizeHexPubkey(this.pubkey));
const normalizedPubkey = this.normalizeHexPubkey(this.pubkey);
if (!normalizedPubkey) {
return false;
}
const sessionActorPubkey = this.normalizeHexPubkey(
nostrClient?.sessionActor?.pubkey,
);
if (sessionActorPubkey && sessionActorPubkey === normalizedPubkey) {
return false;
}
return true;
}
async updateActiveNwcSettings(partial = {}) {
+44 -1
View File
@@ -182,7 +182,16 @@ function createVideoModalStub() {
return {
setCopyEnabled: noop,
setShareEnabled: noop,
setZapVisibility: noop,
setWalletPromptVisible: noop,
zapVisibilityCalls: [],
setZapVisibility(config) {
const payload =
config && typeof config === "object"
? { ...config }
: { visible: Boolean(config) };
this.zapVisibilityCalls.push(payload);
this.lastZapVisibility = payload;
},
dialogOpen: false,
closeZapDialogCalls: [],
closeZapDialog(options = {}) {
@@ -349,6 +358,40 @@ await (async () => {
app.destroy();
})();
await (async () => {
// Test: session actors should not be treated as logged-in users for zaps
const { app, modalStub } = await createApp({
splitAndZap: async () => ({ receipts: [] }),
});
const { nostrClient } = await import("../js/nostr.js");
const originalSessionActor = nostrClient.sessionActor;
const sessionPubkey = "a".repeat(64);
nostrClient.sessionActor = { pubkey: sessionPubkey, privateKey: "priv" };
app.pubkey = sessionPubkey;
modalStub.zapVisibilityCalls = [];
app.zapController.setVisibility(true);
const lastVisibility =
modalStub.zapVisibilityCalls[modalStub.zapVisibilityCalls.length - 1];
assert.deepEqual(
lastVisibility,
{ visible: true, requiresLogin: true },
"zap controller should require login when only a session actor is present",
);
assert.equal(
app.isUserLoggedIn(),
false,
"session actor pubkeys should not count as logged-in users",
);
app.pubkey = null;
nostrClient.sessionActor = originalSessionActor;
app.destroy();
})();
await (async () => {
// Test: wallet required before zapping
const splitCalls = [];