mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-20 13:20:16 +00:00
Remove nostr-login dependency and update lockfile.
This commit is contained in:
@@ -1,48 +1,20 @@
|
||||
import {init as initNostrLogin} from 'nostr-login';
|
||||
|
||||
export default () => ({
|
||||
|
||||
openNostrLogin() {
|
||||
window.nostr.getPublicKey();
|
||||
async init() {
|
||||
|
||||
},
|
||||
|
||||
async init() {
|
||||
await initNostrLogin({
|
||||
methods: ['connect', 'extension'],
|
||||
onAuth: async (npub, options) => {
|
||||
console.log('User logged in', npub, options);
|
||||
console.log('type', options.method);
|
||||
if (options.method === 'readOnly') {
|
||||
console.log('User logged in as read-only');
|
||||
return;
|
||||
}
|
||||
if (options.method === undefined) {
|
||||
Alpine.store('nostr', {user: null});
|
||||
this.$dispatch('nostrLoggedOut', {});
|
||||
return;
|
||||
}
|
||||
const pubkey = await window.nostr.getPublicKey();
|
||||
// fetch profile from /api/nostr/profile/{publicKey}
|
||||
fetch('/api/nostr/profile/' + pubkey)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Profile fetched', data);
|
||||
// store the profile in AlpineJS store
|
||||
Alpine.store('nostr', {user: data});
|
||||
this.$dispatch('nostrLoggedIn', {pubkey: data.pubkey});
|
||||
document.addEventListener('nlAuth', (e) => {
|
||||
// type is login, signup or logout
|
||||
if (e.detail.type === 'login' || e.detail.type === 'signup') {
|
||||
|
||||
} else {
|
||||
console.log('User logged out')
|
||||
Alpine.store('nostr', {user: null});
|
||||
this.$dispatch('nostrLoggedOut', {});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
async openNostrLogin() {
|
||||
const pubkey = await window.nostr.getPublicKey();
|
||||
// fetch profile from /api/nostr/profile/{publicKey}
|
||||
fetch('/api/nostr/profile/' + pubkey)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Profile fetched', data);
|
||||
// store the profile in AlpineJS store
|
||||
Alpine.store('nostr', {user: data});
|
||||
this.$dispatch('nostrLoggedIn', {pubkey: data.pubkey});
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user