mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add NIP98Client
This commit is contained in:
1 file changed
+15
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user