Skip to content

Commit

Permalink
Merge branch 'main' into TALAO
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Sep 27, 2024
2 parents 81b1f51 + 3e6799f commit dad4b69
Show file tree
Hide file tree
Showing 33 changed files with 454 additions and 126 deletions.
1 change: 1 addition & 0 deletions lib/app/shared/constants/parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Parameters {
static const String walletName = 'talao_wallet';

static const DidKeyType didKeyTypeForEbsiV3 = DidKeyType.ebsiv3;
static const DidKeyType didKeyTypeForEbsiV4 = DidKeyType.ebsiv4;
static const DidKeyType didKeyTypeForDefault = DidKeyType.edDSA;
static const DidKeyType didKeyTypeForDutch = DidKeyType.jwkP256;
static const DidKeyType didKeyTypeForOwfBaselineProfile = DidKeyType.jwkP256;
Expand Down
4 changes: 2 additions & 2 deletions lib/app/shared/enum/type/oidc4vc_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum OIDC4VCType {
presentationPrefix: 'openid-hedera://',
),

EBSIV3(
EBSI(
offerPrefix: 'openid-credential-offer://',
presentationPrefix: 'openid-vc://',
),
Expand Down Expand Up @@ -44,7 +44,7 @@ extension OIDC4VCTypeX on OIDC4VCType {
case OIDC4VCType.DEFAULT:
case OIDC4VCType.GAIAX:
case OIDC4VCType.GREENCYPHER:
case OIDC4VCType.EBSIV3:
case OIDC4VCType.EBSI:
case OIDC4VCType.HAIP:
return true;
case OIDC4VCType.JWTVC:
Expand Down
6 changes: 6 additions & 0 deletions lib/app/shared/enum/type/profile/did_key_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum DidKeyType {
p256,
@JsonValue('did:key:ebsi')
ebsiv3,
ebsiv4,
@JsonValue('did:jwk:p-256')
jwkP256,
@JsonValue(
Expand All @@ -29,6 +30,8 @@ extension DidKeyTypeX on DidKeyType {
return 'did:key P-256';
case DidKeyType.ebsiv3:
return 'did:key EBSI-V3';
case DidKeyType.ebsiv4:
return 'did:key EBSI-V4';
case DidKeyType.jwkP256:
return 'did:jwk P-256';
case DidKeyType.jwtClientAttestation:
Expand All @@ -46,6 +49,8 @@ extension DidKeyTypeX on DidKeyType {
return l10n.keyDecentralizedIDP256;
case DidKeyType.ebsiv3:
return l10n.ebsiV3DecentralizedId;
case DidKeyType.ebsiv4:
return l10n.ebsiV4DecentralizedId;
case DidKeyType.jwkP256:
return l10n.jwkDecentralizedIDP256;
case DidKeyType.jwtClientAttestation:
Expand All @@ -62,6 +67,7 @@ extension DidKeyTypeX on DidKeyType {
case DidKeyType.edDSA:
return true;
case DidKeyType.ebsiv3:
case DidKeyType.ebsiv4:
return false;
}
}
Expand Down
6 changes: 5 additions & 1 deletion lib/app/shared/enum/type/profile/profile_type.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum ProfileType {
defaultOne,
ebsiV3,
ebsiV4,
diipv2point1,
diipv3,
custom,
Expand All @@ -13,7 +14,9 @@ extension ProfileTypeX on ProfileType {
case ProfileType.custom:
return 'Custom';
case ProfileType.ebsiV3:
return 'European Blockchain Services Infrastructure';
return 'European Blockchain Services Infrastructure (EBSI v3.x)';
case ProfileType.ebsiV4:
return 'European Blockchain Services Infrastructure (EBSI v4.x)';
case ProfileType.diipv2point1:
return 'Decentralized Identity Interop Profile (DIIP v2.1)';
case ProfileType.enterprise:
Expand All @@ -32,6 +35,7 @@ extension ProfileTypeX on ProfileType {
case ProfileType.diipv2point1:
return false;
case ProfileType.ebsiV3:
case ProfileType.ebsiV4:
case ProfileType.enterprise:
case ProfileType.diipv3:
return true;
Expand Down
37 changes: 20 additions & 17 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ String getCredentialName(String constraints) {
final dynamic constraintsJson = jsonDecode(constraints);
final fieldsPath = JsonPath(r'$..fields');
final dynamic credentialField =
(fieldsPath.read(constraintsJson).first.value as List)
(fieldsPath.read(constraintsJson).first.value! as List)
.where(
(dynamic e) =>
e['path'].toString() == r'[$.credentialSubject.type]',
Expand All @@ -113,7 +113,7 @@ String getIssuersName(String constraints) {
final dynamic constraintsJson = jsonDecode(constraints);
final fieldsPath = JsonPath(r'$..fields');
final dynamic issuerField =
(fieldsPath.read(constraintsJson).first.value as List)
(fieldsPath.read(constraintsJson).first.value! as List)
.where(
(dynamic e) => e['path'].toString() == r'[$.issuer]',
)
Expand Down Expand Up @@ -234,12 +234,12 @@ String getDateTimeWithoutSpace({DateTime? dateTime}) {
}

int getIndexValue({
required bool isEBSIV3,
required bool isEBSI,
required DidKeyType didKeyType,
}) {
switch (didKeyType) {
case DidKeyType.secp256k1:
if (isEBSIV3) {
if (isEBSI) {
return 3;
} else {
return 1;
Expand All @@ -250,7 +250,8 @@ int getIndexValue({
return 5;
case DidKeyType.jwkP256:
return 6;

case DidKeyType.ebsiv4:
return 7;
case DidKeyType.edDSA:
case DidKeyType.jwtClientAttestation:
return 0; // it is not needed, just assigned
Expand Down Expand Up @@ -282,7 +283,7 @@ Future<String> getPrivateKey({

case DidKeyType.secp256k1:
final index = getIndexValue(
isEBSIV3: true,
isEBSI: true,
didKeyType: didKeyType,
);
final key = profileCubit.oidc4vc.privateKeyFromMnemonic(
Expand All @@ -293,9 +294,10 @@ Future<String> getPrivateKey({

case DidKeyType.p256:
case DidKeyType.ebsiv3:
case DidKeyType.ebsiv4:
case DidKeyType.jwkP256:
final indexValue = getIndexValue(
isEBSIV3: false,
isEBSI: false,
didKeyType: didKeyType,
);

Expand Down Expand Up @@ -398,9 +400,9 @@ DidKeyType? getDidKeyFromString(String? didKeyTypeString) {
Future<String> fetchPrivateKey({
required ProfileCubit profileCubit,
required DidKeyType didKeyType,
bool? isEBSIV3,
bool? isEBSI,
}) async {
if (isEBSIV3 != null && isEBSIV3) {
if (isEBSI != null && isEBSI) {
final privateKey = await getPrivateKey(
profileCubit: profileCubit,
didKeyType: DidKeyType.ebsiv3,
Expand Down Expand Up @@ -533,6 +535,7 @@ Future<(String, String)> getDidAndKid({

switch (didKeyType) {
case DidKeyType.ebsiv3:
case DidKeyType.ebsiv4:

//b'\xd1\xd6\x03' in python
final List<int> prefixByteList = [0xd1, 0xd6, 0x03];
Expand Down Expand Up @@ -592,11 +595,11 @@ Future<(String, String)> getDidAndKid({

Future<(String, String)> fetchDidAndKid({
required String privateKey,
bool? isEBSIV3,
bool? isEBSI,
required ProfileCubit profileCubit,
required DidKeyType didKeyType,
}) async {
if (isEBSIV3 != null && isEBSIV3) {
if (isEBSI != null && isEBSI) {
final (did, kid) = await getDidAndKid(
didKeyType: DidKeyType.ebsiv3,
privateKey: privateKey,
Expand Down Expand Up @@ -785,7 +788,7 @@ Future<
for (final oidc4vcType in OIDC4VCType.values) {
if (oidc4vcType.isEnabled && url.startsWith(oidc4vcType.offerPrefix)) {
if (oidc4vcType == OIDC4VCType.DEFAULT ||
oidc4vcType == OIDC4VCType.EBSIV3) {
oidc4vcType == OIDC4VCType.EBSI) {
if (credSupported?.trustFramework != null &&
credSupported == credSupported?.trustFramework) {
return (
Expand All @@ -801,7 +804,7 @@ Future<
if (credSupported?.trustFramework?.name != null &&
credSupported?.trustFramework?.name == 'ebsi') {
return (
OIDC4VCType.EBSIV3,
OIDC4VCType.EBSI,
openIdConfiguration,
authorizationServerConfiguration,
credentialOfferJson,
Expand Down Expand Up @@ -997,7 +1000,7 @@ Future<Map<String, dynamic>?> getClientMetada({
}
}

Future<bool?> isEBSIV3ForVerifiers({
Future<bool?> isEBSIForVerifiers({
required Uri uri,
required OIDC4VC oidc4vc,
required OIDC4VCIDraftType oidc4vciDraftType,
Expand Down Expand Up @@ -1595,7 +1598,7 @@ bool supportCryptoCredential(ProfileModel profileModel) {
// oAuthClientAttestationPop
Future<(String?, String?, String?, String?, String?)> getClientDetails({
required ProfileCubit profileCubit,
required bool isEBSIV3,
required bool isEBSI,
required String issuer,
}) async {
try {
Expand All @@ -1612,13 +1615,13 @@ Future<(String?, String?, String?, String?, String?)> getClientDetails({

final String privateKey = await fetchPrivateKey(
profileCubit: profileCubit,
isEBSIV3: isEBSIV3,
isEBSI: isEBSI,
didKeyType: didKeyType,
);

final (did, _) = await fetchDidAndKid(
privateKey: privateKey,
isEBSIV3: isEBSIV3,
isEBSI: isEBSI,
profileCubit: profileCubit,
didKeyType: didKeyType,
);
Expand Down
22 changes: 21 additions & 1 deletion lib/app/shared/widget/base/credential_field.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:altme/app/shared/launch_url/launch_url.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class CredentialField extends StatelessWidget {
Expand All @@ -9,6 +11,7 @@ class CredentialField extends StatelessWidget {
this.titleColor,
this.valueColor,
this.padding = const EdgeInsets.all(8),
this.type = 'string',
});

final String value;
Expand All @@ -17,6 +20,7 @@ class CredentialField extends StatelessWidget {
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;
final String type;

@override
Widget build(BuildContext context) {
Expand All @@ -29,6 +33,7 @@ class CredentialField extends StatelessWidget {
valueColor: valueColor,
padding: padding,
showVertically: showVertically,
type: type,
),
);
}
Expand All @@ -43,6 +48,7 @@ class DisplayCredentialField extends StatelessWidget {
this.valueColor,
required this.padding,
required this.showVertically,
this.type = 'string',
});

final String? title;
Expand All @@ -51,6 +57,7 @@ class DisplayCredentialField extends StatelessWidget {
final Color? valueColor;
final EdgeInsetsGeometry padding;
final bool showVertically;
final String type;

@override
Widget build(BuildContext context) {
Expand All @@ -74,7 +81,20 @@ class DisplayCredentialField extends StatelessWidget {
],
TextSpan(
text: value,
style: textTheme.bodyMedium!.copyWith(color: valueColor),
style: textTheme.bodyMedium!.copyWith(
color: (type == 'uri' || type == 'email')
? Theme.of(context).colorScheme.primary
: valueColor,
),
recognizer: TapGestureRecognizer()
..onTap = () async {
if (type == 'uri') {
await LaunchUrl.launch(value);
}
if (type == 'email') {
await LaunchUrl.launch('mailto:$value');
}
},
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/app/shared/widget/wallet_logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class WalletLogo extends StatelessWidget {
? ImageStrings.appLogoStage
: ImageStrings.appLogo;
case ProfileType.ebsiV3:
case ProfileType.ebsiV4:
image = ImageStrings.ebsiLogo;
case ProfileType.enterprise:
final isLightTheme =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class _CryptoBottomSheetPageState extends State<CryptoBottomSheetPage> {
ConfirmDialog(
title: l10n
.deleteAccountMessage(
data.name),
data.name,),
yes: l10n.ok,
showNoButton: false,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DidKeyTypeWidget extends StatelessWidget {
VCFormatType.ldpVc;

final isUnmatchedDid = didKeyType == DidKeyType.ebsiv3 ||
didKeyType == DidKeyType.ebsiv4 ||
didKeyType == DidKeyType.jwkP256;

if (isldpVc && isUnmatchedDid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class CredentialSubjectData extends StatelessWidget {
titleColor: Theme.of(context).colorScheme.onSurface,
valueColor: Theme.of(context).colorScheme.onSurface,
showVertically: showVertically,
type: value['value_type'].toString(),
);
}).toList(),
);
Expand Down
Loading

0 comments on commit dad4b69

Please sign in to comment.