@prosopo/types 3.0.6 → 3.5.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 (52) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/dist/api/index.d.ts +1 -0
  3. package/dist/api/index.d.ts.map +1 -1
  4. package/dist/api/index.js +1 -0
  5. package/dist/api/ipapi.d.ts +171 -0
  6. package/dist/api/ipapi.d.ts.map +1 -0
  7. package/dist/api/ipapi.js +1 -0
  8. package/dist/api/params.d.ts +2 -1
  9. package/dist/api/params.d.ts.map +1 -1
  10. package/dist/api/params.js +1 -0
  11. package/dist/cjs/api/index.cjs +1 -0
  12. package/dist/cjs/api/ipapi.cjs +1 -0
  13. package/dist/cjs/api/params.cjs +1 -0
  14. package/dist/cjs/client/index.cjs +11 -0
  15. package/dist/cjs/client/settings.cjs +65 -1
  16. package/dist/cjs/config/config.cjs +9 -1
  17. package/dist/cjs/config/frictionless.cjs +4 -1
  18. package/dist/cjs/config/index.cjs +2 -0
  19. package/dist/cjs/datasets/captcha.cjs +1 -1
  20. package/dist/cjs/index.cjs +15 -0
  21. package/dist/cjs/provider/api.cjs +15 -0
  22. package/dist/cjs/provider/detection.cjs +1 -0
  23. package/dist/cjs/provider/index.cjs +3 -0
  24. package/dist/client/index.js +13 -2
  25. package/dist/client/settings.d.ts +356 -8
  26. package/dist/client/settings.d.ts.map +1 -1
  27. package/dist/client/settings.js +67 -3
  28. package/dist/config/config.d.ts +37 -0
  29. package/dist/config/config.d.ts.map +1 -1
  30. package/dist/config/config.js +10 -2
  31. package/dist/config/frictionless.d.ts +4 -0
  32. package/dist/config/frictionless.d.ts.map +1 -1
  33. package/dist/config/frictionless.js +5 -2
  34. package/dist/config/index.js +4 -2
  35. package/dist/datasets/captcha.js +1 -1
  36. package/dist/index.js +20 -5
  37. package/dist/procaptcha/manager.d.ts +1 -1
  38. package/dist/procaptcha/manager.d.ts.map +1 -1
  39. package/dist/procaptcha/props.d.ts +1 -0
  40. package/dist/procaptcha/props.d.ts.map +1 -1
  41. package/dist/procaptcha-frictionless/props.d.ts +1 -1
  42. package/dist/procaptcha-frictionless/props.d.ts.map +1 -1
  43. package/dist/provider/api.d.ts +263 -1
  44. package/dist/provider/api.d.ts.map +1 -1
  45. package/dist/provider/api.js +17 -2
  46. package/dist/provider/detection.d.ts +8 -0
  47. package/dist/provider/detection.d.ts.map +1 -0
  48. package/dist/provider/detection.js +1 -0
  49. package/dist/provider/index.d.ts +1 -0
  50. package/dist/provider/index.d.ts.map +1 -1
  51. package/dist/provider/index.js +5 -2
  52. package/package.json +9 -12
@@ -29,11 +29,22 @@ exports.Tier = user.Tier;
29
29
  exports.TierMonthlyLimits = user.TierMonthlyLimits;
30
30
  exports.TierSchema = user.TierSchema;
31
31
  exports.ClientSettingsSchema = settings.ClientSettingsSchema;
32
+ exports.IPValidationAction = settings.IPValidationAction;
33
+ exports.IPValidationActionSchema = settings.IPValidationActionSchema;
34
+ exports.IPValidationRulesSchema = settings.IPValidationRulesSchema;
35
+ exports.abuseScoreThresholdDefault = settings.abuseScoreThresholdDefault;
36
+ exports.abuseScoreThresholdExceedActionDefault = settings.abuseScoreThresholdExceedActionDefault;
32
37
  exports.captchaTypeDefault = settings.captchaTypeDefault;
38
+ exports.cityChangeActionDefault = settings.cityChangeActionDefault;
39
+ exports.countryChangeActionDefault = settings.countryChangeActionDefault;
40
+ exports.distanceExceedActionDefault = settings.distanceExceedActionDefault;
41
+ exports.distanceThresholdKmDefault = settings.distanceThresholdKmDefault;
33
42
  exports.domainsDefault = settings.domainsDefault;
34
43
  exports.frictionlessThresholdDefault = settings.frictionlessThresholdDefault;
35
44
  exports.imageThresholdDefault = settings.imageThresholdDefault;
45
+ exports.ispChangeActionDefault = settings.ispChangeActionDefault;
36
46
  exports.powDifficultyDefault = settings.powDifficultyDefault;
47
+ exports.requireAllConditionsDefault = settings.requireAllConditionsDefault;
37
48
  exports.CaptchaType = captchaType.CaptchaType;
