Skip to content

Commit

Permalink
replace request with axios (backport from monero-ts), bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
borgvin committed Sep 28, 2024
1 parent 2a1473a commit a35202f
Show file tree
Hide file tree
Showing 7 changed files with 959 additions and 1,605 deletions.
2,034 changes: 806 additions & 1,228 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "haven-wallet-core",
"description": "A JavaScript library for using Haven",
"version": "3.3.2",
"version": "4.1.0",
"license": "MIT",
"repository": "https://github.com/haven-protocol-org/haven-web-core",
"private": false,
Expand All @@ -18,13 +18,12 @@
"dependencies": {
"ajv": "^6.12.6",
"async": "2.6.4",
"crypto-js": "^4.0.0",
"axios": "^1.7.7",
"crypto-js": "^4.2.0",
"html5-fs": "0.1.1",
"memfs": "^3.2.2",
"net": "^1.0.2",
"promise-throttle": "^1.1.2",
"request": "2.88.0",
"request-promise": "^4.2.6",
"serialize-javascript": "^3.1.0",
"text-encoding": "^0.7.0",
"tls": "0.0.1",
Expand All @@ -40,7 +39,7 @@
"crypto-browserify": "^3.12.0",
"eslint": "^8.0.1",
"https-browserify": "^1.0.0",
"jsdoc": "^3.6.7",
"jsdoc": "^4.0.3",
"memfs": "^3.2.0",
"minimist": "^1.2.5",
"mocha": "^9.1.3",
Expand Down
2 changes: 0 additions & 2 deletions src/main/cpp/http_client_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ EM_JS(const char*, js_send_json_request, (const char* uri, const char* username,
body: UTF8ToString(body),
resolveWithFullResponse: true,
rejectUnauthorized: LibraryUtils.isRejectUnauthorized(UTF8ToString(reject_unauthorized_fn_id)),
requestApi: GenUtils.isFirefox() ? "xhr" : "fetch" // firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1491010
}).then(resp => {

// build response container
Expand Down Expand Up @@ -96,7 +95,6 @@ EM_JS(const char*, js_send_binary_request, (const char* uri, const char* usernam
body: view,
resolveWithFullResponse: true,
rejectUnauthorized: LibraryUtils.isRejectUnauthorized(UTF8ToString(reject_unauthorized_fn_id)),
requestApi: GenUtils.isFirefox() ? "xhr" : "fetch" // firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1491010
}).then(resp => {

// write binary body to heap to pass back pointer
Expand Down
25 changes: 25 additions & 0 deletions src/main/js/common/GenUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,31 @@ class GenUtils {
process.kill(signal ? signal : "SIGINT");
});
}

/**
* Resolve the given promise with a timeout.
*
* @param promise the promise to resolve within the timeout
* @param timeoutMs the timeout in milliseconds to resolve the promise
* @return the result of the promise unless error thrown
*/
static async executeWithTimeout(promise, timeoutMs) {
return new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
reject('Execution timed out in ' + timeoutMs + ' milliseconds')
}, timeoutMs);
promise.then(
(result) => {
clearTimeout(timeoutId);
resolve(result);
},
(error) => {
clearTimeout(timeoutId);
reject(error);
}
);
});
}
}

module.exports = GenUtils;
Loading

0 comments on commit a35202f

Please sign in to comment.