decrypt
This commit is contained in:
parent
8a0381fdec
commit
c95145e9b8
4 changed files with 110 additions and 2 deletions
|
|
@ -1 +1,41 @@
|
||||||
{}
|
{
|
||||||
|
"1588267168029": "bf17bcd0-8b06-11ea-a55c-65bfc1984f1d",
|
||||||
|
"1588681379439": "28550ff0-8ecb-11ea-969f-4d62aac95774",
|
||||||
|
"1588682332759": "608e2670-8ecd-11ea-87b2-457142fbfd14",
|
||||||
|
"1588686578449": "432f0810-8ed7-11ea-87b2-457142fbfd14",
|
||||||
|
"1588691210156": "0be56ec0-8ee2-11ea-b451-db8db0aa9304",
|
||||||
|
"1588692739649": "9b8b8b10-8ee5-11ea-af63-3f8455295a72",
|
||||||
|
"1588693351356": "08269fc0-8ee7-11ea-af63-3f8455295a72",
|
||||||
|
"1588693672181": "c760a250-8ee7-11ea-af63-3f8455295a72",
|
||||||
|
"1588695594069": "40e97850-8eec-11ea-82ac-eb4bdbeb5b08",
|
||||||
|
"1588777414456": "c1a9bb80-8faa-11ea-a21c-27181e309ce9",
|
||||||
|
"1588875978019": "3e1fe730-9090-11ea-be9a-fd598d9fe42e",
|
||||||
|
"1588876229603": "d4149330-9090-11ea-be9a-fd598d9fe42e",
|
||||||
|
"1588956209331": "0bb69030-914b-11ea-9915-7d8575c7d7d6",
|
||||||
|
"1588956430736": "8fae4900-914b-11ea-b7dd-7739c97d07d1",
|
||||||
|
"1588956514153": "c166b590-914b-11ea-be20-ff6376c94523",
|
||||||
|
"1588956572038": "e3e74260-914b-11ea-a907-8dc48c5f73ca",
|
||||||
|
"1588956871271": "96429770-914c-11ea-9f2a-27f17d10eb3f",
|
||||||
|
"1588956997132": "e1479bd0-914c-11ea-9191-5921516e0069",
|
||||||
|
"1588957154759": "3f3b6d70-914d-11ea-98a6-b9e95e29d726",
|
||||||
|
"1588957207891": "5ee6ba30-914d-11ea-b774-a15d7db527e0",
|
||||||
|
"1588957287159": "8e261070-914d-11ea-84a8-dd1dd8903c92",
|
||||||
|
"1588958573336": "8cc51980-9150-11ea-bee2-ff3e4f6f98a2",
|
||||||
|
"1588958723075": "e6057530-9150-11ea-8f5c-dd32e08c17a8",
|
||||||
|
"1588958765514": "ff5122a0-9150-11ea-a1a3-1318b2bd7648",
|
||||||
|
"1588958867628": "3c2e7ec0-9151-11ea-885a-8b3a1f547acd",
|
||||||
|
"1588959061866": "aff4dca0-9151-11ea-b7cc-017e49154646",
|
||||||
|
"1588959145874": "e2077720-9151-11ea-aa00-b32b012e406e",
|
||||||
|
"1588959220436": "0e78b940-9152-11ea-945d-9f0aad8d126b",
|
||||||
|
"1588959767721": "54adc990-9153-11ea-b1a0-e9a76e1a2c63",
|
||||||
|
"1588960727745": "90e5d310-9155-11ea-8b3d-eb85067d3373",
|
||||||
|
"1588960835074": "d0deee20-9155-11ea-953b-395239254c4f",
|
||||||
|
"1588960928537": "08944090-9156-11ea-8534-41793f2f68f2",
|
||||||
|
"1588960981939": "2868c030-9156-11ea-9f8f-651b1c9f056d",
|
||||||
|
"1588961072527": "5e6761f0-9156-11ea-875a-6745b5e14aa2",
|
||||||
|
"1588961123832": "7cfbe780-9156-11ea-928b-19f67f61ba9d",
|
||||||
|
"1588961161326": "935508e0-9156-11ea-bbdf-5561c24d1e18",
|
||||||
|
"1588961273668": "d64b1040-9156-11ea-a585-6172ab2a214f",
|
||||||
|
"1588962216857": "087a4890-9159-11ea-9d0a-29444d4244a2",
|
||||||
|
"1588962992470": "d6c76f60-915a-11ea-be93-d165f70259a3"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1164,6 +1164,29 @@ const saveSeedBackup = async (mnemonicPhrase, user, SEA) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} backups
|
||||||
|
* @param {UserGUNNode} user
|
||||||
|
* @param {ISEA} SEA
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
const saveChannelsBackup = async (backups,user,SEA) => {
|
||||||
|
if (backups == '') {
|
||||||
|
throw new TypeError('cant save an empty channel backup')
|
||||||
|
}
|
||||||
|
const mySecret = require('../Mediator').getMySecret()
|
||||||
|
const encryptBackups = await SEA.encrypt(backups,mySecret)
|
||||||
|
return new Promise((res,rej) => {
|
||||||
|
user.get(Key.CHANNELS_BACKUP).put(encryptBackups,ack => {
|
||||||
|
if(ack.err) {
|
||||||
|
rej(ack.err)
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} pub
|
* @param {string} pub
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
|
|
@ -1211,6 +1234,7 @@ module.exports = {
|
||||||
generateOrderAddress,
|
generateOrderAddress,
|
||||||
setBio,
|
setBio,
|
||||||
saveSeedBackup,
|
saveSeedBackup,
|
||||||
|
saveChannelsBackup,
|
||||||
disconnect,
|
disconnect,
|
||||||
setLastSeenApp
|
setLastSeenApp
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ exports.BIO = 'bio'
|
||||||
|
|
||||||
exports.SEED_BACKUP = 'seedBackup'
|
exports.SEED_BACKUP = 'seedBackup'
|
||||||
|
|
||||||
|
exports.CHANNELS_BACKUP = 'channelsBackup'
|
||||||
|
|
||||||
exports.LAST_SEEN_APP = 'lastSeenApp'
|
exports.LAST_SEEN_APP = 'lastSeenApp'
|
||||||
|
|
||||||
exports.LAST_SEEN_NODE = 'lastSeenNode'
|
exports.LAST_SEEN_NODE = 'lastSeenNode'
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,33 @@ module.exports = async (
|
||||||
// Send an event to update lightning's status
|
// Send an event to update lightning's status
|
||||||
mySocketsEvents.emit("updateLightning");
|
mySocketsEvents.emit("updateLightning");
|
||||||
|
|
||||||
|
//register to listen for channel backups
|
||||||
|
const user = require('../services/gunDB/Mediator').getUser()
|
||||||
|
const SEA = require('../services/gunDB/Mediator').mySEA
|
||||||
|
const onNewChannelBackup = () => {
|
||||||
|
const { lightning } = LightningServices.services;
|
||||||
|
logger.warn("Subscribing to channel backup ...")
|
||||||
|
const stream = lightning.SubscribeChannelBackups({})
|
||||||
|
stream.on("data", data => {
|
||||||
|
logger.info(" New channel backup data")
|
||||||
|
GunActions.saveChannelsBackup(JSON.stringify(data),user,SEA)
|
||||||
|
})
|
||||||
|
stream.on("end", ()=>{
|
||||||
|
logger.info("Channel backup stream ended, starting a new one...")
|
||||||
|
onNewChannelBackup()
|
||||||
|
})
|
||||||
|
stream.on("error", err => {
|
||||||
|
logger.error("Channel backup stream error:", err);
|
||||||
|
})
|
||||||
|
stream.on("status", status => {
|
||||||
|
logger.error("Channel backup stream status:", status);
|
||||||
|
if (status.code === 14) {
|
||||||
|
onNewChannelBackup();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onNewChannelBackup();
|
||||||
|
|
||||||
// Generate auth token and send it as a JSON response
|
// Generate auth token and send it as a JSON response
|
||||||
const token = await auth.generateToken();
|
const token = await auth.generateToken();
|
||||||
res.json({
|
res.json({
|
||||||
|
|
@ -1580,8 +1607,23 @@ module.exports = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
const GunEvent = Common.Constants.Event
|
const GunEvent = Common.Constants.Event
|
||||||
const Events = require('../services/gunDB/contact-api/events')
|
|
||||||
const Key = require('../services/gunDB/contact-api/key')
|
const Key = require('../services/gunDB/contact-api/key')
|
||||||
|
app.get("/api/gun/lndchanbackups", async (req,res) => {
|
||||||
|
try{
|
||||||
|
const user = require('../services/gunDB/Mediator').getUser()
|
||||||
|
|
||||||
|
const SEA = require('../services/gunDB/Mediator').mySEA
|
||||||
|
const mySecret = require('../services/gunDB/Mediator').getMySecret()
|
||||||
|
const encBackup = await user.get(Key.CHANNELS_BACKUP).then()
|
||||||
|
const backup = await SEA.decrypt(encBackup,mySecret)
|
||||||
|
res.json({data:backup})
|
||||||
|
} catch (err) {
|
||||||
|
res.json({ok:"err"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const Events = require('../services/gunDB/contact-api/events')
|
||||||
|
|
||||||
const {timeout5} = require('../services/gunDB/contact-api/utils')
|
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) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue