Compare commits

...
19 Commits
Author SHA1 Message Date
Chris Troutner 1b1bf36a89 Merge pull request #163 from Permissionless-Software-Foundation/ct-unstable
fix(Docker): Fixing broken Docker file
2021-10-03 05:38:28 -07:00
Chris Troutner 8de5399818 fix(Docker): Fixing broken Docker file 2021-10-03 05:37:16 -07:00
Chris Troutner 4f4984a982 Merge pull request #162 from Permissionless-Software-Foundation/ct-unstable
feat(getBlockHash): Reimplementing lost getBlockHash method in Blockc…
2021-09-21 07:41:44 -07:00
Chris Troutner d9fc84f136 feat(getBlockHash): Reimplementing lost getBlockHash method in Blockchain lib 2021-09-21 07:39:18 -07:00
Chris Troutner d444666dec Merge pull request #160 from Permissionless-Software-Foundation/ct-unstable
fix(tests): Fixing broken JWT token test
2021-08-16 08:30:31 -07:00
Chris Troutner c8f3649004 fix(tests): Fixing broken JWT token test 2021-08-16 08:26:39 -07:00
Chris Troutner ee876ce8e4 Merge pull request #159 from Permissionless-Software-Foundation/ct-unstable
fix(bch-js): Bumping to v4.20.7
2021-08-09 10:47:44 -07:00
Chris Troutner fbd02802f0 Merge branch 'master' into ct-unstable 2021-08-09 10:45:32 -07:00
Chris Troutner 6e72879103 fix(bch-js): Bumping to v4.20.7 2021-08-09 10:44:43 -07:00
Chris Troutner 2817300ad6 Merge pull request #158 from Permissionless-Software-Foundation/ct-unstable
fix(debug): Removing debugging statements
2021-08-07 12:45:43 -07:00
Chris Troutner 4aa7cad552 fix(debug): Removing debugging statements 2021-08-07 12:44:14 -07:00
Chris Troutner 5a9401aeb1 Merge pull request #157 from Permissionless-Software-Foundation/ct-unstable
fix(jwt): Getting closer to root cause
2021-08-07 12:23:27 -07:00
Chris Troutner 0ae02790a2 fix(jwt): Getting closer to root cause 2021-08-07 12:21:25 -07:00
Chris Troutner 4d3adab9e0 Merge pull request #156 from Permissionless-Software-Foundation/ct-unstable
fix(jwt): A little more jwt debugging
2021-08-07 12:16:21 -07:00
Chris Troutner 91f06b6311 Merge branch 'master' into ct-unstable 2021-08-07 12:14:23 -07:00
Chris Troutner 2fc175d818 fix(jwt): A little more jwt debugging 2021-08-07 12:14:09 -07:00
Chris Troutner 731861cb1d Merge pull request #155 from Permissionless-Software-Foundation/ct-unstable
fix(rate limits): Digging deeper into rate limit debugging
2021-08-07 11:55:28 -07:00
Chris Troutner 9a01f5ffe6 Merge branch 'master' into ct-unstable 2021-08-07 11:45:53 -07:00
Chris Troutner c62c515474 fix(rate limits): Digging deeper into rate limit debugging 2021-08-07 11:45:42 -07:00
8 changed files with 16168 additions and 635 deletions
+35 -6
View File
@@ -1,19 +1,48 @@
FROM christroutner/ct-base-ubuntu
FROM ubuntu:20.04
MAINTAINER Chris Troutner <chris.troutner@gmail.com>
RUN apt-get update -y
#Update the OS and install any OS packages needed.
RUN apt-get update
RUN apt-get install -y sudo git curl nano gnupg wget
#Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs build-essential
#Create the user 'safeuser' and add them to the sudo group.
RUN useradd -ms /bin/bash safeuser
RUN adduser safeuser sudo
#Set password to 'abcd8765' change value below if you want a different password
RUN echo safeuser:abcd8765 | chpasswd
#Set the working directory to be the users home directory
WORKDIR /home/safeuser
#Setup NPM for non-root global install (like on a mac)
RUN mkdir /home/safeuser/.npm-global
RUN chown -R safeuser .npm-global
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
# Update to the latest version of npm.
# Working with npm@7.21.1
RUN npm install -g npm
#FROM christroutner/ct-base-ubuntu
#MAINTAINER Chris Troutner <chris.troutner@gmail.com>
#RUN apt-get update -y
#Set the working directory to be the home directory
WORKDIR /home/safeuser
#WORKDIR /home/safeuser
# Switch to user account.
USER safeuser
# Prep 'sudo' commands.
#RUN echo 'abcd8765' | sudo -S pwd
# Install Redis. TODO: Make this a separate container.
# Clone the repository
WORKDIR /home/safeuser
RUN git clone https://github.com/Permissionless-Software-Foundation/bch-api
+15724 -273
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -31,7 +31,7 @@
"node": ">=10.15.1"
},
"dependencies": {
"@psf/bch-js": "^4.18.0",
"@psf/bch-js": "^4.20.7",
"apidoc": "^0.26.0",
"axios": "^0.21.1",
"bitcore-lib-cash": "^8.23.1",
+2
View File
@@ -12,6 +12,8 @@
// req.locals.jwtToken property.
const getTokenFromHeaders = (req, res, next) => {
try {
// console.log('req.headers: ', req.headers)
// Only executes if the authorization header exists.
if (req.headers.authorization) {
// Retrieve the auth string from the header object.
+6 -4
View File
@@ -221,7 +221,9 @@ class RateLimits {
// should be returned by the middleware.
async trackRateLimits (req, res, jwtToken) {
const debugInfo = {
jwtToken
jwtToken,
userObj: req.body.usrObj,
locals: req.locals
}
// Anonymous rate limits are used by default.
@@ -268,9 +270,9 @@ class RateLimits {
res.locals.rateLimitTriggered = true
// console.log('res.locals: ', res.locals)
console.log(
`rate limit debug info: ${JSON.stringify(debugInfo, null, 2)}`
)
// console.log(
// `rate limit debug info: ${JSON.stringify(debugInfo, null, 2)}`
// )
// Rate limited was triggered
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
File diff suppressed because it is too large Load Diff
+5
View File
@@ -175,6 +175,11 @@ class RouteUtils {
msg: '429 Too Many Requests',
status: 429
}
} else if (err.error.includes('Network error:')) {
return {
msg: err.error,
status: 503
}
}
}
+12 -10
View File
@@ -73,16 +73,18 @@ describe('#JWTRouter', () => {
const result = await uut.jwtInfo(req, res)
// console.log('result: ', result)
assert.property(result, 'id')
assert.property(result, 'email')
assert.property(result, 'apiLevel')
assert.property(result, 'rateLimit')
assert.property(result, 'pointsToConsume')
assert.property(result, 'duration')
assert.property(result, 'iat')
assert.property(result, 'exp')
assert.property(result, 'expiration')
assert.property(result, 'createdAt')
assert.equal(result.error, 'jwt expired')
// assert.property(result, 'id')
// assert.property(result, 'email')
// assert.property(result, 'apiLevel')
// assert.property(result, 'rateLimit')
// assert.property(result, 'pointsToConsume')
// assert.property(result, 'duration')
// assert.property(result, 'iat')
// assert.property(result, 'exp')
// assert.property(result, 'expiration')
// assert.property(result, 'createdAt')
})
it('should return an error with malformed JWT token', async () => {