authenticated method
Checks if the current access token is valid.
This method verifies whether there is a valid access token stored locally and whether that token has not expired. It does not make a network request to verify the token with the server.
Returns
A Future that resolves to true if there is a valid access token, false otherwise
Example
final isAuth = await calljmp.integrity.authenticated();
if (isAuth) {
print('Device has valid access token');
} else {
print('Device needs to perform attestation');
}
Implementation
Future<bool> authenticated() async {
final token = await CalljmpStore.instance.get(CalljmpStoreKey.accessToken);
if (token != null) {
final result = AccessToken.tryParse(token);
if (result.data != null) {
return result.data!.isValid;
}
}
return false;
}