Permalink
Browse files

Tidy up the packaging

  • Loading branch information...
1 parent a7687de commit 65acd41be316dc5d12061bda43affb78b9b2d6eb @legastero committed Nov 20, 2013
Showing with 286 additions and 112 deletions.
  1. +6 −24 .jshintrc
  2. +23 −0 CONTRIBUTING.md
  3. +37 −0 Gruntfile.js
  4. +20 −0 LICENSE
  5. +38 −4 README.md
  6. +10 −0 SECURITY.md
  7. +0 −12 build.js
  8. +17 −19 build/stanzaio.bundle.js
  9. +7 −7 build/stanzaio.bundle.min.js
  10. +2 −0 index.js
  11. +2 −0 lib/client.js
  12. +2 −0 lib/jid.js
  13. +2 −0 lib/plugins/attention.js
  14. +2 −1 lib/plugins/avatar.js
  15. +2 −1 lib/plugins/bookmarks.js
  16. +2 −1 lib/plugins/carbons.js
  17. +2 −1 lib/plugins/chatstates.js
  18. +2 −0 lib/plugins/correction.js
  19. +2 −1 lib/plugins/dataforms.js
  20. +2 −1 lib/plugins/delayed.js
  21. +16 −17 lib/plugins/disco.js
  22. +2 −0 lib/plugins/forwarding.js
  23. +2 −0 lib/plugins/hashes.js
  24. +2 −0 lib/plugins/idle.js
  25. +2 −0 lib/plugins/invisible.js
  26. +2 −0 lib/plugins/jingle.js
  27. +2 −0 lib/plugins/json.js
  28. +2 −0 lib/plugins/mam.js
  29. +2 −0 lib/plugins/muc.js
  30. +2 −0 lib/plugins/private.js
  31. +3 −1 lib/plugins/pubsub.js
  32. +2 −0 lib/plugins/receipts.js
  33. +2 −0 lib/plugins/time.js
  34. +2 −0 lib/plugins/version.js
  35. +2 −0 lib/sm.js
  36. +2 −0 lib/stanza/avatar.js
  37. +2 −0 lib/stanza/chatstates.js
  38. +2 −0 lib/stanza/dataforms.js
  39. +2 −0 lib/stanza/disco.js
  40. +2 −0 lib/stanza/error.js
  41. +2 −0 lib/stanza/iq.js
  42. +2 −0 lib/stanza/jingle.js
  43. +2 −0 lib/stanza/json.js
  44. +2 −0 lib/stanza/mam.js
  45. +2 −0 lib/stanza/message.js
  46. +2 −0 lib/stanza/muc.js
  47. +2 −0 lib/stanza/presence.js
  48. +2 −0 lib/stanza/pubsub.js
  49. +2 −0 lib/stanza/roster.js
  50. +2 −0 lib/stanza/rsm.js
  51. +2 −0 lib/stanza/rtp.js
  52. +2 −0 lib/stanza/sasl.js
  53. +2 −0 lib/stanza/stream.js
  54. +2 −0 lib/stanza/streamError.js
  55. +2 −0 lib/stanza/streamFeatures.js
  56. +2 −0 lib/stanza/time.js
  57. +2 −0 lib/stanza/util.js
  58. +8 −18 lib/websocket.js
  59. +9 −4 package.json
