pax_global_header 0000666 0000000 0000000 00000000064 13132231220 0014477 g ustar 00root root 0000000 0000000 52 comment=2b6b91b63ef27f1b17d6057f48d10b068fcf529f
strophejs-plugin-rsm-0.0.2/ 0000775 0000000 0000000 00000000000 13132231220 0015612 5 ustar 00root root 0000000 0000000 strophejs-plugin-rsm-0.0.2/.gitignore 0000664 0000000 0000000 00000000033 13132231220 0017576 0 ustar 00root root 0000000 0000000 *~
.*.sw?
lib
node_modules
strophejs-plugin-rsm-0.0.2/.npmignore 0000664 0000000 0000000 00000000006 13132231220 0017605 0 ustar 00root root 0000000 0000000 *.log
strophejs-plugin-rsm-0.0.2/CHANGELOG.md 0000664 0000000 0000000 00000000235 13132231220 0017423 0 ustar 00root root 0000000 0000000 # 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.txt 0000664 0000000 0000000 00000002120 13132231220 0017430 0 ustar 00root root 0000000 0000000 MIT 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.md 0000664 0000000 0000000 00000003120 13132231220 0017065 0 ustar 00root root 0000000 0000000 # 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.json 0000664 0000000 0000000 00000001677 13132231220 0021041 0 ustar 00root root 0000000 0000000 {
"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.json 0000664 0000000 0000000 00000001603 13132231220 0020100 0 ustar 00root root 0000000 0000000 {
"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/ 0000775 0000000 0000000 00000000000 13132231220 0016401 5 ustar 00root root 0000000 0000000 strophejs-plugin-rsm-0.0.2/src/strophe.rsm.js 0000664 0000000 0000000 00000002654 13132231220 0021232 0 ustar 00root root 0000000 0000000 import { $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');
}
}
}
}
};