Add docs for blossom, add nip 86 and 98 support

This commit is contained in:
Jon Staab
2025-06-10 13:18:03 -07:00
parent 90b2ab2974
commit 4cabf53c2f
13 changed files with 314 additions and 17 deletions
+42
View File
@@ -0,0 +1,42 @@
# NIP-98 HTTP Auth
Implementation of NIP-98 HTTP Authentication for authenticating HTTP requests with Nostr events.
## Functions
```typescript
// Creates an HTTP auth event for authenticating requests
export declare const makeHttpAuth: (url: string, method?: string, body?: string) => Promise<Event>
// Creates Authorization header from signed HTTP auth event
export declare const makeHttpAuthHeader: (event: SignedEvent) => string
```
## Example
```typescript
import { makeHttpAuth, makeHttpAuthHeader } from '@welshman/util'
const url = "https://api.example.com/upload"
const method = "POST"
const body = {data: "example"}
// Create HTTP auth event
const authEvent = await makeHttpAuth(url, method, JSON.stringify(body))
// Sign the auth event
const signedEvent = await signer.signEvent(authEvent)
// Create Authorization header
const authHeader = makeHttpAuthHeader(signedEvent)
// Use in fetch request
const response = await fetch(url, {
body,
method,
headers: {
"Authorization": authHeader,
"Content-Type": "application/json"
},
})
```