Adopts to new JWT impl where the token goes as BOSH URL param.
This commit is contained in:
parent
75811941e0
commit
bf3cce0875
|
@ -52,7 +52,7 @@ function JitsiConference(options) {
|
|||
*/
|
||||
JitsiConference.prototype.join = function (password) {
|
||||
if(this.room)
|
||||
this.room.join(password, this.connection.tokenPassword);
|
||||
this.room.join(password);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,32 +1,17 @@
|
|||
var JitsiConference = require("./JitsiConference");
|
||||
var XMPP = require("./modules/xmpp/xmpp");
|
||||
var RandomUtil = require("./modules/util/RandomUtil");
|
||||
|
||||
/**
|
||||
* Utility method that generates user name based on random hex values.
|
||||
* Eg. 12345678-1234-1234-12345678
|
||||
* @returns {string}
|
||||
*/
|
||||
function generateUserName() {
|
||||
return RandomUtil.random8digitsHex() + "-" + RandomUtil.random4digitsHex() + "-" +
|
||||
RandomUtil.random4digitsHex() + "-" + RandomUtil.random8digitsHex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
|
||||
* JitsiConference interface.
|
||||
* @param appID identification for the provider of Jitsi Meet video conferencing services.
|
||||
* @param tokenPassword secret generated by the provider of Jitsi Meet video conferencing services.
|
||||
* The token will be send to the provider from the Jitsi Meet server deployment for authorization of the current client.
|
||||
* The format is:
|
||||
* passwordToken = token + "_" + roomName + "_" + ts
|
||||
* See doc/tokens.md for more info on how tokens are generated.
|
||||
* @param token the JWT token used to authenticate with the server(optional)
|
||||
* @param options Object with properties / settings related to connection with the server.
|
||||
* @constructor
|
||||
*/
|
||||
function JitsiConnection(appID, tokenPassword, options) {
|
||||
function JitsiConnection(appID, token, options) {
|
||||
this.appID = appID;
|
||||
this.tokenPassword = tokenPassword;
|
||||
this.token = token;
|
||||
this.options = options;
|
||||
this.xmpp = new XMPP(options);
|
||||
this.conferences = {};
|
||||
|
@ -40,14 +25,6 @@ JitsiConnection.prototype.connect = function (options) {
|
|||
if(!options)
|
||||
options = {};
|
||||
|
||||
// If we have token provided use it as a password and generate random username
|
||||
if (this.tokenPassword) {
|
||||
options.password = this.tokenPassword;
|
||||
if (!options.id) {
|
||||
options.id = generateUserName() + "@" + this.options.hosts.domain;
|
||||
}
|
||||
}
|
||||
|
||||
this.xmpp.connect(options.id, options.password);
|
||||
}
|
||||
|
||||
|
|
|
@ -2640,10 +2640,12 @@ Strophe.Connection.prototype = {
|
|||
}
|
||||
|
||||
if (!acceptable) {
|
||||
console.error("req: ", elem, "Resp:", stanza);
|
||||
throw {
|
||||
name: "StropheError",
|
||||
message: "Got answer to IQ from wrong jid:" + from +
|
||||
"\nExpected jid: " + expectedFrom
|
||||
"\nExpected jid: " + expectedFrom +"" +
|
||||
"\n stanza to String: " + stanza.toString()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -112,17 +112,17 @@ ChatRoom.prototype.updateDeviceAvailability = function (devices) {
|
|||
});
|
||||
};
|
||||
|
||||
ChatRoom.prototype.join = function (password, tokenPassword) {
|
||||
ChatRoom.prototype.join = function (password) {
|
||||
if(password)
|
||||
this.password = password;
|
||||
var self = this;
|
||||
this.moderator.allocateConferenceFocus(function()
|
||||
{
|
||||
self.sendPresence(tokenPassword);
|
||||
self.sendPresence();
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
ChatRoom.prototype.sendPresence = function (tokenPassword) {
|
||||
ChatRoom.prototype.sendPresence = function () {
|
||||
if (!this.presMap['to']) {
|
||||
// Too early to send presence - not initialized
|
||||
return;
|
||||
|
@ -142,11 +142,6 @@ ChatRoom.prototype.sendPresence = function (tokenPassword) {
|
|||
pres.c('c', this.connection.caps.generateCapsAttrs()).up();
|
||||
}
|
||||
|
||||
if (tokenPassword) {
|
||||
pres.c('token', { xmlns: 'http://jitsi.org/jitmeet/auth-token'})
|
||||
.t(tokenPassword).up();
|
||||
}
|
||||
|
||||
parser.JSON2packet(this.presMap.nodes, pres);
|
||||
this.connection.send(pres);
|
||||
};
|
||||
|
|
|
@ -14,6 +14,12 @@ var authenticatedUser = false;
|
|||
function createConnection(bosh) {
|
||||
bosh = bosh || '/http-bind';
|
||||
|
||||
// Append token as URL param
|
||||
if (this.token) {
|
||||
bosh += bosh.indexOf('?') == -1 ?
|
||||
'?token=' + this.token : '&token=' + this.token;
|
||||
}
|
||||
|
||||
return new Strophe.Connection(bosh);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue