From ab772de34b420fab7359c789a7bfd85093e503cc Mon Sep 17 00:00:00 2001 From: glowkey Date: Mon, 19 Feb 2018 09:25:11 -0700 Subject: [PATCH] refactor cxs to vcx (#189) Signed-off-by: glowkey --- cxs/ci/scripts/readme.txt | 31 --- cxs/libcxs/include/cxs.h | 218 ------------------ cxs/libcxs/scripts/postinst | 7 - cxs/wrappers/node/package.json | 57 ----- cxs/wrappers/node/src/rustlib.ts | 151 ------------ cxs/wrappers/node/test/CXSMockTest.js | 22 -- cxs/wrappers/node/test/helpers.js | 37 --- {cxs => vcx}/README.md | 18 +- {cxs => vcx}/ci/Dockerfile-wrapper-testing | 6 +- {cxs => vcx}/ci/Jenkinsfile | 58 ++--- {cxs => vcx}/ci/change_toml_version.py | 0 {cxs => vcx}/ci/scripts/buildnum.py | 0 {cxs => vcx}/ci/scripts/cargo-update-so | 4 +- {cxs => vcx}/ci/scripts/cargo-update-version | 8 +- {cxs => vcx}/ci/scripts/create_npm_deb.py | 8 +- {cxs => vcx}/ci/scripts/getCert.sh | 0 {cxs => vcx}/ci/scripts/gzip_so_file.py | 0 vcx/ci/scripts/readme.txt | 31 +++ {cxs => vcx}/ci/scripts/test-process.py | 8 +- {cxs => vcx}/ci/scripts/test_update_so.py | 8 +- {cxs => vcx}/ci/scripts/toml_utils.py | 2 +- {cxs => vcx}/ci/scripts/version_utils.py | 0 {cxs => vcx}/ci/test.dockerfile | 6 +- {cxs => vcx}/ci/ubuntu.dockerfile | 6 +- {cxs/libcxs => vcx/libvcx}/Cargo.toml | 10 +- {cxs/libcxs => vcx/libvcx}/build.rs | 0 vcx/libvcx/include/vcx.h | 218 ++++++++++++++++++ .../libvcx}/sample_config/config.json | 0 vcx/libvcx/scripts/postinst | 7 + {cxs/libcxs => vcx/libvcx}/scripts/postrm | 2 +- .../libvcx}/scripts/provision_agent_keys.py | 6 +- .../libvcx}/src/api/claim_def.rs | 38 +-- .../libvcx}/src/api/connection.rs | 80 +++---- .../libvcx}/src/api/issuer_claim.rs | 82 +++---- {cxs/libcxs => vcx/libvcx}/src/api/mod.rs | 32 +-- {cxs/libcxs => vcx/libvcx}/src/api/proof.rs | 58 ++--- {cxs/libcxs => vcx/libvcx}/src/api/schema.rs | 56 ++--- {cxs/libcxs => vcx/libvcx}/src/api/utils.rs | 8 +- .../api/cxs.rs => vcx/libvcx/src/api/vcx.rs | 28 +-- {cxs/libcxs => vcx/libvcx}/src/claim_def.rs | 0 .../libvcx}/src/claim_request.rs | 0 {cxs/libcxs => vcx/libvcx}/src/connection.rs | 36 +-- .../libcxs => vcx/libvcx}/src/issuer_claim.rs | 40 ++-- {cxs/libcxs => vcx/libvcx}/src/lib.rs | 2 +- .../libvcx}/src/messages/create_key.rs | 0 .../libvcx}/src/messages/get_message.rs | 0 .../libvcx}/src/messages/invite.rs | 0 .../libcxs => vcx/libvcx}/src/messages/mod.rs | 0 .../libvcx}/src/messages/proofs/mod.rs | 0 .../src/messages/proofs/proof_message.rs | 0 .../src/messages/proofs/proof_request.rs | 0 .../libvcx}/src/messages/register.rs | 0 .../libvcx}/src/messages/send_message.rs | 0 .../libvcx}/src/messages/update_profile.rs | 0 .../libvcx}/src/messages/validation.rs | 0 {cxs/libcxs => vcx/libvcx}/src/proof.rs | 38 +-- .../libvcx}/src/proof_compliance.rs | 4 +- {cxs/libcxs => vcx/libvcx}/src/schema.rs | 0 {cxs/libcxs => vcx/libvcx}/src/settings.rs | 2 +- .../libvcx}/src/utils/callback.rs | 0 .../libvcx}/src/utils/ccallback.rs | 0 .../libvcx}/src/utils/constants.rs | 0 .../libvcx}/src/utils/cstring.rs | 0 {cxs/libcxs => vcx/libvcx}/src/utils/error.rs | 0 .../libvcx}/src/utils/httpclient.rs | 0 {cxs/libcxs => vcx/libvcx}/src/utils/json.rs | 0 .../libvcx}/src/utils/libindy/anoncreds.rs | 0 .../libvcx}/src/utils/libindy/call.rs | 0 .../libvcx}/src/utils/libindy/callback.rs | 0 .../libvcx}/src/utils/libindy/crypto.rs | 0 .../libvcx}/src/utils/libindy/error_codes.rs | 0 .../libvcx}/src/utils/libindy/ledger.rs | 0 .../libvcx}/src/utils/libindy/mod.rs | 0 .../libvcx}/src/utils/libindy/pool.rs | 0 .../libvcx}/src/utils/libindy/return_types.rs | 4 +- .../libvcx}/src/utils/libindy/signus.rs | 0 .../libvcx}/src/utils/libindy/wallet.rs | 0 .../libcxs => vcx/libvcx}/src/utils/logger.rs | 0 {cxs/libcxs => vcx/libvcx}/src/utils/mod.rs | 0 .../libvcx}/src/utils/openssl.rs | 0 .../libvcx}/src/utils/timeout.rs | 0 .../libvcx}/src/utils/version_constants.rs | 0 .../libvcx}/tests/claim_def_dep.rs | 28 +-- {cxs/libcxs => vcx/libvcx}/tests/demo.rs | 46 ++-- .../libvcx}/tests/demo_with_composite.rs | 74 +++--- .../libcxs.rs => vcx/libvcx/tests/libvcx.rs | 2 +- .../libvcx}/tests/utils/claim_def_wallet.rs | 0 .../libvcx}/tests/utils/cstring.rs | 0 .../libcxs => vcx/libvcx}/tests/utils/demo.rs | 34 +-- {cxs/libcxs => vcx/libvcx}/tests/utils/mod.rs | 0 .../libvcx}/tests/utils/timeout.rs | 0 {cxs => vcx}/wrappers/node/.gitignore | 0 {cxs => vcx}/wrappers/node/.npmignore | 0 {cxs => vcx}/wrappers/node/README.md | 6 +- {cxs => vcx}/wrappers/node/package-lock.json | 4 +- vcx/wrappers/node/package.json | 57 +++++ .../wrappers/node/src/api/VCXBase.ts | 8 +- .../wrappers/node/src/api/VCXBaseWithState.ts | 4 +- .../wrappers/node/src/api/VCXMock.ts | 6 +- .../wrappers/node/src/api/claimDef.ts | 20 +- {cxs => vcx}/wrappers/node/src/api/common.ts | 0 .../wrappers/node/src/api/connection.ts | 36 +-- {cxs => vcx}/wrappers/node/src/api/errors.ts | 2 +- {cxs => vcx}/wrappers/node/src/api/init.ts | 14 +- .../wrappers/node/src/api/issuerClaim.ts | 48 ++-- {cxs => vcx}/wrappers/node/src/api/proof.ts | 36 +-- {cxs => vcx}/wrappers/node/src/api/schema.ts | 28 +-- {cxs => vcx}/wrappers/node/src/errors.ts | 2 +- {cxs => vcx}/wrappers/node/src/index.ts | 4 +- vcx/wrappers/node/src/rustlib.ts | 151 ++++++++++++ .../wrappers/node/src/utils/ffi-helpers.ts | 0 .../src/utils/memory-management-helpers.ts | 0 .../cxs.ts => vcx/wrappers/node/src/vcx.ts | 14 +- vcx/wrappers/node/test/VCXMockTest.js | 22 ++ .../wrappers/node/test/claimDefTest.js | 12 +- .../wrappers/node/test/connectionTest.js | 24 +- .../wrappers/node/test/ffiTest.separate.js | 40 ++-- vcx/wrappers/node/test/helpers.js | 37 +++ .../wrappers/node/test/issueClaimFfiTest.js | 6 +- .../wrappers/node/test/issuerClaimTest.js | 22 +- {cxs => vcx}/wrappers/node/test/proofTest.js | 16 +- {cxs => vcx}/wrappers/node/test/schemaTest.js | 12 +- {cxs => vcx}/wrappers/node/tsconfig.json | 0 {cxs => vcx}/wrappers/node/tslint.json | 0 {cxs => vcx}/wrappers/python3/.gitignore | 0 {cxs => vcx}/wrappers/python3/MANIFEST.in | 0 {cxs => vcx}/wrappers/python3/README.md | 0 {cxs => vcx}/wrappers/python3/cxs/__init__.py | 0 .../wrappers/python3/requirements.txt | 0 {cxs => vcx}/wrappers/python3/setup.py | 0 .../wrappers/python3/tests/test_cxs_init.py | 0 131 files changed, 1126 insertions(+), 1126 deletions(-) delete mode 100644 cxs/ci/scripts/readme.txt delete mode 100644 cxs/libcxs/include/cxs.h delete mode 100755 cxs/libcxs/scripts/postinst delete mode 100644 cxs/wrappers/node/package.json delete mode 100644 cxs/wrappers/node/src/rustlib.ts delete mode 100644 cxs/wrappers/node/test/CXSMockTest.js delete mode 100644 cxs/wrappers/node/test/helpers.js rename {cxs => vcx}/README.md (74%) rename {cxs => vcx}/ci/Dockerfile-wrapper-testing (90%) rename {cxs => vcx}/ci/Jenkinsfile (70%) rename {cxs => vcx}/ci/change_toml_version.py (100%) rename {cxs => vcx}/ci/scripts/buildnum.py (100%) rename {cxs => vcx}/ci/scripts/cargo-update-so (91%) rename {cxs => vcx}/ci/scripts/cargo-update-version (91%) rename {cxs => vcx}/ci/scripts/create_npm_deb.py (87%) rename {cxs => vcx}/ci/scripts/getCert.sh (100%) rename {cxs => vcx}/ci/scripts/gzip_so_file.py (100%) create mode 100644 vcx/ci/scripts/readme.txt rename {cxs => vcx}/ci/scripts/test-process.py (81%) rename {cxs => vcx}/ci/scripts/test_update_so.py (76%) rename {cxs => vcx}/ci/scripts/toml_utils.py (99%) rename {cxs => vcx}/ci/scripts/version_utils.py (100%) rename {cxs => vcx}/ci/test.dockerfile (93%) rename {cxs => vcx}/ci/ubuntu.dockerfile (94%) rename {cxs/libcxs => vcx/libvcx}/Cargo.toml (84%) rename {cxs/libcxs => vcx/libvcx}/build.rs (100%) create mode 100644 vcx/libvcx/include/vcx.h rename {cxs/libcxs => vcx/libvcx}/sample_config/config.json (100%) create mode 100755 vcx/libvcx/scripts/postinst rename {cxs/libcxs => vcx/libvcx}/scripts/postrm (50%) rename {cxs/libcxs => vcx/libvcx}/scripts/provision_agent_keys.py (96%) rename {cxs/libcxs => vcx/libvcx}/src/api/claim_def.rs (92%) rename {cxs/libcxs => vcx/libvcx}/src/api/connection.rs (87%) rename {cxs/libcxs => vcx/libvcx}/src/api/issuer_claim.rs (88%) rename {cxs/libcxs => vcx/libvcx}/src/api/mod.rs (84%) rename {cxs/libcxs => vcx/libvcx}/src/api/proof.rs (94%) rename {cxs/libcxs => vcx/libvcx}/src/api/schema.rs (92%) rename {cxs/libcxs => vcx/libvcx}/src/api/utils.rs (93%) rename cxs/libcxs/src/api/cxs.rs => vcx/libvcx/src/api/vcx.rs (91%) rename {cxs/libcxs => vcx/libvcx}/src/claim_def.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/claim_request.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/connection.rs (96%) rename {cxs/libcxs => vcx/libvcx}/src/issuer_claim.rs (96%) rename {cxs/libcxs => vcx/libvcx}/src/lib.rs (96%) rename {cxs/libcxs => vcx/libvcx}/src/messages/create_key.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/get_message.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/invite.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/mod.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/proofs/mod.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/proofs/proof_message.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/proofs/proof_request.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/register.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/send_message.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/update_profile.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/messages/validation.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/proof.rs (97%) rename {cxs/libcxs => vcx/libvcx}/src/proof_compliance.rs (99%) rename {cxs/libcxs => vcx/libvcx}/src/schema.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/settings.rs (99%) rename {cxs/libcxs => vcx/libvcx}/src/utils/callback.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/ccallback.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/constants.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/cstring.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/error.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/httpclient.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/json.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/anoncreds.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/call.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/callback.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/crypto.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/error_codes.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/ledger.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/mod.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/pool.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/return_types.rs (99%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/signus.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/libindy/wallet.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/logger.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/mod.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/openssl.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/timeout.rs (100%) rename {cxs/libcxs => vcx/libvcx}/src/utils/version_constants.rs (100%) rename {cxs/libcxs => vcx/libvcx}/tests/claim_def_dep.rs (98%) rename {cxs/libcxs => vcx/libvcx}/tests/demo.rs (88%) rename {cxs/libcxs => vcx/libvcx}/tests/demo_with_composite.rs (89%) rename cxs/libcxs/tests/libcxs.rs => vcx/libvcx/tests/libvcx.rs (78%) rename {cxs/libcxs => vcx/libvcx}/tests/utils/claim_def_wallet.rs (100%) rename {cxs/libcxs => vcx/libvcx}/tests/utils/cstring.rs (100%) rename {cxs/libcxs => vcx/libvcx}/tests/utils/demo.rs (95%) rename {cxs/libcxs => vcx/libvcx}/tests/utils/mod.rs (100%) rename {cxs/libcxs => vcx/libvcx}/tests/utils/timeout.rs (100%) rename {cxs => vcx}/wrappers/node/.gitignore (100%) rename {cxs => vcx}/wrappers/node/.npmignore (100%) rename {cxs => vcx}/wrappers/node/README.md (70%) rename {cxs => vcx}/wrappers/node/package-lock.json (99%) create mode 100644 vcx/wrappers/node/package.json rename cxs/wrappers/node/src/api/CXSBase.ts => vcx/wrappers/node/src/api/VCXBase.ts (92%) rename cxs/wrappers/node/src/api/CXSBaseWithState.ts => vcx/wrappers/node/src/api/VCXBaseWithState.ts (93%) rename cxs/wrappers/node/src/api/CXSMock.ts => vcx/wrappers/node/src/api/VCXMock.ts (73%) rename {cxs => vcx}/wrappers/node/src/api/claimDef.ts (84%) rename {cxs => vcx}/wrappers/node/src/api/common.ts (100%) rename {cxs => vcx}/wrappers/node/src/api/connection.ts (84%) rename {cxs => vcx}/wrappers/node/src/api/errors.ts (66%) rename {cxs => vcx}/wrappers/node/src/api/init.ts (62%) rename {cxs => vcx}/wrappers/node/src/api/issuerClaim.ts (82%) rename {cxs => vcx}/wrappers/node/src/api/proof.ts (85%) rename {cxs => vcx}/wrappers/node/src/api/schema.ts (87%) rename {cxs => vcx}/wrappers/node/src/errors.ts (66%) rename {cxs => vcx}/wrappers/node/src/index.ts (82%) create mode 100644 vcx/wrappers/node/src/rustlib.ts rename {cxs => vcx}/wrappers/node/src/utils/ffi-helpers.ts (100%) rename {cxs => vcx}/wrappers/node/src/utils/memory-management-helpers.ts (100%) rename cxs/wrappers/node/src/cxs.ts => vcx/wrappers/node/src/vcx.ts (63%) create mode 100644 vcx/wrappers/node/test/VCXMockTest.js rename {cxs => vcx}/wrappers/node/test/claimDefTest.js (86%) rename {cxs => vcx}/wrappers/node/test/connectionTest.js (92%) rename {cxs => vcx}/wrappers/node/test/ffiTest.separate.js (73%) create mode 100644 vcx/wrappers/node/test/helpers.js rename {cxs => vcx}/wrappers/node/test/issueClaimFfiTest.js (80%) rename {cxs => vcx}/wrappers/node/test/issuerClaimTest.js (92%) rename {cxs => vcx}/wrappers/node/test/proofTest.js (93%) rename {cxs => vcx}/wrappers/node/test/schemaTest.js (92%) rename {cxs => vcx}/wrappers/node/tsconfig.json (100%) rename {cxs => vcx}/wrappers/node/tslint.json (100%) rename {cxs => vcx}/wrappers/python3/.gitignore (100%) rename {cxs => vcx}/wrappers/python3/MANIFEST.in (100%) rename {cxs => vcx}/wrappers/python3/README.md (100%) rename {cxs => vcx}/wrappers/python3/cxs/__init__.py (100%) rename {cxs => vcx}/wrappers/python3/requirements.txt (100%) rename {cxs => vcx}/wrappers/python3/setup.py (100%) rename {cxs => vcx}/wrappers/python3/tests/test_cxs_init.py (100%) diff --git a/cxs/ci/scripts/readme.txt b/cxs/ci/scripts/readme.txt deleted file mode 100644 index 5127c8f7ea..0000000000 --- a/cxs/ci/scripts/readme.txt +++ /dev/null @@ -1,31 +0,0 @@ -How to package debians for the libcxs library and associated wrappers (as a dev): - -01) Add ./sdk/cxs/ci/scripts to your PATH variable - -02) Build Release binary of libcxs.so - '$ cargo build' - -03) Move to ./sdk/cxs/libcxs directory. - -04) Update Cargo.toml and package.json files to current version/build. - '$ cargo update-version' - -05) Update libcxs/release/libcxs.so to newest version. - '$ cargo update-so' - -06) Create debian package - '$ cargo deb --no-build' - -07) Gzip so file - '$ python ./sdk/cxs/ci/scripts/gzip_so_file.py ./sdk/cxs/libcxs/target/debug/libcxs.so. DEST_DIR' - -08) Copy target/debug/libcxs.so to ./sdk/cxs/wrapers/node/lib - -09) Change directories to './sdk/cxs/wrappers/node' - -10) Package npm module - '$ npm pack' - -11) Run ./sdk/cxs/ci/scripts/create_npm_deb.py - '$ create_npm_deb.py node-cxs-.tgz' - diff --git a/cxs/libcxs/include/cxs.h b/cxs/libcxs/include/cxs.h deleted file mode 100644 index 421b8caf23..0000000000 --- a/cxs/libcxs/include/cxs.h +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef __CXS_H -#define __CXS_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum -{ - none = 0, - initialized, - offer_sent, - request_received, - accepted, - unfulfilled, - expired, - revoked, -} cxs_state_t; - -typedef enum -{ - undefined = 0, - validated = 1, - invalid = 2, -} cxs_proof_state_t; - -typedef unsigned int cxs_error_t; -typedef unsigned int cxs_schema_handle_t; -typedef unsigned int cxs_claimdef_handle_t; -typedef unsigned int cxs_connection_handle_t; -typedef unsigned int cxs_claim_handle_t; -typedef unsigned int cxs_proof_handle_t; -typedef unsigned int cxs_command_handle_t; -typedef unsigned int cxs_bool_t; - -typedef struct { - - union { - cxs_schema_handle_t schema_handle; - cxs_claimdef_handle_t claimdef_handle; - cxs_connection_handle_t connection_handle; - cxs_claim_handle_t claim_handle; - cxs_proof_handle_t proof_handle; - } handle; - - cxs_error_t status; - char *msg; - -} cxs_status_t; - - -/** - * Initialize the SDK - */ - -cxs_error_t cxs_init(cxs_command_handle_t handle, const char *config_path,void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err)); - - -/** - * Schema object - * - * For creating, validating and committing a schema to the sovrin ledger. - */ - -/** Creates a schema from a json string. Populates a handle to the new schema. */ -cxs_error_t cxs_schema_create(cxs_command_handle_t command_handle, const char *source_id, const char *schema_name, const char *schema_data, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err, cxs_schema_handle_t schema_handle)); - -/** Populates status with the current state of this claim. */ -cxs_error_t cxs_schema_serialize(cxs_command_handle_t command_handle, cxs_schema_handle_t schema_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *state)); - -/** Re-creates a claim object from the specified serialization. */ -cxs_error_t cxs_schema_deserialize(cxs_command_handle_t command_handle, const char *serialized_schema, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_schema_handle_t schema_handle)); - -/** Populates data with the contents of the schema handle. */ -cxs_error_t cxs_schema_get_attributes(cxs_command_handle_t command_handle, const char *source_id, cxs_schema_handle_t sequence_no, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *schema_attrs)); - -/** Populates sequence_no with the actual sequence number of the schema on the sovrin ledger. */ -cxs_error_t cxs_schema_get_sequence_no(cxs_command_handle_t command_handle, cxs_schema_handle_t schema_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_schema_handle_t sequence_no)); - -/** Release memory associated with schema object. */ -cxs_error_t cxs_schema_release(cxs_schema_handle_t handle); - - -/** - * claimdef object - * - * For creating, validating and committing a claim definition to the sovrin ledger. - */ - -/** Creates a claim definition from the given schema. Populates a handle to the new claimdef. */ -cxs_error_t cxs_claimdef_create(cxs_command_handle_t command_handle, const char *source_id, const char *claimdef_name, cxs_schema_handle_t schema_seq_no, cxs_bool_t revocation, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err, cxs_claimdef_handle_t claimdef_handle)); - -/** Populates status with the current state of this claim. */ -cxs_error_t cxs_claimdef_serialize(cxs_command_handle_t command_handle, cxs_claimdef_handle_t claimdef_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *state)); - -/** Re-creates a claim object from the specified serialization. */ -cxs_error_t cxs_claimdef_deserialize(cxs_command_handle_t command_handle, const char *serialized_claimdef, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_claimdef_handle_t claimdef_handle)); - -/** Asynchronously commits the claimdef to the ledger. */ -cxs_error_t cxs_claimdef_commit(cxs_claimdef_handle_t claimdef_handle); - -/** Populates sequence_no with the actual sequence number of the claimdef on the sovrin ledger. */ -cxs_error_t cxs_claimdef_get_sequence_no(cxs_claimdef_handle_t claimdef_handle, int *sequence_no); - -/** Populates data with the contents of the claimdef handle. */ -cxs_error_t cxs_claimdef_get(cxs_claimdef_handle_t claimdef_handle, char *data); - - -/** - * connection object - * - * For creating a connection with an identity owner for interactions such as exchanging - * claims and proofs. - */ - -/** Creates a connection object to a specific identity owner. Populates a handle to the new connection. */ -cxs_error_t cxs_connection_create(cxs_command_handle_t command_handle, const char *recipient_info, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err, cxs_connection_handle_t connection_handle)); - -/** Asynchronously request a connection be made. */ -cxs_error_t cxs_connection_connect(cxs_command_handle_t command_handle, cxs_connection_handle_t connection_handle, const char *connection_type, void (*cb)(cxs_command_handle_t, cxs_error_t err)); - -/** Returns the contents of the connection handle or null if the connection does not exist. */ -cxs_error_t cxs_connection_serialize(cxs_command_handle_t command_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *state)); - -/** Re-creates a connection object from the specified serialization. */ -cxs_error_t cxs_connection_deserialize(cxs_command_handle_t command_handle, const char *serialized_claim, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_connection_handle_t connection_handle)); - -/** Request a state update from the agent for the given connection. */ -cxs_error_t cxs_connection_update_state(cxs_command_handle_t command_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Retrieves the state of the connection */ -cxs_error_t cxs_connection_get_state(cxs_command_handle_t command_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Releases the connection from memory. */ -cxs_error_t cxs_connection_release(cxs_connection_handle_t connection_handle); - -/** Get the invite details for the connection. */ -cxs_error_t cxs_connection_invite_details(cxs_command_handle_t command_handle, cxs_connection_handle_t connection_handle, int abbreviated, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *details)); - - -/** - * claim issuer object - * - * Used for offering and managing a claim with an identity owner. - */ - -/** Creates a claim object from the specified claimdef handle. Populates a handle the new claim. */ -cxs_error_t cxs_issuer_create_claim(cxs_command_handle_t command_handle, const char *source_id, cxs_schema_handle_t schema_seq_no, const char *issuer_did, const char * claim_data, const char * claim_name, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err, cxs_claim_handle_t claim_handle)); - -/** Asynchronously sends the claim offer to the connection. */ -cxs_error_t cxs_issuer_send_claim_offer(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err)); - -/** Updates the state of the claim from the agency. */ -cxs_error_t cxs_issuer_claim_update_state(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Retrieves the state of the issuer_claim. */ -cxs_error_t cxs_issuer_claim_get_state(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Asynchronously send the claim to the connection. Populates a handle to the new transaction. */ -cxs_error_t cxs_issuer_send_claim(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err)); - -/** Populates status with the current state of this claim. */ -cxs_error_t cxs_issuer_claim_serialize(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *state)); - -/** Re-creates a claim object from the specified serialization. */ -cxs_error_t cxs_issuer_claim_deserialize(cxs_command_handle_t, const char *serialized_claim, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_claim_handle_t claim_handle)); - -/** Terminates a claim for the specified reason. */ -cxs_error_t cxs_issuer_terminate_claim(cxs_command_handle_t command_handle, cxs_claim_handle_t claim_handle, cxs_state_t state_type, const char *msg); - -/** Releases the claim from memory. */ -cxs_error_t cxs_issuer_claim_release(cxs_claim_handle_t claim_handle); - -/** Populates claim_request with the latest claim request received. (not in MVP) */ -cxs_error_t cxs_issuer_get_claim_request(cxs_claim_handle_t claim_handle, char *claim_request); - -/** Sets the claim request in an accepted state. (not in MVP) */ -cxs_error_t cxs_issuer_accept_claim(cxs_claim_handle_t claim_handle); - -/** - * proof object - * - * Used for requesting and managing a proof request with an identity owner. - */ - -/** Creates a proof object. Populates a handle to the new proof. */ -cxs_error_t cxs_proof_create(cxs_command_handle_t command_handle, const char *source_id, const char *requested_attrs, const char *requested_predicates, const char *name, void (*cb)(cxs_command_handle_t command_handle, cxs_error_t err, cxs_proof_handle_t proof_handle)); - -/** Asynchronously send a proof request to the connection. */ -cxs_error_t cxs_proof_send_request(cxs_command_handle_t command_handle, cxs_proof_handle_t proof_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err)); - -/** Populate response_data with the latest proof offer received. */ -cxs_error_t cxs_get_proof(cxs_command_handle_t command_handle, cxs_proof_handle_t proof_handle, cxs_connection_handle_t connection_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_proof_state_t state, const char *proof_string)); - -/** Set proof offer as accepted. */ -cxs_error_t cxs_proof_accepted(cxs_proof_handle_t proof_handle); - -/** Populates status with the current state of this proof request. */ -cxs_error_t cxs_proof_update_state(cxs_command_handle_t command_handle, cxs_proof_handle_t proof_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Retrieves the state of the proof. */ -cxs_error_t cxs_proof_get_state(cxs_command_handle_t command_handle, cxs_proof_handle_t proof_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_state_t state)); - -/** Populates status with the current state of this claim. */ -cxs_error_t cxs_proof_serialize(cxs_command_handle_t command_handle, cxs_proof_handle_t proof_handle, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, const char *state)); - -/** Re-creates a claim object from the specified serialization. */ -cxs_error_t cxs_proof_deserialize(cxs_command_handle_t command_handle, const char *serialized_proof, void (*cb)(cxs_command_handle_t xcommand_handle, cxs_error_t err, cxs_proof_handle_t proof_handle)); - -/** Releases the proof from memory. */ -cxs_error_t cxs_proof_release(cxs_proof_handle_t proof_handle); - -void cxs_set_next_agency_response(int); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cxs/libcxs/scripts/postinst b/cxs/libcxs/scripts/postinst deleted file mode 100755 index 010753a3bc..0000000000 --- a/cxs/libcxs/scripts/postinst +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# postinst script for libcxs - -/sbin/ldconfig - -ln -s `ls -rt /usr/lib/libcxs.* | tail -n1` /usr/lib/libcxs.so - diff --git a/cxs/wrappers/node/package.json b/cxs/wrappers/node/package.json deleted file mode 100644 index 7db5b1c142..0000000000 --- a/cxs/wrappers/node/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "description": "Node wrapper for cxs", - "license": "ISC", - "typings": "dist/index.d.ts", - "directories": { - "test": "test", - "build": "dist", - "lib": "src" - }, - "author": "evernym", - "bugs": { - "url": "https://github.com/evernym/cxs/issues" - }, - "standard": { - "env": [ - "mocha" - ] - }, - "repository": { - "url": "git+https://github.com/evernym/cxs.git", - "type": "git" - }, - "version": "0.1.543416+469b25d", - "dependencies": { - "@types/node": "^8.0.47", - "weak": "^1.0.1", - "fs-extra": "^4.0.2", - "@types/ref-struct": "0.0.28", - "@types/ffi": "0.0.19", - "change-case": "^3.0.1", - "ffi": "^2.2.0", - "lodash": "^4.17.4", - "path": "^0.12.7", - "ref-struct": "^1.1.0", - "@types/ref": "0.0.28", - "ref": "^1.3.5" - }, - "scripts": { - "compile": "./node_modules/.bin/tsc -p ./tsconfig.json", - "test": "mocha -gc --expose-gc test/**/*Test.js && mocha -gc --expose-gc test/**/*Test.separate.js", - "lint": "./node_modules/.bin/tslint --type-check -c ./tslint.json -p ./tsconfig.json && ./node_modules/.bin/standard 'test/**/*.js'", - "doc-gen": "./node_modules/.bin/jsdoc -r -d doc dist/*" - }, - "devDependencies": { - "tslint": "^5.8.0", - "typescript": "^2.5.3", - "tslint-config-standard": "^6.0.1", - "chai": "^4.1.2", - "standard": "^10.0.3", - "sinon": "^4.1.2", - "jsdoc": "^3.5.5", - "mocha": "^3.5.3" - }, - "main": "dist/index.js", - "homepage": "https://github.com/evernym/cxs#readme", - "name": "cxs" -} diff --git a/cxs/wrappers/node/src/rustlib.ts b/cxs/wrappers/node/src/rustlib.ts deleted file mode 100644 index aa78687bd8..0000000000 --- a/cxs/wrappers/node/src/rustlib.ts +++ /dev/null @@ -1,151 +0,0 @@ -import * as ref from 'ref' -import * as StructType from 'ref-struct' - -import { CXSRuntime } from './cxs' - -export const CxsStatus = StructType({ - handle: 'int', - msg: 'string', - status: 'int' -}) - -// FFI Type Strings -export const FFI_ERROR_CODE = 'int' -export const FFI_BOOL = 'bool' -export const FFI_CONNECTION_HANDLE = 'uint32' -export const FFI_UNSIGNED_INT = 'uint32' -export const FFI_UNSIGNED_INT_PTR = ref.refType('uint32') -export const FFI_STRING = 'string' -export const FFI_CONFIG_PATH = FFI_STRING -export const FFI_STRING_DATA = 'string' -export const FFI_SOURCE_ID = 'string' -export const FFI_CONNECTION_DATA = 'string' -export const FFI_VOID = ref.types.void -export const FFI_CONNECTION_HANDLE_PTR = ref.refType(FFI_CONNECTION_HANDLE) -export const FFI_CALLBACK_PTR = 'pointer' -export const FFI_COMMAND_HANDLE = 'uint32' -export const FFI_CLAIM_HANDLE = 'uint32' -export const FFI_PROOF_HANDLE = 'uint32' -export const FFI_CLAIMDEF_HANDLE = 'uint32' -export const FFI_SCHEMA_HANDLE = 'uint32' -export const FFI_SCHEMA_NUMBER = 'uint32' - -// Rust Lib Native Types -export type rust_did = string -export type rust_error_code = number -export type rust_command_handle = number -export type rust_object_handle = number -export type rust_pool_handle = rust_object_handle -export type rust_wallet_handle = rust_object_handle -export type rust_listener_handle = rust_object_handle -export type rust_connection_handle = rust_object_handle - -export interface IFFIEntryPoint { - cxs_init: (commandId: number, configPath: string, cb: any) => number, - // connection - cxs_connection_connect: (commandId: number, handle: string, data: string, cb: any) => number, - cxs_connection_create: (commandId: number, data: string, cb: any) => number, - cxs_connection_deserialize: (commandId: number, data: string, cb: any) => number, - cxs_connection_release: (handle: string) => number, - cxs_connection_serialize: (commandId: number, handle: string, cb: any) => number, - cxs_connection_update_state: (commandId: number, handle: string, cb: any) => number, - cxs_connection_get_state: (commandId: number, handle: string, cb: any) => number, - cxs_connection_invite_details: (commandId: number, handle: string, abbreviated: boolean, cb: any) => number, - // issuer - cxs_issuer_claim_deserialize: (commandId: number, data: string, cb: any) => number, - cxs_issuer_claim_serialize: (commandId: number, handle: string, cb: any) => number, - cxs_issuer_claim_update_state: (commandId: number, handle: string, cb: any) => number, - cxs_issuer_claim_get_state: (commandId: number, handle: string, cb: any) => number, - cxs_issuer_create_claim: any, - cxs_issuer_send_claim: (commandId: number, claimHandle: string, connectionHandle: string, cb: any) => number, - cxs_issuer_send_claim_offer: (commandId: number, claimHandle: string, connectionHandle: string, cb: any) => number, - // proof - cxs_proof_create: (commandId: number, sourceId: string, attrs: string, predicates: string, - name: string, cb: any) => number, - cxs_proof_deserialize: (commandId: number, data: string, cb: any) => number, - cxs_get_proof: (commandId: number, proofHandle: string, connectionHandle: string, cb: any) => number, - cxs_proof_release: (handle: string) => number, - cxs_proof_send_request: (commandId: number, proofHandle: string, connectionHandle: string, cb: any) => number, - cxs_proof_serialize: (commandId: number, handle: string, cb: any) => number, - cxs_proof_update_state: (commandId: number, handle: string, cb: any) => number, - cxs_proof_get_state: (commandId: number, handle: string, cb: any) => number, - // mock - cxs_set_next_agency_response: (messageIndex: number) => void, - - // claimdef - cxs_claimdef_create: (commandId: number, sourceId: string, claimDefName: string, schemaNo: number, - issuerDid: string, revocation: boolean, cb: any) => number - cxs_claimdef_deserialize: (commandId: number, data: string, cb: any) => number, - cxs_claimdef_serialize: (commandId: number, handle: string, cb: any) => number, - cxs_claimdef_release: (handle: string) => number, - - // schema - cxs_schema_get_attributes: (commandId: number, sourceId: string, schemaNo: number, cb: any) => number, - cxs_schema_create: (commandId: number, sourceId: string, schemaName: string, schemaData: string, - cb: any) => number, - cxs_schema_get_sequence_no: (commandId: number, handle: string, cb: any) => number, - cxs_schema_deserialize: (commandId: number, data: string, cb: any) => number, - cxs_schema_serialize: (commandId: number, handle: string, cb: any) => number, - cxs_schema_release: (handle: string) => number, - -} - -// tslint:disable object-literal-sort-keys -export const FFIConfiguration: { [ Key in keyof IFFIEntryPoint ]: any } = { - - cxs_init: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONFIG_PATH, FFI_CALLBACK_PTR]], - // connection - cxs_connection_connect: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CONNECTION_DATA, - FFI_CALLBACK_PTR]], - cxs_connection_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_connection_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_connection_release: [FFI_ERROR_CODE, [FFI_CONNECTION_HANDLE]], - cxs_connection_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], - cxs_connection_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], - cxs_connection_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], - cxs_connection_invite_details: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_BOOL, - FFI_CALLBACK_PTR]], - // issuer - cxs_issuer_claim_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_issuer_claim_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], - cxs_issuer_claim_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], - cxs_issuer_claim_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], - cxs_issuer_create_claim: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, - 'int', 'string', 'string', 'string', 'pointer']], - cxs_issuer_send_claim: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CONNECTION_HANDLE, - FFI_CALLBACK_PTR]], - cxs_issuer_send_claim_offer: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CONNECTION_HANDLE, - FFI_CALLBACK_PTR]], - // proof - cxs_proof_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_STRING_DATA, - FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_proof_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_get_proof: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CONNECTION_HANDLE, - FFI_CALLBACK_PTR]],// tslint:disable-line - cxs_proof_release: [FFI_ERROR_CODE, [FFI_PROOF_HANDLE]], - cxs_proof_send_request: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CONNECTION_HANDLE, - FFI_CALLBACK_PTR]], - cxs_proof_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], - cxs_proof_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], - cxs_proof_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], - // claimDef - cxs_claimdef_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_SCHEMA_NUMBER, - FFI_STRING_DATA, FFI_BOOL, FFI_CALLBACK_PTR]], - cxs_claimdef_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_claimdef_release: [FFI_ERROR_CODE, [FFI_CLAIMDEF_HANDLE]], - cxs_claimdef_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIMDEF_HANDLE, FFI_CALLBACK_PTR]], - // mock - cxs_set_next_agency_response: [FFI_VOID, [FFI_UNSIGNED_INT]], - // schema - cxs_schema_get_attributes: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_SCHEMA_NUMBER, FFI_CALLBACK_PTR]], - cxs_schema_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_STRING_DATA, - FFI_CALLBACK_PTR]], - cxs_schema_get_sequence_no: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SCHEMA_HANDLE, FFI_CALLBACK_PTR]], - cxs_schema_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], - cxs_schema_release: [FFI_ERROR_CODE, [FFI_SCHEMA_HANDLE]], - cxs_schema_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SCHEMA_HANDLE, FFI_CALLBACK_PTR]] -} - -let _rustAPI: IFFIEntryPoint = null -export const initRustAPI = (path?: string) => _rustAPI = new CXSRuntime({ basepath: path }).ffi -export const rustAPI = () => _rustAPI diff --git a/cxs/wrappers/node/test/CXSMockTest.js b/cxs/wrappers/node/test/CXSMockTest.js deleted file mode 100644 index 41ad584b33..0000000000 --- a/cxs/wrappers/node/test/CXSMockTest.js +++ /dev/null @@ -1,22 +0,0 @@ -const assert = require('chai').assert -const cxs = require('../dist/index') -const { stubInitCXS } = require('./helpers') -const { Connection, CXSMock } = cxs - -describe('A CXSMock', function () { - this.timeout(30000) - - before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') - }) - - it('can be called.', async () => { - CXSMock.setCxsMock(1) - try { - await Connection.create({ id: '234', DIDself: '456', DIDremote: '0' }) - } catch (err) { - assert.equal(err.toString(), 'Error: cxs_connection_create -> 1010') - } - }) -}) diff --git a/cxs/wrappers/node/test/helpers.js b/cxs/wrappers/node/test/helpers.js deleted file mode 100644 index dec10fbf7a..0000000000 --- a/cxs/wrappers/node/test/helpers.js +++ /dev/null @@ -1,37 +0,0 @@ -const { stub } = require('sinon') - -const cxs = require('../dist') - -let _initCXSCalled = false -let _spyInitCXS -const _stubInitCXS = () => { - const initCXSOriginal = cxs.initCxs - const stubInitCXS = stub(cxs, 'initCxs') - stubInitCXS.callsFake(async function (...args) { - if (_initCXSCalled) { - console.log('calling a stub -> already called') - return - } - console.log('calling a stub -> calling original') - await initCXSOriginal(...args) - _initCXSCalled = true - }) - return stubInitCXS -} -const stubInitCXS = () => { - if (!_spyInitCXS) { - _spyInitCXS = _stubInitCXS() - } - return _spyInitCXS -} - -const shouldThrow = (fn) => new Promise(async (resolve, reject) => { - try { - await fn() - reject(new Error(`${fn.toSting()} should have thrown!`)) - } catch (e) { - resolve(e) - } -}) - -module.exports = { stubInitCXS, shouldThrow } diff --git a/cxs/README.md b/vcx/README.md similarity index 74% rename from cxs/README.md rename to vcx/README.md index 24d7ca413b..88d7cc3b99 100644 --- a/cxs/README.md +++ b/vcx/README.md @@ -1,4 +1,4 @@ -# CXS +# VCX 1) Install rust and rustup (https://www.rust-lang.org/install.html). 2) Install libindy (https://repo.evernym.com/libindy/). @@ -14,15 +14,15 @@ # Debians and Artifacts -**`libcxs__amd.deb`** -- a debian that will install the .so library into /usr/lib, update `ldconfig`, and install provision script to `/usr/share/libcxs/`. -- Published to https://repo.corp.evernym.com/deb/pool/main/libc/libcxs/ +**`libvcx__amd.deb`** +- a debian that will install the .so library into /usr/lib, update `ldconfig`, and install provision script to `/usr/share/libvcx/`. +- Published to https://repo.corp.evernym.com/deb/pool/main/libc/libvcx/ -**`cxs_.deb`** +**`vcx_.deb`** - an unintelligent debian package that puts the nodejs package contents into a global node_modules location. -**`cxs.tgz`** -- target for the `$npm install cxs.tgz` +**`vcx.tgz`** +- target for the `$npm install vcx.tgz` -**`libcxs.tar.gz`** -- simple archive of libcxs.so and provision python script. +**`libvcx.tar.gz`** +- simple archive of libvcx.so and provision python script. diff --git a/cxs/ci/Dockerfile-wrapper-testing b/vcx/ci/Dockerfile-wrapper-testing similarity index 90% rename from cxs/ci/Dockerfile-wrapper-testing rename to vcx/ci/Dockerfile-wrapper-testing index 68db7f1789..1be9d51cef 100644 --- a/cxs/ci/Dockerfile-wrapper-testing +++ b/vcx/ci/Dockerfile-wrapper-testing @@ -46,9 +46,9 @@ RUN curl -fsOSL $LIBINDY_DOWNLOAD_URL \ && dpkg -i $LIBINDY_DEB \ && apt-get -f install -COPY libcxs/target/debug/libcxs.so /usr/lib/libcxs.so +COPY libvcx/target/debug/libvcx.so /usr/lib/libvcx.so -RUN useradd -ms /bin/bash -u $uid cxs -USER cxs +RUN useradd -ms /bin/bash -u $uid vcx +USER vcx diff --git a/cxs/ci/Jenkinsfile b/vcx/ci/Jenkinsfile similarity index 70% rename from cxs/ci/Jenkinsfile rename to vcx/ci/Jenkinsfile index 2b72c26986..351418d35e 100644 --- a/cxs/ci/Jenkinsfile +++ b/vcx/ci/Jenkinsfile @@ -6,13 +6,13 @@ def getUserUid() { return sh(returnStdout: true, script: 'id -u').trim() } -// docker build -t libcxs-test --build-arg uid=1001 -f cxs/ci/ubuntu.dockerfile cxs/ci -def build(name, file='cxs/ci/ubuntu.dockerfile', context='cxs/ci', customParams = '') { +// docker build -t libvcx-test --build-arg uid=1001 -f vcx/ci/ubuntu.dockerfile vcx/ci +def build(name, file='vcx/ci/ubuntu.dockerfile', context='vcx/ci', customParams = '') { return docker.build("$name-test", "--build-arg uid=${getUserUid()} -f $file $context") } -// docker build -t wrapper-test --build-arg uid=1001 -f cxs/ci/Dockerfile-wrapper-testing -def build_wrapper_testing_image(file='cxs/ci/Dockerfile-wrapper-testing', context='cxs', customParams = ''){ +// docker build -t wrapper-test --build-arg uid=1001 -f vcx/ci/Dockerfile-wrapper-testing +def build_wrapper_testing_image(file='vcx/ci/Dockerfile-wrapper-testing', context='vcx', customParams = ''){ return docker.build("wrapper-test", "--build-arg uid=${getUserUid()} -f $file $context") } @@ -22,7 +22,7 @@ node('ubuntu') { checkout scm } - app = build('libcxs', 'cxs/ci/ubuntu.dockerfile', 'cxs/ci') + app = build('libvcx', 'vcx/ci/ubuntu.dockerfile', 'vcx/ci') // update the versions in the toml file and package.json updateVersions(app) @@ -36,7 +36,7 @@ node('ubuntu') { // update the so file to have version updateSo(app) // test the npm package and create the npm gzip artifact - wrapper = build_wrapper_testing_image('cxs/ci/Dockerfile-wrapper-testing', 'cxs') + wrapper = build_wrapper_testing_image('vcx/ci/Dockerfile-wrapper-testing', 'vcx') testNodeWrapper(wrapper) if (env.BRANCH_NAME == "master") { // create the debian of the library @@ -58,12 +58,12 @@ node('ubuntu') { def buildDocker(){ def app - def pathToCi = 'cxs/ci' + def pathToCi = 'vcx/ci' stage ('Build docker environment'){ sh "pwd" sh "ls ${pathToCi}" sh "echo building" - app = build('cxs') + app = build('vcx') } return app } @@ -74,8 +74,8 @@ def buildRust(envn){ sh "ls -l" sh "rustc --version" sh "gcc --version" - // sh "cd cxs/libcxs; cargo test -- --test-threads=1" - sh "cd cxs/libcxs; cargo build --features ci" + // sh "cd vcx/libvcx; cargo test -- --test-threads=1" + sh "cd vcx/libvcx; cargo build --features ci" } } } @@ -84,7 +84,7 @@ def testRust(envn) { stage ('Testing Rust'){ sh "echo Testing" envn.inside { - sh "cd cxs/libcxs; cargo test --color never -- --test-threads=1" + sh "cd vcx/libvcx; cargo test --color never -- --test-threads=1" } } } @@ -93,7 +93,7 @@ def testRust(envn) { // updates the path to include the scripts, // needed for cargo commands def updatePath(app) { - dir ('cxs/ci/scripts') { + dir ('vcx/ci/scripts') { app.inside { sh 'export PATH=$PATH:`pwd`' } @@ -107,8 +107,8 @@ def updateVersions(app) { app.inside { sh 'ls -l' // TODO fix this ... these *SHOULD* be cargo commands. - sh 'cd cxs/libcxs; ls -l; ls ../ci/scripts' - sh 'cd cxs/libcxs; python ../ci/scripts/cargo-update-version' + sh 'cd vcx/libvcx; ls -l; ls ../ci/scripts' + sh 'cd vcx/libvcx; python ../ci/scripts/cargo-update-version' } } @@ -117,32 +117,32 @@ def updateVersions(app) { def updateSo(app) { stage('Updating .so file version') { app.inside { - sh 'cd cxs/libcxs; python ../ci/scripts/cargo-update-so' + sh 'cd vcx/libvcx; python ../ci/scripts/cargo-update-so' } } } -// Creates the debian package for the library, as well as gzips the libcxs.so. file +// Creates the debian package for the library, as well as gzips the libvcx.so. file // Publishes both artifacts. def createDeb(envn) { - stage('Build libcxs Debian and compress .so file') { + stage('Build libvcx Debian and compress .so file') { envn.inside { - CERT_SCRIPT = 'cxs/ci/scripts/getCert.sh' - SCRIPT = 'cxs/ci/scripts/gzip_so_file.py' - FILES = 'cxs/libcxs/target/debug/libcxs.so.* cxs/libcxs/scripts/provision_agent_keys.py' - DEST = 'libcxs.tar.gz' + CERT_SCRIPT = 'vcx/ci/scripts/getCert.sh' + SCRIPT = 'vcx/ci/scripts/gzip_so_file.py' + FILES = 'vcx/libvcx/target/debug/libvcx.so.* vcx/libvcx/scripts/provision_agent_keys.py' + DEST = 'libvcx.tar.gz' // get Evernym Certificate onto machine sh "${CERT_SCRIPT}" // build debian - sh 'cd cxs/libcxs/; cargo deb --no-build' + sh 'cd vcx/libvcx/; cargo deb --no-build' if (env.BRANCH_NAME == "master") { // archive debian to Jenkins - archiveArtifacts allowEmptyARchive: true, artifacts: "cxs/libcxs/target/debian/libcxs_*_amd64.deb" + archiveArtifacts allowEmptyARchive: true, artifacts: "vcx/libvcx/target/debian/libvcx_*_amd64.deb" // archive .so file to Jenkins sh "python ${SCRIPT} ${FILES} ${DEST}" @@ -150,7 +150,7 @@ def createDeb(envn) { // upload debian to Repo withCredentials([usernameColonPassword(credentialsId: 'jenkins-kraken-svc', variable: 'KRAKEN_CREDENTIALS')]) { - sh "find cxs/libcxs/target/debian/ -type f -name 'libcxs_*_amd64.deb' -exec curl --cacert /tmp/cert/ca.crt -u \"${KRAKEN_CREDENTIALS}\" -X POST https://kraken.corp.evernym.com/repo/agency_dev/upload -F file=@{} \\;" + sh "find vcx/libvcx/target/debian/ -type f -name 'libvcx_*_amd64.deb' -exec curl --cacert /tmp/cert/ca.crt -u \"${KRAKEN_CREDENTIALS}\" -X POST https://kraken.corp.evernym.com/repo/agency_dev/upload -F file=@{} \\;" } } } @@ -160,7 +160,7 @@ def createDeb(envn) { // Creates the tgz file that can be 'npm install'-ed. def testNodeWrapper(envn) { - dir ('cxs/wrappers/node'){ + dir ('vcx/wrappers/node'){ stage ('Test Node Wrapper'){ envn.inside { sh 'npm -v' @@ -172,7 +172,7 @@ def testNodeWrapper(envn) { sh 'ls -l' sh 'npm pack' sh 'ls' - sh "test -f cxs-*.tgz" + sh "test -f vcx-*.tgz" archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.tgz' } } @@ -182,14 +182,14 @@ def testNodeWrapper(envn) { // Creates debian that can install through npm. def createNpmDeb(app){ - dir('cxs') { + dir('vcx') { stage ('Create Npm Deb') { app.inside { // TODO make this a version number from the script somehow. sh 'ls' - sh 'python ci/scripts/create_npm_deb.py wrappers/node/cxs-*.tgz' + sh 'python ci/scripts/create_npm_deb.py wrappers/node/vcx-*.tgz' sh 'ls' - archiveArtifacts allowEmptyArchive: true, artifacts: 'cxs*.deb' + archiveArtifacts allowEmptyArchive: true, artifacts: 'vcx*.deb' } } } diff --git a/cxs/ci/change_toml_version.py b/vcx/ci/change_toml_version.py similarity index 100% rename from cxs/ci/change_toml_version.py rename to vcx/ci/change_toml_version.py diff --git a/cxs/ci/scripts/buildnum.py b/vcx/ci/scripts/buildnum.py similarity index 100% rename from cxs/ci/scripts/buildnum.py rename to vcx/ci/scripts/buildnum.py diff --git a/cxs/ci/scripts/cargo-update-so b/vcx/ci/scripts/cargo-update-so similarity index 91% rename from cxs/ci/scripts/cargo-update-so rename to vcx/ci/scripts/cargo-update-so index 8b9d359ea8..b8259c9ac3 100755 --- a/cxs/ci/scripts/cargo-update-so +++ b/vcx/ci/scripts/cargo-update-so @@ -6,7 +6,7 @@ import re # this will update the so file with version and # revision number from the Cargo.toml file. -# This must be run from the ./libcxs directory +# This must be run from the ./libvcx directory TOML = 'Cargo.toml' SO_DIR = './target/debug/' @@ -18,7 +18,7 @@ def remove_old_so(d): print(os.path.isdir(d)) files = os.listdir(d) - pat = re.compile("libcxs\.so\.*\d") + pat = re.compile("libvcx\.so\.*\d") files = filter(pat.match, files) for f in files: print("removing file: %s " % f) diff --git a/cxs/ci/scripts/cargo-update-version b/vcx/ci/scripts/cargo-update-version similarity index 91% rename from cxs/ci/scripts/cargo-update-version rename to vcx/ci/scripts/cargo-update-version index 19bd1ac79f..6e4f8662ea 100755 --- a/cxs/ci/scripts/cargo-update-version +++ b/vcx/ci/scripts/cargo-update-version @@ -14,12 +14,12 @@ import json # Then it writes the new numbers to the Cargo.toml # and also to the package.json for the wrapper. -# This requires that you are in the ./libcxs +# This requires that you are in the ./libvcx # directory. TOML_FILENAME = 'Cargo.toml' -LIBCXS_DIR = 'libcxs' +LIBVCX_DIR = 'libvcx' NPM_PACKAGE_JSON = '../wrappers/node/package.json' # Verify that we are in the correct directory @@ -27,7 +27,7 @@ NPM_PACKAGE_JSON = '../wrappers/node/package.json' def verify_cwd(target_dir, toml_file): dir_path = os.getcwd() if os.path.basename(dir_path) != target_dir: - print('This command must run in the ./libcxs directory') + print('This command must run in the ./libvcx directory') sys.exit(1) for f in os.listdir(dir_path): if f == toml_file: @@ -37,7 +37,7 @@ def verify_cwd(target_dir, toml_file): def main(): - verify_cwd(LIBCXS_DIR, TOML_FILENAME) + verify_cwd(LIBVCX_DIR, TOML_FILENAME) (major, minor) = extract_version_from_file(TOML_FILENAME) build_number = buildnum.main() print('build:\t\t%s ' % build_number) diff --git a/cxs/ci/scripts/create_npm_deb.py b/vcx/ci/scripts/create_npm_deb.py similarity index 87% rename from cxs/ci/scripts/create_npm_deb.py rename to vcx/ci/scripts/create_npm_deb.py index b1bd80f0c3..d1fcdc858b 100755 --- a/cxs/ci/scripts/create_npm_deb.py +++ b/vcx/ci/scripts/create_npm_deb.py @@ -17,19 +17,19 @@ def create_deb(filename): print('%s doesnt exist' %s) sys.exit(1) - if os.path.isfile('package') or os.path.isdir('package') or os.path.isfile('cxs') or os.path.isdir('cxs'): - print('file or directory \'package\' or \'cxs\' already exists, cannot perform action.') + if os.path.isfile('package') or os.path.isdir('package') or os.path.isfile('vcx') or os.path.isdir('vcx'): + print('file or directory \'package\' or \'vcx\' already exists, cannot perform action.') sys.exit(1) with tarfile.open(filename, 'r') as f_out: f_out.extractall() (name, version) = get_info('package') - shutil.move('package', 'cxs') + shutil.move('package', 'vcx') prefix = '/usr/local/lib/node_modules' cmd = 'fpm -s dir --output-type deb --name %s --version %s --prefix %s %s' % (name, version, prefix, name) os.system(cmd) - shutil.rmtree('cxs') + shutil.rmtree('vcx') def print_usage(): diff --git a/cxs/ci/scripts/getCert.sh b/vcx/ci/scripts/getCert.sh similarity index 100% rename from cxs/ci/scripts/getCert.sh rename to vcx/ci/scripts/getCert.sh diff --git a/cxs/ci/scripts/gzip_so_file.py b/vcx/ci/scripts/gzip_so_file.py similarity index 100% rename from cxs/ci/scripts/gzip_so_file.py rename to vcx/ci/scripts/gzip_so_file.py diff --git a/vcx/ci/scripts/readme.txt b/vcx/ci/scripts/readme.txt new file mode 100644 index 0000000000..588ae48ef6 --- /dev/null +++ b/vcx/ci/scripts/readme.txt @@ -0,0 +1,31 @@ +How to package debians for the libvcx library and associated wrappers (as a dev): + +01) Add ./sdk/vcx/ci/scripts to your PATH variable + +02) Build Release binary of libvcx.so + '$ cargo build' + +03) Move to ./sdk/vcx/libvcx directory. + +04) Update Cargo.toml and package.json files to current version/build. + '$ cargo update-version' + +05) Update libvcx/release/libvcx.so to newest version. + '$ cargo update-so' + +06) Create debian package + '$ cargo deb --no-build' + +07) Gzip so file + '$ python ./sdk/vcx/ci/scripts/gzip_so_file.py ./sdk/vcx/libvcx/target/debug/libvcx.so. DEST_DIR' + +08) Copy target/debug/libvcx.so to ./sdk/vcx/wrapers/node/lib + +09) Change directories to './sdk/vcx/wrappers/node' + +10) Package npm module + '$ npm pack' + +11) Run ./sdk/vcx/ci/scripts/create_npm_deb.py + '$ create_npm_deb.py node-vcx-.tgz' + diff --git a/cxs/ci/scripts/test-process.py b/vcx/ci/scripts/test-process.py similarity index 81% rename from cxs/ci/scripts/test-process.py rename to vcx/ci/scripts/test-process.py index 405e708892..d4a22951ef 100755 --- a/cxs/ci/scripts/test-process.py +++ b/vcx/ci/scripts/test-process.py @@ -12,21 +12,21 @@ def test_debian_file(): print('executing: cargo deb') os.system('cargo deb --no-build') - debian_dir = '/sdk/cxs/libcxs/target/debian/' + debian_dir = '/sdk/vcx/libvcx/target/debian/' pattern = re.compile('lib.*\.deb') debian_file = filter(pattern.match, os.listdir(debian_dir))[0] print('copying file: %s' % debian_file) shutil.copyfile(debian_dir + debian_file, '/data/' + debian_file) def test_gzip_so_file(): - version = toml_utils.get_version_from_file('/sdk/cxs/libcxs/Cargo.toml') - src = '/sdk/cxs/libcxs/target/release/libcxs.so.%s' % version + version = toml_utils.get_version_from_file('/sdk/vcx/libvcx/Cargo.toml') + src = '/sdk/vcx/libvcx/target/release/libvcx.so.%s' % version dest_dir = '/data' gzip_so_file.gz(src, dest_dir) def cargo_commands(): print('changing directory') - os.chdir('/sdk/cxs/libcxs') + os.chdir('/sdk/vcx/libvcx') print(os.listdir(os.getcwd())) print('executing: cargo update-version') os.system('cargo update-version') diff --git a/cxs/ci/scripts/test_update_so.py b/vcx/ci/scripts/test_update_so.py similarity index 76% rename from cxs/ci/scripts/test_update_so.py rename to vcx/ci/scripts/test_update_so.py index 432fd19a1d..70b535a5d0 100644 --- a/cxs/ci/scripts/test_update_so.py +++ b/vcx/ci/scripts/test_update_so.py @@ -4,12 +4,12 @@ import os TOML = 'Cargo.toml' -SO_FILE = 'libcxs.so' +SO_FILE = 'libvcx.so' def test_update_so_file(): toml_utils.update_so(SO_FILE, '4.5.6') - cmd = "ls libcxs*" + cmd = "ls libvcx*" os.system(cmd) - cmd = "mv libcxs* %s" % SO_FILE + cmd = "mv libvcx* %s" % SO_FILE os.system(cmd) print('finished') @@ -22,4 +22,4 @@ def test_get_version_from_toml(): test_update_so_file() -#test_update_so('libcxs.so', 1, 2, 3456) +#test_update_so('libvcx.so', 1, 2, 3456) diff --git a/cxs/ci/scripts/toml_utils.py b/vcx/ci/scripts/toml_utils.py similarity index 99% rename from cxs/ci/scripts/toml_utils.py rename to vcx/ci/scripts/toml_utils.py index 6881f16584..866b2bf08c 100755 --- a/cxs/ci/scripts/toml_utils.py +++ b/vcx/ci/scripts/toml_utils.py @@ -5,7 +5,7 @@ import sys import os -SO_FILE = 'libcxs.so' +SO_FILE = 'libvcx.so' # update the so file with the major minor build def update_so(src_dir, version): diff --git a/cxs/ci/scripts/version_utils.py b/vcx/ci/scripts/version_utils.py similarity index 100% rename from cxs/ci/scripts/version_utils.py rename to vcx/ci/scripts/version_utils.py diff --git a/cxs/ci/test.dockerfile b/vcx/ci/test.dockerfile similarity index 93% rename from cxs/ci/test.dockerfile rename to vcx/ci/test.dockerfile index 226203560d..b747683559 100644 --- a/cxs/ci/test.dockerfile +++ b/vcx/ci/test.dockerfile @@ -64,9 +64,9 @@ RUN cargo install cargo-deb RUN gem install fpm RUN apt-get install rpm -y -RUN export PATH=$PATH:/sdk/cxs/ci/scripts/ +RUN export PATH=$PATH:/sdk/vcx/ci/scripts/ -#RUN useradd -ms /bin/bash -u $uid cxs -#USER cxs +#RUN useradd -ms /bin/bash -u $uid vcx +#USER vcx WORKDIR / diff --git a/cxs/ci/ubuntu.dockerfile b/vcx/ci/ubuntu.dockerfile similarity index 94% rename from cxs/ci/ubuntu.dockerfile rename to vcx/ci/ubuntu.dockerfile index c16a2664c9..9bddd35dad 100644 --- a/cxs/ci/ubuntu.dockerfile +++ b/vcx/ci/ubuntu.dockerfile @@ -63,10 +63,10 @@ RUN curl -fsOSL $RUST_DOWNLOAD_URL \ RUN gem install fpm RUN apt-get install rpm -y -RUN useradd -ms /bin/bash -u $uid cxs -USER cxs +RUN useradd -ms /bin/bash -u $uid vcx +USER vcx -# cargo deb for debian packaging of libcxs +# cargo deb for debian packaging of libvcx RUN cargo install cargo-deb diff --git a/cxs/libcxs/Cargo.toml b/vcx/libvcx/Cargo.toml similarity index 84% rename from cxs/libcxs/Cargo.toml rename to vcx/libvcx/Cargo.toml index 8ce7b27efb..ae1089fbb4 100644 --- a/cxs/libcxs/Cargo.toml +++ b/vcx/libvcx/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "libcxs" +name = "libvcx" version = "0.1.2097319" authors = [ "Mark Hadley " ] publish = false -description = "C callable library for libcxs" +description = "C callable library for libvcx" license = "" [lib] -name = "cxs" +name = "vcx" path = "src/lib.rs" crate-type = ["staticlib","rlib", "dylib"] @@ -59,8 +59,8 @@ section = "admin" revision = "338ad01" priority = "optional" assets = [ - ["target/debug/libcxs.so.*", "usr/lib/", "644"], - ["scripts/provision_agent_keys.py", "usr/share/libcxs/", "655"] + ["target/debug/libvcx.so.*", "usr/lib/", "644"], + ["scripts/provision_agent_keys.py", "usr/share/libvcx/", "655"] ] maintainer-scripts = "./scripts" diff --git a/cxs/libcxs/build.rs b/vcx/libvcx/build.rs similarity index 100% rename from cxs/libcxs/build.rs rename to vcx/libvcx/build.rs diff --git a/vcx/libvcx/include/vcx.h b/vcx/libvcx/include/vcx.h new file mode 100644 index 0000000000..de19f02976 --- /dev/null +++ b/vcx/libvcx/include/vcx.h @@ -0,0 +1,218 @@ +#ifndef __VCX_H +#define __VCX_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + none = 0, + initialized, + offer_sent, + request_received, + accepted, + unfulfilled, + expired, + revoked, +} vcx_state_t; + +typedef enum +{ + undefined = 0, + validated = 1, + invalid = 2, +} vcx_proof_state_t; + +typedef unsigned int vcx_error_t; +typedef unsigned int vcx_schema_handle_t; +typedef unsigned int vcx_claimdef_handle_t; +typedef unsigned int vcx_connection_handle_t; +typedef unsigned int vcx_claim_handle_t; +typedef unsigned int vcx_proof_handle_t; +typedef unsigned int vcx_command_handle_t; +typedef unsigned int vcx_bool_t; + +typedef struct { + + union { + vcx_schema_handle_t schema_handle; + vcx_claimdef_handle_t claimdef_handle; + vcx_connection_handle_t connection_handle; + vcx_claim_handle_t claim_handle; + vcx_proof_handle_t proof_handle; + } handle; + + vcx_error_t status; + char *msg; + +} vcx_status_t; + + +/** + * Initialize the SDK + */ + +vcx_error_t vcx_init(vcx_command_handle_t handle, const char *config_path,void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err)); + + +/** + * Schema object + * + * For creating, validating and committing a schema to the sovrin ledger. + */ + +/** Creates a schema from a json string. Populates a handle to the new schema. */ +vcx_error_t vcx_schema_create(vcx_command_handle_t command_handle, const char *source_id, const char *schema_name, const char *schema_data, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err, vcx_schema_handle_t schema_handle)); + +/** Populates status with the current state of this claim. */ +vcx_error_t vcx_schema_serialize(vcx_command_handle_t command_handle, vcx_schema_handle_t schema_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *state)); + +/** Re-creates a claim object from the specified serialization. */ +vcx_error_t vcx_schema_deserialize(vcx_command_handle_t command_handle, const char *serialized_schema, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_schema_handle_t schema_handle)); + +/** Populates data with the contents of the schema handle. */ +vcx_error_t vcx_schema_get_attributes(vcx_command_handle_t command_handle, const char *source_id, vcx_schema_handle_t sequence_no, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *schema_attrs)); + +/** Populates sequence_no with the actual sequence number of the schema on the sovrin ledger. */ +vcx_error_t vcx_schema_get_sequence_no(vcx_command_handle_t command_handle, vcx_schema_handle_t schema_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_schema_handle_t sequence_no)); + +/** Release memory associated with schema object. */ +vcx_error_t vcx_schema_release(vcx_schema_handle_t handle); + + +/** + * claimdef object + * + * For creating, validating and committing a claim definition to the sovrin ledger. + */ + +/** Creates a claim definition from the given schema. Populates a handle to the new claimdef. */ +vcx_error_t vcx_claimdef_create(vcx_command_handle_t command_handle, const char *source_id, const char *claimdef_name, vcx_schema_handle_t schema_seq_no, vcx_bool_t revocation, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err, vcx_claimdef_handle_t claimdef_handle)); + +/** Populates status with the current state of this claim. */ +vcx_error_t vcx_claimdef_serialize(vcx_command_handle_t command_handle, vcx_claimdef_handle_t claimdef_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *state)); + +/** Re-creates a claim object from the specified serialization. */ +vcx_error_t vcx_claimdef_deserialize(vcx_command_handle_t command_handle, const char *serialized_claimdef, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_claimdef_handle_t claimdef_handle)); + +/** Asynchronously commits the claimdef to the ledger. */ +vcx_error_t vcx_claimdef_commit(vcx_claimdef_handle_t claimdef_handle); + +/** Populates sequence_no with the actual sequence number of the claimdef on the sovrin ledger. */ +vcx_error_t vcx_claimdef_get_sequence_no(vcx_claimdef_handle_t claimdef_handle, int *sequence_no); + +/** Populates data with the contents of the claimdef handle. */ +vcx_error_t vcx_claimdef_get(vcx_claimdef_handle_t claimdef_handle, char *data); + + +/** + * connection object + * + * For creating a connection with an identity owner for interactions such as exchanging + * claims and proofs. + */ + +/** Creates a connection object to a specific identity owner. Populates a handle to the new connection. */ +vcx_error_t vcx_connection_create(vcx_command_handle_t command_handle, const char *recipient_info, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err, vcx_connection_handle_t connection_handle)); + +/** Asynchronously request a connection be made. */ +vcx_error_t vcx_connection_connect(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, const char *connection_type, void (*cb)(vcx_command_handle_t, vcx_error_t err)); + +/** Returns the contents of the connection handle or null if the connection does not exist. */ +vcx_error_t vcx_connection_serialize(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *state)); + +/** Re-creates a connection object from the specified serialization. */ +vcx_error_t vcx_connection_deserialize(vcx_command_handle_t command_handle, const char *serialized_claim, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_connection_handle_t connection_handle)); + +/** Request a state update from the agent for the given connection. */ +vcx_error_t vcx_connection_update_state(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Retrieves the state of the connection */ +vcx_error_t vcx_connection_get_state(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Releases the connection from memory. */ +vcx_error_t vcx_connection_release(vcx_connection_handle_t connection_handle); + +/** Get the invite details for the connection. */ +vcx_error_t vcx_connection_invite_details(vcx_command_handle_t command_handle, vcx_connection_handle_t connection_handle, int abbreviated, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *details)); + + +/** + * claim issuer object + * + * Used for offering and managing a claim with an identity owner. + */ + +/** Creates a claim object from the specified claimdef handle. Populates a handle the new claim. */ +vcx_error_t vcx_issuer_create_claim(vcx_command_handle_t command_handle, const char *source_id, vcx_schema_handle_t schema_seq_no, const char *issuer_did, const char * claim_data, const char * claim_name, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err, vcx_claim_handle_t claim_handle)); + +/** Asynchronously sends the claim offer to the connection. */ +vcx_error_t vcx_issuer_send_claim_offer(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err)); + +/** Updates the state of the claim from the agency. */ +vcx_error_t vcx_issuer_claim_update_state(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Retrieves the state of the issuer_claim. */ +vcx_error_t vcx_issuer_claim_get_state(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Asynchronously send the claim to the connection. Populates a handle to the new transaction. */ +vcx_error_t vcx_issuer_send_claim(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err)); + +/** Populates status with the current state of this claim. */ +vcx_error_t vcx_issuer_claim_serialize(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *state)); + +/** Re-creates a claim object from the specified serialization. */ +vcx_error_t vcx_issuer_claim_deserialize(vcx_command_handle_t, const char *serialized_claim, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_claim_handle_t claim_handle)); + +/** Terminates a claim for the specified reason. */ +vcx_error_t vcx_issuer_terminate_claim(vcx_command_handle_t command_handle, vcx_claim_handle_t claim_handle, vcx_state_t state_type, const char *msg); + +/** Releases the claim from memory. */ +vcx_error_t vcx_issuer_claim_release(vcx_claim_handle_t claim_handle); + +/** Populates claim_request with the latest claim request received. (not in MVP) */ +vcx_error_t vcx_issuer_get_claim_request(vcx_claim_handle_t claim_handle, char *claim_request); + +/** Sets the claim request in an accepted state. (not in MVP) */ +vcx_error_t vcx_issuer_accept_claim(vcx_claim_handle_t claim_handle); + +/** + * proof object + * + * Used for requesting and managing a proof request with an identity owner. + */ + +/** Creates a proof object. Populates a handle to the new proof. */ +vcx_error_t vcx_proof_create(vcx_command_handle_t command_handle, const char *source_id, const char *requested_attrs, const char *requested_predicates, const char *name, void (*cb)(vcx_command_handle_t command_handle, vcx_error_t err, vcx_proof_handle_t proof_handle)); + +/** Asynchronously send a proof request to the connection. */ +vcx_error_t vcx_proof_send_request(vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err)); + +/** Populate response_data with the latest proof offer received. */ +vcx_error_t vcx_get_proof(vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, vcx_connection_handle_t connection_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_proof_state_t state, const char *proof_string)); + +/** Set proof offer as accepted. */ +vcx_error_t vcx_proof_accepted(vcx_proof_handle_t proof_handle); + +/** Populates status with the current state of this proof request. */ +vcx_error_t vcx_proof_update_state(vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Retrieves the state of the proof. */ +vcx_error_t vcx_proof_get_state(vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t state)); + +/** Populates status with the current state of this claim. */ +vcx_error_t vcx_proof_serialize(vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *state)); + +/** Re-creates a claim object from the specified serialization. */ +vcx_error_t vcx_proof_deserialize(vcx_command_handle_t command_handle, const char *serialized_proof, void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_proof_handle_t proof_handle)); + +/** Releases the proof from memory. */ +vcx_error_t vcx_proof_release(vcx_proof_handle_t proof_handle); + +void vcx_set_next_agency_response(int); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cxs/libcxs/sample_config/config.json b/vcx/libvcx/sample_config/config.json similarity index 100% rename from cxs/libcxs/sample_config/config.json rename to vcx/libvcx/sample_config/config.json diff --git a/vcx/libvcx/scripts/postinst b/vcx/libvcx/scripts/postinst new file mode 100755 index 0000000000..0c49332d6c --- /dev/null +++ b/vcx/libvcx/scripts/postinst @@ -0,0 +1,7 @@ +#!/bin/sh +# postinst script for libvcx + +/sbin/ldconfig + +ln -s `ls -rt /usr/lib/libvcx.* | tail -n1` /usr/lib/libvcx.so + diff --git a/cxs/libcxs/scripts/postrm b/vcx/libvcx/scripts/postrm similarity index 50% rename from cxs/libcxs/scripts/postrm rename to vcx/libvcx/scripts/postrm index 574ee6c746..953950fd89 100755 --- a/cxs/libcxs/scripts/postrm +++ b/vcx/libvcx/scripts/postrm @@ -1,5 +1,5 @@ #!/bin/sh -# postinst script for libcxs +# postinst script for libvcx /sbin/ldconfig -v diff --git a/cxs/libcxs/scripts/provision_agent_keys.py b/vcx/libvcx/scripts/provision_agent_keys.py similarity index 96% rename from cxs/libcxs/scripts/provision_agent_keys.py rename to vcx/libvcx/scripts/provision_agent_keys.py index c4b9d0067d..c1550a26e2 100644 --- a/cxs/libcxs/scripts/provision_agent_keys.py +++ b/vcx/libvcx/scripts/provision_agent_keys.py @@ -50,12 +50,12 @@ def get_agency_info(agency_url): def register_agent(args): try: #Try to load the SO from CWD first - cxs = CDLL("./libcxs.so") + vcx = CDLL("./libvcx.so") except OSError as e: if 'No such file or directory' in e.args: try: #Not found, Try from system library paths - cxs = CDLL("libcxs.so") + vcx = CDLL("libvcx.so") except: raise agency_info = get_agency_info(args.AGENCY_URL) @@ -69,7 +69,7 @@ def register_agent(args): c_json = c_char_p(json_str.encode('utf-8')) - rc = cxs.cxs_provision_agent(c_json) + rc = vcx.vcx_provision_agent(c_json) if rc == 0: sys.stderr.write("could not register agent, see log\n") diff --git a/cxs/libcxs/src/api/claim_def.rs b/vcx/libvcx/src/api/claim_def.rs similarity index 92% rename from cxs/libcxs/src/api/claim_def.rs rename to vcx/libvcx/src/api/claim_def.rs index 4d8360c646..6cd31202ae 100644 --- a/cxs/libcxs/src/api/claim_def.rs +++ b/vcx/libvcx/src/api/claim_def.rs @@ -28,7 +28,7 @@ use settings; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_claimdef_create(command_handle: u32, +pub extern fn vcx_claimdef_create(command_handle: u32, source_id: *const c_char, claimdef_name: *const c_char, schema_seq_no: u32, @@ -38,7 +38,7 @@ pub extern fn cxs_claimdef_create(command_handle: u32, check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); check_useful_c_str!(claimdef_name, error::INVALID_OPTION.code_num); check_useful_c_str!(source_id, error::INVALID_OPTION.code_num); - info!("cxs create claimdef called"); + info!("vcx create claimdef called"); let issuer_did: String = if !issuer_did.is_null() { check_useful_c_str!(issuer_did, error::INVALID_OPTION.code_num); issuer_did.to_owned() @@ -81,7 +81,7 @@ pub extern fn cxs_claimdef_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_claimdef_serialize(command_handle: u32, +pub extern fn vcx_claimdef_serialize(command_handle: u32, claimdef_handle: u32, cb: Option) -> u32 { @@ -123,7 +123,7 @@ pub extern fn cxs_claimdef_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_claimdef_deserialize(command_handle: u32, +pub extern fn vcx_claimdef_deserialize(command_handle: u32, claimdef_data: *const c_char, cb: Option) -> u32 { @@ -142,16 +142,16 @@ pub extern fn cxs_claimdef_deserialize(command_handle: u32, } #[no_mangle] -pub extern fn cxs_claimdef_release(claimdef_handle: u32) -> u32 { +pub extern fn vcx_claimdef_release(claimdef_handle: u32) -> u32 { claim_def::release(claimdef_handle) } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_commit(claimdef_handle: u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_commit(claimdef_handle: u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_get_sequence_no(claimdef_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_get_sequence_no(claimdef_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_get(claimdef_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_get(claimdef_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } #[cfg(test)] mod tests { @@ -187,7 +187,7 @@ mod tests { assert_eq!(err, 0); assert!(claimdef_handle > 0); println!("successfully called create_and_serialize_cb"); - assert_eq!(cxs_claimdef_serialize(0,claimdef_handle,Some(serialize_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_claimdef_serialize(0,claimdef_handle,Some(serialize_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } @@ -217,9 +217,9 @@ mod tests { } #[test] - fn test_cxs_create_claimdef_success() { + fn test_vcx_create_claimdef_success() { set_default_and_enable_test_mode(); - assert_eq!(cxs_claimdef_create(0, + assert_eq!(vcx_claimdef_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Claim Def").unwrap().into_raw(), 15, @@ -231,7 +231,7 @@ mod tests { #[ignore] #[test] - fn test_cxs_create_claimdef_with_pool() { + fn test_vcx_create_claimdef_with_pool() { settings::set_defaults(); pool::open_sandbox_pool(); init_wallet("a_test_wallet").unwrap(); @@ -239,7 +239,7 @@ mod tests { let (my_did, _) = SignusUtils::create_and_store_my_did(wallet_handle, Some(DEMO_ISSUER_PW_SEED)).unwrap(); SignusUtils::create_and_store_my_did(wallet_handle, Some(DEMO_AGENT_PW_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID, &my_did); - assert_eq!(cxs_claimdef_create(0, + assert_eq!(vcx_claimdef_create(0, CString::new("qqqqq").unwrap().into_raw(), CString::new("Test Claim Def").unwrap().into_raw(), 22, @@ -250,10 +250,10 @@ mod tests { } #[test] - fn test_cxs_create_claimdef_fails() { + fn test_vcx_create_claimdef_fails() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE, "false"); - assert_eq!(cxs_claimdef_create(0, + assert_eq!(vcx_claimdef_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Claim Def").unwrap().into_raw(), 0, @@ -264,9 +264,9 @@ mod tests { } #[test] - fn test_cxs_claimdef_serialize() { + fn test_vcx_claimdef_serialize() { set_default_and_enable_test_mode(); - assert_eq!(cxs_claimdef_create(0, + assert_eq!(vcx_claimdef_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Claim Def").unwrap().into_raw(), 15, @@ -277,10 +277,10 @@ mod tests { } #[test] - fn test_cxs_claimdef_deserialize_succeeds() { + fn test_vcx_claimdef_deserialize_succeeds() { set_default_and_enable_test_mode(); let original = "{\"source_id\":\"test id\",\"claim_def\":{\"ref\":15,\"origin\":\"4fUDR9R7fjwELRvH9JT6HH\",\"signature_type\":\"CL\",\"data\":{\"primary\":{\"n\":\"9\",\"s\":\"5\",\"rms\":\"4\",\"r\":{\"city\":\"6\",\"address2\":\"8\",\"address1\":\"7\",\"state\":\"6\",\"zip\":\"1\"},\"rctxt\":\"7\",\"z\":\"7\"},\"revocation\":null}},\"handle\":1378455216,\"name\":\"NAME\"}"; - cxs_claimdef_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); + vcx_claimdef_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); thread::sleep(Duration::from_millis(200)); } } diff --git a/cxs/libcxs/src/api/connection.rs b/vcx/libvcx/src/api/connection.rs similarity index 87% rename from cxs/libcxs/src/api/connection.rs rename to vcx/libvcx/src/api/connection.rs index 918161d0ab..67fda36d35 100644 --- a/cxs/libcxs/src/api/connection.rs +++ b/vcx/libvcx/src/api/connection.rs @@ -24,13 +24,13 @@ use connection::{build_connection, connect, to_string, get_state, release, is_va /// Error code as a u32 #[no_mangle] #[allow(unused_assignments)] -pub extern fn cxs_connection_create(command_handle: u32, +pub extern fn vcx_connection_create(command_handle: u32, source_id: *const c_char, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); check_useful_c_str!(source_id, error::INVALID_OPTION.code_num); - info!("cxs create connection called"); + info!("vcx create connection called"); thread::spawn(move|| { match build_connection(source_id) { Ok(handle) => cb(command_handle, error::SUCCESS.code_num, handle), @@ -57,13 +57,13 @@ pub extern fn cxs_connection_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_connect(command_handle:u32, +pub extern fn vcx_connection_connect(command_handle:u32, connection_handle: u32, connection_options: *const c_char, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); - info!("cxs connection connect called"); + info!("vcx connection connect called"); if !is_valid_handle(connection_handle) { return error::INVALID_CONNECTION_HANDLE.code_num; @@ -111,7 +111,7 @@ pub extern fn cxs_connection_connect(command_handle:u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_serialize(command_handle: u32, +pub extern fn vcx_connection_serialize(command_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -151,7 +151,7 @@ pub extern fn cxs_connection_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_deserialize(command_handle: u32, +pub extern fn vcx_connection_deserialize(command_handle: u32, connection_data: *const c_char, cb: Option) -> u32 { @@ -183,7 +183,7 @@ pub extern fn cxs_connection_deserialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_update_state(command_handle: u32, +pub extern fn vcx_connection_update_state(command_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -206,7 +206,7 @@ pub extern fn cxs_connection_update_state(command_handle: u32, } #[no_mangle] -pub extern fn cxs_connection_get_state(command_handle: u32, +pub extern fn vcx_connection_get_state(command_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -237,7 +237,7 @@ pub extern fn cxs_connection_get_state(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_invite_details(command_handle: u32, +pub extern fn vcx_connection_invite_details(command_handle: u32, connection_handle: u32, abbreviated: bool, cb: Option) -> u32 { @@ -272,7 +272,7 @@ pub extern fn cxs_connection_invite_details(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_connection_release(connection_handle: u32) -> u32 { +pub extern fn vcx_connection_release(connection_handle: u32) -> u32 { release(connection_handle) } @@ -285,7 +285,7 @@ mod tests { use utils::error; use std::thread; use std::time::Duration; - use api::CxsStateType; + use api::VcxStateType; use utils::httpclient; use utils::constants::GET_MESSAGES_RESPONSE; @@ -296,10 +296,10 @@ mod tests { } #[test] - fn test_cxs_connection_create() { + fn test_vcx_connection_create() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let rc = cxs_connection_create(0, + let rc = vcx_connection_create(0, CString::new("test_create").unwrap().into_raw(), Some(create_cb)); assert_eq!(rc, error::SUCCESS.code_num); @@ -307,15 +307,15 @@ mod tests { } #[test] - fn test_cxs_connection_create_fails() { + fn test_vcx_connection_create_fails() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let rc = cxs_connection_create(0, + let rc = vcx_connection_create(0, CString::new("test_create_fails").unwrap().into_raw(), None); assert_eq!(rc, error::INVALID_OPTION.code_num); - let rc = cxs_connection_create(0, + let rc = vcx_connection_create(0, ptr::null(), Some(create_cb)); assert_eq!(rc, error::INVALID_OPTION.code_num); @@ -326,14 +326,14 @@ mod tests { } #[test] - fn test_cxs_connection_connect() { + fn test_vcx_connection_connect() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let rc = cxs_connection_connect(0,0, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); + let rc = vcx_connection_connect(0,0, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); assert_eq!(rc, error::INVALID_CONNECTION_HANDLE.code_num); - let handle = build_connection("test_cxs_connection_connect".to_owned()).unwrap(); + let handle = build_connection("test_vcx_connection_connect".to_owned()).unwrap(); assert!(handle > 0); - let rc = cxs_connection_connect(0,handle, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); + let rc = vcx_connection_connect(0,handle, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); thread::sleep(Duration::from_millis(500)); assert_eq!(rc, error::SUCCESS.code_num); } @@ -341,26 +341,26 @@ mod tests { extern "C" fn update_state_cb(command_handle: u32, err: u32, state: u32) { assert_eq!(err, 0); println!("successfully called update_state_cb"); - assert_eq!(state,CxsStateType::CxsStateAccepted as u32); + assert_eq!(state,VcxStateType::VcxStateAccepted as u32); } #[test] - fn test_cxs_connection_update_state() { + fn test_vcx_connection_update_state() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let handle = build_connection("test_cxs_connection_update_state".to_owned()).unwrap(); + let handle = build_connection("test_vcx_connection_update_state".to_owned()).unwrap(); assert!(handle > 0); httpclient::set_next_u8_response(GET_MESSAGES_RESPONSE.to_vec()); - let rc = cxs_connection_update_state(0,handle,Some(update_state_cb)); + let rc = vcx_connection_update_state(0,handle,Some(update_state_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } #[test] - fn test_cxs_connection_update_state_fails() { + fn test_vcx_connection_update_state_fails() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let rc = cxs_connection_update_state(0,0,None); + let rc = vcx_connection_update_state(0,0,None); assert_eq!(rc, error::INVALID_OPTION.code_num); } @@ -375,27 +375,27 @@ mod tests { #[test] #[allow(unused_assignments)] - fn test_cxs_connection_serialize() { + fn test_vcx_connection_serialize() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let handle = build_connection("test_cxs_connection_get_data".to_owned()).unwrap(); + let handle = build_connection("test_vcx_connection_get_data".to_owned()).unwrap(); assert!(handle > 0); - let data = cxs_connection_serialize(0,handle, Some(serialize_cb)); + let data = vcx_connection_serialize(0,handle, Some(serialize_cb)); thread::sleep(Duration::from_millis(200)); assert_eq!(data, 0); } #[test] - fn test_cxs_connection_release() { + fn test_vcx_connection_release() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let handle = build_connection("test_cxs_connection_release".to_owned()).unwrap(); + let handle = build_connection("test_vcx_connection_release".to_owned()).unwrap(); assert!(handle > 0); - let rc = cxs_connection_release(handle); + let rc = vcx_connection_release(handle); assert_eq!(rc, error::SUCCESS.code_num); - let rc = cxs_connection_connect(0,handle, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); + let rc = vcx_connection_connect(0,handle, CString::new("{}").unwrap().into_raw(),Some(connect_cb)); assert_eq!(rc, error::INVALID_CONNECTION_HANDLE.code_num); } @@ -403,7 +403,7 @@ mod tests { assert_eq!(err, 0); assert!(connection_handle > 0); println!("successfully called deserialize_cb"); - let string = r#"{"source_id":"test_cxs_connection_deserialialize_succeeds","handle":2829557145,"pw_did":"8XFh8yBzrpJQmNyZzgoTqB","pw_verkey":"EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A","did_endpoint":"","state":1,"uuid":"","endpoint":"","invite_detail":{"statusCode":"","connReqId":"","senderDetail":{"name":"","agentKeyDlgProof":{"agentDID":"","agentDelegatedKey":"","signature":""},"DID":"","logoUrl":"","verKey":""},"senderAgencyDetail":{"DID":"","verKey":"","endpoint":""},"targetName":"","statusMsg":""},"agent_did":"U5LXs4U7P9msh647kToezy","agent_vk":"FktSZg8idAVzyQZrdUppK6FTrfAzW3wWVzAjJAfdUvJq","their_pw_did":"","their_pw_verkey":""}"#; + let string = r#"{"source_id":"test_vcx_connection_deserialialize_succeeds","handle":2829557145,"pw_did":"8XFh8yBzrpJQmNyZzgoTqB","pw_verkey":"EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A","did_endpoint":"","state":1,"uuid":"","endpoint":"","invite_detail":{"statusCode":"","connReqId":"","senderDetail":{"name":"","agentKeyDlgProof":{"agentDID":"","agentDelegatedKey":"","signature":""},"DID":"","logoUrl":"","verKey":""},"senderAgencyDetail":{"DID":"","verKey":"","endpoint":""},"targetName":"","statusMsg":""},"agent_did":"U5LXs4U7P9msh647kToezy","agent_vk":"FktSZg8idAVzyQZrdUppK6FTrfAzW3wWVzAjJAfdUvJq","their_pw_did":"","their_pw_verkey":""}"#; let new = to_string(connection_handle).unwrap(); println!("original: {}",string); @@ -412,12 +412,12 @@ mod tests { } #[test] - fn test_cxs_connection_deserialize_succeeds() { + fn test_vcx_connection_deserialize_succeeds() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let string = r#"{"source_id":"test_cxs_connection_deserialialize_succeeds","handle":2829557145,"pw_did":"8XFh8yBzrpJQmNyZzgoTqB","pw_verkey":"EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A","did_endpoint":"","state":1,"uuid":"","endpoint":"","invite_detail":{"statusCode":"","connReqId":"","senderDetail":{"name":"","agentKeyDlgProof":{"agentDID":"","agentDelegatedKey":"","signature":""},"DID":"","logoUrl":"","verKey":""},"senderAgencyDetail":{"DID":"","verKey":"","endpoint":""},"targetName":"","statusMsg":""},"agent_did":"U5LXs4U7P9msh647kToezy","agent_vk":"FktSZg8idAVzyQZrdUppK6FTrfAzW3wWVzAjJAfdUvJq","their_pw_did":"","their_pw_verkey":""}"#; + let string = r#"{"source_id":"test_vcx_connection_deserialialize_succeeds","handle":2829557145,"pw_did":"8XFh8yBzrpJQmNyZzgoTqB","pw_verkey":"EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A","did_endpoint":"","state":1,"uuid":"","endpoint":"","invite_detail":{"statusCode":"","connReqId":"","senderDetail":{"name":"","agentKeyDlgProof":{"agentDID":"","agentDelegatedKey":"","signature":""},"DID":"","logoUrl":"","verKey":""},"senderAgencyDetail":{"DID":"","verKey":"","endpoint":""},"targetName":"","statusMsg":""},"agent_did":"U5LXs4U7P9msh647kToezy","agent_vk":"FktSZg8idAVzyQZrdUppK6FTrfAzW3wWVzAjJAfdUvJq","their_pw_did":"","their_pw_verkey":""}"#; - cxs_connection_deserialize(0,CString::new(string).unwrap().into_raw(), Some(deserialize_cb)); + vcx_connection_deserialize(0,CString::new(string).unwrap().into_raw(), Some(deserialize_cb)); thread::sleep(Duration::from_millis(200)); } @@ -427,12 +427,12 @@ mod tests { } #[test] - fn test_cxs_connection_get_state() { + fn test_vcx_connection_get_state() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let handle = build_connection("test_cxs_connection_update_state".to_owned()).unwrap(); + let handle = build_connection("test_vcx_connection_update_state".to_owned()).unwrap(); assert!(handle > 0); - let rc = cxs_connection_get_state(0,handle,Some(get_state_cb)); + let rc = vcx_connection_get_state(0,handle,Some(get_state_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } diff --git a/cxs/libcxs/src/api/issuer_claim.rs b/vcx/libvcx/src/api/issuer_claim.rs similarity index 88% rename from cxs/libcxs/src/api/issuer_claim.rs rename to vcx/libvcx/src/api/issuer_claim.rs index 6eaac42993..99d584a196 100644 --- a/cxs/libcxs/src/api/issuer_claim.rs +++ b/vcx/libvcx/src/api/issuer_claim.rs @@ -36,7 +36,7 @@ use std::ptr; /// Error code as a u32 #[no_mangle] #[allow(unused_variables, unused_mut)] -pub extern fn cxs_issuer_create_claim(command_handle: u32, +pub extern fn vcx_issuer_create_claim(command_handle: u32, source_id: *const c_char, schema_seq_no: u32, issuer_did: *const c_char, @@ -90,7 +90,7 @@ pub extern fn cxs_issuer_create_claim(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_issuer_send_claim_offer(command_handle: u32, +pub extern fn vcx_issuer_send_claim_offer(command_handle: u32, claim_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -130,7 +130,7 @@ pub extern fn cxs_issuer_send_claim_offer(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_issuer_claim_update_state(command_handle: u32, +pub extern fn vcx_issuer_claim_update_state(command_handle: u32, claim_handle: u32, cb: Option) -> u32 { @@ -150,7 +150,7 @@ pub extern fn cxs_issuer_claim_update_state(command_handle: u32, } #[no_mangle] -pub extern fn cxs_issuer_claim_get_state(command_handle: u32, +pub extern fn vcx_issuer_claim_get_state(command_handle: u32, claim_handle: u32, cb: Option) -> u32 { @@ -168,9 +168,9 @@ pub extern fn cxs_issuer_claim_get_state(command_handle: u32, } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_issuer_get_claim_request(claim_handle: u32, claim_request: *mut c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_issuer_get_claim_request(claim_handle: u32, claim_request: *mut c_char) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_issuer_accept_claim(claim_handle: u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_issuer_accept_claim(claim_handle: u32) -> u32 { error::SUCCESS.code_num } /// Send Claim that was requested by user /// @@ -186,7 +186,7 @@ pub extern fn cxs_issuer_accept_claim(claim_handle: u32) -> u32 { error::SUCCESS /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_issuer_send_claim(command_handle: u32, +pub extern fn vcx_issuer_send_claim(command_handle: u32, claim_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -214,7 +214,7 @@ pub extern fn cxs_issuer_send_claim(command_handle: u32, } #[allow(unused_variables)] -pub extern fn cxs_issuer_terminate_claim(claim_handle: u32, termination_type: u32, msg: *const c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_issuer_terminate_claim(claim_handle: u32, termination_type: u32, msg: *const c_char) -> u32 { error::SUCCESS.code_num } /// Takes the claim object and returns a json string of all its attributes /// @@ -228,7 +228,7 @@ pub extern fn cxs_issuer_terminate_claim(claim_handle: u32, termination_type: u3 /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_issuer_claim_serialize(command_handle: u32, +pub extern fn vcx_issuer_claim_serialize(command_handle: u32, claim_handle: u32, cb: Option) -> u32 { @@ -269,7 +269,7 @@ pub extern fn cxs_issuer_claim_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_issuer_claim_deserialize(command_handle: u32, +pub extern fn vcx_issuer_claim_deserialize(command_handle: u32, claim_data: *const c_char, cb: Option) -> u32 { @@ -296,7 +296,7 @@ pub extern fn cxs_issuer_claim_deserialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_claim_issuer_release(claim_handle: u32) -> u32 { issuer_claim::release(claim_handle) } +pub extern fn vcx_claim_issuer_release(claim_handle: u32) -> u32 { issuer_claim::release(claim_handle) } #[cfg(test)] @@ -308,15 +308,15 @@ mod tests { use std::time::Duration; use settings; use connection; - use api::CxsStateType; + use api::VcxStateType; use utils::constants::{DEFAULT_SERIALIZED_ISSUER_CLAIM, CLAIM_REQ_STRING}; - use api::cxs::cxs_init; + use api::vcx::vcx_init; static DEFAULT_CLAIM_NAME: &str = "Claim Name Default"; static DEFAULT_DID: &str = "8XFh8yBzrpJQmNyZzgoTqB"; static DEFAULT_ATTR: &str = "{\"attr\":\"value\"}"; static DEFAULT_SCHEMA_SEQ_NO: u32 = 32; - static ISSUER_CLAIM_STATE_ACCEPTED: &str = r#"{"claim_id":"a claim id","claim_name":"claim name","source_id":"test_cxs_issuer_send_claim","handle":123,"claim_attributes":"{\"state\":[\"UT\"],\"zip\":[\"84000\"],\"city\":[\"Draper\"],\"address2\":[\"Suite 3\"],\"address1\":[\"123 Main St\"]}","msg_uid":"","schema_seq_no":32,"issuer_did":"8XFh8yBzrpJQmNyZzgoTqB","issued_did":"VsKV7grR1BUE29mG2Fm2kX","issued_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","remote_did":"VsKV7grR1BUE29mG2Fm2kX","remote_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","agent_did":"VsKV7grR1BUE29mG2Fm2kX","agent_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","state":3,"ref_msg_id":"abc123"}"#; + static ISSUER_CLAIM_STATE_ACCEPTED: &str = r#"{"claim_id":"a claim id","claim_name":"claim name","source_id":"test_vcx_issuer_send_claim","handle":123,"claim_attributes":"{\"state\":[\"UT\"],\"zip\":[\"84000\"],\"city\":[\"Draper\"],\"address2\":[\"Suite 3\"],\"address1\":[\"123 Main St\"]}","msg_uid":"","schema_seq_no":32,"issuer_did":"8XFh8yBzrpJQmNyZzgoTqB","issued_did":"VsKV7grR1BUE29mG2Fm2kX","issued_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","remote_did":"VsKV7grR1BUE29mG2Fm2kX","remote_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","agent_did":"VsKV7grR1BUE29mG2Fm2kX","agent_vk":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW","state":3,"ref_msg_id":"abc123"}"#; extern "C" fn create_cb(command_handle: u32, err: u32, claim_handle: u32) { assert_eq!(err, 0); assert!(claim_handle > 0); @@ -333,10 +333,10 @@ mod tests { } #[test] - fn test_cxs_issuer_create_claim_success() { + fn test_vcx_issuer_create_claim_success() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - assert_eq!(cxs_issuer_create_claim(0, + assert_eq!(vcx_issuer_create_claim(0, ptr::null(), 32, ptr::null(), @@ -347,10 +347,10 @@ mod tests { } #[test] - fn test_cxs_issuer_create_claim_fails() { + fn test_vcx_issuer_create_claim_fails() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - assert_eq!(cxs_issuer_create_claim( + assert_eq!(vcx_issuer_create_claim( 0, ptr::null(), 32, @@ -365,15 +365,15 @@ mod tests { assert_eq!(err, 0); assert!(claim_handle > 0); println!("successfully called create_and_serialize_cb"); - assert_eq!(cxs_issuer_claim_serialize(0,claim_handle,Some(serialize_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_issuer_claim_serialize(0,claim_handle,Some(serialize_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } #[test] - fn test_cxs_issuer_claim_serialize() { + fn test_vcx_issuer_claim_serialize() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - assert_eq!(cxs_issuer_create_claim(0, + assert_eq!(vcx_issuer_create_claim(0, ptr::null(), DEFAULT_SCHEMA_SEQ_NO, CString::new(DEFAULT_DID).unwrap().into_raw(), @@ -388,16 +388,16 @@ mod tests { } #[test] - fn test_cxs_issuer_send_claim_offer() { + fn test_vcx_issuer_send_claim_offer() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); let handle = issuer_claim::from_string(DEFAULT_SERIALIZED_ISSUER_CLAIM).unwrap(); - assert_eq!(issuer_claim::get_state(handle),CxsStateType::CxsStateInitialized as u32); + assert_eq!(issuer_claim::get_state(handle),VcxStateType::VcxStateInitialized as u32); let connection_handle = connection::build_connection("test_send_claim_offer".to_owned()).unwrap(); - assert_eq!(cxs_issuer_send_claim_offer(0,handle,connection_handle,Some(send_offer_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_issuer_send_claim_offer(0,handle,connection_handle,Some(send_offer_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(1000)); } @@ -407,15 +407,15 @@ mod tests { } #[test] - fn test_cxs_issuer_send_a_claim() { + fn test_vcx_issuer_send_a_claim() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID, DEFAULT_DID); use claim_request::ClaimRequest; - let test_name = "test_cxs_issuer_send_a_claim"; + let test_name = "test_vcx_issuer_send_a_claim"; - //let result = cxs_init(0,ptr::null(),Some(init_cb)); + //let result = vcx_init(0,ptr::null(),Some(init_cb)); thread::sleep(Duration::from_secs(1)); let handle = issuer_claim::from_string(ISSUER_CLAIM_STATE_ACCEPTED).unwrap(); @@ -429,14 +429,14 @@ mod tests { claim_request.issuer_did = settings::get_config_value(settings::CONFIG_ENTERPRISE_DID).clone().unwrap(); claim_request.schema_seq_no = 15; issuer_claim::set_claim_request(handle, claim_request).unwrap(); - assert_eq!(issuer_claim::get_state(handle),CxsStateType::CxsStateRequestReceived as u32); + assert_eq!(issuer_claim::get_state(handle),VcxStateType::VcxStateRequestReceived as u32); /**********************************************************************/ // create connection let connection_handle = connection::build_connection("test_send_claim".to_owned()).unwrap(); // send the claim - assert_eq!(cxs_issuer_send_claim(0, handle, connection_handle, Some(send_offer_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_issuer_send_claim(0, handle, connection_handle, Some(send_offer_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(1000)); } extern "C" fn deserialize_cb(command_handle: u32, err: u32, claim_handle: u32) { @@ -453,23 +453,23 @@ mod tests { } #[test] - fn test_cxs_issuer_claim_deserialize_succeeds() { + fn test_vcx_issuer_claim_deserialize_succeeds() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); let string = DEFAULT_SERIALIZED_ISSUER_CLAIM; - cxs_issuer_claim_deserialize(0,CString::new(string).unwrap().into_raw(), Some(deserialize_cb)); + vcx_issuer_claim_deserialize(0,CString::new(string).unwrap().into_raw(), Some(deserialize_cb)); thread::sleep(Duration::from_millis(200)); } // TODO: Need to get this test working /* #[test] - fn test_cxs_issue_claim_fails_without_claim_def_in_wallet(){ + fn test_vcx_issue_claim_fails_without_claim_def_in_wallet(){ - let test_name = "test_cxs_issue_claim_fails_without_claim_def_in_wallet"; + let test_name = "test_vcx_issue_claim_fails_without_claim_def_in_wallet"; let schema_seq_num = 32 as u32; - let result = cxs_init(0,ptr::null(),Some(init_cb)); + let result = vcx_init(0,ptr::null(),Some(init_cb)); thread::sleep(Duration::from_secs(1)); settings::set_defaults(); @@ -477,7 +477,7 @@ mod tests { settings::set_config_value(settings::CONFIG_AGENT_ENDPOINT, mockito::SERVER_URL); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID,"8XFh8yBzrpJQmNyZzgoTqB"); - let original_issuer_claim_str = "{\"source_id\":\"test_cxs_issue_claim_fails_without_claim_def_in_wallet\",\"handle\":123,\"claim_attributes\":\"{\\\"attr\\\":\\\"value\\\"}\",\"msg_uid\":\"\",\"schema_seq_no\":32,\"issuer_did\":\"8XFh8yBzrpJQmNyZzgoTqB\",\"issued_did\":\"\",\"state\":3}"; + let original_issuer_claim_str = "{\"source_id\":\"test_vcx_issue_claim_fails_without_claim_def_in_wallet\",\"handle\":123,\"claim_attributes\":\"{\\\"attr\\\":\\\"value\\\"}\",\"msg_uid\":\"\",\"schema_seq_no\":32,\"issuer_did\":\"8XFh8yBzrpJQmNyZzgoTqB\",\"issued_did\":\"\",\"state\":3}"; let handle = issuer_claim::from_string(original_issuer_claim_str).unwrap(); let connection_handle = connection::create_connection(test_name.to_owned()); /* align claim request and claim def ***********************************/ @@ -488,7 +488,7 @@ mod tests { claim_request.schema_seq_no = schema_seq_num as i32; assert_eq!(claim_request.schema_seq_no, schema_seq_num as i32); issuer_claim::set_claim_request(handle, &claim_request).unwrap(); - assert_eq!(issuer_claim::get_state(handle),CxsStateType::CxsStateRequestReceived as u32); + assert_eq!(issuer_claim::get_state(handle),VcxStateType::VcxStateRequestReceived as u32); let schema = create_default_schema(schema_seq_num); let wallet_name = create_dummy_wallet(test_name); // put_claim_def_in_issuer_wallet(&settings::get_config_value( @@ -502,7 +502,7 @@ mod tests { // wait for response, response should be error - assert_eq!(cxs_issuer_send_claim(command_handle, handle, connection_handle, Some(send_offer_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_issuer_send_claim(command_handle, handle, connection_handle, Some(send_offer_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(1000)); } */ @@ -517,13 +517,13 @@ mod tests { #[test] fn test_create_claim_arguments_correct(){ - let result = cxs_init(0,ptr::null(),Some(init_cb)); + let result = vcx_init(0,ptr::null(),Some(init_cb)); thread::sleep(Duration::from_secs(1)); settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID, DEFAULT_DID); - assert_eq!(cxs_issuer_create_claim(0, + assert_eq!(vcx_issuer_create_claim(0, ptr::null(), DEFAULT_SCHEMA_SEQ_NO, CString::new(DEFAULT_DID).unwrap().into_raw(), @@ -538,12 +538,12 @@ mod tests { } #[test] - fn test_cxs_issuer_claim_get_state() { + fn test_vcx_issuer_claim_get_state() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); let handle = issuer_claim::from_string(DEFAULT_SERIALIZED_ISSUER_CLAIM).unwrap(); assert!(handle > 0); - let rc = cxs_issuer_claim_get_state(0,handle,Some(get_state_cb)); + let rc = vcx_issuer_claim_get_state(0,handle,Some(get_state_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } diff --git a/cxs/libcxs/src/api/mod.rs b/vcx/libvcx/src/api/mod.rs similarity index 84% rename from cxs/libcxs/src/api/mod.rs rename to vcx/libvcx/src/api/mod.rs index 0817dee42c..e6e41a02d7 100644 --- a/cxs/libcxs/src/api/mod.rs +++ b/vcx/libvcx/src/api/mod.rs @@ -1,6 +1,6 @@ extern crate libc; -pub mod cxs; +pub mod vcx; pub mod connection; pub mod issuer_claim; pub mod utils; @@ -17,7 +17,7 @@ pub enum Errorcode Failure = 1, Waiting = 2, } -/// This macro allows the CxsStateType to be +/// This macro allows the VcxStateType to be /// serialized within serde as an integer (represented as /// a string, because its still JSON). macro_rules! enum_number { @@ -70,19 +70,19 @@ macro_rules! enum_number { } } -enum_number!(CxsStateType +enum_number!(VcxStateType { - CxsStateNone = 0, - CxsStateInitialized = 1, - CxsStateOfferSent = 2, - CxsStateRequestReceived = 3, - CxsStateAccepted = 4, - CxsStateUnfulfilled = 5, - CxsStateExpired = 6, - CxsStateRevoked = 7, + VcxStateNone = 0, + VcxStateInitialized = 1, + VcxStateOfferSent = 2, + VcxStateRequestReceived = 3, + VcxStateAccepted = 4, + VcxStateUnfulfilled = 5, + VcxStateExpired = 6, + VcxStateRevoked = 7, }); -// undefined is correlated with CxsStateNon -> Haven't received Proof +// undefined is correlated with VcxStateNon -> Haven't received Proof // Validated is both validated by indy-sdk and by comparing proof-request // Invalid is that it failed one or both of validation processes enum_number!(ProofStateType @@ -93,7 +93,7 @@ enum_number!(ProofStateType }); #[repr(C)] -pub struct CxsStatus { +pub struct VcxStatus { pub handle: ::std::os::raw::c_int, pub status: ::std::os::raw::c_int, pub msg: *mut ::std::os::raw::c_char, @@ -104,11 +104,11 @@ pub struct CxsStatus { mod tests { use super::*; use serde_json; - use self::CxsStateType::*; + use self::VcxStateType::*; #[test] - fn test_serialize_cxs_state_type(){ - let z = CxsStateNone; + fn test_serialize_vcx_state_type(){ + let z = VcxStateNone; let y = serde_json::to_string(&z).unwrap(); assert_eq!(y,"0"); } diff --git a/cxs/libcxs/src/api/proof.rs b/vcx/libvcx/src/api/proof.rs similarity index 94% rename from cxs/libcxs/src/api/proof.rs rename to vcx/libvcx/src/api/proof.rs index 738afdf2a3..e2f295b0fb 100644 --- a/cxs/libcxs/src/api/proof.rs +++ b/vcx/libvcx/src/api/proof.rs @@ -30,7 +30,7 @@ use std::ptr; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_create(command_handle: u32, +pub extern fn vcx_proof_create(command_handle: u32, source_id: *const c_char, requested_attrs: *const c_char, requested_predicates: *const c_char, @@ -73,7 +73,7 @@ pub extern fn cxs_proof_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_update_state(command_handle: u32, +pub extern fn vcx_proof_update_state(command_handle: u32, proof_handle: u32, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); @@ -92,7 +92,7 @@ pub extern fn cxs_proof_update_state(command_handle: u32, } #[no_mangle] -pub extern fn cxs_proof_get_state(command_handle: u32, +pub extern fn vcx_proof_get_state(command_handle: u32, proof_handle: u32, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); @@ -120,7 +120,7 @@ pub extern fn cxs_proof_get_state(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_serialize(command_handle: u32, +pub extern fn vcx_proof_serialize(command_handle: u32, proof_handle: u32, cb: Option) -> u32 { @@ -162,7 +162,7 @@ pub extern fn cxs_proof_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_deserialize(command_handle: u32, +pub extern fn vcx_proof_deserialize(command_handle: u32, proof_data: *const c_char, cb: Option) -> u32 { @@ -188,7 +188,7 @@ pub extern fn cxs_proof_deserialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_release(proof_handle: u32) -> u32 { +pub extern fn vcx_proof_release(proof_handle: u32) -> u32 { proof::release(proof_handle) } @@ -206,7 +206,7 @@ pub extern fn cxs_proof_release(proof_handle: u32) -> u32 { /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_proof_send_request(command_handle: u32, +pub extern fn vcx_proof_send_request(command_handle: u32, proof_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -247,7 +247,7 @@ pub extern fn cxs_proof_send_request(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_get_proof(command_handle: u32, +pub extern fn vcx_get_proof(command_handle: u32, proof_handle: u32, connection_handle: u32, cb: Option) -> u32 { @@ -282,7 +282,7 @@ pub extern fn cxs_get_proof(command_handle: u32, #[allow(unused_variables)] -pub extern fn cxs_proof_accepted(proof_handle: u32, response_data: *const c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_proof_accepted(proof_handle: u32, response_data: *const c_char) -> u32 { error::SUCCESS.code_num } #[cfg(test)] @@ -296,7 +296,7 @@ mod tests { use settings; use proof::{ create_proof }; use proof; - use api::CxsStateType; + use api::VcxStateType; use connection; use api::{ ProofStateType }; @@ -349,7 +349,7 @@ mod tests { assert_eq!(err, 0); assert!(proof_handle > 0); println!("successfully called create_and_serialize_cb"); - assert_eq!(cxs_proof_serialize(0, proof_handle, Some(serialize_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_proof_serialize(0, proof_handle, Some(serialize_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } @@ -366,7 +366,7 @@ mod tests { extern "C" fn update_state_cb(command_handle: u32, err: u32, state: u32) { assert_eq!(err, 0); println!("successfully called update_state_cb"); - assert_eq!(state, CxsStateType::CxsStateInitialized as u32); + assert_eq!(state, VcxStateType::VcxStateInitialized as u32); } @@ -380,9 +380,9 @@ mod tests { } #[test] - fn test_cxs_create_proof_success() { + fn test_vcx_create_proof_success() { set_default_and_enable_test_mode(); - assert_eq!(cxs_proof_create(0, + assert_eq!(vcx_proof_create(0, ptr::null(), CString::new(REQUESTED_ATTRS).unwrap().into_raw(), CString::new(REQUESTED_PREDICATES).unwrap().into_raw(), @@ -392,9 +392,9 @@ mod tests { } #[test] - fn test_cxs_create_proof_fails() { + fn test_vcx_create_proof_fails() { set_default_and_enable_test_mode(); - assert_eq!(cxs_proof_create( + assert_eq!(vcx_proof_create( 0, ptr::null(), ptr::null(), @@ -405,9 +405,9 @@ mod tests { } #[test] - fn test_cxs_proof_serialize() { + fn test_vcx_proof_serialize() { set_default_and_enable_test_mode(); - assert_eq!(cxs_proof_create(0, + assert_eq!(vcx_proof_create(0, ptr::null(), CString::new(REQUESTED_ATTRS).unwrap().into_raw(), CString::new(REQUESTED_PREDICATES).unwrap().into_raw(), @@ -417,10 +417,10 @@ mod tests { } #[test] - fn test_cxs_proof_deserialize_succeeds() { + fn test_vcx_proof_deserialize_succeeds() { set_default_and_enable_test_mode(); let original = r#"{"nonce":"123456","version":"1.0","handle":1,"msg_uid":"","ref_msg_id":"","name":"Name Data","prover_vk":"","agent_did":"","agent_vk":"","remote_did":"","remote_vk":"","prover_did":"8XFh8yBzrpJQmNyZzgoTqB","requested_attrs":"{\"attrs\":[{\"name\":\"person name\"},{\"schema_seq_no\":1,\"name\":\"address_1\"},{\"schema_seq_no\":2,\"issuer_did\":\"ISSUER_DID2\",\"name\":\"address_2\"},{\"schema_seq_no\":1,\"name\":\"city\"},{\"schema_seq_no\":1,\"name\":\"state\"},{\"schema_seq_no\":1,\"name\":\"zip\"}]}","requested_predicates":"{\"attr_name\":\"age\",\"p_type\":\"GE\",\"value\":18,\"schema_seq_no\":1,\"issuer_did\":\"DID1\"}","source_id":"source id","state":2,"proof_state":0,"proof":null,"proof_request":null}"#; - cxs_proof_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); + vcx_proof_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); thread::sleep(Duration::from_millis(200)); } @@ -437,13 +437,13 @@ mod tests { }; assert!(handle > 0); thread::sleep(Duration::from_millis(300)); - let rc = cxs_proof_update_state(0, handle, Some(update_state_cb)); + let rc = vcx_proof_update_state(0, handle, Some(update_state_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } #[test] - fn test_cxs_proof_send_request() { + fn test_vcx_proof_send_request() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); @@ -454,12 +454,12 @@ mod tests { Ok(x) => x, Err(_) => panic!("Proof creation failed"), }; - assert_eq!(proof::get_state(handle),CxsStateType::CxsStateInitialized as u32); + assert_eq!(proof::get_state(handle),VcxStateType::VcxStateInitialized as u32); let connection_handle = connection::build_connection("test_send_proof_request".to_owned()).unwrap(); - assert_eq!(cxs_proof_send_request(0,handle,connection_handle,Some(send_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_proof_send_request(0,handle,connection_handle,Some(send_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(1000)); - assert_eq!(proof::get_state(handle),CxsStateType::CxsStateOfferSent as u32); + assert_eq!(proof::get_state(handle),VcxStateType::VcxStateOfferSent as u32); } #[test] @@ -475,7 +475,7 @@ mod tests { connection::set_pw_did(connection_handle, "XXFh7yBzrpJQmNyZzgoTqB"); thread::sleep(Duration::from_millis(300)); - let rc = cxs_get_proof(0, handle, connection_handle, Some(no_proof_cb)); + let rc = vcx_get_proof(0, handle, connection_handle, Some(no_proof_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } @@ -489,7 +489,7 @@ mod tests { thread::sleep(Duration::from_millis(300)); let proof_handle = proof::from_string(PROOF_WITH_INVALID_STATE).unwrap(); - let rc = cxs_get_proof(0, proof_handle, connection_handle, Some(verify_invalid_proof_cb)); + let rc = vcx_get_proof(0, proof_handle, connection_handle, Some(verify_invalid_proof_cb)); thread::sleep(Duration::from_millis(900)); assert_eq!(rc, 0); } @@ -500,12 +500,12 @@ mod tests { } #[test] - fn test_cxs_connection_get_state() { + fn test_vcx_connection_get_state() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); let handle = proof::from_string(r#"{"nonce":"123456","version":"1.0","handle":1,"msg_uid":"","ref_msg_id":"","name":"Name Data","prover_vk":"","agent_did":"","agent_vk":"","remote_did":"","remote_vk":"","prover_did":"8XFh8yBzrpJQmNyZzgoTqB","requested_attrs":"{\"attrs\":[{\"name\":\"person name\"},{\"schema_seq_no\":1,\"name\":\"address_1\"},{\"schema_seq_no\":2,\"issuer_did\":\"ISSUER_DID2\",\"name\":\"address_2\"},{\"schema_seq_no\":1,\"name\":\"city\"},{\"schema_seq_no\":1,\"name\":\"state\"},{\"schema_seq_no\":1,\"name\":\"zip\"}]}","requested_predicates":"{\"attr_name\":\"age\",\"p_type\":\"GE\",\"value\":18,\"schema_seq_no\":1,\"issuer_did\":\"DID1\"}","source_id":"source id","state":2,"proof_state":0,"proof":null,"proof_request":null}"#).unwrap(); assert!(handle > 0); - let rc = cxs_proof_get_state(0,handle,Some(get_state_cb)); + let rc = vcx_proof_get_state(0,handle,Some(get_state_cb)); assert_eq!(rc, error::SUCCESS.code_num); thread::sleep(Duration::from_millis(300)); } diff --git a/cxs/libcxs/src/api/schema.rs b/vcx/libvcx/src/api/schema.rs similarity index 92% rename from cxs/libcxs/src/api/schema.rs rename to vcx/libvcx/src/api/schema.rs index f4d8f18890..67827798f7 100644 --- a/cxs/libcxs/src/api/schema.rs +++ b/vcx/libvcx/src/api/schema.rs @@ -26,7 +26,7 @@ use settings; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_create(command_handle: u32, +pub extern fn vcx_schema_create(command_handle: u32, source_id: *const c_char, schema_name: *const c_char, schema_data: *const c_char, @@ -66,7 +66,7 @@ pub extern fn cxs_schema_create(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_serialize(command_handle: u32, +pub extern fn vcx_schema_serialize(command_handle: u32, schema_handle: u32, cb: Option) -> u32 { @@ -108,7 +108,7 @@ pub extern fn cxs_schema_serialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_deserialize(command_handle: u32, +pub extern fn vcx_schema_deserialize(command_handle: u32, schema_data: *const c_char, cb: Option) -> u32 { @@ -134,7 +134,7 @@ pub extern fn cxs_schema_deserialize(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_release(schema_handle: u32) -> u32 { +pub extern fn vcx_schema_release(schema_handle: u32) -> u32 { schema::release(schema_handle) } @@ -148,7 +148,7 @@ pub extern fn cxs_schema_release(schema_handle: u32) -> u32 { /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_get_sequence_no(command_handle: u32, +pub extern fn vcx_schema_get_sequence_no(command_handle: u32, schema_handle: u32, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); @@ -180,13 +180,13 @@ pub extern fn cxs_schema_get_sequence_no(command_handle: u32, /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_schema_get_attributes(command_handle: u32, +pub extern fn vcx_schema_get_attributes(command_handle: u32, source_id: *const c_char, sequence_no: u32, cb: Option) -> u32 { check_useful_c_callback!(cb, error::INVALID_OPTION.code_num); check_useful_c_str!(source_id, error::INVALID_OPTION.code_num); - info!("cxs call to get schema attributes"); + info!("vcx call to get schema attributes"); thread::spawn( move|| { match schema::get_schema_attrs(source_id, sequence_no) { @@ -212,7 +212,7 @@ mod tests { extern crate serde_json; use super::*; - use api::claim_def::cxs_claimdef_create; + use api::claim_def::vcx_claimdef_create; use std::ffi::CString; use std::thread; use std::time::Duration; @@ -237,7 +237,7 @@ mod tests { assert_eq!(err, 0); assert!(schema_handle > 0); println!("successfully called create_and_serialize_cb"); - assert_eq!(cxs_schema_serialize(0, schema_handle, Some(serialize_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_schema_serialize(0, schema_handle, Some(serialize_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } @@ -245,7 +245,7 @@ mod tests { assert_eq!(err, 0); assert!(schema_handle > 0); println!("successfully called create_cb_get_seq_no"); - assert_eq!(cxs_schema_get_sequence_no(0, schema_handle, Some(get_seq_no_cb)), error::SUCCESS.code_num); + assert_eq!(vcx_schema_get_sequence_no(0, schema_handle, Some(get_seq_no_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } @@ -255,7 +255,7 @@ mod tests { println!("successfully called create_schema_and_claimdef_cb"); let schema_seq_no = schema::get_sequence_num(schema_handle).unwrap(); println!("created schema with schema_seq_no: {}", schema_seq_no); - assert_eq!(cxs_claimdef_create(0, + assert_eq!(vcx_claimdef_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Claim Def").unwrap().into_raw(), schema_seq_no, @@ -296,9 +296,9 @@ mod tests { } #[test] - fn test_cxs_create_schema_success() { + fn test_vcx_create_schema_success() { set_default_and_enable_test_mode(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new("{}").unwrap().into_raw(), @@ -308,7 +308,7 @@ mod tests { #[ignore] #[test] - fn test_cxs_create_schema_with_pool() { + fn test_vcx_create_schema_with_pool() { settings::set_defaults(); pool::open_sandbox_pool(); init_wallet("a_test_wallet").unwrap(); @@ -317,7 +317,7 @@ mod tests { SignusUtils::create_and_store_my_did(wallet_handle, Some(DEMO_AGENT_PW_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID, &my_did); let data = r#"{"name":"name","version":"1.0","attr_names":["name","male"]}"#.to_string(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new(data).unwrap().into_raw(), @@ -327,7 +327,7 @@ mod tests { #[ignore] #[test] - fn test_cxs_create_schema_and_create_claimdef_with_pool() { + fn test_vcx_create_schema_and_create_claimdef_with_pool() { settings::set_defaults(); pool::open_sandbox_pool(); init_wallet("a_test_wallet").unwrap(); @@ -336,7 +336,7 @@ mod tests { SignusUtils::create_and_store_my_did(wallet_handle, Some(DEMO_AGENT_PW_SEED)).unwrap(); settings::set_config_value(settings::CONFIG_ENTERPRISE_DID, &my_did); let data = r#"{"name":"Claim For Driver's License","version":"1.0","attr_names":["address1","address2","city","state","zip"]}"#.to_string(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new(data).unwrap().into_raw(), @@ -346,10 +346,10 @@ mod tests { #[ignore] #[test] - fn test_cxs_schema_get_attrs_with_pool() { + fn test_vcx_schema_get_attrs_with_pool() { set_default_and_enable_test_mode(); let data = r#"{"name":"name","version":"1.0","attr_names":["name","male"]}"#.to_string(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new(data).unwrap().into_raw(), @@ -358,10 +358,10 @@ mod tests { } #[test] - fn test_cxs_schema_serialize() { + fn test_vcx_schema_serialize() { set_default_and_enable_test_mode(); let data = r#"{"name":"name","version":"1.0","attr_names":["name","male"]}"#.to_string(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new(data).unwrap().into_raw(), @@ -370,17 +370,17 @@ mod tests { } #[test] - fn test_cxs_schema_deserialize_succeeds() { + fn test_vcx_schema_deserialize_succeeds() { set_default_and_enable_test_mode(); let original = r#"{"data":{"seqNo":15,"identifier":"4fUDR9R7fjwELRvH9JT6HH","txnTime":1510246647,"type":"101","data":{"name":"Home Address","version":"0.1","attr_names":["address1","address2","city","state","zip"]}},"handle":1,"name":"schema_name","source_id":"testId","sequence_num":306}"#; - cxs_schema_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); + vcx_schema_deserialize(0,CString::new(original).unwrap().into_raw(), Some(deserialize_cb)); thread::sleep(Duration::from_millis(200)); } #[test] - fn test_cxs_schema_get_schema_no_succeeds() { + fn test_vcx_schema_get_schema_no_succeeds() { set_default_and_enable_test_mode(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new("{}").unwrap().into_raw(), @@ -390,14 +390,14 @@ mod tests { } #[test] - fn test_cxs_schema_get_attrs() { + fn test_vcx_schema_get_attrs() { set_default_and_enable_test_mode(); let data = r#"{"name":"name","version":"1.0","attr_names":["name","male"]}"#.to_string(); - assert_eq!(cxs_schema_create(0, + assert_eq!(vcx_schema_create(0, CString::new("Test Source ID").unwrap().into_raw(), CString::new("Test Schema").unwrap().into_raw(), CString::new(data).unwrap().into_raw(), Some(create_and_serialize_cb)), error::SUCCESS.code_num); thread::sleep(Duration::from_millis(200)); } -} \ No newline at end of file +} diff --git a/cxs/libcxs/src/api/utils.rs b/vcx/libvcx/src/api/utils.rs similarity index 93% rename from cxs/libcxs/src/api/utils.rs rename to vcx/libvcx/src/api/utils.rs index 7a975602cb..8582a7f4e9 100644 --- a/cxs/libcxs/src/api/utils.rs +++ b/vcx/libvcx/src/api/utils.rs @@ -20,7 +20,7 @@ pub struct Config { } #[no_mangle] -pub extern fn cxs_provision_agent(json: *const c_char) -> *mut c_char { +pub extern fn vcx_provision_agent(json: *const c_char) -> *mut c_char { check_useful_c_str!(json, ptr::null_mut()); let my_config: Config = match serde_json::from_str(&json) { @@ -45,7 +45,7 @@ pub extern fn cxs_provision_agent(json: *const c_char) -> *mut c_char { } #[no_mangle] -pub extern fn cxs_set_next_agency_response(message_index: u32) { +pub extern fn vcx_set_next_agency_response(message_index: u32) { let message = match message_index { 1 => CREATE_KEYS_RESPONSE.to_vec(), 2 => UPDATE_PROFILE_RESPONSE.to_vec(), @@ -93,8 +93,8 @@ mod tests { println!("json_string: {}",json_string); let c_json = CString::new(json_string).unwrap().into_raw(); - let result = cxs_provision_agent(c_json); - //let result = cxs_provision_agent(c_did, c_vk, c_host, c_wallet, ptr::null(), ptr::null(), ptr::null()); + let result = vcx_provision_agent(c_json); + //let result = vcx_provision_agent(c_did, c_vk, c_host, c_wallet, ptr::null(), ptr::null(), ptr::null()); let final_string; unsafe { diff --git a/cxs/libcxs/src/api/cxs.rs b/vcx/libvcx/src/api/vcx.rs similarity index 91% rename from cxs/libcxs/src/api/cxs.rs rename to vcx/libvcx/src/api/vcx.rs index 2ac1ae84b7..9a7ea3dd19 100644 --- a/cxs/libcxs/src/api/cxs.rs +++ b/vcx/libvcx/src/api/vcx.rs @@ -9,7 +9,7 @@ use settings; use std::thread; use std::path::Path; -/// Initializes CXS with config file +/// Initializes VCX with config file /// /// Possible values in the Config file: -> /// @@ -39,7 +39,7 @@ use std::path::Path; /// /// logo_url: url for enterprise's logo /// -/// An example file is at libcxs/sample_config/config.json +/// An example file is at libvcx/sample_config/config.json /// /// #Params /// command_handle: command handle to map callback to user context. @@ -51,7 +51,7 @@ use std::path::Path; /// #Returns /// Error code as a u32 #[no_mangle] -pub extern fn cxs_init (command_handle: u32, +pub extern fn vcx_init (command_handle: u32, config_path:*const c_char, cb: Option) -> u32 { @@ -204,13 +204,13 @@ pub extern fn cxs_init (command_handle: u32, */ #[allow(unused_variables, unused_mut)] -pub extern fn cxs_schema_create(schema_data: *const c_char, schema_handle: *mut u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_schema_create(schema_data: *const c_char, schema_handle: *mut u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_schema_commit(schema_handle: u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_schema_commit(schema_handle: u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables)] -pub extern fn cxs_schema_get_data(schema_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_schema_get_data(schema_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_schema_get_sequence_no(schema_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_schema_get_sequence_no(schema_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } /** @@ -218,13 +218,13 @@ pub extern fn cxs_schema_get_sequence_no(schema_handle: u32, sequence_no: *mut u */ #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_create(schema_handle: u32, claimdef_handle: *mut u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_create(schema_handle: u32, claimdef_handle: *mut u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_commit(claimdef_handle: u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_commit(claimdef_handle: u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_get_sequence_no(claimdef_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_get_sequence_no(claimdef_handle: u32, sequence_no: *mut u32) -> u32 { error::SUCCESS.code_num } #[allow(unused_variables, unused_mut)] -pub extern fn cxs_claimdef_get(claimdef_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } +pub extern fn vcx_claimdef_get(claimdef_handle: u32, data: *mut c_char) -> u32 { error::SUCCESS.code_num } #[cfg(test)] @@ -268,7 +268,7 @@ mod tests { Ok(_) => println!("sample config ready"), } - let result = cxs_init(0,CString::new(config_path).unwrap().into_raw(),Some(init_cb)); + let result = vcx_init(0,CString::new(config_path).unwrap().into_raw(),Some(init_cb)); assert_eq!(result,0); thread::sleep(Duration::from_secs(1)); // Leave file around or other concurrent tests will fail @@ -286,7 +286,7 @@ mod tests { fn test_init_bad_path() { use utils::libindy::pool::get_pool_handle; let empty_str = CString::new("").unwrap().into_raw(); - assert_eq!(error::INVALID_OPTION.code_num,cxs_init(0,empty_str,Some(init_cb))); + assert_eq!(error::INVALID_OPTION.code_num,vcx_init(0,empty_str,Some(init_cb))); match get_pool_handle() { Ok(h) => {pool::close().unwrap();}, @@ -299,7 +299,7 @@ mod tests { fn test_init_no_config_path() { settings::set_defaults(); settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); - let result = cxs_init(0,ptr::null(),Some(init_cb)); + let result = vcx_init(0,ptr::null(),Some(init_cb)); assert_eq!(result,error::INVALID_CONFIGURATION.code_num); thread::sleep(Duration::from_secs(1)); wallet::delete_wallet("wallet1").unwrap(); diff --git a/cxs/libcxs/src/claim_def.rs b/vcx/libvcx/src/claim_def.rs similarity index 100% rename from cxs/libcxs/src/claim_def.rs rename to vcx/libvcx/src/claim_def.rs diff --git a/cxs/libcxs/src/claim_request.rs b/vcx/libvcx/src/claim_request.rs similarity index 100% rename from cxs/libcxs/src/claim_request.rs rename to vcx/libvcx/src/claim_request.rs diff --git a/cxs/libcxs/src/connection.rs b/vcx/libvcx/src/connection.rs similarity index 96% rename from cxs/libcxs/src/connection.rs rename to vcx/libvcx/src/connection.rs index ca13f68fd7..377cf53399 100644 --- a/cxs/libcxs/src/connection.rs +++ b/vcx/libvcx/src/connection.rs @@ -8,7 +8,7 @@ use utils::libindy::wallet; use utils::error; use utils::libindy::signus::SignusUtils; use utils::libindy::crypto; -use api::CxsStateType; +use api::VcxStateType; use rand::Rng; use std::sync::Mutex; use std::collections::HashMap; @@ -42,7 +42,7 @@ struct Connection { pw_did: String, pw_verkey: String, did_endpoint: String, - state: CxsStateType, + state: VcxStateType, uuid: String, endpoint: String, // For QR code invitation @@ -55,7 +55,7 @@ struct Connection { impl Connection { fn connect(&mut self, options: Option) -> Result { - info!("\"cxs_connection_connect\" for handle {}", self.handle); + info!("\"vcx_connection_connect\" for handle {}", self.handle); if !self.ready_to_connect() { warn!("connection {} in state {} not ready to connect",self.handle,self.state as u32); return Err(error::NOT_READY.code_num); @@ -93,7 +93,7 @@ impl Connection { return Err(error::POST_MSG_FAILURE.code_num) }, Ok(response) => { - self.state = CxsStateType::CxsStateOfferSent; + self.state = VcxStateType::VcxStateOfferSent; self.invite_detail = match parse_invite_detail(&response[0]) { Ok(x) => x, Err(x) => { @@ -111,7 +111,7 @@ impl Connection { fn set_their_pw_did(&mut self, did: &str) { self.their_pw_did = did.to_string(); } fn set_agent_did(&mut self, did: &str) { self.agent_did = did.to_string(); } fn get_agent_did(&self) -> String { self.agent_did.clone() } - fn set_state(&mut self, state: CxsStateType) { self.state = state; } + fn set_state(&mut self, state: VcxStateType) { self.state = state; } fn get_pw_did(&self) -> String { self.pw_did.clone() } fn get_their_pw_did(&self) -> String { self.their_pw_did.clone() } fn get_pw_verkey(&self) -> String { self.pw_verkey.clone() } @@ -125,7 +125,7 @@ impl Connection { fn set_uuid(&mut self, uuid: &str) { self.uuid = uuid.to_string(); } fn set_endpoint(&mut self, endpoint: &str) { self.endpoint = endpoint.to_string(); } fn ready_to_connect(&self) -> bool { - if self.state == CxsStateType::CxsStateNone || self.state == CxsStateType::CxsStateAccepted { + if self.state == VcxStateType::VcxStateNone || self.state == VcxStateType::VcxStateAccepted { false } else { true @@ -161,7 +161,7 @@ pub fn set_their_pw_did(handle: u32, did: &str) { }; } -pub fn set_state(handle: u32, state: CxsStateType) { +pub fn set_state(handle: u32, state: VcxStateType) { match CONNECTION_MAP.lock().unwrap().get_mut(&handle) { Some(cxn) => cxn.set_state(state), None => {} @@ -255,7 +255,7 @@ pub fn get_their_pw_verkey(handle: u32) -> Result { pub fn get_state(handle: u32) -> u32 { match CONNECTION_MAP.lock().unwrap().get(&handle) { Some(t) => t.get_state(), - None=> CxsStateType::CxsStateNone as u32, + None=> VcxStateType::VcxStateNone as u32, } } @@ -309,7 +309,7 @@ fn create_connection(source_id: String) -> u32 { pw_did: String::new(), pw_verkey: String::new(), did_endpoint: String::new(), - state: CxsStateType::CxsStateNone, + state: VcxStateType::VcxStateNone, uuid: String::new(), endpoint: String::new(), invite_detail: InviteDetail::new(), @@ -360,7 +360,7 @@ pub fn build_connection(source_id: String) -> Result { Ok(_) => info!("updated profile on agent"), }; - set_state(new_handle, CxsStateType::CxsStateInitialized); + set_state(new_handle, VcxStateType::VcxStateInitialized); Ok(new_handle) } @@ -417,7 +417,7 @@ pub fn update_state(handle: u32) -> Result { let details = parse_acceptance_details(handle, &i)?; set_their_pw_did(handle, &details.did); set_their_pw_verkey(handle, &details.verkey); - set_state(handle, CxsStateType::CxsStateAccepted); + set_state(handle, VcxStateType::VcxStateAccepted); } } Ok(error::SUCCESS.code_num) @@ -598,7 +598,7 @@ mod tests { assert!(handle > 0); assert!(!get_pw_did(handle).unwrap().is_empty()); assert!(!get_pw_verkey(handle).unwrap().is_empty()); - assert_eq!(get_state(handle), CxsStateType::CxsStateInitialized as u32); + assert_eq!(get_state(handle), VcxStateType::VcxStateInitialized as u32); connect(handle, Some("{}".to_string())).unwrap(); release(handle); } @@ -626,7 +626,7 @@ mod tests { #[test] fn test_get_state_fails() { let state = get_state(1); - assert_eq!(state, CxsStateType::CxsStateNone as u32); + assert_eq!(state, VcxStateType::VcxStateNone as u32); } #[test] @@ -657,7 +657,7 @@ mod tests { pw_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), pw_verkey: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), did_endpoint: String::new(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, uuid: String::new(), endpoint: String::new(), invite_detail: InviteDetail::new(), @@ -713,7 +713,7 @@ mod tests { settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true"); let handle = build_connection("test_serialize_deserialize".to_owned()).unwrap(); assert!(handle > 0); - assert_eq!(get_state(handle), CxsStateType::CxsStateInitialized as u32); + assert_eq!(get_state(handle), VcxStateType::VcxStateInitialized as u32); connect(handle,Some(String::new())).unwrap(); connect(handle, Some(String::new())).unwrap(); } @@ -749,7 +749,7 @@ mod tests { pw_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(), pw_verkey: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(), did_endpoint: String::new(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, uuid: String::new(), endpoint: String::new(), invite_detail: InviteDetail::new(), @@ -766,7 +766,7 @@ mod tests { #[ignore] #[test] - fn test_cxs_connection_create_real() { + fn test_vcx_connection_create_real() { ::utils::logger::LoggerUtils::init(); settings::set_defaults(); let agency_did = "FhrSrYtQcw3p9xwf7NYemf"; @@ -795,7 +795,7 @@ mod tests { let string = to_string(handle).unwrap(); println!("my connection: {}", string); - while get_state(handle) != CxsStateType::CxsStateAccepted as u32{ + while get_state(handle) != VcxStateType::VcxStateAccepted as u32{ thread::sleep(Duration::from_millis(1000)); update_state(handle).unwrap(); } diff --git a/cxs/libcxs/src/issuer_claim.rs b/vcx/libvcx/src/issuer_claim.rs similarity index 96% rename from cxs/libcxs/src/issuer_claim.rs rename to vcx/libvcx/src/issuer_claim.rs index ebc570dec6..d2db9cc9f7 100644 --- a/cxs/libcxs/src/issuer_claim.rs +++ b/vcx/libvcx/src/issuer_claim.rs @@ -5,7 +5,7 @@ extern crate libc; use std::sync::Mutex; use std::collections::HashMap; use rand::Rng; -use api::CxsStateType; +use api::VcxStateType; use utils::error; use messages; use settings; @@ -33,7 +33,7 @@ pub struct IssuerClaim { msg_uid: String, schema_seq_no: u32, issuer_did: String, - state: CxsStateType, + state: VcxStateType, pub claim_request: Option, claim_name: String, pub claim_id: String, @@ -70,7 +70,7 @@ impl IssuerClaim { fn send_claim_offer(&mut self, connection_handle: u32) -> Result { info!("sending claim offer for issuer_claim handle {} to connection handle {}", self.handle, connection_handle); - if self.state != CxsStateType::CxsStateInitialized { + if self.state != VcxStateType::VcxStateInitialized { warn!("claim {} has invalid state {} for sending claimOffer", self.handle, self.state as u32); return Err(error::NOT_READY.code_num); } @@ -113,7 +113,7 @@ impl IssuerClaim { }, Ok(response) => { self.msg_uid = get_offer_details(&response[0])?; - self.state = CxsStateType::CxsStateOfferSent; + self.state = VcxStateType::VcxStateOfferSent; info!("sent claim offer for: {}", self.handle); return Ok(error::SUCCESS.code_num); } @@ -123,7 +123,7 @@ impl IssuerClaim { fn send_claim(&mut self, connection_handle: u32) -> Result { info!("sending claim for issuer_claim handle {} to connection handle {}", self.handle, connection_handle); - if self.state != CxsStateType::CxsStateRequestReceived { + if self.state != VcxStateType::VcxStateRequestReceived { warn!("claim {} has invalid state {} for sending claim", self.handle, self.state as u32); return Err(error::NOT_READY.code_num); } @@ -172,7 +172,7 @@ impl IssuerClaim { }, Ok(response) => { self.msg_uid = get_offer_details(&response[0])?; - self.state = CxsStateType::CxsStateAccepted; + self.state = VcxStateType::VcxStateAccepted; info!("issued claim: {}", self.handle); return Ok(error::SUCCESS.code_num); } @@ -228,10 +228,10 @@ impl IssuerClaim { fn get_claim_offer_status(&mut self) -> Result { info!("updating state for claim offer: {}", self.handle); - if self.state == CxsStateType::CxsStateRequestReceived { + if self.state == VcxStateType::VcxStateRequestReceived { return Ok(error::SUCCESS.code_num); } - else if self.state != CxsStateType::CxsStateOfferSent || self.msg_uid.is_empty() || self.issued_did.is_empty() { + else if self.state != VcxStateType::VcxStateOfferSent || self.msg_uid.is_empty() || self.issued_did.is_empty() { return Ok(error::SUCCESS.code_num); } @@ -239,7 +239,7 @@ impl IssuerClaim { self.claim_request = Some(parse_claim_req_payload(&payload)?); info!("received claim request for claim offer: {}", self.handle); - self.state = CxsStateType::CxsStateRequestReceived; + self.state = VcxStateType::VcxStateRequestReceived; Ok(error::SUCCESS.code_num) } @@ -334,7 +334,7 @@ pub fn issuer_claim_create(schema_seq_no: u32, msg_uid: String::new(), claim_attributes: claim_data, issuer_did, - state: CxsStateType::CxsStateNone, + state: VcxStateType::VcxStateNone, schema_seq_no, claim_request: None, claim_name, @@ -350,7 +350,7 @@ pub fn issuer_claim_create(schema_seq_no: u32, new_issuer_claim.validate_claim_offer()?; - new_issuer_claim.state = CxsStateType::CxsStateInitialized; + new_issuer_claim.state = VcxStateType::VcxStateInitialized; info!("inserting handle {} into claim_issuer table", new_handle); ISSUER_CLAIM_MAP.lock().unwrap().insert(new_handle, new_issuer_claim); @@ -368,7 +368,7 @@ pub fn update_state(handle: u32) { pub fn get_state(handle: u32) -> u32 { match ISSUER_CLAIM_MAP.lock().unwrap().get(&handle) { Some(t) => t.get_state(), - None => CxsStateType::CxsStateNone as u32, + None => VcxStateType::VcxStateNone as u32, } } @@ -545,7 +545,7 @@ pub mod tests { issuer_did: "QTrbV4raAcND4DWWzBmdsh".to_owned(), issued_did: "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), issued_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, claim_name: DEFAULT_CLAIM_NAME.to_owned(), claim_request: Some(claim_req.to_owned()), claim_id: String::from(DEFAULT_CLAIM_ID), @@ -620,7 +620,7 @@ pub mod tests { "{\"attr\":\"value\"}".to_owned()).unwrap(); assert_eq!(send_claim_offer(handle, connection_handle).unwrap(), error::SUCCESS.code_num); - assert_eq!(get_state(handle), CxsStateType::CxsStateOfferSent as u32); + assert_eq!(get_state(handle), VcxStateType::VcxStateOfferSent as u32); assert_eq!(get_offer_uid(handle).unwrap(), "ntc2ytb"); } @@ -638,7 +638,7 @@ pub mod tests { let issuer_did = claim_req.issuer_did; let mut claim = create_standard_issuer_claim(); - claim.state = CxsStateType::CxsStateRequestReceived; + claim.state = VcxStateType::VcxStateRequestReceived; let connection_handle = build_connection("test_send_claim_offer".to_owned()).unwrap(); @@ -650,7 +650,7 @@ pub mod tests { }, }; assert_eq!(claim.msg_uid, "ntc2ytb"); - assert_eq!(claim.state, CxsStateType::CxsStateAccepted); + assert_eq!(claim.state, VcxStateType::VcxStateAccepted); } #[test] @@ -687,7 +687,7 @@ pub mod tests { issuer_did: "QTrbV4raAcND4DWWzBmdsh".to_owned(), issued_did: "8XFh8yBzrpJQmNyZzgoTqB".to_owned(), issued_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, claim_request: Some(claim_req.to_owned()), claim_name: DEFAULT_CLAIM_NAME.to_owned(), claim_id: String::from(DEFAULT_CLAIM_ID), @@ -702,7 +702,7 @@ pub mod tests { httpclient::set_next_u8_response(UPDATE_CLAIM_RESPONSE.to_vec()); claim.update_state(); - assert_eq!(claim.get_state(), CxsStateType::CxsStateRequestReceived as u32); + assert_eq!(claim.get_state(), VcxStateType::VcxStateRequestReceived as u32); let claim_request = claim.claim_request.clone().unwrap(); assert_eq!(claim_request.issuer_did, "2hoqvcwupRTUNkXn6ArYzs"); assert_eq!(claim_request.schema_seq_no, 15); @@ -842,7 +842,7 @@ pub mod tests { let issuer_did = claim_req.issuer_did; let mut claim = create_standard_issuer_claim(); - claim.state = CxsStateType::CxsStateRequestReceived; + claim.state = VcxStateType::VcxStateRequestReceived; let connection_handle = build_connection("test_send_claim_offer".to_owned()).unwrap(); @@ -853,7 +853,7 @@ pub mod tests { assert_eq!(x, 0) }, }; - assert_eq!(claim.state, CxsStateType::CxsStateAccepted); + assert_eq!(claim.state, VcxStateType::VcxStateAccepted); } diff --git a/cxs/libcxs/src/lib.rs b/vcx/libvcx/src/lib.rs similarity index 96% rename from cxs/libcxs/src/lib.rs rename to vcx/libvcx/src/lib.rs index 1d14a9c412..1b7abc2138 100644 --- a/cxs/libcxs/src/lib.rs +++ b/vcx/libvcx/src/lib.rs @@ -1,6 +1,6 @@ #![allow(unused_variables)] #![allow(dead_code)] -#![crate_name = "cxs"] +#![crate_name = "vcx"] extern crate serde; extern crate rand; extern crate reqwest; diff --git a/cxs/libcxs/src/messages/create_key.rs b/vcx/libvcx/src/messages/create_key.rs similarity index 100% rename from cxs/libcxs/src/messages/create_key.rs rename to vcx/libvcx/src/messages/create_key.rs diff --git a/cxs/libcxs/src/messages/get_message.rs b/vcx/libvcx/src/messages/get_message.rs similarity index 100% rename from cxs/libcxs/src/messages/get_message.rs rename to vcx/libvcx/src/messages/get_message.rs diff --git a/cxs/libcxs/src/messages/invite.rs b/vcx/libvcx/src/messages/invite.rs similarity index 100% rename from cxs/libcxs/src/messages/invite.rs rename to vcx/libvcx/src/messages/invite.rs diff --git a/cxs/libcxs/src/messages/mod.rs b/vcx/libvcx/src/messages/mod.rs similarity index 100% rename from cxs/libcxs/src/messages/mod.rs rename to vcx/libvcx/src/messages/mod.rs diff --git a/cxs/libcxs/src/messages/proofs/mod.rs b/vcx/libvcx/src/messages/proofs/mod.rs similarity index 100% rename from cxs/libcxs/src/messages/proofs/mod.rs rename to vcx/libvcx/src/messages/proofs/mod.rs diff --git a/cxs/libcxs/src/messages/proofs/proof_message.rs b/vcx/libvcx/src/messages/proofs/proof_message.rs similarity index 100% rename from cxs/libcxs/src/messages/proofs/proof_message.rs rename to vcx/libvcx/src/messages/proofs/proof_message.rs diff --git a/cxs/libcxs/src/messages/proofs/proof_request.rs b/vcx/libvcx/src/messages/proofs/proof_request.rs similarity index 100% rename from cxs/libcxs/src/messages/proofs/proof_request.rs rename to vcx/libvcx/src/messages/proofs/proof_request.rs diff --git a/cxs/libcxs/src/messages/register.rs b/vcx/libvcx/src/messages/register.rs similarity index 100% rename from cxs/libcxs/src/messages/register.rs rename to vcx/libvcx/src/messages/register.rs diff --git a/cxs/libcxs/src/messages/send_message.rs b/vcx/libvcx/src/messages/send_message.rs similarity index 100% rename from cxs/libcxs/src/messages/send_message.rs rename to vcx/libvcx/src/messages/send_message.rs diff --git a/cxs/libcxs/src/messages/update_profile.rs b/vcx/libvcx/src/messages/update_profile.rs similarity index 100% rename from cxs/libcxs/src/messages/update_profile.rs rename to vcx/libvcx/src/messages/update_profile.rs diff --git a/cxs/libcxs/src/messages/validation.rs b/vcx/libvcx/src/messages/validation.rs similarity index 100% rename from cxs/libcxs/src/messages/validation.rs rename to vcx/libvcx/src/messages/validation.rs diff --git a/cxs/libcxs/src/proof.rs b/vcx/libvcx/src/proof.rs similarity index 97% rename from cxs/libcxs/src/proof.rs rename to vcx/libvcx/src/proof.rs index 6d7f3772f9..ad44f7dcf0 100644 --- a/cxs/libcxs/src/proof.rs +++ b/vcx/libvcx/src/proof.rs @@ -7,7 +7,7 @@ use self::openssl::bn::{ BigNum, BigNumRef }; use settings; use connection; use rand::Rng; -use api::{ CxsStateType, ProofStateType }; +use api::{ VcxStateType, ProofStateType }; use std::sync::Mutex; use std::collections::HashMap; use messages::proofs::proof_message::{ProofMessage, ClaimData }; @@ -37,7 +37,7 @@ struct Proof { ref_msg_id: String, prover_did: String, prover_vk: String, - state: CxsStateType, + state: VcxStateType, proof_state: ProofStateType, name: String, version: String, @@ -172,7 +172,7 @@ impl Proof { } fn send_proof_request(&mut self, connection_handle: u32) -> Result { - if self.state != CxsStateType::CxsStateInitialized { + if self.state != VcxStateType::VcxStateInitialized { warn!("proof {} has invalid state {} for sending proofRequest", self.handle, self.state as u32); return Err(error::NOT_READY.code_num); } @@ -216,7 +216,7 @@ impl Proof { .send_secure() { Ok(response) => { self.msg_uid = get_proof_details(&response[0])?; - self.state = CxsStateType::CxsStateOfferSent; + self.state = VcxStateType::VcxStateOfferSent; return Ok(error::SUCCESS.code_num) }, Err(x) => { @@ -236,10 +236,10 @@ impl Proof { fn get_proof_request_status(&mut self) -> Result { info!("updating state for proof {}", self.handle); - if self.state == CxsStateType::CxsStateAccepted { + if self.state == VcxStateType::VcxStateAccepted { return Ok(error::SUCCESS.code_num); } - else if self.state != CxsStateType::CxsStateOfferSent || self.msg_uid.is_empty() || self.prover_did.is_empty() { + else if self.state != VcxStateType::VcxStateOfferSent || self.msg_uid.is_empty() || self.prover_did.is_empty() { return Ok(error::SUCCESS.code_num); } @@ -250,7 +250,7 @@ impl Proof { Ok(x) => Some(x), }; - self.state = CxsStateType::CxsStateAccepted; + self.state = VcxStateType::VcxStateAccepted; match self.proof_validation() { Ok(x) => { @@ -304,7 +304,7 @@ pub fn create_proof(source_id: Option, requested_predicates, prover_did: String::new(), prover_vk: String::new(), - state: CxsStateType::CxsStateNone, + state: VcxStateType::VcxStateNone, proof_state: ProofStateType::ProofUndefined, name, version: String::from("1.0"), @@ -319,7 +319,7 @@ pub fn create_proof(source_id: Option, new_proof.validate_proof_request()?; - new_proof.state = CxsStateType::CxsStateInitialized; + new_proof.state = VcxStateType::VcxStateInitialized; { let mut m = PROOF_MAP.lock().unwrap(); @@ -347,14 +347,14 @@ pub fn update_state(handle: u32) { pub fn get_state(handle: u32) -> u32 { match PROOF_MAP.lock().unwrap().get(&handle) { Some(t) => t.get_state(), - None => CxsStateType::CxsStateNone as u32, + None => VcxStateType::VcxStateNone as u32, } } pub fn get_proof_state(handle: u32) -> u32 { match PROOF_MAP.lock().unwrap().get(&handle) { Some(t) => t.get_proof_state(), - None => CxsStateType::CxsStateNone as u32, + None => VcxStateType::VcxStateNone as u32, } } @@ -567,7 +567,7 @@ mod tests { Err(_) => panic!("Proof creation failed"), }; assert_eq!(send_proof_request(handle, connection_handle).unwrap(), error::SUCCESS.code_num); - assert_eq!(get_state(handle), CxsStateType::CxsStateOfferSent as u32); + assert_eq!(get_state(handle), VcxStateType::VcxStateOfferSent as u32); assert_eq!(get_proof_uuid(handle).unwrap(), "ntc2ytb"); } @@ -635,7 +635,7 @@ mod tests { requested_predicates: String::from("[]"), prover_did: String::from("GxtnGN6ypZYgEqcftSQFnC"), prover_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, proof_state: ProofStateType::ProofUndefined, name: String::new(), version: String::from("1.0"), @@ -652,7 +652,7 @@ mod tests { httpclient::set_next_u8_response(UPDATE_PROOF_RESPONSE.to_vec()); proof.update_state(); - assert_eq!(proof.get_state(), CxsStateType::CxsStateAccepted as u32); + assert_eq!(proof.get_state(), VcxStateType::VcxStateAccepted as u32); } #[test] @@ -674,7 +674,7 @@ mod tests { requested_predicates: String::from("[]"), prover_did: String::from("GxtnGN6ypZYgEqcftSQFnC"), prover_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, proof_state: ProofStateType::ProofInvalid, name: String::new(), version: String::from("1.0"), @@ -692,7 +692,7 @@ mod tests { //httpclient::set_next_u8_response(GET_PROOF_OR_CLAIM_RESPONSE.to_vec()); proof.update_state(); - assert_eq!(proof.get_state(), CxsStateType::CxsStateAccepted as u32); + assert_eq!(proof.get_state(), VcxStateType::VcxStateAccepted as u32); assert_eq!(proof.get_proof_state(), ProofStateType::ProofInvalid as u32); assert_eq!(proof.prover_did, "GxtnGN6ypZYgEqcftSQFnC"); /* converting proof to a string produces non-deterministic results */ @@ -714,7 +714,7 @@ mod tests { requested_predicates: String::from("[]"), prover_did: String::from("GxtnGN6ypZYgEqcftSQFnC"), prover_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, proof_state: ProofStateType::ProofUndefined, name: String::new(), version: String::from("1.0"), @@ -777,7 +777,7 @@ mod tests { requested_predicates: String::from("[]"), prover_did: String::from("GxtnGN6ypZYgEqcftSQFnC"), prover_vk: VERKEY.to_string(), - state: CxsStateType::CxsStateOfferSent, + state: VcxStateType::VcxStateOfferSent, proof_state: ProofStateType::ProofUndefined, name: String::new(), version: String::from("1.0"), @@ -847,7 +847,7 @@ mod tests { // requested_predicates: String::from("[]"), // prover_did: String::from("GxtnGN6ypZYgEqcftSQFnC"), // prover_vk: VERKEY.to_string(), -// state: CxsStateType::CxsStateOfferSent, +// state: VcxStateType::VcxStateOfferSent, // proof_state: ProofStateType::ProofUndefined, // name: String::new(), // version: String::from("1.0"), diff --git a/cxs/libcxs/src/proof_compliance.rs b/vcx/libvcx/src/proof_compliance.rs similarity index 99% rename from cxs/libcxs/src/proof_compliance.rs rename to vcx/libvcx/src/proof_compliance.rs index 5da6c18bb3..bbe64e5498 100644 --- a/cxs/libcxs/src/proof_compliance.rs +++ b/vcx/libvcx/src/proof_compliance.rs @@ -7,7 +7,7 @@ pub fn proof_compliance(request: &ProofRequestData, proof: &ProofMessage) -> Res let proof_revealed_attrs = &proof.requested_proof.revealed_attrs; let proofs = &proof.proofs; let requested_attrs = &request.requested_attrs; - info!("starting cxs proof verification"); + info!("starting vcx proof verification"); for (key, val) in requested_attrs.iter() { let name = &val.name; let issuer_did = val.issuer_did.clone(); @@ -193,4 +193,4 @@ mod tests { proof_compliance(&proof_req, &proof_obj).unwrap(); } -} \ No newline at end of file +} diff --git a/cxs/libcxs/src/schema.rs b/vcx/libvcx/src/schema.rs similarity index 100% rename from cxs/libcxs/src/schema.rs rename to vcx/libvcx/src/schema.rs diff --git a/cxs/libcxs/src/settings.rs b/vcx/libvcx/src/settings.rs similarity index 99% rename from cxs/libcxs/src/settings.rs rename to vcx/libvcx/src/settings.rs index a5b04522bd..68ebe6e21c 100644 --- a/cxs/libcxs/src/settings.rs +++ b/vcx/libvcx/src/settings.rs @@ -113,7 +113,7 @@ fn validate_config() -> Result { if Path::new(setting.1).exists() { valid = true; } else { - error!("Genesis file pointed to by cxs config file does not exists"); + error!("Genesis file pointed to by vcx config file does not exists"); valid = false; } } else { diff --git a/cxs/libcxs/src/utils/callback.rs b/vcx/libvcx/src/utils/callback.rs similarity index 100% rename from cxs/libcxs/src/utils/callback.rs rename to vcx/libvcx/src/utils/callback.rs diff --git a/cxs/libcxs/src/utils/ccallback.rs b/vcx/libvcx/src/utils/ccallback.rs similarity index 100% rename from cxs/libcxs/src/utils/ccallback.rs rename to vcx/libvcx/src/utils/ccallback.rs diff --git a/cxs/libcxs/src/utils/constants.rs b/vcx/libvcx/src/utils/constants.rs similarity index 100% rename from cxs/libcxs/src/utils/constants.rs rename to vcx/libvcx/src/utils/constants.rs diff --git a/cxs/libcxs/src/utils/cstring.rs b/vcx/libvcx/src/utils/cstring.rs similarity index 100% rename from cxs/libcxs/src/utils/cstring.rs rename to vcx/libvcx/src/utils/cstring.rs diff --git a/cxs/libcxs/src/utils/error.rs b/vcx/libvcx/src/utils/error.rs similarity index 100% rename from cxs/libcxs/src/utils/error.rs rename to vcx/libvcx/src/utils/error.rs diff --git a/cxs/libcxs/src/utils/httpclient.rs b/vcx/libvcx/src/utils/httpclient.rs similarity index 100% rename from cxs/libcxs/src/utils/httpclient.rs rename to vcx/libvcx/src/utils/httpclient.rs diff --git a/cxs/libcxs/src/utils/json.rs b/vcx/libvcx/src/utils/json.rs similarity index 100% rename from cxs/libcxs/src/utils/json.rs rename to vcx/libvcx/src/utils/json.rs diff --git a/cxs/libcxs/src/utils/libindy/anoncreds.rs b/vcx/libvcx/src/utils/libindy/anoncreds.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/anoncreds.rs rename to vcx/libvcx/src/utils/libindy/anoncreds.rs diff --git a/cxs/libcxs/src/utils/libindy/call.rs b/vcx/libvcx/src/utils/libindy/call.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/call.rs rename to vcx/libvcx/src/utils/libindy/call.rs diff --git a/cxs/libcxs/src/utils/libindy/callback.rs b/vcx/libvcx/src/utils/libindy/callback.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/callback.rs rename to vcx/libvcx/src/utils/libindy/callback.rs diff --git a/cxs/libcxs/src/utils/libindy/crypto.rs b/vcx/libvcx/src/utils/libindy/crypto.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/crypto.rs rename to vcx/libvcx/src/utils/libindy/crypto.rs diff --git a/cxs/libcxs/src/utils/libindy/error_codes.rs b/vcx/libvcx/src/utils/libindy/error_codes.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/error_codes.rs rename to vcx/libvcx/src/utils/libindy/error_codes.rs diff --git a/cxs/libcxs/src/utils/libindy/ledger.rs b/vcx/libvcx/src/utils/libindy/ledger.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/ledger.rs rename to vcx/libvcx/src/utils/libindy/ledger.rs diff --git a/cxs/libcxs/src/utils/libindy/mod.rs b/vcx/libvcx/src/utils/libindy/mod.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/mod.rs rename to vcx/libvcx/src/utils/libindy/mod.rs diff --git a/cxs/libcxs/src/utils/libindy/pool.rs b/vcx/libvcx/src/utils/libindy/pool.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/pool.rs rename to vcx/libvcx/src/utils/libindy/pool.rs diff --git a/cxs/libcxs/src/utils/libindy/return_types.rs b/vcx/libvcx/src/utils/libindy/return_types.rs similarity index 99% rename from cxs/libcxs/src/utils/libindy/return_types.rs rename to vcx/libvcx/src/utils/libindy/return_types.rs index 7e2b8338e0..96cfb0fa78 100644 --- a/cxs/libcxs/src/utils/libindy/return_types.rs +++ b/vcx/libvcx/src/utils/libindy/return_types.rs @@ -16,7 +16,7 @@ use std::sync::Mutex; use std::ops::Deref; fn log_error(e: T) { - warn!("Unable to send through libindy callback in cxs: {}", e); + warn!("Unable to send through libindy callback in vcx: {}", e); } fn insert_closure(closure: T, map: &Mutex>) -> i32 { @@ -335,4 +335,4 @@ mod tests { assert!(val.is_err()); } -} \ No newline at end of file +} diff --git a/cxs/libcxs/src/utils/libindy/signus.rs b/vcx/libvcx/src/utils/libindy/signus.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/signus.rs rename to vcx/libvcx/src/utils/libindy/signus.rs diff --git a/cxs/libcxs/src/utils/libindy/wallet.rs b/vcx/libvcx/src/utils/libindy/wallet.rs similarity index 100% rename from cxs/libcxs/src/utils/libindy/wallet.rs rename to vcx/libvcx/src/utils/libindy/wallet.rs diff --git a/cxs/libcxs/src/utils/logger.rs b/vcx/libvcx/src/utils/logger.rs similarity index 100% rename from cxs/libcxs/src/utils/logger.rs rename to vcx/libvcx/src/utils/logger.rs diff --git a/cxs/libcxs/src/utils/mod.rs b/vcx/libvcx/src/utils/mod.rs similarity index 100% rename from cxs/libcxs/src/utils/mod.rs rename to vcx/libvcx/src/utils/mod.rs diff --git a/cxs/libcxs/src/utils/openssl.rs b/vcx/libvcx/src/utils/openssl.rs similarity index 100% rename from cxs/libcxs/src/utils/openssl.rs rename to vcx/libvcx/src/utils/openssl.rs diff --git a/cxs/libcxs/src/utils/timeout.rs b/vcx/libvcx/src/utils/timeout.rs similarity index 100% rename from cxs/libcxs/src/utils/timeout.rs rename to vcx/libvcx/src/utils/timeout.rs diff --git a/cxs/libcxs/src/utils/version_constants.rs b/vcx/libvcx/src/utils/version_constants.rs similarity index 100% rename from cxs/libcxs/src/utils/version_constants.rs rename to vcx/libvcx/src/utils/version_constants.rs diff --git a/cxs/libcxs/tests/claim_def_dep.rs b/vcx/libvcx/tests/claim_def_dep.rs similarity index 98% rename from cxs/libcxs/tests/claim_def_dep.rs rename to vcx/libvcx/tests/claim_def_dep.rs index c73abb3518..186e1da957 100644 --- a/cxs/libcxs/tests/claim_def_dep.rs +++ b/vcx/libvcx/tests/claim_def_dep.rs @@ -3,14 +3,14 @@ mod tests { extern crate rusqlcipher; - extern crate cxs; + extern crate vcx; - use self::cxs::utils::constants::{DEMO_ISSUER_PW_SEED, DEMO_AGENT_PW_SEED}; - use self::cxs::utils::libindy::signus::SignusUtils; - use self::cxs::schema::{create_new_schema, get_sequence_num}; - use self::cxs::claim_def::create_new_claimdef; - use self::cxs::utils::libindy::wallet; - use self::cxs::utils::libindy::pool; + use self::vcx::utils::constants::{DEMO_ISSUER_PW_SEED, DEMO_AGENT_PW_SEED}; + use self::vcx::utils::libindy::signus::SignusUtils; + use self::vcx::schema::{create_new_schema, get_sequence_num}; + use self::vcx::claim_def::create_new_claimdef; + use self::vcx::utils::libindy::wallet; + use self::vcx::utils::libindy::pool; static STAGING_ENTRIES: &[[&str;3];14] = &[ [ @@ -432,8 +432,8 @@ mod tests { #[test] fn test_creating_claim_def_dependencies() { let wallet_name = "my_real_wallet"; - self::cxs::utils::logger::LoggerUtils::init(); - self::cxs::settings::set_defaults(); + self::vcx::utils::logger::LoggerUtils::init(); + self::vcx::settings::set_defaults(); pool::open_sandbox_pool(); @@ -464,8 +464,8 @@ mod tests { use self::rusqlcipher::Connection; use std::env::home_dir; - self::cxs::utils::logger::LoggerUtils::init(); - self::cxs::settings::set_defaults(); + self::vcx::utils::logger::LoggerUtils::init(); + self::vcx::settings::set_defaults(); let wallet_key = String::from(""); let home = home_dir().unwrap(); let wallet_name = "my_real_wallet"; @@ -474,10 +474,10 @@ mod tests { let wallet_db = home.join(wallet_dir); if wallet_key.len() > 0 { - self::cxs::settings::set_config_value(self::cxs::settings::CONFIG_WALLET_KEY, &wallet_key); + self::vcx::settings::set_config_value(self::vcx::settings::CONFIG_WALLET_KEY, &wallet_key); } - self::cxs::utils::libindy::wallet::init_wallet(wallet_name).unwrap(); + self::vcx::utils::libindy::wallet::init_wallet(wallet_name).unwrap(); let connection = Connection::open(wallet_db.as_path()).unwrap(); @@ -489,4 +489,4 @@ mod tests { connection.execute("INSERT OR REPLACE INTO wallet VALUES (?,?,?)", &[&entry[0].to_string(), &entry[1].to_string(), &entry[2].to_string()]).unwrap(); } } -} \ No newline at end of file +} diff --git a/cxs/libcxs/tests/demo.rs b/vcx/libvcx/tests/demo.rs similarity index 88% rename from cxs/libcxs/tests/demo.rs rename to vcx/libvcx/tests/demo.rs index 90d8c8a7cb..19f80a0278 100644 --- a/cxs/libcxs/tests/demo.rs +++ b/vcx/libvcx/tests/demo.rs @@ -1,4 +1,4 @@ -extern crate cxs; +extern crate vcx; extern crate tempfile; extern crate libc; extern crate rand; @@ -16,9 +16,9 @@ use std::io::Write; use std::thread; use std::time::Duration; use std::ffi::CString; -use cxs::api; +use vcx::api; use std::sync::mpsc::channel; -use cxs::utils::libindy::pool::open_sandbox_pool; +use vcx::utils::libindy::pool::open_sandbox_pool; static CLAIM_DATA: &str = r#"{"address1": ["123 Main St"], "address2": ["Suite 3"], "city": ["Draper"], "state": ["UT"], "zip": ["84000"]}"#; static CLAIM_DEF_ISSUER_DID: &str = "2hoqvcwupRTUNkXn6ArYzs"; @@ -35,9 +35,9 @@ fn test_demo(){ } fn demo(){ - let serialize_connection_fn = api::connection::cxs_connection_serialize; - let serialize_claim_fn = api::issuer_claim::cxs_issuer_claim_serialize; - let invite_details = api::connection::cxs_connection_invite_details; + let serialize_connection_fn = api::connection::vcx_connection_serialize; + let serialize_claim_fn = api::issuer_claim::vcx_issuer_claim_serialize; + let invite_details = api::connection::vcx_connection_invite_details; let random_int: u32 = rand::random(); let logo_url = format!("https://robohash.org/{}?set=set3", random_int); @@ -52,7 +52,7 @@ fn demo(){ "agent_pairwise_verkey": "FqBMwDobDQNjHCMyVBJG8hUY4Fq5XcgqqRdj89dTBZwL", "agency_pairwise_did": "2opd29fJoE7UJwtVn6QDhd", "wallet_name": "my_real_wallet", - "genesis_path":self::cxs::utils::constants::GENESIS_PATH, + "genesis_path":self::vcx::utils::constants::GENESIS_PATH, "logo_url":logo_url, "agent_pairwise_did": "UDDEoTTzUG7vmcEq6meesq", "enterprise_did": "5bJqPo8aCWyBwLQosZkJcB", @@ -68,7 +68,7 @@ fn demo(){ "agent_endpoint": "https://agency-ea-sandbox.evernym.com", "agent_pairwise_verkey": "En9myzhuLRqLAw6zPwVFaSmiNtVwZDDYazvuBLHD6Hin", "agency_pairwise_did": "LyDVoajwQ6skcGSf6DKay9", - "genesis_path":self::cxs::utils::constants::GENESIS_PATH, + "genesis_path":self::vcx::utils::constants::GENESIS_PATH, "logo_url":logo_url, "wallet_name":"my_real_wallet", "agent_pairwise_did": "SHEzUMX56jxo9BPU8Rsmnc", @@ -92,7 +92,7 @@ fn demo(){ "agency_pairwise_did": "7o2xT9Qtp83cJUJMUBTF3M", "enterprise_verkey": "vrWGArMA3toVoZrYGSAMjR2i9KjBS66bZWyWuYJJYPf", "agent_pairwise_verkey": "Chj1oQYdmbTXKG96Fpo8C2sd6fRrt9UyCrbmuo4vzroK", - "genesis_path":self::cxs::utils::constants::GENESIS_PATH + "genesis_path":self::vcx::utils::constants::GENESIS_PATH }).to_string(); let mut file = NamedTempFileOptions::new() @@ -103,10 +103,10 @@ fn demo(){ file.write_all(config_string.as_bytes()).unwrap(); open_sandbox_pool(); - self::cxs::utils::libindy::pool::close().unwrap(); + self::vcx::utils::libindy::pool::close().unwrap(); let path = CString::new(file.path().to_str().unwrap()).unwrap(); - let r = api::cxs::cxs_init(0,path.as_ptr(),Some(generic_cb)); + let r = api::vcx::vcx_init(0,path.as_ptr(),Some(generic_cb)); assert_eq!(r,0); thread::sleep(Duration::from_secs(1)); @@ -167,8 +167,8 @@ fn demo(){ #[allow(unused_variables)] let claim_data = CString::new("{\"claim\":\"attributes\"}").unwrap(); // let issuer_did_cstring = CString::new(issuer_did).unwrap(); - let rc = api::connection::cxs_connection_create( - command_handle,CString::new("test_cxs_connection_connect").unwrap().into_raw(),create_connection_cb); + let rc = api::connection::vcx_connection_create( + command_handle,CString::new("test_vcx_connection_connect").unwrap().into_raw(),create_connection_cb); assert_eq!(rc,0); let (err, connection_handle) = receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap(); println!("Connection Handle: {}", connection_handle); @@ -180,7 +180,7 @@ fn demo(){ let phone_number = "2053863441"; let connection_opt = json!({"phone":phone_number}); // let connection_opt = String::from(""); - let rc = api::connection::cxs_connection_connect(command_handle, + let rc = api::connection::vcx_connection_connect(command_handle, connection_handle, CString::new(connection_opt.to_string()).unwrap().into_raw(),cb); assert_eq!(rc, 0); @@ -188,19 +188,19 @@ fn demo(){ assert_eq!(err,0); // serialize connection to see the connection invite ****************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); - let err = invite_details_cxs_object(connection_handle, invite_details); + let err = invite_details_vcx_object(connection_handle, invite_details); assert_eq!(err,0); // Update State, wait for connection ********************************************* - let connection_state = wait_for_updated_state(connection_handle, 4, api::connection::cxs_connection_update_state); + let connection_state = wait_for_updated_state(connection_handle, 4, api::connection::vcx_connection_update_state); assert_eq!(connection_state, 4); // update claim ******************************************************************* let target_claim_state = 1; - let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); @@ -212,11 +212,11 @@ fn demo(){ assert_eq!(err,0); // Serialize again **************************************************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); // Serialize claim **************************************************************** - let err = serialize_cxs_object(claim_handle, serialize_claim_fn); + let err = serialize_vcx_object(claim_handle, serialize_claim_fn); assert_eq!(err,0); receive_request_send_claim(connection_handle,claim_handle); @@ -228,7 +228,7 @@ fn receive_request_send_claim(connection_handle: u32, claim_handle:u32){ // update claim ******************************************************************* let target_claim_state = 3; - let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); @@ -239,7 +239,7 @@ fn receive_request_send_claim(connection_handle: u32, claim_handle:u32){ fn send_proof_request_and_receive_proof(connection_handle: u32, proof_handle:u32){ let target_proof_state = 1; - let state = wait_for_updated_state(proof_handle, target_proof_state, api::proof::cxs_proof_update_state); + let state = wait_for_updated_state(proof_handle, target_proof_state, api::proof::vcx_proof_update_state); assert_eq!(target_proof_state, state); let target_state = 4; @@ -247,7 +247,7 @@ fn send_proof_request_and_receive_proof(connection_handle: u32, proof_handle:u32 let err = utils::demo::send_proof_request(proof_handle, connection_handle); assert_eq!(err, 0); - let state = wait_for_updated_state(proof_handle, target_state, api::proof::cxs_proof_update_state); + let state = wait_for_updated_state(proof_handle, target_state, api::proof::vcx_proof_update_state); assert_eq!(state, target_state); diff --git a/cxs/libcxs/tests/demo_with_composite.rs b/vcx/libvcx/tests/demo_with_composite.rs similarity index 89% rename from cxs/libcxs/tests/demo_with_composite.rs rename to vcx/libvcx/tests/demo_with_composite.rs index beea79334f..6b12c65bd6 100644 --- a/cxs/libcxs/tests/demo_with_composite.rs +++ b/vcx/libvcx/tests/demo_with_composite.rs @@ -1,4 +1,4 @@ -extern crate cxs; +extern crate vcx; extern crate tempfile; extern crate libc; extern crate rand; @@ -16,12 +16,12 @@ use std::io::Write; use std::thread; use std::time::Duration; use std::ffi::CString; -use cxs::api; -use cxs::utils::libindy::pool; +use vcx::api; +use vcx::utils::libindy::pool; use std::sync::mpsc::channel; #[allow(dead_code)] -static SERIALIZED_CONNECTION: &str = r#"{"source_id":"test_cxs_connection_connect","handle":2608616713,"pw_did":"62LeFLkN9ZeCr32j73PUyD","pw_verkey":"3jnnnL65mTW786LaTJSwEKENEMwmMowuJTYmVho23qNU","did_endpoint":"","state":4,"uuid":"","endpoint":"","invite_detail":{"e":"34.210.228.152:80","rid":"6oHwpBN","sakdp":"key","sn":"enterprise","sD":"62LeFLkN9ZeCr32j73PUyD","lu":"https://s19.postimg.org/ykyz4x8jn/evernym.png","sVk":"3jnnnL65mTW786LaTJSwEKENEMwmMowuJTYmVho23qNU","tn":"there"}}"#; +static SERIALIZED_CONNECTION: &str = r#"{"source_id":"test_vcx_connection_connect","handle":2608616713,"pw_did":"62LeFLkN9ZeCr32j73PUyD","pw_verkey":"3jnnnL65mTW786LaTJSwEKENEMwmMowuJTYmVho23qNU","did_endpoint":"","state":4,"uuid":"","endpoint":"","invite_detail":{"e":"34.210.228.152:80","rid":"6oHwpBN","sakdp":"key","sn":"enterprise","sD":"62LeFLkN9ZeCr32j73PUyD","lu":"https://s19.postimg.org/ykyz4x8jn/evernym.png","sVk":"3jnnnL65mTW786LaTJSwEKENEMwmMowuJTYmVho23qNU","tn":"there"}}"#; #[allow(dead_code)] static SERIALIZED_CLAIM: &str = r#"{"source_id":"Claim For Driver's License","handle":3664805180,"claim_attributes":"{\"age\":[\"28\",\"28\"],\"height\":[\"175\",\"175\"],\"name\":[\"Alex\",\"1139481716457488690172217916278103335\"],\"sex\":[\"male\",\"5944657099558967239210949258394887428692050081607692519917050011144233115103\"]}","msg_uid":"7TKyPLr","schema_seq_no":12,"issuer_did":"Niaxv2v4mPr1HdTeJkQxuU","issued_did":"62LeFLkN9ZeCr32j73PUyD","state":2,"claim_request":null}"#; static CLAIM_DATA1: &str = r#"{"address1": ["Claim1 address1"], "address2": ["Claim1 address2"], "city": ["Claim1 New York"], "state": ["New York"], "zip": ["888888"]}"#; @@ -51,9 +51,9 @@ fn test_demo_full(){ } fn demo_full(){ - let serialize_connection_fn = api::connection::cxs_connection_serialize; - let serialize_claim_fn = api::issuer_claim::cxs_issuer_claim_serialize; - let invite_details = api::connection::cxs_connection_invite_details; + let serialize_connection_fn = api::connection::vcx_connection_serialize; + let serialize_claim_fn = api::issuer_claim::vcx_issuer_claim_serialize; + let invite_details = api::connection::vcx_connection_invite_details; let random_int: u32 = rand::random(); let logo_url = format!("https://robohash.org/{}?set=set3", random_int); @@ -72,7 +72,7 @@ fn demo_full(){ "agency_pairwise_did": "7o2xT9Qtp83cJUJMUBTF3M", "enterprise_verkey": "vrWGArMA3toVoZrYGSAMjR2i9KjBS66bZWyWuYJJYPf", "agent_pairwise_verkey": "Chj1oQYdmbTXKG96Fpo8C2sd6fRrt9UyCrbmuo4vzroK", - "genesis_path":self::cxs::utils::constants::GENESIS_PATH + "genesis_path":self::vcx::utils::constants::GENESIS_PATH }).to_string(); let mut file = NamedTempFileOptions::new() @@ -83,10 +83,10 @@ fn demo_full(){ file.write_all(config_string.as_bytes()).unwrap(); pool::open_sandbox_pool(); - self::cxs::utils::libindy::pool::close().unwrap(); + self::vcx::utils::libindy::pool::close().unwrap(); let path = CString::new(file.path().to_str().unwrap()).unwrap(); - let r = api::cxs::cxs_init(0,path.as_ptr(),Some(generic_cb)); + let r = api::vcx::vcx_init(0,path.as_ptr(),Some(generic_cb)); assert_eq!(r,0); thread::sleep(Duration::from_secs(1)); @@ -233,8 +233,8 @@ fn demo_full(){ #[allow(unused_variables)] let claim_data = CString::new("{\"claim\":\"attributes\"}").unwrap(); // let issuer_did_cstring = CString::new(issuer_did).unwrap(); - let rc = api::connection::cxs_connection_create( - command_handle,CString::new("test_cxs_connection_connect").unwrap().into_raw(),create_connection_cb); + let rc = api::connection::vcx_connection_create( + command_handle,CString::new("test_vcx_connection_connect").unwrap().into_raw(),create_connection_cb); assert_eq!(rc,0); let (err, connection_handle) = receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap(); println!("Connection Handle: {}", connection_handle); @@ -250,7 +250,7 @@ fn demo_full(){ // let phone_number = "2182578533"; let connection_opt = json!({"phone":phone_number}); //let connection_opt = String::from(""); - let rc = api::connection::cxs_connection_connect(command_handle, + let rc = api::connection::vcx_connection_connect(command_handle, connection_handle, CString::new(connection_opt.to_string()).unwrap().into_raw(),cb); assert_eq!(rc, 0); @@ -258,19 +258,19 @@ fn demo_full(){ assert_eq!(err,0); // serialize connection to see the connection invite ****************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); - let err = invite_details_cxs_object(connection_handle, invite_details); + let err = invite_details_vcx_object(connection_handle, invite_details); assert_eq!(err,0); // Update State, wait for connection ********************************************* - let connection_state = wait_for_updated_state(connection_handle, 4, api::connection::cxs_connection_update_state); + let connection_state = wait_for_updated_state(connection_handle, 4, api::connection::vcx_connection_update_state); assert_eq!(connection_state, 4); // update claim1 ******************************************************************* let target_claim_state = 1; - let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); // Send Claim Offer1 *************************************************************** @@ -280,11 +280,11 @@ fn demo_full(){ assert_eq!(err,0); // Serialize again **************************************************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); // Serialize claim **************************************************************** - let err = serialize_cxs_object(claim_handle, serialize_claim_fn); + let err = serialize_vcx_object(claim_handle, serialize_claim_fn); assert_eq!(err,0); receive_request_send_claim(connection_handle,claim_handle); @@ -294,7 +294,7 @@ fn demo_full(){ // update claim2 ******************************************************************* let target_claim_state = 1; - let claim_state = wait_for_updated_state(claim_handle2, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle2, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); // Send Claim Offer2 *************************************************************** @@ -304,11 +304,11 @@ fn demo_full(){ assert_eq!(err,0); // Serialize again **************************************************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); // Serialize claim **************************************************************** - let err = serialize_cxs_object(claim_handle2, serialize_claim_fn); + let err = serialize_vcx_object(claim_handle2, serialize_claim_fn); assert_eq!(err,0); receive_request_send_claim(connection_handle,claim_handle2); // std::thread::sleep(Duration::from_millis(3)); @@ -317,7 +317,7 @@ fn demo_full(){ // update claim3 ******************************************************************* let target_claim_state = 1; - let claim_state = wait_for_updated_state(claim_handle3, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle3, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); // Send Claim Offer3 *************************************************************** @@ -327,11 +327,11 @@ fn demo_full(){ assert_eq!(err,0); // Serialize again **************************************************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); // Serialize claim **************************************************************** - let err = serialize_cxs_object(claim_handle3, serialize_claim_fn); + let err = serialize_vcx_object(claim_handle3, serialize_claim_fn); assert_eq!(err,0); receive_request_send_claim(connection_handle,claim_handle3); std::thread::sleep(Duration::from_millis(3)); @@ -340,7 +340,7 @@ fn demo_full(){ // update claim4 ******************************************************************* let target_claim_state = 1; - let claim_state = wait_for_updated_state(claim_handle4, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle4, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); // Send Claim Offer4 *************************************************************** @@ -350,11 +350,11 @@ fn demo_full(){ assert_eq!(err,0); // Serialize again **************************************************************** - let err = serialize_cxs_object(connection_handle, serialize_connection_fn); + let err = serialize_vcx_object(connection_handle, serialize_connection_fn); assert_eq!(err,0); // Serialize claim **************************************************************** - let err = serialize_cxs_object(claim_handle4, serialize_claim_fn); + let err = serialize_vcx_object(claim_handle4, serialize_claim_fn); assert_eq!(err,0); receive_request_send_claim(connection_handle,claim_handle4); @@ -363,7 +363,7 @@ fn demo_full(){ // **** Do only when creating new schema and claimdef // update claim5 ******************************************************************* // let target_claim_state = 1; -// let claim_state = wait_for_updated_state(claim_handle5, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); +// let claim_state = wait_for_updated_state(claim_handle5, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); // assert_eq!(claim_state, target_claim_state); // // // Send Claim Offer5 *************************************************************** @@ -373,11 +373,11 @@ fn demo_full(){ // assert_eq!(err,0); // // // Serialize again **************************************************************** -// let err = serialize_cxs_object(connection_handle, serialize_connection_fn); +// let err = serialize_vcx_object(connection_handle, serialize_connection_fn); // assert_eq!(err,0); // // // Serialize claim **************************************************************** -// let err = serialize_cxs_object(claim_handle5, serialize_claim_fn); +// let err = serialize_vcx_object(claim_handle5, serialize_claim_fn); // assert_eq!(err,0); // // receive_request_send_claim(connection_handle,claim_handle5); @@ -391,7 +391,7 @@ fn receive_request_send_claim(connection_handle: u32, claim_handle:u32){ // update claim ******************************************************************* let target_claim_state = 3; - let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::cxs_issuer_claim_update_state); + let claim_state = wait_for_updated_state(claim_handle, target_claim_state, api::issuer_claim::vcx_issuer_claim_update_state); assert_eq!(claim_state, target_claim_state); @@ -402,7 +402,7 @@ fn receive_request_send_claim(connection_handle: u32, claim_handle:u32){ fn send_proof_request_and_receive_proof(connection_handle: u32, proof_handle:u32){ let target_proof_state = 1; - let state = wait_for_updated_state(proof_handle, target_proof_state, api::proof::cxs_proof_update_state); + let state = wait_for_updated_state(proof_handle, target_proof_state, api::proof::vcx_proof_update_state); assert_eq!(target_proof_state, state); let target_state = 4; @@ -410,7 +410,7 @@ fn send_proof_request_and_receive_proof(connection_handle: u32, proof_handle:u32 let err = utils::demo::send_proof_request(proof_handle, connection_handle); assert_eq!(err, 0); - let state = wait_for_updated_state(proof_handle, target_state, api::proof::cxs_proof_update_state); + let state = wait_for_updated_state(proof_handle, target_state, api::proof::vcx_proof_update_state); assert_eq!(state, target_state); @@ -460,16 +460,16 @@ fn init_sdk(){ file.write_all(config_string.as_bytes()).unwrap(); let path = CString::new(file.path().to_str().unwrap()).unwrap(); - let r = api::cxs::cxs_init(0,path.as_ptr(),Some(generic_cb)); + let r = api::vcx::vcx_init(0,path.as_ptr(),Some(generic_cb)); assert_eq!(r,0); thread::sleep(Duration::from_secs(1)); // deserialize connection ********************************************************* let serialized_connection = SERIALIZED_CONNECTION; - let connection_handle = deserialize_cxs_object(serialized_connection, api::connection::cxs_connection_deserialize); + let connection_handle = deserialize_vcx_object(serialized_connection, api::connection::vcx_connection_deserialize); assert!(connection_handle>0); // deserialize claim ************************************************************** - let claim_handle = deserialize_cxs_object(SERIALIZED_CLAIM, api::issuer_claim::cxs_issuer_claim_deserialize); + let claim_handle = deserialize_vcx_object(SERIALIZED_CLAIM, api::issuer_claim::vcx_issuer_claim_deserialize); assert!(claim_handle>0); } diff --git a/cxs/libcxs/tests/libcxs.rs b/vcx/libvcx/tests/libvcx.rs similarity index 78% rename from cxs/libcxs/tests/libcxs.rs rename to vcx/libvcx/tests/libvcx.rs index 1931e9dc1e..d5198f8f0b 100644 --- a/cxs/libcxs/tests/libcxs.rs +++ b/vcx/libvcx/tests/libvcx.rs @@ -1,4 +1,4 @@ -extern crate cxs; +extern crate vcx; #[cfg(test)] mod tests { diff --git a/cxs/libcxs/tests/utils/claim_def_wallet.rs b/vcx/libvcx/tests/utils/claim_def_wallet.rs similarity index 100% rename from cxs/libcxs/tests/utils/claim_def_wallet.rs rename to vcx/libvcx/tests/utils/claim_def_wallet.rs diff --git a/cxs/libcxs/tests/utils/cstring.rs b/vcx/libvcx/tests/utils/cstring.rs similarity index 100% rename from cxs/libcxs/tests/utils/cstring.rs rename to vcx/libvcx/tests/utils/cstring.rs diff --git a/cxs/libcxs/tests/utils/demo.rs b/vcx/libvcx/tests/utils/demo.rs similarity index 95% rename from cxs/libcxs/tests/utils/demo.rs rename to vcx/libvcx/tests/utils/demo.rs index a6aaad0bc9..3b5cc10e59 100644 --- a/cxs/libcxs/tests/utils/demo.rs +++ b/vcx/libvcx/tests/utils/demo.rs @@ -1,4 +1,4 @@ -extern crate cxs; +extern crate vcx; extern crate tempfile; extern crate libc; extern crate serde_json; @@ -12,7 +12,7 @@ use self::libc::c_char; use std::thread; use std::time::Duration; use std::ffi::CString; -use cxs::api; +use vcx::api; use std::sync::Mutex; use std::sync::mpsc::channel; @@ -40,7 +40,7 @@ pub fn create_claim_offer(claim_name: &str, source_id: &str, claim_data_value: s #[allow(unused_variables)] let issuer_did_cstring = CString::new(issuer_did).unwrap(); let claim_name_cstring = CString::new(claim_name).unwrap(); - let rc = api::issuer_claim::cxs_issuer_create_claim(command_handle, + let rc = api::issuer_claim::vcx_issuer_create_claim(command_handle, source_id_cstring.as_ptr(), schema_seq_no, ptr::null(), @@ -56,7 +56,7 @@ pub fn send_claim_offer(claim_handle: u32, connection_handle: u32) -> u32 { let (sender, receiver) = channel(); let cb = Box::new(move|err|{sender.send(err).unwrap();}); let (command_handle, cb) = closure_to_send_claim_object(cb); - let rc = api::issuer_claim::cxs_issuer_send_claim_offer(command_handle, + let rc = api::issuer_claim::vcx_issuer_send_claim_offer(command_handle, claim_handle, connection_handle, cb); @@ -69,13 +69,13 @@ pub fn send_claim(claim_handle: u32, connection_handle: u32) -> u32 { let (sender, receiver) = channel(); let cb = Box::new(move|err|{sender.send(err).unwrap();}); let (command_handle, cb) = closure_to_send_claim_object(cb); - let rc = api::issuer_claim::cxs_issuer_send_claim(command_handle, claim_handle, connection_handle, cb); + let rc = api::issuer_claim::vcx_issuer_send_claim(command_handle, claim_handle, connection_handle, cb); assert_eq!(rc,0); receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap() } #[allow(dead_code)] -pub fn deserialize_cxs_object(serialized_connection: &str,f:extern fn(u32, *const c_char, Option) ->u32 ) -> u32{ +pub fn deserialize_vcx_object(serialized_connection: &str,f:extern fn(u32, *const c_char, Option) ->u32 ) -> u32{ fn closure_to_deserialize_connection(closure: Box) -> (u32, Option ) ->u32) -> u32{ +pub fn serialize_vcx_object(connection_handle: u32, f:extern fn(u32, u32, Option ) ->u32) -> u32{ fn closure_to_serialize_connection(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_SERIALIZE_CONNECTION: Mutex) -> u32) -> u32 { - fn closure_to_cxs_connection(closure: Box) -> +pub fn invite_details_vcx_object(connection_handle: u32, f:extern fn(u32, u32, bool, Option) -> u32) -> u32 { + fn closure_to_vcx_connection(closure: Box) -> (u32, Option) { lazy_static! { static ref CALLBACKS_SERIALIZE_CONNECTION: Mutex>> = Default::default(); } @@ -172,7 +172,7 @@ pub fn invite_details_cxs_object(connection_handle: u32, f:extern fn(u32, u32, b } let (sender, receiver) = channel(); let cb = Box::new(move |err|{sender.send(err).unwrap();}); - let (command_handle, cb) = closure_to_cxs_connection(cb); + let (command_handle, cb) = closure_to_vcx_connection(cb); let rc = f(command_handle, connection_handle, true, @@ -326,7 +326,7 @@ pub fn send_proof_request(proof_handle: u32, connection_handle: u32) -> u32 { let (sender, receiver) = channel(); let cb = Box::new(move|err|{sender.send(err).unwrap();}); let (command_handle, cb) = closure_to_send_claim_object(cb); - let rc = api::proof::cxs_proof_send_request(command_handle, proof_handle, connection_handle, cb); + let rc = api::proof::vcx_proof_send_request(command_handle, proof_handle, connection_handle, cb); assert_eq!(rc,0); receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap() @@ -340,7 +340,7 @@ pub fn create_proof_request(source_id: &str, requested_attrs: &str) -> (u32, u32 let (command_handle, cb) = closure_to_create_claim(cb); let predicates_cstring = CString::new("[]").unwrap(); let proof_name_cstring = CString::new("proof name").unwrap(); - let rc = api::proof::cxs_proof_create(command_handle, + let rc = api::proof::vcx_proof_create(command_handle, source_id_cstring.as_ptr(), requested_attrs.as_ptr(), predicates_cstring.as_ptr(), @@ -381,7 +381,7 @@ pub fn get_proof(proof_handle: u32, connection_handle: u32) -> u32 { let (sender, receiver) = channel(); let cb = Box::new(move |err|{sender.send(err).unwrap();}); let (command_handle, cb) = closure_to_get_proof(cb); - let rc = api::proof::cxs_get_proof(command_handle, + let rc = api::proof::vcx_get_proof(command_handle, proof_handle, connection_handle, cb); @@ -398,7 +398,7 @@ pub fn create_claimdef(source_id: &str, claimdef_name: &str, schema_seq_no: u32) let cb = Box::new(move|err, claimdef_handle|{sender.send((err, claimdef_handle)).unwrap();}); let (command_handle, cb) = closure_to_create_claimdef(cb); let claimdef_name_cstring = CString::new(claimdef_name).unwrap(); - let rc = api::claim_def::cxs_claimdef_create(command_handle, + let rc = api::claim_def::vcx_claimdef_create(command_handle, source_id_cstring.as_ptr(), claimdef_name_cstring.as_ptr(), schema_seq_no, @@ -417,13 +417,13 @@ pub fn create_schema(source_id: &str, schema_name: &str, schema_data: &str) -> ( let (command_handle, cb) = closure_to_create_claimdef(cb); let schema_name_cstring = CString::new(schema_name).unwrap(); let schema_data_cstring = CString::new(schema_data).unwrap(); - let rc = api::schema::cxs_schema_create(command_handle, + let rc = api::schema::vcx_schema_create(command_handle, source_id_cstring.as_ptr(), schema_name_cstring.as_ptr(), schema_data_cstring.as_ptr(), cb); assert_eq!(rc, 0); let (rc, handle) = receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap(); - let schema_no = ::cxs::schema::get_sequence_num(handle).unwrap(); + let schema_no = ::vcx::schema::get_sequence_num(handle).unwrap(); (rc, handle, schema_no) -} \ No newline at end of file +} diff --git a/cxs/libcxs/tests/utils/mod.rs b/vcx/libvcx/tests/utils/mod.rs similarity index 100% rename from cxs/libcxs/tests/utils/mod.rs rename to vcx/libvcx/tests/utils/mod.rs diff --git a/cxs/libcxs/tests/utils/timeout.rs b/vcx/libvcx/tests/utils/timeout.rs similarity index 100% rename from cxs/libcxs/tests/utils/timeout.rs rename to vcx/libvcx/tests/utils/timeout.rs diff --git a/cxs/wrappers/node/.gitignore b/vcx/wrappers/node/.gitignore similarity index 100% rename from cxs/wrappers/node/.gitignore rename to vcx/wrappers/node/.gitignore diff --git a/cxs/wrappers/node/.npmignore b/vcx/wrappers/node/.npmignore similarity index 100% rename from cxs/wrappers/node/.npmignore rename to vcx/wrappers/node/.npmignore diff --git a/cxs/wrappers/node/README.md b/vcx/wrappers/node/README.md similarity index 70% rename from cxs/wrappers/node/README.md rename to vcx/wrappers/node/README.md index 9c7bfb6af9..40af429c16 100644 --- a/cxs/wrappers/node/README.md +++ b/vcx/wrappers/node/README.md @@ -1,4 +1,4 @@ -# CXS NodeJS Wrapper +# VCX NodeJS Wrapper ## Contribution Guide @@ -10,8 +10,8 @@ Make sure you have these packages installed: Also this has a dependency on: -* libcxs debian -Because it creates a symlink (/usr/lib/libcxs.so) +* libvcx debian +Because it creates a symlink (/usr/lib/libvcx.so) Run this commands before submitting your PR: diff --git a/cxs/wrappers/node/package-lock.json b/vcx/wrappers/node/package-lock.json similarity index 99% rename from cxs/wrappers/node/package-lock.json rename to vcx/wrappers/node/package-lock.json index 440e1d2145..8369d5951c 100644 --- a/cxs/wrappers/node/package-lock.json +++ b/vcx/wrappers/node/package-lock.json @@ -1,6 +1,6 @@ { - "name": "cxs", - "version": "0.1.296161+44bd27c", + "name": "vcx", + "version": "0.1.543416+469b25d", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/vcx/wrappers/node/package.json b/vcx/wrappers/node/package.json new file mode 100644 index 0000000000..e119915dd3 --- /dev/null +++ b/vcx/wrappers/node/package.json @@ -0,0 +1,57 @@ +{ + "description": "Node wrapper for vcx", + "license": "ISC", + "typings": "dist/index.d.ts", + "directories": { + "test": "test", + "build": "dist", + "lib": "src" + }, + "author": "evernym", + "bugs": { + "url": "https://github.com/evernym/vcx/issues" + }, + "standard": { + "env": [ + "mocha" + ] + }, + "repository": { + "url": "git+https://github.com/evernym/vcx.git", + "type": "git" + }, + "version": "0.1.543416+469b25d", + "dependencies": { + "@types/node": "^8.0.47", + "weak": "^1.0.1", + "fs-extra": "^4.0.2", + "@types/ref-struct": "0.0.28", + "@types/ffi": "0.0.19", + "change-case": "^3.0.1", + "ffi": "^2.2.0", + "lodash": "^4.17.4", + "path": "^0.12.7", + "ref-struct": "^1.1.0", + "@types/ref": "0.0.28", + "ref": "^1.3.5" + }, + "scripts": { + "compile": "./node_modules/.bin/tsc -p ./tsconfig.json", + "test": "mocha -gc --expose-gc test/**/*Test.js && mocha -gc --expose-gc test/**/*Test.separate.js", + "lint": "./node_modules/.bin/tslint --type-check -c ./tslint.json -p ./tsconfig.json && ./node_modules/.bin/standard 'test/**/*.js'", + "doc-gen": "./node_modules/.bin/jsdoc -r -d doc dist/*" + }, + "devDependencies": { + "tslint": "^5.8.0", + "typescript": "^2.5.3", + "tslint-config-standard": "^6.0.1", + "chai": "^4.1.2", + "standard": "^10.0.3", + "sinon": "^4.1.2", + "jsdoc": "^3.5.5", + "mocha": "^3.5.3" + }, + "main": "dist/index.js", + "homepage": "https://github.com/evernym/vcx#readme", + "name": "vcx" +} diff --git a/cxs/wrappers/node/src/api/CXSBase.ts b/vcx/wrappers/node/src/api/VCXBase.ts similarity index 92% rename from cxs/wrappers/node/src/api/CXSBase.ts rename to vcx/wrappers/node/src/api/VCXBase.ts index 16b56dc4be..a9040a8fd5 100644 --- a/cxs/wrappers/node/src/api/CXSBase.ts +++ b/vcx/wrappers/node/src/api/VCXBase.ts @@ -2,7 +2,7 @@ import * as ffi from 'ffi' import { createFFICallbackPromise } from '../utils/ffi-helpers' import { GCWatcher } from '../utils/memory-management-helpers' -export abstract class CXSBase extends GCWatcher { +export abstract class VCXBase extends GCWatcher { protected abstract _serializeFn: any protected abstract _deserializeFn: any protected _handle: string @@ -14,12 +14,12 @@ export abstract class CXSBase extends GCWatcher { this._sourceId = sourceId } - static async _deserialize ( - CXSClass: new(...args: any[]) => T, + static async _deserialize ( + VCXClass: new(...args: any[]) => T, objData: { source_id: string }, constructorParams?: P ): Promise { - const obj = new CXSClass(objData.source_id, constructorParams) + const obj = new VCXClass(objData.source_id, constructorParams) await obj._initFromData(objData) return obj } diff --git a/cxs/wrappers/node/src/api/CXSBaseWithState.ts b/vcx/wrappers/node/src/api/VCXBaseWithState.ts similarity index 93% rename from cxs/wrappers/node/src/api/CXSBaseWithState.ts rename to vcx/wrappers/node/src/api/VCXBaseWithState.ts index 9531d55591..cddfc5b281 100644 --- a/cxs/wrappers/node/src/api/CXSBaseWithState.ts +++ b/vcx/wrappers/node/src/api/VCXBaseWithState.ts @@ -1,9 +1,9 @@ import * as ffi from 'ffi' import { createFFICallbackPromise } from '../utils/ffi-helpers' import { StateType } from './common' -import { CXSBase } from './CXSBase' +import { VCXBase } from './VCXBase' -export abstract class CXSBaseWithState extends CXSBase { +export abstract class VCXBaseWithState extends VCXBase { protected abstract _updateStFn: any protected abstract _getStFn: any diff --git a/cxs/wrappers/node/src/api/CXSMock.ts b/vcx/wrappers/node/src/api/VCXMock.ts similarity index 73% rename from cxs/wrappers/node/src/api/CXSMock.ts rename to vcx/wrappers/node/src/api/VCXMock.ts index 909a6c63e9..0c5f943411 100644 --- a/cxs/wrappers/node/src/api/CXSMock.ts +++ b/vcx/wrappers/node/src/api/VCXMock.ts @@ -7,8 +7,8 @@ // 7 -> get_message response with proof import { rustAPI } from '../rustlib' -export class CXSMock { - static setCxsMock (messageIndex: number) { - rustAPI().cxs_set_next_agency_response(messageIndex) +export class VCXMock { + static setVcxMock (messageIndex: number) { + rustAPI().vcx_set_next_agency_response(messageIndex) } } diff --git a/cxs/wrappers/node/src/api/claimDef.ts b/vcx/wrappers/node/src/api/claimDef.ts similarity index 84% rename from cxs/wrappers/node/src/api/claimDef.ts rename to vcx/wrappers/node/src/api/claimDef.ts index c64deb92e4..b6fdd0c1f9 100644 --- a/cxs/wrappers/node/src/api/claimDef.ts +++ b/vcx/wrappers/node/src/api/claimDef.ts @@ -1,6 +1,6 @@ -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { rustAPI } from '../rustlib' -import { CXSBase } from './CXSBase' +import { VCXBase } from './VCXBase' /** * @interface @@ -39,10 +39,10 @@ export interface IClaimDefParams { /** * @class Class representing a Claim Definition */ -export class ClaimDef extends CXSBase { - protected _releaseFn = rustAPI().cxs_claimdef_release - protected _serializeFn = rustAPI().cxs_claimdef_serialize - protected _deserializeFn = rustAPI().cxs_claimdef_deserialize +export class ClaimDef extends VCXBase { + protected _releaseFn = rustAPI().vcx_claimdef_release + protected _serializeFn = rustAPI().vcx_claimdef_serialize + protected _deserializeFn = rustAPI().vcx_claimdef_deserialize private _name: string private _schemaNo: number @@ -68,7 +68,7 @@ export class ClaimDef extends CXSBase { const commandHandle = 0 const issuerDid = null try { - await claimDef._create((cb) => rustAPI().cxs_claimdef_create( + await claimDef._create((cb) => rustAPI().vcx_claimdef_create( commandHandle, claimDef.sourceId, claimDef._name, @@ -79,7 +79,7 @@ export class ClaimDef extends CXSBase { )) return claimDef } catch (err) { - throw new CXSInternalError(`cxs_claimdef_create -> ${err}`) + throw new VCXInternalError(`vcx_claimdef_create -> ${err}`) } } @@ -104,7 +104,7 @@ export class ClaimDef extends CXSBase { } return await super._deserialize(ClaimDef, data, claimDefParams) } catch (err) { - throw new CXSInternalError(`cxs_claimdef_deserialize -> ${err}`) + throw new VCXInternalError(`vcx_claimdef_deserialize -> ${err}`) } } @@ -122,7 +122,7 @@ export class ClaimDef extends CXSBase { const data: IClaimDefObj = JSON.parse(await super._serialize()) return data } catch (err) { - throw new CXSInternalError(`cxs_claimdef_serialize -> ${err}`) + throw new VCXInternalError(`vcx_claimdef_serialize -> ${err}`) } } } diff --git a/cxs/wrappers/node/src/api/common.ts b/vcx/wrappers/node/src/api/common.ts similarity index 100% rename from cxs/wrappers/node/src/api/common.ts rename to vcx/wrappers/node/src/api/common.ts diff --git a/cxs/wrappers/node/src/api/connection.ts b/vcx/wrappers/node/src/api/connection.ts similarity index 84% rename from cxs/wrappers/node/src/api/connection.ts rename to vcx/wrappers/node/src/api/connection.ts index 33933034cc..fdd19c2a31 100644 --- a/cxs/wrappers/node/src/api/connection.ts +++ b/vcx/wrappers/node/src/api/connection.ts @@ -1,9 +1,9 @@ import * as ffi from 'ffi' -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { rustAPI } from '../rustlib' import { createFFICallbackPromise } from '../utils/ffi-helpers' import { StateType } from './common' -import { CXSBaseWithState } from './CXSBaseWithState' +import { VCXBaseWithState } from './VCXBaseWithState' /** * @description Interface that represents the attributes of a Connection object. @@ -35,13 +35,13 @@ export interface IConnectOptions { /** * @class Class representing a Connection */ -export class Connection extends CXSBaseWithState { - protected _releaseFn = rustAPI().cxs_connection_release - protected _updateStFn = rustAPI().cxs_connection_update_state - protected _getStFn = rustAPI().cxs_connection_get_state - protected _serializeFn = rustAPI().cxs_connection_serialize - protected _deserializeFn = rustAPI().cxs_connection_deserialize - protected _inviteDetailFn = rustAPI().cxs_connection_invite_details +export class Connection extends VCXBaseWithState { + protected _releaseFn = rustAPI().vcx_connection_release + protected _updateStFn = rustAPI().vcx_connection_update_state + protected _getStFn = rustAPI().vcx_connection_get_state + protected _serializeFn = rustAPI().vcx_connection_serialize + protected _deserializeFn = rustAPI().vcx_connection_deserialize + protected _inviteDetailFn = rustAPI().vcx_connection_invite_details /** * @memberof Connection @@ -58,10 +58,10 @@ export class Connection extends CXSBaseWithState { const connection = new Connection(recipientInfo.id) const commandHandle = 0 try { - await connection._create((cb) => rustAPI().cxs_connection_create(commandHandle, recipientInfo.id, cb)) + await connection._create((cb) => rustAPI().vcx_connection_create(commandHandle, recipientInfo.id, cb)) return connection } catch (err) { - throw new CXSInternalError(`cxs_connection_create -> ${err}`) + throw new VCXInternalError(`vcx_connection_create -> ${err}`) } } @@ -83,7 +83,7 @@ export class Connection extends CXSBaseWithState { const connection = await super._deserialize(Connection, connectionData) return connection } catch (err) { - throw new CXSInternalError(`cxs_connection_deserialize -> ${err}`) + throw new VCXInternalError(`vcx_connection_deserialize -> ${err}`) } } @@ -104,7 +104,7 @@ export class Connection extends CXSBaseWithState { try { return await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_connection_connect(0, this._handle, connectionData, cb) + const rc = rustAPI().vcx_connection_connect(0, this._handle, connectionData, cb) if (rc) { resolve(rc) } @@ -120,7 +120,7 @@ export class Connection extends CXSBaseWithState { }) ) } catch (error) { - throw new CXSInternalError(`cxs_connection_connect -> ${error}`) + throw new VCXInternalError(`vcx_connection_connect -> ${error}`) } } @@ -138,7 +138,7 @@ export class Connection extends CXSBaseWithState { const data: IConnectionData = JSON.parse(await super._serialize()) return data } catch (err) { - throw new CXSInternalError(`cxs_connection_serialize -> ${err}`) + throw new VCXInternalError(`vcx_connection_serialize -> ${err}`) } } @@ -153,7 +153,7 @@ export class Connection extends CXSBaseWithState { try { await this._updateState() } catch (error) { - throw new CXSInternalError(`cxs_connection_updateState -> ${error}`) + throw new VCXInternalError(`vcx_connection_updateState -> ${error}`) } } @@ -168,7 +168,7 @@ export class Connection extends CXSBaseWithState { try { return await this._getState() } catch (error) { - throw new CXSInternalError(`cxs_connection_get_state -> ${error}`) + throw new VCXInternalError(`vcx_connection_get_state -> ${error}`) } } @@ -185,7 +185,7 @@ export class Connection extends CXSBaseWithState { const data: string = await this._inviteDetails(abbr) return data } catch (err) { - throw new CXSInternalError(`cxs_connection_invite_details -> ${err}`) + throw new VCXInternalError(`vcx_connection_invite_details -> ${err}`) } } diff --git a/cxs/wrappers/node/src/api/errors.ts b/vcx/wrappers/node/src/api/errors.ts similarity index 66% rename from cxs/wrappers/node/src/api/errors.ts rename to vcx/wrappers/node/src/api/errors.ts index 2637626cb5..70abf884b0 100644 --- a/cxs/wrappers/node/src/api/errors.ts +++ b/vcx/wrappers/node/src/api/errors.ts @@ -1,4 +1,4 @@ // tslint:disable max-classes-per-file export class ConnectionTimeoutError extends Error {} -export class CXSInternalError extends Error {} +export class VCXInternalError extends Error {} diff --git a/cxs/wrappers/node/src/api/init.ts b/vcx/wrappers/node/src/api/init.ts similarity index 62% rename from cxs/wrappers/node/src/api/init.ts rename to vcx/wrappers/node/src/api/init.ts index ac45efc8a5..cb4513615e 100644 --- a/cxs/wrappers/node/src/api/init.ts +++ b/vcx/wrappers/node/src/api/init.ts @@ -1,20 +1,20 @@ import { Callback } from 'ffi' -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { initRustAPI, rustAPI } from '../rustlib' import { createFFICallbackPromise } from '../utils/ffi-helpers' -export interface IInitCXSOptions { - libCXSPath?: string +export interface IInitVCXOptions { + libVCXPath?: string } -export async function initCxs (configPath: string, options: IInitCXSOptions = {}): Promise { - initRustAPI(options.libCXSPath) +export async function initVcx (configPath: string, options: IInitVCXOptions = {}): Promise { + initRustAPI(options.libVCXPath) let rc = null try { return await createFFICallbackPromise( (resolve, reject, cb) => { - rc = rustAPI().cxs_init(0, configPath, cb) + rc = rustAPI().vcx_init(0, configPath, cb) if (rc) { reject(rc) } else { @@ -30,6 +30,6 @@ export async function initCxs (configPath: string, options: IInitCXSOptions = {} }) ) } catch (err) { - throw new CXSInternalError(`cxs_init -> ${err}`) + throw new VCXInternalError(`vcx_init -> ${err}`) } } diff --git a/cxs/wrappers/node/src/api/issuerClaim.ts b/vcx/wrappers/node/src/api/issuerClaim.ts similarity index 82% rename from cxs/wrappers/node/src/api/issuerClaim.ts rename to vcx/wrappers/node/src/api/issuerClaim.ts index b53df2d052..cd71daad4c 100644 --- a/cxs/wrappers/node/src/api/issuerClaim.ts +++ b/vcx/wrappers/node/src/api/issuerClaim.ts @@ -1,11 +1,11 @@ import { Callback } from 'ffi' -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { rustAPI } from '../rustlib' import { createFFICallbackPromise } from '../utils/ffi-helpers' import { StateType } from './common' import { Connection } from './connection' -import { CXSBaseWithState } from './CXSBaseWithState' +import { VCXBaseWithState } from './VCXBaseWithState' /** * @interface @@ -23,14 +23,14 @@ export interface IClaimConfig { claimName: string, } -export interface IClaimCXSAttributes { +export interface IClaimVCXAttributes { [ index: string ]: [ string ] } export interface IClaimParams { schemaNum: number, claimName: string, - attr: IClaimCXSAttributes + attr: IClaimVCXAttributes } /** @@ -51,16 +51,16 @@ export interface IClaimData { /** * @class Class representing an Issuer Claim */ -export class IssuerClaim extends CXSBaseWithState { - protected _releaseFn = rustAPI().cxs_connection_release - protected _updateStFn = rustAPI().cxs_issuer_claim_update_state - protected _getStFn = rustAPI().cxs_issuer_claim_get_state - protected _serializeFn = rustAPI().cxs_issuer_claim_serialize - protected _deserializeFn = rustAPI().cxs_issuer_claim_deserialize +export class IssuerClaim extends VCXBaseWithState { + protected _releaseFn = rustAPI().vcx_connection_release + protected _updateStFn = rustAPI().vcx_issuer_claim_update_state + protected _getStFn = rustAPI().vcx_issuer_claim_get_state + protected _serializeFn = rustAPI().vcx_issuer_claim_serialize + protected _deserializeFn = rustAPI().vcx_issuer_claim_deserialize private _schemaNum: number private _issuerDID: string private _claimName: string - private _attr: IClaimCXSAttributes + private _attr: IClaimVCXAttributes constructor (sourceId, { schemaNum, claimName, attr }: IClaimParams) { super(sourceId) @@ -81,14 +81,14 @@ export class IssuerClaim extends CXSBaseWithState { * @returns {Promise} An Issuer Claim Object */ static async create ({ attr, sourceId, schemaNum, claimName }: IClaimConfig): Promise { - const attrsCXS: IClaimCXSAttributes = Object.keys(attr) + const attrsVCX: IClaimVCXAttributes = Object.keys(attr) .reduce((accum, attrKey) => ({ ...accum, [attrKey]: [attr[attrKey]] }), {}) - const claim = new IssuerClaim(sourceId, { schemaNum, claimName, attr: attrsCXS }) - const attrsStringified = JSON.stringify(attrsCXS) + const claim = new IssuerClaim(sourceId, { schemaNum, claimName, attr: attrsVCX }) + const attrsStringified = JSON.stringify(attrsVCX) const commandHandle = 0 const issuerDid = null try { - await claim._create((cb) => rustAPI().cxs_issuer_create_claim( + await claim._create((cb) => rustAPI().vcx_issuer_create_claim( commandHandle, sourceId, schemaNum, @@ -100,7 +100,7 @@ export class IssuerClaim extends CXSBaseWithState { ) return claim } catch (err) { - throw new CXSInternalError(`cxs_issuer_create_claim -> ${err}`) + throw new VCXInternalError(`vcx_issuer_create_claim -> ${err}`) } } @@ -128,7 +128,7 @@ export class IssuerClaim extends CXSBaseWithState { const claim = await super._deserialize(IssuerClaim, claimData, params) return claim } catch (err) { - throw new CXSInternalError(`cxs_issuer_claim_deserialize -> ${err}`) + throw new VCXInternalError(`vcx_issuer_claim_deserialize -> ${err}`) } } @@ -143,7 +143,7 @@ export class IssuerClaim extends CXSBaseWithState { try { return await this._getState() } catch (error) { - throw new CXSInternalError(`cxs_issuer_claim_get_state -> ${error}`) + throw new VCXInternalError(`vcx_issuer_claim_get_state -> ${error}`) } } @@ -158,7 +158,7 @@ export class IssuerClaim extends CXSBaseWithState { try { await this._updateState() } catch (error) { - throw new CXSInternalError(`cxs_issuer_claim_updateState -> ${error}`) + throw new VCXInternalError(`vcx_issuer_claim_updateState -> ${error}`) } } @@ -175,7 +175,7 @@ export class IssuerClaim extends CXSBaseWithState { try { return JSON.parse(await super._serialize()) } catch (err) { - throw new CXSInternalError(`cxs_issuer_claim_serialize -> ${err}`) + throw new VCXInternalError(`vcx_issuer_claim_serialize -> ${err}`) } } @@ -193,7 +193,7 @@ export class IssuerClaim extends CXSBaseWithState { try { await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_issuer_send_claim_offer(0, this.handle, connection.handle, cb) + const rc = rustAPI().vcx_issuer_send_claim_offer(0, this.handle, connection.handle, cb) if (rc) { reject(rc) } @@ -208,7 +208,7 @@ export class IssuerClaim extends CXSBaseWithState { ) } catch (err) { // TODO handle error - throw new CXSInternalError(`cxs_issuer_send_claim_offer -> ${err}`) + throw new VCXInternalError(`vcx_issuer_send_claim_offer -> ${err}`) } } @@ -226,7 +226,7 @@ export class IssuerClaim extends CXSBaseWithState { try { await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_issuer_send_claim(0, this.handle, connection.handle, cb) + const rc = rustAPI().vcx_issuer_send_claim(0, this.handle, connection.handle, cb) if (rc) { reject(rc) } @@ -240,7 +240,7 @@ export class IssuerClaim extends CXSBaseWithState { }) ) } catch (err) { - throw new CXSInternalError(`cxs_issuer_send_claim -> ${err}`) + throw new VCXInternalError(`vcx_issuer_send_claim -> ${err}`) } } diff --git a/cxs/wrappers/node/src/api/proof.ts b/vcx/wrappers/node/src/api/proof.ts similarity index 85% rename from cxs/wrappers/node/src/api/proof.ts rename to vcx/wrappers/node/src/api/proof.ts index eb759361b1..41783e8b6a 100644 --- a/cxs/wrappers/node/src/api/proof.ts +++ b/vcx/wrappers/node/src/api/proof.ts @@ -1,12 +1,12 @@ import { snakeCase } from 'change-case' import { Callback } from 'ffi' import { _ } from 'lodash' -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { rustAPI } from '../rustlib' import { createFFICallbackPromise } from '../utils/ffi-helpers' import { StateType } from './common' import { Connection } from './connection' -import { CXSBaseWithState } from './CXSBaseWithState' +import { VCXBaseWithState } from './VCXBaseWithState' export interface IProofConfig { sourceId: string, @@ -72,12 +72,12 @@ export enum ProofState { /** * @class Class representing a Connection */ -export class Proof extends CXSBaseWithState { - protected _releaseFn = rustAPI().cxs_proof_release - protected _updateStFn = rustAPI().cxs_proof_update_state - protected _getStFn = rustAPI().cxs_proof_get_state - protected _serializeFn = rustAPI().cxs_proof_serialize - protected _deserializeFn = rustAPI().cxs_proof_deserialize +export class Proof extends VCXBaseWithState { + protected _releaseFn = rustAPI().vcx_proof_release + protected _updateStFn = rustAPI().vcx_proof_update_state + protected _getStFn = rustAPI().vcx_proof_get_state + protected _serializeFn = rustAPI().vcx_proof_serialize + protected _deserializeFn = rustAPI().vcx_proof_deserialize private _requestedAttributes: IProofAttr[] private _name: string private _proofState: number @@ -100,7 +100,7 @@ export class Proof extends CXSBaseWithState { const commandHandle = 0 try { - await proof._create((cb) => rustAPI().cxs_proof_create( + await proof._create((cb) => rustAPI().vcx_proof_create( commandHandle, proof.sourceId, JSON.stringify(proof._convertAttrToSnakeCase(data.attrs)), @@ -110,7 +110,7 @@ export class Proof extends CXSBaseWithState { )) return proof } catch (err) { - throw new CXSInternalError(`cxs_proof_create -> ${err}`) + throw new VCXInternalError(`vcx_proof_create -> ${err}`) } } @@ -132,7 +132,7 @@ export class Proof extends CXSBaseWithState { const proof = await super._deserialize(Proof, proofData) return proof } catch (err) { - throw new CXSInternalError(`cxs_proof_deserialize -> ${err}`) + throw new VCXInternalError(`vcx_proof_deserialize -> ${err}`) } } @@ -150,7 +150,7 @@ export class Proof extends CXSBaseWithState { const data: IProofData = JSON.parse(await super._serialize()) return data } catch (err) { - throw new CXSInternalError(`cxs_proof_serialize -> ${err}`) + throw new VCXInternalError(`vcx_proof_serialize -> ${err}`) } } @@ -165,7 +165,7 @@ export class Proof extends CXSBaseWithState { try { return await this._getState() } catch (error) { - throw new CXSInternalError(`cxs_proof_get_state -> ${error}`) + throw new VCXInternalError(`vcx_proof_get_state -> ${error}`) } } @@ -180,7 +180,7 @@ export class Proof extends CXSBaseWithState { try { await this._updateState() } catch (error) { - throw new CXSInternalError(`cxs_proof_updateState -> ${error}`) + throw new VCXInternalError(`vcx_proof_updateState -> ${error}`) } } @@ -198,7 +198,7 @@ export class Proof extends CXSBaseWithState { try { await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_proof_send_request(0, this.handle, connection.handle, cb) + const rc = rustAPI().vcx_proof_send_request(0, this.handle, connection.handle, cb) if (rc) { reject(rc) } @@ -212,7 +212,7 @@ export class Proof extends CXSBaseWithState { }) ) } catch (err) { - throw new CXSInternalError(`cxs_proof_send_request -> ${err}`) + throw new VCXInternalError(`vcx_proof_send_request -> ${err}`) } } @@ -220,7 +220,7 @@ export class Proof extends CXSBaseWithState { try { const proof = await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_get_proof(0, this.handle, connection.handle, cb) + const rc = rustAPI().vcx_get_proof(0, this.handle, connection.handle, cb) if (rc) { reject(rc) } @@ -237,7 +237,7 @@ export class Proof extends CXSBaseWithState { ) return {proofAttrs: JSON.parse(proof), proofState: this.getProofState()} } catch (err) { - throw new CXSInternalError(`cxs_get_proof -> ${err}`) + throw new VCXInternalError(`vcx_get_proof -> ${err}`) } } diff --git a/cxs/wrappers/node/src/api/schema.ts b/vcx/wrappers/node/src/api/schema.ts similarity index 87% rename from cxs/wrappers/node/src/api/schema.ts rename to vcx/wrappers/node/src/api/schema.ts index ae4b0645cd..ce0e82c3c7 100644 --- a/cxs/wrappers/node/src/api/schema.ts +++ b/vcx/wrappers/node/src/api/schema.ts @@ -2,10 +2,10 @@ import { snakeCase } from 'change-case' import * as ffi from 'ffi' import { _ } from 'lodash' -import { CXSInternalError } from '../errors' +import { VCXInternalError } from '../errors' import { rustAPI } from '../rustlib' import { createFFICallbackPromise } from '../utils/ffi-helpers' -import { CXSBase } from './CXSBase' +import { VCXBase } from './VCXBase' export interface ISchema { sourceId: string, @@ -51,10 +51,10 @@ export interface ISchemaParams { schemaAttrs?: ISchemaAttrs, } -export class Schema extends CXSBase { - protected _releaseFn = rustAPI().cxs_schema_release - protected _serializeFn = rustAPI().cxs_schema_serialize - protected _deserializeFn = rustAPI().cxs_schema_deserialize +export class Schema extends VCXBase { + protected _releaseFn = rustAPI().vcx_schema_release + protected _serializeFn = rustAPI().vcx_schema_serialize + protected _deserializeFn = rustAPI().vcx_schema_deserialize private _name: string private _schemaNo: number private _schemaAttrs: ISchemaAttrs @@ -81,7 +81,7 @@ export class Schema extends CXSBase { const schema = new Schema(data.sourceId, { name: data.data.name, schemaNo: 0, schemaAttrs: data.data }) const commandHandle = 0 try { - await schema._create((cb) => rustAPI().cxs_schema_create( + await schema._create((cb) => rustAPI().vcx_schema_create( commandHandle, schema.sourceId, schema._name, @@ -91,7 +91,7 @@ export class Schema extends CXSBase { await schema.getSchemaNo() return schema } catch (err) { - throw new CXSInternalError(`cxs_schema_create -> ${err}`) + throw new VCXInternalError(`vcx_schema_create -> ${err}`) } } @@ -117,7 +117,7 @@ export class Schema extends CXSBase { } return await super._deserialize(Schema, schema, schemaParams) } catch (err) { - throw new CXSInternalError(`cxs_schema_deserialize -> ${err}`) + throw new VCXInternalError(`vcx_schema_deserialize -> ${err}`) } } @@ -134,7 +134,7 @@ export class Schema extends CXSBase { let rc = null const schemaData = await createFFICallbackPromise( (resolve, reject, cb) => { - rc = rustAPI().cxs_schema_get_attributes(0, data.sourceId, data.seqNo, cb) + rc = rustAPI().vcx_schema_get_attributes(0, data.sourceId, data.seqNo, cb) if (rc) { reject(rc) } @@ -160,7 +160,7 @@ export class Schema extends CXSBase { newSchema._handle = JSON.stringify(schemaObj.handle) return newSchema } catch (err) { - throw new CXSInternalError(`cxs_schema_get_attributes -> ${err}`) + throw new VCXInternalError(`vcx_schema_get_attributes -> ${err}`) } } @@ -178,7 +178,7 @@ export class Schema extends CXSBase { const data: ISchemaObj = JSON.parse(await super._serialize()) return data } catch (err) { - throw new CXSInternalError(`cxs_schema_serialize -> ${err}`) + throw new VCXInternalError(`vcx_schema_serialize -> ${err}`) } } @@ -186,7 +186,7 @@ export class Schema extends CXSBase { try { const schemaNo = await createFFICallbackPromise( (resolve, reject, cb) => { - const rc = rustAPI().cxs_schema_get_sequence_no(0, this.handle, cb) + const rc = rustAPI().vcx_schema_get_sequence_no(0, this.handle, cb) if (rc) { reject(rc) } @@ -203,7 +203,7 @@ export class Schema extends CXSBase { ) return schemaNo } catch (err) { - throw new CXSInternalError(`cxs_schema_get_sequence_no -> ${err}`) + throw new VCXInternalError(`vcx_schema_get_sequence_no -> ${err}`) } } diff --git a/cxs/wrappers/node/src/errors.ts b/vcx/wrappers/node/src/errors.ts similarity index 66% rename from cxs/wrappers/node/src/errors.ts rename to vcx/wrappers/node/src/errors.ts index 2637626cb5..70abf884b0 100644 --- a/cxs/wrappers/node/src/errors.ts +++ b/vcx/wrappers/node/src/errors.ts @@ -1,4 +1,4 @@ // tslint:disable max-classes-per-file export class ConnectionTimeoutError extends Error {} -export class CXSInternalError extends Error {} +export class VCXInternalError extends Error {} diff --git a/cxs/wrappers/node/src/index.ts b/vcx/wrappers/node/src/index.ts similarity index 82% rename from cxs/wrappers/node/src/index.ts rename to vcx/wrappers/node/src/index.ts index 4608913d80..f9023c603a 100644 --- a/cxs/wrappers/node/src/index.ts +++ b/vcx/wrappers/node/src/index.ts @@ -3,9 +3,9 @@ export * from './api/init' export * from './api/claimDef' export * from './api/common' export * from './api/connection' -export * from './api/CXSMock' +export * from './api/VCXMock' export * from './api/issuerClaim' export * from './api/proof' export * from './api/schema' -export * from './cxs' +export * from './vcx' export * from './rustlib' diff --git a/vcx/wrappers/node/src/rustlib.ts b/vcx/wrappers/node/src/rustlib.ts new file mode 100644 index 0000000000..0bac9f95d8 --- /dev/null +++ b/vcx/wrappers/node/src/rustlib.ts @@ -0,0 +1,151 @@ +import * as ref from 'ref' +import * as StructType from 'ref-struct' + +import { VCXRuntime } from './vcx' + +export const VcxStatus = StructType({ + handle: 'int', + msg: 'string', + status: 'int' +}) + +// FFI Type Strings +export const FFI_ERROR_CODE = 'int' +export const FFI_BOOL = 'bool' +export const FFI_CONNECTION_HANDLE = 'uint32' +export const FFI_UNSIGNED_INT = 'uint32' +export const FFI_UNSIGNED_INT_PTR = ref.refType('uint32') +export const FFI_STRING = 'string' +export const FFI_CONFIG_PATH = FFI_STRING +export const FFI_STRING_DATA = 'string' +export const FFI_SOURCE_ID = 'string' +export const FFI_CONNECTION_DATA = 'string' +export const FFI_VOID = ref.types.void +export const FFI_CONNECTION_HANDLE_PTR = ref.refType(FFI_CONNECTION_HANDLE) +export const FFI_CALLBACK_PTR = 'pointer' +export const FFI_COMMAND_HANDLE = 'uint32' +export const FFI_CLAIM_HANDLE = 'uint32' +export const FFI_PROOF_HANDLE = 'uint32' +export const FFI_CLAIMDEF_HANDLE = 'uint32' +export const FFI_SCHEMA_HANDLE = 'uint32' +export const FFI_SCHEMA_NUMBER = 'uint32' + +// Rust Lib Native Types +export type rust_did = string +export type rust_error_code = number +export type rust_command_handle = number +export type rust_object_handle = number +export type rust_pool_handle = rust_object_handle +export type rust_wallet_handle = rust_object_handle +export type rust_listener_handle = rust_object_handle +export type rust_connection_handle = rust_object_handle + +export interface IFFIEntryPoint { + vcx_init: (commandId: number, configPath: string, cb: any) => number, + // connection + vcx_connection_connect: (commandId: number, handle: string, data: string, cb: any) => number, + vcx_connection_create: (commandId: number, data: string, cb: any) => number, + vcx_connection_deserialize: (commandId: number, data: string, cb: any) => number, + vcx_connection_release: (handle: string) => number, + vcx_connection_serialize: (commandId: number, handle: string, cb: any) => number, + vcx_connection_update_state: (commandId: number, handle: string, cb: any) => number, + vcx_connection_get_state: (commandId: number, handle: string, cb: any) => number, + vcx_connection_invite_details: (commandId: number, handle: string, abbreviated: boolean, cb: any) => number, + // issuer + vcx_issuer_claim_deserialize: (commandId: number, data: string, cb: any) => number, + vcx_issuer_claim_serialize: (commandId: number, handle: string, cb: any) => number, + vcx_issuer_claim_update_state: (commandId: number, handle: string, cb: any) => number, + vcx_issuer_claim_get_state: (commandId: number, handle: string, cb: any) => number, + vcx_issuer_create_claim: any, + vcx_issuer_send_claim: (commandId: number, claimHandle: string, connectionHandle: string, cb: any) => number, + vcx_issuer_send_claim_offer: (commandId: number, claimHandle: string, connectionHandle: string, cb: any) => number, + // proof + vcx_proof_create: (commandId: number, sourceId: string, attrs: string, predicates: string, + name: string, cb: any) => number, + vcx_proof_deserialize: (commandId: number, data: string, cb: any) => number, + vcx_get_proof: (commandId: number, proofHandle: string, connectionHandle: string, cb: any) => number, + vcx_proof_release: (handle: string) => number, + vcx_proof_send_request: (commandId: number, proofHandle: string, connectionHandle: string, cb: any) => number, + vcx_proof_serialize: (commandId: number, handle: string, cb: any) => number, + vcx_proof_update_state: (commandId: number, handle: string, cb: any) => number, + vcx_proof_get_state: (commandId: number, handle: string, cb: any) => number, + // mock + vcx_set_next_agency_response: (messageIndex: number) => void, + + // claimdef + vcx_claimdef_create: (commandId: number, sourceId: string, claimDefName: string, schemaNo: number, + issuerDid: string, revocation: boolean, cb: any) => number + vcx_claimdef_deserialize: (commandId: number, data: string, cb: any) => number, + vcx_claimdef_serialize: (commandId: number, handle: string, cb: any) => number, + vcx_claimdef_release: (handle: string) => number, + + // schema + vcx_schema_get_attributes: (commandId: number, sourceId: string, schemaNo: number, cb: any) => number, + vcx_schema_create: (commandId: number, sourceId: string, schemaName: string, schemaData: string, + cb: any) => number, + vcx_schema_get_sequence_no: (commandId: number, handle: string, cb: any) => number, + vcx_schema_deserialize: (commandId: number, data: string, cb: any) => number, + vcx_schema_serialize: (commandId: number, handle: string, cb: any) => number, + vcx_schema_release: (handle: string) => number, + +} + +// tslint:disable object-literal-sort-keys +export const FFIConfiguration: { [ Key in keyof IFFIEntryPoint ]: any } = { + + vcx_init: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONFIG_PATH, FFI_CALLBACK_PTR]], + // connection + vcx_connection_connect: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CONNECTION_DATA, + FFI_CALLBACK_PTR]], + vcx_connection_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_connection_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_connection_release: [FFI_ERROR_CODE, [FFI_CONNECTION_HANDLE]], + vcx_connection_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], + vcx_connection_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], + vcx_connection_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_CALLBACK_PTR]], + vcx_connection_invite_details: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CONNECTION_HANDLE, FFI_BOOL, + FFI_CALLBACK_PTR]], + // issuer + vcx_issuer_claim_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_issuer_claim_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], + vcx_issuer_claim_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], + vcx_issuer_claim_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CALLBACK_PTR]], + vcx_issuer_create_claim: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, + 'int', 'string', 'string', 'string', 'pointer']], + vcx_issuer_send_claim: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CONNECTION_HANDLE, + FFI_CALLBACK_PTR]], + vcx_issuer_send_claim_offer: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIM_HANDLE, FFI_CONNECTION_HANDLE, + FFI_CALLBACK_PTR]], + // proof + vcx_proof_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_STRING_DATA, + FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_proof_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_get_proof: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CONNECTION_HANDLE, + FFI_CALLBACK_PTR]],// tslint:disable-line + vcx_proof_release: [FFI_ERROR_CODE, [FFI_PROOF_HANDLE]], + vcx_proof_send_request: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CONNECTION_HANDLE, + FFI_CALLBACK_PTR]], + vcx_proof_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], + vcx_proof_update_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], + vcx_proof_get_state: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_PROOF_HANDLE, FFI_CALLBACK_PTR]], + // claimDef + vcx_claimdef_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_SCHEMA_NUMBER, + FFI_STRING_DATA, FFI_BOOL, FFI_CALLBACK_PTR]], + vcx_claimdef_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_claimdef_release: [FFI_ERROR_CODE, [FFI_CLAIMDEF_HANDLE]], + vcx_claimdef_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_CLAIMDEF_HANDLE, FFI_CALLBACK_PTR]], + // mock + vcx_set_next_agency_response: [FFI_VOID, [FFI_UNSIGNED_INT]], + // schema + vcx_schema_get_attributes: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_SCHEMA_NUMBER, FFI_CALLBACK_PTR]], + vcx_schema_create: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SOURCE_ID, FFI_STRING_DATA, FFI_STRING_DATA, + FFI_CALLBACK_PTR]], + vcx_schema_get_sequence_no: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SCHEMA_HANDLE, FFI_CALLBACK_PTR]], + vcx_schema_deserialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_STRING_DATA, FFI_CALLBACK_PTR]], + vcx_schema_release: [FFI_ERROR_CODE, [FFI_SCHEMA_HANDLE]], + vcx_schema_serialize: [FFI_ERROR_CODE, [FFI_COMMAND_HANDLE, FFI_SCHEMA_HANDLE, FFI_CALLBACK_PTR]] +} + +let _rustAPI: IFFIEntryPoint = null +export const initRustAPI = (path?: string) => _rustAPI = new VCXRuntime({ basepath: path }).ffi +export const rustAPI = () => _rustAPI diff --git a/cxs/wrappers/node/src/utils/ffi-helpers.ts b/vcx/wrappers/node/src/utils/ffi-helpers.ts similarity index 100% rename from cxs/wrappers/node/src/utils/ffi-helpers.ts rename to vcx/wrappers/node/src/utils/ffi-helpers.ts diff --git a/cxs/wrappers/node/src/utils/memory-management-helpers.ts b/vcx/wrappers/node/src/utils/memory-management-helpers.ts similarity index 100% rename from cxs/wrappers/node/src/utils/memory-management-helpers.ts rename to vcx/wrappers/node/src/utils/memory-management-helpers.ts diff --git a/cxs/wrappers/node/src/cxs.ts b/vcx/wrappers/node/src/vcx.ts similarity index 63% rename from cxs/wrappers/node/src/cxs.ts rename to vcx/wrappers/node/src/vcx.ts index 4a0c4b8633..377d0c6fb1 100644 --- a/cxs/wrappers/node/src/cxs.ts +++ b/vcx/wrappers/node/src/vcx.ts @@ -3,25 +3,25 @@ import * as path from 'path' import { FFIConfiguration, IFFIEntryPoint } from './rustlib' -export interface ICXSRuntimeConfig { +export interface IVCXRuntimeConfig { basepath?: string } -// CXSRuntime is the object that interfaces with the cxs sdk functions +// VCXRuntime is the object that interfaces with the vcx sdk functions // FFIConfiguration will contain all the sdk api functions -// CXSRuntimeConfg is a class that currently only contains a chosen basepath for the .so file +// VCXRuntimeConfg is a class that currently only contains a chosen basepath for the .so file // I made it a class just in case we think of more needed configs -export class CXSRuntime { +export class VCXRuntime { readonly ffi: IFFIEntryPoint - private _config: ICXSRuntimeConfig + private _config: IVCXRuntimeConfig - constructor (config: ICXSRuntimeConfig = {}) { + constructor (config: IVCXRuntimeConfig = {}) { this._config = config // initialize FFI const libraryPath = this._initializeBasepath() this.ffi = ffi.Library(libraryPath, FFIConfiguration) } - private _initializeBasepath = (): string => this._config.basepath || path.resolve(__dirname, '/usr/lib/libcxs.so') + private _initializeBasepath = (): string => this._config.basepath || path.resolve(__dirname, '/usr/lib/libvcx.so') } diff --git a/vcx/wrappers/node/test/VCXMockTest.js b/vcx/wrappers/node/test/VCXMockTest.js new file mode 100644 index 0000000000..e6f1c1ea0d --- /dev/null +++ b/vcx/wrappers/node/test/VCXMockTest.js @@ -0,0 +1,22 @@ +const assert = require('chai').assert +const vcx = require('../dist/index') +const { stubInitVCX } = require('./helpers') +const { Connection, VCXMock } = vcx + +describe('A VCXMock', function () { + this.timeout(30000) + + before(async () => { + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') + }) + + it('can be called.', async () => { + VCXMock.setVcxMock(1) + try { + await Connection.create({ id: '234', DIDself: '456', DIDremote: '0' }) + } catch (err) { + assert.equal(err.toString(), 'Error: vcx_connection_create -> 1010') + } + }) +}) diff --git a/cxs/wrappers/node/test/claimDefTest.js b/vcx/wrappers/node/test/claimDefTest.js similarity index 86% rename from cxs/wrappers/node/test/claimDefTest.js rename to vcx/wrappers/node/test/claimDefTest.js index 0dcfedac5d..8e9589b21b 100644 --- a/cxs/wrappers/node/test/claimDefTest.js +++ b/vcx/wrappers/node/test/claimDefTest.js @@ -1,7 +1,7 @@ const assert = require('chai').assert -const cxs = require('../dist/index') -const { stubInitCXS } = require('./helpers') -const { ClaimDef, Error } = cxs +const vcx = require('../dist/index') +const { stubInitVCX } = require('./helpers') +const { ClaimDef, Error } = vcx const CLAIM_DEF = { name: 'test', @@ -14,8 +14,8 @@ describe('A ClaimDef', function () { this.timeout(30000) before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') }) it('can be created.', async () => { @@ -49,7 +49,7 @@ describe('A ClaimDef', function () { try { await claimDef.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_claimdef_serialize -> 1037') + assert.equal(error.toString(), 'Error: vcx_claimdef_serialize -> 1037') } }) }) diff --git a/cxs/wrappers/node/test/connectionTest.js b/vcx/wrappers/node/test/connectionTest.js similarity index 92% rename from cxs/wrappers/node/test/connectionTest.js rename to vcx/wrappers/node/test/connectionTest.js index 4dc94bb595..0ae2e46a8e 100644 --- a/cxs/wrappers/node/test/connectionTest.js +++ b/vcx/wrappers/node/test/connectionTest.js @@ -1,17 +1,17 @@ const chai = require('chai') const ffi = require('ffi') -const cxs = require('../dist') -const { stubInitCXS } = require('./helpers') +const vcx = require('../dist') +const { stubInitVCX } = require('./helpers') const assert = chai.assert -const { Connection, StateType, Error, rustAPI } = cxs +const { Connection, StateType, Error, rustAPI } = vcx describe('A Connection object with ', function () { this.timeout(10000) before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') }) // connection_create tests @@ -61,7 +61,7 @@ describe('A Connection object with ', function () { try { await connection.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_connection_serialize -> 1003') + assert.equal(error.toString(), 'Error: vcx_connection_serialize -> 1003') } }) @@ -80,7 +80,7 @@ describe('A Connection object with ', function () { try { await connection.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_connection_serialize -> 1003') + assert.equal(error.toString(), 'Error: vcx_connection_serialize -> 1003') } }) @@ -99,7 +99,7 @@ describe('A Connection object with ', function () { try { await Connection.deserialize({source_id: 'Invalid'}) } catch (error) { - assert.equal(error.toString(), 'Error: cxs_connection_deserialize -> 1016') + assert.equal(error.toString(), 'Error: vcx_connection_deserialize -> 1016') } }) @@ -167,7 +167,7 @@ describe('A Connection object with ', function () { try { await connection.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_connection_serialize -> 1003') + assert.equal(error.toString(), 'Error: vcx_connection_serialize -> 1003') } }) @@ -176,8 +176,8 @@ describe('A Connection object with ', function () { assert.equal(await connection.release(), Error.INVALID_CONNECTION_HANDLE) }) - it('serialize() should return CxsStateType as an integer', async () => { - const connection = await Connection.create({ id: 'returnCxsTypeInteger' }) + it('serialize() should return VcxStateType as an integer', async () => { + const connection = await Connection.create({ id: 'returnVcxTypeInteger' }) const inviteDetails = await connection.connect({ sms: true }) assert(inviteDetails) const result = await connection.serialize() @@ -189,7 +189,7 @@ describe('A Connection object with ', function () { assert.notEqual(connection._handle, undefined) const inviteDetails = await connection.connect({ sms: true }) assert(inviteDetails) - const serialize = rustAPI().cxs_connection_serialize + const serialize = rustAPI().vcx_connection_serialize const handle = connection._handle const data = await connection.serialize() assert.notEqual(data, null) diff --git a/cxs/wrappers/node/test/ffiTest.separate.js b/vcx/wrappers/node/test/ffiTest.separate.js similarity index 73% rename from cxs/wrappers/node/test/ffiTest.separate.js rename to vcx/wrappers/node/test/ffiTest.separate.js index 7401fdf476..133c3b33d9 100644 --- a/cxs/wrappers/node/test/ffiTest.separate.js +++ b/vcx/wrappers/node/test/ffiTest.separate.js @@ -1,20 +1,20 @@ require('chai') require('fs-extra') const ffi = require('ffi') -const cxs = require('../dist') +const vcx = require('../dist') const assert = require('assert') -const { CXSRuntime } = cxs +const { VCXRuntime } = vcx -describe('call to cxs_init with provided path', function () { +describe('call to vcx_init with provided path', function () { this.timeout(10000) - let path = '/usr/lib/libcxs.so' - const run = new CXSRuntime({ basepath: path }) + let path = '/usr/lib/libvcx.so' + const run = new VCXRuntime({ basepath: path }) it('should return 1004', async () => { let result = null result = await new Promise((resolve, reject) => { - result = run.ffi.cxs_init( + result = run.ffi.vcx_init( 0, 'garbage', ffi.Callback('void', ['uint32', 'uint32'], @@ -31,7 +31,7 @@ describe('call to cxs_init with provided path', function () { // null path given should always error it('should return 1004', async () => { let result = await new Promise((resolve, reject) => - resolve(run.ffi.cxs_init( + resolve(run.ffi.vcx_init( 0, null, ffi.Callback('void', ['uint32', 'uint32'], @@ -44,14 +44,14 @@ describe('call to cxs_init with provided path', function () { // these tests were created to only test that the ffi could be called with each function -describe('Using the cxs ffi directly ', async () => { - let path = '/usr/lib/libcxs.so' - const run = new CXSRuntime({ basepath: path }) +describe('Using the vcx ffi directly ', async () => { + let path = '/usr/lib/libvcx.so' + const run = new VCXRuntime({ basepath: path }) - it('a call to cxs_connection_create should return 0', async () => { + it('a call to vcx_connection_create should return 0', async () => { let result = null result = await new Promise((resolve, reject) => { - result = run.ffi.cxs_connection_create( + result = run.ffi.vcx_connection_create( 0, '1', ffi.Callback('void', ['uint32', 'uint32', 'uint32'], @@ -65,10 +65,10 @@ describe('Using the cxs ffi directly ', async () => { assert.equal(result, 0) }) - it('a to cxs_connection_connect without the ability to connect should return 1', async () => { + it('a to vcx_connection_connect without the ability to connect should return 1', async () => { let connectResult = null connectResult = await new Promise((resolve, reject) => { - connectResult = run.ffi.cxs_connection_connect( + connectResult = run.ffi.vcx_connection_connect( 0, 1, JSON.stringify({connection_type: 'sms', phone: 123}), @@ -83,9 +83,9 @@ describe('Using the cxs ffi directly ', async () => { assert.equal(connectResult, 1003) }) - it('a call to cxs_connection_serialize should return 0', async function () { + it('a call to vcx_connection_serialize should return 0', async function () { const result = await new Promise(function (resolve, reject) { - const rc = run.ffi.cxs_connection_serialize( + const rc = run.ffi.vcx_connection_serialize( 0, 1, ffi.Callback('void', ['uint32', 'uint32', 'string'], (handle, err, data) => { @@ -104,9 +104,9 @@ describe('Using the cxs ffi directly ', async () => { assert.equal(result, null) }) - it('a call to cxs_connection_get_state should return 0', async () => { + it('a call to vcx_connection_get_state should return 0', async () => { const state = await new Promise((resolve, reject) => { - const rc = run.ffi.cxs_connection_update_state( + const rc = run.ffi.vcx_connection_update_state( 0, 1, ffi.Callback('void', ['uint32', 'uint32', 'uint32'], (handle, err, state) => { @@ -123,7 +123,7 @@ describe('Using the cxs ffi directly ', async () => { assert.equal(state, 0) }) - it('a call to cxs_connection_release without ability to release should return 1', function () { - assert.equal(run.ffi.cxs_connection_release(2), 1003) + it('a call to vcx_connection_release without ability to release should return 1', function () { + assert.equal(run.ffi.vcx_connection_release(2), 1003) }) }) diff --git a/vcx/wrappers/node/test/helpers.js b/vcx/wrappers/node/test/helpers.js new file mode 100644 index 0000000000..091f9e2f52 --- /dev/null +++ b/vcx/wrappers/node/test/helpers.js @@ -0,0 +1,37 @@ +const { stub } = require('sinon') + +const vcx = require('../dist') + +let _initVCXCalled = false +let _spyInitVCX +const _stubInitVCX = () => { + const initVCXOriginal = vcx.initVcx + const stubInitVCX = stub(vcx, 'initVcx') + stubInitVCX.callsFake(async function (...args) { + if (_initVCXCalled) { + console.log('calling a stub -> already called') + return + } + console.log('calling a stub -> calling original') + await initVCXOriginal(...args) + _initVCXCalled = true + }) + return stubInitVCX +} +const stubInitVCX = () => { + if (!_spyInitVCX) { + _spyInitVCX = _stubInitVCX() + } + return _spyInitVCX +} + +const shouldThrow = (fn) => new Promise(async (resolve, reject) => { + try { + await fn() + reject(new Error(`${fn.toSting()} should have thrown!`)) + } catch (e) { + resolve(e) + } +}) + +module.exports = { stubInitVCX, shouldThrow } diff --git a/cxs/wrappers/node/test/issueClaimFfiTest.js b/vcx/wrappers/node/test/issueClaimFfiTest.js similarity index 80% rename from cxs/wrappers/node/test/issueClaimFfiTest.js rename to vcx/wrappers/node/test/issueClaimFfiTest.js index 4331871584..b5c6b30f80 100644 --- a/cxs/wrappers/node/test/issueClaimFfiTest.js +++ b/vcx/wrappers/node/test/issueClaimFfiTest.js @@ -1,18 +1,18 @@ const assert = require('chai').assert const Callback = require('ffi').Callback -const { CXSRuntime } = require('../dist') +const { VCXRuntime } = require('../dist') describe('The wrapper', async function () { var callback = null it('can call the ffi directly', async function () { - var ffi = new CXSRuntime().ffi + var ffi = new VCXRuntime().ffi callback = Callback('void', ['uint32', 'uint32', 'uint32'], function (handle, err, data) { /* tslint:disable */ console.log('commandHandle: ' + handle) /* tslint:enable */ }) - const res = await ffi.cxs_issuer_create_claim(0, 'sourceId', 32, 'regularstring', 'regularstring', 'regularstring', callback) + const res = await ffi.vcx_issuer_create_claim(0, 'sourceId', 32, 'regularstring', 'regularstring', 'regularstring', callback) assert.equal(res, 0) }) }) diff --git a/cxs/wrappers/node/test/issuerClaimTest.js b/vcx/wrappers/node/test/issuerClaimTest.js similarity index 92% rename from cxs/wrappers/node/test/issuerClaimTest.js rename to vcx/wrappers/node/test/issuerClaimTest.js index 81fc70cf46..addaa103cd 100644 --- a/cxs/wrappers/node/test/issuerClaimTest.js +++ b/vcx/wrappers/node/test/issuerClaimTest.js @@ -1,9 +1,9 @@ const assert = require('chai').assert const expect = require('chai').expect -const cxs = require('../dist') -const { stubInitCXS, shouldThrow } = require('./helpers') +const vcx = require('../dist') +const { stubInitVCX, shouldThrow } = require('./helpers') -const { IssuerClaim, Connection, StateType, Error } = cxs +const { IssuerClaim, Connection, StateType, Error } = vcx const config = { sourceId: 'jsonCreation', @@ -33,8 +33,8 @@ describe('An issuerClaim', async function () { this.timeout(30000) before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') }) it('can be created.', async function () { @@ -113,7 +113,7 @@ describe('An issuerClaim', async function () { try { await claim.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_issuer_claim_serialize -> ' + Error.INVALID_ISSUER_CLAIM_HANDLE) + assert.equal(error.toString(), 'Error: vcx_issuer_claim_serialize -> ' + Error.INVALID_ISSUER_CLAIM_HANDLE) } }) @@ -153,7 +153,7 @@ describe('An issuerClaim', async function () { try { await claim.sendClaim(connection) } catch (error) { - assert.equal(error.toString(), 'Error: cxs_issuer_send_claim -> ' + Error.INVALID_ISSUER_CLAIM_HANDLE) + assert.equal(error.toString(), 'Error: vcx_issuer_send_claim -> ' + Error.INVALID_ISSUER_CLAIM_HANDLE) } }) @@ -165,7 +165,7 @@ describe('An issuerClaim', async function () { try { await claim.sendClaim(releasedConnection) } catch (error) { - assert.equal(error.toString(), 'Error: cxs_issuer_send_claim -> ' + Error.INVALID_CONNECTION_HANDLE) + assert.equal(error.toString(), 'Error: vcx_issuer_send_claim -> ' + Error.INVALID_CONNECTION_HANDLE) } }) @@ -174,10 +174,10 @@ describe('An issuerClaim', async function () { const sourceId = 'Claim' const claim = await IssuerClaim.create({ ...config, sourceId }) const error = await shouldThrow(() => claim.sendClaim(connection)) - assert.equal(error.toString(), 'Error: cxs_issuer_send_claim -> ' + Error.NOT_READY) + assert.equal(error.toString(), 'Error: vcx_issuer_send_claim -> ' + Error.NOT_READY) }) - it('sending claim with valid claim offer should have state CxsStateAccepted', async function () { + it('sending claim with valid claim offer should have state VcxStateAccepted', async function () { let connection = await Connection.create({id: '123'}) await connection.connect({ sms: true }) const sourceId = 'Claim' @@ -185,7 +185,7 @@ describe('An issuerClaim', async function () { await claim.sendOffer(connection) assert.equal(await claim.getState(), StateType.OfferSent) // we serialize and deserialize because this is the only - // way to fool the libcxs into thinking we've received a + // way to fool the libvcx into thinking we've received a // valid claim requset. let jsonClaim = await claim.serialize() jsonClaim.state = StateType.RequestReceived diff --git a/cxs/wrappers/node/test/proofTest.js b/vcx/wrappers/node/test/proofTest.js similarity index 93% rename from cxs/wrappers/node/test/proofTest.js rename to vcx/wrappers/node/test/proofTest.js index 379748c223..2530819e5a 100644 --- a/cxs/wrappers/node/test/proofTest.js +++ b/vcx/wrappers/node/test/proofTest.js @@ -1,7 +1,7 @@ const assert = require('chai').assert -const cxs = require('../dist/index') -const { stubInitCXS } = require('./helpers') -const { Connection, Proof, StateType, Error, ProofState } = cxs +const vcx = require('../dist/index') +const { stubInitVCX } = require('./helpers') +const { Connection, Proof, StateType, Error, ProofState } = vcx const ATTR = [{issuerDid: '8XFh8yBzrpJQmNyZzgoTqB', schemaSeqNo: 1, name: 'test'}] const PROOF_MSG = '{"version":"0.1","to_did":"BnRXf8yDMUwGyZVDkSENeq","from_did":"GxtnGN6ypZYgEqcftSQFnC","proof_request_id":"cCanHnpFAD","proofs":{"claim::f22cc7c8-924f-4541-aeff-29a9aed9c46b":{"proof":{"primary_proof":{"eq_proof":{"revealed_attrs":{"state":"96473275571522321025213415717206189191162"},"a_prime":"921....546","e":"158....756","v":"114....069","m":{"address2":"140....691","city":"209....294","address1":"111...738","zip":"149....066"},"m1":"777....518","m2":"515....229"},"ge_proofs":[]},"non_revoc_proof":null},"schema_seq_no":15,"issuer_did":"4fUDR9R7fjwELRvH9JT6HH"}},"aggregated_proof":{"c_hash":"25105671496406009212798488318112715144459298495509265715919744143493847046467","c_list":[[72,245,38,"....",46,195,18]]},"requested_proof":{"revealed_attrs":{"attr_key_id":["claim::f22cc7c8-924f-4541-aeff-29a9aed9c46b","UT","96473275571522321025213415717206189191162"]},"unrevealed_attrs":{},"self_attested_attrs":{},"predicates":{}}}' @@ -10,8 +10,8 @@ describe('A Proof', function () { this.timeout(30000) before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') }) it('can be created.', async () => { @@ -59,7 +59,7 @@ describe('A Proof', function () { try { await proof.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_proof_serialize -> 1017') + assert.equal(error.toString(), 'Error: vcx_proof_serialize -> 1017') } }) @@ -89,7 +89,7 @@ describe('A Proof', function () { try { await proof.requestProof(connection) } catch (err) { - assert.equal(err.toString(), 'Error: cxs_proof_send_request -> 1003') + assert.equal(err.toString(), 'Error: vcx_proof_send_request -> 1003') } }) @@ -103,7 +103,7 @@ describe('A Proof', function () { try { await proof.requestProof(connection) } catch (err) { - assert.equal(err.toString(), 'Error: cxs_proof_send_request -> 1017') + assert.equal(err.toString(), 'Error: vcx_proof_send_request -> 1017') } }) diff --git a/cxs/wrappers/node/test/schemaTest.js b/vcx/wrappers/node/test/schemaTest.js similarity index 92% rename from cxs/wrappers/node/test/schemaTest.js rename to vcx/wrappers/node/test/schemaTest.js index ce0912a132..01a2aa6bb2 100644 --- a/cxs/wrappers/node/test/schemaTest.js +++ b/vcx/wrappers/node/test/schemaTest.js @@ -1,7 +1,7 @@ const assert = require('chai').assert -const cxs = require('../dist/index') -const { stubInitCXS } = require('./helpers') -const { Schema, Error } = cxs +const vcx = require('../dist/index') +const { stubInitVCX } = require('./helpers') +const { Schema, Error } = vcx const SCHEMA = { sourceId: 'sourceId', @@ -16,8 +16,8 @@ describe('A Shema', function () { this.timeout(30000) before(async () => { - stubInitCXS() - await cxs.initCxs('ENABLE_TEST_MODE') + stubInitVCX() + await vcx.initVcx('ENABLE_TEST_MODE') }) it('can be created.', async () => { @@ -61,7 +61,7 @@ describe('A Shema', function () { try { await schema.serialize() } catch (error) { - assert.equal(error.toString(), 'Error: cxs_schema_serialize -> 1042') + assert.equal(error.toString(), 'Error: vcx_schema_serialize -> 1042') } }) diff --git a/cxs/wrappers/node/tsconfig.json b/vcx/wrappers/node/tsconfig.json similarity index 100% rename from cxs/wrappers/node/tsconfig.json rename to vcx/wrappers/node/tsconfig.json diff --git a/cxs/wrappers/node/tslint.json b/vcx/wrappers/node/tslint.json similarity index 100% rename from cxs/wrappers/node/tslint.json rename to vcx/wrappers/node/tslint.json diff --git a/cxs/wrappers/python3/.gitignore b/vcx/wrappers/python3/.gitignore similarity index 100% rename from cxs/wrappers/python3/.gitignore rename to vcx/wrappers/python3/.gitignore diff --git a/cxs/wrappers/python3/MANIFEST.in b/vcx/wrappers/python3/MANIFEST.in similarity index 100% rename from cxs/wrappers/python3/MANIFEST.in rename to vcx/wrappers/python3/MANIFEST.in diff --git a/cxs/wrappers/python3/README.md b/vcx/wrappers/python3/README.md similarity index 100% rename from cxs/wrappers/python3/README.md rename to vcx/wrappers/python3/README.md diff --git a/cxs/wrappers/python3/cxs/__init__.py b/vcx/wrappers/python3/cxs/__init__.py similarity index 100% rename from cxs/wrappers/python3/cxs/__init__.py rename to vcx/wrappers/python3/cxs/__init__.py diff --git a/cxs/wrappers/python3/requirements.txt b/vcx/wrappers/python3/requirements.txt similarity index 100% rename from cxs/wrappers/python3/requirements.txt rename to vcx/wrappers/python3/requirements.txt diff --git a/cxs/wrappers/python3/setup.py b/vcx/wrappers/python3/setup.py similarity index 100% rename from cxs/wrappers/python3/setup.py rename to vcx/wrappers/python3/setup.py diff --git a/cxs/wrappers/python3/tests/test_cxs_init.py b/vcx/wrappers/python3/tests/test_cxs_init.py similarity index 100% rename from cxs/wrappers/python3/tests/test_cxs_init.py rename to vcx/wrappers/python3/tests/test_cxs_init.py