@captchafox/react
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -9,2 +9,3 @@ import { WidgetApi, WidgetOptions } from '@captchafox/types'; | ||
className?: string | undefined; | ||
nonce?: string | undefined; | ||
} & React.RefAttributes<CaptchaFoxInstance>>; | ||
@@ -11,0 +12,0 @@ |
@@ -33,3 +33,3 @@ "use client"; | ||
function loadCaptchaScript() { | ||
return __async(this, null, function* () { | ||
return __async(this, arguments, function* ({ nonce } = {}) { | ||
if (document.querySelector(`script[src="${SCRIPT_SRC}"]`)) | ||
@@ -43,2 +43,5 @@ return mountInstance; | ||
script.onerror = rejectFn; | ||
if (nonce) { | ||
script.nonce = nonce; | ||
} | ||
document.body.appendChild(script); | ||
@@ -53,3 +56,3 @@ return mountInstance; | ||
var CaptchaFox = forwardRef( | ||
({ sitekey, lang, mode, theme, className, onError, onVerify, onLoad, onFail, onClose }, ref) => { | ||
({ sitekey, lang, mode, theme, className, nonce, onError, onVerify, onLoad, onFail, onClose }, ref) => { | ||
const [containerRef, setContainerRef] = useState(); | ||
@@ -120,3 +123,3 @@ const [widgetId, setWidgetId] = useState(); | ||
} else { | ||
loadCaptchaScript().then(() => __async(void 0, null, function* () { | ||
loadCaptchaScript({ nonce }).then(() => __async(void 0, null, function* () { | ||
if (isApiReady()) { | ||
@@ -123,0 +126,0 @@ firstRendered.current = true; |
{ | ||
"name": "@captchafox/react", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"main": "./dist/index.cjs", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.js", |
@@ -37,13 +37,14 @@ # @captchafox/react | ||
| **Prop** | **Type** | **Description** | **Required** | | ||
| -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------ | | ||
| sitekey | `string` | The sitekey for the widget | ✅ | | ||
| lang | `string` | The language the widget should display. Defaults to automatically detecting it. | | | ||
| mode | `inline\|popup\|hidden` | The mode the widget should be displayed in . | | | ||
| theme | `light` \| `dark` \| [`ThemeDefinition`](https://docs.captchafox.com/theming#custom-theme) | The theme of the widget. Defaults to light. | | ||
| onVerify | `function` | Called with the response token after successful verification. | | | ||
| onFail | `function` | Called after unsuccessful verification. | | | ||
| onError | `function` | Called when an error occured. | | | ||
| onExpire | `function` | Called when the challenge expires. | | | ||
| onClose | `function` | Called when the challenge was closed. | | | ||
| **Prop** | **Type** | **Description** | **Required** | | ||
| -------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------ | | ||
| sitekey | `string` | The sitekey for the widget | ✅ | | ||
| lang | `string` | The language the widget should display. Defaults to automatically detecting it. | | | ||
| mode | `inline\|popup\|hidden` | The mode the widget should be displayed in . | | | ||
| theme | `light` | `dark` | [`ThemeDefinition`](https://docs.captchafox.com/theming#custom-theme) | The theme of the widget. Defaults to light. | | | ||
| nonce | `string` | Randomly generated nonce | | | ||
| onVerify | `function` | Called with the response token after successful verification. | | | ||
| onFail | `function` | Called after unsuccessful verification. | | | ||
| onError | `function` | Called when an error occured. | | | ||
| onExpire | `function` | Called when the challenge expires. | | | ||
| onClose | `function` | Called when the challenge was closed. | | | ||
@@ -50,0 +51,0 @@ ### Using the verification callback |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17805
323
97
1