@prosopo/provider 2.3.1 → 2.3.2
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/dist/api/admin/apiAdminRoutesProvider.d.ts +9 -0
- package/dist/api/admin/apiAdminRoutesProvider.d.ts.map +1 -0
- package/dist/api/admin/apiAdminRoutesProvider.js +17 -0
- package/dist/api/admin/apiAdminRoutesProvider.js.map +1 -0
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.d.ts +13 -0
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.d.ts.map +1 -0
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.js +20 -0
- package/dist/api/admin/apiRegisterSiteKeyEndpoint.js.map +1 -0
- package/dist/api/admin/createApiAdminRoutesProvider.d.ts +5 -0
- package/dist/api/admin/createApiAdminRoutesProvider.d.ts.map +1 -0
- package/dist/api/admin/createApiAdminRoutesProvider.js +8 -0
- package/dist/api/admin/createApiAdminRoutesProvider.js.map +1 -0
- package/dist/api/admin/export.d.ts +3 -0
- package/dist/api/admin/export.d.ts.map +1 -0
- package/dist/api/admin/export.js +3 -0
- package/dist/api/admin/export.js.map +1 -0
- package/dist/api/blacklistRequestInspector.d.ts +19 -0
- package/dist/api/blacklistRequestInspector.d.ts.map +1 -0
- package/dist/api/blacklistRequestInspector.js +61 -0
- package/dist/api/blacklistRequestInspector.js.map +1 -0
- package/dist/api/block.d.ts +1 -2
- package/dist/api/block.d.ts.map +1 -1
- package/dist/api/block.js +13 -38
- package/dist/api/block.js.map +1 -1
- package/dist/api/captcha.d.ts.map +1 -1
- package/dist/api/captcha.js +6 -7
- package/dist/api/captcha.js.map +1 -1
- package/dist/api/export.d.ts +2 -0
- package/dist/api/export.d.ts.map +1 -0
- package/dist/api/export.js +2 -0
- package/dist/api/export.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tasks/client/clientTasks.d.ts +1 -5
- package/dist/tasks/client/clientTasks.d.ts.map +1 -1
- package/dist/tasks/client/clientTasks.js +1 -51
- package/dist/tasks/client/clientTasks.js.map +1 -1
- package/dist/tasks/frictionless/frictionlessTasks.d.ts +1 -3
- package/dist/tasks/frictionless/frictionlessTasks.d.ts.map +1 -1
- package/dist/tasks/frictionless/frictionlessTasks.js +0 -10
- package/dist/tasks/frictionless/frictionlessTasks.js.map +1 -1
- package/dist/tasks/imgCaptcha/imgCaptchaTasksUtils.d.ts +1 -3
- package/dist/tasks/imgCaptcha/imgCaptchaTasksUtils.d.ts.map +1 -1
- package/dist/tasks/imgCaptcha/imgCaptchaTasksUtils.js +0 -29
- package/dist/tasks/imgCaptcha/imgCaptchaTasksUtils.js.map +1 -1
- package/dist/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.js +1 -60
- package/dist/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.js.map +1 -1
- package/dist/tests/unit/tasks/imgCaptcha/imgCaptchaTasksUtils.unit.test.js +1 -101
- package/dist/tests/unit/tasks/imgCaptcha/imgCaptchaTasksUtils.unit.test.js.map +1 -1
- package/package.json +13 -11
- package/dist/api/admin.d.ts +0 -4
- package/dist/api/admin.d.ts.map +0 -1
- package/dist/api/admin.js +0 -87
- package/dist/api/admin.js.map +0 -1
- package/dist/rules/ip.d.ts +0 -4
- package/dist/rules/ip.d.ts.map +0 -1
- package/dist/rules/ip.js +0 -19
- package/dist/rules/ip.js.map +0 -1
- package/dist/rules/user.d.ts +0 -4
- package/dist/rules/user.d.ts.map +0 -1
- package/dist/rules/user.js +0 -10
- package/dist/rules/user.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frictionlessTasks.d.ts","sourceRoot":"","sources":["../../../src/tasks/frictionless/frictionlessTasks.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"frictionlessTasks.d.ts","sourceRoot":"","sources":["../../../src/tasks/frictionless/frictionlessTasks.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAEN,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAW,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,qBAAa,mBAAmB;IAC/B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,iBAAiB,CAAC;gBAGrB,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,iBAAiB;IAOtB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAI9C,gBAAgB,IAAI,8BAA8B;IAO5C,cAAc,CACnB,OAAO,EAAE,QAAQ,GACf,OAAO,CAAC,8BAA8B,CAAC;CAe1C"}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { ApiParams, } from "@prosopo/types";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
|
-
import { checkIpRules } from "../../rules/ip.js";
|
|
4
3
|
import { checkLangRules } from "../../rules/lang.js";
|
|
5
|
-
import { checkUserRules } from "../../rules/user.js";
|
|
6
4
|
export class FrictionlessManager {
|
|
7
5
|
constructor(config, pair, db) {
|
|
8
6
|
this.config = config;
|
|
9
7
|
this.pair = pair;
|
|
10
8
|
this.db = db;
|
|
11
9
|
}
|
|
12
|
-
async checkIpRules(ipAddress, dapp) {
|
|
13
|
-
const rule = await checkIpRules(this.db, ipAddress, dapp);
|
|
14
|
-
return !!rule;
|
|
15
|
-
}
|
|
16
|
-
async checkUserRules(user, dapp) {
|
|
17
|
-
const rule = await checkUserRules(this.db, user, dapp);
|
|
18
|
-
return !!rule;
|
|
19
|
-
}
|
|
20
10
|
checkLangRules(acceptLanguage) {
|
|
21
11
|
return checkLangRules(this.config, acceptLanguage);
|
|
22
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frictionlessTasks.js","sourceRoot":"","sources":["../../../src/tasks/frictionless/frictionlessTasks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"frictionlessTasks.js","sourceRoot":"","sources":["../../../src/tasks/frictionless/frictionlessTasks.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,SAAS,GAGT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,mBAAmB;IAK/B,YACC,MAA2B,EAC3B,IAAiB,EACjB,EAAqB;QAErB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,CAAC;IAED,cAAc,CAAC,cAAsB;QACpC,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,gBAAgB;QACf,OAAO;YACN,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO;YAChC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI;SACxB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CACnB,OAAiB;QAEjB,MAAM,aAAa,GAAY;YAC9B,SAAS,EAAE,MAAM,EAAE;YACnB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,OAAO;SAChB,CAAC;QAEF,MAAM,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAEhD,OAAO;YACN,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK;YAC9B,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS;YAC9C,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI;SACxB,CAAC;IACH,CAAC;CACD"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CaptchaMerkleTree } from "@prosopo/datasets";
|
|
2
|
-
import type { CaptchaSolution
|
|
3
|
-
import type { IProviderDatabase } from "@prosopo/types-database";
|
|
2
|
+
import type { CaptchaSolution } from "@prosopo/types";
|
|
4
3
|
export declare const buildTreeAndGetCommitmentId: (captchaSolutions: CaptchaSolution[]) => {
|
|
5
4
|
tree: CaptchaMerkleTree;
|
|
6
5
|
commitmentId: string;
|
|
7
6
|
};
|
|
8
|
-
export declare const getCaptchaConfig: (db: IProviderDatabase, config: ProsopoConfigOutput, ipAddress: IPAddress, user: string, dapp: string) => Promise<ProsopoCaptchaCountConfigSchemaOutput>;
|
|
9
7
|
//# sourceMappingURL=imgCaptchaTasksUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imgCaptchaTasksUtils.d.ts","sourceRoot":"","sources":["../../../src/tasks/imgCaptcha/imgCaptchaTasksUtils.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,iBAAiB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"imgCaptchaTasksUtils.d.ts","sourceRoot":"","sources":["../../../src/tasks/imgCaptcha/imgCaptchaTasksUtils.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,iBAAiB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOtD,eAAO,MAAM,2BAA2B,qBACrB,eAAe,EAAE,KACjC;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAqBjD,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ProsopoEnvError } from "@prosopo/common";
|
|
2
2
|
import { CaptchaMerkleTree, computeCaptchaSolutionHash, } from "@prosopo/datasets";
|
|
3
|
-
import { checkIpRules } from "../../rules/ip.js";
|
|
4
|
-
import { checkUserRules } from "../../rules/user.js";
|
|
5
3
|
export const buildTreeAndGetCommitmentId = (captchaSolutions) => {
|
|
6
4
|
const tree = new CaptchaMerkleTree();
|
|
7
5
|
const solutionsHashed = captchaSolutions.map((captcha) => computeCaptchaSolutionHash(captcha));
|
|
@@ -17,31 +15,4 @@ export const buildTreeAndGetCommitmentId = (captchaSolutions) => {
|
|
|
17
15
|
}
|
|
18
16
|
return { tree, commitmentId };
|
|
19
17
|
};
|
|
20
|
-
export const getCaptchaConfig = async (db, config, ipAddress, user, dapp) => {
|
|
21
|
-
const ipRule = await checkIpRules(db, ipAddress, dapp);
|
|
22
|
-
if (ipRule) {
|
|
23
|
-
return {
|
|
24
|
-
solved: {
|
|
25
|
-
count: ipRule?.captchaConfig?.solved.count || config.captchas.solved.count,
|
|
26
|
-
},
|
|
27
|
-
unsolved: {
|
|
28
|
-
count: ipRule?.captchaConfig?.unsolved.count ||
|
|
29
|
-
config.captchas.unsolved.count,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const userRule = await checkUserRules(db, user, dapp);
|
|
34
|
-
if (userRule) {
|
|
35
|
-
return {
|
|
36
|
-
solved: {
|
|
37
|
-
count: userRule?.captchaConfig?.solved.count || config.captchas.solved.count,
|
|
38
|
-
},
|
|
39
|
-
unsolved: {
|
|
40
|
-
count: userRule?.captchaConfig?.unsolved.count ||
|
|
41
|
-
config.captchas.unsolved.count,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return config.captchas;
|
|
46
|
-
};
|
|
47
18
|
//# sourceMappingURL=imgCaptchaTasksUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imgCaptchaTasksUtils.js","sourceRoot":"","sources":["../../../src/tasks/imgCaptcha/imgCaptchaTasksUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,mBAAmB,CAAC;AAQ3B,
|
|
1
|
+
{"version":3,"file":"imgCaptchaTasksUtils.js","sourceRoot":"","sources":["../../../src/tasks/imgCaptcha/imgCaptchaTasksUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAC1C,gBAAmC,EACiB,EAAE;IACtD,MAAM,IAAI,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxD,0BAA0B,CAAC,OAAO,CAAC,CACnC,CAAC;IACF,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE5B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IACrC,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,MAAM,IAAI,eAAe,CACxB,qDAAqD,EACrD;YACC,OAAO,EAAE;gBACR,cAAc,EAAE,2BAA2B,CAAC,IAAI;gBAChD,YAAY,EAAE,YAAY;aAC1B;SACD,CACD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Address4 } from "ip-address";
|
|
2
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
2
|
import { FrictionlessManager } from "../../../../tasks/frictionless/frictionlessTasks.js";
|
|
4
3
|
describe("Frictionless Task Manager", () => {
|
|
@@ -7,41 +6,7 @@ describe("Frictionless Task Manager", () => {
|
|
|
7
6
|
let captchaConfig;
|
|
8
7
|
let frictionlessTaskManager;
|
|
9
8
|
beforeEach(() => {
|
|
10
|
-
db = {
|
|
11
|
-
getIPBlockRuleRecord: vi.fn((ip) => {
|
|
12
|
-
const ipBlockRules = [
|
|
13
|
-
{
|
|
14
|
-
_id: 1,
|
|
15
|
-
ip: 16843009.0,
|
|
16
|
-
dappAccount: "testDapp",
|
|
17
|
-
global: false,
|
|
18
|
-
hardBlock: false,
|
|
19
|
-
type: "ipAddress",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
_id: 2,
|
|
23
|
-
ip: 33686018.0,
|
|
24
|
-
global: true,
|
|
25
|
-
hardBlock: false,
|
|
26
|
-
type: "ipAddress",
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
return ipBlockRules.find((rule) => BigInt(rule.ip) === ip);
|
|
30
|
-
}),
|
|
31
|
-
getUserBlockRuleRecord: vi.fn((user, dapp) => {
|
|
32
|
-
const userBlockRules = [
|
|
33
|
-
{
|
|
34
|
-
_id: 1,
|
|
35
|
-
userAccount: "testUser1",
|
|
36
|
-
dappAccount: "testDapp",
|
|
37
|
-
global: false,
|
|
38
|
-
hardBlock: false,
|
|
39
|
-
type: "user",
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
return userBlockRules.find((rule) => rule.userAccount === user && rule.dappAccount === dapp);
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
9
|
+
db = {};
|
|
45
10
|
pair = {
|
|
46
11
|
sign: vi.fn(),
|
|
47
12
|
address: "testAddress",
|
|
@@ -54,30 +19,6 @@ describe("Frictionless Task Manager", () => {
|
|
|
54
19
|
frictionlessTaskManager = new FrictionlessManager(captchaConfig, pair, db);
|
|
55
20
|
vi.clearAllMocks();
|
|
56
21
|
});
|
|
57
|
-
describe("checkIpRules", () => {
|
|
58
|
-
it("should return true if an ip has a rule against it and a dapp", async () => {
|
|
59
|
-
const result = await frictionlessTaskManager.checkIpRules(new Address4("1.1.1.1"), "testDapp");
|
|
60
|
-
expect(result).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
it("should return true if an ip has a rule against it but no dapp", async () => {
|
|
63
|
-
const result = await frictionlessTaskManager.checkIpRules(new Address4("2.2.2.2"), "testDapp");
|
|
64
|
-
expect(result).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
it("should return false for an ip with no rule", async () => {
|
|
67
|
-
const result = await frictionlessTaskManager.checkIpRules(new Address4("3.3.3.3"), "testDapp");
|
|
68
|
-
expect(result).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("checkUserRules", () => {
|
|
72
|
-
it("should return true if a user has a rule against it and a dapp", async () => {
|
|
73
|
-
const result = await frictionlessTaskManager.checkUserRules("testUser1", "testDapp");
|
|
74
|
-
expect(result).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
it("should return true if a user has no rule against it", async () => {
|
|
77
|
-
const result = await frictionlessTaskManager.checkUserRules("testUser2", "testDapp");
|
|
78
|
-
expect(result).toBe(false);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
22
|
describe("checkLangRules", () => {
|
|
82
23
|
it("should return an inflated score if a lang rule is set", async () => {
|
|
83
24
|
const result = frictionlessTaskManager.checkLangRules("en");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frictionlessTasks.unit.test.js","sourceRoot":"","sources":["../../../../../src/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"frictionlessTasks.unit.test.js","sourceRoot":"","sources":["../../../../../src/tests/unit/tasks/frictionless/frictionlessTasks.unit.test.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,M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sopoEnvError } from "@prosopo/common";
|
|
2
2
|
import { CaptchaMerkleTree, computeCaptchaSolutionHash, } from "@prosopo/datasets";
|
|
3
|
-
import { BlockRuleType } from "@prosopo/types";
|
|
4
|
-
import { Address4 } from "ip-address";
|
|
5
3
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
import { checkUserRules } from "../../../../rules/user.js";
|
|
8
|
-
import { buildTreeAndGetCommitmentId, getCaptchaConfig, } from "../../../../tasks/imgCaptcha/imgCaptchaTasksUtils.js";
|
|
4
|
+
import { buildTreeAndGetCommitmentId } from "../../../../tasks/imgCaptcha/imgCaptchaTasksUtils.js";
|
|
9
5
|
vi.mock("@prosopo/datasets", () => ({
|
|
10
6
|
CaptchaMerkleTree: vi.fn().mockImplementation(() => ({
|
|
11
7
|
build: vi.fn(),
|
|
@@ -13,16 +9,6 @@ vi.mock("@prosopo/datasets", () => ({
|
|
|
13
9
|
})),
|
|
14
10
|
computeCaptchaSolutionHash: vi.fn(),
|
|
15
11
|
}));
|
|
16
|
-
vi.mock("../../../../rules/ip.js", () => {
|
|
17
|
-
return {
|
|
18
|
-
checkIpRules: vi.fn(),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
vi.mock("../../../../rules/user.js", () => {
|
|
22
|
-
return {
|
|
23
|
-
checkUserRules: vi.fn(),
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
12
|
describe("buildTreeAndGetCommitmentId", () => {
|
|
27
13
|
const mockCaptchaSolutions = [
|
|
28
14
|
{ challenge: "challenge1", solution: "solution1", salt: "salt1" },
|
|
@@ -57,90 +43,4 @@ describe("buildTreeAndGetCommitmentId", () => {
|
|
|
57
43
|
}));
|
|
58
44
|
});
|
|
59
45
|
});
|
|
60
|
-
describe("getCaptchaConfig", () => {
|
|
61
|
-
it("should return the default captcha config if no rules are found", async () => {
|
|
62
|
-
const db = {
|
|
63
|
-
getIPBlockRuleRecord: vi.fn().mockResolvedValue(null),
|
|
64
|
-
getUserBlockRuleRecord: vi.fn().mockResolvedValue(null),
|
|
65
|
-
};
|
|
66
|
-
const config = {
|
|
67
|
-
captchas: {
|
|
68
|
-
solved: { count: 1 },
|
|
69
|
-
unsolved: { count: 2 },
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
const ipAddress = new Address4("1.1.1.1");
|
|
73
|
-
const user = "mockedUser";
|
|
74
|
-
const dapp = "mockedDapp";
|
|
75
|
-
const result = await getCaptchaConfig(db, config, ipAddress, user, dapp);
|
|
76
|
-
expect(result).toEqual({
|
|
77
|
-
solved: { count: 1 },
|
|
78
|
-
unsolved: { count: 2 },
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
it("should return the users config if there is one specified against the user's ip address", async () => {
|
|
82
|
-
const ipRule = {
|
|
83
|
-
ip: 16843009,
|
|
84
|
-
global: false,
|
|
85
|
-
hardBlock: false,
|
|
86
|
-
type: BlockRuleType.ipAddress,
|
|
87
|
-
captchaConfig: {
|
|
88
|
-
solved: { count: 3 },
|
|
89
|
-
unsolved: { count: 4 },
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
checkIpRules.mockReturnValue(ipRule);
|
|
93
|
-
const db = {
|
|
94
|
-
getIPBlockRuleRecord: vi.fn().mockResolvedValue(ipRule),
|
|
95
|
-
getUserBlockRuleRecord: vi.fn().mockResolvedValue(null),
|
|
96
|
-
};
|
|
97
|
-
const config = {
|
|
98
|
-
captchas: {
|
|
99
|
-
solved: { count: 1 },
|
|
100
|
-
unsolved: { count: 2 },
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
const ipAddress = new Address4("1.1.1.1");
|
|
104
|
-
const user = "mockedUser";
|
|
105
|
-
const dapp = "mockedDapp";
|
|
106
|
-
const result = await getCaptchaConfig(db, config, ipAddress, user, dapp);
|
|
107
|
-
expect(result).toEqual({
|
|
108
|
-
solved: { count: 3 },
|
|
109
|
-
unsolved: { count: 4 },
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
it("should return the user's config if there is one specified against the user's account", async () => {
|
|
113
|
-
const userRule = {
|
|
114
|
-
userAccount: "mockedUser",
|
|
115
|
-
dappAccount: "mockedDapp",
|
|
116
|
-
global: false,
|
|
117
|
-
hardBlock: false,
|
|
118
|
-
type: BlockRuleType.userAccount,
|
|
119
|
-
captchaConfig: {
|
|
120
|
-
solved: { count: 5 },
|
|
121
|
-
unsolved: { count: 6 },
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
checkIpRules.mockReturnValue(null);
|
|
125
|
-
const db = {
|
|
126
|
-
getIPBlockRuleRecord: vi.fn().mockResolvedValue(null),
|
|
127
|
-
getUserBlockRuleRecord: vi.fn().mockResolvedValue(userRule),
|
|
128
|
-
};
|
|
129
|
-
checkUserRules.mockReturnValue(userRule);
|
|
130
|
-
const config = {
|
|
131
|
-
captchas: {
|
|
132
|
-
solved: { count: 1 },
|
|
133
|
-
unsolved: { count: 2 },
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
const ipAddress = new Address4("1.1.1.1");
|
|
137
|
-
const user = "mockedUser";
|
|
138
|
-
const dapp = "mockedDapp";
|
|
139
|
-
const result = await getCaptchaConfig(db, config, ipAddress, user, dapp);
|
|
140
|
-
expect(result).toEqual({
|
|
141
|
-
solved: { count: 5 },
|
|
142
|
-
unsolved: { count: 6 },
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
46
|
//# sourceMappingURL=imgCaptchaTasksUtils.unit.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imgCaptchaTasksUtils.unit.test.js","sourceRoot":"","sources":["../../../../../src/tests/unit/tasks/imgCaptcha/imgCaptchaTasksUtils.unit.test.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file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BAA2B,CAAC,oBAAoB,CAAC,CAAC;QAEjE,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC7C,MAAM,CAAC,0BAA0B,CAAC,CAAC,oBAAoB,CACtD,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAAC;QACF,MAAM,CAAC,0BAA0B,CAAC,CAAC,oBAAoB,CACtD,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YACxB,YAAY,EAAE,gBAAgB;SAC9B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAE9D,iBAAyB,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;YACpD,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;YACd,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;SACpB,CAAC,CAAC,CAAC;QAEJ,MAAM,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CACtE,IAAI,eAAe,CAClB,qDAAqD,EACrD;YACC,OAAO,EAAE;gBACR,cAAc,EAAE,6BAA6B;gBAC7C,YAAY,EAAE,IAAI;aAClB;SACD,CACD,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/provider",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,16 +27,18 @@
|
|
|
27
27
|
"@polkadot/keyring": "12.6.2",
|
|
28
28
|
"@polkadot/util": "12.6.2",
|
|
29
29
|
"@polkadot/util-crypto": "12.6.2",
|
|
30
|
-
"@prosopo/
|
|
31
|
-
"@prosopo/
|
|
32
|
-
"@prosopo/
|
|
33
|
-
"@prosopo/
|
|
34
|
-
"@prosopo/
|
|
35
|
-
"@prosopo/
|
|
36
|
-
"@prosopo/
|
|
37
|
-
"@prosopo/types
|
|
38
|
-
"@prosopo/types-
|
|
39
|
-
"@prosopo/
|
|
30
|
+
"@prosopo/api-route": "2.3.2",
|
|
31
|
+
"@prosopo/common": "2.3.2",
|
|
32
|
+
"@prosopo/config": "2.3.2",
|
|
33
|
+
"@prosopo/keyring": "2.3.2",
|
|
34
|
+
"@prosopo/database": "2.3.2",
|
|
35
|
+
"@prosopo/datasets": "2.3.2",
|
|
36
|
+
"@prosopo/env": "2.3.2",
|
|
37
|
+
"@prosopo/types": "2.3.2",
|
|
38
|
+
"@prosopo/types-database": "2.3.2",
|
|
39
|
+
"@prosopo/types-env": "2.3.2",
|
|
40
|
+
"@prosopo/util": "2.3.2",
|
|
41
|
+
"@prosopo/user-access-policy": "2.3.2",
|
|
40
42
|
"cron": "3.1.7",
|
|
41
43
|
"express": "4.21.1",
|
|
42
44
|
"ip-address": "10.0.1",
|
package/dist/api/admin.d.ts
DELETED
package/dist/api/admin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAkFnE"}
|
package/dist/api/admin.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { logError } from "@prosopo/common";
|
|
2
|
-
import { AddBlockRulesIPSpec, AddBlockRulesUserSpec, AdminApiPaths, RegisterSitekeyBody, RemoveBlockRulesIPSpec, RemoveBlockRulesUserSpec, } from "@prosopo/types";
|
|
3
|
-
import { Router } from "express";
|
|
4
|
-
import { Tasks } from "../index.js";
|
|
5
|
-
export function prosopoAdminRouter(env) {
|
|
6
|
-
const router = Router();
|
|
7
|
-
const tasks = new Tasks(env);
|
|
8
|
-
router.post(AdminApiPaths.SiteKeyRegister, async (req, res, next) => {
|
|
9
|
-
try {
|
|
10
|
-
tasks.logger.info("Registering site key, request body:");
|
|
11
|
-
tasks.logger.info(req.body);
|
|
12
|
-
const { siteKey, settings } = RegisterSitekeyBody.parse(req.body);
|
|
13
|
-
const temp = settings || {};
|
|
14
|
-
await tasks.clientTaskManager.registerSiteKey(siteKey, temp);
|
|
15
|
-
const response = {
|
|
16
|
-
status: "success",
|
|
17
|
-
};
|
|
18
|
-
res.json(response);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
logError(err, tasks.logger);
|
|
22
|
-
res.status(500).send("An internal server error occurred.");
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
router.post(AdminApiPaths.BlockRuleIPAdd, async (req, res, next) => {
|
|
26
|
-
try {
|
|
27
|
-
tasks.logger.info("Adding block rules");
|
|
28
|
-
const parsed = AddBlockRulesIPSpec.parse(req.body);
|
|
29
|
-
await tasks.clientTaskManager.addIPBlockRules(parsed);
|
|
30
|
-
const response = {
|
|
31
|
-
status: "success",
|
|
32
|
-
};
|
|
33
|
-
res.json(response);
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
logError(err, tasks.logger);
|
|
37
|
-
res.status(400).send("An internal server error occurred.");
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
router.post(AdminApiPaths.BlockRuleIPRemove, async (req, res, next) => {
|
|
41
|
-
try {
|
|
42
|
-
tasks.logger.info("Removing block rules");
|
|
43
|
-
const parsed = RemoveBlockRulesIPSpec.parse(req.body);
|
|
44
|
-
await tasks.clientTaskManager.removeIPBlockRules(parsed);
|
|
45
|
-
const response = {
|
|
46
|
-
status: "success",
|
|
47
|
-
};
|
|
48
|
-
res.json(response);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
logError(err, tasks.logger);
|
|
52
|
-
res.status(400).send("An internal server error occurred.");
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
router.post(AdminApiPaths.BlocKRuleUserAdd, async (req, res, next) => {
|
|
56
|
-
try {
|
|
57
|
-
tasks.logger.info("Adding block rules");
|
|
58
|
-
const parsed = AddBlockRulesUserSpec.parse(req.body);
|
|
59
|
-
await tasks.clientTaskManager.addUserBlockRules(parsed);
|
|
60
|
-
const response = {
|
|
61
|
-
status: "success",
|
|
62
|
-
};
|
|
63
|
-
res.json(response);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
logError(err, tasks.logger);
|
|
67
|
-
res.status(400).send("An internal server error occurred.");
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
router.post(AdminApiPaths.BlockRuleUserRemove, async (req, res, next) => {
|
|
71
|
-
try {
|
|
72
|
-
tasks.logger.info("Removing block rules");
|
|
73
|
-
const parsed = RemoveBlockRulesUserSpec.parse(req.body);
|
|
74
|
-
await tasks.clientTaskManager.removeUserBlockRules(parsed);
|
|
75
|
-
const response = {
|
|
76
|
-
status: "success",
|
|
77
|
-
};
|
|
78
|
-
res.json(response);
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
logError(err, tasks.logger);
|
|
82
|
-
res.status(400).send("An internal server error occurred.");
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return router;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=admin.js.map
|
package/dist/api/admin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,QAAQ,EAAE,MA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AC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC5B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/rules/ip.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BlockRule, IPAddress } from "@prosopo/types";
|
|
2
|
-
import type { IProviderDatabase } from "@prosopo/types-database";
|
|
3
|
-
export declare const checkIpRules: (db: IProviderDatabase, ipAddress: IPAddress, dapp: string) => Promise<BlockRule | undefined>;
|
|
4
|
-
//# sourceMappingURL=ip.d.ts.map
|
package/dist/rules/ip.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ip.d.ts","sourceRoot":"","sources":["../../src/rules/ip.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,eAAO,MAAM,YAAY,OACpB,iBAAiB,aACV,SAAS,QACd,MAAM,KACV,OAAO,CAAC,SAAS,GAAG,SAAS,CAwB/B,CAAC"}
|
package/dist/rules/ip.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const checkIpRules = async (db, ipAddress, dapp) => {
|
|
2
|
-
const rule = await db.getIPBlockRuleRecord(ipAddress.bigInt());
|
|
3
|
-
if (rule && BigInt(rule.ip) === ipAddress.bigInt()) {
|
|
4
|
-
if (rule.global) {
|
|
5
|
-
return rule;
|
|
6
|
-
}
|
|
7
|
-
if (rule.dappAccount === dapp) {
|
|
8
|
-
return rule;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const dappRule = await db.getIPBlockRuleRecord(ipAddress.bigInt(), dapp);
|
|
12
|
-
if (dappRule &&
|
|
13
|
-
dappRule.dappAccount === dapp &&
|
|
14
|
-
BigInt(dappRule.ip) === ipAddress.bigInt()) {
|
|
15
|
-
return rule;
|
|
16
|
-
}
|
|
17
|
-
return undefined;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=ip.js.map
|
package/dist/rules/ip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ip.js","sourceRoot":"","sources":["../../src/rules/ip.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAChC,EAAqB,EACrB,SAAoB,EACpB,IAAY,EACqB,EAAE;IACnC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAE/D,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;QAEpD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IACzE,IACC,QAAQ;QACR,QAAQ,CAAC,WAAW,KAAK,IAAI;QAC7B,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE,EACzC,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
|
package/dist/rules/user.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BlockRule } from "@prosopo/types";
|
|
2
|
-
import type { IProviderDatabase } from "@prosopo/types-database";
|
|
3
|
-
export declare const checkUserRules: (db: IProviderDatabase, user: string, dapp: string) => Promise<BlockRule | undefined>;
|
|
4
|
-
//# sourceMappingURL=user.d.ts.map
|
package/dist/rules/user.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/rules/user.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,eAAO,MAAM,cAAc,OACtB,iBAAiB,QACf,MAAM,QACN,MAAM,KACV,OAAO,CAAC,SAAS,GAAG,SAAS,CAW/B,CAAC"}
|
package/dist/rules/user.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const checkUserRules = async (db, user, dapp) => {
|
|
2
|
-
const userRule = await db.getUserBlockRuleRecord(user, dapp);
|
|
3
|
-
if (userRule &&
|
|
4
|
-
userRule.userAccount === user &&
|
|
5
|
-
userRule.dappAccount === dapp) {
|
|
6
|
-
return userRule;
|
|
7
|
-
}
|
|
8
|
-
return undefined;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=user.js.map
|
package/dist/rules/user.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/rules/user.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAClC,EAAqB,EACrB,IAAY,EACZ,IAAY,EACqB,EAAE;IACnC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE7D,IACC,QAAQ;QACR,QAAQ,CAAC,WAAW,KAAK,IAAI;QAC7B,QAAQ,CAAC,WAAW,KAAK,IAAI,EAC5B,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
|