Skip to content

Commit

Permalink
Refactor, remove legacy agency protocol (#127)
Browse files Browse the repository at this point in the history
* Rename modules api->api_c, v3->aries

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>

* Optimize imports, use explicit instead of * imports, fix rust warnings

Files messages/*.rs were importing everything from messages/mod.rs
which was causing linting problems in InteliJ Idea, failing to
resolve error:: module.

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>

* Remove legacy agency protocol

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>

* Remove mentions of legacy protocol from docs

* Dont propagate ignored args from c-layer to further calls

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>

* Update tests

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>

* Revert rename api->api_c

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
  • Loading branch information
Patrik-Stas authored Oct 5, 2020
1 parent 217e4ee commit 65bfe25
Show file tree
Hide file tree
Showing 140 changed files with 664 additions and 2,239 deletions.
2 changes: 1 addition & 1 deletion libvcx/Cargo.lock

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

91 changes: 11 additions & 80 deletions libvcx/src/api/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use error::prelude::*;
use utils::cstring::CStringUtils;
use utils::error;
use utils::threadpool::spawn;
use v3::messages::a2a::A2AMessage;
use aries::messages::a2a::A2AMessage;

/*
Tha API represents a pairwise connection with another identity owner.
Expand All @@ -18,26 +18,8 @@ use v3::messages::a2a::A2AMessage;
# States
The set of object states, messages and transitions depends on the communication method is used.
There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`.
The communication method can be specified as a config option on one of *_init functions.
proprietary:
Inviter:
VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called.
VcxStateType::VcxStateOfferSent - once `vcx_connection_connect` (send Connection invite) is called.
VcxStateType::VcxStateAccepted - once `connReqAnswer` messages is received.
use `vcx_connection_update_state` or `vcx_connection_update_state_with_message` functions for state updates.
VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called.
Invitee:
VcxStateType::VcxStateRequestReceived - once `vcx_connection_create_with_invite` (create Connection object with invite) is called.
VcxStateType::VcxStateAccepted - once `vcx_connection_connect` (accept Connection invite) is called.
VcxStateType::VcxStateNone - once `vcx_connection_delete_connection` (delete Connection object) is called.
aries:
Inviter:
VcxStateType::VcxStateInitialized - once `vcx_connection_create` (create Connection object) is called.
Expand Down Expand Up @@ -70,18 +52,6 @@ use v3::messages::a2a::A2AMessage;
# Transitions
proprietary:
Inviter:
VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized
VcxStateType::VcxStateInitialized - `vcx_connection_connect` - VcxStateType::VcxStateOfferSent
VcxStateType::VcxStateOfferSent - received `connReqAnswer` - VcxStateType::VcxStateAccepted
any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone`
Invitee:
VcxStateType::None - `vcx_connection_create_with_invite` - VcxStateType::VcxStateRequestReceived
VcxStateType::VcxStateRequestReceived - `vcx_connection_connect` - VcxStateType::VcxStateAccepted
any state - `vcx_connection_delete_connection` - `VcxStateType::VcxStateNone`
aries - RFC: https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0036-issue-credential
Inviter:
VcxStateType::None - `vcx_connection_create` - VcxStateType::VcxStateInitialized
Expand Down Expand Up @@ -114,10 +84,6 @@ use v3::messages::a2a::A2AMessage;
# Messages
proprietary:
ConnectionRequest (`connReq`)
ConnectionRequestAnswer (`connReqAnswer`)
aries:
Invitation - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect
ConnectionRequest - https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#1-connection-request
Expand Down Expand Up @@ -232,8 +198,6 @@ pub extern fn vcx_connection_create(command_handle: CommandHandle,
///
/// # Examples
/// invite_details -> depends on communication method:
/// proprietary:
/// {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}}
/// aries: https://github.com/hyperledger/aries-rfcs/tree/master/features/0160-connection-protocol#0-invitation-to-connect
/// {
/// "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation",
Expand Down Expand Up @@ -661,14 +625,12 @@ pub extern fn vcx_connection_get_state(command_handle: CommandHandle,
///
/// connection_handle: was provided during creation. Used to identify connection object
///
/// abbreviated: abbreviated connection details for QR codes or not (applicable for `proprietary` communication method only)
/// abbreviated: deprecated, has not effect
///
/// cb: Callback that provides the json string of details
///
/// # Example
/// details -> depends on communication method:
/// proprietary:
/// {"targetName": "", "statusMsg": "message created", "connReqId": "mugIkrWeMr", "statusCode": "MS-101", "threadId": null, "senderAgencyDetail": {"endpoint": "http://localhost:8080", "verKey": "key", "DID": "did"}, "senderDetail": {"agentKeyDlgProof": {"agentDID": "8f6gqnT13GGMNPWDa2TRQ7", "agentDelegatedKey": "5B3pGBYjDeZYSNk9CXvgoeAAACe2BeujaAkipEC7Yyd1", "signature": "TgGSvZ6+/SynT3VxAZDOMWNbHpdsSl8zlOfPlcfm87CjPTmC/7Cyteep7U3m9Gw6ilu8SOOW59YR1rft+D8ZDg=="}, "publicDID": "7YLxxEfHRiZkCMVNii1RCy", "name": "Faber", "logoUrl": "http://robohash.org/234", "verKey": "CoYZMV6GrWqoG9ybfH3npwH3FnWPcHmpWYUF8n172FUx", "DID": "Ney2FxHT4rdEyy6EDCCtxZ"}}
/// aries:
/// {
/// "label": "Alice",
Expand All @@ -686,23 +648,23 @@ pub extern fn vcx_connection_get_state(command_handle: CommandHandle,
#[no_mangle]
pub extern fn vcx_connection_invite_details(command_handle: CommandHandle,
connection_handle: u32,
abbreviated: bool,
_abbreviated: bool,
cb: Option<extern fn(xcommand_handle: CommandHandle, err: u32, details: *const c_char)>) -> u32 {
info!("vcx_connection_invite_details >>>");

check_useful_c_callback!(cb, VcxErrorKind::InvalidOption);

let source_id = get_source_id(connection_handle).unwrap_or_default();
trace!("vcx_connection_invite_details(command_handle: {}, connection_handle: {}, abbreviated: {}), source_id: {:?}",
command_handle, connection_handle, abbreviated, source_id);
trace!("vcx_connection_invite_details(command_handle: {}, connection_handle: {}), source_id: {:?}",
command_handle, connection_handle, source_id);

if !is_valid_handle(connection_handle) {
error!("vcx_connection_get_state - invalid handle");
return VcxError::from(VcxErrorKind::InvalidConnectionHandle).into();
}

spawn(move || {
match get_invite_details(connection_handle, abbreviated) {
match get_invite_details(connection_handle) {
Ok(str) => {
trace!("vcx_connection_invite_details_cb(command_handle: {}, connection_handle: {}, rc: {}, details: {}), source_id: {:?}",
command_handle, connection_handle, error::SUCCESS.message, str, source_id);
Expand Down Expand Up @@ -734,37 +696,7 @@ pub extern fn vcx_connection_invite_details(command_handle: CommandHandle,
///
/// msg: actual message to send
///
/// send_msg_options: (applicable for `proprietary` communication method only)
/// {
/// msg_type: String, // type of message to send. can be any string.
/// msg_title: String, // message title (user notification)
/// ref_msg_id: Option<String>, // If responding to a message, id of the message
/// }
///
/// # Example:
/// msg ->
/// "HI"
/// OR
/// {"key": "value"}
/// OR
/// {
/// "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping",
/// "@id": "518be002-de8e-456e-b3d5-8fe472477a86",
/// "comment": "Hi. Are you listening?",
/// "response_requested": true
/// }
///
/// send_msg_options ->
/// {
/// "msg_type":"Greeting",
/// "msg_title": "Hi There"
/// }
/// OR
/// {
/// "msg_type":"Greeting",
/// "msg_title": "Hi There",
/// "ref_msg_id" "as2d343sag"
/// }
/// send_msg_options: deprecated, has not effect
///
/// cb: Callback that provides id of retrieved response message
///
Expand All @@ -774,19 +706,18 @@ pub extern fn vcx_connection_invite_details(command_handle: CommandHandle,
pub extern fn vcx_connection_send_message(command_handle: CommandHandle,
connection_handle: u32,
msg: *const c_char,
send_msg_options: *const c_char,
_send_msg_options: *const c_char,
cb: Option<extern fn(xcommand_handle: CommandHandle, err: u32, msg_id: *const c_char)>) -> u32 {
info!("vcx_connection_send_message >>>");

check_useful_c_callback!(cb, VcxErrorKind::InvalidOption);
check_useful_c_str!(msg, VcxErrorKind::InvalidOption);
check_useful_c_str!(send_msg_options, VcxErrorKind::InvalidOption);

trace!("vcx_connection_send_message(command_handle: {}, connection_handle: {}, msg: {}, send_msg_options: {})",
command_handle, connection_handle, msg, send_msg_options);
trace!("vcx_connection_send_message(command_handle: {}, connection_handle: {}, msg: {})",
command_handle, connection_handle, msg);

spawn(move || {
match send_generic_message(connection_handle, &msg, &send_msg_options) {
match send_generic_message(connection_handle, &msg) {
Ok(x) => {
trace!("vcx_connection_send_message_cb(command_handle: {}, rc: {}, msg_id: {})",
command_handle, error::SUCCESS.message, x);
Expand Down
6 changes: 0 additions & 6 deletions libvcx/src/api/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::ptr;

use indy_sys::CommandHandle;
use libc::c_char;
use serde_json;

use connection;
use credential;
Expand All @@ -18,7 +17,6 @@ use utils::threadpool::spawn;
# State
The set of object states, messages and transitions depends on the communication method is used.
There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`.
The communication method can be specified as a config option on one of *_init functions.
VcxStateType::VcxStateRequestReceived - once `vcx_credential_create_with_offer` (create Credential object) is called.
Expand Down Expand Up @@ -96,8 +94,6 @@ pub extern fn vcx_credential_get_payment_info(command_handle: CommandHandle,
///
/// # Example
/// offer -> depends on communication method:
/// proprietary:
/// [{"msg_type": "CREDENTIAL_OFFER","version": "0.1","to_did": "...","from_did":"...","credential": {"account_num": ["...."],"name_on_account": ["Alice"]},"schema_seq_no": 48,"issuer_did": "...","credential_name": "Account Certificate","credential_id": "3675417066","msg_ref_id": "ymy5nth"}]
/// aries:
/// {"@type":"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/offer-credential", "@id":"<uuid-of-offer-message>", "comment":"somecomment", "credential_preview":<json-ldobject>, "offers~attach":[{"@id":"libindy-cred-offer-0", "mime-type":"application/json", "data":{"base64":"<bytesforbase64>"}}]}
///
Expand Down Expand Up @@ -152,8 +148,6 @@ pub extern fn vcx_credential_create_with_offer(command_handle: CommandHandle,
///
/// # Example
/// credential -> depends on communication method:
/// proprietary:
/// {"credential_id":"cred_id", "credential": {"libindy_cred":"{....}","rev_reg_def_json":"","cred_def_id":"cred_def_id","msg_type":"CLAIM","claim_offer_id":"1234","version":"0.1","from_did":"did"}}
/// aries:
/// https://github.com/hyperledger/aries-rfcs/tree/master/features/0036-issue-credential#issue-credential
///
Expand Down
19 changes: 0 additions & 19 deletions libvcx/src/api/disclosed_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,8 @@ use utils::threadpool::spawn;
# State
The set of object states, messages and transitions depends on the communication method is used.
There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`.
The communication method can be specified as a config option on one of *_init functions.
proprietary:
VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called.
VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_generate_proof` is called.
VcxStateType::VcxStateAccepted - once `vcx_disclosed_proof_send_proof` (send `PROOF` message) is called.
aries:
VcxStateType::VcxStateRequestReceived - once `vcx_disclosed_proof_create_with_request` (create DisclosedProof object) is called.
Expand All @@ -40,13 +32,6 @@ use utils::threadpool::spawn;
# Transitions
proprietary:
VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived
VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_generate_proof` - VcxStateType::VcxStateRequestReceived
VcxStateType::VcxStateRequestReceived - `vcx_disclosed_proof_send_proof` - VcxStateType::VcxStateAccepted
aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation
VcxStateType::None - `vcx_disclosed_proof_create_with_request` - VcxStateType::VcxStateRequestReceived
Expand All @@ -60,10 +45,6 @@ use utils::threadpool::spawn;
# Messages
proprietary:
ProofRequest (`PROOF_REQ`)
Proof (`PROOF`)
aries:
PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation
Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation
Expand Down
2 changes: 0 additions & 2 deletions libvcx/src/api/issuer_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::ptr;

use indy_sys::CommandHandle;
use libc::c_char;
use serde_json;

use connection;
use error::prelude::*;
Expand All @@ -19,7 +18,6 @@ use utils::threadpool::spawn;
# State
The set of object states, messages and transitions depends on the communication method is used.
There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`.
The communication method can be specified as a config option on one of *_init functions.
VcxStateType::VcxStateInitialized - once `vcx_issuer_create_credential` (create IssuerCredential object) is called.
Expand Down
20 changes: 0 additions & 20 deletions libvcx/src/api/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ use utils::threadpool::spawn;
# State
The set of object states, messages and transitions depends on the communication method is used.
There are two communication methods: `proprietary` and `aries`. The default communication method is `proprietary`.
The communication method can be specified as a config option on one of *_init functions.
proprietary:
VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called.
VcxStateType::VcxStateOfferSent - once `vcx_credential_send_request` (send `PROOF_REQ` message) is called.
VcxStateType::VcxStateAccepted - once `PROOF` messages is received.
use `vcx_proof_update_state` or `vcx_proof_update_state_with_message` functions for state updates.
aries:
VcxStateType::VcxStateInitialized - once `vcx_proof_create` (create Proof object) is called.
Expand All @@ -41,13 +32,6 @@ use utils::threadpool::spawn;
# Transitions
proprietary:
VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized
VcxStateType::VcxStateInitialized - `vcx_credential_send_request` - VcxStateType::VcxStateOfferSent
VcxStateType::VcxStateOfferSent - received `PROOF` - VcxStateType::VcxStateAccepted
aries: RFC - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#propose-presentation
VcxStateType::None - `vcx_proof_create` - VcxStateType::VcxStateInitialized
Expand All @@ -59,10 +43,6 @@ use utils::threadpool::spawn;
# Messages
proprietary:
ProofRequest (`PROOF_REQ`)
Proof (`PROOF`)
aries:
PresentationRequest - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#request-presentation
Presentation - https://github.com/hyperledger/aries-rfcs/tree/7b6b93acbaf9611d3c892c4bada142fe2613de6e/features/0037-present-proof#presentation
Expand Down
1 change: 0 additions & 1 deletion libvcx/src/api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ pub extern fn vcx_set_next_agency_response(message_index: u32) {
info!("vcx_set_next_agency_response >>>");

let message = match message_index {
1 => CREATE_KEYS_RESPONSE.to_vec(),
2 => UPDATE_PROFILE_RESPONSE.to_vec(),
3 => GET_MESSAGES_RESPONSE.to_vec(),
4 => UPDATE_CREDENTIAL_RESPONSE.to_vec(),
Expand Down
1 change: 0 additions & 1 deletion libvcx/src/api/vcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use utils::libindy::{ledger, pool, wallet};
use utils::libindy::pool::{init_pool, is_pool_open};
use utils::threadpool::spawn;
use utils::version_constants;
use indy_sys::INVALID_POOL_HANDLE;

/// Initializes VCX with config settings
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use settings;
use settings::ProtocolTypes;
use utils::httpclient;
use utils::libindy::signus::create_and_store_my_did;
use v3::messages::a2a::A2AMessage;
use v3::messages::connection::did_doc::DidDoc;
use v3::utils::encryption_envelope::EncryptionEnvelope;
use aries::messages::a2a::A2AMessage;
use aries::messages::connection::did_doc::DidDoc;
use aries::utils::encryption_envelope::EncryptionEnvelope;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentInfo {
Expand Down
Loading

0 comments on commit 65bfe25

Please sign in to comment.