Skip to content

Commit

Permalink
Default value for Custom profile #2414
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Feb 19, 2024
1 parent cfcad1b commit 21f9be8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 50 deletions.
32 changes: 13 additions & 19 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,6 @@ class ProfileCubit extends Cubit<ProfileState> {
jsonDecode(customProfileSettingJsonString)
as Map<String, dynamic>;

if (customProfileSettingMap['selfSovereignIdentityOptions']
['customOidc4vcProfile']['client_id'] ==
null) {
customProfileSettingMap['selfSovereignIdentityOptions']
['customOidc4vcProfile']['client_id'] = Parameters.clientId;
}
if (customProfileSettingMap['selfSovereignIdentityOptions']
['customOidc4vcProfile']['client_secret'] ==
null) {
customProfileSettingMap['selfSovereignIdentityOptions']
['customOidc4vcProfile']['client_secret'] = randomString(12);
}

profileSetting = ProfileSetting.fromJson(customProfileSettingMap);
} else {
profileSetting = ProfileSetting.initial();
Expand Down Expand Up @@ -546,15 +533,22 @@ class ProfileCubit extends Cubit<ProfileState> {
),
);
case ProfileType.custom:
final String customProfileSettingBackup =
final String? customProfileSettingBackup =
await secureStorageProvider.get(
SecureStorageKeys.customProfileSettings,
) ??
jsonEncode(state.model.profileSetting);
final customProfileSetting = ProfileSetting.fromJson(
json.decode(customProfileSettingBackup) as Map<String, dynamic>,
SecureStorageKeys.customProfileSettings,
);

late ProfileSetting customProfileSetting;

if (customProfileSettingBackup == null) {
customProfileSetting = ProfileSetting.initial();
} else {
final profileJson =
json.decode(customProfileSettingBackup) as Map<String, dynamic>;

customProfileSetting = ProfileSetting.fromJson(profileJson);
}

await update(
state.model.copyWith(
profileType: profileType,
Expand Down
34 changes: 11 additions & 23 deletions lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,21 @@ class DiscoverCardsOptions extends Equatable {
required this.displayGender,
required this.displayDefi,
required this.displayHumanity,
required this.displayHumanityJwt,
required this.displayOver13,
required this.displayOver15,
required this.displayOver18,
required this.displayOver18Jwt,
required this.displayOver50,
required this.displayEmailPass,
required this.displayEmailPassJwt,
required this.displayPhonePass,
required this.displayPhonePassJwt,
required this.displayVerifiableId,
required this.displayVerifiableIdJwt,
required this.displayExternalIssuer,
required this.displayChainborn,
required this.displayTezotopia,
this.displayOver18Jwt = false,
this.displayVerifiableIdJwt = true,
this.displayEmailPass = true,
this.displayEmailPassJwt = true,
this.displayPhonePass = true,
this.displayPhonePassJwt = true,
this.displayChainborn = false,
this.displayTezotopia = false,
this.displayHumanityJwt = true,
});

factory DiscoverCardsOptions.fromJson(Map<String, dynamic> json) =>
Expand All @@ -196,22 +196,13 @@ class DiscoverCardsOptions extends Equatable {
factory DiscoverCardsOptions.initial() => const DiscoverCardsOptions(
displayDefi: true,
displayHumanity: true,
displayHumanityJwt: true,
displayOver13: false,
displayOver15: false,
displayOver18: true,
displayOver18Jwt: false,
displayOver21: false,
displayOver50: false,
displayChainborn: false,
displayTezotopia: false,
displayVerifiableId: true,
displayVerifiableIdJwt: true,
displayOver65: false,
displayEmailPass: true,
displayEmailPassJwt: true,
displayPhonePass: true,
displayPhonePassJwt: true,
displayAgeRange: false,
displayGender: false,
displayExternalIssuer: [],
Expand Down Expand Up @@ -542,8 +533,8 @@ class CustomOidc4VcProfile extends Equatable {
required this.securityLevel,
required this.siopv2Draft,
required this.clientType,
required this.clientId,
required this.clientSecret,
this.clientId = Parameters.clientId,
this.clientSecret = 'FGbzMrvUpeFr',
this.vcFormatType = VCFormatType.jwtVcJson,
this.proofHeader = ProofHeaderType.kid,
});
Expand All @@ -556,13 +547,11 @@ class CustomOidc4VcProfile extends Equatable {
oidc4vciDraft: OIDC4VCIDraftType.draft11,
oidc4vpDraft: OIDC4VPDraftType.draft18,
scope: false,
proofHeader: ProofHeaderType.kid,
securityLevel: false,
siopv2Draft: SIOPV2DraftType.draft12,
clientType: ClientType.did,
clientId: Parameters.clientId,
clientSecret: randomString(12),
vcFormatType: VCFormatType.jwtVcJson,
);

factory CustomOidc4VcProfile.fromJson(Map<String, dynamic> json) =>
Expand Down Expand Up @@ -658,7 +647,6 @@ class SettingsMenu extends Equatable {
displayDeveloperMode: true,
displayHelpCenter: true,
displayProfile: true,
displaySelfSovereignIdentity: true,
);

final bool displayDeveloperMode;
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@ packages:
dependency: "direct main"
description:
name: dio
sha256: "797e1e341c3dd2f69f2dad42564a6feff3bfb87187d05abb93b9609e6f1645c3"
sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8"
url: "https://pub.dev"
source: hosted
version: "5.4.0"
version: "5.4.1"
dio_cache_interceptor:
dependency: transitive
description:
Expand Down Expand Up @@ -779,10 +779,10 @@ packages:
dependency: "direct main"
description:
name: file_saver
sha256: "8ffd91ae9f543c5ebbfec71a814ee5aa9e21176d31335133308abf63f4c42e8a"
sha256: f66e1732f6dbbef256171a18b8e493cd360c4fd53b2098eb48d47a6fd676f9ee
url: "https://pub.dev"
source: hosted
version: "0.2.9"
version: "0.2.10"
file_selector_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -1413,10 +1413,10 @@ packages:
dependency: transitive
description:
name: local_auth_android
sha256: "54e9c35ce52c06333355ab0d0f41e4c06dbca354b23426765ba41dfb1de27598"
sha256: "3bcd732dda7c75fcb7ddaef12e131230f53dcc8c00790d0d6efb3aa0fbbeda57"
url: "https://pub.dev"
source: hosted
version: "1.0.36"
version: "1.0.37"
local_auth_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -2441,10 +2441,10 @@ packages:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: a932c3a8082e118f80a475ce692fde89dc20fddb24c57360b96bc56f7035de1f
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
Expand Down

0 comments on commit 21f9be8

Please sign in to comment.