@prosopo/database 0.2.16 → 0.2.19

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,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const mongoose = require("mongoose");
4
+ const captchaEventSchema = new mongoose.Schema({
5
+ touchEvents: [
6
+ {
7
+ x: Number,
8
+ y: Number,
9
+ timestamp: Number
10
+ }
11
+ ],
12
+ mouseEvents: [
13
+ {
14
+ x: Number,
15
+ y: Number,
16
+ timestamp: Number
17
+ }
18
+ ],
19
+ keyboardEvents: [
20
+ {
21
+ key: String,
22
+ timestamp: Number,
23
+ isShiftKey: Boolean,
24
+ isCtrlKey: Boolean
25
+ }
26
+ ],
27
+ accountId: String
28
+ });
29
+ const CaptchaEvent = mongoose.model("CaptchaEvent", captchaEventSchema);
30
+ const addCaptchaEventRecord = async (record) => {
31
+ try {
32
+ const newRecord = new CaptchaEvent(record);
33
+ await newRecord.save();
34
+ console.log("Record added successfully");
35
+ } catch (error) {
36
+ console.error("Error adding record to the database:", error);
37
+ }
38
+ };
39
+ const saveCaptchaEvent = async (events, accountId, atlasUri) => {
40
+ await mongoose.connect(atlasUri).then(() => console.log("Connected to MongoDB Atlas")).catch((err) => console.error("Error connecting to MongoDB:", err));
41
+ const captchaEventData = {
42
+ ...events,
43
+ accountId
44
+ };
45
+ addCaptchaEventRecord(captchaEventData).then(() => console.log("Captcha event data saved")).catch((error) => console.error("Error saving captcha event data:", error));
46
+ };
47
+ exports.saveCaptchaEvent = saveCaptchaEvent;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const eventsDatabase = require("./eventsDatabase.cjs");
4
+ exports.saveCaptchaEvent = eventsDatabase.saveCaptchaEvent;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const index = require("./databases/index.cjs");
4
+ require("./eventsDatabase/index.cjs");
5
+ const eventsDatabase = require("./eventsDatabase/eventsDatabase.cjs");
4
6
  exports.Databases = index.Databases;
7
+ exports.saveCaptchaEvent = eventsDatabase.saveCaptchaEvent;
@@ -0,0 +1,3 @@
1
+ import { StoredEvents } from '@prosopo/types';
2
+ export declare const saveCaptchaEvent: (events: StoredEvents, accountId: string, atlasUri: string) => Promise<void>;
3
+ //# sourceMappingURL=eventsDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventsDatabase.d.ts","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA8C7C,eAAO,MAAM,gBAAgB,WAAkB,YAAY,aAAa,MAAM,YAAY,MAAM,kBAc/F,CAAA"}
@@ -0,0 +1,51 @@
1
+ import mongoose from 'mongoose';
2
+ const captchaEventSchema = new mongoose.Schema({
3
+ touchEvents: [
4
+ {
5
+ x: Number,
6
+ y: Number,
7
+ timestamp: Number,
8
+ },
9
+ ],
10
+ mouseEvents: [
11
+ {
12
+ x: Number,
13
+ y: Number,
14
+ timestamp: Number,
15
+ },
16
+ ],
17
+ keyboardEvents: [
18
+ {
19
+ key: String,
20
+ timestamp: Number,
21
+ isShiftKey: Boolean,
22
+ isCtrlKey: Boolean,
23
+ },
24
+ ],
25
+ accountId: String,
26
+ });
27
+ const CaptchaEvent = mongoose.model('CaptchaEvent', captchaEventSchema);
28
+ const addCaptchaEventRecord = async (record) => {
29
+ try {
30
+ const newRecord = new CaptchaEvent(record);
31
+ await newRecord.save();
32
+ console.log('Record added successfully');
33
+ }
34
+ catch (error) {
35
+ console.error('Error adding record to the database:', error);
36
+ }
37
+ };
38
+ export const saveCaptchaEvent = async (events, accountId, atlasUri) => {
39
+ await mongoose
40
+ .connect(atlasUri)
41
+ .then(() => console.log('Connected to MongoDB Atlas'))
42
+ .catch((err) => console.error('Error connecting to MongoDB:', err));
43
+ const captchaEventData = {
44
+ ...events,
45
+ accountId,
46
+ };
47
+ addCaptchaEventRecord(captchaEventData)
48
+ .then(() => console.log('Captcha event data saved'))
49
+ .catch((error) => console.error('Error saving captcha event data:', error));
50
+ };
51
+ //# sourceMappingURL=eventsDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventsDatabase.js","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,MAAM,kBAAkB,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;IAC3C,WAAW,EAAE;QACT;YACI,CAAC,EAAE,MAAM;YACT,CAAC,EAAE,MAAM;YACT,SAAS,EAAE,MAAM;SACpB;KACJ;IACD,WAAW,EAAE;QACT;YACI,CAAC,EAAE,MAAM;YACT,CAAC,EAAE,MAAM;YACT,SAAS,EAAE,MAAM;SACpB;KACJ;IACD,cAAc,EAAE;QACZ;YACI,GAAG,EAAE,MAAM;YACX,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,SAAS,EAAE,OAAO;SACrB;KACJ;IACD,SAAS,EAAE,MAAM;CACpB,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;AAEvE,MAAM,qBAAqB,GAAG,KAAK,EAAE,MAKpC,EAAiB,EAAE;IAChB,IAAI;QACA,MAAM,SAAS,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;QAC1C,MAAM,SAAS,CAAC,IAAI,EAAE,CAAA;QACtB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;KAC3C;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAA;KAC/D;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAoB,EAAE,SAAiB,EAAE,QAAgB,EAAE,EAAE;IAChG,MAAM,QAAQ;SACT,OAAO,CAAC,QAAQ,CAAC;SACjB,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;SACrD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC,CAAA;IAEvE,MAAM,gBAAgB,GAAG;QACrB,GAAG,MAAM;QACT,SAAS;KACZ,CAAA;IAED,qBAAqB,CAAC,gBAAgB,CAAC;SAClC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;SACnD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC,CAAA;AACnF,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './eventsDatabase.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eventsDatabase/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './eventsDatabase.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eventsDatabase/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './databases/index.js';
2
+ export * from './eventsDatabase/index.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './databases/index.js';
2
+ export * from './eventsDatabase/index.js';
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@prosopo/database",
3
- "version": "0.2.16",
3
+ "version": "0.2.19",
4
4
  "description": "Prosopo database plugins for provider",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "engines": {
8
- "node": ">=16",
9
- "npm": "8.9"
8
+ "node": ">=18",
9
+ "npm": ">=9"
10
10
  },
11
11
  "exports": {
12
12
  ".": {
@@ -18,8 +18,12 @@
18
18
  "clean": "tsc --build --clean",
19
19
  "build": "tsc --build --verbose tsconfig.json",
20
20
  "build:cjs": "npx vite --config vite.cjs.config.ts build",
21
- "lint": "npx eslint .",
22
- "lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
21
+ "eslint": "npx eslint . --no-error-on-unmatched-pattern --ignore-path ../../.eslintignore",
22
+ "eslint:fix": "npm run eslint -- --fix",
23
+ "prettier": "npx prettier . --check --no-error-on-unmatched-pattern --ignore-path ../../.eslintignore",
24
+ "prettier:fix": "npm run prettier -- --write",
25
+ "lint": "npm run eslint && npm run prettier",
26
+ "lint:fix": "npm run eslint:fix && npm run prettier:fix"
23
27
  },
24
28
  "repository": {
25
29
  "type": "git",
@@ -33,11 +37,11 @@
33
37
  "homepage": "https://github.com/prosopo/captcha#readme",
34
38
  "dependencies": {
35
39
  "@polkadot/util": "^12.5.1",
36
- "@prosopo/captcha-contract": "0.2.16",
37
- "@prosopo/common": "0.2.16",
38
- "@prosopo/config": "0.2.16",
39
- "@prosopo/types": "0.2.16",
40
- "@prosopo/types-database": "0.2.16",
40
+ "@prosopo/captcha-contract": "0.2.19",
41
+ "@prosopo/common": "0.2.19",
42
+ "@prosopo/config": "0.2.19",
43
+ "@prosopo/types": "0.2.19",
44
+ "@prosopo/types-database": "0.2.19",
41
45
  "mongodb": "5.8.0",
42
46
  "mongodb-memory-server": "^8.7.2",
43
47
  "mongoose": "^7.3.3"