mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 01:02:05 -07:00
Compare commits
17
Commits
joey
...
basic-auth-only
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb0fba6924 | ||
|
|
ed6c612be9 | ||
|
|
9969ccafac | ||
|
|
5f1e7d88bb | ||
|
|
1a115a0012 | ||
|
|
442b802b79 | ||
|
|
9e895bb0bd | ||
|
|
0a0644d05c | ||
|
|
1a57177e4a | ||
|
|
039348aa24 | ||
|
|
2c147d518e | ||
|
|
fb78033a67 | ||
|
|
33d1c74143 | ||
|
|
7b927da53b | ||
|
|
74c8ceb962 | ||
|
|
83a5db5ac7 | ||
|
|
a1366bf46f |
@@ -18,6 +18,7 @@ USER safeuser
|
||||
WORKDIR /home/safeuser
|
||||
RUN git clone https://github.com/Permissionless-Software-Foundation/bch-api
|
||||
WORKDIR /home/safeuser/bch-api
|
||||
RUN git checkout basic-auth-only
|
||||
RUN npm install --silent
|
||||
|
||||
# Generate documentation
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
The rate limits below were originially coded with the idea of charging on a
|
||||
per-resource basis. However, that was confusing to end users trying to purchase
|
||||
a subscription. So everything was simplied to two tiers: paid and anonymous
|
||||
|
||||
CT 3/4/21: I increased the total points from 1,000 to 100,000 to prevent systems
|
||||
with Basic Authentication from hitting internal rate limits when calling
|
||||
hydrateUtxos().
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
@@ -19,7 +23,9 @@ const jwt = require('jsonwebtoken')
|
||||
const wlogger = require('../util/winston-logging')
|
||||
const config = require('../../config')
|
||||
|
||||
const ANON_LIMITS = config.anonRateLimit
|
||||
// Hard coding limits since basic-authentiation is assumed to be the primary access.
|
||||
const ANON_LIMITS = 333
|
||||
|
||||
const WHITELIST_RATE_LIMIT = config.whitelistRateLimit
|
||||
const WHITELIST_DOMAINS = config.whitelistDomains
|
||||
const INTERNAL_RATE_LIMIT = 1
|
||||
@@ -142,7 +148,7 @@ class RateLimits {
|
||||
let rateLimit = ANON_LIMITS
|
||||
|
||||
// Only evaluate the JWT token if the user is not using Basic Authentication.
|
||||
if (!req.locals.proLimit) {
|
||||
if (!req.locals.proLimit && !req.body.usrObj.proLimit) {
|
||||
// Code here for the rate limiter is adapted from this example:
|
||||
// https://github.com/animir/node-rate-limiter-flexible/wiki/Overall-example#authorized-and-not-authorized-users
|
||||
try {
|
||||
@@ -195,7 +201,7 @@ class RateLimits {
|
||||
`User ${key} consuming ${pointsToConsume} point for resource ${resource}.`
|
||||
)
|
||||
|
||||
rateLimit = Math.floor(1000 / pointsToConsume)
|
||||
rateLimit = Math.floor(100000 / pointsToConsume)
|
||||
|
||||
// Update the key so that rate limits track both the user and the resource.
|
||||
key = `${key}-${resource}`
|
||||
|
||||
+14
-5
@@ -36,9 +36,13 @@ util.inspect.defaultOptions = { depth: 5 }
|
||||
// Determine the Access password for a private instance of SLPDB.
|
||||
// https://gist.github.com/christroutner/fc717ca704dec3dded8b52fae387eab2
|
||||
// Password for General Purpose (GP) SLPDB.
|
||||
const SLPDB_PASS_GP = process.env.SLPDB_PASS_GP ? process.env.SLPDB_PASS_GP : 'BITBOX'
|
||||
const SLPDB_PASS_GP = process.env.SLPDB_PASS_GP
|
||||
? process.env.SLPDB_PASS_GP
|
||||
: 'BITBOX'
|
||||
// Password for Whitelist (WL) SLPDB.
|
||||
const SLPDB_PASS_WL = process.env.SLPDB_PASS_WL ? process.env.SLPDB_PASS_WL : 'BITBOX'
|
||||
const SLPDB_PASS_WL = process.env.SLPDB_PASS_WL
|
||||
? process.env.SLPDB_PASS_WL
|
||||
: 'BITBOX'
|
||||
|
||||
// const rawtransactions = require('./full-node/rawtransactions')
|
||||
const RawTransactions = require('./full-node/rawtransactions')
|
||||
@@ -46,7 +50,7 @@ const rawTransactions = new RawTransactions()
|
||||
|
||||
// Setup REST and TREST URLs used by slpjs
|
||||
// Dev note: this allows for unit tests to mock the URL.
|
||||
if (!process.env.REST_URL) process.env.REST_URL = 'https://bchn.fullstack.cash/v4/'
|
||||
if (!process.env.REST_URL) { process.env.REST_URL = 'https://bchn.fullstack.cash/v4/' }
|
||||
if (!process.env.TREST_URL) {
|
||||
process.env.TREST_URL = 'https://testnet.fullstack.cash/v4/'
|
||||
}
|
||||
@@ -1213,10 +1217,13 @@ class Slp {
|
||||
msg: ''
|
||||
}
|
||||
|
||||
const path = `${process.env.SLP_API_URL}slp/validate/${txid}`
|
||||
// console.log(`validate2Single path: ${path}`)
|
||||
|
||||
// Request options
|
||||
const opt = {
|
||||
method: 'get',
|
||||
baseURL: `${process.env.SLP_API_URL}slp/validate/${txid}`,
|
||||
baseURL: path,
|
||||
timeout: 10000 // Exit after 10 seconds.
|
||||
}
|
||||
const tokenRes = await _this.axios.request(opt)
|
||||
@@ -2117,7 +2124,9 @@ class Slp {
|
||||
// console.log(`theseUtxos: ${JSON.stringify(theseUtxos, null, 2)}`)
|
||||
|
||||
// Get SLP token details.
|
||||
const details = await _this.bchjs.SLP.Utils.tokenUtxoDetailsWL(theseUtxos)
|
||||
const details = await _this.bchjs.SLP.Utils.tokenUtxoDetailsWL(
|
||||
theseUtxos
|
||||
)
|
||||
// console.log('details : ', details)
|
||||
|
||||
// Replace the original UTXO data with the hydrated data.
|
||||
|
||||
Reference in New Issue
Block a user