diff --git a/.github/workflows/autoclose_stale_issues.yml b/.github/workflows/autoclose_stale_issues.yml new file mode 100644 index 00000000..43441028 --- /dev/null +++ b/.github/workflows/autoclose_stale_issues.yml @@ -0,0 +1,17 @@ +name: 'Close stale issues and PR' +on: + schedule: + - cron: '00 05 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + stale-issue-message: 'This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.' + close-issue-message: 'This issue was closed because it has been stalled for 10 days with no activity.' + days-before-stale: 20 + days-before-close: 10 + days-before-pr-stale: -1 + days-before-pr-close: -1 \ No newline at end of file diff --git a/.github/workflows/polygonid_flutter_sdk.yml b/.github/workflows/polygonid_flutter_sdk.yml index a2a067ed..945023f3 100644 --- a/.github/workflows/polygonid_flutter_sdk.yml +++ b/.github/workflows/polygonid_flutter_sdk.yml @@ -162,11 +162,12 @@ jobs: # script: cd example&&flutter test integration_test/libpolygonid_test.dart --verbose # job responsible for publishing the package to pub.dev - publish: - needs: [ common ] #, ios , android ] - runs-on: ubuntu-latest - steps: - - name: Publish dry run - if: github.base_ref == 'main' - run: flutter pub publish --dry-run + # enable it once published for the first time on pub.dev otherwise it will fail + #publish: + # needs: [ common ] #, ios , android ] + # runs-on: ubuntu-latest + # steps: + # - name: Publish dry run + # if: github.base_ref == 'main' + # run: flutter pub publish --dry-run diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f8f45c..97fed9d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.2.9 +- Multiple circuits download and circuit V3 support +- Credential rawValue field on the claimDTO and claimEntity +- Credential refresh service +- Credential DisplayType capability +- Minor fixes + ## 2.2.8+2 - Fixed protocol library method for revocation status check diff --git a/README.md b/README.md index 4750db15..695f2eb2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # Polygon ID Flutter SDK -[![pub package](https://img.shields.io/badge/pub-2.2.8+2-blueviolet)](https://pub.dev/packages/polygonid_flutter_sdk) +[![pub package](https://img.shields.io/badge/pub-2.2.9-blueviolet)](https://pub.dev/packages/polygonid_flutter_sdk) [![build](https://github.com/iden3/polygonid-flutter-sdk/workflows/polygonid_flutter_sdk/badge.svg)](https://github.com/iden3/polygonid-flutter-sdk/actions?query=workflow%3Apolygonid_flutter_sdk) [![codecov](https://codecov.io/gh/iden3/polygonid-flutter-sdk/branch/develop/graph/badge.svg?token=0SI0XWGXKL)](https://codecov.io/gh/iden3/polygonid-flutter-sdk) [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/iden3/polygonid-flutter-sdk/blob/master/LICENSE-APACHE) diff --git a/android/sdk.properties b/android/sdk.properties index be128566..7fefac7b 100644 --- a/android/sdk.properties +++ b/android/sdk.properties @@ -1,3 +1,3 @@ ext { - sdkVersion = '2.2.6' + sdkVersion = '2.2.9' } \ No newline at end of file diff --git a/android/src/main/jniLibs/arm64-v8a/libpolygonid.h b/android/src/main/jniLibs/arm64-v8a/libpolygonid.h index f8a9ca58..fd376fb3 100644 --- a/android/src/main/jniLibs/arm64-v8a/libpolygonid.h +++ b/android/src/main/jniLibs/arm64-v8a/libpolygonid.h @@ -183,7 +183,19 @@ extern GoUint8 PLGNAtomicQuerySigV2OnChainInputs(char** jsonResponse, char* in, // } // extern GoUint8 PLGNAtomicQueryMtpV2OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3Inputs returns the inputs for the credentialAtomicQueryV3 +// circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3Inputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3OnChainInputs returns the inputs for the +// credentialAtomicQueryV3OnChain circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); extern void PLGNFreeStatus(PLGNStatus* status); +extern GoUint8 PLGNCleanCache(PLGNStatus** status); +extern GoUint8 PLGNCacheCredentials(char* in, char* cfg, PLGNStatus** status); #ifdef __cplusplus } diff --git a/android/src/main/jniLibs/arm64-v8a/libpolygonid.so b/android/src/main/jniLibs/arm64-v8a/libpolygonid.so index 1ac3128d..aa6c6260 100644 Binary files a/android/src/main/jniLibs/arm64-v8a/libpolygonid.so and b/android/src/main/jniLibs/arm64-v8a/libpolygonid.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_authV2.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_authV2.so old mode 100755 new mode 100644 index b5ec1d21..e58f7421 Binary files a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_authV2.so and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_authV2.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2.so old mode 100755 new mode 100644 index 4e8bcbc0..e3e4cb0b Binary files a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2.so and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so old mode 100755 new mode 100644 index 4df8db9d..8935cca2 Binary files a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2.so old mode 100755 new mode 100644 index e2b83c02..6803e1ba Binary files a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2.so and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so old mode 100755 new mode 100644 index 08ec554a..68f07276 Binary files a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3.so new file mode 100644 index 00000000..4304b347 Binary files /dev/null and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3OnChain.so b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3OnChain.so new file mode 100644 index 00000000..d482df30 Binary files /dev/null and b/android/src/main/jniLibs/arm64-v8a/libwitnesscalc_credentialAtomicQueryV3OnChain.so differ diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2.h index a5382380..d2b80cfa 100644 --- a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2.h +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQueryMTPV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2OnChain.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2OnChain.h index 8b771684..013885cc 100644 --- a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2OnChain.h +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryMTPV2OnChain.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQueryMTPV2OnChain( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2.h index 80309e76..f03309b2 100644 --- a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2.h +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQuerySigV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2OnChain.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2OnChain.h index 2a4688d1..e55016da 100644 --- a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2OnChain.h +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQuerySigV2OnChain.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQuerySigV2OnChain( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3.h new file mode 100644 index 00000000..50dfbfef --- /dev/null +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3_H diff --git a/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3OnChain.h b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3OnChain.h new file mode 100644 index 00000000..c958b7bb --- /dev/null +++ b/android/src/main/jniLibs/arm64-v8a/witnesscalc_credentialAtomicQueryV3OnChain.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3OnChain( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H diff --git a/android/src/main/jniLibs/armeabi-v7a/libpolygonid.h b/android/src/main/jniLibs/armeabi-v7a/libpolygonid.h index 9450c7a0..ab2cdc68 100644 --- a/android/src/main/jniLibs/armeabi-v7a/libpolygonid.h +++ b/android/src/main/jniLibs/armeabi-v7a/libpolygonid.h @@ -183,7 +183,19 @@ extern GoUint8 PLGNAtomicQuerySigV2OnChainInputs(char** jsonResponse, char* in, // } // extern GoUint8 PLGNAtomicQueryMtpV2OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3Inputs returns the inputs for the credentialAtomicQueryV3 +// circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3Inputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3OnChainInputs returns the inputs for the +// credentialAtomicQueryV3OnChain circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); extern void PLGNFreeStatus(PLGNStatus* status); +extern GoUint8 PLGNCleanCache(PLGNStatus** status); +extern GoUint8 PLGNCacheCredentials(char* in, char* cfg, PLGNStatus** status); #ifdef __cplusplus } diff --git a/android/src/main/jniLibs/armeabi-v7a/libpolygonid.so b/android/src/main/jniLibs/armeabi-v7a/libpolygonid.so index 495d388b..5c730964 100644 Binary files a/android/src/main/jniLibs/armeabi-v7a/libpolygonid.so and b/android/src/main/jniLibs/armeabi-v7a/libpolygonid.so differ diff --git a/android/src/main/jniLibs/x86/libpolygonid.h b/android/src/main/jniLibs/x86/libpolygonid.h index 9450c7a0..ab2cdc68 100644 --- a/android/src/main/jniLibs/x86/libpolygonid.h +++ b/android/src/main/jniLibs/x86/libpolygonid.h @@ -183,7 +183,19 @@ extern GoUint8 PLGNAtomicQuerySigV2OnChainInputs(char** jsonResponse, char* in, // } // extern GoUint8 PLGNAtomicQueryMtpV2OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3Inputs returns the inputs for the credentialAtomicQueryV3 +// circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3Inputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3OnChainInputs returns the inputs for the +// credentialAtomicQueryV3OnChain circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); extern void PLGNFreeStatus(PLGNStatus* status); +extern GoUint8 PLGNCleanCache(PLGNStatus** status); +extern GoUint8 PLGNCacheCredentials(char* in, char* cfg, PLGNStatus** status); #ifdef __cplusplus } diff --git a/android/src/main/jniLibs/x86/libpolygonid.so b/android/src/main/jniLibs/x86/libpolygonid.so index 2374af1b..394744f0 100644 Binary files a/android/src/main/jniLibs/x86/libpolygonid.so and b/android/src/main/jniLibs/x86/libpolygonid.so differ diff --git a/android/src/main/jniLibs/x86_64/libpolygonid.h b/android/src/main/jniLibs/x86_64/libpolygonid.h index f8a9ca58..fd376fb3 100644 --- a/android/src/main/jniLibs/x86_64/libpolygonid.h +++ b/android/src/main/jniLibs/x86_64/libpolygonid.h @@ -183,7 +183,19 @@ extern GoUint8 PLGNAtomicQuerySigV2OnChainInputs(char** jsonResponse, char* in, // } // extern GoUint8 PLGNAtomicQueryMtpV2OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3Inputs returns the inputs for the credentialAtomicQueryV3 +// circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3Inputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3OnChainInputs returns the inputs for the +// credentialAtomicQueryV3OnChain circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); extern void PLGNFreeStatus(PLGNStatus* status); +extern GoUint8 PLGNCleanCache(PLGNStatus** status); +extern GoUint8 PLGNCacheCredentials(char* in, char* cfg, PLGNStatus** status); #ifdef __cplusplus } diff --git a/android/src/main/jniLibs/x86_64/libpolygonid.so b/android/src/main/jniLibs/x86_64/libpolygonid.so index c32d050e..73f61368 100644 Binary files a/android/src/main/jniLibs/x86_64/libpolygonid.so and b/android/src/main/jniLibs/x86_64/libpolygonid.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_authV2.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_authV2.so old mode 100755 new mode 100644 index 13911df1..324beafe Binary files a/android/src/main/jniLibs/x86_64/libwitnesscalc_authV2.so and b/android/src/main/jniLibs/x86_64/libwitnesscalc_authV2.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2.so old mode 100755 new mode 100644 index 7bd80bd3..22f6ba2a Binary files a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2.so and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so old mode 100755 new mode 100644 index 3c141811..5389131e Binary files a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2.so old mode 100755 new mode 100644 index b31189c6..b57de0b8 Binary files a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2.so and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so old mode 100755 new mode 100644 index 82dd4626..22646310 Binary files a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQuerySigV2OnChain.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3.so new file mode 100644 index 00000000..a4c89ee2 Binary files /dev/null and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3.so differ diff --git a/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3OnChain.so b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3OnChain.so new file mode 100644 index 00000000..a4f6b974 Binary files /dev/null and b/android/src/main/jniLibs/x86_64/libwitnesscalc_credentialAtomicQueryV3OnChain.so differ diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2.h index a5382380..d2b80cfa 100644 --- a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2.h +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQueryMTPV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2OnChain.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2OnChain.h index 8b771684..013885cc 100644 --- a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2OnChain.h +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryMTPV2OnChain.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQueryMTPV2OnChain( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2.h index 80309e76..f03309b2 100644 --- a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2.h +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQuerySigV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2OnChain.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2OnChain.h index 2a4688d1..e55016da 100644 --- a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2OnChain.h +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQuerySigV2OnChain.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQuerySigV2OnChain( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3.h new file mode 100644 index 00000000..50dfbfef --- /dev/null +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3_H diff --git a/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3OnChain.h b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3OnChain.h new file mode 100644 index 00000000..c958b7bb --- /dev/null +++ b/android/src/main/jniLibs/x86_64/witnesscalc_credentialAtomicQueryV3OnChain.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3OnChain( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H diff --git a/example/README.md b/example/README.md index cfb9f380..e4996e06 100644 --- a/example/README.md +++ b/example/README.md @@ -15,11 +15,12 @@ Demonstrates how to use the polygonid_flutter_sdk plugin. ### Install 1. Clone the `polygonid-flutter-sdk` repository. 2. Run `flutter pub get` from example directory. -3. Run `build_runner` to generate `.g.dart` files: +3. Configure the environment per the instructions below. +4. Run `build_runner` to generate `.g.dart` files: ```bash -flutter pub run build_runner build --delete-conflicting-outputs +dart run build_runner build --delete-conflicting-outputs ``` -4. After the previous steps, build and run the project. +5. After the previous steps, build and run the project. ## Examples diff --git a/example/ios/Podfile b/example/ios/Podfile index 74fddb17..4914c4a1 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -55,7 +55,7 @@ post_install do |installer| target.build_configurations.each do |config| xcconfig_path = config.base_configuration_reference.real_path xcconfig = File.read(xcconfig_path) - new_xcconfig = xcconfig.sub('OTHER_LDFLAGS = $(inherited)', 'OTHER_LDFLAGS = $(inherited) -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/librapidsnark.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_authV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQuerySigV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libfr.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libgmp.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libpolygonid.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libbabyjubjub.a" -lc++ -lz') + new_xcconfig = xcconfig.sub('OTHER_LDFLAGS = $(inherited)', 'OTHER_LDFLAGS = $(inherited) -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/librapidsnark.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_authV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQuerySigV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryV3.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryV3OnChain.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libfr.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libgmp.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libpolygonid.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libbabyjubjub.a" -lc++ -lz') File.open(xcconfig_path, "w") { |file| file << new_xcconfig } end end diff --git a/example/lib/src/presentation/dependency_injection/dependencies_provider.dart b/example/lib/src/presentation/dependency_injection/dependencies_provider.dart index f312b07b..c38242c9 100644 --- a/example/lib/src/presentation/dependency_injection/dependencies_provider.dart +++ b/example/lib/src/presentation/dependency_injection/dependencies_provider.dart @@ -17,6 +17,7 @@ import 'package:polygonid_flutter_sdk_example/src/presentation/ui/home/home_bloc import 'package:polygonid_flutter_sdk_example/src/presentation/ui/restore_identity/bloc/restore_identity_bloc.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/sign/sign_bloc.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/splash/splash_bloc.dart'; +import 'package:polygonid_flutter_sdk_example/utils/qr_code_parser_utils.dart'; final getIt = GetIt.instance; @@ -34,12 +35,15 @@ Future init() async { registerIdentityDependencies(); registerBackupIdentityDependencies(); registerRestoreIdentityDependencies(); + registerUtilities(); } void registerEnv() { Map polygonMumbai = jsonDecode(Env.polygonMumbai); - List env = [ - EnvEntity( + Map polygonMainnet = jsonDecode(Env.polygonMainnet); + + Map env = { + "mumbai": EnvEntity( blockchain: polygonMumbai['blockchain'], network: polygonMumbai['network'], web3Url: polygonMumbai['web3Url'], @@ -49,13 +53,23 @@ void registerEnv() { pushUrl: polygonMumbai['pushUrl'], ipfsUrl: polygonMumbai['ipfsUrl'], ), - ]; - getIt.registerSingleton>(env); + "mainnet": EnvEntity( + blockchain: polygonMainnet['blockchain'], + network: polygonMainnet['network'], + web3Url: polygonMainnet['web3Url'], + web3RdpUrl: polygonMainnet['web3RdpUrl'], + web3ApiKey: polygonMainnet['web3ApiKey'], + idStateContract: polygonMainnet['idStateContract'], + pushUrl: polygonMainnet['pushUrl'], + ipfsUrl: polygonMainnet['ipfsUrl'], + ) + }; + getIt.registerSingleton>(env); } /// Future registerProviders() async { - await PolygonIdSdk.init(env: getIt>()[0]); + await PolygonIdSdk.init(env: getIt>()["mumbai"]); getIt.registerLazySingleton(() => PolygonIdSdk.I); } @@ -71,7 +85,11 @@ void registerHomeDependencies() { /// void registerClaimsDependencies() { - getIt.registerFactory(() => ClaimsBloc(getIt(), getIt())); + getIt.registerFactory(() => ClaimsBloc( + getIt(), + getIt(), + getIt(), + )); } /// @@ -81,7 +99,7 @@ void registerClaimDetailDependencies() { /// void registerAuthDependencies() { - getIt.registerFactory(() => AuthBloc(getIt())); + getIt.registerFactory(() => AuthBloc(getIt(), getIt())); } /// @@ -113,3 +131,9 @@ void registerRestoreIdentityDependencies() { getIt .registerFactory(() => RestoreIdentityBloc(getIt())); } + +/// Register utilities +void registerUtilities() { + getIt.registerLazySingleton( + () => QrcodeParserUtils(getIt())); +} diff --git a/example/lib/src/presentation/ui/auth/auth_bloc.dart b/example/lib/src/presentation/ui/auth/auth_bloc.dart index 1e0199e5..4e8335e6 100644 --- a/example/lib/src/presentation/ui/auth/auth_bloc.dart +++ b/example/lib/src/presentation/ui/auth/auth_bloc.dart @@ -1,18 +1,41 @@ +import 'dart:typed_data'; + import 'package:bloc/bloc.dart'; +import 'dart:math'; +import 'package:polygonid_flutter_sdk/common/domain/domain_constants.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart'; import 'package:polygonid_flutter_sdk_example/src/data/secure_storage.dart'; +import 'package:polygonid_flutter_sdk_example/src/presentation/dependency_injection/dependencies_provider.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/auth/auth_event.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/auth/auth_state.dart'; +import 'package:polygonid_flutter_sdk_example/src/presentation/ui/common/widgets/profile_radio_button.dart'; +import 'package:polygonid_flutter_sdk_example/utils/nonce_utils.dart'; +import 'package:polygonid_flutter_sdk_example/utils/qr_code_parser_utils.dart'; import 'package:polygonid_flutter_sdk_example/utils/secure_storage_keys.dart'; class AuthBloc extends Bloc { final PolygonIdSdk _polygonIdSdk; + final QrcodeParserUtils _qrcodeParserUtils; + + static const SelectedProfile _defaultProfile = SelectedProfile.public; + SelectedProfile selectedProfile = _defaultProfile; - AuthBloc(this._polygonIdSdk) : super(const AuthState.initial()) { + AuthBloc( + this._polygonIdSdk, + this._qrcodeParserUtils, + ) : super(const AuthState.initial()) { on(_handleClickScanQrCode); on(_handleScanQrCodeResponse); + on(_handleProfileSelected); + } + + void _handleProfileSelected( + ProfileSelectedEvent event, Emitter emit) { + selectedProfile = event.profile; + emit(AuthState.profileSelected(event.profile)); } /// @@ -35,8 +58,8 @@ class AuthBloc extends Bloc { } try { - final Iden3MessageEntity iden3message = await _polygonIdSdk.iden3comm - .getIden3Message(message: qrCodeResponse); + final Iden3MessageEntity iden3message = + await _qrcodeParserUtils.getIden3MessageFromQrCode(qrCodeResponse); emit(AuthState.loaded(iden3message)); String? privateKey = @@ -73,10 +96,15 @@ class AuthBloc extends Bloc { network: envEntity.network); try { + final BigInt nonce = selectedProfile == SelectedProfile.public + ? GENESIS_PROFILE_NONCE + : await NonceUtils(getIt()).getPrivateProfileNonce( + did: did, privateKey: privateKey, from: iden3message.from); await _polygonIdSdk.iden3comm.authenticate( message: iden3message, genesisDid: did, privateKey: privateKey, + profileNonce: nonce, ); emit(const AuthState.authenticated()); diff --git a/example/lib/src/presentation/ui/auth/auth_event.dart b/example/lib/src/presentation/ui/auth/auth_event.dart index 7b0223a6..10017aae 100644 --- a/example/lib/src/presentation/ui/auth/auth_event.dart +++ b/example/lib/src/presentation/ui/auth/auth_event.dart @@ -1,9 +1,12 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:polygonid_flutter_sdk_example/src/presentation/ui/common/widgets/profile_radio_button.dart'; part 'auth_event.freezed.dart'; @freezed class AuthEvent with _$AuthEvent { + const factory AuthEvent.profileSelected(SelectedProfile profile) = + ProfileSelectedEvent; const factory AuthEvent.clickScanQrCode() = ClickScanQrCodeEvent; const factory AuthEvent.onScanQrCodeResponse(String? response) = ScanQrCodeResponse; diff --git a/example/lib/src/presentation/ui/auth/auth_state.dart b/example/lib/src/presentation/ui/auth/auth_state.dart index dc126b9d..548e6bdb 100644 --- a/example/lib/src/presentation/ui/auth/auth_state.dart +++ b/example/lib/src/presentation/ui/auth/auth_state.dart @@ -1,5 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk_example/src/presentation/ui/common/widgets/profile_radio_button.dart'; part 'auth_state.freezed.dart'; @@ -9,6 +10,9 @@ class AuthState with _$AuthState { const factory AuthState.loading() = LoadingAuthState; + const factory AuthState.profileSelected(SelectedProfile profile) = + ProfileSelectedAuthState; + const factory AuthState.navigateToQrCodeScanner() = NavigateToQrCodeScannerAuthState; diff --git a/example/lib/src/presentation/ui/auth/widgets/auth.dart b/example/lib/src/presentation/ui/auth/widgets/auth.dart index e80445ca..43f1dfd9 100644 --- a/example/lib/src/presentation/ui/auth/widgets/auth.dart +++ b/example/lib/src/presentation/ui/auth/widgets/auth.dart @@ -6,6 +6,7 @@ import 'package:polygonid_flutter_sdk_example/src/presentation/ui/auth/auth_bloc import 'package:polygonid_flutter_sdk_example/src/presentation/ui/auth/auth_event.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/auth/auth_state.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/common/widgets/button_next_action.dart'; +import 'package:polygonid_flutter_sdk_example/src/presentation/ui/common/widgets/profile_radio_button.dart'; import 'package:polygonid_flutter_sdk_example/utils/custom_button_style.dart'; import 'package:polygonid_flutter_sdk_example/utils/custom_colors.dart'; import 'package:polygonid_flutter_sdk_example/utils/custom_strings.dart'; @@ -49,23 +50,22 @@ class _AuthScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - child: SingleChildScrollView( - child: Column( - children: [ - const SizedBox(height: 50), - _buildDescription(), - const SizedBox(height: 24), - _buildProgress(), - const SizedBox(height: 24), - _buildAuthenticationSuccessSection(), - const SizedBox(height: 24), - _buildErrorSection(), - const SizedBox(height: 48), - ], - ), + SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 50), + _buildDescription(), + const SizedBox(height: 24), + _buildProgress(), + const SizedBox(height: 24), + _buildAuthenticationSuccessSection(), + const SizedBox(height: 24), + _buildErrorSection(), + const SizedBox(height: 48), + ], ), ), + Expanded(child: _buildRadioButtons()), Padding( padding: const EdgeInsets.only(bottom: 16), child: Stack( @@ -221,4 +221,17 @@ class _AuthScreenState extends State { }, ); } + + /// + Widget _buildRadioButtons() { + void _selectProfile(SelectedProfile profile) { + widget._bloc.add(AuthEvent.profileSelected(profile)); + } + + return BlocBuilder( + bloc: widget._bloc, + builder: (BuildContext context, AuthState state) { + return ProfileRadio(widget._bloc.selectedProfile, _selectProfile); + }); + } } diff --git a/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_bloc.dart b/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_bloc.dart index 24a5db49..c8da2a6a 100644 --- a/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_bloc.dart +++ b/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_bloc.dart @@ -15,6 +15,7 @@ class ClaimDetailBloc extends Bloc { ClaimDetailBloc(this._polygonIdSdk) : super(const ClaimDetailState.initial()) { on(_deleteClaimEvent); + on(_refreshClaimEvent); } /// @@ -51,4 +52,7 @@ class ClaimDetailBloc extends Bloc { emit(const ClaimDetailState.error(CustomStrings.claimRemovingError)); } } + + Future _refreshClaimEvent( + RefreshClaimEvent event, Emitter emit) async {} } diff --git a/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_event.dart b/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_event.dart index 82f51d0d..b48eba0f 100644 --- a/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_event.dart +++ b/example/lib/src/presentation/ui/claim_detail/bloc/claim_detail_event.dart @@ -6,4 +6,7 @@ part 'claim_detail_event.freezed.dart'; class ClaimDetailEvent with _$ClaimDetailEvent { const factory ClaimDetailEvent.deleteClaim({required String claimId}) = DeleteClaimEvent; + + const factory ClaimDetailEvent.refreshClaim({required String claimId}) = + RefreshClaimEvent; } diff --git a/example/lib/src/presentation/ui/claim_detail/widgets/claim_detail.dart b/example/lib/src/presentation/ui/claim_detail/widgets/claim_detail.dart index 7e7e9b73..760c344c 100644 --- a/example/lib/src/presentation/ui/claim_detail/widgets/claim_detail.dart +++ b/example/lib/src/presentation/ui/claim_detail/widgets/claim_detail.dart @@ -63,6 +63,7 @@ class _ClaimDetailScreenState extends State { ), ), const SizedBox(height: 24), + _buildRefreshCredentialButton(), _buildRemoveClaimButton(), _buildBlocListener(), ], @@ -140,4 +141,27 @@ class _ClaimDetailScreenState extends State { child: const SizedBox.shrink(), ); } + + Widget _buildRefreshCredentialButton() { + return Visibility( + visible: widget.claimModel.refreshable, + child: Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Align( + alignment: Alignment.center, + child: ElevatedButton( + onPressed: () { + widget._bloc.add( + ClaimDetailEvent.refreshClaim(claimId: widget.claimModel.id)); + }, + style: CustomButtonStyle.primaryButtonStyle, + child: const Text( + CustomStrings.refreshClaimButtonCTA, + style: CustomTextStyles.primaryButtonTextStyle, + ), + ), + ), + ), + ); + } } diff --git a/example/lib/src/presentation/ui/claims/claims_bloc.dart b/example/lib/src/presentation/ui/claims/claims_bloc.dart index f36217e5..29a54c04 100644 --- a/example/lib/src/presentation/ui/claims/claims_bloc.dart +++ b/example/lib/src/presentation/ui/claims/claims_bloc.dart @@ -1,6 +1,8 @@ import 'dart:async'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_constants.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; @@ -14,15 +16,19 @@ import 'package:polygonid_flutter_sdk_example/src/presentation/ui/claims/claims_ import 'package:polygonid_flutter_sdk_example/src/presentation/ui/claims/mappers/claim_model_mapper.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/claims/models/claim_model.dart'; import 'package:polygonid_flutter_sdk_example/utils/custom_strings.dart'; +import 'package:polygonid_flutter_sdk_example/utils/nonce_utils.dart'; +import 'package:polygonid_flutter_sdk_example/utils/qr_code_parser_utils.dart'; import 'package:polygonid_flutter_sdk_example/utils/secure_storage_keys.dart'; class ClaimsBloc extends Bloc { final ClaimModelMapper _mapper; final PolygonIdSdk _polygonIdSdk; + final QrcodeParserUtils _qrcodeParserUtils; ClaimsBloc( this._mapper, this._polygonIdSdk, + this._qrcodeParserUtils, ) : super(const ClaimsState.initial()) { on(_fetchAndSaveClaims); on(_getClaims); @@ -58,17 +64,23 @@ class ClaimsBloc extends Bloc { emit(const ClaimsState.loading()); Iden3MessageEntity iden3message = event.iden3message; - if (event.iden3message.messageType != Iden3MessageType.credentialOffer) { emit(const ClaimsState.error("Read message is not of type offer")); return; } + BigInt nonce = await NonceUtils(_polygonIdSdk).lookupNonce( + did: didIdentifier, + privateKey: privateKey, + from: iden3message.from) ?? + GENESIS_PROFILE_NONCE; + try { List claimList = await _polygonIdSdk.iden3comm.fetchAndSaveClaims( message: event.iden3message as OfferIden3MessageEntity, genesisDid: didIdentifier, + profileNonce: nonce, privateKey: privateKey, ); @@ -313,8 +325,8 @@ class ClaimsBloc extends Bloc { } try { - final Iden3MessageEntity iden3message = await _polygonIdSdk.iden3comm - .getIden3Message(message: qrCodeResponse!); + final Iden3MessageEntity iden3message = + await _qrcodeParserUtils.getIden3MessageFromQrCode(qrCodeResponse!); emit(ClaimsState.qrCodeScanned(iden3message)); } catch (error) { emit(const ClaimsState.error("Scanned code is not valid")); diff --git a/example/lib/src/presentation/ui/claims/mappers/claim_model_mapper.dart b/example/lib/src/presentation/ui/claims/mappers/claim_model_mapper.dart index 1f6b95a0..b92ef31d 100644 --- a/example/lib/src/presentation/ui/claims/mappers/claim_model_mapper.dart +++ b/example/lib/src/presentation/ui/claims/mappers/claim_model_mapper.dart @@ -51,7 +51,10 @@ class ClaimModelMapper implements FromMapper { proofType = proofType.substring(0, proofType.length - 1); } + bool refreshable = from.info.containsKey(["refreshService"]); + String value = ''; + // Details List details = []; @@ -89,13 +92,15 @@ class ClaimModelMapper implements FromMapper { ]); return ClaimModel( - id: from.id, - name: name, - issuer: from.issuer, - expiration: from.expiration, - state: stateMapper.mapFrom(from.state), - type: from.type, - value: value, - details: details); + id: from.id, + name: name, + issuer: from.issuer, + expiration: from.expiration, + state: stateMapper.mapFrom(from.state), + type: from.type, + value: value, + details: details, + refreshable: refreshable, + ); } } diff --git a/example/lib/src/presentation/ui/claims/models/claim_model.dart b/example/lib/src/presentation/ui/claims/models/claim_model.dart index 50656357..493d1f01 100644 --- a/example/lib/src/presentation/ui/claims/models/claim_model.dart +++ b/example/lib/src/presentation/ui/claims/models/claim_model.dart @@ -12,13 +12,17 @@ class ClaimModel { final String type; final List details; - ClaimModel( - {required this.id, - required this.value, - required this.expiration, - required this.issuer, - required this.type, - required this.state, - required this.name, - required this.details}); + final bool refreshable; + + ClaimModel({ + required this.id, + required this.value, + required this.expiration, + required this.issuer, + required this.type, + required this.state, + required this.name, + required this.details, + required this.refreshable, + }); } diff --git a/example/lib/src/presentation/ui/common/widgets/profile_radio_button.dart b/example/lib/src/presentation/ui/common/widgets/profile_radio_button.dart new file mode 100644 index 00000000..aa92a7f0 --- /dev/null +++ b/example/lib/src/presentation/ui/common/widgets/profile_radio_button.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:polygonid_flutter_sdk_example/utils/custom_colors.dart'; +import 'package:polygonid_flutter_sdk_example/utils/custom_strings.dart'; + +enum SelectedProfile { public, private } + +typedef ProfileCallback = void Function(SelectedProfile); + +class ProfileRadio extends StatelessWidget { + const ProfileRadio(SelectedProfile profile, ProfileCallback profileCallback, + {Key? key}) + : _profile = profile, + _profileCallback = profileCallback, + super(key: key); + + final ProfileCallback _profileCallback; + final SelectedProfile? _profile; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + _makeRadioListTile( + CustomStrings.authPublicProfile, SelectedProfile.public), + _makeRadioListTile( + CustomStrings.authPrivateProfile, SelectedProfile.private), + ], + ); + } + + Widget _makeRadioListTile(String text, SelectedProfile value) { + return RadioListTile( + title: Text(text), + value: value, + groupValue: _profile, + activeColor: CustomColors.primaryButton, + onChanged: (SelectedProfile? value) { + _profileCallback(value!); + }); + } +} diff --git a/example/lib/src/presentation/ui/home/home_bloc.dart b/example/lib/src/presentation/ui/home/home_bloc.dart index fb0b6d89..4e9b15ba 100644 --- a/example/lib/src/presentation/ui/home/home_bloc.dart +++ b/example/lib/src/presentation/ui/home/home_bloc.dart @@ -10,6 +10,7 @@ import 'package:polygonid_flutter_sdk_example/src/presentation/ui/home/home_even import 'package:polygonid_flutter_sdk_example/src/presentation/ui/home/home_state.dart'; import 'package:polygonid_flutter_sdk_example/utils/custom_strings.dart'; import 'package:polygonid_flutter_sdk_example/utils/secure_storage_keys.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; class HomeBloc extends Bloc { final PolygonIdSdk _polygonIdSdk; @@ -50,7 +51,7 @@ class HomeBloc extends Bloc { try { PrivateIdentityEntity identity = await _polygonIdSdk.identity.addIdentity(); - print("identity: ${identity.privateKey}"); + logger().i("identity: ${identity.privateKey}"); await SecureStorage.write( key: SecureStorageKeys.privateKey, value: identity.privateKey); emit(HomeState.loaded(identifier: identity.did)); diff --git a/example/lib/src/presentation/ui/splash/splash_bloc.dart b/example/lib/src/presentation/ui/splash/splash_bloc.dart index 469c9cac..a343fb22 100644 --- a/example/lib/src/presentation/ui/splash/splash_bloc.dart +++ b/example/lib/src/presentation/ui/splash/splash_bloc.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/download_info_entity.dart'; import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart'; import 'package:polygonid_flutter_sdk_example/src/presentation/ui/splash/splash_event.dart'; @@ -19,8 +20,25 @@ class SplashBloc extends Bloc { /// Simulation of a possible loading time Future onStartDownloadSplashEvent( StartDownloadSplashEvent event, Emitter emit) async { + //https://iden3-circuits-bucket.s3.eu-west-1.amazonaws.com/tmpv3.zip + //"https://circuits.polygonid.me/circuits/v1.0.0/polygonid-keys.zip" + Stream stream = - PolygonIdSdk.I.proof.initCircuitsDownloadAndGetInfoStream; + PolygonIdSdk.I.proof.initCircuitsDownloadAndGetInfoStream( + circuitsToDownload: [ + CircuitsToDownloadParam( + circuitsName: "circuitsV2", + bucketUrl: + "https://circuits.polygonid.me/circuits/v1.0.0/polygonid-keys.zip", + ), + CircuitsToDownloadParam( + circuitsName: "circuitsV3", + bucketUrl: + "https://iden3-circuits-bucket.s3.eu-west-1.amazonaws.com/circuitsv3-beta-0.zip", + ), + ], + ); + _subscription = stream.listen((downloadInfo) { add(DownloadProgressSplashEvent(downloadInfo)); }); diff --git a/example/lib/utils/custom_strings.dart b/example/lib/utils/custom_strings.dart index bd92134e..bb224f22 100644 --- a/example/lib/utils/custom_strings.dart +++ b/example/lib/utils/custom_strings.dart @@ -17,6 +17,8 @@ class CustomStrings { "You need to create an identity first"; // AUTH + static const String authPrivateProfile = "Private Profile"; + static const String authPublicProfile = "Public Profile"; static const String authButtonCTA = "Connect"; static const String authDescription = "Authenticate through verifier provider by scanning QR Code.\nIf you are already authenticated, you can skip this step"; @@ -45,7 +47,7 @@ class CustomStrings { // ERROR static const String genericError = "A generic error occurred, try again"; - static const String iden3messageGenericError = "Error in the readed message"; + static const String iden3messageGenericError = "Error in the read message"; // SIGN MESSAGE FEATURE CARD static const String signMessageMethod = "identity.sign()"; @@ -90,4 +92,5 @@ class CustomStrings { static const String restoreIdentityScreenInitialState = "Not restored yet"; static const String restoreIdentityScreenSuccess = "Identity restored successfully"; + static const String refreshClaimButtonCTA = "Refresh credential"; } diff --git a/example/lib/utils/nonce_utils.dart b/example/lib/utils/nonce_utils.dart new file mode 100644 index 00000000..c3951d4f --- /dev/null +++ b/example/lib/utils/nonce_utils.dart @@ -0,0 +1,96 @@ +import 'dart:math'; + +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; +import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart'; + +class NonceUtils { + static const PROFILE_NONCE_KEY = "profileNonce"; + + final PolygonIdSdk _polygonIdSdk; + + NonceUtils(this._polygonIdSdk); + + Future getPrivateProfileNonce({ + required String did, + required String privateKey, + required String from, + }) async { + final nonceLookup = + await lookupNonce(did: did, privateKey: privateKey, from: from); + + if (nonceLookup != null) { + logger().i("Found nonce for $from: $nonceLookup"); + return nonceLookup; + } + + return setupNewNonce(did: did, privateKey: privateKey, from: from); + } + + BigInt randomNonce() { + final random = Random.secure(); + const int size = 248; + BigInt value = BigInt.from(0); + for (var i = 0; i < size; i++) { + value = value << 1; + if (random.nextBool()) { + value = value | BigInt.from(1); + } + } + if (value == BigInt.zero) { + return randomNonce(); + } + return value; + } + + Future setupNewNonce({ + required String did, + required String privateKey, + required String from, + }) async { + BigInt nonce = randomNonce(); + logger().i("Generating new nonce for $from: $nonce"); + + await _polygonIdSdk.identity.addProfile( + genesisDid: did, privateKey: privateKey, profileNonce: nonce); + + Map info = { + PROFILE_NONCE_KEY: nonce.toString(), + }; + await _polygonIdSdk.iden3comm.addDidProfileInfo( + did: did, privateKey: privateKey, interactedWithDid: from, info: info); + + return nonce; + } + + Future lookupNonce({ + required String did, + required String privateKey, + required String from, + }) async { + Map readInfo = await _polygonIdSdk.iden3comm.getDidProfileInfo( + did: did, privateKey: privateKey, interactedWithDid: from); + logger().i("info from $from: $readInfo"); + + return (readInfo[PROFILE_NONCE_KEY] != null) + ? BigInt.parse(readInfo[PROFILE_NONCE_KEY]) + : null; + } + + Future removeProfileInfo({ + required String did, + required String privateKey, + required String from, + }) async { + Map profilesToDelete = await _polygonIdSdk.identity + .getProfiles(genesisDid: did, privateKey: privateKey); + for (var nonce in profilesToDelete.keys) { + if (nonce != BigInt.zero) { + await _polygonIdSdk.identity.removeProfile( + genesisDid: did, privateKey: privateKey, profileNonce: nonce); + } + } + + await _polygonIdSdk.iden3comm.removeDidProfileInfo( + did: did, privateKey: privateKey, interactedWithDid: from); + } +} diff --git a/example/lib/utils/qr_code_parser_utils.dart b/example/lib/utils/qr_code_parser_utils.dart new file mode 100644 index 00000000..eaef29b9 --- /dev/null +++ b/example/lib/utils/qr_code_parser_utils.dart @@ -0,0 +1,56 @@ +import 'dart:convert'; + +import 'package:http/http.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart'; + +class QrcodeParserUtils { + final PolygonIdSdk _polygonIdSdk; + + QrcodeParserUtils(this._polygonIdSdk); + + /// + Future getIden3MessageFromQrCode(String message) async { + try { + String rawMessage = message; + if (message.startsWith("iden3comm://?i_m")) { + rawMessage = await _getMessageFromBase64(message); + } + + if (message.startsWith("iden3comm://?request_uri")) { + rawMessage = await _getMessageFromRemote(message); + } + + Iden3MessageEntity? _iden3Message = + await _polygonIdSdk.iden3comm.getIden3Message(message: rawMessage); + return _iden3Message; + } catch (error) { + throw Exception("Error while processing the QR code"); + } + } + + /// + Future _getMessageFromRemote(String message) async { + try { + message = message.replaceAll("iden3comm://?request_uri=", ""); + Response response = await get(Uri.parse(message)); + if (response.statusCode != 200) { + throw Exception("Error while getting the message from the remote"); + } + return response.body; + } catch (error) { + throw Exception("Error while getting the message from the remote"); + } + } + + /// + Future _getMessageFromBase64(String message) async { + try { + message = message.replaceAll("iden3comm://?i_m=", ""); + String decodedMessage = String.fromCharCodes(base64.decode(message)); + return decodedMessage; + } catch (error) { + throw Exception("Error while getting the message from the base64"); + } + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b32c1d08..8e2a221d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,7 +5,7 @@ description: Demonstrates how to use the polygonid_flutter_sdk plugin. # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 2.2.8+23081801 +version: 2.2.9+24012901 environment: diff --git a/ios/Classes/libpolygonid.h b/ios/Classes/libpolygonid.h index f8a9ca58..fd376fb3 100644 --- a/ios/Classes/libpolygonid.h +++ b/ios/Classes/libpolygonid.h @@ -183,7 +183,19 @@ extern GoUint8 PLGNAtomicQuerySigV2OnChainInputs(char** jsonResponse, char* in, // } // extern GoUint8 PLGNAtomicQueryMtpV2OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3Inputs returns the inputs for the credentialAtomicQueryV3 +// circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3Inputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); + +// PLGNAtomicQueryV3OnChainInputs returns the inputs for the +// credentialAtomicQueryV3OnChain circuit with optional selective disclosure. +// +extern GoUint8 PLGNAtomicQueryV3OnChainInputs(char** jsonResponse, char* in, char* cfg, PLGNStatus** status); extern void PLGNFreeStatus(PLGNStatus* status); +extern GoUint8 PLGNCleanCache(PLGNStatus** status); +extern GoUint8 PLGNCacheCredentials(char* in, char* cfg, PLGNStatus** status); #ifdef __cplusplus } diff --git a/ios/Classes/witnesscalc_authV2.h b/ios/Classes/witnesscalc_authV2.h index e6fd96de..72b1f72b 100644 --- a/ios/Classes/witnesscalc_authV2.h +++ b/ios/Classes/witnesscalc_authV2.h @@ -6,6 +6,10 @@ extern "C" { #endif +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + /** * * @return error code: @@ -20,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_authV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/ios/Classes/witnesscalc_credentialAtomicQueryMTPV2.h b/ios/Classes/witnesscalc_credentialAtomicQueryMTPV2.h index a5382380..d2b80cfa 100644 --- a/ios/Classes/witnesscalc_credentialAtomicQueryMTPV2.h +++ b/ios/Classes/witnesscalc_credentialAtomicQueryMTPV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQueryMTPV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/ios/Classes/witnesscalc_credentialAtomicQuerySigV2.h b/ios/Classes/witnesscalc_credentialAtomicQuerySigV2.h index 80309e76..f03309b2 100644 --- a/ios/Classes/witnesscalc_credentialAtomicQuerySigV2.h +++ b/ios/Classes/witnesscalc_credentialAtomicQuerySigV2.h @@ -24,7 +24,7 @@ extern "C" { * */ -extern int +int witnesscalc_credentialAtomicQuerySigV2( const char *circuit_buffer, unsigned long circuit_size, const char *json_buffer, unsigned long json_size, diff --git a/ios/Classes/witnesscalc_credentialAtomicQueryV3.h b/ios/Classes/witnesscalc_credentialAtomicQueryV3.h new file mode 100644 index 00000000..50dfbfef --- /dev/null +++ b/ios/Classes/witnesscalc_credentialAtomicQueryV3.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3_H diff --git a/ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h b/ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h new file mode 100644 index 00000000..c958b7bb --- /dev/null +++ b/ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h @@ -0,0 +1,39 @@ +#ifndef WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H +#define WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define WITNESSCALC_OK 0x0 +#define WITNESSCALC_ERROR 0x1 +#define WITNESSCALC_ERROR_SHORT_BUFFER 0x2 + +/** + * + * @return error code: + * WITNESSCALC_OK - in case of success. + * WITNESSCALC_ERROR - in case of an error. + * + * On success wtns_buffer is filled with witness data and + * wtns_size contains the number bytes copied to wtns_buffer. + * + * If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + * and the minimum size for wtns_buffer in wtns_size. + * + */ + +int +witnesscalc_credentialAtomicQueryV3OnChain( + const char *circuit_buffer, unsigned long circuit_size, + const char *json_buffer, unsigned long json_size, + char *wtns_buffer, unsigned long *wtns_size, + char *error_msg, unsigned long error_msg_maxsize); + +#ifdef __cplusplus +} +#endif + + +#endif // WITNESSCALC_CREDENTIALATOMICQUERYV3ONCHAIN_H diff --git a/ios/libfr.a b/ios/libfr.a index 63c83665..15e2a05d 100644 Binary files a/ios/libfr.a and b/ios/libfr.a differ diff --git a/ios/libgmp.a b/ios/libgmp.a index f93cef78..5aadbd4a 100644 Binary files a/ios/libgmp.a and b/ios/libgmp.a differ diff --git a/ios/libpolygonid-ios-simulator.a b/ios/libpolygonid-ios-simulator.a index 72a08e0b..b0a54ac6 100644 Binary files a/ios/libpolygonid-ios-simulator.a and b/ios/libpolygonid-ios-simulator.a differ diff --git a/ios/libpolygonid-ios.a b/ios/libpolygonid-ios.a index af90c38e..c856ea90 100644 Binary files a/ios/libpolygonid-ios.a and b/ios/libpolygonid-ios.a differ diff --git a/ios/libpolygonid.a b/ios/libpolygonid.a index 21a6898e..239d8fce 100644 Binary files a/ios/libpolygonid.a and b/ios/libpolygonid.a differ diff --git a/ios/libwitnesscalc_authV2.a b/ios/libwitnesscalc_authV2.a index f808096b..a88ce358 100644 Binary files a/ios/libwitnesscalc_authV2.a and b/ios/libwitnesscalc_authV2.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a b/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a index 0853f76f..298dbb92 100644 Binary files a/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a and b/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a b/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a index 9ab364a2..3b8ab415 100644 Binary files a/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a and b/ios/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQuerySigV2.a b/ios/libwitnesscalc_credentialAtomicQuerySigV2.a index e31022c6..36191673 100644 Binary files a/ios/libwitnesscalc_credentialAtomicQuerySigV2.a and b/ios/libwitnesscalc_credentialAtomicQuerySigV2.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a b/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a index c8d6d06e..ff811d55 100644 Binary files a/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a and b/ios/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQueryV3.a b/ios/libwitnesscalc_credentialAtomicQueryV3.a new file mode 100644 index 00000000..79512eb3 Binary files /dev/null and b/ios/libwitnesscalc_credentialAtomicQueryV3.a differ diff --git a/ios/libwitnesscalc_credentialAtomicQueryV3OnChain.a b/ios/libwitnesscalc_credentialAtomicQueryV3OnChain.a new file mode 100644 index 00000000..7242cc31 Binary files /dev/null and b/ios/libwitnesscalc_credentialAtomicQueryV3OnChain.a differ diff --git a/ios/polygonid_flutter_sdk.podspec b/ios/polygonid_flutter_sdk.podspec index 373a9564..b4f53a43 100644 --- a/ios/polygonid_flutter_sdk.podspec +++ b/ios/polygonid_flutter_sdk.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'polygonid_flutter_sdk' - s.version = '2.2.8' + s.version = '2.2.9' s.summary = 'Flutter plugin for PolygonID SDK' s.description = <<-DESC PolygonID SDK flutter plugin project. @@ -24,7 +24,7 @@ PolygonID SDK flutter plugin project. # s.ios.deployment_target = '9.0' # s.ios.vendored_frameworks = 'Frameworks/Core.xcframework' # Flutter.framework does not contain a i386 nor arm64 slice. - s.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-force_load $(PODS_TARGET_SRCROOT)/Frameworks/libbabyjubjub.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libpolygonid.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/librapidsnark.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_authV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryMTPV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQuerySigV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libgmp.a -lc++ -lz" } + s.pod_target_xcconfig = { "OTHER_LDFLAGS" => "-force_load $(PODS_TARGET_SRCROOT)/Frameworks/libbabyjubjub.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libpolygonid.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/librapidsnark.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_authV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryMTPV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQuerySigV2.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQuerySigV2OnChain.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryMTPV2OnChain.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryV3.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libwitnesscalc_credentialAtomicQueryV3OnChain.a -force_load $(PODS_TARGET_SRCROOT)/Frameworks/libgmp.a -lc++ -lz" } # s.vendored_libraries = "Frameworks/**/*.a" s.pod_target_xcconfig = { 'STRIP_STYLE' => 'non-global', diff --git a/lib/common/infrastructure/stacktrace_stream_manager.dart b/lib/common/infrastructure/stacktrace_stream_manager.dart index fdaa5761..44814d08 100644 --- a/lib/common/infrastructure/stacktrace_stream_manager.dart +++ b/lib/common/infrastructure/stacktrace_stream_manager.dart @@ -2,22 +2,56 @@ import 'dart:async'; import 'package:hive/hive.dart'; import 'package:injectable/injectable.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; + +const _stacktraceBoxName = 'stacktrace'; @lazySingleton class StacktraceManager { bool isEnabled = false; - static const String stacktraceBoxName = 'stacktrace'; + String _errorTrace = ''; - StreamController _stacktraceStreamController = - StreamController.broadcast(); + String _stacktrace = ''; - StreamController _errorStreamController = - StreamController.broadcast(); + var _stacktraceStreamController = StreamController.broadcast(); + var _errorStreamController = StreamController.broadcast(); Stream get stacktraceStream => _stacktraceStreamController.stream; Stream get errorStream => _errorStreamController.stream; + /// Get the stacktrace + String get stacktrace { + if (!_isBoxOpen()) return ''; + var box = Hive.box(_stacktraceBoxName); + final _stacktrace = box.get(_stacktraceBoxName) ?? ''; + return _stacktrace; + } + + /// Get the error trace + String get errorTrace => _errorTrace; + + /// Add new trace to the stacktrace + void addTrace(String stepDescription, {bool log = false}) { + if (log) { + logger().i(stepDescription); + } + + if (!isEnabled || !_isBoxOpen()) return; + + // write string in an encrypted Hive box + final box = Hive.box(_stacktraceBoxName); + + _stacktrace += stepDescription + '\n***\n***'; + box.put(_stacktraceBoxName, _stacktrace); + _stacktraceStreamController.add(stepDescription); + } + + void addError(String error) { + _errorTrace += '\n***' + error + '\n***'; + _errorStreamController.add(error); + } + /// we reset the stream /// so we can use it again void reset() { @@ -28,8 +62,13 @@ class StacktraceManager { _errorStreamController = StreamController.broadcast(); } - /// we clear the stacktrace + /// Clear the stacktrace void clear() { + return; + } + + void clearStacktrace() { + _stacktrace = ''; _errorTrace = ''; _stacktraceStreamController.add(''); _errorStreamController.add(_errorTrace); @@ -38,46 +77,16 @@ class StacktraceManager { } if (_isBoxOpen()) { - var box = Hive.box(stacktraceBoxName); + final box = Hive.box(_stacktraceBoxName); box.clear(); } } - /// we close the stream + /// Close streams void dispose() { _stacktraceStreamController.close(); _errorStreamController.close(); } - /// we add a new trace to the stacktrace stream - void addTrace(String stepDescription) { - if (!isEnabled || !_isBoxOpen()) return; - //write string in an external txt file - - var box = Hive.box(stacktraceBoxName); - - String _stacktrace = box.get(stacktraceBoxName) ?? ''; - _stacktrace += stepDescription + '\n***\n***'; - box.put(stacktraceBoxName, _stacktrace); - _stacktraceStreamController.add(stepDescription); - } - - void addError(String error) { - _errorTrace += '\n***' + error + '\n***'; - _errorStreamController.add(error); - } - - /// get the stacktrace - String get stacktrace { - if (!_isBoxOpen()) return ''; - var box = Hive.box(stacktraceBoxName); - String _stacktrace = box.get(stacktraceBoxName) ?? ''; - return _stacktrace; - } - - /// get the error trace - String get errorTrace => _errorTrace; - - /// - bool _isBoxOpen() => Hive.isBoxOpen(stacktraceBoxName); + bool _isBoxOpen() => Hive.isBoxOpen(_stacktraceBoxName); } diff --git a/lib/common/libs/polygonidcore/native_polygonidcore.dart b/lib/common/libs/polygonidcore/native_polygonidcore.dart index 6d85ae8b..d43e0add 100644 --- a/lib/common/libs/polygonidcore/native_polygonidcore.dart +++ b/lib/common/libs/polygonidcore/native_polygonidcore.dart @@ -269,6 +269,264 @@ class NativePolygonIdCoreLib { set __mb_cur_max(int value) => ___mb_cur_max.value = value; + ffi.Pointer malloc_type_malloc( + int size, + int type_id, + ) { + return _malloc_type_malloc( + size, + type_id, + ); + } + + late final _malloc_type_mallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Size, malloc_type_id_t)>>('malloc_type_malloc'); + late final _malloc_type_malloc = _malloc_type_mallocPtr + .asFunction Function(int, int)>(); + + ffi.Pointer malloc_type_calloc( + int count, + int size, + int type_id, + ) { + return _malloc_type_calloc( + count, + size, + type_id, + ); + } + + late final _malloc_type_callocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Size, ffi.Size, malloc_type_id_t)>>('malloc_type_calloc'); + late final _malloc_type_calloc = _malloc_type_callocPtr + .asFunction Function(int, int, int)>(); + + void malloc_type_free( + ffi.Pointer ptr, + int type_id, + ) { + return _malloc_type_free( + ptr, + type_id, + ); + } + + late final _malloc_type_freePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, malloc_type_id_t)>>('malloc_type_free'); + late final _malloc_type_free = _malloc_type_freePtr + .asFunction, int)>(); + + ffi.Pointer malloc_type_realloc( + ffi.Pointer ptr, + int size, + int type_id, + ) { + return _malloc_type_realloc( + ptr, + size, + type_id, + ); + } + + late final _malloc_type_reallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Size, + malloc_type_id_t)>>('malloc_type_realloc'); + late final _malloc_type_realloc = _malloc_type_reallocPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + ffi.Pointer malloc_type_valloc( + int size, + int type_id, + ) { + return _malloc_type_valloc( + size, + type_id, + ); + } + + late final _malloc_type_vallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Size, malloc_type_id_t)>>('malloc_type_valloc'); + late final _malloc_type_valloc = _malloc_type_vallocPtr + .asFunction Function(int, int)>(); + + ffi.Pointer malloc_type_aligned_alloc( + int alignment, + int size, + int type_id, + ) { + return _malloc_type_aligned_alloc( + alignment, + size, + type_id, + ); + } + + late final _malloc_type_aligned_allocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Size, ffi.Size, + malloc_type_id_t)>>('malloc_type_aligned_alloc'); + late final _malloc_type_aligned_alloc = _malloc_type_aligned_allocPtr + .asFunction Function(int, int, int)>(); + + int malloc_type_posix_memalign( + ffi.Pointer> memptr, + int alignment, + int size, + int type_id, + ) { + return _malloc_type_posix_memalign( + memptr, + alignment, + size, + type_id, + ); + } + + late final _malloc_type_posix_memalignPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer>, ffi.Size, + ffi.Size, malloc_type_id_t)>>('malloc_type_posix_memalign'); + late final _malloc_type_posix_memalign = + _malloc_type_posix_memalignPtr.asFunction< + int Function(ffi.Pointer>, int, int, int)>(); + + ffi.Pointer malloc_type_zone_malloc( + ffi.Pointer zone, + int size, + int type_id, + ) { + return _malloc_type_zone_malloc( + zone, + size, + type_id, + ); + } + + late final _malloc_type_zone_mallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Size, + malloc_type_id_t)>>('malloc_type_zone_malloc'); + late final _malloc_type_zone_malloc = _malloc_type_zone_mallocPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + ffi.Pointer malloc_type_zone_calloc( + ffi.Pointer zone, + int count, + int size, + int type_id, + ) { + return _malloc_type_zone_calloc( + zone, + count, + size, + type_id, + ); + } + + late final _malloc_type_zone_callocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Size, + ffi.Size, malloc_type_id_t)>>('malloc_type_zone_calloc'); + late final _malloc_type_zone_calloc = _malloc_type_zone_callocPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, int, int)>(); + + void malloc_type_zone_free( + ffi.Pointer zone, + ffi.Pointer ptr, + int type_id, + ) { + return _malloc_type_zone_free( + zone, + ptr, + type_id, + ); + } + + late final _malloc_type_zone_freePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + malloc_type_id_t)>>('malloc_type_zone_free'); + late final _malloc_type_zone_free = _malloc_type_zone_freePtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + ffi.Pointer malloc_type_zone_realloc( + ffi.Pointer zone, + ffi.Pointer ptr, + int size, + int type_id, + ) { + return _malloc_type_zone_realloc( + zone, + ptr, + size, + type_id, + ); + } + + late final _malloc_type_zone_reallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + malloc_type_id_t)>>('malloc_type_zone_realloc'); + late final _malloc_type_zone_realloc = + _malloc_type_zone_reallocPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + ffi.Pointer malloc_type_zone_valloc( + ffi.Pointer zone, + int size, + int type_id, + ) { + return _malloc_type_zone_valloc( + zone, + size, + type_id, + ); + } + + late final _malloc_type_zone_vallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Size, + malloc_type_id_t)>>('malloc_type_zone_valloc'); + late final _malloc_type_zone_valloc = _malloc_type_zone_vallocPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + ffi.Pointer malloc_type_zone_memalign( + ffi.Pointer zone, + int alignment, + int size, + int type_id, + ) { + return _malloc_type_zone_memalign( + zone, + alignment, + size, + type_id, + ); + } + + late final _malloc_type_zone_memalignPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Size, + ffi.Size, malloc_type_id_t)>>('malloc_type_zone_memalign'); + late final _malloc_type_zone_memalign = + _malloc_type_zone_memalignPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, int, int)>(); + ffi.Pointer malloc( int __size, ) { @@ -294,9 +552,8 @@ class NativePolygonIdCoreLib { } late final _callocPtr = _lookup< - ffi - .NativeFunction Function(ffi.Size, ffi.Size)>>( - 'calloc'); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Size, ffi.Size)>>('calloc'); late final _calloc = _callocPtr.asFunction Function(int, int)>(); @@ -356,9 +613,8 @@ class NativePolygonIdCoreLib { } late final _aligned_allocPtr = _lookup< - ffi - .NativeFunction Function(ffi.Size, ffi.Size)>>( - 'aligned_alloc'); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Size, ffi.Size)>>('aligned_alloc'); late final _aligned_alloc = _aligned_allocPtr.asFunction Function(int, int)>(); @@ -615,9 +871,8 @@ class NativePolygonIdCoreLib { } late final _mblenPtr = _lookup< - ffi - .NativeFunction, ffi.Size)>>( - 'mblen'); + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Size)>>('mblen'); late final _mblen = _mblenPtr.asFunction, int)>(); @@ -875,9 +1130,8 @@ class NativePolygonIdCoreLib { } late final _wctombPtr = _lookup< - ffi - .NativeFunction, ffi.WChar)>>( - 'wctomb'); + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.WChar)>>('wctomb'); late final _wctomb = _wctombPtr.asFunction, int)>(); @@ -945,9 +1199,8 @@ class NativePolygonIdCoreLib { } late final _erand48Ptr = _lookup< - ffi - .NativeFunction)>>( - 'erand48'); + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer)>>('erand48'); late final _erand48 = _erand48Ptr.asFunction)>(); @@ -1056,9 +1309,8 @@ class NativePolygonIdCoreLib { } late final _jrand48Ptr = _lookup< - ffi - .NativeFunction)>>( - 'jrand48'); + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer)>>('jrand48'); late final _jrand48 = _jrand48Ptr.asFunction)>(); @@ -1084,9 +1336,8 @@ class NativePolygonIdCoreLib { } late final _lcong48Ptr = _lookup< - ffi - .NativeFunction)>>( - 'lcong48'); + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer)>>('lcong48'); late final _lcong48 = _lcong48Ptr.asFunction)>(); @@ -1143,9 +1394,8 @@ class NativePolygonIdCoreLib { } late final _nrand48Ptr = _lookup< - ffi - .NativeFunction)>>( - 'nrand48'); + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer)>>('nrand48'); late final _nrand48 = _nrand48Ptr.asFunction)>(); @@ -1398,9 +1648,9 @@ class NativePolygonIdCoreLib { } late final _arc4random_bufPtr = _lookup< - ffi - .NativeFunction, ffi.Size)>>( - 'arc4random_buf'); + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Size)>>('arc4random_buf'); late final _arc4random_buf = _arc4random_bufPtr .asFunction, int)>(); @@ -1684,9 +1934,8 @@ class NativePolygonIdCoreLib { } late final _getloadavgPtr = _lookup< - ffi - .NativeFunction, ffi.Int)>>( - 'getloadavg'); + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int)>>('getloadavg'); late final _getloadavg = _getloadavgPtr.asFunction, int)>(); @@ -2611,9 +2860,8 @@ class NativePolygonIdCoreLib { } late final _strnlenPtr = _lookup< - ffi - .NativeFunction, ffi.Size)>>( - 'strnlen'); + ffi.NativeFunction< + ffi.Size Function(ffi.Pointer, ffi.Size)>>('strnlen'); late final _strnlen = _strnlenPtr.asFunction, int)>(); @@ -2818,9 +3066,8 @@ class NativePolygonIdCoreLib { } late final _strmodePtr = _lookup< - ffi - .NativeFunction)>>( - 'strmode'); + ffi.NativeFunction< + ffi.Void Function(ffi.Int, ffi.Pointer)>>('strmode'); late final _strmode = _strmodePtr.asFunction)>(); @@ -2948,9 +3195,8 @@ class NativePolygonIdCoreLib { } late final _bzeroPtr = _lookup< - ffi - .NativeFunction, ffi.Size)>>( - 'bzero'); + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Size)>>('bzero'); late final _bzero = _bzeroPtr.asFunction, int)>(); @@ -3395,6 +3641,62 @@ class NativePolygonIdCoreLib { ffi.Pointer, ffi.Pointer>)>(); + int PLGNAtomicQueryV3Inputs( + ffi.Pointer> jsonResponse, + ffi.Pointer in1, + ffi.Pointer cfg, + ffi.Pointer> status, + ) { + return _PLGNAtomicQueryV3Inputs( + jsonResponse, + in1, + cfg, + status, + ); + } + + late final _PLGNAtomicQueryV3InputsPtr = _lookup< + ffi.NativeFunction< + GoUint8 Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>( + 'PLGNAtomicQueryV3Inputs'); + late final _PLGNAtomicQueryV3Inputs = _PLGNAtomicQueryV3InputsPtr.asFunction< + int Function(ffi.Pointer>, ffi.Pointer, + ffi.Pointer, ffi.Pointer>)>(); + + int PLGNAtomicQueryV3OnChainInputs( + ffi.Pointer> jsonResponse, + ffi.Pointer in1, + ffi.Pointer cfg, + ffi.Pointer> status, + ) { + return _PLGNAtomicQueryV3OnChainInputs( + jsonResponse, + in1, + cfg, + status, + ); + } + + late final _PLGNAtomicQueryV3OnChainInputsPtr = _lookup< + ffi.NativeFunction< + GoUint8 Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>>( + 'PLGNAtomicQueryV3OnChainInputs'); + late final _PLGNAtomicQueryV3OnChainInputs = + _PLGNAtomicQueryV3OnChainInputsPtr.asFunction< + int Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); + void PLGNFreeStatus( ffi.Pointer status, ) { @@ -3408,6 +3710,26 @@ class NativePolygonIdCoreLib { 'PLGNFreeStatus'); late final _PLGNFreeStatus = _PLGNFreeStatusPtr.asFunction)>(); + + int PLGNCacheCredentials( + ffi.Pointer in1, + ffi.Pointer cfg, + ffi.Pointer> status, + ) { + return _PLGNCacheCredentials( + in1, + cfg, + status, + ); + } + + late final _PLGNCacheCredentialsPtr = _lookup< + ffi.NativeFunction< + GoUint8 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>>('PLGNCacheCredentials'); + late final _PLGNCacheCredentials = _PLGNCacheCredentialsPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(); } class __mbstate_t extends ffi.Union { @@ -3420,7 +3742,7 @@ class __mbstate_t extends ffi.Union { class __darwin_pthread_handler_rec extends ffi.Struct { external ffi - .Pointer)>> + .Pointer)>> __routine; external ffi.Pointer __arg; @@ -4527,6 +4849,11 @@ class lldiv_t extends ffi.Struct { external int rem; } +typedef malloc_type_id_t = ffi.UnsignedLongLong; + +class _malloc_zone_t extends ffi.Opaque {} + +typedef malloc_zone_t = _malloc_zone_t; typedef dev_t = __darwin_dev_t; typedef __darwin_dev_t = __int32_t; typedef mode_t = __darwin_mode_t; @@ -4646,14 +4973,16 @@ const int __API_TO_BE_DEPRECATED_MACOS = 100000; const int __API_TO_BE_DEPRECATED_IOS = 100000; -const int __API_TO_BE_DEPRECATED_TVOS = 100000; +const int __API_TO_BE_DEPRECATED_MACCATALYST = 100000; const int __API_TO_BE_DEPRECATED_WATCHOS = 100000; -const int __API_TO_BE_DEPRECATED_MACCATALYST = 100000; +const int __API_TO_BE_DEPRECATED_TVOS = 100000; const int __API_TO_BE_DEPRECATED_DRIVERKIT = 100000; +const int __API_TO_BE_DEPRECATED_XROS = 100000; + const int __MAC_10_0 = 1000; const int __MAC_10_1 = 1010; @@ -4710,6 +5039,8 @@ const int __MAC_10_14_1 = 101401; const int __MAC_10_14_4 = 101404; +const int __MAC_10_14_5 = 101405; + const int __MAC_10_14_6 = 101406; const int __MAC_10_15 = 101500; @@ -4740,6 +5071,10 @@ const int __MAC_12_2 = 120200; const int __MAC_12_3 = 120300; +const int __MAC_12_4 = 120400; + +const int __MAC_12_5 = 120500; + const int __MAC_13_0 = 130000; const int __MAC_13_1 = 130100; @@ -4748,6 +5083,10 @@ const int __MAC_13_2 = 130200; const int __MAC_13_3 = 130300; +const int __MAC_13_4 = 130400; + +const int __MAC_14_0 = 140000; + const int __IPHONE_2_0 = 20000; const int __IPHONE_2_1 = 20100; @@ -4852,6 +5191,8 @@ const int __IPHONE_14_3 = 140300; const int __IPHONE_14_5 = 140500; +const int __IPHONE_14_4 = 140400; + const int __IPHONE_14_6 = 140600; const int __IPHONE_14_7 = 140700; @@ -4868,6 +5209,10 @@ const int __IPHONE_15_3 = 150300; const int __IPHONE_15_4 = 150400; +const int __IPHONE_15_5 = 150500; + +const int __IPHONE_15_6 = 150600; + const int __IPHONE_16_0 = 160000; const int __IPHONE_16_1 = 160100; @@ -4878,6 +5223,90 @@ const int __IPHONE_16_3 = 160300; const int __IPHONE_16_4 = 160400; +const int __IPHONE_16_5 = 160500; + +const int __IPHONE_17_0 = 170000; + +const int __WATCHOS_1_0 = 10000; + +const int __WATCHOS_2_0 = 20000; + +const int __WATCHOS_2_1 = 20100; + +const int __WATCHOS_2_2 = 20200; + +const int __WATCHOS_3_0 = 30000; + +const int __WATCHOS_3_1 = 30100; + +const int __WATCHOS_3_1_1 = 30101; + +const int __WATCHOS_3_2 = 30200; + +const int __WATCHOS_4_0 = 40000; + +const int __WATCHOS_4_1 = 40100; + +const int __WATCHOS_4_2 = 40200; + +const int __WATCHOS_4_3 = 40300; + +const int __WATCHOS_5_0 = 50000; + +const int __WATCHOS_5_1 = 50100; + +const int __WATCHOS_5_2 = 50200; + +const int __WATCHOS_5_3 = 50300; + +const int __WATCHOS_6_0 = 60000; + +const int __WATCHOS_6_1 = 60100; + +const int __WATCHOS_6_2 = 60200; + +const int __WATCHOS_7_0 = 70000; + +const int __WATCHOS_7_1 = 70100; + +const int __WATCHOS_7_2 = 70200; + +const int __WATCHOS_7_3 = 70300; + +const int __WATCHOS_7_4 = 70400; + +const int __WATCHOS_7_5 = 70500; + +const int __WATCHOS_7_6 = 70600; + +const int __WATCHOS_8_0 = 80000; + +const int __WATCHOS_8_1 = 80100; + +const int __WATCHOS_8_3 = 80300; + +const int __WATCHOS_8_4 = 80400; + +const int __WATCHOS_8_5 = 80500; + +const int __WATCHOS_8_6 = 80600; + +const int __WATCHOS_8_7 = 80700; + +const int __WATCHOS_9_0 = 90000; + +const int __WATCHOS_9_1 = 90100; + +const int __WATCHOS_9_2 = 90200; + +const int __WATCHOS_9_3 = 90300; + +const int __WATCHOS_9_4 = 90400; + +const int __WATCHOS_9_5 = 90500; + +const int __WATCHOS_10_0 = 100000; + const int __TVOS_9_0 = 90000; const int __TVOS_9_1 = 90100; @@ -4944,6 +5373,10 @@ const int __TVOS_15_3 = 150300; const int __TVOS_15_4 = 150400; +const int __TVOS_15_5 = 150500; + +const int __TVOS_15_6 = 150600; + const int __TVOS_16_0 = 160000; const int __TVOS_16_1 = 160100; @@ -4954,77 +5387,65 @@ const int __TVOS_16_3 = 160300; const int __TVOS_16_4 = 160400; -const int __WATCHOS_1_0 = 10000; - -const int __WATCHOS_2_0 = 20000; - -const int __WATCHOS_2_1 = 20100; - -const int __WATCHOS_2_2 = 20200; - -const int __WATCHOS_3_0 = 30000; +const int __TVOS_16_5 = 160500; -const int __WATCHOS_3_1 = 30100; - -const int __WATCHOS_3_1_1 = 30101; - -const int __WATCHOS_3_2 = 30200; +const int __TVOS_17_0 = 170000; -const int __WATCHOS_4_0 = 40000; +const int __BRIDGEOS_2_0 = 20000; -const int __WATCHOS_4_1 = 40100; +const int __BRIDGEOS_3_0 = 30000; -const int __WATCHOS_4_2 = 40200; +const int __BRIDGEOS_3_1 = 30100; -const int __WATCHOS_4_3 = 40300; +const int __BRIDGEOS_3_4 = 30400; -const int __WATCHOS_5_0 = 50000; +const int __BRIDGEOS_4_0 = 40000; -const int __WATCHOS_5_1 = 50100; +const int __BRIDGEOS_4_1 = 40100; -const int __WATCHOS_5_2 = 50200; +const int __BRIDGEOS_5_0 = 50000; -const int __WATCHOS_5_3 = 50300; +const int __BRIDGEOS_5_1 = 50100; -const int __WATCHOS_6_0 = 60000; +const int __BRIDGEOS_5_3 = 50300; -const int __WATCHOS_6_1 = 60100; +const int __BRIDGEOS_6_0 = 60000; -const int __WATCHOS_6_2 = 60200; +const int __BRIDGEOS_6_2 = 60200; -const int __WATCHOS_7_0 = 70000; +const int __BRIDGEOS_6_4 = 60400; -const int __WATCHOS_7_1 = 70100; +const int __BRIDGEOS_6_5 = 60500; -const int __WATCHOS_7_2 = 70200; +const int __BRIDGEOS_6_6 = 60600; -const int __WATCHOS_7_3 = 70300; +const int __BRIDGEOS_7_0 = 70000; -const int __WATCHOS_7_4 = 70400; +const int __BRIDGEOS_7_1 = 70100; -const int __WATCHOS_7_5 = 70500; +const int __BRIDGEOS_7_2 = 70200; -const int __WATCHOS_7_6 = 70600; +const int __BRIDGEOS_7_3 = 70300; -const int __WATCHOS_8_0 = 80000; +const int __BRIDGEOS_7_4 = 70400; -const int __WATCHOS_8_1 = 80100; +const int __BRIDGEOS_8_0 = 80000; -const int __WATCHOS_8_3 = 80300; +const int __DRIVERKIT_19_0 = 190000; -const int __WATCHOS_8_4 = 80400; +const int __DRIVERKIT_20_0 = 200000; -const int __WATCHOS_8_5 = 80500; +const int __DRIVERKIT_21_0 = 210000; -const int __WATCHOS_9_0 = 90000; +const int __DRIVERKIT_22_0 = 220000; -const int __WATCHOS_9_1 = 90100; +const int __DRIVERKIT_22_4 = 220400; -const int __WATCHOS_9_2 = 90200; +const int __DRIVERKIT_22_5 = 220500; -const int __WATCHOS_9_3 = 90300; +const int __DRIVERKIT_23_0 = 230000; -const int __WATCHOS_9_4 = 90400; +const int __XROS_1_0 = 10000; const int MAC_OS_X_VERSION_10_0 = 1000; @@ -5082,29 +5503,57 @@ const int MAC_OS_X_VERSION_10_14_1 = 101401; const int MAC_OS_X_VERSION_10_14_4 = 101404; +const int MAC_OS_X_VERSION_10_14_5 = 101405; + const int MAC_OS_X_VERSION_10_14_6 = 101406; const int MAC_OS_X_VERSION_10_15 = 101500; const int MAC_OS_X_VERSION_10_15_1 = 101501; +const int MAC_OS_X_VERSION_10_15_4 = 101504; + const int MAC_OS_X_VERSION_10_16 = 101600; const int MAC_OS_VERSION_11_0 = 110000; +const int MAC_OS_VERSION_11_1 = 110100; + +const int MAC_OS_VERSION_11_3 = 110300; + +const int MAC_OS_VERSION_11_4 = 110400; + +const int MAC_OS_VERSION_11_5 = 110500; + +const int MAC_OS_VERSION_11_6 = 110600; + const int MAC_OS_VERSION_12_0 = 120000; +const int MAC_OS_VERSION_12_1 = 120100; + +const int MAC_OS_VERSION_12_2 = 120200; + +const int MAC_OS_VERSION_12_3 = 120300; + +const int MAC_OS_VERSION_12_4 = 120400; + +const int MAC_OS_VERSION_12_5 = 120500; + const int MAC_OS_VERSION_13_0 = 130000; -const int __DRIVERKIT_19_0 = 190000; +const int MAC_OS_VERSION_13_1 = 130100; -const int __DRIVERKIT_20_0 = 200000; +const int MAC_OS_VERSION_13_2 = 130200; -const int __DRIVERKIT_21_0 = 210000; +const int MAC_OS_VERSION_13_3 = 130300; + +const int MAC_OS_VERSION_13_4 = 130400; + +const int MAC_OS_VERSION_14_0 = 140000; -const int __MAC_OS_X_VERSION_MIN_REQUIRED = 130000; +const int __MAC_OS_X_VERSION_MIN_REQUIRED = 140000; -const int __MAC_OS_X_VERSION_MAX_ALLOWED = 130300; +const int __MAC_OS_X_VERSION_MAX_ALLOWED = 140000; const int __ENABLE_LEGACY_MAC_AVAILABILITY = 1; @@ -5600,6 +6049,10 @@ const int IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT = 0; const int IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON = 1; +const int IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT = 0; + +const int IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON = 1; + const int WNOHANG = 1; const int WUNTRACED = 2; diff --git a/lib/common/libs/polygonidcore/pidcore_base.dart b/lib/common/libs/polygonidcore/pidcore_base.dart index 8d2545f4..662886e4 100644 --- a/lib/common/libs/polygonidcore/pidcore_base.dart +++ b/lib/common/libs/polygonidcore/pidcore_base.dart @@ -18,7 +18,8 @@ class PolygonIdCore { PolygonIdCore(); - String? consumeStatus(ffi.Pointer> status, String msg) { + String? consumeStatus( + ffi.Pointer> status, String msg) { if (status == ffi.nullptr || status.value == ffi.nullptr) { if (kDebugMode) { print("unable to allocate status\n"); diff --git a/lib/common/utils/format_utils.dart b/lib/common/utils/format_utils.dart new file mode 100644 index 00000000..d657c884 --- /dev/null +++ b/lib/common/utils/format_utils.dart @@ -0,0 +1,12 @@ +class FormatUtils { + static Map convertSnakeCaseToCamelCase( + Map map) { + var newMap = {}; + map.forEach((key, value) { + var newKey = key.replaceAllMapped( + RegExp(r'_([a-zA-Z])'), (Match m) => m[1]!.toUpperCase()); + newMap[newKey] = value; + }); + return newMap; + } +} diff --git a/lib/credential/data/credential_repository_impl.dart b/lib/credential/data/credential_repository_impl.dart index 4625430c..4dbc1564 100644 --- a/lib/credential/data/credential_repository_impl.dart +++ b/lib/credential/data/credential_repository_impl.dart @@ -1,5 +1,6 @@ import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filters_mapper.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; +import 'package:polygonid_flutter_sdk/credential/data/data_sources/cache_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/data_sources/remote_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/data_sources/storage_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_dto.dart'; @@ -14,6 +15,7 @@ import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/reque import 'package:polygonid_flutter_sdk/identity/data/data_sources/db_destination_path_data_source.dart'; import 'package:polygonid_flutter_sdk/identity/data/data_sources/encryption_db_data_source.dart'; import 'package:polygonid_flutter_sdk/identity/data/mappers/encryption_key_mapper.dart'; +import 'package:sembast/sembast.dart'; import 'data_sources/local_claim_data_source.dart'; import 'dtos/claim_info_dto.dart'; @@ -22,6 +24,7 @@ class CredentialRepositoryImpl extends CredentialRepository { final RemoteClaimDataSource _remoteClaimDataSource; final StorageClaimDataSource _storageClaimDataSource; final LocalClaimDataSource _localClaimDataSource; + final CacheCredentialDataSource _cacheCredentialDataSource; final ClaimMapper _claimMapper; final FiltersMapper _filtersMapper; final IdFilterMapper _idFilterMapper; @@ -30,6 +33,7 @@ class CredentialRepositoryImpl extends CredentialRepository { this._remoteClaimDataSource, this._storageClaimDataSource, this._localClaimDataSource, + this._cacheCredentialDataSource, this._claimMapper, this._filtersMapper, this._idFilterMapper, @@ -52,30 +56,62 @@ class CredentialRepositoryImpl extends CredentialRepository { Future> getClaims( {List? filters, required String genesisDid, - required String privateKey}) { - return _storageClaimDataSource - .getClaims( - filter: filters == null ? null : _filtersMapper.mapTo(filters), - did: genesisDid, - privateKey: privateKey) - .then((claims) => - claims.map((claim) => _claimMapper.mapFrom(claim)).toList()) - .catchError((error) => throw GetClaimsException(error)); + required String privateKey}) async { + try { + final List claimDTOlist = + await _storageClaimDataSource.getClaims( + filter: filters == null ? null : _filtersMapper.mapTo(filters), + did: genesisDid, + privateKey: privateKey, + ); + + final List claimEntityList = + claimDTOlist.map((claim) => _claimMapper.mapFrom(claim)).toList(); + return claimEntityList; + } catch (error) { + throw GetClaimsException(error); + } } @override Future getClaim( {required String claimId, required String genesisDid, - required String privateKey}) { - return _storageClaimDataSource - .getClaims( - filter: _idFilterMapper.mapTo(claimId), - did: genesisDid, - privateKey: privateKey) - .then((claims) => claims.isEmpty - ? throw ClaimNotFoundException(claimId) - : _claimMapper.mapFrom(claims.first)); + required String privateKey}) async { + try { + ClaimDTO claimDTO = await _storageClaimDataSource.getClaim( + credentialId: claimId, did: genesisDid, privateKey: privateKey); + + ClaimEntity claimEntity = _claimMapper.mapFrom(claimDTO); + return claimEntity; + } catch (e) { + rethrow; + } + } + + @override + Future getCredentialByPartialId({ + required String partialId, + required String genesisDid, + required String privateKey, + }) async { + try { + List claimDTOlist = + await _storageClaimDataSource.getCredentialByPartialId( + partialId: partialId, + did: genesisDid, + privateKey: privateKey, + ); + + if (claimDTOlist.isEmpty || claimDTOlist.length > 1) { + throw ClaimNotFoundException(partialId); + } + + ClaimEntity claimEntity = _claimMapper.mapFrom(claimDTOlist.first); + return claimEntity; + } catch (e) { + rethrow; + } } @override @@ -169,4 +205,15 @@ class CredentialRepositoryImpl extends CredentialRepository { Future> getAuthClaim({required List publicKey}) { return _localClaimDataSource.getAuthClaim(publicKey: publicKey); } + + @override + Future cacheCredential({ + required String credential, + String? config, + }) { + return _cacheCredentialDataSource.cacheCredential( + credential: credential, + config: config, + ); + } } diff --git a/lib/credential/data/data_sources/cache_claim_data_source.dart b/lib/credential/data/data_sources/cache_claim_data_source.dart new file mode 100644 index 00000000..a76eaf0e --- /dev/null +++ b/lib/credential/data/data_sources/cache_claim_data_source.dart @@ -0,0 +1,20 @@ +import 'dart:convert'; + +import '../../../constants.dart'; +import 'lib_pidcore_credential_data_source.dart'; + +class CacheCredentialDataSource { + LibPolygonIdCoreCredentialDataSource _libPolygonIdCoreCredentialDataSource; + + CacheCredentialDataSource(this._libPolygonIdCoreCredentialDataSource); + + Future cacheCredential({ + required String credential, + String? config, + }) async { + return _libPolygonIdCoreCredentialDataSource.cacheCredentials( + credential, + config, + ); + } +} diff --git a/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart b/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart index 59ce8161..34f075bd 100644 --- a/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart +++ b/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart @@ -30,4 +30,8 @@ class LibPolygonIdCoreCredentialDataSource { logger().d("issueAuthClaim: $output"); return output; } + + String? cacheCredentials(String input, String? config) { + return _polygonIdCoreCredential.cacheCredentials(input, config); + } } diff --git a/lib/credential/data/data_sources/storage_claim_data_source.dart b/lib/credential/data/data_sources/storage_claim_data_source.dart index 78ffdedd..a0683636 100644 --- a/lib/credential/data/data_sources/storage_claim_data_source.dart +++ b/lib/credential/data/data_sources/storage_claim_data_source.dart @@ -1,6 +1,7 @@ import 'package:injectable/injectable.dart'; import 'package:polygonid_flutter_sdk/common/data/data_sources/secure_identity_storage_data_source.dart'; import 'package:polygonid_flutter_sdk/constants.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/exceptions/credential_exceptions.dart'; import 'package:polygonid_flutter_sdk/sdk/di/injector.dart'; import 'package:sembast/sembast.dart'; @@ -108,14 +109,62 @@ class StorageClaimDataSource extends SecureIdentityStorageDataSource { await _storeRefWrapper.removeAll(transaction); } - Future> getClaims( - {Filter? filter, required String did, required String privateKey}) { + Future> getClaims({ + Filter? filter, + required String did, + required String privateKey, + }) async { + Database database = await getDatabase(did: did, privateKey: privateKey); + + List>> snapshots = + await _storeRefWrapper.find(database, finder: Finder(filter: filter)); + + List claims = snapshots.map((snapshot) { + ClaimDTO claimDTO = ClaimDTO.fromJson(snapshot.value); + return claimDTO; + }).toList(); + + database.close(); + return claims; + } + + Future> getCredentialByPartialId({ + required String did, + required String privateKey, + required String partialId, + }) { return getDatabase(did: did, privateKey: privateKey).then((database) => _storeRefWrapper - .find(database, finder: Finder(filter: filter)) - .then((snapshots) => snapshots - .map((snapshot) => ClaimDTO.fromJson(snapshot.value)) - .toList()) - .whenComplete(() => database.close())); + .find(database, + finder: Finder( + filter: Filter.custom((record) => + (record.value as Map)['id'] + ?.toString() + .contains(partialId) ?? + false))) + .then((snapshots) { + return snapshots.map((snapshot) { + return ClaimDTO.fromJson(snapshot.value); + }).toList(); + }).whenComplete(() => database.close())); + } + + /// Get a [ClaimDTO] filtered by id associated to the identity previously stored + Future getClaim({ + required String credentialId, + required String did, + required String privateKey, + }) async { + Database db = await getDatabase(did: did, privateKey: privateKey); + + Map? credential = + await _storeRefWrapper.get(db, credentialId); + if (credential == null) { + throw ClaimNotFoundException(credentialId); + } + + ClaimDTO claimDTO = ClaimDTO.fromJson(credential); + db.close(); + return claimDTO; } } diff --git a/lib/credential/data/dtos/claim_dto.dart b/lib/credential/data/dtos/claim_dto.dart index c0f09b14..11bd0442 100644 --- a/lib/credential/data/dtos/claim_dto.dart +++ b/lib/credential/data/dtos/claim_dto.dart @@ -1,37 +1,82 @@ +import 'dart:convert'; + import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; import 'claim_info_dto.dart'; -part 'claim_dto.g.dart'; - -@JsonSerializable(explicitToJson: true) class ClaimDTO extends Equatable { final String id; final String issuer; final String did; final String state; - @JsonKey(name: "credential") final ClaimInfoDTO info; final String? expiration; final String type; Map? schema; + Map? displayType; + final String credentialRawValue; - ClaimDTO( - {required this.id, - required this.issuer, - required this.did, - required this.type, - this.state = '', - this.expiration, - required this.info, - this.schema}); + ClaimDTO({ + required this.id, + required this.issuer, + required this.did, + required this.type, + this.state = '', + this.expiration, + required this.info, + this.schema, + this.displayType, + required this.credentialRawValue, + }); - factory ClaimDTO.fromJson(Map json) => - _$ClaimDTOFromJson(json); + factory ClaimDTO.fromJson(Map json) { + return ClaimDTO( + id: json['id'] as String, + issuer: json['issuer'] as String, + did: json['did'] as String, + type: json['type'] as String, + state: json['state'] as String? ?? '', + expiration: json['expiration'] as String?, + info: ClaimInfoDTO.fromJson(json['credential'] as Map), + schema: json['schema'] as Map?, + displayType: json['displayType'] as Map?, + credentialRawValue: json['credentialRawValue'] ?? jsonEncode(json), + ); + } - Map toJson() => _$ClaimDTOToJson(this); + Map toJson() { + return { + 'id': id, + 'issuer': issuer, + 'did': did, + 'state': state, + 'credential': info.toJson(), + 'expiration': expiration, + 'type': type, + 'schema': schema, + 'displayType': displayType, + 'credentialRawValue': credentialRawValue, + }; + } + + @override + List get props => [ + id, + issuer, + did, + state, + info, + expiration, + type, + schema, + displayType, + credentialRawValue + ]; @override - List get props => [issuer, did, state, info]; + String toString() { + return 'ClaimDTO{id: $id, issuer: $issuer, did: $did, state: $state, info: $info, expiration: $expiration, type: $type, schema: $schema, displayType: $displayType, credentialRawValue: $credentialRawValue}'; + } } diff --git a/lib/credential/data/dtos/claim_dto.g.dart b/lib/credential/data/dtos/claim_dto.g.dart deleted file mode 100644 index f4ae44c0..00000000 --- a/lib/credential/data/dtos/claim_dto.g.dart +++ /dev/null @@ -1,29 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'claim_dto.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -ClaimDTO _$ClaimDTOFromJson(Map json) => ClaimDTO( - id: json['id'] as String, - issuer: json['issuer'] as String, - did: json['did'] as String, - type: json['type'] as String, - state: json['state'] as String? ?? '', - expiration: json['expiration'] as String?, - info: ClaimInfoDTO.fromJson(json['credential'] as Map), - schema: json['schema'] as Map?, - ); - -Map _$ClaimDTOToJson(ClaimDTO instance) => { - 'id': instance.id, - 'issuer': instance.issuer, - 'did': instance.did, - 'state': instance.state, - 'credential': instance.info.toJson(), - 'expiration': instance.expiration, - 'type': instance.type, - 'schema': instance.schema, - }; diff --git a/lib/credential/data/dtos/claim_info_dto.dart b/lib/credential/data/dtos/claim_info_dto.dart index 0bbb294f..3c5b95db 100644 --- a/lib/credential/data/dtos/claim_info_dto.dart +++ b/lib/credential/data/dtos/claim_info_dto.dart @@ -21,6 +21,8 @@ class ClaimInfoDTO extends Equatable { final CredentialSchemaDTO credentialSchema; @JsonKey(name: 'proof') final List proofs; + final RefreshServiceDTO? refreshService; + final DisplayMethodDTO? displayMethod; const ClaimInfoDTO( this.id, @@ -33,6 +35,8 @@ class ClaimInfoDTO extends Equatable { this.issuer, this.credentialSchema, this.proofs, + this.refreshService, + this.displayMethod, ); factory ClaimInfoDTO.fromJson(Map json) => @@ -53,9 +57,42 @@ class ClaimInfoDTO extends Equatable { issuer, credentialSchema, proofs, + refreshService, ]; } +/// If credential is refreshable, this is the data needed to refresh it +class RefreshServiceDTO { + final String id; + final String type; + + const RefreshServiceDTO(this.id, this.type); + + factory RefreshServiceDTO.fromJson(Map json) { + String id = json['id'] as String; + String type = json['type'] as String; + + return RefreshServiceDTO(id, type); + } + + Map toJson() { + Map result = { + 'id': id, + 'type': type, + }; + + return result; + } + + @override + List get props => [id, type]; + + @override + String toString() { + return 'RefreshServiceDTO{id: $id, type: $type}'; + } +} + class CredentialSubjectDTO extends Equatable { final String id; final String type; @@ -98,7 +135,9 @@ enum CredentialStatusType { @JsonValue("SparseMerkleTreeProof") sparseMerkleTreeProof, @JsonValue("Iden3OnchainSparseMerkleTreeProof2023") - iden3OnchainSparseMerkleTreeProof2023 + iden3OnchainSparseMerkleTreeProof2023, + @JsonValue("Iden3commRevocationStatusV1.0") + iden3commRevocationStatusV1 } @JsonSerializable(explicitToJson: true) @@ -137,3 +176,20 @@ class CredentialSchemaDTO extends Equatable { @override List get props => [id, type]; } + +@JsonSerializable() +class DisplayMethodDTO { + /// Contains url. + final String id; + final String type; + + DisplayMethodDTO(this.id, this.type); + + factory DisplayMethodDTO.fromJson(Map json) => + _$DisplayMethodDTOFromJson(json); + + Map toJson() => _$DisplayMethodDTOToJson(this); + + @override + List get props => [id, type]; +} diff --git a/lib/credential/data/dtos/claim_info_dto.g.dart b/lib/credential/data/dtos/claim_info_dto.g.dart index 518597fd..5ced8e08 100644 --- a/lib/credential/data/dtos/claim_info_dto.g.dart +++ b/lib/credential/data/dtos/claim_info_dto.g.dart @@ -22,6 +22,14 @@ ClaimInfoDTO _$ClaimInfoDTOFromJson(Map json) => ClaimInfoDTO( (json['proof'] as List) .map((e) => ClaimProofDTO.fromJson(e as Map)) .toList(), + json['refreshService'] == null + ? null + : RefreshServiceDTO.fromJson( + json['refreshService'] as Map), + json['displayMethod'] == null + ? null + : DisplayMethodDTO.fromJson( + json['displayMethod'] as Map), ); Map _$ClaimInfoDTOToJson(ClaimInfoDTO instance) => @@ -36,6 +44,8 @@ Map _$ClaimInfoDTOToJson(ClaimInfoDTO instance) => 'issuer': instance.issuer, 'credentialSchema': instance.credentialSchema.toJson(), 'proof': instance.proofs.map((e) => e.toJson()).toList(), + 'refreshService': instance.refreshService?.toJson(), + 'displayMethod': instance.displayMethod?.toJson(), }; CredentialStatusDTO _$CredentialStatusDTOFromJson(Map json) => @@ -64,6 +74,8 @@ const _$CredentialStatusTypeEnumMap = { CredentialStatusType.sparseMerkleTreeProof: 'SparseMerkleTreeProof', CredentialStatusType.iden3OnchainSparseMerkleTreeProof2023: 'Iden3OnchainSparseMerkleTreeProof2023', + CredentialStatusType.iden3commRevocationStatusV1: + 'Iden3commRevocationStatusV1.0', }; CredentialSchemaDTO _$CredentialSchemaDTOFromJson(Map json) => @@ -78,3 +90,15 @@ Map _$CredentialSchemaDTOToJson( 'id': instance.id, 'type': instance.type, }; + +DisplayMethodDTO _$DisplayMethodDTOFromJson(Map json) => + DisplayMethodDTO( + json['id'] as String, + json['type'] as String, + ); + +Map _$DisplayMethodDTOToJson(DisplayMethodDTO instance) => + { + 'id': instance.id, + 'type': instance.type, + }; diff --git a/lib/credential/data/dtos/claim_proofs/claim_proof_dto.dart b/lib/credential/data/dtos/claim_proofs/claim_proof_dto.dart index 54cf4938..92842ec4 100644 --- a/lib/credential/data/dtos/claim_proofs/claim_proof_dto.dart +++ b/lib/credential/data/dtos/claim_proofs/claim_proof_dto.dart @@ -76,7 +76,9 @@ enum ClaimProofIssuerCredStatusType { @JsonValue("SparseMerkleTreeProof") sparseMerkleTreeProof, @JsonValue("Iden3OnchainSparseMerkleTreeProof2023") - iden3OnchainSparseMerkleTreeProof2023 + iden3OnchainSparseMerkleTreeProof2023, + @JsonValue("Iden3commRevocationStatusV1.0") + iden3commRevocationStatusV1 } @JsonSerializable(explicitToJson: true) diff --git a/lib/credential/data/dtos/claim_proofs/claim_proof_dto.g.dart b/lib/credential/data/dtos/claim_proofs/claim_proof_dto.g.dart index dbd1141d..4fb5c2de 100644 --- a/lib/credential/data/dtos/claim_proofs/claim_proof_dto.g.dart +++ b/lib/credential/data/dtos/claim_proofs/claim_proof_dto.g.dart @@ -55,6 +55,8 @@ const _$ClaimProofIssuerCredStatusTypeEnumMap = { ClaimProofIssuerCredStatusType.sparseMerkleTreeProof: 'SparseMerkleTreeProof', ClaimProofIssuerCredStatusType.iden3OnchainSparseMerkleTreeProof2023: 'Iden3OnchainSparseMerkleTreeProof2023', + ClaimProofIssuerCredStatusType.iden3commRevocationStatusV1: + 'Iden3commRevocationStatusV1.0', }; ClaimProofIssuerStateDTO _$ClaimProofIssuerStateDTOFromJson( diff --git a/lib/credential/data/dtos/display_type/basic_display_type.dart b/lib/credential/data/dtos/display_type/basic_display_type.dart new file mode 100644 index 00000000..491cd4ff --- /dev/null +++ b/lib/credential/data/dtos/display_type/basic_display_type.dart @@ -0,0 +1,78 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; + +part 'basic_display_type.g.dart'; + +@JsonSerializable() +class Iden3BasicDisplayType extends DisplayType { + static const name = "Iden3BasicDisplayMethodV1"; + + final String? title; + final String? description; + final String? issuerName; + final String? titleTextColor; + final String? descriptionTextColor; + final String? issuerTextColor; + final String? backgroundImageUrl; + final String? backgroundColor; + @JsonKey(toJson: _logoToJson, fromJson: _logoFromJson) + final Iden3BasicDisplayTypeLogo? logo; + + Iden3BasicDisplayType( + this.title, + this.description, + this.issuerName, + this.titleTextColor, + this.descriptionTextColor, + this.issuerTextColor, + this.backgroundImageUrl, + this.backgroundColor, + this.logo, + ); + + factory Iden3BasicDisplayType.fromJson(Map json) => + _$Iden3BasicDisplayTypeFromJson(json); + + @override + Map toJson() => _$Iden3BasicDisplayTypeToJson(this); + + @override + String get typeName => name; + + @override + List get props => [ + title, + description, + issuerName, + titleTextColor, + descriptionTextColor, + issuerTextColor, + backgroundImageUrl, + backgroundColor, + logo, + ]; +} + +@JsonSerializable() +class Iden3BasicDisplayTypeLogo { + final String? uri; + final String? alt; + + Iden3BasicDisplayTypeLogo(this.uri, this.alt); + + factory Iden3BasicDisplayTypeLogo.fromJson(Map json) => + _$Iden3BasicDisplayTypeLogoFromJson(json); + + Map toJson() => _$Iden3BasicDisplayTypeLogoToJson(this); + + @override + List get props => [uri, alt]; +} + +Map? _logoToJson(Iden3BasicDisplayTypeLogo? logo) { + return logo?.toJson(); +} + +Iden3BasicDisplayTypeLogo? _logoFromJson(Map? json) { + return json == null ? null : Iden3BasicDisplayTypeLogo.fromJson(json); +} diff --git a/lib/credential/data/dtos/display_type/basic_display_type.g.dart b/lib/credential/data/dtos/display_type/basic_display_type.g.dart new file mode 100644 index 00000000..1cb21deb --- /dev/null +++ b/lib/credential/data/dtos/display_type/basic_display_type.g.dart @@ -0,0 +1,49 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'basic_display_type.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Iden3BasicDisplayType _$Iden3BasicDisplayTypeFromJson( + Map json) => + Iden3BasicDisplayType( + json['title'] as String?, + json['description'] as String?, + json['issuerName'] as String?, + json['titleTextColor'] as String?, + json['descriptionTextColor'] as String?, + json['issuerTextColor'] as String?, + json['backgroundImageUrl'] as String?, + json['backgroundColor'] as String?, + _logoFromJson(json['logo'] as Map?), + ); + +Map _$Iden3BasicDisplayTypeToJson( + Iden3BasicDisplayType instance) => + { + 'title': instance.title, + 'description': instance.description, + 'issuerName': instance.issuerName, + 'titleTextColor': instance.titleTextColor, + 'descriptionTextColor': instance.descriptionTextColor, + 'issuerTextColor': instance.issuerTextColor, + 'backgroundImageUrl': instance.backgroundImageUrl, + 'backgroundColor': instance.backgroundColor, + 'logo': _logoToJson(instance.logo), + }; + +Iden3BasicDisplayTypeLogo _$Iden3BasicDisplayTypeLogoFromJson( + Map json) => + Iden3BasicDisplayTypeLogo( + json['uri'] as String?, + json['alt'] as String?, + ); + +Map _$Iden3BasicDisplayTypeLogoToJson( + Iden3BasicDisplayTypeLogo instance) => + { + 'uri': instance.uri, + 'alt': instance.alt, + }; diff --git a/lib/credential/data/dtos/display_type/display_type.dart b/lib/credential/data/dtos/display_type/display_type.dart new file mode 100644 index 00000000..7a7ff623 --- /dev/null +++ b/lib/credential/data/dtos/display_type/display_type.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/basic_display_type.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/unknown_display_type.dart'; + +abstract class DisplayType { + const DisplayType(); + + String get typeName; + + factory DisplayType.fromJson(Map json) { + switch (json['type']) { + case Iden3BasicDisplayType.name: + return Iden3BasicDisplayType.fromJson(json); + default: + return UnknownDisplayType.fromJson(json); + } + } + + Map toJson(); +} diff --git a/lib/credential/data/dtos/display_type/unknown_display_type.dart b/lib/credential/data/dtos/display_type/unknown_display_type.dart new file mode 100644 index 00000000..8945e06c --- /dev/null +++ b/lib/credential/data/dtos/display_type/unknown_display_type.dart @@ -0,0 +1,17 @@ +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; + +class UnknownDisplayType extends DisplayType { + final Map displayType; + + @override + String get typeName => "UnknownDisplayType"; + + UnknownDisplayType(this.displayType); + + factory UnknownDisplayType.fromJson(Map json) { + return UnknownDisplayType(json); + } + + @override + Map toJson() => displayType; +} diff --git a/lib/credential/data/mappers/claim_mapper.dart b/lib/credential/data/mappers/claim_mapper.dart index 93fe6cbc..44b88dab 100644 --- a/lib/credential/data/mappers/claim_mapper.dart +++ b/lib/credential/data/mappers/claim_mapper.dart @@ -1,4 +1,5 @@ import 'package:polygonid_flutter_sdk/common/mappers/mapper.dart'; +import 'package:polygonid_flutter_sdk/credential/data/mappers/display_type_mapper.dart'; import '../../domain/entities/claim_entity.dart'; import '../dtos/claim_dto.dart'; @@ -8,32 +9,48 @@ import 'claim_state_mapper.dart'; class ClaimMapper extends Mapper { final ClaimStateMapper _claimStateMapper; final ClaimInfoMapper _claimInfoMapper; + final DisplayTypeMapper _displayTypeMapper; - ClaimMapper(this._claimStateMapper, this._claimInfoMapper); + ClaimMapper( + this._claimStateMapper, + this._claimInfoMapper, + this._displayTypeMapper, + ); @override ClaimEntity mapFrom(ClaimDTO from) { + final displayType = from.displayType; return ClaimEntity( - id: from.id, - issuer: from.issuer, - did: from.did, - state: _claimStateMapper.mapFrom(from.state), - expiration: from.expiration, - schema: from.schema, - type: from.type, - info: _claimInfoMapper.mapFrom(from.info)); + id: from.id, + issuer: from.issuer, + did: from.did, + state: _claimStateMapper.mapFrom(from.state), + expiration: from.expiration, + schema: from.schema, + type: from.type, + info: _claimInfoMapper.mapFrom(from.info), + displayType: from.displayType == null + ? _displayTypeMapper.mapFrom(displayType) + : null, + credentialRawValue: from.credentialRawValue, + ); } @override ClaimDTO mapTo(ClaimEntity to) { + final displayType = to.displayType; return ClaimDTO( - id: to.id, - issuer: to.issuer, - did: to.did, - state: _claimStateMapper.mapTo(to.state), - type: to.type, - expiration: to.expiration, - schema: to.schema, - info: _claimInfoMapper.mapTo(to.info)); + id: to.id, + issuer: to.issuer, + did: to.did, + state: _claimStateMapper.mapTo(to.state), + type: to.type, + expiration: to.expiration, + schema: to.schema, + info: _claimInfoMapper.mapTo(to.info), + displayType: + to.displayType == null ? null : _displayTypeMapper.mapTo(displayType), + credentialRawValue: to.credentialRawValue, + ); } } diff --git a/lib/credential/data/mappers/display_type_mapper.dart b/lib/credential/data/mappers/display_type_mapper.dart new file mode 100644 index 00000000..b4272c0f --- /dev/null +++ b/lib/credential/data/mappers/display_type_mapper.dart @@ -0,0 +1,27 @@ +import 'package:polygonid_flutter_sdk/common/mappers/mapper.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/basic_display_type.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; + +class DisplayTypeMapper extends Mapper?, DisplayType?> { + @override + DisplayType? mapFrom(Map? from) { + return from == null ? null : DisplayType.fromJson(from); + } + + @override + Map? mapTo(DisplayType? to) { + if (to == null) { + return null; + } + final json = to.toJson(); + json['type'] = to.typeName; + return json; + } +} + +class DisplayTypeMapperParam { + final String type; + final Map json; + + DisplayTypeMapperParam(this.type, this.json); +} diff --git a/lib/credential/domain/entities/claim_entity.dart b/lib/credential/domain/entities/claim_entity.dart index 77bfb741..0556d419 100644 --- a/lib/credential/domain/entities/claim_entity.dart +++ b/lib/credential/domain/entities/claim_entity.dart @@ -1,3 +1,5 @@ +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; + enum ClaimState { active, expired, pending, revoked } class ClaimEntity { @@ -9,16 +11,22 @@ class ClaimEntity { final Map? schema; final String type; final Map info; + final DisplayType? displayType; + + final String credentialRawValue; - ClaimEntity( - {required this.id, - required this.issuer, - required this.did, - required this.state, - this.expiration, - this.schema, - required this.type, - required this.info}); + ClaimEntity({ + required this.id, + required this.issuer, + required this.did, + required this.state, + this.expiration, + this.schema, + required this.type, + required this.info, + this.displayType, + required this.credentialRawValue, + }); factory ClaimEntity.fromJson(Map json) { return ClaimEntity( @@ -30,6 +38,8 @@ class ClaimEntity { schema: json['schema'], type: json['type'], info: json['info'], + displayType: json['displayType'], + credentialRawValue: json['credentialRawValue'], ); } @@ -43,12 +53,15 @@ class ClaimEntity { 'schema': schema, 'type': type, 'info': info, + 'displayType': displayType?.toJson(), + 'credentialRawValue': credentialRawValue, }; @override String toString() => "[ClaimEntity] {id: $id, " "issuer: $issuer, did: $did, state: $state, " - "expiration: $expiration, schema: $schema, type: $type, info: $info}"; + "expiration: $expiration, schema: $schema, type: $type, info: $info, " + "displayType: $displayType}"; @override bool operator ==(Object other) => @@ -62,7 +75,8 @@ class ClaimEntity { expiration == other.expiration && schema == other.schema && type == other.type && - info.toString() == other.info.toString(); + info.toString() == other.info.toString() && + displayType == other.displayType; @override int get hashCode => runtimeType.hashCode; diff --git a/lib/credential/domain/exceptions/credential_exceptions.dart b/lib/credential/domain/exceptions/credential_exceptions.dart index ec4beee7..65bd0103 100644 --- a/lib/credential/domain/exceptions/credential_exceptions.dart +++ b/lib/credential/domain/exceptions/credential_exceptions.dart @@ -35,3 +35,9 @@ class NullRevocationStatusException implements Exception { NullRevocationStatusException(this.claim); } + +class RefreshCredentialException extends ErrorException { + final String errorMessage; + + RefreshCredentialException(this.errorMessage, [dynamic error]) : super(error); +} diff --git a/lib/credential/domain/repositories/credential_repository.dart b/lib/credential/domain/repositories/credential_repository.dart index 9895a93b..2351b239 100644 --- a/lib/credential/domain/repositories/credential_repository.dart +++ b/lib/credential/domain/repositories/credential_repository.dart @@ -21,6 +21,12 @@ abstract class CredentialRepository { required String genesisDid, required String privateKey}); + Future getCredentialByPartialId({ + required String partialId, + required String genesisDid, + required String privateKey, + }); + Future removeClaims( {required List claimIds, required String genesisDid, @@ -45,4 +51,9 @@ abstract class CredentialRepository { {required ClaimEntity claim, required bool rhs}); Future> getAuthClaim({required List publicKey}); + + Future cacheCredential({ + required String credential, + String? config, + }); } diff --git a/lib/credential/domain/use_cases/cache_credential_use_case.dart b/lib/credential/domain/use_cases/cache_credential_use_case.dart new file mode 100644 index 00000000..d89585fc --- /dev/null +++ b/lib/credential/domain/use_cases/cache_credential_use_case.dart @@ -0,0 +1,33 @@ +import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; +import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/did_profile_info_repository.dart'; + +class CacheCredentialParam { + final String credential; + final String? config; + + CacheCredentialParam({ + required this.credential, + this.config, + }); +} + +class CacheCredentialUseCase + extends FutureUseCase { + final CredentialRepository _credentialRepository; + + CacheCredentialUseCase( + this._credentialRepository, + ); + + @override + Future execute({ + required CacheCredentialParam param, + }) { + return _credentialRepository.cacheCredential( + credential: param.credential, + config: param.config, + ); + } +} diff --git a/lib/credential/domain/use_cases/get_auth_claim_use_case.dart b/lib/credential/domain/use_cases/get_auth_claim_use_case.dart index 0cbd794b..774d64aa 100644 --- a/lib/credential/domain/use_cases/get_auth_claim_use_case.dart +++ b/lib/credential/domain/use_cases/get_auth_claim_use_case.dart @@ -19,8 +19,6 @@ class GetAuthClaimUseCase extends FutureUseCase, List> { .getAuthClaim(publicKey: param) .then((authClaim) { logger().i("[GetAuthClaimUseCase] auth claim: $authClaim"); - _stacktraceManager - .addTrace("[GetAuthClaimUseCase] auth claim: $authClaim"); return authClaim; }).catchError((error) { logger().e("[GetAuthClaimUseCase] Error: $error"); diff --git a/lib/credential/domain/use_cases/get_claims_use_case.dart b/lib/credential/domain/use_cases/get_claims_use_case.dart index 42431332..5f231beb 100644 --- a/lib/credential/domain/use_cases/get_claims_use_case.dart +++ b/lib/credential/domain/use_cases/get_claims_use_case.dart @@ -40,10 +40,6 @@ class GetClaimsUseCase // if profileNonce is zero, return all profiles credentials, // if profileNonce > 0 then return only credentials from that profile if (param.profileNonce >= GENESIS_PROFILE_NONCE) { - // TODO check param.did and did from profile nonce are the same or return exception - /*String did = await _getCurrentEnvDidIdentifierUseCase.execute( - param: GetCurrentEnvDidIdentifierParam( - privateKey: param.privateKey, profileNonce: param.profileNonce));*/ return _credentialRepository .getClaims( filters: param.filters, diff --git a/lib/credential/domain/use_cases/get_credential_by_id_use_case.dart b/lib/credential/domain/use_cases/get_credential_by_id_use_case.dart new file mode 100644 index 00000000..8e06d7cf --- /dev/null +++ b/lib/credential/domain/use_cases/get_credential_by_id_use_case.dart @@ -0,0 +1,30 @@ +import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart'; + +class GetCredentialByIdUseCase + extends FutureUseCase { + final CredentialRepository _credentialRepository; + + GetCredentialByIdUseCase(this._credentialRepository); + + Future execute({required GetCredentialByIdParam param}) async { + return await _credentialRepository.getClaim( + privateKey: param.privateKey, + genesisDid: param.genesisDid, + claimId: param.id, + ); + } +} + +class GetCredentialByIdParam { + final String id; + final String privateKey; + final String genesisDid; + + GetCredentialByIdParam({ + required this.id, + required this.privateKey, + required this.genesisDid, + }); +} diff --git a/lib/credential/domain/use_cases/get_credential_by_partial_id_use_case.dart b/lib/credential/domain/use_cases/get_credential_by_partial_id_use_case.dart new file mode 100644 index 00000000..9b44345b --- /dev/null +++ b/lib/credential/domain/use_cases/get_credential_by_partial_id_use_case.dart @@ -0,0 +1,37 @@ +import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; +import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart'; + +class GetCredentialByPartialIdParam { + final String partialId; + final String genesisDid; + final String privateKey; + + GetCredentialByPartialIdParam({ + required this.partialId, + required this.genesisDid, + required this.privateKey, + }); +} + +class GetCredentialByPartialIdUseCase + extends FutureUseCase { + final CredentialRepository _credentialRepository; + final StacktraceManager _stacktraceManager; + + GetCredentialByPartialIdUseCase( + this._credentialRepository, + this._stacktraceManager, + ); + + @override + Future execute( + {required GetCredentialByPartialIdParam param}) async { + return _credentialRepository.getCredentialByPartialId( + partialId: param.partialId, + genesisDid: param.genesisDid, + privateKey: param.privateKey, + ); + } +} diff --git a/lib/credential/domain/use_cases/refresh_credential_use_case.dart b/lib/credential/domain/use_cases/refresh_credential_use_case.dart new file mode 100644 index 00000000..1d5e8352 --- /dev/null +++ b/lib/credential/domain/use_cases/refresh_credential_use_case.dart @@ -0,0 +1,120 @@ +import 'dart:convert'; + +import 'package:polygonid_flutter_sdk/common/domain/domain_constants.dart'; +import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; +import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_info_dto.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/exceptions/credential_exceptions.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_token_use_case.dart'; +import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/get_identity_use_case.dart'; +import 'package:uuid/uuid.dart'; + +class RefreshCredentialUseCase + extends FutureUseCase { + final CredentialRepository _credentialRepository; + final StacktraceManager _stacktraceManager; + final GetIdentityUseCase _getIdentityUseCase; + final GetAuthTokenUseCase _getAuthTokenUseCase; + final Iden3commCredentialRepository _iden3commCredentialRepository; + final RemoveClaimsUseCase _removeClaimsUseCase; + final SaveClaimsUseCase _saveClaimsUseCase; + + RefreshCredentialUseCase( + this._credentialRepository, + this._stacktraceManager, + this._getIdentityUseCase, + this._getAuthTokenUseCase, + this._iden3commCredentialRepository, + this._removeClaimsUseCase, + this._saveClaimsUseCase, + ); + + @override + Future execute({required RefreshCredentialParam param}) async { + var identityEntity = await _getIdentityUseCase.execute( + param: GetIdentityParam( + genesisDid: param.genesisDid, privateKey: param.privateKey)); + + BigInt claimSubjectProfileNonce = identityEntity.profiles.keys.firstWhere( + (k) => identityEntity.profiles[k] == param.credential.did, + orElse: () => GENESIS_PROFILE_NONCE); + + if (!param.credential.info.containsKey("refreshService") || + param.credential.info["refreshService"] == null) { + throw RefreshCredentialException("Refresh service not found"); + } + + RefreshServiceDTO refreshService = + RefreshServiceDTO.fromJson(param.credential.info["refreshService"]); + String refreshServiceUrl = refreshService.id; + String id = const Uuid().v4(); + CredentialRefreshIden3MessageEntity credentialRefreshEntity = + CredentialRefreshIden3MessageEntity( + id: id, + typ: "application/iden3comm-plain-json", + type: "https://iden3-communication.io/credentials/1.0/refresh", + thid: id, + body: CredentialRefreshBodyRequest( + param.credential.id.replaceAll("urn:uuid:", ""), + "expired", + ), + from: param.credential.did, + to: param.credential.issuer, + ); + + String authToken = await _getAuthTokenUseCase.execute( + param: GetAuthTokenParam( + genesisDid: param.genesisDid, + profileNonce: claimSubjectProfileNonce, + privateKey: param.privateKey, + message: jsonEncode(credentialRefreshEntity), + ), + ); + + ClaimEntity claimEntity; + + claimEntity = await _iden3commCredentialRepository.refreshCredential( + authToken: authToken, + url: refreshServiceUrl, + profileDid: param.credential.did, + ); + + if (claimEntity.id == param.credential.id) { + await _removeClaimsUseCase.execute( + param: RemoveClaimsParam( + claimIds: [param.credential.id], + genesisDid: param.genesisDid, + privateKey: param.privateKey, + ), + ); + } + + await _saveClaimsUseCase.execute( + param: SaveClaimsParam( + claims: [claimEntity], + genesisDid: param.genesisDid, + privateKey: param.privateKey, + ), + ); + + return claimEntity; + } +} + +class RefreshCredentialParam { + final ClaimEntity credential; + final String genesisDid; + final String privateKey; + + RefreshCredentialParam({ + required this.credential, + required this.genesisDid, + required this.privateKey, + }); +} diff --git a/lib/credential/domain/use_cases/update_claim_use_case.dart b/lib/credential/domain/use_cases/update_claim_use_case.dart index 1440723a..fe65ba5c 100644 --- a/lib/credential/domain/use_cases/update_claim_use_case.dart +++ b/lib/credential/domain/use_cases/update_claim_use_case.dart @@ -47,13 +47,15 @@ class UpdateClaimUseCase extends FutureUseCase { genesisDid: param.genesisDid, privateKey: param.privateKey) .then((claim) => ClaimEntity( - id: param.id, - issuer: param.issuer ?? claim.issuer, - did: param.genesisDid, - state: param.state ?? claim.state, - expiration: param.expiration ?? claim.expiration, - type: param.type ?? claim.type, - info: param.data ?? claim.info)) + id: param.id, + issuer: param.issuer ?? claim.issuer, + did: claim.did, + state: param.state ?? claim.state, + expiration: param.expiration ?? claim.expiration, + type: param.type ?? claim.type, + info: param.data ?? claim.info, + credentialRawValue: claim.credentialRawValue, + )) .then((updated) => _credentialRepository.saveClaims( claims: [updated], genesisDid: param.genesisDid, diff --git a/lib/credential/libs/polygonidcore/pidcore_credential.dart b/lib/credential/libs/polygonidcore/pidcore_credential.dart index eb50b831..338eddd2 100644 --- a/lib/credential/libs/polygonidcore/pidcore_credential.dart +++ b/lib/credential/libs/polygonidcore/pidcore_credential.dart @@ -29,4 +29,23 @@ class PolygonIdCoreCredential extends PolygonIdCore { return result; } + + String? cacheCredentials(String input, String? config) { + ffi.Pointer in1 = input.toNativeUtf8().cast(); + ffi.Pointer cfg = ffi.nullptr; + if (config != null) { + cfg = config.toNativeUtf8().cast(); + } + ffi.Pointer> status = + malloc>(); + int res = PolygonIdCore.nativePolygonIdCoreLib + .PLGNCacheCredentials(in1, cfg, status); + if (res == 0) { + String? consumedStatus = consumeStatus(status, ""); + if (consumedStatus != null) { + return consumedStatus; + } + } + return ""; + } } diff --git a/lib/iden3comm/data/data_sources/remote_iden3comm_data_source.dart b/lib/iden3comm/data/data_sources/remote_iden3comm_data_source.dart index c732e9ea..c77d3965 100644 --- a/lib/iden3comm/data/data_sources/remote_iden3comm_data_source.dart +++ b/lib/iden3comm/data/data_sources/remote_iden3comm_data_source.dart @@ -53,10 +53,65 @@ class RemoteIden3commDataSource { }); } - Future fetchClaim( - {required String authToken, required String url, required String did}) { + Future refreshCredential({ + required String authToken, + required String url, + required, + required String profileDid, + }) async { + Uri? uri = Uri.tryParse(url); + if (uri == null) { + throw NetworkException("Invalid url"); + } + + http.Response response = await client.post( + uri, + body: authToken, + headers: { + HttpHeaders.acceptHeader: '*/*', + HttpHeaders.contentTypeHeader: 'text/plain', + }, + ); + + if (response.statusCode != 200) { + logger().d( + 'refreshCredential Error: code: ${response.statusCode} msg: ${response.body}'); + _stacktraceManager.addError( + 'refreshCredential Error: $url response with\ncode: ${response.statusCode}\nmsg: ${response.body}'); + throw NetworkException(response); + } else { + FetchClaimResponseDTO fetchResponse = + FetchClaimResponseDTO.fromJson(json.decode(response.body)); + + if (fetchResponse.type == FetchClaimResponseType.issuance) { + return ClaimDTO( + id: fetchResponse.credential.id, + issuer: fetchResponse.from, + did: profileDid, + type: fetchResponse.credential.credentialSubject.type, + expiration: fetchResponse.credential.expirationDate, + info: fetchResponse.credential, + credentialRawValue: response.body, + ); + } else { + _stacktraceManager.addTrace( + "[RemoteIden3commDataSource] fetchClaim: UnsupportedFetchClaimTypeException"); + _stacktraceManager.addError( + "[RemoteIden3commDataSource] fetchClaim: UnsupportedFetchClaimTypeException"); + throw UnsupportedFetchClaimTypeException(response); + } + } + } + + Future fetchClaim({ + required String authToken, + required String url, + required String did, + }) { _stacktraceManager.addTrace( "[RemoteIden3commDataSource] fetchClaim: did:$did\nurl: $url\nauthToken: $authToken"); + logger().i( + "[RemoteIden3commDataSource] fetchClaim: did:$did\nurl: $url\nauthToken: $authToken"); return Future.value(Uri.parse(url)) .then((uri) => client.post( uri, @@ -67,20 +122,29 @@ class RemoteIden3commDataSource { }, )) .then((response) { + logger() + .d("fetchClaim: code: ${response.statusCode} msg: ${response.body}"); _stacktraceManager.addTrace( "[RemoteIden3commDataSource] fetchClaim: ${response.statusCode} ${response.body}"); if (response.statusCode == 200) { - FetchClaimResponseDTO fetchResponse = - FetchClaimResponseDTO.fromJson(json.decode(response.body)); + Map jsonResponse = json.decode(response.body); + final fetchResponse = FetchClaimResponseDTO.fromJson(jsonResponse); if (fetchResponse.type == FetchClaimResponseType.issuance) { - return ClaimDTO( - id: fetchResponse.credential.id, - issuer: fetchResponse.from, - did: did, - type: fetchResponse.credential.credentialSubject.type, - expiration: fetchResponse.credential.expirationDate, - info: fetchResponse.credential); + logger().i( + "[RemoteIden3commDataSource] fetchClaim: ${fetchResponse.credential.toJson()}"); + final claimDTO = ClaimDTO( + id: fetchResponse.credential.id, + issuer: fetchResponse.from, + did: did, + type: fetchResponse.credential.credentialSubject.type, + expiration: fetchResponse.credential.expirationDate, + info: fetchResponse.credential, + credentialRawValue: response.body, + ); + logger().i( + "[RemoteIden3commDataSource] fetchClaim: ${claimDTO.info.toJson()}"); + return claimDTO; } else { _stacktraceManager.addTrace( "[RemoteIden3commDataSource] fetchClaim: UnsupportedFetchClaimTypeException"); @@ -110,6 +174,8 @@ class RemoteIden3commDataSource { var schemaUri = Uri.parse(schemaUrl); _stacktraceManager.addTrace( "[RemoteIden3commDataSource] fetchSchema original url: $url"); + logger().i( + "[RemoteIden3commDataSource] fetchSchema original url: $url\nschemaUrl: $schemaUrl"); Dio dio = Dio(); final dir = await getApplicationDocumentsDirectory(); @@ -126,7 +192,9 @@ class RemoteIden3commDataSource { ), ); - var schemaResponse = await dio.get(schemaUri.toString()); + final schemaResponse = await dio.get(schemaUri.toString()); + logger().d( + 'fetchSchema: code: ${schemaResponse.statusCode} msg: ${schemaResponse.data}'); _stacktraceManager.addTrace( "[RemoteIden3commDataSource] fetchSchema: ${schemaResponse.statusCode} ${schemaResponse.data}"); if (schemaResponse.statusCode == 200) { @@ -155,6 +223,63 @@ class RemoteIden3commDataSource { } } + Future> fetchDisplayType({required String url}) async { + try { + String displayTypeUrl = url; + + if (displayTypeUrl.toLowerCase().startsWith("ipfs://")) { + String ipfsHash = displayTypeUrl.replaceFirst("ipfs://", ""); + displayTypeUrl = "https://ipfs.io/ipfs/$ipfsHash"; + } + + final displayTypeUri = Uri.parse(displayTypeUrl); + _stacktraceManager.addTrace( + "[RemoteIden3commDataSource] fetchDisplayType original url: $url"); + + final dio = Dio(); + final dir = await getApplicationDocumentsDirectory(); + final path = dir.path; + dio.interceptors.add( + DioCacheInterceptor( + options: CacheOptions( + store: HiveCacheStore(path), + policy: CachePolicy.refreshForceCache, + hitCacheOnErrorExcept: [], + maxStale: const Duration(days: 14), + priority: CachePriority.high, + ), + ), + ); + + final response = await dio.get(displayTypeUri.toString()); + _stacktraceManager.addTrace( + "[RemoteIden3commDataSource] fetchDisplayType: ${response.statusCode} ${response.data}"); + if (response.statusCode == 200) { + Map data = {}; + bool isMap = response.data is Map; + if (!isMap) { + data = json.decode(response.data); + } else { + data = response.data; + } + + return data; + } else { + _stacktraceManager.addTrace( + "[RemoteIden3commDataSource] fetchDisplayType: ${response.statusCode} ${response.data}"); + _stacktraceManager.addError( + "[RemoteIden3commDataSource] fetchDisplayType: ${response.statusCode} ${response.data}"); + throw NetworkException(response); + } + } catch (error) { + _stacktraceManager + .addTrace("[RemoteIden3commDataSource] fetchDisplayType: $error"); + _stacktraceManager + .addError("[RemoteIden3commDataSource] fetchDisplayType: $error"); + throw FetchDisplayTypeException(error); + } + } + /// Future cleanSchemaCache() async { final dir = await getApplicationDocumentsDirectory(); diff --git a/lib/iden3comm/data/mappers/didProfileInfoInteractedDidFilterMapper.dart b/lib/iden3comm/data/mappers/did_profile_info_interacted_did_filter_mapper.dart similarity index 100% rename from lib/iden3comm/data/mappers/didProfileInfoInteractedDidFilterMapper.dart rename to lib/iden3comm/data/mappers/did_profile_info_interacted_did_filter_mapper.dart diff --git a/lib/iden3comm/data/mappers/proof_request_filters_mapper.dart b/lib/iden3comm/data/mappers/proof_request_filters_mapper.dart index a558acb7..789a848a 100644 --- a/lib/iden3comm/data/mappers/proof_request_filters_mapper.dart +++ b/lib/iden3comm/data/mappers/proof_request_filters_mapper.dart @@ -21,10 +21,10 @@ class ProofRequestFiltersMapper List filters = [ FilterEntity( name: 'credential.credentialSubject.type', value: query.type!), - /*FilterEntity( + FilterEntity( operator: FilterOperator.equalsAnyInList, name: 'credential.@context', - value: query.context!),*/ + value: query.context!), ]; if (query.allowedIssuers != null && query.allowedIssuers is List && @@ -67,6 +67,10 @@ class ProofRequestFiltersMapper filters.addAll( _getFilterByOperator(key, operator, value.toString())); } + } else if (type.contains("positiveInteger")) { + // PositiveInteger is not supported by the filter 'cause this type + // is stored as a string in the database. So we need to filter manually + // this is why we don't add the filter here } else { filters.addAll(_getFilterByOperator(key, operator, value)); } diff --git a/lib/iden3comm/data/repositories/did_profile_info_repository_impl.dart b/lib/iden3comm/data/repositories/did_profile_info_repository_impl.dart index 745ddf9d..7d465f6d 100644 --- a/lib/iden3comm/data/repositories/did_profile_info_repository_impl.dart +++ b/lib/iden3comm/data/repositories/did_profile_info_repository_impl.dart @@ -1,7 +1,7 @@ import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filters_mapper.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/secure_storage_did_profile_info_data_source.dart'; -import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/didProfileInfoInteractedDidFilterMapper.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/did_profile_info_interacted_did_filter_mapper.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/did_profile_info_repository.dart'; class DidProfileInfoRepositoryImpl implements DidProfileInfoRepository { diff --git a/lib/iden3comm/data/repositories/iden3comm_credential_repository_impl.dart b/lib/iden3comm/data/repositories/iden3comm_credential_repository_impl.dart index d5b9bc4b..7d454686 100644 --- a/lib/iden3comm/data/repositories/iden3comm_credential_repository_impl.dart +++ b/lib/iden3comm/data/repositories/iden3comm_credential_repository_impl.dart @@ -1,3 +1,4 @@ +import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_dto.dart'; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_mapper.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/remote_iden3comm_data_source.dart'; @@ -33,15 +34,29 @@ class Iden3commCredentialRepositoryImpl extends Iden3commCredentialRepository { return _remoteIden3commDataSource .fetchClaim(authToken: authToken, url: url, did: did) .then((dto) { - /// Error in fetching schema is not blocking - return _remoteIden3commDataSource - .fetchSchema(url: dto.info.credentialSchema.id) - .then((schema) { - dto.schema = schema; + final displayMethod = dto.info.displayMethod; + + /// Error in fetching schema or displayType is not blocking + final futures = Future.wait([ + _remoteIden3commDataSource + .fetchSchema(url: dto.info.credentialSchema.id) + .then((schema) { + dto.schema = schema; + return dto; + }).catchError((_) => dto), + if (displayMethod != null) + _remoteIden3commDataSource + .fetchDisplayType(url: displayMethod.id) + .then((displayType) { + displayType['type'] = displayMethod.type; + dto.displayType = displayType; + return dto; + }).catchError((_) { return dto; - }) - .catchError((_) => dto) - .then((value) => _claimMapper.mapFrom(dto)); + }), + ]); + + return futures.then((_) => _claimMapper.mapFrom(dto)); }).catchError((error) => throw FetchClaimException(error)); } @@ -51,4 +66,26 @@ class Iden3commCredentialRepositoryImpl extends Iden3commCredentialRepository { .fetchSchema(url: url) .catchError((error) => throw FetchSchemaException(error)); } + + @override + Future refreshCredential({ + required String url, + required String authToken, + required String profileDid, + }) async { + ClaimDTO claimDTO = await _remoteIden3commDataSource + .refreshCredential( + url: url, + authToken: authToken, + profileDid: profileDid, + ) + .catchError((error) => throw Exception(error)); + + Map schema = await _remoteIden3commDataSource.fetchSchema( + url: claimDTO.info.credentialSchema.id); + + claimDTO.schema = schema; + ClaimEntity claimEntity = _claimMapper.mapFrom(claimDTO); + return claimEntity; + } } diff --git a/lib/iden3comm/domain/entities/authorization/request/auth_request_iden3_message_entity.dart b/lib/iden3comm/domain/entities/authorization/request/auth_request_iden3_message_entity.dart index 5750d935..c0260f68 100644 --- a/lib/iden3comm/domain/entities/authorization/request/auth_request_iden3_message_entity.dart +++ b/lib/iden3comm/domain/entities/authorization/request/auth_request_iden3_message_entity.dart @@ -100,6 +100,13 @@ class AuthIden3MessageEntity extends Iden3MessageEntity { ); } + @override + Map toJson() { + final Map data = super.toJson(); + data['body'] = body.toJson(); + return data; + } + @override String toString() => "[AuthIden3MessageEntity] {${super.toString()}}"; diff --git a/lib/iden3comm/domain/entities/common/iden3_message_entity.dart b/lib/iden3comm/domain/entities/common/iden3_message_entity.dart index 3602c6fc..6e27105e 100644 --- a/lib/iden3comm/domain/entities/common/iden3_message_entity.dart +++ b/lib/iden3comm/domain/entities/common/iden3_message_entity.dart @@ -4,7 +4,9 @@ enum Iden3MessageType { authResponse, credentialOffer, credentialIssuanceResponse, - proofContractInvokeRequest + proofContractInvokeRequest, + credentialRefresh, + credentialStatusUpdate, } /// Represents an iden3 message. diff --git a/lib/iden3comm/domain/entities/common/request/proof_request_entity.dart b/lib/iden3comm/domain/entities/common/request/proof_request_entity.dart index 9c926540..d4b45ee8 100644 --- a/lib/iden3comm/domain/entities/common/request/proof_request_entity.dart +++ b/lib/iden3comm/domain/entities/common/request/proof_request_entity.dart @@ -47,4 +47,10 @@ class ProofQueryParamEntity { @override int get hashCode => runtimeType.hashCode; + + Map toJson() => { + 'field': field, + 'values': values, + 'operator': operator, + }; } diff --git a/lib/iden3comm/domain/entities/common/request/proof_scope_query_request.dart b/lib/iden3comm/domain/entities/common/request/proof_scope_query_request.dart index efa9bd14..721508d3 100644 --- a/lib/iden3comm/domain/entities/common/request/proof_scope_query_request.dart +++ b/lib/iden3comm/domain/entities/common/request/proof_scope_query_request.dart @@ -112,7 +112,9 @@ class ProofScopeQueryRequest { final bool? skipClaimRevocationCheck; final Map? credentialSubject; - //final ProofScopeRulesQuerySchemaRequest? schema; + final String? proofType; + + final int? groupId; ProofScopeQueryRequest({ this.allowedIssuers, @@ -121,7 +123,8 @@ class ProofScopeQueryRequest { this.challenge, this.credentialSubject, this.skipClaimRevocationCheck, - /*this.schema*/ + this.proofType, + this.groupId, }); /// Creates an instance from the given json @@ -130,19 +133,20 @@ class ProofScopeQueryRequest { /// @returns [ProofScopeRulesQueryRequest] factory ProofScopeQueryRequest.fromJson(Map? json) { if (json != null) { - //ProofScopeRulesQuerySchemaRequest? schema = - // ProofScopeRulesQuerySchemaRequest.fromJson(json['schema']); return ProofScopeQueryRequest( allowedIssuers: List.from(json['allowedIssuers']), context: json['context'], type: json['type'], challenge: json['challenge'], + proofType: json['proofType'], /// FIXME: flooring doubles without decimals to ints, this is because of protobuf /// only use number_value for google.protobuf.Value and turn int to float credentialSubject: (json['credentialSubject'] as Map?) ?.deepDoubleToInt(), skipClaimRevocationCheck: json['skipClaimRevocationCheck'], + + groupId: json['groupId'], ); //schema: schema); } else { @@ -157,13 +161,14 @@ class ProofScopeQueryRequest { 'challenge': challenge, 'credentialSubject': credentialSubject, 'skipClaimRevocationCheck': skipClaimRevocationCheck, - //'schema': schema!.toJson() + 'proofType': proofType, + 'groupId': groupId, }..removeWhere( (dynamic key, dynamic value) => key == null || value == null); @override String toString() => - "[ProofScopeRulesQueryRequest] {allowedIssuers: $allowedIssuers, challenge: $challenge, credentialSubject: $credentialSubject, context: $context, type: $type, skipClaimRevocationCheck: $skipClaimRevocationCheck}"; + "[ProofScopeRulesQueryRequest] {allowedIssuers: $allowedIssuers, challenge: $challenge, credentialSubject: $credentialSubject, context: $context, type: $type, skipClaimRevocationCheck: $skipClaimRevocationCheck, proofType: $proofType, groupId: $groupId}"; @override bool operator ==(Object other) => @@ -174,7 +179,9 @@ class ProofScopeQueryRequest { challenge == other.challenge && context == other.context && type == other.type && + proofType == other.proofType && skipClaimRevocationCheck == other.skipClaimRevocationCheck && + groupId == other.groupId && const DeepCollectionEquality() .equals(credentialSubject, other.credentialSubject); diff --git a/lib/iden3comm/domain/entities/common/request/proof_scope_request.dart b/lib/iden3comm/domain/entities/common/request/proof_scope_request.dart index a89845e3..50e584b1 100644 --- a/lib/iden3comm/domain/entities/common/request/proof_scope_request.dart +++ b/lib/iden3comm/domain/entities/common/request/proof_scope_request.dart @@ -83,11 +83,14 @@ class ProofScopeRequest { final bool? optional; final ProofScopeQueryRequest query; + final Map? params; + ProofScopeRequest({ required this.id, required this.circuitId, this.optional, required this.query, + this.params, }); /// Creates an instance from the given json @@ -102,6 +105,7 @@ class ProofScopeRequest { circuitId: json['circuitId'], optional: json['optional'], query: query, + params: json['params'], ); } @@ -110,12 +114,13 @@ class ProofScopeRequest { 'circuitId': circuitId, 'optional': optional, 'query': query.toJson(), + 'params': params, }..removeWhere( (dynamic key, dynamic value) => key == null || value == null); @override String toString() => - "[ProofScopeRequest] {id: $id, circuitId: $circuitId, optional: $optional, query: $query}"; + "[ProofScopeRequest] {id: $id, circuitId: $circuitId, optional: $optional, query: $query, params: $params}"; @override bool operator ==(Object other) => @@ -125,7 +130,8 @@ class ProofScopeRequest { id == other.id && circuitId == other.circuitId && optional == other.optional && - query == other.query; + query == other.query && + params == other.params; @override int get hashCode => runtimeType.hashCode; diff --git a/lib/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart b/lib/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart new file mode 100644 index 00000000..e2aaf21c --- /dev/null +++ b/lib/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart @@ -0,0 +1,79 @@ +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; + +class CredentialRefreshIden3MessageEntity extends Iden3MessageEntity { + @override + final CredentialRefreshBodyRequest body; + + CredentialRefreshIden3MessageEntity({ + required super.id, + required super.typ, + required super.type, + required super.thid, + required super.from, + required this.body, + required super.to, + }) : super(messageType: Iden3MessageType.credentialRefresh); + + factory CredentialRefreshIden3MessageEntity.fromJson( + Map json) { + CredentialRefreshBodyRequest body = + CredentialRefreshBodyRequest.fromJson(json['body']); + + return CredentialRefreshIden3MessageEntity( + id: json['id'], + typ: json['typ'], + type: json['type'], + thid: json['thid'], + from: json['from'], + to: json['to'], + body: body, + ); + } + + @override + String toString() => + "[CredentialRefreshIden3MessageEntity] {${super.toString()}}"; + + @override + bool operator ==(Object other) => + super == other && other is CredentialRefreshIden3MessageEntity; + + @override + int get hashCode => runtimeType.hashCode; +} + +class CredentialRefreshBodyRequest { + final String id; + final String reason; + + CredentialRefreshBodyRequest(this.id, this.reason); + + factory CredentialRefreshBodyRequest.fromJson(Map json) { + return CredentialRefreshBodyRequest( + json['id'], + json['reason'], + ); + } + + Map toJson() { + return { + 'id': id, + 'reason': reason, + }; + } + + @override + String toString() => + "[CredentialRefreshBodyRequest] {id: $id, reason: $reason}"; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CredentialRefreshBodyRequest && + runtimeType == other.runtimeType && + id == other.id && + reason == other.reason; + + @override + int get hashCode => runtimeType.hashCode; +} diff --git a/lib/iden3comm/domain/entities/credential/response/credential_status_update_message_entity.dart b/lib/iden3comm/domain/entities/credential/response/credential_status_update_message_entity.dart new file mode 100644 index 00000000..4efcb339 --- /dev/null +++ b/lib/iden3comm/domain/entities/credential/response/credential_status_update_message_entity.dart @@ -0,0 +1,96 @@ +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; + +class CredentialStatusUpdateMessageEntity extends Iden3MessageEntity { + @override + final CredentialStatusUpdateBody body; + + CredentialStatusUpdateMessageEntity({ + required super.id, + required super.typ, + required super.type, + required super.thid, + required super.from, + required super.to, + required this.body, + }) : super(messageType: Iden3MessageType.credentialStatusUpdate); + + /// Creates an instance from the given json + /// + /// @param [Map] json + /// @returns [CredentialStatusUpdateMessageEntity] + factory CredentialStatusUpdateMessageEntity.fromJson( + Map json) { + CredentialStatusUpdateBody body = + CredentialStatusUpdateBody.fromJson(json['body']); + + return CredentialStatusUpdateMessageEntity( + id: json['id'], + typ: json['typ'], + type: json['type'], + thid: json['thid'], + from: json['from'], + to: json['to'], + body: body, + ); + } + + @override + Map toJson() { + final Map data = super.toJson(); + data['body'] = body.toJson(); + return data; + } + + @override + String toString() => + "[CredentialStatusUpdateMessageEntity] {${super.toString()}}"; + + @override + bool operator ==(Object other) => + super == other && other is CredentialStatusUpdateMessageEntity; + + @override + int get hashCode => runtimeType.hashCode; +} + +class CredentialStatusUpdateBody { + final String id; + final String reason; + + CredentialStatusUpdateBody({ + required this.id, + required this.reason, + }); + + /// Creates an instance from the given json + /// + /// @param [Map] json + /// @returns [CredentialStatusUpdateBody] + factory CredentialStatusUpdateBody.fromJson(Map json) { + return CredentialStatusUpdateBody( + id: json['id'], + reason: json['reason'], + ); + } + + @override + Map toJson() => { + 'id': id, + 'reason': reason, + }; + + @override + String toString() => + "[CredentialStatusUpdateBody] {id: $id, reason: $reason}"; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CredentialStatusUpdateBody && + runtimeType == other.runtimeType && + id == other.id && + reason == other.reason; + + @override + int get hashCode => runtimeType.hashCode; +} diff --git a/lib/iden3comm/domain/exceptions/iden3comm_exceptions.dart b/lib/iden3comm/domain/exceptions/iden3comm_exceptions.dart index dc2c9b68..774e6948 100644 --- a/lib/iden3comm/domain/exceptions/iden3comm_exceptions.dart +++ b/lib/iden3comm/domain/exceptions/iden3comm_exceptions.dart @@ -50,6 +50,10 @@ class FetchSchemaException extends ErrorException { FetchSchemaException(error) : super(error); } +class FetchDisplayTypeException extends ErrorException { + FetchDisplayTypeException(error) : super(error); +} + class UnsupportedFetchClaimTypeException extends ErrorException { UnsupportedFetchClaimTypeException(error) : super(error); } diff --git a/lib/iden3comm/domain/repositories/iden3comm_credential_repository.dart b/lib/iden3comm/domain/repositories/iden3comm_credential_repository.dart index 6206ba15..06e27fa9 100644 --- a/lib/iden3comm/domain/repositories/iden3comm_credential_repository.dart +++ b/lib/iden3comm/domain/repositories/iden3comm_credential_repository.dart @@ -13,4 +13,10 @@ abstract class Iden3commCredentialRepository { }); Future> fetchSchema({required String url}); + + Future refreshCredential({ + required String url, + required String authToken, + required String profileDid, + }); } diff --git a/lib/iden3comm/domain/use_cases/authenticate_use_case.dart b/lib/iden3comm/domain/use_cases/authenticate_use_case.dart index a75a07cb..fa942595 100644 --- a/lib/iden3comm/domain/use_cases/authenticate_use_case.dart +++ b/lib/iden3comm/domain/use_cases/authenticate_use_case.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart'; @@ -65,6 +66,12 @@ class AuthenticateUseCase extends FutureUseCase { @override Future execute({required AuthenticateParam param}) async { try { + _stacktraceManager.addTrace( + "[AuthenticateUseCase][MainFlow] auth request: " + + jsonEncode(param.message.toJson()), + log: true, + ); + // we want to misure the time of the whole process Stopwatch stopwatch = Stopwatch()..start(); logger().i("stopwatch started"); @@ -159,8 +166,8 @@ class AuthenticateUseCase extends FutureUseCase { if (error is NullAtomicQueryInputsException) { _stacktraceManager.addTrace( "[AuthenticateUseCase] Error: $error\nerror: ${error.errorMessage}"); - _stacktraceManager.addError( - "[AuthenticateUseCase] error: ${error.errorMessage}"); + _stacktraceManager + .addError("[AuthenticateUseCase] error: ${error.errorMessage}"); logger().d( "[AuthenticateUseCase] Error: $error\nerror: ${error.errorMessage}"); } else { diff --git a/lib/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart b/lib/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart index 5fa2aae6..3e6f3d2a 100644 --- a/lib/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart +++ b/lib/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart @@ -54,9 +54,9 @@ class CheckProfileAndDidCurrentEnvUseCase }))) .then((identity) { logger().i( - "[CheckProfileAndDidCurrentEnvUseCase] Profile ${param.profileNonce} and private key ${param.privateKey} are valid for current env"); + "[CheckProfileAndDidCurrentEnvUseCase] Profile ${param.profileNonce} and private key are valid for current env"); _stacktraceManager.addTrace( - "[CheckProfileAndDidCurrentEnvUseCase] Profile ${param.profileNonce} and private key ${param.privateKey} are valid for current env"); + "[CheckProfileAndDidCurrentEnvUseCase] Profile ${param.profileNonce} and private key are valid for current env"); return identity; }).catchError((error) { logger().e("[CheckProfileAndDidCurrentEnvUseCase] Error: $error"); diff --git a/lib/iden3comm/domain/use_cases/fetch_and_save_claims_use_case.dart b/lib/iden3comm/domain/use_cases/fetch_and_save_claims_use_case.dart index 2d50a5f4..175e66ee 100644 --- a/lib/iden3comm/domain/use_cases/fetch_and_save_claims_use_case.dart +++ b/lib/iden3comm/domain/use_cases/fetch_and_save_claims_use_case.dart @@ -1,6 +1,9 @@ +import 'dart:convert'; + import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart'; import 'package:polygonid_flutter_sdk/common/domain/use_cases/get_env_use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/cache_credential_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart'; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_did_identifier_use_case.dart'; @@ -13,6 +16,7 @@ import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_us import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/request/offer_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_token_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_fetch_requests_use_case.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/atomic_query_inputs_config_param.dart'; class FetchAndSaveClaimsParam { final OfferIden3MessageEntity message; @@ -39,6 +43,7 @@ class FetchAndSaveClaimsUseCase final GetAuthTokenUseCase _getAuthTokenUseCase; final SaveClaimsUseCase _saveClaimsUseCase; final GetClaimRevocationStatusUseCase _getClaimRevocationStatusUseCase; + final CacheCredentialUseCase _cacheCredentialUseCase; final StacktraceManager _stacktraceManager; FetchAndSaveClaimsUseCase( @@ -50,102 +55,105 @@ class FetchAndSaveClaimsUseCase this._getAuthTokenUseCase, this._saveClaimsUseCase, this._getClaimRevocationStatusUseCase, + this._cacheCredentialUseCase, this._stacktraceManager, ); @override - Future> execute( - {required FetchAndSaveClaimsParam param}) async { + Future> execute({ + required FetchAndSaveClaimsParam param, + }) async { /// Get the corresponding fetch request from [OfferIden3MessageEntity] /// For each, get the auth token /// With the auth token, fetch the [ClaimEntity] /// Then save the list of [ClaimEntity] - /// - - await _checkProfileAndDidCurrentEnvUseCase.execute( - param: CheckProfileAndDidCurrentEnvParam( - did: param.genesisDid, - privateKey: param.privateKey, - profileNonce: param.profileNonce)); - - EnvEntity env = await _getEnvUseCase.execute(); - - String profileDid = await _getDidIdentifierUseCase.execute( - param: GetDidIdentifierParam( - privateKey: param.privateKey, - blockchain: env.blockchain, - network: env.network, - profileNonce: param.profileNonce)); - - return _getFetchRequestsUseCase - .execute(param: GetFetchRequestsParam(param.message, profileDid)) - .then((requests) async { - List claims = []; - - for (String request in requests) { - await _getAuthTokenUseCase - .execute( - param: GetAuthTokenParam( - genesisDid: param.genesisDid, - profileNonce: param.profileNonce, - privateKey: param.privateKey, - message: request, - )) - .then((authToken) => _iden3commCredentialRepository.fetchClaim( - did: profileDid, - authToken: authToken, - url: param.message.body.url)) - .then((claim) async { - /*Map revStatus = - await _getClaimRevocationStatusUseCase - .execute( - param: GetClaimRevocationStatusParam(claim: claim)) - .catchError((_) => {}); - - /// FIXME: define an entity for revocation and use it in repo impl - if (revStatus.isNotEmpty && - revStatus["mtp"] != null && - revStatus["mtp"]["existence"] != null && - revStatus["mtp"]["existence"] == true) { - claim = ClaimEntity( - id: claim.id, - issuer: claim.issuer, - did: claim.did, - state: ClaimState.revoked, - expiration: claim.expiration, - schema: claim.schema, - type: claim.type, - info: claim.info, - ); - }*/ - claims.add(claim); - }); - } - - return claims; - }) - // TODO profileDid - .then((claims) => _saveClaimsUseCase - .execute( - param: SaveClaimsParam( - claims: claims, - genesisDid: param.genesisDid, + + try { + await _checkProfileAndDidCurrentEnvUseCase.execute( + param: CheckProfileAndDidCurrentEnvParam( + did: param.genesisDid, privateKey: param.privateKey, - )) - .then((_) { - logger().i( - "[FetchAndSaveClaimsUseCase] All claims have been saved: $claims"); - _stacktraceManager.addTrace( - "[FetchAndSaveClaimsUseCase] All claims have been saved: claimsLength ${claims.length}"); - return claims; - })) - .catchError((error) { - logger().e("[FetchAndSaveClaimsUseCase] Error: $error"); - _stacktraceManager - .addTrace("[FetchAndSaveClaimsUseCase] Error: $error"); - _stacktraceManager - .addError("[FetchAndSaveClaimsUseCase] Error: $error"); - throw error; - }); + profileNonce: param.profileNonce)); + + EnvEntity env = await _getEnvUseCase.execute(); + + String profileDid = await _getDidIdentifierUseCase.execute( + param: GetDidIdentifierParam( + privateKey: param.privateKey, + blockchain: env.blockchain, + network: env.network, + profileNonce: param.profileNonce)); + + final List requests = await _getFetchRequestsUseCase.execute( + param: GetFetchRequestsParam( + param.message, + profileDid, + )); + + List claims = []; + for (String request in requests) { + final String authToken = await _getAuthTokenUseCase.execute( + param: GetAuthTokenParam( + genesisDid: param.genesisDid, + profileNonce: param.profileNonce, + privateKey: param.privateKey, + message: request, + )); + + ClaimEntity claimEntity = + await _iden3commCredentialRepository.fetchClaim( + did: profileDid, + authToken: authToken, + url: param.message.body.url); + + claims.add(claimEntity); + } + + await _saveClaimsUseCase.execute( + param: SaveClaimsParam( + claims: claims, + genesisDid: param.genesisDid, + privateKey: param.privateKey, + )); + + logger() + .i("[FetchAndSaveClaimsUseCase] All claims have been saved: $claims"); + _stacktraceManager.addTrace( + "[FetchAndSaveClaimsUseCase] All claims have been saved: claimsLength ${claims.length}"); + + final config = AtomicQueryInputsConfigParam( + ethereumUrl: env.web3Url + env.web3ApiKey, + stateContractAddr: env.idStateContract, + ipfsNodeURL: env.ipfsUrl, + ); + + for (final claim in claims) { + // cache claim + try { + await _cacheCredentialUseCase.execute( + param: CacheCredentialParam( + credential: jsonEncode( + { + "verifiableCredentials": claim.toJson(), + }, + ), + config: jsonEncode(config.toJson()), + ), + ); + } catch (e) { + logger() + .e("[FetchAndSaveClaimsUseCase] Error while caching claim: $e"); + _stacktraceManager.addTrace( + "[FetchAndSaveClaimsUseCase] Error while caching claim: $e"); + } + } + + return claims; + } catch (error) { + logger().e("[FetchAndSaveClaimsUseCase] Error: $error"); + _stacktraceManager.addTrace("[FetchAndSaveClaimsUseCase] Error: $error"); + _stacktraceManager.addError("[FetchAndSaveClaimsUseCase] Error: $error"); + rethrow; + } } } diff --git a/lib/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart b/lib/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart index e18abad1..47f4700b 100644 --- a/lib/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart +++ b/lib/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:typed_data'; +import 'package:flutter/foundation.dart'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; @@ -11,6 +12,7 @@ import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/request/p import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/iden3comm_proof_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/iden3comm_sd_proof_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/iden3comm_vp_proof.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/did_entity.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/identity_entity.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/node_entity.dart'; @@ -45,19 +47,27 @@ class GenerateIden3commProofParam { final String? stateContractAddr; final String? ipfsNodeURL; - GenerateIden3commProofParam( - this.did, - this.profileNonce, - this.claimSubjectProfileNonce, - this.credential, - this.request, - this.circuitData, + final String? verifierId; + final String? linkNonce; + + final Map? transactionData; + + GenerateIden3commProofParam({ + required this.did, + required this.profileNonce, + required this.claimSubjectProfileNonce, + required this.credential, + required this.request, + required this.circuitData, this.privateKey, this.challenge, this.ethereumUrl, this.stateContractAddr, this.ipfsNodeURL, - ); + this.verifierId, + this.linkNonce, + this.transactionData, + }); } class GenerateIden3commProofUseCase @@ -89,8 +99,9 @@ class GenerateIden3commProofUseCase ); @override - Future execute( - {required GenerateIden3commProofParam param}) async { + Future execute({ + required GenerateIden3commProofParam param, + }) async { List? authClaim; MTProofEntity? incProof; MTProofEntity? nonRevProof; @@ -99,13 +110,29 @@ class GenerateIden3commProofUseCase Map? config; String? signature; + logger().i("[GenerateIden3commProofUseCase] claim:"); + logger().i(param.credential.toJson()); + Stopwatch stopwatch = Stopwatch()..start(); - if (param.request.circuitId == "credentialAtomicQueryMTPV2OnChain" || - param.request.circuitId == "credentialAtomicQuerySigV2OnChain") { + final circuitId = param.request.circuitId; + + // TODO (moria): remove this with v3 circuit release + if (circuitId.startsWith(CircuitType.v3CircuitPrefix) && + !circuitId.endsWith(CircuitType.currentCircuitBetaPostfix)) { + _stacktraceManager.addTrace( + "V3 circuit beta version mismatch $circuitId is not supported, current is ${CircuitType.currentCircuitBetaPostfix}"); + throw Exception( + "V3 circuit beta version mismatch $circuitId is not supported, current is ${CircuitType.currentCircuitBetaPostfix}"); + } + + if (circuitId == CircuitType.mtponchain.name || + circuitId == CircuitType.sigonchain.name || + circuitId == CircuitType.circuitsV3onchain.name) { //on chain start _stacktraceManager.addTrace( "[GenerateIden3commProofUseCase] OnChain ${param.request.circuitId}"); + IdentityEntity identity = await _getIdentityUseCase.execute( param: GetIdentityParam( genesisDid: param.did, privateKey: param.privateKey)); @@ -113,12 +140,14 @@ class GenerateIden3commProofUseCase "[GenerateIden3commProofUseCase] identity: ${identity.did}"); logger().i( "GENERATION PROOF getIdentityUseCase executed in ${stopwatch.elapsed}"); + authClaim = await _getAuthClaimUseCase.execute(param: identity.publicKey); - _stacktraceManager.addTrace("[GenerateIden3commProofUseCase] authClaim"); logger().i( "GENERATION PROOF getAuthClaimUseCase executed in ${stopwatch.elapsed}"); + NodeEntity authClaimNode = await _identityRepository.getAuthClaimNode(children: authClaim); + _stacktraceManager .addTrace("[GenerateIden3commProofUseCase] authClaimNode"); logger().i( @@ -194,6 +223,10 @@ class GenerateIden3commProofUseCase proofScopeRequest: param.request.toJson(), circuitId: param.request.circuitId, config: config, + verifierId: param.verifierId, + linkNonce: param.linkNonce, + scopeParams: param.request.params, + transactionData: param.transactionData, ) .catchError((error) { _stacktraceManager @@ -207,15 +240,30 @@ class GenerateIden3commProofUseCase logger().i( "GENERATION PROOF calculateAtomicQueryInputs executed in ${stopwatch.elapsed}"); - dynamic inputsJson = json.decode(Uint8ArrayUtils.uint8ListToString(res)); + final inputsString = Uint8ArrayUtils.uint8ListToString(res); + dynamic inputsJson = json.decode(inputsString); + + _stacktraceManager.addTrace( + "[GenerateIden3commProofUseCase][MainFlow] atomic inputs JSON:$inputsString", + log: true, + ); + Uint8List atomicQueryInputs = Uint8ArrayUtils.uint8ListfromString(json.encode(inputsJson["inputs"])); + if (kDebugMode) { + //just for debug + String inputs = Uint8ArrayUtils.uint8ListToString(atomicQueryInputs); + } + var vpProof; if (inputsJson["verifiablePresentation"] != null) { vpProof = Iden3commVPProof.fromJson(inputsJson["verifiablePresentation"]); } + logger().i('[GenerateIden3commProofUseCase] verifiablePresentation:'); + logger().i(vpProof ?? inputsJson["verifiablePresentation"]); + logger().i( "GENERATION PROOF atomicQueryInputs executed in ${stopwatch.elapsed}"); @@ -223,8 +271,10 @@ class GenerateIden3commProofUseCase return _proveUseCase .execute(param: ProveParam(atomicQueryInputs, param.circuitData)) .then((proof) { - _stacktraceManager.addTrace("[GenerateIden3commProofUseCase] proof"); - logger().i("[GenerateProofUseCase] proof: $proof"); + _stacktraceManager.addTrace( + "[GenerateIden3commProofUseCase][MainFlow] proof: ${jsonEncode(proof.toJson())}", + log: true, + ); if (vpProof != null) { return Iden3commSDProofEntity( diff --git a/lib/iden3comm/domain/use_cases/get_auth_inputs_use_case.dart b/lib/iden3comm/domain/use_cases/get_auth_inputs_use_case.dart index ca791939..a7f4fc9a 100644 --- a/lib/iden3comm/domain/use_cases/get_auth_inputs_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_auth_inputs_use_case.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:typed_data'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; @@ -60,12 +61,8 @@ class GetAuthInputsUseCase param: GetIdentityParam( genesisDid: param.genesisDid, privateKey: param.privateKey)); - _stacktraceManager.addTrace("[GetAuthInputsUseCase] Identity: $identity"); - List authClaim = await _getAuthClaimUseCase.execute(param: identity.publicKey); - _stacktraceManager - .addTrace("[GetAuthInputsUseCase] Auth claim: ${authClaim.toString()}"); NodeEntity authClaimNode = await _identityRepository.getAuthClaimNode(children: authClaim); _stacktraceManager.addTrace("[GetAuthInputsUseCase] Auth claim node"); @@ -90,13 +87,13 @@ class GetAuthInputsUseCase param: GetLatestStateParam( did: param.genesisDid, privateKey: param.privateKey)); - _stacktraceManager - .addTrace("[GetAuthInputsUseCase] Tree state: ${treeState.toString()}"); + _stacktraceManager.addTrace( + "[GetAuthInputsUseCase][MainFlow] Tree state: ${jsonEncode(treeState)}"); GistMTProofEntity gistProof = await _getGistMTProofUseCase.execute(param: param.genesisDid); - _stacktraceManager - .addTrace("[GetAuthInputsUseCase] Gist proof: ${gistProof.toString()}"); + _stacktraceManager.addTrace( + "[GetAuthInputsUseCase][MainFlow] Gist proof: ${jsonEncode(gistProof.toJson())}"); return _signMessageUseCase .execute(param: SignMessageParam(param.privateKey, param.challenge)) diff --git a/lib/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart b/lib/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart index 1c83cc95..8f35ab2c 100644 --- a/lib/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart @@ -1,3 +1,5 @@ +import 'package:collection/collection.dart'; +import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; @@ -8,9 +10,11 @@ import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claims_use import 'package:polygonid_flutter_sdk/credential/domain/use_cases/update_claim_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/request/proof_request_entity.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/request/proof_scope_query_request.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exceptions.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_requests_use_case.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/proof/data/mappers/circuit_type_mapper.dart'; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/is_proof_circuit_supported_use_case.dart'; @@ -54,8 +58,9 @@ class GetIden3commClaimsUseCase ); @override - Future> execute( - {required GetIden3commClaimsParam param}) async { + Future> execute({ + required GetIden3commClaimsParam param, + }) async { List claims = []; List requests = @@ -67,110 +72,89 @@ class GetIden3commClaimsUseCase for (ProofRequestEntity request in requests) { if (await _isProofCircuitSupported.execute( param: request.scope.circuitId)) { - // Claims - claims.add( - await _iden3commCredentialRepository - .getFilters(request: request) - .then((filters) { - _stacktraceManager - .addTrace("[GetIden3commClaimsUseCase] filters: $filters"); - return _getClaimsUseCase.execute( - param: GetClaimsParam( - filters: filters, - genesisDid: param.genesisDid, - profileNonce: param.profileNonce, - privateKey: param.privateKey, - ), - ); - }).then( - (claims) async { - if (claims.isEmpty) { - _stacktraceManager - .addTrace("[GetIden3commClaimsUseCase] claims is empty"); - return null; - } - - bool hasValidProofType = claims.any((element) { - List> proofs = element.info["proof"]; - List proofTypes = - proofs.map((e) => e["type"] as String).toList(); - - CircuitType circuitType = - _circuitTypeMapper.mapTo(request.scope.circuitId); - - switch (circuitType) { - case CircuitType.mtp: - case CircuitType.mtponchain: - bool success = [ - 'Iden3SparseMerkleProof', - 'Iden3SparseMerkleTreeProof' - ].any((element) => proofTypes.contains(element)); - return success; - case CircuitType.sig: - case CircuitType.sigonchain: - bool success = proofTypes.contains('BJJSignature2021'); - return success; - case CircuitType.auth: - case CircuitType.unknown: - break; - } - return false; - }); - - if (!hasValidProofType) { - _stacktraceManager.addTrace( - "[GetIden3commClaimsUseCase] claims has no valid proof type"); - return null; - } - - /*if (request.scope.query.skipClaimRevocationCheck == null || - request.scope.query.skipClaimRevocationCheck == false) { - _stacktraceManager.addTrace( - "[GetIden3commClaimsUseCase] claims has valid proof type, checking revocation status"); - for (int i = 0; i < claims.length; i++) { - int revNonce = await _getClaimRevocationNonceUseCase.execute( - param: claims[i]); - _stacktraceManager - .addTrace("[GetIden3commClaimsUseCase] revNonce"); - Map? savedNonRevProof; - if (param.nonRevocationProofs.isNotEmpty && - param.nonRevocationProofs.containsKey(revNonce)) { - savedNonRevProof = param.nonRevocationProofs[revNonce]; - } - - Map nonRevProof = - await _getClaimRevocationStatusUseCase - .execute( - param: GetClaimRevocationStatusParam( - claim: claims[i], - nonRevProof: savedNonRevProof)) - .catchError((_) => {}); - _stacktraceManager - .addTrace("[GetIden3commClaimsUseCase] nonRevProof"); - - /// FIXME: define an entity for revocation and use it in repo impl - if (nonRevProof.isNotEmpty && - nonRevProof["mtp"] != null && - nonRevProof["mtp"]["existence"] != null && - nonRevProof["mtp"]["existence"] == true) { - claims[i] = await _updateClaimUseCase.execute( - param: UpdateClaimParam( - id: claims[i].id, - state: ClaimState.revoked, - genesisDid: param.genesisDid, - privateKey: param.privateKey)); - } - } - return claims - .where((claim) => claim.state != ClaimState.revoked) - .toList() - .first; - } else {*/ - return claims.first; - /*}*/ - }, + List filters = + await _iden3commCredentialRepository.getFilters(request: request); + _stacktraceManager + .addTrace("[GetIden3commClaimsUseCase] filters: $filters"); + + List claimsFiltered = await _getClaimsUseCase.execute( + param: GetClaimsParam( + filters: filters, + genesisDid: param.genesisDid, + profileNonce: param.profileNonce, + privateKey: param.privateKey, ), ); + + // filter manually positive integer + claimsFiltered = _filterManuallyIfPositiveInteger( + request: request, + claimsFiltered: claimsFiltered, + ); + + //filter manually proof type + claimsFiltered = _filterManuallyIfQueryContainsProofType( + request: request, + claimsFiltered: claimsFiltered, + ); + + if (claimsFiltered.isEmpty) { + _stacktraceManager + .addTrace("[GetIden3commClaimsUseCase] claims is empty"); + continue; + } + + var validClaim = claimsFiltered.firstWhereOrNull((element) { + List> proofs = element.info["proof"]; + List proofTypes = + proofs.map((e) => e["type"] as String).toList(); + + final circuitId = request.scope.circuitId; + // TODO (moria): remove this with v3 circuit release + if (circuitId.startsWith(CircuitType.v3CircuitPrefix) && + !circuitId.endsWith(CircuitType.currentCircuitBetaPostfix)) { + _stacktraceManager.addTrace( + "V3 circuit beta version mismatch $circuitId is not supported, current is ${CircuitType.currentCircuitBetaPostfix}"); + throw Exception( + "V3 circuit beta version mismatch $circuitId is not supported, current is ${CircuitType.currentCircuitBetaPostfix}"); + } + + CircuitType circuitType = _circuitTypeMapper.mapTo(circuitId); + + switch (circuitType) { + case CircuitType.mtp: + case CircuitType.mtponchain: + bool success = [ + 'Iden3SparseMerkleProof', + 'Iden3SparseMerkleTreeProof' + ].any((element) => proofTypes.contains(element)); + return success; + case CircuitType.sig: + case CircuitType.sigonchain: + bool success = proofTypes.contains('BJJSignature2021'); + return success; + case CircuitType.auth: + case CircuitType.unknown: + break; + case CircuitType.circuitsV3: + case CircuitType.circuitsV3onchain: + bool success = [ + 'Iden3SparseMerkleProof', + 'Iden3SparseMerkleTreeProof', + 'BJJSignature2021', + ].any((element) => proofTypes.contains(element)); + return success; + } + return false; + }); + + if (validClaim == null) { + _stacktraceManager.addTrace( + "[GetIden3commClaimsUseCase] claims has no valid proof type"); + continue; + } + + claims.add(validClaim); } } @@ -187,4 +171,128 @@ class GetIden3commClaimsUseCase return claims; } + + String _getTypeFromNestedObject( + Map contextMap, String nestedKey) { + List keys = nestedKey.split('.'); + dynamic value = contextMap; + for (String key in keys) { + if (value is Map && value[key].containsKey("@context")) { + value = value[key]["@context"]; + } else if (value is Map && + value[key].containsKey("@type")) { + value = value[key]["@type"]; + break; + } else { + break; + } + } + return value; + } + + /// + dynamic _getNestedValue(Map map, String key) { + List keys = key.split('.'); + dynamic value = map; + for (String key in keys) { + if (value is Map && value.containsKey(key)) { + value = value[key]; + } else { + break; + } + } + return value; + } + + /// The positiveInteger type is not supported by the filter 'cause this type + /// is stored as a string in the database. So we need to filter manually + List _filterManuallyIfPositiveInteger({ + required ProofRequestEntity request, + required List claimsFiltered, + }) { + try { + if (request.scope.query.credentialSubject == null) return claimsFiltered; + + ProofScopeQueryRequest query = request.scope.query; + Map? context = + request.context["@context"][0][query.type]["@context"]; + if (context == null) return claimsFiltered; + + Map requestMap = request.scope.query.credentialSubject!; + requestMap.forEach((key, map) { + if (map == null || map is! Map || map.isEmpty) return; + + String type = _getTypeFromNestedObject(context, key); + if (!type.contains("positiveInteger")) return; + + _processMap(map, key, claimsFiltered); + }); + } catch (ignored) { + // Consider logging the exception + } + return claimsFiltered; + } + + void _processMap(dynamic map, String key, List claimsFiltered) { + map.forEach((operator, needle) { + _filterClaims(operator, needle, key, claimsFiltered); + }); + } + + void _filterClaims(String operator, dynamic needle, String key, + List claimsFiltered) { + // Implement the filtering logic here, similar to what you have in your switch case + claimsFiltered.removeWhere((element) { + Map credentialSubject = + element.info["credentialSubject"]; + dynamic value = _getNestedValue(credentialSubject, key); + if (value != null) { + BigInt valueBigInt = BigInt.parse(value); + switch (operator) { + case '\$gt': + return valueBigInt <= BigInt.from(needle); + case '\$gte': + return valueBigInt < BigInt.from(needle); + case '\$lt': + return valueBigInt >= BigInt.from(needle); + case '\$lte': + return valueBigInt > BigInt.from(needle); + case '\$eq': + return valueBigInt != BigInt.from(needle); + case '\$neq': + return valueBigInt == BigInt.from(needle); + case '\$in': + List values = List.from(needle); + List stringList = values.map((e) => e.toString()).toList(); + return !stringList.contains(value); + case '\$nin': + List values = List.from(needle); + List stringList = values.map((e) => e.toString()).toList(); + return stringList.contains(value); + } + } + return false; + }); + } + + List _filterManuallyIfQueryContainsProofType({ + required ProofRequestEntity request, + required List claimsFiltered, + }) { + try { + if (request.scope.query.proofType == null || + request.scope.query.proofType!.isEmpty) return claimsFiltered; + + String proofType = request.scope.query.proofType!; + claimsFiltered.removeWhere((element) { + List> proofs = element.info["proof"]; + List proofTypes = + proofs.map((e) => e["type"] as String).toList(); + return !proofTypes.contains(proofType); + }); + } catch (ignored) { + // Consider logging the exception + } + return claimsFiltered; + } } diff --git a/lib/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart b/lib/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart index d8dfc7b7..acb7e20e 100644 --- a/lib/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart @@ -1,14 +1,29 @@ +import 'dart:math'; + +import 'package:flutter/foundation.dart'; +import 'package:ninja_prime/ninja_prime.dart'; +import 'dart:convert'; + +import 'package:intl/intl.dart'; import 'package:polygonid_flutter_sdk/common/domain/domain_constants.dart'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_info_dto.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/refresh_credential_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/iden3comm_proof_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/request/proof_request_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exceptions.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_token_use_case.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/did_entity.dart'; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_did_use_case.dart'; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/get_identity_use_case.dart'; @@ -23,6 +38,7 @@ import 'package:polygonid_flutter_sdk/proof/domain/entities/circuit_data_entity. import 'package:polygonid_flutter_sdk/proof/domain/repositories/proof_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_requests_use_case.dart'; +import 'package:uuid/uuid.dart'; class GetIden3commProofsParam { final Iden3MessageEntity message; @@ -35,16 +51,20 @@ class GetIden3commProofsParam { final String? ipfsNodeUrl; final Map>? nonRevocationProofs; - GetIden3commProofsParam( - {required this.message, - required this.genesisDid, - required this.profileNonce, - required this.privateKey, - this.challenge, - this.ethereumUrl, - this.stateContractAddr, - this.ipfsNodeUrl, - this.nonRevocationProofs}); + final Map? transactionData; + + GetIden3commProofsParam({ + required this.message, + required this.genesisDid, + required this.profileNonce, + required this.privateKey, + this.challenge, + this.ethereumUrl, + this.stateContractAddr, + this.ipfsNodeUrl, + this.nonRevocationProofs, + this.transactionData, + }); } class GetIden3commProofsUseCase @@ -58,6 +78,12 @@ class GetIden3commProofsUseCase final ProofGenerationStepsStreamManager _proofGenerationStepsStreamManager; final StacktraceManager _stacktraceManager; + final GetAuthTokenUseCase _getAuthTokenUseCase; + final Iden3commCredentialRepository _iden3commCredentialRepository; + final RemoveClaimsUseCase _removeClaimsUseCase; + final SaveClaimsUseCase _saveClaimsUseCase; + final RefreshCredentialUseCase _refreshCredentialUseCase; + GetIden3commProofsUseCase( this._proofRepository, this._getIden3commClaimsUseCase, @@ -67,35 +93,38 @@ class GetIden3commProofsUseCase this._getIdentityUseCase, this._proofGenerationStepsStreamManager, this._stacktraceManager, + this._getAuthTokenUseCase, + this._iden3commCredentialRepository, + this._removeClaimsUseCase, + this._saveClaimsUseCase, + this._refreshCredentialUseCase, ); @override - Future> execute( - {required GetIden3commProofsParam param}) async { + Future> execute({ + required GetIden3commProofsParam param, + }) async { try { List proofs = []; - - Stopwatch stopwatch = Stopwatch()..start(); + Map groupIdLinkNonceMap = {}; _proofGenerationStepsStreamManager.add("Getting proof requests"); List requests = await _getProofRequestsUseCase.execute(param: param.message); _stacktraceManager .addTrace("[GetIden3commProofsUseCase] requests: $requests"); - logger().i( - "STOPPE after _getProofRequestsUseCase ${stopwatch.elapsedMilliseconds}"); List claims = await _getIden3commClaimsUseCase.execute( - param: GetIden3commClaimsParam( - message: param.message, - genesisDid: param.genesisDid, - profileNonce: param.profileNonce, - privateKey: param.privateKey, - nonRevocationProofs: param.nonRevocationProofs ?? {})); + param: GetIden3commClaimsParam( + message: param.message, + genesisDid: param.genesisDid, + profileNonce: param.profileNonce, + privateKey: param.privateKey, + nonRevocationProofs: param.nonRevocationProofs ?? {}, + ), + ); _stacktraceManager.addTrace( "[GetIden3commProofsUseCase] claims found: ${claims.length}"); - logger().i( - "STOPPE after _getIden3commClaimsUseCase ${stopwatch.elapsedMilliseconds}"); if ((requests.isNotEmpty && claims.isNotEmpty && @@ -106,18 +135,33 @@ class GetIden3commProofsUseCase for (int i = 0; i < requests.length; i++) { ProofRequestEntity request = requests[i]; ClaimEntity? claim = claims[i]; - if (claim != null && - claim.type == request.scope.query.type && - await _isProofCircuitSupported.execute( - param: request.scope.circuitId)) { + + if (claim == null) { + continue; + } + + if (claim.expiration != null) { + claim = await _checkCredentialExpirationAndTryRefreshIfExpired( + claim: claim, + param: param, + ); + } + + bool isCircuitSupported = await _isProofCircuitSupported.execute( + param: request.scope.circuitId, + ); + bool isCorrectType = claim.type == request.scope.query.type; + + if (isCorrectType && isCircuitSupported) { String circuitId = request.scope.circuitId; CircuitDataEntity circuitData = await _proofRepository.loadCircuitFiles(circuitId); String? challenge; String? privKey; - if (circuitId == "credentialAtomicQuerySigV2OnChain" || - circuitId == "credentialAtomicQueryMTPV2OnChain") { + if (circuitId == CircuitType.mtponchain.name || + circuitId == CircuitType.sigonchain.name || + circuitId == CircuitType.circuitsV3onchain.name) { privKey = param.privateKey; challenge = param.challenge; } @@ -128,28 +172,53 @@ class GetIden3commProofsUseCase privateKey: param.privateKey)); BigInt claimSubjectProfileNonce = identityEntity.profiles.keys - .firstWhere((k) => identityEntity.profiles[k] == claim.did, + .firstWhere((k) => identityEntity.profiles[k] == claim!.did, orElse: () => GENESIS_PROFILE_NONCE); + int? groupId = request.scope.query.groupId; + String linkNonce = "0"; + // Check if groupId exists in the map + if (groupId != null) { + if (groupIdLinkNonceMap.containsKey(groupId)) { + // Use the existing linkNonce for this groupId + linkNonce = groupIdLinkNonceMap[groupId]!; + } else { + // Generate a new linkNonce for this groupId + linkNonce = + generateLinkNonce(); // Replace this with your linkNonce generation logic + groupIdLinkNonceMap[groupId] = linkNonce; + } + } + _proofGenerationStepsStreamManager .add("Generating proof for ${claim.type}"); + + // Generate proof param + GenerateIden3commProofParam proofParam = + GenerateIden3commProofParam( + did: param.genesisDid, + profileNonce: param.profileNonce, + claimSubjectProfileNonce: claimSubjectProfileNonce, + credential: claim, + request: request.scope, + circuitData: circuitData, + privateKey: privKey, + challenge: challenge, + ethereumUrl: param.ethereumUrl, + stateContractAddr: param.stateContractAddr, + ipfsNodeURL: param.ipfsNodeUrl, + verifierId: param.message.from, + linkNonce: linkNonce, + transactionData: param.transactionData, + ); + // Generate proof - proofs.add(await _generateIden3commProofUseCase.execute( - param: GenerateIden3commProofParam( - param.genesisDid, - param.profileNonce, - claimSubjectProfileNonce, - claim, - request.scope, - circuitData, - privKey, - challenge, - param.ethereumUrl, - param.stateContractAddr, - param.ipfsNodeUrl, - ))); - logger().i( - "STOPPE after _generateIden3commProofUseCase $i ${stopwatch.elapsedMilliseconds}"); + Iden3commProofEntity proof = + await _generateIden3commProofUseCase.execute( + param: proofParam, + ); + + proofs.add(proof); } } } else { @@ -175,4 +244,58 @@ class GetIden3commProofsUseCase rethrow; } } + + /// We generate a random linkNonce for each groupId + String generateLinkNonce() { + final BigInt safeMaxVal = BigInt.parse( + "21888242871839275222246405745257275088548364400416034343698204186575808495617"); + // get max value of 2 ^ 248 + BigInt base = BigInt.parse('2'); + int exponent = 248; + final maxVal = base.pow(exponent) - BigInt.one; + final random = Random.secure(); + BigInt randomNumber; + do { + randomNumber = randomBigInt(248, max: maxVal, random: random); + if (kDebugMode) { + print("random number $randomNumber"); + print("less than safeMax ${randomNumber < safeMaxVal}"); + } + } while (randomNumber >= safeMaxVal); + + return randomNumber.toString(); + } + + /// Check if the credential is expired and try to refresh it if it is + /// and if it has a refresh service + Future _checkCredentialExpirationAndTryRefreshIfExpired({ + required ClaimEntity claim, + required GetIden3commProofsParam param, + }) async { + var now = DateTime.now().toUtc(); + DateTime expirationTime = + DateFormat("yyyy-MM-ddTHH:mm:ssZ").parse(claim.expiration!); + + var nowFormatted = DateFormat("yyyy-MM-dd HH:mm:ss").format(now); + var expirationTimeFormatted = + DateFormat("yyyy-MM-dd HH:mm:ss").format(expirationTime); + bool isExpired = nowFormatted.compareTo(expirationTimeFormatted) > 0 || + claim.state == ClaimState.expired; + + if (isExpired && claim.info.containsKey("refreshService")) { + _proofGenerationStepsStreamManager + .add("Refreshing expired credential..."); + + ClaimEntity refreshedClaimEntity = + await _refreshCredentialUseCase.execute( + param: RefreshCredentialParam( + credential: claim, + genesisDid: param.genesisDid, + privateKey: param.privateKey, + )); + + claim = refreshedClaimEntity; + } + return claim; + } } diff --git a/lib/iden3comm/domain/use_cases/get_iden3message_type_use_case.dart b/lib/iden3comm/domain/use_cases/get_iden3message_type_use_case.dart index 88e41eb6..fe7a4cbb 100644 --- a/lib/iden3comm/domain/use_cases/get_iden3message_type_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_iden3message_type_use_case.dart @@ -24,6 +24,9 @@ class GetIden3MessageTypeUseCase case "https://iden3-communication.io/proofs/1.0/contract-invoke-request": type = Iden3MessageType.proofContractInvokeRequest; break; + case "https://iden3-communication.io/credentials/1.0/status-update": + type = Iden3MessageType.credentialStatusUpdate; + break; } return Future.value(type); diff --git a/lib/iden3comm/domain/use_cases/get_iden3message_use_case.dart b/lib/iden3comm/domain/use_cases/get_iden3message_use_case.dart index 8985850f..e2790fd9 100644 --- a/lib/iden3comm/domain/use_cases/get_iden3message_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_iden3message_use_case.dart @@ -3,7 +3,9 @@ import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/authorization/request/auth_request_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/request/credential_refresh_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/request/offer_iden3_message_entity.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/response/credential_status_update_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/credential/response/fetch_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/request/contract_iden3_message_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exceptions.dart'; @@ -36,6 +38,10 @@ class GetIden3MessageUseCase extends FutureUseCase { return FetchIden3MessageEntity.fromJson(json); case Iden3MessageType.proofContractInvokeRequest: return ContractIden3MessageEntity.fromJson(json); + case Iden3MessageType.credentialRefresh: + return CredentialRefreshIden3MessageEntity.fromJson(json); + case Iden3MessageType.credentialStatusUpdate: + return CredentialStatusUpdateMessageEntity.fromJson(json); case Iden3MessageType.authResponse: case Iden3MessageType.unknown: throw UnsupportedIden3MsgTypeException(type); diff --git a/lib/iden3comm/domain/use_cases/get_jwz_use_case.dart b/lib/iden3comm/domain/use_cases/get_jwz_use_case.dart index 74b0777d..63647c71 100644 --- a/lib/iden3comm/domain/use_cases/get_jwz_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_jwz_use_case.dart @@ -42,8 +42,8 @@ class GetJWZUseCase extends FutureUseCase { String encodedJwz = await _iden3commRepository.encodeJWZ(jwz: jwz); - logger().i("[GetJWZUseCase] JWZ: $encodedJwz"); - _stacktraceManager.addTrace("[GetJWZUseCase] JWZ: $encodedJwz"); + logger().i("[GetJWZUseCase][MainFlow] JWZ: $encodedJwz"); + _stacktraceManager.addTrace("[GetJWZUseCase][MainFlow] JWZ: $encodedJwz"); return encodedJwz; } catch (error) { logger().e("[GetJWZUseCase] Error: $error"); diff --git a/lib/iden3comm/domain/use_cases/get_proof_requests_use_case.dart b/lib/iden3comm/domain/use_cases/get_proof_requests_use_case.dart index 947d563b..126380c8 100644 --- a/lib/iden3comm/domain/use_cases/get_proof_requests_use_case.dart +++ b/lib/iden3comm/domain/use_cases/get_proof_requests_use_case.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/common/iden3_message_entity.dart'; @@ -37,11 +39,11 @@ class GetProofRequestsUseCase for (ProofScopeRequest scope in param.body.scope!) { var context = await _getProofQueryContextUseCase.execute(param: scope); _stacktraceManager.addTrace( - "[GetProofRequestsUseCase] _getProofQueryContextUseCase: $context"); + "[GetProofRequestsUseCase] _getProofQueryContextUseCase: ${jsonEncode(context)}"); ProofQueryParamEntity query = await _getProofQueryUseCase.execute(param: scope); _stacktraceManager.addTrace( - "[GetProofRequestsUseCase] _getProofQueryUseCase: $query"); + "[GetProofRequestsUseCase] _getProofQueryUseCase: ${jsonEncode(query.toJson())}"); proofRequests.add(ProofRequestEntity(scope, context, query)); } } diff --git a/lib/identity/data/dtos/circuit_type.dart b/lib/identity/data/dtos/circuit_type.dart new file mode 100644 index 00000000..3cb262a9 --- /dev/null +++ b/lib/identity/data/dtos/circuit_type.dart @@ -0,0 +1,17 @@ +enum CircuitType { + auth("authV2"), + mtp("credentialAtomicQueryMTPV2"), + sig("credentialAtomicQuerySigV2"), + mtponchain("credentialAtomicQueryMTPV2OnChain"), + sigonchain("credentialAtomicQuerySigV2OnChain"), + circuitsV3("credentialAtomicQueryV3$currentCircuitBetaPostfix"), + circuitsV3onchain("credentialAtomicQueryV3OnChain$currentCircuitBetaPostfix"), + unknown(""); + + static const v3CircuitPrefix = "credentialAtomicQueryV3"; + static const currentCircuitBetaPostfix = "-beta.0"; + + final String name; + + const CircuitType(this.name); +} diff --git a/lib/identity/data/dtos/hash_dto.dart b/lib/identity/data/dtos/hash_dto.dart index 937098c4..d2cda37b 100644 --- a/lib/identity/data/dtos/hash_dto.dart +++ b/lib/identity/data/dtos/hash_dto.dart @@ -83,6 +83,9 @@ class HashDTO extends Equatable { @override bool operator ==(Object other) { if (other is HashDTO) { + if (data.length != other.data.length) { + return false; + } for (int i = 0; i < data.length; i++) { if (data[i] != other.data[i]) { return false; diff --git a/lib/identity/domain/entities/hash_entity.dart b/lib/identity/domain/entities/hash_entity.dart index 37a58cb3..c7453353 100644 --- a/lib/identity/domain/entities/hash_entity.dart +++ b/lib/identity/domain/entities/hash_entity.dart @@ -15,4 +15,8 @@ class HashEntity { @override int get hashCode => runtimeType.hashCode; + + Map toJson() => { + 'data': data, + }; } diff --git a/lib/identity/domain/use_cases/get_identity_auth_claim_use_case.dart b/lib/identity/domain/use_cases/get_identity_auth_claim_use_case.dart index a9ba1020..bd076a33 100644 --- a/lib/identity/domain/use_cases/get_identity_auth_claim_use_case.dart +++ b/lib/identity/domain/use_cases/get_identity_auth_claim_use_case.dart @@ -23,8 +23,6 @@ class GetIdentityAuthClaimUseCase extends FutureUseCase> { .getPublicKeys(privateKey: param) .then((pubKeys) => _getAuthClaimUseCase.execute(param: pubKeys)) .then((authClaim) { - _stacktraceManager - .addTrace("[GetIdentityAuthClaimUseCase] AuthClaim is $authClaim"); logger().i("[GetIdentityAuthClaimUseCase] AuthClaim is $authClaim"); return authClaim; diff --git a/lib/identity/domain/use_cases/identity/get_identity_use_case.dart b/lib/identity/domain/use_cases/identity/get_identity_use_case.dart index b9be8d51..01201177 100644 --- a/lib/identity/domain/use_cases/identity/get_identity_use_case.dart +++ b/lib/identity/domain/use_cases/identity/get_identity_use_case.dart @@ -70,7 +70,8 @@ class GetIdentityUseCase } logger().i("[GetIdentityUseCase] Identity: $identity"); - _stacktraceManager.addTrace("[GetIdentityUseCase] Identity: $identity"); + _stacktraceManager.addTrace( + "[GetIdentityUseCase] Identity DID: ${identity.did}, public key: ${identity.publicKey}, profiles: ${identity.profiles}"); return identity; } catch (error) { diff --git a/lib/identity/domain/use_cases/identity/get_private_key_use_case.dart b/lib/identity/domain/use_cases/identity/get_private_key_use_case.dart index 8a28ad69..04f34007 100644 --- a/lib/identity/domain/use_cases/identity/get_private_key_use_case.dart +++ b/lib/identity/domain/use_cases/identity/get_private_key_use_case.dart @@ -17,9 +17,6 @@ class GetPrivateKeyUseCase extends FutureUseCase { @override Future execute({required String param}) async { return _identityRepository.getPrivateKey(secret: param).then((privateKey) { - logger().i("[GetPrivateKeyUseCase] private key: $privateKey"); - _stacktraceManager - .addTrace("[GetPrivateKeyUseCase] private key: $privateKey"); return privateKey; }).catchError((error) { logger().e("[GetPrivateKeyUseCase] Error: $error"); diff --git a/lib/proof/data/data_sources/circuits_download_data_source.dart b/lib/proof/data/data_sources/circuits_download_data_source.dart index 1291b8d4..44729175 100644 --- a/lib/proof/data/data_sources/circuits_download_data_source.dart +++ b/lib/proof/data/data_sources/circuits_download_data_source.dart @@ -2,9 +2,10 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:injectable/injectable.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/download_response_dto.dart'; -@lazySingleton +@injectable class CircuitsDownloadDataSource { final Dio _client; late CancelToken _cancelToken; @@ -22,17 +23,21 @@ class CircuitsDownloadDataSource { int get downloadSize => _downloadSize; /// - Future initStreamedResponseFromServer(String downloadPath) async { + Future initStreamedResponseFromServer({ + required List circuitsToDownload, + }) async { _cancelToken = CancelToken(); - const bucketUrl = - "https://circuits.polygonid.me/circuits/v1.0.0/polygonid-keys.zip"; // first we get the file size try { - Response headResponse = await _client.head(bucketUrl); - int contentLength = - int.parse(headResponse.headers.value('content-length') ?? "0"); - _downloadSize = contentLength; + int totalContentLength = 0; + for (CircuitsToDownloadParam param in circuitsToDownload) { + Response headResponse = await _client.head(param.bucketUrl); + int contentLength = + int.parse(headResponse.headers.value('content-length') ?? "0"); + totalContentLength += contentLength; + } + _downloadSize = totalContentLength; } catch (e) { _cancelToken.cancel(); _controller.add(DownloadResponseDTO( @@ -45,30 +50,32 @@ class CircuitsDownloadDataSource { } try { - await _client.download( - bucketUrl, - downloadPath, - deleteOnError: true, - cancelToken: _cancelToken, - onReceiveProgress: (received, total) { - if (total <= 0) { - _cancelToken.cancel(); - _controller.add(DownloadResponseDTO( - progress: 0, - total: 0, - errorOccurred: true, - errorMessage: "Error occurred while downloading circuits", - )); - return; - } - _controller.add( - DownloadResponseDTO( - progress: received, - total: total, - ), - ); - }, - ); + for (CircuitsToDownloadParam param in circuitsToDownload) { + await _client.download( + param.bucketUrl, + param.downloadPath, + deleteOnError: true, + cancelToken: _cancelToken, + onReceiveProgress: (received, total) { + if (total <= 0) { + _cancelToken.cancel(); + _controller.add(DownloadResponseDTO( + progress: 0, + total: 0, + errorOccurred: true, + errorMessage: "Error occurred while downloading circuits", + )); + return; + } + _controller.add( + DownloadResponseDTO( + progress: received, + total: total, + ), + ); + }, + ); + } } catch (e) { _cancelToken.cancel(); _controller.add(DownloadResponseDTO( diff --git a/lib/proof/data/data_sources/circuits_files_data_source.dart b/lib/proof/data/data_sources/circuits_files_data_source.dart index cd8e6867..f6a97177 100644 --- a/lib/proof/data/data_sources/circuits_files_data_source.dart +++ b/lib/proof/data/data_sources/circuits_files_data_source.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:archive/archive.dart'; +import 'package:polygonid_flutter_sdk/proof/domain/exceptions/proof_generation_exceptions.dart'; import 'package:polygonid_flutter_sdk/sdk/di/injector.dart'; class CircuitsFilesDataSource { @@ -12,39 +13,50 @@ class CircuitsFilesDataSource { Future> loadCircuitFiles(String circuitId) async { String path = directory.path; - var circuitDatFileName = '$circuitId.dat'; - var circuitDatFilePath = '$path/$circuitDatFileName'; - var circuitDatFile = File(circuitDatFilePath); - - var circuitZkeyFileName = '$circuitId.zkey'; - var circuitZkeyFilePath = '$path/$circuitZkeyFileName'; - var circuitZkeyFile = File(circuitZkeyFilePath); - - return [ - circuitDatFile.readAsBytesSync(), - circuitZkeyFile.readAsBytesSync() - ]; + try { + var circuitDatFileName = '$circuitId.dat'; + var circuitDatFilePath = '$path/$circuitDatFileName'; + var circuitDatFile = File(circuitDatFilePath); + + var circuitZkeyFileName = '$circuitId.zkey'; + var circuitZkeyFilePath = '$path/$circuitZkeyFileName'; + var circuitZkeyFile = File(circuitZkeyFilePath); + + return [ + circuitDatFile.readAsBytesSync(), + circuitZkeyFile.readAsBytesSync() + ]; + } on PathNotFoundException catch (error) { + throw CircuitNotDownloadedException( + circuit: circuitId, + errorMessage: error.message, + ); + } catch (_) { + rethrow; + } } /// - Future circuitsFilesExist() { - String fileName = 'circuits.zip'; + Future circuitsFilesExist({required String circuitsFileName}) async { + String fileName = '${circuitsFileName.trim()}.zip'; String path = directory.path; var file = File('$path/$fileName'); return file.exists(); } - Future getPathToCircuitZipFile() async { + Future getPathToCircuitZipFile( + {required String circuitsFileName}) async { String path = directory.path; - String fileName = 'circuits.zip'; + String fileName = '${circuitsFileName.trim()}.zip'; return '$path/$fileName'; } - Future getPathToCircuitZipFileTemp() async { + Future getPathToCircuitZipFileTemp( + {required String circuitsFileName}) async { String path = directory.path; - String fileName = 'circuits_temp.zip'; + String fileName = '${circuitsFileName.trim()}_temp.zip'; return '$path/$fileName'; } diff --git a/lib/proof/data/data_sources/lib_pidcore_proof_data_source.dart b/lib/proof/data/data_sources/lib_pidcore_proof_data_source.dart index 3377e56b..9b1bb1d4 100644 --- a/lib/proof/data/data_sources/lib_pidcore_proof_data_source.dart +++ b/lib/proof/data/data_sources/lib_pidcore_proof_data_source.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:injectable/injectable.dart'; import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; +import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_info_dto.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/atomic_query_inputs_config_param.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/atomic_query_inputs_param.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/gist_mtproof_dto.dart'; @@ -18,13 +20,22 @@ class ComputeAtomicQueryInputs { required this.param, required this.configParam, }); + + Map toJson() { + return { + "param": param.toJson(), + "configParam": configParam?.toJson(), + }; + } } @injectable class LibPolygonIdCoreWrapper { final PolygonIdCoreProof _polygonIdCoreProof; - LibPolygonIdCoreWrapper(this._polygonIdCoreProof); + LibPolygonIdCoreWrapper( + this._polygonIdCoreProof, + ); Future getProofInputs(AtomicQueryInputsParam atomicQueryInputsParam, AtomicQueryInputsConfigParam? atomicQueryInputsConfigParam) async { @@ -68,6 +79,16 @@ class LibPolygonIdCoreWrapper { jsonEncode(computeParam.param.toJson()), jsonEncode(computeParam.configParam?.toJson())); break; + case AtomicQueryInputsType.v3: + result = _polygonIdCoreProof.getV3ProofInputs( + jsonEncode(computeParam.param.toJson()), + jsonEncode(computeParam.configParam?.toJson())); + break; + case AtomicQueryInputsType.v3onchain: + result = _polygonIdCoreProof.getV3OnchainProofInputs( + jsonEncode(computeParam.param.toJson()), + jsonEncode(computeParam.configParam?.toJson())); + break; case AtomicQueryInputsType.unknown: throw NullAtomicQueryInputsException(computeParam.param.id); } @@ -90,9 +111,11 @@ class LibPolygonIdCoreWrapper { class LibPolygonIdCoreProofDataSource { final LibPolygonIdCoreWrapper _libPolygonIdCoreWrapper; + final StacktraceManager _stacktraceManager; LibPolygonIdCoreProofDataSource( this._libPolygonIdCoreWrapper, + this._stacktraceManager, ); String proofFromSC(String input) { @@ -163,39 +186,63 @@ class LibPolygonIdCoreProofDataSource { required Map request, required String circuitId, //ProofScopeRequest request, Map? config, + String? verifierId, + String? linkNonce, + Map? scopeParams, + Map? transactionData, }) { AtomicQueryInputsType type = AtomicQueryInputsType.unknown; - if (circuitId == "credentialAtomicQueryMTPV2") { + if (circuitId == CircuitType.mtp.name) { type = AtomicQueryInputsType.mtp; - } else if (circuitId == "credentialAtomicQueryMTPV2OnChain") { + } else if (circuitId == CircuitType.mtponchain.name) { type = AtomicQueryInputsType.mtponchain; - } else if (circuitId == "credentialAtomicQuerySigV2") { + } else if (circuitId == CircuitType.sig.name) { type = AtomicQueryInputsType.sig; - } else if (circuitId == "credentialAtomicQuerySigV2OnChain") { + } else if (circuitId == CircuitType.sigonchain.name) { type = AtomicQueryInputsType.sigonchain; + } else if (circuitId == CircuitType.circuitsV3.name) { + type = AtomicQueryInputsType.v3; + } else if (circuitId == CircuitType.circuitsV3onchain.name) { + type = AtomicQueryInputsType.v3onchain; } + final inputParam = AtomicQueryInputsParam( + type: type, + id: id, + profileNonce: profileNonce, + claimSubjectProfileNonce: claimSubjectProfileNonce, + authClaim: authClaim, + incProof: incProof, + nonRevProof: nonRevProof, + treeState: treeState, + gistProof: gistProof, + challenge: challenge, + signature: signature, + credential: credential, + request: request, + verifierId: verifierId, + linkNonce: linkNonce, + params: scopeParams, + transactionData: transactionData, + ); + + logger().i( + "[LibPolygonIdCoreProofDataSource][MainFlow]getProofInputs input param: ${jsonEncode(inputParam.toJson())}"); + _stacktraceManager.addTrace( + "[LibPolygonIdCoreProofDataSource][MainFlow]getProofInputs input param: ${jsonEncode(inputParam.toJson())}"); + AtomicQueryInputsConfigParam? configParam; if (config != null) { configParam = AtomicQueryInputsConfigParam.fromJson(config); + + logger().i( + "[LibPolygonIdCoreProofDataSource][MainFlow]getProofInputs config param: ${jsonEncode(inputParam.toJson())}"); + _stacktraceManager.addTrace( + "[LibPolygonIdCoreProofDataSource][MainFlow]getProofInputs config param: ${jsonEncode(inputParam.toJson())}"); } return _libPolygonIdCoreWrapper.getProofInputs( - AtomicQueryInputsParam( - type: type, - id: id, - profileNonce: profileNonce, - claimSubjectProfileNonce: claimSubjectProfileNonce, - authClaim: authClaim, - incProof: incProof, - nonRevProof: nonRevProof, - treeState: treeState, - gistProof: gistProof, - challenge: challenge, - signature: signature, - credential: credential, - request: request, - ), + inputParam, configParam, ); } diff --git a/lib/proof/data/data_sources/proof_circuit_data_source.dart b/lib/proof/data/data_sources/proof_circuit_data_source.dart index fab31930..1bdaadec 100644 --- a/lib/proof/data/data_sources/proof_circuit_data_source.dart +++ b/lib/proof/data/data_sources/proof_circuit_data_source.dart @@ -1,11 +1,13 @@ -import 'package:polygonid_flutter_sdk/proof/data/mappers/circuit_type_mapper.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; class ProofCircuitDataSource { static const List _supportedCircuits = [ CircuitType.mtp, CircuitType.sig, CircuitType.mtponchain, - CircuitType.sigonchain + CircuitType.sigonchain, + CircuitType.circuitsV3, + CircuitType.circuitsV3onchain, ]; Future isCircuitSupported({required CircuitType circuit}) { diff --git a/lib/proof/data/data_sources/witness_data_source.dart b/lib/proof/data/data_sources/witness_data_source.dart index 83c3710b..10a67310 100644 --- a/lib/proof/data/data_sources/witness_data_source.dart +++ b/lib/proof/data/data_sources/witness_data_source.dart @@ -1,8 +1,11 @@ import 'package:flutter/foundation.dart'; import 'package:injectable/injectable.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/witness_param.dart'; import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/mtp_v2/witness_mtp.dart'; import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/sig_v2/witness_sig.dart'; +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/v3/witness_v3.dart'; +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/v3_onchain/witness_v3_onchain.dart'; import '../../libs/witnesscalc/auth_v2/witness_auth.dart'; import '../../libs/witnesscalc/mtp_v2_onchain/witness_mtp_onchain.dart'; @@ -25,6 +28,12 @@ class WitnessIsolatesWrapper { Future computeWitnessSigOnchain(WitnessParam param) => compute(_computeWitnessSigOnchain, param); + + Future computeWitnessV3(WitnessParam param) => + compute(_computeWitnessV3, param); + + Future computeWitnessV3Onchain(WitnessParam param) => + compute(_computeWitnessV3Onchain, param); } /// As this is running in a separate thread, we cannot inject [WitnessAuthLib] @@ -69,6 +78,24 @@ Future _computeWitnessSigOnchain(WitnessParam param) async { return witnessBytes; } +Future _computeWitnessV3(WitnessParam param) async { + final WitnessV3Lib witnessLib = WitnessV3Lib(); + final Uint8List? witnessBytes = await witnessLib.calculateWitness( + param.wasm, + param.json, + ); + return witnessBytes; +} + +Future _computeWitnessV3Onchain(WitnessParam param) async { + final WitnessV3OnchainLib witnessLib = WitnessV3OnchainLib(); + final Uint8List? witnessBytes = await witnessLib.calculateWitness( + param.wasm, + param.json, + ); + return witnessBytes; +} + class WitnessDataSource { final WitnessIsolatesWrapper _witnessIsolatesWrapper; @@ -87,6 +114,10 @@ class WitnessDataSource { return _witnessIsolatesWrapper.computeWitnessMtpOnchain(param); case CircuitType.sigonchain: return _witnessIsolatesWrapper.computeWitnessSigOnchain(param); + case CircuitType.circuitsV3: + return _witnessIsolatesWrapper.computeWitnessV3(param); + case CircuitType.circuitsV3onchain: + return _witnessIsolatesWrapper.computeWitnessV3Onchain(param); default: return Future.value(null); } diff --git a/lib/proof/data/dtos/atomic_query_inputs_param.dart b/lib/proof/data/dtos/atomic_query_inputs_param.dart index d6c28f3c..054d8720 100644 --- a/lib/proof/data/dtos/atomic_query_inputs_param.dart +++ b/lib/proof/data/dtos/atomic_query_inputs_param.dart @@ -1,6 +1,15 @@ +import 'package:polygonid_flutter_sdk/common/utils/format_utils.dart'; import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_info_dto.dart'; -enum AtomicQueryInputsType { mtp, sig, mtponchain, sigonchain, unknown } +enum AtomicQueryInputsType { + mtp, + sig, + mtponchain, + sigonchain, + v3, + v3onchain, + unknown; +} class AtomicQueryInputsParam { final AtomicQueryInputsType type; @@ -17,6 +26,13 @@ class AtomicQueryInputsParam { final ClaimInfoDTO credential; final Map request; + final String? verifierId; + final String? linkNonce; + + final Map? params; + + final Map? transactionData; + AtomicQueryInputsParam({ required this.type, required this.id, @@ -31,21 +47,40 @@ class AtomicQueryInputsParam { this.signature, required this.credential, required this.request, + this.verifierId, + this.linkNonce, + this.params, + this.transactionData, }); - Map toJson() => { - "id": id, - "profileNonce": profileNonce.toString(), - "claimSubjectProfileNonce": claimSubjectProfileNonce.toString(), - "authClaim": authClaim, - "authClaimIncMtp": incProof, - "authClaimNonRevMtp": nonRevProof, - "gistProof": gistProof, - "treeState": treeState, - "challenge": challenge, - "signature": signature, - "verifiableCredentials": credential.toJson(), - "request": request, - }..removeWhere( - (dynamic key, dynamic value) => key == null || value == null); + Map toJson() { + Map inputs = { + "id": id, + "profileNonce": profileNonce.toString(), + "claimSubjectProfileNonce": claimSubjectProfileNonce.toString(), + "authClaim": authClaim, + "authClaimIncMtp": incProof, + "authClaimNonRevMtp": nonRevProof, + "gistProof": gistProof, + "treeState": treeState, + "challenge": challenge, + "signature": signature, + "verifiableCredentials": credential.toJson(), + "request": request, + "verifierId": verifierId, + "linkNonce": linkNonce, + "params": params, + }..removeWhere((dynamic key, dynamic value) => value == null); + + if (transactionData?.isNotEmpty ?? false) { + inputs['transactionData'] = + FormatUtils.convertSnakeCaseToCamelCase(transactionData!); + } + + if (verifierId?.isEmpty ?? true) { + inputs.remove('verifierId'); + } + + return inputs; + } } diff --git a/lib/proof/data/dtos/circuits_to_download_param.dart b/lib/proof/data/dtos/circuits_to_download_param.dart new file mode 100644 index 00000000..b695a2dc --- /dev/null +++ b/lib/proof/data/dtos/circuits_to_download_param.dart @@ -0,0 +1,47 @@ +import 'package:equatable/equatable.dart'; + +class CircuitsToDownloadParam extends Equatable { + final String circuitsName; + final String bucketUrl; + String? downloadPath; + + CircuitsToDownloadParam({ + required this.circuitsName, + required this.bucketUrl, + this.downloadPath, + }); + + @override + List get props => [circuitsName, bucketUrl]; + + @override + bool get stringify => true; + + CircuitsToDownloadParam copyWith({ + String? circuitsName, + String? bucketUrl, + String? downloadPath, + }) { + return CircuitsToDownloadParam( + circuitsName: circuitsName ?? this.circuitsName, + bucketUrl: bucketUrl ?? this.bucketUrl, + downloadPath: downloadPath ?? this.downloadPath, + ); + } + + Map toJson() { + return { + 'circuitsName': circuitsName, + 'bucketUrl': bucketUrl, + 'downloadPath': downloadPath, + }; + } + + factory CircuitsToDownloadParam.fromJson(Map map) { + return CircuitsToDownloadParam( + circuitsName: map['circuitsName'], + bucketUrl: map['bucketUrl'], + downloadPath: map['downloadPath'], + ); + } +} diff --git a/lib/proof/data/mappers/circuit_type_mapper.dart b/lib/proof/data/mappers/circuit_type_mapper.dart index 0a1ede3f..d9bb0a5a 100644 --- a/lib/proof/data/mappers/circuit_type_mapper.dart +++ b/lib/proof/data/mappers/circuit_type_mapper.dart @@ -1,28 +1,14 @@ import 'package:polygonid_flutter_sdk/common/mappers/to_mapper.dart'; - -enum CircuitType { auth, mtp, sig, mtponchain, sigonchain, unknown } +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; class CircuitTypeMapper extends ToMapper { @override CircuitType mapTo(String to) { - switch (to) { - case "authV2": - return CircuitType.auth; - - case "credentialAtomicQueryMTPV2": - return CircuitType.mtp; - - case "credentialAtomicQuerySigV2": - return CircuitType.sig; - - case "credentialAtomicQueryMTPV2OnChain": - return CircuitType.mtponchain; - - case "credentialAtomicQuerySigV2OnChain": - return CircuitType.sigonchain; - - default: - return CircuitType.unknown; + for (var e in CircuitType.values) { + if (e.name == to) { + return e; + } } + return CircuitType.unknown; } } diff --git a/lib/proof/data/repositories/proof_repository_impl.dart b/lib/proof/data/repositories/proof_repository_impl.dart index 0304609b..e2a5ed48 100644 --- a/lib/proof/data/repositories/proof_repository_impl.dart +++ b/lib/proof/data/repositories/proof_repository_impl.dart @@ -12,6 +12,7 @@ import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/auth_proof_mapper.d import 'package:polygonid_flutter_sdk/identity/data/data_sources/local_contract_files_data_source.dart'; import 'package:polygonid_flutter_sdk/identity/data/data_sources/remote_identity_data_source.dart'; import 'package:polygonid_flutter_sdk/identity/data/data_sources/rpc_data_source.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/identity/data/dtos/hash_dto.dart'; import 'package:polygonid_flutter_sdk/proof/data/data_sources/circuits_download_data_source.dart'; import 'package:polygonid_flutter_sdk/proof/data/data_sources/circuits_files_data_source.dart'; @@ -20,6 +21,7 @@ import 'package:polygonid_flutter_sdk/proof/data/data_sources/lib_pidcore_proof_ import 'package:polygonid_flutter_sdk/proof/data/data_sources/proof_circuit_data_source.dart'; import 'package:polygonid_flutter_sdk/proof/data/data_sources/prover_lib_data_source.dart'; import 'package:polygonid_flutter_sdk/proof/data/data_sources/witness_data_source.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/gist_mtproof_dto.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/node_aux_dto.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/mtproof_dto.dart'; @@ -87,21 +89,26 @@ class ProofRepositoryImpl extends ProofRepository { } @override - Future calculateAtomicQueryInputs( - {required String id, - required BigInt profileNonce, - required BigInt claimSubjectProfileNonce, - required ClaimEntity claim, - required Map proofScopeRequest, - required String circuitId, - MTProofEntity? incProof, - MTProofEntity? nonRevProof, - GistMTProofEntity? gistProof, - List? authClaim, - Map? treeState, - Map? config, - String? challenge, - String? signature}) async { + Future calculateAtomicQueryInputs({ + required String id, + required BigInt profileNonce, + required BigInt claimSubjectProfileNonce, + required ClaimEntity claim, + required Map proofScopeRequest, + required String circuitId, + MTProofEntity? incProof, + MTProofEntity? nonRevProof, + GistMTProofEntity? gistProof, + List? authClaim, + Map? treeState, + Map? config, + String? challenge, + String? signature, + String? verifierId, + String? linkNonce, + Map? scopeParams, + Map? transactionData, + }) async { ClaimDTO credentialDto = _claimMapper.mapTo(claim); Map? gistProofMap; if (gistProof != null) { @@ -150,6 +157,10 @@ class ProofRepositoryImpl extends ProofRepository { request: proofScopeRequest, circuitId: circuitId, config: config, + verifierId: verifierId, + linkNonce: linkNonce, + scopeParams: scopeParams, + transactionData: transactionData, ); } catch (e) { _stacktraceManager.addTrace( @@ -253,13 +264,8 @@ class ProofRepositoryImpl extends ProofRepository { } @override - Stream get circuitsDownloadInfoStream async* { - String pathForZipFileTemp = - await _circuitsFilesDataSource.getPathToCircuitZipFileTemp(); - String pathForZipFile = - await _circuitsFilesDataSource.getPathToCircuitZipFile(); - String pathForCircuits = await _circuitsFilesDataSource.getPath(); - + Stream circuitsDownloadInfoStream( + {required List circuitsToDownload}) async* { await for (final downloadResponse in _circuitsDownloadDataSource.downloadStream) { int progress = downloadResponse.progress; @@ -274,29 +280,49 @@ class ProofRepositoryImpl extends ProofRepository { if (downloadResponse.done) { final int downloadSize = _circuitsDownloadDataSource.downloadSize; - // we get the size of the temp zip file - int zipFileSize = _circuitsFilesDataSource.zipFileSize( - pathToFile: pathForZipFileTemp); + int totalZipFileSize = 0; + + for (CircuitsToDownloadParam param in circuitsToDownload) { + if (param.downloadPath == null) { + continue; + } + String pathForZipFileTemp = param.downloadPath!; + String pathForZipFile = await _circuitsFilesDataSource + .getPathToCircuitZipFile(circuitsFileName: param.circuitsName); + String pathForCircuits = await _circuitsFilesDataSource.getPath(); + + // we get the size of the temp zip file + int zipFileSize = _circuitsFilesDataSource.zipFileSize( + pathToFile: pathForZipFileTemp); + + totalZipFileSize += zipFileSize; + + await _completeWritingFile( + pathForCircuits: pathForCircuits, + pathForZipFile: pathForZipFile, + pathForZipFileTemp: pathForZipFileTemp, + ); + } - if (downloadSize != 0 && zipFileSize != downloadSize) { + if (downloadSize != 0 && totalZipFileSize != downloadSize) { try { // if error we delete the temp file - _circuitsFilesDataSource.deleteFile(pathForZipFileTemp); + for (CircuitsToDownloadParam param in circuitsToDownload) { + if (param.downloadPath == null) { + continue; + } + String pathForZipFileTemp = param.downloadPath!; + _circuitsFilesDataSource.deleteFile(pathForZipFileTemp); + } } catch (_) {} yield DownloadInfo.onError( errorMessage: "Downloaded files incorrect"); } - await _completeWritingFile( - pathForCircuits: pathForCircuits, - pathForZipFile: pathForZipFile, - pathForZipFileTemp: pathForZipFileTemp, - ); - yield DownloadInfo.onDone( contentLength: downloadSize, - downloaded: zipFileSize, + downloaded: totalZipFileSize, ); } @@ -309,20 +335,27 @@ class ProofRepositoryImpl extends ProofRepository { /// @override - Future initCircuitsDownloadFromServer() { - return _circuitsFilesDataSource.getPathToCircuitZipFileTemp().then( - (pathForZipFileTemp) => - // We delete eventual temp zip file downloaded before - _circuitsFilesDataSource.deleteFile(pathForZipFileTemp).then((_) => - // Init download - _circuitsDownloadDataSource - .initStreamedResponseFromServer(pathForZipFileTemp))); + Future initCircuitsDownloadFromServer({ + required List circuitsToDownload, + }) async { + for (int i = 0; i < circuitsToDownload.length; i++) { + CircuitsToDownloadParam param = circuitsToDownload[i]; + String path = await _circuitsFilesDataSource.getPathToCircuitZipFileTemp( + circuitsFileName: param.circuitsName); + // we delete the file if it exists + await _circuitsFilesDataSource.deleteFile(path); + circuitsToDownload[i].downloadPath = path; + } + return _circuitsDownloadDataSource.initStreamedResponseFromServer( + circuitsToDownload: circuitsToDownload, + ); } /// @override - Future circuitsFilesExist() { - return _circuitsFilesDataSource.circuitsFilesExist(); + Future circuitsFilesExist({required String circuitsFileName}) { + return _circuitsFilesDataSource.circuitsFilesExist( + circuitsFileName: circuitsFileName); } /// diff --git a/lib/proof/domain/entities/gist_mtproof_entity.dart b/lib/proof/domain/entities/gist_mtproof_entity.dart index 5451d1b8..92fdc0b6 100644 --- a/lib/proof/domain/entities/gist_mtproof_entity.dart +++ b/lib/proof/domain/entities/gist_mtproof_entity.dart @@ -19,4 +19,9 @@ class GistMTProofEntity { @override int get hashCode => runtimeType.hashCode; + + Map toJson() => { + 'root': root, + 'proof': proof.toJson(), + }; } diff --git a/lib/proof/domain/entities/mtproof_entity.dart b/lib/proof/domain/entities/mtproof_entity.dart index 379ea10a..715afa12 100644 --- a/lib/proof/domain/entities/mtproof_entity.dart +++ b/lib/proof/domain/entities/mtproof_entity.dart @@ -24,4 +24,10 @@ class MTProofEntity { @override int get hashCode => runtimeType.hashCode; + + Map toJson() => { + 'existence': existence, + 'siblings': siblings.map((e) => e.toJson()).toList(), + 'nodeAux': nodeAux?.toJson(), + }; } diff --git a/lib/proof/domain/entities/node_aux_entity.dart b/lib/proof/domain/entities/node_aux_entity.dart index 52346366..e3cc2fab 100644 --- a/lib/proof/domain/entities/node_aux_entity.dart +++ b/lib/proof/domain/entities/node_aux_entity.dart @@ -17,4 +17,9 @@ class NodeAuxEntity { @override int get hashCode => runtimeType.hashCode; + + Map toJson() => { + 'key': key, + 'value': value, + }; } diff --git a/lib/proof/domain/exceptions/proof_generation_exceptions.dart b/lib/proof/domain/exceptions/proof_generation_exceptions.dart index a54a1a13..6de00df5 100644 --- a/lib/proof/domain/exceptions/proof_generation_exceptions.dart +++ b/lib/proof/domain/exceptions/proof_generation_exceptions.dart @@ -35,5 +35,14 @@ class ProofInputsException implements Exception { final String? errorMessage; ProofInputsException(this.errorMessage); +} + +class CircuitNotDownloadedException implements Exception { + final String circuit; + final String errorMessage; + CircuitNotDownloadedException({ + required this.circuit, + required this.errorMessage, + }); } diff --git a/lib/proof/domain/repositories/proof_repository.dart b/lib/proof/domain/repositories/proof_repository.dart index f3f4c071..1bcb575e 100644 --- a/lib/proof/domain/repositories/proof_repository.dart +++ b/lib/proof/domain/repositories/proof_repository.dart @@ -2,6 +2,7 @@ import 'dart:typed_data'; import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/circuit_data_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/download_info_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/gist_mtproof_entity.dart'; @@ -28,6 +29,10 @@ abstract class ProofRepository { String? challenge, String? signature, Map? config, + String? verifierId, + String? linkNonce, + Map? scopeParams, + Map? transactionData, }); Future calculateWitness( @@ -41,11 +46,14 @@ abstract class ProofRepository { Future getGistProof( {required String idAsInt, required String contractAddress}); - Stream get circuitsDownloadInfoStream; + Stream circuitsDownloadInfoStream( + {required List circuitsToDownload}); - Future circuitsFilesExist(); + Future circuitsFilesExist({required String circuitsFileName}); - Future initCircuitsDownloadFromServer(); + Future initCircuitsDownloadFromServer({ + required List circuitsToDownload, + }); Future cancelDownloadCircuits(); } diff --git a/lib/proof/domain/use_cases/circuits_files_exist_use_case.dart b/lib/proof/domain/use_cases/circuits_files_exist_use_case.dart index d5881d0c..b176965b 100644 --- a/lib/proof/domain/use_cases/circuits_files_exist_use_case.dart +++ b/lib/proof/domain/use_cases/circuits_files_exist_use_case.dart @@ -2,14 +2,16 @@ import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; import 'package:polygonid_flutter_sdk/proof/domain/repositories/proof_repository.dart'; -class CircuitsFilesExistUseCase extends FutureUseCase { +class CircuitsFilesExistUseCase extends FutureUseCase { final ProofRepository _proofRepository; CircuitsFilesExistUseCase(this._proofRepository); @override - Future execute({void param}) { - return _proofRepository.circuitsFilesExist().then((value) { + Future execute({required String param}) { + return _proofRepository + .circuitsFilesExist(circuitsFileName: param) + .then((value) { logger().i("[CircuitsFilesExistUseCase] circuits files exist: $value"); return value; }); diff --git a/lib/proof/domain/use_cases/download_circuits_use_case.dart b/lib/proof/domain/use_cases/download_circuits_use_case.dart index cb651253..7910fa84 100644 --- a/lib/proof/domain/use_cases/download_circuits_use_case.dart +++ b/lib/proof/domain/use_cases/download_circuits_use_case.dart @@ -1,10 +1,12 @@ import 'dart:async'; import 'package:polygonid_flutter_sdk/common/domain/use_case.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/download_info_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/repositories/proof_repository.dart'; -class DownloadCircuitsUseCase extends StreamUseCase { +class DownloadCircuitsUseCase + extends StreamUseCase { final ProofRepository _proofRepository; DownloadCircuitsUseCase( @@ -12,16 +14,34 @@ class DownloadCircuitsUseCase extends StreamUseCase { ); @override - Stream execute({void param}) async* { - yield* await _proofRepository.circuitsFilesExist().then((exist) { - if (exist) { - return Stream.value( - DownloadInfo.onDone(contentLength: 0, downloaded: 0)); + Stream execute({required DownloadCircuitsParam param}) async* { + final missingCircuits = []; + for (final circuit in param.circuitsToDownload) { + final exist = await _proofRepository.circuitsFilesExist( + circuitsFileName: circuit.circuitsName, + ); + if (!exist) { + missingCircuits.add(circuit); } + } - _proofRepository.initCircuitsDownloadFromServer(); + if (missingCircuits.isEmpty) { + yield* Stream.value(DownloadInfo.onDone(contentLength: 0, downloaded: 0)); + return; + } - return _proofRepository.circuitsDownloadInfoStream; - }); + // intentionally not awaited + _proofRepository.initCircuitsDownloadFromServer( + circuitsToDownload: missingCircuits, + ); + yield* _proofRepository.circuitsDownloadInfoStream( + circuitsToDownload: missingCircuits, + ); } } + +class DownloadCircuitsParam { + List circuitsToDownload; + + DownloadCircuitsParam({required this.circuitsToDownload}); +} diff --git a/lib/proof/domain/use_cases/generate_zkproof_use_case.dart b/lib/proof/domain/use_cases/generate_zkproof_use_case.dart index b616e0ba..7376aa1f 100644 --- a/lib/proof/domain/use_cases/generate_zkproof_use_case.dart +++ b/lib/proof/domain/use_cases/generate_zkproof_use_case.dart @@ -46,6 +46,11 @@ class GenerateZKProofParam { final Map proofScopeRequest; final Map? config; + final String? verifierId; + final String? linkNonce; + + final Map? transactionData; + GenerateZKProofParam( this.identifier, this.profileNonce, @@ -61,6 +66,9 @@ class GenerateZKProofParam { this.signature, this.proofScopeRequest, this.config, + this.verifierId, + this.linkNonce, + this.transactionData, ); } @@ -95,6 +103,12 @@ class GenerateZKProofUseCase proofScopeRequest: param.proofScopeRequest, circuitId: param.circuitData.circuitId, config: param.config, + verifierId: param.verifierId, + linkNonce: param.linkNonce, + scopeParams: param.proofScopeRequest.containsKey('params') + ? param.proofScopeRequest['params'] + : null, + transactionData: param.transactionData, ) .catchError((error) { logger().e("[GenerateZKProofUseCase] Error: $error"); diff --git a/lib/proof/domain/use_cases/prove_use_case.dart b/lib/proof/domain/use_cases/prove_use_case.dart index 095a6985..4fd56dc6 100644 --- a/lib/proof/domain/use_cases/prove_use_case.dart +++ b/lib/proof/domain/use_cases/prove_use_case.dart @@ -32,6 +32,8 @@ class ProveUseCase extends FutureUseCase { param.inputs, ); + Stopwatch stopwatch = Stopwatch()..start(); + // Generate proof ZKProofEntity zkProofEntity = await _proofRepository.prove( param.circuitData, @@ -39,6 +41,8 @@ class ProveUseCase extends FutureUseCase { ); _stacktraceManager.addTrace("[ProveUseCase] proof"); + _stacktraceManager.addTrace( + "[ProveUseCase][MainFlow] proof generated in ${stopwatch.elapsedMilliseconds} ms"); logger().i("[ProveUseCase] proof: $zkProofEntity"); return zkProofEntity; diff --git a/lib/proof/libs/polygonidcore/pidcore_proof.dart b/lib/proof/libs/polygonidcore/pidcore_proof.dart index 16567e1f..e10d0c61 100644 --- a/lib/proof/libs/polygonidcore/pidcore_proof.dart +++ b/lib/proof/libs/polygonidcore/pidcore_proof.dart @@ -145,4 +145,60 @@ class PolygonIdCoreProof extends PolygonIdCore { return result; } + + String getV3ProofInputs(String input, String? config) { + ffi.Pointer in1 = input.toNativeUtf8().cast(); + ffi.Pointer cfg = ffi.nullptr; + if (config != null) { + cfg = config.toNativeUtf8().cast(); + } + ffi.Pointer> response = + malloc>(); + ffi.Pointer> status = + malloc>(); + int res = PolygonIdCore.nativePolygonIdCoreLib + .PLGNAtomicQueryV3Inputs(response, in1, cfg, status); + if (res == 0) { + String? consumedStatus = consumeStatus(status, ""); + if (consumedStatus != null) { + throw ProofInputsException(consumedStatus); + } + } + String result = ""; + ffi.Pointer jsonResponse = response.value; + ffi.Pointer jsonString = jsonResponse.cast(); + if (jsonString != ffi.nullptr) { + result = jsonString.toDartString(); + } + + return result; + } + + String getV3OnchainProofInputs(String input, String? config) { + ffi.Pointer in1 = input.toNativeUtf8().cast(); + ffi.Pointer cfg = ffi.nullptr; + if (config != null) { + cfg = config.toNativeUtf8().cast(); + } + ffi.Pointer> response = + malloc>(); + ffi.Pointer> status = + malloc>(); + int res = PolygonIdCore.nativePolygonIdCoreLib + .PLGNAtomicQueryV3OnChainInputs(response, in1, cfg, status); + if (res == 0) { + String? consumedStatus = consumeStatus(status, ""); + if (consumedStatus != null) { + throw ProofInputsException(consumedStatus); + } + } + String result = ""; + ffi.Pointer jsonResponse = response.value; + ffi.Pointer jsonString = jsonResponse.cast(); + if (jsonString != ffi.nullptr) { + result = jsonString.toDartString(); + } + + return result; + } } diff --git a/lib/proof/libs/witnesscalc/v3/native_witness_v3.dart b/lib/proof/libs/witnesscalc/v3/native_witness_v3.dart new file mode 100644 index 00000000..dda5e757 --- /dev/null +++ b/lib/proof/libs/witnesscalc/v3/native_witness_v3.dart @@ -0,0 +1,82 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint +import 'dart:ffi' as ffi; + +/// Bindings to `ios/Classes/witnesscalc_credentialAtomicQueryV3.h`. +class NativeWitnessV3Lib { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + NativeWitnessV3Lib(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + NativeWitnessV3Lib.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + /// @return error code: + /// WITNESSCALC_OK - in case of success. + /// WITNESSCALC_ERROR - in case of an error. + /// + /// On success wtns_buffer is filled with witness data and + /// wtns_size contains the number bytes copied to wtns_buffer. + /// + /// If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + /// and the minimum size for wtns_buffer in wtns_size. + int witnesscalc_credentialAtomicQueryV3( + ffi.Pointer circuit_buffer, + int circuit_size, + ffi.Pointer json_buffer, + int json_size, + ffi.Pointer wtns_buffer, + ffi.Pointer wtns_size, + ffi.Pointer error_msg, + int error_msg_maxsize, + ) { + return _witnesscalc_credentialAtomicQueryV3( + circuit_buffer, + circuit_size, + json_buffer, + json_size, + wtns_buffer, + wtns_size, + error_msg, + error_msg_maxsize, + ); + } + + late final _witnesscalc_credentialAtomicQueryV3Ptr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('witnesscalc_credentialAtomicQueryV3'); + late final _witnesscalc_credentialAtomicQueryV3 = + _witnesscalc_credentialAtomicQueryV3Ptr.asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int)>(); +} + +const int WITNESSCALC_OK = 0; + +const int WITNESSCALC_ERROR = 1; + +const int WITNESSCALC_ERROR_SHORT_BUFFER = 2; diff --git a/lib/proof/libs/witnesscalc/v3/witness_v3.dart b/lib/proof/libs/witnesscalc/v3/witness_v3.dart new file mode 100644 index 00000000..12bdcd3b --- /dev/null +++ b/lib/proof/libs/witnesscalc/v3/witness_v3.dart @@ -0,0 +1,75 @@ +import 'dart:ffi' as ffi; +import 'dart:ffi'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; +import 'package:injectable/injectable.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; + +import 'native_witness_v3.dart'; + +@injectable +class WitnessV3Lib { + static NativeWitnessV3Lib get _nativeWitnessV3Lib { + return Platform.isAndroid + ? NativeWitnessV3Lib(ffi.DynamicLibrary.open( + "libwitnesscalc_credentialAtomicQueryV3.so")) + : NativeWitnessV3Lib(ffi.DynamicLibrary.process()); + } + + WitnessV3Lib(); + + Future calculateWitness( + Uint8List wasmBytes, Uint8List inputsJsonBytes) async { + int circuitSize = wasmBytes.length; + ffi.Pointer circuitBuffer = malloc(circuitSize); + final data = wasmBytes; + for (int i = 0; i < circuitSize; i++) { + circuitBuffer[i] = data[i]; + } + + int jsonSize = inputsJsonBytes.length; + ffi.Pointer jsonBuffer = malloc(jsonSize); + final data2 = inputsJsonBytes; + for (int i = 0; i < jsonSize; i++) { + jsonBuffer[i] = data2[i]; + } + + ffi.Pointer wtnsSize = malloc(); + wtnsSize.value = 4 * 1024 * 1024; + ffi.Pointer wtnsBuffer = malloc(wtnsSize.value); + + int errorMaxSize = 256; + ffi.Pointer errorMsg = malloc(errorMaxSize); + + int result = _nativeWitnessV3Lib.witnesscalc_credentialAtomicQueryV3( + circuitBuffer, + circuitSize, + jsonBuffer, + jsonSize, + wtnsBuffer, + wtnsSize, + errorMsg, + errorMaxSize, + ); + + if (result == WITNESSCALC_OK) { + Uint8List wtnsBytes = Uint8List(wtnsSize.value); + for (int i = 0; i < wtnsSize.value; i++) { + wtnsBytes[i] = wtnsBuffer[i]; + } + return wtnsBytes; + } else if (result == WITNESSCALC_ERROR) { + ffi.Pointer jsonString = errorMsg.cast(); + String errormsg = jsonString.toDartString(); + + logger().e("$result: ${result.toString()}. Error: $errormsg"); + } else if (result == WITNESSCALC_ERROR_SHORT_BUFFER) { + logger().e( + "$result: ${result.toString()}. Error: Short buffer for proof or public"); + } + return null; + } +} diff --git a/lib/proof/libs/witnesscalc/v3_onchain/native_witness_v3_onchain.dart b/lib/proof/libs/witnesscalc/v3_onchain/native_witness_v3_onchain.dart new file mode 100644 index 00000000..fe568c9e --- /dev/null +++ b/lib/proof/libs/witnesscalc/v3_onchain/native_witness_v3_onchain.dart @@ -0,0 +1,82 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint +import 'dart:ffi' as ffi; + +/// Bindings to `ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h`. +class NativeWitnessV3OnchainLib { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + NativeWitnessV3OnchainLib(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + NativeWitnessV3OnchainLib.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + /// @return error code: + /// WITNESSCALC_OK - in case of success. + /// WITNESSCALC_ERROR - in case of an error. + /// + /// On success wtns_buffer is filled with witness data and + /// wtns_size contains the number bytes copied to wtns_buffer. + /// + /// If wtns_buffer is too small then the function returns WITNESSCALC_ERROR_SHORT_BUFFER + /// and the minimum size for wtns_buffer in wtns_size. + int witnesscalc_credentialAtomicQueryV3OnChain( + ffi.Pointer circuit_buffer, + int circuit_size, + ffi.Pointer json_buffer, + int json_size, + ffi.Pointer wtns_buffer, + ffi.Pointer wtns_size, + ffi.Pointer error_msg, + int error_msg_maxsize, + ) { + return _witnesscalc_credentialAtomicQueryV3OnChain( + circuit_buffer, + circuit_size, + json_buffer, + json_size, + wtns_buffer, + wtns_size, + error_msg, + error_msg_maxsize, + ); + } + + late final _witnesscalc_credentialAtomicQueryV3OnChainPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>('witnesscalc_credentialAtomicQueryV3OnChain'); + late final _witnesscalc_credentialAtomicQueryV3OnChain = + _witnesscalc_credentialAtomicQueryV3OnChainPtr.asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int)>(); +} + +const int WITNESSCALC_OK = 0; + +const int WITNESSCALC_ERROR = 1; + +const int WITNESSCALC_ERROR_SHORT_BUFFER = 2; diff --git a/lib/proof/libs/witnesscalc/v3_onchain/witness_v3_onchain.dart b/lib/proof/libs/witnesscalc/v3_onchain/witness_v3_onchain.dart new file mode 100644 index 00000000..551259dd --- /dev/null +++ b/lib/proof/libs/witnesscalc/v3_onchain/witness_v3_onchain.dart @@ -0,0 +1,76 @@ +import 'dart:ffi' as ffi; +import 'dart:ffi'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; +import 'package:injectable/injectable.dart'; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart'; + +import 'native_witness_v3_onchain.dart'; + +@injectable +class WitnessV3OnchainLib { + static NativeWitnessV3OnchainLib get _nativeWitnessV3OnchainLib { + return Platform.isAndroid + ? NativeWitnessV3OnchainLib(ffi.DynamicLibrary.open( + "libwitnesscalc_credentialAtomicQueryV3OnChain.so")) + : NativeWitnessV3OnchainLib(ffi.DynamicLibrary.process()); + } + + WitnessV3OnchainLib(); + + Future calculateWitness( + Uint8List wasmBytes, Uint8List inputsJsonBytes) async { + int circuitSize = wasmBytes.length; + ffi.Pointer circuitBuffer = malloc(circuitSize); + final data = wasmBytes; + for (int i = 0; i < circuitSize; i++) { + circuitBuffer[i] = data[i]; + } + + int jsonSize = inputsJsonBytes.length; + ffi.Pointer jsonBuffer = malloc(jsonSize); + final data2 = inputsJsonBytes; + for (int i = 0; i < jsonSize; i++) { + jsonBuffer[i] = data2[i]; + } + + ffi.Pointer wtnsSize = malloc(); + wtnsSize.value = 4 * 1024 * 1024; + ffi.Pointer wtnsBuffer = malloc(wtnsSize.value); + + int errorMaxSize = 256; + ffi.Pointer errorMsg = malloc(errorMaxSize); + + int result = + _nativeWitnessV3OnchainLib.witnesscalc_credentialAtomicQueryV3OnChain( + circuitBuffer, + circuitSize, + jsonBuffer, + jsonSize, + wtnsBuffer, + wtnsSize, + errorMsg, + errorMaxSize, + ); + + if (result == WITNESSCALC_OK) { + Uint8List wtnsBytes = Uint8List(wtnsSize.value); + for (int i = 0; i < wtnsSize.value; i++) { + wtnsBytes[i] = wtnsBuffer[i]; + } + return wtnsBytes; + } else if (result == WITNESSCALC_ERROR) { + ffi.Pointer jsonString = errorMsg.cast(); + String errormsg = jsonString.toDartString(); + + logger().e("$result: ${result.toString()}. Error: $errormsg"); + } else if (result == WITNESSCALC_ERROR_SHORT_BUFFER) { + logger().e( + "$result: ${result.toString()}. Error: Short buffer for proof or public"); + } + return null; + } +} diff --git a/lib/sdk/credential.dart b/lib/sdk/credential.dart index fe8f121e..5e24c0f4 100644 --- a/lib/sdk/credential.dart +++ b/lib/sdk/credential.dart @@ -6,6 +6,9 @@ import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.da import 'package:polygonid_flutter_sdk/credential/domain/exceptions/credential_exceptions.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claim_revocation_status_use_case.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_credential_by_id_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_credential_by_partial_id_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/refresh_credential_use_case.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/update_claim_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exceptions.dart'; @@ -27,6 +30,18 @@ abstract class PolygonIdSdkCredential { required String genesisDid, required String privateKey}); + Future? getCredentialById({ + required String credentialId, + required String genesisDid, + required String privateKey, + }); + + Future? getCredentialByPartialId({ + required String partialCredentialId, + required String genesisDid, + required String privateKey, + }); + /// Get a list of [ClaimEntity] associated to the identity previously stored /// in the the Polygon ID Sdk. /// @@ -109,6 +124,12 @@ abstract class PolygonIdSdkCredential { String? type, Map? data, }); + + Future refreshCredential({ + required String genesisDid, + required String privateKey, + required ClaimEntity credential, + }); } @injectable @@ -119,6 +140,10 @@ class Credential implements PolygonIdSdkCredential { final RemoveClaimsUseCase _removeClaimsUseCase; final UpdateClaimUseCase _updateClaimUseCase; final StacktraceManager _stacktraceManager; + final RefreshCredentialUseCase _refreshCredentialUseCase; + final GetCredentialByIdUseCase _getCredentialByIdUseCase; + + final GetCredentialByPartialIdUseCase _getCredentialByPartialIdUseCase; Credential( this._saveClaimsUseCase, @@ -127,6 +152,9 @@ class Credential implements PolygonIdSdkCredential { this._getClaimRevocationStatusUseCase, this._updateClaimUseCase, this._stacktraceManager, + this._refreshCredentialUseCase, + this._getCredentialByIdUseCase, + this._getCredentialByPartialIdUseCase, ); @override @@ -141,6 +169,40 @@ class Credential implements PolygonIdSdkCredential { claims: claims, genesisDid: genesisDid, privateKey: privateKey)); } + @override + Future getCredentialById({ + required String credentialId, + required String genesisDid, + required String privateKey, + }) { + _stacktraceManager.clear(); + _stacktraceManager + .addTrace("PolygonIdSdk.Credential.getCredentialById called"); + return _getCredentialByIdUseCase.execute( + param: GetCredentialByIdParam( + genesisDid: genesisDid, + privateKey: privateKey, + id: credentialId, + )); + } + + @override + Future getCredentialByPartialId({ + required String partialCredentialId, + required String genesisDid, + required String privateKey, + }) { + _stacktraceManager.clear(); + _stacktraceManager + .addTrace("PolygonIdSdk.Credential.getCredentialByPartialId called"); + return _getCredentialByPartialIdUseCase.execute( + param: GetCredentialByPartialIdParam( + genesisDid: genesisDid, + privateKey: privateKey, + partialId: partialCredentialId, + )); + } + @override Future> getClaims( {List? filters, @@ -256,4 +318,18 @@ class Credential implements PolygonIdSdkCredential { data: data, privateKey: privateKey)); } + + @override + Future refreshCredential({ + required String genesisDid, + required String privateKey, + required ClaimEntity credential, + }) { + return _refreshCredentialUseCase.execute( + param: RefreshCredentialParam( + credential: credential, + genesisDid: genesisDid, + privateKey: privateKey, + )); + } } diff --git a/lib/sdk/di/injector.config.dart b/lib/sdk/di/injector.config.dart index 60ad8cb1..33a01bc4 100644 --- a/lib/sdk/di/injector.config.dart +++ b/lib/sdk/di/injector.config.dart @@ -11,397 +11,413 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:io' as _i16; -import 'package:archive/archive.dart' as _i79; +import 'package:archive/archive.dart' as _i82; import 'package:dio/dio.dart' as _i15; -import 'package:encrypt/encrypt.dart' as _i17; +import 'package:encrypt/encrypt.dart' as _i18; import 'package:flutter/services.dart' as _i3; import 'package:get_it/get_it.dart' as _i1; import 'package:http/http.dart' as _i11; import 'package:injectable/injectable.dart' as _i2; -import 'package:logger/logger.dart' as _i38; -import 'package:package_info_plus/package_info_plus.dart' as _i43; +import 'package:logger/logger.dart' as _i39; +import 'package:package_info_plus/package_info_plus.dart' as _i44; import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/env_mapper.dart' - as _i20; -import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filter_mapper.dart' as _i21; -import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filters_mapper.dart' +import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filter_mapper.dart' as _i22; +import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filters_mapper.dart' + as _i23; import 'package:polygonid_flutter_sdk/common/data/data_sources/package_info_datasource.dart' - as _i44; + as _i45; import 'package:polygonid_flutter_sdk/common/data/data_sources/storage_key_value_data_source.dart' - as _i92; + as _i95; import 'package:polygonid_flutter_sdk/common/data/repositories/config_repository_impl.dart' - as _i108; + as _i112; import 'package:polygonid_flutter_sdk/common/data/repositories/package_info_repository_impl.dart' - as _i45; -import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart' as _i52; + as _i46; +import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart' as _i53; import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart' - as _i70; + as _i71; import 'package:polygonid_flutter_sdk/common/domain/repositories/config_repository.dart' - as _i118; + as _i122; import 'package:polygonid_flutter_sdk/common/domain/repositories/package_info_repository.dart' - as _i100; + as _i103; import 'package:polygonid_flutter_sdk/common/domain/use_cases/get_env_use_case.dart' - as _i125; + as _i131; import 'package:polygonid_flutter_sdk/common/domain/use_cases/get_package_name_use_case.dart' - as _i111; + as _i115; import 'package:polygonid_flutter_sdk/common/domain/use_cases/set_env_use_case.dart' - as _i136; + as _i142; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart' - as _i64; + as _i65; import 'package:polygonid_flutter_sdk/common/libs/polygonidcore/pidcore_base.dart' - as _i46; + as _i47; import 'package:polygonid_flutter_sdk/credential/data/credential_repository_impl.dart' - as _i109; + as _i113; +import 'package:polygonid_flutter_sdk/credential/data/data_sources/cache_claim_data_source.dart' + as _i111; import 'package:polygonid_flutter_sdk/credential/data/data_sources/lib_pidcore_credential_data_source.dart' - as _i93; + as _i96; import 'package:polygonid_flutter_sdk/credential/data/data_sources/local_claim_data_source.dart' - as _i97; + as _i100; import 'package:polygonid_flutter_sdk/credential/data/data_sources/remote_claim_data_source.dart' - as _i102; + as _i105; import 'package:polygonid_flutter_sdk/credential/data/data_sources/storage_claim_data_source.dart' - as _i84; + as _i87; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_info_mapper.dart' as _i9; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_mapper.dart' - as _i83; + as _i86; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_state_mapper.dart' as _i10; +import 'package:polygonid_flutter_sdk/credential/data/mappers/display_type_mapper.dart' + as _i17; import 'package:polygonid_flutter_sdk/credential/data/mappers/id_filter_mapper.dart' - as _i28; + as _i29; import 'package:polygonid_flutter_sdk/credential/data/mappers/revocation_status_mapper.dart' - as _i62; + as _i63; import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart' - as _i119; + as _i123; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/add_did_profile_info_use_case.dart' - as _i138; + as _i144; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/cache_credential_use_case.dart' + as _i145; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/generate_non_rev_proof_use_case.dart' - as _i169; + as _i176; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_auth_claim_use_case.dart' - as _i121; + as _i125; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claim_revocation_nonce_use_case.dart' - as _i122; + as _i126; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claim_revocation_status_use_case.dart' - as _i173; + as _i180; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claims_use_case.dart' - as _i191; + as _i199; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_credential_by_id_use_case.dart' + as _i127; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_credential_by_partial_id_use_case.dart' + as _i128; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_did_profile_info_list_use_case.dart' - as _i123; + as _i129; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_did_profile_info_use_case.dart' - as _i124; + as _i130; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_non_rev_proof_use_case.dart' - as _i172; + as _i179; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/refresh_credential_use_case.dart' + as _i192; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_all_claims_use_case.dart' - as _i131; + as _i137; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_claims_use_case.dart' - as _i132; + as _i138; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_did_profile_info_use_case.dart' - as _i133; + as _i139; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_use_case.dart' - as _i135; + as _i141; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/update_claim_use_case.dart' - as _i137; + as _i143; import 'package:polygonid_flutter_sdk/credential/libs/polygonidcore/pidcore_credential.dart' - as _i47; + as _i48; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/iden3_message_data_source.dart' - as _i29; + as _i30; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/lib_pidcore_iden3comm_data_source.dart' - as _i94; + as _i97; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/remote_iden3comm_data_source.dart' - as _i103; + as _i106; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/secure_storage_did_profile_info_data_source.dart' - as _i105; + as _i108; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/secure_storage_interaction_data_source.dart' - as _i106; + as _i109; import 'package:polygonid_flutter_sdk/iden3comm/data/data_sources/storage_interaction_data_source.dart' - as _i91; + as _i94; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/auth_inputs_mapper.dart' as _i4; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/auth_proof_mapper.dart' - as _i80; + as _i83; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/auth_response_mapper.dart' as _i5; -import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/didProfileInfoInteractedDidFilterMapper.dart' +import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/did_profile_info_interacted_did_filter_mapper.dart' as _i14; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/iden3_message_type_mapper.dart' - as _i30; + as _i31; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/iden3comm_proof_mapper.dart' - as _i88; + as _i91; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/iden3comm_vp_proof_mapper.dart' - as _i31; + as _i32; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/interaction_id_filter_mapper.dart' - as _i33; -import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/interaction_mapper.dart' as _i34; -import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/jwz_mapper.dart' +import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/interaction_mapper.dart' as _i35; +import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/jwz_mapper.dart' + as _i36; import 'package:polygonid_flutter_sdk/iden3comm/data/mappers/proof_request_filters_mapper.dart' - as _i57; + as _i58; import 'package:polygonid_flutter_sdk/iden3comm/data/repositories/did_profile_info_repository_impl.dart' - as _i110; + as _i114; import 'package:polygonid_flutter_sdk/iden3comm/data/repositories/iden3comm_credential_repository_impl.dart' - as _i113; + as _i117; import 'package:polygonid_flutter_sdk/iden3comm/data/repositories/iden3comm_repository_impl.dart' - as _i114; + as _i118; import 'package:polygonid_flutter_sdk/iden3comm/data/repositories/interaction_repository_impl.dart' - as _i115; + as _i119; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/did_profile_info_repository.dart' - as _i120; + as _i124; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart' - as _i126; + as _i132; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_repository.dart' - as _i127; + as _i133; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/interaction_repository.dart' - as _i128; + as _i134; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/authenticate_use_case.dart' - as _i199; + as _i207; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/check_profile_and_did_current_env.dart' - as _i179; + as _i186; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/clean_schema_cache_use_case.dart' - as _i139; + as _i146; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/fetch_and_save_claims_use_case.dart' - as _i190; + as _i198; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart' - as _i180; + as _i187; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_challenge_use_case.dart' - as _i140; + as _i147; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_inputs_use_case.dart' - as _i181; + as _i188; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_token_use_case.dart' - as _i182; + as _i189; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_fetch_requests_use_case.dart' - as _i23; + as _i24; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_filters_use_case.dart' - as _i170; + as _i177; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_claims_rev_nonce_use_case.dart' - as _i192; + as _i200; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart' - as _i193; + as _i201; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart' - as _i194; + as _i202; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3message_type_use_case.dart' - as _i24; + as _i25; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3message_use_case.dart' - as _i86; + as _i89; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_jwz_use_case.dart' - as _i141; + as _i148; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_query_context_use_case.dart' - as _i143; + as _i150; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_query_use_case.dart' - as _i87; + as _i90; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_requests_use_case.dart' - as _i144; + as _i151; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_schemas_use_case.dart' - as _i145; + as _i152; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/interaction/add_interaction_use_case.dart' - as _i178; + as _i185; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/interaction/get_interactions_use_case.dart' - as _i176; + as _i183; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/interaction/remove_interactions_use_case.dart' - as _i177; + as _i184; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/interaction/update_interaction_use_case.dart' - as _i185; + as _i193; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/listen_and_store_notification_use_case.dart' - as _i129; + as _i135; import 'package:polygonid_flutter_sdk/iden3comm/libs/polygonidcore/pidcore_iden3comm.dart' - as _i48; + as _i49; import 'package:polygonid_flutter_sdk/identity/data/data_sources/db_destination_path_data_source.dart' as _i12; import 'package:polygonid_flutter_sdk/identity/data/data_sources/encryption_db_data_source.dart' - as _i18; + as _i19; import 'package:polygonid_flutter_sdk/identity/data/data_sources/lib_babyjubjub_data_source.dart' - as _i36; + as _i37; import 'package:polygonid_flutter_sdk/identity/data/data_sources/lib_pidcore_identity_data_source.dart' - as _i95; + as _i98; import 'package:polygonid_flutter_sdk/identity/data/data_sources/local_contract_files_data_source.dart' - as _i37; + as _i38; import 'package:polygonid_flutter_sdk/identity/data/data_sources/remote_identity_data_source.dart' - as _i61; + as _i62; import 'package:polygonid_flutter_sdk/identity/data/data_sources/rpc_data_source.dart' - as _i130; + as _i136; import 'package:polygonid_flutter_sdk/identity/data/data_sources/secure_storage_profiles_data_source.dart' - as _i107; + as _i110; import 'package:polygonid_flutter_sdk/identity/data/data_sources/smt_data_source.dart' - as _i116; + as _i120; import 'package:polygonid_flutter_sdk/identity/data/data_sources/storage_identity_data_source.dart' - as _i90; + as _i93; import 'package:polygonid_flutter_sdk/identity/data/data_sources/storage_smt_data_source.dart' - as _i89; + as _i92; import 'package:polygonid_flutter_sdk/identity/data/data_sources/wallet_data_source.dart' - as _i68; + as _i69; import 'package:polygonid_flutter_sdk/identity/data/mappers/encryption_key_mapper.dart' - as _i19; + as _i20; import 'package:polygonid_flutter_sdk/identity/data/mappers/hash_mapper.dart' - as _i26; -import 'package:polygonid_flutter_sdk/identity/data/mappers/hex_mapper.dart' as _i27; +import 'package:polygonid_flutter_sdk/identity/data/mappers/hex_mapper.dart' + as _i28; import 'package:polygonid_flutter_sdk/identity/data/mappers/identity_dto_mapper.dart' - as _i32; + as _i33; import 'package:polygonid_flutter_sdk/identity/data/mappers/node_mapper.dart' - as _i99; + as _i102; import 'package:polygonid_flutter_sdk/identity/data/mappers/node_type_dto_mapper.dart' - as _i40; -import 'package:polygonid_flutter_sdk/identity/data/mappers/node_type_entity_mapper.dart' as _i41; -import 'package:polygonid_flutter_sdk/identity/data/mappers/node_type_mapper.dart' +import 'package:polygonid_flutter_sdk/identity/data/mappers/node_type_entity_mapper.dart' as _i42; +import 'package:polygonid_flutter_sdk/identity/data/mappers/node_type_mapper.dart' + as _i43; import 'package:polygonid_flutter_sdk/identity/data/mappers/poseidon_hash_mapper.dart' - as _i53; -import 'package:polygonid_flutter_sdk/identity/data/mappers/private_key_mapper.dart' as _i54; +import 'package:polygonid_flutter_sdk/identity/data/mappers/private_key_mapper.dart' + as _i55; import 'package:polygonid_flutter_sdk/identity/data/mappers/q_mapper.dart' - as _i60; + as _i61; import 'package:polygonid_flutter_sdk/identity/data/mappers/rhs_node_mapper.dart' - as _i104; + as _i107; import 'package:polygonid_flutter_sdk/identity/data/mappers/rhs_node_type_mapper.dart' - as _i63; + as _i64; import 'package:polygonid_flutter_sdk/identity/data/mappers/state_identifier_mapper.dart' - as _i65; -import 'package:polygonid_flutter_sdk/identity/data/mappers/tree_state_mapper.dart' as _i66; -import 'package:polygonid_flutter_sdk/identity/data/mappers/tree_type_mapper.dart' +import 'package:polygonid_flutter_sdk/identity/data/mappers/tree_state_mapper.dart' as _i67; +import 'package:polygonid_flutter_sdk/identity/data/mappers/tree_type_mapper.dart' + as _i68; import 'package:polygonid_flutter_sdk/identity/data/repositories/identity_repository_impl.dart' - as _i146; + as _i153; import 'package:polygonid_flutter_sdk/identity/data/repositories/smt_repository_impl.dart' - as _i117; + as _i121; import 'package:polygonid_flutter_sdk/identity/domain/repositories/identity_repository.dart' - as _i149; + as _i156; import 'package:polygonid_flutter_sdk/identity/domain/repositories/smt_repository.dart' - as _i134; + as _i140; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/fetch_identity_state_use_case.dart' - as _i168; + as _i175; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/fetch_state_roots_use_case.dart' - as _i156; + as _i163; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_current_env_did_identifier_use_case.dart' - as _i183; + as _i190; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_did_identifier_use_case.dart' - as _i174; + as _i181; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_did_use_case.dart' - as _i158; + as _i165; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_genesis_state_use_case.dart' - as _i171; + as _i178; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_identity_auth_claim_use_case.dart' - as _i161; + as _i168; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_latest_state_use_case.dart' - as _i142; + as _i149; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/get_public_keys_use_case.dart' - as _i163; + as _i170; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/add_identity_use_case.dart' - as _i196; + as _i204; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/add_new_identity_use_case.dart' - as _i197; + as _i205; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/backup_identity_use_case.dart' - as _i186; + as _i194; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/check_identity_validity_use_case.dart' - as _i187; + as _i195; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/create_identity_use_case.dart' - as _i188; + as _i196; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/get_identities_use_case.dart' - as _i160; + as _i167; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/get_identity_use_case.dart' - as _i175; + as _i182; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/get_private_key_use_case.dart' - as _i162; + as _i169; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/remove_identity_use_case.dart' - as _i204; + as _i212; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/restore_identity_use_case.dart' - as _i205; + as _i213; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/sign_message_use_case.dart' - as _i152; + as _i159; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/identity/update_identity_use_case.dart' - as _i195; + as _i203; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/add_profile_use_case.dart' - as _i198; + as _i206; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/check_profile_validity_use_case.dart' as _i7; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/create_profiles_use_case.dart' - as _i189; + as _i197; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/get_profiles_use_case.dart' - as _i184; + as _i191; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/remove_profile_use_case.dart' - as _i202; + as _i210; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/restore_profiles_use_case.dart' - as _i203; + as _i211; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/smt/create_identity_state_use_case.dart' - as _i167; + as _i174; import 'package:polygonid_flutter_sdk/identity/domain/use_cases/smt/remove_identity_state_use_case.dart' - as _i148; + as _i155; import 'package:polygonid_flutter_sdk/identity/libs/bjj/bjj.dart' as _i6; import 'package:polygonid_flutter_sdk/identity/libs/polygonidcore/pidcore_identity.dart' - as _i49; + as _i50; import 'package:polygonid_flutter_sdk/proof/data/data_sources/circuits_download_data_source.dart' - as _i81; + as _i84; import 'package:polygonid_flutter_sdk/proof/data/data_sources/circuits_files_data_source.dart' - as _i82; + as _i85; import 'package:polygonid_flutter_sdk/proof/data/data_sources/gist_mtproof_data_source.dart' - as _i25; + as _i26; import 'package:polygonid_flutter_sdk/proof/data/data_sources/lib_pidcore_proof_data_source.dart' - as _i96; + as _i99; import 'package:polygonid_flutter_sdk/proof/data/data_sources/proof_circuit_data_source.dart' - as _i55; + as _i56; import 'package:polygonid_flutter_sdk/proof/data/data_sources/prover_lib_data_source.dart' - as _i59; + as _i60; import 'package:polygonid_flutter_sdk/proof/data/data_sources/witness_data_source.dart' - as _i72; + as _i73; import 'package:polygonid_flutter_sdk/proof/data/mappers/circuit_type_mapper.dart' as _i8; import 'package:polygonid_flutter_sdk/proof/data/mappers/gist_mtproof_mapper.dart' - as _i112; + as _i116; import 'package:polygonid_flutter_sdk/proof/data/mappers/mtproof_mapper.dart' - as _i98; + as _i101; import 'package:polygonid_flutter_sdk/proof/data/mappers/node_aux_mapper.dart' - as _i39; + as _i40; import 'package:polygonid_flutter_sdk/proof/data/mappers/zkproof_base_mapper.dart' - as _i77; + as _i80; import 'package:polygonid_flutter_sdk/proof/data/mappers/zkproof_mapper.dart' - as _i78; + as _i81; import 'package:polygonid_flutter_sdk/proof/data/repositories/proof_repository_impl.dart' - as _i147; + as _i154; import 'package:polygonid_flutter_sdk/proof/domain/repositories/proof_repository.dart' - as _i150; + as _i157; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/cancel_download_circuits_use_case.dart' - as _i153; + as _i160; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/circuits_files_exist_use_case.dart' - as _i154; + as _i161; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/download_circuits_use_case.dart' - as _i155; + as _i162; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/generate_zkproof_use_case.dart' - as _i157; + as _i164; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/get_gist_mtproof_use_case.dart' - as _i159; + as _i166; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/is_proof_circuit_supported_use_case.dart' - as _i164; + as _i171; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/load_circuit_use_case.dart' - as _i165; + as _i172; import 'package:polygonid_flutter_sdk/proof/domain/use_cases/prove_use_case.dart' - as _i151; + as _i158; import 'package:polygonid_flutter_sdk/proof/infrastructure/proof_generation_stream_manager.dart' - as _i56; + as _i57; import 'package:polygonid_flutter_sdk/proof/libs/polygonidcore/pidcore_proof.dart' - as _i50; -import 'package:polygonid_flutter_sdk/proof/libs/prover/prover.dart' as _i58; + as _i51; +import 'package:polygonid_flutter_sdk/proof/libs/prover/prover.dart' as _i59; import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/auth_v2/witness_auth.dart' - as _i71; + as _i72; import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/mtp_v2/witness_mtp.dart' - as _i73; -import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/mtp_v2_onchain/witness_mtp_onchain.dart' as _i74; -import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/sig_v2/witness_sig.dart' +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/mtp_v2_onchain/witness_mtp_onchain.dart' as _i75; -import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/sig_v2_onchain/witness_sig_onchain.dart' +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/sig_v2/witness_sig.dart' as _i76; -import 'package:polygonid_flutter_sdk/sdk/credential.dart' as _i200; -import 'package:polygonid_flutter_sdk/sdk/di/injector.dart' as _i207; -import 'package:polygonid_flutter_sdk/sdk/error_handling.dart' as _i85; -import 'package:polygonid_flutter_sdk/sdk/iden3comm.dart' as _i201; -import 'package:polygonid_flutter_sdk/sdk/identity.dart' as _i206; -import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart' as _i51; +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/sig_v2_onchain/witness_sig_onchain.dart' + as _i77; +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/v3/witness_v3.dart' + as _i78; +import 'package:polygonid_flutter_sdk/proof/libs/witnesscalc/v3_onchain/witness_v3_onchain.dart' + as _i79; +import 'package:polygonid_flutter_sdk/sdk/credential.dart' as _i208; +import 'package:polygonid_flutter_sdk/sdk/di/injector.dart' as _i215; +import 'package:polygonid_flutter_sdk/sdk/error_handling.dart' as _i88; +import 'package:polygonid_flutter_sdk/sdk/iden3comm.dart' as _i209; +import 'package:polygonid_flutter_sdk/sdk/identity.dart' as _i214; +import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart' as _i52; import 'package:polygonid_flutter_sdk/sdk/polygonid_flutter_channel.dart' - as _i101; -import 'package:polygonid_flutter_sdk/sdk/proof.dart' as _i166; + as _i104; +import 'package:polygonid_flutter_sdk/sdk/proof.dart' as _i173; import 'package:sembast/sembast.dart' as _i13; -import 'package:web3dart/web3dart.dart' as _i69; +import 'package:web3dart/web3dart.dart' as _i70; extension GetItInjectableX on _i1.GetIt { // initializes the registration of main-scope dependencies inside of GetIt @@ -433,7 +449,6 @@ extension GetItInjectableX on _i1.GetIt { gh.factory<_i10.ClaimStateMapper>(() => _i10.ClaimStateMapper()); gh.factory<_i11.Client>(() => networkModule.client); gh.factory<_i12.CreatePathWrapper>(() => _i12.CreatePathWrapper()); - gh.lazySingletonAsync<_i13.Database>(() => databaseModule.database()); gh.factoryParamAsync<_i13.Database, String?, String?>( ( identifier, @@ -445,6 +460,7 @@ extension GetItInjectableX on _i1.GetIt { ), instanceName: 'polygonIdSdkIdentity', ); + gh.lazySingletonAsync<_i13.Database>(() => databaseModule.database()); gh.factory<_i12.DestinationPathDataSource>( () => _i12.DestinationPathDataSource(gh<_i12.CreatePathWrapper>())); gh.factory<_i14.DidProfileInfoInteractedDidFilterMapper>( @@ -452,7 +468,8 @@ extension GetItInjectableX on _i1.GetIt { gh.factory<_i15.Dio>(() => networkModule.dio); gh.factoryAsync<_i16.Directory>( () => filesManagerModule.applicationDocumentsDirectory); - gh.factoryParam<_i17.Encrypter, _i17.Key, dynamic>( + gh.factory<_i17.DisplayTypeMapper>(() => _i17.DisplayTypeMapper()); + gh.factoryParam<_i18.Encrypter, _i18.Key, dynamic>( ( key, _, @@ -460,96 +477,100 @@ extension GetItInjectableX on _i1.GetIt { encryptionModule.encryptAES(key), instanceName: 'encryptAES', ); - gh.factory<_i18.EncryptionDbDataSource>( - () => _i18.EncryptionDbDataSource()); - gh.factory<_i19.EncryptionKeyMapper>(() => _i19.EncryptionKeyMapper()); - gh.factory<_i20.EnvMapper>(() => _i20.EnvMapper()); - gh.factory<_i21.FilterMapper>(() => _i21.FilterMapper()); - gh.factory<_i22.FiltersMapper>( - () => _i22.FiltersMapper(gh<_i21.FilterMapper>())); - gh.factory<_i23.GetFetchRequestsUseCase>( - () => _i23.GetFetchRequestsUseCase()); - gh.factory<_i24.GetIden3MessageTypeUseCase>( - () => _i24.GetIden3MessageTypeUseCase()); - gh.factory<_i25.GistMTProofDataSource>(() => _i25.GistMTProofDataSource()); - gh.factory<_i26.HashMapper>(() => _i26.HashMapper()); - gh.factory<_i27.HexMapper>(() => _i27.HexMapper()); - gh.factory<_i28.IdFilterMapper>(() => _i28.IdFilterMapper()); - gh.factory<_i29.Iden3MessageDataSource>( - () => _i29.Iden3MessageDataSource()); - gh.factory<_i30.Iden3MessageTypeMapper>( - () => _i30.Iden3MessageTypeMapper()); - gh.factory<_i31.Iden3commVPProofMapper>( - () => _i31.Iden3commVPProofMapper()); - gh.factory<_i32.IdentityDTOMapper>(() => _i32.IdentityDTOMapper()); - gh.factory<_i33.InteractionIdFilterMapper>( - () => _i33.InteractionIdFilterMapper()); - gh.factory<_i34.InteractionMapper>(() => _i34.InteractionMapper()); - gh.factory<_i35.JWZMapper>(() => _i35.JWZMapper()); - gh.factory<_i36.LibBabyJubJubDataSource>( - () => _i36.LibBabyJubJubDataSource(gh<_i6.BabyjubjubLib>())); - gh.factory<_i37.LocalContractFilesDataSource>( - () => _i37.LocalContractFilesDataSource()); - gh.factory<_i38.Logger>(() => loggerModule.logger); + gh.factory<_i19.EncryptionDbDataSource>( + () => _i19.EncryptionDbDataSource()); + gh.factory<_i20.EncryptionKeyMapper>(() => _i20.EncryptionKeyMapper()); + gh.factory<_i21.EnvMapper>(() => _i21.EnvMapper()); + gh.factory<_i22.FilterMapper>(() => _i22.FilterMapper()); + gh.factory<_i23.FiltersMapper>( + () => _i23.FiltersMapper(gh<_i22.FilterMapper>())); + gh.factory<_i24.GetFetchRequestsUseCase>( + () => _i24.GetFetchRequestsUseCase()); + gh.factory<_i25.GetIden3MessageTypeUseCase>( + () => _i25.GetIden3MessageTypeUseCase()); + gh.factory<_i26.GistMTProofDataSource>(() => _i26.GistMTProofDataSource()); + gh.factory<_i27.HashMapper>(() => _i27.HashMapper()); + gh.factory<_i28.HexMapper>(() => _i28.HexMapper()); + gh.factory<_i29.IdFilterMapper>(() => _i29.IdFilterMapper()); + gh.factory<_i30.Iden3MessageDataSource>( + () => _i30.Iden3MessageDataSource()); + gh.factory<_i31.Iden3MessageTypeMapper>( + () => _i31.Iden3MessageTypeMapper()); + gh.factory<_i32.Iden3commVPProofMapper>( + () => _i32.Iden3commVPProofMapper()); + gh.factory<_i33.IdentityDTOMapper>(() => _i33.IdentityDTOMapper()); + gh.factory<_i34.InteractionIdFilterMapper>( + () => _i34.InteractionIdFilterMapper()); + gh.factory<_i35.InteractionMapper>(() => _i35.InteractionMapper()); + gh.factory<_i36.JWZMapper>(() => _i36.JWZMapper()); + gh.factory<_i37.LibBabyJubJubDataSource>( + () => _i37.LibBabyJubJubDataSource(gh<_i6.BabyjubjubLib>())); + gh.factory<_i38.LocalContractFilesDataSource>( + () => _i38.LocalContractFilesDataSource()); + gh.factory<_i39.Logger>(() => loggerModule.logger); gh.factory>>>( () => databaseModule.identityStateStore, instanceName: 'identityStateStore', ); gh.lazySingleton<_i3.MethodChannel>(() => channelModule.methodChannel); - gh.factory<_i39.NodeAuxMapper>(() => _i39.NodeAuxMapper()); - gh.factory<_i40.NodeTypeDTOMapper>(() => _i40.NodeTypeDTOMapper()); - gh.factory<_i41.NodeTypeEntityMapper>(() => _i41.NodeTypeEntityMapper()); - gh.factory<_i42.NodeTypeMapper>(() => _i42.NodeTypeMapper()); - gh.lazySingletonAsync<_i43.PackageInfo>(() => platformModule.packageInfo); - gh.factoryAsync<_i44.PackageInfoDataSource>(() async => - _i44.PackageInfoDataSource(await getAsync<_i43.PackageInfo>())); - gh.factoryAsync<_i45.PackageInfoRepositoryImpl>(() async => - _i45.PackageInfoRepositoryImpl( - await getAsync<_i44.PackageInfoDataSource>())); - gh.factory<_i46.PolygonIdCore>(() => _i46.PolygonIdCore()); - gh.factory<_i47.PolygonIdCoreCredential>( - () => _i47.PolygonIdCoreCredential()); - gh.factory<_i48.PolygonIdCoreIden3comm>( - () => _i48.PolygonIdCoreIden3comm()); - gh.factory<_i49.PolygonIdCoreIdentity>(() => _i49.PolygonIdCoreIdentity()); - gh.factory<_i50.PolygonIdCoreProof>(() => _i50.PolygonIdCoreProof()); - gh.factory<_i51.PolygonIdSdk>(() => channelModule.polygonIdSdk); - gh.factory<_i52.PolygonIdSdkLogger>(() => loggerModule.sdkLogger); - gh.factory<_i53.PoseidonHashMapper>( - () => _i53.PoseidonHashMapper(gh<_i27.HexMapper>())); - gh.factory<_i54.PrivateKeyMapper>(() => _i54.PrivateKeyMapper()); - gh.factory<_i55.ProofCircuitDataSource>( - () => _i55.ProofCircuitDataSource()); - gh.lazySingleton<_i56.ProofGenerationStepsStreamManager>( - () => _i56.ProofGenerationStepsStreamManager()); - gh.factory<_i57.ProofRequestFiltersMapper>( - () => _i57.ProofRequestFiltersMapper()); - gh.factory<_i58.ProverLib>(() => _i58.ProverLib()); - gh.factory<_i59.ProverLibWrapper>(() => _i59.ProverLibWrapper()); - gh.factory<_i60.QMapper>(() => _i60.QMapper()); - gh.factory<_i61.RemoteIdentityDataSource>( - () => _i61.RemoteIdentityDataSource()); - gh.factory<_i62.RevocationStatusMapper>( - () => _i62.RevocationStatusMapper()); - gh.factory<_i63.RhsNodeTypeMapper>(() => _i63.RhsNodeTypeMapper()); + gh.factory<_i40.NodeAuxMapper>(() => _i40.NodeAuxMapper()); + gh.factory<_i41.NodeTypeDTOMapper>(() => _i41.NodeTypeDTOMapper()); + gh.factory<_i42.NodeTypeEntityMapper>(() => _i42.NodeTypeEntityMapper()); + gh.factory<_i43.NodeTypeMapper>(() => _i43.NodeTypeMapper()); + gh.lazySingletonAsync<_i44.PackageInfo>(() => platformModule.packageInfo); + gh.factoryAsync<_i45.PackageInfoDataSource>(() async => + _i45.PackageInfoDataSource(await getAsync<_i44.PackageInfo>())); + gh.factoryAsync<_i46.PackageInfoRepositoryImpl>(() async => + _i46.PackageInfoRepositoryImpl( + await getAsync<_i45.PackageInfoDataSource>())); + gh.factory<_i47.PolygonIdCore>(() => _i47.PolygonIdCore()); + gh.factory<_i48.PolygonIdCoreCredential>( + () => _i48.PolygonIdCoreCredential()); + gh.factory<_i49.PolygonIdCoreIden3comm>( + () => _i49.PolygonIdCoreIden3comm()); + gh.factory<_i50.PolygonIdCoreIdentity>(() => _i50.PolygonIdCoreIdentity()); + gh.factory<_i51.PolygonIdCoreProof>(() => _i51.PolygonIdCoreProof()); + gh.factory<_i52.PolygonIdSdk>(() => channelModule.polygonIdSdk); + gh.factory<_i53.PolygonIdSdkLogger>(() => loggerModule.sdkLogger); + gh.factory<_i54.PoseidonHashMapper>( + () => _i54.PoseidonHashMapper(gh<_i28.HexMapper>())); + gh.factory<_i55.PrivateKeyMapper>(() => _i55.PrivateKeyMapper()); + gh.factory<_i56.ProofCircuitDataSource>( + () => _i56.ProofCircuitDataSource()); + gh.lazySingleton<_i57.ProofGenerationStepsStreamManager>( + () => _i57.ProofGenerationStepsStreamManager()); + gh.factory<_i58.ProofRequestFiltersMapper>( + () => _i58.ProofRequestFiltersMapper()); + gh.factory<_i59.ProverLib>(() => _i59.ProverLib()); + gh.factory<_i60.ProverLibWrapper>(() => _i60.ProverLibWrapper()); + gh.factory<_i61.QMapper>(() => _i61.QMapper()); + gh.factory<_i62.RemoteIdentityDataSource>( + () => _i62.RemoteIdentityDataSource()); + gh.factory<_i63.RevocationStatusMapper>( + () => _i63.RevocationStatusMapper()); + gh.factory<_i64.RhsNodeTypeMapper>(() => _i64.RhsNodeTypeMapper()); gh.factoryParam<_i13.SembastCodec, String, dynamic>(( privateKey, _, ) => databaseModule.getCodec(privateKey)); - gh.lazySingleton<_i64.StacktraceManager>(() => _i64.StacktraceManager()); - gh.factory<_i65.StateIdentifierMapper>(() => _i65.StateIdentifierMapper()); + gh.lazySingleton<_i65.StacktraceManager>(() => _i65.StacktraceManager()); + gh.factory<_i66.StateIdentifierMapper>(() => _i66.StateIdentifierMapper()); gh.factory<_i13.StoreRef>>( - () => databaseModule.interactionStore, - instanceName: 'interactionStore', + () => databaseModule.profileStore, + instanceName: 'profilesStore', ); gh.factory<_i13.StoreRef>>( () => databaseModule.didProfileInfoStore, instanceName: 'didProfileInfoStore', ); gh.factory<_i13.StoreRef>>( - () => databaseModule.profileStore, - instanceName: 'profilesStore', + () => databaseModule.interactionStore, + instanceName: 'interactionStore', + ); + gh.factory<_i13.StoreRef>>( + () => databaseModule.claimStore, + instanceName: 'claimStore', ); gh.factory<_i13.StoreRef>( () => databaseModule.keyValueStore, @@ -559,783 +580,816 @@ extension GetItInjectableX on _i1.GetIt { () => databaseModule.identityStore, instanceName: 'identityStore', ); - gh.factory<_i13.StoreRef>>( - () => databaseModule.claimStore, - instanceName: 'claimStore', - ); - gh.factory<_i66.TreeStateMapper>(() => _i66.TreeStateMapper()); - gh.factory<_i67.TreeTypeMapper>(() => _i67.TreeTypeMapper()); - gh.factory<_i68.WalletLibWrapper>(() => _i68.WalletLibWrapper()); - gh.factoryParam<_i69.Web3Client, _i70.EnvEntity, dynamic>(( + gh.factory<_i67.TreeStateMapper>(() => _i67.TreeStateMapper()); + gh.factory<_i68.TreeTypeMapper>(() => _i68.TreeTypeMapper()); + gh.factory<_i69.WalletLibWrapper>(() => _i69.WalletLibWrapper()); + gh.factoryParam<_i70.Web3Client, _i71.EnvEntity, dynamic>(( env, _, ) => networkModule.web3client(env)); - gh.factory<_i71.WitnessAuthV2Lib>(() => _i71.WitnessAuthV2Lib()); - gh.factory<_i72.WitnessIsolatesWrapper>( - () => _i72.WitnessIsolatesWrapper()); - gh.factory<_i73.WitnessMTPV2Lib>(() => _i73.WitnessMTPV2Lib()); - gh.factory<_i74.WitnessMTPV2OnchainLib>( - () => _i74.WitnessMTPV2OnchainLib()); - gh.factory<_i75.WitnessSigV2Lib>(() => _i75.WitnessSigV2Lib()); - gh.factory<_i76.WitnessSigV2OnchainLib>( - () => _i76.WitnessSigV2OnchainLib()); - gh.factory<_i77.ZKProofBaseMapper>(() => _i77.ZKProofBaseMapper()); - gh.factory<_i78.ZKProofMapper>(() => _i78.ZKProofMapper()); - gh.factory<_i79.ZipDecoder>(() => filesManagerModule.zipDecoder()); - gh.factory<_i80.AuthProofMapper>(() => _i80.AuthProofMapper( - gh<_i26.HashMapper>(), - gh<_i39.NodeAuxMapper>(), + gh.factory<_i72.WitnessAuthV2Lib>(() => _i72.WitnessAuthV2Lib()); + gh.factory<_i73.WitnessIsolatesWrapper>( + () => _i73.WitnessIsolatesWrapper()); + gh.factory<_i74.WitnessMTPV2Lib>(() => _i74.WitnessMTPV2Lib()); + gh.factory<_i75.WitnessMTPV2OnchainLib>( + () => _i75.WitnessMTPV2OnchainLib()); + gh.factory<_i76.WitnessSigV2Lib>(() => _i76.WitnessSigV2Lib()); + gh.factory<_i77.WitnessSigV2OnchainLib>( + () => _i77.WitnessSigV2OnchainLib()); + gh.factory<_i78.WitnessV3Lib>(() => _i78.WitnessV3Lib()); + gh.factory<_i79.WitnessV3OnchainLib>(() => _i79.WitnessV3OnchainLib()); + gh.factory<_i80.ZKProofBaseMapper>(() => _i80.ZKProofBaseMapper()); + gh.factory<_i81.ZKProofMapper>(() => _i81.ZKProofMapper()); + gh.factory<_i82.ZipDecoder>(() => filesManagerModule.zipDecoder()); + gh.factory<_i83.AuthProofMapper>(() => _i83.AuthProofMapper( + gh<_i27.HashMapper>(), + gh<_i40.NodeAuxMapper>(), )); - gh.lazySingleton<_i81.CircuitsDownloadDataSource>( - () => _i81.CircuitsDownloadDataSource(gh<_i15.Dio>())); - gh.factoryAsync<_i82.CircuitsFilesDataSource>(() async => - _i82.CircuitsFilesDataSource(await getAsync<_i16.Directory>())); - gh.factory<_i83.ClaimMapper>(() => _i83.ClaimMapper( + gh.factory<_i84.CircuitsDownloadDataSource>( + () => _i84.CircuitsDownloadDataSource(gh<_i15.Dio>())); + gh.factoryAsync<_i85.CircuitsFilesDataSource>(() async => + _i85.CircuitsFilesDataSource(await getAsync<_i16.Directory>())); + gh.factory<_i86.ClaimMapper>(() => _i86.ClaimMapper( gh<_i10.ClaimStateMapper>(), gh<_i9.ClaimInfoMapper>(), + gh<_i17.DisplayTypeMapper>(), )); - gh.factory<_i84.ClaimStoreRefWrapper>(() => _i84.ClaimStoreRefWrapper( + gh.factory<_i87.ClaimStoreRefWrapper>(() => _i87.ClaimStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'claimStore'))); - gh.factory<_i85.ErrorHandling>( - () => _i85.ErrorHandling(gh<_i64.StacktraceManager>())); - gh.factory<_i86.GetIden3MessageUseCase>(() => _i86.GetIden3MessageUseCase( - gh<_i24.GetIden3MessageTypeUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i88.ErrorHandling>( + () => _i88.ErrorHandling(gh<_i65.StacktraceManager>())); + gh.factory<_i89.GetIden3MessageUseCase>(() => _i89.GetIden3MessageUseCase( + gh<_i25.GetIden3MessageTypeUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i87.GetProofQueryUseCase>( - () => _i87.GetProofQueryUseCase(gh<_i64.StacktraceManager>())); - gh.factory<_i88.Iden3commProofMapper>(() => _i88.Iden3commProofMapper( - gh<_i77.ZKProofBaseMapper>(), - gh<_i31.Iden3commVPProofMapper>(), + gh.factory<_i90.GetProofQueryUseCase>( + () => _i90.GetProofQueryUseCase(gh<_i65.StacktraceManager>())); + gh.factory<_i91.Iden3commProofMapper>(() => _i91.Iden3commProofMapper( + gh<_i80.ZKProofBaseMapper>(), + gh<_i32.Iden3commVPProofMapper>(), )); - gh.factory<_i89.IdentitySMTStoreRefWrapper>(() => - _i89.IdentitySMTStoreRefWrapper( + gh.factory<_i92.IdentitySMTStoreRefWrapper>(() => + _i92.IdentitySMTStoreRefWrapper( gh>>>( instanceName: 'identityStateStore'))); - gh.factory<_i90.IdentityStoreRefWrapper>(() => _i90.IdentityStoreRefWrapper( + gh.factory<_i93.IdentityStoreRefWrapper>(() => _i93.IdentityStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'identityStore'))); - gh.factory<_i91.InteractionStoreRefWrapper>(() => - _i91.InteractionStoreRefWrapper( + gh.factory<_i94.InteractionStoreRefWrapper>(() => + _i94.InteractionStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'interactionStore'))); - gh.factory<_i92.KeyValueStoreRefWrapper>(() => _i92.KeyValueStoreRefWrapper( + gh.factory<_i95.KeyValueStoreRefWrapper>(() => _i95.KeyValueStoreRefWrapper( gh<_i13.StoreRef>(instanceName: 'keyValueStore'))); - gh.factory<_i93.LibPolygonIdCoreCredentialDataSource>(() => - _i93.LibPolygonIdCoreCredentialDataSource( - gh<_i47.PolygonIdCoreCredential>())); - gh.factory<_i94.LibPolygonIdCoreIden3commDataSource>(() => - _i94.LibPolygonIdCoreIden3commDataSource( - gh<_i48.PolygonIdCoreIden3comm>())); - gh.factory<_i95.LibPolygonIdCoreIdentityDataSource>(() => - _i95.LibPolygonIdCoreIdentityDataSource( - gh<_i49.PolygonIdCoreIdentity>())); - gh.factory<_i96.LibPolygonIdCoreWrapper>( - () => _i96.LibPolygonIdCoreWrapper(gh<_i50.PolygonIdCoreProof>())); - gh.factory<_i97.LocalClaimDataSource>(() => _i97.LocalClaimDataSource( - gh<_i93.LibPolygonIdCoreCredentialDataSource>())); - gh.factory<_i98.MTProofMapper>(() => _i98.MTProofMapper( - gh<_i26.HashMapper>(), - gh<_i39.NodeAuxMapper>(), + gh.factory<_i96.LibPolygonIdCoreCredentialDataSource>(() => + _i96.LibPolygonIdCoreCredentialDataSource( + gh<_i48.PolygonIdCoreCredential>())); + gh.factory<_i97.LibPolygonIdCoreIden3commDataSource>(() => + _i97.LibPolygonIdCoreIden3commDataSource( + gh<_i49.PolygonIdCoreIden3comm>())); + gh.factory<_i98.LibPolygonIdCoreIdentityDataSource>(() => + _i98.LibPolygonIdCoreIdentityDataSource( + gh<_i50.PolygonIdCoreIdentity>())); + gh.factory<_i99.LibPolygonIdCoreWrapper>( + () => _i99.LibPolygonIdCoreWrapper(gh<_i51.PolygonIdCoreProof>())); + gh.factory<_i100.LocalClaimDataSource>(() => _i100.LocalClaimDataSource( + gh<_i96.LibPolygonIdCoreCredentialDataSource>())); + gh.factory<_i101.MTProofMapper>(() => _i101.MTProofMapper( + gh<_i27.HashMapper>(), + gh<_i40.NodeAuxMapper>(), )); - gh.factory<_i99.NodeMapper>(() => _i99.NodeMapper( - gh<_i42.NodeTypeMapper>(), - gh<_i41.NodeTypeEntityMapper>(), - gh<_i40.NodeTypeDTOMapper>(), - gh<_i26.HashMapper>(), + gh.factory<_i102.NodeMapper>(() => _i102.NodeMapper( + gh<_i43.NodeTypeMapper>(), + gh<_i42.NodeTypeEntityMapper>(), + gh<_i41.NodeTypeDTOMapper>(), + gh<_i27.HashMapper>(), )); - gh.factoryAsync<_i100.PackageInfoRepository>(() async => + gh.factoryAsync<_i103.PackageInfoRepository>(() async => repositoriesModule.packageInfoRepository( - await getAsync<_i45.PackageInfoRepositoryImpl>())); - gh.factory<_i101.PolygonIdFlutterChannel>( - () => _i101.PolygonIdFlutterChannel( - gh<_i51.PolygonIdSdk>(), + await getAsync<_i46.PackageInfoRepositoryImpl>())); + gh.factory<_i104.PolygonIdFlutterChannel>( + () => _i104.PolygonIdFlutterChannel( + gh<_i52.PolygonIdSdk>(), gh<_i3.MethodChannel>(), )); - gh.factory<_i59.ProverLibDataSource>( - () => _i59.ProverLibDataSource(gh<_i59.ProverLibWrapper>())); - gh.factory<_i102.RemoteClaimDataSource>(() => _i102.RemoteClaimDataSource( + gh.factory<_i60.ProverLibDataSource>( + () => _i60.ProverLibDataSource(gh<_i60.ProverLibWrapper>())); + gh.factory<_i105.RemoteClaimDataSource>(() => _i105.RemoteClaimDataSource( gh<_i11.Client>(), - gh<_i64.StacktraceManager>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i103.RemoteIden3commDataSource>( - () => _i103.RemoteIden3commDataSource( + gh.factory<_i106.RemoteIden3commDataSource>( + () => _i106.RemoteIden3commDataSource( gh<_i11.Client>(), - gh<_i64.StacktraceManager>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i104.RhsNodeMapper>( - () => _i104.RhsNodeMapper(gh<_i63.RhsNodeTypeMapper>())); - gh.factory<_i105.SecureDidProfileInfoStoreRefWrapper>(() => - _i105.SecureDidProfileInfoStoreRefWrapper( + gh.factory<_i107.RhsNodeMapper>( + () => _i107.RhsNodeMapper(gh<_i64.RhsNodeTypeMapper>())); + gh.factory<_i108.SecureDidProfileInfoStoreRefWrapper>(() => + _i108.SecureDidProfileInfoStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'didProfileInfoStore'))); - gh.factory<_i106.SecureInteractionStoreRefWrapper>(() => - _i106.SecureInteractionStoreRefWrapper( + gh.factory<_i109.SecureInteractionStoreRefWrapper>(() => + _i109.SecureInteractionStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'interactionStore'))); - gh.factory<_i105.SecureStorageDidProfileInfoDataSource>(() => - _i105.SecureStorageDidProfileInfoDataSource( - gh<_i105.SecureDidProfileInfoStoreRefWrapper>())); - gh.factory<_i106.SecureStorageInteractionDataSource>(() => - _i106.SecureStorageInteractionDataSource( - gh<_i106.SecureInteractionStoreRefWrapper>())); - gh.factory<_i107.SecureStorageProfilesStoreRefWrapper>(() => - _i107.SecureStorageProfilesStoreRefWrapper( + gh.factory<_i108.SecureStorageDidProfileInfoDataSource>(() => + _i108.SecureStorageDidProfileInfoDataSource( + gh<_i108.SecureDidProfileInfoStoreRefWrapper>())); + gh.factory<_i109.SecureStorageInteractionDataSource>(() => + _i109.SecureStorageInteractionDataSource( + gh<_i109.SecureInteractionStoreRefWrapper>())); + gh.factory<_i110.SecureStorageProfilesStoreRefWrapper>(() => + _i110.SecureStorageProfilesStoreRefWrapper( gh<_i13.StoreRef>>( instanceName: 'profilesStore'))); - gh.factory<_i84.StorageClaimDataSource>( - () => _i84.StorageClaimDataSource(gh<_i84.ClaimStoreRefWrapper>())); - gh.factoryAsync<_i90.StorageIdentityDataSource>( - () async => _i90.StorageIdentityDataSource( + gh.factory<_i87.StorageClaimDataSource>( + () => _i87.StorageClaimDataSource(gh<_i87.ClaimStoreRefWrapper>())); + gh.factoryAsync<_i93.StorageIdentityDataSource>( + () async => _i93.StorageIdentityDataSource( await getAsync<_i13.Database>(), - gh<_i90.IdentityStoreRefWrapper>(), + gh<_i93.IdentityStoreRefWrapper>(), )); - gh.factoryAsync<_i91.StorageInteractionDataSource>( - () async => _i91.StorageInteractionDataSource( + gh.factoryAsync<_i94.StorageInteractionDataSource>( + () async => _i94.StorageInteractionDataSource( await getAsync<_i13.Database>(), - gh<_i91.InteractionStoreRefWrapper>(), + gh<_i94.InteractionStoreRefWrapper>(), )); - gh.factoryAsync<_i92.StorageKeyValueDataSource>( - () async => _i92.StorageKeyValueDataSource( + gh.factoryAsync<_i95.StorageKeyValueDataSource>( + () async => _i95.StorageKeyValueDataSource( await getAsync<_i13.Database>(), - gh<_i92.KeyValueStoreRefWrapper>(), + gh<_i95.KeyValueStoreRefWrapper>(), )); - gh.factory<_i89.StorageSMTDataSource>( - () => _i89.StorageSMTDataSource(gh<_i89.IdentitySMTStoreRefWrapper>())); - gh.factory<_i68.WalletDataSource>( - () => _i68.WalletDataSource(gh<_i68.WalletLibWrapper>())); - gh.factory<_i72.WitnessDataSource>( - () => _i72.WitnessDataSource(gh<_i72.WitnessIsolatesWrapper>())); - gh.factoryAsync<_i108.ConfigRepositoryImpl>( - () async => _i108.ConfigRepositoryImpl( - await getAsync<_i92.StorageKeyValueDataSource>(), - gh<_i20.EnvMapper>(), + gh.factory<_i92.StorageSMTDataSource>( + () => _i92.StorageSMTDataSource(gh<_i92.IdentitySMTStoreRefWrapper>())); + gh.factory<_i69.WalletDataSource>( + () => _i69.WalletDataSource(gh<_i69.WalletLibWrapper>())); + gh.factory<_i73.WitnessDataSource>( + () => _i73.WitnessDataSource(gh<_i73.WitnessIsolatesWrapper>())); + gh.factory<_i111.CacheCredentialDataSource>(() => + _i111.CacheCredentialDataSource( + gh<_i96.LibPolygonIdCoreCredentialDataSource>())); + gh.factoryAsync<_i112.ConfigRepositoryImpl>( + () async => _i112.ConfigRepositoryImpl( + await getAsync<_i95.StorageKeyValueDataSource>(), + gh<_i21.EnvMapper>(), )); - gh.factory<_i109.CredentialRepositoryImpl>( - () => _i109.CredentialRepositoryImpl( - gh<_i102.RemoteClaimDataSource>(), - gh<_i84.StorageClaimDataSource>(), - gh<_i97.LocalClaimDataSource>(), - gh<_i83.ClaimMapper>(), - gh<_i22.FiltersMapper>(), - gh<_i28.IdFilterMapper>(), + gh.factory<_i113.CredentialRepositoryImpl>( + () => _i113.CredentialRepositoryImpl( + gh<_i105.RemoteClaimDataSource>(), + gh<_i87.StorageClaimDataSource>(), + gh<_i100.LocalClaimDataSource>(), + gh<_i111.CacheCredentialDataSource>(), + gh<_i86.ClaimMapper>(), + gh<_i23.FiltersMapper>(), + gh<_i29.IdFilterMapper>(), )); - gh.factory<_i110.DidProfileInfoRepositoryImpl>( - () => _i110.DidProfileInfoRepositoryImpl( - gh<_i105.SecureStorageDidProfileInfoDataSource>(), - gh<_i22.FiltersMapper>(), + gh.factory<_i114.DidProfileInfoRepositoryImpl>( + () => _i114.DidProfileInfoRepositoryImpl( + gh<_i108.SecureStorageDidProfileInfoDataSource>(), + gh<_i23.FiltersMapper>(), gh<_i14.DidProfileInfoInteractedDidFilterMapper>(), )); - gh.factoryAsync<_i111.GetPackageNameUseCase>(() async => - _i111.GetPackageNameUseCase( - await getAsync<_i100.PackageInfoRepository>())); - gh.factory<_i112.GistMTProofMapper>(() => _i112.GistMTProofMapper( - gh<_i98.MTProofMapper>(), - gh<_i26.HashMapper>(), + gh.factoryAsync<_i115.GetPackageNameUseCase>(() async => + _i115.GetPackageNameUseCase( + await getAsync<_i103.PackageInfoRepository>())); + gh.factory<_i116.GistMTProofMapper>(() => _i116.GistMTProofMapper( + gh<_i101.MTProofMapper>(), + gh<_i27.HashMapper>(), )); - gh.factory<_i113.Iden3commCredentialRepositoryImpl>( - () => _i113.Iden3commCredentialRepositoryImpl( - gh<_i103.RemoteIden3commDataSource>(), - gh<_i57.ProofRequestFiltersMapper>(), - gh<_i83.ClaimMapper>(), + gh.factory<_i117.Iden3commCredentialRepositoryImpl>( + () => _i117.Iden3commCredentialRepositoryImpl( + gh<_i106.RemoteIden3commDataSource>(), + gh<_i58.ProofRequestFiltersMapper>(), + gh<_i86.ClaimMapper>(), )); - gh.factory<_i114.Iden3commRepositoryImpl>( - () => _i114.Iden3commRepositoryImpl( - gh<_i29.Iden3MessageDataSource>(), - gh<_i103.RemoteIden3commDataSource>(), - gh<_i94.LibPolygonIdCoreIden3commDataSource>(), - gh<_i36.LibBabyJubJubDataSource>(), + gh.factory<_i118.Iden3commRepositoryImpl>( + () => _i118.Iden3commRepositoryImpl( + gh<_i30.Iden3MessageDataSource>(), + gh<_i106.RemoteIden3commDataSource>(), + gh<_i97.LibPolygonIdCoreIden3commDataSource>(), + gh<_i37.LibBabyJubJubDataSource>(), gh<_i5.AuthResponseMapper>(), gh<_i4.AuthInputsMapper>(), - gh<_i80.AuthProofMapper>(), - gh<_i112.GistMTProofMapper>(), - gh<_i60.QMapper>(), - gh<_i35.JWZMapper>(), - gh<_i88.Iden3commProofMapper>(), + gh<_i83.AuthProofMapper>(), + gh<_i116.GistMTProofMapper>(), + gh<_i61.QMapper>(), + gh<_i36.JWZMapper>(), + gh<_i91.Iden3commProofMapper>(), + )); + gh.factoryAsync<_i119.InteractionRepositoryImpl>( + () async => _i119.InteractionRepositoryImpl( + gh<_i109.SecureStorageInteractionDataSource>(), + await getAsync<_i94.StorageInteractionDataSource>(), + gh<_i35.InteractionMapper>(), + gh<_i23.FiltersMapper>(), + gh<_i34.InteractionIdFilterMapper>(), )); - gh.factoryAsync<_i115.InteractionRepositoryImpl>( - () async => _i115.InteractionRepositoryImpl( - gh<_i106.SecureStorageInteractionDataSource>(), - await getAsync<_i91.StorageInteractionDataSource>(), - gh<_i34.InteractionMapper>(), - gh<_i22.FiltersMapper>(), - gh<_i33.InteractionIdFilterMapper>(), + gh.factory<_i99.LibPolygonIdCoreProofDataSource>( + () => _i99.LibPolygonIdCoreProofDataSource( + gh<_i99.LibPolygonIdCoreWrapper>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i96.LibPolygonIdCoreProofDataSource>(() => - _i96.LibPolygonIdCoreProofDataSource( - gh<_i96.LibPolygonIdCoreWrapper>())); - gh.factory<_i116.SMTDataSource>(() => _i116.SMTDataSource( - gh<_i27.HexMapper>(), - gh<_i36.LibBabyJubJubDataSource>(), - gh<_i89.StorageSMTDataSource>(), + gh.factory<_i120.SMTDataSource>(() => _i120.SMTDataSource( + gh<_i28.HexMapper>(), + gh<_i37.LibBabyJubJubDataSource>(), + gh<_i92.StorageSMTDataSource>(), )); - gh.factory<_i117.SMTRepositoryImpl>(() => _i117.SMTRepositoryImpl( - gh<_i116.SMTDataSource>(), - gh<_i89.StorageSMTDataSource>(), - gh<_i36.LibBabyJubJubDataSource>(), - gh<_i99.NodeMapper>(), - gh<_i26.HashMapper>(), - gh<_i98.MTProofMapper>(), - gh<_i67.TreeTypeMapper>(), - gh<_i66.TreeStateMapper>(), + gh.factory<_i121.SMTRepositoryImpl>(() => _i121.SMTRepositoryImpl( + gh<_i120.SMTDataSource>(), + gh<_i92.StorageSMTDataSource>(), + gh<_i37.LibBabyJubJubDataSource>(), + gh<_i102.NodeMapper>(), + gh<_i27.HashMapper>(), + gh<_i101.MTProofMapper>(), + gh<_i68.TreeTypeMapper>(), + gh<_i67.TreeStateMapper>(), )); - gh.factory<_i107.SecureStorageProfilesDataSource>(() => - _i107.SecureStorageProfilesDataSource( - gh<_i107.SecureStorageProfilesStoreRefWrapper>())); - gh.factoryAsync<_i118.ConfigRepository>(() async => repositoriesModule - .configRepository(await getAsync<_i108.ConfigRepositoryImpl>())); - gh.factory<_i119.CredentialRepository>(() => repositoriesModule - .credentialRepository(gh<_i109.CredentialRepositoryImpl>())); - gh.factory<_i120.DidProfileInfoRepository>(() => repositoriesModule - .didProfileInfoRepository(gh<_i110.DidProfileInfoRepositoryImpl>())); - gh.factory<_i121.GetAuthClaimUseCase>(() => _i121.GetAuthClaimUseCase( - gh<_i119.CredentialRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i110.SecureStorageProfilesDataSource>(() => + _i110.SecureStorageProfilesDataSource( + gh<_i110.SecureStorageProfilesStoreRefWrapper>())); + gh.factoryAsync<_i122.ConfigRepository>(() async => repositoriesModule + .configRepository(await getAsync<_i112.ConfigRepositoryImpl>())); + gh.factory<_i123.CredentialRepository>(() => repositoriesModule + .credentialRepository(gh<_i113.CredentialRepositoryImpl>())); + gh.factory<_i124.DidProfileInfoRepository>(() => repositoriesModule + .didProfileInfoRepository(gh<_i114.DidProfileInfoRepositoryImpl>())); + gh.factory<_i125.GetAuthClaimUseCase>(() => _i125.GetAuthClaimUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i122.GetClaimRevocationNonceUseCase>(() => - _i122.GetClaimRevocationNonceUseCase(gh<_i119.CredentialRepository>())); - gh.factory<_i123.GetDidProfileInfoListUseCase>(() => - _i123.GetDidProfileInfoListUseCase( - gh<_i120.DidProfileInfoRepository>())); - gh.factory<_i124.GetDidProfileInfoUseCase>(() => - _i124.GetDidProfileInfoUseCase(gh<_i120.DidProfileInfoRepository>())); - gh.factoryAsync<_i125.GetEnvUseCase>(() async => _i125.GetEnvUseCase( - await getAsync<_i118.ConfigRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i126.GetClaimRevocationNonceUseCase>(() => + _i126.GetClaimRevocationNonceUseCase(gh<_i123.CredentialRepository>())); + gh.factory<_i127.GetCredentialByIdUseCase>( + () => _i127.GetCredentialByIdUseCase(gh<_i123.CredentialRepository>())); + gh.factory<_i128.GetCredentialByPartialIdUseCase>( + () => _i128.GetCredentialByPartialIdUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), + )); + gh.factory<_i129.GetDidProfileInfoListUseCase>(() => + _i129.GetDidProfileInfoListUseCase( + gh<_i124.DidProfileInfoRepository>())); + gh.factory<_i130.GetDidProfileInfoUseCase>(() => + _i130.GetDidProfileInfoUseCase(gh<_i124.DidProfileInfoRepository>())); + gh.factoryAsync<_i131.GetEnvUseCase>(() async => _i131.GetEnvUseCase( + await getAsync<_i122.ConfigRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i126.Iden3commCredentialRepository>(() => + gh.factory<_i132.Iden3commCredentialRepository>(() => repositoriesModule.iden3commCredentialRepository( - gh<_i113.Iden3commCredentialRepositoryImpl>())); - gh.factory<_i127.Iden3commRepository>(() => repositoriesModule - .iden3commRepository(gh<_i114.Iden3commRepositoryImpl>())); - gh.factoryAsync<_i128.InteractionRepository>(() async => + gh<_i117.Iden3commCredentialRepositoryImpl>())); + gh.factory<_i133.Iden3commRepository>(() => repositoriesModule + .iden3commRepository(gh<_i118.Iden3commRepositoryImpl>())); + gh.factoryAsync<_i134.InteractionRepository>(() async => repositoriesModule.interactionRepository( - await getAsync<_i115.InteractionRepositoryImpl>())); - gh.factoryAsync<_i129.ListenAndStoreNotificationUseCase>(() async => - _i129.ListenAndStoreNotificationUseCase( - await getAsync<_i128.InteractionRepository>())); - gh.factoryAsync<_i130.RPCDataSource>( - () async => _i130.RPCDataSource(await getAsync<_i125.GetEnvUseCase>())); - gh.factory<_i131.RemoveAllClaimsUseCase>(() => _i131.RemoveAllClaimsUseCase( - gh<_i119.CredentialRepository>(), - gh<_i64.StacktraceManager>(), + await getAsync<_i119.InteractionRepositoryImpl>())); + gh.factoryAsync<_i135.ListenAndStoreNotificationUseCase>(() async => + _i135.ListenAndStoreNotificationUseCase( + await getAsync<_i134.InteractionRepository>())); + gh.factoryAsync<_i136.RPCDataSource>( + () async => _i136.RPCDataSource(await getAsync<_i131.GetEnvUseCase>())); + gh.factory<_i137.RemoveAllClaimsUseCase>(() => _i137.RemoveAllClaimsUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i132.RemoveClaimsUseCase>(() => _i132.RemoveClaimsUseCase( - gh<_i119.CredentialRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i138.RemoveClaimsUseCase>(() => _i138.RemoveClaimsUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i133.RemoveDidProfileInfoUseCase>(() => - _i133.RemoveDidProfileInfoUseCase( - gh<_i120.DidProfileInfoRepository>())); - gh.factory<_i134.SMTRepository>( - () => repositoriesModule.smtRepository(gh<_i117.SMTRepositoryImpl>())); - gh.factory<_i135.SaveClaimsUseCase>(() => _i135.SaveClaimsUseCase( - gh<_i119.CredentialRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i139.RemoveDidProfileInfoUseCase>(() => + _i139.RemoveDidProfileInfoUseCase( + gh<_i124.DidProfileInfoRepository>())); + gh.factory<_i140.SMTRepository>( + () => repositoriesModule.smtRepository(gh<_i121.SMTRepositoryImpl>())); + gh.factory<_i141.SaveClaimsUseCase>(() => _i141.SaveClaimsUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i136.SetEnvUseCase>(() async => - _i136.SetEnvUseCase(await getAsync<_i118.ConfigRepository>())); - gh.factory<_i137.UpdateClaimUseCase>(() => _i137.UpdateClaimUseCase( - gh<_i119.CredentialRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i142.SetEnvUseCase>(() async => + _i142.SetEnvUseCase(await getAsync<_i122.ConfigRepository>())); + gh.factory<_i143.UpdateClaimUseCase>(() => _i143.UpdateClaimUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i138.AddDidProfileInfoUseCase>(() => - _i138.AddDidProfileInfoUseCase(gh<_i120.DidProfileInfoRepository>())); - gh.factory<_i139.CleanSchemaCacheUseCase>( - () => _i139.CleanSchemaCacheUseCase(gh<_i127.Iden3commRepository>())); - gh.factory<_i140.GetAuthChallengeUseCase>( - () => _i140.GetAuthChallengeUseCase( - gh<_i127.Iden3commRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i144.AddDidProfileInfoUseCase>(() => + _i144.AddDidProfileInfoUseCase(gh<_i124.DidProfileInfoRepository>())); + gh.factory<_i145.CacheCredentialUseCase>( + () => _i145.CacheCredentialUseCase(gh<_i123.CredentialRepository>())); + gh.factory<_i146.CleanSchemaCacheUseCase>( + () => _i146.CleanSchemaCacheUseCase(gh<_i133.Iden3commRepository>())); + gh.factory<_i147.GetAuthChallengeUseCase>( + () => _i147.GetAuthChallengeUseCase( + gh<_i133.Iden3commRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i141.GetJWZUseCase>(() => _i141.GetJWZUseCase( - gh<_i127.Iden3commRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i148.GetJWZUseCase>(() => _i148.GetJWZUseCase( + gh<_i133.Iden3commRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i142.GetLatestStateUseCase>(() => _i142.GetLatestStateUseCase( - gh<_i134.SMTRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i149.GetLatestStateUseCase>(() => _i149.GetLatestStateUseCase( + gh<_i140.SMTRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i143.GetProofQueryContextUseCase>( - () => _i143.GetProofQueryContextUseCase( - gh<_i126.Iden3commCredentialRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i150.GetProofQueryContextUseCase>( + () => _i150.GetProofQueryContextUseCase( + gh<_i132.Iden3commCredentialRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i144.GetProofRequestsUseCase>( - () => _i144.GetProofRequestsUseCase( - gh<_i143.GetProofQueryContextUseCase>(), - gh<_i87.GetProofQueryUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i151.GetProofRequestsUseCase>( + () => _i151.GetProofRequestsUseCase( + gh<_i150.GetProofQueryContextUseCase>(), + gh<_i90.GetProofQueryUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i145.GetSchemasUseCase>(() => - _i145.GetSchemasUseCase(gh<_i126.Iden3commCredentialRepository>())); - gh.factoryAsync<_i146.IdentityRepositoryImpl>( - () async => _i146.IdentityRepositoryImpl( - gh<_i68.WalletDataSource>(), - gh<_i61.RemoteIdentityDataSource>(), - await getAsync<_i90.StorageIdentityDataSource>(), - await getAsync<_i130.RPCDataSource>(), - gh<_i37.LocalContractFilesDataSource>(), - gh<_i36.LibBabyJubJubDataSource>(), - gh<_i95.LibPolygonIdCoreIdentityDataSource>(), - gh<_i18.EncryptionDbDataSource>(), + gh.factory<_i152.GetSchemasUseCase>(() => + _i152.GetSchemasUseCase(gh<_i132.Iden3commCredentialRepository>())); + gh.factoryAsync<_i153.IdentityRepositoryImpl>( + () async => _i153.IdentityRepositoryImpl( + gh<_i69.WalletDataSource>(), + gh<_i62.RemoteIdentityDataSource>(), + await getAsync<_i93.StorageIdentityDataSource>(), + await getAsync<_i136.RPCDataSource>(), + gh<_i38.LocalContractFilesDataSource>(), + gh<_i37.LibBabyJubJubDataSource>(), + gh<_i98.LibPolygonIdCoreIdentityDataSource>(), + gh<_i19.EncryptionDbDataSource>(), gh<_i12.DestinationPathDataSource>(), - gh<_i27.HexMapper>(), - gh<_i54.PrivateKeyMapper>(), - gh<_i32.IdentityDTOMapper>(), - gh<_i104.RhsNodeMapper>(), - gh<_i65.StateIdentifierMapper>(), - gh<_i99.NodeMapper>(), - gh<_i19.EncryptionKeyMapper>(), - gh<_i107.SecureStorageProfilesDataSource>(), + gh<_i28.HexMapper>(), + gh<_i55.PrivateKeyMapper>(), + gh<_i33.IdentityDTOMapper>(), + gh<_i107.RhsNodeMapper>(), + gh<_i66.StateIdentifierMapper>(), + gh<_i102.NodeMapper>(), + gh<_i20.EncryptionKeyMapper>(), + gh<_i110.SecureStorageProfilesDataSource>(), )); - gh.factoryAsync<_i147.ProofRepositoryImpl>( - () async => _i147.ProofRepositoryImpl( - gh<_i72.WitnessDataSource>(), - gh<_i59.ProverLibDataSource>(), - gh<_i96.LibPolygonIdCoreProofDataSource>(), - gh<_i25.GistMTProofDataSource>(), - gh<_i55.ProofCircuitDataSource>(), - gh<_i61.RemoteIdentityDataSource>(), - gh<_i37.LocalContractFilesDataSource>(), - gh<_i81.CircuitsDownloadDataSource>(), - await getAsync<_i130.RPCDataSource>(), + gh.factoryAsync<_i154.ProofRepositoryImpl>( + () async => _i154.ProofRepositoryImpl( + gh<_i73.WitnessDataSource>(), + gh<_i60.ProverLibDataSource>(), + gh<_i99.LibPolygonIdCoreProofDataSource>(), + gh<_i26.GistMTProofDataSource>(), + gh<_i56.ProofCircuitDataSource>(), + gh<_i62.RemoteIdentityDataSource>(), + gh<_i38.LocalContractFilesDataSource>(), + gh<_i84.CircuitsDownloadDataSource>(), + await getAsync<_i136.RPCDataSource>(), gh<_i8.CircuitTypeMapper>(), - gh<_i78.ZKProofMapper>(), - gh<_i83.ClaimMapper>(), - gh<_i62.RevocationStatusMapper>(), - gh<_i80.AuthProofMapper>(), - gh<_i112.GistMTProofMapper>(), - await getAsync<_i82.CircuitsFilesDataSource>(), - gh<_i64.StacktraceManager>(), + gh<_i81.ZKProofMapper>(), + gh<_i86.ClaimMapper>(), + gh<_i63.RevocationStatusMapper>(), + gh<_i83.AuthProofMapper>(), + gh<_i116.GistMTProofMapper>(), + await getAsync<_i85.CircuitsFilesDataSource>(), + gh<_i65.StacktraceManager>(), )); - gh.factory<_i148.RemoveIdentityStateUseCase>( - () => _i148.RemoveIdentityStateUseCase( - gh<_i134.SMTRepository>(), - gh<_i64.StacktraceManager>(), + gh.factory<_i155.RemoveIdentityStateUseCase>( + () => _i155.RemoveIdentityStateUseCase( + gh<_i140.SMTRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i149.IdentityRepository>(() async => repositoriesModule - .identityRepository(await getAsync<_i146.IdentityRepositoryImpl>())); - gh.factoryAsync<_i150.ProofRepository>(() async => repositoriesModule - .proofRepository(await getAsync<_i147.ProofRepositoryImpl>())); - gh.factoryAsync<_i151.ProveUseCase>(() async => _i151.ProveUseCase( - await getAsync<_i150.ProofRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i156.IdentityRepository>(() async => repositoriesModule + .identityRepository(await getAsync<_i153.IdentityRepositoryImpl>())); + gh.factoryAsync<_i157.ProofRepository>(() async => repositoriesModule + .proofRepository(await getAsync<_i154.ProofRepositoryImpl>())); + gh.factoryAsync<_i158.ProveUseCase>(() async => _i158.ProveUseCase( + await getAsync<_i157.ProofRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i152.SignMessageUseCase>(() async => - _i152.SignMessageUseCase(await getAsync<_i149.IdentityRepository>())); - gh.factoryAsync<_i153.CancelDownloadCircuitsUseCase>(() async => - _i153.CancelDownloadCircuitsUseCase( - await getAsync<_i150.ProofRepository>())); - gh.factoryAsync<_i154.CircuitsFilesExistUseCase>(() async => - _i154.CircuitsFilesExistUseCase( - await getAsync<_i150.ProofRepository>())); - gh.factoryAsync<_i155.DownloadCircuitsUseCase>(() async => - _i155.DownloadCircuitsUseCase(await getAsync<_i150.ProofRepository>())); - gh.factoryAsync<_i156.FetchStateRootsUseCase>(() async => - _i156.FetchStateRootsUseCase( - await getAsync<_i149.IdentityRepository>())); - gh.factoryAsync<_i157.GenerateZKProofUseCase>( - () async => _i157.GenerateZKProofUseCase( - await getAsync<_i150.ProofRepository>(), - await getAsync<_i151.ProveUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i159.SignMessageUseCase>(() async => + _i159.SignMessageUseCase(await getAsync<_i156.IdentityRepository>())); + gh.factoryAsync<_i160.CancelDownloadCircuitsUseCase>(() async => + _i160.CancelDownloadCircuitsUseCase( + await getAsync<_i157.ProofRepository>())); + gh.factoryAsync<_i161.CircuitsFilesExistUseCase>(() async => + _i161.CircuitsFilesExistUseCase( + await getAsync<_i157.ProofRepository>())); + gh.factoryAsync<_i162.DownloadCircuitsUseCase>(() async => + _i162.DownloadCircuitsUseCase(await getAsync<_i157.ProofRepository>())); + gh.factoryAsync<_i163.FetchStateRootsUseCase>(() async => + _i163.FetchStateRootsUseCase( + await getAsync<_i156.IdentityRepository>())); + gh.factoryAsync<_i164.GenerateZKProofUseCase>( + () async => _i164.GenerateZKProofUseCase( + await getAsync<_i157.ProofRepository>(), + await getAsync<_i158.ProveUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i158.GetDidUseCase>(() async => - _i158.GetDidUseCase(await getAsync<_i149.IdentityRepository>())); - gh.factoryAsync<_i159.GetGistMTProofUseCase>( - () async => _i159.GetGistMTProofUseCase( - await getAsync<_i150.ProofRepository>(), - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i158.GetDidUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i165.GetDidUseCase>(() async => + _i165.GetDidUseCase(await getAsync<_i156.IdentityRepository>())); + gh.factoryAsync<_i166.GetGistMTProofUseCase>( + () async => _i166.GetGistMTProofUseCase( + await getAsync<_i157.ProofRepository>(), + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i165.GetDidUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i160.GetIdentitiesUseCase>( - () async => _i160.GetIdentitiesUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i167.GetIdentitiesUseCase>( + () async => _i167.GetIdentitiesUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i161.GetIdentityAuthClaimUseCase>( - () async => _i161.GetIdentityAuthClaimUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i121.GetAuthClaimUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i168.GetIdentityAuthClaimUseCase>( + () async => _i168.GetIdentityAuthClaimUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i125.GetAuthClaimUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i162.GetPrivateKeyUseCase>( - () async => _i162.GetPrivateKeyUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i169.GetPrivateKeyUseCase>( + () async => _i169.GetPrivateKeyUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i163.GetPublicKeysUseCase>( - () async => _i163.GetPublicKeysUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i170.GetPublicKeysUseCase>( + () async => _i170.GetPublicKeysUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i164.IsProofCircuitSupportedUseCase>(() async => - _i164.IsProofCircuitSupportedUseCase( - await getAsync<_i150.ProofRepository>())); - gh.factoryAsync<_i165.LoadCircuitUseCase>( - () async => _i165.LoadCircuitUseCase( - await getAsync<_i150.ProofRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i171.IsProofCircuitSupportedUseCase>(() async => + _i171.IsProofCircuitSupportedUseCase( + await getAsync<_i157.ProofRepository>())); + gh.factoryAsync<_i172.LoadCircuitUseCase>( + () async => _i172.LoadCircuitUseCase( + await getAsync<_i157.ProofRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i166.Proof>(() async => _i166.Proof( - await getAsync<_i157.GenerateZKProofUseCase>(), - await getAsync<_i155.DownloadCircuitsUseCase>(), - await getAsync<_i154.CircuitsFilesExistUseCase>(), - gh<_i56.ProofGenerationStepsStreamManager>(), - await getAsync<_i153.CancelDownloadCircuitsUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i173.Proof>(() async => _i173.Proof( + await getAsync<_i164.GenerateZKProofUseCase>(), + await getAsync<_i162.DownloadCircuitsUseCase>(), + await getAsync<_i161.CircuitsFilesExistUseCase>(), + gh<_i57.ProofGenerationStepsStreamManager>(), + await getAsync<_i160.CancelDownloadCircuitsUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i167.CreateIdentityStateUseCase>( - () async => _i167.CreateIdentityStateUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i134.SMTRepository>(), - await getAsync<_i161.GetIdentityAuthClaimUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i174.CreateIdentityStateUseCase>( + () async => _i174.CreateIdentityStateUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i140.SMTRepository>(), + await getAsync<_i168.GetIdentityAuthClaimUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i168.FetchIdentityStateUseCase>( - () async => _i168.FetchIdentityStateUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i158.GetDidUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i175.FetchIdentityStateUseCase>( + () async => _i175.FetchIdentityStateUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i165.GetDidUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i169.GenerateNonRevProofUseCase>( - () async => _i169.GenerateNonRevProofUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i119.CredentialRepository>(), - await getAsync<_i168.FetchIdentityStateUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i176.GenerateNonRevProofUseCase>( + () async => _i176.GenerateNonRevProofUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i123.CredentialRepository>(), + await getAsync<_i175.FetchIdentityStateUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i170.GetFiltersUseCase>( - () async => _i170.GetFiltersUseCase( - gh<_i126.Iden3commCredentialRepository>(), - await getAsync<_i164.IsProofCircuitSupportedUseCase>(), - gh<_i144.GetProofRequestsUseCase>(), + gh.factoryAsync<_i177.GetFiltersUseCase>( + () async => _i177.GetFiltersUseCase( + gh<_i132.Iden3commCredentialRepository>(), + await getAsync<_i171.IsProofCircuitSupportedUseCase>(), + gh<_i151.GetProofRequestsUseCase>(), )); - gh.factoryAsync<_i171.GetGenesisStateUseCase>( - () async => _i171.GetGenesisStateUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i134.SMTRepository>(), - await getAsync<_i161.GetIdentityAuthClaimUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i178.GetGenesisStateUseCase>( + () async => _i178.GetGenesisStateUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i140.SMTRepository>(), + await getAsync<_i168.GetIdentityAuthClaimUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i172.GetNonRevProofUseCase>( - () async => _i172.GetNonRevProofUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i119.CredentialRepository>(), - await getAsync<_i168.FetchIdentityStateUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i179.GetNonRevProofUseCase>( + () async => _i179.GetNonRevProofUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i123.CredentialRepository>(), + await getAsync<_i175.FetchIdentityStateUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i173.GetClaimRevocationStatusUseCase>( - () async => _i173.GetClaimRevocationStatusUseCase( - gh<_i119.CredentialRepository>(), - await getAsync<_i169.GenerateNonRevProofUseCase>(), - await getAsync<_i172.GetNonRevProofUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i180.GetClaimRevocationStatusUseCase>( + () async => _i180.GetClaimRevocationStatusUseCase( + gh<_i123.CredentialRepository>(), + await getAsync<_i176.GenerateNonRevProofUseCase>(), + await getAsync<_i179.GetNonRevProofUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i174.GetDidIdentifierUseCase>( - () async => _i174.GetDidIdentifierUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i171.GetGenesisStateUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i181.GetDidIdentifierUseCase>( + () async => _i181.GetDidIdentifierUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i178.GetGenesisStateUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i175.GetIdentityUseCase>( - () async => _i175.GetIdentityUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i158.GetDidUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i182.GetIdentityUseCase>( + () async => _i182.GetIdentityUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i165.GetDidUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i176.GetInteractionsUseCase>( - () async => _i176.GetInteractionsUseCase( - await getAsync<_i128.InteractionRepository>(), + gh.factoryAsync<_i183.GetInteractionsUseCase>( + () async => _i183.GetInteractionsUseCase( + await getAsync<_i134.InteractionRepository>(), gh<_i7.CheckProfileValidityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), )); - gh.factoryAsync<_i177.RemoveInteractionsUseCase>( - () async => _i177.RemoveInteractionsUseCase( - await getAsync<_i128.InteractionRepository>(), - await getAsync<_i175.GetIdentityUseCase>(), + gh.factoryAsync<_i184.RemoveInteractionsUseCase>( + () async => _i184.RemoveInteractionsUseCase( + await getAsync<_i134.InteractionRepository>(), + await getAsync<_i182.GetIdentityUseCase>(), )); - gh.factoryAsync<_i178.AddInteractionUseCase>( - () async => _i178.AddInteractionUseCase( - await getAsync<_i128.InteractionRepository>(), + gh.factoryAsync<_i185.AddInteractionUseCase>( + () async => _i185.AddInteractionUseCase( + await getAsync<_i134.InteractionRepository>(), gh<_i7.CheckProfileValidityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), )); - gh.factoryAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>( - () async => _i179.CheckProfileAndDidCurrentEnvUseCase( + gh.factoryAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>( + () async => _i186.CheckProfileAndDidCurrentEnvUseCase( gh<_i7.CheckProfileValidityUseCase>(), - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), + )); + gh.factoryAsync<_i187.GenerateIden3commProofUseCase>( + () async => _i187.GenerateIden3commProofUseCase( + await getAsync<_i156.IdentityRepository>(), + gh<_i140.SMTRepository>(), + await getAsync<_i157.ProofRepository>(), + await getAsync<_i158.ProveUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), + gh<_i125.GetAuthClaimUseCase>(), + await getAsync<_i166.GetGistMTProofUseCase>(), + await getAsync<_i165.GetDidUseCase>(), + await getAsync<_i159.SignMessageUseCase>(), + gh<_i149.GetLatestStateUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i180.GenerateIden3commProofUseCase>( - () async => _i180.GenerateIden3commProofUseCase( - await getAsync<_i149.IdentityRepository>(), - gh<_i134.SMTRepository>(), - await getAsync<_i150.ProofRepository>(), - await getAsync<_i151.ProveUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), - gh<_i121.GetAuthClaimUseCase>(), - await getAsync<_i159.GetGistMTProofUseCase>(), - await getAsync<_i158.GetDidUseCase>(), - await getAsync<_i152.SignMessageUseCase>(), - gh<_i142.GetLatestStateUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i188.GetAuthInputsUseCase>( + () async => _i188.GetAuthInputsUseCase( + await getAsync<_i182.GetIdentityUseCase>(), + gh<_i125.GetAuthClaimUseCase>(), + await getAsync<_i159.SignMessageUseCase>(), + await getAsync<_i166.GetGistMTProofUseCase>(), + gh<_i149.GetLatestStateUseCase>(), + gh<_i133.Iden3commRepository>(), + await getAsync<_i156.IdentityRepository>(), + gh<_i140.SMTRepository>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i181.GetAuthInputsUseCase>( - () async => _i181.GetAuthInputsUseCase( - await getAsync<_i175.GetIdentityUseCase>(), - gh<_i121.GetAuthClaimUseCase>(), - await getAsync<_i152.SignMessageUseCase>(), - await getAsync<_i159.GetGistMTProofUseCase>(), - gh<_i142.GetLatestStateUseCase>(), - gh<_i127.Iden3commRepository>(), - await getAsync<_i149.IdentityRepository>(), - gh<_i134.SMTRepository>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i189.GetAuthTokenUseCase>( + () async => _i189.GetAuthTokenUseCase( + await getAsync<_i172.LoadCircuitUseCase>(), + gh<_i148.GetJWZUseCase>(), + gh<_i147.GetAuthChallengeUseCase>(), + await getAsync<_i188.GetAuthInputsUseCase>(), + await getAsync<_i158.ProveUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i182.GetAuthTokenUseCase>( - () async => _i182.GetAuthTokenUseCase( - await getAsync<_i165.LoadCircuitUseCase>(), - gh<_i141.GetJWZUseCase>(), - gh<_i140.GetAuthChallengeUseCase>(), - await getAsync<_i181.GetAuthInputsUseCase>(), - await getAsync<_i151.ProveUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i190.GetCurrentEnvDidIdentifierUseCase>( + () async => _i190.GetCurrentEnvDidIdentifierUseCase( + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i183.GetCurrentEnvDidIdentifierUseCase>( - () async => _i183.GetCurrentEnvDidIdentifierUseCase( - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i191.GetProfilesUseCase>( + () async => _i191.GetProfilesUseCase( + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i184.GetProfilesUseCase>( - () async => _i184.GetProfilesUseCase( - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i192.RefreshCredentialUseCase>( + () async => _i192.RefreshCredentialUseCase( + gh<_i123.CredentialRepository>(), + gh<_i65.StacktraceManager>(), + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i189.GetAuthTokenUseCase>(), + gh<_i132.Iden3commCredentialRepository>(), + gh<_i138.RemoveClaimsUseCase>(), + gh<_i141.SaveClaimsUseCase>(), )); - gh.factoryAsync<_i185.UpdateInteractionUseCase>( - () async => _i185.UpdateInteractionUseCase( - await getAsync<_i128.InteractionRepository>(), + gh.factoryAsync<_i193.UpdateInteractionUseCase>( + () async => _i193.UpdateInteractionUseCase( + await getAsync<_i134.InteractionRepository>(), gh<_i7.CheckProfileValidityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i178.AddInteractionUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i185.AddInteractionUseCase>(), )); - gh.factoryAsync<_i186.BackupIdentityUseCase>( - () async => _i186.BackupIdentityUseCase( - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i194.BackupIdentityUseCase>( + () async => _i194.BackupIdentityUseCase( + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i187.CheckIdentityValidityUseCase>( - () async => _i187.CheckIdentityValidityUseCase( - await getAsync<_i162.GetPrivateKeyUseCase>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i195.CheckIdentityValidityUseCase>( + () async => _i195.CheckIdentityValidityUseCase( + await getAsync<_i169.GetPrivateKeyUseCase>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i188.CreateIdentityUseCase>( - () async => _i188.CreateIdentityUseCase( - await getAsync<_i163.GetPublicKeysUseCase>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i196.CreateIdentityUseCase>( + () async => _i196.CreateIdentityUseCase( + await getAsync<_i170.GetPublicKeysUseCase>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i189.CreateProfilesUseCase>( - () async => _i189.CreateProfilesUseCase( - await getAsync<_i163.GetPublicKeysUseCase>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i197.CreateProfilesUseCase>( + () async => _i197.CreateProfilesUseCase( + await getAsync<_i170.GetPublicKeysUseCase>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i190.FetchAndSaveClaimsUseCase>( - () async => _i190.FetchAndSaveClaimsUseCase( - gh<_i126.Iden3commCredentialRepository>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - gh<_i23.GetFetchRequestsUseCase>(), - await getAsync<_i182.GetAuthTokenUseCase>(), - gh<_i135.SaveClaimsUseCase>(), - await getAsync<_i173.GetClaimRevocationStatusUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i198.FetchAndSaveClaimsUseCase>( + () async => _i198.FetchAndSaveClaimsUseCase( + gh<_i132.Iden3commCredentialRepository>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + gh<_i24.GetFetchRequestsUseCase>(), + await getAsync<_i189.GetAuthTokenUseCase>(), + gh<_i141.SaveClaimsUseCase>(), + await getAsync<_i180.GetClaimRevocationStatusUseCase>(), + gh<_i145.CacheCredentialUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i191.GetClaimsUseCase>(() async => _i191.GetClaimsUseCase( - gh<_i119.CredentialRepository>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i199.GetClaimsUseCase>(() async => _i199.GetClaimsUseCase( + gh<_i123.CredentialRepository>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i192.GetIden3commClaimsRevNonceUseCase>( - () async => _i192.GetIden3commClaimsRevNonceUseCase( - gh<_i126.Iden3commCredentialRepository>(), - await getAsync<_i191.GetClaimsUseCase>(), - gh<_i122.GetClaimRevocationNonceUseCase>(), - await getAsync<_i164.IsProofCircuitSupportedUseCase>(), - gh<_i144.GetProofRequestsUseCase>(), + gh.factoryAsync<_i200.GetIden3commClaimsRevNonceUseCase>( + () async => _i200.GetIden3commClaimsRevNonceUseCase( + gh<_i132.Iden3commCredentialRepository>(), + await getAsync<_i199.GetClaimsUseCase>(), + gh<_i126.GetClaimRevocationNonceUseCase>(), + await getAsync<_i171.IsProofCircuitSupportedUseCase>(), + gh<_i151.GetProofRequestsUseCase>(), )); - gh.factoryAsync<_i193.GetIden3commClaimsUseCase>( - () async => _i193.GetIden3commClaimsUseCase( - gh<_i126.Iden3commCredentialRepository>(), - await getAsync<_i191.GetClaimsUseCase>(), - await getAsync<_i173.GetClaimRevocationStatusUseCase>(), - gh<_i122.GetClaimRevocationNonceUseCase>(), - gh<_i137.UpdateClaimUseCase>(), - await getAsync<_i164.IsProofCircuitSupportedUseCase>(), - gh<_i144.GetProofRequestsUseCase>(), + gh.factoryAsync<_i201.GetIden3commClaimsUseCase>( + () async => _i201.GetIden3commClaimsUseCase( + gh<_i132.Iden3commCredentialRepository>(), + await getAsync<_i199.GetClaimsUseCase>(), + await getAsync<_i180.GetClaimRevocationStatusUseCase>(), + gh<_i126.GetClaimRevocationNonceUseCase>(), + gh<_i143.UpdateClaimUseCase>(), + await getAsync<_i171.IsProofCircuitSupportedUseCase>(), + gh<_i151.GetProofRequestsUseCase>(), gh<_i8.CircuitTypeMapper>(), - gh<_i64.StacktraceManager>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i194.GetIden3commProofsUseCase>( - () async => _i194.GetIden3commProofsUseCase( - await getAsync<_i150.ProofRepository>(), - await getAsync<_i193.GetIden3commClaimsUseCase>(), - await getAsync<_i180.GenerateIden3commProofUseCase>(), - await getAsync<_i164.IsProofCircuitSupportedUseCase>(), - gh<_i144.GetProofRequestsUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), - gh<_i56.ProofGenerationStepsStreamManager>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i202.GetIden3commProofsUseCase>( + () async => _i202.GetIden3commProofsUseCase( + await getAsync<_i157.ProofRepository>(), + await getAsync<_i201.GetIden3commClaimsUseCase>(), + await getAsync<_i187.GenerateIden3commProofUseCase>(), + await getAsync<_i171.IsProofCircuitSupportedUseCase>(), + gh<_i151.GetProofRequestsUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), + gh<_i57.ProofGenerationStepsStreamManager>(), + gh<_i65.StacktraceManager>(), + await getAsync<_i189.GetAuthTokenUseCase>(), + gh<_i132.Iden3commCredentialRepository>(), + gh<_i138.RemoveClaimsUseCase>(), + gh<_i141.SaveClaimsUseCase>(), + await getAsync<_i192.RefreshCredentialUseCase>(), )); - gh.factoryAsync<_i195.UpdateIdentityUseCase>( - () async => _i195.UpdateIdentityUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i188.CreateIdentityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), + gh.factoryAsync<_i203.UpdateIdentityUseCase>( + () async => _i203.UpdateIdentityUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i196.CreateIdentityUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), )); - gh.factoryAsync<_i196.AddIdentityUseCase>( - () async => _i196.AddIdentityUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i188.CreateIdentityUseCase>(), - await getAsync<_i167.CreateIdentityStateUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i204.AddIdentityUseCase>( + () async => _i204.AddIdentityUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i196.CreateIdentityUseCase>(), + await getAsync<_i174.CreateIdentityStateUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i197.AddNewIdentityUseCase>( - () async => _i197.AddNewIdentityUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i196.AddIdentityUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i205.AddNewIdentityUseCase>( + () async => _i205.AddNewIdentityUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i204.AddIdentityUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i198.AddProfileUseCase>( - () async => _i198.AddProfileUseCase( - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i195.UpdateIdentityUseCase>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - await getAsync<_i189.CreateProfilesUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i206.AddProfileUseCase>( + () async => _i206.AddProfileUseCase( + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i203.UpdateIdentityUseCase>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + await getAsync<_i197.CreateProfilesUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i199.AuthenticateUseCase>( - () async => _i199.AuthenticateUseCase( - gh<_i127.Iden3commRepository>(), - await getAsync<_i194.GetIden3commProofsUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - await getAsync<_i182.GetAuthTokenUseCase>(), - await getAsync<_i125.GetEnvUseCase>(), - await getAsync<_i111.GetPackageNameUseCase>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - gh<_i56.ProofGenerationStepsStreamManager>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i207.AuthenticateUseCase>( + () async => _i207.AuthenticateUseCase( + gh<_i133.Iden3commRepository>(), + await getAsync<_i202.GetIden3commProofsUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + await getAsync<_i189.GetAuthTokenUseCase>(), + await getAsync<_i131.GetEnvUseCase>(), + await getAsync<_i115.GetPackageNameUseCase>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + gh<_i57.ProofGenerationStepsStreamManager>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i200.Credential>(() async => _i200.Credential( - gh<_i135.SaveClaimsUseCase>(), - await getAsync<_i191.GetClaimsUseCase>(), - gh<_i132.RemoveClaimsUseCase>(), - await getAsync<_i173.GetClaimRevocationStatusUseCase>(), - gh<_i137.UpdateClaimUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i208.Credential>(() async => _i208.Credential( + gh<_i141.SaveClaimsUseCase>(), + await getAsync<_i199.GetClaimsUseCase>(), + gh<_i138.RemoveClaimsUseCase>(), + await getAsync<_i180.GetClaimRevocationStatusUseCase>(), + gh<_i143.UpdateClaimUseCase>(), + gh<_i65.StacktraceManager>(), + await getAsync<_i192.RefreshCredentialUseCase>(), + gh<_i127.GetCredentialByIdUseCase>(), + gh<_i128.GetCredentialByPartialIdUseCase>(), )); - gh.factoryAsync<_i201.Iden3comm>(() async => _i201.Iden3comm( - await getAsync<_i190.FetchAndSaveClaimsUseCase>(), - gh<_i86.GetIden3MessageUseCase>(), - gh<_i145.GetSchemasUseCase>(), - await getAsync<_i199.AuthenticateUseCase>(), - await getAsync<_i170.GetFiltersUseCase>(), - await getAsync<_i193.GetIden3commClaimsUseCase>(), - await getAsync<_i192.GetIden3commClaimsRevNonceUseCase>(), - await getAsync<_i194.GetIden3commProofsUseCase>(), - await getAsync<_i176.GetInteractionsUseCase>(), - await getAsync<_i178.AddInteractionUseCase>(), - await getAsync<_i177.RemoveInteractionsUseCase>(), - await getAsync<_i185.UpdateInteractionUseCase>(), - gh<_i139.CleanSchemaCacheUseCase>(), - gh<_i64.StacktraceManager>(), - gh<_i138.AddDidProfileInfoUseCase>(), - gh<_i124.GetDidProfileInfoUseCase>(), - gh<_i123.GetDidProfileInfoListUseCase>(), - gh<_i133.RemoveDidProfileInfoUseCase>(), + gh.factoryAsync<_i209.Iden3comm>(() async => _i209.Iden3comm( + await getAsync<_i198.FetchAndSaveClaimsUseCase>(), + gh<_i89.GetIden3MessageUseCase>(), + gh<_i152.GetSchemasUseCase>(), + await getAsync<_i207.AuthenticateUseCase>(), + await getAsync<_i177.GetFiltersUseCase>(), + await getAsync<_i201.GetIden3commClaimsUseCase>(), + await getAsync<_i200.GetIden3commClaimsRevNonceUseCase>(), + await getAsync<_i202.GetIden3commProofsUseCase>(), + await getAsync<_i183.GetInteractionsUseCase>(), + await getAsync<_i185.AddInteractionUseCase>(), + await getAsync<_i184.RemoveInteractionsUseCase>(), + await getAsync<_i193.UpdateInteractionUseCase>(), + gh<_i146.CleanSchemaCacheUseCase>(), + gh<_i65.StacktraceManager>(), + gh<_i144.AddDidProfileInfoUseCase>(), + gh<_i130.GetDidProfileInfoUseCase>(), + gh<_i129.GetDidProfileInfoListUseCase>(), + gh<_i139.RemoveDidProfileInfoUseCase>(), )); - gh.factoryAsync<_i202.RemoveProfileUseCase>( - () async => _i202.RemoveProfileUseCase( - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i195.UpdateIdentityUseCase>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - await getAsync<_i189.CreateProfilesUseCase>(), - gh<_i148.RemoveIdentityStateUseCase>(), - gh<_i131.RemoveAllClaimsUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i210.RemoveProfileUseCase>( + () async => _i210.RemoveProfileUseCase( + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i203.UpdateIdentityUseCase>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + await getAsync<_i197.CreateProfilesUseCase>(), + gh<_i155.RemoveIdentityStateUseCase>(), + gh<_i137.RemoveAllClaimsUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i203.RestoreProfilesUseCase>( - () async => _i203.RestoreProfilesUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i195.UpdateIdentityUseCase>(), + gh.factoryAsync<_i211.RestoreProfilesUseCase>( + () async => _i211.RestoreProfilesUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i203.UpdateIdentityUseCase>(), )); - gh.factoryAsync<_i204.RemoveIdentityUseCase>( - () async => _i204.RemoveIdentityUseCase( - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i184.GetProfilesUseCase>(), - await getAsync<_i202.RemoveProfileUseCase>(), - gh<_i148.RemoveIdentityStateUseCase>(), - gh<_i131.RemoveAllClaimsUseCase>(), - await getAsync<_i179.CheckProfileAndDidCurrentEnvUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i212.RemoveIdentityUseCase>( + () async => _i212.RemoveIdentityUseCase( + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i191.GetProfilesUseCase>(), + await getAsync<_i210.RemoveProfileUseCase>(), + gh<_i155.RemoveIdentityStateUseCase>(), + gh<_i137.RemoveAllClaimsUseCase>(), + await getAsync<_i186.CheckProfileAndDidCurrentEnvUseCase>(), + gh<_i65.StacktraceManager>(), )); - gh.factoryAsync<_i205.RestoreIdentityUseCase>( - () async => _i205.RestoreIdentityUseCase( - await getAsync<_i196.AddIdentityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i149.IdentityRepository>(), - await getAsync<_i183.GetCurrentEnvDidIdentifierUseCase>(), - await getAsync<_i203.RestoreProfilesUseCase>(), + gh.factoryAsync<_i213.RestoreIdentityUseCase>( + () async => _i213.RestoreIdentityUseCase( + await getAsync<_i204.AddIdentityUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i156.IdentityRepository>(), + await getAsync<_i190.GetCurrentEnvDidIdentifierUseCase>(), + await getAsync<_i211.RestoreProfilesUseCase>(), )); - gh.factoryAsync<_i206.Identity>(() async => _i206.Identity( - await getAsync<_i187.CheckIdentityValidityUseCase>(), - await getAsync<_i162.GetPrivateKeyUseCase>(), - await getAsync<_i197.AddNewIdentityUseCase>(), - await getAsync<_i205.RestoreIdentityUseCase>(), - await getAsync<_i186.BackupIdentityUseCase>(), - await getAsync<_i175.GetIdentityUseCase>(), - await getAsync<_i160.GetIdentitiesUseCase>(), - await getAsync<_i204.RemoveIdentityUseCase>(), - await getAsync<_i174.GetDidIdentifierUseCase>(), - await getAsync<_i152.SignMessageUseCase>(), - await getAsync<_i168.FetchIdentityStateUseCase>(), - await getAsync<_i198.AddProfileUseCase>(), - await getAsync<_i184.GetProfilesUseCase>(), - await getAsync<_i202.RemoveProfileUseCase>(), - await getAsync<_i158.GetDidUseCase>(), - gh<_i64.StacktraceManager>(), + gh.factoryAsync<_i214.Identity>(() async => _i214.Identity( + await getAsync<_i195.CheckIdentityValidityUseCase>(), + await getAsync<_i169.GetPrivateKeyUseCase>(), + await getAsync<_i205.AddNewIdentityUseCase>(), + await getAsync<_i213.RestoreIdentityUseCase>(), + await getAsync<_i194.BackupIdentityUseCase>(), + await getAsync<_i182.GetIdentityUseCase>(), + await getAsync<_i167.GetIdentitiesUseCase>(), + await getAsync<_i212.RemoveIdentityUseCase>(), + await getAsync<_i181.GetDidIdentifierUseCase>(), + await getAsync<_i159.SignMessageUseCase>(), + await getAsync<_i175.FetchIdentityStateUseCase>(), + await getAsync<_i206.AddProfileUseCase>(), + await getAsync<_i191.GetProfilesUseCase>(), + await getAsync<_i210.RemoveProfileUseCase>(), + await getAsync<_i165.GetDidUseCase>(), + gh<_i65.StacktraceManager>(), )); return this; } } -class _$PlatformModule extends _i207.PlatformModule {} +class _$PlatformModule extends _i215.PlatformModule {} -class _$NetworkModule extends _i207.NetworkModule {} +class _$NetworkModule extends _i215.NetworkModule {} -class _$DatabaseModule extends _i207.DatabaseModule {} +class _$DatabaseModule extends _i215.DatabaseModule {} -class _$FilesManagerModule extends _i207.FilesManagerModule {} +class _$FilesManagerModule extends _i215.FilesManagerModule {} -class _$EncryptionModule extends _i207.EncryptionModule {} +class _$EncryptionModule extends _i215.EncryptionModule {} -class _$LoggerModule extends _i207.LoggerModule {} +class _$LoggerModule extends _i215.LoggerModule {} -class _$ChannelModule extends _i207.ChannelModule {} +class _$ChannelModule extends _i215.ChannelModule {} -class _$RepositoriesModule extends _i207.RepositoriesModule {} +class _$RepositoriesModule extends _i215.RepositoriesModule {} diff --git a/lib/sdk/iden3comm.dart b/lib/sdk/iden3comm.dart index 0efcf8d4..80f102bc 100644 --- a/lib/sdk/iden3comm.dart +++ b/lib/sdk/iden3comm.dart @@ -115,16 +115,18 @@ abstract class PolygonIdSdkIden3comm { /// /// The [privateKey] is the key used to access all the sensitive info from the identity /// and also to realize operations like generating proofs - Future> getProofs( - {required Iden3MessageEntity message, - required String genesisDid, - BigInt? profileNonce, - required String privateKey, - String? challenge, - String? ethereumUrl, - String? stateContractAddr, - String? ipfsNodeUrl, - Map>? nonRevocationProofs}); + Future> getProofs({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + String? challenge, + String? ethereumUrl, + String? stateContractAddr, + String? ipfsNodeUrl, + Map>? nonRevocationProofs, + Map? transactionData, + }); /// Authenticate response from iden3Message sharing the needed /// (if any) proofs requested by it @@ -295,20 +297,20 @@ class Iden3comm implements PolygonIdSdkIden3comm { @override Future getIden3Message({required String message}) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getIden3MessageUseCase.execute(param: message); } @override Future>> getSchemas( {required Iden3MessageEntity message}) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getSchemasUseCase.execute(param: message); } @override Future> getFilters({required Iden3MessageEntity message}) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getFiltersUseCase.execute(param: message); } @@ -318,7 +320,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { required String genesisDid, BigInt? profileNonce, required String privateKey}) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); if (message is! OfferIden3MessageEntity) { _stacktraceManager.addTrace( '[fetchAndSaveClaims] Invalid message type: ${message.messageType}'); @@ -340,7 +342,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { BigInt? profileNonce, required String privateKey, Map>? nonRevocationProofs}) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getIden3commClaimsUseCase.execute( param: GetIden3commClaimsParam( message: message, @@ -358,7 +360,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { BigInt? profileNonce, required String privateKey, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getIden3commClaimsRevNonceUseCase.execute( param: GetIden3commClaimsRevNonceParam( message: message, @@ -369,17 +371,19 @@ class Iden3comm implements PolygonIdSdkIden3comm { } @override - Future> getProofs( - {required Iden3MessageEntity message, - required String genesisDid, - BigInt? profileNonce, - required String privateKey, - String? challenge, - String? ethereumUrl, - String? stateContractAddr, - String? ipfsNodeUrl, - Map>? nonRevocationProofs}) { - _stacktraceManager.clear(); + Future> getProofs({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + String? challenge, + String? ethereumUrl, + String? stateContractAddr, + String? ipfsNodeUrl, + Map>? nonRevocationProofs, + Map? transactionData, + }) { + _stacktraceManager.clearStacktrace(); return _getIden3commProofsUseCase.execute( param: GetIden3commProofsParam( message: message, @@ -391,6 +395,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { stateContractAddr: stateContractAddr, ipfsNodeUrl: ipfsNodeUrl, nonRevocationProofs: nonRevocationProofs, + transactionData: transactionData, )); } @@ -404,7 +409,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { Map>? nonRevocationProofs, String? challenge, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); if (message is! AuthIden3MessageEntity) { _stacktraceManager.addTrace( '[authenticate] Invalid message type: ${message.messageType}'); @@ -434,7 +439,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { List? states, List? filters, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _getInteractionsUseCase.execute( param: GetInteractionsParam( genesisDid: genesisDid, @@ -451,7 +456,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { String? privateKey, required List ids, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _removeInteractionsUseCase.execute( param: RemoveInteractionsParam( genesisDid: genesisDid, privateKey: privateKey, ids: ids)); @@ -463,7 +468,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { String? genesisDid, String? privateKey, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _addInteractionUseCase.execute( param: AddInteractionParam( genesisDid: genesisDid, @@ -479,7 +484,7 @@ class Iden3comm implements PolygonIdSdkIden3comm { String? privateKey, InteractionState? state, }) { - _stacktraceManager.clear(); + _stacktraceManager.clearStacktrace(); return _updateInteractionUseCase.execute( param: UpdateInteractionParam( genesisDid: genesisDid, diff --git a/lib/sdk/polygonid_flutter_channel.dart b/lib/sdk/polygonid_flutter_channel.dart index a3b06353..7005841e 100644 --- a/lib/sdk/polygonid_flutter_channel.dart +++ b/lib/sdk/polygonid_flutter_channel.dart @@ -17,6 +17,7 @@ import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/i import 'package:polygonid_flutter_sdk/identity/domain/entities/did_entity.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/identity_entity.dart'; import 'package:polygonid_flutter_sdk/identity/domain/entities/private_identity_entity.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/circuit_data_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/download_info_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/gist_mtproof_entity.dart'; @@ -373,14 +374,21 @@ class PolygonIdFlutterChannel case 'startDownloadCircuits': return _listen( name: downloadCircuitsName, - stream: initCircuitsDownloadAndGetInfoStream, + stream: initCircuitsDownloadAndGetInfoStream( + circuitsToDownload: + (call.arguments['circuitsToDownload'] as List) + .map((e) => CircuitsToDownloadParam.fromJson( + jsonDecode(e as String))) + .toList(), + ), onDone: () { _closeSubscription('downloadCircuits') .then((_) => downloadCircuitsName); }); case 'isAlreadyDownloadedCircuitsFromServer': - return isAlreadyDownloadedCircuitsFromServer(); + return isAlreadyDownloadedCircuitsFromServer( + circuitsFileName: call.arguments['circuitsFileName']); case 'cancelDownloadCircuits': return cancelDownloadCircuits() @@ -534,26 +542,30 @@ class PolygonIdFlutterChannel } @override - Future> getProofs( - {required Iden3MessageEntity message, - required String genesisDid, - BigInt? profileNonce, - required String privateKey, - String? challenge, - String? ethereumUrl, - String? stateContractAddr, - String? ipfsNodeUrl, - Map>? nonRevocationProofs}) { + Future> getProofs({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + String? challenge, + String? ethereumUrl, + String? stateContractAddr, + String? ipfsNodeUrl, + Map>? nonRevocationProofs, + Map? transactionData, + }) { return _polygonIdSdk.iden3comm.getProofs( - message: message, - genesisDid: genesisDid, - profileNonce: profileNonce, - privateKey: privateKey, - challenge: challenge, - ethereumUrl: ethereumUrl, - stateContractAddr: stateContractAddr, - ipfsNodeUrl: ipfsNodeUrl, - nonRevocationProofs: nonRevocationProofs); + message: message, + genesisDid: genesisDid, + profileNonce: profileNonce, + privateKey: privateKey, + challenge: challenge, + ethereumUrl: ethereumUrl, + stateContractAddr: stateContractAddr, + ipfsNodeUrl: ipfsNodeUrl, + nonRevocationProofs: nonRevocationProofs, + transactionData: transactionData, + ); } @override @@ -767,12 +779,19 @@ class PolygonIdFlutterChannel /// Proof @override - Stream get initCircuitsDownloadAndGetInfoStream => - _polygonIdSdk.proof.initCircuitsDownloadAndGetInfoStream; + Stream initCircuitsDownloadAndGetInfoStream({ + required List circuitsToDownload, + }) { + return _polygonIdSdk.proof.initCircuitsDownloadAndGetInfoStream( + circuitsToDownload: circuitsToDownload, + ); + } @override - Future isAlreadyDownloadedCircuitsFromServer() { - return _polygonIdSdk.proof.isAlreadyDownloadedCircuitsFromServer(); + Future isAlreadyDownloadedCircuitsFromServer( + {required String circuitsFileName}) { + return _polygonIdSdk.proof.isAlreadyDownloadedCircuitsFromServer( + circuitsFileName: circuitsFileName); } @override @@ -873,4 +892,33 @@ class PolygonIdFlutterChannel // TODO: implement restoreProfiles throw UnimplementedError(); } + + @override + Future refreshCredential({ + required String genesisDid, + required String privateKey, + required ClaimEntity credential, + }) { + // TODO: implement refreshCredential + throw UnimplementedError(); + } + + @override + Future? getCredentialById( + {required String credentialId, + required String genesisDid, + required String privateKey}) { + // TODO: implement getCredentialById + throw UnimplementedError(); + } + + @override + Future? getCredentialByPartialId({ + required String partialCredentialId, + required String genesisDid, + required String privateKey, + }) { + // TODO: implement getCredentialByPartialId + throw UnimplementedError(); + } } diff --git a/lib/sdk/proof.dart b/lib/sdk/proof.dart index 6e31ca8f..0620a134 100644 --- a/lib/sdk/proof.dart +++ b/lib/sdk/proof.dart @@ -7,6 +7,7 @@ import 'package:injectable/injectable.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/circuits_to_download_param.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/download_info_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/gist_mtproof_entity.dart'; import 'package:polygonid_flutter_sdk/proof/domain/entities/mtproof_entity.dart'; @@ -38,9 +39,12 @@ abstract class PolygonIdSdkProof { String? signature, Map? config}); - Stream get initCircuitsDownloadAndGetInfoStream; + Stream initCircuitsDownloadAndGetInfoStream({ + required List circuitsToDownload, + }); - Future isAlreadyDownloadedCircuitsFromServer(); + Future isAlreadyDownloadedCircuitsFromServer( + {required String circuitsFileName}); Stream proofGenerationStepsStream(); @@ -66,54 +70,67 @@ class Proof implements PolygonIdSdkProof { ); @override - Future prove( - {required String identifier, - required BigInt profileNonce, - required BigInt claimSubjectProfileNonce, - required ClaimEntity credential, - required CircuitDataEntity circuitData, - required Map proofScopeRequest, - List? authClaim, - MTProofEntity? incProof, - MTProofEntity? nonRevProof, - GistMTProofEntity? gistProof, - Map? treeState, - String? challenge, - String? signature, - Map? config}) { + Future prove({ + required String identifier, + required BigInt profileNonce, + required BigInt claimSubjectProfileNonce, + required ClaimEntity credential, + required CircuitDataEntity circuitData, + required Map proofScopeRequest, + List? authClaim, + MTProofEntity? incProof, + MTProofEntity? nonRevProof, + GistMTProofEntity? gistProof, + Map? treeState, + String? challenge, + String? signature, + Map? config, + String? verifierId, + String? linkNonce, + Map? transactionData, + }) { _stacktraceManager.clear(); _stacktraceManager.addTrace("PolygonIdSdk.Proof.prove called"); return generateZKProofUseCase.execute( param: GenerateZKProofParam( - identifier, - profileNonce, - claimSubjectProfileNonce, - credential, - circuitData, - authClaim, - incProof, - nonRevProof, - gistProof, - treeState, - challenge, - signature, - proofScopeRequest, - config)); + identifier, + profileNonce, + claimSubjectProfileNonce, + credential, + circuitData, + authClaim, + incProof, + nonRevProof, + gistProof, + treeState, + challenge, + signature, + proofScopeRequest, + config, + verifierId, + linkNonce, + transactionData, + )); } /// @override - Future isAlreadyDownloadedCircuitsFromServer() async { + Future isAlreadyDownloadedCircuitsFromServer( + {required String circuitsFileName}) async { _stacktraceManager.clear(); _stacktraceManager.addTrace( "PolygonIdSdk.Proof.isAlreadyDownloadedCircuitsFromServer called"); - return _circuitsFilesExistUseCase.execute(); + return _circuitsFilesExistUseCase.execute(param: circuitsFileName); } /// @override - Stream get initCircuitsDownloadAndGetInfoStream { - return _downloadCircuitsUseCase.execute(); + Stream initCircuitsDownloadAndGetInfoStream({ + required List circuitsToDownload, + }) { + return _downloadCircuitsUseCase.execute( + param: DownloadCircuitsParam(circuitsToDownload: circuitsToDownload), + ); } /// Returns a [Stream] of [String] of proof generation steps diff --git a/pubspec.yaml b/pubspec.yaml index 1c7fe630..ab1ef45a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,14 +1,13 @@ name: polygonid_flutter_sdk description: PolygonID Flutter SDK (https://polygon.technology/polygon-id). This plugin provides a cross-platform tool (iOS, Android) to integrate the PolygonID solution. -version: 2.2.8+2 +version: 2.2.9 homepage: https://polygon.technology/polygon-id repository: https://github.com/0xPolygonID/polygonid-flutter-sdk issue_tracker: https://github.com/0xPolygonID/polygonid-flutter-sdk/issues documentation: https://0xpolygonid.github.io/tutorials/ environment: - sdk: ">=2.17.0 <4.0.0" - flutter: ">=1.20.0" + sdk: ">=2.19.0 <4.0.0" dependencies: flutter: @@ -32,7 +31,7 @@ dependencies: uuid: ^3.0.6 encrypt: 5.0.3 pointycastle: 3.7.3 - package_info_plus: ^4.0.1 + package_info_plus: ^4.2.0 bip32: ^2.0.0 dio: ^5.3.0 dio_cache_interceptor: ^3.4.2 @@ -41,6 +40,7 @@ dependencies: intl: ^0.18.1 hive: ^2.2.3 hive_flutter: ^1.1.0 + ninja_prime: ^2.0.0 dev_dependencies: flutter_test: @@ -57,6 +57,20 @@ dev_dependencies: build_runner: ^2.4.6 ffigen: + #name: NativeWitnessV3OnchainLib + #description: Bindings to `ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h`. + #output: 'lib/proof/libs/witnesscalc/v3_onchain/native_witness_v3_onchain.dart' + #headers: + # entry-points: + # - 'ios/Classes/witnesscalc_credentialAtomicQueryV3OnChain.h' + + #name: NativeWitnessV3Lib + #description: Bindings to `ios/Classes/witnesscalc_credentialAtomicQueryV3.h`. + #output: 'lib/proof/libs/witnesscalc/v3/native_witness_v3.dart' + #headers: + # entry-points: + # - 'ios/Classes/witnesscalc_credentialAtomicQueryV3.h' + name: NativePolygonIdCoreLib description: Bindings to `ios/Classes/libpolygonid.h`. output: 'lib/common/libs/polygonidcore/native_polygonidcore.dart' diff --git a/rust/makefile b/rust/Makefile similarity index 96% rename from rust/makefile rename to rust/Makefile index d4d3fb62..8617ae80 100644 --- a/rust/makefile +++ b/rust/Makefile @@ -27,8 +27,7 @@ help: makefile ## init: Install missing dependencies. .PHONY: init init: - rustup target add aarch64-apple-ios x86_64-apple-ios - #rustup target add armv7-apple-ios armv7s-apple-ios i386-apple-ios ## deprecated + rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android @if [ $$(uname) == "Darwin" ] ; then cargo install cargo-lipo ; fi cargo install cbindgen diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6a193cd8..6868db53 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -24,6 +24,7 @@ extern crate lazy_static; use ff::*; use std::str; + use crate::eddsa::{Signature, decompress_point, Point, PrivateKey, verify, decompress_signature, /*compress_point,*/ PointProjective, Q, B8, new_key}; use num_bigint::{Sign, BigInt, ToBigInt}; use std::os::raw::{c_char}; @@ -33,6 +34,7 @@ use std::str::FromStr; use num_traits::{Num, ToPrimitive}; use rustc_hex::{FromHex, ToHex}; use num::Zero; +use std::panic::catch_unwind; /*lazy_static! { static ref B8: Point = Point { @@ -49,7 +51,7 @@ use num::Zero; }*/ #[no_mangle] -pub extern fn pack_signature(signature: *const c_char) -> *mut c_char { +pub /*extern*/ fn pack_signature_internal(signature: *const c_char) -> *mut c_char { let signature_cstr = unsafe { CStr::from_ptr(signature) }; let signature_str = match signature_cstr.to_str() { Err(_) => "there", @@ -90,13 +92,17 @@ pub extern fn pack_signature(signature: *const c_char) -> *mut c_char { let y_big: BigInt = BigInt::from_bytes_le(Sign::Plus, &r_b8_bytes[15..32]); //let y_big = x_big.clone(); - let r_b8: Point = Point { - x: Fr::from_str( + let x:Fr = Fr::from_str( &x_big.to_string(), - ).unwrap(), - y: Fr::from_str( + ).unwrap(); + + let y:Fr = Fr::from_str( &y_big.to_string(), - ).unwrap(), + ).unwrap(); + + let r_b8: Point = Point { + x: x, + y: y, }; let sig = Signature { r_b8 : r_b8.clone(), s }; @@ -107,7 +113,19 @@ pub extern fn pack_signature(signature: *const c_char) -> *mut c_char { } #[no_mangle] -pub extern fn unpack_signature(compressed_signature: *const c_char) -> *mut c_char { +pub extern fn pack_signature(signature: *const c_char) -> *mut c_char { + let result = catch_unwind(|| pack_signature_internal(signature)); + match result { + Ok(res) => res, + Err(e) => { + println!("pack_signature Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub /*extern*/ fn unpack_signature_internal(compressed_signature: *const c_char) -> *mut c_char { let compressed_signature_cstr = unsafe { CStr::from_ptr(compressed_signature) }; let compressed_signature_str = match compressed_signature_cstr.to_str() { Err(_) => "there", @@ -149,6 +167,20 @@ pub extern fn unpack_signature(compressed_signature: *const c_char) -> *mut c_ch CString::new(hex_string.as_str()).unwrap().into_raw() } +#[no_mangle] +pub extern fn unpack_signature(compressed_signature: *const c_char) -> *mut c_char { + println!("Rust unpack_signature"); + let result = catch_unwind(|| unpack_signature_internal(compressed_signature)); + match result { + Ok(res) => res, + Err(e) => { + println!("unpack_signature Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + + fn vector_as_u8_64_array(vector: Vec) -> [u8; 64] { let mut arr = [0u8;64]; for (place, element) in arr.iter_mut().zip(vector.iter()) { @@ -158,7 +190,7 @@ fn vector_as_u8_64_array(vector: Vec) -> [u8; 64] { } #[no_mangle] -pub extern fn pack_point(point_x: *const c_char, point_y: *const c_char) -> *mut c_char { +pub /*extern*/ fn pack_point_internal(point_x: *const c_char, point_y: *const c_char) -> *mut c_char { let point_x_cstr = unsafe { CStr::from_ptr(point_x) }; let point_x_str = match point_x_cstr.to_str() { Err(_) => "there", @@ -179,6 +211,18 @@ pub extern fn pack_point(point_x: *const c_char, point_y: *const c_char) -> *mut CString::new(hex_string.as_str()).unwrap().into_raw() } +#[no_mangle] +pub extern fn pack_point(point_x: *const c_char, point_y: *const c_char) -> *mut c_char { + let result = catch_unwind(|| pack_point_internal(point_x, point_y)); + match result { + Ok(res) => res, + Err(e) => { + println!("pack_point Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + pub fn to_hex_string(bytes: Vec) -> String { let strs: Vec = bytes.iter() .map(|b| format!("{:02X}", b)) @@ -187,7 +231,7 @@ pub fn to_hex_string(bytes: Vec) -> String { } #[no_mangle] -pub extern fn unpack_point(compressed_point: *const c_char) -> *mut c_char { +pub /*extern*/ fn unpack_point_internal(compressed_point: *const c_char) -> *mut c_char { let compressed_point_str = unsafe { CStr::from_ptr(compressed_point) }.to_str().unwrap(); let y_bytes_raw = compressed_point_str.from_hex().unwrap(); let mut y_bytes: [u8; 32] = [0; 32]; @@ -203,7 +247,19 @@ pub extern fn unpack_point(compressed_point: *const c_char) -> *mut c_char { } #[no_mangle] -pub extern fn prv2pub(private_key: *const c_char) -> *mut c_char { +pub extern fn unpack_point(compressed_point: *const c_char) -> *mut c_char { + let result = catch_unwind(|| unpack_point_internal(compressed_point)); + match result { + Ok(res) => res, + Err(e) => { + println!("unpack_point Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub /*extern*/ fn prv2pub_internal(private_key: *const c_char) -> *mut c_char { /*let private_key_bytes: [u8; 32] = *array_ref!(private_key[..32], 0, 32); let private_key = PrivateKey::import(private_key_bytes.to_vec()).unwrap();*/ let private_key_str = unsafe { CStr::from_ptr(private_key) }.to_str().unwrap(); @@ -221,7 +277,20 @@ pub extern fn prv2pub(private_key: *const c_char) -> *mut c_char { } #[no_mangle] -pub extern fn poseidon_hash(input: *const c_char) -> *mut c_char { +pub extern fn prv2pub(private_key: *const c_char) -> *mut c_char { + let result = catch_unwind(|| prv2pub_internal(private_key)); + match result { + Ok(res) => res, + Err(e) => { + println!("prv2pub Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + + +#[no_mangle] +pub /*extern*/ fn poseidon_hash_internal(input: *const c_char) -> *mut c_char { let input_str = unsafe { CStr::from_ptr(input) }.to_str().unwrap(); let b0: Fr = Fr::from_str(input_str).unwrap(); @@ -230,12 +299,117 @@ pub extern fn poseidon_hash(input: *const c_char) -> *mut c_char { //let hm_input = vec![x.clone(), y.clone(), z.clone()]; let poseidon = Poseidon::new(); let hm = poseidon.hash(hm_input).unwrap(); + //hm.to_string: Fr(0x29176100eaa962bdc1fe6c654d6a3c130e96a4d1168b33848b897dc502820133) + return CString::new(to_hex(&hm).as_str()).unwrap().into_raw(); + //return CString::new(hm.to_string()).unwrap().into_raw(); +} + +#[no_mangle] +pub extern fn poseidon_hash(input: *const c_char) -> *mut c_char { + let result = catch_unwind(|| poseidon_hash_internal(input)); + match result { + Ok(res) => res, + Err(e) => { + println!("poseidon_hash Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub extern "C" fn poseidon_hash2_internal(input1: *const c_char, input2: *const c_char) -> *mut c_char { + let input_str1 = unsafe { CStr::from_ptr(input1) }.to_str().unwrap(); + let input_str2 = unsafe { CStr::from_ptr(input2) }.to_str().unwrap(); + + let b1: Fr = Fr::from_str(input_str1).unwrap(); + let b2: Fr = Fr::from_str(input_str2).unwrap(); + + let hm_input = vec![b1.clone(), b2.clone()]; + + let poseidon = Poseidon::new(); + let hm = poseidon.hash(hm_input).unwrap(); + return CString::new(to_hex(&hm).as_str()).unwrap().into_raw(); } +#[no_mangle] +pub extern "C" fn poseidon_hash2(input1: *const c_char, input2: *const c_char) -> *mut c_char { + let result = catch_unwind(|| poseidon_hash2_internal(input1, input2)); + match result { + Ok(res) => res, + Err(e) => { + println!("poseidon_hash2 Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub extern "C" fn poseidon_hash3_internal(input1: *const c_char, input2: *const c_char, input3: *const c_char) -> *mut c_char { + let input_str1 = unsafe { CStr::from_ptr(input1) }.to_str().unwrap(); + let input_str2 = unsafe { CStr::from_ptr(input2) }.to_str().unwrap(); + let input_str3 = unsafe { CStr::from_ptr(input3) }.to_str().unwrap(); + + let b1: Fr = Fr::from_str(input_str1).unwrap(); + let b2: Fr = Fr::from_str(input_str2).unwrap(); + let b3: Fr = Fr::from_str(input_str3).unwrap(); + + let hm_input = vec![b1.clone(), b2.clone(), b3.clone()]; + + let poseidon = Poseidon::new(); + let hm = poseidon.hash(hm_input).unwrap(); + + return CString::new(to_hex(&hm).as_str()).unwrap().into_raw(); +} + +#[no_mangle] +pub extern "C" fn poseidon_hash3(input1: *const c_char, input2: *const c_char, input3: *const c_char) -> *mut c_char { + let result = catch_unwind(|| poseidon_hash3_internal(input1, input2, input3)); + match result { + Ok(res) => res, + Err(e) => { + println!("poseidon_hash3 Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub extern "C" fn poseidon_hash4_internal(input1: *const c_char, input2: *const c_char, input3: *const c_char, input4: *const c_char) -> *mut c_char { + let input_str1 = unsafe { CStr::from_ptr(input1) }.to_str().unwrap(); + let input_str2 = unsafe { CStr::from_ptr(input2) }.to_str().unwrap(); + let input_str3 = unsafe { CStr::from_ptr(input3) }.to_str().unwrap(); + let input_str4 = unsafe { CStr::from_ptr(input4) }.to_str().unwrap(); + + let b1: Fr = Fr::from_str(input_str1).unwrap(); + let b2: Fr = Fr::from_str(input_str2).unwrap(); + let b3: Fr = Fr::from_str(input_str3).unwrap(); + let b4: Fr = Fr::from_str(input_str4).unwrap(); + + let hm_input = vec![b1.clone(), b2.clone(), b3.clone(), b4.clone()]; + + let poseidon = Poseidon::new(); + let hm = poseidon.hash(hm_input).unwrap(); + + return CString::new(to_hex(&hm).as_str()).unwrap().into_raw(); +} + +#[no_mangle] +pub extern "C" fn poseidon_hash4(input1: *const c_char, input2: *const c_char, input3: *const c_char, input4: *const c_char) -> *mut c_char { + let result = catch_unwind(|| poseidon_hash4_internal(input1, input2, input3, input4)); + match result { + Ok(res) => res, + Err(e) => { + println!("poseidon_hash4 Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + + #[no_mangle] //pub extern fn hash_poseidon(tx_compressed_data: *const c_char, to_eth_addr: *const c_char, to_bjj_ay: *const c_char, rq_txcompressed_data_v2: *const c_char, rq_to_eth_addr: *const c_char, rq_to_bjj_ay: *const c_char) -> *mut c_char { -pub extern fn hash_poseidon(claims_tree: *const c_char, revocation_tree: *const c_char, roots_tree_root: *const c_char) -> *mut c_char { +pub /*extern*/ fn hash_poseidon_internal(claims_tree: *const c_char, revocation_tree: *const c_char, roots_tree_root: *const c_char) -> *mut c_char { //let claims_tree_str = unsafe { CStr::from_ptr(claims_tree) }.to_str().unwrap(); //let claims_tree_bigint = match claims_tree_str.parse::() { // Ok(n) => BigInt::from(n), @@ -322,8 +496,21 @@ pub extern fn hash_poseidon(claims_tree: *const c_char, revocation_tree: *const return CString::new(to_hex(&hm).as_str()).unwrap().into_raw(); } + #[no_mangle] -pub extern fn sign_poseidon(private_key: *const c_char, msg: *const c_char) -> *mut c_char { +pub extern fn hash_poseidon(claims_tree: *const c_char, revocation_tree: *const c_char, roots_tree_root: *const c_char) -> *mut c_char { + let result = catch_unwind(|| hash_poseidon_internal(claims_tree, revocation_tree, roots_tree_root)); + match result { + Ok(res) => res, + Err(e) => { + println!("hash_poseidon Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub /*extern*/ fn sign_poseidon_internal(private_key: *const c_char, msg: *const c_char) -> *mut c_char { let private_key_str = unsafe { CStr::from_ptr(private_key) }.to_str().unwrap(); //let pk_bigint = BigInt::from_str(private_key_str).unwrap(); let pk_bytes_raw = private_key_str.from_hex().unwrap(); @@ -339,7 +526,19 @@ pub extern fn sign_poseidon(private_key: *const c_char, msg: *const c_char) -> * } #[no_mangle] -pub extern fn verify_poseidon(private_key: *const c_char, compressed_signature: *const c_char, message: *const c_char) -> *mut c_char { +pub extern fn sign_poseidon(private_key: *const c_char, msg: *const c_char) -> *mut c_char { + let result = catch_unwind(|| sign_poseidon_internal(private_key, msg)); + match result { + Ok(res) => res, + Err(e) => { + println!("sign_poseidon Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + +#[no_mangle] +pub /*extern*/ fn verify_poseidon_internal(private_key: *const c_char, compressed_signature: *const c_char, message: *const c_char) -> *mut c_char { let private_key_str = unsafe { CStr::from_ptr(private_key) }.to_str().unwrap(); // let pk_bigint = BigInt::from_str(private_key_str).unwrap(); let pk_bytes_raw = private_key_str.from_hex().unwrap(); @@ -368,10 +567,23 @@ pub extern fn verify_poseidon(private_key: *const c_char, compressed_signature: } } + +#[no_mangle] +pub extern fn verify_poseidon(private_key: *const c_char, compressed_signature: *const c_char, message: *const c_char) -> *mut c_char { + let result = catch_unwind(|| verify_poseidon_internal(private_key, compressed_signature, message)); + match result { + Ok(res) => res, + Err(e) => { + println!("verify_poseidon Rust Err: {:?}", e); + std::ptr::null_mut() + } + } +} + #[no_mangle] pub extern fn cstring_free(str: *mut c_char) { unsafe { if str.is_null() { return } CString::from_raw(str) }; -} \ No newline at end of file +} diff --git a/test/common/common_mocks.dart b/test/common/common_mocks.dart index 61e62667..3b27aef7 100644 --- a/test/common/common_mocks.dart +++ b/test/common/common_mocks.dart @@ -75,4 +75,8 @@ class CommonMocks { pushUrl: url, ipfsUrl: url, ); + + static String expiration = "2050-01-01T00:00:00Z"; + + static String credentialRawValue = "{\"the\": \"value\"}"; } diff --git a/test/common/credential_mocks.dart b/test/common/credential_mocks.dart index 7c3b446f..a229f579 100644 --- a/test/common/credential_mocks.dart +++ b/test/common/credential_mocks.dart @@ -17,6 +17,8 @@ class CredentialMocks { type: CommonMocks.type, info: CommonMocks.aMap, schema: CommonMocks.aMap, + expiration: CommonMocks.expiration, + credentialRawValue: CommonMocks.credentialRawValue, ); /// We assume [ClaimInfoDTO] has been tested @@ -110,5 +112,6 @@ class CredentialMocks { did: CommonMocks.did, type: CommonMocks.type, info: ClaimInfoDTO.fromJson(jsonDecode(claimInfoJson)), + credentialRawValue: CommonMocks.credentialRawValue, ); } diff --git a/test/common/utils/format_utils_test.dart b/test/common/utils/format_utils_test.dart new file mode 100644 index 00000000..685551c6 --- /dev/null +++ b/test/common/utils/format_utils_test.dart @@ -0,0 +1,41 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:polygonid_flutter_sdk/common/utils/format_utils.dart'; + +void main() { + group('FormatUtils', () { + test( + 'convertSnakeCaseToCamelCase should return empty map when input is empty', + () { + final result = FormatUtils.convertSnakeCaseToCamelCase({}); + expect(result, {}); + }); + + test('convertSnakeCaseToCamelCase should convert snake_case to camelCase', + () { + final result = + FormatUtils.convertSnakeCaseToCamelCase({'snake_case': 'value'}); + expect(result, {'snakeCase': 'value'}); + }); + + test('convertSnakeCaseToCamelCase should handle multiple snake_case keys', + () { + final result = FormatUtils.convertSnakeCaseToCamelCase( + {'snake_case_one': 'value1', 'snake_case_two': 'value2'}); + expect(result, {'snakeCaseOne': 'value1', 'snakeCaseTwo': 'value2'}); + }); + + test('convertSnakeCaseToCamelCase should not modify camelCase keys', () { + final result = + FormatUtils.convertSnakeCaseToCamelCase({'camelCase': 'value'}); + expect(result, {'camelCase': 'value'}); + }); + + test( + 'convertSnakeCaseToCamelCase should handle mixed snake_case and camelCase keys', + () { + final result = FormatUtils.convertSnakeCaseToCamelCase( + {'snake_case': 'value1', 'camelCase': 'value2'}); + expect(result, {'snakeCase': 'value1', 'camelCase': 'value2'}); + }); + }); +} diff --git a/test/credential/data/data_sources/storage_claim_data_source_test.dart b/test/credential/data/data_sources/storage_claim_data_source_test.dart index 16c2f4ec..c0f5d663 100644 --- a/test/credential/data/data_sources/storage_claim_data_source_test.dart +++ b/test/credential/data/data_sources/storage_claim_data_source_test.dart @@ -56,26 +56,32 @@ final credential = FetchClaimResponseDTO.fromJson(jsonDecode(mockFetchClaim)).credential; final mockClaims = [ ClaimDTO( - id: credential.id, - issuer: issuers[0], - did: identifiers[0], - expiration: expirations[0], - type: types[0], - info: credential), + id: credential.id, + issuer: issuers[0], + did: identifiers[0], + expiration: expirations[0], + type: types[0], + info: credential, + credentialRawValue: mockFetchClaim, + ), ClaimDTO( - id: credential.id, - issuer: issuers[1], - did: identifiers[1], - expiration: expirations[1], - type: types[1], - info: credential), + id: credential.id, + issuer: issuers[1], + did: identifiers[1], + expiration: expirations[1], + type: types[1], + info: credential, + credentialRawValue: mockFetchClaim, + ), ClaimDTO( - id: credential.id, - issuer: issuers[2], - did: identifiers[2], - expiration: expirations[2], - type: types[2], - info: credential) + id: credential.id, + issuer: issuers[2], + did: identifiers[2], + expiration: expirations[2], + type: types[2], + info: credential, + credentialRawValue: mockFetchClaim, + ) ]; final exception = Exception(); diff --git a/test/credential/data/dtos/credential_dto_test.dart b/test/credential/data/dtos/credential_dto_test.dart index 8f9a68e9..569cb0a9 100644 --- a/test/credential/data/dtos/credential_dto_test.dart +++ b/test/credential/data/dtos/credential_dto_test.dart @@ -26,6 +26,10 @@ String data = ''' "id": "did:polygonid:polygon:mumbai:2qGJnNTaHyvZwcTG4jWDif2E5GnWuLGfuWb2misbrC", "type": "KYCAgeCredential" }, + "displayMethod": { + "id": "https://cornhub.com/test", + "type": "Iden3BasicDisplayMethodV1" + }, "expirationDate": "2030-01-01T00:00:00Z", "id": "http://52.213.238.159/api/v1/identities/did:polygonid:polygon:mumbai:2qJNoD4vLiuoaM6B5rEidsSR4Kj9ZTJp1wgvhB6wBB/claims/3f43b616-9d57-11ed-a2b8-0242ac120004", "issuanceDate": "2023-01-26T08:55:56.747082936Z", diff --git a/test/credential/data/mappers/claim_mapper_test.dart b/test/credential/data/mappers/claim_mapper_test.dart index e39a7773..82ac3a41 100644 --- a/test/credential/data/mappers/claim_mapper_test.dart +++ b/test/credential/data/mappers/claim_mapper_test.dart @@ -4,9 +4,11 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_dto.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_info_mapper.dart'; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_mapper.dart'; import 'package:polygonid_flutter_sdk/credential/data/mappers/claim_state_mapper.dart'; +import 'package:polygonid_flutter_sdk/credential/data/mappers/display_type_mapper.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/data/dtos/credential/response/fetch_claim_response_dto.dart'; @@ -29,23 +31,27 @@ final dto = ClaimDTO( expiration: fetchClaimDTO.credential.expirationDate, type: fetchClaimDTO.credential.credentialSubject.type, info: fetchClaimDTO.credential, + credentialRawValue: mockFetchClaim, ); final entity = ClaimEntity( - issuer: fetchClaimDTO.from, - did: identifier, - expiration: fetchClaimDTO.credential.expirationDate, - info: info, - type: fetchClaimDTO.credential.credentialSubject.type, - state: ClaimState.active, - id: fetchClaimDTO.credential.id); + issuer: fetchClaimDTO.from, + did: identifier, + expiration: fetchClaimDTO.credential.expirationDate, + info: info, + type: fetchClaimDTO.credential.credentialSubject.type, + state: ClaimState.active, + id: fetchClaimDTO.credential.id, + credentialRawValue: mockFetchClaim, +); // Dependencies MockClaimStateMapper stateMapper = MockClaimStateMapper(); MockClaimInfoMapper infoMapper = MockClaimInfoMapper(); +MockDisplayTypeMapper displayTypeMapper = MockDisplayTypeMapper(); // Tested instance -ClaimMapper mapper = ClaimMapper(stateMapper, infoMapper); +ClaimMapper mapper = ClaimMapper(stateMapper, infoMapper, displayTypeMapper); -@GenerateMocks([ClaimStateMapper, ClaimInfoMapper]) +@GenerateMocks([ClaimStateMapper, ClaimInfoMapper, DisplayTypeMapper]) void main() { setUp(() {}); @@ -56,6 +62,7 @@ void main() { // Given when(infoMapper.mapFrom(any)).thenReturn(info); when(stateMapper.mapFrom(any)).thenReturn(ClaimState.active); + when(displayTypeMapper.mapFrom(any)).thenReturn(null); // When expect(mapper.mapFrom(dto), entity); @@ -64,6 +71,8 @@ void main() { expect(verify(infoMapper.mapFrom(captureAny)).captured.first, fetchClaimDTO.credential); expect(verify(stateMapper.mapFrom(captureAny)).captured.first, ''); + expect( + verify(displayTypeMapper.mapFrom(captureAny)).captured.first, null); }); }); @@ -74,6 +83,7 @@ void main() { // Given when(infoMapper.mapTo(any)).thenReturn(fetchClaimDTO.credential); when(stateMapper.mapTo(any)).thenReturn(''); + when(displayTypeMapper.mapTo(any)).thenReturn(null); // When expect(mapper.mapTo(entity), dto); diff --git a/test/credential/data/repositories/credential_repository_impl_test.dart b/test/credential/data/repositories/credential_repository_impl_test.dart index 1429b6a9..8db7d329 100644 --- a/test/credential/data/repositories/credential_repository_impl_test.dart +++ b/test/credential/data/repositories/credential_repository_impl_test.dart @@ -9,6 +9,7 @@ import 'package:polygonid_flutter_sdk/common/data/data_sources/mappers/filters_m import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/constants.dart'; import 'package:polygonid_flutter_sdk/credential/data/credential_repository_impl.dart'; +import 'package:polygonid_flutter_sdk/credential/data/data_sources/cache_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/data_sources/local_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/data_sources/remote_claim_data_source.dart'; import 'package:polygonid_flutter_sdk/credential/data/data_sources/storage_claim_data_source.dart'; @@ -40,27 +41,43 @@ final fetchClaimDTO = FetchClaimResponseDTO.fromJson(jsonDecode(mockFetchClaim)); final claimDTOs = [ ClaimDTO( - id: "id1", issuer: "", did: "", type: '', info: fetchClaimDTO.credential), + id: "id1", + issuer: "", + did: "", + type: '', + info: fetchClaimDTO.credential, + credentialRawValue: mockFetchClaim, + ), ClaimDTO( - id: "id2", issuer: "", did: "", type: '', info: fetchClaimDTO.credential), + id: "id2", + issuer: "", + did: "", + type: '', + info: fetchClaimDTO.credential, + credentialRawValue: mockFetchClaim, + ), ]; final claimEntities = [ ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.active, - id: "id1"), + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.active, + id: "id1", + credentialRawValue: mockFetchClaim, + ), ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.active, - id: "id2") + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.active, + id: "id2", + credentialRawValue: mockFetchClaim, + ) ]; final filters = [ FilterEntity(name: "theName", value: "theValue"), @@ -84,6 +101,8 @@ MockRemoteClaimDataSource remoteClaimDataSource = MockRemoteClaimDataSource(); MockStorageClaimDataSource storageClaimDataSource = MockStorageClaimDataSource(); MockLocalClaimDataSource localClaimDataSource = MockLocalClaimDataSource(); +MockCacheCredentialDataSource cacheCredentialDataSource = + MockCacheCredentialDataSource(); MockClaimMapper claimMapper = MockClaimMapper(); MockFiltersMapper filtersMapper = MockFiltersMapper(); MockIdFilterMapper idFilterMapper = MockIdFilterMapper(); @@ -93,6 +112,7 @@ CredentialRepositoryImpl repository = CredentialRepositoryImpl( remoteClaimDataSource, storageClaimDataSource, localClaimDataSource, + cacheCredentialDataSource, claimMapper, filtersMapper, idFilterMapper, @@ -102,6 +122,7 @@ CredentialRepositoryImpl repository = CredentialRepositoryImpl( RemoteClaimDataSource, StorageClaimDataSource, LocalClaimDataSource, + CacheCredentialDataSource, ClaimMapper, FiltersMapper, IdFilterMapper, @@ -298,6 +319,15 @@ void main() { privateKey: anyNamed('privateKey'), filter: anyNamed('filter'))) .thenAnswer((realInvocation) => Future.value([claimDTOs[0]])); + when( + storageClaimDataSource.getClaim( + credentialId: anyNamed('credentialId'), + did: anyNamed('did'), + privateKey: privateKey, + ), + ).thenAnswer((realInvocation) => Future.value(claimDTOs[0])); + + when(filtersMapper.mapTo(any)).thenReturn(filter); when(claimMapper.mapFrom(any)).thenReturn(claimEntities[0]); when(idFilterMapper.mapTo(any)).thenReturn(filter); }); @@ -307,23 +337,25 @@ void main() { () async { // When expect( - await repository.getClaim( - genesisDid: CommonMocks.identifier, - privateKey: CommonMocks.privateKey, - claimId: ids[0]), - claimEntities[0]); - - // Then - expect(verify(idFilterMapper.mapTo(captureAny)).captured.first, ids[0]); - - var captureGet = verify(storageClaimDataSource.getClaims( - did: captureAnyNamed('did'), - privateKey: captureAnyNamed('privateKey'), - filter: captureAnyNamed('filter'))) - .captured; - expect(captureGet[0], CommonMocks.identifier); - expect(captureGet[1], CommonMocks.privateKey); - expect(captureGet[2], filter); + await repository.getClaim( + genesisDid: CommonMocks.identifier, + privateKey: CommonMocks.privateKey, + claimId: ids[0], + ), + claimEntities[0], + ); + + var captureGet = verify( + storageClaimDataSource.getClaim( + credentialId: captureAnyNamed('credentialId'), + did: captureAnyNamed('did'), + privateKey: captureAnyNamed('privateKey'), + ), + ).captured; + + expect(captureGet[0], CommonMocks.id); + expect(captureGet[1], CommonMocks.identifier); + expect(captureGet[2], CommonMocks.privateKey); expect( verify(claimMapper.mapFrom(captureAny)).captured.first, claimDTOs[0]); @@ -333,34 +365,38 @@ void main() { "Given an id, when I call getClaim and no claim are found, then I expect a ClaimNotFoundException to be thrown", () async { // Given - when(storageClaimDataSource.getClaims( - did: anyNamed('did'), - privateKey: anyNamed('privateKey'), - filter: anyNamed('filter'))) - .thenAnswer((realInvocation) => Future.value([])); + when( + storageClaimDataSource.getClaim( + credentialId: anyNamed('credentialId'), + did: anyNamed('did'), + privateKey: anyNamed('privateKey'), + ), + ).thenAnswer( + (realInvocation) => Future.error(ClaimNotFoundException(ids[0]))); // When await repository .getClaim( - genesisDid: CommonMocks.identifier, - privateKey: CommonMocks.privateKey, - claimId: ids[0]) + genesisDid: CommonMocks.identifier, + privateKey: CommonMocks.privateKey, + claimId: ids[0], + ) .then((value) => expect(true, false)) .catchError((error) { expect(error, isA()); expect(error.id, ids[0]); }); - // Then - expect(verify(idFilterMapper.mapTo(captureAny)).captured.first, ids[0]); + var captureGet = verify( + storageClaimDataSource.getClaim( + did: captureAnyNamed('did'), + privateKey: captureAnyNamed('privateKey'), + credentialId: captureAnyNamed('credentialId'), + ), + ).captured; - var captureGet = verify(storageClaimDataSource.getClaims( - did: captureAnyNamed('did'), - privateKey: captureAnyNamed('privateKey'), - filter: captureAnyNamed('filter'))) - .captured; expect(captureGet[0], CommonMocks.identifier); expect(captureGet[1], CommonMocks.privateKey); - expect(captureGet[2], filter); + expect(captureGet[2], CommonMocks.id); verifyNever(claimMapper.mapFrom(captureAny)); }); @@ -369,30 +405,37 @@ void main() { "Given an id, when I call getClaim and an error occurred, then I expect an exception to be thrown", () async { // Given - when(storageClaimDataSource.getClaims( - did: anyNamed('did'), - privateKey: anyNamed('privateKey'), - filter: anyNamed('filter'))) - .thenAnswer((realInvocation) => Future.error(exception)); - // When + when( + storageClaimDataSource.getClaim( + did: anyNamed('did'), + privateKey: anyNamed('privateKey'), + credentialId: anyNamed('credentialId'), + ), + ).thenAnswer( + (realInvocation) => Future.error(exception), + ); + await expectLater( - repository.getClaim( - genesisDid: CommonMocks.identifier, - privateKey: CommonMocks.privateKey, - claimId: ids[0]), - throwsA(exception)); + repository.getClaim( + genesisDid: CommonMocks.identifier, + claimId: ids[0], + privateKey: CommonMocks.privateKey, + ), + throwsA(exception), + ); // Then - expect(verify(idFilterMapper.mapTo(captureAny)).captured.first, ids[0]); + final captureGet = verify( + storageClaimDataSource.getClaim( + did: captureAnyNamed('did'), + privateKey: captureAnyNamed('privateKey'), + credentialId: captureAnyNamed('credentialId'), + ), + ).captured; - var captureGet = verify(storageClaimDataSource.getClaims( - did: captureAnyNamed('did'), - privateKey: captureAnyNamed('privateKey'), - filter: captureAnyNamed('filter'))) - .captured; expect(captureGet[0], CommonMocks.identifier); expect(captureGet[1], CommonMocks.privateKey); - expect(captureGet[2], filter); + expect(captureGet[2], CommonMocks.id); verifyNever(claimMapper.mapFrom(captureAny)); }); diff --git a/test/credential/domain/use_cases/get_claims_use_case_test.dart b/test/credential/domain/use_cases/get_claims_use_case_test.dart index fb2d735f..4e308447 100644 --- a/test/credential/domain/use_cases/get_claims_use_case_test.dart +++ b/test/credential/domain/use_cases/get_claims_use_case_test.dart @@ -41,55 +41,67 @@ final GetClaimsParam profileParam = GetClaimsParam( genesisDid: identifier, profileNonce: BigInt.one, privateKey: privateKey); final claimEntities = [ ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.active, - id: "id1"), + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.active, + id: "id1", + credentialRawValue: "", + ), ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.pending, - id: "id2"), + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.pending, + id: "id2", + credentialRawValue: "", + ), ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.revoked, - id: "id3") + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.revoked, + id: "id3", + credentialRawValue: "", + ) ]; final profilesClaimEntities = [ ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.active, - id: "id1"), + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.active, + id: "id1", + credentialRawValue: "", + ), ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.pending, - id: "id2"), + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.pending, + id: "id2", + credentialRawValue: "", + ), ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.revoked, - id: "id3") + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.revoked, + id: "id3", + credentialRawValue: "", + ) ]; var exception = Exception(); diff --git a/test/credential/domain/use_cases/update_claim_use_case_test.dart b/test/credential/domain/use_cases/update_claim_use_case_test.dart index e9d33c7c..feea5e2a 100644 --- a/test/credential/domain/use_cases/update_claim_use_case_test.dart +++ b/test/credential/domain/use_cases/update_claim_use_case_test.dart @@ -21,6 +21,7 @@ const type = "theType"; const data = {"some": "data"}; const otherData = {"some": "otherData"}; final exception = Exception(); +const credentialRawValue = "theCredentialRawValue"; final UpdateClaimParam param = UpdateClaimParam( id: id, @@ -31,22 +32,26 @@ final UpdateClaimParam param = UpdateClaimParam( data: otherData); final claimEntity = ClaimEntity( - issuer: issuer, - did: identifier, - expiration: expiration, - info: data, - type: type, - state: ClaimState.active, - id: id); + issuer: issuer, + did: identifier, + expiration: expiration, + info: data, + type: type, + state: ClaimState.active, + id: id, + credentialRawValue: credentialRawValue, +); final otherClaimEntity = ClaimEntity( - issuer: otherIssuer, - did: identifier, - expiration: otherExpiration, - info: otherData, - type: type, - state: ClaimState.active, - id: id); + issuer: otherIssuer, + did: identifier, + expiration: otherExpiration, + info: otherData, + type: type, + state: ClaimState.active, + id: id, + credentialRawValue: credentialRawValue, +); // Dependencies MockCredentialRepository credentialRepository = MockCredentialRepository(); diff --git a/test/iden3comm/data/data_sources/remote_iden3comm_data_source_test.dart b/test/iden3comm/data/data_sources/remote_iden3comm_data_source_test.dart index d508d39f..1fdcb30f 100644 --- a/test/iden3comm/data/data_sources/remote_iden3comm_data_source_test.dart +++ b/test/iden3comm/data/data_sources/remote_iden3comm_data_source_test.dart @@ -35,7 +35,8 @@ final claim = ClaimDTO( did: identifier, expiration: fetchClaimDTO.credential.expirationDate, type: fetchClaimDTO.credential.credentialSubject.type, - info: fetchClaimDTO.credential); + info: fetchClaimDTO.credential, + credentialRawValue: mockFetchClaim); //DEPENDENCIES MockClient client = MockClient(); diff --git a/test/iden3comm/data/dtos/fetch_claim_response_dto_test.dart b/test/iden3comm/data/dtos/fetch_claim_response_dto_test.dart index d35f372b..eaede11a 100644 --- a/test/iden3comm/data/dtos/fetch_claim_response_dto_test.dart +++ b/test/iden3comm/data/dtos/fetch_claim_response_dto_test.dart @@ -190,7 +190,56 @@ String mockOtherTypeFetchClaim = ''' "type": "https://iden3-communication.io/credentials/1.0/other-response" } '''; + +String mockFetchCredentialMTP = ''' +{ + "body": { + "credential": { + "id": "https://issuer-admin.polygonid.me/v1/credentials/69b66264-a0b2-11ee-93b5-0242ac120009", + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld", + "ipfs://QmdH1Vu79p2NcZLFbHxzJnLuUHJiMZnBeT7SNpLaqK7k9X" + ], + "type": [ + "VerifiableCredential", + "POAP01" + ], + "issuanceDate": "2023-12-22T10:11:03.325197614Z", + "credentialSubject": { + "city": "affasfsg", + "id": "did:polygonid:polygon:mumbai:2qFXVU2SPH9WvhPW1S4nqrY2zc9q8124hoj5hr2Tmy", + "type": "POAP01" + }, + "credentialStatus": { + "id": "https://rhs-staging.polygonid.me/node?state=cf4d52e845a60ab1c442546eddfefa3ec3c01e04db239a5bac170e7fc1bd6b19", + "revocationNonce": 3135116222, + "statusIssuer": { + "id": "https://issuer-admin.polygonid.me/v1/credentials/revocation/status/3135116222", + "revocationNonce": 3135116222, + "type": "SparseMerkleTreeProof" + }, + "type": "Iden3ReverseSparseMerkleTreeProof" + }, + "issuer": "did:polygonid:polygon:mumbai:2qMCebtitXNzau92r4JNV3y162hkzVZPn75UPMiE1G", + "credentialSchema": { + "id": "ipfs://QmTSwnuCB9grYMB2z5EKXDagfChurK5MiMCS6efrRbsyVX", + "type": "JsonSchema2023" + }, + "proof" : [] + } + }, + "from": "did:polygonid:polygon:mumbai:2qMCebtitXNzau92r4JNV3y162hkzVZPn75UPMiE1G", + "id": "166aa1b4-69d2-4355-aea1-d802c2341186", + "threadID": "5a23c836-8e4c-4c2b-bbdf-df3dd342884d", + "to": "did:polygonid:polygon:mumbai:2qFXVU2SPH9WvhPW1S4nqrY2zc9q8124hoj5hr2Tmy", + "typ": "application/iden3comm-plain-json", + "type": "https://iden3-communication.io/credentials/1.0/issuance-response" +} +'''; + var json = jsonDecode(mockFetchClaim); +var jsonMTP = jsonDecode(mockFetchCredentialMTP); // Dependencies @@ -204,4 +253,15 @@ void main() { FetchClaimResponseDTO dto = FetchClaimResponseDTO.fromJson(json); }); }); + + group("FetchClaimResponseDTO with MTP", () { + test("should parse valid JSON with MTP correctly", () { + var dto = FetchClaimResponseDTO.fromJson(jsonMTP); + expect(dto.type, FetchClaimResponseType.issuance); + expect(dto.from, + "did:polygonid:polygon:mumbai:2qMCebtitXNzau92r4JNV3y162hkzVZPn75UPMiE1G"); + expect(dto.credential.id, + "https://issuer-admin.polygonid.me/v1/credentials/69b66264-a0b2-11ee-93b5-0242ac120009"); + }); + }); } diff --git a/test/iden3comm/data/mappers/proof_request_filters_mapper_test.dart b/test/iden3comm/data/mappers/proof_request_filters_mapper_test.dart index 2432b7c9..25287b43 100644 --- a/test/iden3comm/data/mappers/proof_request_filters_mapper_test.dart +++ b/test/iden3comm/data/mappers/proof_request_filters_mapper_test.dart @@ -202,7 +202,7 @@ main() { test("From ProofRequestEntity to List LT operator", () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityLT); - expect(filters.length, 3); + expect(filters.length, 4); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCAgeCredential"); }); @@ -210,7 +210,7 @@ main() { test("From ProofRequestEntity to List GT operator", () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityGT); - expect(filters.length, 3); + expect(filters.length, 4); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCAgeCredential"); }); @@ -218,7 +218,7 @@ main() { test("From ProofRequestEntity to List EQ", () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityEQ); - expect(filters.length, 3); + expect(filters.length, 4); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCAgeCredential"); }); @@ -226,7 +226,7 @@ main() { test("From ProofRequestEntity to List IN", () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityIN); - expect(filters.length, 3); + expect(filters.length, 4); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCAgeCredential"); }); @@ -234,7 +234,7 @@ main() { test("From ProofRequestEntity to List NIN", () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityNIN); - expect(filters.length, 4); + expect(filters.length, 5); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCAgeCredential"); }); @@ -244,7 +244,7 @@ main() { () { List filters = proofRequestFiltersMapper.mapFrom(mockProofRequestEntityNINCountry); - expect(filters.length, 6); + expect(filters.length, 7); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCCountryOfResidenceCredential"); }); @@ -253,7 +253,7 @@ main() { () { List filters = proofRequestFiltersMapper .mapFrom(mockProofRequestEntityNotSupportedOperator); - expect(filters.length, 2); + expect(filters.length, 3); expect(filters[0].name, "credential.credentialSubject.type"); expect(filters[0].value, "KYCCountryOfResidenceCredential"); }); diff --git a/test/iden3comm/domain/use_cases/fetch_and_save_claims_use_case_test.dart b/test/iden3comm/domain/use_cases/fetch_and_save_claims_use_case_test.dart index 28a1d37f..8100abe4 100644 --- a/test/iden3comm/domain/use_cases/fetch_and_save_claims_use_case_test.dart +++ b/test/iden3comm/domain/use_cases/fetch_and_save_claims_use_case_test.dart @@ -5,6 +5,7 @@ import 'package:polygonid_flutter_sdk/common/domain/use_cases/get_env_use_case.d import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/credential/domain/entities/claim_entity.dart'; import 'package:polygonid_flutter_sdk/credential/domain/repositories/credential_repository.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/cache_credential_use_case.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claim_revocation_status_use_case.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; @@ -36,13 +37,15 @@ final revStatus = { }; final claimEntity = ClaimEntity( - issuer: "", - did: "", - expiration: "", - info: {}, - type: "", - state: ClaimState.active, - id: "id"); + issuer: "", + did: "", + expiration: "", + info: {}, + type: "", + state: ClaimState.active, + id: "id", + credentialRawValue: "", +); final result = [claimEntity, claimEntity, claimEntity]; @@ -66,6 +69,8 @@ MockSaveClaimsUseCase saveClaimsUseCase = MockSaveClaimsUseCase(); MockGetAuthTokenUseCase getAuthTokenUseCase = MockGetAuthTokenUseCase(); MockGetClaimRevocationStatusUseCase getClaimRevocationStatusUseCase = MockGetClaimRevocationStatusUseCase(); +MockCacheCredentialUseCase cacheCredentialUseCase = + MockCacheCredentialUseCase(); MockStacktraceManager stacktraceManager = MockStacktraceManager(); // Tested instance @@ -78,6 +83,7 @@ FetchAndSaveClaimsUseCase useCase = FetchAndSaveClaimsUseCase( getAuthTokenUseCase, saveClaimsUseCase, getClaimRevocationStatusUseCase, + cacheCredentialUseCase, stacktraceManager, ); @@ -90,6 +96,7 @@ FetchAndSaveClaimsUseCase useCase = FetchAndSaveClaimsUseCase( GetAuthTokenUseCase, SaveClaimsUseCase, GetClaimRevocationStatusUseCase, + CacheCredentialUseCase, StacktraceManager, ]) void main() { @@ -177,8 +184,9 @@ void main() { j++; } - var revStatusVerify = verify(getClaimRevocationStatusUseCase.execute( - param: captureAnyNamed('param'))); + // FIXME: This is verifying code that is currently commented out. + // var revStatusVerify = verify(getClaimRevocationStatusUseCase.execute( + // param: captureAnyNamed('param'))); }); test( diff --git a/test/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case_test.dart b/test/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case_test.dart index d8f45049..339969cd 100644 --- a/test/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case_test.dart +++ b/test/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case_test.dart @@ -4,10 +4,15 @@ import 'package:mockito/mockito.dart'; import 'package:polygonid_flutter_sdk/common/domain/entities/filter_entity.dart'; import 'package:polygonid_flutter_sdk/common/infrastructure/stacktrace_stream_manager.dart'; import 'package:polygonid_flutter_sdk/credential/domain/use_cases/get_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/refresh_credential_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/remove_claims_use_case.dart'; +import 'package:polygonid_flutter_sdk/credential/domain/use_cases/save_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/entities/proof/response/iden3comm_sd_proof_entity.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exceptions.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_credential_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/repositories/iden3comm_repository.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart'; +import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_auth_token_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_claims_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_proof_requests_use_case.dart'; import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3comm_proofs_use_case.dart'; @@ -56,6 +61,13 @@ MockGetIdentityUseCase getIdentityUseCase = MockGetIdentityUseCase(); MockProofGenerationStepsStreamManager proofGenerationStepsStreamManager = MockProofGenerationStepsStreamManager(); MockStacktraceManager stacktraceStreamManager = MockStacktraceManager(); +MockGetAuthTokenUseCase getAuthTokenUseCase = MockGetAuthTokenUseCase(); +MockIden3commCredentialRepository iden3commCredentialRepository = + MockIden3commCredentialRepository(); +MockRemoveClaimsUseCase removeClaimsUseCase = MockRemoveClaimsUseCase(); +MockSaveClaimsUseCase saveClaimsUseCase = MockSaveClaimsUseCase(); +MockRefreshCredentialUseCase refreshCredentialUseCase = + MockRefreshCredentialUseCase(); // Tested instance GetIden3commProofsUseCase useCase = GetIden3commProofsUseCase( @@ -67,6 +79,11 @@ GetIden3commProofsUseCase useCase = GetIden3commProofsUseCase( getIdentityUseCase, proofGenerationStepsStreamManager, stacktraceStreamManager, + getAuthTokenUseCase, + iden3commCredentialRepository, + removeClaimsUseCase, + saveClaimsUseCase, + refreshCredentialUseCase, ); @GenerateMocks([ @@ -78,6 +95,11 @@ GetIden3commProofsUseCase useCase = GetIden3commProofsUseCase( GetIdentityUseCase, ProofGenerationStepsStreamManager, StacktraceManager, + GetAuthTokenUseCase, + Iden3commCredentialRepository, + RemoveClaimsUseCase, + SaveClaimsUseCase, + RefreshCredentialUseCase, ]) main() { setUp(() { diff --git a/test/identity/data/dtos/hash_dto_test.dart b/test/identity/data/dtos/hash_dto_test.dart new file mode 100644 index 00000000..2423b24f --- /dev/null +++ b/test/identity/data/dtos/hash_dto_test.dart @@ -0,0 +1,55 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/hash_dto.dart'; +import 'dart:typed_data'; + +void main() { + group('HashDTO', () { + test('== operator should return true when data fields are equal', () { + final data1 = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO1 = HashDTO(data: data1); + + final data2 = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO2 = HashDTO(data: data2); + + expect(hashDTO1 == hashDTO2, isTrue); + }); + + test('== operator should return false when data fields are not equal', () { + final data1 = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO1 = HashDTO(data: data1); + + final data2 = Uint8List.fromList([6, 7, 8, 9, 10]); + final hashDTO2 = HashDTO(data: data2); + + expect(hashDTO1 == hashDTO2, isFalse); + }); + + test( + '== operator should return false when data fields have different lengths', + () { + final data1 = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO1 = HashDTO(data: data1); + + final data2 = Uint8List.fromList([1, 2, 3, 4, 5, 6]); + final hashDTO2 = HashDTO(data: data2); + + expect(hashDTO1 == hashDTO2, isFalse); + }); + + test('toBigInt should return correct BigInt value', () { + final data = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO = HashDTO(data: data); + + final expectedBigInt = BigInt.parse('21542142465'); + expect(hashDTO.toBigInt(), equals(expectedBigInt)); + }); + + test('testBit should return correct bit value', () { + final data = Uint8List.fromList([1, 2, 3, 4, 5]); + final hashDTO = HashDTO(data: data); + + expect(hashDTO.testBit(0), isTrue); + expect(hashDTO.testBit(1), isFalse); + }); + }); +} diff --git a/test/proof/data/data_sources/atomic_query_inputs_param_test.dart b/test/proof/data/data_sources/atomic_query_inputs_param_test.dart new file mode 100644 index 00000000..e9177c56 --- /dev/null +++ b/test/proof/data/data_sources/atomic_query_inputs_param_test.dart @@ -0,0 +1,90 @@ +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:polygonid_flutter_sdk/credential/data/dtos/claim_info_dto.dart'; +import 'package:polygonid_flutter_sdk/proof/data/dtos/atomic_query_inputs_param.dart'; +import 'package:polygonid_flutter_sdk/common/utils/format_utils.dart'; + +import '../../../common/credential_mocks.dart'; + +void main() { + group('AtomicQueryInputsParam', () { + test('toJson includes all non-null fields', () { + final param = AtomicQueryInputsParam( + type: AtomicQueryInputsType.mtp, + id: 'testId', + profileNonce: BigInt.from(123), + claimSubjectProfileNonce: BigInt.from(456), + credential: + ClaimInfoDTO.fromJson(jsonDecode(CredentialMocks.claimInfoJson)), + request: {'key': 'value'}, + ); + + final json = param.toJson(); + + expect(json['id'], 'testId'); + expect(json['profileNonce'], '123'); + expect(json['claimSubjectProfileNonce'], '456'); + expect(json['request'], {'key': 'value'}); + }); + + test('toJson excludes null fields', () { + final param = AtomicQueryInputsParam( + type: AtomicQueryInputsType.mtp, + id: 'testId', + profileNonce: BigInt.from(123), + claimSubjectProfileNonce: BigInt.from(456), + credential: + ClaimInfoDTO.fromJson(jsonDecode(CredentialMocks.claimInfoJson)), + request: {'key': 'value'}, + ); + + final json = param.toJson(); + + expect(json.containsKey('authClaim'), false); + expect(json.containsKey('incProof'), false); + expect(json.containsKey('nonRevProof'), false); + expect(json.containsKey('gistProof'), false); + expect(json.containsKey('treeState'), false); + expect(json.containsKey('challenge'), false); + expect(json.containsKey('signature'), false); + expect(json.containsKey('verifierId'), false); + expect(json.containsKey('linkNonce'), false); + expect(json.containsKey('params'), false); + }); + + test('toJson converts transactionData to camelCase', () { + final param = AtomicQueryInputsParam( + type: AtomicQueryInputsType.mtp, + id: 'testId', + profileNonce: BigInt.from(123), + claimSubjectProfileNonce: BigInt.from(456), + credential: + ClaimInfoDTO.fromJson(jsonDecode(CredentialMocks.claimInfoJson)), + request: {'key': 'value'}, + transactionData: {'snake_case_key': 'value'}, + ); + + final json = param.toJson(); + + expect(json['transactionData'], {'snakeCaseKey': 'value'}); + }); + + test('toJson excludes verifierId if it is empty', () { + final param = AtomicQueryInputsParam( + type: AtomicQueryInputsType.mtp, + id: 'testId', + profileNonce: BigInt.from(123), + claimSubjectProfileNonce: BigInt.from(456), + credential: + ClaimInfoDTO.fromJson(jsonDecode(CredentialMocks.claimInfoJson)), + request: {'key': 'value'}, + verifierId: '', + ); + + final json = param.toJson(); + + expect(json.containsKey('verifierId'), false); + }); + }); +} diff --git a/test/proof/data/data_sources/witness_data_source_test.dart b/test/proof/data/data_sources/witness_data_source_test.dart index e2749837..65291df2 100644 --- a/test/proof/data/data_sources/witness_data_source_test.dart +++ b/test/proof/data/data_sources/witness_data_source_test.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart'; import 'package:polygonid_flutter_sdk/proof/data/data_sources/witness_data_source.dart'; import 'package:polygonid_flutter_sdk/proof/data/dtos/witness_param.dart'; import 'package:polygonid_flutter_sdk/proof/data/mappers/circuit_type_mapper.dart';