@prosopo/provider 0.2.14 → 0.2.15
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.js +0 -56
- package/dist/api/admin.js.map +1 -1
- package/dist/api/captcha.d.ts +0 -6
- package/dist/api/captcha.d.ts.map +1 -1
- package/dist/api/captcha.js +11 -73
- package/dist/api/captcha.js.map +1 -1
- package/dist/batch/commitments.js +0 -18
- package/dist/batch/commitments.js.map +1 -1
- package/dist/batch/index.js +0 -13
- package/dist/batch/index.js.map +1 -1
- package/dist/cjs/api/captcha.cjs +9 -19
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- package/dist/scheduler.js +0 -15
- package/dist/scheduler.js.map +1 -1
- package/dist/tasks/calculateSolutions.d.ts +0 -3
- package/dist/tasks/calculateSolutions.d.ts.map +1 -1
- package/dist/tasks/calculateSolutions.js +0 -27
- package/dist/tasks/calculateSolutions.js.map +1 -1
- package/dist/tasks/index.js +0 -13
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/tasks.d.ts +0 -63
- package/dist/tasks/tasks.d.ts.map +1 -1
- package/dist/tasks/tasks.js +1 -84
- package/dist/tasks/tasks.js.map +1 -1
- package/dist/tests/accounts.js +0 -13
- package/dist/tests/accounts.js.map +1 -1
- package/dist/tests/batch/commitments.test.js +4 -68
- package/dist/tests/batch/commitments.test.js.map +1 -1
- package/dist/tests/contract/helpers.test.js +0 -1
- package/dist/tests/contract/helpers.test.js.map +1 -1
- package/dist/tests/dataUtils/DatabaseAccounts.js +0 -1
- package/dist/tests/dataUtils/DatabaseAccounts.js.map +1 -1
- package/dist/tests/dataUtils/DatabasePopulator.js +0 -7
- package/dist/tests/dataUtils/DatabasePopulator.js.map +1 -1
- package/dist/tests/dataUtils/dapp-example-contract/loadFiles.js +0 -15
- package/dist/tests/dataUtils/dapp-example-contract/loadFiles.js.map +1 -1
- package/dist/tests/dataUtils/funds.d.ts +0 -15
- package/dist/tests/dataUtils/funds.d.ts.map +1 -1
- package/dist/tests/dataUtils/funds.js +1 -24
- package/dist/tests/dataUtils/funds.js.map +1 -1
- package/dist/tests/dataUtils/populateDatabase.js +0 -1
- package/dist/tests/dataUtils/populateDatabase.js.map +1 -1
- package/dist/tests/tasks/tasks.test.js +1 -207
- package/dist/tests/tasks/tasks.test.js.map +1 -1
- package/dist/tests/util.test.js +0 -14
- package/dist/tests/util.test.js.map +1 -1
- package/dist/util.d.ts +0 -11
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +0 -31
- package/dist/util.js.map +1 -1
- package/package.json +10 -10
package/dist/api/admin.js
CHANGED
|
@@ -1,58 +1,2 @@
|
|
|
1
|
-
// import { Keyring } from '@polkadot/keyring'
|
|
2
|
-
// import { ProviderEnvironment } from '@prosopo/types-env'
|
|
3
|
-
// import express, { Router } from 'express'
|
|
4
|
-
// import jwt from 'jsonwebtoken'
|
|
5
1
|
export {};
|
|
6
|
-
// /**
|
|
7
|
-
// * Admin router with auth, temp example
|
|
8
|
-
// *
|
|
9
|
-
// * @return {Router} - router stuff
|
|
10
|
-
// * @param {Environment} env - env stuff
|
|
11
|
-
// */
|
|
12
|
-
// export function adminRouter(env: ProviderEnvironment): Router {
|
|
13
|
-
// const keyring = new Keyring({ type: 'sr25519' })
|
|
14
|
-
// const router = express.Router()
|
|
15
|
-
// // Middleware to verify auth token
|
|
16
|
-
// const authMiddleware = (req, res, next) => {
|
|
17
|
-
// const authHeader = req.headers.authorization
|
|
18
|
-
// if (authHeader) {
|
|
19
|
-
// const token = authHeader.split(' ')[1]
|
|
20
|
-
// // Verify token using the public key
|
|
21
|
-
// jwt.verify(token, env.config.account.address, (err, user) => {
|
|
22
|
-
// if (err) {
|
|
23
|
-
// return res.sendStatus(403)
|
|
24
|
-
// }
|
|
25
|
-
// req.user = user
|
|
26
|
-
// next()
|
|
27
|
-
// })
|
|
28
|
-
// } else {
|
|
29
|
-
// res.sendStatus(401)
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
32
|
-
// // Endpoint to authenticate user using Polkadot network for signing messages
|
|
33
|
-
// router.post('/auth', async (req, res) => {
|
|
34
|
-
// const { message, signature } = req.body
|
|
35
|
-
// try {
|
|
36
|
-
// const address = env.config.account.address
|
|
37
|
-
// const pair = keyring.addFromAddress(env.config.account.address)
|
|
38
|
-
// const isValid = pair.verify(message, signature, address)
|
|
39
|
-
// if (isValid) {
|
|
40
|
-
// const user = { address }
|
|
41
|
-
// // temp jwt, need to verify usage with correct imports and types
|
|
42
|
-
// const accessToken = jwt.sign(user, env.config.account.secret, { expiresIn: '1h' })
|
|
43
|
-
// return res.json({ accessToken })
|
|
44
|
-
// } else {
|
|
45
|
-
// return res.status(401).json({ message: 'bad auth' })
|
|
46
|
-
// }
|
|
47
|
-
// } catch (err) {
|
|
48
|
-
// // todo needs proper prosopo error handling
|
|
49
|
-
// return res.status(500).json({ message: 'An error occurred' })
|
|
50
|
-
// }
|
|
51
|
-
// })
|
|
52
|
-
// // Secure endpoint which requires auth token to access
|
|
53
|
-
// router.get('/secure', authMiddleware, (req, res) => {
|
|
54
|
-
// res.json({ message: 'correct auth' })
|
|
55
|
-
// })
|
|
56
|
-
// return router
|
|
57
|
-
// }
|
|
58
2
|
//# sourceMappingURL=admin.js.map
|
package/dist/api/admin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":""}
|
package/dist/api/captcha.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { ProviderEnvironment } from '@prosopo/types-env';
|
|
2
2
|
import { Router } from 'express';
|
|
3
|
-
/**
|
|
4
|
-
* Returns a router connected to the database which can interact with the Proposo protocol
|
|
5
|
-
*
|
|
6
|
-
* @return {Router} - A middleware router that can interact with the Prosopo protocol
|
|
7
|
-
* @param {Environment} env - The Prosopo environment
|
|
8
|
-
*/
|
|
9
3
|
export declare function prosopoRouter(env: ProviderEnvironment): Router;
|
|
10
4
|
//# sourceMappingURL=captcha.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/api/captcha.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/api/captcha.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAKxD,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAQzC,wBAAgB,aAAa,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAmJ9D"}
|
package/dist/api/captcha.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
1
|
import { ApiParams, ApiPaths, CaptchaSolutionBody, VerifySolutionBody, } from '@prosopo/types';
|
|
15
2
|
import { CaptchaRequestBody } from '@prosopo/types';
|
|
16
3
|
import { CaptchaStatus } from '@prosopo/captcha-contract/types-returns';
|
|
@@ -20,22 +7,9 @@ import { parseBlockNumber } from '../util.js';
|
|
|
20
7
|
import { parseCaptchaAssets } from '@prosopo/datasets';
|
|
21
8
|
import { validateAddress } from '@polkadot/util-crypto/address';
|
|
22
9
|
import express from 'express';
|
|
23
|
-
/**
|
|
24
|
-
* Returns a router connected to the database which can interact with the Proposo protocol
|
|
25
|
-
*
|
|
26
|
-
* @return {Router} - A middleware router that can interact with the Prosopo protocol
|
|
27
|
-
* @param {Environment} env - The Prosopo environment
|
|
28
|
-
*/
|
|
29
10
|
export function prosopoRouter(env) {
|
|
30
11
|
const router = express.Router();
|
|
31
12
|
const tasks = new Tasks(env);
|
|
32
|
-
/**
|
|
33
|
-
* Provides a Captcha puzzle to a Dapp User
|
|
34
|
-
* @param {string} datasetId - Provider datasetId
|
|
35
|
-
* @param {string} userAccount - Dapp User AccountId
|
|
36
|
-
* @param {string} blockNumber - Block number
|
|
37
|
-
* @return {Captcha} - The Captcha data
|
|
38
|
-
*/
|
|
39
13
|
router.get(`${ApiPaths.GetCaptchaChallenge}/:${ApiParams.datasetId}/:${ApiParams.user}/:${ApiParams.dapp}/:${ApiParams.blockNumber}`, async (req, res, next) => {
|
|
40
14
|
try {
|
|
41
15
|
const { blockNumber, datasetId, user, dapp } = CaptchaRequestBody.parse(req.params);
|
|
@@ -60,25 +34,15 @@ export function prosopoRouter(env) {
|
|
|
60
34
|
return res.json(captchaResponse);
|
|
61
35
|
}
|
|
62
36
|
catch (err) {
|
|
63
|
-
// TODO fix error handling
|
|
64
37
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
65
38
|
}
|
|
66
39
|
});
|
|
67
|
-
/**
|
|
68
|
-
* Receives solved CAPTCHA challenges, store to database, and check against solution commitment
|
|
69
|
-
*
|
|
70
|
-
* @param {string} userAccount - Dapp User id
|
|
71
|
-
* @param {string} dappAccount - Dapp Contract AccountId
|
|
72
|
-
* @param {Captcha[]} captchas - The Captcha solutions
|
|
73
|
-
* @return {DappUserSolutionResult} - The Captcha solution result and proof
|
|
74
|
-
*/
|
|
75
40
|
router.post(ApiPaths.SubmitCaptchaSolution, async (req, res, next) => {
|
|
76
41
|
let parsed;
|
|
77
42
|
try {
|
|
78
43
|
parsed = CaptchaSolutionBody.parse(req.body);
|
|
79
44
|
}
|
|
80
45
|
catch (err) {
|
|
81
|
-
// TODO fix error handling
|
|
82
46
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
83
47
|
}
|
|
84
48
|
try {
|
|
@@ -89,79 +53,53 @@ export function prosopoRouter(env) {
|
|
|
89
53
|
});
|
|
90
54
|
}
|
|
91
55
|
catch (err) {
|
|
92
|
-
// TODO fix error handling
|
|
93
56
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
94
57
|
}
|
|
95
58
|
});
|
|
96
|
-
/**
|
|
97
|
-
* Verifies a user's solution as being approved or not
|
|
98
|
-
*
|
|
99
|
-
* @param {string} userAccount - Dapp User id
|
|
100
|
-
* @param {string} commitmentId - The captcha solution to look up
|
|
101
|
-
*/
|
|
102
59
|
router.post(ApiPaths.VerifyCaptchaSolution, async (req, res, next) => {
|
|
103
60
|
let parsed;
|
|
104
61
|
try {
|
|
105
62
|
parsed = VerifySolutionBody.parse(req.body);
|
|
106
63
|
}
|
|
107
64
|
catch (err) {
|
|
108
|
-
// TODO fix error handling
|
|
109
65
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
110
66
|
}
|
|
111
67
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
const solution = await (parsed.commitmentId
|
|
69
|
+
? tasks.getDappUserCommitmentById(parsed.commitmentId)
|
|
70
|
+
: tasks.getDappUserCommitmentByAccount(parsed.user));
|
|
71
|
+
if (!solution) {
|
|
72
|
+
return res.json({ status: req.t('API.USER_NOT_VERIFIED'), solutionApproved: false });
|
|
116
73
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (solution) {
|
|
121
|
-
let approved = false;
|
|
122
|
-
if (solution.status === CaptchaStatus.approved) {
|
|
123
|
-
statusMessage = 'API.USER_VERIFIED';
|
|
124
|
-
approved = true;
|
|
125
|
-
}
|
|
126
|
-
return res.json({
|
|
127
|
-
status: req.t(statusMessage),
|
|
128
|
-
solutionApproved: approved,
|
|
129
|
-
commitmentId: solution.id,
|
|
130
|
-
});
|
|
74
|
+
const msSinceCompleted = new Date().getTime() - solution.completedAt;
|
|
75
|
+
if (parsed.maxVerifiedTime && msSinceCompleted > parsed.maxVerifiedTime) {
|
|
76
|
+
return res.json({ status: req.t('API.USER_NOT_VERIFIED'), solutionApproved: false });
|
|
131
77
|
}
|
|
78
|
+
const isApproved = solution.status === CaptchaStatus.approved;
|
|
132
79
|
return res.json({
|
|
133
|
-
status: req.t(
|
|
134
|
-
solutionApproved:
|
|
80
|
+
status: req.t(isApproved ? 'API.USER_VERIFIED' : 'API.USER_NOT_VERIFIED'),
|
|
81
|
+
solutionApproved: isApproved,
|
|
135
82
|
});
|
|
136
83
|
}
|
|
137
84
|
catch (err) {
|
|
138
|
-
// TODO fix error handling
|
|
139
85
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
140
86
|
}
|
|
141
87
|
});
|
|
142
|
-
/**
|
|
143
|
-
* Verifies that the provider is running and registered in the contract
|
|
144
|
-
*/
|
|
145
88
|
router.get(ApiPaths.GetProviderStatus, async (req, res, next) => {
|
|
146
89
|
try {
|
|
147
90
|
const status = await tasks.providerStatus();
|
|
148
91
|
return res.json({ status });
|
|
149
92
|
}
|
|
150
93
|
catch (err) {
|
|
151
|
-
// TODO fix error handling
|
|
152
94
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
153
95
|
}
|
|
154
96
|
});
|
|
155
|
-
/**
|
|
156
|
-
* Gets public details of the provider
|
|
157
|
-
*/
|
|
158
97
|
router.get(ApiPaths.GetProviderDetails, async (req, res, next) => {
|
|
159
98
|
try {
|
|
160
99
|
const details = await tasks.getProviderDetails();
|
|
161
100
|
return res.json(details);
|
|
162
101
|
}
|
|
163
102
|
catch (err) {
|
|
164
|
-
// TODO fix error handling
|
|
165
103
|
return next(new ProsopoApiError(err, undefined, 400));
|
|
166
104
|
}
|
|
167
105
|
});
|
package/dist/api/captcha.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/api/captcha.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/api/captcha.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,SAAS,EACT,QAAQ,EAER,mBAAmB,EAGnB,kBAAkB,GACrB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,OAAmB,MAAM,SAAS,CAAA;AAQzC,MAAM,UAAU,aAAa,CAAC,GAAwB;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAS5B,MAAM,CAAC,GAAG,CACN,GAAG,QAAQ,CAAC,mBAAmB,KAAK,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW,EAAE,EACzH,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI;YACA,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAA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AC5D,IAAI;YACA,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,CAAA;YAC3C,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;SAC9B;QAAC,OAAO,GAAG,EAAE;YAEV,OAAO,IAAI,CAAC,IAAI,eAAe,CAAC,GAAY,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAA;SACjE;IACL,CAAC,CAAC,CAAA;IAKF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC7D,IAAI;YACA,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,kBAAkB,EAAE,CAAA;YAChD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SAC3B;QAAC,OAAO,GAAG,EAAE;YAEV,OAAO,IAAI,CAAC,IAAI,eAAe,CAAC,GAAY,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAA;SACjE;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -14,27 +14,19 @@ export class BatchCommitmentsTask {
|
|
|
14
14
|
this.nonce = startNonce;
|
|
15
15
|
}
|
|
16
16
|
async run() {
|
|
17
|
-
// create a task id
|
|
18
17
|
const taskId = randomAsHex(32);
|
|
19
18
|
const taskRunning = await checkIfTaskIsRunning(ScheduledTaskNames.BatchCommitment, this.db);
|
|
20
|
-
// taskRunning and intervalExceeded checks separated over multiple lines to avoid race conditions between providers
|
|
21
19
|
if (!taskRunning) {
|
|
22
20
|
const intervalExceeded = await this.batchIntervalExceeded();
|
|
23
21
|
if (intervalExceeded) {
|
|
24
22
|
try {
|
|
25
|
-
// update last commit time
|
|
26
23
|
await this.db.storeScheduledTaskStatus(taskId, ScheduledTaskNames.BatchCommitment, ScheduledTaskStatus.Running);
|
|
27
|
-
//get commitments
|
|
28
24
|
const commitments = await this.getCommitments();
|
|
29
25
|
if (commitments.length > 0) {
|
|
30
26
|
this.logger.info(`Found ${commitments.length} commitments to commit`);
|
|
31
|
-
// get the extrinsics that are to be batched and an id associated with each one
|
|
32
27
|
const { extrinsics, ids: commitmentIds } = await this.createExtrinsics(commitments);
|
|
33
|
-
// commit and get the Ids of the commitments that were committed on-chain
|
|
34
28
|
await batch(this.contract.contract, this.contract.pair, extrinsics, this.logger);
|
|
35
|
-
// flag commitments as batched
|
|
36
29
|
await this.flagBatchedCommitments(commitmentIds);
|
|
37
|
-
// update last commit time and store the commitmentIds that were batched
|
|
38
30
|
await this.db.storeScheduledTaskStatus(taskId, ScheduledTaskNames.BatchCommitment, ScheduledTaskStatus.Completed, {
|
|
39
31
|
data: {
|
|
40
32
|
commitmentIds: commitments
|
|
@@ -68,9 +60,6 @@ export class BatchCommitmentsTask {
|
|
|
68
60
|
const commit = this.convertCommit(commitment);
|
|
69
61
|
commitmentArray.push(commit);
|
|
70
62
|
const encodedArgs = encodeStringArgs(this.contract.abi, fragment, [commitmentArray]);
|
|
71
|
-
// TODO can we get storage deposit from the provided query method?
|
|
72
|
-
// https://matrix.to/#/!utTuYglskDvqRRMQta:matrix.org/$tELySFxCORlHCHveOknGJBx-MdVe-SxFN8_BsYvcDmI?via=matrix.org&via=t2bot.io&via=cardinal.ems.host
|
|
73
|
-
// const response = await this.contract.query.providerCommitMany(commitmentArray)
|
|
74
63
|
const buildExtrinsicResult = await this.contract.getExtrinsicAndGasEstimates('providerCommitMany', encodedArgs);
|
|
75
64
|
extrinsic = buildExtrinsicResult.extrinsic;
|
|
76
65
|
const { options, storageDeposit } = buildExtrinsicResult;
|
|
@@ -80,10 +69,8 @@ export class BatchCommitmentsTask {
|
|
|
80
69
|
this.logger.debug(`${CONTRACT_METHOD_NAME} paymentInfo:`, paymentInfo.toNumber());
|
|
81
70
|
}
|
|
82
71
|
catch (e) {
|
|
83
|
-
// TODO https://github.com/polkadot-js/api/issues/5504
|
|
84
72
|
paymentInfo = new BN(0);
|
|
85
73
|
}
|
|
86
|
-
//totalEncodedLength += extrinsic.encodedLength
|
|
87
74
|
totalRefTime = totalRefTime.add(this.contract.api.registry.createType('WeightV2', options.gasLimit).refTime.toBn());
|
|
88
75
|
totalProofSize = totalProofSize.add(this.contract.api.registry.createType('WeightV2', options.gasLimit).proofSize.toBn());
|
|
89
76
|
totalFee = totalFee.add(paymentInfo.add(storageDeposit.asCharge.toBn()));
|
|
@@ -94,8 +81,6 @@ export class BatchCommitmentsTask {
|
|
|
94
81
|
.toString(), '`', 'UNIT');
|
|
95
82
|
this.logger.debug('Total Fee `', totalFee.div(oneUnit(this.contract.api)).toString(), '`', 'UNIT');
|
|
96
83
|
const feeTooHigh = totalFee.gt((await this.contract.api.query.system.account(this.contract.pair.address)).data.free.toBn());
|
|
97
|
-
// Check if we have a maximum number of transactions that we can successfully submit in a block or if the
|
|
98
|
-
// total fee is more than the provider has left in their account
|
|
99
84
|
if (extrinsicTooHigh || feeTooHigh) {
|
|
100
85
|
const msg = extrinsicTooHigh ? 'Max batch extrinsic percentage reached' : 'Fee too high';
|
|
101
86
|
this.logger.warn(msg);
|
|
@@ -119,12 +104,10 @@ export class BatchCommitmentsTask {
|
|
|
119
104
|
this.batchCommitConfig.maxBatchExtrinsicPercentage);
|
|
120
105
|
}
|
|
121
106
|
async batchIntervalExceeded() {
|
|
122
|
-
//if time since last commit > batchCommitInterval
|
|
123
107
|
const lastTime = await this.db.getLastBatchCommitTime();
|
|
124
108
|
return Date.now() - lastTime.getSeconds() > this.batchCommitConfig.interval;
|
|
125
109
|
}
|
|
126
110
|
async getCommitments() {
|
|
127
|
-
// get commitments that have not yet been batched on-chain
|
|
128
111
|
return await this.db.getUnbatchedDappUserCommitments();
|
|
129
112
|
}
|
|
130
113
|
async flagBatchedCommitments(commitmentIds) {
|
|
@@ -135,7 +118,6 @@ export class BatchCommitmentsTask {
|
|
|
135
118
|
return {
|
|
136
119
|
...commit,
|
|
137
120
|
userSignature,
|
|
138
|
-
// to satisfy typescript
|
|
139
121
|
requestedAt: new BN(requestedAt).toNumber(),
|
|
140
122
|
completedAt: new BN(completedAt).toNumber(),
|
|
141
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../src/batch/commitments.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAA2C,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAIjH,OAAO,EAA0B,oBAAoB,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGlH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE1D,MAAM,eAAe,GAAG,IAAI,EAAE,CAAC,KAAM,CAAC,CAAA;AACtC,MAAM,oBAAoB,GAAG,oBAAoB,CAAA;AAEjD,MAAM,OAAO,oBAAoB;IAM7B,YACI,iBAA0C,EAC1C,WAAmC,EACnC,EAAY,EACZ,UAAkB,EAClB,MAAc;QAEd,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAA;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAA;IAC3B,CAAC;IACD,KAAK,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../src/batch/commitments.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAA2C,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAIjH,OAAO,EAA0B,oBAAoB,EAAE,KAAK,E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,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,GAAG;YACrF,IAAI,CAAC,iBAAiB,CAAC,2BAA2B,CACrD,CAAA;IACL,CAAC;IAED,KAAK,CAAC,qBAAqB;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAA;QACvD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAA;IAC/E,CAAC;IAED,KAAK,CAAC,cAAc;QAEhB,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,aAAqB;QAC9C,MAAM,IAAI,CAAC,EAAE,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAA;IAC/D,CAAC;IAED,aAAa,CAAC,UAAgC;QAC1C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,GAAG,UAAU,CAAA;QAE7F,OAAO;YACH,GAAG,MAAM;YACT,aAAa;YAEb,WAAW,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;YAC3C,WAAW,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;SAC9C,CAAA;IACL,CAAC;CACJ"}
|
package/dist/batch/index.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
1
|
export * from './commitments.js';
|
|
15
2
|
//# sourceMappingURL=index.js.map
|
package/dist/batch/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/batch/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/batch/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAA"}
|
package/dist/cjs/api/captcha.cjs
CHANGED
|
@@ -71,28 +71,18 @@ function prosopoRouter(env) {
|
|
|
71
71
|
return next(new common.ProsopoApiError(err, void 0, 400));
|
|
72
72
|
}
|
|
73
73
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
solution = await tasks$1.getDappUserCommitmentByAccount(parsed.user);
|
|
78
|
-
} else {
|
|
79
|
-
solution = await tasks$1.getDappUserCommitmentById(parsed.commitmentId);
|
|
74
|
+
const solution = await (parsed.commitmentId ? tasks$1.getDappUserCommitmentById(parsed.commitmentId) : tasks$1.getDappUserCommitmentByAccount(parsed.user));
|
|
75
|
+
if (!solution) {
|
|
76
|
+
return res.json({ status: req.t("API.USER_NOT_VERIFIED"), solutionApproved: false });
|
|
80
77
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
statusMessage = "API.USER_VERIFIED";
|
|
85
|
-
approved = true;
|
|
86
|
-
}
|
|
87
|
-
return res.json({
|
|
88
|
-
status: req.t(statusMessage),
|
|
89
|
-
solutionApproved: approved,
|
|
90
|
-
commitmentId: solution.id
|
|
91
|
-
});
|
|
78
|
+
const msSinceCompleted = (/* @__PURE__ */ new Date()).getTime() - solution.completedAt;
|
|
79
|
+
if (parsed.maxVerifiedTime && msSinceCompleted > parsed.maxVerifiedTime) {
|
|
80
|
+
return res.json({ status: req.t("API.USER_NOT_VERIFIED"), solutionApproved: false });
|
|
92
81
|
}
|
|
82
|
+
const isApproved = solution.status === typesReturns.CaptchaStatus.approved;
|
|
93
83
|
return res.json({
|
|
94
|
-
status: req.t(
|
|
95
|
-
solutionApproved:
|
|
84
|
+
status: req.t(isApproved ? "API.USER_VERIFIED" : "API.USER_NOT_VERIFIED"),
|
|
85
|
+
solutionApproved: isApproved
|
|
96
86
|
});
|
|
97
87
|
} catch (err) {
|
|
98
88
|
return next(new common.ProsopoApiError(err, void 0, 400));
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
1
|
export * from './tasks/index.js';
|
|
15
2
|
export * from './util.js';
|
|
16
3
|
export * from './batch/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
|
package/dist/scheduler.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
// [object Object]
|
|
15
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
16
1
|
import { BatchCommitmentsTask } from './batch/commitments.js';
|
|
17
2
|
import { CalculateSolutionsTask } from './tasks/calculateSolutions.js';
|
|
18
3
|
import { CronJob } from 'cron';
|
package/dist/scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAElC,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAAiB,EAAE,MAA2B;IAC5F,MAAM,GAAG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CAAC,CAAC,GAAG,EAAE,EAAE;YACtB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,KAAK,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -2,9 +2,6 @@ import { ProviderEnvironment } from '@prosopo/types-env';
|
|
|
2
2
|
import { Tasks } from './tasks.js';
|
|
3
3
|
export declare class CalculateSolutionsTask extends Tasks {
|
|
4
4
|
constructor(env: ProviderEnvironment);
|
|
5
|
-
/**
|
|
6
|
-
* Apply new captcha solutions to captcha dataset and recalculate merkle tree
|
|
7
|
-
*/
|
|
8
5
|
run(): Promise<number>;
|
|
9
6
|
}
|
|
10
7
|
//# sourceMappingURL=calculateSolutions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateSolutions.d.ts","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,qBAAa,sBAAuB,SAAQ,KAAK;gBACjC,GAAG,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"calculateSolutions.d.ts","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,qBAAa,sBAAuB,SAAQ,KAAK;gBACjC,GAAG,EAAE,mBAAmB;IAQ9B,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;CAqE/B"}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
1
|
import { CaptchaStates } from '@prosopo/types';
|
|
15
2
|
import { ProsopoEnvError, getLogger } from '@prosopo/common';
|
|
16
3
|
import { ScheduledTaskNames } from '@prosopo/types';
|
|
@@ -22,27 +9,19 @@ export class CalculateSolutionsTask extends Tasks {
|
|
|
22
9
|
super(env);
|
|
23
10
|
this.logger = getLogger(env.config.logLevel, 'CalculateSolutionsTask');
|
|
24
11
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Apply new captcha solutions to captcha dataset and recalculate merkle tree
|
|
27
|
-
*/
|
|
28
12
|
async run() {
|
|
29
13
|
try {
|
|
30
14
|
const taskRunning = await checkIfTaskIsRunning(ScheduledTaskNames.CalculateSolution, this.db);
|
|
31
15
|
if (!taskRunning) {
|
|
32
|
-
// Get the current datasetId from the contract
|
|
33
16
|
const provider = (await this.contract.methods.getProvider(this.contract.pair.address, {})).value
|
|
34
17
|
.unwrap()
|
|
35
18
|
.unwrap();
|
|
36
|
-
// Get any unsolved CAPTCHA challenges from the database for this datasetId
|
|
37
19
|
const unsolvedCaptchas = await this.db.getAllCaptchasByDatasetId(provider.datasetId.toString(), CaptchaStates.Unsolved);
|
|
38
|
-
// edge case when a captcha dataset contains no unsolved CAPTCHA challenges
|
|
39
20
|
if (!unsolvedCaptchas) {
|
|
40
21
|
return 0;
|
|
41
22
|
}
|
|
42
|
-
// Sort the unsolved CAPTCHA challenges by their captchaId
|
|
43
23
|
const unsolvedSorted = unsolvedCaptchas.sort(captchaSort);
|
|
44
24
|
this.logger.info(`There are ${unsolvedSorted.length} unsolved CAPTCHA challenges`);
|
|
45
|
-
// Get the solution configuration from the config file
|
|
46
25
|
const requiredNumberOfSolutions = this.captchaSolutionConfig.requiredNumberOfSolutions;
|
|
47
26
|
const winningPercentage = this.captchaSolutionConfig.solutionWinningPercentage;
|
|
48
27
|
const winningNumberOfSolutions = Math.round(requiredNumberOfSolutions * (winningPercentage / 100));
|
|
@@ -53,20 +32,15 @@ export class CalculateSolutionsTask extends Tasks {
|
|
|
53
32
|
if (solutionsToUpdate.rows().length > 0) {
|
|
54
33
|
this.logger.info(`There are ${solutionsToUpdate.rows().length} CAPTCHA challenges to update with solutions`);
|
|
55
34
|
try {
|
|
56
|
-
// TODO polars doesn't have the captchaId field in the type
|
|
57
35
|
const captchaIdsToUpdate = [...solutionsToUpdate['captchaId'].values()];
|
|
58
36
|
const commitmentIds = solutions
|
|
59
37
|
.filter((s) => captchaIdsToUpdate.indexOf(s.captchaId) > -1)
|
|
60
38
|
.map((s) => s.commitmentId);
|
|
61
39
|
const dataset = await this.db.getDataset(provider.datasetId.toString());
|
|
62
40
|
dataset.captchas = updateSolutions(solutionsToUpdate, dataset.captchas, this.logger);
|
|
63
|
-
// store new solutions in database
|
|
64
41
|
await this.providerSetDataset(dataset);
|
|
65
|
-
// mark user solutions as used to calculate new solutions
|
|
66
42
|
await this.db.flagProcessedDappUserSolutions(captchaIdsToUpdate);
|
|
67
|
-
// mark user commitments as used to calculate new solutions
|
|
68
43
|
await this.db.flagProcessedDappUserCommitments(commitmentIds);
|
|
69
|
-
// remove old captcha challenges from database
|
|
70
44
|
await this.db.removeCaptchas(captchaIdsToUpdate);
|
|
71
45
|
return solutionsToUpdate.rows().length;
|
|
72
46
|
}
|
|
@@ -84,7 +58,6 @@ export class CalculateSolutionsTask extends Tasks {
|
|
|
84
58
|
return 0;
|
|
85
59
|
}
|
|
86
60
|
catch (error) {
|
|
87
|
-
// TODO fix error handling
|
|
88
61
|
throw new ProsopoEnvError(error, 'GENERAL.CALCULATE_CAPTCHA_SOLUTION');
|
|
89
62
|
}
|
|
90
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateSolutions.js","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculateSolutions.js","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7C,YAAY,GAAwB;QAChC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAA;IAC1E,CAAC;IAKD,KAAK,CAAC,GAAG;QACL,IAAI;YACA,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;YAC7F,IAAI,CAAC,WAAW,EAAE;gBAEd,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK;qBAC3F,MAAM,EAAE;qBACR,MAAM,EAAE,CAAA;gBAGb,MAAM,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js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
1
|
export * from './tasks.js';
|
|
15
2
|
export * from './calculateSolutions.js';
|
|
16
3
|
//# sourceMappingURL=index.js.map
|
package/dist/tasks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA"}
|