/ˈkɒŋkɔːd/
agreement or harmony between people or groups.
Demo App 👉 https://demo.concords.app
TypeDocs 👉 https://typedoc.concords.app
$ npm install @concords/ledger --save
$ yarn add @concords/ledger
import ledger from '@concords/ledger';
const {
auth,
load,
create,
replay,
commit,
add,
destroy,
} = ledger();
To ensure integrity in the ledger, Concords uses an ECDSA key-pair to sign and verify transactions added to the ledger. The Keys are generated in the users browser using the Web Crypto API.
{
"secret": "JRxW6TjcK76B1KLKi7uo5syiKAFkgPWmSb6cmnv95i2cV5mClSv1dYCDD8uuYs3S",
"identity": {
"x": "ztE--LL6yBgQOy7Yr6egGZYi4n3OLWX22GsBCYPx-efYNvePZQ6GEYT1SIvaIgZA",
"y": "RuOLBSMJmD-BK5URkjwP32MoGLRzmyqNUIrdTpBOwnGP2BZepXzMNu9114YvMOoG"
}
}
Example using LokiJS
// plugin.js
const useLokiPlugin = (db) => {
let collection;
function createCollection({ ledger }) {
collection = db.addCollection(ledger.id, { disableMeta: true });
}
return {
getCollection: () => collection,
plugin: {
onLoad: createCollection,
onAdd(record) {
const item = collection.findOne({ id: record.data.id });
if (item) {
collection.update({ ...item, ...record.data });
} else {
collection.insert(record.data);
}
},
},
};
};
import ledger from '@concords/ledger';
import loki from 'lokijs';
import useLokiPlugin from './plugin';
const {
getCollection,
plugin: lokiPlugin
} = useLokiPlugin(new loki('ledger.db'));
function handleUpdates({ ledger }) {
const collection = getCollection();
list = collection.chain()
.compoundsort([['created_at', false], ['title', true]])
.data();
}
const { add, commit } = ledger({
...user,
ledger,
plugins: [
lokiPlugin,
{
onReady: handleUpdates,
onUpdate: handleUpdates,
}
]
});