mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 16:48:50 +00:00
get rid of httpmethod enum.
This commit is contained in:
16
nip98.ts
16
nip98.ts
@@ -8,18 +8,6 @@ import {
|
|||||||
} from './event'
|
} from './event'
|
||||||
import {utf8Decoder, utf8Encoder} from './utils'
|
import {utf8Decoder, utf8Encoder} from './utils'
|
||||||
|
|
||||||
enum HttpMethod {
|
|
||||||
Get = 'get',
|
|
||||||
Head = 'head',
|
|
||||||
Post = 'post'
|
|
||||||
Put = 'put'
|
|
||||||
Delete = 'delete'
|
|
||||||
Connect = 'connect'
|
|
||||||
Options = 'options'
|
|
||||||
Trace = 'trace'
|
|
||||||
Patch = 'patch'
|
|
||||||
}
|
|
||||||
|
|
||||||
const _authorizationScheme = 'Nostr '
|
const _authorizationScheme = 'Nostr '
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +19,7 @@ const _authorizationScheme = 'Nostr '
|
|||||||
*/
|
*/
|
||||||
export async function getToken(
|
export async function getToken(
|
||||||
loginUrl: string,
|
loginUrl: string,
|
||||||
httpMethod: HttpMethod | string,
|
httpMethod: string,
|
||||||
sign: <K extends number = number>(
|
sign: <K extends number = number>(
|
||||||
e: EventTemplate<K>
|
e: EventTemplate<K>
|
||||||
) => Promise<Event<K>> | Event<K>,
|
) => Promise<Event<K>> | Event<K>,
|
||||||
@@ -39,8 +27,6 @@ export async function getToken(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!loginUrl || !httpMethod)
|
if (!loginUrl || !httpMethod)
|
||||||
throw new Error('Missing loginUrl or httpMethod')
|
throw new Error('Missing loginUrl or httpMethod')
|
||||||
if (!httpMethod in HttpMethod)
|
|
||||||
throw new Error('Unknown httpMethod')
|
|
||||||
|
|
||||||
const event = getBlankEvent(Kind.HttpAuth)
|
const event = getBlankEvent(Kind.HttpAuth)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user