mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-28 07:43:18 +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});
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -68,6 +68,10 @@
|
||||
|
||||
{{--@include('components.layouts.partials.notification-buttons')--}}
|
||||
|
||||
|
||||
<x-button label="Mit Nostr verbinden" @click="openNostrLogin"
|
||||
x-show="!$store.nostr.user"/>
|
||||
|
||||
<!-- Info button -->
|
||||
<div class="relative inline-flex" x-data="{ open: false }">
|
||||
<button
|
||||
@@ -162,5 +166,24 @@
|
||||
</div>
|
||||
</div>
|
||||
@livewireScriptConfig
|
||||
<script>
|
||||
window.wnjParams = {
|
||||
position: 'bottom',
|
||||
// The only accepted value is 'bottom', default is top
|
||||
accent: 'orange',
|
||||
// Supported values: cyan (default), green, purple, red, orange, neutral, stone
|
||||
startHidden: false,
|
||||
// If the host page has a button that call `getPublicKey` to start a
|
||||
// login procedure, the minimized widget can be hidden until connected
|
||||
compactMode: false,
|
||||
// Show the minimized widget in a compact form
|
||||
disableOverflowFix: false,
|
||||
// If the host page on mobile has an horizontal scrolling, the floating
|
||||
// element/modal are pushed to the extreme right/bottom and exit the
|
||||
// viewport. A style is injected in the html/body elements fix this.
|
||||
// This option permit to disable this default behavior
|
||||
}
|
||||
</script>
|
||||
<script src="{{ asset('dist/window.nostr.min.js.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -20,7 +20,7 @@ mount(function() {
|
||||
$isNotCurrentSubItem = 'block text-gray-500/90 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition truncate';
|
||||
@endphp
|
||||
|
||||
<!-- Sidebar backdrop (mobile only) -->
|
||||
<!-- Sidebar backdrop (mobile only) -->
|
||||
<div
|
||||
class="fixed inset-0 bg-gray-900 bg-opacity-30 z-40 lg:hidden lg:z-auto transition-opacity duration-200"
|
||||
:class="sidebarOpen ? 'opacity-100' : 'opacity-0 pointer-events-none'"
|
||||
@@ -57,7 +57,7 @@ mount(function() {
|
||||
$activeItemClass = 'block text-amber-500 transition truncate';
|
||||
@endphp
|
||||
|
||||
<!-- Links -->
|
||||
<!-- Links -->
|
||||
<div class="space-y-8">
|
||||
{{--@include('components.layouts.navigation.meetups')--}}
|
||||
@include('components.layouts.navigation.association')
|
||||
|
||||
Reference in New Issue
Block a user