UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

47 lines (46 loc) 1.61 kB
import { API } from '../core/api'; import { Contact, ContactList, QueryOptions, QueryResult } from '../models'; import { ReadableStream } from 'web-streams-polyfill/ponyfill'; /** * Contacts is an API module for managing local contacts and finding contacts on the network * * @extends API */ export default class Contacts extends API { /** * Adds or updates a contact directly, usually from a search * * @param contact JSON object representing a contact * @returns Whether the operation was sucessfull */ add(address: string, contact: Contact): Promise<boolean>; /** * Retrieve information about a known contact * * @param address Address of the contact * @returns The associated contact object */ get(address: string): Promise<Contact>; /** * Retrieves a list of known contacts * @returns An array of all known contacts */ list(): Promise<ContactList>; /** * Remove a known contact * * @param address Address of the contact * @returns Whether the operation was successfull */ remove(contactId: string): Promise<boolean>; /** * Searches locally and on the network for contacts by display name, peer id, or address * * @param name Search by display name string * @param address Search by account address string * @param options Additional options to control the query * @returns A ReadableStream of QueryResult objects. * }) */ search(name?: string, address?: string, options?: QueryOptions): Promise<ReadableStream<QueryResult>>; }