@hcaptcha/react-hcaptcha 1.9.3 → 1.10.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 CHANGED
@@ -126,7 +126,7 @@ return <HCaptcha ref={captchaRef} onLoad={onLoad} sitekey={sitekey} {...props} /
126
126
  |---|---|---|---|---|
127
127
  |`sitekey`|String|**Yes**|`-`|This is your sitekey, this allows you to load captcha. If you need a sitekey, please visit [hCaptcha](https://www.hcaptcha.com), and sign up to get your sitekey.|
128
128
  |`size`|String (normal, compact, invisible)|No|`normal`|This specifies the "size" of the component. hCaptcha allows you to decide how big the component will appear on render, this always defaults to normal.|
129
- |`theme`|String (light, dark)|No|`light`|hCaptcha supports both a light and dark theme. If no theme is inherently set, the captcha will always default to light.|
129
+ |`theme`|String (light, dark, contrast) or Object|No|`light`|hCaptcha supports both a light and dark theme. Defaults to light. Takes Object if custom theme is used.|
130
130
  |`tabindex`|Integer|No|`0`|Set the tabindex of the widget and popup. When appropriate, this can make navigation of your site more intuitive.|
131
131
  |`languageOverride`|String (ISO 639-2 code)|No|`auto`|hCaptcha auto-detects language via the user's browser. This overrides that to set a default UI language. See [language codes](https://hcaptcha.com/docs/languages).|
132
132
  |`reCaptchaCompat`|Boolean|No|`true`|Disable drop-in replacement for reCAPTCHA with `false` to prevent hCaptcha from injecting into `window.grecaptcha`.|
@@ -138,8 +138,10 @@ return <HCaptcha ref={captchaRef} onLoad={onLoad} sitekey={sitekey} {...props} /
138
138
  |`imghost`|String|No|`-`|See enterprise docs.|
139
139
  |`reportapi`|String|No|`-`|See enterprise docs.|
140
140
  |`sentry`|String|No|`-`|See enterprise docs.|
141
+ |`secureApi`|Boolean|No|`-`|See enterprise docs.|
142
+ |`scriptSource`|String|No|`-`|See enterprise docs.|
141
143
  | `cleanup` | Boolean | No | `true` | Remove script tag after setup.|
142
- |`custom`|Boolean|No|`-`|See enterprise docs.|
144
+ |`custom`|Boolean|No|`-`|Custom theme: see enterprise docs.|
143
145
  |`loadAsync`|Boolean|No|`true`|Set if the script should be loaded asynchronously.|
144
146
  |`scriptLocation`|Element|No|`document.head`| Location of where to append the script tag. Make sure to add it to an area that will persist to prevent loading multiple times in the same document view. Note: If `null` is provided, the `document.head` will be used.|
145
147
 
@@ -190,6 +192,10 @@ Please note that "invisible" simply means that no hCaptcha button will be render
190
192
  3. #### Make sure you are using `reCaptchaCompat=false` if you have the reCAPTCHA JS loaded on the same page.
191
193
  The hCaptcha "compatibility mode" will interfere with reCAPTCHA, as it adds properties with the same name. If for any reason you are running both hCaptcha and reCAPTCHA in parallel (we recommend only running hCaptcha) then please disable our compatibility mode.
192
194
 
195
+ 4. #### Avoid conflicts with legacy Sentry package usage on react-hcaptcha 1.9.0+
196
+ If you are using Sentry 7.x in your React app, this can conflict with the upstream `hcaptcha-loader` package's Sentry error tracing. You can avoid this issue by setting the `sentry` prop to `false`.
197
+
198
+
193
199
 
194
200
  ---
195
201
  ### Contributing
package/dist/constants.js CHANGED
@@ -3,17 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.breadcrumbMessages = exports.scopeTag = void 0;
7
- var scopeTag = {
6
+ exports.scopeTag = exports.breadcrumbMessages = void 0;
7
+ var scopeTag = exports.scopeTag = {
8
8
  key: 'source',
9
9
  value: '@hCaptcha/react'
10
10
  };
11
- exports.scopeTag = scopeTag;
12
- var breadcrumbMessages = {
11
+ var breadcrumbMessages = exports.breadcrumbMessages = {
13
12
  mounted: 'hCaptcha component mounted',
14
13
  expired: 'hCaptcha expired',
15
14
  unmounted: 'hCaptcha component unmounted',
16
15
  reset: 'hCaptcha reset',
17
16
  removed: 'hCaptcha removed'
18
- };
19
- exports.breadcrumbMessages = breadcrumbMessages;
17
+ };
package/dist/esm/index.js CHANGED
@@ -128,6 +128,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
128
128
  custom = _this$props.custom,
129
129
  loadAsync = _this$props.loadAsync,
130
130
  scriptLocation = _this$props.scriptLocation,
131
+ scriptSource = _this$props.scriptSource,
132
+ secureApi = _this$props.secureApi,
131
133
  _this$props$cleanup = _this$props.cleanup,
132
134
  cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup;
133
135
  var mountParams = {
@@ -144,6 +146,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
144
146
  custom: custom,
145
147
  loadAsync: loadAsync,
146
148
  scriptLocation: scriptLocation,
149
+ scriptSource: scriptSource,
150
+ secureApi: secureApi,
147
151
  cleanup: cleanup
148
152
  };
149
153
  hCaptchaLoader(mountParams).then(this.handleOnLoad, this.handleError)["catch"](this.handleError);
@@ -216,6 +220,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
216
220
  // render captcha and wait for captcha id
217
221
  _this4.renderCaptcha(function () {
218
222
  // trigger onLoad if it exists
223
+
219
224
  var onLoad = _this4.props.onLoad;
220
225
  if (onLoad) onLoad();
221
226
  });
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
@@ -9,23 +9,24 @@ exports["default"] = void 0;
9
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
16
  var React = _interopRequireWildcard(require("react"));
17
17
  var _loader = require("@hcaptcha/loader");
18
18
  var _utils = require("./utils.js");
19
19
  var _constants = require("./constants");
20
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20
+ 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); }
21
+ 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; }
22
+ 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)); }
23
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
24
  var HCaptcha = /*#__PURE__*/function (_React$Component) {
23
25
  (0, _inherits2["default"])(HCaptcha, _React$Component);
24
- var _super = _createSuper(HCaptcha);
25
26
  function HCaptcha(props) {
26
27
  var _this;
27
28
  (0, _classCallCheck2["default"])(this, HCaptcha);
28
- _this = _super.call(this, props);
29
+ _this = _callSuper(this, HCaptcha, [props]);
29
30
 
30
31
  /**
31
32
  * Internal reference to track hCaptcha API
@@ -154,6 +155,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
154
155
  custom = _this$props.custom,
155
156
  loadAsync = _this$props.loadAsync,
156
157
  scriptLocation = _this$props.scriptLocation,
158
+ scriptSource = _this$props.scriptSource,
159
+ secureApi = _this$props.secureApi,
157
160
  _this$props$cleanup = _this$props.cleanup,
158
161
  cleanup = _this$props$cleanup === void 0 ? true : _this$props$cleanup;
159
162
  var mountParams = {
@@ -170,6 +173,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
170
173
  custom: custom,
171
174
  loadAsync: loadAsync,
172
175
  scriptLocation: scriptLocation,
176
+ scriptSource: scriptSource,
177
+ secureApi: secureApi,
173
178
  cleanup: cleanup
174
179
  };
175
180
  (0, _loader.hCaptchaLoader)(mountParams).then(this.handleOnLoad, this.handleError)["catch"](this.handleError);
@@ -250,6 +255,7 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
250
255
  // render captcha and wait for captcha id
251
256
  _this4.renderCaptcha(function () {
252
257
  // trigger onLoad if it exists
258
+
253
259
  var onLoad = _this4.props.onLoad;
254
260
  if (onLoad) onLoad();
255
261
  });
@@ -387,6 +393,5 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
387
393
  }]);
388
394
  return HCaptcha;
389
395
  }(React.Component);
390
- var _default = HCaptcha;
391
- exports["default"] = _default;
396
+ var _default = exports["default"] = HCaptcha;
392
397
  module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hcaptcha/react-hcaptcha",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "types": "types/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -53,12 +53,13 @@
53
53
  "react": "^16.14.0",
54
54
  "react-dom": "^16.14.0",
55
55
  "rimraf": "^3.0.2",
56
+ "wait-for-expect": "^3.0.2",
56
57
  "webpack": "^5.76.3",
57
58
  "webpack-cli": "^5.0.1",
58
59
  "webpack-dev-server": "^4.13.1"
59
60
  },
60
61
  "dependencies": {
61
62
  "@babel/runtime": "^7.17.9",
62
- "@hcaptcha/loader": "^1.0.10"
63
+ "@hcaptcha/loader": "^1.2.0"
63
64
  }
64
65
  }
package/src/index.js CHANGED
@@ -139,6 +139,8 @@ class HCaptcha extends React.Component {
139
139
  custom,
140
140
  loadAsync,
141
141
  scriptLocation,
142
+ scriptSource,
143
+ secureApi,
142
144
  cleanup = true,
143
145
  } = this.props;
144
146
  const mountParams = {
@@ -155,6 +157,8 @@ class HCaptcha extends React.Component {
155
157
  custom,
156
158
  loadAsync,
157
159
  scriptLocation,
160
+ scriptSource,
161
+ secureApi,
158
162
  cleanup
159
163
  };
160
164
 
package/types/index.d.ts CHANGED
@@ -24,7 +24,7 @@ interface HCaptchaProps {
24
24
  languageOverride?: string;
25
25
  sitekey: string;
26
26
  size?: "normal" | "compact" | "invisible";
27
- theme?: "light" | "dark";
27
+ theme?: "light" | "dark" | "contrast" | Object;
28
28
  tabIndex?: number;
29
29
  id?: string;
30
30
  reCaptchaCompat?: boolean;
@@ -32,6 +32,9 @@ interface HCaptchaProps {
32
32
  scriptLocation?: HTMLElement | null;
33
33
  sentry?: boolean;
34
34
  cleanup?: boolean;
35
+ custom?: boolean;
36
+ secureApi?: boolean;
37
+ scriptSource?: string;
35
38
  }
36
39
 
37
40
  interface ExecuteResponse {