-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sonny Piers
committed
Nov 29, 2017
1 parent
7b29c82
commit 9278794
Showing
54 changed files
with
712 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
const xml = require('@xmpp/xml') | ||
|
||
/* | ||
* References | ||
* https://xmpp.org/rfcs/rfc6120.html#bind | ||
*/ | ||
|
||
const NS = 'urn:ietf:params:xml:ns:xmpp-bind' | ||
|
||
function makeBindElement(resource) { | ||
return xml('bind', {xmlns: NS}, resource && xml('resource', {}, resource)) | ||
} | ||
|
||
function match(features) { | ||
return features.getChild('bind', NS) | ||
} | ||
|
||
module.exports = function bind(streamFeatures) { | ||
const {entity} = streamFeatures | ||
|
||
function bind(resource) { | ||
entity._status('binding') | ||
return entity.plugins['iq-caller'] | ||
.set(makeBindElement(resource)) | ||
.then(result => { | ||
const jid = result.getChildText('jid') | ||
entity._jid(jid) | ||
entity._status('bound') | ||
return jid | ||
}) | ||
} | ||
|
||
function handleFeature() { | ||
entity._status('bind') | ||
return entity.isHandled('bind') | ||
? entity.delegate('bind', resource => bind(resource)) | ||
: bind() | ||
} | ||
|
||
streamFeatures.use({ | ||
name: 'bind', | ||
priority: 2500, | ||
match, | ||
run: () => handleFeature(), | ||
}) | ||
|
||
return {bind} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "@xmpp/bind", | ||
"description": "XMPP bind for JavaScript", | ||
"repository": "github:xmppjs/xmpp.js", | ||
"homepage": "https://github.com/xmppjs/xmpp.js/tree/master/packages/bind", | ||
"bugs": "http://github.com/xmppjs/xmpp.js/issues", | ||
"version": "0.3.0", | ||
"license": "ISC", | ||
"keywords": ["XMPP", "bind"], | ||
"dependencies": { | ||
"@xmpp/xml": "^0.3.0" | ||
}, | ||
"engines": { | ||
"node": ">= 6", | ||
"npm": ">= 2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
'use strict' | ||
|
||
exports['stream-features'] = require('@xmpp/plugins/stream-features') | ||
exports.bind = require('@xmpp/plugins/bind') | ||
exports.sasl = require('@xmpp/plugins/sasl') | ||
exports['sasl-plain'] = require('@xmpp/plugins/sasl-plain') | ||
exports['sasl-scram-sha-1'] = require('@xmpp/plugins/sasl-scram-sha-1') | ||
exports['sasl-anonymous'] = require('@xmpp/plugins/sasl-anonymous') | ||
exports.starttls = require('@xmpp/plugins/starttls') | ||
exports.resolve = require('@xmpp/plugins/resolve') | ||
exports[ | ||
'session-establishment' | ||
] = require('@xmpp/plugins/session-establishment') | ||
exports['iq-caller'] = require('@xmpp/plugins/iq-caller') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.