diff --git a/README_ACAPy-Integration.md b/README_ACAPy-Integration.md new file mode 100644 index 00000000..d7d1d188 --- /dev/null +++ b/README_ACAPy-Integration.md @@ -0,0 +1,224 @@ + +# Run ACA-Py-agent + +```bash +git clone https://github.com/hyperledger/aries-cloudagent-python.git + +cd aries-cloudagent-python + +PORTS="8030:8030 8031:8031" ./scripts/run_docker start \ +--endpoint http://192.168.0.104:8030 \ +--label alice.agent \ +--inbound-transport http 0.0.0.0 8030 \ +--outbound-transport http \ +--admin 0.0.0.0 8031 \ +--admin-insecure-mode \ +--wallet-type indy \ +--wallet-name alice.agent420695 \ +--wallet-key alice.agent420695 \ +--preserve-exchange-records \ +--auto-provision \ +--genesis-url http://dev.greenlight.bcovrin.vonx.io/genesis \ +--trace-target log \ +--trace-tag acapy.events \ +--trace-label alice.agent.trace \ +--auto-ping-connection \ +--log-level DEBUG \ +--trace-target log \ +--trace-tag acapy.events \ +--trace-label alice.agent.trace \ +--auto-accept-invites \ +--auto-accept-requests \ +--auto-store-credential \ +--auto-respond-messages \ +--recreate-wallet \ +--replace-public-did \ +--invite-public +``` +# Create invitation (auto_accept=TRUE) +```bash +curl -X POST "http://localhost:8031/connections/create-invitation?alias=abc&auto_accept=true&multi_use=false" -H "accept: application/json" -H "Content-Type: application/json" -d "{}" +``` + +# Generate local DID +```bash +curl -X GET "http://localhost:8031/wallet/did" -H "accept: application/json" +``` + +# Register DID in http://dev.greenlight.bcovrin.vonx.io/ + +```bash +curl -X POST "http://localhost:8031/wallet/did/public?did=8XPCojrpqe6mpNd7nNEywf" -H "accept: application/json" +``` + +# Create simple schema +```bash +curl -X POST http://localhost:8031/schemas \ +-H 'Content-Type: application/json' \ +-d '{ +"attributes": [ +"name", +"date", +"degree", +"age" +], +"schema_name": "my-schema", +"schema_version": "1.0" +}' +``` + +# Create credential definition +```bash +curl -X POST http://localhost:8031/credential-definitions \ +-H 'Content-Type: application/json' \ +-d '{ +"schema_id": "8XPCojrpqe6mpNd7nNEywf:2:my-schema:1.0", +"tag": "default" +}' +``` + +# Offer js template +```json +{ + "comment": "string", + "credential_proposal": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/credential-preview", + "attributes": [{ + "name": "name", + "value": "Alice Smith" + }, + { + "name": "date", + "value": "2020-01-01" + }, + { + "name": "degree", + "value": "Maths" + }, + { + "name": "age", + "value": "24" + } + ] + }, + "schema_issuer_did": "UPDNa6DA2ddQrmXM1XZwtj", + "connection_id": "1895e3ef-e7f1-4510-958a-76b952c75677", + "schema_version": "18.8.9", + "schema_id": "UPDNa6DA2ddQrmXM1XZwtj:2:degree schema:18.8.9", + "issuer_did": "UPDNa6DA2ddQrmXM1XZwtj", + "cred_def_id": "UPDNa6DA2ddQrmXM1XZwtj:3:CL:18:default", + "schema_name": "degree schema" +} +``` + +# Create offer +```bash +curl -X POST "http://localhost:8031/issue-credential/create-offer" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"auto_issue\": true, \"auto_remove\": true, \"comment\": \"string\", \"cred_def_id\": \"8XPCojrpqe6mpNd7nNEywf:3:CL:100226:default\", \"credential_preview\": { \"@type\": \"issue-credential/1.0/credential-preview\", \"attributes\": [ {\"mime-type\": \"plain/text\", \"name\": \"name\", \"value\": \"Alice Smith\" }, {\"mime-type\": \"plain/text\", \"name\": \"date\", \"value\": \"2020-01-01\" }, {\"mime-type\": \"plain/text\", \"name\": \"degree\", \"value\": \"Maths\" }, { \"mime-type\": \"plain/text\", \"name\": \"age\", \"value\": \"24\" } ] }, \"trace\": true}" +``` + +# Check connection id necessary for sending an offer +```bash +curl -X GET "http://localhost:8031/connections" -H "accept: application/json" +``` + +# Send an offer +```bash +curl -X POST "http://localhost:8031/issue-credential/send-offer" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"auto_issue\": true, \"auto_remove\": true, \"comment\": \"string\", \"connection_id\": \"9dddf8a4-fadd-4b33-985d-956363b87627\", \"cred_def_id\": \"8XPCojrpqe6mpNd7nNEywf:3:CL:100226:default\", \"credential_preview\": { \"@type\": \"issue-credential/1.0/credential-preview\", \"attributes\": [ { \"mime-type\": \"plain/text\", \"name\": \"name\", \"value\": \"Alice Smith\" }, { \"mime-type\": \"plain/text\",\"name\": \"date\", \"value\": \"2020-01-01\" }, {\"mime-type\": \"plain/text\", \"name\": \"degree\", \"value\": \"Maths\" }, {\"mime-type\": \"plain/text\", \"name\": \"age\", \"value\": \"24\" } ] }, \"trace\": true}" +``` + +# Js template for sening a proof + +```json +{ + "comment": "string", + "connection_id": "928db78f-f604-468d-a628-37bb1aa18959", + "proof_request": { + "name": "Proof request", + "nonce": "1", + "requested_attributes": { + "0_name_uuid": { + "names": [ + "name" + ], + "restrictions": [ + { + "cred_def_id": "TudtWPvPFnQgCkafqYi556:3:CL:100049:default" + } + ] + } + }, + "requested_predicates": { + "0_age_GE_uuid": { + "name": "age", + "p_type": "<=", + "p_value": 24, + "restrictions": [ + { + "cred_def_id": "TudtWPvPFnQgCkafqYi556:3:CL:100049:default" + } + ] + } + }, + "version": "1.0" + }, + "trace": false +} +``` + +# Send a proof to verifier and store it inside the wallet +```bash +curl -X POST "http://localhost:8031/present-proof/send-request" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"comment\": \"string\", \"connection_id\": \"9dddf8a4-fadd-4b33-985d-956363b87627\", \"proof_request\": { \"name\": \"Proof request\", \"nonce\": \"1\", \"requested_attributes\": { \"0_name_uuid\": { \"names\": [\"name\"], \"restrictions\": [ { \"cred_def_id\": \"8XPCojrpqe6mpNd7nNEywf:3:CL:100226:default\" } ]} }, \"requested_predicates\": { \"0_age_GE_uuid\": { \"name\": \"age\", \"p_type\": \"<=\", \"p_value\": 24, \"restrictions\": [ { \"cred_def_id\": \"8XPCojrpqe6mpNd7nNEywf:3:CL:100226:default\" } ] } }, \"version\": \"1.0\" }, \"trace\": false}" +``` + +# Check present proof requests +```bash +curl -X GET "http://localhost:8031/present-proof/records?connection_id=9dddf8a4-fadd-4b33-985d-956363b87627" -H "accept: application/json" +``` + +# Verify presentation +```bash +curl -X POST "http://localhost:8031/present-proof/records/6963e863-3176-43db-a564-284eeea66a55/verify-presentation" -H "accept: application/json" +``` + +```json +{ + ... + "requested_proof": { + "revealed_attrs": {}, + "revealed_attr_groups": { + "0_name_uuid": { + "sub_proof_index": 0, + "values": { + "name": { + "raw": "Alice Smith", + "encoded": "62816810226936654797779705000772968058283780124309077049681734835796332704413" + } + } + } + }, + "self_attested_attrs": {}, + "unrevealed_attrs": {}, + "predicates": { + "0_age_GE_uuid": { + "sub_proof_index": 0 + } + } + }, + "identifiers": [ + { + "schema_id": "8XPCojrpqe6mpNd7nNEywf:2:my-schema:1.0", + "cred_def_id": "8XPCojrpqe6mpNd7nNEywf:3:CL:100226:default" + } + ] +}, +"updated_at": "2021-10-06 10:37:44.061163Z", +"role": "verifier", +"verified": "true", +"auto_present": false, +"created_at": "2021-10-06 10:34:13.606899Z", +"thread_id": "632effd3-87a9-4550-8e59-5d803aed7ff3", +"initiator": "self", +"trace": false, +"state": "verified" +} +``` \ No newline at end of file diff --git a/acapy.md b/acapy.md new file mode 100644 index 00000000..c2fd18da --- /dev/null +++ b/acapy.md @@ -0,0 +1,121 @@ +##WS Connector (not supported now): +```bash +PORTS="8030:8030 8031:8031" ./scripts/run_docker start \ + --endpoint ws://192.168.0.104:8030 \ + --label alice.agent \ + --inbound-transport ws 0.0.0.0 8030 \ + --outbound-transport ws \ + --admin 0.0.0.0 8031 \ + --admin-insecure-mode \ + --wallet-type indy \ + --wallet-name alice.agent420695 \ + --wallet-key alice.agent420695 \ + --preserve-exchange-records \ + --auto-provision \ + --genesis-url http://dev.greenlight.bcovrin.vonx.io/genesis \ + --trace-target log \ + --trace-tag acapy.events \ + --trace-label alice.agent.trace \ + --auto-ping-connection \ + --auto-respond-messages \ + --auto-accept-invites \ + --auto-accept-requests \ + --debug-credentials \ + --log-level DEBUG +``` +##HTTP Connector: +```bash +PORTS="8030:8030 8031:8031" ./scripts/run_docker start \ + --endpoint http://192.168.0.104:8030 \ + --label alice.agent \ + --inbound-transport http 0.0.0.0 8030 \ + --outbound-transport http \ + --admin 0.0.0.0 8031 \ + --admin-insecure-mode \ + --wallet-type indy \ + --wallet-name alice.agent420695 \ + --wallet-key alice.agent420695 \ + --preserve-exchange-records \ + --wallet-local-did \ + --auto-provision \ + --genesis-url http://dev.greenlight.bcovrin.vonx.io/genesis \ + --trace-target log \ + --trace-tag acapy.events \ + --trace-label alice.agent.trace \ + --auto-ping-connection \ + --log-level DEBUG \ + --trace-target log \ + --trace-tag acapy.events \ + --trace-label alice.agent.trace \ + --recreate-wallet \ + --auto-accept-invites \ + --auto-accept-requests \ + --auto-store-credential \ + --auto-respond-messages +``` +##Create invitation (with auto_accept = TRUE): +```bash + curl -X POST "http://localhost:8031/connections/create-invitation?auto_accept=true&multi_use=false" -H "accept: application/json" -H "Content-Type: application/json" -d "{}" +``` +##Get DID: +```bash +curl -X GET "http://localhost:8031/wallet/did" -H "accept: application/json" +``` +##Register DID at http://dev.greenlight.bcovrin.vonx.io/ + +##Set public DID: +```bash +curl -X POST "http://localhost:8031/wallet/did/public?did=MdaRwvD9nXVuNKWsV8bsi5" -H "accept: application/json" +``` +##Create schema: +```bash +curl -X POST http://localhost:8031/schemas \ + -H 'Content-Type: application/json' \ + -d '{ + "attributes": [ + "name", + "age" + ], + "schema_name": "my-schema", + "schema_version": "1.0" +}' +``` +##Create cred-def: +```bash +curl -X POST http://localhost:8031/credential-definitions \ + -H 'Content-Type: application/json' \ + -d '{ + "schema_id": "MdaRwvD9nXVuNKWsV8bsi5:2:my-schema:1.0", + "tag": "default" + }' +``` +##Send proposal: +```bash +curl -X POST http://localhost:8031/issue-credential-1.0/send-proposal \ + -H "Content-Type: application/json" -d '{ + "comment": "I want this", + "connection_id": "2e0b22de-e4ec-4896-8216-e3a9d1b7d91b", + "credential_preview": { + "@type": "issue-credential/1.0/credential-preview", + "attributes": [ + { + "mime-type": "plain/text", + "name": "name", + "value": "Bob" + }, + { + "mime-type": "plain/text", + "name": "age", + "value": "30" + } + ] + }, + "filter": { + "dif": {}, + "indy": {} + } +}' +``` +```bash +curl -X POST "http://localhost:8031/issue-credential/send-proposal" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"comment\": \"I want this\", \"connection_id\": \"7b978828-db24-490b-9721-b4a7655c7b59\", \"credential_preview\": { \"@type\": \"issue-credential/1.0/credential-preview\", \"attributes\": [ { \"mime-type\": \"plain/text\", \"name\": \"name\", \"value\": \"Bob\" }, { \"mime-type\": \"plain/text\", \"name\": \"age\", \"value\": \"30\" } ] }, \"filter\": { \"dif\": {}, \"indy\": {} }}" +``` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 11a8a875..7b7731d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -93,10 +93,9 @@ kotlin { summary = "Kotlin sample project with CocoaPods dependencies" homepage = "https://github.com/Kotlin/kotlin-with-cocoapods-sample" - ios.deploymentTarget = "12.2" - osx.deploymentTarget = "10.8" + ios.deploymentTarget = "9.0" + osx.deploymentTarget = "10.10" tvos.deploymentTarget = "9.0" - frameworkName = "ssi_agent" podfile = project.file("./samples/swiftIosApp/Podfile") @@ -152,6 +151,9 @@ kotlin { implementation("org.slf4j:slf4j-api:1.7.30") implementation("org.slf4j:slf4j-log4j12:1.8.0-alpha2") implementation("log4j:log4j:1.2.17") + implementation("com.googlecode.json-simple:json-simple:1.1") + implementation("org.eclipse.jetty:jetty-servlet:9.4.3.v20170317") + implementation("org.eclipse.jetty:jetty-server:9.4.3.v20170317") //implementation( "com.sun.jna:jna:3.0.9") diff --git a/files/sovrin_buildernet_genesis.txt b/files/sovrin_buildernet_genesis.txt index baed6fb3..b2548138 100644 --- a/files/sovrin_buildernet_genesis.txt +++ b/files/sovrin_buildernet_genesis.txt @@ -1,4 +1,4 @@ -{"reqSignature":{},"txn":{"data":{"data":{"alias":"FoundationBuilder","blskey":"3gmhmqpPLqznZF3g3niodaHjbpsB6TEeE9SpgXgBnZJLmXgeRzJqTLajVwbhxrkomJFTFU4ohDC4ZRXKbUPCQywJuPAQnst8XBtCFredMECn4Z3goi1mNt5QVRdU8Ue2xMSkdLpsQMjCsNwYUsBguwXYUQnDXQXnHqRkK9qrivucQ5Z","blskey_pop":"RHWacPhUNc9JWsGNdmWYHrAvvhsow399x3ttNKKLDpz9GkxxnTKxtiZqarkx4uP5ByTwF4kM8nZddFKWuzoKizVLttALQ2Sc2BNJfRzzUZMNeQSnESkKZ7U5vE2NhUDff6pjANczrrDAXd12AjSG61QADWdg8CVciZFYtEGmKepwzP","client_ip":"35.161.146.16","client_port":"9702","node_ip":"50.112.53.5","node_port":"9701","services":["VALIDATOR"]},"dest":"GVvdyd7Y6hsBEy5yDDHjqkXgH8zW34K74RsxUiUCZDCE"},"metadata":{"from":"V5qJo72nMeF7x3ci8Zv2WP"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fe991cd590fff10f596bb6fe2362229de47d49dd50748e38b96f368152be29c7"},"ver":"1"} -{"reqSignature":{},"txn":{"data":{"data":{"alias":"vnode1","blskey":"t5jtREu8au2dwFwtH6QWopmTGxu6qmJ3iSnk321yLgeu7mHQRXf2ZCBuez8KCAQvFZGqqAoy2FcYvDGCqQxRCz9qXKgiBtykzxjDjYu87JECwwddnktz5UabPfZmfu6EoDn4rFxvd4myPu2hksb5Z9GT6UeoEYi7Ub3yLFQ3xxaQXc","blskey_pop":"QuHB7tiuFBPQ6zPkwHfMtjzWqXJBLACtfggm7zCRHHgdva18VN4tNg7LUU2FfKGQSLZz1M7oRxhhgJkZLL19aGvaHB2MPtnBWK9Hr8LMiwi95UjX3TVXJri4EvPjQ6UUvHrjZGUFvKQphPyVTMZBJwfkpGAGhpbTQuQpEH7f56m1X5","client_ip":"206.189.143.34","client_port":"9796","node_ip":"206.189.143.34","node_port":"9797","services":["VALIDATOR"]},"dest":"9Aj2LjQ2fwszJRSdZqg53q5e6ayScmtpeZyPGgKDswT8"},"metadata":{"from":"FzAaV9Waa1DccDa72qwg13"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"5afc282bf9a7a5e3674c09ee48e54d73d129aa86aa226691b042e56ff9eaf59b"},"ver":"1"} -{"reqSignature":{},"txn":{"data":{"data":{"alias":"xsvalidatorec2irl","blskey":"4ge1yEvjdcV6sDSqbevqPRWq72SgkZqLqfavBXC4LxnYh4QHFpHkrwzMNjpVefvhn1cgejHayXTfTE2Fhpu1grZreUajV36T6sT4BiewAisdEw59mjMxkp9teYDYLQqwPUFPgaGKDbFCUBEaNdAP4E8Q4UFiF13Qo5842pAY13mKC23","blskey_pop":"R5PoEfWvni5BKvy7EbUbwFMQrsgcuzuU1ksxfvySH6FC5jpmisvcHMdVNik6LMvAeSdt6K4sTLrqnaaQCf5aCHkeTcQRgDVR7oFYgyZCkF953m4kSwUM9QHzqWZP89C6GkBx6VPuL1RgPahuBHDJHHiK73xLaEJzzFZtZZxwoWYABH","client_ip":"52.50.114.133","client_port":"9702","node_ip":"52.209.6.196","node_port":"9701","services":["VALIDATOR"]},"dest":"DXn8PUYKZZkq8gC7CZ2PqwECzUs2bpxYiA5TWgoYARa7"},"metadata":{"from":"QuCBjYx4CbGCiMcoqQg1y"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"1972fce7af84b7f63b7f0c00495a84425cce3b0c552008576e7996524cca04cb"},"ver":"1"} -{"reqSignature":{},"txn":{"data":{"data":{"alias":"danube","blskey":"3Vt8fxn7xg8n8pR872cvGWNuR7STFzFSPMftX96zF6871wYVTR27aspxGSeEtx9wj8g4D3GdCxHJbQ4FsxQz6TATQswiiZfxAVNjLLUci8WSH4t1GPx9CvGXB2uzDfVnnJyhhnASxJEbvykLUBBFG3fW4tMQixujpowUADz5jHm427u","blskey_pop":"RJpXXLkjRRv9Lk8tJz8LTkhhC7RWjHQcB9CG8J8U8fXT6arTDMYc62zXtToBAmGkGu8Udsmo3Hh7mv4KB9JAf8ufGY9WsnppCVwar7zEXyBfLpCnDhvVcBAzkhRpHmqHygN24DeBu9aH6tw4uXxVJvRRGSbPtxjWa379BmfQWzXHCb","client_ip":"207.180.207.73","client_port":"9702","node_ip":"173.249.14.196","node_port":"9701","services":["VALIDATOR"]},"dest":"52muwfE7EjTGDKxiQCYWr58D8BcrgyKVjhHgRQdaLiMw"},"metadata":{"from":"VbPQNHsvoLZdaNU7fTBeFx"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"ebf340b317c044d970fcd0ca018d8903726fa70c8d8854752cd65e29d443686c"},"ver":"1"} \ No newline at end of file +{"reqSignature":{},"txn":{"data":{"data":{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","blskey_pop":"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1","client_ip":"159.203.21.90","client_port":9702,"node_ip":"159.203.21.90","node_port":9701,"services":["VALIDATOR"]},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"},"metadata":{"from":"Th7MpTaRZVRYnPiabds81Y"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"},"ver":"1"} +{"reqSignature":{},"txn":{"data":{"data":{"alias":"Node2","blskey":"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk","blskey_pop":"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5","client_ip":"159.203.21.90","client_port":9704,"node_ip":"159.203.21.90","node_port":9703,"services":["VALIDATOR"]},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb"},"metadata":{"from":"EbP4aYNeTHL6q385GuVpRV"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc"},"ver":"1"} +{"reqSignature":{},"txn":{"data":{"data":{"alias":"Node3","blskey":"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5","blskey_pop":"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh","client_ip":"159.203.21.90","client_port":9706,"node_ip":"159.203.21.90","node_port":9705,"services":["VALIDATOR"]},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya"},"metadata":{"from":"4cU41vWW82ArfxJxHkzXPG"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4"},"ver":"1"} +{"reqSignature":{},"txn":{"data":{"data":{"alias":"Node4","blskey":"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw","blskey_pop":"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP","client_ip":"159.203.21.90","client_port":9708,"node_ip":"159.203.21.90","node_port":9707,"services":["VALIDATOR"]},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA"},"metadata":{"from":"TWwCRQRZ2ZHMJFn9TzLp7W"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008"},"ver":"1"} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8490e139..7a541c8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,3 +3,4 @@ kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.native.enableDependencyPropagation=false android.useAndroidX=true org.gradle.jvmargs=-Xmx2560m +kotlin.native.cacheKind.iosX64=none \ No newline at end of file diff --git a/kotlin_multiplatform_agent.podspec b/kotlin_multiplatform_agent.podspec index d274eb82..86d4da89 100644 --- a/kotlin_multiplatform_agent.podspec +++ b/kotlin_multiplatform_agent.podspec @@ -12,8 +12,8 @@ Pod::Spec.new do |spec| spec.libraries = "c++" spec.module_name = "#{spec.name}_umbrella" - spec.ios.deployment_target = '12.2' - spec.osx.deployment_target = '10.8' + spec.ios.deployment_target = '9.0' + spec.osx.deployment_target = '10.10' spec.tvos.deployment_target = '9.0' spec.dependency 'PocketSocket' diff --git a/libindy-pod/Podfile b/libindy-pod/Podfile index 9b544f16..87452a9d 100644 --- a/libindy-pod/Podfile +++ b/libindy-pod/Podfile @@ -1,5 +1,6 @@ source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/hyperledger/indy-sdk.git' +source 'https://github.com/AFNetworking/AFNetworking.git' platform :ios, '10.2' workspace 'Indy.xcworkspace' @@ -9,6 +10,7 @@ def appPods pod 'libzmq-pw', "4.2.2" pod 'OpenSSL-XM' pod 'libindy', "1.15.0" + pod 'AFNetworking', '~> 4.0.1' end target 'Indy-demo' do diff --git a/libindy-pod/Podfile.lock b/libindy-pod/Podfile.lock index 4fedf164..0527c764 100644 --- a/libindy-pod/Podfile.lock +++ b/libindy-pod/Podfile.lock @@ -1,4 +1,19 @@ PODS: + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): + - AFNetworking/NSURLSession - CoreBitcoin (0.6.8.1): - ISO8601DateFormatter - OpenSSL-Universal (= 1.0.1.16) @@ -10,6 +25,7 @@ PODS: - OpenSSL-XM (1.0.210.1) DEPENDENCIES: + - AFNetworking (~> 4.0.1) - CoreBitcoin (from `https://raw.github.com/oleganza/CoreBitcoin/master/CoreBitcoin.podspec`) - libindy (= 1.15.0) - libsodium (~> 1.0.12) @@ -18,6 +34,7 @@ DEPENDENCIES: SPEC REPOS: https://github.com/CocoaPods/Specs.git: + - AFNetworking - ISO8601DateFormatter - libsodium - OpenSSL-Universal @@ -31,6 +48,7 @@ EXTERNAL SOURCES: :podspec: https://raw.github.com/oleganza/CoreBitcoin/master/CoreBitcoin.podspec SPEC CHECKSUMS: + AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce CoreBitcoin: 4ac6f6a61e543f08399c2fe57496d4fdcbaf74f9 ISO8601DateFormatter: 4551b6ce4f83185425f583b0b3feb3c7b59b942c libindy: 11318335b528494a6155943c4cc6579926cee7e3 @@ -39,6 +57,6 @@ SPEC CHECKSUMS: OpenSSL-Universal: 85ef63bf81d0741b03c8719cd29685c37c59518d OpenSSL-XM: f2d7697be2a4b01a2c62239fd577e4137cab4f3a -PODFILE CHECKSUM: 0a8f96afcfb11e7ccc903389bb274981430ae9d7 +PODFILE CHECKSUM: 212fdca7ab7526fd25b2db67240614e37b173855 COCOAPODS: 1.10.1 diff --git a/samples/swiftIosApp/Podfile b/samples/swiftIosApp/Podfile index 78108f30..673777d9 100644 --- a/samples/swiftIosApp/Podfile +++ b/samples/swiftIosApp/Podfile @@ -7,9 +7,10 @@ target 'swiftIosApp' do pod 'libsodium', '~> 1.0.12' pod 'libzmq-pw', "4.2.2" pod 'PocketSocket', '1.0.1' - pod 'ssi_agent', "0.0.11", :source => "https://github.com/Lumedic/ssi-mobile-sdk.git" + pod 'AFNetworking', '4.0.1' + #pod 'ssi_agent', "0.0.11", :source => "https://github.com/Lumedic/ssi-mobile-sdk.git" #Comment out line above and uncomment 3 lines below for local build - #pod 'kotlin_multiplatform_agent', :path => '../../' + pod 'kotlin_multiplatform_agent', :path => '../../' #pod 'OpenSSL-XM', '~> 1.0.210.1' #pod 'libindy', "1.15.0" diff --git a/samples/swiftIosApp/Podfile.lock b/samples/swiftIosApp/Podfile.lock index e4697c59..701e5514 100644 --- a/samples/swiftIosApp/Podfile.lock +++ b/samples/swiftIosApp/Podfile.lock @@ -1,6 +1,22 @@ PODS: + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): + - AFNetworking/NSURLSession - kotlin_multiplatform_agent (1.0-SNAPSHOT): - - PocketSocket/Client + - AFNetworking + - PocketSocket - libsodium (1.0.12) - libzmq-pw (4.2.2) - PocketSocket (1.0.1): @@ -14,6 +30,7 @@ PODS: - PocketSocket/Client DEPENDENCIES: + - AFNetworking (= 4.0.1) - kotlin_multiplatform_agent (from `../../`) - libsodium (~> 1.0.12) - libzmq-pw (= 4.2.2) @@ -21,6 +38,7 @@ DEPENDENCIES: SPEC REPOS: https://github.com/CocoaPods/Specs.git: + - AFNetworking - libsodium - PocketSocket https://github.com/hyperledger/indy-sdk.git: @@ -31,11 +49,12 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - kotlin_multiplatform_agent: c32bcd33881e8d8d10efc3b8c543490e02eaafba + AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce + kotlin_multiplatform_agent: 119e345f384e3b13edb0b5484b2ded201f818f91 libsodium: 9a8faa5ef2fa0d2d57bd7f7d79bf8fb7c1a9f0ea libzmq-pw: 493d316cf7f91117bce03df7588b3a7ff0f4a797 PocketSocket: 9c6867d66fb4f962af96b9b07f4b45bb561b2c2a -PODFILE CHECKSUM: ff15c8b202149f736578e4b4c19db9746ab76fc7 +PODFILE CHECKSUM: ddd179987db5fb3f2518d82c9e970b9a1870227d COCOAPODS: 1.10.1 diff --git a/samples/swiftIosApp/swiftIosApp/AppDelegate.swift b/samples/swiftIosApp/swiftIosApp/AppDelegate.swift index 604da524..913f931a 100644 --- a/samples/swiftIosApp/swiftIosApp/AppDelegate.swift +++ b/samples/swiftIosApp/swiftIosApp/AppDelegate.swift @@ -27,6 +27,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + ToBeReworked.init().enableIndyLog() + let cic = ConnectionInitiatorControllerImpl() let crc = CredentialReceiverControllerImpl() let cpc = CredPresenterControllerImpl() @@ -106,12 +108,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { Logger.logMessageDebug(message: "Before creating ssiAgentApi", tag: "INIT", throwable: nil) + let tpc = TrustPingControllerImpl() ssiAgentApi = SsiAgentBuilderImpl(walletConnector: indyWalletConnector) .withConnectionInitiatorController(connectionInitiatorController: cic) .withCredReceiverController(credReceiverController: crc) .withCredPresenterController(credPresenterController: cpc) .withLedgerConnector(ledgerConnector: indyLedgerConnector) + .withTrustPingController(trustPingController: tpc) .build() @@ -133,6 +137,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } +} +class TrustPingControllerImpl: TrustPingController +{ + func onTrustPingReceived(connection: PeerConnection) -> ActionResult { + print("Connection onTrustPingReceived ") + return ActionResult(connection: connection, trustPingSuccessful: true) + } + + func onTrustPingResponseDidNotReceived(connection: PeerConnection) { + print("Connection onTrustPingResponseDidNotReceived") + } + + func onTrustPingResponseReceived(connection: PeerConnection) { + print("Connection onTrustPingResponseReceived") + } + + func onTrustPingSent(connection: PeerConnection) { + print("Connection onTrustPingSent") + } + + } func getEnvironmentVar(_ name: String) -> String? { @@ -143,7 +168,9 @@ func getEnvironmentVar(_ name: String) -> String? { class ConnectionInitiatorControllerImpl: ConnectionInitiatorController { func onFailure(connection: PeerConnection?, error: DidExchangeError, message: String?, details: String?, stackTrace: String?) { - + print("Connection failure", message) + print("Connection failure", details) + print("Connection failure", stackTrace) print("Connection failure", error) } @@ -183,7 +210,7 @@ class LibraryStateListenerImpl : LibraryStateListener { print("Library initialized") Logger.logMessageDebug(message: "Listener: Initialization completed", tag: "INIT", throwable: nil) - let connection = ssiAgentApi.unsafelyUnwrapped.connect(url: "wss://lce-agent-dev.lumedic.io/ws?c_i=eyJsYWJlbCI6IkNsb3VkIEFnZW50IiwiaW1hZ2VVcmwiOm51bGwsInNlcnZpY2VFbmRwb2ludCI6IndzczovL2xjZS1hZ2VudC1kZXYubHVtZWRpYy5pby93cyIsInJvdXRpbmdLZXlzIjpbIjVoUDdreEFDQnpGVXJQSmo0VkhzMTdpRGJ0TU1wclZRSlFTVm84dnZzdGdwIl0sInJlY2lwaWVudEtleXMiOlsiRkdTOXZYTm1lMWQydVozV1BDcDdFZXJzd1A1MUI5M1k0RllvdGJaSmZKcXoiXSwiQGlkIjoiYWY2MTE4ZWMtNDk1Yi00ZjU1LWFmNGUtYzA3OTk0ZDA4MDMxIiwiQHR5cGUiOiJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiJ9", keepConnectionAlive: true) + let connection = ssiAgentApi.unsafelyUnwrapped.connect(url: "http://192.168.0.104:8024?c_i=eyJAdHlwZSI6ICJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiOGRlZTNjY2ItZmNjYy00MzhjLTkyNDYtYWUxOWM3ZmQ3NGVjIiwgImxhYmVsIjogImZhYmVyLmFnZW50IiwgInNlcnZpY2VFbmRwb2ludCI6ICJodHRwOi8vMTkyLjE2OC4wLjEwNDo4MDI0IiwgInJvdXRpbmdLZXlzIjogWyJBV2R2bU44MXU0Nko4MlZZR2pzRFVSd3ZycmRTSFNmY1djSjEzdW05RGRpWiJdLCAicmVjaXBpZW50S2V5cyI6IFsiNnVIWjNETmMxalZqWGdFWlZhd3hTOFhyYjdMUm1kdzlTTjJEb0sxRVg5VTIiXX0=", keepConnectionAlive: true) //Sleeper().sleep(value: 5000) // ssiAgentApi.unsafelyUnwrapped.abandonConnection(connection: connection.unsafelyUnwrapped, force: true, notifyPeerBeforeAbandoning: false) diff --git a/src/androidTest/java/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt b/src/androidTest/java/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt index bba827d2..5733728c 100644 --- a/src/androidTest/java/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt +++ b/src/androidTest/java/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt @@ -122,9 +122,6 @@ class SsiAgentApiImplTest { ssiAgentApi.init(object : LibraryStateListener { override fun initializationCompleted() { -// ssiAgentApi.abandonAllConnections(force = true, notifyPeerBeforeAbandoning = false) - - logger.d { "Connecting to issuer" } val connection = ssiAgentApi.connect(issuerInvitationUrl, keepConnectionAlive = true) logger.d { "Connected to issuer" } @@ -170,11 +167,11 @@ class SsiAgentApiImplTest { } override fun onDone(connection: PeerConnection) { - + logger.d { "Accepting onDone" } } override fun onProblemReportGenerated(connection: PeerConnection, problemReport: ProblemReport) { - + logger.d { "Accepting onProblemReportGenerated" } } } @@ -205,21 +202,23 @@ class SsiAgentApiImplTest { connection: PeerConnection, credentialRequestContainer: CredentialRequestContainer ){ - + logger.d { "Accepting onOfferReceived onRequestSent" } } override fun onCredentialReceived( connection: PeerConnection, credentialContainer: CredentialContainer ): CallbackResult { + logger.d { "Accepting onOfferReceived onCredentialReceived" } return CallbackResult(true) } override fun onDone(connection: PeerConnection, credentialContainer: CredentialContainer) { - + logger.d { "Accepting onOfferReceived onDone" } } override fun onProblemReport(connection: PeerConnection, problemReport: ProblemReport): CallbackResult { + logger.d { "Accepting onOfferReceived onProblemReport" } TODO("Not yet implemented") } @@ -263,6 +262,7 @@ class SsiAgentApiImplTest { details: String?, stackTrace: String? ) { + logger.d { "onFailure" } TODO("Not yet implemented") } diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveConnectionResponseAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveConnectionResponseAction.kt index 66fe47ff..eb3e6de6 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveConnectionResponseAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveConnectionResponseAction.kt @@ -32,7 +32,6 @@ class ReceiveConnectionResponseAction( val connectionResponse = json.decodeFromString(messageContext!!.receivedUnpackedMessage!!.message) - val ourConnectionId = connectionResponse.thread.thid val ourConnection = walletConnector.walletHolder.getConnectionRecordById(ourConnectionId) @@ -57,7 +56,7 @@ class ReceiveConnectionResponseAction( } PeerConnectionState.ABANDONED -> return ActionResult(ourConnection) - else -> TODO("Not implemented") // process different possibilities here according to state diagram + else -> TODO("Not implemented") } diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveInvitationAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveInvitationAction.kt index a479ff51..c8346e19 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveInvitationAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/didexchange/impl/ReceiveInvitationAction.kt @@ -55,6 +55,8 @@ class ReceiveInvitationAction( val connectionId = uuid4().toString() + println(invitationUrl) + println(encodedInvitation) connection = PeerConnection( id = connectionId, state = PeerConnectionState.INVITATION_RECEIVED, invitation = this.invitationUrl, @@ -77,6 +79,9 @@ class ReceiveInvitationAction( val connectionRequestJson = Json.encodeToString(connectionRequest) logger.d { "Connection request: $connectionRequestJson" } + println("<<<<<<<<<<<<<<<<<<") + println(connectionId) + println("<<<<<<<<<<<<<<<<<<") MessageSender.packAndSendMessage( Message(connectionRequestJson), connection, walletConnector, transport, services, @@ -127,9 +132,12 @@ class ReceiveInvitationAction( @OptIn(InternalAPI::class) private fun parseInvitationFromInvitationUrl(encodedInvitation: String): Invitation { - val jsonInvitation = Base64.base64StringToPlainString(encodedInvitation) + var jsonInvitation = Base64.base64StringToPlainString(encodedInvitation) + //jsonInvitation = jsonInvitation.replace("}",",\"routingKeys\":[\"DpKFzS83aZZf3ti4DSMKKGRyWcmgBYchETeWGNRWoPaz\"]}" ) + val res = Json { ignoreUnknownKeys = true }.decodeFromString(jsonInvitation) + //res.routingKeys = listOf("DpKFzS83aZZf3ti4DSMKKGRyWcmgBYchETeWGNRWoPaz") logger.d { "JSON invitation $jsonInvitation" } - return Json { ignoreUnknownKeys = true }.decodeFromString(jsonInvitation) + return res } private fun buildConnectionRequest(invitation: Invitation, connectionId: String): ConnectionRequest { @@ -178,7 +186,7 @@ class ReceiveInvitationAction( priority = 0, recipientKeys = listOf(walletConnector.walletHolder.getIdentityDetails().verkey), //TODO: remove this randomness once agent is fixed - serviceEndpoint = "ws://test${Random.nextInt(1000, 100000)}:8123" + serviceEndpoint = "http://192.168.0.104:8123" ) return listOf(service) diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/issue/impl/ReceiveCredentialAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/issue/impl/ReceiveCredentialAction.kt index d6131c15..6e515a99 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/issue/impl/ReceiveCredentialAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/issue/impl/ReceiveCredentialAction.kt @@ -7,10 +7,12 @@ import com.dxc.ssi.agent.didcomm.actions.issue.CredentialIssuenceAction import com.dxc.ssi.agent.didcomm.commoon.MessageSender import com.dxc.ssi.agent.didcomm.constants.toProblemReportDescription import com.dxc.ssi.agent.didcomm.model.ack.Ack +import com.dxc.ssi.agent.didcomm.model.common.Thread import com.dxc.ssi.agent.didcomm.model.issue.container.CredentialContainer import com.dxc.ssi.agent.didcomm.model.problem.ProblemReport import com.dxc.ssi.agent.didcomm.states.issue.CredentialIssuenceState import com.dxc.ssi.agent.model.messages.Message +import com.dxc.ssi.agent.wallet.indy.model.issue.IndyCredential import com.dxc.utils.Result import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString @@ -60,7 +62,14 @@ class ReceiveCredentialAction( revocationRegistryDefinition = null ) // 4. Build Credential Ack - val credentialAck = Ack(id = uuid4().toString(), thread = credentialContainerMessage.thread) + val idRow = (credential as IndyCredential) + val credentialAck = Ack(id = uuid4().toString(), thread = + Thread(credentialContainerMessage.thread.thid), status = "OK",type = """did:sov:${ + idRow.schemaIdRaw.split( + ":" + )[0] + };spec/issue-credential/1.0/ack""" + ) // 5. Send credential ack val result = MessageSender.packAndSendMessage( @@ -79,6 +88,7 @@ class ReceiveCredentialAction( val problemReport = ProblemReport( id = uuid4().toString(), description = com.dxc.ssi.agent.didcomm.constants.DidCommProblemCodes.COULD_NOT_DELIVER_MESSAGE.toProblemReportDescription() + ) Result.Success(ActionResult()) } diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/trustping/SendTrustPingAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/trustping/SendTrustPingAction.kt index a9ffbf32..c43d723b 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/trustping/SendTrustPingAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/trustping/SendTrustPingAction.kt @@ -37,7 +37,7 @@ class SendTrustPingAction( val trustPingRequest = TrustPingRequest( id = requestId, - responseRequested = true + responseRequested = false ) diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ProcessPresentationRequestAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ProcessPresentationRequestAction.kt index ba8fbe19..b66350d6 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ProcessPresentationRequestAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ProcessPresentationRequestAction.kt @@ -133,6 +133,7 @@ class ProcessPresentationRequestAction( } catch (e: Throwable) { + logger.d { """Issue: ${e.message}""" } val problemReport = ProblemReport( id = uuid4().toString(), description = DidCommProblemCodes.INTERNAL_AGENT_ERROR.toProblemReportDescription(), diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ReceivePresentationAckAction.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ReceivePresentationAckAction.kt index 1db48b3f..a46bd44f 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ReceivePresentationAckAction.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/actions/verify/impl/ReceivePresentationAckAction.kt @@ -1,24 +1,10 @@ package com.dxc.ssi.agent.didcomm.actions.verify.impl -import com.dxc.ssi.agent.api.callbacks.verification.CredPresenterController -import com.dxc.ssi.agent.api.pluggable.LedgerConnector -import com.dxc.ssi.agent.api.pluggable.Transport -import com.dxc.ssi.agent.api.pluggable.wallet.WalletConnector import com.dxc.ssi.agent.didcomm.actions.ActionResult import com.dxc.ssi.agent.didcomm.actions.verify.CredentialVerificationAction -import com.dxc.ssi.agent.model.PeerConnection -/* -class ReceivePresentationAckAction( - private val walletConnector: WalletConnector, - private val ledgerConnector: LedgerConnector, - private val transport: Transport, - private val credPresenterController: CredPresenterController, - private val presentationRequestMessage: PresentationAckContainer, - private val connection: Connection -) : CredentialVerificationAction { - override fun perform(): ActionResult { - TODO("Not implemented") - } +class ReceivePresentationAckAction : CredentialVerificationAction { + override suspend fun perform(): ActionResult { + return(ActionResult()) + } } -*/ \ No newline at end of file diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessagePacker.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessagePacker.kt index fccc10cb..f3373fbb 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessagePacker.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessagePacker.kt @@ -21,29 +21,29 @@ object MessagePacker { ): MessageEnvelop { //TODO: check if we always need to pack our message into forward message - val messageEnvelop = MessageEnvelop( - payload = walletConnector.walletHolder.packMessage( - message, - connection.peerRecipientKeys - ) - ) - - logger.d { "Packed message: ${messageEnvelop.payload}" } - + val messageEnvelop = MessageEnvelop( + payload = walletConnector.walletHolder.packMessage( + message, + connection.peerRecipientKeys + ) + ) + + logger.d { "Packed message: $message" } + logger.d { "Packed message: $connection" } //TODO: understand how to handle case with multiple recepient keys. Should we form forward message for each of those keys? - val forwardMessage = BuildForwardMessage.buildForwardMessage(messageEnvelop, connection.peerRecipientKeys.first()) + //val forwardMessage = BuildForwardMessage.buildForwardMessage(messageEnvelop, connection.peerRecipientKeys.first()) - val outerMessageEnvelop = MessageEnvelop( - payload = walletConnector.walletHolder.packMessage( - Message(Json.encodeToString(forwardMessage)), - connection.peerRecipientKeys, - useAnonCrypt = true - ) - ) +// val outerMessageEnvelop = MessageEnvelop( +// payload = walletConnector.walletHolder.packMessage( +// message, +// connection.peerRecipientKeys, +// useAnonCrypt = true +// ) +// ) - logger.d { "Packed forward message: ${outerMessageEnvelop.payload}" } + logger.d { "Packed forward message: ${messageEnvelop.payload}" } - return outerMessageEnvelop + return messageEnvelop } } \ No newline at end of file diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessageSender.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessageSender.kt index 2b231cf2..a9892391 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessageSender.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/commoon/MessageSender.kt @@ -10,8 +10,10 @@ import com.dxc.ssi.agent.kermit.Severity import com.dxc.ssi.agent.model.ConnectionTransportState import com.dxc.ssi.agent.model.PeerConnection import com.dxc.ssi.agent.model.messages.Message +import com.dxc.ssi.agent.model.messages.MessageEnvelop import com.dxc.utils.Result + //TODO: understand what should be responsibility of this helper and how we can avoid it object MessageSender { @@ -29,6 +31,8 @@ object MessageSender { logger.d { "MessageSender: preparing to pack and send message: $message" } val messageToSend = MessagePacker.packAndPrepareForwardMessage(message, connection, walletConnector) + + println(message) return try { transport.sendMessage(connection, messageToSend) services.connectionsTrackerService!!.setConnectionTransportState(connection, ConnectionTransportState.CONNECTED) diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/ack/Ack.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/ack/Ack.kt index 8c13e209..d07d102d 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/ack/Ack.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/ack/Ack.kt @@ -21,7 +21,8 @@ import kotlinx.serialization.Serializable * */ @Serializable data class Ack( - @Required @SerialName("@type") val type: String = "https://didcomm.org/notification/1.0/ack", + @Required @SerialName("@type") val type: String, @SerialName("@id") val id: String, + @SerialName("status") val status:String, @SerialName("~thread") val thread: Thread? = null ) diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/common/Thread.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/common/Thread.kt index 3c82eaf2..ddd9c71c 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/common/Thread.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/common/Thread.kt @@ -9,3 +9,4 @@ import kotlinx.serialization.Serializable * */ @Serializable data class Thread(val thid: String) + diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/didexchange/Invitation.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/didexchange/Invitation.kt index f194fe24..3b9912b8 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/didexchange/Invitation.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/didexchange/Invitation.kt @@ -31,7 +31,7 @@ data class Invitation( val label: String, @Serializable(with = UrlSerializer::class) val serviceEndpoint: Url, - val recipientKeys: List, - val routingKeys: List, - val imageUrl: String? + var recipientKeys: List, + //var routingKeys: List, //ver key agent + //val imageUrl: String? ) \ No newline at end of file diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/issue/container/CredentialPreview.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/issue/container/CredentialPreview.kt index cc55df80..8b4a8339 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/issue/container/CredentialPreview.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/model/issue/container/CredentialPreview.kt @@ -31,6 +31,6 @@ import kotlinx.serialization.Serializable data class CredentialPreview( //TODO: provide fault and validate it @SerialName("@type") val type: String, - @SerialName("@id") val id: String?, + //@SerialName("@id") val id: String?, val attributes: List ) diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/AbstractMessageProcessor.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/AbstractMessageProcessor.kt index 9d459d03..770a1e25 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/AbstractMessageProcessor.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/AbstractMessageProcessor.kt @@ -52,6 +52,7 @@ abstract class AbstractMessageProcessor( inline fun > getMessageTypeGeneric(message: String): T { + logger.d { "Determined message type: $message" } val typeAttribute = Json { ignoreUnknownKeys = true }.decodeFromString(message).type val messageType = enumValues().single { Regex((it as MessageType).getTypeString()).matches(typeAttribute) } diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/verify/CredVerifierProcessorImpl.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/verify/CredVerifierProcessorImpl.kt index 91a740e3..b37411b6 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/verify/CredVerifierProcessorImpl.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/didcomm/processor/verify/CredVerifierProcessorImpl.kt @@ -14,9 +14,9 @@ import com.dxc.ssi.agent.didcomm.processor.MessageType import com.dxc.ssi.agent.didcomm.processor.Processors import com.dxc.ssi.agent.didcomm.services.Services import com.dxc.ssi.agent.didcomm.states.verify.CredentialVerificationStateMachine -import com.dxc.ssi.agent.kermit.Severity import com.dxc.ssi.agent.model.PresentationRequestResponseAction import com.dxc.ssi.agent.model.messages.Context +import com.dxc.ssi.agent.didcomm.actions.verify.impl.ReceivePresentationAckAction class CredVerifierProcessorImpl( walletConnector: WalletConnector, @@ -43,7 +43,9 @@ class CredVerifierProcessorImpl( PRESENTATION_PROPOSAL("^.*present-proof/1.0/propose-presentation$", { actionParams -> TODO("Not implemented") }), PROBLEM_REPORT("to be done", { actionParams -> kotlin.TODO("Not implemented") }), - PRESENTATION_ACK("to be done", { actionParams -> kotlin.TODO("Not implemented") }); + PRESENTATION_ACK("^.*present-proof/1.0/ack$", { actionParams -> + ReceivePresentationAckAction() + }); override fun getTypeString(): String = _typeString override fun getMessageHandler(): (ActionParams) -> Action = _action diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/ledger/indy/genesis/GenesisGenerator.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/ledger/indy/genesis/GenesisGenerator.kt index 5bf2d665..fd17f8d9 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/ledger/indy/genesis/GenesisGenerator.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/ledger/indy/genesis/GenesisGenerator.kt @@ -47,12 +47,14 @@ class GenesisGenerator( } private val sovrinBuilderNetPoolGenesis = """ - {"reqSignature":{},"txn":{"data":{"data":{"alias":"FoundationBuilder","blskey":"3gmhmqpPLqznZF3g3niodaHjbpsB6TEeE9SpgXgBnZJLmXgeRzJqTLajVwbhxrkomJFTFU4ohDC4ZRXKbUPCQywJuPAQnst8XBtCFredMECn4Z3goi1mNt5QVRdU8Ue2xMSkdLpsQMjCsNwYUsBguwXYUQnDXQXnHqRkK9qrivucQ5Z","blskey_pop":"RHWacPhUNc9JWsGNdmWYHrAvvhsow399x3ttNKKLDpz9GkxxnTKxtiZqarkx4uP5ByTwF4kM8nZddFKWuzoKizVLttALQ2Sc2BNJfRzzUZMNeQSnESkKZ7U5vE2NhUDff6pjANczrrDAXd12AjSG61QADWdg8CVciZFYtEGmKepwzP","client_ip":"35.161.146.16","client_port":"9702","node_ip":"50.112.53.5","node_port":"9701","services":["VALIDATOR"]},"dest":"GVvdyd7Y6hsBEy5yDDHjqkXgH8zW34K74RsxUiUCZDCE"},"metadata":{"from":"V5qJo72nMeF7x3ci8Zv2WP"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fe991cd590fff10f596bb6fe2362229de47d49dd50748e38b96f368152be29c7"},"ver":"1"} - {"reqSignature":{},"txn":{"data":{"data":{"alias":"vnode1","blskey":"t5jtREu8au2dwFwtH6QWopmTGxu6qmJ3iSnk321yLgeu7mHQRXf2ZCBuez8KCAQvFZGqqAoy2FcYvDGCqQxRCz9qXKgiBtykzxjDjYu87JECwwddnktz5UabPfZmfu6EoDn4rFxvd4myPu2hksb5Z9GT6UeoEYi7Ub3yLFQ3xxaQXc","blskey_pop":"QuHB7tiuFBPQ6zPkwHfMtjzWqXJBLACtfggm7zCRHHgdva18VN4tNg7LUU2FfKGQSLZz1M7oRxhhgJkZLL19aGvaHB2MPtnBWK9Hr8LMiwi95UjX3TVXJri4EvPjQ6UUvHrjZGUFvKQphPyVTMZBJwfkpGAGhpbTQuQpEH7f56m1X5","client_ip":"206.189.143.34","client_port":"9796","node_ip":"206.189.143.34","node_port":"9797","services":["VALIDATOR"]},"dest":"9Aj2LjQ2fwszJRSdZqg53q5e6ayScmtpeZyPGgKDswT8"},"metadata":{"from":"FzAaV9Waa1DccDa72qwg13"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"5afc282bf9a7a5e3674c09ee48e54d73d129aa86aa226691b042e56ff9eaf59b"},"ver":"1"} - {"reqSignature":{},"txn":{"data":{"data":{"alias":"xsvalidatorec2irl","blskey":"4ge1yEvjdcV6sDSqbevqPRWq72SgkZqLqfavBXC4LxnYh4QHFpHkrwzMNjpVefvhn1cgejHayXTfTE2Fhpu1grZreUajV36T6sT4BiewAisdEw59mjMxkp9teYDYLQqwPUFPgaGKDbFCUBEaNdAP4E8Q4UFiF13Qo5842pAY13mKC23","blskey_pop":"R5PoEfWvni5BKvy7EbUbwFMQrsgcuzuU1ksxfvySH6FC5jpmisvcHMdVNik6LMvAeSdt6K4sTLrqnaaQCf5aCHkeTcQRgDVR7oFYgyZCkF953m4kSwUM9QHzqWZP89C6GkBx6VPuL1RgPahuBHDJHHiK73xLaEJzzFZtZZxwoWYABH","client_ip":"52.50.114.133","client_port":"9702","node_ip":"52.209.6.196","node_port":"9701","services":["VALIDATOR"]},"dest":"DXn8PUYKZZkq8gC7CZ2PqwECzUs2bpxYiA5TWgoYARa7"},"metadata":{"from":"QuCBjYx4CbGCiMcoqQg1y"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"1972fce7af84b7f63b7f0c00495a84425cce3b0c552008576e7996524cca04cb"},"ver":"1"} - {"reqSignature":{},"txn":{"data":{"data":{"alias":"danube","blskey":"3Vt8fxn7xg8n8pR872cvGWNuR7STFzFSPMftX96zF6871wYVTR27aspxGSeEtx9wj8g4D3GdCxHJbQ4FsxQz6TATQswiiZfxAVNjLLUci8WSH4t1GPx9CvGXB2uzDfVnnJyhhnASxJEbvykLUBBFG3fW4tMQixujpowUADz5jHm427u","blskey_pop":"RJpXXLkjRRv9Lk8tJz8LTkhhC7RWjHQcB9CG8J8U8fXT6arTDMYc62zXtToBAmGkGu8Udsmo3Hh7mv4KB9JAf8ufGY9WsnppCVwar7zEXyBfLpCnDhvVcBAzkhRpHmqHygN24DeBu9aH6tw4uXxVJvRRGSbPtxjWa379BmfQWzXHCb","client_ip":"207.180.207.73","client_port":"9702","node_ip":"173.249.14.196","node_port":"9701","services":["VALIDATOR"]},"dest":"52muwfE7EjTGDKxiQCYWr58D8BcrgyKVjhHgRQdaLiMw"},"metadata":{"from":"VbPQNHsvoLZdaNU7fTBeFx"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"ebf340b317c044d970fcd0ca018d8903726fa70c8d8854752cd65e29d443686c"},"ver":"1"} + {"reqSignature":{},"txn":{"data":{"data":{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","blskey_pop":"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1","client_ip":"159.203.21.90","client_port":9702,"node_ip":"159.203.21.90","node_port":9701,"services":["VALIDATOR"]},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"},"metadata":{"from":"Th7MpTaRZVRYnPiabds81Y"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"},"ver":"1"} + {"reqSignature":{},"txn":{"data":{"data":{"alias":"Node2","blskey":"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk","blskey_pop":"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5","client_ip":"159.203.21.90","client_port":9704,"node_ip":"159.203.21.90","node_port":9703,"services":["VALIDATOR"]},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb"},"metadata":{"from":"EbP4aYNeTHL6q385GuVpRV"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc"},"ver":"1"} + {"reqSignature":{},"txn":{"data":{"data":{"alias":"Node3","blskey":"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5","blskey_pop":"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh","client_ip":"159.203.21.90","client_port":9706,"node_ip":"159.203.21.90","node_port":9705,"services":["VALIDATOR"]},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya"},"metadata":{"from":"4cU41vWW82ArfxJxHkzXPG"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4"},"ver":"1"} + {"reqSignature":{},"txn":{"data":{"data":{"alias":"Node4","blskey":"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw","blskey_pop":"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP","client_ip":"159.203.21.90","client_port":9708,"node_ip":"159.203.21.90","node_port":9707,"services":["VALIDATOR"]},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA"},"metadata":{"from":"TWwCRQRZ2ZHMJFn9TzLp7W"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008"},"ver":"1"} """.trimIndent() + + private val sovrinStagingNetPoolGenesis: String = "Find proper genesis file" diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/transport/AppSocket.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/transport/AppSocket.kt index 6b8909ff..1ab0084c 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/transport/AppSocket.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/transport/AppSocket.kt @@ -3,9 +3,7 @@ package com.dxc.ssi.agent.transport import co.touchlab.stately.isolate.IsolateState import com.dxc.ssi.agent.kermit.Kermit import com.dxc.ssi.agent.kermit.LogcatLogger -import com.dxc.ssi.agent.kermit.Severity import com.dxc.ssi.agent.model.messages.MessageEnvelop -import com.dxc.ssi.agent.utils.CoroutineHelper import com.dxc.ssi.agent.utils.ObjectHolder import com.dxc.utils.System import kotlinx.coroutines.* @@ -32,11 +30,10 @@ class AppSocket(url: String, incomingMessagesChannel: Channel) { private val socketListener: PlatformSocketListener = object : PlatformSocketListener { override fun onOpen() { - currentState = State.CONNECTED - CoroutineHelper.waitForCompletion(CoroutineScope(Dispatchers.Default).async { + GlobalScope.async { socketOpenedChannel.send(SocketOpenedMessage()) - }) + } logger.d { "PlatformSocketListener: ${System.getCurrentThread()} - Opened socket" } } @@ -45,23 +42,23 @@ class AppSocket(url: String, incomingMessagesChannel: Channel) { socketError = t currentState = State.CLOSED logger.d { "PlatformSocketListener: Socket failure: $t \n ${t.stackTraceToString()}" } - CoroutineHelper.waitForCompletion(CoroutineScope(Dispatchers.Default).async { + GlobalScope.async { socketOpenedChannel.send(SocketFailureMessage()) - }) - + } } override fun onMessage(msg: String) { logger.d { "${System.getCurrentThread()} - Received message: $msg" } - CoroutineHelper.waitForCompletion(CoroutineScope(Dispatchers.Default).async { + GlobalScope.async { incomingMessagesChannel.send(MessageEnvelop(msg)) - }) - + } } override fun onClosing(code: Int, reason: String) { currentState = State.CLOSING - CoroutineHelper.waitForCompletion(CoroutineScope(Dispatchers.Default).async { socketClosingChannel.send(Unit) }) + GlobalScope.async { + socketClosingChannel.send(Unit) + } logger.d { "PlatformSocketListener: Closing socket: code = $code, reason = $reason" } } @@ -83,7 +80,6 @@ class AppSocket(url: String, incomingMessagesChannel: Channel) { socketError = null currentState = State.CONNECTING - ws.openSocket(socketListener) logger.d { "Thread = ${System.getCurrentThread()} awaiting while websocket is opened" } diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/transport/WebSocketTransportImpl.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/transport/WebSocketTransportImpl.kt index cdb6d9e2..99db1918 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/transport/WebSocketTransportImpl.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/transport/WebSocketTransportImpl.kt @@ -4,13 +4,12 @@ import com.dxc.ssi.agent.api.pluggable.Transport import com.dxc.ssi.agent.exceptions.transport.MessageCouldNotBeDeliveredException import com.dxc.ssi.agent.model.PeerConnection import com.dxc.ssi.agent.model.messages.MessageEnvelop -import io.ktor.http.* -import io.ktor.util.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.delay import com.dxc.ssi.agent.kermit.Kermit import com.dxc.ssi.agent.kermit.LogcatLogger -import com.dxc.ssi.agent.kermit.Severity +import io.ktor.util.* + //TODO: handle closing websocket correctly //TODO: cleanup websockets cache with time to avoid memory leak @@ -27,16 +26,17 @@ class WebSocketTransportImpl : Transport { @OptIn(InternalAPI::class) override suspend fun sendMessage(connection: PeerConnection, message: MessageEnvelop) { logger.d { "Before sending message to endpoint: ${connection.endpoint}" } - if (!(connection.endpoint.protocol == URLProtocol.WS || connection.endpoint.protocol == URLProtocol.WSS)) - throw IllegalArgumentException("Only websockets are supported by WebSocketTransportImpl!") - + //if (!(connection.endpoint.protocol == URLProtocol.WS || connection.endpoint.protocol == URLProtocol.WSS)) + //throw IllegalArgumentException("Only websockets are supported by WebSocketTransportImpl!") + println(connection.endpoint.protocol) var numberOfRetries = 0 while (true) { try { val appSocket = appSocketThreadSafeProvider.provideAppSocket(connection.endpoint.toString()) - appSocket.send(message.payload) + appSocket.send(connection.endpoint.toString() + "::" + message.payload) + break } catch (t: Throwable) { //TODO: check somewhere if connection already abandoned, do not retry diff --git a/src/commonMain/kotlin/com/dxc/ssi/agent/wallet/indy/IndyWalletHolder.kt b/src/commonMain/kotlin/com/dxc/ssi/agent/wallet/indy/IndyWalletHolder.kt index d7faeb35..300ab0fb 100644 --- a/src/commonMain/kotlin/com/dxc/ssi/agent/wallet/indy/IndyWalletHolder.kt +++ b/src/commonMain/kotlin/com/dxc/ssi/agent/wallet/indy/IndyWalletHolder.kt @@ -57,6 +57,7 @@ open class IndyWalletHolder( override suspend fun storeConnectionRecord(connection: PeerConnection) { val wallet = isoWallet.access { it.obj }!! + logger.d{"Store storeConnectionRecord ${connection.invitation}"} WalletCustomRecordsRepository.upsertWalletRecord(wallet, PeerConnectionRecord(connection)) } @@ -75,6 +76,7 @@ open class IndyWalletHolder( override suspend fun findConnectionByVerKey(verKey: String): PeerConnection? { + logger.d{"Store findConnectionByVerKey $verKey"} val query = "{\"${WalletRecordTag.ConnectionVerKey.name}\": \"${verKey}\"}" val wallet = isoWallet.access { it.obj }!! @@ -124,7 +126,7 @@ open class IndyWalletHolder( val byteArrayMessage = message.payload.toByteArray() val recipientVk = recipientKeys.joinToString(separator = "\",\"", prefix = "[\"", postfix = "\"]") - //val recipientVk = recipientKeys.joinToString(separator = ",",prefix = "", postfix = "") + //val recipientVk = recipientKeys.joinToString(separator = ",",prefix = "\"", postfix = "\"") logger.d { "recipientKeys = $recipientVk" } val senderVk = if (useAnonCrypt) null else isoVerkey.access { it.obj } diff --git a/src/iosMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt b/src/iosMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt index 136025e5..77220408 100644 --- a/src/iosMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt +++ b/src/iosMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt @@ -5,10 +5,10 @@ import cocoapods.PocketSocket.PSWebSocket import cocoapods.PocketSocket.PSWebSocketDelegateProtocol import com.dxc.ssi.agent.kermit.Kermit import com.dxc.ssi.agent.kermit.LogcatLogger -import com.dxc.ssi.agent.kermit.Severity -import platform.Foundation.NSError -import platform.Foundation.NSURL -import platform.Foundation.NSURLRequest +import io.ktor.utils.io.core.* +import kotlinx.cinterop.allocArrayOf +import kotlinx.cinterop.memScoped +import platform.Foundation.* import platform.darwin.NSInteger import platform.darwin.NSObject import platform.darwin.dispatch_queue_create @@ -16,6 +16,7 @@ import platform.posix.sleep import kotlin.native.concurrent.isFrozen + data class WebSocketWrapper(var websocket: PSWebSocket? = null) internal actual class PlatformSocket actual constructor(url: String) : NSObject(), PSWebSocketDelegateProtocol { diff --git a/src/iosMain/kotlin/com/dxc/ssi/agent/utils/ToBeReworked.kt b/src/iosMain/kotlin/com/dxc/ssi/agent/utils/ToBeReworked.kt index a7649ffd..e5eea9b6 100644 --- a/src/iosMain/kotlin/com/dxc/ssi/agent/utils/ToBeReworked.kt +++ b/src/iosMain/kotlin/com/dxc/ssi/agent/utils/ToBeReworked.kt @@ -31,9 +31,13 @@ object ToBeReworked { ) { initRuntimeIfNeeded() logger.d { pointer?.toKString()!! } + print(pointer?.toKString()!!) logger.d { val1?.toKString()!! } + print(val1?.toKString()!!) logger.d { val2?.toKString()!! } + print(val2?.toKString()!!) logger.d { val3?.toKString()!! } + print(val3?.toKString()!!) return }) indy_set_logger( diff --git a/src/iosTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt b/src/iosTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt index d8025b08..56edf4a4 100644 --- a/src/iosTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt +++ b/src/iosTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt @@ -72,8 +72,7 @@ class SsiAgentApiImplTest { val indyWalletConnector = IndyWalletConnector.build(walletHolder) val indyLedgerConnectorConfiguration = IndyLedgerConnectorConfiguration( - genesisMode = GenesisMode.IP, - ipAddress = "192.168.0.117" + genesisMode = GenesisMode.SOVRIN_BUILDERNET ) val ssiAgentApi = SsiAgentBuilderImpl(indyWalletConnector) @@ -85,10 +84,14 @@ class SsiAgentApiImplTest { val issuerInvitationUrl = - "ws://192.168.0.117:7000/ws?c_i=eyJsYWJlbCI6Iklzc3VlciIsImltYWdlVXJsIjpudWxsLCJzZXJ2aWNlRW5kcG9pbnQiOiJ3czovLzE5Mi4xNjguMC4xMTc6NzAwMC93cyIsInJvdXRpbmdLZXlzIjpbIjNGV3NHOUhZbzdzYjdjeHppRVBUb3ZaRGdjbko4cGFWWmNxWkVwRUZHOVluIl0sInJlY2lwaWVudEtleXMiOlsiOVNONEJBbUZhZW1QYlloWWphRHRWVWJqRnpZR0x0aXQ5ZnVnRmo3UlREYXYiXSwiQGlkIjoiMmJlNGZmZWYtM2I1NS00MTA4LWE5ZmMtZWM2NGQ5YjZjMjdjIiwiQHR5cGUiOiJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiJ9" + "ws://192.168.0.104:8030?c_i=eyJAdHlwZSI6ICJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMmQ4MzQ5MDgtNDcwYy00MzUwLWJlYzMtMzc0ZGQ0ODQ1ZWJkIiwgInNlcnZpY2VFbmRwb2ludCI6ICJ3czovLzE5Mi4xNjguMC4xMDQ6ODAzMCIsICJsYWJlbCI6ICJhbGljZS5hZ2VudCIsICJyZWNpcGllbnRLZXlzIjogWyJDekNmTkY5VFRCSnlmeVV0UjlhVnVLZjVXRXpZTEV3UHJnd3ZYSnlQdTlVRyJdfQ==" + //"ws://192.168.0.117:7000/ws?c_i=eyJsYWJlbCI6Iklzc3VlciIsImltYWdlVXJsIjpudWxsLCJzZXJ2aWNlRW5kcG9pbnQiOiJ3czovLzE5Mi4xNjguMC4xMTc6NzAwMC93cyIsInJvdXRpbmdLZXlzIjpbIjNGV3NHOUhZbzdzYjdjeHppRVBUb3ZaRGdjbko4cGFWWmNxWkVwRUZHOVluIl0sInJlY2lwaWVudEtleXMiOlsiOVNONEJBbUZhZW1QYlloWWphRHRWVWJqRnpZR0x0aXQ5ZnVnRmo3UlREYXYiXSwiQGlkIjoiMmJlNGZmZWYtM2I1NS00MTA4LWE5ZmMtZWM2NGQ5YjZjMjdjIiwiQHR5cGUiOiJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiJ9" val verifierInvitationUrl = - "ws://192.168.0.117:9000/ws?c_i=eyJsYWJlbCI6IlZlcmlmaWVyIiwiaW1hZ2VVcmwiOm51bGwsInNlcnZpY2VFbmRwb2ludCI6IndzOi8vMTkyLjE2OC4wLjExNzo5MDAwL3dzIiwicm91dGluZ0tleXMiOlsiNjUyYksyZzFlS3llcFZvQTJyU2dLQzZETFVqSGpRWEpyNXQzeUdYS0d5dW0iXSwicmVjaXBpZW50S2V5cyI6WyJHSmRNSncycktjRmk4aWgydGpKcHhiVWlLbnF2VlhKM2hrRXhMUGVMTUU3VyJdLCJAaWQiOiIwODQzYzUzZC00YjYwLTRjMDUtYTg2NS1hNzVkNDRiZWM3YTYiLCJAdHlwZSI6ImRpZDpzb3Y6QnpDYnNOWWhNcmpIaXFaRFRVQVNIZztzcGVjL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIn0==" + "ws://192.168.0.104:8030?c_i=eyJAdHlwZSI6ICJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMmQ4MzQ5MDgtNDcwYy00MzUwLWJlYzMtMzc0ZGQ0ODQ1ZWJkIiwgInNlcnZpY2VFbmRwb2ludCI6ICJ3czovLzE5Mi4xNjguMC4xMDQ6ODAzMCIsICJsYWJlbCI6ICJhbGljZS5hZ2VudCIsICJyZWNpcGllbnRLZXlzIjogWyJDekNmTkY5VFRCSnlmeVV0UjlhVnVLZjVXRXpZTEV3UHJnd3ZYSnlQdTlVRyJdfQ==" + + //val verifierInvitationUrl = + // "ws://192.168.0.117:9000/ws?c_i=eyJsYWJlbCI6IlZlcmlmaWVyIiwiaW1hZ2VVcmwiOm51bGwsInNlcnZpY2VFbmRwb2ludCI6IndzOi8vMTkyLjE2OC4wLjExNzo5MDAwL3dzIiwicm91dGluZ0tleXMiOlsiNjUyYksyZzFlS3llcFZvQTJyU2dLQzZETFVqSGpRWEpyNXQzeUdYS0d5dW0iXSwicmVjaXBpZW50S2V5cyI6WyJHSmRNSncycktjRmk4aWgydGpKcHhiVWlLbnF2VlhKM2hrRXhMUGVMTUU3VyJdLCJAaWQiOiIwODQzYzUzZC00YjYwLTRjMDUtYTg2NS1hNzVkNDRiZWM3YTYiLCJAdHlwZSI6ImRpZDpzb3Y6QnpDYnNOWWhNcmpIaXFaRFRVQVNIZztzcGVjL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIn0==" diff --git a/src/jvmMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt b/src/jvmMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt index 72178bf9..5976ab6d 100644 --- a/src/jvmMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt +++ b/src/jvmMain/kotlin/com/dxc/ssi/agent/transport/PlatformSocket.kt @@ -1,42 +1,91 @@ package com.dxc.ssi.agent.transport - import okhttp3.* +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.RequestBody.Companion.toRequestBody +import org.eclipse.jetty.server.Server +import org.eclipse.jetty.servlet.ServletHandler +import java.io.IOException +import java.net.InetAddress +import java.net.InetSocketAddress +import java.util.* +import javax.servlet.ServletException +import javax.servlet.http.HttpServlet +import javax.servlet.http.HttpServletRequest +import javax.servlet.http.HttpServletResponse + +private var pfl: PlatformSocketListener? = null internal actual class PlatformSocket actual constructor(url: String) { - private val socketEndpoint = url + + private var client: OkHttpClient? = null private var webSocket: WebSocket? = null - actual fun openSocket(platformSocketListener: PlatformSocketListener) { - val socketRequest = Request.Builder().url(socketEndpoint).build() - val webClient = OkHttpClient().newBuilder().build() - webSocket = webClient.newWebSocket( - socketRequest, - object : WebSocketListener() { - override fun onOpen(webSocket: WebSocket, response: Response) = platformSocketListener.onOpen() - override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) = - platformSocketListener.onFailure(t) - - override fun onMessage(webSocket: WebSocket, text: String) = - platformSocketListener.onMessage(text) - - override fun onClosing(webSocket: WebSocket, code: Int, reason: String) = - platformSocketListener.onClosing(code, reason) - - override fun onClosed(webSocket: WebSocket, code: Int, reason: String) = - platformSocketListener.onClosed(code, reason) - } - ) + object EmbeddedJettyExample { + class HelloServlet : HttpServlet() { + @Throws(ServletException::class, IOException::class) + override fun doPost(request: HttpServletRequest?, response: HttpServletResponse) { + if ("POST".equals(request!!.method, ignoreCase = true)) { + try { + val s: Scanner = Scanner(request.inputStream, "UTF-8").useDelimiter("\\A") + val res = if (s.hasNext()) s.next() else "" + pfl?.onMessage(res) + println(">>>>>>>>>POST>>>>>>>>>") + println(res) + println(">>>>>>>>>POST>>>>>>>>>") + response.contentType = "application/json" + response.status = HttpServletResponse.SC_OK + response.writer.println("{ \"status\": \"ok\"}") + } catch (t: Throwable) { + pfl?.onFailure(t) + } + } + } + } + } + actual fun openSocket(platformSocketListener: PlatformSocketListener) { + pfl = platformSocketListener + client = OkHttpClient() + val runnable = Runnable { + val isa = InetSocketAddress(InetAddress.getByName("192.168.0.104"), 8123) + val server = Server(isa) + val servletHandler = ServletHandler() + server.handler = servletHandler + servletHandler.addServletWithMapping(EmbeddedJettyExample.HelloServlet::class.java, "/") + server.start() + server.join() + } + val thread = Thread(runnable) + try { + thread.start() + platformSocketListener.onOpen() + } catch (e: Exception) { + println(e.message) + } } actual fun closeSocket(code: Int, reason: String) { webSocket?.close(code, reason) webSocket = null - } actual fun sendMessage(msg: String) { - webSocket?.send(msg) + println("send message") + val s = msg.split("::") + println(s[0]) + println(s[1]) + val body: RequestBody = s[1].toRequestBody("application/ssi-agent-wire".toMediaTypeOrNull()) + val requestGet: Request = Request.Builder() + .url(s[0]) + .post(body) + .build() + val res: String? = null + try { + client?.newCall(requestGet)?.execute().use { response -> response?.body!!.string() } + println(res) + } catch (e: Exception) { + println(e.message) + } } } \ No newline at end of file diff --git a/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt b/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt index 2886f25d..cb9149b3 100644 --- a/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt +++ b/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/SsiAgentApiImplTest.kt @@ -25,6 +25,7 @@ import com.dxc.ssi.agent.didcomm.model.verify.container.PresentationRequestConta import com.dxc.ssi.agent.kermit.Kermit import com.dxc.ssi.agent.kermit.LogcatLogger import com.dxc.ssi.agent.kermit.Severity +import com.dxc.ssi.agent.ledger.indy.GenesisMode import com.dxc.ssi.agent.ledger.indy.IndyLedgerConnectorBuilder import com.dxc.ssi.agent.model.DidConfig import com.dxc.ssi.agent.model.OfferResponseAction @@ -43,20 +44,21 @@ import org.junit.Test class SsiAgentApiImplTest { - private val walletName = "newWalletName55" + private val walletName = "newWalletName58" private val walletPassword = "newWalletPassword" private val did = "Aj4mwDVVEh46K17Cqh4dpU" private lateinit var ssiAgentApi: SsiAgentApi var logger: Kermit = Kermit(LogcatLogger()) @Test - @Ignore("Ignored because it is actually integration tests which should be moved out of unit tests in order to to run during build") + //@Ignore("Ignored because it is actually integration tests which should be moved out of unit tests in order to to run during build") //TODO: Move integration tests to separate module fun basicTest() { logger.d { "Starting test" } EnvironmentUtils.initEnvironment(EnvironmentImpl()) + val walletManager: WalletManager = IndyWalletManager if (!walletManager.isWalletExistsAndOpenable(walletName, walletPassword)) @@ -82,7 +84,8 @@ class SsiAgentApiImplTest { val indyLedgerConnector = IndyLedgerConnectorBuilder() - .withGenesisFilePath("/home/ivan/IdeaProjects/dxc/Lumedic/ssi-mobile-sdk/files/sovrin_buildernet_genesis.txt") + .withGenesisFilePath("/Users/kkamyczek/krzysztof/ssi-mobile-sdk/files/sovrin_buildernet_genesis.txt") + .withGenesisMode(GenesisMode.SOVRIN_BUILDERNET) .build() ssiAgentApi = SsiAgentBuilderImpl(indyWalletConnector) @@ -94,18 +97,14 @@ class SsiAgentApiImplTest { .build() val invitationUrl = - "wss://lce-agent-dev.lumedic.io/ws?c_i=eyJsYWJlbCI6IkNsb3VkIEFnZW50IiwiaW1hZ2VVcmwiOm51bGwsInNlcnZpY2VFbmRwb2ludCI6IndzczovL2xjZS1hZ2VudC1kZXYubHVtZWRpYy5pby93cyIsInJvdXRpbmdLZXlzIjpbIjVoUDdreEFDQnpGVXJQSmo0VkhzMTdpRGJ0TU1wclZRSlFTVm84dnZzdGdwIl0sInJlY2lwaWVudEtleXMiOlsiSkJFTjRrQlZpV0pSRmV1M29ncFEyaTNTQnlFWDE5Mk5Mbnl3TlV4ejRIUk4iXSwiQGlkIjoiNDU2ZWMwNmEtYmJiMi00NmJmLThjYzctMGM1YmVkZmJlNTNiIiwiQHR5cGUiOiJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiJ9" - - + "http://192.168.0.104:8030?c_i=eyJAdHlwZSI6ICJkaWQ6c292OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMjQ4YmM2M2UtMmE1NS00ZDkyLTg5NDYtMmY3MGJhMjFmMDRiIiwgInJlY2lwaWVudEtleXMiOiBbIkRqSlVtSFBmcldMeDQ1ZmViUjlaVnhienpiQ0JtcUFvcXZ2VjloWWZVMzV1Il0sICJzZXJ2aWNlRW5kcG9pbnQiOiAiaHR0cDovLzE5Mi4xNjguMC4xMDQ6ODAzMCIsICJsYWJlbCI6ICJhbGljZS5hZ2VudCJ9" ssiAgentApi.init(object : LibraryStateListener { override fun initializationCompleted() { - logger.d { "Connecting to issuer" } - // ssiAgentApi.abandonAllConnections() - val connection = ssiAgentApi.connect(invitationUrl, keepConnectionAlive = true) - - logger.d { "Connected to issuer" } + logger.d ("Control"){ "Connecting to issuer" } + ssiAgentApi.connect(invitationUrl, keepConnectionAlive = true) + logger.d ("Control"){ "Connected to issuer" } } @@ -115,29 +114,31 @@ class SsiAgentApiImplTest { details: String?, stackTrace: String? ) { - logger.d { "Received error from library: $error with details: $details" } + logger.d ("Control"){ "Received error from library: $error with details: $details" } } }) - Sleeper().sleep(1_000_000) + Sleeper().sleep(1_000_000_000) } class StatefulConnectionControllerImpl : StatefulConnectionController { var logger: Kermit = Kermit(LogcatLogger()) override fun onReconnected(connection: PeerConnection) { - TODO("Not yet implemented") + // TODO("Not yet implemented") + logger.d ("Control"){ "onReconnected" } } override fun onReconnectFailed(reconnectionError: ReconnectionError, reason: String?) { - logger.d { "Failed to reconnect: $reconnectionError " } + logger.d ("Control"){ "Failed to reconnect: $reconnectionError " } } override fun onDisconnected(connection: PeerConnection) { - TODO("Not yet implemented") + logger.d ("Control"){ "onDisconnected" } + //TODO("Not yet implemented") } } @@ -147,17 +148,16 @@ class SsiAgentApiImplTest { connection: PeerConnection, presentationRequest: PresentationRequestContainer ): PresentationRequestResponseAction { - - + logger.d ("Control"){ "CredPresenterControllerImpl ACCEPT" } return PresentationRequestResponseAction.ACCEPT } override fun onDone(connection: PeerConnection) { - + logger.d ("Control"){ "CredPresenterControllerImpl onDone" } } override fun onProblemReportGenerated(connection: PeerConnection, problemReport: ProblemReport) { - + logger.d ("Control"){ "CredPresenterControllerImpl onProblemReportGenerated" } } } @@ -168,6 +168,7 @@ class SsiAgentApiImplTest { credentialOfferContainer: CredentialOfferContainer ): OfferResponseAction { + logger.d ("Control"){ "OfferResponseAction.ACCEPT" } return OfferResponseAction.ACCEPT } @@ -175,18 +176,19 @@ class SsiAgentApiImplTest { connection: PeerConnection, credentialRequestContainer: CredentialRequestContainer ) { - + logger.d ("Control"){ "CredReceiverControllerImpl onRequestSent" } } override fun onCredentialReceived( connection: PeerConnection, credentialContainer: CredentialContainer ): CallbackResult { + logger.d ("Control"){ "CredReceiverControllerImpl onCredentialReceived" } return CallbackResult(true) } override fun onDone(connection: PeerConnection, credentialContainer: CredentialContainer) { - + logger.d ("Control"){ "Ack sent for credential onDone" } } override fun onProblemReport(connection: PeerConnection, problemReport: ProblemReport): CallbackResult { @@ -194,35 +196,34 @@ class SsiAgentApiImplTest { } override fun onAckSent(connection: PeerConnection, ack: Ack) { - logger.d { "Ack sent for credential" } + logger.d ("Control") { "Ack sent for credential" } } - - } - inner class ConnectionInitiatorControllerImpl() : ConnectionInitiatorController { + inner class ConnectionInitiatorControllerImpl : ConnectionInitiatorController { override fun onInvitationReceived( connection: PeerConnection, invitation: Invitation ): CallbackResult { + logger.d ("Control") { "ConnectionInitiatorControllerImpl onInvitationReceived" } return CallbackResult(canProceedFurther = true) } override fun onRequestSent(connection: PeerConnection, request: ConnectionRequest) { - logger.d { "Request sent hook called : $connection, $request" } + logger.d ("Control"){ "Request sent hook called : $connection, $request" } } override fun onResponseReceived(connection: PeerConnection, response: ConnectionResponse): CallbackResult { - logger.d { "Response received hook called : $connection, $response" } + logger.d ("Control"){ "Response received hook called : $connection, $response" } return CallbackResult(true) } override fun onCompleted(connection: PeerConnection) { - + logger.d ("Control") { "onCompleted : $connection" } } override fun onAbandoned(connection: PeerConnection, problemReport: ProblemReport?) { - + logger.d ("Control") { "onAbandoned : $connection" } } override fun onFailure( @@ -232,7 +233,7 @@ class SsiAgentApiImplTest { details: String?, stackTrace: String? ) { - logger.d { "Failure occured for connection $connection, error-> $error, details -> $details" } + logger.d ("Control") { "Failure occured for connection $connection, error-> $error, details -> $details" } } } diff --git a/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/UseThirdPartyWalletTest.kt b/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/UseThirdPartyWalletTest.kt index 4d55bded..afa90bdd 100644 --- a/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/UseThirdPartyWalletTest.kt +++ b/src/jvmTest/kotlin/com/dxc/ssi/agent/api/impl/UseThirdPartyWalletTest.kt @@ -271,11 +271,11 @@ class UseThirdPartyWalletTest { } override fun onCompleted(connection: PeerConnection) { - + logger.d { "Response received hook called onCompleted: $connection" } } override fun onAbandoned(connection: PeerConnection, problemReport: ProblemReport?) { - + logger.d { "Response received hook called onAbandoned: $connection, $problemReport" } } override fun onFailure(