Re-write net docs
This commit is contained in:
@@ -1,19 +1,11 @@
|
||||
import EventEmitter from "events"
|
||||
import {on, poll, call} from "@welshman/lib"
|
||||
import {SignedEvent, StampedEvent} from "@welshman/util"
|
||||
import {makeEvent, CLIENT_AUTH} from "@welshman/util"
|
||||
import {makeRelayAuth} from "@welshman/util"
|
||||
import {isRelayAuth, isClientAuth, isRelayOk, RelayMessage} from "./message.js"
|
||||
import {Socket, SocketStatus, SocketEvent} from "./socket.js"
|
||||
import {Unsubscriber} from "./util.js"
|
||||
|
||||
export const makeAuthEvent = (url: string, challenge: string) =>
|
||||
makeEvent(CLIENT_AUTH, {
|
||||
tags: [
|
||||
["relay", url],
|
||||
["challenge", challenge],
|
||||
],
|
||||
})
|
||||
|
||||
export enum AuthStatus {
|
||||
None = "auth:status:none",
|
||||
Requested = "auth:status:requested",
|
||||
@@ -108,7 +100,7 @@ export class AuthState extends EventEmitter {
|
||||
|
||||
this.setStatus(AuthStatus.PendingSignature)
|
||||
|
||||
const template = makeAuthEvent(this.socket.url, this.challenge)
|
||||
const template = makeRelayAuth(this.socket.url, this.challenge)
|
||||
const event = await sign(template)
|
||||
|
||||
if (event) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import {makeEvent} from "./Events.js"
|
||||
import {CLIENT_AUTH} from "./Kinds.js"
|
||||
|
||||
export const makeRelayAuth = (url: string, challenge: string) =>
|
||||
makeEvent(CLIENT_AUTH, {
|
||||
tags: [
|
||||
["relay", url],
|
||||
["challenge", challenge],
|
||||
],
|
||||
})
|
||||
@@ -7,6 +7,7 @@ export * from "./Handler.js"
|
||||
export * from "./Kinds.js"
|
||||
export * from "./Links.js"
|
||||
export * from "./List.js"
|
||||
export * from "./Nip42.js"
|
||||
export * from "./Nip86.js"
|
||||
export * from "./Nip98.js"
|
||||
export * from "./Profile.js"
|
||||
|
||||
Reference in New Issue
Block a user