diff --git a/packages/firebase_app_check/firebase_app_check_web/lib/firebase_app_check_web.dart b/packages/firebase_app_check/firebase_app_check_web/lib/firebase_app_check_web.dart index ddf8d2db28ee..e028a042348e 100644 --- a/packages/firebase_app_check/firebase_app_check_web/lib/firebase_app_check_web.dart +++ b/packages/firebase_app_check/firebase_app_check_web/lib/firebase_app_check_web.dart @@ -157,7 +157,7 @@ class FirebaseAppCheckWeb extends FirebaseAppCheckPlatform { @override Future getToken(bool forceRefresh) async { return convertWebExceptions>(() async { - app_check_interop.AppCheckTokenResult result = + app_check_interop.AppCheckTokenResultJsImpl result = await _delegate!.getToken(forceRefresh); return result.token.toDart; }); @@ -166,7 +166,7 @@ class FirebaseAppCheckWeb extends FirebaseAppCheckPlatform { @override Future getLimitedUseToken() async { return convertWebExceptions>(() async { - app_check_interop.AppCheckTokenResult result = + app_check_interop.AppCheckTokenResultJsImpl result = await _delegate!.getLimitedUseToken(); return result.token.toDart; }); diff --git a/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check.dart b/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check.dart index 34d63e984274..63f261ca8fa6 100644 --- a/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check.dart +++ b/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check.dart @@ -58,22 +58,20 @@ class AppCheck extends JsObjectWrapper { isTokenAutoRefreshEnabled.toJS, ); - Future getToken(bool? forceRefresh) => - app_check_interop.getToken(jsObject, forceRefresh?.toJS).toDart.then( - (value) => value! as app_check_interop.AppCheckTokenResult, - ); + Future getToken( + bool? forceRefresh, + ) => + app_check_interop.getToken(jsObject, forceRefresh?.toJS).toDart; - Future getLimitedUseToken() => - app_check_interop.getLimitedUseToken(jsObject).toDart.then( - (value) => value! as app_check_interop.AppCheckTokenResult, - ); + Future getLimitedUseToken() => + app_check_interop.getLimitedUseToken(jsObject).toDart; JSFunction? _idTokenChangedUnsubscribe; - StreamController? + StreamController? get idTokenChangedController => _idTokenChangedController; - StreamController? + StreamController? // ignore: close_sinks _idTokenChangedController; @@ -92,11 +90,14 @@ class AppCheck extends JsObjectWrapper { return 'no-op'; } - Stream onTokenChanged(String appName) { + Stream onTokenChanged( + String appName, + ) { final appCheckWindowsKey = _appCheckWindowsKey(appName); unsubscribeWindowsListener(appCheckWindowsKey); if (_idTokenChangedController == null) { - final nextWrapper = ((app_check_interop.AppCheckTokenResult result) { + final nextWrapper = + ((app_check_interop.AppCheckTokenResultJsImpl result) { _idTokenChangedController!.add(result); }).toJS; @@ -119,8 +120,8 @@ class AppCheck extends JsObjectWrapper { removeWindowsListener(appCheckWindowsKey); } - _idTokenChangedController = - StreamController.broadcast( + _idTokenChangedController = StreamController< + app_check_interop.AppCheckTokenResultJsImpl>.broadcast( onListen: startListen, onCancel: stopListen, sync: true, diff --git a/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check_interop.dart b/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check_interop.dart index c80074972e3f..a72b2cf0c2a4 100644 --- a/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check_interop.dart +++ b/packages/firebase_app_check/firebase_app_check_web/lib/src/interop/app_check_interop.dart @@ -21,14 +21,14 @@ external AppCheckJsImpl initializeAppCheck( @JS() @staticInterop -external JSPromise /* AppCheckTokenResult */ getToken( +external JSPromise getToken( AppCheckJsImpl? appCheck, JSBoolean? forceRefresh, ); @JS() @staticInterop -external JSPromise /* AppCheckTokenResult */ getLimitedUseToken( +external JSPromise getLimitedUseToken( AppCheckJsImpl? appCheck, ); @@ -64,11 +64,7 @@ class ReCaptchaEnterpriseProvider implements ReCaptchaProvider { external factory ReCaptchaEnterpriseProvider(JSString recaptchaKey); } -@JS() -@staticInterop -abstract class AppCheckTokenResult {} - -extension AppCheckTokenResultJsImplX on AppCheckTokenResult { +extension type AppCheckTokenResultJsImpl._(JSObject _) implements JSObject { external JSString get token; } @@ -88,10 +84,6 @@ extension AppCheckOptionsJsImplX on AppCheckOptions { external ReCaptchaProvider get provider; } -@JS('AppCheck') -@staticInterop -abstract class AppCheckJsImpl {} - -extension AppCheckJsImplX on AppCheckJsImpl { +extension type AppCheckJsImpl._(JSObject _) implements JSObject { external AppJsImpl get app; } diff --git a/tests/integration_test/firebase_app_check/firebase_app_check_e2e_test.dart b/tests/integration_test/firebase_app_check/firebase_app_check_e2e_test.dart index 61950b98d28a..2046367d76b1 100644 --- a/tests/integration_test/firebase_app_check/firebase_app_check_e2e_test.dart +++ b/tests/integration_test/firebase_app_check/firebase_app_check_e2e_test.dart @@ -44,9 +44,7 @@ void main() { // Needs a debug token pasted in the Firebase console to work so we catch the exception. expect(exception, isA()); } - // This will fail until this is resolved: https://github.com/dart-lang/sdk/issues/52572 }, - skip: kIsWeb, ); test( @@ -73,9 +71,7 @@ void main() { // Needs a debug token pasted in the Firebase console to work so we catch the exception. expect(exception, isA()); } - // This will fail until this is resolved: https://github.com/dart-lang/sdk/issues/52572 }, - skip: kIsWeb, ); test(