@prosopo/provider-mock 0.2.15 → 0.2.17

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/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@prosopo/provider-mock",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",
8
8
  "engines": {
9
- "node": ">=16",
10
- "npm": "8.9"
9
+ "node": ">=18",
10
+ "npm": ">=9"
11
11
  },
12
12
  "scripts": {
13
13
  "clean": "tsc --build --clean",
14
14
  "build": "tsc --build --verbose tsconfig.json"
15
15
  },
16
16
  "dependencies": {
17
- "@prosopo/cli": "0.2.15",
18
- "@prosopo/common": "0.2.15",
19
- "@prosopo/types": "0.2.15",
17
+ "@prosopo/cli": "0.2.17",
18
+ "@prosopo/common": "0.2.17",
19
+ "@prosopo/types": "0.2.17",
20
20
  "es-main": "^1.3.0",
21
21
  "express": "^4.18.1"
22
22
  },
package/src/api.ts DELETED
@@ -1,72 +0,0 @@
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
- import { ApiPaths, VerifySolutionBody } from '@prosopo/types'
15
- import { ProsopoApiError } from '@prosopo/common'
16
- import { VerifySolutionBodyType } from '@prosopo/types'
17
- import express, { Router } from 'express'
18
-
19
- /**
20
- * Returns a router connected to the database which can interact with the Proposo protocol
21
- *
22
- * @return {Router} - A middleware router that can interact with the Prosopo protocol
23
- * @param {Environment} env - The Prosopo environment
24
- */
25
- export function prosopoRouter(): Router {
26
- const router = express.Router()
27
-
28
- /**
29
- * Verifies a user's solution as being approved or not
30
- *
31
- * @param {string} userAccount - Dapp User id
32
- * @param {string} commitmentId - The captcha solution to look up
33
- */
34
- router.post(ApiPaths.VerifyCaptchaSolution, async (req, res, next) => {
35
- let parsed: VerifySolutionBodyType
36
- try {
37
- parsed = VerifySolutionBody.parse(req.body)
38
- } catch (err) {
39
- // TODO fix error handling
40
- console.log('parsing error')
41
- return next(new ProsopoApiError(err as Error, undefined, 400))
42
- }
43
- try {
44
- const testCommitmentId = '0x123456789test'
45
- const testAccount = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
46
- let statusMessage = 'API.USER_NOT_VERIFIED'
47
- let approved = false
48
- if (
49
- (parsed.user && parsed.user === testAccount) ||
50
- (parsed.commitmentId && parsed.commitmentId === testCommitmentId)
51
- ) {
52
- approved = true
53
- statusMessage = 'API.USER_VERIFIED'
54
- return res.json({
55
- status: req.t(statusMessage),
56
- solutionApproved: approved,
57
- commitmentId: testCommitmentId,
58
- })
59
- }
60
-
61
- return res.json({
62
- status: req.t(statusMessage),
63
- solutionApproved: false,
64
- })
65
- } catch (err) {
66
- // TODO fix error handling
67
- return next(new ProsopoApiError(err as Error, undefined, 400))
68
- }
69
- })
70
-
71
- return router
72
- }
package/src/start.ts DELETED
@@ -1,27 +0,0 @@
1
- import { LogLevel, getLogger } from '@prosopo/common'
2
- import { handleErrors } from '@prosopo/cli'
3
- import { i18nMiddleware } from '@prosopo/common'
4
- import { prosopoRouter } from './api.js'
5
- import cors from 'cors'
6
- import express from 'express'
7
- const logger = getLogger(LogLevel.enum.info, 'prosopo:provider-mock:start.ts')
8
-
9
- async function startApi() {
10
- const apiApp = express()
11
- const apiPort = '9229'
12
-
13
- apiApp.use(cors())
14
- apiApp.use(express.json())
15
- apiApp.use(i18nMiddleware({}))
16
- apiApp.use(prosopoRouter())
17
-
18
- apiApp.use(handleErrors)
19
- apiApp.listen(apiPort, () => {
20
- logger.info(`Prosopo app listening at http://localhost:${apiPort}`)
21
- })
22
- }
23
-
24
- startApi().catch((error) => {
25
- logger.error(error)
26
- process.exit(1)
27
- })
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.esm.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./dist",
6
- "module": "NodeNext"
7
- },
8
- "include": ["src", "src/**/*.json"],
9
- "references": [
10
- {
11
- "path": "../../dev/config"
12
- },
13
- {
14
- "path": "../../packages/cli"
15
- },
16
- {
17
- "path": "../../packages/common"
18
- },
19
- {
20
- "path": "../../packages/types"
21
- }
22
- ]
23
- }