From a89d278f6205d8d66a2e610e54b4ff32f09b7fe5 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Fri, 31 May 2024 08:38:46 +0000 Subject: [PATCH 01/48] unplug config caching --- packages/oidc4vc/lib/src/oidc4vc.dart | 43 ++++++++++++++------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index c00c19d65..84aa85714 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1758,27 +1758,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 +1786,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 { From de0cd269eb182b5680499cb23c6888edfc86fb8d Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 31 May 2024 14:27:18 +0545 Subject: [PATCH 02/48] package update and add some test for pincode but commented for now --- pubspec.yaml | 2 +- test/pin_code/view/pin_code_page_test.dart | 126 +++++++++++++++++++++ 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 test/pin_code/view/pin_code_page_test.dart diff --git a/pubspec.yaml b/pubspec.yaml index ba245593f..1a30f23be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: altme description: AltMe Flutter App version: 2.5.9+459 -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +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/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); +// }); +// }); +// } From 60f5ba02cabc56469f1e7af4faef3ca26d9ac9e6 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 31 May 2024 14:31:03 +0545 Subject: [PATCH 03/48] Add builder in more pages to avoid provider error --- lib/onboarding/tos/view/onboarding_tos_page.dart | 8 ++++++-- .../view/onboarding_verify_phrase.dart | 16 ++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/onboarding/tos/view/onboarding_tos_page.dart b/lib/onboarding/tos/view/onboarding_tos_page.dart index a9de6740c..2379327fa 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(), + ); + }, ), ); } 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(), + ); + }, ), ); } From 0aa043dc72905d1868b1cde9b022ab49dab4b075 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 31 May 2024 14:36:54 +0545 Subject: [PATCH 04/48] delete fvm config --- .fvm/fvm_config.json | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .fvm/fvm_config.json 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 From 0c7bd1f4474847816683c160b28599023746c4b3 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 31 May 2024 16:29:19 +0545 Subject: [PATCH 05/48] add some polygon id test --- packages/polygonid/lib/src/polygonid.dart | 88 ++++++++----------- packages/polygonid/pubspec.yaml | 1 + .../polygonid/test/src/polygonid_test.dart | 47 +++++++++- 3 files changed, 85 insertions(+), 51 deletions(-) diff --git a/packages/polygonid/lib/src/polygonid.dart b/packages/polygonid/lib/src/polygonid.dart index b13f2fba4..0492af428 100644 --- a/packages/polygonid/lib/src/polygonid.dart +++ b/packages/polygonid/lib/src/polygonid.dart @@ -21,15 +21,21 @@ import 'package:web3dart/web3dart.dart'; /// {@endtemplate} class PolygonId { /// {@macro polygonid} - factory PolygonId() { - return _instance ??= PolygonId._(); + factory PolygonId({PolygonIdSdk? polygonIdSdk}) { + if (polygonIdSdk != null) { + _instance.polygonIdSdk = polygonIdSdk; + return _instance; + } else { + _instance.polygonIdSdk = PolygonIdSdk.I; + 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'; @@ -75,7 +81,7 @@ class PolygonId { required String network, required String ipfsUrl, }) { - return PolygonIdSdk.I.setEnv( + return polygonIdSdk.setEnv( env: EnvEntity( blockchain: blockchain, network: network, @@ -91,19 +97,19 @@ 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; + return polygonIdSdk.proof.initCircuitsDownloadAndGetInfoStream; } /// Create Identity @@ -121,9 +127,8 @@ class PolygonId { required String network, }) async { try { - final sdk = PolygonIdSdk.I; final secret = bip393.mnemonicToEntropy(mnemonic); - final identity = await sdk.identity.addIdentity(secret: secret); + final identity = await polygonIdSdk.identity.addIdentity(secret: secret); return identity; } catch (e) { if (e is IdentityAlreadyExistsException) { @@ -158,9 +163,8 @@ class PolygonId { required String mnemonic, required String network, }) async { - final sdk = PolygonIdSdk.I; final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, privateKey: privateKey, @@ -174,12 +178,11 @@ class PolygonId { required String mnemonic, required String network, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, ); - final identity = await sdk.identity.restoreIdentity( + final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, ); @@ -192,13 +195,12 @@ class PolygonId { 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 +209,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 +220,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 @@ -241,10 +241,8 @@ class PolygonId { required String mnemonic, }) async { try { - final sdk = PolygonIdSdk.I; - 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 +250,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, @@ -281,16 +279,14 @@ class PolygonId { required String network, }) async { try { - final sdk = PolygonIdSdk.I; - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + 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, @@ -311,16 +307,14 @@ class PolygonId { required String mnemonic, required String network, }) async { - final sdk = PolygonIdSdk.I; - final privateKey = await getPrivateKey(mnemonic: mnemonic); - final did = await sdk.identity.getDidIdentifier( + 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, @@ -345,12 +339,11 @@ class PolygonId { required String mnemonic, required String network, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, ); - return sdk.identity.backupIdentity( + return polygonIdSdk.identity.backupIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, ); @@ -375,12 +368,11 @@ class PolygonId { required String encryptedDb, required String network, }) async { - final sdk = PolygonIdSdk.I; final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, ); - final identity = await sdk.identity.restoreIdentity( + final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, genesisDid: userIdentity.did, encryptedDb: encryptedDb, @@ -401,9 +393,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 +408,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 @@ -440,17 +429,16 @@ class PolygonId { required String network, }) async { try { - final sdk = PolygonIdSdk.I; - final privateKey = await getPrivateKey(mnemonic: mnemonic); - 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, @@ -469,7 +457,6 @@ class PolygonId { required String mnemonic, required String network, }) async { - final sdk = PolygonIdSdk.I; var challenge = walletAddress; if (challenge.toLowerCase().startsWith('0x')) { @@ -485,7 +472,8 @@ class PolygonId { network: network, ); - 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..2c94e254b 100644 --- a/packages/polygonid/test/src/polygonid_test.dart +++ b/packages/polygonid/test/src/polygonid_test.dart @@ -1,11 +1,56 @@ // ignore_for_file: prefer_const_constructors 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/sdk/polygon_id_sdk.dart'; + +class MockPolygonIdSdk extends Mock implements PolygonIdSdk {} void main() { + final MockPolygonIdSdk polygonIdSdk = MockPolygonIdSdk(); + final PolygonId polygonId = PolygonId(polygonIdSdk: polygonIdSdk); + + 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); }); }); } From 96985004ba3ddbb5c2a3dbb970c0a5596485ce4c Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 16:33:18 +0545 Subject: [PATCH 06/48] add polygon id test --- packages/polygonid/lib/src/polygonid.dart | 126 ++++-- .../polygonid/test/src/polygonid_test.dart | 416 ++++++++++++++++++ 2 files changed, 494 insertions(+), 48 deletions(-) diff --git a/packages/polygonid/lib/src/polygonid.dart b/packages/polygonid/lib/src/polygonid.dart index 0492af428..42c4046e3 100644 --- a/packages/polygonid/lib/src/polygonid.dart +++ b/packages/polygonid/lib/src/polygonid.dart @@ -22,13 +22,8 @@ import 'package:web3dart/web3dart.dart'; class PolygonId { /// {@macro polygonid} factory PolygonId({PolygonIdSdk? polygonIdSdk}) { - if (polygonIdSdk != null) { - _instance.polygonIdSdk = polygonIdSdk; - return _instance; - } else { - _instance.polygonIdSdk = PolygonIdSdk.I; - return _instance; - } + _instance.polygonIdSdk = polygonIdSdk ?? PolygonIdSdk.I; + return _instance; } PolygonId._internal(); @@ -112,48 +107,23 @@ class PolygonId { return polygonIdSdk.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 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'); - } - } - } - /// 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; } @@ -162,8 +132,12 @@ class PolygonId { Future getUserIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, @@ -177,10 +151,12 @@ class PolygonId { Future getIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, @@ -189,6 +165,37 @@ class PolygonId { 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, @@ -239,9 +246,14 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String network, required String mnemonic, + Uint8List? private, }) async { try { - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); + final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, @@ -277,9 +289,13 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { try { - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, @@ -306,8 +322,12 @@ class PolygonId { required String claimId, required String mnemonic, required String network, + Uint8List? private, }) async { - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, network: network, @@ -338,10 +358,12 @@ class PolygonId { Future backupIdentity({ required String mnemonic, required String network, + Uint8List? private, }) async { final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); return polygonIdSdk.identity.backupIdentity( privateKey: userIdentity.privateKey, @@ -367,10 +389,12 @@ class PolygonId { required String mnemonic, required String encryptedDb, required String network, + Uint8List? private, }) async { final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); final identity = await polygonIdSdk.identity.restoreIdentity( privateKey: userIdentity.privateKey, @@ -427,9 +451,13 @@ class PolygonId { required Iden3MessageEntity iden3MessageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { try { - final privateKey = await getPrivateKey(mnemonic: mnemonic); + final privateKey = await getPrivateKey( + mnemonic: mnemonic, + private: private, + ); final did = await polygonIdSdk.identity.getDidIdentifier( blockchain: blockchain, @@ -456,6 +484,7 @@ class PolygonId { required Iden3MessageEntity contractIden3messageEntity, required String mnemonic, required String network, + Uint8List? private, }) async { var challenge = walletAddress; @@ -470,6 +499,7 @@ class PolygonId { final userIdentity = await getUserIdentity( mnemonic: mnemonic, network: network, + private: private, ); final List response = diff --git a/packages/polygonid/test/src/polygonid_test.dart b/packages/polygonid/test/src/polygonid_test.dart index 2c94e254b..0b97e8e78 100644 --- a/packages/polygonid/test/src/polygonid_test.dart +++ b/packages/polygonid/test/src/polygonid_test.dart @@ -1,9 +1,221 @@ // 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/iden3comm/domain/entities/proof/response/iden3comm_proof_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 {} @@ -11,6 +223,11 @@ void main() { final MockPolygonIdSdk polygonIdSdk = MockPolygonIdSdk(); final PolygonId polygonId = PolygonId(polygonIdSdk: polygonIdSdk); + final proof = MockProof(); + final identity = MockIdentity(); + final credential = MockCredential(); + final iden3comm = MockIden3comm(); + final env = EnvEntity( blockchain: 'polygon', network: 'network', @@ -52,5 +269,204 @@ void main() { 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, []); + }); }); } From 1c114f60c7400f8d2c3a3aee0b4102104f7d2d02 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 16:34:32 +0545 Subject: [PATCH 07/48] add polygon id in github workflow --- .github/workflows/polygonid.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/polygonid.yaml diff --git a/.github/workflows/polygonid.yaml b/.github/workflows/polygonid.yaml new file mode 100644 index 000000000..829e4145c --- /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.19.6 + min_coverage: 30 + working_directory: packages/polygonid + dart_sdk: 3.3.4 + build_runner: false From 99e3e1169d4cebc497ca83077d9f5f56d134bc6e Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 16:40:32 +0545 Subject: [PATCH 08/48] remove unused import --- packages/polygonid/test/src/polygonid_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/polygonid/test/src/polygonid_test.dart b/packages/polygonid/test/src/polygonid_test.dart index 0b97e8e78..0f0a68487 100644 --- a/packages/polygonid/test/src/polygonid_test.dart +++ b/packages/polygonid/test/src/polygonid_test.dart @@ -5,7 +5,6 @@ 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/iden3comm/domain/entities/proof/response/iden3comm_proof_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'; @@ -177,8 +176,9 @@ class MockIden3comm extends Mock implements Iden3comm { } @override - Future>> getSchemas( - {required Iden3MessageEntity message}) { + Future>> getSchemas({ + required Iden3MessageEntity message, + }) { return Future.value([]); } From 5fa34b0acbb042bb957f1c1b5942b8432e6f8db0 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 17:19:18 +0545 Subject: [PATCH 09/48] attempt to add didkit tests --- .github/workflows/did_kit.yaml | 14 +++ .../did_kit/lib/src/did_kit_provider.dart | 30 +++-- .../did_kit/lib/src/didkit_interface.dart | 14 +++ packages/did_kit/lib/src/didkit_wrapper.dart | 83 ++++++++++++++ ...t_test.dart => did_kit_provider_test.dart} | 103 +++++++++++++----- 5 files changed, 203 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/did_kit.yaml create mode 100644 packages/did_kit/lib/src/didkit_interface.dart create mode 100644 packages/did_kit/lib/src/didkit_wrapper.dart rename packages/did_kit/test/src/{did_kit_test.dart => did_kit_provider_test.dart} (55%) diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml new file mode 100644 index 000000000..b943dd1d6 --- /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.19.6 + min_coverage: 30 + working_directory: packages/did_kit + dart_sdk: 3.3.4 + build_runner: false 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..6d903edf7 --- /dev/null +++ b/packages/did_kit/lib/src/didkit_interface.dart @@ -0,0 +1,14 @@ +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); }); }); } From 96348def50694730c2d2bc61d4a7930717c788b2 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 17:29:48 +0545 Subject: [PATCH 10/48] Attempt to pass didkit test --- packages/did_kit/pubspec.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/did_kit/pubspec.yaml b/packages/did_kit/pubspec.yaml index 9c912fce4..cb5e9e4ff 100644 --- a/packages/did_kit/pubspec.yaml +++ b/packages/did_kit/pubspec.yaml @@ -8,7 +8,9 @@ environment: dependencies: didkit: - path: ../../../didkit/lib/flutter + git: + url: https://github.com/spruceid/didkit.git + path: lib/flutter flutter: sdk: flutter mocktail: ^1.0.2 From 7c990070dd4a49510b1e139dab8241ecf6c323c6 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 17:31:53 +0545 Subject: [PATCH 11/48] Attempt to pass didkit test --- packages/did_kit/lib/src/didkit_interface.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/did_kit/lib/src/didkit_interface.dart b/packages/did_kit/lib/src/didkit_interface.dart index 6d903edf7..be25ced3f 100644 --- a/packages/did_kit/lib/src/didkit_interface.dart +++ b/packages/did_kit/lib/src/didkit_interface.dart @@ -6,7 +6,10 @@ abstract class DIDKitInterface { Future issueCredential(String credential, String options, String key); Future verifyCredential(String credential, String options); Future issuePresentation( - String presentation, String options, String key); + String presentation, + String options, + String key, + ); Future verifyPresentation(String presentation, String options); Future resolveDID(String did, String inputMetadata); Future dereferenceDIDURL(String didUrl, String inputMetadata); From cbe4d87a30bc9c83a88235c522c61b31fe94b95f Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Mon, 3 Jun 2024 18:43:37 +0545 Subject: [PATCH 12/48] fix bug for polygon Id test --- packages/polygonid/lib/src/polygonid.dart | 12 ++++-------- packages/polygonid/test/src/polygonid_test.dart | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/polygonid/lib/src/polygonid.dart b/packages/polygonid/lib/src/polygonid.dart index 42c4046e3..87da919e8 100644 --- a/packages/polygonid/lib/src/polygonid.dart +++ b/packages/polygonid/lib/src/polygonid.dart @@ -20,18 +20,12 @@ import 'package:web3dart/web3dart.dart'; /// A Very Good Project created by Very Good CLI. /// {@endtemplate} class PolygonId { - /// {@macro polygonid} - factory PolygonId({PolygonIdSdk? polygonIdSdk}) { - _instance.polygonIdSdk = polygonIdSdk ?? PolygonIdSdk.I; - return _instance; - } + PolygonId({this.sdk}); - PolygonId._internal(); + final PolygonIdSdk? sdk; late PolygonIdSdk polygonIdSdk; - static final PolygonId _instance = PolygonId._internal(); - /// blockchain static const blockchain = 'polygon'; @@ -63,6 +57,8 @@ class PolygonId { ipfsUrl: ipfsUrl, ), ); + + polygonIdSdk = sdk ?? PolygonIdSdk.I; isInitialized = true; } diff --git a/packages/polygonid/test/src/polygonid_test.dart b/packages/polygonid/test/src/polygonid_test.dart index 0f0a68487..652cbf0b3 100644 --- a/packages/polygonid/test/src/polygonid_test.dart +++ b/packages/polygonid/test/src/polygonid_test.dart @@ -221,7 +221,7 @@ class MockPolygonIdSdk extends Mock implements PolygonIdSdk {} void main() { final MockPolygonIdSdk polygonIdSdk = MockPolygonIdSdk(); - final PolygonId polygonId = PolygonId(polygonIdSdk: polygonIdSdk); + final PolygonId polygonId = PolygonId(sdk: polygonIdSdk); final proof = MockProof(); final identity = MockIdentity(); From 8eb94d24967f69d49c774aece057ca269cd98ea7 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 13:07:26 +0545 Subject: [PATCH 13/48] some update for keygenerator --- packages/key_generator/pubspec.yaml | 6 +++--- packages/key_generator/test/src/key_generator_test.dart | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/key_generator/pubspec.yaml b/packages/key_generator/pubspec.yaml index 8feaaa36e..91c009179 100644 --- a/packages/key_generator/pubspec.yaml +++ b/packages/key_generator/pubspec.yaml @@ -23,7 +23,7 @@ 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..aee428e05 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 = From ca933bb9327dd2797426c59f4574b130e03272bb Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 13:39:26 +0545 Subject: [PATCH 14/48] feat: Update key generator test and update flutter and dart version for test --- .github/workflows/credential_manifest.yaml | 6 +- .github/workflows/cryptocurrency_keys.yaml | 6 +- .github/workflows/did_kit.yaml | 4 +- .github/workflows/jwt_decode.yaml | 6 +- .github/workflows/key_generator.yaml | 14 +++ .github/workflows/polygonid.yaml | 4 +- .github/workflows/secure_storage.yaml | 4 +- .../key_generator/lib/src/key_generator.dart | 1 - packages/key_generator/pubspec.yaml | 4 +- .../test/src/key_generator_test.dart | 93 +++++++++++-------- 10 files changed, 83 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/key_generator.yaml 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 index b943dd1d6..2647f7254 100644 --- a/.github/workflows/did_kit.yaml +++ b/.github/workflows/did_kit.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/did_kit - dart_sdk: 3.3.4 + dart_sdk: 3.4.1 build_runner: false 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/polygonid.yaml b/.github/workflows/polygonid.yaml index 829e4145c..507dffe6e 100644 --- a/.github/workflows/polygonid.yaml +++ b/.github/workflows/polygonid.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/polygonid - dart_sdk: 3.3.4 + 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/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 91c009179..819da38bd 100644 --- a/packages/key_generator/pubspec.yaml +++ b/packages/key_generator/pubspec.yaml @@ -13,15 +13,13 @@ 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: flutter_test: sdk: flutter diff --git a/packages/key_generator/test/src/key_generator_test.dart b/packages/key_generator/test/src/key_generator_test.dart index aee428e05..81f83783d 100644 --- a/packages/key_generator/test/src/key_generator_test.dart +++ b/packages/key_generator/test/src/key_generator_test.dart @@ -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); }); }); } From 25e0bd2c88852a1f9c176b94529a2757da360303 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 15:00:11 +0545 Subject: [PATCH 15/48] update polygon id test --- packages/polygonid/lib/src/polygonid.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/polygonid/lib/src/polygonid.dart b/packages/polygonid/lib/src/polygonid.dart index 87da919e8..b3557a778 100644 --- a/packages/polygonid/lib/src/polygonid.dart +++ b/packages/polygonid/lib/src/polygonid.dart @@ -20,12 +20,19 @@ import 'package:web3dart/web3dart.dart'; /// A Very Good Project created by Very Good CLI. /// {@endtemplate} class PolygonId { - PolygonId({this.sdk}); + factory PolygonId({PolygonIdSdk? sdk}) { + if (sdk != null) { + _instance.polygonIdSdk = sdk; + } + return _instance; + } - final PolygonIdSdk? sdk; + PolygonId._internal(); late PolygonIdSdk polygonIdSdk; + static final PolygonId _instance = PolygonId._internal(); + /// blockchain static const blockchain = 'polygon'; @@ -58,7 +65,7 @@ class PolygonId { ), ); - polygonIdSdk = sdk ?? PolygonIdSdk.I; + polygonIdSdk = PolygonIdSdk.I; isInitialized = true; } From c172c4bd9437fd53bd88b96b814d8f00810f3c1c Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 15:05:10 +0545 Subject: [PATCH 16/48] update didkit path --- packages/did_kit/pubspec.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/did_kit/pubspec.yaml b/packages/did_kit/pubspec.yaml index cb5e9e4ff..9c912fce4 100644 --- a/packages/did_kit/pubspec.yaml +++ b/packages/did_kit/pubspec.yaml @@ -8,9 +8,7 @@ environment: dependencies: didkit: - git: - url: https://github.com/spruceid/didkit.git - path: lib/flutter + path: ../../../didkit/lib/flutter flutter: sdk: flutter mocktail: ^1.0.2 From 6a29ba1465862b3d2874ad05f81eede5ccd8eb35 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 18:08:39 +0545 Subject: [PATCH 17/48] Update didkit path in github workflow --- .github/workflows/did_kit.yaml | 2 +- .github/workflows/flutter_package.yaml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml index 2647f7254..22c84751a 100644 --- a/.github/workflows/did_kit.yaml +++ b/.github/workflows/did_kit.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october with: flutter_channel: stable flutter_version: 3.22.1 diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index d84446759..7ac20afe3 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -101,6 +101,9 @@ jobs: - name: 📦 Install Dependencies run: | + if grep -q 'path: ../../../didkit/lib/flutter' pubspec.yaml; then + sed -i 's|path: ../../../didkit/lib/flutter|git:\n url: https://github.com/spruceid/didkit.git\n path: lib/flutter|' pubspec.yaml + fi flutter pub global activate very_good_cli very_good packages get --recursive --ignore=${{inputs.package_get_excludes}} @@ -131,4 +134,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}} From e9fece442584ce0628561e28974afd77573998ee Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 18:11:08 +0545 Subject: [PATCH 18/48] add oidc4vc in github workflow test --- .github/workflows/oidc4vc.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/oidc4vc.yaml diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml new file mode 100644 index 000000000..8b6639f97 --- /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@october + with: + flutter_channel: stable + flutter_version: 3.22.1 + min_coverage: 30 + working_directory: packages/oidc4vc + dart_sdk: 3.4.1 + build_runner: false From 53b56a25821685f009b1606ddf90fc3f99eb10cf Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Fri, 31 May 2024 10:35:21 +0000 Subject: [PATCH 19/48] merge pincode from jeprouvemonage --- lib/pin_code/cubit/pin_code_view_cubit.dart | 166 +++++++++++- lib/pin_code/cubit/pin_code_view_state.dart | 39 ++- lib/pin_code/pin_code.dart | 1 + lib/pin_code/typedef.dart | 1 - lib/pin_code/view/confirm_pin_code_page.dart | 51 ++-- lib/pin_code/view/delete_my_wallet_page.dart | 75 ++++++ .../view/enter_new_pin_code_page.dart | 13 +- lib/pin_code/view/pin_code_page.dart | 140 +++++----- lib/pin_code/widgets/delete_button.dart | 6 +- lib/pin_code/widgets/num_keyboard.dart | 12 +- lib/pin_code/widgets/pin_code_widget.dart | 254 +++++++++--------- lib/pin_code/widgets/widgets.dart | 1 + lib/pin_code/widgets/wrong_pincode_popup.dart | 57 ++++ 13 files changed, 552 insertions(+), 264 deletions(-) create mode 100644 lib/pin_code/view/delete_my_wallet_page.dart create mode 100644 lib/pin_code/widgets/wrong_pincode_popup.dart diff --git a/lib/pin_code/cubit/pin_code_view_cubit.dart b/lib/pin_code/cubit/pin_code_view_cubit.dart index b20135591..eeb77ed7c 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; + bool 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,115 @@ 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..9654197df 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,21 +71,23 @@ 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, + 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.background, + body: PinCodeWidget( + title: l10n.confirmYourPinCode, header: widget.isFromOnboarding ? MStepper( step: 1, @@ -105,24 +99,17 @@ class _ConfirmPinCodeViewState extends State { style: Theme.of(context).textTheme.labelLarge, ), cancelButton: Text( - l10n.cancel, - style: Theme.of(context).textTheme.labelLarge, + 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..e9eb85e46 --- /dev/null +++ b/lib/pin_code/view/delete_my_wallet_page.dart @@ -0,0 +1,75 @@ +import 'package:altme/app/shared/constants/image_strings.dart'; +import 'package:altme/app/shared/constants/sizes.dart'; +import 'package:altme/app/shared/widget/widget.dart'; +import 'package:altme/credentials/cubit/credentials_cubit.dart'; +import 'package:altme/l10n/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.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.icon80, + ), + 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: () { + Navigator.of(context).pop(); + context.read().reset(); + }, + ), + ], + ), + ); + } +} 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..987f7c01d 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, @@ -79,7 +76,6 @@ class _EnterNewPinCodeViewState extends State { backgroundColor: Theme.of(context).colorScheme.background, body: PinCodeWidget( title: l10n.enterNewPinCode, - passwordEnteredCallback: _onPasscodeEntered, header: widget.isFromOnboarding ? MStepper( step: 1, @@ -95,15 +91,16 @@ class _EnterNewPinCodeViewState extends State { style: Theme.of(context).textTheme.labelLarge, ), cancelCallback: _onPasscodeCancelled, + isNewCode: true, ), ); } - 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..08e859f3f 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -1,13 +1,10 @@ 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 +38,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,9 +68,15 @@ class PinCodeView extends StatefulWidget { } class _PinCodeViewState extends State { + final totalPermitedLoginAttempt = 3; final StreamController _verificationNotifier = StreamController.broadcast(); + @override + void initState() { + super.initState(); + } + @override void dispose() { _verificationNotifier.close(); @@ -87,81 +89,73 @@ class _PinCodeViewState extends State { return WillPopScope( onWillPop: () async => !widget.restrictToBack, child: BasePage( - backgroundColor: Theme.of(context).colorScheme.surface, + backgroundColor: Theme.of(context).colorScheme.background, + 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_widget.dart b/lib/pin_code/widgets/pin_code_widget.dart index 2a832a227..42e631536 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,21 @@ class PinCodeWidget extends StatefulWidget { this.cancelCallback, this.subTitle, this.header, - this.allowAction = true, + this.onLoginAttempt, + this.isNewCode = 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; // 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 +53,46 @@ 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) { + _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); + }, 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) { @@ -120,59 +123,86 @@ class _PinCodeWidgetState extends State const SizedBox(height: Sizes.spaceNormal), 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, + child: 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, + 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.space2XLarge, + 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 +229,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( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate( widget.passwordDigits, (index) => Container( - margin: - const EdgeInsets.all( + margin: const EdgeInsets.all( 8, ), child: Circle( allowAction: - widget.allowAction, + state.allowAction, filled: index < - enteredPasscode - .length, - circleUIConfig: widget - .circleUIConfig, - extraSize: - animation.value, + enteredPasscode.length, + circleUIConfig: + widget.circleUIConfig, ), ), ), - ); - }, ), ), ], @@ -271,30 +284,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 +302,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 +313,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..50a1c5377 --- /dev/null +++ b/lib/pin_code/widgets/wrong_pincode_popup.dart @@ -0,0 +1,57 @@ +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; + + /// be careful, BaseBottomSheet is a custom widget from jeprouvemonage + return BaseBottomSheet( + body: Column( + children: [ + Image.asset( + ImageStrings.warningCircle, + width: Sizes.icon80, + ), + const SizedBox( + height: Sizes.spaceLarge, + ), + Text( + l10n.codeSecretIncorrect, + 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(); + }, + ), + ], + ), + ); + } +} From f70468030c280343584681c5b0953eb423cb1a85 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Mon, 3 Jun 2024 16:28:44 +0000 Subject: [PATCH 20/48] migrate pincode system from jeprouvemonage --- .../helper_functions/reset_wallet.dart | 14 +++++++ .../reset_wallet/view/reset_wallet_menu.dart | 29 ++++++------- .../user_pin/view/user_pin_page.dart | 4 +- lib/l10n/arb/app_en.arb | 20 ++++++++- lib/l10n/untranslated.json | 39 +++++++++++++++-- lib/pin_code/view/delete_my_wallet_page.dart | 8 ++-- .../view/enter_new_pin_code_page.dart | 3 +- lib/pin_code/view/pin_code_page.dart | 4 -- lib/pin_code/widgets/pin_code_widget.dart | 42 +++++++++---------- lib/pin_code/widgets/wrong_pincode_popup.dart | 9 ++-- lib/splash/view/splash_page.dart | 33 ++++++++++++--- pubspec.lock | 16 +++---- script.sh | 4 +- 13 files changed, 152 insertions(+), 73 deletions(-) create mode 100644 lib/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart 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..c92d0aa7c 100644 --- a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart +++ b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart @@ -1,6 +1,7 @@ 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'; @@ -101,22 +102,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/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index fd119ac7a..f0014052c 100644 --- a/lib/dashboard/user_pin/view/user_pin_page.dart +++ b/lib/dashboard/user_pin/view/user_pin_page.dart @@ -38,7 +38,7 @@ class UserPinPage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => - PinCodeViewCubit(profileCubit: context.read()), + PinCodeViewCubit(), child: UserPinView( onCancel: onCancel, onProceed: onProceed, @@ -89,7 +89,6 @@ class _UserPinViewState extends State { body: PinCodeWidget( title: widget.txCode?.description ?? l10n.pleaseInsertTheSecredCodeReceived, - passwordEnteredCallback: _onPasscodeEntered, passwordDigits: widget.txCode?.length ?? 4, deleteButton: Text( l10n.delete, @@ -104,7 +103,6 @@ class _UserPinViewState extends State { Navigator.pop(context); widget.onProceed.call(pinCodeValue!); }, - shouldTriggerVerification: _verificationNotifier.stream, ), ), ); 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/pin_code/view/delete_my_wallet_page.dart b/lib/pin_code/view/delete_my_wallet_page.dart index e9eb85e46..e18555bc7 100644 --- a/lib/pin_code/view/delete_my_wallet_page.dart +++ b/lib/pin_code/view/delete_my_wallet_page.dart @@ -2,6 +2,7 @@ import 'package:altme/app/shared/constants/image_strings.dart'; import 'package:altme/app/shared/constants/sizes.dart'; import 'package:altme/app/shared/widget/widget.dart'; import 'package:altme/credentials/cubit/credentials_cubit.dart'; +import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -40,7 +41,7 @@ class DeleteMyWalletView extends StatelessWidget { ), Image.asset( ImageStrings.cardMissing, - width: Sizes.icon80, + width: Sizes.icon, ), const SizedBox( height: Sizes.spaceLarge, @@ -63,9 +64,8 @@ class DeleteMyWalletView extends StatelessWidget { ), MyElevatedButton( text: l10n.deleteMyWallet, - onPressed: () { - Navigator.of(context).pop(); - context.read().reset(); + 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 987f7c01d..97e60631c 100644 --- a/lib/pin_code/view/enter_new_pin_code_page.dart +++ b/lib/pin_code/view/enter_new_pin_code_page.dart @@ -91,7 +91,8 @@ class _EnterNewPinCodeViewState extends State { style: Theme.of(context).textTheme.labelLarge, ), cancelCallback: _onPasscodeCancelled, - isNewCode: true, + isNewCode: true, + isValidCallback: _isValidCallback, ), ); } diff --git a/lib/pin_code/view/pin_code_page.dart b/lib/pin_code/view/pin_code_page.dart index 08e859f3f..391b97a3e 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -1,4 +1,3 @@ -import 'dart:async'; import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; @@ -69,8 +68,6 @@ class PinCodeView extends StatefulWidget { class _PinCodeViewState extends State { final totalPermitedLoginAttempt = 3; - final StreamController _verificationNotifier = - StreamController.broadcast(); @override void initState() { @@ -79,7 +76,6 @@ class _PinCodeViewState extends State { @override void dispose() { - _verificationNotifier.close(); super.dispose(); } diff --git a/lib/pin_code/widgets/pin_code_widget.dart b/lib/pin_code/widgets/pin_code_widget.dart index 42e631536..920efa667 100644 --- a/lib/pin_code/widgets/pin_code_widget.dart +++ b/lib/pin_code/widgets/pin_code_widget.dart @@ -120,7 +120,7 @@ class _PinCodeWidgetState extends State 0.5, showPoweredBy: true, ), - const SizedBox(height: Sizes.spaceNormal), + const SizedBox(height: Sizes.spaceSmall), PinCodeTitle( title: widget.title, subTitle: state.allowAction @@ -134,11 +134,11 @@ class _PinCodeWidgetState extends State height: 40, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: List.generate( - widget.passwordDigits, - (index) => Container( - margin: const EdgeInsets.all(8), - child: Circle( + children: List.generate( + widget.passwordDigits, + (index) => Container( + margin: const EdgeInsets.all(8), + child: Circle( allowAction: state.allowAction, filled: index < enteredPasscode.length, @@ -152,13 +152,13 @@ class _PinCodeWidgetState extends State .error, ) : widget.circleUIConfig, - ), - ), ), + ), + ), ), ), SizedBox( - height: Sizes.space2XLarge, + height: Sizes.spaceSmall, child: isPincodeDifferent ? Text( l10n.pincodeDifferent, @@ -246,24 +246,24 @@ class _PinCodeWidgetState extends State const EdgeInsets.only(top: 20), height: 40, child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: List.generate( - widget.passwordDigits, - (index) => Container( + mainAxisAlignment: + MainAxisAlignment.center, + children: List.generate( + widget.passwordDigits, + (index) => Container( margin: const EdgeInsets.all( - 8, - ), - child: Circle( - allowAction: + 8, + ), + child: Circle( + allowAction: state.allowAction, - filled: index < + filled: index < enteredPasscode.length, circleUIConfig: widget.circleUIConfig, - ), - ), ), + ), + ), ), ), ], diff --git a/lib/pin_code/widgets/wrong_pincode_popup.dart b/lib/pin_code/widgets/wrong_pincode_popup.dart index 50a1c5377..9f1ac1a81 100644 --- a/lib/pin_code/widgets/wrong_pincode_popup.dart +++ b/lib/pin_code/widgets/wrong_pincode_popup.dart @@ -16,19 +16,18 @@ class WrongPinCodePopUp extends StatelessWidget { Widget build(BuildContext context) { final l10n = context.l10n; - /// be careful, BaseBottomSheet is a custom widget from jeprouvemonage - return BaseBottomSheet( + return BasePage( body: Column( children: [ Image.asset( - ImageStrings.warningCircle, - width: Sizes.icon80, + ImageStrings.cardMissing, + width: Sizes.icon, ), const SizedBox( height: Sizes.spaceLarge, ), Text( - l10n.codeSecretIncorrect, + l10n.userPinIsIncorrect, style: Theme.of(context).textTheme.displaySmall, ), const SizedBox( 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/pubspec.lock b/pubspec.lock index 694c40b0c..6f697d117 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: @@ -1223,10 +1223,10 @@ 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: @@ -1247,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: @@ -1980,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: diff --git a/script.sh b/script.sh index fec93f3dd..6a98ab97d 100755 --- a/script.sh +++ b/script.sh @@ -21,10 +21,10 @@ function buildRunner { ( echo "$d" cd "packages/$d" - dart run build_runner build --delete-conflicting-outputs + dart pub run build_runner build --delete-conflicting-outputs ) done - dart run build_runner build --delete-conflicting-outputs + dart pub run build_runner build --delete-conflicting-outputs } function podUpdate { From 5cab5d9e2685c9b9d6b5f2b7c2ea203a81521c9c Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 10:28:55 +0000 Subject: [PATCH 21/48] enabling didkit package tests on github --- didkit/lib/flutter/libdidkit.so | 1 + didkit/lib/flutter/pubspec.lock | 229 ++++++++++++++++++++++++++++++++ didkit/lib/flutter/pubspec.yaml | 26 ++++ pubspec.lock | 16 +-- 4 files changed, 264 insertions(+), 8 deletions(-) create mode 120000 didkit/lib/flutter/libdidkit.so create mode 100644 didkit/lib/flutter/pubspec.lock create mode 100644 didkit/lib/flutter/pubspec.yaml diff --git a/didkit/lib/flutter/libdidkit.so b/didkit/lib/flutter/libdidkit.so new file mode 120000 index 000000000..9929202ba --- /dev/null +++ b/didkit/lib/flutter/libdidkit.so @@ -0,0 +1 @@ +../../../didkit/lib/flutter/libdidkit.so \ No newline at end of file diff --git a/didkit/lib/flutter/pubspec.lock b/didkit/lib/flutter/pubspec.lock new file mode 100644 index 000000000..e86de7310 --- /dev/null +++ b/didkit/lib/flutter/pubspec.lock @@ -0,0 +1,229 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: "direct main" + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + flutter: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" + source: hosted + version: "0.8.0" + meta: + dependency: transitive + description: + name: meta + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" + source: hosted + version: "1.12.0" + path: + dependency: transitive + description: + name: path + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + pedantic: + dependency: "direct dev" + description: + name: pedantic + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + uuid: + dependency: "direct dev" + description: + name: uuid + sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + url: "https://pub.dev" + source: hosted + version: "3.0.7" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" +sdks: + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/didkit/lib/flutter/pubspec.yaml b/didkit/lib/flutter/pubspec.yaml new file mode 100644 index 000000000..2113d2b16 --- /dev/null +++ b/didkit/lib/flutter/pubspec.yaml @@ -0,0 +1,26 @@ +name: didkit +description: A new flutter plugin project. +version: 0.0.2 +author: Spruce Systems, Inc. +homepage: https://github.com/spruceid/didkit/tree/main/lib/flutter + +environment: + sdk: ">=2.12.0 <3.0.0" + +dependencies: + ffi: ^2.0.0 + +dev_dependencies: + flutter_test: + sdk: flutter + pedantic: ^1.11.0 + uuid: ^3.0.4 + +flutter: + plugin: + platforms: + android: + package: com.spruceid.DIDKit + pluginClass: DIDKitFlutterPlugin + ios: + pluginClass: DIDKitFlutterPlugin diff --git a/pubspec.lock b/pubspec.lock index 6f697d117..5efc42bde 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1231,10 +1231,10 @@ packages: dependency: transitive description: name: image_picker_android - sha256: c01a23e2dc3a71330e96705e08115f9e1d63780fc54f09b8a31d5e8a6881ca33 + sha256: "4161e1f843d8480d2e9025ee22411778c3c9eb7e40076dcf2da23d8242b7b51c" url: "https://pub.dev" source: hosted - version: "0.8.12+2" + version: "0.8.12+3" image_picker_for_web: dependency: transitive description: @@ -1565,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: @@ -1756,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: @@ -2417,10 +2417,10 @@ 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: From 395a8aaf1b778b2cfd21fc256f87be6a328305bd Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 10:33:05 +0000 Subject: [PATCH 22/48] update didkit path --- packages/did_kit/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/did_kit/pubspec.yaml b/packages/did_kit/pubspec.yaml index 9c912fce4..2dc8321f9 100644 --- a/packages/did_kit/pubspec.yaml +++ b/packages/did_kit/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: didkit: - path: ../../../didkit/lib/flutter + path: ../../didkit/lib/flutter flutter: sdk: flutter mocktail: ^1.0.2 From aaa7122ea00b49293f3b3fd858fb92922db1ac87 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 11:22:05 +0000 Subject: [PATCH 23/48] update symliks for didkit --- didkit/lib/flutter/android | 1 + didkit/lib/flutter/lib | 1 + pubspec.lock | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 120000 didkit/lib/flutter/android create mode 120000 didkit/lib/flutter/lib diff --git a/didkit/lib/flutter/android b/didkit/lib/flutter/android new file mode 120000 index 000000000..e383911a8 --- /dev/null +++ b/didkit/lib/flutter/android @@ -0,0 +1 @@ +../../../../didkit/lib/flutter/android \ No newline at end of file diff --git a/didkit/lib/flutter/lib b/didkit/lib/flutter/lib new file mode 120000 index 000000000..cdb239eee --- /dev/null +++ b/didkit/lib/flutter/lib @@ -0,0 +1 @@ +../../../../didkit/lib/flutter/lib \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 5efc42bde..e04714c7a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -595,7 +595,7 @@ packages: didkit: dependency: transitive description: - path: "../didkit/lib/flutter" + path: "didkit/lib/flutter" relative: true source: path version: "0.0.2" From 808af5d51f990d1e497407adf314aee3e7134970 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 11:23:41 +0000 Subject: [PATCH 24/48] update didkit library --- didkit/lib/flutter/lib | 1 - didkit/lib/flutter/lib/didkit.dart | 522 +++++++++++++++++++++++++++++ 2 files changed, 522 insertions(+), 1 deletion(-) delete mode 120000 didkit/lib/flutter/lib create mode 100644 didkit/lib/flutter/lib/didkit.dart diff --git a/didkit/lib/flutter/lib b/didkit/lib/flutter/lib deleted file mode 120000 index cdb239eee..000000000 --- a/didkit/lib/flutter/lib +++ /dev/null @@ -1 +0,0 @@ -../../../../didkit/lib/flutter/lib \ No newline at end of file diff --git a/didkit/lib/flutter/lib/didkit.dart b/didkit/lib/flutter/lib/didkit.dart new file mode 100644 index 000000000..0e2999069 --- /dev/null +++ b/didkit/lib/flutter/lib/didkit.dart @@ -0,0 +1,522 @@ +library didkit; + +import 'dart:ffi'; +import 'dart:io'; + +import 'package:ffi/ffi.dart'; + +// TODO: support Windows +final DynamicLibrary lib = Platform.isAndroid || Platform.isLinux + ? DynamicLibrary.open('libdidkit.so') + : Platform.isMacOS + ? DynamicLibrary.open('libdidkit.dylib') + : DynamicLibrary.process(); + +final get_version = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_get_version'); + +final get_error_message = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_error_message'); + +final get_error_code = + lib.lookupFunction('didkit_error_code'); + +final generate_ed25519_key = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_generate_ed25519_key'); + +final generate_secp256r1_key = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_generate_secp256r1_key'); + +final generate_secp256k1_key = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_generate_secp256k1_key'); + +final generate_secp384r1_key = + lib.lookupFunction Function(), Pointer Function()>( + 'didkit_generate_secp384r1_key'); + +final key_to_did = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, +)>('didkit_key_to_did'); + +final key_to_verification_method = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, +)>('didkit_key_to_verification_method'); + +final issue_credential = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +)>('didkit_vc_issue_credential'); + +final verify_credential = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, +)>('didkit_vc_verify_credential'); + +final issue_presentation = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +)>('didkit_vc_issue_presentation'); + +final verify_presentation = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, +)>('didkit_vc_verify_presentation'); + +final resolve_did = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, +)>('didkit_resolve_did'); + +final dereference_did_url = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, +)>('didkit_dereference_did_url'); + +final did_auth = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +)>('didkit_did_auth'); + +final create_context = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, +)>('didkit_create_context'); + +final create_context_map = lib.lookupFunction< + Pointer Function( + Pointer>, + Uint32, +), + Pointer Function( + Pointer>, + int, +)>('didkit_create_context_map'); + +final prepare_issue_credential = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +)>('didkit_vc_prepare_issue_credential'); + +final complete_issue_credential = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, +)>('didkit_vc_complete_issue_credential'); + +final prepare_issue_presentation = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, +)>('didkit_vc_prepare_issue_presentation'); + +final complete_issue_presentation = lib.lookupFunction< + Pointer Function( + Pointer, + Pointer, + Pointer, +), + Pointer Function( + Pointer, + Pointer, + Pointer, +)>('didkit_vc_complete_issue_presentation'); + +final free_string = lib.lookupFunction< + Void Function( + Pointer, +), + void Function( + Pointer, +)>('didkit_free_string'); + +class DIDKitException implements Exception { + int code; + String message; + + DIDKitException(this.code, this.message); + + @override + String toString() { + return 'DIDKitException ($code): $message'; + } +} + +DIDKitException lastError() { + final code = get_error_code(); + final message_utf8 = get_error_message(); + final message_string = message_utf8.address == nullptr.address + ? 'Unable to get error message' + : message_utf8.toDartString(); + + return DIDKitException(code, message_string); +} + +class DIDKit { + static String getVersion() { + return get_version().toDartString(); + } + + static String generateEd25519Key() { + final key = generate_ed25519_key(); + if (key.address == nullptr.address) throw lastError(); + final key_string = key.toDartString(); + free_string(key); + return key_string; + } + + static String generateSecp256r1Key() { + final key = generate_secp256r1_key(); + if (key.address == nullptr.address) throw lastError(); + final key_string = key.toDartString(); + free_string(key); + return key_string; + } + + static String generateSecp256k1Key() { + final key = generate_secp256k1_key(); + if (key.address == nullptr.address) throw lastError(); + final key_string = key.toDartString(); + free_string(key); + return key_string; + } + + static String generateSecp384r1Key() { + final key = generate_secp384r1_key(); + if (key.address == nullptr.address) throw lastError(); + final key_string = key.toDartString(); + free_string(key); + return key_string; + } + + @Deprecated('Use [keyToDID]') + static String keyToDIDKey(String key) { + final did_key = key_to_did('key'.toNativeUtf8(), key.toNativeUtf8()); + if (did_key.address == nullptr.address) throw lastError(); + final did_key_string = did_key.toDartString(); + free_string(did_key); + return did_key_string; + } + + static String keyToDID(String methodPattern, String key) { + final did = key_to_did(methodPattern.toNativeUtf8(), key.toNativeUtf8()); + if (did.address == nullptr.address) throw lastError(); + final did_string = did.toDartString(); + free_string(did); + return did_string; + } + + static String keyToVerificationMethod(String methodPattern, String key) { + final vm = key_to_verification_method( + methodPattern.toNativeUtf8(), key.toNativeUtf8()); + if (vm.address == nullptr.address) throw lastError(); + final vm_string = vm.toDartString(); + free_string(vm); + return vm_string; + } + + static String issueCredential( + String credential, + String options, + String key, [ + String? contextMap, + ]) { + final vc = issue_credential( + credential.toNativeUtf8(), + options.toNativeUtf8(), + key.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (vc.address == nullptr.address) throw lastError(); + final vc_string = vc.toDartString(); + free_string(vc); + return vc_string; + } + + static String verifyCredential( + String credential, + String options, [ + String? contextMap, + ]) { + final result = verify_credential( + credential.toNativeUtf8(), + options.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (result.address == nullptr.address) throw lastError(); + final result_string = result.toDartString(); + free_string(result); + return result_string; + } + + static String issuePresentation( + String presentation, + String options, + String key, [ + String? contextMap, + ]) { + final vp = issue_presentation( + presentation.toNativeUtf8(), + options.toNativeUtf8(), + key.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (vp.address == nullptr.address) throw lastError(); + final vp_string = vp.toDartString(); + free_string(vp); + return vp_string; + } + + static String verifyPresentation( + String presentation, + String options, [ + String? contextMap, + ]) { + final result = verify_presentation( + presentation.toNativeUtf8(), + options.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (result.address == nullptr.address) throw lastError(); + final result_string = result.toDartString(); + free_string(result); + return result_string; + } + + static String resolveDID(String did, String inputMetadata) { + final result = + resolve_did(did.toNativeUtf8(), inputMetadata.toNativeUtf8()); + if (result.address == nullptr.address) throw lastError(); + final result_string = result.toDartString(); + free_string(result); + return result_string; + } + + static String dereferenceDIDURL(String didUrl, String inputMetadata) { + final result = dereference_did_url( + didUrl.toNativeUtf8(), inputMetadata.toNativeUtf8()); + if (result.address == nullptr.address) throw lastError(); + final result_string = result.toDartString(); + free_string(result); + return result_string; + } + + static String DIDAuth( + String did, + String options, + String key, [ + String? contextMap, + ]) { + final vp = did_auth( + did.toNativeUtf8(), + options.toNativeUtf8(), + key.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (vp.address == nullptr.address) throw lastError(); + final vp_string = vp.toDartString(); + free_string(vp); + return vp_string; + } + + static String createContext( + String url, + String json, + ) { + final context = create_context( + url.toNativeUtf8(), + json.toNativeUtf8(), + ); + if (context.address == nullptr.address) throw lastError(); + final context_string = context.toDartString(); + free_string(context); + return context_string; + } + + static String createContextMap(List contexts) { + final size = contexts.length; + + // FOOTGUN NOTE: + // malloc.allocate(size); → allocates 'size' *bytes* + // malloc(size); → allocates 'size * sizeof(type)' bytes -- YOU WANT THIS ONE + + final array = malloc>(size); + + final native = contexts.map((c) => c.toNativeUtf8()).toList(); + + native.asMap().forEach((index, str) { + array[index] = str; + }); + + final context = create_context_map(array, size); + malloc.free(array); + + if (context.address == nullptr.address) throw lastError(); + final context_string = context.toDartString(); + free_string(context); + return context_string; + } + + static String prepareIssueCredential( + String credential, + String options, + String key, [ + String? contextMap, + ]) { + final prep = prepare_issue_credential( + credential.toNativeUtf8(), + options.toNativeUtf8(), + key.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (prep.address == nullptr.address) throw lastError(); + final prep_string = prep.toDartString(); + free_string(prep); + return prep_string; + } + + static String completeIssueCredential( + String credential, + String preparation, + String signature, + ) { + final vc = complete_issue_credential( + credential.toNativeUtf8(), + preparation.toNativeUtf8(), + signature.toNativeUtf8(), + ); + if (vc.address == nullptr.address) throw lastError(); + final vc_string = vc.toDartString(); + free_string(vc); + return vc_string; + } + + static String prepareIssuePresentation( + String presentation, + String options, + String key, [ + String? contextMap, + ]) { + final prep = prepare_issue_presentation( + presentation.toNativeUtf8(), + options.toNativeUtf8(), + key.toNativeUtf8(), + contextMap?.toNativeUtf8() ?? nullptr, + ); + if (prep.address == nullptr.address) throw lastError(); + final prep_string = prep.toDartString(); + free_string(prep); + return prep_string; + } + + static String completeIssuePresentation( + String presentation, + String preparation, + String signature, + ) { + final vp = complete_issue_presentation( + presentation.toNativeUtf8(), + preparation.toNativeUtf8(), + signature.toNativeUtf8(), + ); + if (vp.address == nullptr.address) throw lastError(); + final vp_string = vp.toDartString(); + free_string(vp); + return vp_string; + } +} From 6de39fb1a4e89b4307e8af4080185d7e57cd756d Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 11:26:30 +0000 Subject: [PATCH 25/48] update didkit linking --- didkit/lib/flutter/ios | 1 + didkit/lib/flutter/libdidkit.a | 1 + 2 files changed, 2 insertions(+) create mode 120000 didkit/lib/flutter/ios create mode 120000 didkit/lib/flutter/libdidkit.a diff --git a/didkit/lib/flutter/ios b/didkit/lib/flutter/ios new file mode 120000 index 000000000..6fefb81d6 --- /dev/null +++ b/didkit/lib/flutter/ios @@ -0,0 +1 @@ +../../../../didkit/lib/flutter/ios/ \ No newline at end of file diff --git a/didkit/lib/flutter/libdidkit.a b/didkit/lib/flutter/libdidkit.a new file mode 120000 index 000000000..0acd2b089 --- /dev/null +++ b/didkit/lib/flutter/libdidkit.a @@ -0,0 +1 @@ +../../../didkit/lib/flutter/libdidkit.a \ No newline at end of file From cb928b26fafe1443a4f80d293cf3c65d2be744f3 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 18:38:31 +0545 Subject: [PATCH 26/48] remove override of workflow --- .github/workflows/did_kit.yaml | 2 +- .github/workflows/flutter_package.yaml | 3 --- .github/workflows/oidc4vc.yaml | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml index 22c84751a..2647f7254 100644 --- a/.github/workflows/did_kit.yaml +++ b/.github/workflows/did_kit.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable flutter_version: 3.22.1 diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index 7ac20afe3..bed2f519e 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -101,9 +101,6 @@ jobs: - name: 📦 Install Dependencies run: | - if grep -q 'path: ../../../didkit/lib/flutter' pubspec.yaml; then - sed -i 's|path: ../../../didkit/lib/flutter|git:\n url: https://github.com/spruceid/didkit.git\n path: lib/flutter|' pubspec.yaml - fi flutter pub global activate very_good_cli very_good packages get --recursive --ignore=${{inputs.package_get_excludes}} diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml index 8b6639f97..53c8622a8 100644 --- a/.github/workflows/oidc4vc.yaml +++ b/.github/workflows/oidc4vc.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable flutter_version: 3.22.1 From 404ada55b4e4cafa936b25705381b72992d63f14 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Tue, 4 Jun 2024 18:52:45 +0545 Subject: [PATCH 27/48] test workflow path update for didkit --- .github/workflows/did_kit.yaml | 2 +- .github/workflows/flutter_package.yaml | 3 +++ .github/workflows/oidc4vc.yaml | 2 +- packages/did_kit/pubspec.yaml | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml index 2647f7254..22c84751a 100644 --- a/.github/workflows/did_kit.yaml +++ b/.github/workflows/did_kit.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october with: flutter_channel: stable flutter_version: 3.22.1 diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index bed2f519e..7ac20afe3 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -101,6 +101,9 @@ jobs: - name: 📦 Install Dependencies run: | + if grep -q 'path: ../../../didkit/lib/flutter' pubspec.yaml; then + sed -i 's|path: ../../../didkit/lib/flutter|git:\n url: https://github.com/spruceid/didkit.git\n path: lib/flutter|' pubspec.yaml + fi flutter pub global activate very_good_cli very_good packages get --recursive --ignore=${{inputs.package_get_excludes}} diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml index 53c8622a8..8b6639f97 100644 --- a/.github/workflows/oidc4vc.yaml +++ b/.github/workflows/oidc4vc.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october with: flutter_channel: stable flutter_version: 3.22.1 diff --git a/packages/did_kit/pubspec.yaml b/packages/did_kit/pubspec.yaml index 2dc8321f9..9c912fce4 100644 --- a/packages/did_kit/pubspec.yaml +++ b/packages/did_kit/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: didkit: - path: ../../didkit/lib/flutter + path: ../../../didkit/lib/flutter flutter: sdk: flutter mocktail: ^1.0.2 From ae1991756dc319335ae10dec7b219fc4ff0b1237 Mon Sep 17 00:00:00 2001 From: hawkbee <49282360+hawkbee1@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:09:25 +0200 Subject: [PATCH 28/48] Update oidc4vc.yaml --- .github/workflows/oidc4vc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml index 8b6639f97..0aeed6fba 100644 --- a/.github/workflows/oidc4vc.yaml +++ b/.github/workflows/oidc4vc.yaml @@ -11,4 +11,4 @@ jobs: min_coverage: 30 working_directory: packages/oidc4vc dart_sdk: 3.4.1 - build_runner: false + build_runner: true From b0764cad4f1c901c91c9264a3e0fe00007da3775 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 13:25:57 +0000 Subject: [PATCH 29/48] update flutter_package.yaml --- .github/workflows/flutter_package.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index 7ac20afe3..44a5fb8a1 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -101,8 +101,8 @@ jobs: - name: 📦 Install Dependencies run: | - if grep -q 'path: ../../../didkit/lib/flutter' pubspec.yaml; then - sed -i 's|path: ../../../didkit/lib/flutter|git:\n url: https://github.com/spruceid/didkit.git\n path: lib/flutter|' pubspec.yaml + 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}} From 5caf9da99c4d8be520ffa883ed4ef1362aa4ead0 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 13:35:07 +0000 Subject: [PATCH 30/48] analyze issue --- .../test/src/client_authentication_test.dart | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) 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', + ); }); }); } From a2344567860cdcb01a82caa639f1324a6ba6be6e Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 13:43:57 +0000 Subject: [PATCH 31/48] flutter analyze lib test --- packages/oidc4vc/lib/src/oidc4vc.dart | 2 +- packages/oidc4vc/test/src/oidc4vc_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 84aa85714..1b0ce7e64 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1747,7 +1747,7 @@ class OIDC4VC { }) async { try { final secureStorageProvider = getSecureStorage; - final cachedData = await secureStorageProvider.get(uri); + // final cachedData = await secureStorageProvider.get(uri); // TODO(hawkbee): To be removed. /// temporary solution to purge faulty stored data /// Will be removed in the future diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index 17c476de9..6831a33f1 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -444,7 +444,7 @@ void main() { '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 + '{"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, @@ -625,8 +625,8 @@ void main() { 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 + 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' + 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; final isVerified = await oidc4vc.verifyEncodedData( issuer: issuer, From 46984c352bdef4618fdf704330bc3af02fc76b3c Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 14:03:24 +0000 Subject: [PATCH 32/48] Revert "flutter analyze lib test" This reverts commit a2344567860cdcb01a82caa639f1324a6ba6be6e. --- packages/oidc4vc/lib/src/oidc4vc.dart | 2 +- packages/oidc4vc/test/src/oidc4vc_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 1b0ce7e64..84aa85714 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1747,7 +1747,7 @@ class OIDC4VC { }) async { try { final secureStorageProvider = getSecureStorage; - // final cachedData = await secureStorageProvider.get(uri); + final cachedData = await secureStorageProvider.get(uri); // TODO(hawkbee): To be removed. /// temporary solution to purge faulty stored data /// Will be removed in the future diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index 6831a33f1..17c476de9 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -444,7 +444,7 @@ void main() { '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"}'; + '{"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, @@ -625,8 +625,8 @@ void main() { test('returns VerificationType.notVerified for OKP', () async { const vcJwt = 'eyJraWQiOiItMTkwOTU3MjI1NyIsImFsZyI6IkVkRFNBIn0.' - 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' - 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; + 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' // ignore: lines_longer_than_80_chars + 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; // ignore: lines_longer_than_80_chars final isVerified = await oidc4vc.verifyEncodedData( issuer: issuer, From 9e93b3d7a232488a45b8bc581bf7343399f950ea Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Tue, 4 Jun 2024 14:03:54 +0000 Subject: [PATCH 33/48] flutter analyze lib test --- packages/oidc4vc/lib/src/oidc4vc.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 84aa85714..1b0ce7e64 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1747,7 +1747,7 @@ class OIDC4VC { }) async { try { final secureStorageProvider = getSecureStorage; - final cachedData = await secureStorageProvider.get(uri); + // final cachedData = await secureStorageProvider.get(uri); // TODO(hawkbee): To be removed. /// temporary solution to purge faulty stored data /// Will be removed in the future From a6e92b4eefa766f174abae86e0ac890ff74dbd10 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 10:55:42 +0545 Subject: [PATCH 34/48] fix: Remove didkit folder and fix some warning --- didkit/lib/flutter/android | 1 - didkit/lib/flutter/ios | 1 - didkit/lib/flutter/lib/didkit.dart | 522 -------------------- didkit/lib/flutter/libdidkit.a | 1 - didkit/lib/flutter/libdidkit.so | 1 - didkit/lib/flutter/pubspec.lock | 229 --------- didkit/lib/flutter/pubspec.yaml | 26 - packages/oidc4vc/test/src/oidc4vc_test.dart | 6 +- 8 files changed, 3 insertions(+), 784 deletions(-) delete mode 120000 didkit/lib/flutter/android delete mode 120000 didkit/lib/flutter/ios delete mode 100644 didkit/lib/flutter/lib/didkit.dart delete mode 120000 didkit/lib/flutter/libdidkit.a delete mode 120000 didkit/lib/flutter/libdidkit.so delete mode 100644 didkit/lib/flutter/pubspec.lock delete mode 100644 didkit/lib/flutter/pubspec.yaml diff --git a/didkit/lib/flutter/android b/didkit/lib/flutter/android deleted file mode 120000 index e383911a8..000000000 --- a/didkit/lib/flutter/android +++ /dev/null @@ -1 +0,0 @@ -../../../../didkit/lib/flutter/android \ No newline at end of file diff --git a/didkit/lib/flutter/ios b/didkit/lib/flutter/ios deleted file mode 120000 index 6fefb81d6..000000000 --- a/didkit/lib/flutter/ios +++ /dev/null @@ -1 +0,0 @@ -../../../../didkit/lib/flutter/ios/ \ No newline at end of file diff --git a/didkit/lib/flutter/lib/didkit.dart b/didkit/lib/flutter/lib/didkit.dart deleted file mode 100644 index 0e2999069..000000000 --- a/didkit/lib/flutter/lib/didkit.dart +++ /dev/null @@ -1,522 +0,0 @@ -library didkit; - -import 'dart:ffi'; -import 'dart:io'; - -import 'package:ffi/ffi.dart'; - -// TODO: support Windows -final DynamicLibrary lib = Platform.isAndroid || Platform.isLinux - ? DynamicLibrary.open('libdidkit.so') - : Platform.isMacOS - ? DynamicLibrary.open('libdidkit.dylib') - : DynamicLibrary.process(); - -final get_version = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_get_version'); - -final get_error_message = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_error_message'); - -final get_error_code = - lib.lookupFunction('didkit_error_code'); - -final generate_ed25519_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_ed25519_key'); - -final generate_secp256r1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp256r1_key'); - -final generate_secp256k1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp256k1_key'); - -final generate_secp384r1_key = - lib.lookupFunction Function(), Pointer Function()>( - 'didkit_generate_secp384r1_key'); - -final key_to_did = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_key_to_did'); - -final key_to_verification_method = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_key_to_verification_method'); - -final issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_issue_credential'); - -final verify_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_verify_credential'); - -final issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_issue_presentation'); - -final verify_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_verify_presentation'); - -final resolve_did = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_resolve_did'); - -final dereference_did_url = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_dereference_did_url'); - -final did_auth = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_did_auth'); - -final create_context = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, -)>('didkit_create_context'); - -final create_context_map = lib.lookupFunction< - Pointer Function( - Pointer>, - Uint32, -), - Pointer Function( - Pointer>, - int, -)>('didkit_create_context_map'); - -final prepare_issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_prepare_issue_credential'); - -final complete_issue_credential = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_complete_issue_credential'); - -final prepare_issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, -)>('didkit_vc_prepare_issue_presentation'); - -final complete_issue_presentation = lib.lookupFunction< - Pointer Function( - Pointer, - Pointer, - Pointer, -), - Pointer Function( - Pointer, - Pointer, - Pointer, -)>('didkit_vc_complete_issue_presentation'); - -final free_string = lib.lookupFunction< - Void Function( - Pointer, -), - void Function( - Pointer, -)>('didkit_free_string'); - -class DIDKitException implements Exception { - int code; - String message; - - DIDKitException(this.code, this.message); - - @override - String toString() { - return 'DIDKitException ($code): $message'; - } -} - -DIDKitException lastError() { - final code = get_error_code(); - final message_utf8 = get_error_message(); - final message_string = message_utf8.address == nullptr.address - ? 'Unable to get error message' - : message_utf8.toDartString(); - - return DIDKitException(code, message_string); -} - -class DIDKit { - static String getVersion() { - return get_version().toDartString(); - } - - static String generateEd25519Key() { - final key = generate_ed25519_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp256r1Key() { - final key = generate_secp256r1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp256k1Key() { - final key = generate_secp256k1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - static String generateSecp384r1Key() { - final key = generate_secp384r1_key(); - if (key.address == nullptr.address) throw lastError(); - final key_string = key.toDartString(); - free_string(key); - return key_string; - } - - @Deprecated('Use [keyToDID]') - static String keyToDIDKey(String key) { - final did_key = key_to_did('key'.toNativeUtf8(), key.toNativeUtf8()); - if (did_key.address == nullptr.address) throw lastError(); - final did_key_string = did_key.toDartString(); - free_string(did_key); - return did_key_string; - } - - static String keyToDID(String methodPattern, String key) { - final did = key_to_did(methodPattern.toNativeUtf8(), key.toNativeUtf8()); - if (did.address == nullptr.address) throw lastError(); - final did_string = did.toDartString(); - free_string(did); - return did_string; - } - - static String keyToVerificationMethod(String methodPattern, String key) { - final vm = key_to_verification_method( - methodPattern.toNativeUtf8(), key.toNativeUtf8()); - if (vm.address == nullptr.address) throw lastError(); - final vm_string = vm.toDartString(); - free_string(vm); - return vm_string; - } - - static String issueCredential( - String credential, - String options, - String key, [ - String? contextMap, - ]) { - final vc = issue_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vc.address == nullptr.address) throw lastError(); - final vc_string = vc.toDartString(); - free_string(vc); - return vc_string; - } - - static String verifyCredential( - String credential, - String options, [ - String? contextMap, - ]) { - final result = verify_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String issuePresentation( - String presentation, - String options, - String key, [ - String? contextMap, - ]) { - final vp = issue_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } - - static String verifyPresentation( - String presentation, - String options, [ - String? contextMap, - ]) { - final result = verify_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String resolveDID(String did, String inputMetadata) { - final result = - resolve_did(did.toNativeUtf8(), inputMetadata.toNativeUtf8()); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String dereferenceDIDURL(String didUrl, String inputMetadata) { - final result = dereference_did_url( - didUrl.toNativeUtf8(), inputMetadata.toNativeUtf8()); - if (result.address == nullptr.address) throw lastError(); - final result_string = result.toDartString(); - free_string(result); - return result_string; - } - - static String DIDAuth( - String did, - String options, - String key, [ - String? contextMap, - ]) { - final vp = did_auth( - did.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } - - static String createContext( - String url, - String json, - ) { - final context = create_context( - url.toNativeUtf8(), - json.toNativeUtf8(), - ); - if (context.address == nullptr.address) throw lastError(); - final context_string = context.toDartString(); - free_string(context); - return context_string; - } - - static String createContextMap(List contexts) { - final size = contexts.length; - - // FOOTGUN NOTE: - // malloc.allocate(size); → allocates 'size' *bytes* - // malloc(size); → allocates 'size * sizeof(type)' bytes -- YOU WANT THIS ONE - - final array = malloc>(size); - - final native = contexts.map((c) => c.toNativeUtf8()).toList(); - - native.asMap().forEach((index, str) { - array[index] = str; - }); - - final context = create_context_map(array, size); - malloc.free(array); - - if (context.address == nullptr.address) throw lastError(); - final context_string = context.toDartString(); - free_string(context); - return context_string; - } - - static String prepareIssueCredential( - String credential, - String options, - String key, [ - String? contextMap, - ]) { - final prep = prepare_issue_credential( - credential.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (prep.address == nullptr.address) throw lastError(); - final prep_string = prep.toDartString(); - free_string(prep); - return prep_string; - } - - static String completeIssueCredential( - String credential, - String preparation, - String signature, - ) { - final vc = complete_issue_credential( - credential.toNativeUtf8(), - preparation.toNativeUtf8(), - signature.toNativeUtf8(), - ); - if (vc.address == nullptr.address) throw lastError(); - final vc_string = vc.toDartString(); - free_string(vc); - return vc_string; - } - - static String prepareIssuePresentation( - String presentation, - String options, - String key, [ - String? contextMap, - ]) { - final prep = prepare_issue_presentation( - presentation.toNativeUtf8(), - options.toNativeUtf8(), - key.toNativeUtf8(), - contextMap?.toNativeUtf8() ?? nullptr, - ); - if (prep.address == nullptr.address) throw lastError(); - final prep_string = prep.toDartString(); - free_string(prep); - return prep_string; - } - - static String completeIssuePresentation( - String presentation, - String preparation, - String signature, - ) { - final vp = complete_issue_presentation( - presentation.toNativeUtf8(), - preparation.toNativeUtf8(), - signature.toNativeUtf8(), - ); - if (vp.address == nullptr.address) throw lastError(); - final vp_string = vp.toDartString(); - free_string(vp); - return vp_string; - } -} diff --git a/didkit/lib/flutter/libdidkit.a b/didkit/lib/flutter/libdidkit.a deleted file mode 120000 index 0acd2b089..000000000 --- a/didkit/lib/flutter/libdidkit.a +++ /dev/null @@ -1 +0,0 @@ -../../../didkit/lib/flutter/libdidkit.a \ No newline at end of file diff --git a/didkit/lib/flutter/libdidkit.so b/didkit/lib/flutter/libdidkit.so deleted file mode 120000 index 9929202ba..000000000 --- a/didkit/lib/flutter/libdidkit.so +++ /dev/null @@ -1 +0,0 @@ -../../../didkit/lib/flutter/libdidkit.so \ No newline at end of file diff --git a/didkit/lib/flutter/pubspec.lock b/didkit/lib/flutter/pubspec.lock deleted file mode 100644 index e86de7310..000000000 --- a/didkit/lib/flutter/pubspec.lock +++ /dev/null @@ -1,229 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - crypto: - dependency: transitive - description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.dev" - source: hosted - version: "3.0.3" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - ffi: - dependency: "direct main" - description: - name: ffi - sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - flutter: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" - url: "https://pub.dev" - source: hosted - version: "10.0.4" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" - url: "https://pub.dev" - source: hosted - version: "3.0.3" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" - url: "https://pub.dev" - source: hosted - version: "0.8.0" - meta: - dependency: transitive - description: - name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - path: - dependency: transitive - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" - source: hosted - version: "1.3.2" - uuid: - dependency: "direct dev" - description: - name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.dev" - source: hosted - version: "3.0.7" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" - url: "https://pub.dev" - source: hosted - version: "14.2.1" -sdks: - dart: ">=3.3.0 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" diff --git a/didkit/lib/flutter/pubspec.yaml b/didkit/lib/flutter/pubspec.yaml deleted file mode 100644 index 2113d2b16..000000000 --- a/didkit/lib/flutter/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: didkit -description: A new flutter plugin project. -version: 0.0.2 -author: Spruce Systems, Inc. -homepage: https://github.com/spruceid/didkit/tree/main/lib/flutter - -environment: - sdk: ">=2.12.0 <3.0.0" - -dependencies: - ffi: ^2.0.0 - -dev_dependencies: - flutter_test: - sdk: flutter - pedantic: ^1.11.0 - uuid: ^3.0.4 - -flutter: - plugin: - platforms: - android: - package: com.spruceid.DIDKit - pluginClass: DIDKitFlutterPlugin - ios: - pluginClass: DIDKitFlutterPlugin diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index 17c476de9..56748eb25 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -444,7 +444,7 @@ void main() { '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 + '{"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, @@ -625,8 +625,8 @@ void main() { 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 + 'eyJqdGkiOiIyMjkxNmYzYy05MDkzLTQ4MTMtODM5Ny1mMTBlNmI3MDRiNjgiLCJkZWxlZ2F0aW9uSWQiOiJiNGFlNDdhNy02MjVhLTQ2MzAtOTcyNy00NTc2NGE3MTJjY2UiLCJleHAiOjE2NTUyNzkxMDksIm5iZiI6MTY1NTI3ODgwOSwic2NvcGUiOiJyZWFkIG9wZW5pZCIsImlzcyI6Imh0dHBzOi8vaWRzdnIuZXhhbXBsZS5jb20iLCJzdWIiOiJ1c2VybmFtZSIsImF1ZCI6ImFwaS5leGFtcGxlLmNvbSIsImlhdCI6MTY1NTI3ODgwOSwicHVycG9zZSI6ImFjY2Vzc190b2tlbiJ9.' + 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; final isVerified = await oidc4vc.verifyEncodedData( issuer: issuer, From 1bcfb869e71f6f3b147adb476eb5d90378fce74a Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 11:24:37 +0545 Subject: [PATCH 35/48] run build runner for dependent package --- .github/workflows/flutter_package.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index 44a5fb8a1..af1303ec6 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -107,6 +107,17 @@ jobs: 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}} From a5f9cd68075a1d0f89f72624507eabed034f2445 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 11:28:49 +0545 Subject: [PATCH 36/48] fix: initial dir parameter reading --- .github/workflows/flutter_package.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flutter_package.yaml b/.github/workflows/flutter_package.yaml index af1303ec6..72e527acb 100644 --- a/.github/workflows/flutter_package.yaml +++ b/.github/workflows/flutter_package.yaml @@ -111,11 +111,11 @@ jobs: run: | if grep -q 'path: ../credential_manifest' pubspec.yaml; then initial_dir=$(pwd) - echo initial_dir + echo $initial_dir cd ../credential_manifest flutter pub get dart pub run build_runner build --delete-conflicting-outputs - cd initial_dir + cd $initial_dir fi - name: ⚙️ Run Setup From 62f4529fe31f0284639c922a06ea46cb63a38f33 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 11:58:27 +0545 Subject: [PATCH 37/48] fix: Mock secure storage --- packages/oidc4vc/lib/src/oidc4vc.dart | 19 +- packages/oidc4vc/test/src/oidc4vc_test.dart | 1289 ++++++++++--------- 2 files changed, 673 insertions(+), 635 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 1b0ce7e64..5f6a2a296 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,6 +785,7 @@ class OIDC4VC { openIdConfiguration.jwksUri!, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); return response as Map; @@ -804,6 +811,7 @@ class OIDC4VC { required String issuer, required OIDC4VCIDraftType oidc4vciDraftType, required Dio dio, + SecureStorageProvider? secureStorage, }) async { var tokenEndPoint = '$issuer/token'; @@ -817,6 +825,7 @@ class OIDC4VC { baseUrl: authorizationServer, isAuthorizationServer: true, dio: dio, + secureStorage: secureStorage, ); if (authorizationServerConfiguration.tokenEndpoint != null) { @@ -832,6 +841,7 @@ class OIDC4VC { required String issuer, required OIDC4VCIDraftType oidc4vciDraftType, required Dio dio, + SecureStorageProvider? secureStorage, }) async { var authorizationEndpoint = '$issuer/authorize'; @@ -845,6 +855,7 @@ class OIDC4VC { baseUrl: authorizationServer, isAuthorizationServer: true, dio: dio, + secureStorage: secureStorage, ); if (authorizationServerConfiguration.authorizationEndpoint != null) { @@ -1618,6 +1629,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 +1645,7 @@ class OIDC4VC { baseUrl, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); return data; } @@ -1642,6 +1655,7 @@ class OIDC4VC { url, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); final data = response is String ? jsonDecode(response) as Map @@ -1662,6 +1676,7 @@ class OIDC4VC { String baseUrl, { required bool isCachingEnabled, required Dio dio, + SecureStorageProvider? secureStorage, }) async { final url = '$baseUrl/.well-known/openid-credential-issuer'; @@ -1670,6 +1685,7 @@ class OIDC4VC { url, isCachingEnabled: isCachingEnabled, dio: dio, + secureStorage: secureStorage, ); final data = response is String ? jsonDecode(response) as Map @@ -1744,9 +1760,10 @@ class OIDC4VC { 'Content-Type': 'application/json; charset=UTF-8', }, bool isCachingEnabled = false, + SecureStorageProvider? secureStorage, }) async { try { - final secureStorageProvider = getSecureStorage; + final secureStorageProvider = secureStorage ?? getSecureStorage; // final cachedData = await secureStorageProvider.get(uri); // TODO(hawkbee): To be removed. /// temporary solution to purge faulty stored data diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index 56748eb25..b80b36a6d 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -16,746 +16,767 @@ 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'; + group('selective disclosure', () { + const content = + '["Qg_O64zqAxe412a108iroA", "phone_number", "+81-80-1234-5678"]'; - const issuerState = 'test7'; - const nonce = '8b60e2fb-87f3-4401-8107-0f0128ea01ab'; + const expectedDisclosure = + 'WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgInBob25lX251bWJlciIsICIrODEtODAtMTIzNC01Njc4Il0'; - 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)), - ); + const expectedHash = 's0BKYsLWxQQeU8tVlltM7MKsIRTrEIa1PkJmqxBBf5U'; - 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, - ); + test('get disclosure', () { + final disclosure = oidc4vc.getDisclosure(content); + expect(disclosure, expectedDisclosure); + }); - expect(authorizationEndpoint, expectedAuthorizationEndpoint); - expect( - authorizationRequestParemeters, - expectedAuthorizationRequestParemeters, - ); - }, - ); + test('sh256 hash of Disclosure test', () { + final sha256Hash = oidc4vc.sh256HashOfContent(content); + expect(sha256Hash, expectedHash); + }); + }); - 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', - ), - ), - ); - }, - ); + group('publicKeyBase58ToPublicJwk', () { + const publicKeyBase58 = '2S73k5pn5umfnaW31qx6dXFndEn6SmWw7LpgSjNNC5BF'; - 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\"}]"}'; + final expectedPublicJWK = { + 'crv': 'Ed25519', + 'kty': 'OKP', + 'x': 'FUoLewH4w4-KdaPH2cjZbL--CKYxQRWR05Yd_bIbhQo', + }; - 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, - ); - - expect( - jsonEncode(authorizationRequestParemeters), - expectedAuthorizationRequestParemeters, - ); - }, - ); - }); - - 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'; + group('OIC4VC request credential', () { + const issuer = 'https://talao.co/issuer/zxhaokccsi'; - 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"}'; - final tokenData = oidc4vc.buildTokenData( - redirectUri: redirectUri, - preAuthorizedCode: preAuthorizedCode, - clientId: clientId, - ); - - expect(jsonEncode(tokenData), expectedTokenData); - }); - - 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.' - 'rjeE8D_e4RYzgvpu-nOwwx7PWMiZyDZwkwO6RiHR5t8g4JqqVokUKQt-oST1s45wubacfeDSFogOrIhe3UHDAg'; + 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(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()), ); - expect(value, jsonDecode(expectedDidDocument)); }); - }, - ); + }); + + 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('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)); + }); + }, + ); + }); } From 2b78188162246ea39655c37d3059089ae8838970 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 12:01:39 +0545 Subject: [PATCH 38/48] remove trailing comma --- packages/oidc4vc/test/src/oidc4vc_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index b80b36a6d..f84e55e63 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -697,7 +697,8 @@ void main() { (request) => request.throws( 401, DioException( - requestOptions: RequestOptions(path: tokenEndPoint)), + requestOptions: RequestOptions(path: tokenEndPoint), + ), ), ); From 7028ff86d2323c364dd64d4df485046d81bae954 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 12:13:15 +0545 Subject: [PATCH 39/48] fix: Always depend upon the flutter_package.yaml of main branch --- .github/workflows/did_kit.yaml | 2 +- .github/workflows/oidc4vc.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/did_kit.yaml b/.github/workflows/did_kit.yaml index 22c84751a..2647f7254 100644 --- a/.github/workflows/did_kit.yaml +++ b/.github/workflows/did_kit.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable flutter_version: 3.22.1 diff --git a/.github/workflows/oidc4vc.yaml b/.github/workflows/oidc4vc.yaml index 0aeed6fba..cb83c408f 100644 --- a/.github/workflows/oidc4vc.yaml +++ b/.github/workflows/oidc4vc.yaml @@ -4,7 +4,7 @@ on: [pull_request, push] jobs: build: - uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@october + uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main with: flutter_channel: stable flutter_version: 3.22.1 From 5a14eba48170b387d9bbad5838e15169af4de685 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 14:07:07 +0545 Subject: [PATCH 40/48] feat: Display developer mode for default profile #2654 --- lib/dashboard/drawer/src/view/drawer_page.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dashboard/drawer/src/view/drawer_page.dart b/lib/dashboard/drawer/src/view/drawer_page.dart index c518c887b..df9c74d38 100644 --- a/lib/dashboard/drawer/src/view/drawer_page.dart +++ b/lib/dashboard/drawer/src/view/drawer_page.dart @@ -120,8 +120,7 @@ class DrawerView extends StatelessWidget { ], if (profileModel - .profileSetting.settingsMenu.displayDeveloperMode && - profileModel.profileType != ProfileType.defaultOne) ...[ + .profileSetting.settingsMenu.displayDeveloperMode) ...[ DrawerCategoryItem( title: l10n.developerMode, subTitle: l10n.developerModeSubtitle, From 2a7e7826309882a12e8423c94b1c8f4a2231d48e Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 14:27:40 +0545 Subject: [PATCH 41/48] feat: Use public fallback if universal resolver fails #2665 --- packages/oidc4vc/lib/src/oidc4vc.dart | 20 ++++++++--- packages/oidc4vc/test/src/oidc4vc_test.dart | 37 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 5f6a2a296..6b9f249fa 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -790,11 +790,21 @@ class OIDC4VC { 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; diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index f84e55e63..8e932d1dc 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -740,6 +740,43 @@ void main() { 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 = From 5c8bcefa4d5f9ea5306a44eb8bbe0e8643996fdf Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 5 Jun 2024 15:07:05 +0545 Subject: [PATCH 42/48] fix: Remove linter problems --- lib/app/shared/extension/extension.dart | 2 +- .../widget/button/my_elevated_button.dart | 8 +- lib/app/shared/widget/checkbox_item.dart | 2 +- .../widgets/crypto_accont_item.dart | 2 +- .../widgets/advance_settings_radio_item.dart | 2 +- .../reset_wallet/view/reset_wallet_menu.dart | 2 - .../widgets/select_box_account_item.dart | 2 +- .../qr_code_scan/view/qr_camera_view.dart | 7 +- .../widgets/select_network_fee_item.dart | 2 +- lib/dashboard/src/view/dashboard_page.dart | 7 +- .../user_pin/view/user_pin_page.dart | 7 +- .../wallet_ready/view/wallet_ready_page.dart | 2 +- lib/pin_code/cubit/pin_code_view_cubit.dart | 12 +- lib/pin_code/view/confirm_pin_code_page.dart | 22 +- lib/pin_code/view/delete_my_wallet_page.dart | 2 - lib/pin_code/view/pin_code_page.dart | 5 +- .../test/src/secure_jwt_signer_test.dart | 5 +- .../shared/enum/credential_category_test.dart | 68 +- ...redential_subject_type_extension_test.dart | 784 ++++++++++++------ .../shared/enum/polygon_id_network_test.dart | 4 +- .../credential_status_extension_test.dart | 6 +- .../shared/enum/type/language_type_test.dart | 4 +- .../extension/unit8List_extension_test.dart | 40 - .../extension/unit_8_list_extension_test.dart | 15 +- .../helper_functions_test.dart | 331 +++++--- test/app/shared/issuer/check_issuer_test.dart | 14 +- .../issuer/models/organization_info_test.dart | 8 +- .../state_message/state_message_test.dart | 2 +- .../network/network_exception_test.dart | 4 +- .../wallet_address_validator_test.dart | 14 +- .../widget/base/otp_textfield_test.dart | 9 +- test/app/shared/widget/base/page_test.dart | 4 +- .../widget/dialog/confirm_dialog_test.dart | 14 +- .../widget/dialog/text_field_dialog_test.dart | 3 +- test/app/shared/widget/wallet_logo_test.dart | 3 +- .../view/onboarding_gen_phrase_test.dart | 3 +- .../helper_function/helper_function_test.dart | 4 +- .../view/protect_wallet_page_test.dart | 3 +- .../tos/cubit/onboarding_tos_cubit_test.dart | 3 +- .../tos/cubit/onboarding_tos_state_test.dart | 4 +- test/route/cubit/route_cubit_test.dart | 2 - test/route/router/router_test.dart | 4 +- test/scan/cubit/scan_cubit.dart | 2 +- test/splash/cubit/splash_cubit_test.dart | 2 - test/theme/app_theme_test.dart | 60 +- 45 files changed, 953 insertions(+), 552 deletions(-) delete mode 100644 test/app/shared/extension/unit8List_extension_test.dart diff --git a/lib/app/shared/extension/extension.dart b/lib/app/shared/extension/extension.dart index c8a08d0ed..dc5db6f25 100644 --- a/lib/app/shared/extension/extension.dart +++ b/lib/app/shared/extension/extension.dart @@ -2,4 +2,4 @@ export 'bigint_extension.dart'; export 'double_extension.dart'; export 'iterable_extension.dart'; export 'string_extension.dart'; -export 'unit8List_extension.dart'; +export 'unit8list_extension.dart'; diff --git a/lib/app/shared/widget/button/my_elevated_button.dart b/lib/app/shared/widget/button/my_elevated_button.dart index 9e58c6ed0..62155f4f2 100644 --- a/lib/app/shared/widget/button/my_elevated_button.dart +++ b/lib/app/shared/widget/button/my_elevated_button.dart @@ -90,16 +90,16 @@ ButtonStyle elevatedStyleFrom({ GestureTapCallback? onPressed, }) { return ButtonStyle( - elevation: MaterialStateProperty.all(elevation), - padding: MaterialStateProperty.all( + elevation: WidgetStateProperty.all(elevation), + padding: WidgetStateProperty.all( EdgeInsets.symmetric(vertical: verticalSpacing), ), - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( onPressed == null ? Theme.of(context).colorScheme.disabledBgColor : backgroundColor ?? Theme.of(context).colorScheme.primary, ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), ), diff --git a/lib/app/shared/widget/checkbox_item.dart b/lib/app/shared/widget/checkbox_item.dart index d9cf52f36..52f263264 100644 --- a/lib/app/shared/widget/checkbox_item.dart +++ b/lib/app/shared/widget/checkbox_item.dart @@ -26,7 +26,7 @@ class CheckboxItem extends StatelessWidget { children: [ Checkbox( value: value, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), shape: const RoundedRectangleBorder( diff --git a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart index c1d1cbf9a..8581cb2e1 100644 --- a/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart +++ b/lib/dashboard/crypto_account_switcher/crypto_bottom_sheet/widgets/crypto_accont_item.dart @@ -34,7 +34,7 @@ class CryptoAccountItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart b/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart index bafa0c81b..4b1e1ec1d 100644 --- a/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart +++ b/lib/dashboard/drawer/advance_settings/widgets/advance_settings_radio_item.dart @@ -22,7 +22,7 @@ class AdvanceSettingsRadioItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart index c92d0aa7c..231e6b652 100644 --- a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart +++ b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart @@ -1,10 +1,8 @@ import 'package:altme/app/app.dart'; -import 'package:altme/credentials/credentials.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/theme/theme.dart'; -import 'package:altme/wallet/wallet.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart b/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart index 354cab5f6..3df20e18c 100644 --- a/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart +++ b/lib/dashboard/home/tab_bar/tokens/widgets/select_box_account_item.dart @@ -32,7 +32,7 @@ class SelectBoxAccountItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), checkColor: Theme.of(context).colorScheme.onPrimary, diff --git a/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart b/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart index 074c39ae5..e31e928a6 100644 --- a/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart +++ b/lib/dashboard/qr_code/qr_code_scan/view/qr_camera_view.dart @@ -20,10 +20,11 @@ class QrCameraView extends StatefulWidget { }); final String title; - final Function(InputImage inputImage) onImage; + final dynamic Function(InputImage inputImage) onImage; final VoidCallback? onCameraFeedReady; final VoidCallback? onDetectorViewModeChanged; - final Function(CameraLensDirection direction)? onCameraLensDirectionChanged; + final dynamic Function(CameraLensDirection direction)? + onCameraLensDirectionChanged; final CameraLensDirection initialCameraLensDirection; @override @@ -34,7 +35,9 @@ class _QrCameraViewState extends State { static List _cameras = []; CameraController? _controller; int _cameraIndex = -1; + // ignore: unused_field double _currentZoomLevel = 1; + // ignore: unused_field double _minAvailableZoom = 1; // ignore: unused_field double _maxAvailableZoom = 1; diff --git a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart index 06f45ce5a..059451b36 100644 --- a/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart +++ b/lib/dashboard/select_network_fee_bottom_sheet/widgets/select_network_fee_item.dart @@ -25,7 +25,7 @@ class SelectNetworkFeeItem extends StatelessWidget { horizontalTitleGap: 0, leading: Checkbox( value: isSelected, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary, ), checkColor: Theme.of(context).colorScheme.primary, diff --git a/lib/dashboard/src/view/dashboard_page.dart b/lib/dashboard/src/view/dashboard_page.dart index 6963197aa..d59d7496b 100644 --- a/lib/dashboard/src/view/dashboard_page.dart +++ b/lib/dashboard/src/view/dashboard_page.dart @@ -6,7 +6,6 @@ import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/enterprise/cubit/enterprise_cubit.dart'; import 'package:altme/kyc_verification/kyc_verification.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:altme/splash/cubit/splash_cubit.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -162,12 +161,12 @@ class _DashboardViewState extends State { .helpCenterOptions .displayChatSupport; - return WillPopScope( - onWillPop: () async { + return PopScope( + canPop: false, + onPopInvoked: (_) async { if (scaffoldKey.currentState!.isDrawerOpen) { Navigator.of(context).pop(); } - return false; }, child: BasePage( scrollView: false, diff --git a/lib/dashboard/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index f0014052c..4fb31507c 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(), + create: (context) => PinCodeViewCubit(), child: UserPinView( onCancel: onCancel, onProceed: onProceed, @@ -81,8 +80,8 @@ class _UserPinViewState extends State { final l10n = context.l10n; return BlocBuilder( builder: (context, state) { - return WillPopScope( - onWillPop: () async => false, + return PopScope( + canPop: false, child: BasePage( backgroundColor: Theme.of(context).colorScheme.background, scrollView: false, diff --git a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart index 286491ed0..1e1190477 100644 --- a/lib/onboarding/wallet_ready/view/wallet_ready_page.dart +++ b/lib/onboarding/wallet_ready/view/wallet_ready_page.dart @@ -138,7 +138,7 @@ class _WalletReadyViewState extends State { scale: 1.3, child: Checkbox( value: state.isAgreeWithTerms, - fillColor: MaterialStateProperty.all( + fillColor: WidgetStateProperty.all( Theme.of(context).colorScheme.primary, ), materialTapTargetSize: diff --git a/lib/pin_code/cubit/pin_code_view_cubit.dart b/lib/pin_code/cubit/pin_code_view_cubit.dart index eeb77ed7c..db1d3cc9c 100644 --- a/lib/pin_code/cubit/pin_code_view_cubit.dart +++ b/lib/pin_code/cubit/pin_code_view_cubit.dart @@ -19,7 +19,7 @@ class PinCodeViewCubit extends Cubit { final loginAttemptCount = state.loginAttemptCount + 1; final loginAttemptsRemaining = totalPermitedLoginAttempt - state.loginAttemptCount - 1; - bool allowAction = true; + const allowAction = true; // if (loginAttemptCount >= totalPermitedLoginAttempt) { // allowAction = false; // _startLockTimer(); @@ -124,10 +124,12 @@ class PinCodeViewCubit extends Cubit { return; } } - emit(state.copyWith( - isPinCodeValid: true, - enteredPasscode: passCode, - )); + emit( + state.copyWith( + isPinCodeValid: true, + enteredPasscode: passCode, + ), + ); // on new pincode // void _onPasscodeEntered(String enteredPasscode) { diff --git a/lib/pin_code/view/confirm_pin_code_page.dart b/lib/pin_code/view/confirm_pin_code_page.dart index 9654197df..f67b2fc88 100644 --- a/lib/pin_code/view/confirm_pin_code_page.dart +++ b/lib/pin_code/view/confirm_pin_code_page.dart @@ -88,17 +88,17 @@ class _ConfirmPinCodeViewState extends State { backgroundColor: Theme.of(context).colorScheme.background, body: PinCodeWidget( title: l10n.confirmYourPinCode, - header: widget.isFromOnboarding - ? MStepper( - step: 1, - totalStep: byPassScreen ? 2 : 3, - ) - : null, - deleteButton: Text( - l10n.delete, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelButton: Text( + header: widget.isFromOnboarding + ? MStepper( + step: 1, + totalStep: byPassScreen ? 2 : 3, + ) + : null, + deleteButton: Text( + l10n.delete, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelButton: Text( l10n.cancel, style: Theme.of(context).textTheme.labelLarge, ), diff --git a/lib/pin_code/view/delete_my_wallet_page.dart b/lib/pin_code/view/delete_my_wallet_page.dart index e18555bc7..ad2e67d74 100644 --- a/lib/pin_code/view/delete_my_wallet_page.dart +++ b/lib/pin_code/view/delete_my_wallet_page.dart @@ -1,11 +1,9 @@ import 'package:altme/app/shared/constants/image_strings.dart'; import 'package:altme/app/shared/constants/sizes.dart'; import 'package:altme/app/shared/widget/widget.dart'; -import 'package:altme/credentials/cubit/credentials_cubit.dart'; import 'package:altme/dashboard/drawer/reset_wallet/helper_functions/reset_wallet.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; class DeleteMyWalletPage extends StatelessWidget { const DeleteMyWalletPage({super.key}); diff --git a/lib/pin_code/view/pin_code_page.dart b/lib/pin_code/view/pin_code_page.dart index 391b97a3e..fa3676f4d 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -1,4 +1,3 @@ - import 'package:altme/app/app.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/pin_code/pin_code.dart'; @@ -82,8 +81,8 @@ class _PinCodeViewState extends State { @override Widget build(BuildContext context) { final l10n = context.l10n; - return WillPopScope( - onWillPop: () async => !widget.restrictToBack, + return PopScope( + canPop: !widget.restrictToBack, child: BasePage( backgroundColor: Theme.of(context).colorScheme.background, title: '', diff --git a/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart b/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart index 1fc327786..1733de055 100644 --- a/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart +++ b/packages/secure_jwt_signer/test/src/secure_jwt_signer_test.dart @@ -1,13 +1,10 @@ -// ignore_for_file: prefer_const_constructors -import 'dart:convert'; - import 'package:secure_jwt_signer/secure_jwt_signer.dart'; import 'package:test/test.dart'; void main() { group('SecureJwtSigner', () { test('can be instantiated', () { - expect(SecureJwtSigner(), isNotNull); + expect(const SecureJwtSigner(), isNotNull); }); }); } diff --git a/test/app/shared/enum/credential_category_test.dart b/test/app/shared/enum/credential_category_test.dart index 32a64652d..58e99e8d7 100644 --- a/test/app/shared/enum/credential_category_test.dart +++ b/test/app/shared/enum/credential_category_test.dart @@ -4,68 +4,116 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; class MockAppLocalizations extends Mock implements AppLocalizations { + @override final my = 'My'; + @override final get = 'Get'; - + @override final advantagesCards = 'A1'; + @override final advantagesCredentialHomeSubtitle = 'A2'; + @override final advantagesDiscoverCards = 'A3'; + @override final advantagesCredentialDiscoverSubtitle = 'A4'; - + @override final identityCards = 'A1'; + @override final identityCredentialHomeSubtitle = 'A2'; + @override final identityDiscoverCards = 'A3'; + @override final identityCredentialDiscoverSubtitle = 'A4'; + @override final myProfessionalCards = 'A1'; + @override final myProfessionalrCardsSubtitle = 'A2'; + @override final myProfessionalCredentialDiscoverSubtitle = 'A3'; + @override final contactInfoCredentials = 'A1'; + @override final contactInfoCredentialHomeSubtitle = 'A2'; + @override final contactInfoDiscoverCredentials = 'A3'; + @override final contactInfoCredentialDiscoverSubtitle = 'A4'; + @override final blockchainAccounts = 'A1'; + @override final blockchainAccountsCredentialHomeSubtitle = 'A2'; + @override final blockchainCardsDiscoverTitle = 'A3'; + @override final blockchainCardsDiscoverSubtitle = 'A4'; + @override final educationCredentials = 'A1'; + @override final educationCredentialHomeSubtitle = 'A2'; + @override final educationDiscoverCredentials = 'A3'; + @override final educationCredentialsDiscoverSubtitle = 'A4'; + @override final otherCards = 'A1'; + @override final otherCredentialHomeSubtitle = 'A2'; + @override final otherCredentialDiscoverSubtitle = 'A4'; + @override final financeCredentialsHomeTitle = 'A1'; + @override final financeCredentialsHomeSubtitle = 'A2'; + @override final financeCredentialsDiscoverTitle = 'A3'; + @override final financeCredentialsDiscoverSubtitle = 'A4'; + @override final hummanityProofCredentialsHomeTitle = 'A1'; + @override final hummanityProofCredentialsHomeSubtitle = 'A2'; + @override final hummanityProofCredentialsDiscoverTitle = 'A3'; + @override final hummanityProofCredentialsDiscoverSubtitle = 'A4'; + @override final socialMediaCredentialsHomeTitle = 'A1'; + @override final socialMediaCredentialsHomeSubtitle = 'A2'; + @override final socialMediaCredentialsDiscoverTitle = 'A3'; + @override final socialMediaCredentialsDiscoverSubtitle = 'A4'; + @override final walletIntegrityCredentialsHomeTitle = 'A1'; + @override final walletIntegrityCredentialsHomeSubtitle = 'A2'; + @override final walletIntegrityCredentialsDiscoverTitle = 'A3'; + @override final walletIntegrityCredentialsDiscoverSubtitle = 'A4'; + @override final polygonCredentialsHomeTitle = 'A1'; + @override final polygonCredentialsHomeSubtitle = 'A2'; + @override final polygonCredentialsDiscoverTitle = 'A3'; + @override final polygonCredentialsDiscoverSubtitle = 'A4'; + @override final pendingCredentialsHomeTitle = 'A1'; + @override final pendingCredentialsHomeSubtitle = 'A2'; } @@ -113,15 +161,21 @@ void main() { expect(CredentialCategory.identityCards.showInHomeIfListEmpty, true); expect(CredentialCategory.professionalCards.showInHomeIfListEmpty, false); expect(CredentialCategory.advantagesCards.showInHomeIfListEmpty, false); - expect(CredentialCategory.contactInfoCredentials.showInHomeIfListEmpty, - false); - expect(CredentialCategory.blockchainAccountsCards.showInHomeIfListEmpty, - false); + expect( + CredentialCategory.contactInfoCredentials.showInHomeIfListEmpty, + false, + ); + expect( + CredentialCategory.blockchainAccountsCards.showInHomeIfListEmpty, + false, + ); expect(CredentialCategory.educationCards.showInHomeIfListEmpty, false); expect(CredentialCategory.othersCards.showInHomeIfListEmpty, false); expect(CredentialCategory.financeCards.showInHomeIfListEmpty, false); expect( - CredentialCategory.humanityProofCards.showInHomeIfListEmpty, false); + CredentialCategory.humanityProofCards.showInHomeIfListEmpty, + false, + ); expect(CredentialCategory.socialMediaCards.showInHomeIfListEmpty, false); expect(CredentialCategory.walletIntegrity.showInHomeIfListEmpty, false); expect(CredentialCategory.polygonidCards.showInHomeIfListEmpty, false); diff --git a/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart b/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart index df2f5615d..b01c5937b 100644 --- a/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart +++ b/test/app/shared/enum/credential_subject_type/credential_subject_type_extension_test.dart @@ -24,10 +24,14 @@ void main() { ); for (final value in CredentialSubjectType.values) { - expect(value.backgroundColor(credentialModel), - equals(const Color(0xFFFFFFFF))); - expect(value.backgroundColor(credentialModel2), - equals(value.defaultBackgroundColor)); + expect( + value.backgroundColor(credentialModel), + equals(const Color(0xFFFFFFFF)), + ); + expect( + value.backgroundColor(credentialModel2), + equals(value.defaultBackgroundColor), + ); } }); @@ -338,102 +342,174 @@ void main() { test('CredentialSubjectType name returns correct value', () { expect( - CredentialSubjectType.defiCompliance.name, equals('DefiCompliance')); + CredentialSubjectType.defiCompliance.name, + equals('DefiCompliance'), + ); expect(CredentialSubjectType.livenessCard.name, equals('Liveness')); - expect(CredentialSubjectType.tezotopiaMembership.name, - equals('MembershipCard_1')); - expect(CredentialSubjectType.chainbornMembership.name, - equals('Chainborn_MembershipCard')); - expect(CredentialSubjectType.twitterCard.name, - equals('TwitterAccountProof')); + expect( + CredentialSubjectType.tezotopiaMembership.name, + equals('MembershipCard_1'), + ); + expect( + CredentialSubjectType.chainbornMembership.name, + equals('Chainborn_MembershipCard'), + ); + expect( + CredentialSubjectType.twitterCard.name, + equals('TwitterAccountProof'), + ); expect(CredentialSubjectType.ageRange.name, equals('AgeRange')); expect(CredentialSubjectType.nationality.name, equals('Nationality')); expect(CredentialSubjectType.gender.name, equals('Gender')); - expect(CredentialSubjectType.walletCredential.name, - equals('WalletCredential')); - expect(CredentialSubjectType.tezosAssociatedWallet.name, - equals('TezosAssociatedAddress')); - expect(CredentialSubjectType.ethereumAssociatedWallet.name, - equals('EthereumAssociatedAddress')); - expect(CredentialSubjectType.fantomAssociatedWallet.name, - equals('FantomAssociatedAddress')); - expect(CredentialSubjectType.polygonAssociatedWallet.name, - equals('PolygonAssociatedAddress')); - expect(CredentialSubjectType.binanceAssociatedWallet.name, - equals('BinanceAssociatedAddress')); - expect(CredentialSubjectType.ethereumPooAddress.name, - equals('EthereumPooAddress')); - expect(CredentialSubjectType.fantomPooAddress.name, - equals('FantomPooAddress')); - expect(CredentialSubjectType.polygonPooAddress.name, - equals('PolygonPooAddress')); - expect(CredentialSubjectType.binancePooAddress.name, - equals('BinancePooAddress')); - expect(CredentialSubjectType.tezosPooAddress.name, - equals('TezosPooAddress')); - expect(CredentialSubjectType.certificateOfEmployment.name, - equals('CertificateOfEmployment')); + expect( + CredentialSubjectType.walletCredential.name, + equals('WalletCredential'), + ); + expect( + CredentialSubjectType.tezosAssociatedWallet.name, + equals('TezosAssociatedAddress'), + ); + expect( + CredentialSubjectType.ethereumAssociatedWallet.name, + equals('EthereumAssociatedAddress'), + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.name, + equals('FantomAssociatedAddress'), + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.name, + equals('PolygonAssociatedAddress'), + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.name, + equals('BinanceAssociatedAddress'), + ); + expect( + CredentialSubjectType.ethereumPooAddress.name, + equals('EthereumPooAddress'), + ); + expect( + CredentialSubjectType.fantomPooAddress.name, + equals('FantomPooAddress'), + ); + expect( + CredentialSubjectType.polygonPooAddress.name, + equals('PolygonPooAddress'), + ); + expect( + CredentialSubjectType.binancePooAddress.name, + equals('BinancePooAddress'), + ); + expect( + CredentialSubjectType.tezosPooAddress.name, + equals('TezosPooAddress'), + ); + expect( + CredentialSubjectType.certificateOfEmployment.name, + equals('CertificateOfEmployment'), + ); expect(CredentialSubjectType.emailPass.name, equals('EmailPass')); expect(CredentialSubjectType.identityPass.name, equals('IdentityPass')); expect( - CredentialSubjectType.verifiableIdCard.name, equals('VerifiableId')); + CredentialSubjectType.verifiableIdCard.name, + equals('VerifiableId'), + ); expect(CredentialSubjectType.linkedInCard.name, equals('LinkedinCard')); - expect(CredentialSubjectType.learningAchievement.name, - equals('LearningAchievement')); + expect( + CredentialSubjectType.learningAchievement.name, + equals('LearningAchievement'), + ); expect(CredentialSubjectType.over13.name, equals('Over13')); expect(CredentialSubjectType.over15.name, equals('Over15')); expect(CredentialSubjectType.over18.name, equals('Over18')); expect(CredentialSubjectType.over21.name, equals('Over21')); expect(CredentialSubjectType.over50.name, equals('Over50')); expect(CredentialSubjectType.over65.name, equals('Over65')); - expect(CredentialSubjectType.passportFootprint.name, - equals('PassportNumber')); + expect( + CredentialSubjectType.passportFootprint.name, + equals('PassportNumber'), + ); expect(CredentialSubjectType.phonePass.name, equals('PhoneProof')); - expect(CredentialSubjectType.professionalExperienceAssessment.name, - equals('ProfessionalExperienceAssessment')); - expect(CredentialSubjectType.professionalSkillAssessment.name, - equals('ProfessionalSkillAssessment')); - expect(CredentialSubjectType.professionalStudentCard.name, - equals('ProfessionalStudentCard')); + expect( + CredentialSubjectType.professionalExperienceAssessment.name, + equals('ProfessionalExperienceAssessment'), + ); + expect( + CredentialSubjectType.professionalSkillAssessment.name, + equals('ProfessionalSkillAssessment'), + ); + expect( + CredentialSubjectType.professionalStudentCard.name, + equals('ProfessionalStudentCard'), + ); expect(CredentialSubjectType.residentCard.name, equals('ResidentCard')); - expect(CredentialSubjectType.employeeCredential.name, - equals('EmployeeCredential')); - expect(CredentialSubjectType.legalPersonalCredential.name, - equals('LegalPersonCredential')); + expect( + CredentialSubjectType.employeeCredential.name, + equals('EmployeeCredential'), + ); + expect( + CredentialSubjectType.legalPersonalCredential.name, + equals('LegalPersonCredential'), + ); expect(CredentialSubjectType.selfIssued.name, equals('SelfIssued')); expect(CredentialSubjectType.studentCard.name, equals('StudentCard')); expect(CredentialSubjectType.voucher.name, equals('Voucher')); expect(CredentialSubjectType.tezVoucher.name, equals('TezVoucher_1')); expect( - CredentialSubjectType.diplomaCard.name, equals('VerifiableDiploma')); + CredentialSubjectType.diplomaCard.name, + equals('VerifiableDiploma'), + ); expect(CredentialSubjectType.aragoPass.name, equals('AragoPass')); expect( - CredentialSubjectType.aragoEmailPass.name, equals('AragoEmailPass')); + CredentialSubjectType.aragoEmailPass.name, + equals('AragoEmailPass'), + ); + expect( + CredentialSubjectType.aragoIdentityCard.name, + equals('AragoIdCard'), + ); expect( - CredentialSubjectType.aragoIdentityCard.name, equals('AragoIdCard')); - expect(CredentialSubjectType.aragoLearningAchievement.name, - equals('AragoLearningAchievement')); + CredentialSubjectType.aragoLearningAchievement.name, + equals('AragoLearningAchievement'), + ); expect(CredentialSubjectType.aragoOver18.name, equals('AragoOver18')); - expect(CredentialSubjectType.pcdsAgentCertificate.name, - equals('PCDSAgentCertificate')); - expect( - CredentialSubjectType.euDiplomaCard.name, - equals( - 'https://api.preprod.ebsi.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd')); - expect( - CredentialSubjectType.euVerifiableId.name, - equals( - 'https://api-conformance.ebsi.eu/trusted-schemas-registry/v2/schemas/z22ZAMdQtNLwi51T2vdZXGGZaYyjrsuP1yzWyXZirCAHv')); - expect(CredentialSubjectType.kycAgeCredential.name, - equals('KYCAgeCredential')); - expect(CredentialSubjectType.kycCountryOfResidence.name, - equals('KYCCountryOfResidenceCredential')); - expect(CredentialSubjectType.proofOfTwitterStats.name, - equals('ProofOfTwitterStats')); - expect(CredentialSubjectType.civicPassCredential.name, - equals('CivicPassCredential')); - expect(CredentialSubjectType.identityCredential.name, - equals('IdentityCredential')); + expect( + CredentialSubjectType.pcdsAgentCertificate.name, + equals('PCDSAgentCertificate'), + ); + expect( + CredentialSubjectType.euDiplomaCard.name, + equals( + 'https://api.preprod.ebsi.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', + ), + ); + expect( + CredentialSubjectType.euVerifiableId.name, + equals( + 'https://api-conformance.ebsi.eu/trusted-schemas-registry/v2/schemas/z22ZAMdQtNLwi51T2vdZXGGZaYyjrsuP1yzWyXZirCAHv', + ), + ); + expect( + CredentialSubjectType.kycAgeCredential.name, + equals('KYCAgeCredential'), + ); + expect( + CredentialSubjectType.kycCountryOfResidence.name, + equals('KYCCountryOfResidenceCredential'), + ); + expect( + CredentialSubjectType.proofOfTwitterStats.name, + equals('ProofOfTwitterStats'), + ); + expect( + CredentialSubjectType.civicPassCredential.name, + equals('CivicPassCredential'), + ); + expect( + CredentialSubjectType.identityCredential.name, + equals('IdentityCredential'), + ); expect(CredentialSubjectType.eudiPid.name, equals('EudiPid')); expect(CredentialSubjectType.pid.name, equals('Pid')); expect(CredentialSubjectType.defaultCredential.name, equals('')); @@ -567,7 +643,9 @@ void main() { expect(value.blockchainWidget, isA()); } else if (value == CredentialSubjectType.ethereumAssociatedWallet) { expect( - value.blockchainWidget, isA()); + value.blockchainWidget, + isA(), + ); } else if (value == CredentialSubjectType.polygonAssociatedWallet) { expect(value.blockchainWidget, isA()); } else if (value == CredentialSubjectType.binanceAssociatedWallet) { @@ -584,40 +662,64 @@ void main() { expect(CredentialSubjectType.defiCompliance.title, 'Defi Compliance'); expect(CredentialSubjectType.livenessCard.title, 'Liveness'); expect( - CredentialSubjectType.tezotopiaMembership.title, 'Membership Card'); + CredentialSubjectType.tezotopiaMembership.title, + 'Membership Card', + ); expect(CredentialSubjectType.chainbornMembership.title, 'Chainborn'); expect(CredentialSubjectType.twitterCard.title, 'Twitter Account Proof'); expect(CredentialSubjectType.ageRange.title, 'Age Range'); expect(CredentialSubjectType.nationality.title, 'Nationality'); expect(CredentialSubjectType.gender.title, 'Gender'); expect(CredentialSubjectType.walletCredential.title, 'Wallet Credential'); - expect(CredentialSubjectType.tezosAssociatedWallet.title, - 'Tezos Associated Address'); - expect(CredentialSubjectType.ethereumAssociatedWallet.title, - 'Ethereum Associated Address'); - expect(CredentialSubjectType.fantomAssociatedWallet.title, - 'Fantom Associated Address'); - expect(CredentialSubjectType.polygonAssociatedWallet.title, - 'Polygon Associated Address'); - expect(CredentialSubjectType.binanceAssociatedWallet.title, - 'BNB Chain Associated Address'); - expect(CredentialSubjectType.ethereumPooAddress.title, - 'Ethereum Poo Address'); - expect( - CredentialSubjectType.fantomPooAddress.title, 'Fantom Poo Address'); - expect( - CredentialSubjectType.polygonPooAddress.title, 'Polygon Poo Address'); - expect(CredentialSubjectType.binancePooAddress.title, - 'BNB Chain Poo Address'); + expect( + CredentialSubjectType.tezosAssociatedWallet.title, + 'Tezos Associated Address', + ); + expect( + CredentialSubjectType.ethereumAssociatedWallet.title, + 'Ethereum Associated Address', + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.title, + 'Fantom Associated Address', + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.title, + 'Polygon Associated Address', + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.title, + 'BNB Chain Associated Address', + ); + expect( + CredentialSubjectType.ethereumPooAddress.title, + 'Ethereum Poo Address', + ); + expect( + CredentialSubjectType.fantomPooAddress.title, + 'Fantom Poo Address', + ); + expect( + CredentialSubjectType.polygonPooAddress.title, + 'Polygon Poo Address', + ); + expect( + CredentialSubjectType.binancePooAddress.title, + 'BNB Chain Poo Address', + ); expect(CredentialSubjectType.tezosPooAddress.title, 'Tezos Poo Address'); - expect(CredentialSubjectType.certificateOfEmployment.title, - 'Certificate of Employment'); + expect( + CredentialSubjectType.certificateOfEmployment.title, + 'Certificate of Employment', + ); expect(CredentialSubjectType.emailPass.title, 'Email Pass'); expect(CredentialSubjectType.identityPass.title, 'Identity Pass'); expect(CredentialSubjectType.verifiableIdCard.title, 'VerifiableId'); expect(CredentialSubjectType.linkedInCard.title, 'Linkedin Card'); - expect(CredentialSubjectType.learningAchievement.title, - 'Learning Achievement'); + expect( + CredentialSubjectType.learningAchievement.title, + 'Learning Achievement', + ); expect(CredentialSubjectType.over13.title, 'Over13'); expect(CredentialSubjectType.over15.title, 'Over15'); expect(CredentialSubjectType.over18.title, 'Over18'); @@ -626,12 +728,18 @@ void main() { expect(CredentialSubjectType.over65.title, 'Over18'); expect(CredentialSubjectType.passportFootprint.title, 'Passport Number'); expect(CredentialSubjectType.phonePass.title, 'Phone Proof'); - expect(CredentialSubjectType.professionalExperienceAssessment.title, - 'Professional Experience Assessment'); - expect(CredentialSubjectType.professionalSkillAssessment.title, - 'Professional Skill Assessment'); - expect(CredentialSubjectType.professionalStudentCard.title, - 'Professional Student Card'); + expect( + CredentialSubjectType.professionalExperienceAssessment.title, + 'Professional Experience Assessment', + ); + expect( + CredentialSubjectType.professionalSkillAssessment.title, + 'Professional Skill Assessment', + ); + expect( + CredentialSubjectType.professionalStudentCard.title, + 'Professional Student Card', + ); expect(CredentialSubjectType.residentCard.title, 'Resident Card'); expect(CredentialSubjectType.selfIssued.title, 'Self Issued'); expect(CredentialSubjectType.studentCard.title, 'Student Card'); @@ -641,27 +749,45 @@ void main() { expect(CredentialSubjectType.aragoPass.title, 'Arago Pass'); expect(CredentialSubjectType.aragoEmailPass.title, 'Arago Email Pass'); expect(CredentialSubjectType.aragoIdentityCard.title, 'Arago Id Card'); - expect(CredentialSubjectType.aragoLearningAchievement.title, - 'Arago Learning Achievement'); + expect( + CredentialSubjectType.aragoLearningAchievement.title, + 'Arago Learning Achievement', + ); expect(CredentialSubjectType.aragoOver18.title, 'Arago Over18'); - expect(CredentialSubjectType.pcdsAgentCertificate.title, - 'PCDS Agent Certificate'); + expect( + CredentialSubjectType.pcdsAgentCertificate.title, + 'PCDS Agent Certificate', + ); expect(CredentialSubjectType.euDiplomaCard.title, 'EU Diploma'); expect(CredentialSubjectType.euVerifiableId.title, 'EU VerifiableID'); expect( - CredentialSubjectType.kycAgeCredential.title, 'KYC Age Credential'); - expect(CredentialSubjectType.kycCountryOfResidence.title, - 'KYC Country of Residence'); - expect(CredentialSubjectType.proofOfTwitterStats.title, - 'Proof Of Twitter Stats'); - expect(CredentialSubjectType.civicPassCredential.title, - 'Civic Pass Credential'); - expect(CredentialSubjectType.employeeCredential.title, - 'Employee Credential'); - expect(CredentialSubjectType.legalPersonalCredential.title, - 'Legal Person Credential'); - expect(CredentialSubjectType.identityCredential.title, - 'Identity Credential'); + CredentialSubjectType.kycAgeCredential.title, + 'KYC Age Credential', + ); + expect( + CredentialSubjectType.kycCountryOfResidence.title, + 'KYC Country of Residence', + ); + expect( + CredentialSubjectType.proofOfTwitterStats.title, + 'Proof Of Twitter Stats', + ); + expect( + CredentialSubjectType.civicPassCredential.title, + 'Civic Pass Credential', + ); + expect( + CredentialSubjectType.employeeCredential.title, + 'Employee Credential', + ); + expect( + CredentialSubjectType.legalPersonalCredential.title, + 'Legal Person Credential', + ); + expect( + CredentialSubjectType.identityCredential.title, + 'Identity Credential', + ); expect(CredentialSubjectType.eudiPid.title, 'EudiPid'); expect(CredentialSubjectType.pid.title, 'Pid'); expect(CredentialSubjectType.defaultCredential.title, ''); @@ -690,15 +816,25 @@ void main() { expect(CredentialSubjectType.diplomaCard.supportSingleOnly, true); expect(CredentialSubjectType.twitterCard.supportSingleOnly, true); expect( - CredentialSubjectType.tezosAssociatedWallet.supportSingleOnly, true); - expect(CredentialSubjectType.ethereumAssociatedWallet.supportSingleOnly, - true); + CredentialSubjectType.tezosAssociatedWallet.supportSingleOnly, + true, + ); expect( - CredentialSubjectType.fantomAssociatedWallet.supportSingleOnly, true); - expect(CredentialSubjectType.polygonAssociatedWallet.supportSingleOnly, - true); - expect(CredentialSubjectType.binanceAssociatedWallet.supportSingleOnly, - true); + CredentialSubjectType.ethereumAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.supportSingleOnly, + true, + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.supportSingleOnly, + true, + ); expect(CredentialSubjectType.walletCredential.supportSingleOnly, false); expect(CredentialSubjectType.tezosPooAddress.supportSingleOnly, false); @@ -706,82 +842,132 @@ void main() { expect(CredentialSubjectType.fantomPooAddress.supportSingleOnly, false); expect(CredentialSubjectType.polygonPooAddress.supportSingleOnly, false); expect(CredentialSubjectType.binancePooAddress.supportSingleOnly, false); - expect(CredentialSubjectType.certificateOfEmployment.supportSingleOnly, - false); + expect( + CredentialSubjectType.certificateOfEmployment.supportSingleOnly, + false, + ); expect(CredentialSubjectType.defaultCredential.supportSingleOnly, false); expect(CredentialSubjectType.emailPass.supportSingleOnly, false); expect(CredentialSubjectType.linkedInCard.supportSingleOnly, false); expect( - CredentialSubjectType.learningAchievement.supportSingleOnly, false); + CredentialSubjectType.learningAchievement.supportSingleOnly, + false, + ); expect(CredentialSubjectType.phonePass.supportSingleOnly, false); expect( - CredentialSubjectType - .professionalExperienceAssessment.supportSingleOnly, - false); + CredentialSubjectType + .professionalExperienceAssessment.supportSingleOnly, + false, + ); + expect( + CredentialSubjectType.professionalSkillAssessment.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.professionalSkillAssessment.supportSingleOnly, - false); - expect(CredentialSubjectType.professionalStudentCard.supportSingleOnly, - false); + CredentialSubjectType.professionalStudentCard.supportSingleOnly, + false, + ); expect(CredentialSubjectType.selfIssued.supportSingleOnly, false); expect(CredentialSubjectType.studentCard.supportSingleOnly, false); expect(CredentialSubjectType.aragoPass.supportSingleOnly, false); expect(CredentialSubjectType.aragoEmailPass.supportSingleOnly, false); expect(CredentialSubjectType.aragoIdentityCard.supportSingleOnly, false); - expect(CredentialSubjectType.aragoLearningAchievement.supportSingleOnly, - false); + expect( + CredentialSubjectType.aragoLearningAchievement.supportSingleOnly, + false, + ); expect(CredentialSubjectType.aragoOver18.supportSingleOnly, false); expect( - CredentialSubjectType.pcdsAgentCertificate.supportSingleOnly, false); + CredentialSubjectType.pcdsAgentCertificate.supportSingleOnly, + false, + ); expect(CredentialSubjectType.euDiplomaCard.supportSingleOnly, false); expect(CredentialSubjectType.euVerifiableId.supportSingleOnly, false); expect(CredentialSubjectType.kycAgeCredential.supportSingleOnly, false); expect( - CredentialSubjectType.kycCountryOfResidence.supportSingleOnly, false); + CredentialSubjectType.kycCountryOfResidence.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.proofOfTwitterStats.supportSingleOnly, false); + CredentialSubjectType.proofOfTwitterStats.supportSingleOnly, + false, + ); expect( - CredentialSubjectType.civicPassCredential.supportSingleOnly, false); + CredentialSubjectType.civicPassCredential.supportSingleOnly, + false, + ); expect(CredentialSubjectType.employeeCredential.supportSingleOnly, false); - expect(CredentialSubjectType.legalPersonalCredential.supportSingleOnly, - false); + expect( + CredentialSubjectType.legalPersonalCredential.supportSingleOnly, + false, + ); expect(CredentialSubjectType.identityCredential.supportSingleOnly, false); expect(CredentialSubjectType.eudiPid.supportSingleOnly, false); expect(CredentialSubjectType.pid.supportSingleOnly, false); }); test('CredentialSubjectType getVCFormatType returns correct value', () { - expect(CredentialSubjectType.ethereumAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.fantomAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.polygonAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.binanceAssociatedWallet.getVCFormatType, - VCFormatType.values); - expect(CredentialSubjectType.tezosAssociatedWallet.getVCFormatType, - VCFormatType.values); + expect( + CredentialSubjectType.ethereumAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.fantomAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.polygonAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.binanceAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); + expect( + CredentialSubjectType.tezosAssociatedWallet.getVCFormatType, + VCFormatType.values, + ); expect( - CredentialSubjectType.over13.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.over13.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over15.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over21.getVCFormatType, + [VCFormatType.ldpVc], + ); + expect( + CredentialSubjectType.over50.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over15.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.over65.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over21.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.gender.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over50.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.ageRange.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.over65.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.defiCompliance.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.gender.getVCFormatType, [VCFormatType.ldpVc]); + CredentialSubjectType.tezotopiaMembership.getVCFormatType, + [VCFormatType.ldpVc], + ); expect( - CredentialSubjectType.ageRange.getVCFormatType, [VCFormatType.ldpVc]); - expect(CredentialSubjectType.defiCompliance.getVCFormatType, - [VCFormatType.ldpVc]); - expect(CredentialSubjectType.tezotopiaMembership.getVCFormatType, - [VCFormatType.ldpVc]); - expect(CredentialSubjectType.chainbornMembership.getVCFormatType, - [VCFormatType.ldpVc]); + CredentialSubjectType.chainbornMembership.getVCFormatType, + [VCFormatType.ldpVc], + ); expect(CredentialSubjectType.verifiableIdCard.getVCFormatType, [ VCFormatType.ldpVc, @@ -790,10 +976,14 @@ void main() { VCFormatType.jwtVc, ]); - expect(CredentialSubjectType.identityCredential.getVCFormatType, - [VCFormatType.vcSdJWT]); - expect(CredentialSubjectType.eudiPid.getVCFormatType, - [VCFormatType.vcSdJWT]); + expect( + CredentialSubjectType.identityCredential.getVCFormatType, + [VCFormatType.vcSdJWT], + ); + expect( + CredentialSubjectType.eudiPid.getVCFormatType, + [VCFormatType.vcSdJWT], + ); expect(CredentialSubjectType.pid.getVCFormatType, [VCFormatType.vcSdJWT]); expect(CredentialSubjectType.over18.getVCFormatType, [ @@ -801,89 +991,167 @@ void main() { VCFormatType.jwtVcJson, ]); - expect(CredentialSubjectType.phonePass.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - expect(CredentialSubjectType.livenessCard.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - expect(CredentialSubjectType.emailPass.getVCFormatType, - [VCFormatType.ldpVc, VCFormatType.jwtVcJson]); - - expect(CredentialSubjectType.nationality.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.identityPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.passportFootprint.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.residentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect( - CredentialSubjectType.voucher.getVCFormatType, [VCFormatType.jwtVc]); - expect(CredentialSubjectType.tezVoucher.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.diplomaCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.twitterCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.walletCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.tezosPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.ethereumPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.fantomPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.polygonPooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.binancePooAddress.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.certificateOfEmployment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.defaultCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.linkedInCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.learningAchievement.getVCFormatType, - [VCFormatType.jwtVc]); - expect( - CredentialSubjectType - .professionalExperienceAssessment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.professionalSkillAssessment.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.professionalStudentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.selfIssued.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.studentCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoEmailPass.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoIdentityCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoLearningAchievement.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.aragoOver18.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.pcdsAgentCertificate.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.euDiplomaCard.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.euVerifiableId.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.kycAgeCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.kycCountryOfResidence.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.proofOfTwitterStats.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.civicPassCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.employeeCredential.getVCFormatType, - [VCFormatType.jwtVc]); - expect(CredentialSubjectType.legalPersonalCredential.getVCFormatType, - [VCFormatType.jwtVc]); + expect( + CredentialSubjectType.phonePass.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + expect( + CredentialSubjectType.livenessCard.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + expect( + CredentialSubjectType.emailPass.getVCFormatType, + [VCFormatType.ldpVc, VCFormatType.jwtVcJson], + ); + + expect( + CredentialSubjectType.nationality.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.identityPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.passportFootprint.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.residentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.voucher.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.tezVoucher.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.diplomaCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.twitterCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.walletCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.tezosPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.ethereumPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.fantomPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.polygonPooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.binancePooAddress.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.certificateOfEmployment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.defaultCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.linkedInCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.learningAchievement.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalExperienceAssessment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalSkillAssessment.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.professionalStudentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.selfIssued.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.studentCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoEmailPass.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoIdentityCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoLearningAchievement.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.aragoOver18.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.pcdsAgentCertificate.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.euDiplomaCard.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.euVerifiableId.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.kycAgeCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.kycCountryOfResidence.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.proofOfTwitterStats.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.civicPassCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.employeeCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); + expect( + CredentialSubjectType.legalPersonalCredential.getVCFormatType, + [VCFormatType.jwtVc], + ); }); test('CredentialSubjectType order returns correct value', () { diff --git a/test/app/shared/enum/polygon_id_network_test.dart b/test/app/shared/enum/polygon_id_network_test.dart index 54f309b20..e69762883 100644 --- a/test/app/shared/enum/polygon_id_network_test.dart +++ b/test/app/shared/enum/polygon_id_network_test.dart @@ -15,7 +15,9 @@ void main() { test('oppositeNetwork should return correct opposite network', () { expect( - PolygonIdNetwork.PolygonMainnet.oppositeNetwork, 'mumbai(testnet)'); + PolygonIdNetwork.PolygonMainnet.oppositeNetwork, + 'mumbai(testnet)', + ); expect(PolygonIdNetwork.PolygonMumbai.oppositeNetwork, 'mainnet'); }); }); diff --git a/test/app/shared/enum/status/credential_status_extension_test.dart b/test/app/shared/enum/status/credential_status_extension_test.dart index 77fc84dd8..a7527a7e7 100644 --- a/test/app/shared/enum/status/credential_status_extension_test.dart +++ b/test/app/shared/enum/status/credential_status_extension_test.dart @@ -11,8 +11,10 @@ void main() { expect(CredentialStatus.pending.icon, Icons.circle_outlined); expect(CredentialStatus.unknown.icon, Icons.circle_outlined); expect(CredentialStatus.invalidSignature.icon, Icons.circle_outlined); - expect(CredentialStatus.statusListInvalidSignature.icon, - Icons.circle_outlined); + expect( + CredentialStatus.statusListInvalidSignature.icon, + Icons.circle_outlined, + ); expect(CredentialStatus.noStatus.icon, Icons.circle_outlined); }); }); diff --git a/test/app/shared/enum/type/language_type_test.dart b/test/app/shared/enum/type/language_type_test.dart index eaaa11216..3a85ac106 100644 --- a/test/app/shared/enum/type/language_type_test.dart +++ b/test/app/shared/enum/type/language_type_test.dart @@ -25,7 +25,9 @@ void main() { test('LanguageType getTitle returns correct value', () { final l10n = MockAppLocalizations(); expect( - LanguageType.phone.getTitle(l10n: l10n, name: ''), equals('Phone')); + LanguageType.phone.getTitle(l10n: l10n, name: ''), + equals('Phone'), + ); expect(LanguageType.ca.getTitle(l10n: l10n, name: ''), equals('Catalan')); expect(LanguageType.en.getTitle(l10n: l10n, name: ''), equals('English')); expect(LanguageType.es.getTitle(l10n: l10n, name: ''), equals('Spanish')); diff --git a/test/app/shared/extension/unit8List_extension_test.dart b/test/app/shared/extension/unit8List_extension_test.dart deleted file mode 100644 index 9effdc86f..000000000 --- a/test/app/shared/extension/unit8List_extension_test.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'dart:typed_data'; -import 'package:altme/app/app.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Uint8ListExtension', () { - test( - 'filterPayload returns the original list if length is less than or equal to 6', - () { - final list = Uint8List.fromList([1, 2, 3]); - expect(list.filterPayload, list); - - final shortList = Uint8List.fromList([1, 2, 3, 4, 5, 6]); - expect(shortList.filterPayload, shortList); - }); - - test( - 'filterPayload returns the original list if the first two elements do not match the test list', - () { - final list = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9]); - expect(list.filterPayload, list); - - final differentFirstElement = - Uint8List.fromList([6, 1, 3, 4, 5, 6, 7, 8, 9]); - expect(differentFirstElement.filterPayload, differentFirstElement); - - final differentSecondElement = - Uint8List.fromList([5, 5, 3, 4, 5, 6, 7, 8, 9]); - expect(differentSecondElement.filterPayload, differentSecondElement); - }); - - test( - 'filterPayload returns a sublist starting from index 6 if the first two elements match the test list', - () { - final list = Uint8List.fromList([5, 1, 3, 4, 5, 6, 7, 8, 9]); - final expected = Uint8List.fromList([7, 8, 9]); - expect(list.filterPayload, expected); - }); - }); -} diff --git a/test/app/shared/extension/unit_8_list_extension_test.dart b/test/app/shared/extension/unit_8_list_extension_test.dart index e13d65fcb..2ff3c43eb 100644 --- a/test/app/shared/extension/unit_8_list_extension_test.dart +++ b/test/app/shared/extension/unit_8_list_extension_test.dart @@ -5,9 +5,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Uint8ListExtension', () { test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns the original list if length is less than or equal to 6', - () { + 'filterPayload returns the original list ' + 'if length is less than or equal to 6', () { final list = Uint8List.fromList([1, 2, 3]); expect(list.filterPayload, list); @@ -16,9 +15,8 @@ void main() { }); test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns the original list if the first two elements do not match the test list', - () { + 'filterPayload returns the original list ' + 'if the first two elements do not match the test list', () { final list = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9]); expect(list.filterPayload, list); @@ -32,9 +30,8 @@ void main() { }); test( - // ignore: lines_longer_than_80_chars - 'filterPayload returns a sublist starting from index 6 if the first two elements match the test list', - () { + 'filterPayload returns a sublist starting from index 6 ' + 'if the first two elements match the test list', () { final list = Uint8List.fromList([5, 1, 3, 4, 5, 6, 7, 8, 9]); final expected = Uint8List.fromList([7, 8, 9]); expect(list.filterPayload, expected); diff --git a/test/app/shared/helper_functions/helper_functions_test.dart b/test/app/shared/helper_functions/helper_functions_test.dart index d0b148260..d4b7764b9 100644 --- a/test/app/shared/helper_functions/helper_functions_test.dart +++ b/test/app/shared/helper_functions/helper_functions_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: lines_longer_than_80_chars + import 'dart:convert'; import 'package:altme/app/app.dart'; @@ -84,7 +86,8 @@ void main() { test('Should return last issuer DID if multiple issuers in URI', () { final uri = Uri.parse( - 'https://example.com?issuer=did:example1&issuer=did:example2',); + 'https://example.com?issuer=did:example1&issuer=did:example2', + ); expect(getIssuerDid(uriToCheck: uri), 'did:example2'); }); }); @@ -111,11 +114,12 @@ void main() { test('stringToHexPrefixedWith05 returns correct value', () { const payload = 'Bibash'; expect( - stringToHexPrefixedWith05( - payload: payload, - dateTime: DateTime(2022, 1, 1, 0, 0, 0, 0), - ), - '05010031323254657a6f73205369676e6564204d6573736167653a20616c746d652e696f20323032322d30312d30312030303a30303a30302e30303020426962617368',); + stringToHexPrefixedWith05( + payload: payload, + dateTime: DateTime(2022, 1, 1, 0, 0, 0, 0), + ), + '05010031323254657a6f73205369676e6564204d6573736167653a20616c746d652e696f20323032322d30312d30312030303a30303a30302e30303020426962617368', + ); }); test('getCredentialName returns correct credential name', () { @@ -148,17 +152,29 @@ void main() { test('getBlockchainType returns correct issuer name', () { expect( - getBlockchainType(AccountType.tezos), equals(BlockchainType.tezos),); - expect(getBlockchainType(AccountType.ethereum), - equals(BlockchainType.ethereum),); + getBlockchainType(AccountType.tezos), + equals(BlockchainType.tezos), + ); + expect( + getBlockchainType(AccountType.ethereum), + equals(BlockchainType.ethereum), + ); + expect( + getBlockchainType(AccountType.fantom), + equals(BlockchainType.fantom), + ); + expect( + getBlockchainType(AccountType.polygon), + equals(BlockchainType.polygon), + ); + expect( + getBlockchainType(AccountType.binance), + equals(BlockchainType.binance), + ); expect( - getBlockchainType(AccountType.fantom), equals(BlockchainType.fantom),); - expect(getBlockchainType(AccountType.polygon), - equals(BlockchainType.polygon),); - expect(getBlockchainType(AccountType.binance), - equals(BlockchainType.binance),); - expect(() => getBlockchainType(AccountType.ssi), - throwsA(isA()),); + () => getBlockchainType(AccountType.ssi), + throwsA(isA()), + ); }); test('getCredTypeFromName returns correct type', () { @@ -186,21 +202,22 @@ void main() { final result = await getssiMnemonicsInList(mockSecureStorage); expect( - result, - containsAll([ - 'word1', - 'word2', - 'word3', - 'word4', - 'word5', - 'word6', - 'word7', - 'word8', - 'word9', - 'word10', - 'word11', - 'word12', - ]),); + result, + containsAll([ + 'word1', + 'word2', + 'word3', + 'word4', + 'word5', + 'word6', + 'word7', + 'word8', + 'word9', + 'word10', + 'word11', + 'word12', + ]), + ); }); test('getDateTimeWithoutSpace replaces spaces with dashes', () { @@ -211,26 +228,34 @@ void main() { test('getIndexValue returns correct index for each DidKeyType', () { expect( - getIndexValue(isEBSIV3: true, didKeyType: DidKeyType.secp256k1), 3,); + getIndexValue(isEBSIV3: true, didKeyType: DidKeyType.secp256k1), + 3, + ); expect( - getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.secp256k1), 1,); + getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.secp256k1), + 1, + ); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.p256), 4); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.ebsiv3), 5); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.jwkP256), 6); expect(getIndexValue(isEBSIV3: false, didKeyType: DidKeyType.edDSA), 0); expect( - getIndexValue( - isEBSIV3: false, didKeyType: DidKeyType.jwtClientAttestation,), - 0,); + getIndexValue( + isEBSIV3: false, + didKeyType: DidKeyType.jwtClientAttestation, + ), + 0, + ); }); group('getWalletAttestationP256Key', () { test('returns existing key', () async { const existingKey = 'existing_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyForWallet),) - .thenAnswer((_) => Future.value(existingKey)); + when( + () => + mockSecureStorage.get(SecureStorageKeys.p256PrivateKeyForWallet), + ).thenAnswer((_) => Future.value(existingKey)); final result = await getWalletAttestationP256Key(mockSecureStorage); @@ -238,10 +263,10 @@ void main() { }); test('generates and returns new key', () async { - const newKey = 'new_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyForWallet),) - .thenAnswer((_) => Future.value(null)); + when( + () => + mockSecureStorage.get(SecureStorageKeys.p256PrivateKeyForWallet), + ).thenAnswer((_) => Future.value(null)); when(() => mockSecureStorage.set(any(), any())) .thenAnswer((_) async {}); @@ -262,9 +287,10 @@ void main() { group('getP256KeyToGetAndPresentVC', () { test('returns existing key', () async { const existingKey = 'existing_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC),) - .thenAnswer((_) => Future.value(existingKey)); + when( + () => mockSecureStorage + .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC), + ).thenAnswer((_) => Future.value(existingKey)); final result = await getP256KeyToGetAndPresentVC(mockSecureStorage); @@ -272,10 +298,10 @@ void main() { }); test('generates and returns new key', () async { - const newKey = 'new_key'; - when(() => mockSecureStorage - .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC),) - .thenAnswer((_) => Future.value(null)); + when( + () => mockSecureStorage + .get(SecureStorageKeys.p256PrivateKeyToGetAndPresentVC), + ).thenAnswer((_) => Future.value(null)); when(() => mockSecureStorage.set(any(), any())) .thenAnswer((_) async {}); @@ -313,8 +339,10 @@ void main() { expect(getDidKeyFromString('DidKeyType.p256'), DidKeyType.p256); expect(getDidKeyFromString('DidKeyType.ebsiv3'), DidKeyType.ebsiv3); expect(getDidKeyFromString('DidKeyType.jwkP256'), DidKeyType.jwkP256); - expect(getDidKeyFromString('DidKeyType.jwtClientAttestation'), - DidKeyType.jwtClientAttestation,); + expect( + getDidKeyFromString('DidKeyType.jwtClientAttestation'), + DidKeyType.jwtClientAttestation, + ); expect(getDidKeyFromString('InvalidKeyType'), null); expect(getDidKeyFromString(null), null); }); @@ -355,11 +383,15 @@ void main() { test('getSignatureType returns correct signature type for circuitId', () { expect(getSignatureType('credentialAtomicQuerySigV2'), 'BJJ Signature'); - expect(getSignatureType('credentialAtomicQuerySigV2OnChain'), - 'BJJ Signature',); + expect( + getSignatureType('credentialAtomicQuerySigV2OnChain'), + 'BJJ Signature', + ); expect(getSignatureType('credentialAtomicQueryMTPV2'), 'SMT Signature'); - expect(getSignatureType('credentialAtomicQueryMTPV2OnChain'), - 'SMT Signature',); + expect( + getSignatureType('credentialAtomicQueryMTPV2OnChain'), + 'SMT Signature', + ); expect(getSignatureType('unknownCircuitId'), ''); }); @@ -375,7 +407,9 @@ void main() { 'https://example.com?uri_list=https%3A%2F%2Fexample.com%2Fpath1&uri_list=https%3A%2F%2Fexample.com%2Fpath2'; final result = generateUriList(url); expect( - result, ['https://example.com/path1', 'https://example.com/path2'],); + result, + ['https://example.com/path1', 'https://example.com/path2'], + ); }); test('sortedPublcJwk returns sorted public JWK without private key', () { @@ -540,7 +574,8 @@ void main() { group('getPresentationDefinition', () { test('returns presentation definition from URI', () async { final uri = Uri.parse( - "https://example.com?presentation_definition={'title':'Test'}",); + "https://example.com?presentation_definition={'title':'Test'}", + ); final presentationDefinition = await getPresentationDefinition(uri: uri, client: mockClient); @@ -559,7 +594,8 @@ void main() { 'returns presentation definition from URI with ' 'presentation_definition_uri', () async { final uri = Uri.parse( - 'https://example.com?presentation_definition_uri=https://example.com/presentation.com',); + 'https://example.com?presentation_definition_uri=https://example.com/presentation.com', + ); dioAdapter.onGet( 'https://example.com/presentation.com', @@ -574,7 +610,8 @@ void main() { test('returns null for invalid presentation_definition_uri', () async { final uri = Uri.parse( - 'https://example.com?presentation_definition_uri=https://example.com/presentation.com',); + 'https://example.com?presentation_definition_uri=https://example.com/presentation.com', + ); dioAdapter.onGet( 'https://example.com/presentation.com', @@ -610,7 +647,8 @@ void main() { 'returns client metadata from URI with ' 'client_metadata_uri', () async { final uri = Uri.parse( - 'https://example.com?client_metadata_uri=https://example.com.com',); + 'https://example.com?client_metadata_uri=https://example.com.com', + ); dioAdapter.onGet( 'https://example.com.com', @@ -625,7 +663,8 @@ void main() { test('returns null for invalid client_metadata_uri', () async { final uri = Uri.parse( - 'https://example.com?client_metadata_uri=https://example.com.com',); + 'https://example.com?client_metadata_uri=https://example.com.com', + ); dioAdapter.onGet( 'https://example.com.com', @@ -808,72 +847,118 @@ void main() { }); test('getErrorResponseString returns correct ResponseString', () { - expect(getErrorResponseString('invalid_request'), - ResponseString.RESPONSE_STRING_invalidRequest,); - expect(getErrorResponseString('invalid_request_uri'), - ResponseString.RESPONSE_STRING_invalidRequest,); - expect(getErrorResponseString('invalid_request_object'), - ResponseString.RESPONSE_STRING_invalidRequest,); - - expect(getErrorResponseString('unauthorized_client'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('access_denied'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('invalid_or_missing_proof'), - ResponseString.RESPONSE_STRING_accessDenied,); - expect(getErrorResponseString('interaction_required'), - ResponseString.RESPONSE_STRING_accessDenied,); - - expect(getErrorResponseString('unsupported_response_type'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('invalid_scope'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('request_not_supported'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - expect(getErrorResponseString('request_uri_not_supported'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); - - expect(getErrorResponseString('unsupported_credential_type'), - ResponseString.RESPONSE_STRING_unsupportedCredential,); - expect(getErrorResponseString('login_required'), - ResponseString.RESPONSE_STRING_aloginIsRequired,); - expect(getErrorResponseString('account_selection_required'), - ResponseString.RESPONSE_STRING_aloginIsRequired,); - - expect(getErrorResponseString('consent_required'), - ResponseString.RESPONSE_STRING_userConsentIsRequired,); - - expect(getErrorResponseString('registration_not_supported'), - ResponseString.RESPONSE_STRING_theWalletIsNotRegistered,); - - expect(getErrorResponseString('invalid_grant'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); - expect(getErrorResponseString('invalid_client'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); - expect(getErrorResponseString('invalid_token'), - ResponseString.RESPONSE_STRING_credentialIssuanceDenied,); + expect( + getErrorResponseString('invalid_request'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); + expect( + getErrorResponseString('invalid_request_uri'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); + expect( + getErrorResponseString('invalid_request_object'), + ResponseString.RESPONSE_STRING_invalidRequest, + ); expect( - getErrorResponseString('unsupported_credential_format'), - ResponseString - .RESPONSE_STRING_thisCredentialFormatIsNotSupported,); + getErrorResponseString('unauthorized_client'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('access_denied'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('invalid_or_missing_proof'), + ResponseString.RESPONSE_STRING_accessDenied, + ); + expect( + getErrorResponseString('interaction_required'), + ResponseString.RESPONSE_STRING_accessDenied, + ); - expect(getErrorResponseString('unsupported_format'), - ResponseString.RESPONSE_STRING_thisFormatIsNotSupported,); + expect( + getErrorResponseString('unsupported_response_type'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('invalid_scope'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('request_not_supported'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + expect( + getErrorResponseString('request_uri_not_supported'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); + + expect( + getErrorResponseString('unsupported_credential_type'), + ResponseString.RESPONSE_STRING_unsupportedCredential, + ); + expect( + getErrorResponseString('login_required'), + ResponseString.RESPONSE_STRING_aloginIsRequired, + ); + expect( + getErrorResponseString('account_selection_required'), + ResponseString.RESPONSE_STRING_aloginIsRequired, + ); + + expect( + getErrorResponseString('consent_required'), + ResponseString.RESPONSE_STRING_userConsentIsRequired, + ); + + expect( + getErrorResponseString('registration_not_supported'), + ResponseString.RESPONSE_STRING_theWalletIsNotRegistered, + ); - expect(getErrorResponseString('invalid_issuer_metadata'), - ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid,); + expect( + getErrorResponseString('invalid_grant'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + expect( + getErrorResponseString('invalid_client'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + expect( + getErrorResponseString('invalid_token'), + ResponseString.RESPONSE_STRING_credentialIssuanceDenied, + ); + + expect( + getErrorResponseString('unsupported_credential_format'), + ResponseString.RESPONSE_STRING_thisCredentialFormatIsNotSupported, + ); + + expect( + getErrorResponseString('unsupported_format'), + ResponseString.RESPONSE_STRING_thisFormatIsNotSupported, + ); + + expect( + getErrorResponseString('invalid_issuer_metadata'), + ResponseString.RESPONSE_STRING_theCredentialOfferIsInvalid, + ); - expect(getErrorResponseString('server_error'), - ResponseString.RESPONSE_STRING_theServiceIsNotAvailable,); + expect( + getErrorResponseString('server_error'), + ResponseString.RESPONSE_STRING_theServiceIsNotAvailable, + ); expect( - getErrorResponseString('issuance_pending'), - ResponseString - .RESPONSE_STRING_theIssuanceOfThisCredentialIsPending,); + getErrorResponseString('issuance_pending'), + ResponseString.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending, + ); - expect(getErrorResponseString('random'), - ResponseString.RESPONSE_STRING_thisRequestIsNotSupported,); + expect( + getErrorResponseString('random'), + ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + ); }); test('isIDTokenOnly', () { @@ -937,7 +1022,7 @@ void main() { 'presentation_definition': { 'id': 'cred-123', 'format': 'vp', - 'input_descriptors': [], + 'input_descriptors': [], }, 'presentation_definition_uri': 'https://example.com/presentation', 'registration': { @@ -983,7 +1068,7 @@ void main() { format: Format.fromJson( { 'ldp_vc': { - 'proof_type': [], + 'proof_type': [], }, }, ), @@ -1230,7 +1315,7 @@ void main() { () => checkX509( clientId: '', header: { - 'x5c': [], + 'x5c': [], }, encodedData: '', ), diff --git a/test/app/shared/issuer/check_issuer_test.dart b/test/app/shared/issuer/check_issuer_test.dart index 8f1c68b42..8ce2671bb 100644 --- a/test/app/shared/issuer/check_issuer_test.dart +++ b/test/app/shared/issuer/check_issuer_test.dart @@ -28,7 +28,9 @@ void main() { mockSecureStorage = MockSecureStorage(); dioAdapter = DioAdapter( - dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); + dio: Dio(BaseOptions()), + matcher: const UrlRequestMatcher(), + ); client.httpClientAdapter = dioAdapter; mockClient = DioClient( baseUrl: 'https://example.com/', @@ -133,8 +135,8 @@ void main() { }); test( - 'should return empty issuer if organizationInfo.issuerDomain does not contain uriToCheck.host', - () async { + 'should return empty issuer if organizationInfo.issuerDomain ' + 'does not contain uriToCheck.host', () async { final response = { 'issuer': { 'preferredName': 'Example Issuer', @@ -156,8 +158,10 @@ void main() { final result = await checkIssuer.isIssuerInApprovedList(); - expect(jsonEncode(result), - equals(jsonEncode(Issuer.emptyIssuer(uriToCheck.host)))); + expect( + jsonEncode(result), + equals(jsonEncode(Issuer.emptyIssuer(uriToCheck.host))), + ); }); test('should throw exception when an error occurs', () async { diff --git a/test/app/shared/issuer/models/organization_info_test.dart b/test/app/shared/issuer/models/organization_info_test.dart index eb7d82165..cf0c8b53a 100644 --- a/test/app/shared/issuer/models/organization_info_test.dart +++ b/test/app/shared/issuer/models/organization_info_test.dart @@ -4,8 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('OrganizationInfo', () { test( - 'OrganizationInfo fromJson should return a valid OrganizationInfo object', - () { + 'OrganizationInfo fromJson should ' + 'return a valid OrganizationInfo object', () { final json = { 'id': 'org-123', 'legalName': 'Example Org', @@ -42,8 +42,8 @@ void main() { }); test( - 'OrganizationInfo.emptyOrganizationInfo should return an OrganizationInfo with default values', - () { + 'OrganizationInfo.emptyOrganizationInfo ' + 'should return an OrganizationInfo with default values', () { final organizationInfo = OrganizationInfo.emptyOrganizationInfo('example.com'); diff --git a/test/app/shared/models/state_message/state_message_test.dart b/test/app/shared/models/state_message/state_message_test.dart index 2467e27ba..dfb1db98d 100644 --- a/test/app/shared/models/state_message/state_message_test.dart +++ b/test/app/shared/models/state_message/state_message_test.dart @@ -1,5 +1,5 @@ -import 'package:test/test.dart'; import 'package:altme/app/app.dart'; +import 'package:test/test.dart'; void main() { group('StateMessage', () { diff --git a/test/app/shared/network/network_exception_test.dart b/test/app/shared/network/network_exception_test.dart index 53a02734d..1ea1e3f49 100644 --- a/test/app/shared/network/network_exception_test.dart +++ b/test/app/shared/network/network_exception_test.dart @@ -103,7 +103,9 @@ void main() { ); final message = NetworkException.getDioException(error: error); expect( - message.message, NetworkError.NETWORK_ERROR_NO_INTERNET_CONNECTION); + message.message, + NetworkError.NETWORK_ERROR_NO_INTERNET_CONNECTION, + ); }); test('return internalServerError response when statusCode is 500', () { diff --git a/test/app/shared/validators/wallet_address_validator_test.dart b/test/app/shared/validators/wallet_address_validator_test.dart index 0fca3d1ae..a55817624 100644 --- a/test/app/shared/validators/wallet_address_validator_test.dart +++ b/test/app/shared/validators/wallet_address_validator_test.dart @@ -21,9 +21,11 @@ void main() { test('returns true for valid Ethereum address', () { expect( - validator.validateWalletAddress( - '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'), - isTrue); + validator.validateWalletAddress( + '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + ), + isTrue, + ); }); test('returns false for invalid Ethereum address', () { @@ -32,9 +34,9 @@ void main() { test('returns true for valid Tezos address', () { expect( - validator - .validateWalletAddress('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb'), - isTrue); + validator.validateWalletAddress('tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb'), + isTrue, + ); }); test('returns false for invalid Tezos address', () { diff --git a/test/app/shared/widget/base/otp_textfield_test.dart b/test/app/shared/widget/base/otp_textfield_test.dart index 390068e64..34fca0ee4 100644 --- a/test/app/shared/widget/base/otp_textfield_test.dart +++ b/test/app/shared/widget/base/otp_textfield_test.dart @@ -1,7 +1,6 @@ import 'package:altme/app/app.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; import '../../../../helpers/helpers.dart'; @@ -71,8 +70,9 @@ void main() { expect(controllers[1].text, '1'); expect( - FocusScope.of(tester.element(find.byType(TextField).at(1))).hasFocus, - true); + FocusScope.of(tester.element(find.byType(TextField).at(1))).hasFocus, + true, + ); }); testWidgets('onTap moves cursor to end of text', (tester) async { @@ -91,7 +91,8 @@ void main() { expect( controllers[0].selection, TextSelection.fromPosition( - TextPosition(offset: controllers[0].text.length)), + TextPosition(offset: controllers[0].text.length), + ), ); }); }); diff --git a/test/app/shared/widget/base/page_test.dart b/test/app/shared/widget/base/page_test.dart index c8800f802..f41f5c81c 100644 --- a/test/app/shared/widget/base/page_test.dart +++ b/test/app/shared/widget/base/page_test.dart @@ -37,8 +37,8 @@ void main() { }); testWidgets( - 'renders CustomAppBar when title is provided and secure screen is true', - (tester) async { + 'renders CustomAppBar when title is provided ' + 'and secure screen is true', (tester) async { await tester.pumpApp( BasePage( body: Container(), diff --git a/test/app/shared/widget/dialog/confirm_dialog_test.dart b/test/app/shared/widget/dialog/confirm_dialog_test.dart index fbe07bd1f..5cf963e05 100644 --- a/test/app/shared/widget/dialog/confirm_dialog_test.dart +++ b/test/app/shared/widget/dialog/confirm_dialog_test.dart @@ -136,12 +136,14 @@ void main() { const yesText = 'Yes'; const noText = 'No'; - await tester.pumpApp(const ConfirmDialog( - title: title, - yes: yesText, - no: noText, - showNoButton: false, - )); + await tester.pumpApp( + const ConfirmDialog( + title: title, + yes: yesText, + no: noText, + showNoButton: false, + ), + ); expect(find.text(yesText.toUpperCase()), findsOneWidget); expect(find.text(noText.toUpperCase()), findsNothing); diff --git a/test/app/shared/widget/dialog/text_field_dialog_test.dart b/test/app/shared/widget/dialog/text_field_dialog_test.dart index 267382bea..4844bf3a0 100644 --- a/test/app/shared/widget/dialog/text_field_dialog_test.dart +++ b/test/app/shared/widget/dialog/text_field_dialog_test.dart @@ -16,7 +16,8 @@ void main() { no: 'No', ), ); - // Verify that the title, label, subtitle, and initial value are displayed. + // Verify that the title, label, subtitle, + // and initial value are displayed. expect(find.text('Title'), findsOneWidget); expect(find.text('Label'), findsOneWidget); expect(find.text('Subtitle'), findsOneWidget); diff --git a/test/app/shared/widget/wallet_logo_test.dart b/test/app/shared/widget/wallet_logo_test.dart index 5565c7fe9..5821e5eb0 100644 --- a/test/app/shared/widget/wallet_logo_test.dart +++ b/test/app/shared/widget/wallet_logo_test.dart @@ -136,7 +136,8 @@ void main() { }); testWidgets( - 'displays correct image for ProfileType.owfBaselineProfile in development', + 'displays correct image for ' + 'ProfileType.owfBaselineProfile in development', (WidgetTester tester) async { await tester.pumpApp( Scaffold( diff --git a/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart b/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart index af55c501d..7bc14632e 100644 --- a/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart +++ b/test/onboarding/gen_phrase/view/onboarding_gen_phrase_test.dart @@ -149,7 +149,8 @@ void main() { BlocProvider.value(value: walletCubit), BlocProvider.value(value: splashCubit), BlocProvider.value( - value: altmeChatSupportCubit), + value: altmeChatSupportCubit, + ), BlocProvider.value(value: profileCubit), ], child: const OnBoardingGenPhrasePage(), diff --git a/test/onboarding/helper_function/helper_function_test.dart b/test/onboarding/helper_function/helper_function_test.dart index 4de6827eb..8b06a4ca4 100644 --- a/test/onboarding/helper_function/helper_function_test.dart +++ b/test/onboarding/helper_function/helper_function_test.dart @@ -95,8 +95,8 @@ void main() { ); }); - const mnemonicString = - 'notice photo opera keen climb agent soft parrot best joke field devote'; + const mnemonicString = 'notice photo opera keen climb' + ' agent soft parrot best joke field devote'; test('should generate account correctly', () async { when(() => homeCubit.emitHasWallet()).thenAnswer((_) async => {}); diff --git a/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart b/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart index cdddecd8a..ced9e2d88 100644 --- a/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart +++ b/test/onboarding/protect_wallet/view/protect_wallet_page_test.dart @@ -205,7 +205,8 @@ void main() { BlocProvider.value(value: walletCubit), BlocProvider.value(value: splashCubit), BlocProvider.value( - value: altmeChatSupportCubit), + value: altmeChatSupportCubit, + ), BlocProvider.value( value: ProfileCubit( didKitProvider: didKitProvider, diff --git a/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart b/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart index 40be207fa..58ae82d34 100644 --- a/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart +++ b/test/onboarding/tos/cubit/onboarding_tos_cubit_test.dart @@ -40,7 +40,8 @@ void main() { ); blocTest( - 'emits [acceptanceButtonEnabled] when setAcceptanceButtonEnabled is called', + 'emits [acceptanceButtonEnabled] ' + 'when setAcceptanceButtonEnabled is called', build: () => onBoardingTosCubit, act: (cubit) => cubit.setAcceptanceButtonEnabled(acceptanceButtonEnabled: true), diff --git a/test/onboarding/tos/cubit/onboarding_tos_state_test.dart b/test/onboarding/tos/cubit/onboarding_tos_state_test.dart index de231cca7..0e4394b28 100644 --- a/test/onboarding/tos/cubit/onboarding_tos_state_test.dart +++ b/test/onboarding/tos/cubit/onboarding_tos_state_test.dart @@ -23,8 +23,8 @@ void main() { }); test( - 'toJson and fromJson methods should serialize and deserialize correctly', - () { + 'toJson and fromJson methods should serialize ' + 'and deserialize correctly', () { const state = OnBoardingTosState( agreeTerms: true, scrollIsOver: false, diff --git a/test/route/cubit/route_cubit_test.dart b/test/route/cubit/route_cubit_test.dart index 08a88168a..da958227f 100644 --- a/test/route/cubit/route_cubit_test.dart +++ b/test/route/cubit/route_cubit_test.dart @@ -1,8 +1,6 @@ import 'package:altme/route/route.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; -import 'package:logger/logger.dart'; void main() { group('RouteCubit', () { diff --git a/test/route/router/router_test.dart b/test/route/router/router_test.dart index c8ad47ae7..98b1f95b0 100644 --- a/test/route/router/router_test.dart +++ b/test/route/router/router_test.dart @@ -6,8 +6,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('RightToLeftRoute transition test', (WidgetTester tester) async { - final fromWidget = Scaffold(body: Center(child: Text('From Screen'))); - final toWidget = Scaffold(body: Center(child: Text('To Screen'))); + const fromWidget = Scaffold(body: Center(child: Text('From Screen'))); + const toWidget = Scaffold(body: Center(child: Text('To Screen'))); final navigatorKey = GlobalKey(); diff --git a/test/scan/cubit/scan_cubit.dart b/test/scan/cubit/scan_cubit.dart index f3b91c806..29daade2e 100644 --- a/test/scan/cubit/scan_cubit.dart +++ b/test/scan/cubit/scan_cubit.dart @@ -66,4 +66,4 @@ void main() { // Add more tests here... }); -} \ No newline at end of file +} diff --git a/test/splash/cubit/splash_cubit_test.dart b/test/splash/cubit/splash_cubit_test.dart index a867e4cc7..62d261ab2 100644 --- a/test/splash/cubit/splash_cubit_test.dart +++ b/test/splash/cubit/splash_cubit_test.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:altme/app/app.dart'; import 'package:altme/chat_room/chat_room.dart'; import 'package:altme/credentials/credentials.dart'; diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index 5f4b0a291..74df0adae 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -37,8 +37,10 @@ void main() { expect(colorScheme.onElevatedButton, equals(Colors.white)); expect(colorScheme.appBarUpperLayer, const Color(0xff25095B)); expect(colorScheme.appBarLowerLayer, equals(colorScheme.background)); - expect(colorScheme.surfaceContainer, - equals(const Color(0xff707070).withOpacity(0.07))); + expect( + colorScheme.surfaceContainer, + equals(const Color(0xff707070).withOpacity(0.07)), + ); expect(colorScheme.drawerSurface, const Color(0xff232630)); expect(colorScheme.label, equals(Colors.white)); expect(colorScheme.unSelectedLabel, const Color(0xff86809D)); @@ -46,8 +48,10 @@ void main() { expect(colorScheme.selectedBottomBar, equals(colorScheme.surface)); expect(colorScheme.drawerBackground, const Color(0xff0B0514)); expect(colorScheme.borderColor, const Color(0xFFDDCEF4)); - expect(colorScheme.defualtDialogCancelButtonBorderColor, - const Color(0xFFFFFFFF).withOpacity(0.2)); + expect( + colorScheme.defualtDialogCancelButtonBorderColor, + const Color(0xFFFFFFFF).withOpacity(0.2), + ); expect(colorScheme.markDownH1, equals(Colors.white)); expect(colorScheme.markDownH2, equals(Colors.white)); expect(colorScheme.markDownP, const Color(0xFFD1CCE3)); @@ -56,8 +60,10 @@ void main() { expect(colorScheme.subtitle2, const Color(0xFF8B8C92)); expect(colorScheme.profileDummy, const Color(0xFF212121)); expect(colorScheme.documentShadow, const Color(0xFF424242)); - expect(colorScheme.documentShape, - equals(const Color(0xff3700b3).withOpacity(0.05))); + expect( + colorScheme.documentShape, + equals(const Color(0xff3700b3).withOpacity(0.05)), + ); expect(colorScheme.star, const Color(0xFFFFB83D)); expect(colorScheme.genderIcon, const Color(0xFF212121)); expect(colorScheme.activeCredential, equals(Colors.green)); @@ -69,14 +75,18 @@ void main() { expect(colorScheme.alertInfoMessage, equals(Colors.cyan)); expect(colorScheme.alertSuccessMessage, equals(Colors.green)); expect(colorScheme.qrScanBackground, const Color(0xff2B1C48)); - expect(colorScheme.qrScanInnerShadow, - const Color(0xff000000).withOpacity(0.16)); + expect( + colorScheme.qrScanInnerShadow, + const Color(0xff000000).withOpacity(0.16), + ); expect(colorScheme.qrScanOuterShadow, const Color(0xff430F91)); expect(colorScheme.dialogText, const Color(0xffF5F5F5)); expect(colorScheme.tabBarNotSelected, const Color(0xFF280164)); expect(colorScheme.credentialBackground, const Color(0xFF211F33)); - expect(colorScheme.cryptoAccountNotSelected, - equals(Colors.grey.withOpacity(0.15))); + expect( + colorScheme.cryptoAccountNotSelected, + equals(Colors.grey.withOpacity(0.15)), + ); expect(colorScheme.startButtonColorA, const Color(0xff18ACFF)); expect(colorScheme.startButtonColorB, const Color(0xff6600FF)); expect(colorScheme.associatedWalletBorder, const Color(0xff524B67)); @@ -137,7 +147,9 @@ void main() { expect(textTheme.customListTileTitleStyle.fontWeight, FontWeight.w800); expect( - textTheme.customListTileSubTitleStyle.color, const Color(0xFF86809D)); + textTheme.customListTileSubTitleStyle.color, + const Color(0xFF86809D), + ); expect(textTheme.customListTileSubTitleStyle.fontSize, 16); expect(textTheme.customListTileSubTitleStyle.fontWeight, FontWeight.w400); @@ -310,7 +322,9 @@ void main() { ); expect(textTheme.learningAchievementDescription.fontSize, 12); expect( - textTheme.learningAchievementDescription.fontWeight, FontWeight.w400); + textTheme.learningAchievementDescription.fontWeight, + FontWeight.w400, + ); expect(textTheme.credentialIssuer.color, const Color(0xff212121)); expect(textTheme.credentialIssuer.fontSize, 13); @@ -373,17 +387,25 @@ void main() { expect(textTheme.tezosAssociatedAddressData.fontSize, 17); expect(textTheme.tezosAssociatedAddressData.fontWeight, FontWeight.normal); - expect(textTheme.tezosAssociatedAddressTitleCard.color, - const Color(0xffFAFDFF)); + expect( + textTheme.tezosAssociatedAddressTitleCard.color, + const Color(0xffFAFDFF), + ); expect(textTheme.tezosAssociatedAddressTitleCard.fontSize, 20); expect( - textTheme.tezosAssociatedAddressTitleCard.fontWeight, FontWeight.w700); + textTheme.tezosAssociatedAddressTitleCard.fontWeight, + FontWeight.w700, + ); expect( - textTheme.credentialStudentCardTextCard.color, const Color(0xffffffff)); + textTheme.credentialStudentCardTextCard.color, + const Color(0xffffffff), + ); expect(textTheme.credentialStudentCardTextCard.fontSize, 14); expect( - textTheme.credentialStudentCardTextCard.fontWeight, FontWeight.normal); + textTheme.credentialStudentCardTextCard.fontWeight, + FontWeight.normal, + ); expect(textTheme.over18.color, const Color(0xffffffff)); expect(textTheme.over18.fontSize, 20); @@ -546,7 +568,9 @@ void main() { expect(textTheme.credentialManifestTitle1.fontWeight, FontWeight.w700); expect( - textTheme.credentialManifestDescription.color, const Color(0xffFFFFFF)); + textTheme.credentialManifestDescription.color, + const Color(0xffFFFFFF), + ); expect(textTheme.credentialManifestDescription.fontSize, 16); expect(textTheme.credentialManifestDescription.fontWeight, FontWeight.w400); From 3365fbdc7722ddcb2b2c5b63764a9be0d79c8b93 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 09:22:46 +0000 Subject: [PATCH 43/48] user pin validation when getting credential --- .../user_pin/view/user_pin_page.dart | 60 ++++++++----------- lib/pin_code/widgets/pin_code_widget.dart | 9 ++- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lib/dashboard/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index f0014052c..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(), + create: (context) => PinCodeViewCubit(), child: UserPinView( onCancel: onCancel, onProceed: onProceed, @@ -79,42 +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, - 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!); - }, - ), + 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/pin_code/widgets/pin_code_widget.dart b/lib/pin_code/widgets/pin_code_widget.dart index 920efa667..e338e265d 100644 --- a/lib/pin_code/widgets/pin_code_widget.dart +++ b/lib/pin_code/widgets/pin_code_widget.dart @@ -24,6 +24,7 @@ class PinCodeWidget extends StatefulWidget { this.header, this.onLoginAttempt, this.isNewCode = false, + this.isUserPin = false, }) : circleUIConfig = circleUIConfig ?? const CircleUIConfig(), keyboardUIConfig = keyboardUIConfig ?? const KeyboardUIConfig(); @@ -33,6 +34,8 @@ class PinCodeWidget extends StatefulWidget { final String? subTitle; final int passwordDigits; 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; @@ -74,7 +77,7 @@ class _PinCodeWidgetState extends State }); } if (current.enteredPasscode.length == widget.passwordDigits) { - if (current.isPinCodeValid) { + if (current.isPinCodeValid || widget.isUserPin) { _validationCallback(); } else { if (widget.title == l10n.confirmYourPinCode) { @@ -89,6 +92,10 @@ class _PinCodeWidgetState extends State listener: (context, state) { widget.onLoginAttempt ?.call(state.loginAttemptCount, state.loginAttemptsRemaining); + // if (state.enteredPasscode.length == widget.passwordDigits && + // widget.isUserPin) { + // _validationCallback(); + // } }, builder: (context, state) { final enteredPasscode = state.enteredPasscode; From ee6ded1492da968554b99957cbcb5b73691f55e4 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 11:18:49 +0000 Subject: [PATCH 44/48] linter --- lib/app/shared/extension/extension.dart | 2 +- ...tension.dart => unit8_list_extension.dart} | 0 lib/app/shared/loading/loading_view.dart | 2 +- lib/app/shared/widget/numeric_keyboard.dart | 2 +- .../view/software_license_view.dart | 2 +- .../about_altme/terms/view/terms_page.dart | 2 +- .../view/account_private_key_page.dart | 2 +- .../view/private_key_qr_page.dart | 2 +- .../widget/confidential_client_widget.dart | 2 +- .../view/credential_qr_page.dart | 2 +- .../qr_display/view/qr_display_page.dart | 2 +- .../tos/view/onboarding_tos_page.dart | 2 +- lib/pin_code/view/confirm_pin_code_page.dart | 2 +- .../view/enter_new_pin_code_page.dart | 2 +- lib/pin_code/view/pin_code_page.dart | 2 +- pubspec.lock | 2 +- .../enum/type/blockchain_type_test.dart | 236 ++++++++++++------ test/theme/app_theme_test.dart | 2 +- 18 files changed, 178 insertions(+), 90 deletions(-) rename lib/app/shared/extension/{unit8List_extension.dart => unit8_list_extension.dart} (100%) diff --git a/lib/app/shared/extension/extension.dart b/lib/app/shared/extension/extension.dart index dc5db6f25..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/numeric_keyboard.dart b/lib/app/shared/widget/numeric_keyboard.dart index cefdfb5e5..2c69a7326 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, 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..e822e4ad1 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 @@ -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/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/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/widget/confidential_client_widget.dart index 997bc82a0..d2605cbf6 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 @@ -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/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/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/onboarding/tos/view/onboarding_tos_page.dart b/lib/onboarding/tos/view/onboarding_tos_page.dart index 2379327fa..0069f6493 100644 --- a/lib/onboarding/tos/view/onboarding_tos_page.dart +++ b/lib/onboarding/tos/view/onboarding_tos_page.dart @@ -70,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/pin_code/view/confirm_pin_code_page.dart b/lib/pin_code/view/confirm_pin_code_page.dart index f67b2fc88..3f89e92bc 100644 --- a/lib/pin_code/view/confirm_pin_code_page.dart +++ b/lib/pin_code/view/confirm_pin_code_page.dart @@ -85,7 +85,7 @@ class _ConfirmPinCodeViewState extends State { titleAlignment: Alignment.topCenter, 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.confirmYourPinCode, header: widget.isFromOnboarding 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 97e60631c..25ac66037 100644 --- a/lib/pin_code/view/enter_new_pin_code_page.dart +++ b/lib/pin_code/view/enter_new_pin_code_page.dart @@ -73,7 +73,7 @@ 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, header: widget.isFromOnboarding diff --git a/lib/pin_code/view/pin_code_page.dart b/lib/pin_code/view/pin_code_page.dart index fa3676f4d..a9bc9f239 100644 --- a/lib/pin_code/view/pin_code_page.dart +++ b/lib/pin_code/view/pin_code_page.dart @@ -84,7 +84,7 @@ class _PinCodeViewState extends State { return PopScope( canPop: !widget.restrictToBack, child: BasePage( - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, title: '', titleAlignment: Alignment.topCenter, titleLeading: widget.restrictToBack ? null : const BackLeadingButton(), diff --git a/pubspec.lock b/pubspec.lock index e04714c7a..5efc42bde 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -595,7 +595,7 @@ packages: didkit: dependency: transitive description: - path: "didkit/lib/flutter" + path: "../didkit/lib/flutter" relative: true source: path version: "0.0.2" 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/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index 74df0adae..331f14354 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -36,7 +36,7 @@ void main() { 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.appBarLowerLayer, equals(colorScheme.surface)); expect( colorScheme.surfaceContainer, equals(const Color(0xff707070).withOpacity(0.07)), From 1ceb1f9e6849a8d8d4b58fa20cc4f0412aa9a2b2 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 11:51:30 +0000 Subject: [PATCH 45/48] CustomColorScheme factorisation --- lib/theme/app_theme/app_theme.dart | 141 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/lib/theme/app_theme/app_theme.dart b/lib/theme/app_theme/app_theme.dart index 9aca45e97..1d7176d76 100644 --- a/lib/theme/app_theme/app_theme.dart +++ b/lib/theme/app_theme/app_theme.dart @@ -103,151 +103,152 @@ 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 redColor => error; + Color get transactionApplied => onTertiary; + Color get transactionFailed => error; + Color get transactionSkipped => onErrorContainer; + Color get activeColorOfNetwork => primary; - Color get greyText => const Color(0xFFD1CCE3); + Color get greyText => onSurface.withOpacity(0.6); - Color get kycKeyIconColor => const Color(0xFF86809D); + Color get kycKeyIconColor => onSurface.withOpacity(0.6); - Color get lightPurple => const Color(0xFF5F556F); + Color get lightPurple => secondary; - Color get popupBackground => const Color(0xff271C38); + Color get popupBackground => surface; - Color get cardHighlighted => const Color(0xFF251F38); + Color get cardHighlighted => surface; - Color get defaultDialogDark => const Color(0xFF322643); + Color get defaultDialogDark => surface; - Color get closeIconColor => const Color(0xFFA79ABA); + Color get closeIconColor => onSurface.withOpacity(0.6); - Color get kycVerifyButton => const Color(0xFF0045FF); + Color get kycVerifyButton => primary; - Color get checkMarkColor => const Color(0xFF00B267); + Color get checkMarkColor => onTertiary; - Color get accountBottomSheetBorder => Colors.grey[200]!; + Color get accountBottomSheetBorder => onSurface.withOpacity(0.12); - Color get digitPrimaryColor => Colors.white; + Color get digitPrimaryColor => onSurface; Color get digitFillColor => Colors.transparent; - Color get disabledBgColor => const Color(0xFF6A5F7B); + Color get disabledBgColor => onSurface.withOpacity(0.12); - Color get disabledTextColor => const Color(0xFF000000); + Color get disabledTextColor => onSurface.withOpacity(0.38); - Color get darkGradientStartColor => const Color(0xff0A0F19); + Color get darkGradientStartColor => surface; - Color get darkGradientEndColor => const Color(0xff25095B); + Color get darkGradientEndColor => surface; Color get transparent => Colors.transparent; - Color get onOutlineButton => const Color(0xFF6600FF); + Color get onOutlineButton => primary; - Color get onElevatedButton => const Color(0xFFFFFFFF); + Color get onElevatedButton => onPrimary; - Color get appBarUpperLayer => const Color(0xff25095B); + Color get appBarUpperLayer => surface; Color get appBarLowerLayer => surface; - Color get surfaceContainer => const Color(0xff707070).withOpacity(0.07); + Color get surfaceContainer => surface.withOpacity(0.07); - Color get drawerSurface => const Color(0xff232630); + Color get drawerSurface => surface; - Color get label => Colors.white; + Color get label => onSurface; - Color get unSelectedLabel => const Color(0xff86809D); + Color get unSelectedLabel => onSurface.withOpacity(0.6); - Color get leadingButton => const Color(0xffF1EFF8); + Color get leadingButton => onSurface; Color get selectedBottomBar => surface; - Color get drawerBackground => const Color(0xff0B0514); + Color get drawerBackground => surface; - Color get borderColor => const Color(0xFFDDCEF4); + Color get borderColor => onSurface.withOpacity(0.12); Color get defualtDialogCancelButtonBorderColor => - const Color(0xFFFFFFFF).withOpacity(0.2); + onSurface.withOpacity(0.2); - Color get markDownH1 => const Color(0xFFFFFFFF); + Color get markDownH1 => onSurface; - Color get markDownH2 => const Color(0xFFFFFFFF); + Color get markDownH2 => onSurface; - Color get markDownP => const Color(0xFFD1CCE3); + Color get markDownP => onSurface.withOpacity(0.6); - Color get markDownA => const Color(0xff517bff); + Color get markDownA => primary; - Color get subtitle1 => const Color(0xFFFFFFFF); + Color get subtitle1 => onSurface; - Color get subtitle2 => const Color(0xFF8B8C92); + Color get subtitle2 => onSurface.withOpacity(0.6); - Color get profileDummy => const Color(0xFF212121); + Color get profileDummy => onSurface; - Color get documentShadow => const Color(0xFF424242); + Color get documentShadow => onSurface.withOpacity(0.12); - Color get documentShape => const Color(0xff3700b3).withOpacity(0.05); + Color get documentShape => primary.withOpacity(0.05); - Color get star => const Color(0xFFFFB83D); + Color get star => onErrorContainer; - Color get genderIcon => const Color(0xFF212121); + Color get genderIcon => onSurface; - Color get activeCredential => Colors.green; + Color get activeCredential => onTertiary; - Color get expiredCredential => Colors.orange; + Color get expiredCredential => onErrorContainer; - Color get revokedCredential => Colors.red; + Color get revokedCredential => error; - Color get buttonDisabled => const Color(0xFF424242); + Color get buttonDisabled => onSurface.withOpacity(0.38); - Color get alertErrorMessage => Colors.red; + Color get alertErrorMessage => error; - Color get alertWarningMessage => Colors.yellow; + Color get alertWarningMessage => onErrorContainer; - Color get alertInfoMessage => Colors.cyan; + Color get alertInfoMessage => outline; - Color get alertSuccessMessage => Colors.green; + Color get alertSuccessMessage => onTertiary; - Color get qrScanBackground => const Color(0xff2B1C48); + Color get qrScanBackground => surface; - Color get qrScanInnerShadow => const Color(0xff000000).withOpacity(0.16); + Color get qrScanInnerShadow => shadow.withOpacity(0.16); - Color get qrScanOuterShadow => const Color(0xff430F91); + Color get qrScanOuterShadow => primary; - Color get dialogText => const Color(0xffF5F5F5); + Color get dialogText => onSurface; - Color get tabBarNotSelected => const Color(0xFF280164); + Color get tabBarNotSelected => secondaryContainer; - Color get credentialBackground => const Color(0xFF211F33); + Color get credentialBackground => surface; - Color get cryptoAccountNotSelected => Colors.grey.withOpacity(0.15); + Color get cryptoAccountNotSelected => onSurface.withOpacity(0.15); - Color get startButtonColorA => const Color(0xff18ACFF); + Color get startButtonColorA => primary; - Color get startButtonColorB => const Color(0xff6600FF); + Color get startButtonColorB => primaryContainer; - Color get associatedWalletBorder => const Color(0xff524B67); + Color get associatedWalletBorder => onSurface.withOpacity(0.12); - Color get deleteColor => const Color(0xff322643); + Color get deleteColor => surface; - Color get blueColor => const Color(0xff322643); + Color get blueColor => surface; - Color get titleColor => const Color(0xffD1CCE3); + Color get titleColor => onSurface; - Color get valueColor => const Color(0xffFFFFFF); + Color get valueColor => onSurface; - Color get lightGrey => const Color(0xFF616161); + Color get lightGrey => onSurface.withOpacity(0.6); - Color get darkGrey => const Color(0xFF212121); + Color get darkGrey => onSurface; - Color get activeColor => const Color(0xFF08B530); + Color get activeColor => onTertiary; - Color get inactiveColor => const Color(0xFFFF0045); + Color get inactiveColor => error; - Color get beaconBorder => const Color(0xff86809D); + Color get beaconBorder => onSurface.withOpacity(0.6); - Color get cardBackground => const Color(0xFF211F33); + Color get cardBackground => surface; } extension CustomTextTheme on TextTheme { From 09f0296cfb7e98147d09c5467fe6034a55e91589 Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 12:09:00 +0000 Subject: [PATCH 46/48] remove a few CustomColorScheme --- .../widgets/token_select_box.dart | 5 +- .../widgets/network_switcher_button.dart | 2 +- .../widgets/transaction_item.dart | 4 +- lib/pin_code/widgets/pin_code_title.dart | 4 +- lib/theme/app_theme/app_theme.dart | 78 +------------------ test/theme/app_theme_test.dart | 12 +-- 6 files changed, 16 insertions(+), 89 deletions(-) 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..0cedea183 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 @@ -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/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..6d1bfd6a7 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 @@ -20,7 +20,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/transaction_item.dart b/lib/dashboard/home/tab_bar/tokens/send_receive_home/widgets/transaction_item.dart index 2c9dd5511..e2cd7f3a7 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,11 +103,11 @@ 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 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/theme/app_theme/app_theme.dart b/lib/theme/app_theme/app_theme.dart index 1d7176d76..97796ad12 100644 --- a/lib/theme/app_theme/app_theme.dart +++ b/lib/theme/app_theme/app_theme.dart @@ -105,149 +105,73 @@ abstract class AppTheme { extension CustomColorScheme on ColorScheme { - Color get redColor => error; - Color get transactionApplied => onTertiary; - Color get transactionFailed => error; - Color get transactionSkipped => onErrorContainer; - Color get activeColorOfNetwork => primary; - - Color get greyText => onSurface.withOpacity(0.6); - Color get kycKeyIconColor => onSurface.withOpacity(0.6); - Color get lightPurple => secondary; - Color get popupBackground => surface; - Color get cardHighlighted => surface; - Color get defaultDialogDark => surface; - Color get closeIconColor => onSurface.withOpacity(0.6); - Color get kycVerifyButton => primary; - Color get checkMarkColor => onTertiary; - Color get accountBottomSheetBorder => onSurface.withOpacity(0.12); - Color get digitPrimaryColor => onSurface; - Color get digitFillColor => Colors.transparent; - Color get disabledBgColor => onSurface.withOpacity(0.12); - Color get disabledTextColor => onSurface.withOpacity(0.38); - Color get darkGradientStartColor => surface; - Color get darkGradientEndColor => surface; - Color get transparent => Colors.transparent; - Color get onOutlineButton => primary; - Color get onElevatedButton => onPrimary; - Color get appBarUpperLayer => surface; - Color get appBarLowerLayer => surface; - Color get surfaceContainer => surface.withOpacity(0.07); - Color get drawerSurface => surface; - Color get label => onSurface; - Color get unSelectedLabel => onSurface.withOpacity(0.6); - Color get leadingButton => onSurface; - Color get selectedBottomBar => surface; - Color get drawerBackground => surface; - Color get borderColor => onSurface.withOpacity(0.12); - - Color get defualtDialogCancelButtonBorderColor => - onSurface.withOpacity(0.2); - + Color get defualtDialogCancelButtonBorderColor => onSurface.withOpacity(0.2); Color get markDownH1 => onSurface; - Color get markDownH2 => onSurface; - Color get markDownP => onSurface.withOpacity(0.6); - Color get markDownA => primary; - Color get subtitle1 => onSurface; - Color get subtitle2 => onSurface.withOpacity(0.6); - Color get profileDummy => onSurface; - Color get documentShadow => onSurface.withOpacity(0.12); - Color get documentShape => primary.withOpacity(0.05); - Color get star => onErrorContainer; - Color get genderIcon => onSurface; - Color get activeCredential => onTertiary; - Color get expiredCredential => onErrorContainer; - Color get revokedCredential => error; - Color get buttonDisabled => onSurface.withOpacity(0.38); - Color get alertErrorMessage => error; - Color get alertWarningMessage => onErrorContainer; - Color get alertInfoMessage => outline; - Color get alertSuccessMessage => onTertiary; - Color get qrScanBackground => surface; - Color get qrScanInnerShadow => shadow.withOpacity(0.16); - Color get qrScanOuterShadow => primary; - Color get dialogText => onSurface; - Color get tabBarNotSelected => secondaryContainer; - Color get credentialBackground => surface; - Color get cryptoAccountNotSelected => onSurface.withOpacity(0.15); - Color get startButtonColorA => primary; - Color get startButtonColorB => primaryContainer; - Color get associatedWalletBorder => onSurface.withOpacity(0.12); - Color get deleteColor => surface; - Color get blueColor => surface; - Color get titleColor => onSurface; - Color get valueColor => onSurface; - Color get lightGrey => onSurface.withOpacity(0.6); - Color get darkGrey => onSurface; - Color get activeColor => onTertiary; - Color get inactiveColor => error; - Color get beaconBorder => onSurface.withOpacity(0.6); - Color get cardBackground => surface; } diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index 331f14354..b0283c948 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -11,12 +11,12 @@ 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.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.kycKeyIconColor, const Color(0xFF86809D)); expect(colorScheme.lightPurple, const Color(0xFF5F556F)); expect(colorScheme.popupBackground, const Color(0xff271C38)); From d78ef5d044683ff09c6a26c5b1ed75769947823e Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 13:28:32 +0000 Subject: [PATCH 47/48] remove colorScheme extension --- .../status/credential_status_extension.dart | 5 +- .../enum/type/message_type/message_type.dart | 1 - .../message_type/message_type_extension.dart | 8 +- lib/app/shared/widget/base/markdown_page.dart | 13 +- lib/app/shared/widget/base/otp_textfield.dart | 3 +- .../widget/button/my_elevated_button.dart | 5 +- .../widget/button/my_gradient_button.dart | 15 +- .../widget/button/my_outlined_button.dart | 7 +- .../widget/cached_image_from_network.dart | 31 ++-- lib/app/shared/widget/default_dialog.dart | 2 +- .../widget/dialog/becareful_dialog.dart | 6 +- .../shared/widget/dialog/confirm_dialog.dart | 6 +- .../widget/dialog/error_details_dialog.dart | 8 +- .../shared/widget/dialog/error_dialog.dart | 6 +- .../widget/dialog/text_field_dialog.dart | 10 +- .../shared/widget/dialog_close_button.dart | 3 +- lib/app/shared/widget/display_terms.dart | 10 +- lib/app/shared/widget/error_view.dart | 2 +- lib/app/shared/widget/grouped_section.dart | 3 +- lib/app/shared/widget/imported_tag.dart | 3 +- lib/app/shared/widget/numeric_keyboard.dart | 18 +-- lib/app/shared/widget/phrase_word.dart | 2 +- .../view/import_account_step3_page.dart | 2 +- .../import_account/widgets/account_item.dart | 2 +- .../verify_age/view/ai_age_result_page.dart | 3 +- .../verify_age/view/verify_age_page.dart | 2 +- .../widgets/permissions.dart | 2 +- .../widgets/select_account.dart | 2 +- .../view/connected_dapps_page.dart | 2 +- .../operation/widgets/fee_details.dart | 4 +- .../operation/widgets/sender_reciever.dart | 2 +- .../view/crypto_bottom_sheet_view.dart | 6 +- .../discover/view/discover_page.dart | 3 +- .../discover/view/discover_tab_page.dart | 3 +- .../widgets/discover_dynamic_detail.dart | 2 +- .../about_altme/view/about_altme_menu.dart | 2 +- .../view/software_license_view.dart | 2 +- .../view/blockchain_settings_menu.dart | 3 +- .../widgets/manage_accounts_item.dart | 4 +- .../view/manage_network_page.dart | 5 +- .../help_center/faqs/view/faqs_page.dart | 2 +- .../help_center/view/help_center_menu.dart | 3 +- .../import_talao_community_card_page.dart | 2 +- .../profile/view/pick_profile_menu.dart | 3 +- .../widget/profile_selector_widget.dart | 4 +- .../reset_wallet/view/reset_wallet_menu.dart | 2 +- .../src/view/check_linkedin_profile.dart | 3 +- .../drawer/src/view/drawer_page.dart | 3 +- .../src/widgets/drawer_category_item.dart | 4 +- .../drawer/src/widgets/drawer_item.dart | 19 ++- .../drawer/src/widgets/drawer_item2.dart | 19 ++- .../src/widgets/drawer_item_divider.dart | 3 +- .../drawer/src/widgets/enterprise_data.dart | 2 +- .../ssi/backup/src/view/backup_menu.dart | 3 +- .../drawer/ssi/manage_did/view/did_menu.dart | 3 +- .../widget/client_authentication_widget.dart | 6 +- .../widget/client_type_widget.dart | 6 +- .../widget/confidential_client_widget.dart | 4 +- .../widget/did_key_type_widget.dart | 6 +- .../widget/draft_type_widget.dart | 6 +- .../widget/option_container.dart | 2 +- .../widget/proof_header_widget.dart | 6 +- .../widget/proof_type_widget.dart | 6 +- .../widget/vc_format_widget.dart | 6 +- .../widgets/upload_file.dart | 4 +- .../ssi/restore/src/view/restore_menu.dart | 3 +- .../drawer/ssi/src/view/ssi_menu.dart | 3 +- .../view/trust_framework_page.dart | 2 +- .../view/advanced_security_settings_menu.dart | 3 +- .../src/view/wallet_security_menu.dart | 3 +- .../view/wallet_settings_menu.dart | 3 +- .../widget/language_selector_widget.dart | 4 +- lib/dashboard/home/home/widgets/qr_icon.dart | 8 +- .../home/widgets/token_reward_dialog.dart | 2 +- .../home/home/widgets/wallet_dialog.dart | 16 +-- .../widgets/credential_active_status.dart | 2 +- .../widgets/credential_subject_data.dart | 5 +- .../widgets/deferred_credential_data.dart | 9 +- .../detail/widgets/developer_details.dart | 5 +- .../view/get_linkedin_info_page.dart | 2 +- .../list/view/home_credentials_list_page.dart | 3 +- .../widgets/credential_detail_tab_bar.dart | 2 +- .../list/widgets/credential_item_shimmer.dart | 2 +- .../polygon_id_credential_offer_view.dart | 2 +- .../view/polygon_id_verification_view.dart | 2 +- .../view/credentials_receive_page.dart | 2 +- .../credentials/widgets/activity_widget.dart | 6 +- .../widgets/credential_background.dart | 3 +- .../widgets/credential_container.dart | 3 +- .../widgets/credential_dynamic_detail.dart | 4 +- .../credential_manifest_card.dart | 2 +- .../credential_manifest_details.dart | 5 +- .../expansiontile_container.dart | 9 +- ...essional_experience_assessment_widget.dart | 2 +- .../resident_card_widget.dart | 6 +- .../wallet_credential_widget.dart | 5 +- .../widgets/descriptioni_dialog.dart | 3 +- .../credentials/widgets/display_wiget.dart | 4 +- .../home/tab_bar/nft/view/nft_page.dart | 2 +- .../home/tab_bar/nft/widgets/nft_item.dart | 2 +- .../tab_bar/nft/widgets/nft_item_shimmer.dart | 2 +- .../tab_bar/nft/widgets/nft_url_widget.dart | 3 +- .../tab_controller/widgets/tab_bar.dart | 2 +- .../all_tokens/view/all_tokens_page.dart | 6 +- .../widgets/token_contract_item.dart | 2 +- .../view/confirm_token_transaction_page.dart | 2 +- .../confirm_transaction_details_card.dart | 4 +- .../widgets/transaction_done_dialog.dart | 2 +- .../widgets/token_select_box.dart | 2 +- .../tokens/receive/view/receive_page.dart | 2 +- .../widgets/change_network_bottom_sheet.dart | 8 +- .../widgets/network_switcher_button.dart | 1 - .../widgets/recent_transactions.dart | 8 +- .../widgets/transaction_item.dart | 2 +- .../tokens/token_page/view/token_page.dart | 2 +- .../tokens/token_page/widgets/token_item.dart | 2 +- .../widgets/token_item_shimmer.dart | 2 +- .../widgets/account_select_box_view.dart | 14 +- .../widgets/withdrawal_address_input.dart | 3 +- .../qr_code/widget/developer_mode_dialog.dart | 5 +- .../search/widgets/search_item_shimmer.dart | 2 +- .../select_network_fee_bottom_sheet.dart | 6 +- .../src/widgets/bottom_bar_item.dart | 10 +- .../src/widgets/home_title_leading.dart | 3 +- .../view/import_from_wallet_page.dart | 2 +- .../view/import_wallet_page.dart | 2 +- .../widgets/wallet_type_item.dart | 5 +- .../widget/kyc_button.dart | 3 +- .../widgets/finish_kyc_dialog.dart | 2 +- lib/kyc_verification/widgets/kyc_dialog.dart | 7 +- .../widgets/biometrics_switch.dart | 2 +- .../view/onboarding_gen_phrase.dart | 2 +- .../view/protect_wallet_page.dart | 2 +- lib/onboarding/starter/view/starter_page.dart | 9 +- lib/onboarding/widgets/protect_widget.dart | 2 +- .../widget/display_selective_disclosure.dart | 10 +- lib/theme/app_theme/app_theme.dart | 72 ---------- test/theme/app_theme_test.dart | 136 +++++++++--------- 138 files changed, 395 insertions(+), 440 deletions(-) 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/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 62155f4f2..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'; @@ -96,7 +95,7 @@ ButtonStyle elevatedStyleFrom({ ), 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: WidgetStateProperty.all( @@ -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/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 2c69a7326..f3a43ff5c 100644 --- a/lib/app/shared/widget/numeric_keyboard.dart +++ b/lib/app/shared/widget/numeric_keyboard.dart @@ -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..b9936dd81 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 @@ -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/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 e822e4ad1..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( 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/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/view/reset_wallet_menu.dart b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart index 231e6b652..56ecebe59 100644 --- a/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart +++ b/lib/dashboard/drawer/reset_wallet/view/reset_wallet_menu.dart @@ -38,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( 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 df9c74d38..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), diff --git a/lib/dashboard/drawer/src/widgets/drawer_category_item.dart b/lib/dashboard/drawer/src/widgets/drawer_category_item.dart index 2e2d4debe..72e0113a4 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.surface, 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..bbb2efb47 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.surface, 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 d2605cbf6..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( 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/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..de34a668e 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 @@ -42,7 +42,7 @@ class MyTab extends StatelessWidget { : null, color: isSelected ? null - : AppTheme.darkThemeData.colorScheme.tabBarNotSelected, + : AppTheme.darkThemeData.colorScheme.secondaryContainer, ), child: Row( mainAxisAlignment: MainAxisAlignment.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 0cedea183..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, 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 6d1bfd6a7..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'; 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 e2cd7f3a7..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 @@ -111,7 +111,7 @@ class TransactionItem extends StatelessWidget { : 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/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/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/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/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/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 55e113a93..1417b60e8 100644 --- a/lib/onboarding/protect_wallet/view/protect_wallet_page.dart +++ b/lib/onboarding/protect_wallet/view/protect_wallet_page.dart @@ -133,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/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/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/theme/app_theme/app_theme.dart b/lib/theme/app_theme/app_theme.dart index 97796ad12..30c4acf11 100644 --- a/lib/theme/app_theme/app_theme.dart +++ b/lib/theme/app_theme/app_theme.dart @@ -103,78 +103,6 @@ abstract class AppTheme { ); } - -extension CustomColorScheme on ColorScheme { - Color get kycKeyIconColor => onSurface.withOpacity(0.6); - Color get lightPurple => secondary; - Color get popupBackground => surface; - Color get cardHighlighted => surface; - Color get defaultDialogDark => surface; - Color get closeIconColor => onSurface.withOpacity(0.6); - Color get kycVerifyButton => primary; - Color get checkMarkColor => onTertiary; - Color get accountBottomSheetBorder => onSurface.withOpacity(0.12); - Color get digitPrimaryColor => onSurface; - Color get digitFillColor => Colors.transparent; - Color get disabledBgColor => onSurface.withOpacity(0.12); - Color get disabledTextColor => onSurface.withOpacity(0.38); - Color get darkGradientStartColor => surface; - Color get darkGradientEndColor => surface; - Color get transparent => Colors.transparent; - Color get onOutlineButton => primary; - Color get onElevatedButton => onPrimary; - Color get appBarUpperLayer => surface; - Color get appBarLowerLayer => surface; - Color get surfaceContainer => surface.withOpacity(0.07); - Color get drawerSurface => surface; - Color get label => onSurface; - Color get unSelectedLabel => onSurface.withOpacity(0.6); - Color get leadingButton => onSurface; - Color get selectedBottomBar => surface; - Color get drawerBackground => surface; - Color get borderColor => onSurface.withOpacity(0.12); - Color get defualtDialogCancelButtonBorderColor => onSurface.withOpacity(0.2); - Color get markDownH1 => onSurface; - Color get markDownH2 => onSurface; - Color get markDownP => onSurface.withOpacity(0.6); - Color get markDownA => primary; - Color get subtitle1 => onSurface; - Color get subtitle2 => onSurface.withOpacity(0.6); - Color get profileDummy => onSurface; - Color get documentShadow => onSurface.withOpacity(0.12); - Color get documentShape => primary.withOpacity(0.05); - Color get star => onErrorContainer; - Color get genderIcon => onSurface; - Color get activeCredential => onTertiary; - Color get expiredCredential => onErrorContainer; - Color get revokedCredential => error; - Color get buttonDisabled => onSurface.withOpacity(0.38); - Color get alertErrorMessage => error; - Color get alertWarningMessage => onErrorContainer; - Color get alertInfoMessage => outline; - Color get alertSuccessMessage => onTertiary; - Color get qrScanBackground => surface; - Color get qrScanInnerShadow => shadow.withOpacity(0.16); - Color get qrScanOuterShadow => primary; - Color get dialogText => onSurface; - Color get tabBarNotSelected => secondaryContainer; - Color get credentialBackground => surface; - Color get cryptoAccountNotSelected => onSurface.withOpacity(0.15); - Color get startButtonColorA => primary; - Color get startButtonColorB => primaryContainer; - Color get associatedWalletBorder => onSurface.withOpacity(0.12); - Color get deleteColor => surface; - Color get blueColor => surface; - Color get titleColor => onSurface; - Color get valueColor => onSurface; - Color get lightGrey => onSurface.withOpacity(0.6); - Color get darkGrey => onSurface; - Color get activeColor => onTertiary; - Color get inactiveColor => error; - Color get beaconBorder => onSurface.withOpacity(0.6); - Color get cardBackground => surface; -} - extension CustomTextTheme on TextTheme { TextStyle get hintTextFieldStyle => GoogleFonts.nunito( fontSize: 14, diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index b0283c948..f1fbb7566 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -17,89 +17,89 @@ void main() { expect(colorScheme.onErrorContainer, const Color(0xFFFF5F0A)); expect(colorScheme.primary, const Color(0xFF2C7DF7)); expect(colorScheme.onSurface.withOpacity(0.6), 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.surface)); + 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.surfaceContainer, + colorScheme.surface.withOpacity(0.07), 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.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.defualtDialogCancelButtonBorderColor, + colorScheme.onSurface.withOpacity(0.2), 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.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.documentShape, + colorScheme.primary.withOpacity(0.05), 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.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.qrScanInnerShadow, + colorScheme.shadow.withOpacity(0.16), 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.primary, const Color(0xff430F91)); + expect(colorScheme.onSurface, const Color(0xffF5F5F5)); + expect(colorScheme.secondaryContainer, const Color(0xFF280164)); + expect(colorScheme.surface, const Color(0xFF211F33)); expect( - colorScheme.cryptoAccountNotSelected, + colorScheme.onSurface.withOpacity(0.15), 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.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', () { From 3d87a2562315678e481d939391d08be52130264c Mon Sep 17 00:00:00 2001 From: hawkbee1 Date: Wed, 5 Jun 2024 15:00:55 +0000 Subject: [PATCH 48/48] Adjust surfaces colors --- .../shared/widget/base/background_card.dart | 2 +- .../view/crypto_bottom_sheet_view.dart | 2 +- .../src/widgets/drawer_category_item.dart | 2 +- .../drawer/src/widgets/drawer_item.dart | 2 +- .../tab_controller/widgets/tab_bar.dart | 31 +++++++++---------- lib/theme/app_theme/app_theme.dart | 12 ++++--- 6 files changed, 26 insertions(+), 25 deletions(-) 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/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 b9936dd81..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, diff --git a/lib/dashboard/drawer/src/widgets/drawer_category_item.dart b/lib/dashboard/drawer/src/widgets/drawer_category_item.dart index 72e0113a4..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.surface, + color: Theme.of(context).colorScheme.surfaceBright, borderRadius: const BorderRadius.all( Radius.circular(Sizes.normalRadius), ), diff --git a/lib/dashboard/drawer/src/widgets/drawer_item.dart b/lib/dashboard/drawer/src/widgets/drawer_item.dart index bbb2efb47..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.surface, + color: Theme.of(context).colorScheme.surfaceBright, borderRadius: const BorderRadius.all( Radius.circular( Sizes.normalRadius, 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 de34a668e..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.secondaryContainer, - ), + 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/theme/app_theme/app_theme.dart b/lib/theme/app_theme/app_theme.dart index 30c4acf11..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(