@prosopo/procaptcha-pow 0.3.1 → 0.3.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.
Files changed (32) hide show
  1. package/dist/Services/Manager.d.ts +3 -20
  2. package/dist/Services/Manager.d.ts.map +1 -1
  3. package/dist/Services/Manager.js +87 -23
  4. package/dist/Services/Manager.js.map +1 -1
  5. package/dist/Services/SolverService.d.ts.map +1 -1
  6. package/dist/Services/SolverService.js.map +1 -1
  7. package/dist/cjs/Services/Manager.cjs +102 -39
  8. package/dist/cjs/account/dist/extension/ExtensionWeb3.cjs +28 -0
  9. package/dist/cjs/account/dist/index.cjs +2 -0
  10. package/dist/cjs/components/Captcha.cjs +51 -121
  11. package/dist/cjs/components/ProcaptchaPoW.cjs +4 -2
  12. package/dist/cjs/web-components/dist/CaptchaPlaceholder.cjs +13 -55
  13. package/dist/cjs/web-components/dist/Checkbox.cjs +21 -11
  14. package/dist/cjs/web-components/dist/Containers.cjs +42 -0
  15. package/dist/cjs/web-components/dist/LoadingSpinner.cjs +4 -0
  16. package/dist/cjs/web-components/dist/Logo.cjs +16 -0
  17. package/dist/cjs/web-components/dist/LogoWithText.cjs +10 -0
  18. package/dist/cjs/web-components/dist/LogoWithoutText.cjs +10 -0
  19. package/dist/cjs/web-components/dist/WidgetConstants.cjs +12 -0
  20. package/dist/cjs/web-components/dist/index.cjs +11 -0
  21. package/dist/components/Captcha.d.ts +1 -17
  22. package/dist/components/Captcha.d.ts.map +1 -1
  23. package/dist/components/Captcha.js +32 -80
  24. package/dist/components/Captcha.js.map +1 -1
  25. package/dist/components/ProcaptchaPoW.d.ts +4 -2
  26. package/dist/components/ProcaptchaPoW.d.ts.map +1 -1
  27. package/dist/components/ProcaptchaPoW.js +1 -1
  28. package/dist/components/ProcaptchaPoW.js.map +1 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/package.json +8 -8
  32. package/vite.cjs.config.ts +13 -0
@@ -1,22 +1,5 @@
1
- import { ProcaptchaClientConfigInput } from '@prosopo/types';
2
- type ProcaptchaPowOutput = {
3
- user: string;
4
- dapp: string;
5
- commitmentId?: string | undefined;
6
- providerUrl?: string | undefined;
7
- blockNumber?: number | undefined;
1
+ import { ProcaptchaCallbacks, ProcaptchaClientConfigInput, ProcaptchaState, ProcaptchaStateUpdateFn } from '@prosopo/types';
2
+ export declare const Manager: (configInput: ProcaptchaClientConfigInput, state: ProcaptchaState, onStateUpdate: ProcaptchaStateUpdateFn, callbacks: ProcaptchaCallbacks) => {
3
+ start: () => Promise<void>;
8
4
  };
9
- export interface ProcaptchaEvents {
10
- onError: (error: Error) => void;
11
- onAccountNotFound: (address: string) => void;
12
- onHuman: (output: ProcaptchaPowOutput) => void;
13
- onExtensionNotFound: () => void;
14
- onChallengeExpired: () => void;
15
- onExpired: () => void;
16
- onFailed: () => void;
17
- onOpen: () => void;
18
- onClose: () => void;
19
- }
20
- export declare const Manager: (configInput: ProcaptchaClientConfigInput) => Promise<import("@prosopo/api").PowCaptchaSolutionResponse>;
21
- export {};
22
5
  //# sourceMappingURL=Manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/Services/Manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAwD,MAAM,gBAAgB,CAAA;AASlH,KAAK,mBAAmB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/B,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC9C,mBAAmB,EAAE,MAAM,IAAI,CAAA;IAC/B,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,OAAO,gBAAuB,2BAA2B,+DAmFrE,CAAA"}
1
+ {"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/Services/Manager.ts"],"names":[],"mappings":"AAaA,OAAO,EAGH,mBAAmB,EACnB,2BAA2B,EAG3B,eAAe,EACf,uBAAuB,EAC1B,MAAM,gBAAgB,CAAA;AAcvB,eAAO,MAAM,OAAO,gBACH,2BAA2B,SACjC,eAAe,iBACP,uBAAuB,aAC3B,mBAAmB;;CAmKjC,CAAA"}
@@ -1,14 +1,32 @@
1
+ import { ApiParams, ProcaptchaConfigSchema, } from '@prosopo/types';
1
2
  import { ApiPromise } from '@polkadot/api/promise/Api';
2
3
  import { ExtensionWeb2 } from '@prosopo/account';
3
4
  import { Keyring } from '@polkadot/keyring';
4
- import { ProcaptchaConfigSchema } from '@prosopo/types';
5
5
  import { ProsopoCaptchaContract, wrapQuery } from '@prosopo/contract';
6
- import { ProsopoEnvError, trimProviderUrl } from '@prosopo/common';
6
+ import { ProsopoContractError, ProsopoEnvError, trimProviderUrl } from '@prosopo/common';
7
7
  import { ProviderApi } from '@prosopo/api';
