Skip to content

Commit

Permalink
Merge branch 'main' into main_android
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Sep 14, 2023
2 parents db0e629 + ea33b0b commit d23628f
Show file tree
Hide file tree
Showing 30 changed files with 742 additions and 258 deletions.
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.13.3",
"flutterSdkVersion": "3.13.4",
"flavors": {}
}
18 changes: 16 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,31 @@ target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end


$iOSVersion = '14.0'

post_install do |installer|
# Google's ML Kit Barcode Scanning setup
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end

installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# polygonid-setup
# polygonid-setup
target.build_configurations.each do |config|
cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)']
cflags << '-fembed-bitcode'
config.build_settings['OTHER_CFLAGS'] = cflags
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion

# Google's ML Kit Barcode Scanning setup
if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
end
if target.name == "Pods-Runner"
puts "Updating #{target.name} OTHER_LDFLAGS"
Expand Down
2 changes: 2 additions & 0 deletions lib/app/shared/constants/secure_storage_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class SecureStorageKeys {
static const String userPINCodeForAuthentication =
'userPINCodeForAuthentication';

static const String isSecurityLow = 'isSecurityLow';

static const String pinCode = 'pinCode';
static const String data = 'data';
static const String rsaKeyJson = 'RSAKeyJson';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,6 @@ enum ResponseString {
RESPONSE_STRING_youcanSelectOnlyXCredential,
RESPONSE_STRING_theCredentialIsNotReady,
RESPONSE_STRING_theCredentialIsNoMoreReady,
RESPONSE_STRING_theRequestIsRejected,
RESPONSE_STRING_userPinIsIncorrect,
}
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@ extension ResponseStringX on ResponseString {

case ResponseString.RESPONSE_STRING_theCredentialIsNoMoreReady:
return globalMessage.RESPONSE_STRING_theCredentialIsNoMoreReady;

case ResponseString.RESPONSE_STRING_theRequestIsRejected:
return globalMessage.RESPONSE_STRING_theRequestIsRejected;

case ResponseString.RESPONSE_STRING_userPinIsIncorrect:
return globalMessage.RESPONSE_STRING_userPinIsIncorrect;
}
}
}
30 changes: 26 additions & 4 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ List<int> sortedPublcJwk(Map<String, dynamic> privateKey) {
bool isUriAsValueValid(List<String> keys) =>
keys.contains('response_type') &&
keys.contains('client_id') &&
keys.contains('redirect_uri') &&
keys.contains('nonce');

bool isPolygonIdUrl(String url) =>
Expand Down Expand Up @@ -577,9 +576,9 @@ Future<String> getHost({

return Uri.parse(decodedResponse['redirect_uri'].toString()).host;
} else {
return Uri.parse(
uri.queryParameters['redirect_uri'] ?? '',
).host;
final String? redirectUri = getRedirectUri(uri);
if (redirectUri == null) return '';
return Uri.parse(redirectUri).host;
}
}
}
Expand Down Expand Up @@ -628,3 +627,26 @@ Future<(String?, String)> getIssuerAndPreAuthorizedCode({

return (preAuthorizedCode, issuer);
}

bool isURL(String input) {
final Uri? uri = Uri.tryParse(input);
return uri != null && uri.hasScheme;
}

String? getRedirectUri(Uri uri) {
final clientId = uri.queryParameters['client_id'] ?? '';
final redirectUri = uri.queryParameters['redirect_uri'];

/// if redirectUri is not provided and client_id is url then
/// redirectUri = client_id
if (redirectUri == null) {
final isUrl = isURL(clientId);
if (isUrl) {
return clientId;
} else {
return null;
}
} else {
return redirectUri;
}
}
2 changes: 2 additions & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,6 @@ class GlobalMessage {
l10n.theCredentialIsNotReady;
String get RESPONSE_STRING_theCredentialIsNoMoreReady =>
l10n.theCredentialIsNoMoreReady;
String get RESPONSE_STRING_theRequestIsRejected => l10n.theRequestIsRejected;
String get RESPONSE_STRING_userPinIsIncorrect => l10n.userPinIsIncorrect;
}
10 changes: 10 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,16 @@ class ResponseMessage with MessageHandler {
.localise(
context,
);

case ResponseString.RESPONSE_STRING_theRequestIsRejected:
return ResponseString.RESPONSE_STRING_theRequestIsRejected.localise(
context,
);

case ResponseString.RESPONSE_STRING_userPinIsIncorrect:
return ResponseString.RESPONSE_STRING_userPinIsIncorrect.localise(
context,
);
}
}
return '';
Expand Down
15 changes: 10 additions & 5 deletions lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,18 @@ class CredentialsCubit extends Cubit<CredentialsState> {

if (iteratedCredentialSubjectModel.credentialSubjectType ==
CredentialSubjectType.emailPass) {
/// check if email is same
if (email ==
(iteratedCredentialSubjectModel as EmailPassModel).email) {
await deleteById(
id: storedCredential.id,
showMessage: false,
);
break;
/// format should be same ldp_vc or jwt_vc
if ((credential.jwt == null && storedCredential.jwt == null) ||
(credential.jwt != null && storedCredential.jwt != null)) {
await deleteById(
id: storedCredential.id,
showMessage: false,
);
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'view/security_page.dart';
116 changes: 116 additions & 0 deletions lib/dashboard/drawer/wallet_security/security/view/security_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/profile/profile.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

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

static Route<dynamic> route() {
return MaterialPageRoute<void>(
builder: (_) => const SecurityPage(),
settings: const RouteSettings(name: '/SecurityPage'),
);
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return BasePage(
title: l10n.security,
useSafeArea: true,
scrollView: false,
titleAlignment: Alignment.topCenter,
padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall),
titleLeading: const BackLeadingButton(),
body: BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
padding: const EdgeInsets.all(Sizes.spaceSmall),
margin: const EdgeInsets.all(Sizes.spaceXSmall),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.cardHighlighted,
borderRadius: const BorderRadius.all(
Radius.circular(Sizes.largeRadius),
),
),
child: Column(
children: [
ListTile(
onTap: () {
context
.read<ProfileCubit>()
.setSecurityLevel(isSecurityLow: true);
},
shape: const RoundedRectangleBorder(
side: BorderSide(
color: Color(0xFFDDDDEE),
width: 0.5,
),
),
title: Text(
l10n.lowSecurity,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
),
),
trailing: Icon(
state.model.isSecurityLow
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
size: Sizes.icon2x,
color: Theme.of(context).colorScheme.onPrimary,
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: Sizes.spaceSmall,
vertical: Sizes.spaceXSmall,
),
child: Divider(
height: 0,
color: Theme.of(context).colorScheme.borderColor,
),
),
ListTile(
onTap: () {
context
.read<ProfileCubit>()
.setSecurityLevel(isSecurityLow: false);
},
shape: const RoundedRectangleBorder(
side: BorderSide(
color: Color(0xFFDDDDEE),
width: 0.5,
),
),
title: Text(
l10n.highSecurity,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
),
),
trailing: Icon(
!state.model.isSecurityLow
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
size: Sizes.icon2x,
color: Theme.of(context).colorScheme.onPrimary,
),
),
],
),
),
],
);
},
),
);
}
}
1 change: 1 addition & 0 deletions lib/dashboard/drawer/wallet_security/wallet_security.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'recovery_key/recovery_key.dart';
export 'security/security.dart';
export 'wallet_security/wallet_security.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ class WalletSecurityView extends StatelessWidget {
}
},
),
DrawerItem(
title: l10n.security,
onTap: () {
Navigator.of(context).push<void>(SecurityPage.route());
},
),
],
),
),
Expand Down
17 changes: 17 additions & 0 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ class ProfileCubit extends Cubit<ProfileState> {
.get(SecureStorageKeys.userConsentForVerifierAccess)) ==
'true';

