From d0a3b10cfe5b4e77cccb883f23394359a5863729 Mon Sep 17 00:00:00 2001 From: philc Date: Mon, 27 Mar 2023 07:52:21 +0200 Subject: [PATCH] update checkdata.js --- apxtrib.code-workspace | 14 - apxtrib.js | 34 +- models/Contracts.js | 2 +- models/Messages.js | 20 +- models/Nationchains.js | 233 +++++---- models/Odmdb.js | 140 +++++- models/Outputs.js | 2 +- models/OutputsDev.js | 2 +- models/Pagans.js | 1 - models/Referentials.js | 2 +- models/Referentialssave.js | 2 +- models/Setup.js | 126 ++--- models/Tags.js | 96 +++- models/Tribes.js | 38 +- models/UploadFiles.js | 2 +- models/lg/odmdb_en.json | 4 + nationchains/{apixtribe.html => apxtrib.html} | 16 +- .../{antsnation.html => nation_base.html} | 4 +- .../socialworld/contracts/checkdata.js | 452 +++++++++++------- .../contracts/lg/checkdata_en.json | 5 + .../socialworld/contracts/nation_base.js | 36 ++ .../socialworld/contracts/toolsbox.js | 2 +- .../socialworld/contracts/town_base.js | 36 ++ .../contracts/unittest/checkdata.js | 146 ++++++ .../socialworld/metaobject/nation.json | 36 -- .../socialworld/metaobject/pagans.json | 265 ---------- .../socialworld/metaobject/towns.json | 1 - .../socialworld/objects/nations/ants.json | 10 +- .../socialworld/objects/nations/escape.json | 5 - .../searchindex/nations_nationId_all.json | 6 + .../nations/searchindex/nationslist.json | 1 - .../nations/searchindex/tribeslist.json | 1 - .../accessright.json} | 0 .../objects/schema/lg/nations_en.json | 19 + .../objects/schema/lg/nations_fr.json | 7 + .../objects/schema/lg/pagans_en.json | 42 ++ .../objects/schema/lg/pagans_fr.json | 41 ++ .../objects/schema/lg/towns_en.json | 8 + .../objects/schema/lg/towns_fr.json | 8 + .../socialworld/objects/schema/nations.json | 28 ++ .../socialworld/objects/schema/pagans.json | 86 ++++ .../socialworld/objects/schema/towns.json | 45 ++ .../socialworld/objects/towns/game.json | 7 - .../socialworld/objects/towns/hill.json | 9 + .../searchindex/towns_nationId_townId.json | 1 + .../towns/searchindex/towns_townId_all.json | 16 + .../socialworld/objects/towns/wall.json | 9 + .../tribes/searchindex/tribeslist.json | 0 nationchains/socialworld/setup/townSetup.json | 11 + nationchains/socialworld/setup/townconf.json | 13 + nationchains/socialworld/setup/tribeconf.json | 25 + nationchains/town_base.html | 13 + package.json | 6 +- routes/nationchains.js | 2 +- routes/pagans.js | 2 +- routes/tribes.js | 12 +- setup/ASUPconfig.jsold | 12 +- setup/apixtribe.crabdance.com.mustache | 12 +- setup/config.mustache | 4 +- .../data/domain/apixpress/clientconf.mustache | 4 +- .../dataManagement/object/users.json | 8 +- .../dataManagementBackup/object/users.json | 8 +- .../apixpress/users/searchindex/uids.json | 4 +- .../www/app/webapp/app_index_fr.html | 2 +- .../www/app/webapp/fullscreen_auth_fr.html | 12 +- .../apixpress/www/app/webapp/manifest.json | 2 +- .../adminapixpress/adminapixpress.js | 24 +- .../sidebaradminapixpress_fr.json | 10 +- .../ASUPPdata_sidebarAdminapixpress_fr.json | 2 +- .../components/appmesa/appmesa.mustache | 2 +- .../components/appmesa/data_appmesa_fr.json | 4 +- .../components/appmesa/data_sidebar_fr.json | 4 +- .../static/components/appmesa/search.js | 4 +- .../app/webapp/static/data/appmesa_fr.json | 4 +- .../www/app/webapp/static/data/auth_fr.json | 6 +- .../static/data/fullscreensimplehead_fr.json | 2 +- .../static/data/sidebarAdminapixpress_fr.json | 2 +- .../app/webapp/static/data/sidebar_fr.json | 4 +- .../domain/apixpress/www/cdn/doc/apiXpress.mm | 2 +- .../apixpress/www/cdn/public/index.html | 2 +- .../www/cdn/public/js/tagASUPVOIRstate.js.js | 4 +- .../www/cdn/suiviprojetapiXpress.svg | 34 +- unittest.js | 105 ++++ 83 files changed, 1608 insertions(+), 825 deletions(-) delete mode 100644 apxtrib.code-workspace create mode 100644 models/lg/odmdb_en.json rename nationchains/{apixtribe.html => apxtrib.html} (79%) rename nationchains/{antsnation.html => nation_base.html} (65%) create mode 100644 nationchains/socialworld/contracts/lg/checkdata_en.json create mode 100644 nationchains/socialworld/contracts/nation_base.js create mode 100644 nationchains/socialworld/contracts/town_base.js create mode 100644 nationchains/socialworld/contracts/unittest/checkdata.js delete mode 100644 nationchains/socialworld/metaobject/nation.json delete mode 100755 nationchains/socialworld/metaobject/pagans.json delete mode 100644 nationchains/socialworld/metaobject/towns.json delete mode 100644 nationchains/socialworld/objects/nations/escape.json create mode 100644 nationchains/socialworld/objects/nations/searchindex/nations_nationId_all.json delete mode 100644 nationchains/socialworld/objects/nations/searchindex/nationslist.json delete mode 100644 nationchains/socialworld/objects/nations/searchindex/tribeslist.json rename nationchains/socialworld/objects/{nations/searchindex/townslist.json => schema/accessright.json} (100%) create mode 100644 nationchains/socialworld/objects/schema/lg/nations_en.json create mode 100644 nationchains/socialworld/objects/schema/lg/nations_fr.json create mode 100644 nationchains/socialworld/objects/schema/lg/pagans_en.json create mode 100644 nationchains/socialworld/objects/schema/lg/pagans_fr.json create mode 100644 nationchains/socialworld/objects/schema/lg/towns_en.json create mode 100644 nationchains/socialworld/objects/schema/lg/towns_fr.json create mode 100644 nationchains/socialworld/objects/schema/nations.json create mode 100755 nationchains/socialworld/objects/schema/pagans.json create mode 100644 nationchains/socialworld/objects/schema/towns.json delete mode 100644 nationchains/socialworld/objects/towns/game.json create mode 100644 nationchains/socialworld/objects/towns/hill.json create mode 100644 nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json create mode 100644 nationchains/socialworld/objects/towns/searchindex/towns_townId_all.json create mode 100644 nationchains/socialworld/objects/towns/wall.json delete mode 100644 nationchains/socialworld/objects/tribes/searchindex/tribeslist.json create mode 100755 nationchains/socialworld/setup/townSetup.json create mode 100644 nationchains/socialworld/setup/townconf.json create mode 100755 nationchains/socialworld/setup/tribeconf.json create mode 100644 nationchains/town_base.html create mode 100644 unittest.js diff --git a/apxtrib.code-workspace b/apxtrib.code-workspace deleted file mode 100644 index 890e59a..0000000 --- a/apxtrib.code-workspace +++ /dev/null @@ -1,14 +0,0 @@ -{ - "folders": [ - { - "path": "." - }, - { - "path": "../apxtrib.wiki" - }, - { - "path": "../apxtribautoeval" - } - ], - "settings": {} -} \ No newline at end of file diff --git a/apxtrib.js b/apxtrib.js index c871050..a5491b3 100755 --- a/apxtrib.js +++ b/apxtrib.js @@ -5,27 +5,32 @@ const express = require( 'express' ); /******************************************* -SEE http://gitlab.ndda.fr/philc/apixtribe/-/wikis/HOWTOoverview -To have a quick understanding before doing deeply in source code +SEE https://gitea.ndda.fr/apxtrib/apxtrib/wiki/Devrules +To have a quick understanding and convention before doing deeply in source code *********************************************/ +// to make absolute path with `${__base}relativepath` +global.__base = __dirname +'/'; // check setup if( !fs.existsSync( '/etc/nginx/nginx.conf' ) ) { console.log( '\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available, install then rerun yarn command.' ); process.exit(); } if( !fs.existsSync( './tribes/townconf.js' ) ) { - console.log( `\x1b[42m####################################\nWellcome into apixtribe, you need to init your town by "yarn setup" the first time . \nCheck README's project to learn more. more.\n #####################################\x1b[0m` ); + console.log( `\x1b[42m#########################################################################\x1b[0m\n\x1b[42mWellcome into apxtrib, init your town and first tribe by 'yarn setup'. \x1b[0m \n\x1b[42mThen 'yarn dev' or 'yarn startpm2'. Check README's project to learn more.\x1b[0m\n\x1b[42m#########################################################################\x1b[0m` ); process.exit(); } // config.js exist in any case from Setup.checkinit(); const config = require( './tribes/townconf.js' ); -// Tribes allow to get local apixtribe instance context +// Tribes allow to get local apxtrib instance context // dataclient .tribeids [] .DOMs [] .routes (plugins {url:name route:path}) .appname {tribeid:[website]} const dataclient = require( './models/Tribes' ) .init(); -console.log( 'allowed DOMs to access to this apixtribe server: ', dataclient.DOMs ) +console.log( 'allowed DOMs to access to this apxtrib server: ', dataclient.DOMs ) const app = express(); +Object.keys(config.appset).forEach(p=>{ + app.set(p,config.appset[p]) +}) app.set( 'trust proxy', true ); // To set depending of data form or get size to send app.use( bodyParser.urlencoded( config.bodyparse.urlencoded ) ); @@ -79,10 +84,10 @@ app.use( express.static( `${__dirname}/tribes/${config.mayorId}/www/cdn/public`, dotfiles: 'allow' } ) ); -//Allow to public access a space dev delivered by apixtribe +//Allow to public access a space dev delivered by apxtrib // this is just a static open route for dev purpose, // for production, we'll use a nginx static set to /www/app/appname -/*console.log( `${config.dnsapixtribe}/space/tribeid/website`, dataclient.appname ); +/*console.log( `${config.dnsapxtrib}/space/tribeid/website`, dataclient.appname ); Object.keys( dataclient.appname ) .forEach( cid => { dataclient.appname[ cid ].forEach( website => { @@ -91,9 +96,9 @@ Object.keys( dataclient.appname ) } ); */ // Routers add any routes from /routes and /plugins -console.log( 'Routes available on this apixtribe instance' ); +console.log( 'Routes available on this apxtrib instance' ); console.log( dataclient.routes ); -// prefix only use for dev purpose in production a proxy nginx redirect /app/ to node apixtribe +// prefix only use for dev purpose in production a proxy nginx redirect /app/ to node apxtrib dataclient.routes.forEach( r => { try { @@ -103,17 +108,8 @@ dataclient.routes.forEach( r => { console.log( 'raise err-:', err ); } } ) -// Listen web server from config profil (dev prod, other) app.listen( config.porthttp, () => { - console.log( `check in your browser that api works http://${config.dnsapixtribe}:${config.porthttp}` ); + console.log( `check in your browser that api works http://${config.dnsapxtrib}:${config.porthttp}` ); } ); -/*httpServer.setTimeout( config.settimeout ); -if( config.withssl == "YES" ) { - const httpsServer = https.createServer( config.SSLCredentials, app ); - httpsServer.listen( config.port.https, () => { - console.log( `check in your browser that api works https://${config.dnsapixtribe}:${config.port.https}` ); - } ); - httpsServer.setTimeout( config.settimeout ); -};*/ console.log( "\x1b[42m\x1b[37m", "Made with love for people's freedom, enjoy !!!", "\x1b[0m" ); diff --git a/models/Contracts.js b/models/Contracts.js index a9fe1f6..91ddd88 100755 --- a/models/Contracts.js +++ b/models/Contracts.js @@ -85,7 +85,7 @@ Contracts.initActiontodo = async ( envoie ) => { const actiondone = await Contracts[ todo.action ]( todo, envoie ); todo.datesRun.push( moment( new Date() ) .format( 'YYYYMMDD HH:mm:ss' ) ); - //console.log("actiondone", actio jsonfile.writeFileSyncndone); + //console.log("actiondone" log.actionlist += "STATUS:" + actiondone.status + " -- " + listaction[ action ] + "\n"; if( actiondone.status == 200 ) { todo.error = ""; diff --git a/models/Messages.js b/models/Messages.js index 5cc7507..bd456a7 100755 --- a/models/Messages.js +++ b/models/Messages.js @@ -12,11 +12,11 @@ const config = require( '../tribes/townconf.js' ); const checkdata = require( `../nationchains/socialworld/contracts/checkdata.js`); /* Message manager -* Manage apixtribe message at different level +* Manage apxtrib message at different level * this means that an object (most often a user or a contact) want to send a question to an other user. -To know more http://gitlab.ndda.fr/philc/apixtribe/-/wikis/HOWTONotification +To know more http://gitlab.ndda.fr/philc/apxtrib/-/wikis/HOWTONotification */ const Messages = {}; @@ -35,7 +35,7 @@ Messages.byEmailwithmailjet = ( tribeid, msg ) => { TextPart:"texte content", HTMLPart:"html content" }] - If tribeid has a mailjet account it use it if not then it use the apixtribe @mailjetconf = {apikeypub:, apikeypriv:, From:{Email:,Name:}} + If tribeid has a mailjet account it use it if not then it use the apxtrib @mailjetconf = {apikeypub:, apikeypriv:, From:{Email:,Name:}} This send a bunch of messages check the mailjet account used FYI: Basic account is 200 email /days 6000 /month Log is stored into @@ -48,12 +48,12 @@ Messages.byEmailwithmailjet = ( tribeid, msg ) => { if( confclient.smtp && confclient.smtp.mailjet ) { mailjetconf = confclient.smtp.mailjet; } else { - const confapixtribe = fs.readJsonSync( `${config.tribes}/${config.mayorId}/clientconf.json` ); - if( !( confapixtribe.smtp && confapixtribe.smtp.mailjet ) ) { - return { status: 403, data: { models: "Messages", info: [ "nosmtpmailjet" ], moreinfo: "missing smtpmailjet parameter in apixtribe contact your admin to activate an mailjet account on this server." } } + const confapxtrib = fs.readJsonSync( `${config.tribes}/${config.mayorId}/clientconf.json` ); + if( !( confapxtrib.smtp && confapxtrib.smtp.mailjet ) ) { + return { status: 403, data: { models: "Messages", info: [ "nosmtpmailjet" ], moreinfo: "missing smtpmailjet parameter in apxtrib contact your admin to activate an mailjet account on this server." } } } - tribeidsender = "apixtribe"; - mailjetconf = confapixtribe.smtp.mailjet; + tribeidsender = "apxtrib"; + mailjetconf = confapxtrib.smtp.mailjet; } //add from from setings account const MSG = msg.map( m => { m.From = mailjetconf.From; return m; } ); @@ -79,7 +79,7 @@ Messages.byEmailwithmailjet = ( tribeid, msg ) => { }; Messages.buildemail = ( tribeid, tplmessage, data ) => { /* @tribeid => client concerned by sending email get info from clientconf.json (customization, useradmin:{ EMAIL,LOGIN} , ...) - @tplmessage => folder where template is available (ex: apixtribe/referentials/dataManagement/template/order) + @tplmessage => folder where template is available (ex: apxtrib/referentials/dataManagement/template/order) @data { destemail = email to if destuuid => then it get user EMAIL if exiat subject = mail subject @@ -279,7 +279,7 @@ Messages.notification = ( data, header ) => { }; } //by default store in tmp/notification this is only for sysadmin - // user adminapixtribe + // user adminapxtrib let notdest = `${config.tmp}`; if( data.app ) { diff --git a/models/Nationchains.js b/models/Nationchains.js index abdccc9..a1bfc54 100755 --- a/models/Nationchains.js +++ b/models/Nationchains.js @@ -1,18 +1,14 @@ -const bcrypt = require( 'bcrypt' ); -const fs = require( 'fs-extra' ); -const path = require( 'path' ); -const jsonfile = require( 'jsonfile' ); -const glob = require( 'glob' ); -const jwt = require( 'jwt-simple' ); -const moment = require( 'moment' ); -const axios = require( 'axios' ); -const UUID = require( 'uuid' ); -const Outputs = require( './Outputs.js' ); -const config = require( '../tribes/townconf.js' ); -const checkdata = require( `../nationchains/socialworld/contracts/checkdata.js`); +const bcrypt = require("bcrypt"); +const fs = require("fs-extra"); +const glob = require("glob"); +const jwt = require("jwt-simple"); +const axios = require("axios"); +const config = require("../tribes/townconf.js"); +const Odmdb = require('../models/Odmdb.js'); + /* Blockchain manager -* Manage network directory +* Manage network directory of nations and towns * read Blockchain and search, * submit a transaction (now) or contract (futur) to store from userA.pubkey to userB.pubkey a number of AXESS * mine to be able to register a block and create AXESS @@ -21,85 +17,146 @@ Blockchain manager */ const Nationchains = {}; Nationchains.init = () => { - console.group( 'init Nationchains' ); -} + console.group("init Nationchains"); +}; Nationchains.synchronize = () => { - /* - Run process to communicate with a list of apixtribe instance to update transaction and earn AXP + /* + Run process to communicate with a list of apxtrib instance to update transaction and earn AXP To creation of a new tribeid or a new login */ - //update himself then send to other information - if( process.env.NODE_ENV != "prod" ) { - // Not concerned - return {} - } - const initcurrentinstance = { - "fixedIP": "", - "lastblocknumber": 0, - "firsttimeupdate": 0, - "lastimeupdate": 0, - "positifupdate": 0, - "negatifupdate": 0, - "pubkeyadmin": "", - "tribeids": [], - "logins": [], - "knowninstance": [] - }; - let currentinstance = initcurrentinstance; - try { - currentinstance = fs.readFileSync( `${config.tribes}/${config.mayorId}/nationchains/nodes/${config.rootURL}`, 'utf-8' ) - } catch ( err ) { - console.log( 'first init' ) - } - const loginsglob = fs.readJsonSync( `${config.tmp}/loginsglob.json`, 'utf-8' ); - currentinstance.logins = Object.keys( loginsglob ); - currentinstance.tribeids = [ ...new Set( Object.values( loginsglob ) ) ]; - currentinstance.instanceknown = glob.Sync( `${config.tribes}/${config.mayorId}/nationchains/nodes/*` ); - //Save it - fs.outputJsonSync( `${config.tribes}/${config.mayorId}/nationchains/nodes/${config.rootURL}`, currentinstance ); - // proof of work - // try to find a key based on last block with difficulty - // if find then send to all for update and try to get token - // in any case rerun Nationchains.synchronize() - currentinstance.instanceknown.forEach( u => { - if( u != config.rootURL ) { - //send currentinstance info and get back state of - axios.post( `https://${u}/nationchains/push`, currentinstance ) - .then( rep => { - newdata = rep.payload.moreinfo - //Available update info - fs.readJson( `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, ( err, data ) => { - if( err ) { - data.negatifupdate += 1; - data.lasttimeupdate = Date.now(); - } else { - data.positifupdate += 1; - data.lastimeupdate = Date.now(); - data.tribeids = newdata.tribeids; - data.logins = newdata.logins; - data.lastblocknumber = newdata.lastblocknumber; - newdata.knowninstance.forEach( k => { - if( !data.knowninstance.includes( k ) ) { - data.knowninstance.push( k ); - //init the domain for next update - initcurrentinstance.firsttimeupdate = Date.now(); - fs.outputJson( `${config.tribes}/${config.mayorId}/nationchains/nodes/${k}`, initcurrentinstance, 'utf-8' ) - } - } ) - } - //save with info - fs.outputJson( `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, data ); - } ) - } ) - .catch( err => { - //Not available - data.negatifupdate += 1; - data.lasttimeupdate = Date.now(); - fs.outputJson( `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, data ); - } ); - } - } ); + //update himself then send to other information + if (process.env.NODE_ENV != "prod") { + // Not concerned + return {}; + } + const initcurrentinstance = { + fixedIP: "", + lastblocknumber: 0, + firsttimeupdate: 0, + lastimeupdate: 0, + positifupdate: 0, + negatifupdate: 0, + pubkeyadmin: "", + tribeids: [], + logins: [], + knowninstance: [], + }; + let currentinstance = initcurrentinstance; + try { + currentinstance = fs.readFileSync( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${config.rootURL}`, + "utf-8" + ); + } catch (err) { + console.log("first init"); + } + const loginsglob = fs.readJsonSync(`${config.tmp}/loginsglob.json`, "utf-8"); + currentinstance.logins = Object.keys(loginsglob); + currentinstance.tribeids = [...new Set(Object.values(loginsglob))]; + currentinstance.instanceknown = glob.Sync( + `${config.tribes}/${config.mayorId}/nationchains/nodes/*` + ); + //Save it + fs.outputJsonSync( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${config.rootURL}`, + currentinstance + ); + // proof of work + // try to find a key based on last block with difficulty + // if find then send to all for update and try to get token + // in any case rerun Nationchains.synchronize() + currentinstance.instanceknown.forEach((u) => { + if (u != config.rootURL) { + //send currentinstance info and get back state of + axios + .post(`https://${u}/nationchains/push`, currentinstance) + .then((rep) => { + newdata = rep.payload.moreinfo; + //Available update info + fs.readJson( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, + (err, data) => { + if (err) { + data.negatifupdate += 1; + data.lasttimeupdate = Date.now(); + } else { + data.positifupdate += 1; + data.lastimeupdate = Date.now(); + data.tribeids = newdata.tribeids; + data.logins = newdata.logins; + data.lastblocknumber = newdata.lastblocknumber; + newdata.knowninstance.forEach((k) => { + if (!data.knowninstance.includes(k)) { + data.knowninstance.push(k); + //init the domain for next update + initcurrentinstance.firsttimeupdate = Date.now(); + fs.outputJson( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${k}`, + initcurrentinstance, + "utf-8" + ); + } + }); + } + //save with info + fs.outputJson( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, + data + ); + } + ); + }) + .catch((err) => { + //Not available + data.negatifupdate += 1; + data.lasttimeupdate = Date.now(); + fs.outputJson( + `${config.tribes}/${config.mayorId}/nationchains/nodes/${u}`, + data + ); + }); + } + }); }; +Nationchains.create = (conf) => { + /* + @conf from a nationchains/socialworld/setup/townSetup {object, nationName, townName, dns} + @return + */ + const res = {}; + if (conf.object=="town"){ + Odmdb.create("nationchains/socialworld/objects","town",conf); + } + const nation_town = fs.readJsonSync( + "./nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json" + ); + if (!ObjectKeys(nation_town).includes(conf.nationName)) { + res.status = 404; + res.info = `your nationName ${conf.nationName} does not exist you have to choose an existing one`; + return res; + } + if (nation_town[conf.nationName].includes(conf.townName)) { + res.status = 409; + res.info = `This conf.townName already exist you have to find a unique town name per nation`; + return res; + } + const towndata = { + uuid: conf.townName, + nationid: conf.nationName, + url: `${conf.townName}.${conf.nationName}.${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`, + towndata + ); + res.status=200 + res.info=`${townName} create for ${nationName} nation`; + return res +}; module.exports = Nationchains; diff --git a/models/Odmdb.js b/models/Odmdb.js index 2452ef2..48ee7c9 100644 --- a/models/Odmdb.js +++ b/models/Odmdb.js @@ -1,10 +1,16 @@ -const glob = require( 'glob' ); -const path = require( 'path' ); -const fs = require( 'fs-extra' ); -const config = require( '../tribes/townconf.js' ); +const glob = require("glob"); +const path = require("path"); +const fs = require("fs-extra"); +//const config = require( '../tribes/townconf.js' ); +const check = require(`../nationchains/socialworld/contracts/checkdata.js`); +/* This manage Objects for indexing and check and act to CRUD + objectpath/objects/schema/objectName.json + /objectNames/searchindes/objectName_valueofkey_uuildlist.json + /objectNames/uuid.json + +*/ const Odmdb = {}; - /* Input: metaobject => data mapper of Key: Value @@ -13,5 +19,127 @@ Input: metaobject => data mapper of Key: Value objname + action index => update /searcindex of objects concern */ +Odmdb.schema = (objectPath, objectName) => { + // Return schema if exist and objectpath contain objectName { status:200;data:schema} + if (!fs.existsSync(`${objectPath}/${objectName}`)) + return { + status: 404, + info: "|odmdb|objectpathnamedoesnotexist", + moreinfo: `${objectPath}/${objectName}`, + }; + if (!fs.existsSync(`${objectPath}/schema/${objectName}.json`)) { + return { + status: 404, + info: `|odmdb|schemanotfound`, + moreinfo: `file not found ${objectPath}/schema/${objectName}.json`, + }; + } else { + return { + status: 200, + data: fs.readJsonSync(`${objectPath}/schema/${objectName}.json`), + }; + } +}; -module.exports = Odmdb; \ No newline at end of file +Odmdb.check = (objectPath, objectName, data) => { + /* + @objectPath path to the folder that contain /objects/objectName/ /objectsInfo/objectName_lg.json /objectsMeta/objectName.json + @objectName name of object + @data data to check based on objectsMeta definition + */ + const schema = Odmdb.schema(objectPath, objectName); + if (schema.status != 200) return schema; + console.log("SCHEMA for checking:"); + console.log(schema.data); + console.log("DATA to check:"); + console.log(data); + const validate = checkdata.schema.data(schema.data,data) + + /*const ajv = new Ajv({strict:"log"}); + const validate = ajv.compile(schema.data); + const valid = validate(data) + console.log("valid:",valid) + */ +}; +Odmdb.search = (objectPath, objectName, search) => { + /* + @search= { + txt: string, + algo: match | pattern | fuzzy + fieldstring:[list of field], + indexfilter:{index1:[val1,val2 | ] } + } + Return data:[uuids] + + example: search exact match hill in townId + heavy search={txt:"hill",algo:"match",fieldstring:"toxnId"} + light search={txt:"hill", algo:"match", indexfilter:{"key":"townId","value":[]}} + light search={txt:"hill", algo:"match", indexfilter:{"key":"nationId","value":"ants"}} + + */ + const schema = Odmdb.schema(objectPath, objectName); + if (schema.status != 200) return schema; +}; +Odmdb.get = (objectPath, objectName, uuidprimarykeyList, fieldList) => { + /* + @uuidprimarykeyList list of uuid requested + @fieldList key to return for each object + Return objectName {status:200; data:{found:[{primarykey,field}],notfound:[uuid]} + if all primarykey exist then data.notfound does not exist + if all primarykey does not exist data.found does not exist + */ + const res = { status: 200, data: {} }; + uuidprimarykeyList.forEach((id) => { + if (fs.existsSync(`${objectPath}/${objectName}/${id}.json`)) { + if (!res.data.found) res.data.found = []; + const objectdata = fs.readJsonSync( + `${objectPath}/${objectName}/${id}.json` + ); + if (!fieldList) { + res.data.found.push(objectdata); + } else { + const objinfo = {}; + fieldlList.forEach((k) => { + if (objectdata[k]) objinfo[k] = objectdata[k]; + }); + res.data.found.push(objinfo); + } + } else { + if (!res.data.notfound) res.data.notfound = []; + } + }); + return res; +}; +Odmdb.create = (objectPath, objectName, data) => { + /* + Create an objects data into objectName + @objectPath path to the folder that contain /objects/objectName/ /objectsInfo/objectName_lg.json /objectsMeta/objectName.json + @objectName name of object + @data data to check based on objectsMeta definition + */ +}; +Odmdb.update = (objectPath, objectName, data) => { + /* + Create an objects data into objectName + @objectPath path to the folder that contain /objects/objectName/ /objectsInfo/objectName_lg.json /objectsMeta/objectName.json + @objectName name of object + @data data to check based on objectsMeta definition + */ +}; +Odmdb.delete = (objectPath, objectName, data) => { + /* + Create an objects data into objectName + @objectPath path to the folder that contain /objects/objectName/ /objectsInfo/objectName_lg.json /objectsMeta/objectName.json + @objectName name of object + @data data to check based on objectsMeta definition + */ +}; +console.log("test Odmdb"); +console.log( + Odmdb.check( + "/media/phil/usbfarm/apxtrib/nationchains/socialworld/objects", + "nations", + { nationId: "123", status: "unchain" } + ) +); +module.exports = Odmdb; diff --git a/models/Outputs.js b/models/Outputs.js index ed3f3b2..87f3da0 100755 --- a/models/Outputs.js +++ b/models/Outputs.js @@ -435,7 +435,7 @@ Outputs.addjson = function ( data, header ) { try { fs.outputJsonSync( header.destinationfile + '/' + header.filename, data.jsonp ); if( data.callback ) { - const execCB = require( `${config.mainDir}/models/tribeid/${header.xworkon + const execCB = require( `${__base}/models/tribeid/${header.xworkon }` ); execCB[ data.callback ](); } diff --git a/models/OutputsDev.js b/models/OutputsDev.js index 3861c53..e184296 100755 --- a/models/OutputsDev.js +++ b/models/OutputsDev.js @@ -350,7 +350,7 @@ Outputs.addjson = function ( data, header ) { try { fs.outputJsonSync( header.destinationfile + '/' + header.filename, data.jsonp ); if( data.callback ) { - const execCB = require( `${config.mainDir}/models/tribeid/${header.xworkon + const execCB = require( `${__base}/models/tribeid/${header.xworkon }` ); execCB[ data.callback ](); } diff --git a/models/Pagans.js b/models/Pagans.js index ca98b6c..450e452 100755 --- a/models/Pagans.js +++ b/models/Pagans.js @@ -1,6 +1,5 @@ const bcrypt = require( 'bcrypt' ); const fs = require( 'fs-extra' ); -const jsonfile = require( 'jsonfile' ); const glob = require( 'glob' ); const moment = require( 'moment' ); const jwt = require( 'jwt-simple' ); diff --git a/models/Referentials.js b/models/Referentials.js index e2a8dbb..7f31ed0 100755 --- a/models/Referentials.js +++ b/models/Referentials.js @@ -239,7 +239,7 @@ Referentials.update = ( tribeid, source, name ) => { } } }; -//console.log( Referentials.update( 'apixtribe', "object", "user" ) ) +//console.log( Referentials.update( 'apxtrib', "object", "user" ) ) Referentials.genereobjet = ( tribeid, destination, tplmustache, objet, filtre ) => { /* @TODO diff --git a/models/Referentialssave.js b/models/Referentialssave.js index fd60fe1..d41b3ee 100755 --- a/models/Referentialssave.js +++ b/models/Referentialssave.js @@ -204,7 +204,7 @@ Referentials.update = ( tribeid, source, name ) => { } } }; -//console.log( Referentials.update( 'apixtribe', "object", "user" ) ) +//console.log( Referentials.update( 'apxtrib', "object", "user" ) ) Referentials.genereobjet = ( tribeid, destination, tplmustache, objet, filtre ) => { /* @TODO diff --git a/models/Setup.js b/models/Setup.js index 137d6a7..6841b48 100755 --- a/models/Setup.js +++ b/models/Setup.js @@ -2,6 +2,7 @@ const fs = require( 'fs-extra' ); const path = require( 'path' ); const dnsSync = require( 'dns-sync' ); const Mustache = require( 'mustache' ); +const Odmdb= require('./Odmdb.js'); const Setup = {}; @@ -9,11 +10,11 @@ if( !fs.existsSync( '/etc/nginx/nginx.conf' ) ) { console.log( '\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available' ); process.exit(); } -if( !fs.existsSync( '../config.js' ) ) { - console.log( `\x1b[42m####################################\nWellcome into apixtribe, this is a first install.\nWe need to make this server accessible from internet subdomain.domain to current IP. This setup will create your unique tribeid, with an admin login user to let you connect to the parameter interface.\nCheck README's project to learn more. more.\n#####################################\x1b[0m` ); - const confdata = fs.readJsonSync( path.normalize( `${__dirname}/../setup/configsetup.json` ) ); - console.log( 'Current setup conf from :\n' + path.normalize( `${__dirname}/../setup/configsetup.json` + '\nChange with relevant setup data and rerun yarn setup' ) ); - console.log( confdata ) +if( !fs.existsSync( `./tribes/townconf.json` ) ) { + console.log( `\x1b[42m####################################\nWellcome into apxtrib, this is a first install.\nWe need to make this server accessible from internet subdomain.domain to current IP. This setup will create your unique tribeid, with an admin login user to let you connect to the parameter interface.\nCheck README's project to learn more. more.\n#####################################\x1b[0m` ); + const townSetup = fs.readJsonSync( './nationchains/socialworld/setup/townSetup.json') ; + console.log( `Current setup conf from :./nationchains/socialworld/setup/townSetup.json\nChange with relevant setup data and rerun yarn setup` ) ; + console.log( townSetup ) const readline = require( 'readline' ); const rl = readline.createInterface( { input: process.stdin, @@ -21,16 +22,26 @@ if( !fs.existsSync( '../config.js' ) ) { } ); rl.question( 'This is the data from setup/configsetup.json used, is it correct to use as first install (Yes/no)?', function ( rep1 ) { - let quest = `This is a production install, please check that ${confdata.subdomain}.${confdata.domain} IP is well redirect to tour server`; + let quest = `This is a production install, please check that ${townSetup.townName}.${townSetup.nationName}.${townSetup.dns} IP is well redirect to tour server`; if( rep1 !== "Yes" ) process.exit( 0 ); - if( confdata.domain == 'local.fr' ) { - quest = `This is a development installation, please add in your /etc/hosts "127.0.0.1 ${confdata.subdomain}.${confdata.domain} " `; + if( townSetup.dns == 'unchain' ) { + quest = `This is a development installation, please add in your /etc/hosts 127.0.0.1 ${townSetup.townName}.${townSetup.nationName}.${townSetup.dns} `; } rl.question( quest + '\nAre you sure to set this? (Yes/no)', function ( rep2 ) { if( rep2 == "Yes" ) { - const check = Setup.checkdata( confdata ); + const check = Setup.check( townSetup ); if( check == "" ) { - Setup.config( confdata ); + const townconf=fs.readJsonSync('./nationchains/socialworld/setup/townSetup.json') + // create tribes folder with townconf.json + fs.outputJsonSync(`./tribes/townconf.json`,{...townSetup,...townconf},{spaces:2}) + const Nationchains = require('./Nationchains'); + const Tribes = require('./Tribes'); + const Pagans = require('./Pagans'); + townSetup.object="town" + Nationschains.create(townSetup); + Tribes.create(townSetup); + Pagans.create(townSetup); + //Setup.config( townSetup ); } else { console.log( check ); } @@ -48,93 +59,100 @@ if( !fs.existsSync( '../config.js' ) ) { console.log( 'Carefull you have already a config.js that is running. If you want to change remove config.js file and run again yarn setup' ); } -Setup.checkdata = conf => { - let rep = ""; - if( ![ 'dev', 'prod' ].includes( conf.mode ) ) { - rep += "mode have to be 'dev' or 'prod' currently it's " + conf.mode + "\n"; +Setup.check = conf => { + var rep = ""; + const nation_town=fs.readJsonSync('./nationchains/socialworld/objects/towns/searchindex/towns_nation_uuid.json'); + if (!ObjectKeys(nation_town).includes(conf.nationName)){ + rep+=`your nationName ${conf.nationName} does not exist you have to choose an existing one`; } + if (nation_town[conf.nationName].includes(conf.townName)){ + rep+=`This conf.townName already exist you have to find a unique town name per nation`; + } + const getnation = Odmdb.get('./nationchains/socialworld/objects','towns',[conf.NationName];[nationId]) + if getnation.data.notfound conf.language.forEach( l => { if( ![ "fr", "en", "it", "de", "sp" ].includes( l ) ) { rep += l + " Only fr,en,it,de,sp are available \n"; } } ); - if( !fs.existsSync( `/home/${conf.linuxuser}` ) ) { - rep += `/home/${conf.linuxuser} does not exist, user has to be create with a /home on this server\n`; + if( !fs.existsSync( `/home/${conf.sudoerUser}` ) ) { + rep += `/home/${conf.sudoerUser} does not exist, user has to be create with a /home on this server\n`; } - // avant eslint if( !( /^[a-z\s\-]+$/.test( conf.druidid ) ) ) { - if( !( /^[a-z\s-]+$/.test( conf.druidid ) ) ) { - rep += `${conf.druidid} have to contain only a-z characters `; - } - // add a check later have to be unique if not in dev - if( !( /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.{}:|\s]{8,}/.test( conf.genericpsw ) ) ) { - rep += "Give a generic pasword for all your tribeid's user,they will change it min 8 char special char upper lower case and number" + try { + if ("true"== execSync("timeout 2 sudo id && sudo=\"true\" || sudo=\"false\";echo \"$sudo\"").toString().trim().split(/\r?\n/).slice(-1)) { + rep+=`${sudoerUser} is not sudoer please change this `; + } ; + }catch(err){ + console.log(err); + rep+=" Check your user it seems to not be a sudoer" } if( conf.jwtsecret.length < 32 ) { rep += "Your jwtsecretkey must have at least 32 characters" } - if( conf.mode != 'dev' && !dnsSync.resolve( `${conf.subdomain}.${conf.domain}` ) ) { - rep += `\nresolving ${conf.subdomain}.${conf.domain} will not responding valid IP, please setup domain redirection IP before runing this script` + if( conf.dns != 'unchain' && !dnsSync.resolve( `${conf.townName}.${conf.nationName}.${conf.dns}` ) ) { + rep += `\nresolving $${conf.townName}.${conf.nationName}.${conf.dns} will not responding valid IP, please setup domain redirection IP before runing this script` } return rep }; -Setup.config = ( confdata ) => { + +Setup.config = ( townSetup ) => { // Init this instance with a .config.js - Setup.configjs( confdata ); - // Create tribeid space + a user admin + webspace withe apixtribe webapp install - Setup.druidid( confdata ); + Setup.configjs( townSetup ); + // Create tribeid space + a user admin + webspace withe apxtrib webapp install + Setup.druidid( townSetup ); }; -Setup.configjs = ( confdata ) => { +Setup.configjs = ( townSetup ) => { // Set /config.js - let confapixtribe = fs.readFileSync( './setup/config.mustache', 'utf-8' ); - fs.writeFileSync( './config.js', Mustache.render( confapixtribe, confdata ), 'utf-8' ); + let confapxtrib = fs.readFileSync( './setup/config.mustache', 'utf-8' ); + fs.writeFileSync( './config.js', Mustache.render( confapxtrib, townSetup ), 'utf-8' ); if( fs.existsSync( './config.js' ) ) { console.log( 'config.js successfully created.' ); } else { - console.log( "config.js not created, check what's wrong in tpl:", confapixtribe ); - console.log( "for data :", confdata ); + console.log( "config.js not created, check what's wrong in tpl:", confapxtrib ); + console.log( "for data :", townSetup ); process.exit(); } }; -Setup.druidid = ( confdata ) => { +Setup.druidid = ( townSetup ) => { // create a tribeid with a user that will admin this instance into /tribes/tribeid /users const config = require( '../config.js' ); // Need to do it on setup this is also done again in models/Tribes.js - console.log( `${config.tribes}/${confdata.druidid}` ) - fs.ensureDirSync( `${config.tribes}/${confdata.druidid}` ); + console.log( `${config.tribes}/${townSetup.druidid}` ) + fs.ensureDirSync( `${config.tribes}/${townSetup.druidid}` ); [ 'users', 'www', 'referentials', 'nationchains' ].forEach( r => { - fs.copySync( `${config.mainDir}/setup/tribes/apixtribe/${r}`, `${config.tribes}/${confdata.druidid}/${r}` ); + fs.copySync( `${__base}/setup/tribes/apxtrib/${r}`, `${config.tribes}/${townSetup.druidid}/${r}` ); } ) - /* const confcli = JSON.parse( Mustache.render( fs.readFileSync( `${config.mainDir}/setup/tribes/apixtribe/clientconf.mustache`, 'utf8' ), confdata ) ); - fs.outputJsonSync( `${config.tribes}/${confdata.druidid}/clientconf.json`, confcli ); + /* const confcli = JSON.parse( Mustache.render( fs.readFileSync( `${__base}/setup/tribes/apxtrib/clientconf.mustache`, 'utf8' ), townSetup ) ); + fs.outputJsonSync( `${config.tribes}/${townSetup.druidid}/clientconf.json`, confcli ); // Create a new tribeid + admin user for this tribeid // with access to {druidid}:webapp as admin - */ + */ const Tribes = require( '../models/Tribes.js' ); const access = { app: {}, data: {} } - access.app[ `${confdata.druidid}:webapp` ] = "admin"; - access.data[ confdata.druidid ] = { "users": "CRUDO", "referentials": "CRUDO", "www": "CRUDO" }; + access.app[ `${townSetup.druidid}:webapp` ] = "admin"; + access.data[ townSetup.druidid ] = { "users": "CRUDO", "referentials": "CRUDO", "www": "CRUDO" }; const createclient = Tribes.create( { - tribeid: confdata.druidid, - genericpsw: confdata.genericpsw, - lanquageReferential: confdata.language, + tribeid: townSetup.druidid, + genericpsw: townSetup.genericpsw, + lanquageReferential: townSetup.language, useradmin: { - LOGIN: confdata.login, - xlang: confdata.language[ 0 ], + LOGIN: townSetup.login, + xlang: townSetup.language[ 0 ], ACCESSRIGHTS: access } } ); if( createclient.status == 200 ) { - console.log( `Your tribeid domain was created with login : ${confdata.login} and password: ${confdata.genericpsw}, change it after the 1st login on https://${confdata.subdomain}.${confdata.domain}` ); + console.log( `Your tribeid domain was created with login : ${townSetup.login} and password: ${townSetup.genericpsw}, change it after the 1st login on https://${townSetup.subdomain}.${townSetup.domain}` ); // Create nginx conf for a first install const confnginx = fs.readFileSync( './setup/nginx/nginx.conf.mustache', 'utf8' ); - fs.outputFileSync( '/etc/nginx/nginx.conf', Mustache.render( confnginx, confdata ), 'utf-8' ); - // Create a spacedev for webapp of apixtribe + fs.outputFileSync( '/etc/nginx/nginx.conf', Mustache.render( confnginx, townSetup ), 'utf-8' ); + // Create a spacedev for webapp of apxtrib // that will be accesible in prod from https://subdomain.domain/ and in dev http://webapp.local.fr const addspaceweb = Tribes.addspaceweb( { setup: true, - dnsname: [ `${confdata.subdomain}.${confdata.domain}` ], - mode: confdata.mode, - tribeid: confdata.druidid, + dnsname: [ `${townSetup.subdomain}.${townSetup.domain}` ], + mode: townSetup.mode, + tribeid: townSetup.druidid, website: 'webapp', pageindex: "app_index_fr.html" } ); diff --git a/models/Tags.js b/models/Tags.js index 0ed7c0a..301353b 100755 --- a/models/Tags.js +++ b/models/Tags.js @@ -1,13 +1,10 @@ -const fs = require( 'fs' ); -const formidable = require( 'formidable' ); -const jsonfile = require( 'jsonfile' ); +const fs = require( 'fs-extra' ); const path = require( 'path' ); const glob = require( 'glob' ); -const mustache = require( 'mustache' ); const moment = require( 'moment' ); // Check if package is installed or not to pickup the right config file -const config = require( '../tribes/townconf.js' ); - +//const config = require( '../tribes/townconf.js' ); +const config={} const Tags = {}; /* @@ -64,7 +61,7 @@ Tags.getfile = ( filename, req ) => { } ); return { status: 200, - payload: { moreinfo: "Declenche tag", filename: `${config.mainDir}/public/imgtg.png` } + payload: { moreinfo: "Declenche tag", filename: `${__base}/public/imgtg.png` } } } return { status: 404, payload: {} } @@ -226,4 +223,89 @@ Tags.dataloadstat = ( tribeid ) => { console.log(ar.some(el => el[0] == 1 && el[1] == 1)) console.log(ar.some(el => el == [1, 3])) */ +Tags.nginxlog=(pathFile)=>{ + /* + Read an nginx log file and return + @TODO standardiser le log nginx pour recuperer des données (IP,...) + @return {visites:{year:month:{day:number of visites}}, + visitors:{year:month:{day: number of unique visitors for the day}} + year: number of unique visitors for the year} + month:month : number of unique visitors for the month] + } + */ + const log= fs.readFileSync(pathFile,'utf-8'); + const logs=log.split('\n'); + console.log(`nombre ligne ${logs.length}`) + const stat={visits:{},visitors:{}}; + const visitor={} + var previousdt=moment(); + var previoususeragent=""; + console.log(moment(previousdt).format('DD/MMM/YYYY:hh:mm:ss')) + logs.forEach(l=>{ + const elt= l.split('##'); + const useragent = (elt[2] && elt[2].split("\" \"")[1]) ? elt[2].split("\" \"")[1]:"unknown"; + //elt[0] = [30/Jun/2022:15:15:53 +0200] + const dttime = moment(elt[0].split(' ')[0].substring(1),'DD/MMM/YYYY:hh:mm:ss'); + ['visits','visitors'].forEach(ch=>{ + if (!stat[ch][dttime.format('YYYY')]) stat[ch][dttime.format('YYYY')]={}; + if (!stat[ch][dttime.format('YYYY')][dttime.format('MMM')]) stat[ch][dttime.format('YYYY')][dttime.format('MMM')]={} + if (!stat[ch][dttime.format('YYYY')][dttime.format('MMM')][dttime.format('DD')]) stat[ch][dttime.format('YYYY')][dttime.format('MMM')][[dttime.format('DD')]]=0 + if (!visitor[dttime.format('YYYY')]) visitor[dttime.format('YYYY')]={}; + if (!visitor[dttime.format('YYYY')][dttime.format('MMM')]) visitor[dttime.format('YYYY')][dttime.format('MMM')]={} + if (!visitor[dttime.format('YYYY')][dttime.format('MMM')][dttime.format('DD')]) visitor[dttime.format('YYYY')][dttime.format('MMM')][[dttime.format('DD')]]=[] + }) + //console.log(elt[0].split(' ')[0]+ "####" + moment(elt[0],'DD/MMM/YYYY:hh:mm:ss').format('DD-MM-YYYY h:mm:ss')); + //console.log("EEEE"+moment(previousdt).format('DD/MMM/YYYY:hh:mm:ss') + "hhhhhhh" +moment(dttime).format('DD/MMM/YYYY:hh:mm:ss')) + //console.log(previousdt!=dttime) + if (!visitor[dttime.format('YYYY')][dttime.format('MMM')][dttime.format('DD')].includes(useragent)){ + visitor[dttime.format('YYYY')][dttime.format('MMM')][dttime.format('DD')].push(useragent) + } + if (previoususeragent != useragent || parseInt(Math.round(previousdt.toDate().getTime()/100000)) != parseInt(Math.round(dttime.toDate().getTime()/100000))) { + /*console.log("###########################################################"); + console.log(`${previousdt.toDate().getTime()} != ${dttime.toDate().getTime()}`); + console.log(moment(previousdt).format('DD/MMM/YYYY:hh:mm:ss') + "hhhhhhh" + moment(dttime).format('DD/MMM/YYYY:hh:mm:ss')) + console.log(`useragent: ${useragent} previoususeragent: ${previoususeragent}`); + */ + stat['visits'][dttime.format('YYYY')][dttime.format('MMM')][[dttime.format('DD')]]+=1 + previousdt=dttime; + previoususeragent=useragent; + }else{ + //console.log("identique compte pas" ) + } + }) + Object.keys(visitor).forEach(y=>{ + var uniqvisitoryear=[]; + Object.keys(visitor[y]).forEach(m=>{ + var uniqvisitormonth=[]; + Object.keys(visitor[y][m]).forEach(d=>{ + uniqvisitormonth = [...uniqvisitormonth, ...visitor[y][m][d]] + stat.visitors[y][m][d] = visitor[y][m][d].length + }) + uniqvisitoryear=[...uniqvisitoryear, ...uniqvisitormonth] + stat.visitors[y][m][m]=uniqvisitormonth.length; + }) + stat.visitors[y][y]=uniqvisitoryear.length + }) + return {status:200, data:stat} +} +Tags.statin2D=(stat,pathfile)=>{ + if (stat.status==200){ + stat=stat.data + }else { + return stat + } + let csv="type;year;month;day;Number\n\r"; + ["visits", "visitors"].forEach(ch=>{ + Object.keys(stat[ch]).forEach(y=>{ + Object.keys(stat[ch][y]).forEach(m=>{ + Object.keys(stat[ch][y][m]).forEach(d=>{ + csv+=`${ch};${y};${m};${d};${stat[ch][y][m][d]}\n\r` + }) + }) + }) + }) + fs.outputFileSync(pathfile,csv); + return {status:200, info:"fileready", moreinfo:pathfile} +} +console.log(Tags.statin2D(Tags.nginxlog('/home/phil/Documents/nginx/presentation.capsthd.access.log'),'/home/phil/Documents/nginx/stat.csv')); module.exports = Tags; diff --git a/models/Tribes.js b/models/Tribes.js index b8b0ecc..b420aec 100755 --- a/models/Tribes.js +++ b/models/Tribes.js @@ -11,7 +11,7 @@ const moment = require( 'moment' ); const UUID = require( 'uuid' ); const Outputs = require( './Outputs.js' ); const Pagans = require( './Pagans.js' ); -const config = require( '../tribes/townconf.js' ); +const config = require( '../tribes/townconf' ); const checkdata = require( `../nationchains/socialworld/contracts/checkdata.js`); /* @@ -61,19 +61,19 @@ Tribes.init = () => { Tribes.create = ( data ) => { /* data = clientconf.json { - "tribeid": "apixtribe", + "tribeid": "apxtrib", "genericpsw": "Trze3aze!", "website": { - "presentation":"https://www.apixtribe.org", - "webapp": "https://webapp.apixtribe.org" + "presentation":"https://www.apxtrib.org", + "webapp": "https://webapp.apxtrib.org" }, - "allowedDOMs": ["local.fr", "localhost:9002", "ndda.fr", "apixtribe.org"], - "clientname": "apixtribe", + "allowedDOMs": ["local.fr", "localhost:9002", "ndda.fr", "apxtrib.org"], + "clientname": "apxtrib", "clientlogo": "", "geoloc": [], - "useradmin": {PUBKEY:"",EMAIL:"",LOGIN:"adminapixtribe",UUID:"adminapixtribe"}, + "useradmin": {PUBKEY:"",EMAIL:"",LOGIN:"adminapxtrib",UUID:"adminapxtrib"}, "smtp": { - "emailFrom": "support@apixtribe.org", + "emailFrom": "support@apxtrib.org", "emailcc": [], "service": "gmail", "auth": { @@ -90,7 +90,7 @@ Tribes.create = ( data ) => { "dnsname": a domain name belonging to the client "subdns": "www", a sub domain subdns.dnsname give a public web access to "website": { keywebsite:url}, give access to config.tribes/tribeid/www/keywebsite/index.html, - "allowedDOMs": ["local.fr", "localhost:9002", "nnda.fr"], //for CORS, @TODO generate from prévious URL this allow this apixtribe instance to be accessible + "allowedDOMs": ["local.fr", "localhost:9002", "nnda.fr"], //for CORS, @TODO generate from prévious URL this allow this apxtrib instance to be accessible "clientname": Name of the organisation if any, "clientlogo": logo of the organisation if any, "geoloc": [], if any @@ -98,7 +98,7 @@ Tribes.create = ( data ) => { "PUBKEY":public key to be authentify without an email, "EMAIL":user email, we need at least one of authentification set up after the user can use both or only one "LOGIN": login to use for access admintribeid, - "UUID": unique id normaly UUID but a uuid admintribeid is the same person in any apixtribe instance so we use it by convention. + "UUID": unique id normaly UUID but a uuid admintribeid is the same person in any apxtrib instance so we use it by convention. "xlang": lang used by this user }, "smtp": { smtp used to send email by nodemailer lib basic example with a google account @@ -134,10 +134,10 @@ Tribes.create = ( data ) => { } fs.ensureDirSync( `${config.tribes}/${data.tribeid}` ); [ 'users', 'www', 'referentials', 'nationchains' ].forEach( r => { - fs.copySync( `${config.mainDir}/setup/tribes/apixtribe/${r}`, `${config.tribes}/${data.tribeid}/${r}` ); + fs.copySync( `${__base}/setup/tribes/apxtrib/${r}`, `${config.tribes}/${data.tribeid}/${r}` ); } ) fs.outputJsonSync( `${config.tribes}/${data.tribeid}/clientconf.json`, data ); - const confcli = JSON.parse( Mustache.render( fs.readFileSync( `${config.mainDir}/setup/tribes/apixtribe/clientconf.mustache`, 'utf8' ), data ) ); + const confcli = JSON.parse( Mustache.render( fs.readFileSync( `${__base}/setup/tribes/apxtrib/clientconf.mustache`, 'utf8' ), data ) ); fs.outputJsonSync( `${config.tribes}/${data.tribeid}/clientconf.json`, confcli ); return Pagans.createUser( { @@ -151,7 +151,7 @@ Tribes.archive = ( tribeid ) => { // remove tribeid de data ou devdata try { fs.moveSync( `${config.tribes}/${tribeid}`, `${config.archivefolder}/${tribeid}` ); - //update apixtribeenv + //update apxtribenv Tribes.init(); return { status: 200, payload: { info: [ 'deletetribeidsuccessfull' ], models: 'Tribes', moreinfo: "TODO see in Tribes.archive" } } } catch ( err ) { @@ -279,7 +279,7 @@ Tribes.addspaceweb = ( data ) => { nginx conf and ssl to serve each https://dnsname to /{tribeid}/www/app/{website} - Carefull this action is executed with root and restart nginx + apixtribe to work + Carefull this action is executed with root and restart nginx + apxtrib to work */ data.configdomain = config.tribes; data.porthttp = config.porthttp; @@ -293,7 +293,7 @@ Tribes.addspaceweb = ( data ) => { // add nginx http config const confnginx = fs.readFileSync( 'setup/nginx/modelwebsite.conf.mustache', 'utf-8' ); fs.outputFileSync( `/etc/nginx/conf.d/${data.dnsname[0]}.conf`, Mustache.render( confnginx, data ), 'utf-8' ); - if( data.mode == "dev" ) { + if( data.dns == "unchain" ) { //add in /etc/hosts let hosts = fs.readFileSync( '/etc/hosts', 'utf8' ); let chg = false; @@ -320,14 +320,14 @@ Tribes.addspaceweb = ( data ) => { clientconf.allowedDOMs = [ ...new Set( ...clientconf.allowedDOMs, ...data.dnsname ) ]; fs.outputJsonSync( `${config.tribes}/${data.tribeid}/clientconf.json`, clientconf, 'utf-8' ); if( !data.setup ) { - // in setup apixtribe is not running and it will be start manually at the 1st run + // in setup apxtrib is not running and it will be start manually at the 1st run // in other case need to plan a restart for CORS - setTimeout( Tribes.restartapixtribe, 300000, data.clienId ); + setTimeout( Tribes.restartapxtrib, 300000, data.clienId ); } const nginxrestart = execSync( `sudo systemctl restart nginx` ) .toString(); console.log( 'Restart nginx', nginxrestart ) - if( data.mode == "prod" ) { + if( data.mode != "unchain" ) { // get ssl certificate ATTENTION il faut ajouter -d devant chaque domain qui redirige vers l'espace web. const certbot = execSync( `sudo certbot --nginx -d ${data.dnsname.join(' -d ')}` ) .toString(); @@ -343,7 +343,7 @@ Tribes.addspaceweb = ( data ) => { } }; } -Tribes.restartapixtribe = ( tribeid ) => { +Tribes.restartapxtrib = ( tribeid ) => { console.log( 'A restarting was requested 5mn ago from a new spacedev for ' + tribeid ) execSync( 'yarn restartpm2' ); } diff --git a/models/UploadFiles.js b/models/UploadFiles.js index bfb9c36..f436186 100755 --- a/models/UploadFiles.js +++ b/models/UploadFiles.js @@ -38,7 +38,7 @@ UploadFiles.addjson = function ( data, header ) { try { fs.outputJsonSync( header.destinationfile + '/' + header.filename, data.jsonp ); if( data.callback ) { - const execCB = require( `${config.mainDir}/models/tribeid/${ + const execCB = require( `${__base}/models/tribeid/${ header.xworkon }` ); execCB[ data.callback ](); diff --git a/models/lg/odmdb_en.json b/models/lg/odmdb_en.json new file mode 100644 index 0000000..74de930 --- /dev/null +++ b/models/lg/odmdb_en.json @@ -0,0 +1,4 @@ +{ + "schemanotfound":"Schema not found", + "bjectpathnamedoesnotexist":"ObjectPath or objectName does not exist " +} \ No newline at end of file diff --git a/nationchains/apixtribe.html b/nationchains/apxtrib.html similarity index 79% rename from nationchains/apixtribe.html rename to nationchains/apxtrib.html index cfcdf06..55f710d 100644 --- a/nationchains/apixtribe.html +++ b/nationchains/apxtrib.html @@ -2,7 +2,7 @@ - apiXtribe pourquoi comment + apxtrib pourquoi comment @@ -17,18 +17,18 @@ Our occidental society (globalization) wants us more and more money to control u To make us under control, our masters print money and force us to breath it. We have no choice; they control institutions, they can stole our properties or our freedom, they drive the single thought. Forget strke and demonstration, to rebalance and create counter-powers, an alternative is to earn the minimum of their money to stay under their radar and keep our ressources (time, energy) to learn, create and share value for our tribes of friends, family, or people that share common view... A DAO, by design (the blockchain) cannot be control by a central power, because it is a common good, each actor has a benefit and is free to apply fair rules.
-apiXtribes aims to allow any group of people to define rules to apply for their exchange of values. +apxtribs aims to allow any group of people to define rules to apply for their exchange of values. With our master's money to create value you have to respect their rules (a register company, list of standards, list of taxes, ...) in exchange you benefit of institutions like protections (police with the legitimate violence), justice (law), school, medical, ... If you are a good boy then master give you back cash grant. -If you agree with the master's world, and happy to let institution decide for you, this is fine (apiXtribe is not for you). But if you consider that diversity is more resilient than standard and **you want to have choices then this project is for you.** Who knows the futur ;-) apiXtribe could be use to run the democratie (demos kratos: by the people for the people). +If you agree with the master's world, and happy to let institution decide for you, this is fine (apxtrib is not for you). But if you consider that diversity is more resilient than standard and **you want to have choices then this project is for you.** Who knows the futur ;-) apxtrib could be use to run the democratie (demos kratos: by the people for the people). ## Why money is the sinews of war Our masters killed social ties by implementing the KPI (Key Performance Indicator) to quantify the value of each of us base on their rules. Their money is magic, they use as KPI of an individual value as well as the tools to drive our life. In occident, who can survive today without money in his pocket or in master's bank? By **disconnecting value of money with gold or other "physical limit"** the money just value what they decide.
-apiXtribe use a crypto (that looks like a money but is not a money) to value each rule application to create a proof of work and at least a proof of stake that any human involve has an interest to protect it. +apxtrib use a crypto (that looks like a money but is not a money) to value each rule application to create a proof of work and at least a proof of stake that any human involve has an interest to protect it. Then rules (**contracts**) can be set by anyone based on **an algo like if/then** between 2 humans. When the condition is trig then something is register in the blockchain. @@ -45,20 +45,20 @@ Then rules (**contracts**) can be set by anyone based on **an algo like if/then* "B is baned of the community" ``` -**apiXtribe blockchain will register this standard "contracts" and "reputation" of those who respects or not contracts. This cannot be change by any one and any one can read it.**
-A and B are just unique identificator (anonymous or not), to prove a human own A or B, apiXtribe use cryptograpĥic PGP based on public/private key. apiXtribe needs a network topology to be strong enough to avoid central control. This is why apiXtribe recommand rewarding rules to actor that provide electricity, machine, network access. Virtual world exist because physical one exist. +**apxtrib blockchain will register this standard "contracts" and "reputation" of those who respects or not contracts. This cannot be change by any one and any one can read it.**
+A and B are just unique identificator (anonymous or not), to prove a human own A or B, apxtrib use cryptograpĥic PGP based on public/private key. apxtrib needs a network topology to be strong enough to avoid central control. This is why apxtrib recommand rewarding rules to actor that provide electricity, machine, network access. Virtual world exist because physical one exist. Until you stay **in crypto world, you just exchange data so no tax** (no master's rules). You can sale a service against money until you respect master/country's rule of this money (company that collect value tax, register turnover, ...). Then you can deliver crypto to your customer to consume your's or other's services when they want. If you exchange token against gov money then you have to respect your gov's laws (some country's law ask you to pay tax onto added value). So be aware of what you are doing some gov can kill you or put you in jail to exchange their money or data. This Xtrib coin is not for speculation is for social link without man in the middle that stole you.

**As a non tech,** you can invest and request to get your own nation or town (become a mayor) or tribe (become a druid). As non tech you'll need the help of a dev that will help you to modelise and setup Contracts. Any way you can also simply join any tribe as pagan and sales data/product and exchange it again Xtrib coin of a nation. -For non tech, if you have a project please request it to [support@apixtribe.org](mailto:support@apixtribe.org) +For non tech, if you have a project please request it to [support@apxtrib.org](mailto:support@apxtrib.org) **As tech**: **- As sysadmin** you can install a town, for yourself or for a "non tech" and earn Xtrib in exchange
**- As back-end and front-end dev** you can dev web service (node.js express static web based on pwa) that you can sale to a druid or a mayor, or become yourself a druid and host a town to sale usage against Xtribe.
-**- As a former** you can create tuto or training to explain how to install an apiXtribe node, how to dev quickly an app with a setup. This is agnostic about the front-end pwa framework, react, vue, angular, .. . For the back-end is suitable for node.js dev but you can use any linux command to produce something to deliver accross apiXtribe.
+**- As a former** you can create tuto or training to explain how to install an apxtrib node, how to dev quickly an app with a setup. This is agnostic about the front-end pwa framework, react, vue, angular, .. . For the back-end is suitable for node.js dev but you can use any linux command to produce something to deliver accross apxtrib.
**- As a newbie** you can join this open source project to learn how to dev as a part of the team and to increase your portfolio of node.js/linux project. We strongly believe in the cypher punk philosophy french :[cypher punk manifesto](https://dev.ndda.fr/cypherpunkmanifestofrench.html) english: [cypher punk manifesto](https://dev.ndda.fr/cypherpunkmanifestoenglish.html). diff --git a/nationchains/antsnation.html b/nationchains/nation_base.html similarity index 65% rename from nationchains/antsnation.html rename to nationchains/nation_base.html index bd77bae..4069d88 100644 --- a/nationchains/antsnation.html +++ b/nationchains/nation_base.html @@ -2,12 +2,12 @@ - ANTS Nation + Nation Base contract -

Info sur la nation des ANTS leur ville pour les rejoindre

+

Info sur lla nation de

\ No newline at end of file diff --git a/nationchains/socialworld/contracts/checkdata.js b/nationchains/socialworld/contracts/checkdata.js index e9822d4..773435c 100755 --- a/nationchains/socialworld/contracts/checkdata.js +++ b/nationchains/socialworld/contracts/checkdata.js @@ -3,183 +3,299 @@ This module have to be independant of any external package it is shared between back and front and is usefull to apply common check in front before sending it in back can be include in project with - -or with const checkdata = require('../public/js/checkdata.js') - + - into a browser : + - into a node.js : const check = require( `../nationchains/socialworld/contracts/check.js`); */ - // --## -const checkdata = {}; -// each checkdata.test. return true or false -checkdata.test = {}; - -checkdata.test.emailadress = ( ctx, email ) => { - const regExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return regExp.test( email ); +const check = {}; +check.schema = {}; +check.schema.properties = {}; +check.schema.properties.type = {}; +check.schema.properties.type.string = (str) => typeof str === "string"; +check.schema.properties.type.number = (n) => typeof n === "number"; +check.schema.properties.type.integer = (n) => + n != "" && !isNaN(n) && Math.round(n) == n; +check.schema.properties.type.float = (n) => + n != "" && !isNaN(n) && Math.round(n) != n; //not yet in json schema +check.schema.properties.minLength = (str, min) => + typeof str === "string" && str.length > parseInt(min); +check.schema.properties.maxLength = (str, max) => + typeof str === "string" && str.length < parseInt(max); +check.schema.properties.multipleOf = (n, val) => + typeof n === "number" && + typeof val === "number" && + parseFloat(n) / parseFloat(val) - + Math.round(parseFloat(n) / parseFloat(val)) < + 0.0000001; +check.schema.properties.range = ( + n, + minimum, + exclusiveMinimum, + maximum, + exclusiveMaximum +) => { + //console.log(minimum,exclusiveMinimum,maximum, exclusiveMaximum,n) + if (typeof n !== "number") return false; + if (minimum && parseFloat(n) < parseFloat(minimum)) return false; + if (exclusiveMinimum && parseFloat(n) <= parseFloat(exclusiveMinimum)) + return false; + if (maximum && parseFloat(n) > parseFloat(maximum)) return false; + if (exclusiveMaximum && parseFloat(n) >= parseFloat(exclusiveMaximum)) + return false; + return true; }; +check.schema.properties.pattern = (str, pattern) => { + try { + new RegExp(pattern); + } catch (e) { + return false; + } + return pattern.test(str); +}; +check.schema.properties.enum = (str, enumvalues) => + typeof str === "string" && enumvalues.includes(str); +// see format https://json-schema.org/understanding-json-schema/reference/string.html#format +check.schema.properties.format = { + "date-time": / /, + time: / /, + date: / /, + duration: / /, + email: + /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, + "idn-email": / /, + uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, + uri: / /, + "uri-reference": / /, + iri: / /, + hostname: / /, + "idn-hostname": / /, + ipv4: /^([0–9]{1,3}.){3}.([0–9]{1,3})$/, + ipv6: /^((([0–9A-Fa-f]{1,4}:){7}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}:[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){5}:([0–9A-Fa-f]{1,4}:)?[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){4}:([0–9A-Fa-f]{1,4}:){0,2}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){3}:([0–9A-Fa-f]{1,4}:){0,3}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){2}:([0–9A-Fa-f]{1,4}:){0,4}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(([0–9A-Fa-f]{1,4}:){0,5}:((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(::([0–9A-Fa-f]{1,4}:){0,5}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|([0–9A-Fa-f]{1,4}::([0–9A-Fa-f]{1,4}:){0,5}[0–9A-Fa-f]{1,4})|(::([0–9A-Fa-f]{1,4}:){0,6}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){1,7}:))$/, + telephonefr: /^0[1-9][0-9]{9}$/, + telephoneinter: /^\+*(\d{3})*[0-9,\-]{8,}/, + password: + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.{}:|\s]{8,}/, + postalcodefr: /(^\d{5}$)|(^\d{5}-\d{4}$)/, +}; + +check.schema.validation = (schema) => { + /*validate a schema structure*/ + const res = { status: 200, err: [] }; + if (schema.properties) { + Object.keys(schema.properties).forEach((p) => { + const properties = schema.properties; + if ( + properties[p].type && + typeof properties[p].type === "string" && + !check.schema.properties.type[properties[p].type] + ) { + res.err.push({ + info: "|checkdata|typedoesnotexistinschema", + moreinfo: ` ${properties[p].type}`, + }); + } + if ( + properties[p].type && + typeof properties[p].type === "object" && + Array.isArray(properties[p].type) + ) { + properties[p].type.forEach((tp) => { + if (!check.schema.properties.type[tp]) + res.err.push({ + info: "|checkdata|typedoesnotexistinschema", + moreinfo: `${tp} of ${properties[p].type}`, + }); + }); + } + if ( + properties[p].format && + !check.schema.properties.format[properties[p].format] + ) { + res.err.push({ + info: "|checkdata|formatdoesnotexistinschema", + moreinfo: ` ${properties[p].format}`, + }); + } + if (properties[p].enum && !Array.isArray(properties[p].enum)) { + res.err.push({ + info: "|checkdata|enumisnotarrayinschema", + moreinfo: ` ${properties[p].enum}`, + }); + } + }); + } + // 406 means not acceptable + if (res.err.length > 0) res.status = 406; + return res; +}; + +check.schema.data = (schema, ctx, data) => { + /* validate a data set with a schema in a context ctx */ + /* + console.log('#################') + console.log(schema); + console.log('---------') + console.log(data) + */ + const validschema = check.schema.validation(schema); + if (validschema.status != 200) return validschema; + const res = { status: 200, err: [] }; + if (schema.properties) { + const properties = schema.properties; + Object.keys(properties).forEach((p) => { + //type is mandatory in a propertie + if (data[p]) { + const typlist = + properties[p].type && typeof properties[p].type === "string" + ? [properties[p].type] + : properties[p].type; + let valid = false; + typlist.forEach((typ) => { + // at least one test have to be ok + if (check.schema.properties.type[typ](data[p])) valid = true; + }); + if (!valid) + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]}`, + }); + + if ( + properties[p].minLength && + !check.schema.properties.minLength(data[p], properties[p].minLength) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} minLength:${properties[p].minLength}`, + }); + } + if ( + properties[p].maxLength && + !check.schema.properties.maxLength(data[p], properties[p].maxLength) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} maxLength:${properties[p].maxLength}`, + }); + } + if ( + properties[p].multipleOf && + !check.schema.properties.multipleOf(data[p], properties[p].multipleOf) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} not a multipleOf:${properties[p].multipleOf}`, + }); + } + if ( + properties[p].minimum || + properties[p].maximum || + properties[p].exclusiveMinimum || + properties[p].exclusiveMaximum + ) { + // test range + if ( + !check.schema.properties.range( + data[p], + properties[p].minimum, + properties[p].exclusiveMinimum, + properties[p].maximum, + properties[p].exclusiveMaximum + ) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} not in range ${properties[p].minimum} exclu: ${properties[p].exclusiveMinimum} and ${properties[p].maximum} exclu: ${properties[p].exclusiveMaximum}`, + }); + } + } + if ( + properties[p].enum && + !check.schema.properties.enum(data[p], properties[p].enum) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} not in enum list :${properties[p].enum}`, + }); + } + if (properties[p].format) { + properties[p].pattern = + check.schema.properties.format[properties[p].format]; + } + if ( + properties[p].pattern && + !check.schema.properties.pattern(data[p], properties[p].pattern) + ) { + res.err.push({ + info: "|checkdata|dataerrpropertie", + moreinfo: `${p} : ${data[p]} problem pattern or format ${properties[p].pattern}`, + }); + } + } else if (schema.required.includes(p)) { + res.err.push({ + info: "|checkdata|dataerrpropertiesrequired", + moreinfo: `${p}`, + }); + } + }); + } + if (res.err.length > 0) res.status = 417; + return res; +}; + /* - * @emaillist = "email1,email2, email3" - * it check if each eamil separate by , are correct - */ -checkdata.test.emailadresslist = ( ctx, emaillist ) => { - //console.log(emaillist.split(',')) - if( emaillist.length > 0 ) { - const emails = emaillist.split( ',' ); - for( var i in emails ) { - //console.log(emails[i]) - if( !checkdata.test.emailadress( "", emails[ i ].trim() ) ) { - return false - } - } - }; - return true; -}; - -checkdata.test.password = ( ctx, pwd ) => { - const regExp = new RegExp( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.{}:|\s]{8,}/ - ); - return regExp.test( pwd ); -}; -checkdata.test.required = ( ctx, val ) => - ( val != null && val != 'undefined' && val.length > 0 ) || ( !!val && val.constructor === Array && val.length > 0 ) || ( !!val && val.constructor === Object && Object.keys( val ) - .length > 0 ); - -checkdata.test.isNumber = ( ctx, n ) => typeof n === 'number'; -checkdata.test.isInt = ( ctx, n ) => n != '' && !isNaN( n ) && Math.round( n ) == n; -checkdata.test.isFloat = ( ctx, n ) => n != '' && !isNaN( n ) && Math.round( n ) != n; -checkdata.test.unique = ( ctx, val ) => { - if( ctx.list[ ctx.currentfield ] ) { - return !ctx.list[ ctx.currentfield ].includes( val ); - } else { - console.log( 'ERR no list for field:' + ctx.currentfield ); - return false; - } -}; -checkdata.test.isDateDay = ( ctx, dateDay ) => true; -/* checkdata.test.filterInvalidInArray = (array, validate) => - array ? array.filter(el => !validate(el)) : true; -// return true when every elements is valid +Normalize data link to check.schema.properties.format +or any normalization to get consistent data */ - -checkdata.test.postalCode = ( ctx, postalCode ) => { - if( postalCode.length == 0 ) return true; - const regExp = new RegExp( /(^\d{5}$)|(^\d{5}-\d{4}$)/ ); - return regExp.test( postalCode ); +const normalize={}; +normalize.telephonefr =(phone)=>{ + phone = phone.trim().replace(/[- .]/g, ""); + if ( + check.schema.properties.format.telephoenfr(phone) && + phone.length == 10 && + phone[0] == "0" + ) { + phone = "+33 " + phone.substring(1); + } + return phone; }; -/** - * PHONE - */ -checkdata.test.phoneNumber = ( ctx, phoneNumber ) => { - if( phoneNumber.length == 0 ) return true; - phoneNumber = phoneNumber.trim() - .replace( /[- .]/g, '' ) - //french number - const regExpfr = new RegExp( /^0[1-9][0-9]{9}$/ ); - const regExpInternational = new RegExp( /^\+*(\d{3})*[0-9,\-]{8,}/ ); - return regExpfr.test( phoneNumber ) || regExpInternational.test( phoneNumber ); -}; -/* - * @phonelist = "phone1,phone2,phone3" - * it check if each phone separate by , are correct - */ -checkdata.test.phoneNumberlist = ( ctx, phonelist ) => { - //console.log(emaillist.split(',')) - if( phonelist.length > 0 ) { - const phones = phonelist.split( ',' ); - for( var i in phones ) { - //console.log(emails[i]) - if( !checkdata.test.phoneNumber( "", phones[ i ].trim() ) ) { - return false - } - } - }; - return true; +normalize.zfill10 = (num) => { + let s = num + ""; + while (s.length < 10) s = "0" + s; + return s; }; -// checkdata.normalize take a correct data then reformat it to harmonise it -checkdata.normalize = {}; -checkdata.normalize.phoneNumber = ( ctx, phone ) => { - phone = phone.trim() - .replace( /[- .]/g, '' ); - if( checkdata.test.phoneNumber( '', phone ) && phone.length == 10 && phone[ 0 ] == "0" ) { - phone = '+33 ' + phone.substring( 1 ); - } - return phone; -} -checkdata.normalize.upperCase = ( ctx, txt ) => txt.toUpperCase(); -checkdata.normalize.lowerCase = ( ctx, txt ) => txt.toLowerCase(); + +check.test.unique = (ctx, val) => { + if (ctx.list[ctx.currentfield]) { + return !ctx.list[ctx.currentfield].includes(val); + } else { + console.log("ERR no list for field:" + ctx.currentfield); + return false; + } +}; + +// check.normalize take a correct data then reformat it to harmonise it +check.normalize = {}; +check.normalize.phoneNumber = (ctx, phone) => { + phone = phone.trim().replace(/[- .]/g, ""); + if ( + check.test.phoneNumber("", phone) && + phone.length == 10 && + phone[0] == "0" + ) { + phone = "+33 " + phone.substring(1); + } + return phone; +}; +check.normalize.upperCase = (ctx, txt) => txt.toUpperCase(); +check.normalize.lowerCase = (ctx, txt) => txt.toLowerCase(); // fixe 10 position et complete par des 0 devant -checkdata.normalize.zfill10 = ( ctx, num ) => { - let s = num + ''; - while( s.length < 10 ) s = '0' + s; - return s; -}; -/*let tt = "+33 1 02.03 04 05"; -console.log(checkdata.test.phoneNumber('', tt)) -console.log(checkdata.normalize.phoneNumber('', tt)) -*/ -checkdata.evaluate = ( contexte, referential, data ) => { - /* - * contexte object {} with full info for evaluation - * file referential path to get object to apply - * data related to object - - return {validefor =[keyword of error] if empty no error, - clean data eventually reformated - updateDatabase} - */ - console.log( 'contexte', contexte ); - console.log( 'referentiel', referential ); - console.log( 'data', data ); - const invalidefor = []; - const objectdef = {}; - const listfield = referential.map( ch => { - objectdef[ ch.idfield ] = ch; - return ch.idfield; - } ); - - Object.keys( data ) - .forEach( field => { - if( !listfield.includes( field ) ) { - // some data can be inside an object with no control at all - // they are used for process only - // i leave it in case it will become a non sens - // invalidefor.push('ERRFIELD unknown of referentials ' + field); - } else { - if( objectdef[ field ].check ) { - // check data with rule list in check - objectdef[ field ].check.forEach( ctrl => { - console.log( 'ctrl', ctrl ); - contexte.currentfield = field; - if( !checkdata.test[ ctrl ] ) { - invalidefor.push( 'ERR check function does not exist :' + ctrl + '___' + field ) - } else { - if( !checkdata.test[ ctrl ]( contexte, data[ field ] ) ) - invalidefor.push( 'ERR' + ctrl + '___' + field ); - } - } ); - } - - if( objectdef[ field ].nouserupdate ) { - // check if user can modify this information - console.log( - 'evaluation :' + field + ' -- ' + objectdef[ field ].nouserupdate, - eval( objectdef[ field ].nouserupdate ) - ); - const evalright = eval( objectdef[ field ].nouserupdate ); - objectdef[ field ].nouserupdate = evalright; - } - } - } ); - console.log( { - invalidefor, - data - } ); - return { - invalidefor, - data - }; +check.normalize.zfill10 = (ctx, num) => { + let s = num + ""; + while (s.length < 10) s = "0" + s; + return s; }; -if( typeof module !== 'undefined' ) module.exports = checkdata; +if (typeof module !== "undefined") module.exports = check; diff --git a/nationchains/socialworld/contracts/lg/checkdata_en.json b/nationchains/socialworld/contracts/lg/checkdata_en.json new file mode 100644 index 0000000..119f72b --- /dev/null +++ b/nationchains/socialworld/contracts/lg/checkdata_en.json @@ -0,0 +1,5 @@ +{ + "typedoesnnotexistinschema":"This type in your propertie is not manage by checkdata.js", + "dataerrpropertie":"Check your data that not fit your schema rules propertie", + "dataerrpropertiesrequired":"This propertie is required and not present in your data" +} \ No newline at end of file diff --git a/nationchains/socialworld/contracts/nation_base.js b/nationchains/socialworld/contracts/nation_base.js new file mode 100644 index 0000000..fbe091a --- /dev/null +++ b/nationchains/socialworld/contracts/nation_base.js @@ -0,0 +1,36 @@ +/* +Ants nation contract +*/ + +const Contract={ + object:"nation", + id:"ants", + version:"0.0.0", + dt_create:"20230307", + dt_update:"", + info:"https://apxtrib.crabdance.com/nation_base.html", +}; + +Contract.trigger = ()=>{ + // Identification of rule to trig + // Create token for a tribe => +} + +Contract.druidAllowedtoCreateToken = (tokenconf, hashtokenconf)=>{ + /* + @tokenconf ={ + tokenvalue: float value in apxtr, + quantity: int number of token, + druidId: uuid, + costrequest: float cost of this in apxtr to the mayorId + } + Check balance druid wallet + @return {status:200, data:{transacId:blocktimestamp,tokens:[token1, token2, ...]} + {status:<>200, info:'error message'} + Store transaction in open block with transacId + A token = druidUuid_hash(with blockchain elected privatekey) + Druid can sale his token with his rules at a tribe level but any user that request an exchange ffrom a token + */ +} + +module.exports = Contract; \ No newline at end of file diff --git a/nationchains/socialworld/contracts/toolsbox.js b/nationchains/socialworld/contracts/toolsbox.js index 97f9597..76e3c5d 100755 --- a/nationchains/socialworld/contracts/toolsbox.js +++ b/nationchains/socialworld/contracts/toolsbox.js @@ -6,7 +6,7 @@ const moment = require( 'moment' ); const config = require( '../config' ); const utils = {}; -console.log( "Check in /utils/index.js to find usefull function for your dev.\n Feel free to send suggestion, code to maintainer of apixtribe project (see /package.json to get email).\n We'll add to the roadmap to add it." ); +console.log( "Check in /utils/index.js to find usefull function for your dev.\n Feel free to send suggestion, code to maintainer of apxtrib project (see /package.json to get email).\n We'll add to the roadmap to add it." ); /** * EMAIL diff --git a/nationchains/socialworld/contracts/town_base.js b/nationchains/socialworld/contracts/town_base.js new file mode 100644 index 0000000..d40639a --- /dev/null +++ b/nationchains/socialworld/contracts/town_base.js @@ -0,0 +1,36 @@ +/* +Town contract:town_base +*/ + +const Contract={ + object:"town", + id:"town_base", + version:"0.0.0", + dt_create:"20230307", + dt_update:"", + info:"https://apxtrib.crabdance.com/town_base.html", +}; + +Contract.trigger = ()=>{ + // Identification of rule to trig + // Create token for a tribe => +} + +Contract.druidAllowedtoCreateToken = (tokenconf, hashtokenconf)=>{ + /* + @tokenconf ={ + tokenvalue: float value in apxtr, + quantity: int number of token, + druidId: uuid, + costrequest: float cost of this in apxtr to the mayorId + } + Check balance druid wallet + @return {status:200, data:{transacId:blocktimestamp,tokens:[token1, token2, ...]} + {status:<>200, info:'error message'} + Store transaction in open block with transacId + A token = druidUuid_hash(with blockchain elected privatekey) + Druid can sale his token with his rules at a tribe level but any user that request an exchange ffrom a token + */ +} + +module.exports = Contract; \ No newline at end of file diff --git a/nationchains/socialworld/contracts/unittest/checkdata.js b/nationchains/socialworld/contracts/unittest/checkdata.js new file mode 100644 index 0000000..21920b8 --- /dev/null +++ b/nationchains/socialworld/contracts/unittest/checkdata.js @@ -0,0 +1,146 @@ +/* +Unit testing +*/ +const assert = require("assert"); +const checkdata = require("../checkdata.js"); + +const ut = { name: "checkdata" }; + +const schema = { + $schema: "http://json-schema.org/schema#", + title: "Dummy schema to test checkdata.js", + description: "Checkdata is use on server as well as into a browser", + $comment: "We change schema type on the fly to simplify the test", + type: "Object", + properties: { + totest: {}, + }, +}; +const testproperties = [ + { + name: "test1", + data: { totest: "blabla" }, + properties: { totest: { type: "string" } }, + status: 200 + }, + { + name: "test2", + data: { totest: 123 }, + properties: { totest: { type: "string" } }, + status: 417 + }, + { + name: "test3", + data: { totest: 123.13 }, + properties: { totest: { type: "integer" } }, + status: 417 + }, + { + name: "test4", + data: { totest: 123 }, + properties: { totest: { type: "number" } }, + status: 200 + }, + { + name: "test5", + data: { totest: 12312 }, + properties: { totest: { type: "number" } }, + status: 200 + }, + { + name: "test6", + data: { totest: 12.313 }, + properties: { totest: { type: "float" } }, + status: 200 + }, + { + name: "test7", + data: { totest: "blablab sfde" }, + properties: { totest: { type: "string", minLength: 1111 } }, + status: 417 + }, + { + name: "test8", + data: { totest: "blablab sfde" }, + properties: { totest: { type: "string", minLength: 4, maxLength: 128} }, + status: 200 + }, + { + name: "test9", + data: { totest: 12 }, + properties: { totest: { type: "integer", multipleOf:3} }, + status: 200 + }, + { + name: "test10", + data: { totest: 9 }, + properties: { totest: { type: "number", minimum:-10, exclusiveMaximum:10} }, + status: 200 + }, + { + name: "test11", + data: { totest: 10 }, + properties: { totest: { type: "number", minimum:-10, exclusiveMaximum:10} }, + status: 417 + }, + { + name: "test12", + data: { totest: "gfhrtabcdgfr" }, + properties: { totest: { type: "string", pattern:/.*abc.*/} }, + status: 200 + }, + { + name: "test13", + data: { totest: "toto@google.com" }, + properties: { totest: { type: "string", format:"email"} }, + status: 200 + }, + { + name: "test14", + data: { totest: "Aze123@0" }, + properties: { totest: { type: "string", format:"password"} }, + status: 200 + }, + { + name: "test15", + data: { totest: "value1" }, + properties: { totest: { type: "string", enum:["value1","value2","value3"]} }, + status: 200 + }, + { + name: "test16", + data: { totest: ["t1","t2"] }, + properties: { totest: { type: ["string", "number"] }}, + status: 417 + } + , + { + name: "test17", + data: { totest: 12 }, + properties: { totest: { type: ["string", "number"] }}, + status: 200 + } +]; + +ut.testproperties = (options) => { + let msg = ""; + testproperties.forEach((t) => { + schema.properties = t.properties; + const res = checkdata.schema.data(schema, {}, t.data); + if (res.status != t.status) { + msg = (msg == "") ? "Unconsistent testproperties() name list: " : `${msg},`; + if (options.verbose) { + console.log(t) + console.log(res); + } + msg += res.err.map((e) => ` ${t.name} ${e.info}`); + } + }); + return assert.deepEqual(msg, "", msg); +}; + +ut.run = (options) => { + console.log("Test checkdata properties"); + ut.testproperties(options); +}; +module.exports = ut; diff --git a/nationchains/socialworld/metaobject/nation.json b/nationchains/socialworld/metaobject/nation.json deleted file mode 100644 index 94c8b2d..0000000 --- a/nationchains/socialworld/metaobject/nation.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "idfield": "name", - "nouserupdate": true, - "nouservisible": true, - "desc": { - "fr": "Nom unique d'une nation dans un monde social", - "en": "A unique nation name in a social world" - }, - "desclong": { - "fr": "Nom unique identifiant une nation dans le monde social créer par un maire d'une nouvelle ville avec un contrat sociale specifique", - "en": "Unique nation name in the social world created by a mayor of a town." - }, - "info": { - "fr": "

Une nation posséde un nom unique, un contrat sociale (contracts/name.js) signé et validé par tous les maires des villes associées à cette nation

", - "en": "

A nation is defined by this unique name and a contratcs/nationname.js signed by each town's major define the common nation rules

" - }, - "check": ["required", "unique"], - "type": "text", - "questioncollecte":"questioninput", - "searchindex":["all"] - }, - { - "idfield": "nationtype", - "searchindex": ["name"], - "check": ["required"], - "desc": { - "fr": "Type de nation" - }, - "default": "ACTIVE", - "type": "data", - "questioncollect": "questionselect", - "data": "state.json" - }, - -] \ No newline at end of file diff --git a/nationchains/socialworld/metaobject/pagans.json b/nationchains/socialworld/metaobject/pagans.json deleted file mode 100755 index 58fae87..0000000 --- a/nationchains/socialworld/metaobject/pagans.json +++ /dev/null @@ -1,265 +0,0 @@ -[{ - "idfield": "UUID", - "nouserupdate": true, - "nouservisible": true, - "desc": { - "fr": "identifiant utilisateur", - "en": "user id" - }, - "desclong": { - "fr": "Identifiant unique généré via UUID v4", - "en": "unique Id from a UUID v4" - }, - "info": { - "fr": "

L'usage d'UUID v4 permet de générer un code unique sans centralisation, car il est basé sur un timestamp et une clé crypto ce qui donne un code du type 7d8291c0-e137-11e8-9f7b-1dc8e57bed33

", - "en": "

UUID v4 allow a client to generate a unique code without centralisation, base on a timestamp and a salt it looks like 7d8291c0-e137-11e8-9f7b-1dc8e57bed33

" - }, - "check": ["required", "unique"], - "type": "text", - "tpl": "input" - }, - { - "idfield": "LOGIN", - "nouserupdate": true, - "check": ["required", "unique"], - "desc": { - "fr": "login", - "en": "login" - }, - "type": "text", - "tpl": "input", - "info": { - "fr": "

Le login doit être unique sur une instance d'apixtribe.

Pour échanger en dehors d'une instance apixtribe on utilise la clé public du user ou pour un humain login@apixtribe.domain.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", - "en": "

Login have to be unique into an apixtribe instance

To exchange outside of an apixtribe instance, we use PublicKey or login@apixtribe.domain.xx or login@domainclient.xx where domain.xx is a apixtribe name server on internet and domain.xx is a tribeid name where a /tribeid/www is available on the net.

" - } - }, - { - "idfield": "BIOGRAPHY", - "desc": { - "fr": "Vous en quelques mots", - "en": "Few words" - }, - "placeholder": { - "fr": "", - "en": "" - }, - "rows": 2, - "tpl": "textarea" - }, - { - "nouserupdate": true, - "idfield": "PUBLICKEY", - "desc": { - "fr": "Votre clé public pour ce compte", - "en": "Your public key for this uuid" - }, - "info": { - "fr": "

Cette clé est générée par votre navigateur, garder précisuesement votre clé privée que seule vous connaissez. En cas de perte de cette clé tous vos actifs seront perdus.

Cette méthode nous permet de vous garantir un contrôle total décentralisé.

", - "en": "

This key was generated by your browser, keep the private key related to this public key.

We garanty your total control by this way

." - }, - "tpl": "textarea" - }, - { - "idfield": "IMGAVATAR", - "tpl": "inputimg", - "altimg": "image avatar", - "classimg": "rounded-circle img-responsive mt-2", - "width": 128, - "height:" - 128, - "classdivupload": "mt-2", - "classbtn": "btn-primary", - "desc": { - "fr": "changer votre avatar", - "en": "upload an avatar" - }, - "info": { - "fr": "Pour un meilleur rendu, une mage carré de 128pc en foat jpg", - "en": "For best results, use an image at least 128px by 128px in .jpg format" - }, - - }, - { - "idfield": "EMAIL", - "desc": { - "fr": "email", - "en": "email" - }, - "tpl": "input", - "type": "email", - "check": ["emailadress", "unique"], - "placeholder": { - "fr": "#@", - "en": "@" - } - }, - { - "idfield": "PHONE", - "desc": { - "fr": "Tel", - "en": "Phone" - }, - "check": ["phone"] - "tpl": "input", - "type": "text" - }, - { - "idfield": "NAME", - "desc": { - "fr": "Nom", - "en": "Name" - }, - "tpl": "input", - "type": "text" - }, - { - "idfield": "FIRSTNAME", - "desc": { - "fr": "Prénom", - "en": "First Name" - }, - "tpl": "input", - "type": "text" - }, - { - "idfield": "NICKNAME", - "desc": { - "fr": "Pseudo", - "en": "Nickname" - }, - "tpl": "input", - "type": "text" - }, - "info": { - "fr": "

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apixtribe

Attention ce nom n'est unique que sur une instance d'apixtribe. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", - "en": "

Carrefull a pseudo is unique into an instance of apixtribe to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

" - }, - "tpl": "input", - "type": "text" -}, { - "idfield": "COMPANYNAME", - "desc": { - "fr": "Nom de Société", - "en": "Compagnie name" - }, - "tpl": "input", - "type": "text" -}, { - "idfield": "BILLINGADD", - "desc": { - "fr": "Adresse complete de facturation par defaut", - "en": "Full billing adress default" - }, - "tpl": "input", - "type": "text", - "placeholder": { - "fr": "1 chemin du paradis - 91430 IGNY France", - "en": "123 Main St- 123MZ -Oxford UK" - } -}, { - "idfield": "DELIVERYADD", - "desc": { - "fr": "Adresse complete de livraison par defaut", - "en": "Full delivery adress default" - }, - "tpl": "input", - "type": "text", - "placeholder": { - "fr": "1 chemin du paradis - 91430 IGNY France", - "en": "123 Main St- 123MZ -Oxford UK" - } -}, { - "idfield": "ADDRESS1", - "desc": { - "fr": "Adresse", - "en": "Address" - }, - "tpl": "input", - "type": "text", - "placeholder": { - "fr": "1 chemin du paradis", - "en": "123 Main St" - } -}, { - "idfield": "ADDRESS2", - "desc": { - "fr": "Adresse 2", - "en": "Address 2" - }, - "tpl": "input", - "type": "text", - "placeholder": { - "fr": "Appartement B", - "en": "Apt B" - } -}, { - "idfield": "CITY", - "desc": { - "fr": "Ville ", - "en": "CITY" - }, - "tpl": "input", - "type": "text" -}, { - "idfield": "ZIP", - "desc": { - "fr": "Code Postal", - "en": "ZIP" - }, - "tpl": "input", - "type": "text" -}, { - "idfield": "COUNTRY", - "desc": { - "fr": "Pays", - "en": "Country" - }, - "tpl": "input", - "type": "text" -}, { - "nouserupdate": true, - "idfield": "DATE_CREATE", - "desc": { - "fr": "Date de création", - "en": "Create Date" - }, - "tpl": "date", - "format": "YYYY-MM-DD", - "default": "moment(new Date()).format('YYYY-MM-DD')" -}, { - "nouserupdate": true,o - "idfield": "DATE_UPDATE", - "desc": { - "fr": "Date mise à jour", - "en": "Update date" - }, - "tpl": "date", - "format": "YYYY-MM-DD", - "default": "moment(new Date()).format('YYYY-MM-DD')" -}, { - "nouserupdate": true, - "idfield": "DATE_LASTLOGIN", - "desc": { - "fr": "Date de derniére connexion", - "en": "Last date login" - }, - "tpl": "date", - "format": "YYYY-MM-DD", - "default": "moment(new Date()).format('YYYY-MM-DD')" -}, { - "idfield": "ACCESSRIGHTS", - "nouserupdate": true, - "desc": { - "fr": "Vos droits d'accès", - "en": "Your access rights" - }, - "default": { - "app": {}, - "data": { - "tribeidname": { - "users": "O" - } - } - }, - "tpl": "jsoneditor" -}] diff --git a/nationchains/socialworld/metaobject/towns.json b/nationchains/socialworld/metaobject/towns.json deleted file mode 100644 index 0637a08..0000000 --- a/nationchains/socialworld/metaobject/towns.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/ants.json b/nationchains/socialworld/objects/nations/ants.json index 154bb6e..89ae2ec 100644 --- a/nationchains/socialworld/objects/nations/ants.json +++ b/nationchains/socialworld/objects/nations/ants.json @@ -1,7 +1,5 @@ -{"UUID":"ants", -"publickey":"123", -"status":"open", -"domain":["antsnation.mooo.com"], -"svg":"", -"towns":["hill"] +{ + "nationId":"ants", + "dtcreate":"2023-03-19T14:05:00+02:00", + "contracts":"socialworld/contracts/nation_base.js" } \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/escape.json b/nationchains/socialworld/objects/nations/escape.json deleted file mode 100644 index f9c28d3..0000000 --- a/nationchains/socialworld/objects/nations/escape.json +++ /dev/null @@ -1,5 +0,0 @@ -{"UUID":"escape", -"publickey":"123", -"status":"open", -"towns":["game"] -} \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/searchindex/nations_nationId_all.json b/nationchains/socialworld/objects/nations/searchindex/nations_nationId_all.json new file mode 100644 index 0000000..998a8dd --- /dev/null +++ b/nationchains/socialworld/objects/nations/searchindex/nations_nationId_all.json @@ -0,0 +1,6 @@ +{"ants":{ + "nationId":"ants", + "publickey":"123", + "status":"unchain", + "svg":"" +}} \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/searchindex/nationslist.json b/nationchains/socialworld/objects/nations/searchindex/nationslist.json deleted file mode 100644 index 6843706..0000000 --- a/nationchains/socialworld/objects/nations/searchindex/nationslist.json +++ /dev/null @@ -1 +0,0 @@ -["escapenation"] \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/searchindex/tribeslist.json b/nationchains/socialworld/objects/nations/searchindex/tribeslist.json deleted file mode 100644 index 0ef9f40..0000000 --- a/nationchains/socialworld/objects/nations/searchindex/tribeslist.json +++ /dev/null @@ -1 +0,0 @@ -{"archilinea":["escapenation","game"]} \ No newline at end of file diff --git a/nationchains/socialworld/objects/nations/searchindex/townslist.json b/nationchains/socialworld/objects/schema/accessright.json similarity index 100% rename from nationchains/socialworld/objects/nations/searchindex/townslist.json rename to nationchains/socialworld/objects/schema/accessright.json diff --git a/nationchains/socialworld/objects/schema/lg/nations_en.json b/nationchains/socialworld/objects/schema/lg/nations_en.json new file mode 100644 index 0000000..47d4e54 --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/nations_en.json @@ -0,0 +1,19 @@ +{ + "title":"Nation definition", + "description":"A nation from apXtrib social world", + "$comment":"", + "properties":{ + "nationId":{ + "title":"Unique nation name", + "description":"A unique string that define a nation a-z and 0-9 onlyin a social world" + }, + "dtcreate":{ + "title":"Creation date", + "description":"Nation date of creation" + }, + "contracts":{ + "title":"Social contract of the nation", + "description":"A uri of the signed js contract that rules this nation" + } + } +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/lg/nations_fr.json b/nationchains/socialworld/objects/schema/lg/nations_fr.json new file mode 100644 index 0000000..8b2739b --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/nations_fr.json @@ -0,0 +1,7 @@ +{ + "nationnamedesc":"Nom unique d'une nation dans un monde social", + "nationnamedesclong":"Nom unique identifiant une nation dans le monde social créer par un maire d'une nouvelle ville avec un contrat sociale specifique", + "nationnameinfo":"

Une nation posséde un nom unique, un contrat sociale (contracts/name.js) signé et validé par tous les maires des villes associées à cette nation

", + "statusdesc":"Statut de la nation", + "statusactive":"Nation active" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/lg/pagans_en.json b/nationchains/socialworld/objects/schema/lg/pagans_en.json new file mode 100644 index 0000000..2664fda --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/pagans_en.json @@ -0,0 +1,42 @@ +{ + "ERRcritical": "Critical Error", + "loginAlreadyExist": "Login already exists", + "emailAlreadyExist":"Email already exists", + "failtoWritefs":"Fail to write on system", + "successfullCreate": "Successfully created", + "successfullDelete": "Successfully deleted", + "serverNeedAuthentification":"This server needs authentification", + "forbiddenAccess":"Forbidden Access", + "userNotAllowtoCreate":"User is not allow to create", + "userNotAllowtoUpdate":"User is not allow to update", + "userNotAllowtoDelet":"User is not allow to delete", + "uuidNotFound":"Paggans {{uuid}} not found for {{tribeName}}", + "useremailNotfound":"Email not found", + "loginDoesNotExist":" Login does not exist", + "checkCredentials":" Check yopur credentials" + "wrongPassword":"Check your password", + "invalidData":"Check your data", + "pswToosimple":"Password too simple, need to contain at least 8 caracters lower and uppercase, number and @! ...", + "ERRemail":"Check your email", + "ERRnewnewbisdiff":"Both password are not the same", + "paganiddesc":"unique id", + "paganiddesclong":"Unique Identification based on UUID.v4()", + "paganidinfo":"

UUID v4 allow a client to generate a unique code without centralisation, base on a timestamp and a salt it looks like 7d8291c0-e137-11e8-9f7b-1dc8e57bed33

", + "logindesc":"login", + "logininfo":"

Login have to be unique into a town (composed of letter: a to z and 0 to 9)

To exchange outside of a town, we use PublicKey / uuid or login@tribeId.townId.nationId.dns

", + "pswdesc":"A strong password minimum 8char uper lower number specialm char", + "biographydesc":"Few words about you", + "publickeyinfo":"

This key was generated by your browser, keep the private key related to this public key.

We garanty your total control by this way

.", + "imgavatardesc":"Upload an avatar", + "imgavatarinfo":"For best results, use an image at least 128px by 128px in .jpg format", + "emaildesc":"Email de recuperation de mot de passe", + "telephonedesc":"Phone", + "familyNamedesc":"Last name", + "givenNamedesc":"First name", + "additionalNamedesc":"Nickname", + "additionalNamesinfo":"

Carrefull a pseudo is unique into an instance of apxtrib to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

", + "dtcreatedesc":"Creation date", + "dtupdatedesc":"last update", + "dtlastlogindesc":"Last login access", + "accessrightsdesc":"Your accessrigts" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/lg/pagans_fr.json b/nationchains/socialworld/objects/schema/lg/pagans_fr.json new file mode 100644 index 0000000..e07ba59 --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/pagans_fr.json @@ -0,0 +1,41 @@ +{ + "ERRcritical": "Erreur critique", + "loginAlreadyExist": "Ce login exist déjà", + "emailAlreadyExist":"Cet email exist déjà", + "failtoWritefs":"Impossible d'ecrire sur le serveur", + "successfullCreate": "Création réussit", + "successfullDelete": "Mise à jour effectuée", + "serverNeedAuthentification":"Ce serveur a besoin d'une authentification", + "forbiddenAccess":"Accès interdit", + "userNotAllowtoCreate":"Pas d'autorisation de creation", + "userNotAllowtoUpdate":"Pas d'autorisatiuon de mise à jour", + "userNotAllowtoDelet":"Pas d'autorisation de suppression", + "uuidNotFound":"Le paîen {{uuid}} n'existe pas dans la tribu {{tribeName}}", + "useremailNotfound":"Email introuvable", + "loginDoesNotExist":" Login introuvable", + "checkCredentials":" Vérifier vos parametres d'accès" + "wrongPassword":"Vérifier votre mot de passe", + "invalidData":"Vérifier vos données", + "pswToosimple":"Votre mot de passe est trop simple, doit contenir au moins 8 caractères avec des lettres majusculmes, minuscules des nombres et au moins un caractere special @! ...", + "ERRemail":"Vérifier votre email", + "ERRnewnewbisdiff":"Les 2 mots de passe ne sont pas identique", + "uuiddesc":"Identifiant", + "uuiddesclong":"Identifiant unique au format UUID.v4()", + "uuidinfo":"

L'usage d'UUID v4 permet de générer un code unique sans centralisation, car il est basé sur un timestamp et une clé crypto ce qui donne un code du type 7d8291c0-e137-11e8-9f7b-1dc8e57bed33

", + "logindesc":"login", + "logininfo":"

Le login doit être unique sur une instance d'apxtrib.

Pour échanger en dehors d'une instance apxtrib on utilise la clé public du user ou pour un humain login@trib.town§.nation.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", + "biographydesc":"Vous en quelques mots", + "publickeyinfo":"

Cette clé est générée par votre navigateur, garder précisuesement votre clé privée que seule vous connaissez. En cas de perte de cette clé tous vos actifs seront perdus.

Cette méthode nous permet de vous garantir un contrôle total décentralisé.

", + "imgavatardesc":"Changer votren avatar", + "imgavatarinfo":"Pour un meilleur rendu, une mage carré de 128pc en foat jpg", + "emaildesc":"Email", + "telephonedesc":"Tel", + "familyNamedesc":"Nom", + "givenNamedesc":"Prénom", + "additionalNamedesc":"Pseudo", + "additionalNamesinfo":"

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apxtrib

Attention ce nom n'est unique que sur une instance d'apxtrib. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", + "dtcreatedesc":"Date de creation", + "dtupdatedesc":"Dernière mise à jour", + "dtlastlogindesc":"Dernier accès au login", + "accessrightsdesc":"Vos droits d'accès" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/lg/towns_en.json b/nationchains/socialworld/objects/schema/lg/towns_en.json new file mode 100644 index 0000000..dd9bc35 --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/towns_en.json @@ -0,0 +1,8 @@ +{ + "townnamedesc":"A unique town name in a nation for a social world", + "townnamedesclong":"Unique town name in the social world created by a mayor.", + "townnameinfo":"

A town is defined by this unique name and a contratcs/townname.js signed by each druid that create a tribe inside this town

", + "antsnationdesc":"ants nation", + "statusdesc":"Town's status", + "statusactive":"Active Town" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/lg/towns_fr.json b/nationchains/socialworld/objects/schema/lg/towns_fr.json new file mode 100644 index 0000000..227eca7 --- /dev/null +++ b/nationchains/socialworld/objects/schema/lg/towns_fr.json @@ -0,0 +1,8 @@ +{ + "townnamedesc":"Nom unique d'une ville dans une nation", + "townnamedesclong":"Nom unique identifiant une ville dans une nation d'un monde social, créer par un maire d'une nouvelle ville avec un contrat sociale specifique", + "townnameinfo":"

Une ville posséde un nom unique, un contrat sociale (contracts/name.js) signé et validé par tous les maires des villes associées à cette nation

", + "antsnationdesc":"nation des ants", + "statusdesc":"Statut de la ville", + "statusactive":"Ville active" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/schema/nations.json b/nationchains/socialworld/objects/schema/nations.json new file mode 100644 index 0000000..0bd8dc8 --- /dev/null +++ b/nationchains/socialworld/objects/schema/nations.json @@ -0,0 +1,28 @@ +{ + "$schema":"http://json-schema.org/schema#", + "$id":"nationchains/socialworld/objects/schema/nations", + "title": "Nation definition", + "description": "A nation from apXtrib world", + "$comment":"see ./lg/nations_lg.json for description in your languange lg", + "type": "object", + "properties": { + "nationId": { + "type": "string", + "pattern":"^[a-z0-9]*$" + }, + "dtcreate": { + "type": "string", + "format":"datetime" + }, + "contracts":{ + "type": "string", + "format":"uri" + } + }, + "required": ["nationId", "dtcreate","contracts"], + "additionalProperties":false, + "apxprimarykey":"nationId", + "apxsearchindex": [ + { "key": "nationId", "value": [] } + ] +} diff --git a/nationchains/socialworld/objects/schema/pagans.json b/nationchains/socialworld/objects/schema/pagans.json new file mode 100755 index 0000000..239756a --- /dev/null +++ b/nationchains/socialworld/objects/schema/pagans.json @@ -0,0 +1,86 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "socialworld/schema/pagans", + "title":"Pagan definition", + "description": "A pagan is an uuid to manage identity by deliver a way to its owner to proof he owns from a privatekey in the socialworld of apXtrib and manage access keys deliver by druid or mayor to interact physical ressource (CRUD on it).", + "type": "objects", + "properties":{ + "paganId":{ + "description": "|Pagans|paganiddesc", + "apxdesclong": "|Pagans|paganiddesclong" + "apxinfo":"|Pagans|paganidinfo", + "type": "string", + "apxtype":"uuidv4" + }, + "login":{ + "description": "|Pagans|logindesc", + "type": "string", + "pattern":"^[a-z0-9]*$", + "apxinfo": "|Pagans|logininfo" + }, + "password":{ + "description": "|Pagans|pswdesc", + "type": "string" + }, + "townId":{ + "description":"", + "type":"string", + "$apxenumkey": "socialworld/objects/nations/searchindex/towns_townId_all.json" + }, + "tribeId":{ + "description":"", + "type":"string", + "$apxenumkey": "tribes/objects/tribes/searchindex/tribes_tribeId_all.json" + }, + "publicKey":{ + "description": "|Pagans|publickeydesc", + "type":"string", + "apxinfo": "|Pagans|publickeyinfo" + }, + "biography":{ + "description": "|Pagans|biographydesc", + "type":"string", + "pattern":"^.{O,150}$" + }, + "imgavatar":{ + "description": "|Pagans|imgavatardesc", + "apxinfo": "|Pagans|imgavatarinfo", + "type":"string", + "apxtype":"file" + }, + "emailrecup":{ + "description":"|Pagans|emaildesc", + "tpl": "input", + "type": "email", + "check": ["emailadress", "unique"], + }, + "dtcreate":{ + "description": "|Pagans|dtcreatedesc", + "type":"string", + "pattern":"^[0-9]{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$", + "default": "moment(new Date()).format('YYYY-MM-DD')" +},"dtupdate": { + "description": "|Pagans|dtupdatedesc", + "type":"string", + "pattern":"^[0-9]{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$", + "default": "moment(new Date()).format('YYYY-MM-DD')" +},"dtlastlogin" { + "description": "|Pagans|dtlastlogindesc", + "type":"string", + "pattern":"^[0-9]{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$", + "default": "moment(new Date()).format('YYYY-MM-DD')" +},"accessrights": { + "description": "|Pagans|accessrightsdesc", + "type":"object", + "$ref":"socialworld/schema/accessright.json" + } +}, +"required": ["paganId","login","townId", "tribeId"], +"apxprimarykey": "paganId", +"apxunique":["login"], +"apxsearchindex": [ + { "key": "login", "value": "paganId" }, + { "key": "email", "value": "paganId" }, + { "key": "token", "value": "paganId" } +] + } diff --git a/nationchains/socialworld/objects/schema/towns.json b/nationchains/socialworld/objects/schema/towns.json new file mode 100644 index 0000000..3569440 --- /dev/null +++ b/nationchains/socialworld/objects/schema/towns.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "socialworld/objects/schema/towns", + "title": "Town", + "description": "A town belonging to a nation from apXtrib world", + "type": "object", + "properties": { + "townId": { + "description": "|Towns|townnamedesc", + "desclong": "|Townss|townnamedesclong", + "info": "|Towns|townnameinfo", + "type": "string", + "pattern":"^[a-z0-9]*$" + }, + "nationId": { + "description": "|Towns|nationdesc", + "desclong": "|Townss|nationdesclong", + "type": "string", + "$apxenumkey": "socialworld/objects/nations/searchindex/nations_uuid_uuid.json" + }, + "status": { + "desc": "|Towns|statusdesc", + "default": "active", + "type": "string", + "$apxenumkey": "data", + "data": { + "chain": { "desc": "|Towns|statuschain" }, + "tochain": { "desc": "|Towns|statustosync" }, + "unchain": { "desc": "|Towns|statusunchain" } + } + }, + "url": { + "desc": "|Towns|urldesc", + "type": "string", + "apxtype":"url" + } + }, + "required": ["townId", "status", "nationId", "url"], + "apxprimarykey": "townId", + "apxsearchindex": [ + { "key": "status", "value": "townId" }, + { "key": "nationId", "value": "townId" }, + { "key": "townId", "value": [] } + ] +} diff --git a/nationchains/socialworld/objects/towns/game.json b/nationchains/socialworld/objects/towns/game.json deleted file mode 100644 index a6ece87..0000000 --- a/nationchains/socialworld/objects/towns/game.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "url":"https://escape.game.apixtribe.org", - "IP":"213.32.65.213", - "mayorid":"123", - "status":"" - "tribes":[] - } \ No newline at end of file diff --git a/nationchains/socialworld/objects/towns/hill.json b/nationchains/socialworld/objects/towns/hill.json new file mode 100644 index 0000000..27738f0 --- /dev/null +++ b/nationchains/socialworld/objects/towns/hill.json @@ -0,0 +1,9 @@ +{ + "id":"hill", + "nationid":"ants", + "contract":"town_base", + "url":"https://hill.ants.mooo.com", + "IP":"213.32.65.213", + "mayorid":"123", + "status":"" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json b/nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json new file mode 100644 index 0000000..1d3e764 --- /dev/null +++ b/nationchains/socialworld/objects/towns/searchindex/towns_nationId_townId.json @@ -0,0 +1 @@ +{"ants":["hill","wall"]} \ No newline at end of file diff --git a/nationchains/socialworld/objects/towns/searchindex/towns_townId_all.json b/nationchains/socialworld/objects/towns/searchindex/towns_townId_all.json new file mode 100644 index 0000000..812f098 --- /dev/null +++ b/nationchains/socialworld/objects/towns/searchindex/towns_townId_all.json @@ -0,0 +1,16 @@ +{"hill":{ + "townId":"hill", + "nationId":"ants", + "url":"https://hill.ants.mooo.com", + "IP":"213.32.65.213", + "mayorid":"123", + "status":"" +},"wall":{ + "townId":"wall" + "nationid":"ants", + "url":"https://wall.ants.mooo.com", + "IP":"213.32.65.213", + "mayorid":"123", + "status":"" +} +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/towns/wall.json b/nationchains/socialworld/objects/towns/wall.json new file mode 100644 index 0000000..547ee92 --- /dev/null +++ b/nationchains/socialworld/objects/towns/wall.json @@ -0,0 +1,9 @@ +{ + "id":"wall", + "nationid":"ants", + "contract":"town_base", + "url":"https://wall.ants.mooo.com", + "IP":"213.32.65.213", + "mayorid":"123", + "status":"" +} \ No newline at end of file diff --git a/nationchains/socialworld/objects/tribes/searchindex/tribeslist.json b/nationchains/socialworld/objects/tribes/searchindex/tribeslist.json deleted file mode 100644 index e69de29..0000000 diff --git a/nationchains/socialworld/setup/townSetup.json b/nationchains/socialworld/setup/townSetup.json new file mode 100755 index 0000000..33555bf --- /dev/null +++ b/nationchains/socialworld/setup/townSetup.json @@ -0,0 +1,11 @@ +{ + "sudoerUser": "phil", + "nationName":"ants", + "townName":"devndda", + "tribeName":"devndda", + "dns":"unchain", + "paganslogin":"pat", + "apiport": 3018, + "language": ["fr", "en"], + "jwtsecret": "longsentenceusedtoencryptionChangethisforproduction" +} \ No newline at end of file diff --git a/nationchains/socialworld/setup/townconf.json b/nationchains/socialworld/setup/townconf.json new file mode 100644 index 0000000..14de3fe --- /dev/null +++ b/nationchains/socialworld/setup/townconf.json @@ -0,0 +1,13 @@ +{ + "saltRounds":10, + "exposedHeaders":[ "xauth", "xpaganid", "xlang", "xtribe", "xworkon", "xapp" ], + "unittesting":["middlewares","models","routes","nationchains"], + "appset":{"trust proxy":true}, + "bodyparse": { + "urlencoded": { + "limit": "50mb", + "extended": true + }, + "json": { "limit": "500mb" } + } +} \ No newline at end of file diff --git a/nationchains/socialworld/setup/tribeconf.json b/nationchains/socialworld/setup/tribeconf.json new file mode 100755 index 0000000..cdb45fe --- /dev/null +++ b/nationchains/socialworld/setup/tribeconf.json @@ -0,0 +1,25 @@ +{ + "tribeid": "${tribeName}", + "genericpsw": "", + "saltRounds": "12", + "allowedDOMs": ["${townName}.${nationName}.${dns}"], + "customization": { + "claim": "Be a Producer, not a product.", + "name": "apxtrib", + "logo": "https://${townName}.${nationName}.${dns}/static/img/chartegraphique/logo_bgtransparent.png", + "favicon": "https://${townName}.${nationName}.${dns}/static/img//chartegraphique/favicon.png", + "colors": { + "primary": "#01717B", + "secondary": "#CA5F00", + "success": "", + "info": "", + "warning": "", + "danger": "", + "light": "#fff", + "dark": "#222" + } + }, + "smtp": {}, + "accepted-language": "fr,en", + "langueReferential": ["fr"] +} diff --git a/nationchains/town_base.html b/nationchains/town_base.html new file mode 100644 index 0000000..6b24452 --- /dev/null +++ b/nationchains/town_base.html @@ -0,0 +1,13 @@ + + + + + Town base contract + + + + +

Info sur le contrat de base d'une ville

+

+ + \ No newline at end of file diff --git a/package.json b/package.json index 1b38405..b1a06bf 100755 --- a/package.json +++ b/package.json @@ -4,21 +4,21 @@ "logo": { "file": "./nationchains/static/img/chartegraphique/logocarre_bgplein.png" }, - "description": "A standard conf api based on express.js with basic and usefull component to manage api project", + "description": "A Decentralized Autonomous Organization based on express.js restFULL api, allowing Pagans to join social rules (contracts.js) engrave in a nationsChains without any man in the middle.", "main": "apxtrib.js", "repository": { "url": "https://gitea.ndda.fr/apxtrib/apxtrib", "type": "git" }, "scripts": { - "apidoc": "apidoc -i routes/ -o apidoc/", "stoppm2": "pm2 stop apxtrib.js", "startpm2": "pm2 start apxtrib.js --log-date-format 'DD-MM HH:mm:ss.SSS'", "restartpm2": "pm2 restart apxtrib.js --log-date-format 'DD-MM HH:mm:ss.SSS'", "startblockchain": "pm2 start ./models/Blockchains.js --log-date-format 'DD-MM HH:mm:ss:SSS'", "logpm2": "pm2 logs apxtrib.js --lines 200", "setup": "node models/Setup.js", - "dev": "node apxtrib.js" + "dev": "node apxtrib.js", + "unittest": "node unittest.js" }, "apidoc": { "url": "https://apxtrib.crabdance.com/apidoc" diff --git a/routes/nationchains.js b/routes/nationchains.js index 9890e28..6086b5c 100755 --- a/routes/nationchains.js +++ b/routes/nationchains.js @@ -26,7 +26,7 @@ Manage a new towns in a nation => update nation:[nationname:towns:[]} contracts/ */ router.post( '/push', checkHeaders, ( req, res ) => { - // Get information from other apixtribe instance in req.body + // Get information from other apxtrib instance in req.body // check req.body.hashnext => means this is a candidate to validate next block // // return it's own information back with the last call to Nationchains.synchronize() diff --git a/routes/pagans.js b/routes/pagans.js index 4dc96ab..b8b3151 100755 --- a/routes/pagans.js +++ b/routes/pagans.js @@ -30,7 +30,7 @@ appname is a website space object /sitewebsrc/appname website live is strored into /dist source in /src This can be managed by maildigitcreator or not. -apixtribe/sitewebs/webapp is the webinterface of apixtribe +apxtrib/sitewebs/webapp is the webinterface of apxtrib profil: admin / manager / user are key word to give specific access to data into model. Any kind of other profil can exist. It is usefull to manage specific menu in an app. It is also possible to authorize update a field's object depending of rule into dataManagement/object/ diff --git a/routes/tribes.js b/routes/tribes.js index 94db2ef..416765e 100755 --- a/routes/tribes.js +++ b/routes/tribes.js @@ -15,11 +15,11 @@ const router = express.Router(); router.get( '/clientconf/:tribeid', checkHeaders, isAuthenticated, ( req, res ) => { /* get a clientconf.json for a tribeid depending of user accessright - if tribeid == all and user is admin of apixtribe => get /tmp/clientconfglob.json + if tribeid == all and user is admin of apxtrib => get /tmp/clientconfglob.json req.session.header.accessrights, req.session.header.apixpaganid */ console.log( `Tribes/clientconf for tribeid:${req.params.tribeid}` ) - if( req.params.tribeid == "all" && req.session.header.accessrights.data.apixtribe && req.session.header.accessrights.data.apixtribe.tribeid && req.session.header.accessrights.data.apixtribe.tribeid.includes( 'R' ) ) { + if( req.params.tribeid == "all" && req.session.header.accessrights.data.apxtrib && req.session.header.accessrights.data.apxtrib.tribeid && req.session.header.accessrights.data.apxtrib.tribeid.includes( 'R' ) ) { res.status( 200 ) .send( { moreinfo: fs.readJsonSync( `${config.tmp}/clientconfglob.json`, 'utf-8' ) } ); return; @@ -207,10 +207,10 @@ router.delete( '/file', checkHeaders, isAuthenticated, ( req, res ) => { router.post( '/uploadfile', checkHeaders, isAuthenticated, ( req, res ) => { console.log( 'upload a file ' ) /* Authentification is needed to get a TOKEN - curl -X POST -H "xtribe: apixtribe" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: 1" -H "xauth: 1" -H "xapp: pvmsaveurs:pvmsaveurs" -H "Content-Type: application/json" -d '{"LOGIN":"adminapixtribe","PASSWORD":"Trze3aze!"}' http://pvmsaveurs.pvmsaveurs.fr/app/users/login + curl -X POST -H "xtribe: apxtrib" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: 1" -H "xauth: 1" -H "xapp: pvmsaveurs:pvmsaveurs" -H "Content-Type: application/json" -d '{"LOGIN":"adminapxtrib","PASSWORD":"Trze3aze!"}' http://pvmsaveurs.pvmsaveurs.fr/app/users/login if exist replace xpaganidTOKEN with payload.TOKEN value - curl -H "xtribe: pvmsaveurs" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: adminapixtribe" -H "xauth: xpressuuisToken" -H "xapp: pvmsaveurs:pvmsaveurs" -F 'data=@filename.xx' http://pvmsaveurs.pvmsaveurs.fr/app/Tribes/uploadfile + curl -H "xtribe: pvmsaveurs" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: adminapxtrib" -H "xauth: xpressuuisToken" -H "xapp: pvmsaveurs:pvmsaveurs" -F 'data=@filename.xx' http://pvmsaveurs.pvmsaveurs.fr/app/Tribes/uploadfile */ const formidable = require( 'formidable' ); const form = formidable( { multiples: false } ); @@ -255,13 +255,13 @@ router.post( '/uploadzip', checkHeaders, ( req, res ) => { }, Example: cd where zip file is stored - curl -H "xtribe: pvmsaveurs" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: adminapixtribe" -H "xauth: 1" -H "xapp: pvmsaveurs:pvmsaveurs" -F 'data=@articlesTribespvm.zip' http://pvmsaveurs.pvmsaveurs.fr/app/Tribes/uploadzip + curl -H "xtribe: pvmsaveurs" -H "xworkon: pvmsaveurs" -H "xlang: fr" -H "xpaganid: adminapxtrib" -H "xauth: 1" -H "xapp: pvmsaveurs:pvmsaveurs" -F 'data=@articlesTribespvm.zip' http://pvmsaveurs.pvmsaveurs.fr/app/Tribes/uploadzip */ const clientconf = fs.readJSONSync( `${config.tribes}/${req.session.header.xworkon}/clientconf.json` ) if( !clientconf.uploadzip ) { return res.status( '404' ) - .send( { info: [ "missconf" ], models: "Tribes", moreinfo: `no uploadzip in clientconf for ${req.session.header.xworkon} please contact apixtribe admin ` } ); + .send( { info: [ "missconf" ], models: "Tribes", moreinfo: `no uploadzip in clientconf for ${req.session.header.xworkon} please contact apxtrib admin ` } ); }; const uploadzip = clientconf.uploadzip; const formidable = require( 'formidable' ); diff --git a/setup/ASUPconfig.jsold b/setup/ASUPconfig.jsold index 6337ae0..7c2ad41 100755 --- a/setup/ASUPconfig.jsold +++ b/setup/ASUPconfig.jsold @@ -3,7 +3,7 @@ const path = require( 'path' ); const fs = require( 'fs' ); const config = {}; if( !process.env.NODE_ENV ) process.env.NODE_ENV = "dev" -console.log( 'apixtribe process.env.NODE_ENV: ', process.env.NODE_ENV ); +console.log( 'apxtrib process.env.NODE_ENV: ', process.env.NODE_ENV ); // VOIR l'ancien fichier de cnfig au cas ou il manque des chemins dans config // voir la doc http://gitlab.ndda.fr/philc/apiamaildigitfr/wikis/InstallConf config.prod = { @@ -44,7 +44,7 @@ config.prod = { } }; // Development and test config -// apixtribe.local.fr +// apxtrib.local.fr config.dev = { mainDir: __dirname, @@ -52,13 +52,13 @@ config.dev = { public: path.join( __dirname, '/public' ), //public allow to serve on /public file into folder /public with or without login archivefolder: path.join( __dirname, '/archive' ), - rootURL: 'apixtribe.local.fr', + rootURL: 'apxtrib.local.fr', domain: path.join( __dirname, '/data/tribee' ), withssl: "YES", SSLCredentials: { - key: path.join( __dirname, '/setup/data/certs/apixtribe.local.fr.key' ), - cert: path.join( __dirname, '/setup/data/certs/apixtribe.local.fr.crt' ), - ca: path.join( __dirname, '/setup/data/certs/apixtribe.local.fr.csr' ) + key: path.join( __dirname, '/setup/data/certs/apxtrib.local.fr.key' ), + cert: path.join( __dirname, '/setup/data/certs/apxtrib.local.fr.crt' ), + ca: path.join( __dirname, '/setup/data/certs/apxtrib.local.fr.csr' ) }, port: { http: "{{httpport}}", diff --git a/setup/apixtribe.crabdance.com.mustache b/setup/apixtribe.crabdance.com.mustache index 473cb3c..5f6d03e 100755 --- a/setup/apixtribe.crabdance.com.mustache +++ b/setup/apixtribe.crabdance.com.mustache @@ -1,12 +1,12 @@ server { - server_name {{config.apixtribeDNS}}; + server_name {{config.apxtribDNS}}; add_header X-Request-ID $request_id; # Return to client add_header Access-Control-Allow-Origin *; add_header Access-Control-Max-Age 3600; add_header Access-Control-Expose-Headers Content-Length; add_header Access-Control-Allow-Headers Range; - access_log /media/phil/usbfarm/apixtribe/tmp/nginx/apixtribe.crabdance.access.log main; + access_log /media/phil/usbfarm/apxtrib/tmp/nginx/apxtrib.crabdance.access.log main; #location = /app { # return 302 /app/; @@ -28,10 +28,10 @@ server { } location / { - root /media/phil/usbfarm/apixtribe/nationchains/; - index apixtribe.html; + root /media/phil/usbfarm/apxtrib/nationchains/; + index apxtrib.html; } - error_page 404 /media/phil/usbfarm/apixtribe/nationchains/error/404.html; - error_page 500 502 503 504 /media/phil/usbfarm/apixtribe/nationchains/error/50x.html; + error_page 404 /media/phil/usbfarm/apxtrib/nationchains/error/404.html; + error_page 500 502 503 504 /media/phil/usbfarm/apxtrib/nationchains/error/50x.html; } diff --git a/setup/config.mustache b/setup/config.mustache index 336f2ea..1ef53fd 100755 --- a/setup/config.mustache +++ b/setup/config.mustache @@ -3,11 +3,11 @@ const config = { loglevel:"{{consoleloglevel}}", linuxuser:"{{linuxuser}}", druidid:"{{druidid}}", - dnsapixtribe:"{{subdomain}}.{{domain}}", + dnsapxtrib:"{{subdomain}}.{{domain}}", mainDir: __dirname, tmp: path.join( __dirname, '/tmp' ), public: path.join( __dirname, 'data/tribe/{{druidid}}/www/cdn' ), - //(@TODO ASUP mettre /cdn de apixtribe) public allow to serve on /public file into folder /public with or without login + //(@TODO ASUP mettre /cdn de apxtrib) public allow to serve on /public file into folder /public with or without login archivefolder: path.join( __dirname, '/archive' ), domain: path.join( __dirname, '/data/tribe' ), porthttp:{{porthttp}} , diff --git a/setup/data/domain/apixpress/clientconf.mustache b/setup/data/domain/apixpress/clientconf.mustache index 8cb5d32..2dc97c2 100755 --- a/setup/data/domain/apixpress/clientconf.mustache +++ b/setup/data/domain/apixpress/clientconf.mustache @@ -8,8 +8,8 @@ "allowedDOMs": ["{{domain}}"], "customization": { "claim": "Be a Producer, not a product.", - "name": "apixtribe", - "logo": "https://{{subdomain}}.{{domain}}/cdn/{{druidid}}/img/logo/apixtribe.png", + "name": "apxtrib", + "logo": "https://{{subdomain}}.{{domain}}/cdn/{{druidid}}/img/logo/apxtrib.png", "favicon": "https://{{subdomain}}.{{domain}}/cdn/{{druidid}}/img/iconX74x74.png", "colors": { "primary": "#01717B", diff --git a/setup/data/domain/apixpress/referentials/dataManagement/object/users.json b/setup/data/domain/apixpress/referentials/dataManagement/object/users.json index 0a14d3f..4e1f246 100755 --- a/setup/data/domain/apixpress/referentials/dataManagement/object/users.json +++ b/setup/data/domain/apixpress/referentials/dataManagement/object/users.json @@ -29,8 +29,8 @@ "type": "text", "tpl": "input", "info": { - "fr": "

Le login doit être unique sur une instance d'apixtribe.

Pour échanger en dehors d'une instance apixtribe on utilise la clé public du user ou pour un humain login@apixtribe.domain.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", - "en": "

Login have to be unique into an apixtribe instance

To exchange outside of an apixtribe instance, we use PublicKey or login@apixtribe.domain.xx or login@domainclient.xx where domain.xx is a apixtribe name server on internet and domain.xx is a tribeid name where a /tribeid/www is available on the net.

" + "fr": "

Le login doit être unique sur une instance d'apxtrib.

Pour échanger en dehors d'une instance apxtrib on utilise la clé public du user ou pour un humain login@apxtrib.domain.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", + "en": "

Login have to be unique into an apxtrib instance

To exchange outside of an apxtrib instance, we use PublicKey or login@apxtrib.domain.xx or login@domainclient.xx where domain.xx is a apxtrib name server on internet and domain.xx is a tribeid name where a /tribeid/www is available on the net.

" } }, { @@ -118,8 +118,8 @@ "en": "pseudo" }, "info": { - "fr": "

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apixtribe

Attention ce nom n'est unique que sur une instance d'apixtribe. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", - "en": "

Carrefull a pseudo is unique into an instance of apixtribe to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

" + "fr": "

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apxtrib

Attention ce nom n'est unique que sur une instance d'apxtrib. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", + "en": "

Carrefull a pseudo is unique into an instance of apxtrib to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

" }, "tpl": "input", "type": "text" diff --git a/setup/data/domain/apixpress/referentials/dataManagementBackup/object/users.json b/setup/data/domain/apixpress/referentials/dataManagementBackup/object/users.json index 0a14d3f..4e1f246 100755 --- a/setup/data/domain/apixpress/referentials/dataManagementBackup/object/users.json +++ b/setup/data/domain/apixpress/referentials/dataManagementBackup/object/users.json @@ -29,8 +29,8 @@ "type": "text", "tpl": "input", "info": { - "fr": "

Le login doit être unique sur une instance d'apixtribe.

Pour échanger en dehors d'une instance apixtribe on utilise la clé public du user ou pour un humain login@apixtribe.domain.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", - "en": "

Login have to be unique into an apixtribe instance

To exchange outside of an apixtribe instance, we use PublicKey or login@apixtribe.domain.xx or login@domainclient.xx where domain.xx is a apixtribe name server on internet and domain.xx is a tribeid name where a /tribeid/www is available on the net.

" + "fr": "

Le login doit être unique sur une instance d'apxtrib.

Pour échanger en dehors d'une instance apxtrib on utilise la clé public du user ou pour un humain login@apxtrib.domain.xx avec le nom du domaine qui heberge l'instance

Ou encore login@domain.xx tout domain.xx utilisé pour heberger un espace web client /tribeid/www/

", + "en": "

Login have to be unique into an apxtrib instance

To exchange outside of an apxtrib instance, we use PublicKey or login@apxtrib.domain.xx or login@domainclient.xx where domain.xx is a apxtrib name server on internet and domain.xx is a tribeid name where a /tribeid/www is available on the net.

" } }, { @@ -118,8 +118,8 @@ "en": "pseudo" }, "info": { - "fr": "

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apixtribe

Attention ce nom n'est unique que sur une instance d'apixtribe. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", - "en": "

Carrefull a pseudo is unique into an instance of apixtribe to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

" + "fr": "

Nom avec lequel vous souhaitez qu'on vous reconnaisse sur l'instance de l'apxtrib

Attention ce nom n'est unique que sur une instance d'apxtrib. Un même speudo peut-être utilisé sur un autre serveur pour garantir l'identité vérifié pseudo@ domaine de rattachement.

", + "en": "

Carrefull a pseudo is unique into an instance of apxtrib to be sure to contact the right person check pseudo@ domain

.

Pseudo can be changed that is not the case of login.

" }, "tpl": "input", "type": "text" diff --git a/setup/data/domain/apixpress/users/searchindex/uids.json b/setup/data/domain/apixpress/users/searchindex/uids.json index dd37254..cc98962 100755 --- a/setup/data/domain/apixpress/users/searchindex/uids.json +++ b/setup/data/domain/apixpress/users/searchindex/uids.json @@ -5,10 +5,10 @@ "$2b$10$hFV/33UixB3Cn.XzLIhmTeRYU2XThnxYuwCVIifwQ7v/yCtRLIsuq", { "app": { - "apixtribe:webapp": "admin" + "apxtrib:webapp": "admin" }, "data": { - "apixtribe": { + "apxtrib": { "users": "CRUDO", "referentials": "CRUDO" } diff --git a/setup/data/domain/apixpress/www/app/webapp/app_index_fr.html b/setup/data/domain/apixpress/www/app/webapp/app_index_fr.html index 1183554..8f8dcb1 100755 --- a/setup/data/domain/apixpress/www/app/webapp/app_index_fr.html +++ b/setup/data/domain/apixpress/www/app/webapp/app_index_fr.html @@ -1,5 +1,5 @@ - + diff --git a/setup/data/domain/apixpress/www/app/webapp/fullscreen_auth_fr.html b/setup/data/domain/apixpress/www/app/webapp/fullscreen_auth_fr.html index 92dedde..33a9db9 100755 --- a/setup/data/domain/apixpress/www/app/webapp/fullscreen_auth_fr.html +++ b/setup/data/domain/apixpress/www/app/webapp/fullscreen_auth_fr.html @@ -1,12 +1,12 @@ - + - apixtribe> + apxtrib> @@ -22,19 +22,19 @@

Need-Data

- Votre hébergement apixtribe en toute confidentialité. + Votre hébergement apxtrib en toute confidentialité.

- logo apixtribe + logo apxtrib
- +
@@ -108,7 +108,7 @@ value="Trze3aze!" placeholder="Mot de passe ou hash sur clé public" />

S'inscrire à votre communauté

- Vous devez disposez du nom de la communauté qui vous invite à ouvrir un compte chez elle.
Pour créer une communauté, sur cet hébergement: contact@need-data.com.
En savoir plus sur Anomymat & apixtribe. + Vous devez disposez du nom de la communauté qui vous invite à ouvrir un compte chez elle.
Pour créer une communauté, sur cet hébergement: contact@need-data.com.
En savoir plus sur Anomymat & apxtrib.

diff --git a/setup/data/domain/apixpress/www/app/webapp/manifest.json b/setup/data/domain/apixpress/www/app/webapp/manifest.json index dd69777..f7040bf 100755 --- a/setup/data/domain/apixpress/www/app/webapp/manifest.json +++ b/setup/data/domain/apixpress/www/app/webapp/manifest.json @@ -1 +1 @@ -{"name":"apixtribe Need-Data","short_name":"apixtribe","start_url":"app_index_fr.html","background_color":"purple","description":"Webapp to manage an apixtribe server.","display":"fullscreen","icons":[{"src":"static/img/icons/iconX74x74.png","sizes":"74x74","type":"image/png"}]} +{"name":"apxtrib Need-Data","short_name":"apxtrib","start_url":"app_index_fr.html","background_color":"purple","description":"Webapp to manage an apxtrib server.","display":"fullscreen","icons":[{"src":"static/img/icons/iconX74x74.png","sizes":"74x74","type":"image/png"}]} diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/adminapixpress.js b/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/adminapixpress.js index 30b902e..6f8de51 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/adminapixpress.js +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/adminapixpress.js @@ -3,32 +3,32 @@ pwa.main = pwa.main || {}; pwa.main.tpldata = pwa.main.tpldata || {}; pwa.main.tpl = pwa.main.tpl || {}; //menu -pwa.main.tpldata.sidebarAdminapixtribe = `static/components/adminapixtribe/sidebaradminapixtribe`; +pwa.main.tpldata.sidebarAdminapxtrib = `static/components/adminapxtrib/sidebaradminapxtrib`; // Custom data in user lang //tremplate to store -pwa.main.tpl.adminapixtribe = 'static/components/adminapixtribe/adminapixtribe.mustache'; -pwa.main.tpl.adminapixtribesysinfo = 'static/components/adminapixtribe/adminapixtribesysinfo.mustache'; -pwa.main.tpl.adminapixtribeactivity = 'static/components/adminapixtribe/adminapixtribeactivity.mustache'; +pwa.main.tpl.adminapxtrib = 'static/components/adminapxtrib/adminapxtrib.mustache'; +pwa.main.tpl.adminapxtribsysinfo = 'static/components/adminapxtrib/adminapxtribsysinfo.mustache'; +pwa.main.tpl.adminapxtribactivity = 'static/components/adminapxtrib/adminapxtribactivity.mustache'; -pwa.adminapixtribe = {}; +pwa.adminapxtrib = {}; -pwa.adminapixtribe.init = () => { +pwa.adminapxtrib.init = () => { // Run back stuff to update data } -pwa.adminapixtribe.sysinfoview = () => { +pwa.adminapxtrib.sysinfoview = () => { const datasysinfo = {}; //request to get info and push them in template document.getElementById( 'maincontent' ) - .innerHTML = Mustache.render( pwa.state.data.tpl.adminapixtribesysinfo, datasysinfo ); + .innerHTML = Mustache.render( pwa.state.data.tpl.adminapxtribsysinfo, datasysinfo ); } -pwa.adminapixtribe.activityview = () => { +pwa.adminapxtrib.activityview = () => { const dataactivity = {}; //request to get info and push them in template document.getElementById( 'maincontent' ) - .innerHTML = Mustache.render( pwa.state.data.tpl.adminapixtribeactivity, dataactivity ); + .innerHTML = Mustache.render( pwa.state.data.tpl.adminapxtribactivity, dataactivity ); } -pwa.adminapixtribe.tribeidview = () => { +pwa.adminapxtrib.tribeidview = () => { const datatribeid = {}; //request to get info and push them in template document.getElementById( 'maincontent' ) - .innerHTML = Mustache.render( pwa.state.data.tpl.adminapixtribe, datatribeid ); + .innerHTML = Mustache.render( pwa.state.data.tpl.adminapxtrib, datatribeid ); } diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/sidebaradminapixpress_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/sidebaradminapixpress_fr.json index 8c12a85..a914194 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/sidebaradminapixpress_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/adminapixpress/sidebaradminapixpress_fr.json @@ -1,22 +1,22 @@ { - "groupheader": "Admin apixtribe", + "groupheader": "Admin apxtrib", "sbssgroupmenu": [{ "name": "Activité", "icon": "sliders", - "actionclick": "pwa.adminapixtribe.init()", + "actionclick": "pwa.adminapxtrib.init()", "iditemmenus": "adminxpress", "itemmenus": [{ "name": "Info activités", - "actionclick": "pwa.adminapixtribe.activityview()" + "actionclick": "pwa.adminapxtrib.activityview()" }, { "name": "Admin des tribeid", - "actionclick": "pwa.adminapixtribe.tribeidview()" + "actionclick": "pwa.adminapxtrib.tribeidview()" } ] }, { "name": "System Info", "icon": "sliders", - "actionclick": "pwa.adminapixtribe.sysinfoview()" + "actionclick": "pwa.adminapxtrib.sysinfoview()" }] } \ No newline at end of file diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/ASUPPdata_sidebarAdminapixpress_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/ASUPPdata_sidebarAdminapixpress_fr.json index c367242..d6c5887 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/ASUPPdata_sidebarAdminapixpress_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/ASUPPdata_sidebarAdminapixpress_fr.json @@ -1,5 +1,5 @@ { - "groupheader": "Admin apixtribe", + "groupheader": "Admin apxtrib", "sbssgroupmenu": [{ "name": "Tribes", "icon": "sliders", diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/appmesa.mustache b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/appmesa.mustache index b5ef007..4c31fb7 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/appmesa.mustache +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/appmesa.mustache @@ -10,7 +10,7 @@

- {{claim}} © + {{claim}} ©

diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_appmesa_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_appmesa_fr.json index 963e4db..b1e605b 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_appmesa_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_appmesa_fr.json @@ -1,8 +1,8 @@ { "navbarclass": "navbar-expand navbar-light navbar-bg", "footer": { - "urlapixtribe": "https://apixtribe.org", - "claim": "apixtribe made with love for freedom", + "urlapxtrib": "https://apxtrib.org", + "claim": "apxtrib made with love for freedom", "links": [{ "url": "#", "desc": "Support" diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_sidebar_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_sidebar_fr.json index 5112e9b..da5ac4f 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_sidebar_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/data_sidebar_fr.json @@ -2,7 +2,7 @@ "sbbrandlink": "app_index_fr.html", "sbtitle": "Need-Data", "sbgroupmenu": [{ - "groupheader": "apixtribe", + "groupheader": "apxtrib", "sbssgroupmenu": [{ "name": "Les news", "icon": "sliders", @@ -12,7 +12,7 @@ "name": "Reporting", "icon": "sliders", "actionclick": "pwa.reporting.init()", - "iditemmenus": "reportingapixtribe", + "iditemmenus": "reportingapxtrib", "itemmenus": [{ "name": "", "actionclick": "pwa.reporting.init()" diff --git a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/search.js b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/search.js index 79902bd..3bfc7a8 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/search.js +++ b/setup/data/domain/apixpress/www/app/webapp/static/components/appmesa/search.js @@ -1,6 +1,6 @@ // app management for search request /* -@todo create a search/index content for an apixtribe instance +@todo create a search/index content for an apxtrib instance //store request to analyse kind of looking for */ @@ -34,7 +34,7 @@ pwa.search.tpl = ` pwa.search.dataexample = { searchtxt: "search string to looking for", results: [ { - url: "https://apixtribe.org", + url: "https://apxtrib.org", format: "pdf", title: "Search finding title of the page", desc: "sentence contexte of the searchtxt", diff --git a/setup/data/domain/apixpress/www/app/webapp/static/data/appmesa_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/data/appmesa_fr.json index 963e4db..b1e605b 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/data/appmesa_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/data/appmesa_fr.json @@ -1,8 +1,8 @@ { "navbarclass": "navbar-expand navbar-light navbar-bg", "footer": { - "urlapixtribe": "https://apixtribe.org", - "claim": "apixtribe made with love for freedom", + "urlapxtrib": "https://apxtrib.org", + "claim": "apxtrib made with love for freedom", "links": [{ "url": "#", "desc": "Support" diff --git a/setup/data/domain/apixpress/www/app/webapp/static/data/auth_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/data/auth_fr.json index 0b4e998..bd49956 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/data/auth_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/data/auth_fr.json @@ -1,7 +1,7 @@ { "signin": { "claimh1": "Need-Data", - "claimp": "Votre hébergement apixtribe en toute confidentialité.", + "claimp": "Votre hébergement apxtrib en toute confidentialité.", "logo": "static/img/logo/ndda.png", "classlogo": "img-fluid", "login": "Identifiant", @@ -30,8 +30,8 @@ }, "register": { "claimh1": "S'inscrire à votre communauté", - "claimp": "Vous devez disposez du nom de la communauté qui vous invite à ouvrir un compte chez elle.
Pour créer une communauté, sur cet hébergement: contact@need-data.com.
En savoir plus sur Anomymat & apixtribe.", - "logoapixtribe": "static/img/logo/apixtribe.png", + "claimp": "Vous devez disposez du nom de la communauté qui vous invite à ouvrir un compte chez elle.
Pour créer une communauté, sur cet hébergement: contact@need-data.com.
En savoir plus sur Anomymat & apxtrib.", + "logoapxtrib": "static/img/logo/apxtrib.png", "logoowner": "static/img/logo/ndda.png", "login": "Votre identifiant", "loginph": "login ou clé public", diff --git a/setup/data/domain/apixpress/www/app/webapp/static/data/fullscreensimplehead_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/data/fullscreensimplehead_fr.json index 374beaf..2689585 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/data/fullscreensimplehead_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/data/fullscreensimplehead_fr.json @@ -1,5 +1,5 @@ { - "title": "apixtribe", + "title": "apxtrib", "js": [], "css": ["static/fonts/icofont/icofont.min.css", "css/fullscreen/styles.css"] } \ No newline at end of file diff --git a/setup/data/domain/apixpress/www/app/webapp/static/data/sidebarAdminapixpress_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/data/sidebarAdminapixpress_fr.json index f242f62..ed2b35b 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/data/sidebarAdminapixpress_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/data/sidebarAdminapixpress_fr.json @@ -1,5 +1,5 @@ [{ - "groupheader": "Admin apixtribe", + "groupheader": "Admin apxtrib", "sbssgroupmenu": [{ "name": "Tribes", "icon": "sliders", diff --git a/setup/data/domain/apixpress/www/app/webapp/static/data/sidebar_fr.json b/setup/data/domain/apixpress/www/app/webapp/static/data/sidebar_fr.json index 5112e9b..da5ac4f 100755 --- a/setup/data/domain/apixpress/www/app/webapp/static/data/sidebar_fr.json +++ b/setup/data/domain/apixpress/www/app/webapp/static/data/sidebar_fr.json @@ -2,7 +2,7 @@ "sbbrandlink": "app_index_fr.html", "sbtitle": "Need-Data", "sbgroupmenu": [{ - "groupheader": "apixtribe", + "groupheader": "apxtrib", "sbssgroupmenu": [{ "name": "Les news", "icon": "sliders", @@ -12,7 +12,7 @@ "name": "Reporting", "icon": "sliders", "actionclick": "pwa.reporting.init()", - "iditemmenus": "reportingapixtribe", + "iditemmenus": "reportingapxtrib", "itemmenus": [{ "name": "", "actionclick": "pwa.reporting.init()" diff --git a/setup/data/domain/apixpress/www/cdn/doc/apiXpress.mm b/setup/data/domain/apixpress/www/cdn/doc/apiXpress.mm index 61e9030..0cefa52 100755 --- a/setup/data/domain/apixpress/www/cdn/doc/apiXpress.mm +++ b/setup/data/domain/apixpress/www/cdn/doc/apiXpress.mm @@ -1,6 +1,6 @@ - + diff --git a/setup/data/domain/apixpress/www/cdn/public/index.html b/setup/data/domain/apixpress/www/cdn/public/index.html index ae0298f..4312564 100755 --- a/setup/data/domain/apixpress/www/cdn/public/index.html +++ b/setup/data/domain/apixpress/www/cdn/public/index.html @@ -1,4 +1,4 @@

ST**** ME I'M FAMOUS!

-

apixtribe +

apxtrib

\ No newline at end of file diff --git a/setup/data/domain/apixpress/www/cdn/public/js/tagASUPVOIRstate.js.js b/setup/data/domain/apixpress/www/cdn/public/js/tagASUPVOIRstate.js.js index 6ddc901..6d1c088 100755 --- a/setup/data/domain/apixpress/www/cdn/public/js/tagASUPVOIRstate.js.js +++ b/setup/data/domain/apixpress/www/cdn/public/js/tagASUPVOIRstate.js.js @@ -132,7 +132,7 @@ tg.action = (post) => { xhttp.onreadystatechange = function() {}; xhttp.open( 'POST', - `${pwa.urlapixtribe}/tags/${pwa.tribeid}`, + `${pwa.urlapxtrib}/tags/${pwa.tribeid}`, true ); xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); @@ -151,7 +151,7 @@ tg.action = (post) => { $(document) .ready(function() { if(!pwa.tribeid) { - pwa.urlapixtribe = 'https://api' + $('#mxp') + pwa.urlapxtrib = 'https://api' + $('#mxp') .attr('data-destin') + '.maildigit.fr'; pwa.tribeid = $('#mxp') .attr('data-tribeid'); diff --git a/setup/data/domain/apixpress/www/cdn/suiviprojetapiXpress.svg b/setup/data/domain/apixpress/www/cdn/suiviprojetapiXpress.svg index e00ef3f..cfb1b95 100755 --- a/setup/data/domain/apixpress/www/cdn/suiviprojetapiXpress.svg +++ b/setup/data/domain/apixpress/www/cdn/suiviprojetapiXpress.svg @@ -16,7 +16,7 @@ version="1.1" id="svg8" inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)" - sodipodi:docname="suiviprojetapixtribe.svg"> + sodipodi:docname="suiviprojetapxtrib.svg"> Referentials /apixtribe/referentials/object/users.jsonReferentials /apxtrib/referentials/object/users.jsonhttp://gitlab.ndda.fr/philc/apixtribe/-/wikis/HOWTOMessagehttp://gitlab.ndda.fr/philc/apxtrib/-/wikis/HOWTOMessageget /clientconfglob => 200 full config for all server + token /403 (only for admin apixtribe) only for admin apxtrib) get /contentfull/:source/:idref http://gitlab.ndda.fr/philc/apixtribe/-/wikis/SETUPhttp://gitlab.ndda.fr/philc/apxtrib/-/wikis/SETUP @@ -857,7 +857,7 @@ x="3.6254988" y="119.11422" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.41111112px;font-family:Cantarell;-inkscape-font-specification:'Cantarell, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#063665;fill-opacity:1;stroke-width:0.26458332" - id="tspan1152"> Instance apixtribe http://local.apixtribe.fr (no ssl for nginx and express) Instance apxtrib http://local.apxtrib.fr (no ssl for nginx and express) <prod> registar dnsname to apixtribe IP serveur + let'sencrypt certbot prod> registar dnsname to apxtrib IP serveur + let'sencrypt certbot Instance https://apixtribe.ndda.fr (ssll for nginx, reverse proxy to express.js) Instance https://apxtrib.ndda.fr (ssll for nginx, reverse proxy to express.js)http://gitlab.ndda.fr/philc/apixtribe/-/wikis/HOWTOpluginhttp://gitlab.ndda.fr/philc/apxtrib/-/wikis/HOWTOpluginProcess for Dev mod local apixtribe installationProcess for Dev mod local apxtrib installationincron detect in REGEXFOLDER='(.*\/apixtribe)\/(.*)\/domaine\/(.*)\/spacedev\/(.*)\/src\/(.*)'incron detect in REGEXFOLDER='(.*\/apxtrib)\/(.*)\/domaine\/(.*)\/spacedev\/(.*)\/src\/(.*)'1- POST http://mesa.apixtribe.fr/app/maildigitcreator/publish/presentation1- POST http://mesa.apxtrib.fr/app/maildigitcreator/publish/presentationReferentials /apixtribe/referentials/object/Tribes.jsonReferentials /apxtrib/referentials/object/Tribes.json{the function to run}}; +module.exports=ut; +\x1b[0m + +To request any update or change in the code add to your git branch a new file into where you test your modifications /inittest/ +We first run your test and check with git diff your code before merge your branch with your inittest + +You'll be inform when a new release including your change into azpXtrib will be available. +\x1b[7mThanks for improving our democracy tool.\x1b[0m +`; +ut.run = (options) => { + if (options.filetotest.length == 0) + console.log( + "Check your files because no test to run (for more: yarn unittest -help)" + ); + options.filetotest.forEach((f) => { + const unittest = require(f); + console.log("\x1b[34m", `Unittest ${f}`, "\x1b[0m"); + try { + unittest.run(options); + console.log("✅", "\x1b[32m", unittest.name, "\x1b[0m"); + } catch (e) { + console.log( + "❌", + "\x1b[41m", + unittest.name, + e.stack.split("\n")[0], + "\x1b[0m" + ); + if (options.verbose) console.log(e.stack); + } + }); +}; +const options = { filetotest: [] }; +process.argv.slice(2).forEach((arg) => { + switch (arg.substring(0, 2)) { + case "-v": + options.verbose = true; + break; + case "-p": + options.publish = true; + break; + case "-h": + options.active = true; + options.help = true; + break; + default: + options.active = true; + config.unittesting.forEach((codefolder) => { + glob + .sync(`${__base}${codefolder}/**/unittest/${arg}.js`) + .forEach((f) => { + if (!options.filetotest.includes(f)) options.filetotest.push(f); + }); + }); + break; + } +}); +if (!options.active) { + config.unittesting.forEach((codefolder) => { + glob.sync(`${__base}${codefolder}/**/unittest/*.js`).forEach((f) => { + if (!options.filetotest.includes(f)) options.filetotest.push(f); + }); + }); + console.log( + "You can test only some unittest by passing yarn unittest name where name is a /unittest/name.js file that exist, type 'yarn unittest -help' for more" + ); + console.log("Looking for unittest folder into ", config.unittesting); +} +options.help ? console.log(ut.help) : ut.run(options);