mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
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:
9
nip98.ts
9
nip98.ts
@@ -10,7 +10,14 @@ import {utf8Decoder, utf8Encoder} from './utils'
|
|||||||
|
|
||||||
enum HttpMethod {
|
enum HttpMethod {
|
||||||
Get = 'get',
|
Get = 'get',
|
||||||
|
Head = 'head',
|
||||||
Post = 'post'
|
Post = 'post'
|
||||||
|
Put = 'put'
|
||||||
|
Delete = 'delete'
|
||||||
|
Connect = 'connect'
|
||||||
|
Options = 'options'
|
||||||
|
Trace = 'trace'
|
||||||
|
Patch = 'patch'
|
||||||
}
|
}
|
||||||
|
|
||||||
const _authorizationScheme = 'Nostr '
|
const _authorizationScheme = 'Nostr '
|
||||||
@@ -32,7 +39,7 @@ 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 !== HttpMethod.Get && httpMethod !== HttpMethod.Post)
|
if (!httpMethod in HttpMethod)
|
||||||
throw new Error('Unknown httpMethod')
|
throw new Error('Unknown httpMethod')
|
||||||
|
|
||||||
const event = getBlankEvent(Kind.HttpAuth)
|
const event = getBlankEvent(Kind.HttpAuth)
|
||||||
|
|||||||
Reference in New Issue
Block a user