mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Preserve NIP-07 permissions on logout
This commit is contained in:
1 parent
377564c53b
commit
596e2f472b
3 files changed
+27
-9
No files matched your search
@@ -219,6 +219,15 @@ export const ADMIN_WHITELIST_MODE_STORAGE_KEY = "bitvid_admin_whitelist_mode";
|
||||
*/
|
||||
export const DEFAULT_WHITELIST_MODE_ENABLED = true;
|
||||
|
||||
/**
|
||||
* Whether bitvid should clear stored NIP-07 permissions when users log out.
|
||||
*
|
||||
* Set this to `true` if your environment requires removing cached extension
|
||||
* permissions on logout (e.g., shared devices). Leave it `false` to preserve
|
||||
* permissions so returning users do not need to reauthorize the extension.
|
||||
*/
|
||||
export const CLEAR_NIP07_PERMISSIONS_ON_LOGOUT = false;
|
||||
|
||||
/**
|
||||
* Whether the public client should display content flagged as NSFW.
|
||||
*
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS,
|
||||
DEFAULT_PLAYBACK_SOURCE,
|
||||
DEFAULT_PLAYBACK_START_TIMEOUT,
|
||||
CLEAR_NIP07_PERMISSIONS_ON_LOGOUT,
|
||||
} from "../config/instance-config.js";
|
||||
|
||||
export const WATCH_HISTORY_VERSION_TAG_VALUE = "2";
|
||||
@@ -137,3 +138,4 @@ export { VIEW_COUNT_CACHE_TTL_MS };
|
||||
export { ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS };
|
||||
export { DEFAULT_PLAYBACK_SOURCE };
|
||||
export { DEFAULT_PLAYBACK_START_TIMEOUT };
|
||||
export { CLEAR_NIP07_PERMISSIONS_ON_LOGOUT };
|
||||
+16
-9
@@ -17,7 +17,7 @@
|
||||
* - Signer Management: Orchestrates NIP-07 (Extension), NIP-46 (Remote/Bunker), and NIP-01 (Local nsec) signers.
|
||||
*/
|
||||
|
||||
import { isDevMode } from "../config.js";
|
||||
import { CLEAR_NIP07_PERMISSIONS_ON_LOGOUT, isDevMode } from "../config.js";
|
||||
import { FEATURE_PUBLISH_NIP71 } from "../constants.js";
|
||||
import { bytesToHex, sha256 } from "../../vendor/crypto-helpers.bundle.min.js";
|
||||
import { infoHashFromMagnet } from "../magnets.js";
|
||||
@@ -4396,9 +4396,9 @@ export class NostrClient {
|
||||
* - Wipes session actor (ephemeral keys).
|
||||
* - Disconnects NIP-46 remote signer (if active).
|
||||
* - Clears Watch History cache.
|
||||
* - Resets permissions cache.
|
||||
* - Optionally clears stored NIP-07 permissions.
|
||||
*/
|
||||
logout() {
|
||||
logout({ clearNip07Permissions = null } = {}) {
|
||||
const previousPubkey = this.pubkey;
|
||||
this.pubkey = null;
|
||||
logoutSigner(previousPubkey);
|
||||
@@ -4432,13 +4432,20 @@ export class NostrClient {
|
||||
}
|
||||
|
||||
this.watchHistory.clear();
|
||||
if (
|
||||
this.extensionPermissionCache &&
|
||||
typeof this.extensionPermissionCache.clear === "function"
|
||||
) {
|
||||
this.extensionPermissionCache.clear();
|
||||
const shouldClearNip07Permissions =
|
||||
typeof clearNip07Permissions === "boolean"
|
||||
? clearNip07Permissions
|
||||
: CLEAR_NIP07_PERMISSIONS_ON_LOGOUT;
|
||||
|
||||
if (shouldClearNip07Permissions) {
|
||||
if (
|
||||
this.extensionPermissionCache &&
|
||||
typeof this.extensionPermissionCache.clear === "function"
|
||||
) {
|
||||
this.extensionPermissionCache.clear();
|
||||
}
|
||||
clearStoredNip07Permissions();
|
||||
}
|
||||
clearStoredNip07Permissions();
|
||||
devLogger.log("User logged out.");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user