mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-13 05:26:47 +00:00
21 lines
584 B
JavaScript
21 lines
584 B
JavaScript
export default () => ({
|
|
|
|
async init() {
|
|
|
|
},
|
|
|
|
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});
|
|
});
|
|
},
|
|
|
|
});
|