JavaScript implementation of CPIM "Common Presence and Instant Messaging" (RFC 3862)
npm install cpimJavaScript implementation of CPIM "Common Presence and Instant Messaging" (RFC 3862).
Suitable for parsing and generating CPIM messages, allowing access to CPIM headers and the MIME component (via the mimemessage library) of messages such as:
``
From: Iñaki Baz Castillo
To: Alice
Subject: Wines tonight!
DateTime: 2015-06-25T11:30:00-08:00
Content-type: text/plain; charset=utf-8
Hi Alice, tonight wines at home
`
`bash`
$ npm install cpim --save
And then:
`javascript`
var cpim = require('cpim');
The browserified version of the library at dist/cpim.js exposes the global window.cpim module.
`html`
Let's build a CPIM message to invite Alice to our party.
`javascript
var cpim = require('cpim');
var message, mime;
mime = cpim.mimemessage.factory({
contentType: 'text/html',
body: '
message = cpim.factory({
from: 'Iñaki Baz Castillo
to: 'Alice
subject: 'Hi!',
mime: mime
});
`
By calling message.toString() it produces the following CPIM formatted string:
`
From: Iñaki Baz Castillo
To: Alice
DateTime: 2015-08-11T12:05:43.569Z
Content-Type: text/html
Documentation
You can read the full API documentation in the docs folder.
$3
The library includes the Node debug module. In order to enable debugging:
In Node set the
DEBUG=cpim* environment variable before running the application, or set it at the top of the script:`javascript
process.env.DEBUG = 'cpim*';
`You may prefer to also enable MIME debug:
`javascript
process.env.DEBUG = 'cpim mimemessage';
`In the browser run
cpim.debug.enable('cpim'); and reload the page. Note that the debugging settings are stored into the browser LocalStorage. To disable it run cpim.debug.disable('cpim');`.Iñaki Baz Castillo at eFace2Face, inc.
MIT :)