diff --git a/package-lock.json b/package-lock.json index 7157825..1ae87dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,8 @@ "@tailwindcss/forms": "^0.5.10", "@tailwindcss/typography": "^0.5.16", "@tailwindcss/vite": "^4.0.12", - "@types/node": "^22.13.10", + "@types/node": "^22.18.1", + "@types/qrcode": "^1.5.5", "@types/rollup-plugin-visualizer": "^4.2.3", "@vitejs/plugin-vue": "^5.2.1", "@vue/tsconfig": "^0.7.0", @@ -5078,13 +5079,23 @@ } }, "node_modules/@types/node": { - "version": "22.13.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz", - "integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", + "version": "22.18.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.1.tgz", + "integrity": "sha512-rzSDyhn4cYznVG+PCzGe1lwuMYJrcBS1fc3JqSa2PvtABwWo+dZ1ij5OVok3tqfpEBCBoaR4d7upFJk73HRJDw==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.20.0" + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/qrcode": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", + "integrity": "sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" } }, "node_modules/@types/resolve": { @@ -13616,9 +13627,9 @@ } }, "node_modules/undici-types": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", - "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 7b20497..ae6f91e 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "@tailwindcss/forms": "^0.5.10", "@tailwindcss/typography": "^0.5.16", "@tailwindcss/vite": "^4.0.12", - "@types/node": "^22.13.10", + "@types/node": "^22.18.1", + "@types/qrcode": "^1.5.5", "@types/rollup-plugin-visualizer": "^4.2.3", "@vitejs/plugin-vue": "^5.2.1", "@vue/tsconfig": "^0.7.0", diff --git a/src/composables/useNostrChat.ts b/src/composables/useNostrChat.ts index a01ab5f..b1372b8 100644 --- a/src/composables/useNostrChat.ts +++ b/src/composables/useNostrChat.ts @@ -109,7 +109,7 @@ export function useNostrChat() { } // Set up periodic cleanup - let cleanupInterval: NodeJS.Timeout | null = null + let cleanupInterval: number | null = null // Clean up resources const cleanup = () => { @@ -375,7 +375,7 @@ export function useNostrChat() { // Set up periodic cleanup of malformed messages if (!cleanupInterval) { - cleanupInterval = setInterval(cleanupMalformedMessages, 5 * 60 * 1000) // Every 5 minutes + cleanupInterval = setInterval(cleanupMalformedMessages, 5 * 60 * 1000) as unknown as number // Every 5 minutes console.log('Set up periodic cleanup of malformed messages') } diff --git a/src/composables/useNostrclientHub.ts b/src/composables/useNostrclientHub.ts index f675a0a..d12debb 100644 --- a/src/composables/useNostrclientHub.ts +++ b/src/composables/useNostrclientHub.ts @@ -129,12 +129,12 @@ export function useNostrclientHub() { connectionStatus.value = 'disconnected' }) - nostrclientHub.on('error', (err) => { + nostrclientHub.on('error', (err: any) => { error.value = err connectionStatus.value = 'error' }) - nostrclientHub.on('connectionError', (err) => { + nostrclientHub.on('connectionError', (err: any) => { error.value = err connectionStatus.value = 'error' }) @@ -144,19 +144,19 @@ export function useNostrclientHub() { connectionStatus.value = 'error' }) - nostrclientHub.on('event', ({ subscriptionId, event }) => { + nostrclientHub.on('event', ({ subscriptionId, event }: any) => { console.log('Received event for subscription:', subscriptionId, event.id) }) - nostrclientHub.on('eose', ({ subscriptionId }) => { + nostrclientHub.on('eose', ({ subscriptionId }: any) => { console.log('EOSE received for subscription:', subscriptionId) }) - nostrclientHub.on('notice', ({ message }) => { + nostrclientHub.on('notice', ({ message }: any) => { console.log('Notice from nostrclient:', message) }) - nostrclientHub.on('eventPublished', ({ eventId }) => { + nostrclientHub.on('eventPublished', ({ eventId }: any) => { console.log('Event published successfully:', eventId) }) } diff --git a/src/composables/useTicketPurchase.ts b/src/composables/useTicketPurchase.ts index e6bd52d..269b26c 100644 --- a/src/composables/useTicketPurchase.ts +++ b/src/composables/useTicketPurchase.ts @@ -144,7 +144,7 @@ export function useTicketPurchase() { // Start payment status check async function startPaymentStatusCheck(eventId: string, hash: string) { isPaymentPending.value = true - let checkInterval: NodeJS.Timeout | null = null + let checkInterval: number | null = null const checkPayment = async () => { try { @@ -174,7 +174,7 @@ export function useTicketPurchase() { await checkPayment() // Then check every 2 seconds - checkInterval = setInterval(checkPayment, 2000) + checkInterval = setInterval(checkPayment, 2000) as unknown as number } // Stop payment status check diff --git a/src/lib/nostr/nostrclientHub.ts b/src/lib/nostr/nostrclientHub.ts index 300f879..e37d189 100644 --- a/src/lib/nostr/nostrclientHub.ts +++ b/src/lib/nostr/nostrclientHub.ts @@ -1,6 +1,31 @@ -import { EventEmitter } from 'events' import type { Filter, Event } from 'nostr-tools' +// Simple EventEmitter for browser compatibility +class EventEmitter { + private events: { [key: string]: Function[] } = {} + + on(event: string, listener: Function) { + if (!this.events[event]) { + this.events[event] = [] + } + this.events[event].push(listener) + } + + emit(event: string, ...args: any[]) { + if (this.events[event]) { + this.events[event].forEach(listener => listener(...args)) + } + } + + removeAllListeners(event?: string) { + if (event) { + delete this.events[event] + } else { + this.events = {} + } + } +} + export interface NostrclientConfig { url: string privateKey?: string // For private WebSocket endpoint @@ -25,7 +50,7 @@ export class NostrclientHub extends EventEmitter { private ws: WebSocket | null = null private config: NostrclientConfig private subscriptions: Map = new Map() - private reconnectInterval?: NodeJS.Timeout + private reconnectInterval?: number private reconnectAttempts = 0 private readonly maxReconnectAttempts = 5 private readonly reconnectDelay = 5000 @@ -324,7 +349,7 @@ export class NostrclientHub extends EventEmitter { this.reconnectInterval = setTimeout(async () => { await this.connect() - }, delay) + }, delay) as unknown as number } } diff --git a/src/lib/nostr/relayHub.ts b/src/lib/nostr/relayHub.ts index e63f161..d4f3dee 100644 --- a/src/lib/nostr/relayHub.ts +++ b/src/lib/nostr/relayHub.ts @@ -63,8 +63,8 @@ export class RelayHub extends EventEmitter { private connectedRelays: Map = new Map() private subscriptions: Map = new Map() public isInitialized = false - private reconnectInterval?: NodeJS.Timeout - private healthCheckInterval?: NodeJS.Timeout + private reconnectInterval?: number + private healthCheckInterval?: number private mobileVisibilityHandler?: () => void // Connection state @@ -400,7 +400,7 @@ export class RelayHub extends EventEmitter { this.reconnectInterval = setTimeout(async () => { await this.connect() - }, this.reconnectDelay) + }, this.reconnectDelay) as unknown as number } /** @@ -413,7 +413,7 @@ export class RelayHub extends EventEmitter { this.healthCheckInterval = setInterval(() => { this.performHealthCheck() - }, this.healthCheckIntervalMs) + }, this.healthCheckIntervalMs) as unknown as number } /** diff --git a/src/lib/services/paymentMonitor.ts b/src/lib/services/paymentMonitor.ts index 451bca3..395bfb4 100644 --- a/src/lib/services/paymentMonitor.ts +++ b/src/lib/services/paymentMonitor.ts @@ -27,7 +27,7 @@ class PaymentMonitorService { error: null }) - private monitoringInterval: NodeJS.Timeout | null = null + private monitoringInterval: number | null = null private updateCallbacks: Map void> = new Map() // Computed properties @@ -98,7 +98,7 @@ class PaymentMonitorService { // Set up interval for periodic checks this.monitoringInterval = setInterval(async () => { await this.checkAllPayments() - }, 30000) // Check every 30 seconds + }, 30000) as unknown as number // Check every 30 seconds } /**