@prosopo/types-database 3.0.9 → 3.0.11
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 +26 -0
- package/dist/cjs/types/index.cjs +1 -0
- package/dist/cjs/types/provider.cjs +2 -0
- package/dist/cjs/types/userAgent.cjs +1 -0
- package/dist/index.js +29 -2
- package/dist/types/captcha.js +19 -15
- package/dist/types/client.js +64 -59
- package/dist/types/index.js +30 -5
- package/dist/types/mongo.js +1 -2
- package/dist/types/provider.js +224 -197
- package/dist/types/userAgent.js +1 -0
- package/package.json +21 -17
- package/vite.cjs.config.ts +2 -2
- package/vite.esm.config.ts +20 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/provider/pendingCaptchaRequest.d.ts +0 -14
- package/dist/provider/pendingCaptchaRequest.d.ts.map +0 -1
- package/dist/provider/pendingCaptchaRequest.js +0 -2
- package/dist/provider/pendingCaptchaRequest.js.map +0 -1
- package/dist/types/captcha.d.ts +0 -22
- package/dist/types/captcha.d.ts.map +0 -1
- package/dist/types/captcha.js.map +0 -1
- package/dist/types/client.d.ts +0 -92
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/client.js.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/mongo.d.ts +0 -13
- package/dist/types/mongo.d.ts.map +0 -1
- package/dist/types/mongo.js.map +0 -1
- package/dist/types/provider.d.ts +0 -526
- package/dist/types/provider.d.ts.map +0 -1
- package/dist/types/provider.js.map +0 -1
package/dist/types/provider.js
CHANGED
|
@@ -1,254 +1,281 @@
|
|
|
1
1
|
import { TranslationKeysSchema } from "@prosopo/locale";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Schema } from "mongoose";
|
|
6
|
-
import { any, array, bigint, boolean, nativeEnum, object, string, union, instanceof as zInstanceof, } from "zod";
|
|
2
|
+
import { Tier, CaptchaStatus, TimestampSchema, CaptchaSolutionSchema, ScheduledTaskStatus, ScheduledTaskNames, CaptchaType } from "@prosopo/types";
|
|
3
|
+
import mongoose, { Schema } from "mongoose";
|
|
4
|
+
import { object, string, nativeEnum, union, instanceof as _instanceof, boolean, bigint, array, any } from "zod";
|
|
7
5
|
import { UserSettingsSchema } from "./client.js";
|
|
8
6
|
const ONE_HOUR = 60 * 60;
|
|
9
7
|
const ONE_DAY = ONE_HOUR * 24;
|
|
10
8
|
const ONE_WEEK = ONE_DAY * 7;
|
|
11
9
|
const ONE_MONTH = ONE_WEEK * 4;
|
|
12
10
|
const TEN_MINUTES = 10 * 60;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const ClientRecordSchema = new Schema({
|
|
12
|
+
account: String,
|
|
13
|
+
settings: UserSettingsSchema,
|
|
14
|
+
tier: { type: String, enum: Tier, required: true }
|
|
17
15
|
});
|
|
18
16
|
ClientRecordSchema.index({ account: 1 });
|
|
19
17
|
const CaptchaResultSchema = object({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
18
|
+
status: nativeEnum(CaptchaStatus),
|
|
19
|
+
reason: TranslationKeysSchema.optional(),
|
|
20
|
+
error: string().optional()
|
|
21
|
+
});
|
|
22
|
+
const UserCommitmentSchema = object({
|
|
23
|
+
userAccount: string(),
|
|
24
|
+
dappAccount: string(),
|
|
25
|
+
datasetId: string(),
|
|
26
|
+
providerAccount: string(),
|
|
27
|
+
id: string(),
|
|
28
|
+
result: CaptchaResultSchema,
|
|
29
|
+
userSignature: string(),
|
|
30
|
+
ipAddress: bigint(),
|
|
31
|
+
headers: object({}).catchall(string()),
|
|
32
|
+
ja4: string(),
|
|
33
|
+
userSubmitted: boolean(),
|
|
34
|
+
serverChecked: boolean(),
|
|
35
|
+
storedAtTimestamp: TimestampSchema.optional(),
|
|
36
|
+
requestedAtTimestamp: TimestampSchema,
|
|
37
|
+
lastUpdatedTimestamp: TimestampSchema.optional(),
|
|
38
|
+
frictionlessTokenId: union([
|
|
39
|
+
string(),
|
|
40
|
+
_instanceof(mongoose.Types.ObjectId)
|
|
41
|
+
]).optional()
|
|
42
|
+
});
|
|
43
|
+
const CaptchaRecordSchema = new Schema({
|
|
44
|
+
captchaId: { type: String, required: true },
|
|
45
|
+
captchaContentId: { type: String, required: true },
|
|
46
|
+
assetURI: { type: String, required: false },
|
|
47
|
+
datasetId: { type: String, required: true },
|
|
48
|
+
datasetContentId: { type: String, required: true },
|
|
49
|
+
solved: { type: Boolean, required: true },
|
|
50
|
+
target: { type: String, required: true },
|
|
51
|
+
salt: { type: String, required: true },
|
|
52
|
+
items: {
|
|
53
|
+
type: [
|
|
54
|
+
new Schema(
|
|
55
|
+
{
|
|
56
|
+
hash: { type: String, required: true },
|
|
57
|
+
data: { type: String, required: true },
|
|
58
|
+
type: { type: String, required: true }
|
|
59
|
+
},
|
|
60
|
+
{ _id: false }
|
|
61
|
+
)
|
|
62
|
+
],
|
|
63
|
+
required: true
|
|
64
|
+
}
|
|
64
65
|
});
|
|
65
66
|
CaptchaRecordSchema.index({ captchaId: 1 });
|
|
66
67
|
CaptchaRecordSchema.index({ datasetId: 1 });
|
|
67
68
|
CaptchaRecordSchema.index({ datasetId: 1, solved: 1 });
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
error: { type: String, required: false },
|
|
82
|
-
},
|
|
83
|
-
difficulty: { type: Number, required: true },
|
|
84
|
-
ipAddress: { type: BigInt, required: true },
|
|
85
|
-
headers: { type: Object, required: true },
|
|
86
|
-
ja4: { type: String, required: true },
|
|
87
|
-
userSignature: { type: String, required: false },
|
|
88
|
-
userSubmitted: { type: Boolean, required: true },
|
|
89
|
-
serverChecked: { type: Boolean, required: true },
|
|
90
|
-
storedAtTimestamp: { type: Date, required: false, expires: ONE_MONTH },
|
|
91
|
-
geolocation: { type: String, required: false },
|
|
92
|
-
vpn: { type: Boolean, required: false },
|
|
93
|
-
frictionlessTokenId: {
|
|
94
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
95
|
-
required: false,
|
|
69
|
+
const PoWCaptchaRecordSchema = new Schema({
|
|
70
|
+
challenge: { type: String, required: true },
|
|
71
|
+
dappAccount: { type: String, required: true },
|
|
72
|
+
userAccount: { type: String, required: true },
|
|
73
|
+
requestedAtTimestamp: { type: Number, required: true },
|
|
74
|
+
lastUpdatedTimestamp: { type: Number, required: false },
|
|
75
|
+
result: {
|
|
76
|
+
status: { type: String, enum: CaptchaStatus, required: true },
|
|
77
|
+
reason: {
|
|
78
|
+
type: String,
|
|
79
|
+
enum: TranslationKeysSchema.options,
|
|
80
|
+
required: false
|
|
96
81
|
},
|
|
82
|
+
error: { type: String, required: false }
|
|
83
|
+
},
|
|
84
|
+
difficulty: { type: Number, required: true },
|
|
85
|
+
ipAddress: { type: BigInt, required: true },
|
|
86
|
+
headers: { type: Object, required: true },
|
|
87
|
+
ja4: { type: String, required: true },
|
|
88
|
+
userSignature: { type: String, required: false },
|
|
89
|
+
userSubmitted: { type: Boolean, required: true },
|
|
90
|
+
serverChecked: { type: Boolean, required: true },
|
|
91
|
+
storedAtTimestamp: { type: Date, required: false, expires: ONE_MONTH },
|
|
92
|
+
geolocation: { type: String, required: false },
|
|
93
|
+
vpn: { type: Boolean, required: false },
|
|
94
|
+
parsedUserAgentInfo: { type: Object, required: false },
|
|
95
|
+
frictionlessTokenId: {
|
|
96
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
97
|
+
required: false
|
|
98
|
+
}
|
|
97
99
|
});
|
|
98
100
|
PoWCaptchaRecordSchema.index({ challenge: 1 });
|
|
99
101
|
PoWCaptchaRecordSchema.index({ storedAtTimestamp: 1 });
|
|
100
102
|
PoWCaptchaRecordSchema.index({ storedAtTimestamp: 1, lastUpdatedTimestamp: 1 });
|
|
101
103
|
PoWCaptchaRecordSchema.index({ dappAccount: 1, requestedAtTimestamp: 1 });
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
error: { type: String, required: false },
|
|
116
|
-
},
|
|
117
|
-
ipAddress: { type: BigInt, required: true },
|
|
118
|
-
headers: { type: Object, required: true },
|
|
119
|
-
ja4: { type: String, required: true },
|
|
120
|
-
userSignature: { type: String, required: true },
|
|
121
|
-
userSubmitted: { type: Boolean, required: true },
|
|
122
|
-
serverChecked: { type: Boolean, required: true },
|
|
123
|
-
storedAtTimestamp: { type: Number, required: false },
|
|
124
|
-
requestedAtTimestamp: { type: Number, required: true },
|
|
125
|
-
lastUpdatedTimestamp: { type: Number, required: false },
|
|
126
|
-
geolocation: { type: String, required: false },
|
|
127
|
-
vpn: { type: Boolean, required: false },
|
|
128
|
-
frictionlessTokenId: {
|
|
129
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
130
|
-
required: false,
|
|
104
|
+
const UserCommitmentRecordSchema = new Schema({
|
|
105
|
+
userAccount: { type: String, required: true },
|
|
106
|
+
dappAccount: { type: String, required: true },
|
|
107
|
+
providerAccount: { type: String, required: true },
|
|
108
|
+
datasetId: { type: String, required: true },
|
|
109
|
+
id: { type: String, required: true },
|
|
110
|
+
result: {
|
|
111
|
+
status: { type: String, enum: CaptchaStatus, required: true },
|
|
112
|
+
reason: {
|
|
113
|
+
type: String,
|
|
114
|
+
enum: TranslationKeysSchema.options,
|
|
115
|
+
required: false
|
|
131
116
|
},
|
|
117
|
+
error: { type: String, required: false }
|
|
118
|
+
},
|
|
119
|
+
ipAddress: { type: BigInt, required: true },
|
|
120
|
+
headers: { type: Object, required: true },
|
|
121
|
+
ja4: { type: String, required: true },
|
|
122
|
+
userSignature: { type: String, required: true },
|
|
123
|
+
userSubmitted: { type: Boolean, required: true },
|
|
124
|
+
serverChecked: { type: Boolean, required: true },
|
|
125
|
+
storedAtTimestamp: { type: Number, required: false },
|
|
126
|
+
requestedAtTimestamp: { type: Number, required: true },
|
|
127
|
+
lastUpdatedTimestamp: { type: Number, required: false },
|
|
128
|
+
geolocation: { type: String, required: false },
|
|
129
|
+
vpn: { type: Boolean, required: false },
|
|
130
|
+
parsedUserAgentInfo: { type: Object, required: false },
|
|
131
|
+
frictionlessTokenId: {
|
|
132
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
133
|
+
required: false
|
|
134
|
+
}
|
|
132
135
|
});
|
|
133
136
|
UserCommitmentRecordSchema.index({ id: -1 });
|
|
134
137
|
UserCommitmentRecordSchema.index({ storedAtTimestamp: 1 });
|
|
135
138
|
UserCommitmentRecordSchema.index({
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
storedAtTimestamp: 1,
|
|
140
|
+
lastUpdatedTimestamp: 1
|
|
138
141
|
});
|
|
139
142
|
UserCommitmentRecordSchema.index({ userAccount: 1, dappAccount: 1 });
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const DatasetRecordSchema = new Schema({
|
|
144
|
+
contentTree: { type: [[String]], required: true },
|
|
145
|
+
datasetContentId: { type: String, required: true },
|
|
146
|
+
datasetId: { type: String, required: true },
|
|
147
|
+
format: { type: String, required: true },
|
|
148
|
+
solutionTree: { type: [[String]], required: true }
|
|
146
149
|
});
|
|
147
150
|
DatasetRecordSchema.index({ datasetId: 1 });
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
const SolutionRecordSchema = new Schema({
|
|
152
|
+
captchaId: { type: String, required: true },
|
|
153
|
+
captchaContentId: { type: String, required: true },
|
|
154
|
+
datasetId: { type: String, required: true },
|
|
155
|
+
datasetContentId: { type: String, required: true },
|
|
156
|
+
salt: { type: String, required: true },
|
|
157
|
+
solution: { type: [String], required: true }
|
|
155
158
|
});
|
|
156
159
|
SolutionRecordSchema.index({ captchaId: 1 });
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
const UserSolutionSchema = CaptchaSolutionSchema.extend({
|
|
161
|
+
processed: boolean(),
|
|
162
|
+
checked: boolean(),
|
|
163
|
+
commitmentId: string()
|
|
161
164
|
});
|
|
162
|
-
|
|
165
|
+
const UserSolutionRecordSchema = new Schema(
|
|
166
|
+
{
|
|
163
167
|
captchaId: { type: String, required: true },
|
|
164
168
|
captchaContentId: { type: String, required: true },
|
|
165
169
|
salt: { type: String, required: true },
|
|
166
170
|
solution: [{ type: String, required: true }],
|
|
167
171
|
processed: { type: Boolean, required: true },
|
|
168
172
|
checked: { type: Boolean, required: true },
|
|
169
|
-
commitmentId: { type: String, required: true }
|
|
170
|
-
},
|
|
173
|
+
commitmentId: { type: String, required: true }
|
|
174
|
+
},
|
|
175
|
+
{ _id: false }
|
|
176
|
+
);
|
|
171
177
|
UserSolutionRecordSchema.index({ captchaId: 1 });
|
|
172
178
|
UserSolutionRecordSchema.index({ commitmentId: -1 });
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
const UserCommitmentWithSolutionsSchema = UserCommitmentSchema.extend({
|
|
180
|
+
captchas: array(UserSolutionSchema)
|
|
175
181
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
const PendingRecordSchema = new Schema({
|
|
183
|
+
accountId: { type: String, required: true },
|
|
184
|
+
pending: { type: Boolean, required: true },
|
|
185
|
+
salt: { type: String, required: true },
|
|
186
|
+
requestHash: { type: String, required: true },
|
|
187
|
+
deadlineTimestamp: { type: Number, required: true },
|
|
188
|
+
// unix timestamp
|
|
189
|
+
requestedAtTimestamp: { type: Date, required: true, expires: ONE_WEEK },
|
|
190
|
+
ipAddress: { type: BigInt, required: true },
|
|
191
|
+
frictionlessTokenId: {
|
|
192
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
threshold: { type: Number, required: true, default: 0.8 }
|
|
189
196
|
});
|
|
190
197
|
PendingRecordSchema.index({ requestHash: -1 });
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
198
|
+
const ScheduledTaskSchema = object({
|
|
199
|
+
processName: nativeEnum(ScheduledTaskNames),
|
|
200
|
+
datetime: TimestampSchema,
|
|
201
|
+
updated: TimestampSchema.optional(),
|
|
202
|
+
status: nativeEnum(ScheduledTaskStatus),
|
|
203
|
+
result: object({
|
|
204
|
+
data: any().optional(),
|
|
205
|
+
error: any().optional()
|
|
206
|
+
}).optional()
|
|
207
|
+
});
|
|
208
|
+
const ScheduledTaskRecordSchema = new Schema({
|
|
209
|
+
processName: { type: String, enum: ScheduledTaskNames, required: true },
|
|
210
|
+
datetime: { type: Date, required: true, expires: ONE_WEEK },
|
|
211
|
+
updated: { type: Number, required: false },
|
|
212
|
+
status: { type: String, enum: ScheduledTaskStatus, required: true },
|
|
213
|
+
result: {
|
|
214
|
+
type: new Schema(
|
|
215
|
+
{
|
|
216
|
+
error: { type: String, required: false },
|
|
217
|
+
data: { type: Object, required: false }
|
|
218
|
+
},
|
|
219
|
+
{ _id: false }
|
|
220
|
+
),
|
|
221
|
+
required: false
|
|
222
|
+
}
|
|
213
223
|
});
|
|
214
224
|
ScheduledTaskRecordSchema.index({ processName: 1 });
|
|
215
225
|
ScheduledTaskRecordSchema.index({ processName: 1, status: 1 });
|
|
216
226
|
ScheduledTaskRecordSchema.index({ _id: 1, status: 1 });
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
const FrictionlessTokenRecordSchema = new Schema({
|
|
228
|
+
token: { type: String, required: true, unique: true },
|
|
229
|
+
score: { type: Number, required: true },
|
|
230
|
+
threshold: { type: Number, required: true },
|
|
231
|
+
scoreComponents: {
|
|
232
|
+
baseScore: { type: Number, required: true },
|
|
233
|
+
lScore: { type: Number, required: false },
|
|
234
|
+
timeout: { type: Number, required: false },
|
|
235
|
+
accessPolicy: { type: Number, required: false }
|
|
236
|
+
},
|
|
237
|
+
createdAt: { type: Date, default: Date.now, expires: ONE_DAY },
|
|
238
|
+
storedAtTimestamp: { type: Date, required: false },
|
|
239
|
+
lastUpdatedTimestamp: { type: Date, required: false }
|
|
230
240
|
});
|
|
231
241
|
FrictionlessTokenRecordSchema.index({ token: 1 }, { unique: true });
|
|
232
242
|
FrictionlessTokenRecordSchema.index({ storedAtTimestamp: 1 });
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
const SessionRecordSchema = new Schema({
|
|
244
|
+
sessionId: { type: String, required: true, unique: true },
|
|
245
|
+
createdAt: { type: Date, required: true, expires: ONE_DAY },
|
|
246
|
+
tokenId: {
|
|
247
|
+
type: mongoose.Schema.Types.ObjectId
|
|
248
|
+
},
|
|
249
|
+
captchaType: { type: String, enum: CaptchaType, required: true },
|
|
250
|
+
storedAtTimestamp: { type: Date, required: false },
|
|
251
|
+
lastUpdatedTimestamp: { type: Date, required: false },
|
|
252
|
+
deleted: { type: Boolean, required: false }
|
|
243
253
|
});
|
|
244
254
|
SessionRecordSchema.index({ sessionId: 1 }, { unique: true });
|
|
245
255
|
SessionRecordSchema.index({ storedAtTimestamp: 1 });
|
|
246
256
|
SessionRecordSchema.index({ deleted: 1 });
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
257
|
+
const DetectorRecordSchema = new Schema({
|
|
258
|
+
createdAt: { type: Date, required: true },
|
|
259
|
+
detectorKey: { type: String, required: true },
|
|
260
|
+
expiresAt: { type: Date, required: false, expires: 0 }
|
|
251
261
|
});
|
|
252
262
|
DetectorRecordSchema.index({ createdAt: 1 }, { unique: true });
|
|
253
263
|
DetectorRecordSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
254
|
-
|
|
264
|
+
export {
|
|
265
|
+
CaptchaRecordSchema,
|
|
266
|
+
ClientRecordSchema,
|
|
267
|
+
DatasetRecordSchema,
|
|
268
|
+
DetectorRecordSchema,
|
|
269
|
+
FrictionlessTokenRecordSchema,
|
|
270
|
+
PendingRecordSchema,
|
|
271
|
+
PoWCaptchaRecordSchema,
|
|
272
|
+
ScheduledTaskRecordSchema,
|
|
273
|
+
ScheduledTaskSchema,
|
|
274
|
+
SessionRecordSchema,
|
|
275
|
+
SolutionRecordSchema,
|
|
276
|
+
UserCommitmentRecordSchema,
|
|
277
|
+
UserCommitmentSchema,
|
|
278
|
+
UserCommitmentWithSolutionsSchema,
|
|
279
|
+
UserSolutionRecordSchema,
|
|
280
|
+
UserSolutionSchema
|
|
281
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/types-database",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Types for prosopo database",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"npm": "10.8.2"
|
|
10
|
-
},
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
11
8
|
"exports": {
|
|
12
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
13
11
|
"import": "./dist/index.js",
|
|
14
12
|
"require": "./dist/cjs/index.cjs"
|
|
15
13
|
}
|
|
16
14
|
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "20",
|
|
17
|
+
"npm": "10.8.2"
|
|
18
|
+
},
|
|
17
19
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"build": "tsc --build --verbose",
|
|
21
|
-
"build:cjs": "
|
|
20
|
+
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
|
|
21
|
+
"build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
|
|
22
|
+
"build:tsc": "tsc --build --verbose",
|
|
23
|
+
"build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
|
|
24
|
+
"typecheck": "tsc --build --declaration --emitDeclarationOnly",
|
|
25
|
+
"test": "echo no tests"
|
|
22
26
|
},
|
|
23
27
|
"repository": {
|
|
24
28
|
"type": "git",
|
|
@@ -31,21 +35,21 @@
|
|
|
31
35
|
},
|
|
32
36
|
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
33
37
|
"dependencies": {
|
|
34
|
-
"@prosopo/common": "3.0
|
|
35
|
-
"@prosopo/types": "3.0.
|
|
36
|
-
"@prosopo/user-access-policy": "3.3.
|
|
38
|
+
"@prosopo/common": "3.1.0",
|
|
39
|
+
"@prosopo/types": "3.0.4",
|
|
40
|
+
"@prosopo/user-access-policy": "3.3.1",
|
|
37
41
|
"@typegoose/auto-increment": "4.13.0",
|
|
38
42
|
"axios": "1.10.0",
|
|
39
43
|
"esbuild": "0.25.6",
|
|
40
44
|
"express": "4.21.2",
|
|
41
45
|
"mongodb": "6.9.0",
|
|
42
|
-
"mongoose": "8.
|
|
46
|
+
"mongoose": "8.6.2",
|
|
47
|
+
"zod": "3.23.8",
|
|
48
|
+
"@prosopo/config": "3.1.1",
|
|
43
49
|
"openpgp": "5.11.3",
|
|
44
|
-
"webpack-dev-server": "5.2.2"
|
|
45
|
-
"zod": "3.23.8"
|
|
50
|
+
"webpack-dev-server": "5.2.2"
|
|
46
51
|
},
|
|
47
52
|
"devDependencies": {
|
|
48
|
-
"@prosopo/config": "3.1.0",
|
|
49
53
|
"@vitest/coverage-v8": "3.0.9",
|
|
50
54
|
"concurrently": "9.0.1",
|
|
51
55
|
"del-cli": "6.0.0",
|
package/vite.cjs.config.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { ViteEsmConfig } from "@prosopo/config";
|
|
17
|
+
|
|
18
|
+
export default function () {
|
|
19
|
+
return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
|
|
20
|
+
}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ApiParams } from "@prosopo/types";
|
|
2
|
-
import type { FrictionlessTokenId } 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: number;
|
|
10
|
-
ipAddress: bigint;
|
|
11
|
-
frictionlessTokenId?: FrictionlessTokenId;
|
|
12
|
-
threshold: number;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=pendingCaptchaRequest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pendingCaptchaRequest.d.ts","sourceRoot":"","sources":["../../src/provider/pendingCaptchaRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,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,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pendingCaptchaRequest.js","sourceRoot":"","sources":["../../src/provider/pendingCaptchaRequest.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC"}
|
package/dist/types/captcha.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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 ScoreComponents, type SessionRecord, type UserCommitment, type UserCommitmentRecord } from "./provider.js";
|
|
5
|
-
export type StoredSession = Pick<SessionRecord, "_id" | "sessionId" | "createdAt" | "captchaType" | "deleted" | "tokenId"> & {
|
|
6
|
-
score: number;
|
|
7
|
-
scoreComponents: ScoreComponents;
|
|
8
|
-
threshold: number;
|
|
9
|
-
};
|
|
10
|
-
export declare const StoredSessionRecordSchema: Schema;
|
|
11
|
-
export declare const StoredUserCommitmentRecordSchema: Schema;
|
|
12
|
-
export declare const StoredPoWCaptchaRecordSchema: Schema;
|
|
13
|
-
export interface ICaptchaDatabase extends IDatabase {
|
|
14
|
-
saveCaptchas(sessionEvents: StoredSession[], imageCaptchaEvents: UserCommitmentRecord[], powCaptchaEvents: PoWCaptchaRecord[]): Promise<void>;
|
|
15
|
-
getCaptchas(filter: RootFilterQuery<CaptchaProperties>, limit: number): Promise<{
|
|
16
|
-
userCommitmentRecords: UserCommitmentRecord[];
|
|
17
|
-
powCaptchaRecords: PoWCaptchaRecord[];
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export interface CaptchaProperties extends Partial<UserCommitment & PoWCaptcha> {
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=captcha.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAEN,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAEzB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,aAAa,GAAG,IAAI,CAC/B,aAAa,EACb,KAAK,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,CACzE,GAAG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,MAStC,CAAC;AAEH,eAAO,MAAM,gCAAgC,EAAE,MAE7C,CAAC;AAGH,eAAO,MAAM,4BAA4B,EAAE,MAEzC,CAAC;AAOH,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"}
|