authenticate static method
Implementation
static Future<void> authenticate(bool isLocal, String middlePageCanisterId,
String appHost, String appScheme) async {
try {
_newIdentity = await Ed25519KeyIdentity.generate(null);
Ed25519PublicKey publicKey = _newIdentity!.getPublicKey();
var publicKeyDer = publicKey.toDer();
publicKeyString = bytesToHex(publicKeyDer);
final url = isLocal
? 'http://localhost:4943?sessionkey=$publicKeyString&host=$appHost&scheme=$appScheme&canisterId=$middlePageCanisterId'
: 'https://$middlePageCanisterId.icp0.io?sessionkey=$publicKeyString&host=$appHost&scheme=$appScheme';
await launchUrl(
Uri.parse(url),
customTabsOptions: CustomTabsOptions(
colorSchemes: CustomTabsColorSchemes.defaults(
toolbarColor: Colors.blue,
navigationBarColor: Colors.black,
),
shareState: CustomTabsShareState.on,
urlBarHidingEnabled: true,
showTitle: true,
),
safariVCOptions: const SafariViewControllerOptions(
preferredBarTintColor: Colors.blue,
preferredControlTintColor: Colors.black,
barCollapsingEnabled: true,
entersReaderIfAvailable: false,
),
);
} catch (e) {
log('Error: $e');
}
}