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 May 30, 2024
2 parents b246f26 + a472a9c commit b51204f
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ List<CredentialModel> getCredentialsFromFilterList({
}
}
}
return selectedCredential;
return selectedCredential.toSet().toList();
}
return credentialList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class SelectiveDisclosureCubit extends Cubit<SelectiveDisclosureState> {
final searchList = getTextsFromCredential(path, credentialData);
for (final element in searchList) {
final key = path.split('.').toList().last;
json[key] = element;
json[key] = {
'element': element,
'optional': field.optional,
};
}
}
}
Expand Down Expand Up @@ -81,27 +84,20 @@ class SelectiveDisclosureCubit extends Cubit<SelectiveDisclosureState> {
int? index;

if (threeDotValue != null) {
for (final element
in selectiveDisclosure.disclosureToContent.entries.toList()) {
final sh256Hash = oidc4vc.sh256HashOfContent(element.value.toString());
if (sh256Hash == threeDotValue) {
final disclosure = element.key.replaceAll('=', '');

index = selectiveDisclosure.disclosureFromJWT
.indexWhere((element) => element == disclosure);
}
}
index = selectiveDisclosure.disclosureFromJWT
.indexWhere((entry) => entry == threeDotValue);
} else if (claimsKey != null) {
index = selectiveDisclosure.extractedValuesFromJwt.entries
.toList()
.indexWhere((entry) => entry.key == claimsKey);
index =
selectiveDisclosure.disclosureToContent.entries.toList().indexWhere(
(entry) => entry.value.toString().contains(claimsKey),
);
}

if (index == null) {
if (index == null || index == -1) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Issue with the dislosuer of jwt.',
'error_description': 'Issue with the dislosure of jwt.',
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/scan/cubit/scan_cubit.dart';
import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:altme/selective_disclosure/widget/display_selective_disclosure.dart';
import 'package:altme/selective_disclosure/widget/inject_selective_disclosure_state.dart';
import 'package:credential_manifest/credential_manifest.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -115,8 +115,8 @@ class _SelectiveDisclosurePickViewState
);
}
},
child: BlocBuilder<SelectiveDisclosureCubit, SelectiveDisclosureState>(
builder: (context, state) {
child: Builder(
builder: (BuildContext context) {
final profileSetting =
context.read<ProfileCubit>().state.model.profileSetting;

Expand All @@ -143,10 +143,8 @@ class _SelectiveDisclosurePickViewState
isDiscover: false,
),
const SizedBox(height: 20),
DisplaySelectiveDisclosure(
ConsumeSelectiveDisclosureCubit(
credentialModel: widget.credentialToBePresented,
claims: null,
selectiveDisclosureState: state,
onPressed: (claimKey, claimKeyId, threeDotValue) {
context.read<SelectiveDisclosureCubit>().disclosureAction(
claimsKey: claimKey,
Expand All @@ -164,13 +162,18 @@ class _SelectiveDisclosurePickViewState
padding: const EdgeInsets.all(16),
child: Tooltip(
message: l10n.credentialPickPresent,
child: MyGradientButton(
onPressed: () => present(
context: context,
selectedSDIndexInJWT: state.selectedSDIndexInJWT,
uri: widget.uri,
),
text: l10n.credentialPickPresent,
child: BlocBuilder<SelectiveDisclosureCubit,
SelectiveDisclosureState>(
builder: (context, state) {
return MyGradientButton(
onPressed: () => present(
context: context,
selectedSDIndexInJWT: state.selectedSDIndexInJWT,
uri: widget.uri,
),
text: l10n.credentialPickPresent,
);
},
),
),
),
Expand Down Expand Up @@ -218,10 +221,8 @@ class _SelectiveDisclosurePickViewState
if (encryptedValues != null) {
var newJwt = '${encryptedValues[0]}~';

encryptedValues.removeAt(0);

for (final index in selectedSDIndexInJWT) {
newJwt = '$newJwt${encryptedValues[index]}~';
newJwt = '$newJwt${encryptedValues[index + 1]}~';
}

// Key Binding JWT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@ class MissingCredentialsCubit extends Cubit<MissingCredentialsState> {
credentialField['filter'] as Map<String, dynamic>,
);

final credentialName =
filter.pattern ?? filter.contains!.containsConst;
final credentialName = filter.pattern ??
filter.contains?.containsConst ??
filter.containsConst;

if (credentialName == null) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Invalid presentatoin Definition.',
},
);
}

final CredentialSubjectType? credentialSubjectType =
getCredTypeFromName(credentialName);
Expand Down
18 changes: 0 additions & 18 deletions lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,24 +628,6 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
}
}

final clientMetadata = state.uri!.queryParameters['client_metadata'];
if (clientMetadata != null) {
final clientMetadataMap =
jsonDecode(clientMetadata) as Map<String, dynamic>;
final data =
clientMetadataMap['subject_syntax_types_supported'] as List<dynamic>;
if (!data.contains('did:key')) {
if (isSecurityHigh) {
throw ResponseMessage(
data: {
'error': 'unsupported_response_type',
'error_description': 'The subject syntax type is not supported.',
},
);
}
}
}

final redirectUri = state.uri!.queryParameters['redirect_uri'];
final responseUri = state.uri!.queryParameters['response_uri'];
final clientId = state.uri!.queryParameters['client_id'];
Expand Down
6 changes: 0 additions & 6 deletions lib/dashboard/src/view/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ class _DashboardViewState extends State<DashboardView> {
context.read<QRCodeScanCubit>().deepLink();
context.read<BeaconCubit>().startBeacon();

final splashCubit = context.read<SplashCubit>();
if (splashCubit.state.isNewVersion) {
WhatIsNewDialog.show(context);
splashCubit.disableWhatsNewPopUp();
}

// check if enterprise account is suspended or not
if (context.read<ProfileCubit>().state.model.profileType ==
ProfileType.enterprise) {
Expand Down
Loading

0 comments on commit b51204f

Please sign in to comment.