Skip to content

Latest commit

 

History

History
627 lines (446 loc) · 22.7 KB

DOCUMENTATION.md

File metadata and controls

627 lines (446 loc) · 22.7 KB

Classes

State : State

Class representing the actual state of a stream

Mode

Class representing the different modes of a stream

Stream : Stream

Class representing the actual state of a stream

Message

Class representing the a MAM message

Provider : Provider

Class representing the interface of a Provider

State : State

Class representing the actual state of a stream

Kind: global class

new State(seed, root, security, mode, sideKey)

the created state

Param Type Default Description
seed string | null null The seed of the state
root string | null null The index root of the stream
security int 2 the security level of the stream
mode string the mode of the stream
sideKey string | null null optionally the sideKey for encrypting and decrypting messages

state.MamState : object

– the state formatted as mam.client.js compatible object

Kind: instance property of State

state.MamState

Kind: instance property of State

Param Type Description
mamState object the state object returned by the mam.client.js library

state.Subscribed : array

  • subscribed channels (not used in this implementation)

Kind: instance property of State

state.Channel : object

Channel - the channel object of this state

Kind: instance property of State

state.Seed : string

the seed used in this state

Kind: instance property of State

state.Seed

Kind: instance property of State

Param Type Description
value string set the seed that should be used with this state

state.Root : string

the index root of this state

Kind: instance property of State

state.Root

Kind: instance property of State

Param Type Description
value string set the index root of this state

state.NextRoot : string

the next root used for attatching new messages

Kind: instance property of State

state.NextRoot

Kind: instance property of State

Param Type Description
value string set the next root used for attatching new messages

state.Security : int

the security level of this tate

Kind: instance property of State

state.Security

Kind: instance property of State

Param Type Description
value int set the security level of this state

state.Mode : string

the mode of this state

Kind: instance property of State

state.Mode

Kind: instance property of State

Param Type Description
value string set the mode of this state

state.SideKey : string | null

the optional sideKey for encrypting or decrypting messages

Kind: instance property of State

state.SideKey

Kind: instance property of State

Param Type Description
value string | null set the optional sideKey for encrypting or decrypting messages

state.Start : int

the start of this state

Kind: instance property of State

state.Start

Kind: instance property of State

Param Type Description
value int set the start of this state

state.Index : int

the index of this state

Kind: instance property of State

state.Index

Kind: instance property of State

Param Type Description
value int set the index of this state

state.Count : int

the count of this state

Kind: instance property of State

state.Count

Kind: instance property of State

Param Type Description
value int set the count of this state

state.NextCount : int

the nextCount of this state

Kind: instance property of State

state.NextCount

Kind: instance property of State

Param Type Description
value int set the nextCount of this state

state.Timeout : int

the timeout of this state

Kind: instance property of State

state.Timeout

Kind: instance property of State

Param Type Description
value int set the timeout of this state

Mode

Class representing the different modes of a stream

Kind: global class

Mode.PUBLIC

Represents the public mode of a Stream

Kind: static property of Mode

Mode.PRIVATE

Represents the private mode of a Stream

Kind: static property of Mode

Mode.RESTRICTED

Represents the restricted mode of a Stream

Kind: static property of Mode

Stream : Stream

Class representing the actual state of a stream

Kind: global class

new Stream(messageProvider, seed, mode, security, sideKey)

Creates a new stream object

Param Type Default Description
messageProvider Provider the url to a fullnode the messages should get attatched to
seed string null the seed of the stream
mode string the mode of the stream
security int 2 the security level of the stream
sideKey string | null null the optional sideKey for encrypting and decrypting messages

stream.isPublisher : boolean

returns if this stream can also publish messages

Kind: instance property of Stream

stream.Provider : Provider

returns the actual provider of this stream

Kind: instance property of Stream

stream.State : State

returns the current state of this stream

Kind: instance property of Stream

stream.State

Kind: instance property of Stream

Param Type Description
state State sets the state of this stream

stream.init()

Initializing the latest MAM-State of the stream

Kind: instance method of Stream

stream.fetchMessages(filters) : Array.<Message>

Fetch messages from the tangle or a storage provider

Kind: instance method of Stream

Param Type Description
filters Object the filters that should be applied for fetching MAM messages
filters.fromRoot string | null the root since which the messages should be fetched from
filters.start int | null start value for pagination, skip start messages
filters.limit int | null the maximum number of messages that should get fetched
filters.type string | null the type of the messages that should get fetched
filters.orderByDate string | null the ordering of the messages asc (ascending) or desc (descending)

