-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1189 from atsign-foundation/verify_atsign_onboarded
fix: Add "isOnboarded" method to verify if atSign is onboarded
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
abstract class AtAuthService { | ||
/// Checks whether the atSign has been onboarded. | ||
/// Queries the keychain for the encryption public key. | ||
/// If the key is found, the atSign is considered onboarded, and true is returned. | ||
/// Otherwise, false is returned. | ||
Future<bool> isOnboarded(String atSign); | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/at_client_mobile/lib/src/auth/at_auth_service_impl.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:at_client_mobile/at_client_mobile.dart'; | ||
import 'package:at_client_mobile/src/atsign_key.dart'; | ||
|
||
class AtAuthServiceImpl implements AtAuthService { | ||
AtServiceFactory? atServiceFactory; | ||
|
||
// ignore: unused_field | ||
final String _atSign; | ||
|
||
// ignore: unused_field | ||
final AtClientPreference _atClientPreference; | ||
|
||
final KeyChainManager _keyChainManager = KeyChainManager.getInstance(); | ||
AtClientManager atClientManager = AtClientManager.getInstance(); | ||
|
||
AtAuthServiceImpl(this._atSign, this._atClientPreference); | ||
|
||
@override | ||
Future<bool> isOnboarded(String atSign) async { | ||
AtsignKey? atsignKey = await _keyChainManager.readAtsign(name: atSign); | ||
if (atsignKey == null) { | ||
return false; | ||
} | ||
if (atsignKey.encryptionPublicKey == null || | ||
atsignKey.encryptionPublicKey!.isEmpty) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |