Skip to content

Commit

Permalink
unplug config caching
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed May 31, 2024
1 parent 221d6e8 commit a89d278
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1758,34 +1758,35 @@ class OIDC4VC {

dio.options.headers = headers;

if (isCachingEnabled) {
final secureStorageProvider = getSecureStorage;
final cachedData = await secureStorageProvider.get(uri);
if (cachedData == null) {
response = await dio.get<dynamic>(uri);
} 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);
} else {
/// directly return cached data
/// returned here to avoid the caching override everytime
final response = await cachedDataJson['data'];
return response;
}
}
}
// if (isCachingEnabled) {
// final secureStorageProvider = getSecureStorage;
// final cachedData = await secureStorageProvider.get(uri);
// if (cachedData == null) {
// response = await dio.get<dynamic>(uri);
// } 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);
// } else {
// /// directly return cached data
// /// returned here to avoid the caching override everytime
// final response = await cachedDataJson['data'];
// return response;
// }
// }
// }
// temporary deactiviting this caching du to issue with
// flutter_secure_storage on ios #2657
// final expiry =
// DateTime.now().add(const Duration(days: 2)).millisecondsSinceEpoch;

// final value = {'expiry': expiry, 'data': response.data};
// await secureStorageProvider.set(uri, jsonEncode(value));
response = await dio.get<dynamic>(uri);

return response.data;
} on FormatException {
Expand Down

0 comments on commit a89d278

Please sign in to comment.