Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose the rust cargo.toml version string #422

Merged
merged 5 commits into from
May 19, 2022
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
72 changes: 72 additions & 0 deletions docs/reference/proto/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

- [KeyType](#okapi-keys-v1-KeyType)

- [okapi/metadata/metadata.proto](#okapi_metadata_metadata-proto)
- [MetadataRequest](#okapi-metadata-MetadataRequest)
- [MetadataResponse](#okapi-metadata-MetadataResponse)
- [MetadataResponse.VariablesEntry](#okapi-metadata-MetadataResponse-VariablesEntry)

- [okapi/proofs/v1/proofs.proto](#okapi_proofs_v1_proofs-proto)
- [CreateProofRequest](#okapi-proofs-v1-CreateProofRequest)
- [CreateProofResponse](#okapi-proofs-v1-CreateProofResponse)
Expand Down Expand Up @@ -372,6 +377,73 @@



<a name="okapi_metadata_metadata-proto"></a>
<p align="right"><a href="#top">Top</a></p>

## okapi/metadata/metadata.proto



<a name="okapi-metadata-MetadataRequest"></a>

### MetadataRequest
Request custom metadata about the native okapi binaries


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| variables | [string](#string) | repeated | optional field, can contain any of the cargo env vars |






<a name="okapi-metadata-MetadataResponse"></a>

### MetadataResponse
Metadata information about the native okapi binaries. Always returns the version information


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [string](#string) | | The full version string from okapi |
| version_major | [int32](#int32) | | Major version |
| version_minor | [int32](#int32) | | Minor version |
| variables | [MetadataResponse.VariablesEntry](#okapi-metadata-MetadataResponse-VariablesEntry) | repeated | etc

will include any non default requested variables |






<a name="okapi-metadata-MetadataResponse-VariablesEntry"></a>

### MetadataResponse.VariablesEntry



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| key | [string](#string) | | |
| value | [string](#string) | | |















<a name="okapi_proofs_v1_proofs-proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
4 changes: 4 additions & 0 deletions include/okapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ int32_t ldproofs_verify_proof(struct ByteBuffer request,
struct ByteBuffer *response,
struct ExternError *err);

int32_t okapi_metadata(struct ByteBuffer request,
struct ByteBuffer *response,
struct ExternError *err);

int32_t oberon_create_key(struct ByteBuffer request,
struct ByteBuffer *response,
struct ExternError *err);
Expand Down
4 changes: 2 additions & 2 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "okapi"
version = "0.1.0"
authors = ["Tomislav Markovski <[email protected]>"]
authors = ["Tomislav Markovski <[email protected]>", "Scott Phillips <[email protected]>"]
edition = "2018"
# ensure this is not checked in as "true" as it will
# cause vendored libraries to fail compilation due
Expand Down Expand Up @@ -49,7 +49,7 @@ wasm-bindgen-test = "0.3.13"

[package.metadata.deb]
maintainer = "Tomislav Markovski <[email protected]>"
copyright = "2021, Trinsic <[email protected]>"
copyright = "2021-2022, Trinsic <[email protected]>"
license-file = ["../LICENSE", "4"]
extended-description = """\
Collection of tools that support workflows for \
Expand Down
3 changes: 3 additions & 0 deletions native/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn compile_protobuf_files() {
"../proto/okapi/keys/v1/keys.proto",
"../proto/okapi/proofs/v1/proofs.proto",
"../proto/okapi/security/v1/security.proto",
"../proto/okapi/metadata/metadata.proto",
],
&["../proto", "../proto/pbmse/v1/"],
)
Expand All @@ -56,6 +57,7 @@ fn compile_protobuf_files() {
copy("okapi.transport.v1.rs", "./src/proto/okapi/okapi_transport.rs").unwrap();
copy("okapi.proofs.v1.rs", "./src/proto/okapi/okapi_proofs.rs").unwrap();
copy("okapi.security.v1.rs", "./src/proto/okapi/okapi_security.rs").unwrap();
copy("okapi.metadata.rs", "./src/proto/okapi/okapi_metadata.rs").unwrap();
copy("google.protobuf.rs", "./src/proto/google_protobuf.rs").unwrap();
copy("pbmse.v1.rs", "./src/proto/pbmse.rs").unwrap();
remove_file("okapi.examples.v1.rs").unwrap();
Expand All @@ -64,6 +66,7 @@ fn compile_protobuf_files() {
remove_file("okapi.transport.v1.rs").unwrap();
remove_file("okapi.proofs.v1.rs").unwrap();
remove_file("okapi.security.v1.rs").unwrap();
remove_file("okapi.metadata.rs").unwrap();
remove_file("google.protobuf.rs").unwrap();
remove_file("pbmse.v1.rs").unwrap();
}
7 changes: 7 additions & 0 deletions native/src/ffi/metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::{proto::metadata::*, *};
use ffi_support::{ByteBuffer, ExternError};

#[no_mangle]
pub extern "C" fn okapi_metadata(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 {
c_impl!(MetadataRequest, Metadata, get_metadata, request, response, err)
}
1 change: 1 addition & 0 deletions native/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ pub mod didcomm;
pub mod didkey;
pub mod hashing;
pub mod ldproofs;
pub mod metadata;
pub mod oberon;
pub mod utils;
5 changes: 3 additions & 2 deletions native/src/ffi/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ffi_support::ByteBuffer;
use std::os::raw::c_char;

// TODO: Cargo build doesn't expand these correctly with cbindgen, manually expanded below.
// define_string_destructor!(didcomm_string_free2);
Expand All @@ -15,7 +16,7 @@ pub extern "C" fn didcomm_byte_buffer_free(v: ByteBuffer) {

#[no_mangle]
#[deprecated]
pub unsafe extern "C" fn didcomm_string_free(s: *mut std::os::raw::c_char) {
pub unsafe extern "C" fn didcomm_string_free(s: *mut c_char) {
// Note: This should never happen, but in the case of a bug aborting
// here is better than the badness that happens if we unwind across
// the FFI boundary.
Expand All @@ -35,7 +36,7 @@ pub extern "C" fn okapi_bytebuffer_free(v: ByteBuffer) {
}

#[no_mangle]
pub unsafe extern "C" fn okapi_string_free(s: *mut std::os::raw::c_char) {
pub unsafe extern "C" fn okapi_string_free(s: *mut c_char) {
// Note: This should never happen, but in the case of a bug aborting
// here is better than the badness that happens if we unwind across
// the FFI boundary.
Expand Down
4 changes: 3 additions & 1 deletion native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct DIDKey {}
pub struct LdProofs {}
pub struct Oberon {}
pub struct Hashing {}
pub struct Metadata {}

#[allow(clippy::ptr_arg)]
pub trait MessageFormatter {
Expand Down Expand Up @@ -44,7 +45,8 @@ pub mod didkey;
mod ffi;
#[cfg(feature = "hashing")]
pub mod hashing;
mod ldproofs;
pub mod ldproofs;
pub mod metadata;
pub mod oberon;
pub mod proto;
#[cfg(test)]
Expand Down
19 changes: 19 additions & 0 deletions native/src/metadata/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::didcomm::Error;
use crate::proto::okapi::okapi_metadata::{MetadataRequest, MetadataResponse};

impl crate::Metadata {
pub fn get_metadata<'a>(_request: &MetadataRequest) -> Result<MetadataResponse, Error<'a>> {
Ok(MetadataResponse {
version: option_env!("CARGO_PKG_VERSION").unwrap_or_default().to_string(),
version_major: option_env!("CARGO_PKG_VERSION_MAJOR").unwrap_or_default().parse().unwrap_or_default(),
version_minor: option_env!("CARGO_PKG_VERSION_MINOR").unwrap_or_default().parse().unwrap_or_default(),
version_patch: option_env!("CARGO_PKG_VERSION_PATCH").unwrap_or_default().parse().unwrap_or_default(),

target_family: option_env!("CARGO_CFG_TARGET_FAMILY").unwrap_or_default().to_string(),
target_os: option_env!("CARGO_CFG_TARGET_OS").unwrap_or_default().to_string(),
target_arch: option_env!("CARGO_CFG_TARGET_ARCH").unwrap_or_default().to_string(),
target_vendor: option_env!("CARGO_CFG_TARGET_VENDOR").unwrap_or_default().to_string(),
target_env: option_env!("CARGO_CFG_TARGET_ENV").unwrap_or_default().to_string(),
})
}
}
18 changes: 9 additions & 9 deletions native/src/proto/google_protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Struct {
/// Unordered map of dynamically typed values.
#[prost(map="string, message", tag="1")]
#[prost(map = "string, message", tag = "1")]
pub fields: ::std::collections::HashMap<::prost::alloc::string::String, Value>,
}
/// `Value` represents a dynamically typed value which can be either
Expand All @@ -21,7 +21,7 @@ pub struct Struct {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Value {
/// The kind of value.
#[prost(oneof="value::Kind", tags="1, 2, 3, 4, 5, 6")]
#[prost(oneof = "value::Kind", tags = "1, 2, 3, 4, 5, 6")]
pub kind: ::core::option::Option<value::Kind>,
}
/// Nested message and enum types in `Value`.
Expand All @@ -30,22 +30,22 @@ pub mod value {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
/// Represents a null value.
#[prost(enumeration="super::NullValue", tag="1")]
#[prost(enumeration = "super::NullValue", tag = "1")]
NullValue(i32),
/// Represents a double value.
#[prost(double, tag="2")]
#[prost(double, tag = "2")]
NumberValue(f64),
/// Represents a string value.
#[prost(string, tag="3")]
#[prost(string, tag = "3")]
StringValue(::prost::alloc::string::String),
/// Represents a boolean value.
#[prost(bool, tag="4")]
#[prost(bool, tag = "4")]
BoolValue(bool),
/// Represents a structured value.
#[prost(message, tag="5")]
#[prost(message, tag = "5")]
StructValue(super::Struct),
/// Represents a repeated `Value`.
#[prost(message, tag="6")]
#[prost(message, tag = "6")]
ListValue(super::ListValue),
}
}
Expand All @@ -55,7 +55,7 @@ pub mod value {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValue {
/// Repeated field of dynamically typed values.
#[prost(message, repeated, tag="1")]
#[prost(message, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<Value>,
}
/// `NullValue` is a singleton enumeration to represent the null value for the
Expand Down
3 changes: 3 additions & 0 deletions native/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,6 @@ pub mod hashing {
}
pub mod okapi;
pub mod pbmse;
pub mod metadata {
pub use crate::proto::okapi::okapi_metadata::*;
}
1 change: 1 addition & 0 deletions native/src/proto/okapi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod okapi_examples;
pub mod okapi_hashing;
pub mod okapi_keys;
pub mod okapi_metadata;
pub mod okapi_proofs;
pub mod okapi_security;
pub mod okapi_transport;
5 changes: 2 additions & 3 deletions native/src/proto/okapi/okapi_examples.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct BasicMessage {
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub text: ::prost::alloc::string::String,
}
44 changes: 18 additions & 26 deletions native/src/proto/okapi/okapi_hashing.rs
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3HashRequest {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3HashResponse {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub digest: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3KeyedHashRequest {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="2")]
#[prost(bytes = "vec", tag = "2")]
pub key: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3KeyedHashResponse {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub digest: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3DeriveKeyRequest {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub context: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="2")]
#[prost(bytes = "vec", tag = "2")]
pub key_material: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Blake3DeriveKeyResponse {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub digest: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Sha256HashRequest {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub data: ::prost::alloc::vec::Vec<u8>,
}
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct Sha256HashResponse {
#[prost(bytes="vec", tag="1")]
#[prost(bytes = "vec", tag = "1")]
pub digest: ::prost::alloc::vec::Vec<u8>,
}
Loading