UNPKG

@bsv/wallet-toolbox-client

Version:
82 lines 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WalletSettingsManager = exports.TESTNET_DEFAULT_SETTINGS = exports.DEFAULT_SETTINGS = void 0; const sdk_1 = require("@bsv/sdk"); const SETTINGS_BASKET = 'wallet settings'; // Defaults can be overridden as needed exports.DEFAULT_SETTINGS = { trustSettings: { trustLevel: 2, trustedCertifiers: [ { name: 'Metanet Trust Services', description: 'Registry for protocols, baskets, and certificates types', iconUrl: 'https://bsvblockchain.org/favicon.ico', identityKey: '03daf815fe38f83da0ad83b5bedc520aa488aef5cbc93a93c67a7fe60406cbffe8', trust: 4 }, { name: 'SocialCert', description: 'Certifies social media handles, phone numbers and emails', iconUrl: 'https://socialcert.net/favicon.ico', trust: 3, identityKey: '02cf6cdf466951d8dfc9e7c9367511d0007ed6fba35ed42d425cc412fd6cfd4a17' } ] }, theme: { mode: 'dark' } }; // Mapping of certifier names to their testnet identity keys const TESTNET_IDENTITY_KEYS = { 'Babbage Trust Services': '03d0b36b5c98b000ec9ffed9a2cf005e279244edf6a19cf90545cdebe873162761', IdentiCert: '036dc48522aba1705afbb43df3c04dbd1da373b6154341a875bceaa2a3e7f21528', SocialCert: '02cf6cdf466951d8dfc9e7c9367511d0007ed6fba35ed42d425cc412fd6cfd4a17' }; // Define defaults that can be imported for a testnet environment exports.TESTNET_DEFAULT_SETTINGS = { ...exports.DEFAULT_SETTINGS, trustSettings: { ...exports.DEFAULT_SETTINGS.trustSettings, trustedCertifiers: exports.DEFAULT_SETTINGS.trustSettings.trustedCertifiers.map(certifier => ({ ...certifier, // Use the testnet key if provided, otherwise fallback to the default identityKey: TESTNET_IDENTITY_KEYS[certifier.name] || certifier.identityKey })) } }; /** * Manages wallet settings */ class WalletSettingsManager { constructor(wallet, config = { defaultSettings: exports.DEFAULT_SETTINGS }) { this.wallet = wallet; this.config = config; this.kv = new sdk_1.LocalKVStore(wallet, SETTINGS_BASKET, true); } /** * Returns a user's wallet settings * * @returns - Wallet settings object */ async get() { return JSON.parse((await this.kv.get('settings', JSON.stringify(this.config.defaultSettings)))); } /** * Creates (or updates) the user's settings token. * * @param settings - The wallet settings to be stored. */ async set(settings) { await this.kv.set('settings', JSON.stringify(settings)); } /** * Deletes the user's settings token. */ async delete() { await this.kv.remove('settings'); } } exports.WalletSettingsManager = WalletSettingsManager; //# sourceMappingURL=WalletSettingsManager.js.map