@hcaptcha/react-hcaptcha 1.11.2 → 1.11.3
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/dist/esm/index.js +11 -9
- package/dist/index.js +11 -9
- package/package.json +1 -1
- package/src/index.js +2 -0
package/dist/esm/index.js
CHANGED
|
@@ -201,6 +201,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
201
201
|
});
|
|
202
202
|
};
|
|
203
203
|
_proto.removeCaptcha = function removeCaptcha(callback) {
|
|
204
|
+
var _this5 = this;
|
|
204
205
|
var hcaptcha = this._hcaptcha;
|
|
205
206
|
var captchaId = this.captchaId;
|
|
206
207
|
if (!this.isReady()) {
|
|
@@ -209,6 +210,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
209
210
|
this.setState({
|
|
210
211
|
isRemoved: true
|
|
211
212
|
}, function () {
|
|
213
|
+
_this5.captchaId = '';
|
|
212
214
|
hcaptcha.remove(captchaId);
|
|
213
215
|
callback && callback();
|
|
214
216
|
});
|
|
@@ -218,24 +220,24 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
218
220
|
});
|
|
219
221
|
};
|
|
220
222
|
_proto.handleOnLoad = function handleOnLoad() {
|
|
221
|
-
var
|
|
223
|
+
var _this6 = this;
|
|
222
224
|
this.setState({
|
|
223
225
|
isApiReady: true
|
|
224
226
|
}, function () {
|
|
225
227
|
try {
|
|
226
|
-
var element = getMountElement(
|
|
228
|
+
var element = getMountElement(_this6.props.scriptLocation);
|
|
227
229
|
var frame = getFrame(element);
|
|
228
|
-
|
|
230
|
+
_this6._hcaptcha = frame.window.hcaptcha;
|
|
229
231
|
|
|
230
232
|
// render captcha and wait for captcha id
|
|
231
|
-
|
|
233
|
+
_this6.renderCaptcha(function () {
|
|
232
234
|
// trigger onLoad if it exists
|
|
233
235
|
|
|
234
|
-
var onLoad =
|
|
236
|
+
var onLoad = _this6.props.onLoad;
|
|
235
237
|
if (onLoad) onLoad();
|
|
236
238
|
});
|
|
237
239
|
} catch (error) {
|
|
238
|
-
|
|
240
|
+
_this6.sentryHub.captureException(error);
|
|
239
241
|
}
|
|
240
242
|
});
|
|
241
243
|
};
|
|
@@ -299,7 +301,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
299
301
|
this.props.onChalExpired();
|
|
300
302
|
};
|
|
301
303
|
_proto.execute = function execute(opts) {
|
|
302
|
-
var
|
|
304
|
+
var _this7 = this;
|
|
303
305
|
if (opts === void 0) {
|
|
304
306
|
opts = null;
|
|
305
307
|
}
|
|
@@ -310,9 +312,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
310
312
|
if (!this.isReady()) {
|
|
311
313
|
var _opts;
|
|
312
314
|
var onReady = new Promise(function (resolve, reject) {
|
|
313
|
-
|
|
315
|
+
_this7._onReady = function (id) {
|
|
314
316
|
try {
|
|
315
|
-
var _hcaptcha =
|
|
317
|
+
var _hcaptcha = _this7._hcaptcha;
|
|
316
318
|
if (opts && opts.async) {
|
|
317
319
|
_hcaptcha.execute(id, opts).then(resolve)["catch"](reject);
|
|
318
320
|
} else {
|
package/dist/index.js
CHANGED
|
@@ -234,6 +234,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
234
234
|
}, {
|
|
235
235
|
key: "removeCaptcha",
|
|
236
236
|
value: function removeCaptcha(callback) {
|
|
237
|
+
var _this5 = this;
|
|
237
238
|
var hcaptcha = this._hcaptcha;
|
|
238
239
|
var captchaId = this.captchaId;
|
|
239
240
|
if (!this.isReady()) {
|
|
@@ -242,6 +243,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
242
243
|
this.setState({
|
|
243
244
|
isRemoved: true
|
|
244
245
|
}, function () {
|
|
246
|
+
_this5.captchaId = '';
|
|
245
247
|
hcaptcha.remove(captchaId);
|
|
246
248
|
callback && callback();
|
|
247
249
|
});
|
|
@@ -253,24 +255,24 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
253
255
|
}, {
|
|
254
256
|
key: "handleOnLoad",
|
|
255
257
|
value: function handleOnLoad() {
|
|
256
|
-
var
|
|
258
|
+
var _this6 = this;
|
|
257
259
|
this.setState({
|
|
258
260
|
isApiReady: true
|
|
259
261
|
}, function () {
|
|
260
262
|
try {
|
|
261
|
-
var element = (0, _utils.getMountElement)(
|
|
263
|
+
var element = (0, _utils.getMountElement)(_this6.props.scriptLocation);
|
|
262
264
|
var frame = (0, _utils.getFrame)(element);
|
|
263
|
-
|
|
265
|
+
_this6._hcaptcha = frame.window.hcaptcha;
|
|
264
266
|
|
|
265
267
|
// render captcha and wait for captcha id
|
|
266
|
-
|
|
268
|
+
_this6.renderCaptcha(function () {
|
|
267
269
|
// trigger onLoad if it exists
|
|
268
270
|
|
|
269
|
-
var onLoad =
|
|
271
|
+
var onLoad = _this6.props.onLoad;
|
|
270
272
|
if (onLoad) onLoad();
|
|
271
273
|
});
|
|
272
274
|
} catch (error) {
|
|
273
|
-
|
|
275
|
+
_this6.sentryHub.captureException(error);
|
|
274
276
|
}
|
|
275
277
|
});
|
|
276
278
|
}
|
|
@@ -350,7 +352,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
350
352
|
}, {
|
|
351
353
|
key: "execute",
|
|
352
354
|
value: function execute() {
|
|
353
|
-
var
|
|
355
|
+
var _this7 = this;
|
|
354
356
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
355
357
|
opts = (0, _typeof2["default"])(opts) === 'object' ? opts : null;
|
|
356
358
|
try {
|
|
@@ -359,9 +361,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
359
361
|
if (!this.isReady()) {
|
|
360
362
|
var _opts;
|
|
361
363
|
var onReady = new Promise(function (resolve, reject) {
|
|
362
|
-
|
|
364
|
+
_this7._onReady = function (id) {
|
|
363
365
|
try {
|
|
364
|
-
var _hcaptcha =
|
|
366
|
+
var _hcaptcha = _this7._hcaptcha;
|
|
365
367
|
if (opts && opts.async) {
|
|
366
368
|
_hcaptcha.execute(id, opts).then(resolve)["catch"](reject);
|
|
367
369
|
} else {
|
package/package.json
CHANGED