fix(nip98): Add support for HEAD, PUT, CONNECT, OPTIONS, TRACE and PATCH http methods

This PR adds common HTTP methods (as listed on https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)
This commit is contained in:
Pierre Buyle
2023-08-14 19:02:30 -04:00
committed by fiatjaf_
parent d13eecad4a
commit 2431896921

View File

@@ -10,7 +10,14 @@ 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 '
@@ -32,7 +39,7 @@ export async function getToken(
): Promise<string> {
if (!loginUrl || !httpMethod)
throw new Error('Missing loginUrl or httpMethod')
if (httpMethod !== HttpMethod.Get && httpMethod !== HttpMethod.Post)
if (!httpMethod in HttpMethod)
throw new Error('Unknown httpMethod')
const event = getBlankEvent(Kind.HttpAuth)