mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +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.
93 lines
4.0 KiB
TypeScript
93 lines
4.0 KiB
TypeScript
/**
|
|
* Audited & minimal JS implementation of
|
|
* [BIP39 mnemonic phrases](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).
|
|
* @module
|
|
* @example
|
|
```js
|
|
import * as bip39 from '@scure/bip39';
|
|
import { wordlist } from '@scure/bip39/wordlists/english';
|
|
const mn = bip39.generateMnemonic(wordlist);
|
|
console.log(mn);
|
|
const ent = bip39.mnemonicToEntropy(mn, wordlist)
|
|
bip39.entropyToMnemonic(ent, wordlist);
|
|
bip39.validateMnemonic(mn, wordlist);
|
|
await bip39.mnemonicToSeed(mn, 'password');
|
|
bip39.mnemonicToSeedSync(mn, 'password');
|
|
|
|
// Wordlists
|
|
import { wordlist as czech } from '@scure/bip39/wordlists/czech';
|
|
import { wordlist as english } from '@scure/bip39/wordlists/english';
|
|
import { wordlist as french } from '@scure/bip39/wordlists/french';
|
|
import { wordlist as italian } from '@scure/bip39/wordlists/italian';
|
|
import { wordlist as japanese } from '@scure/bip39/wordlists/japanese';
|
|
import { wordlist as korean } from '@scure/bip39/wordlists/korean';
|
|
import { wordlist as portuguese } from '@scure/bip39/wordlists/portuguese';
|
|
import { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese';
|
|
import { wordlist as spanish } from '@scure/bip39/wordlists/spanish';
|
|
import { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese';
|
|
```
|
|
*/
|
|
/**
|
|
* Generate x random words. Uses Cryptographically-Secure Random Number Generator.
|
|
* @param wordlist imported wordlist for specific language
|
|
* @param strength mnemonic strength 128-256 bits
|
|
* @example
|
|
* generateMnemonic(wordlist, 128)
|
|
* // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
|
|
*/
|
|
export declare function generateMnemonic(wordlist: string[], strength?: number): string;
|
|
/**
|
|
* Reversible: Converts mnemonic string to raw entropy in form of byte array.
|
|
* @param mnemonic 12-24 words
|
|
* @param wordlist imported wordlist for specific language
|
|
* @example
|
|
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
|
|
* mnemonicToEntropy(mnem, wordlist)
|
|
* // Produces
|
|
* new Uint8Array([
|
|
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
|
|
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
|
|
* ])
|
|
*/
|
|
export declare function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array;
|
|
/**
|
|
* Reversible: Converts raw entropy in form of byte array to mnemonic string.
|
|
* @param entropy byte array
|
|
* @param wordlist imported wordlist for specific language
|
|
* @returns 12-24 words
|
|
* @example
|
|
* const ent = new Uint8Array([
|
|
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
|
|
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
|
|
* ]);
|
|
* entropyToMnemonic(ent, wordlist);
|
|
* // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
|
|
*/
|
|
export declare function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string;
|
|
/**
|
|
* Validates mnemonic for being 12-24 words contained in `wordlist`.
|
|
*/
|
|
export declare function validateMnemonic(mnemonic: string, wordlist: string[]): boolean;
|
|
/**
|
|
* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
|
|
* @param mnemonic 12-24 words
|
|
* @param passphrase string that will additionally protect the key
|
|
* @returns 64 bytes of key data
|
|
* @example
|
|
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
|
|
* await mnemonicToSeed(mnem, 'password');
|
|
* // new Uint8Array([...64 bytes])
|
|
*/
|
|
export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
|
|
/**
|
|
* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
|
|
* @param mnemonic 12-24 words
|
|
* @param passphrase string that will additionally protect the key
|
|
* @returns 64 bytes of key data
|
|
* @example
|
|
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
|
|
* mnemonicToSeedSync(mnem, 'password');
|
|
* // new Uint8Array([...64 bytes])
|
|
*/
|
|
export declare function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array;
|