forked from LinusU/flutter_web_auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
2 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,15 @@ | ||
// | ||
// Generated file. Do not edit. | ||
// | ||
|
||
// ignore_for_file: lines_longer_than_80_chars | ||
|
||
import 'package:flutter_web_auth/src/flutter_web_auth_web.dart'; | ||
|
||
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | ||
|
||
// ignore: public_member_api_docs | ||
void registerPlugins(Registrar registrar) { | ||
FlutterWebAuthPlugin.registerWith(registrar); | ||
registrar.registerMessageHandler(); | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
<!DOCTYPE html> | ||
<title>Authentication complete</title> | ||
<p>Authentication is complete. If this does not happen automatically, please | ||
close the window. | ||
<script> | ||
window.opener.postMessage({ | ||
'flutter-web-auth': window.location.href | ||
}, window.location.origin); | ||
window.close(); | ||
</script> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- | ||
If you are serving your web app in a path other than the root, change the | ||
href value below to reflect the base path you are serving from. | ||
The path provided below has to start and end with a slash "/" in order for | ||
it to work correctly. | ||
Fore more details: | ||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base | ||
--> | ||
<base href="/"> | ||
|
||
<meta charset="UTF-8"> | ||
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> | ||
<meta name="description" content="A new Flutter project."> | ||
|
||
<!-- iOS meta tags & icons --> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
<meta name="apple-mobile-web-app-title" content="example"> | ||
<link rel="apple-touch-icon" href="icons/Icon-192.png"> | ||
|
||
<!-- Favicon --> | ||
<link rel="icon" type="image/png" href="favicon.png"/> | ||
|
||
<title>example</title> | ||
<link rel="manifest" href="manifest.json"> | ||
</head> | ||
<body> | ||
<!-- This script installs service_worker.js to provide PWA functionality to | ||
application. For more information, see: | ||
https://developers.google.com/web/fundamentals/primers/service-workers --> | ||
<script> | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('flutter-first-frame', function () { | ||
navigator.serviceWorker.register('flutter_service_worker.js'); | ||
}); | ||
} | ||
</script> | ||
<script src="main.dart.js" type="application/javascript"></script> | ||
</body> | ||
</html> |
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,23 @@ | ||
{ | ||
"name": "example", | ||
"short_name": "example", | ||
"start_url": ".", | ||
"display": "standalone", | ||
"background_color": "#0175C2", | ||
"theme_color": "#0175C2", | ||
"description": "A new Flutter project.", | ||
"orientation": "portrait-primary", | ||
"prefer_related_applications": false, | ||
"icons": [ | ||
{ | ||
"src": "icons/Icon-192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "icons/Icon-512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
] | ||
} |
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,42 @@ | ||
import 'dart:async'; | ||
import 'dart:html'; | ||
import 'dart:js'; | ||
|
||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | ||
|
||
class FlutterWebAuthPlugin { | ||
static void registerWith(Registrar registrar) { | ||
final MethodChannel channel = MethodChannel( | ||
'flutter_web_auth', const StandardMethodCodec(), registrar.messenger); | ||
final FlutterWebAuthPlugin instance = FlutterWebAuthPlugin(); | ||
channel.setMethodCallHandler(instance.handleMethodCall); | ||
} | ||
|
||
Future<dynamic> handleMethodCall(MethodCall call) async { | ||
switch (call.method) { | ||
case 'authenticate': | ||
final String url = call.arguments['url']; | ||
return _authenticate(url); | ||
default: | ||
throw PlatformException( | ||
code: 'Unimplemented', | ||
details: "The flutter_web_auth plugin for web doesn't implement " | ||
"the method '${call.method}'"); | ||
} | ||
} | ||
|
||
static Future<String> _authenticate(String url) async { | ||
context.callMethod('open', [url]); | ||
await for (MessageEvent messageEvent in window.onMessage) { | ||
if (messageEvent.origin == Uri.base.origin) { | ||
final flutterWebAuthMessage = messageEvent.data['flutter-web-auth']; | ||
if (flutterWebAuthMessage is String) { | ||
return flutterWebAuthMessage; | ||
} | ||
} | ||
} | ||
throw new PlatformException( | ||
code: 'error', message: 'Iterable window.onMessage is empty'); | ||
} | ||
} |
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