@hcaptcha/react-hcaptcha 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/esm/index.js +16 -4
- package/dist/index.js +16 -4
- package/package.json +3 -3
- package/src/index.js +11 -3
- package/types/index.d.ts +1 -0
package/README.md
CHANGED
|
@@ -137,7 +137,8 @@ return <HCaptcha ref={captchaRef} onLoad={onLoad} sitekey={sitekey} {...props} /
|
|
|
137
137
|
|`host`|String|No|`-`|See enterprise docs.|
|
|
138
138
|
|`imghost`|String|No|`-`|See enterprise docs.|
|
|
139
139
|
|`reportapi`|String|No|`-`|See enterprise docs.|
|
|
140
|
-
|`sentry`|
|
|
140
|
+
|`sentry`|Boolean|No|`true`|See enterprise docs.|
|
|
141
|
+
|`userJourneys`|Boolean|No|`false`|See enterprise docs.|
|
|
141
142
|
|`secureApi`|Boolean|No|`-`|See enterprise docs.|
|
|
142
143
|
|`scriptSource`|String|No|`-`|See enterprise docs.|
|
|
143
144
|
| `cleanup` | Boolean | No | `true` | Remove script tag after setup.|
|
|
@@ -204,6 +205,12 @@ To resolve this, update the version of the Sentry client you are including on yo
|
|
|
204
205
|
You can avoid this issue by setting the `sentry` prop to `false`.
|
|
205
206
|
|
|
206
207
|
|
|
208
|
+
### Handling SDK Errors
|
|
209
|
+
|
|
210
|
+
If the JS SDK fails to load, the `onError` callback will be invoked with `script-error` argument.
|
|
211
|
+
|
|
212
|
+
This will be rare, but could happen in the event you are testing offline, or have enabled a firewall that does not allow outbound connections to the asset hosts hCaptcha uses.
|
|
213
|
+
|
|
207
214
|
---
|
|
208
215
|
### Contributing
|
|
209
216
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
1
2
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
2
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
|
+
var _excluded = ["userJourneys"];
|
|
3
5
|
import * as React from 'react';
|
|
4
6
|
import { hCaptchaLoader } from '@hcaptcha/loader';
|
|
5
7
|
import { getFrame, getMountElement } from './utils.js';
|
|
@@ -122,7 +124,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
122
124
|
scriptSource = _this$props.scriptSource,
|
|
123
125
|
secureApi = _this$props.secureApi,
|
|
124
126
|
_this$props$cleanup = _this$props.cleanup,
|
|
125
|
-
cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup
|
|
127
|
+
cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup,
|
|
128
|
+
userJourneys = _this$props.userJourneys;
|
|
126
129
|
var mountParams = {
|
|
127
130
|
render: 'explicit',
|
|
128
131
|
apihost: apihost,
|
|
@@ -139,7 +142,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
139
142
|
scriptLocation: scriptLocation,
|
|
140
143
|
scriptSource: scriptSource,
|
|
141
144
|
secureApi: secureApi,
|
|
142
|
-
cleanup: cleanup
|
|
145
|
+
cleanup: cleanup,
|
|
146
|
+
userJourneys: userJourneys
|
|
143
147
|
};
|
|
144
148
|
hCaptchaLoader(mountParams).then(this.handleOnLoad, this.handleError)["catch"](this.handleError);
|
|
145
149
|
this.apiScriptRequested = true;
|
|
@@ -154,6 +158,13 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
154
158
|
// • API is not ready
|
|
155
159
|
// • Component has already been mounted
|
|
156
160
|
if (!isApiReady || captchaId) return;
|
|
161
|
+
|
|
162
|
+
// It is needed to pass only the props that hCaptcha supports
|
|
163
|
+
// React are able to receive userJourneys as prop but hCaptcha not
|
|
164
|
+
// hcaptcha expects to have only "uj" parameter to enable user journeys
|
|
165
|
+
var _this$props2 = this.props,
|
|
166
|
+
userJourneys = _this$props2.userJourneys,
|
|
167
|
+
basicProps = _objectWithoutPropertiesLoose(_this$props2, _excluded);
|
|
157
168
|
var renderParams = Object.assign({
|
|
158
169
|
"open-callback": this.handleOpen,
|
|
159
170
|
"close-callback": this.handleClose,
|
|
@@ -161,9 +172,10 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
161
172
|
"chalexpired-callback": this.handleChallengeExpired,
|
|
162
173
|
"expired-callback": this.handleExpire,
|
|
163
174
|
"callback": this.handleSubmit
|
|
164
|
-
},
|
|
175
|
+
}, basicProps, {
|
|
165
176
|
hl: this.props.hl || this.props.languageOverride,
|
|
166
|
-
languageOverride: undefined
|
|
177
|
+
languageOverride: undefined,
|
|
178
|
+
uj: userJourneys !== undefined ? userJourneys : false
|
|
167
179
|
});
|
|
168
180
|
var hcaptcha = this._hcaptcha;
|
|
169
181
|
//Render hCaptcha widget and provide necessary callbacks - hCaptcha
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -16,6 +17,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
16
17
|
var React = _interopRequireWildcard(require("react"));
|
|
17
18
|
var _loader = require("@hcaptcha/loader");
|
|
18
19
|
var _utils = require("./utils.js");
|
|
20
|
+
var _excluded = ["userJourneys"];
|
|
19
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
21
23
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
@@ -149,7 +151,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
149
151
|
scriptSource = _this$props.scriptSource,
|
|
150
152
|
secureApi = _this$props.secureApi,
|
|
151
153
|
_this$props$cleanup = _this$props.cleanup,
|
|
152
|
-
cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup
|
|
154
|
+
cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup,
|
|
155
|
+
userJourneys = _this$props.userJourneys;
|
|
153
156
|
var mountParams = {
|
|
154
157
|
render: 'explicit',
|
|
155
158
|
apihost: apihost,
|
|
@@ -166,7 +169,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
166
169
|
scriptLocation: scriptLocation,
|
|
167
170
|
scriptSource: scriptSource,
|
|
168
171
|
secureApi: secureApi,
|
|
169
|
-
cleanup: cleanup
|
|
172
|
+
cleanup: cleanup,
|
|
173
|
+
userJourneys: userJourneys
|
|
170
174
|
};
|
|
171
175
|
(0, _loader.hCaptchaLoader)(mountParams).then(this.handleOnLoad, this.handleError)["catch"](this.handleError);
|
|
172
176
|
this.apiScriptRequested = true;
|
|
@@ -183,6 +187,13 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
183
187
|
// • API is not ready
|
|
184
188
|
// • Component has already been mounted
|
|
185
189
|
if (!isApiReady || captchaId) return;
|
|
190
|
+
|
|
191
|
+
// It is needed to pass only the props that hCaptcha supports
|
|
192
|
+
// React are able to receive userJourneys as prop but hCaptcha not
|
|
193
|
+
// hcaptcha expects to have only "uj" parameter to enable user journeys
|
|
194
|
+
var _this$props2 = this.props,
|
|
195
|
+
userJourneys = _this$props2.userJourneys,
|
|
196
|
+
basicProps = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded);
|
|
186
197
|
var renderParams = Object.assign({
|
|
187
198
|
"open-callback": this.handleOpen,
|
|
188
199
|
"close-callback": this.handleClose,
|
|
@@ -190,9 +201,10 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
190
201
|
"chalexpired-callback": this.handleChallengeExpired,
|
|
191
202
|
"expired-callback": this.handleExpire,
|
|
192
203
|
"callback": this.handleSubmit
|
|
193
|
-
},
|
|
204
|
+
}, basicProps, {
|
|
194
205
|
hl: this.props.hl || this.props.languageOverride,
|
|
195
|
-
languageOverride: undefined
|
|
206
|
+
languageOverride: undefined,
|
|
207
|
+
uj: userJourneys !== undefined ? userJourneys : false
|
|
196
208
|
});
|
|
197
209
|
var hcaptcha = this._hcaptcha;
|
|
198
210
|
//Render hCaptcha widget and provide necessary callbacks - hCaptcha
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hcaptcha/react-hcaptcha",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"types": "types/index.d.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"wait-for-expect": "^3.0.2",
|
|
57
57
|
"webpack": "^5.76.3",
|
|
58
58
|
"webpack-cli": "^5.0.1",
|
|
59
|
-
"webpack-dev-server": "^
|
|
59
|
+
"webpack-dev-server": "^5.2.1"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@babel/runtime": "^7.17.9",
|
|
63
|
-
"@hcaptcha/loader": "^2.0.
|
|
63
|
+
"@hcaptcha/loader": "^2.0.1"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/index.js
CHANGED
|
@@ -130,6 +130,7 @@ class HCaptcha extends React.Component {
|
|
|
130
130
|
scriptSource,
|
|
131
131
|
secureApi,
|
|
132
132
|
cleanup = true,
|
|
133
|
+
userJourneys,
|
|
133
134
|
} = this.props;
|
|
134
135
|
const mountParams = {
|
|
135
136
|
render: 'explicit',
|
|
@@ -147,7 +148,8 @@ class HCaptcha extends React.Component {
|
|
|
147
148
|
scriptLocation,
|
|
148
149
|
scriptSource,
|
|
149
150
|
secureApi,
|
|
150
|
-
cleanup
|
|
151
|
+
cleanup,
|
|
152
|
+
userJourneys
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
hCaptchaLoader(mountParams)
|
|
@@ -167,6 +169,11 @@ class HCaptcha extends React.Component {
|
|
|
167
169
|
// • Component has already been mounted
|
|
168
170
|
if (!isApiReady || captchaId) return;
|
|
169
171
|
|
|
172
|
+
// It is needed to pass only the props that hCaptcha supports
|
|
173
|
+
// React are able to receive userJourneys as prop but hCaptcha not
|
|
174
|
+
// hcaptcha expects to have only "uj" parameter to enable user journeys
|
|
175
|
+
const { userJourneys, ...basicProps } = this.props;
|
|
176
|
+
|
|
170
177
|
const renderParams = Object.assign({
|
|
171
178
|
"open-callback" : this.handleOpen,
|
|
172
179
|
"close-callback" : this.handleClose,
|
|
@@ -174,9 +181,10 @@ class HCaptcha extends React.Component {
|
|
|
174
181
|
"chalexpired-callback": this.handleChallengeExpired,
|
|
175
182
|
"expired-callback" : this.handleExpire,
|
|
176
183
|
"callback" : this.handleSubmit,
|
|
177
|
-
},
|
|
184
|
+
}, basicProps, {
|
|
178
185
|
hl: this.props.hl || this.props.languageOverride,
|
|
179
|
-
languageOverride: undefined
|
|
186
|
+
languageOverride: undefined,
|
|
187
|
+
uj: userJourneys !== undefined ? userJourneys : false,
|
|
180
188
|
});
|
|
181
189
|
|
|
182
190
|
const hcaptcha = this._hcaptcha;
|