mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
fix(rate limits): Testing recursive rate limits
This commit is contained in:
Generated
+7
-7
@@ -8,7 +8,7 @@
|
|||||||
"version": "1.16.0",
|
"version": "1.16.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@psf/bch-js": "^4.15.2",
|
"@psf/bch-js": "^4.15.3",
|
||||||
"apidoc": "^0.26.0",
|
"apidoc": "^0.26.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"bitcore-lib-cash": "^8.23.1",
|
"bitcore-lib-cash": "^8.23.1",
|
||||||
@@ -458,9 +458,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@psf/bch-js": {
|
"node_modules/@psf/bch-js": {
|
||||||
"version": "4.15.2",
|
"version": "4.15.3",
|
||||||
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-4.15.2.tgz",
|
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-4.15.3.tgz",
|
||||||
"integrity": "sha512-ZJi6JdF2z/WJ02+G3Xs0V8GZUEe8HJuZqH5VEa7aq1dwZpWithq5rirZHNhWj5IfUwv3VQH6nYFObPo6Op6orA==",
|
"integrity": "sha512-J5Jk1Y7oTmTs6kCX83hxY10kp5FZd0KI4bFGiZ8qJX+V1hqFsS57+Byd4qIa/+cK+PEyTifCMnCkfKVXLS8tHw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@psf/bip21": "^2.0.1",
|
"@psf/bip21": "^2.0.1",
|
||||||
"@psf/bip32-utils": "^0.13.1",
|
"@psf/bip32-utils": "^0.13.1",
|
||||||
@@ -18627,9 +18627,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@psf/bch-js": {
|
"@psf/bch-js": {
|
||||||
"version": "4.15.2",
|
"version": "4.15.3",
|
||||||
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-4.15.2.tgz",
|
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-4.15.3.tgz",
|
||||||
"integrity": "sha512-ZJi6JdF2z/WJ02+G3Xs0V8GZUEe8HJuZqH5VEa7aq1dwZpWithq5rirZHNhWj5IfUwv3VQH6nYFObPo6Op6orA==",
|
"integrity": "sha512-J5Jk1Y7oTmTs6kCX83hxY10kp5FZd0KI4bFGiZ8qJX+V1hqFsS57+Byd4qIa/+cK+PEyTifCMnCkfKVXLS8tHw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@psf/bip21": "^2.0.1",
|
"@psf/bip21": "^2.0.1",
|
||||||
"@psf/bip32-utils": "^0.13.1",
|
"@psf/bip32-utils": "^0.13.1",
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@
|
|||||||
"node": ">=10.15.1"
|
"node": ">=10.15.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@psf/bch-js": "^4.15.2",
|
"@psf/bch-js": "^4.15.3",
|
||||||
"apidoc": "^0.26.0",
|
"apidoc": "^0.26.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"bitcore-lib-cash": "^8.23.1",
|
"bitcore-lib-cash": "^8.23.1",
|
||||||
|
|||||||
@@ -129,9 +129,17 @@ class RateLimits {
|
|||||||
const resource = _this.getResource(req.url)
|
const resource = _this.getResource(req.url)
|
||||||
wlogger.debug(`resource: ${resource}`)
|
wlogger.debug(`resource: ${resource}`)
|
||||||
|
|
||||||
|
// Key will be the JWT ID if it exists, otherwise the IP address of the caller.
|
||||||
let key = userId || req.ip
|
let key = userId || req.ip
|
||||||
res.locals.key = key // Feedback for tests.
|
res.locals.key = key // Feedback for tests.
|
||||||
|
|
||||||
|
// For internal calls that make a lot of internal calls, like
|
||||||
|
// hydrateUtxoDetails(), the origin of the caller will be passed in
|
||||||
|
// via the POST body.
|
||||||
|
if (req.body && req.body.ip) {
|
||||||
|
key = req.body.ip
|
||||||
|
}
|
||||||
|
|
||||||
// const pointsToConsume = userId ? 1 : 30
|
// const pointsToConsume = userId ? 1 : 30
|
||||||
decoded.resource = resource
|
decoded.resource = resource
|
||||||
let pointsToConsume = _this.calcPoints(decoded)
|
let pointsToConsume = _this.calcPoints(decoded)
|
||||||
@@ -147,11 +155,6 @@ class RateLimits {
|
|||||||
|
|
||||||
wlogger.info(`origin: ${origin}`)
|
wlogger.info(`origin: ${origin}`)
|
||||||
|
|
||||||
const bodyOrigin = req.body.origin
|
|
||||||
if (bodyOrigin) {
|
|
||||||
console.log(`bodyOrigin: ${bodyOrigin}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the request originates from one of the approved wallet apps, then
|
// If the request originates from one of the approved wallet apps, then
|
||||||
// apply paid-access rate limits.
|
// apply paid-access rate limits.
|
||||||
// console.log(`origin: ${JSON.stringify(origin, null, 2)}`)
|
// console.log(`origin: ${JSON.stringify(origin, null, 2)}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user