38
49
  exports.CaptchaTypeSchema = captchaType.CaptchaTypeSchema;
39
50
  exports.CaptchaTypeSpec = captchaTypeSpec.CaptchaTypeSpec;
@@ -42,6 +53,7 @@ exports.CaptchaTimeoutSchema = config.CaptchaTimeoutSchema;
42
53
  exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
43
54
  exports.DatabaseTypes = config.DatabaseTypes;
44
55
  exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
56
+ exports.IpApiServiceSpec = config.IpApiServiceSpec;
45
57
  exports.Mode = config.Mode;
46
58
  exports.ModeEnum = config.ModeEnum;
47
59
  exports.PolkadotSecretJSONSpec = config.PolkadotSecretJSONSpec;
@@ -65,6 +77,7 @@ exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = timeouts.DEFAULT_POW_CAPTCHA_VERI
65
77
  exports.FrictionlessPenalties = frictionless.FrictionlessPenalties;
66
78
  exports.PENALTY_ACCESS_RULE_DEFAULT = frictionless.PENALTY_ACCESS_RULE_DEFAULT;
67
79
  exports.PENALTY_OLD_TIMESTAMP_DEFAULT = frictionless.PENALTY_OLD_TIMESTAMP_DEFAULT;
80
+ exports.PENALTY_UNVERIFIED_HOST_DEFAULT = frictionless.PENALTY_UNVERIFIED_HOST_DEFAULT;
68
81
  exports.CaptchaItemSchema = captcha.CaptchaItemSchema;
69
82
  exports.CaptchaItemTypes = captcha.CaptchaItemTypes;
70
83
  exports.CaptchaSchema = captcha.CaptchaSchema;
@@ -112,11 +125,13 @@ exports.ProsopoCaptchaCountConfigSchema = api.ProsopoCaptchaCountConfigSchema;
112
125
  exports.ProviderDefaultRateLimits = api.ProviderDefaultRateLimits;
113
126
  exports.PublicApiPaths = api.PublicApiPaths;
114
127
  exports.RegisterSitekeyBody = api.RegisterSitekeyBody;
128
+ exports.RemoveDetectorKeyBodySpec = api.RemoveDetectorKeyBodySpec;
115
129
  exports.ServerPowCaptchaVerifyRequestBody = api.ServerPowCaptchaVerifyRequestBody;
116
130
  exports.SubmitPowCaptchaSolutionBody = api.SubmitPowCaptchaSolutionBody;
117
131
  exports.UpdateDetectorKeyBody = api.UpdateDetectorKeyBody;
118
132
  exports.VerifyPowCaptchaSolutionBody = api.VerifyPowCaptchaSolutionBody;
119
133
  exports.VerifySolutionBody = api.VerifySolutionBody;
134
+ exports.providerDetailsSchema = api.providerDetailsSchema;
120
135
  exports.ScheduledTaskNames = scheduler.ScheduledTaskNames;
121
136
  exports.ScheduledTaskStatus = scheduler.ScheduledTaskStatus;
122
137
  exports.ProcaptchaResponse = manager.ProcaptchaResponse;
@@ -30,6 +30,15 @@ var PublicApiPaths = /* @__PURE__ */ ((PublicApiPaths2) => {
30
30
  PublicApiPaths2["GetProviderDetails"] = "/v1/prosopo/provider/public/details";
31
31
  return PublicApiPaths2;
32
32
  })(PublicApiPaths || {});
