@prosopo/procaptcha 0.1.9 → 0.1.10

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 (114) hide show
  1. package/.eslintrc.js +28 -29
  2. package/.prettierrc.js +7 -0
  3. package/dist/api/AsyncFactory.d.ts.map +1 -1
  4. package/dist/api/AsyncFactory.js +2 -2
  5. package/dist/api/AsyncFactory.js.map +1 -1
  6. package/dist/api/Extension.d.ts +15 -0
  7. package/dist/api/Extension.d.ts.map +1 -0
  8. package/dist/api/Extension.js +9 -0
  9. package/dist/api/Extension.js.map +1 -0
  10. package/dist/api/ExtensionWeb2.d.ts +10 -25
  11. package/dist/api/ExtensionWeb2.d.ts.map +1 -1
  12. package/dist/api/ExtensionWeb2.js +79 -90
  13. package/dist/api/ExtensionWeb2.js.map +1 -1
  14. package/dist/api/ExtensionWeb3.d.ts +5 -52
  15. package/dist/api/ExtensionWeb3.d.ts.map +1 -1
  16. package/dist/api/ExtensionWeb3.js +24 -142
  17. package/dist/api/ExtensionWeb3.js.map +1 -1
  18. package/dist/api/HttpClientBase.d.ts +1 -1
  19. package/dist/api/HttpClientBase.d.ts.map +1 -1
  20. package/dist/api/HttpClientBase.js +2 -2
  21. package/dist/api/HttpClientBase.js.map +1 -1
  22. package/dist/api/ProsopoContract.d.ts +3 -3
  23. package/dist/api/ProsopoContract.d.ts.map +1 -1
  24. package/dist/api/ProsopoContract.js +25 -4
  25. package/dist/api/ProsopoContract.js.map +1 -1
  26. package/dist/api/ProsopoContractBase.d.ts +18 -20
  27. package/dist/api/ProsopoContractBase.d.ts.map +1 -1
  28. package/dist/api/ProsopoContractBase.js +34 -27
  29. package/dist/api/ProsopoContractBase.js.map +1 -1
  30. package/dist/api/errors.d.ts +13 -0
  31. package/dist/api/errors.d.ts.map +1 -0
  32. package/dist/api/errors.js +28 -0
  33. package/dist/api/errors.js.map +1 -0
  34. package/dist/api/handlers.d.ts +2 -2
  35. package/dist/api/handlers.d.ts.map +1 -1
  36. package/dist/api/handlers.js +2 -10
  37. package/dist/api/handlers.js.map +1 -1
  38. package/dist/api/index.d.ts +0 -1
  39. package/dist/api/index.d.ts.map +1 -1
  40. package/dist/api/index.js +0 -1
  41. package/dist/api/index.js.map +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/modules/Manager.d.ts +13 -0
  45. package/dist/modules/Manager.d.ts.map +1 -0
  46. package/dist/modules/Manager.js +346 -0
  47. package/dist/modules/Manager.js.map +1 -0
  48. package/dist/modules/ProsopoCaptchaApi.d.ts +12 -14
  49. package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -1
  50. package/dist/modules/ProsopoCaptchaApi.js +36 -56
  51. package/dist/modules/ProsopoCaptchaApi.js.map +1 -1
  52. package/dist/modules/ProsopoCaptchaStateClient.d.ts +0 -17
  53. package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +1 -1
  54. package/dist/modules/ProsopoCaptchaStateClient.js +0 -109
  55. package/dist/modules/ProsopoCaptchaStateClient.js.map +1 -1
  56. package/dist/modules/canvas.d.ts.map +1 -1
  57. package/dist/modules/canvas.js +84 -21
  58. package/dist/modules/canvas.js.map +1 -1
  59. package/dist/modules/index.d.ts +1 -6
  60. package/dist/modules/index.d.ts.map +1 -1
  61. package/dist/modules/index.js +1 -6
  62. package/dist/modules/index.js.map +1 -1
  63. package/dist/modules/storage.d.ts +10 -0
  64. package/dist/modules/storage.d.ts.map +1 -1
  65. package/dist/modules/storage.js +17 -17
  66. package/dist/modules/storage.js.map +1 -1
  67. package/dist/types/api.d.ts +19 -21
  68. package/dist/types/api.d.ts.map +1 -1
  69. package/dist/types/client.d.ts +10 -60
  70. package/dist/types/client.d.ts.map +1 -1
  71. package/dist/types/contract.d.ts +1 -1
  72. package/dist/types/contract.d.ts.map +1 -1
  73. package/dist/types/index.d.ts +1 -0
  74. package/dist/types/index.d.ts.map +1 -1
  75. package/dist/types/index.js +1 -0
  76. package/dist/types/index.js.map +1 -1
  77. package/dist/types/manager.d.ts +67 -0
  78. package/dist/types/manager.d.ts.map +1 -0
  79. package/dist/types/manager.js +3 -0
  80. package/dist/types/manager.js.map +1 -0
  81. package/dist/types/utils.d.ts +2 -0
  82. package/dist/types/utils.d.ts.map +1 -0
  83. package/dist/types/utils.js +3 -0
  84. package/dist/types/utils.js.map +1 -0
  85. package/dist/utils/utils.d.ts +2 -0
  86. package/dist/utils/utils.d.ts.map +1 -0
  87. package/dist/utils/utils.js +8 -0
  88. package/dist/utils/utils.js.map +1 -0
  89. package/package.json +4 -3
  90. package/tsconfig.json +5 -2
  91. package/dist/api/AccountCreator.d.ts +0 -19
  92. package/dist/api/AccountCreator.d.ts.map +0 -1
  93. package/dist/api/AccountCreator.js +0 -88
  94. package/dist/api/AccountCreator.js.map +0 -1
  95. package/dist/api/ProviderApi.d.ts +0 -14
  96. package/dist/api/ProviderApi.d.ts.map +0 -1
  97. package/dist/api/ProviderApi.js +0 -53
  98. package/dist/api/ProviderApi.js.map +0 -1
  99. package/dist/modules/ProsopoCaptchaClient.d.ts +0 -26
  100. package/dist/modules/ProsopoCaptchaClient.d.ts.map +0 -1
  101. package/dist/modules/ProsopoCaptchaClient.js +0 -112
  102. package/dist/modules/ProsopoCaptchaClient.js.map +0 -1
  103. package/dist/modules/client.d.ts +0 -9
  104. package/dist/modules/client.d.ts.map +0 -1
  105. package/dist/modules/client.js +0 -40
  106. package/dist/modules/client.js.map +0 -1
  107. package/dist/modules/contract.d.ts +0 -7
  108. package/dist/modules/contract.d.ts.map +0 -1
  109. package/dist/modules/contract.js +0 -42
  110. package/dist/modules/contract.js.map +0 -1
  111. package/dist/modules/extension.d.ts +0 -4
  112. package/dist/modules/extension.d.ts.map +0 -1
  113. package/dist/modules/extension.js +0 -31
  114. package/dist/modules/extension.js.map +0 -1
