initializeSDK static method

Future<void> initializeSDK({
  1. required String authDomain,
  2. required String authClientId,
  3. required String loginRedirectUri,
  4. required String logoutRedirectUri,
  5. List<String> scopes = _defaultScopes,
  6. String? audience,
})

Implementation

static Future<void> initializeSDK(
    {required String authDomain,
    required String authClientId,
    required String loginRedirectUri,
    required String logoutRedirectUri,
    List<String> scopes = _defaultScopes,
    String? audience}) async {
  _config = AuthConfig(
      authDomain: authDomain,
      authClientId: authClientId,
      loginRedirectUri: loginRedirectUri,
      logoutRedirectUri: logoutRedirectUri,
      scopes: scopes,
      audience: audience);

  secure_store.FlutterSecureStorage secureStorage =
      const secure_store.FlutterSecureStorage(
          aOptions: secure_store.AndroidOptions());

  Future<List<int>> getSecureKey(
      secure_store.FlutterSecureStorage secureStorage) async {
    var containsEncryptionKey =
        await secureStorage.containsKey(key: 'encryptionKey');
    if (!containsEncryptionKey) {
      var key = Hive.generateSecureKey();
      await secureStorage.write(
          key: 'encryptionKey', value: base64UrlEncode(key));
      return key;
    } else {
      final base64 = await secureStorage.read(key: 'encryptionKey');
      return base64Url.decode(base64!);
    }
  }

  final secureKey = await getSecureKey(secureStorage);

  final path = await getTemporaryDirectory();

  await Store.init(HiveAesCipher(secureKey), path.path);
}