Skip to content

Commit

Permalink
Merge pull request #316 from 0xPolygonID/hotfix/proof-request-filteri…
Browse files Browse the repository at this point in the history
…ng-fix
  • Loading branch information
rauljareno authored May 24, 2023
2 parents 680f05b + ea3cbad commit f21dd2b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 41 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/polygonid_flutter_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
matrix:
device:
# The available simulators are listed by the "xcrun xctrace list devices" command
- "iPhone 13 Pro Max Simulator (16.2)" # the name of the simulator could be different depending on the macos version you are using
- "iPhone 14 Pro Max Simulator (16.2)" # the name of the simulator could be different depending on the macos version you are using
# if one of the jobs in the matrix expansion fails, the rest of the jobs will be cancelled
fail-fast: true
runs-on: macos-latest # or macos-latest if you prefer, but be aware that the available simulators could be different if you run a different version
Expand Down Expand Up @@ -88,11 +88,6 @@ jobs:
ENV_POLYGON_MUMBAI: ${{ secrets.ENV_POLYGON_MUMBAI }}
run: cd example&&flutter clean&&flutter pub get&&flutter pub run build_runner build --delete-conflicting-outputs

- name: Format
run: dart format --set-exit-if-changed lib test example

- name: Analyze
run: flutter analyze lib test example
- name: "List all simulators"
run: "xcrun xctrace list devices"
- name: "Start Simulator"
Expand All @@ -104,8 +99,8 @@ jobs:
echo $UDID
xcrun simctl boot "${UDID:?No Simulator with this name found}"
- name: Run integration tests
run: cd example&&flutter test integration_test/libpolygonid_test.dart --verbose
#- name: Run integration tests
# run: cd example&&flutter test integration_test/libpolygonid_test.dart --verbose

# job responsible for running Flutter tests on Android devices
# android:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Polygon ID Flutter SDK

