Skip to content

Commit d6405a9

Browse files
Feature/handle sms (#89)
* feature: handle sms: schema * chore: add prettier explicitly * chore: bump to 2.0.3 --------- Co-authored-by: Aliaksandr Babrykovich <aliaksandr.babrykovich@callstack.com>
1 parent 7ce1ebe commit d6405a9

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

Hcaptcha.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const buildHcaptchaApiUrl = (jsSrc, siteKey, hl, theme, host, sentry, endpoint,
6161
* @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.)
6262
* @param {string} host: hCaptcha SDK host identifier. null value means that it will be generated by SDK
6363
* @param {object} debug: debug information
64-
* @parem {string} hCaptcha challenge orientation
64+
* @param {string} orientation: hCaptcha challenge orientation
6565
*/
6666
const Hcaptcha = ({
6767
onMessage,
@@ -241,7 +241,19 @@ const Hcaptcha = ({
241241
if (event.url.slice(0, 24) === 'https://www.hcaptcha.com') {
242242
Linking.openURL(event.url);
243243
return false;
244+
} else if (event.url.toLowerCase().startsWith('sms:')) {
245+
Linking.openURL(event.url).catch((err) => {
246+
onMessage({
247+
nativeEvent: {
248+
data: 'sms-open-failed',
249+
description: err.message,
250+
},
251+
success: false
252+
});
253+
});
254+
return false;
244255
}
256+
245257
return true;
246258
}}
247259
mixedContentMode={'always'}

__mocks__/react-native-webview.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const setWebViewMessageData = (data) => {
77
messageDataToSend = data;
88
};
99

10-
const WebView = (props) => {
10+
const WebView = React.forwardRef((props, ref) => {
1111
const { onMessage } = props;
1212

1313
React.useEffect(() => {
@@ -17,7 +17,7 @@ const WebView = (props) => {
1717
}
1818
}, [onMessage]);
1919

20-
return React.createElement('WebView', props);
21-
};
20+
return React.createElement('WebView', { ...props, ref });
21+
});
2222

2323
export default WebView;

__tests__/__snapshots__/ConfirmHcaptcha.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
8282
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8383
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8484
<script type="text/javascript">
85-
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
85+
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
8686
</script>
8787
<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>
8888
<script type="text/javascript">

__tests__/__snapshots__/Hcaptcha.test.js.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports[`Hcaptcha snapshot tests Theme test object 1`] = `
4444
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4545
<meta http-equiv="X-UA-Compatible" content="ie=edge">
4646
<script type="text/javascript">
47-
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
47+
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
4848
</script>
4949
<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>
5050
<script type="text/javascript">
@@ -172,7 +172,7 @@ exports[`Hcaptcha snapshot tests Theme test string 1`] = `
172172
<meta name="viewport" content="width=device-width, initial-scale=1.0">
173173
<meta http-equiv="X-UA-Compatible" content="ie=edge">
174174
<script type="text/javascript">
175-
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
175+
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
176176
</script>
177177
<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>
178178
<script type="text/javascript">
@@ -300,7 +300,7 @@ exports[`Hcaptcha snapshot tests Theme test undefined 1`] = `
300300
<meta name="viewport" content="width=device-width, initial-scale=1.0">
301301
<meta http-equiv="X-UA-Compatible" content="ie=edge">
302302
<script type="text/javascript">
303-
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
303+
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
304304
</script>
305305
<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>
306306
<script type="text/javascript">
@@ -428,7 +428,7 @@ exports[`Hcaptcha snapshot tests renders Hcaptcha with all props 1`] = `
428428
<meta name="viewport" content="width=device-width, initial-scale=1.0">
429429
<meta http-equiv="X-UA-Compatible" content="ie=edge">
430430
<script type="text/javascript">
431-
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_2":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
431+
Object.entries({"rnver_0_0_0":true,"dep_mocked-md5":true,"sdk_2_0_3":true}).forEach(function (entry) { window[entry[0]] = entry[1] })
432432
</script>
433433
<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>
434434
<script type="text/javascript">
@@ -591,7 +591,7 @@ exports[`Hcaptcha snapshot tests renders Hcaptcha with debug 1`] = `
591591
<meta name="viewport" content="width=device-width, initial-scale=1.0">
592592
<meta http-equiv="X-UA-Compatible" content="ie=edge">
593593
<script type="text/javascript">
594-
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] })
594+
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] })
595595
</script>
596596
<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>
597597
<script type="text/javascript">

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hcaptcha/react-native-hcaptcha",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "hCaptcha Library for React Native (both Android and iOS)",
55
"main": "index.js",
66
"scripts": {
@@ -54,6 +54,7 @@
5454
"eslint-plugin-react-native": "^5.0.0",
5555
"husky": "^9.1.7",
5656
"jest": "^29.7.0",
57+
"prettier": "^3.6.2",
5758
"react": "*",
5859
"react-native": "*",
5960
"react-native-modal": "*",

0 commit comments

Comments
 (0)