web


git clone https://radroots.dev/git/web.git
Log | Files | Refs | Submodules | README | LICENSE

config.ts (2014B)


      1 import { _env } from "$lib/_env";
      2 import type { AppConfigRole } from "@radroots/apps-lib-pwa/types/app";
      3 import { IDB_CONFIG_CIPHER_SQL } from "@radroots/client/idb";
      4 import { root_symbol } from "@radroots/utils";
      5 import type { NostrEventTagClient } from "@radroots/nostr";
      6 
      7 export const cfg_data = {
      8     sql_cipher: IDB_CONFIG_CIPHER_SQL
      9 } as const;
     10 
     11 export const _cfg = {
     12     role_default: `public`
     13 } as const;
     14 
     15 export const radroots_nostr_pubkey = `1f5a37bd7050cffe4dd9c35e029fa1da5c84f429de0818c9e22ecf122815e184`
     16 
     17 export const err = {
     18     nostr: {
     19         no_relays: `error.nostr.no_relays_connected`
     20     }
     21 };
     22 
     23 export const cfg_delay = {
     24     load: 321,
     25     notify: 123,
     26     mount_el: 500,
     27     nostr_relay_poll_document: 3000,
     28     entry_focus: 2000,
     29     load_notify: 3000,
     30 };
     31 
     32 export const cfg_nostr = {
     33     relay_url: _env.RADROOTS_RELAY,
     34     relay_pubkey: radroots_nostr_pubkey,
     35     relay_polling_count_max: 10,
     36 };
     37 
     38 export const cfg_nostr_client: NostrEventTagClient = {
     39     name: root_symbol,
     40     pubkey: cfg_nostr.relay_pubkey,
     41     relay: cfg_nostr.relay_url
     42 };
     43 
     44 export const cfg_datastore_key_map = {
     45     //cfg_nostr_key: "cfg:nostr:key",
     46     //cfg_profile: "cfg:profile",
     47     nostr_key: "nostr:key",
     48     eula_date: "app:eula:date",
     49 } as const;
     50 
     51 export const cfg_datastore_key_param_map = {
     52     nostr_profile: (public_key: string) => `nostr:${public_key}:profile`,
     53     radroots_profile: (public_key: string) => `radroots:${public_key}:profile`,
     54 } as const;
     55 
     56 
     57 export type ConfigData = {
     58     nostr_public_key?: string;
     59     nostr_profile?: string;
     60     role?: AppConfigRole;
     61     nip05_request?: boolean;
     62     nip05_key?: string;
     63 };
     64 
     65 export type AppData = {
     66     active_key: string;
     67     role: AppConfigRole;
     68     eula_date: string;
     69     nip05_key?: string;
     70 };
     71 
     72 export type cfg_datastore_key_obj_map_types = {
     73     cfg_data: ConfigData;
     74     app_data: AppData;
     75 }
     76 
     77 export const cfg_datastore_key_obj_map: Record<keyof cfg_datastore_key_obj_map_types, string> = {
     78     cfg_data: "cfg:data",
     79     app_data: "app:data",
     80 };