Compare commits

...

11 Commits

Author SHA1 Message Date
sairaj mote
6cb7f88bd5 Moving to new tor links
Some checks failed
Workflow push to Dappbundle / Build (push) Has been cancelled
2024-01-21 01:27:16 +05:30
sairaj mote
ca05df8d75 Create push-dappbundle.yml 2023-12-18 22:07:15 +05:30
sairajzero
2f102d7916 Merge https://github.com/ranchimall/standard-operations 2023-07-30 15:15:38 +05:30
sairajzero
098a62047c floCloudAPI v2.4.5 : file support
- uploadFile: upload a file to the cloud
- downloadFile: download a file from cloud

- upload/download file supports encryption of file. use options.encrypt in uploadFile and options.decrypt in downloadFile
2023-07-29 05:41:06 +05:30
sairajzero
5be35c28ce floDapps v2.4.1
- support for multiple cloud networks
2023-07-29 05:01:14 +05:30
SaketAnand
c3ebcb99f8
Update README.md 2023-07-29 03:41:35 +05:30
SaketAnand
87aa77327b
Update README.md 2023-07-28 21:21:22 +05:30
SaketAnand
dd5fae96aa
Update README.md 2023-07-28 21:20:57 +05:30
SaketAnand
e6b7dc12cf
Update README.md 2023-07-28 21:20:28 +05:30
SaketAnand
46a095ca44
Update README.md 2023-07-28 21:18:19 +05:30
sairajzero
471f291848 floCloudAPI v2.4.4: edit comment feature
- senders can now edit the comment of data they sent (by re-signing the new data)
2023-07-26 03:45:35 +05:30
8 changed files with 236 additions and 81 deletions

32
.github/workflows/push-dappbundle.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Workflow push to Dappbundle
on: [push]
jobs:
build:
name: Build
runs-on: self-hosted
steps:
- name: Executing remote command
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.R_HOST }}
username: ${{ secrets.P_USERNAME }}
password: ${{ secrets.P_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle" ]; then
echo "Folder exists. Skipping Git clone."
else
echo "Folder does not exist. Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/ && git clone https://github.com/ranchimall/dappbundle.git
fi
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" ]; then
echo "Repository exists. Remove folder "
rm -r "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}"
fi
echo "Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle && git clone https://github.com/ranchimall/${{ github.event.repository.name }}
cd "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" && rm -rf .gitattributes .git .github .gitignore
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/ && git add . && git commit -m "Workflow updating files of ${{ github.event.repository.name }}" && git push "https://ranchimalldev:${{ secrets.RM_ACCESS_TOKEN }}@github.com/ranchimall/dappbundle.git"

View File

@ -1,2 +1,28 @@
# FLO_LogSheet
A log sheet app based of FLO via Supernode Cloud
# FLO LogSheet
FLO Log Sheet is a blockchain-based spreadsheet like app to store data on a decentralized cloud storage. High-quality data can be curated using a blockchain-based scoring system. It is used to keep a record of accurate data. The highest quality or the most accurate data is scored the highest.
There are two types of sheets:
i) Public sheet
ii) Private sheet
### Live URL for FLO LogSheet:
*https://ranchimall.github.io/flologsheet/*
### Public sheet
Anyone with a Bitcoin address or a FLO blockchain address can make entries to the sheet
### Private sheet
Only authorized Bitcoin or FLO addresses can make entries
### Creation of a sheet
• Currently this feature is kept to only authorized sub-admins of the RanchiMall ecosystem to avoid flooding of data and to maintain the quality of data
• Sub-admins are approved FLO or BTC addresses that can make changes such as the creation of a sheet and scoring the entries inside a sheet
### Scoring
• Scoring is done to maintain the authenticity of the data
• Unscored entries or entries with a score of 0 are automatically deleted from the cloud after 7 days
• Scoring can only be done by the authorized FLO or BTC addresses
#### Note:
• Currently Flo LogSheet has sheets for various RanchiMall projects like Project B (Token Room) El Salvador, BIT Sindri Blockchain Project, blockchain-based Labour Market in Ranchi, and the token allocation & room nights data for Token Room
• RanchiMall uses these sheets to maintain the quality and accuracy of these project's statistics

File diff suppressed because one or more lines are too long

1
scripts/floBlockchainAPI.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
(function (EXPORTS) { //floCloudAPI v2.4.3a
(function (EXPORTS) { //floCloudAPI v2.4.5
/* FLO Cloud operations to send/request application data*/
'use strict';
const floCloudAPI = EXPORTS;
@ -609,49 +609,39 @@
})
}
*/
/*(NEEDS UPDATE)
//edit comment of data in supernode cloud (mutable comments only)
floCloudAPI.editApplicationData = function(vectorClock, newComment, oldData, options = {}) {
//edit comment of data in supernode cloud (sender only)
floCloudAPI.editApplicationData = function (vectorClock, comment_edit, options = {}) {
return new Promise((resolve, reject) => {
let p0
if (!oldData) {
options.atVectorClock = vectorClock;
options.callback = false;
p0 = requestApplicationData(false, options)
} else
p0 = Promise.resolve({
vectorClock: {
...oldData
}
})
p0.then(d => {
if (d.senderID != user.id)
return reject("Invalid requestorID")
else if (!d.comment.startsWith("EDIT:"))
return reject("Data immutable")
let data = {
//request the data from cloud for resigning
let req_options = Object.assign({}, options);
req_options.atVectorClock = vectorClock;
requestApplicationData(undefined, req_options).then(result => {
if (!result.length)
return reject("Data not found");
let data = result[0];
if (data.senderID !== user.id)
return reject("Only sender can edit comment");
data.comment = comment_edit;
let hashcontent = ["receiverID", "time", "application", "type", "message", "comment"]
.map(d => data[d]).join("|");
let re_sign = user.sign(hashcontent);
var request = {
receiverID: options.receiverID || DEFAULT.adminID,
requestorID: user.id,
receiverID: d.receiverID,
pubKey: user.public,
time: Date.now(),
application: d.application,
edit: {
vectorClock: vectorClock,
comment: newComment
}
vectorClock: vectorClock,
edit: comment_edit,
re_sign: re_sign
}
d.comment = data.edit.comment;
let hashcontent = ["receiverID", "time", "application", "type", "message",
"comment"
]
.map(x => d[x]).join("|")
data.edit.sign = user.sign(hashcontent)
singleRequest(data.receiverID, data)
.then(result => resolve("Data comment updated"))
let request_hash = ["time", "vectorClock", "edit", "re_sign"].map(d => request[d]).join("|");
request.sign = user.sign(request_hash);
singleRequest(request.receiverID, request)
.then(result => resolve(result))
.catch(error => reject(error))
})
}).catch(error => reject(error))
})
}
*/
//tag data in supernode cloud (subAdmin access only)
floCloudAPI.tagApplicationData = function (vectorClock, tag, options = {}) {
@ -811,6 +801,67 @@
})
}
//upload file
floCloudAPI.uploadFile = function (fileBlob, type, options = {}) {
return new Promise((resolve, reject) => {
if (!(fileBlob instanceof File) && !(fileBlob instanceof Blob))
return reject("file must be instance of File/Blob");
fileBlob.arrayBuffer().then(arraybuf => {
let file_data = { type: fileBlob.type, name: fileBlob.name };
file_data.content = Crypto.util.bytesToBase64(new Uint8Array(arraybuf));
if (options.encrypt) {
let encryptionKey = options.encrypt === true ?
floGlobals.settings.encryptionKey : options.encrypt
file_data = floCrypto.encryptData(JSON.stringify(file_data), encryptionKey)
}
sendApplicationData(file_data, type, options)
.then(({ vectorClock, receiverID, type, application }) => resolve({ vectorClock, receiverID, type, application }))
.catch(error => reject(error))
}).catch(error => reject(error))
})
}
//download file
floCloudAPI.downloadFile = function (vectorClock, options = {}) {
return new Promise((resolve, reject) => {
options.atVectorClock = vectorClock;
requestApplicationData(options.type, options).then(result => {
if (!result.length)
return reject("File not found");
result = result[0];
try {
let file_data = decodeMessage(result.message);
//file is encrypted: decryption required
if (file_data instanceof Object && "secret" in file_data) {
if (!options.decrypt)
return reject("Data is encrypted");
let decryptionKey = (options.decrypt === true) ? Crypto.AES.decrypt(user_private, aes_key) : options.decrypt;
if (!Array.isArray(decryptionKey))
decryptionKey = [decryptionKey];
let flag = false;
for (let key of decryptionKey) {
try {
let tmp = floCrypto.decryptData(file_data, key);
file_data = JSON.parse(tmp);
flag = true;
break;
} catch (error) { }
}
if (!flag)
return reject("Unable to decrypt file: Invalid private key");
}
//reconstruct the file
let arraybuf = new Uint8Array(Crypto.util.base64ToBytes(file_data.content))
result.file = new File([arraybuf], file_data.name, { type: file_data.type });
resolve(result)
} catch (error) {
console.error(error);
reject("Data is not a file");
}
}).catch(error => reject(error))
})
}
/*
Functions:
findDiff(original, updatedObj) returns an object with the added, deleted and updated differences

View File

@ -1,4 +1,4 @@
(function (EXPORTS) { //floDapps v2.4.0
(function (EXPORTS) { //floDapps v2.4.1
/* General functions for FLO Dapps*/
'use strict';
const floDapps = EXPORTS;
@ -172,12 +172,7 @@
//general
lastTx: {},
//supernode (cloud list)
supernodes: {
indexes: {
uri: null,
pubKey: null
}
}
supernodes: {}
}
var obs_a = {
//login credentials
@ -257,7 +252,8 @@
return new Promise((resolve, reject) => {
if (!startUpOptions.cloud)
return resolve("No cloud for this app");
compactIDB.readData("lastTx", floCloudAPI.SNStorageID, DEFAULT.root).then(lastTx => {
const CLOUD_KEY = "floCloudAPI#" + floCloudAPI.SNStorageID;
compactIDB.readData("lastTx", CLOUD_KEY, DEFAULT.root).then(lastTx => {
var query_options = { sentOnly: true, pattern: floCloudAPI.SNStorageName };
if (typeof lastTx == 'number') //lastTx is tx count (*backward support)
query_options.ignoreOld = lastTx;
@ -265,25 +261,27 @@
query_options.after = lastTx;
//fetch data from flosight
floBlockchainAPI.readData(floCloudAPI.SNStorageID, query_options).then(result => {
for (var i = result.data.length - 1; i >= 0; i--) {
var content = JSON.parse(result.data[i])[floCloudAPI.SNStorageName];
for (let sn in content.removeNodes)
compactIDB.removeData("supernodes", sn, DEFAULT.root);
for (let sn in content.newNodes)
compactIDB.writeData("supernodes", content.newNodes[sn], sn, DEFAULT.root);
for (let sn in content.updateNodes)
compactIDB.readData("supernodes", sn, DEFAULT.root).then(r => {
r = r || {}
r.uri = content.updateNodes[sn];
compactIDB.writeData("supernodes", r, sn, DEFAULT.root);
});
}
compactIDB.writeData("lastTx", result.lastItem, floCloudAPI.SNStorageID, DEFAULT.root);
compactIDB.readAllData("supernodes", DEFAULT.root).then(nodes => {
floCloudAPI.init(nodes)
.then(result => resolve("Loaded Supernode list\n" + result))
.catch(error => reject(error))
})
compactIDB.readData("supernodes", CLOUD_KEY, DEFAULT.root).then(nodes => {
nodes = nodes || {};
for (var i = result.data.length - 1; i >= 0; i--) {
var content = JSON.parse(result.data[i])[floCloudAPI.SNStorageName];
for (let sn in content.removeNodes)
delete nodes[sn];
for (let sn in content.newNodes)
nodes[sn] = content.newNodes[sn];
for (let sn in content.updateNodes)
if (sn in nodes) //check if node is listed
nodes[sn].uri = content.updateNodes[sn];
}
Promise.all([
compactIDB.writeData("lastTx", result.lastItem, CLOUD_KEY, DEFAULT.root),
compactIDB.writeData("supernodes", nodes, CLOUD_KEY, DEFAULT.root)
]).then(_ => {
floCloudAPI.init(nodes)
.then(result => resolve("Loaded Supernode list\n" + result))
.catch(error => reject(error))
}).catch(error => reject(error))
}).catch(error => reject(error))
})
}).catch(error => reject(error))
})

File diff suppressed because one or more lines are too long

1
scripts/floTokenAPI.min.js vendored Normal file

File diff suppressed because one or more lines are too long