pax_global_header00006660000000000000000000000064134727575050014531gustar00rootroot0000000000000052 comment=7c069920252fa98c96208d90aec0520491c4eabe strophejs-plugin-mam-0.0.3/000077500000000000000000000000001347275750500156165ustar00rootroot00000000000000strophejs-plugin-mam-0.0.3/.gitignore000066400000000000000000000000331347275750500176020ustar00rootroot00000000000000*~ .*.sw? lib node_modules strophejs-plugin-mam-0.0.3/.npmignore000066400000000000000000000000061347275750500176110ustar00rootroot00000000000000*.log strophejs-plugin-mam-0.0.3/CHANGELOG.md000066400000000000000000000006401347275750500174270ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.0.3] - 2017-07-14 - Add UMD packaging to support more NPM environments ## [0.0.2] - 2017-04-27 - put jid in the right place ## [0.0.1] - 2017-03-16 - Initial release as an NPM package strophejs-plugin-mam-0.0.3/LICENSE.txt000066400000000000000000000020531347275750500174410ustar00rootroot00000000000000Copyright (c) 2012 Kim Alvefur Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. strophejs-plugin-mam-0.0.3/README.markdown000066400000000000000000000040631347275750500203220ustar00rootroot00000000000000# strophe.mam.js Plugin for [strophe.js](https://www.npmjs.com/package/strophe.js) to provide Message Archiving Management ([XEP-0313]( http://xmpp.org/extensions/xep-0313.html)). This plugin requires the [Strophe.RSM](https://github.com/strophe/strophejs-plugin-rsm) plugin to be loaded as well. ## Install npm install strophejs-plugin-mam ## Usage ### Querying an archive `connection.mam.query(where, parameters)` `where` is the JID hosting the archive. In most cases you will want to set this to your own bare JID in order query your personal archive, but it could also be a MUC room, an archiving component or a bot. `parameters` is an object containing parameters for the query. This can have properties from two and a half categories: **Handlers**: `onMessage` which gets called for each message received, and `onComplete` which is called when the query is completed. **Filtering**: Half of this is the parameters defined by MAM; `with`, `start` or `end`, which allow you to filter the results on who the conversation was *with*, and the time range. Additionally, parameters from [Result Set Management][RSM] can be supplied. You would probably be most interested in the `after` and `before` properties, which allow you to do pagination of the result set, and the `max` property, which allow you to limit the number of items in each page. *Note:* Better RSM integration is on the TODO, you currently have to pick out the `last` or `first` items yourself and pass those as `after` or `before` respectively. [RSM]: http://xmpp.org/extensions/xep-0059.html ### Example To query, for example, your personal archive for conversations with `juliet@capulet.com` you could do: connection.mam.query("you@example.com", { "with": "juliet@capulet.com", onMessage: function(message) { console.log("Message from ", $(message).find("forwarded message").attr("from"), ": ", $(message).find("forwarded message body").text()); return true; }, onComplete: function(response) { console.log("Got all the messages"); } }); strophejs-plugin-mam-0.0.3/package-lock.json000066400000000000000000000016771347275750500210450ustar00rootroot00000000000000{ "name": "strophejs-plugin-mam", "version": "0.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { "rollup": { "version": "0.45.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.45.1.tgz", "integrity": "sha512-uAARayLMSESiUdpwkcDgUky4TwPBQhvpZmz3UuMtNoyeq79iHEM9IyBTB/5TWEBtzz4D/j2x0KAGMOVq6MhO7g==", "dev": true, "requires": { "source-map-support": "0.4.15" } }, "source-map": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", "dev": true }, "source-map-support": { "version": "0.4.15", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz", "integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E=", "dev": true, "requires": { "source-map": "0.5.6" } } } } strophejs-plugin-mam-0.0.3/package.json000066400000000000000000000017161347275750500201110ustar00rootroot00000000000000{ "name": "strophejs-plugin-mam", "version": "0.0.3", "description": "A strophe.js plugin for Message Archive Management (XEP-0313)", "main": "lib/strophe.mam.js", "scripts": { "build": "rollup src/strophe.mam.js -f umd -g strophe.js:window -e strophejs-plugin-rsm -o lib/strophe.mam.js -m", "prepublish": "npm run --silent build", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/strophe/strophejs-plugin-mam.git" }, "keywords": [ "strophe.js", "strophe", "xmpp", "plugin" ], "author": "The strophe plugin developers", "license": "MIT", "bugs": { "url": "https://github.com/strophe/strophejs-plugin-mam/issues" }, "homepage": "https://github.com/strophe/strophejs-plugin-mam#readme", "devDependencies": { "rollup": "^0.45.0" }, "peerDependencies": { "strophe.js": "^1.2.12", "strophejs-plugin-rsm": ">=0.0.1" } } strophejs-plugin-mam-0.0.3/src/000077500000000000000000000000001347275750500164055ustar00rootroot00000000000000strophejs-plugin-mam-0.0.3/src/strophe.mam.js000066400000000000000000000037701347275750500212070ustar00rootroot00000000000000/* XEP-0313: Message Archive Management * Copyright (C) 2012 Kim Alvefur * * This file is MIT/X11 licensed. Please see the * LICENSE.txt file in the source package for more information. * * Modified by: Chris Tunbridge (github.com/Destreyf/) * Updated to support v0.3 of the XMPP XEP-0313 standard * http://xmpp.org/extensions/xep-0313.html * */ import { $iq, Strophe } from 'strophe.js'; Strophe.addConnectionPlugin('mam', { _c: null, _p: [ 'with', 'start', 'end' ], init: function (conn) { this._c = conn; Strophe.addNamespace('MAM', 'urn:xmpp:mam:2'); }, query: function (jid, options) { var _p = this._p; var attr = { type:'set', to:jid }; options = options || {}; var mamAttr = {xmlns: Strophe.NS.MAM}; if (!!options.queryid) { mamAttr.queryid = options.queryid; delete options.queryid; } var iq = $iq(attr).c('query', mamAttr).c('x',{xmlns:'jabber:x:data', type:'submit'}); iq.c('field',{var:'FORM_TYPE', type:'hidden'}).c('value').t(Strophe.NS.MAM).up().up(); var i; for (i = 0; i < this._p.length; i++) { var pn = _p[i]; var p = options[pn]; delete options[pn]; if (!!p) { iq.c('field',{var:pn}).c('value').t(p).up().up(); } } iq.up(); var onMessage = options.onMessage; delete options.onMessage; var onComplete = options.onComplete; delete options.onComplete; iq.cnode(new Strophe.RSM(options).toXML()); var _c = this._c; var handler = _c.addHandler(onMessage, Strophe.NS.MAM, 'message', null); return this._c.sendIQ(iq, function(){ _c.deleteHandler(handler); onComplete.apply(this, arguments); }, function(err){ //error callBack function console.log("Error Response from server:", err); }); } });