@prosopo/procaptcha 0.1.7 → 0.1.9
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/.eslintrc.js +20 -4
- package/README.md +3 -3
- package/dist/api/AccountCreator.d.ts +19 -0
- package/dist/api/AccountCreator.d.ts.map +1 -0
- package/dist/api/AccountCreator.js +88 -0
- package/dist/api/AccountCreator.js.map +1 -0
- package/dist/api/AsyncFactory.d.ts +7 -0
- package/dist/api/AsyncFactory.d.ts.map +1 -0
- package/dist/api/AsyncFactory.js +30 -0
- package/dist/api/AsyncFactory.js.map +1 -0
- package/dist/api/ExtensionWeb2.d.ts +27 -0
- package/dist/api/ExtensionWeb2.d.ts.map +1 -0
- package/dist/api/ExtensionWeb2.js +106 -0
- package/dist/api/ExtensionWeb2.js.map +1 -0
- package/dist/api/ExtensionWeb3.d.ts +56 -0
- package/dist/api/ExtensionWeb3.d.ts.map +1 -0
- package/dist/api/ExtensionWeb3.js +151 -0
- package/dist/api/ExtensionWeb3.js.map +1 -0
- package/dist/api/HttpClientBase.d.ts +9 -0
- package/dist/api/HttpClientBase.d.ts.map +1 -0
- package/dist/api/HttpClientBase.js +36 -0
- package/dist/api/HttpClientBase.js.map +1 -0
- package/dist/api/ProsopoContract.d.ts +13 -0
- package/dist/api/ProsopoContract.d.ts.map +1 -0
- package/dist/api/ProsopoContract.js +38 -0
- package/dist/api/ProsopoContract.js.map +1 -0
- package/dist/api/ProsopoContractBase.d.ts +32 -0
- package/dist/api/ProsopoContractBase.d.ts.map +1 -0
- package/dist/api/ProsopoContractBase.js +132 -0
- package/dist/api/ProsopoContractBase.js.map +1 -0
- package/dist/api/ProviderApi.d.ts +14 -0
- package/dist/api/ProviderApi.d.ts.map +1 -0
- package/dist/api/ProviderApi.js +53 -0
- package/dist/api/ProviderApi.js.map +1 -0
- package/dist/api/handlers.d.ts +5 -0
- package/dist/api/handlers.d.ts.map +1 -0
- package/dist/api/handlers.js +21 -0
- package/dist/api/handlers.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +26 -0
- package/dist/api/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/ProsopoCaptchaApi.d.ts +21 -0
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaApi.js +120 -0
- package/dist/modules/ProsopoCaptchaApi.js.map +1 -0
- package/dist/modules/ProsopoCaptchaClient.d.ts +26 -0
- package/dist/modules/ProsopoCaptchaClient.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaClient.js +112 -0
- package/dist/modules/ProsopoCaptchaClient.js.map +1 -0
- package/dist/modules/ProsopoCaptchaStateClient.d.ts +18 -0
- package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaStateClient.js +111 -0
- package/dist/modules/ProsopoCaptchaStateClient.js.map +1 -0
- package/dist/modules/canvas.d.ts +2 -0
- package/dist/modules/canvas.d.ts.map +1 -0
- package/dist/modules/canvas.js +286 -0
- package/dist/modules/canvas.js.map +1 -0
- package/dist/modules/client.d.ts +9 -0
- package/dist/modules/client.d.ts.map +1 -0
- package/dist/modules/client.js +40 -0
- package/dist/modules/client.js.map +1 -0
- package/dist/modules/contract.d.ts +7 -0
- package/dist/modules/contract.d.ts.map +1 -0
- package/dist/modules/contract.js +42 -0
- package/dist/modules/contract.js.map +1 -0
- package/dist/modules/extension.d.ts +4 -0
- package/dist/modules/extension.d.ts.map +1 -0
- package/dist/modules/extension.js +31 -0
- package/dist/modules/extension.js.map +1 -0
- package/dist/modules/index.d.ts +8 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +26 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/storage.d.ts +14 -0
- package/dist/modules/storage.d.ts.map +1 -0
- package/dist/modules/storage.js +35 -0
- package/dist/modules/storage.js.map +1 -0
- package/dist/types/api.d.ts +53 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +22 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/client.d.ts +61 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +3 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/contract.d.ts +5 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +3 -0
- package/dist/types/contract.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +9 -6
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ProsopoContractBase from "./ProsopoContractBase";
|
|
2
|
+
import { Signer } from '@polkadot/api/types';
|
|
3
|
+
import { ProsopoDappOperatorIsHumanUserResponse, TransactionResponse } from '../types';
|
|
4
|
+
import { ProsopoRandomProviderResponse } from "../types";
|
|
5
|
+
import { CaptchaSolutionCommitment } from "@prosopo/datasets";
|
|
6
|
+
export declare class ProsopoContract extends ProsopoContractBase {
|
|
7
|
+
getRandomProvider(): Promise<ProsopoRandomProviderResponse>;
|
|
8
|
+
getCaptchaSolutionCommitment(commitmentId: string): Promise<CaptchaSolutionCommitment>;
|
|
9
|
+
dappUserCommit(signer: Signer, captchaDatasetId: string, userMerkleTreeRoot: string, providerAddress: string): Promise<TransactionResponse>;
|
|
10
|
+
dappOperatorIsHumanUser(solutionThreshold: number): Promise<ProsopoDappOperatorIsHumanUserResponse>;
|
|
11
|
+
}
|
|
12
|
+
export default ProsopoContract;
|
|
13
|
+
//# sourceMappingURL=ProsopoContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoContract.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":"AAgBA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,sCAAsC,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,qBAAa,eAAgB,SAAQ,mBAAmB;IAEvC,iBAAiB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAI3D,4BAA4B,CAAC,YAAY,EAAE,MAAM;IAIjD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3I,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,sCAAsC,CAAC;CAOnH;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProsopoContract = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
7
|
+
//
|
|
8
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
//
|
|
13
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
//
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
// import {Hash} from '@polkadot/types/interfaces';
|
|
21
|
+
const ProsopoContractBase_1 = tslib_1.__importDefault(require("./ProsopoContractBase"));
|
|
22
|
+
class ProsopoContract extends ProsopoContractBase_1.default {
|
|
23
|
+
async getRandomProvider() {
|
|
24
|
+
return await this.query('getRandomActiveProvider', [this.account.address, this.dappAddress]);
|
|
25
|
+
}
|
|
26
|
+
async getCaptchaSolutionCommitment(commitmentId) {
|
|
27
|
+
return await this.query('getCaptchaSolutionCommitment', [commitmentId]);
|
|
28
|
+
}
|
|
29
|
+
async dappUserCommit(signer, captchaDatasetId, userMerkleTreeRoot, providerAddress) {
|
|
30
|
+
return await this.transaction(signer, 'dappUserCommit', [this.dappAddress, captchaDatasetId, userMerkleTreeRoot, providerAddress]);
|
|
31
|
+
}
|
|
32
|
+
async dappOperatorIsHumanUser(solutionThreshold) {
|
|
33
|
+
return await this.query('dappOperatorIsHumanUser', [this.account.address, solutionThreshold]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ProsopoContract = ProsopoContract;
|
|
37
|
+
exports.default = ProsopoContract;
|
|
38
|
+
//# sourceMappingURL=ProsopoContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoContract.js","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,mDAAmD;AACnD,wFAAwD;AAMxD,MAAa,eAAgB,SAAQ,6BAAmB;IAE7C,KAAK,CAAC,iBAAiB;QAC1B,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAkC,CAAC;IAClI,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,YAAoB;QAC1D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,8BAA8B,EAAE,CAAC,YAAY,CAAC,CAA8B,CAAC;IACzG,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,gBAAwB,EAAE,kBAA0B,EAAE,eAAuB;QACrH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IACvI,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,iBAAyB;QAE1D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAA2C,CAAC;IAC5I,CAAC;CAIJ;AArBD,0CAqBC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApiPromise } from "@polkadot/api";
|
|
2
|
+
import { Abi, ContractPromise } from "@polkadot/api-contract";
|
|
3
|
+
import { InjectedAccountWithMeta } from "@polkadot/extension-inject/types";
|
|
4
|
+
import { AnyJson } from "@polkadot/types/types/codec";
|
|
5
|
+
import { ProviderInterface } from "@polkadot/rpc-provider/types";
|
|
6
|
+
import { Signer } from "@polkadot/api/types";
|
|
7
|
+
import { TransactionResponse } from '../types';
|
|
8
|
+
import AsyncFactory from "./AsyncFactory";
|
|
9
|
+
export declare class ProsopoContractBase extends AsyncFactory {
|
|
10
|
+
protected api: ApiPromise;
|
|
11
|
+
protected abi: Abi;
|
|
12
|
+
protected contract: ContractPromise;
|
|
13
|
+
protected account: InjectedAccountWithMeta;
|
|
14
|
+
protected dappAddress: string;
|
|
15
|
+
address: string;
|
|
16
|
+
/**
|
|
17
|
+
* @param address
|
|
18
|
+
* @param dappAddress
|
|
19
|
+
* @param account
|
|
20
|
+
* @param providerInterface
|
|
21
|
+
*/
|
|
22
|
+
init(address: string, dappAddress: string, account: InjectedAccountWithMeta, providerInterface: ProviderInterface): Promise<this>;
|
|
23
|
+
getApi(): ApiPromise;
|
|
24
|
+
getContract(): ContractPromise;
|
|
25
|
+
getAccount(): InjectedAccountWithMeta;
|
|
26
|
+
getDappAddress(): string;
|
|
27
|
+
disconnect(): Promise<void>;
|
|
28
|
+
query<T>(method: string, args: any[]): Promise<T | AnyJson | null>;
|
|
29
|
+
transaction(signer: Signer, method: string, args: any[]): Promise<TransactionResponse>;
|
|
30
|
+
}
|
|
31
|
+
export default ProsopoContractBase;
|
|
32
|
+
//# sourceMappingURL=ProsopoContractBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoContractBase.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,YAAY;IAEjD,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC;IACpC,SAAS,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvB,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;KAKC;IACY,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,iBAAiB;IAUvH,MAAM,IAAI,UAAU;IAIpB,WAAW,IAAI,eAAe;IAI9B,UAAU,IAAI,uBAAuB;IAIrC,cAAc,IAAI,MAAM;IAIlB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IA0BlE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAwEtG;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProsopoContractBase = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
7
|
+
//
|
|
8
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
//
|
|
13
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
//
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
const api_1 = require("@polkadot/api");
|
|
21
|
+
const api_contract_1 = require("@polkadot/api-contract");
|
|
22
|
+
const contract_1 = require("@prosopo/contract");
|
|
23
|
+
const AsyncFactory_1 = tslib_1.__importDefault(require("./AsyncFactory"));
|
|
24
|
+
class ProsopoContractBase extends AsyncFactory_1.default {
|
|
25
|
+
api;
|
|
26
|
+
abi;
|
|
27
|
+
contract;
|
|
28
|
+
account;
|
|
29
|
+
dappAddress;
|
|
30
|
+
address;
|
|
31
|
+
/**
|
|
32
|
+
* @param address
|
|
33
|
+
* @param dappAddress
|
|
34
|
+
* @param account
|
|
35
|
+
* @param providerInterface
|
|
36
|
+
*/
|
|
37
|
+
async init(address, dappAddress, account, providerInterface) {
|
|
38
|
+
this.api = await api_1.ApiPromise.create({ provider: providerInterface });
|
|
39
|
+
this.abi = new api_contract_1.Abi(contract_1.abiJson, this.api.registry.getChainProperties());
|
|
40
|
+
this.contract = new api_contract_1.ContractPromise(this.api, this.abi, address);
|
|
41
|
+
this.address = address;
|
|
42
|
+
this.dappAddress = dappAddress;
|
|
43
|
+
this.account = account;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
getApi() {
|
|
47
|
+
return this.api;
|
|
48
|
+
}
|
|
49
|
+
getContract() {
|
|
50
|
+
return this.contract;
|
|
51
|
+
}
|
|
52
|
+
getAccount() {
|
|
53
|
+
return this.account;
|
|
54
|
+
}
|
|
55
|
+
getDappAddress() {
|
|
56
|
+
return this.dappAddress;
|
|
57
|
+
}
|
|
58
|
+
async disconnect() {
|
|
59
|
+
await this.api.disconnect();
|
|
60
|
+
}
|
|
61
|
+
async query(method, args) {
|
|
62
|
+
try {
|
|
63
|
+
const abiMessage = this.abi.findMessage(method);
|
|
64
|
+
const response = await this.contract.query[method](this.account.address, {}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
65
|
+
console.log("QUERY RESPONSE", method, args, response);
|
|
66
|
+
if (response.result.isOk) {
|
|
67
|
+
if (response.output) {
|
|
68
|
+
return (0, contract_1.unwrap)(response.output.toHuman());
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new contract_1.ProsopoContractError(response.result.asErr);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
console.error("ERROR", e);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// https://polkadot.js.org/docs/api/cookbook/tx/
|
|
84
|
+
// https://polkadot.js.org/docs/api/start/api.tx.subs/
|
|
85
|
+
async transaction(signer, method, args) {
|
|
86
|
+
const queryBeforeTx = await this.query(method, args);
|
|
87
|
+
console.log("QUERY BEFORE TX....................", queryBeforeTx);
|
|
88
|
+
const abiMessage = this.abi.findMessage(method);
|
|
89
|
+
const extrinsic = this.contract.tx[method]({}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
90
|
+
// this.api.setSigner(signer);
|
|
91
|
+
// const response = await buildTx(this.api.registry, extrinsic, this.account.address, { signer });
|
|
92
|
+
// console.log("buildTx RESPONSE", response);
|
|
93
|
+
// return;
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
extrinsic.signAndSend(this.account.address, { signer }, (result) => {
|
|
96
|
+
const { dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex } = result;
|
|
97
|
+
console.log("TX STATUS", status.type);
|
|
98
|
+
console.log("IS FINALIZED", status?.isFinalized);
|
|
99
|
+
console.log("IN BLOCK", status?.isInBlock);
|
|
100
|
+
console.log("EVENTS", events);
|
|
101
|
+
if (internalError) {
|
|
102
|
+
console.error("internalError", internalError);
|
|
103
|
+
reject(internalError);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (dispatchError) {
|
|
107
|
+
console.error("dispatchError", dispatchError);
|
|
108
|
+
reject(dispatchError);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// [Ready, InBlock, Finalized...]
|
|
112
|
+
// Instant seal ON.
|
|
113
|
+
if (status?.isInBlock) {
|
|
114
|
+
const blockHash = status.asInBlock.toHex();
|
|
115
|
+
resolve({ dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex, blockHash });
|
|
116
|
+
}
|
|
117
|
+
// Instant seal OFF.
|
|
118
|
+
// if (status?.isFinalized) {
|
|
119
|
+
// const blockHash = status.asFinalized.toHex();
|
|
120
|
+
// resolve({ dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex, blockHash });
|
|
121
|
+
// }
|
|
122
|
+
})
|
|
123
|
+
.catch((e) => {
|
|
124
|
+
console.error("signAndSend ERROR", e);
|
|
125
|
+
reject(e);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.ProsopoContractBase = ProsopoContractBase;
|
|
131
|
+
exports.default = ProsopoContractBase;
|
|
132
|
+
//# sourceMappingURL=ProsopoContractBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoContractBase.js","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,uCAA8D;AAC9D,yDAA8D;AAG9D,gDAA4F;AAK5F,0EAA0C;AAE1C,MAAa,mBAAoB,SAAQ,sBAAY;IAEvC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ACG,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;gBACtC,MAAM,CAAC,CAAC,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;QAEX,CAAC,CAAC,CAAC;IAEP,CAAC;CAEJ;AAjJD,kDAiJC;AAED,kBAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import HttpClientBase from "./HttpClientBase";
|
|
2
|
+
import { CaptchaSolutionResponse, GetCaptchaResponse, ProsopoCaptchaConfig, ProsopoRandomProviderResponse } from '../types';
|
|
3
|
+
import { CaptchaSolution } from "@prosopo/datasets";
|
|
4
|
+
export declare class ProviderApi extends HttpClientBase {
|
|
5
|
+
private config;
|
|
6
|
+
constructor(config: ProsopoCaptchaConfig);
|
|
7
|
+
getProviders(): Promise<{
|
|
8
|
+
accounts: string[];
|
|
9
|
+
}>;
|
|
10
|
+
getCaptchaChallenge(randomProvider: ProsopoRandomProviderResponse): Promise<GetCaptchaResponse>;
|
|
11
|
+
submitCaptchaSolution(captchas: CaptchaSolution[], requestHash: string, userAccount: string, salt: string, blockHash?: string, txHash?: string, web2?: boolean): Promise<CaptchaSolutionResponse>;
|
|
12
|
+
}
|
|
13
|
+
export default ProviderApi;
|
|
14
|
+
//# sourceMappingURL=ProviderApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderApi.d.ts","sourceRoot":"","sources":["../../src/api/ProviderApi.ts"],"names":[],"mappings":"AAeA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAChC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,WAAY,SAAQ,cAAc;IAE3C,OAAO,CAAC,MAAM,CAAuB;gBAEzB,MAAM,EAAE,oBAAoB;IAKjC,YAAY,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAI/C,mBAAmB,CAAC,cAAc,EAAE,6BAA6B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQ/F,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAa3M;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderApi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
7
|
+
//
|
|
8
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
//
|
|
13
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
//
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
const HttpClientBase_1 = tslib_1.__importDefault(require("./HttpClientBase"));
|
|
21
|
+
const storage_1 = tslib_1.__importDefault(require("../modules/storage"));
|
|
22
|
+
class ProviderApi extends HttpClientBase_1.default {
|
|
23
|
+
config;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
super(config['providerApi.baseURL'], config['providerApi.prefix']);
|
|
26
|
+
this.config = config;
|
|
27
|
+
}
|
|
28
|
+
getProviders() {
|
|
29
|
+
return this.axios.get(`/providers`);
|
|
30
|
+
}
|
|
31
|
+
getCaptchaChallenge(randomProvider) {
|
|
32
|
+
const { provider } = randomProvider;
|
|
33
|
+
let { blockNumber } = randomProvider;
|
|
34
|
+
blockNumber = blockNumber.replace(/,/g, '');
|
|
35
|
+
const userAccount = storage_1.default.getAccount();
|
|
36
|
+
return this.axios.get(`/provider/captcha/${provider.datasetId}/${userAccount}/${this.config['dappAccount']}/${blockNumber}`);
|
|
37
|
+
}
|
|
38
|
+
submitCaptchaSolution(captchas, requestHash, userAccount, salt, blockHash, txHash, web2) {
|
|
39
|
+
return this.axios.post(`/provider/solution`, {
|
|
40
|
+
blockHash,
|
|
41
|
+
captchas,
|
|
42
|
+
requestHash,
|
|
43
|
+
txHash,
|
|
44
|
+
userAccount,
|
|
45
|
+
dappAccount: this.config['dappAccount'],
|
|
46
|
+
web2,
|
|
47
|
+
salt
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ProviderApi = ProviderApi;
|
|
52
|
+
exports.default = ProviderApi;
|
|
53
|
+
//# sourceMappingURL=ProviderApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderApi.js","sourceRoot":"","sources":["../../src/api/ProviderApi.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,8EAA8C;AAC9C,y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AAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAGpC,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;CAevE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProsopoApiError = void 0;
|
|
4
|
+
class ProsopoApiError extends Error {
|
|
5
|
+
constructor(error, context, ...params) {
|
|
6
|
+
if ("data" in error) {
|
|
7
|
+
super(error.data.message);
|
|
8
|
+
}
|
|
9
|
+
else if ("statusText" in error) {
|
|
10
|
+
super(error.statusText);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
super(error.toString());
|
|
14
|
+
}
|
|
15
|
+
this.name = context && `${ProsopoApiError.name}@${context}` || ProsopoApiError.name;
|
|
16
|
+
console.error('\n********************* ERROR *********************\n');
|
|
17
|
+
console.error(this.cause, this.stack, ...params);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ProsopoApiError = ProsopoApiError;
|
|
21
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/api/handlers.ts"],"names":[],"mappings":";;;AAkBA,MAAa,eAAgB,SAAQ,KAAK;IACtC,YAAY,KAAoB,EAAE,OAAgB,EAAE,GAAG,MAAa;QAChE,IAAG,MAAM,IAAI,KAAK,EAAE;YAChB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SAC5B;aAAM,IAAI,YAAY,IAAI,KAAK,EAAE;YAC9B,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;SAC1B;aAAM;YACH,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;SAC1B;QAED,IAAI,CAAC,IAAI,GAAG,OAAO,IAAI,GAAG,eAAe,CAAC,IAAI,IAAI,OAAO,EAAE,IAAI,eAAe,CAAC,IAAI,CAAC;QAGpF,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,CAAC;IACrD,CAAC;CACJ;AAhBD,0CAgBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './AsyncFactory';
|
|
2
|
+
export * from './ExtensionWeb3';
|
|
3
|
+
export * from './ExtensionWeb2';
|
|
4
|
+
export * from './HttpClientBase';
|
|
5
|
+
export * from './ProsopoContract';
|
|
6
|
+
export * from './ProsopoContractBase';
|
|
7
|
+
export * from './ProviderApi';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAeA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
6
|
+
//
|
|
7
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
8
|
+
// it under the terms of the GNU General Public License as published by
|
|
9
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
// (at your option) any later version.
|
|
11
|
+
//
|
|
12
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
13
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
// GNU General Public License for more details.
|
|
16
|
+
//
|
|
17
|
+
// You should have received a copy of the GNU General Public License
|
|
18
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+
tslib_1.__exportStar(require("./AsyncFactory"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./ExtensionWeb3"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./ExtensionWeb2"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./HttpClientBase"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./ProsopoContract"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./ProsopoContractBase"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./ProviderApi"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,2DAAiC;AACjC,4DAAkC;AAClC,gEAAsC;AACtC,wDAA8B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
6
|
+
//
|
|
7
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
8
|
+
// it under the terms of the GNU General Public License as published by
|
|
9
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
// (at your option) any later version.
|
|
11
|
+
//
|
|
12
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
13
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
// GNU General Public License for more details.
|
|
16
|
+
//
|
|
17
|
+
// You should have received a copy of the GNU General Public License
|
|
18
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+
tslib_1.__exportStar(require("./api"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./modules"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,gDAAsB;AACtB,oDAA0B;AAC1B,kDAAwB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CaptchaSolution } from "@prosopo/datasets";
|
|
2
|
+
import { Signer } from "@polkadot/api/types";
|
|
3
|
+
import { GetCaptchaResponse, ProsopoRandomProviderResponse } from "../types/api";
|
|
4
|
+
import ProviderApi from "../api/ProviderApi";
|
|
5
|
+
import ProsopoContract from "../api/ProsopoContract";
|
|
6
|
+
import { TCaptchaSubmitResult } from '../types/client';
|
|
7
|
+
export declare type SubmitFunction = typeof ProsopoCaptchaApi.prototype.submitCaptchaSolutionWeb3 | typeof ProsopoCaptchaApi.prototype.submitCaptchaSolutionWeb2;
|
|
8
|
+
export declare class ProsopoCaptchaApi {
|
|
9
|
+
protected contract: ProsopoContract;
|
|
10
|
+
protected provider: ProsopoRandomProviderResponse;
|
|
11
|
+
protected providerApi: ProviderApi;
|
|
12
|
+
protected submitCaptchaFn: SubmitFunction;
|
|
13
|
+
constructor(contract: ProsopoContract, provider: ProsopoRandomProviderResponse, providerApi: ProviderApi, web2: boolean);
|
|
14
|
+
getCaptchaChallenge(): Promise<GetCaptchaResponse>;
|
|
15
|
+
verifyCaptchaChallengeContent(provider: ProsopoRandomProviderResponse, captchaChallenge: GetCaptchaResponse): void;
|
|
16
|
+
submitCaptchaSolution(signer: Signer, requestHash: string, datasetId: string, solutions: CaptchaSolution[]): Promise<TCaptchaSubmitResult>;
|
|
17
|
+
submitCaptchaSolutionWeb2(signer: Signer, requestHash: string, datasetId: string, solutions: CaptchaSolution[]): Promise<TCaptchaSubmitResult>;
|
|
18
|
+
submitCaptchaSolutionWeb3(signer: Signer, requestHash: string, datasetId: string, solutions: CaptchaSolution[]): Promise<TCaptchaSubmitResult>;
|
|
19
|
+
}
|
|
20
|
+
export default ProsopoCaptchaApi;
|
|
21
|
+
//# sourceMappingURL=ProsopoCaptchaApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoCaptchaApi.d.ts","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaApi.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEH,eAAe,EAElB,MAAM,mBAAmB,CAAC;AAC3B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O,CAAC,oBAAoB,CAAC;CA+C/J;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProsopoCaptchaApi = void 0;
|
|
4
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
6
|
+
//
|
|
7
|
+
// procaptcha is free software: you can redistribute it and/or modify
|
|
8
|
+
// it under the terms of the GNU General Public License as published by
|
|
9
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
// (at your option) any later version.
|
|
11
|
+
//
|
|
12
|
+
// procaptcha is distributed in the hope that it will be useful,
|
|
13
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
// GNU General Public License for more details.
|
|
16
|
+
//
|
|
17
|
+
// You should have received a copy of the GNU General Public License
|
|
18
|
+
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
20
|
+
const datasets_1 = require("@prosopo/datasets");
|
|
21
|
+
const handlers_1 = require("../api/handlers");
|
|
22
|
+
const contract_1 = require("@prosopo/contract");
|
|
23
|
+
const datasets_2 = require("@prosopo/datasets");
|
|
24
|
+
class ProsopoCaptchaApi {
|
|
25
|
+
contract;
|
|
26
|
+
provider;
|
|
27
|
+
providerApi;
|
|
28
|
+
submitCaptchaFn;
|
|
29
|
+
constructor(contract, provider, providerApi, web2) {
|
|
30
|
+
this.contract = contract;
|
|
31
|
+
this.provider = provider;
|
|
32
|
+
this.providerApi = providerApi;
|
|
33
|
+
this.submitCaptchaFn = web2 ? this.submitCaptchaSolutionWeb2 : this.submitCaptchaSolutionWeb3;
|
|
34
|
+
}
|
|
35
|
+
async getCaptchaChallenge() {
|
|
36
|
+
let captchaChallenge;
|
|
37
|
+
try {
|
|
38
|
+
captchaChallenge = await this.providerApi.getCaptchaChallenge(this.provider);
|
|
39
|
+
this.verifyCaptchaChallengeContent(this.provider, captchaChallenge);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw new contract_1.ProsopoEnvError(err);
|
|
43
|
+
}
|
|
44
|
+
return captchaChallenge;
|
|
45
|
+
}
|
|
46
|
+
verifyCaptchaChallengeContent(provider, captchaChallenge) {
|
|
47
|
+
// TODO make sure root is equal to root on the provider
|
|
48
|
+
const proofLength = captchaChallenge.captchas[0].proof.length;
|
|
49
|
+
console.log(provider.provider);
|
|
50
|
+
console.log(provider.provider.datasetIdContent, captchaChallenge.captchas[0].proof[proofLength - 1][0]);
|
|
51
|
+
if (provider.provider.datasetIdContent !== captchaChallenge.captchas[0].proof[proofLength - 1][0]) {
|
|
52
|
+
throw new contract_1.ProsopoEnvError("CAPTCHA.INVALID_DATASET_CONTENT_ID");
|
|
53
|
+
}
|
|
54
|
+
for (const captchaWithProof of captchaChallenge.captchas) {
|
|
55
|
+
if (!(0, datasets_1.verifyProof)(captchaWithProof.captcha.captchaContentId, captchaWithProof.proof)) {
|
|
56
|
+
throw new contract_1.ProsopoEnvError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
console.log("CAPTCHA.CHALLENGE_VERIFIED");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
async submitCaptchaSolution(signer, requestHash, datasetId, solutions) {
|
|
63
|
+
return this.submitCaptchaFn(signer, requestHash, datasetId, solutions);
|
|
64
|
+
}
|
|
65
|
+
async submitCaptchaSolutionWeb2(signer, requestHash, datasetId, solutions) {
|
|
66
|
+
const salt = (0, util_crypto_1.randomAsHex)();
|
|
67
|
+
const captchaSolutionsSalted = solutions.map((captcha) => ({
|
|
68
|
+
...captcha,
|
|
69
|
+
salt,
|
|
70
|
+
}));
|
|
71
|
+
let result;
|
|
72
|
+
try {
|
|
73
|
+
result = await this.providerApi.submitCaptchaSolution(captchaSolutionsSalted, requestHash, this.contract.getAccount().address, salt, undefined, undefined, true);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
throw new handlers_1.ProsopoApiError(err);
|
|
77
|
+
}
|
|
78
|
+
return [result, undefined, undefined];
|
|
79
|
+
}
|
|
80
|
+
async submitCaptchaSolutionWeb3(signer, requestHash, datasetId, solutions) {
|
|
81
|
+
const salt = (0, util_crypto_1.randomAsHex)();
|
|
82
|
+
const tree = new datasets_1.CaptchaMerkleTree();
|
|
83
|
+
const captchaSolutionsSalted = solutions.map((captcha) => ({
|
|
84
|
+
...captcha,
|
|
85
|
+
salt,
|
|
86
|
+
}));
|
|
87
|
+
const captchasHashed = captchaSolutionsSalted.map((captcha) => (0, datasets_2.computeCaptchaSolutionHash)(captcha));
|
|
88
|
+
tree.build(captchasHashed);
|
|
89
|
+
const commitmentId = tree.root.hash;
|
|
90
|
+
console.log("solveCaptchaChallenge commitmentId", commitmentId);
|
|
91
|
+
// console.log("solveCaptchaChallenge USER ACCOUNT", this.contract.getAccount().address);
|
|
92
|
+
// console.log("solveCaptchaChallenge DAPP ACCOUNT", this.contract.getDappAddress());
|
|
93
|
+
// console.log("solveCaptchaChallenge CONTRACT ADDRESS", this.contract.getContract().address.toString());
|
|
94
|
+
let tx;
|
|
95
|
+
try {
|
|
96
|
+
tx = await this.contract.dappUserCommit(signer, datasetId, commitmentId, this.provider.providerId);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
throw new contract_1.ProsopoEnvError(err);
|
|
100
|
+
}
|
|
101
|
+
let result;
|
|
102
|
+
try {
|
|
103
|
+
result = await this.providerApi.submitCaptchaSolution(captchaSolutionsSalted, requestHash, this.contract.getAccount().address, salt, tx.blockHash, tx.txHash.toString());
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
throw new handlers_1.ProsopoApiError(err);
|
|
107
|
+
}
|
|
108
|
+
let commitment;
|
|
109
|
+
try {
|
|
110
|
+
commitment = await this.contract.getCaptchaSolutionCommitment(commitmentId);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
throw new contract_1.ProsopoEnvError(err);
|
|
114
|
+
}
|
|
115
|
+
return [result, tx, commitment];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.ProsopoCaptchaApi = ProsopoCaptchaApi;
|
|
119
|
+
exports.default = ProsopoCaptchaApi;
|
|
120
|
+
//# sourceMappingURL=ProsopoCaptchaApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoCaptchaApi.js","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaApi.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,uDAAoD;AACpD,gDAI2B;AAS3B,8CAAgD;AAChD,gDAAkD;AAClD,gDAA6D;AAO7D,MAAa,iBAAiB;IAEhB,QAAQ,CAAkB;IAC1B,QAAQ,CAAgC;IACxC,WAAW,CAAc;IACzB,eAAe,CAAgB;IAEzC,YAAY,QAAyB,EAAE,QAAuC,EAAE,WAAwB,EAAE,IAAa;QACnH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC;IAClG,CAAC;IAEM,KAAK,CAAC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AAiB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CaptchaEventCallbacks, ICaptchaContextReducer, ICaptchaStatusReducer, IExtensionInterface, TExtensionAccount } from "../types/client";
|
|
2
|
+
import { ProsopoRandomProviderResponse } from "../types/api";
|
|
3
|
+
import { ProsopoContract } from "../api/ProsopoContract";
|
|
4
|
+
import { ProviderApi } from "../api/ProviderApi";
|
|
5
|
+
import { ProsopoCaptchaApi } from "./ProsopoCaptchaApi";
|
|
6
|
+
export declare class ProsopoCaptchaClient {
|
|
7
|
+
manager: ICaptchaContextReducer;
|
|
8
|
+
status: ICaptchaStatusReducer;
|
|
9
|
+
callbacks: CaptchaEventCallbacks | undefined;
|
|
10
|
+
providerApi: ProviderApi;
|
|
11
|
+
private static extension;
|
|
12
|
+
private static contract;
|
|
13
|
+
private static provider;
|
|
14
|
+
private static captchaApi;
|
|
15
|
+
constructor(manager: ICaptchaContextReducer, status: ICaptchaStatusReducer, callbacks?: CaptchaEventCallbacks);
|
|
16
|
+
getExtension(): IExtensionInterface;
|
|
17
|
+
setExtension(extension: IExtensionInterface): void;
|
|
18
|
+
getContract(): ProsopoContract | undefined;
|
|
19
|
+
getProvider(): ProsopoRandomProviderResponse | undefined;
|
|
20
|
+
getCaptchaApi(): ProsopoCaptchaApi | undefined;
|
|
21
|
+
onLoad(createAccount?: boolean): Promise<void>;
|
|
22
|
+
onAccountChange(account?: TExtensionAccount): Promise<void>;
|
|
23
|
+
onAccountUnset(): void;
|
|
24
|
+
}
|
|
25
|
+
export default ProsopoCaptchaClient;
|
|
26
|
+
//# sourceMappingURL=ProsopoCaptchaClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProsopoCaptchaClient.d.ts","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaClient.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,6BAA6B,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,oBAAoB;IAEtB,OAAO,EAAE,sBAAsB,CAAC;IAChC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,SAAS,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC7C,WAAW,EAAE,WAAW,CAAC;IAEhC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAsB;IAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IACrD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4C;IACnE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAgC;gBAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,qBAAqB;IAOtG,YAAY;IAIZ,YAAY,CAAC,SAAS,EAAE,mBAAmB;IAI3C,WAAW;IAIX,WAAW;IAIX,aAAa;IAIP,MAAM,CAAC,aAAa,CAAC,EAAE,OAAO;IAsC9B,eAAe,CAAC,OAAO,CAAC,EAAE,iBAAiB;IA2CjD,cAAc;CAYxB;AAED,eAAe,oBAAoB,CAAC"}
|