@prosopo/provider-mock 0.2.32 → 0.2.33

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.d.ts CHANGED
@@ -1,9 +1,3 @@
1
1
  import { Router } from 'express';
2
- /**
3
- * Returns a router connected to the database which can interact with the Proposo protocol
4
- *
5
- * @return {Router} - A middleware router that can interact with the Prosopo protocol
6
- * @param {Environment} env - The Prosopo environment
7
- */
8
2
  export declare function prosopoRouter(): Router;
9
3
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAgBA,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CA+CtC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAgBA,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAOzC,wBAAgB,aAAa,IAAI,MAAM,CAmDtC"}
package/dist/api.js CHANGED
@@ -1,50 +1,28 @@
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 { ApiPaths, VerifySolutionBody } from '@prosopo/types';
15
2
  import { ProsopoApiError } from '@prosopo/common';
16
3
  import express from 'express';
17
- /**
18
- * Returns a router connected to the database which can interact with the Proposo protocol
19
- *
20
- * @return {Router} - A middleware router that can interact with the Prosopo protocol
21
- * @param {Environment} env - The Prosopo environment
22
- */
23
4
  export function prosopoRouter() {
24
5
  const router = express.Router();
25
- /**
26
- * Verifies a user's solution as being approved or not
27
- *
28
- * @param {string} userAccount - Dapp User id
29
- * @param {string} commitmentId - The captcha solution to look up
30
- */
31
6
  router.post(ApiPaths.VerifyCaptchaSolution, async (req, res, next) => {
32
7
  let parsed;
33
8
  try {
34
9
  parsed = VerifySolutionBody.parse(req.body);
35
10
  }
36
11
  catch (err) {
37
- // TODO fix error handling
38
- console.log('parsing error');
39
- return next(new ProsopoApiError(err, undefined, 400));
12
+ return next(new ProsopoApiError('CAPTCHA.PARSE_ERROR', {
13
+ context: { error: err, errorCode: 400 },
14
+ logLevel: 'info',
15
+ }));
40
16
  }
41
17
  try {
42
18
  const testCommitmentId = '0x123456789test';
43
19
  const testAccount = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
20
+ const testDapp = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
44
21
  let statusMessage = 'API.USER_NOT_VERIFIED';
45
22
  let approved = false;
46
23
  if ((parsed.user && parsed.user === testAccount) ||
47
- (parsed.commitmentId && parsed.commitmentId === testCommitmentId)) {
24
+ (parsed.commitmentId && parsed.commitmentId === testCommitmentId) ||
25
+ (parsed.dapp && parsed.dapp === testDapp)) {
48
26
  approved = true;
49
27
  statusMessage = 'API.USER_VERIFIED';
50
28
  return res.json({
@@ -59,8 +37,7 @@ export function prosopoRouter() {
59
37
  });
60
38
  }
61
39
  catch (err) {
62
- // TODO fix error handling
63
- return next(new ProsopoApiError(err, undefined, 400));
40
+ return next(new ProsopoApiError('API.UNKNOWN', { context: { error: err, errorCode: 500 } }));
64
41
  }
65
42
  });
66
43
  return router;
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE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"Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -20,9 +20,9 @@
20
20
  "lint:fix": "npm run eslint:fix && npm run prettier:fix"
21
21
  },
22
22
  "dependencies": {
23
- "@prosopo/cli": "0.2.32",
24
- "@prosopo/common": "0.2.32",
25
- "@prosopo/types": "0.2.32",
23
+ "@prosopo/cli": "0.2.33",
24
+ "@prosopo/common": "0.2.33",
25
+ "@prosopo/types": "0.2.33",
26
26
  "es-main": "^1.3.0",
27
27
  "express": "^4.18.1"
28
28
  },