@prosopo/database 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/base/index.d.ts +3 -0
  2. package/dist/base/index.d.ts.map +1 -0
  3. package/dist/base/index.js +3 -0
  4. package/dist/base/index.js.map +1 -0
  5. package/dist/base/mongo.d.ts +16 -0
  6. package/dist/base/mongo.d.ts.map +1 -0
  7. package/dist/base/mongo.js +89 -0
  8. package/dist/base/mongo.js.map +1 -0
  9. package/dist/{databases → base}/mongoMemory.d.ts +3 -2
  10. package/dist/base/mongoMemory.d.ts.map +1 -0
  11. package/dist/{databases → base}/mongoMemory.js +7 -10
  12. package/dist/base/mongoMemory.js.map +1 -0
  13. package/dist/cjs/base/index.cjs +6 -0
  14. package/dist/cjs/base/mongo.cjs +97 -0
  15. package/dist/cjs/{databases → base}/mongoMemory.cjs +7 -10
  16. package/dist/cjs/databases/captcha.cjs +82 -0
  17. package/dist/cjs/databases/client.cjs +46 -0
  18. package/dist/cjs/databases/index.cjs +12 -3
  19. package/dist/cjs/databases/{mongo.cjs → provider.cjs} +113 -109
  20. package/dist/cjs/index.cjs +11 -6
  21. package/dist/databases/captcha.d.ts +16 -0
  22. package/dist/databases/captcha.d.ts.map +1 -0
  23. package/dist/databases/captcha.js +75 -0
  24. package/dist/databases/captcha.js.map +1 -0
  25. package/dist/databases/client.d.ts +12 -0
  26. package/dist/databases/client.d.ts.map +1 -0
  27. package/dist/databases/client.js +42 -0
  28. package/dist/databases/client.js.map +1 -0
  29. package/dist/databases/index.d.ts +11 -2
  30. package/dist/databases/index.d.ts.map +1 -1
  31. package/dist/databases/index.js +11 -2
  32. package/dist/databases/index.js.map +1 -1
  33. package/dist/databases/{mongo.d.ts → provider.d.ts} +30 -22
  34. package/dist/databases/provider.d.ts.map +1 -0
  35. package/dist/databases/{mongo.js → provider.js} +124 -100
  36. package/dist/databases/provider.js.map +1 -0
  37. package/dist/index.d.ts +1 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -2
  40. package/dist/index.js.map +1 -1
  41. package/package.json +52 -44
  42. package/dist/captchaDatabase/captchaDatabase.d.ts +0 -3
  43. package/dist/captchaDatabase/captchaDatabase.d.ts.map +0 -1
  44. package/dist/captchaDatabase/captchaDatabase.js +0 -43
  45. package/dist/captchaDatabase/captchaDatabase.js.map +0 -1
  46. package/dist/captchaDatabase/index.d.ts +0 -2
  47. package/dist/captchaDatabase/index.d.ts.map +0 -1
  48. package/dist/captchaDatabase/index.js +0 -2
  49. package/dist/captchaDatabase/index.js.map +0 -1
  50. package/dist/cjs/captchaDatabase/captchaDatabase.cjs +0 -53
  51. package/dist/cjs/captchaDatabase/index.cjs +0 -4
  52. package/dist/cjs/eventsDatabase/eventsDatabase.cjs +0 -47
  53. package/dist/cjs/eventsDatabase/index.cjs +0 -4
  54. package/dist/databases/mongo.d.ts.map +0 -1
  55. package/dist/databases/mongo.js.map +0 -1
  56. package/dist/databases/mongoMemory.d.ts.map +0 -1
  57. package/dist/databases/mongoMemory.js.map +0 -1
  58. package/dist/eventsDatabase/eventsDatabase.d.ts +0 -3
  59. package/dist/eventsDatabase/eventsDatabase.d.ts.map +0 -1
  60. package/dist/eventsDatabase/eventsDatabase.js +0 -48
  61. package/dist/eventsDatabase/eventsDatabase.js.map +0 -1
  62. package/dist/eventsDatabase/index.d.ts +0 -2
  63. package/dist/eventsDatabase/index.d.ts.map +0 -1
  64. package/dist/eventsDatabase/index.js +0 -2
  65. package/dist/eventsDatabase/index.js.map +0 -1
@@ -4,28 +4,84 @@ const is = require("@polkadot/util/is");
4
4
  const common = require("@prosopo/common");
5
5
  const types = require("@prosopo/types");
6
6
  const typesDatabase = require("@prosopo/types-database");
7
- const mongodb = require("mongodb");
8
- const mongoose = require("mongoose");
9
- mongoose.set("strictQuery", false);
10
- const DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
11
- class ProsopoDatabase extends common.AsyncFactory {
12
- constructor() {
13
- super();
14
- this.url = "";
15
- this.dbname = "";
16
- this.logger = common.getLoggerDefault();
17
- }
18
- async init(url, dbname, logger, authSource) {
19
- const baseEndpoint = url || DEFAULT_ENDPOINT;
20
- const parsedUrl = new URL(baseEndpoint);
21
- parsedUrl.pathname = dbname;
22
- if (authSource) {
23
- parsedUrl.searchParams.set("authSource", authSource);
24
- }
25
- this.url = parsedUrl.toString();
26
- this.dbname = dbname;
27
- this.logger = logger;
28
- return this;
7
+ const mongo = require("../base/mongo.cjs");
8
+ var TableNames = /* @__PURE__ */ ((TableNames2) => {
9
+ TableNames2["captcha"] = "captcha";
10
+ TableNames2["dataset"] = "dataset";
11
+ TableNames2["solution"] = "solution";
12
+ TableNames2["commitment"] = "commitment";
13
+ TableNames2["usersolution"] = "usersolution";
14
+ TableNames2["pending"] = "pending";
15
+ TableNames2["scheduler"] = "scheduler";
16
+ TableNames2["powcaptcha"] = "powcaptcha";
17
+ TableNames2["client"] = "client";
18
+ return TableNames2;
19
+ })(TableNames || {});
20
+ const PROVIDER_TABLES = [
21
+ {
22
+ collectionName: "captcha",
23
+ modelName: "Captcha",
24
+ schema: typesDatabase.CaptchaRecordSchema
25
+ },
26
+ {
27
+ collectionName: "powcaptcha",
28
+ modelName: "PowCaptcha",
29
+ schema: typesDatabase.PoWCaptchaRecordSchema
30
+ },
31
+ {
32
+ collectionName: "dataset",
33
+ modelName: "Dataset",
34
+ schema: typesDatabase.DatasetRecordSchema
35
+ },
36
+ {
37
+ collectionName: "solution",
38
+ modelName: "Solution",
39
+ schema: typesDatabase.SolutionRecordSchema
40
+ },
41
+ {
42
+ collectionName: "commitment",
43
+ modelName: "UserCommitment",
44
+ schema: typesDatabase.UserCommitmentRecordSchema
45
+ },
46
+ {
47
+ collectionName: "usersolution",
48
+ modelName: "UserSolution",
49
+ schema: typesDatabase.UserSolutionRecordSchema
50
+ },
51
+ {
52
+ collectionName: "pending",
53
+ modelName: "Pending",
54
+ schema: typesDatabase.PendingRecordSchema
55
+ },
56
+ {
57
+ collectionName: "scheduler",
58
+ modelName: "Scheduler",
59
+ schema: typesDatabase.ScheduledTaskRecordSchema
60
+ },
61
+ {
62
+ collectionName: "client",
63
+ modelName: "Client",
64
+ schema: typesDatabase.ClientRecordSchema
65
+ }
66
+ ];
67
+ class ProviderDatabase extends mongo.MongoDatabase {
68
+ constructor(url, dbname, authSource, logger) {
69
+ super(url, dbname, authSource, logger);
70
+ this.tables = {};
71
+ this.tables = {};
72
+ }
73
+ async connect() {
74
+ await super.connect();
75
+ this.loadTables();
76
+ }
77
+ loadTables() {
78
+ const tables = {};
79
+ PROVIDER_TABLES.map(({ collectionName, modelName, schema }) => {
80
+ if (this.connection) {
81
+ tables[collectionName] = this.connection.model(modelName, schema);
82
+ }
83
+ });
84
+ this.tables = tables;
29
85
  }
30
86
  getTables() {
31
87
  if (!this.tables) {
@@ -36,79 +92,6 @@ class ProsopoDatabase extends common.AsyncFactory {
36
92
  }
37
93
  return this.tables;
38
94
  }
39
- getConnection() {
40
- if (!this.connection) {
41
- throw new common.ProsopoDBError("DATABASE.CONNECTION_UNDEFINED", {
42
- context: { failedFuncName: this.getConnection.name },
43
- logger: this.logger
44
- });
45
- }
46
- return this.connection;
47
- }
48
- /**
49
- * @description Connect to the database and set the various tables
50
- */
51
- async connect() {
52
- this.logger.info(
53
- `Mongo url: ${this.url.replace(/\w+:\w+/, "<Credentials>")}`
54
- );
55
- this.connection = await new Promise((resolve, reject) => {
56
- const connection = mongoose.createConnection(this.url, {
57
- dbName: this.dbname,
58
- serverApi: mongodb.ServerApiVersion.v1
59
- });
60
- connection.on("open", () => {
61
- this.logger.info(`Database connection to ${this.url} opened`);
62
- resolve(connection);
63
- });
64
- connection.on("error", (err) => {
65
- this.logger.error(`Database error: ${err}`);
66
- reject(err);
67
- });
68
- connection.on("connected", () => {
69
- this.logger.info(`Database connected to ${this.url}`);
70
- resolve(connection);
71
- });
72
- connection.on("disconnected", () => {
73
- this.logger.info(`Database disconnected from ${this.url}`);
74
- });
75
- connection.on("reconnected", () => {
76
- this.logger.info(`Database reconnected to ${this.url}`);
77
- resolve(connection);
78
- });
79
- connection.on("reconnectFailed", () => {
80
- this.logger.error(`Database reconnect failed to ${this.url}`);
81
- });
82
- connection.on("close", () => {
83
- this.logger.info(`Database connection to ${this.url} closed`);
84
- });
85
- connection.on("fullsetup", () => {
86
- this.logger.info(`Database connection to ${this.url} is fully setup`);
87
- resolve(connection);
88
- });
89
- });
90
- this.tables = {
91
- captcha: this.connection.model("Captcha", typesDatabase.CaptchaRecordSchema),
92
- powCaptcha: this.connection.model("PowCaptcha", typesDatabase.PowCaptchaRecordSchema),
93
- dataset: this.connection.model("Dataset", typesDatabase.DatasetRecordSchema),
94
- solution: this.connection.model("Solution", typesDatabase.SolutionRecordSchema),
95
- commitment: this.connection.model(
96
- "UserCommitment",
97
- typesDatabase.UserCommitmentRecordSchema
98
- ),
99
- usersolution: this.connection.model(
100
- "UserSolution",
101
- typesDatabase.UserSolutionRecordSchema
102
- ),
103
- pending: this.connection.model("Pending", typesDatabase.PendingRecordSchema),
104
- scheduler: this.connection.model("Scheduler", typesDatabase.ScheduledTaskRecordSchema)
105
- };
106
- }
107
- /** Close connection to the database */
108
- async close() {
109
- this.logger.debug(`Closing connection to ${this.url}`);
110
- await this.connection?.close();
111
- }
112
95
  /**
113
96
  * @description Load a dataset to the database
114
97
  * @param {Dataset} dataset
@@ -124,7 +107,7 @@ class ProsopoDatabase extends common.AsyncFactory {
124
107
  contentTree: parsedDataset.contentTree,
125
108
  solutionTree: parsedDataset.solutionTree
126
109
  };
127
- await this.tables?.dataset.updateOne(
110
+ await this.tables.dataset?.updateOne(
128
111
  { datasetId: parsedDataset.datasetId },
129
112
  { $set: datasetDoc },
130
113
  { upsert: true }
@@ -374,12 +357,13 @@ class ProsopoDatabase extends common.AsyncFactory {
374
357
  * @param userSignature
375
358
  * @returns {Promise<void>} A promise that resolves when the record is added.
376
359
  */
377
- async storePowCaptchaRecord(challenge, components, difficulty, providerSignature, ipAddress, serverChecked = false, userSubmitted = false, storedStatus = typesDatabase.StoredStatusNames.notStored, userSignature) {
360
+ async storePowCaptchaRecord(challenge, components, difficulty, providerSignature, ipAddress, headers, serverChecked = false, userSubmitted = false, storedStatus = typesDatabase.StoredStatusNames.notStored, userSignature) {
378
361
  const tables = this.getTables();
379
362
  const powCaptchaRecord = {
380
363
  challenge,
381
364
  ...components,
382
365
  ipAddress,
366
+ headers,
383
367
  result: { status: types.CaptchaStatus.pending },
384
368
  userSubmitted,
385
369
  serverChecked,
@@ -389,7 +373,7 @@ class ProsopoDatabase extends common.AsyncFactory {
389
373
  lastUpdatedTimestamp: Date.now()
390
374
  };
391
375
  try {
392
- await tables.powCaptcha.create(powCaptchaRecord);
376
+ await tables.powcaptcha.create(powCaptchaRecord);
393
377
  this.logger.info("PowCaptcha record added successfully", {
394
378
  challenge,
395
379
  userSubmitted,
@@ -419,7 +403,7 @@ class ProsopoDatabase extends common.AsyncFactory {
419
403
  /**
420
404
  * @description Retrieves a PoW Captcha record by its challenge string.
421
405
  * @param {string} challenge The challenge string to search for.
422
- * @returns {Promise<PoWCaptchaStored | null>} A promise that resolves with the found record or null if not found.
406
+ * @returns {Promise<PoWCaptchaRecord | null>} A promise that resolves with the found record or null if not found.
423
407
  */
424
408
  async getPowCaptchaRecordByChallenge(challenge) {
425
409
  if (!this.tables) {
@@ -429,7 +413,7 @@ class ProsopoDatabase extends common.AsyncFactory {
429
413
  });
430
414
  }
431
415
  try {
432
- const record = await this.tables.powCaptcha.findOne({ challenge }).lean();
416
+ const record = await this.tables.powcaptcha.findOne({ challenge }).lean();
433
417
  if (record) {
434
418
  this.logger.info("PowCaptcha record retrieved successfully", {
435
419
  challenge
@@ -455,7 +439,6 @@ class ProsopoDatabase extends common.AsyncFactory {
455
439
  * @param result
456
440
  * @param serverChecked
457
441
  * @param userSubmitted
458
- * @param storedStatus
459
442
  * @param userSignature
460
443
  * @returns {Promise<void>} A promise that resolves when the record is updated.
461
444
  */
@@ -470,7 +453,7 @@ class ProsopoDatabase extends common.AsyncFactory {
470
453
  lastUpdatedTimestamp: timestamp
471
454
  };
472
455
  try {
473
- const updateResult = await tables.powCaptcha.updateOne(
456
+ const updateResult = await tables.powcaptcha.updateOne(
474
457
  { challenge },
475
458
  {
476
459
  $set: update
@@ -567,7 +550,7 @@ class ProsopoDatabase extends common.AsyncFactory {
567
550
  /** @description Get Dapp User PoW captcha commitments that have not been counted towards the client's total
568
551
  */
569
552
  async getUnstoredDappUserPoWCommitments() {
570
- const docs = await this.tables?.powCaptcha.find({
553
+ const docs = await this.tables?.powcaptcha.find({
571
554
  $or: [
572
555
  { storedStatus: { $ne: typesDatabase.StoredStatusNames.stored } },
573
556
  { storedStatus: { $exists: false } }
@@ -581,7 +564,7 @@ class ProsopoDatabase extends common.AsyncFactory {
581
564
  const updateDoc = {
582
565
  storedAtTimestamp: Date.now()
583
566
  };
584
- await this.tables?.powCaptcha.updateMany(
567
+ await this.tables?.powcaptcha.updateMany(
585
568
  { challenge: { $in: challenges } },
586
569
  { $set: updateDoc },
587
570
  { upsert: false }
@@ -594,7 +577,7 @@ class ProsopoDatabase extends common.AsyncFactory {
594
577
  [typesDatabase.StoredStatusNames.serverChecked]: true,
595
578
  lastUpdatedTimestamp: Date.now()
596
579
  };
597
- await this.tables?.powCaptcha.updateMany(
580
+ await this.tables?.powcaptcha.updateMany(
598
581
  { challenge: { $in: challenges } },
599
582
  {
600
583
  $set: updateDoc
@@ -605,7 +588,7 @@ class ProsopoDatabase extends common.AsyncFactory {
605
588
  /** @description Remove processed Dapp User captcha solutions from the user solution table
606
589
  */
607
590
  async removeProcessedDappUserSolutions(commitmentIds) {
608
- return await this.tables?.usersolution.deleteMany({
591
+ return this.tables?.usersolution.deleteMany({
609
592
  processed: true,
610
593
  commitmentId: { $in: commitmentIds }
611
594
  });
@@ -613,7 +596,7 @@ class ProsopoDatabase extends common.AsyncFactory {
613
596
  /** @description Remove processed Dapp User captcha commitments from the user commitments table
614
597
  */
615
598
  async removeProcessedDappUserCommitments(commitmentIds) {
616
- return await this.tables?.commitment.deleteMany({
599
+ return this.tables?.commitment.deleteMany({
617
600
  processed: true,
618
601
  id: { $in: commitmentIds }
619
602
  });
@@ -901,7 +884,7 @@ class ProsopoDatabase extends common.AsyncFactory {
901
884
  if (status) {
902
885
  lookup.status = status;
903
886
  }
904
- const cursor = await this.tables?.scheduler?.findOne(lookup).sort({ datetime: -1 }).lean();
887
+ const cursor = await this.tables?.scheduler?.findOne(lookup).sort({ datetime: -1 }).limit(1).lean();
905
888
  return cursor ? cursor : void 0;
906
889
  }
907
890
  /**
@@ -934,5 +917,26 @@ class ProsopoDatabase extends common.AsyncFactory {
934
917
  }
935
918
  );
936
919
  }
920
+ /**
921
+ * @description Update the client records
922
+ */
923
+ async updateClientRecords(clientRecords) {
924
+ const ops = clientRecords.map((record) => {
925
+ const clientRecord = {
926
+ account: record.account,
927
+ settings: record.settings
928
+ };
929
+ return {
930
+ updateOne: {
931
+ filter: { account: record.account },
932
+ update: {
933
+ $set: clientRecord
934
+ },
935
+ upsert: true
936
+ }
937
+ };
938
+ });
939
+ await this.tables?.client.bulkWrite(ops);
940
+ }
937
941
  }
938
- exports.ProsopoDatabase = ProsopoDatabase;
942
+ exports.ProviderDatabase = ProviderDatabase;
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./base/index.cjs");
3
4
  const index = require("./databases/index.cjs");
4
- require("./eventsDatabase/index.cjs");
5
- require("./captchaDatabase/index.cjs");
6
- const eventsDatabase = require("./eventsDatabase/eventsDatabase.cjs");
7
- const captchaDatabase = require("./captchaDatabase/captchaDatabase.cjs");
5
+ const mongo = require("./base/mongo.cjs");
6
+ const mongoMemory = require("./base/mongoMemory.cjs");
7
+ const provider = require("./databases/provider.cjs");
8
+ const captcha = require("./databases/captcha.cjs");
9
+ const client = require("./databases/client.cjs");
8
10
  exports.Databases = index.Databases;
9
- exports.saveCaptchaEvent = eventsDatabase.saveCaptchaEvent;
10
- exports.saveCaptchas = captchaDatabase.saveCaptchas;
11
+ exports.MongoDatabase = mongo.MongoDatabase;
12
+ exports.MongoMemoryDatabase = mongoMemory.MongoMemoryDatabase;
13
+ exports.ProviderDatabase = provider.ProviderDatabase;
14
+ exports.CaptchaDatabase = captcha.CaptchaDatabase;
15
+ exports.ClientDatabase = client.ClientDatabase;
@@ -0,0 +1,16 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import { type ICaptchaDatabase, type PoWCaptchaRecord, type Tables, type UserCommitmentRecord } from "@prosopo/types-database";
3
+ import { MongoDatabase } from "../base/index.js";
4
+ declare enum TableNames {
5
+ commitment = "commitment",
6
+ powcaptcha = "powcaptcha"
7
+ }
8
+ export declare class CaptchaDatabase extends MongoDatabase implements ICaptchaDatabase {
9
+ tables: Tables<TableNames>;
10
+ constructor(url: string, dbname?: string, authSource?: string, logger?: Logger);
11
+ connect(): Promise<void>;
12
+ getTables(): Tables<TableNames>;
13
+ saveCaptchas(imageCaptchaEvents: UserCommitmentRecord[], powCaptchaEvents: PoWCaptchaRecord[]): Promise<void>;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=captcha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/databases/captcha.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,MAAM,EAAoC,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAErB,KAAK,MAAM,EACX,KAAK,oBAAoB,EAEzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,aAAK,UAAU;IACd,UAAU,eAAe;IACzB,UAAU,eAAe;CACzB;AAeD,qBAAa,eAAgB,SAAQ,aAAc,YAAW,gBAAgB;IAC7E,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;gBAG1B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM;IAMD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASvC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC;IAUzB,YAAY,CACjB,kBAAkB,EAAE,oBAAoB,EAAE,EAC1C,gBAAgB,EAAE,gBAAgB,EAAE;CAsCrC"}
@@ -0,0 +1,75 @@
1
+ import { ProsopoDBError, getLoggerDefault } from "@prosopo/common";
2
+ import { PoWCaptchaRecordSchema, UserCommitmentRecordSchema, } from "@prosopo/types-database";
3
+ import { MongoDatabase } from "../base/index.js";
4
+ const logger = getLoggerDefault();
5
+ var TableNames;
6
+ (function (TableNames) {
7
+ TableNames["commitment"] = "commitment";
8
+ TableNames["powcaptcha"] = "powcaptcha";
9
+ })(TableNames || (TableNames = {}));
10
+ const CAPTCHA_TABLES = [
11
+ {
12
+ collectionName: TableNames.powcaptcha,
13
+ modelName: "PowCaptcha",
14
+ schema: PoWCaptchaRecordSchema,
15
+ },
16
+ {
17
+ collectionName: TableNames.commitment,
18
+ modelName: "UserCommitment",
19
+ schema: UserCommitmentRecordSchema,
20
+ },
21
+ ];
22
+ export class CaptchaDatabase extends MongoDatabase {
23
+ constructor(url, dbname, authSource, logger) {
24
+ super(url, dbname, authSource, logger);
25
+ this.tables = {};
26
+ }
27
+ async connect() {
28
+ await super.connect();
29
+ CAPTCHA_TABLES.map(({ collectionName, modelName, schema }) => {
30
+ if (this.connection) {
31
+ this.tables[collectionName] = this.connection.model(modelName, schema);
32
+ }
33
+ });
34
+ }
35
+ getTables() {
36
+ if (!this.tables) {
37
+ throw new ProsopoDBError("DATABASE.TABLES_UNDEFINED", {
38
+ context: { failedFuncName: this.getTables.name },
39
+ logger: this.logger,
40
+ });
41
+ }
42
+ return this.tables;
43
+ }
44
+ async saveCaptchas(imageCaptchaEvents, powCaptchaEvents) {
45
+ await this.connect();
46
+ if (imageCaptchaEvents.length) {
47
+ const result = await this.tables.commitment.bulkWrite(imageCaptchaEvents.map((doc) => {
48
+ const { _id, ...safeDoc } = doc;
49
+ return {
50
+ updateOne: {
51
+ filter: { id: safeDoc.id },
52
+ update: { $set: safeDoc },
53
+ upsert: true,
54
+ },
55
+ };
56
+ }));
57
+ logger.info("Mongo Saved Image Events", result);
58
+ }
59
+ if (powCaptchaEvents.length) {
60
+ const result = await this.tables.powcaptcha.bulkWrite(powCaptchaEvents.map((doc) => {
61
+ const { _id, ...safeDoc } = doc;
62
+ return {
63
+ updateOne: {
64
+ filter: { challenge: safeDoc.challenge },
65
+ update: { $set: safeDoc },
66
+ upsert: true,
67
+ },
68
+ };
69
+ }));
70
+ logger.info("Mongo Saved PoW Events", result);
71
+ }
72
+ await this.close();
73
+ }
74
+ }
75
+ //# sourceMappingURL=captcha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/databases/captcha.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ import { type Logger } from "@prosopo/common";
2
+ import type { Timestamp } from "@prosopo/types";
3
+ import { type ClientRecord, type IClientDatabase, TableNames, type Tables } from "@prosopo/types-database";
4
+ import { MongoDatabase } from "../base/index.js";
5
+ export declare class ClientDatabase extends MongoDatabase implements IClientDatabase {
6
+ tables: Tables<TableNames>;
7
+ constructor(url: string, dbname?: string, authSource?: string, logger?: Logger);
8
+ connect(): Promise<void>;
9
+ getTables(): Tables<TableNames>;
10
+ getUpdatedClients(updatedAtTimestamp: Timestamp): Promise<ClientRecord[]>;
11
+ }
12
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/databases/client.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,MAAM,EAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUjD,qBAAa,cAAe,SAAQ,aAAc,YAAW,eAAe;IAC3E,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;gBAG1B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM;IAMD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASvC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC;IAUzB,iBAAiB,CACtB,kBAAkB,EAAE,SAAS,GAC3B,OAAO,CAAC,YAAY,EAAE,CAAC;CAY1B"}
@@ -0,0 +1,42 @@
1
+ import { ProsopoDBError } from "@prosopo/common";
2
+ import { TableNames, UserDataSchema, } from "@prosopo/types-database";
3
+ import { MongoDatabase } from "../base/index.js";
4
+ const CLIENT_TABLES = [
5
+ {
6
+ collectionName: TableNames.emails,
7
+ modelName: "Email",
8
+ schema: UserDataSchema,
9
+ },
10
+ ];
11
+ export class ClientDatabase extends MongoDatabase {
12
+ constructor(url, dbname, authSource, logger) {
13
+ super(url, dbname, authSource, logger);
14
+ this.tables = {};
15
+ }
16
+ async connect() {
17
+ await super.connect();
18
+ CLIENT_TABLES.map(({ collectionName, modelName, schema }) => {
19
+ if (this.connection) {
20
+ this.tables[collectionName] = this.connection.model(modelName, schema);
21
+ }
22
+ });
23
+ }
24
+ getTables() {
25
+ if (!this.tables) {
26
+ throw new ProsopoDBError("DATABASE.TABLES_UNDEFINED", {
27
+ context: { failedFuncName: this.getTables.name },
28
+ logger: this.logger,
29
+ });
30
+ }
31
+ return this.tables;
32
+ }
33
+ async getUpdatedClients(updatedAtTimestamp) {
34
+ await this.connect();
35
+ const newClientRecords = await this.tables.emails
36
+ .find({ updatedAtTimestamp: { $gt: updatedAtTimestamp }, activated: true }, { account: 1, settings: 1 })
37
+ .lean();
38
+ await this.close();
39
+ return newClientRecords;
40
+ }
41
+ }
42
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/databases/client.ts"],"names":[],"mappings":"AAcA,OAAO,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAGN,UAAU,EAEV,cAAc,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,aAAa,GAAG;IACrB;QACC,cAAc,EAAE,UAAU,CAAC,MAAM;QACjC,SAAS,EAAE,OAAO;QAClB,MAAM,EAAE,cAAc;KACtB;CACD,CAAC;AAEF,MAAM,OAAO,cAAe,SAAQ,aAAa;IAGhD,YACC,GAAW,EACX,MAAe,EACf,UAAmB,EACnB,MAAe;QAEf,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,EAAwB,CAAC;IACxC,CAAC;IAEQ,KAAK,CAAC,OAAO;QACrB,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;YAC3D,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxE,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,SAAS;QACR,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,cAAc,CAAC,2BAA2B,EAAE;gBACrD,OAAO,EAAE,EAAE,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAChD,MAAM,EAAE,IAAI,CAAC,MAAM;aACnB,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,iBAAiB,CACtB,kBAA6B;QAE7B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAErB,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM;aAC/C,IAAI,CACJ,EAAE,kBAAkB,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EACpE,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAC3B;aACA,IAAI,EAAkB,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,gBAAgB,CAAC;IACzB,CAAC;CACD"}
@@ -1,7 +1,16 @@
1
- import { ProsopoDatabase as MongoDatabase } from "./mongo.js";
2
- import { MongoMemoryDatabase } from "./mongoMemory.js";
1
+ import { MongoDatabase } from "../base/mongo.js";
2
+ import { MongoMemoryDatabase } from "../base/mongoMemory.js";
3
+ import { CaptchaDatabase } from "./captcha.js";
4
+ import { ClientDatabase } from "./client.js";
5
+ import { ProviderDatabase } from "./provider.js";
6
+ export * from "./captcha.js";
7
+ export * from "./client.js";
8
+ export { ProviderDatabase } from "./provider.js";
3
9
  export declare const Databases: {
4
10
  mongo: typeof MongoDatabase;
11
+ provider: typeof ProviderDatabase;
12
+ client: typeof ClientDatabase;
13
+ captcha: typeof CaptchaDatabase;
5
14
  mongoMemory: typeof MongoMemoryDatabase;
6
15
  };
7
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,eAAO,MAAM,SAAS;;;CAGrB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC"}
@@ -1,8 +1,17 @@
1
1
  import { DatabaseTypes } from "@prosopo/types";
2
- import { ProsopoDatabase as MongoDatabase } from "./mongo.js";
3
- import { MongoMemoryDatabase } from "./mongoMemory.js";
2
+ import { MongoDatabase } from "../base/mongo.js";
3
+ import { MongoMemoryDatabase } from "../base/mongoMemory.js";
4
+ import { CaptchaDatabase } from "./captcha.js";
5
+ import { ClientDatabase } from "./client.js";
6
+ import { ProviderDatabase } from "./provider.js";
7
+ export * from "./captcha.js";
8
+ export * from "./client.js";
9
+ export { ProviderDatabase } from "./provider.js";
4
10
  export const Databases = {
5
11
  [DatabaseTypes.Values.mongo]: MongoDatabase,
12
+ [DatabaseTypes.Values.provider]: ProviderDatabase,
13
+ [DatabaseTypes.Values.client]: ClientDatabase,
14
+ [DatabaseTypes.Values.captcha]: CaptchaDatabase,
6
15
  [DatabaseTypes.Values.mongoMemory]: MongoMemoryDatabase,
7
16
  };
8
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa;IAC3C,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,mBAAmB;CACvD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa;IAC3C,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,gBAAgB;IACjD,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,cAAc;IAC7C,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,eAAe;IAC/C,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,mBAAmB;CACvD,CAAC"}
@@ -1,21 +1,27 @@
1
- import { AsyncFactory, type Logger, TranslationKey } from "@prosopo/common";
2
- import { type Captcha, CaptchaResult, type CaptchaSolution, CaptchaStates, type DatasetBase, type DatasetWithIds, type DatasetWithIdsAndTree, type Hash, type PendingCaptchaRequest, PoWChallengeComponents, PoWChallengeId, ScheduledTaskNames, type ScheduledTaskResult, ScheduledTaskStatus } from "@prosopo/types";
3
- import { type Database, type PoWCaptchaStored, type ScheduledTaskRecord, type SolutionRecord, StoredStatus, type Tables, type UserCommitmentRecord, type UserSolutionRecord } from "@prosopo/types-database";
4
- import { type DeleteResult } from "mongodb";
5
- import mongoose, { type Connection, ObjectId } from "mongoose";
6
- export declare class ProsopoDatabase extends AsyncFactory implements Database {
7
- url: string;
8
- tables?: Tables;
9
- dbname: string;
10
- connection?: Connection;
11
- logger: Logger;
12
- constructor();
13
- init(url: string, dbname: string, logger: Logger, authSource?: string): Promise<this>;
14
- getTables(): Tables;
15
- getConnection(): mongoose.Connection;
1
+ import { type Logger, type TranslationKey } from "@prosopo/common";
2
+ import { type Captcha, type CaptchaResult, type CaptchaSolution, CaptchaStates, type Dataset, type DatasetBase, type DatasetWithIds, type DatasetWithIdsAndTree, type Hash, type PendingCaptchaRequest, type PoWChallengeComponents, type PoWChallengeId, type RequestHeaders, type ScheduledTaskNames, type ScheduledTaskResult, type ScheduledTaskStatus } from "@prosopo/types";
3
+ import { type ClientRecord, type IDatabase, type PoWCaptchaRecord, type ScheduledTaskRecord, type SolutionRecord, type StoredStatus, type Tables, type UserCommitment, type UserCommitmentRecord, type UserSolutionRecord } from "@prosopo/types-database";
4
+ import type { DeleteResult } from "mongodb";
5
+ import type { ObjectId } from "mongoose";
6
+ import { MongoDatabase } from "../base/mongo.js";
7
+ declare enum TableNames {
8
+ captcha = "captcha",
9
+ dataset = "dataset",
10
+ solution = "solution",
11
+ commitment = "commitment",
12
+ usersolution = "usersolution",
13
+ pending = "pending",
14
+ scheduler = "scheduler",
15
+ powcaptcha = "powcaptcha",
16
+ client = "client"
17
+ }
18
+ export declare class ProviderDatabase extends MongoDatabase implements IDatabase {
19
+ tables: Tables<TableNames>;
20
+ constructor(url: string, dbname?: string, authSource?: string, logger?: Logger);
16
21
  connect(): Promise<void>;
17
- close(): Promise<void>;
18
- storeDataset(dataset: DatasetWithIdsAndTree): Promise<void>;
22
+ loadTables(): void;
23
+ getTables(): Tables<TableNames>;
24
+ storeDataset(dataset: Dataset | DatasetWithIdsAndTree): Promise<void>;
19
25
  getSolutions(datasetId: string): Promise<SolutionRecord[]>;
20
26
  getDataset(datasetId: string): Promise<DatasetWithIds>;
21
27
  getRandomCaptcha(solved: boolean, datasetId: Hash, size?: number): Promise<Captcha[] | undefined>;
@@ -23,9 +29,9 @@ export declare class ProsopoDatabase extends AsyncFactory implements Database {
23
29
  updateCaptcha(captcha: Captcha, datasetId: Hash): Promise<void>;
24
30
  removeCaptchas(captchaIds: string[]): Promise<void>;
25
31
  getDatasetDetails(datasetId: Hash): Promise<DatasetBase>;
26
- storeDappUserSolution(captchas: CaptchaSolution[], commit: UserCommitmentRecord): Promise<void>;
27
- storePowCaptchaRecord(challenge: PoWChallengeId, components: PoWChallengeComponents, difficulty: number, providerSignature: string, ipAddress: string, serverChecked?: boolean, userSubmitted?: boolean, storedStatus?: StoredStatus, userSignature?: string): Promise<void>;
28
- getPowCaptchaRecordByChallenge(challenge: string): Promise<PoWCaptchaStored | null>;
32
+ storeDappUserSolution(captchas: CaptchaSolution[], commit: UserCommitment): Promise<void>;
33
+ storePowCaptchaRecord(challenge: PoWChallengeId, components: PoWChallengeComponents, difficulty: number, providerSignature: string, ipAddress: string, headers: RequestHeaders, serverChecked?: boolean, userSubmitted?: boolean, storedStatus?: StoredStatus, userSignature?: string): Promise<void>;
34
+ getPowCaptchaRecordByChallenge(challenge: string): Promise<PoWCaptchaRecord | null>;
29
35
  updatePowCaptchaRecord(challenge: PoWChallengeId, result: CaptchaResult, serverChecked?: boolean, userSubmitted?: boolean, userSignature?: string): Promise<void>;
30
36
  getProcessedDappUserSolutions(): Promise<UserSolutionRecord[]>;
31
37
  getProcessedDappUserCommitments(): Promise<UserCommitmentRecord[]>;
@@ -33,7 +39,7 @@ export declare class ProsopoDatabase extends AsyncFactory implements Database {
33
39
  getUnstoredDappUserCommitments(): Promise<UserCommitmentRecord[]>;
34
40
  markDappUserCommitmentsStored(commitmentIds: Hash[]): Promise<void>;
35
41
  markDappUserCommitmentsChecked(commitmentIds: Hash[]): Promise<void>;
36
- getUnstoredDappUserPoWCommitments(): Promise<PoWCaptchaStored[]>;
42
+ getUnstoredDappUserPoWCommitments(): Promise<PoWCaptchaRecord[]>;
37
43
  markDappUserPoWCommitmentsStored(challenges: string[]): Promise<void>;
38
44
  markDappUserPoWCommitmentsChecked(challenges: string[]): Promise<void>;
39
45
  removeProcessedDappUserSolutions(commitmentIds: string[]): Promise<DeleteResult | undefined>;
@@ -56,5 +62,7 @@ export declare class ProsopoDatabase extends AsyncFactory implements Database {
56
62
  getLastScheduledTaskStatus(task: ScheduledTaskNames, status?: ScheduledTaskStatus): Promise<ScheduledTaskRecord | undefined>;
57
63
  createScheduledTaskStatus(taskName: ScheduledTaskNames, status: ScheduledTaskStatus): Promise<ObjectId>;
58
64
  updateScheduledTaskStatus(taskId: ObjectId, status: ScheduledTaskStatus, result?: ScheduledTaskResult): Promise<void>;
65
+ updateClientRecords(clientRecords: ClientRecord[]): Promise<void>;
59
66
  }
60
- //# sourceMappingURL=mongo.d.ts.map
67
+ export {};
68
+ //# sourceMappingURL=provider.d.ts.map