[![pub package](https://img.shields.io/badge/pub-2.2.3-blueviolet)](https://pub.dev/packages/polygonid_flutter_sdk)
[![pub package](https://img.shields.io/badge/pub-2.2.4-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)
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ post_install do |installer|
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
config.build_settings['DEAD_CODE_STRIPPING'] = 'NO'
config.build_settings['STRIP_STYLE'] = 'non-global'
end
if target.name == "Pods-Runner"
puts "Updating #{target.name} OTHER_LDFLAGS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ class ClaimModelMapper implements FromMapper<ClaimEntity, ClaimModel> {
creationDate = DateFormat("d MMM yyyy").format(
DateTime.fromMillisecondsSinceEpoch(
(proof['issuerData']['state']['blockTimestamp']) * 1000));
proofType += '- SMT Signature\n';
} else if (proof['type'] == "BJJSignature2021") {
proofType += '- BJJ Signature\n';
} else {
proofType += '- ${proof['type']}\n';
}
proofType += '- ${proof['type']}\n';
}
proofType = proofType.substring(0, proofType.length - 1);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2+23050202
version: 2.2.4+23052803


environment:
Expand Down
2 changes: 1 addition & 1 deletion lib/common/data/data_sources/mappers/filter_mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FilterMapper extends ToMapper<Filter, FilterEntity> {
case FilterOperator.lesserEqual:
return Filter.lessThanOrEquals(to.name, to.value);
case FilterOperator.inList:
return Filter.inList(to.name, to.value);
return Filter.inList(to.name, to.value as List<Object>);
case FilterOperator.or:
return Filter.or((to.value as List<FilterEntity>)
.map((filter) => mapTo(filter))
Expand Down
2 changes: 1 addition & 1 deletion lib/common/domain/entities/filter_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum FilterOperator {
class FilterEntity {
final FilterOperator operator;
final String name;
final dynamic value;
final Object value;

FilterEntity(
{this.operator = FilterOperator.equal,
Expand Down
64 changes: 46 additions & 18 deletions lib/iden3comm/data/mappers/proof_request_filters_mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ class ProofRequestFiltersMapper

List<FilterEntity> filters = [
FilterEntity(
name: 'credential.credentialSubject.type', value: query.type),
name: 'credential.credentialSubject.type', value: query.type!),
FilterEntity(
operator: FilterOperator.equalsAnyInList,
name: 'credential.@context',
value: query.context),
value: query.context!),
];
if (query.allowedIssuers is List && query.allowedIssuers!.isNotEmpty) {
if (query.allowedIssuers != null &&
query.allowedIssuers is List &&
query.allowedIssuers!.isNotEmpty) {
if (query.allowedIssuers![0] != "*") {
filters.add(FilterEntity(
operator: FilterOperator.inList,
name: 'issuer',
value: query.allowedIssuers));
value: query.allowedIssuers!));
}
}

Expand All @@ -42,16 +44,38 @@ class ProofRequestFiltersMapper
if (query.credentialSubject != null) {
Map<String, dynamic> request = query.credentialSubject!;
request.forEach((key, map) {
if (map != null && map is Map) {
if (map != null &&
map is Map &&
map.isNotEmpty &&
context != null &&
context[key] != null &&
context[key]["@type"] != null) {
String type = context[key]["@type"];
if (type.contains("double")) {
// double not supported
filters.add(FilterEntity(
operator: FilterOperator.nonEqual,
name:
'schema.properties.credentialSubject.properties.$key.type',
value: "number"));
}
map.forEach((operator, value) {
if (context != null &&
context[key] != null &&
context[key]["@type"].contains("boolean")) {
if (type.contains("boolean")) {
FilterEntity? booleanFilter =
_getBooleanFiltersByOperator(key, operator, value);
if (booleanFilter != null) {
filters.add(booleanFilter);
}
} else if (type.contains("string")) {
if (operator == '\$in' || operator == '\$nin') {
List<dynamic> values = List.from(value);
List<String> stringList =
values.map((e) => e.toString()).toList();
filters.addAll(_getFilterByOperator(key, operator, stringList));
} else {
filters.addAll(
_getFilterByOperator(key, operator, value.toString()));
}
} else {
filters.addAll(_getFilterByOperator(key, operator, value));
}
Expand Down Expand Up @@ -85,17 +109,21 @@ class ProofRequestFiltersMapper
value: value)
];
case '\$in':
List<int> values = [];
List<dynamic> included = value;
for (int val in included) {
values.add(val);
if (value is List) {
return [
FilterEntity(
operator: FilterOperator.inList,
name: 'credential.credentialSubject.$field',
value: value)
];
} else {
return [
FilterEntity(
operator: FilterOperator.inList,
name: 'credential.credentialSubject.$field',
value: [value])
];
}
return [
FilterEntity(
operator: FilterOperator.inList,
name: 'credential.credentialSubject.$field',
value: values)
];
case '\$nin':
return List.from(value)
.map((item) => FilterEntity(
Expand Down
4 changes: 2 additions & 2 deletions lib/sdk/iden3comm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ abstract class PolygonIdSdkIden3comm {
BigInt? profileNonce,
required String privateKey});

/// Get a list of [ClaimEntity] from iden3comm message
/// stored in Polygon Id Sdk.
/// Get a list of [ClaimEntity] stored in Polygon Id Sdk that fulfills
/// the request from iden3comm message.
///
/// The [message] is the iden3comm message entity
///
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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.2
version: 2.2.4
homepage: https://polygon.technology/polygon-id
repository: https://github.com/iden3/polygonid-flutter-sdk
issue_tracker: https://github.com/iden3/polygonid-flutter-sdk/issues
Expand All @@ -16,9 +16,9 @@ dependencies:
http: ^0.13.6
ffi: ^2.0.1
hex: ^0.2.0
web3dart: 2.3.5
web3dart: ^2.6.1
web_socket_channel: ^2.2.0
ffigen: ^7.2.9
ffigen: ^8.0.2
json_annotation: ^4.6.0
equatable: ^2.0.3
crypto: ^3.0.1
Expand Down

0 comments on commit f21dd2b

Please sign in to comment.