@prosopo/procaptcha 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/api/AsyncFactory.d.ts +7 -0
- package/dist/api/AsyncFactory.d.ts.map +1 -0
- package/{src/api/AsyncFactory.ts → dist/api/AsyncFactory.js} +8 -9
- package/dist/api/AsyncFactory.js.map +1 -0
- package/dist/api/Extension.d.ts +22 -0
- package/dist/api/Extension.d.ts.map +1 -0
- package/{src/api/Extension.ts → dist/api/Extension.js} +39 -56
- package/dist/api/Extension.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/{src/api/ProsopoContract.ts → dist/api/ProsopoContract.js} +18 -20
- package/dist/api/ProsopoContract.js.map +1 -0
- package/dist/api/ProsopoContractBase.d.ts +31 -0
- package/dist/api/ProsopoContractBase.d.ts.map +1 -0
- package/dist/api/ProsopoContractBase.js +131 -0
- package/dist/api/ProsopoContractBase.js.map +1 -0
- package/dist/api/ProviderApi.d.ts +21 -0
- package/dist/api/ProviderApi.d.ts.map +1 -0
- package/dist/api/ProviderApi.js +54 -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 +14 -0
- package/dist/api/handlers.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/{src/api/handlers.ts → dist/api/index.js} +10 -14
- package/dist/api/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/modules/index.ts → dist/index.js} +7 -7
- package/dist/index.js.map +1 -0
- package/dist/modules/ProsopoCaptchaApi.d.ts +16 -0
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaApi.js +86 -0
- package/dist/modules/ProsopoCaptchaApi.js.map +1 -0
- package/dist/modules/ProsopoCaptchaClient.d.ts +27 -0
- package/dist/modules/ProsopoCaptchaClient.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaClient.js +97 -0
- package/dist/modules/ProsopoCaptchaClient.js.map +1 -0
- package/dist/modules/ProsopoCaptchaStateClient.d.ts +17 -0
- package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +1 -0
- package/dist/modules/ProsopoCaptchaStateClient.js +104 -0
- package/dist/modules/ProsopoCaptchaStateClient.js.map +1 -0
- package/dist/modules/client.d.ts +9 -0
- package/dist/modules/client.d.ts.map +1 -0
- package/{src/modules/client.ts → dist/modules/client.js} +13 -12
- 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/{src/api/HttpClientBase.ts → dist/modules/contract.js} +14 -21
- package/dist/modules/contract.js.map +1 -0
- package/dist/modules/extension.d.ts +3 -0
- package/dist/modules/extension.d.ts.map +1 -0
- package/{src/api/index.ts → dist/modules/extension.js} +10 -6
- 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/{src/modules/contract.ts → dist/modules/index.js} +11 -8
- 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/{src/modules/storage.ts → dist/modules/storage.js} +7 -7
- package/dist/modules/storage.js.map +1 -0
- package/dist/types/api.d.ts +45 -0
- package/dist/types/api.d.ts.map +1 -0
- package/{src/types/index.ts → dist/types/api.js} +7 -3
- package/dist/types/api.js.map +1 -0
- package/{src/types/client.ts → dist/types/client.d.ts} +8 -36
- 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/{src/modules/extension.ts → dist/types/index.js} +7 -5
- package/dist/types/index.js.map +1 -0
- package/img/contracts-page.png +0 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -0
- package/src/api/ProsopoContractBase.ts +0 -169
- package/src/api/ProviderApi.ts +0 -59
- package/src/index.ts +0 -18
- package/src/modules/ProsopoCaptchaApi.ts +0 -105
- package/src/modules/ProsopoCaptchaClient.ts +0 -131
- package/src/modules/ProsopoCaptchaStateClient.ts +0 -146
- package/src/types/api.ts +0 -79
- package/src/types/contract.ts +0 -21
- package/tests/mocks/browser.ts +0 -25
- package/tests/modules/client.test.ts +0 -56
package/src/types/api.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
3
|
-
//
|
|
4
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
5
|
-
// it under the terms of the GNU General Public License as published by
|
|
6
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
// (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
// GNU General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU General Public License
|
|
15
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
// declare module "*.json" {
|
|
17
|
-
// const value: any;
|
|
18
|
-
// export default value;
|
|
19
|
-
// }
|
|
20
|
-
|
|
21
|
-
import { InjectedAccountWithMeta, InjectedExtension } from "@polkadot/extension-inject/types";
|
|
22
|
-
|
|
23
|
-
// import { SubmittableResult } from "@polkadot/api";
|
|
24
|
-
import {Captcha, CaptchaStatus} from "@prosopo/contract";
|
|
25
|
-
|
|
26
|
-
export interface ProsopoRandomProviderResponse {
|
|
27
|
-
providerId: string,
|
|
28
|
-
blockNumber: string;
|
|
29
|
-
provider: ProposoProvider;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ProposoProvider {
|
|
33
|
-
balance: string;
|
|
34
|
-
captchaDatasetId: string;
|
|
35
|
-
fee: string;
|
|
36
|
-
payee: string; // TODO: enum?
|
|
37
|
-
serviceOrigin: string;
|
|
38
|
-
status: string; // TODO: enum
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// export interface CaptchaResponseCaptchaItem {
|
|
42
|
-
// captchaId: string;
|
|
43
|
-
// datasetId: string;
|
|
44
|
-
// items: CaptchaImageSchema[];
|
|
45
|
-
// target: string;
|
|
46
|
-
// salt?: string;
|
|
47
|
-
// solution?: number[];
|
|
48
|
-
// }
|
|
49
|
-
|
|
50
|
-
export interface CaptchaImageSchema {
|
|
51
|
-
path: string,
|
|
52
|
-
type: string
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface CaptchaResponseCaptcha {
|
|
56
|
-
captcha: Captcha;
|
|
57
|
-
proof: string[][];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface GetCaptchaResponse {
|
|
61
|
-
captchas: CaptchaResponseCaptcha[];
|
|
62
|
-
requestHash: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface CaptchaSolution {
|
|
66
|
-
captchaId: string;
|
|
67
|
-
solution: number[];
|
|
68
|
-
salt: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface CaptchaSolutionResponse {
|
|
72
|
-
status: string;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface ProsopoCaptchaConfig {
|
|
76
|
-
"providerApi.baseURL": string;
|
|
77
|
-
"providerApi.prefix": string;
|
|
78
|
-
"dappAccount": string;
|
|
79
|
-
}
|
package/src/types/contract.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
3
|
-
//
|
|
4
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
5
|
-
// it under the terms of the GNU General Public License as published by
|
|
6
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
// (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
// GNU General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU General Public License
|
|
15
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
// import { SubmittableResult } from "@polkadot/api";
|
|
17
|
-
import type { SubmittableResultValue } from '@polkadot/api/types';
|
|
18
|
-
|
|
19
|
-
export type TransactionResponse = SubmittableResultValue & {
|
|
20
|
-
blockHash?: string,
|
|
21
|
-
};
|
package/tests/mocks/browser.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export class LocalStorageMock {
|
|
2
|
-
|
|
3
|
-
private store: {[key: string]: string};
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
this.store = {};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
clear() {
|
|
10
|
-
this.store = {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getItem(key: string) {
|
|
14
|
-
return this.store[key] || null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setItem(key: string, value: any) {
|
|
18
|
-
this.store[key] = String(value);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
removeItem(key: string) {
|
|
22
|
-
delete this.store[key];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// import { LocalStorageMock } from "../mocks/browser";
|
|
2
|
-
import { ProsopoCaptchaConfig } from "../../src/types/api";
|
|
3
|
-
|
|
4
|
-
import { captchaContextReducer, captchaStateReducer, captchaStatusReducer } from "../../src/modules/client";
|
|
5
|
-
import { ICaptchaContextState, ICaptchaState } from "../../src/types/client";
|
|
6
|
-
|
|
7
|
-
import chai from "chai";
|
|
8
|
-
|
|
9
|
-
const expect = chai.expect;
|
|
10
|
-
|
|
11
|
-
describe("CLIENT UNIT TESTS", () => {
|
|
12
|
-
|
|
13
|
-
// var localStorage: LocalStorageMock;
|
|
14
|
-
|
|
15
|
-
const testConfig: ProsopoCaptchaConfig = {
|
|
16
|
-
"providerApi.baseURL": "http://localhost:3000",
|
|
17
|
-
"providerApi.prefix": "/v1/prosopo",
|
|
18
|
-
"dappAccount": "",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
before(async () => {
|
|
22
|
-
// localStorage = new LocalStorageMock();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("client context reducer", async () => {
|
|
26
|
-
|
|
27
|
-
const testState: ICaptchaContextState = {
|
|
28
|
-
config: testConfig,
|
|
29
|
-
contractAddress: "test",
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
testConfig.dappAccount = "dapp";
|
|
33
|
-
const contextReducer = captchaContextReducer(testState, { config: testConfig });
|
|
34
|
-
|
|
35
|
-
expect(contextReducer.config.dappAccount).to.equal(testConfig.dappAccount);
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("client state reducer", async () => {
|
|
40
|
-
|
|
41
|
-
const testState: ICaptchaState = {
|
|
42
|
-
captchaIndex: 0,
|
|
43
|
-
captchaSolution: [[0, 1, 2, 3]],
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const captchaSolution = testState.captchaSolution;
|
|
47
|
-
captchaSolution.push([4, 5]);
|
|
48
|
-
|
|
49
|
-
const stateReducer = captchaStateReducer(testState, { captchaSolution });
|
|
50
|
-
|
|
51
|
-
expect(stateReducer.captchaSolution.length).to.equal(2);
|
|
52
|
-
expect(stateReducer.captchaSolution[1]).to.include.members([4, 5]);
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
});
|