Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Off-the-Record Messaging Protocol implemented in JavaScript
JavaScript HTML C Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
vendor
.gitignore
.travis.yml
Makefile
grunt.js
license
otr.js
otr.min.js
package.json
readme.md

readme.md

Off-the Record Messaging Protocol v2 in JavaScript

Build Status


Warning

Replace Math.random()

See: bigint.js


Install

For now, see this example for use in the browser.

Although this is a client library, it can be used on the server.

npm install otr

Usage

Initial setup: Compute your long-lived key beforehand. Currently this is expensive and can take upwards of half a second. For each user you're communicating with, instantiate an OTR object.

var OTR = require('otr')
  , DSA = require('dsa')

// precompute your DSA key
var myKey = new DSA.Key()

// provide some callbacks to otr
var uicb = function (msg) {
  console.log("message to display to the user: " + msg)
}
var iocb = function (msg) {
  console.log("message to send to buddy: " + msg)
}

// provide options
var options = {
    fragment_size: 140  // fragment the message in case of char limits
  , send_interval: 200  // ms delay between sending fragmented msgs, avoid rate limits
}

var buddyList = {
    'userA': new OTR(myKey, uicb, iocb, options)
  , 'userB' new OTR(myKey uicb, iocb, options)
}

New message from userA received: Pass the received message to the receiveMsg method.

var rcvmsg = "Message from userA."
buddyList.userA.receiveMsg(rcvmsg)

Send a message to userA: Pass the message to the sendMsg method.

var newmsg = "Message to userA."
buddyList.userA.sendMsg(newmsg)

Spec: http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html

Using:

Something went wrong with that request. Please try again.