commit
793e47de0a
4 changed files with 13 additions and 34 deletions
|
|
@ -110,19 +110,12 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
|
|
||||||
ordersProcessed.add(orderID)
|
ordersProcessed.add(orderID)
|
||||||
|
|
||||||
logger.info(
|
|
||||||
`onOrders() -> processing order: ${orderID} -- ${JSON.stringify(
|
|
||||||
order
|
|
||||||
)} -- addr: ${addr}`
|
|
||||||
)
|
|
||||||
|
|
||||||
const alreadyAnswered = await getUser()
|
const alreadyAnswered = await getUser()
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
.get(orderID)
|
.get(orderID)
|
||||||
.then()
|
.then()
|
||||||
|
|
||||||
if (alreadyAnswered) {
|
if (alreadyAnswered) {
|
||||||
logger.info('this order is already answered, quitting')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,10 +202,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
private: true
|
private: true
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
|
||||||
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
|
||||||
)
|
|
||||||
|
|
||||||
const invoice = await _addInvoice(invoiceReq)
|
const invoice = await _addInvoice(invoiceReq)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
||||||
return resolvedValue
|
return resolvedValue
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(e)
|
console.log(e)
|
||||||
logger.info(JSON.stringify(e))
|
|
||||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,9 @@ const startSocket = socket => {
|
||||||
|
|
||||||
if (isAuthenticated()) {
|
if (isAuthenticated()) {
|
||||||
socket.onAny(() => {
|
socket.onAny(() => {
|
||||||
GunActions.setLastSeenApp()
|
GunActions.setLastSeenApp().catch(e =>
|
||||||
|
console.log('error setting last seen app', e)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,9 @@ module.exports = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkHealth = async () => {
|
const checkHealth = async () => {
|
||||||
logger.info('Getting service status...')
|
|
||||||
let LNDStatus = {}
|
let LNDStatus = {}
|
||||||
try {
|
try {
|
||||||
const serviceStatus = await getAvailableService()
|
const serviceStatus = await getAvailableService()
|
||||||
logger.info('Received status:', serviceStatus)
|
|
||||||
LNDStatus = serviceStatus
|
LNDStatus = serviceStatus
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
LNDStatus = {
|
LNDStatus = {
|
||||||
|
|
@ -88,7 +86,6 @@ module.exports = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info('Getting API status...')
|
|
||||||
const APIHealth = await Http.get(
|
const APIHealth = await Http.get(
|
||||||
`${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping`
|
`${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping`
|
||||||
)
|
)
|
||||||
|
|
@ -97,7 +94,6 @@ module.exports = async (
|
||||||
responseTime: APIHealth.headers['x-response-time'],
|
responseTime: APIHealth.headers['x-response-time'],
|
||||||
success: true
|
success: true
|
||||||
}
|
}
|
||||||
logger.info('Received API status!', APIStatus)
|
|
||||||
return {
|
return {
|
||||||
LNDStatus,
|
LNDStatus,
|
||||||
APIStatus,
|
APIStatus,
|
||||||
|
|
@ -223,7 +219,6 @@ module.exports = async (
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
const legacyDeviceId = req.headers['x-shockwallet-device-id']
|
const legacyDeviceId = req.headers['x-shockwallet-device-id']
|
||||||
const deviceId = req.headers['encryption-device-id']
|
const deviceId = req.headers['encryption-device-id']
|
||||||
logger.debug('Decrypting route...')
|
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
nonEncryptedRoutes.includes(req.path) ||
|
nonEncryptedRoutes.includes(req.path) ||
|
||||||
|
|
@ -308,21 +303,12 @@ module.exports = async (
|
||||||
app.use(async (req, res, next) => {
|
app.use(async (req, res, next) => {
|
||||||
const legacyDeviceId = req.headers['x-shockwallet-device-id']
|
const legacyDeviceId = req.headers['x-shockwallet-device-id']
|
||||||
const deviceId = req.headers['encryption-device-id']
|
const deviceId = req.headers['encryption-device-id']
|
||||||
logger.info('Decrypting route...')
|
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
nonEncryptedRoutes.includes(req.path) ||
|
nonEncryptedRoutes.includes(req.path) ||
|
||||||
process.env.DISABLE_SHOCK_ENCRYPTION === 'true' ||
|
process.env.DISABLE_SHOCK_ENCRYPTION === 'true' ||
|
||||||
(legacyDeviceId && !deviceId)
|
(legacyDeviceId && !deviceId)
|
||||||
) {
|
) {
|
||||||
logger.info(
|
|
||||||
'Unprotected route detected! ' +
|
|
||||||
req.path +
|
|
||||||
' Legacy ID:' +
|
|
||||||
legacyDeviceId +
|
|
||||||
' Device ID:' +
|
|
||||||
deviceId
|
|
||||||
)
|
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,7 +357,6 @@ module.exports = async (
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use(async (req, res, next) => {
|
app.use(async (req, res, next) => {
|
||||||
logger.info(`Route: ${req.path}`)
|
|
||||||
if (unprotectedRoutes[req.method][req.path]) {
|
if (unprotectedRoutes[req.method][req.path]) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -502,7 +487,7 @@ module.exports = async (
|
||||||
*/
|
*/
|
||||||
app.get('/healthz', async (req, res) => {
|
app.get('/healthz', async (req, res) => {
|
||||||
const health = await checkHealth()
|
const health = await checkHealth()
|
||||||
logger.info('Healthz response:', health)
|
logger.info('Healthz response:', health.APIStatus.success)
|
||||||
res.json(health)
|
res.json(health)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -1112,7 +1097,6 @@ module.exports = async (
|
||||||
res.json({ errorMessage: 'LND is down' })
|
res.json({ errorMessage: 'LND is down' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info('GetInfo:', response)
|
|
||||||
if (!response.uris || response.uris.length === 0) {
|
if (!response.uris || response.uris.length === 0) {
|
||||||
if (config.lndAddress) {
|
if (config.lndAddress) {
|
||||||
response.uris = [response.identity_pubkey + '@' + config.lndAddress]
|
response.uris = [response.identity_pubkey + '@' + config.lndAddress]
|
||||||
|
|
@ -3171,6 +3155,7 @@ module.exports = async (
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
|
logger.info(`gun ONCE: ${path}`)
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
data: await handleGunFetch({
|
data: await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
|
|
@ -3186,6 +3171,7 @@ module.exports = async (
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
|
logger.info(`gun LOAD: ${path}`)
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
data: await handleGunFetch({
|
data: await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
|
|
@ -3201,6 +3187,7 @@ module.exports = async (
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
|
logger.info(`gun otheruser ONCE: ${path}`)
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
data: await handleGunFetch({
|
data: await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
|
|
@ -3216,6 +3203,7 @@ module.exports = async (
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
|
logger.info(`gun otheruser LOAD: ${path}`)
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
data: await handleGunFetch({
|
data: await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
|
|
@ -3232,7 +3220,7 @@ module.exports = async (
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||||
const { path /*:rawPath*/, publicKey, type } = req.params
|
const { path /*:rawPath*/, publicKey, type } = req.params
|
||||||
console.log(path)
|
logger.info(`gun otheruser ${type}: ${path}`)
|
||||||
// const path = decodeURI(rawPath)
|
// const path = decodeURI(rawPath)
|
||||||
if (!publicKey || publicKey === 'undefined') {
|
if (!publicKey || publicKey === 'undefined') {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
|
|
@ -3273,6 +3261,7 @@ module.exports = async (
|
||||||
try {
|
try {
|
||||||
const { lightning } = LightningServices.services
|
const { lightning } = LightningServices.services
|
||||||
const { methodName } = req.params
|
const { methodName } = req.params
|
||||||
|
logger.info(`lnd RPC: ${methodName}`)
|
||||||
const args = req.body
|
const args = req.body
|
||||||
|
|
||||||
lightning[methodName](args, (err, lres) => {
|
lightning[methodName](args, (err, lres) => {
|
||||||
|
|
@ -3302,7 +3291,7 @@ module.exports = async (
|
||||||
ap.post('/api/gun/put', async (req, res) => {
|
ap.post('/api/gun/put', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { path, value } = req.body
|
const { path, value } = req.body
|
||||||
|
logger.info(`gun PUT: ${path}`)
|
||||||
await GunWriteRPC.put(path, value)
|
await GunWriteRPC.put(path, value)
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
|
|
@ -3322,7 +3311,7 @@ module.exports = async (
|
||||||
ap.post('/api/gun/set', async (req, res) => {
|
ap.post('/api/gun/set', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { path, value } = req.body
|
const { path, value } = req.body
|
||||||
|
logger.info(`gun PUT: ${path}`)
|
||||||
const id = await GunWriteRPC.set(path, value)
|
const id = await GunWriteRPC.set(path, value)
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue