Skip to content

Commit

Permalink
Merge branch 'main' into uniffi-holder
Browse files Browse the repository at this point in the history
Signed-off-by: George Mulhearn <[email protected]>
  • Loading branch information
gmulhearn authored Oct 31, 2023
2 parents 3212357 + a521dc4 commit 7e58bd8
Show file tree
Hide file tree
Showing 74 changed files with 761 additions and 833 deletions.
7 changes: 6 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions agency_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ edition.workspace = true
doctest = false

[dependencies]
async-trait = "0.1.53"
env_logger = "0.9.0"
log = "0.4.16"
lazy_static = "1.3"
serde = "1.0.97"
serde_json = "1.0.40"
serde_derive = "1.0.97"
reqwest = "0.11.10"
regex = "1.1.0"
url = { version = "2.3", features = ["serde"] }
uuid = { version = "0.8", default-features = false, features = ["v4"]}
thiserror = "1.0.37"
async-trait = "0.1.73"
shared_vcx = { path = "../shared_vcx" }
16 changes: 8 additions & 8 deletions agency_client/src/errors/mapping_sharedvcx.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use shared_vcx::errors::error::{SharedVcxError, SharedVcxErrorKind};
use shared_vcx::errors::validation::{ValidationError, ValidationErrorKind};

use crate::errors::error::{AgencyClientError, AgencyClientErrorKind};

impl From<SharedVcxErrorKind> for AgencyClientErrorKind {
fn from(error: SharedVcxErrorKind) -> Self {
impl From<ValidationErrorKind> for AgencyClientErrorKind {
fn from(error: ValidationErrorKind) -> Self {
match error {
SharedVcxErrorKind::InvalidDid => AgencyClientErrorKind::InvalidDid,
SharedVcxErrorKind::InvalidVerkey => AgencyClientErrorKind::InvalidVerkey,
SharedVcxErrorKind::NotBase58 => AgencyClientErrorKind::NotBase58,
ValidationErrorKind::InvalidDid => AgencyClientErrorKind::InvalidDid,
ValidationErrorKind::InvalidVerkey => AgencyClientErrorKind::InvalidVerkey,
ValidationErrorKind::NotBase58 => AgencyClientErrorKind::NotBase58,
}
}
}

impl From<SharedVcxError> for AgencyClientError {
fn from(error: SharedVcxError) -> Self {
impl From<ValidationError> for AgencyClientError {
fn from(error: ValidationError) -> Self {
let kind: AgencyClientErrorKind = error.kind().into();
AgencyClientError::from_msg(kind, error.to_string())
}
Expand Down
121 changes: 0 additions & 121 deletions agency_client/src/httpclient.rs

This file was deleted.

34 changes: 31 additions & 3 deletions agency_client/src/internal/messaging.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
use core::u8;

use serde_json::Value;
use shared_vcx::http_client::post_message;

use crate::{
agency_client::AgencyClient,
errors::error::{AgencyClientError, AgencyClientErrorKind, AgencyClientResult},
httpclient,
messages::{a2a_message::Client2AgencyMessage, forward::ForwardV2},
testing::mocking::AgencyMockDecrypted,
testing::{
mocking,
mocking::{AgencyMock, AgencyMockDecrypted, HttpClientMockResponse},
},
};

impl AgencyClient {
pub async fn post_to_agency(&self, body_content: Vec<u8>) -> AgencyClientResult<Vec<u8>> {
let url = self.get_agency_url_full()?;
httpclient::post_message(body_content, url).await
if mocking::agency_mocks_enabled() {
if HttpClientMockResponse::has_response() {
warn!("post_message >> mocking response for POST {}", &url);
return HttpClientMockResponse::get_response();
}
if AgencyMockDecrypted::has_decrypted_mock_responses() {
warn!(
"post_message >> will use mocked decrypted response for POST {}",
&url
);
return Ok(vec![]);
}
let mocked_response = AgencyMock::get_response();
warn!(
"post_message >> mocking response of length {} for POST {}",
mocked_response.len(),
&url
);
return Ok(mocked_response);
}
post_message(body_content, url).await.map_err(|err| {
AgencyClientError::from_msg(
AgencyClientErrorKind::PostMessageFailed,
format!("Cannot send message to agency: {err}"),
)
})
}

pub async fn prepare_message_for_agency(
Expand Down
2 changes: 0 additions & 2 deletions agency_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern crate serde_derive;

use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;

mod utils;

#[macro_use]
Expand All @@ -18,7 +17,6 @@ pub mod agency_client;
pub mod api;
pub mod configuration;

pub mod httpclient;
pub mod messages;
pub mod testing;
pub mod wallet;
Expand Down
7 changes: 3 additions & 4 deletions agents/node/vcxagent-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@
"demo:faber:mysql": "node demo/faber.js --mysql",
"demo:alice:sign": "node demo/alice-signature.js",
"demo:faber:verify": "node demo/faber-verify-signature.js",
"test:integration": "npm run test:integration:issue-verify && npm run test:integration:signing && npm run test:integration:messaging && npm run test:integration:tails && npm run test:integration:trustping && npm run test:integration:feature-discovery && npm run test:integration:public-invite && npm run test:integration:out-of-band && npm run test:integration:endpoint && npm run test:integration:connection",
"test:integration": "npm run test:integration:issue-verify && npm run test:integration:signing && npm run test:integration:messaging && npm run test:integration:tails && npm run test:integration:trustping && npm run test:integration:public-invite && npm run test:integration:out-of-band && npm run test:integration:endpoint && npm run test:integration:connection",
"test:integration:issue-verify": "jest --forceExit --env=node --runInBand test/issue-verify.spec.js",
"test:integration:signing": "jest --forceExit --env=node --runInBand test/sign-verify.spec.js",
"test:integration:messaging": "jest --forceExit --env=node --runInBand test/messaging.spec.js",
"test:integration:tails": "jest --forceExit --env=node --runInBand test/distribute-tails.spec.js",
"test:integration:trustping": "jest --forceExit --env=node --runInBand test/trustping.spec.js",
"test:integration:feature-discovery": "jest --forceExit --env=node --runInBand test/feature-discovery.spec.js",
"test:integration:public-invite": "jest --forceExit --env=node --runInBand test/public-invite.spec.js",
"test:integration:out-of-band": "jest --forceExit --env=node --runInBand test/out-of-band.spec.js",
"test:integration:endpoint": "jest --forceExit --env=node --runInBand test/endpoint.spec.js",
"test:integration:connection": "jest --forceExit --env=node --runInBand test/connection.spec.js"
},
"dependencies": {
"@hyperledger/node-vcx-wrapper": "file:../../../wrappers/node",
"axios": "^0.27.2",
"axios": "^1.6.0",
"ffi-napi": "^4.0.3",
"fs-extra": "^4.0.3",
"lodash": "^4.17.21",
Expand All @@ -64,7 +63,7 @@
"command-line-usage": "^5.0.5",
"express": "^4.17.1",
"is-port-reachable": "^2.0.1",
"jest": "^26.6.3",
"jest": "^29.7.0",
"readline-sync": "^1.4.10",
"standard": "^16.0.4",
"winston": "^3.3.3"
Expand Down
5 changes: 2 additions & 3 deletions agents/node/vcxagent-core/src/common.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const sleepPromise = require('sleep-promise')
const axios = require('axios')
const combineURLs = require('axios/lib/helpers/combineURLs')

module.exports.testTailsUrl = 'http://some-tails-url.org'

async function waitUntilAgencyIsReady (agencyEndpoint, logger) {
let agencyReady = false

const url = combineURLs(agencyEndpoint, '/agency')
const url = `${agencyEndpoint}/agency`

while (!agencyReady) {
try {
Expand All @@ -23,7 +22,7 @@ async function waitUntilAgencyIsReady (agencyEndpoint, logger) {
async function getAgencyConfig (agencyUrl, logger) {
let agencyDid, agencyVerkey

const url = combineURLs(agencyUrl, '/agency')
const url = `${agencyUrl}/agency`

logger.info(`Obtaining agency DID and verkey info from ${url}`)
try {
Expand Down
6 changes: 0 additions & 6 deletions agents/node/vcxagent-core/src/services/service-connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,6 @@ module.exports.createServiceConnections = function createServiceConnections ({ l
await connection.sendPing()
}

async function discoverTheirFeatures (connectionId) {
const connection = await getVcxConnection(connectionId)
await connection.sendDiscoveryFeatures()
}

return {
// inviter
inviterConnectionCreate,
Expand All @@ -206,7 +201,6 @@ module.exports.createServiceConnections = function createServiceConnections ({ l
updateAllReceivedMessages,

sendPing,
discoverTheirFeatures,

getState,
listIds,
Expand Down
3 changes: 2 additions & 1 deletion agents/node/vcxagent-core/test/connection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const express = require('express')
const { createAliceAndFaber } = require('./utils/utils')
const { initRustLogger } = require('../src')

jest.setTimeout(1000 * 60 * 4)

beforeAll(async () => {
jest.setTimeout(1000 * 60 * 4)
initRustLogger(process.env.RUST_LOG || 'vcx=error')
})

Expand Down
3 changes: 2 additions & 1 deletion agents/node/vcxagent-core/test/distribute-tails.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const { proofRequestDataStandard } = require('./utils/data')
const TAILS_DIR_ALICE = '/tmp/alice/tails'
const TAILS_DIR_FABER = '/tmp/faber/tails'

jest.setTimeout(1000 * 60 * 4)

beforeAll(async () => {
jest.setTimeout(1000 * 60 * 4)
initRustLogger(process.env.RUST_LOG || 'vcx=error')
mkdirp(TAILS_DIR_ALICE)
mkdirp(TAILS_DIR_FABER)
Expand Down
3 changes: 2 additions & 1 deletion agents/node/vcxagent-core/test/endpoint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const { ConnectionStateType } = require('@hyperledger/node-vcx-wrapper')
const { createAliceAndFaber } = require('./utils/utils')
const { initRustLogger } = require('../src')

jest.setTimeout(1000 * 60 * 4)

beforeAll(async () => {
jest.setTimeout(1000 * 60 * 4)
initRustLogger(process.env.RUST_LOG || 'vcx=error')
})

Expand Down
Loading

0 comments on commit 7e58bd8

Please sign in to comment.