something

This commit is contained in:
fiatjaf
2025-07-19 10:41:48 -03:00
parent de1cf0ed60
commit 719462f041
5 changed files with 53 additions and 18 deletions

View File

@@ -1,21 +1,13 @@
/* global WebSocket */
import { verifyEvent } from './pure.ts'
import { AbstractRelay } from './abstract-relay.ts'
import { AbstractRelay, WebSocketBaseConn } from './abstract-relay.ts'
var _WebSocket: typeof WebSocket
try {
_WebSocket = WebSocket
} catch {}
export function useWebSocketImplementation(websocketImplementation: any) {
_WebSocket = websocketImplementation
}
class BrowserWs extends WebSocket implements WebSocketBase, WebSocketBaseConn {}
export class Relay extends AbstractRelay {
constructor(url: string) {
super(url, { verifyEvent, websocketImplementation: _WebSocket })
super(url, { verifyEvent, websocketImplementation: BrowserWs })
}
static async connect(url: string): Promise<Relay> {
@@ -25,6 +17,4 @@ export class Relay extends AbstractRelay {
}
}
export type RelayRecord = Record<string, { read: boolean; write: boolean }>
export * from './abstract-relay.ts'