@prosopo/procaptcha 0.1.18 → 0.1.19

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 (89) hide show
  1. package/dist/api/Extension.d.ts +16 -0
  2. package/dist/api/Extension.d.ts.map +1 -0
  3. package/dist/api/Extension.js +6 -0
  4. package/dist/api/Extension.js.map +1 -0
  5. package/dist/api/ExtensionWeb2.d.ts +13 -0
  6. package/dist/api/ExtensionWeb2.d.ts.map +1 -0
  7. package/dist/api/ExtensionWeb2.js +97 -0
  8. package/dist/api/ExtensionWeb2.js.map +1 -0
  9. package/dist/api/ExtensionWeb3.d.ts +10 -0
  10. package/dist/api/ExtensionWeb3.d.ts.map +1 -0
  11. package/dist/api/ExtensionWeb3.js +29 -0
  12. package/dist/api/ExtensionWeb3.js.map +1 -0
  13. package/dist/api/HttpClientBase.d.ts +9 -0
  14. package/dist/api/HttpClientBase.d.ts.map +1 -0
  15. package/dist/api/HttpClientBase.js +28 -0
  16. package/dist/api/HttpClientBase.js.map +1 -0
  17. package/dist/api/errors.d.ts +16 -0
  18. package/dist/api/errors.d.ts.map +1 -0
  19. package/dist/api/errors.js +39 -0
  20. package/dist/api/errors.js.map +1 -0
  21. package/dist/api/handlers.d.ts +6 -0
  22. package/dist/api/handlers.d.ts.map +1 -0
  23. package/dist/api/handlers.js +9 -0
  24. package/dist/api/handlers.js.map +1 -0
  25. package/dist/api/index.d.ts +4 -0
  26. package/dist/api/index.d.ts.map +1 -0
  27. package/dist/api/index.js +17 -0
  28. package/dist/api/index.js.map +1 -0
  29. package/dist/api/sign.d.ts +5 -0
  30. package/dist/api/sign.d.ts.map +1 -0
  31. package/dist/api/sign.js +25 -0
  32. package/dist/api/sign.js.map +1 -0
  33. package/dist/index.d.ts +5 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +18 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/modules/Manager.d.ts +22 -0
  38. package/dist/modules/Manager.d.ts.map +1 -0
  39. package/dist/modules/Manager.js +421 -0
  40. package/dist/modules/Manager.js.map +1 -0
  41. package/dist/modules/ProsopoCaptchaApi.d.ts +21 -0
  42. package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -0
  43. package/dist/modules/ProsopoCaptchaApi.js +100 -0
  44. package/dist/modules/ProsopoCaptchaApi.js.map +1 -0
  45. package/dist/modules/canvas.d.ts +13 -0
  46. package/dist/modules/canvas.d.ts.map +1 -0
  47. package/dist/modules/canvas.js +359 -0
  48. package/dist/modules/canvas.js.map +1 -0
  49. package/dist/modules/index.d.ts +3 -0
  50. package/dist/modules/index.d.ts.map +1 -0
  51. package/dist/modules/index.js +16 -0
  52. package/dist/modules/index.js.map +1 -0
  53. package/dist/modules/storage.d.ts +24 -0
  54. package/dist/modules/storage.d.ts.map +1 -0
  55. package/dist/modules/storage.js +46 -0
  56. package/dist/modules/storage.js.map +1 -0
  57. package/dist/types/api.d.ts +35 -0
  58. package/dist/types/api.d.ts.map +1 -0
  59. package/dist/types/api.js +21 -0
  60. package/dist/types/api.js.map +1 -0
  61. package/dist/types/client.d.ts +5 -0
  62. package/dist/types/client.d.ts.map +1 -0
  63. package/dist/types/client.js +2 -0
  64. package/dist/types/client.js.map +1 -0
  65. package/dist/types/contract.d.ts +5 -0
  66. package/dist/types/contract.d.ts.map +1 -0
  67. package/dist/types/contract.js +2 -0
  68. package/dist/types/contract.js.map +1 -0
  69. package/dist/types/index.d.ts +5 -0
  70. package/dist/types/index.d.ts.map +1 -0
  71. package/dist/types/index.js +18 -0
  72. package/dist/types/index.js.map +1 -0
  73. package/dist/types/manager.d.ts +62 -0
  74. package/dist/types/manager.d.ts.map +1 -0
  75. package/dist/types/manager.js +9 -0
  76. package/dist/types/manager.js.map +1 -0
  77. package/dist/types/utils.d.ts +2 -0
  78. package/dist/types/utils.d.ts.map +1 -0
  79. package/dist/types/utils.js +2 -0
  80. package/dist/types/utils.js.map +1 -0
  81. package/dist/utils/index.d.ts +2 -0
  82. package/dist/utils/index.d.ts.map +1 -0
  83. package/dist/utils/index.js +15 -0
  84. package/dist/utils/index.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 +17 -0
  88. package/dist/utils/utils.js.map +1 -0
  89. package/package.json +7 -7