8
8
  import { WsProvider } from '@polkadot/rpc-provider/ws';
9
9
  import { ContractAbi as abiJson } from '@prosopo/captcha-contract/contract-info';
10
+ import { buildUpdateState, getDefaultEvents } from '@prosopo/procaptcha-common';
11
+ import { sleep } from '@prosopo/procaptcha';
10
12
  import { solvePoW } from './SolverService.js';
11
- export const Manager = async (configInput) => {
13
+ export const Manager = (configInput, state, onStateUpdate, callbacks) => {
14
+ const defaultState = () => {
15
+ return {
16
+ showModal: false,
17
+ loading: false,
18
+ index: 0,
19
+ challenge: undefined,
20
+ solutions: undefined,
21
+ isHuman: false,
22
+ captchaApi: undefined,
23
+ account: undefined,
24
+ };
25
+ };
26
+ const clearTimeout = () => {
27
+ window.clearTimeout(state.timeout);
28
+ updateState({ timeout: undefined });
29
+ };
12
30
  const getConfig = () => {
13
31
  const config = {
14
32
  userAccountAddress: '',
@@ -32,25 +50,71 @@ export const Manager = async (configInput) => {
32
50
  const keyring = new Keyring({ type, ss58Format: api.registry.chainSS58 });
33
51
  return new ProsopoCaptchaContract(api, JSON.parse(abiJson), network.contract.address, 'prosopo', 0, keyring.addFromAddress(getConfig().account.address || ''));
34
52
  };
35
- const config = getConfig();
36
- if (!config.web2 && !config.userAccountAddress) {
37
- throw new ProsopoEnvError('GENERAL.ACCOUNT_NOT_FOUND', {
38
- context: { error: 'Account address has not been set for web3 mode' },
39
- });
40
- }
41
- const ext = new ExtensionWeb2();
42
- const account = await ext.getAccount(config);
43
- const contract = await loadContract();
44
- const getRandomProviderResponse = await wrapQuery(contract.query.getRandomActiveProvider, contract.query)(account.account.address, configInput.account.address || '');
45
- const providerUrl = trimProviderUrl(getRandomProviderResponse.provider.url.toString());
46
- const providerApi = new ProviderApi(getNetwork(getConfig()), providerUrl, configInput.account.address || '');
47
- const challenge = await providerApi.getPowCaptchaChallenge(account.account.address, configInput.account.address || '');
48
- console.log('challenge', challenge);
49
- console.log('challenge', challenge.challenge);
50
- console.log('challenge', challenge.difficulty);
51
- const solution = solvePoW(challenge.challenge, challenge.difficulty);
52
- console.log('solution', solution);
53
- const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, account.account.address, configInput.account.address || '', getRandomProviderResponse, solution);
54
- return verifiedSolution;
53
+ const getAccount = () => {
54
+ if (!state.account) {
55
+ throw new ProsopoEnvError('GENERAL.ACCOUNT_NOT_FOUND', { context: { error: 'Account not loaded' } });
56
+ }
57
+ const account = state.account;
58
+ return account;
59
+ };
60
+ const getDappAccount = () => {
61
+ if (!state.dappAccount) {
62
+ throw new ProsopoEnvError('GENERAL.SITE_KEY_MISSING');
63
+ }
64
+ const dappAccount = state.dappAccount;
65
+ return dappAccount;
66
+ };
67
+ const getBlockNumber = () => {
68
+ if (!state.blockNumber) {
69
+ throw new ProsopoContractError('CAPTCHA.INVALID_BLOCK_NO', { context: { error: 'Block number not found' } });
70
+ }
71
+ const blockNumber = state.blockNumber;
72
+ return blockNumber;
73
+ };
74
+ const updateState = buildUpdateState(state, onStateUpdate);
75
+ const resetState = () => {
76
+ clearTimeout();
77
+ updateState(defaultState());
78
+ };
79
+ const start = async () => {
80
+ if (state.loading) {
81
+ return;
82
+ }
83
+ if (state.isHuman) {
84
+ return;
85
+ }
86
+ resetState();
87
+ updateState({ loading: true });
88
+ const config = getConfig();
89
+ updateState({ dappAccount: config.account.address });
90
+ await sleep(100);
91
+ if (!config.web2 && !config.userAccountAddress) {
92
+ throw new ProsopoEnvError('GENERAL.ACCOUNT_NOT_FOUND', {
93
+ context: { error: 'Account address has not been set for web3 mode' },
94
+ });
95
+ }
96
+ const ext = new ExtensionWeb2();
97
+ const account = await ext.getAccount(config);
98
+ const contract = await loadContract();
99
+ const events = getDefaultEvents(onStateUpdate, state, callbacks);
100
+ const getRandomProviderResponse = await wrapQuery(contract.query.getRandomActiveProvider, contract.query)(account.account.address, getDappAccount());
101
+ const providerUrl = trimProviderUrl(getRandomProviderResponse.provider.url.toString());
102
+ const providerApi = new ProviderApi(getNetwork(getConfig()), providerUrl, getDappAccount());
103
+ const challenge = await providerApi.getPowCaptchaChallenge(account.account.address, getDappAccount());
104
+ const solution = solvePoW(challenge.challenge, challenge.difficulty);
105
+ await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.address, getDappAccount(), getRandomProviderResponse, solution);
106
+ if (state.isHuman) {
107
+ events.onHuman({
108
+ providerUrl,
109
+ [ApiParams.user]: getAccount().account.address,
110
+ [ApiParams.dapp]: getDappAccount(),
111
+ [ApiParams.challengeId]: challenge.challenge,
112
+ [ApiParams.blockNumber]: getBlockNumber(),
113
+ });
114
+ }
115
+ };
116
+ return {
117
+ start,
118
+ };
55
119
  };
56
120
  //# sourceMappingURL=Manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Manager.js","sourceRoot":"","sources":["../../src/Services/Manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAA6D,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAClH,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAsB7C,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,WAAwC,EAAE,EAAE;IACtE,MAAM,SAAS,GAAG,GAAG,EAAE;QACnB,MAAM,MAAM,GAAgC;YACxC,kBAAkB,EAAE,EAAE;YACtB,GAAG,WAAW;SACjB,CAAA;QAED,OAAO,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,CAAC,MAAoC,EAAE,EAAE;QACxD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACtD,IAAI,CAAC,OAAO,EA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CAAC,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;QACpE,MAAM,WAAW,CAAC,wBAAwB,CACtC,SAAS,EACT,UAAU,EAAE,CAAC,OAAO,CAAC,OAAO,EAC5B,cAAc,EAAE,EAChB,yBAAyB,EACzB,QAAQ,CACX,CAAA;QACD,IAAI,KAAK,CAAC,OAAO,EAAE;YACf,MAAM,CAAC,OAAO,CAAC;gBACX,WAAW;gBACX,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,OAAO;gBAC9C,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE;gBAClC,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,SAAS;gBAC5C,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,cAAc,EAAE;aAC5C,CAAC,CAAA;SACL;IACL,CAAC,CAAA;IAED,OAAO;QACH,KAAK;KACR,CAAA;AACL,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SolverService.d.ts","sourceRoot":"","sources":["../../src/Services/SolverService.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,SAAU,MAAM,cAAc,MAAM,KAAG,MAe3D,CAAA"}
1
+ {"version":3,"file":"SolverService.d.ts","sourceRoot":"","sources":["../../src/Services/SolverService.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,QAAQ,SAAU,MAAM,cAAc,MAAM,KAAG,MAe3D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SolverService.js","sourceRoot":"","sources":["../../src/Services/SolverService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAU,EAAE;IACjE,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CA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AG,CAAC,MAAkB,EAAU,EAAE,CAC/C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;KACjD,IAAI,CAAC,EAAE,CAAC,CAAA"}
@@ -1,29 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const types = require("@prosopo/types");
3
4
  const Api = require("@polkadot/api/promise/Api");
4
5
  require("../account/dist/index.cjs");
5
6
  const keyring = require("@polkadot/keyring");
6
- const types = require("@prosopo/types");
7
7
  const contract = require("@prosopo/contract");
8
8
  const common = require("@prosopo/common");
9
9
  const api = require("@prosopo/api");
10
10
  const ws = require("@polkadot/rpc-provider/ws");
11
11
  const contractInfo = require("@prosopo/captcha-contract/contract-info");
12
+ const procaptchaCommon = require("@prosopo/procaptcha-common");
13
+ const procaptcha = require("@prosopo/procaptcha");
12
14
  const SolverService = require("./SolverService.cjs");
13
15
  const ExtensionWeb2 = require("../account/dist/extension/ExtensionWeb2.cjs");
14
- const Manager = async (configInput) => {
16
+ const Manager = (configInput, state, onStateUpdate, callbacks) => {
17
+ const defaultState = () => {
18
+ return {
19
+ // note order matters! see buildUpdateState. These fields are set in order, so disable modal first, then set loading to false, etc.
20
+ showModal: false,
21
+ loading: false,
22
+ index: 0,
23
+ challenge: void 0,
24
+ solutions: void 0,
25
+ isHuman: false,
26
+ captchaApi: void 0,
27
+ account: void 0
28
+ // don't handle timeout here, this should be handled by the state management
29
+ };
30
+ };
31
+ const clearTimeout = () => {
32
+ window.clearTimeout(state.timeout);
33
+ updateState({ timeout: void 0 });
34
+ };
15
35
  const getConfig = () => {
16
- const config2 = {
36
+ const config = {
17
37
  userAccountAddress: "",
18
38
  ...configInput
19
39
  };
20
- return types.ProcaptchaConfigSchema.parse(config2);
40
+ return types.ProcaptchaConfigSchema.parse(config);
21
41
  };
22
- const getNetwork = (config2) => {
23
- const network = config2.networks[config2.defaultNetwork];
42
+ const getNetwork = (config) => {
43
+ const network = config.networks[config.defaultNetwork];
24
44
  if (!network) {
25
45
  throw new common.ProsopoEnvError("DEVELOPER.NETWORK_NOT_FOUND", {
26
- context: { error: `No network found for environment ${config2.defaultEnvironment}` }
46
+ context: { error: `No network found for environment ${config.defaultEnvironment}` }
27
47
  });
28
48
  }
29
49
  return network;
@@ -42,37 +62,80 @@ const Manager = async (configInput) => {
42
62
  keyring$1.addFromAddress(getConfig().account.address || "")
43
63
  );
44
64
  };
45
- const config = getConfig();
46
- if (!config.web2 && !config.userAccountAddress) {
47
- throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
48
- context: { error: "Account address has not been set for web3 mode" }
49
- });
50
- }
51
- const ext = new ExtensionWeb2.ExtensionWeb2();
52
- const account = await ext.getAccount(config);
53
- const contract$1 = await loadContract();
54
- const getRandomProviderResponse = await contract.wrapQuery(
55
- contract$1.query.getRandomActiveProvider,
56
- contract$1.query
57
- )(account.account.address, configInput.account.address || "");
58
- const providerUrl = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
59
- const providerApi = new api.ProviderApi(getNetwork(getConfig()), providerUrl, configInput.account.address || "");
60
- const challenge = await providerApi.getPowCaptchaChallenge(
61
- account.account.address,
62
- configInput.account.address || ""
63
- );
64
- console.log("challenge", challenge);
65
- console.log("challenge", challenge.challenge);
66
- console.log("challenge", challenge.difficulty);
67
- const solution = SolverService.solvePoW(challenge.challenge, challenge.difficulty);
68
- console.log("solution", solution);
69
- const verifiedSolution = await providerApi.submitPowCaptchaSolution(
70
- challenge,
71
- account.account.address,
72
- configInput.account.address || "",
73
- getRandomProviderResponse,
74
- solution
75
- );
76
- return verifiedSolution;
65
+ const getAccount = () => {
66
+ if (!state.account) {
67
+ throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
68
+ }
69
+ const account = state.account;
70
+ return account;
71
+ };
72
+ const getDappAccount = () => {
73
+ if (!state.dappAccount) {
74
+ throw new common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
75
+ }
76
+ const dappAccount = state.dappAccount;
77
+ return dappAccount;
78
+ };
79
+ const getBlockNumber = () => {
80
+ if (!state.blockNumber) {
81
+ throw new common.ProsopoContractError("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
82
+ }
83
+ const blockNumber = state.blockNumber;
84
+ return blockNumber;
85
+ };
86
+ const updateState = procaptchaCommon.buildUpdateState(state, onStateUpdate);
87
+ const resetState = () => {
88
+ clearTimeout();
89
+ updateState(defaultState());
90
+ };
91
+ const start = async () => {
92
+ if (state.loading) {
93
+ return;
94
+ }
95
+ if (state.isHuman) {
96
+ return;
97
+ }
98
+ resetState();
99
+ updateState({ loading: true });
100
+ const config = getConfig();
101
+ updateState({ dappAccount: config.account.address });
102
+ await procaptcha.sleep(100);
103
+ if (!config.web2 && !config.userAccountAddress) {
104
+ throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
105
+ context: { error: "Account address has not been set for web3 mode" }
106
+ });
107
+ }
108
+ const ext = new ExtensionWeb2.ExtensionWeb2();
109
+ const account = await ext.getAccount(config);
110
+ const contract$1 = await loadContract();
111
+ const events = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
112
+ const getRandomProviderResponse = await contract.wrapQuery(
113
+ contract$1.query.getRandomActiveProvider,
114
+ contract$1.query
115
+ )(account.account.address, getDappAccount());
116
+ const providerUrl = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
117
+ const providerApi = new api.ProviderApi(getNetwork(getConfig()), providerUrl, getDappAccount());
118
+ const challenge = await providerApi.getPowCaptchaChallenge(account.account.address, getDappAccount());
119
+ const solution = SolverService.solvePoW(challenge.challenge, challenge.difficulty);
120
+ await providerApi.submitPowCaptchaSolution(
121
+ challenge,
122
+ getAccount().account.address,
123
+ getDappAccount(),
124
+ getRandomProviderResponse,
125
+ solution
126
+ );
127
+ if (state.isHuman) {
128
+ events.onHuman({
129
+ providerUrl,
130
+ [types.ApiParams.user]: getAccount().account.address,
131
+ [types.ApiParams.dapp]: getDappAccount(),
132
+ [types.ApiParams.challengeId]: challenge.challenge,
133
+ [types.ApiParams.blockNumber]: getBlockNumber()
134
+ });
135
+ }
136
+ };
137
+ return {
138
+ start
139
+ };
77
140
  };
78
141
  exports.Manager = Manager;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Extension = require("./Extension.cjs");
4
+ const common = require("@prosopo/common");
5
+ const extensionDapp = require("@polkadot/extension-dapp");
6
+ class ExtensionWeb3 extends Extension.Extension {
7
+ async getAccount(config) {
8
+ const { dappName, userAccountAddress: address } = config;
9
+ if (!address) {
10
+ throw new common.ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
11
+ }
12
+ const extensions = await extensionDapp.web3Enable(dappName);
13
+ if (extensions.length === 0) {
14
+ throw new common.ProsopoError("WIDGET.NO_EXTENSION_FOUND");
15
+ }
16
+ for (const extension of extensions) {
17
+ const accounts = await extension.accounts.get();
18
+ const account = accounts.find((account2) => account2.address === address);
19
+ if (account) {
20
+ return { account, extension };
21
+ }
22
+ }
23
+ throw new common.ProsopoError("WIDGET.ACCOUNT_NOT_FOUND", {
24
+ context: { error: `No account found matching ${address}` }
25
+ });
26
+ }
27
+ }
28
+ exports.ExtensionWeb3 = ExtensionWeb3;
@@ -2,5 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const Extension = require("./extension/Extension.cjs");
4
4
  const ExtensionWeb2 = require("./extension/ExtensionWeb2.cjs");
5
+ const ExtensionWeb3 = require("./extension/ExtensionWeb3.cjs");
5
6
  exports.Extension = Extension.Extension;
6
7
  exports.ExtensionWeb2 = ExtensionWeb2.ExtensionWeb2;
8
+ exports.ExtensionWeb3 = ExtensionWeb3.ExtensionWeb3;
@@ -2,77 +2,42 @@
2
2
  const jsxRuntime = require("@emotion/react/jsx-runtime");
3
3
  require("../web-components/dist/index.cjs");
4
4
  const Manager = require("../Services/Manager.cjs");
5
- const react = require("@emotion/react");
6
- const react$1 = require("react");
5
+ const procaptchaCommon = require("@prosopo/procaptcha-common");
6
+ const react = require("react");
7
7
  const theme = require("../web-components/dist/theme.cjs");
8
+ const Containers = require("../web-components/dist/Containers.cjs");
9
+ const WidgetConstants = require("../web-components/dist/WidgetConstants.cjs");
8
10
  const LoadingSpinner = require("../web-components/dist/LoadingSpinner.cjs");
9
11
  const Checkbox = require("../web-components/dist/Checkbox.cjs");
10
- const logoStyle = react.css`
11
- align-items: center;
12
- justify-content: flex-end;
13
- display: flex;
14
- padding: 8px;
15
-
16
- @media (max-width: 245px) {
17
- &:nth-of-type(1),
18
- &:nth-of-type(2) {
19
- display: none;
20
- } /* Both logos hidden */
21
- }
22
-
23
- @media (min-width: 245px) and (max-width: 400px) {
24
- &:nth-of-type(1) {
25
- display: flex;
26
- } /* logoWithText */
27
- &:nth-of-type(2) {
28
- display: none;
29
- } /* logoWithoutText */
30
- }
31
-
32
- @media (min-width: 401px) {
33
- &:nth-of-type(1) {
34
- display: none;
35
- } /* logoWithText */
36
- &:nth-of-type(2) {
37
- display: flex;
38
- } /* logoWithoutText */
39
- }
40
- `;
12
+ const Logo = require("../web-components/dist/Logo.cjs");
41
13
  const Procaptcha = (props) => {
42
- const [checked, setChecked] = react$1.useState(false);
43
- const [loading, setLoading] = react$1.useState(false);
44
- const darkMode = props.config.theme;
45
- const styleWidth = { maxWidth: "400px", minWidth: "200px", margin: "8px" };
46
- const themeColor = darkMode ? "light" : "dark";
47
- const theme$1 = react$1.useMemo(() => darkMode === "light" ? theme.lightTheme : theme.darkTheme, [darkMode]);
48
- const handlePowCaptcha = async () => {
49
- setLoading(true);
50
- Manager.Manager(props.config).then((verified) => {
51
- if (verified.verified) {
52
- console.log("verified");
53
- setChecked(true);
54
- }
55
- setLoading(false);
56
- });
57
- };
58
- return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styleWidth, "data-cy": "button-human", children: [
14
+ const config = props.config;
15
+ const themeColor = config.theme === "light" ? "light" : "dark";
16
+ const theme$1 = props.config.theme === "light" ? theme.lightTheme : theme.darkTheme;
17
+ const callbacks = props.callbacks || {};
18
+ const [state, _updateState] = procaptchaCommon.useProcaptcha(react.useState, react.useRef);
19
+ const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
20
+ const manager = Manager.Manager(config, state, updateState, callbacks);
21
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(Containers.ContainerDiv, { children: /* @__PURE__ */ jsxRuntime.jsx(Containers.WidthBasedStylesDiv, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: WidgetConstants.WIDGET_DIMENSIONS, "data-cy": "button-human", children: [
59
22
  " ",
60
23
  /* @__PURE__ */ jsxRuntime.jsxs(
61
24
  "div",
62
25
  {
63
26
  style: {
64
- padding: "8px",
27
+ padding: "2px",
65
28
  border: "1px solid",
66
29
  backgroundColor: theme$1.palette.background.default,
67
30
  borderColor: theme$1.palette.grey[300],
68
- borderRadius: "8px",
31
+ borderRadius: "4px",
69
32
  display: "flex",
70
- justifyContent: "space-between",
71
33
  alignItems: "center",
72
- flexWrap: "wrap"
34
+ flexWrap: "wrap",
35
+ justifyContent: "space-between",
36
+ minHeight: `${WidgetConstants.WIDGET_INNER_HEIGHT}px`,
37
+ overflow: "hidden"
73
38
  },
74
39
  children: [
75
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
40
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: /* @__PURE__ */ jsxRuntime.jsx(
76
41
  "div",
77
42
  {
78
43
  style: {
@@ -81,76 +46,41 @@ const Procaptcha = (props) => {
81
46
  alignItems: "center",
82
47
  flexWrap: "wrap"
83
48
  },
84
- children: [
85
- /* @__PURE__ */ jsxRuntime.jsx(
86
- "div",
87
- {
88
- style: {
89
- height: "50px",
90
- width: "50px",
91
- display: "flex",
92
- alignItems: "center",
93
- justifyContent: "center",
94
- flexDirection: "column",
95
- verticalAlign: "middle"
96
- },
97
- children: /* @__PURE__ */ jsxRuntime.jsx(
98
- "div",
99
- {
100
- style: {
101
- display: "flex"
102
- },
103
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: loading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner.LoadingSpinner, { themeColor }) : /* @__PURE__ */ jsxRuntime.jsx(
104
- Checkbox.Checkbox,
105
- {
106
- checked,
107
- onChange: handlePowCaptcha,
108
- themeColor: props.config.theme || "light"
109
- }
110
- ) })
111
- }
112
- )
113
- }
114
- ),
115
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: theme$1.palette.background.contrastText, paddingLeft: "4px" }, children: "I am a human" }) })
116
- ]
117
- }
118
- ) }),
119
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
120
- "a",
121
- {
122
- href: "https://www.prosopo.io/#features?ref=accounts.prosopo.io&utm_campaign=widget&utm_medium=checkbox",
123
- target: "_blank",
124
- "aria-label": "Visit prosopo.io to learn more about the service and its accessibility options.",
125
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
126
- /* @__PURE__ */ jsxRuntime.jsx(
127
- "div",
128
- {
129
- css: logoStyle,
130
- dangerouslySetInnerHTML: {
131
- __html: darkMode === "light" ? logoWithoutTextBlack : logoWithoutTextWhite
49
+ children: /* @__PURE__ */ jsxRuntime.jsx(
50
+ "div",
51
+ {
52
+ style: {
53
+ display: "flex",
54
+ alignItems: "center",
55
+ justifyContent: "center",
56
+ flexDirection: "column",
57
+ verticalAlign: "middle"
58
+ },
59
+ children: /* @__PURE__ */ jsxRuntime.jsx(
60
+ "div",
61
+ {
62
+ style: {
63
+ display: "flex"
64
+ },
65
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: state.loading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner.LoadingSpinner, { themeColor }) : /* @__PURE__ */ jsxRuntime.jsx(
66
+ Checkbox.Checkbox,
67
+ {
68
+ checked: state.isHuman,
69
+ onChange: manager.start,
70
+ themeColor,
71
+ labelText: "I am human"
72
+ }
73
+ ) })
132
74
  }
133
- }
134
- ),
135
- /* @__PURE__ */ jsxRuntime.jsx(
136
- "div",
137
- {
138
- css: logoStyle,
139
- dangerouslySetInnerHTML: {
140
- __html: darkMode === "light" ? logoWithTextBlack : logoWithTextWhite
141
- }
142
- }
143
- )
144
- ] }) })
75
+ )
76
+ }
77
+ )
145
78
  }
