@prosopo/types 0.3.39 → 0.3.41
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.
- package/dist/cjs/config/config.cjs +58 -3
- package/dist/cjs/config/index.cjs +9 -0
- package/dist/cjs/index.cjs +10 -0
- package/dist/cjs/provider/api.cjs +24 -2
- package/dist/cjs/provider/index.cjs +1 -0
- package/dist/config/config.d.ts +394 -108
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +46 -2
- package/dist/config/config.js.map +1 -1
- package/dist/config/network.d.ts +17 -17
- package/dist/contract/artifacts.d.ts +239 -239
- package/dist/datasets/captcha.d.ts +75 -40
- package/dist/datasets/captcha.d.ts.map +1 -1
- package/dist/datasets/dataset.d.ts +109 -40
- package/dist/datasets/dataset.d.ts.map +1 -1
- package/dist/procaptcha/manager.d.ts +6 -6
- package/dist/provider/api.d.ts +20 -2
- package/dist/provider/api.d.ts.map +1 -1
- package/dist/provider/api.js +9 -1
- package/dist/provider/api.js.map +1 -1
- package/package.json +7 -5
|
@@ -6,7 +6,15 @@ const index = require("../networks/index.cjs");
|
|
|
6
6
|
const LogLevel = z.enum(["trace", "debug", "info", "warn", "error", "fatal", "log"]);
|
|
7
7
|
const DatabaseTypes = z.enum(["mongo", "mongoMemory"]);
|
|
8
8
|
const EnvironmentTypesSchema = z.enum(["development", "staging", "production"]);
|
|
9
|
-
const
|
|
9
|
+
const ONE_MINUTE = 60 * 1e3;
|
|
10
|
+
const DEFAULT_IMAGE_CAPTCHA_TIMEOUT = ONE_MINUTE;
|
|
11
|
+
const DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 2;
|
|
12
|
+
const DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 3;
|
|
13
|
+
const DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 15;
|
|
14
|
+
const DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = ONE_MINUTE;
|
|
15
|
+
const DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 2;
|
|
16
|
+
const DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 3;
|
|
17
|
+
const DEFAULT_MAX_VERIFIED_TIME_CONTRACT = ONE_MINUTE * 15;
|
|
10
18
|
const DatabaseConfigSchema = z.record(
|
|
11
19
|
EnvironmentTypesSchema,
|
|
12
20
|
z.object({
|
|
@@ -64,9 +72,47 @@ const ProsopoClientConfigSchema = ProsopoBasicConfigSchema.merge(
|
|
|
64
72
|
serverUrl: z.string().optional()
|
|
65
73
|
})
|
|
66
74
|
);
|
|
75
|
+
const defaultImageCaptchaTimeouts = {
|
|
76
|
+
challengeTimeout: DEFAULT_IMAGE_CAPTCHA_TIMEOUT,
|
|
77
|
+
solutionTimeout: DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT,
|
|
78
|
+
verifiedTimeout: DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT,
|
|
79
|
+
cachedTimeout: DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED
|
|
80
|
+
};
|
|
81
|
+
const defaultPoWCaptchaTimeouts = {
|
|
82
|
+
challengeTimeout: DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT,
|
|
83
|
+
solutionTimeout: DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT,
|
|
84
|
+
cachedTimeout: DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT
|
|
85
|
+
};
|
|
86
|
+
const defaultContractCaptchaTimeouts = {
|
|
87
|
+
maxVerifiedTime: DEFAULT_MAX_VERIFIED_TIME_CONTRACT
|
|
88
|
+
};
|
|
89
|
+
const defaultCaptchaTimeouts = {
|
|
90
|
+
image: defaultImageCaptchaTimeouts,
|
|
91
|
+
pow: defaultPoWCaptchaTimeouts,
|
|
92
|
+
contract: defaultContractCaptchaTimeouts
|
|
93
|
+
};
|
|
94
|
+
const CaptchaTimeoutSchema = z.object({
|
|
95
|
+
image: z.object({
|
|
96
|
+
// Set this to a default value for the frontend
|
|
97
|
+
challengeTimeout: z.number().positive().optional().default(DEFAULT_IMAGE_CAPTCHA_TIMEOUT),
|
|
98
|
+
// Set this to a default value for the frontend
|
|
99
|
+
solutionTimeout: z.number().positive().optional().default(DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT),
|
|
100
|
+
verifiedTimeout: z.number().positive().optional().default(DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT),
|
|
101
|
+
cachedTimeout: z.number().positive().optional().default(DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED)
|
|
102
|
+
}).default(defaultImageCaptchaTimeouts),
|
|
103
|
+
pow: z.object({
|
|
104
|
+
verifiedTimeout: z.number().positive().optional().default(DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT),
|
|
105
|
+
solutionTimeout: z.number().positive().optional().default(DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT),
|
|
106
|
+
cachedTimeout: z.number().positive().optional().default(DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT)
|
|
107
|
+
}).default(defaultPoWCaptchaTimeouts),
|
|
108
|
+
contract: z.object({
|
|
109
|
+
maxVerifiedTime: z.number().positive().optional().default(DEFAULT_MAX_VERIFIED_TIME_CONTRACT)
|
|
110
|
+
}).default(defaultContractCaptchaTimeouts)
|
|
111
|
+
}).default(defaultCaptchaTimeouts);
|
|
67
112
|
const ProsopoServerConfigSchema = ProsopoClientConfigSchema.merge(
|
|
68
113
|
z.object({
|
|
69
|
-
serverUrl: z.string().url().optional()
|
|
114
|
+
serverUrl: z.string().url().optional(),
|
|
115
|
+
timeouts: CaptchaTimeoutSchema.optional().default(defaultCaptchaTimeouts)
|
|
70
116
|
})
|
|
71
117
|
);
|
|
72
118
|
const AccountCreatorConfigSchema = z.object({
|
|
@@ -86,7 +132,7 @@ const ProcaptchaConfigSchema = ProsopoClientConfigSchema.and(
|
|
|
86
132
|
z.object({
|
|
87
133
|
accountCreator: AccountCreatorConfigSchema.optional(),
|
|
88
134
|
theme: ThemeType.optional(),
|
|
89
|
-
|
|
135
|
+
captchas: CaptchaTimeoutSchema.optional().default(defaultCaptchaTimeouts)
|
|
90
136
|
})
|
|
91
137
|
);
|
|
92
138
|
const ProsopoConfigSchema = ProsopoBasicConfigSchema.merge(
|
|
@@ -110,6 +156,15 @@ const ProsopoConfigSchema = ProsopoBasicConfigSchema.merge(
|
|
|
110
156
|
);
|
|
111
157
|
exports.AccountCreatorConfigSchema = AccountCreatorConfigSchema;
|
|
112
158
|
exports.BatchCommitConfigSchema = BatchCommitConfigSchema;
|
|
159
|
+
exports.CaptchaTimeoutSchema = CaptchaTimeoutSchema;
|
|
160
|
+
exports.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT;
|
|
161
|
+
exports.DEFAULT_IMAGE_CAPTCHA_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT;
|
|
162
|
+
exports.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT;
|
|
163
|
+
exports.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED;
|
|
164
|
+
exports.DEFAULT_MAX_VERIFIED_TIME_CONTRACT = DEFAULT_MAX_VERIFIED_TIME_CONTRACT;
|
|
165
|
+
exports.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT;
|
|
166
|
+
exports.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT;
|
|
167
|
+
exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT;
|
|
113
168
|
exports.DatabaseConfigSchema = DatabaseConfigSchema;
|
|
114
169
|
exports.DatabaseTypes = DatabaseTypes;
|
|
115
170
|
exports.EnvironmentTypesSchema = EnvironmentTypesSchema;
|
|
@@ -4,6 +4,15 @@ const config = require("./config.cjs");
|
|
|
4
4
|
const network = require("./network.cjs");
|
|
5
5
|
exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
|
|
6
6
|
exports.BatchCommitConfigSchema = config.BatchCommitConfigSchema;
|
|
7
|
+
exports.CaptchaTimeoutSchema = config.CaptchaTimeoutSchema;
|
|
8
|
+
exports.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT;
|
|
9
|
+
exports.DEFAULT_IMAGE_CAPTCHA_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_TIMEOUT;
|
|
10
|
+
exports.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT;
|
|
11
|
+
exports.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = config.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED;
|
|
12
|
+
exports.DEFAULT_MAX_VERIFIED_TIME_CONTRACT = config.DEFAULT_MAX_VERIFIED_TIME_CONTRACT;
|
|
13
|
+
exports.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = config.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT;
|
|
14
|
+
exports.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = config.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT;
|
|
15
|
+
exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = config.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT;
|
|
7
16
|
exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
|
|
8
17
|
exports.DatabaseTypes = config.DatabaseTypes;
|
|
9
18
|
exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -22,6 +22,15 @@ exports.FeaturesEnum = index$1.FeaturesEnum;
|
|
|
22
22
|
exports.networks = index;
|
|
23
23
|
exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
|
|
24
24
|
exports.BatchCommitConfigSchema = config.BatchCommitConfigSchema;
|
|
25
|
+
exports.CaptchaTimeoutSchema = config.CaptchaTimeoutSchema;
|
|
26
|
+
exports.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT;
|
|
27
|
+
exports.DEFAULT_IMAGE_CAPTCHA_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_TIMEOUT;
|
|
28
|
+
exports.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = config.DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT;
|
|
29
|
+
exports.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = config.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED;
|
|
30
|
+
exports.DEFAULT_MAX_VERIFIED_TIME_CONTRACT = config.DEFAULT_MAX_VERIFIED_TIME_CONTRACT;
|
|
31
|
+
exports.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = config.DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT;
|
|
32
|
+
exports.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = config.DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT;
|
|
33
|
+
exports.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = config.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT;
|
|
25
34
|
exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
|
|
26
35
|
exports.DatabaseTypes = config.DatabaseTypes;
|
|
27
36
|
exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
|
|
@@ -81,6 +90,7 @@ exports.ApiParams = api.ApiParams;
|
|
|
81
90
|
exports.ApiPaths = api.ApiPaths;
|
|
82
91
|
exports.CaptchaRequestBody = api.CaptchaRequestBody;
|
|
83
92
|
exports.CaptchaSolutionBody = api.CaptchaSolutionBody;
|
|
93
|
+
exports.GetPowCaptchaChallengeRequestBody = api.GetPowCaptchaChallengeRequestBody;
|
|
84
94
|
exports.ServerPowCaptchaVerifyRequestBody = api.ServerPowCaptchaVerifyRequestBody;
|
|
85
95
|
exports.SubmitPowCaptchaSolutionBody = api.SubmitPowCaptchaSolutionBody;
|
|
86
96
|
exports.VerifySolutionBody = api.VerifySolutionBody;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../datasets/index.cjs");
|
|
4
|
+
require("../config/index.cjs");
|
|
4
5
|
const z = require("zod");
|
|
5
6
|
const captcha = require("../datasets/captcha.cjs");
|
|
7
|
+
const config = require("../config/config.cjs");
|
|
6
8
|
var ApiPaths = /* @__PURE__ */ ((ApiPaths2) => {
|
|
7
9
|
ApiPaths2["GetCaptchaChallenge"] = "/v1/prosopo/provider/captcha";
|
|
8
10
|
ApiPaths2["GetPowCaptchaChallenge"] = "/v1/prosopo/provider/captcha/pow";
|
|
@@ -35,6 +37,7 @@ var ApiParams = /* @__PURE__ */ ((ApiParams2) => {
|
|
|
35
37
|
ApiParams2["proof"] = "proof";
|
|
36
38
|
ApiParams2["providerUrl"] = "providerUrl";
|
|
37
39
|
ApiParams2["procaptchaResponse"] = "procaptcha-response";
|
|
40
|
+
ApiParams2["verifiedTimeout"] = "verifiedTimeout";
|
|
38
41
|
ApiParams2["maxVerifiedTime"] = "maxVerifiedTime";
|
|
39
42
|
ApiParams2["verified"] = "verified";
|
|
40
43
|
ApiParams2["status"] = "status";
|
|
@@ -104,13 +107,27 @@ const VerifySolutionBody = z.object({
|
|
|
104
107
|
[
|
|
105
108
|
"maxVerifiedTime"
|
|
106
109
|
/* maxVerifiedTime */
|
|
107
|
-
]: z.number().optional()
|
|
110
|
+
]: z.number().optional().default(config.DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED)
|
|
108
111
|
});
|
|
109
112
|
const ServerPowCaptchaVerifyRequestBody = z.object({
|
|
110
113
|
[
|
|
111
114
|
"challenge"
|
|
112
115
|
/* challenge */
|
|
113
116
|
]: z.string(),
|
|
117
|
+
[
|
|
118
|
+
"dapp"
|
|
119
|
+
/* dapp */
|
|
120
|
+
]: z.string(),
|
|
121
|
+
[
|
|
122
|
+
"verifiedTimeout"
|
|
123
|
+
/* verifiedTimeout */
|
|
124
|
+
]: z.number().optional().default(config.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT)
|
|
125
|
+
});
|
|
126
|
+
const GetPowCaptchaChallengeRequestBody = z.object({
|
|
127
|
+
[
|
|
128
|
+
"user"
|
|
129
|
+
/* user */
|
|
130
|
+
]: z.string(),
|
|
114
131
|
[
|
|
115
132
|
"dapp"
|
|
116
133
|
/* dapp */
|
|
@@ -144,13 +161,18 @@ const SubmitPowCaptchaSolutionBody = z.object({
|
|
|
144
161
|
[
|
|
145
162
|
"nonce"
|
|
146
163
|
/* nonce */
|
|
147
|
-
]: z.number()
|
|
164
|
+
]: z.number(),
|
|
165
|
+
[
|
|
166
|
+
"verifiedTimeout"
|
|
167
|
+
/* verifiedTimeout */
|
|
168
|
+
]: z.number().optional().default(config.DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT)
|
|
148
169
|
});
|
|
149
170
|
exports.AdminApiPaths = AdminApiPaths;
|
|
150
171
|
exports.ApiParams = ApiParams;
|
|
151
172
|
exports.ApiPaths = ApiPaths;
|
|
152
173
|
exports.CaptchaRequestBody = CaptchaRequestBody;
|
|
153
174
|
exports.CaptchaSolutionBody = CaptchaSolutionBody;
|
|
175
|
+
exports.GetPowCaptchaChallengeRequestBody = GetPowCaptchaChallengeRequestBody;
|
|
154
176
|
exports.ServerPowCaptchaVerifyRequestBody = ServerPowCaptchaVerifyRequestBody;
|
|
155
177
|
exports.SubmitPowCaptchaSolutionBody = SubmitPowCaptchaSolutionBody;
|
|
156
178
|
exports.VerifySolutionBody = VerifySolutionBody;
|
|
@@ -9,6 +9,7 @@ exports.ApiParams = api.ApiParams;
|
|
|
9
9
|
exports.ApiPaths = api.ApiPaths;
|
|
10
10
|
exports.CaptchaRequestBody = api.CaptchaRequestBody;
|
|
11
11
|
exports.CaptchaSolutionBody = api.CaptchaSolutionBody;
|
|
12
|
+
exports.GetPowCaptchaChallengeRequestBody = api.GetPowCaptchaChallengeRequestBody;
|
|
12
13
|
exports.ServerPowCaptchaVerifyRequestBody = api.ServerPowCaptchaVerifyRequestBody;
|
|
13
14
|
exports.SubmitPowCaptchaSolutionBody = api.SubmitPowCaptchaSolutionBody;
|
|
14
15
|
exports.VerifySolutionBody = api.VerifySolutionBody;
|