final isSecurityLowValue =
await secureStorageProvider.get(SecureStorageKeys.isSecurityLow);

final isSecurityLow =
isSecurityLowValue == null || isSecurityLowValue == 'true';

final userPINCodeForAuthenticationValue = await secureStorageProvider
.get(SecureStorageKeys.userPINCodeForAuthentication);
final userPINCodeForAuthentication =
Expand Down Expand Up @@ -139,6 +145,7 @@ class ProfileCubit extends Cubit<ProfileState> {
userConsentForVerifierAccess: userConsentForVerifierAccess,
userPINCodeForAuthentication: userPINCodeForAuthentication,
oidc4vcType: oidc4vcType,
isSecurityLow: isSecurityLow,
);

emit(
Expand Down Expand Up @@ -240,6 +247,11 @@ class ProfileCubit extends Cubit<ProfileState> {
profileModel.oidc4vcType.name,
);

await secureStorageProvider.set(
SecureStorageKeys.isSecurityLow,
profileModel.isSecurityLow.toString(),
);

emit(
state.copyWith(
model: profileModel,
Expand Down Expand Up @@ -310,6 +322,11 @@ class ProfileCubit extends Cubit<ProfileState> {
await update(profileModel);
}

Future<void> setSecurityLevel({bool isSecurityLow = true}) async {
final profileModel = state.model.copyWith(isSecurityLow: isSecurityLow);
await update(profileModel);
}

@override
Future<void> close() async {
_timer?.cancel();
Expand Down
6 changes: 6 additions & 0 deletions lib/dashboard/profile/models/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ProfileModel extends Equatable {
this.companyWebsite = '',
this.jobTitle = '',
required this.oidc4vcType,
required this.isSecurityLow,
});

factory ProfileModel.fromJson(Map<String, dynamic> json) =>
Expand All @@ -47,6 +48,7 @@ class ProfileModel extends Equatable {
userPINCodeForAuthentication: true,
tezosNetwork: TezosNetwork.mainNet(),
oidc4vcType: OIDC4VCType.EBSIV3,
isSecurityLow: true,
);

final String firstName;
Expand All @@ -66,6 +68,7 @@ class ProfileModel extends Equatable {
final bool userConsentForVerifierAccess;
final bool userPINCodeForAuthentication;
final OIDC4VCType oidc4vcType;
final bool isSecurityLow;

@override
List<Object> get props => [
Expand All @@ -86,6 +89,7 @@ class ProfileModel extends Equatable {
userConsentForVerifierAccess,
userPINCodeForAuthentication,
oidc4vcType,
isSecurityLow,
];

Map<String, dynamic> toJson() => _$ProfileModelToJson(this);
Expand All @@ -108,6 +112,7 @@ class ProfileModel extends Equatable {
bool? userConsentForVerifierAccess,
bool? userPINCodeForAuthentication,
OIDC4VCType? oidc4vcType,
bool? isSecurityLow,
}) {
return ProfileModel(
firstName: firstName ?? this.firstName,
Expand All @@ -130,6 +135,7 @@ class ProfileModel extends Equatable {
userPINCodeForAuthentication:
userPINCodeForAuthentication ?? this.userPINCodeForAuthentication,
oidc4vcType: oidc4vcType ?? this.oidc4vcType,
isSecurityLow: isSecurityLow ?? this.isSecurityLow,
);
}
}
Loading

0 comments on commit d23628f

Please sign in to comment.