-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement external browser for iOS marketplace
move lnurl auth outside the browser
- Loading branch information
1 parent
12f1baf
commit 97215cb
Showing
3 changed files
with
66 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:breez/bloc/lnurl/lnurl_actions.dart'; | ||
import 'package:breez/bloc/lnurl/lnurl_bloc.dart'; | ||
import 'package:breez/bloc/lnurl/lnurl_model.dart'; | ||
import 'package:breez/bloc/marketplace/vendor_model.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
Future<String> handleLNUrlAuth(VendorModel vendor, LNUrlBloc lnurlBloc, String responsdID) async { | ||
Uri uri = Uri.parse(vendor.url); | ||
var response = await http.get(uri); | ||
if (response.statusCode != 200 && response.statusCode != 201) { | ||
throw Exception("Failed to call ${vendor.displayName} API"); | ||
} | ||
Map<String, dynamic> decoded = json.decode(response.body); | ||
String lnUrl = decoded[responsdID] as String; | ||
Fetch fetchAction = Fetch(lnUrl); | ||
lnurlBloc.actionsSink.add(fetchAction); | ||
var fetchResponse = await fetchAction.future; | ||
if (fetchResponse.runtimeType != AuthFetchResponse) { | ||
throw "Invalid URL"; | ||
} | ||
AuthFetchResponse authResponse = fetchResponse as AuthFetchResponse; | ||
var action = Login(authResponse, jwt: true); | ||
lnurlBloc.actionsSink.add(action); | ||
return await action.future; | ||
} |
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