Add NIP98Client

This commit is contained in:
Alex Gleason committed 2025-09-07 17:41:39 -05:00
1 parent c32fa627e4
commit fd9aa5b683
1 file changed
+15
+15
View File
@@ -0,0 +1,15 @@
import { NostrSigner, NIP98 } from "@nostrify/nostrify";
import { N64 } from "@nostrify/nostrify/utils";
export class NIP98Client {
constructor(private signer: NostrSigner) {}
async fetch(input: string | URL | Request, init?: RequestInit) {
const request = new Request(input, init);
const template = await NIP98.template(request);
const event = await this.signer.signEvent(template);
const token = N64.encodeEvent(event);
request.headers.set("Authorization", `Nostr ${token}`);
return fetch(request);
}
}