Use NIP98Client from Nostrify

This commit is contained in:
Alex Gleason committed 2025-09-15 16:09:45 -05:00
1 parent dedb9c7f55
commit 11522c8426
5 files changed
+19 -34

No files matched your search

-15
View File
@@ -1,15 +0,0 @@
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);
}
}
+3 -3
View File
@@ -1,5 +1,5 @@
import OpenAI from 'openai';
import { NIP98Client } from './NIP98Client';
import { NIP98Client } from '@nostrify/nostrify';
import type { AIConnection } from '@/contexts/AISettingsContext';
import type { NUser } from '@nostrify/react/login';
@@ -17,8 +17,8 @@ export function createAIClient(connection: AIConnection, user?: NUser): OpenAI {
// If Nostr authentication is required and we have a user, use NIP-98
if (connection.nostr && user?.signer) {
const nip98Client = new NIP98Client(user.signer);
const nip98Client = new NIP98Client({ signer: user.signer });
return new OpenAI({
...baseConfig,
fetch: (input, init) => nip98Client.fetch(input, init),
+2 -2
View File
@@ -1,5 +1,5 @@
import JSZip from 'jszip';
import { NIP98Client } from './NIP98Client';
import { NIP98Client } from '@nostrify/nostrify';
import type { NostrSigner } from '@nostrify/nostrify';
import type { JSRuntimeFS } from './JSRuntime';
@@ -56,7 +56,7 @@ export async function deployProject(options: DeployOptions): Promise<DeployResul
formData.append('file', zipBlob, `${projectId}.zip`);
// Create NIP-98 authenticated client and deploy
const nip98Client = new NIP98Client(signer);
const nip98Client = new NIP98Client({ signer });
const response = await nip98Client.fetch(deployUrl, {
method: 'POST',
body: formData,