@prosopo/api 0.2.0 → 0.2.1
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/HttpClientBase.d.ts.map +1 -1
- package/dist/api/HttpClientBase.js +2 -2
- package/dist/api/HttpClientBase.js.map +1 -1
- package/dist/cjs/api/HttpClientBase.cjs +17 -0
- package/dist/cjs/api/ProviderApi.cjs +47 -0
- package/dist/cjs/api/index.cjs +6 -0
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/types/api.cjs +1 -0
- package/dist/cjs/types/index.cjs +2 -0
- package/package.json +10 -3
- package/vite.cjs.config.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.d.ts","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAaA,
|
|
1
|
+
{"version":3,"file":"HttpClientBase.d.ts","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAoB,MAAM,OAAO,CAAA;AAEtE,qBAAa,cAAc;IACvB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;gBAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAK;IAMxC,SAAS,CAAC,eAAe,aAAc,aAAa,SAGnD;IAED,SAAS,CAAC,YAAY,UAAW,GAAG,oBAA0B;CACjE;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import axios from 'axios';
|
|
14
|
+
import { default as axios } from 'axios';
|
|
15
15
|
export class HttpClientBase {
|
|
16
16
|
constructor(baseURL, prefix = '') {
|
|
17
17
|
this.responseHandler = (response) => {
|
|
@@ -20,7 +20,7 @@ export class HttpClientBase {
|
|
|
20
20
|
};
|
|
21
21
|
this.errorHandler = (error) => Promise.reject(error);
|
|
22
22
|
baseURL = baseURL + prefix;
|
|
23
|
-
this.axios = axios.
|
|
23
|
+
this.axios = axios.create({ baseURL });
|
|
24
24
|
this.axios.interceptors.response.use(this.responseHandler, this.errorHandler);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.js","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"HttpClientBase.js","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAgC,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AAEtE,MAAM,OAAO,cAAc;IAGvB,YAAY,OAAe,EAAE,MAAM,GAAG,EAAE;QAM9B,oBAAe,GAAG,CAAC,QAAuB,EAAE,EAAE;YACpD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;YAC5C,OAAO,QAAQ,CAAC,IAAI,CAAA;QACxB,CAAC,CAAA;QAES,iBAAY,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAV1D,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACjF,CAAC;CAQJ;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const axios = require("axios");
|
|
4
|
+
class HttpClientBase {
|
|
5
|
+
constructor(baseURL, prefix = "") {
|
|
6
|
+
this.responseHandler = (response) => {
|
|
7
|
+
console.log("API REQUEST", response.request);
|
|
8
|
+
return response.data;
|
|
9
|
+
};
|
|
10
|
+
this.errorHandler = (error) => Promise.reject(error);
|
|
11
|
+
baseURL = baseURL + prefix;
|
|
12
|
+
this.axios = axios.create({ baseURL });
|
|
13
|
+
this.axios.interceptors.response.use(this.responseHandler, this.errorHandler);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.HttpClientBase = HttpClientBase;
|
|
17
|
+
exports.default = HttpClientBase;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const types = require("@prosopo/types");
|
|
3
|
+
const HttpClientBase = require("./HttpClientBase.cjs");
|
|
4
|
+
class ProviderApi extends HttpClientBase.HttpClientBase {
|
|
5
|
+
constructor(network, providerUrl, account) {
|
|
6
|
+
if (!providerUrl.startsWith("http")) {
|
|
7
|
+
providerUrl = `https://${providerUrl}`;
|
|
8
|
+
}
|
|
9
|
+
console.log("ProviderApi", providerUrl);
|
|
10
|
+
super(providerUrl);
|
|
11
|
+
this.network = network;
|
|
12
|
+
this.account = account;
|
|
13
|
+
}
|
|
14
|
+
getCaptchaChallenge(userAccount, randomProvider) {
|
|
15
|
+
const { provider } = randomProvider;
|
|
16
|
+
const { blockNumber } = randomProvider;
|
|
17
|
+
const dappAccount = this.account;
|
|
18
|
+
const url = `${types.ApiPaths.GetCaptchaChallenge}/${provider.datasetId}/${userAccount}/${dappAccount}/${blockNumber.toString().replace(/,/g, "")}`;
|
|
19
|
+
console.log(url);
|
|
20
|
+
return this.axios.get(url);
|
|
21
|
+
}
|
|
22
|
+
submitCaptchaSolution(captchas, requestHash, userAccount, salt, signature) {
|
|
23
|
+
const captchaSolutionBody = types.CaptchaSolutionBody.parse({
|
|
24
|
+
captchas,
|
|
25
|
+
requestHash,
|
|
26
|
+
user: userAccount,
|
|
27
|
+
dapp: this.account,
|
|
28
|
+
salt,
|
|
29
|
+
signature
|
|
30
|
+
});
|
|
31
|
+
return this.axios.post(types.ApiPaths.SubmitCaptchaSolution, captchaSolutionBody);
|
|
32
|
+
}
|
|
33
|
+
verifyDappUser(userAccount, commitmentId) {
|
|
34
|
+
const payload = { user: userAccount };
|
|
35
|
+
if (commitmentId) {
|
|
36
|
+
payload["commitmentId"] = commitmentId;
|
|
37
|
+
}
|
|
38
|
+
return this.axios.post(types.ApiPaths.VerifyCaptchaSolution, payload);
|
|
39
|
+
}
|
|
40
|
+
getProviderStatus() {
|
|
41
|
+
return this.axios.get(types.ApiPaths.GetProviderStatus);
|
|
42
|
+
}
|
|
43
|
+
getProviderDetails() {
|
|
44
|
+
return this.axios.get(types.ApiPaths.GetProviderDetails);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
module.exports = ProviderApi;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const HttpClientBase = require("./HttpClientBase.cjs");
|
|
4
|
+
const ProviderApi = require("./ProviderApi.cjs");
|
|
5
|
+
exports.HttpClientBase = HttpClientBase.HttpClientBase;
|
|
6
|
+
exports.ProviderApi = ProviderApi;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./api/index.cjs");
|
|
4
|
+
require("./types/index.cjs");
|
|
5
|
+
const ProviderApi = require("./api/ProviderApi.cjs");
|
|
6
|
+
const HttpClientBase = require("./api/HttpClientBase.cjs");
|
|
7
|
+
exports.ProviderApi = ProviderApi;
|
|
8
|
+
exports.HttpClientBase = HttpClientBase.HttpClientBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Wrapper for the provider API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/cjs/index.cjs"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
7
13
|
"scripts": {
|
|
8
14
|
"clean": "tsc --build --clean",
|
|
9
15
|
"build": "tsc --build --verbose",
|
|
16
|
+
"build:cjs": "npx vite --config vite.cjs.config.ts build",
|
|
10
17
|
"lint": "npx eslint .",
|
|
11
18
|
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
|
|
12
19
|
},
|
|
@@ -21,8 +28,8 @@
|
|
|
21
28
|
},
|
|
22
29
|
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
23
30
|
"dependencies": {
|
|
24
|
-
"@prosopo/types": "0.2.
|
|
25
|
-
"axios": "^
|
|
31
|
+
"@prosopo/types": "0.2.1",
|
|
32
|
+
"axios": "^1.5.0"
|
|
26
33
|
},
|
|
27
34
|
"devDependencies": {
|
|
28
35
|
"tslib": "^2.6.2",
|