@prosopo/procaptcha-frictionless 2.1.6 → 2.1.8
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/package.json +8 -8
- package/dist/ProcaptchaFrictionless.d.ts +0 -3
- package/dist/ProcaptchaFrictionless.d.ts.map +0 -1
- package/dist/ProcaptchaFrictionless.js +0 -53
- package/dist/ProcaptchaFrictionless.js.map +0 -1
- package/dist/cjs/ProcaptchaFrictionless.cjs +0 -78
- package/dist/cjs/index.cjs +0 -4
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@prosopo/detector": "2.1.
|
|
30
|
-
"@prosopo/locale-browser": "2.1.
|
|
31
|
-
"@prosopo/procaptcha-pow": "2.1.
|
|
32
|
-
"@prosopo/procaptcha-react": "2.1.
|
|
33
|
-
"@prosopo/types": "2.1.
|
|
34
|
-
"@prosopo/web-components": "2.1.
|
|
29
|
+
"@prosopo/detector": "2.1.8",
|
|
30
|
+
"@prosopo/locale-browser": "2.1.8",
|
|
31
|
+
"@prosopo/procaptcha-pow": "2.1.8",
|
|
32
|
+
"@prosopo/procaptcha-react": "2.1.8",
|
|
33
|
+
"@prosopo/types": "2.1.8",
|
|
34
|
+
"@prosopo/web-components": "2.1.8",
|
|
35
35
|
"react": "18.3.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@prosopo/config": "2.1.
|
|
38
|
+
"@prosopo/config": "2.1.8",
|
|
39
39
|
"@vitest/coverage-v8": "2.1.1",
|
|
40
40
|
"concurrently": "9.0.1",
|
|
41
41
|
"npm-run-all": "4.1.5",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type ProcaptchaFrictionlessProps } from "@prosopo/types";
|
|
2
|
-
export declare const ProcaptchaFrictionless: ({ config, callbacks, detectBot, }: ProcaptchaFrictionlessProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
//# sourceMappingURL=ProcaptchaFrictionless.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaFrictionless.d.ts","sourceRoot":"","sources":["../src/ProcaptchaFrictionless.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKN,KAAK,2BAA2B,EAChC,MAAM,gBAAgB,CAAC;AAiCxB,eAAO,MAAM,sBAAsB,sCAIhC,2BAA2B,4CAyC7B,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ProviderApi } from "@prosopo/api";
|
|
3
|
-
import { ProsopoEnvError } from "@prosopo/common";
|
|
4
|
-
import detect from "@prosopo/detector";
|
|
5
|
-
import { getRandomActiveProvider } from "@prosopo/procaptcha-common";
|
|
6
|
-
import { ProcaptchaPow } from "@prosopo/procaptcha-pow";
|
|
7
|
-
import { Procaptcha } from "@prosopo/procaptcha-react";
|
|
8
|
-
import { ProcaptchaConfigSchema, } from "@prosopo/types";
|
|
9
|
-
import { ProcaptchaPlaceholder } from "@prosopo/web-components";
|
|
10
|
-
import { useEffect, useState } from "react";
|
|
11
|
-
const customDetectBot = async (config) => {
|
|
12
|
-
const botScore = await detect();
|
|
13
|
-
if (!config.account.address) {
|
|
14
|
-
throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
|
|
15
|
-
}
|
|
16
|
-
const provider = await getRandomActiveProvider(config);
|
|
17
|
-
const providerApi = new ProviderApi(provider.provider.url, config.account.address);
|
|
18
|
-
const captcha = await providerApi.getFrictionlessCaptcha(botScore.token, config.account.address);
|
|
19
|
-
return {
|
|
20
|
-
captchaType: captcha.captchaType,
|
|
21
|
-
sessionId: captcha.sessionId,
|
|
22
|
-
provider: provider,
|
|
23
|
-
status: captcha.status,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export const ProcaptchaFrictionless = ({ config, callbacks, detectBot = customDetectBot, }) => {
|
|
27
|
-
const [componentToRender, setComponentToRender] = useState(_jsx(ProcaptchaPlaceholder, { config: config, callbacks: callbacks }));
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const configOutput = ProcaptchaConfigSchema.parse(config);
|
|
30
|
-
const detectAndSetComponent = async () => {
|
|
31
|
-
try {
|
|
32
|
-
const result = await detectBot(configOutput);
|
|
33
|
-
if (result.captchaType === "image") {
|
|
34
|
-
setComponentToRender(_jsx(Procaptcha, { config: config, callbacks: callbacks }));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const frictionlessState = {
|
|
38
|
-
provider: result.provider,
|
|
39
|
-
sessionId: result.sessionId,
|
|
40
|
-
};
|
|
41
|
-
setComponentToRender(_jsx(ProcaptchaPow, { config: config, callbacks: callbacks, frictionlessState: frictionlessState }));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
console.error(error);
|
|
46
|
-
setComponentToRender(_jsx(Procaptcha, { config: config, callbacks: callbacks }));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
detectAndSetComponent();
|
|
50
|
-
}, [config, callbacks, detectBot, config.language]);
|
|
51
|
-
return componentToRender;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=ProcaptchaFrictionless.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaFrictionless.js","sourceRoot":"","sources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CAAC,CAAC;IAEpD,OAAO,iBAAiB,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const api = require("@prosopo/api");
|
|
5
|
-
const common = require("@prosopo/common");
|
|
6
|
-
const detect = require("@prosopo/detector");
|
|
7
|
-
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
8
|
-
const procaptchaPow = require("@prosopo/procaptcha-pow");
|
|
9
|
-
const procaptchaReact = require("@prosopo/procaptcha-react");
|
|
10
|
-
const types = require("@prosopo/types");
|
|
11
|
-
const webComponents = require("@prosopo/web-components");
|
|
12
|
-
const react = require("react");
|
|
13
|
-
const customDetectBot = async (config) => {
|
|
14
|
-
const botScore = await detect();
|
|
15
|
-
if (!config.account.address) {
|
|
16
|
-
throw new common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
|
|
17
|
-
}
|
|
18
|
-
const provider = await procaptchaCommon.getRandomActiveProvider(config);
|
|
19
|
-
const providerApi = new api.ProviderApi(
|
|
20
|
-
provider.provider.url,
|
|
21
|
-
config.account.address
|
|
22
|
-
);
|
|
23
|
-
const captcha = await providerApi.getFrictionlessCaptcha(
|
|
24
|
-
botScore.token,
|
|
25
|
-
config.account.address
|
|
26
|
-
);
|
|
27
|
-
return {
|
|
28
|
-
captchaType: captcha.captchaType,
|
|
29
|
-
sessionId: captcha.sessionId,
|
|
30
|
-
provider,
|
|
31
|
-
status: captcha.status
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const ProcaptchaFrictionless = ({
|
|
35
|
-
config,
|
|
36
|
-
callbacks,
|
|
37
|
-
detectBot = customDetectBot
|
|
38
|
-
}) => {
|
|
39
|
-
const [componentToRender, setComponentToRender] = react.useState(
|
|
40
|
-
/* @__PURE__ */ jsxRuntime.jsx(webComponents.ProcaptchaPlaceholder, { config, callbacks })
|
|
41
|
-
);
|
|
42
|
-
react.useEffect(() => {
|
|
43
|
-
const configOutput = types.ProcaptchaConfigSchema.parse(config);
|
|
44
|
-
const detectAndSetComponent = async () => {
|
|
45
|
-
try {
|
|
46
|
-
const result = await detectBot(configOutput);
|
|
47
|
-
if (result.captchaType === "image") {
|
|
48
|
-
setComponentToRender(
|
|
49
|
-
/* @__PURE__ */ jsxRuntime.jsx(procaptchaReact.Procaptcha, { config, callbacks })
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
const frictionlessState = {
|
|
53
|
-
provider: result.provider,
|
|
54
|
-
sessionId: result.sessionId
|
|
55
|
-
};
|
|
56
|
-
setComponentToRender(
|
|
57
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
58
|
-
procaptchaPow.ProcaptchaPow,
|
|
59
|
-
{
|
|
60
|
-
config,
|
|
61
|
-
callbacks,
|
|
62
|
-
frictionlessState
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error(error);
|
|
69
|
-
setComponentToRender(
|
|
70
|
-
/* @__PURE__ */ jsxRuntime.jsx(procaptchaReact.Procaptcha, { config, callbacks })
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
detectAndSetComponent();
|
|
75
|
-
}, [config, callbacks, detectBot, config.language]);
|
|
76
|
-
return componentToRender;
|
|
77
|
-
};
|
|
78
|
-
exports.ProcaptchaFrictionless = ProcaptchaFrictionless;
|
package/dist/cjs/index.cjs
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,6BAA6B,CAAC"}
|