146
- ) })
79
+ ) }),
80
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: WidgetConstants.WIDGET_URL, target: "_blank", "aria-label": WidgetConstants.WIDGET_URL_TEXT, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(Logo, { themeColor }) }) }) })
147
81
  ]
148
82
  }
149
83
  )
150
- ] }) }) });
84
+ ] }) }) }) }) });
151
85
  };
152
- const logoWithTextBlack = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2062.63 468.67" height="35px" width="140px"><defs><style>.cls-1{fill:#1d1d1b;}</style></defs><title>Prosopo Logo Black</title><path class="cls-1" d="M335.55,1825.19A147.75,147.75,0,0,1,483.3,1972.94h50.5c0-109.49-88.76-198.25-198.25-198.25v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M269.36,1891.39A147.74,147.74,0,0,1,417.1,2039.13h50.5c0-109.49-88.75-198.24-198.24-198.24v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M414,2157.17a147.75,147.75,0,0,1-147.74-147.74h-50.5c0,109.49,88.75,198.24,198.24,198.24v-50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M480.17,2091a147.74,147.74,0,0,1-147.74-147.75H281.92c0,109.49,88.76,198.25,198.25,198.25V2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M862.8,2017.5q-27.39,22.86-78.25,22.86h-65v112.19H654.82v-312h134q46.32,0,73.86,24.13t27.55,74.72Q890.2,1994.64,862.8,2017.5ZM813,1905.1q-12.37-10.36-34.7-10.38H719.59v91.87h58.75q22.32,0,34.7-11.22t12.39-35.56Q825.43,1915.48,813,1905.1Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1045.69,1916.42c.78.08,2.51.19,5.19.32v61.81c-3.81-.42-7.2-.71-10.16-.85s-5.36-.21-7.2-.21q-36.4,0-48.89,23.71-7,13.33-7,41.06v110.29H916.89V1921.82h57.58V1962q14-23.07,24.34-31.54,16.94-14.18,44-14.18C1044,1916.32,1044.92,1916.35,1045.69,1916.42Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1265.64,2124.32q-29.21,36.06-88.69,36.06t-88.69-36.06Q1059,2088.26,1059,2037.5q0-49.9,29.22-86.5t88.69-36.59q59.47,0,88.69,36.59t29.21,86.5Q1294.85,2088.26,1265.64,2124.32ZM1217.38,2091q14.17-18.81,14.18-53.48t-14.18-53.37q-14.19-18.7-40.64-18.71T1136,1984.13q-14.29,18.72-14.29,53.37T1136,2091q14.28,18.81,40.75,18.81T1217.38,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1371.81,2078.88q1.92,16.1,8.29,22.87,11.28,12.06,41.7,12.06,17.85,0,28.39-5.29t10.53-15.88a17.12,17.12,0,0,0-8.48-15.45q-8.49-5.28-63.12-18.2-39.33-9.73-55.41-24.35-16.08-14.39-16.09-41.49,0-32,25.14-54.93t70.75-23q43.26,0,70.53,17.25t31.29,59.59H1455q-1.27-11.64-6.58-18.42-10-12.27-34-12.28-19.74,0-28.13,6.14t-8.38,14.4c0,6.91,3,11.93,8.92,15q8.89,4.89,63,16.73,36,8.46,54.05,25.61,17.77,17.35,17.78,43.39,0,34.3-25.56,56t-79,21.7q-54.51,0-80.49-23t-26-58.53Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1745.54,2124.32q-29.22,36.06-88.7,36.06t-88.69-36.06q-29.2-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.7,36.59t29.21,86.5Q1774.75,2088.26,1745.54,2124.32ZM1697.27,2091q14.19-18.81,14.19-53.48t-14.19-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.28,53.37t14.28,53.48q14.3,18.81,40.75,18.81T1697.27,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1992.75,1946.59q28.24,29.84,28.23,87.63,0,61-27.58,92.93t-71.06,32q-27.69,0-46-13.76-10-7.62-19.6-22.23v120.24H1797V1921.82h57.79v34.08q9.79-15,20.88-23.71,20.23-15.43,48.15-15.45Q1964.53,1916.74,1992.75,1946.59Zm-46.3,43.39q-12.3-20.52-39.88-20.53-33.15,0-45.54,31.11-6.43,16.51-6.42,41.92,0,40.21,21.58,56.51,12.82,9.53,30.37,9.53,25.45,0,38.83-19.48t13.36-51.86Q1958.75,2010.51,1946.45,1990Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M2249.14,2124.32q-29.2,36.06-88.69,36.06t-88.69-36.06q-29.22-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.69,36.59t29.22,86.5Q2278.36,2088.26,2249.14,2124.32ZM2200.88,2091q14.19-18.81,14.18-53.48t-14.18-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.29,53.37t14.29,53.48q14.3,18.81,40.75,18.81T2200.88,2091Z" transform="translate(-215.73 -1774.69)"/></svg>';
153
- const logoWithTextWhite = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2062.63 468.67" height="35px" width="140px"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Prosopo Logo Black</title><path class="cls-1" d="M335.55,1825.19A147.75,147.75,0,0,1,483.3,1972.94h50.5c0-109.49-88.76-198.25-198.25-198.25v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M269.36,1891.39A147.74,147.74,0,0,1,417.1,2039.13h50.5c0-109.49-88.75-198.24-198.24-198.24v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M414,2157.17a147.75,147.75,0,0,1-147.74-147.74h-50.5c0,109.49,88.75,198.24,198.24,198.24v-50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M480.17,2091a147.74,147.74,0,0,1-147.74-147.75H281.92c0,109.49,88.76,198.25,198.25,198.25V2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M862.8,2017.5q-27.39,22.86-78.25,22.86h-65v112.19H654.82v-312h134q46.32,0,73.86,24.13t27.55,74.72Q890.2,1994.64,862.8,2017.5ZM813,1905.1q-12.37-10.36-34.7-10.38H719.59v91.87h58.75q22.32,0,34.7-11.22t12.39-35.56Q825.43,1915.48,813,1905.1Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1045.69,1916.42c.78.08,2.51.19,5.19.32v61.81c-3.81-.42-7.2-.71-10.16-.85s-5.36-.21-7.2-.21q-36.4,0-48.89,23.71-7,13.33-7,41.06v110.29H916.89V1921.82h57.58V1962q14-23.07,24.34-31.54,16.94-14.18,44-14.18C1044,1916.32,1044.92,1916.35,1045.69,1916.42Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1265.64,2124.32q-29.21,36.06-88.69,36.06t-88.69-36.06Q1059,2088.26,1059,2037.5q0-49.9,29.22-86.5t88.69-36.59q59.47,0,88.69,36.59t29.21,86.5Q1294.85,2088.26,1265.64,2124.32ZM1217.38,2091q14.17-18.81,14.18-53.48t-14.18-53.37q-14.19-18.7-40.64-18.71T1136,1984.13q-14.29,18.72-14.29,53.37T1136,2091q14.28,18.81,40.75,18.81T1217.38,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1371.81,2078.88q1.92,16.1,8.29,22.87,11.28,12.06,41.7,12.06,17.85,0,28.39-5.29t10.53-15.88a17.12,17.12,0,0,0-8.48-15.45q-8.49-5.28-63.12-18.2-39.33-9.73-55.41-24.35-16.08-14.39-16.09-41.49,0-32,25.14-54.93t70.75-23q43.26,0,70.53,17.25t31.29,59.59H1455q-1.27-11.64-6.58-18.42-10-12.27-34-12.28-19.74,0-28.13,6.14t-8.38,14.4c0,6.91,3,11.93,8.92,15q8.89,4.89,63,16.73,36,8.46,54.05,25.61,17.77,17.35,17.78,43.39,0,34.3-25.56,56t-79,21.7q-54.51,0-80.49-23t-26-58.53Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1745.54,2124.32q-29.22,36.06-88.7,36.06t-88.69-36.06q-29.2-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.7,36.59t29.21,86.5Q1774.75,2088.26,1745.54,2124.32ZM1697.27,2091q14.19-18.81,14.19-53.48t-14.19-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.28,53.37t14.28,53.48q14.3,18.81,40.75,18.81T1697.27,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1992.75,1946.59q28.24,29.84,28.23,87.63,0,61-27.58,92.93t-71.06,32q-27.69,0-46-13.76-10-7.62-19.6-22.23v120.24H1797V1921.82h57.79v34.08q9.79-15,20.88-23.71,20.23-15.43,48.15-15.45Q1964.53,1916.74,1992.75,1946.59Zm-46.3,43.39q-12.3-20.52-39.88-20.53-33.15,0-45.54,31.11-6.43,16.51-6.42,41.92,0,40.21,21.58,56.51,12.82,9.53,30.37,9.53,25.45,0,38.83-19.48t13.36-51.86Q1958.75,2010.51,1946.45,1990Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M2249.14,2124.32q-29.2,36.06-88.69,36.06t-88.69-36.06q-29.22-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.69,36.59t29.22,86.5Q2278.36,2088.26,2249.14,2124.32ZM2200.88,2091q14.19-18.81,14.18-53.48t-14.18-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.29,53.37t14.29,53.48q14.3,18.81,40.75,18.81T2200.88,2091Z" transform="translate(-215.73 -1774.69)"/></svg>';
154
- const logoWithoutTextWhite = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 348" height="35px"><path id="Vector" d="M95.7053 40.2707C127.005 40.2707 157.022 52.6841 179.154 74.78C201.286 96.8759 213.719 126.844 213.719 158.093H254.056C254.056 70.7808 183.16 -4.57764e-05 95.7053 -4.57764e-05V40.2707Z" fill="#fff"/><path id="Vector_2" d="M42.8365 93.0614C58.3333 93.0614 73.6784 96.1087 87.9955 102.029C102.313 107.95 115.322 116.628 126.279 127.568C137.237 138.508 145.93 151.496 151.86 165.79C157.79 180.084 160.843 195.404 160.843 210.875H201.179C201.179 123.564 130.291 52.7906 42.8365 52.7906V93.0614Z" fill="#fff"/><path id="Vector_3" d="M158.367 305.005C127.07 305.003 97.056 292.59 74.926 270.496C52.796 248.402 40.3626 218.437 40.3604 187.191H0.0239563C0.0239563 274.503 70.9123 345.276 158.367 345.276V305.005Z" fill="#fff"/><path id="Vector_4" d="M211.219 252.239C195.722 252.239 180.376 249.191 166.059 243.27C151.741 237.349 138.732 228.67 127.774 217.729C116.816 206.788 108.123 193.799 102.194 179.505C96.2637 165.21 93.2121 149.889 93.2132 134.417H52.8687C52.8687 221.729 123.765 292.509 211.219 292.509V252.239Z" fill="#fff"/></g><defs><clipPath id="clip0_1_2"><rect width="254" height="345" fill="white"/></clipPath></defs></svg>';
155
- const logoWithoutTextBlack = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 348" height="35px"><path id="Vector" d="M95.7053 40.2707C127.005 40.2707 157.022 52.6841 179.154 74.78C201.286 96.8759 213.719 126.844 213.719 158.093H254.056C254.056 70.7808 183.16 -4.57764e-05 95.7053 -4.57764e-05V40.2707Z" fill="#000000"/><path id="Vector_2" d="M42.8365 93.0614C58.3333 93.0614 73.6784 96.1087 87.9955 102.029C102.313 107.95 115.322 116.628 126.279 127.568C137.237 138.508 145.93 151.496 151.86 165.79C157.79 180.084 160.843 195.404 160.843 210.875H201.179C201.179 123.564 130.291 52.7906 42.8365 52.7906V93.0614Z" fill="#000000"/><path id="Vector_3" d="M158.367 305.005C127.07 305.003 97.056 292.59 74.926 270.496C52.796 248.402 40.3626 218.437 40.3604 187.191H0.0239563C0.0239563 274.503 70.9123 345.276 158.367 345.276V305.005Z" fill="#000000"/><path id="Vector_4" d="M211.219 252.239C195.722 252.239 180.376 249.191 166.059 243.27C151.741 237.349 138.732 228.67 127.774 217.729C116.816 206.788 108.123 193.799 102.194 179.505C96.2637 165.21 93.2121 149.889 93.2132 134.417H52.8687C52.8687 221.729 123.765 292.509 211.219 292.509V252.239Z" fill="#000000"/></g><defs><clipPath id="clip0_1_2"><rect width="254" height="345" fill="white"/></clipPath></defs></svg>';
156
86
  module.exports = Procaptcha;