@prosopo/procaptcha-pow 2.1.1 → 2.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-pow",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -27,15 +27,15 @@
27
27
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
28
28
  "dependencies": {
29
29
  "@polkadot/util": "12.6.2",
30
- "@prosopo/account": "2.1.1",
31
- "@prosopo/api": "2.1.1",
32
- "@prosopo/common": "2.1.1",
33
- "@prosopo/locale-browser": "2.1.1",
34
- "@prosopo/procaptcha": "2.1.1",
35
- "@prosopo/procaptcha-common": "2.1.1",
36
- "@prosopo/types": "2.1.1",
37
- "@prosopo/util": "2.1.1",
38
- "@prosopo/web-components": "2.1.1",
30
+ "@prosopo/account": "2.1.3",
31
+ "@prosopo/api": "2.1.3",
32
+ "@prosopo/common": "2.1.3",
33
+ "@prosopo/locale-browser": "2.1.3",
34
+ "@prosopo/procaptcha": "2.1.3",
35
+ "@prosopo/procaptcha-common": "2.1.3",
36
+ "@prosopo/types": "2.1.3",
37
+ "@prosopo/util": "2.1.3",
38
+ "@prosopo/web-components": "2.1.3",
39
39
  "react": "18.3.1"
40
40
  },
41
41
  "overrides": {
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@prosopo/config": "2.1.1",
49
+ "@prosopo/config": "2.1.3",
50
50
  "@vitest/coverage-v8": "2.1.1",
51
51
  "concurrently": "9.0.1",
52
52
  "npm-run-all": "4.1.5",
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("@emotion/react/jsx-runtime");
4
- const webComponents = require("@prosopo/web-components");
5
- const react = require("react");
6
- const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
7
- const ProcaptchaWidget = react.lazy(async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs"))));
8
- const ProcaptchaPow = (props) => /* @__PURE__ */ jsxRuntime.jsx(
9
- react.Suspense,
10
- {
11
- fallback: /* @__PURE__ */ jsxRuntime.jsx(
12
- webComponents.ProcaptchaPlaceholder,
13
- {
14
- config: props.config,
15
- callbacks: props.callbacks
16
- }
17
- ),
18
- children: /* @__PURE__ */ jsxRuntime.jsx(ProcaptchaWidget, { config: props.config, callbacks: props.callbacks })
19
- }
20
- );
21
- exports.ProcaptchaPow = ProcaptchaPow;
@@ -1,138 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const localeBrowser = require("@prosopo/locale-browser");
4
- const procaptchaCommon = require("@prosopo/procaptcha-common");
5
- const webComponents = require("@prosopo/web-components");
6
- const react = require("react");
7
- const Manager = require("../services/Manager.cjs");
8
- const Procaptcha = (props) => {
9
- const { t } = localeBrowser.useTranslation();
10
- const config = props.config;
11
- const themeColor = config.theme === "light" ? "light" : "dark";
12
- const theme = props.config.theme === "light" ? webComponents.lightTheme : webComponents.darkTheme;
13
- const callbacks = props.callbacks || {};
14
- const [state, _updateState] = procaptchaCommon.useProcaptcha(react.useState, react.useRef);
15
- const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
16
- const manager = react.useRef(Manager.Manager(config, state, updateState, callbacks));
17
- const captchaRef = react.useRef(null);
18
- react.useEffect(() => {
19
- const element = captchaRef.current;
20
- if (!element) return;
21
- const form = element.closest("form");
22
- if (!form) return;
23
- const handleSubmit = () => {
24
- manager.current.resetState();
25
- };
26
- form.addEventListener("submit", handleSubmit);
27
- if (config.language) {
28
- localeBrowser.i18n.changeLanguage(config.language);
29
- }
30
- return () => {
31
- form.removeEventListener("submit", handleSubmit);
32
- };
33
- }, [config.language]);
34
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: captchaRef, children: /* @__PURE__ */ jsxRuntime.jsx(
35
- "div",
36
- {
37
- style: {
38
- maxWidth: webComponents.WIDGET_MAX_WIDTH,
39
- maxHeight: "100%",
40
- overflowX: "auto"
41
- },
42
- children: /* @__PURE__ */ jsxRuntime.jsx(webComponents.ContainerDiv, { children: /* @__PURE__ */ jsxRuntime.jsx(webComponents.WidthBasedStylesDiv, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: webComponents.WIDGET_DIMENSIONS, "data-cy": "button-human", children: [
43
- " ",
44
- /* @__PURE__ */ jsxRuntime.jsxs(
45
- "div",
46
- {
47
- style: {
48
- padding: webComponents.WIDGET_PADDING,
49
- border: webComponents.WIDGET_BORDER,
50
- backgroundColor: theme.palette.background.default,
51
- borderColor: theme.palette.grey[300],
52
- borderRadius: webComponents.WIDGET_BORDER_RADIUS,
53
- display: "flex",
54
- alignItems: "center",
55
- flexWrap: "wrap",
56
- justifyContent: "space-between",
57
- minHeight: `${webComponents.WIDGET_INNER_HEIGHT}px`,
58
- overflow: "hidden"
59
- },
60
- children: [
61
- /* @__PURE__ */ jsxRuntime.jsx(
62
- "div",
63
- {
64
- style: { display: "inline-flex", flexDirection: "column" },
65
- children: /* @__PURE__ */ jsxRuntime.jsx(
66
- "div",
67
- {
68
- style: {
69
- display: "flex",
70
- justifyContent: "flex-start",
71
- alignItems: "center",
72
- flexWrap: "wrap"
73
- },
74
- children: /* @__PURE__ */ jsxRuntime.jsx(
75
- "div",
76
- {
77
- style: {
78
- display: "flex",
79
- alignItems: "center",
80
- justifyContent: "center",
81
- flexDirection: "column",
82
- verticalAlign: "middle"
83
- },
84
- children: /* @__PURE__ */ jsxRuntime.jsx(
85
- "div",
86
- {
87
- style: {
88
- display: "flex"
89
- },
90
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: state.loading ? /* @__PURE__ */ jsxRuntime.jsx(
91
- webComponents.LoadingSpinner,
92
- {
93
- themeColor,
94
- "aria-label": "Loading spinner"
95
- }
96
- ) : /* @__PURE__ */ jsxRuntime.jsx(
97
- webComponents.Checkbox,
98
- {
99
- checked: state.isHuman,
100
- onChange: manager.current.start,
101
- themeColor,
102
- labelText: t("WIDGET.I_AM_HUMAN"),
103
- error: state.error,
104
- "aria-label": "human checkbox"
105
- }
106
- ) })
107
- }
108
- )
109
- }
110
- )
111
- }
112
- )
113
- }
114
- ),
115
- /* @__PURE__ */ jsxRuntime.jsx(
116
- "div",
117
- {
118
- style: { display: "inline-flex", flexDirection: "column" },
119
- children: /* @__PURE__ */ jsxRuntime.jsx(
120
- "a",
121
- {
122
- href: webComponents.WIDGET_URL,
123
- target: "_blank",
124
- "aria-label": webComponents.WIDGET_URL_TEXT,
125
- rel: "noreferrer",
126
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(webComponents.Logo, { themeColor, "aria-label": "Prosopo logo" }) })
127
- }
128
- )
129
- }
130
- )
131
- ]
132
- }
133
- )
134
- ] }) }) })
135
- }
136
- ) });
137
- };
138
- module.exports = Procaptcha;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./components/ProcaptchaWidget.cjs");
4
- const ProcaptchaPoW = require("./components/ProcaptchaPoW.cjs");
5
- exports.ProcaptchaPow = ProcaptchaPoW.ProcaptchaPow;
@@ -1,179 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const string = require("@polkadot/util/string");
4
- const account = require("@prosopo/account");
5
- const api = require("@prosopo/api");
6
- const common = require("@prosopo/common");
7
- const procaptcha = require("@prosopo/procaptcha");
8
- const procaptchaCommon = require("@prosopo/procaptcha-common");
9
- const types = require("@prosopo/types");
10
- const util = require("@prosopo/util");
11
- const Manager = (configInput, state, onStateUpdate, callbacks) => {
12
- const events = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
13
- const defaultState = () => {
14
- return {
15
- // note order matters! see buildUpdateState. These fields are set in order, so disable modal first, then set loading to false, etc.
16
- showModal: false,
17
- loading: false,
18
- index: 0,
19
- challenge: void 0,
20
- solutions: void 0,
21
- isHuman: false,
22
- captchaApi: void 0,
23
- account: void 0
24
- // don't handle timeout here, this should be handled by the state management
25
- };
26
- };
27
- const clearTimeout = () => {
28
- window.clearTimeout(Number(state.timeout));
29
- updateState({ timeout: void 0 });
30
- };
31
- const clearSuccessfulChallengeTimeout = () => {
32
- window.clearTimeout(Number(state.successfullChallengeTimeout));
33
- updateState({ successfullChallengeTimeout: void 0 });
34
- };
35
- const getConfig = () => {
36
- const config = {
37
- userAccountAddress: "",
38
- ...configInput
39
- };
40
- if (state.account) {
41
- config.userAccountAddress = state.account.account.address;
42
- }
43
- return types.ProcaptchaConfigSchema.parse(config);
44
- };
45
- const getAccount = () => {
46
- if (!state.account) {
47
- throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
48
- context: { error: "Account not loaded" }
49
- });
50
- }
51
- const account2 = state.account;
52
- return { account: account2 };
53
- };
54
- const getDappAccount = () => {
55
- if (!state.dappAccount) {
56
- throw new common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
57
- }
58
- const dappAccount = state.dappAccount;
59
- return dappAccount;
60
- };
61
- const updateState = procaptchaCommon.buildUpdateState(state, onStateUpdate);
62
- const resetState = () => {
63
- clearTimeout();
64
- clearSuccessfulChallengeTimeout();
65
- updateState(defaultState());
66
- };
67
- const setValidChallengeTimeout = () => {
68
- const timeMillis = getConfig().captchas.pow.solutionTimeout;
69
- const successfullChallengeTimeout = setTimeout(() => {
70
- updateState({ isHuman: false });
71
- events.onExpired();
72
- }, timeMillis);
73
- updateState({ successfullChallengeTimeout });
74
- };
75
- const start = async () => {
76
- await procaptchaCommon.providerRetry(
77
- async () => {
78
- if (state.loading) {
79
- return;
80
- }
81
- if (state.isHuman) {
82
- return;
83
- }
84
- resetState();
85
- updateState({
86
- loading: true
87
- });
88
- updateState({ attemptCount: state.attemptCount + 1 });
89
- const config = getConfig();
90
- const ext = config.web2 ? new account.ExtensionWeb2() : new account.ExtensionWeb3();
91
- const user = await ext.getAccount(config);
92
- const userAccount = user.account.address;
93
- updateState({
94
- account: { account: { address: userAccount } }
95
- });
96
- updateState({ dappAccount: config.account.address });
97
- await procaptcha.sleep(100);
98
- if (!config.web2 && !config.userAccountAddress) {
99
- throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
100
- context: {
101
- error: "Account address has not been set for web3 mode"
102
- }
103
- });
104
- }
105
- const getRandomProviderResponse = await procaptchaCommon.getRandomActiveProvider(
106
- getConfig()
107
- );
108
- const events2 = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
109
- const providerUrl = getRandomProviderResponse.provider.url;
110
- const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
111
- const challenge = await providerApi.getPowCaptchaChallenge(
112
- userAccount,
113
- getDappAccount()
114
- );
115
- if (challenge.error) {
116
- updateState({
117
- error: challenge.error,
118
- loading: false
119
- });
120
- } else {
121
- const solution = util.solvePoW(challenge.challenge, challenge.difficulty);
122
- const signer = user.extension?.signer;
123
- if (!signer || !signer.signRaw) {
124
- throw new common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
125
- context: {
126
- error: "Signer is not defined, cannot sign message to prove account ownership"
127
- }
128
- });
129
- }
130
- const userTimestampSignature = await signer.signRaw({
131
- address: userAccount,
132
- data: string.stringToHex(challenge[types.ApiParams.timestamp].toString()),
133
- type: "bytes"
134
- });
135
- const verifiedSolution = await providerApi.submitPowCaptchaSolution(
136
- challenge,
137
- getAccount().account.account.address,
138
- getDappAccount(),
139
- solution,
140
- userTimestampSignature.signature.toString(),
141
- config.captchas.pow.verifiedTimeout
142
- );
143
- if (verifiedSolution[types.ApiParams.verified]) {
144
- updateState({
145
- isHuman: true,
146
- loading: false
147
- });
148
- events2.onHuman(
149
- types.encodeProcaptchaOutput({
150
- [types.ApiParams.providerUrl]: providerUrl,
151
- [types.ApiParams.user]: getAccount().account.account.address,
152
- [types.ApiParams.dapp]: getDappAccount(),
153
- [types.ApiParams.challenge]: challenge.challenge,
154
- [types.ApiParams.nonce]: solution,
155
- [types.ApiParams.timestamp]: challenge.timestamp,
156
- [types.ApiParams.signature]: {
157
- [types.ApiParams.provider]: challenge.signature.provider,
158
- [types.ApiParams.user]: {
159
- [types.ApiParams.timestamp]: userTimestampSignature.signature.toString()
160
- }
161
- }
162
- })
163
- );
164
- setValidChallengeTimeout();
165
- }
166
- }
167
- },
168
- start,
169
- resetState,
170
- state.attemptCount,
171
- 10
172
- );
173
- };
174
- return {
175
- start,
176
- resetState
177
- };
178
- };
179
- exports.Manager = Manager;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Captcha.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Captcha.d.ts","sourceRoot":"","sources":["../../src/components/Captcha.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Captcha.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Captcha.js","sourceRoot":"","sources":["../../src/components/Captcha.tsx"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import type { ProcaptchaEvents } from "@prosopo/types";
2
- import { type LazyExoticComponent } from "react";
3
- import type { ReactElement } from "react";
4
- type ProcaptchaProps = React.ComponentProps<typeof ProcaptchaWidget>;
5
- declare const ProcaptchaWidget: LazyExoticComponent<(props: any, callbacks: Partial<ProcaptchaEvents>) => ReactElement>;
6
- export declare const ProcaptchaPow: (props: ProcaptchaProps) => import("@emotion/react/jsx-runtime").JSX.Element;
7
- export {};
8
- //# sourceMappingURL=ProcaptchaPoW.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProcaptchaPoW.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,KAAK,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAErE,QAAA,MAAM,gBAAgB,EAAE,mBAAmB,CAE1C,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,YAAY,CACd,CAAC;AAEtD,eAAO,MAAM,aAAa,UAAW,eAAe,qDAWnD,CAAC"}
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- import { ProcaptchaPlaceholder } from "@prosopo/web-components";
3
- import { Suspense, lazy } from "react";
4
- const ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
5
- export const ProcaptchaPow = (props) => (_jsx(Suspense, { fallback: _jsx(ProcaptchaPlaceholder, { config: props.config, callbacks: props.callbacks }), children: _jsx(ProcaptchaWidget, { config: props.config, callbacks: props.callbacks }) }));
6
- //# sourceMappingURL=ProcaptchaPoW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProcaptchaPoW.js","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAA4B,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAKjE,MAAM,gBAAgB,GAGlB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAsB,EAAE,EAAE,CAAC,CACxD,KAAC,QAAQ,IACR,QAAQ,EACP,KAAC,qBAAqB,IACrB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,GACzB,YAGH,KAAC,gBAAgB,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAI,GAC5D,CACX,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { ProcaptchaProps } from "@prosopo/types";
2
- declare const Procaptcha: (props: ProcaptchaProps) => import("@emotion/react/jsx-runtime").JSX.Element;
3
- export default Procaptcha;
4
- //# sourceMappingURL=ProcaptchaWidget.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAqBtD,QAAA,MAAM,UAAU,UAAW,eAAe,qDAkIzC,CAAC;AACF,eAAe,UAAU,CAAC"}
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { i18n, useTranslation } from "@prosopo/locale-browser";
3
- import { buildUpdateState, useProcaptcha } from "@prosopo/procaptcha-common";
4
- import { Checkbox, ContainerDiv, LoadingSpinner, Logo, WIDGET_BORDER, WIDGET_BORDER_RADIUS, WIDGET_DIMENSIONS, WIDGET_INNER_HEIGHT, WIDGET_MAX_WIDTH, WIDGET_PADDING, WIDGET_URL, WIDGET_URL_TEXT, WidthBasedStylesDiv, darkTheme, lightTheme, } from "@prosopo/web-components";
5
- import { useEffect, useRef, useState } from "react";
6
- import { Manager } from "../services/Manager.js";
7
- const Procaptcha = (props) => {
8
- const { t } = useTranslation();
9
- const config = props.config;
10
- const themeColor = config.theme === "light" ? "light" : "dark";
11
- const theme = props.config.theme === "light" ? lightTheme : darkTheme;
12
- const callbacks = props.callbacks || {};
13
- const [state, _updateState] = useProcaptcha(useState, useRef);
14
- const updateState = buildUpdateState(state, _updateState);
15
- const manager = useRef(Manager(config, state, updateState, callbacks));
16
- const captchaRef = useRef(null);
17
- useEffect(() => {
18
- const element = captchaRef.current;
19
- if (!element)
20
- return;
21
- const form = element.closest("form");
22
- if (!form)
23
- return;
24
- const handleSubmit = () => {
25
- manager.current.resetState();
26
- };
27
- form.addEventListener("submit", handleSubmit);
28
- if (config.language) {
29
- i18n.changeLanguage(config.language);
30
- }
31
- return () => {
32
- form.removeEventListener("submit", handleSubmit);
33
- };
34
- }, [config.language]);
35
- return (_jsx("div", { ref: captchaRef, children: _jsx("div", { style: {
36
- maxWidth: WIDGET_MAX_WIDTH,
37
- maxHeight: "100%",
38
- overflowX: "auto",
39
- }, children: _jsx(ContainerDiv, { children: _jsx(WidthBasedStylesDiv, { children: _jsxs("div", { style: WIDGET_DIMENSIONS, "data-cy": "button-human", children: [" ", _jsxs("div", { style: {
40
- padding: WIDGET_PADDING,
41
- border: WIDGET_BORDER,
42
- backgroundColor: theme.palette.background.default,
43
- borderColor: theme.palette.grey[300],
44
- borderRadius: WIDGET_BORDER_RADIUS,
45
- display: "flex",
46
- alignItems: "center",
47
- flexWrap: "wrap",
48
- justifyContent: "space-between",
49
- minHeight: `${WIDGET_INNER_HEIGHT}px`,
50
- overflow: "hidden",
51
- }, children: [_jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: _jsx("div", { style: {
52
- display: "flex",
53
- justifyContent: "flex-start",
54
- alignItems: "center",
55
- flexWrap: "wrap",
56
- }, children: _jsx("div", { style: {
57
- display: "flex",
58
- alignItems: "center",
59
- justifyContent: "center",
60
- flexDirection: "column",
61
- verticalAlign: "middle",
62
- }, children: _jsx("div", { style: {
63
- display: "flex",
64
- }, children: _jsx("div", { style: { flex: 1 }, children: state.loading ? (_jsx(LoadingSpinner, { themeColor: themeColor, "aria-label": "Loading spinner" })) : (_jsx(Checkbox, { checked: state.isHuman, onChange: manager.current.start, themeColor: themeColor, labelText: t("WIDGET.I_AM_HUMAN"), error: state.error, "aria-label": "human checkbox" })) }) }) }) }) }), _jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: _jsx("a", { href: WIDGET_URL, target: "_blank", "aria-label": WIDGET_URL_TEXT, rel: "noreferrer", children: _jsx("div", { style: { flex: 1 }, children: _jsx(Logo, { themeColor: themeColor, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) }) }) }));
65
- };
66
- export default Procaptcha;
67
- //# sourceMappingURL=ProcaptchaWidget.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IAC7C,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAA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O,CAAC,KAAK,EAC/B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,CAAC,CAAC,mBAAmB,CAAC,EACjC,KAAK,EAAE,KAAK,CAAC,KAAK,gBACP,gBAAgB,GAC1B,CACF,GACI,GACD,GACD,GACD,GACD,EAEN,cACC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,YAE1D,YACC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAC,QAAQ,gBACH,eAAe,EAC3B,GAAG,EAAC,YAAY,YAEhB,cAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YACtB,KAAC,IAAI,IAAC,UAAU,EAAE,UAAU,gBAAa,cAAc,GAAG,GACrD,GACH,GACC,IACD,IACD,GACe,GACR,GACV,GACD,CACN,CAAC;AACH,CAAC,CAAC;AACF,eAAe,UAAU,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./components/ProcaptchaWidget.js";
2
- export * from "./components/ProcaptchaPoW.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC"}
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./components/ProcaptchaWidget.js";
2
- export * from "./components/ProcaptchaPoW.js";
3
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC"}
@@ -1,6 +0,0 @@
1
- import { type ProcaptchaCallbacks, type ProcaptchaClientConfigInput, type ProcaptchaState, type ProcaptchaStateUpdateFn } from "@prosopo/types";
2
- export declare const Manager: (configInput: ProcaptchaClientConfigInput, state: ProcaptchaState, onStateUpdate: ProcaptchaStateUpdateFn, callbacks: ProcaptchaCallbacks) => {
3
- start: () => Promise<void>;
4
- resetState: () => void;
5
- };
6
- //# sourceMappingURL=Manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGN,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEhC,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE5B,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,OAAO,gBACN,2BAA2B,SACjC,eAAe,iBACP,uBAAuB,aAC3B,mBAAmB;;;CA+N9B,CAAC"}
@@ -1,156 +0,0 @@
1
- import { stringToHex } from "@polkadot/util/string";
2
- import { ExtensionWeb2, ExtensionWeb3 } from "@prosopo/account";
3
- import { ProviderApi } from "@prosopo/api";
4
- import { ProsopoEnvError } from "@prosopo/common";
5
- import { sleep } from "@prosopo/procaptcha";
6
- import { buildUpdateState, getDefaultEvents, getRandomActiveProvider, providerRetry, } from "@prosopo/procaptcha-common";
7
- import { ApiParams, ProcaptchaConfigSchema, encodeProcaptchaOutput, } from "@prosopo/types";
8
- import { solvePoW } from "@prosopo/util";
9
- export const Manager = (configInput, state, onStateUpdate, callbacks) => {
10
- const events = getDefaultEvents(onStateUpdate, state, callbacks);
11
- const defaultState = () => {
12
- return {
13
- showModal: false,
14
- loading: false,
15
- index: 0,
16
- challenge: undefined,
17
- solutions: undefined,
18
- isHuman: false,
19
- captchaApi: undefined,
20
- account: undefined,
21
- };
22
- };
23
- const clearTimeout = () => {
24
- window.clearTimeout(Number(state.timeout));
25
- updateState({ timeout: undefined });
26
- };
27
- const clearSuccessfulChallengeTimeout = () => {
28
- window.clearTimeout(Number(state.successfullChallengeTimeout));
29
- updateState({ successfullChallengeTimeout: undefined });
30
- };
31
- const getConfig = () => {
32
- const config = {
33
- userAccountAddress: "",
34
- ...configInput,
35
- };
36
- if (state.account) {
37
- config.userAccountAddress = state.account.account.address;
38
- }
39
- return ProcaptchaConfigSchema.parse(config);
40
- };
41
- const getAccount = () => {
42
- if (!state.account) {
43
- throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
44
- context: { error: "Account not loaded" },
45
- });
46
- }
47
- const account = state.account;
48
- return { account };
49
- };
50
- const getDappAccount = () => {
51
- if (!state.dappAccount) {
52
- throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
53
- }
54
- const dappAccount = state.dappAccount;
55
- return dappAccount;
56
- };
57
- const updateState = buildUpdateState(state, onStateUpdate);
58
- const resetState = () => {
59
- clearTimeout();
60
- clearSuccessfulChallengeTimeout();
61
- updateState(defaultState());
62
- };
63
- const setValidChallengeTimeout = () => {
64
- const timeMillis = getConfig().captchas.pow.solutionTimeout;
65
- const successfullChallengeTimeout = setTimeout(() => {
66
- updateState({ isHuman: false });
67
- events.onExpired();
68
- }, timeMillis);
69
- updateState({ successfullChallengeTimeout });
70
- };
71
- const start = async () => {
72
- await providerRetry(async () => {
73
- if (state.loading) {
74
- return;
75
- }
76
- if (state.isHuman) {
77
- return;
78
- }
79
- resetState();
80
- updateState({
81
- loading: true,
82
- });
83
- updateState({ attemptCount: state.attemptCount + 1 });
84
- const config = getConfig();
85
- const ext = config.web2 ? new ExtensionWeb2() : new ExtensionWeb3();
86
- const user = await ext.getAccount(config);
87
- const userAccount = user.account.address;
88
- updateState({
89
- account: { account: { address: userAccount } },
90
- });
91
- updateState({ dappAccount: config.account.address });
92
- await sleep(100);
93
- if (!config.web2 && !config.userAccountAddress) {
94
- throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
95
- context: {
96
- error: "Account address has not been set for web3 mode",
97
- },
98
- });
99
- }
100
- const getRandomProviderResponse = await getRandomActiveProvider(getConfig());
101
- const events = getDefaultEvents(onStateUpdate, state, callbacks);
102
- const providerUrl = getRandomProviderResponse.provider.url;
103
- const providerApi = new ProviderApi(providerUrl, getDappAccount());
104
- const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount());
105
- if (challenge.error) {
106
- updateState({
107
- error: challenge.error,
108
- loading: false,
109
- });
110
- }
111
- else {
112
- const solution = solvePoW(challenge.challenge, challenge.difficulty);
113
- const signer = user.extension?.signer;
114
- if (!signer || !signer.signRaw) {
115
- throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
116
- context: {
117
- error: "Signer is not defined, cannot sign message to prove account ownership",
118
- },
119
- });
120
- }
121
- const userTimestampSignature = await signer.signRaw({
122
- address: userAccount,
123
- data: stringToHex(challenge[ApiParams.timestamp].toString()),
124
- type: "bytes",
125
- });
126
- const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), solution, userTimestampSignature.signature.toString(), config.captchas.pow.verifiedTimeout);
127
- if (verifiedSolution[ApiParams.verified]) {
128
- updateState({
129
- isHuman: true,
130
- loading: false,
131
- });
132
- events.onHuman(encodeProcaptchaOutput({
133
- [ApiParams.providerUrl]: providerUrl,
134
- [ApiParams.user]: getAccount().account.account.address,
135
- [ApiParams.dapp]: getDappAccount(),
136
- [ApiParams.challenge]: challenge.challenge,
137
- [ApiParams.nonce]: solution,
138
- [ApiParams.timestamp]: challenge.timestamp,
139
- [ApiParams.signature]: {
140
- [ApiParams.provider]: challenge.signature.provider,
141
- [ApiParams.user]: {
142
- [ApiParams.timestamp]: userTimestampSignature.signature.toString(),
143
- },
144
- },
145
- }));
146
- setValidChallengeTimeout();
147
- }
148
- }
149
- }, start, resetState, state.attemptCount, 10);
150
- };
151
- return {
152
- start,
153
- resetState,
154
- };
155
- };
156
- //# sourceMappingURL=Manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Manager.js","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM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