mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
15 lines
536 B
TypeScript
15 lines
536 B
TypeScript
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);
|
|
}
|
|
} |