pax_global_header00006660000000000000000000000064131322312200014477gustar00rootroot0000000000000052 comment=2b6b91b63ef27f1b17d6057f48d10b068fcf529f strophejs-plugin-rsm-0.0.2/000077500000000000000000000000001313223122000156125ustar00rootroot00000000000000strophejs-plugin-rsm-0.0.2/.gitignore000066400000000000000000000000331313223122000175760ustar00rootroot00000000000000*~ .*.sw? lib node_modules strophejs-plugin-rsm-0.0.2/.npmignore000066400000000000000000000000061313223122000176050ustar00rootroot00000000000000*.log strophejs-plugin-rsm-0.0.2/CHANGELOG.md000066400000000000000000000002351313223122000174230ustar00rootroot00000000000000# Changelog ## 0.0.2 (2017-07-14) - Add UMD packaging to support more NPM environments ## 0.0.1 (2017-02-16) - First release as a standalone NPM package. strophejs-plugin-rsm-0.0.2/LICENSE.txt000066400000000000000000000021201313223122000174300ustar00rootroot00000000000000MIT License Copyright 2006-2017 Strophe (https://github.com/strophe/strophejs) 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-rsm-0.0.2/README.md000066400000000000000000000031201313223122000170650ustar00rootroot00000000000000# strophe.rsm.js Plugin for [strophe.js](https://www.npmjs.com/package/strophe.js) providing Result Set Management (RSM) [XEP-0059](http://xmpp.org/extensions/xep-0059.html). ## Install ```bash npm install strophejs-plugin-rsm ``` ### ES6 ```js import 'strophejs-plugin-rsm'; ``` ### Browser ``` html ``` ## Usage Make sure [Strophe](https://www.npmjs.com/package/strophe.js) is installed and the plugin is imported into your app. With RSM is available to do paged stanza requests like so: ```js require('strophejs-plugin-rsm'); var connection = new Strophe.Connection('wss://...'); var options = { before: '', isGroup: false, max: 50, }; var messages = []; var queryid = connection.getUniqueId(); var stanza = $iq({ type: 'set' }).c('query', { xmlns: Strophe.NS.MAM, queryid }); var node = new Strophe.RSM(options); stanza.cnode(node.toXML()); connection.addHandler((message: any) => { var fin = getElementByTagName(message, 'fin', Strophe.NS.MAM); var result = getElementByTagName(message, 'result', Strophe.NS.MAM); if (fin && queryid === fin.getAttribute('queryid')) { var paging = new Strophe.RSM({ xml: fin }); // `paging` is now our paged RSM object with the following attributes: // paging.next() // paging.previous() // paging.toXML() // paging.fromXMLElement() return false; } else if (result && queryid === result.getAttribute('queryid')) { messages.push(message); } return true; }, Strophe.NS.MAM); connection.sendIQ(stanza, null, null); ``` strophejs-plugin-rsm-0.0.2/package-lock.json000066400000000000000000000016771313223122000210410ustar00rootroot00000000000000{ "name": "strophejs-plugin-rsm", "version": "0.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { "rollup": { "version": "0.45.2", "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.45.2.tgz", "integrity": "sha512-2+bq5GQSrocdhr+M92mOQRmF1evtLRzv9NdmEC2wo7BILvTG8irHCtD0q+zg8ikNu63iJicdN5IzyxAXRTFKOQ==", "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-rsm-0.0.2/package.json000066400000000000000000000016031313223122000201000ustar00rootroot00000000000000{ "name": "strophejs-plugin-rsm", "version": "0.0.2", "description": "A strophe.js plugin for XEP-0059 Result Set Management", "main": "lib/strophe.rsm.js", "scripts": { "build": "rollup src/strophe.rsm.js -f umd -g strophe.js:window -o lib/strophe.rsm.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-rsm.git" }, "keywords": [ "xmpp", "strophe", "strophe.js", "RSM" ], "author": "The strophe plugin developers", "license": "MIT", "bugs": { "url": "https://github.com/strophe/strophejs-plugin-rsm/issues" }, "homepage": "https://github.com/strophe/strophejs-plugin-rsm#readme", "devDependencies": { "rollup": "^0.45.2" }, "peerDependencies": { "strophe.js": ">=1.2" } } strophejs-plugin-rsm-0.0.2/src/000077500000000000000000000000001313223122000164015ustar00rootroot00000000000000strophejs-plugin-rsm-0.0.2/src/strophe.rsm.js000066400000000000000000000026541313223122000212320ustar00rootroot00000000000000import { $build, Strophe } from 'strophe.js'; Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm'); Strophe.RSM = function(options) { this.attribs = ['max', 'first', 'last', 'after', 'before', 'index', 'count']; if (typeof options.xml != 'undefined') { this.fromXMLElement(options.xml); } else { for (var ii = 0; ii < this.attribs.length; ii++) { var attrib = this.attribs[ii]; this[attrib] = options[attrib]; } } }; Strophe.RSM.prototype = { toXML: function() { var xml = $build('set', {xmlns: Strophe.NS.RSM}); for (var ii = 0; ii < this.attribs.length; ii++) { var attrib = this.attribs[ii]; if (typeof this[attrib] != 'undefined') { xml = xml.c(attrib).t(this[attrib].toString()).up(); } } return xml.tree(); }, next: function(max) { var newSet = new Strophe.RSM({max: max, after: this.last}); return newSet; }, previous: function(max) { var newSet = new Strophe.RSM({max: max, before: this.first}); return newSet; }, fromXMLElement: function(xmlElement) { for (var ii = 0; ii < this.attribs.length; ii++) { var attrib = this.attribs[ii]; var elem = xmlElement.getElementsByTagName(attrib)[0]; if (typeof elem != 'undefined' && elem !== null) { this[attrib] = Strophe.getText(elem); if (attrib == 'first') { this.index = elem.getAttribute('index'); } } } } };