33
+ const providerDetailsSchema = z.object({
34
+ version: z.string(),
35
+ message: z.string(),
36
+ redis: z.object({
37
+ actor: z.string(),
38
+ isReady: z.boolean(),
39
+ awaitingTimeSeconds: z.number()
40
+ }).array()
41
+ });
33
42
  var AdminApiPaths = /* @__PURE__ */ ((AdminApiPaths2) => {
34
43
  AdminApiPaths2["SiteKeyRegister"] = "/v1/prosopo/provider/admin/sitekey/register";
35
44
  AdminApiPaths2["UpdateDetectorKey"] = "/v1/prosopo/provider/admin/detector/update";
@@ -178,6 +187,10 @@ const RegisterSitekeyBody = z.object({
178
187
  const UpdateDetectorKeyBody = z.object({
179
188
  [params.ApiParams.detectorKey]: z.string()
180
189
  });
190
+ const RemoveDetectorKeyBodySpec = z.object({
191
+ [params.ApiParams.detectorKey]: z.string(),
192
+ [params.ApiParams.expirationInSeconds]: z.number().positive().optional()
193
+ });
181
194
  const ProsopoCaptchaCountConfigSchema = z.object({
182
195
  solved: z.object({
183
196
  count: z.number().positive()
@@ -219,8 +232,10 @@ exports.ProsopoCaptchaCountConfigSchema = ProsopoCaptchaCountConfigSchema;
219
232
  exports.ProviderDefaultRateLimits = ProviderDefaultRateLimits;
220
233
  exports.PublicApiPaths = PublicApiPaths;
221
234
  exports.RegisterSitekeyBody = RegisterSitekeyBody;
235
+ exports.RemoveDetectorKeyBodySpec = RemoveDetectorKeyBodySpec;
222
236
  exports.ServerPowCaptchaVerifyRequestBody = ServerPowCaptchaVerifyRequestBody;
223
237
  exports.SubmitPowCaptchaSolutionBody = SubmitPowCaptchaSolutionBody;
224
238
  exports.UpdateDetectorKeyBody = UpdateDetectorKeyBody;
225
239
  exports.VerifyPowCaptchaSolutionBody = VerifyPowCaptchaSolutionBody;
226
240
  exports.VerifySolutionBody = VerifySolutionBody;
241
+ exports.providerDetailsSchema = providerDetailsSchema;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./accounts.cjs");
4
4
  const api = require("./api.cjs");
5
5
  const scheduler = require("./scheduler.cjs");
6
+ require("./detection.cjs");
6
7
  exports.AdminApiPaths = api.AdminApiPaths;
7
8
  exports.ApiPathRateLimits = api.ApiPathRateLimits;
8
9
  exports.ApiPrefix = api.ApiPrefix;
@@ -20,10 +21,12 @@ exports.ProsopoCaptchaCountConfigSchema = api.ProsopoCaptchaCountConfigSchema;
20
21
  exports.ProviderDefaultRateLimits = api.ProviderDefaultRateLimits;
21
22
  exports.PublicApiPaths = api.PublicApiPaths;
22
23
  exports.RegisterSitekeyBody = api.RegisterSitekeyBody;
24
+ exports.RemoveDetectorKeyBodySpec = api.RemoveDetectorKeyBodySpec;
23
25
  exports.ServerPowCaptchaVerifyRequestBody = api.ServerPowCaptchaVerifyRequestBody;
24
26
  exports.SubmitPowCaptchaSolutionBody = api.SubmitPowCaptchaSolutionBody;
25
27
  exports.UpdateDetectorKeyBody = api.UpdateDetectorKeyBody;
26
28
  exports.VerifyPowCaptchaSolutionBody = api.VerifyPowCaptchaSolutionBody;
27
29
  exports.VerifySolutionBody = api.VerifySolutionBody;
30
+ exports.providerDetailsSchema = api.providerDetailsSchema;
28
31
  exports.ScheduledTaskNames = scheduler.ScheduledTaskNames;
29
32
  exports.ScheduledTaskStatus = scheduler.ScheduledTaskStatus;
@@ -1,5 +1,5 @@
1
1
  import { Tier, TierMonthlyLimits, TierSchema } from "./user.js";
2
- import { ClientSettingsSchema, captchaTypeDefault, domainsDefault, frictionlessThresholdDefault, imageThresholdDefault, powDifficultyDefault } from "./settings.js";
2
+ import { ClientSettingsSchema, IPValidationAction, IPValidationActionSchema, IPValidationRulesSchema, abuseScoreThresholdDefault, abuseScoreThresholdExceedActionDefault, captchaTypeDefault, cityChangeActionDefault, countryChangeActionDefault, distanceExceedActionDefault, distanceThresholdKmDefault, domainsDefault, frictionlessThresholdDefault, imageThresholdDefault, ispChangeActionDefault, powDifficultyDefault, requireAllConditionsDefault } from "./settings.js";
3
3
  import { CaptchaType, CaptchaTypeSchema } from "./captchaType/captchaType.js";
4
4
  import { CaptchaTypeSpec } from "./captchaType/captchaTypeSpec.js";
5
5
  export {
@@ -7,12 +7,23 @@ export {
7
7
  CaptchaTypeSchema,
8
8
  CaptchaTypeSpec,
9
9
  ClientSettingsSchema,
10
+ IPValidationAction,
11
+ IPValidationActionSchema,
12
+ IPValidationRulesSchema,
10
13
  Tier,
11
14
  TierMonthlyLimits,
12
15
  TierSchema,
16
+ abuseScoreThresholdDefault,
17
+ abuseScoreThresholdExceedActionDefault,
13
18
  captchaTypeDefault,
19
+ cityChangeActionDefault,
20
+ countryChangeActionDefault,
21
+ distanceExceedActionDefault,
22
+ distanceThresholdKmDefault,
14
23
  domainsDefault,
15
24
  frictionlessThresholdDefault,
16
25
  imageThresholdDefault,
17
- powDifficultyDefault
26
+ ispChangeActionDefault,
27
+ powDifficultyDefault,
28
+ requireAllConditionsDefault
18
29
  };
@@ -1,28 +1,376 @@
1
- import { type output } from "zod";
1
+ import { type output, z } from "zod";
2
2
  import { CaptchaType } from "./captchaType/captchaType.js";
3
3
  export declare const captchaTypeDefault = CaptchaType.frictionless;
4
4
  export declare const domainsDefault: string[];
5
5
  export declare const frictionlessThresholdDefault = 0.5;
6
6
  export declare const powDifficultyDefault = 4;
7
7
  export declare const imageThresholdDefault = 0.8;
8
- export declare const ClientSettingsSchema: import("zod").ZodObject<{
9
- captchaType: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNativeEnum<typeof CaptchaType>>>;
10
- domains: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>>;
11
- frictionlessThreshold: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
12
- powDifficulty: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
13
- imageThreshold: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
14
- }, "strip", import("zod").ZodTypeAny, {
8
+ export declare enum IPValidationAction {
9
+ Allow = "allow",
10
+ Reject = "reject",
11
+ Flag = "flag"
12
+ }
13
+ export type IPValidateCondition = {
14
+ met: boolean;
15
+ action: IPValidationAction;
16
+ message: string;
17
+ };
18
+ export declare const IPValidationActionSchema: z.ZodNativeEnum<typeof IPValidationAction>;
19
+ export declare const countryChangeActionDefault = IPValidationAction.Allow;
20
+ export declare const cityChangeActionDefault = IPValidationAction.Allow;
21
+ export declare const ispChangeActionDefault = IPValidationAction.Allow;
22
+ export declare const distanceThresholdKmDefault = 1000;
23
+ export declare const abuseScoreThresholdDefault = 0.005;
24
+ export declare const distanceExceedActionDefault = IPValidationAction.Reject;
25
+ export declare const abuseScoreThresholdExceedActionDefault = IPValidationAction.Reject;
26
+ export declare const requireAllConditionsDefault = false;
27
+ declare const IPValidationSchema: z.ZodObject<{
28
+ actions: z.ZodObject<{
29
+ countryChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
30
+ cityChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
31
+ ispChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
32
+ distanceExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
33
+ abuseScoreExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ countryChangeAction?: IPValidationAction | undefined;
36
+ cityChangeAction?: IPValidationAction | undefined;
37
+ ispChangeAction?: IPValidationAction | undefined;
38
+ distanceExceedAction?: IPValidationAction | undefined;
39
+ abuseScoreExceedAction?: IPValidationAction | undefined;
40
+ }, {
41
+ countryChangeAction?: IPValidationAction | undefined;
42
+ cityChangeAction?: IPValidationAction | undefined;
43
+ ispChangeAction?: IPValidationAction | undefined;
44
+ distanceExceedAction?: IPValidationAction | undefined;
45
+ abuseScoreExceedAction?: IPValidationAction | undefined;
46
+ }>;
47
+ distanceThresholdKm: z.ZodOptional<z.ZodNumber>;
48
+ abuseScoreThreshold: z.ZodOptional<z.ZodNumber>;
49
+ requireAllConditions: z.ZodOptional<z.ZodBoolean>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ actions: {
52
+ countryChangeAction?: IPValidationAction | undefined;
53
+ cityChangeAction?: IPValidationAction | undefined;
54
+ ispChangeAction?: IPValidationAction | undefined;
55
+ distanceExceedAction?: IPValidationAction | undefined;
56
+ abuseScoreExceedAction?: IPValidationAction | undefined;
57
+ };
58
+ distanceThresholdKm?: number | undefined;
59
+ abuseScoreThreshold?: number | undefined;
60
+ requireAllConditions?: boolean | undefined;
61
+ }, {
62
+ actions: {
63
+ countryChangeAction?: IPValidationAction | undefined;
64
+ cityChangeAction?: IPValidationAction | undefined;
65
+ ispChangeAction?: IPValidationAction | undefined;
66
+ distanceExceedAction?: IPValidationAction | undefined;
67
+ abuseScoreExceedAction?: IPValidationAction | undefined;
68
+ };
69
+ distanceThresholdKm?: number | undefined;
70
+ abuseScoreThreshold?: number | undefined;
71
+ requireAllConditions?: boolean | undefined;
72
+ }>;
73
+ export declare const IPValidationRulesSchema: z.ZodObject<{
74
+ actions: z.ZodObject<{
75
+ countryChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
76
+ cityChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
77
+ ispChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
78
+ distanceExceedAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
79
+ abuseScoreExceedAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ countryChangeAction: IPValidationAction;
82
+ cityChangeAction: IPValidationAction;
83
+ ispChangeAction: IPValidationAction;
84
+ distanceExceedAction: IPValidationAction;
85
+ abuseScoreExceedAction: IPValidationAction;
86
+ }, {
87
+ countryChangeAction?: IPValidationAction | undefined;
88
+ cityChangeAction?: IPValidationAction | undefined;
89
+ ispChangeAction?: IPValidationAction | undefined;
90
+ distanceExceedAction?: IPValidationAction | undefined;
91
+ abuseScoreExceedAction?: IPValidationAction | undefined;
92
+ }>;
93
+ distanceThresholdKm: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
94
+ abuseScoreThreshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
95
+ requireAllConditions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
96
+ countryOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
97
+ actions: z.ZodObject<{
98
+ countryChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
99
+ cityChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
100
+ ispChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
101
+ distanceExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
102
+ abuseScoreExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ countryChangeAction?: IPValidationAction | undefined;
105
+ cityChangeAction?: IPValidationAction | undefined;
106
+ ispChangeAction?: IPValidationAction | undefined;
107
+ distanceExceedAction?: IPValidationAction | undefined;
108
+ abuseScoreExceedAction?: IPValidationAction | undefined;
109
+ }, {
110
+ countryChangeAction?: IPValidationAction | undefined;
111
+ cityChangeAction?: IPValidationAction | undefined;
112
+ ispChangeAction?: IPValidationAction | undefined;
113
+ distanceExceedAction?: IPValidationAction | undefined;
114
+ abuseScoreExceedAction?: IPValidationAction | undefined;
115
+ }>;
116
+ distanceThresholdKm: z.ZodOptional<z.ZodNumber>;
117
+ abuseScoreThreshold: z.ZodOptional<z.ZodNumber>;
118
+ requireAllConditions: z.ZodOptional<z.ZodBoolean>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ actions: {
121
+ countryChangeAction?: IPValidationAction | undefined;
122
+ cityChangeAction?: IPValidationAction | undefined;
123
+ ispChangeAction?: IPValidationAction | undefined;
124
+ distanceExceedAction?: IPValidationAction | undefined;
125
+ abuseScoreExceedAction?: IPValidationAction | undefined;
126
+ };
127
+ distanceThresholdKm?: number | undefined;
128
+ abuseScoreThreshold?: number | undefined;
129
+ requireAllConditions?: boolean | undefined;
130
+ }, {
131
+ actions: {
132
+ countryChangeAction?: IPValidationAction | undefined;
133
+ cityChangeAction?: IPValidationAction | undefined;
134
+ ispChangeAction?: IPValidationAction | undefined;
135
+ distanceExceedAction?: IPValidationAction | undefined;
136
+ abuseScoreExceedAction?: IPValidationAction | undefined;
137
+ };
138
+ distanceThresholdKm?: number | undefined;
139
+ abuseScoreThreshold?: number | undefined;
140
+ requireAllConditions?: boolean | undefined;
141
+ }>>>;
142
+ }, "strip", z.ZodTypeAny, {
143
+ actions: {
144
+ countryChangeAction: IPValidationAction;
145
+ cityChangeAction: IPValidationAction;
146
+ ispChangeAction: IPValidationAction;
147
+ distanceExceedAction: IPValidationAction;
148
+ abuseScoreExceedAction: IPValidationAction;
149
+ };
150
+ distanceThresholdKm: number;
151
+ abuseScoreThreshold: number;
152
+ requireAllConditions: boolean;
153
+ countryOverrides?: Record<string, {
154
+ actions: {
155
+ countryChangeAction?: IPValidationAction | undefined;
156
+ cityChangeAction?: IPValidationAction | undefined;
157
+ ispChangeAction?: IPValidationAction | undefined;
158
+ distanceExceedAction?: IPValidationAction | undefined;
159
+ abuseScoreExceedAction?: IPValidationAction | undefined;
160
+ };
161
+ distanceThresholdKm?: number | undefined;
162
+ abuseScoreThreshold?: number | undefined;
163
+ requireAllConditions?: boolean | undefined;
164
+ }> | undefined;
165
+ }, {
166
+ actions: {
167
+ countryChangeAction?: IPValidationAction | undefined;
168
+ cityChangeAction?: IPValidationAction | undefined;
169
+ ispChangeAction?: IPValidationAction | undefined;
170
+ distanceExceedAction?: IPValidationAction | undefined;
171
+ abuseScoreExceedAction?: IPValidationAction | undefined;
172
+ };
173
+ distanceThresholdKm?: number | undefined;
174
+ abuseScoreThreshold?: number | undefined;
175
+ requireAllConditions?: boolean | undefined;
176
+ countryOverrides?: Record<string, {
177
+ actions: {
178
+ countryChangeAction?: IPValidationAction | undefined;
179
+ cityChangeAction?: IPValidationAction | undefined;
180
+ ispChangeAction?: IPValidationAction | undefined;
181
+ distanceExceedAction?: IPValidationAction | undefined;
182
+ abuseScoreExceedAction?: IPValidationAction | undefined;
183
+ };
184
+ distanceThresholdKm?: number | undefined;
185
+ abuseScoreThreshold?: number | undefined;
186
+ requireAllConditions?: boolean | undefined;
187
+ }> | undefined;
188
+ }>;
189
+ export declare const ClientSettingsSchema: z.ZodObject<{
190
+ captchaType: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof CaptchaType>>>;
191
+ domains: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
192
+ frictionlessThreshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
193
+ powDifficulty: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
194
+ imageThreshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
195
+ ipValidationRules: z.ZodOptional<z.ZodObject<{
196
+ actions: z.ZodObject<{
197
+ countryChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
198
+ cityChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
199
+ ispChangeAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
200
+ distanceExceedAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
201
+ abuseScoreExceedAction: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ countryChangeAction: IPValidationAction;
204
+ cityChangeAction: IPValidationAction;
205
+ ispChangeAction: IPValidationAction;
206
+ distanceExceedAction: IPValidationAction;
207
+ abuseScoreExceedAction: IPValidationAction;
208
+ }, {
209
+ countryChangeAction?: IPValidationAction | undefined;
210
+ cityChangeAction?: IPValidationAction | undefined;
211
+ ispChangeAction?: IPValidationAction | undefined;
212
+ distanceExceedAction?: IPValidationAction | undefined;
213
+ abuseScoreExceedAction?: IPValidationAction | undefined;
214
+ }>;
215
+ distanceThresholdKm: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
216
+ abuseScoreThreshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
217
+ requireAllConditions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
218
+ countryOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
219
+ actions: z.ZodObject<{
220
+ countryChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
221
+ cityChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
222
+ ispChangeAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
223
+ distanceExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
224
+ abuseScoreExceedAction: z.ZodOptional<z.ZodOptional<z.ZodNativeEnum<typeof IPValidationAction>>>;
225
+ }, "strip", z.ZodTypeAny, {
226
+ countryChangeAction?: IPValidationAction | undefined;
227
+ cityChangeAction?: IPValidationAction | undefined;
228
+ ispChangeAction?: IPValidationAction | undefined;
229
+ distanceExceedAction?: IPValidationAction | undefined;
230
+ abuseScoreExceedAction?: IPValidationAction | undefined;
231
+ }, {
232
+ countryChangeAction?: IPValidationAction | undefined;
233
+ cityChangeAction?: IPValidationAction | undefined;
234
+ ispChangeAction?: IPValidationAction | undefined;
235
+ distanceExceedAction?: IPValidationAction | undefined;
236
+ abuseScoreExceedAction?: IPValidationAction | undefined;
237
+ }>;
238
+ distanceThresholdKm: z.ZodOptional<z.ZodNumber>;
239
+ abuseScoreThreshold: z.ZodOptional<z.ZodNumber>;
240
+ requireAllConditions: z.ZodOptional<z.ZodBoolean>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ actions: {
243
+ countryChangeAction?: IPValidationAction | undefined;
244
+ cityChangeAction?: IPValidationAction | undefined;
245
+ ispChangeAction?: IPValidationAction | undefined;
246
+ distanceExceedAction?: IPValidationAction | undefined;
247
+ abuseScoreExceedAction?: IPValidationAction | undefined;
248
+ };
249
+ distanceThresholdKm?: number | undefined;
250
+ abuseScoreThreshold?: number | undefined;
251
+ requireAllConditions?: boolean | undefined;
252
+ }, {
253
+ actions: {
254
+ countryChangeAction?: IPValidationAction | undefined;
255
+ cityChangeAction?: IPValidationAction | undefined;
256
+ ispChangeAction?: IPValidationAction | undefined;
257
+ distanceExceedAction?: IPValidationAction | undefined;
258
+ abuseScoreExceedAction?: IPValidationAction | undefined;
259
+ };
260
+ distanceThresholdKm?: number | undefined;
261
+ abuseScoreThreshold?: number | undefined;
262
+ requireAllConditions?: boolean | undefined;
263
+ }>>>;
264
+ }, "strip", z.ZodTypeAny, {
265
+ actions: {
266
+ countryChangeAction: IPValidationAction;
267
+ cityChangeAction: IPValidationAction;
268
+ ispChangeAction: IPValidationAction;
269
+ distanceExceedAction: IPValidationAction;
270
+ abuseScoreExceedAction: IPValidationAction;
271
+ };
272
+ distanceThresholdKm: number;
273
+ abuseScoreThreshold: number;
274
+ requireAllConditions: boolean;
275
+ countryOverrides?: Record<string, {
276
+ actions: {
277
+ countryChangeAction?: IPValidationAction | undefined;
278
+ cityChangeAction?: IPValidationAction | undefined;
279
+ ispChangeAction?: IPValidationAction | undefined;
280
+ distanceExceedAction?: IPValidationAction | undefined;
281
+ abuseScoreExceedAction?: IPValidationAction | undefined;
282
+ };
283
+ distanceThresholdKm?: number | undefined;
284
+ abuseScoreThreshold?: number | undefined;
285
+ requireAllConditions?: boolean | undefined;
286
+ }> | undefined;
287
+ }, {
288
+ actions: {
289
+ countryChangeAction?: IPValidationAction | undefined;
290
+ cityChangeAction?: IPValidationAction | undefined;
291
+ ispChangeAction?: IPValidationAction | undefined;
292
+ distanceExceedAction?: IPValidationAction | undefined;
293
+ abuseScoreExceedAction?: IPValidationAction | undefined;
294
+ };
295
+ distanceThresholdKm?: number | undefined;
296
+ abuseScoreThreshold?: number | undefined;
297
+ requireAllConditions?: boolean | undefined;
298
+ countryOverrides?: Record<string, {
299
+ actions: {
300
+ countryChangeAction?: IPValidationAction | undefined;
301
+ cityChangeAction?: IPValidationAction | undefined;
302
+ ispChangeAction?: IPValidationAction | undefined;
303
+ distanceExceedAction?: IPValidationAction | undefined;
304
+ abuseScoreExceedAction?: IPValidationAction | undefined;
305
+ };
306
+ distanceThresholdKm?: number | undefined;
307
+ abuseScoreThreshold?: number | undefined;
308
+ requireAllConditions?: boolean | undefined;
309
+ }> | undefined;
310
+ }>>;
311
+ }, "strip", z.ZodTypeAny, {
15
312
  captchaType: CaptchaType;
16
313
  domains: string[];
17
314
  frictionlessThreshold: number;
18
315
  powDifficulty: number;
19
316
  imageThreshold: number;
317
+ ipValidationRules?: {
318
+ actions: {
319
+ countryChangeAction: IPValidationAction;
320
+ cityChangeAction: IPValidationAction;
321
+ ispChangeAction: IPValidationAction;
322
+ distanceExceedAction: IPValidationAction;
323
+ abuseScoreExceedAction: IPValidationAction;
324
+ };
325
+ distanceThresholdKm: number;
326
+ abuseScoreThreshold: number;
327
+ requireAllConditions: boolean;
328
+ countryOverrides?: Record<string, {
329
+ actions: {
330
+ countryChangeAction?: IPValidationAction | undefined;
331
+ cityChangeAction?: IPValidationAction | undefined;
332
+ ispChangeAction?: IPValidationAction | undefined;
333
+ distanceExceedAction?: IPValidationAction | undefined;
334
+ abuseScoreExceedAction?: IPValidationAction | undefined;
335
+ };
336
+ distanceThresholdKm?: number | undefined;
337
+ abuseScoreThreshold?: number | undefined;
338
+ requireAllConditions?: boolean | undefined;
339
+ }> | undefined;
340
+ } | undefined;
20
341
  }, {
21
342
  captchaType?: CaptchaType | undefined;
22
343
  domains?: string[] | undefined;
23
344
  frictionlessThreshold?: number | undefined;
24
345
  powDifficulty?: number | undefined;
25
346
  imageThreshold?: number | undefined;
347
+ ipValidationRules?: {
348
+ actions: {
349
+ countryChangeAction?: IPValidationAction | undefined;
350
+ cityChangeAction?: IPValidationAction | undefined;
351
+ ispChangeAction?: IPValidationAction | undefined;
352
+ distanceExceedAction?: IPValidationAction | undefined;
353
+ abuseScoreExceedAction?: IPValidationAction | undefined;
354
+ };
355
+ distanceThresholdKm?: number | undefined;
356
+ abuseScoreThreshold?: number | undefined;
357
+ requireAllConditions?: boolean | undefined;
358
+ countryOverrides?: Record<string, {
359
+ actions: {
360
+ countryChangeAction?: IPValidationAction | undefined;
361
+ cityChangeAction?: IPValidationAction | undefined;
362
+ ispChangeAction?: IPValidationAction | undefined;
363
+ distanceExceedAction?: IPValidationAction | undefined;
364
+ abuseScoreExceedAction?: IPValidationAction | undefined;
365
+ };
366
+ distanceThresholdKm?: number | undefined;
367
+ abuseScoreThreshold?: number | undefined;
368
+ requireAllConditions?: boolean | undefined;
369
+ }> | undefined;
370
+ } | undefined;
26
371
  }>;
27
372
  export type IUserSettings = output<typeof ClientSettingsSchema>;
373
+ export type IIPValidationRules = output<typeof IPValidationRulesSchema>;
374
+ export type IIPValidation = output<typeof IPValidationSchema>;
375
+ export {};
28
376
  //# sourceMappingURL=settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/client/settings.ts"],"names":[],"mappings":"AAaA,OAAO,EAAyB,KAAK,MAAM,EAAU,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,cAAc,EAAE,MAAM,EAAO,CAAC;AAC3C,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAU/B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/client/settings.ts"],"names":[],"mappings":"AAaA,OAAO,EAAkC,KAAK,MAAM,EAAU,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,cAAc,EAAE,MAAM,EAAO,CAAC;AAC3C,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAGzC,oBAAY,kBAAkB;IAC7B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;CACb;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,wBAAwB,4CAAmC,CAAC;AAGzE,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AACnE,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAChE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAChD,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AACrE,eAAO,MAAM,sCAAsC,4BAA4B,CAAC;AAChF,eAAO,MAAM,2BAA2B,QAAQ,CAAC;AAEjD,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYtB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgClC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW/B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAChE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { object, number, array, string } from "zod";
1
+ import { z, object, boolean, number, string, array } from "zod";
2
2
  import { CaptchaType } from "./captchaType/captchaType.js";
3
3
  import { CaptchaTypeSpec } from "./captchaType/captchaTypeSpec.js";
4
4
  const captchaTypeDefault = CaptchaType.frictionless;
@@ -6,18 +6,82 @@ const domainsDefault = [];
6
6
  const frictionlessThresholdDefault = 0.5;
7
7
  const powDifficultyDefault = 4;
8
8
  const imageThresholdDefault = 0.8;
9
+ var IPValidationAction = /* @__PURE__ */ ((IPValidationAction2) => {
10
+ IPValidationAction2["Allow"] = "allow";
11
+ IPValidationAction2["Reject"] = "reject";
12
+ IPValidationAction2["Flag"] = "flag";
13
+ return IPValidationAction2;
14
+ })(IPValidationAction || {});
15
+ const IPValidationActionSchema = z.nativeEnum(IPValidationAction);
16
+ const countryChangeActionDefault = "allow";
17
+ const cityChangeActionDefault = "allow";
18
+ const ispChangeActionDefault = "allow";
19
+ const distanceThresholdKmDefault = 1e3;
20
+ const abuseScoreThresholdDefault = 5e-3;
21
+ const distanceExceedActionDefault = "reject";
22
+ const abuseScoreThresholdExceedActionDefault = "reject";
23
+ const requireAllConditionsDefault = false;
24
+ const IPValidationSchema = object({
25
+ actions: object({
26
+ countryChangeAction: IPValidationActionSchema.optional(),
27
+ cityChangeAction: IPValidationActionSchema.optional(),
28
+ ispChangeAction: IPValidationActionSchema.optional(),
29
+ distanceExceedAction: IPValidationActionSchema.optional(),
30
+ abuseScoreExceedAction: IPValidationActionSchema.optional()
31
+ }).partial(),
32
+ // all optional, so you can just override what you need
33
+ distanceThresholdKm: number().positive().optional(),
34
+ abuseScoreThreshold: number().positive().optional(),
35
+ requireAllConditions: boolean().optional()
36
+ });
37
+ const IPValidationRulesSchema = object({
38
+ actions: object({
39
+ countryChangeAction: IPValidationActionSchema.optional().default(
40
+ countryChangeActionDefault
41
+ ),
42
+ cityChangeAction: IPValidationActionSchema.optional().default(
43
+ cityChangeActionDefault
44
+ ),
45
+ ispChangeAction: IPValidationActionSchema.optional().default(
46
+ ispChangeActionDefault
47
+ ),
48
+ distanceExceedAction: IPValidationActionSchema.optional().default(
49
+ distanceExceedActionDefault
50
+ ),
51
+ abuseScoreExceedAction: IPValidationActionSchema.optional().default(
52
+ abuseScoreThresholdExceedActionDefault
53
+ )
54
+ }),
55
+ distanceThresholdKm: number().positive().optional().default(distanceThresholdKmDefault),
56
+ abuseScoreThreshold: number().positive().optional().default(abuseScoreThresholdDefault),
57
+ requireAllConditions: z.boolean().optional().default(requireAllConditionsDefault),
58
+ // overrides are now lightweight, not recursive
59
+ countryOverrides: z.record(string(), IPValidationSchema).optional()
60
+ });
9
61
  const ClientSettingsSchema = object({
10
62
  captchaType: CaptchaTypeSpec.optional().default(captchaTypeDefault),
11
63
  domains: array(string()).optional().default([...domainsDefault]),
12
64
  frictionlessThreshold: number().optional().default(frictionlessThresholdDefault),
13
65
  powDifficulty: number().optional().default(powDifficultyDefault),
14
- imageThreshold: number().optional().default(imageThresholdDefault)
66
+ imageThreshold: number().optional().default(imageThresholdDefault),
67
+ ipValidationRules: IPValidationRulesSchema.optional()
15
68
  });
16
69
  export {
17
70
  ClientSettingsSchema,
71
+ IPValidationAction,
72
+ IPValidationActionSchema,
73
+ IPValidationRulesSchema,
74
+ abuseScoreThresholdDefault,
75
+ abuseScoreThresholdExceedActionDefault,
18
76
  captchaTypeDefault,
77
+ cityChangeActionDefault,
78
+ countryChangeActionDefault,
79
+ distanceExceedActionDefault,
80
+ distanceThresholdKmDefault,
19
81
  domainsDefault,
20
82
  frictionlessThresholdDefault,
21
83
  imageThresholdDefault,
22
- powDifficultyDefault
84
+ ispChangeActionDefault,
85
+ powDifficultyDefault,
86
+ requireAllConditionsDefault
23
87
  };