@@ -1,61 +1,11 @@
1
- import { InjectedAccountWithMeta, InjectedExtension } from "@polkadot/extension-inject/types";
2
- import { CaptchaSolutionResponse, GetCaptchaResponse, ProsopoCaptchaConfig } from "../types/api";
3
- import { TransactionResponse } from "../types/contract";
4
- import { CaptchaSolutionCommitment } from "@prosopo/datasets";
5
- export declare type TExtensionAccount = InjectedAccountWithMeta;
6
- export declare type TCaptchaSubmitResult = [CaptchaSolutionResponse, TransactionResponse?, CaptchaSolutionCommitment?];
7
- export interface IExtensionInterface {
8
- checkExtension(): void;
9
- getExtension(): InjectedExtension | undefined;
10
- getAccounts(): InjectedAccountWithMeta[];
11
- getAccount(): InjectedAccountWithMeta | undefined;
12
- setAccount(account: string): void;
13
- unsetAccount(): void;
14
- getDefaultAccount(): InjectedAccountWithMeta | undefined;
15
- setDefaultAccount(): void;
16
- createAccount(): Promise<InjectedAccountWithMeta | undefined>;
17
- }
18
- export interface ICaptchaClientEvents {
19
- onLoad?: (extension: IExtensionInterface, contractAddress: string) => void;
20
- onAccountChange?: (account?: TExtensionAccount) => void;
21
- }
22
- export interface ICaptchaStateClientEvents {
23
- onLoadCaptcha?: (captchaChallenge: GetCaptchaResponse | Error) => void;
24
- onSubmit?: (result: TCaptchaSubmitResult | Error, captchaState: ICaptchaState) => void;
25
- onChange?: (captchaSolution: string[][], index: number) => void;
26
- onCancel?: () => void;
27
- onSolved?: (result: TCaptchaSubmitResult, isHuman?: boolean) => void;
28
- }
29
- export interface CaptchaEventCallbacks extends ICaptchaClientEvents, ICaptchaStateClientEvents {
30
- }
31
- export interface ICaptchaContextState {
32
- config: ProsopoCaptchaConfig;
33
- contractAddress?: string;
34
- account?: InjectedAccountWithMeta;
35
- }
36
- export interface ICaptchaContextReducer {
37
- state: ICaptchaContextState;
38
- update: (value: Partial<ICaptchaContextState>) => void;
39
- }
40
- export interface ICaptchaState {
41
- captchaChallenge?: GetCaptchaResponse;
42
- captchaIndex: number;
43
- captchaSolution: string[][];
44
- }
45
- export interface ICaptchaStateReducer {
46
- state: ICaptchaState;
47
- update: (value: Partial<ICaptchaState>) => void;
48
- }
49
- export interface ICaptchaStatusState {
50
- info?: string;
51
- error?: string;
52
- }
53
- export interface ICaptchaStatusReducerAction {
54
- info?: [string, any] | string;
55
- error?: [string, any] | string | Error;
56
- }
57
- export interface ICaptchaStatusReducer {
58
- state: ICaptchaStatusState;
59
- update: (value: Partial<ICaptchaStatusReducerAction>) => void;
60
- }
1
+ import { CaptchaSolutionResponse } from '../types/api';
2
+ import { TransactionResponse } from '../types/contract';
3
+ import { CaptchaSolutionCommitment } from '@prosopo/datasets';
4
+ import { CaptchaSolutionCommitmentId } from '@prosopo/api';
5
+ export type TCaptchaSubmitResult = [
6
+ CaptchaSolutionResponse,
7
+ CaptchaSolutionCommitmentId,
8
+ TransactionResponse?,
9
+ CaptchaSolutionCommitment?
10
+ ];
61
11
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;AAE7D,oBAAY,iBAAiB,GAAG,uBAAuB,CAAC;AAExD,oBAAY,oBAAoB,GAAG,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC;AAE/G,MAAM,WAAW,mBAAmB;IAChC,cAAc,IAAI,IAAI,CAAC;IACvB,YAAY,IAAI,iBAAiB,GAAG,SAAS,CAAC;IAC9C,WAAW,IAAI,uBAAuB,EAAE,CAAC;IACzC,UAAU,IAAI,uBAAuB,GAAG,SAAS,CAAC;IAClD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,IAAI,IAAI,CAAC;IACrB,iBAAiB,IAA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,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,EAAE,CAAC;CAE/B;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IACxC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAC;CACjE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAE1D,MAAM,MAAM,oBAAoB,GAAG;IAC/B,uBAAuB;IACvB,2BAA2B;IAC3B,mBAAmB,CAAC;IACpB,yBAAyB,CAAC;CAC7B,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { SubmittableResultValue } from '@polkadot/api/types';
2
- export declare type TransactionResponse = SubmittableResultValue & {
2
+ export type TransactionResponse = SubmittableResultValue & {
3
3
  blockHash?: string;
4
4
  };
5
5
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/types/contract.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,oBAAY,mBAAmB,GAAG,sBAAsB,GAAG;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/types/contract.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAEjE,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG;IACvD,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './api';
2
2
  export * from './contract';
3
+ export * from './manager';
3
4
  export * from './client';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAeA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAeA,cAAc,OAAO,CAAA;AACrB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA"}
@@ -18,5 +18,6 @@ const tslib_1 = require("tslib");
18
18
  // along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
19
19
  tslib_1.__exportStar(require("./api"), exports);
20
20
  tslib_1.__exportStar(require("./contract"), exports);
21
+ tslib_1.__exportStar(require("./manager"), exports);
21
22
  tslib_1.__exportStar(require("./client"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/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,qDAA2B;AAC3B,mDAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/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,gDAAqB;AACrB,qDAA0B;AAC1B,oDAAyB;AACzB,mDAAwB"}
@@ -0,0 +1,67 @@
1
+ import { InjectedAccount, InjectedExtension } from '@polkadot/extension-inject/types';
2
+ import { GetCaptchaResponse } from '@prosopo/api';
3
+ import { TCaptchaSubmitResult } from './client';
4
+ import { ProsopoNetwork } from '@prosopo/api';
5
+ import { Optional } from './utils';
6
+ import { ProsopoCaptchaApi } from '../modules/ProsopoCaptchaApi';
7
+ /**
8
+ * House the account and associated extension.
9
+ */
10
+ export interface Account {
11
+ account: InjectedAccount;
12
+ extension: InjectedExtension;
13
+ }
14
+ /**
15
+ * The configuration of Procaptcha. This is passed it to Procaptcha as a prop. Values here are not updated by Procaptcha and are considered immutable from within Procaptcha.
16
+ */
17
+ export interface ProcaptchaConfig {
18
+ userAccountAddress: string;
19
+ web2: boolean;
20
+ dappName: string;
21
+ network: ProsopoNetwork;
22
+ solutionThreshold: number;
23
+ }
24
+ /**
25
+ * The config to be passed to procaptcha. Some fields can be optional, e.g. userAccountAddress and web2, depending on the mode of Procaptcha (web2 or web3).
26
+ */
27
+ export type ProcaptchaConfigOptional = Optional<Optional<ProcaptchaConfig, 'userAccountAddress'>, 'web2'>;
28
+ /**
29
+ * The state of Procaptcha. This is mutated as required to reflect the captcha process.
30
+ */
31
+ export interface ProcaptchaState {
32
+ isHuman: boolean;
33
+ index: number;
34
+ solutions: string[][];
35
+ captchaApi: ProsopoCaptchaApi | undefined;
36
+ challenge: GetCaptchaResponse | undefined;
37
+ showModal: boolean;
38
+ loading: boolean;
39
+ account: Account | undefined;
40
+ submission: TCaptchaSubmitResult | undefined;
41
+ }
42
+ /**
43
+ * Function to update the state of the Procaptcha component. This is a partial state which is coalesced with the existing state, replacing any fields that are defined and using values from the current state for any undefined state variables.
44
+ */
45
+ export type ProcaptchaStateUpdateFn = (state: Partial<ProcaptchaState>) => void;
46
+ /**
47
+ * A set of callbacks called by Procaptcha on certain events. These are optional as the client can decide which events they wish to listen for.
48
+ */
49
+ export type ProcaptchaCallbacks = Partial<ProcaptchaEvents>;
50
+ /**
51
+ * A list of all events which can occur during the Procaptcha process.
52
+ */
53
+ export interface ProcaptchaEvents {
54
+ onError: (error: Error) => void;
55
+ onAccountNotFound: (address: string) => void;
56
+ onHuman: (output: ProcaptchaOutput) => void;
57
+ onExtensionNotFound: () => void;
58
+ }
59
+ /**
60
+ * The information produced by procaptcha on completion of the captcha process, whether verified by smart contract, a pending commitment in the cache of a provider or a captcha challenge.
61
+ */
62
+ export interface ProcaptchaOutput {
63
+ commitmentId?: string;
64
+ providerUrl?: string;
65
+ userAccountAddress: string;
66
+ }
67
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/types/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA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AAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC3C,mBAAmB,EAAE,MAAM,IAAI,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;CAC7B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/types/manager.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const sleep: (ms: any) => Promise<unknown>;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,+BAEjB,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ const sleep = (ms) => {
5
+ return new Promise((resolve) => setTimeout(resolve, ms));
6
+ };
7
+ exports.sleep = sleep;
8
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,EAAE,EAAE,EAAE;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA;AAFY,QAAA,KAAK,SAEjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -23,8 +23,9 @@
23
23
  "@polkadot/types": "^8.13.1",
24
24
  "@polkadot/util": "^10.0.2",
25
25
  "@polkadot/util-crypto": "^10.0.2",
26
- "@prosopo/contract": "^0.1.9",
27
- "@prosopo/datasets": "^0.1.9",
26
+ "@prosopo/api": "^0.1.10",
27
+ "@prosopo/contract": "^0.1.10",
28
+ "@prosopo/datasets": "^0.1.10",
28
29
  "axios": "^0.27.2"
29
30
  },
30
31
  "devDependencies": {
package/tsconfig.json CHANGED
@@ -15,10 +15,13 @@
15
15
  ],
16
16
  "references": [
17
17
  {
18
- "path": "../provider"
18
+ "path": "../api"
19
+ },
20
+ {
21
+ "path": "../datasets"
19
22
  },
20
23
  {
21
24
  "path": "../contract"
22
- }
25
+ },
23
26
  ]
24
27
  }
