new SessionClient(optionsopt)
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Creation client options
Properties
|
- Source:
Example
const sessionClient = new SessionClient()
Methods
(async) changeAvatar(data) → {Promise.<object>}
Change your avatar
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer | image data |
- Source:
Returns:
avatar's URL and profileKey to decode
- Type
- Promise.<object>
close()
stop listening for messages
- Source:
(async) decodeAvatar(url, profileKeyUint8) → {Promise.<Buffer>}
decode an avatar (usually from a message)
Parameters:
Name | Type | Description |
---|---|---|
url |
String | Avatar URL |
profileKeyUint8 |
Uint8Array |
- Source:
Returns:
a buffer containing raw binary data for image of avatar
- Type
- Promise.<Buffer>
deleteOpenGroupV2Message(open, message) → {Promise.<Array>}
Delete Open Group V2 Message
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group V2 handle |
message |
Int | ID to delete |
- Source:
Returns:
result of deletion (false, null or true)
- Type
- Promise.<Array>
Example
sessionClient.joinOpenGroup('chat.getsession.org')
deleteOpenGroupV3Message(open, message) → {Promise.<Array>}
Delete Open Group V3 Message
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group V3 handle |
message |
Int | ID to delete |
- Source:
Returns:
result of deletion (false, null or true)
- Type
- Promise.<Array>
Example
sessionClient.joinOpenGroup('chat.getsession.org')
(async) getAttachments(message) → {Promise.<Array>}
get and decrypt all attachments
Parameters:
Name | Type | Description |
---|---|---|
message |
Object | message to download attachments from |
- Source:
Returns:
an array of buffers of downloaded data
- Type
- Promise.<Array>
(async) joinOpenGroupV2(open, open) → {Promise.<Object>}
Join Open Group V2, Receive Open Group V2 token
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group handle |
open |
Number | group Channel |
- Source:
Returns:
Object {token: {String}, channelId: {Int}, lastMessageId: {Int}}
- Type
- Promise.<Object>
Example
sessionClient.joinOpenGroup('chat.getsession.org')
(async) joinOpenGroupV3(open, open) → {Promise.<Object>}
Join Open Group V3, Receive Open Group V3 token
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group handle |
open |
Number | group Channel |
- Source:
Returns:
Object {token: {String}, channelId: {Int}, lastMessageId: {Int}}
- Type
- Promise.<Object>
Example
sessionClient.joinOpenGroupV3('chat.getsession.org')
(async) loadIdentity(options)
set an identity for this session client
sets this.identityOutput
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | a list of options of how to set up the identity
Properties
|
- Source:
Example
client.loadIdentity({
seed: fs.existsSync('seed.txt') && fs.readFileSync('seed.txt').toString(),
//displayName: 'Sample Session Client',
//avatarFile: 'avatar.png',
}).then(async() => {
// Do stuff
})
(async) makeImageAttachment(data) → {Promise.<Object>}
get and decrypt all attachments
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer | image data |
- Source:
Returns:
returns an attachmentPointer
- Type
- Promise.<Object>
(async) open()
start listening for messages
- Source:
(async) poll()
poll storage server for messages and emit events
- Source:
Fires:
- SessionClient#event:updateLastHash
- SessionClient#event:preKeyBundle
- SessionClient#event:receiptMessage
- SessionClient#event:nullMessage
- SessionClient#event:messages
(async) send(destination, messageTextBodyopt, optionsopt) → {Promise.<Bool>}
Send a Session message
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
destination |
String | pubkey of who you want to send to | |||||||||||||||||||||||||||||
messageTextBody |
String |
<optional> |
text message to send | ||||||||||||||||||||||||||||
options |
object |
<optional> |
Send options
Properties
|
- Source:
Returns:
If operation was successful or not
- Type
- Promise.<Bool>
Example
sessionClient.send('05d233c6c8daed63a48dfc872a6602512fd5a18fc764a6d75a08b9b25e7562851a', 'I didn\'t change the pubkey')
(async) sendOpenGroupInvite(destination, serverName, serverAddress, channelId) → {Promise.<Bool>}
Send an open group invite
Currently works on desktop not on iOS/Android
Parameters:
Name | Type | Description |
---|---|---|
destination |
String | pubkey of who you want to send to |
serverName |
String | Server description |
serverAddress |
String | Server URL |
channelId |
Number | Channel number |
- Source:
Returns:
If operation was successful or not
- Type
- Promise.<Bool>
Example
sessionClient.sendOpenGroupInvite('05d233c6c8daed63a48dfc872a6602512fd5a18fc764a6d75a08b9b25e7562851a', 'Session Chat', 'https://chat.getsession.org/', 1)
(async) sendOpenGroupV2Message(open)
Send Open Group V2 Message
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group handle |
- Source:
Example
sessionClient.joinOpenGroup('chat.getsession.org')
(async) sendOpenGroupV3Message(open)
Send Open Group V3 Message
Parameters:
Name | Type | Description |
---|---|---|
open |
String | group handle |
- Source:
Example
sessionClient.joinOpenGroup('chat.getsession.org')
(async) sendSafeOpenGroupInvite(destination, serverName, serverAddress, channelId) → {Promise.<Bool>}
Send an open group invite with additional text for mobile
seems to work with V2 (leave channel as 1)
Parameters:
Name | Type | Description |
---|---|---|
destination |
String | pubkey of who you want to send to |
serverName |
String | Server description |
serverAddress |
String | Server URL |
channelId |
Number | Channel number |
- Source:
Returns:
If operation was successful or not
- Type
- Promise.<Bool>
Example
sessionClient.sendOpenGroupInvite('05d233c6c8daed63a48dfc872a6602512fd5a18fc764a6d75a08b9b25e7562851a', 'Session Chat', 'https://chat.getsession.org/', 1)