From 2431896921cc8d62b32af77d5089305e6f6e74b5 Mon Sep 17 00:00:00 2001 From: Pierre Buyle Date: Mon, 14 Aug 2023 19:02:30 -0400 Subject: [PATCH] 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) --- nip98.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nip98.ts b/nip98.ts index b3138e8..4fcdd39 100644 --- a/nip98.ts +++ b/nip98.ts @@ -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 { 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)