mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Ensure NIP-07 permissions are granted before signing and encrypting
This commit is contained in:
1 parent
a36d807361
commit
deffbf7670
6 files changed
+232
-80
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
getCurrentUserNpub,
|
||||
} from "../state/appState.js";
|
||||
import { userLogger } from "../utils/logger.js";
|
||||
import { requestDefaultExtensionPermissions } from "../nostr.js";
|
||||
import {
|
||||
getSavedProfiles,
|
||||
getActiveProfilePubkey,
|
||||
@@ -245,6 +246,15 @@ export default class AuthService {
|
||||
}
|
||||
|
||||
const result = await this.nostrClient.login(options);
|
||||
const permissionResult = await requestDefaultExtensionPermissions();
|
||||
if (!permissionResult.ok) {
|
||||
const error = new Error(
|
||||
"The NIP-07 extension denied the permission request required to finish logging in.",
|
||||
);
|
||||
error.code = "extension-permission-denied";
|
||||
error.cause = permissionResult.error;
|
||||
throw error;
|
||||
}
|
||||
const pubkey =
|
||||
typeof result === "string"
|
||||
? result
|
||||
|
||||
Reference in new issue
Block a user