Skip to content

Commit

Permalink
Merge branch 'TALAO' into TALAO_android
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Feb 20, 2024
2 parents 35c1c44 + f40d176 commit b8436c7
Show file tree
Hide file tree
Showing 101 changed files with 2,348 additions and 1,415 deletions.
Binary file added assets/image/owfBaselineProfileLogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/app/shared/constants/image_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class ImageStrings {

static const String imagePath = 'assets/image';
static const String ebsiLogo = '$imagePath/ebsi_logo.png';
static const String owfBaselineProfileLogo =
'$imagePath/owfBaselineProfileLogo.jpg';

static const String cardMissing = '$imagePath/card_missing.png';
static const String employmentCertificateFront =
'$imagePath/carte-attestation-employeur-recto.png';
Expand Down
6 changes: 6 additions & 0 deletions lib/app/shared/constants/parameters.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:altme/app/shared/enum/enum.dart';
import 'package:altme/dashboard/dashboard.dart';

class Parameters {
Expand Down Expand Up @@ -67,4 +68,9 @@ class Parameters {
static const int maxEntries = 3;

static const String appName = 'Talao';

static const DidKeyType didKeyTypeForEbsiV3 = DidKeyType.ebsiv3;
static const DidKeyType didKeyTypeForDefault = DidKeyType.p256;
static const DidKeyType didKeyTypeForDutch = DidKeyType.jwkP256;
static const DidKeyType didKeyTypeForOwfBaselineProfile = DidKeyType.jwkP256;
}
10 changes: 8 additions & 2 deletions lib/app/shared/constants/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Urls {
static const String issuerBaseUrl = 'https://issuer.talao.co';
static const String phonePassUrl = 'https://issuer.talao.co/phonepass';
static const String emailPassUrl = 'https://issuer.talao.co/emailpass';
static const String emailPassUrlJWTVCJSON =
'https://issuer.talao.co/emailpass?format=jwt_vc_json';

static const String tezotopiaVoucherUrl =
'https://issuer.tezotopia.altme.io/issuer/voucher_mobile';
Expand Down Expand Up @@ -50,9 +52,13 @@ class Urls {
static const String twitterCardUrl = 'https://issuer.talao.co/twitter/';

static const String identityCardUrlLDPVC =
'https://issuer.talao.co/passbase/endpoint/verifiableid/';
'https://talao.co/id360/oidc4vc?format=ldp_vc&type=verifiableid';

static const String identityCardUrlJWTVCJSON =
'https://talao.co/id360/oidc4vc/';
'https://talao.co/id360/oidc4vc?format=jwt_vc_json&type=verifiableid';

static const String identityCardUrlVCSDJWT =
'https://talao.co/id360/oidc4vc?format=vcsd-jwt&type=identitycredential';

static const String over18JWTVCJSON =
'https://talao.co/id360/oidc4vc?type=over18';
Expand Down
1 change: 0 additions & 1 deletion lib/app/shared/enum/credential_category.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:altme/app/app.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,21 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.binanceAssociatedWallet:
case CredentialSubjectType.tezosAssociatedWallet:
case CredentialSubjectType.defiCompliance:
case CredentialSubjectType.emailPass:
case CredentialSubjectType.tezotopiaMembership:
case CredentialSubjectType.phonePass:
case CredentialSubjectType.chainbornMembership:
return [VCFormatType.ldpVc];

case CredentialSubjectType.verifiableIdCard:
return [
VCFormatType.ldpVc,
VCFormatType.jwtVcJson,
VCFormatType.vcSdJWT,
];

case CredentialSubjectType.over18:
case CredentialSubjectType.livenessCard:
case CredentialSubjectType.emailPass:
return [VCFormatType.ldpVc, VCFormatType.jwtVcJson];

case CredentialSubjectType.nationality:
Expand Down Expand Up @@ -736,7 +742,18 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {

case CredentialSubjectType.emailPass:
image = ImageStrings.dummyEmailPassCard;
link = Urls.emailPassUrl;

switch (vcFormatType) {
case VCFormatType.ldpVc:
link = Urls.emailPassUrl;
case VCFormatType.jwtVcJson:
link = Urls.emailPassUrlJWTVCJSON;
case VCFormatType.jwtVc:
case VCFormatType.jwtVcJsonLd:
case VCFormatType.vcSdJWT:
link = '';
}

whyGetThisCard = ResponseString.RESPONSE_STRING_emailPassWhyGetThisCard;
expirationDateDetails =
ResponseString.RESPONSE_STRING_emailPassExpirationDate;
Expand Down Expand Up @@ -767,6 +784,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
link = Urls.over18JWTVCJSON;
case VCFormatType.jwtVc:
case VCFormatType.jwtVcJsonLd:
case VCFormatType.vcSdJWT:
link = '';
}
whyGetThisCard = ResponseString.RESPONSE_STRING_over18WhyGetThisCard;
Expand Down Expand Up @@ -828,6 +846,8 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case VCFormatType.jwtVc:
case VCFormatType.jwtVcJsonLd:
link = '';
case VCFormatType.vcSdJWT:
link = Urls.identityCardUrlVCSDJWT;
}

whyGetThisCard =
Expand Down Expand Up @@ -897,6 +917,7 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
link = Urls.livenessCardJWTVCJSON;
case VCFormatType.jwtVc:
case VCFormatType.jwtVcJsonLd:
case VCFormatType.vcSdJWT:
link = '';
}

Expand Down Expand Up @@ -972,7 +993,6 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
longDescription: longDescription == null
? null
: ResponseMessage(message: longDescription),
vcFormatTypes: getVCFormatType,
);
}

