@prosopo/types-database 4.0.0 → 4.0.6

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.
@@ -0,0 +1,45 @@
1
+
2
+ > @prosopo/types-database@4.0.6 build:cjs
3
+ > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
+
5
+ ViteCommonJSConfig: .
6
+ {
7
+ tsConfigPaths: [
8
+ '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
9
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
10
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
11
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
12
+ '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
13
+ '/home/runner/work/captcha/captcha/packages/user-access-policy/tsconfig.json',
14
+ '/home/runner/work/captcha/captcha/packages/api-route/tsconfig.json',
15
+ '/home/runner/work/captcha/captcha/packages/redis-client/tsconfig.json',
16
+ '/home/runner/work/captcha/captcha/packages/api/tsconfig.json'
17
+ ]
18
+ }
19
+ {
20
+ externals: [
21
+ '@prosopo/common',
22
+ '@prosopo/locale',
23
+ '@prosopo/types',
24
+ '@prosopo/util',
25
+ '@prosopo/util-crypto',
26
+ '@prosopo/user-access-policy',
27
+ '@prosopo/api-route',
28
+ '@prosopo/redis-client',
29
+ '@prosopo/api'
30
+ ]
31
+ }
32
+ vite v6.4.1 building SSR bundle for production...
33
+ Bundle build started
34
+ transforming...
35
+ Build end
36
+ ✓ 7 modules transformed.
37
+ rendering chunks...
38
+ dist/cjs/types/mongo.cjs  0.01 kB
39
+ dist/cjs/types/userAgent.cjs  0.01 kB
40
+ dist/cjs/types/captcha.cjs  0.77 kB
41
+ dist/cjs/index.cjs  2.10 kB
42
+ dist/cjs/types/index.cjs  2.10 kB
43
+ dist/cjs/types/client.cjs  4.01 kB
44
+ dist/cjs/types/provider.cjs 13.99 kB
45
+ ✓ built in 131ms
@@ -0,0 +1,45 @@
1
+
2
+ > @prosopo/types-database@4.0.6 build
3
+ > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV
4
+
5
+ ViteEsmConfig: .
6
+ {
7
+ tsConfigPaths: [
8
+ '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
9
+ '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
10
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
11
+ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
12
+ '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
13
+ '/home/runner/work/captcha/captcha/packages/user-access-policy/tsconfig.json',
14
+ '/home/runner/work/captcha/captcha/packages/api-route/tsconfig.json',
15
+ '/home/runner/work/captcha/captcha/packages/redis-client/tsconfig.json',
16
+ '/home/runner/work/captcha/captcha/packages/api/tsconfig.json'
17
+ ]
18
+ }
19
+ {
20
+ externals: [
21
+ '@prosopo/common',
22
+ '@prosopo/locale',
23
+ '@prosopo/types',
24
+ '@prosopo/util',
25
+ '@prosopo/util-crypto',
26
+ '@prosopo/user-access-policy',
27
+ '@prosopo/api-route',
28
+ '@prosopo/redis-client',
29
+ '@prosopo/api'
30
+ ]
31
+ }
32
+ vite v6.4.1 building SSR bundle for production...
33
+ Bundle build started
34
+ transforming...
35
+ Build end
36
+ ✓ 7 modules transformed.
37
+ rendering chunks...
38
+ dist/types/mongo.js  0.00 kB
39
+ dist/types/userAgent.js  0.00 kB
40
+ dist/types/captcha.js  0.60 kB
41
+ dist/index.js  1.55 kB
42
+ dist/types/index.js  1.55 kB
43
+ dist/types/client.js  3.87 kB
44
+ dist/types/provider.js 13.05 kB
45
+ ✓ built in 238ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @prosopo/types-database
2
2
 
3
+ ## 4.0.6
4
+ ### Patch Changes
5
+
6
+ - 7d5eb3f: bump
7
+ - Updated dependencies [7d5eb3f]
8
+ - @prosopo/common@3.1.26
9
+ - @prosopo/locale@3.1.26
10
+ - @prosopo/types@3.6.4
11
+ - @prosopo/user-access-policy@3.5.32
12
+
13
+ ## 4.0.5
14
+ ### Patch Changes
15
+
16
+ - 93d92a7: little bump for publish all
17
+ - Updated dependencies [93d92a7]
18
+ - @prosopo/common@3.1.25
19
+ - @prosopo/locale@3.1.25
20
+ - @prosopo/types@3.6.3
21
+ - @prosopo/user-access-policy@3.5.31
22
+
23
+ ## 4.0.4
24
+ ### Patch Changes
25
+
26
+ - 8ee8434: bump node engines to 24 and npm version to 11
27
+ - cfee479: make @prosopo/config a dev dep
28
+ - Updated dependencies [8ee8434]
29
+ - Updated dependencies [cfee479]
30
+ - @prosopo/user-access-policy@3.5.30
31
+ - @prosopo/common@3.1.24
32
+ - @prosopo/locale@3.1.24
33
+ - @prosopo/types@3.6.2
34
+
35
+ ## 4.0.3
36
+ ### Patch Changes
37
+
38
+ - e926831: mega mini bump for all to trigger publish all
39
+ - Updated dependencies [e926831]
40
+ - @prosopo/config@3.1.23
41
+ - @prosopo/common@3.1.23
42
+ - @prosopo/locale@3.1.23
43
+ - @prosopo/types@3.6.1
44
+ - @prosopo/user-access-policy@3.5.29
45
+
46
+ ## 4.0.2
47
+ ### Patch Changes
48
+
49
+ - 0a9887c: Remove unique from token index
50
+
51
+ ## 4.0.1
52
+ ### Patch Changes
53
+
54
+ - 3e5d80a: add reason field
55
+
3
56
  ## 4.0.0
4
57
  ### Major Changes
5
58
 
@@ -5,7 +5,7 @@ const provider = require("./types/provider.cjs");
5
5
  const client = require("./types/client.cjs");
6
6
  const captcha = require("./types/captcha.cjs");
7
7
  exports.CaptchaRecordSchema = provider.CaptchaRecordSchema;
8
- exports.ClientEntropyRecordSchema = provider.ClientEntropyRecordSchema;
8
+ exports.ClientContextEntropyRecordSchema = provider.ClientContextEntropyRecordSchema;
9
9
  exports.ClientRecordSchema = provider.ClientRecordSchema;
10
10
  exports.CompositeIpAddressRecordSchemaObj = provider.CompositeIpAddressRecordSchemaObj;
11
11
  exports.CompositeIpAddressSchema = provider.CompositeIpAddressSchema;
@@ -73,7 +73,19 @@ const UserSettingsSchema = new mongoose.Schema({
73
73
  },
74
74
  contextAware: {
75
75
  enabled: { type: Boolean, default: false },
76
- threshold: { type: Number, default: types.contextAwareThresholdDefault }
76
+ contexts: {
77
+ type: mongoose.Schema.Types.Mixed,
78
+ default: {
79
+ [types.ContextType.Default]: {
80
+ type: types.ContextType.Default,
81
+ threshold: types.contextAwareThresholdDefault
82
+ },
83
+ [types.ContextType.Webview]: {
84
+ type: types.ContextType.Webview,
85
+ threshold: types.contextAwareThresholdDefault
86
+ }
87
+ }
88
+ }
77
89
  }
78
90
  });
79
91
  const UserDataSchema = new mongoose.Schema({
@@ -6,7 +6,7 @@ const client = require("./client.cjs");
6
6
  const captcha = require("./captcha.cjs");
7
7
  require("./userAgent.cjs");
8
8
  exports.CaptchaRecordSchema = provider.CaptchaRecordSchema;
9
- exports.ClientEntropyRecordSchema = provider.ClientEntropyRecordSchema;
9
+ exports.ClientContextEntropyRecordSchema = provider.ClientContextEntropyRecordSchema;
10
10
  exports.ClientRecordSchema = provider.ClientRecordSchema;
11
11
  exports.CompositeIpAddressRecordSchemaObj = provider.CompositeIpAddressRecordSchemaObj;
12
12
  exports.CompositeIpAddressSchema = provider.CompositeIpAddressSchema;
@@ -276,7 +276,7 @@ ScheduledTaskRecordSchema.index({ _id: 1, status: 1 });
276
276
  const SessionRecordSchema = new mongoose.Schema({
277
277
  sessionId: { type: String, required: true },
278
278
  createdAt: { type: Date, required: true },
279
- token: { type: String, required: true, unique: true },
279
+ token: { type: String, required: true },
280
280
  score: { type: Number, required: true },
281
281
  threshold: { type: Number, required: true },
282
282
  scoreComponents: {
@@ -298,7 +298,8 @@ const SessionRecordSchema = new mongoose.Schema({
298
298
  userSitekeyIpHash: { type: String, required: false },
299
299
  webView: { type: Boolean, required: true, default: false },
300
300
  iFrame: { type: Boolean, required: true, default: false },
301
- decryptedHeadHash: { type: String, required: false, default: "" }
301
+ decryptedHeadHash: { type: String, required: false, default: "" },
302
+ reason: { type: String, required: false }
302
303
  });
303
304
  SessionRecordSchema.index({ createdAt: 1 });
304
305
  SessionRecordSchema.index({ deleted: 1 });
@@ -313,15 +314,24 @@ const DetectorRecordSchema = new mongoose.Schema({
313
314
  });
314
315
  DetectorRecordSchema.index({ createdAt: 1 }, { unique: true });
315
316
  DetectorRecordSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
316
- const ClientEntropyRecordSchema = new mongoose.Schema({
317
- account: { type: String, required: true, unique: true },
318
- entropy: { type: String, required: true },
319
- createdAt: { type: Date, required: true },
320
- updatedAt: { type: Date, required: true }
321
- });
322
- ClientEntropyRecordSchema.index({ account: 1 }, { unique: true });
317
+ const ClientContextEntropyRecordSchema = new mongoose.Schema(
318
+ {
319
+ account: { type: String, required: true },
320
+ contextType: {
321
+ type: String,
322
+ enum: Object.values(types.ContextType),
323
+ required: true
324
+ },
325
+ entropy: { type: String, required: true }
326
+ },
327
+ { timestamps: { createdAt: true, updatedAt: true } }
328
+ );
329
+ ClientContextEntropyRecordSchema.index(
330
+ { account: 1, contextType: 1 },
331
+ { unique: true }
332
+ );
323
333
  exports.CaptchaRecordSchema = CaptchaRecordSchema;
324
- exports.ClientEntropyRecordSchema = ClientEntropyRecordSchema;
334
+ exports.ClientContextEntropyRecordSchema = ClientContextEntropyRecordSchema;
325
335
  exports.ClientRecordSchema = ClientRecordSchema;
326
336
  exports.CompositeIpAddressRecordSchemaObj = CompositeIpAddressRecordSchemaObj;
327
337
  exports.CompositeIpAddressSchema = CompositeIpAddressSchema;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./types/index.js";
2
- import { CaptchaRecordSchema, ClientEntropyRecordSchema, ClientRecordSchema, CompositeIpAddressRecordSchemaObj, CompositeIpAddressSchema, DatasetRecordSchema, DetectorRecordSchema, IpAddressType, PendingRecordSchema, PoWCaptchaRecordSchema, ScheduledTaskRecordSchema, ScheduledTaskSchema, SessionRecordSchema, SolutionRecordSchema, UserCommitmentRecordSchema, UserCommitmentSchema, UserCommitmentWithSolutionsSchema, UserSolutionRecordSchema, UserSolutionSchema, parseMongooseCompositeIpAddress } from "./types/provider.js";
2
+ import { CaptchaRecordSchema, ClientContextEntropyRecordSchema, ClientRecordSchema, CompositeIpAddressRecordSchemaObj, CompositeIpAddressSchema, DatasetRecordSchema, DetectorRecordSchema, IpAddressType, PendingRecordSchema, PoWCaptchaRecordSchema, ScheduledTaskRecordSchema, ScheduledTaskSchema, SessionRecordSchema, SolutionRecordSchema, UserCommitmentRecordSchema, UserCommitmentSchema, UserCommitmentWithSolutionsSchema, UserSolutionRecordSchema, UserSolutionSchema, parseMongooseCompositeIpAddress } from "./types/provider.js";
3
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
- ClientEntropyRecordSchema,
8
+ ClientContextEntropyRecordSchema,
9
9
  ClientRecordSchema,
10
10
  CompositeIpAddressRecordSchemaObj,
11
11
  CompositeIpAddressSchema,
@@ -1,5 +1,5 @@
1
- import { requireAllConditionsDefault, abuseScoreThresholdDefault, distanceThresholdKmDefault, abuseScoreThresholdExceedActionDefault, distanceExceedActionDefault, ispChangeActionDefault, cityChangeActionDefault, countryChangeActionDefault, contextAwareThresholdDefault } from "@prosopo/types";
2
- import { Schema } from "mongoose";
1
+ import { requireAllConditionsDefault, abuseScoreThresholdDefault, distanceThresholdKmDefault, abuseScoreThresholdExceedActionDefault, distanceExceedActionDefault, ispChangeActionDefault, cityChangeActionDefault, countryChangeActionDefault, ContextType, contextAwareThresholdDefault } from "@prosopo/types";
2
+ import mongoose, { Schema } from "mongoose";
3
3
  const IPValidationRulesSchema = new Schema({
4
4
  actions: {
5
5
  countryChangeAction: {
@@ -71,7 +71,19 @@ const UserSettingsSchema = new Schema({
71
71
  },
72
72
  contextAware: {
73
73
  enabled: { type: Boolean, default: false },
74
- threshold: { type: Number, default: contextAwareThresholdDefault }
74
+ contexts: {
75
+ type: mongoose.Schema.Types.Mixed,
76
+ default: {
77
+ [ContextType.Default]: {
78
+ type: ContextType.Default,
79
+ threshold: contextAwareThresholdDefault
80
+ },
81
+ [ContextType.Webview]: {
82
+ type: ContextType.Webview,
83
+ threshold: contextAwareThresholdDefault
84
+ }
85
+ }
86
+ }
75
87
  }
76
88
  });
77
89
  const UserDataSchema = new Schema({
@@ -1,12 +1,12 @@
1
1
  import "./mongo.js";
2
- import { CaptchaRecordSchema, ClientEntropyRecordSchema, ClientRecordSchema, CompositeIpAddressRecordSchemaObj, CompositeIpAddressSchema, DatasetRecordSchema, DetectorRecordSchema, IpAddressType, PendingRecordSchema, PoWCaptchaRecordSchema, ScheduledTaskRecordSchema, ScheduledTaskSchema, SessionRecordSchema, SolutionRecordSchema, UserCommitmentRecordSchema, UserCommitmentSchema, UserCommitmentWithSolutionsSchema, UserSolutionRecordSchema, UserSolutionSchema, parseMongooseCompositeIpAddress } from "./provider.js";
2
+ import { CaptchaRecordSchema, ClientContextEntropyRecordSchema, ClientRecordSchema, CompositeIpAddressRecordSchemaObj, CompositeIpAddressSchema, DatasetRecordSchema, DetectorRecordSchema, IpAddressType, PendingRecordSchema, PoWCaptchaRecordSchema, ScheduledTaskRecordSchema, ScheduledTaskSchema, SessionRecordSchema, SolutionRecordSchema, UserCommitmentRecordSchema, UserCommitmentSchema, UserCommitmentWithSolutionsSchema, UserSolutionRecordSchema, UserSolutionSchema, parseMongooseCompositeIpAddress } from "./provider.js";
3
3
  import { AccountSchema, IPValidationRulesSchema, TableNames, UserDataSchema, UserSettingsSchema } from "./client.js";
4
4
  import { StoredPoWCaptchaRecordSchema, StoredSessionRecordSchema, StoredUserCommitmentRecordSchema } from "./captcha.js";
5
5
  import "./userAgent.js";
6
6
  export {
7
7
  AccountSchema,
8
8
  CaptchaRecordSchema,
9
- ClientEntropyRecordSchema,
9
+ ClientContextEntropyRecordSchema,
10
10
  ClientRecordSchema,
11
11
  CompositeIpAddressRecordSchemaObj,
12
12
  CompositeIpAddressSchema,
@@ -1,5 +1,5 @@
1
1
  import { TranslationKeysSchema } from "@prosopo/locale";
2
- import { Tier, CaptchaStatus, CaptchaSolutionSchema, ScheduledTaskStatus, ScheduledTaskNames, CaptchaType } from "@prosopo/types";
2
+ import { Tier, CaptchaStatus, CaptchaSolutionSchema, ScheduledTaskStatus, ScheduledTaskNames, CaptchaType, ContextType } from "@prosopo/types";
3
3
  import { Schema } from "mongoose";
4
4
  import { object, nativeEnum, bigint, string, array, number, date, boolean, any } from "zod";
5
5
  import { UserSettingsSchema } from "./client.js";
@@ -274,7 +274,7 @@ ScheduledTaskRecordSchema.index({ _id: 1, status: 1 });
274
274
  const SessionRecordSchema = new Schema({
275
275
  sessionId: { type: String, required: true },
276
276
  createdAt: { type: Date, required: true },
277
- token: { type: String, required: true, unique: true },
277
+ token: { type: String, required: true },
278
278
  score: { type: Number, required: true },
279
279
  threshold: { type: Number, required: true },
280
280
  scoreComponents: {
@@ -296,7 +296,8 @@ const SessionRecordSchema = new Schema({
296
296
  userSitekeyIpHash: { type: String, required: false },
297
297
  webView: { type: Boolean, required: true, default: false },
298
298
  iFrame: { type: Boolean, required: true, default: false },
299
- decryptedHeadHash: { type: String, required: false, default: "" }
299
+ decryptedHeadHash: { type: String, required: false, default: "" },
300
+ reason: { type: String, required: false }
300
301
  });
301
302
  SessionRecordSchema.index({ createdAt: 1 });
302
303
  SessionRecordSchema.index({ deleted: 1 });
@@ -311,16 +312,25 @@ const DetectorRecordSchema = new Schema({
311
312
  });
312
313
  DetectorRecordSchema.index({ createdAt: 1 }, { unique: true });
313
314
  DetectorRecordSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
314
- const ClientEntropyRecordSchema = new Schema({
315
- account: { type: String, required: true, unique: true },
316
- entropy: { type: String, required: true },
317
- createdAt: { type: Date, required: true },
318
- updatedAt: { type: Date, required: true }
319
- });
320
- ClientEntropyRecordSchema.index({ account: 1 }, { unique: true });
315
+ const ClientContextEntropyRecordSchema = new Schema(
316
+ {
317
+ account: { type: String, required: true },
318
+ contextType: {
319
+ type: String,
320
+ enum: Object.values(ContextType),
321
+ required: true
322
+ },
323
+ entropy: { type: String, required: true }
324
+ },
325
+ { timestamps: { createdAt: true, updatedAt: true } }
326
+ );
327
+ ClientContextEntropyRecordSchema.index(
328
+ { account: 1, contextType: 1 },
329
+ { unique: true }
330
+ );
321
331
  export {
322
332
  CaptchaRecordSchema,
323
- ClientEntropyRecordSchema,
333
+ ClientContextEntropyRecordSchema,
324
334
  ClientRecordSchema,
325
335
  CompositeIpAddressRecordSchemaObj,
326
336
  CompositeIpAddressSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/types-database",
3
- "version": "4.0.0",
3
+ "version": "4.0.6",
4
4
  "description": "Types for prosopo database",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,8 +13,8 @@
13
13
  }
14
14
  },
15
15
  "engines": {
16
- "node": ">=v20.0.0",
17
- "npm": ">=10.6.0"
16
+ "node": "^24",
17
+ "npm": "^11"
18
18
  },
19
19
  "scripts": {
20
20
  "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
@@ -34,15 +34,15 @@
34
34
  },
35
35
  "homepage": "https://github.com/prosopo/captcha#readme",
36
36
  "dependencies": {
37
- "@prosopo/common": "3.1.22",
38
- "@prosopo/locale": "3.1.22",
39
- "@prosopo/types": "3.6.0",
40
- "@prosopo/user-access-policy": "3.5.28",
41
- "@prosopo/config": "3.1.22",
37
+ "@prosopo/common": "3.1.26",
38
+ "@prosopo/locale": "3.1.26",
39
+ "@prosopo/types": "3.6.4",
40
+ "@prosopo/user-access-policy": "3.5.32",
42
41
  "mongoose": "8.13.0",
43
42
  "zod": "3.23.8"
44
43
  },
45
44
  "devDependencies": {
45
+ "@prosopo/config": "3.1.26",
46
46
  "@types/node": "22.10.2",
47
47
  "@vitest/coverage-v8": "3.2.4",
48
48
  "concurrently": "9.0.1",