[NEW] Jitsi JWT added to URL (#1746)

This commit is contained in:
Djorkaeff Alexandre 2020-02-18 11:06:14 -03:00 committed by GitHub
parent 270ec79450
commit aaca4ad268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 15 deletions

View File

@ -35,6 +35,9 @@ export default {
Jitsi_Domain: { Jitsi_Domain: {
type: 'valueAsString' type: 'valueAsString'
}, },
Jitsi_Enabled_TokenAuth: {
type: 'valueAsBoolean'
},
Jitsi_URL_Room_Prefix: { Jitsi_URL_Room_Prefix: {
type: 'valueAsString' type: 'valueAsString'
}, },

View File

@ -17,10 +17,25 @@ const jitsiBaseUrl = ({
return `${ urlProtocol }${ urlDomain }${ prefix }${ uniqueIdentifier }`; return `${ urlProtocol }${ urlDomain }${ prefix }${ uniqueIdentifier }`;
}; };
function callJitsi(rid, onlyAudio = false) { async function callJitsi(rid, onlyAudio = false) {
let accessToken;
let queryString = '';
const { settings } = reduxStore.getState(); const { settings } = reduxStore.getState();
const { Jitsi_Enabled_TokenAuth } = settings;
Navigation.navigate('JitsiMeetView', { url: `${ jitsiBaseUrl(settings) }${ rid }`, onlyAudio, rid }); if (Jitsi_Enabled_TokenAuth) {
try {
accessToken = await this.sdk.methodCall('jitsi:generateAccessToken', rid);
} catch (e) {
// do nothing
}
}
if (accessToken) {
queryString = `?jwt=${ accessToken }`;
}
Navigation.navigate('JitsiMeetView', { url: `${ jitsiBaseUrl(settings) }${ rid }${ queryString }`, onlyAudio, rid });
} }
export default callJitsi; export default callJitsi;

View File

@ -2,14 +2,27 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import JitsiMeet, { JitsiMeetView as RNJitsiMeetView } from 'react-native-jitsi-meet'; import JitsiMeet, { JitsiMeetView as RNJitsiMeetView } from 'react-native-jitsi-meet';
import BackgroundTimer from 'react-native-background-timer'; import BackgroundTimer from 'react-native-background-timer';
import { connect } from 'react-redux';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import { getUserSelector } from '../selectors/login';
import sharedStyles from './Styles'; import sharedStyles from './Styles';
const formatUrl = (url, baseUrl, uriSize, avatarAuthURLFragment) => (
`${ baseUrl }/avatar/${ url }?format=png&width=${ uriSize }&height=${ uriSize }${ avatarAuthURLFragment }`
);
class JitsiMeetView extends React.Component { class JitsiMeetView extends React.Component {
static propTypes = { static propTypes = {
navigation: PropTypes.object navigation: PropTypes.object,
baseUrl: PropTypes.string,
user: PropTypes.shape({
id: PropTypes.string,
username: PropTypes.string,
name: PropTypes.string,
token: PropTypes.string
})
} }
constructor(props) { constructor(props) {
@ -21,14 +34,25 @@ class JitsiMeetView extends React.Component {
} }
componentDidMount() { componentDidMount() {
const { navigation } = this.props; const { navigation, user, baseUrl } = this.props;
const {
name: displayName, id: userId, token, username
} = user;
const avatarAuthURLFragment = `&rc_token=${ token }&rc_uid=${ userId }`;
const avatar = formatUrl(username, baseUrl, 100, avatarAuthURLFragment);
setTimeout(() => { setTimeout(() => {
const userInfo = {
displayName,
avatar
};
const url = navigation.getParam('url'); const url = navigation.getParam('url');
const onlyAudio = navigation.getParam('onlyAudio', false); const onlyAudio = navigation.getParam('onlyAudio', false);
if (onlyAudio) { if (onlyAudio) {
JitsiMeet.audioCall(url); JitsiMeet.audioCall(url, userInfo);
} else { } else {
JitsiMeet.call(url); JitsiMeet.call(url, userInfo);
} }
}, 1000); }, 1000);
} }
@ -71,4 +95,9 @@ class JitsiMeetView extends React.Component {
} }
} }
export default JitsiMeetView; const mapStateToProps = state => ({
user: getUserSelector(state),
baseUrl: state.server.server
});
export default connect(mapStateToProps)(JitsiMeetView);

View File

@ -296,7 +296,7 @@ PODS:
- React - React
- react-native-document-picker (3.2.4): - react-native-document-picker (3.2.4):
- React - React
- react-native-jitsi-meet (2.0.4): - react-native-jitsi-meet (2.1.0):
- JitsiMeetSDK - JitsiMeetSDK
- React - React
- react-native-keyboard-input (5.3.1): - react-native-keyboard-input (5.3.1):
@ -753,7 +753,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b
react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320 react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320
react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061 react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061
react-native-jitsi-meet: 5bc06e8b65a7d04fd3705d5720f3b2ec66e49a29 react-native-jitsi-meet: 04ccc47303c62ba2b7e7407a113f5f46241ebd75
react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb
react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8 react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8
react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1 react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-jitsi-meet", "name": "react-native-jitsi-meet",
"version": "2.0.4", "version": "2.1.0",
"summary": "Jitsi Meet SDK wrapper for React Native.", "summary": "Jitsi Meet SDK wrapper for React Native.",
"license": "Apache-2.0", "license": "Apache-2.0",
"authors": { "authors": {
@ -13,7 +13,7 @@
}, },
"source": { "source": {
"git": "https://github.com/skrafft/react-native-jitsi-meet.git", "git": "https://github.com/skrafft/react-native-jitsi-meet.git",
"tag": "v2.0.4" "tag": "v2.1.0"
}, },
"source_files": "ios/**/*.{h,m}", "source_files": "ios/**/*.{h,m}",
"dependencies": { "dependencies": {

View File

@ -296,7 +296,7 @@ PODS:
- React - React
- react-native-document-picker (3.2.4): - react-native-document-picker (3.2.4):
- React - React
- react-native-jitsi-meet (2.0.4): - react-native-jitsi-meet (2.1.0):
- JitsiMeetSDK - JitsiMeetSDK
- React - React
- react-native-keyboard-input (5.3.1): - react-native-keyboard-input (5.3.1):
@ -753,7 +753,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b
react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320 react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320
react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061 react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061
react-native-jitsi-meet: 5bc06e8b65a7d04fd3705d5720f3b2ec66e49a29 react-native-jitsi-meet: 04ccc47303c62ba2b7e7407a113f5f46241ebd75
react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb
react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8 react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8
react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1 react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1

View File

@ -9493,8 +9493,8 @@ react-native-iphone-x-helper@^1.0.3:
integrity sha512-xIeTo4s77wwKgBZLVRIZC9tM9/PkXS46Ul76NXmvmixEb3ZwqGdQesR3zRiLMOoIdfOURB6N9bba9po7+x9Bag== integrity sha512-xIeTo4s77wwKgBZLVRIZC9tM9/PkXS46Ul76NXmvmixEb3ZwqGdQesR3zRiLMOoIdfOURB6N9bba9po7+x9Bag==
react-native-jitsi-meet@RocketChat/react-native-jitsi-meet: react-native-jitsi-meet@RocketChat/react-native-jitsi-meet:
version "2.0.4" version "2.1.0"
resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/5f535b301d18a26860e2e04ca5b164a564184b48" resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/351789a80ba5c05f27b702e69d3354f0e3651a49"
react-native-keyboard-aware-scroll-view@0.9.1: react-native-keyboard-aware-scroll-view@0.9.1:
version "0.9.1" version "0.9.1"