Added support for disabling encryption via .env
This commit is contained in:
parent
0afeff22b4
commit
9f131db7e3
3 changed files with 15 additions and 4 deletions
1
.env.example
Normal file
1
.env.example
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DISABLE_SHOCK_ENCRYPTION=false
|
||||||
|
|
@ -227,7 +227,7 @@ module.exports = async (
|
||||||
const deviceId = req.headers["x-shockwallet-device-id"];
|
const deviceId = req.headers["x-shockwallet-device-id"];
|
||||||
logger.debug("Decrypting route...")
|
logger.debug("Decrypting route...")
|
||||||
try {
|
try {
|
||||||
if (nonEncryptedRoutes.includes(req.path)) {
|
if (nonEncryptedRoutes.includes(req.path) || process.env.DISABLE_SHOCK_ENCRYPTION) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1617,6 +1617,7 @@ module.exports = async (
|
||||||
|
|
||||||
const GunEvent = Common.Constants.Event
|
const GunEvent = Common.Constants.Event
|
||||||
const Key = require('../services/gunDB/contact-api/key')
|
const Key = require('../services/gunDB/contact-api/key')
|
||||||
|
const { timeout5 } = require('../services/gunDB/contact-api/utils')
|
||||||
app.get("/api/gun/lndchanbackups", async (req,res) => {
|
app.get("/api/gun/lndchanbackups", async (req,res) => {
|
||||||
try{
|
try{
|
||||||
const user = require('../services/gunDB/Mediator').getUser()
|
const user = require('../services/gunDB/Mediator').getUser()
|
||||||
|
|
@ -1634,8 +1635,6 @@ module.exports = async (
|
||||||
|
|
||||||
const Events = require('../services/gunDB/contact-api/events')
|
const Events = require('../services/gunDB/contact-api/events')
|
||||||
|
|
||||||
const {timeout5} = require('../services/gunDB/contact-api/utils')
|
|
||||||
|
|
||||||
app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => {
|
app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => {
|
||||||
try {
|
try {
|
||||||
// spinup
|
// spinup
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ const server = program => {
|
||||||
const Http = require('http')
|
const Http = require('http')
|
||||||
const Express = require('express')
|
const Express = require('express')
|
||||||
const Crypto = require('crypto')
|
const Crypto = require('crypto')
|
||||||
|
const Dotenv = require('dotenv')
|
||||||
const LightningServices = require('../utils/lightningServices')
|
const LightningServices = require('../utils/lightningServices')
|
||||||
const Encryption = require('../utils/encryptionStore')
|
const Encryption = require('../utils/encryptionStore')
|
||||||
const app = Express()
|
const app = Express()
|
||||||
|
|
@ -25,6 +26,7 @@ const server = program => {
|
||||||
// load app default configuration data
|
// load app default configuration data
|
||||||
const defaults = require('../config/defaults')(program.mainnet)
|
const defaults = require('../config/defaults')(program.mainnet)
|
||||||
// define useful global variables ======================================
|
// define useful global variables ======================================
|
||||||
|
Dotenv.config()
|
||||||
module.useTLS = program.usetls
|
module.useTLS = program.usetls
|
||||||
module.serverPort = program.serverport || defaults.serverPort
|
module.serverPort = program.serverport || defaults.serverPort
|
||||||
module.httpsPort = module.serverPort
|
module.httpsPort = module.serverPort
|
||||||
|
|
@ -41,6 +43,12 @@ const server = program => {
|
||||||
|
|
||||||
logger.info('Mainnet Mode:', !!program.mainnet)
|
logger.info('Mainnet Mode:', !!program.mainnet)
|
||||||
|
|
||||||
|
if (process.env.DISABLE_SHOCK_ENCRYPTION) {
|
||||||
|
logger.error('Encryption Mode: false')
|
||||||
|
} else {
|
||||||
|
logger.info('Encryption Mode: true')
|
||||||
|
}
|
||||||
|
|
||||||
const stringifyData = data => {
|
const stringifyData = data => {
|
||||||
if (typeof data === 'object') {
|
if (typeof data === 'object') {
|
||||||
const stringifiedData = JSON.stringify(data)
|
const stringifiedData = JSON.stringify(data)
|
||||||
|
|
@ -64,7 +72,10 @@ const server = program => {
|
||||||
const deviceId = req.headers['x-shockwallet-device-id']
|
const deviceId = req.headers['x-shockwallet-device-id']
|
||||||
const oldSend = res.send
|
const oldSend = res.send
|
||||||
|
|
||||||
if (!nonEncryptedRoutes.includes(req.path)) {
|
if (
|
||||||
|
!nonEncryptedRoutes.includes(req.path) &&
|
||||||
|
!process.env.DISABLE_SHOCK_ENCRYPTION
|
||||||
|
) {
|
||||||
res.send = (...args) => {
|
res.send = (...args) => {
|
||||||
if (args[0] && args[0].encryptedData && args[0].encryptionKey) {
|
if (args[0] && args[0].encryptedData && args[0].encryptionKey) {
|
||||||
logger.warn('Response loop detected!')
|
logger.warn('Response loop detected!')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue