@prosopo/types-database 3.0.13 → 3.3.13
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/CHANGELOG.md +332 -0
- package/dist/cjs/index.cjs +5 -1
- package/dist/cjs/types/captcha.cjs +3 -14
- package/dist/cjs/types/client.cjs +70 -4
- package/dist/cjs/types/index.cjs +5 -1
- package/dist/cjs/types/provider.cjs +102 -51
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -0
- package/dist/provider/pendingCaptchaRequest.d.ts +14 -0
- package/dist/provider/pendingCaptchaRequest.d.ts.map +1 -0
- package/dist/provider/pendingCaptchaRequest.js +2 -0
- package/dist/provider/pendingCaptchaRequest.js.map +1 -0
- package/dist/types/captcha.d.ts +18 -0
- package/dist/types/captcha.d.ts.map +1 -0
- package/dist/types/captcha.js +4 -15
- package/dist/types/captcha.js.map +1 -0
- package/dist/types/client.d.ts +259 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +70 -4
- package/dist/types/client.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -4
- package/dist/types/index.js.map +1 -0
- package/dist/types/mongo.d.ts +13 -0
- package/dist/types/mongo.d.ts.map +1 -0
- package/dist/types/mongo.js.map +1 -0
- package/dist/types/provider.d.ts +667 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +106 -55
- package/dist/types/provider.js.map +1 -0
- package/dist/types/userAgent.d.ts +31 -0
- package/dist/types/userAgent.d.ts.map +1 -0
- package/dist/types/userAgent.js.map +1 -0
- package/package.json +15 -20
|
@@ -16,6 +16,40 @@ const ClientRecordSchema = new mongoose.Schema({
|
|
|
16
16
|
tier: { type: String, enum: types.Tier, required: true }
|
|
17
17
|
});
|
|
18
18
|
ClientRecordSchema.index({ account: 1 });
|
|
19
|
+
var IpAddressType = /* @__PURE__ */ ((IpAddressType2) => {
|
|
20
|
+
IpAddressType2["v4"] = "v4";
|
|
21
|
+
IpAddressType2["v6"] = "v6";
|
|
22
|
+
return IpAddressType2;
|
|
23
|
+
})(IpAddressType || {});
|
|
24
|
+
const CompositeIpAddressSchema = zod.object({
|
|
25
|
+
lower: zod.bigint(),
|
|
26
|
+
upper: zod.bigint().optional(),
|
|
27
|
+
type: zod.nativeEnum(IpAddressType)
|
|
28
|
+
});
|
|
29
|
+
const CompositeIpAddressRecordSchemaObj = {
|
|
30
|
+
lower: {
|
|
31
|
+
// INT64 isn't enough capable - it reserves extra bits for the sign bit, etc, so Decimal128 guarantees no overflow
|
|
32
|
+
type: mongoose.Schema.Types.Decimal128,
|
|
33
|
+
required: true,
|
|
34
|
+
// without casting to string Mongoose not able to set bigint to Decimal128
|
|
35
|
+
set: (value) => "bigint" === typeof value ? value.toString() : value
|
|
36
|
+
},
|
|
37
|
+
upper: {
|
|
38
|
+
// INT64 isn't enough capable - it reserves extra bits for the sign bit, etc, so Decimal128 guarantees no overflow
|
|
39
|
+
type: mongoose.Schema.Types.Decimal128,
|
|
40
|
+
required: false,
|
|
41
|
+
// without casting to string Mongoose not able to set bigint to Decimal128
|
|
42
|
+
set: (value) => "bigint" === typeof value ? value.toString() : value
|
|
43
|
+
},
|
|
44
|
+
type: { type: String, enum: IpAddressType, required: true }
|
|
45
|
+
};
|
|
46
|
+
const parseMongooseCompositeIpAddress = (ip) => {
|
|
47
|
+
return {
|
|
48
|
+
lower: BigInt(ip.lower.$numberDecimal ?? ip.lower),
|
|
49
|
+
upper: ip.upper ? BigInt(ip.upper?.$numberDecimal ?? ip.upper) : void 0,
|
|
50
|
+
type: ip.type
|
|
51
|
+
};
|
|
52
|
+
};
|
|
19
53
|
const CaptchaResultSchema = zod.object({
|
|
20
54
|
status: zod.nativeEnum(types.CaptchaStatus),
|
|
21
55
|
reason: locale.TranslationKeysSchema.optional(),
|
|
@@ -29,18 +63,17 @@ const UserCommitmentSchema = zod.object({
|
|
|
29
63
|
id: zod.string(),
|
|
30
64
|
result: CaptchaResultSchema,
|
|
31
65
|
userSignature: zod.string(),
|
|
32
|
-
ipAddress:
|
|
66
|
+
ipAddress: CompositeIpAddressSchema,
|
|
67
|
+
providedIp: CompositeIpAddressSchema.optional(),
|
|
33
68
|
headers: zod.object({}).catchall(zod.string()),
|
|
34
69
|
ja4: zod.string(),
|
|
35
70
|
userSubmitted: zod.boolean(),
|
|
36
71
|
serverChecked: zod.boolean(),
|
|
37
|
-
storedAtTimestamp:
|
|
38
|
-
requestedAtTimestamp:
|
|
39
|
-
lastUpdatedTimestamp:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
zod.instanceof(mongoose.Types.ObjectId)
|
|
43
|
-
]).optional()
|
|
72
|
+
storedAtTimestamp: zod.date().optional(),
|
|
73
|
+
requestedAtTimestamp: zod.date(),
|
|
74
|
+
lastUpdatedTimestamp: zod.date().optional(),
|
|
75
|
+
sessionId: zod.string().optional(),
|
|
76
|
+
coords: zod.array(zod.array(zod.array(zod.number()))).optional()
|
|
44
77
|
});
|
|
45
78
|
const CaptchaRecordSchema = new mongoose.Schema({
|
|
46
79
|
captchaId: { type: String, required: true },
|
|
@@ -72,8 +105,8 @@ const PoWCaptchaRecordSchema = new mongoose.Schema({
|
|
|
72
105
|
challenge: { type: String, required: true },
|
|
73
106
|
dappAccount: { type: String, required: true },
|
|
74
107
|
userAccount: { type: String, required: true },
|
|
75
|
-
requestedAtTimestamp: { type:
|
|
76
|
-
lastUpdatedTimestamp: { type:
|
|
108
|
+
requestedAtTimestamp: { type: Date, required: true },
|
|
109
|
+
lastUpdatedTimestamp: { type: Date, required: false },
|
|
77
110
|
result: {
|
|
78
111
|
status: { type: String, enum: types.CaptchaStatus, required: true },
|
|
79
112
|
reason: {
|
|
@@ -84,7 +117,11 @@ const PoWCaptchaRecordSchema = new mongoose.Schema({
|
|
|
84
117
|
error: { type: String, required: false }
|
|
85
118
|
},
|
|
86
119
|
difficulty: { type: Number, required: true },
|
|
87
|
-
ipAddress:
|
|
120
|
+
ipAddress: CompositeIpAddressRecordSchemaObj,
|
|
121
|
+
providedIp: {
|
|
122
|
+
type: new mongoose.Schema(CompositeIpAddressRecordSchemaObj, { _id: false }),
|
|
123
|
+
required: false
|
|
124
|
+
},
|
|
88
125
|
headers: { type: Object, required: true },
|
|
89
126
|
ja4: { type: String, required: true },
|
|
90
127
|
userSignature: { type: String, required: false },
|
|
@@ -94,15 +131,17 @@ const PoWCaptchaRecordSchema = new mongoose.Schema({
|
|
|
94
131
|
geolocation: { type: String, required: false },
|
|
95
132
|
vpn: { type: Boolean, required: false },
|
|
96
133
|
parsedUserAgentInfo: { type: Object, required: false },
|
|
97
|
-
|
|
98
|
-
type:
|
|
134
|
+
sessionId: {
|
|
135
|
+
type: String,
|
|
99
136
|
required: false
|
|
100
|
-
}
|
|
137
|
+
},
|
|
138
|
+
coords: { type: [[[Number]]], required: false }
|
|
101
139
|
});
|
|
102
140
|
PoWCaptchaRecordSchema.index({ challenge: 1 });
|
|
103
|
-
PoWCaptchaRecordSchema.index({ storedAtTimestamp: 1 });
|
|
104
141
|
PoWCaptchaRecordSchema.index({ storedAtTimestamp: 1, lastUpdatedTimestamp: 1 });
|
|
105
142
|
PoWCaptchaRecordSchema.index({ dappAccount: 1, requestedAtTimestamp: 1 });
|
|
143
|
+
PoWCaptchaRecordSchema.index({ "ipAddress.lower": 1 });
|
|
144
|
+
PoWCaptchaRecordSchema.index({ "ipAddress.upper": 1 });
|
|
106
145
|
const UserCommitmentRecordSchema = new mongoose.Schema({
|
|
107
146
|
userAccount: { type: String, required: true },
|
|
108
147
|
dappAccount: { type: String, required: true },
|
|
@@ -118,30 +157,36 @@ const UserCommitmentRecordSchema = new mongoose.Schema({
|
|
|
118
157
|
},
|
|
119
158
|
error: { type: String, required: false }
|
|
120
159
|
},
|
|
121
|
-
ipAddress:
|
|
160
|
+
ipAddress: CompositeIpAddressRecordSchemaObj,
|
|
161
|
+
providedIp: {
|
|
162
|
+
type: new mongoose.Schema(CompositeIpAddressRecordSchemaObj, { _id: false }),
|
|
163
|
+
required: false
|
|
164
|
+
},
|
|
122
165
|
headers: { type: Object, required: true },
|
|
123
166
|
ja4: { type: String, required: true },
|
|
124
167
|
userSignature: { type: String, required: true },
|
|
125
168
|
userSubmitted: { type: Boolean, required: true },
|
|
126
169
|
serverChecked: { type: Boolean, required: true },
|
|
127
|
-
storedAtTimestamp: { type:
|
|
128
|
-
requestedAtTimestamp: { type:
|
|
129
|
-
lastUpdatedTimestamp: { type:
|
|
170
|
+
storedAtTimestamp: { type: Date, required: false, expires: ONE_MONTH },
|
|
171
|
+
requestedAtTimestamp: { type: Date, required: true },
|
|
172
|
+
lastUpdatedTimestamp: { type: Date, required: false },
|
|
130
173
|
geolocation: { type: String, required: false },
|
|
131
174
|
vpn: { type: Boolean, required: false },
|
|
132
175
|
parsedUserAgentInfo: { type: Object, required: false },
|
|
133
|
-
|
|
134
|
-
type:
|
|
176
|
+
sessionId: {
|
|
177
|
+
type: String,
|
|
135
178
|
required: false
|
|
136
|
-
}
|
|
179
|
+
},
|
|
180
|
+
coords: { type: [[[Number]]], required: false }
|
|
137
181
|
});
|
|
138
182
|
UserCommitmentRecordSchema.index({ id: -1 });
|
|
139
|
-
UserCommitmentRecordSchema.index({ storedAtTimestamp: 1 });
|
|
140
183
|
UserCommitmentRecordSchema.index({
|
|
141
184
|
storedAtTimestamp: 1,
|
|
142
185
|
lastUpdatedTimestamp: 1
|
|
143
186
|
});
|
|
144
187
|
UserCommitmentRecordSchema.index({ userAccount: 1, dappAccount: 1 });
|
|
188
|
+
UserCommitmentRecordSchema.index({ "ipAddress.lower": 1 });
|
|
189
|
+
UserCommitmentRecordSchema.index({ "ipAddress.upper": 1 });
|
|
145
190
|
const DatasetRecordSchema = new mongoose.Schema({
|
|
146
191
|
contentTree: { type: [[String]], required: true },
|
|
147
192
|
datasetContentId: { type: String, required: true },
|
|
@@ -162,7 +207,8 @@ SolutionRecordSchema.index({ captchaId: 1 });
|
|
|
162
207
|
const UserSolutionSchema = types.CaptchaSolutionSchema.extend({
|
|
163
208
|
processed: zod.boolean(),
|
|
164
209
|
checked: zod.boolean(),
|
|
165
|
-
commitmentId: zod.string()
|
|
210
|
+
commitmentId: zod.string(),
|
|
211
|
+
createdAt: zod.date()
|
|
166
212
|
});
|
|
167
213
|
const UserSolutionRecordSchema = new mongoose.Schema(
|
|
168
214
|
{
|
|
@@ -172,7 +218,8 @@ const UserSolutionRecordSchema = new mongoose.Schema(
|
|
|
172
218
|
solution: [{ type: String, required: true }],
|
|
173
219
|
processed: { type: Boolean, required: true },
|
|
174
220
|
checked: { type: Boolean, required: true },
|
|
175
|
-
commitmentId: { type: String, required: true }
|
|
221
|
+
commitmentId: { type: String, required: true },
|
|
222
|
+
createdAt: { type: Date, default: Date.now, expires: ONE_MONTH }
|
|
176
223
|
},
|
|
177
224
|
{ _id: false }
|
|
178
225
|
);
|
|
@@ -189,9 +236,9 @@ const PendingRecordSchema = new mongoose.Schema({
|
|
|
189
236
|
deadlineTimestamp: { type: Number, required: true },
|
|
190
237
|
// unix timestamp
|
|
191
238
|
requestedAtTimestamp: { type: Date, required: true, expires: ONE_WEEK },
|
|
192
|
-
ipAddress:
|
|
193
|
-
|
|
194
|
-
type:
|
|
239
|
+
ipAddress: CompositeIpAddressRecordSchemaObj,
|
|
240
|
+
sessionId: {
|
|
241
|
+
type: String,
|
|
195
242
|
required: false
|
|
196
243
|
},
|
|
197
244
|
threshold: { type: Number, required: true, default: 0.8 }
|
|
@@ -199,8 +246,8 @@ const PendingRecordSchema = new mongoose.Schema({
|
|
|
199
246
|
PendingRecordSchema.index({ requestHash: -1 });
|
|
200
247
|
const ScheduledTaskSchema = zod.object({
|
|
201
248
|
processName: zod.nativeEnum(types.ScheduledTaskNames),
|
|
202
|
-
datetime:
|
|
203
|
-
updated:
|
|
249
|
+
datetime: zod.date(),
|
|
250
|
+
updated: zod.date().optional(),
|
|
204
251
|
status: zod.nativeEnum(types.ScheduledTaskStatus),
|
|
205
252
|
result: zod.object({
|
|
206
253
|
data: zod.any().optional(),
|
|
@@ -210,7 +257,7 @@ const ScheduledTaskSchema = zod.object({
|
|
|
210
257
|
const ScheduledTaskRecordSchema = new mongoose.Schema({
|
|
211
258
|
processName: { type: String, enum: types.ScheduledTaskNames, required: true },
|
|
212
259
|
datetime: { type: Date, required: true, expires: ONE_WEEK },
|
|
213
|
-
updated: { type:
|
|
260
|
+
updated: { type: Date, required: false },
|
|
214
261
|
status: { type: String, enum: types.ScheduledTaskStatus, required: true },
|
|
215
262
|
result: {
|
|
216
263
|
type: new mongoose.Schema(
|
|
@@ -226,7 +273,9 @@ const ScheduledTaskRecordSchema = new mongoose.Schema({
|
|
|
226
273
|
ScheduledTaskRecordSchema.index({ processName: 1 });
|
|
227
274
|
ScheduledTaskRecordSchema.index({ processName: 1, status: 1 });
|
|
228
275
|
ScheduledTaskRecordSchema.index({ _id: 1, status: 1 });
|
|
229
|
-
const
|
|
276
|
+
const SessionRecordSchema = new mongoose.Schema({
|
|
277
|
+
sessionId: { type: String, required: true },
|
|
278
|
+
createdAt: { type: Date, required: true },
|
|
230
279
|
token: { type: String, required: true, unique: true },
|
|
231
280
|
score: { type: Number, required: true },
|
|
232
281
|
threshold: { type: Number, required: true },
|
|
@@ -234,40 +283,41 @@ const FrictionlessTokenRecordSchema = new mongoose.Schema({
|
|
|
234
283
|
baseScore: { type: Number, required: true },
|
|
235
284
|
lScore: { type: Number, required: false },
|
|
236
285
|
timeout: { type: Number, required: false },
|
|
237
|
-
accessPolicy: { type: Number, required: false }
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
storedAtTimestamp: { type: Date, required: false },
|
|
241
|
-
lastUpdatedTimestamp: { type: Date, required: false }
|
|
242
|
-
});
|
|
243
|
-
FrictionlessTokenRecordSchema.index({ token: 1 }, { unique: true });
|
|
244
|
-
FrictionlessTokenRecordSchema.index({ storedAtTimestamp: 1 });
|
|
245
|
-
const SessionRecordSchema = new mongoose.Schema({
|
|
246
|
-
sessionId: { type: String, required: true, unique: true },
|
|
247
|
-
createdAt: { type: Date, required: true, expires: ONE_DAY },
|
|
248
|
-
tokenId: {
|
|
249
|
-
type: mongoose.Schema.Types.ObjectId
|
|
286
|
+
accessPolicy: { type: Number, required: false },
|
|
287
|
+
unverifiedHost: { type: Number, required: false },
|
|
288
|
+
webView: { type: Number, required: false }
|
|
250
289
|
},
|
|
290
|
+
providerSelectEntropy: { type: Number, required: true },
|
|
291
|
+
ipAddress: CompositeIpAddressRecordSchemaObj,
|
|
251
292
|
captchaType: { type: String, enum: types.CaptchaType, required: true },
|
|
252
|
-
|
|
293
|
+
solvedImagesCount: { type: Number, required: false },
|
|
294
|
+
powDifficulty: { type: Number, required: false },
|
|
295
|
+
storedAtTimestamp: { type: Date, required: false, expires: ONE_DAY },
|
|
253
296
|
lastUpdatedTimestamp: { type: Date, required: false },
|
|
254
|
-
deleted: { type: Boolean, required: false }
|
|
297
|
+
deleted: { type: Boolean, required: false },
|
|
298
|
+
webView: { type: Boolean, required: true, default: false },
|
|
299
|
+
iFrame: { type: Boolean, required: true, default: false },
|
|
300
|
+
decryptedHeadHash: { type: String, required: false, default: "" }
|
|
255
301
|
});
|
|
256
|
-
SessionRecordSchema.index({
|
|
257
|
-
SessionRecordSchema.index({ storedAtTimestamp: 1 });
|
|
302
|
+
SessionRecordSchema.index({ createdAt: 1 });
|
|
258
303
|
SessionRecordSchema.index({ deleted: 1 });
|
|
304
|
+
SessionRecordSchema.index({ sessionId: 1 }, { unique: true });
|
|
305
|
+
SessionRecordSchema.index({ providerSelectEntropy: 1 });
|
|
306
|
+
SessionRecordSchema.index({ token: 1 });
|
|
259
307
|
const DetectorRecordSchema = new mongoose.Schema({
|
|
260
308
|
createdAt: { type: Date, required: true },
|
|
261
309
|
detectorKey: { type: String, required: true },
|
|
262
|
-
expiresAt: { type: Date, required: false
|
|
310
|
+
expiresAt: { type: Date, required: false }
|
|
263
311
|
});
|
|
264
312
|
DetectorRecordSchema.index({ createdAt: 1 }, { unique: true });
|
|
265
313
|
DetectorRecordSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
266
314
|
exports.CaptchaRecordSchema = CaptchaRecordSchema;
|
|
267
315
|
exports.ClientRecordSchema = ClientRecordSchema;
|
|
316
|
+
exports.CompositeIpAddressRecordSchemaObj = CompositeIpAddressRecordSchemaObj;
|
|
317
|
+
exports.CompositeIpAddressSchema = CompositeIpAddressSchema;
|
|
268
318
|
exports.DatasetRecordSchema = DatasetRecordSchema;
|
|
269
319
|
exports.DetectorRecordSchema = DetectorRecordSchema;
|
|
270
|
-
exports.
|
|
320
|
+
exports.IpAddressType = IpAddressType;
|
|
271
321
|
exports.PendingRecordSchema = PendingRecordSchema;
|
|
272
322
|
exports.PoWCaptchaRecordSchema = PoWCaptchaRecordSchema;
|
|
273
323
|
exports.ScheduledTaskRecordSchema = ScheduledTaskRecordSchema;
|
|
@@ -279,3 +329,4 @@ exports.UserCommitmentSchema = UserCommitmentSchema;
|
|
|
279
329
|
exports.UserCommitmentWithSolutionsSchema = UserCommitmentWithSolutionsSchema;
|
|
280
330
|
exports.UserSolutionRecordSchema = UserSolutionRecordSchema;
|
|
281
331
|
exports.UserSolutionSchema = UserSolutionSchema;
|
|
332
|
+
exports.parseMongooseCompositeIpAddress = parseMongooseCompositeIpAddress;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import "./types/index.js";
|
|
2
|
-
import { CaptchaRecordSchema, ClientRecordSchema, DatasetRecordSchema, DetectorRecordSchema,
|
|
3
|
-
import { AccountSchema, TableNames, UserDataSchema, UserSettingsSchema } from "./types/client.js";
|
|
2
|
+
import { CaptchaRecordSchema, ClientRecordSchema, CompositeIpAddressRecordSchemaObj, CompositeIpAddressSchema, DatasetRecordSchema, DetectorRecordSchema, IpAddressType, PendingRecordSchema, PoWCaptchaRecordSchema, ScheduledTaskRecordSchema, ScheduledTaskSchema, SessionRecordSchema, SolutionRecordSchema, UserCommitmentRecordSchema, UserCommitmentSchema, UserCommitmentWithSolutionsSchema, UserSolutionRecordSchema, UserSolutionSchema, parseMongooseCompositeIpAddress } from "./types/provider.js";
|
|
3
|
+
import { AccountSchema, IPValidationRulesSchema, TableNames, UserDataSchema, UserSettingsSchema } from "./types/client.js";
|
|
4
4
|
import { StoredPoWCaptchaRecordSchema, StoredSessionRecordSchema, StoredUserCommitmentRecordSchema } from "./types/captcha.js";
|
|
5
5
|
export {
|
|
6
6
|
AccountSchema,
|
|
7
7
|
CaptchaRecordSchema,
|
|
8
8
|
ClientRecordSchema,
|
|
9
|
+
CompositeIpAddressRecordSchemaObj,
|
|
10
|
+
CompositeIpAddressSchema,
|
|
9
11
|
DatasetRecordSchema,
|
|
10
12
|
DetectorRecordSchema,
|
|
11
|
-
|
|
13
|
+
IPValidationRulesSchema,
|
|
14
|
+
IpAddressType,
|
|
12
15
|
PendingRecordSchema,
|
|
13
16
|
PoWCaptchaRecordSchema,
|
|
14
17
|
ScheduledTaskRecordSchema,
|
|
@@ -25,5 +28,6 @@ export {
|
|
|
25
28
|
UserDataSchema,
|
|
26
29
|
UserSettingsSchema,
|
|
27
30
|
UserSolutionRecordSchema,
|
|
28
|
-
UserSolutionSchema
|
|
31
|
+
UserSolutionSchema,
|
|
32
|
+
parseMongooseCompositeIpAddress
|
|
29
33
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiParams } from "@prosopo/types";
|
|
2
|
+
import type { CompositeIpAddress } from "../types/index.js";
|
|
3
|
+
export interface PendingCaptchaRequest {
|
|
4
|
+
accountId: string;
|
|
5
|
+
pending: boolean;
|
|
6
|
+
salt: string;
|
|
7
|
+
[ApiParams.requestHash]: string;
|
|
8
|
+
deadlineTimestamp: number;
|
|
9
|
+
requestedAtTimestamp: Date;
|
|
10
|
+
ipAddress: CompositeIpAddress;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
threshold: number;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=pendingCaptchaRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingCaptchaRequest.d.ts","sourceRoot":"","sources":["../../src/provider/pendingCaptchaRequest.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,IAAI,CAAC;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingCaptchaRequest.js","sourceRoot":"","sources":["../../src/provider/pendingCaptchaRequest.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PoWCaptcha } from "@prosopo/types";
|
|
2
|
+
import { type RootFilterQuery, Schema } from "mongoose";
|
|
3
|
+
import type { IDatabase } from "./mongo.js";
|
|
4
|
+
import { type PoWCaptchaRecord, type SessionRecord, type UserCommitment, type UserCommitmentRecord } from "./provider.js";
|
|
5
|
+
export type StoredSession = SessionRecord;
|
|
6
|
+
export declare const StoredSessionRecordSchema: Schema;
|
|
7
|
+
export declare const StoredUserCommitmentRecordSchema: Schema;
|
|
8
|
+
export declare const StoredPoWCaptchaRecordSchema: Schema;
|
|
9
|
+
export interface ICaptchaDatabase extends IDatabase {
|
|
10
|
+
saveCaptchas(sessionEvents: StoredSession[], imageCaptchaEvents: UserCommitmentRecord[], powCaptchaEvents: PoWCaptchaRecord[]): Promise<void>;
|
|
11
|
+
getCaptchas(filter: RootFilterQuery<CaptchaProperties>, limit: number): Promise<{
|
|
12
|
+
userCommitmentRecords: UserCommitmentRecord[];
|
|
13
|
+
powCaptchaRecords: PoWCaptchaRecord[];
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface CaptchaProperties extends Partial<UserCommitment & PoWCaptcha> {
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=captcha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/types/captcha.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAEzB,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C,eAAO,MAAM,yBAAyB,EAAE,MAA4B,CAAC;AAErE,eAAO,MAAM,gCAAgC,EAAE,MAE7C,CAAC;AAGH,eAAO,MAAM,4BAA4B,EAAE,MAEzC,CAAC;AAGH,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IAClD,YAAY,CACX,aAAa,EAAE,aAAa,EAAE,EAC9B,kBAAkB,EAAE,oBAAoB,EAAE,EAC1C,gBAAgB,EAAE,gBAAgB,EAAE,GAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,WAAW,CACV,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAC1C,KAAK,EAAE,MAAM,GACX,OAAO,CAAC;QACV,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;QAC9C,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;KACtC,CAAC,CAAC;CACH;AAED,MAAM,WAAW,iBAChB,SAAQ,OAAO,CAAC,cAAc,GAAG,UAAU,CAAC;CAAG"}
|
package/dist/types/captcha.js
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import {
|
|
3
|
-
const StoredSessionRecordSchema =
|
|
4
|
-
sessionId: SessionRecordSchema.obj.sessionId,
|
|
5
|
-
createdAt: SessionRecordSchema.obj.createdAt,
|
|
6
|
-
captchaType: SessionRecordSchema.obj.captchaType,
|
|
7
|
-
tokenId: SessionRecordSchema.obj.tokenId,
|
|
8
|
-
deleted: SessionRecordSchema.obj.deleted,
|
|
9
|
-
score: FrictionlessTokenRecordSchema.obj.score,
|
|
10
|
-
scoreComponents: FrictionlessTokenRecordSchema.obj.scoreComponents,
|
|
11
|
-
threshold: FrictionlessTokenRecordSchema.obj.threshold
|
|
12
|
-
});
|
|
2
|
+
import { SessionRecordSchema, UserCommitmentRecordSchema, PoWCaptchaRecordSchema } from "./provider.js";
|
|
3
|
+
const StoredSessionRecordSchema = SessionRecordSchema;
|
|
13
4
|
const StoredUserCommitmentRecordSchema = new Schema({
|
|
14
5
|
...UserCommitmentRecordSchema.obj
|
|
15
6
|
});
|
|
16
|
-
StoredUserCommitmentRecordSchema.index({
|
|
7
|
+
StoredUserCommitmentRecordSchema.index({ sessionId: 1 });
|
|
17
8
|
const StoredPoWCaptchaRecordSchema = new Schema({
|
|
18
9
|
...PoWCaptchaRecordSchema.obj
|
|
19
10
|
});
|
|
20
|
-
StoredPoWCaptchaRecordSchema.index({
|
|
21
|
-
StoredSessionRecordSchema.index({ sessionId: 1 });
|
|
22
|
-
StoredSessionRecordSchema.index({ tokenId: 1 });
|
|
11
|
+
StoredPoWCaptchaRecordSchema.index({ sessionId: 1 });
|
|
23
12
|
export {
|
|
24
13
|
StoredPoWCaptchaRecordSchema,
|
|
25
14
|
StoredSessionRecordSchema,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/types/captcha.ts"],"names":[],"mappings":"AAeA,OAAO,EAAwB,MAAM,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAEN,sBAAsB,EAEtB,mBAAmB,EAGnB,0BAA0B,GAC1B,MAAM,eAAe,CAAC;AAKvB,MAAM,CAAC,MAAM,yBAAyB,GAAW,mBAAmB,CAAC;AAErE,MAAM,CAAC,MAAM,gCAAgC,GAAW,IAAI,MAAM,CAAC;IAClE,GAAG,0BAA0B,CAAC,GAAG;CACjC,CAAC,CAAC;AACH,gCAAgC,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,4BAA4B,GAAW,IAAI,MAAM,CAAC;IAC9D,GAAG,sBAAsB,CAAC,GAAG;CAC7B,CAAC,CAAC;AACH,4BAA4B,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { type IUserData, type IUserSettings, type Timestamp } from "@prosopo/types";
|
|
2
|
+
import type mongoose from "mongoose";
|
|
3
|
+
import type { IDatabase } from "./mongo.js";
|
|
4
|
+
import type { ClientRecord, Tables } from "./provider.js";
|
|
5
|
+
export type UserDataRecord = mongoose.Document & IUserData;
|
|
6
|
+
export declare const IPValidationRulesSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
7
|
+
distanceThresholdKm: number;
|
|
8
|
+
abuseScoreThreshold: number;
|
|
9
|
+
requireAllConditions: boolean;
|
|
10
|
+
forceConsistentIp: boolean;
|
|
11
|
+
actions?: {
|
|
12
|
+
countryChangeAction: any;
|
|
13
|
+
cityChangeAction: any;
|
|
14
|
+
ispChangeAction: any;
|
|
15
|
+
distanceExceedAction: any;
|
|
16
|
+
abuseScoreExceedAction: any;
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
countryOverrides?: Map<string, {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
} | {
|
|
21
|
+
actions?: {
|
|
22
|
+
countryChangeAction?: any;
|
|
23
|
+
cityChangeAction?: any;
|
|
24
|
+
ispChangeAction?: any;
|
|
25
|
+
distanceExceedAction?: any;
|
|
26
|
+
abuseScoreExceedAction?: any;
|
|
27
|
+
} | null | undefined;
|
|
28
|
+
distanceThresholdKm?: number | null | undefined;
|
|
29
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
30
|
+
requireAllConditions?: boolean | null | undefined;
|
|
31
|
+
}> | null | undefined;
|
|
32
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
33
|
+
distanceThresholdKm: number;
|
|
34
|
+
abuseScoreThreshold: number;
|
|
35
|
+
requireAllConditions: boolean;
|
|
36
|
+
forceConsistentIp: boolean;
|
|
37
|
+
actions?: {
|
|
38
|
+
countryChangeAction: any;
|
|
39
|
+
cityChangeAction: any;
|
|
40
|
+
ispChangeAction: any;
|
|
41
|
+
distanceExceedAction: any;
|
|
42
|
+
abuseScoreExceedAction: any;
|
|
43
|
+
} | null | undefined;
|
|
44
|
+
countryOverrides?: Map<string, {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
actions?: {
|
|
48
|
+
countryChangeAction?: any;
|
|
49
|
+
cityChangeAction?: any;
|
|
50
|
+
ispChangeAction?: any;
|
|
51
|
+
distanceExceedAction?: any;
|
|
52
|
+
abuseScoreExceedAction?: any;
|
|
53
|
+
} | null | undefined;
|
|
54
|
+
distanceThresholdKm?: number | null | undefined;
|
|
55
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
56
|
+
requireAllConditions?: boolean | null | undefined;
|
|
57
|
+
}> | null | undefined;
|
|
58
|
+
}>> & mongoose.FlatRecord<{
|
|
59
|
+
distanceThresholdKm: number;
|
|
60
|
+
abuseScoreThreshold: number;
|
|
61
|
+
requireAllConditions: boolean;
|
|
62
|
+
forceConsistentIp: boolean;
|
|
63
|
+
actions?: {
|
|
64
|
+
countryChangeAction: any;
|
|
65
|
+
cityChangeAction: any;
|
|
66
|
+
ispChangeAction: any;
|
|
67
|
+
distanceExceedAction: any;
|
|
68
|
+
abuseScoreExceedAction: any;
|
|
69
|
+
} | null | undefined;
|
|
70
|
+
countryOverrides?: Map<string, {
|
|
71
|
+
[x: string]: unknown;
|
|
72
|
+
} | {
|
|
73
|
+
actions?: {
|
|
74
|
+
countryChangeAction?: any;
|
|
75
|
+
cityChangeAction?: any;
|
|
76
|
+
ispChangeAction?: any;
|
|
77
|
+
distanceExceedAction?: any;
|
|
78
|
+
abuseScoreExceedAction?: any;
|
|
79
|
+
} | null | undefined;
|
|
80
|
+
distanceThresholdKm?: number | null | undefined;
|
|
81
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
82
|
+
requireAllConditions?: boolean | null | undefined;
|
|
83
|
+
}> | null | undefined;
|
|
84
|
+
}> & {
|
|
85
|
+
_id: mongoose.Types.ObjectId;
|
|
86
|
+
} & {
|
|
87
|
+
__v: number;
|
|
88
|
+
}>;
|
|
89
|
+
export declare const UserSettingsSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
90
|
+
domains: string[];
|
|
91
|
+
disallowWebView: boolean;
|
|
92
|
+
captchaType?: string | null | undefined;
|
|
93
|
+
frictionlessThreshold?: number | null | undefined;
|
|
94
|
+
powDifficulty?: number | null | undefined;
|
|
95
|
+
imageThreshold?: number | null | undefined;
|
|
96
|
+
ipValidationRules?: {
|
|
97
|
+
distanceThresholdKm: number;
|
|
98
|
+
abuseScoreThreshold: number;
|
|
99
|
+
requireAllConditions: boolean;
|
|
100
|
+
forceConsistentIp: boolean;
|
|
101
|
+
actions?: {
|
|
102
|
+
countryChangeAction: any;
|
|
103
|
+
cityChangeAction: any;
|
|
104
|
+
ispChangeAction: any;
|
|
105
|
+
distanceExceedAction: any;
|
|
106
|
+
abuseScoreExceedAction: any;
|
|
107
|
+
} | null | undefined;
|
|
108
|
+
countryOverrides?: Map<string, {
|
|
109
|
+
[x: string]: unknown;
|
|
110
|
+
} | {
|
|
111
|
+
actions?: {
|
|
112
|
+
countryChangeAction?: any;
|
|
113
|
+
cityChangeAction?: any;
|
|
114
|
+
ispChangeAction?: any;
|
|
115
|
+
distanceExceedAction?: any;
|
|
116
|
+
abuseScoreExceedAction?: any;
|
|
117
|
+
} | null | undefined;
|
|
118
|
+
distanceThresholdKm?: number | null | undefined;
|
|
119
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
120
|
+
requireAllConditions?: boolean | null | undefined;
|
|
121
|
+
}> | null | undefined;
|
|
122
|
+
} | null | undefined;
|
|
123
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
124
|
+
domains: string[];
|
|
125
|
+
disallowWebView: boolean;
|
|
126
|
+
captchaType?: string | null | undefined;
|
|
127
|
+
frictionlessThreshold?: number | null | undefined;
|
|
128
|
+
powDifficulty?: number | null | undefined;
|
|
129
|
+
imageThreshold?: number | null | undefined;
|
|
130
|
+
ipValidationRules?: {
|
|
131
|
+
distanceThresholdKm: number;
|
|
132
|
+
abuseScoreThreshold: number;
|
|
133
|
+
requireAllConditions: boolean;
|
|
134
|
+
forceConsistentIp: boolean;
|
|
135
|
+
actions?: {
|
|
136
|
+
countryChangeAction: any;
|
|
137
|
+
cityChangeAction: any;
|
|
138
|
+
ispChangeAction: any;
|
|
139
|
+
distanceExceedAction: any;
|
|
140
|
+
abuseScoreExceedAction: any;
|
|
141
|
+
} | null | undefined;
|
|
142
|
+
countryOverrides?: Map<string, {
|
|
143
|
+
[x: string]: unknown;
|
|
144
|
+
} | {
|
|
145
|
+
actions?: {
|
|
146
|
+
countryChangeAction?: any;
|
|
147
|
+
cityChangeAction?: any;
|
|
148
|
+
ispChangeAction?: any;
|
|
149
|
+
distanceExceedAction?: any;
|
|
150
|
+
abuseScoreExceedAction?: any;
|
|
151
|
+
} | null | undefined;
|
|
152
|
+
distanceThresholdKm?: number | null | undefined;
|
|
153
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
154
|
+
requireAllConditions?: boolean | null | undefined;
|
|
155
|
+
}> | null | undefined;
|
|
156
|
+
} | null | undefined;
|
|
157
|
+
}>> & mongoose.FlatRecord<{
|
|
158
|
+
domains: string[];
|
|
159
|
+
disallowWebView: boolean;
|
|
160
|
+
captchaType?: string | null | undefined;
|
|
161
|
+
frictionlessThreshold?: number | null | undefined;
|
|
162
|
+
powDifficulty?: number | null | undefined;
|
|
163
|
+
imageThreshold?: number | null | undefined;
|
|
164
|
+
ipValidationRules?: {
|
|
165
|
+
distanceThresholdKm: number;
|
|
166
|
+
abuseScoreThreshold: number;
|
|
167
|
+
requireAllConditions: boolean;
|
|
168
|
+
forceConsistentIp: boolean;
|
|
169
|
+
actions?: {
|
|
170
|
+
countryChangeAction: any;
|
|
171
|
+
cityChangeAction: any;
|
|
172
|
+
ispChangeAction: any;
|
|
173
|
+
distanceExceedAction: any;
|
|
174
|
+
abuseScoreExceedAction: any;
|
|
175
|
+
} | null | undefined;
|
|
176
|
+
countryOverrides?: Map<string, {
|
|
177
|
+
[x: string]: unknown;
|
|
178
|
+
} | {
|
|
179
|
+
actions?: {
|
|
180
|
+
countryChangeAction?: any;
|
|
181
|
+
cityChangeAction?: any;
|
|
182
|
+
ispChangeAction?: any;
|
|
183
|
+
distanceExceedAction?: any;
|
|
184
|
+
abuseScoreExceedAction?: any;
|
|
185
|
+
} | null | undefined;
|
|
186
|
+
distanceThresholdKm?: number | null | undefined;
|
|
187
|
+
abuseScoreThreshold?: number | null | undefined;
|
|
188
|
+
requireAllConditions?: boolean | null | undefined;
|
|
189
|
+
}> | null | undefined;
|
|
190
|
+
} | null | undefined;
|
|
191
|
+
}> & {
|
|
192
|
+
_id: mongoose.Types.ObjectId;
|
|
193
|
+
} & {
|
|
194
|
+
__v: number;
|
|
195
|
+
}>;
|
|
196
|
+
export declare const UserDataSchema: mongoose.Schema<UserDataRecord>;
|
|
197
|
+
type User = {
|
|
198
|
+
email: string;
|
|
199
|
+
name: string;
|
|
200
|
+
role: string;
|
|
201
|
+
createdAt: number;
|
|
202
|
+
updatedAt: number;
|
|
203
|
+
status: string;
|
|
204
|
+
};
|
|
205
|
+
type AccountRecord = mongoose.Document & {
|
|
206
|
+
createdAt: number;
|
|
207
|
+
updatedAt: number;
|
|
208
|
+
signupEmail: string;
|
|
209
|
+
tier: string;
|
|
210
|
+
tierRequestQuota: number;
|
|
211
|
+
marketingPreferences: boolean;
|
|
212
|
+
users: User[];
|
|
213
|
+
sites: {
|
|
214
|
+
name: string;
|
|
215
|
+
siteKey: string;
|
|
216
|
+
secretKey: string;
|
|
217
|
+
settings: IUserSettings;
|
|
218
|
+
createdAt: number;
|
|
219
|
+
updatedAt: number;
|
|
220
|
+
active: boolean;
|
|
221
|
+
}[];
|
|
222
|
+
deletedUsers: User[];
|
|
223
|
+
};
|
|
224
|
+
export declare const AccountSchema: mongoose.Schema<AccountRecord, mongoose.Model<AccountRecord, any, any, any, mongoose.Document<unknown, any, AccountRecord> & mongoose.Document<unknown, any, any> & {
|
|
225
|
+
createdAt: number;
|
|
226
|
+
updatedAt: number;
|
|
227
|
+
signupEmail: string;
|
|
228
|
+
tier: string;
|
|
229
|
+
tierRequestQuota: number;
|
|
230
|
+
marketingPreferences: boolean;
|
|
231
|
+
users: User[];
|
|
232
|
+
sites: {
|
|
233
|
+
name: string;
|
|
234
|
+
siteKey: string;
|
|
235
|
+
secretKey: string;
|
|
236
|
+
settings: IUserSettings;
|
|
237
|
+
createdAt: number;
|
|
238
|
+
updatedAt: number;
|
|
239
|
+
active: boolean;
|
|
240
|
+
}[];
|
|
241
|
+
deletedUsers: User[];
|
|
242
|
+
} & Required<{
|
|
243
|
+
_id: unknown;
|
|
244
|
+
}> & {
|
|
245
|
+
__v: number;
|
|
246
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, AccountRecord, mongoose.Document<unknown, {}, mongoose.FlatRecord<AccountRecord>> & mongoose.FlatRecord<AccountRecord> & Required<{
|
|
247
|
+
_id: unknown;
|
|
248
|
+
}> & {
|
|
249
|
+
__v: number;
|
|
250
|
+
}>;
|
|
251
|
+
export declare enum TableNames {
|
|
252
|
+
accounts = "accounts"
|
|
253
|
+
}
|
|
254
|
+
export interface IClientDatabase extends IDatabase {
|
|
255
|
+
getTables(): Tables<TableNames>;
|
|
256
|
+
getUpdatedClients(updatedAtTimestamp: Timestamp): Promise<ClientRecord[]>;
|
|
257
|
+
}
|
|
258
|
+
export {};
|
|
259
|
+
//# sourceMappingURL=client.d.ts.map
|