@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.
Files changed (98) hide show
  1. package/README.md +13 -0
  2. package/dist/api/AsyncFactory.d.ts +7 -0
  3. package/dist/api/AsyncFactory.d.ts.map +1 -0
  4. package/{src/api/AsyncFactory.ts → dist/api/AsyncFactory.js} +8 -9
  5. package/dist/api/AsyncFactory.js.map +1 -0
  6. package/dist/api/Extension.d.ts +22 -0
  7. package/dist/api/Extension.d.ts.map +1 -0
  8. package/{src/api/Extension.ts → dist/api/Extension.js} +39 -56
  9. package/dist/api/Extension.js.map +1 -0
  10. package/dist/api/HttpClientBase.d.ts +9 -0
  11. package/dist/api/HttpClientBase.d.ts.map +1 -0
  12. package/dist/api/HttpClientBase.js +36 -0
  13. package/dist/api/HttpClientBase.js.map +1 -0
  14. package/dist/api/ProsopoContract.d.ts +13 -0
  15. package/dist/api/ProsopoContract.d.ts.map +1 -0
  16. package/{src/api/ProsopoContract.ts → dist/api/ProsopoContract.js} +18 -20
  17. package/dist/api/ProsopoContract.js.map +1 -0
  18. package/dist/api/ProsopoContractBase.d.ts +31 -0
  19. package/dist/api/ProsopoContractBase.d.ts.map +1 -0
  20. package/dist/api/ProsopoContractBase.js +131 -0
  21. package/dist/api/ProsopoContractBase.js.map +1 -0
  22. package/dist/api/ProviderApi.d.ts +21 -0
  23. package/dist/api/ProviderApi.d.ts.map +1 -0
  24. package/dist/api/ProviderApi.js +54 -0
  25. package/dist/api/ProviderApi.js.map +1 -0
  26. package/dist/api/handlers.d.ts +5 -0
  27. package/dist/api/handlers.d.ts.map +1 -0
  28. package/dist/api/handlers.js +14 -0
  29. package/dist/api/handlers.js.map +1 -0
  30. package/dist/api/index.d.ts +7 -0
  31. package/dist/api/index.d.ts.map +1 -0
  32. package/{src/api/handlers.ts → dist/api/index.js} +10 -14
  33. package/dist/api/index.js.map +1 -0
  34. package/dist/index.d.ts +4 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/{src/modules/index.ts → dist/index.js} +7 -7
  37. package/dist/index.js.map +1 -0
  38. package/dist/modules/ProsopoCaptchaApi.d.ts +16 -0
  39. package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -0
  40. package/dist/modules/ProsopoCaptchaApi.js +86 -0
  41. package/dist/modules/ProsopoCaptchaApi.js.map +1 -0
  42. package/dist/modules/ProsopoCaptchaClient.d.ts +27 -0
  43. package/dist/modules/ProsopoCaptchaClient.d.ts.map +1 -0
  44. package/dist/modules/ProsopoCaptchaClient.js +97 -0
  45. package/dist/modules/ProsopoCaptchaClient.js.map +1 -0
  46. package/dist/modules/ProsopoCaptchaStateClient.d.ts +17 -0
  47. package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +1 -0
  48. package/dist/modules/ProsopoCaptchaStateClient.js +104 -0
  49. package/dist/modules/ProsopoCaptchaStateClient.js.map +1 -0
  50. package/dist/modules/client.d.ts +9 -0
  51. package/dist/modules/client.d.ts.map +1 -0
  52. package/{src/modules/client.ts → dist/modules/client.js} +13 -12
  53. package/dist/modules/client.js.map +1 -0
  54. package/dist/modules/contract.d.ts +7 -0
  55. package/dist/modules/contract.d.ts.map +1 -0
  56. package/{src/api/HttpClientBase.ts → dist/modules/contract.js} +14 -21
  57. package/dist/modules/contract.js.map +1 -0
  58. package/dist/modules/extension.d.ts +3 -0
  59. package/dist/modules/extension.d.ts.map +1 -0
  60. package/{src/api/index.ts → dist/modules/extension.js} +10 -6
  61. package/dist/modules/extension.js.map +1 -0
  62. package/dist/modules/index.d.ts +8 -0
  63. package/dist/modules/index.d.ts.map +1 -0
  64. package/{src/modules/contract.ts → dist/modules/index.js} +11 -8
  65. package/dist/modules/index.js.map +1 -0
  66. package/dist/modules/storage.d.ts +14 -0
  67. package/dist/modules/storage.d.ts.map +1 -0
  68. package/{src/modules/storage.ts → dist/modules/storage.js} +7 -7
  69. package/dist/modules/storage.js.map +1 -0
  70. package/dist/types/api.d.ts +45 -0
  71. package/dist/types/api.d.ts.map +1 -0
  72. package/{src/types/index.ts → dist/types/api.js} +7 -3
  73. package/dist/types/api.js.map +1 -0
  74. package/{src/types/client.ts → dist/types/client.d.ts} +8 -36
  75. package/dist/types/client.d.ts.map +1 -0
  76. package/dist/types/client.js +3 -0
  77. package/dist/types/client.js.map +1 -0
  78. package/dist/types/contract.d.ts +5 -0
  79. package/dist/types/contract.d.ts.map +1 -0
  80. package/dist/types/contract.js +3 -0
  81. package/dist/types/contract.js.map +1 -0
  82. package/dist/types/index.d.ts +4 -0
  83. package/dist/types/index.d.ts.map +1 -0
  84. package/{src/modules/extension.ts → dist/types/index.js} +7 -5
  85. package/dist/types/index.js.map +1 -0
  86. package/img/contracts-page.png +0 -0
  87. package/package.json +2 -2
  88. package/tsconfig.tsbuildinfo +1 -0
  89. package/src/api/ProsopoContractBase.ts +0 -169
  90. package/src/api/ProviderApi.ts +0 -59
  91. package/src/index.ts +0 -18
  92. package/src/modules/ProsopoCaptchaApi.ts +0 -105
  93. package/src/modules/ProsopoCaptchaClient.ts +0 -131
  94. package/src/modules/ProsopoCaptchaStateClient.ts +0 -146
  95. package/src/types/api.ts +0 -79
  96. package/src/types/contract.ts +0 -21
  97. package/tests/mocks/browser.ts +0 -25
  98. 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
- }
@@ -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
- };
@@ -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
- });