@@ -1,19 +0,0 @@
1
- import { ApiPromise } from "@polkadot/api";
2
- import { InjectedAccountWithMeta } from "@polkadot/extension-inject/types";
3
- import AsyncFactory from "./AsyncFactory";
4
- import { Keyring } from "@polkadot/keyring";
5
- import { ProviderInterface } from "@polkadot/rpc-provider/types";
6
- import { AccountCreatorConfig } from "../types/index";
7
- export declare class AccountCreator extends AsyncFactory {
8
- protected api: ApiPromise;
9
- protected config: AccountCreatorConfig;
10
- protected source: string;
11
- /**
12
- * @param providerInterface
13
- * @param config
14
- */
15
- init(providerInterface: ProviderInterface, config: AccountCreatorConfig, source: string): Promise<this>;
16
- createAccount(keyring?: Keyring, address?: string): Promise<InjectedAccountWithMeta>;
17
- getFingerprint(): Promise<string>;
18
- }
19
- //# sourceMappingURL=AccountCreator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountCreator.d.ts","sourceRoot":"","sources":["../../src/api/AccountCreator.ts"],"names":[],"mappings":"AAeA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAC;AACzE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,OAAO,EAA+B,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAK/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAGpD,qBAAa,cAAe,SAAQ,YAAY;IAE5C,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACvC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACU,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM;IAOvF,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAsCpF,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAUjD"}
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccountCreator = 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 AsyncFactory_1 = tslib_1.__importDefault(require("./AsyncFactory"));
22
- const keyring_1 = require("@polkadot/keyring");
23
- const util_crypto_1 = require("@polkadot/util-crypto");
24
- const fingerprintjs_1 = tslib_1.__importStar(require("@fingerprintjs/fingerprintjs"));
25
- const bip39_1 = require("@polkadot/util-crypto/mnemonic/bip39");
26
- const util_1 = require("@polkadot/util");
27
- const canvas_1 = require("../modules/canvas");
28
- const datasets_1 = require("@prosopo/datasets");
29
- class AccountCreator extends AsyncFactory_1.default {
30
- api;
31
- config;
32
- source;
33
- /**
34
- * @param providerInterface
35
- * @param config
36
- */
37
- async init(providerInterface, config, source) {
38
- this.api = await api_1.ApiPromise.create({ provider: providerInterface });
39
- this.source = source;
40
- this.config = config;
41
- return this;
42
- }
43
- async createAccount(keyring, address) {
44
- const params = {
45
- area: this.config.area,
46
- offsetParameter: this.config.offsetParameter,
47
- multiplier: this.config.multiplier,
48
- fontSizeFactor: this.config.fontSizeFactor,
49
- maxShadowBlur: this.config.maxShadowBlur
50
- };
51
- const browserEntropy = await this.getFingerprint();
52
- const canvasEntropy = (0, canvas_1.picassoCanvas)(this.config.numberOfRounds, this.config.seed, params);
53
- const entropy = (0, datasets_1.hexHash)([canvasEntropy, browserEntropy].join(""), 128).slice(2);
54
- console.log("canvas entropy", canvasEntropy);
55
- console.log("browserEntropy", browserEntropy);
56
- console.log("entropy", entropy);
57
- const u8Entropy = (0, util_1.stringToU8a)(entropy);
58
- const mnemonic = (0, bip39_1.entropyToMnemonic)(u8Entropy);
59
- if (!keyring) {
60
- keyring = new keyring_1.Keyring({ type: 'sr25519', ss58Format: this.api.registry.chainSS58 });
61
- }
62
- await (0, util_crypto_1.cryptoWaitReady)();
63
- if (address) {
64
- return { address: address, meta: { source: this.source, name: address } };
65
- }
66
- else {
67
- const account = keyring?.addFromMnemonic(mnemonic);
68
- return {
69
- address: account.address.length === 42
70
- ? account.address
71
- : (0, keyring_1.encodeAddress)((0, keyring_1.decodeAddress)(account.address), this.api.registry.chainSS58),
72
- meta: { source: this.source, name: account.address },
73
- };
74
- }
75
- }
76
- async getFingerprint() {
77
- // Initialize an agent at application startup.
78
- const fpPromise = fingerprintjs_1.default.load();
79
- // Get the visitor identifier when you need it.
80
- const fp = await fpPromise;
81
- const result = await fp.get();
82
- // strip out the components that change in incognito mode
83
- const { screenFrame, ...componentsReduced } = result.components;
84
- return (0, fingerprintjs_1.hashComponents)(componentsReduced);
85
- }
86
- }
87
- exports.AccountCreator = AccountCreator;
88
- //# sourceMappingURL=AccountCreator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AccountCreator.js","sourceRoot":"","sources":["../../src/api/AccountCreator.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,uCAAyC;AAEzC,0EAA0C;AAC1C,+CAAwE;AACxE,uDAAsD;AAEtD,sFAA0E;AAC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C,GAAG,EAAE,CAAA;QAC7B,yDAAyD;QACzD,MAAM,EAAC,WAAW,EAAE,GAAG,iBAAiB,EAAC,GAAG,MAAM,CAAC,UAAU,CAAA;QAC7D,OAAO,IAAA,8BAAc,EAAC,iBAAiB,CAAC,CAAA;IAC5C,CAAC;CACJ;AAjED,wCAiEC"}
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,53 +0,0 @@
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
@@ -1 +0,0 @@
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,yEAAyC;AASzC,MAAa,WAAY,SAAQ,wBAAc;IAEnC,MAAM,CAAuB;IAErC,YAAY,MAA4B;QACpC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAEM,mBAAmB,CAAC,cAA6C;QACpE,MAAM,EAAC,QAAQ,EAAC,GAAG,cAAc,CAAC;QAClC,IAAI,EAAC,WAAW,EAAC,GAAG,cAAc,CAAC;QACnC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,QAAQ,CAAC,SAAS,IAAI,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC;IACjI,CAAC;IAEM,qBAAqB,CAAC,QAA2B,EAAE,WAAmB,EAAE,WAAmB,EAAE,IAAY,EAAE,SAAkB,EAAE,MAAe,EAAE,IAAc;QACjK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE;YACzC,SAAS;YACT,QAAQ;YACR,WAAW;YACX,MAAM;YACN,WAAW;YACX,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YACvC,IAAI;YACJ,IAAI;SACP,CAAC,CAAC;IACP,CAAC;CAEJ;AAlCD,kCAkCC;AAED,kBAAe,WAAW,CAAC"}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProsopoCaptchaClient = void 0;
4
- const contract_1 = require("./contract");
5
- const extension_1 = require("./extension");
6
- const ProviderApi_1 = require("../api/ProviderApi");
7
- const ProsopoCaptchaApi_1 = require("./ProsopoCaptchaApi");
8
- const contract_2 = require("@prosopo/contract");
9
- class ProsopoCaptchaClient {
10
- manager;
11
- status;
12
- callbacks;
13
- providerApi;
14
- static extension;
15
- static contract;
16
- static provider;
17
- static captchaApi;
18
- constructor(manager, status, callbacks) {
19
- this.manager = manager;
20
- this.status = status;
21
- this.callbacks = callbacks;
22
- this.providerApi = new ProviderApi_1.ProviderApi(manager.state.config);
23
- }
24
- getExtension() {
25
- return ProsopoCaptchaClient.extension;
26
- }
27
- setExtension(extension) {
28
- ProsopoCaptchaClient.extension = extension;
29
- }
30
- getContract() {
31
- return ProsopoCaptchaClient.contract;
32
- }
33
- getProvider() {
34
- return ProsopoCaptchaClient.provider;
35
- }
36
- getCaptchaApi() {
37
- return ProsopoCaptchaClient.captchaApi;
38
- }
39
- async onLoad(createAccount) {
40
- if (!ProsopoCaptchaClient.extension) {
41
- try {
42
- ProsopoCaptchaClient.extension = await (0, extension_1.getExtension)((0, contract_1.getWsProvider)(this.manager.state.config['dappUrl']), this.manager.state.config['web2'], this.manager.state.config['accountCreator'], this.manager.state.config['dappName']);
43
- }
44
- catch (err) {
45
- throw new contract_2.ProsopoEnvError(err);
46
- }
47
- }
48
- if (this.callbacks?.onLoad) {
49
- this.callbacks.onLoad(ProsopoCaptchaClient.extension, this.manager.state.config['prosopoContractAccount']);
50
- this.manager.update({ contractAddress: this.manager.state.config['prosopoContractAccount'] });
51
- }
52
- let account;
53
- if (createAccount) {
54
- try {
55
- account = await this.getExtension().createAccount();
56
- }
57
- catch (err) {
58
- throw new contract_2.ProsopoEnvError(err);
59
- }
60
- }
61
- else {
62
- try {
63
- account = await this.getExtension().getAccount();
64
- }
65
- catch (err) {
66
- throw new contract_2.ProsopoEnvError(err);
67
- }
68
- }
69
- await this.onAccountChange(account);
70
- }
71
- async onAccountChange(account) {
72
- if (!account) {
73
- this.onAccountUnset();
74
- return;
75
- }
76
- try {
77
- ProsopoCaptchaClient.extension.setAccount(account.address);
78
- }
79
- catch (err) {
80
- throw new contract_2.ProsopoEnvError(err);
81
- }
82
- try {
83
- ProsopoCaptchaClient.contract = await (0, contract_1.getProsopoContract)(this.manager.state.config['prosopoContractAccount'], this.manager.state.config['dappAccount'], account, (0, contract_1.getWsProvider)(this.manager.state.config['dappUrl']));
84
- }
85
- catch (err) {
86
- throw new contract_2.ProsopoEnvError(err);
87
- }
88
- try {
89
- ProsopoCaptchaClient.provider = await ProsopoCaptchaClient.contract.getRandomProvider();
90
- }
91
- catch (err) {
92
- throw new contract_2.ProsopoEnvError(err);
93
- }
94
- ProsopoCaptchaClient.captchaApi = new ProsopoCaptchaApi_1.ProsopoCaptchaApi(ProsopoCaptchaClient.contract, ProsopoCaptchaClient.provider, this.providerApi, this.manager.state.config['web2']);
95
- if (this.callbacks?.onAccountChange) {
96
- this.callbacks.onAccountChange(account);
97
- }
98
- this.manager.update({ account });
99
- }
100
- onAccountUnset() {
101
- ProsopoCaptchaClient.contract = undefined;
102
- ProsopoCaptchaClient.provider = undefined;
103
- ProsopoCaptchaClient.captchaApi = undefined;
104
- if (this.callbacks?.onAccountChange) {
105
- this.callbacks.onAccountChange(undefined);
106
- }
107
- this.manager.update({ account: undefined });
108
- }
109
- }
110
- exports.ProsopoCaptchaClient = ProsopoCaptchaClient;
111
- exports.default = ProsopoCaptchaClient;
112
- //# sourceMappingURL=ProsopoCaptchaClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProsopoCaptchaClient.js","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaClient.ts"],"names":[],"mappings":";;;AAwBA,yCAA6D;AAC7D,2CAAyC;AACzC,oDAA+C;AAC/C,2DAAsD;AACtD,gDAAkD;AAElD,MAAa,oBAAoB;IAEtB,OAAO,CAAyB;IAChC,MAAM,CAAwB;IAC9B,SAAS,CAAoC;IAC7C,WAAW,CAAc;IAExB,MAAM,CAAC,SAAS,CAAsB;IACtC,MAAM,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