nostr-tribes
Version:
Client library for using nostr tribes
64 lines (63 loc) • 1.82 kB
TypeScript
import { Event } from 'nostr-tools/core';
import { SimplePool } from 'nostr-tools';
import type { WindowNostr } from 'nostr-tools/nip07';
import { MemStore } from './util.js';
declare global {
interface Window {
nostr?: WindowNostr;
}
}
export type StampType = '+' | '0' | '-';
export type Judgement = {
[key: string]: [StampType, string, Event | undefined];
};
/** Return if this is a curate (+), ban (-) or neutral (0) stamp */
export declare function stampType(stamp: Event): StampType;
type Options = {
relays?: string[];
timeout?: number;
logfn?: (message: string) => void;
};
type MemberData = {
parents: string[];
name?: string;
avatar?: string;
nip05?: string;
};
export declare class Tribe {
event?: Event;
dtag: string;
tribename: string;
leader: string;
description?: string;
image?: string;
pool: SimplePool;
context: string;
relays: string[];
blossoms: string[];
synced: boolean;
timeout: number;
members: Map<string, MemberData>;
last_sync?: number;
logfn?: (message: string) => void;
banstore: MemStore;
constructor(tribe: string, opts?: Options);
private log;
fetchEvent(): Promise<void>;
subscribe(): Promise<void>;
sync(opts?: {
force?: boolean;
}): Promise<void>;
sync_profiles(): Promise<void>;
member(pubkey: string): boolean;
entry(pubkey: string): MemberData;
name(pubkey: string): string;
membership(pubkey: string): StampType;
get population(): number;
children(pubkey: string): string[];
bannedby(pubkey: string): string[];
judgeEvents(events: Event[]): Promise<Judgement>;
stamp_pubkey(pubkey: string, type?: StampType): Promise<void>;
stamp_event(event: Event, type?: StampType): Promise<void>;
}
export {};