Expand Down
2 changes: 0 additions & 2 deletions lib/app/shared/enum/type/profile/profile.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export 'did_key_type.dart';
export 'profile_type.dart';
export 'subject_syntax.dart';
export 'user_pin_digits.dart';
export 'wallet_app_type.dart';
12 changes: 10 additions & 2 deletions lib/app/shared/enum/type/profile/profile_type.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:altme/l10n/l10n.dart';

enum ProfileType {
custom,
defaultOne,
ebsiV3,
dutch,
enterprise,
owfBaselineProfile,
custom,
}

extension ProfileTypeX on ProfileType {
Expand All @@ -20,17 +22,23 @@ extension ProfileTypeX on ProfileType {
case ProfileType.dutch:
return l10n.decentralizedIdentityInteropProfile;
case ProfileType.enterprise:
return name.isEmpty ? 'Enterprise' : name;
return name.isEmpty ? l10n.enterprise : name;
case ProfileType.owfBaselineProfile:
return l10n.oWFBaselineProfile;
case ProfileType.defaultOne:
return l10n.defaultProfile;
}
}

bool get showSponseredBy {
switch (this) {
case ProfileType.custom:
case ProfileType.defaultOne:
case ProfileType.dutch:
return false;
case ProfileType.ebsiV3:
case ProfileType.enterprise:
case ProfileType.owfBaselineProfile:
return true;
}
}
Expand Down
8 changes: 0 additions & 8 deletions lib/app/shared/enum/type/profile/subject_syntax.dart

This file was deleted.

20 changes: 0 additions & 20 deletions lib/app/shared/enum/type/profile/user_pin_digits.dart

This file was deleted.

49 changes: 34 additions & 15 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ Future<(String, String)> getDidAndKid({
required String privateKey,
required SecureStorageProvider secureStorage,
required DidKeyType didKeyType,
DIDKitProvider? didKitProvider,
required DIDKitProvider? didKitProvider,
}) async {
late String did;
late String kid;
Expand Down Expand Up @@ -637,8 +637,11 @@ Future<(OIDC4VCType?, OpenIdConfiguration?, OpenIdConfiguration?, dynamic)>
}

final credentialsSupported = openIdConfiguration.credentialsSupported;
final credentialConfigurationsSupported =
openIdConfiguration.credentialConfigurationsSupported;

if (credentialsSupported == null) {
if (credentialsSupported == null &&
credentialConfigurationsSupported == null) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
Expand All @@ -647,13 +650,18 @@ Future<(OIDC4VCType?, OpenIdConfiguration?, OpenIdConfiguration?, dynamic)>
);
}

final credSupported = credentialsSupported[0];
CredentialsSupported? credSupported;

if (credentialsSupported != null) {
credSupported = credentialsSupported[0];
}

