cleanup
This commit is contained in:
@@ -185,41 +185,42 @@ Nations.synchronize = () => {
|
||||
|
||||
Nations.create = (conf) => {
|
||||
/*
|
||||
@conf from a nationchains/socialworld/setup/townSetup {object, nationName, townName, dns}
|
||||
@conf from a nationchains/socialworld/setup/townSetup {object, nationId, townId, dns}
|
||||
@return
|
||||
*/
|
||||
const res = {};
|
||||
if (conf.object=="towns"){
|
||||
Odmdb.create("nationchains/socialworld/objects","towns",conf);
|
||||
}
|
||||
const nation_town = fs.readJsonSync(
|
||||
"./nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json"
|
||||
const nations = fs.readJsonSync(
|
||||
"./nationchains/nations/idx/nationId_all.json"
|
||||
);
|
||||
if (!ObjectKeys(nation_town).includes(conf.nationName)) {
|
||||
if (!ObjectKeys(nations).includes(conf.nationId)) {
|
||||
res.status = 404;
|
||||
res.info = `your nationName ${conf.nationName} does not exist you have to choose an existing one`;
|
||||
res.info = `your nationId ${conf.nationId} does not exist you have to choose an existing one`;
|
||||
return res;
|
||||
}
|
||||
if (nation_town[conf.nationName].includes(conf.townName)) {
|
||||
const towns = fs.readJsonSync( "./nationchains/towns/idx/townId_all.json")
|
||||
if (towns[conf.nationId].includes(conf.townId)) {
|
||||
res.status = 409;
|
||||
res.info = `This conf.townName already exist you have to find a unique town name per nation`;
|
||||
res.info = `This conf.townId already exist you have to find a unique town name`;
|
||||
return res;
|
||||
}
|
||||
const towndata = {
|
||||
uuid: conf.townName,
|
||||
nationid: conf.nationName,
|
||||
url: `${conf.townName}.${conf.nationName}.${conf.dns}`,
|
||||
uuid: conf.townId,
|
||||
nationid: conf.nationId,
|
||||
url: `${conf.townId}.${conf.nationId}.${conf.dns}`,
|
||||
status: (conf.dns=="unchain")? "unchain" : "tochain",
|
||||
};
|
||||
const metatown=fs.readJsonSync('./nationchains/socialworld/metaobject/towns.json');
|
||||
Odmdb.add(objectpath, towns, metatown,towndata)
|
||||
|
||||
fs.outputJsonSync(
|
||||
`./nationchains/socialworld/objects/towns/${townName}.json`,
|
||||
`./nationchains/socialworld/objects/towns/${townId}.json`,
|
||||
towndata
|
||||
);
|
||||
res.status=200
|
||||
res.info=`${townName} create for ${nationName} nation`;
|
||||
res.info=`${townId} create for ${nationId} nation`;
|
||||
return res
|
||||
};
|
||||
|
||||
|
@@ -36,35 +36,12 @@ Pagans.createId = async (alias,passphrase) =>{
|
||||
passphrase: passphrase, // protects the private key
|
||||
format: "armored", // output key format, defaults to 'armored' (other options: 'binary' or 'object')
|
||||
});
|
||||
console.log(privateKey)
|
||||
console.log(publicKey)
|
||||
apxpagans[alias]={alias,publicKey};
|
||||
|
||||
fs.outputJsonSync(`${conf.dirname}/nationchains/pagans/idx/alias_all.json`,apxpagans);
|
||||
fs.outputJsonSync(`${conf.dirname}/nationchains/pagans/itm/${alias}.json`,{alias,publicKey});
|
||||
return {status:200, data:{alias,privateKey,publicKey}}
|
||||
}
|
||||
|
||||
Pagans.generateKey = async (alias, passphrase) => {
|
||||
/**
|
||||
* @param {string} alias a unique alias that identify an identity
|
||||
* @param {string} passphrase a string to cipher the publicKey (can be empty, less secure but simpler)
|
||||
* @return {publicKey,privateKey} with userIds = [{alias}]
|
||||
*/
|
||||
const { privateKey, publicKey } = await openpgp.generateKey({
|
||||
type: "ecc", // Type of the key, defaults to ECC
|
||||
curve: "curve25519", // ECC curve name, defaults to curve25519
|
||||
userIDs: [{ alias: alias }], // you can pass multiple user IDs
|
||||
passphrase: passphrase, // protects the private key
|
||||
format: "armored", // output key format, defaults to 'armored' (other options: 'binary' or 'object')
|
||||
});
|
||||
// key start by '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
||||
// get liste of alias:pubklickey await axios.get('api/v0/pagans')
|
||||
// check alias does not exist
|
||||
console.log(privateKey)
|
||||
return { alias, privateKey, publicKey };
|
||||
|
||||
};
|
||||
//console.log( Pagans.generateKey('toto',''))
|
||||
Pagans.detachedSignature = async (pubK, privK, passphrase, message) => {
|
||||
/**
|
||||
@@ -104,7 +81,7 @@ Pagans.generateKey = async (alias, passphrase) => {
|
||||
const verificationResult = await openpgp.verify({
|
||||
msg, // Message object
|
||||
signature,
|
||||
verificationKeys: publicKey,
|
||||
verificationKeys: publicKey
|
||||
});
|
||||
const { verified, keyID } = verificationResult.signatures[0];
|
||||
try {
|
||||
|
@@ -44,6 +44,7 @@ Setup.init = async () => {
|
||||
`./nationchains/nations/idx/nationId_all.json`
|
||||
);
|
||||
const apxtowns = fs.readJsonSync(`./nationchains/towns/idx/townId_all.json`);
|
||||
|
||||
let apxpagans={}
|
||||
if (fs.existsSync(`./nationchains/pagans/idx/alias_all.json`)){
|
||||
apxpagans = fs.readJsonSync(
|
||||
@@ -73,9 +74,13 @@ Setup.init = async () => {
|
||||
*/
|
||||
townconf.sudoerUser = process.env.USER;
|
||||
townconf.dirname = path.resolve(`${__dirname}/../../`);
|
||||
// nginx allow to set a new website space
|
||||
// To allow to serve the nation website until the end
|
||||
townconf.nginx.include.push(
|
||||
`${townconf.dirname}/nationchains/**/nginx_*.conf`
|
||||
`${townconf.dirname}/nationchains/www/nginx_*.conf`
|
||||
);
|
||||
// To allow to serve tribes web site
|
||||
townconf.nginx.include.push(
|
||||
`${townconf.dirname}/nationchains/tribes/*/www/nginx_*.conf`
|
||||
);
|
||||
townconf.nginx.logs = `${townconf.dirname}/nationchains/logs/nginx`;
|
||||
townconf.nginx.website = "adminapx";
|
||||
@@ -144,7 +149,7 @@ Setup.init = async () => {
|
||||
apxtribes[townconf.tribeId]=townconf.tribe;
|
||||
fs.outputJsonSync(`./nationchains/tribes/idx/tribeId_all.json`,apxtribes);
|
||||
fs.outputJsonSync(`./nationchains/tribes/itm/${townconf.tribeId}.json`,townconf.tribe,{spaces:2});
|
||||
fs.ensureDirSync(`./nationchains/tribes/${townconf.tribeId}/logs`);
|
||||
fs.ensureDirSync(`./nationchains/tribes/${townconf.tribeId}/logs/nginx`);
|
||||
|
||||
//CREATE a mayorId pagans if it does not exist
|
||||
if (!apxpagans[townconf.mayorId]){
|
||||
|
@@ -12,6 +12,33 @@ const hasAccessrighton = require( '../middlewares/hasAccessrighton' );
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
router.get('www', checkHeaders,isAuthenticated,hasAccessrighton('www','R'),(req,res)=>{
|
||||
/**
|
||||
* @api {get} /tribes/www/:tribeId
|
||||
* @apiName Get list of www object (space web)
|
||||
* @apiGroup Tribes
|
||||
*
|
||||
* @apiUse apxHeader
|
||||
*
|
||||
* @apiParam {String} tribeId Mandatory it identify an existing tribe
|
||||
* @apiParam {String} Check if Person has access as Read to object www
|
||||
* @apiError (404) {string} status the file does not exist
|
||||
* @apiError (404) {string} ref objectmodel to get in the right language
|
||||
* @apiError (404) {string} msg key to get template from objectmodel
|
||||
* @apiError (404) {object} data use to render lg/objectmodel_lg.json
|
||||
*
|
||||
* @apiSuccess (200) {object} data contains indexfile requested
|
||||
*/
|
||||
res.status(200).json({data:{}})
|
||||
})
|
||||
|
||||
//router.post('www/') to create a webspace
|
||||
|
||||
//router.put('www/:app') to update
|
||||
|
||||
//router.delete('www/:tribeId/:app)
|
||||
|
||||
|
||||
router.get( '/clientconf/:tribeid', checkHeaders, isAuthenticated, ( req, res ) => {
|
||||
/*
|
||||
get a clientconf.json for a tribeid depending of user accessright
|
||||
|
Reference in New Issue
Block a user