Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Fix for 1 vulnerabilities #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ e.g. System Message
* **`renderMessageText`** _(Function)_ - Custom message text
* **`renderMessageImage`** _(Function)_ - Custom message image
* **`imageProps`** _(Object)_ - Extra props to be passed to the [`<Image>`](https://facebook.github.io/react-native/docs/image.html) component created by the default `renderMessageImage`
* **`videoProps`** _(Object)_ - Extra props to be passed to the [`<Video>`](https://github.com/react-native-community/react-native-video) component created by the default `renderMessageVideo`
* **`lightboxProps`** _(Object)_ - Extra props to be passed to the `MessageImage`'s [Lightbox](https://github.com/oblador/react-native-lightbox)
* **`renderCustomView`** _(Function)_ - Custom view inside the bubble
* **`renderDay`** _(Function)_ - Custom day above a message
Expand Down
8 changes: 8 additions & 0 deletions example-pusher-chatkit/.snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.5
ignore: {}
# patches apply the minimum changes required to fix a vulnerability
patch:
'npm:lodash:20180130':
- react-native > plist > xmlbuilder > lodash:
patched: '2019-10-16T14:03:49.763Z'
18,245 changes: 12,134 additions & 6,111 deletions example-pusher-chatkit/package-lock.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions example-pusher-chatkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
"test": "jest",
"snyk-protect": "snyk protect",
"prepare": "npm run snyk-protect"
},
"dependencies": {
"@pusher/chatkit": "^0.7.12",
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-gifted-chat": "^0.4.3"
"react-native": "0.60.0",
"react-native-gifted-chat": "^0.4.3",
"snyk": "^1.290.1"
},
"devDependencies": {
"babel-jest": "22.4.3",
Expand All @@ -20,5 +23,6 @@
},
"jest": {
"preset": "react-native"
}
},
"snyk": true
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"react-native-communications": "2.2.1",
"react-native-lightbox": "^0.7.0",
"react-native-parsed-text": "^0.0.20",
"uuid": "3.3.0"
"uuid": "3.3.0",
"react-native-video": "^3.2.1"
},
"peerDependencies": {
"prop-types": "*",
Expand Down
15 changes: 15 additions & 0 deletions src/Bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Time from './Time';
import Color from './Color';

import { isSameUser, isSameDay } from './utils';
import MessageVideo from './MessageVideo';

export default class Bubble extends React.PureComponent {

Expand Down Expand Up @@ -90,6 +91,17 @@ export default class Bubble extends React.PureComponent {
return null;
}

renderMessageVideo() {
if (this.props.currentMessage.video) {
const { containerStyle, wrapperStyle, ...messageVideoProps } = this.props;
if (this.props.renderMessageVideo) {
return this.props.renderMessageVideo(messageVideoProps);
}
return <MessageVideo {...messageVideoProps} />;
}
return null;
}

renderTicks() {
const { currentMessage } = this.props;
if (this.props.renderTicks) {
Expand Down Expand Up @@ -146,6 +158,7 @@ export default class Bubble extends React.PureComponent {
<View>
{this.renderCustomView()}
{this.renderMessageImage()}
{this.renderMessageVideo()}
{this.renderMessageText()}
<View style={[styles.bottom, this.props.bottomContainerStyle[this.props.position]]}>
{this.renderTime()}
Expand Down Expand Up @@ -222,6 +235,7 @@ Bubble.defaultProps = {
touchableProps: {},
onLongPress: null,
renderMessageImage: null,
renderMessageVideo: null,
renderMessageText: null,
renderCustomView: null,
renderTicks: null,
Expand All @@ -247,6 +261,7 @@ Bubble.propTypes = {
touchableProps: PropTypes.object,
onLongPress: PropTypes.func,
renderMessageImage: PropTypes.func,
renderMessageVideo: PropTypes.func,
renderMessageText: PropTypes.func,
renderCustomView: PropTypes.func,
renderTime: PropTypes.func,
Expand Down
2 changes: 2 additions & 0 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ GiftedChat.defaultProps = {
renderMessageText: null,
renderMessageImage: null,
imageProps: {},
videoProps: {},
lightboxProps: {},
textInputProps: {},
listViewProps: {},
Expand Down Expand Up @@ -586,6 +587,7 @@ GiftedChat.propTypes = {
renderMessageText: PropTypes.func,
renderMessageImage: PropTypes.func,
imageProps: PropTypes.object,
videoProps: PropTypes.object,
lightboxProps: PropTypes.object,
renderCustomView: PropTypes.func,
renderDay: PropTypes.func,
Expand Down
56 changes: 56 additions & 0 deletions src/MessageVideo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import PropTypes from 'prop-types';
import React from 'react';
import { StyleSheet, View, ViewPropTypes } from 'react-native';
import Video from 'react-native-video';


export default function MessageVideo({
containerStyle,
videoProps,
videoStyle,
currentMessage,
}) {
return (
// eslint-disable-next-line no-use-before-define
<View style={[styles.container, containerStyle]}>

<Video
{...videoProps}
ref={(r) => { this.player = r; }}
source={{ uri: currentMessage.video }}
style={videoStyle}
resizeMode="cover"
onBuffer={this.onBuffer}
onLoadStart={this.onLoadStart}
onLoad={this.onLoad}
/>
</View>
);
}

const styles = StyleSheet.create({
container: {
},
});

MessageVideo.defaultProps = {
currentMessage: {
// video: null,
},
containerStyle: {},
videoStyle: {
width: 150,
height: 100,
borderRadius: 13,
margin: 3,
resizeMode: 'cover',
},
videoProps: {},
};

MessageVideo.propTypes = {
currentMessage: PropTypes.object,
containerStyle: ViewPropTypes.style,
videoStyle: ViewPropTypes.style,
videoProps: PropTypes.object,
};