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 Apr 18, 2024
2 parents 55a8a7e + ed5d1a1 commit 0f831cb
Show file tree
Hide file tree
Showing 85 changed files with 1,943 additions and 650 deletions.
103 changes: 103 additions & 0 deletions lib/app/shared/constants/constants_json.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ignore_for_file: lines_longer_than_80_chars

import 'package:altme/app/app.dart';

abstract class ConstantsJson {
static const tezosAssociatedAddressCredentialManifestJson = <String, dynamic>{
'id': 'TezosAssociatedAddress',
Expand Down Expand Up @@ -249,4 +251,105 @@ abstract class ConstantsJson {
],
'presentation_definition': <String, dynamic>{},
};

static const walletMetadataForIssuers = <String, dynamic>{
'vp_formats_supported': {
'jwt_vp': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'jwt_vc': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'jwt_vp_json': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'jwt_vc_json': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'vc+sd-jwt': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'ldp_vp': {
'proof_type': [
'JsonWebSignature2020',
'Ed25519Signature2018',
'EcdsaSecp256k1Signature2019',
'RsaSignature2018',
],
},
'ldp_vc': {
'proof_type': [
'JsonWebSignature2020',
'Ed25519Signature2018',
'EcdsaSecp256k1Signature2019',
'RsaSignature2018',
],
},
},
'grant_types': ['authorization code', 'pre-authorized_code'],
'redirect_uris': [Parameters.redirectUri],
'subject_syntax_types_supported': ['did:key', 'did:jwk'],
'subject_syntax_types_discriminations': [
'did:key:jwk_jcs-pub',
'did:ebsi:v1',
],
'response_types_supported': ['vp_token', 'id_token'],
'token_endpoint_auth_method_supported': [
'none',
'client_id',
'client_secret_post',
'client_secret_basic',
'client_secret_jwt',
],
'credential_offer_endpoint_supported': [
'openid-credential-offer://',
'haip://',
],
'contacts': ['[email protected]'],
};

static const walletMetadataForVerifiers = <String, dynamic>{
'wallet_name': Parameters.walletName,
'key_type': 'software',
'user_authentication': 'system_biometry',
'authorization_endpoint': Parameters.authorizationEndPoint,
'grant_types_supported': ['authorization_code', 'pre-authorized_code'],
'response_types_supported': ['vp_token', 'id_token'],
'vp_formats_supported': {
'jwt_vc_json': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'jwt_vp_json': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'vc+sd-jwt': {
'alg_values_supported': ['ES256', 'ES256K', 'EdDSA'],
},
'ldp_vp': {
'proof_type': [
'JsonWebSignature2020',
'Ed25519Signature2018',
'EcdsaSecp256k1Signature2019',
'RsaSignature2018',
],
},
'ldp_vc': {
'proof_type': [
'JsonWebSignature2020',
'Ed25519Signature2018',
'EcdsaSecp256k1Signature2019',
'RsaSignature2018',
],
},
},
'client_id_schemes_supported': [
'did',
'redirect_uri',
'x509_san_dns',
'verifier_attestation',
],
'request_object_signing_alg_values_supported': ['ES256', 'ES256K'],
'presentation_definition_uri_supported': true,
'contacts': ['[email protected]'],
};
}
19 changes: 19 additions & 0 deletions lib/app/shared/constants/parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,29 @@ class Parameters {
static const String clientId = 'urn:altme:0001';
static const int maxEntries = 3;

// 'Talao'for talao
static const String appName = 'Altme';

// false for talao
static const bool supportDefiCompliance = true;
// false for talao
static const bool supportCryptoAccountOwnershipInDiscoverForEnterpriseMode =
true;
// false for talao
static const bool showChainbornCard = false;
// false for talao
static const bool showTezotopiaCard = false;

//'https://app.talao.co/app/download/authorize' for Talao
static const String redirectUri =
'https://app.altme.io/app/download/authorize';

//'https://app.talao.co/app/download/callback' for Talao
static const String authorizationEndPoint =
'https://app.altme.io/app/download/callback';

// 'talao_wallet'for talao
static const String walletName = 'altme_wallet';

static const DidKeyType didKeyTypeForEbsiV3 = DidKeyType.ebsiv3;
static const DidKeyType didKeyTypeForDefault = DidKeyType.edDSA;
Expand Down
64 changes: 54 additions & 10 deletions lib/app/shared/dio_client/dio_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import 'dart:convert';
import 'package:altme/app/app.dart';
import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:secure_storage/secure_storage.dart';
part 'logging.dart';

const _defaultConnectTimeout = Duration(minutes: 1);
const _defaultReceiveTimeout = Duration(minutes: 1);

class DioClient {
DioClient(this.baseUrl, this.dio) {
DioClient({
this.baseUrl,
required this.secureStorageProvider,
required this.dio,
}) {
if (baseUrl != null) {
dio.options.baseUrl = baseUrl!;
}

dio
..options.baseUrl = baseUrl
..options.connectTimeout = _defaultConnectTimeout
..options.receiveTimeout = _defaultReceiveTimeout
..httpClientAdapter
Expand All @@ -31,8 +39,9 @@ class DioClient {

final log = getLogger('DioClient');

final String baseUrl;
final SecureStorageProvider secureStorageProvider;
final Dio dio;
String? baseUrl;

Future<dynamic> get(
String uri, {
Expand All @@ -43,6 +52,7 @@ class DioClient {
Map<String, dynamic> headers = const <String, dynamic>{
'Content-Type': 'application/json; charset=UTF-8',
},
bool isCachingEnabled = false,
}) async {
try {
final isInternetAvailable = await isConnected();
Expand All @@ -54,13 +64,47 @@ class DioClient {

final stopwatch = Stopwatch()..start();
await getSpecificHeader(uri, headers);
final response = await dio.get<dynamic>(
uri,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
log.i('uri - $uri');

final cachedData = await secureStorageProvider.get(uri);
dynamic response;

if (!isCachingEnabled || cachedData == null) {
response = await dio.get<dynamic>(
uri,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
} else {
final cachedDataJson = jsonDecode(cachedData);
final expiry = int.parse(cachedDataJson['expiry'].toString());

final isExpired = DateTime.now().millisecondsSinceEpoch > expiry;

if (isExpired) {
response = await dio.get<dynamic>(
uri,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
} else {
/// directly return cached data
/// returned here to avoid the caching override everytime
final response = await cachedDataJson['data'];
log.i('Time - ${stopwatch.elapsed}');
return response;
}
}
final expiry =
DateTime.now().add(const Duration(days: 2)).millisecondsSinceEpoch;

final value = {'expiry': expiry, 'data': response.data};
await secureStorageProvider.set(uri, jsonEncode(value));

log.i('Time - ${stopwatch.elapsed}');
return response.data;
} on FormatException catch (_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ enum ResponseString {
RESPONSE_STRING_successfullyAddedEnterpriseAccount,
RESPONSE_STRING_successfullyUpdatedEnterpriseAccount,
RESPONSE_STRING_thisWalleIsAlreadyConfigured,
RESPONSE_STRING_invalidStatus,
RESPONSE_STRING_statusListInvalidSignature,
RESPONSE_STRING_theWalletIsSuspended,
}
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ extension ResponseStringX on ResponseString {

case ResponseString.RESPONSE_STRING_thisWalleIsAlreadyConfigured:
return globalMessage.RESPONSE_STRING_thisWalleIsAlreadyConfigured;

case ResponseString.RESPONSE_STRING_invalidStatus:
return globalMessage.RESPONSE_STRING_invalidStatus;

case ResponseString.RESPONSE_STRING_statusListInvalidSignature:
return globalMessage.RESPONSE_STRING_statusListInvalidSignature;

case ResponseString.RESPONSE_STRING_theWalletIsSuspended:
return globalMessage.RESPONSE_STRING_theWalletIsSuspended;
}
}
}
1 change: 1 addition & 0 deletions lib/app/shared/enum/status/credential_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ enum CredentialStatus {
active,
expired,
invalidSignature,
statusListInvalidSignature,
invalidStatus,
unknown,
noStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
return const PolygonAssociatedAddressWidget();
} else if (this == CredentialSubjectType.binanceAssociatedWallet) {
return const BinanceAssociatedAddressWidget();
} else if (this == CredentialSubjectType.tezosAssociatedWallet) {
return const TezosAssociatedAddressWidget();
} else if (this == CredentialSubjectType.fantomAssociatedWallet) {
return const FantomAssociatedAddressWidget();
}
Expand Down
4 changes: 4 additions & 0 deletions lib/app/shared/extension/credential_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ extension CredentialStatusExtension on CredentialStatus {
return l10n.unknown;
case CredentialStatus.invalidStatus:
return l10n.statusIsInvalid;
case CredentialStatus.statusListInvalidSignature:
return l10n.statuslListSignatureFailed;
case CredentialStatus.noStatus:
return '';
}
Expand All @@ -33,6 +35,7 @@ extension CredentialStatusExtension on CredentialStatus {
case CredentialStatus.pending:
case CredentialStatus.unknown:
case CredentialStatus.invalidSignature:
case CredentialStatus.statusListInvalidSignature:
case CredentialStatus.noStatus:
return Icons.circle_outlined;
}
Expand All @@ -47,6 +50,7 @@ extension CredentialStatusExtension on CredentialStatus {
case CredentialStatus.pending:
case CredentialStatus.unknown:
case CredentialStatus.invalidSignature:
case CredentialStatus.statusListInvalidSignature:
case CredentialStatus.noStatus:
return Theme.of(context).colorScheme.inactiveColor;
}
Expand Down
Loading

0 comments on commit 0f831cb

Please sign in to comment.