mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Use NIP98Client from Nostrify
This commit is contained in:
5 files changed
+19
-34
No files matched your search
Generated
+12
-12
@@ -13,8 +13,8 @@
|
||||
"@hookform/resolvers": "^3.9.0",
|
||||
"@isomorphic-git/lightning-fs": "^4.6.2",
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.4",
|
||||
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.8",
|
||||
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.5",
|
||||
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.9",
|
||||
"@radix-ui/react-accordion": "^1.2.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||
@@ -1223,9 +1223,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jsr/nostrify__nostrify": {
|
||||
"version": "0.46.4",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.46.4.tgz",
|
||||
"integrity": "sha512-bYuYkw9+jnHIDEJD6i+w0p8xV1oBLr1RF5rS3qF2yTz1b8i50dXKMO2cLObjalAAO3RYbnib3l85t1ZgWLCzAA==",
|
||||
"version": "0.46.5",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.46.5.tgz",
|
||||
"integrity": "sha512-l81N0o1A4WKAnOhq600ASDLxZbwzFZzUjhAkARPNFbWkXmEssVvXEQXyyoy1s7lboK45iZCijW0Bia7NHXmSug==",
|
||||
"dependencies": {
|
||||
"@jsr/nostrify__types": "^0.36.0",
|
||||
"@jsr/scure__base": "^1.2.4",
|
||||
@@ -1353,9 +1353,9 @@
|
||||
},
|
||||
"node_modules/@nostrify/nostrify": {
|
||||
"name": "@jsr/nostrify__nostrify",
|
||||
"version": "0.46.4",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.46.4.tgz",
|
||||
"integrity": "sha512-bYuYkw9+jnHIDEJD6i+w0p8xV1oBLr1RF5rS3qF2yTz1b8i50dXKMO2cLObjalAAO3RYbnib3l85t1ZgWLCzAA==",
|
||||
"version": "0.46.5",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.46.5.tgz",
|
||||
"integrity": "sha512-l81N0o1A4WKAnOhq600ASDLxZbwzFZzUjhAkARPNFbWkXmEssVvXEQXyyoy1s7lboK45iZCijW0Bia7NHXmSug==",
|
||||
"dependencies": {
|
||||
"@jsr/nostrify__types": "^0.36.0",
|
||||
"@jsr/scure__base": "^1.2.4",
|
||||
@@ -1368,11 +1368,11 @@
|
||||
},
|
||||
"node_modules/@nostrify/react": {
|
||||
"name": "@jsr/nostrify__react",
|
||||
"version": "0.2.8",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.8.tgz",
|
||||
"integrity": "sha512-9sCsMm1uwuGWU+NhgFf6LS/4JzeRXnGOz+ocA5X3/ncvxZhidPOEAU39QyygRLFo/JYG8OC5wlyH8w0Uejq+VQ==",
|
||||
"version": "0.2.9",
|
||||
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.9.tgz",
|
||||
"integrity": "sha512-S19YP9adasszJbxgdIeC/4KXtZsAs9nf8I/2ptjr7pipyZWx8HykjjFE5pahj2TNMFc0/pEErcYpxGBg5t2n6Q==",
|
||||
"dependencies": {
|
||||
"@jsr/nostrify__nostrify": "^0.46.4",
|
||||
"@jsr/nostrify__nostrify": "^0.46.5",
|
||||
"nostr-tools": "^2.13.0",
|
||||
"react": "^18.0.0"
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
"@hookform/resolvers": "^3.9.0",
|
||||
"@isomorphic-git/lightning-fs": "^4.6.2",
|
||||
"@mozilla/readability": "^0.6.0",
|
||||
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.4",
|
||||
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.8",
|
||||
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.46.5",
|
||||
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.9",
|
||||
"@radix-ui/react-accordion": "^1.2.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user