diff --git a/package-lock.json b/package-lock.json index 51c27282..99424b7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,8 +11,10 @@ "dependencies": { "@types/node": "^18.14.2", "console": "^0.7.2", + "decimal.js": "^10.4.3", "google-protobuf": "^3.20.3", - "grpc-web": "^1.4.2" + "grpc-web": "^1.4.2", + "node-xmlhttprequest": "^1.0.6" }, "devDependencies": { "@babel/core": "^7.21.0", @@ -22,7 +24,6 @@ "@typescript-eslint/eslint-plugin": "5.53.0", "@typescript-eslint/parser": "^5.53.0", "babel-jest": "^29.4.3", - "decimal.js": "^10.4.3", "eslint": "^8.35.0", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.3", @@ -30,7 +31,6 @@ "eslint-plugin-jsx-a11y": "^6.7.1", "jest": "^29.7.0", "monero-ts": "^0.11.1", - "node-xmlhttprequest": "^1.0.6", "ts-jest": "^29.2.5", "ts-jest-resolver": "^2.0.1", "typedoc": "^0.23.26", @@ -1890,7 +1890,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", - "dev": true, "engines": { "node": ">=14" } @@ -3591,9 +3590,9 @@ } }, "node_modules/axios": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", - "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", "dev": true, "dependencies": { "follow-redirects": "^1.15.6", @@ -4171,9 +4170,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -4216,8 +4215,7 @@ "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", - "dev": true + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "node_modules/dedent": { "version": "1.5.3", @@ -8234,7 +8232,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/node-xmlhttprequest/-/node-xmlhttprequest-1.0.6.tgz", "integrity": "sha512-wBcHLcDg0oIyRQNKwPzyF+W5/eqwbvPM6Tbaz9E8lTBN/7OVMGaLTWYkL69Tt8eo6JyjoPtoAaVtZYcNIfRKvw==", - "dev": true, "dependencies": { "undici": "6.6.2" } @@ -9604,7 +9601,6 @@ "version": "6.6.2", "resolved": "https://registry.npmjs.org/undici/-/undici-6.6.2.tgz", "integrity": "sha512-vSqvUE5skSxQJ5sztTZ/CdeJb1Wq0Hf44hlYMciqHghvz+K88U0l7D6u1VsndoFgskDcnU+nG3gYmMzJVzd9Qg==", - "dev": true, "dependencies": { "@fastify/busboy": "^2.0.0" }, diff --git a/package.json b/package.json index efa63665..54db03ae 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "console": "^0.7.2", "decimal.js": "^10.4.3", "google-protobuf": "^3.20.3", - "grpc-web": "^1.4.2" + "grpc-web": "^1.4.2", + "node-xmlhttprequest": "^1.0.6" }, "devDependencies": { "@babel/core": "^7.21.0", @@ -48,7 +49,6 @@ "eslint-plugin-jsx-a11y": "^6.7.1", "jest": "^29.7.0", "monero-ts": "^0.11.1", - "node-xmlhttprequest": "^1.0.6", "ts-jest": "^29.2.5", "ts-jest-resolver": "^2.0.1", "typedoc": "^0.23.26", diff --git a/src/index.ts b/src/index.ts index 0b68fe9a..49e79ffb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,19 @@ +try { + new XMLHttpRequest(); +} +catch { + const xhr = require('node-xmlhttprequest'); + + //@ts-ignore + global.ProgressEvent = xhr.ProgressEvent; + //@ts-ignore + global.XMLHttpRequestEventTarget = xhr.XMLHttpRequestEventTarget; + //@ts-ignore + global.XMLHttpRequestUpload = xhr.XMLHttpRequestUpload; + //@ts-ignore + global.XMLHttpRequest = xhr.XMLHttpRequest; +} + import HavenoClient from "./HavenoClient"; import HavenoError from "./types/HavenoError"; import HavenoUtils from "./utils/HavenoUtils";