JSLib Reference Manual / Exports / ChannelApi

Class: ChannelApi#

Channel API

Requires a Channel object to initialize. That can be a ChannelSocket, for example, or if you just need access to send commands to the channel you can use ChannelEndpoint (since “Channel” is an abstract class)

Table of contents#

Constructors#

Accessors#

Methods#

Constructors#

constructor#

new ChannelApi(channel)

Parameters#

Name

Type

channel

Channel

Accessors#

channelId#

get channelId(): undefined | string

Returns#

undefined | string

Methods#

acceptVisitor#

acceptVisitor(pubKey): Promise<unknown>

Parameters#

Name

Type

pubKey

string

Returns#

Promise<unknown>


authorize#

authorize(ownerPublicKey, serverSecret): Promise<any>

Parameters#

Name

Type

ownerPublicKey

Dictionary<any>

serverSecret

string

Returns#

Promise<any>


budd#

budd(): Promise<SBChannelHandle>

“budd” will spin a channel off an existing one. You need to provide one of the following combinations of info:

  • nothing (special case, create new channel and transfer all storage budget)

  • just storage amount (creates new channel with that amount)

  • just a target channel (moves all storage budget to that channel)

  • just keys (creates new channel with those keys and transfers all storage budget)

  • keys and storage amount (creates new channel with those keys and that storage amount)

In the first (special) case you can just call budd(), in the other cases you need to fill out the options object.

Another way to remember the above: all combinations are valid except both a target channel and assigning keys.

Note: if you’re specifying the target channel, then the return values will not include the private key (that return value will be empty).

Returns#

Promise<SBChannelHandle>

budd(options): Promise<SBChannelHandle>

Parameters#

Name

Type

options

Object

options.keys?

JsonWebKey

options.storage?

number

options.targetChannel?

string

Returns#

Promise<SBChannelHandle>


downloadData#

downloadData(): Promise<unknown>

downloadData

Returns#

Promise<unknown>


getAdminData#

getAdminData(): Promise<ChannelAdminData>

getAdminData

Returns#

Promise<ChannelAdminData>


getCapacity#

getCapacity(): Promise<any>

getCapacity

Returns#

Promise<any>


getJoinRequests#

getJoinRequests(): Promise<any>

getJoinRequests

Returns#

Promise<any>


getLastMessageTimes#

getLastMessageTimes(): Promise<unknown>

getLastMessageTimes

Returns#

Promise<unknown>


getMother#

getMother(): Promise<any>

getMother

Get the channelID from which this channel was budded. Note that this is only accessible by Owner (as well as hosting server)

Returns#

Promise<any>


getOldMessages#

getOldMessages(currentMessagesLength?, paginate?): Promise<ChannelMessage[]>

getOldMessages

Will return most recent messages from the channel.

Parameters#

Name

Type

Default value

Description

currentMessagesLength

number

100

number to fetch (default 100)

paginate

boolean

false

if true, will paginate from last request (default false) TODO: this needs to be able to check that the channel socket is ready, otherwise the keys might not be … currently before calling this, make a ready check on the socket

Returns#

Promise<ChannelMessage[]>


getStorageLimit#

getStorageLimit(): Promise<any>

getStorageLimit (current storage budget)

Returns#

Promise<any>


isLocked#

isLocked(): Promise<boolean>

isLocked

Returns#

Promise<boolean>


lock#

lock(): Promise<unknown>

Returns#

Promise<unknown>


ownerKeyRotation#

ownerKeyRotation(): void

Returns#

void


postPubKey#

postPubKey(_exportable_pubKey): Promise<{ success: boolean }>

Parameters#

Name

Type

_exportable_pubKey

JsonWebKey

Returns#

Promise<{ success: boolean }>


setMOTD#

setMOTD(motd): Promise<any>

Set message of the day

Parameters#

Name

Type

motd

string

Returns#

Promise<any>


storageRequest#

storageRequest(byteLength): Promise<Dictionary<any>>

Parameters#

Name

Type

byteLength

number

Returns#

Promise<Dictionary<any>>


updateCapacity#

updateCapacity(capacity): Promise<any>

Update (set) the capacity of the channel; Owner only

Parameters#

Name

Type

capacity

number

Returns#

Promise<any>


uploadChannel#

uploadChannel(channelData): Promise<any>

Parameters#

Name

Type

channelData

ChannelData

Returns#

Promise<any>