node.js bindings for deltachat-core
Lars-Magnus Skog b6db9adf14
1.0.0-alpha.1
2 weeks ago
.circleci set up circleci 3 months ago
ci_scripts Rust core (#308) 2 months ago
deltachat-core-rust @ 6ccc75b1ed Upgrade rust core to 1.0.0-alpha.1 (#358) 3 weeks ago
images Document tests and coverage 10 months ago
lib Set defaults for mailbox flags 3 weeks ago
scripts chore: bring back prebuilt binaries (#340) 1 month ago
src fix(windows): use mutex from libuv for the string table (#338) 1 month ago
test Fix test count 3 weeks ago
.gitignore Add Prebuildify (#191) 7 months ago
.gitmodules Remove deltachat-core submodule 2 months ago
.npmignore chore: bring back prebuilt binaries (#340) 1 month ago
.npmrc Prevent building package-lock.json 2 months ago
.travis.yml chore: bring back prebuilt binaries (#340) 1 month ago
CHANGELOG.md Update CHANGELOG 2 weeks ago
CONTRIBUTORS.md Update CHANGELOG 2 weeks ago
LICENSE Add LICENSE 1 year ago
README.md Upgrade rust core to 1.0.0-alpha.1 (#358) 3 weeks ago
UPGRADING.md Update changelog 6 months ago
appveyor.yml chore: add node_modules and deltachat-core-rust/target to appveyor cache (#348) 1 month ago
binding.gyp Link with the dependencies of rust-core (#351) 1 month ago
binding.js chore: bring back prebuilt binaries (#340) 1 month ago
constants.js Remove http get (#326) 1 month ago
events.js Remove http get (#326) 1 month ago
index.js Fix standard 3 months ago
package.json 1.0.0-alpha.1 2 weeks ago
windows.md Update readme (#336) 1 month ago

README.md

deltachat-node

node.js bindings for deltachat-core-rust

Appveyor build status Build Status npm Node version Coverage Status dependencies JavaScript Style Guide

WORK IN PROGRESS The API can change at any time and will not follow semver versioning until v1.0.0 has been released.

If you are upgrading: please see UPGRADING.md.

deltachat-node primarily aims to offer two things:

  • A high level JavaScript api with syntactic sugar
  • A low level c binding api around deltachat-core-rust

Table of Contents

Click to expand

Install

By default the installation will build deltachat-core-rust from the submodule using scripts/rebuild-core.js. Simply invoke npm:

npm install deltchat-node

Using system libdeltachat

It is possible to use the system-wide installed libdeltachat.so library which will be located using pkg-config. You need to have installed deltachat-core-rust before installing this way. Using this approach allows you to build libdeltachat.so with your own specific options.

Invoke npm with the extra arguments:

npm install deltachat-node --dc-system-lib=true

When invoking node-gyp directly this can be achieved in a slightly different way:

node-gyp rebuild -- -Dsystem_dc_core=true

Usage

const DeltaChat = require('deltachat-node')
const dc = new DeltaChat()

const opts = {
  addr: '[email]',
  mail_pw: '[password]'
}

const contact = '[email]'

dc.on('ALL', console.log.bind(null, 'core |'))

dc.on('DC_EVENT_INCOMING_MSG', (chatId, msgId) => {
  const msg = dc.getMessage(msgId)
  console.log(chatId, msg)
  dc.sendMessage(chatId, `Bot agrees to ${Math.random() * 100}%`)
})

dc.open(() => {
  const onReady = () => {
    const contactId = dc.createContact('Test', contact)
    const chatId = dc.createChatByContactId(contactId)
    dc.sendMessage(chatId, 'Hi!')
    dc.close(() => {
      console.log('Bye.')
    })
  }
  if (!dc.isConfigured()) {
    dc.once('ready', onReady)
    dc.configure(opts)
  } else {
    onReady()
  }
})

API

The high level JavaScript API is a collection of classes wrapping most context types provided by deltachat-core-rust. Please see the class list for an overview of this.

dc = DeltaChat()

Creates a new DeltaChat instance.

Initializes the main context and sets up event handling. Call dc.open(cwd, cb) to start and dc.configure(opts, cb) if needed.


class DeltaChat

The DeltaChat class wraps a dc_context_t* and handles most operations, such as connecting to an IMAP server, sending messages with SMTP etc. It is through this instance you get references to the other class types following below.

dc.addAddressBook(addressBook)

Add a number of contacts. Corresponds to dc_add_address_book().

dc.addContactToChat(chatId, contactId)

Add a member to a group. Corresponds to dc_add_contact_to_chat().

dc.archiveChat(chatId, archive)

Archive or unarchive a chat. Corresponds to dc_archive_chat().

dc.blockContact(contactId, block)

Block or unblock a contact. Corresponds to dc_block_contact().

dc.checkQrCode(qrCode)

Check a scanned QR code. Corresponds to dc_check_qr().

dc.clearStringTable()

Clears the string table for handling DC_EVENT_GET_STR events from core.

dc.close([cb])

Stops the threads and closes down the DeltaChat instance. Calls back when underlying context has been fully closed.

dc.configure(options[, cb])

Configure and connect a context. Corresponds to dc_configure().

The options object takes the following properties:

  • options.addr (string, required): Email address of the chat user.
  • options.mail_server (string, optional): IMAP-server, guessed if left out.
  • options.mail_user (string, optional): IMAP-username, guessed if left out.
  • options.mail_pw (string, required): IMAP-password of the chat user.
  • options.mail_port (string | integer, optional): IMAP-port, guessed if left out.
  • options.send_server (string, optional): SMTP-server, guessed if left out.
  • options.send_user (string, optional): SMTP-user, guessed if left out.
  • options.send_pw (string, optional): SMTP-password, guessed if left out.
  • options.send_port (string | integer, optional): SMTP-port, guessed if left out.
  • options.server_flags (integer, optional): IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out.
  • options.displayname (string, optional): Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty.
  • options.selfstatus (string, optional): Own status to display e.g. in email footers, defaults to a standard text.
  • options.selfavatar (string, optional): File containing avatar.
  • options.e2ee_enabled (boolean, optional): Enable E2EE. Defaults to true.
  • options.mdns_enabled (boolean, optional): Send and request read receipts. Defaults to true.
  • options.inbox_watch (boolean, optional): Watch INBOX-folder for changes. Defaults to true.
  • options.sentbox_watch (boolean, optional): Watch Sent-folder for changes. Defaults to true.
  • options.mvbox_watch (boolean, optional): Watch DeltaChat-folder for changes. Defaults to true.
  • options.mvbox_move (boolean, optional): Heuristically detect chat-messages and move them to the DeltaChat-folder. Defaults to true.
  • options.show_emails (integer, optional): DC_SHOW_EMAILS_OFF (0) show direct replies to chats only (default), DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1) also show all mails of confirmed contacts, DC_SHOW_EMAILS_ALL (2) also show mails of unconfirmed contacts in the deaddrop.
  • options.save_mime_headers (boolean, optional): Set to true if you want to use dc.getMimeHeaders() later.

dc.continueKeyTransfer(messageId, setupCode, callback)

Continue the AutoCrypt key transfer on another device. Corresponds to dc_continue_key_transfer().

  • messageId (string|integer, required) See deltachat api documentation
  • setupCode (string, required) See deltachat api documentation
  • callback (function, required) Called with an error if setup code is bad

dc.createChatByContactId(contactId)

Create a normal chat with a single user. Corresponds to dc_create_chat_by_contact_id().

dc.createChatByMessageId(messageId)

Create a normal chat or group chat by a message id. Corresponds to dc_create_chat_by_msg_id().

dc.createContact(name, addr)

Add a single contact as a result of an explicit user action. Corresponds to dc_create_contact().

dc.createUnverifiedGroupChat(chatName)

Create a new unverified group chat. Corresponds to dc_create_group_chat().

dc.createVerifiedGroupChat(chatName)

Create a new verified group chat. Corresponds to dc_create_group_chat().

dc.deleteChat(chatId)

Delete a chat. Corresponds to dc_delete_chat().

dc.deleteContact(contactId)

Delete a contact. Corresponds to dc_delete_contact().

dc.deleteMessages(messageIds)

Delete messages. Corresponds to dc_delete_msgs().

dc.forwardMessages(messageIds, chatId)

Forward messages to another chat. Corresponds to dc_forward_msgs().

dc.getBlobdir()

Get the blob directory. Corresponds to dc_get_blobdir().

dc.getBlockedCount()

Get the number of blocked contacts. Corresponds to dc_get_blocked_cnt().

dc.getBlockedContacts()

Get blocked contacts. Corresponds to dc_get_blocked_contacts().

dc.getChat(chatId)

Get Chat object by a chat id. Corresponds to `dc_get_chat().

dc.getChatContacts(chatId)

Get contact ids belonging to a chat. Corresponds to dc_get_chat_contacts().

dc.getChatIdByContactId(contactId)

Check, if there is a normal chat with a given contact. Corresponds to `dc_get_chat_id_by_contact_id().

dc.getChatMedia(chatId, msgType1, msgType2, msgType3)

Returns all message ids of the given type in a chat. Corresponds to dc_get_chat_media().

dc.getLocations(chatId, contactId, timestampFrom, timestampTo)

Returns an array of locations for a given chat, contact and timestamp range. Each item in the array is an object with the following properties:

  • accuracy
  • latitude
  • longitude
  • timestamp
  • contactId
  • msgId
  • chatId

dc.getMimeHeaders(messageId)

Get the raw mime-headers of the given message. Corresponds to dc_get_mime_headers().

dc.getChatMessages(chatId, flags, marker1before)

Get all message ids belonging to a chat. Corresponds to dc_get_chat_msgs().

dc.getChats(listFlags, queryStr, queryContactId)

Like dc.getChatList() but returns a JavaScript array of ids.

dc.getChatList(listFlags, queryStr, queryContactId)

Get a list of chats. Returns a ChatList object. Corresponds to dc_get_chatlist().

DeltaChat.getConfig(path, callback)

Get configuration from a path. Calls back with (err, config). A static method which does a minimal open and if the path has a configured state the config parameter contains the following properties:

  • addr (string): Email address used to configure the account.

dc.getConfig(key)

Get a configuration option. Corresponds to dc_get_config().

dc.getContact(contactId)

Get a single Contact object. Corresponds to dc_get_contact().

dc.getContactEncryptionInfo(contactId)

Get encryption info for a contact. Corresponds to dc_get_contact_encrinfo().

dc.getContacts(listFlags, query)

Return known and unblocked contacts. Corresponds to dc_get_contacts().

dc.getDraft(chatId)

Get draft for a chat, if any. Corresponds to dc_get_draft().

dc.getFreshMessageCount(chatId)

Get the number of fresh messages in a chat. Corresponds to dc_get_fresh_msg_cnt().

dc.getFreshMessages()

Returns the message ids of all fresh messages of any chat. Corresponds to dc_get_fresh_msgs().

dc.getInfo()

Get info about the context. Corresponds to dc_get_info().

Returns an object with the following properties:

  • arch
  • blobdir
  • configured_mvbox_folder
  • configured_sentbox_folder
  • database_dir
  • database_version
  • deltachat_core_version
  • display_name
  • e2ee_enabled
  • entered_account_settings
  • fingerprint
  • folders_configured
  • inbox_watch
  • is_configured
  • mdns_enabled
  • messages_in_contact_requests
  • mvbox_move
  • mvbox_watch
  • number_of_chat_messages
  • number_of_chats
  • number_of_contacts
  • private_key_count
  • public_key_count
  • sentbox_watch
  • sqlite_thread_safe
  • sqlite_version
  • used_account_settings

dc.getMessage(messageId)

Get a single Message object. Corresponds to dc_get_msg().

dc.getMessageCount(chatId)

Get the total number of messages in a chat. Corresponds to dc_get_msg_cnt().

dc.getMessageInfo(messageId)

Get an informational text for a single message. Corresponds to dc_get_msg_info().

dc.getNextMediaMessage(messageId, msgType1, msgType2, msgType3)

Get next message of the same type. Corresponds to dc_get_next_media().

dc.getPreviousMediaMessage(messageId, msgType1, msgType2, msgType3)

Get previous message of the same type. Corresponds to dc_get_next_media().

dc.getSecurejoinQrCode(groupChatId)

Get QR code text that will offer a secure-join verification. Corresponds to dc_get_securejoin_qr().

dc.getStarredMessages()

Returns an array of starred messages.

DeltaChat.getSystemInfo()

Static method. Returns a stripped version of dc.getInfo() which only contains stats of the software and the system and no user related data. Useful when you want to grab version numbers. It should be fast, since no opening of database or configuring is required.

dc.importExport(what, param1, param2)

Import/export things. Corresponds to dc_imex().

dc.importExportHasBackup(dirName)

Check if there is a backup file. Corresponds to dc_imex_has_backup().

dc.initiateKeyTransfer(callback)

Initiate Autocrypt setup transfer. Corresponds to dc_initiate_key_transfer().

  • callback (function, required) Called with an error as first argument (or null) and the setup code as second argument if no error occured.

dc.isConfigured()

Check if the context is already configured. Corresponds to dc_is_configured().

dc.isContactInChat(chatId, contactId)

Check if a given contact id is a member of a group chat. Corresponds to dc_is_contact_in_chat().

dc.isOpen()

Check if the context database is open. Corresponds to dc_is_open().

dc.joinSecurejoin(qrCode)

Join an out-of-band-verification initiated on another device with dc.getSecurejoinQrCode(). Corresponds to dc_join_securejoin().

dc.markNoticedChat(chatId)

Mark all messages in a chat as noticed. Corresponds to dc_marknoticed_chat().

dc.markNoticedAllChats()

Same as dc.markNoticedChat() but for all chats. Corresponds to dc_marknoticed_all_chats().

dc.lookupContactIdByAddr(addr)

Returns true if an e-mail address belongs to a known and unblocked contact, otherwise false. Corresponds to dc_lookup_contact_id_by_addr().

dc.markNoticedContact(contactId)

Mark all messages sent by the given contact as noticed. Corresponds to dc_marknoticed_contact().

dc.markSeenMessages(messageIds)

Mark a message as seen, updates the IMAP state and sends MDNs. Corresponds to dc_markseen_msgs().

DeltaChat.maybeValidAddr(addr)

Static method. Returns true if addr maybe is a valid e-mail address, otherwise false. Corresponds to dc_may_be_valid_addr().

dc.maybeNetwork()

Called as a hint to deltachat-core-rust that the network is available again, to trigger pending messages to be sent. Corresponds to dc_maybe_network().

dc.messageNew([viewType])

Create a new Message object. Corresponds to dc_msg_new(). The viewType parameter is optional and defaults to DC_MSG_TEXT. Pick from one of the following values:

  • DC_MSG_TEXT
  • DC_MSG_AUDIO
  • DC_MSG_FILE
  • DC_MSG_GIF
  • DC_MSG_IMAGE
  • DC_MSG_VIDEO
  • DC_MSG_VOICE

dc.open([cwd], callback)

Opens the underlying database.

  • cwd (string, optional) Path to working directory, defaults to current working directory.
  • callback (function, required) Called with an error if the database could not be opened.

dc.removeContactFromChat(chatId, contactId)

Remove a member from a group. Corresponds to dc_remove_contact_from_chat().

dc.searchMessages(chatId, query)

Search messages containing the given query string. Corresponds to dc_search_msgs().

dc.sendMessage(chatId, msg)

Send a message of any type to a chat. Corresponds to dc_send_msg(). The msg parameter can either be a string or a Message object.

dc.setChatName(chatId, name)

Set group name. Corresponds to dc_set_chat_name().

dc.setChatProfileImage(chatId, image)

Set group profile image. Corresponds to dc_set_chat_profile_image().

dc.setConfig(key, value)

Configure the context. Corresponds to dc_set_config().

dc.setDraft(chatId, message)

Save a draft for a chat in the database. Corresponds to dc_set_draft().

dc.setStringTable(index, str)

Allows the caller to define custom strings for DC_EVENT_GET_STR events, e.g. when letting core know about a different language. The first parameter index is an integer corresponding to a DC_STR_* in constants.js and str is the new value.

dc.starMessages(messageIds, star)

Star/unstar messages. Corresponds to dc_star_msgs().


class Chat

An object representing a single chat in memory.

chat.getArchived()

Get archived state. Corresponds to dc_chat_get_archived().

chat.getColor()

Get a color for the chat. Corresponds to dc_chat_get_color().

chat.getId()

Get chat id. Corresponds to dc_chat_get_id().

chat.getName()

Get name of a chat. Corresponds to dc_chat_get_name().

chat.getProfileImage()

Get the chat's profile image. Corresponds to dc_chat_get_profile_image().

chat.getSubtitle()

Get a subtitle for a chat. Corresponds to dc_chat_get_subtitle().

chat.getType()

Get chat type. Corresponds to dc_chat_get_type().

chat.isSelfTalk()

Check if a chat is a self talk. Corresponds to dc_chat_is_self_talk().

chat.isUnpromoted()

Check if a chat is still unpromoted. Corresponds to dc_chat_is_unpromoted().

chat.isVerified()

Check if a chat is verified. Corresponds to dc_chat_is_verified().

chat.toJson()

Returns the object state as a JavaScript serializable object.


class ChatList

An object representing a single chatlist in memory.

list.getChatId(index)

Get a single chat id of a chatlist. Corresponds to dc_chatlist_get_chat_id().

list.getCount()

Get the number of chats in a chatlist. Corresponds to dc_chatlist_get_cnt().

list.getMessageId(index)

Get a single message id of a chatlist. Corresponds to dc_chatlist_get_msg_id().

list.getSummary(index, chat)

Get a summary for a chatlist index. Returns a Lot object. Corresponds to dc_chatlist_get_summary().


class Contact

An object representing a single contact in memory.

contact.getAddress()

Get email address. Corresponds to dc_contact_().

contact.getId()

Get a color for the contact. Corresponds to dc_chat_get_color().

contact.getDisplayName()

Get display name. Corresponds to dc_contact_get_display_name().

contact.getFirstName()

Get the part of the name before the first space. Corresponds to dc_contact_get_first_name().

contact.getId()

Get the id of the contact. Corresponds to dc_contact_get_id().

contact.getName()

Get the name of the contact. Corresponds to dc_contact_get_name().

contact.getNameAndAddress()

Get a summary of name and address. Corresponds to dc_contact_get_name_n_addr().

contact.getProfileImage()

Get the profile image of a contact. Corresponds to dc_contact_get_profile_image().

contact.isBlocked()

Check if a contact is blocked. Corresponds to dc_contact_is_blocked().

contact.isVerified()

Check if a contact is verified. Corresponds to dc_contact_is_verified().

contact.toJson()

Returns the object state as a JavaScript serializable object.


class Lot

An object containing a set of values in memory.

lot.getId()

Get the associated id. Corresponds to dc_lot_get_id().

lot.getState()

Get the associated state. Corresponds to dc_lot_get_state().

lot.getText1()

Get first string. Corresponds to dc_lot_get_text1().

lot.getText1Meaning()

Get the meaning of the first string. Corresponds to dc_lot_get_text1_meaning().

lot.getText2()

Get the second string. Corresponds to dc_lot_get_text2().

lot.getTimestamp()

Get the associated timestamp. Corresponds to dc_lot_get_timestamp().

lot.toJson()

Returns the object state as a JavaScript serializable object.


class Message

An object representing a single message in memory.

msg.getChatId()

Get the id of the chat the message belongs to. Corresponds to dc_msg_get_chat_id().

msg.getDuration()

Get duration of audio of video. Corresponds to dc_msg_get_duration().

msg.getFile()

Find out full path, file name and extension of the file associated with a message. Corresponds to dc_msg_get_file().

msg.getFilebytes()

Get the size of the file. Corresponds to dc_msg_get_filebytes().

msg.getFilemime()

Get mime type of the file. Corresponds to dc_msg_get_filemime().

msg.getFilename()

Get base file name without path. Corresponds to dc_msg_get_filename().

msg.getFromId()

Get the id of the contact that wrote the message. Corresponds to dc_msg_get_from_id().

msg.getHeight()

Get height of image or video. Corresponds to dc_msg_get_height().

msg.getId()

Get the id of the message. Corresponds to dc_msg_get_id().

msg.getReceivedTimestamp()

Get message receive time. Corresponds to dc_msg_get_received_timestamp().

msg.getSetupcodebegin()

Get first characters of the setup code. Corresponds to dc_msg_get_setupcodebegin().

msg.getShowpadlock()

Check if a padlock should be shown beside the message. Corresponds to dc_msg_get_showpadlock().

msg.getSortTimestamp()

Get message time used for sorting. Corresponds to dc_msg_get_sort_timestamp().

msg.getState()

Get the state of the message. Returns a MessageState object. Corresponds to dc_msg_get_state().

msg.getSummary(chat)

Get a summary of a message. Returns a Lot object. Corresponds to dc_msg_get_summary().

msg.getSummarytext(approxCharacters)

Get a message summary as a single line of text. Corresponds to `dc_msg_get_summarytext().

msg.getText()

Get the text of the message. Corresponds to dc_msg_get_text().

msg.getTimestamp()

Get message sending time. Corresponds to dc_msg_get_timestamp().

msg.getViewType()

Get the view type of the message. Returns a MessageViewType object. Corresponds to dc_msg_get_viewtype().

msg.getWidth()

Get the width of image or video. Corresponds to dc_msg_get_width().

msg.hasDeviatingTimestamp()

Check if a message has a deviating timestamp. Corresponds to dc_msg_has_deviating_timestamp().

msg.hasLocation()

Check if a message has a location. Corresponds to dc_msg_has_location().

msg.isDeadDrop()

Check if the message belongs to the virtual dead drop chat.

msg.isForwarded()

Check if the message is a forwarded message. Corresponds to dc_msg_is_forwarded().

msg.isIncreation()

Check if a message is still in creation. Corresponds to dc_msg_is_increation().

msg.isInfo()

Check if the message is an informational message, created by the device or by another user. Corresponds to dc_msg_is_info().

msg.isSent()

Check if a message was sent successfully. Corresponds to dc_msg_is_sent().

msg.isSetupmessage()

Check if the message is an Autocrypt setup message. Corresponds to dc_msg_is_setupmessage().

msg.isStarred()

Check if a message is starred. Corresponds to dc_msg_is_starred().

msg.latefilingMediasize(width, height, duration)

Late filing information to a message. Corresponds to dc_msg_latefiling_mediasize().

msg.setDimension(width, height)

Set the dimensions associated with a message. Corresponds to dc_msg_set_dimension(). Returns this so you can do chained commands.

msg.setDuration(duration)

Set the duration assocated with the message object. Corresponds to dc_msg_set_duration(). Returns this so you can do chained commands.

msg.setLocation(latitude, longitude)

Set the location of a message. Corresponds to dc_msg_set_location(). Returns this so you can do chained commands.

msg.setFile(file, mime)

Set the file assocated with the message object. Corresponds to dc_msg_set_file(). Returns this so you can do chained commands.

msg.setText(text)

Set the test of a message object. Corresponds to dc_msg_set_text(). Returns this so you can do chained commands.

msg.toJson()

Returns the object state as a JavaScript serializable object.


class MessageState

An object representing a Message state.

state.isUndefined()

Message state is DC_STATE_UNDEFINED.

state.isFresh()

Message state is DC_STATE_IN_FRESH.

state.isNoticed()

Message state is DC_STATE_IN_NOTICED.

state.isSeen()

Message state is DC_STATE_IN_SEEN.

state.isPending()

Message state is DC_STATE_OUT_PENDING.

state.isFailed()

Message state is DC_STATE_OUT_FAILED.

state.isDelivered()

Message state is DC_STATE_OUT_DELIVERED.

state.isReceived()

Message state is DC_STATE_OUT_MDN_RCVD.

state.state

Internal state property.


class MessageViewType

An object representing a Message view type.

viewType.isText()

Message type is DC_MSG_TEXT.

viewType.isImage()

Message type has DC_MSG_IMAGE bits set.

viewType.isGif()

Message type is DC_MSG_GIF.

viewType.isAudio()

Message type has DC_MSG_AUDIO bits set.

viewType.isVoice()

Message type is DC_MSG_VOICE.

viewType.isVideo()

Message type has DC_MSG_VIDEO bits set.

viewType.isFile()

Message type is DC_MSG_FILE.

viewType.viewType

Internal viewType property.

Events

DeltaChat is an EventEmitter and emits the following events.

Event Description Arguments
ready DeltaChat is ready -
DC_EVENT_INFO Info string (info)
DC_EVENT_SMTP_CONNECTED Info string (info)
DC_EVENT_IMAP_CONNECTED Info string (info)
DC_EVENT_SMTP_MESSAGE_SENT Info string (info)
DC_EVENT_WARNING Warning string (warning)
DC_EVENT_ERROR Error string (error)
DC_EVENT_ERROR_NETWORK Network error (first, error)
DC_EVENT_ERROR_SELF_NOT_IN_GROUP Info string (info)
DC_EVENT_MSGS_CHANGED Messages or chats changed (chatId, msgId)
DC_EVENT_INCOMING_MSG There is a fresh message (chatId, msgId)
DC_EVENT_MSG_DELIVERED Message was sent successfully (chatId, msgId)
DC_EVENT_MSG_FAILED Message could not be sent (chatId, msgId)
DC_EVENT_MSG_READ Message read by the receiver (chatId, msgId)
DC_EVENT_CHAT_MODIFIED Chat modified (chatId)
DC_EVENT_CONTACTS_CHANGED Contact changed (contactId)
DC_EVENT_LOCATION_CHANGED Location changed for a contact (contactId)
DC_EVENT_CONFIGURE_PROGRESS Configuration progress (progress)
DC_EVENT_IMEX_PROGRESS Import/export progress (progress)
DC_EVENT_IMEX_FILE_WRITTEN A file has been exported (fileName)
DC_EVENT_SECUREJOIN_INVITER_PROGRESS Progress of a secure-join handshake (contactId, progress)
DC_EVENT_SECUREJOIN_JOINER_PROGRESS Progress of a secure-join handshake (contactId, progress)
ALL All events from deltachat-core (event, data1, data2)

Developing

Tests and Coverage

Running npm test ends with showing a code coverage report, which is produced by nyc.

test output

The coverage report from nyc in the console is rather limited. To get a more detailed coverage report you can run npm run coverage-html-report. This will produce a html report from the nyc data and display it in a browser on your local machine.

On Travis the coverage report is also passed to coveralls.

To run the integration tests you need to set the DC_ADDR and DC_MAIL_PW environment variables. E.g.:

$ export DC_ADDR=user@site.org
$ export DC_MAIL_PW=myp4ssw0rD
$ npm run test-integration

Scripts

We have the following scripts for building, testing and coverage:

  • npm run coverage Creates a coverage report and passes it to coveralls. Only done by Travis.
  • npm run coverage-html-report Generates a html report from the coverage data and opens it in a browser on the local machine.
  • npm run generate-constants Generates constants.js and events.js based on the deltachat-core-rust/deltachat-ffi/deltachat.h header file.
  • npm install After dependencies are installed, runs node-gyp-build to see if the native code needs to be rebuilt.
  • npm run rebuild-all Rebuilds all code.
  • npm run rebuild-core Rebuilds code in deltachat-core-rust.
  • npm run rebuild-bindings Rebuilds the bindings and links with deltachat-core-rust.
  • npm run node-gyp-build Tries to load prebuilts and falls back to rebuilding the code.
  • npm run prebuild Builds prebuilt binary to prebuilds/$PLATFORM-$ARCH. Copies deltachat.dll from deltachat-core-rust for windows.
  • npm run download-prebuilds Downloads all prebuilt binaries from github before npm publish.
  • npm run submodule Updates the deltachat-core-rust submodule.
  • npm test Runs standard and then the tests in test/index.js.
  • npm run test-integration Runs the integration tests.
  • npm run hallmark Runs hallmark on all markdown files.

Releases

The following steps are needed to make a release:

  1. Update CHANGELOG.md (and run npm run hallmark to adjust markdown)
  2. Bump version number, e.g. npm version minor, which will update version number in package.json, commit the changes and tag the commit
  3. Push to github, e.g. git push origin master && git push origin --tags
  4. Wait until Travis and AppVeyor have finished and uploaded prebuilt binaries to GitHub
  5. npm run download-prebuilds to download prebuilt binaries from GitHub.
  6. npm publish

License

Licensed under the GPLv3, see LICENSE file for details.

Copyright © 2018 Delta Chat contributors.