diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json deleted file mode 100644 index 9bdedb8b3..000000000 --- a/.fvm/fvm_config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutterSdkVersion": "3.16.8", - "flavors": {} -} \ No newline at end of file diff --git a/.github/workflows/credential_manifest.yaml b/.github/workflows/credential_manifest.yaml index 3a78be899..e87ee708f 100644 --- a/.github/workflows/credential_manifest.yaml +++ b/.github/workflows/credential_manifest.yaml @@ -1,13 +1,13 @@ name: credential_manifest -on: [ pull_request, push ] +on: [pull_request, push] jobs: build: uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable - flutter_version: 3.19.6 + flutter_version: 3.22.1 min_coverage: 30 working_directory: packages/credential_manifest - dart_sdk: 3.3.4 + dart_sdk: 3.4.1 diff --git a/.github/workflows/cryptocurrency_keys.yaml b/.github/workflows/cryptocurrency_keys.yaml index 41c60bf47..a0e4f85c8 100644 --- a/.github/workflows/cryptocurrency_keys.yaml +++ b/.github/workflows/cryptocurrency_keys.yaml @@ -1,13 +1,13 @@ name: cryptocurrency_keys -on: [ pull_request, push ] +on: [pull_request, push] jobs: build: uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable - flutter_version: 3.19.6 + flutter_version: 3.22.1 min_coverage: 30 working_directory: packages/cryptocurrency_keys - dart_sdk: 3.3.4 + dart_sdk: 3.4.1 diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml new file mode 100644 index 000000000..2647f7254 --- /dev/null +++ b/.github/workflows/did_kit.yaml @@ -0,0 +1,14 @@ +name: did_kit + +on: [pull_request, push] + +jobs: + build: + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + with: + flutter_channel: stable + flutter_version: 3.22.1 + min_coverage: 30 + working_directory: packages/did_kit + dart_sdk: 3.4.1 + build_runner: false diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index d84446759..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}} @@ -131,4 +145,4 @@ jobs: with: path: ${{inputs.working_directory}}/coverage/lcov.info exclude: ${{inputs.coverage_excludes}} - min_coverage: ${{inputs.min_coverage}} \ No newline at end of file + min_coverage: ${{inputs.min_coverage}} diff --git a/.github/workflows/jwt_decode.yaml b/.github/workflows/jwt_decode.yaml index 9f5dd42f6..aed836c8f 100644 --- a/.github/workflows/jwt_decode.yaml +++ b/.github/workflows/jwt_decode.yaml @@ -1,14 +1,14 @@ name: jwt_decode -on: [ pull_request, push ] +on: [pull_request, push] jobs: build: uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable - flutter_version: 3.19.6 + flutter_version: 3.22.1 min_coverage: 30 working_directory: packages/jwt_decode - dart_sdk: 3.3.4 + dart_sdk: 3.4.1 build_runner: false diff --git a/.github/workflows/key_generator.yaml b/.github/workflows/key_generator.yaml new file mode 100644 index 000000000..e0f9419df --- /dev/null +++ b/.github/workflows/key_generator.yaml @@ -0,0 +1,14 @@ +name: key_generator + +on: [pull_request, push] + +jobs: + build: + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + with: + flutter_channel: stable + flutter_version: 3.22.1 + min_coverage: 30 + working_directory: packages/key_generator + dart_sdk: 3.4.1 + build_runner: false diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml new file mode 100644 index 000000000..cb83c408f --- /dev/null +++ b/.github/workflows/oidc4vc.yaml @@ -0,0 +1,14 @@ +name: oidc4vc + +on: [pull_request, push] + +jobs: + build: + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + with: + flutter_channel: stable + flutter_version: 3.22.1 + min_coverage: 30 + working_directory: packages/oidc4vc + dart_sdk: 3.4.1 + build_runner: true diff --git a/.github/workflows/polygonid.yaml b/.github/workflows/polygonid.yaml new file mode 100644 index 000000000..507dffe6e --- /dev/null +++ b/.github/workflows/polygonid.yaml @@ -0,0 +1,14 @@ +name: polygonid + +on: [pull_request, push] + +jobs: + build: + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + with: + flutter_channel: stable + flutter_version: 3.22.1 + min_coverage: 30 + working_directory: packages/polygonid + dart_sdk: 3.4.1 + build_runner: false diff --git a/.github/workflows/secure_storage.yaml b/.github/workflows/secure_storage.yaml index 8f292dfb8..40b656652 100644 --- a/.github/workflows/secure_storage.yaml +++ b/.github/workflows/secure_storage.yaml @@ -7,8 +7,8 @@ jobs: uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable - flutter_version: 3.19.6 + flutter_version: 3.22.1 min_coverage: 30 working_directory: packages/secure_storage - dart_sdk: 3.3.4 + dart_sdk: 3.4.1 build_runner: false diff --git a/lib/app/shared/enum/status/credential_status_extension.dart b/lib/app/shared/enum/status/credential_status_extension.dart index 020172507..526687c22 100644 --- a/lib/app/shared/enum/status/credential_status_extension.dart +++ b/lib/app/shared/enum/status/credential_status_extension.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; extension CredentialStatusExtension on CredentialStatus { @@ -44,7 +43,7 @@ extension CredentialStatusExtension on CredentialStatus { Color color(BuildContext context) { switch (this) { case CredentialStatus.active: - return Theme.of(context).colorScheme.activeColor; + return Theme.of(context).colorScheme.onTertiary; case CredentialStatus.invalidStatus: case CredentialStatus.expired: case CredentialStatus.pending: @@ -52,7 +51,7 @@ extension CredentialStatusExtension on CredentialStatus { case CredentialStatus.invalidSignature: case CredentialStatus.statusListInvalidSignature: case CredentialStatus.noStatus: - return Theme.of(context).colorScheme.inactiveColor; + return Theme.of(context).colorScheme.error; } } } diff --git a/lib/app/shared/enum/type/message_type/message_type.dart b/lib/app/shared/enum/type/message_type/message_type.dart index 957cf94ee..ba575dc44 100644 --- a/lib/app/shared/enum/type/message_type/message_type.dart +++ b/lib/app/shared/enum/type/message_type/message_type.dart @@ -1,5 +1,4 @@ import 'package:altme/app/shared/constants/icon_strings.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; part 'message_type_extension.dart'; diff --git a/lib/app/shared/enum/type/message_type/message_type_extension.dart b/lib/app/shared/enum/type/message_type/message_type_extension.dart index e33279aaa..59019c38f 100644 --- a/lib/app/shared/enum/type/message_type/message_type_extension.dart +++ b/lib/app/shared/enum/type/message_type/message_type_extension.dart @@ -4,13 +4,13 @@ extension MessageTypeX on MessageType { Color getColor(BuildContext context) { switch (this) { case MessageType.error: - return Theme.of(context).colorScheme.alertErrorMessage; + return Theme.of(context).colorScheme.error; case MessageType.warning: - return Theme.of(context).colorScheme.alertWarningMessage; + return Theme.of(context).colorScheme.onErrorContainer; case MessageType.info: - return Theme.of(context).colorScheme.alertInfoMessage; + return Theme.of(context).colorScheme.outline; case MessageType.success: - return Theme.of(context).colorScheme.alertSuccessMessage; + return Theme.of(context).colorScheme.onTertiary; } } diff --git a/lib/app/shared/extension/extension.dart b/lib/app/shared/extension/extension.dart index c8a08d0ed..e333dbbdc 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 'unit8_list_extension.dart'; diff --git a/lib/app/shared/extension/unit8List_extension.dart b/lib/app/shared/extension/unit8_list_extension.dart similarity index 100% rename from lib/app/shared/extension/unit8List_extension.dart rename to lib/app/shared/extension/unit8_list_extension.dart diff --git a/lib/app/shared/loading/loading_view.dart b/lib/app/shared/loading/loading_view.dart index c6caa7813..18e7bab43 100644 --- a/lib/app/shared/loading/loading_view.dart +++ b/lib/app/shared/loading/loading_view.dart @@ -54,7 +54,7 @@ class LoadingView { minWidth: size.width * 0.5, ), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(10), ), child: Padding( diff --git a/lib/app/shared/widget/base/background_card.dart b/lib/app/shared/widget/base/background_card.dart index f2ccdd398..6ab3b67ef 100644 --- a/lib/app/shared/widget/base/background_card.dart +++ b/lib/app/shared/widget/base/background_card.dart @@ -26,7 +26,7 @@ class BackgroundCard extends StatelessWidget { height: height, width: width, decoration: BoxDecoration( - color: color ?? Theme.of(context).colorScheme.surface, + color: color ?? Theme.of(context).colorScheme.surfaceBright, borderRadius: const BorderRadius.all(Radius.circular(15)), ), child: child, diff --git a/lib/app/shared/widget/base/markdown_page.dart b/lib/app/shared/widget/base/markdown_page.dart index c8c7306f2..39e4ffcf2 100644 --- a/lib/app/shared/widget/base/markdown_page.dart +++ b/lib/app/shared/widget/base/markdown_page.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -33,13 +32,17 @@ class MarkdownPage extends StatelessWidget { data: snapshot.data!, styleSheet: MarkdownStyleSheet( h1: TextStyle( - color: Theme.of(context).colorScheme.markDownH1, + color: Theme.of(context).colorScheme.onSurface, ), h2: TextStyle( - color: Theme.of(context).colorScheme.markDownH2, + color: Theme.of(context).colorScheme.onSurface, ), - a: TextStyle(color: Theme.of(context).colorScheme.markDownA), - p: TextStyle(color: Theme.of(context).colorScheme.markDownP), + a: TextStyle(color: Theme.of(context).colorScheme.primary), + p: TextStyle( + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6),), ), onTapLink: (text, href, title) => _onTapLink(href), ); diff --git a/lib/app/shared/widget/base/otp_textfield.dart b/lib/app/shared/widget/base/otp_textfield.dart index dad5a2636..67962c99e 100644 --- a/lib/app/shared/widget/base/otp_textfield.dart +++ b/lib/app/shared/widget/base/otp_textfield.dart @@ -1,4 +1,3 @@ -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class OtpTextField extends StatelessWidget { @@ -27,7 +26,7 @@ class OtpTextField extends StatelessWidget { style: Theme.of(context).textTheme.labelLarge, cursorColor: Theme.of(context).colorScheme.onPrimary, decoration: InputDecoration( - fillColor: Theme.of(context).colorScheme.lightPurple, + fillColor: Theme.of(context).colorScheme.secondary, filled: true, border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), diff --git a/lib/app/shared/widget/button/my_elevated_button.dart b/lib/app/shared/widget/button/my_elevated_button.dart index 9e58c6ed0..c872fc511 100644 --- a/lib/app/shared/widget/button/my_elevated_button.dart +++ b/lib/app/shared/widget/button/my_elevated_button.dart @@ -1,4 +1,3 @@ -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -90,16 +89,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 + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.12) : backgroundColor ?? Theme.of(context).colorScheme.primary, ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), ), @@ -124,7 +123,7 @@ class ElevatedButtonText extends StatelessWidget { return Text( text.toUpperCase(), style: GoogleFonts.nunito( - color: textColor ?? Theme.of(context).colorScheme.onElevatedButton, + color: textColor ?? Theme.of(context).colorScheme.onPrimary, fontSize: fontSize, fontWeight: FontWeight.w700, ), diff --git a/lib/app/shared/widget/button/my_gradient_button.dart b/lib/app/shared/widget/button/my_gradient_button.dart index 504ad0960..a975ad173 100644 --- a/lib/app/shared/widget/button/my_gradient_button.dart +++ b/lib/app/shared/widget/button/my_gradient_button.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class MyGradientButton extends StatelessWidget { @@ -46,8 +45,8 @@ class MyGradientButton extends StatelessWidget { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Theme.of(context).colorScheme.startButtonColorA, - Theme.of(context).colorScheme.startButtonColorB, + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryContainer, ], ); return SizedBox( @@ -57,7 +56,7 @@ class MyGradientButton extends StatelessWidget { borderRadius: BorderRadius.circular(borderRadius), gradient: onPressed == null ? null : gradientValue, color: onPressed == null - ? Theme.of(context).colorScheme.disabledBgColor + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.12) : null, ), child: icon == null @@ -106,8 +105,8 @@ ButtonStyle gradientStyleFrom({ return ElevatedButton.styleFrom( elevation: elevation, padding: EdgeInsets.symmetric(vertical: verticalSpacing), - backgroundColor: Theme.of(context).colorScheme.transparent, - shadowColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, + shadowColor: Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), ), @@ -136,8 +135,8 @@ class GradientButtonText extends StatelessWidget { upperCase ? text.toUpperCase() : text, style: TextStyle( color: onPressed != null - ? Theme.of(context).colorScheme.onElevatedButton - : Theme.of(context).colorScheme.disabledTextColor, + ? Theme.of(context).colorScheme.onPrimary + : Theme.of(context).colorScheme.onSurface.withOpacity(0.38), fontSize: fontSize, fontWeight: FontWeight.w700, ), diff --git a/lib/app/shared/widget/button/my_outlined_button.dart b/lib/app/shared/widget/button/my_outlined_button.dart index bcebb67c1..671745caf 100644 --- a/lib/app/shared/widget/button/my_outlined_button.dart +++ b/lib/app/shared/widget/button/my_outlined_button.dart @@ -1,4 +1,3 @@ -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class MyOutlinedButton extends StatelessWidget { @@ -103,7 +102,7 @@ ButtonStyle outlinedStyleFrom({ backgroundColor ?? Theme.of(context).colorScheme.surface, side: BorderSide( color: onPressed == null - ? Theme.of(context).colorScheme.disabledBgColor + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.12) : borderColor ?? Theme.of(context).colorScheme.primary, width: 2, ), @@ -133,8 +132,8 @@ class OutlinedButtonText extends StatelessWidget { text.toUpperCase(), style: TextStyle( color: onPressed == null - ? Theme.of(context).colorScheme.disabledBgColor - : textColor ?? Theme.of(context).colorScheme.onOutlineButton, + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.12) + : textColor ?? Theme.of(context).colorScheme.primary, fontSize: fontSize, fontWeight: FontWeight.w700, ), diff --git a/lib/app/shared/widget/cached_image_from_network.dart b/lib/app/shared/widget/cached_image_from_network.dart index 7c2dec106..3cb2b7f62 100644 --- a/lib/app/shared/widget/cached_image_from_network.dart +++ b/lib/app/shared/widget/cached_image_from_network.dart @@ -49,7 +49,8 @@ class CachedImageFromNetwork extends StatelessWidget { placeholderBuilder: (_) => Container( width: width, height: height, - color: Theme.of(context).colorScheme.lightGrey, + color: + Theme.of(context).colorScheme.onSurface.withOpacity(0.6), ), ) : url.startsWith('http') @@ -76,19 +77,25 @@ class CachedImageFromNetwork extends StatelessWidget { ) : Container( color: bgColor ?? - Theme.of(context).colorScheme.lightGrey, + Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), ); }, - errorWidget: (context, error, dynamic _) => - errorMessage == null - ? ColoredBox( - color: Theme.of(context).colorScheme.lightGrey, - child: Icon( - Icons.error, - color: Theme.of(context).colorScheme.darkGrey, - ), - ) - : ErrorWidget(errorMessage: errorMessage), + errorWidget: (context, error, dynamic _) => errorMessage == + null + ? ColoredBox( + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), + child: Icon( + Icons.error, + color: Theme.of(context).colorScheme.onSurface, + ), + ) + : ErrorWidget(errorMessage: errorMessage), ) : Image.memory( base64Decode(url), 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/app/shared/widget/default_dialog.dart b/lib/app/shared/widget/default_dialog.dart index 9e0c95281..40a75765d 100644 --- a/lib/app/shared/widget/default_dialog.dart +++ b/lib/app/shared/widget/default_dialog.dart @@ -19,7 +19,7 @@ class DefaultDialog extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric( horizontal: Sizes.spaceNormal, diff --git a/lib/app/shared/widget/dialog/becareful_dialog.dart b/lib/app/shared/widget/dialog/becareful_dialog.dart index 1a1eba899..a1df695eb 100644 --- a/lib/app/shared/widget/dialog/becareful_dialog.dart +++ b/lib/app/shared/widget/dialog/becareful_dialog.dart @@ -43,7 +43,7 @@ class BeCarefulDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric( horizontal: Sizes.spaceNormal, @@ -57,7 +57,7 @@ class BeCarefulDialog extends StatelessWidget { children: [ DialogCloseButton( showText: false, - color: Theme.of(context).colorScheme.defaultDialogDark, + color: Theme.of(context).colorScheme.surface, ), Image.asset( IconStrings.alert, @@ -94,7 +94,7 @@ class BeCarefulDialog extends StatelessWidget { fontSize: 15, borderColor: Theme.of(context) .colorScheme - .defualtDialogCancelButtonBorderColor, + .onSurface.withOpacity(0.2), borderRadius: 12, onPressed: () { Navigator.of(context).pop(); diff --git a/lib/app/shared/widget/dialog/confirm_dialog.dart b/lib/app/shared/widget/dialog/confirm_dialog.dart index ec9ed52d0..cdf9b3d63 100644 --- a/lib/app/shared/widget/dialog/confirm_dialog.dart +++ b/lib/app/shared/widget/dialog/confirm_dialog.dart @@ -30,9 +30,9 @@ class ConfirmDialog extends StatelessWidget { @override Widget build(BuildContext context) { final color = dialogColor ?? Theme.of(context).colorScheme.primary; - final background = bgColor ?? Theme.of(context).colorScheme.popupBackground; + final background = bgColor ?? Theme.of(context).colorScheme.surface; final textColor = - this.textColor ?? Theme.of(context).colorScheme.dialogText; + this.textColor ?? Theme.of(context).colorScheme.onSurface; final l10n = context.l10n; return AlertDialog( @@ -84,7 +84,7 @@ class ConfirmDialog extends StatelessWidget { fontSize: 15, borderColor: Theme.of(context) .colorScheme - .defualtDialogCancelButtonBorderColor, + .onSurface.withOpacity(0.2), backgroundColor: background, textColor: textColor, borderRadius: Sizes.smallRadius, diff --git a/lib/app/shared/widget/dialog/error_details_dialog.dart b/lib/app/shared/widget/dialog/error_details_dialog.dart index 3609545bb..645796f5d 100644 --- a/lib/app/shared/widget/dialog/error_details_dialog.dart +++ b/lib/app/shared/widget/dialog/error_details_dialog.dart @@ -23,9 +23,9 @@ class ErrorDetailsDialog extends StatelessWidget { @override Widget build(BuildContext context) { final color = dialogColor ?? Theme.of(context).colorScheme.primary; - final background = bgColor ?? Theme.of(context).colorScheme.popupBackground; + final background = bgColor ?? Theme.of(context).colorScheme.surface; final textColor = - this.textColor ?? Theme.of(context).colorScheme.dialogText; + this.textColor ?? Theme.of(context).colorScheme.onSurface; final l10n = context.l10n; return AlertDialog( @@ -62,10 +62,10 @@ class ErrorDetailsDialog extends StatelessWidget { child: Text( l10n.moreDetails, style: Theme.of(context).textTheme.bodyMedium!.copyWith( - color: Theme.of(context).colorScheme.markDownA, + color: Theme.of(context).colorScheme.primary, decoration: TextDecoration.underline, decorationColor: - Theme.of(context).colorScheme.markDownA, + Theme.of(context).colorScheme.primary, ), textAlign: TextAlign.center, ), diff --git a/lib/app/shared/widget/dialog/error_dialog.dart b/lib/app/shared/widget/dialog/error_dialog.dart index 2c7639713..2036b6cc1 100644 --- a/lib/app/shared/widget/dialog/error_dialog.dart +++ b/lib/app/shared/widget/dialog/error_dialog.dart @@ -24,9 +24,9 @@ class ErrorDialog extends StatelessWidget { @override Widget build(BuildContext context) { final color = dialogColor ?? Theme.of(context).colorScheme.primary; - final background = bgColor ?? Theme.of(context).colorScheme.popupBackground; + final background = bgColor ?? Theme.of(context).colorScheme.surface; final textColor = - this.textColor ?? Theme.of(context).colorScheme.dialogText; + this.textColor ?? Theme.of(context).colorScheme.onSurface; final l10n = context.l10n; return AlertDialog( @@ -61,7 +61,7 @@ class ErrorDialog extends StatelessWidget { fontSize: 15, borderColor: Theme.of(context) .colorScheme - .defualtDialogCancelButtonBorderColor, + .onSurface.withOpacity(0.2), backgroundColor: background, textColor: textColor, borderRadius: Sizes.smallRadius, diff --git a/lib/app/shared/widget/dialog/text_field_dialog.dart b/lib/app/shared/widget/dialog/text_field_dialog.dart index f3ef3bc5f..bd3560e1c 100644 --- a/lib/app/shared/widget/dialog/text_field_dialog.dart +++ b/lib/app/shared/widget/dialog/text_field_dialog.dart @@ -54,8 +54,8 @@ class _TextFieldDialogState extends State { final color = widget.dialogColor ?? Theme.of(context).colorScheme.primary; final background = - widget.bgColor ?? Theme.of(context).colorScheme.popupBackground; - final text = widget.textColor ?? Theme.of(context).colorScheme.label; + widget.bgColor ?? Theme.of(context).colorScheme.surface; + final text = widget.textColor ?? Theme.of(context).colorScheme.onSurface; return AlertDialog( backgroundColor: background, @@ -108,7 +108,7 @@ class _TextFieldDialogState extends State { elevation: 10, borderRadius: Sizes.smallRadius, backgroundColor: color, - textColor: Theme.of(context).colorScheme.label, + textColor: Theme.of(context).colorScheme.onSurface, fontSize: 15, onPressed: () { Navigator.of(context).pop(controller.text); @@ -123,9 +123,9 @@ class _TextFieldDialogState extends State { borderRadius: Sizes.smallRadius, borderColor: Theme.of(context) .colorScheme - .defualtDialogCancelButtonBorderColor, + .onSurface.withOpacity(0.2), backgroundColor: background, - textColor: Theme.of(context).colorScheme.dialogText, + textColor: Theme.of(context).colorScheme.onSurface, onPressed: () { Navigator.of(context).pop(''); }, diff --git a/lib/app/shared/widget/dialog_close_button.dart b/lib/app/shared/widget/dialog_close_button.dart index e2c192df6..22778d3cd 100644 --- a/lib/app/shared/widget/dialog_close_button.dart +++ b/lib/app/shared/widget/dialog_close_button.dart @@ -30,7 +30,8 @@ class DialogCloseButton extends StatelessWidget { Container( padding: const EdgeInsets.all(0.5), decoration: BoxDecoration( - color: color ?? Theme.of(context).colorScheme.closeIconColor, + color: color ?? + Theme.of(context).colorScheme.onSurface.withOpacity(0.6), shape: BoxShape.circle, ), child: const Icon( diff --git a/lib/app/shared/widget/display_terms.dart b/lib/app/shared/widget/display_terms.dart index 8cb53e93b..6bab855c4 100644 --- a/lib/app/shared/widget/display_terms.dart +++ b/lib/app/shared/widget/display_terms.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -154,11 +153,12 @@ class MarkdownBody extends StatelessWidget { data: data, styleSheet: MarkdownStyleSheet( h1: TextStyle( - color: Theme.of(context).colorScheme.markDownH1, + color: Theme.of(context).colorScheme.onSurface, ), - h2: TextStyle(color: Theme.of(context).colorScheme.markDownH2), - a: TextStyle(color: Theme.of(context).colorScheme.markDownA), - p: TextStyle(color: Theme.of(context).colorScheme.markDownP), + h2: TextStyle(color: Theme.of(context).colorScheme.onSurface), + a: TextStyle(color: Theme.of(context).colorScheme.primary), + p: TextStyle( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),), //onTapLink: (text, href, title) => _onTapLink(href), ), diff --git a/lib/app/shared/widget/error_view.dart b/lib/app/shared/widget/error_view.dart index e4f227cae..778d370e6 100644 --- a/lib/app/shared/widget/error_view.dart +++ b/lib/app/shared/widget/error_view.dart @@ -29,7 +29,7 @@ class ErrorView extends StatelessWidget { width: MediaQuery.of(context).size.width / 2.5, child: MyOutlinedButton( text: l10n.tryAgain, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, onPressed: onTap, fontSize: 14, verticalSpacing: 10, diff --git a/lib/app/shared/widget/grouped_section.dart b/lib/app/shared/widget/grouped_section.dart index 1b0adb90a..393e097aa 100644 --- a/lib/app/shared/widget/grouped_section.dart +++ b/lib/app/shared/widget/grouped_section.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class GroupedSection extends StatelessWidget { @@ -16,7 +15,7 @@ class GroupedSection extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceSmall), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.largeRadius), ), diff --git a/lib/app/shared/widget/imported_tag.dart b/lib/app/shared/widget/imported_tag.dart index ab12b0cc2..2e4dd7349 100644 --- a/lib/app/shared/widget/imported_tag.dart +++ b/lib/app/shared/widget/imported_tag.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class ImportedTag extends StatelessWidget { @@ -14,7 +13,7 @@ class ImportedTag extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context).highlightColor, border: Border.all( - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), width: 0.35, ), borderRadius: diff --git a/lib/app/shared/widget/numeric_keyboard.dart b/lib/app/shared/widget/numeric_keyboard.dart index cefdfb5e5..f3a43ff5c 100644 --- a/lib/app/shared/widget/numeric_keyboard.dart +++ b/lib/app/shared/widget/numeric_keyboard.dart @@ -161,7 +161,7 @@ class KeyboardButton extends StatelessWidget { child: InkWell( highlightColor: allowAction ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.background, + : Theme.of(context).colorScheme.surface, splashColor: allowAction ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.surface, @@ -182,10 +182,10 @@ class KeyboardButton extends StatelessWidget { color: allowAction ? Theme.of(context) .colorScheme - .digitPrimaryColor + .onSurface : Theme.of(context) .colorScheme - .digitPrimaryColor + .onSurface .withOpacity(0.1), width: digitBorderWidth, ) @@ -193,9 +193,9 @@ class KeyboardButton extends StatelessWidget { ), child: Container( alignment: Alignment.center, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, - color: Theme.of(context).colorScheme.digitFillColor, + color: Colors.transparent, ), child: label != null ? Text( @@ -206,7 +206,7 @@ class KeyboardButton extends StatelessWidget { : digitTextStyle!.copyWith( color: Theme.of(context) .colorScheme - .digitPrimaryColor + .onSurface .withOpacity(0.1), ) : allowAction @@ -219,7 +219,7 @@ class KeyboardButton extends StatelessWidget { .copyWith( color: Theme.of(context) .colorScheme - .digitPrimaryColor + .onSurface .withOpacity(0.1), ), semanticsLabel: semanticsLabel, @@ -246,16 +246,16 @@ class KeyboardButton extends StatelessWidget { ? Border.all( color: Theme.of(context) .colorScheme - .digitPrimaryColor, + .onSurface, width: digitBorderWidth, ) : null, ), child: Container( alignment: Alignment.center, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, - color: Theme.of(context).colorScheme.digitFillColor, + color: Colors.transparent, ), child: label != null ? Text( diff --git a/lib/app/shared/widget/phrase_word.dart b/lib/app/shared/widget/phrase_word.dart index efc373003..8bb6b486d 100644 --- a/lib/app/shared/widget/phrase_word.dart +++ b/lib/app/shared/widget/phrase_word.dart @@ -29,7 +29,7 @@ class PhraseWord extends StatelessWidget { vertical: Sizes.spaceSmall, ), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.transparent, + color: Colors.transparent, border: Border.all( width: 1.5, color: color, diff --git a/lib/dashboard/add_account/import_account/view/import_account_step3_page.dart b/lib/dashboard/add_account/import_account/view/import_account_step3_page.dart index 7935fd66a..b6d630f28 100644 --- a/lib/dashboard/add_account/import_account/view/import_account_step3_page.dart +++ b/lib/dashboard/add_account/import_account/view/import_account_step3_page.dart @@ -129,7 +129,7 @@ class _ImportAccountStep3ViewState extends State { margin: const EdgeInsets.all(Sizes.spaceNormal), decoration: BoxDecoration( shape: BoxShape.circle, - color: Theme.of(context).colorScheme.checkMarkColor, + color: Theme.of(context).colorScheme.onTertiary, ), child: const Icon( Icons.check, diff --git a/lib/dashboard/add_account/import_account/widgets/account_item.dart b/lib/dashboard/add_account/import_account/widgets/account_item.dart index 020176c74..cda0c7cb7 100644 --- a/lib/dashboard/add_account/import_account/widgets/account_item.dart +++ b/lib/dashboard/add_account/import_account/widgets/account_item.dart @@ -24,7 +24,7 @@ class AccountItem extends StatelessWidget { vertical: Sizes.spaceSmall, ), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.cardHighlighted, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular( Sizes.smallRadius, diff --git a/lib/dashboard/ai_age_verification/verify_age/view/ai_age_result_page.dart b/lib/dashboard/ai_age_verification/verify_age/view/ai_age_result_page.dart index 82a6b7d60..3050a3b27 100644 --- a/lib/dashboard/ai_age_verification/verify_age/view/ai_age_result_page.dart +++ b/lib/dashboard/ai_age_verification/verify_age/view/ai_age_result_page.dart @@ -2,7 +2,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/kyc_verification/kyc_verification.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/app_theme/app_theme.dart'; import 'package:confetti/confetti.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -250,7 +249,7 @@ class FailureWidget extends StatelessWidget { text: l10n.decline, verticalSpacing: 16, borderRadius: Sizes.largeRadius, - backgroundColor: Theme.of(context).colorScheme.cardHighlighted, + backgroundColor: Theme.of(context).colorScheme.surface, onPressed: () { Navigator.pushAndRemoveUntil( context, diff --git a/lib/dashboard/ai_age_verification/verify_age/view/verify_age_page.dart b/lib/dashboard/ai_age_verification/verify_age/view/verify_age_page.dart index 53b148b2f..15ea27e0d 100644 --- a/lib/dashboard/ai_age_verification/verify_age/view/verify_age_page.dart +++ b/lib/dashboard/ai_age_verification/verify_age/view/verify_age_page.dart @@ -99,7 +99,7 @@ class _VerifyAgeViewState extends State { MyElevatedButton( text: l10n.decline, verticalSpacing: 16, - backgroundColor: Theme.of(context).colorScheme.cardHighlighted, + backgroundColor: Theme.of(context).colorScheme.surface, borderRadius: Sizes.largeRadius, onPressed: () { Navigator.of(context).pop(); diff --git a/lib/dashboard/connection/confirm_connection/widgets/permissions.dart b/lib/dashboard/connection/confirm_connection/widgets/permissions.dart index a23d26d23..3285a2861 100644 --- a/lib/dashboard/connection/confirm_connection/widgets/permissions.dart +++ b/lib/dashboard/connection/confirm_connection/widgets/permissions.dart @@ -12,7 +12,7 @@ class Permissions extends StatelessWidget { return Container( decoration: BoxDecoration( border: Border.all( - color: Theme.of(context).colorScheme.beaconBorder, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), width: 1.5, ), borderRadius: BorderRadius.circular(15), diff --git a/lib/dashboard/connection/confirm_connection/widgets/select_account.dart b/lib/dashboard/connection/confirm_connection/widgets/select_account.dart index f34377b9b..1a8264d90 100644 --- a/lib/dashboard/connection/confirm_connection/widgets/select_account.dart +++ b/lib/dashboard/connection/confirm_connection/widgets/select_account.dart @@ -62,7 +62,7 @@ class SelectAccount extends StatelessWidget { ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ), ); diff --git a/lib/dashboard/connection/connected_dapps/view/connected_dapps_page.dart b/lib/dashboard/connection/connected_dapps/view/connected_dapps_page.dart index 0c947af51..13c87048a 100644 --- a/lib/dashboard/connection/connected_dapps/view/connected_dapps_page.dart +++ b/lib/dashboard/connection/connected_dapps/view/connected_dapps_page.dart @@ -193,7 +193,7 @@ class _ConnectedDappsViewState extends State { separatorBuilder: (_, __) => Divider( height: 0.1, color: - Theme.of(context).colorScheme.borderColor, + Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ), ], diff --git a/lib/dashboard/connection/operation/widgets/fee_details.dart b/lib/dashboard/connection/operation/widgets/fee_details.dart index 6d51aa750..7e9aa957e 100644 --- a/lib/dashboard/connection/operation/widgets/fee_details.dart +++ b/lib/dashboard/connection/operation/widgets/fee_details.dart @@ -23,7 +23,7 @@ class FeeDetails extends StatelessWidget { final double grandTotal = amount + fee; return BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -96,7 +96,7 @@ class FeeDetails extends StatelessWidget { ), child: Divider( height: 0.1, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ); } diff --git a/lib/dashboard/connection/operation/widgets/sender_reciever.dart b/lib/dashboard/connection/operation/widgets/sender_reciever.dart index a11b3c110..65e834266 100644 --- a/lib/dashboard/connection/operation/widgets/sender_reciever.dart +++ b/lib/dashboard/connection/operation/widgets/sender_reciever.dart @@ -41,7 +41,7 @@ class SenderReceiverCard extends StatelessWidget { @override Widget build(BuildContext context) { return BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: SizedBox( width: double.infinity, child: Column( diff --git a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/view/crypto_bottom_sheet_view.dart b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/view/crypto_bottom_sheet_view.dart index 1fa704330..fb5791266 100644 --- a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/view/crypto_bottom_sheet_view.dart +++ b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/view/crypto_bottom_sheet_view.dart @@ -95,7 +95,7 @@ class _CryptoBottomSheetPageState extends State { backgroundColor: Colors.transparent, body: DecoratedBox( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface, + color: Theme.of(context).colorScheme.surfaceDim, boxShadow: [ BoxShadow( color: Theme.of(context).colorScheme.inversePrimary, @@ -140,7 +140,8 @@ class _CryptoBottomSheetPageState extends State { border: Border.all( color: Theme.of(context) .colorScheme - .accountBottomSheetBorder, + .onSurface + .withOpacity(0.12), width: 0.2, ), borderRadius: const BorderRadius.all( @@ -173,7 +174,8 @@ class _CryptoBottomSheetPageState extends State { height: 0.2, color: Theme.of(context) .colorScheme - .borderColor, + .onSurface + .withOpacity(0.12), ), ), ), 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/discover/view/discover_page.dart b/lib/dashboard/discover/view/discover_page.dart index a09d810a0..4693bde01 100644 --- a/lib/dashboard/discover/view/discover_page.dart +++ b/lib/dashboard/discover/view/discover_page.dart @@ -1,7 +1,6 @@ import 'package:altme/app/shared/widget/widget.dart'; import 'package:altme/credentials/credentials.dart'; import 'package:altme/dashboard/dashboard.dart'; -import 'package:altme/theme/theme.dart'; import 'package:altme/wallet/cubit/wallet_cubit.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -31,7 +30,7 @@ class _DiscoverPageState extends State { return BasePage( scrollView: false, padding: EdgeInsets.zero, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, body: BlocListener( listenWhen: (previous, current) { // if (current.model.profileSetting.selfSovereignIdentityOptions diff --git a/lib/dashboard/discover/view/discover_tab_page.dart b/lib/dashboard/discover/view/discover_tab_page.dart index 373697b7a..8096c730a 100644 --- a/lib/dashboard/discover/view/discover_tab_page.dart +++ b/lib/dashboard/discover/view/discover_tab_page.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -44,7 +43,7 @@ class _DiscoverTabPageViewState extends State return BasePage( scrollView: false, padding: EdgeInsets.zero, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, body: BlocBuilder( builder: (context, tabState) { _tabController.index = tabState; diff --git a/lib/dashboard/discover/widgets/discover_dynamic_detail.dart b/lib/dashboard/discover/widgets/discover_dynamic_detail.dart index b8fff09a5..8afab93d7 100644 --- a/lib/dashboard/discover/widgets/discover_dynamic_detail.dart +++ b/lib/dashboard/discover/widgets/discover_dynamic_detail.dart @@ -54,7 +54,7 @@ class DiscoverDynamicDetial extends StatelessWidget { }, child: ImageIcon( const AssetImage(IconStrings.link), - color: Theme.of(context).colorScheme.markDownA, + color: Theme.of(context).colorScheme.primary, size: 17, ), ), diff --git a/lib/dashboard/drawer/about_altme/about_altme/view/about_altme_menu.dart b/lib/dashboard/drawer/about_altme/about_altme/view/about_altme_menu.dart index bceccf02d..cac5387b1 100644 --- a/lib/dashboard/drawer/about_altme/about_altme/view/about_altme_menu.dart +++ b/lib/dashboard/drawer/about_altme/about_altme/view/about_altme_menu.dart @@ -35,7 +35,7 @@ class AboutAltmeView extends StatelessWidget { final profileSetting = profileModel.profileSetting; return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/about_altme/sofware_licenses/view/software_license_view.dart b/lib/dashboard/drawer/about_altme/sofware_licenses/view/software_license_view.dart index 928a38e9a..5b7759ace 100644 --- a/lib/dashboard/drawer/about_altme/sofware_licenses/view/software_license_view.dart +++ b/lib/dashboard/drawer/about_altme/sofware_licenses/view/software_license_view.dart @@ -61,7 +61,7 @@ class _SoftwareLicenseViewState extends State { physics: const ScrollPhysics(), itemBuilder: (context, index) { return BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.symmetric(horizontal: 8), margin: const EdgeInsets.only(bottom: 8), child: TransparentInkWell( @@ -98,7 +98,7 @@ class _SoftwareLicenseViewState extends State { const SizedBox(width: 10), Icon( Icons.chevron_right, - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, ), ], ), diff --git a/lib/dashboard/drawer/about_altme/terms/view/terms_page.dart b/lib/dashboard/drawer/about_altme/terms/view/terms_page.dart index dedd6538e..aeb2276ce 100644 --- a/lib/dashboard/drawer/about_altme/terms/view/terms_page.dart +++ b/lib/dashboard/drawer/about_altme/terms/view/terms_page.dart @@ -14,7 +14,7 @@ class TermsPage extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return BasePage( - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, title: l10n.termsOfUse, titleLeading: const BackLeadingButton(), scrollView: false, 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/blockchain_settings/blockchain_settings/view/blockchain_settings_menu.dart b/lib/dashboard/drawer/blockchain_settings/blockchain_settings/view/blockchain_settings_menu.dart index 64f80d6ec..0aca6d109 100644 --- a/lib/dashboard/drawer/blockchain_settings/blockchain_settings/view/blockchain_settings_menu.dart +++ b/lib/dashboard/drawer/blockchain_settings/blockchain_settings/view/blockchain_settings_menu.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.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'; @@ -29,7 +28,7 @@ class BlockchainSettingsView extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/account_private_key_page.dart b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/account_private_key_page.dart index 56ed1807a..64b063942 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/account_private_key_page.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/account_private_key_page.dart @@ -76,7 +76,7 @@ class _AccountPrivateKeyPageState extends State }, icon: Icon( Icons.qr_code, - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, ), ), body: BackgroundCard( diff --git a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/private_key_qr_page.dart b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/private_key_qr_page.dart index 18c54cfca..688a20ae8 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/private_key_qr_page.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/private_key_qr_page.dart @@ -81,7 +81,7 @@ class _PrivateKeyQrPageState extends State child: QrImageView( data: widget.data, size: 200, - foregroundColor: Theme.of(context).colorScheme.onBackground, + foregroundColor: Theme.of(context).colorScheme.onSurface, ), ), const SizedBox(height: 10), diff --git a/lib/dashboard/drawer/blockchain_settings/manage_accounts/widgets/manage_accounts_item.dart b/lib/dashboard/drawer/blockchain_settings/manage_accounts/widgets/manage_accounts_item.dart index 793c94c9c..424f51592 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_accounts/widgets/manage_accounts_item.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_accounts/widgets/manage_accounts_item.dart @@ -35,12 +35,12 @@ class ManageAccountsItem extends StatelessWidget { margin: const EdgeInsets.only(bottom: Sizes.spaceSmall), padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.cardHighlighted, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.normalRadius), ), border: Border.all( - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), width: 0.25, ), ), diff --git a/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart b/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart index 9f326e49e..eae0356e9 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart @@ -58,7 +58,10 @@ class ManageNetworkPage extends StatelessWidget { ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ], diff --git a/lib/dashboard/drawer/help_center/faqs/view/faqs_page.dart b/lib/dashboard/drawer/help_center/faqs/view/faqs_page.dart index a0b4d9e05..c7d8c85fb 100644 --- a/lib/dashboard/drawer/help_center/faqs/view/faqs_page.dart +++ b/lib/dashboard/drawer/help_center/faqs/view/faqs_page.dart @@ -65,7 +65,7 @@ class FAQsView extends StatelessWidget { decoration: TextDecoration.underline, color: Theme.of(context) .colorScheme - .markDownA, + .primary, ) : Theme.of(context).textTheme.faqAns, textAlign: TextAlign.justify, diff --git a/lib/dashboard/drawer/help_center/help_center/view/help_center_menu.dart b/lib/dashboard/drawer/help_center/help_center/view/help_center_menu.dart index 17e681773..f35e473d3 100644 --- a/lib/dashboard/drawer/help_center/help_center/view/help_center_menu.dart +++ b/lib/dashboard/drawer/help_center/help_center/view/help_center_menu.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -52,7 +51,7 @@ class HelpCenterView extends StatelessWidget { } return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/import_talao_community_card/view/import_talao_community_card_page.dart b/lib/dashboard/drawer/import_talao_community_card/view/import_talao_community_card_page.dart index c93ac0626..42d4a3179 100644 --- a/lib/dashboard/drawer/import_talao_community_card/view/import_talao_community_card_page.dart +++ b/lib/dashboard/drawer/import_talao_community_card/view/import_talao_community_card_page.dart @@ -132,7 +132,7 @@ class _ImportTalaoCommunityCardViewState shape: BoxShape.circle, color: Theme.of(context) .colorScheme - .checkMarkColor, + .onTertiary, ), child: const Icon( Icons.check, diff --git a/lib/dashboard/drawer/profile/view/pick_profile_menu.dart b/lib/dashboard/drawer/profile/view/pick_profile_menu.dart index 4488347c9..dd49a8857 100644 --- a/lib/dashboard/drawer/profile/view/pick_profile_menu.dart +++ b/lib/dashboard/drawer/profile/view/pick_profile_menu.dart @@ -2,7 +2,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/dashboard/drawer/profile/widget/profile_selector_widget.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class PickProfileMenu extends StatelessWidget { @@ -27,7 +26,7 @@ class PickProfileMenuView extends StatelessWidget { @override Widget build(BuildContext context) { return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/profile/widget/profile_selector_widget.dart b/lib/dashboard/drawer/profile/widget/profile_selector_widget.dart index 0ae8121fd..86bf8df8d 100644 --- a/lib/dashboard/drawer/profile/widget/profile_selector_widget.dart +++ b/lib/dashboard/drawer/profile/widget/profile_selector_widget.dart @@ -29,7 +29,7 @@ class ProfileSelectorWidget extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceSmall), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.largeRadius), ), @@ -73,7 +73,7 @@ class ProfileSelectorWidget extends StatelessWidget { child: Divider( height: 0, color: - Theme.of(context).colorScheme.borderColor, + Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart b/lib/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart new file mode 100644 index 000000000..409e74664 --- /dev/null +++ b/lib/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart @@ -0,0 +1,14 @@ +import 'package:altme/credentials/cubit/credentials_cubit.dart'; +import 'package:altme/dashboard/drawer/help_center/altme_support_chat/cubit/altme_support_chat_cubit.dart'; +import 'package:altme/dashboard/profile/cubit/profile_cubit.dart'; +import 'package:altme/wallet/cubit/wallet_cubit.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +Future resetWallet(BuildContext context) async { + await context.read().resetProfile(); + await context + .read() + .resetWallet(context.read()); + await context.read().dispose(); +} 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 f8f84326d..56ecebe59 100644 --- a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart +++ b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart @@ -1,9 +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'; @@ -39,7 +38,7 @@ class ResetWalletView extends StatelessWidget { titleAlignment: Alignment.topCenter, padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall), titleLeading: const BackLeadingButton(), - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, body: BlocBuilder( builder: (context, state) { return Column( @@ -101,22 +100,18 @@ class ResetWalletView extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceSmall), child: MyElevatedButton( text: l10n.resetWallet, - onPressed: state.isBackupCredentialSaved && - state.isRecoveryPhraseWritten - ? () async { - await securityCheck( - context: context, - localAuthApi: LocalAuthApi(), - onSuccess: () async { - await context.read().resetProfile(); - await context - .read() - .resetWallet(context.read()); - await context.read().dispose(); - }, - ); - } - : null, + onPressed: + state.isBackupCredentialSaved && state.isRecoveryPhraseWritten + ? () async { + await securityCheck( + context: context, + localAuthApi: LocalAuthApi(), + onSuccess: () async { + await resetWallet(context); + }, + ); + } + : null, ), ); }, diff --git a/lib/dashboard/drawer/src/view/check_linkedin_profile.dart b/lib/dashboard/drawer/src/view/check_linkedin_profile.dart index 9c08ee72e..841c0439d 100644 --- a/lib/dashboard/drawer/src/view/check_linkedin_profile.dart +++ b/lib/dashboard/drawer/src/view/check_linkedin_profile.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -30,7 +29,7 @@ class CheckForLinkedInProfileView extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: SingleChildScrollView( child: Padding( diff --git a/lib/dashboard/drawer/src/view/drawer_page.dart b/lib/dashboard/drawer/src/view/drawer_page.dart index c518c887b..1517fdaed 100644 --- a/lib/dashboard/drawer/src/view/drawer_page.dart +++ b/lib/dashboard/drawer/src/view/drawer_page.dart @@ -3,7 +3,6 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/dashboard/drawer/profile/view/pick_profile_menu.dart'; import 'package:altme/enterprise/cubit/enterprise_cubit.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -29,7 +28,7 @@ class DrawerView extends StatelessWidget { return SizedBox( width: MediaQuery.of(context).size.width, child: Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15), @@ -120,8 +119,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/drawer/src/widgets/drawer_category_item.dart b/lib/dashboard/drawer/src/widgets/drawer_category_item.dart index 2e2d4debe..171a677d4 100644 --- a/lib/dashboard/drawer/src/widgets/drawer_category_item.dart +++ b/lib/dashboard/drawer/src/widgets/drawer_category_item.dart @@ -25,7 +25,7 @@ class DrawerCategoryItem extends StatelessWidget { child: Container( padding: padding, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surfaceBright, borderRadius: const BorderRadius.all( Radius.circular(Sizes.normalRadius), ), @@ -58,7 +58,7 @@ class DrawerCategoryItem extends StatelessWidget { Icon( Icons.chevron_right, size: Sizes.icon2x, - color: Theme.of(context).colorScheme.unSelectedLabel, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), ), ], ], diff --git a/lib/dashboard/drawer/src/widgets/drawer_item.dart b/lib/dashboard/drawer/src/widgets/drawer_item.dart index 89b93bd04..34ea0e840 100644 --- a/lib/dashboard/drawer/src/widgets/drawer_item.dart +++ b/lib/dashboard/drawer/src/widgets/drawer_item.dart @@ -26,7 +26,7 @@ class DrawerItem extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceNormal), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surfaceBright, borderRadius: const BorderRadius.all( Radius.circular( Sizes.normalRadius, @@ -48,7 +48,10 @@ class DrawerItem extends StatelessWidget { style: Theme.of(context).textTheme.drawerItemTitle.copyWith( color: isDisabled - ? Theme.of(context).colorScheme.lightGrey + ? Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6) : null, ), ), @@ -61,7 +64,10 @@ class DrawerItem extends StatelessWidget { .drawerItemSubtitle .copyWith( color: isDisabled - ? Theme.of(context).colorScheme.lightGrey + ? Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6) : null, ), ), @@ -78,8 +84,11 @@ class DrawerItem extends StatelessWidget { Icons.chevron_right, size: Sizes.icon2x, color: isDisabled - ? Theme.of(context).colorScheme.lightGrey - : Theme.of(context).colorScheme.unSelectedLabel, + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.6) + : Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), ), ], ], diff --git a/lib/dashboard/drawer/src/widgets/drawer_item2.dart b/lib/dashboard/drawer/src/widgets/drawer_item2.dart index 1429f401d..99801b9a3 100644 --- a/lib/dashboard/drawer/src/widgets/drawer_item2.dart +++ b/lib/dashboard/drawer/src/widgets/drawer_item2.dart @@ -26,7 +26,7 @@ class DrawerItem2 extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceNormal), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular( Sizes.normalRadius, @@ -47,7 +47,10 @@ class DrawerItem2 extends StatelessWidget { style: Theme.of(context).textTheme.drawerItemTitle.copyWith( color: isDisabled - ? Theme.of(context).colorScheme.lightGrey + ? Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6) : null, ), ), @@ -60,7 +63,10 @@ class DrawerItem2 extends StatelessWidget { .drawerItemSubtitle .copyWith( color: isDisabled - ? Theme.of(context).colorScheme.lightGrey + ? Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6) : null, ), ), @@ -77,8 +83,11 @@ class DrawerItem2 extends StatelessWidget { Icons.chevron_right, size: 26, color: isDisabled - ? Theme.of(context).colorScheme.lightGrey - : Theme.of(context).colorScheme.unSelectedLabel, + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.6) + : Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), ), ], ], diff --git a/lib/dashboard/drawer/src/widgets/drawer_item_divider.dart b/lib/dashboard/drawer/src/widgets/drawer_item_divider.dart index d3f4d4b2b..a81e9f445 100644 --- a/lib/dashboard/drawer/src/widgets/drawer_item_divider.dart +++ b/lib/dashboard/drawer/src/widgets/drawer_item_divider.dart @@ -1,4 +1,3 @@ -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class DrawerItemDivider extends StatelessWidget { @@ -11,7 +10,7 @@ class DrawerItemDivider extends StatelessWidget { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), width: 0.2, ), ), diff --git a/lib/dashboard/drawer/src/widgets/enterprise_data.dart b/lib/dashboard/drawer/src/widgets/enterprise_data.dart index ad2e4e0de..63a6e87ed 100644 --- a/lib/dashboard/drawer/src/widgets/enterprise_data.dart +++ b/lib/dashboard/drawer/src/widgets/enterprise_data.dart @@ -19,7 +19,7 @@ class EnterpriseData extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceNormal), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.normalRadius), ), diff --git a/lib/dashboard/drawer/ssi/backup/src/view/backup_menu.dart b/lib/dashboard/drawer/ssi/backup/src/view/backup_menu.dart index 9a465d69d..5b144597f 100644 --- a/lib/dashboard/drawer/ssi/backup/src/view/backup_menu.dart +++ b/lib/dashboard/drawer/ssi/backup/src/view/backup_menu.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -28,7 +27,7 @@ class BackupView extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: SingleChildScrollView( child: Padding( diff --git a/lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart b/lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart index 2739c9f75..20865d7bf 100644 --- a/lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart +++ b/lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart @@ -2,7 +2,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/polygon_id/polygon_id.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -29,7 +28,7 @@ class DidView extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: SingleChildScrollView( child: Padding( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_authentication_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_authentication_widget.dart index 42d20fa54..8fb078117 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_authentication_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_authentication_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -36,7 +35,10 @@ class ClientAuthenticationWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_type_widget.dart index d154ccbef..a96ba238c 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_type_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/client_type_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -31,7 +30,10 @@ class ClientTypeWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart index 997bc82a0..80fb03bb5 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart @@ -12,8 +12,8 @@ class ConfidentialClientWidget extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; final color = Theme.of(context).colorScheme.primary; - final background = Theme.of(context).colorScheme.popupBackground; - final textColor = Theme.of(context).colorScheme.dialogText; + final background = Theme.of(context).colorScheme.surface; + final textColor = Theme.of(context).colorScheme.onSurface; return BlocBuilder( builder: (context, state) { final clientIdController = TextEditingController( @@ -118,7 +118,7 @@ class ConfidentialClientWidget extends StatelessWidget { ), decoration: BoxDecoration( border: Border.all( - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, ), borderRadius: const BorderRadius.all( Radius.circular( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/did_key_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/did_key_type_widget.dart index 040c2d27d..f5e513d2e 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/did_key_type_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/did_key_type_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -35,7 +34,10 @@ class DidKeyTypeWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart index af814253d..f535378a1 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/draft_type_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -31,7 +30,10 @@ class DraftTypeWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/option_container.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/option_container.dart index 1c46885b5..a743100ba 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/option_container.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/option_container.dart @@ -21,7 +21,7 @@ class OptionContainer extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceSmall), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.largeRadius), ), diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_header_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_header_widget.dart index 121f67bab..a1e62c379 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_header_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_header_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -31,7 +30,10 @@ class ProofHeaderWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_type_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_type_widget.dart index fc509e13d..98af2898d 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_type_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/proof_type_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -31,7 +30,10 @@ class ProofTypeWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/vc_format_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/vc_format_widget.dart index ee02be9be..868cc7e7c 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/vc_format_widget.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/vc_format_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:oidc4vc/oidc4vc.dart'; @@ -31,7 +30,10 @@ class VCFormatWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8), child: Divider( height: 0, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/drawer/ssi/restore/restore_credential/widgets/upload_file.dart b/lib/dashboard/drawer/ssi/restore/restore_credential/widgets/upload_file.dart index 92d21670c..8ddb35716 100644 --- a/lib/dashboard/drawer/ssi/restore/restore_credential/widgets/upload_file.dart +++ b/lib/dashboard/drawer/ssi/restore/restore_credential/widgets/upload_file.dart @@ -22,7 +22,7 @@ class UploadFile extends StatelessWidget { return DottedBorder( borderType: BorderType.RRect, radius: const Radius.circular(Sizes.smallRadius), - color: Theme.of(context).colorScheme.cardHighlighted, + color: Theme.of(context).colorScheme.surface, child: InkWell( onTap: onTap, child: Container( @@ -30,7 +30,7 @@ class UploadFile extends StatelessWidget { height: 85, decoration: BoxDecoration( color: filePath != null - ? Theme.of(context).colorScheme.cardHighlighted + ? Theme.of(context).colorScheme.surface : null, borderRadius: const BorderRadius.all( Radius.circular(Sizes.smallRadius), diff --git a/lib/dashboard/drawer/ssi/restore/src/view/restore_menu.dart b/lib/dashboard/drawer/ssi/restore/src/view/restore_menu.dart index 083222eb1..50d34bc43 100644 --- a/lib/dashboard/drawer/ssi/restore/src/view/restore_menu.dart +++ b/lib/dashboard/drawer/ssi/restore/src/view/restore_menu.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -28,7 +27,7 @@ class RestoreView extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: SingleChildScrollView( child: Padding( diff --git a/lib/dashboard/drawer/ssi/src/view/ssi_menu.dart b/lib/dashboard/drawer/ssi/src/view/ssi_menu.dart index 7766cc1f1..76f95e041 100644 --- a/lib/dashboard/drawer/ssi/src/view/ssi_menu.dart +++ b/lib/dashboard/drawer/ssi/src/view/ssi_menu.dart @@ -2,7 +2,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/dashboard/drawer/ssi/manage_did/view/did_menu.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -37,7 +36,7 @@ class SSIView extends StatelessWidget { .selfSovereignIdentityOptions .displayManageDecentralizedId; return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/ssi/trust_framework/view/trust_framework_page.dart b/lib/dashboard/drawer/ssi/trust_framework/view/trust_framework_page.dart index 061ae178a..8ae0de734 100644 --- a/lib/dashboard/drawer/ssi/trust_framework/view/trust_framework_page.dart +++ b/lib/dashboard/drawer/ssi/trust_framework/view/trust_framework_page.dart @@ -76,7 +76,7 @@ class TrustFrameworkPage extends StatelessWidget { horizontal: Sizes.spaceSmall, ), child: Divider( - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ), IssuerVerifierSelector( diff --git a/lib/dashboard/drawer/wallet_security/advanced_security_settings/view/advanced_security_settings_menu.dart b/lib/dashboard/drawer/wallet_security/advanced_security_settings/view/advanced_security_settings_menu.dart index d1106c6b1..f53bbd2c6 100644 --- a/lib/dashboard/drawer/wallet_security/advanced_security_settings/view/advanced_security_settings_menu.dart +++ b/lib/dashboard/drawer/wallet_security/advanced_security_settings/view/advanced_security_settings_menu.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -30,7 +29,7 @@ class AdvancedSecuritySettingsView extends StatelessWidget { return BlocBuilder( builder: (context, state) { return Drawer( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, child: SafeArea( child: SingleChildScrollView( child: Padding( diff --git a/lib/dashboard/drawer/wallet_security/src/view/wallet_security_menu.dart b/lib/dashboard/drawer/wallet_security/src/view/wallet_security_menu.dart index da236fc3e..df5275e3d 100644 --- a/lib/dashboard/drawer/wallet_security/src/view/wallet_security_menu.dart +++ b/lib/dashboard/drawer/wallet_security/src/view/wallet_security_menu.dart @@ -3,7 +3,6 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/onboarding/protect_wallet/view/protect_wallet_page.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,7 +31,7 @@ class WalletSecurityView extends StatelessWidget { return BlocBuilder( builder: (context, state) { return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/wallet_settings/view/wallet_settings_menu.dart b/lib/dashboard/drawer/wallet_settings/view/wallet_settings_menu.dart index 5bcd9834a..d119899a3 100644 --- a/lib/dashboard/drawer/wallet_settings/view/wallet_settings_menu.dart +++ b/lib/dashboard/drawer/wallet_settings/view/wallet_settings_menu.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class WalletSettingsMenu extends StatelessWidget { @@ -25,7 +24,7 @@ class WalletSettingsMenuView extends StatelessWidget { @override Widget build(BuildContext context) { return BasePage( - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, useSafeArea: true, scrollView: true, titleAlignment: Alignment.topCenter, diff --git a/lib/dashboard/drawer/wallet_settings/widget/language_selector_widget.dart b/lib/dashboard/drawer/wallet_settings/widget/language_selector_widget.dart index f4048b3a2..f169fa2a9 100644 --- a/lib/dashboard/drawer/wallet_settings/widget/language_selector_widget.dart +++ b/lib/dashboard/drawer/wallet_settings/widget/language_selector_widget.dart @@ -23,7 +23,7 @@ class LanguageSelectorWidget extends StatelessWidget { padding: const EdgeInsets.all(Sizes.spaceSmall), margin: const EdgeInsets.all(Sizes.spaceXSmall), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.drawerSurface, + color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular(Sizes.largeRadius), ), @@ -62,7 +62,7 @@ class LanguageSelectorWidget extends StatelessWidget { child: Divider( height: 0, color: - Theme.of(context).colorScheme.borderColor, + Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ), ListTile( diff --git a/lib/dashboard/home/home/widgets/qr_icon.dart b/lib/dashboard/home/home/widgets/qr_icon.dart index 56a6181b9..ff1c7589f 100644 --- a/lib/dashboard/home/home/widgets/qr_icon.dart +++ b/lib/dashboard/home/home/widgets/qr_icon.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -46,16 +45,17 @@ class QRIcon extends StatelessWidget { height: 75, width: 75, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.qrScanBackground, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(50), boxShadow: [ BoxShadow( - color: Theme.of(context).colorScheme.qrScanOuterShadow, + color: Theme.of(context).colorScheme.primary, blurRadius: 5, offset: Offset.zero, ), BoxShadow( - color: Theme.of(context).colorScheme.qrScanInnerShadow, + color: + Theme.of(context).colorScheme.shadow.withOpacity(0.16), blurRadius: 12, spreadRadius: -12, offset: Offset.zero, diff --git a/lib/dashboard/home/home/widgets/token_reward_dialog.dart b/lib/dashboard/home/home/widgets/token_reward_dialog.dart index 3a33d3c5b..5db4deee9 100644 --- a/lib/dashboard/home/home/widgets/token_reward_dialog.dart +++ b/lib/dashboard/home/home/widgets/token_reward_dialog.dart @@ -29,7 +29,7 @@ class TokenRewardDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric( horizontal: Sizes.spaceNormal, diff --git a/lib/dashboard/home/home/widgets/wallet_dialog.dart b/lib/dashboard/home/home/widgets/wallet_dialog.dart index 63cf03f99..d3bff1203 100644 --- a/lib/dashboard/home/home/widgets/wallet_dialog.dart +++ b/lib/dashboard/home/home/widgets/wallet_dialog.dart @@ -13,7 +13,7 @@ class WalletDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), shape: const RoundedRectangleBorder( @@ -29,14 +29,14 @@ class WalletDialog extends StatelessWidget { IconStrings.cardSend, width: 50, height: 50, - color: Theme.of(context).colorScheme.dialogText, + color: Theme.of(context).colorScheme.onSurface, ), const SizedBox(height: 30), Text( l10n.createTitle, style: Theme.of(context).textTheme.defaultDialogTitle.copyWith( fontSize: 18, - color: Theme.of(context).colorScheme.dialogText, + color: Theme.of(context).colorScheme.onSurface, ), textAlign: TextAlign.center, ), @@ -46,7 +46,7 @@ class WalletDialog extends StatelessWidget { style: Theme.of(context) .textTheme .defaultDialogSubtitle - .copyWith(color: Theme.of(context).colorScheme.dialogText), + .copyWith(color: Theme.of(context).colorScheme.onSurface), textAlign: TextAlign.center, ), const SizedBox(height: 30), @@ -76,12 +76,12 @@ class WalletDialog extends StatelessWidget { verticalSpacing: 12, fontSize: 13, borderRadius: 8, - textColor: Theme.of(context).colorScheme.lightPurple, + textColor: Theme.of(context).colorScheme.secondary, borderColor: Theme.of(context) .colorScheme - .defualtDialogCancelButtonBorderColor, - backgroundColor: - Theme.of(context).colorScheme.popupBackground, + .onSurface + .withOpacity(0.2), + backgroundColor: Theme.of(context).colorScheme.surface, onPressed: () { Navigator.pop(context); Navigator.of(context).push( diff --git a/lib/dashboard/home/tab_bar/credentials/credential_qr/view/credential_qr_page.dart b/lib/dashboard/home/tab_bar/credentials/credential_qr/view/credential_qr_page.dart index f5ce895ad..d743229fc 100644 --- a/lib/dashboard/home/tab_bar/credentials/credential_qr/view/credential_qr_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/credential_qr/view/credential_qr_page.dart @@ -44,7 +44,7 @@ class CredentialQrPage extends StatelessWidget { child: QrImageView( data: data, size: 200, - foregroundColor: Theme.of(context).colorScheme.onBackground, + foregroundColor: Theme.of(context).colorScheme.onSurface, ), ), const SizedBox(height: 10), diff --git a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_active_status.dart b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_active_status.dart index 640830178..ac5950d4e 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_active_status.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_active_status.dart @@ -23,7 +23,7 @@ class CredentialActiveStatus extends StatelessWidget { .textTheme .credentialFieldDescription .copyWith( - color: Theme.of(context).colorScheme.valueColor, + color: Theme.of(context).colorScheme.onSurface, ), ), const SizedBox(width: 5), diff --git a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart index e7e50e0ff..4a0de54f2 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/widgets/credential_subject_data.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/lang/cubit/lang_cubit.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:json_path/json_path.dart'; @@ -122,8 +121,8 @@ class CredentialSubjectData extends StatelessWidget { padding: const EdgeInsets.only(top: 10), title: title, value: data, - titleColor: Theme.of(context).colorScheme.titleColor, - valueColor: Theme.of(context).colorScheme.valueColor, + titleColor: Theme.of(context).colorScheme.onSurface, + valueColor: Theme.of(context).colorScheme.onSurface, showVertically: showVertically, ); }).toList(), diff --git a/lib/dashboard/home/tab_bar/credentials/detail/widgets/deferred_credential_data.dart b/lib/dashboard/home/tab_bar/credentials/detail/widgets/deferred_credential_data.dart index ec4ad95ca..f0c832520 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/widgets/deferred_credential_data.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/widgets/deferred_credential_data.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class DeferredCredentialData extends StatelessWidget { @@ -25,8 +24,8 @@ class DeferredCredentialData extends StatelessWidget { padding: const EdgeInsets.only(top: 10), title: l10n.issuer, value: credentialModel.pendingInfo!.issuer ?? '', - titleColor: Theme.of(context).colorScheme.titleColor, - valueColor: Theme.of(context).colorScheme.valueColor, + titleColor: Theme.of(context).colorScheme.onSurface, + valueColor: Theme.of(context).colorScheme.onSurface, showVertically: showVertically, ), CredentialField( @@ -35,8 +34,8 @@ class DeferredCredentialData extends StatelessWidget { value: UiDate.formatDate( credentialModel.pendingInfo!.requestedAt, ), - titleColor: Theme.of(context).colorScheme.titleColor, - valueColor: Theme.of(context).colorScheme.valueColor, + titleColor: Theme.of(context).colorScheme.onSurface, + valueColor: Theme.of(context).colorScheme.onSurface, showVertically: showVertically, ), ], diff --git a/lib/dashboard/home/tab_bar/credentials/detail/widgets/developer_details.dart b/lib/dashboard/home/tab_bar/credentials/detail/widgets/developer_details.dart index 5ef973db8..6c054deb2 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/widgets/developer_details.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/widgets/developer_details.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class DeveloperDetails extends StatelessWidget { @@ -27,8 +26,8 @@ class DeveloperDetails extends StatelessWidget { credentialModel.credentialPreview.credentialSubjectModel.id ?? ''; final String type = credentialModel.credentialPreview.type.toString(); - final titleColor = Theme.of(context).colorScheme.titleColor; - final valueColor = Theme.of(context).colorScheme.valueColor; + final titleColor = Theme.of(context).colorScheme.onSurface; + final valueColor = Theme.of(context).colorScheme.onSurface; return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/credentials/linkedin_credential/get_linkedin_info/view/get_linkedin_info_page.dart b/lib/dashboard/home/tab_bar/credentials/linkedin_credential/get_linkedin_info/view/get_linkedin_info_page.dart index 71a5a42ac..be65314e8 100644 --- a/lib/dashboard/home/tab_bar/credentials/linkedin_credential/get_linkedin_info/view/get_linkedin_info_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/linkedin_credential/get_linkedin_info/view/get_linkedin_info_page.dart @@ -112,7 +112,7 @@ class _GetLinkedinInfoViewState extends State { margin: const EdgeInsets.all(Sizes.spaceNormal), decoration: BoxDecoration( shape: BoxShape.circle, - color: Theme.of(context).colorScheme.checkMarkColor, + color: Theme.of(context).colorScheme.onTertiary, ), child: const Icon( Icons.check, diff --git a/lib/dashboard/home/tab_bar/credentials/list/view/home_credentials_list_page.dart b/lib/dashboard/home/tab_bar/credentials/list/view/home_credentials_list_page.dart index 7a32e9867..3c321267f 100644 --- a/lib/dashboard/home/tab_bar/credentials/list/view/home_credentials_list_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/list/view/home_credentials_list_page.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/credentials/cubit/credentials_cubit.dart'; import 'package:altme/dashboard/dashboard.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'; @@ -43,7 +42,7 @@ class _HomeCredentialsListPageState extends State return BasePage( scrollView: false, padding: EdgeInsets.zero, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, body: BlocListener( listenWhen: (previous, current) { if (current.model.profileSetting.selfSovereignIdentityOptions diff --git a/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_detail_tab_bar.dart b/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_detail_tab_bar.dart index c7e963a23..91d3d63a6 100644 --- a/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_detail_tab_bar.dart +++ b/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_detail_tab_bar.dart @@ -39,7 +39,7 @@ class CredentialDetailTabbar extends StatelessWidget { ), decoration: isSelected ? BoxDecoration( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), borderRadius: const BorderRadius.only( topLeft: Radius.circular(Sizes.smallRadius), topRight: Radius.circular(Sizes.smallRadius), diff --git a/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_item_shimmer.dart b/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_item_shimmer.dart index 062095cc0..bdef1c8a7 100644 --- a/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_item_shimmer.dart +++ b/lib/dashboard/home/tab_bar/credentials/list/widgets/credential_item_shimmer.dart @@ -7,7 +7,7 @@ class CredentialItemShimmer extends StatelessWidget { @override Widget build(BuildContext context) { return BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: EdgeInsets.zero, child: const Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_credential_offer/view/polygon_id_credential_offer_view.dart b/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_credential_offer/view/polygon_id_credential_offer_view.dart index 25e04a74b..0f5d28bd5 100644 --- a/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_credential_offer/view/polygon_id_credential_offer_view.dart +++ b/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_credential_offer/view/polygon_id_credential_offer_view.dart @@ -35,7 +35,7 @@ class PolygonIdCredentialOfferPage extends StatelessWidget { l10n.wouldYouLikeToAcceptThisCredentialsFromThisOrganisation, textAlign: TextAlign.center, style: Theme.of(context).textTheme.credentialSubtitle.copyWith( - color: Theme.of(context).colorScheme.lightPurple, + color: Theme.of(context).colorScheme.secondary, ), ), const SizedBox(height: 30), diff --git a/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_verification/view/polygon_id_verification_view.dart b/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_verification/view/polygon_id_verification_view.dart index 083253df6..986e2a951 100644 --- a/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_verification/view/polygon_id_verification_view.dart +++ b/lib/dashboard/home/tab_bar/credentials/polygon_id/polygon_id_verification/view/polygon_id_verification_view.dart @@ -97,7 +97,7 @@ class _PolygonIdVerificationViewState extends State { textAlign: TextAlign.center, style: Theme.of(context).textTheme.credentialSubtitle.copyWith( - color: Theme.of(context).colorScheme.lightPurple, + color: Theme.of(context).colorScheme.secondary, ), ), const SizedBox(height: 10), diff --git a/lib/dashboard/home/tab_bar/credentials/receive/view/credentials_receive_page.dart b/lib/dashboard/home/tab_bar/credentials/receive/view/credentials_receive_page.dart index 28886e0e1..e891fe023 100644 --- a/lib/dashboard/home/tab_bar/credentials/receive/view/credentials_receive_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/receive/view/credentials_receive_page.dart @@ -60,7 +60,7 @@ class _CredentialsReceivePageState extends State { final outputDescriptors = credentialModel.credentialManifest?.outputDescriptors; - final textColor = Theme.of(context).colorScheme.valueColor; + final textColor = Theme.of(context).colorScheme.onSurface; final profileSetting = context.read().state.model.profileSetting; diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/activity_widget.dart b/lib/dashboard/home/tab_bar/credentials/widgets/activity_widget.dart index 10e5c3126..fdd297ff2 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/activity_widget.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/activity_widget.dart @@ -17,8 +17,8 @@ class ActivityWidget extends StatelessWidget { @override Widget build(BuildContext context) { final l10n = context.l10n; - final titleColor = Theme.of(context).colorScheme.titleColor; - final valueColor = Theme.of(context).colorScheme.valueColor; + final titleColor = Theme.of(context).colorScheme.onSurface; + final valueColor = Theme.of(context).colorScheme.onSurface; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -74,7 +74,7 @@ class ActivityWidget extends StatelessWidget { ), const SizedBox(height: 5), ], - Divider(color: Theme.of(context).colorScheme.surfaceContainer), + Divider(color: Theme.of(context).colorScheme.surface.withOpacity(0.07)), ], ); } diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_background.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_background.dart index b82fa189c..8fe9e2754 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_background.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_background.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class CredentialBackground extends StatelessWidget { @@ -28,7 +27,7 @@ class CredentialBackground extends StatelessWidget { credentialModel.credentialPreview.credentialSubjectModel .credentialSubjectType .backgroundColor(credentialModel), - shapeColor: Theme.of(context).colorScheme.documentShape, + shapeColor: Theme.of(context).colorScheme.primary.withOpacity(0.05), value: 0, shapeSize: 256, anchors: showBgDecoration diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_container.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_container.dart index eadf15399..b862c09dd 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_container.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_container.dart @@ -1,5 +1,4 @@ import 'package:altme/app/shared/constants/sizes.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class CredentialContainer extends StatelessWidget { @@ -14,7 +13,7 @@ class CredentialContainer extends StatelessWidget { decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: Theme.of(context).colorScheme.documentShadow, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), blurRadius: 15, spreadRadius: 1, offset: const Offset(0, 4), diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_dynamic_detail.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_dynamic_detail.dart index bafbb9985..52e85c498 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_dynamic_detail.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_dynamic_detail.dart @@ -68,7 +68,7 @@ class CredentialDynamicDetial extends StatelessWidget { (format == AltMeStrings.uri || format == AltMeStrings.email)) ? valueTheme.copyWith( - color: Theme.of(context).colorScheme.markDownA, + color: Theme.of(context).colorScheme.primary, ) : valueTheme, recognizer: TapGestureRecognizer() @@ -90,7 +90,7 @@ class CredentialDynamicDetial extends StatelessWidget { }, child: ImageIcon( const AssetImage(IconStrings.link), - color: Theme.of(context).colorScheme.markDownA, + color: Theme.of(context).colorScheme.primary, size: 17, ), ), diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_card.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_card.dart index c1b17928b..5f8129783 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_card.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_card.dart @@ -47,7 +47,7 @@ class CredentialManifestCard extends StatelessWidget { ], ) : null, - shapeColor: Theme.of(context).colorScheme.documentShape, + shapeColor: Theme.of(context).colorScheme.primary.withOpacity(0.05), value: 1, anchors: showBgDecoration ? const [Alignment.bottomRight] diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_details.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_details.dart index 3d0c324d6..b36ef5ec4 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_details.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/credential_manifest_details.dart @@ -1,6 +1,5 @@ import 'package:altme/dashboard/dashboard.dart'; -import 'package:altme/theme/theme.dart'; import 'package:credential_manifest/credential_manifest.dart'; import 'package:flutter/material.dart'; @@ -16,8 +15,8 @@ class CredentialManifestDetails extends StatelessWidget { @override Widget build(BuildContext context) { - final titleColor = Theme.of(context).colorScheme.titleColor; - final valueColor = Theme.of(context).colorScheme.valueColor; + final titleColor = Theme.of(context).colorScheme.onSurface; + final valueColor = Theme.of(context).colorScheme.onSurface; return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/expansiontile_container.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/expansiontile_container.dart index 9278d05d8..012e63e25 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/expansiontile_container.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_manifest_widgets/expansiontile_container.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class ExpansionTileContainer extends StatelessWidget { @@ -13,15 +12,15 @@ class ExpansionTileContainer extends StatelessWidget { @override Widget build(BuildContext context) { return BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.symmetric(horizontal: 8), margin: const EdgeInsets.only(bottom: 8), child: Theme( data: Theme.of(context).copyWith( unselectedWidgetColor: Theme.of(context).colorScheme.onPrimary, - dividerColor: Theme.of(context).colorScheme.surfaceContainer, - splashColor: Theme.of(context).colorScheme.transparent, - highlightColor: Theme.of(context).colorScheme.transparent, + dividerColor: Theme.of(context).colorScheme.surface.withOpacity(0.07), + splashColor: Colors.transparent, + highlightColor: Colors.transparent, colorScheme: ColorScheme.dark( primary: Theme.of(context).colorScheme.onPrimary, ), diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/professional_experience_assessment_widget.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/professional_experience_assessment_widget.dart index b517b5274..6e2e3a2c0 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/professional_experience_assessment_widget.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/professional_experience_assessment_widget.dart @@ -98,7 +98,7 @@ class ProfessionalExperienceAssessmentWidget extends StatelessWidget { StarRating( starCount: 5, rating: double.parse(item.reviewRating.ratingValue), - color: Theme.of(context).colorScheme.star, + color: Theme.of(context).colorScheme.onErrorContainer, ), ], ), diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/resident_card_widget.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/resident_card_widget.dart index 4195ed1b2..50d1a8634 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/resident_card_widget.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/resident_card_widget.dart @@ -104,14 +104,14 @@ class GenderDisplay extends StatelessWidget { switch (residentCardModel.gender) { case 'male': genderIcon = - Icon(Icons.male, color: Theme.of(context).colorScheme.genderIcon); + Icon(Icons.male, color: Theme.of(context).colorScheme.onSurface); case 'female': genderIcon = - Icon(Icons.female, color: Theme.of(context).colorScheme.genderIcon); + Icon(Icons.female, color: Theme.of(context).colorScheme.onSurface); default: genderIcon = Icon( Icons.transgender, - color: Theme.of(context).colorScheme.genderIcon, + color: Theme.of(context).colorScheme.onSurface, ); } return genderIcon; diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/wallet_credential_widget.dart b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/wallet_credential_widget.dart index 6d902fde1..c3df1bde2 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/wallet_credential_widget.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/credential_widget/wallet_credential_widget.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -40,8 +39,8 @@ class WalletCredentialetailsWidget extends StatelessWidget { @override Widget build(BuildContext context) { final l10n = context.l10n; - final titleColor = Theme.of(context).colorScheme.titleColor; - final valueColor = Theme.of(context).colorScheme.valueColor; + final titleColor = Theme.of(context).colorScheme.onSurface; + final valueColor = Theme.of(context).colorScheme.onSurface; final isDeveloperMode = context.read().state.model.isDeveloperMode; diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/descriptioni_dialog.dart b/lib/dashboard/home/tab_bar/credentials/widgets/descriptioni_dialog.dart index f2e0acf9e..5aee2e202 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/descriptioni_dialog.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/descriptioni_dialog.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class DescriptionDialog extends StatelessWidget { @@ -15,7 +14,7 @@ class DescriptionDialog extends StatelessWidget { Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; - final background = Theme.of(context).colorScheme.popupBackground; + final background = Theme.of(context).colorScheme.surface; return AlertDialog( backgroundColor: background, diff --git a/lib/dashboard/home/tab_bar/credentials/widgets/display_wiget.dart b/lib/dashboard/home/tab_bar/credentials/widgets/display_wiget.dart index 5c87be341..2e8af2c82 100644 --- a/lib/dashboard/home/tab_bar/credentials/widgets/display_wiget.dart +++ b/lib/dashboard/home/tab_bar/credentials/widgets/display_wiget.dart @@ -14,8 +14,8 @@ class DisplayWidget extends StatelessWidget { @override Widget build(BuildContext context) { - final titleColor = Theme.of(context).colorScheme.titleColor; - final valueColor = Theme.of(context).colorScheme.valueColor; + final titleColor = Theme.of(context).colorScheme.onSurface; + final valueColor = Theme.of(context).colorScheme.onSurface; final textTheme = Theme.of(context).textTheme; final titleTheme = diff --git a/lib/dashboard/home/tab_bar/nft/view/nft_page.dart b/lib/dashboard/home/tab_bar/nft/view/nft_page.dart index 5482aab15..da4540aec 100644 --- a/lib/dashboard/home/tab_bar/nft/view/nft_page.dart +++ b/lib/dashboard/home/tab_bar/nft/view/nft_page.dart @@ -49,7 +49,7 @@ class _NftViewState extends State { return BasePage( scrollView: false, padding: EdgeInsets.zero, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, body: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/nft/widgets/nft_item.dart b/lib/dashboard/home/tab_bar/nft/widgets/nft_item.dart index a2f61582b..fffb811ea 100644 --- a/lib/dashboard/home/tab_bar/nft/widgets/nft_item.dart +++ b/lib/dashboard/home/tab_bar/nft/widgets/nft_item.dart @@ -24,7 +24,7 @@ class NftItem extends StatelessWidget { return InkWell( onTap: onClick, child: BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/nft/widgets/nft_item_shimmer.dart b/lib/dashboard/home/tab_bar/nft/widgets/nft_item_shimmer.dart index 6de4e9217..dd913f34f 100644 --- a/lib/dashboard/home/tab_bar/nft/widgets/nft_item_shimmer.dart +++ b/lib/dashboard/home/tab_bar/nft/widgets/nft_item_shimmer.dart @@ -7,7 +7,7 @@ class NftItemShimmer extends StatelessWidget { @override Widget build(BuildContext context) { return BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.all(10), child: const Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/nft/widgets/nft_url_widget.dart b/lib/dashboard/home/tab_bar/nft/widgets/nft_url_widget.dart index 02fcdbb94..d433c3dbc 100644 --- a/lib/dashboard/home/tab_bar/nft/widgets/nft_url_widget.dart +++ b/lib/dashboard/home/tab_bar/nft/widgets/nft_url_widget.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class NftUrlWidget extends StatelessWidget { @@ -32,7 +31,7 @@ class NftUrlWidget extends StatelessWidget { end: Alignment.topRight, stops: const [0.3, 1.0], ), - color: Theme.of(context).colorScheme.tabBarNotSelected, + color: Theme.of(context).colorScheme.secondaryContainer, ), child: Center( child: Text( diff --git a/lib/dashboard/home/tab_bar/tab_controller/widgets/tab_bar.dart b/lib/dashboard/home/tab_bar/tab_controller/widgets/tab_bar.dart index 3e64add61..b72a8850e 100644 --- a/lib/dashboard/home/tab_bar/tab_controller/widgets/tab_bar.dart +++ b/lib/dashboard/home/tab_bar/tab_controller/widgets/tab_bar.dart @@ -28,22 +28,21 @@ class MyTab extends StatelessWidget { vertical: Sizes.spaceSmall, ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(Sizes.normalRadius), - gradient: isSelected - ? LinearGradient( - colors: [ - AppTheme.darkThemeData.colorScheme.primary, - AppTheme.darkThemeData.colorScheme.secondary, - ], - begin: Alignment.bottomLeft, - end: Alignment.topRight, - stops: const [0.3, 1.0], - ) - : null, - color: isSelected - ? null - : AppTheme.darkThemeData.colorScheme.tabBarNotSelected, - ), + borderRadius: BorderRadius.circular(Sizes.normalRadius), + gradient: isSelected + ? LinearGradient( + colors: [ + AppTheme.darkThemeData.colorScheme.primary, + AppTheme.darkThemeData.colorScheme.secondary, + ], + begin: Alignment.bottomLeft, + end: Alignment.topRight, + stops: const [0.3, 1.0], + ) + : null, + color: isSelected + ? null + : AppTheme.darkThemeData.colorScheme.tertiary), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/dashboard/home/tab_bar/tokens/all_tokens/view/all_tokens_page.dart b/lib/dashboard/home/tab_bar/tokens/all_tokens/view/all_tokens_page.dart index 4b5b723f0..ebf9cb1e8 100644 --- a/lib/dashboard/home/tab_bar/tokens/all_tokens/view/all_tokens_page.dart +++ b/lib/dashboard/home/tab_bar/tokens/all_tokens/view/all_tokens_page.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -130,7 +129,10 @@ class _AllTokensViewState extends State<_AllTokensView> { separatorBuilder: (_, __) { return Divider( height: 0.3, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ); }, itemCount: state.filteredContracts.length, diff --git a/lib/dashboard/home/tab_bar/tokens/all_tokens/widgets/token_contract_item.dart b/lib/dashboard/home/tab_bar/tokens/all_tokens/widgets/token_contract_item.dart index 9f490f183..85ed5df9f 100644 --- a/lib/dashboard/home/tab_bar/tokens/all_tokens/widgets/token_contract_item.dart +++ b/lib/dashboard/home/tab_bar/tokens/all_tokens/widgets/token_contract_item.dart @@ -44,7 +44,7 @@ class TokenContractItem extends StatelessWidget { trailing: Switcher( size: SwitcherSize.small, colorOn: Theme.of(context).colorScheme.primary, - colorOff: Theme.of(context).colorScheme.cardBackground, + colorOff: Theme.of(context).colorScheme.surface, onChanged: onChange, value: isOn, ), diff --git a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/view/confirm_token_transaction_page.dart b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/view/confirm_token_transaction_page.dart index 095b91daa..6480c43bd 100644 --- a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/view/confirm_token_transaction_page.dart +++ b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/view/confirm_token_transaction_page.dart @@ -192,7 +192,7 @@ class _ConfirmWithdrawalViewState extends State { const FromAccountWidget(isEnabled: false), const SizedBox(height: Sizes.spaceNormal), BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: SizedBox( width: double.infinity, child: Column( diff --git a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/confirm_transaction_details_card.dart b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/confirm_transaction_details_card.dart index be508ceb1..cda514201 100644 --- a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/confirm_transaction_details_card.dart +++ b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/confirm_transaction_details_card.dart @@ -31,7 +31,7 @@ class ConfirmTransactionDetailsCard extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -137,7 +137,7 @@ class ConfirmTransactionDetailsCard extends StatelessWidget { ), child: Divider( height: 0.1, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), ), ); } diff --git a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/transaction_done_dialog.dart b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/transaction_done_dialog.dart index d721c40c7..042b67ead 100644 --- a/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/transaction_done_dialog.dart +++ b/lib/dashboard/home/tab_bar/tokens/confirm_token_transaction/widgets/transaction_done_dialog.dart @@ -40,7 +40,7 @@ class TransactionDoneDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric( horizontal: Sizes.spaceNormal, diff --git a/lib/dashboard/home/tab_bar/tokens/insert_withdrawal_amount/widgets/token_select_box.dart b/lib/dashboard/home/tab_bar/tokens/insert_withdrawal_amount/widgets/token_select_box.dart index 6a91436a0..d057c68a0 100644 --- a/lib/dashboard/home/tab_bar/tokens/insert_withdrawal_amount/widgets/token_select_box.dart +++ b/lib/dashboard/home/tab_bar/tokens/insert_withdrawal_amount/widgets/token_select_box.dart @@ -82,7 +82,7 @@ class _TokenSelectBoxItem extends StatelessWidget { } }, child: BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.min, @@ -145,7 +145,10 @@ class _TokenSelectBoxItem extends StatelessWidget { .decimalNumber(2) .formatNumber, style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: Theme.of(context).colorScheme.greyText, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), ), ), ], diff --git a/lib/dashboard/home/tab_bar/tokens/receive/view/receive_page.dart b/lib/dashboard/home/tab_bar/tokens/receive/view/receive_page.dart index cc3ef7188..16fbf1b05 100644 --- a/lib/dashboard/home/tab_bar/tokens/receive/view/receive_page.dart +++ b/lib/dashboard/home/tab_bar/tokens/receive/view/receive_page.dart @@ -60,7 +60,7 @@ class ReceivePage extends StatelessWidget { ), BackgroundCard( padding: const EdgeInsets.all(Sizes.spaceNormal), - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: Column( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/change_network_bottom_sheet.dart b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/change_network_bottom_sheet.dart index 2a5027334..85560587d 100644 --- a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/change_network_bottom_sheet.dart +++ b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/change_network_bottom_sheet.dart @@ -87,7 +87,8 @@ class _ChangeNetworkBottomSheetPageState border: Border.all( color: Theme.of(context) .colorScheme - .accountBottomSheetBorder, + .onSurface + .withOpacity(0.12), width: 0.2, ), borderRadius: const BorderRadius.all( @@ -108,7 +109,10 @@ class _ChangeNetworkBottomSheetPageState ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ), diff --git a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/network_switcher_button.dart b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/network_switcher_button.dart index d3ee84189..2e40afb86 100644 --- a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/network_switcher_button.dart +++ b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/network_switcher_button.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/drawer/drawer.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -20,7 +19,7 @@ class NetworkSwitcherButton extends StatelessWidget { width: 6, height: 6, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.activeColorOfNetwork, + color: Theme.of(context).colorScheme.primary, shape: BoxShape.circle, ), ), diff --git a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/recent_transactions.dart b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/recent_transactions.dart index cb7220635..03cbdbc87 100644 --- a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/recent_transactions.dart +++ b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/recent_transactions.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -26,7 +25,7 @@ class RecentTransactions extends StatelessWidget { final l10n = context.l10n; return Expanded( child: BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, margin: const EdgeInsets.all(Sizes.spaceSmall), padding: const EdgeInsets.all(Sizes.spaceSmall), child: Column( @@ -66,7 +65,10 @@ class RecentTransactions extends StatelessWidget { ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ); }, diff --git a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/transaction_item.dart b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/transaction_item.dart index 2c9dd5511..c569c6727 100644 --- a/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/transaction_item.dart +++ b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/transaction_item.dart @@ -103,15 +103,15 @@ class TransactionItem extends StatelessWidget { operationModel.status, style: Theme.of(context).textTheme.titleSmall?.copyWith( color: operationModel.status.toLowerCase() == 'applied' - ? Theme.of(context).colorScheme.transactionApplied + ? Theme.of(context).colorScheme.onTertiary : operationModel.status.toLowerCase() == 'failed' || operationModel.status.toLowerCase() == 'backtracked' - ? Theme.of(context).colorScheme.transactionFailed + ? Theme.of(context).colorScheme.error : operationModel.status.toLowerCase() == 'skipped' ? Theme.of(context) .colorScheme - .transactionSkipped + .error : null, ), ), diff --git a/lib/dashboard/home/tab_bar/tokens/token_page/view/token_page.dart b/lib/dashboard/home/tab_bar/tokens/token_page/view/token_page.dart index 0967105f0..188549a20 100644 --- a/lib/dashboard/home/tab_bar/tokens/token_page/view/token_page.dart +++ b/lib/dashboard/home/tab_bar/tokens/token_page/view/token_page.dart @@ -80,7 +80,7 @@ class _TokensViewState extends State { child: BasePage( scrollView: false, padding: EdgeInsets.zero, - backgroundColor: Theme.of(context).colorScheme.transparent, + backgroundColor: Colors.transparent, body: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item.dart b/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item.dart index b99e19308..8e1e517c6 100644 --- a/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item.dart +++ b/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item.dart @@ -18,7 +18,7 @@ class TokenItem extends StatelessWidget { return Padding( padding: const EdgeInsets.only(bottom: 10), child: BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.symmetric(horizontal: 10), child: ListTile( contentPadding: EdgeInsets.zero, diff --git a/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item_shimmer.dart b/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item_shimmer.dart index 1b28cbe4b..43755fe51 100644 --- a/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item_shimmer.dart +++ b/lib/dashboard/home/tab_bar/tokens/token_page/widgets/token_item_shimmer.dart @@ -9,7 +9,7 @@ class TokenItemShimmer extends StatelessWidget { return Padding( padding: const EdgeInsets.only(bottom: 10), child: BackgroundCard( - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), padding: const EdgeInsets.symmetric(horizontal: 10), child: const ListTile( minVerticalPadding: 0, diff --git a/lib/dashboard/home/tab_bar/tokens/widgets/account_select_box_view.dart b/lib/dashboard/home/tab_bar/tokens/widgets/account_select_box_view.dart index 319ef909b..419cbf144 100644 --- a/lib/dashboard/home/tab_bar/tokens/widgets/account_select_box_view.dart +++ b/lib/dashboard/home/tab_bar/tokens/widgets/account_select_box_view.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; -import 'package:altme/theme/theme.dart'; import 'package:altme/wallet/wallet.dart'; import 'package:flutter/material.dart'; @@ -25,7 +24,7 @@ class AccountSelectBoxView extends StatelessWidget { @override Widget build(BuildContext context) { return BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -41,9 +40,9 @@ class AccountSelectBoxView extends StatelessWidget { Theme( data: Theme.of(context).copyWith( unselectedWidgetColor: Theme.of(context).colorScheme.onPrimary, - dividerColor: Theme.of(context).colorScheme.cardBackground, - splashColor: Theme.of(context).colorScheme.transparent, - highlightColor: Theme.of(context).colorScheme.transparent, + dividerColor: Theme.of(context).colorScheme.surface, + splashColor: Colors.transparent, + highlightColor: Colors.transparent, colorScheme: ColorScheme.dark( primary: Theme.of(context).colorScheme.onPrimary, ), @@ -79,7 +78,10 @@ class AccountSelectBoxView extends StatelessWidget { ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ), 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/home/tab_bar/tokens/widgets/withdrawal_address_input.dart b/lib/dashboard/home/tab_bar/tokens/widgets/withdrawal_address_input.dart index 8957727ea..ce0bfee14 100644 --- a/lib/dashboard/home/tab_bar/tokens/widgets/withdrawal_address_input.dart +++ b/lib/dashboard/home/tab_bar/tokens/widgets/withdrawal_address_input.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -74,7 +73,7 @@ class _WithdrawalAddressInputPageState Widget build(BuildContext context) { final l10n = context.l10n; return BackgroundCard( - color: Theme.of(context).colorScheme.cardBackground, + color: Theme.of(context).colorScheme.surface, padding: const EdgeInsets.only( top: Sizes.spaceSmall, right: Sizes.spaceSmall, 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/qr_code/qr_display/view/qr_display_page.dart b/lib/dashboard/qr_code/qr_display/view/qr_display_page.dart index b4ce1fbf8..897a58b03 100644 --- a/lib/dashboard/qr_code/qr_display/view/qr_display_page.dart +++ b/lib/dashboard/qr_code/qr_display/view/qr_display_page.dart @@ -36,7 +36,7 @@ class QrCodeDisplayPage extends StatelessWidget { child: QrImageView( data: data, size: 200, - foregroundColor: Theme.of(context).colorScheme.onBackground, + foregroundColor: Theme.of(context).colorScheme.onSurface, ), ), const SizedBox(height: 10), diff --git a/lib/dashboard/qr_code/widget/developer_mode_dialog.dart b/lib/dashboard/qr_code/widget/developer_mode_dialog.dart index bdc1824c8..0ecc508f8 100644 --- a/lib/dashboard/qr_code/widget/developer_mode_dialog.dart +++ b/lib/dashboard/qr_code/widget/developer_mode_dialog.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class DeveloperModeDialog extends StatelessWidget { @@ -18,8 +17,8 @@ class DeveloperModeDialog extends StatelessWidget { @override Widget build(BuildContext context) { final color = Theme.of(context).colorScheme.primary; - final background = Theme.of(context).colorScheme.popupBackground; - final textColor = Theme.of(context).colorScheme.dialogText; + final background = Theme.of(context).colorScheme.surface; + final textColor = Theme.of(context).colorScheme.onSurface; final l10n = context.l10n; return AlertDialog( diff --git a/lib/dashboard/search/widgets/search_item_shimmer.dart b/lib/dashboard/search/widgets/search_item_shimmer.dart index 93855cadc..2135e6db2 100644 --- a/lib/dashboard/search/widgets/search_item_shimmer.dart +++ b/lib/dashboard/search/widgets/search_item_shimmer.dart @@ -10,7 +10,7 @@ class SearchItemShimmer extends StatelessWidget { padding: const EdgeInsets.only(bottom: 10), child: BackgroundCard( padding: EdgeInsets.zero, - color: Theme.of(context).colorScheme.surfaceContainer, + color: Theme.of(context).colorScheme.surface.withOpacity(0.07), child: const AspectRatio( aspectRatio: Sizes.credentialAspectRatio, child: ShimmerWidget.rectangular( diff --git a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_bottom_sheet.dart b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_bottom_sheet.dart index 3feeb8a26..c1b167db5 100644 --- a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_bottom_sheet.dart +++ b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_bottom_sheet.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -114,7 +113,10 @@ class _SelectNetworkFeeBottomSheetViewState ), child: Divider( height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + color: Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.12), ), ), ); 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/dashboard/src/widgets/bottom_bar_item.dart b/lib/dashboard/src/widgets/bottom_bar_item.dart index f833bff30..e6345ed3e 100644 --- a/lib/dashboard/src/widgets/bottom_bar_item.dart +++ b/lib/dashboard/src/widgets/bottom_bar_item.dart @@ -41,7 +41,10 @@ class BottomBarItem extends StatelessWidget { AssetImage(icon), color: isSelected ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.unSelectedLabel, + : Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), size: 20, ), ), @@ -53,7 +56,10 @@ class BottomBarItem extends StatelessWidget { style: Theme.of(context).textTheme.bottomBar.copyWith( color: isSelected ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.unSelectedLabel, + : Theme.of(context) + .colorScheme + .onSurface + .withOpacity(0.6), ), ), ], diff --git a/lib/dashboard/src/widgets/home_title_leading.dart b/lib/dashboard/src/widgets/home_title_leading.dart index d0a81c7b8..15f71dd49 100644 --- a/lib/dashboard/src/widgets/home_title_leading.dart +++ b/lib/dashboard/src/widgets/home_title_leading.dart @@ -1,5 +1,4 @@ import 'package:altme/app/app.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class HomeTitleLeading extends StatelessWidget { @@ -15,7 +14,7 @@ class HomeTitleLeading extends StatelessWidget { return IconButton( icon: ImageIcon( const AssetImage(IconStrings.settings), - color: Theme.of(context).colorScheme.leadingButton, + color: Theme.of(context).colorScheme.onSurface, ), onPressed: onPressed, ); diff --git a/lib/dashboard/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index fd119ac7a..5fc5a038d 100644 --- a/lib/dashboard/user_pin/view/user_pin_page.dart +++ b/lib/dashboard/user_pin/view/user_pin_page.dart @@ -37,8 +37,7 @@ class UserPinPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - PinCodeViewCubit(profileCubit: context.read()), + create: (context) => PinCodeViewCubit(), child: UserPinView( onCancel: onCancel, onProceed: onProceed, @@ -79,44 +78,35 @@ class _UserPinViewState extends State { @override Widget build(BuildContext context) { final l10n = context.l10n; - return BlocBuilder( - builder: (context, state) { - return WillPopScope( - onWillPop: () async => false, - child: BasePage( - backgroundColor: Theme.of(context).colorScheme.background, - scrollView: false, - body: PinCodeWidget( - title: widget.txCode?.description ?? - l10n.pleaseInsertTheSecredCodeReceived, - passwordEnteredCallback: _onPasscodeEntered, - passwordDigits: widget.txCode?.length ?? 4, - deleteButton: Text( - l10n.delete, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelButton: Text( - l10n.cancel, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelCallback: _onPasscodeCancelled, - isValidCallback: () { - Navigator.pop(context); - widget.onProceed.call(pinCodeValue!); - }, - shouldTriggerVerification: _verificationNotifier.stream, - ), + return WillPopScope( + onWillPop: () async => false, + child: BasePage( + backgroundColor: Theme.of(context).colorScheme.surface, + scrollView: false, + body: PinCodeWidget( + title: widget.txCode?.description ?? + l10n.pleaseInsertTheSecredCodeReceived, + passwordDigits: widget.txCode?.length ?? 4, + deleteButton: Text( + l10n.delete, + style: Theme.of(context).textTheme.labelLarge, ), - ); - }, + cancelButton: Text( + l10n.cancel, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelCallback: _onPasscodeCancelled, + isValidCallback: () { + Navigator.pop(context); + widget.onProceed + .call(context.read().state.enteredPasscode); + }, + isUserPin: true, + ), + ), ); } - Future _onPasscodeEntered(String enteredPasscode) async { - pinCodeValue = enteredPasscode; - _verificationNotifier.add(true); - } - void _onPasscodeCancelled() { Navigator.of(context).pop(); widget.onCancel.call(); diff --git a/lib/import_wallet/view/import_from_wallet_page.dart b/lib/import_wallet/view/import_from_wallet_page.dart index 018dd4863..5705352db 100644 --- a/lib/import_wallet/view/import_from_wallet_page.dart +++ b/lib/import_wallet/view/import_from_wallet_page.dart @@ -205,7 +205,7 @@ class _ImportFromOtherWalletViewState extends State { margin: const EdgeInsets.all(Sizes.spaceNormal), decoration: BoxDecoration( shape: BoxShape.circle, - color: Theme.of(context).colorScheme.checkMarkColor, + color: Theme.of(context).colorScheme.onTertiary, ), child: const Icon( Icons.check, diff --git a/lib/import_wallet/view/import_wallet_page.dart b/lib/import_wallet/view/import_wallet_page.dart index 4e5c1388e..026fa429a 100644 --- a/lib/import_wallet/view/import_wallet_page.dart +++ b/lib/import_wallet/view/import_wallet_page.dart @@ -198,7 +198,7 @@ class _ImportWalletViewState extends State { shape: BoxShape.circle, color: Theme.of(context) .colorScheme - .checkMarkColor, + .onTertiary, ), child: const Icon( Icons.check, diff --git a/lib/import_wallet/widgets/wallet_type_item.dart b/lib/import_wallet/widgets/wallet_type_item.dart index 8d387509a..312117bc7 100644 --- a/lib/import_wallet/widgets/wallet_type_item.dart +++ b/lib/import_wallet/widgets/wallet_type_item.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/import_wallet/import_wallet.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class WalletTypeItem extends StatelessWidget { @@ -20,7 +19,9 @@ class WalletTypeItem extends StatelessWidget { color: Theme.of(context).highlightColor, borderRadius: const BorderRadius.all(Radius.circular(Sizes.smallRadius)), - border: Border.all(color: Theme.of(context).colorScheme.borderColor), + border: Border.all( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12), + ), ), child: Row( mainAxisSize: MainAxisSize.max, diff --git a/lib/issuer_websites_page/widget/kyc_button.dart b/lib/issuer_websites_page/widget/kyc_button.dart index fdec566ec..e5705fc0e 100644 --- a/lib/issuer_websites_page/widget/kyc_button.dart +++ b/lib/issuer_websites_page/widget/kyc_button.dart @@ -1,6 +1,5 @@ import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; class KYCButton extends StatelessWidget { @@ -17,7 +16,7 @@ class KYCButton extends StatelessWidget { await showDialog( context: context, builder: (context) => AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.only( top: 24, diff --git a/lib/kyc_verification/widgets/finish_kyc_dialog.dart b/lib/kyc_verification/widgets/finish_kyc_dialog.dart index 8f440d34f..bb3ae58ee 100644 --- a/lib/kyc_verification/widgets/finish_kyc_dialog.dart +++ b/lib/kyc_verification/widgets/finish_kyc_dialog.dart @@ -12,7 +12,7 @@ class FinishKycDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), shape: const RoundedRectangleBorder( diff --git a/lib/kyc_verification/widgets/kyc_dialog.dart b/lib/kyc_verification/widgets/kyc_dialog.dart index f8685393c..4fbf63921 100644 --- a/lib/kyc_verification/widgets/kyc_dialog.dart +++ b/lib/kyc_verification/widgets/kyc_dialog.dart @@ -15,7 +15,7 @@ class KycDialog extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; return AlertDialog( - backgroundColor: Theme.of(context).colorScheme.popupBackground, + backgroundColor: Theme.of(context).colorScheme.surface, surfaceTintColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), shape: const RoundedRectangleBorder( @@ -91,7 +91,7 @@ class KycDialog extends StatelessWidget { verticalSpacing: 18, fontSize: 18, borderRadius: 20, - backgroundColor: Theme.of(context).colorScheme.kycVerifyButton, + backgroundColor: Theme.of(context).colorScheme.primary, onPressed: () { Navigator.of(context).pop(); startVerificationPressed.call(); @@ -108,7 +108,8 @@ class KycDialog extends StatelessWidget { Image.asset( IconStrings.lockCircle, width: Sizes.icon, - color: Theme.of(context).colorScheme.kycKeyIconColor, + color: + Theme.of(context).colorScheme.onSurface.withOpacity(0.6), ), Expanded( child: Text( diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index 978479f64..e6f2c67b9 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -1057,5 +1057,23 @@ "theWalletIsSuspended": "The wallet is suspended.", "clientTypeTitle": "Wallet Client_id Scheme", "confidentialClient": "Confidential Client", - "jwkThumbprintP256Key": "JWK Thumbprint P-256 Key" + "jwkThumbprintP256Key": "JWK Thumbprint P-256 Key", + "walletBlockedPopupTitle": "Blockerd 10 minutes", + "walletBlockedPopupDescription": "Too many failed attempts, your wallet is blocked for your security.\nYou can reset your wallet in order to use servives again.", + "deleteMyWalletForWrontPincodeTitle": "Account blocked after 3 unsuccessful attempts", + "deleteMyWalletForWrontPincodeDescription": "For your security you must reset you wallet to use our services again.", + "walletBloced": "Account blocked", + "deleteMyWallet": "Delete my account", + "pincodeRules": "Your secret code can't be a sequence or have 4 identical digit.", + "pincodeSerie": "You can't have 4 identical digits.", + "pincodeSequence": "You can't have a sequence of 4 digits.", + "pincodeDifferent": "Incorrect code.\nBoth codes are not the same.", + "codeSecretIncorrectDescription": "Be carreful, {count} attempt{plural} left.", + "@codeSecretIncorrectDescription": { + "description": "", + "placeholders": { + "count": {}, + "plural": {} + } + } } diff --git a/lib/l10n/untranslated.json b/lib/l10n/untranslated.json index ab3681128..f3ccf8ad7 100644 --- a/lib/l10n/untranslated.json +++ b/lib/l10n/untranslated.json @@ -3,14 +3,36 @@ "french", "spanish", "catalan", - "english" + "english", + "walletBlockedPopupTitle", + "walletBlockedPopupDescription", + "deleteMyWalletForWrontPincodeTitle", + "deleteMyWalletForWrontPincodeDescription", + "walletBloced", + "deleteMyWallet", + "pincodeRules", + "pincodeSerie", + "pincodeSequence", + "pincodeDifferent", + "codeSecretIncorrectDescription" ], "es": [ "french", "spanish", "catalan", - "english" + "english", + "walletBlockedPopupTitle", + "walletBlockedPopupDescription", + "deleteMyWalletForWrontPincodeTitle", + "deleteMyWalletForWrontPincodeDescription", + "walletBloced", + "deleteMyWallet", + "pincodeRules", + "pincodeSerie", + "pincodeSequence", + "pincodeDifferent", + "codeSecretIncorrectDescription" ], "fr": [ @@ -30,6 +52,17 @@ "theWalletIsSuspended", "clientTypeTitle", "confidentialClient", - "jwkThumbprintP256Key" + "jwkThumbprintP256Key", + "walletBlockedPopupTitle", + "walletBlockedPopupDescription", + "deleteMyWalletForWrontPincodeTitle", + "deleteMyWalletForWrontPincodeDescription", + "walletBloced", + "deleteMyWallet", + "pincodeRules", + "pincodeSerie", + "pincodeSequence", + "pincodeDifferent", + "codeSecretIncorrectDescription" ] } diff --git a/lib/onboarding/activate_biometircs/widgets/biometrics_switch.dart b/lib/onboarding/activate_biometircs/widgets/biometrics_switch.dart index f282640c1..8b94393c4 100644 --- a/lib/onboarding/activate_biometircs/widgets/biometrics_switch.dart +++ b/lib/onboarding/activate_biometircs/widgets/biometrics_switch.dart @@ -18,7 +18,7 @@ class BiometricsSwitch extends StatelessWidget { final l10n = context.l10n; return BackgroundCard( padding: const EdgeInsets.all(Sizes.spaceSmall), - color: Theme.of(context).colorScheme.cardHighlighted, + color: Theme.of(context).colorScheme.surface, child: Row( children: [ Image.asset( diff --git a/lib/onboarding/gen_phrase/view/onboarding_gen_phrase.dart b/lib/onboarding/gen_phrase/view/onboarding_gen_phrase.dart index 00c63dff9..0ac0844e5 100644 --- a/lib/onboarding/gen_phrase/view/onboarding_gen_phrase.dart +++ b/lib/onboarding/gen_phrase/view/onboarding_gen_phrase.dart @@ -157,7 +157,7 @@ class _OnBoardingGenPhraseViewState extends State { MyElevatedButton( text: l10n.verifyLater, verticalSpacing: 18, - backgroundColor: Theme.of(context).colorScheme.blueColor, + backgroundColor: Theme.of(context).colorScheme.surface, onPressed: () async { await context .read() diff --git a/lib/onboarding/protect_wallet/view/protect_wallet_page.dart b/lib/onboarding/protect_wallet/view/protect_wallet_page.dart index 3d6d5df8c..1417b60e8 100644 --- a/lib/onboarding/protect_wallet/view/protect_wallet_page.dart +++ b/lib/onboarding/protect_wallet/view/protect_wallet_page.dart @@ -45,11 +45,15 @@ class ProtectWalletPage extends StatelessWidget { altmeChatSupportCubit: context.read(), profileCubit: context.read(), ), - child: ProtectWalletView( - routeType: routeType, - profileCubit: context.read(), - onBoardingGenPhraseCubit: context.read(), - onboardingCubit: context.read(), + child: Builder( + builder: (context) { + return ProtectWalletView( + routeType: routeType, + profileCubit: context.read(), + onBoardingGenPhraseCubit: context.read(), + onboardingCubit: context.read(), + ); + }, ), ); } @@ -129,7 +133,7 @@ class _ProtectWalletViewState extends State { useSafeArea: true, padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceXSmall), titleLeading: const BackLeadingButton(), - backgroundColor: Theme.of(context).colorScheme.drawerBackground, + backgroundColor: Theme.of(context).colorScheme.surface, title: l10n.protectYourWallet, titleAlignment: Alignment.topCenter, body: BlocBuilder( diff --git a/lib/onboarding/starter/view/starter_page.dart b/lib/onboarding/starter/view/starter_page.dart index e3e3d1634..b60ec9c04 100644 --- a/lib/onboarding/starter/view/starter_page.dart +++ b/lib/onboarding/starter/view/starter_page.dart @@ -3,7 +3,6 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/onboarding/onboarding.dart'; import 'package:altme/splash/splash.dart'; -import 'package:altme/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -45,8 +44,8 @@ class StarterView extends StatelessWidget { decoration: BoxDecoration( gradient: LinearGradient( colors: [ - Theme.of(context).colorScheme.darkGradientStartColor, - Theme.of(context).colorScheme.darkGradientEndColor, + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.surface, ], end: Alignment.topCenter, begin: Alignment.bottomCenter, @@ -95,9 +94,9 @@ class StarterView extends StatelessWidget { const Spacer(flex: 1), MyOutlinedButton( text: l10n.importAccount, - textColor: Theme.of(context).colorScheme.lightPurple, + textColor: Theme.of(context).colorScheme.secondary, borderColor: - Theme.of(context).colorScheme.lightPurple, + Theme.of(context).colorScheme.secondary, backgroundColor: Colors.transparent, onPressed: () async { await profileCubit.setWalletType( diff --git a/lib/onboarding/tos/view/onboarding_tos_page.dart b/lib/onboarding/tos/view/onboarding_tos_page.dart index a9de6740c..0069f6493 100644 --- a/lib/onboarding/tos/view/onboarding_tos_page.dart +++ b/lib/onboarding/tos/view/onboarding_tos_page.dart @@ -18,8 +18,12 @@ class OnBoardingTosPage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) => OnBoardingTosCubit(), - child: OnBoardingTosView( - onBoardingTosCubit: context.read(), + child: Builder( + builder: (context) { + return OnBoardingTosView( + onBoardingTosCubit: context.read(), + ); + }, ), ); } @@ -66,7 +70,7 @@ class _OnBoardingTosViewState extends State { return false; }, child: BasePage( - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, title: l10n.termsOfUse, scrollView: false, padding: const EdgeInsets.symmetric(horizontal: 10), diff --git a/lib/onboarding/verify_phrase/view/onboarding_verify_phrase.dart b/lib/onboarding/verify_phrase/view/onboarding_verify_phrase.dart index a4ec794d8..493731452 100644 --- a/lib/onboarding/verify_phrase/view/onboarding_verify_phrase.dart +++ b/lib/onboarding/verify_phrase/view/onboarding_verify_phrase.dart @@ -47,12 +47,16 @@ class OnBoardingVerifyPhrasePage extends StatelessWidget { altmeChatSupportCubit: context.read(), profileCubit: context.read(), ), - child: OnBoardingVerifyPhraseView( - mnemonic: mnemonic, - isFromOnboarding: isFromOnboarding, - onBoardingVerifyPhraseCubit: - context.read(), - onboardingCubit: context.read(), + child: Builder( + builder: (context) { + return OnBoardingVerifyPhraseView( + mnemonic: mnemonic, + isFromOnboarding: isFromOnboarding, + onBoardingVerifyPhraseCubit: + context.read(), + onboardingCubit: context.read(), + ); + }, ), ); } diff --git a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart index ae958d45b..1e1190477 100644 --- a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart +++ b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart @@ -22,10 +22,14 @@ class WalletReadyPage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) => WalletReadyCubit(), - child: WalletReadyView( - profileCubit: context.read(), - walletReadyCubit: context.read(), - confettiController: ConfettiController(), + child: Builder( + builder: (context) { + return WalletReadyView( + profileCubit: context.read(), + walletReadyCubit: context.read(), + confettiController: ConfettiController(), + ); + }, ), ); } @@ -134,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/onboarding/widgets/protect_widget.dart b/lib/onboarding/widgets/protect_widget.dart index ba9ae8a30..d4e667f5e 100644 --- a/lib/onboarding/widgets/protect_widget.dart +++ b/lib/onboarding/widgets/protect_widget.dart @@ -31,7 +31,7 @@ class ProtectWidget extends StatelessWidget { decoration: BoxDecoration( color: isSelected ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.drawerSurface, + : Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.all( Radius.circular( Sizes.normalRadius, diff --git a/lib/pin_code/cubit/pin_code_view_cubit.dart b/lib/pin_code/cubit/pin_code_view_cubit.dart index b20135591..db1d3cc9c 100644 --- a/lib/pin_code/cubit/pin_code_view_cubit.dart +++ b/lib/pin_code/cubit/pin_code_view_cubit.dart @@ -1,20 +1,63 @@ +import 'dart:async'; + import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/pin_code/pin_code.dart'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:secure_storage/secure_storage.dart'; part 'pin_code_view_state.dart'; class PinCodeViewCubit extends Cubit { PinCodeViewCubit({ - required this.profileCubit, + this.totalPermitedLoginAttempt = 3, }) : super(const PinCodeViewState()); - final ProfileCubit profileCubit; + final int totalPermitedLoginAttempt; + + void loginAttempt() { + final loginAttemptCount = state.loginAttemptCount + 1; + final loginAttemptsRemaining = + totalPermitedLoginAttempt - state.loginAttemptCount - 1; + const allowAction = true; + // if (loginAttemptCount >= totalPermitedLoginAttempt) { + // allowAction = false; + // _startLockTimer(); + // } + emit( + state.copyWith( + loginAttemptCount: loginAttemptCount, + loginAttemptsRemaining: loginAttemptsRemaining, + allowAction: allowAction, + ), + ); + } + + Timer? _timer; + + void _startLockTimer() { + _timer = Timer.periodic(const Duration(minutes: 10), (timer) { + _resetloginAttemptCount(); + _timer?.cancel(); + }); + } + + void _resetloginAttemptCount() { + emit( + state.copyWith( + loginAttemptCount: 0, + allowAction: true, + loginAttemptsRemaining: totalPermitedLoginAttempt, + ), + ); + } void setEnteredPasscode(String enteredPasscode) { - emit(state.copyWith(enteredPasscode: enteredPasscode)); + emit( + state.copyWith( + enteredPasscode: enteredPasscode, + ), + ); } void onDeleteCancelButtonPressed(CancelCallback? cancelCallback) { @@ -30,12 +73,12 @@ class PinCodeViewCubit extends Cubit { } } - void onKeyboardButtonPressed({ + Future onKeyboardButtonPressed({ required String text, CancelCallback? cancelCallback, required int passwordDigits, - required PasswordEnteredCallback passwordEnteredCallback, - }) { + bool isNewCode = false, + }) async { final enteredPasscode = state.enteredPasscode; if (text == NumericKeyboard.deleteButton) { onDeleteCancelButtonPressed(cancelCallback); @@ -43,10 +86,117 @@ class PinCodeViewCubit extends Cubit { } if (enteredPasscode.length < passwordDigits) { final passCode = enteredPasscode + text; - setEnteredPasscode(passCode); + if (passCode.length == passwordDigits) { - passwordEnteredCallback(passCode); + if (isNewCode) { + if (isPincodeSeries( + digit: passCode, + passwordDigits: passwordDigits, + )) { + emit( + state.copyWith( + isPincodeSeries: true, + enteredPasscode: passCode, + ), + ); + return; + } + if (isPincodeSequence( + digit: passCode, + passwordDigits: passwordDigits, + )) { + emit( + state.copyWith( + isPincodeSequence: true, + enteredPasscode: passCode, + ), + ); + return; + } + await getSecureStorage.set(SecureStorageKeys.pinCode, passCode); + } else { + final isValid = + (await getSecureStorage.get(SecureStorageKeys.pinCode)) == + passCode; + if (!isValid) { + setEnteredPasscode(passCode); + loginAttempt(); + return; + } + } + emit( + state.copyWith( + isPinCodeValid: true, + enteredPasscode: passCode, + ), + ); + +// on new pincode + // void _onPasscodeEntered(String enteredPasscode) { + // Navigator.pushReplacement( + // context, + // ConfirmPinCodePage.route( + // storedPassword: enteredPasscode, + // isValidCallback: widget.isValidCallback, + // isFromOnboarding: widget.isFromOnboarding, + // ), + // ); + // } + } else { + setEnteredPasscode(passCode); + } + } else { + emit( + state.copyWith( + enteredPasscode: text, + isPincodeSequence: false, + isPincodeSeries: false, + ), + ); + } + } + + bool areAllDigitsIdentical(String number) { + // Convert the number to a string to easily access its digits + + // Check if all digits are the same + for (int i = 1; i < number.length; i++) { + if (number[i] != number[0]) { + return false; } } + + return true; + } + + bool isPincodeSequence({required String digit, required int passwordDigits}) { + if (digit.length == passwordDigits) { + bool isValidDesc = false; + bool isValidAsc = false; + // test if pin code is a serie asc or desc + for (int i = 1; i < digit.length; i++) { + if (i > 0) { + if (int.parse(digit[i]) != (int.parse(digit[i - 1]) + 1)) { + isValidAsc = true; + } + if (int.parse(digit[i]) != (int.parse(digit[i - 1]) - 1)) { + isValidDesc = true; + } + } + } + if (isValidAsc && isValidDesc) { + return false; + } else { + return true; + } + } + return false; + } + + bool isPincodeSeries({required String digit, required int passwordDigits}) { + if (digit.length == passwordDigits) { + return areAllDigitsIdentical(digit); + } + return true; } } diff --git a/lib/pin_code/cubit/pin_code_view_state.dart b/lib/pin_code/cubit/pin_code_view_state.dart index ba520b7a2..7ffd1e053 100644 --- a/lib/pin_code/cubit/pin_code_view_state.dart +++ b/lib/pin_code/cubit/pin_code_view_state.dart @@ -3,16 +3,51 @@ part of 'pin_code_view_cubit.dart'; class PinCodeViewState extends Equatable { const PinCodeViewState({ this.enteredPasscode = '', + this.loginAttemptCount = 0, + this.loginAttemptsRemaining = 3, + this.allowAction = true, + this.isPincodeSequence = false, + this.isPincodeSeries = false, + this.isPinCodeValid = false, }); final String enteredPasscode; + final int loginAttemptCount; + final int loginAttemptsRemaining; + final bool allowAction; + final bool isPincodeSeries; + final bool isPincodeSequence; + final bool isPinCodeValid; - PinCodeViewState copyWith({String? enteredPasscode}) { + PinCodeViewState copyWith({ + String? enteredPasscode, + int? loginAttemptCount, + int? loginAttemptsRemaining, + bool? allowAction, + bool? isPincodeSequence, + bool? isPincodeSeries, + bool? isPinCodeValid, + }) { return PinCodeViewState( enteredPasscode: enteredPasscode ?? this.enteredPasscode, + loginAttemptCount: loginAttemptCount ?? this.loginAttemptCount, + loginAttemptsRemaining: + loginAttemptsRemaining ?? this.loginAttemptsRemaining, + allowAction: allowAction ?? this.allowAction, + isPincodeSequence: isPincodeSequence ?? this.isPincodeSequence, + isPincodeSeries: isPincodeSeries ?? this.isPincodeSeries, + isPinCodeValid: isPinCodeValid ?? this.isPinCodeValid, ); } @override - List get props => [enteredPasscode]; + List get props => [ + enteredPasscode, + loginAttemptCount, + allowAction, + loginAttemptsRemaining, + isPincodeSequence, + isPincodeSeries, + isPinCodeValid, + ]; } diff --git a/lib/pin_code/pin_code.dart b/lib/pin_code/pin_code.dart index aeab34334..c188aa1af 100644 --- a/lib/pin_code/pin_code.dart +++ b/lib/pin_code/pin_code.dart @@ -1,6 +1,7 @@ export 'cubit/pin_code_view_cubit.dart'; export 'typedef.dart'; export 'view/confirm_pin_code_page.dart'; +export 'view/delete_my_wallet_page.dart'; export 'view/enter_new_pin_code_page.dart'; export 'view/pin_code_page.dart'; export 'widgets/widgets.dart'; diff --git a/lib/pin_code/typedef.dart b/lib/pin_code/typedef.dart index 915c03d7f..b6e8af307 100644 --- a/lib/pin_code/typedef.dart +++ b/lib/pin_code/typedef.dart @@ -1,3 +1,2 @@ -typedef PasswordEnteredCallback = dynamic Function(String text); typedef IsValidCallback = dynamic Function(); typedef CancelCallback = dynamic Function(); diff --git a/lib/pin_code/view/confirm_pin_code_page.dart b/lib/pin_code/view/confirm_pin_code_page.dart index 2a9f96cfb..3f89e92bc 100644 --- a/lib/pin_code/view/confirm_pin_code_page.dart +++ b/lib/pin_code/view/confirm_pin_code_page.dart @@ -1,13 +1,9 @@ -import 'dart:async'; - import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/onboarding/onboarding.dart'; +import 'package:altme/onboarding/widgets/m_stepper.dart'; import 'package:altme/pin_code/pin_code.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:secure_storage/secure_storage.dart'; class ConfirmPinCodePage extends StatelessWidget { const ConfirmPinCodePage({ @@ -39,8 +35,7 @@ class ConfirmPinCodePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - PinCodeViewCubit(profileCubit: context.read()), + create: (context) => PinCodeViewCubit(), child: ConfirmPinCodeView( storedPassword: storedPassword, isValidCallback: isValidCallback, @@ -67,9 +62,6 @@ class ConfirmPinCodeView extends StatefulWidget { } class _ConfirmPinCodeViewState extends State { - final StreamController _verificationNotifier = - StreamController.broadcast(); - bool get byPassScreen => !Parameters.walletHandlesCrypto; @override @@ -79,50 +71,45 @@ class _ConfirmPinCodeViewState extends State { @override void dispose() { - _verificationNotifier.close(); super.dispose(); } @override Widget build(BuildContext context) { final l10n = context.l10n; - return BasePage( - scrollView: false, - titleLeading: const BackLeadingButton(), - padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall), - backgroundColor: Theme.of(context).colorScheme.background, - body: PinCodeWidget( - title: l10n.confirmYourPinCode, - passwordEnteredCallback: _onPasscodeEntered, - 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, + return WillPopScope( + onWillPop: () async => !widget.isFromOnboarding, + child: BasePage( + scrollView: false, + title: '', + titleAlignment: Alignment.topCenter, + titleLeading: const BackLeadingButton(), + padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall), + backgroundColor: Theme.of(context).colorScheme.surface, + 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( + l10n.cancel, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelCallback: _onPasscodeCancelled, + isValidCallback: widget.isValidCallback, + isNewCode: false, ), - cancelCallback: _onPasscodeCancelled, - isValidCallback: widget.isValidCallback, - shouldTriggerVerification: _verificationNotifier.stream, ), ); } - Future _onPasscodeEntered(String enteredPasscode) async { - final bool isValid = widget.storedPassword == enteredPasscode; - if (isValid) { - await getSecureStorage.set(SecureStorageKeys.pinCode, enteredPasscode); - } - _verificationNotifier.add(isValid); - } - void _onPasscodeCancelled() { Navigator.maybePop(context); } diff --git a/lib/pin_code/view/delete_my_wallet_page.dart b/lib/pin_code/view/delete_my_wallet_page.dart new file mode 100644 index 000000000..ad2e67d74 --- /dev/null +++ b/lib/pin_code/view/delete_my_wallet_page.dart @@ -0,0 +1,73 @@ +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/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; +import 'package:altme/l10n/l10n.dart'; +import 'package:flutter/material.dart'; + +class DeleteMyWalletPage extends StatelessWidget { + const DeleteMyWalletPage({super.key}); + + static Route route() { + return MaterialPageRoute( + builder: (_) => const DeleteMyWalletPage(), + settings: const RouteSettings(name: '/deleteMyWalletPage'), + ); + } + + @override + Widget build(BuildContext context) { + return const DeleteMyWalletView(); + } +} + +class DeleteMyWalletView extends StatelessWidget { + const DeleteMyWalletView({ + super.key, + }); + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + return BasePage( + title: l10n.walletBloced, + titleAlignment: Alignment.topCenter, + scrollView: false, + body: Column( + children: [ + const Spacer( + flex: 8, + ), + Image.asset( + ImageStrings.cardMissing, + width: Sizes.icon, + ), + const SizedBox( + height: Sizes.spaceLarge, + ), + Text( + l10n.deleteMyWalletForWrontPincodeTitle, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.displaySmall, + ), + const SizedBox( + height: Sizes.spaceXSmall, + ), + Text( + l10n.deleteMyWalletForWrontPincodeDescription, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.labelMedium, + ), + const Spacer( + flex: 14, + ), + MyElevatedButton( + text: l10n.deleteMyWallet, + onPressed: () async { + await resetWallet(context); + }, + ), + ], + ), + ); + } +} diff --git a/lib/pin_code/view/enter_new_pin_code_page.dart b/lib/pin_code/view/enter_new_pin_code_page.dart index 0b0356207..25ac66037 100644 --- a/lib/pin_code/view/enter_new_pin_code_page.dart +++ b/lib/pin_code/view/enter_new_pin_code_page.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/onboarding/onboarding.dart'; +import 'package:altme/onboarding/widgets/m_stepper.dart'; import 'package:altme/pin_code/pin_code.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -19,7 +18,6 @@ class EnterNewPinCodePage extends StatelessWidget { static Route route({ required VoidCallback isValidCallback, required bool isFromOnboarding, - bool restrictToBack = true, }) => MaterialPageRoute( builder: (_) => EnterNewPinCodePage( @@ -32,8 +30,7 @@ class EnterNewPinCodePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - PinCodeViewCubit(profileCubit: context.read()), + create: (context) => PinCodeViewCubit(), child: EnterNewPinCodeView( isValidCallback: isValidCallback, isFromOnboarding: isFromOnboarding, @@ -76,10 +73,9 @@ class _EnterNewPinCodeViewState extends State { scrollView: false, titleLeading: const BackLeadingButton(), padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall), - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, body: PinCodeWidget( title: l10n.enterNewPinCode, - passwordEnteredCallback: _onPasscodeEntered, header: widget.isFromOnboarding ? MStepper( step: 1, @@ -95,15 +91,17 @@ class _EnterNewPinCodeViewState extends State { style: Theme.of(context).textTheme.labelLarge, ), cancelCallback: _onPasscodeCancelled, + isNewCode: true, + isValidCallback: _isValidCallback, ), ); } - void _onPasscodeEntered(String enteredPasscode) { + void _isValidCallback() { Navigator.pushReplacement( context, ConfirmPinCodePage.route( - storedPassword: enteredPasscode, + storedPassword: context.read().state.enteredPasscode, isValidCallback: widget.isValidCallback, isFromOnboarding: widget.isFromOnboarding, ), diff --git a/lib/pin_code/view/pin_code_page.dart b/lib/pin_code/view/pin_code_page.dart index 6145f53c5..a9bc9f239 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -1,13 +1,8 @@ -import 'dart:async'; - import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/pin_code/cubit/pin_code_view_cubit.dart'; -import 'package:altme/pin_code/widgets/widgets.dart'; +import 'package:altme/pin_code/pin_code.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:secure_storage/secure_storage.dart'; class PinCodePage extends StatelessWidget { const PinCodePage({ @@ -41,8 +36,7 @@ class PinCodePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - PinCodeViewCubit(profileCubit: context.read()), + create: (context) => PinCodeViewCubit(totalPermitedLoginAttempt: 3), child: PinCodeView( isValidCallback: isValidCallback, restrictToBack: restrictToBack, @@ -72,96 +66,91 @@ class PinCodeView extends StatefulWidget { } class _PinCodeViewState extends State { - final StreamController _verificationNotifier = - StreamController.broadcast(); + final totalPermitedLoginAttempt = 3; + + @override + void initState() { + super.initState(); + } @override void dispose() { - _verificationNotifier.close(); super.dispose(); } @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.surface, + title: '', + titleAlignment: Alignment.topCenter, + titleLeading: widget.restrictToBack ? null : const BackLeadingButton(), scrollView: false, - body: BlocBuilder( - builder: (context, state) { - return PinCodeWidget( - title: l10n.enterYourPinCode, - subTitle: l10n.pinCodeMessage, - passwordEnteredCallback: _onPasscodeEntered, - deleteButton: Text( - l10n.delete, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelButton: Text( - l10n.cancel, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelCallback: _onPasscodeCancelled, - isValidCallback: () async { - switch (widget.walletProtectionType) { - case WalletProtectionType.pinCode: - Navigator.pop(context); - widget.isValidCallback.call(); - case WalletProtectionType.biometrics: - throw ResponseMessage( - data: { - 'error': 'invalid_format', - 'error_description': 'The biomertics is not supported.', - }, - ); - case WalletProtectionType.FA2: - final LocalAuthApi localAuthApi = LocalAuthApi(); - final authenticated = await localAuthApi.authenticate( - localizedReason: l10n.scanFingerprintToAuthenticate, - ); - if (authenticated) { - Navigator.pop(context); - widget.isValidCallback.call(); - } else { - Navigator.pop(context); - AlertMessage.showStateMessage( - context: context, - stateMessage: StateMessage.success( - showDialog: false, - stringMessage: l10n.authenticationFailed, - ), - ); - } + body: PinCodeWidget( + title: l10n.enterYourPinCode, + subTitle: l10n.pinCodeMessage, + deleteButton: Text( + l10n.delete, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelButton: Text( + l10n.cancel, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelCallback: _onPasscodeCancelled, + isValidCallback: () async { + switch (widget.walletProtectionType) { + case WalletProtectionType.pinCode: + Navigator.pop(context); + widget.isValidCallback.call(); + case WalletProtectionType.biometrics: + throw ResponseMessage( + data: { + 'error': 'invalid_format', + 'error_description': 'The biomertics is not supported.', + }, + ); + case WalletProtectionType.FA2: + final LocalAuthApi localAuthApi = LocalAuthApi(); + final authenticated = await localAuthApi.authenticate( + localizedReason: l10n.scanFingerprintToAuthenticate, + ); + if (authenticated) { + Navigator.pop(context); + widget.isValidCallback.call(); + } else { + Navigator.pop(context); + AlertMessage.showStateMessage( + context: context, + stateMessage: StateMessage.success( + showDialog: false, + stringMessage: l10n.authenticationFailed, + ), + ); } - }, - shouldTriggerVerification: _verificationNotifier.stream, - allowAction: state.allowLogin, - ); + } + }, + // shouldTriggerVerification: _verificationNotifier.stream, + onLoginAttempt: (loginAttempt, loginAttemptsRemaining) { + if (loginAttemptsRemaining > 0) { + showModalBottomSheet( + context: context, + builder: (_) => WrongPinCodePopUp( + loginAttemptsRemaining: loginAttemptsRemaining, + ), + ); + } else { + Navigator.of(context).push(DeleteMyWalletPage.route()); + } }, ), ), ); } - Future _onPasscodeEntered(String enteredPasscode) async { - final profileCubit = context.read(); - - profileCubit.passcodeEntered(); - - bool isValid = false; - - if (profileCubit.state.allowLogin) { - isValid = (await getSecureStorage.get(SecureStorageKeys.pinCode)) == - enteredPasscode; - if (isValid) { - profileCubit.resetloginAttemptCount(); - } - } - _verificationNotifier.add(isValid); - } - void _onPasscodeCancelled() { Navigator.of(context).maybePop(); } diff --git a/lib/pin_code/widgets/delete_button.dart b/lib/pin_code/widgets/delete_button.dart index 57941a128..2602c8fe5 100644 --- a/lib/pin_code/widgets/delete_button.dart +++ b/lib/pin_code/widgets/delete_button.dart @@ -1,6 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:altme/pin_code/pin_code.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class DeleteButton extends StatelessWidget { @@ -22,12 +22,12 @@ class DeleteButton extends StatelessWidget { Widget build(BuildContext context) { final PinCodeViewCubit pinCodeViewCubit = context.read(); final passCode = pinCodeViewCubit.state.enteredPasscode; - return CupertinoButton( + return TextButton( onPressed: () => context .read() .onDeleteCancelButtonPressed(cancelCallback), child: Container( - margin: keyboardUIConfig.digitInnerMargin, + // margin: keyboardUIConfig.digitInnerMargin, child: passCode.isEmpty ? cancelButton : deleteButton, ), ); diff --git a/lib/pin_code/widgets/num_keyboard.dart b/lib/pin_code/widgets/num_keyboard.dart index 82b023866..762064b7f 100644 --- a/lib/pin_code/widgets/num_keyboard.dart +++ b/lib/pin_code/widgets/num_keyboard.dart @@ -8,31 +8,33 @@ class NumKeyboard extends StatelessWidget { super.key, KeyboardUIConfig? keyboardUIConfig, this.passwordDigits = 4, - required this.passwordEnteredCallback, this.cancelCallback, required this.allowAction, + this.isNewCode = false, + required this.keyboardButton, }) : keyboardUIConfig = keyboardUIConfig ?? const KeyboardUIConfig(); final KeyboardUIConfig keyboardUIConfig; final int passwordDigits; - final PasswordEnteredCallback passwordEnteredCallback; final CancelCallback? cancelCallback; final bool allowAction; - + final bool isNewCode; + final Widget keyboardButton; @override Widget build(BuildContext context) { return NumericKeyboard( - allowAction: allowAction, + allowAction: true, onKeyboardTap: (text) { if (!allowAction) return; context.read().onKeyboardButtonPressed( passwordDigits: passwordDigits, - passwordEnteredCallback: passwordEnteredCallback, text: text, cancelCallback: cancelCallback, + isNewCode: isNewCode, ); }, keyboardUIConfig: keyboardUIConfig, + trailingButton: keyboardButton, ); } } diff --git a/lib/pin_code/widgets/pin_code_title.dart b/lib/pin_code/widgets/pin_code_title.dart index 940630da0..078393d46 100644 --- a/lib/pin_code/widgets/pin_code_title.dart +++ b/lib/pin_code/widgets/pin_code_title.dart @@ -25,7 +25,7 @@ class PinCodeTitle extends StatelessWidget { : Theme.of(context) .textTheme .pinCodeTitle - .copyWith(color: Theme.of(context).colorScheme.redColor), + .copyWith(color: Theme.of(context).colorScheme.error), ), if (subTitle != null) ...[ const SizedBox(height: 10), @@ -36,7 +36,7 @@ class PinCodeTitle extends StatelessWidget { : Theme.of(context) .textTheme .pinCodeMessage - .copyWith(color: Theme.of(context).colorScheme.redColor), + .copyWith(color: Theme.of(context).colorScheme.error), textAlign: TextAlign.center, ), ], diff --git a/lib/pin_code/widgets/pin_code_widget.dart b/lib/pin_code/widgets/pin_code_widget.dart index 2a832a227..e338e265d 100644 --- a/lib/pin_code/widgets/pin_code_widget.dart +++ b/lib/pin_code/widgets/pin_code_widget.dart @@ -1,22 +1,19 @@ -import 'dart:async'; - import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/dashboard.dart'; +import 'package:altme/dashboard/profile/cubit/profile_cubit.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/pin_code/pin_code.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +typedef OnLoginAttempt = void Function(int, int); + class PinCodeWidget extends StatefulWidget { const PinCodeWidget({ super.key, required this.title, this.passwordDigits = 4, - required this.passwordEnteredCallback, required this.cancelButton, required this.deleteButton, - this.shouldTriggerVerification, this.isValidCallback, CircleUIConfig? circleUIConfig, KeyboardUIConfig? keyboardUIConfig, @@ -25,21 +22,24 @@ class PinCodeWidget extends StatefulWidget { this.cancelCallback, this.subTitle, this.header, - this.allowAction = true, + this.onLoginAttempt, + this.isNewCode = false, + this.isUserPin = false, }) : circleUIConfig = circleUIConfig ?? const CircleUIConfig(), keyboardUIConfig = keyboardUIConfig ?? const KeyboardUIConfig(); + final OnLoginAttempt? onLoginAttempt; final Widget? header; final String title; final String? subTitle; final int passwordDigits; - final PasswordEnteredCallback passwordEnteredCallback; - final bool allowAction; + final bool isNewCode; + // When a specific pin is requested to get a credential + final bool isUserPin; // Cancel button and delete button will be switched based on the screen state final Widget cancelButton; final Widget deleteButton; - final Stream? shouldTriggerVerification; final CircleUIConfig circleUIConfig; final KeyboardUIConfig keyboardUIConfig; @@ -56,40 +56,50 @@ class PinCodeWidget extends StatefulWidget { class _PinCodeWidgetState extends State with SingleTickerProviderStateMixin { - late StreamSubscription? streamSubscription; - late AnimationController controller; - late Animation animation; + late bool isPincodeDifferent; final log = getLogger('PinCodeWidget'); @override void initState() { super.initState(); - streamSubscription = - widget.shouldTriggerVerification?.listen(_showValidation); - controller = AnimationController( - duration: const Duration(milliseconds: 400), - vsync: this, - ); - final Animation curve = - CurvedAnimation(parent: controller, curve: ShakeCurve()); - animation = Tween(begin: 0, end: 10).animate(curve) - ..addStatusListener((status) { - if (status == AnimationStatus.completed) { - context.read().setEnteredPasscode(''); - controller.value = 0; - } - }); + isPincodeDifferent = false; } @override Widget build(BuildContext context) { final l10n = context.l10n; - return BlocBuilder( + return BlocConsumer( + listenWhen: (previous, current) { + if (current.enteredPasscode.length < widget.passwordDigits) { + setState(() { + isPincodeDifferent = false; + }); + } + if (current.enteredPasscode.length == widget.passwordDigits) { + if (current.isPinCodeValid || widget.isUserPin) { + _validationCallback(); + } else { + if (widget.title == l10n.confirmYourPinCode) { + setState(() { + isPincodeDifferent = true; + }); + } + } + } + return previous.loginAttemptCount != current.loginAttemptCount; + }, + listener: (context, state) { + widget.onLoginAttempt + ?.call(state.loginAttemptCount, state.loginAttemptsRemaining); + // if (state.enteredPasscode.length == widget.passwordDigits && + // widget.isUserPin) { + // _validationCallback(); + // } + }, builder: (context, state) { - final PinCodeViewCubit pinCodeViewCubit = - context.read(); - final enteredPasscode = pinCodeViewCubit.state.enteredPasscode; + final enteredPasscode = state.enteredPasscode; + final titleStyle = Theme.of(context).textTheme.labelMedium; return OrientationBuilder( builder: (context, orientation) { @@ -117,62 +127,89 @@ class _PinCodeWidgetState extends State 0.5, showPoweredBy: true, ), - const SizedBox(height: Sizes.spaceNormal), + const SizedBox(height: Sizes.spaceSmall), PinCodeTitle( title: widget.title, - subTitle: widget.allowAction + subTitle: state.allowAction ? widget.subTitle : l10n.pincodeAttemptMessage, - allowAction: widget.allowAction, + allowAction: state.allowAction, ), + const SizedBox(height: Sizes.spaceXSmall), Container( margin: const EdgeInsets.only(top: 16), height: 40, - child: AnimatedBuilder( - animation: animation, - builder: (_, __) { - return Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: List.generate( - widget.passwordDigits, - (index) => Container( - margin: const EdgeInsets.all(8), - child: Circle( - allowAction: widget.allowAction, - filled: index < - enteredPasscode.length, - circleUIConfig: - widget.circleUIConfig, - extraSize: animation.value, - ), - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate( + widget.passwordDigits, + (index) => Container( + margin: const EdgeInsets.all(8), + child: Circle( + allowAction: state.allowAction, + filled: + index < enteredPasscode.length, + circleUIConfig: (state + .isPincodeSequence || + state.isPincodeSeries || + isPincodeDifferent) + ? CircleUIConfig( + fillColor: Theme.of(context) + .colorScheme + .error, + ) + : widget.circleUIConfig, ), - ); - }, + ), + ), ), ), + SizedBox( + height: Sizes.spaceSmall, + child: isPincodeDifferent + ? Text( + l10n.pincodeDifferent, + style: titleStyle?.copyWith( + color: Theme.of(context) + .colorScheme + .error, + ), + textAlign: TextAlign.center, + ) + : state.isPincodeSeries + ? Text( + l10n.pincodeSerie, + style: titleStyle?.copyWith( + color: Theme.of(context) + .colorScheme + .error, + ), + textAlign: TextAlign.center, + ) + : state.isPincodeSequence + ? Text( + l10n.pincodeSequence, + style: titleStyle?.copyWith( + color: Theme.of(context) + .colorScheme + .error, + ), + textAlign: TextAlign.center, + ) + : const SizedBox.shrink(), + ), NumKeyboard( - passwordEnteredCallback: - widget.passwordEnteredCallback, keyboardUIConfig: widget.keyboardUIConfig, passwordDigits: widget.passwordDigits, cancelCallback: widget.cancelCallback, - allowAction: widget.allowAction, + allowAction: true, + isNewCode: widget.isNewCode, + keyboardButton: + KeyboardButton(widget: widget), ), widget.bottomWidget ?? Container(), ], ), - Positioned( - bottom: 0, - right: 0, - child: DeleteButton( - cancelButton: widget.cancelButton, - deleteButton: widget.deleteButton, - cancelCallback: widget.cancelCallback, - keyboardUIConfig: widget.keyboardUIConfig, - ), - ), ], ), ], @@ -199,58 +236,41 @@ class _PinCodeWidgetState extends State if (widget.header != null) widget.header! else - WalletLogo( - profileModel: context - .read() - .state - .model, - height: 90, - width: MediaQuery.of(context) - .size - .shortestSide * - 0.5, - showPoweredBy: true, - ), + // const AltMeLogo( + // size: Sizes.logoLarge, + // ), + const Center(), const SizedBox( height: Sizes.spaceNormal, ), PinCodeTitle( title: widget.title, subTitle: widget.subTitle, - allowAction: widget.allowAction, + allowAction: state.allowAction, ), Container( margin: const EdgeInsets.only(top: 20), height: 40, - child: AnimatedBuilder( - animation: animation, - builder: (_, __) { - return Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: List.generate( - widget.passwordDigits, - (index) => Container( - margin: - const EdgeInsets.all( - 8, - ), - child: Circle( - allowAction: - widget.allowAction, - filled: index < - enteredPasscode - .length, - circleUIConfig: widget - .circleUIConfig, - extraSize: - animation.value, - ), - ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: List.generate( + widget.passwordDigits, + (index) => Container( + margin: const EdgeInsets.all( + 8, + ), + child: Circle( + allowAction: + state.allowAction, + filled: index < + enteredPasscode.length, + circleUIConfig: + widget.circleUIConfig, ), - ); - }, + ), + ), ), ), ], @@ -271,30 +291,16 @@ class _PinCodeWidgetState extends State ), Expanded( child: NumKeyboard( - passwordEnteredCallback: - widget.passwordEnteredCallback, keyboardUIConfig: widget.keyboardUIConfig, passwordDigits: widget.passwordDigits, cancelCallback: widget.cancelCallback, - allowAction: widget.allowAction, + allowAction: true, + keyboardButton: KeyboardButton(widget: widget), ), ), ], ), ), - Positioned( - bottom: 0, - right: 0, - child: Align( - alignment: Alignment.bottomRight, - child: DeleteButton( - cancelButton: widget.cancelButton, - deleteButton: widget.deleteButton, - cancelCallback: widget.cancelCallback, - keyboardUIConfig: widget.keyboardUIConfig, - ), - ), - ), ], ); }, @@ -303,32 +309,6 @@ class _PinCodeWidgetState extends State ); } - @override - void didUpdateWidget(PinCodeWidget old) { - super.didUpdateWidget(old); - // in case the stream instance changed, subscribe to the new one - if (widget.shouldTriggerVerification != old.shouldTriggerVerification) { - streamSubscription?.cancel(); - streamSubscription = - widget.shouldTriggerVerification?.listen(_showValidation); - } - } - - @override - void dispose() { - controller.dispose(); - streamSubscription?.cancel(); - super.dispose(); - } - - void _showValidation(bool isValid) { - if (isValid) { - _validationCallback(); - } else { - controller.forward(); - } - } - void _validationCallback() { if (widget.isValidCallback != null) { widget.isValidCallback!.call(); @@ -340,3 +320,22 @@ class _PinCodeWidgetState extends State } } } + +class KeyboardButton extends StatelessWidget { + const KeyboardButton({ + super.key, + required this.widget, + }); + + final PinCodeWidget widget; + + @override + Widget build(BuildContext context) { + return DeleteButton( + cancelButton: widget.cancelButton, + deleteButton: widget.deleteButton, + cancelCallback: widget.cancelCallback, + keyboardUIConfig: widget.keyboardUIConfig, + ); + } +} diff --git a/lib/pin_code/widgets/widgets.dart b/lib/pin_code/widgets/widgets.dart index e5cdb9f4d..778e28fcb 100644 --- a/lib/pin_code/widgets/widgets.dart +++ b/lib/pin_code/widgets/widgets.dart @@ -4,3 +4,4 @@ export 'num_keyboard.dart'; export 'pin_code_title.dart'; export 'pin_code_widget.dart'; export 'shake_curve.dart'; +export 'wrong_pincode_popup.dart'; diff --git a/lib/pin_code/widgets/wrong_pincode_popup.dart b/lib/pin_code/widgets/wrong_pincode_popup.dart new file mode 100644 index 000000000..9f1ac1a81 --- /dev/null +++ b/lib/pin_code/widgets/wrong_pincode_popup.dart @@ -0,0 +1,56 @@ +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/l10n/l10n.dart'; +import 'package:flutter/material.dart'; + +class WrongPinCodePopUp extends StatelessWidget { + const WrongPinCodePopUp({ + super.key, + required this.loginAttemptsRemaining, + }); + + final int loginAttemptsRemaining; + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + + return BasePage( + body: Column( + children: [ + Image.asset( + ImageStrings.cardMissing, + width: Sizes.icon, + ), + const SizedBox( + height: Sizes.spaceLarge, + ), + Text( + l10n.userPinIsIncorrect, + style: Theme.of(context).textTheme.displaySmall, + ), + const SizedBox( + height: Sizes.spaceXSmall, + ), + Text( + l10n.codeSecretIncorrectDescription( + loginAttemptsRemaining, + loginAttemptsRemaining == 1 ? '' : 's', + ), + style: Theme.of(context).textTheme.labelMedium, + ), + const SizedBox( + height: Sizes.spaceLarge, + ), + MyElevatedButton( + text: l10n.tryAgain, + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + } +} diff --git a/lib/selective_disclosure/widget/display_selective_disclosure.dart b/lib/selective_disclosure/widget/display_selective_disclosure.dart index 5757ef2fc..9b505fe62 100644 --- a/lib/selective_disclosure/widget/display_selective_disclosure.dart +++ b/lib/selective_disclosure/widget/display_selective_disclosure.dart @@ -78,7 +78,7 @@ class DisplaySelectiveDisclosure extends StatelessWidget { title, style: Theme.of(context).textTheme.credentialFieldTitle.copyWith( - color: Theme.of(context).colorScheme.titleColor, + color: Theme.of(context).colorScheme.onSurface, ), ), ), @@ -203,8 +203,8 @@ class DisplaySelectiveDisclosure extends StatelessWidget { padding: EdgeInsets.only(top: isFirstElement ? 10 : 0), title: title, value: claims.data, - titleColor: Theme.of(context).colorScheme.titleColor, - valueColor: Theme.of(context).colorScheme.valueColor, + titleColor: Theme.of(context).colorScheme.onSurface, + valueColor: Theme.of(context).colorScheme.onSurface, showVertically: showVertically, ), if (selectiveDisclosureState != null && @@ -221,8 +221,8 @@ class DisplaySelectiveDisclosure extends StatelessWidget { color: disable != null && disable! ? Theme.of(context) .colorScheme - .lightGrey - .withOpacity(0.2) + .onSurface + .withOpacity(0.7) : Theme.of(context).colorScheme.onPrimary, ), ), diff --git a/lib/splash/view/splash_page.dart b/lib/splash/view/splash_page.dart index 5166f7130..f66cfb19a 100644 --- a/lib/splash/view/splash_page.dart +++ b/lib/splash/view/splash_page.dart @@ -7,6 +7,7 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/deep_link/deep_link.dart'; import 'package:altme/enterprise/enterprise.dart'; import 'package:altme/l10n/l10n.dart'; +import 'package:altme/pin_code/view/pin_code_page.dart'; import 'package:altme/polygon_id/polygon_id.dart'; import 'package:altme/splash/splash.dart'; import 'package:flutter/foundation.dart'; @@ -42,7 +43,28 @@ class _SplashViewState extends State { void initState() { WidgetsBinding.instance.addPostFrameCallback( (_) async { + final Uri? initialUri = await _handleInitialUri(context); + await context.read().initialiseApp(); + + /// In case app is opened through deeplink we need to handle + /// incoming request. + if (initialUri != null) { + await Navigator.of(context).push( + PinCodePage.route( + restrictToBack: true, + isValidCallback: () { + Navigator.of(context).push(DashboardPage.route()); + }, + walletProtectionType: WalletProtectionType.pinCode, + ), + ); + + await processIncomingUri( + initialUri, + context, + ); + } }, ); super.initState(); @@ -198,12 +220,12 @@ class _SplashViewState extends State { /// throughout your app's life. /// /// We handle all exceptions, since it is called from initState. - Future _handleInitialUri(BuildContext context) async { + Future _handleInitialUri(BuildContext context) async { // In this example app this is an almost useless guard, but it is here to // show we are not going to call getInitialUri multiple times, even if this // was a widget that will be disposed of (ex. a navigation route change). final log = getLogger('DeepLink - _handleInitialUri'); - if (!mounted) return; + if (!mounted) return null; if (!_initialUriIsHandled) { _initialUriIsHandled = true; @@ -213,18 +235,19 @@ class _SplashViewState extends State { log.i('no initial uri'); } else { log.i('got initial uri: $uri'); - if (!mounted) return; + if (!mounted) return null; log.i('got uri: $uri'); - await processIncomingUri(uri, context); + return uri; } } on services.PlatformException { // Platform messages may fail but we ignore the exception log.e('falied to get initial uri'); } on FormatException catch (err) { - if (!mounted) return; + if (!mounted) return null; log.e('malformed initial uri: $err'); } } + return null; } @override diff --git a/lib/theme/app_theme/app_theme.dart b/lib/theme/app_theme/app_theme.dart index 9aca45e97..a908d4453 100644 --- a/lib/theme/app_theme/app_theme.dart +++ b/lib/theme/app_theme/app_theme.dart @@ -10,7 +10,7 @@ abstract class AppTheme { /// An accent color used for less prominent components in the UI, such as /// filter chips, while expanding the opportunity for color expression. - static Color darkSecondary = const Color(0xff00A1FF); + static Color darkSecondary = const Color(0xff18ACFF); /// A color that's clearly legible when drawn on secondary static Color darkOnSecondary = const Color(0xffFFFFFF); @@ -18,13 +18,13 @@ abstract class AppTheme { /// A color used as a contrasting accent that can balance primary /// and secondary colors or bring heightened attention to an element, /// such as an input field. - static Color darkTertiary = const Color(0xffFFFFFF); + static Color darkTertiary = const Color(0xFF280164); /// A color that's clearly legible when drawn on tertiary. static Color darkOnTertiary = const Color(0xffD1CCE3); /// The background color for widgets like Card. - static Color darkSurface = const Color(0xff1A182D); + static Color darkSurface = const Color(0xff0B0514); /// A color that's clearly legible when drawn on surface. static Color darkOnSurface = const Color(0xffEDEAF5); @@ -55,17 +55,19 @@ abstract class AppTheme { dividerColor: dividerColor, highlightColor: highlightColor, colorScheme: ColorScheme( - primary: darkPrimary, + primary: const Color(0xff6600FF), onPrimary: darkOnPrimary, secondary: darkSecondary, onSecondary: darkOnSecondary, tertiary: darkTertiary, onTertiary: darkOnTertiary, - surface: darkSurface, + surface: const Color(0xff0B0514), onSurface: darkOnSurface, error: darkError, onError: darkOnError, shadow: darkShadow, + surfaceBright: const Color(0xff232630), + surfaceDim: const Color(0xff271C38), brightness: Brightness.dark, ), textTheme: TextTheme( @@ -103,153 +105,6 @@ abstract class AppTheme { ); } -extension CustomColorScheme on ColorScheme { - Color get redColor => const Color(0xFFFF0045); - Color get transactionApplied => const Color(0xFF00B267); - Color get transactionFailed => const Color(0xFFFF0045); - Color get transactionSkipped => const Color(0xFFFF5F0A); - Color get activeColorOfNetwork => const Color(0xFF2C7DF7); - - Color get greyText => const Color(0xFFD1CCE3); - - Color get kycKeyIconColor => const Color(0xFF86809D); - - Color get lightPurple => const Color(0xFF5F556F); - - Color get popupBackground => const Color(0xff271C38); - - Color get cardHighlighted => const Color(0xFF251F38); - - Color get defaultDialogDark => const Color(0xFF322643); - - Color get closeIconColor => const Color(0xFFA79ABA); - - Color get kycVerifyButton => const Color(0xFF0045FF); - - Color get checkMarkColor => const Color(0xFF00B267); - - Color get accountBottomSheetBorder => Colors.grey[200]!; - - Color get digitPrimaryColor => Colors.white; - - Color get digitFillColor => Colors.transparent; - - Color get disabledBgColor => const Color(0xFF6A5F7B); - - Color get disabledTextColor => const Color(0xFF000000); - - Color get darkGradientStartColor => const Color(0xff0A0F19); - - Color get darkGradientEndColor => const Color(0xff25095B); - - Color get transparent => Colors.transparent; - - Color get onOutlineButton => const Color(0xFF6600FF); - - Color get onElevatedButton => const Color(0xFFFFFFFF); - - Color get appBarUpperLayer => const Color(0xff25095B); - - Color get appBarLowerLayer => surface; - - Color get surfaceContainer => const Color(0xff707070).withOpacity(0.07); - - Color get drawerSurface => const Color(0xff232630); - - Color get label => Colors.white; - - Color get unSelectedLabel => const Color(0xff86809D); - - Color get leadingButton => const Color(0xffF1EFF8); - - Color get selectedBottomBar => surface; - - Color get drawerBackground => const Color(0xff0B0514); - - Color get borderColor => const Color(0xFFDDCEF4); - - Color get defualtDialogCancelButtonBorderColor => - const Color(0xFFFFFFFF).withOpacity(0.2); - - Color get markDownH1 => const Color(0xFFFFFFFF); - - Color get markDownH2 => const Color(0xFFFFFFFF); - - Color get markDownP => const Color(0xFFD1CCE3); - - Color get markDownA => const Color(0xff517bff); - - Color get subtitle1 => const Color(0xFFFFFFFF); - - Color get subtitle2 => const Color(0xFF8B8C92); - - Color get profileDummy => const Color(0xFF212121); - - Color get documentShadow => const Color(0xFF424242); - - Color get documentShape => const Color(0xff3700b3).withOpacity(0.05); - - Color get star => const Color(0xFFFFB83D); - - Color get genderIcon => const Color(0xFF212121); - - Color get activeCredential => Colors.green; - - Color get expiredCredential => Colors.orange; - - Color get revokedCredential => Colors.red; - - Color get buttonDisabled => const Color(0xFF424242); - - Color get alertErrorMessage => Colors.red; - - Color get alertWarningMessage => Colors.yellow; - - Color get alertInfoMessage => Colors.cyan; - - Color get alertSuccessMessage => Colors.green; - - Color get qrScanBackground => const Color(0xff2B1C48); - - Color get qrScanInnerShadow => const Color(0xff000000).withOpacity(0.16); - - Color get qrScanOuterShadow => const Color(0xff430F91); - - Color get dialogText => const Color(0xffF5F5F5); - - Color get tabBarNotSelected => const Color(0xFF280164); - - Color get credentialBackground => const Color(0xFF211F33); - - Color get cryptoAccountNotSelected => Colors.grey.withOpacity(0.15); - - Color get startButtonColorA => const Color(0xff18ACFF); - - Color get startButtonColorB => const Color(0xff6600FF); - - Color get associatedWalletBorder => const Color(0xff524B67); - - Color get deleteColor => const Color(0xff322643); - - Color get blueColor => const Color(0xff322643); - - Color get titleColor => const Color(0xffD1CCE3); - - Color get valueColor => const Color(0xffFFFFFF); - - Color get lightGrey => const Color(0xFF616161); - - Color get darkGrey => const Color(0xFF212121); - - Color get activeColor => const Color(0xFF08B530); - - Color get inactiveColor => const Color(0xFFFF0045); - - Color get beaconBorder => const Color(0xff86809D); - - Color get cardBackground => const Color(0xFF211F33); -} - extension CustomTextTheme on TextTheme { TextStyle get hintTextFieldStyle => GoogleFonts.nunito( fontSize: 14, diff --git a/packages/did_kit/lib/src/did_kit_provider.dart b/packages/did_kit/lib/src/did_kit_provider.dart index c4d19d442..fba7dd2c0 100644 --- a/packages/did_kit/lib/src/did_kit_provider.dart +++ b/packages/did_kit/lib/src/did_kit_provider.dart @@ -1,20 +1,26 @@ -import 'package:didkit/didkit.dart'; +import 'package:did_kit/src/didkit_interface.dart'; +import 'package:did_kit/src/didkit_wrapper.dart'; class DIDKitProvider { + DIDKitProvider({DIDKitInterface? didKit}) + : didKit = didKit ?? DIDKitWrapper(); + + final DIDKitInterface didKit; + String getVersion() { - return DIDKit.getVersion(); + return didKit.getVersion(); } String generateEd25519Key() { - return DIDKit.generateEd25519Key(); + return didKit.generateEd25519Key(); } String keyToDID(String methodName, String key) { - return DIDKit.keyToDID(methodName, key); + return didKit.keyToDID(methodName, key); } Future keyToVerificationMethod(String methodName, String key) async { - return DIDKit.keyToVerificationMethod(methodName, key); + return didKit.keyToVerificationMethod(methodName, key); } Future issueCredential( @@ -22,14 +28,14 @@ class DIDKitProvider { String options, String key, ) async { - return DIDKit.issueCredential(credential, options, key); + return didKit.issueCredential(credential, options, key); } Future verifyCredential( String credential, String options, ) async { - return DIDKit.verifyCredential(credential, options); + return didKit.verifyCredential(credential, options); } Future issuePresentation( @@ -37,28 +43,28 @@ class DIDKitProvider { String options, String key, ) async { - return DIDKit.issuePresentation(presentation, options, key); + return didKit.issuePresentation(presentation, options, key); } Future verifyPresentation( String presentation, String options, ) async { - return DIDKit.verifyPresentation(presentation, options); + return didKit.verifyPresentation(presentation, options); } Future resolveDID( String did, String inputMetadata, ) async { - return DIDKit.resolveDID(did, inputMetadata); + return didKit.resolveDID(did, inputMetadata); } Future dereferenceDIDURL( String didUrl, String inputMetadata, ) async { - return DIDKit.dereferenceDIDURL(didUrl, inputMetadata); + return didKit.dereferenceDIDURL(didUrl, inputMetadata); } Future didAuth( @@ -66,6 +72,6 @@ class DIDKitProvider { String options, String key, ) async { - return DIDKit.DIDAuth(did, options, key); + return didKit.didAuth(did, options, key); } } diff --git a/packages/did_kit/lib/src/didkit_interface.dart b/packages/did_kit/lib/src/didkit_interface.dart new file mode 100644 index 000000000..be25ced3f --- /dev/null +++ b/packages/did_kit/lib/src/didkit_interface.dart @@ -0,0 +1,17 @@ +abstract class DIDKitInterface { + String getVersion(); + String generateEd25519Key(); + String keyToDID(String methodName, String key); + Future keyToVerificationMethod(String methodName, String key); + Future issueCredential(String credential, String options, String key); + Future verifyCredential(String credential, String options); + Future issuePresentation( + String presentation, + String options, + String key, + ); + Future verifyPresentation(String presentation, String options); + Future resolveDID(String did, String inputMetadata); + Future dereferenceDIDURL(String didUrl, String inputMetadata); + Future didAuth(String did, String options, String key); +} diff --git a/packages/did_kit/lib/src/didkit_wrapper.dart b/packages/did_kit/lib/src/didkit_wrapper.dart new file mode 100644 index 000000000..3edbdf29b --- /dev/null +++ b/packages/did_kit/lib/src/didkit_wrapper.dart @@ -0,0 +1,83 @@ +import 'package:did_kit/src/didkit_interface.dart'; +import 'package:didkit/didkit.dart'; + +class DIDKitWrapper implements DIDKitInterface { + @override + String getVersion() { + return DIDKit.getVersion(); + } + + @override + String generateEd25519Key() { + return DIDKit.generateEd25519Key(); + } + + @override + String keyToDID(String methodName, String key) { + return DIDKit.keyToDID(methodName, key); + } + + @override + Future keyToVerificationMethod(String methodName, String key) async { + return DIDKit.keyToVerificationMethod(methodName, key); + } + + @override + Future issueCredential( + String credential, + String options, + String key, + ) async { + return DIDKit.issueCredential(credential, options, key); + } + + @override + Future verifyCredential( + String credential, + String options, + ) async { + return DIDKit.verifyCredential(credential, options); + } + + @override + Future issuePresentation( + String presentation, + String options, + String key, + ) async { + return DIDKit.issuePresentation(presentation, options, key); + } + + @override + Future verifyPresentation( + String presentation, + String options, + ) async { + return DIDKit.verifyPresentation(presentation, options); + } + + @override + Future resolveDID( + String did, + String inputMetadata, + ) async { + return DIDKit.resolveDID(did, inputMetadata); + } + + @override + Future dereferenceDIDURL( + String didUrl, + String inputMetadata, + ) async { + return DIDKit.dereferenceDIDURL(didUrl, inputMetadata); + } + + @override + Future didAuth( + String did, + String options, + String key, + ) async { + return DIDKit.DIDAuth(did, options, key); + } +} diff --git a/packages/did_kit/test/src/did_kit_test.dart b/packages/did_kit/test/src/did_kit_provider_test.dart similarity index 55% rename from packages/did_kit/test/src/did_kit_test.dart rename to packages/did_kit/test/src/did_kit_provider_test.dart index 4640c86b0..02510b29c 100644 --- a/packages/did_kit/test/src/did_kit_test.dart +++ b/packages/did_kit/test/src/did_kit_provider_test.dart @@ -2,8 +2,11 @@ import 'dart:convert'; import 'package:did_kit/did_kit.dart'; import 'package:did_kit/src/did_kit_provider.dart'; -import 'package:didkit/didkit.dart'; +import 'package:did_kit/src/didkit_interface.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +class MockDIDKitInterface extends Mock implements DIDKitInterface {} void main() { const didKitVersion = '0.3.0'; @@ -55,55 +58,53 @@ void main() { 'challenge': 'Uuid().v4()', }); + late DIDKitInterface mockDIDKit; late DIDKitProvider didKitProvider; - setUpAll(() { - didKitProvider = DIDKitProvider(); + setUp(() { + mockDIDKit = MockDIDKitInterface(); + didKitProvider = DIDKitProvider(didKit: mockDIDKit); }); group('DidKitProvider', () { test('verify did kit version is $didKitVersion', () { + when(() => mockDIDKit.getVersion()).thenReturn(didKitVersion); expect(didKitProvider.getVersion(), didKitVersion); + verify(() => mockDIDKit.getVersion()).called(1); }); - test('exceptions with empty inputs', () async { - expect( - () => didKitProvider.issueCredential('', '', ''), - throwsA(isInstanceOf()), - ); - expect( - () => didKitProvider.issuePresentation('', '', ''), - throwsA(isInstanceOf()), - ); - expect( - () => didKitProvider.verifyCredential('', ''), - throwsA(isInstanceOf()), - ); - expect( - () => didKitProvider.verifyPresentation('', ''), - throwsA(isInstanceOf()), - ); - }); - - test('generateEd25519Key method mocked', () { + test('generateEd25519Key returns correct key', () { + when(() => mockDIDKit.generateEd25519Key()).thenReturn(ed25519Key); expect(didKitProvider.generateEd25519Key(), equals(ed25519Key)); + verify(() => mockDIDKit.generateEd25519Key()).called(1); }); - test('keyToDID method mocked', () async { + test('keyToDID returns correct DID', () { + when(() => mockDIDKit.keyToDID(any(), any())).thenReturn(did); + expect( didKitProvider.keyToDID(key, ed25519Key), equals(did), ); + verify(() => mockDIDKit.keyToDID(key, ed25519Key)).called(1); }); - test('keyToVerificationMethod method mocked', () async { + test('keyToVerificationMethod returns correct verification method', + () async { + when(() => mockDIDKit.keyToVerificationMethod(any(), any())) + .thenAnswer((_) async => vm); + expect( await didKitProvider.keyToVerificationMethod(key, ed25519Key), equals(vm), ); + verify(() => mockDIDKit.keyToVerificationMethod(key, ed25519Key)) + .called(1); }); - test('issueCredential method mocked', () async { + test('issueCredential returns correct vc', () async { + when(() => mockDIDKit.issueCredential(any(), any(), any())) + .thenAnswer((_) async => vc); expect( await didKitProvider.issueCredential( jsonEncode(credential), @@ -112,16 +113,30 @@ void main() { ), equals(vc), ); + verify( + () => mockDIDKit.issueCredential( + jsonEncode(credential), + jsonEncode(options), + key, + ), + ).called(1); }); - test('verifyCredential method mocked', () async { + test('verifyCredential returns correct verifyResult', () async { + when(() => mockDIDKit.verifyCredential(any(), any())) + .thenAnswer((_) async => verifyResult); expect( await didKitProvider.verifyCredential(vc, jsonEncode(verifyOptions)), equals(verifyResult), ); + verify( + () => mockDIDKit.verifyCredential(vc, jsonEncode(verifyOptions)), + ).called(1); }); - test('issuePresentation method mocked', () async { + test('issuePresentation returns correct vc', () async { + when(() => mockDIDKit.issuePresentation(any(), any(), any())) + .thenAnswer((_) async => vc); expect( await didKitProvider.issuePresentation( jsonEncode(presentation), @@ -130,9 +145,18 @@ void main() { ), equals(vc), ); + verify( + () => mockDIDKit.issuePresentation( + jsonEncode(presentation), + jsonEncode(options), + key, + ), + ).called(1); }); - test('verifyPresentation method mocked', () async { + test('verifyPresentation returns correct verifyResult', () async { + when(() => mockDIDKit.verifyPresentation(any(), any())) + .thenAnswer((_) async => verifyResult); expect( await didKitProvider.verifyPresentation( vc, @@ -140,27 +164,48 @@ void main() { ), equals(verifyResult), ); + verify( + () => mockDIDKit.verifyPresentation( + vc, + jsonEncode(verifyOptions), + ), + ).called(1); }); test('resolveDID method mocked', () async { + when(() => mockDIDKit.resolveDID(any(), any())) + .thenAnswer((_) async => ''); expect( await didKitProvider.resolveDID(did, '{}'), isInstanceOf(), ); + verify( + () => mockDIDKit.resolveDID(did, '{}'), + ).called(1); }); test('dereferenceDIDURL method mocked', () async { + when(() => mockDIDKit.dereferenceDIDURL(any(), any())) + .thenAnswer((_) async => ''); expect( await didKitProvider.dereferenceDIDURL(vm, '{}'), isInstanceOf(), ); + verify( + () => mockDIDKit.dereferenceDIDURL(vm, '{}'), + ).called(1); }); test('didAuth method mocked', () async { + when(() => mockDIDKit.didAuth(any(), any(), any())) + .thenAnswer((_) async => ''); expect( await didKitProvider.didAuth(did, proofOptions, key), isInstanceOf(), ); + verify( + () => mockDIDKit.didAuth(did, proofOptions, key), + ).called(1); }); }); } diff --git a/packages/key_generator/lib/src/key_generator.dart b/packages/key_generator/lib/src/key_generator.dart index 46f10a4ec..918c476c3 100644 --- a/packages/key_generator/lib/src/key_generator.dart +++ b/packages/key_generator/lib/src/key_generator.dart @@ -1,6 +1,5 @@ import 'dart:convert'; import 'dart:typed_data'; - import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip393; import 'package:dart_bip32_bip44/dart_bip32_bip44.dart'; diff --git a/packages/key_generator/pubspec.yaml b/packages/key_generator/pubspec.yaml index 8feaaa36e..819da38bd 100644 --- a/packages/key_generator/pubspec.yaml +++ b/packages/key_generator/pubspec.yaml @@ -13,17 +13,15 @@ dependencies: dart_web3: ^0.0.3 ed25519_hd_key: ^2.2.0 hex: ^0.2.0 + pinenacl: ^0.3.3 secp256k1: ^0.3.0 tezart: git: url: https://github.com/autonomy-system/tezart.git ref: e53e4ab9eaabea53cbf70e814efd2245b4659f48 -dependency_overrides: - pinenacl: ^0.5.1 # tezart from git depends on pinenacl ^0.3.3 - dev_dependencies: - coverage: ^1.6.3 - mocktail: ^0.3.0 - test: ^1.24.3 + flutter_test: + sdk: flutter + mocktail: ^1.0.2 very_good_analysis: ^5.0.0+1 diff --git a/packages/key_generator/test/src/key_generator_test.dart b/packages/key_generator/test/src/key_generator_test.dart index ec12b309a..81f83783d 100644 --- a/packages/key_generator/test/src/key_generator_test.dart +++ b/packages/key_generator/test/src/key_generator_test.dart @@ -1,5 +1,5 @@ +import 'package:flutter_test/flutter_test.dart'; import 'package:key_generator/key_generator.dart'; -import 'package:test/test.dart'; void main() { const mnemonics = @@ -138,50 +138,63 @@ void main() { }); }); - group('ethereum', () { - const accountType = AccountType.ethereum; - test('throw Exception for secretKey from ethereum', () async { - final key = await keyGenerator.jwkFromMnemonic( - mnemonic: mnemonics, - accountType: accountType, - derivePathIndex: derivePathIndex, - ); - expect(key, evmJwkKey); - }); + group('EVM', () { + const accountTypes = [ + AccountType.ethereum, + AccountType.fantom, + AccountType.polygon, + AccountType.binance, + ]; + + for (final accountType in accountTypes) { + test('throw Exception for secretKey from ethereum', () async { + final key = await keyGenerator.jwkFromMnemonic( + mnemonic: mnemonics, + accountType: accountType, + derivePathIndex: derivePathIndex, + ); + expect(key, evmJwkKey); + }); - test('key from secretKey for ethereum', () async { - final key = await keyGenerator.jwkFromSecretKey( - secretKey: ethereumSecretKey, - accountType: accountType, - ); - expect(key, evmJwkKey); - }); + test('key from secretKey for ethereum', () async { + final key = await keyGenerator.jwkFromSecretKey( + secretKey: ethereumSecretKey, + accountType: accountType, + ); + expect(key, evmJwkKey); + }); - test('0x wallet address from mnemonics for ethereum', () async { - final walletAddress = await keyGenerator.walletAddressFromMnemonic( - mnemonic: mnemonics, - accountType: accountType, - derivePathIndex: derivePathIndex, - ); - expect(walletAddress, ethereumWalletAddress); - }); + test('0x wallet address from mnemonics for ethereum', () async { + final walletAddress = await keyGenerator.walletAddressFromMnemonic( + mnemonic: mnemonics, + accountType: accountType, + derivePathIndex: derivePathIndex, + ); + expect(walletAddress, ethereumWalletAddress); + }); - test('secretKey from mnemonics for ethereum ', () async { - final secretKey = await keyGenerator.secretKeyFromMnemonic( - mnemonic: mnemonics, - accountType: accountType, - derivePathIndex: derivePathIndex, - ); - expect(secretKey, ethereumSecretKey); - }); + test('secretKey from mnemonics for ethereum ', () async { + final secretKey = await keyGenerator.secretKeyFromMnemonic( + mnemonic: mnemonics, + accountType: accountType, + derivePathIndex: derivePathIndex, + ); + expect(secretKey, ethereumSecretKey); + }); - test('0x wallet address from secret key for ethereum', () async { - final walletAddress = await keyGenerator.walletAddressFromSecretKey( - secretKey: ethereumSecretKey, - accountType: accountType, - ); - expect(walletAddress, ethereumWalletAddress); - }); + test('0x wallet address from secret key for ethereum', () async { + final walletAddress = await keyGenerator.walletAddressFromSecretKey( + secretKey: ethereumSecretKey, + accountType: accountType, + ); + expect(walletAddress, ethereumWalletAddress); + }); + } + }); + + test('getKeystore returns correct value', () { + final data = keyGenerator.getKeystore(secretKey: tezosSecretKey); + expect(data.address, tezosWalletAddress); }); }); } diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index c00c19d65..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 @@ -1758,27 +1785,27 @@ class OIDC4VC { dio.options.headers = headers; - if (isCachingEnabled) { - final secureStorageProvider = getSecureStorage; - final cachedData = await secureStorageProvider.get(uri); - if (cachedData == null) { - response = await dio.get(uri); - } else { - final cachedDataJson = jsonDecode(cachedData); - final expiry = int.parse(cachedDataJson['expiry'].toString()); - - final isExpired = DateTime.now().millisecondsSinceEpoch > expiry; - - if (isExpired) { - response = await dio.get(uri); - } else { - /// directly return cached data - /// returned here to avoid the caching override everytime - final response = await cachedDataJson['data']; - return response; - } - } - } + // if (isCachingEnabled) { + // final secureStorageProvider = getSecureStorage; + // final cachedData = await secureStorageProvider.get(uri); + // if (cachedData == null) { + // response = await dio.get(uri); + // } else { + // final cachedDataJson = jsonDecode(cachedData); + // final expiry = int.parse(cachedDataJson['expiry'].toString()); + + // final isExpired = DateTime.now().millisecondsSinceEpoch > expiry; + + // if (isExpired) { + // response = await dio.get(uri); + // } else { + // /// directly return cached data + // /// returned here to avoid the caching override everytime + // final response = await cachedDataJson['data']; + // return response; + // } + // } + // } // temporary deactiviting this caching du to issue with // flutter_secure_storage on ios #2657 // final expiry = @@ -1786,6 +1813,7 @@ class OIDC4VC { // final value = {'expiry': expiry, 'data': response.data}; // await secureStorageProvider.set(uri, jsonEncode(value)); + response = await dio.get(uri); return response.data; } on FormatException { 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/polygonid/lib/src/polygonid.dart b/packages/polygonid/lib/src/polygonid.dart index b13f2fba4..b3557a778 100644 --- a/packages/polygonid/lib/src/polygonid.dart +++ b/packages/polygonid/lib/src/polygonid.dart @@ -20,16 +20,18 @@ import 'package:web3dart/web3dart.dart'; /// A Very Good Project created by Very Good CLI. /// {@endtemplate} class PolygonId { - /// {@macro polygonid} - factory PolygonId() { - return _instance ??= PolygonId._(); + factory PolygonId({PolygonIdSdk? sdk}) { + if (sdk != null) { + _instance.polygonIdSdk = sdk; + } + return _instance; } - /// private contructor - PolygonId._(); + PolygonId._internal(); + + late PolygonIdSdk polygonIdSdk; - /// _instance - static PolygonId? _instance; + static final PolygonId _instance = PolygonId._internal(); /// blockchain static const blockchain = 'polygon'; @@ -62,6 +64,8 @@ class PolygonId { ipfsUrl: ipfsUrl, ), ); + + polygonIdSdk = PolygonIdSdk.I; isInitialized = true; } @@ -75,7 +79,7 @@ class PolygonId { required String network, required String ipfsUrl, }) { - return PolygonIdSdk.I.setEnv( + return polygonIdSdk.setEnv( env: EnvEntity( blockchain: blockchain, network: network, @@ -91,64 +95,38 @@ class PolygonId { /// PolygonId SDK getEnv Future getEnv() async { - return PolygonIdSdk.I.getEnv(); + return polygonIdSdk.getEnv(); } /// check if curcuit is already downloaded Future isCircuitsDownloaded() async { final isDownloaded = - await PolygonIdSdk.I.proof.isAlreadyDownloadedCircuitsFromServer(); + await polygonIdSdk.proof.isAlreadyDownloadedCircuitsFromServer(); return isDownloaded; } /// init Circuits Download And Get Info Stream Stream get initCircuitsDownloadAndGetInfoStream { - return PolygonIdSdk.I.proof.initCircuitsDownloadAndGetInfoStream; - } - - /// Create Identity - /// - /// blockchain and network are not optional, they are used to associate the - /// identity to a specific blockchain network. - /// - /// it is recommended to securely save the privateKey generated with - /// createIdentity(), this will often be used within the sdk methods as a - /// security system, you can find the privateKey in the PrivateIdentityEntity - /// object. - /// - Future addIdentity({ - required String mnemonic, - required String network, - }) async { - try { - final sdk = PolygonIdSdk.I; - final secret = bip393.mnemonicToEntropy(mnemonic); - final identity = await sdk.identity.addIdentity(secret: secret); - return identity; - } catch (e) { - if (e is IdentityAlreadyExistsException) { - final identity = await getIdentity( - mnemonic: mnemonic, - network: network, - ); - return identity; - } else { - throw Exception('ISSUE_WHILE_ADDING_IDENTITY'); - } - } + return polygonIdSdk.proof.initCircuitsDownloadAndGetInfoStream; } /// get private key from mnemonics Future getPrivateKey({ required String mnemonic, + Uint8List? private, }) async { - final secret = bip393.mnemonicToEntropy(mnemonic); + late Uint8List privateKey; - final privadoIdWallet = await BjjWallet.createBjjWallet( - secret: Uint8List.fromList(secret.codeUnits), - ); + if (private == null) { + final secret = bip393.mnemonicToEntropy(mnemonic); + final privadoIdWallet = await BjjWallet.createBjjWallet( + secret: Uint8List.fromList(secret.codeUnits), + ); + privateKey = privadoIdWallet.privateKey; + } else { + privateKey = private; + } - final privateKey = privadoIdWallet.privateKey; final epk = HEX.encode(privateKey); return epk; } @@ -157,10 +135,13 @@ class PolygonId { Future getUserIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, @@ -173,32 +154,63 @@ class PolygonId { Future getIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); - final identity = await sdk.identity.restoreIdentity( + final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, ); return identity; } + /// Create Identity + /// + /// blockchain and network are not optional, they are used to associate the + /// identity to a specific blockchain network. + /// + /// it is recommended to securely save the privateKey generated with + /// createIdentity(), this will often be used within the sdk methods as a + /// security system, you can find the privateKey in the PrivateIdentityEntity + /// object. + /// + Future addIdentity({ + required String mnemonic, + required String network, + }) async { + try { + final secret = bip393.mnemonicToEntropy(mnemonic); + final identity = await polygonIdSdk.identity.addIdentity(secret: secret); + return identity; + } catch (e) { + if (e is IdentityAlreadyExistsException) { + final identity = await getIdentity( + mnemonic: mnemonic, + network: network, + ); + return identity; + } else { + throw Exception('ISSUE_WHILE_ADDING_IDENTITY'); + } + } + } + /// Remove the previously stored identity associated with the identifier Future removeIdentity({ required String genesisDid, required String privateKey, required String network, }) async { - final sdk = PolygonIdSdk.I; - final genesisDid = await sdk.identity.getDidIdentifier( + final genesisDid = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, ); - return sdk.identity.removeIdentity( + return polygonIdSdk.identity.removeIdentity( privateKey: privateKey, genesisDid: genesisDid, ); @@ -207,8 +219,7 @@ class PolygonId { /// Get a list of public info of [IdentityEntity] associated /// to the identities stored in the Polygon ID Sdk. Future> getIdentities() { - final sdk = PolygonIdSdk.I; - return sdk.identity.getIdentities(); + return polygonIdSdk.identity.getIdentities(); } /// Returns a [Iden3MessageEntity] from an iden3comm message string. @@ -219,8 +230,7 @@ class PolygonId { /// iden3comm message string needs to be parsed to a supported /// [Iden3MessageEntity] by the Polygon Id Sdk using this method. Future getIden3Message({required String message}) { - final sdk = PolygonIdSdk.I; - return sdk.iden3comm.getIden3Message(message: message); + return polygonIdSdk.iden3comm.getIden3Message(message: message); } /// Authenticate response from iden3Message sharing the needed @@ -239,12 +249,15 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String network, required String mnemonic, + Uint8List? private, }) async { try { - final sdk = PolygonIdSdk.I; + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, @@ -252,7 +265,7 @@ class PolygonId { /// Authenticate response from iden3Message sharing the needed /// (if any) proofs requested by it - await sdk.iden3comm.authenticate( + await polygonIdSdk.iden3comm.authenticate( message: iden3MessageEntity, genesisDid: did, privateKey: privateKey, @@ -279,18 +292,20 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { try { - final sdk = PolygonIdSdk.I; - - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, ); - final claimEntities = await sdk.iden3comm.fetchAndSaveClaims( + final claimEntities = await polygonIdSdk.iden3comm.fetchAndSaveClaims( message: iden3MessageEntity, genesisDid: did, privateKey: privateKey, @@ -310,17 +325,19 @@ class PolygonId { required String claimId, required String mnemonic, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; - - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, ); - return sdk.credential.getClaimsByIds( + return polygonIdSdk.credential.getClaimsByIds( claimIds: [claimId], genesisDid: did, privateKey: privateKey, @@ -344,13 +361,14 @@ class PolygonId { Future backupIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); - return sdk.identity.backupIdentity( + return polygonIdSdk.identity.backupIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, ); @@ -374,13 +392,14 @@ class PolygonId { required String mnemonic, required String encryptedDb, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); - final identity = await sdk.identity.restoreIdentity( + final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, encryptedDb: encryptedDb, @@ -401,9 +420,7 @@ class PolygonId { required PrivateIdentityEntity privateIdentityEntity, }) async { try { - final sdk = PolygonIdSdk.I; - - final claimEntities = await sdk.credential.getClaims( + final claimEntities = await polygonIdSdk.credential.getClaims( genesisDid: privateIdentityEntity.did, privateKey: privateIdentityEntity.privateKey, ); @@ -418,8 +435,7 @@ class PolygonId { Future>> getSchemas({ required Iden3MessageEntity message, }) async { - final sdk = PolygonIdSdk.I; - return sdk.iden3comm.getSchemas(message: message); + return polygonIdSdk.iden3comm.getSchemas(message: message); } /// Get a list of [ClaimEntity] from iden3comm message @@ -438,19 +454,22 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { try { - final sdk = PolygonIdSdk.I; - - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); - final did = await sdk.identity.getDidIdentifier( + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, ); - final claimEntities = await sdk.iden3comm.getClaimsFromIden3Message( + final claimEntities = + await polygonIdSdk.iden3comm.getClaimsFromIden3Message( message: iden3MessageEntity, genesisDid: did, privateKey: privateKey, @@ -468,8 +487,8 @@ class PolygonId { required Iden3MessageEntity contractIden3messageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { - final sdk = PolygonIdSdk.I; var challenge = walletAddress; if (challenge.toLowerCase().startsWith('0x')) { @@ -483,9 +502,11 @@ class PolygonId { final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); - final List response = await sdk.iden3comm.getProofs( + final List response = + await polygonIdSdk.iden3comm.getProofs( message: contractIden3messageEntity, genesisDid: userIdentity.did, privateKey: userIdentity.privateKey, diff --git a/packages/polygonid/pubspec.yaml b/packages/polygonid/pubspec.yaml index 590605453..c680a37ce 100644 --- a/packages/polygonid/pubspec.yaml +++ b/packages/polygonid/pubspec.yaml @@ -20,4 +20,5 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + mocktail: ^1.0.2 very_good_analysis: ^5.0.0+1 diff --git a/packages/polygonid/test/src/polygonid_test.dart b/packages/polygonid/test/src/polygonid_test.dart index 8978d590f..652cbf0b3 100644 --- a/packages/polygonid/test/src/polygonid_test.dart +++ b/packages/polygonid/test/src/polygonid_test.dart @@ -1,11 +1,472 @@ // ignore_for_file: prefer_const_constructors +import 'dart:typed_data'; + import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; import 'package:polygonid/polygonid.dart'; +import 'package:polygonid_flutter_sdk/common/domain/entities/env_entity.dart'; +import 'package:polygonid_flutter_sdk/identity/domain/entities/identity_entity.dart'; +import 'package:polygonid_flutter_sdk/sdk/credential.dart'; +import 'package:polygonid_flutter_sdk/sdk/iden3comm.dart'; +import 'package:polygonid_flutter_sdk/sdk/identity.dart'; +import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart'; +import 'package:polygonid_flutter_sdk/sdk/proof.dart'; + +class ConcreteIden3MessageEntity extends Iden3MessageEntity { + const ConcreteIden3MessageEntity({ + required super.id, + required super.typ, + required super.type, + super.messageType, + required super.thid, + required super.from, + super.to, + required this.body, + }); + + @override + final dynamic body; +} + +final iden3MessageEntity = ConcreteIden3MessageEntity( + id: '123', + typ: 'type', + type: 'type', + messageType: Iden3MessageType.authRequest, + thid: 'thid', + from: 'from', + to: 'to', + body: {'key': 'value'}, +); + +final downloadInfo = DownloadInfo.onDone(contentLength: 1, downloaded: 1); +const mnemonics = + '''notice photo opera keen climb agent soft parrot best joke field devote'''; + +const privateIdentityEntity = PrivateIdentityEntity( + did: '', + privateKey: '', + profiles: {}, + publicKey: [], +); + +final privateKey = Uint8List.fromList([ + 0x00, + 0x01, + 0x02, + 0x03, + 0x04, + 0x05, + 0x06, + 0x07, + 0x08, + 0x09, + 0x0a, + 0x0b, + 0x0c, + 0x0d, + 0x0e, + 0x0f, + 0x10, + 0x11, + 0x12, + 0x13, + 0x14, + 0x15, + 0x16, + 0x17, + 0x18, + 0x19, + 0x1a, + 0x1b, + 0x1c, + 0x1d, + 0x1e, + 0x1f, +]); + +const stringPrivateKey = + '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'; + +const did = 'I am did'; + +class MockProof extends Mock implements Proof { + @override + Future isAlreadyDownloadedCircuitsFromServer() async { + return true; + } + + @override + Stream get initCircuitsDownloadAndGetInfoStream { + return Stream.value(downloadInfo); + } +} + +class MockIdentity extends Mock implements Identity { + @override + Future getDidIdentifier({ + required String privateKey, + required String blockchain, + required String network, + BigInt? profileNonce, + }) { + return Future.value(did); + } + + @override + Future addIdentity({String? secret}) async { + return Future.value(privateIdentityEntity); + } + + @override + Future removeIdentity({ + required String genesisDid, + required String privateKey, + }) { + return Future.value(); + } + + @override + Future> getIdentities() { + return Future.value([]); + } + + @override + Future restoreIdentity({ + required String genesisDid, + required String privateKey, + String? encryptedDb, + }) { + return Future.value(privateIdentityEntity); + } + + @override + Future backupIdentity({ + required String genesisDid, + required String privateKey, + }) { + return Future.value('ok'); + } +} + +class MockCredential extends Mock implements Credential { + @override + Future> getClaims({ + List? filters, + required String genesisDid, + required String privateKey, + }) { + return Future.value([]); + } + + @override + Future> getClaimsByIds({ + required List claimIds, + required String genesisDid, + required String privateKey, + }) { + return Future.value([]); + } +} + +class MockIden3comm extends Mock implements Iden3comm { + @override + Future getIden3Message({required String message}) { + return Future.value(iden3MessageEntity); + } + + @override + Future>> getSchemas({ + required Iden3MessageEntity message, + }) { + return Future.value([]); + } + + @override + Future authenticate({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + String? pushToken, + Map>? nonRevocationProofs, + String? challenge, + }) { + return Future.value(); + } + + @override + Future> fetchAndSaveClaims({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + }) { + return Future.value([]); + } + + @override + Future> getClaimsFromIden3Message({ + required Iden3MessageEntity message, + required String genesisDid, + BigInt? profileNonce, + required String privateKey, + Map>? nonRevocationProofs, + }) { + return Future.value([]); + } +} + +class MockPolygonIdSdk extends Mock implements PolygonIdSdk {} void main() { + final MockPolygonIdSdk polygonIdSdk = MockPolygonIdSdk(); + final PolygonId polygonId = PolygonId(sdk: polygonIdSdk); + + final proof = MockProof(); + final identity = MockIdentity(); + final credential = MockCredential(); + final iden3comm = MockIden3comm(); + + final env = EnvEntity( + blockchain: 'polygon', + network: 'network', + web3Url: 'web3Url', + web3RdpUrl: 'web3RdpUrl', + web3ApiKey: 'web3ApiKey', + idStateContract: 'idStateContract', + pushUrl: 'pushUrl', + ipfsUrl: 'ipfsUrl', + ); + group('PolygonId', () { test('can be instantiated', () { - expect(PolygonId(), isNotNull); + expect(polygonId, isNotNull); + }); + + test('initialised default value is correct', () { + expect(PolygonId.blockchain, 'polygon'); + expect(polygonId.isInitialized, false); + }); + + test('setEnv works correctly', () async { + when(() => polygonIdSdk.setEnv(env: env)).thenAnswer((_) async => {}); + await polygonId.setEnv( + network: 'network', + web3Url: 'web3Url', + web3RdpUrl: 'web3RdpUrl', + web3ApiKey: 'web3ApiKey', + idStateContract: 'idStateContract', + pushUrl: 'pushUrl', + ipfsUrl: 'ipfsUrl', + ); + verify(() => polygonIdSdk.setEnv(env: env)).called(1); + }); + + test('getEnv works correctly', () async { + when(polygonIdSdk.getEnv).thenAnswer((_) async => env); + final data = await polygonId.getEnv(); + expect(data, env); + verify(polygonIdSdk.getEnv).called(1); + }); + + test('isCircuitsDownloaded works correctly', () async { + when(() => polygonIdSdk.proof).thenReturn(proof); + final data = await polygonId.isCircuitsDownloaded(); + expect(data, true); + }); + + test('initCircuitsDownloadAndGetInfoStream works correctly', () async { + when(() => polygonIdSdk.proof).thenReturn(proof); + final stream = polygonId.initCircuitsDownloadAndGetInfoStream; + final emittedValues = await stream.toList(); + expect(emittedValues, [downloadInfo]); + }); + + test('getPrivateKey returns correct value', () async { + final data = await polygonId.getPrivateKey( + mnemonic: mnemonics, + private: privateKey, + ); + expect(data, stringPrivateKey); + }); + + test('getUserIdentity returns correct value', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.getUserIdentity( + mnemonic: mnemonics, + private: privateKey, + network: 'polygon', + ); + expect(data.did, did); + expect(data.privateKey, stringPrivateKey); + }); + + test('getIdentity returns correct value', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.getIdentity( + mnemonic: mnemonics, + private: privateKey, + network: 'polygon', + ); + + expect(data, privateIdentityEntity); + }); + + test('addIdentity works correctly', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = + await polygonId.addIdentity(mnemonic: mnemonics, network: 'polygon'); + expect(data, privateIdentityEntity); + }); + + test('getIden3Message works correctly', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + + final data = await polygonId.getIden3Message(message: ''); + expect(data, iden3MessageEntity); + }); + + test('removeIdentity works correctly', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + + await polygonId.removeIdentity( + genesisDid: '', + network: '', + privateKey: '', + ); + verify(() => polygonIdSdk.identity.removeIdentity); + }); + + test('authenticate works correctly', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + + final data = await polygonId.authenticate( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + private: privateKey, + ); + + expect(data, true); + }); + + test('authenticate throws Exception', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + + final data = await polygonId.authenticate( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + ); + + expect(data, false); + }); + + test('getClaims works correctly', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.getClaims( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + private: privateKey, + ); + expect(data, []); + }); + + test('getClaims throws Exception', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + expect( + () => polygonId.getClaims( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + ), + throwsA(isA()), + ); + }); + + test('getClaimById works correctly', () async { + when(() => polygonIdSdk.credential).thenReturn(credential); + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.getClaimById( + network: 'polygon', + mnemonic: mnemonics, + private: privateKey, + claimId: '', + ); + expect(data, []); + }); + + test('backupIdentity works correctly', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.backupIdentity( + network: 'polygon', + mnemonic: mnemonics, + private: privateKey, + ); + expect(data, 'ok'); + }); + + test('backupIdrestoreIdentityentity works correctly', () async { + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.restoreIdentity( + network: 'polygon', + mnemonic: mnemonics, + encryptedDb: '', + private: privateKey, + ); + expect(data, privateIdentityEntity); + }); + + test('restoreClaims works correctly', () async { + when(() => polygonIdSdk.credential).thenReturn(credential); + + final data = await polygonId.restoreClaims( + privateIdentityEntity: PrivateIdentityEntity( + did: '', + privateKey: '', + profiles: {}, + publicKey: [], + ), + ); + expect(data, []); + }); + + test('getSchemas works correctly', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + + final data = await polygonId.getSchemas(message: iden3MessageEntity); + expect(data, >[]); + }); + + test('getClaimsFromIden3Message throws Exception', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + expect( + () => polygonId.getClaimsFromIden3Message( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + ), + throwsA(isA()), + ); + }); + + test('getClaimsFromIden3Message works correctly', () async { + when(() => polygonIdSdk.iden3comm).thenReturn(iden3comm); + when(() => polygonIdSdk.identity).thenReturn(identity); + final data = await polygonId.getClaimsFromIden3Message( + iden3MessageEntity: iden3MessageEntity, + network: 'polygon', + mnemonic: mnemonics, + private: privateKey, + ); + expect(data, []); }); }); } 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/pubspec.lock b/pubspec.lock index c1c52bf62..5efc42bde 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: archive - sha256: "6bd38d335f0954f5fad9c79e614604fbf03a0e5b975923dd001b6ea965ef5b4b" + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d url: "https://pub.dev" source: hosted - version: "3.6.0" + version: "3.6.1" args: dependency: transitive description: @@ -302,10 +302,10 @@ packages: dependency: transitive description: name: camera_android - sha256: b350ac087f111467e705b2b76cc1322f7f5bdc122aa83b4b243b0872f390d229 + sha256: "3af7f0b55f184d392d2eec238aaa30552ebeef2915e5e094f5488bf50d6d7ca2" url: "https://pub.dev" source: hosted - version: "0.10.9+2" + version: "0.10.9+3" camera_avfoundation: dependency: transitive description: @@ -997,25 +997,18 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" + sha256: c6b0b4c05c458e1c01ad9bcc14041dd7b1f6783d487be4386f793f47a8a4d03e url: "https://pub.dev" source: hosted - version: "2.0.19" + version: "2.0.20" flutter_secure_storage: dependency: transitive description: name: flutter_secure_storage -<<<<<<< HEAD - sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0" - url: "https://pub.dev" - source: hosted - version: "9.2.2" -======= sha256: ffdbb60130e4665d2af814a0267c481bcf522c41ae2e43caf69fa0146876d685 url: "https://pub.dev" source: hosted version: "9.0.0" ->>>>>>> october flutter_secure_storage_linux: dependency: transitive description: @@ -1230,18 +1223,18 @@ packages: dependency: "direct main" description: name: image_picker - sha256: "33974eca2e87e8b4e3727f1b94fa3abcb25afe80b6bc2c4d449a0e150aedf720" + sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" image_picker_android: dependency: transitive description: name: image_picker_android - sha256: "0f57fee1e8bfadf8cc41818bbcd7f72e53bb768a54d9496355d5e8a5681a19f1" + sha256: "4161e1f843d8480d2e9025ee22411778c3c9eb7e40076dcf2da23d8242b7b51c" url: "https://pub.dev" source: hosted - version: "0.8.12+1" + version: "0.8.12+3" image_picker_for_web: dependency: transitive description: @@ -1254,10 +1247,10 @@ packages: dependency: transitive description: name: image_picker_ios - sha256: "4824d8c7f6f89121ef0122ff79bb00b009607faecc8545b86bca9ab5ce1e95bf" + sha256: "6703696ad49f5c3c8356d576d7ace84d1faf459afb07accbb0fae780753ff447" url: "https://pub.dev" source: hosted - version: "0.8.11+2" + version: "0.8.12" image_picker_linux: dependency: transitive description: @@ -1380,47 +1373,26 @@ packages: dependency: transitive description: name: leak_tracker -<<<<<<< HEAD sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted version: "10.0.4" -======= - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" - url: "https://pub.dev" - source: hosted - version: "10.0.0" ->>>>>>> october leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing -<<<<<<< HEAD sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted version: "3.0.3" -======= - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 - url: "https://pub.dev" - source: hosted - version: "2.0.1" ->>>>>>> october leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing -<<<<<<< HEAD sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted version: "3.0.1" -======= - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 - url: "https://pub.dev" - source: hosted - version: "2.0.1" ->>>>>>> october linkify: dependency: transitive description: @@ -1449,10 +1421,10 @@ packages: dependency: transitive description: name: local_auth_android - sha256: e0e5b1ea247c5a0951c13a7ee13dc1beae69750e6a2e1910d1ed6a3cd4d56943 + sha256: "48dfb2d954da8ef6a77adfc93a29998f7729e9308eaa817e91dea4500317b2c8" url: "https://pub.dev" source: hosted - version: "1.0.38" + version: "1.0.39" local_auth_darwin: dependency: transitive description: @@ -1545,17 +1517,10 @@ packages: dependency: transitive description: name: meta -<<<<<<< HEAD sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted version: "1.12.0" -======= - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 - url: "https://pub.dev" - source: hosted - version: "1.11.0" ->>>>>>> october mime: dependency: "direct main" description: @@ -1600,10 +1565,10 @@ packages: dependency: "direct main" description: name: model_viewer_plus - sha256: "633efbd081efe9af8b149c5553fa1e3e83a298ccc151955b0fe9d56a666943be" + sha256: ad1a349510e199eb40d5da5c9f8fb1f63442f07842f7544a31d9d38ba9658c0d url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "1.8.0" nested: dependency: transitive description: @@ -1735,10 +1700,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d + sha256: "9c96da072b421e98183f9ea7464898428e764bc0ce5567f27ec8693442e72514" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.2.5" path_provider_foundation: dependency: transitive description: @@ -1791,10 +1756,10 @@ packages: dependency: transitive description: name: permission_handler_apple - sha256: e9ad66020b89ff1b63908f247c2c6f931c6e62699b756ef8b3c4569350cd8662 + sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 url: "https://pub.dev" source: hosted - version: "9.4.4" + version: "9.4.5" permission_handler_html: dependency: transitive description: @@ -2015,10 +1980,10 @@ packages: dependency: transitive description: name: rational - sha256: ba58e9e18df9abde280e8b10051e4bce85091e41e8e7e411b6cde2e738d357cf + sha256: cb808fb6f1a839e6fc5f7d8cb3b0a10e1db48b3be102de73938c627f0b636336 url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" retry: dependency: transitive description: @@ -2047,17 +2012,10 @@ packages: dependency: "direct main" description: name: screenshot -<<<<<<< HEAD sha256: "63817697a7835e6ce82add4228e15d233b74d42975c143ad8cfe07009fab866b" url: "https://pub.dev" source: hosted version: "3.0.0" -======= - sha256: d448f43130f49bc7eead1b267b3ea0291cb2450f037bb0a0ecce7aa4c65e2aee - url: "https://pub.dev" - source: hosted - version: "2.5.0" ->>>>>>> october scroll_to_index: dependency: transitive description: @@ -2141,10 +2099,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" + sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577" url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" shared_preferences_foundation: dependency: transitive description: @@ -2459,18 +2417,18 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" url: "https://pub.dev" source: hosted - version: "6.2.6" + version: "6.3.0" url_launcher_android: dependency: transitive description: name: url_launcher_android - sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9" + sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" url_launcher_ios: dependency: transitive description: @@ -2659,17 +2617,10 @@ packages: dependency: "direct main" description: name: webview_flutter_android -<<<<<<< HEAD - sha256: "2282ba2320af34b2bd5320156c664d73f3f022341ed78847bc87723bf88c142f" - url: "https://pub.dev" - source: hosted - version: "3.16.2" -======= - sha256: "0d21cfc3bfdd2e30ab2ebeced66512b91134b39e72e97b43db2d47dda1c4e53a" + sha256: f42447ca49523f11d8f70abea55ea211b3cafe172dd7a0e7ac007bb35dd356dc url: "https://pub.dev" source: hosted - version: "3.16.3" ->>>>>>> october + version: "3.16.4" webview_flutter_platform_interface: dependency: transitive description: @@ -2690,17 +2641,10 @@ packages: dependency: transitive description: name: win32 -<<<<<<< HEAD sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4 url: "https://pub.dev" source: hosted version: "5.5.1" -======= - sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" - url: "https://pub.dev" - source: hosted - version: "5.5.0" ->>>>>>> october win32_registry: dependency: transitive description: @@ -2766,10 +2710,5 @@ packages: source: hosted version: "2.2.1" sdks: -<<<<<<< HEAD dart: ">=3.4.0 <4.0.0" flutter: ">=3.22.0" -======= - dart: ">=3.3.0 <4.0.0" - flutter: ">=3.19.0" ->>>>>>> october diff --git a/pubspec.yaml b/pubspec.yaml index 01c3a2092..1a30f23be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: altme description: AltMe Flutter App -version: 0.0.1+1 -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +version: 2.5.9+459 +publish_to: "none" # Remove this line if you wish to publish to pub.dev environment: sdk: ">=3.1.0 <4.0.0" diff --git a/script.sh b/script.sh index 7983327a4..6a98ab97d 100755 --- a/script.sh +++ b/script.sh @@ -1,17 +1,17 @@ function pub { - fvm flutter clean + flutter clean for d in `ls packages`; do ( cd "packages/$d" - fvm flutter clean - fvm flutter pub get - fvm flutter pub upgrade + flutter clean + flutter pub get + flutter pub upgrade ) done - fvm flutter pub get - fvm flutter pub upgrade + flutter pub get + flutter pub upgrade } function buildRunner { @@ -21,10 +21,10 @@ function buildRunner { ( echo "$d" cd "packages/$d" - fvm flutter packages pub run build_runner build --delete-conflicting-outputs + dart pub run build_runner build --delete-conflicting-outputs ) done - fvm flutter packages pub run build_runner build --delete-conflicting-outputs + dart pub run build_runner build --delete-conflicting-outputs } function podUpdate { @@ -41,17 +41,17 @@ function podUpdate { if [[ "$*" == *-runDev* ]]; then echo "flutter run development" - fvm flutter run --flavor development --target lib/main_development.dart + flutter run --flavor development --target lib/main_development.dart elif [[ "$*" == *-runstage* ]]; then echo "flutter run staging" - fvm flutter run --flavor staging --target lib/main_staging.dart + flutter run --flavor staging --target lib/main_staging.dart elif [[ "$*" == *-run* ]]; then echo "flutter run production" - fvm flutter run --flavor production --target lib/main_production.dart + flutter run --flavor production --target lib/main_production.dart elif [[ "$*" == *-pod* ]]; then @@ -62,7 +62,7 @@ then buildRunner echo "deploy android" echo "Make sure you are in right branch" - fvm flutter build appbundle --flavor "production" --target "lib/main_production.dart" + flutter build appbundle --flavor "production" --target "lib/main_production.dart" # cd android # fastlane deploy echo "app bundle deployed on internal testing track" @@ -74,7 +74,7 @@ then podUpdate echo "deploy ios" echo "Make sure you are in right branch" - fvm flutter build ios --release --flavor "production" --target "lib/main_production.dart" + flutter build ios --release --flavor "production" --target "lib/main_production.dart" cd ios fastlane beta elif [[ "$*" == *-pub* ]]; 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/blockchain_type_test.dart b/test/app/shared/enum/type/blockchain_type_test.dart index 8afe660a7..d7ac7856c 100644 --- a/test/app/shared/enum/type/blockchain_type_test.dart +++ b/test/app/shared/enum/type/blockchain_type_test.dart @@ -34,18 +34,28 @@ void main() { test('BlockchainType chain returns correct value', () { expect(() => BlockchainType.tezos.chain, throwsA(isA())); expect( - BlockchainType.ethereum.chain, equals('${Parameters.NAMESPACE}:1')); + BlockchainType.ethereum.chain, + equals('${Parameters.NAMESPACE}:1'), + ); expect( - BlockchainType.fantom.chain, equals('${Parameters.NAMESPACE}:250')); + BlockchainType.fantom.chain, + equals('${Parameters.NAMESPACE}:250'), + ); expect( - BlockchainType.polygon.chain, equals('${Parameters.NAMESPACE}:137')); + BlockchainType.polygon.chain, + equals('${Parameters.NAMESPACE}:137'), + ); expect( - BlockchainType.binance.chain, equals('${Parameters.NAMESPACE}:56')); + BlockchainType.binance.chain, + equals('${Parameters.NAMESPACE}:56'), + ); }); test('BlockchainType chainId returns correct value', () { expect( - () => BlockchainType.tezos.chainId, throwsA(isA())); + () => BlockchainType.tezos.chainId, + throwsA(isA()), + ); expect(BlockchainType.ethereum.chainId, equals(1)); expect(BlockchainType.fantom.chainId, equals(250)); expect(BlockchainType.polygon.chainId, equals(137)); @@ -53,93 +63,171 @@ void main() { }); test('BlockchainType derivePathIndexKey returns correct value', () { - expect(BlockchainType.tezos.derivePathIndexKey, - equals(SecureStorageKeys.tezosDerivePathIndex)); - expect(BlockchainType.ethereum.derivePathIndexKey, - equals(SecureStorageKeys.ethereumDerivePathIndex)); - expect(BlockchainType.fantom.derivePathIndexKey, - equals(SecureStorageKeys.fantomDerivePathIndex)); - expect(BlockchainType.polygon.derivePathIndexKey, - equals(SecureStorageKeys.polygonDerivePathIndex)); - expect(BlockchainType.binance.derivePathIndexKey, - equals(SecureStorageKeys.binanceDerivePathIndex)); + expect( + BlockchainType.tezos.derivePathIndexKey, + equals(SecureStorageKeys.tezosDerivePathIndex), + ); + expect( + BlockchainType.ethereum.derivePathIndexKey, + equals(SecureStorageKeys.ethereumDerivePathIndex), + ); + expect( + BlockchainType.fantom.derivePathIndexKey, + equals(SecureStorageKeys.fantomDerivePathIndex), + ); + expect( + BlockchainType.polygon.derivePathIndexKey, + equals(SecureStorageKeys.polygonDerivePathIndex), + ); + expect( + BlockchainType.binance.derivePathIndexKey, + equals(SecureStorageKeys.binanceDerivePathIndex), + ); }); test('BlockchainType credentialManifest returns correct value', () { expect( - jsonEncode(BlockchainType.tezos.credentialManifest), - equals(jsonEncode(CredentialManifest.fromJson( - ConstantsJson.tezosAssociatedAddressCredentialManifestJson)))); + jsonEncode(BlockchainType.tezos.credentialManifest), + equals( + jsonEncode( + CredentialManifest.fromJson( + ConstantsJson.tezosAssociatedAddressCredentialManifestJson, + ), + ), + ), + ); expect( - jsonEncode(BlockchainType.ethereum.credentialManifest), - equals(jsonEncode(CredentialManifest.fromJson( - ConstantsJson.ethereumAssociatedAddressCredentialManifestJson)))); + jsonEncode(BlockchainType.ethereum.credentialManifest), + equals( + jsonEncode( + CredentialManifest.fromJson( + ConstantsJson.ethereumAssociatedAddressCredentialManifestJson, + ), + ), + ), + ); expect( - jsonEncode(BlockchainType.fantom.credentialManifest), - equals(jsonEncode(CredentialManifest.fromJson( - ConstantsJson.fantomAssociatedAddressCredentialManifestJson)))); + jsonEncode(BlockchainType.fantom.credentialManifest), + equals( + jsonEncode( + CredentialManifest.fromJson( + ConstantsJson.fantomAssociatedAddressCredentialManifestJson, + ), + ), + ), + ); expect( - jsonEncode(BlockchainType.polygon.credentialManifest), - equals(jsonEncode(CredentialManifest.fromJson( - ConstantsJson.polygonAssociatedAddressCredentialManifestJson)))); + jsonEncode(BlockchainType.polygon.credentialManifest), + equals( + jsonEncode( + CredentialManifest.fromJson( + ConstantsJson.polygonAssociatedAddressCredentialManifestJson, + ), + ), + ), + ); expect( - jsonEncode(BlockchainType.binance.credentialManifest), - equals(jsonEncode(CredentialManifest.fromJson( - ConstantsJson.binanceAssociatedAddressCredentialManifestJson)))); + jsonEncode(BlockchainType.binance.credentialManifest), + equals( + jsonEncode( + CredentialManifest.fromJson( + ConstantsJson.binanceAssociatedAddressCredentialManifestJson, + ), + ), + ), + ); }); test('BlockchainType filter returns correct value', () { expect( - jsonEncode(BlockchainType.tezos.filter.toJson()), - equals(jsonEncode( - Filter(type: 'String', pattern: 'TezosAssociatedAddress') - .toJson()))); - expect( - jsonEncode(BlockchainType.ethereum.filter.toJson()), - equals(jsonEncode( - Filter(type: 'String', pattern: 'EthereumAssociatedAddress') - .toJson()))); - expect( - jsonEncode(BlockchainType.fantom.filter.toJson()), - equals(jsonEncode( - Filter(type: 'String', pattern: 'FantomAssociatedAddress') - .toJson()))); - expect( - jsonEncode(BlockchainType.polygon.filter.toJson()), - equals(jsonEncode( - Filter(type: 'String', pattern: 'PolygonAssociatedAddress') - .toJson()))); - expect( - jsonEncode(BlockchainType.binance.filter.toJson()), - equals(jsonEncode( - Filter(type: 'String', pattern: 'BinanceAssociatedAddress') - .toJson()))); + jsonEncode(BlockchainType.tezos.filter.toJson()), + equals( + jsonEncode( + Filter(type: 'String', pattern: 'TezosAssociatedAddress').toJson(), + ), + ), + ); + expect( + jsonEncode(BlockchainType.ethereum.filter.toJson()), + equals( + jsonEncode( + Filter(type: 'String', pattern: 'EthereumAssociatedAddress') + .toJson(), + ), + ), + ); + expect( + jsonEncode(BlockchainType.fantom.filter.toJson()), + equals( + jsonEncode( + Filter(type: 'String', pattern: 'FantomAssociatedAddress').toJson(), + ), + ), + ); + expect( + jsonEncode(BlockchainType.polygon.filter.toJson()), + equals( + jsonEncode( + Filter(type: 'String', pattern: 'PolygonAssociatedAddress') + .toJson(), + ), + ), + ); + expect( + jsonEncode(BlockchainType.binance.filter.toJson()), + equals( + jsonEncode( + Filter(type: 'String', pattern: 'BinanceAssociatedAddress') + .toJson(), + ), + ), + ); }); test('BlockchainType connectionBridge returns correct value', () { - expect(BlockchainType.tezos.connectionBridge, - equals(ConnectionBridgeType.beacon)); - expect(BlockchainType.ethereum.connectionBridge, - equals(ConnectionBridgeType.walletconnect)); - expect(BlockchainType.fantom.connectionBridge, - equals(ConnectionBridgeType.walletconnect)); - expect(BlockchainType.polygon.connectionBridge, - equals(ConnectionBridgeType.walletconnect)); - expect(BlockchainType.binance.connectionBridge, - equals(ConnectionBridgeType.walletconnect)); + expect( + BlockchainType.tezos.connectionBridge, + equals(ConnectionBridgeType.beacon), + ); + expect( + BlockchainType.ethereum.connectionBridge, + equals(ConnectionBridgeType.walletconnect), + ); + expect( + BlockchainType.fantom.connectionBridge, + equals(ConnectionBridgeType.walletconnect), + ); + expect( + BlockchainType.polygon.connectionBridge, + equals(ConnectionBridgeType.walletconnect), + ); + expect( + BlockchainType.binance.connectionBridge, + equals(ConnectionBridgeType.walletconnect), + ); }); test('BlockchainType networks returns correct value', () { - expect(BlockchainType.tezos.networks, - equals([TezosNetwork.mainNet(), TezosNetwork.ghostnet()])); - expect(BlockchainType.ethereum.networks, - equals([EthereumNetwork.mainNet(), EthereumNetwork.testNet()])); - expect(BlockchainType.fantom.networks, - equals([FantomNetwork.mainNet(), FantomNetwork.testNet()])); - expect(BlockchainType.polygon.networks, - equals([PolygonNetwork.mainNet(), PolygonNetwork.testNet()])); - expect(BlockchainType.binance.networks, - equals([BinanceNetwork.mainNet(), BinanceNetwork.testNet()])); + expect( + BlockchainType.tezos.networks, + equals([TezosNetwork.mainNet(), TezosNetwork.ghostnet()]), + ); + expect( + BlockchainType.ethereum.networks, + equals([EthereumNetwork.mainNet(), EthereumNetwork.testNet()]), + ); + expect( + BlockchainType.fantom.networks, + equals([FantomNetwork.mainNet(), FantomNetwork.testNet()]), + ); + expect( + BlockchainType.polygon.networks, + equals([PolygonNetwork.mainNet(), PolygonNetwork.testNet()]), + ); + expect( + BlockchainType.binance.networks, + equals([BinanceNetwork.mainNet(), BinanceNetwork.testNet()]), + ); }); test('BlockchainType isDisabled returns correct value', () { 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/pin_code/view/pin_code_page_test.dart b/test/pin_code/view/pin_code_page_test.dart new file mode 100644 index 000000000..92192333d --- /dev/null +++ b/test/pin_code/view/pin_code_page_test.dart @@ -0,0 +1,126 @@ +// import 'package:altme/app/app.dart'; +// import 'package:altme/dashboard/dashboard.dart'; +// import 'package:altme/flavor/flavor.dart'; +// import 'package:altme/pin_code/pin_code.dart'; +// import 'package:bloc_test/bloc_test.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_bloc/flutter_bloc.dart'; +// import 'package:flutter_test/flutter_test.dart'; +// import 'package:mockingjay/mockingjay.dart'; +// import 'package:secure_storage/secure_storage.dart'; + +// import '../../helpers/helpers.dart'; + +// class MockProfleCubit extends MockCubit implements ProfileCubit { +// @override +// final state = ProfileState(model: ProfileModel.empty()); +// } + +// class MockSecureStorageProvider extends Mock implements SecureStorageProvider {} + +// class MockLocalAuthApi extends Mock implements LocalAuthApi {} + +// class MockFlavorCubit extends MockCubit implements FlavorCubit { +// @override +// final state = FlavorMode.development; +// } + +// void main() { +// group('Pincode Page', () { +// final PinCodeViewCubit pinCodeViewCubit = PinCodeViewCubit(); +// final MockNavigator navigator = MockNavigator(); +// final MockSecureStorageProvider secureStorageProvider = +// MockSecureStorageProvider(); +// final MockProfleCubit profleCubit = MockProfleCubit(); +// final MockLocalAuthApi localAuthApi = MockLocalAuthApi(); +// final MockFlavorCubit flavorCubit = MockFlavorCubit(); + +// setUpAll(() { +// when(() => secureStorageProvider.get(any())).thenAnswer((_) async => ''); + +// when(() => secureStorageProvider.set(any(), any())) +// .thenAnswer((_) async => Future.value()); + +// when(navigator.canPop).thenReturn(true); +// when(() => navigator.push(any())).thenAnswer((_) async {}); +// when(() => navigator.pushAndRemoveUntil(any(), any())) +// .thenAnswer((_) async {}); +// when(() => navigator.pushReplacement(any())) +// .thenAnswer((_) async {}); +// }); + +// testWidgets('is routable', (tester) async { +// await tester.pumpApp( +// MockNavigatorProvider( +// navigator: navigator, +// child: Builder( +// builder: (context) => Scaffold( +// floatingActionButton: FloatingActionButton( +// onPressed: () { +// Navigator.of(context).push( +// PinCodePage.route( +// isValidCallback: () {}, +// walletProtectionType: WalletProtectionType.FA2, +// ), +// ); +// }, +// ), +// ), +// ), +// ), +// ); +// await tester.tap(find.byType(FloatingActionButton)); +// await tester.pumpAndSettle(); + +// verify( +// () => navigator.push( +// any( +// that: isRoute( +// whereName: equals('/pinCodePage'), +// ), +// ), +// ), +// ).called(1); +// }); + +// testWidgets('renders PinCodePage', (tester) async { +// await tester.pumpApp( +// MultiBlocProvider( +// providers: [ +// BlocProvider.value(value: profleCubit), +// BlocProvider.value(value: pinCodeViewCubit), +// BlocProvider.value(value: flavorCubit), +// ], +// child: PinCodePage( +// isValidCallback: () {}, +// walletProtectionType: WalletProtectionType.FA2, +// secureStorageProvider: secureStorageProvider, +// localAuthApi: localAuthApi, +// ), +// ), +// ); +// expect(find.byType(PinCodeView), findsOneWidget); +// }); + +// testWidgets('renders UI correctly', (tester) async { +// await tester.pumpApp( +// MultiBlocProvider( +// providers: [ +// BlocProvider.value(value: profleCubit), +// BlocProvider.value(value: pinCodeViewCubit), +// BlocProvider.value(value: flavorCubit), +// ], +// child: PinCodeView( +// isValidCallback: () {}, +// walletProtectionType: WalletProtectionType.FA2, +// secureStorageProvider: secureStorageProvider, +// localAuthApi: localAuthApi, +// profileCubit: profleCubit, +// ), +// ), +// ); +// expect(find.byType(BasePage), findsOneWidget); +// expect(find.byType(PinCodeWidget), findsOneWidget); +// }); +// }); +// } 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..f1fbb7566 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -11,85 +11,95 @@ void main() { test('CustomColorScheme Test', () { const colorScheme = ColorScheme.dark(); - expect(colorScheme.redColor, const Color(0xFFFF0045)); - expect(colorScheme.transactionApplied, const Color(0xFF00B267)); - expect(colorScheme.transactionFailed, const Color(0xFFFF0045)); - expect(colorScheme.transactionSkipped, const Color(0xFFFF5F0A)); - expect(colorScheme.activeColorOfNetwork, const Color(0xFF2C7DF7)); - expect(colorScheme.greyText, const Color(0xFFD1CCE3)); - expect(colorScheme.kycKeyIconColor, const Color(0xFF86809D)); - expect(colorScheme.lightPurple, const Color(0xFF5F556F)); - expect(colorScheme.popupBackground, const Color(0xff271C38)); - expect(colorScheme.cardHighlighted, const Color(0xFF251F38)); - expect(colorScheme.defaultDialogDark, const Color(0xFF322643)); - expect(colorScheme.closeIconColor, const Color(0xFFA79ABA)); - expect(colorScheme.kycVerifyButton, const Color(0xFF0045FF)); - expect(colorScheme.checkMarkColor, const Color(0xFF00B267)); - expect(colorScheme.accountBottomSheetBorder, equals(Colors.grey[200])); - expect(colorScheme.digitPrimaryColor, equals(Colors.white)); - expect(colorScheme.digitFillColor, equals(Colors.transparent)); - expect(colorScheme.disabledBgColor, const Color(0xFF6A5F7B)); - expect(colorScheme.disabledTextColor, const Color(0xFF000000)); - expect(colorScheme.darkGradientStartColor, const Color(0xff0A0F19)); - expect(colorScheme.darkGradientEndColor, const Color(0xff25095B)); - expect(colorScheme.transparent, equals(Colors.transparent)); - expect(colorScheme.onOutlineButton, const Color(0xFF6600FF)); - 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.drawerSurface, const Color(0xff232630)); - expect(colorScheme.label, equals(Colors.white)); - expect(colorScheme.unSelectedLabel, const Color(0xff86809D)); - expect(colorScheme.leadingButton, const Color(0xffF1EFF8)); - 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.markDownH1, equals(Colors.white)); - expect(colorScheme.markDownH2, equals(Colors.white)); - expect(colorScheme.markDownP, const Color(0xFFD1CCE3)); - expect(colorScheme.markDownA, const Color(0xff517bff)); - expect(colorScheme.subtitle1, equals(Colors.white)); - 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.star, const Color(0xFFFFB83D)); - expect(colorScheme.genderIcon, const Color(0xFF212121)); - expect(colorScheme.activeCredential, equals(Colors.green)); - expect(colorScheme.expiredCredential, equals(Colors.orange)); - expect(colorScheme.revokedCredential, equals(Colors.red)); - expect(colorScheme.buttonDisabled, const Color(0xFF424242)); - expect(colorScheme.alertErrorMessage, equals(Colors.red)); - expect(colorScheme.alertWarningMessage, equals(Colors.yellow)); - 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.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.startButtonColorA, const Color(0xff18ACFF)); - expect(colorScheme.startButtonColorB, const Color(0xff6600FF)); - expect(colorScheme.associatedWalletBorder, const Color(0xff524B67)); - expect(colorScheme.deleteColor, const Color(0xff322643)); - expect(colorScheme.blueColor, const Color(0xff322643)); - expect(colorScheme.titleColor, const Color(0xffD1CCE3)); - expect(colorScheme.valueColor, const Color(0xffFFFFFF)); - expect(colorScheme.lightGrey, const Color(0xFF616161)); - expect(colorScheme.darkGrey, const Color(0xFF212121)); - expect(colorScheme.activeColor, const Color(0xFF08B530)); - expect(colorScheme.inactiveColor, const Color(0xFFFF0045)); - expect(colorScheme.beaconBorder, const Color(0xff86809D)); - expect(colorScheme.cardBackground, const Color(0xFF211F33)); + expect(colorScheme.error, const Color(0xFFFF0045)); + expect(colorScheme.onTertiary, const Color(0xFF00B267)); + expect(colorScheme.error, const Color(0xFFFF0045)); + expect(colorScheme.onErrorContainer, const Color(0xFFFF5F0A)); + expect(colorScheme.primary, const Color(0xFF2C7DF7)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFFD1CCE3)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFF86809D)); + expect(colorScheme.secondary, const Color(0xFF5F556F)); + expect(colorScheme.surface, const Color(0xff271C38)); + expect(colorScheme.surface, const Color(0xFF251F38)); + expect(colorScheme.surface, const Color(0xFF322643)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFFA79ABA)); + expect(colorScheme.primary, const Color(0xFF0045FF)); + expect(colorScheme.onTertiary, const Color(0xFF00B267)); + expect(colorScheme.onSurface.withOpacity(0.12), equals(Colors.grey[200])); + expect(colorScheme.onSurface, equals(Colors.white)); + expect(Colors.transparent, equals(Colors.transparent)); + expect(colorScheme.onSurface.withOpacity(0.12), const Color(0xFF6A5F7B)); + expect(colorScheme.onSurface.withOpacity(0.38), const Color(0xFF000000)); + expect(colorScheme.surface, const Color(0xff0A0F19)); + expect(colorScheme.surface, const Color(0xff25095B)); + expect(Colors.transparent, equals(Colors.transparent)); + expect(colorScheme.primary, const Color(0xFF6600FF)); + expect(colorScheme.onPrimary, equals(Colors.white)); + expect(colorScheme.surface, const Color(0xff25095B)); + expect(colorScheme.surface, equals(colorScheme.surface)); + expect( + colorScheme.surface.withOpacity(0.07), + equals(const Color(0xff707070).withOpacity(0.07)), + ); + expect(colorScheme.surface, const Color(0xff232630)); + expect(colorScheme.onSurface, equals(Colors.white)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xff86809D)); + expect(colorScheme.onSurface, const Color(0xffF1EFF8)); + expect(colorScheme.surface, equals(colorScheme.surface)); + expect(colorScheme.surface, const Color(0xff0B0514)); + expect(colorScheme.onSurface.withOpacity(0.12), const Color(0xFFDDCEF4)); + expect( + colorScheme.onSurface.withOpacity(0.2), + const Color(0xFFFFFFFF).withOpacity(0.2), + ); + expect(colorScheme.onSurface, equals(Colors.white)); + expect(colorScheme.onSurface, equals(Colors.white)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFFD1CCE3)); + expect(colorScheme.primary, const Color(0xff517bff)); + expect(colorScheme.onSurface, equals(Colors.white)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFF8B8C92)); + expect(colorScheme.onSurface, const Color(0xFF212121)); + expect(colorScheme.onSurface.withOpacity(0.12), const Color(0xFF424242)); + expect( + colorScheme.primary.withOpacity(0.05), + equals(const Color(0xff3700b3).withOpacity(0.05)), + ); + expect(colorScheme.onErrorContainer, const Color(0xFFFFB83D)); + expect(colorScheme.onSurface, const Color(0xFF212121)); + expect(colorScheme.onTertiary, equals(Colors.green)); + expect(colorScheme.onErrorContainer, equals(Colors.orange)); + expect(colorScheme.error, equals(Colors.red)); + expect(colorScheme.onSurface.withOpacity(0.38), const Color(0xFF424242)); + expect(colorScheme.error, equals(Colors.red)); + expect(colorScheme.onErrorContainer, equals(Colors.yellow)); + expect(colorScheme.outline, equals(Colors.cyan)); + expect(colorScheme.onTertiary, equals(Colors.green)); + expect(colorScheme.surface, const Color(0xff2B1C48)); + expect( + colorScheme.shadow.withOpacity(0.16), + const Color(0xff000000).withOpacity(0.16), + ); + expect(colorScheme.primary, const Color(0xff430F91)); + expect(colorScheme.onSurface, const Color(0xffF5F5F5)); + expect(colorScheme.secondaryContainer, const Color(0xFF280164)); + expect(colorScheme.surface, const Color(0xFF211F33)); + expect( + colorScheme.onSurface.withOpacity(0.15), + equals(Colors.grey.withOpacity(0.15)), + ); + expect(colorScheme.primary, const Color(0xff18ACFF)); + expect(colorScheme.primaryContainer, const Color(0xff6600FF)); + expect(colorScheme.onSurface.withOpacity(0.12), const Color(0xff524B67)); + expect(colorScheme.surface, const Color(0xff322643)); + expect(colorScheme.surface, const Color(0xff322643)); + expect(colorScheme.onSurface, const Color(0xffD1CCE3)); + expect(colorScheme.onSurface, const Color(0xffFFFFFF)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xFF616161)); + expect(colorScheme.onSurface, const Color(0xFF212121)); + expect(colorScheme.onTertiary, const Color(0xFF08B530)); + expect(colorScheme.error, const Color(0xFFFF0045)); + expect(colorScheme.onSurface.withOpacity(0.6), const Color(0xff86809D)); + expect(colorScheme.surface, const Color(0xFF211F33)); }); test('CustomTextTheme extension test', () { @@ -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);