@@ -0,0 +1,62 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { GetCaptchaResponse } from '@prosopo/api';
3
+ import { InjectedAccount, InjectedExtension } from '@polkadot/extension-inject/types';
4
+ import { ProcaptchaClientConfig, ProcaptchaOutput } from '@prosopo/types';
5
+ import { ProsopoCaptchaApi } from '../modules/ProsopoCaptchaApi.js';
6
+ import { TCaptchaSubmitResult } from './client.js';
7
+ /**
8
+ * House the account and associated extension.
9
+ */
10
+ export interface Account {
11
+ account: InjectedAccount;
12
+ extension: InjectedExtension;
13
+ }
14
+ /**
15
+ * The config to be passed to procaptcha. Some fields can be optional, e.g.
16
+ * userAccountAddress and web2, depending on the mode of Procaptcha (web2 or web3).
17
+ */
18
+ export type ProcaptchaConfigOptional = ProcaptchaClientConfig;
19
+ /**
20
+ * The state of Procaptcha. This is mutated as required to reflect the captcha
21
+ * process.
22
+ */
23
+ export interface ProcaptchaState {
24
+ isHuman: boolean;
25
+ index: number;
26
+ solutions: string[][];
27
+ captchaApi: ProsopoCaptchaApi | undefined;
28
+ challenge: GetCaptchaResponse | undefined;
29
+ showModal: boolean;
30
+ loading: boolean;
31
+ account: Account | undefined;
32
+ dappAccount: string | undefined;
33
+ submission: TCaptchaSubmitResult | undefined;
34
+ timeout: NodeJS.Timeout | undefined;
35
+ blockNumber: number | undefined;
36
+ }
37
+ /**
38
+ * Function to update the state of the Procaptcha component. This is a partial
39
+ * state which is coalesced with the existing state, replacing any fields that
40
+ * are defined and using values from the current state for any undefined state
41
+ * variables.
42
+ */
43
+ export type ProcaptchaStateUpdateFn = (state: Partial<ProcaptchaState>) => void;
44
+ /**
45
+ * A set of callbacks called by Procaptcha on certain events. These are optional
46
+ * as the client can decide which events they wish to listen for.
47
+ */
48
+ export type ProcaptchaCallbacks = Partial<ProcaptchaEvents>;
49
+ /**
50
+ * A list of all events which can occur during the Procaptcha process.
51
+ */
52
+ export interface ProcaptchaEvents {
53
+ onError: (error: Error) => void;
54
+ onAccountNotFound: (address: string) => void;
55
+ onHuman: (output: ProcaptchaOutput) => void;
56
+ onExtensionNotFound: () => void;
57
+ onExpired: () => void;
58
+ onFailed: () => void;
59
+ }
60
+ export type TProcaptchaEventNames = keyof ProcaptchaEvents;
61
+ export declare const ProcapchaEventNames: TProcaptchaEventNames[];
62
+ //# 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,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACrF,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,iBAAiB,CAAA;CAC/B;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,CAAA;AAE7D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,EAAE,EAAE,CAAA;IACrB,UAAU,EAAE,iBAAiB,GAAG,SAAS,CAAA;IACzC,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACzC,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAA;IAC5C,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAA;IACnC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;CAClC;AAED;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;AAE/E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/B,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC3C,mBAAmB,EAAE,MAAM,IAAI,CAAA;IAC/B,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG,MAAM,gBAAgB,CAAA;AAE1D,eAAO,MAAM,mBAAmB,EAAE,qBAAqB,EAOtD,CAAA"}
@@ -0,0 +1,9 @@
1
+ export const ProcapchaEventNames = [
2
+ 'onError',
3
+ 'onAccountNotFound',
4
+ 'onHuman',
5
+ 'onExtensionNotFound',
6
+ 'onExpired',
7
+ 'onFailed',
8
+ ];
9
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/types/manager.ts"],"names":[],"mappings":"AA+EA,MAAM,CAAC,MAAM,mBAAmB,GAA4B;IACxD,SAAS;IACT,mBAAmB;IACnB,SAAS;IACT,qBAAqB;IACrB,WAAW;IACX,UAAU;CACb,CAAA"}
@@ -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,2 @@
1
+ export {};
2
+ //# 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 * from './utils.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export * from './utils.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const sleep: (ms: number) => 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,OAAQ,MAAM,qBAE/B,CAAA"}
@@ -0,0 +1,17 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export const sleep = (ms) => {
15
+ return new Promise((resolve) => setTimeout(resolve, ms));
16
+ };
17
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE;IAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -35,12 +35,12 @@
35
35
  "@polkadot/types": "10.9.1",
36
36
  "@polkadot/util": "12.3.2",
37
37
  "@polkadot/util-crypto": "12.3.2",
38
- "@prosopo/api": "^0.1.18",
39
- "@prosopo/common": "^0.1.18",
40
- "@prosopo/contract": "^0.1.18",
41
- "@prosopo/datasets": "^0.1.18",
42
- "@prosopo/types": "^0.1.18",
43
- "@prosopo/util": "^0.1.18",
38
+ "@prosopo/api": "^0.1.19",
39
+ "@prosopo/common": "^0.1.19",
40
+ "@prosopo/contract": "^0.1.19",
41
+ "@prosopo/datasets": "^0.1.19",
42
+ "@prosopo/types": "^0.1.19",
43
+ "@prosopo/util": "^0.1.19",
44
44
  "axios": "^0.27.2"
45
45
  },
46
46
  "devDependencies": {