Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class FirebaseAppCheckWeb extends FirebaseAppCheckPlatform {
@override
Future<String?> getToken(bool forceRefresh) async {
return convertWebExceptions<Future<String?>>(() async {
app_check_interop.AppCheckTokenResult result =
app_check_interop.AppCheckTokenResultJsImpl result =
await _delegate!.getToken(forceRefresh);
return result.token.toDart;
});
Expand All @@ -166,7 +166,7 @@ class FirebaseAppCheckWeb extends FirebaseAppCheckPlatform {
@override
Future<String> getLimitedUseToken() async {
return convertWebExceptions<Future<String>>(() async {
app_check_interop.AppCheckTokenResult result =
app_check_interop.AppCheckTokenResultJsImpl result =
await _delegate!.getLimitedUseToken();
return result.token.toDart;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,20 @@ class AppCheck extends JsObjectWrapper<app_check_interop.AppCheckJsImpl> {
isTokenAutoRefreshEnabled.toJS,
);

Future<app_check_interop.AppCheckTokenResult> getToken(bool? forceRefresh) =>
app_check_interop.getToken(jsObject, forceRefresh?.toJS).toDart.then(
(value) => value! as app_check_interop.AppCheckTokenResult,
);
Future<app_check_interop.AppCheckTokenResultJsImpl> getToken(
bool? forceRefresh,
) =>
app_check_interop.getToken(jsObject, forceRefresh?.toJS).toDart;

Future<app_check_interop.AppCheckTokenResult> getLimitedUseToken() =>
app_check_interop.getLimitedUseToken(jsObject).toDart.then(
(value) => value! as app_check_interop.AppCheckTokenResult,
);
Future<app_check_interop.AppCheckTokenResultJsImpl> getLimitedUseToken() =>
app_check_interop.getLimitedUseToken(jsObject).toDart;

JSFunction? _idTokenChangedUnsubscribe;

StreamController<app_check_interop.AppCheckTokenResult>?
StreamController<app_check_interop.AppCheckTokenResultJsImpl>?
get idTokenChangedController => _idTokenChangedController;

StreamController<app_check_interop.AppCheckTokenResult>?
StreamController<app_check_interop.AppCheckTokenResultJsImpl>?
// ignore: close_sinks
_idTokenChangedController;

Expand All @@ -92,11 +90,14 @@ class AppCheck extends JsObjectWrapper<app_check_interop.AppCheckJsImpl> {
return 'no-op';
}

Stream<app_check_interop.AppCheckTokenResult> onTokenChanged(String appName) {
Stream<app_check_interop.AppCheckTokenResultJsImpl> 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;

Expand All @@ -119,8 +120,8 @@ class AppCheck extends JsObjectWrapper<app_check_interop.AppCheckJsImpl> {
removeWindowsListener(appCheckWindowsKey);
}

_idTokenChangedController =
StreamController<app_check_interop.AppCheckTokenResult>.broadcast(
_idTokenChangedController = StreamController<
app_check_interop.AppCheckTokenResultJsImpl>.broadcast(
onListen: startListen,
onCancel: stopListen,
sync: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ external AppCheckJsImpl initializeAppCheck(

@JS()
@staticInterop
external JSPromise /* AppCheckTokenResult */ getToken(
external JSPromise<AppCheckTokenResultJsImpl> getToken(
AppCheckJsImpl? appCheck,
JSBoolean? forceRefresh,
);

@JS()
@staticInterop
external JSPromise /* AppCheckTokenResult */ getLimitedUseToken(
external JSPromise<AppCheckTokenResultJsImpl> getLimitedUseToken(
AppCheckJsImpl? appCheck,
);

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<FirebaseException>());
}
// This will fail until this is resolved: https://github.com/dart-lang/sdk/issues/52572
},
skip: kIsWeb,
);

test(
Expand All @@ -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<FirebaseException>());
}
// This will fail until this is resolved: https://github.com/dart-lang/sdk/issues/52572
},
skip: kIsWeb,
);

test(
Expand Down
Loading