-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
platform_interface_firebase_app_check.dart
102 lines (85 loc) 路 3.74 KB
/
platform_interface_firebase_app_check.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ignore_for_file: require_trailing_commas
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:firebase_app_check_platform_interface/firebase_app_check_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:meta/meta.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import '../method_channel/method_channel_firebase_app_check.dart';
abstract class FirebaseAppCheckPlatform extends PlatformInterface {
/// The [FirebaseApp] this instance was initialized with.
FirebaseAppCheckPlatform({this.appInstance}) : super(token: _token);
/// Create an instance using [app] using the existing implementation
factory FirebaseAppCheckPlatform.instanceFor({required FirebaseApp app}) {
return FirebaseAppCheckPlatform.instance
.delegateFor(app: app)
.setInitialValues();
}
/// The [FirebaseApp] this instance was initialized with.
@protected
final FirebaseApp? appInstance;
/// Create an instance using [app]
static final Object _token = Object();
/// Returns the [FirebaseApp] for the current instance.
FirebaseApp get app {
if (appInstance == null) {
return Firebase.app();
}
return appInstance!;
}
static FirebaseAppCheckPlatform? _instance;
/// The current default [FirebaseAppCheckPlatform] instance.
///
/// It will always default to [FirebaseAppCheckPlatform]
/// if no other implementation was provided.
static FirebaseAppCheckPlatform get instance {
return _instance ??= MethodChannelFirebaseAppCheck.instance;
}
/// Sets the [FirebaseAppCheckPlatform.instance]
static set instance(FirebaseAppCheckPlatform instance) {
PlatformInterface.verify(instance, _token);
_instance = instance;
}
/// Activates the Firebase App Check service.
///
/// On web, provide the reCAPTCHA v3 Site Key which can be found in the
/// Firebase Console. For more information, see
/// [the Firebase Documentation](https://firebase.google.com/docs/app-check/web?authuser=0).
Future<void> activate(
{String? webRecaptchaSiteKey, bool? androidDebugProvider}) {
throw UnimplementedError('activate() is not implemented');
}
/// Get the current App Check token. Attaches to the most recent in-flight
/// request if one is present. Returns null if no token is present and no
/// token requests are in-flight.
///
/// If `forceRefresh` is true, will always try to fetch a fresh token. If
/// false, will use a cached token if found in storage.
Future<String?> getToken(bool forceRefresh) async {
throw UnimplementedError('getToken() is not implemented');
}
/// If true, the SDK automatically refreshes App Check tokens as needed.
Future<void> setTokenAutoRefreshEnabled(bool isTokenAutoRefreshEnabled) {
throw UnimplementedError('setTokenAutoRefreshEnabled() is not implemented');
}
/// Registers a listener to changes in the token state.
Stream<String?> get onTokenChange {
throw UnimplementedError('tokenChanges() is not implemented');
}
/// Enables delegates to create new instances of themselves if a none default
/// [FirebaseApp] instance is required by the user.
@protected
FirebaseAppCheckPlatform delegateFor({required FirebaseApp app}) {
throw UnimplementedError('delegateFor() is not implemented');
}
/// Sets any initial values on the instance.
///
/// Platforms with Method Channels can provide constant values to be available
/// before the instance has initialized to prevent any unnecessary async
/// calls.
@protected
FirebaseAppCheckPlatform setInitialValues() {
throw UnimplementedError('setInitialValues() is not implemented');
}
}