You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been attempting to use the npm nostr-login package with the @nostr-dev-kit/ndk, NDKNip46Signer packages. Initializing and fetching seems to be working, but I'm having issues publishing new events. Can you help me identify what I'm doing wrong?
Console errors:
@nostr-dev-kit_ndk.js?v=0271c622:12222 Uncaught (in promise) TypeError: this.signer.user is not a function
at Proxy.sendRequest (@nostr-dev-kit_ndk.js?v=0271c622:12222:41)
at @nostr-dev-kit_ndk.js?v=0271c622:12603:16
at new Promise (<anonymous>)
at Proxy.sign (@nostr-dev-kit_ndk.js?v=0271c622:12602:21)
at _NDKEvent.sign (@nostr-dev-kit_ndk.js?v=0271c622:8160:29)
at async _NDKEvent.publish (@nostr-dev-kit_ndk.js?v=0271c622:8187:7)
at async Proxy.publishEvent (nostr.js?t=1726341404422:241:1)
at async Proxy.handleSave (NoteEventDetail.vue:67:21)`
Here are some relevant snippets from my code:
Attempting to initialize:
{
localStorage.setItem("debug", "ndk:*"); // TODO: TESTING debug NDK internals
const authStore = useAuthStore();
let { loginMethod, toggleModal, setLoginStatus } = authStore;
// let signer;
let remoteNpub;
try {
if (!ndk) {
ndk = new NDK();
}
if (loginMethod === "nostr-login") {
try {
await initNostrLogin({
bunkers: 'nsec.app',
theme: 'ocean',
darkMode: true,
perms: 'sign_event:1, nip04_encrypt',
noBanner: true,
isSignInWithExtension: false, // TODO: not working as expected
onAuth: async (npub, options) => {
console.log(`User authenticated with pubkey: ${npub}`, options);
remoteNpub = npub;
},
}).catch((ex) => {
console.error('Error initializing Nostr Login:', ex);
});
} catch (ex) {
console.error('Error initializing Nostr Login:', ex);
}
await launchNostrLoginDialog({
startScreen: 'login-bunker-url' // TODO: Not workng as expected
});
if (window.nostr) {
this.signer = new NDKNip46Signer(ndk, remoteNpub, window.nostr);
} else {
throw new Error('Nostr Login not initialized');
}
} else {
throw new Error(`Unsupported login method: ${loginMethod}`);
}
const user = await this.signer.user();
if (user?.npub) {
const userData = await useIndexedDB().get(user.npub || "");
if (userData) {
if (!userData.encryptionKey) {
this.missingEncryptionKey = true;
}
if (
!userData.encryptedAnnotAPIAcct ||
!userData.encryptedAnnotAPIKey ||
!userData.relayUrls ||
userData.relayUrls.length === 0
) {
const missingOptionalCredentials = !userData.encryptedAnnotAPIAcct ||
!userData.encryptedAnnotAPIKey
|| !userData.relayUrls
|| userData.relayUrls.length === 0;
if (missingOptionalCredentials) {
this.missingOptionalCredentials = true;
}
}
} else {
this.missingEncryptionKey = true;
}
const explicitRelayUrls = userData?.relayUrls?.length ? userData.relayUrls : [];
ndk = new NDK({ explicitRelayUrls, signer: this.signer });
await ndk.connect();
console.log("NDK Connected..");
const resp = await this.fetchUser(user.npub);
if (resp) {
setLoginStatus(true);
toggleModal(false);
}
}
}catch (error) {
console.error("Error connecting to NDK:", error);
throw error;
}
}
I've been attempting to use the npm nostr-login package with the @nostr-dev-kit/ndk, NDKNip46Signer packages. Initializing and fetching seems to be working, but I'm having issues publishing new events. Can you help me identify what I'm doing wrong?
Console errors:
Here are some relevant snippets from my code:
Attempting to initialize:
Attempting to Publish:
The text was updated successfully, but these errors were encountered: