@prosopo/types 0.2.7 → 0.2.9
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/cjs/config/config.cjs +34 -43
- package/dist/cjs/config/enumMap.cjs +8 -0
- package/dist/cjs/config/index.cjs +5 -3
- package/dist/cjs/config/network.cjs +32 -0
- package/dist/cjs/contracts/captcha/dist/contract-info/captcha.cjs +2 -2
- package/dist/cjs/datasets/captcha.cjs +7 -0
- package/dist/cjs/datasets/dataset.cjs +4 -0
- package/dist/cjs/datasets/index.cjs +3 -0
- package/dist/cjs/index.cjs +10 -3
- package/dist/cjs/networks/index.cjs +38 -0
- package/dist/config/config.d.ts +558 -311
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +42 -45
- package/dist/config/config.js.map +1 -1
- package/dist/config/enumMap.d.ts +3 -0
- package/dist/config/enumMap.d.ts.map +1 -0
- package/dist/config/enumMap.js +6 -0
- package/dist/config/enumMap.js.map +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/network.d.ts +84 -0
- package/dist/config/network.d.ts.map +1 -0
- package/dist/config/network.js +27 -0
- package/dist/config/network.js.map +1 -0
- package/dist/datasets/captcha.d.ts +96 -1
- package/dist/datasets/captcha.d.ts.map +1 -1
- package/dist/datasets/captcha.js +5 -0
- package/dist/datasets/captcha.js.map +1 -1
- package/dist/datasets/dataset.d.ts +98 -0
- package/dist/datasets/dataset.d.ts.map +1 -1
- package/dist/datasets/dataset.js +4 -1
- package/dist/datasets/dataset.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/networks/index.d.ts +4 -0
- package/dist/networks/index.d.ts.map +1 -0
- package/dist/networks/index.js +45 -0
- package/dist/networks/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const common = require("@prosopo/common");
|
|
4
|
+
const network = require("./network.cjs");
|
|
4
5
|
const z = require("zod");
|
|
6
|
+
const index = require("../networks/index.cjs");
|
|
5
7
|
const DatabaseTypes = z.z.enum(["mongo", "mongoMemory"]);
|
|
6
|
-
const EnvironmentTypesSchema = z.z.enum(["development", "
|
|
7
|
-
const NetworkNamesSchema = EnvironmentTypesSchema;
|
|
8
|
+
const EnvironmentTypesSchema = z.z.enum(["development", "staging", "production"]);
|
|
8
9
|
const DatabaseConfigSchema = z.z.record(
|
|
9
10
|
EnvironmentTypesSchema,
|
|
10
11
|
z.z.object({
|
|
@@ -13,52 +14,35 @@ const DatabaseConfigSchema = z.z.record(
|
|
|
13
14
|
dbname: z.z.string(),
|
|
14
15
|
authSource: z.z.string()
|
|
15
16
|
})
|
|
16
|
-
)
|
|
17
|
+
);
|
|
17
18
|
const BatchCommitConfigSchema = z.z.object({
|
|
18
|
-
interval: z.z.number().positive(),
|
|
19
|
-
maxBatchExtrinsicPercentage: z.z.number().positive()
|
|
19
|
+
interval: z.z.number().positive().optional().default(300),
|
|
20
|
+
maxBatchExtrinsicPercentage: z.z.number().positive().optional().default(59)
|
|
20
21
|
});
|
|
21
22
|
const ProsopoBaseConfigSchema = z.z.object({
|
|
22
|
-
logLevel: common.LogLevel,
|
|
23
|
-
defaultEnvironment: EnvironmentTypesSchema.default(EnvironmentTypesSchema.Values.
|
|
24
|
-
|
|
23
|
+
logLevel: common.LogLevel.optional().default(common.LogLevel.enum.info),
|
|
24
|
+
defaultEnvironment: EnvironmentTypesSchema.default(EnvironmentTypesSchema.Values.production),
|
|
25
|
+
defaultNetwork: network.NetworkNamesSchema.default(network.NetworkNamesSchema.Values.rococo),
|
|
26
|
+
// The account with which to query the contract.merge sign transactions
|
|
25
27
|
account: z.z.object({
|
|
26
|
-
address: z.z.string(),
|
|
28
|
+
address: z.z.string().optional(),
|
|
27
29
|
secret: z.z.string().optional(),
|
|
28
30
|
password: z.z.string().optional()
|
|
29
31
|
})
|
|
30
32
|
});
|
|
31
|
-
const NetworkConfigSchema = z.z.object({
|
|
32
|
-
endpoint: z.z.string().url(),
|
|
33
|
-
contract: z.z.object({
|
|
34
|
-
address: z.z.string(),
|
|
35
|
-
name: z.z.string()
|
|
36
|
-
}),
|
|
37
|
-
accounts: z.z.array(z.z.string()).optional()
|
|
38
|
-
});
|
|
39
|
-
const ProsopoNetworksSchema = z.z.record(NetworkNamesSchema, NetworkConfigSchema.required()).default({
|
|
40
|
-
development: {
|
|
41
|
-
endpoint: "ws://127.0.0.1:9944",
|
|
42
|
-
contract: {
|
|
43
|
-
address: "",
|
|
44
|
-
name: ""
|
|
45
|
-
},
|
|
46
|
-
accounts: []
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
33
|
const ProsopoBasicConfigSchema = ProsopoBaseConfigSchema.merge(
|
|
50
34
|
z.z.object({
|
|
51
|
-
networks: ProsopoNetworksSchema,
|
|
35
|
+
networks: network.ProsopoNetworksSchema.default(index),
|
|
52
36
|
database: DatabaseConfigSchema.optional()
|
|
53
37
|
})
|
|
54
38
|
);
|
|
55
39
|
const ProsopoCaptchaCountConfigSchema = z.z.object({
|
|
56
40
|
solved: z.z.object({
|
|
57
41
|
count: z.z.number().positive()
|
|
58
|
-
}),
|
|
42
|
+
}).optional().default({ count: 1 }),
|
|
59
43
|
unsolved: z.z.object({
|
|
60
44
|
count: z.z.number().nonnegative()
|
|
61
|
-
})
|
|
45
|
+
}).optional().default({ count: 1 })
|
|
62
46
|
});
|
|
63
47
|
const ProsopoImageServerConfigSchema = z.z.object({
|
|
64
48
|
baseURL: z.z.string().url(),
|
|
@@ -67,18 +51,17 @@ const ProsopoImageServerConfigSchema = z.z.object({
|
|
|
67
51
|
const ProsopoCaptchaSolutionConfigSchema = z.z.object({
|
|
68
52
|
requiredNumberOfSolutions: z.z.number().positive().min(2),
|
|
69
53
|
solutionWinningPercentage: z.z.number().positive().max(100),
|
|
70
|
-
captchaFilePath: z.z.string(),
|
|
71
54
|
captchaBlockRecency: z.z.number().positive().min(2)
|
|
72
55
|
});
|
|
73
56
|
const ProsopoClientConfigSchema = ProsopoBasicConfigSchema.merge(
|
|
74
57
|
z.z.object({
|
|
75
58
|
userAccountAddress: z.z.string().optional(),
|
|
76
|
-
web2: z.z.boolean(),
|
|
77
|
-
solutionThreshold: z.z.number().positive().max(100),
|
|
78
|
-
dappName: z.z.string(),
|
|
59
|
+
web2: z.z.boolean().optional().default(true),
|
|
60
|
+
solutionThreshold: z.z.number().positive().max(100).optional().default(80),
|
|
61
|
+
dappName: z.z.string().optional().default("ProsopoClientDapp"),
|
|
79
62
|
serverUrl: z.z.string().url()
|
|
80
63
|
})
|
|
81
|
-
);
|
|
64
|
+
).refine((schema) => schema.defaultNetwork in schema.networks, "defaultNetwork must be in networks");
|
|
82
65
|
const ProsopoServerConfigSchema = ProsopoClientConfigSchema;
|
|
83
66
|
const AccountCreatorConfigSchema = z.z.object({
|
|
84
67
|
area: z.z.object({
|
|
@@ -93,17 +76,28 @@ const AccountCreatorConfigSchema = z.z.object({
|
|
|
93
76
|
seed: z.z.number().positive()
|
|
94
77
|
});
|
|
95
78
|
const ThemeType = z.z.union([z.z.literal("light"), z.z.literal("dark")]);
|
|
96
|
-
const ProcaptchaConfigSchema = ProsopoClientConfigSchema.
|
|
79
|
+
const ProcaptchaConfigSchema = ProsopoClientConfigSchema.and(
|
|
97
80
|
z.z.object({
|
|
98
81
|
accountCreator: AccountCreatorConfigSchema.optional(),
|
|
99
|
-
theme: ThemeType.optional()
|
|
82
|
+
theme: ThemeType.optional(),
|
|
83
|
+
challengeValidLength: z.z.number().positive().optional()
|
|
100
84
|
})
|
|
101
85
|
);
|
|
102
86
|
const ProsopoConfigSchema = ProsopoBasicConfigSchema.merge(
|
|
103
87
|
z.z.object({
|
|
104
|
-
captchas: ProsopoCaptchaCountConfigSchema
|
|
105
|
-
|
|
106
|
-
|
|
88
|
+
captchas: ProsopoCaptchaCountConfigSchema.optional().default({
|
|
89
|
+
solved: { count: 1 },
|
|
90
|
+
unsolved: { count: 1 }
|
|
91
|
+
}),
|
|
92
|
+
captchaSolutions: ProsopoCaptchaSolutionConfigSchema.optional().default({
|
|
93
|
+
requiredNumberOfSolutions: 3,
|
|
94
|
+
solutionWinningPercentage: 80,
|
|
95
|
+
captchaBlockRecency: 10
|
|
96
|
+
}),
|
|
97
|
+
batchCommit: BatchCommitConfigSchema.optional().default({
|
|
98
|
+
interval: 300,
|
|
99
|
+
maxBatchExtrinsicPercentage: 59
|
|
100
|
+
}),
|
|
107
101
|
server: ProsopoImageServerConfigSchema
|
|
108
102
|
})
|
|
109
103
|
);
|
|
@@ -112,8 +106,6 @@ exports.BatchCommitConfigSchema = BatchCommitConfigSchema;
|
|
|
112
106
|
exports.DatabaseConfigSchema = DatabaseConfigSchema;
|
|
113
107
|
exports.DatabaseTypes = DatabaseTypes;
|
|
114
108
|
exports.EnvironmentTypesSchema = EnvironmentTypesSchema;
|
|
115
|
-
exports.NetworkConfigSchema = NetworkConfigSchema;
|
|
116
|
-
exports.NetworkNamesSchema = NetworkNamesSchema;
|
|
117
109
|
exports.ProcaptchaConfigSchema = ProcaptchaConfigSchema;
|
|
118
110
|
exports.ProsopoBaseConfigSchema = ProsopoBaseConfigSchema;
|
|
119
111
|
exports.ProsopoBasicConfigSchema = ProsopoBasicConfigSchema;
|
|
@@ -122,5 +114,4 @@ exports.ProsopoCaptchaSolutionConfigSchema = ProsopoCaptchaSolutionConfigSchema;
|
|
|
122
114
|
exports.ProsopoClientConfigSchema = ProsopoClientConfigSchema;
|
|
123
115
|
exports.ProsopoConfigSchema = ProsopoConfigSchema;
|
|
124
116
|
exports.ProsopoImageServerConfigSchema = ProsopoImageServerConfigSchema;
|
|
125
|
-
exports.ProsopoNetworksSchema = ProsopoNetworksSchema;
|
|
126
117
|
exports.ProsopoServerConfigSchema = ProsopoServerConfigSchema;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const z = require("zod");
|
|
4
|
+
const enumMap = (enumeration, obj) => {
|
|
5
|
+
const validateKeysInEnum = (record) => Object.keys(record).every((key) => enumeration.safeParse(key).success);
|
|
6
|
+
return z.z.record(obj).refine(validateKeysInEnum);
|
|
7
|
+
};
|
|
8
|
+
exports.enumMap = enumMap;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const config = require("./config.cjs");
|
|
4
|
+
const network = require("./network.cjs");
|
|
4
5
|
exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
|
|
5
6
|
exports.BatchCommitConfigSchema = config.BatchCommitConfigSchema;
|
|
6
7
|
exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
|
|
7
8
|
exports.DatabaseTypes = config.DatabaseTypes;
|
|
8
9
|
exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
|
|
9
|
-
exports.NetworkConfigSchema = config.NetworkConfigSchema;
|
|
10
|
-
exports.NetworkNamesSchema = config.NetworkNamesSchema;
|
|
11
10
|
exports.ProcaptchaConfigSchema = config.ProcaptchaConfigSchema;
|
|
12
11
|
exports.ProsopoBaseConfigSchema = config.ProsopoBaseConfigSchema;
|
|
13
12
|
exports.ProsopoBasicConfigSchema = config.ProsopoBasicConfigSchema;
|
|
@@ -16,5 +15,8 @@ exports.ProsopoCaptchaSolutionConfigSchema = config.ProsopoCaptchaSolutionConfig
|
|
|
16
15
|
exports.ProsopoClientConfigSchema = config.ProsopoClientConfigSchema;
|
|
17
16
|
exports.ProsopoConfigSchema = config.ProsopoConfigSchema;
|
|
18
17
|
exports.ProsopoImageServerConfigSchema = config.ProsopoImageServerConfigSchema;
|
|
19
|
-
exports.ProsopoNetworksSchema = config.ProsopoNetworksSchema;
|
|
20
18
|
exports.ProsopoServerConfigSchema = config.ProsopoServerConfigSchema;
|
|
19
|
+
exports.NetworkConfigSchema = network.NetworkConfigSchema;
|
|
20
|
+
exports.NetworkNamesSchema = network.NetworkNamesSchema;
|
|
21
|
+
exports.NetworkPairTypeSchema = network.NetworkPairTypeSchema;
|
|
22
|
+
exports.ProsopoNetworksSchema = network.ProsopoNetworksSchema;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const enumMap = require("./enumMap.cjs");
|
|
4
|
+
const z = require("zod");
|
|
5
|
+
const NetworkNamesSchema = z.z.enum(["development", "rococo", "shiden"]);
|
|
6
|
+
const NetworkPairTypeSchema = z.z.union([
|
|
7
|
+
z.z.literal("sr25519"),
|
|
8
|
+
z.z.literal("ed25519"),
|
|
9
|
+
z.z.literal("ecdsa"),
|
|
10
|
+
z.z.literal("ethereum")
|
|
11
|
+
]);
|
|
12
|
+
const NetworkConfigSchema = z.z.object({
|
|
13
|
+
endpoint: z.z.string().url(),
|
|
14
|
+
contract: z.z.object({
|
|
15
|
+
address: z.z.string(),
|
|
16
|
+
name: z.z.string()
|
|
17
|
+
}),
|
|
18
|
+
pairType: NetworkPairTypeSchema,
|
|
19
|
+
ss58Format: z.z.number().positive().default(42)
|
|
20
|
+
});
|
|
21
|
+
const ProsopoNetworksSchema = enumMap.enumMap(
|
|
22
|
+
NetworkNamesSchema,
|
|
23
|
+
NetworkConfigSchema.required({
|
|
24
|
+
endpoint: true,
|
|
25
|
+
pairType: true,
|
|
26
|
+
ss58Format: true
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
exports.NetworkConfigSchema = NetworkConfigSchema;
|
|
30
|
+
exports.NetworkNamesSchema = NetworkNamesSchema;
|
|
31
|
+
exports.NetworkPairTypeSchema = NetworkPairTypeSchema;
|
|
32
|
+
exports.ProsopoNetworksSchema = ProsopoNetworksSchema;
|