stream.sendMessages(...messages) : Array.<Message>

Send message objects to the tangle

Kind: instance method of Stream

Param Type Description
...messages Message the message objects that should get published

stream.deleteStream()

Delete the stream and notify all listeners

Kind: instance method of Stream

stream.subscribe(callback, fromRoot, timeout)

Subscribe to a stream to get notified when new messages arrives

Kind: instance method of Stream

Param Type Default Description
callback function the method which should be called, when a new message arrives. Takes the message as argument
fromRoot string | null null the root since which messages should get subscribed
timeout int | null the timeout of the interval the messages should get fetched

Stream.createListenerStream(messageProvider, root, mode, security, sideKey) : Stream

Creates a new ListenerStream for reading new MAM messages

Kind: static method of Stream

Param Type Default Description
messageProvider Provider the url to a fullnode the messages should get attatched to
root string the index root of the stream
mode string the mode of the stream
security int 2 the security level of the stream
sideKey string | null null the optional sideKey for encrypting and decrypting messages

Stream.createPublisherStream(messageProvider, seed, mode, security, sideKey) : Stream

Creates a new PublisherStream for sending and reading new MAM messages

Kind: static method of Stream

Param Type Default Description
messageProvider Provider the url to a fullnode the messages should get attatched to
seed string the seed of the stream
mode string the mode of the stream
security int 2 the security level of the stream
sideKey string | null null the optional sideKey for encrypting and decrypting messages

Stream.initializePublisherStream(messageProvider, seed, mode, security, sideKey) : Stream

Initializes a already existing Stream for sending and reading new MAM messages

Kind: static method of Stream

Param Type Default Description
messageProvider Provider the url to a fullnode the messages should get attatched to
seed string the seed of the stream
mode string the mode of the stream
security int 2 the security level of the stream
sideKey string | null null the optional sideKey for encrypting and decrypting messages

Message

Class representing the a MAM message

Kind: global class

message.Trytes : string

the message as trytes string

Kind: instance property of Message

message.Raw : Object

the raw message object

Kind: instance property of Message

message.Message : string | int | Object | Array

the actual content of the message

Kind: instance property of Message

message.Transactions : Array

all transactions if this message is already attatched to the tangle

Kind: instance property of Message

message.Type : string

the type of this message

Kind: instance property of Message

message.Publisher : string

the publisher of this message

Kind: instance property of Message

message.Timestamp : Date

the timestamp of this message

Kind: instance property of Message

Message.TYPE_DELETION : string

the message type for Deletion

Kind: static property of Message

Message.TYPE_PROMOTIONAL : string

the message type for Promotional

Kind: static property of Message

Message.TYPE_TRANSACTIONAL : string

the message type for Transactional

Kind: static property of Message

Message.createMessage(messageStream, message, type, publisher) : Message

Create a new MAM message

Kind: static method of Message

Param Type Default Description
messageStream Stream the stream this message should get published in or fetched from
message string | int | Object | Array the actual content that should get published
type string the type of this message
publisher string | null null the publisher of this message

Provider : Provider

Class representing the interface of a Provider

Kind: global class

new Provider(provider, publisher, attatchToTangle)

Create a new Provider object

Param Type Default Description
provider string the url of the fullnode that should handle communication with the tangle
publisher string null the name of the publisher attatched to all messages, where the publisher does not get overwritten
attatchToTangle function a function outsourcing or overwriting the attatchToTangle method

provider.createStream(messageStream)

Creating a stream or storing the stream details (but never publish the sideKey or seed!)

Kind: instance method of Provider

Param Type
messageStream Stream

provider.updateState(messageStream)

Update the state of the stream to it's latest state

Kind: instance method of Provider

Param Type Description
messageStream Stream the stream the message should get published to

provider.publishMessages(messageStream, ...messages) : Array.<Message>

Publish one or multiple messages to the tangle

Kind: instance method of Provider

Param Type Description
messageStream Stream the stream the message should get published to
...messages Message the published messages

provider.fetchMessages(messageStream, filters) : Array.<Message>

Fetch messages from the tangle or a permanent storage

Kind: instance method of Provider

Param Type Description
messageStream Stream
filters Object the filters that should be applied for fetching MAM messages
filters.fromRoot string | null the root since which the messages should be fetched from
filters.start int | null start value for pagination, skip start messages
filters.limit int | null the maximum number of messages that should get fetched
filters.type string | null the type of the messages that should get fetched
filters.orderByDate string | null the ordering of the messages asc (ascending) or desc (descending)