{"_id":"@anoldgangsta/capacitor-plugin-recaptcha","name":"@anoldgangsta/capacitor-plugin-recaptcha","dist-tags":{"latest":"7.3.1"},"versions":{"7.3.1":{"name":"@anoldgangsta/capacitor-plugin-recaptcha","version":"7.3.1","description":"Capacitor plugin for reCAPTCHA Enterprise","main":"dist/plugin.cjs.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","author":{"name":"Szabolcs Fruhwald","email":"mail@szab100.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/szab100/capacitor-plugin-recaptcha.git"},"bugs":{"url":"https://github.com/szab100/capacitor-plugin-recaptcha/issues"},"keywords":["capacitor","plugin","native","recaptcha enterprise","recaptcha enterprise v3","recaptcha","recaptcha v3"],"scripts":{"verify":"npm run verify:ios && npm run verify:android && npm run verify:web","verify:ios":"xcodebuild -scheme CapacitorPluginRecaptcha -destination generic/platform=iOS","verify:android":"cd android && ./gradlew clean build test && cd ..","verify:web":"npm run build","lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","fmt":"npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format","eslint":"eslint . --ext ts","prettier":"prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java","swiftlint":"node-swiftlint","docgen":"docgen --api RecaptchaEnterprisePlugin --output-readme README.md --output-json dist/docs.json","build":"npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs","clean":"rimraf ./dist","watch":"tsc --watch","prepublishOnly":"npm run build"},"devDependencies":{"@capacitor/android":"^8.2.0","@capacitor/core":"^8.2.0","@capacitor/docgen":"^0.3.1","@capacitor/ios":"^8.2.0","@ionic/eslint-config":"^0.4.0","@ionic/prettier-config":"^4.0.0","@ionic/swiftlint-config":"^2.0.0","eslint":"^10.0.3","prettier":"^3.8.1","prettier-plugin-java":"^2.8.1","rimraf":"^6.1.3","rollup":"^4.59.0","swiftlint":"^2.0.0","typescript":"~5.9.3"},"peerDependencies":{"@capacitor/core":">=8.2.0"},"prettier":"@ionic/prettier-config","swiftlint":"@ionic/swiftlint-config","eslintConfig":{"extends":"@ionic/eslint-config/recommended"},"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"dependencies":{"recaptcha-v3":"^1.11.3"},"gitHead":"08e9261562735a58a274065d2ad0c032fb684a45","_id":"@anoldgangsta/capacitor-plugin-recaptcha@7.3.1","homepage":"https://github.com/szab100/capacitor-plugin-recaptcha#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-ms59y4Kqf2eqN+wec1r/EDmU0VdkkJsrBOvhGINjylZLEk8bBN+tX5QapnWdLF5vgBUg4UE7p1OOk1gKa8gofg==","shasum":"758a179d6d9c3865d394b997de0c66cfdcb99148","tarball":"https://registry.npmjs.org/@anoldgangsta/capacitor-plugin-recaptcha/-/capacitor-plugin-recaptcha-7.3.1.tgz","fileCount":28,"unpackedSize":38331,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAJf26T9A7QesK+A6ei5s3ZjPIMpSxNL4ER9gmT0r/yOAiEA6wbXGSypyyx3qAWwnCjKVjSn6siR+hmRfDCELS3rmyo="}]},"_npmUser":{"name":"anoldgangsta","email":"bryandevel@gmail.com"},"directories":{},"maintainers":[{"name":"anoldgangsta","email":"bryandevel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/capacitor-plugin-recaptcha_7.3.1_1773021437144_0.47695866140737286"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-09T01:57:17.028Z","7.3.1":"2026-03-09T01:57:17.292Z","modified":"2026-03-09T01:57:17.566Z"},"maintainers":[{"name":"anoldgangsta","email":"bryandevel@gmail.com"}],"description":"Capacitor plugin for reCAPTCHA Enterprise","homepage":"https://github.com/szab100/capacitor-plugin-recaptcha#readme","keywords":["capacitor","plugin","native","recaptcha enterprise","recaptcha enterprise v3","recaptcha","recaptcha v3"],"repository":{"type":"git","url":"git+https://github.com/szab100/capacitor-plugin-recaptcha.git"},"author":{"name":"Szabolcs Fruhwald","email":"mail@szab100.com"},"bugs":{"url":"https://github.com/szab100/capacitor-plugin-recaptcha/issues"},"license":"MIT","readme":"<p align=\"center\"><br><img src=\"https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png\" width=\"128\" height=\"128\" /></p>\r\n<h3 align=\"center\">Capacitor Plugin reCAPTCHA Enterprise</h3>\r\n<p align=\"center\"><strong><code>capacitor-plugin-recaptcha</code></strong></p>\r\n<p align=\"center\">\r\n  # Capacitor Plugin reCAPTCHA Enterprise\r\n\r\n[![npm version](https://badge.fury.io/js/capacitor-plugin-recaptcha.svg)](https://badge.fury.io/js/capacitor-plugin-recaptcha)\r\n[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\r\n[![CI](https://github.com/szab100/capacitor-plugin-recaptcha/actions/workflows/ci.yml/badge.svg)](https://github.com/szab100/capacitor-plugin-recaptcha/actions/workflows/ci.yml)\r\n\r\nA cross-platform Capacitor plugin for integrating [Google reCAPTCHA Enterprise](https://cloud.google.com/recaptcha-enterprise/docs/overview) into your web, Android, and iOS apps.\r\n\r\n---\r\n\r\n## About This Plugin\r\n\r\n**Capacitor Plugin reCAPTCHA Enterprise** enables you to easily integrate [Google reCAPTCHA Enterprise](https://cloud.google.com/recaptcha-enterprise/docs/overview) in your Capacitor-based apps. It provides a simple, unified API for Web, Android, and iOS platforms.\r\n\r\n- **Android & iOS**: This plugin is based on the official [Google reCAPTCHA Enterprise Mobile SDK setup guide](https://cloud.google.com/recaptcha/docs/setup-overview-mobile). It uses the native SDKs for maximum security and compatibility.\r\n- **Web**: Uses the [recaptcha-v3](https://www.npmjs.com/package/recaptcha-v3) package under the hood for seamless browser integration.\r\n\r\n### Why use this plugin?\r\n- Unified API for all platforms\r\n- Secure, production-ready integration\r\n- Designed for backend token assessment\r\n\r\n---\r\n\r\n## Prerequisites & Platform-specific Notes\r\n\r\n### Android\r\n- Your app's package name **must be whitelisted** in your reCAPTCHA site key settings in Google Cloud Console.\r\n- Follow the [Android setup instructions](https://cloud.google.com/recaptcha/docs/setup-android).\r\n\r\n### iOS\r\n- Your app's bundle identifier **must be whitelisted** in your reCAPTCHA site key settings.\r\n- You **must** follow the [iOS setup instructions](https://cloud.google.com/recaptcha/docs/setup-ios) in detail:\r\n  - Add the **App Attest** capability to your app.\r\n  - Configure the required entitlements and provisioning profiles.\r\n  - Ensure your app is signed with the correct Apple Developer Team.\r\n  - See the [official iOS documentation](https://cloud.google.com/recaptcha/docs/setup-ios) for all required steps.\r\n\r\n### Web\r\n- No extra setup needed beyond providing your reCAPTCHA Enterprise site key.\r\n- See [recaptcha-v3 npm package](https://www.npmjs.com/package/recaptcha-v3) for more details.\r\n\r\n---\r\n</p>\r\n\r\n## Backend Token Verification Example\r\n\r\nAfter you obtain a token from the plugin, you must verify and assess it on your backend using the Google reCAPTCHA Enterprise API.\r\n\r\nSee the official Google documentation: [Create an assessment (Node.js)](https://cloud.google.com/recaptcha/docs/create-assessment-website#create-assessment-Node.js)\r\n\r\n### TypeScript/Node.js Example for Verifying a reCAPTCHA Enterprise Token\r\n\r\nFirst, install the required package:\r\n\r\n```bash\r\nnpm install @google-cloud/recaptcha-enterprise\r\n```\r\n\r\nHere's a TypeScript/Node.js example for verifying a reCAPTCHA Enterprise token:\r\n```typescript\r\nimport { RecaptchaEnterpriseServiceClient } from '@google-cloud/recaptcha-enterprise';\r\n\r\nstatic verifyRecaptchaEnterprise = async (token: string, siteKey: string, expectedAction = 'LOGIN'): Promise<boolean> => {\r\n  try {\r\n    const projectId = firebaseServiceAccount.project_id;\r\n    if (!projectId || !siteKey) {\r\n      throw new Error('Google Cloud project ID not set or site key is missing.');\r\n    }\r\n\r\n    const client = new RecaptchaEnterpriseServiceClient({\r\n      credentials: {\r\n        // Use your credentials or set the GOOGLE_APPLICATION_CREDENTIALS environment variable\r\n        client_email: firebaseServiceAccount.client_email,\r\n        private_key: firebaseServiceAccount.private_key,\r\n      },\r\n      projectId: firebaseServiceAccount.project_id,\r\n    });\r\n\r\n    const [assessment] = await client.createAssessment({\r\n      parent: `projects/${projectId}`,\r\n      assessment: {\r\n        event: {\r\n          token,\r\n          siteKey,\r\n        },\r\n      },\r\n    });\r\n\r\n    // Check for valid token and action match\r\n    const { tokenProperties, riskAnalysis } = assessment;\r\n    if (!tokenProperties || !tokenProperties.valid) {\r\n      console.error('Invalid or missing reCAPTCHA token properties:', tokenProperties?.invalidReason);\r\n      return false;\r\n    }\r\n    if (tokenProperties.action !== expectedAction.toLowerCase()) {\r\n      console.error('reCAPTCHA action mismatch:', tokenProperties.action);\r\n      return false;\r\n    }\r\n\r\n    // You can adjust the threshold as needed (0.5 is a common default)\r\n    const score = riskAnalysis?.score ?? 0;\r\n    return score >= 0.5;\r\n  } catch (error) {\r\n    console.error('Error verifying reCAPTCHA Enterprise:', error);\r\n    return false;\r\n  }\r\n};\r\n```\r\n\r\n**Key points:**\r\n- Always verify the token and action server-side.\r\n- Assess the risk score and handle accordingly.\r\n- Never trust the token or score on the client.\r\n- You must use your Google Cloud project credentials.\r\n\r\n---\r\n\r\n## Maintainers\r\n\r\n| Maintainer | GitHub | Social |\r\n| -----------| -------| -------|\r\n| Szabolcs Fruhwald (szab100) | [szab100](https://github.com/szab100) | [@szab100](https://x.com/szab100) |\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install capacitor-plugin-recaptcha\r\nnpx cap sync\r\n```\r\n\r\n## API\r\n\r\n* [`load(...)`](#load)\r\n* [`execute(...)`](#execute)\r\n\r\n## Usage\r\n<docgen-api>\n<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->\n\n### load(...)\n\n```typescript\nload(options: { siteKey: string; }) => any\n```\n\nLoads the reCAPTCHA SDK or native client with the given siteKey. Must be called during app startup before any execute calls.\n\n| Param         | Type                              |\n| ------------- | --------------------------------- |\n| **`options`** | <code>{ siteKey: string; }</code> |\n\n**Returns:** <code>any</code>\n\n--------------------\n\n\n### execute(...)\n\n```typescript\nexecute(options: { action: string; }) => any\n```\n\nExecutes reCAPTCHA Enterprise with the given action and returns a token.\n\n| Param         | Type                             |\n| ------------- | -------------------------------- |\n| **`options`** | <code>{ action: string; }</code> |\n\n**Returns:** <code>any</code>\n\n--------------------\n\n</docgen-api>","readmeFilename":"README.md","_rev":"1-ffbc31d8f85100d24935d3c55d8c603e"}