Files
boris/node_modules/applesauce-accounts/dist/accounts/nostr-connect-account.js
Gigi 5d53a827e0 feat: initialize markr nostr bookmark client
- 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.
2025-10-02 07:17:07 +02:00

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);
}
}