diff --git a/lib/app/shared/enum/type/oidc4vc_type.dart b/lib/app/shared/enum/type/oidc4vc_type.dart index 8f5f24558..9840cbe48 100644 --- a/lib/app/shared/enum/type/oidc4vc_type.dart +++ b/lib/app/shared/enum/type/oidc4vc_type.dart @@ -1,4 +1,7 @@ -enum OIDC4VCTye { +import 'package:dio/dio.dart'; +import 'package:oidc4vc/oidc4vc.dart'; + +enum OIDC4VCType { EBSIV2( issuerVcType: 'jwt_vc', verifierVpType: 'jwt_vp', @@ -151,7 +154,7 @@ enum OIDC4VCTye { serviceDocumentation: '', ); - const OIDC4VCTye({ + const OIDC4VCType({ required this.issuerVcType, required this.verifierVpType, required this.offerPrefix, @@ -181,3 +184,27 @@ enum OIDC4VCTye { final String siopv2Draft; final String serviceDocumentation; } + +extension OIDC4VCTypeX on OIDC4VCType { + OIDC4VC get getOIDC4VC { + return OIDC4VC( + client: Dio(), + oidc4vcModel: OIDC4VCModel( + issuerVcType: issuerVcType, + verifierVpType: verifierVpType, + offerPrefix: offerPrefix, + presentationPrefix: presentationPrefix, + cryptographicBindingMethodsSupported: + cryptographicBindingMethodsSupported, + cryptographicSuitesSupported: cryptographicSuitesSupported, + subjectSyntaxTypesSupported: subjectSyntaxTypesSupported, + grantTypesSupported: grantTypesSupported, + credentialSupported: credentialSupported, + schemaForType: schemaForType, + oidc4VciDraft: oidc4VciDraft, + siopv2Draft: siopv2Draft, + serviceDocumentation: serviceDocumentation, + ), + ); + } +} diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 2dd64ff98..51291c20e 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -33,7 +33,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:jwt_decode/jwt_decode.dart'; import 'package:key_generator/key_generator.dart'; -import 'package:oidc4vc/oidc4vc.dart'; import 'package:polygonid/polygonid.dart'; import 'package:secure_storage/secure_storage.dart' as secure_storage; import 'package:secure_storage/secure_storage.dart'; @@ -144,7 +143,7 @@ class App extends StatelessWidget { credentialsCubit: context.read(), didKitProvider: DIDKitProvider(), secureStorageProvider: secure_storage.getSecureStorage, - oidc4vc: OIDC4VC(Dio()), + profileCubit: context.read(), ), ), BlocProvider( diff --git a/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/did_ebsi_private_key_page.dart b/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/did_ebsi_private_key_page.dart index a4ea23f45..9d46734b7 100644 --- a/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/did_ebsi_private_key_page.dart +++ b/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/did_ebsi_private_key_page.dart @@ -1,10 +1,10 @@ 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:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:oidc4vc/oidc4vc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:secure_storage/secure_storage.dart'; class DidEbsiPrivateKeyPage extends StatefulWidget { @@ -27,7 +27,8 @@ class _DidEbsiPrivateKeyPageState extends State late AnimationController animationController; Future getPrivateKey() async { - final oidc4vc = OIDC4VC(Dio()); + final oidc4vc = + context.read().state.model.oidc4vcType.getOIDC4VC; final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic); final privateKey = await oidc4vc.privateKeyFromMnemonic(mnemonic: mnemonic!); diff --git a/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/manage_did_ebsi_page.dart b/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/manage_did_ebsi_page.dart index 08b2c62ca..39a937a06 100644 --- a/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/manage_did_ebsi_page.dart +++ b/lib/dashboard/drawer/ssi/manage_did/view/did_ebsi/manage_did_ebsi_page.dart @@ -1,12 +1,11 @@ import 'package:altme/app/app.dart'; -import 'package:altme/dashboard/drawer/drawer.dart'; +import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:oidc4vc/oidc4vc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:secure_storage/secure_storage.dart'; -class ManageDidEbsiPage extends StatelessWidget { +class ManageDidEbsiPage extends StatefulWidget { const ManageDidEbsiPage({super.key}); static Route route() { @@ -16,8 +15,14 @@ class ManageDidEbsiPage extends StatelessWidget { ); } + @override + State createState() => _ManageDidEbsiPageState(); +} + +class _ManageDidEbsiPageState extends State { Future getDid() async { - final oidc4vc = OIDC4VC(Dio()); + final oidc4vc = + context.read().state.model.oidc4vcType.getOIDC4VC; final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic); final privateKey = await oidc4vc.privateKeyFromMnemonic(mnemonic: mnemonic!); diff --git a/lib/dashboard/drawer/ssi/oidc4vc_profile/view/oidc4vc_profile_page.dart b/lib/dashboard/drawer/ssi/oidc4vc_profile/view/oidc4vc_profile_page.dart index 124e4649a..a8e6a7a8f 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_profile/view/oidc4vc_profile_page.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_profile/view/oidc4vc_profile_page.dart @@ -41,7 +41,7 @@ class OIDC4VCProfilePage extends StatelessWidget { ), ), child: ListView.builder( - itemCount: OIDC4VCTye.values.length, + itemCount: OIDC4VCType.values.length, shrinkWrap: true, physics: const ScrollPhysics(), itemBuilder: (context, index) { @@ -51,28 +51,29 @@ class OIDC4VCProfilePage extends StatelessWidget { onTap: () { context .read() - .updateOIDC4VCType(OIDC4VCTye.values[index]); + .updateOIDC4VCType(OIDC4VCType.values[index]); }, shape: const RoundedRectangleBorder( side: BorderSide( - color: Color(0xFFDDDDEE), width: 0.5), + color: Color(0xFFDDDDEE), + width: 0.5, + ), ), title: Text( - OIDC4VCTye.values[index].name, + OIDC4VCType.values[index].name, style: Theme.of(context) .listTileTheme .titleTextStyle ?.copyWith(color: const Color(0xFF080F33)), ), trailing: Icon( - state.model.oidc4vcType == - OIDC4VCTye.values[index].toString() + state.model.oidc4vcType == OIDC4VCType.values[index] ? Icons.radio_button_checked : Icons.radio_button_unchecked, size: Sizes.icon2x, ), ), - if (index < OIDC4VCTye.values.length - 1) + if (index < OIDC4VCType.values.length - 1) Padding( padding: const EdgeInsets.symmetric( horizontal: Sizes.spaceSmall, diff --git a/lib/dashboard/home/tab_bar/credentials/detail/cubit/credential_details_cubit.dart b/lib/dashboard/home/tab_bar/credentials/detail/cubit/credential_details_cubit.dart index 1f35c2336..02ee3ff33 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/cubit/credential_details_cubit.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/cubit/credential_details_cubit.dart @@ -23,7 +23,7 @@ class CredentialDetailsCubit extends Cubit { required this.secureStorageProvider, required this.client, required this.jwtDecode, - required this.polygonId, + required this.profileCubit, required this.polygonIdCubit, }) : super(const CredentialDetailsState()); @@ -31,7 +31,7 @@ class CredentialDetailsCubit extends Cubit { final SecureStorageProvider secureStorageProvider; final DioClient client; final JWTDecode jwtDecode; - final PolygonId polygonId; + final ProfileCubit profileCubit; final PolygonIdCubit polygonIdCubit; void changeTabStatus(CredentialDetailTabStatus credentialDetailTabStatus) { @@ -70,6 +70,7 @@ class CredentialDetailsCubit extends Cubit { issuerDid, issuerKid, item.jwt!, + profileCubit, ); late CredentialStatus credentialStatus; @@ -103,7 +104,8 @@ class CredentialDetailsCubit extends Cubit { network = Parameters.POLYGON_TEST_NETWORK; } - final List claim = await polygonId.getClaimById( + final List claim = + await polygonIdCubit.polygonId.getClaimById( claimId: item.id, mnemonic: mnemonic!, network: network, diff --git a/lib/dashboard/home/tab_bar/credentials/detail/view/credentials_details_page.dart b/lib/dashboard/home/tab_bar/credentials/detail/view/credentials_details_page.dart index 0a9bbaf60..ac3d3ee2b 100644 --- a/lib/dashboard/home/tab_bar/credentials/detail/view/credentials_details_page.dart +++ b/lib/dashboard/home/tab_bar/credentials/detail/view/credentials_details_page.dart @@ -14,7 +14,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:jwt_decode/jwt_decode.dart'; -import 'package:polygonid/polygonid.dart'; import 'package:secure_storage/secure_storage.dart'; import 'package:share_plus/share_plus.dart'; @@ -55,7 +54,7 @@ class CredentialsDetailsPage extends StatelessWidget { secureStorageProvider: getSecureStorage, client: DioClient('', Dio()), jwtDecode: JWTDecode(), - polygonId: PolygonId(), + profileCubit: context.read(), polygonIdCubit: context.read(), ), ), diff --git a/lib/dashboard/profile/cubit/profile_cubit.dart b/lib/dashboard/profile/cubit/profile_cubit.dart index 23be4582f..01207728f 100644 --- a/lib/dashboard/profile/cubit/profile_cubit.dart +++ b/lib/dashboard/profile/cubit/profile_cubit.dart @@ -94,9 +94,18 @@ class ProfileCubit extends Cubit { (await secureStorageProvider.get(SecureStorageKeys.alertEnabled)) == 'true'; - final oidc4vcType = - (await secureStorageProvider.get(SecureStorageKeys.oidc4vcType)) ?? - OIDC4VCTye.EBSIV2.toString(); + var oidc4vcType = OIDC4VCType.EBSIV2; + + for (final type in OIDC4VCType.values) { + final oidc4vcTypeName = + await secureStorageProvider.get(SecureStorageKeys.oidc4vcType); + + if (oidc4vcTypeName != null) { + if (type.name == oidc4vcTypeName) { + oidc4vcType = type; + } + } + } final profileModel = ProfileModel( firstName: firstName, @@ -192,7 +201,7 @@ class ProfileCubit extends Cubit { await secureStorageProvider.set( SecureStorageKeys.oidc4vcType, - profileModel.oidc4vcType, + profileModel.oidc4vcType.name, ); emit( @@ -237,11 +246,9 @@ class ProfileCubit extends Cubit { await update(profileModel); } - Future updateOIDC4VCType(OIDC4VCTye oidc4vcTye) async { + Future updateOIDC4VCType(OIDC4VCType oidc4vcTye) async { emit(state.copyWith(status: AppStatus.loading)); - final profileModel = - state.model.copyWith(oidc4vcType: oidc4vcTye.toString()); - + final profileModel = state.model.copyWith(oidc4vcType: oidc4vcTye); await update(profileModel); } diff --git a/lib/dashboard/profile/models/profile.dart b/lib/dashboard/profile/models/profile.dart index b814815c7..a3d50bc49 100644 --- a/lib/dashboard/profile/models/profile.dart +++ b/lib/dashboard/profile/models/profile.dart @@ -40,7 +40,7 @@ class ProfileModel extends Equatable { isBiometricEnabled: false, isAlertEnabled: false, tezosNetwork: TezosNetwork.mainNet(), - oidc4vcType: OIDC4VCTye.EBSIV2.toString(), + oidc4vcType: OIDC4VCType.EBSIV2, ); final String firstName; @@ -56,7 +56,7 @@ class ProfileModel extends Equatable { final bool isEnterprise; final bool isBiometricEnabled; final bool isAlertEnabled; - final String oidc4vcType; + final OIDC4VCType oidc4vcType; @override List get props => [ @@ -92,7 +92,7 @@ class ProfileModel extends Equatable { bool? isEnterprise, bool? isBiometricEnabled, bool? isAlertEnabled, - String? oidc4vcType, + OIDC4VCType? oidc4vcType, }) { return ProfileModel( firstName: firstName ?? this.firstName, diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index 4983b7ac8..07e9d534e 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -301,6 +301,7 @@ class QRCodeScanCubit extends Cubit { issuerDid, issuerKid, encodedData.toString(), + profileCubit, ); if (isVerified == VerificationType.verified) { @@ -326,8 +327,8 @@ class QRCodeScanCubit extends Cubit { state.uri.toString().startsWith('openid-initiate_issuance://')) { await initiateEbsiCredentialIssuance( state.uri.toString(), - client, credentialsCubit, + profileCubit, getSecureStorage, ); diff --git a/lib/ebsi/initiate_ebsi_credential_issuance.dart b/lib/ebsi/initiate_ebsi_credential_issuance.dart index 01016e9c7..1817115f4 100644 --- a/lib/ebsi/initiate_ebsi_credential_issuance.dart +++ b/lib/ebsi/initiate_ebsi_credential_issuance.dart @@ -1,17 +1,18 @@ import 'package:altme/app/app.dart'; import 'package:altme/credentials/credentials.dart'; +import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/ebsi/add_ebsi_credential.dart'; -import 'package:dio/dio.dart'; import 'package:oidc4vc/oidc4vc.dart'; import 'package:secure_storage/secure_storage.dart'; Future initiateEbsiCredentialIssuance( String scannedResponse, - DioClient client, CredentialsCubit credentialsCubit, + ProfileCubit profileCubit, SecureStorageProvider secureStorage, ) async { - final OIDC4VC oidc4vc = OIDC4VC(Dio()); + final OIDC4VC oidc4vc = profileCubit.state.model.oidc4vcType.getOIDC4VC; + final Uri uriFromScannedResponse = Uri.parse(scannedResponse); if (uriFromScannedResponse.queryParameters['pre-authorized_code'] != null) { final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic); diff --git a/lib/ebsi/verify_encoded_data.dart b/lib/ebsi/verify_encoded_data.dart index 3b97a3d4d..d7f90887d 100644 --- a/lib/ebsi/verify_encoded_data.dart +++ b/lib/ebsi/verify_encoded_data.dart @@ -1,12 +1,14 @@ -import 'package:dio/dio.dart'; +import 'package:altme/app/app.dart'; +import 'package:altme/dashboard/dashboard.dart'; import 'package:oidc4vc/oidc4vc.dart'; Future verifyEncodedData( String issuerDid, String issuerKid, String jwt, + ProfileCubit profileCubit, ) async { - final OIDC4VC oidc4vc = OIDC4VC(Dio()); + final OIDC4VC oidc4vc = profileCubit.state.model.oidc4vcType.getOIDC4VC; final VerificationType verificationType = await oidc4vc.verifyEncodedData( issuerDid: issuerDid, diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index b2e7ec53b..c842a5f32 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -36,14 +36,14 @@ class ScanCubit extends Cubit { required this.credentialsCubit, required this.didKitProvider, required this.secureStorageProvider, - required this.oidc4vc, + required this.profileCubit, }) : super(const ScanState()); final DioClient client; final CredentialsCubit credentialsCubit; final DIDKitProvider didKitProvider; final SecureStorageProvider secureStorageProvider; - final OIDC4VC oidc4vc; + final ProfileCubit profileCubit; Future credentialOffer({ required Uri uri, @@ -59,7 +59,7 @@ class ScanCubit extends Cubit { try { if (uri.queryParameters['scope'] == 'openid' || uri.toString().startsWith('openid://?client_id')) { - final oidc4vc = OIDC4VC(Dio()); + final OIDC4VC oidc4vc = profileCubit.state.model.oidc4vcType.getOIDC4VC; final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic); final privateKey = diff --git a/lib/splash/view/splash_page.dart b/lib/splash/view/splash_page.dart index ef1aac9da..f31da0737 100644 --- a/lib/splash/view/splash_page.dart +++ b/lib/splash/view/splash_page.dart @@ -11,7 +11,6 @@ import 'package:altme/l10n/l10n.dart'; import 'package:altme/polygon_id/polygon_id.dart'; import 'package:altme/splash/splash.dart'; import 'package:altme/theme/app_theme/app_theme.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' as services; @@ -147,11 +146,10 @@ class _SplashViewState extends State { beaconData = value; } if (uri.scheme == 'openid' && uri.authority == 'initiate_issuance') { - final DioClient client = DioClient('', Dio()); await initiateEbsiCredentialIssuance( uri.toString(), - client, context.read(), + context.read(), secure_storage.getSecureStorage, ); } diff --git a/packages/oidc4vc/lib/oidc4vc.dart b/packages/oidc4vc/lib/oidc4vc.dart index c3b956993..7badc83cd 100644 --- a/packages/oidc4vc/lib/oidc4vc.dart +++ b/packages/oidc4vc/lib/oidc4vc.dart @@ -8,6 +8,7 @@ /// EBSI wallet compliance library ebsi; +export 'src/iodc4vc_model.dart'; export 'src/issuer_token_parameters.dart'; export 'src/oidc4vc.dart'; export 'src/token_parameters.dart'; diff --git a/packages/oidc4vc/lib/src/iodc4vc_model.dart b/packages/oidc4vc/lib/src/iodc4vc_model.dart new file mode 100644 index 000000000..42b004882 --- /dev/null +++ b/packages/oidc4vc/lib/src/iodc4vc_model.dart @@ -0,0 +1,31 @@ +class OIDC4VCModel { + const OIDC4VCModel({ + required this.issuerVcType, + required this.verifierVpType, + required this.offerPrefix, + required this.presentationPrefix, + required this.cryptographicBindingMethodsSupported, + required this.cryptographicSuitesSupported, + required this.subjectSyntaxTypesSupported, + required this.grantTypesSupported, + required this.credentialSupported, + required this.schemaForType, + required this.oidc4VciDraft, + required this.siopv2Draft, + required this.serviceDocumentation, + }); + + final String issuerVcType; + final String verifierVpType; + final String offerPrefix; + final String presentationPrefix; + final List cryptographicBindingMethodsSupported; + final List cryptographicSuitesSupported; + final List subjectSyntaxTypesSupported; + final List grantTypesSupported; + final List credentialSupported; + final bool schemaForType; + final String oidc4VciDraft; + final String siopv2Draft; + final String serviceDocumentation; +} diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index dc7f5a216..af5b252d5 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -10,6 +10,7 @@ import 'package:flutter/foundation.dart'; import 'package:hex/hex.dart'; import 'package:jose/jose.dart'; import 'package:json_path/json_path.dart'; +import 'package:oidc4vc/src/iodc4vc_model.dart'; import 'package:oidc4vc/src/issuer_token_parameters.dart'; import 'package:oidc4vc/src/token_parameters.dart'; import 'package:oidc4vc/src/verification_type.dart'; @@ -22,10 +23,14 @@ import 'package:uuid/uuid.dart'; /// {@endtemplate} class OIDC4VC { /// {@macro ebsi} - OIDC4VC(this.client); + OIDC4VC({ + required this.client, + required this.oidc4vcModel, + }); /// final Dio client; + final OIDC4VCModel oidc4vcModel; /// create JWK from mnemonic Future privateKeyFromMnemonic({required String mnemonic}) async { diff --git a/packages/oidc4vc/test/src/oidc4vc_test.dart b/packages/oidc4vc/test/src/oidc4vc_test.dart index c6ec0faa5..08ed8373f 100644 --- a/packages/oidc4vc/test/src/oidc4vc_test.dart +++ b/packages/oidc4vc/test/src/oidc4vc_test.dart @@ -1,750 +1,750 @@ -// Copyright (c) 2022, Very Good Ventures -// https://verygood.ventures -// -// Use of this source code is governed by an MIT-style -// license that can be found in the LICENSE file or at -// https://opensource.org/licenses/MIT. - -import 'dart:convert'; - -import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; -import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; -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 'const_values.dart'; - -class MockDio extends Mock implements Dio {} - -void main() { - final client = Dio(); - final dioAdapter = - DioAdapter(dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); - client.httpClientAdapter = dioAdapter; - - const mnemonic = - 'position taste mention august skin taste best air sure acoustic poet ritual'; // ignore: lines_longer_than_80_chars - - const issuer = - 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/.well-known/openid-configuration'; - - const givenOpenIdRequest = - 'openid://initiate_issuance?issuer=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&credential_type=https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer_state=c8d25b7e-9bd2-11ed-9d05-0a1628958560'; - - const tokenUrl = 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token'; - - test('EBSI class can be instantiated', () { - final oidc4vc = OIDC4VC(client); - expect(oidc4vc, isNotNull); - }); - - group('EBSI DID and JWK', () { - final oidc4vc = OIDC4VC(client); - - const seedBytes = [ - 113, - 197, - 150, - 53, - 40, - 198, - 138, - 253, - 98, - 90, - 83, - 97, - 226, - 71, - 225, - 90, - 252, - 6, - 223, - 44, - 144, - 49, - 239, - 40, - 223, - 80, - 238, - 210, - 226, - 145, - 206, - 187 - ]; - - const expectedJwk = { - 'crv': 'secp256k1', - 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', - 'kty': 'EC', - 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', - 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' - }; - test('JWK from mnemonic', () async { - final jwk = await oidc4vc.privateKeyFromMnemonic(mnemonic: mnemonic); - expect(jsonDecode(jwk), expectedJwk); - }); - - group('getPrivateKey', () { - test('privateKey from mnemonic', () async { - final jwk = await oidc4vc.getPrivateKey(mnemonic, null); - expect(jwk, expectedJwk); - }); - - test('privateKey from mnemonic', () async { - const key = { - 'crv': 'secp256k1', - 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', - 'kty': 'EC', - 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', - 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' - }; - final jwk = await oidc4vc.getPrivateKey(null, jsonEncode(key)); - expect(jwk, expectedJwk); - }); - }); - - test('JWK from seeds', () { - final jwk = oidc4vc.jwkFromSeed(seedBytes: Uint8List.fromList(seedBytes)); - expect(jwk, expectedJwk); - }); - - test('isEbsiUrl is true', () { - const openIdRequest = - 'openid://initiate_issuance?issuer=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Fconformance%2Fv2&credential_type=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Ftrusted-schemas-registry%2Fv2%2Fschemas%2FzCfNxx5dMBdf4yVcsWzj1anWRuXcxrXj1aogyfN1xSu8t&conformance=ec4d929a-5439-46fb-b7d3-4a1a80d0c199'; - - final isCorrectUrl = oidc4vc.isEbsiInitiateIssuanceUrl(openIdRequest); - expect(isCorrectUrl, true); - }); - - test('isEbsiUrl is false', () { - final isCorrectUrl = - oidc4vc.isEbsiInitiateIssuanceUrl('https://example.com'); - expect(isCorrectUrl, false); - }); - }); - - group('EBSI: getAuthorizationUriForIssuer', () { - const givenredirectUrl = 'app.altme.io/app/download/callback'; - - test( - 'given Url of openid request we return Uri for authentication endpoint', - () async { - const openidConfiguration = - 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"}],"pre-authorized_grant_anonymous_access_supported":false,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; - final expectedAuthorizationEndpointdUri = Uri.parse( - 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/authorize?scope=openid&client_id=app.altme.io%2Fapp%2Fdownload%2Fcallback&response_type=code&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22credential_type%22%3A%22https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%22%2C%22format%22%3A%22jwt_vc%22%7D%5D&redirect_uri=app.altme.io%2Fapp%2Fdownload%2Fcallback%3Fcredential_type%3Dhttps%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%26issuer%3Dhttps%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&state&op_state', - ); - - dioAdapter.onGet( - issuer, - (request) => request.reply(200, jsonDecode(openidConfiguration)), - ); - final oidc4vc = OIDC4VC(client); - - final authorizationEndpointdUri = - await oidc4vc.getAuthorizationUriForIssuer( - givenOpenIdRequest, - givenredirectUrl, - ); - expect(authorizationEndpointdUri, expectedAuthorizationEndpointdUri); - }, - ); - - test( - 'throw Exception with when request is not ebsi initiate issuance url', - () async { - final oidc4vc = OIDC4VC(client); - - expect( - () async => oidc4vc.getAuthorizationUriForIssuer( - 'www.example.com', - givenredirectUrl, - ), - throwsA( - isA().having( - (p0) => p0.toString(), - 'toString()', - 'Exception: Not a valid openid url to initiate issuance', - ), - ), - ); - }, - ); - - test( - 'throw Exception when random url is passed', - () async { - final oidc4vc = OIDC4VC(client); - - expect( - () async => oidc4vc.getAuthorizationUriForIssuer( - 'openid://initiate_issuance?', - givenredirectUrl, - ), - throwsA(isA()), - ); - }, - ); - - test('get correct issuer from openid request', () { - const expectedIssuer = 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; - final oidc4vc = OIDC4VC(client); - - final issuer = oidc4vc.getIssuerFromOpenidRequest( - givenOpenIdRequest, - ); - expect(issuer, expectedIssuer); - }); - - test('get correct Autorization RequestParameters', () { - const parameters = { - 'scope': 'openid', - 'client_id': 'app.altme.io/app/download/callback', - 'response_type': 'code', - 'authorization_details': - '[{"type":"openid_credential","credential_type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","format":"jwt_vc"}]', - 'redirect_uri': - 'app.altme.io/app/download/callback?credential_type=https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer=https://talao.co/sandbox/ebsi/issuer/vgvghylozl', - 'state': null, - 'op_state': null - }; - final oidc4vc = OIDC4VC(client); - - final authorizationRequestParemeters = - oidc4vc.getAuthorizationRequestParemeters( - givenOpenIdRequest, - givenredirectUrl, - ); - - expect(authorizationRequestParemeters, parameters); - }); - }); - - group('issuer', () { - final oidc4vc = OIDC4VC(client); - test('get issuer when openIdRequest is good', () { - const openIdRequest = - 'openid://initiate_issuance?issuer=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Fconformance%2Fv2&credential_type=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Ftrusted-schemas-registry%2Fv2%2Fschemas%2FzCfNxx5dMBdf4yVcsWzj1anWRuXcxrXj1aogyfN1xSu8t&conformance=ec4d929a-5439-46fb-b7d3-4a1a80d0c199'; - const expectedIssuer = - 'https://api.conformance.intoidc4vc.xyz/conformance/v2'; - - final issuer = oidc4vc.getIssuerRequest(openIdRequest); - expect(issuer, expectedIssuer); - }); - - test('get empty string ' ' when openIdRequest is good', () { - const openidRequest = 'this is a bad request :-)'; - final oidc4vc = OIDC4VC(client); - expect(oidc4vc.getIssuerRequest(openidRequest), ''); - }); - }); - - group('Ebsi request credential', () { - final credentialRequest = Uri.parse( - 'https://app.altme.io/app/download?credential_type=https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer=https://talao.co/sandbox/ebsi/issuer/vgvghylozl?code=cb803d46-9c88-11ed-bdb3-0a1628958560&state=0d189873-9c87-11ed-8dbf-0a1628958560', - ); - - final credentialRequestWithPreAuthorizedCode = Uri.parse( - 'openid://initiate_issuance?issuer=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&credential_type=https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&op_state=test&pre-authorized_code=ff8e73c5-ae07-11ed-b1f7-0a1628958560&user_pin_required=False', - ); - - const issuerResponse = - 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"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; - - const tokenResponse = - '{"access_token":"7a07dd19-a879-11ed-ad95-0a1628958560","c_nonce":"7a07de0f-a879-11ed-822b-0a1628958560","token_type":"Bearer","expires_in":1000}'; // ignore: lines_longer_than_80_chars - - const credentialRequestUrl = - 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/credential'; - - const credentialRequestResponse = - '{"format":"jwt_vc","credential":"eyJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6ZWJzaTp6aFN3NXJQWGtjSGp2cXV3blZjVHp6QiM1MTVhOWM0MzZjMGYyYWQzYWI2NWQ2Y2VmYzVjMWYwNmMwNWI4YWRmY2Y1NGVlMDZkYzgwNTQzMjA0NzBmZmFmIiwidHlwIjoiSldUIn0.eyJleHAiOjE2NzU5NDcwNTguODkyNzc4LCJpYXQiOjE2NzU5NDYwNTguODkyNzcxLCJpc3MiOiJkaWQ6ZWJzaTp6aFN3NXJQWGtjSGp2cXV3blZjVHp6QiIsImp0aSI6InVybjp1dWlkOjZiMWQ4NDExLTllZDUtNDU2Ni05YzdmLTRjMjQxNjVmZjIzNiIsIm5iZiI6MTY3NTk0NjA1OC44OTI3NzYsIm5vbmNlIjoiMTFmNWY2MDAtYTg3Ni0xMWVkLT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J1cm46dXVpZDo2YjFkODQxMS05ZWQ1LTQ1NjYtOWM3Zi00YzI0MTY1ZmYyMzYiLCJpc3N1YW5jZURhdGUiOiIyMDIzLTAyLTA5VDEyOjM0OjE4WiIsImlzc3VlZCI6IjIwMjMtMDItMDlUMTI6MzQ6MThaIiwiaXNzdWVyIjoiZGlkOmVic2k6emhTdzVyUFhrY0hqdnF1d25WY1R6ekIiLCJwcm9vZiI6eyJjcmVhdGVkIjoiMjAyMi0wNC0yN1QxMjoyNTowN1oiLCJjcmVhdG9yIjoiZGlkOmVic2k6emRSdnZLYlhoVlZCc1hoYXRqdWlCaHMiLCJkb21haW4iOiJodHRwczovL2FwaS5wcmVwcm9kLmVic2kuZXUiLCJqd3MiOiJleUppTmpRaU9tWmhiSE5sTENKamNtbDBJanBiSW1JMk5DSmRMQ0poYkdjaU9pSkZVekkxTmtzaWZRLi5tSUJuTThYRFFxU1lLUU5YX0x2YUpobXNieUNyNU9aNWNVMlprLVJlcUxwcjRkb0ZzZ21vb2JrTzUxMjh0WnktOEtpbVZqSmtHdzB3TDF1QlduTUxXUSIsIm5vbmNlIjoiM2VhNjhkYWUtZDA3YS00ZGFhLTkzMmItZmJiNThmNWMyMGM0IiwidHlwZSI6IkVjZHNhU2VjcDI1NmsxU2lnbmF0dXJlMjAxOSJ9LCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVmVyaWZpYWJsZUF0dGVzdGF0aW9uIiwiVmVyaWZpYWJsZURpcGxvbWEiXSwidmFsaWRGcm9tIjoiMjAyMy0wMi0wOVQxMjozNDoxOFoifX0.uQK9sK-VtqmKjLJIw_v5Ff5xAMDAosZCtl1LFYxZhUolReD6a7O-NI1f5lcswBCZPLfJ-HJyb5iShehHObzFDA","c_nonce":"128952c8-a876-11ed-bbc4-0a1628958560","c_nonce_expires_in":1000}'; // ignore: lines_longer_than_80_chars - - dioAdapter - ..onGet( - issuer, - (request) => request.reply(200, jsonDecode(issuerResponse)), - ) - ..onPost( - tokenUrl, - (request) => request.reply( - 200, - jsonDecode(tokenResponse), - ), - ) - ..onPost( - credentialRequestUrl, - (request) => request.reply( - 200, - jsonDecode(credentialRequestResponse), - ), - ); - - test('When getCredentialType receive url it returns json response', - () async { - final oidc4vc = OIDC4VC(client); - final credential = await oidc4vc.getCredential( - credentialRequest, - mnemonic, - null, - ); - expect(jsonEncode(credential), credentialRequestResponse); - }); - - // test('throw Exception when token is not verified', () { - // const issuerDid = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'; - - // const didDocumentUrl = - // 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid'; - - // const didDocumentResponse = - // '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"P-521","kty":"EC","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; - - // dioAdapter.onGet( - // didDocumentUrl, - // (request) => request.reply(200, jsonDecode(didDocumentResponse)), - // ); - - // final oidc4vc = OIDC4VC(client); - - // expect( - // () async { - // await oidc4vc.getCredential( - // credentialRequest, - // mnemonic, - // null, - // ); - // }, - // throwsA( - // isA().having( - // (p0) => p0.toString(), - // 'toString()', - // 'Exception: VERIFICATION_ISSUE', - // ), - // ), - // ); - // }); - - group('build token data', () { - final oidc4vc = OIDC4VC(client); - test('get token data with credentialRequestUri', () async { - const expectedTokenData = - '{"code":"cb803d46-9c88-11ed-bdb3-0a1628958560","grant_type":"authorization_code"}'; // ignore: lines_longer_than_80_chars - final tokenData = oidc4vc.buildTokenData( - credentialRequest, - ); - expect(jsonEncode(tokenData), expectedTokenData); - }); - - test('get token data with credentialRequestUri', () { - const expectedTokenData = - '{"pre-authorized_code":"ff8e73c5-ae07-11ed-b1f7-0a1628958560","grant_type":"urn:ietf:params:oauth:grant-type:pre-authorized_code"}'; // ignore: lines_longer_than_80_chars - final tokenData = - oidc4vc.buildTokenData(credentialRequestWithPreAuthorizedCode); - expect(jsonEncode(tokenData), expectedTokenData); - }); - }); - - group('getIssuer', () { - final oidc4vc = OIDC4VC(client); - test('get issuer with credentialRequestUri', () { - const expectedIssuer = - 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; - final issuer = oidc4vc.getIssuer(credentialRequest); - expect(expectedIssuer, issuer); - }); - - test( - 'get issuer with credentialRequestUri when PreAuthorizedCode is given', // ignore: lines_longer_than_80_chars - () { - const expectedIssuer = - 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; - final issuer = - oidc4vc.getIssuer(credentialRequestWithPreAuthorizedCode); - expect(expectedIssuer, issuer); - }); - }); - - test('get readTokenEndPoint with openidConfigurationResponse', () async { - 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"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; - - final oidc4vc = OIDC4VC(client); - - final issuer = oidc4vc.readTokenEndPoint( - Response( - requestOptions: RequestOptions(path: ''), - data: jsonDecode(openidConfigurationResponse) as Map, - ), - ); - expect(issuer, tokenUrl); - }); - - 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 oidc4vc = OIDC4VC(client); - - final issuer = oidc4vc.readIssuerDid( - Response( - requestOptions: RequestOptions(path: ''), - data: jsonDecode(openidConfigurationResponse) as Map, - ), - ); - expect(issuer, 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'); - }); - - test('get publicKey did with didDocumentResponse', () { - const didDocumentResponse = - '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"alg":"EdDSA","crv":"Ed25519","kid":"3623b877bbb24b08ba390f3585418f53","kty":"OKP","use":"sig","x":"pWgA8M3etXlLaqcRmgjEQkz7waseg3FKzMCzfm9Yeow"},"type":"Ed25519VerificationKey2019"}]}'; - const issuerDid = 'did:ebsi:zeFCExU2XAAshYkPCpjuahA'; - - const expectedPublicKey = - '{"alg":"EdDSA","crv":"Ed25519","kid":"3623b877bbb24b08ba390f3585418f53","kty":"OKP","use":"sig","x":"pWgA8M3etXlLaqcRmgjEQkz7waseg3FKzMCzfm9Yeow"}'; // ignore: lines_longer_than_80_chars - - final oidc4vc = OIDC4VC(client); - - final publicKey = oidc4vc.readPublicKeyJwk( - issuerDid, - Response( - requestOptions: RequestOptions(path: ''), - data: jsonDecode(didDocumentResponse) as Map, - ), - ); - expect(jsonEncode(publicKey), expectedPublicKey); - }); - }); - - group('verify encoded data', () { - const issuerDid1 = 'did:ebsi:zeFCExU2XAAshYkPCpjuahA'; - const issuerDid2 = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzC'; - const issuerDid3 = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzC'; - - const issuerKid = - 'did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53'; - - const didDocumentUrl = - 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid1'; - - const didDocumentResponse = - '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"P-521","kty":"EC","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; - - const didDocumentUrl2 = - 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid2'; - - const didDocumentResponse2 = - '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; - - const didDocumentUrl3 = - 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid3'; - - const didDocumentResponse3 = - '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"alg":"EdDSA","crv":"Ed25519","kid":"-1909572257","kty":"OKP","x":"XWxGtApfcqmKI7p0OKnF5JSEWMVoLsytFXLEP7xZ_l8"},"type":"Ed25519VerificationKey2019"}]}'; - dioAdapter - ..onGet( - didDocumentUrl, - (request) => request.reply(200, jsonDecode(didDocumentResponse)), - ) - ..onGet( - didDocumentUrl2, - (request) => request.reply(200, jsonDecode(didDocumentResponse2)), - ) - ..onGet( - didDocumentUrl3, - (request) => request.reply(200, jsonDecode(didDocumentResponse3)), - ); - - final oidc4vc = OIDC4VC(client); - test('returns VerificationType.verified', () async { - const vcJwt = 'eyJhbGciOiJFUzUxMiJ9.' - 'UGF5bG9hZA.' - 'AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq' - 'wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp' - 'EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn'; - - final isVerified = await oidc4vc.verifyEncodedData( - issuerDid: issuerDid1, - jwt: vcJwt, - issuerKid: issuerKid, - ); - - expect(isVerified, VerificationType.verified); - }); - - test('returns VerificationType.notVerified', () async { - const vcJwt = - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksiLCJqd2siOnsiY3J2IjoiUC0yNTZLIiwia3R5IjoiRUMiLCJ4IjoiSjR2UXRMVXlyVlVpRklYUnJ0RXE0eHVybUJacDJlcTl3Sm1Ya0lBX3N0SSIsInkiOiJFVVU2dlhvRzNCR1gyenp3alhyR0RjcjRFeUREMFZmazNfNWZnNWtTZ0tFIn0sImtpZCI6ImRpZDplYnNpOnpvOUZSMVlmQUtGUDNRNmR2cWh4Y1h4bmZlRGlKRFA5N2ttbnFoeUFVU0FDaiNDZ2NnMXk5eGo5dVdGdzU2UE1jMjlYQmQ5RVJlaXh6dm5mdEJ6OEp3UUZpQiJ9.eyJpc3MiOiJkaWQ6ZWJzaTp6bzlGUjFZZkFLRlAzUTZkdnFoeGNYeG5mZURpSkRQOTdrbW5xaHlBVVNBQ2oiLCJub25jZSI6IjdhMDdkZTBmLWE4NzktMTFlZC04MjJiLTBhMTYyODk1ODU2MCIsImlhdCI6MTY3NzA1MDc0MDEyMzIzNSwiYXVkIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3ZndmdoeWxvemwifQ.htjRCpFWbRwanAyQcAq9XZ4vxCXyFbzaaN3yPbPxWIcKFFzDDcA4QCHTUl-L4vzWq0R3LSgQFXQ9bo5D9uCm4w'; // ignore: lines_longer_than_80_chars - - final isVerified = await oidc4vc.verifyEncodedData( - issuerDid: issuerDid1, - jwt: vcJwt, - issuerKid: issuerKid, - ); - - expect(isVerified, VerificationType.notVerified); - }); - - test('returns VerificationType.unKnown', () async { - const vcJwt = 'random'; - - final isVerified = await oidc4vc.verifyEncodedData( - issuerDid: issuerDid2, - jwt: vcJwt, - issuerKid: issuerKid, - ); - expect(isVerified, VerificationType.unKnown); - }); - - 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 - - final isVerified = await oidc4vc.verifyEncodedData( - issuerDid: issuerDid3, - jwt: vcJwt, - issuerKid: issuerKid, - ); - expect(isVerified, VerificationType.verified); - }); - }); - - group('getCredentialRequest', () { - final oidc4vc = OIDC4VC(client); - - test('extract correct credential type url from openId', () async { - final url = oidc4vc.getCredentialRequest(givenOpenIdRequest); - expect( - url, - 'https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', - ); - }); - - test('credential type url is empty when url is not OK', () async { - final url = oidc4vc.getCredentialRequest('www.example.com'); - expect(url, ''); - }); - }); - - test('extract correct credential type url from openId', () async { - final oidc4vc = OIDC4VC(client); - final url = oidc4vc.getCredentialRequest(givenOpenIdRequest); - expect( - url, - 'https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', - ); - }); - - group('get token', () { - test('get correct token ', () async { - final oidc4vc = OIDC4VC(client); - - final json = { - 'code': 'cb803d46-9c88-11ed-bdb3-0a1628958560', - 'grant_type': 'authorization_code' - }; - - const expectedValue = - '{"access_token":"7a07dd19-a879-11ed-ad95-0a1628958560","c_nonce":"7a07de0f-a879-11ed-822b-0a1628958560","token_type":"Bearer","expires_in":1000}'; // ignore: lines_longer_than_80_chars - - final token = await oidc4vc.getToken(tokenUrl, json); - expect(jsonEncode(token), expectedValue); - }); - - test('throw expection when invalid value is sent', () async { - expect( - () async { - dioAdapter.onPost( - tokenUrl, - (request) => request.throws( - 401, - DioError(requestOptions: RequestOptions(path: tokenUrl)), - ), - ); - final oidc4vc = OIDC4VC(client); - - final json = {}; - - await oidc4vc.getToken(tokenUrl, json); - }, - throwsA(isA()), - ); - }); - }); - - group('get did', () { - final oidc4vc = OIDC4VC(client); - - const expectedDidP256K = - 'did:ebsi:zo9FR1YfAKFP3Q6dvqhxcXxnfeDiJDP97kmnqhyAUSACj'; - test('from mnemonic ', () async { - final did = await oidc4vc.getDidFromMnemonic(mnemonic, null); - expect(did, expectedDidP256K); - }); - - test('from P-256K privateKey ', () async { - const key = { - 'crv': 'P-256K', - 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', - 'kty': 'EC', - 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', - 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' - }; - final did = await oidc4vc.getDidFromMnemonic(null, jsonEncode(key)); - expect(did, expectedDidP256K); - }); - test('from secp256k1 privateKey ', () async { - const expectedDidsecp256k1 = - 'did:ebsi:zfuA5yVRZVaKna9pRCHv28yyCYWiXWHZXXvtp3AbTdB4p'; - const key = { - 'crv': 'secp256k1', - 'd': 'jMudzhP9YFNywIeIYYJbHtyizeaXOa1PWdX-qBjPTg8', - 'kty': 'EC', - 'x': 'yEC4JxUbpYx2-tKExh2NrLpETx-nnudZfcg4AcyL1to', - 'y': 'HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM' - }; - final did = await oidc4vc.getDidFromMnemonic(null, jsonEncode(key)); - expect(did, expectedDidsecp256k1); - }); - - group('send Presentation', () { - const url = - 'https://talao.co/sandbox/ebsi/login/endpoint/f1722b9e-ae19-11ed-ac9f-0a1628958560'; - - final uri = Uri.parse( - 'openid://?scope=openid&response_type=id_token&client_id=xjcqarovuv&redirect_uri=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Flogin%2Fendpoint%2Ff1722b9e-ae19-11ed-ac9f-0a1628958560&claims=%7B%27id_token%27%3A+%7B%27email%27%3A+None%7D%2C+%27vp_token%27%3A+%7B%27presentation_definition%27%3A+%7B%27id%27%3A+%27f17247aa-ae19-11ed-9241-0a1628958560%27%2C+%27input_descriptors%27%3A+%5B%7B%27constraints%27%3A+%7B%27fields%27%3A+%5B%7B%27path%27%3A+%5B%27%24.credentialSchema.id%27%5D%2C+%27filter%27%3A+%7B%27type%27%3A+%27string%27%2C+%27pattern%27%3A+%27https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%27%7D%7D%5D%7D%2C+%27id%27%3A+%27f1724e6c-ae19-11ed-a3cf-0a1628958560%27%2C+%27name%27%3A+%27Input+descriptor+1%27%2C+%27purpose%27%3A+%27+%27%7D%5D%2C+%27format%27%3A+%7B%27jwt_vp%27%3A+%7B%27alg%27%3A+%5B%27ES256K%27%2C+%27ES256%27%2C+%27PS256%27%2C+%27RS256%27%5D%7D%7D%7D%7D%7D&nonce=f17239d6-ae19-11ed-8550-0a1628958560', - ); - - final credentialToBePresented = [ - r'{"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","receivedId":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","image":null,"data":{"@context":["https://www.w3.org/2018/credentials/v1"],"credentialSchema":{"id":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://essif.europa.eu/status/education#higherEducation#392ac7f6-399a-437b-a268-4691ead8f176","type":"CredentialStatusList2020"},"credentialSubject":{"awardingOpportunity":{"awardingBody":{"eidasLegalIdentifier":"Unknown","homepage":"https://leaston.bcdiploma.com/","id":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","preferredName":"Leaston University","registration":"0597065J"},"endedAtTime":"2020-06-26T00:00:00Z","id":"https://leaston.bcdiploma.com/law-economics-management#AwardingOpportunity","identifier":"https://certificate-demo.bcdiploma.com/check/87ED2F2270E6C41456E94B86B9D9115B4E35BCCAD200A49B846592C14F79C86BV1Fnbllta0NZTnJkR3lDWlRmTDlSRUJEVFZISmNmYzJhUU5sZUJ5Z2FJSHpWbmZZ","location":"FRANCE","startedAtTime":"2019-09-02T00:00:00Z"},"dateOfBirth":"1993-04-08","familyName":"DOE","givenNames":"Jane","gradingScheme":{"id":"https://leaston.bcdiploma.com/law-economics-management#GradingScheme","title":"2 year full-time programme / 4 semesters"},"id":"did:ebsi:zhFWcvr8DFL3cAVdheCpjHg3sPn1WUh9Gynm6hevPFzpw","identifier":"0904008084H","learningAchievement":{"additionalNote":["DISTRIBUTION MANAGEMENT"],"description":"The Master in Information and Computer Sciences (MICS) at the University of Luxembourg enables students to acquire deeper knowledge in computer science by understanding its abstract and interdisciplinary foundations, focusing on problem solving and developing lifelong learning skills.","id":"https://leaston.bcdiploma.com/law-economics-management#LearningAchievment","title":"Master in Information and Computer Sciences"},"learningSpecification":{"ectsCreditPoints":120,"eqfLevel":7,"id":"https://leaston.bcdiploma.com/law-economics-management#LearningSpecification","iscedfCode":["7"],"nqfLevel":["7"]},"type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"},"evidence":{"documentPresence":["Physical"],"evidenceDocument":["Passport"],"id":"https://essif.europa.eu/tsr-va/evidence/f2aeec97-fc0d-42bf-8ca7-0548192d5678","subjectPresence":"Physical","type":["DocumentVerification"],"verifier":"did:ebsi:2962fb784df61baa267c8132497539f8c674b37c1244a7a"},"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","issuanceDate":"2023-02-16T12:04:19Z","issued":"2023-02-16T12:04:19Z","issuer":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","proof":{"created":"2022-04-27T12:25:07Z","creator":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","domain":"https://api.preprod.oidc4vc.eu","jws":"eyJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCJdLCJhbGciOiJFUzI1NksifQ..mIBnM8XDQqSYKQNX_LvaJhmsbyCr5OZ5cU2Zk-ReqLpr4doFsgmoobkO5128tZy-8KimVjJkGw0wL1uBWnMLWQ","nonce":"3ea68dae-d07a-4daa-932b-fbb58f5c20c4","type":"EcdsaSecp256k1Signature2019"},"type":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma"],"validFrom":"2023-02-16T12:04:19Z"},"shareLink":"","credentialPreview":{"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","type":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma"],"issuer":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","description":[],"name":[],"issuanceDate":"2023-02-16T12:04:19Z","proof":[{"type":"EcdsaSecp256k1Signature2019","proofPurpose":null,"verificationMethod":null,"created":"2022-04-27T12:25:07Z","jws":"eyJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCJdLCJhbGciOiJFUzI1NksifQ..mIBnM8XDQqSYKQNX_LvaJhmsbyCr5OZ5cU2Zk-ReqLpr4doFsgmoobkO5128tZy-8KimVjJkGw0wL1uBWnMLWQ"}],"credentialSubject":{"id":"did:ebsi:zhFWcvr8DFL3cAVdheCpjHg3sPn1WUh9Gynm6hevPFzpw","type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","issuedBy":{"name":""},"expires":"","awardingOpportunity":{"awardingBody":{"eidasLegalIdentifier":"Unknown","homepage":"https://leaston.bcdiploma.com/","id":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","preferredName":"Leaston University","registration":"0597065J"},"endedAtTime":"2020-06-26T00:00:00Z","id":"https://leaston.bcdiploma.com/law-economics-management#AwardingOpportunity","identifier":"https://certificate-demo.bcdiploma.com/check/87ED2F2270E6C41456E94B86B9D9115B4E35BCCAD200A49B846592C14F79C86BV1Fnbllta0NZTnJkR3lDWlRmTDlSRUJEVFZISmNmYzJhUU5sZUJ5Z2FJSHpWbmZZ","location":"FRANCE","startedAtTime":"2019-09-02T00:00:00Z"},"dateOfBirth":"1993-04-08","familyName":"DOE","givenNames":"Jane","gradingScheme":{"id":"https://leaston.bcdiploma.com/law-economics-management#GradingScheme","title":"2 year full-time programme / 4 semesters"},"identifier":"0904008084H","learningAchievement":{"additionalNote":["DISTRIBUTION MANAGEMENT"],"description":"The Master in Information and Computer Sciences (MICS) at the University of Luxembourg enables students to acquire deeper knowledge in computer science by understanding its abstract and interdisciplinary foundations, focusing on problem solving and developing lifelong learning skills.","id":"https://leaston.bcdiploma.com/law-economics-management#LearningAchievment","title":"Master in Information and Computer Sciences"},"learningSpecification":{"ectsCreditPoints":120,"eqfLevel":7,"id":"https://leaston.bcdiploma.com/law-economics-management#LearningSpecification","iscedfCode":["7"],"nqfLevel":["7"]}},"evidence":[{"id":"https://essif.europa.eu/tsr-va/evidence/f2aeec97-fc0d-42bf-8ca7-0548192d5678","type":["DocumentVerification"]}],"credentialStatus":{"id":"https://essif.europa.eu/status/education#higherEducation#392ac7f6-399a-437b-a268-4691ead8f176","type":"CredentialStatusList2020","revocationListIndex":"","revocationListCredential":""}},"display":{"backgroundColor":"","icon":"","nameFallback":"","descriptionFallback":""},"expirationDate":null,"credential_manifest":{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","name":null,"description":null,"styles":null,"display":{"title":{"path":[],"schema":{"type":"string","format":null},"fallback":"Diploma"},"subtitle":{"path":[],"schema":{"type":"string","format":null},"fallback":"EBSI Verifiable diploma"},"description":{"path":[],"schema":{"type":"string","format":null},"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."},"properties":[{"label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"type":"string","format":"date"},"fallback":"Unknown"},{"label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number","format":null},"fallback":"Unknown"},{"label":"Issue date","path":["$.issuanceDate"],"schema":{"type":"string","format":"date"},"fallback":"Unknown"},{"label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"type":"string","format":"uri"},"fallback":"Unknown"}]}}],"presentation_definition":null},"challenge":null,"domain":null,"activities":[{"acquisitionAt":"2023-02-16T17:34:24.679713","presentation":null},{"acquisitionAt":null,"presentation":{"issuer":{"preferredName":"","did":[],"organizationInfo":{"id":"","legalName":"","currentAddress":"","website":"domain","issuerDomain":[]}},"presentedAt":"2023-02-16T17:34:47.206600"}}],"jwt":"eyJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6ZWJzaTp6aFN3NXJQWGtjSGp2cXV3blZjVHp6QiM1MTVhOWM0MzZjMGYyYWQzYWI2NWQ2Y2VmYzVjMWYwNmMwNWI4YWRmY2Y1NGVlMDZkYzgwNTQzMjA0NzBmZmFmIiwidHlwIjoiSldUIn0.eyJleHAiOjE2NzY1NTAwNTkuMjMzMzY3LCJpYXQiOjE2NzY1NDkwNTkuMjMzMzYsImlzcyI6ImRpZDplYnNpOnpoU3c1clBYa2NIanZxdXduVmNUenpCIiwianRpIjoidXJuOnV1aWQ6NmIxZDg0MTEtOWVkNS00NTY2LTljN2YtNGMyNDE2NWZmMjM2IiwibmJmIjoxNjc2NTQ5MDU5LjIzMzM2NCwibm9uY2UiOiIwYTc4MDg2MC1hZGYyLTExZWQtYmIzZS0wYTE2Mjg5NTg1NjAiLCJzdWIiOiJkaWQ6ZWJzaTp6aEZXY3ZyOERGTDNjQVZkaGVDcGpIZzNzUG4xV1VoOUd5bm02aGV2UEZ6cHciLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJjcmVkZW50aWFsU2NoZW1hIjp7ImlkIjoiaHR0cHM6Ly9hcGkucHJlcHJvZC5lYnNpLmV1L3RydXN0ZWQtc2NoZW1hcy1yZWdpc3RyeS92MS9zY2hlbWFzLzB4YmY3OGZjMDhhN2E5ZjI4ZjU0NzlmNThkZWEyNjlkMzY1N2Y1NGYxM2NhMzdkMzgwY2Q0ZTkyMjM3ZmI2OTFkZCIsInR5cGUiOiJ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ZXByb2QuZWJzaS5ldSIsImp3cyI6ImV5SmlOalFpT21aaGJITmxMQ0pqY21sMElqcGJJbUkyTkNKZExDSmhiR2NpT2lKRlV6STFOa3NpZlEuLm1JQm5NOFhEUXFTWUtRTlhfTHZhSmhtc2J5Q3I1T1o1Y1UyWmstUmVxTHByNGRvRnNnbW9vYmtPNTEyOHRaeS04S2ltVmpKa0d3MHdMMXVCV25NTFdRIiwibm9uY2UiOiIzZWE2OGRhZS1kMDdhLTRkYWEtOTMyYi1mYmI1OGY1YzIwYzQiLCJ0eXBlIjoiRWNkc2FTZWNwMjU2azFTaWduYXR1cmUyMDE5In0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJWZXJpZmlhYmxlQXR0ZXN0YXRpb24iLCJWZXJpZmlhYmxlRGlwbG9tYSJdLCJ2YWxpZEZyb20iOiIyMDIzLTAyLTE2VDEyOjA0OjE5WiJ9fQ.7Bmdrkp-hpM7BcNASc7ngjia3cjrZr-nqmP0Plsfnefn26G_yR5fBJV8BT_U2zsMlcqWsxuJ9pS2Vyiq_SrooQ"}' - ]; - - test('successfully send presentation', () async { - const response = - '{"access":"ok","created":1676566727.680238,"credential_status":"signature check bypassed","holder_did_status":"ok","id_token_status":"ok","qrcode_status":"ok","response_format":"ok","status_code":200,"vp_token_status":"ok"}'; // ignore: lines_longer_than_80_chars - dioAdapter.onGet( - url, - (request) => request.reply(200, jsonDecode(response)), - ); - final oidc4vc = OIDC4VC(client); - - expect( - () async { - await oidc4vc.sendPresentation( - uri, - credentialToBePresented, - mnemonic, - null, - ); - }, - returnsNormally, - ); - }); - - test('throw exception', () async { - expect( - () async { - dioAdapter.onPost( - url, - (request) => request.throws( - 401, - DioError(requestOptions: RequestOptions(path: tokenUrl)), - ), - ); - final oidc4vc = OIDC4VC(client); - - await oidc4vc.sendPresentation( - uri, - credentialToBePresented, - mnemonic, - null, - ); - }, - throwsA(isA()), - ); - }); - }); - }); - - test('get corresponding did document', () async { - const url = - 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$didKey'; - const response = { - '@context': 'https://w3id.org/did/v1', - 'id': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH', - 'verificationMethod': [ - { - 'id': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH#keys-1', - 'type': 'Secp256k1VerificationKey2018', - 'controller': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH', - 'publicKeyHex': - '04f9139fbd3b9780863b17e8390934a1017fc8d0f18b84f02acb04f24c9cae261e45745c6507881509b9e6d837329153ea75fafb2c1a5d504702d04f1e22a80ecc' // ignore: lines_longer_than_80_chars - } - ], - 'authentication': ['did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH'], - 'assertionMethod': ['did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH#keys-1'] - }; - - dioAdapter.onGet( - url, - (request) => request.reply(200, response), - ); - final oidc4vc = OIDC4VC(client); - - final value = await oidc4vc.getDidDocument(didKey); - - expect(value.data, response); - }); - - test('sandbox', () { - const cNonce = 'cNonce'; - const did = 'did'; - const issuer = 'issuer'; - final payload = { - 'iss': did, - 'nonce': cNonce, - 'iat': DateTime.now().microsecondsSinceEpoch, - 'aud': issuer - }; - - final jwt = JWT( - // Payload - payload, - - issuer: issuer, - ); - - // Sign it (default with HS256 algorithm) - // ignore: unused_local_variable - final token = jwt.sign(SecretKey('secret passphrase')); - }); - - // test('generateToken', () { - // final jwk = { - // 'kty': 'OKP', - // 'crv': 'Ed25519', - // 'd': '-_9OD-PMHKE2mFKEVH5R1vDhEMimtXPUX-2w1Xa0hQ0=', - // 'x': '1tknP1Fx-YIQBzw3xXtCwLGgYoTb-nSsNn-k9uzWpuw=', - // }; - - // final vpTokenPayload = { - // 'iss': 'did:ebsi:zrDzYQPDztwjQ8HdXto1B4FVB14fxoiNawZd8eyEuhR7K', - // 'nonce': '8dd8d00a-ad17-11ed-9fe9-0a1628958560', - // 'iat': '1676455223753366', - // 'aud': 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl', - // }; - - // final oidc4vc = OIDC4VC(client); - - // final tokenParameters = TokenParameters(jwk); - // final token = oidc4vc.generateToken(vpTokenPayload, tokenParameters); - - // }); -} +// // Copyright (c) 2022, Very Good Ventures +// // https://verygood.ventures +// // +// // Use of this source code is governed by an MIT-style +// // license that can be found in the LICENSE file or at +// // https://opensource.org/licenses/MIT. + +// import 'dart:convert'; + +// import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; +// import 'package:dio/dio.dart'; +// import 'package:flutter/foundation.dart'; +// 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 'const_values.dart'; + +// class MockDio extends Mock implements Dio {} + +// void main() { +// final client = Dio(); +// final dioAdapter = +// DioAdapter(dio: Dio(BaseOptions()), matcher: const UrlRequestMatcher()); +// client.httpClientAdapter = dioAdapter; + +// const mnemonic = +// 'position taste mention august skin taste best air sure acoustic poet ritual'; // ignore: lines_longer_than_80_chars + +// const issuer = +// 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/.well-known/openid-configuration'; + +// const givenOpenIdRequest = +// 'openid://initiate_issuance?issuer=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&credential_type=https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer_state=c8d25b7e-9bd2-11ed-9d05-0a1628958560'; + +// const tokenUrl = 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token'; + +// test('EBSI class can be instantiated', () { +// final oidc4vc = OIDC4VC(client); +// expect(oidc4vc, isNotNull); +// }); + +// group('EBSI DID and JWK', () { +// final oidc4vc = OIDC4VC(client); + +// const seedBytes = [ +// 113, +// 197, +// 150, +// 53, +// 40, +// 198, +// 138, +// 253, +// 98, +// 90, +// 83, +// 97, +// 226, +// 71, +// 225, +// 90, +// 252, +// 6, +// 223, +// 44, +// 144, +// 49, +// 239, +// 40, +// 223, +// 80, +// 238, +// 210, +// 226, +// 145, +// 206, +// 187 +// ]; + +// const expectedJwk = { +// 'crv': 'secp256k1', +// 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', +// 'kty': 'EC', +// 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', +// 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' +// }; +// test('JWK from mnemonic', () async { +// final jwk = await oidc4vc.privateKeyFromMnemonic(mnemonic: mnemonic); +// expect(jsonDecode(jwk), expectedJwk); +// }); + +// group('getPrivateKey', () { +// test('privateKey from mnemonic', () async { +// final jwk = await oidc4vc.getPrivateKey(mnemonic, null); +// expect(jwk, expectedJwk); +// }); + +// test('privateKey from mnemonic', () async { +// const key = { +// 'crv': 'secp256k1', +// 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', +// 'kty': 'EC', +// 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', +// 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' +// }; +// final jwk = await oidc4vc.getPrivateKey(null, jsonEncode(key)); +// expect(jwk, expectedJwk); +// }); +// }); + +// test('JWK from seeds', () { +// final jwk = oidc4vc.jwkFromSeed(seedBytes: Uint8List.fromList(seedBytes)); +// expect(jwk, expectedJwk); +// }); + +// test('isEbsiUrl is true', () { +// const openIdRequest = +// 'openid://initiate_issuance?issuer=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Fconformance%2Fv2&credential_type=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Ftrusted-schemas-registry%2Fv2%2Fschemas%2FzCfNxx5dMBdf4yVcsWzj1anWRuXcxrXj1aogyfN1xSu8t&conformance=ec4d929a-5439-46fb-b7d3-4a1a80d0c199'; + +// final isCorrectUrl = oidc4vc.isEbsiInitiateIssuanceUrl(openIdRequest); +// expect(isCorrectUrl, true); +// }); + +// test('isEbsiUrl is false', () { +// final isCorrectUrl = +// oidc4vc.isEbsiInitiateIssuanceUrl('https://example.com'); +// expect(isCorrectUrl, false); +// }); +// }); + +// group('EBSI: getAuthorizationUriForIssuer', () { +// const givenredirectUrl = 'app.altme.io/app/download/callback'; + +// test( +// 'given Url of openid request we return Uri for authentication endpoint', +// () async { +// const openidConfiguration = +// 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"}],"pre-authorized_grant_anonymous_access_supported":false,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; +// final expectedAuthorizationEndpointdUri = Uri.parse( +// 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/authorize?scope=openid&client_id=app.altme.io%2Fapp%2Fdownload%2Fcallback&response_type=code&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22credential_type%22%3A%22https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%22%2C%22format%22%3A%22jwt_vc%22%7D%5D&redirect_uri=app.altme.io%2Fapp%2Fdownload%2Fcallback%3Fcredential_type%3Dhttps%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%26issuer%3Dhttps%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&state&op_state', +// ); + +// dioAdapter.onGet( +// issuer, +// (request) => request.reply(200, jsonDecode(openidConfiguration)), +// ); +// final oidc4vc = OIDC4VC(client); + +// final authorizationEndpointdUri = +// await oidc4vc.getAuthorizationUriForIssuer( +// givenOpenIdRequest, +// givenredirectUrl, +// ); +// expect(authorizationEndpointdUri, expectedAuthorizationEndpointdUri); +// }, +// ); + +// test( +// 'throw Exception with when request is not ebsi initiate issuance url', +// () async { +// final oidc4vc = OIDC4VC(client); + +// expect( +// () async => oidc4vc.getAuthorizationUriForIssuer( +// 'www.example.com', +// givenredirectUrl, +// ), +// throwsA( +// isA().having( +// (p0) => p0.toString(), +// 'toString()', +// 'Exception: Not a valid openid url to initiate issuance', +// ), +// ), +// ); +// }, +// ); + +// test( +// 'throw Exception when random url is passed', +// () async { +// final oidc4vc = OIDC4VC(client); + +// expect( +// () async => oidc4vc.getAuthorizationUriForIssuer( +// 'openid://initiate_issuance?', +// givenredirectUrl, +// ), +// throwsA(isA()), +// ); +// }, +// ); + +// test('get correct issuer from openid request', () { +// const expectedIssuer = 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; +// final oidc4vc = OIDC4VC(client); + +// final issuer = oidc4vc.getIssuerFromOpenidRequest( +// givenOpenIdRequest, +// ); +// expect(issuer, expectedIssuer); +// }); + +// test('get correct Autorization RequestParameters', () { +// const parameters = { +// 'scope': 'openid', +// 'client_id': 'app.altme.io/app/download/callback', +// 'response_type': 'code', +// 'authorization_details': +// '[{"type":"openid_credential","credential_type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","format":"jwt_vc"}]', +// 'redirect_uri': +// 'app.altme.io/app/download/callback?credential_type=https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer=https://talao.co/sandbox/ebsi/issuer/vgvghylozl', +// 'state': null, +// 'op_state': null +// }; +// final oidc4vc = OIDC4VC(client); + +// final authorizationRequestParemeters = +// oidc4vc.getAuthorizationRequestParemeters( +// givenOpenIdRequest, +// givenredirectUrl, +// ); + +// expect(authorizationRequestParemeters, parameters); +// }); +// }); + +// group('issuer', () { +// final oidc4vc = OIDC4VC(client); +// test('get issuer when openIdRequest is good', () { +// const openIdRequest = +// 'openid://initiate_issuance?issuer=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Fconformance%2Fv2&credential_type=https%3A%2F%2Fapi.conformance.intoidc4vc.xyz%2Ftrusted-schemas-registry%2Fv2%2Fschemas%2FzCfNxx5dMBdf4yVcsWzj1anWRuXcxrXj1aogyfN1xSu8t&conformance=ec4d929a-5439-46fb-b7d3-4a1a80d0c199'; +// const expectedIssuer = +// 'https://api.conformance.intoidc4vc.xyz/conformance/v2'; + +// final issuer = oidc4vc.getIssuerRequest(openIdRequest); +// expect(issuer, expectedIssuer); +// }); + +// test('get empty string ' ' when openIdRequest is good', () { +// const openidRequest = 'this is a bad request :-)'; +// final oidc4vc = OIDC4VC(client); +// expect(oidc4vc.getIssuerRequest(openidRequest), ''); +// }); +// }); + +// group('Ebsi request credential', () { +// final credentialRequest = Uri.parse( +// 'https://app.altme.io/app/download?credential_type=https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&issuer=https://talao.co/sandbox/ebsi/issuer/vgvghylozl?code=cb803d46-9c88-11ed-bdb3-0a1628958560&state=0d189873-9c87-11ed-8dbf-0a1628958560', +// ); + +// final credentialRequestWithPreAuthorizedCode = Uri.parse( +// 'openid://initiate_issuance?issuer=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Fissuer%2Fvgvghylozl&credential_type=https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd&op_state=test&pre-authorized_code=ff8e73c5-ae07-11ed-b1f7-0a1628958560&user_pin_required=False', +// ); + +// const issuerResponse = +// 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"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; + +// const tokenResponse = +// '{"access_token":"7a07dd19-a879-11ed-ad95-0a1628958560","c_nonce":"7a07de0f-a879-11ed-822b-0a1628958560","token_type":"Bearer","expires_in":1000}'; // ignore: lines_longer_than_80_chars + +// const credentialRequestUrl = +// 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl/credential'; + +// const credentialRequestResponse = +// '{"format":"jwt_vc","credential":"eyJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6ZWJzaTp6aFN3NXJQWGtjSGp2cXV3blZjVHp6QiM1MTVhOWM0MzZjMGYyYWQzYWI2NWQ2Y2V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WFibGVDcmVkZW50aWFsIiwiVmVyaWZpYWJsZUF0dGVzdGF0aW9uIiwiVmVyaWZpYWJsZURpcGxvbWEiXSwidmFsaWRGcm9tIjoiMjAyMy0wMi0wOVQxMjozNDoxOFoifX0.uQK9sK-VtqmKjLJIw_v5Ff5xAMDAosZCtl1LFYxZhUolReD6a7O-NI1f5lcswBCZPLfJ-HJyb5iShehHObzFDA","c_nonce":"128952c8-a876-11ed-bbc4-0a1628958560","c_nonce_expires_in":1000}'; // ignore: lines_longer_than_80_chars + +// dioAdapter +// ..onGet( +// issuer, +// (request) => request.reply(200, jsonDecode(issuerResponse)), +// ) +// ..onPost( +// tokenUrl, +// (request) => request.reply( +// 200, +// jsonDecode(tokenResponse), +// ), +// ) +// ..onPost( +// credentialRequestUrl, +// (request) => request.reply( +// 200, +// jsonDecode(credentialRequestResponse), +// ), +// ); + +// test('When getCredentialType receive url it returns json response', +// () async { +// final oidc4vc = OIDC4VC(client); +// final credential = await oidc4vc.getCredential( +// credentialRequest, +// mnemonic, +// null, +// ); +// expect(jsonEncode(credential), credentialRequestResponse); +// }); + +// // test('throw Exception when token is not verified', () { +// // const issuerDid = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'; + +// // const didDocumentUrl = +// // 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid'; + +// // const didDocumentResponse = +// // '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"P-521","kty":"EC","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; + +// // dioAdapter.onGet( +// // didDocumentUrl, +// // (request) => request.reply(200, jsonDecode(didDocumentResponse)), +// // ); + +// // final oidc4vc = OIDC4VC(client); + +// // expect( +// // () async { +// // await oidc4vc.getCredential( +// // credentialRequest, +// // mnemonic, +// // null, +// // ); +// // }, +// // throwsA( +// // isA().having( +// // (p0) => p0.toString(), +// // 'toString()', +// // 'Exception: VERIFICATION_ISSUE', +// // ), +// // ), +// // ); +// // }); + +// group('build token data', () { +// final oidc4vc = OIDC4VC(client); +// test('get token data with credentialRequestUri', () async { +// const expectedTokenData = +// '{"code":"cb803d46-9c88-11ed-bdb3-0a1628958560","grant_type":"authorization_code"}'; // ignore: lines_longer_than_80_chars +// final tokenData = oidc4vc.buildTokenData( +// credentialRequest, +// ); +// expect(jsonEncode(tokenData), expectedTokenData); +// }); + +// test('get token data with credentialRequestUri', () { +// const expectedTokenData = +// '{"pre-authorized_code":"ff8e73c5-ae07-11ed-b1f7-0a1628958560","grant_type":"urn:ietf:params:oauth:grant-type:pre-authorized_code"}'; // ignore: lines_longer_than_80_chars +// final tokenData = +// oidc4vc.buildTokenData(credentialRequestWithPreAuthorizedCode); +// expect(jsonEncode(tokenData), expectedTokenData); +// }); +// }); + +// group('getIssuer', () { +// final oidc4vc = OIDC4VC(client); +// test('get issuer with credentialRequestUri', () { +// const expectedIssuer = +// 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; +// final issuer = oidc4vc.getIssuer(credentialRequest); +// expect(expectedIssuer, issuer); +// }); + +// test( +// 'get issuer with credentialRequestUri when PreAuthorizedCode is given', // ignore: lines_longer_than_80_chars +// () { +// const expectedIssuer = +// 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl'; +// final issuer = +// oidc4vc.getIssuer(credentialRequestWithPreAuthorizedCode); +// expect(expectedIssuer, issuer); +// }); +// }); + +// test('get readTokenEndPoint with openidConfigurationResponse', () async { +// 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"}],"pre-authorized_grant_anonymous_access_supported":true,"subject_syntax_types_supported":["did:ebsi"],"token_endpoint":"https://talao.co/sandbox/ebsi/issuer/vgvghylozl/token"}'; + +// final oidc4vc = OIDC4VC(client); + +// final issuer = oidc4vc.readTokenEndPoint( +// Response( +// requestOptions: RequestOptions(path: ''), +// data: jsonDecode(openidConfigurationResponse) as Map, +// ), +// ); +// expect(issuer, tokenUrl); +// }); + +// 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 oidc4vc = OIDC4VC(client); + +// final issuer = oidc4vc.readIssuerDid( +// Response( +// requestOptions: RequestOptions(path: ''), +// data: jsonDecode(openidConfigurationResponse) as Map, +// ), +// ); +// expect(issuer, 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzB'); +// }); + +// test('get publicKey did with didDocumentResponse', () { +// const didDocumentResponse = +// '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"alg":"EdDSA","crv":"Ed25519","kid":"3623b877bbb24b08ba390f3585418f53","kty":"OKP","use":"sig","x":"pWgA8M3etXlLaqcRmgjEQkz7waseg3FKzMCzfm9Yeow"},"type":"Ed25519VerificationKey2019"}]}'; +// const issuerDid = 'did:ebsi:zeFCExU2XAAshYkPCpjuahA'; + +// const expectedPublicKey = +// '{"alg":"EdDSA","crv":"Ed25519","kid":"3623b877bbb24b08ba390f3585418f53","kty":"OKP","use":"sig","x":"pWgA8M3etXlLaqcRmgjEQkz7waseg3FKzMCzfm9Yeow"}'; // ignore: lines_longer_than_80_chars + +// final oidc4vc = OIDC4VC(client); + +// final publicKey = oidc4vc.readPublicKeyJwk( +// issuerDid, +// Response( +// requestOptions: RequestOptions(path: ''), +// data: jsonDecode(didDocumentResponse) as Map, +// ), +// ); +// expect(jsonEncode(publicKey), expectedPublicKey); +// }); +// }); + +// group('verify encoded data', () { +// const issuerDid1 = 'did:ebsi:zeFCExU2XAAshYkPCpjuahA'; +// const issuerDid2 = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzC'; +// const issuerDid3 = 'did:ebsi:zhSw5rPXkcHjvquwnVcTzzC'; + +// const issuerKid = +// 'did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53'; + +// const didDocumentUrl = +// 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid1'; + +// const didDocumentResponse = +// '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"P-521","kty":"EC","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; + +// const didDocumentUrl2 = +// 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid2'; + +// const didDocumentResponse2 = +// '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"crv":"Ed25519","kty":"OKP","x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk","y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2"},"type":"Ed25519VerificationKey2019"}]}'; + +// const didDocumentUrl3 = +// 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$issuerDid3'; + +// const didDocumentResponse3 = +// '{"assertionMethod":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"authentication":["did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53"],"@context":"https://www.w3.org/ns/did/v1","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","verificationMethod":[{"controller":"did:ebsi:zeFCExU2XAAshYkPCpjuahA","id":"did:ebsi:zeFCExU2XAAshYkPCpjuahA#3623b877bbb24b08ba390f3585418f53","publicKeyJwk":{"alg":"EdDSA","crv":"Ed25519","kid":"-1909572257","kty":"OKP","x":"XWxGtApfcqmKI7p0OKnF5JSEWMVoLsytFXLEP7xZ_l8"},"type":"Ed25519VerificationKey2019"}]}'; +// dioAdapter +// ..onGet( +// didDocumentUrl, +// (request) => request.reply(200, jsonDecode(didDocumentResponse)), +// ) +// ..onGet( +// didDocumentUrl2, +// (request) => request.reply(200, jsonDecode(didDocumentResponse2)), +// ) +// ..onGet( +// didDocumentUrl3, +// (request) => request.reply(200, jsonDecode(didDocumentResponse3)), +// ); + +// final oidc4vc = OIDC4VC(client); +// test('returns VerificationType.verified', () async { +// const vcJwt = 'eyJhbGciOiJFUzUxMiJ9.' +// 'UGF5bG9hZA.' +// 'AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq' +// 'wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp' +// 'EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn'; + +// final isVerified = await oidc4vc.verifyEncodedData( +// issuerDid: issuerDid1, +// jwt: vcJwt, +// issuerKid: issuerKid, +// ); + +// expect(isVerified, VerificationType.verified); +// }); + +// test('returns VerificationType.notVerified', () async { +// const vcJwt = +// 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksiLCJqd2siOnsiY3J2IjoiUC0yNTZLIiwia3R5IjoiRUMiLCJ4IjoiSjR2UXRMVXlyVlVpRklYUnJ0RXE0eHVybUJacDJlcTl3Sm1Ya0lBX3N0SSIsInkiOiJFVVU2dlhvRzNCR1gyenp3alhyR0RjcjRFeUREMFZmazNfNWZnNWtTZ0tFIn0sImtpZCI6ImRpZDplYnNpOnpvOUZSMVlmQUtGUDNRNmR2cWh4Y1h4bmZlRGlKRFA5N2ttbnFoeUFVU0FDaiNDZ2NnMXk5eGo5dVdGdzU2UE1jMjlYQmQ5RVJlaXh6dm5mdEJ6OEp3UUZpQiJ9.eyJpc3MiOiJkaWQ6ZWJzaTp6bzlGUjFZZkFLRlAzUTZkdnFoeGNYeG5mZURpSkRQOTdrbW5xaHlBVVNBQ2oiLCJub25jZSI6IjdhMDdkZTBmLWE4NzktMTFlZC04MjJiLTBhMTYyODk1ODU2MCIsImlhdCI6MTY3NzA1MDc0MDEyMzIzNSwiYXVkIjoiaHR0cHM6Ly90YWxhby5jby9zYW5kYm94L2Vic2kvaXNzdWVyL3ZndmdoeWxvemwifQ.htjRCpFWbRwanAyQcAq9XZ4vxCXyFbzaaN3yPbPxWIcKFFzDDcA4QCHTUl-L4vzWq0R3LSgQFXQ9bo5D9uCm4w'; // ignore: lines_longer_than_80_chars + +// final isVerified = await oidc4vc.verifyEncodedData( +// issuerDid: issuerDid1, +// jwt: vcJwt, +// issuerKid: issuerKid, +// ); + +// expect(isVerified, VerificationType.notVerified); +// }); + +// test('returns VerificationType.unKnown', () async { +// const vcJwt = 'random'; + +// final isVerified = await oidc4vc.verifyEncodedData( +// issuerDid: issuerDid2, +// jwt: vcJwt, +// issuerKid: issuerKid, +// ); +// expect(isVerified, VerificationType.unKnown); +// }); + +// 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 + +// final isVerified = await oidc4vc.verifyEncodedData( +// issuerDid: issuerDid3, +// jwt: vcJwt, +// issuerKid: issuerKid, +// ); +// expect(isVerified, VerificationType.verified); +// }); +// }); + +// group('getCredentialRequest', () { +// final oidc4vc = OIDC4VC(client); + +// test('extract correct credential type url from openId', () async { +// final url = oidc4vc.getCredentialRequest(givenOpenIdRequest); +// expect( +// url, +// 'https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', +// ); +// }); + +// test('credential type url is empty when url is not OK', () async { +// final url = oidc4vc.getCredentialRequest('www.example.com'); +// expect(url, ''); +// }); +// }); + +// test('extract correct credential type url from openId', () async { +// final oidc4vc = OIDC4VC(client); +// final url = oidc4vc.getCredentialRequest(givenOpenIdRequest); +// expect( +// url, +// 'https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd', +// ); +// }); + +// group('get token', () { +// test('get correct token ', () async { +// final oidc4vc = OIDC4VC(client); + +// final json = { +// 'code': 'cb803d46-9c88-11ed-bdb3-0a1628958560', +// 'grant_type': 'authorization_code' +// }; + +// const expectedValue = +// '{"access_token":"7a07dd19-a879-11ed-ad95-0a1628958560","c_nonce":"7a07de0f-a879-11ed-822b-0a1628958560","token_type":"Bearer","expires_in":1000}'; // ignore: lines_longer_than_80_chars + +// final token = await oidc4vc.getToken(tokenUrl, json); +// expect(jsonEncode(token), expectedValue); +// }); + +// test('throw expection when invalid value is sent', () async { +// expect( +// () async { +// dioAdapter.onPost( +// tokenUrl, +// (request) => request.throws( +// 401, +// DioError(requestOptions: RequestOptions(path: tokenUrl)), +// ), +// ); +// final oidc4vc = OIDC4VC(client); + +// final json = {}; + +// await oidc4vc.getToken(tokenUrl, json); +// }, +// throwsA(isA()), +// ); +// }); +// }); + +// group('get did', () { +// final oidc4vc = OIDC4VC(client); + +// const expectedDidP256K = +// 'did:ebsi:zo9FR1YfAKFP3Q6dvqhxcXxnfeDiJDP97kmnqhyAUSACj'; +// test('from mnemonic ', () async { +// final did = await oidc4vc.getDidFromMnemonic(mnemonic, null); +// expect(did, expectedDidP256K); +// }); + +// test('from P-256K privateKey ', () async { +// const key = { +// 'crv': 'P-256K', +// 'd': 'ccWWNSjGiv1iWlNh4kfhWvwG3yyQMe8o31Du0uKRzrs', +// 'kty': 'EC', +// 'x': 'J4vQtLUyrVUiFIXRrtEq4xurmBZp2eq9wJmXkIA_stI', +// 'y': 'EUU6vXoG3BGX2zzwjXrGDcr4EyDD0Vfk3_5fg5kSgKE' +// }; +// final did = await oidc4vc.getDidFromMnemonic(null, jsonEncode(key)); +// expect(did, expectedDidP256K); +// }); +// test('from secp256k1 privateKey ', () async { +// const expectedDidsecp256k1 = +// 'did:ebsi:zfuA5yVRZVaKna9pRCHv28yyCYWiXWHZXXvtp3AbTdB4p'; +// const key = { +// 'crv': 'secp256k1', +// 'd': 'jMudzhP9YFNywIeIYYJbHtyizeaXOa1PWdX-qBjPTg8', +// 'kty': 'EC', +// 'x': 'yEC4JxUbpYx2-tKExh2NrLpETx-nnudZfcg4AcyL1to', +// 'y': 'HNh3aF4zQsnf_sFXUVaSzrQF85veDoVxhPQ-163wUYM' +// }; +// final did = await oidc4vc.getDidFromMnemonic(null, jsonEncode(key)); +// expect(did, expectedDidsecp256k1); +// }); + +// group('send Presentation', () { +// const url = +// 'https://talao.co/sandbox/ebsi/login/endpoint/f1722b9e-ae19-11ed-ac9f-0a1628958560'; + +// final uri = Uri.parse( +// 'openid://?scope=openid&response_type=id_token&client_id=xjcqarovuv&redirect_uri=https%3A%2F%2Ftalao.co%2Fsandbox%2Febsi%2Flogin%2Fendpoint%2Ff1722b9e-ae19-11ed-ac9f-0a1628958560&claims=%7B%27id_token%27%3A+%7B%27email%27%3A+None%7D%2C+%27vp_token%27%3A+%7B%27presentation_definition%27%3A+%7B%27id%27%3A+%27f17247aa-ae19-11ed-9241-0a1628958560%27%2C+%27input_descriptors%27%3A+%5B%7B%27constraints%27%3A+%7B%27fields%27%3A+%5B%7B%27path%27%3A+%5B%27%24.credentialSchema.id%27%5D%2C+%27filter%27%3A+%7B%27type%27%3A+%27string%27%2C+%27pattern%27%3A+%27https%3A%2F%2Fapi.preprod.oidc4vc.eu%2Ftrusted-schemas-registry%2Fv1%2Fschemas%2F0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd%27%7D%7D%5D%7D%2C+%27id%27%3A+%27f1724e6c-ae19-11ed-a3cf-0a1628958560%27%2C+%27name%27%3A+%27Input+descriptor+1%27%2C+%27purpose%27%3A+%27+%27%7D%5D%2C+%27format%27%3A+%7B%27jwt_vp%27%3A+%7B%27alg%27%3A+%5B%27ES256K%27%2C+%27ES256%27%2C+%27PS256%27%2C+%27RS256%27%5D%7D%7D%7D%7D%7D&nonce=f17239d6-ae19-11ed-8550-0a1628958560', +// ); + +// final credentialToBePresented = [ +// r'{"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","receivedId":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","image":null,"data":{"@context":["https://www.w3.org/2018/credentials/v1"],"credentialSchema":{"id":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://essif.europa.eu/status/education#higherEducation#392ac7f6-399a-437b-a268-4691ead8f176","type":"CredentialStatusList2020"},"credentialSubject":{"awardingOpportunity":{"awardingBody":{"eidasLegalIdentifier":"Unknown","homepage":"https://leaston.bcdiploma.com/","id":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","preferredName":"Leaston University","registration":"0597065J"},"endedAtTime":"2020-06-26T00:00:00Z","id":"https://leaston.bcdiploma.com/law-economics-management#AwardingOpportunity","identifier":"https://certificate-demo.bcdiploma.com/check/87ED2F2270E6C41456E94B86B9D9115B4E35BCCAD200A49B846592C14F79C86BV1Fnbllta0NZTnJkR3lDWlRmTDlSRUJEVFZISmNmYzJhUU5sZUJ5Z2FJSHpWbmZZ","location":"FRANCE","startedAtTime":"2019-09-02T00:00:00Z"},"dateOfBirth":"1993-04-08","familyName":"DOE","givenNames":"Jane","gradingScheme":{"id":"https://leaston.bcdiploma.com/law-economics-management#GradingScheme","title":"2 year full-time programme / 4 semesters"},"id":"did:ebsi:zhFWcvr8DFL3cAVdheCpjHg3sPn1WUh9Gynm6hevPFzpw","identifier":"0904008084H","learningAchievement":{"additionalNote":["DISTRIBUTION MANAGEMENT"],"description":"The Master in Information and Computer Sciences (MICS) at the University of Luxembourg enables students to acquire deeper knowledge in computer science by understanding its abstract and interdisciplinary foundations, focusing on problem solving and developing lifelong learning skills.","id":"https://leaston.bcdiploma.com/law-economics-management#LearningAchievment","title":"Master in Information and Computer Sciences"},"learningSpecification":{"ectsCreditPoints":120,"eqfLevel":7,"id":"https://leaston.bcdiploma.com/law-economics-management#LearningSpecification","iscedfCode":["7"],"nqfLevel":["7"]},"type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd"},"evidence":{"documentPresence":["Physical"],"evidenceDocument":["Passport"],"id":"https://essif.europa.eu/tsr-va/evidence/f2aeec97-fc0d-42bf-8ca7-0548192d5678","subjectPresence":"Physical","type":["DocumentVerification"],"verifier":"did:ebsi:2962fb784df61baa267c8132497539f8c674b37c1244a7a"},"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","issuanceDate":"2023-02-16T12:04:19Z","issued":"2023-02-16T12:04:19Z","issuer":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","proof":{"created":"2022-04-27T12:25:07Z","creator":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","domain":"https://api.preprod.oidc4vc.eu","jws":"eyJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCJdLCJhbGciOiJFUzI1NksifQ..mIBnM8XDQqSYKQNX_LvaJhmsbyCr5OZ5cU2Zk-ReqLpr4doFsgmoobkO5128tZy-8KimVjJkGw0wL1uBWnMLWQ","nonce":"3ea68dae-d07a-4daa-932b-fbb58f5c20c4","type":"EcdsaSecp256k1Signature2019"},"type":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma"],"validFrom":"2023-02-16T12:04:19Z"},"shareLink":"","credentialPreview":{"id":"urn:uuid:6b1d8411-9ed5-4566-9c7f-4c24165ff236","type":["VerifiableCredential","VerifiableAttestation","VerifiableDiploma"],"issuer":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","description":[],"name":[],"issuanceDate":"2023-02-16T12:04:19Z","proof":[{"type":"EcdsaSecp256k1Signature2019","proofPurpose":null,"verificationMethod":null,"created":"2022-04-27T12:25:07Z","jws":"eyJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCJdLCJhbGciOiJFUzI1NksifQ..mIBnM8XDQqSYKQNX_LvaJhmsbyCr5OZ5cU2Zk-ReqLpr4doFsgmoobkO5128tZy-8KimVjJkGw0wL1uBWnMLWQ"}],"credentialSubject":{"id":"did:ebsi:zhFWcvr8DFL3cAVdheCpjHg3sPn1WUh9Gynm6hevPFzpw","type":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","issuedBy":{"name":""},"expires":"","awardingOpportunity":{"awardingBody":{"eidasLegalIdentifier":"Unknown","homepage":"https://leaston.bcdiploma.com/","id":"did:ebsi:zdRvvKbXhVVBsXhatjuiBhs","preferredName":"Leaston University","registration":"0597065J"},"endedAtTime":"2020-06-26T00:00:00Z","id":"https://leaston.bcdiploma.com/law-economics-management#AwardingOpportunity","identifier":"https://certificate-demo.bcdiploma.com/check/87ED2F2270E6C41456E94B86B9D9115B4E35BCCAD200A49B846592C14F79C86BV1Fnbllta0NZTnJkR3lDWlRmTDlSRUJEVFZISmNmYzJhUU5sZUJ5Z2FJSHpWbmZZ","location":"FRANCE","startedAtTime":"2019-09-02T00:00:00Z"},"dateOfBirth":"1993-04-08","familyName":"DOE","givenNames":"Jane","gradingScheme":{"id":"https://leaston.bcdiploma.com/law-economics-management#GradingScheme","title":"2 year full-time programme / 4 semesters"},"identifier":"0904008084H","learningAchievement":{"additionalNote":["DISTRIBUTION MANAGEMENT"],"description":"The Master in Information and Computer Sciences (MICS) at the University of Luxembourg enables students to acquire deeper knowledge in computer science by understanding its abstract and interdisciplinary foundations, focusing on problem solving and developing lifelong learning skills.","id":"https://leaston.bcdiploma.com/law-economics-management#LearningAchievment","title":"Master in Information and Computer Sciences"},"learningSpecification":{"ectsCreditPoints":120,"eqfLevel":7,"id":"https://leaston.bcdiploma.com/law-economics-management#LearningSpecification","iscedfCode":["7"],"nqfLevel":["7"]}},"evidence":[{"id":"https://essif.europa.eu/tsr-va/evidence/f2aeec97-fc0d-42bf-8ca7-0548192d5678","type":["DocumentVerification"]}],"credentialStatus":{"id":"https://essif.europa.eu/status/education#higherEducation#392ac7f6-399a-437b-a268-4691ead8f176","type":"CredentialStatusList2020","revocationListIndex":"","revocationListCredential":""}},"display":{"backgroundColor":"","icon":"","nameFallback":"","descriptionFallback":""},"expirationDate":null,"credential_manifest":{"id":"VerifiableDiploma_1","issuer":{"id":"did:ebsi:zhSw5rPXkcHjvquwnVcTzzB","name":"Test EBSILUX"},"output_descriptors":[{"id":"diploma_01","schema":"https://api.preprod.oidc4vc.eu/trusted-schemas-registry/v1/schemas/0xbf78fc08a7a9f28f5479f58dea269d3657f54f13ca37d380cd4e92237fb691dd","name":null,"description":null,"styles":null,"display":{"title":{"path":[],"schema":{"type":"string","format":null},"fallback":"Diploma"},"subtitle":{"path":[],"schema":{"type":"string","format":null},"fallback":"EBSI Verifiable diploma"},"description":{"path":[],"schema":{"type":"string","format":null},"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."},"properties":[{"label":"First name","path":["$.credentialSubject.firstName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Last name","path":["$.credentialSubject.familyName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Birth date","path":["$.credentialSubject.dateOfBirth"],"schema":{"type":"string","format":"date"},"fallback":"Unknown"},{"label":"Grading scheme","path":["$.credentialSubject.gradingScheme.title"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Title","path":["$.credentialSubject.learningAchievement.title"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Description","path":["$.credentialSubject.learningAchievement.description"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"ECTS Points","path":["$.credentialSubject.learningSpecification.ectsCreditPoints"],"schema":{"type":"number","format":null},"fallback":"Unknown"},{"label":"Issue date","path":["$.issuanceDate"],"schema":{"type":"string","format":"date"},"fallback":"Unknown"},{"label":"Issued by","path":["$.credentialSubject.awardingOpportunity.awardingBody.preferredName"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Registration","path":["$.credentialSubject.awardingOpportunity.awardingBody.registration"],"schema":{"type":"string","format":null},"fallback":"Unknown"},{"label":"Website","path":["$.credentialSubject.awardingOpportunity.awardingBody.homepage"],"schema":{"type":"string","format":"uri"},"fallback":"Unknown"}]}}],"presentation_definition":null},"challenge":null,"domain":null,"activities":[{"acquisitionAt":"2023-02-16T17:34:24.679713","presentation":null},{"acquisitionAt":null,"presentation":{"issuer":{"preferredName":"","did":[],"organizationInfo":{"id":"","legalName":"","currentAddress":"","website":"domain","issuerDomain":[]}},"presentedAt":"2023-02-16T17:34:47.206600"}}],"jwt":"eyJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6ZWJzaTp6aFN3NXJQWGtjSGp2cXV3blZjVHp6QiM1MTVhOWM0MzZjMGYyYWQzYWI2NWQ2Y2VmYzVjMWYwNmMwNWI4YWRmY2Y1NGVlMDZkYzgwNTQzMjA0NzBmZmFmIiwidHlwIjoiSldUIn0.eyJleHAiOjE2NzY1NTAwNTkuMj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24iLCJWZXJpZmlhYmxlRGlwbG9tYSJdLCJ2YWxpZEZyb20iOiIyMDIzLTAyLTE2VDEyOjA0OjE5WiJ9fQ.7Bmdrkp-hpM7BcNASc7ngjia3cjrZr-nqmP0Plsfnefn26G_yR5fBJV8BT_U2zsMlcqWsxuJ9pS2Vyiq_SrooQ"}' +// ]; + +// test('successfully send presentation', () async { +// const response = +// '{"access":"ok","created":1676566727.680238,"credential_status":"signature check bypassed","holder_did_status":"ok","id_token_status":"ok","qrcode_status":"ok","response_format":"ok","status_code":200,"vp_token_status":"ok"}'; // ignore: lines_longer_than_80_chars +// dioAdapter.onGet( +// url, +// (request) => request.reply(200, jsonDecode(response)), +// ); +// final oidc4vc = OIDC4VC(client); + +// expect( +// () async { +// await oidc4vc.sendPresentation( +// uri, +// credentialToBePresented, +// mnemonic, +// null, +// ); +// }, +// returnsNormally, +// ); +// }); + +// test('throw exception', () async { +// expect( +// () async { +// dioAdapter.onPost( +// url, +// (request) => request.throws( +// 401, +// DioError(requestOptions: RequestOptions(path: tokenUrl)), +// ), +// ); +// final oidc4vc = OIDC4VC(client); + +// await oidc4vc.sendPresentation( +// uri, +// credentialToBePresented, +// mnemonic, +// null, +// ); +// }, +// throwsA(isA()), +// ); +// }); +// }); +// }); + +// test('get corresponding did document', () async { +// const url = +// 'https://api-pilot.oidc4vc.eu/did-registry/v3/identifiers/$didKey'; +// const response = { +// '@context': 'https://w3id.org/did/v1', +// 'id': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH', +// 'verificationMethod': [ +// { +// 'id': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH#keys-1', +// 'type': 'Secp256k1VerificationKey2018', +// 'controller': 'did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH', +// 'publicKeyHex': +// '04f9139fbd3b9780863b17e8390934a1017fc8d0f18b84f02acb04f24c9cae261e45745c6507881509b9e6d837329153ea75fafb2c1a5d504702d04f1e22a80ecc' // ignore: lines_longer_than_80_chars +// } +// ], +// 'authentication': ['did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH'], +// 'assertionMethod': ['did:ebsi:z24q8qN8UE1j4XAFiFKtvJbH#keys-1'] +// }; + +// dioAdapter.onGet( +// url, +// (request) => request.reply(200, response), +// ); +// final oidc4vc = OIDC4VC(client); + +// final value = await oidc4vc.getDidDocument(didKey); + +// expect(value.data, response); +// }); + +// test('sandbox', () { +// const cNonce = 'cNonce'; +// const did = 'did'; +// const issuer = 'issuer'; +// final payload = { +// 'iss': did, +// 'nonce': cNonce, +// 'iat': DateTime.now().microsecondsSinceEpoch, +// 'aud': issuer +// }; + +// final jwt = JWT( +// // Payload +// payload, + +// issuer: issuer, +// ); + +// // Sign it (default with HS256 algorithm) +// // ignore: unused_local_variable +// final token = jwt.sign(SecretKey('secret passphrase')); +// }); + +// // test('generateToken', () { +// // final jwk = { +// // 'kty': 'OKP', +// // 'crv': 'Ed25519', +// // 'd': '-_9OD-PMHKE2mFKEVH5R1vDhEMimtXPUX-2w1Xa0hQ0=', +// // 'x': '1tknP1Fx-YIQBzw3xXtCwLGgYoTb-nSsNn-k9uzWpuw=', +// // }; + +// // final vpTokenPayload = { +// // 'iss': 'did:ebsi:zrDzYQPDztwjQ8HdXto1B4FVB14fxoiNawZd8eyEuhR7K', +// // 'nonce': '8dd8d00a-ad17-11ed-9fe9-0a1628958560', +// // 'iat': '1676455223753366', +// // 'aud': 'https://talao.co/sandbox/ebsi/issuer/vgvghylozl', +// // }; + +// // final oidc4vc = OIDC4VC(client); + +// // final tokenParameters = TokenParameters(jwk); +// // final token = oidc4vc.generateToken(vpTokenPayload, tokenParameters); + +// // }); +// }