@prosopo/procaptcha-wrapper 2.6.9 → 2.6.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @prosopo/procaptcha-wrapper
2
2
 
3
+ ## 2.6.11
4
+ ### Patch Changes
5
+
6
+ - 91d56e7: enable nx caching
7
+ - 828066d: remove empty test npm scripts, add missing npm test scripts
8
+ - 91bbe87: configure typecheck before bundle for vue packages
9
+ - 686c5f5: fix bundling setup wrt types
10
+ - 91bbe87: make typecheck script always recompile
11
+ - 346e092: NODE_ENV default to "development"
12
+ - 5d36e05: remove tsc --force
13
+ - Updated dependencies [828066d]
14
+ - Updated dependencies [df4e030]
15
+ - Updated dependencies [91bbe87]
16
+ - Updated dependencies [3ef4fd2]
17
+ - Updated dependencies [91bbe87]
18
+ - Updated dependencies [346e092]
19
+ - Updated dependencies [5d36e05]
20
+ - @prosopo/types@3.0.6
21
+ - @prosopo/config@3.1.3
22
+ - @prosopo/locale@3.1.2
23
+ - @prosopo/util@3.0.5
24
+
25
+ ## 2.6.10
26
+ ### Patch Changes
27
+
28
+ - eb71691: configure typecheck before bundle for vue packages
29
+ - eb71691: make typecheck script always recompile
30
+ - Updated dependencies [eb71691]
31
+ - Updated dependencies [eb71691]
32
+ - @prosopo/locale@3.1.1
33
+ - @prosopo/types@3.0.5
34
+ - @prosopo/util@3.0.4
35
+ - @prosopo/config@3.1.2
36
+
3
37
  ## 2.6.9
4
38
  ### Patch Changes
5
39
 
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const renderer = require("./render/renderer.cjs");
4
+ const renderProcaptcha = renderer.createRenderer({
5
+ // @ts-expect-error
6
+ scriptUrl: "https://js.prosopo.io/js/procaptcha.bundle.js",
7
+ // @ts-expect-error
8
+ scriptId: "procaptcha-bundle"
9
+ });
10
+ exports.renderProcaptcha = renderProcaptcha;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const loadRenderFunction = async (scriptUrl, scriptId) => {
4
+ await loadScript(scriptUrl, {
5
+ id: scriptId,
6
+ type: "module",
7
+ async: true,
8
+ defer: true
9
+ });
10
+ if (void 0 === window.procaptcha?.render) {
11
+ throw new Error("Render script does not contain the render function");
12
+ }
13
+ return window.procaptcha.render;
14
+ };
15
+ const loadScript = async (url, attributes) => {
16
+ const scriptTag = document.createElement("script");
17
+ const scriptAttributes = {
18
+ src: url,
19
+ ...attributes
20
+ };
21
+ Object.assign(scriptTag, scriptAttributes);
22
+ await insertScriptTag(document.head, scriptTag);
23
+ };
24
+ const insertScriptTag = async (target, scriptTag) => {
25
+ return new Promise((resolve, reject) => {
26
+ scriptTag.onload = () => {
27
+ resolve();
28
+ };
29
+ scriptTag.onerror = (event) => {
30
+ reject(event);
31
+ };
32
+ target.appendChild(scriptTag);
33
+ });
34
+ };
35
+ exports.loadRenderFunction = loadRenderFunction;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const renderFunction = require("./renderFunction.cjs");
4
+ const createRenderer = (settings) => {
5
+ let renderFunction$1;
6
+ const getRenderFunction = async () => {
7
+ if (!renderFunction$1) {
8
+ renderFunction$1 = await renderFunction.loadRenderFunction(
9
+ settings.scriptUrl,
10
+ settings.scriptId
11
+ );
12
+ }
13
+ return renderFunction$1;
14
+ };
15
+ return async (element, options) => {
16
+ const renderOptions = Object.assign({}, options);
17
+ const renderFunction2 = await getRenderFunction();
18
+ await renderFunction2(element, renderOptions);
19
+ };
20
+ };
21
+ exports.createRenderer = createRenderer;
package/dist/index.d.ts CHANGED
@@ -1,68 +1,6 @@
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-CN";
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
- web3?: boolean;
54
- userAccountAddress?: string;
55
- }
56
-
57
- export declare enum ProcaptchaType {
58
- image = "image",
59
- pow = "pow",
60
- frictionless = "frictionless",
61
- invisible = "invisible"
62
- }
63
-
64
- declare type RendererFunction = (element: HTMLElement, options: ProcaptchaRenderOptions) => Promise<void>;
65
-
66
- export declare const renderProcaptcha: RendererFunction;
67
-
68
- export { }
1
+ import type { Languages } from "@prosopo/locale";
2
+ import type { CaptchaType, ProcaptchaRenderOptions } from "@prosopo/types";
3
+ import type { RendererFunction } from "./render/renderFunction.js";
4
+ export declare const renderProcaptcha: RendererFunction;
5
+ export type { ProcaptchaRenderOptions, CaptchaType as ProcaptchaType, Languages as ProcaptchaLanguages, };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,eAAO,MAAM,gBAAgB,EAAE,gBAK7B,CAAC;AAEH,YAAY,EACX,uBAAuB,EACvB,WAAW,IAAI,cAAc,EAC7B,SAAS,IAAI,mBAAmB,GAChC,CAAC"}
package/dist/index.js CHANGED
@@ -1,41 +1,10 @@
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({
1
+ import { createRenderer } from "./render/renderer.js";
2
+ const renderProcaptcha = createRenderer({
34
3
  // @ts-expect-error
35
4
  scriptUrl: "https://js.prosopo.io/js/procaptcha.bundle.js",
36
5
  // @ts-expect-error
37
6
  scriptId: "procaptcha-bundle"
38
7
  });
39
8
  export {
40
- u as renderProcaptcha
9
+ renderProcaptcha
41
10
  };
@@ -0,0 +1,11 @@
1
+ import type { ProcaptchaRenderOptions } from "@prosopo/types";
2
+ export type RendererFunction = (element: HTMLElement, options: ProcaptchaRenderOptions) => Promise<void>;
3
+ export declare const loadRenderFunction: (scriptUrl: string, scriptId: string) => Promise<RendererFunction>;
4
+ declare global {
5
+ interface Window {
6
+ procaptcha: {
7
+ render: RendererFunction;
8
+ } | undefined;
9
+ }
10
+ }
11
+ //# sourceMappingURL=renderFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderFunction.d.ts","sourceRoot":"","sources":["../../src/render/renderFunction.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,CAC9B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,uBAAuB,KAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,eAAO,MAAM,kBAAkB,cACnB,MAAM,YACP,MAAM,KACd,OAAO,CAAC,gBAAgB,CAa1B,CAAC;AAmCF,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,UAAU,EACP;YACA,MAAM,EAAE,gBAAgB,CAAC;SACxB,GACD,SAAS,CAAC;KACb;CACD"}
@@ -0,0 +1,35 @@
1
+ const loadRenderFunction = async (scriptUrl, scriptId) => {
2
+ await loadScript(scriptUrl, {
3
+ id: scriptId,
4
+ type: "module",
5
+ async: true,
6
+ defer: true
7
+ });
8
+ if (void 0 === window.procaptcha?.render) {
9
+ throw new Error("Render script does not contain the render function");
10
+ }
11
+ return window.procaptcha.render;
12
+ };
13
+ const loadScript = async (url, attributes) => {
14
+ const scriptTag = document.createElement("script");
15
+ const scriptAttributes = {
16
+ src: url,
17
+ ...attributes
18
+ };
19
+ Object.assign(scriptTag, scriptAttributes);
20
+ await insertScriptTag(document.head, scriptTag);
21
+ };
22
+ const insertScriptTag = async (target, scriptTag) => {
23
+ return new Promise((resolve, reject) => {
24
+ scriptTag.onload = () => {
25
+ resolve();
26
+ };
27
+ scriptTag.onerror = (event) => {
28
+ reject(event);
29
+ };
30
+ target.appendChild(scriptTag);
31
+ });
32
+ };
33
+ export {
34
+ loadRenderFunction
35
+ };
@@ -0,0 +1,8 @@
1
+ import { type RendererFunction } from "./renderFunction.js";
2
+ interface RendererSettings {
3
+ scriptUrl: string;
4
+ scriptId: string;
5
+ }
6
+ export declare const createRenderer: (settings: RendererSettings) => RendererFunction;
7
+ export {};
8
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAEhF,UAAU,gBAAgB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,cAAc,aAChB,gBAAgB,KACxB,gBA0BF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { loadRenderFunction } from "./renderFunction.js";
2
+ const createRenderer = (settings) => {
3
+ let renderFunction;
4
+ const getRenderFunction = async () => {
5
+ if (!renderFunction) {
6
+ renderFunction = await loadRenderFunction(
7
+ settings.scriptUrl,
8
+ settings.scriptId
9
+ );
10
+ }
11
+ return renderFunction;
12
+ };
13
+ return async (element, options) => {
14
+ const renderOptions = Object.assign({}, options);
15
+ const renderFunction2 = await getRenderFunction();
16
+ await renderFunction2(element, renderOptions);
17
+ };
18
+ };
19
+ export {
20
+ createRenderer
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-wrapper",
3
- "version": "2.6.9",
3
+ "version": "2.6.11",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "20",
@@ -17,21 +17,19 @@
17
17
  },
18
18
  "scripts": {
19
19
  "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
20
- "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
20
+ "build": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
21
21
  "build:tsc": "tsc --build --verbose",
22
- "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
23
- "typecheck": "tsc --build --declaration --emitDeclarationOnly",
24
- "test": "echo no tests",
25
- "bundle": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.config.ts --mode $NODE_ENV"
22
+ "build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
23
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly"
26
24
  },
27
25
  "dependencies": {
28
- "@prosopo/types": "3.0.4",
29
- "@prosopo/util": "3.0.3",
30
- "@prosopo/config": "3.1.1",
31
- "@prosopo/locale": "3.1.0"
26
+ "@prosopo/types": "3.0.6",
27
+ "@prosopo/util": "3.0.5",
28
+ "@prosopo/config": "3.1.3",
29
+ "@prosopo/locale": "3.1.2"
32
30
  },
33
31
  "devDependencies": {
34
- "@prosopo/procaptcha-integration-build-config": "1.1.1",
32
+ "@prosopo/procaptcha-integration-build-config": "1.1.3",
35
33
  "del-cli": "6.0.0"
36
34
  },
37
35
  "author": "PROSOPO LIMITED <info@prosopo.io>",
package/vite.config.ts DELETED
@@ -1,29 +0,0 @@
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
- });