@prosopo/procaptcha 0.1.10 → 0.1.14
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/README.md +10 -3
- package/assets/contracts-page.png +0 -0
- package/dist/api/Extension.d.ts +3 -2
- package/dist/api/Extension.d.ts.map +1 -1
- package/dist/api/Extension.js.map +1 -1
- package/dist/api/ExtensionWeb2.d.ts +3 -2
- package/dist/api/ExtensionWeb2.d.ts.map +1 -1
- package/dist/api/ExtensionWeb2.js +24 -18
- package/dist/api/ExtensionWeb2.js.map +1 -1
- package/dist/api/ExtensionWeb3.d.ts +3 -2
- package/dist/api/ExtensionWeb3.d.ts.map +1 -1
- package/dist/api/ExtensionWeb3.js +1 -1
- package/dist/api/ExtensionWeb3.js.map +1 -1
- package/dist/api/errors.d.ts +3 -0
- package/dist/api/errors.d.ts.map +1 -1
- package/dist/api/errors.js +7 -1
- package/dist/api/errors.js.map +1 -1
- package/dist/api/handlers.js +1 -1
- package/dist/api/handlers.js.map +1 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -3
- package/dist/api/index.js.map +1 -1
- package/dist/api/sign.d.ts +5 -0
- package/dist/api/sign.d.ts.map +1 -0
- package/dist/api/sign.js +16 -0
- package/dist/api/sign.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/Manager.d.ts +9 -0
- package/dist/modules/Manager.d.ts.map +1 -1
- package/dist/modules/Manager.js +113 -40
- package/dist/modules/Manager.js.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.d.ts +10 -8
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.js +55 -35
- package/dist/modules/ProsopoCaptchaApi.js.map +1 -1
- package/dist/modules/canvas.js +2 -2
- package/dist/modules/canvas.js.map +1 -1
- package/dist/modules/storage.d.ts.map +1 -1
- package/dist/modules/storage.js +15 -0
- package/dist/modules/storage.js.map +1 -1
- package/dist/types/api.d.ts +1 -17
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/client.d.ts +3 -9
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/manager.d.ts +20 -27
- package/dist/types/manager.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +21 -24
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -36
- package/.prettierrc.js +0 -7
- package/LICENSE +0 -201
- package/dist/api/AsyncFactory.d.ts +0 -7
- package/dist/api/AsyncFactory.d.ts.map +0 -1
- package/dist/api/AsyncFactory.js +0 -30
- package/dist/api/AsyncFactory.js.map +0 -1
- package/dist/api/ProsopoContract.d.ts +0 -13
- package/dist/api/ProsopoContract.d.ts.map +0 -1
- package/dist/api/ProsopoContract.js +0 -59
- package/dist/api/ProsopoContract.js.map +0 -1
- package/dist/api/ProsopoContractBase.d.ts +0 -30
- package/dist/api/ProsopoContractBase.d.ts.map +0 -1
- package/dist/api/ProsopoContractBase.js +0 -139
- package/dist/api/ProsopoContractBase.js.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.d.ts +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.js +0 -2
- package/dist/modules/ProsopoCaptchaStateClient.js.map +0 -1
- package/tsconfig.json +0 -27
package/dist/api/AsyncFactory.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncFactory = 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 datasets_1 = require("@prosopo/datasets");
|
|
20
|
-
class AsyncFactory {
|
|
21
|
-
constructor() {
|
|
22
|
-
throw new datasets_1.ProsopoEnvError('GENERAL.ASYNC_FACTORY_CREATE');
|
|
23
|
-
}
|
|
24
|
-
static async create(...args) {
|
|
25
|
-
return await Object.create(this.prototype).init(...args);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.AsyncFactory = AsyncFactory;
|
|
29
|
-
exports.default = AsyncFactory;
|
|
30
|
-
//# sourceMappingURL=AsyncFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncFactory.js","sourceRoot":"","sources":["../../src/api/AsyncFactory.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,gDAAmD;AAEnD,MAAsB,YAAY;IAC9B;QACI,MAAM,IAAI,0BAAe,CAAC,8BAA8B,CAAC,CAAA;IAC7D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAW;QACrC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;IAC5D,CAAC;CAGJ;AAVD,oCAUC;AAED,kBAAe,YAAY,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContract.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":"AAgBA,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,sCAAsC,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,qBAAa,eAAgB,SAAQ,mBAAmB;IACvC,iBAAiB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAQ3D,4BAA4B,CAAC,YAAY,EAAE,MAAM;IAIjD,cAAc,CACvB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,MAAM,GACxB,OAAO,CAAC,mBAAmB,CAAC;IASlB,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,sCAAsC,CAAC;CAcnH;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
console.log('getRandomProvider', this.userAccountAddress, this.dappAddress);
|
|
25
|
-
return (await this.query('getRandomActiveProvider', [
|
|
26
|
-
this.userAccountAddress,
|
|
27
|
-
this.dappAddress,
|
|
28
|
-
]));
|
|
29
|
-
}
|
|
30
|
-
async getCaptchaSolutionCommitment(commitmentId) {
|
|
31
|
-
return (await this.query('getCaptchaSolutionCommitment', [commitmentId]));
|
|
32
|
-
}
|
|
33
|
-
async dappUserCommit(signer, captchaDatasetId, userMerkleTreeRoot, providerAddress) {
|
|
34
|
-
return await this.transaction(signer, 'dappUserCommit', [
|
|
35
|
-
this.dappAddress,
|
|
36
|
-
captchaDatasetId,
|
|
37
|
-
userMerkleTreeRoot,
|
|
38
|
-
providerAddress,
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
async dappOperatorIsHumanUser(solutionThreshold) {
|
|
42
|
-
let response;
|
|
43
|
-
try {
|
|
44
|
-
response = await this.query('dappOperatorIsHumanUser', [this.userAccountAddress, solutionThreshold]);
|
|
45
|
-
// TODO make the contract always return true or false
|
|
46
|
-
if (response !== true) {
|
|
47
|
-
throw new Error('dappOperatorIsHumanUser returned false');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
console.debug(response);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return response;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.ProsopoContract = ProsopoContract;
|
|
58
|
-
exports.default = ProsopoContract;
|
|
59
|
-
//# sourceMappingURL=ProsopoContract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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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AAO,QAAkD,CAAA;IAC7D,CAAC;CACJ;AAzCD,0CAyCC;AAED,kBAAe,eAAe,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ApiPromise } from '@polkadot/api';
|
|
2
|
-
import { Abi, ContractPromise } from '@polkadot/api-contract';
|
|
3
|
-
import { AnyJson } from '@polkadot/types/types/codec';
|
|
4
|
-
import { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
5
|
-
import { Signer } from '@polkadot/api/types';
|
|
6
|
-
import { TransactionResponse } from '../types';
|
|
7
|
-
import AsyncFactory from './AsyncFactory';
|
|
8
|
-
export declare class ProsopoContractBase extends AsyncFactory {
|
|
9
|
-
api: ApiPromise;
|
|
10
|
-
abi: Abi;
|
|
11
|
-
contract: ContractPromise;
|
|
12
|
-
userAccountAddress: string;
|
|
13
|
-
dappAddress: string;
|
|
14
|
-
contractAddress: string;
|
|
15
|
-
/**
|
|
16
|
-
* @param contractAddress
|
|
17
|
-
* @param dappAddress
|
|
18
|
-
* @param userAccountAddress
|
|
19
|
-
* @param providerInterface
|
|
20
|
-
*/
|
|
21
|
-
init(contractAddress: string, dappAddress: string, userAccountAddress: string, providerInterface: ProviderInterface): Promise<this>;
|
|
22
|
-
getApi(): ApiPromise;
|
|
23
|
-
getContract(): ContractPromise;
|
|
24
|
-
getDappAddress(): string;
|
|
25
|
-
disconnect(): Promise<void>;
|
|
26
|
-
query<T>(method: string, args: any[]): Promise<T | AnyJson | null>;
|
|
27
|
-
transaction(signer: Signer, method: string, args: any[]): Promise<TransactionResponse>;
|
|
28
|
-
}
|
|
29
|
-
export default ProsopoContractBase;
|
|
30
|
-
//# sourceMappingURL=ProsopoContractBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContractBase.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAA;AAC7D,O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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
|
-
userAccountAddress;
|
|
29
|
-
dappAddress;
|
|
30
|
-
contractAddress;
|
|
31
|
-
/**
|
|
32
|
-
* @param contractAddress
|
|
33
|
-
* @param dappAddress
|
|
34
|
-
* @param userAccountAddress
|
|
35
|
-
* @param providerInterface
|
|
36
|
-
*/
|
|
37
|
-
async init(contractAddress, dappAddress, userAccountAddress, 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, contractAddress);
|
|
41
|
-
this.contractAddress = contractAddress;
|
|
42
|
-
this.dappAddress = dappAddress;
|
|
43
|
-
this.userAccountAddress = userAccountAddress;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
getApi() {
|
|
47
|
-
return this.api;
|
|
48
|
-
}
|
|
49
|
-
getContract() {
|
|
50
|
-
return this.contract;
|
|
51
|
-
}
|
|
52
|
-
getDappAddress() {
|
|
53
|
-
return this.dappAddress;
|
|
54
|
-
}
|
|
55
|
-
async disconnect() {
|
|
56
|
-
await this.api.disconnect();
|
|
57
|
-
}
|
|
58
|
-
async query(method, args) {
|
|
59
|
-
try {
|
|
60
|
-
const abiMessage = this.abi.findMessage(method);
|
|
61
|
-
const response = await this.contract.query[method](this.userAccountAddress, {}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
62
|
-
console.log('QUERY RESPONSE', method, args, response);
|
|
63
|
-
if (response.result.isOk) {
|
|
64
|
-
if (response.output) {
|
|
65
|
-
return (0, contract_1.unwrap)(response.output.toHuman());
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
throw new contract_1.ProsopoContractError(response.result.asErr);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
console.error('ERROR', e);
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// https://polkadot.js.org/docs/api/cookbook/tx/
|
|
81
|
-
// https://polkadot.js.org/docs/api/start/api.tx.subs/
|
|
82
|
-
async transaction(signer, method, args) {
|
|
83
|
-
const queryBeforeTx = await this.query(method, args);
|
|
84
|
-
console.log('QUERY BEFORE TX....................', queryBeforeTx);
|
|
85
|
-
const abiMessage = this.abi.findMessage(method);
|
|
86
|
-
const extrinsic = this.contract.tx[method]({}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
87
|
-
// this.api.setSigner(signer);
|
|
88
|
-
// const response = await buildTx(this.api.registry, extrinsic, this.account.address, { signer });
|
|
89
|
-
// console.log("buildTx RESPONSE", response);
|
|
90
|
-
// return;
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
extrinsic
|
|
93
|
-
.signAndSend(this.userAccountAddress, { signer }, (result) => {
|
|
94
|
-
const { dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex } = result;
|
|
95
|
-
console.log('TX STATUS', status.type);
|
|
96
|
-
console.log('IS FINALIZED', status?.isFinalized);
|
|
97
|
-
console.log('IN BLOCK', status?.isInBlock);
|
|
98
|
-
console.log('EVENTS', events);
|
|
99
|
-
if (internalError) {
|
|
100
|
-
console.error('internalError', internalError);
|
|
101
|
-
reject(internalError);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (dispatchError) {
|
|
105
|
-
console.error('dispatchError', dispatchError);
|
|
106
|
-
reject(dispatchError);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
// [Ready, InBlock, Finalized...]
|
|
110
|
-
// Instant seal ON.
|
|
111
|
-
if (status?.isInBlock) {
|
|
112
|
-
const blockHash = status.asInBlock.toHex();
|
|
113
|
-
resolve({
|
|
114
|
-
dispatchError,
|
|
115
|
-
dispatchInfo,
|
|
116
|
-
events,
|
|
117
|
-
internalError,
|
|
118
|
-
status,
|
|
119
|
-
txHash,
|
|
120
|
-
txIndex,
|
|
121
|
-
blockHash,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
// Instant seal OFF.
|
|
125
|
-
// if (status?.isFinalized) {
|
|
126
|
-
// const blockHash = status.asFinalized.toHex();
|
|
127
|
-
// resolve({ dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex, blockHash });
|
|
128
|
-
// }
|
|
129
|
-
})
|
|
130
|
-
.catch((e) => {
|
|
131
|
-
console.error('signAndSend ERROR', e);
|
|
132
|
-
reject(e);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.ProsopoContractBase = ProsopoContractBase;
|
|
138
|
-
exports.default = ProsopoContractBase;
|
|
139
|
-
//# sourceMappingURL=ProsopoContractBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,uCAA6D;AAC7D,yDAA6D;AAC7D,gDAA2F;AAK3F,0EAAyC;AAGzC,MAAa,mBAAoB,SAAQ,sBAAY;IACjD,GAAG,CAAY;IACf,GAAG,CAAK;IACR,QAAQ,CAAiB;IACzB,kBAAkB,CAAQ;IAC1B,WAAW,CAAQ;IAEZ,eAAe,CAAQ;IAE9B;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACb,eAAuB,EACvB,WAAmB,EACnB,kBAA0B,EAC1B,iBAAoC;QAEpC,IAAI,CAAC,GAAG,GAAG,MAAM,gBAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAG,CAAC,kBAAO,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,QAAQ,GAAG,IAAI,8BAAe,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;QACxE,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,OAAO,IAAI,CAAA;IACf,CAAC;IAEM,MAA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AAM,CAAC,aAAa,CAAC,CAAA;oBAErB,OAAM;iBACT;gBAED,iCAAiC;gBAEjC,mBAAmB;gBACnB,IAAI,MAAM,EAAE,SAAS,EAAE;oBACnB,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;oBAE1C,OAAO,CAAC;wBACJ,aAAa;wBACb,YAAY;wBACZ,MAAM;wBACN,aAAa;wBACb,MAAM;wBACN,MAAM;wBACN,OAAO;wBACP,SAAS;qBACZ,CAAC,CAAA;iBACL;gBAED,oBAAoB;gBACpB,6BAA6B;gBAE7B,kDAAkD;gBAElD,yGAAyG;gBAEzG,IAAI;YACR,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;gBACrC,MAAM,CAAC,CAAC,CAAC,CAAA;YACb,CAAC,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AA/ID,kDA+IC;AAED,kBAAe,mBAAmB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=ProsopoCaptchaStateClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoCaptchaStateClient.d.ts","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaStateClient.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoCaptchaStateClient.js","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaStateClient.ts"],"names":[],"mappings":""}
|
package/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.build.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"target": "esnext",
|
|
8
|
-
"lib": [
|
|
9
|
-
"esnext",
|
|
10
|
-
"dom"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"./src/**/*.ts"
|
|
15
|
-
],
|
|
16
|
-
"references": [
|
|
17
|
-
{
|
|
18
|
-
"path": "../api"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"path": "../datasets"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../contract"
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
}
|