Skip to content
Merged
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
14 changes: 13 additions & 1 deletion Hcaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const buildHcaptchaApiUrl = (jsSrc, siteKey, hl, theme, host, sentry, endpoint,
* @param {string} imghost: Points loaded hCaptcha challenge images to a user defined image location, used for proxies. Default: https://imgs.hcaptcha.com (Override only if using first-party hosting feature.)
* @param {string} host: hCaptcha SDK host identifier. null value means that it will be generated by SDK
* @param {object} debug: debug information
* @parem {string} hCaptcha challenge orientation
* @param {string} orientation: hCaptcha challenge orientation
*/
const Hcaptcha = ({
onMessage,
Expand Down Expand Up @@ -241,7 +241,19 @@ const Hcaptcha = ({
if (event.url.slice(0, 24) === 'https://www.hcaptcha.com') {
Linking.openURL(event.url);
return false;
} else if (event.url.toLowerCase().startsWith('sms:')) {
Linking.openURL(event.url).catch((err) => {
onMessage({
nativeEvent: {
data: 'sms-open-failed',
description: err.message,
},
success: false
});
});
return false;
}

return true;
}}
mixedContentMode={'always'}
Expand Down
6 changes: 3 additions & 3 deletions __mocks__/react-native-webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const setWebViewMessageData = (data) => {
messageDataToSend = data;
};

const WebView = (props) => {
const WebView = React.forwardRef((props, ref) => {
const { onMessage } = props;

React.useEffect(() => {
Expand All @@ -17,7 +17,7 @@ const WebView = (props) => {
}
}, [onMessage]);

return React.createElement('WebView', props);
};
return React.createElement('WebView', { ...props, ref });
});

export default WebView;
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/ConfirmHcaptcha.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://all.props/api-endpoint?render=explicit&onload=onloadCallback&host=all-props-host&hl=en&sentry=true&endpoint=https%3A%2F%2Fall.props%2Fendpoint&assethost=https%3A%2F%2Fall.props%2Fassethost&imghost=https%3A%2F%2Fall.props%2Fimghost&reportapi=https%3A%2F%2Fall.props%2Freportapi&orientation=portrait" async defer></script>
<script type="text/javascript">
Expand Down
10 changes: 5 additions & 5 deletions __tests__/__snapshots__/Hcaptcha.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports[`Hcaptcha snapshot tests Theme test object 1`] = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://hcaptcha.com/1/api.js?render=explicit&onload=onloadCallback&host=00000000-0000-0000-0000-000000000000.react-native.hcaptcha.com&hl=en&custom=true" async defer></script>
<script type="text/javascript">
Expand Down Expand Up @@ -172,7 +172,7 @@ exports[`Hcaptcha snapshot tests Theme test string 1`] = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://hcaptcha.com/1/api.js?render=explicit&onload=onloadCallback&host=00000000-0000-0000-0000-000000000000.react-native.hcaptcha.com&hl=en" async defer></script>
<script type="text/javascript">
Expand Down Expand Up @@ -300,7 +300,7 @@ exports[`Hcaptcha snapshot tests Theme test undefined 1`] = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://hcaptcha.com/1/api.js?render=explicit&onload=onloadCallback&host=00000000-0000-0000-0000-000000000000.react-native.hcaptcha.com&hl=en" async defer></script>
<script type="text/javascript">
Expand Down Expand Up @@ -428,7 +428,7 @@ exports[`Hcaptcha snapshot tests renders Hcaptcha with all props 1`] = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://all.props/api-endpoint?render=explicit&onload=onloadCallback&host=all-props-host&hl=fr&endpoint=https%3A%2F%2Fall.props%2Fendpoint&assethost=https%3A%2F%2Fall.props%2Fassethost&imghost=https%3A%2F%2Fall.props%2Fimghost&reportapi=https%3A%2F%2Fall.props%2Freportapi" async defer></script>
<script type="text/javascript">
Expand Down Expand Up @@ -591,7 +591,7 @@ exports[`Hcaptcha snapshot tests renders Hcaptcha with debug 1`] = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
Object.entries({"a":1,"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
Object.entries({"a":1,"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="https://hcaptcha.com/1/api.js?render=explicit&onload=onloadCallback&host=00000000-0000-0000-0000-000000000000.react-native.hcaptcha.com&hl=en" async defer></script>
<script type="text/javascript">
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hcaptcha/react-native-hcaptcha",
"version": "2.0.2",
"version": "2.0.3",
"description": "hCaptcha Library for React Native (both Android and iOS)",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -54,6 +54,7 @@
"eslint-plugin-react-native": "^5.0.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"react": "*",
"react-native": "*",
"react-native-modal": "*",
Expand Down
Loading