@prosopo/types 2.5.3 → 2.6.1

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 (48) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/api/api.cjs +1 -0
  3. package/dist/cjs/api/index.cjs +5 -0
  4. package/dist/cjs/api/params.cjs +42 -0
  5. package/dist/cjs/client/captchaType/captchaType.cjs +9 -0
  6. package/dist/cjs/client/captchaType/captchaTypeSpec.cjs +6 -0
  7. package/dist/cjs/client/index.cjs +17 -0
  8. package/dist/cjs/client/settings.cjs +23 -0
  9. package/dist/cjs/client/user.cjs +33 -0
  10. package/dist/cjs/config/config.cjs +210 -0
  11. package/dist/cjs/config/frictionless.cjs +8 -0
  12. package/dist/cjs/config/index.cjs +32 -0
  13. package/dist/cjs/config/network.cjs +10 -0
  14. package/dist/cjs/config/timeouts.cjs +19 -0
  15. package/dist/cjs/datasets/assets.cjs +1 -0
  16. package/dist/cjs/datasets/captcha.cjs +128 -0
  17. package/dist/cjs/datasets/dataset.cjs +32 -0
  18. package/dist/cjs/datasets/index.cjs +35 -0
  19. package/dist/cjs/datasets/merkle.cjs +1 -0
  20. package/dist/cjs/index.cjs +128 -0
  21. package/dist/cjs/procaptcha/api.cjs +1 -0
  22. package/dist/cjs/procaptcha/client.cjs +1 -0
  23. package/dist/cjs/procaptcha/collector.cjs +1 -0
  24. package/dist/cjs/procaptcha/index.cjs +19 -0
  25. package/dist/cjs/procaptcha/manager.cjs +10 -0
  26. package/dist/cjs/procaptcha/props.cjs +1 -0
  27. package/dist/cjs/procaptcha/token.cjs +89 -0
  28. package/dist/cjs/procaptcha/utils.cjs +1 -0
  29. package/dist/cjs/procaptcha-bundle/index.cjs +1 -0
  30. package/dist/cjs/procaptcha-frictionless/index.cjs +2 -0
  31. package/dist/cjs/procaptcha-frictionless/props.cjs +1 -0
  32. package/dist/cjs/provider/accounts.cjs +8 -0
  33. package/dist/cjs/provider/api.cjs +219 -0
  34. package/dist/cjs/provider/argv.cjs +6 -0
  35. package/dist/cjs/provider/index.cjs +30 -0
  36. package/dist/cjs/provider/scheduler.cjs +18 -0
  37. package/dist/client/settings.d.ts +4 -0
  38. package/dist/client/settings.d.ts.map +1 -1
  39. package/dist/client/settings.js +2 -0
  40. package/dist/client/settings.js.map +1 -1
  41. package/dist/client/user.d.ts +1 -1
  42. package/dist/client/user.d.ts.map +1 -1
  43. package/dist/config/config.d.ts +3 -3
  44. package/dist/procaptcha-bundle/index.d.ts +4 -4
  45. package/dist/procaptcha-bundle/index.d.ts.map +1 -1
  46. package/dist/provider/api.d.ts +5 -0
  47. package/dist/provider/api.d.ts.map +1 -1
  48. package/package.json +10 -8
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @prosopo/types
2
+
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 52feffc: Adjustable difficulty img captcha
8
+
9
+ ## 2.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - a0bfc8a: bump all pkg versions since independent versioning applied
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [a0bfc8a]
18
+ - @prosopo/common@2.6.0
19
+ - @prosopo/locale@2.6.0
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./api.cjs");
4
+ const params = require("./params.cjs");
5
+ exports.ApiParams = params.ApiParams;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var ApiParams = /* @__PURE__ */ ((ApiParams2) => {
4
+ ApiParams2["datasetId"] = "datasetId";
5
+ ApiParams2["user"] = "user";
6
+ ApiParams2["dapp"] = "dapp";
7
+ ApiParams2["provider"] = "provider";
8
+ ApiParams2["blockNumber"] = "blockNumber";
9
+ ApiParams2["requestHash"] = "requestHash";
10
+ ApiParams2["captchas"] = "captchas";
11
+ ApiParams2["commitmentId"] = "commitmentId";
12
+ ApiParams2["proof"] = "proof";
13
+ ApiParams2["dappSignature"] = "dappSignature";
14
+ ApiParams2["dappUserSignature"] = "dappUserSignature";
15
+ ApiParams2["providerUrl"] = "providerUrl";
16
+ ApiParams2["procaptchaResponse"] = "procaptcha-response";
17
+ ApiParams2["verifiedTimeout"] = "verifiedTimeout";
18
+ ApiParams2["maxVerifiedTime"] = "maxVerifiedTime";
19
+ ApiParams2["verified"] = "verified";
20
+ ApiParams2["status"] = "status";
21
+ ApiParams2["challenge"] = "challenge";
22
+ ApiParams2["difficulty"] = "difficulty";
23
+ ApiParams2["nonce"] = "nonce";
24
+ ApiParams2["timeouts"] = "timeouts";
25
+ ApiParams2["token"] = "token";
26
+ ApiParams2["secret"] = "secret";
27
+ ApiParams2["timestamp"] = "timestamp";
28
+ ApiParams2["signature"] = "signature";
29
+ ApiParams2["error"] = "error";
30
+ ApiParams2["siteKey"] = "siteKey";
31
+ ApiParams2["captchaType"] = "captchaType";
32
+ ApiParams2["sessionId"] = "sessionId";
33
+ ApiParams2["settings"] = "settings";
34
+ ApiParams2["domains"] = "domains";
35
+ ApiParams2["frictionlessThreshold"] = "frictionlessThreshold";
36
+ ApiParams2["powDifficulty"] = "powDifficulty";
37
+ ApiParams2["score"] = "score";
38
+ ApiParams2["tier"] = "tier";
39
+ ApiParams2["detectorKey"] = "detectorKey";
40
+ return ApiParams2;
41
+ })(ApiParams || {});
42
+ exports.ApiParams = ApiParams;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var CaptchaType = /* @__PURE__ */ ((CaptchaType2) => {
4
+ CaptchaType2["image"] = "image";
5
+ CaptchaType2["pow"] = "pow";
6
+ CaptchaType2["frictionless"] = "frictionless";
7
+ return CaptchaType2;
8
+ })(CaptchaType || {});
9
+ exports.CaptchaType = CaptchaType;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ const captchaType = require("./captchaType.cjs");
5
+ const CaptchaTypeSpec = z.nativeEnum(captchaType.CaptchaType);
6
+ exports.CaptchaTypeSpec = CaptchaTypeSpec;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const user = require("./user.cjs");
4
+ const settings = require("./settings.cjs");
5
+ const captchaType = require("./captchaType/captchaType.cjs");
6
+ const captchaTypeSpec = require("./captchaType/captchaTypeSpec.cjs");
7
+ exports.Tier = user.Tier;
8
+ exports.TierMonthlyLimits = user.TierMonthlyLimits;
9
+ exports.TierSchema = user.TierSchema;
10
+ exports.ClientSettingsSchema = settings.ClientSettingsSchema;
11
+ exports.captchaTypeDefault = settings.captchaTypeDefault;
12
+ exports.domainsDefault = settings.domainsDefault;
13
+ exports.frictionlessThresholdDefault = settings.frictionlessThresholdDefault;
14
+ exports.imageThresholdDefault = settings.imageThresholdDefault;
15
+ exports.powDifficultyDefault = settings.powDifficultyDefault;
16
+ exports.CaptchaType = captchaType.CaptchaType;
17
+ exports.CaptchaTypeSpec = captchaTypeSpec.CaptchaTypeSpec;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ const captchaType = require("./captchaType/captchaType.cjs");
5
+ const captchaTypeSpec = require("./captchaType/captchaTypeSpec.cjs");
6
+ const captchaTypeDefault = captchaType.CaptchaType.frictionless;
7
+ const domainsDefault = [];
8
+ const frictionlessThresholdDefault = 0.5;
9
+ const powDifficultyDefault = 4;
10
+ const imageThresholdDefault = 0.8;
11
+ const ClientSettingsSchema = z.object({
12
+ captchaType: captchaTypeSpec.CaptchaTypeSpec.default(captchaTypeDefault),
13
+ domains: z.array(z.string()).default([...domainsDefault]),
14
+ frictionlessThreshold: z.number().default(frictionlessThresholdDefault),
15
+ powDifficulty: z.number().default(powDifficultyDefault),
16
+ imageThreshold: z.number().default(imageThresholdDefault)
17
+ });
18
+ exports.ClientSettingsSchema = ClientSettingsSchema;
19
+ exports.captchaTypeDefault = captchaTypeDefault;
20
+ exports.domainsDefault = domainsDefault;
21
+ exports.frictionlessThresholdDefault = frictionlessThresholdDefault;
22
+ exports.imageThresholdDefault = imageThresholdDefault;
23
+ exports.powDifficultyDefault = powDifficultyDefault;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ var Tier = /* @__PURE__ */ ((Tier2) => {
5
+ Tier2["Free"] = "free";
6
+ Tier2["Professional"] = "professional";
7
+ Tier2["Enterprise"] = "enterprise";
8
+ return Tier2;
9
+ })(Tier || {});
10
+ const TierSchema = z.z.nativeEnum(Tier);
11
+ const TierMonthlyLimits = {
12
+ [
13
+ "free"
14
+ /* Free */
15
+ ]: {
16
+ verificationRequests: 1e5
17
+ },
18
+ [
19
+ "professional"
20
+ /* Professional */
21
+ ]: {
22
+ verificationRequests: 1e6
23
+ },
24
+ [
25
+ "enterprise"
26
+ /* Enterprise */
27
+ ]: {
28
+ verificationRequests: "Unlimited"
29
+ }
30
+ };
31
+ exports.Tier = Tier;
32
+ exports.TierMonthlyLimits = TierMonthlyLimits;
33
+ exports.TierSchema = TierSchema;
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const locale = require("@prosopo/locale");
4
+ const z = require("zod");
5
+ require("../provider/index.cjs");
6
+ const frictionless = require("./frictionless.cjs");
7
+ const timeouts = require("./timeouts.cjs");
8
+ const api = require("../provider/api.cjs");
9
+ const LogLevel = z.enum([
10
+ "trace",
11
+ "debug",
12
+ "info",
13
+ "warn",
14
+ "error",
15
+ "fatal",
16
+ "log"
17
+ ]);
18
+ const DatabaseTypes = z.enum([
19
+ "mongo",
20
+ "mongoMemory",
21
+ "provider",
22
+ "client",
23
+ "captcha"
24
+ ]);
25
+ const EnvironmentTypesSchema = z.enum([
26
+ "development",
27
+ "staging",
28
+ "production"
29
+ ]);
30
+ const DatabaseConfigSchema = z.record(
31
+ EnvironmentTypesSchema,
32
+ z.object({
33
+ type: z.string(),
34
+ endpoint: z.string(),
35
+ dbname: z.string().default("prosopo"),
36
+ authSource: z.string().default("admin")
37
+ })
38
+ );
39
+ const ProsopoBaseConfigSchema = z.object({
40
+ logLevel: LogLevel.optional().default(LogLevel.enum.info),
41
+ defaultEnvironment: EnvironmentTypesSchema.default(
42
+ EnvironmentTypesSchema.Values.production
43
+ ),
44
+ // The account with which to query the contract.merge sign transactions
45
+ account: z.object({
46
+ address: z.string().optional(),
47
+ secret: z.string().optional(),
48
+ password: z.string().optional()
49
+ })
50
+ });
51
+ const PolkadotSecretJSONSpec = z.object({
52
+ encoded: z.string(),
53
+ encoding: z.object({
54
+ content: z.array(z.string()),
55
+ type: z.array(z.string()),
56
+ version: z.string()
57
+ }),
58
+ address: z.string(),
59
+ meta: z.object({
60
+ genesisHash: z.string(),
61
+ name: z.string(),
62
+ whenCreated: z.number()
63
+ })
64
+ });
65
+ const ProsopoBasicConfigSchema = ProsopoBaseConfigSchema.merge(
66
+ z.object({
67
+ database: DatabaseConfigSchema.optional(),
68
+ devOnlyWatchEvents: z.boolean().optional()
69
+ })
70
+ );
71
+ const ProsopoImageServerConfigSchema = z.object({
72
+ baseURL: z.string().url(),
73
+ port: z.number().optional().default(9229)
74
+ });
75
+ const ProsopoCaptchaSolutionConfigSchema = z.object({
76
+ requiredNumberOfSolutions: z.number().positive().min(2),
77
+ solutionWinningPercentage: z.number().positive().max(100),
78
+ captchaBlockRecency: z.number().positive().min(2)
79
+ });
80
+ const ProsopoClientConfigSchema = ProsopoBasicConfigSchema.merge(
81
+ z.object({
82
+ userAccountAddress: z.string().optional(),
83
+ web2: z.boolean().optional().default(true),
84
+ solutionThreshold: z.number().positive().max(100).optional().default(80),
85
+ dappName: z.string().optional().default("ProsopoClientDapp"),
86
+ serverUrl: z.string().optional()
87
+ })
88
+ );
89
+ const defaultImageCaptchaTimeouts = {
90
+ challengeTimeout: timeouts.DEFAULT_IMAGE_CAPTCHA_TIMEOUT,
91
+ solutionTimeout: timeouts.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT,
92
+ verifiedTimeout: timeouts.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT,
93
+ cachedTimeout: timeouts.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED
94
+ };
95
+ const defaultPoWCaptchaTimeouts = {
96
+ challengeTimeout: timeouts.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT,
97
+ solutionTimeout: timeouts.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT,
98
+ cachedTimeout: timeouts.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT
99
+ };
100
+ const defaultContractCaptchaTimeouts = {
101
+ maxVerifiedTime: timeouts.DEFAULT_MAX_VERIFIED_TIME_CONTRACT
102
+ };
103
+ const defaultCaptchaTimeouts = {
104
+ image: defaultImageCaptchaTimeouts,
105
+ pow: defaultPoWCaptchaTimeouts,
106
+ contract: defaultContractCaptchaTimeouts
107
+ };
108
+ const CaptchaTimeoutSchema = z.object({
109
+ image: z.object({
110
+ // Set this to a default value for the frontend
111
+ challengeTimeout: z.number().positive().optional().default(timeouts.DEFAULT_IMAGE_CAPTCHA_TIMEOUT),
112
+ // Set this to a default value for the frontend
113
+ solutionTimeout: z.number().positive().optional().default(timeouts.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT),
114
+ verifiedTimeout: z.number().positive().optional().default(timeouts.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT),
115
+ cachedTimeout: z.number().positive().optional().default(timeouts.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED)
116
+ }).default(defaultImageCaptchaTimeouts),
117
+ pow: z.object({
118
+ verifiedTimeout: z.number().positive().optional().default(timeouts.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT),
119
+ solutionTimeout: z.number().positive().optional().default(timeouts.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT),
120
+ cachedTimeout: z.number().positive().optional().default(timeouts.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT)
121
+ }).default(defaultPoWCaptchaTimeouts),
122
+ contract: z.object({
123
+ maxVerifiedTime: z.number().positive().optional().default(timeouts.DEFAULT_MAX_VERIFIED_TIME_CONTRACT)
124
+ }).default(defaultContractCaptchaTimeouts)
125
+ }).default(defaultCaptchaTimeouts);
126
+ const ProsopoServerConfigSchema = ProsopoClientConfigSchema.merge(
127
+ z.object({
128
+ serverUrl: z.string().url().optional(),
129
+ timeouts: CaptchaTimeoutSchema.optional().default(defaultCaptchaTimeouts)
130
+ })
131
+ );
132
+ const AccountCreatorConfigSchema = z.object({
133
+ area: z.object({
134
+ width: z.number().positive(),
135
+ height: z.number().positive()
136
+ }),
137
+ offsetParameter: z.number().positive(),
138
+ multiplier: z.number().positive(),
139
+ fontSizeFactor: z.number().positive(),
140
+ maxShadowBlur: z.number().positive(),
141
+ numberOfRounds: z.number().positive(),
142
+ seed: z.number().positive()
143
+ });
144
+ const ThemeType = z.union([z.literal("light"), z.literal("dark")]);
145
+ var ModeEnum = /* @__PURE__ */ ((ModeEnum2) => {
146
+ ModeEnum2["visible"] = "visible";
147
+ ModeEnum2["invisible"] = "invisible";
148
+ return ModeEnum2;
149
+ })(ModeEnum || {});
150
+ const Mode = z.enum([
151
+ "visible",
152
+ "invisible"
153
+ /* invisible */
154
+ ]).optional();
155
+ const ProcaptchaConfigSchema = ProsopoClientConfigSchema.and(
156
+ z.object({
157
+ theme: ThemeType.optional().default("light"),
158
+ captchas: CaptchaTimeoutSchema.optional().default(defaultCaptchaTimeouts),
159
+ language: locale.LanguageSchema.optional(),
160
+ mode: Mode.optional().default(
161
+ "visible"
162
+ /* visible */
163
+ )
164
+ })
165
+ );
166
+ const ProsopoConfigSchema = ProsopoBasicConfigSchema.merge(
167
+ z.object({
168
+ captchas: api.ProsopoCaptchaCountConfigSchema.optional().default({
169
+ solved: { count: 1 },
170
+ unsolved: { count: 0 }
171
+ }),
172
+ penalties: frictionless.FrictionlessPenalties,
173
+ scheduledTasks: z.object({
174
+ captchaScheduler: z.object({
175
+ schedule: z.string().optional()
176
+ }).optional(),
177
+ clientListScheduler: z.object({
178
+ schedule: z.string().optional()
179
+ }).optional()
180
+ }).optional(),
181
+ server: ProsopoImageServerConfigSchema,
182
+ mongoEventsUri: z.string().optional(),
183
+ mongoCaptchaUri: z.string().optional(),
184
+ mongoClientUri: z.string().optional(),
185
+ rateLimits: api.ApiPathRateLimits.default(api.ProviderDefaultRateLimits),
186
+ proxyCount: z.number().optional().default(0),
187
+ lRules: z.record(z.string(), z.number()).optional(),
188
+ authAccount: z.object({
189
+ address: z.string().optional(),
190
+ secret: z.string().optional(),
191
+ password: z.string().optional()
192
+ })
193
+ })
194
+ );
195
+ exports.AccountCreatorConfigSchema = AccountCreatorConfigSchema;
196
+ exports.CaptchaTimeoutSchema = CaptchaTimeoutSchema;
197
+ exports.DatabaseConfigSchema = DatabaseConfigSchema;
198
+ exports.DatabaseTypes = DatabaseTypes;
199
+ exports.EnvironmentTypesSchema = EnvironmentTypesSchema;
200
+ exports.Mode = Mode;
201
+ exports.ModeEnum = ModeEnum;
202
+ exports.PolkadotSecretJSONSpec = PolkadotSecretJSONSpec;
203
+ exports.ProcaptchaConfigSchema = ProcaptchaConfigSchema;
204
+ exports.ProsopoBaseConfigSchema = ProsopoBaseConfigSchema;
205
+ exports.ProsopoBasicConfigSchema = ProsopoBasicConfigSchema;
206
+ exports.ProsopoCaptchaSolutionConfigSchema = ProsopoCaptchaSolutionConfigSchema;
207
+ exports.ProsopoClientConfigSchema = ProsopoClientConfigSchema;
208
+ exports.ProsopoConfigSchema = ProsopoConfigSchema;
209
+ exports.ProsopoImageServerConfigSchema = ProsopoImageServerConfigSchema;
210
+ exports.ProsopoServerConfigSchema = ProsopoServerConfigSchema;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ const FrictionlessPenalties = z.object({
5
+ PENALTY_OLD_TIMESTAMP: z.number().positive().optional().default(0.2),
6
+ PENALTY_ACCESS_RULE: z.number().positive().optional().default(0.5)
7
+ });
8
+ exports.FrictionlessPenalties = FrictionlessPenalties;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const config = require("./config.cjs");
4
+ const network = require("./network.cjs");
5
+ const timeouts = require("./timeouts.cjs");
6
+ const frictionless = require("./frictionless.cjs");
7
+ exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
8
+ exports.CaptchaTimeoutSchema = config.CaptchaTimeoutSchema;
9
+ exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
10
+ exports.DatabaseTypes = config.DatabaseTypes;
11
+ exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
12
+ exports.Mode = config.Mode;
13
+ exports.ModeEnum = config.ModeEnum;
14
+ exports.PolkadotSecretJSONSpec = config.PolkadotSecretJSONSpec;
15
+ exports.ProcaptchaConfigSchema = config.ProcaptchaConfigSchema;
16
+ exports.ProsopoBaseConfigSchema = config.ProsopoBaseConfigSchema;
17
+ exports.ProsopoBasicConfigSchema = config.ProsopoBasicConfigSchema;
18
+ exports.ProsopoCaptchaSolutionConfigSchema = config.ProsopoCaptchaSolutionConfigSchema;
19
+ exports.ProsopoClientConfigSchema = config.ProsopoClientConfigSchema;
20
+ exports.ProsopoConfigSchema = config.ProsopoConfigSchema;
21
+ exports.ProsopoImageServerConfigSchema = config.ProsopoImageServerConfigSchema;
22
+ exports.ProsopoServerConfigSchema = config.ProsopoServerConfigSchema;
23
+ exports.NetworkPairTypeSchema = network.NetworkPairTypeSchema;
24
+ exports.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = timeouts.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT;
25
+ exports.DEFAULT_IMAGE_CAPTCHA_TIMEOUT = timeouts.DEFAULT_IMAGE_CAPTCHA_TIMEOUT;
26
+ exports.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = timeouts.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT;
27
+ exports.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = timeouts.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED;
28
+ exports.DEFAULT_MAX_VERIFIED_TIME_CONTRACT = timeouts.DEFAULT_MAX_VERIFIED_TIME_CONTRACT;
29
+ exports.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = timeouts.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT;
30
+ exports.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = timeouts.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT;
31
+ exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = timeouts.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT;
32
+ exports.FrictionlessPenalties = frictionless.FrictionlessPenalties;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ const NetworkPairTypeSchema = z.union([
5
+ z.literal("sr25519"),
6
+ z.literal("ed25519"),
7
+ z.literal("ecdsa"),
8
+ z.literal("ethereum")
9
+ ]);
10
+ exports.NetworkPairTypeSchema = NetworkPairTypeSchema;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const ONE_MINUTE = 60 * 1e3;
4
+ const DEFAULT_IMAGE_CAPTCHA_TIMEOUT = ONE_MINUTE;
5
+ const DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 2;
6
+ const DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 3;
7
+ const DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 15;
8
+ const DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = ONE_MINUTE;
9
+ const DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 2;
10
+ const DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 3;
11
+ const DEFAULT_MAX_VERIFIED_TIME_CONTRACT = ONE_MINUTE * 15;
12
+ exports.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT;
13
+ exports.DEFAULT_IMAGE_CAPTCHA_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT;
14
+ exports.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT;
15
+ exports.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED;
16
+ exports.DEFAULT_MAX_VERIFIED_TIME_CONTRACT = DEFAULT_MAX_VERIFIED_TIME_CONTRACT;
17
+ exports.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT;
18
+ exports.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT;
19
+ exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ var CaptchaTypes = /* @__PURE__ */ ((CaptchaTypes2) => {
5
+ CaptchaTypes2["SelectAll"] = "SelectAll";
6
+ return CaptchaTypes2;
7
+ })(CaptchaTypes || {});
8
+ var CaptchaItemTypes = /* @__PURE__ */ ((CaptchaItemTypes2) => {
9
+ CaptchaItemTypes2["Text"] = "text";
10
+ CaptchaItemTypes2["Image"] = "image";
11
+ return CaptchaItemTypes2;
12
+ })(CaptchaItemTypes || {});
13
+ var CaptchaStates = /* @__PURE__ */ ((CaptchaStates2) => {
14
+ CaptchaStates2["Solved"] = "solved";
15
+ CaptchaStates2["Unsolved"] = "unsolved";
16
+ return CaptchaStates2;
17
+ })(CaptchaStates || {});
18
+ var CaptchaStatus = /* @__PURE__ */ ((CaptchaStatus2) => {
19
+ CaptchaStatus2["pending"] = "Pending";
20
+ CaptchaStatus2["approved"] = "Approved";
21
+ CaptchaStatus2["disapproved"] = "Disapproved";
22
+ return CaptchaStatus2;
23
+ })(CaptchaStatus || {});
24
+ var GovernanceStatus = /* @__PURE__ */ ((GovernanceStatus2) => {
25
+ GovernanceStatus2["active"] = "Active";
26
+ GovernanceStatus2["inactive"] = "Inactive";
27
+ return GovernanceStatus2;
28
+ })(GovernanceStatus || {});
29
+ var DappPayee = /* @__PURE__ */ ((DappPayee2) => {
30
+ DappPayee2["provider"] = "Provider";
31
+ DappPayee2["dapp"] = "Dapp";
32
+ DappPayee2["any"] = "Any";
33
+ return DappPayee2;
34
+ })(DappPayee || {});
35
+ const TimestampSchema = z.number();
36
+ const POW_SEPARATOR = "___";
37
+ const PowChallengeIdSchema = z.custom((val) => {
38
+ const valSplit = val.split(POW_SEPARATOR);
39
+ try {
40
+ Number.parseInt(valSplit[0]);
41
+ return valSplit.length === 4;
42
+ } catch (e) {
43
+ return false;
44
+ }
45
+ });
46
+ const CaptchaSchema = z.object({
47
+ captchaId: z.union([z.string(), z.undefined()]),
48
+ captchaContentId: z.union([z.string(), z.undefined()]),
49
+ salt: z.string().min(34),
50
+ solution: z.number().array().optional(),
51
+ unlabelled: z.number().array().optional(),
52
+ timeLimit: z.number().optional()
53
+ });
54
+ const CaptchaItemSchema = z.object({
55
+ hash: z.string(),
56
+ data: z.string(),
57
+ type: z.nativeEnum(CaptchaItemTypes)
58
+ });
59
+ const HashedCaptchaItemSchema = CaptchaItemSchema.extend({
60
+ hash: z.string()
61
+ });
62
+ const LabelledItemSchema = HashedCaptchaItemSchema.extend({
63
+ label: z.string()
64
+ });
65
+ const MaybeLabelledHashedItemSchema = HashedCaptchaItemSchema.extend({
66
+ label: z.string().optional()
67
+ });
68
+ const SelectAllCaptchaSchemaRaw = CaptchaSchema.extend({
69
+ items: z.array(CaptchaItemSchema),
70
+ target: z.string()
71
+ });
72
+ const SelectAllCaptchaSchema = SelectAllCaptchaSchemaRaw.extend({
73
+ solution: z.string().array().optional(),
74
+ unlabelled: z.string().array().optional()
75
+ });
76
+ const SelectAllCaptchaSchemaWithNumericSolution = SelectAllCaptchaSchema.extend({
77
+ solution: z.number().array().optional(),
78
+ unlabelled: z.number().array().optional()
79
+ });
80
+ const CaptchasSchema = z.array(SelectAllCaptchaSchemaRaw);
81
+ const CaptchasWithNumericSolutionSchema = z.array(
82
+ SelectAllCaptchaSchemaWithNumericSolution
83
+ );
84
+ const CaptchaSolutionSchema = z.object({
85
+ captchaId: z.string(),
86
+ captchaContentId: z.string(),
87
+ solution: z.string().array(),
88
+ salt: z.string().min(34)
89
+ });
90
+ const CaptchaSolutionArraySchema = z.array(CaptchaSolutionSchema);
91
+ const DataSchema = z.object({
92
+ items: z.array(MaybeLabelledHashedItemSchema)
93
+ });
94
+ const LabelledDataSchema = z.object({
95
+ items: z.array(LabelledItemSchema)
96
+ });
97
+ const CaptchasContainerSchema = z.object({
98
+ captchas: CaptchasSchema,
99
+ format: z.nativeEnum(CaptchaTypes)
100
+ });
101
+ const LabelsContainerSchema = z.object({
102
+ labels: z.array(z.string())
103
+ });
104
+ exports.CaptchaItemSchema = CaptchaItemSchema;
105
+ exports.CaptchaItemTypes = CaptchaItemTypes;
106
+ exports.CaptchaSchema = CaptchaSchema;
107
+ exports.CaptchaSolutionArraySchema = CaptchaSolutionArraySchema;
108
+ exports.CaptchaSolutionSchema = CaptchaSolutionSchema;
109
+ exports.CaptchaStates = CaptchaStates;
110
+ exports.CaptchaStatus = CaptchaStatus;
111
+ exports.CaptchaTypes = CaptchaTypes;
112
+ exports.CaptchasContainerSchema = CaptchasContainerSchema;
113
+ exports.CaptchasSchema = CaptchasSchema;
114
+ exports.CaptchasWithNumericSolutionSchema = CaptchasWithNumericSolutionSchema;
115
+ exports.DappPayee = DappPayee;
116
+ exports.DataSchema = DataSchema;
117
+ exports.GovernanceStatus = GovernanceStatus;
118
+ exports.HashedCaptchaItemSchema = HashedCaptchaItemSchema;
119
+ exports.LabelledDataSchema = LabelledDataSchema;
120
+ exports.LabelledItemSchema = LabelledItemSchema;
121
+ exports.LabelsContainerSchema = LabelsContainerSchema;
122
+ exports.MaybeLabelledHashedItemSchema = MaybeLabelledHashedItemSchema;
123
+ exports.POW_SEPARATOR = POW_SEPARATOR;
124
+ exports.PowChallengeIdSchema = PowChallengeIdSchema;
125
+ exports.SelectAllCaptchaSchema = SelectAllCaptchaSchema;
126
+ exports.SelectAllCaptchaSchemaRaw = SelectAllCaptchaSchemaRaw;
127
+ exports.SelectAllCaptchaSchemaWithNumericSolution = SelectAllCaptchaSchemaWithNumericSolution;
128
+ exports.TimestampSchema = TimestampSchema;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ const captcha = require("./captcha.cjs");
5
+ const DatasetSchema = z.object({
6
+ datasetId: z.string().optional(),
7
+ datasetContentId: z.string().optional(),
8
+ captchas: captcha.CaptchasSchema,
9
+ format: z.nativeEnum(captcha.CaptchaTypes),
10
+ solutionTree: z.array(z.array(z.string())).optional(),
11
+ contentTree: z.array(z.array(z.string())).optional(),
12
+ timeLimit: z.number().optional()
13
+ });
14
+ const DatasetWithNumericSolutionSchema = DatasetSchema.extend({
15
+ captchas: captcha.CaptchasWithNumericSolutionSchema
16
+ });
17
+ const DatasetWithIdsSchema = z.object({
18
+ datasetId: z.string(),
19
+ datasetContentId: z.string().optional(),
20
+ captchas: z.array(captcha.SelectAllCaptchaSchema),
21
+ format: z.nativeEnum(captcha.CaptchaTypes),
22
+ solutionTree: z.array(z.array(z.string())).optional(),
23
+ contentTree: z.array(z.array(z.string())).optional()
24
+ });
25
+ const DatasetWithIdsAndTreeSchema = DatasetWithIdsSchema.extend({
26
+ solutionTree: z.array(z.array(z.string())),
27
+ contentTree: z.array(z.array(z.string()))
28
+ });
29
+ exports.DatasetSchema = DatasetSchema;
30
+ exports.DatasetWithIdsAndTreeSchema = DatasetWithIdsAndTreeSchema;
31
+ exports.DatasetWithIdsSchema = DatasetWithIdsSchema;
32
+ exports.DatasetWithNumericSolutionSchema = DatasetWithNumericSolutionSchema;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const captcha = require("./captcha.cjs");
4
+ const dataset = require("./dataset.cjs");
5
+ require("./merkle.cjs");
6
+ require("./assets.cjs");
7
+ exports.CaptchaItemSchema = captcha.CaptchaItemSchema;
8
+ exports.CaptchaItemTypes = captcha.CaptchaItemTypes;
9
+ exports.CaptchaSchema = captcha.CaptchaSchema;
10
+ exports.CaptchaSolutionArraySchema = captcha.CaptchaSolutionArraySchema;
11
+ exports.CaptchaSolutionSchema = captcha.CaptchaSolutionSchema;
12
+ exports.CaptchaStates = captcha.CaptchaStates;
13
+ exports.CaptchaStatus = captcha.CaptchaStatus;
14
+ exports.CaptchaTypes = captcha.CaptchaTypes;
15
+ exports.CaptchasContainerSchema = captcha.CaptchasContainerSchema;
16
+ exports.CaptchasSchema = captcha.CaptchasSchema;
17
+ exports.CaptchasWithNumericSolutionSchema = captcha.CaptchasWithNumericSolutionSchema;
18
+ exports.DappPayee = captcha.DappPayee;
19
+ exports.DataSchema = captcha.DataSchema;
20
+ exports.GovernanceStatus = captcha.GovernanceStatus;
21
+ exports.HashedCaptchaItemSchema = captcha.HashedCaptchaItemSchema;
22
+ exports.LabelledDataSchema = captcha.LabelledDataSchema;
23
+ exports.LabelledItemSchema = captcha.LabelledItemSchema;
24
+ exports.LabelsContainerSchema = captcha.LabelsContainerSchema;
25
+ exports.MaybeLabelledHashedItemSchema = captcha.MaybeLabelledHashedItemSchema;
26
+ exports.POW_SEPARATOR = captcha.POW_SEPARATOR;
27
+ exports.PowChallengeIdSchema = captcha.PowChallengeIdSchema;
28
+ exports.SelectAllCaptchaSchema = captcha.SelectAllCaptchaSchema;
29
+ exports.SelectAllCaptchaSchemaRaw = captcha.SelectAllCaptchaSchemaRaw;
30
+ exports.SelectAllCaptchaSchemaWithNumericSolution = captcha.SelectAllCaptchaSchemaWithNumericSolution;
31
+ exports.TimestampSchema = captcha.TimestampSchema;
32
+ exports.DatasetSchema = dataset.DatasetSchema;
33
+ exports.DatasetWithIdsAndTreeSchema = dataset.DatasetWithIdsAndTreeSchema;
34
+ exports.DatasetWithIdsSchema = dataset.DatasetWithIdsSchema;
35
+ exports.DatasetWithNumericSolutionSchema = dataset.DatasetWithNumericSolutionSchema;
@@ -0,0 +1 @@
1
+ "use strict";