commit
f7dc0bd1df
4 changed files with 43 additions and 3 deletions
|
|
@ -1043,5 +1043,6 @@ module.exports = {
|
||||||
register,
|
register,
|
||||||
instantiateGun,
|
instantiateGun,
|
||||||
getGun,
|
getGun,
|
||||||
getUser
|
getUser,
|
||||||
|
mySEA
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1022,6 +1022,35 @@ const setBio = (bio, user) =>
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string[]} mnemonicPhrase
|
||||||
|
* @param {UserGUNNode} user
|
||||||
|
* @param {ISEA} SEA
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
const saveSeedBackup = async (mnemonicPhrase, user, SEA) => {
|
||||||
|
if (
|
||||||
|
!Array.isArray(mnemonicPhrase) ||
|
||||||
|
mnemonicPhrase.some(word => typeof word !== 'string') ||
|
||||||
|
mnemonicPhrase.length === 0
|
||||||
|
) {
|
||||||
|
throw new TypeError('expected mnemonicPhrase to be an string array')
|
||||||
|
}
|
||||||
|
|
||||||
|
const mySecret = await SEA.secret(user._.sea.epub, user._.sea)
|
||||||
|
const encryptedSeed = await SEA.encrypt(mnemonicPhrase.join(' '), mySecret)
|
||||||
|
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
user.get(Key.SEED_BACKUP).put(encryptedSeed, ack => {
|
||||||
|
if (ack.err) {
|
||||||
|
rej(ack.err)
|
||||||
|
} else {
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
INITIAL_MSG,
|
INITIAL_MSG,
|
||||||
__createOutgoingFeed,
|
__createOutgoingFeed,
|
||||||
|
|
@ -1037,5 +1066,6 @@ module.exports = {
|
||||||
setDisplayName,
|
setDisplayName,
|
||||||
sendPayment,
|
sendPayment,
|
||||||
generateOrderAddress,
|
generateOrderAddress,
|
||||||
setBio
|
setBio,
|
||||||
|
saveSeedBackup
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,5 @@ exports.ORDER_NODES = 'orderNodes'
|
||||||
exports.ORDER_TO_RESPONSE = 'orderToResponse'
|
exports.ORDER_TO_RESPONSE = 'orderToResponse'
|
||||||
|
|
||||||
exports.BIO = 'bio'
|
exports.BIO = 'bio'
|
||||||
|
|
||||||
|
exports.SEED_BACKUP = 'seedBackup'
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const auth = require("../services/auth/auth");
|
||||||
const FS = require("../utils/fs");
|
const FS = require("../utils/fs");
|
||||||
const LightningServices = require("../utils/lightningServices");
|
const LightningServices = require("../utils/lightningServices");
|
||||||
const GunDB = require("../services/gunDB/Mediator");
|
const GunDB = require("../services/gunDB/Mediator");
|
||||||
|
const GunActions = require("../services/gunDB/contact-api/actions")
|
||||||
const { unprotectedRoutes } = require("../utils/protectedRoutes");
|
const { unprotectedRoutes } = require("../utils/protectedRoutes");
|
||||||
|
|
||||||
const DEFAULT_MAX_NUM_ROUTES_TO_QUERY = 10;
|
const DEFAULT_MAX_NUM_ROUTES_TO_QUERY = 10;
|
||||||
|
|
@ -441,6 +442,12 @@ module.exports = (
|
||||||
// Register user before creating wallet
|
// Register user before creating wallet
|
||||||
const publicKey = await GunDB.register(alias, password);
|
const publicKey = await GunDB.register(alias, password);
|
||||||
|
|
||||||
|
await GunActions.saveSeedBackup(
|
||||||
|
mnemonicPhrase,
|
||||||
|
GunDB.getUser(),
|
||||||
|
GunDB.mySEA
|
||||||
|
)
|
||||||
|
|
||||||
walletUnlocker.initWallet(
|
walletUnlocker.initWallet(
|
||||||
walletArgs,
|
walletArgs,
|
||||||
async (initWalletErr, initWalletResponse) => {
|
async (initWalletErr, initWalletResponse) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue