Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
1,655 changes: 918 additions & 737 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions kepler-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ tokio = ["sea-orm/runtime-tokio-rustls"]
async-std = ["sea-orm/runtime-async-std-rustls"]

[dependencies]
sea-orm = { version = "0.11", default-features = false, features = ["macros", "with-time", "with-json", "sqlx", "sea-orm-internal", "sqlx-dep"] }
sea-orm-migration = { version = "0.11", default-features = false }
sea-orm = { version = "0.12", default-features = false, features = ["macros", "with-time", "with-json", "sqlx", "sea-orm-internal", "sqlx-dep"] }
sea-orm-migration = { version = "0.12", default-features = false }
futures = { default-features = false, version = "0.3", features = ["alloc", "std"] }
pin-project = "1"
time = "0.3"
kepler-lib = { version = "0.2", path = "../lib" }
libp2p = { version = "0.52.1", default-features = false, features = ["ed25519"] }
thiserror = "1"
ssi = "0.6"
ssi = { version = "0.7", git = "https://github.com/spruceid/ssi", branch = "feat/ucan-0.10" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_ipld_dagcbor = "0.3"
serde_ipld_dagcbor = "0.4"

[dev-dependencies]
sea-orm = { version = "0.11", features = ["runtime-async-std-rustls", "sqlx-sqlite"] }
sea-orm = { version = "0.12", features = ["runtime-async-std-rustls", "sqlx-sqlite"] }
async-std = { version = "1", features = ["attributes"] }
318 changes: 150 additions & 168 deletions kepler-core/src/db.rs

Large diffs are not rendered by default.

41 changes: 13 additions & 28 deletions kepler-core/src/events/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use crate::{
hash::{hash, Hash},
types::Metadata,
util::{DelegationInfo, InvocationInfo, RevocationInfo},
};
pub use kepler_lib::{
authorization::{
EncodingError, HeaderEncode, KeplerDelegation, KeplerInvocation, KeplerRevocation,
},
authorization::{Delegation, EncodingError, HeaderEncode, Invocation, Revocation},
libipld::cid::{
multihash::{Code, Error as MultihashError, MultihashDigest},
Cid,
Expand All @@ -19,30 +16,18 @@ use serde_ipld_dagcbor::EncodeError;
#[derive(Debug)]
pub struct SerializedEvent<T>(pub T, pub(crate) Vec<u8>);

#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum FromReqErr<T> {
#[error(transparent)]
Encoding(#[from] EncodingError),
#[error(transparent)]
TryFrom(T),
}

impl<T> SerializedEvent<T> {
pub fn from_header_ser<I>(s: &str) -> Result<Self, FromReqErr<T::Error>>
where
T: TryFrom<I>,
I: HeaderEncode,
{
I::decode(s)
.map_err(FromReqErr::from)
.and_then(|(i, s)| Ok(Self(T::try_from(i).map_err(FromReqErr::TryFrom)?, s)))
impl<T> SerializedEvent<T>
where
T: HeaderEncode,
{
pub fn from_header_ser(s: &str) -> Result<Self, EncodingError> {
T::decode(s).map(|(t, s)| Self(t, s))
}
}

pub type Delegation = SerializedEvent<DelegationInfo>;
pub type Invocation = SerializedEvent<InvocationInfo>;
pub type Revocation = SerializedEvent<RevocationInfo>;
pub type SDelegation = SerializedEvent<Delegation>;
pub type SInvocation = SerializedEvent<Invocation>;
pub type SRevocation = SerializedEvent<Revocation>;

#[derive(Debug, Hash, PartialEq, Eq)]
pub(crate) enum Operation {
Expand Down Expand Up @@ -116,9 +101,9 @@ pub(crate) enum VersionedOperation {

#[derive(Debug)]
pub(crate) enum Event {
Invocation(Box<Invocation>, Vec<Operation>),
Delegation(Box<Delegation>),
Revocation(Box<Revocation>),
Invocation(Box<SInvocation>, Vec<Operation>),
Delegation(Box<SDelegation>),
Revocation(Box<SRevocation>),
}

impl Event {
Expand Down
2 changes: 1 addition & 1 deletion kepler-core/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn get_did_key(key: PublicKey) -> String {
use kepler_lib::libipld::cid::multibase;
// only ed25519 feature is enabled, so this unwrap should never fail
let ed25519_pk_bytes = key.try_into_ed25519().unwrap().to_bytes();
let multicodec_pk = [[0xed].as_slice(), ed25519_pk_bytes.as_slice()].concat();
let multicodec_pk = [[0xed, 0x01].as_slice(), ed25519_pk_bytes.as_slice()].concat();
format!(
"did:key:{}",
multibase::encode(multibase::Base::Base58Btc, multicodec_pk)
Expand Down
1 change: 0 additions & 1 deletion kepler-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod models;
pub mod relationships;
pub mod storage;
pub mod types;
pub mod util;

pub use db::{Commit, InvocationOutcome, OrbitDatabase, TxError, TxStoreError};
pub use libp2p;
Expand Down
4 changes: 2 additions & 2 deletions kepler-core/src/models/abilities.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::hash::Hash;
use crate::types::{Caveats, Resource};
use crate::types::{AbilityName, Caveats, Resource};
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
Expand All @@ -9,7 +9,7 @@ pub struct Model {
#[sea_orm(primary_key)]
pub resource: Resource,
#[sea_orm(primary_key)]
pub ability: String,
pub ability: AbilityName,
#[sea_orm(primary_key)]
pub delegation: Hash,

Expand Down
Loading