@prosopo/procaptcha-wrapper 2.5.5

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/.env ADDED
@@ -0,0 +1,2 @@
1
+ VITE_RENDER_SCRIPT_URL=https://js.prosopo.io/js/procaptcha.bundle.js
2
+ VITE_RENDER_SCRIPT_ID=procaptcha-bundle
@@ -0,0 +1,65 @@
1
+ declare type Features = `${ProcaptchaType}`;
2
+
3
+ export declare const ProcaptchaLanguages: {
4
+ readonly arabic: "ar";
5
+ readonly azerbaijani: "az";
6
+ readonly czech: "cs";
7
+ readonly german: "de";
8
+ readonly greek: "el";
9
+ readonly english: "en";
10
+ readonly spanish: "es";
11
+ readonly finnish: "fi";
12
+ readonly french: "fr";
13
+ readonly hindi: "hi";
14
+ readonly hungarian: "hu";
15
+ readonly indonesian: "id";
16
+ readonly italian: "it";
17
+ readonly japanese: "ja";
18
+ readonly javanese: "jv";
19
+ readonly korean: "ko";
20
+ readonly malayalam: "ml";
21
+ readonly malay: "ms";
22
+ readonly dutch: "nl";
23
+ readonly norwegian: "no";
24
+ readonly polish: "pl";
25
+ readonly portugeseBrazil: "pt-br";
26
+ readonly portuguese: "pt";
27
+ readonly romanian: "ro";
28
+ readonly russian: "ru";
29
+ readonly serbian: "sr";
30
+ readonly swedish: "sv";
31
+ readonly thai: "th";
32
+ readonly turkish: "tr";
33
+ readonly ukrainian: "uk";
34
+ readonly vietnamese: "vi";
35
+ readonly chinese: "zh";
36
+ };
37
+
38
+ export declare interface ProcaptchaRenderOptions {
39
+ siteKey: string;
40
+ theme?: "light" | "dark";
41
+ captchaType?: Features;
42
+ callback?: string | ((token: string) => void);
43
+ "challenge-valid-length"?: string;
44
+ "chalexpired-callback"?: string | (() => void);
45
+ "expired-callback"?: string | (() => void);
46
+ "open-callback"?: string | (() => void);
47
+ "close-callback"?: string | (() => void);
48
+ "error-callback"?: string | (() => void);
49
+ "failed-callback"?: string | (() => void);
50
+ "reset-callback"?: string | (() => void);
51
+ language?: (typeof ProcaptchaLanguages)[keyof typeof ProcaptchaLanguages];
52
+ size?: "invisible";
53
+ }
54
+
55
+ export declare enum ProcaptchaType {
56
+ image = "image",
57
+ pow = "pow",
58
+ frictionless = "frictionless"
59
+ }
60
+
61
+ declare type RendererFunction = (element: HTMLElement, options: ProcaptchaRenderOptions) => Promise<void>;
62
+
63
+ export declare const renderProcaptcha: RendererFunction;
64
+
65
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ const a = async (t, n) => {
2
+ var r;
3
+ if (await s(t, {
4
+ id: n,
5
+ type: "module",
6
+ async: !0,
7
+ defer: !0
8
+ }), ((r = window.procaptcha) == null ? void 0 : r.render) === void 0)
9
+ throw new Error("Render script does not contain the render function");
10
+ return window.procaptcha.render;
11
+ }, s = async (t, n) => {
12
+ const r = document.createElement("script"), e = {
13
+ src: t,
14
+ ...n
15
+ };
16
+ Object.assign(r, e), await i(document.head, r);
17
+ }, i = async (t, n) => new Promise((r, e) => {
18
+ n.onload = () => {
19
+ r();
20
+ }, n.onerror = (c) => {
21
+ e(c);
22
+ }, t.appendChild(n);
23
+ }), d = (t) => {
24
+ let n;
25
+ const r = async () => (n || (n = await a(
26
+ t.scriptUrl,
27
+ t.scriptId
28
+ )), n);
29
+ return async (e, c) => {
30
+ const o = Object.assign({}, c);
31
+ await (await r())(e, o);
32
+ };
33
+ }, u = d({
34
+ // @ts-expect-error
35
+ scriptUrl: "https://js.prosopo.io/js/procaptcha.bundle.js",
36
+ // @ts-expect-error
37
+ scriptId: "procaptcha-bundle"
38
+ });
39
+ export {
40
+ u as renderProcaptcha
41
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@prosopo/procaptcha-wrapper",
3
+ "version": "2.5.5",
4
+ "type": "module",
5
+ "engines": {
6
+ "node": "20",
7
+ "npm": "10.8.2"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "test": "echo \"No test specified\"",
13
+ "clean": "del-cli ./dist",
14
+ "build": "npx vite build"
15
+ },
16
+ "devDependencies": {
17
+ "@prosopo/procaptcha-integration-build-config": "1.0.0",
18
+ "del-cli": "6.0.0",
19
+ "@prosopo/types": "2.5.5"
20
+ },
21
+ "author": "PROSOPO LIMITED <info@prosopo.io>",
22
+ "license": "Apache-2.0",
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/prosopo/captcha/issues"
29
+ },
30
+ "homepage": "https://github.com/prosopo/captcha#readme",
31
+ "sideEffects": false
32
+ }
package/readme.md ADDED
@@ -0,0 +1,28 @@
1
+ # Procaptcha Wrapper
2
+
3
+ ## 1. About the package
4
+
5
+ It's a core package for all the Procaptcha framework integrations.
6
+
7
+ > Note: You shouldn't use this package directly as long as the target framework integration is available.
8
+
9
+ ## 2. Configuration options
10
+
11
+ The package supports all the [Procaptcha options](https://docs.prosopo.io/en/basics/client-side-rendering/).
12
+
13
+ ## 3. Direct usage
14
+
15
+ This package is written in vanilla JS, so in case there is no integration for your framework yet, you can use the package
16
+ directly:
17
+
18
+ ```typescript
19
+ import { type ProcaptchaRenderOptions, renderProcaptcha} from "@prosopo/procaptcha-wrapper";
20
+
21
+ const container = document.querySelector('#your-element');
22
+
23
+ const procaptchaOptions: ProcaptchaRenderOptions = {
24
+ siteKey: "your-site-key",
25
+ };
26
+
27
+ renderProcaptcha(container, procaptchaOptions);
28
+ ```
package/vite.config.ts ADDED
@@ -0,0 +1,29 @@
1
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { createIntegrationViteConfig } from "@prosopo/procaptcha-integration-build-config";
16
+
17
+ export default createIntegrationViteConfig({
18
+ name: "ProcaptchaWrapper",
19
+ directory: __dirname,
20
+ viteSettings: {
21
+ envDir: __dirname,
22
+ },
23
+ dtsPluginOptions: {
24
+ // workaround to "inline" external dependencies
25
+ bundledPackages: ["@prosopo/types", "@prosopo/locale"],
26
+ // note: "bundledPackages" option doesn't work without "rollupTypes" https://github.com/qmhc/vite-plugin-dts/issues/302
27
+ rollupTypes: true,
28
+ },
29
+ });