mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 07:34:28 +01:00
- Add project structure with TypeScript, React, and Vite - Implement nostr authentication using browser extension (NIP-07) - Add NIP-51 compliant bookmark fetching and display - Create minimal UI with login and bookmark components - Integrate applesauce-core and applesauce-react libraries - Add responsive styling with dark/light mode support - Include comprehensive README with setup instructions This is a minimal MVP for a nostr bookmark client that allows users to view their bookmarks according to NIP-51 specification.
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import { NostrConnectSigner, SimpleSigner } from "applesauce-signers";
|
|
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
|
|
import { BaseAccount } from "../account.js";
|
|
/** An account type for NIP-46 signers */
|
|
export class NostrConnectAccount extends BaseAccount {
|
|
static type = "nostr-connect";
|
|
toJSON() {
|
|
if (!this.signer.remote)
|
|
throw new Error("Cant save NostrConnectAccount when not initialized");
|
|
return super.saveCommonFields({
|
|
signer: {
|
|
clientKey: bytesToHex(this.signer.signer.key),
|
|
remote: this.signer.remote,
|
|
relays: this.signer.relays,
|
|
},
|
|
});
|
|
}
|
|
static fromJSON(json) {
|
|
const signer = new NostrConnectSigner({
|
|
relays: json.signer.relays,
|
|
pubkey: json.pubkey,
|
|
remote: json.signer.remote,
|
|
signer: new SimpleSigner(hexToBytes(json.signer.clientKey)),
|
|
});
|
|
const account = new NostrConnectAccount(json.pubkey, signer);
|
|
return super.loadCommonFields(account, json);
|
|
}
|
|
}
|