-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
platform_interface_recaptcha_verifier_factory.dart
122 lines (100 loc) 路 4.06 KB
/
platform_interface_recaptcha_verifier_factory.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ignore_for_file: require_trailing_commas
// Copyright 2020 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 'dart:async';
import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
/// A enum to represent a reCAPTCHA widget size.
enum RecaptchaVerifierSize {
/// Renders the widget in the default size.
normal,
/// Renders the widget in a smaller, compact size.
compact,
}
/// A enum to represent a reCAPTCHA widget theme.
enum RecaptchaVerifierTheme {
/// Renders the widget in a light theme (white-gray background).
light,
/// Renders the widget in a dark theme (black-gray background).
dark,
}
/// Called on successful completion of the reCAPTCHA widget.
typedef RecaptchaVerifierOnSuccess = void Function();
/// Called when the reCAPTCHA widget errors (such as a network error).
typedef RecaptchaVerifierOnError = void Function(
FirebaseAuthException exception,
);
/// Called when the time to complete the reCAPTCHA widget expires.
typedef RecaptchaVerifierOnExpired = void Function();
/// A factory platform class for Recaptcha Verifier implementations.
abstract class RecaptchaVerifierFactoryPlatform extends PlatformInterface {
/// Creates a new [RecaptchaVerifierFactoryPlatform] instance.
RecaptchaVerifierFactoryPlatform() : super(token: _token);
static RecaptchaVerifierFactoryPlatform? _instance;
static final Object _token = Object();
/// Returns an assigned delegate instance.
///
/// On platforms which do not support Recaptcha Verifier, an
/// [UnimplementedError] will be thrown.
static RecaptchaVerifierFactoryPlatform get instance {
if (_instance == null) {
throw UnimplementedError('RecaptchaVerifier is not implemented');
}
return _instance!;
}
/// Sets a factory delegate as the current [RecaptchaVerifierFactoryPlatform]
/// instance.
static set instance(RecaptchaVerifierFactoryPlatform instance) {
PlatformInterface.verify(instance, _token);
_instance = instance;
}
/// Ensures that a delegate class extends [RecaptchaVerifierFactoryPlatform].
static void verifyExtends(RecaptchaVerifierFactoryPlatform instance) {
PlatformInterface.verify(instance, _token);
}
/// Returns the assigned factory delegate.
dynamic get delegate {
throw UnimplementedError('delegate is not implemented');
}
/// Returns a [RecaptchaVerifierFactoryPlatform] delegate instance.
///
/// Underlying implementations can use this method to create the underlying
/// implementation of a Recaptcha Verifier.
RecaptchaVerifierFactoryPlatform delegateFor({
required FirebaseAuthPlatform auth,
String? container,
RecaptchaVerifierSize size = RecaptchaVerifierSize.normal,
RecaptchaVerifierTheme theme = RecaptchaVerifierTheme.light,
RecaptchaVerifierOnSuccess? onSuccess,
RecaptchaVerifierOnError? onError,
RecaptchaVerifierOnExpired? onExpired,
}) {
throw UnimplementedError('delegateFor() is not implemented');
}
/// The application verifier type. For a reCAPTCHA verifier, this is
/// 'recaptcha'.
String get type {
throw UnimplementedError('type is not implemented');
}
/// Clears the reCAPTCHA widget from the page and destroys the current
/// instance.
void clear() {
throw UnimplementedError('clear() is not implemented');
}
/// Pre-renders the reCAPTCHA widget on the page.
///
/// Returns a Future that resolves with the reCAPTCHA widget ID.
///
/// If you do not pre-render the widget, it will be rendered before the
/// sign-in request is called. Depending on the network connection speed, this
/// may cause a small delay before the widget is displayed.
Future<int> render() async {
throw UnimplementedError('render() is not implemented');
}
/// Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA
/// token.
Future<String> verify() async {
throw UnimplementedError('verify() is not implemented');
}
}