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

chore: update deps versions recommended by dependabot #58

Merged
merged 4 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- cron: '0 0 * * 0' # https://crontab.guru/every-week

env:
GRADLE_OPTS: -Xmx2048m
TEST_APP_DEPS: react-native-modal react-native-webview
TEST_APP_DEV_DEPS: typescript @babel/preset-env react-shallow-renderer
RN_BUNDLE_ARGS: --entry-file index.js --platform android --dev false --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Expand Down Expand Up @@ -42,7 +43,7 @@ jobs:
- name: Run yarn add ...
working-directory: rnexample
run: |
yarn add file:../react-native-hcaptcha
yarn add @hcaptcha/react-native-hcaptcha@file:../react-native-hcaptcha
yarn add --dev ${{ env.TEST_APP_DEV_DEPS }}
yarn add ${{ env.TEST_APP_DEPS }}
cp ../react-native-hcaptcha/Example.App.js App.js
Expand Down
12 changes: 7 additions & 5 deletions Hcaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const buildHcaptchaApiUrl = (jsSrc, siteKey, hl, theme, host, sentry, endpoint,
* @param {string} assethost: Points loaded hCaptcha assets to a user defined asset location, used for proxies. Default: https://newassets.hcaptcha.com (Override only if using first-party hosting feature.)
* @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
*/
const Hcaptcha = ({
onMessage,
Expand All @@ -79,6 +80,7 @@ const Hcaptcha = ({
assethost,
imghost,
host,
debug,
}) => {
const apiUrl = buildHcaptchaApiUrl(jsSrc, siteKey, languageCode, theme, host, sentry, endpoint, assethost, imghost, reportapi);

Expand All @@ -92,12 +94,12 @@ const Hcaptcha = ({

const debugInfo = useMemo(
() => {
var result = [];
var result = debug || {};
try {
const {major, minor, patch} = ReactNativeVersion.version;
result.push(`rnver_${major}_${minor}_${patch}`);
result.push('dep_' + md5(Object.keys(global).join('')));
result.push('sdk_' + hcaptchaPackage.version.toString().replace(/\./g, '_'));
result[`rnver_${major}_${minor}_${patch}`] = true;
result['dep_' + md5(Object.keys(global).join(''))] = true;
result['sdk_' + hcaptchaPackage.version.toString().replace(/\./g, '_')] = true;
} catch (e) {
console.log(e);
} finally {
Expand All @@ -116,7 +118,7 @@ const Hcaptcha = ({
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript">
${JSON.stringify(debugInfo)}.forEach(function (value, i) { window[value] = true; });
Object.entries(${JSON.stringify(debugInfo)}).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src="${apiUrl}" async defer></script>
<script type="text/javascript">
Expand Down
12 changes: 12 additions & 0 deletions __tests__/Hcaptcha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@ describe('Hcaptcha snapshot tests', () => {
host="all-props-host" />);
expect(component).toMatchSnapshot();
});
it('test debug', () => {
const component = renderer.create(
<Hcaptcha
siteKey="00000000-0000-0000-0000-000000000000"
url="https://hcaptcha.com"
languageCode="en"
debug={{a: 1}}
/>
);
expect(component).toMatchSnapshot();
});
});

162 changes: 81 additions & 81 deletions __tests__/__snapshots__/ConfirmHcaptcha.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
onBackButtonPress={[Function]}
onBackdropPress={[Function]}
style={
Array [
Object {
[
{
"display": "none",
"margin": 0,
},
Object {
{
"display": undefined,
},
]
Expand All @@ -27,13 +27,13 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
>
<RCTSafeAreaView
style={
Array [
Object {
[
{
"flex": 1,
"justifyContent": "center",
"overflow": "hidden",
},
Object {
{
"backgroundColor": "rgba(0.1, 0.1, 0.1, 0.4)",
},
]
Expand All @@ -55,69 +55,69 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
mixedContentMode="always"
onShouldStartLoadWithRequest={[Function]}
originWhitelist={
Array [
[
"*",
]
}
renderLoading={[Function]}
source={
Object {
{
"baseUrl": "https://hcaptcha.com",
"html": "<!DOCTYPE html>
<html>
<head>
<meta charset=\\"UTF-8\\">
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\">
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\">
<script type=\\"text/javascript\\">
[\\"rnver_0_0_0\\",\\"dep_mocked-md5\\",\\"sdk_1_7_1\\"].forEach(function (value, i) { window[value] = true; });
<meta charset="UTF-8">
<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_1_7_1":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\\" async defer></script>
<script type=\\"text/javascript\\">
<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" async defer></script>
<script type="text/javascript">
var onloadCallback = function() {
try {
console.log(\\"challenge onload starting\\");
hcaptcha.render(\\"submit\\", getRenderConfig(\\"00000000-0000-0000-0000-000000000000\\", \\"light\\", \\"compact\\"));
console.log("challenge onload starting");
hcaptcha.render("submit", getRenderConfig("00000000-0000-0000-0000-000000000000", "light", "compact"));
// have loaded by this point; render is sync.
console.log(\\"challenge render complete\\");
console.log("challenge render complete");
} catch (e) {
console.log(\\"challenge failed to render\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("challenge failed to render");
window.ReactNativeWebView.postMessage("error");
}
try {
console.log(\\"showing challenge\\");
console.log("showing challenge");
hcaptcha.execute(getExecuteOpts());
} catch (e) {
console.log(\\"failed to show challenge\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("failed to show challenge");
window.ReactNativeWebView.postMessage("error");
}
};
var onDataCallback = function(response) {
window.ReactNativeWebView.postMessage(response);
};
var onCancel = function() {
window.ReactNativeWebView.postMessage(\\"cancel\\");
window.ReactNativeWebView.postMessage("cancel");
};
var onOpen = function() {
window.ReactNativeWebView.postMessage(\\"open\\");
console.log(\\"challenge opened\\");
window.ReactNativeWebView.postMessage("open");
console.log("challenge opened");
};
var onDataExpiredCallback = function(error) { window.ReactNativeWebView.postMessage(\\"expired\\"); };
var onChalExpiredCallback = function(error) { window.ReactNativeWebView.postMessage(\\"cancel\\"); };
var onDataExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("expired"); };
var onChalExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("cancel"); };
var onDataErrorCallback = function(error) {
console.log(\\"challenge error callback fired\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("challenge error callback fired");
window.ReactNativeWebView.postMessage("error");
};
const getRenderConfig = function(siteKey, theme, size) {
var config = {
sitekey: siteKey,
size: size,
callback: onDataCallback,
\\"close-callback\\": onCancel,
\\"open-callback\\": onOpen,
\\"expired-callback\\": onDataExpiredCallback,
\\"chalexpired-callback\\": onChalExpiredCallback,
\\"error-callback\\": onDataErrorCallback
"close-callback": onCancel,
"open-callback": onOpen,
"expired-callback": onDataExpiredCallback,
"chalexpired-callback": onChalExpiredCallback,
"error-callback": onDataErrorCallback
};
if (theme) {
config.theme = theme;
Expand All @@ -126,24 +126,24 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with all props 1
};
const getExecuteOpts = function() {
var opts;
const rqdata = \\"{\\"some\\": \\"data\\"}\\";
const rqdata = "{"some": "data"}";
if (rqdata) {
opts = {\\"rqdata\\": rqdata};
opts = {"rqdata": rqdata};
}
return opts;
};
</script>
</head>
<body style=\\"background-color: rgba(0.1, 0.1, 0.1, 0.4);\\">
<div id=\\"submit\\"></div>
<body style="background-color: rgba(0.1, 0.1, 0.1, 0.4);">
<div id="submit"></div>
</body>
</html>",
}
}
startInLoadingState={false}
style={
Array [
Object {
[
{
"backgroundColor": "transparent",
"width": "100%",
},
Expand All @@ -168,12 +168,12 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with minimum pro
onBackButtonPress={[Function]}
onBackdropPress={[Function]}
style={
Array [
Object {
[
{
"display": "none",
"margin": 0,
},
Object {
{
"display": undefined,
},
]
Expand All @@ -182,13 +182,13 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with minimum pro
>
<RCTSafeAreaView
style={
Array [
Object {
[
{
"flex": 1,
"justifyContent": "center",
"overflow": "hidden",
},
Object {
{
"backgroundColor": "rgba(0, 0, 0, 0.3)",
},
]
Expand All @@ -210,69 +210,69 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with minimum pro
mixedContentMode="always"
onShouldStartLoadWithRequest={[Function]}
originWhitelist={
Array [
[
"*",
]
}
renderLoading={[Function]}
source={
Object {
{
"baseUrl": "https://hcaptcha.com",
"html": "<!DOCTYPE html>
<html>
<head>
<meta charset=\\"UTF-8\\">
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\">
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\">
<script type=\\"text/javascript\\">
[\\"test_key\\"].forEach(function (value, i) { window[value] = true; });
<meta charset="UTF-8">
<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(["test_key"]).forEach(function (entry) { window[entry[0]] = entry[1] })
</script>
<script src=\\"https://js.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\\">
<script src="https://js.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">
var onloadCallback = function() {
try {
console.log(\\"challenge onload starting\\");
hcaptcha.render(\\"submit\\", getRenderConfig(\\"00000000-0000-0000-0000-000000000000\\", \\"light\\", \\"invisible\\"));
console.log("challenge onload starting");
hcaptcha.render("submit", getRenderConfig("00000000-0000-0000-0000-000000000000", "light", "invisible"));
// have loaded by this point; render is sync.
console.log(\\"challenge render complete\\");
console.log("challenge render complete");
} catch (e) {
console.log(\\"challenge failed to render\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("challenge failed to render");
window.ReactNativeWebView.postMessage("error");
}
try {
console.log(\\"showing challenge\\");
console.log("showing challenge");
hcaptcha.execute(getExecuteOpts());
} catch (e) {
console.log(\\"failed to show challenge\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("failed to show challenge");
window.ReactNativeWebView.postMessage("error");
}
};
var onDataCallback = function(response) {
window.ReactNativeWebView.postMessage(response);
};
var onCancel = function() {
window.ReactNativeWebView.postMessage(\\"cancel\\");
window.ReactNativeWebView.postMessage("cancel");
};
var onOpen = function() {
window.ReactNativeWebView.postMessage(\\"open\\");
console.log(\\"challenge opened\\");
window.ReactNativeWebView.postMessage("open");
console.log("challenge opened");
};
var onDataExpiredCallback = function(error) { window.ReactNativeWebView.postMessage(\\"expired\\"); };
var onChalExpiredCallback = function(error) { window.ReactNativeWebView.postMessage(\\"cancel\\"); };
var onDataExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("expired"); };
var onChalExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("cancel"); };
var onDataErrorCallback = function(error) {
console.log(\\"challenge error callback fired\\");
window.ReactNativeWebView.postMessage(\\"error\\");
console.log("challenge error callback fired");
window.ReactNativeWebView.postMessage("error");
};
const getRenderConfig = function(siteKey, theme, size) {
var config = {
sitekey: siteKey,
size: size,
callback: onDataCallback,
\\"close-callback\\": onCancel,
\\"open-callback\\": onOpen,
\\"expired-callback\\": onDataExpiredCallback,
\\"chalexpired-callback\\": onChalExpiredCallback,
\\"error-callback\\": onDataErrorCallback
"close-callback": onCancel,
"open-callback": onOpen,
"expired-callback": onDataExpiredCallback,
"chalexpired-callback": onChalExpiredCallback,
"error-callback": onDataErrorCallback
};
if (theme) {
config.theme = theme;
Expand All @@ -283,22 +283,22 @@ exports[`ConfirmHcaptcha snapshot tests renders ConfirmHcaptcha with minimum pro
var opts;
const rqdata = null;
if (rqdata) {
opts = {\\"rqdata\\": rqdata};
opts = {"rqdata": rqdata};
}
return opts;
};
</script>
</head>
<body style=\\"background-color: rgba(0, 0, 0, 0.3);\\">
<div id=\\"submit\\"></div>
<body style="background-color: rgba(0, 0, 0, 0.3);">
<div id="submit"></div>
</body>
</html>",
}
}
startInLoadingState={false}
style={
Array [
Object {
[
{
"backgroundColor": "transparent",
"width": "100%",
},
Expand Down
Loading
Loading