diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index bed2f519e..72e527acb 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -101,9 +101,23 @@ jobs: - name: 📦 Install Dependencies run: | + if grep -q 'path: ../../../didkit/lib/flutter' ../did_kit/pubspec.yaml; then + sed -i 's|path: ../../../didkit/lib/flutter|git:\n url: https://github.com/spruceid/didkit.git\n path: lib/flutter|' ../did_kit/pubspec.yaml + fi flutter pub global activate very_good_cli very_good packages get --recursive --ignore=${{inputs.package_get_excludes}} + - name: 📦 Run build_runner for nested package if necessary + run: | + if grep -q 'path: ../credential_manifest' pubspec.yaml; then + initial_dir=$(pwd) + echo $initial_dir + cd ../credential_manifest + flutter pub get + dart pub run build_runner build --delete-conflicting-outputs + cd $initial_dir + fi + - name: ⚙️ Run Setup if: "${{inputs.setup != ''}}" run: ${{inputs.setup}} diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml index 53c8622a8..cb83c408f 100644 --- a/.github/workflows/oidc4vc.yaml +++ b/.github/workflows/oidc4vc.yaml @@ -11,4 +11,4 @@ jobs: min_coverage: 30 working_directory: packages/oidc4vc dart_sdk: 3.4.1 - build_runner: false + build_runner: true diff --git a/didkit/lib/flutter/android b/didkit/lib/flutter/android deleted file mode 120000 index e383911a8..000000000 --- a/didkit/lib/flutter/android +++ /dev/null @@ -1 +0,0 @@ -../../../../didkit/lib/flutter/android \ No newline at end of file diff --git a/didkit/lib/flutter/ios b/didkit/lib/flutter/ios deleted file mode 120000 index 6fefb81d6..000000000 --- a/didkit/lib/flutter/ios +++ /dev/null @@ -1 +0,0 @@ -../../../../didkit/lib/flutter/ios/ \ No newline at end of file diff --git a/didkit/lib/flutter/lib/didkit.dart b/didkit/lib/flutter/lib/didkit.dart deleted file mode 100644 index 0e2999069..000000000 --- a/didkit/lib/flutter/lib/didkit.dart +++ /dev/null @@ -1,522 +0,0 @@ -library didkit; - -import 'dart:ffi'; -import 'dart:io'; - -import 'package:ffi/ffi.dart'; - -// TODO: support Windows -final DynamicLibrary lib = Platform.isAndroid || Platform.isLinux - ? DynamicLibrary.open('libdidkit.so') - : Platform.isMacOS - ? DynamicLibrary.open('libdidkit.dylib') - : DynamicLibrary.process(); - -final get_version = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_get_version'); - -final get_error_message = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_error_message'); - -final get_error_code = - lib.lookupFunction('didkit_error_code'); - -final generate_ed25519_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_ed25519_key'); - -final generate_secp256r1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp256r1_key'); - -final generate_secp256k1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp256k1_key'); - -final generate_secp384r1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp384r1_key'); - -final key_to_did = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_key_to_did'); - -final key_to_verification_method = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_key_to_verification_method'); - -final issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_issue_credential'); - -final verify_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_verify_credential'); - -final issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_issue_presentation'); - -final verify_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_verify_presentation'); - -final resolve_did = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_resolve_did'); - -final dereference_did_url = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_dereference_did_url'); - -final did_auth = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_did_auth'); - -final create_context = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_create_context'); - -final create_context_map = lib.lookupFunction< - Pointer Function( - Pointer>, - Uint32, -), - Pointer Function( - Pointer>, - int, -)>('didkit_create_context_map'); - -final prepare_issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_prepare_issue_credential'); - -final complete_issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_complete_issue_credential'); - -final prepare_issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_prepare_issue_presentation'); - -final complete_issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_complete_issue_presentation'); - -final free_string = lib.lookupFunction< - Void Function( - Pointer, -), - void Function( - Pointer, -)>('didkit_free_string'); - -class DIDKitException implements Exception { - int code; - String message; - - DIDKitException(this.code, this.message); - - @override - String toString() { - return 'DIDKitException ($code): $message'; - } -} - -DIDKitException lastError() { - final code = get_error_code(); - final message_utf8 = get_error_message(); - final message_string = message_utf8.address == nullptr.address - ? 'Unable to get error message' - : message_utf8.toDartString(); - - return DIDKitException(code, message_string); -} - -class DIDKit { - static String getVersion() { - return get_version().toDartString(); - } - - static String generateEd25519Key() { - final key = generate_ed25519_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp256r1Key() { - final key = generate_secp256r1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp256k1Key() { - final key = generate_secp256k1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp384r1Key() { - final key = generate_secp384r1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - @Deprecated('Use [keyToDID]') - static String keyToDIDKey(String key) { - final did_key = key_to_did('key'.toNativeUtf8(), key.toNativeUtf8()); - if (did_key.address == nullptr.address) throw lastError(); - final did_key_string = did_key.toDartString(); - free_string(did_key); - return did_key_string; - } - - static String keyToDID(String methodPattern, String key) { - final did = key_to_did(methodPattern.toNativeUtf8(), key.toNativeUtf8()); - if (did.address == nullptr.address) throw lastError(); - final did_string = did.toDartString(); - free_string(did); - return did_string; - } - - static String keyToVerificationMethod(String methodPattern, String key) { - final vm = key_to_verification_method( - methodPattern.toNativeUtf8(), key.toNativeUtf8()); - if (vm.address == nullptr.address) throw lastError(); - final vm_string = vm.toDartString(); - free_string(vm); - return vm_string; - } - - static String issueCredential( - String credential, - String options, - String key, [ - String? contextMap, - ]) { - final vc = issue_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vc.address == nullptr.address) throw lastError(); - final vc_string = vc.toDartString(); - free_string(vc); - return vc_string; - } - - static String verifyCredential( - String credential, - String options, [ - String? contextMap, - ]) { - final result = verify_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String issuePresentation( - String presentation, - String options, - String key, [ - String? contextMap, - ]) { - final vp = issue_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } - - static String verifyPresentation( - String presentation, - String options, [ - String? contextMap, - ]) { - final result = verify_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String resolveDID(String did, String inputMetadata) { - final result = - resolve_did(did.toNativeUtf8(), inputMetadata.toNativeUtf8()); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String dereferenceDIDURL(String didUrl, String inputMetadata) { - final result = dereference_did_url( - didUrl.toNativeUtf8(), inputMetadata.toNativeUtf8()); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String DIDAuth( - String did, - String options, - String key, [ - String? contextMap, - ]) { - final vp = did_auth( - did.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } - - static String createContext( - String url, - String json, - ) { - final context = create_context( - url.toNativeUtf8(), - json.toNativeUtf8(), - ); - if (context.address == nullptr.address) throw lastError(); - final context_string = context.toDartString(); - free_string(context); - return context_string; - } - - static String createContextMap(List contexts) { - final size = contexts.length; - - // FOOTGUN NOTE: - // malloc.allocate(size); → allocates 'size' *bytes* - // malloc(size); → allocates 'size * sizeof(type)' bytes -- YOU WANT THIS ONE - - final array = malloc>(size); - - final native = contexts.map((c) => c.toNativeUtf8()).toList(); - - native.asMap().forEach((index, str) { - array[index] = str; - }); - - final context = create_context_map(array, size); - malloc.free(array); - - if (context.address == nullptr.address) throw lastError(); - final context_string = context.toDartString(); - free_string(context); - return context_string; - } - - static String prepareIssueCredential( - String credential, - String options, - String key, [ - String? contextMap, - ]) { - final prep = prepare_issue_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (prep.address == nullptr.address) throw lastError(); - final prep_string = prep.toDartString(); - free_string(prep); - return prep_string; - } - - static String completeIssueCredential( - String credential, - String preparation, - String signature, - ) { - final vc = complete_issue_credential( - credential.toNativeUtf8(), - preparation.toNativeUtf8(), - signature.toNativeUtf8(), - ); - if (vc.address == nullptr.address) throw lastError(); - final vc_string = vc.toDartString(); - free_string(vc); - return vc_string; - } - - static String prepareIssuePresentation( - String presentation, - String options, - String key, [ - String? contextMap, - ]) { - final prep = prepare_issue_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (prep.address == nullptr.address) throw lastError(); - final prep_string = prep.toDartString(); - free_string(prep); - return prep_string; - } - - static String completeIssuePresentation( - String presentation, - String preparation, - String signature, - ) { - final vp = complete_issue_presentation( - presentation.toNativeUtf8(), - preparation.toNativeUtf8(), - signature.toNativeUtf8(), - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } -} diff --git a/didkit/lib/flutter/libdidkit.a b/didkit/lib/flutter/libdidkit.a deleted file mode 120000 index 0acd2b089..000000000 --- a/didkit/lib/flutter/libdidkit.a +++ /dev/null @@ -1 +0,0 @@ -../../../didkit/lib/flutter/libdidkit.a \ No newline at end of file diff --git a/didkit/lib/flutter/libdidkit.so b/didkit/lib/flutter/libdidkit.so deleted file mode 120000 index 9929202ba..000000000 --- a/didkit/lib/flutter/libdidkit.so +++ /dev/null @@ -1 +0,0 @@ -../../../didkit/lib/flutter/libdidkit.so \ No newline at end of file diff --git a/didkit/lib/flutter/pubspec.lock b/didkit/lib/flutter/pubspec.lock deleted file mode 100644 index e86de7310..000000000 --- a/didkit/lib/flutter/pubspec.lock +++ /dev/null @@ -1,229 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - crypto: - dependency: transitive - description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.dev" - source: hosted - version: "3.0.3" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - ffi: - dependency: "direct main" - description: - name: ffi - sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - flutter: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" - url: "https://pub.dev" - source: hosted - version: "10.0.4" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" - url: "https://pub.dev" - source: hosted - version: "3.0.3" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" - url: "https://pub.dev" - source: hosted - version: "0.8.0" - meta: - dependency: transitive - description: - name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - path: - dependency: transitive - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" - source: hosted - version: "1.3.2" - uuid: - dependency: "direct dev" - description: - name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.dev" - source: hosted - version: "3.0.7" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" - url: "https://pub.dev" - source: hosted - version: "14.2.1" -sdks: - dart: ">=3.3.0 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" diff --git a/didkit/lib/flutter/pubspec.yaml b/didkit/lib/flutter/pubspec.yaml deleted file mode 100644 index 2113d2b16..000000000 --- a/didkit/lib/flutter/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: didkit -description: A new flutter plugin project. -version: 0.0.2 -author: Spruce Systems, Inc. -homepage: https://github.com/spruceid/didkit/tree/main/lib/flutter - -environment: - sdk: ">=2.12.0 <3.0.0" - -dependencies: - ffi: ^2.0.0 - -dev_dependencies: - flutter_test: - sdk: flutter - pedantic: ^1.11.0 - uuid: ^3.0.4 - -flutter: - plugin: - platforms: - android: - package: com.spruceid.DIDKit - pluginClass: DIDKitFlutterPlugin - ios: - pluginClass: DIDKitFlutterPlugin diff --git a/lib/app/shared/extension/extension.dart b/lib/app/shared/extension/extension.dart index c8a08d0ed..dc5db6f25 100644 --- a/lib/app/shared/extension/extension.dart +++ b/lib/app/shared/extension/extension.dart @@ -2,4 +2,4 @@ export 'bigint_extension.dart'; export 'double_extension.dart'; export 'iterable_extension.dart'; export 'string_extension.dart'; -export 'unit8List_extension.dart'; +export 'unit8list_extension.dart'; diff --git a/lib/app/shared/widget/button/my_elevated_button.dart b/lib/app/shared/widget/button/my_elevated_button.dart index 9e58c6ed0..62155f4f2 100644 --- a/lib/app/shared/widget/button/my_elevated_button.dart +++ b/lib/app/shared/widget/button/my_elevated_button.dart @@ -90,16 +90,16 @@ ButtonStyle elevatedStyleFrom({ GestureTapCallback? onPressed, }) { return ButtonStyle( - elevation: MaterialStateProperty.all(elevation), - padding: MaterialStateProperty.all( + elevation: WidgetStateProperty.all(elevation), + padding: WidgetStateProperty.all( EdgeInsets.symmetric(vertical: verticalSpacing), ), - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( onPressed == null ? Theme.of(context).colorScheme.disabledBgColor : backgroundColor ?? Theme.of(context).colorScheme.primary, ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), ), diff --git a/lib/app/shared/widget/checkbox_item.dart b/lib/app/shared/widget/checkbox_item.dart index d9cf52f36..52f263264 100644 --- a/lib/app/shared/widget/checkbox_item.dart +++ b/lib/app/shared/widget/checkbox_item.dart @@ -26,7 +26,7 @@ class CheckboxItem extends StatelessWidget { children: [ Checkbox( value: value, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), shape: const RoundedRectangleBorder( diff --git a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart index c1d1cbf9a..8581cb2e1 100644 --- a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart +++ b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart @@ -34,7 +34,7 @@ class CryptoAccountItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart b/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart index bafa0c81b..4b1e1ec1d 100644 --- a/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart +++ b/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart @@ -22,7 +22,7 @@ class AdvanceSettingsRadioItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart index c92d0aa7c..231e6b652 100644 --- a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart +++ b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart @@ -1,10 +1,8 @@ import 'package:altme/app/app.dart'; -import 'package:altme/credentials/credentials.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/theme/theme.dart'; -import 'package:altme/wallet/wallet.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/dashboard/drawer/src/view/drawer_page.dart b/lib/dashboard/drawer/src/view/drawer_page.dart index c518c887b..df9c74d38 100644 --- a/lib/dashboard/drawer/src/view/drawer_page.dart +++ b/lib/dashboard/drawer/src/view/drawer_page.dart @@ -120,8 +120,7 @@ class DrawerView extends StatelessWidget { ], if (profileModel - .profileSetting.settingsMenu.displayDeveloperMode && - profileModel.profileType != ProfileType.defaultOne) ...[ + .profileSetting.settingsMenu.displayDeveloperMode) ...[ DrawerCategoryItem( title: l10n.developerMode, subTitle: l10n.developerModeSubtitle, diff --git a/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart b/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart index 354cab5f6..3df20e18c 100644 --- a/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart +++ b/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart @@ -32,7 +32,7 @@ class SelectBoxAccountItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), checkColor: Theme.of(context).colorScheme.onPrimary, diff --git a/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart b/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart index 074c39ae5..e31e928a6 100644 --- a/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart +++ b/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart @@ -20,10 +20,11 @@ class QrCameraView extends StatefulWidget { }); final String title; - final Function(InputImage inputImage) onImage; + final dynamic Function(InputImage inputImage) onImage; final VoidCallback? onCameraFeedReady; final VoidCallback? onDetectorViewModeChanged; - final Function(CameraLensDirection direction)? onCameraLensDirectionChanged; + final dynamic Function(CameraLensDirection direction)? + onCameraLensDirectionChanged; final CameraLensDirection initialCameraLensDirection; @override @@ -34,7 +35,9 @@ class _QrCameraViewState extends State { static List _cameras = []; CameraController? _controller; int _cameraIndex = -1; + // ignore: unused_field double _currentZoomLevel = 1; + // ignore: unused_field double _minAvailableZoom = 1; // ignore: unused_field double _maxAvailableZoom = 1; diff --git a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart index 06f45ce5a..059451b36 100644 --- a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart +++ b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart @@ -25,7 +25,7 @@ class SelectNetworkFeeItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/src/view/dashboard_page.dart b/lib/dashboard/src/view/dashboard_page.dart index 6963197aa..d59d7496b 100644 --- a/lib/dashboard/src/view/dashboard_page.dart +++ b/lib/dashboard/src/view/dashboard_page.dart @@ -6,7 +6,6 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/enterprise/cubit/enterprise_cubit.dart'; import 'package:altme/kyc_verification/kyc_verification.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/splash/cubit/splash_cubit.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -162,12 +161,12 @@ class _DashboardViewState extends State { .helpCenterOptions .displayChatSupport; - return WillPopScope( - onWillPop: () async { + return PopScope( + canPop: false, + onPopInvoked: (_) async { if (scaffoldKey.currentState!.isDrawerOpen) { Navigator.of(context).pop(); } - return false; }, child: BasePage( scrollView: false, diff --git a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart index 286491ed0..1e1190477 100644 --- a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart +++ b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart @@ -138,7 +138,7 @@ class _WalletReadyViewState extends State { scale: 1.3, child: Checkbox( value: state.isAgreeWithTerms, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), materialTapTargetSize: diff --git a/lib/pin_code/cubit/pin_code_view_cubit.dart b/lib/pin_code/cubit/pin_code_view_cubit.dart index eeb77ed7c..db1d3cc9c 100644 --- a/lib/pin_code/cubit/pin_code_view_cubit.dart +++ b/lib/pin_code/cubit/pin_code_view_cubit.dart @@ -19,7 +19,7 @@ class PinCodeViewCubit extends Cubit { final loginAttemptCount = state.loginAttemptCount + 1; final loginAttemptsRemaining = totalPermitedLoginAttempt - state.loginAttemptCount - 1; - bool allowAction = true; + const allowAction = true; // if (loginAttemptCount >= totalPermitedLoginAttempt) { // allowAction = false; // _startLockTimer(); @@ -124,10 +124,12 @@ class PinCodeViewCubit extends Cubit { return; } } - emit(state.copyWith( - isPinCodeValid: true, - enteredPasscode: passCode, - )); + emit( + state.copyWith( + isPinCodeValid: true, + enteredPasscode: passCode, + ), + ); // on new pincode // void _onPasscodeEntered(String enteredPasscode) { diff --git a/lib/pin_code/view/confirm_pin_code_page.dart b/lib/pin_code/view/confirm_pin_code_page.dart index 9654197df..f67b2fc88 100644 --- a/lib/pin_code/view/confirm_pin_code_page.dart +++ b/lib/pin_code/view/confirm_pin_code_page.dart @@ -88,17 +88,17 @@ class _ConfirmPinCodeViewState extends State { backgroundColor: Theme.of(context).colorScheme.background, body: PinCodeWidget( title: l10n.confirmYourPinCode, - header: widget.isFromOnboarding - ? MStepper( - step: 1, - totalStep: byPassScreen ? 2 : 3, - ) - : null, - deleteButton: Text( - l10n.delete, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelButton: Text( + header: widget.isFromOnboarding + ? MStepper( + step: 1, + totalStep: byPassScreen ? 2 : 3, + ) + : null, + deleteButton: Text( + l10n.delete, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelButton: Text( l10n.cancel, style: Theme.of(context).textTheme.labelLarge, ), diff --git a/lib/pin_code/view/delete_my_wallet_page.dart b/lib/pin_code/view/delete_my_wallet_page.dart index e18555bc7..ad2e67d74 100644 --- a/lib/pin_code/view/delete_my_wallet_page.dart +++ b/lib/pin_code/view/delete_my_wallet_page.dart @@ -1,11 +1,9 @@ import 'package:altme/app/shared/constants/image_strings.dart'; import 'package:altme/app/shared/constants/sizes.dart'; import 'package:altme/app/shared/widget/widget.dart'; -import 'package:altme/credentials/cubit/credentials_cubit.dart'; import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; class DeleteMyWalletPage extends StatelessWidget { const DeleteMyWalletPage({super.key}); diff --git a/lib/pin_code/view/pin_code_page.dart b/lib/pin_code/view/pin_code_page.dart index 391b97a3e..fa3676f4d 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -1,4 +1,3 @@ - import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/pin_code/pin_code.dart'; @@ -82,8 +81,8 @@ class _PinCodeViewState extends State { @override Widget build(BuildContext context) { final l10n = context.l10n; - return WillPopScope( - onWillPop: () async => !widget.restrictToBack, + return PopScope( + canPop: !widget.restrictToBack, child: BasePage( backgroundColor: Theme.of(context).colorScheme.background, title: '', diff --git a/packages/did_kit/pubspec.yaml b/packages/did_kit/pubspec.yaml index 2dc8321f9..9c912fce4 100644 --- a/packages/did_kit/pubspec.yaml +++ b/packages/did_kit/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: didkit: - path: ../../didkit/lib/flutter + path: ../../../didkit/lib/flutter flutter: sdk: flutter mocktail: ^1.0.2 diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 84aa85714..6b9f249fa 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -147,12 +147,14 @@ class OIDC4VC { required String? clientAssertion, required bool secureAuthorizedFlow, required Dio dio, + SecureStorageProvider? secureStorage, }) async { try { final openIdConfiguration = await getOpenIdConfig( baseUrl: issuer, isAuthorizationServer: false, dio: dio, + secureStorage: secureStorage, ); final authorizationEndpoint = await readAuthorizationEndPoint( @@ -160,6 +162,7 @@ class OIDC4VC { issuer: issuer, oidc4vciDraftType: oidc4vciDraftType, dio: dio, + secureStorage: secureStorage, ); final authorizationRequestParemeters = getAuthorizationRequestParemeters( @@ -741,6 +744,7 @@ class OIDC4VC { required bool fromStatusList, required bool isCachingEnabled, required Dio dio, + SecureStorageProvider? secureStorage, }) async { try { if (isURL(didKey)) { @@ -758,6 +762,7 @@ class OIDC4VC { isAuthorizationServer: isAuthorizationServer, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); final authorizationServer = openIdConfiguration.authorizationServer; @@ -768,6 +773,7 @@ class OIDC4VC { isAuthorizationServer: true, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); } @@ -779,15 +785,26 @@ class OIDC4VC { openIdConfiguration.jwksUri!, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); return response as Map; } else { - final didDocument = await dio.get( - 'https://unires:test@unires.talao.co/1.0/identifiers/$didKey', - ); - - return didDocument.data as Map; + try { + final didDocument = await dio.get( + 'https://unires:test@unires.talao.co/1.0/identifiers/$didKey', + ); + return didDocument.data as Map; + } catch (e) { + try { + final didDocument = await dio.get( + 'https://dev.uniresolver.io/1.0/identifiers/$didKey', + ); + return didDocument.data as Map; + } catch (e) { + rethrow; + } + } } } catch (e) { rethrow; @@ -804,6 +821,7 @@ class OIDC4VC { required String issuer, required OIDC4VCIDraftType oidc4vciDraftType, required Dio dio, + SecureStorageProvider? secureStorage, }) async { var tokenEndPoint = '$issuer/token'; @@ -817,6 +835,7 @@ class OIDC4VC { baseUrl: authorizationServer, isAuthorizationServer: true, dio: dio, + secureStorage: secureStorage, ); if (authorizationServerConfiguration.tokenEndpoint != null) { @@ -832,6 +851,7 @@ class OIDC4VC { required String issuer, required OIDC4VCIDraftType oidc4vciDraftType, required Dio dio, + SecureStorageProvider? secureStorage, }) async { var authorizationEndpoint = '$issuer/authorize'; @@ -845,6 +865,7 @@ class OIDC4VC { baseUrl: authorizationServer, isAuthorizationServer: true, dio: dio, + secureStorage: secureStorage, ); if (authorizationServerConfiguration.authorizationEndpoint != null) { @@ -1618,6 +1639,7 @@ class OIDC4VC { required bool isAuthorizationServer, required Dio dio, bool isCachingEnabled = false, + SecureStorageProvider? secureStorage, }) async { ///for OIDC4VCI, the server is an issuer the metadata are all in th ////openid-issuer-configuration or some are in the /openid-configuration @@ -1633,6 +1655,7 @@ class OIDC4VC { baseUrl, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); return data; } @@ -1642,6 +1665,7 @@ class OIDC4VC { url, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); final data = response is String ? jsonDecode(response) as Map @@ -1662,6 +1686,7 @@ class OIDC4VC { String baseUrl, { required bool isCachingEnabled, required Dio dio, + SecureStorageProvider? secureStorage, }) async { final url = '$baseUrl/.well-known/openid-credential-issuer'; @@ -1670,6 +1695,7 @@ class OIDC4VC { url, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); final data = response is String ? jsonDecode(response) as Map @@ -1744,10 +1770,11 @@ class OIDC4VC { 'Content-Type': 'application/json; charset=UTF-8', }, bool isCachingEnabled = false, + SecureStorageProvider? secureStorage, }) async { try { - final secureStorageProvider = getSecureStorage; - final cachedData = await secureStorageProvider.get(uri); + final secureStorageProvider = secureStorage ?? getSecureStorage; + // final cachedData = await secureStorageProvider.get(uri); // TODO(hawkbee): To be removed. /// temporary solution to purge faulty stored data /// Will be removed in the future diff --git a/packages/oidc4vc/test/src/client_authentication_test.dart b/packages/oidc4vc/test/src/client_authentication_test.dart index 7bc7993a8..f3bf8bff2 100644 --- a/packages/oidc4vc/test/src/client_authentication_test.dart +++ b/packages/oidc4vc/test/src/client_authentication_test.dart @@ -4,12 +4,26 @@ import 'package:oidc4vc/oidc4vc.dart'; void main() { group('ClientAuthenticationX', () { test('value', () { - expect(ClientAuthentication.none.value, 'none'); expect( - ClientAuthentication.clientSecretBasic.value, 'client_secret_basic'); - expect(ClientAuthentication.clientSecretPost.value, 'client_secret_post'); - expect(ClientAuthentication.clientId.value, 'client_id'); - expect(ClientAuthentication.clientSecretJwt.value, 'client_secret_jwt'); + ClientAuthentication.none.value, + 'none', + ); + expect( + ClientAuthentication.clientSecretBasic.value, + 'client_secret_basic', + ); + expect( + ClientAuthentication.clientSecretPost.value, + 'client_secret_post', + ); + expect( + ClientAuthentication.clientId.value, + 'client_id', + ); + expect( + ClientAuthentication.clientSecretJwt.value, + 'client_secret_jwt', + ); }); }); } diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index 17c476de9..8e932d1dc 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -16,746 +16,805 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:http_mock_adapter/http_mock_adapter.dart'; import 'package:mocktail/mocktail.dart'; import 'package:oidc4vc/oidc4vc.dart'; +import 'package:secure_storage/secure_storage.dart'; class MockPkcePair extends Mock implements PkcePair {} +class MockSecureStorage extends Mock implements SecureStorageProvider {} + void main() { - final client = Dio(); - final dioAdapter = - DioAdapter(dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); + group('OIDC4VC Test', () { + final client = Dio(); + final dioAdapter = + DioAdapter(dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); - client.httpClientAdapter = dioAdapter; + client.httpClientAdapter = dioAdapter; - const mnemonic = - 'position taste mention august skin taste best air sure acoustic poet ritual'; + const mnemonic = + 'position taste mention august skin taste best air sure acoustic poet ritual'; - final oidc4vc = OIDC4VC(); - test('OIDC4VC class can be instantiated', () { - expect(oidc4vc, isNotNull); - }); + final oidc4vc = OIDC4VC(); - group('OIDC4VC DID and JWK', () { - const seedBytes = [ - 179, - 252, - 27, - 232, - 71, - 245, - 106, - 183, - 70, - 177, - 62, - 72, - 151, - 165, - 139, - 70, - 244, - 61, - 102, - 237, - 37, - 167, - 178, - 54, - 57, - 92, - 45, - 205, - 62, - 98, - 66, - 154, - ]; - - const expectedECJwk = { - 'crv': 'secp256k1', - 'd': 's_wb6Ef1ardGsT5Il6WLRvQ9Zu0lp7I2OVwtzT5iQpo', - 'kty': 'EC', - 'x': 'qs4JLbsmA-7L-3o9V4BoNVrDtYoWE2OOZIvujoVJZ1U', - 'y': '8PLGROkTALZP3YHY5pm0yrMVCjQoctHM3uaxug70mq8', - }; - - const index = 0; - test('JWK from mnemonic', () { - final jwk = oidc4vc.privateKeyFromMnemonic( - mnemonic: mnemonic, - indexValue: index, - ); - expect(jsonDecode(jwk), expectedECJwk); - }); + final mockSecureStorage = MockSecureStorage(); - test('JWK from seeds', () { - final jwk = oidc4vc.jwkFromSeed(seedBytes: Uint8List.fromList(seedBytes)); - expect(jwk, expectedECJwk); + setUpAll(() { + when(() => mockSecureStorage.delete(any())) + .thenAnswer((_) => Future.value()); }); - }); - test('P256 JWK from mnemonics', () { - final jwk = oidc4vc.p256PrivateKeyFromMnemonics( - mnemonic: mnemonic, - indexValue: 0, - ); - final expectedP256Jwk = { - 'kty': 'EC', - 'crv': 'P-256', - 'd': 's_wb6Ef1ardGsT5Il6WLRvQ9Zu0lp7I2OVwtzT5iQpo', - 'x': 'MZZjpNhZGGxqBcPXq499FVC2iu5FcZWwti5u8hgMUaI', - 'y': 'KD4zffV54PZUsQzTzVgoVlWHwKqogRF3JpKQnIGwIRM', - }; - - expect(jsonDecode(jwk), expectedP256Jwk); - }); - - group('edSSA sign and verify test', () { - const privateKey = { - 'kty': 'OKP', - 'crv': 'Ed25519', - 'd': 'lIxdBQu5EHleLsQRF8JOXAImgNu4FXrUs5SOcyrqvO0=', - 'x': 'r_HVGgBwEcVShl1Xt0C_Anc7Qhs4mS5ZUxsR4kq7Qe4=', - }; - - const payload = { - 'name': 'Bibash', - 'surname': 'Shrestha', - }; - - const kid = '3623b877bbb24b08ba390f3585418f53'; - - test('sign and verify with edDSA', () async { - final token = oidc4vc.generateTokenEdDSA( - payload: payload, - privateKey: privateKey, - kid: kid, - ); - - final value = oidc4vc.verifyTokenEdDSA( - token: token, - publicKey: privateKey, // public is private key with d - ); - - expect(value, true); + test('OIDC4VC class can be instantiated', () { + expect(oidc4vc, isNotNull); }); - }); - - group('selective disclosure', () { - const content = - '["Qg_O64zqAxe412a108iroA", "phone_number", "+81-80-1234-5678"]'; - const expectedDisclosure = - 'WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgInBob25lX251bWJlciIsICIrODEtODAtMTIzNC01Njc4Il0'; - - const expectedHash = 's0BKYsLWxQQeU8tVlltM7MKsIRTrEIa1PkJmqxBBf5U'; + group('OIDC4VC DID and JWK', () { + const seedBytes = [ + 179, + 252, + 27, + 232, + 71, + 245, + 106, + 183, + 70, + 177, + 62, + 72, + 151, + 165, + 139, + 70, + 244, + 61, + 102, + 237, + 37, + 167, + 178, + 54, + 57, + 92, + 45, + 205, + 62, + 98, + 66, + 154, + ]; + + const expectedECJwk = { + 'crv': 'secp256k1', + 'd': 's_wb6Ef1ardGsT5Il6WLRvQ9Zu0lp7I2OVwtzT5iQpo', + 'kty': 'EC', + 'x': 'qs4JLbsmA-7L-3o9V4BoNVrDtYoWE2OOZIvujoVJZ1U', + 'y': '8PLGROkTALZP3YHY5pm0yrMVCjQoctHM3uaxug70mq8', + }; + + const index = 0; + test('JWK from mnemonic', () { + final jwk = oidc4vc.privateKeyFromMnemonic( + mnemonic: mnemonic, + indexValue: index, + ); + expect(jsonDecode(jwk), expectedECJwk); + }); - test('get disclosure', () { - final disclosure = oidc4vc.getDisclosure(content); - expect(disclosure, expectedDisclosure); + test('JWK from seeds', () { + final jwk = + oidc4vc.jwkFromSeed(seedBytes: Uint8List.fromList(seedBytes)); + expect(jwk, expectedECJwk); + }); }); - test('sh256 hash of Disclosure test', () { - final sha256Hash = oidc4vc.sh256HashOfContent(content); - expect(sha256Hash, expectedHash); + test('P256 JWK from mnemonics', () { + final jwk = oidc4vc.p256PrivateKeyFromMnemonics( + mnemonic: mnemonic, + indexValue: 0, + ); + final expectedP256Jwk = { + 'kty': 'EC', + 'crv': 'P-256', + 'd': 's_wb6Ef1ardGsT5Il6WLRvQ9Zu0lp7I2OVwtzT5iQpo', + 'x': 'MZZjpNhZGGxqBcPXq499FVC2iu5FcZWwti5u8hgMUaI', + 'y': 'KD4zffV54PZUsQzTzVgoVlWHwKqogRF3JpKQnIGwIRM', + }; + + expect(jsonDecode(jwk), expectedP256Jwk); }); - }); - group('publicKeyBase58ToPublicJwk', () { - const publicKeyBase58 = '2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF'; + group('edSSA sign and verify test', () { + const privateKey = { + 'kty': 'OKP', + 'crv': 'Ed25519', + 'd': 'lIxdBQu5EHleLsQRF8JOXAImgNu4FXrUs5SOcyrqvO0=', + 'x': 'r_HVGgBwEcVShl1Xt0C_Anc7Qhs4mS5ZUxsR4kq7Qe4=', + }; + + const payload = { + 'name': 'Bibash', + 'surname': 'Shrestha', + }; + + const kid = '3623b877bbb24b08ba390f3585418f53'; + + test('sign and verify with edDSA', () async { + final token = oidc4vc.generateTokenEdDSA( + payload: payload, + privateKey: privateKey, + kid: kid, + ); - final expectedPublicJWK = { - 'crv': 'Ed25519', - 'kty': 'OKP', - 'x': 'FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo', - }; + final value = oidc4vc.verifyTokenEdDSA( + token: token, + publicKey: privateKey, // public is private key with d + ); - test('convert publicKeyBase58 to PublicJwk', () { - final publicKey = oidc4vc.publicKeyBase58ToPublicJwk(publicKeyBase58); - expect(publicKey, expectedPublicJWK); + expect(value, true); + }); }); - }); - - group('EBSI: getAuthorizationUriForIssuer', () { - const selectedCredentials = ['EmailPass']; - const clientId = - 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9'; - const redirectUri = 'https://app.altme.io/app/download/oidc4vc'; - - const issuer = 'https://talao.co/issuer/mfyttabosy'; - - const issuerState = 'test7'; - const nonce = '8b60e2fb-87f3-4401-8107-0f0128ea01ab'; - - const pkcePair = PkcePair( - 'Pzy4U_sJ0J7VdIAR6JCwL5hbecv30egmJVP81VDFAnk', - '4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA', - ); - const state = - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM'; - - const authorizationEndPoint = 'https://app.altme.io/app/download/authorize'; - - const openIdConfiguration = - '{"authorization_server":null,"credential_endpoint":"https://talao.co/issuer/mfyttabosy/credential","credential_issuer":"https://talao.co/issuer/mfyttabosy","subject_syntax_types_supported":["urn:ietf:params:oauth:jwk-thumbprint","did:key","did:ebsi","did:tz","did:pkh","did:hedera","did:key","did:ethr","did:web","did:jwk"],"token_endpoint":"https://talao.co/issuer/mfyttabosy/token","batch_endpoint":null,"authorization_endpoint":"https://talao.co/issuer/mfyttabosy/authorize","subject_trust_frameworks_supported":["ebsi"],"credentials_supported":null,"credential_configurations_supported":{"DBCGuest":{"credential_definition":{"type":["VerifiableCredential","DBCGuest"]},"display":[{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"The DBC Guest credential is a DIIP example.","logo":{"alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC Guest (DIIP)","text_color":"#FFFFFF"},{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"The DBC guest credential is a DIIP example.","locale":"en-US","logo":{"alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC Guest (DIIP)","text_color":"#FFFFFF"},{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"De DBC gast credential is een DIIP voorbeeld.","locale":"nl-NL","logo":{"alt_text":"Aaneengesloten open blokken in de kleur blauw, met een blok in de kleur oranje, die tesamen de achtergrond van de kaart vormen.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC gast (DIIP)","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"DBCGuest_scope"},"EmailPass":{"credential_definition":{"type":["VerifiableCredential","EmailPass"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Proof of Email"}],"format":"jwt_vc_json","scope":"EmailPass_scope"},"EmployeeCredential":{"credential_definition":{"type":["VerifiableCredential","EmployeeCredential"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"background_color":"#12107c","locale":"en-US","logo":{"alt_text":"a square logo of a university","url":"https://exampleuniversity.com/public/logo.png"},"name":"Employee Credential","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"EmployeeCredential_scope"},"Over18":{"credential_definition":{"type":["VerifiableCredential","Over18"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Over 18yo proof"},{"locale":"fr-GB","name":"Preuve de majorité"}],"format":"jwt_vc_json","scope":"Over18_scope"},"PhoneProof":{"credential_definition":{"type":["VerifiableCredential","PhoneProof"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Proof of phone number"}],"format":"jwt_vc_json","scope":"PhoneProof_scope"},"VerifiableId":{"credential_definition":{"credentialSubject":{"dateIssued":{"display":[{"locale":"en-US","name":"Issuance date"},{"locale":"fr-FR","name":"Délivré le"}],"mandatory":true},"dateOfBirth":{"display":[{"locale":"en-US","name":"Date of birth"},{"locale":"fr-FR","name":"Né(e) le"}],"mandatory":true},"email":{"display":[{"locale":"en-US","name":"Email"},{"locale":"fr-FR","name":"Email"}],"mandatory":true},"familyName":{"display":[{"locale":"en-US","name":"Family name"},{"locale":"fr-FR","name":"Nom"}],"mandatory":true},"firstName":{"display":[{"locale":"en-US","name":"First name"},{"locale":"fr-FR","name":"Prénom(s)"}],"mandatory":true},"gender":{"display":[{"locale":"en-US","name":"Gender"},{"locale":"fr-FR","name":"Sexe"}],"mandatory":true},"issuing_country":{"display":[{"locale":"en-US","name":"Issuing country"},{"locale":"fr-FR","name":"Délivré par"}],"mandatory":true},"phone_number":{"display":[{"locale":"en-US","name":"Phone number"},{"locale":"fr-FR","name":"Téléphone"}],"mandatory":true}},"order":["firstName","familyName","dateOfBirth","gender","dateIssued","issuing_country","email","phone_number"],"type":["VerifiableCredential","VerifiableId"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"background_color":"#12107c","locale":"en-US","name":"Verifiable Id","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"VerifiableId_scope"}},"deferred_credential_endpoint":"https://talao.co/issuer/mfyttabosy/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":"https://talao.co/issuer/mfyttabosy/jwks","grant_types_supported":["authorization_code","urn:ietf:params:oauth:grant-type:pre-authorized_code"]}'; - - test( - 'given Url of openid request we return Uri for authentication endpoint', - () async { - const expectedAuthorizationEndpoint = - 'https://talao.co/issuer/mfyttabosy/authorize'; - - const expectedAuthorizationRequestParemeters = { - 'response_type': 'code', - 'redirect_uri': 'https://app.altme.io/app/download/oidc4vc', - 'state': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM', - 'nonce': '8b60e2fb-87f3-4401-8107-0f0128ea01ab', - 'code_challenge': '4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA', - 'code_challenge_method': 'S256', - 'issuer_state': 'test7', - 'client_metadata': - '{\"authorization_endpoint\":\"https://app.altme.io/app/download/authorize\",\"scopes_supported\":[\"openid\"],\"response_types_supported\":[\"vp_token\",\"id_token\"],\"client_id_schemes_supported\":[\"redirect_uri\",\"did\"],\"grant_types_supported\":[\"authorization_code\",\"pre-authorized_code\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_object_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_parameter_supported\":true,\"request_uri_parameter_supported\":true,\"request_authentication_methods_supported\":{\"authorization_endpoint\":[\"request_object\"]},\"vp_formats_supported\":{\"jwt_vp\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]},\"jwt_vc\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]}},\"subject_syntax_types_supported\":[\"urn:ietf:params:oauth:jwk-thumbprint\",\"did:key\",\"did:pkh\",\"did:key\",\"did:polygonid\"],\"subject_syntax_types_discriminations\":[\"did:key:jwk_jcs-pub\",\"did:ebsi:v1\"],\"subject_trust_frameworks_supported\":[\"ebsi\"],\"id_token_types_supported\":[\"subject_signed_id_token\"],\"token_endpoint_auth_method\":\"client_id\"}', - 'client_id': - 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9', - 'scope': 'openid', - 'authorization_details': - '[{\"type\":\"openid_credential\",\"credential_configuration_id\":\"EmailPass\"}]', - }; - - dioAdapter.onGet( - 'https://talao.co/issuer/mfyttabosy/.well-known/openid-credential-issuer', - (request) => request.reply(200, jsonDecode(openIdConfiguration)), - ); + group('selective disclosure', () { + const content = + '["Qg_O64zqAxe412a108iroA", "phone_number", "+81-80-1234-5678"]'; - final (authorizationEndpoint, authorizationRequestParemeters) = - await oidc4vc.getAuthorizationData( - selectedCredentials: selectedCredentials, - clientId: clientId, - clientSecret: null, - redirectUri: redirectUri, - issuerState: issuerState, - nonce: nonce, - pkcePair: pkcePair, - state: state, - authorizationEndPoint: authorizationEndPoint, - scope: false, - clientAuthentication: ClientAuthentication.clientId, - oidc4vciDraftType: OIDC4VCIDraftType.draft13, - vcFormatType: VCFormatType.jwtVcJson, - clientAssertion: null, - secureAuthorizedFlow: false, - issuer: issuer, - dio: client, - ); + const expectedDisclosure = + 'WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgInBob25lX251bWJlciIsICIrODEtODAtMTIzNC01Njc4Il0'; - expect(authorizationEndpoint, expectedAuthorizationEndpoint); - expect( - authorizationRequestParemeters, - expectedAuthorizationRequestParemeters, - ); - }, - ); + const expectedHash = 's0BKYsLWxQQeU8tVlltM7MKsIRTrEIa1PkJmqxBBf5U'; - test( - 'throw Exception with when request is not valid', - () async { - expect( - () async => oidc4vc.getAuthorizationData( - selectedCredentials: [], - clientId: '', - issuer: '', - issuerState: '', - nonce: '', - state: '', - pkcePair: const PkcePair( - '', - '', - ), - authorizationEndPoint: '', - clientAssertion: '', - clientAuthentication: ClientAuthentication.clientId, - clientSecret: '', - oidc4vciDraftType: OIDC4VCIDraftType.draft11, - redirectUri: '', - scope: false, - secureAuthorizedFlow: false, - vcFormatType: VCFormatType.jwtVc, - dio: client, - ), - throwsA( - isA().having( - (p0) => p0.toString(), - 'toString()', - 'Exception: NOT_A_VALID_OPENID_URL', - ), - ), - ); - }, - ); + test('get disclosure', () { + final disclosure = oidc4vc.getDisclosure(content); + expect(disclosure, expectedDisclosure); + }); - test( - 'given correct authorization request parameter', - () async { - const expectedAuthorizationRequestParemeters = - r'{"response_type":"code","redirect_uri":"https://app.altme.io/app/download/oidc4vc","state":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM","nonce":"8b60e2fb-87f3-4401-8107-0f0128ea01ab","code_challenge":"4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA","code_challenge_method":"S256","issuer_state":"test7","client_metadata":"{\"authorization_endpoint\":\"https://app.altme.io/app/download/authorize\",\"scopes_supported\":[\"openid\"],\"response_types_supported\":[\"vp_token\",\"id_token\"],\"client_id_schemes_supported\":[\"redirect_uri\",\"did\"],\"grant_types_supported\":[\"authorization_code\",\"pre-authorized_code\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_object_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_parameter_supported\":true,\"request_uri_parameter_supported\":true,\"request_authentication_methods_supported\":{\"authorization_endpoint\":[\"request_object\"]},\"vp_formats_supported\":{\"jwt_vp\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]},\"jwt_vc\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]}},\"subject_syntax_types_supported\":[\"urn:ietf:params:oauth:jwk-thumbprint\",\"did:key\",\"did:pkh\",\"did:key\",\"did:polygonid\"],\"subject_syntax_types_discriminations\":[\"did:key:jwk_jcs-pub\",\"did:ebsi:v1\"],\"subject_trust_frameworks_supported\":[\"ebsi\"],\"id_token_types_supported\":[\"subject_signed_id_token\"],\"token_endpoint_auth_method\":\"client_id\"}","client_id":"did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9","scope":"openid","authorization_details":"[{\"type\":\"openid_credential\",\"credential_configuration_id\":\"EmailPass\"}]"}'; + test('sh256 hash of Disclosure test', () { + final sha256Hash = oidc4vc.sh256HashOfContent(content); + expect(sha256Hash, expectedHash); + }); + }); - final authorizationRequestParemeters = - oidc4vc.getAuthorizationRequestParemeters( - selectedCredentials: selectedCredentials, - clientId: clientId, - authorizationEndPoint: authorizationEndPoint, - clientAssertion: null, - scope: false, - clientAuthentication: ClientAuthentication.clientId, - oidc4vciDraftType: OIDC4VCIDraftType.draft13, - vcFormatType: VCFormatType.jwtVcJson, - secureAuthorizedFlow: false, - issuer: issuer, - issuerState: issuerState, - nonce: nonce, - state: state, - pkcePair: pkcePair, - clientSecret: null, - openIdConfiguration: OpenIdConfiguration.fromJson( - jsonDecode(openIdConfiguration) as Map, - ), - redirectUri: redirectUri, - ); + group('publicKeyBase58ToPublicJwk', () { + const publicKeyBase58 = '2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF'; - expect( - jsonEncode(authorizationRequestParemeters), - expectedAuthorizationRequestParemeters, - ); - }, - ); - }); + final expectedPublicJWK = { + 'crv': 'Ed25519', + 'kty': 'OKP', + 'x': 'FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo', + }; - group('OIC4VC request credential', () { - const issuer = 'https://talao.co/issuer/zxhaokccsi'; + test('convert publicKeyBase58 to PublicJwk', () { + final publicKey = oidc4vc.publicKeyBase58ToPublicJwk(publicKeyBase58); + expect(publicKey, expectedPublicJWK); + }); + }); - const credential = { - 'format': 'jwt_vc', - 'types': [ - 'VerifiableCredential', - 'VerifiableAttestation', - 'VerifiableDiploma2', - ], - }; + group('EBSI: getAuthorizationUriForIssuer', () { + const selectedCredentials = ['EmailPass']; + const clientId = + 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9'; + const redirectUri = 'https://app.altme.io/app/download/oidc4vc'; - const did = - 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa'; + const issuer = 'https://talao.co/issuer/mfyttabosy'; - const kid = - 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa#z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa'; + const issuerState = 'test7'; + const nonce = '8b60e2fb-87f3-4401-8107-0f0128ea01ab'; - const privateKey = - '{"kty":"EC","crv":"P-256","d":"amrwK13ZiYoJ5g0fc6MvXc86RB9ID8VuK_dMowU68FE","x":"fJQ2c9P_YDep3jzidwykcSlyoC4omqBvd9RHP1nz0cw","y":"K7VxrW-S1ONuX5cxrWIltF36ac1K8kj9as_o5cyc2zk"}'; + const pkcePair = PkcePair( + 'Pzy4U_sJ0J7VdIAR6JCwL5hbecv30egmJVP81VDFAnk', + '4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA', + ); - const openIdConfiguration = - '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; + const state = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM'; - const accessToken = '0f0119c2-0867-11ef-8bfa-0a1628958560'; + const authorizationEndPoint = + 'https://app.altme.io/app/download/authorize'; - const nonce = '0f011beb-0867-11ef-817f-0a1628958560'; + const openIdConfiguration = + '{"authorization_server":null,"credential_endpoint":"https://talao.co/issuer/mfyttabosy/credential","credential_issuer":"https://talao.co/issuer/mfyttabosy","subject_syntax_types_supported":["urn:ietf:params:oauth:jwk-thumbprint","did:key","did:ebsi","did:tz","did:pkh","did:hedera","did:key","did:ethr","did:web","did:jwk"],"token_endpoint":"https://talao.co/issuer/mfyttabosy/token","batch_endpoint":null,"authorization_endpoint":"https://talao.co/issuer/mfyttabosy/authorize","subject_trust_frameworks_supported":["ebsi"],"credentials_supported":null,"credential_configurations_supported":{"DBCGuest":{"credential_definition":{"type":["VerifiableCredential","DBCGuest"]},"display":[{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"The DBC Guest credential is a DIIP example.","logo":{"alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC Guest (DIIP)","text_color":"#FFFFFF"},{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"The DBC guest credential is a DIIP example.","locale":"en-US","logo":{"alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC Guest (DIIP)","text_color":"#FFFFFF"},{"background_color":"#3B6F6D","background_image":{"alt_text":"Connected open cubes in blue with one orange cube as a background of the card","url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png"},"description":"De DBC gast credential is een DIIP voorbeeld.","locale":"nl-NL","logo":{"alt_text":"Aaneengesloten open blokken in de kleur blauw, met een blok in de kleur oranje, die tesamen de achtergrond van de kaart vormen.","url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png"},"name":"DBC gast (DIIP)","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"DBCGuest_scope"},"EmailPass":{"credential_definition":{"type":["VerifiableCredential","EmailPass"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Proof of Email"}],"format":"jwt_vc_json","scope":"EmailPass_scope"},"EmployeeCredential":{"credential_definition":{"type":["VerifiableCredential","EmployeeCredential"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"background_color":"#12107c","locale":"en-US","logo":{"alt_text":"a square logo of a university","url":"https://exampleuniversity.com/public/logo.png"},"name":"Employee Credential","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"EmployeeCredential_scope"},"Over18":{"credential_definition":{"type":["VerifiableCredential","Over18"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Over 18yo proof"},{"locale":"fr-GB","name":"Preuve de majorité"}],"format":"jwt_vc_json","scope":"Over18_scope"},"PhoneProof":{"credential_definition":{"type":["VerifiableCredential","PhoneProof"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"locale":"en-GB","name":"Proof of phone number"}],"format":"jwt_vc_json","scope":"PhoneProof_scope"},"VerifiableId":{"credential_definition":{"credentialSubject":{"dateIssued":{"display":[{"locale":"en-US","name":"Issuance date"},{"locale":"fr-FR","name":"Délivré le"}],"mandatory":true},"dateOfBirth":{"display":[{"locale":"en-US","name":"Date of birth"},{"locale":"fr-FR","name":"Né(e) le"}],"mandatory":true},"email":{"display":[{"locale":"en-US","name":"Email"},{"locale":"fr-FR","name":"Email"}],"mandatory":true},"familyName":{"display":[{"locale":"en-US","name":"Family name"},{"locale":"fr-FR","name":"Nom"}],"mandatory":true},"firstName":{"display":[{"locale":"en-US","name":"First name"},{"locale":"fr-FR","name":"Prénom(s)"}],"mandatory":true},"gender":{"display":[{"locale":"en-US","name":"Gender"},{"locale":"fr-FR","name":"Sexe"}],"mandatory":true},"issuing_country":{"display":[{"locale":"en-US","name":"Issuing country"},{"locale":"fr-FR","name":"Délivré par"}],"mandatory":true},"phone_number":{"display":[{"locale":"en-US","name":"Phone number"},{"locale":"fr-FR","name":"Téléphone"}],"mandatory":true}},"order":["firstName","familyName","dateOfBirth","gender","dateIssued","issuing_country","email","phone_number"],"type":["VerifiableCredential","VerifiableId"]},"credential_signing_alg_values_supported":["ES256K","ES256","ES384","RS256"],"cryptographic_binding_methods_supported":["DID","jwk"],"display":[{"background_color":"#12107c","locale":"en-US","name":"Verifiable Id","text_color":"#FFFFFF"}],"format":"jwt_vc_json","scope":"VerifiableId_scope"}},"deferred_credential_endpoint":"https://talao.co/issuer/mfyttabosy/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":"https://talao.co/issuer/mfyttabosy/jwks","grant_types_supported":["authorization_code","urn:ietf:params:oauth:grant-type:pre-authorized_code"]}'; - const credentialRequestUrl = - 'https://talao.co/issuer/zxhaokccsi/credential'; + test( + 'given Url of openid request we return Uri for authentication endpoint', + () async { + const expectedAuthorizationEndpoint = + 'https://talao.co/issuer/mfyttabosy/authorize'; + + const expectedAuthorizationRequestParemeters = { + 'response_type': 'code', + 'redirect_uri': 'https://app.altme.io/app/download/oidc4vc', + 'state': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM', + 'nonce': '8b60e2fb-87f3-4401-8107-0f0128ea01ab', + 'code_challenge': '4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA', + 'code_challenge_method': 'S256', + 'issuer_state': 'test7', + 'client_metadata': + '{\"authorization_endpoint\":\"https://app.altme.io/app/download/authorize\",\"scopes_supported\":[\"openid\"],\"response_types_supported\":[\"vp_token\",\"id_token\"],\"client_id_schemes_supported\":[\"redirect_uri\",\"did\"],\"grant_types_supported\":[\"authorization_code\",\"pre-authorized_code\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_object_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_parameter_supported\":true,\"request_uri_parameter_supported\":true,\"request_authentication_methods_supported\":{\"authorization_endpoint\":[\"request_object\"]},\"vp_formats_supported\":{\"jwt_vp\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]},\"jwt_vc\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]}},\"subject_syntax_types_supported\":[\"urn:ietf:params:oauth:jwk-thumbprint\",\"did:key\",\"did:pkh\",\"did:key\",\"did:polygonid\"],\"subject_syntax_types_discriminations\":[\"did:key:jwk_jcs-pub\",\"did:ebsi:v1\"],\"subject_trust_frameworks_supported\":[\"ebsi\"],\"id_token_types_supported\":[\"subject_signed_id_token\"],\"token_endpoint_auth_method\":\"client_id\"}', + 'client_id': + 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9', + 'scope': 'openid', + 'authorization_details': + '[{\"type\":\"openid_credential\",\"credential_configuration_id\":\"EmailPass\"}]', + }; + + dioAdapter.onGet( + 'https://talao.co/issuer/mfyttabosy/.well-known/openid-credential-issuer', + (request) => request.reply(200, jsonDecode(openIdConfiguration)), + ); - const expecedCredentialResponse = - '{"credential":"eyJhbGciOiJFUzI1NiIsImtpZCI6InFsM2g2Z3Jqem5iaGNSRzVPRWk3V1B6dHNkZ1FLaGhiLXBOU1laSWgtdk0iLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3NDYxODE3NDYsImlhdCI6MTcxNDY0NTc0NiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9pc3N1ZXIvenhoYW9rY2NzaSIsImp0aSI6InVybjp1dWlkOmNkZGE4MWYyLTA4NmUtMTFlZi05ODE3LTBhMTYyODk1ODU2MCIsIm5iZiI6MTcxNDY0NTc0Niwibm9uY2UiOiJjOWZkMzJiYS0wODZlLTExZWYtOTQ5Yi0wYTE2Mjg5NTg1NjAiLCJzdWIiOiJkaWQ6a2V5OnoyZG16RDgxY2dQeDhWa2k3SmJ1dU1tRllyV1BnWW95dHlrVVozZXlxaHQxajlLYnJicGc1aXM4TGZUTHVRMVJzVzVyN3M3WmpiRERGYkRneTF0THJkYzdCajNpdEJHUWt1R1VReWZ6S2hGcWJVTlcyUHFKUE1TU3pXb0YyREdTdkRTaWpDdEp0WUNTUnNqU1ZMcnd1NW9ITmJuUEZ2U0VDNGlSWlBwVTZCNm5FeFJCVGEiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJjcmVkZW50aWFsU2NoZW1hIjp7ImlkIjoiaHR0cHM6Ly9hcGkucHJlcHJvZC5lYnNpLmV1L3RydXN0ZWQtc2NoZW1hcy1yZWdpc3RyeS92MS9zY2hlbWFzLzB4YmY3OGZjMDhhN2E5ZjI4ZjU0NzlmNThkZWEyNjlkMzY1N2Y1NGYxM2NhMzdkMzgwY2Q0ZTkyMjM3ZmI2OTFkZCIsInR5cGUiOiJKc29uU2NoZW1hVmFsaWRhdG9yMjAxOCJ9LCJjcmVkZW50aWFsU3RhdHVzIjpbeyJpZCI6Imh0dHBzOi8vdGFsYW8uY28vc2FuZGJveC9pc3N1ZXIvYml0c3RyaW5nc3RhdHVzbGlzdC8xIzczMDE5Iiwic3RhdHVzTGlzdENyZWRlbnRpYWwiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvaXNzdWVyL2JpdHN0cmluZ3N0YXR1c2xpc3QvMSIsInN0YXR1c0xpc3RJbmRleCI6IjczMDE5Iiwic3RhdHVzUHVycG9zZSI6InJldm9jYXRpb24iLCJ0eXBlIjoiQml0c3RyaW5nU3RhdHVzTGlzdEVudHJ5In1dLCJjcmVkZW50aWFsU3ViamVjdCI6eyJhd2FyZGluZ09wcG9ydHVuaXR5Ijp7ImF3YXJkaW5nQm9keSI6eyJlaWRhc0xlZ2FsSWRlbnRpZmllciI6IlVua25vd24iLCJob21lcGFnZSI6Imh0dHBzOi8vbGVhc3Rvbi5iY2RpcGxvbWEuY29tLyIsImlkIjoiZGlkOmVic2k6emRSdnZLYlhoVlZCc1hoYXRqdWlCaHMiLCJwcmVmZXJyZWROYW1lIjoiTGVhc3RvbiBVbml2ZXJzaXR5IiwicmVnaXN0cmF0aW9uIjoiMDU5NzA2NUoifSwiZW5kZWRBdFRpbWUiOiIyMDIwLTA2LTI2VDAwOjAwOjAwWiIsImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0F3YXJkaW5nT3Bwb3J0dW5pdHkiLCJpZGVudGlmaWVyIjoiaHR0cHM6Ly9jZXJ0aWZpY2F0ZS1kZW1vLmJjZGlwbG9tYS5jb20vY2hlY2svODdFRDJGMjI3MEU2QzQxNDU2RTk0Qjg2QjlEOTExNUI0RTM1QkNDQUQyMDBBNDlCODQ2NTkyQzE0Rjc5Qzg2QlYxRm5ibGx0YTBOWlRuSmtSM2xEV2xSbVREbFNSVUpFVkZaSVNtTm1ZekpoVVU1c1pVSjVaMkZKU0hwV2JtWloiLCJsb2NhdGlvbiI6IkZSQU5DRSIsInN0YXJ0ZWRBdFRpbWUiOiIyMDE5LTA5LTAyVDAwOjAwOjAwWiJ9LCJkYXRlT2ZCaXJ0aCI6IjE5OTMtMDQtMDgiLCJmYW1pbHlOYW1lIjoiRE9FIiwiZ2l2ZW5OYW1lcyI6IkphbmUiLCJncmFkaW5nU2NoZW1lIjp7ImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0dyYWRpbmdTY2hlbWUiLCJ0aXRsZSI6IjIgeWVhciBmdWxsLXRpbWUgcHJvZ3JhbW1lIC8gNCBzZW1lc3RlcnMifSwiaWRlbnRpZmllciI6IjA5MDQwMDgwODRIIiwibGVhcm5pbmdBY2hpZXZlbWVudCI6eyJhZGRpdGlvbmFsTm90ZSI6WyJESVNUUklCVVRJT04gTUFOQUdFTUVOVCJdLCJkZXNjcmlwdGlvbiI6IlRoZSBNYXN0ZXIgaW4gSW5mb3JtYXRpb24gYW5kIENvbXB1dGVyIFNjaWVuY2VzIChNSUNTKSBhdCB0aGUgVW5pdmVyc2l0eSBvZiBMdXhlbWJvdXJnIGVuYWJsZXMgc3R1ZGVudHMgdG8gYWNxdWlyZSBkZWVwZXIga25vd2xlZGdlIGluIGNvbXB1dGVyIHNjaWVuY2UgYnkgdW5kZXJzdGFuZGluZyBpdHMgYWJzdHJhY3QgYW5kIGludGVyZGlzY2lwbGluYXJ5IGZvdW5kYXRpb25zLCBmb2N1c2luZyBvbiBwcm9ibGVtIHNvbHZpbmcgYW5kIGRldmVsb3BpbmcgbGlmZWxvbmcgbGVhcm5pbmcgc2tpbGxzLiIsImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0xlYXJuaW5nQWNoaWV2bWVudCIsInRpdGxlIjoiTWFzdGVyIGluIEluZm9ybWF0aW9uIGFuZCBDb21wdXRlciBTY2llbmNlcyJ9LCJsZWFybmluZ1NwZWNpZmljYXRpb24iOnsiZWN0c0NyZWRpdFBvaW50cyI6MTIwLCJlcWZMZXZlbCI6NywiaWQiOiJodHRwczovL2xlYXN0b24uYmNkaXBsb21hLmNvbS9sYXctZWNvbm9taWNzLW1hbmFnZW1lbnQjTGVhcm5pbmdTcGVjaWZpY2F0aW9uIiwiaXNjZWRmQ29kZSI6WyI3Il0sIm5xZkxldmVsIjpbIjciXX0sInR5cGUiOiJWZXJpZmlhYmxlRGlwbG9tYTIifSwiZXZpZGVuY2UiOnsiZG9jdW1lbnRQcmVzZW5jZSI6WyJQaHlzaWNhbCJdLCJldmlkZW5jZURvY3VtZW50IjpbIlBhc3Nwb3J0Il0sImlkIjoiaHR0cHM6Ly9lc3NpZi5ldXJvcGEuZXUvdHNyLXZhL2V2aWRlbmNlL2YyYWVlYzk3LWZjMGQtNDJiZi04Y2E3LTA1NDgxOTJkNTY3OCIsInN1YmplY3RQcmVzZW5jZSI6IlBoeXNpY2FsIiwidHlwZSI6WyJEb2N1bWVudFZlcmlmaWNhdGlvbiJdLCJ2ZXJpZmllciI6ImRpZDplYnNpOjI5NjJmYjc4NGRmNjFiYWEyNjdjODEzMjQ5NzUzOWY4YzY3NGIzN2MxMjQ0YTdhIn0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJWZXJpZmlhYmxlQXR0ZXN0YXRpb24iLCJWZXJpZmlhYmxlRGlwbG9tYSJdfX0.eU1nRdOMklOK6kKvJk-0iCdng5gXZ7quZV1ob_kr2c3_7wSsOEhlgikZzTkkZAOuxmkkdSnWRsGMoA0M4YEi1Q","c_nonce":"cddafe06-086e-11ef-b80b-0a1628958560","c_nonce_expires_in":5000,"format":"jwt_vc"}'; - dioAdapter.onPost( - credentialRequestUrl, - (request) => request.reply( - 200, - expecedCredentialResponse, - ), - ); + final (authorizationEndpoint, authorizationRequestParemeters) = + await oidc4vc.getAuthorizationData( + selectedCredentials: selectedCredentials, + clientId: clientId, + clientSecret: null, + redirectUri: redirectUri, + issuerState: issuerState, + nonce: nonce, + pkcePair: pkcePair, + state: state, + authorizationEndPoint: authorizationEndPoint, + scope: false, + clientAuthentication: ClientAuthentication.clientId, + oidc4vciDraftType: OIDC4VCIDraftType.draft13, + vcFormatType: VCFormatType.jwtVcJson, + clientAssertion: null, + secureAuthorizedFlow: false, + issuer: issuer, + dio: client, + secureStorage: mockSecureStorage, + ); - test('When getCredentialType receive url it returns json response', - () async { - final (credentialResponseData, deferredCredentialEndpoint, format) = - await oidc4vc.getCredential( - issuer: issuer, - credential: credential, - did: did, - clientId: did, - kid: kid, - privateKey: privateKey, - cryptoHolderBinding: true, - clientType: ClientType.did, - proofHeaderType: ProofHeaderType.kid, - oidc4vciDraftType: OIDC4VCIDraftType.draft11, - clientAuthentication: ClientAuthentication.clientId, - proofType: ProofType.jwt, - openIdConfiguration: OpenIdConfiguration.fromJson( - jsonDecode(openIdConfiguration) as Map, - ), - accessToken: accessToken, - cnonce: nonce, - dio: client, + expect(authorizationEndpoint, expectedAuthorizationEndpoint); + expect( + authorizationRequestParemeters, + expectedAuthorizationRequestParemeters, + ); + }, ); - expect(credentialResponseData, [expecedCredentialResponse]); - expect( - deferredCredentialEndpoint, - 'https://talao.co/issuer/zxhaokccsi/deferred', + test( + 'throw Exception with when request is not valid', + () async { + expect( + () async => oidc4vc.getAuthorizationData( + selectedCredentials: [], + clientId: '', + issuer: '', + issuerState: '', + nonce: '', + state: '', + pkcePair: const PkcePair( + '', + '', + ), + authorizationEndPoint: '', + clientAssertion: '', + clientAuthentication: ClientAuthentication.clientId, + clientSecret: '', + oidc4vciDraftType: OIDC4VCIDraftType.draft11, + redirectUri: '', + scope: false, + secureAuthorizedFlow: false, + vcFormatType: VCFormatType.jwtVc, + dio: client, + ), + throwsA( + isA().having( + (p0) => p0.toString(), + 'toString()', + 'Exception: NOT_A_VALID_OPENID_URL', + ), + ), + ); + }, ); - expect(format, 'jwt_vc'); - }); - test('throw Exception when token is not verified', () { - expect( + test( + 'given correct authorization request parameter', () async { - await oidc4vc.getCredential( - issuer: '', - credential: null, - did: '', - clientId: null, - kid: '', - privateKey: '', - cryptoHolderBinding: true, - clientType: ClientType.did, - proofHeaderType: ProofHeaderType.kid, - oidc4vciDraftType: OIDC4VCIDraftType.draft11, + const expectedAuthorizationRequestParemeters = + r'{"response_type":"code","redirect_uri":"https://app.altme.io/app/download/oidc4vc","state":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlVmVyaWZpZXIiOiI0S29yQ3dtWXlPLV90NGlfaHZhN0YzYUhHcFRfMldxcURoNmVyaW1lcE9BIiwiY3JlZGVudGlhbHMiOlsiRW1haWxQYXNzIl0sImlzc3VlciI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL21meXR0YWJvc3kiLCJpc0VCU0lWMyI6ZmFsc2UsImNsaWVudF9pZCI6ImRpZDpqd2s6ZXlKamNuWWlPaUpRTFRJMU5pSXNJbXQwZVNJNklrVkRJaXdpZUNJNklqWmthMVUyV2sxR1N6YzVWM2RwWTNkS05YSmllRVV4TTNwVGRXdENXVEpQYjBWcFZsVkZhbkZOUldNaUxDSjVJam9pVW01SWVtNTVWbXh5VUZOTlZEZHBja1J6TVRWRU9YZDRaMDF2YW1sVFJFRlJjR1pHYUhGVWEweFNXU0o5IiwiaWF0IjoxNzE0NTQ5OTUxfQ.JJtv8H52NTvPzR3IPET1sXGALdt0yXaQBQbGvDLKNlM","nonce":"8b60e2fb-87f3-4401-8107-0f0128ea01ab","code_challenge":"4KorCwmYyO-_t4i_hva7F3aHGpT_2WqqDh6erimepOA","code_challenge_method":"S256","issuer_state":"test7","client_metadata":"{\"authorization_endpoint\":\"https://app.altme.io/app/download/authorize\",\"scopes_supported\":[\"openid\"],\"response_types_supported\":[\"vp_token\",\"id_token\"],\"client_id_schemes_supported\":[\"redirect_uri\",\"did\"],\"grant_types_supported\":[\"authorization_code\",\"pre-authorized_code\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_object_signing_alg_values_supported\":[\"ES256\",\"ES256K\"],\"request_parameter_supported\":true,\"request_uri_parameter_supported\":true,\"request_authentication_methods_supported\":{\"authorization_endpoint\":[\"request_object\"]},\"vp_formats_supported\":{\"jwt_vp\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]},\"jwt_vc\":{\"alg_values_supported\":[\"ES256\",\"ES256K\"]}},\"subject_syntax_types_supported\":[\"urn:ietf:params:oauth:jwk-thumbprint\",\"did:key\",\"did:pkh\",\"did:key\",\"did:polygonid\"],\"subject_syntax_types_discriminations\":[\"did:key:jwk_jcs-pub\",\"did:ebsi:v1\"],\"subject_trust_frameworks_supported\":[\"ebsi\"],\"id_token_types_supported\":[\"subject_signed_id_token\"],\"token_endpoint_auth_method\":\"client_id\"}","client_id":"did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9","scope":"openid","authorization_details":"[{\"type\":\"openid_credential\",\"credential_configuration_id\":\"EmailPass\"}]"}'; + + final authorizationRequestParemeters = + oidc4vc.getAuthorizationRequestParemeters( + selectedCredentials: selectedCredentials, + clientId: clientId, + authorizationEndPoint: authorizationEndPoint, + clientAssertion: null, + scope: false, clientAuthentication: ClientAuthentication.clientId, - proofType: ProofType.jwt, + oidc4vciDraftType: OIDC4VCIDraftType.draft13, + vcFormatType: VCFormatType.jwtVcJson, + secureAuthorizedFlow: false, + issuer: issuer, + issuerState: issuerState, + nonce: nonce, + state: state, + pkcePair: pkcePair, + clientSecret: null, openIdConfiguration: OpenIdConfiguration.fromJson( jsonDecode(openIdConfiguration) as Map, ), - accessToken: '', - cnonce: null, - dio: client, + redirectUri: redirectUri, + ); + + expect( + jsonEncode(authorizationRequestParemeters), + expectedAuthorizationRequestParemeters, ); }, - throwsA(isA()), ); }); - }); - - group('build token data', () { - const redirectUri = 'https://app.altme.io/app/download/callback'; - const preAuthorizedCode = - 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDplYnNpOjEyMzQja2V5LTEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvZWJzaS9pc3N1ZXIvenhoYW9rY2NzaSIsImNsaWVudF9pZCI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIiLCJleHAiOjE3MTQ2MzU4NDIsImlhdCI6MTcxNDYzNDg0MiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjZhMGJkZWUxLTA4NTUtMTFlZi04MzJlLTBhMTYyODk1ODU2MCIsInN1YiI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIifQ.ViX87lulUM6WZ0lNj5XMEz-Ty5q8nIcI7b-bIYa7VRsqo1wcR_en-8hzN_Q_sp8hqi8lKX80n4jM-DqXqvJk5g'; - - test('get token data with credentialRequestUri for preAuthorizedCode', - () async { - const clientId = - 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbpog7BZb9wdCJCjHfWMTpjcviuoFJ2fd9AiwsWGMFvhNJ5gVMA2mzHSFqkrLMXdHNeePjiaTP15sw8uaWDfyAxehGHKj7YsxymgVnEhcEJgKsLRJHgJZXAiXJGyRxWPGEYC'; - - const expectedTokenData = - '{"pre-authorized_code":"eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDplYnNpOjEyMzQja2V5LTEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvZWJzaS9pc3N1ZXIvenhoYW9rY2NzaSIsImNsaWVudF9pZCI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIiLCJleHAiOjE3MTQ2MzU4NDIsImlhdCI6MTcxNDYzNDg0MiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjZhMGJkZWUxLTA4NTUtMTFlZi04MzJlLTBhMTYyODk1ODU2MCIsInN1YiI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIifQ.ViX87lulUM6WZ0lNj5XMEz-Ty5q8nIcI7b-bIYa7VRsqo1wcR_en-8hzN_Q_sp8hqi8lKX80n4jM-DqXqvJk5g","grant_type":"urn:ietf:params:oauth:grant-type:pre-authorized_code","client_id":"did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbpog7BZb9wdCJCjHfWMTpjcviuoFJ2fd9AiwsWGMFvhNJ5gVMA2mzHSFqkrLMXdHNeePjiaTP15sw8uaWDfyAxehGHKj7YsxymgVnEhcEJgKsLRJHgJZXAiXJGyRxWPGEYC"}'; // ignore: lines_longer_than_80_chars - final tokenData = oidc4vc.buildTokenData( - redirectUri: redirectUri, - preAuthorizedCode: preAuthorizedCode, - clientId: clientId, - ); - expect(jsonEncode(tokenData), expectedTokenData); - }); + group('OIC4VC request credential', () { + const issuer = 'https://talao.co/issuer/zxhaokccsi'; - test('get token data with credentialRequestUri - authorization flow', () { - const clientId = - 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9'; - const expectedTokenData = - '{"code":"6486b7c9-0858-11ef-a82c-0a1628958560","grant_type":"authorization_code","code_verifier":"qZNF2gMjTQf7pJN2NMai1TS9Y81z8xzfPQtbmyVG-Gk","redirect_uri":"https://app.altme.io/app/download/callback","client_id":"did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9"}'; - final tokenData = oidc4vc.buildTokenData( - redirectUri: redirectUri, - clientId: clientId, - code: '6486b7c9-0858-11ef-a82c-0a1628958560', - codeVerifier: 'qZNF2gMjTQf7pJN2NMai1TS9Y81z8xzfPQtbmyVG-Gk', - ); - expect(jsonEncode(tokenData), expectedTokenData); - }); - }); + const credential = { + 'format': 'jwt_vc', + 'types': [ + 'VerifiableCredential', + 'VerifiableAttestation', + 'VerifiableDiploma2', + ], + }; - group('getIssuer', () { - test('get issuer with credentialRequestUri', () async { - const clientId = + const did = 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa'; - const expectedIssuerJwt = - 'eyJhbGciOiJFUzI1NiIsInR5cCI6Im9wZW5pZDR2Y2ktcHJvb2Yrand0Iiwia2lkIjoidmNEV1FrRzBmbXhmRm90clhKZFRZMEhzQklobTQ2UDZYYzNqcXdVbjRVWSJ9.eyJpc3MiOiJkaWQ6a2V5OnoyZG16RDgxY2dQeDhWa2k3SmJ1dU1tRllyV1BnWW95dHlrVVozZXlxaHQxajlLYnJicGc1aXM4TGZUTHVRMVJzVzVyN3M3WmpiRERGYkRneTF0THJkYzdCajNpdEJHUWt1R1VReWZ6S2hGcWJVTlcyUHFKUE1TU3pXb0YyREdTdkRTaWpDdEp0WUNTUnNqU1ZMcnd1NW9ITmJuUEZ2U0VDNGlSWlBwVTZCNm5FeFJCVGEiLCJpYXQiOjE3MTQ3MTU1NDQsImF1ZCI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjJkYTJkNTA2LTA5MTAtMTFlZi05ZTQ5LTBhMTYyODk1ODU2MCJ9.kmRv9RfhwGmAArHiqsZl7HkxE32vO9hyiVuI-lcMmpBPsgJ_eqPSXvkhSrIoUoKCtWAS3gaTT1hRZ5O0_fk9fA'; + const kid = + 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa#z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa'; - final tokenParameters = IssuerTokenParameters( - privateKey: { - 'kty': 'EC', - 'crv': 'P-256', - 'd': 'amrwK13ZiYoJ5g0fc6MvXc86RB9ID8VuK_dMowU68FE', - 'x': 'fJQ2c9P_YDep3jzidwykcSlyoC4omqBvd9RHP1nz0cw', - 'y': 'K7VxrW-S1ONuX5cxrWIltF36ac1K8kj9as_o5cyc2zk', - }, - did: clientId, - mediaType: MediaType.proofOfOwnership, - proofHeaderType: ProofHeaderType.kid, - clientType: ClientType.did, - clientId: clientId, - issuer: 'https://talao.co/issuer/zxhaokccsi', - ); - final issuerJwt = await oidc4vc.getIssuerJwt( - tokenParameters: tokenParameters, - clientAuthentication: ClientAuthentication.clientId, - iss: clientId, - cnonce: '2da2d506-0910-11ef-9e49-0a1628958560', - ); + const privateKey = + '{"kty":"EC","crv":"P-256","d":"amrwK13ZiYoJ5g0fc6MvXc86RB9ID8VuK_dMowU68FE","x":"fJQ2c9P_YDep3jzidwykcSlyoC4omqBvd9RHP1nz0cw","y":"K7VxrW-S1ONuX5cxrWIltF36ac1K8kj9as_o5cyc2zk"}'; - expect(issuerJwt.startsWith('ey'), expectedIssuerJwt.startsWith('ey')); - }); - }); + const openIdConfiguration = + '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; - test('get readTokenEndPoint with openidConfigurationResponse', () async { - const issuer = 'https://talao.co/issuer/zxhaokccsi'; - const openidConfigurationResponse = - '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; - const openidConfigurationResponse2 = - '{"authorization_endpoint":"https://talao.co/issuer/zxhaokccsi/authorize","grant_types_supported":["authorization_code","urn:ietf:params:oauth:grant-type:pre-authorized_code"],"id_token_signing_alg_values_supported":["ES256","ES256K","EdDSA","RS256"],"id_token_types_supported":["subject_signed_id_token"],"jwks_uri":"https://talao.co/issuer/zxhaokccsi/jwks","pushed_authorization_request_endpoint":"https://talao.co/issuer/zxhaokccsi/authorize/par","request_authentication_methods_supported":{"authorization_endpoint":["request_object"]},"request_object_signing_alg_values_supported":["ES256","ES256K","EdDSA","RS256"],"request_parameter_supported":true,"request_uri_parameter_supported":true,"response_modes_supported":["query"],"response_types_supported":["vp_token","id_token"],"scopes_supported":["openid"],"subject_syntax_types_discriminations":["did:key:jwk_jcs-pub","did:ebsi:v1"],"subject_syntax_types_supported":["urn:ietf:params:oauth:jwk-thumbprint","did:key","did:ebsi","did:tz","did:pkh","did:hedera","did:key","did:ethr","did:web","did:jwk"],"subject_trust_frameworks_supported":["ebsi"],"subject_types_supported":["public","pairwise"],"token_endpoint":"https://talao.co/issuer/zxhaokccsi/token","token_endpoint_auth_methods_supported":["client_secret_basic","client_secret_post","client_secret_jwt","none"]}'; - - const expectedTokenEndpoint = 'https://talao.co/issuer/zxhaokccsi/token'; - - dioAdapter.onPost( - '$issuer/.well-known/openid-configuration', - (request) => request.reply( - 200, - jsonDecode(openidConfigurationResponse2), - ), - ); + const accessToken = '0f0119c2-0867-11ef-8bfa-0a1628958560'; - final tokenEndpoint = await oidc4vc.readTokenEndPoint( - dio: client, - issuer: issuer, - oidc4vciDraftType: OIDC4VCIDraftType.draft11, - openIdConfiguration: OpenIdConfiguration.fromJson( - jsonDecode(openidConfigurationResponse) as Map, - ), - ); + const nonce = '0f011beb-0867-11ef-817f-0a1628958560'; - expect(tokenEndpoint, expectedTokenEndpoint); - }); + const credentialRequestUrl = + 'https://talao.co/issuer/zxhaokccsi/credential'; - test('get issuer did with openidConfigurationResponse', () { - const openidConfigurationResponse = - r'{"authorization_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/authorize","batch_credential_endpoint":null,"credential_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/credential","credential_issuer":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl","credential_manifests":[{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"display":{"description":{"fallback":"This card is a proof that you passed this diploma successfully. You can use this card when you need to prove this information to services that have adopted EU EBSI framework.","path":[],"schema":{"type":"string"}},"properties":[{"fallback":"Unknown","label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number"}},{"fallback":"Unknown","label":"Issue date","path":["$.issuanceDate"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"format":"uri","type":"string"}}],"subtitle":{"fallback":"EBSI Verifiable diploma","path":[],"schema":{"type":"string"}},"title":{"fallback":"Diploma","path":[],"schema":{"type":"string"}}},"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"spec_version":"https://identity.foundation/credential-manifest/spec/v1.0.0/"}],"credential_supported":[{"cryptographic_binding_methods_supported":["did"],"cryptographic_suites_supported":["ES256K","ES256","ES384","ES512","RS256"],"display":[{"locale":"en-US","name":"Issuer Talao"}],"format":"jwt_vc","id":"VerifiableDiploma","types":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"},{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"display":{"description":{"fallback":"This card is a proof that you passed this diploma successfully. You can use this card when you need to prove this information to services that have adopted EU EBSI framework.","path":[],"schema":{"type":"string"}},"properties":[{"fallback":"Unknown","label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number"}},{"fallback":"Unknown","label":"Issue date","path":["$.issuanceDate"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"format":"uri","type":"string"}}],"subtitle":{"fallback":"EBSI Verifiable diploma","path":[],"schema":{"type":"string"}},"title":{"fallback":"Diploma","path":[],"schema":{"type":"string"}}},"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"spec_version":"https://identity.foundation/credential-manifest/spec/v1.0.0/"}],"credential_supported":[{"cryptographic_binding_methods_supported":["did"],"cryptographic_suites_supported":["ES256K","ES256","ES384","ES512","RS256"],"display":[{"locale":"en-US","name":"Issuer Talao"}],"format":"jwt_vc","id":"VerifiableDiploma","types":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; + const expecedCredentialResponse = + '{"credential":"eyJhbGciOiJFUzI1NiIsImtpZCI6InFsM2g2Z3Jqem5iaGNSRzVPRWk3V1B6dHNkZ1FLaGhiLXBOU1laSWgtdk0iLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3NDYxODE3NDYsImlhdCI6MTcxNDY0NTc0NiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9pc3N1ZXIvenhoYW9rY2NzaSIsImp0aSI6InVybjp1dWlkOmNkZGE4MWYyLTA4NmUtMTFlZi05ODE3LTBhMTYyODk1ODU2MCIsIm5iZiI6MTcxNDY0NTc0Niwibm9uY2UiOiJjOWZkMzJiYS0wODZlLTExZWYtOTQ5Yi0wYTE2Mjg5NTg1NjAiLCJzdWIiOiJkaWQ6a2V5OnoyZG16RDgxY2dQeDhWa2k3SmJ1dU1tRllyV1BnWW95dHlrVVozZXlxaHQxajlLYnJicGc1aXM4TGZUTHVRMVJzVzVyN3M3WmpiRERGYkRneTF0THJkYzdCajNpdEJHUWt1R1VReWZ6S2hGcWJVTlcyUHFKUE1TU3pXb0YyREdTdkRTaWpDdEp0WUNTUnNqU1ZMcnd1NW9ITmJuUEZ2U0VDNGlSWlBwVTZCNm5FeFJCVGEiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJjcmVkZW50aWFsU2NoZW1hIjp7ImlkIjoiaHR0cHM6Ly9hcGkucHJlcHJvZC5lYnNpLmV1L3RydXN0ZWQtc2NoZW1hcy1yZWdpc3RyeS92MS9zY2hlbWFzLzB4YmY3OGZjMDhhN2E5ZjI4ZjU0NzlmNThkZWEyNjlkMzY1N2Y1NGYxM2NhMzdkMzgwY2Q0ZTkyMjM3ZmI2OTFkZCIsInR5cGUiOiJKc29uU2NoZW1hVmFsaWRhdG9yMjAxOCJ9LCJjcmVkZW50aWFsU3RhdHVzIjpbeyJpZCI6Imh0dHBzOi8vdGFsYW8uY28vc2FuZGJveC9pc3N1ZXIvYml0c3RyaW5nc3RhdHVzbGlzdC8xIzczMDE5Iiwic3RhdHVzTGlzdENyZWRlbnRpYWwiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvaXNzdWVyL2JpdHN0cmluZ3N0YXR1c2xpc3QvMSIsInN0YXR1c0xpc3RJbmRleCI6IjczMDE5Iiwic3RhdHVzUHVycG9zZSI6InJldm9jYXRpb24iLCJ0eXBlIjoiQml0c3RyaW5nU3RhdHVzTGlzdEVudHJ5In1dLCJjcmVkZW50aWFsU3ViamVjdCI6eyJhd2FyZGluZ09wcG9ydHVuaXR5Ijp7ImF3YXJkaW5nQm9keSI6eyJlaWRhc0xlZ2FsSWRlbnRpZmllciI6IlVua25vd24iLCJob21lcGFnZSI6Imh0dHBzOi8vbGVhc3Rvbi5iY2RpcGxvbWEuY29tLyIsImlkIjoiZGlkOmVic2k6emRSdnZLYlhoVlZCc1hoYXRqdWlCaHMiLCJwcmVmZXJyZWROYW1lIjoiTGVhc3RvbiBVbml2ZXJzaXR5IiwicmVnaXN0cmF0aW9uIjoiMDU5NzA2NUoifSwiZW5kZWRBdFRpbWUiOiIyMDIwLTA2LTI2VDAwOjAwOjAwWiIsImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0F3YXJkaW5nT3Bwb3J0dW5pdHkiLCJpZGVudGlmaWVyIjoiaHR0cHM6Ly9jZXJ0aWZpY2F0ZS1kZW1vLmJjZGlwbG9tYS5jb20vY2hlY2svODdFRDJGMjI3MEU2QzQxNDU2RTk0Qjg2QjlEOTExNUI0RTM1QkNDQUQyMDBBNDlCODQ2NTkyQzE0Rjc5Qzg2QlYxRm5ibGx0YTBOWlRuSmtSM2xEV2xSbVREbFNSVUpFVkZaSVNtTm1ZekpoVVU1c1pVSjVaMkZKU0hwV2JtWloiLCJsb2NhdGlvbiI6IkZSQU5DRSIsInN0YXJ0ZWRBdFRpbWUiOiIyMDE5LTA5LTAyVDAwOjAwOjAwWiJ9LCJkYXRlT2ZCaXJ0aCI6IjE5OTMtMDQtMDgiLCJmYW1pbHlOYW1lIjoiRE9FIiwiZ2l2ZW5OYW1lcyI6IkphbmUiLCJncmFkaW5nU2NoZW1lIjp7ImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0dyYWRpbmdTY2hlbWUiLCJ0aXRsZSI6IjIgeWVhciBmdWxsLXRpbWUgcHJvZ3JhbW1lIC8gNCBzZW1lc3RlcnMifSwiaWRlbnRpZmllciI6IjA5MDQwMDgwODRIIiwibGVhcm5pbmdBY2hpZXZlbWVudCI6eyJhZGRpdGlvbmFsTm90ZSI6WyJESVNUUklCVVRJT04gTUFOQUdFTUVOVCJdLCJkZXNjcmlwdGlvbiI6IlRoZSBNYXN0ZXIgaW4gSW5mb3JtYXRpb24gYW5kIENvbXB1dGVyIFNjaWVuY2VzIChNSUNTKSBhdCB0aGUgVW5pdmVyc2l0eSBvZiBMdXhlbWJvdXJnIGVuYWJsZXMgc3R1ZGVudHMgdG8gYWNxdWlyZSBkZWVwZXIga25vd2xlZGdlIGluIGNvbXB1dGVyIHNjaWVuY2UgYnkgdW5kZXJzdGFuZGluZyBpdHMgYWJzdHJhY3QgYW5kIGludGVyZGlzY2lwbGluYXJ5IGZvdW5kYXRpb25zLCBmb2N1c2luZyBvbiBwcm9ibGVtIHNvbHZpbmcgYW5kIGRldmVsb3BpbmcgbGlmZWxvbmcgbGVhcm5pbmcgc2tpbGxzLiIsImlkIjoiaHR0cHM6Ly9sZWFzdG9uLmJjZGlwbG9tYS5jb20vbGF3LWVjb25vbWljcy1tYW5hZ2VtZW50I0xlYXJuaW5nQWNoaWV2bWVudCIsInRpdGxlIjoiTWFzdGVyIGluIEluZm9ybWF0aW9uIGFuZCBDb21wdXRlciBTY2llbmNlcyJ9LCJsZWFybmluZ1NwZWNpZmljYXRpb24iOnsiZWN0c0NyZWRpdFBvaW50cyI6MTIwLCJlcWZMZXZlbCI6NywiaWQiOiJodHRwczovL2xlYXN0b24uYmNkaXBsb21hLmNvbS9sYXctZWNvbm9taWNzLW1hbmFnZW1lbnQjTGVhcm5pbmdTcGVjaWZpY2F0aW9uIiwiaXNjZWRmQ29kZSI6WyI3Il0sIm5xZkxldmVsIjpbIjciXX0sInR5cGUiOiJWZXJpZmlhYmxlRGlwbG9tYTIifSwiZXZpZGVuY2UiOnsiZG9jdW1lbnRQcmVzZW5jZSI6WyJQaHlzaWNhbCJdLCJldmlkZW5jZURvY3VtZW50IjpbIlBhc3Nwb3J0Il0sImlkIjoiaHR0cHM6Ly9lc3NpZi5ldXJvcGEuZXUvdHNyLXZhL2V2aWRlbmNlL2YyYWVlYzk3LWZjMGQtNDJiZi04Y2E3LTA1NDgxOTJkNTY3OCIsInN1YmplY3RQcmVzZW5jZSI6IlBoeXNpY2FsIiwidHlwZSI6WyJEb2N1bWVudFZlcmlmaWNhdGlvbiJdLCJ2ZXJpZmllciI6ImRpZDplYnNpOjI5NjJmYjc4NGRmNjFiYWEyNjdjODEzMjQ5NzUzOWY4YzY3NGIzN2MxMjQ0YTdhIn0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJWZXJpZmlhYmxlQXR0ZXN0YXRpb24iLCJWZXJpZmlhYmxlRGlwbG9tYSJdfX0.eU1nRdOMklOK6kKvJk-0iCdng5gXZ7quZV1ob_kr2c3_7wSsOEhlgikZzTkkZAOuxmkkdSnWRsGMoA0M4YEi1Q","c_nonce":"cddafe06-086e-11ef-b80b-0a1628958560","c_nonce_expires_in":5000,"format":"jwt_vc"}'; + dioAdapter.onPost( + credentialRequestUrl, + (request) => request.reply( + 200, + expecedCredentialResponse, + ), + ); - final issuer = oidc4vc.readIssuerDid( - Response( - requestOptions: RequestOptions(), - data: jsonDecode(openidConfigurationResponse) as Map, - ), - ); - expect(issuer, 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'); - }); + test('When getCredentialType receive url it returns json response', + () async { + final (credentialResponseData, deferredCredentialEndpoint, format) = + await oidc4vc.getCredential( + issuer: issuer, + credential: credential, + did: did, + clientId: did, + kid: kid, + privateKey: privateKey, + cryptoHolderBinding: true, + clientType: ClientType.did, + proofHeaderType: ProofHeaderType.kid, + oidc4vciDraftType: OIDC4VCIDraftType.draft11, + clientAuthentication: ClientAuthentication.clientId, + proofType: ProofType.jwt, + openIdConfiguration: OpenIdConfiguration.fromJson( + jsonDecode(openIdConfiguration) as Map, + ), + accessToken: accessToken, + cnonce: nonce, + dio: client, + ); - test('get publicKey did with didDocumentResponse', () { - const didDocument = - '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; - const issuerDid = 'https://talao.co/sandbox/issuer/statuslist'; - const holderKid = 'AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0'; + expect(credentialResponseData, [expecedCredentialResponse]); + expect( + deferredCredentialEndpoint, + 'https://talao.co/issuer/zxhaokccsi/deferred', + ); + expect(format, 'jwt_vc'); + }); - const expectedPublicKey = - '{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}'; + test('throw Exception when token is not verified', () { + expect( + () async { + await oidc4vc.getCredential( + issuer: '', + credential: null, + did: '', + clientId: null, + kid: '', + privateKey: '', + cryptoHolderBinding: true, + clientType: ClientType.did, + proofHeaderType: ProofHeaderType.kid, + oidc4vciDraftType: OIDC4VCIDraftType.draft11, + clientAuthentication: ClientAuthentication.clientId, + proofType: ProofType.jwt, + openIdConfiguration: OpenIdConfiguration.fromJson( + jsonDecode(openIdConfiguration) as Map, + ), + accessToken: '', + cnonce: null, + dio: client, + ); + }, + throwsA(isA()), + ); + }); + }); - final publicKey = oidc4vc.readPublicKeyJwk( - issuer: issuerDid, - holderKid: holderKid, - didDocument: jsonDecode(didDocument) as Map, - ); - expect(jsonEncode(publicKey), expectedPublicKey); - }); + group('build token data', () { + const redirectUri = 'https://app.altme.io/app/download/callback'; + const preAuthorizedCode = + 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDplYnNpOjEyMzQja2V5LTEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvZWJzaS9pc3N1ZXIvenhoYW9rY2NzaSIsImNsaWVudF9pZCI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIiLCJleHAiOjE3MTQ2MzU4NDIsImlhdCI6MTcxNDYzNDg0MiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjZhMGJkZWUxLTA4NTUtMTFlZi04MzJlLTBhMTYyODk1ODU2MCIsInN1YiI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIifQ.ViX87lulUM6WZ0lNj5XMEz-Ty5q8nIcI7b-bIYa7VRsqo1wcR_en-8hzN_Q_sp8hqi8lKX80n4jM-DqXqvJk5g'; - group('verify encoded data', () { - const issuer = 'did:web:talao.co'; - const issuerKid1 = 'did:web:talao.co#key-2'; - const issuerKid2 = 'did:web:talao.co#key-222'; - const issuerKid3 = 'did:web:talao.co#key-21'; - const issuerKid4 = 'did:web:talao.co#key-3'; + test('get token data with credentialRequestUri for preAuthorizedCode', + () async { + const clientId = + 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbpog7BZb9wdCJCjHfWMTpjcviuoFJ2fd9AiwsWGMFvhNJ5gVMA2mzHSFqkrLMXdHNeePjiaTP15sw8uaWDfyAxehGHKj7YsxymgVnEhcEJgKsLRJHgJZXAiXJGyRxWPGEYC'; - const universal = 'https://unires:test@unires.talao.co/1.0/identifiers'; + const expectedTokenData = + '{"pre-authorized_code":"eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDplYnNpOjEyMzQja2V5LTEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvZWJzaS9pc3N1ZXIvenhoYW9rY2NzaSIsImNsaWVudF9pZCI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIiLCJleHAiOjE3MTQ2MzU4NDIsImlhdCI6MTcxNDYzNDg0MiwiaXNzIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjZhMGJkZWUxLTA4NTUtMTFlZi04MzJlLTBhMTYyODk1ODU2MCIsInN1YiI6Imh0dHBzOi8vc2VsZi1pc3N1ZWQubWUvdjIifQ.ViX87lulUM6WZ0lNj5XMEz-Ty5q8nIcI7b-bIYa7VRsqo1wcR_en-8hzN_Q_sp8hqi8lKX80n4jM-DqXqvJk5g","grant_type":"urn:ietf:params:oauth:grant-type:pre-authorized_code","client_id":"did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbpog7BZb9wdCJCjHfWMTpjcviuoFJ2fd9AiwsWGMFvhNJ5gVMA2mzHSFqkrLMXdHNeePjiaTP15sw8uaWDfyAxehGHKj7YsxymgVnEhcEJgKsLRJHgJZXAiXJGyRxWPGEYC"}'; + final tokenData = oidc4vc.buildTokenData( + redirectUri: redirectUri, + preAuthorizedCode: preAuthorizedCode, + clientId: clientId, + ); - const jwt = - 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDp3ZWI6dGFsYW8uY28ja2V5LTIiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3NDYyNTUzMDYsImlhdCI6MTcxNDcxOTMwNiwiaXNzIjoiZGlkOndlYjp0YWxhby5jbyIsImp0aSI6InVybjp1dWlkOjEyZjdmNmI1LTA5MWEtMTFlZi04MWU1LTBhMTYyODk1ODU2MCIsIm5iZiI6MTcxNDcxOTMwNiwibm9uY2UiOiIxMWVhZTg1YS0wOTFhLTExZWYtODJkNC0wYTE2Mjg5NTg1NjAiLCJzdWIiOiJkaWQ6andrOmV5SmpjbllpT2lKUUxUSTFOaUlzSW10MGVTSTZJa1ZESWl3aWVDSTZJa1pIYTFScWFrUXhPR1l6VVRsc2FteG9WblEyVnpaMWJqSmtjbFJ1WjJoSU1XOVhSM1JRUmpOZk16Z2lMQ0o1SWpvaVkwWkNhWHBYZURoNE5rbE1XbWt5T1ZkRVFtNHpialU0WldWbGNra3ROVmMxWWxOeGVHaFFVR05RWXlKOSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIl0sImNyZWRlbnRpYWxTY2hlbWEiOnsiaWQiOiJodHRwczovL2FwaS1jb25mb3JtYW5jZS5lYnNpLmV1L3RydXN0ZWQtc2NoZW1hcy1yZWdpc3RyeS92Mi9zY2hlbWFzL3oyMlpBTWRRdE5Md2k1MVQydmRaWEdHWmFZeWpyc3VQMXl6V3lYWmlyQ0FIdiIsInR5cGUiOiJGdWxsSnNvblNjaGVtYVZhbGlkYXRvcjIwMjEifSwiY3JlZGVudGlhbFN0YXR1cyI6W3siaWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvaXNzdWVyL2JpdHN0cmluZ3N0YXR1c2xpc3QvMSM1ODg5NyIsInN0YXR1c0xpc3RDcmVkZW50aWFsIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2lzc3Vlci9iaXRzdHJpbmdzdGF0dXNsaXN0LzEiLCJzdGF0dXNMaXN0SW5kZXgiOiI1ODg5NyIsInN0YXR1c1B1cnBvc2UiOiJyZXZvY2F0aW9uIiwidHlwZSI6IkJpdHN0cmluZ1N0YXR1c0xpc3RFbnRyeSJ9XSwiY3JlZGVudGlhbFN1YmplY3QiOnsiZGF0ZUlzc3VlZCI6IjIwMjItMTItMjAiLCJkYXRlT2ZCaXJ0aCI6IjE5MzAtMTAtMDEiLCJmYW1pbHlOYW1lIjoiQ2FzdGFmaW9yaSIsImZpcnN0TmFtZSI6IkJpYW5jYSIsImdlbmRlciI6IkYiLCJ0eXBlIjoiVmVyaWZpYWJsZUlkIn0sImV4cGlyYXRpb25EYXRlIjoiMjAyNS0wNS0wM1QwNjo1NDo1M1oiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVmVyaWZpYWJsZUlkIl0sInZhbGlkRnJvbSI6IjIwMjUtMDUtMDNUMDY6NTQ6NTNaIn19.5DJwR_gUbu-GDpSF7hwXcpmHg-wYmKU_AxOvR4Psimefk0H4JUbX803svm3QhxIK2i4GgMhRWmgqhvML_x7nTw'; + expect(jsonEncode(tokenData), expectedTokenData); + }); - const didDocument = - r'{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w3.org/ns/did/v1",{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"}],"id":"did:web:talao.co","verificationMethod":[{"id":"did:web:talao.co#key-1","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"e":"AQAB","kid":"did:web:talao.co#key-1","kty":"RSA","n":"pPocyKreTAn3YrmGyPYXHklYqUiSSQirGACwJSYYs-ksfw4brtA3SZCmA2sdAO8a2DXfqADwFgVSxJFtJ3GkHLV2ZvOIOnZCX6MF6NIWHB9c64ydrYNJbEy72oyG_-v-sE6rb0x-D-uJe9DFYIURzisyBlNA7imsiZPQniOjPLv0BUgED0vdO5HijFe7XbpVhoU-2oTkHHQ4CadmBZhelCczACkXpOU7mwcImGj9h1__PsyT5VBLi_92-93NimZjechPaaTYEU2u0rfnfVW5eGDYNAynO4Q2bhpFPRTXWZ5Lhnhnq7M76T6DGA3GeAu_MOzB0l4dxpFMJ6wHnekdkQ"}},{"id":"did:web:talao.co#key-2","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"Bls7WaGu_jsharYBAzakvuSERIV_IFR2tS64e5p_Y_Q","y":"haeKjXQ9uzyK4Ind1W4SBUkR_9udjjx1OmKK4vl1jko"}},{"id":"did:web:talao.co#key-21","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI","y":"HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM"}},{"id":"did:web:talao.co#key-3","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}},{"id":"did:web:talao.co#key-4","type":"Ed25519VerificationKey2018","controller":"did:web:talao.co","publicKeyBase58":"2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF"}],"authentication":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"assertionMethod":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"keyAgreement":["did:web:talao.co#key-3","did:web:talao.co#key-4"],"capabilityInvocation":["did:web:talao.co#key-1","did:web:talao.co#key-4"],"service":[{"id":"did:web:talao.co#domain-1","type":"LinkedDomains","serviceEndpoint":"https://talao.co"}]},"didResolutionMetadata":{"contentType":"application/did+ld+json","pattern":"^(did:web:.+)$","driverUrl":"http://uni-resolver-driver-did-uport:8081/1.0/identifiers/","duration":42,"did":{"didString":"did:web:talao.co","methodSpecificId":"talao.co","method":"web"}},"didDocumentMetadata":{}}'; + test('get token data with credentialRequestUri - authorization flow', () { + const clientId = + 'did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9'; + const expectedTokenData = + '{"code":"6486b7c9-0858-11ef-a82c-0a1628958560","grant_type":"authorization_code","code_verifier":"qZNF2gMjTQf7pJN2NMai1TS9Y81z8xzfPQtbmyVG-Gk","redirect_uri":"https://app.altme.io/app/download/callback","client_id":"did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IjZka1U2Wk1GSzc5V3dpY3dKNXJieEUxM3pTdWtCWTJPb0VpVlVFanFNRWMiLCJ5IjoiUm5Iem55VmxyUFNNVDdpckRzMTVEOXd4Z01vamlTREFRcGZGaHFUa0xSWSJ9"}'; + final tokenData = oidc4vc.buildTokenData( + redirectUri: redirectUri, + clientId: clientId, + code: '6486b7c9-0858-11ef-a82c-0a1628958560', + codeVerifier: 'qZNF2gMjTQf7pJN2NMai1TS9Y81z8xzfPQtbmyVG-Gk', + ); + expect(jsonEncode(tokenData), expectedTokenData); + }); + }); - dioAdapter.onGet( - '$universal/$issuer', - (request) => request.reply(200, jsonDecode(didDocument)), - ); + group('getIssuer', () { + test('get issuer with credentialRequestUri', () async { + const clientId = + 'did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrbpg5is8LfTLuQ1RsW5r7s7ZjbDDFbDgy1tLrdc7Bj3itBGQkuGUQyfzKhFqbUNW2PqJPMSSzWoF2DGSvDSijCtJtYCSRsjSVLrwu5oHNbnPFvSEC4iRZPpU6B6nExRBTa'; + + const expectedIssuerJwt = + 'eyJhbGciOiJFUzI1NiIsInR5cCI6Im9wZW5pZDR2Y2ktcHJvb2Yrand0Iiwia2lkIjoidmNEV1FrRzBmbXhmRm90clhKZFRZMEhzQklobTQ2UDZYYzNqcXdVbjRVWSJ9.eyJpc3MiOiJkaWQ6a2V5OnoyZG16RDgxY2dQeDhWa2k3SmJ1dU1tRllyV1BnWW95dHlrVVozZXlxaHQxajlLYnJicGc1aXM4TGZUTHVRMVJzVzVyN3M3WmpiRERGYkRneTF0THJkYzdCajNpdEJHUWt1R1VReWZ6S2hGcWJVTlcyUHFKUE1TU3pXb0YyREdTdkRTaWpDdEp0WUNTUnNqU1ZMcnd1NW9ITmJuUEZ2U0VDNGlSWlBwVTZCNm5FeFJCVGEiLCJpYXQiOjE3MTQ3MTU1NDQsImF1ZCI6Imh0dHBzOi8vdGFsYW8uY28vaXNzdWVyL3p4aGFva2Njc2kiLCJub25jZSI6IjJkYTJkNTA2LTA5MTAtMTFlZi05ZTQ5LTBhMTYyODk1ODU2MCJ9.kmRv9RfhwGmAArHiqsZl7HkxE32vO9hyiVuI-lcMmpBPsgJ_eqPSXvkhSrIoUoKCtWAS3gaTT1hRZ5O0_fk9fA'; + + final tokenParameters = IssuerTokenParameters( + privateKey: { + 'kty': 'EC', + 'crv': 'P-256', + 'd': 'amrwK13ZiYoJ5g0fc6MvXc86RB9ID8VuK_dMowU68FE', + 'x': 'fJQ2c9P_YDep3jzidwykcSlyoC4omqBvd9RHP1nz0cw', + 'y': 'K7VxrW-S1ONuX5cxrWIltF36ac1K8kj9as_o5cyc2zk', + }, + did: clientId, + mediaType: MediaType.proofOfOwnership, + proofHeaderType: ProofHeaderType.kid, + clientType: ClientType.did, + clientId: clientId, + issuer: 'https://talao.co/issuer/zxhaokccsi', + ); + final issuerJwt = await oidc4vc.getIssuerJwt( + tokenParameters: tokenParameters, + clientAuthentication: ClientAuthentication.clientId, + iss: clientId, + cnonce: '2da2d506-0910-11ef-9e49-0a1628958560', + ); - test('returns VerificationType.verified', () async { - final isVerified = await oidc4vc.verifyEncodedData( - issuer: issuer, - jwt: jwt, - issuerKid: issuerKid1, - dio: client, - fromStatusList: false, - isCachingEnabled: false, - publicJwk: null, - ); - expect(isVerified, VerificationType.verified); + expect(issuerJwt.startsWith('ey'), expectedIssuerJwt.startsWith('ey')); + }); }); - test('returns VerificationType.unKnown', () async { - final isVerified = await oidc4vc.verifyEncodedData( - issuer: issuer, - jwt: jwt, - issuerKid: issuerKid2, - dio: client, - fromStatusList: false, - isCachingEnabled: false, - publicJwk: null, + test('get readTokenEndPoint with openidConfigurationResponse', () async { + const issuer = 'https://talao.co/issuer/zxhaokccsi'; + const openidConfigurationResponse = + '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; + const openidConfigurationResponse2 = + '{"authorization_endpoint":"https://talao.co/issuer/zxhaokccsi/authorize","grant_types_supported":["authorization_code","urn:ietf:params:oauth:grant-type:pre-authorized_code"],"id_token_signing_alg_values_supported":["ES256","ES256K","EdDSA","RS256"],"id_token_types_supported":["subject_signed_id_token"],"jwks_uri":"https://talao.co/issuer/zxhaokccsi/jwks","pushed_authorization_request_endpoint":"https://talao.co/issuer/zxhaokccsi/authorize/par","request_authentication_methods_supported":{"authorization_endpoint":["request_object"]},"request_object_signing_alg_values_supported":["ES256","ES256K","EdDSA","RS256"],"request_parameter_supported":true,"request_uri_parameter_supported":true,"response_modes_supported":["query"],"response_types_supported":["vp_token","id_token"],"scopes_supported":["openid"],"subject_syntax_types_discriminations":["did:key:jwk_jcs-pub","did:ebsi:v1"],"subject_syntax_types_supported":["urn:ietf:params:oauth:jwk-thumbprint","did:key","did:ebsi","did:tz","did:pkh","did:hedera","did:key","did:ethr","did:web","did:jwk"],"subject_trust_frameworks_supported":["ebsi"],"subject_types_supported":["public","pairwise"],"token_endpoint":"https://talao.co/issuer/zxhaokccsi/token","token_endpoint_auth_methods_supported":["client_secret_basic","client_secret_post","client_secret_jwt","none"]}'; + + const expectedTokenEndpoint = 'https://talao.co/issuer/zxhaokccsi/token'; + + dioAdapter.onPost( + '$issuer/.well-known/openid-configuration', + (request) => request.reply( + 200, + jsonDecode(openidConfigurationResponse2), + ), ); - expect(isVerified, VerificationType.unKnown); - }); - test('returns VerificationType.notVerified', () async { - const vcJwt = - 'eyJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTcxNDcyMjY3NiwiaWF0IjoxNzE0NzIyNjc2fQ.mVQhu1VmyA6LlcA77NmdhUvTrOoawL_VxhrMzkkh7BE'; - final isVerified = await oidc4vc.verifyEncodedData( - issuer: issuer, - jwt: vcJwt, - issuerKid: issuerKid3, + final tokenEndpoint = await oidc4vc.readTokenEndPoint( dio: client, - fromStatusList: false, - isCachingEnabled: false, - publicJwk: null, + issuer: issuer, + oidc4vciDraftType: OIDC4VCIDraftType.draft11, + openIdConfiguration: OpenIdConfiguration.fromJson( + jsonDecode(openidConfigurationResponse) as Map, + ), + secureStorage: mockSecureStorage, ); - expect(isVerified, VerificationType.notVerified); + + expect(tokenEndpoint, expectedTokenEndpoint); }); - test('returns VerificationType.notVerified for OKP', () async { - const vcJwt = 'eyJraWQiOiItMTkwOTU3MjI1NyIsImFsZyI6IkVkRFNBIn0.' - 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' // ignore: lines_longer_than_80_chars - 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; // ignore: lines_longer_than_80_chars + test('get issuer did with openidConfigurationResponse', () { + const openidConfigurationResponse = + r'{"authorization_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/authorize","batch_credential_endpoint":null,"credential_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/credential","credential_issuer":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl","credential_manifests":[{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"display":{"description":{"fallback":"This card is a proof that you passed this diploma successfully. You can use this card when you need to prove this information to services that have adopted EU EBSI framework.","path":[],"schema":{"type":"string"}},"properties":[{"fallback":"Unknown","label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number"}},{"fallback":"Unknown","label":"Issue date","path":["$.issuanceDate"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"format":"uri","type":"string"}}],"subtitle":{"fallback":"EBSI Verifiable diploma","path":[],"schema":{"type":"string"}},"title":{"fallback":"Diploma","path":[],"schema":{"type":"string"}}},"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"spec_version":"https://identity.foundation/credential-manifest/spec/v1.0.0/"}],"credential_supported":[{"cryptographic_binding_methods_supported":["did"],"cryptographic_suites_supported":["ES256K","ES256","ES384","ES512","RS256"],"display":[{"locale":"en-US","name":"Issuer Talao"}],"format":"jwt_vc","id":"VerifiableDiploma","types":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"},{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"display":{"description":{"fallback":"This card is a proof that you passed this diploma successfully. You can use this card when you need to prove this information to services that have adopted EU EBSI framework.","path":[],"schema":{"type":"string"}},"properties":[{"fallback":"Unknown","label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number"}},{"fallback":"Unknown","label":"Issue date","path":["$.issuanceDate"],"schema":{"format":"date","type":"string"}},{"fallback":"Unknown","label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string"}},{"fallback":"Unknown","label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"format":"uri","type":"string"}}],"subtitle":{"fallback":"EBSI Verifiable diploma","path":[],"schema":{"type":"string"}},"title":{"fallback":"Diploma","path":[],"schema":{"type":"string"}}},"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"spec_version":"https://identity.foundation/credential-manifest/spec/v1.0.0/"}],"credential_supported":[{"cryptographic_binding_methods_supported":["did"],"cryptographic_suites_supported":["ES256K","ES256","ES384","ES512","RS256"],"display":[{"locale":"en-US","name":"Issuer Talao"}],"format":"jwt_vc","id":"VerifiableDiploma","types":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; - final isVerified = await oidc4vc.verifyEncodedData( - issuer: issuer, - jwt: vcJwt, - issuerKid: issuerKid4, - dio: client, - fromStatusList: false, - isCachingEnabled: false, - publicJwk: null, + final issuer = oidc4vc.readIssuerDid( + Response( + requestOptions: RequestOptions(), + data: jsonDecode(openidConfigurationResponse) as Map, + ), ); - expect(isVerified, VerificationType.notVerified); + expect(issuer, 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'); }); - }); - - group('get token', () { - const tokenEndPoint = 'https://talao.co/issuer/zarbjrqrzj/token'; - const tokenData = { - 'pre-authorized_code': '5cdf5508-0923-11ef-90b1-0a1628958560', - 'grant_type': 'urn:ietf:params:oauth:grant-type:pre-authorized_code', - 'client_id': 'did:key:zDnaeoAcB8wFcSWqLeiJbCg663C3qAKkEfuuTM9rGWx2NFWCt', - 'user_pin': '4444', - 'tx_code': '4444', - }; - test('get correct token ', () async { - const response = - '{"access_token":"ac9e48a7-0923-11ef-95a3-0a1628958560","c_nonce":"ac9e4a9c-0923-11ef-a47c-0a1628958560","token_type":"Bearer","expires_in":10000,"c_nonce_expires_in":1704466725,"refresh_token":"ac9e49f2-0923-11ef-91ef-0a1628958560"}'; + test('get publicKey did with didDocumentResponse', () { + const didDocument = + '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; + const issuerDid = 'https://talao.co/sandbox/issuer/statuslist'; + const holderKid = 'AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0'; - dioAdapter.onPost( - tokenEndPoint, - (request) => request.reply(200, jsonDecode(response)), - ); + const expectedPublicKey = + '{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}'; - const expectedValue = - '{"access_token":"ac9e48a7-0923-11ef-95a3-0a1628958560","c_nonce":"ac9e4a9c-0923-11ef-a47c-0a1628958560","token_type":"Bearer","expires_in":10000,"c_nonce_expires_in":1704466725,"refresh_token":"ac9e49f2-0923-11ef-91ef-0a1628958560"}'; - final token = await oidc4vc.getToken( - dio: client, - tokenData: tokenData, - tokenEndPoint: tokenEndPoint, - authorization: null, + final publicKey = oidc4vc.readPublicKeyJwk( + issuer: issuerDid, + holderKid: holderKid, + didDocument: jsonDecode(didDocument) as Map, ); - - expect(jsonEncode(token), expectedValue); + expect(jsonEncode(publicKey), expectedPublicKey); }); - test('throw expection when invalid value is sent', () async { - expect( - () async { - dioAdapter.onPost( - tokenEndPoint, - (request) => request.throws( - 401, - DioException(requestOptions: RequestOptions(path: tokenEndPoint)), - ), - ); + group('verify encoded data', () { + const issuer = 'did:web:talao.co'; + const issuerKid1 = 'did:web:talao.co#key-2'; + const issuerKid2 = 'did:web:talao.co#key-222'; + const issuerKid3 = 'did:web:talao.co#key-21'; + const issuerKid4 = 'did:web:talao.co#key-3'; - await oidc4vc.getToken( - dio: client, - tokenData: tokenData, - tokenEndPoint: tokenEndPoint, - authorization: null, - ); - }, - throwsA(isA()), - ); - }); - }); + const universal = 'https://unires:test@unires.talao.co/1.0/identifiers'; - group( - 'get did document', - () { - test('get corresponding did document', () async { - const issuer = 'did:web:talao.co'; - const universal = 'https://unires:test@unires.talao.co/1.0/identifiers'; + const jwt = + 'eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDp3ZWI6dGFsYW8uY28ja2V5LTIiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3NDYyNTUzMDYsImlhdCI6MTcxNDcxOTMwNiwiaXNzIjoiZGlkOndlYjp0YWxhby5jbyIsImp0aSI6InVybjp1dWlkOjEyZjdmNmI1LTA5MWEtMTFlZi04MWU1LTBhMTYyODk1ODU2MCIsIm5iZiI6MTcxNDcxOTMwNiwibm9uY2UiOiIxMWVhZTg1YS0wOTFhLTExZWYtODJkNC0wYTE2Mjg5NTg1NjAiLCJzdWIiOiJkaWQ6andrOmV5SmpjbllpT2lKUUxUSTFOaUlzSW10MGVTSTZJa1ZESWl3aWVDSTZJa1pIYTFScWFrUXhPR1l6VVRsc2FteG9WblEyVnpaMWJqSmtjbFJ1WjJoSU1XOVhSM1JRUmpOZk16Z2lMQ0o1SWpvaVkwWkNhWHBYZURoNE5rbE1XbWt5T1ZkRVFtNHpialU0WldWbGNra3ROVmMxWWxOeGVHaFFVR05RWXlKOSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIl0sImNyZWRlbnRpYWxTY2hlbWEiOnsiaWQiOiJodHRwczovL2FwaS1jb25mb3JtYW5jZS5lYnNpLmV1L3RydXN0ZWQtc2NoZW1hcy1yZWdpc3RyeS92Mi9zY2hlbWFzL3oyMlpBTWRRdE5Md2k1MVQydmRaWEdHWmFZeWpyc3VQMXl6V3lYWmlyQ0FIdiIsInR5cGUiOiJGdWxsSnNvblNjaGVtYVZhbGlkYXRvcjIwMjEifSwiY3JlZGVudGlhbFN0YXR1cyI6W3siaWQiOiJodHRwczovL3RhbGFvLmNvL3NhbmRib3gvaXNzdWVyL2JpdHN0cmluZ3N0YXR1c2xpc3QvMSM1ODg5NyIsInN0YXR1c0xpc3RDcmVkZW50aWFsIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2lzc3Vlci9iaXRzdHJpbmdzdGF0dXNsaXN0LzEiLCJzdGF0dXNMaXN0SW5kZXgiOiI1ODg5NyIsInN0YXR1c1B1cnBvc2UiOiJyZXZvY2F0aW9uIiwidHlwZSI6IkJpdHN0cmluZ1N0YXR1c0xpc3RFbnRyeSJ9XSwiY3JlZGVudGlhbFN1YmplY3QiOnsiZGF0ZUlzc3VlZCI6IjIwMjItMTItMjAiLCJkYXRlT2ZCaXJ0aCI6IjE5MzAtMTAtMDEiLCJmYW1pbHlOYW1lIjoiQ2FzdGFmaW9yaSIsImZpcnN0TmFtZSI6IkJpYW5jYSIsImdlbmRlciI6IkYiLCJ0eXBlIjoiVmVyaWZpYWJsZUlkIn0sImV4cGlyYXRpb25EYXRlIjoiMjAyNS0wNS0wM1QwNjo1NDo1M1oiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVmVyaWZpYWJsZUlkIl0sInZhbGlkRnJvbSI6IjIwMjUtMDUtMDNUMDY6NTQ6NTNaIn19.5DJwR_gUbu-GDpSF7hwXcpmHg-wYmKU_AxOvR4Psimefk0H4JUbX803svm3QhxIK2i4GgMhRWmgqhvML_x7nTw'; - const didDocument = - r'{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w3.org/ns/did/v1",{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"}],"id":"did:web:talao.co","verificationMethod":[{"id":"did:web:talao.co#key-1","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"e":"AQAB","kid":"did:web:talao.co#key-1","kty":"RSA","n":"pPocyKreTAn3YrmGyPYXHklYqUiSSQirGACwJSYYs-ksfw4brtA3SZCmA2sdAO8a2DXfqADwFgVSxJFtJ3GkHLV2ZvOIOnZCX6MF6NIWHB9c64ydrYNJbEy72oyG_-v-sE6rb0x-D-uJe9DFYIURzisyBlNA7imsiZPQniOjPLv0BUgED0vdO5HijFe7XbpVhoU-2oTkHHQ4CadmBZhelCczACkXpOU7mwcImGj9h1__PsyT5VBLi_92-93NimZjechPaaTYEU2u0rfnfVW5eGDYNAynO4Q2bhpFPRTXWZ5Lhnhnq7M76T6DGA3GeAu_MOzB0l4dxpFMJ6wHnekdkQ"}},{"id":"did:web:talao.co#key-2","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"Bls7WaGu_jsharYBAzakvuSERIV_IFR2tS64e5p_Y_Q","y":"haeKjXQ9uzyK4Ind1W4SBUkR_9udjjx1OmKK4vl1jko"}},{"id":"did:web:talao.co#key-21","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI","y":"HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM"}},{"id":"did:web:talao.co#key-3","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}},{"id":"did:web:talao.co#key-4","type":"Ed25519VerificationKey2018","controller":"did:web:talao.co","publicKeyBase58":"2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF"}],"authentication":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"assertionMethod":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"keyAgreement":["did:web:talao.co#key-3","did:web:talao.co#key-4"],"capabilityInvocation":["did:web:talao.co#key-1","did:web:talao.co#key-4"],"service":[{"id":"did:web:talao.co#domain-1","type":"LinkedDomains","serviceEndpoint":"https://talao.co"}]},"didResolutionMetadata":{"contentType":"application/did+ld+json","pattern":"^(did:web:.+)$","driverUrl":"http://uni-resolver-driver-did-uport:8081/1.0/identifiers/","duration":42,"did":{"didString":"did:web:talao.co","methodSpecificId":"talao.co","method":"web"}},"didDocumentMetadata":{}}'; + const didDocument = + r'{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w3.org/ns/did/v1",{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"}],"id":"did:web:talao.co","verificationMethod":[{"id":"did:web:talao.co#key-1","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"e":"AQAB","kid":"did:web:talao.co#key-1","kty":"RSA","n":"pPocyKreTAn3YrmGyPYXHklYqUiSSQirGACwJSYYs-ksfw4brtA3SZCmA2sdAO8a2DXfqADwFgVSxJFtJ3GkHLV2ZvOIOnZCX6MF6NIWHB9c64ydrYNJbEy72oyG_-v-sE6rb0x-D-uJe9DFYIURzisyBlNA7imsiZPQniOjPLv0BUgED0vdO5HijFe7XbpVhoU-2oTkHHQ4CadmBZhelCczACkXpOU7mwcImGj9h1__PsyT5VBLi_92-93NimZjechPaaTYEU2u0rfnfVW5eGDYNAynO4Q2bhpFPRTXWZ5Lhnhnq7M76T6DGA3GeAu_MOzB0l4dxpFMJ6wHnekdkQ"}},{"id":"did:web:talao.co#key-2","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"Bls7WaGu_jsharYBAzakvuSERIV_IFR2tS64e5p_Y_Q","y":"haeKjXQ9uzyK4Ind1W4SBUkR_9udjjx1OmKK4vl1jko"}},{"id":"did:web:talao.co#key-21","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI","y":"HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM"}},{"id":"did:web:talao.co#key-3","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}},{"id":"did:web:talao.co#key-4","type":"Ed25519VerificationKey2018","controller":"did:web:talao.co","publicKeyBase58":"2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF"}],"authentication":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"assertionMethod":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"keyAgreement":["did:web:talao.co#key-3","did:web:talao.co#key-4"],"capabilityInvocation":["did:web:talao.co#key-1","did:web:talao.co#key-4"],"service":[{"id":"did:web:talao.co#domain-1","type":"LinkedDomains","serviceEndpoint":"https://talao.co"}]},"didResolutionMetadata":{"contentType":"application/did+ld+json","pattern":"^(did:web:.+)$","driverUrl":"http://uni-resolver-driver-did-uport:8081/1.0/identifiers/","duration":42,"did":{"didString":"did:web:talao.co","methodSpecificId":"talao.co","method":"web"}},"didDocumentMetadata":{}}'; - dioAdapter.onGet( - '$universal/$issuer', - (request) => request.reply(200, jsonDecode(didDocument)), - ); + dioAdapter.onGet( + '$universal/$issuer', + (request) => request.reply(200, jsonDecode(didDocument)), + ); - final value = await oidc4vc.getDidDocument( - didKey: issuer, + test('returns VerificationType.verified', () async { + final isVerified = await oidc4vc.verifyEncodedData( + issuer: issuer, + jwt: jwt, + issuerKid: issuerKid1, + dio: client, fromStatusList: false, isCachingEnabled: false, + publicJwk: null, + ); + expect(isVerified, VerificationType.verified); + }); + + test('returns VerificationType.unKnown', () async { + final isVerified = await oidc4vc.verifyEncodedData( + issuer: issuer, + jwt: jwt, + issuerKid: issuerKid2, dio: client, + fromStatusList: false, + isCachingEnabled: false, + publicJwk: null, ); + expect(isVerified, VerificationType.unKnown); + }); - expect(value, jsonDecode(didDocument)); + test('returns VerificationType.notVerified', () async { + const vcJwt = + 'eyJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTcxNDcyMjY3NiwiaWF0IjoxNzE0NzIyNjc2fQ.mVQhu1VmyA6LlcA77NmdhUvTrOoawL_VxhrMzkkh7BE'; + final isVerified = await oidc4vc.verifyEncodedData( + issuer: issuer, + jwt: vcJwt, + issuerKid: issuerKid3, + dio: client, + fromStatusList: false, + isCachingEnabled: false, + publicJwk: null, + ); + expect(isVerified, VerificationType.notVerified); }); - test('get corresponding did document', () async { - const issuer = 'https://talao.co/issuer/zxhaokccsi'; - const openidConfigurationResponse1 = - '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; - const openidConfigurationResponse2 = - '{"authorization_server":null,"credential_endpoint":null,"credential_issuer":null,"subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":null,"credential_configurations_supported":null,"deferred_credential_endpoint":null,"service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":"https://talao.co/sandbox/issuer/statuslist","jwks_uri":"https://talao.co/sandbox/issuer/statuslist/jwks","grant_types_supported":null}'; - const jwkUriResponse = - '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; - - const expectedDidDocument = - '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; - - dioAdapter - ..onGet( - '$issuer/.well-known/openid-credential-issuer', - (request) => - request.reply(200, jsonDecode(openidConfigurationResponse1)), - ) - ..onGet( - '$issuer/.well-known/openid-configuration', - (request) => - request.reply(200, jsonDecode(openidConfigurationResponse2)), - ) - ..onGet( - 'https://talao.co/sandbox/issuer/statuslist/jwks', - (request) => request.reply(200, jsonDecode(jwkUriResponse)), - ); + test('returns VerificationType.notVerified for OKP', () async { + const vcJwt = 'eyJraWQiOiItMTkwOTU3MjI1NyIsImFsZyI6IkVkRFNBIn0.' + 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' + 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; - final value = await oidc4vc.getDidDocument( - didKey: issuer, + final isVerified = await oidc4vc.verifyEncodedData( + issuer: issuer, + jwt: vcJwt, + issuerKid: issuerKid4, + dio: client, fromStatusList: false, isCachingEnabled: false, + publicJwk: null, + ); + expect(isVerified, VerificationType.notVerified); + }); + }); + + group('get token', () { + const tokenEndPoint = 'https://talao.co/issuer/zarbjrqrzj/token'; + const tokenData = { + 'pre-authorized_code': '5cdf5508-0923-11ef-90b1-0a1628958560', + 'grant_type': 'urn:ietf:params:oauth:grant-type:pre-authorized_code', + 'client_id': + 'did:key:zDnaeoAcB8wFcSWqLeiJbCg663C3qAKkEfuuTM9rGWx2NFWCt', + 'user_pin': '4444', + 'tx_code': '4444', + }; + + test('get correct token ', () async { + const response = + '{"access_token":"ac9e48a7-0923-11ef-95a3-0a1628958560","c_nonce":"ac9e4a9c-0923-11ef-a47c-0a1628958560","token_type":"Bearer","expires_in":10000,"c_nonce_expires_in":1704466725,"refresh_token":"ac9e49f2-0923-11ef-91ef-0a1628958560"}'; + + dioAdapter.onPost( + tokenEndPoint, + (request) => request.reply(200, jsonDecode(response)), + ); + + const expectedValue = + '{"access_token":"ac9e48a7-0923-11ef-95a3-0a1628958560","c_nonce":"ac9e4a9c-0923-11ef-a47c-0a1628958560","token_type":"Bearer","expires_in":10000,"c_nonce_expires_in":1704466725,"refresh_token":"ac9e49f2-0923-11ef-91ef-0a1628958560"}'; + final token = await oidc4vc.getToken( dio: client, + tokenData: tokenData, + tokenEndPoint: tokenEndPoint, + authorization: null, ); - expect(value, jsonDecode(expectedDidDocument)); + + expect(jsonEncode(token), expectedValue); }); - }, - ); + + test('throw expection when invalid value is sent', () async { + expect( + () async { + dioAdapter.onPost( + tokenEndPoint, + (request) => request.throws( + 401, + DioException( + requestOptions: RequestOptions(path: tokenEndPoint), + ), + ), + ); + + await oidc4vc.getToken( + dio: client, + tokenData: tokenData, + tokenEndPoint: tokenEndPoint, + authorization: null, + ); + }, + throwsA(isA()), + ); + }); + }); + + group( + 'get did document', + () { + test('get corresponding did document', () async { + const issuer = 'did:web:talao.co'; + const universal = + 'https://unires:test@unires.talao.co/1.0/identifiers'; + + const didDocument = + r'{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w3.org/ns/did/v1",{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"}],"id":"did:web:talao.co","verificationMethod":[{"id":"did:web:talao.co#key-1","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"e":"AQAB","kid":"did:web:talao.co#key-1","kty":"RSA","n":"pPocyKreTAn3YrmGyPYXHklYqUiSSQirGACwJSYYs-ksfw4brtA3SZCmA2sdAO8a2DXfqADwFgVSxJFtJ3GkHLV2ZvOIOnZCX6MF6NIWHB9c64ydrYNJbEy72oyG_-v-sE6rb0x-D-uJe9DFYIURzisyBlNA7imsiZPQniOjPLv0BUgED0vdO5HijFe7XbpVhoU-2oTkHHQ4CadmBZhelCczACkXpOU7mwcImGj9h1__PsyT5VBLi_92-93NimZjechPaaTYEU2u0rfnfVW5eGDYNAynO4Q2bhpFPRTXWZ5Lhnhnq7M76T6DGA3GeAu_MOzB0l4dxpFMJ6wHnekdkQ"}},{"id":"did:web:talao.co#key-2","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"Bls7WaGu_jsharYBAzakvuSERIV_IFR2tS64e5p_Y_Q","y":"haeKjXQ9uzyK4Ind1W4SBUkR_9udjjx1OmKK4vl1jko"}},{"id":"did:web:talao.co#key-21","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI","y":"HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM"}},{"id":"did:web:talao.co#key-3","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}},{"id":"did:web:talao.co#key-4","type":"Ed25519VerificationKey2018","controller":"did:web:talao.co","publicKeyBase58":"2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF"}],"authentication":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"assertionMethod":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"keyAgreement":["did:web:talao.co#key-3","did:web:talao.co#key-4"],"capabilityInvocation":["did:web:talao.co#key-1","did:web:talao.co#key-4"],"service":[{"id":"did:web:talao.co#domain-1","type":"LinkedDomains","serviceEndpoint":"https://talao.co"}]},"didResolutionMetadata":{"contentType":"application/did+ld+json","pattern":"^(did:web:.+)$","driverUrl":"http://uni-resolver-driver-did-uport:8081/1.0/identifiers/","duration":42,"did":{"didString":"did:web:talao.co","methodSpecificId":"talao.co","method":"web"}},"didDocumentMetadata":{}}'; + + dioAdapter.onGet( + '$universal/$issuer', + (request) => request.reply(200, jsonDecode(didDocument)), + ); + + final value = await oidc4vc.getDidDocument( + didKey: issuer, + fromStatusList: false, + isCachingEnabled: false, + dio: client, + ); + + expect(value, jsonDecode(didDocument)); + }); + + test( + 'use public resolver as fallback and get corresponding did document', + () async { + const issuer = 'did:web:talao.co'; + const universal = + 'https://unires:test@unires.talao.co/1.0/identifiers'; + + const public = 'https://dev.uniresolver.io/1.0/identifiers'; + + const didDocument = + r'{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w3.org/ns/did/v1",{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"}],"id":"did:web:talao.co","verificationMethod":[{"id":"did:web:talao.co#key-1","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"e":"AQAB","kid":"did:web:talao.co#key-1","kty":"RSA","n":"pPocyKreTAn3YrmGyPYXHklYqUiSSQirGACwJSYYs-ksfw4brtA3SZCmA2sdAO8a2DXfqADwFgVSxJFtJ3GkHLV2ZvOIOnZCX6MF6NIWHB9c64ydrYNJbEy72oyG_-v-sE6rb0x-D-uJe9DFYIURzisyBlNA7imsiZPQniOjPLv0BUgED0vdO5HijFe7XbpVhoU-2oTkHHQ4CadmBZhelCczACkXpOU7mwcImGj9h1__PsyT5VBLi_92-93NimZjechPaaTYEU2u0rfnfVW5eGDYNAynO4Q2bhpFPRTXWZ5Lhnhnq7M76T6DGA3GeAu_MOzB0l4dxpFMJ6wHnekdkQ"}},{"id":"did:web:talao.co#key-2","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"Bls7WaGu_jsharYBAzakvuSERIV_IFR2tS64e5p_Y_Q","y":"haeKjXQ9uzyK4Ind1W4SBUkR_9udjjx1OmKK4vl1jko"}},{"id":"did:web:talao.co#key-21","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"P-256","kty":"EC","x":"J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI","y":"HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM"}},{"id":"did:web:talao.co#key-3","type":"JwsVerificationKey2020","controller":"did:web:talao.co","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}},{"id":"did:web:talao.co#key-4","type":"Ed25519VerificationKey2018","controller":"did:web:talao.co","publicKeyBase58":"2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF"}],"authentication":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"assertionMethod":["did:web:talao.co#key-1","did:web:talao.co#key-2","did:web:talao.co#key-3","did:web:talao.co#key-4"],"keyAgreement":["did:web:talao.co#key-3","did:web:talao.co#key-4"],"capabilityInvocation":["did:web:talao.co#key-1","did:web:talao.co#key-4"],"service":[{"id":"did:web:talao.co#domain-1","type":"LinkedDomains","serviceEndpoint":"https://talao.co"}]},"didResolutionMetadata":{"contentType":"application/did+ld+json","pattern":"^(did:web:.+)$","driverUrl":"http://uni-resolver-driver-did-uport:8081/1.0/identifiers/","duration":42,"did":{"didString":"did:web:talao.co","methodSpecificId":"talao.co","method":"web"}},"didDocumentMetadata":{}}'; + + dioAdapter + ..onGet( + '$universal/$issuer', + (request) => request.throws( + 500, + DioException.connectionError( + requestOptions: RequestOptions(path: '$universal/$issuer'), + reason: 'Internal Server Error', + ), + ), + ) + ..onGet( + '$public/$issuer', + (request) => request.reply(200, jsonDecode(didDocument)), + ); + + final value = await oidc4vc.getDidDocument( + didKey: issuer, + fromStatusList: false, + isCachingEnabled: false, + dio: client, + ); + + expect(value, jsonDecode(didDocument)); + }); + test('get corresponding did document', () async { + const issuer = 'https://talao.co/issuer/zxhaokccsi'; + const openidConfigurationResponse1 = + '{"authorization_server":"https://talao.co/issuer/zxhaokccsi","credential_endpoint":"https://talao.co/issuer/zxhaokccsi/credential","credential_issuer":"https://talao.co/issuer/zxhaokccsi","subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":[{"display":[{"locale":"en-US","name":"EU Diploma","description":"This the official EBSI VC Diploma","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":{"url":"https://i.ibb.co/CHqjxrJ/dbc-card-hig-res.png","alt_text":"Connected open cubes in blue with one orange cube as a background of the card"},"logo":{"url":"https://dutchblockchaincoalition.org/assets/images/icons/Logo-DBC.png","alt_text":"An orange block shape, with the text Dutch Blockchain Coalition next to it, portraying the logo of the Dutch Blockchain Coalition."}}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma2"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"givenNames":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]}}},{"display":[{"locale":"en-US","name":"Individual attestation","description":"This is the EBSI Individual Verifiable Attestation","text_color":"#FFFFFF","background_color":"#3B6F6D","background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","IndividualVerifiableAttestation"],"id":null,"scope":null,"credentialSubject":{"dateOfBirth":{"display":[{"locale":"en-US","name":"Birth Date"},{"locale":"fr-FR","name":"Date de naissance"}]},"familyName":{"display":[{"locale":"en-US","name":"Family Name"},{"locale":"fr-FR","name":"Nom"}]},"firstName":{"display":[{"locale":"en-US","name":"First Name"},{"locale":"fr-FR","name":"Prénom"}]},"issuing_country":{"display":[{"locale":"en-US","name":"Issued by"},{"locale":"fr-FR","name":"Délivré par"}]},"placeOfBirth":{"display":[{"locale":"en-US","name":"Birth Place"},{"locale":"fr-FR","name":"Lieu de naissance"}]}}},{"display":[{"locale":"en-GB","name":"Email proof","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","EmailPass"],"id":null,"scope":null,"credentialSubject":null},{"display":[{"locale":"en-GB","name":"Verifiable Id","description":"This is a verifiable credential","text_color":null,"background_color":null,"background_image":null,"logo":null}],"format":"jwt_vc","trust_framework":{"name":"ebsi","type":"Accreditation","uri":"TIR link towards accreditation"},"types":["VerifiableCredential","VerifiableAttestation","VerifiableId"],"id":null,"scope":null,"credentialSubject":null}],"credential_configurations_supported":null,"deferred_credential_endpoint":"https://talao.co/issuer/zxhaokccsi/deferred","service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":null,"jwks_uri":null,"grant_types_supported":null}'; + const openidConfigurationResponse2 = + '{"authorization_server":null,"credential_endpoint":null,"credential_issuer":null,"subject_syntax_types_supported":null,"token_endpoint":null,"batch_endpoint":null,"authorization_endpoint":null,"subject_trust_frameworks_supported":null,"credentials_supported":null,"credential_configurations_supported":null,"deferred_credential_endpoint":null,"service_documentation":null,"credential_manifest":null,"credential_manifests":null,"issuer":"https://talao.co/sandbox/issuer/statuslist","jwks_uri":"https://talao.co/sandbox/issuer/statuslist/jwks","grant_types_supported":null}'; + const jwkUriResponse = + '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; + + const expectedDidDocument = + '{"keys":[{"crv":"Ed25519","kid":"AegXN9J71CIQWw7TjhM-eHYZW45TfP0uC5xJduiH_w0","kty":"OKP","x":"FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo"}]}'; + + dioAdapter + ..onGet( + '$issuer/.well-known/openid-credential-issuer', + (request) => + request.reply(200, jsonDecode(openidConfigurationResponse1)), + ) + ..onGet( + '$issuer/.well-known/openid-configuration', + (request) => + request.reply(200, jsonDecode(openidConfigurationResponse2)), + ) + ..onGet( + 'https://talao.co/sandbox/issuer/statuslist/jwks', + (request) => request.reply(200, jsonDecode(jwkUriResponse)), + ); + + final value = await oidc4vc.getDidDocument( + didKey: issuer, + fromStatusList: false, + isCachingEnabled: false, + dio: client, + secureStorage: mockSecureStorage, + ); + expect(value, jsonDecode(expectedDidDocument)); + }); + }, + ); + }); } diff --git a/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart b/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart index 1fc327786..1733de055 100644 --- a/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart +++ b/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart @@ -1,13 +1,10 @@ -// ignore_for_file: prefer_const_constructors -import 'dart:convert'; - import 'package:secure_jwt_signer/secure_jwt_signer.dart'; import 'package:test/test.dart'; void main() { group('SecureJwtSigner', () { test('can be instantiated', () { - expect(SecureJwtSigner(), isNotNull); + expect(const SecureJwtSigner(), isNotNull); }); }); } diff --git a/test/app/shared/enum/credential_category_test.dart b/test/app/shared/enum/credential_category_test.dart index 32a64652d..58e99e8d7 100644 --- a/test/app/shared/enum/credential_category_test.dart +++ b/test/app/shared/enum/credential_category_test.dart @@ -4,68 +4,116 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; class MockAppLocalizations extends Mock implements AppLocalizations { + @override final my = 'My'; + @override final get = 'Get'; - + @override final advantagesCards = 'A1'; + @override final advantagesCredentialHomeSubtitle = 'A2'; + @override final advantagesDiscoverCards = 'A3'; + @override final advantagesCredentialDiscoverSubtitle = 'A4'; - + @override final identityCards = 'A1'; + @override final identityCredentialHomeSubtitle = 'A2'; + @override final identityDiscoverCards = 'A3'; + @override final identityCredentialDiscoverSubtitle = 'A4'; + @override final myProfessionalCards = 'A1'; + @override final myProfessionalrCardsSubtitle = 'A2'; + @override final myProfessionalCredentialDiscoverSubtitle = 'A3'; + @override final contactInfoCredentials = 'A1'; + @override final contactInfoCredentialHomeSubtitle = 'A2'; + @override final contactInfoDiscoverCredentials = 'A3'; + @override final contactInfoCredentialDiscoverSubtitle = 'A4'; + @override final blockchainAccounts = 'A1'; + @override final blockchainAccountsCredentialHomeSubtitle = 'A2'; + @override final blockchainCardsDiscoverTitle = 'A3'; + @override final blockchainCardsDiscoverSubtitle = 'A4'; + @override final educationCredentials = 'A1'; + @override final educationCredentialHomeSubtitle = 'A2'; + @override final educationDiscoverCredentials = 'A3'; + @override final educationCredentialsDiscoverSubtitle = 'A4'; + @override final otherCards = 'A1'; + @override final otherCredentialHomeSubtitle = 'A2'; + @override final otherCredentialDiscoverSubtitle = 'A4'; + @override final financeCredentialsHomeTitle = 'A1'; + @override final financeCredentialsHomeSubtitle = 'A2'; + @override final financeCredentialsDiscoverTitle = 'A3'; + @override final financeCredentialsDiscoverSubtitle = 'A4'; + @override final hummanityProofCredentialsHomeTitle = 'A1'; + @override final hummanityProofCredentialsHomeSubtitle = 'A2'; + @override final hummanityProofCredentialsDiscoverTitle = 'A3'; + @override final hummanityProofCredentialsDiscoverSubtitle = 'A4'; + @override final socialMediaCredentialsHomeTitle = 'A1'; + @override final socialMediaCredentialsHomeSubtitle = 'A2'; + @override final socialMediaCredentialsDiscoverTitle = 'A3'; + @override final socialMediaCredentialsDiscoverSubtitle = 'A4'; + @override final walletIntegrityCredentialsHomeTitle = 'A1'; + @override final walletIntegrityCredentialsHomeSubtitle = 'A2'; + @override final walletIntegrityCredentialsDiscoverTitle = 'A3'; + @override final walletIntegrityCredentialsDiscoverSubtitle = 'A4'; + @override final polygonCredentialsHomeTitle = 'A1'; + @override final polygonCredentialsHomeSubtitle = 'A2'; + @override final polygonCredentialsDiscoverTitle = 'A3'; + @override final polygonCredentialsDiscoverSubtitle = 'A4'; + @override final pendingCredentialsHomeTitle = 'A1'; + @override final pendingCredentialsHomeSubtitle = 'A2'; } @@ -113,15 +161,21 @@ void main() { expect(CredentialCategory.identityCards.showInHomeIfListEmpty, true); expect(CredentialCategory.professionalCards.showInHomeIfListEmpty, false); expect(CredentialCategory.advantagesCards.showInHomeIfListEmpty, false); - expect(CredentialCategory.contactInfoCredentials.showInHomeIfListEmpty, - false); - expect(CredentialCategory.blockchainAccountsCards.showInHomeIfListEmpty, - false); + expect( + CredentialCategory.contactInfoCredentials.showInHomeIfListEmpty, + false, + ); + expect( + CredentialCategory.blockchainAccountsCards.showInHomeIfListEmpty, + false, + ); expect(CredentialCategory.educationCards.showInHomeIfListEmpty, false); expect(CredentialCategory.othersCards.showInHomeIfListEmpty, false); expect(CredentialCategory.financeCards.showInHomeIfListEmpty, false); expect( - CredentialCategory.humanityProofCards.showInHomeIfListEmpty, false); + CredentialCategory.humanityProofCards.showInHomeIfListEmpty, + false, + ); expect(CredentialCategory.socialMediaCards.showInHomeIfListEmpty, false); expect(CredentialCategory.walletIntegrity.showInHomeIfListEmpty, false); expect(CredentialCategory.polygonidCards.showInHomeIfListEmpty, false); diff --git a/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart b/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart index df2f5615d..b01c5937b 100644 --- a/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart +++ b/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart @@ -24,10 +24,14 @@ void main() { ); for (final value in CredentialSubjectType.values) { - expect(value.backgroundColor(credentialModel), - equals(const Color(0xFFFFFFFF))); - expect(value.backgroundColor(credentialModel2), - equals(value.defaultBackgroundColor)); + expect( + value.backgroundColor(credentialModel), + equals(const Color(0xFFFFFFFF)), + ); + expect( + value.backgroundColor(credentialModel2), + equals(value.defaultBackgroundColor), + ); } }); @@ -338,102 +342,174 @@ void main() { test('CredentialSubjectType name returns correct value', () { expect( - CredentialSubjectType.defiCompliance.name, equals('DefiCompliance')); + CredentialSubjectType.defiCompliance.name, + equals('DefiCompliance'), + ); expect(CredentialSubjectType.livenessCard.name, equals('Liveness')); - expect(CredentialSubjectType.tezotopiaMembership.name, - equals('MembershipCard_1')); - expect(CredentialSubjectType.chainbornMembership.name, - equals('Chainborn_MembershipCard')); - expect(CredentialSubjectType.twitterCard.name, - equals('TwitterAccountProof')); + expect( + CredentialSubjectType.tezotopiaMembership.name, + equals('MembershipCard_1'), + ); + expect( + CredentialSubjectType.chainbornMembership.name, + equals('Chainborn_MembershipCard'), + ); + expect( + CredentialSubjectType.twitterCard.name, + equals('TwitterAccountProof'), + ); expect(CredentialSubjectType.ageRange.name, equals('AgeRange')); expect(CredentialSubjectType.nationality.name, equals('Nationality')); expect(CredentialSubjectType.gender.name, equals('Gender')); - expect(CredentialSubjectType.walletCredential.name, - equals('WalletCredential')); - expect(CredentialSubjectType.tezosAssociatedWallet.name, - equals('TezosAssociatedAddress')); - expect(CredentialSubjectType.ethereumAssociatedWallet.name, - equals('EthereumAssociatedAddress')); - expect(CredentialSubjectType.fantomAssociatedWallet.name, - equals('FantomAssociatedAddress')); - expect(CredentialSubjectType.polygonAssociatedWallet.name, - equals('PolygonAssociatedAddress')); - expect(CredentialSubjectType.binanceAssociatedWallet.name, - equals('BinanceAssociatedAddress')); - expect(CredentialSubjectType.ethereumPooAddress.name, - equals('EthereumPooAddress')); - expect(CredentialSubjectType.fantomPooAddress.name, - equals('FantomPooAddress')); - expect(CredentialSubjectType.polygonPooAddress.name, - equals('PolygonPooAddress')); - expect(CredentialSubjectType.binancePooAddress.name, - equals('BinancePooAddress')); - expect(CredentialSubjectType.tezosPooAddress.name, - equals('TezosPooAddress')); - expect(CredentialSubjectType.certificateOfEmployment.name, - equals('CertificateOfEmployment')); + expect( + CredentialSubjectType.walletCredential.name, + equals('WalletCredential'), + ); + expect( + CredentialSubjectType.tezosAssociatedWallet.name, + equals('TezosAssociatedAddress'), + ); + expect( + CredentialSubjectType.ethereumAssociatedWallet.name, + equals('EthereumAssociatedAddress'), + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.name, + equals('FantomAssociatedAddress'), + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.name, + equals('PolygonAssociatedAddress'), + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.name, + equals('BinanceAssociatedAddress'), + ); + expect( + CredentialSubjectType.ethereumPooAddress.name, + equals('EthereumPooAddress'), + ); + expect( + CredentialSubjectType.fantomPooAddress.name, + equals('FantomPooAddress'), + ); + expect( + CredentialSubjectType.polygonPooAddress.name, + equals('PolygonPooAddress'), + ); + expect( + CredentialSubjectType.binancePooAddress.name, + equals('BinancePooAddress'), + ); + expect( + CredentialSubjectType.tezosPooAddress.name, + equals('TezosPooAddress'), + ); + expect( + CredentialSubjectType.certificateOfEmployment.name, + equals('CertificateOfEmployment'), + ); expect(CredentialSubjectType.emailPass.name, equals('EmailPass')); expect(CredentialSubjectType.identityPass.name, equals('IdentityPass')); expect( - CredentialSubjectType.verifiableIdCard.name, equals('VerifiableId')); + CredentialSubjectType.verifiableIdCard.name, + equals('VerifiableId'), + ); expect(CredentialSubjectType.linkedInCard.name, equals('LinkedinCard')); - expect(CredentialSubjectType.learningAchievement.name, - equals('LearningAchievement')); + expect( + CredentialSubjectType.learningAchievement.name, + equals('LearningAchievement'), + ); expect(CredentialSubjectType.over13.name, equals('Over13')); expect(CredentialSubjectType.over15.name, equals('Over15')); expect(CredentialSubjectType.over18.name, equals('Over18')); expect(CredentialSubjectType.over21.name, equals('Over21')); expect(CredentialSubjectType.over50.name, equals('Over50')); expect(CredentialSubjectType.over65.name, equals('Over65')); - expect(CredentialSubjectType.passportFootprint.name, - equals('PassportNumber')); + expect( + CredentialSubjectType.passportFootprint.name, + equals('PassportNumber'), + ); expect(CredentialSubjectType.phonePass.name, equals('PhoneProof')); - expect(CredentialSubjectType.professionalExperienceAssessment.name, - equals('ProfessionalExperienceAssessment')); - expect(CredentialSubjectType.professionalSkillAssessment.name, - equals('ProfessionalSkillAssessment')); - expect(CredentialSubjectType.professionalStudentCard.name, - equals('ProfessionalStudentCard')); + expect( + CredentialSubjectType.professionalExperienceAssessment.name, + equals('ProfessionalExperienceAssessment'), + ); + expect( + CredentialSubjectType.professionalSkillAssessment.name, + equals('ProfessionalSkillAssessment'), + ); + expect( + CredentialSubjectType.professionalStudentCard.name, + equals('ProfessionalStudentCard'), + ); expect(CredentialSubjectType.residentCard.name, equals('ResidentCard')); - expect(CredentialSubjectType.employeeCredential.name, - equals('EmployeeCredential')); - expect(CredentialSubjectType.legalPersonalCredential.name, - equals('LegalPersonCredential')); + expect( + CredentialSubjectType.employeeCredential.name, + equals('EmployeeCredential'), + ); + expect( + CredentialSubjectType.legalPersonalCredential.name, + equals('LegalPersonCredential'), + ); expect(CredentialSubjectType.selfIssued.name, equals('SelfIssued')); expect(CredentialSubjectType.studentCard.name, equals('StudentCard')); expect(CredentialSubjectType.voucher.name, equals('Voucher')); expect(CredentialSubjectType.tezVoucher.name, equals('TezVoucher_1')); expect( - CredentialSubjectType.diplomaCard.name, equals('VerifiableDiploma')); + CredentialSubjectType.diplomaCard.name, + equals('VerifiableDiploma'), + ); expect(CredentialSubjectType.aragoPass.name, equals('AragoPass')); expect( - CredentialSubjectType.aragoEmailPass.name, equals('AragoEmailPass')); + CredentialSubjectType.aragoEmailPass.name, + equals('AragoEmailPass'), + ); + expect( + CredentialSubjectType.aragoIdentityCard.name, + equals('AragoIdCard'), + ); expect( - CredentialSubjectType.aragoIdentityCard.name, equals('AragoIdCard')); - expect(CredentialSubjectType.aragoLearningAchievement.name, - equals('AragoLearningAchievement')); + CredentialSubjectType.aragoLearningAchievement.name, + equals('AragoLearningAchievement'), + ); expect(CredentialSubjectType.aragoOver18.name, equals('AragoOver18')); - expect(CredentialSubjectType.pcdsAgentCertificate.name, - equals('PCDSAgentCertificate')); - expect( - CredentialSubjectType.euDiplomaCard.name, - equals( - 'https://api.preprod.ebsi.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd')); - expect( - CredentialSubjectType.euVerifiableId.name, - equals( - 'https://api-conformance.ebsi.eu/trusted-schemas-registry/v2/schemas/z22ZAMdQtNLwi51T2vdZXGGZaYyjrsuP1yzWyXZirCAHv')); - expect(CredentialSubjectType.kycAgeCredential.name, - equals('KYCAgeCredential')); - expect(CredentialSubjectType.kycCountryOfResidence.name, - equals('KYCCountryOfResidenceCredential')); - expect(CredentialSubjectType.proofOfTwitterStats.name, - equals('ProofOfTwitterStats')); - expect(CredentialSubjectType.civicPassCredential.name, - equals('CivicPassCredential')); - expect(CredentialSubjectType.identityCredential.name, - equals('IdentityCredential')); + expect( + CredentialSubjectType.pcdsAgentCertificate.name, + equals('PCDSAgentCertificate'), + ); + expect( + CredentialSubjectType.euDiplomaCard.name, + equals( + 'https://api.preprod.ebsi.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', + ), + ); + expect( + CredentialSubjectType.euVerifiableId.name, + equals( + 'https://api-conformance.ebsi.eu/trusted-schemas-registry/v2/schemas/z22ZAMdQtNLwi51T2vdZXGGZaYyjrsuP1yzWyXZirCAHv', + ), + ); + expect( + CredentialSubjectType.kycAgeCredential.name, + equals('KYCAgeCredential'), + ); + expect( + CredentialSubjectType.kycCountryOfResidence.name, + equals('KYCCountryOfResidenceCredential'), + ); + expect( + CredentialSubjectType.proofOfTwitterStats.name, + equals('ProofOfTwitterStats'), + ); + expect( + CredentialSubjectType.civicPassCredential.name, + equals('CivicPassCredential'), + ); + expect( + CredentialSubjectType.identityCredential.name, + equals('IdentityCredential'), + ); expect(CredentialSubjectType.eudiPid.name, equals('EudiPid')); expect(CredentialSubjectType.pid.name, equals('Pid')); expect(CredentialSubjectType.defaultCredential.name, equals('')); @@ -567,7 +643,9 @@ void main() { expect(value.blockchainWidget, isA()); } else if (value == CredentialSubjectType.ethereumAssociatedWallet) { expect( - value.blockchainWidget, isA()); + value.blockchainWidget, + isA(), + ); } else if (value == CredentialSubjectType.polygonAssociatedWallet) { expect(value.blockchainWidget, isA()); } else if (value == CredentialSubjectType.binanceAssociatedWallet) { @@ -584,40 +662,64 @@ void main() { expect(CredentialSubjectType.defiCompliance.title, 'Defi Compliance'); expect(CredentialSubjectType.livenessCard.title, 'Liveness'); expect( - CredentialSubjectType.tezotopiaMembership.title, 'Membership Card'); + CredentialSubjectType.tezotopiaMembership.title, + 'Membership Card', + ); expect(CredentialSubjectType.chainbornMembership.title, 'Chainborn'); expect(CredentialSubjectType.twitterCard.title, 'Twitter Account Proof'); expect(CredentialSubjectType.ageRange.title, 'Age Range'); expect(CredentialSubjectType.nationality.title, 'Nationality'); expect(CredentialSubjectType.gender.title, 'Gender'); expect(CredentialSubjectType.walletCredential.title, 'Wallet Credential'); - expect(CredentialSubjectType.tezosAssociatedWallet.title, - 'Tezos Associated Address'); - expect(CredentialSubjectType.ethereumAssociatedWallet.title, - 'Ethereum Associated Address'); - expect(CredentialSubjectType.fantomAssociatedWallet.title, - 'Fantom Associated Address'); - expect(CredentialSubjectType.polygonAssociatedWallet.title, - 'Polygon Associated Address'); - expect(CredentialSubjectType.binanceAssociatedWallet.title, - 'BNB Chain Associated Address'); - expect(CredentialSubjectType.ethereumPooAddress.title, - 'Ethereum Poo Address'); - expect( - CredentialSubjectType.fantomPooAddress.title, 'Fantom Poo Address'); - expect( - CredentialSubjectType.polygonPooAddress.title, 'Polygon Poo Address'); - expect(CredentialSubjectType.binancePooAddress.title, - 'BNB Chain Poo Address'); + expect( + CredentialSubjectType.tezosAssociatedWallet.title, + 'Tezos Associated Address', + ); + expect( + CredentialSubjectType.ethereumAssociatedWallet.title, + 'Ethereum Associated Address', + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.title, + 'Fantom Associated Address', + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.title, + 'Polygon Associated Address', + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.title, + 'BNB Chain Associated Address', + ); + expect( + CredentialSubjectType.ethereumPooAddress.title, + 'Ethereum Poo Address', + ); + expect( + CredentialSubjectType.fantomPooAddress.title, + 'Fantom Poo Address', + ); + expect( + CredentialSubjectType.polygonPooAddress.title, + 'Polygon Poo Address', + ); + expect( + CredentialSubjectType.binancePooAddress.title, + 'BNB Chain Poo Address', + ); expect(CredentialSubjectType.tezosPooAddress.title, 'Tezos Poo Address'); - expect(CredentialSubjectType.certificateOfEmployment.title, - 'Certificate of Employment'); + expect( + CredentialSubjectType.certificateOfEmployment.title, + 'Certificate of Employment', + ); expect(CredentialSubjectType.emailPass.title, 'Email Pass'); expect(CredentialSubjectType.identityPass.title, 'Identity Pass'); expect(CredentialSubjectType.verifiableIdCard.title, 'VerifiableId'); expect(CredentialSubjectType.linkedInCard.title, 'Linkedin Card'); - expect(CredentialSubjectType.learningAchievement.title, - 'Learning Achievement'); + expect( + CredentialSubjectType.learningAchievement.title, + 'Learning Achievement', + ); expect(CredentialSubjectType.over13.title, 'Over13'); expect(CredentialSubjectType.over15.title, 'Over15'); expect(CredentialSubjectType.over18.title, 'Over18'); @@ -626,12 +728,18 @@ void main() { expect(CredentialSubjectType.over65.title, 'Over18'); expect(CredentialSubjectType.passportFootprint.title, 'Passport Number'); expect(CredentialSubjectType.phonePass.title, 'Phone Proof'); - expect(CredentialSubjectType.professionalExperienceAssessment.title, - 'Professional Experience Assessment'); - expect(CredentialSubjectType.professionalSkillAssessment.title, - 'Professional Skill Assessment'); - expect(CredentialSubjectType.professionalStudentCard.title, - 'Professional Student Card'); + expect( + CredentialSubjectType.professionalExperienceAssessment.title, + 'Professional Experience Assessment', + ); + expect( + CredentialSubjectType.professionalSkillAssessment.title, + 'Professional Skill Assessment', + ); + expect( + CredentialSubjectType.professionalStudentCard.title, + 'Professional Student Card', + ); expect(CredentialSubjectType.residentCard.title, 'Resident Card'); expect(CredentialSubjectType.selfIssued.title, 'Self Issued'); expect(CredentialSubjectType.studentCard.title, 'Student Card'); @@ -641,27 +749,45 @@ void main() { expect(CredentialSubjectType.aragoPass.title, 'Arago Pass'); expect(CredentialSubjectType.aragoEmailPass.title, 'Arago Email Pass'); expect(CredentialSubjectType.aragoIdentityCard.title, 'Arago Id Card'); - expect(CredentialSubjectType.aragoLearningAchievement.title, - 'Arago Learning Achievement'); + expect( + CredentialSubjectType.aragoLearningAchievement.title, + 'Arago Learning Achievement', + ); expect(CredentialSubjectType.aragoOver18.title, 'Arago Over18'); - expect(CredentialSubjectType.pcdsAgentCertificate.title, - 'PCDS Agent Certificate'); + expect( + CredentialSubjectType.pcdsAgentCertificate.title, + 'PCDS Agent Certificate', + ); expect(CredentialSubjectType.euDiplomaCard.title, 'EU Diploma'); expect(CredentialSubjectType.euVerifiableId.title, 'EU VerifiableID'); expect( - CredentialSubjectType.kycAgeCredential.title, 'KYC Age Credential'); - expect(CredentialSubjectType.kycCountryOfResidence.title, - 'KYC Country of Residence'); - expect(CredentialSubjectType.proofOfTwitterStats.title, - 'Proof Of Twitter Stats'); - expect(CredentialSubjectType.civicPassCredential.title, - 'Civic Pass Credential'); - expect(CredentialSubjectType.employeeCredential.title, - 'Employee Credential'); - expect(CredentialSubjectType.legalPersonalCredential.title, - 'Legal Person Credential'); - expect(CredentialSubjectType.identityCredential.title, - 'Identity Credential'); + CredentialSubjectType.kycAgeCredential.title, + 'KYC Age Credential', + ); + expect( + CredentialSubjectType.kycCountryOfResidence.title, + 'KYC Country of Residence', + ); + expect( + CredentialSubjectType.proofOfTwitterStats.title, + 'Proof Of Twitter Stats', + ); + expect( + CredentialSubjectType.civicPassCredential.title, + 'Civic Pass Credential', + ); + expect( + CredentialSubjectType.employeeCredential.title, + 'Employee Credential', + ); + expect( + CredentialSubjectType.legalPersonalCredential.title, + 'Legal Person Credential', + ); + expect( + CredentialSubjectType.identityCredential.title, + 'Identity Credential', + ); expect(CredentialSubjectType.eudiPid.title, 'EudiPid'); expect(CredentialSubjectType.pid.title, 'Pid'); expect(CredentialSubjectType.defaultCredential.title, ''); @@ -690,15 +816,25 @@ void main() { expect(CredentialSubjectType.diplomaCard.supportSingleOnly, true); expect(CredentialSubjectType.twitterCard.supportSingleOnly, true); expect( - CredentialSubjectType.tezosAssociatedWallet.supportSingleOnly, true); - expect(CredentialSubjectType.ethereumAssociatedWallet.supportSingleOnly, - true); + CredentialSubjectType.tezosAssociatedWallet.supportSingleOnly, + true, + ); expect( - CredentialSubjectType.fantomAssociatedWallet.supportSingleOnly, true); - expect(CredentialSubjectType.polygonAssociatedWallet.supportSingleOnly, - true); - expect(CredentialSubjectType.binanceAssociatedWallet.supportSingleOnly, - true); + CredentialSubjectType.ethereumAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.supportSingleOnly, + true, + ); expect(CredentialSubjectType.walletCredential.supportSingleOnly, false); expect(CredentialSubjectType.tezosPooAddress.supportSingleOnly, false); @@ -706,82 +842,132 @@ void main() { expect(CredentialSubjectType.fantomPooAddress.supportSingleOnly, false); expect(CredentialSubjectType.polygonPooAddress.supportSingleOnly, false); expect(CredentialSubjectType.binancePooAddress.supportSingleOnly, false); - expect(CredentialSubjectType.certificateOfEmployment.supportSingleOnly, - false); + expect( + CredentialSubjectType.certificateOfEmployment.supportSingleOnly, + false, + ); expect(CredentialSubjectType.defaultCredential.supportSingleOnly, false); expect(CredentialSubjectType.emailPass.supportSingleOnly, false); expect(CredentialSubjectType.linkedInCard.supportSingleOnly, false); expect( - CredentialSubjectType.learningAchievement.supportSingleOnly, false); + CredentialSubjectType.learningAchievement.supportSingleOnly, + false, + ); expect(CredentialSubjectType.phonePass.supportSingleOnly, false); expect( - CredentialSubjectType - .professionalExperienceAssessment.supportSingleOnly, - false); + CredentialSubjectType + .professionalExperienceAssessment.supportSingleOnly, + false, + ); + expect( + CredentialSubjectType.professionalSkillAssessment.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.professionalSkillAssessment.supportSingleOnly, - false); - expect(CredentialSubjectType.professionalStudentCard.supportSingleOnly, - false); + CredentialSubjectType.professionalStudentCard.supportSingleOnly, + false, + ); expect(CredentialSubjectType.selfIssued.supportSingleOnly, false); expect(CredentialSubjectType.studentCard.supportSingleOnly, false); expect(CredentialSubjectType.aragoPass.supportSingleOnly, false); expect(CredentialSubjectType.aragoEmailPass.supportSingleOnly, false); expect(CredentialSubjectType.aragoIdentityCard.supportSingleOnly, false); - expect(CredentialSubjectType.aragoLearningAchievement.supportSingleOnly, - false); + expect( + CredentialSubjectType.aragoLearningAchievement.supportSingleOnly, + false, + ); expect(CredentialSubjectType.aragoOver18.supportSingleOnly, false); expect( - CredentialSubjectType.pcdsAgentCertificate.supportSingleOnly, false); + CredentialSubjectType.pcdsAgentCertificate.supportSingleOnly, + false, + ); expect(CredentialSubjectType.euDiplomaCard.supportSingleOnly, false); expect(CredentialSubjectType.euVerifiableId.supportSingleOnly, false); expect(CredentialSubjectType.kycAgeCredential.supportSingleOnly, false); expect( - CredentialSubjectType.kycCountryOfResidence.supportSingleOnly, false); + CredentialSubjectType.kycCountryOfResidence.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.proofOfTwitterStats.supportSingleOnly, false); + CredentialSubjectType.proofOfTwitterStats.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.civicPassCredential.supportSingleOnly, false); + CredentialSubjectType.civicPassCredential.supportSingleOnly, + false, + ); expect(CredentialSubjectType.employeeCredential.supportSingleOnly, false); - expect(CredentialSubjectType.legalPersonalCredential.supportSingleOnly, - false); + expect( + CredentialSubjectType.legalPersonalCredential.supportSingleOnly, + false, + ); expect(CredentialSubjectType.identityCredential.supportSingleOnly, false); expect(CredentialSubjectType.eudiPid.supportSingleOnly, false); expect(CredentialSubjectType.pid.supportSingleOnly, false); }); test('CredentialSubjectType getVCFormatType returns correct value', () { - expect(CredentialSubjectType.ethereumAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.fantomAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.polygonAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.binanceAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.tezosAssociatedWallet.getVCFormatType, - VCFormatType.values); + expect( + CredentialSubjectType.ethereumAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.tezosAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); expect( - CredentialSubjectType.over13.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.over13.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over15.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over21.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over50.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over15.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.over65.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over21.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.gender.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over50.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.ageRange.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over65.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.defiCompliance.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.gender.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.tezotopiaMembership.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.ageRange.getVCFormatType, [VCFormatType.ldpVc]); - expect(CredentialSubjectType.defiCompliance.getVCFormatType, - [VCFormatType.ldpVc]); - expect(CredentialSubjectType.tezotopiaMembership.getVCFormatType, - [VCFormatType.ldpVc]); - expect(CredentialSubjectType.chainbornMembership.getVCFormatType, - [VCFormatType.ldpVc]); + CredentialSubjectType.chainbornMembership.getVCFormatType, + [VCFormatType.ldpVc], + ); expect(CredentialSubjectType.verifiableIdCard.getVCFormatType, [ VCFormatType.ldpVc, @@ -790,10 +976,14 @@ void main() { VCFormatType.jwtVc, ]); - expect(CredentialSubjectType.identityCredential.getVCFormatType, - [VCFormatType.vcSdJWT]); - expect(CredentialSubjectType.eudiPid.getVCFormatType, - [VCFormatType.vcSdJWT]); + expect( + CredentialSubjectType.identityCredential.getVCFormatType, + [VCFormatType.vcSdJWT], + ); + expect( + CredentialSubjectType.eudiPid.getVCFormatType, + [VCFormatType.vcSdJWT], + ); expect(CredentialSubjectType.pid.getVCFormatType, [VCFormatType.vcSdJWT]); expect(CredentialSubjectType.over18.getVCFormatType, [ @@ -801,89 +991,167 @@ void main() { VCFormatType.jwtVcJson, ]); - expect(CredentialSubjectType.phonePass.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - expect(CredentialSubjectType.livenessCard.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - expect(CredentialSubjectType.emailPass.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - - expect(CredentialSubjectType.nationality.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.identityPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.passportFootprint.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.residentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect( - CredentialSubjectType.voucher.getVCFormatType, [VCFormatType.jwtVc]); - expect(CredentialSubjectType.tezVoucher.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.diplomaCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.twitterCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.walletCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.tezosPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.ethereumPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.fantomPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.polygonPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.binancePooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.certificateOfEmployment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.defaultCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.linkedInCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.learningAchievement.getVCFormatType, - [VCFormatType.jwtVc]); - expect( - CredentialSubjectType - .professionalExperienceAssessment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.professionalSkillAssessment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.professionalStudentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.selfIssued.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.studentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoEmailPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoIdentityCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoLearningAchievement.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoOver18.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.pcdsAgentCertificate.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.euDiplomaCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.euVerifiableId.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.kycAgeCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.kycCountryOfResidence.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.proofOfTwitterStats.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.civicPassCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.employeeCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.legalPersonalCredential.getVCFormatType, - [VCFormatType.jwtVc]); + expect( + CredentialSubjectType.phonePass.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + expect( + CredentialSubjectType.livenessCard.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + expect( + CredentialSubjectType.emailPass.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + + expect( + CredentialSubjectType.nationality.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.identityPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.passportFootprint.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.residentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.voucher.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.tezVoucher.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.diplomaCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.twitterCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.walletCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.tezosPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.ethereumPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.fantomPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.polygonPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.binancePooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.certificateOfEmployment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.defaultCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.linkedInCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.learningAchievement.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalExperienceAssessment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalSkillAssessment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalStudentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.selfIssued.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.studentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoEmailPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoIdentityCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoLearningAchievement.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoOver18.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.pcdsAgentCertificate.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.euDiplomaCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.euVerifiableId.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.kycAgeCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.kycCountryOfResidence.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.proofOfTwitterStats.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.civicPassCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.employeeCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.legalPersonalCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); }); test('CredentialSubjectType order returns correct value', () { diff --git a/test/app/shared/enum/polygon_id_network_test.dart b/test/app/shared/enum/polygon_id_network_test.dart index 54f309b20..e69762883 100644 --- a/test/app/shared/enum/polygon_id_network_test.dart +++ b/test/app/shared/enum/polygon_id_network_test.dart @@ -15,7 +15,9 @@ void main() { test('oppositeNetwork should return correct opposite network', () { expect( - PolygonIdNetwork.PolygonMainnet.oppositeNetwork, 'mumbai(testnet)'); + PolygonIdNetwork.PolygonMainnet.oppositeNetwork, + 'mumbai(testnet)', + ); expect(PolygonIdNetwork.PolygonMumbai.oppositeNetwork, 'mainnet'); }); }); diff --git a/test/app/shared/enum/status/credential_status_extension_test.dart b/test/app/shared/enum/status/credential_status_extension_test.dart index 77fc84dd8..a7527a7e7 100644 --- a/test/app/shared/enum/status/credential_status_extension_test.dart +++ b/test/app/shared/enum/status/credential_status_extension_test.dart @@ -11,8 +11,10 @@ void main() { expect(CredentialStatus.pending.icon, Icons.circle_outlined); expect(CredentialStatus.unknown.icon, Icons.circle_outlined); expect(CredentialStatus.invalidSignature.icon, Icons.circle_outlined); - expect(CredentialStatus.statusListInvalidSignature.icon, - Icons.circle_outlined); + expect( + CredentialStatus.statusListInvalidSignature.icon, + Icons.circle_outlined, + ); expect(CredentialStatus.noStatus.icon, Icons.circle_outlined); }); }); diff --git a/test/app/shared/enum/type/language_type_test.dart b/test/app/shared/enum/type/language_type_test.dart index eaaa11216..3a85ac106 100644 --- a/test/app/shared/enum/type/language_type_test.dart +++ b/test/app/shared/enum/type/language_type_test.dart @@ -25,7 +25,9 @@ void main() { test('LanguageType getTitle returns correct value', () { final l10n = MockAppLocalizations(); expect( - LanguageType.phone.getTitle(l10n: l10n, name: ''), equals('Phone')); + LanguageType.phone.getTitle(l10n: l10n, name: ''), + equals('Phone'), + ); expect(LanguageType.ca.getTitle(l10n: l10n, name: ''), equals('Catalan')); expect(LanguageType.en.getTitle(l10n: l10n, name: ''), equals('English')); expect(LanguageType.es.getTitle(l10n: l10n, name: ''), equals('Spanish')); diff --git a/test/app/shared/extension/unit8List_extension_test.dart b/test/app/shared/extension/unit8List_extension_test.dart deleted file mode 100644 index 9effdc86f..000000000 --- a/test/app/shared/extension/unit8List_extension_test.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'dart:typed_data'; -import 'package:altme/app/app.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Uint8ListExtension', () { - test( - 'filterPayload returns the original list if length is less than or equal to 6', - () { - final list = Uint8List.fromList([1, 2, 3]); - expect(list.filterPayload, list); - - final shortList = Uint8List.fromList([1, 2, 3, 4, 5, 6]); - expect(shortList.filterPayload, shortList); - }); - - test( - 'filterPayload returns the original list if the first two elements do not match the test list', - () { - final list = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9]); - expect(list.filterPayload, list); - - final differentFirstElement = - Uint8List.fromList([6, 1, 3, 4, 5, 6, 7, 8, 9]); - expect(differentFirstElement.filterPayload, differentFirstElement); - - final differentSecondElement = - Uint8List.fromList([5, 5, 3, 4, 5, 6, 7, 8, 9]); - expect(differentSecondElement.filterPayload, differentSecondElement); - }); - - test( - 'filterPayload returns a sublist starting from index 6 if the first two elements match the test list', - () { - final list = Uint8List.fromList([5, 1, 3, 4, 5, 6, 7, 8, 9]); - final expected = Uint8List.fromList([7, 8, 9]); - expect(list.filterPayload, expected); - }); - }); -} diff --git a/test/app/shared/extension/unit_8_list_extension_test.dart b/test/app/shared/extension/unit_8_list_extension_test.dart index e13d65fcb..2ff3c43eb 100644 --- a/test/app/shared/extension/unit_8_list_extension_test.dart +++ b/test/app/shared/extension/unit_8_list_extension_test.dart @@ -5,9 +5,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Uint8ListExtension', () { test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns the original list if length is less than or equal to 6', - () { + 'filterPayload returns the original list ' + 'if length is less than or equal to 6', () { final list = Uint8List.fromList([1, 2, 3]); expect(list.filterPayload, list); @@ -16,9 +15,8 @@ void main() { }); test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns the original list if the first two elements do not match the test list', - () { + 'filterPayload returns the original list ' + 'if the first two elements do not match the test list', () { final list = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9]); expect(list.filterPayload, list); @@ -32,9 +30,8 @@ void main() { }); test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns a sublist starting from index 6 if the first two elements match the test list', - () { + 'filterPayload returns a sublist starting from index 6 ' + 'if the first two elements match the test list', () { final list = Uint8List.fromList([5, 1, 3, 4, 5, 6, 7, 8, 9]); final expected = Uint8List.fromList([7, 8, 9]); expect(list.filterPayload, expected); diff --git a/test/app/shared/helper_functions/helper_functions_test.dart b/test/app/shared/helper_functions/helper_functions_test.dart index d0b148260..d4b7764b9 100644 --- a/test/app/shared/helper_functions/helper_functions_test.dart +++ b/test/app/shared/helper_functions/helper_functions_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: lines_longer_than_80_chars + import 'dart:convert'; import 'package:altme/app/app.dart'; @@ -84,7 +86,8 @@ void main() { test('Should return last issuer DID if multiple issuers in URI', () { final uri = Uri.parse( - 'https://example.com?issuer=did:example1&issuer=did:example2',); + 'https://example.com?issuer=did:example1&issuer=did:example2', + ); expect(getIssuerDid(uriToCheck: uri), 'did:example2'); }); }); @@ -111,11 +114,12 @@ void main() { test('stringToHexPrefixedWith05 returns correct value', () { const payload = 'Bibash'; expect( - stringToHexPrefixedWith05( - payload: payload, - dateTime: DateTime(2022, 1, 1, 0, 0, 0, 0), - ), - '05010031323254657a6f73205369676e6564204d6573736167653a20616c746d652e696f20323032322d30312d30312030303a30303a30302e30303020426962617368',); + stringToHexPrefixedWith05( + payload: payload, + dateTime: DateTime(2022, 1, 1, 0, 0, 0, 0), + ), + '05010031323254657a6f73205369676e6564204d6573736167653a20616c746d652e696f20323032322d30312d30312030303a30303a30302e30303020426962617368', + ); }); test('getCredentialName returns correct credential name', () { @@ -148,17 +152,29 @@ void main() { test('getBlockchainType returns correct issuer name', () { expect( - getBlockchainType(AccountType.tezos), equals(BlockchainType.tezos),); - expect(getBlockchainType(AccountType.ethereum), - equals(BlockchainType.ethereum),); + getBlockchainType(AccountType.tezos), + equals(BlockchainType.tezos), + ); + expect( + getBlockchainType(AccountType.ethereum), + equals(BlockchainType.ethereum), + ); + expect( + getBlockchainType(AccountType.fantom), + equals(BlockchainType.fantom), + ); + expect( + getBlockchainType(AccountType.polygon), + equals(BlockchainType.polygon), + ); + expect( + getBlockchainType(AccountType.binance), + equals(BlockchainType.binance), + ); expect( - getBlockchainType(AccountType.fantom), equals(BlockchainType.fantom),); - expect(getBlockchainType(AccountType.polygon), - equals(BlockchainType.polygon),); - expect(getBlockchainType(AccountType.binance), - equals(BlockchainType.binance),); - expect(() => getBlockchainType(AccountType.ssi), - throwsA(isA()),); + () => getBlockchainType(AccountType.ssi), + throwsA(isA()), + ); }); test('getCredTypeFromName returns correct type', () { @@ -186,21 +202,22 @@ void main() { final result = await getssiMnemonicsInList(mockSecureStorage); expect( - result, - containsAll([ - 'word1', - 'word2', - 'word3', - 'word4', - 'word5', - 'word6', - 'word7', - 'word8', - 'word9', - 'word10', - 'word11', - 'word12', - ]),); + result, + containsAll([ + 'word1', + 'word2', + 'word3', + 'word4', + 'word5', + 'word6', + 'word7', + 'word8', + 'word9', + 'word10', + 'word11', + 'word12', + ]), + ); }); test('getDateTimeWithoutSpace replaces spaces with dashes', () { @@ -211,26 +228,34 @@ void main() { test('getIndexValue returns correct index for each DidKeyType', () { expect( - getIndexValue(isEBSIV3: true, didKeyType: DidKeyType.secp256k1), 3,); + getIndexValue(isEBSIV3: true, didKeyType: DidKeyType.secp256k1), + 3, + ); expect( - getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.secp256k1), 1,); + getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.secp256k1), + 1, + ); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.p256), 4); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.ebsiv3), 5); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.jwkP256), 6); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.edDSA), 0); expect( - getIndexValue( - isEBSIV3: false, didKeyType: DidKeyType.jwtClientAttestation,), - 0,); + getIndexValue( + isEBSIV3: false, + didKeyType: DidKeyType.jwtClientAttestation, + ), + 0, + ); }); group('getWalletAttestationP256Key', () { test('returns existing key', () async { const existingKey = 'existing_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyForWallet),) - .thenAnswer((_) => Future.value(existingKey)); + when( + () => + mockSecureStorage.get(SecureStorageKeys.p256PrivateKeyForWallet), + ).thenAnswer((_) => Future.value(existingKey)); final result = await getWalletAttestationP256Key(mockSecureStorage); @@ -238,10 +263,10 @@ void main() { }); test('generates and returns new key', () async { - const newKey = 'new_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyForWallet),) - .thenAnswer((_) => Future.value(null)); + when( + () => + mockSecureStorage.get(SecureStorageKeys.p256PrivateKeyForWallet), + ).thenAnswer((_) => Future.value(null)); when(() => mockSecureStorage.set(any(), any())) .thenAnswer((_) async {}); @@ -262,9 +287,10 @@ void main() { group('getP256KeyToGetAndPresentVC', () { test('returns existing key', () async { const existingKey = 'existing_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC),) - .thenAnswer((_) => Future.value(existingKey)); + when( + () => mockSecureStorage + .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC), + ).thenAnswer((_) => Future.value(existingKey)); final result = await getP256KeyToGetAndPresentVC(mockSecureStorage); @@ -272,10 +298,10 @@ void main() { }); test('generates and returns new key', () async { - const newKey = 'new_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC),) - .thenAnswer((_) => Future.value(null)); + when( + () => mockSecureStorage + .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC), + ).thenAnswer((_) => Future.value(null)); when(() => mockSecureStorage.set(any(), any())) .thenAnswer((_) async {}); @@ -313,8 +339,10 @@ void main() { expect(getDidKeyFromString('DidKeyType.p256'), DidKeyType.p256); expect(getDidKeyFromString('DidKeyType.ebsiv3'), DidKeyType.ebsiv3); expect(getDidKeyFromString('DidKeyType.jwkP256'), DidKeyType.jwkP256); - expect(getDidKeyFromString('DidKeyType.jwtClientAttestation'), - DidKeyType.jwtClientAttestation,); + expect( + getDidKeyFromString('DidKeyType.jwtClientAttestation'), + DidKeyType.jwtClientAttestation, + ); expect(getDidKeyFromString('InvalidKeyType'), null); expect(getDidKeyFromString(null), null); }); @@ -355,11 +383,15 @@ void main() { test('getSignatureType returns correct signature type for circuitId', () { expect(getSignatureType('credentialAtomicQuerySigV2'), 'BJJ Signature'); - expect(getSignatureType('credentialAtomicQuerySigV2OnChain'), - 'BJJ Signature',); + expect( + getSignatureType('credentialAtomicQuerySigV2OnChain'), + 'BJJ Signature', + ); expect(getSignatureType('credentialAtomicQueryMTPV2'), 'SMT Signature'); - expect(getSignatureType('credentialAtomicQueryMTPV2OnChain'), - 'SMT Signature',); + expect( + getSignatureType('credentialAtomicQueryMTPV2OnChain'), + 'SMT Signature', + ); expect(getSignatureType('unknownCircuitId'), ''); }); @@ -375,7 +407,9 @@ void main() { 'https://example.com?uri_list=https%3A%2F%2Fexample.com%2Fpath1&uri_list=https%3A%2F%2Fexample.com%2Fpath2'; final result = generateUriList(url); expect( - result, ['https://example.com/path1', 'https://example.com/path2'],); + result, + ['https://example.com/path1', 'https://example.com/path2'], + ); }); test('sortedPublcJwk returns sorted public JWK without private key', () { @@ -540,7 +574,8 @@ void main() { group('getPresentationDefinition', () { test('returns presentation definition from URI', () async { final uri = Uri.parse( - "https://example.com?presentation_definition={'title':'Test'}",); + "https://example.com?presentation_definition={'title':'Test'}", + ); final presentationDefinition = await getPresentationDefinition(uri: uri, client: mockClient); @@ -559,7 +594,8 @@ void main() { 'returns presentation definition from URI with ' 'presentation_definition_uri', () async { final uri = Uri.parse( - 'https://example.com?presentation_definition_uri=https://example.com/presentation.com',); + 'https://example.com?presentation_definition_uri=https://example.com/presentation.com', + ); dioAdapter.onGet( 'https://example.com/presentation.com', @@ -574,7 +610,8 @@ void main() { test('returns null for invalid presentation_definition_uri', () async { final uri = Uri.parse( - 'https://example.com?presentation_definition_uri=https://example.com/presentation.com',); + 'https://example.com?presentation_definition_uri=https://example.com/presentation.com', + ); dioAdapter.onGet( 'https://example.com/presentation.com', @@ -610,7 +647,8 @@ void main() { 'returns client metadata from URI with ' 'client_metadata_uri', () async { final uri = Uri.parse( - 'https://example.com?client_metadata_uri=https://example.com.com',); + 'https://example.com?client_metadata_uri=https://example.com.com', + ); dioAdapter.onGet( 'https://example.com.com', @@ -625,7 +663,8 @@ void main() { test('returns null for invalid client_metadata_uri', () async { final uri = Uri.parse( - 'https://example.com?client_metadata_uri=https://example.com.com',); + 'https://example.com?client_metadata_uri=https://example.com.com', + ); dioAdapter.onGet( 'https://example.com.com', @@ -808,72 +847,118 @@ void main() { }); test('getErrorResponseString returns correct ResponseString', () { - expect(getErrorResponseString('invalid_request'), - ResponseString.RESPONSE_STRING_invalidRequest,); - expect(getErrorResponseString('invalid_request_uri'), - ResponseString.RESPONSE_STRING_invalidRequest,); - expect(getErrorResponseString('invalid_request_object'), - ResponseString.RESPONSE_STRING_invalidRequest,); - - expect(getErrorResponseString('unauthorized_client'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('access_denied'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('invalid_or_missing_proof'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('interaction_required'), - ResponseString.RESPONSE_STRING_accessDenied,); - - expect(getErrorResponseString('unsupported_response_type'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('invalid_scope'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('request_not_supported'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('request_uri_not_supported'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - - expect(getErrorResponseString('unsupported_credential_type'), - ResponseString.RESPONSE_STRING_unsupportedCredential,); - expect(getErrorResponseString('login_required'), - ResponseString.RESPONSE_STRING_aloginIsRequired,); - expect(getErrorResponseString('account_selection_required'), - ResponseString.RESPONSE_STRING_aloginIsRequired,); - - expect(getErrorResponseString('consent_required'), - ResponseString.RESPONSE_STRING_userConsentIsRequired,); - - expect(getErrorResponseString('registration_not_supported'), - ResponseString.RESPONSE_STRING_theWalletIsNotRegistered,); - - expect(getErrorResponseString('invalid_grant'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); - expect(getErrorResponseString('invalid_client'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); - expect(getErrorResponseString('invalid_token'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); + expect( + getErrorResponseString('invalid_request'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); + expect( + getErrorResponseString('invalid_request_uri'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); + expect( + getErrorResponseString('invalid_request_object'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); expect( - getErrorResponseString('unsupported_credential_format'), - ResponseString - .RESPONSE_STRING_thisCredentialFormatIsNotSupported,); + getErrorResponseString('unauthorized_client'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('access_denied'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('invalid_or_missing_proof'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('interaction_required'), + ResponseString.RESPONSE_STRING_accessDenied, + ); - expect(getErrorResponseString('unsupported_format'), - ResponseString.RESPONSE_STRING_thisFormatIsNotSupported,); + expect( + getErrorResponseString('unsupported_response_type'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('invalid_scope'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('request_not_supported'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('request_uri_not_supported'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + + expect( + getErrorResponseString('unsupported_credential_type'), + ResponseString.RESPONSE_STRING_unsupportedCredential, + ); + expect( + getErrorResponseString('login_required'), + ResponseString.RESPONSE_STRING_aloginIsRequired, + ); + expect( + getErrorResponseString('account_selection_required'), + ResponseString.RESPONSE_STRING_aloginIsRequired, + ); + + expect( + getErrorResponseString('consent_required'), + ResponseString.RESPONSE_STRING_userConsentIsRequired, + ); + + expect( + getErrorResponseString('registration_not_supported'), + ResponseString.RESPONSE_STRING_theWalletIsNotRegistered, + ); - expect(getErrorResponseString('invalid_issuer_metadata'), - ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid,); + expect( + getErrorResponseString('invalid_grant'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + expect( + getErrorResponseString('invalid_client'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + expect( + getErrorResponseString('invalid_token'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + + expect( + getErrorResponseString('unsupported_credential_format'), + ResponseString.RESPONSE_STRING_thisCredentialFormatIsNotSupported, + ); + + expect( + getErrorResponseString('unsupported_format'), + ResponseString.RESPONSE_STRING_thisFormatIsNotSupported, + ); + + expect( + getErrorResponseString('invalid_issuer_metadata'), + ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid, + ); - expect(getErrorResponseString('server_error'), - ResponseString.RESPONSE_STRING_theServiceIsNotAvailable,); + expect( + getErrorResponseString('server_error'), + ResponseString.RESPONSE_STRING_theServiceIsNotAvailable, + ); expect( - getErrorResponseString('issuance_pending'), - ResponseString - .RESPONSE_STRING_theIssuanceOfThisCredentialIsPending,); + getErrorResponseString('issuance_pending'), + ResponseString.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending, + ); - expect(getErrorResponseString('random'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); + expect( + getErrorResponseString('random'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); }); test('isIDTokenOnly', () { @@ -937,7 +1022,7 @@ void main() { 'presentation_definition': { 'id': 'cred-123', 'format': 'vp', - 'input_descriptors': [], + 'input_descriptors': [], }, 'presentation_definition_uri': 'https://example.com/presentation', 'registration': { @@ -983,7 +1068,7 @@ void main() { format: Format.fromJson( { 'ldp_vc': { - 'proof_type': [], + 'proof_type': [], }, }, ), @@ -1230,7 +1315,7 @@ void main() { () => checkX509( clientId: '', header: { - 'x5c': [], + 'x5c': [], }, encodedData: '', ), diff --git a/test/app/shared/issuer/check_issuer_test.dart b/test/app/shared/issuer/check_issuer_test.dart index 8f1c68b42..8ce2671bb 100644 --- a/test/app/shared/issuer/check_issuer_test.dart +++ b/test/app/shared/issuer/check_issuer_test.dart @@ -28,7 +28,9 @@ void main() { mockSecureStorage = MockSecureStorage(); dioAdapter = DioAdapter( - dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); + dio: Dio(BaseOptions()), + matcher: const UrlRequestMatcher(), + ); client.httpClientAdapter = dioAdapter; mockClient = DioClient( baseUrl: 'https://example.com/', @@ -133,8 +135,8 @@ void main() { }); test( - 'should return empty issuer if organizationInfo.issuerDomain does not contain uriToCheck.host', - () async { + 'should return empty issuer if organizationInfo.issuerDomain ' + 'does not contain uriToCheck.host', () async { final response = { 'issuer': { 'preferredName': 'Example Issuer', @@ -156,8 +158,10 @@ void main() { final result = await checkIssuer.isIssuerInApprovedList(); - expect(jsonEncode(result), - equals(jsonEncode(Issuer.emptyIssuer(uriToCheck.host)))); + expect( + jsonEncode(result), + equals(jsonEncode(Issuer.emptyIssuer(uriToCheck.host))), + ); }); test('should throw exception when an error occurs', () async { diff --git a/test/app/shared/issuer/models/organization_info_test.dart b/test/app/shared/issuer/models/organization_info_test.dart index eb7d82165..cf0c8b53a 100644 --- a/test/app/shared/issuer/models/organization_info_test.dart +++ b/test/app/shared/issuer/models/organization_info_test.dart @@ -4,8 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('OrganizationInfo', () { test( - 'OrganizationInfo fromJson should return a valid OrganizationInfo object', - () { + 'OrganizationInfo fromJson should ' + 'return a valid OrganizationInfo object', () { final json = { 'id': 'org-123', 'legalName': 'Example Org', @@ -42,8 +42,8 @@ void main() { }); test( - 'OrganizationInfo.emptyOrganizationInfo should return an OrganizationInfo with default values', - () { + 'OrganizationInfo.emptyOrganizationInfo ' + 'should return an OrganizationInfo with default values', () { final organizationInfo = OrganizationInfo.emptyOrganizationInfo('example.com'); diff --git a/test/app/shared/models/state_message/state_message_test.dart b/test/app/shared/models/state_message/state_message_test.dart index 2467e27ba..dfb1db98d 100644 --- a/test/app/shared/models/state_message/state_message_test.dart +++ b/test/app/shared/models/state_message/state_message_test.dart @@ -1,5 +1,5 @@ -import 'package:test/test.dart'; import 'package:altme/app/app.dart'; +import 'package:test/test.dart'; void main() { group('StateMessage', () { diff --git a/test/app/shared/network/network_exception_test.dart b/test/app/shared/network/network_exception_test.dart index 53a02734d..1ea1e3f49 100644 --- a/test/app/shared/network/network_exception_test.dart +++ b/test/app/shared/network/network_exception_test.dart @@ -103,7 +103,9 @@ void main() { ); final message = NetworkException.getDioException(error: error); expect( - message.message, NetworkError.NETWORK_ERROR_NO_INTERNET_CONNECTION); + message.message, + NetworkError.NETWORK_ERROR_NO_INTERNET_CONNECTION, + ); }); test('return internalServerError response when statusCode is 500', () { diff --git a/test/app/shared/validators/wallet_address_validator_test.dart b/test/app/shared/validators/wallet_address_validator_test.dart index 0fca3d1ae..a55817624 100644 --- a/test/app/shared/validators/wallet_address_validator_test.dart +++ b/test/app/shared/validators/wallet_address_validator_test.dart @@ -21,9 +21,11 @@ void main() { test('returns true for valid Ethereum address', () { expect( - validator.validateWalletAddress( - '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'), - isTrue); + validator.validateWalletAddress( + '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + ), + isTrue, + ); }); test('returns false for invalid Ethereum address', () { @@ -32,9 +34,9 @@ void main() { test('returns true for valid Tezos address', () { expect( - validator - .validateWalletAddress('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb'), - isTrue); + validator.validateWalletAddress('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb'), + isTrue, + ); }); test('returns false for invalid Tezos address', () { diff --git a/test/app/shared/widget/base/otp_textfield_test.dart b/test/app/shared/widget/base/otp_textfield_test.dart index 390068e64..34fca0ee4 100644 --- a/test/app/shared/widget/base/otp_textfield_test.dart +++ b/test/app/shared/widget/base/otp_textfield_test.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; import '../../../../helpers/helpers.dart'; @@ -71,8 +70,9 @@ void main() { expect(controllers[1].text, '1'); expect( - FocusScope.of(tester.element(find.byType(TextField).at(1))).hasFocus, - true); + FocusScope.of(tester.element(find.byType(TextField).at(1))).hasFocus, + true, + ); }); testWidgets('onTap moves cursor to end of text', (tester) async { @@ -91,7 +91,8 @@ void main() { expect( controllers[0].selection, TextSelection.fromPosition( - TextPosition(offset: controllers[0].text.length)), + TextPosition(offset: controllers[0].text.length), + ), ); }); }); diff --git a/test/app/shared/widget/base/page_test.dart b/test/app/shared/widget/base/page_test.dart index c8800f802..f41f5c81c 100644 --- a/test/app/shared/widget/base/page_test.dart +++ b/test/app/shared/widget/base/page_test.dart @@ -37,8 +37,8 @@ void main() { }); testWidgets( - 'renders CustomAppBar when title is provided and secure screen is true', - (tester) async { + 'renders CustomAppBar when title is provided ' + 'and secure screen is true', (tester) async { await tester.pumpApp( BasePage( body: Container(), diff --git a/test/app/shared/widget/dialog/confirm_dialog_test.dart b/test/app/shared/widget/dialog/confirm_dialog_test.dart index fbe07bd1f..5cf963e05 100644 --- a/test/app/shared/widget/dialog/confirm_dialog_test.dart +++ b/test/app/shared/widget/dialog/confirm_dialog_test.dart @@ -136,12 +136,14 @@ void main() { const yesText = 'Yes'; const noText = 'No'; - await tester.pumpApp(const ConfirmDialog( - title: title, - yes: yesText, - no: noText, - showNoButton: false, - )); + await tester.pumpApp( + const ConfirmDialog( + title: title, + yes: yesText, + no: noText, + showNoButton: false, + ), + ); expect(find.text(yesText.toUpperCase()), findsOneWidget); expect(find.text(noText.toUpperCase()), findsNothing); diff --git a/test/app/shared/widget/dialog/text_field_dialog_test.dart b/test/app/shared/widget/dialog/text_field_dialog_test.dart index 267382bea..4844bf3a0 100644 --- a/test/app/shared/widget/dialog/text_field_dialog_test.dart +++ b/test/app/shared/widget/dialog/text_field_dialog_test.dart @@ -16,7 +16,8 @@ void main() { no: 'No', ), ); - // Verify that the title, label, subtitle, and initial value are displayed. + // Verify that the title, label, subtitle, + // and initial value are displayed. expect(find.text('Title'), findsOneWidget); expect(find.text('Label'), findsOneWidget); expect(find.text('Subtitle'), findsOneWidget); diff --git a/test/app/shared/widget/wallet_logo_test.dart b/test/app/shared/widget/wallet_logo_test.dart index 5565c7fe9..5821e5eb0 100644 --- a/test/app/shared/widget/wallet_logo_test.dart +++ b/test/app/shared/widget/wallet_logo_test.dart @@ -136,7 +136,8 @@ void main() { }); testWidgets( - 'displays correct image for ProfileType.owfBaselineProfile in development', + 'displays correct image for ' + 'ProfileType.owfBaselineProfile in development', (WidgetTester tester) async { await tester.pumpApp( Scaffold( diff --git a/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart b/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart index af55c501d..7bc14632e 100644 --- a/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart +++ b/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart @@ -149,7 +149,8 @@ void main() { BlocProvider.value(value: walletCubit), BlocProvider.value(value: splashCubit), BlocProvider.value( - value: altmeChatSupportCubit), + value: altmeChatSupportCubit, + ), BlocProvider.value(value: profileCubit), ], child: const OnBoardingGenPhrasePage(), diff --git a/test/onboarding/helper_function/helper_function_test.dart b/test/onboarding/helper_function/helper_function_test.dart index 4de6827eb..8b06a4ca4 100644 --- a/test/onboarding/helper_function/helper_function_test.dart +++ b/test/onboarding/helper_function/helper_function_test.dart @@ -95,8 +95,8 @@ void main() { ); }); - const mnemonicString = - 'notice photo opera keen climb agent soft parrot best joke field devote'; + const mnemonicString = 'notice photo opera keen climb' + ' agent soft parrot best joke field devote'; test('should generate account correctly', () async { when(() => homeCubit.emitHasWallet()).thenAnswer((_) async => {}); diff --git a/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart b/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart index cdddecd8a..ced9e2d88 100644 --- a/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart +++ b/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart @@ -205,7 +205,8 @@ void main() { BlocProvider.value(value: walletCubit), BlocProvider.value(value: splashCubit), BlocProvider.value( - value: altmeChatSupportCubit), + value: altmeChatSupportCubit, + ), BlocProvider.value( value: ProfileCubit( didKitProvider: didKitProvider, diff --git a/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart b/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart index 40be207fa..58ae82d34 100644 --- a/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart +++ b/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart @@ -40,7 +40,8 @@ void main() { ); blocTest( - 'emits [acceptanceButtonEnabled] when setAcceptanceButtonEnabled is called', + 'emits [acceptanceButtonEnabled] ' + 'when setAcceptanceButtonEnabled is called', build: () => onBoardingTosCubit, act: (cubit) => cubit.setAcceptanceButtonEnabled(acceptanceButtonEnabled: true), diff --git a/test/onboarding/tos/cubit/onboarding_tos_state_test.dart b/test/onboarding/tos/cubit/onboarding_tos_state_test.dart index de231cca7..0e4394b28 100644 --- a/test/onboarding/tos/cubit/onboarding_tos_state_test.dart +++ b/test/onboarding/tos/cubit/onboarding_tos_state_test.dart @@ -23,8 +23,8 @@ void main() { }); test( - 'toJson and fromJson methods should serialize and deserialize correctly', - () { + 'toJson and fromJson methods should serialize ' + 'and deserialize correctly', () { const state = OnBoardingTosState( agreeTerms: true, scrollIsOver: false, diff --git a/test/route/cubit/route_cubit_test.dart b/test/route/cubit/route_cubit_test.dart index 08a88168a..da958227f 100644 --- a/test/route/cubit/route_cubit_test.dart +++ b/test/route/cubit/route_cubit_test.dart @@ -1,8 +1,6 @@ import 'package:altme/route/route.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; -import 'package:logger/logger.dart'; void main() { group('RouteCubit', () { diff --git a/test/route/router/router_test.dart b/test/route/router/router_test.dart index c8ad47ae7..98b1f95b0 100644 --- a/test/route/router/router_test.dart +++ b/test/route/router/router_test.dart @@ -6,8 +6,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('RightToLeftRoute transition test', (WidgetTester tester) async { - final fromWidget = Scaffold(body: Center(child: Text('From Screen'))); - final toWidget = Scaffold(body: Center(child: Text('To Screen'))); + const fromWidget = Scaffold(body: Center(child: Text('From Screen'))); + const toWidget = Scaffold(body: Center(child: Text('To Screen'))); final navigatorKey = GlobalKey(); diff --git a/test/scan/cubit/scan_cubit.dart b/test/scan/cubit/scan_cubit.dart index f3b91c806..29daade2e 100644 --- a/test/scan/cubit/scan_cubit.dart +++ b/test/scan/cubit/scan_cubit.dart @@ -66,4 +66,4 @@ void main() { // Add more tests here... }); -} \ No newline at end of file +} diff --git a/test/splash/cubit/splash_cubit_test.dart b/test/splash/cubit/splash_cubit_test.dart index a867e4cc7..62d261ab2 100644 --- a/test/splash/cubit/splash_cubit_test.dart +++ b/test/splash/cubit/splash_cubit_test.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:altme/app/app.dart'; import 'package:altme/chat_room/chat_room.dart'; import 'package:altme/credentials/credentials.dart'; diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index 5f4b0a291..74df0adae 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -37,8 +37,10 @@ void main() { expect(colorScheme.onElevatedButton, equals(Colors.white)); expect(colorScheme.appBarUpperLayer, const Color(0xff25095B)); expect(colorScheme.appBarLowerLayer, equals(colorScheme.background)); - expect(colorScheme.surfaceContainer, - equals(const Color(0xff707070).withOpacity(0.07))); + expect( + colorScheme.surfaceContainer, + equals(const Color(0xff707070).withOpacity(0.07)), + ); expect(colorScheme.drawerSurface, const Color(0xff232630)); expect(colorScheme.label, equals(Colors.white)); expect(colorScheme.unSelectedLabel, const Color(0xff86809D)); @@ -46,8 +48,10 @@ void main() { expect(colorScheme.selectedBottomBar, equals(colorScheme.surface)); expect(colorScheme.drawerBackground, const Color(0xff0B0514)); expect(colorScheme.borderColor, const Color(0xFFDDCEF4)); - expect(colorScheme.defualtDialogCancelButtonBorderColor, - const Color(0xFFFFFFFF).withOpacity(0.2)); + expect( + colorScheme.defualtDialogCancelButtonBorderColor, + const Color(0xFFFFFFFF).withOpacity(0.2), + ); expect(colorScheme.markDownH1, equals(Colors.white)); expect(colorScheme.markDownH2, equals(Colors.white)); expect(colorScheme.markDownP, const Color(0xFFD1CCE3)); @@ -56,8 +60,10 @@ void main() { expect(colorScheme.subtitle2, const Color(0xFF8B8C92)); expect(colorScheme.profileDummy, const Color(0xFF212121)); expect(colorScheme.documentShadow, const Color(0xFF424242)); - expect(colorScheme.documentShape, - equals(const Color(0xff3700b3).withOpacity(0.05))); + expect( + colorScheme.documentShape, + equals(const Color(0xff3700b3).withOpacity(0.05)), + ); expect(colorScheme.star, const Color(0xFFFFB83D)); expect(colorScheme.genderIcon, const Color(0xFF212121)); expect(colorScheme.activeCredential, equals(Colors.green)); @@ -69,14 +75,18 @@ void main() { expect(colorScheme.alertInfoMessage, equals(Colors.cyan)); expect(colorScheme.alertSuccessMessage, equals(Colors.green)); expect(colorScheme.qrScanBackground, const Color(0xff2B1C48)); - expect(colorScheme.qrScanInnerShadow, - const Color(0xff000000).withOpacity(0.16)); + expect( + colorScheme.qrScanInnerShadow, + const Color(0xff000000).withOpacity(0.16), + ); expect(colorScheme.qrScanOuterShadow, const Color(0xff430F91)); expect(colorScheme.dialogText, const Color(0xffF5F5F5)); expect(colorScheme.tabBarNotSelected, const Color(0xFF280164)); expect(colorScheme.credentialBackground, const Color(0xFF211F33)); - expect(colorScheme.cryptoAccountNotSelected, - equals(Colors.grey.withOpacity(0.15))); + expect( + colorScheme.cryptoAccountNotSelected, + equals(Colors.grey.withOpacity(0.15)), + ); expect(colorScheme.startButtonColorA, const Color(0xff18ACFF)); expect(colorScheme.startButtonColorB, const Color(0xff6600FF)); expect(colorScheme.associatedWalletBorder, const Color(0xff524B67)); @@ -137,7 +147,9 @@ void main() { expect(textTheme.customListTileTitleStyle.fontWeight, FontWeight.w800); expect( - textTheme.customListTileSubTitleStyle.color, const Color(0xFF86809D)); + textTheme.customListTileSubTitleStyle.color, + const Color(0xFF86809D), + ); expect(textTheme.customListTileSubTitleStyle.fontSize, 16); expect(textTheme.customListTileSubTitleStyle.fontWeight, FontWeight.w400); @@ -310,7 +322,9 @@ void main() { ); expect(textTheme.learningAchievementDescription.fontSize, 12); expect( - textTheme.learningAchievementDescription.fontWeight, FontWeight.w400); + textTheme.learningAchievementDescription.fontWeight, + FontWeight.w400, + ); expect(textTheme.credentialIssuer.color, const Color(0xff212121)); expect(textTheme.credentialIssuer.fontSize, 13); @@ -373,17 +387,25 @@ void main() { expect(textTheme.tezosAssociatedAddressData.fontSize, 17); expect(textTheme.tezosAssociatedAddressData.fontWeight, FontWeight.normal); - expect(textTheme.tezosAssociatedAddressTitleCard.color, - const Color(0xffFAFDFF)); + expect( + textTheme.tezosAssociatedAddressTitleCard.color, + const Color(0xffFAFDFF), + ); expect(textTheme.tezosAssociatedAddressTitleCard.fontSize, 20); expect( - textTheme.tezosAssociatedAddressTitleCard.fontWeight, FontWeight.w700); + textTheme.tezosAssociatedAddressTitleCard.fontWeight, + FontWeight.w700, + ); expect( - textTheme.credentialStudentCardTextCard.color, const Color(0xffffffff)); + textTheme.credentialStudentCardTextCard.color, + const Color(0xffffffff), + ); expect(textTheme.credentialStudentCardTextCard.fontSize, 14); expect( - textTheme.credentialStudentCardTextCard.fontWeight, FontWeight.normal); + textTheme.credentialStudentCardTextCard.fontWeight, + FontWeight.normal, + ); expect(textTheme.over18.color, const Color(0xffffffff)); expect(textTheme.over18.fontSize, 20); @@ -546,7 +568,9 @@ void main() { expect(textTheme.credentialManifestTitle1.fontWeight, FontWeight.w700); expect( - textTheme.credentialManifestDescription.color, const Color(0xffFFFFFF)); + textTheme.credentialManifestDescription.color, + const Color(0xffFFFFFF), + ); expect(textTheme.credentialManifestDescription.fontSize, 16); expect(textTheme.credentialManifestDescription.fontWeight, FontWeight.w400);