View
@@ -7,28 +7,10 @@
"white": true,
"undef": true,
"browser": true,
- "predef": [
- "app",
- "$",
- "FormBot",
- "socket",
- "confirm",
- "alert",
- "require",
- "__dirname",
- "process",
- "exports",
- "console",
- "Buffer",
- "module",
- "escape",
- "unescape",
- "MediaStream",
- "webkitRTCPeerConnection",
- "webkitMediaStream",
- "webkitURL",
- "mozRTCSessionDescription",
- "mozRTCPeerConnection",
- "mozRTCIceCandidate"
- ]
+ "node": true,
+ "trailing": true,
+ "indent": 4,
+ "latedef": true,
+ "newcap": true,
+ "strict": true
}
View
@@ -0,0 +1,23 @@
+# Contributing
+
+## Issues
+
+Feel free to submit bug reports or pull requests.
+
+If you have a security related issue, please see the [Security Guidelines](SECURITY.md) first.
+
+## Pull Requests
+
+For any code changes, please ensure that:
+
+- The latest master branch has been incorporated in your branch
+- JSHint is happy
+- All current tests pass
+- All new tests (there are new tests, right?) pass
+
+The git pre-commit hook should catch most of the above issues if you run `npm install` first to set it up.
+
+## Licensing
+
+All contributions MUST be submitted under the MIT license. Please do not contribute code that you did not write,
+unless you are certain you have the authorization to both do so and release it under MIT.
View
@@ -0,0 +1,37 @@
+"use strict";
+
+module.exports = function (grunt) {
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ browserify: {
+ options: {
+ standalone: 'XMPP'
+ },
+ dist: {
+ files: {
+ 'build/stanzaio.bundle.js': ['<%= pkg.main %>']
+ }
+ }
+ },
+ uglify: {
+ options: {
+ banner: '/*! stanzaio <%= grunt.template.today("yyyy-mm-dd") %>'
+ },
+ dist: {
+ files: {
+ 'build/stanzaio.bundle.min.js': ['build/stanzaio.bundle.js']
+ }
+ }
+ },
+ jshint: {
+ files: ['Gruntfile.js', 'index.js', 'lib/**.js', 'test/**.js'],
+ options: grunt.file.readJSON('.jshintrc')
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-browserify');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+
+ grunt.registerTask('default', ['jshint', 'browserify', 'uglify']);
+};
View
20 LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Lance Stout
+
+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.
View
@@ -1,11 +1,45 @@
-stanza.io
-=========
+# Stanza.io
+**Modern XMPP in the browser, with a JSON API.**
-Getting Started
----------------
+[![Build Status](https://travis-ci.org/legastero/stanza.io.png)](https://travis-ci.org/legastero/stanza.io)
+[![Dependency Status](https://david-dm.org/legastero/stanza.io.png)](https://david-dm.org/legastero/stanza.io)
+[![devDependency Status](https://david-dm.org/legastero/stanza.io/dev-status.png)](https://david-dm.org/legastero/stanza.io#info=devDependencies)
+
+[![Browser Support](https://ci.testling.com/legastero/stanza.io.png)](https://ci.testling.com/legastero/stanza.io)
+
+## What is this?
+
+A basic framework for translating XML to dev-friendly JSON and back again, and can be used
+both in the browser and in node.
+
+## Installing
+
+```sh
+$ npm install jxt
+```
+
+## Building bundled/minified version (for AMD, etc)
+
+```sh
+$ grunt
+```
+
+The bundled and minified files will be in the generated `build` directory.
+
+## Getting Started
1. Find or install a server which supports XMPP over WebSocket (Prosody recommended).
2. Run `npm install` to build `stanza.io.js`
3. Open `demo.html` in your browser
4. Enter your connection info, click connect.
5. Use the JS console to play with the XMPP client (var client).
+
+If you want to see stanza.io in action in a full-featured client, take a look at [Otalk.im](http://otalk.im) (and its [source](https://github.com/andyet/otalk).
+
+## License
+
+MIT
+
+## Created By
+
+If you like this, follow [@lancestout](http://twitter.com/lancestout) on twitter.
View
@@ -0,0 +1,10 @@
+# Reporting Security Issues
+
+[Report Vulnerability to the Node Security Project](mailto:report@nodesecurity.io?cc=lancestout@gmail.com&subject=Security%20Issue%20for%20Stanza.io)
+
+In the interest of responsible disclosure, please use the above to report any security issues so
+that the appropriate patches and advisories can be made.
+
+## History
+
+No security issues have been reported for this project yet.
View
@@ -1,12 +0,0 @@
-var browserify = require('browserify');
-var UglifyJS = require('uglify-js');
-var fs = require('fs');
-
-
-var bundle = browserify();
-bundle.add('./index');
-bundle.bundle({standalone: 'XMPP'}, function (err, js) {
- fs.writeFileSync('build/stanzaio.bundle.js', js);
- var min = UglifyJS.minify(js, {fromString: true}).code;
- fs.writeFileSync('build/stanzaio.bundle.min.js', min);
-});
View
@@ -1,4 +1,6 @@
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.XMPP=e():"undefined"!=typeof global?global.XMPP=e():"undefined"!=typeof self&&(self.XMPP=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+"use strict";
+
exports.Message = require('./lib/stanza/message');
exports.Presence = require('./lib/stanza/presence');
exports.Iq = require('./lib/stanza/iq');
@@ -35,6 +37,8 @@ exports.createClient = function (opts) {
};
},{"./lib/client":2,"./lib/plugins/attention":4,"./lib/plugins/avatar":5,"./lib/plugins/bookmarks":6,"./lib/plugins/carbons":7,"./lib/plugins/chatstates":8,"./lib/plugins/correction":9,"./lib/plugins/delayed":10,"./lib/plugins/disco":11,"./lib/plugins/forwarding":12,"./lib/plugins/hashes":13,"./lib/plugins/idle":14,"./lib/plugins/invisible":15,"./lib/plugins/jingle":16,"./lib/plugins/json":17,"./lib/plugins/mam":18,"./lib/plugins/muc":19,"./lib/plugins/private":20,"./lib/plugins/pubsub":21,"./lib/plugins/receipts":22,"./lib/plugins/time":23,"./lib/plugins/version":24,"./lib/stanza/iq":38,"./lib/stanza/message":42,"./lib/stanza/presence":44,"crypto":72}],2:[function(require,module,exports){
+"use strict";
+
var WildEmitter = require('wildemitter');
var _ = require('underscore');
var async = require('async');
@@ -590,6 +594,8 @@ Client.prototype.JID = function (jid) {
module.exports = Client;
},{"./jid":3,"./stanza/bind":27,"./stanza/error":35,"./stanza/iq":38,"./stanza/message":42,"./stanza/presence":44,"./stanza/roster":48,"./stanza/sasl":51,"./stanza/session":52,"./stanza/sm":53,"./stanza/stream":54,"./stanza/streamError":55,"./stanza/streamFeatures":56,"./websocket":61,"async":62,"hostmeta":77,"node-uuid":105,"paddle":106,"sasl-anonymous":108,"sasl-digest-md5":110,"sasl-external":112,"sasl-plain":114,"sasl-scram-sha-1":116,"saslmechanisms":118,"underscore":119,"wildemitter":120}],3:[function(require,module,exports){
+"use strict";
+
function JID(jid) {
jid = jid || '';
@@ -1516,6 +1522,8 @@ module.exports = function (client) {
};
},{"../stanza/version":59}],25:[function(require,module,exports){
+"use strict";
+
var SM = require('./stanza/sm');
var MAX_SEQ = Math.pow(2, 32);
@@ -3864,7 +3872,10 @@ stanza.add(Iq, 'visible', stanza.boolSub('urn:xmpp:invisible:0', 'visible'));
stanza.add(Iq, 'invisible', stanza.boolSub('urn:xmpp:invisible:0', 'invisible'));
},{"./iq":38,"jxt":98}],61:[function(require,module,exports){
+"use strict";
+
var _ = require('underscore');
+var stanza = require('jxt');
var WildEmitter = require('wildemitter');
var async = require('async');
var Stream = require('./stanza/stream');
@@ -3884,31 +3895,20 @@ function WSConnection() {
self.sendQueue = async.queue(function (data, cb) {
if (self.conn) {
- self.emit('raw:outgoing', data);
-
self.sm.track(data);
if (typeof data !== 'string') {
data = data.toString();
}
+ self.emit('raw:outgoing', data);
self.conn.send(data);
}
cb();
}, 1);
function wrap(data) {
- var result = [self.streamStart, data, self.streamEnd].join('');
- return result;
- }
-
- function parse(data) {
- var nodes = (self.parser.parseFromString(data, 'application/xml')).childNodes;
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].nodeType === 1) {
- return nodes[i];
- }
- }
+ return [self.streamStart, data, self.streamEnd].join('');
}
self.on('connected', function () {
@@ -3935,7 +3935,7 @@ function WSConnection() {
return self.disconnect();
} else if (self.hasStream) {
try {
- streamData = new Stream({}, parse(wrap(data)));
+ streamData = stanza.parse(Stream, wrap(data));
} catch (e) {
return self.disconnect();
}
@@ -3947,10 +3947,10 @@ function WSConnection() {
ended = false;
try {
- streamData = new Stream({}, parse(data + self.streamEnd));
+ streamData = stanza.parse(Stream, wrap(data));
} catch (e) {
try {
- streamData = new Stream({}, parse(data));
+ streamData = stanza.parse(Stream, data);
ended = true;
} catch (e2) {
return self.disconnect();
@@ -3999,8 +3999,6 @@ WSConnection.prototype.connect = function (opts) {
self.hasStream = false;
self.streamStart = '<stream:stream xmlns:stream="http://etherx.jabber.org/streams">';
self.streamEnd = '</stream:stream>';
- self.parser = new DOMParser();
- self.serializer = new XMLSerializer();
self.conn = new WebSocket(opts.wsURL, 'xmpp');
self.conn.onerror = function (e) {
@@ -4058,7 +4056,7 @@ WSConnection.prototype.send = function (data) {
module.exports = WSConnection;
-},{"./sm":25,"./stanza/iq":38,"./stanza/message":42,"./stanza/presence":44,"./stanza/stream":54,"async":62,"node-uuid":105,"underscore":119,"wildemitter":120}],62:[function(require,module,exports){
+},{"./sm":25,"./stanza/iq":38,"./stanza/message":42,"./stanza/presence":44,"./stanza/stream":54,"async":62,"jxt":98,"node-uuid":105,"underscore":119,"wildemitter":120}],62:[function(require,module,exports){
var process=require("__browserify_process");/*global setImmediate: false, setTimeout: false, console: false */
(function () {

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,3 +1,5 @@
+"use strict";
+
exports.Message = require('./lib/stanza/message');
exports.Presence = require('./lib/stanza/presence');
exports.Iq = require('./lib/stanza/iq');
View
@@ -1,3 +1,5 @@
+"use strict";
+
var WildEmitter = require('wildemitter');
var _ = require('underscore');
var async = require('async');
View
@@ -1,3 +1,5 @@
+"use strict";
+
function JID(jid) {
jid = jid || '';
View
@@ -1,3 +1,5 @@
+"use strict";
+
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:attention:0');
View
@@ -1,5 +1,6 @@
-var stanzas = require('../stanza/avatar');
+"use strict";
+var stanzas = require('../stanza/avatar');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:avatar:metadata+notify');
View
@@ -1,5 +1,6 @@
-var stanzas = require('../stanza/bookmarks');
+"use strict";
+var stanzas = require('../stanza/bookmarks');
module.exports = function (client) {
View
@@ -1,5 +1,6 @@
-var stanzas = require('../stanza/carbons');
+"use strict";
+var stanzas = require('../stanza/carbons');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:carbons:2');
@@ -1,5 +1,6 @@
-var stanzas = require('../stanza/chatstates');
+"use strict";
+var stanzas = require('../stanza/chatstates');
module.exports = function (client) {
client.disco.addFeature('http://jabber.org/protocol/chatstates');
@@ -1,3 +1,5 @@
+"use strict";
+
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:message-correct:0');
View
@@ -1,5 +1,6 @@
-require('../stanza/dataforms');
+"use strict";
+require('../stanza/dataforms');
module.exports = function (client) {
client.disco.addFeature('jabber:x:data');
View
@@ -1,5 +1,6 @@
-var stanzas = require('../stanza/delayed');
+"use strict";
+var stanzas = require('../stanza/delayed');
module.exports = function (client) {
client.disco.addFeature('urn:xmpp:delay');
Oops, something went wrong.

0 comments on commit 65acd41

Please sign in to comment.