for (final oidc4vcType in OIDC4VCType.values) {
if (oidc4vcType.isEnabled && url.startsWith(oidc4vcType.offerPrefix)) {
if (oidc4vcType == OIDC4VCType.DEFAULT ||
oidc4vcType == OIDC4VCType.EBSIV3) {
if (credSupported.trustFramework != null &&
credSupported == credSupported.trustFramework) {
if (credSupported?.trustFramework != null &&
credSupported == credSupported?.trustFramework) {
return (
OIDC4VCType.DEFAULT,
openIdConfiguration,
Expand All @@ -662,8 +670,8 @@ Future<(OIDC4VCType?, OpenIdConfiguration?, OpenIdConfiguration?, dynamic)>
);
}

if (credSupported.trustFramework?.name != null &&
credSupported.trustFramework?.name == 'ebsi') {
if (credSupported?.trustFramework?.name != null &&
credSupported?.trustFramework?.name == 'ebsi') {
return (
OIDC4VCType.EBSIV3,
openIdConfiguration,
Expand Down Expand Up @@ -758,7 +766,8 @@ Future<void> handleErrorForOID4VCI({
);
}

if (openIdConfiguration.credentialsSupported == null) {
if (openIdConfiguration.credentialsSupported == null &&
openIdConfiguration.credentialConfigurationsSupported == null) {
throw ResponseMessage(
data: {
'error': 'invalid_issuer_metadata',
Expand Down Expand Up @@ -1011,7 +1020,9 @@ bool isURL(String input) {
}

MessageHandler getMessageHandler(dynamic e) {
if (e is DioException) {
if (e is MessageHandler) {
return e;
} else if (e is DioException) {
final error = NetworkException.getDioException(error: e);

return NetworkException(data: error.data);
Expand All @@ -1022,8 +1033,6 @@ MessageHandler getMessageHandler(dynamic e) {
'error_description': '${e.message}\n\n${e.source}',
},
);
} else if (e is MessageHandler) {
return e;
} else if (e is TypeError) {
return ResponseMessage(
data: {
Expand All @@ -1032,10 +1041,20 @@ MessageHandler getMessageHandler(dynamic e) {
},
);
} else {
return ResponseMessage(
message:
ResponseString.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER,
);
final stringException = e.toString().replaceAll('Exception: ', '');
if (stringException == 'CREDENTIAL_SUPPORT_DATA_ERROR') {
return ResponseMessage(
data: {
'error': 'unsupported_credential_format',
'error_description': 'The credential support format has some issues.',
},
);
} else {
return ResponseMessage(
message:
ResponseString.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER,
);
}
}
}

Expand Down
21 changes: 11 additions & 10 deletions lib/app/shared/widget/powered_by_text.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import 'package:altme/app/app.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:flutter/material.dart';

class PoweredByText extends StatelessWidget {
const PoweredByText({super.key});

@override
Widget build(BuildContext context) {
// final l10n = context.l10n;
// return SizedBox(
// child: Text(
// '${l10n.poweredBy} ${Parameters.appName}',
// maxLines: 1,
// textAlign: TextAlign.center,
// style: Theme.of(context).textTheme.bodyLarge,
// ),
// );
return const SizedBox.shrink();
final l10n = context.l10n;
return SizedBox(
child: Text(
'${l10n.poweredBy} ${Parameters.appName}',
maxLines: 1,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
);
}
}
17 changes: 10 additions & 7 deletions lib/app/shared/widget/wallet_logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class WalletLogo extends StatelessWidget {
switch (profileModel.profileType) {
case ProfileType.custom:
case ProfileType.dutch:
case ProfileType.defaultOne:
image = flavorCubit.state == FlavorMode.development
? ImageStrings.appLogoDev
: flavorCubit.state == FlavorMode.staging
Expand All @@ -35,6 +36,8 @@ class WalletLogo extends StatelessWidget {
image = ImageStrings.ebsiLogo;
case ProfileType.enterprise:
image = profileModel.profileSetting.generalOptions.companyLogo;
case ProfileType.owfBaselineProfile:
image = ImageStrings.owfBaselineProfileLogo;
}

return Column(
Expand All @@ -61,13 +64,13 @@ class WalletLogo extends StatelessWidget {
),
),
),
if (showPoweredBy &&
profileModel.profileType == ProfileType.enterprise) ...[
if (profileModel.profileType.showSponseredBy) ...[
const SizedBox(height: 5),
const Center(child: PoweredByText()),
],
],
// if (showPoweredBy &&
// profileModel.profileType == ProfileType.enterprise) ...[
// if (profileModel.profileType.showSponseredBy) ...[
// const SizedBox(height: 5),
// const Center(child: PoweredByText()),
// ],
// ],
],
);
}
Expand Down
Loading

0 comments on commit b8436c7

Please sign in to comment.