raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
67 lines (66 loc) • 2.57 kB
TypeScript
import type { OperatorFunction } from 'rxjs';
import type { RaidenAction } from '../actions';
import { Capabilities } from '../constants';
import type { Address } from '../utils/types';
import { matrixPresence } from './actions';
import type { Caps } from './types';
/**
* Extract the address in a matrix userId and returns it, or undefined it none
*
* @param userId - matrix user identifier
* @returns address contained in userId
*/
export declare function getAddressFromUserId(userId: string): Address | undefined;
/**
* Stringify a caps mapping to a caps url
* E.g.'mxc://raiden.network/cap?k1=true&k2=v2&k2=v3&k4=null&k5=123'
*
* @param caps - Capabilities object/mapping
* @returns stringified version of caps
*/
export declare function stringifyCaps(caps: Caps): string;
/**
* Parse a caps string in the format 'mxc://raiden.network/cap?k1=true&k2=v2&k2=v3&k4=null&k5=123'
* to a { k1: true, k2: ['v2','v3'], k4: null, k5: 123 } object
*
* @param caps - caps string
* @returns Caps mapping object
*/
export declare function parseCaps(caps?: string | null): Caps | undefined;
/**
* @param caps - Our or partner caps object (possibly empty/undefined)
* @param cap - Cap to fetch from
* @returns Specified capability, with proper fallback
*/
export declare function getCap<C extends Capabilities>(caps: Caps | undefined | null, cap: C): Caps[C];
/**
* Return addresses sorted in lexical order
*
* @param addresses - Addresses to sort
* @returns Addresses sorted in lexical order
*/
export declare function getSortedAddresses<A extends Address[]>(...addresses: A): A;
/**
* Aggregates seen presence updates by userId
*
* @returns custom operator mapping from stream of RaidenActions to userId-presences dict
*/
export declare function getPresencesByUserId(): OperatorFunction<RaidenAction, {
[userId: string]: matrixPresence.success;
}>;
/**
* Aggregates seen presence updates by online addresses (afawk)
*
* @returns custom operator mapping from stream of RaidenActions to address-presence dict
*/
export declare function getPresencesByAddress(): OperatorFunction<RaidenAction, {
[address: string]: matrixPresence.success;
}>;
/**
* Check if given presence is from an online partner which is another Light Client
* For now, this checks peer is online (known presence) and has Capabilities.DELIVERY set to 0
*
* @param presence - optional presence update
* @returns true if partner is online and is another light-client
*/
export declare function peerIsOnlineLC(presence: matrixPresence.success | undefined): boolean;