@prosopo/procaptcha-pow 2.0.2 → 2.1.0
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/dist/cjs/components/ProcaptchaPoW.cjs +13 -1
- package/dist/cjs/components/ProcaptchaWidget.cjs +7 -2
- package/dist/cjs/services/Manager.cjs +87 -95
- package/dist/components/ProcaptchaPoW.d.ts.map +1 -1
- package/dist/components/ProcaptchaPoW.js +1 -1
- package/dist/components/ProcaptchaPoW.js.map +1 -1
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +7 -2
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +69 -79
- package/dist/services/Manager.js.map +1 -1
- package/package.json +69 -68
|
@@ -5,5 +5,17 @@ const webComponents = require("@prosopo/web-components");
|
|
|
5
5
|
const react = require("react");
|
|
6
6
|
const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
|
|
7
7
|
const ProcaptchaWidget = react.lazy(async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs"))));
|
|
8
|
-
const ProcaptchaPow = (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
+
);
|
|
9
21
|
exports.ProcaptchaPow = ProcaptchaPow;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
const common = require("@prosopo/common");
|
|
3
4
|
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
4
5
|
const webComponents = require("@prosopo/web-components");
|
|
5
6
|
const react = require("react");
|
|
6
7
|
const Manager = require("../services/Manager.cjs");
|
|
7
8
|
const Procaptcha = (props) => {
|
|
9
|
+
const { t } = common.useTranslation();
|
|
8
10
|
const config = props.config;
|
|
9
11
|
const themeColor = config.theme === "light" ? "light" : "dark";
|
|
10
12
|
const theme = props.config.theme === "light" ? webComponents.lightTheme : webComponents.darkTheme;
|
|
@@ -22,10 +24,13 @@ const Procaptcha = (props) => {
|
|
|
22
24
|
manager.current.resetState();
|
|
23
25
|
};
|
|
24
26
|
form.addEventListener("submit", handleSubmit);
|
|
27
|
+
if (config.language) {
|
|
28
|
+
common.i18n.changeLanguage(config.language);
|
|
29
|
+
}
|
|
25
30
|
return () => {
|
|
26
31
|
form.removeEventListener("submit", handleSubmit);
|
|
27
32
|
};
|
|
28
|
-
}, []);
|
|
33
|
+
}, [config.language]);
|
|
29
34
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: captchaRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
30
35
|
"div",
|
|
31
36
|
{
|
|
@@ -94,7 +99,7 @@ const Procaptcha = (props) => {
|
|
|
94
99
|
checked: state.isHuman,
|
|
95
100
|
onChange: manager.current.start,
|
|
96
101
|
themeColor,
|
|
97
|
-
labelText: "
|
|
102
|
+
labelText: t("WIDGET.I_AM_HUMAN"),
|
|
98
103
|
"aria-label": "human checkbox"
|
|
99
104
|
}
|
|
100
105
|
) })
|
|
@@ -4,7 +4,6 @@ const string = require("@polkadot/util/string");
|
|
|
4
4
|
const account = require("@prosopo/account");
|
|
5
5
|
const api = require("@prosopo/api");
|
|
6
6
|
const common = require("@prosopo/common");
|
|
7
|
-
const loadBalancer = require("@prosopo/load-balancer");
|
|
8
7
|
const procaptcha = require("@prosopo/procaptcha");
|
|
9
8
|
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
10
9
|
const types = require("@prosopo/types");
|
|
@@ -74,103 +73,96 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
74
73
|
updateState({ successfullChallengeTimeout });
|
|
75
74
|
};
|
|
76
75
|
const start = async () => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
resetState();
|
|
84
|
-
updateState({
|
|
85
|
-
loading: true
|
|
86
|
-
});
|
|
87
|
-
const config = getConfig();
|
|
88
|
-
const ext = config.web2 ? new account.ExtensionWeb2() : new account.ExtensionWeb3();
|
|
89
|
-
const userAccount = config.userAccountAddress || (await ext.getAccount(config)).account.address;
|
|
90
|
-
updateState({
|
|
91
|
-
account: { account: { address: userAccount } }
|
|
92
|
-
});
|
|
93
|
-
updateState({ dappAccount: config.account.address });
|
|
94
|
-
await procaptcha.sleep(100);
|
|
95
|
-
if (!config.web2 && !config.userAccountAddress) {
|
|
96
|
-
throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
97
|
-
context: { error: "Account address has not been set for web3 mode" }
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const getRandomProviderResponse = getRandomActiveProvider();
|
|
101
|
-
const events2 = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
|
|
102
|
-
const providerUrl = getRandomProviderResponse.provider.url;
|
|
103
|
-
const providerApi = new api.ProviderApi(
|
|
104
|
-
providerUrl,
|
|
105
|
-
getDappAccount()
|
|
106
|
-
);
|
|
107
|
-
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
108
|
-
userAccount,
|
|
109
|
-
getDappAccount()
|
|
110
|
-
);
|
|
111
|
-
const solution = util.solvePoW(challenge.challenge, challenge.difficulty);
|
|
112
|
-
const user = await ext.getAccount(getConfig());
|
|
113
|
-
const signer = user.extension?.signer;
|
|
114
|
-
if (!signer || !signer.signRaw) {
|
|
115
|
-
throw new common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
116
|
-
context: {
|
|
117
|
-
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
76
|
+
await procaptchaCommon.providerRetry(
|
|
77
|
+
async () => {
|
|
78
|
+
if (state.loading) {
|
|
79
|
+
return;
|
|
118
80
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
events2.onHuman(
|
|
140
|
-
types.encodeProcaptchaOutput({
|
|
141
|
-
[types.ApiParams.providerUrl]: providerUrl,
|
|
142
|
-
[types.ApiParams.user]: getAccount().account.account.address,
|
|
143
|
-
[types.ApiParams.dapp]: getDappAccount(),
|
|
144
|
-
[types.ApiParams.challenge]: challenge.challenge,
|
|
145
|
-
[types.ApiParams.nonce]: solution,
|
|
146
|
-
[types.ApiParams.timestamp]: challenge.timestamp,
|
|
147
|
-
[types.ApiParams.signature]: {
|
|
148
|
-
[types.ApiParams.provider]: challenge.signature.provider,
|
|
149
|
-
[types.ApiParams.user]: {
|
|
150
|
-
[types.ApiParams.timestamp]: userTimestampSignature.signature.toString()
|
|
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 userAccount = config.userAccountAddress || (await ext.getAccount(config)).account.address;
|
|
92
|
+
updateState({
|
|
93
|
+
account: { account: { address: userAccount } }
|
|
94
|
+
});
|
|
95
|
+
updateState({ dappAccount: config.account.address });
|
|
96
|
+
await procaptcha.sleep(100);
|
|
97
|
+
if (!config.web2 && !config.userAccountAddress) {
|
|
98
|
+
throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
99
|
+
context: {
|
|
100
|
+
error: "Account address has not been set for web3 mode"
|
|
151
101
|
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const getRandomProviderResponse = await procaptchaCommon.getRandomActiveProvider(
|
|
105
|
+
getConfig()
|
|
106
|
+
);
|
|
107
|
+
const events2 = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
|
|
108
|
+
const providerUrl = getRandomProviderResponse.provider.url;
|
|
109
|
+
const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
|
|
110
|
+
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
111
|
+
userAccount,
|
|
112
|
+
getDappAccount()
|
|
113
|
+
);
|
|
114
|
+
const solution = util.solvePoW(challenge.challenge, challenge.difficulty);
|
|
115
|
+
const user = await ext.getAccount(getConfig());
|
|
116
|
+
const signer = user.extension?.signer;
|
|
117
|
+
if (!signer || !signer.signRaw) {
|
|
118
|
+
throw new common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
119
|
+
context: {
|
|
120
|
+
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const userTimestampSignature = await signer.signRaw({
|
|
125
|
+
address: userAccount,
|
|
126
|
+
data: string.stringToHex(challenge[types.ApiParams.timestamp].toString()),
|
|
127
|
+
type: "bytes"
|
|
128
|
+
});
|
|
129
|
+
const verifiedSolution = await providerApi.submitPowCaptchaSolution(
|
|
130
|
+
challenge,
|
|
131
|
+
getAccount().account.account.address,
|
|
132
|
+
getDappAccount(),
|
|
133
|
+
solution,
|
|
134
|
+
userTimestampSignature.signature.toString(),
|
|
135
|
+
config.captchas.pow.verifiedTimeout
|
|
136
|
+
);
|
|
137
|
+
if (verifiedSolution[types.ApiParams.verified]) {
|
|
138
|
+
updateState({
|
|
139
|
+
isHuman: true,
|
|
140
|
+
loading: false
|
|
141
|
+
});
|
|
142
|
+
events2.onHuman(
|
|
143
|
+
types.encodeProcaptchaOutput({
|
|
144
|
+
[types.ApiParams.providerUrl]: providerUrl,
|
|
145
|
+
[types.ApiParams.user]: getAccount().account.account.address,
|
|
146
|
+
[types.ApiParams.dapp]: getDappAccount(),
|
|
147
|
+
[types.ApiParams.challenge]: challenge.challenge,
|
|
148
|
+
[types.ApiParams.nonce]: solution,
|
|
149
|
+
[types.ApiParams.timestamp]: challenge.timestamp,
|
|
150
|
+
[types.ApiParams.signature]: {
|
|
151
|
+
[types.ApiParams.provider]: challenge.signature.provider,
|
|
152
|
+
[types.ApiParams.user]: {
|
|
153
|
+
[types.ApiParams.timestamp]: userTimestampSignature.signature.toString()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
setValidChallengeTimeout();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
start,
|
|
162
|
+
resetState,
|
|
163
|
+
state.attemptCount,
|
|
164
|
+
10
|
|
165
165
|
);
|
|
166
|
-
return {
|
|
167
|
-
providerAccount: randomProvderObj.address,
|
|
168
|
-
provider: {
|
|
169
|
-
url: randomProvderObj.url,
|
|
170
|
-
datasetId: randomProvderObj.datasetId,
|
|
171
|
-
datasetIdContent: randomProvderObj.datasetIdContent
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
166
|
};
|
|
175
167
|
return {
|
|
176
168
|
start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaPoW.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { ProcaptchaPlaceholder } from "@prosopo/web-components";
|
|
3
3
|
import { Suspense, lazy } from "react";
|
|
4
4
|
const ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
|
|
5
|
-
export const ProcaptchaPow = (props) => (_jsx(Suspense, { fallback: _jsx(ProcaptchaPlaceholder, {
|
|
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
6
|
//# sourceMappingURL=ProcaptchaPoW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaPoW.js","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":";
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAkCtD,QAAA,MAAM,UAAU,UAAW,eAAe,qDAiIzC,CAAC;AACF,eAAe,UAAU,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { i18n, useTranslation } from "@prosopo/common";
|
|
2
3
|
import { buildUpdateState, useProcaptcha } from "@prosopo/procaptcha-common";
|
|
3
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";
|
|
4
5
|
import { useEffect, useRef, useState } from "react";
|
|
5
6
|
import { Manager } from "../services/Manager.js";
|
|
6
7
|
const Procaptcha = (props) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
7
9
|
const config = props.config;
|
|
8
10
|
const themeColor = config.theme === "light" ? "light" : "dark";
|
|
9
11
|
const theme = props.config.theme === "light" ? lightTheme : darkTheme;
|
|
@@ -23,10 +25,13 @@ const Procaptcha = (props) => {
|
|
|
23
25
|
manager.current.resetState();
|
|
24
26
|
};
|
|
25
27
|
form.addEventListener("submit", handleSubmit);
|
|
28
|
+
if (config.language) {
|
|
29
|
+
i18n.changeLanguage(config.language);
|
|
30
|
+
}
|
|
26
31
|
return () => {
|
|
27
32
|
form.removeEventListener("submit", handleSubmit);
|
|
28
33
|
};
|
|
29
|
-
}, []);
|
|
34
|
+
}, [config.language]);
|
|
30
35
|
return (_jsx("div", { ref: captchaRef, children: _jsx("div", { style: {
|
|
31
36
|
maxWidth: WIDGET_MAX_WIDTH,
|
|
32
37
|
maxHeight: "100%",
|
|
@@ -56,7 +61,7 @@ const Procaptcha = (props) => {
|
|
|
56
61
|
verticalAlign: "middle",
|
|
57
62
|
}, children: _jsx("div", { style: {
|
|
58
63
|
display: "flex",
|
|
59
|
-
}, 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: "
|
|
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"), "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" }) }) }) })] })] }) }) }) }) }));
|
|
60
65
|
};
|
|
61
66
|
export default Procaptcha;
|
|
62
67
|
//# sourceMappingURL=ProcaptchaWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAAA,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,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,C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manager.ts"],"names":[],"mappings":"
|
|
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;;;CA2N9B,CAAC"}
|
package/dist/services/Manager.js
CHANGED
|
@@ -2,11 +2,10 @@ import { stringToHex } from "@polkadot/util/string";
|
|
|
2
2
|
import { ExtensionWeb2, ExtensionWeb3 } from "@prosopo/account";
|
|
3
3
|
import { ProviderApi } from "@prosopo/api";
|
|
4
4
|
import { ProsopoEnvError } from "@prosopo/common";
|
|
5
|
-
import { loadBalancer } from "@prosopo/load-balancer";
|
|
6
5
|
import { sleep } from "@prosopo/procaptcha";
|
|
7
|
-
import { buildUpdateState, getDefaultEvents } from "@prosopo/procaptcha-common";
|
|
6
|
+
import { buildUpdateState, getDefaultEvents, getRandomActiveProvider, providerRetry, } from "@prosopo/procaptcha-common";
|
|
8
7
|
import { ApiParams, ProcaptchaConfigSchema, encodeProcaptchaOutput, } from "@prosopo/types";
|
|
9
|
-
import {
|
|
8
|
+
import { solvePoW } from "@prosopo/util";
|
|
10
9
|
export const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
11
10
|
const events = getDefaultEvents(onStateUpdate, state, callbacks);
|
|
12
11
|
const defaultState = () => {
|
|
@@ -70,86 +69,77 @@ export const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
70
69
|
updateState({ successfullChallengeTimeout });
|
|
71
70
|
};
|
|
72
71
|
const start = async () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const config = getConfig();
|
|
84
|
-
const ext = config.web2 ? new ExtensionWeb2() : new ExtensionWeb3();
|
|
85
|
-
const userAccount = config.userAccountAddress ||
|
|
86
|
-
(await ext.getAccount(config)).account.address;
|
|
87
|
-
updateState({
|
|
88
|
-
account: { account: { address: userAccount } },
|
|
89
|
-
});
|
|
90
|
-
updateState({ dappAccount: config.account.address });
|
|
91
|
-
await sleep(100);
|
|
92
|
-
if (!config.web2 && !config.userAccountAddress) {
|
|
93
|
-
throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
94
|
-
context: { error: "Account address has not been set for web3 mode" },
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
const getRandomProviderResponse = getRandomActiveProvider();
|
|
98
|
-
const events = getDefaultEvents(onStateUpdate, state, callbacks);
|
|
99
|
-
const providerUrl = getRandomProviderResponse.provider.url;
|
|
100
|
-
const providerApi = new ProviderApi(providerUrl, getDappAccount());
|
|
101
|
-
const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount());
|
|
102
|
-
const solution = solvePoW(challenge.challenge, challenge.difficulty);
|
|
103
|
-
const user = await ext.getAccount(getConfig());
|
|
104
|
-
const signer = user.extension?.signer;
|
|
105
|
-
if (!signer || !signer.signRaw) {
|
|
106
|
-
throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
107
|
-
context: {
|
|
108
|
-
error: "Signer is not defined, cannot sign message to prove account ownership",
|
|
109
|
-
},
|
|
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,
|
|
110
82
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), solution, userTimestampSignature.signature.toString(), config.captchas.pow.verifiedTimeout);
|
|
118
|
-
if (verifiedSolution[ApiParams.verified]) {
|
|
83
|
+
updateState({ attemptCount: state.attemptCount + 1 });
|
|
84
|
+
const config = getConfig();
|
|
85
|
+
const ext = config.web2 ? new ExtensionWeb2() : new ExtensionWeb3();
|
|
86
|
+
const userAccount = config.userAccountAddress ||
|
|
87
|
+
(await ext.getAccount(config)).account.address;
|
|
119
88
|
updateState({
|
|
120
|
-
|
|
121
|
-
loading: false,
|
|
89
|
+
account: { account: { address: userAccount } },
|
|
122
90
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
[ApiParams.timestamp]: challenge.timestamp,
|
|
130
|
-
[ApiParams.signature]: {
|
|
131
|
-
[ApiParams.provider]: challenge.signature.provider,
|
|
132
|
-
[ApiParams.user]: {
|
|
133
|
-
[ApiParams.timestamp]: userTimestampSignature.signature.toString(),
|
|
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",
|
|
134
97
|
},
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
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
|
+
const solution = solvePoW(challenge.challenge, challenge.difficulty);
|
|
106
|
+
const user = await ext.getAccount(getConfig());
|
|
107
|
+
const signer = user.extension?.signer;
|
|
108
|
+
if (!signer || !signer.signRaw) {
|
|
109
|
+
throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
110
|
+
context: {
|
|
111
|
+
error: "Signer is not defined, cannot sign message to prove account ownership",
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const userTimestampSignature = await signer.signRaw({
|
|
116
|
+
address: userAccount,
|
|
117
|
+
data: stringToHex(challenge[ApiParams.timestamp].toString()),
|
|
118
|
+
type: "bytes",
|
|
119
|
+
});
|
|
120
|
+
const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), solution, userTimestampSignature.signature.toString(), config.captchas.pow.verifiedTimeout);
|
|
121
|
+
if (verifiedSolution[ApiParams.verified]) {
|
|
122
|
+
updateState({
|
|
123
|
+
isHuman: true,
|
|
124
|
+
loading: false,
|
|
125
|
+
});
|
|
126
|
+
events.onHuman(encodeProcaptchaOutput({
|
|
127
|
+
[ApiParams.providerUrl]: providerUrl,
|
|
128
|
+
[ApiParams.user]: getAccount().account.account.address,
|
|
129
|
+
[ApiParams.dapp]: getDappAccount(),
|
|
130
|
+
[ApiParams.challenge]: challenge.challenge,
|
|
131
|
+
[ApiParams.nonce]: solution,
|
|
132
|
+
[ApiParams.timestamp]: challenge.timestamp,
|
|
133
|
+
[ApiParams.signature]: {
|
|
134
|
+
[ApiParams.provider]: challenge.signature.provider,
|
|
135
|
+
[ApiParams.user]: {
|
|
136
|
+
[ApiParams.timestamp]: userTimestampSignature.signature.toString(),
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
}));
|
|
140
|
+
setValidChallengeTimeout();
|
|
141
|
+
}
|
|
142
|
+
}, start, resetState, state.attemptCount, 10);
|
|
153
143
|
};
|
|
154
144
|
return {
|
|
155
145
|
start,
|
|
@@ -1 +1 @@
|
|
|
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,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,
|
|
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,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEN,SAAS,EAGT,sBAAsB,EAGtB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,MAAM,OAAO,GAAG,CACtB,WAAwC,EACxC,KAAsB,EACtB,aAAsC,EACtC,SAA8B,EAC7B,EAAE;IACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAEjE,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
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
"name": "@prosopo/procaptcha-pow",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20",
|
|
11
|
+
"npm": ">=9"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/cjs/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"source": "./src/index.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo \"No test specified\"",
|
|
23
|
+
"clean": "tsc --build --clean",
|
|
24
|
+
"build": "tsc --build --verbose",
|
|
25
|
+
"build:cjs": "npx vite --config vite.cjs.config.ts build"
|
|
26
|
+
},
|
|
27
|
+
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@polkadot/util": "12.6.2",
|
|
30
|
+
"@prosopo/account": "2.1.0",
|
|
31
|
+
"@prosopo/api": "2.1.0",
|
|
32
|
+
"@prosopo/common": "2.1.0",
|
|
33
|
+
"@prosopo/procaptcha": "2.1.0",
|
|
34
|
+
"@prosopo/procaptcha-common": "2.1.0",
|
|
35
|
+
"@prosopo/types": "2.1.0",
|
|
36
|
+
"@prosopo/util": "2.1.0",
|
|
37
|
+
"@prosopo/web-components": "2.1.0",
|
|
38
|
+
"react": "18.3.1"
|
|
39
|
+
},
|
|
40
|
+
"overrides": {
|
|
41
|
+
"@polkadot/extension-inject": {
|
|
42
|
+
"@polkadot/api": {
|
|
43
|
+
"version": "10.13.1"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@prosopo/config": "2.1.0",
|
|
49
|
+
"@vitest/coverage-v8": "2.1.1",
|
|
50
|
+
"concurrently": "9.0.1",
|
|
51
|
+
"npm-run-all": "4.1.5",
|
|
52
|
+
"rimraf": "6.0.1",
|
|
53
|
+
"tslib": "2.7.0",
|
|
54
|
+
"tsx": "4.19.1",
|
|
55
|
+
"typescript": "5.6.2",
|
|
56
|
+
"vite": "5.4.6",
|
|
57
|
+
"vitest": "2.1.1"
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/prosopo/captcha.git"
|
|
62
|
+
},
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/prosopo/captcha/issues"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
67
|
+
"description": "",
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"registry": "https://registry.npmjs.org"
|
|
70
|
+
}
|
|
70
71
|
}
|