Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "atomic-cli"
version = "0.13.0"
version = "0.14.0"
authors = ["Joep Meindertsma <joep@argu.co>"]
edition = "2018"
license = "MIT"
Expand All @@ -14,6 +14,6 @@ repository = "https://github.com/joepio/atomic"
promptly = "0.3.0"
clap = "2.33.1"
colored = "1.9.3"
atomic_lib = { version = "0.13.0", path = "../lib", features = ["db", "rdf"] }
atomic_lib = { version = "0.14.0", path = "../lib", features = ["db", "rdf"] }
dirs = "3.0.1"
regex = "1.3.9"
2 changes: 2 additions & 0 deletions cli/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ fn prompt_field(
},
DataType::Timestamp => todo!(),
DataType::Unsupported(unsup) => panic!("Unsupported datatype: {:?}", unsup),
DataType::Boolean => todo!(),
DataType::NestedResource => todo!(),
};
Ok(input)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/wapm.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "atomic"
version = "0.13.0"
version = "0.14.0"
description = "Create, share, fetch and model linked Atomic Data!"
license = "MIT"
repository = "https://github.com/joepio/atomic"
Expand Down
4 changes: 3 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "atomic_lib"
version = "0.13.0"
version = "0.14.0"
authors = ["Joep Meindertsma <joep@argu.co>"]
edition = "2018"
license = "MIT"
Expand All @@ -18,6 +18,8 @@ ureq = "1.4.0"
rio_turtle = { version = "0.5.0", optional = true}
rio_api = { version = "0.5.0", optional = true}
rand = "0.7.3"
ring = "0.16.15"
base64 = "0.13.0"

[features]
db = ["sled", "bincode"]
Expand Down
43 changes: 34 additions & 9 deletions lib/defaults/default_store.ad3
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
["https://atomicdata.dev/classes/Datatype","https://atomicdata.dev/properties/description","A Datatype describes a possible type of value, such as 'string' or 'integer'."]
["https://atomicdata.dev/classes/Datatype","https://atomicdata.dev/properties/shortname","datatype"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Class\"]"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/requires","[\"https://atomicdata.dev/properties/subject\",\"https://atomicdata.dev/properties/createdAt\",\"https://atomicdata.dev/properties/actor\",\"https://atomicdata.dev/properties/signature\"]"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/requires","[\"https://atomicdata.dev/properties/subject\",\"https://atomicdata.dev/properties/createdAt\",\"https://atomicdata.dev/properties/signer\",\"https://atomicdata.dev/properties/signature\"]"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/recommends","[\"https://atomicdata.dev/properties/set\",\"https://atomicdata.dev/properties/remove\",\"https://atomicdata.dev/properties/destroy\"]"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/requires","[\"https://atomicdata.dev/properties/shortname\",\"https://atomicdata.dev/properties/description\"]"]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/description","A Commit describes a possible type of value, such as 'string' or 'integer'."]
["https://atomicdata.dev/classes/Commit","https://atomicdata.dev/properties/shortname","commit"]
["https://atomicdata.dev/classes/Agent","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Class\"]"]
["https://atomicdata.dev/classes/Agent","https://atomicdata.dev/properties/requires","[\"https://atomicdata.dev/properties/createdAt\",\"https://atomicdata.dev/properties/name\",\"https://atomicdata.dev/properties/publicKey\"]"]
["https://atomicdata.dev/classes/Agent","https://atomicdata.dev/properties/recommends","[\"https://atomicdata.dev/properties/description\",\"https://atomicdata.dev/properties/remove\",\"https://atomicdata.dev/properties/destroy\"]"]
["https://atomicdata.dev/classes/Agent","https://atomicdata.dev/properties/description","An Agent is a user that can create or modify data. It has two keys: a private and a public one. The private key should be kept secret. The publik key is for proving that the "]
["https://atomicdata.dev/classes/Agent","https://atomicdata.dev/properties/shortname","agent"]
# Datatypes
["https://atomicdata.dev/datatypes/string","https://atomicdata.dev/properties/shortname","string"]
["https://atomicdata.dev/datatypes/string","https://atomicdata.dev/properties/description","A UTF-8 string. Allows newlines with `\n`. This is a generic string datatype - don't use this for things like [markdown](https://atomicdata.dev/datatypes/markdown) or html."]
Expand All @@ -31,7 +36,7 @@
["https://atomicdata.dev/datatypes/date","https://atomicdata.dev/properties/description","ISO date _without time_.\nYYYY-MM-DD.\n\ne.g. `1991-01-20`\n."]
["https://atomicdata.dev/datatypes/date","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Datatype\"]"]
["https://atomicdata.dev/datatypes/slug","https://atomicdata.dev/properties/shortname","slug"]
["https://atomicdata.dev/datatypes/slug","https://atomicdata.dev/properties/description","Lowercase string without spaces, a-z. These are used for things like JSON keys." ]
["https://atomicdata.dev/datatypes/slug","https://atomicdata.dev/properties/description","Lowercase string without spaces. Only characters, numbers and dashes: `-`. These are used for things like JSON keys." ]
["https://atomicdata.dev/datatypes/slug","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Datatype\"]"]
["https://atomicdata.dev/datatypes/markdown","https://atomicdata.dev/properties/shortname","markdown"]
["https://atomicdata.dev/datatypes/markdown","https://atomicdata.dev/properties/description","Markdown UTF-8 String with [Commonmark syntax](https://commonmark.org/). [Here's a tutorial](https://commonmark.org/help/tutorial/)."]
Expand All @@ -45,6 +50,9 @@
["https://atomicdata.dev/datatypes/boolean","https://atomicdata.dev/properties/shortname","boolean"]
["https://atomicdata.dev/datatypes/boolean","https://atomicdata.dev/properties/description","Either 'true' or 'false'."]
["https://atomicdata.dev/datatypes/boolean","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Datatype\"]"]
["https://atomicdata.dev/datatypes/timestamp","https://atomicdata.dev/properties/shortname","timestamp"]
["https://atomicdata.dev/datatypes/timestamp","https://atomicdata.dev/properties/description","Similar to [Unix Timestamp](https://www.unixtimestamp.com/).\nMilliseconds since midnight UTC 1970 jan 01 (aka the [Unix Epoch](https://en.wikipedia.org/wiki/Unix_time)).\nUse this for most DateTime fields.\nSigned 64 bit integer (instead of 32 bit in Unix systems).\n\ne.g. `1596798919` (= 07 Aug 2020 11:15:19)"]
["https://atomicdata.dev/datatypes/timestamp","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Datatype\"]"]
# Properties
["https://atomicdata.dev/properties/description","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/description","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/markdown"]
Expand All @@ -61,7 +69,7 @@
["https://atomicdata.dev/properties/shortname","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/shortname","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/slug"]
["https://atomicdata.dev/properties/shortname","https://atomicdata.dev/properties/shortname","shortname"]
["https://atomicdata.dev/properties/shortname","https://atomicdata.dev/properties/description","A very short name of the thing."]
["https://atomicdata.dev/properties/shortname","https://atomicdata.dev/properties/description","A short name of something. It can only contain letters, numbers and dashes `-`. Useful in programming contexts where the user should be able to type something short to identify a specific thing."]
["https://atomicdata.dev/properties/recommends","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/recommends","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/resourceArray"]
["https://atomicdata.dev/properties/recommends","https://atomicdata.dev/properties/classtype","https://atomicdata.dev/classes/Property"]
Expand Down Expand Up @@ -89,11 +97,28 @@
["https://atomicdata.dev/properties/destroy","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/boolean"]
["https://atomicdata.dev/properties/destroy","https://atomicdata.dev/properties/shortname","destroy"]
["https://atomicdata.dev/properties/destroy","https://atomicdata.dev/properties/description","If set to true, the entire Subject resource will be removed in this commit. This will be executed _before_ other commands, such as set."]
["https://atomicdata.dev/properties/actor","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/actor","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/atomicURL"]
["https://atomicdata.dev/properties/actor","https://atomicdata.dev/properties/shortname","actor"]
["https://atomicdata.dev/properties/actor","https://atomicdata.dev/properties/description","The actor is the agent (person, organization or something else) that issued the commit."]
["https://atomicdata.dev/properties/signer","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/signer","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/atomicURL"]
["https://atomicdata.dev/properties/signer","https://atomicdata.dev/properties/classtype","https://atomicdata.dev/classes/Agent"]
["https://atomicdata.dev/properties/signer","https://atomicdata.dev/properties/shortname","signer"]
["https://atomicdata.dev/properties/signer","https://atomicdata.dev/properties/description","The signer is the agent (person, organization or something else) that issued the commit."]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/atomicURL"]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/string"]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/shortname","signature"]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/description","The signature is the agent (person, organization or something else) that issued the commit."]
["https://atomicdata.dev/properties/signature","https://atomicdata.dev/properties/description","The signature proves that a Commit is created by a specific Agent. It is a cryptographic proof - an RSA signature of the JSON serialized commit, minus the signature."]
["https://atomicdata.dev/properties/createdAt","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/createdAt","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/Timestamp"]
["https://atomicdata.dev/properties/createdAt","https://atomicdata.dev/properties/shortname","createdat"]
["https://atomicdata.dev/properties/createdAt","https://atomicdata.dev/properties/description","Timestamp when the Commit was created (usually when it was signed)."]
["https://atomicdata.dev/properties/subject","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/subject","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/atomicURL"]
["https://atomicdata.dev/properties/subject","https://atomicdata.dev/properties/shortname","subject"]
["https://atomicdata.dev/properties/subject","https://atomicdata.dev/properties/description","The subject of a Delta - the resource ID that is being changed."]
["https://atomicdata.dev/properties/name","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/name","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/string"]
["https://atomicdata.dev/properties/name","https://atomicdata.dev/properties/shortname","name"]
["https://atomicdata.dev/properties/name","https://atomicdata.dev/properties/description","The name of a thing or person."]
["https://atomicdata.dev/properties/publicKey","https://atomicdata.dev/properties/isA","[\"https://atomicdata.dev/classes/Property\"]"]
["https://atomicdata.dev/properties/publicKey","https://atomicdata.dev/properties/datatype","https://atomicdata.dev/datatypes/string"]
["https://atomicdata.dev/properties/publicKey","https://atomicdata.dev/properties/shortname","publickey"]
["https://atomicdata.dev/properties/publicKey","https://atomicdata.dev/properties/description","The publicKey of an Agent. Is a base64 serialized Ed25519 key."]
2 changes: 1 addition & 1 deletion lib/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ fn main() {
// A subject URL has been created automatically.
let subject = new_property.get_subject();
let fetched_new_resource = store.get_resource(subject).unwrap();
assert!(fetched_new_resource.get_shortname("description").unwrap().to_string() == "age");
assert!(fetched_new_resource.get_shortname("description").unwrap().to_string() == "the age of a person");
}
35 changes: 35 additions & 0 deletions lib/examples/signing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
fn main() {
use ring::{
rand,
signature::{self, KeyPair},
};

// Generate a key pair in PKCS#8 (v2) format.
let rng = rand::SystemRandom::new();
let pkcs8_bytes = signature::Ed25519KeyPair::generate_pkcs8(&rng).unwrap();

// Normally the application would store the PKCS#8 file persistently. Later
// it would read the PKCS#8 file from persistent storage to use it.

let key_pair = signature::Ed25519KeyPair::from_pkcs8(pkcs8_bytes.as_ref()).unwrap();

// Sign the message "hello, world".
const MESSAGE: &[u8] = b"hello, world";
let sig = key_pair.sign(MESSAGE);

let pubkey_b64 = base64::encode(key_pair.public_key());

let peer_public_key_bytes = base64::decode(pubkey_b64).unwrap();

// Normally an application would extract the bytes of the signature and
// send them in a protocol message to the peer(s). Here we just get the
// public key key directly from the key pair.
// let peer_public_key_bytes = key_pair.public_key().as_ref();

// Verify the signature of the message using the public key. Normally the
// verifier of the message would parse the inputs to this code out of the
// protocol message(s) sent by the signer.
let peer_public_key =
signature::UnparsedPublicKey::new(&signature::ED25519, peer_public_key_bytes);
peer_public_key.verify(MESSAGE, sig.as_ref()).unwrap();
}
6 changes: 3 additions & 3 deletions lib/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{errors::AtomicResult, parse::parse_ad3, ResourceString};
pub fn fetch_resource(subject: &str) -> AtomicResult<ResourceString> {
let resp = ureq::get(&subject)
.set("Accept", crate::parse::AD3_MIME)
.timeout_read(500)
.timeout_read(2000)
.call();
if resp.status() != 200 {
return Err(format!("Could not fetch {}. Status: {}", subject, resp.status()).into());
Expand All @@ -33,7 +33,7 @@ pub fn post_commit(endpoint: &str, commit: &crate::Commit) -> AtomicResult<()> {

let resp = ureq::post(&endpoint)
.set("Content-Type", "application/json")
.timeout_read(500)
.timeout_read(2000)
.send_string(&json);

if resp.error() {
Expand All @@ -56,7 +56,7 @@ mod test {

#[test] #[ignore]
fn post_commit_basic() {
let commit = crate::delta::PartialCommit::new("subject".into(), "actor".into()).sign("private_key");
let commit = crate::commit::CommitBuilder::new("subject".into(), "actor".into()).sign("private_key").unwrap();
post_commit("https://atomicdata.dev/commit", &commit).unwrap();
}
}
Loading