Skip to content

Commit

Permalink
feat: replace onboard impl with at_auth.onboard
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Oct 9, 2023
1 parent b90f09c commit beaccd8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 46 deletions.
9 changes: 5 additions & 4 deletions packages/at_onboarding_cli/example/onboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import 'package:at_onboarding_cli/at_onboarding_cli.dart';
import 'package:at_utils/at_logger.dart';

Future<void> main() async {
AtSignLogger.root_level = 'info';
final atSign = '@alice';
AtSignLogger.root_level = 'finest';
final atSign = '@alice🛠';
AtOnboardingPreference atOnboardingPreference = AtOnboardingPreference()
..namespace =
'wavi' // unique identifier that can be used to identify data from your app
..cramSecret =
'b26455a907582760ebf35bc4847de549bc41c24b25c8b1c58d5964f7b4f8a43bc55b0e9a601c9a9657d9a8b8bbc32f88b4e38ffaca03c8710ebae1b14ca9f364'
..atKeysFilePath = '/home/murali/atsign/alice_key.atKeys'
..atKeysFilePath = '/home/murali/.atsign/@alice🛠_key.atKeys'
..appName = 'wavi'
..deviceName = 'pixel'
..rootDomain = 'vip.ve.atsign.zone';
..rootDomain = 'vip.ve.atsign.zone'
..enableEnrollmentDuringOnboard = true;
AtOnboardingService? onboardingService =
AtOnboardingServiceImpl(atSign, atOnboardingPreference);
await onboardingService.onboard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:io';

import 'package:at_chops/at_chops.dart';
import 'package:at_client/at_client.dart';
import 'package:at_onboarding_cli/src/onboard/at_security_keys.dart';
import 'package:at_auth/at_auth.dart';
import 'package:at_onboarding_cli/src/util/at_onboarding_exceptions.dart';
import 'package:at_server_status/at_server_status.dart';
import 'package:at_utils/at_utils.dart';
Expand Down Expand Up @@ -118,35 +118,22 @@ class AtOnboardingServiceImpl implements AtOnboardingService {
// check and wait till secondary exists
await _waitUntilSecondaryCreated(atLookUpImpl);

if (await isOnboarded()) {
throw AtActivateException('atsign is already activated');
}

try {
// authenticate into secondary using cram secret
_isAtsignOnboarded = (await atLookUpImpl
.authenticate_cram(atOnboardingPreference.cramSecret));

if (_isAtsignOnboarded) {
logger.info('Cram authentication successful');
await _activateAtsign(atLookUpImpl);
} else {
throw AtActivateException(
'Cram authentication failed. Please check the cram key'
' and try again \n(or) contact [email protected]');
}
} on Exception catch (e) {
if (e.toString().contains('Auth failed')) {
throw AtActivateException(
'Cram authentication failed. Please check the cram key'
' and try again \n(or) contact [email protected]');
}
logger.severe('Caught exception: $e');
} on Error catch (e, trace) {
logger.severe('Caught error: $e $trace');
} finally {
await atLookUpImpl.close();
}
// if (await isOnboarded()) {
// throw AtActivateException('atsign is already activated');
// }

var atAuthService = AtAuthImpl();
var atOnboardingRequest = AtOnboardingRequest(_atSign);
atOnboardingRequest.rootDomain = atOnboardingPreference.rootDomain;
atOnboardingRequest.rootPort = atOnboardingPreference.rootPort;
atOnboardingRequest.enableEnrollment =
atOnboardingPreference.enableEnrollmentDuringOnboard;
atOnboardingRequest.appName = atOnboardingPreference.appName;
atOnboardingRequest.deviceName = atOnboardingPreference.deviceName;
atOnboardingRequest.publicKeyId = atOnboardingPreference.publicKeyId;
var atOnboardingResponse = await atAuthService.onboard(
atOnboardingRequest, atOnboardingPreference.cramSecret!);
print('****atOnboardingResponse: $atOnboardingResponse');
return _isAtsignOnboarded;
}

Expand Down
12 changes: 0 additions & 12 deletions packages/at_onboarding_cli/lib/src/onboard/at_security_keys.dart

This file was deleted.

12 changes: 12 additions & 0 deletions packages/at_onboarding_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ dependencies:
http: ^0.13.6
at_chops: ^1.0.4

dependency_overrides:
at_auth:
git:
url: https://github.com/atsign-foundation/at_libraries
path: packages/at_auth
ref: at_auth_new_package
at_chops:
git:
url: https://github.com/atsign-foundation/at_libraries
path: packages/at_chops
ref: at_auth_new_package

dev_dependencies:
lints: ^2.1.0
test: ^1.24.2
Expand Down

0 comments on commit beaccd8

Please sign in to comment.